goodsInfo.js 64.3 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183
var t = require("../../../utils/util.js"),
    ut = t,
    e = require("../../../utils/common.js"),
    a = require("../../../utils/wxParse/wxParse.js"),
    s = getApp(),
    i = s.request,
    rq = i,
    oo = s.globalData,
    o = s.globalData.setting,
    os = o;
//评价加载更多
var more = function(e) {
      return e && e.__esModule ? e : {
        default: e
      };
    }(require("../../../utils/LoadMore.js")),
    n = new more.default();
var utils = require('../../../utils/util.js');
var regeneratorRuntime = require('../../../utils/runtime.js');

Page({
  data: {
    start_stop: 2, //秒杀开始 结束 的控制(1正在进行,2即将开始)
    color_type: 0, //线条控制
    color_type_one: 0,
    color_type_two: 1,

    gid: "",
    stoid: o.stoid,
    url: o.url,
    resourceUrl: o.h5_url,  //公众号那边的图片文件域名
    iurl: o.imghost,
    defaultAvatar: o.resourceUrl + "/static/images/user68.jpg",
	
    data: null,
    content: "", //商品详情

    gallery: null, //图片滚动
    is_collect: 0,
    collect_id: 0,
    cartGoodsNum: 0,
    specSelect: 0,
    optionItemId: 0,
    goodsInputNum: 1,
    openSpecModal: !1,
 
    activeCategoryId: 0,
    supportPageScroll: !1,
    address: {
      address: "",
      district: 0
    },
    shipping: "",
    shippingCost: 0,
    enterAddressPage: !1,
    categories: [{
      name: "商品",
      id: 0
    }, {
      name: "详情",
      id: 1
    }, {
      name: "评论",
      id: 2
    }],
    activeCategoryId2: 0,
    categories2: [{
      name: "商品详情",
      id: 0
    }, {
      name: "规格参数",
      id: 1
    }],
    activeCategoryId3: 1,
    categories3: [{
      name: "全部",
      id: 1,
      num: 0
    },
      {
        name: "有图",
        id: 5,
        num: 0
      },

      {
        name: "好评",
        id: 2,
        num: 0
      }, {
        name: "中评",
        id: 3,
        num: 0
      }, {
        name: "差评",
        id: 4,
        num: 0
      },
    ],

    select: {
      price: 0,
      stock: 0,
      specName: "",
      activity: null
    },

  
    //门店相关
    ismend: 0,
    is_sec_mend: 0,
    sto_sele_name: "", //选中的门店名称
    sto_sele_id: "", //选中的门店id
	sto_sele_keyid:'', //选中的门店线下
    sto_sele_distr: "", //选择的门店的配送方式
    is_show_sto_cat: 1, //是否显示门店分类
    only_pk: null,
    all_sto: null,
    sec_sto: null, //选择了的门店分类
    pickpu_list: null, //读出的所有门店list
    def_pickpu_list: null, //一开始5个门店list
    sec_pick_index: 0, //第二级门店选择ID
    fir_pick_index: 0, //第一级门店选择ID
    all_pick_list:null,//所有的门店先记录起来

    //联系电话
    mobile: '',
    //商品的活动类型 0普通  1秒杀 2团购 3优惠  4 积分购  6拼单
    timer: [],

    //商品的购买次数
    prom_buy_num: -1,
    g_buy_num: null,
  
    //会员自己的购买的拼单商品的情况
    //购买的订单
    buy_order: null,
    //1加入购物车  2立即购买
    openSpecModal_ind: 0,

    //---计时器开关----
    is_timer: 1,
    isshow: 0,
    bconfig: null, //基础配置

    //会员分享的头像
    share_head: "",
    share_goods_img: "",

    //----------视频图片data参数---------
    current: 0, //图片计数
    swiperCurrent: 0, //轮播的下标
    hiddenn: 0, //控制轮播计数显示

    screenWidth: 0,
    canvasHidden: 1,

    //--推荐--
    store_config: null,
    is_show_pl: 0, //是否品类
    is_show_pp: 0, //是否品牌
    is_show_gb: 0, //是否国别
    is_closecoupon: 0,


    select_store: 0, //选择更多
    index: 1,
    more_store: 0, //选择门店
    sort_store: 0, //门店分类
    choice_sort_store: 0, //选择分类门店
    new_user: 0, //新用户

    def_pick_store: null, // 默认的门店
    fir_def_store:null,  //客户默认的门店的
    lat: null, //维度
    lon: null, //经度

    is_get_local_ok: 0, //获取坐标是否完成
    region_name: "门店分类", //区域的名字
    is_gps: 1,
    open_ind_store: 0, //哪里打开的门店列表的控制属性
    default_store: {}, //创建添加默认门店地址的对象

    comments_no_more:0,
  
    is_collect_load:0,     //是不是处理
    is_newsales_rules:0,   //是否开启最新的门店规则,此时会新读门店,当点击选择门店时会触发读取线下库存
    sales_rules:1,	       //默认是线上销售

    wait_for_user_store:null,
	poster:null,      //自定义海报
	share_b_img:'',   //自定义分享的背景	
	showPoster: false,	
	hui_condition:null,
	sto_sele_name_1:'',//分享的门店名称
	
  },

  //------初始化加载----------
  onLoad: function(t) {
	 
	console.log("--服务卡项--");  
	console.log(t);  
   
    var ee = this,
        that = ee,
        th = ee,
        gid = t.goods_id,
        first_leader=t.first_leader;
	
	//-- 自定义海报 --
	getApp().request.promiseGet("/api/weshop/goods/poster/page", {	
		data:{store_id:os.stoid, type:1, is_use:1}
	}).then(res=>{
		if(res.data.code==0 && res.data.data && res.data.data.pageData && res.data.data.pageData[0]){			
			var poster_data=res.data.data.pageData[0];
			var json_str=poster_data.jsonStr;			
			if(json_str){
				var json_data=JSON.parse(json_str);		
				if(json_data.bg_img){				
					//-- 把图片那到本地 --
					wx.getImageInfo({
					  src:json_data.bg_img,
					  success: function(res) {
					    var path= res.path;
						th.setData({share_b_img:path})
					  },
					  fail: function(res) {}
					});
				}								
				th.setData({poster:json_data})												
			}			
		}
	})	
				
    //---获取手机地址坐标--
    //--如果tg_id是空的话,分享回来--
    if (gid == undefined || gid == null || gid == "") {
      var  gid_str = decodeURIComponent(t.scene);
      gid_str=gid_str.split("_");
      gid=gid_str[0];
      if(gid_str.length>1){
        first_leader=gid_str[1];
      }	  
	  //-- 如果有room_id的获取 --
	  if(gid_str.length>2 && gid_str[2]){
		  room_id=gid_str[2];
		  room_user_share=1;		  
	  }
	  
    }
    ee.setData({ gid: gid});
    if(first_leader){ 	
      getApp().globalData.first_leader=first_leader;
      //调用接口判断是不是会员
      getApp().request.promiseGet("/api/weshop/shoppingGuide/get/"+os.stoid+"/"+first_leader,{}).then(res=>{
        if(res.data.code==0){
          getApp().globalData.guide_id=res.data.data.id;
        }
      })
    }
    var c_guide_id=t.c_guide_id;
    if(c_guide_id){
      th.data.c_guide_id=c_guide_id;
    }
	
	getApp().getConfig(function(e) {
		ee.setData({sto_sele_name_1:e.store_name})
	})

    //----获取系统参数-----
    getApp().getConfig2(function(e) {
     
      var json_d = JSON.parse(e.switch_list);
      ee.setData({
        store_config: e,
        sys_switch:json_d,
      });
     
      
      th.requestCardNum(), wx.pageScrollTo && th.setData({
        supportPageScroll: !0
      });

     
    },1);

    //获取用户设备信息,屏幕宽度
    wx.getSystemInfo({
      success: res => {
        that.setData({
          screenWidth: res.screenWidth
        })
      }
    });
	
    //获取用户的默认门店
    getApp().get_user_store(function(e) { 
	  if(!e) {
        th.data.fir_def_store={}; //赋值空对象
        return false;
      }
      var ee=JSON.parse(JSON.stringify(e));
      //--定时器推迟一下--
      setTimeout(function () {
        if(!th.data.data) return false;
        var ser_card=th.data.data;
        //--如果默认门店不在等级卡的默认们店以内
        if(ser_card.storageId!=null && ser_card.storageId!=""  &&  ser_card.storageId.indexOf(ee.keyid)==-1){
		   ee.is_no_dis=1;
        }

        var appd=getApp().globalData;
        var w_time = setInterval(function() {
          if (that.data.is_get_local_ok == 0) return false;
          clearInterval(w_time);
          var distance = null;
          var e=JSON.parse(JSON.stringify(ee));

          //如果有开启近距离的话,同时距离优不一样了
          if (that.data.lat != null) {
            //如果经纬度有变化的话
            if( appd.lat==that.data.lat && appd.lon==that.data.lon  && e.distance>0 ){
              that.data.fir_def_store=e;
              that.setData({
                def_pick_store: e,
                sto_sele_name: e.pickup_name,
                sto_sele_id: e.pickup_id,
                sto_sele_distr: e.distr_type,
				sto_sele_keyid:e.keyid,
              })
            }else{
              //要用接口是获取距离,js的计算不准
              getApp().request.promiseGet("/api/weshop/pickup/list",{
                data:{store_id:os.stoid,pickup_id:e.pickup_id,lat:th.data.lat,lon: th.data.lon},
              }).then(res=>{
                if(res.data.code==0){
                  e=res.data.data.pageData[0];
                  if (e){
					e.is_no_dis=ee.is_no_dis;
                    appd.pk_store=e;
                    that.data.fir_def_store=e;
                    that.setData({
                      def_pick_store: e,
                      sto_sele_name: e.pickup_name,
                      sto_sele_id: e.pickup_id,
                      sto_sele_distr: e.distr_type,
					  sto_sele_keyid:e.keyid,
                    })
                  }

                }
              })
            }

            //e.distance = distance;
            appd.lat=that.data.lat;
            appd.lon=that.data.lon;

          }else{
            if (e) {
              e.distance = null;
              that.data.fir_def_store=e;
              that.setData({
                def_pick_store: e,
                sto_sele_name: e.pickup_name,
                sto_sele_id: e.pickup_id,
                sto_sele_distr: e.distr_type,
				sto_sele_keyid:e.keyid,
              })
            }
          }
        }, 500)
      },700)

    });
	 
  },
  //------------程序初始化入口-------------
  async init(gid) {},

  //---展示---
  onShow: function() {
    var that=this;
    this.data.is_timer = 1;
    var ee = this,gid = this.data.gid, i = getApp().request;
	this.wait_for_store_config();

    i.get("/api/weshop/serviceCard/get/" + o.stoid + "/" + ee.data.gid, {
      failRollback: !0,
      success: function(t) {
        if (t.data.code == 0) {
								
					that.setData({
						'data.goods_name': t.data.data.serviceName,
						'data.shop_price': t.data.data.money,
						'data.validDays': t.data.data.validDays,
						'data.serviceContent': t.data.data.serviceContent,
						'data.image_url': t.data.data.imgUrl,
						'data.goods_id': t.data.data.id,
						'data.id': t.data.data.id,
						'data.sales_sum': t.data.data.sales_sum,
						'data.storageId':t.data.data.storageId,
						'data.service_sn':t.data.data.serviceSn,
					});
								
					
					//-----商品详情---
					if(!t.data.data.serviceContent) t.data.data.serviceContent="  ";
					a.wxParse("content", "html", t.data.data.serviceContent, ee, 6);
					e.wxParseAddFullImageUrl(ee, "content");
														
					//获取重表
				    getApp().promiseGet("/api/weshop/serviceItem/list",{
						data:{store_id:o.stoid,service_id:t.data.data.id}
					}).then(res=>{
						if(res.data.code==0){
							var list=res.data.data;
							that.setData({service_list:list})
						}				
					})	
					
									

        } else {
					wx.showModal({
						title: t.data.msg,
						showCancel: !1,
						complete: function() {
							wx.navigateBack();
						}
					});
				};
			}
    });
    this.data.enterAddressPage && (this.data.enterAddressPage = !1);
	this.get_sto();

  },
  enterAddress: function() {
    this.data.enterAddressPage = !0, wx.navigateTo({
      url: "/pages/user/address_list/address_list?operate=selectAddress"
    });
  },
  
  onUnload: function() {
	  for(var i = 1; i < 100; i++) {
	    clearInterval(i);
	  }
  },
  onHide: function() {
    this.data.is_timer = 0;
    for(var i = 1; i < 100; i++) {
      clearInterval(i);
    }
  },
  //----------三个选项按钮-----------
  tabClick: function(t) {
    var e = t.currentTarget.id;
    this.setData({
      activeCategoryId: e
    }), 1 == e ? this.tabGoodsContent() : 2 == e && this.tabComment();
  },
  tabClick2: function(t) {
    this.setData({
      activeCategoryId2: t.currentTarget.id
    });
  },

  tabClick3: function(t) {
    var e = this;
    if (t.currentTarget.id != this.data.activeCategoryId3) {
      e.data.c_curr_p = 1;
      this.setData({
        activeCategoryId3: t.currentTarget.id,
        comments: null,comments_no_more:0,get_c:0,
      });
      this.requestComments_new();
    }
  },

  doScrollTop: function() {
    wx.pageScrollTo({
      scrollTop: 0
    });
  },

  tabComment: function() {
    this.setData({
      activeCategoryId: 2,comments_no_more:0,get_c:0
    }), this.data.comments || this.requestComments_new();
  },

  //商品详情的时候调用
  tabGoodsContent: function() {
    var th = this,
        i = getApp().request;
    this.setData({
      activeCategoryId: 1
    });
  },

 
  //------------加入购物车--------------
  addCart: function(t) {
    var th = this;
    var ind = t.currentTarget.dataset.openSpecModal_ind;
    var action= t.currentTarget.dataset.action;
    if(!ind)  ind = t.currentTarget.dataset.openspecmodal_ind;
    
	th.setData({
      open_ind_store: ind
    });
	
	if(action=="buy"){
		//--------------此时操作的数据------------
		var newd = {
		  id: th.data.data.id,
		  goods_num: th.data.goodsInputNum,
		  pick_id: th.data.sto_sele_id,		
		  keyid: th.data.sto_sele_keyid,		
		};	  
		newd['pick_name'] = th.data.sto_sele_name;		
		newd['guide_id'] = getApp().globalData.guide_id;
		newd['guide_type']=0;
		th.buyNow(newd);
	}else{

        var newd = {
            service_id: th.data.data.id,
            service_sn:th.data.data.service_sn,
            service_name:th.data.data.goods_name,
            goods_num: th.data.goodsInputNum,
            pick_id: th.data.sto_sele_id,
            user_id:oo.user_id,
            store_id:os.stoid,
            money:th.data.data.shop_price
        };
        if(getApp().globalData.guide_id){
            newd['guide_id'] = getApp().globalData.guide_id;
            newd['guide_type']=0;
        }

        //----先看会员在购物车中是否加入了该商品-----
        getApp().request.get("/api/weshop/cartService/page", {
            data: {
                store_id: os.stoid,
                user_id: oo.user_id,
                service_id: th.data.data.id,
                pick_id: th.data.sto_sele_id,
            },
            success: function(re) {

                //-------如果购物车中有相关的数据---------
                if (re.data.data.total > 0) {
                    var item = re.data.data.pageData[0];
                    var updata = {
                        id: item.id,
                        goods_num: th.data.goodsInputNum + item.goods_num,
                        money: th.data.data.shop_price,
                        store_id: os.stoid,
                    };

                    if (getApp().globalData.guide_id) {
                        updata['guide_id'] = getApp().globalData.guide_id;
                        updata['guide_type'] = 1;
                    }
                    getApp().request.put("/api/weshop/cartService/update", {
                        data: updata,
                        success: function(t) {
                            getApp().my_warnning('加入购物车成功', 1, th, 450);
                            var c_num = th.data.cartGoodsNum + th.data.goodsInputNum;
                            th.setData({
                                cartGoodsNum: c_num
                            });
                            th.closeSpecModal();
                        }
                    });
                } else {

                    getApp().request.post("/api/weshop/cartService/save", {
                        data: newd,
                        success: function(t) {
                            getApp().my_warnning('加入购物车成功', 1, th, 450);
                            var c_num = th.data.cartGoodsNum + th.data.goodsInputNum;
                            th.setData({
                                cartGoodsNum: c_num
                            });
                            th.closeSpecModal();
                        }
                    });
                }
            }
        });

    }
	
	
  },
 
  //----------立即购买-----------
  buyNow: function(e) {   
	getApp().globalData.service_now=e;	
	wx.redirectTo({
	   url: "/packageA/pages/cart2_ser/cart2_ser",
	});	
  },
  //----------增加购买数量-----------
  addCartNum: function(t) {
    this.checkCartNum(this.data.goodsInputNum + 1);
  },
  //----------减少购买数量-----------
  subCartNum: function(t) {
    this.checkCartNum(this.data.goodsInputNum - 1);
  },
  //----------输入框输入购买数量-----------
  inputCartNum: function(t) {
    this.checkCartNum(Number(t.detail.value));
  },

  //------检查数量是不是超出限购------
  checkCartNum: function(t) {
	  if(t<=0) return false;
      var th = this;
	  th.setData({goodsInputNum:t})
  },


  closeSpecModal: function() {	  
    this.setData({
      openSpecModal: !1,
      openSpecModal_pt: !1
    });
  },
  
  openSpecModel: function(t) {
	var th=this;
    var open_store = t.currentTarget.dataset.ind;
    this.setData({
      store: 0,
      choice_sort_store: 0,
      sort_store: 0,
      open_ind_store: open_store,
    })
    //--先判断会员状态--
    var user_info = getApp().globalData.userInfo;
    if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) {
      wx.navigateTo({
        url: '/pages/togoin/togoin',
      })
      return false;
    }

    var ind = t.currentTarget.dataset.ind;
    this.setData({
      openSpecModal: !0,
      openSpecModal_ind: ind,
    });

  },
  
  //---------点击收藏和不收藏------------
  collectGoods: function() {
    var t = this,i = getApp().request;
    var user_id = s.globalData.user_id;
    if (user_id == '') {
      getApp().getUserFir(function() {});
      getApp().showWarning("未登录");
      return false;
    } else {

      if(t.data.is_collect_load) return false;
      t.data.is_collect_load=1;

      if (t.data.is_collect == 1) { //删除收藏
        i.delete("/api/weshop/goodscollect/del/" + o.stoid + "/" + t.data.collect_id, {
          success: function(e) {
            t.data.is_collect_load=0;
            if (e.data.code == 0) {
              t.setData({
                is_collect: 0,
                collect_id: 0,
              });
            }
          }
        });
      } else {
        var timestamp = Date.parse(new Date());
        timestamp = timestamp / 1000;
        var d = {
          goods_id: t.data.data.goods_id,
          user_id: s.globalData.user_id,
          store_id: o.stoid,
          add_time: timestamp,
        };
        //加入收藏夹就是导购的ID
        if(getApp().globalData.guide_id){
          d.guide_id=getApp().globalData.guide_id;
          d.guide_type=2;
        }

        i.post("/api/weshop/goodscollect/save", { //添加收藏
          data: d,
          success: function(e) {
            t.data.is_collect_load=0;
            if (e.data.code == 0) {
              t.setData({
                is_collect: 1,
                collect_id: e.data.data.collect_id,
              });
            }
          }
        });
      }
    }
  },

  //---------联系客服------------
  contactService: function() {
    s.getConfig(function(t) {
      if (t.store_tel == undefined) {
        getApp().request.get("/api/weshop/store/get/" + os.stoid, {
          isShowLoading: 1,
          data: {},
          success: function(rs) {
            getApp().globalData.config = rs.data.data;
            if (rs.data.data.store_tel == null && rs.data.data.store_tel == undefined) {
              getApp().my_warnning("商家未设置电话", 0, th);
              return false;
            }
            s.confirmBox("请联系客服:" + rs.data.data.store_tel);
          }
        })
      } else {
        s.confirmBox("请联系客服:" + t.store_tel);
      }
    });
  },
  //-------获取购物车数量----------
  requestCardNum: function() {
    var t = this;
    getApp().request.get("/api/weshop/cart/page", {
      data: {
        store_id: o.stoid,
        user_id: s.globalData.user_id,
        state:0,
        is_gift:0
      },
      success: function(e) {
        var num = 0;
        for (var i = 0; i < e.data.data.pageData.length; i++) {
          num += e.data.data.pageData[i].goods_num;
        }

        /*--
        t.setData({
          cartGoodsNum: num
        });--*/

          //-- 读取服务卡的数量 --
          getApp().promiseGet("/api/weshop/cartService/page",{
              data:{
                  store_id: s.globalData.setting.stoid,
                  user_id: s.globalData.user_id,
              }
          }).then(res=>{
              for (var i = 0; i < res.data.data.pageData.length; i++) {
                  num += res.data.data.pageData[i].goods_num;
              }
              t.setData({cartGoodsNum:num});
          })


      }
    });
  },
  
  //--点击分享事件---
  onShareAppMessage: function(t) {
	
    var th = this;
    var price = th.data.data.shop_price;
    if (th.data.prom_act) {
      price = th.data.prom_act.price;

    }
    var title= th.data.data.goods_name;
    var img=th.data.data.original_img;
    if(th.data.prom_type==6){
      title=th.data.prom_act.share_title;
      img=th.data.iurl+th.data.prom_act.share_imgurl;
    }

	
    var url="/pages/goods/goodsInfo/goodsInfo?goods_id=" + th.data.gid;
    if(getApp().globalData.user_id){
      url+="&first_leader="+getApp().globalData.user_id;
    }
	
	//-- 如果房间分享,且不是会员分享的 --	 
	if(getApp().globalData.room_id && 
	   th.data.data.goods_id==getApp().globalData.room_goods_id &&
	   !getApp().globalData.room_user_share
	   ){	
		url+="&room_id="+getApp().globalData.room_id+"&room_user_share=1";
	}
	
	var ob={
      title: price + "元  " +title,
      path:url,
      imageUrl: img,
    };	
	if(th.data.prom_type==6){		
		title+='\n'+th.data.prom_act.share_remark;
		ob.title=title;
		ob.desc=th.data.prom_act.share_remark;
	}
	
	//如果是积分购的时候
	if(th.data.prom_type==4){
		var name = th.data.prom_act.name;
		//-- 积分购的 --
		var pri0 = th.data.prom_act.addmoney;
		var integral=th.data.prom_act.integral;				 	  
		var text="";			  
		if(integral){text=integral+"积分";  }				  
		if(pri0 && integral){ text+="+";}
		if(pri0){ text+="¥"+pri0;}
			
		ob.title= text+" "+name;		
	}
	
    return ob;
	
  },

  //-----图片失败,默认图片-----
  bind_bnerr: function(e) {
    var _errImg = e.target.dataset.errorimg;
    var _errObj = {};
    _errObj[_errImg] = this.data.iurl + "/miniapp/images/default_g_img.gif";
    this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ;
  },

  //-----图片失败,默认图片-----
  bind_bnerr2: function(e) {

    var _errImg = e.target.dataset.errorimg;
    var _errObj = {};
    _errObj[_errImg] = this.data.iurl + "/miniapp/images/hui_hear_pic.png"
    this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ;
  },

 
  //---------拿出门店分类和门店------------
  get_sto(e) {
    var th = this,that=this;
    var timer_get = setInterval(function() {
      if (th.data.is_get_local_ok == 0) return false;
      var i = getApp().request;
	  if (!th.data.data) return false;	      
      var dd= {
          store_id: o.stoid,
          isstop: 0,
          pageSize: 2000
      }  
      //如果有距离的话
      if (th.data.lat != null) {
        dd.lat = th.data.lat;
        dd.lon = th.data.lon;
      }
      clearInterval(timer_get);
	  
	  //如果会员是有默认的门店话
	  if(!th.data.def_pick_store && th.data.fir_def_store){
		  th.setData({def_pick_store:th.data.fir_def_store});
	  }
	  
	  wx.showLoading({
		  title:'加载中.'
	  });
      //----------获取门店----------------
      getApp().request.promiseGet("/api/weshop/pickup/list", {
        data: dd,
      }).then(res => {
        var e = res;	 
        if (e.data.code == 0) {		
			//--普通门店排版--
			setTimeout(function(){			
			  var sto_list=th.data.data.storageId;
			  if(sto_list){
					 for (var k = 0; k < e.data.data.pageData.length; k++) {
					   var it=e.data.data.pageData[k];	 
					   if (sto_list.indexOf(it.keyid)==-1) {
						  //删除
						  e.data.data.pageData.splice(k--, 1);
					   }
					 }		 
			  }

			  //如果有开启距离的功能,没有设置默认门店,要用最近的门店作为默认门店
			  if(dd.lat && (!th.data.def_pick_store ||  JSON.stringify(th.data.def_pick_store)=='{}') && th.data.bconfig && th.data.bconfig.is_sort_storage){
				th.setData({
				  def_pick_store:e.data.data.pageData[0],
				  sto_sele_name: e.data.data.pageData[0].pickup_name,
				  sto_sele_id: e.data.data.pageData[0].pickup_id,
				  sto_sele_distr: e.data.data.pageData[0].distr_type
				});
				th.data.fir_def_store=e.data.data.pageData[0];
			  }

			  //-- 如果有默认选择门店的时候,要把默认门店放在第一位,修改不要配送方式的判断 --
			  if (th.data.def_pick_store && JSON.stringify(th.data.def_pick_store)!='{}'){
				for (var k = 0; k < e.data.data.pageData.length; k++) {
				  if (e.data.data.pageData[k].pickup_id == th.data.def_pick_store.pickup_id) {
					e.data.data.pageData.splice(k, 1); //删除
					break;
				  }
				}
				e.data.data.pageData.splice(0, 0, th.data.def_pick_store); //添加
			  }
						  	  
			  th.setData({all_pick_list:e.data.data.pageData});		  
		      th.deal_pickup(e);  
		    },800)
          
        }
      })
    }, 200)
  },

  
  //------------处理门店---------------
  deal_pickup(e){
    var th=this;
	if(!th.data.data) return false
	wx.hideLoading(); 
    //单总量超出5个的时候
    if (e.data.data.total > 5) {
      getApp().request.get("/api/weshop/storagecategory/page", {
        data: {
          store_id: o.stoid,
          is_show: 1,
          pageSize: 1000,
		  orderField:"sort",
		  orderType:'asc',
        },
        success: function(ee) {
          if (ee.data.code == 0) {
			
            if (ee.data.data && ee.data.data.pageData &&  ee.data.data.pageData.length > 0) {
              var def_arr = new Array();
              var ishas = 0;
              //-- 开始就看5个门店 --
              for (var k = 0; k < 5; k++) {
                 if (k == e.data.data.pageData.length) break;
                  def_arr.push(e.data.data.pageData[k]);
              }

              th.setData({
                def_pickpu_list: def_arr,
                pickpu_list: ee.data.data.pageData
              });
              var sto_cate = ee.data.data.pageData;
              var sto_arr = e.data.data.pageData;
              var newarr = new Array();
              var qita = new Array();

              //----要进行门店分组--------
              for (var i = 0; i < sto_arr.length; i++) {
                //找一下这个门店有没有在分类数组内
                var find2 = 0, find2name = "",sort=0;
                for (var m = 0; m < sto_cate.length; m++) {
                  if (sto_arr[i].category_id == sto_cate[m].cat_id) {
                    find2 = sto_cate[m].cat_id;
                    find2name = sto_cate[m].cat_name;
                    sort = sto_cate[m].sort;
                    break;
                  }
                }

                if (newarr.length > 0) {
                  var find = 0;
                  //如果有找到,那门店就在这个分组内,否则,分类就要排在其他
                  if (find2 != 0) {
                    for (var ii = 0; ii < newarr.length; ii++) {
                      if (sto_arr[i].category_id == newarr[ii].cat_id) {
                        newarr[ii].s_arr.push(sto_arr[i]);
                        find = 1;
                        break;
                      }
                    }
                    if (find == 0) {
                      var arr0 = new Array();
                      arr0.push(sto_arr[i]);
                      var item = {
                        cat_id: find2,
                        name: find2name,
						sort:sort,
                        s_arr: arr0
                      };
                      newarr.push(item);
                    }
                  } else {
                    qita.push(sto_arr[i]);
                  }
                } else {
                  //如果有找到,那门店就在这个分组内,否则,分类就要排在其他
                  if (find2 != 0) {
                    var arr0 = new Array();
                    arr0.push(sto_arr[i]);
                    var item = {
                      cat_id: find2,
                      name: find2name,
					  sort:sort,
                      s_arr: arr0
                    };
                    newarr.push(item);
                  } else {
                    qita.push(sto_arr[i]);
                  }
                }
              }
			  
			  //门店分类要排序下
			  function compare(property){
			      return function(a,b){
			          var value1 = a[property];
			          var value2 = b[property];
			          return value1 - value2;
			      }
			  }
			  if(newarr.length>0)
			      newarr.sort(compare("sort"));
			  
              //----安排其他的分类-----
              if (qita.length > 0) {
                var item = {
                  cat_id: -1,
                  name: "其他",
                  s_arr: qita
                };
                newarr.push(item);
              }
			  			  
              th.setData({
                is_show_sto_cat: 1,
                all_sto: newarr
              });

            } else {
              th.setData({
                is_show_sto_cat: -1,
                only_pk: e.data.data.pageData
              });
              //-----如果没有默认门店,要取第一个门店作为默认店.此时没有门店分类的情况------
              if (!th.data.def_pick_store) {
                th.setData({def_pick_store:e.data.data.pageData[0]})
              }
            }
          } else {
            th.setData({
              is_show_sto_cat: -1,
              only_pk: e.data.data.pageData
            });
            //-----如果没有默认门店,要取第一个门店作为默认店.此时没有门店分类的情况------
            if (!th.data.def_pick_store) {
              th.setData({def_pick_store:e.data.data.pageData[0]})
            }

          }
        }
      });
    } else {	
      th.setData({
        is_show_sto_cat: 0,
        only_pk: e.data.data.pageData
      });
      //-----如果没有默认门店,要取第一个门店作为默认店------
      if (!th.data.def_pick_store && th.data.bconfig && th.data.bconfig.is_sort_storage) {
        th.setData({
          def_pick_store:e.data.data.pageData[0],
          sto_sele_name: e.data.data.pageData[0].pickup_name,
          sto_sele_id: e.data.data.pageData[0].pickup_id,
          sto_sele_distr: e.data.data.pageData[0].distr_type
        })
      }
    }
  },
 
  //加载更多是靠这个函数
  onReachBottom: function() {
    if (this.data.activeCategoryId == 2){
      if(!this.data.comments_no_more)   this.requestComments_new();
    }

    var goods_list = this.selectComponent("#goods_list"); //组件的id
    if (goods_list) goods_list.get_list();
  },


  //---小于10的格式化函数----
  timeFormat(param) {
    return param < 10 ? '0' + param : param;
  },

 
  //--定义的保存图片方法,分享团---
  saveImageToPhotosAlbum: function() {
    //--先判断会员状态--
    var user_info = getApp().globalData.userInfo;
    if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) {
      //getApp().my_warnning("请先登录",0,this);
      wx.navigateTo({ url: '/pages/togoin/togoin', })
      return false;
    }

    //类型  0普通商品 1秒杀商品  2商家和会员团  3阶梯团  4阶梯团
    var type = this.data.prom_type;
    if (type == 6) type = 2;
    if (this.data.prom_act && this.data.prom_act.kttype == 3) type = 3;

    wx.showLoading({
      title: '生成中...',
    })
    var that = this,
        th = that;
    //设置画板显示,才能开始绘图
    that.setData({
      canvasHidden: false
    })

    var app = getApp();
    var unit = that.data.screenWidth / 750 * 1.35;  //基础单位,
    var path2 = that.data.data.original_img;
    var scene = th.data.gid+"";
    var user_id = getApp().globalData.user_id?getApp().globalData.user_id:0;
    if(user_id>0) {
      scene+="_"+user_id;
    }
	 //-- 如果不是会员分享过来的要分享给别人 --
	if(getApp().globalData.room_id && th.data.data.goods_id==getApp().globalData.room_goods_id && !getApp().globalData.room_user_share) {
		 //固定房间是第3个字符
		 if(!user_id) scene+="_0";
		 scene+="_"+getApp().globalData.room_id ;
	}
    ///二微码
    var path3 = os.url + "/api/wx/open/app/user/getWeAppEwm/" +
        os.stoid + "?sceneValue=" + scene + "&pageValue=pages/goods/goodsInfo/goodsInfo";

    console.log(path3);

    //读取文件成功则OK--
    wx.getImageInfo({
      src: path3,
      success: function(res) {
        //回调写法
        th.get_head_temp(th.get_goods_temp, function() {
          var vpath = res.path;
          var context = wx.createCanvasContext('share');
          //先画背景
          var pg_path = "../../../images/share/share_bg.png";
		  
			// context.fillStyle="#FFFFFF";
			// context.fillRect(0,0,554 * unit, 899 * unit);
			
		  //-- 如果有自定义海报的时候,判断背景的图片 --
		  if(th.data.share_b_img){
			  pg_path=th.data.share_b_img;
		  }	
          context.drawImage(pg_path, 0, 0, 554 * unit, 899 * unit);
		  	  
		  //-- 是自定义海报的情况下 --
		  if(th.data.poster && parseInt(th.data.poster.style)==2) {
			  //在线上分享人的情况下
			  if(parseInt(th.data.poster.show_headpic)){				 
				  //获取坐标
				  var x=parseFloat(th.data.poster.head_x)*2;
				  var y=parseFloat(th.data.poster.head_y)*2;				  
				  var x1=(x+90) *unit;
				  var y1=(y+50) *unit;		  
				  //--昵称---
				  context.setFontSize(24 * unit)
				  context.setFillStyle("black")
				  context.fillText(app.globalData.userInfo.nickname, x1, y1);
				  var width = 24 * app.globalData.userInfo.nickname.length * unit + 4 * unit;				  
				  //强烈推荐 改许程
				  var tj_path = "../../../images/share/q_tj.png";
				  context.drawImage(tj_path, x1 + width, y1-22*unit, 85 * unit, 30 * unit);
				  context.setFontSize(16 * unit)
				  context.setLineJoin('round'); //交点设置成圆角
				  context.setFillStyle("white")
				  context.fillText('强烈推荐', x1 + width+8*unit, y1-1*unit); 
						
					//context.setFillStyle("black")
					//context.setFontSize(24 * unit)
					//context.fillText(getApp().globalData.config.store_name, 40 * unit, 130 * unit);
			  }	
		  } else {
			 //--昵称---
			 context.setFontSize(24 * unit)
			 context.setFillStyle("black")
			 context.fillText(app.globalData.userInfo.nickname, 152 * unit, 76 * unit);
			 var width = 24 * app.globalData.userInfo.nickname.length * unit + 2 * unit;
			 //强烈推荐 改许程
			 var tj_path = "../../../images/share/q_tj.png";
			 context.drawImage(tj_path, 152 * unit + width, 54 * unit, 85 * unit, 30 * unit);
			 context.setFontSize(16 * unit);
			 context.setLineJoin('round'); //交点设置成圆角
			 context.setFillStyle("white");
			 context.fillText('强烈推荐', 149 * unit + width + 15 * unit, 75 * unit); 
		  }
		  
         
          //---产品名称---
          //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度
		  if(type!=4){
			 context.setFillStyle("black");
			 context.setFontSize(21.3 * unit)
			 th.draw_Text(context, th.data.data.goods_name,
			     38 * unit, 180 * unit, 200 * unit, 279 * unit, unit);
			 //------产品的价格-------
			 context.setFontSize(23 * unit)
			 context.setFillStyle("red")
			 context.fillText("¥", 416 * unit, 185 * unit);
			 context.setFontSize(31 * unit)
			 var pri0 = th.data.data.shop_price;
			 if (th.data.prom_act)
			    pri0 = th.data.prom_act.price;			 
			 pri0 = parseFloat(pri0).toFixed(2);
			 context.fillText(pri0, 438 * unit, 185 * unit); 	 
			 //---市场价划掉---
			 context.setFillStyle("gray")
			 context.setFontSize(22 * unit)
			 context.fillText("¥" + th.data.data.market_price, 426 * unit, 213 * unit);
			 context.setStrokeStyle('gray');
			 context.setLineWidth(1 * unit);
			 context.moveTo(426 * unit, 206 * unit);
			 context.lineTo(510 * unit, 206 * unit);
			 context.stroke();
			 
		  }else{
			  context.setFillStyle("black");
			  context.setFontSize(21.3 * unit)
			  th.draw_Text(context, th.data.data.goods_name,
			      38 * unit, 170 * unit, 20 * unit, 300*unit, unit);
			  //------ 产品的价格 -----			 
			  var pri0 = th.data.prom_act.addmoney;
			  var integral=th.data.prom_act.integral;				 	  
			  var text=	"";			  
			  if(integral){text=integral+"积分";  }				  
			  if(pri0 && integral){ text+="+";}
			  if(pri0){ text+="¥"+pri0;}
			  
			  if(!pri0 && !integral){ text="0积分";}			
			  context.setFillStyle("red");	  
			  context.fillText(text, 38 * unit, 235 * unit); 	 
		 			  
		  }
		  	        
          //---中间大图---
          context.drawImage(th.data.share_goods_img, 70 * unit, 250 * unit, 408 * unit, 408 * unit);
          //-------大图后面就不一样了-----------
          switch (type) {
            case 0: //普通商品的展示
			case 4: 
              //中间的几个字
			  if(th.data.poster && parseInt(th.data.poster.style)==2 ){				 		 
				 if(parseInt(th.data.poster.show_quality)){
					 var g_path = "../../../images/share/s_gou.png";
					 context.drawImage(g_path, 56 * unit, 670 * unit, 22 * unit, 22 * unit);
					 context.setFillStyle("red")
					 context.setFontSize(18 * unit)
					 context.fillText("正品保证", 84 * unit, 690 * unit);
					 
					 context.drawImage(g_path, 218 * unit, 670 * unit, 22 * unit, 22 * unit);
					 context.setFillStyle("red")
					 context.setFontSize(18 * unit)
					 context.fillText("纯实体店", 246 * unit, 690 * unit);
					 
					 context.drawImage(g_path, 388 * unit, 670 * unit, 22 * unit, 22 * unit);
					 context.setFillStyle("red")
					 context.setFontSize(18 * unit)
					 context.fillText("官方验证", 420 * unit, 690 * unit);
				 }
				  		  
			  }else{
				  var g_path = "../../../images/share/s_gou.png";
				  context.drawImage(g_path, 56 * unit, 670 * unit, 22 * unit, 22 * unit);
				  context.setFillStyle("red")
				  context.setFontSize(18 * unit)
				  context.fillText("正品保证", 84 * unit, 690 * unit);
				  
				  context.drawImage(g_path, 218 * unit, 670 * unit, 22 * unit, 22 * unit);
				  context.setFillStyle("red")
				  context.setFontSize(18 * unit)
				  context.fillText("纯实体店", 246 * unit, 690 * unit);
				  
				  context.drawImage(g_path, 388 * unit, 670 * unit, 22 * unit, 22 * unit);
				  context.setFillStyle("red")
				  context.setFontSize(18 * unit)
				  context.fillText("官方验证", 420 * unit, 690 * unit);
			  }
			  
			  
				//---画线---
				context.setLineWidth(1 * unit)
				context.moveTo(32 * unit, 710 * unit)
				context.lineTo(520 * unit, 710 * unit)
				context.stroke();
				
				//---文字---
				context.setFillStyle("black")
				context.setFontSize(22 * unit)
			  
			  if(type==0){
				    // 原来start --->				  
				    context.setFontSize(24 * unit)
				    context.fillText(th.data.sto_sele_name_1, 40 * unit, 766 * unit);	
					
					context.setFontSize(22 * unit)
				    context.fillText("优惠乐翻天,精彩就在你身边", 40 * unit, 806 * unit);
				    context.fillText("长按识别二维码,立即开始抢购", 40 * unit, 846 * unit);	
					
			  }else{				  
				    context.setFontSize(24 * unit)
				    context.fillText(th.data.sto_sele_name_1, 40 * unit, 766 * unit);					
					context.setFontSize(22 * unit)
					context.fillText("长按识别二维码", 40 * unit, 806 * unit);
					context.fillText("立即开始兑换", 40 * unit, 846 * unit);
				
														 
			  }
			 
              //---二维吗图---            
			  //-- 自定义海报 --
			  if(th.data.poster){
					   var erm_x= parseFloat(th.data.poster.ewm_x)*2; 
					   var erm_y= parseFloat(th.data.poster.ewm_y)*2; 
					   context.drawImage(vpath, erm_x * unit, erm_y * unit, 120 * unit, 120 * unit);				  
			  }else{
					   //---二维吗图---
					   context.drawImage(vpath, 410 * unit, 726 * unit, 115 * unit, 125 * unit);
			  }	
			  
              break;
            case 1: //秒杀商品的展示
              //---画线---
              context.setLineWidth(1 * unit)
              context.moveTo(32 * unit, 670 * unit)
              context.lineTo(520 * unit, 670 * unit)
              context.stroke();

              //画秒杀的图片
              var miaos_path = '../../../images/share/miao_share.png';
              context.drawImage(miaos_path, 43 * unit, 700 * unit, 222 * unit, 40 * unit);
			
			  context.setFillStyle("black")	
			  context.setFontSize(24 * unit)
			  context.fillText(th.data.sto_sele_name_1, 40 * unit, 786 * unit);				
              //---文字---
              context.setFontSize(22 * unit)
              context.setFillStyle("black")
              context.fillText("特惠好物,限时秒杀", 40 * unit, 826 * unit);
              context.fillText("长按识别二维码,立即开始抢购", 40 * unit, 866 * unit);
						
							
              //---二维吗图---
              //-- 自定义海报 --
              if(th.data.poster){
				   var erm_x= parseFloat(th.data.poster.ewm_x)*2; 
				   var erm_y= parseFloat(th.data.poster.ewm_y)*2; 
				   context.drawImage(vpath, erm_x * unit, erm_y * unit, 120 * unit, 120 * unit);				  
              }else{
				   //---二维吗图---
				   context.drawImage(vpath, 420 * unit, 726 * unit, 120 * unit, 120 * unit);
              }							  
              break;

            case 2: //会员团和商家团的展示
              //---画线---
              context.setLineWidth(1 * unit)
              context.moveTo(32 * unit, 670 * unit)
              context.lineTo(520 * unit, 670 * unit)
              context.stroke();
              //---文字---
             
			  context.setFillStyle("black")
			  context.setFontSize(24 * unit)
			  context.fillText(th.data.sto_sele_name_1, 40 * unit, 720 * unit);

              //绘制成团图片
              var ct_img = "../../../images/share/ct_num.png";
              context.drawImage(ct_img, 40 * unit, 740 * unit, 120 * unit, 30 * unit);
              var ct_num = th.data.prom_act.ct_num;
              context.setFontSize(14 * unit)
              context.font = 'normal';
              context.setFillStyle("red")
              if (ct_num < 10) {
                context.fillText(ct_num + "人拼团", 92 * unit, 760 * unit);
              } else {
                context.fillText(ct_num + "人拼团", 86 * unit, 760 * unit);
              }
              context.setFontSize(22 * unit)
              context.fillText("已拼" + th.data.prom_act.buy_num + "份", 166 * unit, 763 * unit);
             
			  context.setFillStyle("gray")
              context.fillText("快来和我一起拼团吧!", 40 * unit, 806 * unit);
              context.setFillStyle("black")
              context.font = 'normal bold 18px sans-serif';
              context.setFontSize(21.3 * unit)
              context.fillText("长按识别二维码,立即参团", 40 * unit, 836 * unit);
							
							
              //---二维吗图---
              //-- 自定义海报 --
              if(th.data.poster){
				   var erm_x= parseFloat(th.data.poster.ewm_x)*2; 
				   var erm_y= parseFloat(th.data.poster.ewm_y)*2; 
				   context.drawImage(vpath, erm_x * unit, erm_y * unit, 120 * unit, 120 * unit);				  
              }else{
				   //---二维吗图---
				   context.drawImage(vpath, 420 * unit, 726 * unit, 120 * unit, 120 * unit);
              }	
              break
            case 3: //阶梯团的展示
              //---画线---
              context.setLineWidth(1 * unit)
              context.moveTo(32 * unit, 670 * unit)
              context.lineTo(520 * unit, 670 * unit)
              context.stroke();
              //---文字---
              
			  context.setFillStyle("black")
			  context.setFontSize(24 * unit)
			  context.fillText(th.data.sto_sele_name_1, 40 * unit, 720 * unit);
			  
              //---绘制中间阶梯的价格---
              var list = th.data.prom_act.ct_rylist;
              for (var i = 0; i < list.length; i++) {
                var item = list[i];
                var wi = i * 90 * unit;
                context.font = 'normal';
                context.setFontSize(16 * unit)
                context.setFillStyle("red")
                context.fillText("¥", 40 * unit + wi, 756 * unit);
                context.setFontSize(22 * unit)
                var pri = parseFloat(item.price).toFixed(2);
                context.fillText(pri, 56 * unit + wi, 756 * unit);
                context.setFillStyle("gray")
                context.fillText("满" + item.rynum + "人", 40 * unit + wi, 786 * unit);
              }
              //----------------下面部分----------------
							// context.setFillStyle("gray")
							// context.fillText("快来和我一起拼团吧!", 40 * unit, 830 * unit);
							// context.setFillStyle("black")
							// context.font = 'normal bold 18px sans-serif';
							// context.setFontSize(22 * unit)
							// context.fillText("长按识别二维码,立即参团", 40 * unit, 860 * unit);
              //context.setFillStyle("gray")
			  context.setFillStyle("black")
              context.fillText("快来和我一起拼团吧!", 40 * unit, 820 * unit);             
              //context.font = 'normal bold 18px sans-serif';
              context.setFontSize(22 * unit)
              context.fillText("长按识别二维码,立即参团", 40 * unit, 850 * unit);
													
			  
			  //-- 自定义海报 --
			  if(th.data.poster){
				   var erm_x= parseFloat(th.data.poster.ewm_x)*2; 
				   var erm_y= parseFloat(th.data.poster.ewm_y)*2; 
				   context.drawImage(vpath, erm_x * unit, erm_y * unit, 120 * unit, 120 * unit);				  
			  }else{
				   //---二维吗图---
				   context.drawImage(vpath, 420 * unit, 726 * unit, 120 * unit, 120 * unit);
			  }			  
              break
			  
			   
          }
		  
		  
		  //--- 如果是自定义海报的时候 ---
		  if(th.data.poster && parseInt(th.data.poster.style)==2){
			  
			  //如果显示会员信息的话
			  if(parseInt(th.data.poster.show_headpic)){				  
				  //获取坐标
				  var x= parseFloat(th.data.poster.head_x)*2;
				  var y=parseFloat(th.data.poster.head_y)*2;				  
				  //---绘制圆形要放在最后----
				  context.save();
				  context.beginPath();
				  var h_x = x* unit;
				  var h_y = y * unit;
				  var h_r = 40 * unit;
				  var cx = h_x + h_r;
				  var cy = h_y + h_r;
				  context.arc(cx, cy, h_r, 0, Math.PI * 2, false);
				  context.closePath();
				  context.fill();
				  context.clip();
				  context.drawImage(th.data.share_head, h_x, h_y, h_r * 2, h_r * 2);
				  context.restore();
			  }
			  
		  }else{
			  //---绘制圆形要放在最后----
			  context.save();
			  context.beginPath();
			  var h_x = 60 * unit;
			  var h_y = 24 * unit;
			  var h_r = 40 * unit;
			  var cx = h_x + h_r;
			  var cy = h_y + h_r;
			  context.arc(cx, cy, h_r, 0, Math.PI * 2, false);
			  context.closePath();
			  context.fill();
			  context.clip();
			  context.drawImage(th.data.share_head, h_x, h_y, h_r * 2, h_r * 2);
			  context.restore();
		  }
		 
		 
          //把画板内容绘制成图片,并回调 画板图片路径
          context.draw(false, function() {
            setTimeout(function() {
              wx.canvasToTempFilePath({
                x: 0,
                y: 0,
                width: 750,
                height: 1217,
                destWidth: 1.2 * 750 * 750 / that.data.screenWidth,
                destHeight: 1.2 * 1217 * 750 / that.data.screenWidth,
                canvasId: 'share',
                success: function(res) {
                  that.setData({
                    shareImgPath: res.tempFilePath,
                    canvasHidden: true
                  })
                  if (!res.tempFilePath) {
                    wx.showModal({
                      title: '提示',
                      content: '图片绘制中,请稍后重试',
                      showCancel: false
                    })
                    return false;
                  }
                  // wx.previewImage({
                  //   //将图片预览出来
                  //   urls: [that.data.shareImgPath]
                  // });
									that.setData({
										showPoster: true,
									});
                  wx.hideLoading();
                }
              })
            }, 500)

          });
        });
      }
    });
  },


  //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度
  draw_Text: function(ctx, str, leftWidth, initHeight, titleHeight, canvasWidth, unit) {
    var lineWidth = 0;
    var lastSubStrIndex = 0; //每次开始截取的字符串的索引
    var han = 0;
    for (let i = 0; i < str.length; i++) {
      if (han == 2) return;
      //lineWidth += ctx.measureText(str[i]).width;
      lineWidth += ut.measureText(str[i], 21.3 * unit);
      if (lineWidth > canvasWidth) {
        han++;

        if (han == 2)
          ctx.fillText(str.substring(lastSubStrIndex, i) + '...', leftWidth, initHeight); //绘制截取部分
        else
          ctx.fillText(str.substring(lastSubStrIndex, i), leftWidth, initHeight);

        initHeight += 22; //22为字体的高度
        lineWidth = 0;
        lastSubStrIndex = i;
        titleHeight += 20;
      }
      if (i == str.length - 1) { //绘制剩余部分
        ctx.fillText(str.substring(lastSubStrIndex, i + 1), leftWidth, initHeight);
      }
    }
  },

  // ----视频图片----
  // 图片计数器
  swiperChange: function(e) {
    var that = this;
    if (e.detail.current > 0) {
      that.setData({
        hiddenn: 1,
        videopicture: 1,
      })
    } else {
      that.setData({
        hiddenn: 0,
        videopicture: 0,
      })
    }
    if (e.detail.source == 'touch') {
      that.setData({
        current: e.detail.current
      })
    }
  },

  //--获取头像的本地缓存,回调写法--
  get_head_temp: function(tt, func) {
    var ee = this;
    if (ee.data.share_head) {
      tt(func);
      return false;
    }
    //---获取分享图片的本地地址,头像和商品图片----
    var path2 = getApp().globalData.userInfo.head_pic;
    if (path2 == "") {
      ee.data.share_head = "../../../images/share/hui_hear_pic.png";
      tt(func);
    } else {
      path2 = path2.replace("http://thirdwx.qlogo.cn", "https://wx.qlogo.cn");
      path2 = path2.replace("https://thirdwx.qlogo.cn", "https://wx.qlogo.cn");
      wx.getImageInfo({
        src: path2,
        success: function(res) {
          //res.path是网络图片的本地地址
          ee.data.share_head = res.path;
          tt(func);
        },
        fail: function(res) {
          ee.data.share_head = "../../../images/share/hui_hear_pic.png"; //分享的图片不能用网络的
          tt(func);
        }
      });
    }
  },
  //--获取商品图片的本地缓存,回调写法--
  get_goods_temp: function(tt) {
    var ee = this;
    if (ee.data.share_goods_img) {
      tt();
      return false;
    }
    //获取商品是分享图信息
    wx.getImageInfo({
      src: ee.data.data.original_img,
      success: function(res) {
        //res.path是网络图片的本地地址
        ee.data.share_goods_img = res.path;
        tt();
      },
      fail: function(res) {

        ee.data.share_goods_img = "../../../images/share/default_g_img.gif"; //分享的图片不能用网络的
        tt();
      }
    });
  },


  //--跳转到商品详情页面--
  go_goods: function(e) {
    var gid = e.currentTarget.dataset.gid;
    var url = "/pages/goods/goodsInfo/goodsInfo?goods_id=" + gid;
    getApp().goto(url);
  },


  pop_err_img: function(e) {
    var txt = e.currentTarget.dataset.errorimg;
    var ob = {};
    ob[txt] = this.data.iurl + "/miniapp/images/default_g_img.gif";
    this.setData(ob);
  },

  // 选择门店
  choice_store: function(ee) {
    var th = this;
    var ind=ee.currentTarget.dataset.ind;
    var bconfig = th.data.bconfig;

    if(!th.data.only_pk && !th.data.def_pickpu_list){
      getApp().confirmBox("门店库存不足", null, 25000, !1);
      return false;
    }

    if(th.data.only_pk && !th.data.only_pk.length){
      getApp().confirmBox("门店库存不足", null, 25000, !1);
      return false;
    }
    if(th.data.def_pickpu_list &&  !th.data.def_pickpu_list.length){
      getApp().confirmBox("门店库存不足", null, 25000, !1);
      return false;
    }


    if (bconfig && bconfig.is_sort_storage) {
      wx.getLocation({
        type: 'gcj02',
        success: function(res) {

          th.data.lat = res.latitude;
          th.data.lon = res.longitude;
          th.data.is_get_local_ok = 1;
          th.setData({ is_gps: 1 });
          th.get_sto(th.data.is_normal);
        },
        fail: function(res) {
        
          th.data.is_get_local_ok = 1;
          th.get_sto(th.data.is_normal);
          if (res.errCode == 2) {
            th.setData({is_gps: 0});
            if (th.data.is_gps == 0) {
              getApp().confirmBox("请开启GPS定位", null, 25000, !1);
            }
          } else {
            th.setData({ is_gps: "3" });
          }

        }
      })
    }else{
      th.data.is_get_local_ok = 1;
      th.get_sto(th.data.is_normal);
    }

    if(ind!=undefined && ind!=null ){
      this.setData({
        open_ind_store: ind,
        store: 1,
        openSpecModal: !1,
        openSpecModal_pt: !1
      })
    }else{
      this.setData({
        store: 1,
        openSpecModal: !1,
        openSpecModal_pt: !1
      })
    }
  },
  //关闭选择门店
  close_popup: function(e) {
    var th=this;
    this.setData({
      store: 0,
      choice_sort_store: 0,
      sort_store: 0,
      fir_pick_index:0,
      sec_pick_index:0
    })

    var openindstore=this.data.open_ind_store;
    if (openindstore == 1) {
      th.setData({
        openSpecModal: !0,
        openSpecModal_ind: openindstore,
      });
    } else if (openindstore == 2) {
      th.setData({
        openSpecModal: !0,
        openSpecModal_ind: openindstore,
      });
    }
    else if (openindstore == 4) { //4就是拼团
      th.setData({
        openSpecModal_pt: 1,      //打开拼团购买界面
        store: 0,                 //关闭门店
        choice_sort_store: 0,     //关闭门店2级
        sort_store: 0,             //关闭门店2级
      });
    }
    else {
      th.setData({
        store: 0,
        choice_sort_store: 0,
        sort_store: 0
      })
    }
  },

  //选择更多门店
  more_store: function() {
    this.setData({
      sort_store: 1
    });
  },
  
  sort_store: function() { },
  // 返回按钮
  returns: function() {
    this.setData({
      sort_store: 0,
      choice_sort_store: 0
    });
  },
  //---选择分类门店---
  choice_sort_store: function(e) {
    var index = e.currentTarget.dataset.index;
    var region_name = e.currentTarget.dataset.region;
    var item = this.data.all_sto[index];
    this.setData({
      region_name: region_name,
      sort_store: 0,
      choice_sort_store: 1,
      sec_sto: item,
      sec_pick_index: 0
    });
  },

  choose_for_store_fir: function(e) {
    var index_c = e.currentTarget.dataset.ind;
    var th=this;
    th.setData({
      fir_pick_index: index_c
    })

  },

  //确定def_pick为选择的门店
  sure_pick: function(e) {
    var th = this;
    var item = null;
    var openindstore = th.data.open_ind_store;

    if (th.data.choice_sort_store == 0) {
      var index = th.data.fir_pick_index;
      if (th.data.is_show_sto_cat == 1) {
        item = th.data.def_pickpu_list[index];
      } else {
        item = th.data.only_pk[index]; //当没有门店分类的时候
      }

    } else {
      var index = th.data.sec_pick_index;
      item = th.data.sec_sto.s_arr[index];
    }

    var ser_card=this.data.data;
	//判断门店的配送方式是不是匹配
	if(ser_card.storageId!=null && ser_card.storageId!=""  &&  ser_card.storageId.indexOf(item.keyid)==-1){
		wx.showToast({
		  title: "该门店无此服务项目,请重新选择!",
		  icon: 'none',
		  duration: 2000
		});
		return false;
	}
	
   
      th.setData({
        def_pick_store: item,
        sto_sele_name: item.pickup_name,
        sto_sele_id: item.pickup_id,
        sto_sele_keyid: item.keyid,
        sto_sele_distr: item.distr_type,
        store: 0,
        choice_sort_store: 0,
        fir_pick_index: 0
      });
	  
      if (openindstore == 1) {
        th.setData({
          openSpecModal: !0,
          openSpecModal_ind: openindstore,
        });
      } else if (openindstore == 2) {
        th.setData({
          openSpecModal: !0,
          openSpecModal_ind: openindstore,
        });
      }
      else if(openindstore == 4) { //4就是拼团
        th.setData({
          openSpecModal_pt: 1,      //打开拼团购买界面
          store: 0,                 //关闭门店
          choice_sort_store: 0,     //关闭门店2级
          sort_store: 0,             //关闭门店2级
        });
      }
      else {
        th.setData({
          store: 0,
          choice_sort_store: 0,
          sort_store: 0
        })
      }	      
  },
  
  //---点击二级之后的选择---
  choose_for_store: function(e) {
    var index_c = e.currentTarget.dataset.ind;
    var th=this;
    th.setData({
      sec_pick_index: index_c,
      fir_pick_index: index_c
    })

  },
  //把选择的门店设置成默认的门店def_pick
  set_def_pick: function(e) {
    var th = this;
    var item = null;
    if (th.data.choice_sort_store == 0) {
      var index = th.data.fir_pick_index;
      if (th.data.is_show_sto_cat == 1) {
        item = th.data.def_pickpu_list[index];
      } else {
        item = th.data.only_pk[index]; //当没有门店分类的时候
      }
    } else {
      var index = th.data.sec_pick_index;
      item = th.data.sec_sto.s_arr[index];
    }
	
	//判断门店的配送方式是不是匹配
    var ser_card=this.data.data;
    //判断门店的配送方式是不是匹配
    if(ser_card.storageId!=null && ser_card.storageId!=""  &&  ser_card.storageId.indexOf(item.keyid)==-1){
		wx.showToast({
		  title: "该门店无此服务项目,请重新选择!",
		  icon: 'none',
		  duration: 2000
		});
		return false;
	}

    
    
     var store_id = o.stoid;
     var user_id = getApp().globalData.user_id;
     var def_pickup_id = item.pickup_id;

     getApp().request.put('/api/weshop/users/update', {
        data: {
          user_id:user_id,
          def_pickup_id:def_pickup_id
        },
        success: function(res) {
          if (res.data.code == 0) {
            if (th.data.choice_sort_store == 0) th.setData({
              fir_pick_index: 0
            });
            getApp().globalData.pk_store = item;
          } else {
            //s.showWarning("设置默认门店地址失败", null, 500, !1);
            getApp().my_warnning("设置默认门店地址失败",0,th)
          }

        }
      });

      th.setData({
        def_pick_store: item,
        sto_sele_name: item.pickup_name,
        sto_sele_id: item.pickup_id,
        sto_sele_keyid: item.keyid,
        sto_sele_distr: item.distr_type,
        store: 0,
        choice_sort_store: 0
      });

      var openindstore = th.data.open_ind_store;
      if (openindstore == 1) {
        th.setData({
          openSpecModal: !0,
          openSpecModal_ind: openindstore,
          store: 0,
          choice_sort_store: 0,
          sort_store: 0,
        });
      } else if (openindstore == 2) {
        th.setData({
          openSpecModal: !0,
          openSpecModal_ind: openindstore,
          store: 0,
          choice_sort_store: 0,
          sort_store: 0,
        });
      }
      else if (openindstore == 4) { //4就是拼团
        th.setData({
          openSpecModal_pt: 1,      //打开拼团购买界面
          store: 0,                 //关闭门店
          choice_sort_store: 0,     //关闭门店2级
          sort_store: 0,             //关闭门店2级
        });
      }

      else {
        th.setData({
          store: 0,
          choice_sort_store: 0,
          sort_store: 0,
        })
      }
	  
  },

  wait_for_store_config: function() {
    var th = this;
    var t_time = setInterval(function() {
      if (th.data.bconfig == null) false;
      var e = th.data.bconfig;
      if (e && e.is_sort_storage) {
        wx.getLocation({
          type: 'gcj02',
          success: function(res) {
            th.data.lat = res.latitude;
            th.data.lon = res.longitude;
            th.data.is_get_local_ok = 1;
          },
          fail: function(res) {
            if (res.errCode == 2) {
              th.setData({
                is_gps: 0
              });
              if (th.data.is_gps == 0) {
                getApp().confirmBox("请开启GPS定位", null, 10000, !1);
              }

            } else {
              th.setData({
                is_gps: "3"
              });
            }

            th.data.is_get_local_ok = 1;
          }
        })
      } else {
        th.data.is_get_local_ok = 1;
      }
      clearInterval(t_time);
    }, 500)
  },
  
  
  //-- 根据ID拿出门店 --
  get_pick_from_list(pid){
    var all_pick_list=this.data.all_pick_list;
    for(var i in all_pick_list){
      var item=all_pick_list[i];
      if(item.pickup_id==pid){ return item;}
    }
  },
  
  closePoster() {
		this.setData({
			showPoster: false,
		});
   },
	
	// 保存图片到手机
	savePic() {
	   console.log('保存图片');
	   var self = this;
	   // 获取用户的当前设置,返回值中有小程序已经向用户请求过的权限
	   this.getSetting().then((res) => {
	     // 判断用户是否授权了保存到相册的权限,如果没有发起授权
	     if (!res.authSetting['scope.writePhotosAlbum']) {
	       this.authorize().then(() => {
	         // 同意授权后保存下载文件
	         this.saveImage(self.data.shareImgPath)
					 .then(() => {
						 self.setData({
							 showPoster: false
						 });
					 });
	       })
	     } else {
	       // 如果已经授权,保存下载文件
	       this.saveImage(self.data.shareImgPath)
				 .then(() => {
					 self.setData({ showPoster: false });
				 });
	     }
			 
	   })
	 },
	 
	 // 获取用户已经授予了哪些权限
	 getSetting() {
	   return new Promise((resolve, reject) => {
	     wx.getSetting({
	       success: res => {
	         resolve(res)
	       }
	     })
	   })
	 },
	 
	 // 发起首次授权请求
	 authorize() {
	   // isFirst 用来记录是否为首次发起授权,
	   // 如果首次授权拒绝后,isFirst赋值为1
	   let isFirst = wx.getStorageSync('isFirst') || 0;
	   return new Promise((resolve, reject) => {
	     wx.authorize({
	       scope: 'scope.writePhotosAlbum',
	       // 同意授权
	       success: () => {
	         resolve();
	       },
	       // 拒绝授权,这里是用户拒绝授权后的回调
	       fail: res => { 
	         if(isFirst === 0) {
	           wx.setStorageSync('isFirst', 1);
	           wx.showToast({
	             title: '保存失败',
	             icon: 'none',
	             duration: 1000
	           })
	         } else {
	           this.showModal();
	         }
	         console.log('拒绝授权');
	         reject();
	       }
	     })
	   })
	 },
	 	 
	 // 保存图片到系统相册
	 saveImage(saveUrl) {
	   var self = this;
	   return new Promise((resolve, reject) => {
	     wx.saveImageToPhotosAlbum({
	       filePath: saveUrl,
	       success: (res) => {
	         wx.showToast({
	           title: '保存成功',
	           duration: 1000,
	         });
	         self.setData({
	           showPlaybill: 'true'
	         });
	         resolve();
	       },
	       fail: () => {
	         wx.showToast({
	           title: '保存失败',
	           duration: 1000,
	         });
	       }
	     })
	   })
	 },
	 
	 previewImage() {
		 wx.previewImage({
		   //将图片预览出来
		   urls: [this.data.shareImgPath]
		 });
	 },
	 	
	onShareTimeline() {
		var store_name=getApp().globalData.config?getApp().globalData.config.store_name:'';
		if(!store_name)
		   store_name=getApp().globalData.setting.appName;
		
		return {
			title:this.data.data.goods_name + '-' + store_name,
			imageUrl:this.data.gallery[0].image_url,
		}
	},
	     


});