Commit 03ca390cf3254f3d332805e96bfd350e4cf7583b
Merge branch 'dev' of http://git.vipzhuang.cn/wxd/MShopWeApp into dev
Showing
2 changed files
with
7066 additions
and
6877 deletions
pages/cart/cart/cart.js
| @@ -1031,11 +1031,11 @@ Page({ | @@ -1031,11 +1031,11 @@ Page({ | ||
| 1031 | // title: '提示', | 1031 | // title: '提示', |
| 1032 | // content: '购买的数量不能超出库存数量', | 1032 | // content: '购买的数量不能超出库存数量', |
| 1033 | // }); | 1033 | // }); |
| 1034 | - // wx.showToast({ | ||
| 1035 | - // title: '购买的数量不能超出库存数量', | ||
| 1036 | - // icon: 'none', | ||
| 1037 | - // }); | ||
| 1038 | - getApp().my_warnning('购买的数量不能超出库存数量', 0, this); | 1034 | + wx.showToast({ |
| 1035 | + title: '购买的数量不能超出库存数量', | ||
| 1036 | + icon: 'none', | ||
| 1037 | + }); | ||
| 1038 | + // getApp().my_warnning('购买的数量不能超出库存数量', 0, this); | ||
| 1039 | this.data.up_dating = 0; | 1039 | this.data.up_dating = 0; |
| 1040 | } | 1040 | } |
| 1041 | }, | 1041 | }, |
| @@ -1729,11 +1729,11 @@ Page({ | @@ -1729,11 +1729,11 @@ Page({ | ||
| 1729 | th.check_down_line(t, pitem, item, wareIds); | 1729 | th.check_down_line(t, pitem, item, wareIds); |
| 1730 | } else { | 1730 | } else { |
| 1731 | if (t.goods_num > store_count) { | 1731 | if (t.goods_num > store_count) { |
| 1732 | - // wx.showToast({ | ||
| 1733 | - // title: '购买数量超出商品库存', | ||
| 1734 | - // icon: 'none', | ||
| 1735 | - // }); | ||
| 1736 | - getApp().my_warnning('购买数量超出商品库存', 0, th); | 1732 | + wx.showToast({ |
| 1733 | + title: '购买数量超出商品库存', | ||
| 1734 | + icon: 'none', | ||
| 1735 | + }); | ||
| 1736 | + // getApp().my_warnning('购买数量超出商品库存', 0, th); | ||
| 1737 | var txt = "requestData[" + pitem + "].goods[" + item + "].goods_num"; | 1737 | var txt = "requestData[" + pitem + "].goods[" + item + "].goods_num"; |
| 1738 | e.setData({ | 1738 | e.setData({ |
| 1739 | [txt]: store_count | 1739 | [txt]: store_count |
| @@ -1790,11 +1790,11 @@ Page({ | @@ -1790,11 +1790,11 @@ Page({ | ||
| 1790 | 1790 | ||
| 1791 | // 判断当前预购买的数量是否超过可购买的数量 | 1791 | // 判断当前预购买的数量是否超过可购买的数量 |
| 1792 | if (buyed_mum2 > (limit - goodsbuynum) && limit > 0) { | 1792 | if (buyed_mum2 > (limit - goodsbuynum) && limit > 0) { |
| 1793 | - // wx.showToast({ | ||
| 1794 | - // title: '购买数量超出商品限购', | ||
| 1795 | - // icon: 'none', | ||
| 1796 | - // }); | ||
| 1797 | - getApp().my_warnning('购买数量超出商品限购', 0, th); | 1793 | + wx.showToast({ |
| 1794 | + title: '购买数量超出商品限购', | ||
| 1795 | + icon: 'none', | ||
| 1796 | + }); | ||
| 1797 | + //getApp().my_warnning('购买数量超出商品限购', 0, th); | ||
| 1798 | var txt = "requestData[" + pitem + "].goods[" + item + "].goods_num"; | 1798 | var txt = "requestData[" + pitem + "].goods[" + item + "].goods_num"; |
| 1799 | 1799 | ||
| 1800 | //--> by ty | 1800 | //--> by ty |
| @@ -1827,12 +1827,11 @@ Page({ | @@ -1827,12 +1827,11 @@ Page({ | ||
| 1827 | // title: '提示', | 1827 | // title: '提示', |
| 1828 | // content: '购买数量超出商品库存' | 1828 | // content: '购买数量超出商品库存' |
| 1829 | // }); | 1829 | // }); |
| 1830 | - // wx.showToast({ | ||
| 1831 | - // title: '购买数量超出商品库存', | ||
| 1832 | - // icon: 'none', | ||
| 1833 | - // // content: '购买数量超出商品库存' | ||
| 1834 | - // }); | ||
| 1835 | - getApp().my_warnning('购买数量超出商品库存', 0, th); | 1830 | + wx.showToast({ |
| 1831 | + title: '购买数量超出商品库存', | ||
| 1832 | + icon: 'none', | ||
| 1833 | + }); | ||
| 1834 | + // getApp().my_warnning('购买数量超出商品库存', 0, th); | ||
| 1836 | var txt = "requestData[" + pitem + "].goods[" + item + "].goods_num"; | 1835 | var txt = "requestData[" + pitem + "].goods[" + item + "].goods_num"; |
| 1837 | e.setData({ | 1836 | e.setData({ |
| 1838 | [txt]: store_count | 1837 | [txt]: store_count |
| @@ -1852,11 +1851,11 @@ Page({ | @@ -1852,11 +1851,11 @@ Page({ | ||
| 1852 | // title: '提示', | 1851 | // title: '提示', |
| 1853 | // content: '购买数量超出活动库存' | 1852 | // content: '购买数量超出活动库存' |
| 1854 | // }); | 1853 | // }); |
| 1855 | - // wx.showToast({ | ||
| 1856 | - // title: '购买数量超出活动库存', | ||
| 1857 | - // icon: 'none', | ||
| 1858 | - // }); | ||
| 1859 | - getApp().my_warnning('购买数量超出活动库存', 0, th); | 1854 | + wx.showToast({ |
| 1855 | + title: '购买数量超出活动库存', | ||
| 1856 | + icon: 'none', | ||
| 1857 | + }); | ||
| 1858 | + // getApp().my_warnning('购买数量超出活动库存', 0, th); | ||
| 1860 | var txt = "requestData[" + pitem + "].goods[" + item + "].goods_num"; | 1859 | var txt = "requestData[" + pitem + "].goods[" + item + "].goods_num"; |
| 1861 | e.setData({ | 1860 | e.setData({ |
| 1862 | [txt]: false_data.goods_num - false_data.buy_num | 1861 | [txt]: false_data.goods_num - false_data.buy_num |
| @@ -1875,12 +1874,11 @@ Page({ | @@ -1875,12 +1874,11 @@ Page({ | ||
| 1875 | // title: '提示', | 1874 | // title: '提示', |
| 1876 | // content: '购买数量超出商品库存' | 1875 | // content: '购买数量超出商品库存' |
| 1877 | // }); | 1876 | // }); |
| 1878 | - // wx.showToast({ | ||
| 1879 | - // title: '购买数量超出商品库存', | ||
| 1880 | - // icon: 'none', | ||
| 1881 | - // // content: '购买数量超出商品库存' | ||
| 1882 | - // }); | ||
| 1883 | - getApp().my_warnning('购买数量超出商品库存', 0, th); | 1877 | + wx.showToast({ |
| 1878 | + title: '购买数量超出商品库存', | ||
| 1879 | + icon: 'none', | ||
| 1880 | + }); | ||
| 1881 | + //getApp().my_warnning('购买数量超出商品库存', 0, th); | ||
| 1884 | var txt = "requestData[" + pitem + "].goods[" + item + "].goods_num"; | 1882 | var txt = "requestData[" + pitem + "].goods[" + item + "].goods_num"; |
| 1885 | e.setData({ | 1883 | e.setData({ |
| 1886 | [txt]: false_data.redisnum | 1884 | [txt]: false_data.redisnum |
| @@ -1898,12 +1896,11 @@ Page({ | @@ -1898,12 +1896,11 @@ Page({ | ||
| 1898 | // title: '提示', | 1896 | // title: '提示', |
| 1899 | // content: '购买数量超出秒杀限购' | 1897 | // content: '购买数量超出秒杀限购' |
| 1900 | // }); | 1898 | // }); |
| 1901 | - // wx.showToast({ | ||
| 1902 | - // title: '购买数量超出秒杀限购', | ||
| 1903 | - // icon: 'none', | ||
| 1904 | - // // content: '购买数量超出秒杀限购' | ||
| 1905 | - // }); | ||
| 1906 | - getApp().my_warnning('购买数量超出秒杀限购', 0, th); | 1899 | + wx.showToast({ |
| 1900 | + title: '购买数量超出秒杀限购', | ||
| 1901 | + icon: 'none', | ||
| 1902 | + }); | ||
| 1903 | + // getApp().my_warnning('购买数量超出秒杀限购', 0, th); | ||
| 1907 | var txt = "requestData[" + pitem + "].goods[" + item + "].goods_num"; | 1904 | var txt = "requestData[" + pitem + "].goods[" + item + "].goods_num"; |
| 1908 | e.setData({ | 1905 | e.setData({ |
| 1909 | [txt]: false_data.buy_limit | 1906 | [txt]: false_data.buy_limit |
| @@ -1929,12 +1926,11 @@ Page({ | @@ -1929,12 +1926,11 @@ Page({ | ||
| 1929 | // title: '提示', | 1926 | // title: '提示', |
| 1930 | // content: '购买数量超出商品库存' | 1927 | // content: '购买数量超出商品库存' |
| 1931 | // }); | 1928 | // }); |
| 1932 | - // wx.showToast({ | ||
| 1933 | - // title: '购买数量超出商品库存', | ||
| 1934 | - // icon: 'none', | ||
| 1935 | - // // content: '购买数量超出商品库存' | ||
| 1936 | - // }); | ||
| 1937 | - getApp().my_warnning('购买数量超出商品库存', 0, th); | 1929 | + wx.showToast({ |
| 1930 | + title: '购买数量超出商品库存', | ||
| 1931 | + icon: 'none', | ||
| 1932 | + }); | ||
| 1933 | + // getApp().my_warnning('购买数量超出商品库存', 0, th); | ||
| 1938 | var txt = "requestData[" + pitem + "].goods[" + item + "].goods_num"; | 1934 | var txt = "requestData[" + pitem + "].goods[" + item + "].goods_num"; |
| 1939 | e.setData({ | 1935 | e.setData({ |
| 1940 | [txt]: store_count | 1936 | [txt]: store_count |
| @@ -1954,12 +1950,11 @@ Page({ | @@ -1954,12 +1950,11 @@ Page({ | ||
| 1954 | // title: '提示', | 1950 | // title: '提示', |
| 1955 | // content: '购买数量超出活动库存' | 1951 | // content: '购买数量超出活动库存' |
| 1956 | // }); | 1952 | // }); |
| 1957 | - // wx.showToast({ | ||
| 1958 | - // title: '购买数量超出活动库存', | ||
| 1959 | - // icon: 'none', | ||
| 1960 | - // // content: '购买数量超出活动库存' | ||
| 1961 | - // }); | ||
| 1962 | - getApp().my_warnning('购买数量超出活动库存', 0, th); | 1953 | + wx.showToast({ |
| 1954 | + title: '购买数量超出活动库存', | ||
| 1955 | + icon: 'none', | ||
| 1956 | + }); | ||
| 1957 | + // getApp().my_warnning('购买数量超出活动库存', 0, th); | ||
| 1963 | var txt = "requestData[" + pitem + "].goods[" + item + "].goods_num"; | 1958 | var txt = "requestData[" + pitem + "].goods[" + item + "].goods_num"; |
| 1964 | e.setData({ | 1959 | e.setData({ |
| 1965 | [txt]: gr_data.goods_num - gr_data.buy_num | 1960 | [txt]: gr_data.goods_num - gr_data.buy_num |
| @@ -1978,12 +1973,11 @@ Page({ | @@ -1978,12 +1973,11 @@ Page({ | ||
| 1978 | // title: '提示', | 1973 | // title: '提示', |
| 1979 | // content: '购买数量超出商品库存' | 1974 | // content: '购买数量超出商品库存' |
| 1980 | // }); | 1975 | // }); |
| 1981 | - // wx.showToast({ | ||
| 1982 | - // title: '购买数量超出商品库存', | ||
| 1983 | - // icon: 'none', | ||
| 1984 | - // // content: '购买数量超出商品库存' | ||
| 1985 | - // }); | ||
| 1986 | - getApp().my_warnning('购买数量超出商品库存', 0, th); | 1976 | + wx.showToast({ |
| 1977 | + title: '购买数量超出商品库存', | ||
| 1978 | + icon: 'none', | ||
| 1979 | + }); | ||
| 1980 | + // getApp().my_warnning('购买数量超出商品库存', 0, th); | ||
| 1987 | var txt = "requestData[" + pitem + "].goods[" + item + "].goods_num"; | 1981 | var txt = "requestData[" + pitem + "].goods[" + item + "].goods_num"; |
| 1988 | e.setData({ | 1982 | e.setData({ |
| 1989 | [txt]: gr_data.redisnum | 1983 | [txt]: gr_data.redisnum |
| @@ -2001,12 +1995,11 @@ Page({ | @@ -2001,12 +1995,11 @@ Page({ | ||
| 2001 | // title: '提示', | 1995 | // title: '提示', |
| 2002 | // content: '购买数量超出团购限购' | 1996 | // content: '购买数量超出团购限购' |
| 2003 | // }); | 1997 | // }); |
| 2004 | - // wx.showToast({ | ||
| 2005 | - // title: '购买数量超出团购限购', | ||
| 2006 | - // icon: 'none', | ||
| 2007 | - // // content: '购买数量超出团购限购' | ||
| 2008 | - // }); | ||
| 2009 | - getApp().my_warnning('购买数量超出团购限购', 0, th); | 1998 | + wx.showToast({ |
| 1999 | + title: '购买数量超出团购限购', | ||
| 2000 | + icon: 'none', | ||
| 2001 | + }); | ||
| 2002 | + // getApp().my_warnning('购买数量超出团购限购', 0, th); | ||
| 2010 | var txt = "requestData[" + pitem + "].goods[" + item + "].goods_num"; | 2003 | var txt = "requestData[" + pitem + "].goods[" + item + "].goods_num"; |
| 2011 | e.setData({ | 2004 | e.setData({ |
| 2012 | [txt]: gr_data.buy_limit | 2005 | [txt]: gr_data.buy_limit |
| @@ -2082,11 +2075,11 @@ Page({ | @@ -2082,11 +2075,11 @@ Page({ | ||
| 2082 | 2075 | ||
| 2083 | // 检测库存 | 2076 | // 检测库存 |
| 2084 | if(redis_num == 0) { | 2077 | if(redis_num == 0) { |
| 2085 | - // wx.showToast({ | ||
| 2086 | - // title: '超出活动库存', | ||
| 2087 | - // icon: 'none', | ||
| 2088 | - // }); | ||
| 2089 | - getApp().my_warnning('超出活动库存', 0, th); | 2078 | + wx.showToast({ |
| 2079 | + title: '超出活动库存', | ||
| 2080 | + icon: 'none', | ||
| 2081 | + }); | ||
| 2082 | + // getApp().my_warnning('超出活动库存', 0, th); | ||
| 2090 | th.setData({[txt]: redis_num}); | 2083 | th.setData({[txt]: redis_num}); |
| 2091 | t.goods_num = redis_num; | 2084 | t.goods_num = redis_num; |
| 2092 | await th.doCheckAll(); | 2085 | await th.doCheckAll(); |
| @@ -2123,11 +2116,11 @@ Page({ | @@ -2123,11 +2116,11 @@ Page({ | ||
| 2123 | let num = buylimit - gd_buy_num; | 2116 | let num = buylimit - gd_buy_num; |
| 2124 | 2117 | ||
| 2125 | if(totalNum > redis_num) { | 2118 | if(totalNum > redis_num) { |
| 2126 | - // wx.showToast({ | ||
| 2127 | - // title: '超出活动库存', | ||
| 2128 | - // icon: 'none', | ||
| 2129 | - // }); | ||
| 2130 | - getApp().my_warnning('超出活动库存', 0, th); | 2119 | + wx.showToast({ |
| 2120 | + title: '超出活动库存', | ||
| 2121 | + icon: 'none', | ||
| 2122 | + }); | ||
| 2123 | + // getApp().my_warnning('超出活动库存', 0, th); | ||
| 2131 | // 开启限购 | 2124 | // 开启限购 |
| 2132 | if (buylimit > 0) { | 2125 | if (buylimit > 0) { |
| 2133 | if (num > redis_num) { | 2126 | if (num > redis_num) { |
| @@ -2158,11 +2151,11 @@ Page({ | @@ -2158,11 +2151,11 @@ Page({ | ||
| 2158 | // 如果限购数量<=活动库存数量,增加数量时会先超过限购数量,此时应提示“超出活动限购数量” | 2151 | // 如果限购数量<=活动库存数量,增加数量时会先超过限购数量,此时应提示“超出活动限购数量” |
| 2159 | if(totalNum > num) { | 2152 | if(totalNum > num) { |
| 2160 | // 计算还可以购买的数量:库存量 - 已购数 | 2153 | // 计算还可以购买的数量:库存量 - 已购数 |
| 2161 | - // wx.showToast({ | ||
| 2162 | - // title: '超出活动限购', | ||
| 2163 | - // icon: 'none', | ||
| 2164 | - // }); | ||
| 2165 | - getApp().my_warnning('超出活动限购', 0, th); | 2154 | + wx.showToast({ |
| 2155 | + title: '超出活动限购', | ||
| 2156 | + icon: 'none', | ||
| 2157 | + }); | ||
| 2158 | + // getApp().my_warnning('超出活动限购', 0, th); | ||
| 2166 | if (num <= 0) num = 1; | 2159 | if (num <= 0) num = 1; |
| 2167 | th.setData({[txt]: num - cartGoodsNum}); | 2160 | th.setData({[txt]: num - cartGoodsNum}); |
| 2168 | t.goods_num = num - cartGoodsNum; | 2161 | t.goods_num = num - cartGoodsNum; |
| @@ -2202,21 +2195,21 @@ Page({ | @@ -2202,21 +2195,21 @@ Page({ | ||
| 2202 | 2195 | ||
| 2203 | // 检测库存 | 2196 | // 检测库存 |
| 2204 | if(redis_num == 0) { | 2197 | if(redis_num == 0) { |
| 2205 | - // wx.showToast({ | ||
| 2206 | - // title: '超出活动库存', | ||
| 2207 | - // icon: 'none', | ||
| 2208 | - // }); | ||
| 2209 | - getApp().my_warnning('超出活动库存', 0, th); | 2198 | + wx.showToast({ |
| 2199 | + title: '超出活动库存', | ||
| 2200 | + icon: 'none', | ||
| 2201 | + }); | ||
| 2202 | + // getApp().my_warnning('超出活动库存', 0, th); | ||
| 2210 | th.setData({[txt]: redis_num}); | 2203 | th.setData({[txt]: redis_num}); |
| 2211 | return false; | 2204 | return false; |
| 2212 | }; | 2205 | }; |
| 2213 | 2206 | ||
| 2214 | if(t.goods_num > redis_num) { | 2207 | if(t.goods_num > redis_num) { |
| 2215 | - // wx.showToast({ | ||
| 2216 | - // title: '超出活动库存', | ||
| 2217 | - // icon: 'none', | ||
| 2218 | - // }); | ||
| 2219 | - getApp().my_warnning('超出活动库存', 0, th); | 2208 | + wx.showToast({ |
| 2209 | + title: '超出活动库存', | ||
| 2210 | + icon: 'none', | ||
| 2211 | + }); | ||
| 2212 | + // getApp().my_warnning('超出活动库存', 0, th); | ||
| 2220 | th.setData({[txt]: redis_num}); | 2213 | th.setData({[txt]: redis_num}); |
| 2221 | return false; | 2214 | return false; |
| 2222 | }; | 2215 | }; |
| @@ -2256,11 +2249,11 @@ Page({ | @@ -2256,11 +2249,11 @@ Page({ | ||
| 2256 | // 如果限购数量<=活动库存数量,增加数量时会先超过限购数量,此时应提示“超出活动限购数量” | 2249 | // 如果限购数量<=活动库存数量,增加数量时会先超过限购数量,此时应提示“超出活动限购数量” |
| 2257 | if(t.goods_num + gd_buy_num > buylimit) { | 2250 | if(t.goods_num + gd_buy_num > buylimit) { |
| 2258 | // 计算还可以购买的数量:库存量 - 已购数 | 2251 | // 计算还可以购买的数量:库存量 - 已购数 |
| 2259 | - // wx.showToast({ | ||
| 2260 | - // title: '超出活动限购', | ||
| 2261 | - // icon: 'none', | ||
| 2262 | - // }); | ||
| 2263 | - getApp().my_warnning('超出活动限购', 0, th); | 2252 | + wx.showToast({ |
| 2253 | + title: '超出活动限购', | ||
| 2254 | + icon: 'none', | ||
| 2255 | + }); | ||
| 2256 | + // getApp().my_warnning('超出活动限购', 0, th); | ||
| 2264 | th.setData({[txt]: buylimit}); | 2257 | th.setData({[txt]: buylimit}); |
| 2265 | 2258 | ||
| 2266 | }; | 2259 | }; |
| @@ -2291,12 +2284,11 @@ Page({ | @@ -2291,12 +2284,11 @@ Page({ | ||
| 2291 | // title: '提示', | 2284 | // title: '提示', |
| 2292 | // content: '购买数量超出商品库存' | 2285 | // content: '购买数量超出商品库存' |
| 2293 | // }); | 2286 | // }); |
| 2294 | - // wx.showToast({ | ||
| 2295 | - // title: '购买数量超出商品库存', | ||
| 2296 | - // icon: 'none', | ||
| 2297 | - // // content: '购买数量超出商品库存' | ||
| 2298 | - // }); | ||
| 2299 | - getApp().my_warnning('购买数量超出商品库存', 0, th); | 2287 | + wx.showToast({ |
| 2288 | + title: '购买数量超出商品库存', | ||
| 2289 | + icon: 'none', | ||
| 2290 | + }); | ||
| 2291 | + // getApp().my_warnning('购买数量超出商品库存', 0, th); | ||
| 2300 | var txt = "requestData[" + pitem + "].goods[" + item + "].goods_num"; | 2292 | var txt = "requestData[" + pitem + "].goods[" + item + "].goods_num"; |
| 2301 | th.setData({ | 2293 | th.setData({ |
| 2302 | [txt]: ob.CanOutQty | 2294 | [txt]: ob.CanOutQty |
pages/goods/goodsInfo/goodsInfo.js
| 1 | -var t = require("../../../utils/util.js"), | ||
| 2 | - ut = t, | ||
| 3 | - e = require("../../../utils/common.js"), | ||
| 4 | - a = require("../../../utils/wxParse/wxParse.js"), | ||
| 5 | - s = getApp(), | ||
| 6 | - i = s.request, | ||
| 7 | - rq = i, | ||
| 8 | - oo = s.globalData, | ||
| 9 | - o = s.globalData.setting, | ||
| 10 | - os = o; | ||
| 11 | - | ||
| 12 | -let self = null; | ||
| 13 | - | ||
| 14 | -//评价加载更多 | ||
| 15 | -var more = function (e) { | ||
| 16 | - return e && e.__esModule ? e : { | ||
| 17 | - default: e | ||
| 18 | - }; | ||
| 19 | -}(require("../../../utils/LoadMore.js")), | ||
| 20 | - n = new more.default(); | ||
| 21 | -var utils = require('../../../utils/util.js'); | ||
| 22 | -var regeneratorRuntime = require('../../../utils/runtime.js'); | ||
| 23 | -const { app } = require("../../../utils/common.js"); | ||
| 24 | - | ||
| 25 | -Page({ | ||
| 26 | - data: { | ||
| 27 | - start_stop: 2, //秒杀开始 结束 的控制(1正在进行,2即将开始) | ||
| 28 | - color_type: 0, //线条控制 | ||
| 29 | - color_type_one: 0, | ||
| 30 | - color_type_two: 1, | ||
| 31 | - is_no_plus:1, | ||
| 32 | - gid: "", | ||
| 33 | - stoid: o.stoid, | ||
| 34 | - url: o.url, | ||
| 35 | - resourceUrl: o.h5_url, //公众号那边的图片文件域名 | ||
| 36 | - iurl: o.imghost, | ||
| 37 | - defaultAvatar: o.resourceUrl + "/static/images/user68.jpg", | ||
| 38 | - | ||
| 39 | - data: null, | ||
| 40 | - content: "", //商品详情 | ||
| 41 | - comments: null, //商品评论 | ||
| 42 | - c_curr_p: 1, //评论分页 | ||
| 43 | - com_num: 0, //评论人数 | ||
| 44 | - gallery: null, //图片滚动 | ||
| 45 | - is_collect: 0, | ||
| 46 | - collect_id: 0, | ||
| 47 | - cartGoodsNum: 0, | ||
| 48 | - specSelect: 0, | ||
| 49 | - optionItemId: 0, | ||
| 50 | - goodsInputNum: 1, | ||
| 51 | - openSpecModal: !1, | ||
| 52 | - openSpecModal_pt: !1, //拼单的弹起, | ||
| 53 | - openPromModal: !1, | ||
| 54 | - activeCategoryId: 0, | ||
| 55 | - supportPageScroll: !1, | ||
| 56 | - address: { | ||
| 57 | - address: "", | ||
| 58 | - district: 0 | ||
| 59 | - }, | ||
| 60 | - shipping: "", | ||
| 61 | - shippingCost: 0, | ||
| 62 | - enterAddressPage: !1, | ||
| 63 | - categories: [{ | ||
| 64 | - name: "商品", | ||
| 65 | - id: 0 | ||
| 66 | - }, { | ||
| 67 | - name: "详情", | ||
| 68 | - id: 1 | ||
| 69 | - }, { | ||
| 70 | - name: "评价", | ||
| 71 | - id: 2 | ||
| 72 | - }], | ||
| 73 | - activeCategoryId2: 0, | ||
| 74 | - categories2: [{ | ||
| 75 | - name: "商品详情", | ||
| 76 | - id: 0 | ||
| 77 | - }, { | ||
| 78 | - name: "规格参数", | ||
| 79 | - id: 1 | ||
| 80 | - }], | ||
| 81 | - activeCategoryId3: 1, | ||
| 82 | - categories3: [{ | ||
| 83 | - name: "全部", | ||
| 84 | - id: 1, | ||
| 85 | - num: 0 | ||
| 86 | - }, | ||
| 87 | - { | ||
| 88 | - name: "有图", | ||
| 89 | - id: 5, | ||
| 90 | - num: 0 | ||
| 91 | - }, | ||
| 92 | - | ||
| 93 | - { | ||
| 94 | - name: "好评", | ||
| 95 | - id: 2, | ||
| 96 | - num: 0 | ||
| 97 | - }, { | ||
| 98 | - name: "中评", | ||
| 99 | - id: 3, | ||
| 100 | - num: 0 | ||
| 101 | - }, { | ||
| 102 | - name: "差评", | ||
| 103 | - id: 4, | ||
| 104 | - num: 0 | ||
| 105 | - }, | ||
| 106 | - ], | ||
| 107 | - | ||
| 108 | - select: { | ||
| 109 | - price: 0, | ||
| 110 | - stock: 0, | ||
| 111 | - specName: "", | ||
| 112 | - activity: null | ||
| 113 | - }, | ||
| 114 | - | ||
| 115 | - //已选的商品(属性) | ||
| 116 | - sele_g_spec_name: '', | ||
| 117 | - sele_g_id: '', | ||
| 118 | - sele_g: null, | ||
| 119 | - //门店相关 | ||
| 120 | - ismend: 0, | ||
| 121 | - is_sec_mend: 0, | ||
| 122 | - sto_sele_name: "", //选中的门店名称 | ||
| 123 | - sto_sele_id: "", //选中的门店id | ||
| 124 | - sto_sele_distr: "", //选择的门店的配送方式 | ||
| 125 | - is_show_sto_cat: 1, //是否显示门店分类 | ||
| 126 | - only_pk: null, | ||
| 127 | - all_sto: null, | ||
| 128 | - sec_sto: null, //选择了的门店分类 | ||
| 129 | - pickpu_list: null, //读出的所有门店list | ||
| 130 | - def_pickpu_list: null, //一开始5个门店list | ||
| 131 | - sec_pick_index: 0, //第二级门店选择ID | ||
| 132 | - fir_pick_index: 0, //第一级门店选择ID | ||
| 133 | - all_pick_list: null,//所有的门店先记录起来 | ||
| 134 | - //同一条形码的所有商品 | ||
| 135 | - sku_g: null, | ||
| 136 | - sku_g_pt: null, //---拼单的普通购买--- | ||
| 137 | - //联系电话 | ||
| 138 | - mobile: '', | ||
| 139 | - //分类,品牌,国别名称 | ||
| 140 | - cat_name: '', | ||
| 141 | - brand_name: '', | ||
| 142 | - nation_name: '', | ||
| 143 | - | ||
| 144 | - //商品的活动类型 0普通 1秒杀 2团购 3优惠 4 积分购 6拼单 | ||
| 145 | - prom_type: 0, | ||
| 146 | - prom_time_text: "", | ||
| 147 | - prom_price: null, | ||
| 148 | - prom_buy_limit: 0, | ||
| 149 | - djs: null, | ||
| 150 | - prom_st: 0, | ||
| 151 | - prom_r_null: 0, | ||
| 152 | - prom_end_time: null, | ||
| 153 | - prom_start_time: null, | ||
| 154 | - prom_act: null, | ||
| 155 | - pd_xx: 0, | ||
| 156 | - is_normal: 0, //是否普通购买 | ||
| 157 | - teamgroup: null, //有多少人开团 | ||
| 158 | - grounp_tatal: 0, //有几个人开团 | ||
| 159 | - timer: [], | ||
| 160 | - | ||
| 161 | - //商品的购买次数 | ||
| 162 | - prom_buy_num: -1, | ||
| 163 | - g_buy_num: null, | ||
| 164 | - prom_goods_num: 0, //活动商品数量 | ||
| 165 | - prom_buy_num: 0, //活动商品购买数量 | ||
| 166 | - prom_redis_num: 0, //活动商品redis数量 | ||
| 167 | - | ||
| 168 | - //拼单的规则显示 | ||
| 169 | - is_show_gz: 0, | ||
| 170 | - //会员自己的购买的拼单商品的情况 | ||
| 171 | - user_order_pt_state: 0, | ||
| 172 | - //购买的订单 | ||
| 173 | - buy_order: null, | ||
| 174 | - //1加入购物车 2立即购买 | ||
| 175 | - openSpecModal_ind: 0, | ||
| 176 | - | ||
| 177 | - //---计时器开关---- | ||
| 178 | - is_timer: 1, | ||
| 179 | - isshow: 0, | ||
| 180 | - bconfig: null, //基础配置 | ||
| 181 | - | ||
| 182 | - fir_comments: null, //详情页上的评价 | ||
| 183 | - fir_quan: null, //详情页上的券 | ||
| 184 | - quan_list: null, //券列表 | ||
| 185 | - | ||
| 186 | - coupon: 0, | ||
| 187 | - //会员分享的头像 | ||
| 188 | - share_head: "", | ||
| 189 | - share_goods_img: "", | ||
| 190 | - | ||
| 191 | - //----------视频图片data参数--------- | ||
| 192 | - current: 0, //图片计数 | ||
| 193 | - swiperCurrent: 0, //轮播的下标 | ||
| 194 | - hiddenn: 0, //控制轮播计数显示 | ||
| 195 | - | ||
| 196 | - currentTab: 0, // 选择器控制参数 | ||
| 197 | - mapurl: "", | ||
| 198 | - mapurl_f_img: "", | ||
| 199 | - videopicture: 0, //视频图片的控制 | ||
| 200 | - | ||
| 201 | - video: 0, //视频图片切换器 | ||
| 202 | - index: 0, | ||
| 203 | - noon: 0, //开始视频的隐藏 | ||
| 204 | - | ||
| 205 | - screenWidth: 0, | ||
| 206 | - canvasHidden: 1, | ||
| 207 | - | ||
| 208 | - //--推荐-- | ||
| 209 | - store_config: null, | ||
| 210 | - is_show_pl: 0, //是否品类 | ||
| 211 | - is_show_pp: 0, //是否品牌 | ||
| 212 | - is_show_gb: 0, //是否国别 | ||
| 213 | - is_closecoupon: 0, | ||
| 214 | - | ||
| 215 | - //是否点赞中 | ||
| 216 | - iszaning: 0, | ||
| 217 | - | ||
| 218 | - select_store: 0, //选择更多 | ||
| 219 | - index: 1, | ||
| 220 | - more_store: 0, //选择门店 | ||
| 221 | - sort_store: 0, //门店分类 | ||
| 222 | - choice_sort_store: 0, //选择分类门店 | ||
| 223 | - new_user: 0, //新用户 | ||
| 224 | - | ||
| 225 | - def_pick_store: null, // 默认的门店 | ||
| 226 | - fir_def_store: null, //客户默认的门店的 | ||
| 227 | - lat: null, //维度 | ||
| 228 | - lon: null, //经度 | ||
| 229 | - | ||
| 230 | - is_get_local_ok: 0, //获取坐标是否完成 | ||
| 231 | - region_name: "门店分类", //区域的名字 | ||
| 232 | - is_gps: 1, | ||
| 233 | - open_ind_store: 0, //哪里打开的门店列表的控制属性 | ||
| 234 | - default_store: {}, //创建添加默认门店地址的对象 | ||
| 235 | - | ||
| 236 | - comments_no_more: 0, | ||
| 237 | - get_c: 0, //获取评价是不是成 | ||
| 238 | - is_collect_load: 0, //是不是处理 | ||
| 239 | - is_newsales_rules: 0, //是否开启最新的门店规则,此时会新读门店,当点击选择门店时会触发读取线下库存 | ||
| 240 | - sales_rules: 1, //默认是线上销售 | ||
| 241 | - | ||
| 242 | - wait_for_user_store: null, | ||
| 243 | - prom_goods: null, //商品优惠列表 | ||
| 244 | - order_prom: null, //订单优惠 | ||
| 245 | - collocationGoods: null, //搭配购 | ||
| 246 | - | ||
| 247 | - poster: null, //自定义海报 | ||
| 248 | - share_b_img: '', //自定义分享的背景 | ||
| 249 | - | ||
| 250 | - showPoster: false, | ||
| 251 | - hui_condition: null, | ||
| 252 | - sto_sele_name_1: '',//分享的门店名称 | ||
| 253 | - fir_goods: null, | ||
| 254 | - | ||
| 255 | - share_hidden: false, | ||
| 256 | - all_activity_list: null, //所有活动的列表 | ||
| 257 | - | ||
| 258 | - hiddenCS: true, | ||
| 259 | - }, | ||
| 260 | - | ||
| 261 | - //------初始化加载---------- | ||
| 262 | - onLoad: function (t) { | ||
| 263 | - var ee = this, | ||
| 264 | - that = ee, | ||
| 265 | - th = ee, | ||
| 266 | - gid = t.goods_id, | ||
| 267 | - first_leader = t.first_leader, | ||
| 268 | - room_id = t.room_id, | ||
| 269 | - room_user_share = t.room_user_share, //如果是会员分享带有room_id的话,那么接下来会员分享就不传room_id | ||
| 270 | - prom_type = t.prom_type, | ||
| 271 | - prom_id = t.prom_id; //活动ID | ||
| 272 | - | ||
| 273 | - self = this; | ||
| 274 | - | ||
| 275 | - //检查测肤 | ||
| 276 | - getApp().check_skin_face(t,0,gid); | ||
| 277 | - | ||
| 278 | - //-- 自定义海报 -- | ||
| 279 | - getApp().request.promiseGet("/api/weshop/goods/poster/page", { | ||
| 280 | - data: {store_id: os.stoid, type: 1, is_use: 1} | ||
| 281 | - }).then(res => { | ||
| 282 | - if (res.data.code == 0 && res.data.data && res.data.data.pageData && res.data.data.pageData[0]) { | ||
| 283 | - | ||
| 284 | - var poster_data = res.data.data.pageData[0]; | ||
| 285 | - var json_str = poster_data.jsonStr; | ||
| 286 | - | ||
| 287 | - if (json_str) { | ||
| 288 | - var json_data = JSON.parse(json_str); | ||
| 289 | - if (json_data.bg_img) { | ||
| 290 | - | ||
| 291 | - //-- 把图片那到本地 -- | ||
| 292 | - wx.getImageInfo({ | ||
| 293 | - src: json_data.bg_img, | ||
| 294 | - success: function (res) { | ||
| 295 | - var path = res.path; | ||
| 296 | - th.setData({share_b_img: path}) | ||
| 297 | - }, | ||
| 298 | - fail: function (res) { | ||
| 299 | - } | ||
| 300 | - }); | ||
| 301 | - } | ||
| 302 | - th.setData({poster: json_data}) | ||
| 303 | - | ||
| 304 | - } | ||
| 305 | - } | ||
| 306 | - }) | ||
| 307 | - | ||
| 308 | - //---获取手机地址坐标-- | ||
| 309 | - //--如果tg_id是空的话,分享回来-- | ||
| 310 | - if (gid == undefined || gid == null || gid == "") { | ||
| 311 | - var gid_str = decodeURIComponent(t.scene); | ||
| 312 | - gid_str = gid_str.split("_"); | ||
| 313 | - gid = gid_str[0]; | ||
| 314 | - if (gid.indexOf('.') != -1) { | ||
| 315 | - var fir_arr = gid.split("."); | ||
| 316 | - gid = fir_arr[0]; | ||
| 317 | - prom_type = fir_arr[1]; | ||
| 318 | - prom_id = fir_arr[2]; | ||
| 319 | - this.data.prom_type = prom_type; | ||
| 320 | - this.data.prom_id = prom_id; | ||
| 321 | - } | ||
| 322 | - | ||
| 323 | - if (gid_str.length > 1) { | ||
| 324 | - first_leader = gid_str[1]; | ||
| 325 | - } | ||
| 326 | - //-- 如果有room_id的获取 -- | ||
| 327 | - if (gid_str.length > 2 && gid_str[2]) { | ||
| 328 | - room_id = gid_str[2]; | ||
| 329 | - room_user_share = 1; | ||
| 330 | - } | ||
| 331 | - | ||
| 332 | - } | ||
| 333 | - | ||
| 334 | - | ||
| 335 | - //判断活动 | ||
| 336 | - if (prom_type) { | ||
| 337 | - this.data.prom_type = prom_type; | ||
| 338 | - this.data.prom_id = prom_id; | ||
| 339 | - } | ||
| 340 | - ee.setData({gid: gid}); | ||
| 341 | - | ||
| 342 | - console.log("gd onload--2"); | ||
| 343 | - console.log(first_leader); | ||
| 344 | - | ||
| 345 | - if(first_leader) { | ||
| 346 | - console.log("gd onload--3"); | ||
| 347 | - console.log("log---"+first_leader); | ||
| 348 | - getApp().globalData.first_leader = first_leader; | ||
| 349 | - //调用接口判断是不是会员 | ||
| 350 | - getApp().request.promiseGet("/api/weshop/shoppingGuide/get/" + os.stoid + "/" + first_leader, {}).then(res => { | ||
| 351 | - if (res.data.code == 0) { | ||
| 352 | - getApp().globalData.guide_id = res.data.data.id; | ||
| 353 | - } | ||
| 354 | - }) | ||
| 355 | - } | ||
| 356 | - | ||
| 357 | - //-- 如果有房间号 -- | ||
| 358 | - if (room_id) { | ||
| 359 | - getApp().globalData.room_id = room_id; | ||
| 360 | - getApp().globalData.room_goods_id = gid; | ||
| 361 | - //如果是会员分享过来的要记录 | ||
| 362 | - if (room_user_share) | ||
| 363 | - getApp().globalData.room_user_share = room_user_share; | ||
| 364 | - } | ||
| 365 | - | ||
| 366 | - var c_guide_id = t.c_guide_id; | ||
| 367 | - if (c_guide_id) { | ||
| 368 | - th.data.c_guide_id = c_guide_id; | ||
| 369 | - } | ||
| 370 | - | ||
| 371 | - //调用接口判断商家plus有没有过期 | ||
| 372 | - getApp().request.promiseGet("/store/storemoduleendtime/page?store_id=" + os.stoid + "&type=3", {}).then(res => { | ||
| 373 | - if (res.data.code == 0) { | ||
| 374 | - var arr = res.data.data.pageData; | ||
| 375 | - if (arr.length > 0) { | ||
| 376 | - var item = arr[0]; | ||
| 377 | - if (item.is_sy == 0) { | ||
| 378 | - var now = Date.parse(new Date()); now = now / 1000; | ||
| 379 | - if (item.end_time < now) { | ||
| 380 | - th.setData({ is_no_plus: 0 }) | ||
| 381 | - } | ||
| 382 | - } | ||
| 383 | - } | ||
| 384 | - } | ||
| 385 | - }) | ||
| 386 | - | ||
| 387 | - getApp().getConfig(function (e) { | ||
| 388 | - ee.setData({sto_sele_name_1: e.store_name}) | ||
| 389 | - }) | ||
| 390 | - | ||
| 391 | - //----获取系统参数----- | ||
| 392 | - getApp().getConfig2(function (e) { | ||
| 393 | - ee.setData({ | ||
| 394 | - bconfig: e, | ||
| 395 | - sales_rules: e.sales_rules, | ||
| 396 | - }); | ||
| 397 | - | ||
| 398 | - if (e.categoryset.indexOf("," + 1 + ",") != -1) { | ||
| 399 | - ee.setData({ | ||
| 400 | - is_show_pl: 1 | ||
| 401 | - }); | ||
| 402 | - } | ||
| 403 | - if (e.categoryset.indexOf("," + 3 + ",") != -1) { | ||
| 404 | - ee.setData({ | ||
| 405 | - is_show_pp: 1 | ||
| 406 | - }); | ||
| 407 | - } | ||
| 408 | - if (e.categoryset.indexOf("," + 2 + ",") != -1) { | ||
| 409 | - ee.setData({ | ||
| 410 | - is_show_gb: 1 | ||
| 411 | - }); | ||
| 412 | - } | ||
| 413 | - console.log(e); | ||
| 414 | - var json_d = JSON.parse(e.switch_list); | ||
| 415 | - ee.setData({ | ||
| 416 | - store_config: e, | ||
| 417 | - sys_switch: json_d, | ||
| 418 | - is_closecoupon: json_d.is_closecoupon, | ||
| 419 | - is_newsales_rules: json_d.is_newsales_rules | ||
| 420 | - }); | ||
| 421 | - ee.init(gid); | ||
| 422 | - //------几人评价------- | ||
| 423 | - //n.init(th, "", "comments"); | ||
| 424 | - | ||
| 425 | - th.requestCardNum(), wx.pageScrollTo && th.setData({ | ||
| 426 | - supportPageScroll: !0 | ||
| 427 | - }); | ||
| 428 | - | ||
| 429 | - //计算等级价相关 | ||
| 430 | - var swithc_list = e.switch_list; | ||
| 431 | - var sw_arr = JSON.parse(swithc_list); | ||
| 432 | - //---如果后台又开等级卡的开关--- | ||
| 433 | - if (sw_arr.rank_switch && sw_arr.rank_switch == "2") { | ||
| 434 | - th.setData({rank_switch: true}); | ||
| 435 | - //---回调卡的列表--- | ||
| 436 | - th.getPlusCardType(function (ob) { | ||
| 437 | - th.setData({card_list: ob.card_list}); | ||
| 438 | - var ti = setInterval(function () { | ||
| 439 | - var user = getApp().globalData.userInfo; | ||
| 440 | - if (!user) return false; | ||
| 441 | - clearInterval(ti); | ||
| 442 | - if (user.card_field && user['card_expiredate']) { | ||
| 443 | - var str = user['card_expiredate'].replace(/-/g, '/'); | ||
| 444 | - var end = new Date(str); | ||
| 445 | - end = Date.parse(end) / 1000; | ||
| 446 | - var now = ut.gettimestamp(); | ||
| 447 | - //--- 判断是等级会员,且在有效期范围内 --- | ||
| 448 | - if (user.card_field && now < end) { | ||
| 449 | - var card_name = ob.name_map.get(user.card_field); | ||
| 450 | - //if(card_name.length>6) card_name=card_name.substring(0,6); | ||
| 451 | - | ||
| 452 | - var is_near_date = 0; | ||
| 453 | - if (end - now < 60 * 60 * 30 * 24) is_near_date = 1; //如果小于30天 | ||
| 454 | - th.setData({ | ||
| 455 | - card_field: user.card_field, | ||
| 456 | - card_name: card_name, | ||
| 457 | - card_list: ob.card_list, | ||
| 458 | - is_near_date: is_near_date | ||
| 459 | - }); | ||
| 460 | - } | ||
| 461 | - } | ||
| 462 | - }, 500) | ||
| 463 | - }) | ||
| 464 | - } | ||
| 465 | - | ||
| 466 | - }, 1); | ||
| 467 | - | ||
| 468 | - //获取用户设备信息,屏幕宽度 | ||
| 469 | - wx.getSystemInfo({ | ||
| 470 | - success: res => { | ||
| 471 | - that.setData({ | ||
| 472 | - screenWidth: res.screenWidth | ||
| 473 | - }) | ||
| 474 | - } | ||
| 475 | - }); | ||
| 476 | - | ||
| 477 | - //获取用户的默认门店 | ||
| 478 | - getApp().get_user_store(function (e) { | ||
| 479 | - if (!e) { | ||
| 480 | - th.data.fir_def_store = {}; //赋值空对象 | ||
| 481 | - return false; | ||
| 482 | - } | ||
| 483 | - var ee = JSON.parse(JSON.stringify(e)); | ||
| 484 | - //--定时器推迟一下-- | ||
| 485 | - setTimeout(function () { | ||
| 486 | - if (th.data.fir_goods) var g_distr_type = th.data.fir_goods.distr_type; | ||
| 487 | - //--如果默认门店的配送方式不对,就不能被选择,这里不控制,如果不一样,就说明配送方式不对-- | ||
| 488 | - if (ee.distr_type != 0 && g_distr_type != 0 && ee.distr_type != g_distr_type) { | ||
| 489 | - ee.is_no_dis = 1; | ||
| 490 | - } | ||
| 491 | - | ||
| 492 | - var appd = getApp().globalData; | ||
| 493 | - var w_time = setInterval(function () { | ||
| 494 | - if (that.data.is_get_local_ok == 0) return false; | ||
| 495 | - clearInterval(w_time); | ||
| 496 | - var distance = null; | ||
| 497 | - var e = JSON.parse(JSON.stringify(ee)); | ||
| 498 | - | ||
| 499 | - //如果有开启近距离的话,同时距离优不一样了 | ||
| 500 | - if (that.data.lat != null) { | ||
| 501 | - //如果经纬度有变化的话 | ||
| 502 | - if (e && appd.lat == that.data.lat && appd.lon == that.data.lon && e.distance > 0) { | ||
| 503 | - that.set_def_storage(e); | ||
| 504 | - } else { | ||
| 505 | - //要用接口是获取距离,js的计算不准 | ||
| 506 | - getApp().request.promiseGet("/api/weshop/pickup/list", { | ||
| 507 | - data: { | ||
| 508 | - store_id: os.stoid, | ||
| 509 | - pickup_id: e.pickup_id, | ||
| 510 | - lat: th.data.lat, | ||
| 511 | - lon: th.data.lon, | ||
| 512 | - isstop: 0, | ||
| 513 | - is_pos: 1 | ||
| 514 | - }, | ||
| 515 | - }).then(res => { | ||
| 516 | - if (res.data.code == 0) { | ||
| 517 | - e = res.data.data.pageData[0]; | ||
| 518 | - if (e) { | ||
| 519 | - e.is_no_dis = ee.is_no_dis; | ||
| 520 | - appd.pk_store = e; | ||
| 521 | - that.set_def_storage(e); | ||
| 522 | - } | ||
| 523 | - | ||
| 524 | - } | ||
| 525 | - }) | ||
| 526 | - } | ||
| 527 | - //e.distance = distance; | ||
| 528 | - appd.lat = that.data.lat; | ||
| 529 | - appd.lon = that.data.lon; | ||
| 530 | - | ||
| 531 | - } else { | ||
| 532 | - if (e) { | ||
| 533 | - e.distance = null; | ||
| 534 | - that.set_def_storage(e); | ||
| 535 | - } | ||
| 536 | - } | ||
| 537 | - }, 500) | ||
| 538 | - }, 700) | ||
| 539 | - }); | ||
| 540 | - | ||
| 541 | - //更新点击量 | ||
| 542 | - getApp().request.put("/api/weshop/goods/updateClick", { | ||
| 543 | - data: {store_id: os.stoid, goods_id: gid} | ||
| 544 | - }); | ||
| 545 | - | ||
| 546 | - | ||
| 547 | - }, | ||
| 548 | - | ||
| 549 | - | ||
| 550 | - //--- 设置一下默认库存的数量 ---- | ||
| 551 | - set_def_storage(ee) { | ||
| 552 | - var that = this, th = this; | ||
| 553 | - getApp().getConfig2(function (e) { | ||
| 554 | - var sales_rules = e.sales_rules; | ||
| 555 | - if (sales_rules == 2) { | ||
| 556 | - getApp().waitfor2(that, "wait_for_user_store", "fir_goods", function () { | ||
| 557 | - var lock = 0, plist = null; | ||
| 558 | - var gd = that.data.fir_goods; | ||
| 559 | - //先读取门店的lock,采用链式写法,少用await | ||
| 560 | - getApp().request.promiseGet("/api/weshop/order/ware/lock/page", { | ||
| 561 | - data: { | ||
| 562 | - store_id: os.stoid, | ||
| 563 | - wareId: that.data.fir_goods.goods_id, | ||
| 564 | - storageId: ee.pickup_id, | ||
| 565 | - pageSize: 1000 | ||
| 566 | - } | ||
| 567 | - }).then(res => { | ||
| 568 | - if (res.data.code == 0 && res.data.data.total > 0) { | ||
| 569 | - for (var i in res.data.data.pageData) | ||
| 570 | - lock += res.data.data.pageData[i].outQty | ||
| 571 | - } | ||
| 572 | - //---通过接口获取门店的线下库存信息-- | ||
| 573 | - return getApp().request.promiseGet("/api/weshop/goods/getWareStorages", { | ||
| 574 | - data: { | ||
| 575 | - storageNos: ee.pickup_no, | ||
| 576 | - wareIds: encodeURIComponent(th.data.data.erpwareid), | ||
| 577 | - storeId: os.stoid | ||
| 578 | - } | ||
| 579 | - }) | ||
| 580 | - }).then(res => { | ||
| 581 | - if (res.data.code == 0 && res.data.data.total > 0) { | ||
| 582 | - plist = res.data.data.pageData[0]; | ||
| 583 | - } else { | ||
| 584 | - wx.showToast({ | ||
| 585 | - title: '库存不足,请更换其他门店', | ||
| 586 | - icon: 'none', | ||
| 587 | - }); | ||
| 588 | - } | ||
| 589 | - ; | ||
| 590 | - if (plist && plist.CanOutQty - lock > 0) { | ||
| 591 | - ee.CanOutQty = plist.CanOutQty - lock; | ||
| 592 | - } else { | ||
| 593 | - ee.CanOutQty = 0; | ||
| 594 | - } | ||
| 595 | - //--给门店赋值线下库存-- | ||
| 596 | - that.data.fir_def_store = ee; | ||
| 597 | - that.setData({ | ||
| 598 | - def_pick_store: ee, | ||
| 599 | - sto_sele_name: ee.pickup_name, | ||
| 600 | - sto_sele_id: ee.pickup_id, | ||
| 601 | - sto_sele_distr: ee.distr_type | ||
| 602 | - }) | ||
| 603 | - }) | ||
| 604 | - }) | ||
| 605 | - } else { | ||
| 606 | - that.data.fir_def_store = ee; | ||
| 607 | - that.setData({ | ||
| 608 | - def_pick_store: ee, | ||
| 609 | - sto_sele_name: ee.pickup_name, | ||
| 610 | - sto_sele_id: ee.pickup_id, | ||
| 611 | - sto_sele_distr: ee.distr_type | ||
| 612 | - }) | ||
| 613 | - } | ||
| 614 | - }) | ||
| 615 | - | ||
| 616 | - }, | ||
| 617 | - | ||
| 618 | - | ||
| 619 | - //------------程序初始化入口------------- | ||
| 620 | - async init(gid) { | ||
| 621 | - var ee = this, | ||
| 622 | - th = ee, | ||
| 623 | - gallery = null, | ||
| 624 | - is_collect = 0, | ||
| 625 | - collect_id = 0, | ||
| 626 | - categories3 = ee.data.categories3, | ||
| 627 | - fir_com = null, | ||
| 628 | - fir_quan = null, | ||
| 629 | - mapurl = null, | ||
| 630 | - mapurl_f_img = null; | ||
| 631 | - | ||
| 632 | - | ||
| 633 | - //------图片滚动---------- | ||
| 634 | - await getApp().request.promiseGet("/api/weshop/goodsimages/page", { | ||
| 635 | - data: { | ||
| 636 | - store_id: os.stoid, | ||
| 637 | - goods_id: gid, | ||
| 638 | - }, | ||
| 639 | - }).then(res => { | ||
| 640 | - | ||
| 641 | - var t = res; | ||
| 642 | - var g = t.data.data.pageData; | ||
| 643 | - if (g.length == 0) { | ||
| 644 | - var ie = { | ||
| 645 | - "image_url": o.imghost + "/public/images/default_goods_image_240.gif" | ||
| 646 | - }; | ||
| 647 | - g.push(ie); | ||
| 648 | - gallery = g; | ||
| 649 | - return; | ||
| 650 | - } | ||
| 651 | - for (var i = 0; i < g.length; i++) { | ||
| 652 | - if (g[i].image_url.indexOf(o.imghost) == -1) | ||
| 653 | - g[i].image_url = o.imghost + g[i].image_url; | ||
| 654 | - } | ||
| 655 | - gallery = g; | ||
| 656 | - }) | ||
| 657 | - //------是否收藏---------- | ||
| 658 | - await getApp().request.promiseGet("/api/weshop/goodscollect/page", { | ||
| 659 | - data: { | ||
| 660 | - store_id: os.stoid, | ||
| 661 | - goods_id: gid, | ||
| 662 | - user_id: oo.user_id, | ||
| 663 | - } | ||
| 664 | - }).then(res => { | ||
| 665 | - var t = res; | ||
| 666 | - var data = t.data.data.pageData; | ||
| 667 | - if (data && data.length > 0) { | ||
| 668 | - //ee.setData({ is_collect: 1, collect_id: data[0].collect_id, }); | ||
| 669 | - is_collect = 1; | ||
| 670 | - collect_id = data[0].collect_id; | ||
| 671 | - } | ||
| 672 | - }) | ||
| 673 | - | ||
| 674 | - //------获取评价的统计数量---- | ||
| 675 | - await getApp().request.promiseGet("/api/weshop/comment/countlist/", { | ||
| 676 | - data: { | ||
| 677 | - store_id: os.stoid, | ||
| 678 | - goods_id: gid | ||
| 679 | - }, | ||
| 680 | - //failRollback: !0, | ||
| 681 | - | ||
| 682 | - }).then(res => { | ||
| 683 | - var t = res; | ||
| 684 | - var g = t.data.data[0]; | ||
| 685 | - if (g != null && g != undefined) { | ||
| 686 | - var allnum = g.c0 + g.c1 + g.c2 + g.c3 + g.c4 + g.c5; | ||
| 687 | - var num2 = g.c4 + g.c5; | ||
| 688 | - var num3 = g.c3; | ||
| 689 | - var num4 = g.c0 + g.c1 + g.c2; | ||
| 690 | - | ||
| 691 | - var dd = ee.data.categories3; | ||
| 692 | - dd[0].num = allnum; | ||
| 693 | - dd[1].num = g.cimg; | ||
| 694 | - dd[2].num = num2; | ||
| 695 | - dd[3].num = num3; | ||
| 696 | - dd[4].num = num4; | ||
| 697 | - | ||
| 698 | - categories3 = dd; | ||
| 699 | - } | ||
| 700 | - }) | ||
| 701 | - | ||
| 702 | - //----获取详情页的评价---- | ||
| 703 | - await getApp().request.promiseGet("/api/weshop/comment/pageComment", { | ||
| 704 | - data: { | ||
| 705 | - store_id: os.stoid, | ||
| 706 | - goods_id: gid, | ||
| 707 | - pageSize: 3, | ||
| 708 | - parent_id: 0, | ||
| 709 | - page: 1, | ||
| 710 | - is_show: 1, | ||
| 711 | - }, | ||
| 712 | - }).then(res => { | ||
| 713 | - fir_com = res.data.data.pageData; | ||
| 714 | - }) | ||
| 715 | - | ||
| 716 | - if (fir_com) { | ||
| 717 | - for (var ind in fir_com) { | ||
| 718 | - if (fir_com[ind].head_pic == "") fir_com[ind].head_pic = ee.data.iurl + "/miniapp/images/hui_hear_pic.png"; | ||
| 719 | - if (fir_com[ind].img) fir_com[ind].img = ut.unserialize(fir_com[ind].img); | ||
| 720 | - if (fir_com[ind].weapp_img) fir_com[ind].weapp_img = JSON.parse(fir_com[ind].weapp_img); | ||
| 721 | - } | ||
| 722 | - } | ||
| 723 | - | ||
| 724 | - if (th.data.is_closecoupon != 1 && (!th.data.fir_quan || th.data.fir_quan.length <= 0)) { | ||
| 725 | - //----获取详情页的券的数量---- | ||
| 726 | - await getApp().request.promiseGet("/api/weshop/prom/coupon/pageCouponList", { | ||
| 727 | - data: { | ||
| 728 | - store_id: os.stoid, | ||
| 729 | - type: 1, | ||
| 730 | - pageSize: 3, | ||
| 731 | - page: 1, | ||
| 732 | - is_share: 0, | ||
| 733 | - }, | ||
| 734 | - }).then(res1 => { | ||
| 735 | - fir_quan = res1.data.data.pageData; | ||
| 736 | - }) | ||
| 737 | - } | ||
| 738 | - | ||
| 739 | - //--------获取视频图片--------- | ||
| 740 | - await getApp().request.promiseGet("/api/weshop/goodsVideos/get/" + os.stoid + "/" + ee.data.gid, { | ||
| 741 | - 1: 1 | ||
| 742 | - }).then(res1 => { | ||
| 743 | - if (res1.data.code == 0) { | ||
| 744 | - mapurl = res1.data.data.video_url; | ||
| 745 | - mapurl_f_img = res1.data.data.video_img; | ||
| 746 | - } | ||
| 747 | - }) | ||
| 748 | - this.getHistoryBuy(); //获取历史购买 | ||
| 749 | - ee.setData({ | ||
| 750 | - gallery: gallery, | ||
| 751 | - is_collect: is_collect, | ||
| 752 | - collect_id: collect_id, | ||
| 753 | - categories3: categories3, | ||
| 754 | - fir_quan: fir_quan, | ||
| 755 | - fir_comments: fir_com, | ||
| 756 | - mapurl_f_img: mapurl_f_img, | ||
| 757 | - mapurl: mapurl, | ||
| 758 | - }); | ||
| 759 | - | ||
| 760 | - }, | ||
| 761 | - | ||
| 762 | - //---展示--- | ||
| 763 | - onShow: function () { | ||
| 764 | - | ||
| 765 | - getApp().check_can_share(); | ||
| 766 | - | ||
| 767 | - var goods_list = null, th = this, that = this; | ||
| 768 | - var show_prew_img = this.data.show_prew_img | ||
| 769 | - if (show_prew_img) { | ||
| 770 | - show_prew_img = 0; | ||
| 771 | - return false; | ||
| 772 | - } | ||
| 773 | - | ||
| 774 | - if(this.data.show_video) { | ||
| 775 | - this.data.show_video=0; | ||
| 776 | - return false; | ||
| 777 | - } | ||
| 778 | - | ||
| 779 | - //优惠券要实时更新 | ||
| 780 | - getApp().getConfig2(function (e) { | ||
| 781 | - var json_d = JSON.parse(e.switch_list); | ||
| 782 | - th.setData({is_closecoupon: json_d.is_closecoupon}) | ||
| 783 | - th.setData({is_open_offline: json_d.is_pricing_open}) | ||
| 784 | - }, 1) | ||
| 785 | - | ||
| 786 | - | ||
| 787 | - var ui = setInterval(function () { | ||
| 788 | - goods_list = th.selectComponent("#goods_list"); | ||
| 789 | - if (goods_list) { | ||
| 790 | - clearInterval(ui); | ||
| 791 | - goods_list.init(); | ||
| 792 | - return false | ||
| 793 | - } | ||
| 794 | - }, 300) | ||
| 795 | - | ||
| 796 | - this.data.is_timer = 1; | ||
| 797 | - var ee = this, | ||
| 798 | - gid = this.data.gid, | ||
| 799 | - i = getApp().request; | ||
| 800 | - | ||
| 801 | - this.wait_for_store_config(); | ||
| 802 | - //先检验一下商品的活动情况 | ||
| 803 | - this.check_gd_prom_new(function () { | ||
| 804 | - i.get("/api/weshop/goods/get/" + o.stoid + "/" + ee.data.gid, { | ||
| 805 | - failRollback: !0, | ||
| 806 | - success: function (t) { | ||
| 807 | - console.log(t); | ||
| 808 | - if (t.data.code == 0) { | ||
| 809 | - if (t.data.data.is_on_sale != 1) { | ||
| 810 | - wx.showModal({ | ||
| 811 | - title: '商品已经下架', | ||
| 812 | - showCancel: !1, | ||
| 813 | - complete: function () { | ||
| 814 | - wx.navigateBack(); | ||
| 815 | - } | ||
| 816 | - }); | ||
| 817 | - } | ||
| 818 | - | ||
| 819 | - var timestamp = Date.parse(new Date()); | ||
| 820 | - timestamp = timestamp / 1000; | ||
| 821 | - if (t.data.data.on_time > timestamp) { | ||
| 822 | - wx.showModal({ | ||
| 823 | - title: '商品还未上架', | ||
| 824 | - showCancel: !1, | ||
| 825 | - complete: function () { | ||
| 826 | - wx.navigateBack(); | ||
| 827 | - } | ||
| 828 | - }); | ||
| 829 | - } | ||
| 830 | - | ||
| 831 | - if (t.data.data.down_time > 0) { | ||
| 832 | - if (t.data.data.down_time < timestamp) { | ||
| 833 | - wx.showModal({ | ||
| 834 | - title: '商品已经到期下架', | ||
| 835 | - showCancel: !1, | ||
| 836 | - complete: function () { | ||
| 837 | - wx.navigateBack(); | ||
| 838 | - } | ||
| 839 | - }); | ||
| 840 | - } | ||
| 841 | - } | ||
| 842 | - //动态获取商品名称 | ||
| 843 | - wx.setNavigationBarTitle({ | ||
| 844 | - title: t.data.data.goods_name, | ||
| 845 | - }); | ||
| 846 | - | ||
| 847 | - //-- 判断是不是组合购活动,必须要登录后才能判断 -- | ||
| 848 | - if (getApp().globalData.userInfo && t.data.data.prom_type == 7) { | ||
| 849 | - //获取活动信息 | ||
| 850 | - var url = "/api/weshop/prom/zhbuy/get/" + os.stoid + "/" + | ||
| 851 | - t.data.data.prom_id + "/" + getApp().globalData.user_id; | ||
| 852 | - getApp().request.get(url, { | ||
| 853 | - success: function (e) { | ||
| 854 | - if (e.data.code == 0 && e.data.data) { | ||
| 855 | - if (ut.gettimestamp() < e.data.data.start_time) { | ||
| 856 | - return false; | ||
| 857 | - } | ||
| 858 | - if (e.data.data.is_end == 0 && ut.gettimestamp() < e.data.data.end_time) { | ||
| 859 | - //-- 获取商品列表 -- | ||
| 860 | - th.setData({zh_act: e.data.data}); | ||
| 861 | - } | ||
| 862 | - | ||
| 863 | - } | ||
| 864 | - } | ||
| 865 | - }); | ||
| 866 | - } | ||
| 867 | - | ||
| 868 | - //-- 把商品的赋值,同时给活动赋值 -- | ||
| 869 | - ee.data.fir_goods = JSON.parse(JSON.stringify(t.data.data)); | ||
| 870 | - if (t.data.data.prom_type && t.data.data.prom_id) { | ||
| 871 | - ee.data.prom_type = t.data.data.prom_type; | ||
| 872 | - ee.data.prom_id = t.data.data.prom_id; | ||
| 873 | - } | ||
| 874 | - | ||
| 875 | - | ||
| 876 | - if (ee.data.prom_type != 1 && ee.data.prom_type != 4 && ee.data.prom_type != 6 && ee.data.prom_type != 2) { | ||
| 877 | - ee.check_is_youhui(ee.data.gid); | ||
| 878 | - } | ||
| 879 | - | ||
| 880 | - t.data.data.on_time = ut.formatTime(t.data.data.on_time, 'yyyy-MM-dd hh:mm:ss'); | ||
| 881 | - | ||
| 882 | - var cur_price = t.data.data.shop_price; | ||
| 883 | - if (getApp().globalData.userInfo && getApp().globalData.userInfo.card_field) { | ||
| 884 | - var cfile = getApp().globalData.userInfo.card_field; | ||
| 885 | - if (t.data.data[cfile]) { | ||
| 886 | - cur_price = t.data.data[cfile]; | ||
| 887 | - } | ||
| 888 | - } | ||
| 889 | - var txt = (cur_price / t.data.data.market_price * 10).toFixed(2).toString(); | ||
| 890 | - txt = parseFloat(txt); | ||
| 891 | - | ||
| 892 | - t.data.data['disc'] = txt; | ||
| 893 | - | ||
| 894 | - if (t.data.data.original_img.indexOf(o.imghost) == -1) | ||
| 895 | - t.data.data.original_img = o.imghost + t.data.data.original_img; | ||
| 896 | - | ||
| 897 | - if (t.data.data.goods_content == null) t.data.data.goods_content = ""; | ||
| 898 | - | ||
| 899 | - //-----商品详情--- | ||
| 900 | - if (!t.data.data.goods_content) t.data.data.goods_content = " "; | ||
| 901 | - a.wxParse("content", "html", t.data.data.goods_content, ee, 6); | ||
| 902 | - e.wxParseAddFullImageUrl(ee, "content"); | ||
| 903 | - | ||
| 904 | - if (ee.data.prom_type) { | ||
| 905 | - t.data.data.prom_type = ee.data.prom_type; | ||
| 906 | - t.data.data.prom_id = ee.data.prom_id; | ||
| 907 | - } | ||
| 908 | - ee.setData({ | ||
| 909 | - data: t.data.data, | ||
| 910 | - sele_g: t.data.data, | ||
| 911 | - userInfo: getApp().globalData.userInfo | ||
| 912 | - }); | ||
| 913 | - | ||
| 914 | - | ||
| 915 | - //获取统一条形码,普通商品和优惠促销的商品 | ||
| 916 | - if (ee.data.data.prom_type == 0 || ee.data.data.prom_type == 3 || ee.data.data.prom_type == 5 || ee.data.data.prom_type == 7 || ee.data.data.prom_type == 9 || ee.data.data.prom_type == 10) { | ||
| 917 | - //默认门店要拿下门店库存 | ||
| 918 | - if (that.data.sales_rules == 2 && that.data.is_newsales_rules) { | ||
| 919 | - //获取门店 | ||
| 920 | - ee.get_sto(); | ||
| 921 | - | ||
| 922 | - } else { | ||
| 923 | - //获取门店 | ||
| 924 | - ee.get_sto(); | ||
| 925 | - } | ||
| 926 | - | ||
| 927 | - ee.get_sku(o.stoid, t.data.data, gid); | ||
| 928 | - ee.check_has_flash(); | ||
| 929 | - | ||
| 930 | - } | ||
| 931 | - else { | ||
| 932 | - var gg = "", item = t.data.data; | ||
| 933 | - | ||
| 934 | - if (item.goods_spec == "null" || item.goods_spec == null) item.goods_spec = ""; | ||
| 935 | - if (item.goods_color == "null" || item.goods_color == null) item.goods_color = ""; | ||
| 936 | - | ||
| 937 | - if (item.goods_spec != "" && item.goods_color != "") { | ||
| 938 | - gg = item.goods_spec + "/" + item.goods_color; | ||
| 939 | - } else if (item.goods_spec != "" || item.goods_color != "") { | ||
| 940 | - gg = item.goods_spec + item.goods_color; | ||
| 941 | - } else { | ||
| 942 | - gg = "规格1"; | ||
| 943 | - } | ||
| 944 | - t.data.data.gg = gg; | ||
| 945 | - var uu = []; | ||
| 946 | - uu.push(t.data.data); | ||
| 947 | - ee.setData({ | ||
| 948 | - sku_g: uu, | ||
| 949 | - }); | ||
| 950 | - } | ||
| 951 | - ee.data.g_buy_num = new Map(); | ||
| 952 | - ee.check_prom(gid, ee.data.data.prom_type, ee.data.data.prom_id); | ||
| 953 | - | ||
| 954 | - var th = ee; | ||
| 955 | - if (ee.data.cat_name == '') { | ||
| 956 | - //过去国别,分类,品牌的名称 | ||
| 957 | - i.get("/api/weshop/goodscategory/get/" + o.stoid + "/" + th.data.data.cat_id, { | ||
| 958 | - success: function (t) { | ||
| 959 | - var dd = t.data.data; | ||
| 960 | - if (t.data.code == 0) { | ||
| 961 | - th.setData({ | ||
| 962 | - cat_name: dd.name | ||
| 963 | - }); | ||
| 964 | - } | ||
| 965 | - } | ||
| 966 | - }); | ||
| 967 | - //过去国别,分类,品牌的名称 | ||
| 968 | - i.get("/api/weshop/brand/get/" + o.stoid + "/" + th.data.data.brand_id, { | ||
| 969 | - success: function (t) { | ||
| 970 | - var dd = t.data.data; | ||
| 971 | - if (t.data.code == 0) { | ||
| 972 | - th.setData({ | ||
| 973 | - brand_name: dd.name | ||
| 974 | - }); | ||
| 975 | - } | ||
| 976 | - } | ||
| 977 | - }); | ||
| 978 | - //过去国别,分类,品牌的名称 | ||
| 979 | - i.get("/api/weshop/nation/get/" + o.stoid + "/" + th.data.data.nation_id, { | ||
| 980 | - success: function (t) { | ||
| 981 | - var dd = t.data.data; | ||
| 982 | - if (t.data.code == 0) { | ||
| 983 | - th.setData({ | ||
| 984 | - nation_name: dd.name | ||
| 985 | - }); | ||
| 986 | - } | ||
| 987 | - } | ||
| 988 | - }); | ||
| 989 | - } | ||
| 990 | - | ||
| 991 | - } | ||
| 992 | - else { | ||
| 993 | - wx.showModal({ | ||
| 994 | - title: t.data.msg, | ||
| 995 | - showCancel: !1, | ||
| 996 | - complete: function () { | ||
| 997 | - wx.navigateBack(); | ||
| 998 | - } | ||
| 999 | - }); | ||
| 1000 | - } | ||
| 1001 | - } | ||
| 1002 | - }); | ||
| 1003 | - }) | ||
| 1004 | - | ||
| 1005 | - this.data.enterAddressPage && (this.data.enterAddressPage = !1); | ||
| 1006 | - | ||
| 1007 | - | ||
| 1008 | - | ||
| 1009 | - }, | ||
| 1010 | - | ||
| 1011 | - onReady() { | ||
| 1012 | - | ||
| 1013 | - setTimeout(()=>{ | ||
| 1014 | - wx.createSelectorQuery().selectAll(".showArea, .hideArea").boundingClientRect(res => { | ||
| 1015 | - // console.log('node@@@@@@@', res); | ||
| 1016 | - if(res.length != 0) { | ||
| 1017 | - this.setData({ | ||
| 1018 | - showFold: res[0].height < res[1].height, | ||
| 1019 | - }); | ||
| 1020 | - }; | ||
| 1021 | - | ||
| 1022 | - }).exec(); | ||
| 1023 | - }, 1000); | ||
| 1024 | - | ||
| 1025 | - }, | ||
| 1026 | - | ||
| 1027 | - enterAddress: function () { | ||
| 1028 | - this.data.enterAddressPage = !0, wx.navigateTo({ | ||
| 1029 | - url: "/pages/user/address_list/address_list?operate=selectAddress" | ||
| 1030 | - }); | ||
| 1031 | - }, | ||
| 1032 | - onUnload: function () { | ||
| 1033 | - for (var i = 1; i < 100; i++) { | ||
| 1034 | - clearInterval(i); | ||
| 1035 | - } | ||
| 1036 | - }, | ||
| 1037 | - onHide: function () { | ||
| 1038 | - this.data.is_timer = 0; | ||
| 1039 | - for (var i = 1; i < 100; i++) { | ||
| 1040 | - clearInterval(i); | ||
| 1041 | - } | ||
| 1042 | - }, | ||
| 1043 | - //----------三个选项按钮----------- | ||
| 1044 | - tabClick: function (t) { | ||
| 1045 | - var e = t.currentTarget.id; | ||
| 1046 | - this.setData({ | ||
| 1047 | - activeCategoryId: e | ||
| 1048 | - }), 1 == e ? this.tabGoodsContent() : 2 == e && this.tabComment(); | ||
| 1049 | - }, | ||
| 1050 | - tabClick2: function (t) { | ||
| 1051 | - this.setData({ | ||
| 1052 | - activeCategoryId2: t.currentTarget.id | ||
| 1053 | - }); | ||
| 1054 | - }, | ||
| 1055 | - | ||
| 1056 | - tabClick3: function (t) { | ||
| 1057 | - var e = this; | ||
| 1058 | - if (t.currentTarget.id != this.data.activeCategoryId3) { | ||
| 1059 | - e.data.c_curr_p = 1; | ||
| 1060 | - this.setData({ | ||
| 1061 | - activeCategoryId3: t.currentTarget.id, | ||
| 1062 | - comments: null, comments_no_more: 0, get_c: 0, | ||
| 1063 | - }); | ||
| 1064 | - this.requestComments_new(); | ||
| 1065 | - } | ||
| 1066 | - }, | ||
| 1067 | - | ||
| 1068 | - doScrollTop: function () { | ||
| 1069 | - wx.pageScrollTo({ | ||
| 1070 | - scrollTop: 0 | ||
| 1071 | - }); | ||
| 1072 | - }, | ||
| 1073 | - | ||
| 1074 | - tabComment: function () { | ||
| 1075 | - this.setData({ | ||
| 1076 | - activeCategoryId: 2, comments_no_more: 0, get_c: 0 | ||
| 1077 | - }), this.data.comments || this.requestComments_new(); | ||
| 1078 | - }, | ||
| 1079 | - | ||
| 1080 | - //商品详情的时候调用 | ||
| 1081 | - tabGoodsContent: function () { | ||
| 1082 | - var th = this, | ||
| 1083 | - i = getApp().request; | ||
| 1084 | - this.setData({ | ||
| 1085 | - activeCategoryId: 1 | ||
| 1086 | - }); | ||
| 1087 | - | ||
| 1088 | - if (th.data.cat_name == '') { | ||
| 1089 | - //过去国别,分类,品牌的名称 | ||
| 1090 | - i.get("/api/weshop/goodscategory/get/" + o.stoid + "/" + th.data.data.cat_id, { | ||
| 1091 | - success: function (t) { | ||
| 1092 | - var dd = t.data.data; | ||
| 1093 | - if (t.data.code == 0) { | ||
| 1094 | - th.setData({ | ||
| 1095 | - cat_name: dd.name | ||
| 1096 | - }); | ||
| 1097 | - } | ||
| 1098 | - } | ||
| 1099 | - }); | ||
| 1100 | - //过去国别,分类,品牌的名称 | ||
| 1101 | - i.get("/api/weshop/brand/get/" + o.stoid + "/" + th.data.data.brand_id, { | ||
| 1102 | - success: function (t) { | ||
| 1103 | - var dd = t.data.data; | ||
| 1104 | - if (t.data.code == 0) { | ||
| 1105 | - th.setData({ | ||
| 1106 | - brand_name: dd.name | ||
| 1107 | - }); | ||
| 1108 | - } | ||
| 1109 | - } | ||
| 1110 | - }); | ||
| 1111 | - //过去国别,分类,品牌的名称 | ||
| 1112 | - i.get("/api/weshop/nation/get/" + o.stoid + "/" + th.data.data.nation_id, { | ||
| 1113 | - success: function (t) { | ||
| 1114 | - var dd = t.data.data; | ||
| 1115 | - if (t.data.code == 0) { | ||
| 1116 | - th.setData({ | ||
| 1117 | - nation_name: dd.name | ||
| 1118 | - }); | ||
| 1119 | - } | ||
| 1120 | - } | ||
| 1121 | - }); | ||
| 1122 | - } | ||
| 1123 | - }, | ||
| 1124 | - | ||
| 1125 | - //获取redis中的数量 | ||
| 1126 | - async getactLen(func) { | ||
| 1127 | - var r_num = 0, | ||
| 1128 | - prom_type = this.data.prom_type, | ||
| 1129 | - prom_id = this.data.prom_id; | ||
| 1130 | - await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + os.stoid + "/" + prom_type + "/" + prom_id, { | ||
| 1131 | - 1: 1 | ||
| 1132 | - }).then(res => { | ||
| 1133 | - var em = res; | ||
| 1134 | - if (em.data.code == 0) { | ||
| 1135 | - r_num = em.data.data; | ||
| 1136 | - } | ||
| 1137 | - }) | ||
| 1138 | - func(r_num); | ||
| 1139 | - }, | ||
| 1140 | - | ||
| 1141 | - //------------加入购物车-------------- | ||
| 1142 | - addCart: function (t) { | ||
| 1143 | - var th = this; | ||
| 1144 | - var ind = t.currentTarget.dataset.openSpecModal_ind; | ||
| 1145 | - if (!ind) ind = t.currentTarget.dataset.openspecmodal_ind; | ||
| 1146 | - th.setData({ | ||
| 1147 | - open_ind_store: ind | ||
| 1148 | - }); | ||
| 1149 | - | ||
| 1150 | - | ||
| 1151 | - if ("add" == t.currentTarget.dataset.action && getApp().is_sp_hao()) { | ||
| 1152 | - wx.showToast({ | ||
| 1153 | - title: "视频号商品不允许加入购物车", | ||
| 1154 | - icon: 'none', | ||
| 1155 | - duration: 2000 | ||
| 1156 | - }); | ||
| 1157 | - return false; | ||
| 1158 | - } | ||
| 1159 | - | ||
| 1160 | - | ||
| 1161 | - | ||
| 1162 | - //如果是秒杀的话,要看redis够不够 | ||
| 1163 | - if (this.data.prom_type == 1 || this.data.prom_type == 2) { | ||
| 1164 | - | ||
| 1165 | - if (this.data.openSpecModal_flash_normal) { | ||
| 1166 | - this.data.is_normal=1; //是普通购买 | ||
| 1167 | - th.add_cart_func(t); | ||
| 1168 | - return false; | ||
| 1169 | - } | ||
| 1170 | - | ||
| 1171 | - | ||
| 1172 | - this.getactLen(function (num) { | ||
| 1173 | - if (num < th.data.goodsInputNum) { | ||
| 1174 | - getApp().my_warnning("活动库存不足!", 0, th); | ||
| 1175 | - return false; | ||
| 1176 | - } else { | ||
| 1177 | - th.add_cart_func(t); | ||
| 1178 | - } | ||
| 1179 | - }); | ||
| 1180 | - } else { | ||
| 1181 | - th.add_cart_func(t); | ||
| 1182 | - } | ||
| 1183 | - }, | ||
| 1184 | - | ||
| 1185 | - //-- 加入购物的函数 -- | ||
| 1186 | - add_cart_func_inte: function (t) { | ||
| 1187 | - var i = getApp().request; | ||
| 1188 | - if (oo.user_id == null) { | ||
| 1189 | - return s.my_warnning("还未登录!", 0, this); | ||
| 1190 | - } | ||
| 1191 | - if (!getApp().globalData.userInfo) { | ||
| 1192 | - return s.my_warnning("还未登录!", 0, this); | ||
| 1193 | - } | ||
| 1194 | - | ||
| 1195 | - var e = this, | ||
| 1196 | - th = e, | ||
| 1197 | - a = 0, | ||
| 1198 | - o = this.data.data; | ||
| 1199 | - a = o.goods_id; | ||
| 1200 | - | ||
| 1201 | - //----------添加到购物车时,要判断限购数量,-------- | ||
| 1202 | - e.get_buy_num(o, function (ee) { | ||
| 1203 | - //---判断商品是否超出限购--- | ||
| 1204 | - if (th.data.g_buy_num != null && th.data.sele_g.viplimited > 0) { | ||
| 1205 | - if (th.data.goodsInputNum + th.data.g_buy_num.get(th.data.sele_g.goods_id) > th.data.sele_g.viplimited) { | ||
| 1206 | - // wx.showModal({ | ||
| 1207 | - // title: '提示', | ||
| 1208 | - // content: '超出商品限购' | ||
| 1209 | - // }); | ||
| 1210 | - s.my_warnning('超出商品限购', 0, th); | ||
| 1211 | - return false; | ||
| 1212 | - } | ||
| 1213 | - } | ||
| 1214 | - //---判断商品是否超出活动限购--- | ||
| 1215 | - if (th.data.prom_buy_num != -1 && th.data.prom_buy_limit > 0) { | ||
| 1216 | - if (th.data.goodsInputNum + th.data.prom_buy_num > th.data.prom_buy_limit) { | ||
| 1217 | - // wx.showModal({ | ||
| 1218 | - // title: '提示', | ||
| 1219 | - // content: '超出商品活动限购' | ||
| 1220 | - // }); | ||
| 1221 | - s.my_warnning('超出商品活动限购', 0, th); | ||
| 1222 | - return false; | ||
| 1223 | - } | ||
| 1224 | - } | ||
| 1225 | - | ||
| 1226 | - if (th.data.goodsInputNum <= 0) return s.my_warnning("商品数量不能为0", 0, th); | ||
| 1227 | - if (th.data.sto_sele_name == null || th.data.sto_sele_name == undefined) | ||
| 1228 | - this.setData({ | ||
| 1229 | - sto_sele_name: "" | ||
| 1230 | - }); | ||
| 1231 | - if (th.data.sto_sele_name == "") return s.my_warnning("请选择门店", 0, th); | ||
| 1232 | - | ||
| 1233 | - //--------------此时操作的数据------------ | ||
| 1234 | - var newd = { | ||
| 1235 | - goods_id: o.goods_id, | ||
| 1236 | - goods_num: th.data.goodsInputNum, | ||
| 1237 | - pick_id: th.data.sto_sele_id, | ||
| 1238 | - user_id: oo.user_id, | ||
| 1239 | - store_id: th.data.stoid, | ||
| 1240 | - goods_price: th.data.prom_price, | ||
| 1241 | - integral: th.data.prom_integral, | ||
| 1242 | - member_goods_price: o.shop_price, | ||
| 1243 | - goods_name: o.goods_name, | ||
| 1244 | - goods_sn: o.goods_sn, | ||
| 1245 | - sku: o.sku, | ||
| 1246 | - }; | ||
| 1247 | - | ||
| 1248 | - //---是不是从收藏夹出来的--- | ||
| 1249 | - if (th.data.c_guide_id) { | ||
| 1250 | - newd['guide_id'] = th.data.c_guide_id; | ||
| 1251 | - newd['guide_type'] = 2; | ||
| 1252 | - if ("add" == t.currentTarget.dataset.action) newd['guide_type'] = 3; | ||
| 1253 | - } else { | ||
| 1254 | - if (getApp().globalData.guide_id) { | ||
| 1255 | - newd['guide_id'] = getApp().globalData.guide_id; | ||
| 1256 | - newd['guide_type'] = 0; | ||
| 1257 | - if ("add" == t.currentTarget.dataset.action) newd['guide_type'] = 1; | ||
| 1258 | - } | ||
| 1259 | - } | ||
| 1260 | - | ||
| 1261 | - //让商品带上房间号 | ||
| 1262 | - //让商品带上房间号 | ||
| 1263 | - if (!th.data.sys_switch.is_skuroom_id && th.data.sys_switch.is_skuroom_id == 1) { | ||
| 1264 | - if (th.data.data.goods_id == getApp().globalData.room_goods_id) { | ||
| 1265 | - newd.room_id = getApp().globalData.room_id; | ||
| 1266 | - } | ||
| 1267 | - } else { | ||
| 1268 | - if (newd.goods_id == getApp().globalData.room_goods_id) newd.room_id = getApp().globalData.room_id; | ||
| 1269 | - } | ||
| 1270 | - | ||
| 1271 | - //如果是积分够,is_integral_normal就要有积分购普通购买字段 | ||
| 1272 | - //if(o.prom_type==4){ | ||
| 1273 | - //newd.is_integral_normal=1; | ||
| 1274 | - //} | ||
| 1275 | - | ||
| 1276 | - //-----如果是秒杀,团购,积分购,拼团----- | ||
| 1277 | - newd.prom_type = th.data.prom_type; | ||
| 1278 | - newd.prom_id = th.data.prom_id; | ||
| 1279 | - if (o.store_count <= 0) return s.my_warnning("库存已为空!", 0, th); | ||
| 1280 | - if (o.store_count < e.data.goodsInputNum) return s.my_warnning("库存不足!", 0, th); | ||
| 1281 | - | ||
| 1282 | - var i_canbuy = th.data.prom_act.limitqty - th.data.prom_act.buy_num; | ||
| 1283 | - if (i_canbuy < e.data.goodsInputNum) { | ||
| 1284 | - return s.my_warnning("活动库存不足!", 0, th); | ||
| 1285 | - } | ||
| 1286 | - th.add_cart_next(e, t, a, o, newd); //立即购买下一步 | ||
| 1287 | - | ||
| 1288 | - }) | ||
| 1289 | - }, | ||
| 1290 | - | ||
| 1291 | - //-- 加入购物的函数 -- | ||
| 1292 | - add_cart_func: function (t) { | ||
| 1293 | - var i = getApp().request; | ||
| 1294 | - if (oo.user_id == null) { | ||
| 1295 | - return s.my_warnning("还未登录!", 0, this); | ||
| 1296 | - } | ||
| 1297 | - | ||
| 1298 | - if (!getApp().globalData.userInfo) { | ||
| 1299 | - return s.my_warnning("还未登录!", 0, this); | ||
| 1300 | - } | ||
| 1301 | - | ||
| 1302 | - var e = this, | ||
| 1303 | - th = e, | ||
| 1304 | - a = 0, | ||
| 1305 | - o = this.data.sele_g; | ||
| 1306 | - a = o.goods_id; | ||
| 1307 | - | ||
| 1308 | - //----------添加到购物车时,要判断限购数量,-------- | ||
| 1309 | - e.get_buy_num(o, function (ee) { | ||
| 1310 | - //---判断商品是否超出限购--- | ||
| 1311 | - if (th.data.g_buy_num != null && th.data.sele_g.viplimited > 0) { | ||
| 1312 | - if (th.data.goodsInputNum + th.data.g_buy_num.get(th.data.sele_g.goods_id) > th.data.sele_g.viplimited) { | ||
| 1313 | - // wx.showModal({ | ||
| 1314 | - // title: '提示', | ||
| 1315 | - // content: '超出商品限购' | ||
| 1316 | - // }); | ||
| 1317 | - s.my_warnning('超出商品限购', 0, th); | ||
| 1318 | - return false; | ||
| 1319 | - } | ||
| 1320 | - } | ||
| 1321 | - //---判断商品是否超出活动限购--- | ||
| 1322 | - if ((th.data.prom_buy_num != -1 && th.data.prom_buy_limit > 0) && !th.data.is_normal) { | ||
| 1323 | - if (th.data.goodsInputNum + th.data.prom_buy_num > th.data.prom_buy_limit) { | ||
| 1324 | - // wx.showModal({ | ||
| 1325 | - // title: '提示', | ||
| 1326 | - // content: '超出商品活动限购' | ||
| 1327 | - // }); | ||
| 1328 | - s.my_warnning('超出商品活动限购', 0, th); | ||
| 1329 | - return false; | ||
| 1330 | - } | ||
| 1331 | - } | ||
| 1332 | - | ||
| 1333 | - if (th.data.goodsInputNum <= 0) return s.my_warnning("商品数量不能为0", 0, th); | ||
| 1334 | - if (th.data.sto_sele_name == null || th.data.sto_sele_name == undefined) | ||
| 1335 | - this.setData({ | ||
| 1336 | - sto_sele_name: "" | ||
| 1337 | - }); | ||
| 1338 | - if (th.data.sto_sele_name == "") return s.my_warnning("请选择门店", 0, th); | ||
| 1339 | - | ||
| 1340 | - //--------------此时操作的数据------------ | ||
| 1341 | - var newd = { | ||
| 1342 | - goods_id: o.goods_id, | ||
| 1343 | - goods_num: th.data.goodsInputNum, | ||
| 1344 | - pick_id: th.data.sto_sele_id, | ||
| 1345 | - user_id: oo.user_id, | ||
| 1346 | - store_id: th.data.stoid, | ||
| 1347 | - goods_price: o.shop_price, | ||
| 1348 | - member_goods_price: o.shop_price, | ||
| 1349 | - goods_name: o.goods_name, | ||
| 1350 | - goods_sn: o.goods_sn, | ||
| 1351 | - sku: o.sku, | ||
| 1352 | - prom_id: th.data.sele_g.prom_id, | ||
| 1353 | - prom_type: th.data.sele_g.prom_type, | ||
| 1354 | - }; | ||
| 1355 | - | ||
| 1356 | - //---是不是从收藏夹出来的--- | ||
| 1357 | - if (th.data.c_guide_id) { | ||
| 1358 | - newd['guide_id'] = th.data.c_guide_id; | ||
| 1359 | - newd['guide_type'] = 2; | ||
| 1360 | - if ("add" == t.currentTarget.dataset.action) newd['guide_type'] = 3; | ||
| 1361 | - } else { | ||
| 1362 | - if (getApp().globalData.guide_id) { | ||
| 1363 | - newd['guide_id'] = getApp().globalData.guide_id; | ||
| 1364 | - newd['guide_type'] = 0; | ||
| 1365 | - if ("add" == t.currentTarget.dataset.action) newd['guide_type'] = 1; | ||
| 1366 | - } | ||
| 1367 | - } | ||
| 1368 | - | ||
| 1369 | - //让商品带上房间号 | ||
| 1370 | - //让商品带上房间号 | ||
| 1371 | - if (!th.data.sys_switch.is_skuroom_id && th.data.sys_switch.is_skuroom_id == 1) { | ||
| 1372 | - if (th.data.data.goods_id == getApp().globalData.room_goods_id) { | ||
| 1373 | - newd.room_id = getApp().globalData.room_id; | ||
| 1374 | - } | ||
| 1375 | - } else { | ||
| 1376 | - if (newd.goods_id == getApp().globalData.room_goods_id) newd.room_id = getApp().globalData.room_id; | ||
| 1377 | - } | ||
| 1378 | - | ||
| 1379 | - //如果是积分够,is_integral_normal就要有积分购普通购买字段 | ||
| 1380 | - if (o.prom_type == 4) { | ||
| 1381 | - newd.is_integral_normal = 1; | ||
| 1382 | - } | ||
| 1383 | - | ||
| 1384 | - //如果有线下取价 | ||
| 1385 | - if (o.offline_price) { | ||
| 1386 | - newd.offline_price = o.offline_price; | ||
| 1387 | - newd.pricing_type = o.pricing_type; | ||
| 1388 | - } | ||
| 1389 | - | ||
| 1390 | - //-----如果是秒杀,团购,积分购,拼团----- | ||
| 1391 | - if (th.data.prom_type == 1 || th.data.prom_type == 2) { | ||
| 1392 | - | ||
| 1393 | - if (th.data.openSpecModal_flash_normal) { | ||
| 1394 | - | ||
| 1395 | - newd.prom_type = 0; | ||
| 1396 | - newd.prom_id = 0; | ||
| 1397 | - | ||
| 1398 | - //---如果是线下门店销售的时候--- | ||
| 1399 | - if (th.data.sales_rules == 2) { | ||
| 1400 | - var pick = th.get_pick_from_list(th.data.sto_sele_id) | ||
| 1401 | - //---通过接口获取门店的线下库存信息-- | ||
| 1402 | - getApp().request.get("/api/weshop/goods/getWareStorages", { | ||
| 1403 | - data: { | ||
| 1404 | - storageNos: pick.pickup_no, | ||
| 1405 | - wareIds: encodeURIComponent(th.data.sele_g.erpwareid), | ||
| 1406 | - storeId: os.stoid | ||
| 1407 | - }, | ||
| 1408 | - success: function (res) { | ||
| 1409 | - if (res.data.code == 0) { | ||
| 1410 | - if (res.data.data.pageData.length > 0) { | ||
| 1411 | - var CanOutQty = res.data.data.pageData[0].CanOutQty; | ||
| 1412 | - if (CanOutQty < e.data.goodsInputNum) { | ||
| 1413 | - return s.my_warnning("库存不足!", 0, th); | ||
| 1414 | - } | ||
| 1415 | - //在调一次接口,读取商品的预出库的数量,lock | ||
| 1416 | - getApp().request.get("/api/weshop/order/ware/lock/page", { | ||
| 1417 | - data: { | ||
| 1418 | - store_id: os.stoid, | ||
| 1419 | - wareId: th.data.sele_g.goods_id, | ||
| 1420 | - storageId: pick.pickup_id, | ||
| 1421 | - pageSize: 1000 | ||
| 1422 | - }, | ||
| 1423 | - success: function (res_data) { | ||
| 1424 | - if (res_data.data.code == 0 && res_data.data.data.total > 0) { | ||
| 1425 | - | ||
| 1426 | - var lock = 0; | ||
| 1427 | - for (var i in res_data.data.data.pageData) { | ||
| 1428 | - lock += res_data.data.data.pageData[i].outQty; | ||
| 1429 | - } | ||
| 1430 | - | ||
| 1431 | - if (CanOutQty <= lock) { | ||
| 1432 | - return s.my_warnning("库存不足!", 0, th); | ||
| 1433 | - } | ||
| 1434 | - th.add_cart_next(e, t, a, o, newd, CanOutQty - lock); | ||
| 1435 | - } else { | ||
| 1436 | - th.add_cart_next(e, t, a, o, newd, CanOutQty); | ||
| 1437 | - } | ||
| 1438 | - } | ||
| 1439 | - }) | ||
| 1440 | - } else { | ||
| 1441 | - return s.my_warnning("库存不足!", 0, th); | ||
| 1442 | - } | ||
| 1443 | - | ||
| 1444 | - } | ||
| 1445 | - } | ||
| 1446 | - }) | ||
| 1447 | - } else { | ||
| 1448 | - if (o.store_count <= 0) return s.my_warnning("库存已为空!", 0, th); | ||
| 1449 | - if (o.store_count < e.data.goodsInputNum) return s.my_warnning("库存不足!", 0, th); | ||
| 1450 | - th.add_cart_next(e, t, a, o, newd); //加入购物车下一步 | ||
| 1451 | - } | ||
| 1452 | - | ||
| 1453 | - return false; | ||
| 1454 | - } | ||
| 1455 | - | ||
| 1456 | - | ||
| 1457 | - newd.goods_price = th.data.prom_price; | ||
| 1458 | - newd.member_goods_price = th.data.prom_price, | ||
| 1459 | - newd.prom_type = th.data.prom_type; | ||
| 1460 | - newd.prom_id = th.data.prom_id; | ||
| 1461 | - | ||
| 1462 | - if (o.store_count <= 0) return s.my_warnning("库存已为空!", 0, th); | ||
| 1463 | - if (o.store_count < e.data.goodsInputNum) return s.my_warnning("库存不足!", 0, th); | ||
| 1464 | - | ||
| 1465 | - th.add_cart_next(e, t, a, o, newd); //加入购物车下一步 | ||
| 1466 | - | ||
| 1467 | - } else if (o.prom_type == 7) { | ||
| 1468 | - | ||
| 1469 | - //判断进行中的活动,是不是要判断线下库存 | ||
| 1470 | - th.check_zh_acting(function (ee) { | ||
| 1471 | - newd.prom_id = 0; | ||
| 1472 | - newd.prom_type = 0; | ||
| 1473 | - if (ee && th.data.sele_g.act) { | ||
| 1474 | - newd.prom_id = th.data.sele_g.act.id; | ||
| 1475 | - newd.prom_type = 7; | ||
| 1476 | - if (o.store_count <= 0) return s.my_warnning("库存已为空!", 0, th); | ||
| 1477 | - if (o.store_count < e.data.goodsInputNum) return s.my_warnning("库存不足!", 0, th); | ||
| 1478 | - th.add_cart_next(e, t, a, o, newd); //加入购物车下一步 | ||
| 1479 | - return false; | ||
| 1480 | - } else { | ||
| 1481 | - //---如果是线下门店销售的时候--- | ||
| 1482 | - if (th.data.sales_rules == 2) { | ||
| 1483 | - var pick = th.get_pick_from_list(th.data.sto_sele_id) | ||
| 1484 | - //---通过接口获取门店的线下库存信息-- | ||
| 1485 | - getApp().request.get("/api/weshop/goods/getWareStorages", { | ||
| 1486 | - data: { | ||
| 1487 | - storageNos: pick.pickup_no, | ||
| 1488 | - wareIds: encodeURIComponent(th.data.sele_g.erpwareid), | ||
| 1489 | - storeId: os.stoid | ||
| 1490 | - }, | ||
| 1491 | - success: function (res) { | ||
| 1492 | - if (res.data.code == 0) { | ||
| 1493 | - if (res.data.data.pageData.length > 0) { | ||
| 1494 | - var CanOutQty = res.data.data.pageData[0].CanOutQty; | ||
| 1495 | - if (CanOutQty < e.data.goodsInputNum) { | ||
| 1496 | - return s.my_warnning("库存不足!", 0, th); | ||
| 1497 | - } | ||
| 1498 | - //在调一次接口,读取商品的预出库的数量,lock | ||
| 1499 | - getApp().request.get("/api/weshop/order/ware/lock/page", { | ||
| 1500 | - data: { | ||
| 1501 | - store_id: os.stoid, | ||
| 1502 | - wareId: th.data.sele_g.goods_id, | ||
| 1503 | - storageId: pick.pickup_id, | ||
| 1504 | - pageSize: 1000 | ||
| 1505 | - }, | ||
| 1506 | - success: function (res_data) { | ||
| 1507 | - if (res_data.data.code == 0 && res_data.data.data.total > 0) { | ||
| 1508 | - | ||
| 1509 | - var lock = 0; | ||
| 1510 | - for (var i in res_data.data.data.pageData) { | ||
| 1511 | - lock += res_data.data.data.pageData[i].outQty; | ||
| 1512 | - } | ||
| 1513 | - | ||
| 1514 | - if (CanOutQty <= lock) { | ||
| 1515 | - return s.my_warnning("库存不足!", 0, th); | ||
| 1516 | - } | ||
| 1517 | - th.add_cart_next(e, t, a, o, newd, CanOutQty - lock); | ||
| 1518 | - } else { | ||
| 1519 | - th.add_cart_next(e, t, a, o, newd, CanOutQty); | ||
| 1520 | - } | ||
| 1521 | - } | ||
| 1522 | - }) | ||
| 1523 | - } else { | ||
| 1524 | - return s.my_warnning("库存不足!", 0, th); | ||
| 1525 | - } | ||
| 1526 | - | ||
| 1527 | - } | ||
| 1528 | - } | ||
| 1529 | - }) | ||
| 1530 | - } else { | ||
| 1531 | - if (o.store_count <= 0) return s.my_warnning("库存已为空!", 0, th); | ||
| 1532 | - if (o.store_count < e.data.goodsInputNum) return s.my_warnning("库存不足!", 0, th); | ||
| 1533 | - th.add_cart_next(e, t, a, o, newd); //加入购物车下一步 | ||
| 1534 | - } | ||
| 1535 | - } | ||
| 1536 | - }) | ||
| 1537 | - | ||
| 1538 | - } | ||
| 1539 | - else if (th.data.prom_type == 0 || th.data.prom_type == 3 || th.data.prom_type == 4 || th.data.prom_type == 5 || th.data.prom_type == 10) { | ||
| 1540 | - newd.prom_type = 0; | ||
| 1541 | - newd.prom_id = 0; | ||
| 1542 | - | ||
| 1543 | - if (th.data.prom_type == 10) { | ||
| 1544 | - newd.prom_type = th.data.prom_type; | ||
| 1545 | - newd.prom_id = th.data.prom_id; | ||
| 1546 | - } | ||
| 1547 | - | ||
| 1548 | - //---如果是线下门店销售的时候--- | ||
| 1549 | - if (th.data.sales_rules == 2) { | ||
| 1550 | - var pick = th.get_pick_from_list(th.data.sto_sele_id) | ||
| 1551 | - //---通过接口获取门店的线下库存信息-- | ||
| 1552 | - getApp().request.get("/api/weshop/goods/getWareStorages", { | ||
| 1553 | - data: { | ||
| 1554 | - storageNos: pick.pickup_no, | ||
| 1555 | - wareIds: encodeURIComponent(th.data.sele_g.erpwareid), | ||
| 1556 | - storeId: os.stoid | ||
| 1557 | - }, | ||
| 1558 | - success: function (res) { | ||
| 1559 | - if (res.data.code == 0) { | ||
| 1560 | - if (res.data.data.pageData.length > 0) { | ||
| 1561 | - var CanOutQty = res.data.data.pageData[0].CanOutQty; | ||
| 1562 | - if (CanOutQty < e.data.goodsInputNum) { | ||
| 1563 | - return s.my_warnning("库存不足!", 0, th); | ||
| 1564 | - } | ||
| 1565 | - //在调一次接口,读取商品的预出库的数量,lock | ||
| 1566 | - getApp().request.get("/api/weshop/order/ware/lock/page", { | ||
| 1567 | - data: { | ||
| 1568 | - store_id: os.stoid, | ||
| 1569 | - wareId: th.data.sele_g.goods_id, | ||
| 1570 | - storageId: pick.pickup_id, | ||
| 1571 | - pageSize: 1000 | ||
| 1572 | - }, | ||
| 1573 | - success: function (res_data) { | ||
| 1574 | - if (res_data.data.code == 0 && res_data.data.data.total > 0) { | ||
| 1575 | - | ||
| 1576 | - var lock = 0; | ||
| 1577 | - for (var i in res_data.data.data.pageData) { | ||
| 1578 | - lock += res_data.data.data.pageData[i].outQty; | ||
| 1579 | - } | ||
| 1580 | - | ||
| 1581 | - if (CanOutQty <= lock) { | ||
| 1582 | - return s.my_warnning("库存不足!", 0, th); | ||
| 1583 | - } | ||
| 1584 | - th.add_cart_next(e, t, a, o, newd, CanOutQty - lock); | ||
| 1585 | - } else { | ||
| 1586 | - th.add_cart_next(e, t, a, o, newd, CanOutQty); | ||
| 1587 | - } | ||
| 1588 | - } | ||
| 1589 | - }) | ||
| 1590 | - } else { | ||
| 1591 | - return s.my_warnning("库存不足!", 0, th); | ||
| 1592 | - } | ||
| 1593 | - | ||
| 1594 | - } | ||
| 1595 | - } | ||
| 1596 | - }) | ||
| 1597 | - } else { | ||
| 1598 | - if (o.store_count <= 0) return s.my_warnning("库存已为空!", 0, th); | ||
| 1599 | - if (o.store_count < e.data.goodsInputNum) return s.my_warnning("库存不足!", 0, th); | ||
| 1600 | - th.add_cart_next(e, t, a, o, newd); //加入购物车下一步 | ||
| 1601 | - } | ||
| 1602 | - } | ||
| 1603 | - }) | ||
| 1604 | - }, | ||
| 1605 | - | ||
| 1606 | - //---加入购物车的最后一步--- | ||
| 1607 | - add_cart_next(e, t, a, o, newd, CanOutQty) { | ||
| 1608 | - var th = this, i = getApp().request; | ||
| 1609 | - //---如果商品不是积分购和拼团,要判断一个是否要进行等级价的判断------ | ||
| 1610 | - if ((o.prom_type != 1 || o.prom_id <= 0) && ((o.prom_type != 6 && o.prom_type != 4 && o.prom_type != 2 ) || th.data.is_normal)) { | ||
| 1611 | - var conf = th.data.bconfig; | ||
| 1612 | - if (conf.switch_list && getApp().globalData.userInfo['card_field'] && getApp().globalData.userInfo['card_expiredate']) { | ||
| 1613 | - var s_list = JSON.parse(conf.switch_list); | ||
| 1614 | - var now = ut.gettimestamp(); | ||
| 1615 | - | ||
| 1616 | - | ||
| 1617 | - var str = getApp().globalData.userInfo['card_expiredate'].replace(/-/g, '/'); | ||
| 1618 | - var end = new Date(str); | ||
| 1619 | - end = Date.parse(end) / 1000; | ||
| 1620 | - | ||
| 1621 | - //--如果后台有开启等级价的功能,而且会员的等级没有过期的情况下-- | ||
| 1622 | - if (parseInt(s_list.rank_switch) == 2 && end > now) { | ||
| 1623 | - var card_price = o[getApp().globalData.userInfo['card_field']]; | ||
| 1624 | - //如果会员有等级价 | ||
| 1625 | - if (getApp().globalData.userInfo['card_field'] != undefined && getApp().globalData.userInfo['card_field'] != null | ||
| 1626 | - && getApp().globalData.userInfo['card_field'] != "" && card_price > 0) { | ||
| 1627 | - newd.goods_price = card_price; | ||
| 1628 | - newd.member_goods_price = card_price; | ||
| 1629 | - } | ||
| 1630 | - } | ||
| 1631 | - } | ||
| 1632 | - } | ||
| 1633 | - | ||
| 1634 | - //if (this.data.data.goods.is_virtual) return this.buyVirtualGoods(d); | ||
| 1635 | - if ("add" == t.currentTarget.dataset.action) { | ||
| 1636 | - | ||
| 1637 | - if (th.data.prom_goods) { | ||
| 1638 | - newd.prom_type = 3; | ||
| 1639 | - newd.prom_id = th.data.prom_goods[0].prom_id; | ||
| 1640 | - } | ||
| 1641 | - | ||
| 1642 | - //----先看会员在购物车中是否加入了该商品----- | ||
| 1643 | - i.get("/api/weshop/cart/page", { | ||
| 1644 | - data: { | ||
| 1645 | - store_id: e.data.stoid, | ||
| 1646 | - user_id: oo.user_id, | ||
| 1647 | - goods_id: a, | ||
| 1648 | - pick_id: e.data.sto_sele_id, | ||
| 1649 | - state: 0 | ||
| 1650 | - }, | ||
| 1651 | - success: function (re) { | ||
| 1652 | - | ||
| 1653 | - //-------如果购物车中有相关的数据--------- | ||
| 1654 | - if (re.data.data.total > 0) { | ||
| 1655 | - | ||
| 1656 | - var item = re.data.data.pageData[0]; | ||
| 1657 | - | ||
| 1658 | - //判断数量,要看下购物车中有没有该商品 | ||
| 1659 | - if (CanOutQty) { | ||
| 1660 | - if (item.goods_num + th.data.goodsInputNum > CanOutQty) { | ||
| 1661 | - return s.my_warnning("库存不足!", 0, th); | ||
| 1662 | - } | ||
| 1663 | - } else { | ||
| 1664 | - if (item.goods_num + th.data.goodsInputNum > o.store_count) { | ||
| 1665 | - return s.my_warnning("库存不足!", 0, th); | ||
| 1666 | - } | ||
| 1667 | - } | ||
| 1668 | - | ||
| 1669 | - var updata = { | ||
| 1670 | - id: item.id, | ||
| 1671 | - goods_num: e.data.goodsInputNum + item.goods_num, | ||
| 1672 | - goods_price: newd.goods_price, | ||
| 1673 | - member_goods_price: newd.goods_price, | ||
| 1674 | - store_id: th.data.stoid, | ||
| 1675 | - }; | ||
| 1676 | - | ||
| 1677 | - //---是不是从收藏夹出来的--- | ||
| 1678 | - if (th.data.c_guide_id) { | ||
| 1679 | - updata['guide_id'] = th.data.c_guide_id; | ||
| 1680 | - updata['guide_type'] = 3; //加入购物车之后就变成了3 | ||
| 1681 | - } else { | ||
| 1682 | - if (getApp().globalData.guide_id) { | ||
| 1683 | - updata['guide_id'] = getApp().globalData.guide_id; | ||
| 1684 | - updata['guide_type'] = 0; | ||
| 1685 | - } | ||
| 1686 | - } | ||
| 1687 | - | ||
| 1688 | - i.put("/api/weshop/cart/update", { | ||
| 1689 | - data: updata, | ||
| 1690 | - success: function (t) { | ||
| 1691 | - getApp().my_warnning('加入购物车成功', 1, th, 450); | ||
| 1692 | - var c_num = th.data.cartGoodsNum + th.data.goodsInputNum; | ||
| 1693 | - th.setData({ | ||
| 1694 | - cartGoodsNum: c_num | ||
| 1695 | - }); | ||
| 1696 | - th.closeSpecModal(); | ||
| 1697 | - } | ||
| 1698 | - }); | ||
| 1699 | - } else { | ||
| 1700 | - | ||
| 1701 | - | ||
| 1702 | - i.post("/api/weshop/cart/save", { | ||
| 1703 | - data: newd, | ||
| 1704 | - success: function (t) { | ||
| 1705 | - getApp().my_warnning('加入购物车成功', 1, th, 450); | ||
| 1706 | - var c_num = th.data.cartGoodsNum + e.data.goodsInputNum; | ||
| 1707 | - th.setData({ | ||
| 1708 | - cartGoodsNum: c_num | ||
| 1709 | - }); | ||
| 1710 | - th.closeSpecModal(); | ||
| 1711 | - } | ||
| 1712 | - }); | ||
| 1713 | - } | ||
| 1714 | - } | ||
| 1715 | - }); | ||
| 1716 | - | ||
| 1717 | - } | ||
| 1718 | - else { | ||
| 1719 | - | ||
| 1720 | - //这一步主要是要让立即购买 走 购物车的逻辑 参与活动 | ||
| 1721 | - if (newd.prom_type == 10 || newd.prom_type == 7) { | ||
| 1722 | - //----先看会员在购物车中是否加入了该商品,立即购买的----- | ||
| 1723 | - getApp().request.get("/api/weshop/cart/page", { | ||
| 1724 | - data: { | ||
| 1725 | - store_id: e.data.stoid, | ||
| 1726 | - user_id: oo.user_id, | ||
| 1727 | - state: 1 | ||
| 1728 | - }, | ||
| 1729 | - success: function (res) { | ||
| 1730 | - //-------如果购物车中有相关的数据--------- | ||
| 1731 | - if (res.data.code == 0 && res.data.data.total > 0) { | ||
| 1732 | - for (let j in res.data.data.pageData) { | ||
| 1733 | - let item_j = res.data.data.pageData[j]; | ||
| 1734 | - var url = '/api/weshop/cart/del/' + e.data.stoid + '/' + item_j.id; | ||
| 1735 | - getApp().request.delete(url, {}); | ||
| 1736 | - } | ||
| 1737 | - } | ||
| 1738 | - newd.state = 1; | ||
| 1739 | - getApp().request.post("/api/weshop/cart/save", { | ||
| 1740 | - data: newd, | ||
| 1741 | - success: function (t) { | ||
| 1742 | - th.closeSpecModal(); | ||
| 1743 | - getApp().goto("/pages/cart/cart2/cart2?state=1"); | ||
| 1744 | - } | ||
| 1745 | - }); | ||
| 1746 | - } | ||
| 1747 | - }) | ||
| 1748 | - return false; | ||
| 1749 | - } | ||
| 1750 | - | ||
| 1751 | - if (th.data.prom_goods) { | ||
| 1752 | - var prom_d = th.data.prom_goods; | ||
| 1753 | - for (var i in prom_d) { | ||
| 1754 | - //判断活动有俩种条件,0元 1件 | ||
| 1755 | - var condition_t = prom_d[i].prom_type; | ||
| 1756 | - switch (condition_t) { | ||
| 1757 | - case 0: //按钱 | ||
| 1758 | - if (newd.goods_price >= condition_t) { | ||
| 1759 | - newd.prom_type = 3; | ||
| 1760 | - newd.prom_id = prom_d[i].prom_id; | ||
| 1761 | - } | ||
| 1762 | - break | ||
| 1763 | - case 1://按购买数量 | ||
| 1764 | - if (newd.goods_num >= condition_t) { | ||
| 1765 | - newd.prom_type = 3; | ||
| 1766 | - newd.prom_id = prom_d[i].prom_id; | ||
| 1767 | - } | ||
| 1768 | - break; | ||
| 1769 | - } | ||
| 1770 | - } | ||
| 1771 | - | ||
| 1772 | - } | ||
| 1773 | - | ||
| 1774 | - newd['pick_name'] = th.data.sto_sele_name; | ||
| 1775 | - newd['pick_dis'] = th.data.sto_sele_distr; | ||
| 1776 | - th.buyNow(newd); | ||
| 1777 | - } | ||
| 1778 | - }, | ||
| 1779 | - | ||
| 1780 | - | ||
| 1781 | - //----------购买虚拟商品------ | ||
| 1782 | - buyVirtualGoods: function (e) { | ||
| 1783 | - Object.assign(e, { | ||
| 1784 | - goods_name: this.data.data.goods.goods_name, | ||
| 1785 | - spec_name: this.data.select.specName, | ||
| 1786 | - price: this.data.select.price | ||
| 1787 | - }), wx.navigateTo({ | ||
| 1788 | - url: "/pages/virtual/buy_step/buy_step?" + t.Obj2Str(e) | ||
| 1789 | - }); | ||
| 1790 | - }, | ||
| 1791 | - //----------积分兑换--------- | ||
| 1792 | - exchange: function (e) { | ||
| 1793 | - this.data.shippingCost < 0 || this.data.select.stock <= 0 || wx.navigateTo({ | ||
| 1794 | - url: "/pages/cart/integral/integral?" + t.Obj2Str(e) | ||
| 1795 | - }); | ||
| 1796 | - }, | ||
| 1797 | - | ||
| 1798 | - | ||
| 1799 | - //----------立即购买----------- | ||
| 1800 | - buyNow: function (e) { | ||
| 1801 | - // this.data.shippingCost < 0 || this.data.select.stock <= 0 || (Object.assign(e, { | ||
| 1802 | - // action: "buy_now" | ||
| 1803 | - // }), | ||
| 1804 | - this.setData({ | ||
| 1805 | - openSpecModal: 0, | ||
| 1806 | - openSpecModal_inte: 0, | ||
| 1807 | - openSpecModal_inte_normal: 0, | ||
| 1808 | - openSpecModal_pt: 0, | ||
| 1809 | - }) | ||
| 1810 | - | ||
| 1811 | - if (e.prom_type == 4) { | ||
| 1812 | - s.set_b_now(e); | ||
| 1813 | - var url = "/pages/cart/cart2_inte/cart2_inte?is_bnow=1&goods_id=" + e.goods_id; | ||
| 1814 | - getApp().goto(url); | ||
| 1815 | - } else { | ||
| 1816 | - //要判断积分购的普通购买有没有参加优惠活动 | ||
| 1817 | - if (e.is_integral_normal == 1) { | ||
| 1818 | - this.check_nor_promgood(e.goods_id, function (res) { | ||
| 1819 | - if (res && res.cat_id) { | ||
| 1820 | - e.prom_type = 3; | ||
| 1821 | - e.prom_id = res.cat_id | ||
| 1822 | - } | ||
| 1823 | - s.set_b_now(e); | ||
| 1824 | - /*-- | ||
| 1825 | - wx.redirectTo({ | ||
| 1826 | - url: "/pages/cart/cart2/cart2?is_bnow=1&goods_id=" + e.goods_id, | ||
| 1827 | - });--*/ | ||
| 1828 | - getApp().goto("/pages/cart/cart2/cart2?is_bnow=1&goods_id=" + e.goods_id) | ||
| 1829 | - | ||
| 1830 | - }) | ||
| 1831 | - } else { | ||
| 1832 | - s.set_b_now(e); | ||
| 1833 | - /*-- | ||
| 1834 | - wx.redirectTo({ | ||
| 1835 | - url: "/pages/cart/cart2/cart2?is_bnow=1&goods_id=" + e.goods_id, | ||
| 1836 | - });--*/ | ||
| 1837 | - getApp().goto("/pages/cart/cart2/cart2?is_bnow=1&goods_id=" + e.goods_id) | ||
| 1838 | - } | ||
| 1839 | - | ||
| 1840 | - } | ||
| 1841 | - }, | ||
| 1842 | - | ||
| 1843 | - //----------增加购买数量----------- | ||
| 1844 | - addCartNum: function (t) { | ||
| 1845 | - this.checkCartNum(this.data.goodsInputNum + 1); | ||
| 1846 | - }, | ||
| 1847 | - //----------减少购买数量----------- | ||
| 1848 | - subCartNum: function (t) { | ||
| 1849 | - this.checkCartNum(this.data.goodsInputNum - 1); | ||
| 1850 | - }, | ||
| 1851 | - //----------输入框输入购买数量----------- | ||
| 1852 | - inputCartNum: function (t) { | ||
| 1853 | - this.checkCartNum(Number(t.detail.value)); | ||
| 1854 | - }, | ||
| 1855 | - | ||
| 1856 | - //----------增加购买数量----------- | ||
| 1857 | - addCartNum_inte: function (t) { | ||
| 1858 | - this.checkCartNum_inte(this.data.goodsInputNum + 1); | ||
| 1859 | - }, | ||
| 1860 | - //----------减少购买数量----------- | ||
| 1861 | - subCartNum_inte: function (t) { | ||
| 1862 | - this.checkCartNum_inte(this.data.goodsInputNum - 1); | ||
| 1863 | - }, | ||
| 1864 | - //----------输入框输入购买数量----------- | ||
| 1865 | - inputCartNum_inte: function (t) { | ||
| 1866 | - this.checkCartNum_inte(Number(t.detail.value)); | ||
| 1867 | - }, | ||
| 1868 | - | ||
| 1869 | - | ||
| 1870 | - //------检查数量是不是超出限购------ | ||
| 1871 | - checkCartNum: function (t) { | ||
| 1872 | - var th = this; | ||
| 1873 | - this.get_buy_num(this.data.sele_g, async function () { | ||
| 1874 | - | ||
| 1875 | - //--判断商品是否超出限购-- | ||
| 1876 | - if (th.data.g_buy_num != null && th.data.sele_g.viplimited > 0) { | ||
| 1877 | - | ||
| 1878 | - var gd_buy_num = th.data.g_buy_num.get(th.data.sele_g.goods_id); | ||
| 1879 | - | ||
| 1880 | - if (t + gd_buy_num > th.data.sele_g.viplimited) { | ||
| 1881 | - // wx.showModal({ | ||
| 1882 | - // title: '超出商品限购', | ||
| 1883 | - // }); | ||
| 1884 | - s.my_warnning('超出商品限购', 0, th); | ||
| 1885 | - var num = th.data.sele_g.viplimited - gd_buy_num; | ||
| 1886 | - if (num < 0) num = 0; | ||
| 1887 | - th.setData({goodsInputNum: num}) | ||
| 1888 | - return false; | ||
| 1889 | - } | ||
| 1890 | - } | ||
| 1891 | - | ||
| 1892 | - //如果是普通购买的情况下 | ||
| 1893 | - if(th.data.openSpecModal_flash_normal) th.data.is_normal=1; | ||
| 1894 | - | ||
| 1895 | - //--判断商品是否超出活动限购-- | ||
| 1896 | - if (th.data.prom_buy_num != -1 && th.data.prom_buy_limit > 0 && !th.data.is_normal) { | ||
| 1897 | - if (t + th.data.prom_buy_num > th.data.prom_buy_limit) { | ||
| 1898 | - // wx.showModal({ | ||
| 1899 | - // title: '超出商品活动限购', | ||
| 1900 | - // }); | ||
| 1901 | - s.my_warnning('超出商品活动限购', 0, th); | ||
| 1902 | - var num = th.data.prom_buy_limit - th.data.prom_buy_num; | ||
| 1903 | - if (num < 0) num = 0; | ||
| 1904 | - th.setData({goodsInputNum: num}) | ||
| 1905 | - return false; | ||
| 1906 | - } | ||
| 1907 | - } | ||
| 1908 | - | ||
| 1909 | - if ((th.data.sele_g.prom_type == 1 || th.data.sele_g.prom_type == 6) && !th.data.is_normal) { | ||
| 1910 | - var redis_num = 0; | ||
| 1911 | - //------判断活动是否抢光----- | ||
| 1912 | - await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + | ||
| 1913 | - os.stoid + "/" + th.data.sele_g.prom_type + "/" + th.data.sele_g.prom_id, { | ||
| 1914 | - 1: 1 | ||
| 1915 | - }).then(res => { | ||
| 1916 | - redis_num = res.data.data; | ||
| 1917 | - }); | ||
| 1918 | - | ||
| 1919 | - if (t > redis_num) { | ||
| 1920 | - // wx.showModal({ | ||
| 1921 | - // title: '超出商品活动库存', | ||
| 1922 | - // }); | ||
| 1923 | - s.my_warnning('超出商品活动库存', 0, th); | ||
| 1924 | - th.setData({goodsInputNum: redis_num}) | ||
| 1925 | - return false; | ||
| 1926 | - } | ||
| 1927 | - } | ||
| 1928 | - var e = th.data.sele_g.store_count; | ||
| 1929 | - var p_type = th.data.prom_type; //&& p_type!=1 && p_type!=4 | ||
| 1930 | - if (th.data.sales_rules == 2 && (p_type != 1 && p_type != 4 && p_type != 6 || th.data.openSpecModal_inte_normal == 1 || th.data.is_normal == 1)) { | ||
| 1931 | - if (!th.data.def_pick_store) { | ||
| 1932 | - wx.showModal({title: '请选择门店',}); | ||
| 1933 | - return false; | ||
| 1934 | - } else { | ||
| 1935 | - e = th.data.def_pick_store.CanOutQty; | ||
| 1936 | - } | ||
| 1937 | - } | ||
| 1938 | - if (!e) e = 0; | ||
| 1939 | - //库存不足,不增加 | ||
| 1940 | - if (e < t) { | ||
| 1941 | - wx.showModal({title: '库存不足',}); | ||
| 1942 | - if (e < 0) e = 0; | ||
| 1943 | - th.setData({goodsInputNum: e}); | ||
| 1944 | - return false; | ||
| 1945 | - } | ||
| 1946 | - t > e || 0 == e ? t = e : t < 1 && (t = 1); | ||
| 1947 | - th.setData({goodsInputNum: t}); | ||
| 1948 | - th.is_show_more_buy(); | ||
| 1949 | - | ||
| 1950 | - }) | ||
| 1951 | - }, | ||
| 1952 | - | ||
| 1953 | - //----- 检查一下积分购的限购之类的问题 ----- | ||
| 1954 | - checkCartNum_inte: function (t) { | ||
| 1955 | - var th = this; | ||
| 1956 | - this.get_buy_num(this.data.data, async function () { | ||
| 1957 | - ; | ||
| 1958 | - //--判断商品是否超出限购-- | ||
| 1959 | - if (th.data.g_buy_num != null && th.data.data.viplimited > 0) { | ||
| 1960 | - | ||
| 1961 | - var gd_buy_num = th.data.g_buy_num.get(th.data.sele_g.goods_id); | ||
| 1962 | - | ||
| 1963 | - if (t + gd_buy_num > th.data.sele_g.viplimited) { | ||
| 1964 | - // wx.showModal({ | ||
| 1965 | - // title: '超出商品限购', | ||
| 1966 | - // }); | ||
| 1967 | - s.my_warnning('超出商品限购', 0, th); | ||
| 1968 | - var num = th.data.sele_g.viplimited - gd_buy_num; | ||
| 1969 | - if (num < 0) num = 0; | ||
| 1970 | - th.setData({goodsInputNum: num}) | ||
| 1971 | - return false; | ||
| 1972 | - } | ||
| 1973 | - } | ||
| 1974 | - | ||
| 1975 | - //--判断商品是否超出活动限购-- | ||
| 1976 | - if (th.data.prom_buy_num != -1 && th.data.prom_buy_limit > 0) { | ||
| 1977 | - if (t + th.data.prom_buy_num > th.data.prom_buy_limit) { | ||
| 1978 | - // wx.showModal({ | ||
| 1979 | - // title: '超出商品活动限购', | ||
| 1980 | - // }); | ||
| 1981 | - s.my_warnning('超出商品活动限购', 0, th); | ||
| 1982 | - var num = th.data.prom_buy_limit - th.data.prom_buy_num; | ||
| 1983 | - if (num < 0) num = 0; | ||
| 1984 | - th.setData({goodsInputNum: num}) | ||
| 1985 | - return false; | ||
| 1986 | - } | ||
| 1987 | - } | ||
| 1988 | - | ||
| 1989 | - if (th.data.sele_g.prom_type == 1 || th.data.sele_g.prom_type == 6) { | ||
| 1990 | - var redis_num = 0; | ||
| 1991 | - //------判断活动是否抢光----- | ||
| 1992 | - await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + | ||
| 1993 | - os.stoid + "/" + th.data.sele_g.prom_type + "/" + th.data.sele_g.prom_id, { | ||
| 1994 | - 1: 1 | ||
| 1995 | - }).then(res => { | ||
| 1996 | - redis_num = res.data.data; | ||
| 1997 | - }); | ||
| 1998 | - | ||
| 1999 | - if (t > redis_num) { | ||
| 2000 | - // wx.showModal({ | ||
| 2001 | - // title: '超出商品活动库存', | ||
| 2002 | - // }); | ||
| 2003 | - s.my_warnning('超出商品活动库存', 0, th); | ||
| 2004 | - th.setData({goodsInputNum: redis_num}) | ||
| 2005 | - return false; | ||
| 2006 | - } | ||
| 2007 | - } | ||
| 2008 | - | ||
| 2009 | - | ||
| 2010 | - //判断积分购库存 | ||
| 2011 | - if (!th.data.is_normal && th.data.prom_type == 4) { | ||
| 2012 | - var i_canbuy = th.data.prom_act.limitqty - th.data.prom_act.buy_num; | ||
| 2013 | - if (t > i_canbuy) { | ||
| 2014 | - // wx.showModal({ | ||
| 2015 | - // title: '超出商品活动库存', | ||
| 2016 | - // }); | ||
| 2017 | - s.my_warnning('超出商品活动库存', 0, th); | ||
| 2018 | - return false; | ||
| 2019 | - } | ||
| 2020 | - } | ||
| 2021 | - | ||
| 2022 | - var e = th.data.sele_g.store_count; | ||
| 2023 | - var p_type = th.data.prom_type; //&& p_type!=1 && p_type!=4 | ||
| 2024 | - if (th.data.sales_rules == 2 && (p_type != 1 && p_type != 4 && p_type != 6 || th.data.openSpecModal_inte_normal == 1 || th.data.is_normal == 1)) { | ||
| 2025 | - if (!th.data.def_pick_store) { | ||
| 2026 | - wx.showModal({title: '请选择门店',}); | ||
| 2027 | - return false; | ||
| 2028 | - } else { | ||
| 2029 | - e = th.data.def_pick_store.CanOutQty; | ||
| 2030 | - } | ||
| 2031 | - } | ||
| 2032 | - if (!e) e = 0; | ||
| 2033 | - //库存不足,不增加 | ||
| 2034 | - if (e < t) { | ||
| 2035 | - wx.showModal({title: '库存不足',}); | ||
| 2036 | - if (e < 0) e = 0; | ||
| 2037 | - th.setData({goodsInputNum: e}); | ||
| 2038 | - return false; | ||
| 2039 | - } | ||
| 2040 | - t > e || 0 == e ? t = e : t < 1 && (t = 1); | ||
| 2041 | - th.setData({goodsInputNum: t}); | ||
| 2042 | - }) | ||
| 2043 | - }, | ||
| 2044 | - | ||
| 2045 | - | ||
| 2046 | - closeSpecModal: function () { | ||
| 2047 | - if (this.data.openSpecModal_pt && this.data.is_normal) { | ||
| 2048 | - this.get_sto(); | ||
| 2049 | - this.setData({ | ||
| 2050 | - sele_g: this.data.data, | ||
| 2051 | - gid: this.data.data.goods_id | ||
| 2052 | - }) | ||
| 2053 | - | ||
| 2054 | - this.sele_spec_chech_activity(); | ||
| 2055 | - | ||
| 2056 | - } | ||
| 2057 | - | ||
| 2058 | - this.setData({ | ||
| 2059 | - openSpecModal: !1, | ||
| 2060 | - openSpecModal_pt: !1 | ||
| 2061 | - }); | ||
| 2062 | - }, | ||
| 2063 | - | ||
| 2064 | - openSpecModel: function (t) { | ||
| 2065 | - var th = this; | ||
| 2066 | - var open_store = t.currentTarget.dataset.ind; | ||
| 2067 | - | ||
| 2068 | - if(getApp().is_sp_hao() && open_store==1){ | ||
| 2069 | - wx.showToast({ | ||
| 2070 | - title: "视频号商品不允许加入购物车", | ||
| 2071 | - icon: 'none', | ||
| 2072 | - duration: 2000 | ||
| 2073 | - }); | ||
| 2074 | - return false; | ||
| 2075 | - } | ||
| 2076 | - | ||
| 2077 | - this.setData({ | ||
| 2078 | - store: 0, | ||
| 2079 | - choice_sort_store: 0, | ||
| 2080 | - sort_store: 0, | ||
| 2081 | - open_ind_store: open_store, | ||
| 2082 | - }) | ||
| 2083 | - //--先判断会员状态-- | ||
| 2084 | - var user_info = getApp().globalData.userInfo; | ||
| 2085 | - if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { | ||
| 2086 | - wx.navigateTo({ | ||
| 2087 | - url: '/pages/togoin/togoin', | ||
| 2088 | - }) | ||
| 2089 | - return false; | ||
| 2090 | - } | ||
| 2091 | - | ||
| 2092 | - var check_up = 0; | ||
| 2093 | - if (th.data.more_flash) { | ||
| 2094 | - for (var i in th.data.more_flash) { | ||
| 2095 | - var item = th.data.more_flash[i]; | ||
| 2096 | - if (item.prom_type == 1) { | ||
| 2097 | - check_up = 1; | ||
| 2098 | - break | ||
| 2099 | - } | ||
| 2100 | - } | ||
| 2101 | - } | ||
| 2102 | - | ||
| 2103 | - | ||
| 2104 | - if (check_up && open_store == 1) { | ||
| 2105 | - th.setData({is_pop_more: 1}); | ||
| 2106 | - } else { | ||
| 2107 | - var ind = t.currentTarget.dataset.ind; | ||
| 2108 | - //回调。判断是不是优惠促销 | ||
| 2109 | - th.check_is_prom_goods(function () { | ||
| 2110 | - th.setData({ | ||
| 2111 | - openSpecModal: !0, | ||
| 2112 | - openSpecModal_ind: ind, | ||
| 2113 | - }); | ||
| 2114 | - //var is_open=th.data.config | ||
| 2115 | - th.get_off_price(); | ||
| 2116 | - }) | ||
| 2117 | - //--先判断会员状态-- | ||
| 2118 | - var user_info = getApp().globalData.userInfo; | ||
| 2119 | - if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { | ||
| 2120 | - wx.navigateTo({ | ||
| 2121 | - url: '/pages/togoin/togoin', | ||
| 2122 | - }) | ||
| 2123 | - return false; | ||
| 2124 | - } | ||
| 2125 | - var is_go_next = 1; | ||
| 2126 | - if (th.data.more_flash && th.data.more_flash.length > 1 && open_store == 1) { | ||
| 2127 | - is_go_next = 0; | ||
| 2128 | - } | ||
| 2129 | - if (is_go_next) { | ||
| 2130 | - var ind = t.currentTarget.dataset.ind; | ||
| 2131 | - //回调。判断是不是优惠促销 | ||
| 2132 | - th.check_is_prom_goods(function () { | ||
| 2133 | - th.setData({ | ||
| 2134 | - openSpecModal: !0, | ||
| 2135 | - openSpecModal_ind: ind, | ||
| 2136 | - }); | ||
| 2137 | - //var is_open=th.data.config | ||
| 2138 | - th.get_off_price(); | ||
| 2139 | - }) | ||
| 2140 | - } else { | ||
| 2141 | - th.setData({is_pop_more: 1}); | ||
| 2142 | - | ||
| 2143 | - } | ||
| 2144 | - } | ||
| 2145 | - }, | ||
| 2146 | - open_next(){ | ||
| 2147 | - var th = this; | ||
| 2148 | - //回调。判断是不是优惠促销 | ||
| 2149 | - th.check_is_prom_goods(function () { | ||
| 2150 | - th.setData({ | ||
| 2151 | - openSpecModal: !0, | ||
| 2152 | - openSpecModal_ind: 1, | ||
| 2153 | - is_pop_more: 0 | ||
| 2154 | - }); | ||
| 2155 | - th.get_off_price(); | ||
| 2156 | - }) | ||
| 2157 | - }, | ||
| 2158 | - | ||
| 2159 | - //判断是不是优惠促销 | ||
| 2160 | - check_is_prom_goods: function (callback) { | ||
| 2161 | - var th = this; | ||
| 2162 | - var usr = getApp().globalData.userInfo; | ||
| 2163 | - if (this.data.sele_g.prom_type != 0 && this.data.sele_g.prom_type != 3) { | ||
| 2164 | - callback(); | ||
| 2165 | - } else { | ||
| 2166 | - //-- 判断有没有优惠活动 -- | ||
| 2167 | - getApp().request.promiseGet("/api/weshop/goods/getGoodsPromList/" + os.stoid + "/" + th.data.sele_g.goods_id + "/0"+"/"+usr.user_id, {}).then(res => { | ||
| 2168 | - if (res.data.code == 0) { | ||
| 2169 | - var r_data = res.data.data; | ||
| 2170 | - th.data.prom_goods = r_data.promGoodsLists; | ||
| 2171 | - if (!th.data.prom_goods) { | ||
| 2172 | - callback(); | ||
| 2173 | - return false; | ||
| 2174 | - } | ||
| 2175 | - | ||
| 2176 | - ///api/weshop/order/getWPayOrder?store_id=1&user_id=5682366&prom_id=1&goods_id=1 | ||
| 2177 | - getApp().promiseGet("/api/weshop/order/getWPayOrder", { | ||
| 2178 | - data: { | ||
| 2179 | - store_id: os.stoid, | ||
| 2180 | - user_id: usr.user_id, | ||
| 2181 | - goods_id: th.data.sele_g.goods_id, | ||
| 2182 | - prom_id: th.data.prom_goods[0].prom_id | ||
| 2183 | - } | ||
| 2184 | - }).then(res => { | ||
| 2185 | - if (res.data.code == 0) { | ||
| 2186 | - wx.showToast({ | ||
| 2187 | - title: "您已经购买了该商品待支付中", | ||
| 2188 | - icon: 'none', | ||
| 2189 | - duration: 2000 | ||
| 2190 | - }) | ||
| 2191 | - setTimeout(function () { | ||
| 2192 | - getApp().goto("/pages/user/order_detail/order_detail?order_id=" + res.data.data.order_id,) | ||
| 2193 | - }, 1000) | ||
| 2194 | - } | ||
| 2195 | - //未找到相关记录 | ||
| 2196 | - else { | ||
| 2197 | - callback(); | ||
| 2198 | - } | ||
| 2199 | - }) | ||
| 2200 | - } | ||
| 2201 | - | ||
| 2202 | - }) | ||
| 2203 | - | ||
| 2204 | - } | ||
| 2205 | - }, | ||
| 2206 | - | ||
| 2207 | - | ||
| 2208 | - //----获取线下价格------- | ||
| 2209 | - get_off_price() { | ||
| 2210 | - var th = this; | ||
| 2211 | - //没有开启就返回 | ||
| 2212 | - if (!th.data.is_open_offline) return false; | ||
| 2213 | - //先看下购买的功能有没有到期 | ||
| 2214 | - getApp().request.promiseGet("/store/storemoduleendtime/page?store_id=" + os.stoid + "&type=6", {}).then(res => { | ||
| 2215 | - //未购买 | ||
| 2216 | - if (res.data.code != 0 || !res.data.data || !res.data.data.pageData || !res.data.data.pageData.length) { | ||
| 2217 | - return false; | ||
| 2218 | - } else { | ||
| 2219 | - //已经过期 | ||
| 2220 | - var item = res.data.data.pageData[0]; | ||
| 2221 | - if (item.end_time < ut.gettimestamp()) { | ||
| 2222 | - return false; | ||
| 2223 | - } | ||
| 2224 | - } | ||
| 2225 | - | ||
| 2226 | - | ||
| 2227 | - var cur_goods = this.data.sele_g; | ||
| 2228 | - var cur_price = cur_goods.shop_price; | ||
| 2229 | - if (th.data.card_field && cur_goods[th.data.card_field] > 0) { | ||
| 2230 | - cur_price = cur_goods[th.data.card_field]; | ||
| 2231 | - } | ||
| 2232 | - | ||
| 2233 | - var user_info = getApp().globalData.userInfo; | ||
| 2234 | - //获取一下接口,判断是不是有线下接口,必须是普通商品,全局优惠活动也是不行 | ||
| 2235 | - if (cur_goods.prom_type == 0 && !this.data.prom_goods) { | ||
| 2236 | - cur_goods.offline_price = null; | ||
| 2237 | - //如果没有门店,不用计算线下价格 | ||
| 2238 | - var def_pick_store = this.data.def_pick_store; | ||
| 2239 | - if (!def_pick_store) return false; | ||
| 2240 | - getApp().request.get("/api/weshop/goods/listWarePrice", { | ||
| 2241 | - data: { | ||
| 2242 | - VIPId: encodeURIComponent(user_info.erpvipid), | ||
| 2243 | - store_id: os.stoid, | ||
| 2244 | - PickupId: def_pick_store.pickup_id, | ||
| 2245 | - WareIds: encodeURIComponent(cur_goods.erpwareid) | ||
| 2246 | - }, | ||
| 2247 | - success: function (res) { | ||
| 2248 | - if (res.data.code == 0 && res.data.data && res.data.data.length > 0) { | ||
| 2249 | - var datalist = res.data.data; | ||
| 2250 | - if (datalist[0].WarePrice < cur_price) { | ||
| 2251 | - cur_goods.offline_price = datalist[0].WarePrice; //存储线下活动的价格 | ||
| 2252 | - cur_goods.pricing_type = datalist[0].PriceType; //存储线下活动的类型 | ||
| 2253 | - } | ||
| 2254 | - } | ||
| 2255 | - th.setData({sele_g: cur_goods}); | ||
| 2256 | - } | ||
| 2257 | - | ||
| 2258 | - }) | ||
| 2259 | - } | ||
| 2260 | - | ||
| 2261 | - }) | ||
| 2262 | - | ||
| 2263 | - | ||
| 2264 | - }, | ||
| 2265 | - | ||
| 2266 | - | ||
| 2267 | - //---------点击收藏和不收藏------------ | ||
| 2268 | - collectGoods: function () { | ||
| 2269 | - var t = this, | ||
| 2270 | - i = getApp().request; | ||
| 2271 | - var user_id = s.globalData.user_id; | ||
| 2272 | - if (user_id == '') { | ||
| 2273 | - getApp().getUserFir(function () { | ||
| 2274 | - }); | ||
| 2275 | - getApp().showWarning("未登录"); | ||
| 2276 | - return false; | ||
| 2277 | - } else { | ||
| 2278 | - | ||
| 2279 | - if (t.data.is_collect_load) return false; | ||
| 2280 | - t.data.is_collect_load = 1; | ||
| 2281 | - | ||
| 2282 | - if (t.data.is_collect == 1) { //删除收藏 | ||
| 2283 | - i.delete("/api/weshop/goodscollect/del/" + o.stoid + "/" + t.data.collect_id, { | ||
| 2284 | - success: function (e) { | ||
| 2285 | - t.data.is_collect_load = 0; | ||
| 2286 | - if (e.data.code == 0) { | ||
| 2287 | - t.setData({ | ||
| 2288 | - is_collect: 0, | ||
| 2289 | - collect_id: 0, | ||
| 2290 | - }); | ||
| 2291 | - } | ||
| 2292 | - } | ||
| 2293 | - }); | ||
| 2294 | - } else { | ||
| 2295 | - var timestamp = Date.parse(new Date()); | ||
| 2296 | - timestamp = timestamp / 1000; | ||
| 2297 | - var d = { | ||
| 2298 | - goods_id: t.data.data.goods_id, | ||
| 2299 | - user_id: s.globalData.user_id, | ||
| 2300 | - store_id: o.stoid, | ||
| 2301 | - add_time: timestamp, | ||
| 2302 | - }; | ||
| 2303 | - //加入收藏夹就是导购的ID | ||
| 2304 | - if (getApp().globalData.guide_id) { | ||
| 2305 | - d.guide_id = getApp().globalData.guide_id; | ||
| 2306 | - d.guide_type = 2; | ||
| 2307 | - } | ||
| 2308 | - | ||
| 2309 | - i.post("/api/weshop/goodscollect/save", { //添加收藏 | ||
| 2310 | - data: d, | ||
| 2311 | - success: function (e) { | ||
| 2312 | - t.data.is_collect_load = 0; | ||
| 2313 | - if (e.data.code == 0) { | ||
| 2314 | - t.setData({ | ||
| 2315 | - is_collect: 1, | ||
| 2316 | - collect_id: e.data.data.collect_id, | ||
| 2317 | - }); | ||
| 2318 | - } | ||
| 2319 | - } | ||
| 2320 | - }); | ||
| 2321 | - } | ||
| 2322 | - } | ||
| 2323 | - }, | ||
| 2324 | - | ||
| 2325 | - //---------联系客服------------ | ||
| 2326 | - contactService: function () { | ||
| 2327 | - getApp().com_call(this); | ||
| 2328 | - }, | ||
| 2329 | - | ||
| 2330 | - // 获取客服电话 | ||
| 2331 | - getTel() { | ||
| 2332 | - return new Promise((resolve, reject) => { | ||
| 2333 | - s.getConfig(function (t) { | ||
| 2334 | - if (t.store_tel == undefined) { | ||
| 2335 | - getApp().request.get("/api/weshop/store/get/" + os.stoid, { | ||
| 2336 | - isShowLoading: 1, | ||
| 2337 | - data: {}, | ||
| 2338 | - success: function (rs) { | ||
| 2339 | - getApp().globalData.config = rs.data.data; | ||
| 2340 | - if (rs.data.data.store_tel == null && rs.data.data.store_tel == undefined) { | ||
| 2341 | - getApp().my_warnning("商家未设置电话", 0, th); | ||
| 2342 | - return false; | ||
| 2343 | - } | ||
| 2344 | - self.setData({ | ||
| 2345 | - store_tel: rs.data.data.store_tel, | ||
| 2346 | - }); | ||
| 2347 | - // s.confirmBox("请联系客服:" + rs.data.data.store_tel); | ||
| 2348 | - } | ||
| 2349 | - }) | ||
| 2350 | - } else { | ||
| 2351 | - self.setData({ | ||
| 2352 | - store_tel: t.store_tel, | ||
| 2353 | - }); | ||
| 2354 | - // s.confirmBox("请联系客服:" + t.store_tel); | ||
| 2355 | - }; | ||
| 2356 | - resolve(); | ||
| 2357 | - }); | ||
| 2358 | - }); | ||
| 2359 | - }, | ||
| 2360 | - | ||
| 2361 | - //-------获取购物车数量---------- | ||
| 2362 | - requestCardNum: function () { | ||
| 2363 | - var t = this; | ||
| 2364 | - getApp().request.get("/api/weshop/cart/page", { | ||
| 2365 | - data: { | ||
| 2366 | - store_id: o.stoid, | ||
| 2367 | - user_id: s.globalData.user_id, | ||
| 2368 | - state: 0, | ||
| 2369 | - is_gift: 0 | ||
| 2370 | - }, | ||
| 2371 | - success: function (e) { | ||
| 2372 | - var num = 0; | ||
| 2373 | - for (var i = 0; i < e.data.data.pageData.length; i++) { | ||
| 2374 | - num += e.data.data.pageData[i].goods_num; | ||
| 2375 | - } | ||
| 2376 | - | ||
| 2377 | - //-- 读取服务卡的数量 -- | ||
| 2378 | - getApp().promiseGet("/api/weshop/cartService/page", { | ||
| 2379 | - data: { | ||
| 2380 | - store_id: s.globalData.setting.stoid, | ||
| 2381 | - user_id: s.globalData.user_id, | ||
| 2382 | - } | ||
| 2383 | - }).then(res => { | ||
| 2384 | - for (var i = 0; i < res.data.data.pageData.length; i++) { | ||
| 2385 | - num += res.data.data.pageData[i].goods_num; | ||
| 2386 | - } | ||
| 2387 | - t.setData({cartGoodsNum: num}); | ||
| 2388 | - }) | ||
| 2389 | - } | ||
| 2390 | - }); | ||
| 2391 | - }, | ||
| 2392 | - | ||
| 2393 | - previewCommentImgs: function (t) { | ||
| 2394 | - var e = this.data.comments[t.currentTarget.dataset.cidx].img; | ||
| 2395 | - var b = e.slice() | ||
| 2396 | - for (var i in b) { | ||
| 2397 | - b[i] = this.data.iurl + e[i]; | ||
| 2398 | - } | ||
| 2399 | - this.data.show_prew_img = 1; | ||
| 2400 | - getApp().pre_img2(b,t) | ||
| 2401 | - }, | ||
| 2402 | - | ||
| 2403 | - previewCommentImgs_w: function (t) { | ||
| 2404 | - var e = this.data.comments[t.currentTarget.dataset.cidx].weapp_img; | ||
| 2405 | - var b = e.slice() | ||
| 2406 | - for (var i in b) { | ||
| 2407 | - b[i] = this.data.iurl + e[i]; | ||
| 2408 | - } | ||
| 2409 | - this.data.show_prew_img = 1; | ||
| 2410 | - getApp().pre_img2(b,t) | ||
| 2411 | - }, | ||
| 2412 | - | ||
| 2413 | - previewGoodsCommentImgs: function (t) { | ||
| 2414 | - var e = this, | ||
| 2415 | - a = this.data.data.comment[t.currentTarget.dataset.cidx].img; | ||
| 2416 | - a = a.map(function (t) { | ||
| 2417 | - return e.data.url + t; | ||
| 2418 | - }), getApp().pre_img2(a,t); | ||
| 2419 | - this.data.show_prew_img = 1; | ||
| 2420 | - }, | ||
| 2421 | - closePromModal: function () { | ||
| 2422 | - this.setData({ | ||
| 2423 | - openPromModal: !1 | ||
| 2424 | - }); | ||
| 2425 | - }, | ||
| 2426 | - openPromModal: function () { | ||
| 2427 | - this.setData({ | ||
| 2428 | - openPromModal: !0 | ||
| 2429 | - }); | ||
| 2430 | - }, | ||
| 2431 | - | ||
| 2432 | - //--点击分享事件--- | ||
| 2433 | - onShareAppMessage: function (t) { | ||
| 2434 | - getApp().globalData.no_clear=1; | ||
| 2435 | - | ||
| 2436 | - var th = this; | ||
| 2437 | - var price = th.data.sele_g.shop_price; | ||
| 2438 | - if (th.data.prom_act) { | ||
| 2439 | - price = th.data.prom_act.price; | ||
| 2440 | - | ||
| 2441 | - } | ||
| 2442 | - var title = th.data.sele_g.goods_name; | ||
| 2443 | - var img = th.data.sele_g.original_img; | ||
| 2444 | - if (th.data.prom_type == 6 || th.data.prom_type == 1 || th.data.prom_type == 4) { | ||
| 2445 | - title = th.data.prom_act.share_title; | ||
| 2446 | - if (!title) title = th.data.prom_act.title; | ||
| 2447 | - if (th.data.prom_type == 4) title = th.data.prom_act.name; | ||
| 2448 | - | ||
| 2449 | - if (th.data.prom_act.share_imgurl) | ||
| 2450 | - img = th.data.iurl + th.data.prom_act.share_imgurl; | ||
| 2451 | - } | ||
| 2452 | - | ||
| 2453 | - | ||
| 2454 | - var url = "/pages/goods/goodsInfo/goodsInfo?goods_id=" | ||
| 2455 | - + th.data.sele_g.goods_id + "&prom_type=" + th.data.sele_g.prom_type + "&prom_id=" + th.data.sele_g.prom_id; | ||
| 2456 | - if (getApp().globalData.user_id) { | ||
| 2457 | - url += "&first_leader=" + getApp().globalData.user_id; | ||
| 2458 | - } | ||
| 2459 | - | ||
| 2460 | - //-- 如果房间分享,且不是会员分享的 -- | ||
| 2461 | - if (getApp().globalData.room_id && | ||
| 2462 | - th.data.sele_g.goods_id == getApp().globalData.room_goods_id && !getApp().globalData.room_user_share | ||
| 2463 | - ) { | ||
| 2464 | - url += "&room_id=" + getApp().globalData.room_id + "&room_user_share=1"; | ||
| 2465 | - } | ||
| 2466 | - | ||
| 2467 | - var ob = { | ||
| 2468 | - title: price + "元 " + title, | ||
| 2469 | - path: url, | ||
| 2470 | - imageUrl: img, | ||
| 2471 | - }; | ||
| 2472 | - if (th.data.prom_type == 6) { | ||
| 2473 | - title += '\n' + th.data.prom_act.share_remark; | ||
| 2474 | - ob.title = title; | ||
| 2475 | - ob.desc = th.data.prom_act.share_remark; | ||
| 2476 | - } | ||
| 2477 | - | ||
| 2478 | - //如果是积分购的时候 | ||
| 2479 | - if (th.data.prom_type == 4) { | ||
| 2480 | - var name = th.data.prom_act.name; | ||
| 2481 | - //-- 积分购的 -- | ||
| 2482 | - var pri0 = th.data.prom_act.addmoney; | ||
| 2483 | - var integral = th.data.prom_act.integral; | ||
| 2484 | - var text = ""; | ||
| 2485 | - if (integral) { text = integral + "积分"; } | ||
| 2486 | - if (pri0 && integral) { text += "+"; } | ||
| 2487 | - if (pri0) { text += "¥" + pri0; } | ||
| 2488 | - | ||
| 2489 | - ob.title = text + " " + name; | ||
| 2490 | - } | ||
| 2491 | - //-- 页面不能刷新 -- | ||
| 2492 | - this.data.show_prew_img=1; | ||
| 2493 | - | ||
| 2494 | - console.log("share.."); | ||
| 2495 | - console.log(ob); | ||
| 2496 | - return ob; | ||
| 2497 | - | ||
| 2498 | - }, | ||
| 2499 | - | ||
| 2500 | - //-----图片失败,默认图片----- | ||
| 2501 | - bind_bnerr: function (e) { | ||
| 2502 | - var _errImg = e.target.dataset.errorimg; | ||
| 2503 | - var _errObj = {}; | ||
| 2504 | - _errObj[_errImg] = this.data.iurl + "/miniapp/images/default_g_img.gif"; | ||
| 2505 | - this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ; | ||
| 2506 | - }, | ||
| 2507 | - | ||
| 2508 | - //-----图片失败,默认图片----- | ||
| 2509 | - bind_bnerr2: function (e) { | ||
| 2510 | - | ||
| 2511 | - var _errImg = e.target.dataset.errorimg; | ||
| 2512 | - var _errObj = {}; | ||
| 2513 | - _errObj[_errImg] = this.data.iurl + "/miniapp/images/hui_hear_pic.png" | ||
| 2514 | - this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ; | ||
| 2515 | - }, | ||
| 2516 | - | ||
| 2517 | - | ||
| 2518 | - //----------装载同一条形码的商品---------- | ||
| 2519 | - async get_sku(stoid, gd, g_id, is_normal, func) { | ||
| 2520 | - console.log('get_sku'); | ||
| 2521 | - var tt = this, arrdata = null; | ||
| 2522 | - var now = ut.gettimestamp(); | ||
| 2523 | - await getApp().request.promiseGet("/api/weshop/goods/page", { | ||
| 2524 | - data: { | ||
| 2525 | - store_id: o.stoid, | ||
| 2526 | - sku: gd.sku, | ||
| 2527 | - more_spec: gd.more_spec, | ||
| 2528 | - isonsale: 1, | ||
| 2529 | - is_on_sale: 1, | ||
| 2530 | - pageSize: 500, | ||
| 2531 | - orderField: 'gg_ordid,goods_spec,sort' | ||
| 2532 | - } | ||
| 2533 | - }).then(res => { | ||
| 2534 | - var e = res; | ||
| 2535 | - if (e.data.code == 0) arrdata = e.data.data.pageData; | ||
| 2536 | - }) | ||
| 2537 | - if (!arrdata) return false; | ||
| 2538 | - | ||
| 2539 | - var arrsku = new Array(); | ||
| 2540 | - var gitem = null; | ||
| 2541 | - var gb = 1, gg = ""; | ||
| 2542 | - for (var i = 0; i < arrdata.length; i++) { | ||
| 2543 | - var goodsinfo = arrdata[i], prom = null; | ||
| 2544 | - if (goodsinfo.goods_id != g_id) { | ||
| 2545 | - | ||
| 2546 | - switch (goodsinfo.prom_type) { | ||
| 2547 | - case 1: | ||
| 2548 | - | ||
| 2549 | - if(goodsinfo.prom_id) { | ||
| 2550 | - await getApp().request.promiseGet("/api/ms/flash_sale/get/" + os.stoid + "/" + goodsinfo.prom_id, {}).then(res => { | ||
| 2551 | - if (res.data.code == 0) prom = res.data.data; | ||
| 2552 | - }) | ||
| 2553 | - } | ||
| 2554 | - | ||
| 2555 | - | ||
| 2556 | - break; | ||
| 2557 | - case 6: | ||
| 2558 | - await getApp().request.promiseGet("/api/weshop/teamlist/get/" + os.stoid + "/" + goodsinfo.prom_id, {}).then(res => { | ||
| 2559 | - console.log(res); | ||
| 2560 | - if (res.data.code == 0) prom = res.data.data; | ||
| 2561 | - }) | ||
| 2562 | - | ||
| 2563 | - break; | ||
| 2564 | - case 2: | ||
| 2565 | - await getApp().request.promiseGet("/api/weshop/goods/groupBuy/getActInfo/" + os.stoid + "/" + goodsinfo.goods_id + "/" + goodsinfo.prom_id, {}).then(res => { | ||
| 2566 | - if (res.data.code == 0) prom = res.data.data; | ||
| 2567 | - }) | ||
| 2568 | - break; | ||
| 2569 | - case 4: | ||
| 2570 | - await getApp().request.promiseGet("/api/weshop/integralbuy/getActInfo/" + os.stoid + "/" + goodsinfo.goods_id + "/" + goodsinfo.prom_id, {}).then(res => { | ||
| 2571 | - if (res.data.code == 0) prom = res.data.data; | ||
| 2572 | - }) | ||
| 2573 | - break | ||
| 2574 | - //预售和幸运购不参与 | ||
| 2575 | - case 8: | ||
| 2576 | - case 9: | ||
| 2577 | - continue; | ||
| 2578 | - } | ||
| 2579 | - | ||
| 2580 | - } | ||
| 2581 | - //---如果有活动,不算在一起--- | ||
| 2582 | - if (prom) { | ||
| 2583 | - if (goodsinfo.prom_type == 1 || goodsinfo.prom_type == 6) { | ||
| 2584 | - console.log(prom); | ||
| 2585 | - if (prom.is_end == 0 && prom.end_time > now && prom.start_time < now) continue; | ||
| 2586 | - } else { | ||
| 2587 | - continue; | ||
| 2588 | - } | ||
| 2589 | - } | ||
| 2590 | - | ||
| 2591 | - | ||
| 2592 | - var item = arrdata[i], gg = ""; | ||
| 2593 | - if (item.goods_spec == "null" || item.goods_spec == null) item.goods_spec = ""; | ||
| 2594 | - if (item.goods_color == "null" || item.goods_color == null) item.goods_color = ""; | ||
| 2595 | - | ||
| 2596 | - if (item.goods_spec != "" && item.goods_color != "") { | ||
| 2597 | - gg = item.goods_spec + "/" + item.goods_color; | ||
| 2598 | - } else if (item.goods_spec != "" || item.goods_color != "") { | ||
| 2599 | - gg = item.goods_spec + item.goods_color; | ||
| 2600 | - } else { | ||
| 2601 | - gg = "规格" + gb; | ||
| 2602 | - gb++; | ||
| 2603 | - } | ||
| 2604 | - item.gg = gg; | ||
| 2605 | - | ||
| 2606 | - if (item.spec_img) | ||
| 2607 | - item.original_img = os.imghost + item.spec_img; | ||
| 2608 | - else | ||
| 2609 | - item.original_img = os.imghost + item.original_img; | ||
| 2610 | - | ||
| 2611 | - | ||
| 2612 | - if (item.goods_id == g_id) { | ||
| 2613 | - gitem = item; | ||
| 2614 | - } else { | ||
| 2615 | - arrsku.push(item); | ||
| 2616 | - } | ||
| 2617 | - } | ||
| 2618 | - //-----------排列在最前面------------- | ||
| 2619 | - arrsku.splice(0, 0, gitem); | ||
| 2620 | - if (is_normal == 1) { | ||
| 2621 | - tt.setData({ | ||
| 2622 | - sku_g_pt: arrsku, | ||
| 2623 | - sele_g: gitem | ||
| 2624 | - }); | ||
| 2625 | - func(); | ||
| 2626 | - } else { | ||
| 2627 | - tt.setData({ | ||
| 2628 | - sku_g: arrsku, | ||
| 2629 | - sele_g: gitem | ||
| 2630 | - }); | ||
| 2631 | - } | ||
| 2632 | - }, | ||
| 2633 | - | ||
| 2634 | - //-----------选择属性的按钮事件---------- | ||
| 2635 | - sele_spec: function (e) { | ||
| 2636 | - var that = this; | ||
| 2637 | - var gid = e.currentTarget.dataset.gid; | ||
| 2638 | - var nor = e.currentTarget.dataset.nor; | ||
| 2639 | - | ||
| 2640 | - var sku_g = this.data.sku_g; | ||
| 2641 | - if (nor) { | ||
| 2642 | - sku_g = this.data.sku_g_pt; | ||
| 2643 | - } | ||
| 2644 | - | ||
| 2645 | - var item = null; | ||
| 2646 | - for (var i in sku_g) { | ||
| 2647 | - if (sku_g[i].goods_id == gid) { | ||
| 2648 | - item = sku_g[i]; | ||
| 2649 | - if (item.original_img.indexOf(that.data.iurl) == -1) { | ||
| 2650 | - item.original_img = that.data.iurl + item.original_img; | ||
| 2651 | - } | ||
| 2652 | - break | ||
| 2653 | - } | ||
| 2654 | - } | ||
| 2655 | - console.log(item, 2000); | ||
| 2656 | - var cur_price = item.shop_price; | ||
| 2657 | - if (getApp().globalData.userInfo && getApp().globalData.userInfo.card_field) { | ||
| 2658 | - var cfile = getApp().globalData.userInfo.card_field; | ||
| 2659 | - console.log('cfile', cfile); | ||
| 2660 | - if (item[cfile]) { | ||
| 2661 | - cur_price = item[cfile]; | ||
| 2662 | - } | ||
| 2663 | - } | ||
| 2664 | - var txt = (cur_price / item.market_price * 10).toFixed(2).toString(); | ||
| 2665 | - txt = parseFloat(txt); | ||
| 2666 | - item['disc'] = txt; | ||
| 2667 | - if (item) this.setData({ | ||
| 2668 | - sele_g: item, | ||
| 2669 | - gid: gid, | ||
| 2670 | - data: item, | ||
| 2671 | - }); | ||
| 2672 | - | ||
| 2673 | - | ||
| 2674 | - that.check_is_youhui(gid, that.data.is_normal); | ||
| 2675 | - | ||
| 2676 | - //默认门店要拿下门店库存 | ||
| 2677 | - if (that.data.sales_rules == 2 && that.data.def_pick_store) { | ||
| 2678 | - var lock = 0, plist = null; | ||
| 2679 | - //先读取门店的lock,采用链式写法,少用await | ||
| 2680 | - getApp().request.promiseGet("/api/weshop/order/ware/lock/page", { | ||
| 2681 | - data: { | ||
| 2682 | - store_id: os.stoid, | ||
| 2683 | - wareId: that.data.sele_g.goods_id, | ||
| 2684 | - storageId: that.data.def_pick_store.pickup_id, | ||
| 2685 | - pageSize: 1000 | ||
| 2686 | - } | ||
| 2687 | - }).then(res => { | ||
| 2688 | - if (res.data.code == 0 && res.data.data.total > 0) { | ||
| 2689 | - for (var i in res.data.data.pageData) | ||
| 2690 | - lock += res.data.data.pageData[i].outQty | ||
| 2691 | - } | ||
| 2692 | - //---通过接口获取门店的线下库存信息-- | ||
| 2693 | - return getApp().request.promiseGet("/api/weshop/goods/getWareStorages", { | ||
| 2694 | - data: { | ||
| 2695 | - storageNos: that.data.def_pick_store.pickup_no, | ||
| 2696 | - wareIds: encodeURIComponent(that.data.sele_g.erpwareid), | ||
| 2697 | - storeId: os.stoid | ||
| 2698 | - } | ||
| 2699 | - }) | ||
| 2700 | - }).then(res => { | ||
| 2701 | - if (res.data.code == 0 && res.data.data.total > 0) { | ||
| 2702 | - plist = res.data.data.pageData[0]; | ||
| 2703 | - } | ||
| 2704 | - if (plist && plist.CanOutQty - lock > 0) { | ||
| 2705 | - that.data.def_pick_store.CanOutQty = plist.CanOutQty - lock; | ||
| 2706 | - } else { | ||
| 2707 | - that.data.def_pick_store.CanOutQty = 0; | ||
| 2708 | - } | ||
| 2709 | - //--给门店赋值线下库存-- | ||
| 2710 | - that.setData({def_pick_store: that.data.def_pick_store}); | ||
| 2711 | - }) | ||
| 2712 | - } | ||
| 2713 | - this.sele_spec_chech_activity(); | ||
| 2714 | - }, | ||
| 2715 | - | ||
| 2716 | - //选择了不同的规格的时候要判断是不是有活动正在进行中 | ||
| 2717 | - async sele_spec_chech_activity() { | ||
| 2718 | - //---如果是活动的时候--- | ||
| 2719 | - var prom = null, goodsinfo = this.data.sele_g, th = this; | ||
| 2720 | - var user_id = getApp().globalData.user_id; | ||
| 2721 | - if (!user_id) user_id = 0; | ||
| 2722 | - if (goodsinfo.prom_type == 1) { | ||
| 2723 | - await getApp().request.promiseGet("/api/ms/flash_sale/getNew/" + os.stoid + "/" + user_id + "/" + goodsinfo.prom_id, {}).then(res => { | ||
| 2724 | - if (res.data.code == 0) { | ||
| 2725 | - prom = res.data.data; | ||
| 2726 | - prom.price = prom.user_price; | ||
| 2727 | - } | ||
| 2728 | - }) | ||
| 2729 | - } | ||
| 2730 | - if (goodsinfo.prom_type == 6) { | ||
| 2731 | - await getApp().request.promiseGet("/api/weshop/teamlist/get/" + os.stoid + "/" + goodsinfo.prom_id, {}).then(res => { | ||
| 2732 | - if (res.data.code == 0) { | ||
| 2733 | - prom = res.data.data; | ||
| 2734 | - } | ||
| 2735 | - }) | ||
| 2736 | - } | ||
| 2737 | - | ||
| 2738 | - if (goodsinfo.prom_type == 4) { | ||
| 2739 | - await getApp().request.promiseGet("/api/weshop/integralbuy/getActInfo/" + os.stoid + "/" + goodsinfo.goods_id + "/" + goodsinfo.prom_id, {}).then(res => { | ||
| 2740 | - if (res.data.code == 0) { | ||
| 2741 | - prom = res.data.data; | ||
| 2742 | - } | ||
| 2743 | - }) | ||
| 2744 | - } | ||
| 2745 | - | ||
| 2746 | - //----------如果有活动,并且在进行中,就不计算线下库存--------------- | ||
| 2747 | - var now = ut.gettimestamp(); | ||
| 2748 | - if (prom) { | ||
| 2749 | - | ||
| 2750 | - var t1 = prom.start_time; | ||
| 2751 | - var prom_st = 1; | ||
| 2752 | - if (prom.show_time) { | ||
| 2753 | - t1 = prom.show_time; | ||
| 2754 | - if (prom.start_time > now) prom_st = 0; | ||
| 2755 | - } | ||
| 2756 | - if (prom.is_end == 0 && prom.end_time > now && t1 < now) { | ||
| 2757 | - th.setData({ | ||
| 2758 | - prom_type: goodsinfo.prom_type, | ||
| 2759 | - prom_price: prom.price, | ||
| 2760 | - prom_buy_limit: prom.buy_limit ? prom.buy_limit : (prom.limitvipqty ? prom.limitvipqty : 0), | ||
| 2761 | - prom_end_time: prom.end_time, | ||
| 2762 | - prom_start_time: prom.start_time, | ||
| 2763 | - prom_st: prom_st, | ||
| 2764 | - prom_act: prom, | ||
| 2765 | - prom_id: prom.id | ||
| 2766 | - }) | ||
| 2767 | - | ||
| 2768 | - //却换图片 | ||
| 2769 | - th.init(goodsinfo.goods_id); | ||
| 2770 | - var newTime = ut.gettimestamp(); | ||
| 2771 | - var endTime2 = prom.end_time; | ||
| 2772 | - var endTime1 = prom.start_time; | ||
| 2773 | - | ||
| 2774 | - this.data.is_timer = 0; | ||
| 2775 | - | ||
| 2776 | - setTimeout(function () { | ||
| 2777 | - th.data.is_timer = 1; | ||
| 2778 | - if (endTime1 > newTime) { | ||
| 2779 | - th.setData({ | ||
| 2780 | - prom_time_text: '距秒杀开始还有' | ||
| 2781 | - }) | ||
| 2782 | - th.countDown(endTime1, 0); | ||
| 2783 | - } else { | ||
| 2784 | - if (endTime2 > newTime) { | ||
| 2785 | - th.setData({ | ||
| 2786 | - prom_time_text: '距秒杀结束还有', | ||
| 2787 | - prom_st: 1 | ||
| 2788 | - }) | ||
| 2789 | - th.countDown(endTime2); | ||
| 2790 | - } | ||
| 2791 | - } | ||
| 2792 | - | ||
| 2793 | - }, 1000) | ||
| 2794 | - | ||
| 2795 | - return false; | ||
| 2796 | - } | ||
| 2797 | - } | ||
| 2798 | - //---设置普通商品--- | ||
| 2799 | - th.setData({ | ||
| 2800 | - prom_type: 0, | ||
| 2801 | - prom_price: null, | ||
| 2802 | - prom_buy_limit: null, | ||
| 2803 | - prom_end_time: null, | ||
| 2804 | - prom_start_time: null, | ||
| 2805 | - prom_st: null, | ||
| 2806 | - }) | ||
| 2807 | - | ||
| 2808 | - }, | ||
| 2809 | - | ||
| 2810 | - | ||
| 2811 | - //---------拿出门店分类和门店------------ | ||
| 2812 | - get_sto(e) { | ||
| 2813 | - console.log('get_sto') | ||
| 2814 | - var th = this, that = this; | ||
| 2815 | - var is_normal = e; | ||
| 2816 | - | ||
| 2817 | - if (e == 1) { | ||
| 2818 | - th.setData({is_normal: 1}) | ||
| 2819 | - } else { | ||
| 2820 | - th.setData({is_normal: 0}) | ||
| 2821 | - } | ||
| 2822 | - | ||
| 2823 | - var timer_get = setInterval(function () { | ||
| 2824 | - if (th.data.is_get_local_ok == 0) return false; | ||
| 2825 | - var dd = null, i = getApp().request; | ||
| 2826 | - if (!th.data.sele_g) return false; | ||
| 2827 | - | ||
| 2828 | - var g_distr_type = th.data.sele_g.distr_type; | ||
| 2829 | - if (g_distr_type != 0) { | ||
| 2830 | - dd = { | ||
| 2831 | - store_id: o.stoid, | ||
| 2832 | - distr_type: g_distr_type, | ||
| 2833 | - isstop: 0, | ||
| 2834 | - is_pos: 1, | ||
| 2835 | - pageSize: 2000 | ||
| 2836 | - } | ||
| 2837 | - } else { | ||
| 2838 | - dd = { | ||
| 2839 | - store_id: o.stoid, | ||
| 2840 | - isstop: 0, | ||
| 2841 | - is_pos: 1, | ||
| 2842 | - pageSize: 2000 | ||
| 2843 | - } | ||
| 2844 | - } | ||
| 2845 | - //如果有距离的话 | ||
| 2846 | - if (th.data.lat != null) { | ||
| 2847 | - dd.lat = th.data.lat; | ||
| 2848 | - dd.lon = th.data.lon; | ||
| 2849 | - } | ||
| 2850 | - clearInterval(timer_get); | ||
| 2851 | - | ||
| 2852 | - | ||
| 2853 | - //如果会员是有默认的门店话 | ||
| 2854 | - if (!th.data.def_pick_store && th.data.fir_def_store && Object.keys(th.data.fir_def_store).length>0) { | ||
| 2855 | - th.setData({def_pick_store: th.data.fir_def_store}); | ||
| 2856 | - } | ||
| 2857 | - wx.showLoading({ | ||
| 2858 | - title: '加载中.' | ||
| 2859 | - }); | ||
| 2860 | - //----------获取门店---------------- | ||
| 2861 | - getApp().request.promiseGet("/api/weshop/pickup/list", { | ||
| 2862 | - data: dd, | ||
| 2863 | - }).then(res => { | ||
| 2864 | - var e = res; | ||
| 2865 | - | ||
| 2866 | - if (e.data.code == 0 && e.data.data && e.data.data.pageData && e.data.data.pageData.length > 0) { | ||
| 2867 | - | ||
| 2868 | - var his_cate_num = 0; | ||
| 2869 | - for (let i in e.data.data.pageData) { | ||
| 2870 | - let item = e.data.data.pageData[i]; | ||
| 2871 | - if (item.category_id > 0) { | ||
| 2872 | - his_cate_num = 1; | ||
| 2873 | - break; | ||
| 2874 | - } | ||
| 2875 | - } | ||
| 2876 | - e.his_cate_num = his_cate_num; | ||
| 2877 | - | ||
| 2878 | - //如果有开启距离的功能,没有设置默认门店,要用最近的门店作为默认门店 | ||
| 2879 | - if (dd.lat && (!th.data.def_pick_store || JSON.stringify(th.data.def_pick_store) == '{}') && th.data.bconfig && th.data.bconfig.is_sort_storage) { | ||
| 2880 | - th.setData({ | ||
| 2881 | - def_pick_store: e.data.data.pageData[0], | ||
| 2882 | - sto_sele_name: e.data.data.pageData[0].pickup_name, | ||
| 2883 | - sto_sele_id: e.data.data.pageData[0].pickup_id, | ||
| 2884 | - sto_sele_distr: e.data.data.pageData[0].distr_type | ||
| 2885 | - }); | ||
| 2886 | - th.data.fir_def_store = e.data.data.pageData[0]; | ||
| 2887 | - } | ||
| 2888 | - | ||
| 2889 | - //-- 如果有默认选择门店的时候,要把默认门店放在第一位,修改不要配送方式的判断 -- | ||
| 2890 | - if (th.data.def_pick_store && JSON.stringify(th.data.def_pick_store) != '{}') { | ||
| 2891 | - for (var k = 0; k < e.data.data.pageData.length; k++) { | ||
| 2892 | - if (e.data.data.pageData[k].pickup_id == th.data.def_pick_store.pickup_id) { | ||
| 2893 | - e.data.data.pageData.splice(k, 1); //删除 | ||
| 2894 | - break; | ||
| 2895 | - } | ||
| 2896 | - } | ||
| 2897 | - e.data.data.pageData.splice(0, 0, th.data.def_pick_store); //添加 | ||
| 2898 | - } | ||
| 2899 | - | ||
| 2900 | - | ||
| 2901 | - th.setData({all_pick_list: e.data.data.pageData}); | ||
| 2902 | - | ||
| 2903 | - //--获取线下库存,而且不是新的门店规则, 同时是普通购买的时候,或者同时不能是活动,秒杀,拼团,积分购-- | ||
| 2904 | - if (th.data.sales_rules == 2 && !th.data.is_newsales_rules && ((th.data.prom_type != 1 && th.data.prom_type != 6 && th.data.prom_type != 4) || is_normal == 1)) { | ||
| 2905 | - setTimeout(function () { | ||
| 2906 | - th.deal_pickup_dline(e); | ||
| 2907 | - }, 800) | ||
| 2908 | - } else { | ||
| 2909 | - setTimeout(function () { | ||
| 2910 | - th.deal_pickup(e); //--普通门店排版-- | ||
| 2911 | - }, 800) | ||
| 2912 | - } | ||
| 2913 | - } | ||
| 2914 | - }) | ||
| 2915 | - }, 200) | ||
| 2916 | - | ||
| 2917 | - }, | ||
| 2918 | - | ||
| 2919 | - | ||
| 2920 | - //------------处理门店--------------- | ||
| 2921 | - deal_pickup(e) { | ||
| 2922 | - var th = this; | ||
| 2923 | - if (!th.data.sele_g) return false | ||
| 2924 | - | ||
| 2925 | - var g_distr_type = th.data.sele_g.distr_type; | ||
| 2926 | - wx.hideLoading(); | ||
| 2927 | - | ||
| 2928 | - //单总量超出10个的时候,同时门店有分类 | ||
| 2929 | - if (e.data.data.total > 10 && e.his_cate_num) { | ||
| 2930 | - getApp().request.get("/api/weshop/storagecategory/page", { | ||
| 2931 | - data: { | ||
| 2932 | - store_id: o.stoid, | ||
| 2933 | - pageSize: 1000, | ||
| 2934 | - orderField: "sort", | ||
| 2935 | - orderType: 'asc', | ||
| 2936 | - }, | ||
| 2937 | - success: function (ee) { | ||
| 2938 | - if (ee.data.code == 0) { | ||
| 2939 | - var check_all_cate = 0; | ||
| 2940 | - if (ee.data.data && ee.data.data.pageData && ee.data.data.pageData.length > 0) { | ||
| 2941 | - for (let i in ee.data.data.pageData) { | ||
| 2942 | - let item = ee.data.data.pageData[i]; | ||
| 2943 | - if (item.is_show == 1) { | ||
| 2944 | - check_all_cate = 1; | ||
| 2945 | - break | ||
| 2946 | - } | ||
| 2947 | - } | ||
| 2948 | - } | ||
| 2949 | - if (check_all_cate) { | ||
| 2950 | - var sto_cate = ee.data.data.pageData; | ||
| 2951 | - var sto_arr = e.data.data.pageData; | ||
| 2952 | - var newarr = new Array(); | ||
| 2953 | - var qita = new Array(); | ||
| 2954 | - | ||
| 2955 | - | ||
| 2956 | - var is_del_pk = 0; | ||
| 2957 | - //----要进行门店分组-------- | ||
| 2958 | - for (var i = 0; i < sto_arr.length; i++) { | ||
| 2959 | - //找一下这个门店有没有在分类数组内 | ||
| 2960 | - var find2 = 0, find2name = "", sort = 0; | ||
| 2961 | - is_del_pk = 0; | ||
| 2962 | - for (var m = 0; m < sto_cate.length; m++) { | ||
| 2963 | - if (sto_arr[i].category_id == sto_cate[m].cat_id) { | ||
| 2964 | - if (sto_cate[m].is_show != 1) { | ||
| 2965 | - is_del_pk = 1; | ||
| 2966 | - sto_arr.splice(i, 1); | ||
| 2967 | - i--; | ||
| 2968 | - } else { | ||
| 2969 | - find2 = sto_cate[m].cat_id; | ||
| 2970 | - find2name = sto_cate[m].cat_name; | ||
| 2971 | - sort = sto_cate[m].sort; | ||
| 2972 | - is_del_pk = 0; | ||
| 2973 | - } | ||
| 2974 | - break; | ||
| 2975 | - } | ||
| 2976 | - } | ||
| 2977 | - if (is_del_pk) continue; | ||
| 2978 | - | ||
| 2979 | - if (newarr.length > 0) { | ||
| 2980 | - var find = 0; | ||
| 2981 | - //如果有找到,那门店就在这个分组内,否则,分类就要排在其他 | ||
| 2982 | - if (find2 != 0) { | ||
| 2983 | - for (var ii = 0; ii < newarr.length; ii++) { | ||
| 2984 | - if (sto_arr[i].category_id == newarr[ii].cat_id) { | ||
| 2985 | - newarr[ii].s_arr.push(sto_arr[i]); | ||
| 2986 | - find = 1; | ||
| 2987 | - break; | ||
| 2988 | - } | ||
| 2989 | - } | ||
| 2990 | - if (find == 0) { | ||
| 2991 | - var arr0 = new Array(); | ||
| 2992 | - arr0.push(sto_arr[i]); | ||
| 2993 | - var item = { | ||
| 2994 | - cat_id: find2, | ||
| 2995 | - name: find2name, | ||
| 2996 | - sort: sort, | ||
| 2997 | - s_arr: arr0 | ||
| 2998 | - }; | ||
| 2999 | - newarr.push(item); | ||
| 3000 | - } | ||
| 3001 | - } else { | ||
| 3002 | - qita.push(sto_arr[i]); | ||
| 3003 | - } | ||
| 3004 | - } else { | ||
| 3005 | - //如果有找到,那门店就在这个分组内,否则,分类就要排在其他 | ||
| 3006 | - if (find2 != 0) { | ||
| 3007 | - var arr0 = new Array(); | ||
| 3008 | - arr0.push(sto_arr[i]); | ||
| 3009 | - var item = { | ||
| 3010 | - cat_id: find2, | ||
| 3011 | - name: find2name, | ||
| 3012 | - sort: sort, | ||
| 3013 | - s_arr: arr0 | ||
| 3014 | - }; | ||
| 3015 | - newarr.push(item); | ||
| 3016 | - } else { | ||
| 3017 | - qita.push(sto_arr[i]); | ||
| 3018 | - } | ||
| 3019 | - } | ||
| 3020 | - } | ||
| 3021 | - | ||
| 3022 | - var def_arr = new Array(); | ||
| 3023 | - //-- 开始就看10个门店 -- | ||
| 3024 | - for (var k = 0; k < 10; k++) { | ||
| 3025 | - if (k == sto_arr.length) break; | ||
| 3026 | - def_arr.push(sto_arr[k]); | ||
| 3027 | - } | ||
| 3028 | - | ||
| 3029 | - th.setData({ | ||
| 3030 | - def_pickpu_list: def_arr, | ||
| 3031 | - pickpu_list: ee.data.data.pageData | ||
| 3032 | - }); | ||
| 3033 | - | ||
| 3034 | - | ||
| 3035 | - //门店分类要排序下 | ||
| 3036 | - function compare(property) { | ||
| 3037 | - return function (a, b) { | ||
| 3038 | - var value1 = a[property]; | ||
| 3039 | - var value2 = b[property]; | ||
| 3040 | - return value1 - value2; | ||
| 3041 | - } | ||
| 3042 | - } | ||
| 3043 | - | ||
| 3044 | - if (newarr.length > 0) | ||
| 3045 | - newarr.sort(compare("sort")); | ||
| 3046 | - | ||
| 3047 | - | ||
| 3048 | - //----安排其他的分类----- | ||
| 3049 | - if (qita.length > 0) { | ||
| 3050 | - var item = { | ||
| 3051 | - cat_id: -1, | ||
| 3052 | - name: "其他", | ||
| 3053 | - s_arr: qita | ||
| 3054 | - }; | ||
| 3055 | - newarr.push(item); | ||
| 3056 | - } | ||
| 3057 | - | ||
| 3058 | - var sd = { | ||
| 3059 | - all_sto: newarr, | ||
| 3060 | - is_show_sto_cat: 1 | ||
| 3061 | - } | ||
| 3062 | - if (!sto_arr || sto_arr.length <= 10) { | ||
| 3063 | - sd.is_show_sto_cat = -1; | ||
| 3064 | - sd.only_pk = sto_arr; | ||
| 3065 | - } | ||
| 3066 | - th.setData(sd); | ||
| 3067 | - | ||
| 3068 | - } else { | ||
| 3069 | - th.setData({ | ||
| 3070 | - is_show_sto_cat: -1, | ||
| 3071 | - only_pk: e.data.data.pageData | ||
| 3072 | - }); | ||
| 3073 | - //-----如果没有默认门店,要取第一个门店作为默认店.此时没有门店分类的情况------ | ||
| 3074 | - if (!th.data.def_pick_store) { | ||
| 3075 | - th.setData({ | ||
| 3076 | - def_pick_store: e.data.data.pageData[0], | ||
| 3077 | - sto_sele_name: e.data.data.pageData[0].pickup_name, | ||
| 3078 | - sto_sele_id: e.data.data.pageData[0].pickup_id, | ||
| 3079 | - sto_sele_distr: e.data.data.pageData[0].distr_type | ||
| 3080 | - }) | ||
| 3081 | - } | ||
| 3082 | - } | ||
| 3083 | - } else { | ||
| 3084 | - th.setData({ | ||
| 3085 | - is_show_sto_cat: -1, | ||
| 3086 | - only_pk: e.data.data.pageData | ||
| 3087 | - }); | ||
| 3088 | - //-----如果没有默认门店,要取第一个门店作为默认店.此时没有门店分类的情况------ | ||
| 3089 | - if (!th.data.def_pick_store) { | ||
| 3090 | - th.setData({ | ||
| 3091 | - def_pick_store: e.data.data.pageData[0], | ||
| 3092 | - sto_sele_name: e.data.data.pageData[0].pickup_name, | ||
| 3093 | - sto_sele_id: e.data.data.pageData[0].pickup_id, | ||
| 3094 | - sto_sele_distr: e.data.data.pageData[0].distr_type | ||
| 3095 | - }) | ||
| 3096 | - } | ||
| 3097 | - | ||
| 3098 | - } | ||
| 3099 | - } | ||
| 3100 | - }); | ||
| 3101 | - } else { | ||
| 3102 | - th.setData({ | ||
| 3103 | - is_show_sto_cat: 0, | ||
| 3104 | - only_pk: e.data.data.pageData | ||
| 3105 | - }); | ||
| 3106 | - //-----如果没有默认门店,要取第一个门店作为默认店------ | ||
| 3107 | - if (!th.data.def_pick_store && th.data.bconfig && th.data.bconfig.is_sort_storage) { | ||
| 3108 | - th.setData({ | ||
| 3109 | - def_pick_store: e.data.data.pageData[0], | ||
| 3110 | - sto_sele_name: e.data.data.pageData[0].pickup_name, | ||
| 3111 | - sto_sele_id: e.data.data.pageData[0].pickup_id, | ||
| 3112 | - sto_sele_distr: e.data.data.pageData[0].distr_type | ||
| 3113 | - }) | ||
| 3114 | - } | ||
| 3115 | - } | ||
| 3116 | - }, | ||
| 3117 | - | ||
| 3118 | - //------------处理线下门店库存-------- | ||
| 3119 | - deal_pickup_dline(e) { | ||
| 3120 | - var pkno = [], th = this; | ||
| 3121 | - if (!th.data.sele_g) return false; | ||
| 3122 | - | ||
| 3123 | - if (this.data.def_pick_store) { | ||
| 3124 | - pkno.push(this.data.def_pick_store.pickup_no); | ||
| 3125 | - } | ||
| 3126 | - for (var i in e.data.data.pageData) { | ||
| 3127 | - var item = e.data.data.pageData[i]; | ||
| 3128 | - if (pkno.indexOf(item.pickup_no) < 0) | ||
| 3129 | - pkno.push(item.pickup_no); | ||
| 3130 | - } | ||
| 3131 | - pkno.sort(); | ||
| 3132 | - var pkno_str = pkno.join(","); | ||
| 3133 | - var o_plist = e.data.data.pageData; | ||
| 3134 | - var new_list = []; | ||
| 3135 | - var is_find_def_store = 0; | ||
| 3136 | - | ||
| 3137 | - | ||
| 3138 | - var g_distr_type = th.data.sele_g.distr_type; | ||
| 3139 | - var lock = []; | ||
| 3140 | - //先读取门店的lock,采用链式写法,少用await | ||
| 3141 | - getApp().request.promiseGet("/api/weshop/order/ware/lock/page", { | ||
| 3142 | - data: {store_id: os.stoid, wareId: th.data.sele_g.goods_id, pageSize: 1000} | ||
| 3143 | - }).then(res => { | ||
| 3144 | - if (res.data.code == 0 && res.data.data.total > 0) { | ||
| 3145 | - lock = res.data.data.pageData | ||
| 3146 | - } | ||
| 3147 | - //---通过接口获取门店的线下库存信息-- | ||
| 3148 | - return getApp().request.promiseGet("/api/weshop/goods/getWareStorages", { | ||
| 3149 | - data: { | ||
| 3150 | - storageNos: pkno_str, | ||
| 3151 | - wareIds: encodeURIComponent(th.data.sele_g.erpwareid), | ||
| 3152 | - storeId: os.stoid, | ||
| 3153 | - pageSize: 2000 | ||
| 3154 | - } | ||
| 3155 | - }) | ||
| 3156 | - }).then(res => { | ||
| 3157 | - | ||
| 3158 | - wx.hideLoading(); | ||
| 3159 | - if (res.data.code == 0) { | ||
| 3160 | - if (res.data.data.pageData && res.data.data.pageData.length > 0) { | ||
| 3161 | - var plist = res.data.data.pageData; | ||
| 3162 | - var def_pick_store = th.data.def_pick_store; | ||
| 3163 | - //以原来的数组为外循环,保证距离的顺序 | ||
| 3164 | - for (var kk in o_plist) { | ||
| 3165 | - for (var ii in plist) { | ||
| 3166 | - //线下的门店小心 | ||
| 3167 | - var n_item = plist[ii]; | ||
| 3168 | - if (n_item.StorageNo == o_plist[kk].pickup_no) { | ||
| 3169 | - | ||
| 3170 | - //拿到锁库的数量 | ||
| 3171 | - var lock_num = th.find_lock_num(o_plist[kk].pickup_id, lock); | ||
| 3172 | - //可出库数大于预出库库存的数量,可以判断为有库存 | ||
| 3173 | - if (n_item.CanOutQty > lock_num) { | ||
| 3174 | - o_plist[kk].CanOutQty = n_item.CanOutQty - lock_num; | ||
| 3175 | - new_list.push(o_plist[kk]); | ||
| 3176 | - //--如果找到默认门店,同时也应该判断配送方式对不对-- | ||
| 3177 | - if (th.data.fir_def_store && n_item.StorageNo == th.data.fir_def_store.pickup_no && (g_distr_type == 0 || th.data.fir_def_store.distr_type == 0 || th.data.def_pick_store.distr_type == g_distr_type)) { | ||
| 3178 | - th.data.fir_def_store.CanOutQty = n_item.CanOutQty - lock_num; | ||
| 3179 | - if (def_pick_store.pickup_id == th.data.fir_def_store.pickup_id) | ||
| 3180 | - th.setData({def_pick_store: th.data.fir_def_store}) | ||
| 3181 | - is_find_def_store = 1; | ||
| 3182 | - } | ||
| 3183 | - } | ||
| 3184 | - break; | ||
| 3185 | - } | ||
| 3186 | - } | ||
| 3187 | - } | ||
| 3188 | - | ||
| 3189 | - //数据组装下 | ||
| 3190 | - var em = {}; | ||
| 3191 | - em.data = {}; | ||
| 3192 | - em.data.data = {}; | ||
| 3193 | - em.data.data.total = new_list.length; | ||
| 3194 | - em.data.data.pageData = new_list; | ||
| 3195 | - em.data.data.pageData = new_list; | ||
| 3196 | - | ||
| 3197 | - //--如果找到默认门店,同时也应该判断配送方式对不对-- | ||
| 3198 | - if (th.data.fir_def_store && !is_find_def_store && th.data.fir_def_store.pickup_id && (g_distr_type == 0 || th.data.fir_def_store.distr_type == 0 || th.data.def_pick_store.distr_type == g_distr_type)) { | ||
| 3199 | - th.data.fir_def_store.CanOutQty = 0; | ||
| 3200 | - //--当选择的门店是客户默认的门店的时候-- | ||
| 3201 | - if (th.data.def_pick_store && th.data.fir_def_store.pickup_id == th.data.def_pick_store.pickup_id) { | ||
| 3202 | - th.setData({def_pick_store: th.data.fir_def_store}); | ||
| 3203 | - em.data.data.pageData.unshift(th.data.def_pick_store); | ||
| 3204 | - } else { | ||
| 3205 | - em.data.data.pageData.splice(1, 0, th.data.fir_def_store); | ||
| 3206 | - } | ||
| 3207 | - } | ||
| 3208 | - | ||
| 3209 | - //---把数组组装进去--- | ||
| 3210 | - th.deal_pickup(em); | ||
| 3211 | - } else { | ||
| 3212 | - th.setData({def_pick_store: null, all_sto: null, only_pk: null, def_pickpu_list: null}) | ||
| 3213 | - } | ||
| 3214 | - } else { | ||
| 3215 | - th.setData({def_pick_store: null, all_sto: null, only_pk: null, def_pickpu_list: null}) | ||
| 3216 | - } | ||
| 3217 | - }) | ||
| 3218 | - }, | ||
| 3219 | - | ||
| 3220 | - find_lock_num(pick_id, lock) { | ||
| 3221 | - var lock_num = 0; | ||
| 3222 | - if (!lock) return 0; | ||
| 3223 | - if (lock.length < 0) return 0; | ||
| 3224 | - for (var i in lock) { | ||
| 3225 | - if (pick_id == lock[i].pickupId) { | ||
| 3226 | - lock_num += lock[i].outQty; | ||
| 3227 | - } | ||
| 3228 | - } | ||
| 3229 | - return lock_num; | ||
| 3230 | - }, | ||
| 3231 | - | ||
| 3232 | - //----------取货门店被点击的效果------ | ||
| 3233 | - getmendian: function (t) { | ||
| 3234 | - this.setData({ | ||
| 3235 | - ismend: 1, | ||
| 3236 | - }); | ||
| 3237 | - }, | ||
| 3238 | - | ||
| 3239 | - //----------隐藏取货门店,选取门店---------- | ||
| 3240 | - hidemend: function (e) { | ||
| 3241 | - var pid = e.target.dataset.p_id; | ||
| 3242 | - var pname = e.target.dataset.p_name; | ||
| 3243 | - var p_distr_t = e.target.dataset.p_dis; | ||
| 3244 | - this.setData({ | ||
| 3245 | - ismend: 0, | ||
| 3246 | - is_sec_mend: 0, | ||
| 3247 | - sto_sele_id: pid, | ||
| 3248 | - sto_sele_name: pname, | ||
| 3249 | - sto_sele_distr: p_distr_t | ||
| 3250 | - }); | ||
| 3251 | - }, | ||
| 3252 | - | ||
| 3253 | - //------显示取货2级---------- | ||
| 3254 | - show_sec: function (t) { | ||
| 3255 | - var index = t.target.dataset.index; | ||
| 3256 | - var item = this.data.all_sto[index]; | ||
| 3257 | - this.setData({ | ||
| 3258 | - is_sec_mend: 1, | ||
| 3259 | - sec_sto: item | ||
| 3260 | - }); | ||
| 3261 | - }, | ||
| 3262 | - | ||
| 3263 | - //------隐藏取货门店2级---- | ||
| 3264 | - hide_sec_mend: function () { | ||
| 3265 | - this.setData({is_sec_mend: 0,}); | ||
| 3266 | - }, | ||
| 3267 | - | ||
| 3268 | - //评论的调用 | ||
| 3269 | - requestComments_new: async function () { | ||
| 3270 | - var e = this, th = e, ee = e; | ||
| 3271 | - var tp = e.data.activeCategoryId3; | ||
| 3272 | - var t = '/api/weshop/comment/pageComment?page=' + e.data.c_curr_p; | ||
| 3273 | - | ||
| 3274 | - wx.showLoading(); | ||
| 3275 | - var req_where = { | ||
| 3276 | - store_id: o.stoid, pageSize: 5, is_show: 1, | ||
| 3277 | - parent_id: 0, goods_id: th.data.gid, commenttype: tp, | ||
| 3278 | - } | ||
| 3279 | - if (getApp().globalData.userInfo) { | ||
| 3280 | - req_where.userId = getApp().globalData.user_id; | ||
| 3281 | - } | ||
| 3282 | - | ||
| 3283 | - var rs_data = null; | ||
| 3284 | - await getApp().request.promiseGet(t, {data: req_where}).then(res => { | ||
| 3285 | - var tot = res.data.data.total; | ||
| 3286 | - e.data.c_curr_p++; | ||
| 3287 | - e.setData({ | ||
| 3288 | - com_num: tot, //已经有加载 | ||
| 3289 | - }); | ||
| 3290 | - if (res.data.data && res.data.data.pageData && res.data.data.pageData.length > 0) { | ||
| 3291 | - rs_data = res.data.data.pageData; | ||
| 3292 | - } else { | ||
| 3293 | - th.setData({comments_no_more: 1, auto: 1}); | ||
| 3294 | - } | ||
| 3295 | - }) | ||
| 3296 | - | ||
| 3297 | - if (rs_data) { | ||
| 3298 | - //var cda = th.data.comments; | ||
| 3299 | - var cda = rs_data, com_data = th.data.comments; | ||
| 3300 | - for (var ind in cda) { | ||
| 3301 | - var ep = cda[ind]; | ||
| 3302 | - if (cda[ind].head_pic == '') { | ||
| 3303 | - cda[ind].head_pic = th.data.iurl + "/miniapp/images/hui_hear_pic.png"; | ||
| 3304 | - } | ||
| 3305 | - if (ep.weapp_img != "" && ut.isString(ep.weapp_img)) { | ||
| 3306 | - cda[ind].weapp_img = JSON.parse(ep.weapp_img); | ||
| 3307 | - } | ||
| 3308 | - if (ep.img != "" && ut.isString(ep.img)) { | ||
| 3309 | - cda[ind].img = ut.unserialize(ep.img); | ||
| 3310 | - } | ||
| 3311 | - | ||
| 3312 | - //--测量多有字的宽带,计算有多少行-- | ||
| 3313 | - var widh = ut.measureText(ep.content, 30); | ||
| 3314 | - var lines = widh / 712; | ||
| 3315 | - cda[ind].seeMore = false; | ||
| 3316 | - if (lines > 3) cda[ind].seeMore = true; | ||
| 3317 | - | ||
| 3318 | - await getApp().request.promiseGet("/api/weshop/comment/pageComment", { | ||
| 3319 | - data: {store_id: o.stoid, parent_id: ep.comment_id} | ||
| 3320 | - }).then(res => { | ||
| 3321 | - if (res.data.data.pageData && res.data.data.pageData.length > 0) { | ||
| 3322 | - cda[ind].replay_list = res.data.data.pageData; | ||
| 3323 | - } | ||
| 3324 | - }) | ||
| 3325 | - } | ||
| 3326 | - | ||
| 3327 | - if (!com_data) com_data = cda; | ||
| 3328 | - else com_data = com_data.concat(cda); | ||
| 3329 | - | ||
| 3330 | - th.setData({comments: com_data}); | ||
| 3331 | - } | ||
| 3332 | - th.setData({get_c: 1}); | ||
| 3333 | - wx.hideLoading(); | ||
| 3334 | - }, | ||
| 3335 | - | ||
| 3336 | - //加载更多是靠这个函数 | ||
| 3337 | - onReachBottom: function () { | ||
| 3338 | - if (this.data.activeCategoryId == 2) { | ||
| 3339 | - if (!this.data.comments_no_more) this.requestComments_new(); | ||
| 3340 | - } | ||
| 3341 | - | ||
| 3342 | - var goods_list = this.selectComponent("#goods_list"); //组件的id | ||
| 3343 | - if (goods_list) goods_list.get_list(); | ||
| 3344 | - }, | ||
| 3345 | - | ||
| 3346 | - //--------检查是否活动,活动是否开始,或者是否结束------- | ||
| 3347 | - async check_prom(gid, prom_type, prom_id) { | ||
| 3348 | - console.log('check_prom'); | ||
| 3349 | - var ee = this, th = ee; | ||
| 3350 | - var user_id = getApp().globalData.user_id; | ||
| 3351 | - if (!user_id) user_id = 0; | ||
| 3352 | - | ||
| 3353 | - if (prom_type == 3 || prom_type == 0 || prom_type == 5 || prom_type == 7 || prom_type == 9 || prom_type == 10) { | ||
| 3354 | - this.setData({ | ||
| 3355 | - prom_type: 0, isshow: 1, | ||
| 3356 | - }); | ||
| 3357 | - return false; | ||
| 3358 | - } | ||
| 3359 | - | ||
| 3360 | - if (prom_type == 2) { | ||
| 3361 | - //-------判断团购活动是否抢光--------- | ||
| 3362 | - await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + os.stoid + "/" + prom_type + "/" + prom_id, { | ||
| 3363 | - 1: 1 | ||
| 3364 | - }).then(res => { | ||
| 3365 | - var em = res; | ||
| 3366 | - if (em.data.code == 0) { | ||
| 3367 | - if (em.data.data <= 0) ee.setData({ | ||
| 3368 | - prom_r_null: 1 | ||
| 3369 | - }); | ||
| 3370 | - //拿取价格并且判断时间-- | ||
| 3371 | - getApp().request.get("/api/weshop/goods/groupBuy/getActInfo/" + os.stoid + "/" + gid + "/" + prom_id, { | ||
| 3372 | - success: function (t) { | ||
| 3373 | - if (t.data.code != 0) { | ||
| 3374 | - ee.get_normal(gid); | ||
| 3375 | - return false; | ||
| 3376 | - } | ||
| 3377 | - //----已经结束----- | ||
| 3378 | - if (t.data.data.is_end == 1) { | ||
| 3379 | - ee.get_normal(gid); | ||
| 3380 | - return false; | ||
| 3381 | - } | ||
| 3382 | - //----已经过期----- | ||
| 3383 | - var now = ut.gettimestamp(); | ||
| 3384 | - if (t.data.data.end_time < now || t.data.data.start_time > now) { | ||
| 3385 | - ee.get_normal(gid); | ||
| 3386 | - return false; | ||
| 3387 | - } | ||
| 3388 | - | ||
| 3389 | - /*-- 还没有开始预热的也不显示 --*/ | ||
| 3390 | - if (t.data.data.show_time > now) { | ||
| 3391 | - ee.get_normal(gid); | ||
| 3392 | - return false; | ||
| 3393 | - } | ||
| 3394 | - | ||
| 3395 | - var t_gd = ee.data.data; | ||
| 3396 | - var prom_end_time = ut.formatTime(t.data.data.end_time, "yyyy-MM-dd hh:mm:ss"); | ||
| 3397 | - var prom_start_time = ut.formatTime(t.data.data.start_time, "yyyy-MM-dd hh:mm:ss"); | ||
| 3398 | - | ||
| 3399 | - ee.setData({ | ||
| 3400 | - prom_price: t.data.data.price, | ||
| 3401 | - prom_type: 2, | ||
| 3402 | - prom_id: prom_id, | ||
| 3403 | - prom_buy_limit: t.data.data.buy_limit, | ||
| 3404 | - prom_act: t.data.data, | ||
| 3405 | - prom_end_time: prom_end_time, | ||
| 3406 | - prom_start_time: prom_start_time, | ||
| 3407 | - isshow: 1, | ||
| 3408 | - prom_act: t.data.data | ||
| 3409 | - }); | ||
| 3410 | - | ||
| 3411 | - ee.get_sto(); | ||
| 3412 | - var newTime = ut.gettimestamp(); | ||
| 3413 | - var endTime2 = t.data.data.end_time; | ||
| 3414 | - var endTime1 = t.data.data.start_time; | ||
| 3415 | - if (endTime1 > newTime) { | ||
| 3416 | - ee.setData({ | ||
| 3417 | - prom_time_text: '距团购开始还有' | ||
| 3418 | - }) | ||
| 3419 | - ee.countDown(endTime1, 0); | ||
| 3420 | - } else { | ||
| 3421 | - if (endTime2 > newTime) { | ||
| 3422 | - ee.setData({ | ||
| 3423 | - prom_time_text: '距团购结束还有', | ||
| 3424 | - prom_st: 1 | ||
| 3425 | - }) | ||
| 3426 | - ee.countDown(endTime2); | ||
| 3427 | - } | ||
| 3428 | - } | ||
| 3429 | - | ||
| 3430 | - } | ||
| 3431 | - }); | ||
| 3432 | - } | ||
| 3433 | - }) | ||
| 3434 | - } | ||
| 3435 | - | ||
| 3436 | - if (prom_type == 1 && prom_id == 0) { | ||
| 3437 | - this.setData({ | ||
| 3438 | - prom_type: 0, isshow: 1, | ||
| 3439 | - }); | ||
| 3440 | - | ||
| 3441 | - //获取门店 | ||
| 3442 | - this.get_sto(); | ||
| 3443 | - this.get_sku(o.stoid, this.data.data, gid); | ||
| 3444 | - this.check_has_flash(); | ||
| 3445 | - this.data.is_normal = 1; | ||
| 3446 | - this.check_is_youhui(gid, 1); | ||
| 3447 | - return false; | ||
| 3448 | - } | ||
| 3449 | - | ||
| 3450 | - //if (prom_type != 3 && prom_type!=0){ | ||
| 3451 | - //---判断秒杀---- | ||
| 3452 | - if (prom_type == 1 && prom_id > 0) { | ||
| 3453 | - //-------判断活动是否抢光--------- | ||
| 3454 | - await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + os.stoid + "/" + prom_type + "/" + prom_id, { | ||
| 3455 | - 1: 1 | ||
| 3456 | - }).then(res => { | ||
| 3457 | - var em = res; | ||
| 3458 | - if (em.data.code == 0) { | ||
| 3459 | - | ||
| 3460 | - if (em.data.data <= 0) ee.setData({ | ||
| 3461 | - prom_r_null: 1 | ||
| 3462 | - }); | ||
| 3463 | - //拿取价格并且判断时间-- | ||
| 3464 | - getApp().request.get("/api/ms/flash_sale/getNew/" + os.stoid + "/" + user_id + "/" + prom_id, { | ||
| 3465 | - success: function (t) { | ||
| 3466 | - if (t.data.code != 0) { | ||
| 3467 | - ee.get_normal(gid); | ||
| 3468 | - return false; | ||
| 3469 | - } | ||
| 3470 | - //----已经结束----- | ||
| 3471 | - if (t.data.data.is_end == 1) { | ||
| 3472 | - ee.get_normal(gid); | ||
| 3473 | - return false; | ||
| 3474 | - } | ||
| 3475 | - //----已经过期----- | ||
| 3476 | - var now = ut.gettimestamp(); | ||
| 3477 | - if (t.data.data.end_time < now) { | ||
| 3478 | - ee.get_normal(gid); | ||
| 3479 | - return false; | ||
| 3480 | - } | ||
| 3481 | - /*-- 还没有开始预热的也不显示 --*/ | ||
| 3482 | - if (t.data.data.show_time > now) { | ||
| 3483 | - ee.get_normal(gid); | ||
| 3484 | - return false; | ||
| 3485 | - } | ||
| 3486 | - | ||
| 3487 | - var t_gd = ee.data.data; | ||
| 3488 | - var prom_end_time = ut.formatTime(t.data.data.end_time, "yyyy-MM-dd hh:mm:ss"); | ||
| 3489 | - var prom_start_time = ut.formatTime(t.data.data.start_time, "yyyy-MM-dd hh:mm:ss"); | ||
| 3490 | - | ||
| 3491 | - ee.setData({ | ||
| 3492 | - prom_price: t.data.data.user_price, | ||
| 3493 | - prom_type: 1, | ||
| 3494 | - prom_id: prom_id, | ||
| 3495 | - prom_buy_limit: t.data.data.buy_limit, | ||
| 3496 | - prom_act: t.data.data, | ||
| 3497 | - prom_end_time: prom_end_time, | ||
| 3498 | - prom_start_time: prom_start_time, | ||
| 3499 | - isshow: 1, | ||
| 3500 | - }); | ||
| 3501 | - | ||
| 3502 | - ee.get_sto(); | ||
| 3503 | - var newTime = ut.gettimestamp(); | ||
| 3504 | - var endTime2 = t.data.data.end_time; | ||
| 3505 | - var endTime1 = t.data.data.start_time; | ||
| 3506 | - if (endTime1 > newTime) { | ||
| 3507 | - ee.setData({ | ||
| 3508 | - prom_time_text: '距秒杀开始还有' | ||
| 3509 | - }) | ||
| 3510 | - ee.countDown(endTime1, 0); | ||
| 3511 | - } else { | ||
| 3512 | - if (endTime2 > newTime) { | ||
| 3513 | - ee.setData({ | ||
| 3514 | - prom_time_text: '距秒杀结束还有', | ||
| 3515 | - prom_st: 1 | ||
| 3516 | - }) | ||
| 3517 | - ee.countDown(endTime2); | ||
| 3518 | - } | ||
| 3519 | - } | ||
| 3520 | - | ||
| 3521 | - //如果是进行中的话 | ||
| 3522 | - if (endTime1 < newTime) { | ||
| 3523 | - //-- 获取秒杀活动的多少规格 -- | ||
| 3524 | - ee.get_more_flahs(function (list) { | ||
| 3525 | - if (list && list.length > 1) { | ||
| 3526 | - | ||
| 3527 | - var n_item = list[0]; | ||
| 3528 | - var ind = list.findIndex(function (ele) { | ||
| 3529 | - return ele.goods_id == ee.data.data.goods_id; | ||
| 3530 | - }) | ||
| 3531 | - if (ind < 0) return false; | ||
| 3532 | - if (ind > 0) { | ||
| 3533 | - n_item = JSON.parse(JSON.stringify(list[ind])); | ||
| 3534 | - list.splice(ind, 1); | ||
| 3535 | - list.unshift(n_item); | ||
| 3536 | - } | ||
| 3537 | - | ||
| 3538 | - ee.data.sele_g.viplimited = n_item.viplimited; | ||
| 3539 | - ee.data.data.viplimited = n_item.viplimited; | ||
| 3540 | - | ||
| 3541 | - var gb = 1; | ||
| 3542 | - //-- 显示多规格 -- | ||
| 3543 | - for (let i in list) { | ||
| 3544 | - let item = list[i]; | ||
| 3545 | - var gg = ""; | ||
| 3546 | - if (item.goods_spec == "null" || item.goods_spec == null) item.goods_spec = ""; | ||
| 3547 | - if (item.goods_color == "null" || item.goods_color == null) item.goods_color = ""; | ||
| 3548 | - | ||
| 3549 | - if (item.goods_spec != "" && item.goods_color != "") { | ||
| 3550 | - gg = item.goods_spec + "/" + item.goods_color; | ||
| 3551 | - } else if (item.goods_spec != "" || item.goods_color != "") { | ||
| 3552 | - gg = item.goods_spec + item.goods_color; | ||
| 3553 | - } else { | ||
| 3554 | - gg = "规格" + gb; | ||
| 3555 | - gb++; | ||
| 3556 | - } | ||
| 3557 | - item.gg = gg; | ||
| 3558 | - item.prom_id = item.prom_id; | ||
| 3559 | - item.prom_type = 1; | ||
| 3560 | - } | ||
| 3561 | - | ||
| 3562 | - ee.setData({ | ||
| 3563 | - sku_g: list, | ||
| 3564 | - }); | ||
| 3565 | - | ||
| 3566 | - } | ||
| 3567 | - }) | ||
| 3568 | - } | ||
| 3569 | - | ||
| 3570 | - } | ||
| 3571 | - }); | ||
| 3572 | - } | ||
| 3573 | - }) | ||
| 3574 | - } | ||
| 3575 | - | ||
| 3576 | - if (prom_type == 4) { | ||
| 3577 | - //th.setData({is_integral_normal:1}); | ||
| 3578 | - var rdata = { | ||
| 3579 | - store_id: o.stoid, stype: 1, stypeup: 1, goods_id: gid | ||
| 3580 | - } | ||
| 3581 | - | ||
| 3582 | - var integrals = 0; | ||
| 3583 | - var get_datas = { | ||
| 3584 | - user_id: getApp().globalData.user_id, store_id: o.stoid, | ||
| 3585 | - }; | ||
| 3586 | - await getApp().request.promiseGet("/api/weshop/users/getAllPoints", { | ||
| 3587 | - data: get_datas | ||
| 3588 | - }).then(res => { | ||
| 3589 | - if (res.data.code == 0) { | ||
| 3590 | - integrals = res.data.data?.Integral?res.data.data?.Integral:0; | ||
| 3591 | - } | ||
| 3592 | - }) | ||
| 3593 | - | ||
| 3594 | - //获取一下积分活动 | ||
| 3595 | - await getApp().request.promiseGet("/api/weshop/integralbuy/pageIntegralBuyGoodsList", { | ||
| 3596 | - data: rdata | ||
| 3597 | - }).then(res => { | ||
| 3598 | - //调用接口有数据的时候 | ||
| 3599 | - if (res.data.code == 0 && res.data.data && res.data.data.pageData && res.data.data.pageData.length > 0) { | ||
| 3600 | - var inte_data = res.data.data.pageData[0]; | ||
| 3601 | - var can_integral = (parseFloat(integrals) >= parseFloat(inte_data.integral)); | ||
| 3602 | - ee.setData({ | ||
| 3603 | - prom_price: parseFloat(inte_data.addmoney), | ||
| 3604 | - prom_integral: parseFloat(inte_data.integral), | ||
| 3605 | - prom_type: 4, | ||
| 3606 | - prom_id: inte_data.id, | ||
| 3607 | - prom_buy_limit: inte_data.limitvipqty, | ||
| 3608 | - prom_act: inte_data, | ||
| 3609 | - isshow: 1, | ||
| 3610 | - can_integral: can_integral, | ||
| 3611 | - is_shopbuy: parseInt(inte_data.is_shopbuy ? inte_data.is_shopbuy : 0) | ||
| 3612 | - }); | ||
| 3613 | - ee.get_sto(); | ||
| 3614 | - | ||
| 3615 | - } else { | ||
| 3616 | - ee.get_normal(gid); | ||
| 3617 | - return false; | ||
| 3618 | - } | ||
| 3619 | - }) | ||
| 3620 | - | ||
| 3621 | - } | ||
| 3622 | - | ||
| 3623 | - //---判断拼单---- | ||
| 3624 | - if (prom_type == 6) { | ||
| 3625 | - //-------判断活动是否抢光--------- | ||
| 3626 | - await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + os.stoid + "/" + prom_type + "/" + prom_id, { | ||
| 3627 | - 1: 1 | ||
| 3628 | - }).then(res => { | ||
| 3629 | - var em = res; | ||
| 3630 | - var flag = null; | ||
| 3631 | - if (em.data.code == 0) { | ||
| 3632 | - if (em.data.data <= 0) ee.setData({ | ||
| 3633 | - prom_r_null: 1 | ||
| 3634 | - }); | ||
| 3635 | - //拿取价格并且判断时间-- | ||
| 3636 | - getApp().request.get("/api/weshop/teamlist/get/" + | ||
| 3637 | - os.stoid + "/" + prom_id, { | ||
| 3638 | - success: async function (t) { | ||
| 3639 | - if (t.data.code != 0) { | ||
| 3640 | - ee.get_normal(gid); | ||
| 3641 | - return false; | ||
| 3642 | - } | ||
| 3643 | - //----已经结束----- | ||
| 3644 | - if (t.data.data.is_end == 1) { | ||
| 3645 | - ee.get_normal(gid); | ||
| 3646 | - return false; | ||
| 3647 | - } | ||
| 3648 | - //----已经过期----- | ||
| 3649 | - var now = ut.gettimestamp(); | ||
| 3650 | - if (t.data.data.end_time < now) { | ||
| 3651 | - ee.get_normal(gid); | ||
| 3652 | - return false; | ||
| 3653 | - } | ||
| 3654 | - | ||
| 3655 | - /*-- 还没有开始预热的也不显示 --*/ | ||
| 3656 | - if (t.data.data.show_time > now) { | ||
| 3657 | - ee.get_normal(gid); | ||
| 3658 | - return false; | ||
| 3659 | - } | ||
| 3660 | - | ||
| 3661 | - /*-- 判断拼单是否启用 --*/ | ||
| 3662 | - if (!t.data.data.is_show) { | ||
| 3663 | - console.log('没启用'); | ||
| 3664 | - wx.setNavigationBarTitle({ | ||
| 3665 | - title: '系统提示', | ||
| 3666 | - }); | ||
| 3667 | - wx.showToast({ | ||
| 3668 | - title: '此商品暂时没有拼单活动', | ||
| 3669 | - icon: 'none', | ||
| 3670 | - success(){ | ||
| 3671 | - setTimeout(() => { | ||
| 3672 | - wx.navigateBack() | ||
| 3673 | - }, 2000) | ||
| 3674 | - } | ||
| 3675 | - }); | ||
| 3676 | - return false | ||
| 3677 | - } | ||
| 3678 | - | ||
| 3679 | - //判断拼团的---会员身份-- | ||
| 3680 | - await getApp().request.promiseGet("/api/weshop/teamlist/pageteam/2", { | ||
| 3681 | - data: { | ||
| 3682 | - store_id: os.stoid, | ||
| 3683 | - is_end: 0, | ||
| 3684 | - is_show: 1, | ||
| 3685 | - user_id: getApp().globalData.user_id, | ||
| 3686 | - pageSize: 1000 | ||
| 3687 | - } | ||
| 3688 | - }).then(res => { | ||
| 3689 | - let pd_list = res.data.data.pageData; | ||
| 3690 | - if (res.data.code == 0 && pd_list.length > 0) { | ||
| 3691 | - flag = pd_list.some(pd => { | ||
| 3692 | - return pd.goods_id == gid | ||
| 3693 | - }) | ||
| 3694 | - } | ||
| 3695 | - }) | ||
| 3696 | - if (!flag) { | ||
| 3697 | - ee.get_normal(gid); | ||
| 3698 | - return false; | ||
| 3699 | - | ||
| 3700 | - } | ||
| 3701 | - //-------查看自己是不是有买过该团的商品,并还为支付,或者在进行中------- | ||
| 3702 | - await getApp().request.promiseGet("/api/weshop/order/page", { | ||
| 3703 | - data: { | ||
| 3704 | - pt_prom_id: prom_id, | ||
| 3705 | - user_id: oo.user_id, | ||
| 3706 | - store_id: os.stoid, | ||
| 3707 | - pageSize: 1, | ||
| 3708 | - page: 1 | ||
| 3709 | - } | ||
| 3710 | - }).then(e => { | ||
| 3711 | - if (e.data.code == 0 && e.data.data.pageData.length > 0) { | ||
| 3712 | - var odr = e.data.data.pageData[0]; | ||
| 3713 | - th.data.buy_order = odr; | ||
| 3714 | - if (odr.pt_status == 0 && odr.order_status == 1) { | ||
| 3715 | - th.setData({ | ||
| 3716 | - user_order_pt_state: 1 | ||
| 3717 | - }); | ||
| 3718 | - } | ||
| 3719 | - if (odr.pt_status == 1 && odr.order_status == 1) { | ||
| 3720 | - if (odr.is_zsorder == 4) { | ||
| 3721 | - getApp().request.promiseGet("/api/weshop/teamgroup/page/", { | ||
| 3722 | - data: { | ||
| 3723 | - store_id: os.stoid, | ||
| 3724 | - team_id: odr.pt_prom_id, | ||
| 3725 | - listno: odr.pt_listno | ||
| 3726 | - } | ||
| 3727 | - }).then(res => { | ||
| 3728 | - var now = ut.gettimestamp(); | ||
| 3729 | - if (res.data.code == 0 && res.data.data && res.data.data.pageData && res.data.data.pageData.length > 0) { | ||
| 3730 | - var tgr = res.data.data.pageData[0]; | ||
| 3731 | - //如果团的时间已经到了 | ||
| 3732 | - if (now >= tgr.kt_end_time) { | ||
| 3733 | - th.update_jiti(tgr.id); | ||
| 3734 | - } else { | ||
| 3735 | - th.setData({ | ||
| 3736 | - user_order_pt_state: 2 | ||
| 3737 | - }); | ||
| 3738 | - } | ||
| 3739 | - } | ||
| 3740 | - }) | ||
| 3741 | - | ||
| 3742 | - } else { | ||
| 3743 | - th.setData({ | ||
| 3744 | - user_order_pt_state: 2 | ||
| 3745 | - }); | ||
| 3746 | - } | ||
| 3747 | - } | ||
| 3748 | - | ||
| 3749 | - if (odr.pt_status == 2 && odr.is_zsorder == 4) { | ||
| 3750 | - th.setData({ | ||
| 3751 | - user_order_pt_state: 3, | ||
| 3752 | - }); | ||
| 3753 | - th.data.wk_order_id = odr.order_id; | ||
| 3754 | - } | ||
| 3755 | - } | ||
| 3756 | - }) | ||
| 3757 | - | ||
| 3758 | - //----------查看阶梯团------------ | ||
| 3759 | - if (t.data.data.ct_rylist != "null" && t.data.data.ct_rylist != "" && t.data.data.ct_rylist != null && t.data.data.ct_rylist != undefined) { | ||
| 3760 | - t.data.data.ct_rylist = JSON.parse(t.data.data.ct_rylist); | ||
| 3761 | - var max_num = 0; | ||
| 3762 | - t.data.data.ct_rylist.forEach(function (val, ind) { | ||
| 3763 | - if (parseInt(val.rynum) > max_num) max_num = parseInt(val.rynum); | ||
| 3764 | - }) | ||
| 3765 | - t.data.data.max_ct_num = max_num; | ||
| 3766 | - } | ||
| 3767 | - | ||
| 3768 | - var prom_end_time = ut.formatTime(t.data.data.end_time, "yyyy-MM-dd hh:mm:ss"); | ||
| 3769 | - var prom_start_time = ut.formatTime(t.data.data.start_time, "yyyy-MM-dd hh:mm:ss"); | ||
| 3770 | - ee.setData({ | ||
| 3771 | - prom_price: t.data.data.price, | ||
| 3772 | - prom_type: 6, | ||
| 3773 | - prom_id: prom_id, | ||
| 3774 | - prom_buy_limit: t.data.data.buy_limit, | ||
| 3775 | - prom_act: t.data.data, | ||
| 3776 | - prom_end_time: prom_end_time, | ||
| 3777 | - prom_start_time: prom_start_time, | ||
| 3778 | - isshow: 1, | ||
| 3779 | - }); | ||
| 3780 | - | ||
| 3781 | - ee.get_sto(); | ||
| 3782 | - | ||
| 3783 | - var newTime = now; | ||
| 3784 | - var endTime2 = t.data.data.end_time; | ||
| 3785 | - var endTime1 = t.data.data.start_time; | ||
| 3786 | - | ||
| 3787 | - if (endTime1 > newTime) { | ||
| 3788 | - ee.setData({ | ||
| 3789 | - prom_time_text: '距拼单开始还剩:' | ||
| 3790 | - }) | ||
| 3791 | - ee.countDown(endTime1, 0); | ||
| 3792 | - } else { | ||
| 3793 | - if (endTime2 > newTime) { | ||
| 3794 | - ee.setData({ | ||
| 3795 | - prom_time_text: '距拼单结束还剩:', | ||
| 3796 | - prom_st: 1 | ||
| 3797 | - }) | ||
| 3798 | - ee.countDown(endTime2); | ||
| 3799 | - } | ||
| 3800 | - } | ||
| 3801 | - //-------查看有多少人在开这个团------- | ||
| 3802 | - th.get_team_group(prom_id); | ||
| 3803 | - } | ||
| 3804 | - }); | ||
| 3805 | - } | ||
| 3806 | - }) | ||
| 3807 | - } | ||
| 3808 | - }, | ||
| 3809 | - | ||
| 3810 | - //--获取有多少人在开团-- | ||
| 3811 | - async get_team_group(prom_id) { | ||
| 3812 | - var teamgroup = [], | ||
| 3813 | - th = this, | ||
| 3814 | - grounp_tatal = 0; | ||
| 3815 | - //如果活动是开团不是商家团 | ||
| 3816 | - if (this.data.prom_act.kttype > 1) { | ||
| 3817 | - | ||
| 3818 | - var req_data = { | ||
| 3819 | - store_id: os.stoid, | ||
| 3820 | - pageSize: 3, | ||
| 3821 | - page: 1, | ||
| 3822 | - state: 2, | ||
| 3823 | - team_id: prom_id, | ||
| 3824 | - ordernum: 1 | ||
| 3825 | - }; | ||
| 3826 | - | ||
| 3827 | - if (this.data.prom_act.kttype == 3 && this.data.prom_act.max_ct_num) { | ||
| 3828 | - req_data.max_num = this.data.prom_act.max_ct_num; | ||
| 3829 | - } | ||
| 3830 | - | ||
| 3831 | - //获取活动从表信息team_id | ||
| 3832 | - await getApp().request.promiseGet("/api/weshop/teamgroup/page", { | ||
| 3833 | - data: req_data | ||
| 3834 | - }).then(res => { | ||
| 3835 | - teamgroup = res.data.data.pageData; | ||
| 3836 | - grounp_tatal = res.data.data.total; | ||
| 3837 | - }) | ||
| 3838 | - //获取订单的总数这个接口不能用 | ||
| 3839 | - for (i = 0; i < teamgroup.length; i++) { | ||
| 3840 | - await getApp().request.promiseGet("/api/weshop/order/page", { | ||
| 3841 | - data: { | ||
| 3842 | - store_id: os.stoid, | ||
| 3843 | - pt_status: 1, | ||
| 3844 | - pt_listno: teamgroup[i].listno | ||
| 3845 | - } | ||
| 3846 | - }).then(res => { | ||
| 3847 | - var order = res.data.data.pageData; | ||
| 3848 | - teamgroup[i].open_num = order.length; | ||
| 3849 | - }) | ||
| 3850 | - await getApp().request.promiseGet("/api/weshop/users/get/" + os.stoid + "/" + teamgroup[i].openvipid, {}).then(res => { | ||
| 3851 | - var user = res.data.data; | ||
| 3852 | - teamgroup[i].user = user; | ||
| 3853 | - }) | ||
| 3854 | - } | ||
| 3855 | - | ||
| 3856 | - if (teamgroup.length > 0) { | ||
| 3857 | - th.setData({ | ||
| 3858 | - teamgroup: teamgroup, | ||
| 3859 | - grounp_tatal: grounp_tatal | ||
| 3860 | - }); | ||
| 3861 | - th.countDown2(); | ||
| 3862 | - } | ||
| 3863 | - } | ||
| 3864 | - }, | ||
| 3865 | - | ||
| 3866 | - //---小于10的格式化函数---- | ||
| 3867 | - timeFormat(param) { | ||
| 3868 | - return param < 10 ? '0' + param : param; | ||
| 3869 | - }, | ||
| 3870 | - | ||
| 3871 | - // 显示拼单规则 | ||
| 3872 | - showRules: function() { | ||
| 3873 | - this.setData({ | ||
| 3874 | - showRules: true, | ||
| 3875 | - }); | ||
| 3876 | - }, | ||
| 3877 | - | ||
| 3878 | - // 关闭拼单规则 | ||
| 3879 | - closeRules: function() { | ||
| 3880 | - this.setData({ | ||
| 3881 | - showRules: false, | ||
| 3882 | - }); | ||
| 3883 | - }, | ||
| 3884 | - | ||
| 3885 | - //----倒计时函数----- | ||
| 3886 | - countDown(time, prom_st) { | ||
| 3887 | - if (!this.data.is_timer) return false; | ||
| 3888 | - var th = this; | ||
| 3889 | - // 获取当前时间,同时得到活动结束时间数组 | ||
| 3890 | - var endTime = time; | ||
| 3891 | - var newTime = ut.gettimestamp(); | ||
| 3892 | - // 对结束时间进行处理渲染到页面 | ||
| 3893 | - var obj = null; | ||
| 3894 | - // 如果活动未结束,对时间进行处理 | ||
| 3895 | - if (endTime - newTime > 0) { | ||
| 3896 | - var time = (endTime - newTime); | ||
| 3897 | - // 获取天、时、分、秒 | ||
| 3898 | - var day = parseInt(time / (60 * 60 * 24)); | ||
| 3899 | - var hou = parseInt(time % (60 * 60 * 24) / 3600); | ||
| 3900 | - var min = parseInt(time % (60 * 60 * 24) % 3600 / 60); | ||
| 3901 | - var sec = parseInt(time % (60 * 60 * 24) % 3600 % 60); | ||
| 3902 | - obj = { | ||
| 3903 | - day: this.timeFormat(day), | ||
| 3904 | - hou: this.timeFormat(hou), | ||
| 3905 | - min: this.timeFormat(min), | ||
| 3906 | - sec: this.timeFormat(sec) | ||
| 3907 | - } | ||
| 3908 | - } else { | ||
| 3909 | - if (th.data.prom_st == 0) { | ||
| 3910 | - //var endTime2 = new Date(th.data.prom_end_time).getTime(); | ||
| 3911 | - var endTime2 = th.data.prom_act.end_time; | ||
| 3912 | - th.setData({ | ||
| 3913 | - prom_time_text: '距结束还剩:', | ||
| 3914 | - prom_st: 1 | ||
| 3915 | - }) | ||
| 3916 | - setTimeout(function () { | ||
| 3917 | - th.countDown(endTime2) | ||
| 3918 | - }, 1000); | ||
| 3919 | - return false; | ||
| 3920 | - | ||
| 3921 | - } else { | ||
| 3922 | - //活动已结束,全部设置为'00' | ||
| 3923 | - obj = { | ||
| 3924 | - day: '00', | ||
| 3925 | - hou: '00', | ||
| 3926 | - min: '00', | ||
| 3927 | - sec: '00' | ||
| 3928 | - } | ||
| 3929 | - th.setData({ | ||
| 3930 | - prom_time_text: '活动已经结束:', | ||
| 3931 | - prom_st: 3 | ||
| 3932 | - }) | ||
| 3933 | - th.setData({ | ||
| 3934 | - djs: obj | ||
| 3935 | - }); | ||
| 3936 | - return false; | ||
| 3937 | - } | ||
| 3938 | - } | ||
| 3939 | - | ||
| 3940 | - th.setData({ | ||
| 3941 | - djs: obj | ||
| 3942 | - }); | ||
| 3943 | - setTimeout(function () { | ||
| 3944 | - th.countDown(endTime) | ||
| 3945 | - }, 1000); | ||
| 3946 | - }, | ||
| 3947 | - | ||
| 3948 | - | ||
| 3949 | - //-------------获取购买数量的总函数---------------- | ||
| 3950 | - get_buy_num: function (gd, func) { | ||
| 3951 | - var map = this.data.g_buy_num, | ||
| 3952 | - th = this, | ||
| 3953 | - user_id = getApp().globalData.user_id; | ||
| 3954 | - if (user_id == null) { | ||
| 3955 | - map.set(gd.goods_id, 0); | ||
| 3956 | - th.setData({ | ||
| 3957 | - g_buy_num: map, | ||
| 3958 | - prom_buy_num: 0, | ||
| 3959 | - }); | ||
| 3960 | - "function" == typeof func && func(); | ||
| 3961 | - return false; | ||
| 3962 | - } | ||
| 3963 | - | ||
| 3964 | - if (map.has(gd.goods_id)) { | ||
| 3965 | - "function" == typeof func && func(); | ||
| 3966 | - } else { | ||
| 3967 | - //----获取商品购买数---- | ||
| 3968 | - getApp().request.get("/api/weshop/ordergoods/getUserBuyGoodsNum", { | ||
| 3969 | - data: { | ||
| 3970 | - store_id: os.stoid, | ||
| 3971 | - user_id: user_id, | ||
| 3972 | - goods_id: gd.goods_id | ||
| 3973 | - }, | ||
| 3974 | - success: function (t) { | ||
| 3975 | - if (t.data.code == 0) { | ||
| 3976 | - var g_buy_num = t.data.data.goodsbuynum; | ||
| 3977 | - | ||
| 3978 | - //如果是秒杀的时候 | ||
| 3979 | - if (th.data.prom_type == 0 && gd.prom_type == 1) { | ||
| 3980 | - gd.prom_type = 0; | ||
| 3981 | - } | ||
| 3982 | - //如果全场优惠,商品做了秒杀 | ||
| 3983 | - if (th.data.prom_type == 3 && gd.prom_type == 1) { | ||
| 3984 | - gd.prom_type = 0; | ||
| 3985 | - } | ||
| 3986 | - //如果全场阶梯优惠,商品做了秒杀 | ||
| 3987 | - if (th.data.prom_type == 10 && gd.prom_type == 1) { | ||
| 3988 | - gd.prom_type = 0; | ||
| 3989 | - } | ||
| 3990 | - | ||
| 3991 | - | ||
| 3992 | - if (!th.data.is_normal && ( gd.prom_type == 1 || gd.prom_type == 2 || gd.prom_type == 4 || gd.prom_type == 6)) { | ||
| 3993 | - //----获取活动购买数---- | ||
| 3994 | - getApp().request.get("/api/weshop/ordergoods/getUserBuyGoodsNum", { | ||
| 3995 | - data: { | ||
| 3996 | - store_id: os.stoid, | ||
| 3997 | - user_id: user_id, | ||
| 3998 | - goods_id: gd.goods_id, | ||
| 3999 | - prom_type: gd.prom_type, | ||
| 4000 | - prom_id: gd.prom_id | ||
| 4001 | - }, | ||
| 4002 | - //-----获取----- | ||
| 4003 | - success: function (tt) { | ||
| 4004 | - if (tt.data.code == 0) { | ||
| 4005 | - map.set(gd.goods_id, g_buy_num); | ||
| 4006 | - th.setData({ | ||
| 4007 | - g_buy_num: map, | ||
| 4008 | - prom_buy_num: tt.data.data.promgoodsbuynum, | ||
| 4009 | - }); | ||
| 4010 | - "function" == typeof func && func(); | ||
| 4011 | - } | ||
| 4012 | - } | ||
| 4013 | - }); | ||
| 4014 | - } else { | ||
| 4015 | - map.set(gd.goods_id, g_buy_num); | ||
| 4016 | - th.setData({ | ||
| 4017 | - g_buy_num: map | ||
| 4018 | - }); | ||
| 4019 | - "function" == typeof func && func(); | ||
| 4020 | - } | ||
| 4021 | - } | ||
| 4022 | - } | ||
| 4023 | - }); | ||
| 4024 | - } | ||
| 4025 | - }, | ||
| 4026 | - | ||
| 4027 | - //--拼单推荐的显示--- | ||
| 4028 | - tj_Click: function (e) { | ||
| 4029 | - var ind = parseInt(e.target.dataset.ind); | ||
| 4030 | - this.setData({ | ||
| 4031 | - is_show_gz: ind | ||
| 4032 | - }); | ||
| 4033 | - }, | ||
| 4034 | - | ||
| 4035 | - //--------拼团玩法显示详情-------- | ||
| 4036 | - show_pt_xx: function (e) { | ||
| 4037 | - this.setData({ | ||
| 4038 | - pd_xx: 1, | ||
| 4039 | - }) | ||
| 4040 | - }, | ||
| 4041 | - close_pt_xx: function () { | ||
| 4042 | - this.setData({ | ||
| 4043 | - pd_xx: 0, | ||
| 4044 | - }) | ||
| 4045 | - }, | ||
| 4046 | - | ||
| 4047 | - //--点击弹起拼单-- | ||
| 4048 | - openSpecModel_pt: function (e) { | ||
| 4049 | - | ||
| 4050 | - | ||
| 4051 | - this.setData({open_ind_store: 4, goodsInputNum: 1});//拼团直接给4 | ||
| 4052 | - | ||
| 4053 | - | ||
| 4054 | - //--先判断会员状态-- | ||
| 4055 | - var user_info = getApp().globalData.userInfo; | ||
| 4056 | - if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { | ||
| 4057 | - wx.navigateTo({ | ||
| 4058 | - url: '/pages/togoin/togoin', | ||
| 4059 | - }) | ||
| 4060 | - return false; | ||
| 4061 | - } | ||
| 4062 | - | ||
| 4063 | - var th = this; | ||
| 4064 | - var ind = parseInt(e.currentTarget.dataset.it); | ||
| 4065 | - | ||
| 4066 | - //如果是拼单活动的普通购买 | ||
| 4067 | - if (ind == 1) { | ||
| 4068 | - | ||
| 4069 | - if (!th.data.is_normal) { | ||
| 4070 | - th.data.g_buy_num = new Map(); | ||
| 4071 | - } | ||
| 4072 | - | ||
| 4073 | - //如果拼单的sku data是空的,就要先获取一下 | ||
| 4074 | - if (th.data.sku_g_pt) { | ||
| 4075 | - th.get_sto(1); | ||
| 4076 | - th.setData({ | ||
| 4077 | - is_normal: ind, | ||
| 4078 | - openSpecModal_pt: 1 | ||
| 4079 | - }); | ||
| 4080 | - } else { | ||
| 4081 | - th.get_sto(1); | ||
| 4082 | - th.get_sku(o.stoid, th.data.data, th.data.gid, 1, function () { | ||
| 4083 | - th.setData({ | ||
| 4084 | - is_normal: ind, | ||
| 4085 | - openSpecModal_pt: 1 | ||
| 4086 | - }); | ||
| 4087 | - }); | ||
| 4088 | - } | ||
| 4089 | - th.check_is_youhui(th.data.gid, 1); | ||
| 4090 | - } else { | ||
| 4091 | - | ||
| 4092 | - if (th.data.is_normal) { | ||
| 4093 | - th.data.g_buy_num = new Map(); | ||
| 4094 | - } | ||
| 4095 | - | ||
| 4096 | - //拼单商品从这里进,先判断有没有买过商品, | ||
| 4097 | - getApp().request.get("/api/weshop/order/page", { | ||
| 4098 | - data: { | ||
| 4099 | - pt_prom_id: th.data.prom_act.id, | ||
| 4100 | - user_id: oo.user_id, | ||
| 4101 | - store_id: os.stoid, | ||
| 4102 | - pageSize: 1, | ||
| 4103 | - page: 1 | ||
| 4104 | - }, | ||
| 4105 | - success: function (e) { | ||
| 4106 | - //--跳转到已经购买的情况-- | ||
| 4107 | - if (e.data.data.pageData.length > 0) { | ||
| 4108 | - var odr = e.data.data.pageData[0]; | ||
| 4109 | - //还未支付 | ||
| 4110 | - if (odr.pt_status == 0 && (odr.order_status == 1 || odr.order_status == 0)) { | ||
| 4111 | - wx.showModal({ | ||
| 4112 | - title: "您已经购买了该商品待支付中", | ||
| 4113 | - success: function (a) { | ||
| 4114 | - if (a.confirm) { | ||
| 4115 | - wx.navigateTo({ | ||
| 4116 | - url: "/pages/user/order_detail/order_detail?order_id=" + odr.order_id, | ||
| 4117 | - }); | ||
| 4118 | - } | ||
| 4119 | - } | ||
| 4120 | - }); | ||
| 4121 | - } else if (odr.pt_status == 1 && odr.order_status == 1) { | ||
| 4122 | - | ||
| 4123 | - if (this.data.is_go_to_team_show) return false; | ||
| 4124 | - this.data.is_go_to_team_show = 1; | ||
| 4125 | - wx.showLoading(); | ||
| 4126 | - | ||
| 4127 | - /*--- | ||
| 4128 | - wx.redirectTo({ | ||
| 4129 | - url: "/pages/team/team_success/team_success?ordersn=" + odr.order_sn, | ||
| 4130 | - });--*/ | ||
| 4131 | - getApp().goto("/pages/team/team_success/team_success?ordersn=" + odr.order_sn); | ||
| 4132 | - | ||
| 4133 | - } else { | ||
| 4134 | - th.setData({ | ||
| 4135 | - is_normal: ind, | ||
| 4136 | - openSpecModal_pt: 1 | ||
| 4137 | - }); | ||
| 4138 | - } | ||
| 4139 | - } | ||
| 4140 | - else { | ||
| 4141 | - th.setData({ | ||
| 4142 | - is_normal: ind, | ||
| 4143 | - openSpecModal_pt: 1 | ||
| 4144 | - }); | ||
| 4145 | - } | ||
| 4146 | - } | ||
| 4147 | - }) | ||
| 4148 | - } | ||
| 4149 | - }, | ||
| 4150 | - | ||
| 4151 | - //-----------------拼单生成方法--------------------- | ||
| 4152 | - addCart_pt: function () { | ||
| 4153 | - var th = this; | ||
| 4154 | - if (this.data.is_normal == 0) { | ||
| 4155 | - //看一下有没有起购数,如果有起购数,要计算起购数 | ||
| 4156 | - var qnum = parseFloat(th.data.prom_act.minbuynum); | ||
| 4157 | - if (qnum > 0 && th.data.goodsInputNum < qnum) { | ||
| 4158 | - getApp().confirmBox("拼团商品至少要买" + qnum + "件!"); | ||
| 4159 | - return false; | ||
| 4160 | - } | ||
| 4161 | - th.addcart_pt_func(); | ||
| 4162 | - } else { | ||
| 4163 | - th.addcart_pt_func(); | ||
| 4164 | - } | ||
| 4165 | - }, | ||
| 4166 | - | ||
| 4167 | - addcart_pt_func: function () { | ||
| 4168 | - if (oo.user_id == null) { | ||
| 4169 | - s.my_warnning("还未登录!", 0, this); | ||
| 4170 | - return; | ||
| 4171 | - } | ||
| 4172 | - var e = this, | ||
| 4173 | - th = e, | ||
| 4174 | - o = this.data.sele_g; | ||
| 4175 | - if (o.store_count <= 0) return s.my_warnning("库存已为空!", 0, th); | ||
| 4176 | - | ||
| 4177 | - //----------添加到购物车时,要判断限购数量,-------- | ||
| 4178 | - e.get_buy_num(o, async function (ee) { | ||
| 4179 | - | ||
| 4180 | - //---判断商品是否超出限购--- | ||
| 4181 | - if (th.data.g_buy_num != null && th.data.sele_g.viplimited > 0) { | ||
| 4182 | - if (th.data.goodsInputNum + th.data.g_buy_num.get(th.data.sele_g.goods_id) > th.data.sele_g.viplimited) { | ||
| 4183 | - // wx.showModal({ | ||
| 4184 | - // title: '提示', | ||
| 4185 | - // content: '超出商品限购' | ||
| 4186 | - // }); | ||
| 4187 | - s.my_warnning('超出商品限购', 0, th); | ||
| 4188 | - var num = th.data.prom_buy_limit - th.data.prom_buy_num; | ||
| 4189 | - if (num < 0) num = 0; | ||
| 4190 | - th.setData({goodsInputNum: num}) | ||
| 4191 | - return false; | ||
| 4192 | - } | ||
| 4193 | - } | ||
| 4194 | - //---判断商品是否超出活动限购,拼团的普通购买不计算活动的限购--- | ||
| 4195 | - if (th.data.prom_buy_num != -1 && th.data.prom_buy_limit > 0 && th.data.is_normal != 1) { | ||
| 4196 | - if (th.data.goodsInputNum + th.data.prom_buy_num > th.data.prom_buy_limit) { | ||
| 4197 | - // wx.showModal({ | ||
| 4198 | - // title: '提示', | ||
| 4199 | - // content: '超出商品活动限购' | ||
| 4200 | - // }); | ||
| 4201 | - s.my_warnning('超出商品活动限购', 0, th); | ||
| 4202 | - var num = th.data.prom_buy_limit - th.data.prom_buy_num; | ||
| 4203 | - if (num < 0) num = 0; | ||
| 4204 | - th.setData({goodsInputNum: num}) | ||
| 4205 | - return false; | ||
| 4206 | - } | ||
| 4207 | - } | ||
| 4208 | - | ||
| 4209 | - var redis_num = 0 | ||
| 4210 | - //不是普通购买的时候 | ||
| 4211 | - if (th.data.is_normal != 1) { | ||
| 4212 | - //-------判断活动是否抢光--------- | ||
| 4213 | - await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + os.stoid + "/6/" + th.data.sele_g.prom_id, { | ||
| 4214 | - 1: 1 | ||
| 4215 | - }).then(res => { | ||
| 4216 | - redis_num = res.data.data; | ||
| 4217 | - }) | ||
| 4218 | - | ||
| 4219 | - if (th.data.goodsInputNum > redis_num) { | ||
| 4220 | - // wx.showModal({ | ||
| 4221 | - // title: '提示', | ||
| 4222 | - // content: '超出商品活动库存' | ||
| 4223 | - // }); | ||
| 4224 | - s.my_warnning('超出商品活动库存', 0, th); | ||
| 4225 | - th.setData({goodsInputNum: redis_num}) | ||
| 4226 | - | ||
| 4227 | - return false; | ||
| 4228 | - } | ||
| 4229 | - } | ||
| 4230 | - | ||
| 4231 | - if (th.data.goodsInputNum <= 0) return s.my_warnning("商品数量不能为0", 0, th); | ||
| 4232 | - if (th.data.goodsInputNum > o.store_count) { | ||
| 4233 | - th.setData({goodsInputNum: o.store_count}) | ||
| 4234 | - return s.my_warnning("超出商品库存", 0, th); | ||
| 4235 | - } | ||
| 4236 | - | ||
| 4237 | - if (th.data.sto_sele_name == null || th.data.sto_sele_name == undefined) | ||
| 4238 | - this.setData({ | ||
| 4239 | - sto_sele_name: "" | ||
| 4240 | - }); | ||
| 4241 | - if (th.data.sto_sele_name == "") return s.my_warnning("请选择门店", 0, th); | ||
| 4242 | - //--------------此时操作的数据------------ | ||
| 4243 | - var newd = { | ||
| 4244 | - goods_id: o.goods_id, | ||
| 4245 | - goods_num: th.data.goodsInputNum, | ||
| 4246 | - pick_id: th.data.sto_sele_id, | ||
| 4247 | - user_id: oo.user_id, | ||
| 4248 | - store_id: th.data.stoid, | ||
| 4249 | - goods_price: o.shop_price, | ||
| 4250 | - goods_name: o.goods_name, | ||
| 4251 | - goods_sn: o.goods_sn, | ||
| 4252 | - sku: o.sku, | ||
| 4253 | - }; | ||
| 4254 | - | ||
| 4255 | - //---是不是从收藏夹出来的--- | ||
| 4256 | - if (th.data.c_guide_id) { | ||
| 4257 | - newd['guide_id'] = th.data.c_guide_id; | ||
| 4258 | - newd['guide_type'] = 2; | ||
| 4259 | - | ||
| 4260 | - | ||
| 4261 | - | ||
| 4262 | - | ||
| 4263 | - } else { | ||
| 4264 | - if (getApp().globalData.guide_id) { | ||
| 4265 | - newd['guide_id'] = getApp().globalData.guide_id; | ||
| 4266 | - newd['guide_type'] = 0; | ||
| 4267 | - | ||
| 4268 | - | ||
| 4269 | - } | ||
| 4270 | - } | ||
| 4271 | - | ||
| 4272 | - //让商品带上房间号 | ||
| 4273 | - if (!th.data.sys_switch.is_skuroom_id && th.data.sys_switch.is_skuroom_id == 1) { | ||
| 4274 | - if (th.data.data.goods_id == getApp().globalData.room_goods_id) { | ||
| 4275 | - newd.room_id = getApp().globalData.room_id; | ||
| 4276 | - } | ||
| 4277 | - } else { | ||
| 4278 | - if (newd.goods_id == getApp().globalData.room_goods_id) { | ||
| 4279 | - newd.room_id = getApp().globalData.room_id; | ||
| 4280 | - } | ||
| 4281 | - } | ||
| 4282 | - | ||
| 4283 | - //---如果商品不是积分购和拼团,要判断一个是否要进行等级价的判断------ | ||
| 4284 | - | ||
| 4285 | - if (th.data.is_normal == 1) { | ||
| 4286 | - var conf = th.data.bconfig; | ||
| 4287 | - if (conf.switch_list) { | ||
| 4288 | - var s_list = JSON.parse(conf.switch_list); | ||
| 4289 | - //如果后台有开启等级价的功能 | ||
| 4290 | - if (parseInt(s_list.rank_switch) == 2) { | ||
| 4291 | - var card_price = o[getApp().globalData.userInfo['card_field']]; | ||
| 4292 | - //如果会员有等级价 | ||
| 4293 | - if (getApp().globalData.userInfo['card_field'] != undefined && getApp().globalData.userInfo['card_field'] != null | ||
| 4294 | - && getApp().globalData.userInfo['card_field'] != "" && card_price > 0) { | ||
| 4295 | - newd.goods_price = card_price; | ||
| 4296 | - } | ||
| 4297 | - } | ||
| 4298 | - } | ||
| 4299 | - } | ||
| 4300 | - | ||
| 4301 | - | ||
| 4302 | - //-----如果是秒杀,团购,积分购,拼团,且不是普通购买----- | ||
| 4303 | - if (th.data.prom_type == 6 && th.data.is_normal != 1) { | ||
| 4304 | - newd.goods_price = th.data.prom_price; | ||
| 4305 | - newd.prom_type = th.data.prom_type; | ||
| 4306 | - newd.prom_id = th.data.prom_id; | ||
| 4307 | - newd.kt_type = th.data.prom_act.kttype; //开团类型 | ||
| 4308 | - newd.is_pt_tz = 0; | ||
| 4309 | - //th.data.sto_sele_distr=1; //直接用自提的方式提交 | ||
| 4310 | - if (newd.kt_type > 1) { | ||
| 4311 | - newd.is_pt_tz = 1; //开团类型 | ||
| 4312 | - } | ||
| 4313 | - if (newd.kt_type == 3) { | ||
| 4314 | - th.data.sto_sele_distr = 1; | ||
| 4315 | - } | ||
| 4316 | - | ||
| 4317 | - } else if (th.data.prom_type == 3) { | ||
| 4318 | - newd.prom_type = 0; | ||
| 4319 | - newd.prom_id = 0; | ||
| 4320 | - } | ||
| 4321 | - | ||
| 4322 | - newd['pick_name'] = th.data.sto_sele_name; | ||
| 4323 | - newd['pick_dis'] = th.data.sto_sele_distr; | ||
| 4324 | - newd['is_normal'] = th.data.is_normal; | ||
| 4325 | - | ||
| 4326 | - if (newd['is_normal']) { | ||
| 4327 | - newd['is_pd_normal'] = 1; | ||
| 4328 | - //判断一下有没有全局优惠活动 | ||
| 4329 | - th.check_nor_promgood(newd.goods_id, function (e) { | ||
| 4330 | - if (e && e.act_id) { | ||
| 4331 | - newd['prom_type'] = 3; | ||
| 4332 | - newd['prom_id'] = e.act_id; | ||
| 4333 | - } | ||
| 4334 | - th.buyNow(newd) | ||
| 4335 | - }) | ||
| 4336 | - } | ||
| 4337 | - else th.buyNow_pt(newd); | ||
| 4338 | - }) | ||
| 4339 | - }, | ||
| 4340 | - | ||
| 4341 | - //----------立即购买_pt----------- | ||
| 4342 | - buyNow_pt: function (e) { | ||
| 4343 | - s.set_b_now(e); | ||
| 4344 | - wx.navigateTo({ | ||
| 4345 | - url: "/pages/cart/cart2_pt/cart2_pt?is_bnow=1&goods_id=" + e.goods_id, | ||
| 4346 | - }); | ||
| 4347 | - }, | ||
| 4348 | - | ||
| 4349 | - //-------跳转pt商品------- | ||
| 4350 | - go_to_nopay: function () { | ||
| 4351 | - var th = this; | ||
| 4352 | - url = "/pages/user/order_detail/order_detail?order_id=" + th.data.buy_order.order_id; | ||
| 4353 | - getApp().goto(url); | ||
| 4354 | - | ||
| 4355 | - }, | ||
| 4356 | - //-------跳转pt teamshow------- | ||
| 4357 | - go_to_team_show: function () { | ||
| 4358 | - | ||
| 4359 | - if (this.data.is_go_to_team_show) return false; | ||
| 4360 | - this.data.is_go_to_team_show = 1; | ||
| 4361 | - wx.showLoading(); | ||
| 4362 | - | ||
| 4363 | - var th = this; | ||
| 4364 | - var url = "/pages/team/team_success/team_success?ordersn=" + th.data.buy_order.order_sn; | ||
| 4365 | - /*-- | ||
| 4366 | - wx.redirectTo({ | ||
| 4367 | - url:url, | ||
| 4368 | - })--*/ | ||
| 4369 | - getApp().goto(url); | ||
| 4370 | - | ||
| 4371 | - }, | ||
| 4372 | - | ||
| 4373 | - //---拼团倒计时--- | ||
| 4374 | - countDown2() { | ||
| 4375 | - if (!this.data.is_timer) return false; | ||
| 4376 | - var th = this; | ||
| 4377 | - // 获取当前时间,同时得到活动结束时间数组 | ||
| 4378 | - var newTime = ut.gettimestamp(); | ||
| 4379 | - var List = th.data.teamgroup; | ||
| 4380 | - for (var j = 0; j < List.length; j++) { | ||
| 4381 | - // 对结束时间进行处理渲染到页面 | ||
| 4382 | - var endTime = List[j].kt_end_time; | ||
| 4383 | - let obj = null; | ||
| 4384 | - // 如果活动未结束,对时间进行处理 | ||
| 4385 | - if (endTime - newTime > 0) { | ||
| 4386 | - let time = (endTime - newTime); | ||
| 4387 | - // 获取天、时、分、秒 | ||
| 4388 | - let day = parseInt(time / (60 * 60 * 24)); | ||
| 4389 | - let hou = parseInt(time % (60 * 60 * 24) / 3600); | ||
| 4390 | - let min = parseInt(time % (60 * 60 * 24) % 3600 / 60); | ||
| 4391 | - let sec = parseInt(time % (60 * 60 * 24) % 3600 % 60); | ||
| 4392 | - obj = { | ||
| 4393 | - day: this.timeFormat(day), | ||
| 4394 | - hou: this.timeFormat(hou), | ||
| 4395 | - min: this.timeFormat(min), | ||
| 4396 | - sec: this.timeFormat(sec) | ||
| 4397 | - } | ||
| 4398 | - } else { | ||
| 4399 | - //活动已结束,全部设置为'00' | ||
| 4400 | - obj = { | ||
| 4401 | - day: '00', | ||
| 4402 | - hou: '00', | ||
| 4403 | - min: '00', | ||
| 4404 | - sec: '00' | ||
| 4405 | - } | ||
| 4406 | - } | ||
| 4407 | - var txt = "timer[" + j + "]"; | ||
| 4408 | - th.setData({ | ||
| 4409 | - [txt]: obj | ||
| 4410 | - }); | ||
| 4411 | - } | ||
| 4412 | - setTimeout(th.countDown2, 1000); | ||
| 4413 | - }, | ||
| 4414 | - //跳转参加团 | ||
| 4415 | - go_cj_team: function (e) { | ||
| 4416 | - var ind = e.currentTarget.dataset.ind; | ||
| 4417 | - var item = this.data.teamgroup[ind]; | ||
| 4418 | - var goods_id = e.currentTarget.dataset.goodsid; | ||
| 4419 | - var id = item.id; | ||
| 4420 | - var th = this; | ||
| 4421 | - | ||
| 4422 | - getApp().request.get("/api/weshop/order/page", { | ||
| 4423 | - data: { | ||
| 4424 | - pt_prom_id: item.team_id, | ||
| 4425 | - user_id: oo.user_id, | ||
| 4426 | - store_id: os.stoid, | ||
| 4427 | - pageSize: 1, | ||
| 4428 | - page: 1 | ||
| 4429 | - }, | ||
| 4430 | - success: function (e) { | ||
| 4431 | - if (e.data.code != 0) { | ||
| 4432 | - getApp().my_warnning("读取订单失败", 0, th); | ||
| 4433 | - return fasle; | ||
| 4434 | - } | ||
| 4435 | - //--跳转到已经购买的情况-- | ||
| 4436 | - if (e.data.data.pageData.length > 0) { | ||
| 4437 | - var odr = e.data.data.pageData[0]; | ||
| 4438 | - //还未支付 | ||
| 4439 | - if (odr.pt_status == 0 && (odr.order_status == 1 || odr.order_status == 0)) { | ||
| 4440 | - wx.showModal({ | ||
| 4441 | - title: "您已经购买了该商品待支付中", | ||
| 4442 | - success: function (a) { | ||
| 4443 | - if (a.confirm) { | ||
| 4444 | - wx.navigateTo({ | ||
| 4445 | - url: "/pages/user/order_detail/order_detail?order_id=" + odr.order_id, | ||
| 4446 | - }); | ||
| 4447 | - } | ||
| 4448 | - } | ||
| 4449 | - }); | ||
| 4450 | - } else if (odr.pt_status == 1 && odr.order_status == 1) { | ||
| 4451 | - | ||
| 4452 | - if (this.data.is_go_to_team_show) return false; | ||
| 4453 | - this.data.is_go_to_team_show = 1; | ||
| 4454 | - wx.showLoading(); | ||
| 4455 | - /*-- | ||
| 4456 | - wx.redirectTo({ | ||
| 4457 | - url: "/pages/team/team_success/team_success?ordersn=" + odr.order_sn, | ||
| 4458 | - });--*/ | ||
| 4459 | - | ||
| 4460 | - getApp().goto("/pages/team/team_success/team_success?ordersn=" + odr.order_sn); | ||
| 4461 | - | ||
| 4462 | - } else { | ||
| 4463 | - console.log(222,goods_id) | ||
| 4464 | - wx.navigateTo({ | ||
| 4465 | - url: "/pages/team/team_show/team_show?tg_id=" + id +"&goods_id="+goods_id, | ||
| 4466 | - }); | ||
| 4467 | - } | ||
| 4468 | - } | ||
| 4469 | - //--跳转到参团-- | ||
| 4470 | - else { | ||
| 4471 | - console.log(1111,th.data.goods_id) | ||
| 4472 | - wx.navigateTo({ | ||
| 4473 | - url: "/pages/team/team_show/team_show?tg_id=" + id+"&goods_id="+goods_id, | ||
| 4474 | - }); | ||
| 4475 | - } | ||
| 4476 | - } | ||
| 4477 | - }) | ||
| 4478 | - | ||
| 4479 | - }, | ||
| 4480 | - | ||
| 4481 | - //跳到团更多 | ||
| 4482 | - go_t_more: function () { | ||
| 4483 | - var team_id = this.data.prom_id; | ||
| 4484 | - wx.navigateTo({ | ||
| 4485 | - url: "/pages/team/team_more/team_more?team_id=" + team_id, | ||
| 4486 | - }); | ||
| 4487 | - }, | ||
| 4488 | - | ||
| 4489 | - //--点赞功能-- | ||
| 4490 | - click_zan: function (e) { | ||
| 4491 | - var com_id = e.currentTarget.dataset.com_id; | ||
| 4492 | - var item_id = e.currentTarget.dataset.item_id; | ||
| 4493 | - var app = getApp(), | ||
| 4494 | - th = this; | ||
| 4495 | - | ||
| 4496 | - if (app.globalData.userInfo == null || app.globalData.userInfo == undefined) { | ||
| 4497 | - app.confirmBox("您还未登录"); | ||
| 4498 | - return false; | ||
| 4499 | - } | ||
| 4500 | - | ||
| 4501 | - var iszan = th.data.comments[item_id].userZanNum; | ||
| 4502 | - if (this.data.iszaning) return false; | ||
| 4503 | - this.data.iszaning = 1; | ||
| 4504 | - | ||
| 4505 | - | ||
| 4506 | - app.request.post("/api/weshop/commentZan/save", { | ||
| 4507 | - data: { | ||
| 4508 | - store_id: o.stoid, | ||
| 4509 | - user_id: app.globalData.user_id, | ||
| 4510 | - goods_id: th.data.gid, | ||
| 4511 | - comment_id: com_id | ||
| 4512 | - }, | ||
| 4513 | - success: function (ee) { | ||
| 4514 | - | ||
| 4515 | - if (ee.data.code == "-1") { | ||
| 4516 | - app.my_warnning("不能给自己点赞", 0, th); | ||
| 4517 | - th.data.iszaning = 0; | ||
| 4518 | - return; | ||
| 4519 | - } | ||
| 4520 | - | ||
| 4521 | - if (ee.data.code == 0 && iszan != 1) { | ||
| 4522 | - var num = th.data.comments[item_id].zan_num; | ||
| 4523 | - num++; | ||
| 4524 | - var text = "comments[" + item_id + "].zan_num"; | ||
| 4525 | - var text1 = "comments[" + item_id + "].userZanNum"; | ||
| 4526 | - var _errObj = {}; | ||
| 4527 | - _errObj[text] = num; | ||
| 4528 | - _errObj[text1] = 1; | ||
| 4529 | - th.setData(_errObj); | ||
| 4530 | - | ||
| 4531 | - } else { | ||
| 4532 | - var num = th.data.comments[item_id].zan_num; | ||
| 4533 | - num--; | ||
| 4534 | - var text = "comments[" + item_id + "].zan_num"; | ||
| 4535 | - var text1 = "comments[" + item_id + "].userZanNum"; | ||
| 4536 | - var _errObj = {}; | ||
| 4537 | - _errObj[text] = num; | ||
| 4538 | - _errObj[text1] = 0; | ||
| 4539 | - th.setData(_errObj); | ||
| 4540 | - } | ||
| 4541 | - | ||
| 4542 | - setTimeout(function () { | ||
| 4543 | - th.data.iszaning = 0; | ||
| 4544 | - }, 500) | ||
| 4545 | - | ||
| 4546 | - } | ||
| 4547 | - }) | ||
| 4548 | - }, | ||
| 4549 | - | ||
| 4550 | - /*----券的开关---*/ | ||
| 4551 | - switchCoupon: async function (event) { | ||
| 4552 | - var coupon = event.currentTarget.dataset.coupon; | ||
| 4553 | - var app = getApp(); | ||
| 4554 | - var url = "/api/weshop/prom/coupon/pageCouponList"; | ||
| 4555 | - var quan_list = this.data.quan_list; | ||
| 4556 | - var th = this; | ||
| 4557 | - | ||
| 4558 | - //当开启,且列表为空的情况下要 | ||
| 4559 | - if (!quan_list && coupon == "1") { | ||
| 4560 | - wx.showLoading(); | ||
| 4561 | - await app.request.promiseGet(url, { | ||
| 4562 | - data: { | ||
| 4563 | - store_id: os.stoid, | ||
| 4564 | - type: 1, | ||
| 4565 | - pageSize: 100, | ||
| 4566 | - page: 1, | ||
| 4567 | - user_id: app.globalData.user_id, | ||
| 4568 | - is_share: 0 | ||
| 4569 | - } | ||
| 4570 | - }).then(res => { | ||
| 4571 | - wx.hideLoading(); | ||
| 4572 | - quan_list = res.data.data.pageData; | ||
| 4573 | - }) | ||
| 4574 | - | ||
| 4575 | - if (quan_list) { | ||
| 4576 | - for (var ind in quan_list) { | ||
| 4577 | - var ep = quan_list[ind]; | ||
| 4578 | - var start = ""; | ||
| 4579 | - var end = ""; | ||
| 4580 | - if(ep.endtype == 1){ | ||
| 4581 | - if(ep.starttype == 1) { | ||
| 4582 | - start = ut.formatTime(ut.gettimestamp()+3600*24*ep.startdays,"yyyy-MM-dd"); | ||
| 4583 | - }else{ | ||
| 4584 | - start = ut.formatTime(ut.gettimestamp(),"yyyy-MM-dd"); | ||
| 4585 | - } | ||
| 4586 | - if(ep.days > 0) { | ||
| 4587 | - end = ut.formatTime(ut.gettimestamp()+3600*24*ep.startdays+3600*24*ep.days,"yyyy-MM-dd"); | ||
| 4588 | - }else{ | ||
| 4589 | - end = "不限"; | ||
| 4590 | - } | ||
| 4591 | - }else { | ||
| 4592 | - if(ep.starttype == 1 ){ | ||
| 4593 | - start = ut.formatTime(ut.gettimestamp()+3600*24*ep.startdays,"yyyy-MM-dd"); | ||
| 4594 | - }else{ | ||
| 4595 | - if(ep.starttype == 0 && ep.use_start_time >0) { | ||
| 4596 | - start = ut.formatTime(ep.use_start_time ,"yyyy-MM-dd"); | ||
| 4597 | - }else{ | ||
| 4598 | - start = "不限" | ||
| 4599 | - } | ||
| 4600 | - } | ||
| 4601 | - | ||
| 4602 | - if(ep.use_end_time > 0 ) { | ||
| 4603 | - end = ut.formatTime(ep.use_end_time ,"yyyy-MM-dd"); | ||
| 4604 | - }else{ | ||
| 4605 | - end = "不限" | ||
| 4606 | - } | ||
| 4607 | - } | ||
| 4608 | - quan_list[ind].start = start; | ||
| 4609 | - quan_list[ind].end = end; | ||
| 4610 | - // var start = ut.formatTime(ep.use_start_time, "yyyy-MM-dd"); | ||
| 4611 | - // var end = ut.formatTime(ep.use_end_time, "yyyy-MM-dd"); | ||
| 4612 | - // start = start.replace("00:00:00", ""); | ||
| 4613 | - // end = end.replace("00:00:00", ""); | ||
| 4614 | - // quan_list[ind].start = start; | ||
| 4615 | - // quan_list[ind].end = end; | ||
| 4616 | - } | ||
| 4617 | - } | ||
| 4618 | - | ||
| 4619 | - th.setData({ | ||
| 4620 | - coupon: coupon, | ||
| 4621 | - quan_list: quan_list | ||
| 4622 | - }); | ||
| 4623 | - } else { | ||
| 4624 | - th.setData({ | ||
| 4625 | - coupon: coupon | ||
| 4626 | - }); | ||
| 4627 | - } | ||
| 4628 | - }, | ||
| 4629 | - | ||
| 4630 | - //--查看评价-- | ||
| 4631 | - look_pj: function () { | ||
| 4632 | - this.tabComment(); | ||
| 4633 | - this.doScrollTop(); | ||
| 4634 | - }, | ||
| 4635 | - | ||
| 4636 | - //-----领取券----- | ||
| 4637 | - get_quan: function (e) { | ||
| 4638 | - var cid = e.currentTarget.dataset.cid; | ||
| 4639 | - var index = e.currentTarget.dataset.ind; | ||
| 4640 | - var item = this.data.quan_list[index]; | ||
| 4641 | - | ||
| 4642 | - | ||
| 4643 | - //--先判断会员状态-- | ||
| 4644 | - var user_info = getApp().globalData.userInfo; | ||
| 4645 | - if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { | ||
| 4646 | - wx.navigateTo({ | ||
| 4647 | - url: '/pages/togoin/togoin', | ||
| 4648 | - }) | ||
| 4649 | - return false; | ||
| 4650 | - } | ||
| 4651 | - | ||
| 4652 | - | ||
| 4653 | - //如果券还在领取中,不能再点 | ||
| 4654 | - if (item.linging == 1) { | ||
| 4655 | - getApp().my_warnning('领取中..', 0, this); | ||
| 4656 | - return false; | ||
| 4657 | - } | ||
| 4658 | - | ||
| 4659 | - //如果领取的次数到了 | ||
| 4660 | - if (item.everyone_num > 0 && item.lqnum >= item.everyone_num) { | ||
| 4661 | - getApp().my_warnning('领取失败,您已领完该券', 0, this); | ||
| 4662 | - return false; | ||
| 4663 | - } | ||
| 4664 | - | ||
| 4665 | - var lq_num = item.lqnum; | ||
| 4666 | - | ||
| 4667 | - var pdata = { | ||
| 4668 | - 'uid': oo.user_id, | ||
| 4669 | - 'cid': cid, | ||
| 4670 | - 'store_id': os.stoid, | ||
| 4671 | - 'type': 5 | ||
| 4672 | - }; | ||
| 4673 | - | ||
| 4674 | - //-- 导购ID -- | ||
| 4675 | - if (getApp().globalData.guide_id) { | ||
| 4676 | - pdata.guide_id = getApp().globalData.guide_id; | ||
| 4677 | - } | ||
| 4678 | - | ||
| 4679 | - var app = getApp(), | ||
| 4680 | - th = this; | ||
| 4681 | - app.request.post("/api/weshop/couponList/saveCouponList", { | ||
| 4682 | - data: pdata, | ||
| 4683 | - success: function (res) { | ||
| 4684 | - if (res.data.code == 0) { | ||
| 4685 | - app.my_warnning("领取成功", 1, th); | ||
| 4686 | - lq_num++; | ||
| 4687 | - var text = "quan_list[" + index + "].lqnum"; | ||
| 4688 | - var text2 = "quan_list[" + index + "].linging"; | ||
| 4689 | - var obj = {}; | ||
| 4690 | - obj[text] = lq_num; | ||
| 4691 | - obj[text2] = 0; | ||
| 4692 | - th.setData(obj); | ||
| 4693 | - } else { | ||
| 4694 | - app.confirmBox(res.data.msg); | ||
| 4695 | - var text2 = "quan_list[" + index + "].linging"; | ||
| 4696 | - var obj = {}; | ||
| 4697 | - obj[text2] = 0; | ||
| 4698 | - th.setData(obj); | ||
| 4699 | - } | ||
| 4700 | - } | ||
| 4701 | - }) | ||
| 4702 | - }, | ||
| 4703 | - | ||
| 4704 | - | ||
| 4705 | - drawPoster(context, unit, img, vpath, type) { | ||
| 4706 | - // 1.灰色背景 | ||
| 4707 | - context.setFillStyle('#f2f1f6'); | ||
| 4708 | - context.rect(0, 0, 554 * unit, 899 * unit); | ||
| 4709 | - context.fill(); | ||
| 4710 | - | ||
| 4711 | - // 2.商城名称 | ||
| 4712 | - let shopName = this.data.sto_sele_name_1; | ||
| 4713 | - context.setTextAlign('center'); | ||
| 4714 | - context.setFontSize(26 * unit); | ||
| 4715 | - context.setFillStyle('black'); | ||
| 4716 | - context.fillText(shopName, 277 * unit, 60 * unit); | ||
| 4717 | - | ||
| 4718 | - // 3.推荐来源 | ||
| 4719 | - let fromText = `来自${getApp().globalData.userInfo.nickname}的推荐`; | ||
| 4720 | - context.setTextAlign('center'); | ||
| 4721 | - context.setFontSize(22 * unit); | ||
| 4722 | - context.setFillStyle('#96959a'); | ||
| 4723 | - context.fillText(fromText, 277 * unit, 105 * unit); | ||
| 4724 | - | ||
| 4725 | - // 4.海报背景 | ||
| 4726 | - context.setFillStyle('white'); | ||
| 4727 | - context.fillRect(37 * unit, 157 * unit, 480 * unit, 673 * unit); | ||
| 4728 | - | ||
| 4729 | - // 5.商品图片 | ||
| 4730 | - // 图片的x坐标 | ||
| 4731 | - let bg_x = 37 * unit | ||
| 4732 | - // 图片的y坐标 | ||
| 4733 | - let bg_y = 157 * unit | ||
| 4734 | - // 图片宽度 | ||
| 4735 | - let bg_w = 480 * unit | ||
| 4736 | - // 图片高度 | ||
| 4737 | - let bg_h = 474 * unit | ||
| 4738 | - // 图片圆角 | ||
| 4739 | - let bg_r = 4 | ||
| 4740 | - // 绘制海报背景图片圆角 | ||
| 4741 | - context.save() | ||
| 4742 | - context.beginPath() | ||
| 4743 | - context.arc(bg_x + bg_r, bg_y + bg_r, bg_r, Math.PI, Math.PI * 1.5) | ||
| 4744 | - context.arc(bg_x + bg_w - bg_r, bg_y + bg_r, bg_r, Math.PI * 1.5, Math.PI * 2) | ||
| 4745 | - context.arc(bg_x + bg_w, bg_y + bg_h, bg_r, 0, Math.PI * 0.5) | ||
| 4746 | - context.arc(bg_x, bg_y + bg_h, 0, Math.PI * 0.5, Math.PI) | ||
| 4747 | - context.clip() | ||
| 4748 | - context.drawImage(img, bg_x, bg_y, bg_w, bg_h); | ||
| 4749 | - context.restore(); | ||
| 4750 | - | ||
| 4751 | - // 6.强烈推荐 | ||
| 4752 | - let src = ''; | ||
| 4753 | - context.beginPath(); | ||
| 4754 | - if(type == 0) { // 普通 | ||
| 4755 | - src = '../../../images/share/q_tj.png'; | ||
| 4756 | - context.drawImage(src, 54 * unit, 648 * unit, 85 * unit, 30 * unit); | ||
| 4757 | - context.setFontSize(16 * unit) | ||
| 4758 | - context.setFillStyle("white") | ||
| 4759 | - context.setTextAlign('left'); | ||
| 4760 | - context.fillText('强烈推荐', 64 * unit, 668 * unit); | ||
| 4761 | - }; | ||
| 4762 | - if(type == 1) { // 秒杀 | ||
| 4763 | - src = '../../../images/share/miao_share.png'; | ||
| 4764 | - context.drawImage(src, 54 * unit, 648 * unit, 200 * unit, 36 * unit); | ||
| 4765 | - }; | ||
| 4766 | - if(type == 2) { // 商家和会员团 | ||
| 4767 | - src = '../../../images/share/ct_num.png'; | ||
| 4768 | - context.drawImage(src, 54 * unit, 648 * unit, 120 * unit, 30 * unit); | ||
| 4769 | - context.setTextAlign('left'); | ||
| 4770 | - | ||
| 4771 | - let ct_num = self.data.prom_act.ct_num; | ||
| 4772 | - context.setFontSize(16 * unit) | ||
| 4773 | - context.font = 'normal'; | ||
| 4774 | - context.setFillStyle("red") | ||
| 4775 | - if (ct_num < 10) { | ||
| 4776 | - context.fillText(ct_num + "人拼团", 100 * unit, 670 * unit); | ||
| 4777 | - } else { | ||
| 4778 | - context.fillText(ct_num + "人拼团", 96 * unit, 670 * unit); | ||
| 4779 | - } | ||
| 4780 | - context.setFontSize(22 * unit) | ||
| 4781 | - context.fillText("已拼" + self.data.prom_act.buy_num + "份", 186 * unit, 672 * unit); | ||
| 4782 | - }; | ||
| 4783 | - if(type == 3) { // 阶梯团 | ||
| 4784 | - let list = self.data.prom_act.ct_rylist; | ||
| 4785 | - for (let i = 0; i < list.length; i++) { | ||
| 4786 | - let item = list[i]; | ||
| 4787 | - let wi = i * 90 * unit; | ||
| 4788 | - context.font = 'normal'; | ||
| 4789 | - context.setTextAlign('left'); | ||
| 4790 | - context.setFontSize(16 * unit) | ||
| 4791 | - context.setFillStyle("red") | ||
| 4792 | - context.fillText("¥", 50 * unit + wi, 680 * unit); | ||
| 4793 | - context.setFontSize(22 * unit) | ||
| 4794 | - let pri = parseFloat(item.price).toFixed(2); | ||
| 4795 | - context.fillText(pri, 66 * unit + wi, 680 * unit); | ||
| 4796 | - context.setFillStyle("gray") | ||
| 4797 | - context.fillText("满" + item.rynum + "人", 50 * unit + wi, 716 * unit); | ||
| 4798 | - } | ||
| 4799 | - }; | ||
| 4800 | - | ||
| 4801 | - // 7.商品价格 | ||
| 4802 | - if(type != 3) { | ||
| 4803 | - let price = this.data.data.shop_price; | ||
| 4804 | - if (this.data.card_field && this.data.data[this.data.card_field]) { | ||
| 4805 | - price = this.data.data[this.data.card_field]; | ||
| 4806 | - } | ||
| 4807 | - if (this.data.prom_act) price = this.data.prom_price; | ||
| 4808 | - price = parseFloat(price).toFixed(2); | ||
| 4809 | - context.setFontSize(32 * unit); | ||
| 4810 | - context.setFillStyle('#DE1117'); | ||
| 4811 | - context.fillText('¥' + price, 54 * unit, 730 * unit); | ||
| 4812 | - }; | ||
| 4813 | - | ||
| 4814 | - // 8.商品标题 | ||
| 4815 | - context.setFontSize(20 * unit); | ||
| 4816 | - context.setFillStyle('#898989'); | ||
| 4817 | - this.draw_Text(context, this.data.data.goods_name, 54 * unit, 770 * unit, 240 * unit, 240 * unit, unit); | ||
| 4818 | - | ||
| 4819 | - // 9.小程序码 | ||
| 4820 | - context.drawImage(vpath, 375 * unit, 660 * unit, 120 * unit, 120 * unit); | ||
| 4821 | - context.setFontSize(16 * unit); | ||
| 4822 | - context.setFillStyle('#777'); | ||
| 4823 | - context.fillText('长按识别二维码', 378 * unit, 810 * unit); | ||
| 4824 | - | ||
| 4825 | - // 10.竖线 | ||
| 4826 | - context.beginPath(); | ||
| 4827 | - context.setFillStyle('#eee'); | ||
| 4828 | - context.rect(354 * unit, 670 * unit, 1 * unit, 130 * unit); | ||
| 4829 | - context.fill(); | ||
| 4830 | - }, | ||
| 4831 | - | ||
| 4832 | - | ||
| 4833 | - //--定义的保存图片方法,分享团--- | ||
| 4834 | - saveImageToPhotosAlbum: function () { | ||
| 4835 | - //--先判断会员状态-- | ||
| 4836 | - var user_info = getApp().globalData.userInfo; | ||
| 4837 | - if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { | ||
| 4838 | - //getApp().my_warnning("请先登录",0,this); | ||
| 4839 | - wx.navigateTo({url: '/pages/togoin/togoin',}) | ||
| 4840 | - return false; | ||
| 4841 | - } | ||
| 4842 | - | ||
| 4843 | - if (this.data.share_hidden) { | ||
| 4844 | - this.setData({share_hidden: false,}); | ||
| 4845 | - }; | ||
| 4846 | - | ||
| 4847 | - //类型 0普通商品 1秒杀商品 2商家和会员团 3阶梯团 4阶梯团 | ||
| 4848 | - var type = this.data.prom_type; | ||
| 4849 | - if (type == 2) type = -1; | ||
| 4850 | - if (type == 6) type = 2; // 6拼团 2团购 | ||
| 4851 | - | ||
| 4852 | - | ||
| 4853 | - if (this.data.prom_act && this.data.prom_act.kttype == 3) type = 3; | ||
| 4854 | - | ||
| 4855 | - wx.showLoading({title: '生成中...',}) | ||
| 4856 | - var that = this, th = that; | ||
| 4857 | - //设置画板显示,才能开始绘图 | ||
| 4858 | - that.setData({ | ||
| 4859 | - canvasHidden: false | ||
| 4860 | - }) | ||
| 4861 | - | ||
| 4862 | - var app = getApp(); | ||
| 4863 | - var unit = that.data.screenWidth / 750 * 1.35; //基础单位, | ||
| 4864 | - var path2 = that.data.data.original_img; | ||
| 4865 | - var scene = th.data.gid + ""; | ||
| 4866 | - scene += "." + th.data.sele_g.prom_type + "." + th.data.sele_g.prom_id; | ||
| 4867 | - | ||
| 4868 | - var user_id = getApp().globalData.user_id ? getApp().globalData.user_id : 0; | ||
| 4869 | - if (user_id > 0) { | ||
| 4870 | - scene += "_" + user_id; | ||
| 4871 | - } | ||
| 4872 | - //-- 如果不是会员分享过来的要分享给别人 -- | ||
| 4873 | - if (getApp().globalData.room_id && th.data.data.goods_id == getApp().globalData.room_goods_id && !getApp().globalData.room_user_share) { | ||
| 4874 | - //固定房间是第3个字符 | ||
| 4875 | - if (!user_id) scene += "_0"; | ||
| 4876 | - scene += "_" + getApp().globalData.room_id; | ||
| 4877 | - } | ||
| 4878 | - ///二微码 | ||
| 4879 | - var path3 = os.url + "/api/wx/open/app/user/getWeAppEwm/" + | ||
| 4880 | - os.stoid + "?sceneValue=" + scene + "&pageValue=pages/goods/goodsInfo/goodsInfo"; | ||
| 4881 | - | ||
| 4882 | - console.log(path3); | ||
| 4883 | - | ||
| 4884 | - | ||
| 4885 | - // 读取文件成功则OK-- | ||
| 4886 | - wx.getImageInfo({ | ||
| 4887 | - src: path3, | ||
| 4888 | - success: function (res) { | ||
| 4889 | - // 回调写法 | ||
| 4890 | - th.get_head_temp(th.get_goods_temp, function () { | ||
| 4891 | - var vpath = res.path; | ||
| 4892 | - var context = wx.createCanvasContext('share'); | ||
| 4893 | - // 先画背景 | ||
| 4894 | - var pg_path = "../../../images/share/share_bg.png"; | ||
| 4895 | - | ||
| 4896 | - | ||
| 4897 | - //-- 如果有自定义海报的时候,判断背景的图片 -- | ||
| 4898 | - if (th.data.share_b_img) { | ||
| 4899 | - pg_path = th.data.share_b_img; | ||
| 4900 | - } | ||
| 4901 | - // context.drawImage(pg_path, 0, 0, 554 * unit, 899 * unit); | ||
| 4902 | - | ||
| 4903 | - | ||
| 4904 | - if (type == 0 || type == 1 || type == 2 || type == 3) { // 如果是普通商品,绘制新海报 | ||
| 4905 | - th.drawPoster(context, unit, th.data.share_goods_img, vpath, type); | ||
| 4906 | - } else { | ||
| 4907 | - context.drawImage(pg_path, 0, 0, 554 * unit, 899 * unit); | ||
| 4908 | - }; | ||
| 4909 | - | ||
| 4910 | - // th.drawPoster(context, unit, th.data.share_goods_img, vpath); | ||
| 4911 | - | ||
| 4912 | - | ||
| 4913 | - //-- 是自定义海报的情况下 -- | ||
| 4914 | - if (type != 0 && type != 1 && type != 2 && type != 3) { | ||
| 4915 | - | ||
| 4916 | - if (th.data.poster && parseInt(th.data.poster.style) == 2) { | ||
| 4917 | - //在线上分享人的情况下 | ||
| 4918 | - if (parseInt(th.data.poster.show_headpic)) { | ||
| 4919 | - //获取坐标 | ||
| 4920 | - var x = parseFloat(th.data.poster.head_x) * 2; | ||
| 4921 | - var y = parseFloat(th.data.poster.head_y) * 2; | ||
| 4922 | - var x1 = (x + 90) * unit; | ||
| 4923 | - var y1 = (y + 50) * unit; | ||
| 4924 | - //--昵称--- | ||
| 4925 | - context.setFontSize(24 * unit) | ||
| 4926 | - context.setFillStyle("black") | ||
| 4927 | - context.fillText(app.globalData.userInfo.nickname, x1, y1); | ||
| 4928 | - var width = 24 * app.globalData.userInfo.nickname.length * unit + 4 * unit; | ||
| 4929 | - //强烈推荐 改许程 | ||
| 4930 | - var tj_path = "../../../images/share/q_tj.png"; | ||
| 4931 | - context.drawImage(tj_path, x1 + width, y1 - 22 * unit, 85 * unit, 30 * unit); | ||
| 4932 | - context.setFontSize(16 * unit); | ||
| 4933 | - context.setLineJoin('round'); //交点设置成圆角 | ||
| 4934 | - context.setFillStyle("white"); | ||
| 4935 | - context.fillText('强烈推荐', x1 + width + 8 * unit, y1 - 1 * unit); | ||
| 4936 | - | ||
| 4937 | - //context.setFillStyle("black") | ||
| 4938 | - //context.setFontSize(24 * unit) | ||
| 4939 | - //context.fillText(getApp().globalData.config.store_name, 40 * unit, 130 * unit); | ||
| 4940 | - } | ||
| 4941 | - } else { | ||
| 4942 | - //--昵称--- | ||
| 4943 | - context.setFontSize(24 * unit); | ||
| 4944 | - context.setFillStyle("black"); | ||
| 4945 | - context.fillText(app.globalData.userInfo.nickname, 152 * unit, 76 * unit); | ||
| 4946 | - var width = 24 * app.globalData.userInfo.nickname.length * unit + 2 * unit; | ||
| 4947 | - //强烈推荐 改许程 | ||
| 4948 | - var tj_path = "../../../images/share/q_tj.png"; | ||
| 4949 | - context.drawImage(tj_path, 152 * unit + width, 54 * unit, 85 * unit, 30 * unit); | ||
| 4950 | - context.setFontSize(16 * unit); | ||
| 4951 | - context.setLineJoin('round'); //交点设置成圆角 | ||
| 4952 | - context.setFillStyle("white"); | ||
| 4953 | - context.fillText('强烈推荐', 149 * unit + width + 15 * unit, 75 * unit); | ||
| 4954 | - } | ||
| 4955 | - | ||
| 4956 | - } | ||
| 4957 | - ; | ||
| 4958 | - | ||
| 4959 | - | ||
| 4960 | - var share_title = th.data.data.goods_name; | ||
| 4961 | - if (th.data.prom_type == 1 || th.data.prom_type == 2 || th.data.prom_type == 6 || th.data.prom_type == 4) { | ||
| 4962 | - share_title = th.data.prom_act.share_title; | ||
| 4963 | - if (!share_title) share_title = th.data.prom_act.title; | ||
| 4964 | - if (th.data.prom_type == 4) share_title = th.data.prom_act.name; | ||
| 4965 | - } | ||
| 4966 | - | ||
| 4967 | - //---产品名称--- | ||
| 4968 | - //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 | ||
| 4969 | - if (type != 4 && type != 0 && type != 1 && type != 2 && type != 3) { | ||
| 4970 | - context.setFillStyle("black"); | ||
| 4971 | - context.setFontSize(21.3 * unit) | ||
| 4972 | - th.draw_Text(context, share_title, | ||
| 4973 | - 38 * unit, 180 * unit, 200 * unit, 279 * unit, unit); | ||
| 4974 | - | ||
| 4975 | - //------产品的价格------- | ||
| 4976 | - context.setFontSize(23 * unit) | ||
| 4977 | - context.setFillStyle("red") | ||
| 4978 | - | ||
| 4979 | - var pri0 = th.data.data.shop_price; | ||
| 4980 | - if (th.data.card_field && th.data.data[th.data.card_field]) { | ||
| 4981 | - pri0 = th.data.data[th.data.card_field]; | ||
| 4982 | - } | ||
| 4983 | - | ||
| 4984 | - if (th.data.prom_act) | ||
| 4985 | - pri0 = th.data.prom_price; | ||
| 4986 | - pri0 = parseFloat(pri0).toFixed(2); | ||
| 4987 | - var wd1 = th.data.screenWidth - ut.measureText(pri0, 31 * unit) - 25; | ||
| 4988 | - context.fillText("¥", wd1 - 15, 185 * unit); | ||
| 4989 | - context.setFontSize(31 * unit) | ||
| 4990 | - context.fillText(pri0, wd1, 185 * unit); | ||
| 4991 | - | ||
| 4992 | - //---市场价划掉--- | ||
| 4993 | - context.setFillStyle("gray") | ||
| 4994 | - context.setFontSize(22 * unit) | ||
| 4995 | - pri0 = "¥" + th.data.data.market_price.toFixed(2); | ||
| 4996 | - var wd2 = th.data.screenWidth - ut.measureText(pri0, 22 * unit) - 25; | ||
| 4997 | - context.fillText(pri0, wd2, 213 * unit); | ||
| 4998 | - | ||
| 4999 | - context.setStrokeStyle('gray'); | ||
| 5000 | - context.setLineWidth(1 * unit); | ||
| 5001 | - context.moveTo(wd2 - 5, 206 * unit); | ||
| 5002 | - context.lineTo(wd2 + ut.measureText(pri0, 22 * unit) + 5, 206 * unit); | ||
| 5003 | - context.stroke(); | ||
| 5004 | - | ||
| 5005 | - } else if (type == 4 && type != 0 && type != 1 && type != 2 && type != 3) { | ||
| 5006 | - context.setFillStyle("black"); | ||
| 5007 | - context.setFontSize(21.3 * unit) | ||
| 5008 | - th.draw_Text(context, share_title, | ||
| 5009 | - 38 * unit, 170 * unit, 20 * unit, 300 * unit, unit); | ||
| 5010 | - //------ 产品的价格 ----- | ||
| 5011 | - var pri0 = th.data.prom_act.addmoney; | ||
| 5012 | - var integral = th.data.prom_act.integral; | ||
| 5013 | - var text = ""; | ||
| 5014 | - if (integral) { | ||
| 5015 | - text = integral + "积分"; | ||
| 5016 | - } | ||
| 5017 | - if (pri0 && integral) { | ||
| 5018 | - text += "+"; | ||
| 5019 | - } | ||
| 5020 | - if (pri0) { | ||
| 5021 | - text += "¥" + pri0; | ||
| 5022 | - } | ||
| 5023 | - | ||
| 5024 | - if (!pri0 && !integral) { | ||
| 5025 | - text = "0积分"; | ||
| 5026 | - } | ||
| 5027 | - context.setFillStyle("red"); | ||
| 5028 | - context.fillText(text, 38 * unit, 235 * unit); | ||
| 5029 | - | ||
| 5030 | - } | ||
| 5031 | - | ||
| 5032 | - //---中间大图--- | ||
| 5033 | - if (type != 0 && type != 1 && type != 2 && type != 3) { | ||
| 5034 | - context.drawImage(th.data.share_goods_img, 70 * unit, 250 * unit, 408 * unit, 408 * unit); | ||
| 5035 | - } | ||
| 5036 | - ; | ||
| 5037 | - | ||
| 5038 | - | ||
| 5039 | - //-------大图后面就不一样了----------- | ||
| 5040 | - switch (type) { | ||
| 5041 | - case 0: | ||
| 5042 | - break;//普通商品的展示 | ||
| 5043 | - case 4: | ||
| 5044 | - //中间的几个字 | ||
| 5045 | - if (th.data.poster && parseInt(th.data.poster.style) == 2) { | ||
| 5046 | - if (parseInt(th.data.poster.show_quality)) { | ||
| 5047 | - var g_path = "../../../images/share/s_gou.png"; | ||
| 5048 | - context.drawImage(g_path, 56 * unit, 670 * unit, 22 * unit, 22 * unit); | ||
| 5049 | - context.setFillStyle("red") | ||
| 5050 | - context.setFontSize(18 * unit) | ||
| 5051 | - context.fillText("正品保证", 84 * unit, 690 * unit); | ||
| 5052 | - | ||
| 5053 | - context.drawImage(g_path, 218 * unit, 670 * unit, 22 * unit, 22 * unit); | ||
| 5054 | - context.setFillStyle("red") | ||
| 5055 | - context.setFontSize(18 * unit) | ||
| 5056 | - context.fillText("纯实体店", 246 * unit, 690 * unit); | ||
| 5057 | - | ||
| 5058 | - context.drawImage(g_path, 388 * unit, 670 * unit, 22 * unit, 22 * unit); | ||
| 5059 | - context.setFillStyle("red") | ||
| 5060 | - context.setFontSize(18 * unit) | ||
| 5061 | - context.fillText("官方验证", 420 * unit, 690 * unit); | ||
| 5062 | - } | ||
| 5063 | - | ||
| 5064 | - } else { | ||
| 5065 | - var g_path = "../../../images/share/s_gou.png"; | ||
| 5066 | - context.drawImage(g_path, 56 * unit, 670 * unit, 22 * unit, 22 * unit); | ||
| 5067 | - context.setFillStyle("red") | ||
| 5068 | - context.setFontSize(18 * unit) | ||
| 5069 | - context.fillText("正品保证", 84 * unit, 690 * unit); | ||
| 5070 | - | ||
| 5071 | - context.drawImage(g_path, 218 * unit, 670 * unit, 22 * unit, 22 * unit); | ||
| 5072 | - context.setFillStyle("red") | ||
| 5073 | - context.setFontSize(18 * unit) | ||
| 5074 | - context.fillText("纯实体店", 246 * unit, 690 * unit); | ||
| 5075 | - | ||
| 5076 | - context.drawImage(g_path, 388 * unit, 670 * unit, 22 * unit, 22 * unit); | ||
| 5077 | - context.setFillStyle("red") | ||
| 5078 | - context.setFontSize(18 * unit) | ||
| 5079 | - context.fillText("官方验证", 420 * unit, 690 * unit); | ||
| 5080 | - } | ||
| 5081 | - | ||
| 5082 | - | ||
| 5083 | - //---画线--- | ||
| 5084 | - context.setLineWidth(1 * unit) | ||
| 5085 | - context.moveTo(32 * unit, 710 * unit) | ||
| 5086 | - context.lineTo(520 * unit, 710 * unit) | ||
| 5087 | - context.stroke(); | ||
| 5088 | - | ||
| 5089 | - //---文字--- | ||
| 5090 | - context.setFillStyle("black") | ||
| 5091 | - context.setFontSize(22 * unit) | ||
| 5092 | - | ||
| 5093 | - if (type == 0 || type == -1) { | ||
| 5094 | - // 原来start ---> | ||
| 5095 | - context.setFontSize(24 * unit) | ||
| 5096 | - context.fillText(th.data.sto_sele_name_1, 40 * unit, 766 * unit); | ||
| 5097 | - | ||
| 5098 | - context.setFontSize(22 * unit) | ||
| 5099 | - context.fillText("优惠乐翻天,精彩就在你身边", 40 * unit, 806 * unit); | ||
| 5100 | - context.fillText("长按识别二维码,立即开始抢购", 40 * unit, 846 * unit); | ||
| 5101 | - | ||
| 5102 | - } else { | ||
| 5103 | - context.setFontSize(24 * unit) | ||
| 5104 | - context.fillText(th.data.sto_sele_name_1, 40 * unit, 766 * unit); | ||
| 5105 | - context.setFontSize(22 * unit) | ||
| 5106 | - context.fillText("长按识别二维码", 40 * unit, 806 * unit); | ||
| 5107 | - context.fillText("立即开始兑换", 40 * unit, 846 * unit); | ||
| 5108 | - | ||
| 5109 | - } | ||
| 5110 | - | ||
| 5111 | - //---二维吗图--- | ||
| 5112 | - //-- 自定义海报 -- | ||
| 5113 | - if (th.data.poster) { | ||
| 5114 | - var erm_x = parseFloat(th.data.poster.ewm_x) * 2; | ||
| 5115 | - var erm_y = parseFloat(th.data.poster.ewm_y) * 2; | ||
| 5116 | - context.drawImage(vpath, erm_x * unit, erm_y * unit, 136 * unit, 136 * unit); | ||
| 5117 | - } else { | ||
| 5118 | - //---二维吗图--- | ||
| 5119 | - context.drawImage(vpath, 390 * unit, 726 * unit, 136 * unit, 136 * unit); | ||
| 5120 | - } | ||
| 5121 | - ; | ||
| 5122 | - | ||
| 5123 | - break; | ||
| 5124 | - case -12: //秒杀商品的展示 | ||
| 5125 | - //---画线--- | ||
| 5126 | - context.setLineWidth(1 * unit) | ||
| 5127 | - context.moveTo(32 * unit, 670 * unit) | ||
| 5128 | - context.lineTo(520 * unit, 670 * unit) | ||
| 5129 | - context.stroke(); | ||
| 5130 | - | ||
| 5131 | - //画秒杀的图片 | ||
| 5132 | - var miaos_path = '../../../images/share/miao_share.png'; | ||
| 5133 | - context.drawImage(miaos_path, 43 * unit, 700 * unit, 222 * unit, 40 * unit); | ||
| 5134 | - | ||
| 5135 | - context.setFillStyle("black") | ||
| 5136 | - context.setFontSize(24 * unit) | ||
| 5137 | - context.fillText(th.data.sto_sele_name_1, 40 * unit, 786 * unit); | ||
| 5138 | - //---文字--- | ||
| 5139 | - context.setFontSize(22 * unit) | ||
| 5140 | - context.setFillStyle("black") | ||
| 5141 | - context.fillText("特惠好物,限时秒杀", 40 * unit, 826 * unit); | ||
| 5142 | - context.fillText("长按识别二维码,立即开始抢购", 40 * unit, 866 * unit); | ||
| 5143 | - | ||
| 5144 | - | ||
| 5145 | - //---二维吗图--- | ||
| 5146 | - //-- 自定义海报 -- | ||
| 5147 | - if (th.data.poster) { | ||
| 5148 | - var erm_x = parseFloat(th.data.poster.ewm_x) * 2; | ||
| 5149 | - var erm_y = parseFloat(th.data.poster.ewm_y) * 2; | ||
| 5150 | - context.drawImage(vpath, erm_x * unit, erm_y * unit, 135 * unit, 135 * unit); | ||
| 5151 | - } else { | ||
| 5152 | - //---二维吗图--- | ||
| 5153 | - context.drawImage(vpath, 390 * unit, 726 * unit, 135 * unit, 135 * unit); | ||
| 5154 | - } | ||
| 5155 | - break; | ||
| 5156 | - | ||
| 5157 | - case -2: //会员团和商家团的展示 | ||
| 5158 | - //---画线--- | ||
| 5159 | - context.setLineWidth(1 * unit) | ||
| 5160 | - context.moveTo(32 * unit, 670 * unit) | ||
| 5161 | - context.lineTo(520 * unit, 670 * unit) | ||
| 5162 | - context.stroke(); | ||
| 5163 | - //---文字--- | ||
| 5164 | - context.setFillStyle("black") | ||
| 5165 | - context.setFontSize(24 * unit) | ||
| 5166 | - context.fillText(th.data.sto_sele_name_1, 40 * unit, 720 * unit); | ||
| 5167 | - | ||
| 5168 | - //绘制成团图片 | ||
| 5169 | - var ct_img = "../../../images/share/ct_num.png"; | ||
| 5170 | - context.drawImage(ct_img, 40 * unit, 740 * unit, 120 * unit, 30 * unit); | ||
| 5171 | - var ct_num = th.data.prom_act.ct_num; | ||
| 5172 | - context.setFontSize(14 * unit) | ||
| 5173 | - context.font = 'normal'; | ||
| 5174 | - context.setFillStyle("red") | ||
| 5175 | - if (ct_num < 10) { | ||
| 5176 | - context.fillText(ct_num + "人拼团", 92 * unit, 760 * unit); | ||
| 5177 | - } else { | ||
| 5178 | - context.fillText(ct_num + "人拼团", 86 * unit, 760 * unit); | ||
| 5179 | - } | ||
| 5180 | - context.setFontSize(22 * unit) | ||
| 5181 | - context.fillText("已拼" + th.data.prom_act.buy_num + "份", 166 * unit, 763 * unit); | ||
| 5182 | - | ||
| 5183 | - context.setFillStyle("gray") | ||
| 5184 | - context.fillText("快来和我一起拼团吧!", 40 * unit, 806 * unit); | ||
| 5185 | - context.setFillStyle("black") | ||
| 5186 | - context.font = 'normal bold 18px sans-serif'; | ||
| 5187 | - context.setFontSize(21.3 * unit) | ||
| 5188 | - context.fillText("长按识别二维码,立即参团", 40 * unit, 836 * unit); | ||
| 5189 | - | ||
| 5190 | - | ||
| 5191 | - //---二维吗图--- | ||
| 5192 | - //-- 自定义海报 -- | ||
| 5193 | - if (th.data.poster) { | ||
| 5194 | - var erm_x = parseFloat(th.data.poster.ewm_x) * 2; | ||
| 5195 | - var erm_y = parseFloat(th.data.poster.ewm_y) * 2; | ||
| 5196 | - context.drawImage(vpath, erm_x * unit, erm_y * unit, 136 * unit, 136 * unit); | ||
| 5197 | - } else { | ||
| 5198 | - //---二维吗图--- | ||
| 5199 | - context.drawImage(vpath, 390 * unit, 726 * unit, 136 * unit, 136 * unit); | ||
| 5200 | - } | ||
| 5201 | - break | ||
| 5202 | - case -3: //阶梯团的展示 | ||
| 5203 | - //---画线--- | ||
| 5204 | - context.setLineWidth(1 * unit) | ||
| 5205 | - context.moveTo(32 * unit, 670 * unit) | ||
| 5206 | - context.lineTo(520 * unit, 670 * unit) | ||
| 5207 | - context.stroke(); | ||
| 5208 | - //---文字--- | ||
| 5209 | - context.setFillStyle("black") | ||
| 5210 | - context.setFontSize(24 * unit) | ||
| 5211 | - context.fillText(th.data.sto_sele_name_1, 40 * unit, 720 * unit); | ||
| 5212 | - | ||
| 5213 | - //---绘制中间阶梯的价格--- | ||
| 5214 | - var list = th.data.prom_act.ct_rylist; | ||
| 5215 | - for (var i = 0; i < list.length; i++) { | ||
| 5216 | - var item = list[i]; | ||
| 5217 | - var wi = i * 90 * unit; | ||
| 5218 | - context.font = 'normal'; | ||
| 5219 | - context.setFontSize(16 * unit) | ||
| 5220 | - context.setFillStyle("red") | ||
| 5221 | - context.fillText("¥", 40 * unit + wi, 756 * unit); | ||
| 5222 | - context.setFontSize(22 * unit) | ||
| 5223 | - var pri = parseFloat(item.price).toFixed(2); | ||
| 5224 | - context.fillText(pri, 56 * unit + wi, 756 * unit); | ||
| 5225 | - context.setFillStyle("gray") | ||
| 5226 | - context.fillText("满" + item.rynum + "人", 40 * unit + wi, 786 * unit); | ||
| 5227 | - } | ||
| 5228 | - //----------------下面部分---------------- | ||
| 5229 | - // context.setFillStyle("gray") | ||
| 5230 | - // context.fillText("快来和我一起拼团吧!", 40 * unit, 830 * unit); | ||
| 5231 | - // context.setFillStyle("black") | ||
| 5232 | - // context.font = 'normal bold 18px sans-serif'; | ||
| 5233 | - // context.setFontSize(22 * unit) | ||
| 5234 | - // context.fillText("长按识别二维码,立即参团", 40 * unit, 860 * unit); | ||
| 5235 | - //context.setFillStyle("gray") | ||
| 5236 | - context.setFillStyle("black") | ||
| 5237 | - context.fillText("快来和我一起拼团吧!", 40 * unit, 820 * unit); | ||
| 5238 | - //context.font = 'normal bold 18px sans-serif'; | ||
| 5239 | - context.setFontSize(21 * unit) | ||
| 5240 | - context.fillText("长按识别二维码,立即参团", 40 * unit, 850 * unit); | ||
| 5241 | - | ||
| 5242 | - | ||
| 5243 | - //-- 自定义海报 -- | ||
| 5244 | - if (th.data.poster) { | ||
| 5245 | - var erm_x = parseFloat(th.data.poster.ewm_x) * 2; | ||
| 5246 | - var erm_y = parseFloat(th.data.poster.ewm_y) * 2; | ||
| 5247 | - context.drawImage(vpath, erm_x * unit, erm_y * unit, 136 * unit, 136 * unit); | ||
| 5248 | - } else { | ||
| 5249 | - //---二维吗图--- | ||
| 5250 | - context.drawImage(vpath, 390 * unit, 726 * unit, 136 * unit, 136 * unit); | ||
| 5251 | - } | ||
| 5252 | - break | ||
| 5253 | - | ||
| 5254 | - | ||
| 5255 | - case -1: //秒杀商品的展示 | ||
| 5256 | - //---画线--- | ||
| 5257 | - context.setLineWidth(1 * unit) | ||
| 5258 | - context.moveTo(32 * unit, 670 * unit) | ||
| 5259 | - context.lineTo(520 * unit, 670 * unit) | ||
| 5260 | - context.stroke(); | ||
| 5261 | - | ||
| 5262 | - | ||
| 5263 | - context.setFillStyle("black") | ||
| 5264 | - context.setFontSize(24 * unit) | ||
| 5265 | - context.fillText(th.data.sto_sele_name_1, 40 * unit, 744 * unit); | ||
| 5266 | - //---文字--- | ||
| 5267 | - context.setFontSize(22 * unit) | ||
| 5268 | - context.setFillStyle("black") | ||
| 5269 | - context.fillText("长按识别二维码", 40 * unit, 800 * unit); | ||
| 5270 | - context.fillText("立即开始抢购", 40 * unit, 846 * unit); | ||
| 5271 | - | ||
| 5272 | - | ||
| 5273 | - //---二维吗图--- | ||
| 5274 | - //-- 自定义海报 -- | ||
| 5275 | - if (th.data.poster) { | ||
| 5276 | - var erm_x = parseFloat(th.data.poster.ewm_x) * 2; | ||
| 5277 | - var erm_y = parseFloat(th.data.poster.ewm_y) * 2; | ||
| 5278 | - context.drawImage(vpath, erm_x * unit, erm_y * unit, 135 * unit, 135 * unit); | ||
| 5279 | - } else { | ||
| 5280 | - //---二维吗图--- | ||
| 5281 | - context.drawImage(vpath, 390 * unit, 726 * unit, 135 * unit, 135 * unit); | ||
| 5282 | - } | ||
| 5283 | - break; | ||
| 5284 | - | ||
| 5285 | - | ||
| 5286 | - } | ||
| 5287 | - | ||
| 5288 | - | ||
| 5289 | - //--- 如果是自定义海报的时候 --- | ||
| 5290 | - if (type != 0 && type != 1 && type != 2 && type != 3) { | ||
| 5291 | - | ||
| 5292 | - if (th.data.poster && parseInt(th.data.poster.style) == 2) { | ||
| 5293 | - | ||
| 5294 | - //如果显示会员信息的话 | ||
| 5295 | - if (parseInt(th.data.poster.show_headpic)) { | ||
| 5296 | - //获取坐标 | ||
| 5297 | - var x = parseFloat(th.data.poster.head_x) * 2; | ||
| 5298 | - var y = parseFloat(th.data.poster.head_y) * 2; | ||
| 5299 | - //---绘制圆形要放在最后---- | ||
| 5300 | - context.save(); | ||
| 5301 | - context.beginPath(); | ||
| 5302 | - var h_x = x * unit; | ||
| 5303 | - var h_y = y * unit; | ||
| 5304 | - var h_r = 40 * unit; | ||
| 5305 | - var cx = h_x + h_r; | ||
| 5306 | - var cy = h_y + h_r; | ||
| 5307 | - context.arc(cx, cy, h_r, 0, Math.PI * 2, false); | ||
| 5308 | - context.closePath(); | ||
| 5309 | - context.fill(); | ||
| 5310 | - context.clip(); | ||
| 5311 | - context.drawImage(th.data.share_head, h_x, h_y, h_r * 2, h_r * 2); | ||
| 5312 | - context.restore(); | ||
| 5313 | - } | ||
| 5314 | - | ||
| 5315 | - } else { | ||
| 5316 | - //---绘制圆形要放在最后---- | ||
| 5317 | - context.save(); | ||
| 5318 | - context.beginPath(); | ||
| 5319 | - var h_x = 60 * unit; | ||
| 5320 | - var h_y = 24 * unit; | ||
| 5321 | - var h_r = 40 * unit; | ||
| 5322 | - var cx = h_x + h_r; | ||
| 5323 | - var cy = h_y + h_r; | ||
| 5324 | - context.arc(cx, cy, h_r, 0, Math.PI * 2, false); | ||
| 5325 | - context.closePath(); | ||
| 5326 | - context.fill(); | ||
| 5327 | - context.clip(); | ||
| 5328 | - context.drawImage(th.data.share_head, h_x, h_y, h_r * 2, h_r * 2); | ||
| 5329 | - context.restore(); | ||
| 5330 | - } | ||
| 5331 | - | ||
| 5332 | - } | ||
| 5333 | - ; | ||
| 5334 | - | ||
| 5335 | - | ||
| 5336 | - //把画板内容绘制成图片,并回调 画板图片路径 | ||
| 5337 | - context.draw(false, function () { | ||
| 5338 | - setTimeout(function () { | ||
| 5339 | - wx.canvasToTempFilePath({ | ||
| 5340 | - x: 0, | ||
| 5341 | - y: 0, | ||
| 5342 | - width: 750, | ||
| 5343 | - height: 1217, | ||
| 5344 | - destWidth: 1.2 * 750 * 750 / that.data.screenWidth, | ||
| 5345 | - destHeight: 1.2 * 1217 * 750 / that.data.screenWidth, | ||
| 5346 | - canvasId: 'share', | ||
| 5347 | - success: function (res) { | ||
| 5348 | - | ||
| 5349 | - that.setData({ | ||
| 5350 | - shareImgPath: res.tempFilePath, | ||
| 5351 | - canvasHidden: true | ||
| 5352 | - }) | ||
| 5353 | - | ||
| 5354 | - if (!res.tempFilePath) { | ||
| 5355 | - wx.showModal({ | ||
| 5356 | - title: '提示', | ||
| 5357 | - content: '图片绘制中,请稍后重试', | ||
| 5358 | - showCancel: false | ||
| 5359 | - }) | ||
| 5360 | - return false; | ||
| 5361 | - } | ||
| 5362 | - | ||
| 5363 | - // wx.previewImage({ | ||
| 5364 | - // //将图片预览出来 | ||
| 5365 | - // urls: [that.data.shareImgPath] | ||
| 5366 | - // }); | ||
| 5367 | - that.setData({ | ||
| 5368 | - showPoster: true, | ||
| 5369 | - }); | ||
| 5370 | - wx.hideLoading(); | ||
| 5371 | - } | ||
| 5372 | - }) | ||
| 5373 | - }, 500) | ||
| 5374 | - | ||
| 5375 | - }); | ||
| 5376 | - }); | ||
| 5377 | - }, | ||
| 5378 | - fail: function (res) { | ||
| 5379 | - console.log(res); | ||
| 5380 | - wx.hideLoading(); | ||
| 5381 | - | ||
| 5382 | - } | ||
| 5383 | - }); | ||
| 5384 | - }, | ||
| 5385 | - | ||
| 5386 | - | ||
| 5387 | - //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 | ||
| 5388 | - draw_Text: function (ctx, str, leftWidth, initHeight, titleHeight, canvasWidth, unit) { | ||
| 5389 | - var lineWidth = 0; | ||
| 5390 | - var lastSubStrIndex = 0; //每次开始截取的字符串的索引 | ||
| 5391 | - var han = 0; | ||
| 5392 | - for (let i = 0; i < str.length; i++) { | ||
| 5393 | - if (han == 2) return; | ||
| 5394 | - //lineWidth += ctx.measureText(str[i]).width; | ||
| 5395 | - lineWidth += ut.measureText(str[i], 21.3 * unit); | ||
| 5396 | - if (lineWidth > canvasWidth) { | ||
| 5397 | - han++; | ||
| 5398 | - | ||
| 5399 | - if (han == 2) | ||
| 5400 | - ctx.fillText(str.substring(lastSubStrIndex, i) + '...', leftWidth, initHeight); //绘制截取部分 | ||
| 5401 | - else | ||
| 5402 | - ctx.fillText(str.substring(lastSubStrIndex, i), leftWidth, initHeight); | ||
| 5403 | - | ||
| 5404 | - initHeight += 22; //22为字体的高度 | ||
| 5405 | - lineWidth = 0; | ||
| 5406 | - lastSubStrIndex = i; | ||
| 5407 | - titleHeight += 20; | ||
| 5408 | - } | ||
| 5409 | - if (i == str.length - 1) { //绘制剩余部分 | ||
| 5410 | - ctx.fillText(str.substring(lastSubStrIndex, i + 1), leftWidth, initHeight); | ||
| 5411 | - } | ||
| 5412 | - } | ||
| 5413 | - }, | ||
| 5414 | - | ||
| 5415 | - // ----视频图片---- | ||
| 5416 | - // 图片计数器 | ||
| 5417 | - swiperChange: function (e) { | ||
| 5418 | - var that = this; | ||
| 5419 | - if (e.detail.current > 0) { | ||
| 5420 | - that.setData({ | ||
| 5421 | - hiddenn: 1, | ||
| 5422 | - videopicture: 1, | ||
| 5423 | - }) | ||
| 5424 | - } else { | ||
| 5425 | - that.setData({ | ||
| 5426 | - hiddenn: 0, | ||
| 5427 | - videopicture: 0, | ||
| 5428 | - }) | ||
| 5429 | - } | ||
| 5430 | - if (e.detail.source == 'touch') { | ||
| 5431 | - that.setData({ | ||
| 5432 | - current: e.detail.current | ||
| 5433 | - }) | ||
| 5434 | - } | ||
| 5435 | - }, | ||
| 5436 | - | ||
| 5437 | - /*---视频相关--*/ | ||
| 5438 | - videopicture: function (e) { | ||
| 5439 | - var vipi = e.currentTarget.dataset.vipi; | ||
| 5440 | - this.setData({ | ||
| 5441 | - videopicture: vipi, | ||
| 5442 | - swiperCurrent: vipi, | ||
| 5443 | - noon: 0, | ||
| 5444 | - current: 1 | ||
| 5445 | - }); | ||
| 5446 | - }, | ||
| 5447 | - | ||
| 5448 | - videoPlay: function (e) { | ||
| 5449 | - var _index = e.currentTarget.id | ||
| 5450 | - this.setData({ | ||
| 5451 | - _index: _index, | ||
| 5452 | - noon: 1 | ||
| 5453 | - }) | ||
| 5454 | - | ||
| 5455 | - setTimeout(function () { | ||
| 5456 | - //将点击视频进行播放 | ||
| 5457 | - var videoContext = wx.createVideoContext(_index) | ||
| 5458 | - videoContext.play(); | ||
| 5459 | - }, 500) | ||
| 5460 | - | ||
| 5461 | - }, | ||
| 5462 | - | ||
| 5463 | - //加载更多是靠这个函数 | ||
| 5464 | - onReachBottom: function () { | ||
| 5465 | - if (this.data.activeCategoryId == 2) { | ||
| 5466 | - if (!this.data.comments_no_more) this.requestComments_new(); | ||
| 5467 | - } | ||
| 5468 | - | ||
| 5469 | - var goods_list = this.selectComponent("#goods_list"); //组件的id | ||
| 5470 | - if (goods_list) goods_list.get_list(); | ||
| 5471 | - }, | ||
| 5472 | - | ||
| 5473 | - //--获取头像的本地缓存,回调写法-- | ||
| 5474 | - get_head_temp: function (tt, func) { | ||
| 5475 | - var ee = this; | ||
| 5476 | - if (ee.data.share_head) { | ||
| 5477 | - tt(func); | ||
| 5478 | - return false; | ||
| 5479 | - } | ||
| 5480 | - //---获取分享图片的本地地址,头像和商品图片---- | ||
| 5481 | - var path2 = getApp().globalData.userInfo.head_pic; | ||
| 5482 | - if (path2 == "") { | ||
| 5483 | - ee.data.share_head = "../../../images/share/hui_hear_pic.png"; | ||
| 5484 | - tt(func); | ||
| 5485 | - } else { | ||
| 5486 | - path2 = path2.replace("http://thirdwx.qlogo.cn", "https://wx.qlogo.cn"); | ||
| 5487 | - path2 = path2.replace("https://thirdwx.qlogo.cn", "https://wx.qlogo.cn"); | ||
| 5488 | - wx.getImageInfo({ | ||
| 5489 | - src: path2, | ||
| 5490 | - success: function (res) { | ||
| 5491 | - //res.path是网络图片的本地地址 | ||
| 5492 | - ee.data.share_head = res.path; | ||
| 5493 | - tt(func); | ||
| 5494 | - }, | ||
| 5495 | - fail: function (res) { | ||
| 5496 | - ee.data.share_head = "../../../images/share/hui_hear_pic.png"; //分享的图片不能用网络的 | ||
| 5497 | - tt(func); | ||
| 5498 | - } | ||
| 5499 | - }); | ||
| 5500 | - } | ||
| 5501 | - }, | ||
| 5502 | - //--获取商品图片的本地缓存,回调写法-- | ||
| 5503 | - get_goods_temp: function (tt) { | ||
| 5504 | - var ee = this; | ||
| 5505 | - if (ee.data.share_goods_img) { | ||
| 5506 | - tt(); | ||
| 5507 | - return false; | ||
| 5508 | - } | ||
| 5509 | - | ||
| 5510 | - var img_url = ee.data.data.original_img; | ||
| 5511 | - if ((this.data.prom_type == 1 || this.data.prom_type == 6) && this.data.prom_act.share_imgurl) { | ||
| 5512 | - img_url = this.data.iurl + this.data.prom_act.share_imgurl; | ||
| 5513 | - } | ||
| 5514 | - | ||
| 5515 | - //获取商品是分享图信息 | ||
| 5516 | - wx.getImageInfo({ | ||
| 5517 | - src: img_url, | ||
| 5518 | - success: function (res) { | ||
| 5519 | - //res.path是网络图片的本地地址 | ||
| 5520 | - ee.data.share_goods_img = res.path; | ||
| 5521 | - tt(); | ||
| 5522 | - }, | ||
| 5523 | - fail: function (res) { | ||
| 5524 | - ee.data.share_goods_img = "../../../images/share/default_g_img.gif"; //分享的图片不能用网络的 | ||
| 5525 | - tt(); | ||
| 5526 | - } | ||
| 5527 | - }); | ||
| 5528 | - }, | ||
| 5529 | - | ||
| 5530 | - //--外侧评价的点击效果--- | ||
| 5531 | - clik_evaluate: function (e) { | ||
| 5532 | - var val = e.currentTarget.dataset.val; | ||
| 5533 | - this.setData({ | ||
| 5534 | - activeCategoryId: 2, | ||
| 5535 | - activeCategoryId3: val, | ||
| 5536 | - comments: null | ||
| 5537 | - }); | ||
| 5538 | - this.requestComments_new(); | ||
| 5539 | - }, | ||
| 5540 | - | ||
| 5541 | - //--跳转到商品详情页面-- | ||
| 5542 | - go_goods: function (e) { | ||
| 5543 | - var gid = e.currentTarget.dataset.gid; | ||
| 5544 | - var url = "/pages/goods/goodsInfo/goodsInfo?goods_id=" + gid; | ||
| 5545 | - getApp().goto(url); | ||
| 5546 | - }, | ||
| 5547 | - | ||
| 5548 | - //--跳转到支付尾款界面-- | ||
| 5549 | - go_pay_wk: function () { | ||
| 5550 | - var url = "/pages/cart/cart_wk/cart_wk?order_id=" + this.data.wk_order_id; | ||
| 5551 | - getApp().goto(url); | ||
| 5552 | - }, | ||
| 5553 | - | ||
| 5554 | - pop_err_img: function (e) { | ||
| 5555 | - var txt = e.currentTarget.dataset.errorimg; | ||
| 5556 | - var ob = {}; | ||
| 5557 | - ob[txt] = this.data.iurl + "/miniapp/images/default_g_img.gif"; | ||
| 5558 | - this.setData(ob); | ||
| 5559 | - }, | ||
| 5560 | - | ||
| 5561 | - //--调用更新阶梯团的接口-- | ||
| 5562 | - update_jiti: function (id) { | ||
| 5563 | - var th = this; | ||
| 5564 | - //--更新阶梯团-- | ||
| 5565 | - getApp().request.put("/api/weshop/teamgroup/updateTeamOrder/" + os.stoid + "/" + id, { | ||
| 5566 | - success: function (ee) { | ||
| 5567 | - //--等于0是要去支付尾款,接口调用失败,就要去查看参团详情-- | ||
| 5568 | - if (ee.data.code == 0) { | ||
| 5569 | - th.setData({ | ||
| 5570 | - user_order_pt_state: 3, | ||
| 5571 | - }); | ||
| 5572 | - } else if (ee.data.code == -1) { | ||
| 5573 | - th.setData({ | ||
| 5574 | - user_order_pt_state: 2, | ||
| 5575 | - }); | ||
| 5576 | - } | ||
| 5577 | - } | ||
| 5578 | - }) | ||
| 5579 | - }, | ||
| 5580 | - // 选择门店 | ||
| 5581 | - choice_store: function (ee) { | ||
| 5582 | - var th = this; | ||
| 5583 | - var ind = ee.currentTarget.dataset.ind; | ||
| 5584 | - var bconfig = th.data.bconfig; | ||
| 5585 | - | ||
| 5586 | - if (!th.data.only_pk && !th.data.def_pickpu_list) { | ||
| 5587 | - getApp().confirmBox("门店库存不足", null, 25000, !1); | ||
| 5588 | - return false; | ||
| 5589 | - } | ||
| 5590 | - | ||
| 5591 | - if (th.data.only_pk && !th.data.only_pk.length) { | ||
| 5592 | - getApp().confirmBox("门店库存不足", null, 25000, !1); | ||
| 5593 | - return false; | ||
| 5594 | - } | ||
| 5595 | - if (th.data.def_pickpu_list && !th.data.def_pickpu_list.length) { | ||
| 5596 | - getApp().confirmBox("门店库存不足", null, 25000, !1); | ||
| 5597 | - return false; | ||
| 5598 | - } | ||
| 5599 | - | ||
| 5600 | - | ||
| 5601 | - if (bconfig && bconfig.is_sort_storage) { | ||
| 5602 | - wx.getLocation({ | ||
| 5603 | - type: 'gcj02', | ||
| 5604 | - success: function (res) { | ||
| 5605 | - | ||
| 5606 | - th.data.lat = res.latitude; | ||
| 5607 | - th.data.lon = res.longitude; | ||
| 5608 | - th.data.is_get_local_ok = 1; | ||
| 5609 | - th.setData({ | ||
| 5610 | - is_gps: 1 | ||
| 5611 | - }); | ||
| 5612 | - //th.onShow(); | ||
| 5613 | - th.get_sto(th.data.is_normal); | ||
| 5614 | - }, | ||
| 5615 | - fail: function (res) { | ||
| 5616 | - //th.onShow(); | ||
| 5617 | - th.data.is_get_local_ok = 1; | ||
| 5618 | - th.get_sto(th.data.is_normal); | ||
| 5619 | - if (res.errCode == 2) { | ||
| 5620 | - th.setData({ | ||
| 5621 | - is_gps: 0 | ||
| 5622 | - }); | ||
| 5623 | - if (th.data.is_gps == 0) { | ||
| 5624 | - getApp().confirmBox("请开启GPS定位", null, 25000, !1); | ||
| 5625 | - } | ||
| 5626 | - } else { | ||
| 5627 | - th.setData({ | ||
| 5628 | - is_gps: "3" | ||
| 5629 | - }); | ||
| 5630 | - } | ||
| 5631 | - | ||
| 5632 | - } | ||
| 5633 | - }) | ||
| 5634 | - } else { | ||
| 5635 | - th.data.is_get_local_ok = 1; | ||
| 5636 | - th.get_sto(th.data.is_normal); | ||
| 5637 | - } | ||
| 5638 | - | ||
| 5639 | - if (ind != undefined && ind != null) { | ||
| 5640 | - this.setData({ | ||
| 5641 | - open_ind_store: ind, | ||
| 5642 | - store: 1, | ||
| 5643 | - openSpecModal: !1, | ||
| 5644 | - openSpecModal_pt: !1, | ||
| 5645 | - openSpecModal_flash_normal: !1, | ||
| 5646 | - }) | ||
| 5647 | - } else { | ||
| 5648 | - this.setData({ | ||
| 5649 | - store: 1, | ||
| 5650 | - openSpecModal: !1, | ||
| 5651 | - openSpecModal_pt: !1, | ||
| 5652 | - openSpecModal_flash_normal: !1 | ||
| 5653 | - | ||
| 5654 | - }) | ||
| 5655 | - } | ||
| 5656 | - }, | ||
| 5657 | - //关闭选择门店 | ||
| 5658 | - close_popup: function (e) { | ||
| 5659 | - var th = this; | ||
| 5660 | - this.setData({ | ||
| 5661 | - store: 0, | ||
| 5662 | - choice_sort_store: 0, | ||
| 5663 | - sort_store: 0, | ||
| 5664 | - fir_pick_index: 0, | ||
| 5665 | - sec_pick_index: 0 | ||
| 5666 | - }) | ||
| 5667 | - | ||
| 5668 | - var openindstore = this.data.open_ind_store; | ||
| 5669 | - if (openindstore == 1) { | ||
| 5670 | - th.setData({ | ||
| 5671 | - openSpecModal: !0, | ||
| 5672 | - openSpecModal_ind: openindstore, | ||
| 5673 | - }); | ||
| 5674 | - } else if (openindstore == 2) { | ||
| 5675 | - th.setData({ | ||
| 5676 | - openSpecModal: !0, | ||
| 5677 | - openSpecModal_ind: openindstore, | ||
| 5678 | - }); | ||
| 5679 | - } | ||
| 5680 | - else if (openindstore == 4) { //4就是拼团 | ||
| 5681 | - th.setData({ | ||
| 5682 | - openSpecModal_pt: 1, //打开拼团购买界面 | ||
| 5683 | - store: 0, //关闭门店 | ||
| 5684 | - choice_sort_store: 0, //关闭门店2级 | ||
| 5685 | - sort_store: 0, //关闭门店2级 | ||
| 5686 | - }); | ||
| 5687 | - } | ||
| 5688 | - else { | ||
| 5689 | - th.setData({ | ||
| 5690 | - store: 0, | ||
| 5691 | - choice_sort_store: 0, | ||
| 5692 | - sort_store: 0 | ||
| 5693 | - }) | ||
| 5694 | - } | ||
| 5695 | - | ||
| 5696 | - | ||
| 5697 | - }, | ||
| 5698 | - | ||
| 5699 | - //选择更多门店 | ||
| 5700 | - more_store: function () { | ||
| 5701 | - this.setData({ | ||
| 5702 | - sort_store: 1 | ||
| 5703 | - }); | ||
| 5704 | - }, | ||
| 5705 | - sort_store: function () { | ||
| 5706 | - | ||
| 5707 | - }, | ||
| 5708 | - // 返回按钮 | ||
| 5709 | - returns: function () { | ||
| 5710 | - this.setData({ | ||
| 5711 | - sort_store: 0, | ||
| 5712 | - choice_sort_store: 0 | ||
| 5713 | - }); | ||
| 5714 | - }, | ||
| 5715 | - //---选择分类门店--- | ||
| 5716 | - choice_sort_store: function (e) { | ||
| 5717 | - var index = e.currentTarget.dataset.index; | ||
| 5718 | - var region_name = e.currentTarget.dataset.region; | ||
| 5719 | - var item = this.data.all_sto[index]; | ||
| 5720 | - this.setData({ | ||
| 5721 | - region_name: region_name, | ||
| 5722 | - sort_store: 0, | ||
| 5723 | - choice_sort_store: 1, | ||
| 5724 | - sec_sto: item, | ||
| 5725 | - sec_pick_index: 0 | ||
| 5726 | - }); | ||
| 5727 | - }, | ||
| 5728 | - | ||
| 5729 | - choose_for_store_fir: function (e) { | ||
| 5730 | - var index_c = e.currentTarget.dataset.ind; | ||
| 5731 | - var th = this; | ||
| 5732 | - th.setData({ | ||
| 5733 | - fir_pick_index: index_c | ||
| 5734 | - }) | ||
| 5735 | - | ||
| 5736 | - }, | ||
| 5737 | - | ||
| 5738 | - //如果开启线下库存,已经急速库存才会使用 | ||
| 5739 | - async check_the_pick(item, func) { | ||
| 5740 | - var th = this; | ||
| 5741 | - var goodsinfo = th.data.sele_g; | ||
| 5742 | - var erpwareid = goodsinfo.erpwareid; | ||
| 5743 | - var plist = null; | ||
| 5744 | - var lock = 0; | ||
| 5745 | - | ||
| 5746 | - //---如果是活动的时候,同时不是普通购买--- | ||
| 5747 | - if ((th.data.prom_type == 1 || th.data.prom_type == 6 || th.data.prom_type == 4) && !th.data.is_normal) { | ||
| 5748 | - func(); | ||
| 5749 | - return false; | ||
| 5750 | - } | ||
| 5751 | - | ||
| 5752 | - if (this.data.sales_rules != 2) { | ||
| 5753 | - func(); | ||
| 5754 | - } else { | ||
| 5755 | - | ||
| 5756 | - //先读取门店的lock | ||
| 5757 | - await getApp().request.promiseGet("/api/weshop/order/ware/lock/page", { | ||
| 5758 | - data: {store_id: os.stoid, wareId: goodsinfo.goods_id, storageId: item.pickup_id, pageSize: 1000} | ||
| 5759 | - }).then(res => { | ||
| 5760 | - if (res.data.code == 0 && res.data.data.total > 0) { | ||
| 5761 | - for (var i in res.data.data.pageData) | ||
| 5762 | - lock += res.data.data.pageData[i].outQty; | ||
| 5763 | - } | ||
| 5764 | - }) | ||
| 5765 | - //读取线下的门店库存 | ||
| 5766 | - await getApp().request.promiseGet("/api/weshop/goods/getWareStorages", { | ||
| 5767 | - data: {storageNos: item.pickup_no, wareIds: encodeURIComponent(erpwareid), storeId: os.stoid} | ||
| 5768 | - }).then(res => { | ||
| 5769 | - if (res.data.code == 0 && res.data.data.total > 0) { | ||
| 5770 | - plist = res.data.data.pageData[0]; | ||
| 5771 | - } | ||
| 5772 | - }) | ||
| 5773 | - | ||
| 5774 | - if (plist && plist.CanOutQty - lock > 0) { | ||
| 5775 | - item.CanOutQty = plist.CanOutQty - lock; | ||
| 5776 | - func(); | ||
| 5777 | - return false; | ||
| 5778 | - } | ||
| 5779 | - getApp().my_warnning(item.pickup_name + "库存不足!", 0, th); | ||
| 5780 | - | ||
| 5781 | - } | ||
| 5782 | - }, | ||
| 5783 | - | ||
| 5784 | - | ||
| 5785 | - //确定def_pick为选择的门店 | ||
| 5786 | - sure_pick: function (e) { | ||
| 5787 | - var th = this; | ||
| 5788 | - var item = null; | ||
| 5789 | - var openindstore = th.data.open_ind_store; | ||
| 5790 | - | ||
| 5791 | - if (th.data.choice_sort_store == 0) { | ||
| 5792 | - var index = th.data.fir_pick_index; | ||
| 5793 | - if (th.data.is_show_sto_cat == 1) { | ||
| 5794 | - item = th.data.def_pickpu_list[index]; | ||
| 5795 | - } else { | ||
| 5796 | - item = th.data.only_pk[index]; //当没有门店分类的时候 | ||
| 5797 | - } | ||
| 5798 | - | ||
| 5799 | - } else { | ||
| 5800 | - var index = th.data.sec_pick_index; | ||
| 5801 | - item = th.data.sec_sto.s_arr[index]; | ||
| 5802 | - } | ||
| 5803 | - | ||
| 5804 | - if (!th.data.sele_g) return false; | ||
| 5805 | - //判断门店的配送方式是不是匹配 | ||
| 5806 | - var g_distr_type = th.data.sele_g.distr_type; | ||
| 5807 | - if (item.distr_type != 0 && g_distr_type != 0 && item.distr_type != g_distr_type) { | ||
| 5808 | - wx.showToast({ | ||
| 5809 | - title: "门店配送方式不匹配", | ||
| 5810 | - icon: 'none', | ||
| 5811 | - duration: 2000 | ||
| 5812 | - }); | ||
| 5813 | - return false; | ||
| 5814 | - } | ||
| 5815 | - | ||
| 5816 | - //--回调函数的用法-- | ||
| 5817 | - th.check_the_pick(item, function () { | ||
| 5818 | - th.setData({ | ||
| 5819 | - def_pick_store: item, | ||
| 5820 | - sto_sele_name: item.pickup_name, | ||
| 5821 | - sto_sele_id: item.pickup_id, | ||
| 5822 | - sto_sele_distr: item.distr_type, | ||
| 5823 | - store: 0, | ||
| 5824 | - choice_sort_store: 0, | ||
| 5825 | - fir_pick_index: 0 | ||
| 5826 | - }); | ||
| 5827 | - | ||
| 5828 | - switch (openindstore){ | ||
| 5829 | - case 1: | ||
| 5830 | - th.setData({ openSpecModal: !0,openSpecModal_ind: openindstore, }); | ||
| 5831 | - break; | ||
| 5832 | - case 2: | ||
| 5833 | - th.setData({openSpecModal: !0, openSpecModal_ind: openindstore, }); | ||
| 5834 | - break; | ||
| 5835 | - case 4: | ||
| 5836 | - th.setData({ | ||
| 5837 | - openSpecModal_pt: 1, //打开拼团购买界面 | ||
| 5838 | - store: 0, //关闭门店 | ||
| 5839 | - choice_sort_store: 0, //关闭门店2级 | ||
| 5840 | - sort_store: 0, //关闭门店2级 | ||
| 5841 | - }); | ||
| 5842 | - break; | ||
| 5843 | - case 5: | ||
| 5844 | - th.setData({ | ||
| 5845 | - openSpecModal_flash_normal: 1, //打开拼团购买界面 | ||
| 5846 | - store: 0, //关闭门店 | ||
| 5847 | - choice_sort_store: 0, //关闭门店2级 | ||
| 5848 | - sort_store: 0, //关闭门店2级 | ||
| 5849 | - }); | ||
| 5850 | - break; | ||
| 5851 | - default: | ||
| 5852 | - th.setData({ store: 0,choice_sort_store: 0, sort_store: 0}) | ||
| 5853 | - break | ||
| 5854 | - } | ||
| 5855 | - | ||
| 5856 | - /*-- | ||
| 5857 | - if (openindstore == 1) { | ||
| 5858 | - th.setData({ | ||
| 5859 | - openSpecModal: !0, | ||
| 5860 | - openSpecModal_ind: openindstore, | ||
| 5861 | - }); | ||
| 5862 | - } else if (openindstore == 2) { | ||
| 5863 | - th.setData({ | ||
| 5864 | - openSpecModal: !0, | ||
| 5865 | - openSpecModal_ind: openindstore, | ||
| 5866 | - }); | ||
| 5867 | - } | ||
| 5868 | - else if (openindstore == 4) { //4就是拼团 | ||
| 5869 | - th.setData({ | ||
| 5870 | - openSpecModal_pt: 1, //打开拼团购买界面 | ||
| 5871 | - store: 0, //关闭门店 | ||
| 5872 | - choice_sort_store: 0, //关闭门店2级 | ||
| 5873 | - sort_store: 0, //关闭门店2级 | ||
| 5874 | - }); | ||
| 5875 | - } | ||
| 5876 | - else { | ||
| 5877 | - th.setData({ | ||
| 5878 | - store: 0, | ||
| 5879 | - choice_sort_store: 0, | ||
| 5880 | - sort_store: 0 | ||
| 5881 | - }) | ||
| 5882 | - }--*/ | ||
| 5883 | - //如果商品没有其他活动,要取一下线下价格 | ||
| 5884 | - th.get_off_price(); | ||
| 5885 | - }) | ||
| 5886 | - }, | ||
| 5887 | - //---点击二级之后的选择--- | ||
| 5888 | - choose_for_store: function (e) { | ||
| 5889 | - var index_c = e.currentTarget.dataset.ind; | ||
| 5890 | - var th = this; | ||
| 5891 | - th.setData({ | ||
| 5892 | - sec_pick_index: index_c, | ||
| 5893 | - fir_pick_index: index_c | ||
| 5894 | - }) | ||
| 5895 | - | ||
| 5896 | - }, | ||
| 5897 | - //把选择的门店设置成默认的门店def_pick | ||
| 5898 | - set_def_pick: function (e) { | ||
| 5899 | - var th = this; | ||
| 5900 | - var item = null; | ||
| 5901 | - if (th.data.choice_sort_store == 0) { | ||
| 5902 | - var index = th.data.fir_pick_index; | ||
| 5903 | - if (th.data.is_show_sto_cat == 1) { | ||
| 5904 | - item = th.data.def_pickpu_list[index]; | ||
| 5905 | - } else { | ||
| 5906 | - item = th.data.only_pk[index]; //当没有门店分类的时候 | ||
| 5907 | - } | ||
| 5908 | - } else { | ||
| 5909 | - var index = th.data.sec_pick_index; | ||
| 5910 | - item = th.data.sec_sto.s_arr[index]; | ||
| 5911 | - } | ||
| 5912 | - | ||
| 5913 | - //判断门店的配送方式是不是匹配 | ||
| 5914 | - var g_distr_type = th.data.sele_g.distr_type; | ||
| 5915 | - if (item.distr_type != 0 && g_distr_type != 0 && item.distr_type != g_distr_type) { | ||
| 5916 | - wx.showToast({ | ||
| 5917 | - title: "门店配送方式不匹配", | ||
| 5918 | - icon: 'none', | ||
| 5919 | - duration: 2000 | ||
| 5920 | - }); | ||
| 5921 | - return false; | ||
| 5922 | - } | ||
| 5923 | - | ||
| 5924 | - //先设置之前,要判断是不是有库存 | ||
| 5925 | - th.check_the_pick(item, function () { | ||
| 5926 | - var store_id = o.stoid; | ||
| 5927 | - var user_id = getApp().globalData.user_id; | ||
| 5928 | - var def_pickup_id = item.pickup_id; | ||
| 5929 | - | ||
| 5930 | - getApp().request.put('/api/weshop/users/update', { | ||
| 5931 | - data: { | ||
| 5932 | - user_id: user_id, | ||
| 5933 | - def_pickup_id: def_pickup_id | ||
| 5934 | - }, | ||
| 5935 | - success: function (res) { | ||
| 5936 | - if (res.data.code == 0) { | ||
| 5937 | - if (th.data.choice_sort_store == 0) th.setData({ | ||
| 5938 | - fir_pick_index: 0 | ||
| 5939 | - }); | ||
| 5940 | - getApp().globalData.pk_store = item; | ||
| 5941 | - } else { | ||
| 5942 | - //s.showWarning("设置默认门店地址失败", null, 500, !1); | ||
| 5943 | - getApp().my_warnning("设置默认门店地址失败", 0, th) | ||
| 5944 | - } | ||
| 5945 | - | ||
| 5946 | - } | ||
| 5947 | - }); | ||
| 5948 | - | ||
| 5949 | - th.setData({ | ||
| 5950 | - def_pick_store: item, | ||
| 5951 | - sto_sele_name: item.pickup_name, | ||
| 5952 | - sto_sele_id: item.pickup_id, | ||
| 5953 | - sto_sele_distr: item.distr_type, | ||
| 5954 | - store: 0, | ||
| 5955 | - choice_sort_store: 0 | ||
| 5956 | - }); | ||
| 5957 | - | ||
| 5958 | - var openindstore = th.data.open_ind_store; | ||
| 5959 | - if (openindstore == 1) { | ||
| 5960 | - th.setData({ | ||
| 5961 | - openSpecModal: !0, | ||
| 5962 | - openSpecModal_ind: openindstore, | ||
| 5963 | - store: 0, | ||
| 5964 | - choice_sort_store: 0, | ||
| 5965 | - sort_store: 0, | ||
| 5966 | - }); | ||
| 5967 | - } else if (openindstore == 2) { | ||
| 5968 | - th.setData({ | ||
| 5969 | - openSpecModal: !0, | ||
| 5970 | - openSpecModal_ind: openindstore, | ||
| 5971 | - store: 0, | ||
| 5972 | - choice_sort_store: 0, | ||
| 5973 | - sort_store: 0, | ||
| 5974 | - }); | ||
| 5975 | - } | ||
| 5976 | - else if (openindstore == 4) { //4就是拼团 | ||
| 5977 | - th.setData({ | ||
| 5978 | - openSpecModal_pt: 1, //打开拼团购买界面 | ||
| 5979 | - store: 0, //关闭门店 | ||
| 5980 | - choice_sort_store: 0, //关闭门店2级 | ||
| 5981 | - sort_store: 0, //关闭门店2级 | ||
| 5982 | - }); | ||
| 5983 | - } | ||
| 5984 | - | ||
| 5985 | - else { | ||
| 5986 | - th.setData({ | ||
| 5987 | - store: 0, | ||
| 5988 | - choice_sort_store: 0, | ||
| 5989 | - sort_store: 0, | ||
| 5990 | - }) | ||
| 5991 | - } | ||
| 5992 | - | ||
| 5993 | - //如果商品没有其他活动,要取一下线下价格 | ||
| 5994 | - th.get_off_price(); | ||
| 5995 | - | ||
| 5996 | - }) | ||
| 5997 | - }, | ||
| 5998 | - | ||
| 5999 | - wait_for_store_config: function () { | ||
| 6000 | - var th = this; | ||
| 6001 | - //----获取系统参数----- | ||
| 6002 | - getApp().getConfig2(function (e) { | ||
| 6003 | - th.setData({ | ||
| 6004 | - bconfig: e, | ||
| 6005 | - }); | ||
| 6006 | - }) | ||
| 6007 | - var t_time = setInterval(function () { | ||
| 6008 | - if (th.data.bconfig == null) false; | ||
| 6009 | - var e = th.data.bconfig; | ||
| 6010 | - if (e && e.is_sort_storage) { | ||
| 6011 | - wx.getLocation({ | ||
| 6012 | - type: 'gcj02', | ||
| 6013 | - success: function (res) { | ||
| 6014 | - th.data.lat = res.latitude; | ||
| 6015 | - th.data.lon = res.longitude; | ||
| 6016 | - th.data.is_get_local_ok = 1; | ||
| 6017 | - }, | ||
| 6018 | - fail: function (res) { | ||
| 6019 | - if (res.errCode == 2) { | ||
| 6020 | - th.setData({ | ||
| 6021 | - is_gps: 0 | ||
| 6022 | - }); | ||
| 6023 | - if (th.data.is_gps == 0) { | ||
| 6024 | - getApp().confirmBox("请开启GPS定位", null, 10000, !1); | ||
| 6025 | - } | ||
| 6026 | - | ||
| 6027 | - } else { | ||
| 6028 | - th.setData({ | ||
| 6029 | - is_gps: "3" | ||
| 6030 | - }); | ||
| 6031 | - } | ||
| 6032 | - | ||
| 6033 | - th.data.is_get_local_ok = 1; | ||
| 6034 | - } | ||
| 6035 | - }) | ||
| 6036 | - } else { | ||
| 6037 | - th.data.is_get_local_ok = 1; | ||
| 6038 | - } | ||
| 6039 | - clearInterval(t_time); | ||
| 6040 | - }, 500) | ||
| 6041 | - }, | ||
| 6042 | - //显示全部 | ||
| 6043 | - toggleHandler: function (e) { | ||
| 6044 | - var that = this, | ||
| 6045 | - index = e.currentTarget.dataset.index; | ||
| 6046 | - for (var i = 0; i < that.data.comments.length; i++) { | ||
| 6047 | - if (index == i) { | ||
| 6048 | - for (var i = 0; i < that.data.comments.length; i++) { | ||
| 6049 | - that.data.comments[index].auto = true; | ||
| 6050 | - that.data.comments[index].seeMore = false; | ||
| 6051 | - } | ||
| 6052 | - } | ||
| 6053 | - } | ||
| 6054 | - that.setData({ | ||
| 6055 | - comments: that.data.comments | ||
| 6056 | - }) | ||
| 6057 | - }, | ||
| 6058 | - | ||
| 6059 | - //收起更多 | ||
| 6060 | - toggleContent: function (e) { | ||
| 6061 | - var that = this, | ||
| 6062 | - index = e.currentTarget.dataset.index; | ||
| 6063 | - for (var i = 0; i < that.data.comments.length; i++) { | ||
| 6064 | - if (index == i) { | ||
| 6065 | - that.data.comments[index].auto = true; | ||
| 6066 | - that.data.comments[index].seeMore = true; | ||
| 6067 | - } | ||
| 6068 | - } | ||
| 6069 | - that.setData({ | ||
| 6070 | - comments: that.data.comments | ||
| 6071 | - }) | ||
| 6072 | - }, | ||
| 6073 | - | ||
| 6074 | - //--- 获取卡类列表 --- | ||
| 6075 | - getPlusCardType: function (func) { | ||
| 6076 | - var storid = os.stoid; | ||
| 6077 | - var th = this; | ||
| 6078 | - var user = getApp().globalData.userInfo; | ||
| 6079 | - if (!user) return false; | ||
| 6080 | - getApp().request.promiseGet("/api/weshop/plus/vip/mem/bership/list?" + "storeId=" + storid, {}).then(res => { | ||
| 6081 | - var plusCard = res.data.data; | ||
| 6082 | - var arr = [1219, 2089, 3031]; | ||
| 6083 | - var new_arr = new Array(); | ||
| 6084 | - var card_name_map = new Map(); | ||
| 6085 | - | ||
| 6086 | - var list = []; | ||
| 6087 | - for (var i = 0; i < plusCard.length; i++) { | ||
| 6088 | - if ((!user || user.card_field == null || user.card_field == "") && plusCard[i].IsStopBuy == true) continue; | ||
| 6089 | - var name = "card" + plusCard[i].CorrPrice.toLowerCase(); | ||
| 6090 | - card_name_map.set(name, plusCard[i].CardName); | ||
| 6091 | - list.push(plusCard[i]); | ||
| 6092 | - } | ||
| 6093 | - | ||
| 6094 | - var ob = {"card_list": list, "name_map": card_name_map}; | ||
| 6095 | - func(ob); | ||
| 6096 | - }) | ||
| 6097 | - }, | ||
| 6098 | - | ||
| 6099 | - go_plus: function () { | ||
| 6100 | - getApp().goto("/pages/user/plus/plus"); | ||
| 6101 | - }, | ||
| 6102 | - go_card_info: function () { | ||
| 6103 | - getApp().goto("/pages/user/cardinfo/cardinfo"); | ||
| 6104 | - }, | ||
| 6105 | - //-- 根据ID拿出门店 -- | ||
| 6106 | - get_pick_from_list(pid) { | ||
| 6107 | - var all_pick_list = this.data.all_pick_list; | ||
| 6108 | - for (var i in all_pick_list) { | ||
| 6109 | - var item = all_pick_list[i]; | ||
| 6110 | - if (item.pickup_id == pid) { | ||
| 6111 | - return item; | ||
| 6112 | - } | ||
| 6113 | - } | ||
| 6114 | - }, | ||
| 6115 | - //-----显示优惠券的时候情况----- | ||
| 6116 | - show_more_cx: function () { | ||
| 6117 | - if (this.data.is_more_cx) { | ||
| 6118 | - this.setData({is_more_cx: 0}); | ||
| 6119 | - } else { | ||
| 6120 | - this.setData({is_more_cx: 1}); | ||
| 6121 | - } | ||
| 6122 | - }, | ||
| 6123 | - | ||
| 6124 | - //----跳转到搭配购买---- | ||
| 6125 | - go_prom_list: function () { | ||
| 6126 | - | ||
| 6127 | - var url = "../../../packageA/pages/prom_list/prom_list?goods_id=" + this.data.gid; | ||
| 6128 | - var room_id = getApp().globalData.room_id; | ||
| 6129 | - if (room_id && this.data.gid == getApp().globalData.room_goods_id) { | ||
| 6130 | - url += "&room_id=" + room_id; | ||
| 6131 | - } | ||
| 6132 | - wx.navigateTo({url: url,}) | ||
| 6133 | - }, | ||
| 6134 | - | ||
| 6135 | - //---检查有没有优惠活动--- | ||
| 6136 | - check_is_youhui: function (gid, is_nor) { | ||
| 6137 | - var th = this; | ||
| 6138 | - var user_id = getApp().globalData.user_id; | ||
| 6139 | - if (!user_id) user_id = 0; | ||
| 6140 | - //如果是普通购买的时候,要进行调用 | ||
| 6141 | - if (is_nor) { | ||
| 6142 | - getApp().request.get("/api/weshop/goods/getGoodsPromNormal/" + os.stoid + "/" + gid, { | ||
| 6143 | - success: function (res) { | ||
| 6144 | - if (res.data.code == 0) { | ||
| 6145 | - var r_data = res.data.data; | ||
| 6146 | - | ||
| 6147 | - if (r_data.ladderLists) { | ||
| 6148 | - var act_id = r_data.ladderLists[0].form_id; | ||
| 6149 | - //-- 判断会员能不能参与阶梯促销 -- | ||
| 6150 | - getApp().request.promiseGet("/api/weshop/prom/ladderForm/getNew/" + os.stoid + "/" + user_id + "/" + act_id, {}).then(res => { | ||
| 6151 | - if (res.data.code == 0 && res.data.data) { | ||
| 6152 | - var prom_content = ""; | ||
| 6153 | - for (let jj in r_data.ladderLists) { | ||
| 6154 | - if (r_data.ladderLists[jj].discount == 10) { | ||
| 6155 | - prom_content += "第" + (parseInt(jj) + 1) + "件原价,"; | ||
| 6156 | - } else { | ||
| 6157 | - prom_content += "第" + (parseInt(jj) + 1) + "件" + r_data.ladderLists[jj].discount + "折,"; | ||
| 6158 | - } | ||
| 6159 | - } | ||
| 6160 | - prom_content = ut.sub_last(prom_content); | ||
| 6161 | - th.data.prom_type = 10; | ||
| 6162 | - th.data.prom_id = act_id; | ||
| 6163 | - th.setData({ | ||
| 6164 | - jieti_prom: prom_content, | ||
| 6165 | - ladder_act_id: act_id | ||
| 6166 | - }) | ||
| 6167 | - } | ||
| 6168 | - }) | ||
| 6169 | - } | ||
| 6170 | - | ||
| 6171 | - th.setData({ | ||
| 6172 | - prom_goods: r_data.promGoodsLists, | ||
| 6173 | - }) | ||
| 6174 | - th.is_show_more_buy(); | ||
| 6175 | - } | ||
| 6176 | - }, | ||
| 6177 | - }) | ||
| 6178 | - | ||
| 6179 | - } else { | ||
| 6180 | - //调用接口判断订单优惠, | ||
| 6181 | - getApp().request.get("/api/weshop/goods/getGoodsPromList/" + os.stoid + "/" + gid + "/0"+"/"+user_id, { | ||
| 6182 | - success: function (res) { | ||
| 6183 | - if (res.data.code == 0 && res.data.data) { | ||
| 6184 | - var r_data = res.data.data; | ||
| 6185 | - var max = 0, min = 0; | ||
| 6186 | - if (r_data.collocationList) { | ||
| 6187 | - for (var i in r_data.collocationList) { | ||
| 6188 | - if (max == 0) max = r_data.collocationList[i].price; | ||
| 6189 | - if (min == 0) min = r_data.collocationList[i].price; | ||
| 6190 | - | ||
| 6191 | - if (max < parseFloat(r_data.collocationList[i].price)) max = r_data.collocationList[i].price; | ||
| 6192 | - if (min > parseFloat(r_data.collocationList[i].price)) min = r_data.collocationList[i].price; | ||
| 6193 | - } | ||
| 6194 | - r_data.collocationPromList.max = (max + th.data.data.shop_price).toFixed(2); | ||
| 6195 | - r_data.collocationPromList.min = (min + th.data.data.shop_price).toFixed(2); | ||
| 6196 | - } | ||
| 6197 | - | ||
| 6198 | - if (r_data.ladderLists) { | ||
| 6199 | - var act_id = r_data.ladderLists[0].form_id; | ||
| 6200 | - //-- 判断会员能不能参与阶梯促销 -- | ||
| 6201 | - getApp().request.promiseGet("/api/weshop/prom/ladderForm/getNew/" + os.stoid + "/" + user_id + "/" + act_id, {}).then(res => { | ||
| 6202 | - if (res.data.code == 0 && res.data.data) { | ||
| 6203 | - var prom_content = ""; | ||
| 6204 | - for (let jj in r_data.ladderLists) { | ||
| 6205 | - if (r_data.ladderLists[jj].discount == 10) { | ||
| 6206 | - prom_content += "第" + (parseInt(jj) + 1) + "件原价,"; | ||
| 6207 | - } else { | ||
| 6208 | - prom_content += "第" + (parseInt(jj) + 1) + "件" + r_data.ladderLists[jj].discount + "折,"; | ||
| 6209 | - } | ||
| 6210 | - } | ||
| 6211 | - prom_content = ut.sub_last(prom_content); | ||
| 6212 | - th.data.prom_type = 10; | ||
| 6213 | - th.data.prom_id = act_id; | ||
| 6214 | - th.setData({ | ||
| 6215 | - jieti_prom: prom_content, | ||
| 6216 | - ladder_act_id: act_id | ||
| 6217 | - }) | ||
| 6218 | - } | ||
| 6219 | - }) | ||
| 6220 | - } | ||
| 6221 | - | ||
| 6222 | - th.setData({ | ||
| 6223 | - order_prom: r_data.promOrder, | ||
| 6224 | - collocationGoods: r_data.collocationPromList, | ||
| 6225 | - prom_goods: r_data.promGoodsLists, | ||
| 6226 | - }) | ||
| 6227 | - th.is_show_more_buy(); | ||
| 6228 | - } | ||
| 6229 | - } | ||
| 6230 | - }) | ||
| 6231 | - } | ||
| 6232 | - }, | ||
| 6233 | - | ||
| 6234 | - closePoster() { | ||
| 6235 | - this.setData({ | ||
| 6236 | - showPoster: false, | ||
| 6237 | - }); | ||
| 6238 | - }, | ||
| 6239 | - | ||
| 6240 | - // 保存图片到手机 | ||
| 6241 | - savePic() { | ||
| 6242 | - console.log('保存图片'); | ||
| 6243 | - var self = this; | ||
| 6244 | - // 获取用户的当前设置,返回值中有小程序已经向用户请求过的权限 | ||
| 6245 | - this.getSetting().then((res) => { | ||
| 6246 | - // 判断用户是否授权了保存到相册的权限,如果没有发起授权 | ||
| 6247 | - if (!res.authSetting['scope.writePhotosAlbum']) { | ||
| 6248 | - this.authorize().then(() => { | ||
| 6249 | - // 同意授权后保存下载文件 | ||
| 6250 | - this.saveImage(self.data.shareImgPath) | ||
| 6251 | - .then(() => { | ||
| 6252 | - self.setData({ | ||
| 6253 | - showPoster: false | ||
| 6254 | - }); | ||
| 6255 | - }); | ||
| 6256 | - }) | ||
| 6257 | - } else { | ||
| 6258 | - // 如果已经授权,保存下载文件 | ||
| 6259 | - this.saveImage(self.data.shareImgPath) | ||
| 6260 | - .then(() => { | ||
| 6261 | - self.setData({ | ||
| 6262 | - showPoster: false | ||
| 6263 | - }); | ||
| 6264 | - }); | ||
| 6265 | - } | ||
| 6266 | - | ||
| 6267 | - }) | ||
| 6268 | - }, | ||
| 6269 | - | ||
| 6270 | - // 获取用户已经授予了哪些权限 | ||
| 6271 | - getSetting() { | ||
| 6272 | - return new Promise((resolve, reject) => { | ||
| 6273 | - wx.getSetting({ | ||
| 6274 | - success: res => { | ||
| 6275 | - resolve(res) | ||
| 6276 | - } | ||
| 6277 | - }) | ||
| 6278 | - }) | ||
| 6279 | - }, | ||
| 6280 | - | ||
| 6281 | - // 发起首次授权请求 | ||
| 6282 | - authorize() { | ||
| 6283 | - // isFirst 用来记录是否为首次发起授权, | ||
| 6284 | - // 如果首次授权拒绝后,isFirst赋值为1 | ||
| 6285 | - let isFirst = wx.getStorageSync('isFirst') || 0; | ||
| 6286 | - return new Promise((resolve, reject) => { | ||
| 6287 | - wx.authorize({ | ||
| 6288 | - scope: 'scope.writePhotosAlbum', | ||
| 6289 | - // 同意授权 | ||
| 6290 | - success: () => { | ||
| 6291 | - resolve(); | ||
| 6292 | - }, | ||
| 6293 | - // 拒绝授权,这里是用户拒绝授权后的回调 | ||
| 6294 | - fail: res => { | ||
| 6295 | - if (isFirst === 0) { | ||
| 6296 | - wx.setStorageSync('isFirst', 1); | ||
| 6297 | - wx.showToast({ | ||
| 6298 | - title: '保存失败', | ||
| 6299 | - icon: 'none', | ||
| 6300 | - duration: 1000 | ||
| 6301 | - }) | ||
| 6302 | - } else { | ||
| 6303 | - this.showModal(); | ||
| 6304 | - } | ||
| 6305 | - console.log('拒绝授权'); | ||
| 6306 | - reject(); | ||
| 6307 | - } | ||
| 6308 | - }) | ||
| 6309 | - }) | ||
| 6310 | - }, | ||
| 6311 | - | ||
| 6312 | - | ||
| 6313 | - // 保存图片到系统相册 | ||
| 6314 | - saveImage(saveUrl) { | ||
| 6315 | - var self = this; | ||
| 6316 | - return new Promise((resolve, reject) => { | ||
| 6317 | - wx.saveImageToPhotosAlbum({ | ||
| 6318 | - filePath: saveUrl, | ||
| 6319 | - success: (res) => { | ||
| 6320 | - wx.showToast({ | ||
| 6321 | - title: '保存成功', | ||
| 6322 | - duration: 1000, | ||
| 6323 | - }); | ||
| 6324 | - self.setData({ | ||
| 6325 | - showPlaybill: 'true' | ||
| 6326 | - }); | ||
| 6327 | - resolve(); | ||
| 6328 | - }, | ||
| 6329 | - fail: () => { | ||
| 6330 | - wx.showToast({ | ||
| 6331 | - title: '保存失败', | ||
| 6332 | - duration: 1000, | ||
| 6333 | - }); | ||
| 6334 | - } | ||
| 6335 | - }) | ||
| 6336 | - }) | ||
| 6337 | - }, | ||
| 6338 | - | ||
| 6339 | - previewImage(e) { | ||
| 6340 | - this.data.show_prew_img = 1; | ||
| 6341 | - getApp().pre_img(this.data.sele_g.original_img); | ||
| 6342 | - }, | ||
| 6343 | - | ||
| 6344 | - is_show_more_buy: function () { | ||
| 6345 | - var prom_goods = this.data.prom_goods; | ||
| 6346 | - var per_price = this.data.sele_g.shop_price | ||
| 6347 | - if (this.data.card_field && this.data.sele_g[this.data.card_field] > 0) { | ||
| 6348 | - per_price = this.data.sele_g[this.data.card_field]; | ||
| 6349 | - } | ||
| 6350 | - var all_price = per_price * this.data.goodsInputNum; | ||
| 6351 | - var con = null; | ||
| 6352 | - for (var i in prom_goods) { | ||
| 6353 | - var item = prom_goods[i]; | ||
| 6354 | - if (item.prom_type == 1) { | ||
| 6355 | - if (item.condition > this.data.goodsInputNum) { | ||
| 6356 | - con = item; | ||
| 6357 | - con.need = (item.condition - this.data.goodsInputNum).toFixed(2) + "件"; | ||
| 6358 | - break; | ||
| 6359 | - } | ||
| 6360 | - } else { | ||
| 6361 | - if (item.condition > all_price) { | ||
| 6362 | - con = item; | ||
| 6363 | - con.need = (item.condition - all_price).toFixed(2) + "元"; | ||
| 6364 | - break; | ||
| 6365 | - } | ||
| 6366 | - } | ||
| 6367 | - } | ||
| 6368 | - | ||
| 6369 | - this.setData({hui_condition: con}); | ||
| 6370 | - | ||
| 6371 | - }, | ||
| 6372 | - | ||
| 6373 | - //-- 积分购 -- | ||
| 6374 | - go_pay_integral: function () { | ||
| 6375 | - this.data.g_buy_num = new Map(); | ||
| 6376 | - this.get_sto(0) | ||
| 6377 | - this.setData({openSpecModal_inte: 1, goodsInputNum: 1}); | ||
| 6378 | - | ||
| 6379 | - | ||
| 6380 | - }, | ||
| 6381 | - //-- 积分购普通购买 -- | ||
| 6382 | - go_pay_integral_normal: function () { | ||
| 6383 | - | ||
| 6384 | - this.data.g_buy_num = new Map(); | ||
| 6385 | - var th = this; | ||
| 6386 | - if (th.data.sku_g_pt) { | ||
| 6387 | - this.get_sto(1) | ||
| 6388 | - this.setData({openSpecModal_inte_normal: 1}); | ||
| 6389 | - } else { | ||
| 6390 | - th.get_sto(1); | ||
| 6391 | - th.get_sku(o.stoid, th.data.data, th.data.gid, 1, function () { | ||
| 6392 | - th.setData({ | ||
| 6393 | - is_normal: 1, | ||
| 6394 | - openSpecModal_inte_normal: 1 | ||
| 6395 | - }); | ||
| 6396 | - }); | ||
| 6397 | - } | ||
| 6398 | - this.check_is_youhui(th.data.gid, 1); | ||
| 6399 | - }, | ||
| 6400 | - | ||
| 6401 | - closeSpecModal_inte: function () { | ||
| 6402 | - this.setData({openSpecModal_inte: 0}); | ||
| 6403 | - }, | ||
| 6404 | - closeSpecModal_inte_normal: function () { | ||
| 6405 | - this.setData({openSpecModal_inte_normal: 0}); | ||
| 6406 | - //要进行还原 | ||
| 6407 | - this.get_sto(); | ||
| 6408 | - this.setData({ | ||
| 6409 | - sele_g: this.data.data, | ||
| 6410 | - gid: this.data.data.goods_id | ||
| 6411 | - }) | ||
| 6412 | - | ||
| 6413 | - this.sele_spec_chech_activity(); | ||
| 6414 | - }, | ||
| 6415 | - | ||
| 6416 | - addCart_inte: function (t) { | ||
| 6417 | - this.add_cart_func_inte(t); | ||
| 6418 | - }, | ||
| 6419 | - | ||
| 6420 | - onShareTimeline() { | ||
| 6421 | - getApp().globalData.no_clear=1; | ||
| 6422 | - var store_name = getApp().globalData.config ? getApp().globalData.config.store_name : ''; | ||
| 6423 | - if (!store_name) | ||
| 6424 | - store_name = getApp().globalData.setting.appName; | ||
| 6425 | - return { | ||
| 6426 | - title: this.data.data.goods_name + '-' + store_name, | ||
| 6427 | - imageUrl: this.data.gallery[0].image_url, | ||
| 6428 | - } | ||
| 6429 | - }, | ||
| 6430 | - | ||
| 6431 | - | ||
| 6432 | - clickCollapse() { | ||
| 6433 | - this.setData({ | ||
| 6434 | - flag: !this.data.flag, | ||
| 6435 | - }) | ||
| 6436 | - }, | ||
| 6437 | - | ||
| 6438 | - clickShare() { | ||
| 6439 | - if(!getApp().globalData.user_id){ | ||
| 6440 | - getApp().goto("/pages/togoin/togoin"); | ||
| 6441 | - return false; | ||
| 6442 | - } | ||
| 6443 | - this.setData({ | ||
| 6444 | - share_hidden: true, | ||
| 6445 | - }); | ||
| 6446 | - }, | ||
| 6447 | - | ||
| 6448 | - send() { | ||
| 6449 | - this.setData({ | ||
| 6450 | - share_hidden: false, | ||
| 6451 | - }); | ||
| 6452 | - }, | ||
| 6453 | - | ||
| 6454 | - cancel() { | ||
| 6455 | - this.setData({ | ||
| 6456 | - share_hidden: false, | ||
| 6457 | - }); | ||
| 6458 | - }, | ||
| 6459 | - | ||
| 6460 | - //积分购和拼团的普通购买的的时候,要判断有没有全场优惠活动 | ||
| 6461 | - check_nor_promgood(goods_id, back) { | ||
| 6462 | - getApp().request.get("/api/weshop/goods/getGoodsPromNormal/" + os.stoid + "/" + goods_id, { | ||
| 6463 | - success: function (res) { | ||
| 6464 | - if (res.data.code == 0 && res.data.data && res.data.data.promGoodsLists && res.data.data.promGoodsLists.length > 0) { | ||
| 6465 | - var obj = { | ||
| 6466 | - act_id: res.data.data.promGoodsLists[0].prom_id, | ||
| 6467 | - } | ||
| 6468 | - back(obj); | ||
| 6469 | - } else { | ||
| 6470 | - back(0) | ||
| 6471 | - } | ||
| 6472 | - } | ||
| 6473 | - }) | ||
| 6474 | - }, | ||
| 6475 | - | ||
| 6476 | - go_zh: function (e) { | ||
| 6477 | - var id = e.currentTarget.dataset.id; | ||
| 6478 | - getApp().goto("/packageB/pages/zuhegou/index/index?id=" + id); | ||
| 6479 | - }, | ||
| 6480 | - | ||
| 6481 | - check_zh_acting: function (func) { | ||
| 6482 | - var isok = 1, item = this.data.sele_g; | ||
| 6483 | - //如果有组合购 | ||
| 6484 | - var url = "/api/weshop/prom/zhbuy/get/" + os.stoid + "/" + item.prom_id + "/" + getApp().globalData.user_id; | ||
| 6485 | - getApp().request.promiseGet(url, {}).then(res => { | ||
| 6486 | - if (res.data.code == 0 && res.data.data) { | ||
| 6487 | - if (res.data.data.is_show != 1) { | ||
| 6488 | - isok = 0; | ||
| 6489 | - } | ||
| 6490 | - //如果活动已经结束 | ||
| 6491 | - if (res.data.data.is_end == 1) { | ||
| 6492 | - isok = 0; | ||
| 6493 | - } | ||
| 6494 | - //已经结束 | ||
| 6495 | - if (ut.gettimestamp() > res.data.data.end_time) { | ||
| 6496 | - isok = 0; | ||
| 6497 | - } | ||
| 6498 | - //还未开始 | ||
| 6499 | - if (ut.gettimestamp() < res.data.data.start_time) { | ||
| 6500 | - isok = 0; | ||
| 6501 | - } | ||
| 6502 | - | ||
| 6503 | - } else { | ||
| 6504 | - //未找到商品的活动 | ||
| 6505 | - isok = 0; | ||
| 6506 | - } | ||
| 6507 | - item.act = res.data.data; | ||
| 6508 | - func(isok); | ||
| 6509 | - }) | ||
| 6510 | - }, | ||
| 6511 | - | ||
| 6512 | - //获取更多秒杀 | ||
| 6513 | - get_more_flahs: async function (func) { | ||
| 6514 | - var f_more = false; | ||
| 6515 | - var user_id = getApp().globalData.user_id; | ||
| 6516 | - if (!user_id) user_id = 0; | ||
| 6517 | - | ||
| 6518 | - var url = "/api/weshop/goods/listSkuFlash?store_id=" + os.stoid + "&goods_id=" + this.data.data.goods_id + "&user_id=" + user_id; | ||
| 6519 | - //获取秒杀的多规格 | ||
| 6520 | - await getApp().request.promiseGet(url, {}).then(res => { | ||
| 6521 | - if (res.data.code == 0 && res.data.data && res.data.data.length > 0) { | ||
| 6522 | - f_more = res.data.data; | ||
| 6523 | - } | ||
| 6524 | - }) | ||
| 6525 | - if (!f_more) { | ||
| 6526 | - func(false); | ||
| 6527 | - return false; | ||
| 6528 | - } | ||
| 6529 | - //-- 秒杀的价格要更新 -- | ||
| 6530 | - for (let i in f_more) { | ||
| 6531 | - | ||
| 6532 | - let item = f_more[i]; | ||
| 6533 | - f_more[i].prom_id = item.act_id; | ||
| 6534 | - f_more[i].prom_type = 1; | ||
| 6535 | - if (item.goods_id == this.data.data.goods_id) { | ||
| 6536 | - continue; | ||
| 6537 | - } | ||
| 6538 | - var url = "/api/ms/flash_sale/getNew/" + os.stoid + "/" + user_id + "/" + item.act_id; | ||
| 6539 | - await getApp().request.promiseGet(url, {}).then(rs => { | ||
| 6540 | - if (rs.data.code == 0) { | ||
| 6541 | - f_more[i].price = rs.data.data.user_price; | ||
| 6542 | - | ||
| 6543 | - } | ||
| 6544 | - }) | ||
| 6545 | - } | ||
| 6546 | - func(f_more); | ||
| 6547 | - | ||
| 6548 | - }, | ||
| 6549 | - | ||
| 6550 | - //-- 判断是否有秒杀 -- | ||
| 6551 | - check_has_flash: function () { | ||
| 6552 | - var th = this; | ||
| 6553 | - var url = "/api/weshop/activitylist/getGoodActInfo"; | ||
| 6554 | - var user_id = getApp().globalData.user_id; | ||
| 6555 | - if (!user_id) user_id = 0; | ||
| 6556 | - | ||
| 6557 | - var req_data = { | ||
| 6558 | - store_id: os.stoid, goodsidlist: this.data.data.goods_id, is_detail: 1, user_id: user_id | ||
| 6559 | - }; | ||
| 6560 | - //获取秒杀的多规格 | ||
| 6561 | - getApp().request.promiseGet(url, {data: req_data}).then(async function (res) { | ||
| 6562 | - if (res.data.code == 0 && res.data.data && res.data.data.length) { | ||
| 6563 | - var arr_data = res.data.data; | ||
| 6564 | - var new_arr = []; | ||
| 6565 | - for (let i in arr_data) { | ||
| 6566 | - let item = arr_data[i]; | ||
| 6567 | - //找不到活动要剔除 | ||
| 6568 | - if (!item.act_name) continue; | ||
| 6569 | - if (item.prom_type != 1) continue; | ||
| 6570 | - new_arr.push(item); | ||
| 6571 | - } | ||
| 6572 | - | ||
| 6573 | - if (new_arr.length == 1) { | ||
| 6574 | - th.data.prom_id = new_arr[0].act_id; | ||
| 6575 | - th.data.prom_type = new_arr[0].prom_type; | ||
| 6576 | - } | ||
| 6577 | - | ||
| 6578 | - th.setData({more_flash: new_arr}); | ||
| 6579 | - } | ||
| 6580 | - }) | ||
| 6581 | - }, | ||
| 6582 | - | ||
| 6583 | - //-- 跳转到秒杀商品详情页 -- | ||
| 6584 | - go_more_flash: function (e) { | ||
| 6585 | - var prom_id = e.currentTarget.dataset.id; | ||
| 6586 | - var goods_id = this.data.data.goods_id; | ||
| 6587 | - var url = "/pages/goods/goodsInfo/goodsInfo?goods_id=" + goods_id + "&prom_id=" + prom_id + "&prom_type=1"; | ||
| 6588 | - getApp().goto(url); | ||
| 6589 | - }, | ||
| 6590 | - | ||
| 6591 | - close_pop_more: function () { | ||
| 6592 | - this.setData({is_pop_more: 0}) | ||
| 6593 | - }, | ||
| 6594 | - | ||
| 6595 | - con_weixin: function () { | ||
| 6596 | - getApp().con_wx(this); | ||
| 6597 | - }, | ||
| 6598 | - | ||
| 6599 | - get_normal(gid){ | ||
| 6600 | - this.setData({ | ||
| 6601 | - prom_type: 0, | ||
| 6602 | - isshow: 1, | ||
| 6603 | - }); | ||
| 6604 | - this.get_sku(os.stoid, this.data.data, gid); | ||
| 6605 | - this.get_sto(); | ||
| 6606 | - this.check_is_youhui(gid, 1); | ||
| 6607 | - this.data.is_normal = 1; | ||
| 6608 | - }, | ||
| 6609 | - | ||
| 6610 | - | ||
| 6611 | - // 促销 -> 送礼包 -> 查看详情 | ||
| 6612 | - viewLbDetails(e) { | ||
| 6613 | - let id = e.currentTarget.dataset.id; // 获取礼包id | ||
| 6614 | - let flag = e.currentTarget.dataset.flag; | ||
| 6615 | - let url = ''; | ||
| 6616 | - if(flag == 1) { // flag =1 控制跳转到专享礼包 | ||
| 6617 | - url = `/pages/giftpack/giftpacklist/giftpacklist?lbId=${id}&flag=1`; | ||
| 6618 | - } else { | ||
| 6619 | - url = `/packageA/pages/myGiftDetails/myGiftDetails?btn=0&index=0&id=${id}`; // btn=0 控制跳转到的页面不显示按钮 | ||
| 6620 | - }; | ||
| 6621 | - // console.log('myurl', url); | ||
| 6622 | - getApp().goto(url); | ||
| 6623 | - }, | ||
| 6624 | - | ||
| 6625 | - | ||
| 6626 | - | ||
| 6627 | - go_more_ladder: function (e) { | ||
| 6628 | - var prom_id = e.currentTarget.dataset.id; | ||
| 6629 | - getApp().goto("/pages/goods/goodsList/goodsList?ladder_id=" + prom_id); | ||
| 6630 | - }, | ||
| 6631 | - | ||
| 6632 | - getHistoryBuy() { | ||
| 6633 | - let _this = this; | ||
| 6634 | - let req_data = { | ||
| 6635 | - store_id: os.stoid, | ||
| 6636 | - goods_id: this.data.gid, | ||
| 6637 | - pay_status: 1, | ||
| 6638 | - rndid: 1 | ||
| 6639 | - }; | ||
| 6640 | - getApp().request.promiseGet('/api/weshop/ordergoods/list', { | ||
| 6641 | - data: req_data, | ||
| 6642 | - }) | ||
| 6643 | - .then(res => { | ||
| 6644 | - if (t.ajax_ok(res)) { | ||
| 6645 | - _this.setData({ | ||
| 6646 | - historyBuyInfo: res.data.data.pageData, | ||
| 6647 | - }) | ||
| 6648 | - } | ||
| 6649 | - }) | ||
| 6650 | - }, | ||
| 6651 | - | ||
| 6652 | - //-- 检验商品的活动情况 -- | ||
| 6653 | - check_gd_prom_new: function (func) { | ||
| 6654 | - var th = this; | ||
| 6655 | - var user_id = getApp().globalData.user_id; | ||
| 6656 | - if (!user_id) user_id = 0; | ||
| 6657 | - | ||
| 6658 | - var url = '/api/weshop/activitylist/listGoodActInfo2'; | ||
| 6659 | - var req_d = { | ||
| 6660 | - "store_id": os.stoid, | ||
| 6661 | - "goods_id": this.data.gid, | ||
| 6662 | - "user_id": user_id, | ||
| 6663 | - } | ||
| 6664 | - getApp().request.get(url, { | ||
| 6665 | - data: req_d, | ||
| 6666 | - success: function (e) { | ||
| 6667 | - if (e.data.code == 0 && e.data.data && e.data.data.length > 0) { | ||
| 6668 | - var arr = e.data.data; | ||
| 6669 | - var arr2 = arr.filter(function (e) { | ||
| 6670 | - return e.s_time < ut.gettimestamp(); | ||
| 6671 | - }) | ||
| 6672 | - //-- 如果只有一个活动的话 -- | ||
| 6673 | - if (arr.length == 1) { | ||
| 6674 | - th.data.prom_type = arr[0].prom_type; | ||
| 6675 | - th.data.prom_id = arr[0].act_id; | ||
| 6676 | - } | ||
| 6677 | - //-- 如果只有一个进行中的活动的话 -- | ||
| 6678 | - else if (arr2.length == 1) { | ||
| 6679 | - th.data.prom_type = arr2[0].prom_type; | ||
| 6680 | - th.data.prom_id = arr2[0].act_id; | ||
| 6681 | - } | ||
| 6682 | - } | ||
| 6683 | - //-- 调用回调 -- | ||
| 6684 | - func(); | ||
| 6685 | - } | ||
| 6686 | - }); | ||
| 6687 | - }, | ||
| 6688 | - | ||
| 6689 | - //-- 秒杀的普通购买 -- | ||
| 6690 | - openSpecModel_Nor: function () { | ||
| 6691 | - this.data.g_buy_num = new Map(); | ||
| 6692 | - var th = this; | ||
| 6693 | - this.setData({open_ind_store: 5, goodsInputNum: 1});//拼团直接给4 | ||
| 6694 | - if (th.data.sku_g_pt) { | ||
| 6695 | - this.get_sto(1) | ||
| 6696 | - this.setData({openSpecModal_flash_normal: 1}); | ||
| 6697 | - } else { | ||
| 6698 | - th.get_sto(1); | ||
| 6699 | - th.get_sku(o.stoid, th.data.data, th.data.gid, 1, function () { | ||
| 6700 | - th.setData({ | ||
| 6701 | - openSpecModal_flash_normal: 1 | ||
| 6702 | - }); | ||
| 6703 | - }); | ||
| 6704 | - } | ||
| 6705 | - this.check_is_youhui(th.data.gid, 1); | ||
| 6706 | - }, | ||
| 6707 | - | ||
| 6708 | - closeSpecModal_flash_normal: function () { | ||
| 6709 | - this.setData({openSpecModal_flash_normal: 0}); | ||
| 6710 | - }, | ||
| 6711 | - | ||
| 6712 | - | ||
| 6713 | - // 预览海报 | ||
| 6714 | - previewPoster() { | ||
| 6715 | - getApp().globalData.no_clear=1; | ||
| 6716 | - wx.previewImage({ | ||
| 6717 | - current: this.data.shareImgPath, // 当前显示图片的http链接 | ||
| 6718 | - urls: [this.data.shareImgPath] ,// 需要预览的图片http链接列表 | ||
| 6719 | - }); | ||
| 6720 | - }, | ||
| 6721 | - | ||
| 6722 | - screenChange:function (e) { | ||
| 6723 | - let fullScreen = e.detail.fullScreen //值true为进入全屏,false为退出全屏 | ||
| 6724 | - if (fullScreen ){ //退出全屏 | ||
| 6725 | - getApp().globalData.no_clear=1; | ||
| 6726 | - this.data.show_video=1; | ||
| 6727 | - } | ||
| 6728 | - }, | ||
| 6729 | - | ||
| 6730 | - click_contact:function () { | ||
| 6731 | - getApp().globalData.no_clear=1; | ||
| 6732 | - }, | ||
| 6733 | - | ||
| 6734 | - //打开客服操作菜单 | ||
| 6735 | - openCS() { | ||
| 6736 | - // 判断会员状态 | ||
| 6737 | - let user_info = getApp().globalData.userInfo; | ||
| 6738 | - if (user_info == null || user_info.mobile == undefined || user_info.mobile == '' || user_info.mobile == null) { | ||
| 6739 | - wx.navigateTo({ | ||
| 6740 | - url: '/pages/togoin/togoin', | ||
| 6741 | - }) | ||
| 6742 | - return false; | ||
| 6743 | - }; | ||
| 6744 | - // csType/在线客服设置: | ||
| 6745 | - // 0关闭(如果有设置热线电话,则显示拨打热线电话)、 | ||
| 6746 | - // 1小程序客服、 | ||
| 6747 | - // 2企业微信客服 | ||
| 6748 | - if(this.data.sys_switch) { | ||
| 6749 | - let csType = this.data.sys_switch.weapp_customertype; | ||
| 6750 | - if(csType == 0) { | ||
| 6751 | - // 拨打电话号码 | ||
| 6752 | - this.contactService(); | ||
| 6753 | - } else { | ||
| 6754 | - this.getTel() | ||
| 6755 | - .then(() => { | ||
| 6756 | - self.setData({ | ||
| 6757 | - hiddenCS: false, | ||
| 6758 | - }); | ||
| 6759 | - }); | ||
| 6760 | - }; | ||
| 6761 | - }; | ||
| 6762 | - | ||
| 6763 | - }, | ||
| 6764 | - | ||
| 6765 | - //关闭客服操作菜单 | ||
| 6766 | - closeCS() { | ||
| 6767 | - this.setData({ | ||
| 6768 | - hiddenCS: true, | ||
| 6769 | - }); | ||
| 6770 | - }, | ||
| 6771 | - | ||
| 6772 | - | ||
| 6773 | - | ||
| 6774 | - | ||
| 6775 | - | ||
| 6776 | - | ||
| 6777 | - | ||
| 6778 | - | ||
| 6779 | -}) | 1 | +var t = require("../../../utils/util.js"), |
| 2 | + ut = t, | ||
| 3 | + e = require("../../../utils/common.js"), | ||
| 4 | + a = require("../../../utils/wxParse/wxParse.js"), | ||
| 5 | + s = getApp(), | ||
| 6 | + i = s.request, | ||
| 7 | + rq = i, | ||
| 8 | + oo = s.globalData, | ||
| 9 | + o = s.globalData.setting, | ||
| 10 | + os = o; | ||
| 11 | + | ||
| 12 | +let self = null; | ||
| 13 | + | ||
| 14 | +//评价加载更多 | ||
| 15 | +var more = function (e) { | ||
| 16 | + return e && e.__esModule ? e : { | ||
| 17 | + default: e | ||
| 18 | + }; | ||
| 19 | +}(require("../../../utils/LoadMore.js")), | ||
| 20 | + n = new more.default(); | ||
| 21 | +var utils = require('../../../utils/util.js'); | ||
| 22 | +var regeneratorRuntime = require('../../../utils/runtime.js'); | ||
| 23 | +const { app } = require("../../../utils/common.js"); | ||
| 24 | + | ||
| 25 | +Page({ | ||
| 26 | + data: { | ||
| 27 | + start_stop: 2, //秒杀开始 结束 的控制(1正在进行,2即将开始) | ||
| 28 | + color_type: 0, //线条控制 | ||
| 29 | + color_type_one: 0, | ||
| 30 | + color_type_two: 1, | ||
| 31 | + is_no_plus:1, | ||
| 32 | + gid: "", | ||
| 33 | + stoid: o.stoid, | ||
| 34 | + url: o.url, | ||
| 35 | + resourceUrl: o.h5_url, //公众号那边的图片文件域名 | ||
| 36 | + iurl: o.imghost, | ||
| 37 | + defaultAvatar: o.resourceUrl + "/static/images/user68.jpg", | ||
| 38 | + | ||
| 39 | + data: null, | ||
| 40 | + content: "", //商品详情 | ||
| 41 | + comments: null, //商品评论 | ||
| 42 | + c_curr_p: 1, //评论分页 | ||
| 43 | + com_num: 0, //评论人数 | ||
| 44 | + gallery: null, //图片滚动 | ||
| 45 | + is_collect: 0, | ||
| 46 | + collect_id: 0, | ||
| 47 | + cartGoodsNum: 0, | ||
| 48 | + specSelect: 0, | ||
| 49 | + optionItemId: 0, | ||
| 50 | + goodsInputNum: 1, | ||
| 51 | + openSpecModal: !1, | ||
| 52 | + openSpecModal_pt: !1, //拼单的弹起, | ||
| 53 | + openPromModal: !1, | ||
| 54 | + activeCategoryId: 0, | ||
| 55 | + supportPageScroll: !1, | ||
| 56 | + address: { | ||
| 57 | + address: "", | ||
| 58 | + district: 0 | ||
| 59 | + }, | ||
| 60 | + shipping: "", | ||
| 61 | + shippingCost: 0, | ||
| 62 | + enterAddressPage: !1, | ||
| 63 | + categories: [{ | ||
| 64 | + name: "商品", | ||
| 65 | + id: 0 | ||
| 66 | + }, { | ||
| 67 | + name: "详情", | ||
| 68 | + id: 1 | ||
| 69 | + }, { | ||
| 70 | + name: "评价", | ||
| 71 | + id: 2 | ||
| 72 | + }], | ||
| 73 | + activeCategoryId2: 0, | ||
| 74 | + categories2: [{ | ||
| 75 | + name: "商品详情", | ||
| 76 | + id: 0 | ||
| 77 | + }, { | ||
| 78 | + name: "规格参数", | ||
| 79 | + id: 1 | ||
| 80 | + }], | ||
| 81 | + activeCategoryId3: 1, | ||
| 82 | + categories3: [{ | ||
| 83 | + name: "全部", | ||
| 84 | + id: 1, | ||
| 85 | + num: 0 | ||
| 86 | + }, | ||
| 87 | + { | ||
| 88 | + name: "有图", | ||
| 89 | + id: 5, | ||
| 90 | + num: 0 | ||
| 91 | + }, | ||
| 92 | + | ||
| 93 | + { | ||
| 94 | + name: "好评", | ||
| 95 | + id: 2, | ||
| 96 | + num: 0 | ||
| 97 | + }, { | ||
| 98 | + name: "中评", | ||
| 99 | + id: 3, | ||
| 100 | + num: 0 | ||
| 101 | + }, { | ||
| 102 | + name: "差评", | ||
| 103 | + id: 4, | ||
| 104 | + num: 0 | ||
| 105 | + }, | ||
| 106 | + ], | ||
| 107 | + | ||
| 108 | + select: { | ||
| 109 | + price: 0, | ||
| 110 | + stock: 0, | ||
| 111 | + specName: "", | ||
| 112 | + activity: null | ||
| 113 | + }, | ||
| 114 | + | ||
| 115 | + //已选的商品(属性) | ||
| 116 | + sele_g_spec_name: '', | ||
| 117 | + sele_g_id: '', | ||
| 118 | + sele_g: null, | ||
| 119 | + //门店相关 | ||
| 120 | + ismend: 0, | ||
| 121 | + is_sec_mend: 0, | ||
| 122 | + sto_sele_name: "", //选中的门店名称 | ||
| 123 | + sto_sele_id: "", //选中的门店id | ||
| 124 | + sto_sele_distr: "", //选择的门店的配送方式 | ||
| 125 | + is_show_sto_cat: 1, //是否显示门店分类 | ||
| 126 | + only_pk: null, | ||
| 127 | + all_sto: null, | ||
| 128 | + sec_sto: null, //选择了的门店分类 | ||
| 129 | + pickpu_list: null, //读出的所有门店list | ||
| 130 | + def_pickpu_list: null, //一开始5个门店list | ||
| 131 | + sec_pick_index: 0, //第二级门店选择ID | ||
| 132 | + fir_pick_index: 0, //第一级门店选择ID | ||
| 133 | + all_pick_list: null,//所有的门店先记录起来 | ||
| 134 | + //同一条形码的所有商品 | ||
| 135 | + sku_g: null, | ||
| 136 | + sku_g_pt: null, //---拼单的普通购买--- | ||
| 137 | + //联系电话 | ||
| 138 | + mobile: '', | ||
| 139 | + //分类,品牌,国别名称 | ||
| 140 | + cat_name: '', | ||
| 141 | + brand_name: '', | ||
| 142 | + nation_name: '', | ||
| 143 | + | ||
| 144 | + //商品的活动类型 0普通 1秒杀 2团购 3优惠 4 积分购 6拼单 | ||
| 145 | + prom_type: 0, | ||
| 146 | + prom_time_text: "", | ||
| 147 | + prom_price: null, | ||
| 148 | + prom_buy_limit: 0, | ||
| 149 | + djs: null, | ||
| 150 | + prom_st: 0, | ||
| 151 | + prom_r_null: 0, | ||
| 152 | + prom_end_time: null, | ||
| 153 | + prom_start_time: null, | ||
| 154 | + prom_act: null, | ||
| 155 | + pd_xx: 0, | ||
| 156 | + is_normal: 0, //是否普通购买 | ||
| 157 | + teamgroup: null, //有多少人开团 | ||
| 158 | + grounp_tatal: 0, //有几个人开团 | ||
| 159 | + timer: [], | ||
| 160 | + | ||
| 161 | + //商品的购买次数 | ||
| 162 | + prom_buy_num: -1, | ||
| 163 | + g_buy_num: null, | ||
| 164 | + prom_goods_num: 0, //活动商品数量 | ||
| 165 | + prom_buy_num: 0, //活动商品购买数量 | ||
| 166 | + prom_redis_num: 0, //活动商品redis数量 | ||
| 167 | + | ||
| 168 | + //拼单的规则显示 | ||
| 169 | + is_show_gz: 0, | ||
| 170 | + //会员自己的购买的拼单商品的情况 | ||
| 171 | + user_order_pt_state: 0, | ||
| 172 | + //购买的订单 | ||
| 173 | + buy_order: null, | ||
| 174 | + //1加入购物车 2立即购买 | ||
| 175 | + openSpecModal_ind: 0, | ||
| 176 | + | ||
| 177 | + //---计时器开关---- | ||
| 178 | + is_timer: 1, | ||
| 179 | + isshow: 0, | ||
| 180 | + bconfig: null, //基础配置 | ||
| 181 | + | ||
| 182 | + fir_comments: null, //详情页上的评价 | ||
| 183 | + fir_quan: null, //详情页上的券 | ||
| 184 | + quan_list: null, //券列表 | ||
| 185 | + | ||
| 186 | + coupon: 0, | ||
| 187 | + //会员分享的头像 | ||
| 188 | + share_head: "", | ||
| 189 | + share_goods_img: "", | ||
| 190 | + | ||
| 191 | + //----------视频图片data参数--------- | ||
| 192 | + current: 0, //图片计数 | ||
| 193 | + swiperCurrent: 0, //轮播的下标 | ||
| 194 | + hiddenn: 0, //控制轮播计数显示 | ||
| 195 | + | ||
| 196 | + currentTab: 0, // 选择器控制参数 | ||
| 197 | + mapurl: "", | ||
| 198 | + mapurl_f_img: "", | ||
| 199 | + videopicture: 0, //视频图片的控制 | ||
| 200 | + | ||
| 201 | + video: 0, //视频图片切换器 | ||
| 202 | + index: 0, | ||
| 203 | + noon: 0, //开始视频的隐藏 | ||
| 204 | + | ||
| 205 | + screenWidth: 0, | ||
| 206 | + canvasHidden: 1, | ||
| 207 | + | ||
| 208 | + //--推荐-- | ||
| 209 | + store_config: null, | ||
| 210 | + is_show_pl: 0, //是否品类 | ||
| 211 | + is_show_pp: 0, //是否品牌 | ||
| 212 | + is_show_gb: 0, //是否国别 | ||
| 213 | + is_closecoupon: 0, | ||
| 214 | + | ||
| 215 | + //是否点赞中 | ||
| 216 | + iszaning: 0, | ||
| 217 | + | ||
| 218 | + select_store: 0, //选择更多 | ||
| 219 | + index: 1, | ||
| 220 | + more_store: 0, //选择门店 | ||
| 221 | + sort_store: 0, //门店分类 | ||
| 222 | + choice_sort_store: 0, //选择分类门店 | ||
| 223 | + new_user: 0, //新用户 | ||
| 224 | + | ||
| 225 | + def_pick_store: null, // 默认的门店 | ||
| 226 | + fir_def_store: null, //客户默认的门店的 | ||
| 227 | + lat: null, //维度 | ||
| 228 | + lon: null, //经度 | ||
| 229 | + | ||
| 230 | + is_get_local_ok: 0, //获取坐标是否完成 | ||
| 231 | + region_name: "门店分类", //区域的名字 | ||
| 232 | + is_gps: 1, | ||
| 233 | + open_ind_store: 0, //哪里打开的门店列表的控制属性 | ||
| 234 | + default_store: {}, //创建添加默认门店地址的对象 | ||
| 235 | + | ||
| 236 | + comments_no_more: 0, | ||
| 237 | + get_c: 0, //获取评价是不是成 | ||
| 238 | + is_collect_load: 0, //是不是处理 | ||
| 239 | + is_newsales_rules: 0, //是否开启最新的门店规则,此时会新读门店,当点击选择门店时会触发读取线下库存 | ||
| 240 | + sales_rules: 1, //默认是线上销售 | ||
| 241 | + | ||
| 242 | + wait_for_user_store: null, | ||
| 243 | + prom_goods: null, //商品优惠列表 | ||
| 244 | + order_prom: null, //订单优惠 | ||
| 245 | + collocationGoods: null, //搭配购 | ||
| 246 | + | ||
| 247 | + poster: null, //自定义海报 | ||
| 248 | + share_b_img: '', //自定义分享的背景 | ||
| 249 | + | ||
| 250 | + showPoster: false, | ||
| 251 | + hui_condition: null, | ||
| 252 | + sto_sele_name_1: '',//分享的门店名称 | ||
| 253 | + fir_goods: null, | ||
| 254 | + | ||
| 255 | + share_hidden: false, | ||
| 256 | + all_activity_list: null, //所有活动的列表 | ||
| 257 | + | ||
| 258 | + hiddenCS: true, | ||
| 259 | + }, | ||
| 260 | + | ||
| 261 | + //------初始化加载---------- | ||
| 262 | + onLoad: function (t) { | ||
| 263 | + var ee = this, | ||
| 264 | + that = ee, | ||
| 265 | + th = ee, | ||
| 266 | + gid = t.goods_id, | ||
| 267 | + first_leader = t.first_leader, | ||
| 268 | + room_id = t.room_id, | ||
| 269 | + room_user_share = t.room_user_share, //如果是会员分享带有room_id的话,那么接下来会员分享就不传room_id | ||
| 270 | + prom_type = t.prom_type, | ||
| 271 | + prom_id = t.prom_id; //活动ID | ||
| 272 | + | ||
| 273 | + self = this; | ||
| 274 | + | ||
| 275 | + //检查测肤 | ||
| 276 | + getApp().check_skin_face(t,0,gid); | ||
| 277 | + | ||
| 278 | + //-- 自定义海报 -- | ||
| 279 | + getApp().request.promiseGet("/api/weshop/goods/poster/page", { | ||
| 280 | + data: {store_id: os.stoid, type: 1, is_use: 1} | ||
| 281 | + }).then(res => { | ||
| 282 | + if (res.data.code == 0 && res.data.data && res.data.data.pageData && res.data.data.pageData[0]) { | ||
| 283 | + | ||
| 284 | + var poster_data = res.data.data.pageData[0]; | ||
| 285 | + var json_str = poster_data.jsonStr; | ||
| 286 | + | ||
| 287 | + if (json_str) { | ||
| 288 | + var json_data = JSON.parse(json_str); | ||
| 289 | + if (json_data.bg_img) { | ||
| 290 | + | ||
| 291 | + //-- 把图片那到本地 -- | ||
| 292 | + wx.getImageInfo({ | ||
| 293 | + src: json_data.bg_img, | ||
| 294 | + success: function (res) { | ||
| 295 | + var path = res.path; | ||
| 296 | + th.setData({share_b_img: path}) | ||
| 297 | + }, | ||
| 298 | + fail: function (res) { | ||
| 299 | + } | ||
| 300 | + }); | ||
| 301 | + } | ||
| 302 | + th.setData({poster: json_data}) | ||
| 303 | + | ||
| 304 | + } | ||
| 305 | + } | ||
| 306 | + }) | ||
| 307 | + | ||
| 308 | + //---获取手机地址坐标-- | ||
| 309 | + //--如果tg_id是空的话,分享回来-- | ||
| 310 | + if (gid == undefined || gid == null || gid == "") { | ||
| 311 | + var gid_str = decodeURIComponent(t.scene); | ||
| 312 | + gid_str = gid_str.split("_"); | ||
| 313 | + gid = gid_str[0]; | ||
| 314 | + if (gid.indexOf('.') != -1) { | ||
| 315 | + var fir_arr = gid.split("."); | ||
| 316 | + gid = fir_arr[0]; | ||
| 317 | + prom_type = fir_arr[1]; | ||
| 318 | + prom_id = fir_arr[2]; | ||
| 319 | + this.data.prom_type = prom_type; | ||
| 320 | + this.data.prom_id = prom_id; | ||
| 321 | + } | ||
| 322 | + | ||
| 323 | + if (gid_str.length > 1) { | ||
| 324 | + first_leader = gid_str[1]; | ||
| 325 | + } | ||
| 326 | + //-- 如果有room_id的获取 -- | ||
| 327 | + if (gid_str.length > 2 && gid_str[2]) { | ||
| 328 | + room_id = gid_str[2]; | ||
| 329 | + room_user_share = 1; | ||
| 330 | + } | ||
| 331 | + | ||
| 332 | + } | ||
| 333 | + | ||
| 334 | + | ||
| 335 | + //判断活动 | ||
| 336 | + if (prom_type) { | ||
| 337 | + this.data.prom_type = prom_type; | ||
| 338 | + this.data.prom_id = prom_id; | ||
| 339 | + } | ||
| 340 | + ee.setData({gid: gid}); | ||
| 341 | + | ||
| 342 | + console.log("gd onload--2"); | ||
| 343 | + console.log(first_leader); | ||
| 344 | + | ||
| 345 | + if(first_leader) { | ||
| 346 | + console.log("gd onload--3"); | ||
| 347 | + console.log("log---"+first_leader); | ||
| 348 | + getApp().globalData.first_leader = first_leader; | ||
| 349 | + //调用接口判断是不是会员 | ||
| 350 | + getApp().request.promiseGet("/api/weshop/shoppingGuide/get/" + os.stoid + "/" + first_leader, {}).then(res => { | ||
| 351 | + if (res.data.code == 0) { | ||
| 352 | + getApp().globalData.guide_id = res.data.data.id; | ||
| 353 | + } | ||
| 354 | + }) | ||
| 355 | + } | ||
| 356 | + | ||
| 357 | + //-- 如果有房间号 -- | ||
| 358 | + if (room_id) { | ||
| 359 | + getApp().globalData.room_id = room_id; | ||
| 360 | + getApp().globalData.room_goods_id = gid; | ||
| 361 | + //如果是会员分享过来的要记录 | ||
| 362 | + if (room_user_share) | ||
| 363 | + getApp().globalData.room_user_share = room_user_share; | ||
| 364 | + } | ||
| 365 | + | ||
| 366 | + var c_guide_id = t.c_guide_id; | ||
| 367 | + if (c_guide_id) { | ||
| 368 | + th.data.c_guide_id = c_guide_id; | ||
| 369 | + } | ||
| 370 | + | ||
| 371 | + //调用接口判断商家plus有没有过期 | ||
| 372 | + getApp().request.promiseGet("/store/storemoduleendtime/page?store_id=" + os.stoid + "&type=3", {}).then(res => { | ||
| 373 | + if (res.data.code == 0) { | ||
| 374 | + var arr = res.data.data.pageData; | ||
| 375 | + if (arr.length > 0) { | ||
| 376 | + var item = arr[0]; | ||
| 377 | + if (item.is_sy == 0) { | ||
| 378 | + var now = Date.parse(new Date()); now = now / 1000; | ||
| 379 | + if (item.end_time < now) { | ||
| 380 | + th.setData({ is_no_plus: 0 }) | ||
| 381 | + } | ||
| 382 | + } | ||
| 383 | + } | ||
| 384 | + } | ||
| 385 | + }) | ||
| 386 | + | ||
| 387 | + getApp().getConfig(function (e) { | ||
| 388 | + ee.setData({sto_sele_name_1: e.store_name}) | ||
| 389 | + }) | ||
| 390 | + | ||
| 391 | + //----获取系统参数----- | ||
| 392 | + getApp().getConfig2(function (e) { | ||
| 393 | + ee.setData({ | ||
| 394 | + bconfig: e, | ||
| 395 | + sales_rules: e.sales_rules, | ||
| 396 | + }); | ||
| 397 | + | ||
| 398 | + if (e.categoryset.indexOf("," + 1 + ",") != -1) { | ||
| 399 | + ee.setData({ | ||
| 400 | + is_show_pl: 1 | ||
| 401 | + }); | ||
| 402 | + } | ||
| 403 | + if (e.categoryset.indexOf("," + 3 + ",") != -1) { | ||
| 404 | + ee.setData({ | ||
| 405 | + is_show_pp: 1 | ||
| 406 | + }); | ||
| 407 | + } | ||
| 408 | + if (e.categoryset.indexOf("," + 2 + ",") != -1) { | ||
| 409 | + ee.setData({ | ||
| 410 | + is_show_gb: 1 | ||
| 411 | + }); | ||
| 412 | + } | ||
| 413 | + console.log(e); | ||
| 414 | + var json_d = JSON.parse(e.switch_list); | ||
| 415 | + ee.setData({ | ||
| 416 | + store_config: e, | ||
| 417 | + sys_switch: json_d, | ||
| 418 | + is_closecoupon: json_d.is_closecoupon, | ||
| 419 | + is_newsales_rules: json_d.is_newsales_rules | ||
| 420 | + }); | ||
| 421 | + ee.init(gid); | ||
| 422 | + //------几人评价------- | ||
| 423 | + //n.init(th, "", "comments"); | ||
| 424 | + | ||
| 425 | + th.requestCardNum(), wx.pageScrollTo && th.setData({ | ||
| 426 | + supportPageScroll: !0 | ||
| 427 | + }); | ||
| 428 | + | ||
| 429 | + //计算等级价相关 | ||
| 430 | + var swithc_list = e.switch_list; | ||
| 431 | + var sw_arr = JSON.parse(swithc_list); | ||
| 432 | + //---如果后台又开等级卡的开关--- | ||
| 433 | + if (sw_arr.rank_switch && sw_arr.rank_switch == "2") { | ||
| 434 | + th.setData({rank_switch: true}); | ||
| 435 | + //---回调卡的列表--- | ||
| 436 | + th.getPlusCardType(function (ob) { | ||
| 437 | + th.setData({card_list: ob.card_list}); | ||
| 438 | + var ti = setInterval(function () { | ||
| 439 | + var user = getApp().globalData.userInfo; | ||
| 440 | + if (!user) return false; | ||
| 441 | + clearInterval(ti); | ||
| 442 | + if (user.card_field && user['card_expiredate']) { | ||
| 443 | + var str = user['card_expiredate'].replace(/-/g, '/'); | ||
| 444 | + var end = new Date(str); | ||
| 445 | + end = Date.parse(end) / 1000; | ||
| 446 | + var now = ut.gettimestamp(); | ||
| 447 | + //--- 判断是等级会员,且在有效期范围内 --- | ||
| 448 | + if (user.card_field && now < end) { | ||
| 449 | + var card_name = ob.name_map.get(user.card_field); | ||
| 450 | + //if(card_name.length>6) card_name=card_name.substring(0,6); | ||
| 451 | + | ||
| 452 | + var is_near_date = 0; | ||
| 453 | + if (end - now < 60 * 60 * 30 * 24) is_near_date = 1; //如果小于30天 | ||
| 454 | + th.setData({ | ||
| 455 | + card_field: user.card_field, | ||
| 456 | + card_name: card_name, | ||
| 457 | + card_list: ob.card_list, | ||
| 458 | + is_near_date: is_near_date | ||
| 459 | + }); | ||
| 460 | + } | ||
| 461 | + } | ||
| 462 | + }, 500) | ||
| 463 | + }) | ||
| 464 | + } | ||
| 465 | + | ||
| 466 | + }, 1); | ||
| 467 | + | ||
| 468 | + //获取用户设备信息,屏幕宽度 | ||
| 469 | + wx.getSystemInfo({ | ||
| 470 | + success: res => { | ||
| 471 | + that.setData({ | ||
| 472 | + screenWidth: res.screenWidth | ||
| 473 | + }) | ||
| 474 | + } | ||
| 475 | + }); | ||
| 476 | + | ||
| 477 | + //获取用户的默认门店 | ||
| 478 | + getApp().get_user_store(function (e) { | ||
| 479 | + if (!e) { | ||
| 480 | + th.data.fir_def_store = {}; //赋值空对象 | ||
| 481 | + return false; | ||
| 482 | + } | ||
| 483 | + var ee = JSON.parse(JSON.stringify(e)); | ||
| 484 | + //--定时器推迟一下-- | ||
| 485 | + setTimeout(function () { | ||
| 486 | + if (th.data.fir_goods) var g_distr_type = th.data.fir_goods.distr_type; | ||
| 487 | + //--如果默认门店的配送方式不对,就不能被选择,这里不控制,如果不一样,就说明配送方式不对-- | ||
| 488 | + if (ee.distr_type != 0 && g_distr_type != 0 && ee.distr_type != g_distr_type) { | ||
| 489 | + ee.is_no_dis = 1; | ||
| 490 | + } | ||
| 491 | + | ||
| 492 | + var appd = getApp().globalData; | ||
| 493 | + var w_time = setInterval(function () { | ||
| 494 | + if (that.data.is_get_local_ok == 0) return false; | ||
| 495 | + clearInterval(w_time); | ||
| 496 | + var distance = null; | ||
| 497 | + var e = JSON.parse(JSON.stringify(ee)); | ||
| 498 | + | ||
| 499 | + //如果有开启近距离的话,同时距离优不一样了 | ||
| 500 | + if (that.data.lat != null) { | ||
| 501 | + //如果经纬度有变化的话 | ||
| 502 | + if (e && appd.lat == that.data.lat && appd.lon == that.data.lon && e.distance > 0) { | ||
| 503 | + that.set_def_storage(e); | ||
| 504 | + } else { | ||
| 505 | + //要用接口是获取距离,js的计算不准 | ||
| 506 | + getApp().request.promiseGet("/api/weshop/pickup/list", { | ||
| 507 | + data: { | ||
| 508 | + store_id: os.stoid, | ||
| 509 | + pickup_id: e.pickup_id, | ||
| 510 | + lat: th.data.lat, | ||
| 511 | + lon: th.data.lon, | ||
| 512 | + isstop: 0, | ||
| 513 | + is_pos: 1 | ||
| 514 | + }, | ||
| 515 | + }).then(res => { | ||
| 516 | + if (res.data.code == 0) { | ||
| 517 | + e = res.data.data.pageData[0]; | ||
| 518 | + if (e) { | ||
| 519 | + e.is_no_dis = ee.is_no_dis; | ||
| 520 | + appd.pk_store = e; | ||
| 521 | + that.set_def_storage(e); | ||
| 522 | + } | ||
| 523 | + | ||
| 524 | + } | ||
| 525 | + }) | ||
| 526 | + } | ||
| 527 | + //e.distance = distance; | ||
| 528 | + appd.lat = that.data.lat; | ||
| 529 | + appd.lon = that.data.lon; | ||
| 530 | + | ||
| 531 | + } else { | ||
| 532 | + if (e) { | ||
| 533 | + e.distance = null; | ||
| 534 | + that.set_def_storage(e); | ||
| 535 | + } | ||
| 536 | + } | ||
| 537 | + }, 500) | ||
| 538 | + }, 700) | ||
| 539 | + }); | ||
| 540 | + | ||
| 541 | + //更新点击量 | ||
| 542 | + getApp().request.put("/api/weshop/goods/updateClick", { | ||
| 543 | + data: {store_id: os.stoid, goods_id: gid} | ||
| 544 | + }); | ||
| 545 | + | ||
| 546 | + | ||
| 547 | + }, | ||
| 548 | + | ||
| 549 | + | ||
| 550 | + //--- 设置一下默认库存的数量 ---- | ||
| 551 | + set_def_storage(ee) { | ||
| 552 | + var that = this, th = this; | ||
| 553 | + getApp().getConfig2(function (e) { | ||
| 554 | + var sales_rules = e.sales_rules; | ||
| 555 | + if (sales_rules == 2) { | ||
| 556 | + getApp().waitfor2(that, "wait_for_user_store", "fir_goods", function () { | ||
| 557 | + var lock = 0, plist = null; | ||
| 558 | + var gd = that.data.fir_goods; | ||
| 559 | + //先读取门店的lock,采用链式写法,少用await | ||
| 560 | + getApp().request.promiseGet("/api/weshop/order/ware/lock/page", { | ||
| 561 | + data: { | ||
| 562 | + store_id: os.stoid, | ||
| 563 | + wareId: that.data.fir_goods.goods_id, | ||
| 564 | + storageId: ee.pickup_id, | ||
| 565 | + pageSize: 1000 | ||
| 566 | + } | ||
| 567 | + }).then(res => { | ||
| 568 | + if (res.data.code == 0 && res.data.data.total > 0) { | ||
| 569 | + for (var i in res.data.data.pageData) | ||
| 570 | + lock += res.data.data.pageData[i].outQty | ||
| 571 | + } | ||
| 572 | + //---通过接口获取门店的线下库存信息-- | ||
| 573 | + return getApp().request.promiseGet("/api/weshop/goods/getWareStorages", { | ||
| 574 | + data: { | ||
| 575 | + storageNos: ee.pickup_no, | ||
| 576 | + wareIds: encodeURIComponent(th.data.data.erpwareid), | ||
| 577 | + storeId: os.stoid | ||
| 578 | + } | ||
| 579 | + }) | ||
| 580 | + }).then(res => { | ||
| 581 | + if (res.data.code == 0 && res.data.data.total > 0) { | ||
| 582 | + plist = res.data.data.pageData[0]; | ||
| 583 | + } else { | ||
| 584 | + wx.showToast({ | ||
| 585 | + title: '库存不足,请更换其他门店', | ||
| 586 | + icon: 'none', | ||
| 587 | + }); | ||
| 588 | + } | ||
| 589 | + ; | ||
| 590 | + if (plist && plist.CanOutQty - lock > 0) { | ||
| 591 | + ee.CanOutQty = plist.CanOutQty - lock; | ||
| 592 | + } else { | ||
| 593 | + ee.CanOutQty = 0; | ||
| 594 | + } | ||
| 595 | + //--给门店赋值线下库存-- | ||
| 596 | + that.data.fir_def_store = ee; | ||
| 597 | + that.setData({ | ||
| 598 | + def_pick_store: ee, | ||
| 599 | + sto_sele_name: ee.pickup_name, | ||
| 600 | + sto_sele_id: ee.pickup_id, | ||
| 601 | + sto_sele_distr: ee.distr_type | ||
| 602 | + }) | ||
| 603 | + }) | ||
| 604 | + }) | ||
| 605 | + } else { | ||
| 606 | + that.data.fir_def_store = ee; | ||
| 607 | + that.setData({ | ||
| 608 | + def_pick_store: ee, | ||
| 609 | + sto_sele_name: ee.pickup_name, | ||
| 610 | + sto_sele_id: ee.pickup_id, | ||
| 611 | + sto_sele_distr: ee.distr_type | ||
| 612 | + }) | ||
| 613 | + } | ||
| 614 | + }) | ||
| 615 | + | ||
| 616 | + }, | ||
| 617 | + | ||
| 618 | + | ||
| 619 | + //------------程序初始化入口------------- | ||
| 620 | + async init(gid) { | ||
| 621 | + var ee = this, | ||
| 622 | + th = ee, | ||
| 623 | + gallery = null, | ||
| 624 | + is_collect = 0, | ||
| 625 | + collect_id = 0, | ||
| 626 | + categories3 = ee.data.categories3, | ||
| 627 | + fir_com = null, | ||
| 628 | + fir_quan = null, | ||
| 629 | + mapurl = null, | ||
| 630 | + mapurl_f_img = null; | ||
| 631 | + | ||
| 632 | + | ||
| 633 | + //------图片滚动---------- | ||
| 634 | + await getApp().request.promiseGet("/api/weshop/goodsimages/page", { | ||
| 635 | + data: { | ||
| 636 | + store_id: os.stoid, | ||
| 637 | + goods_id: gid, | ||
| 638 | + }, | ||
| 639 | + }).then(res => { | ||
| 640 | + | ||
| 641 | + var t = res; | ||
| 642 | + var g = t.data.data.pageData; | ||
| 643 | + if (g.length == 0) { | ||
| 644 | + var ie = { | ||
| 645 | + "image_url": o.imghost + "/public/images/default_goods_image_240.gif" | ||
| 646 | + }; | ||
| 647 | + g.push(ie); | ||
| 648 | + gallery = g; | ||
| 649 | + return; | ||
| 650 | + } | ||
| 651 | + for (var i = 0; i < g.length; i++) { | ||
| 652 | + if (g[i].image_url.indexOf(o.imghost) == -1) | ||
| 653 | + g[i].image_url = o.imghost + g[i].image_url; | ||
| 654 | + } | ||
| 655 | + gallery = g; | ||
| 656 | + }) | ||
| 657 | + //------是否收藏---------- | ||
| 658 | + await getApp().request.promiseGet("/api/weshop/goodscollect/page", { | ||
| 659 | + data: { | ||
| 660 | + store_id: os.stoid, | ||
| 661 | + goods_id: gid, | ||
| 662 | + user_id: oo.user_id, | ||
| 663 | + } | ||
| 664 | + }).then(res => { | ||
| 665 | + var t = res; | ||
| 666 | + var data = t.data.data.pageData; | ||
| 667 | + if (data && data.length > 0) { | ||
| 668 | + //ee.setData({ is_collect: 1, collect_id: data[0].collect_id, }); | ||
| 669 | + is_collect = 1; | ||
| 670 | + collect_id = data[0].collect_id; | ||
| 671 | + } | ||
| 672 | + }) | ||
| 673 | + | ||
| 674 | + //------获取评价的统计数量---- | ||
| 675 | + await getApp().request.promiseGet("/api/weshop/comment/countlist/", { | ||
| 676 | + data: { | ||
| 677 | + store_id: os.stoid, | ||
| 678 | + goods_id: gid | ||
| 679 | + }, | ||
| 680 | + //failRollback: !0, | ||
| 681 | + | ||
| 682 | + }).then(res => { | ||
| 683 | + var t = res; | ||
| 684 | + var g = t.data.data[0]; | ||
| 685 | + if (g != null && g != undefined) { | ||
| 686 | + var allnum = g.c0 + g.c1 + g.c2 + g.c3 + g.c4 + g.c5; | ||
| 687 | + var num2 = g.c4 + g.c5; | ||
| 688 | + var num3 = g.c3; | ||
| 689 | + var num4 = g.c0 + g.c1 + g.c2; | ||
| 690 | + | ||
| 691 | + var dd = ee.data.categories3; | ||
| 692 | + dd[0].num = allnum; | ||
| 693 | + dd[1].num = g.cimg; | ||
| 694 | + dd[2].num = num2; | ||
| 695 | + dd[3].num = num3; | ||
| 696 | + dd[4].num = num4; | ||
| 697 | + | ||
| 698 | + categories3 = dd; | ||
| 699 | + } | ||
| 700 | + }) | ||
| 701 | + | ||
| 702 | + //----获取详情页的评价---- | ||
| 703 | + await getApp().request.promiseGet("/api/weshop/comment/pageComment", { | ||
| 704 | + data: { | ||
| 705 | + store_id: os.stoid, | ||
| 706 | + goods_id: gid, | ||
| 707 | + pageSize: 3, | ||
| 708 | + parent_id: 0, | ||
| 709 | + page: 1, | ||
| 710 | + is_show: 1, | ||
| 711 | + }, | ||
| 712 | + }).then(res => { | ||
| 713 | + fir_com = res.data.data.pageData; | ||
| 714 | + }) | ||
| 715 | + | ||
| 716 | + if (fir_com) { | ||
| 717 | + for (var ind in fir_com) { | ||
| 718 | + if (fir_com[ind].head_pic == "") fir_com[ind].head_pic = ee.data.iurl + "/miniapp/images/hui_hear_pic.png"; | ||
| 719 | + if (fir_com[ind].img) fir_com[ind].img = ut.unserialize(fir_com[ind].img); | ||
| 720 | + if (fir_com[ind].weapp_img) fir_com[ind].weapp_img = JSON.parse(fir_com[ind].weapp_img); | ||
| 721 | + } | ||
| 722 | + } | ||
| 723 | + | ||
| 724 | + if (th.data.is_closecoupon != 1 && (!th.data.fir_quan || th.data.fir_quan.length <= 0)) { | ||
| 725 | + //----获取详情页的券的数量---- | ||
| 726 | + await getApp().request.promiseGet("/api/weshop/prom/coupon/pageCouponList", { | ||
| 727 | + data: { | ||
| 728 | + store_id: os.stoid, | ||
| 729 | + type: 1, | ||
| 730 | + pageSize: 3, | ||
| 731 | + page: 1, | ||
| 732 | + is_share: 0, | ||
| 733 | + }, | ||
| 734 | + }).then(res1 => { | ||
| 735 | + fir_quan = res1.data.data.pageData; | ||
| 736 | + }) | ||
| 737 | + } | ||
| 738 | + | ||
| 739 | + //--------获取视频图片--------- | ||
| 740 | + await getApp().request.promiseGet("/api/weshop/goodsVideos/get/" + os.stoid + "/" + ee.data.gid, { | ||
| 741 | + 1: 1 | ||
| 742 | + }).then(res1 => { | ||
| 743 | + if (res1.data.code == 0) { | ||
| 744 | + mapurl = res1.data.data.video_url; | ||
| 745 | + mapurl_f_img = res1.data.data.video_img; | ||
| 746 | + } | ||
| 747 | + }) | ||
| 748 | + this.getHistoryBuy(); //获取历史购买 | ||
| 749 | + ee.setData({ | ||
| 750 | + gallery: gallery, | ||
| 751 | + is_collect: is_collect, | ||
| 752 | + collect_id: collect_id, | ||
| 753 | + categories3: categories3, | ||
| 754 | + fir_quan: fir_quan, | ||
| 755 | + fir_comments: fir_com, | ||
| 756 | + mapurl_f_img: mapurl_f_img, | ||
| 757 | + mapurl: mapurl, | ||
| 758 | + }); | ||
| 759 | + | ||
| 760 | + }, | ||
| 761 | + | ||
| 762 | + //---展示--- | ||
| 763 | + onShow: function () { | ||
| 764 | + | ||
| 765 | + getApp().check_can_share(); | ||
| 766 | + | ||
| 767 | + var goods_list = null, th = this, that = this; | ||
| 768 | + var show_prew_img = this.data.show_prew_img | ||
| 769 | + if (show_prew_img) { | ||
| 770 | + show_prew_img = 0; | ||
| 771 | + return false; | ||
| 772 | + } | ||
| 773 | + | ||
| 774 | + if(this.data.show_video) { | ||
| 775 | + this.data.show_video=0; | ||
| 776 | + return false; | ||
| 777 | + } | ||
| 778 | + | ||
| 779 | + //优惠券要实时更新 | ||
| 780 | + getApp().getConfig2(function (e) { | ||
| 781 | + var json_d = JSON.parse(e.switch_list); | ||
| 782 | + th.setData({is_closecoupon: json_d.is_closecoupon}) | ||
| 783 | + th.setData({is_open_offline: json_d.is_pricing_open}) | ||
| 784 | + }, 1) | ||
| 785 | + | ||
| 786 | + | ||
| 787 | + var ui = setInterval(function () { | ||
| 788 | + goods_list = th.selectComponent("#goods_list"); | ||
| 789 | + if (goods_list) { | ||
| 790 | + clearInterval(ui); | ||
| 791 | + goods_list.init(); | ||
| 792 | + return false | ||
| 793 | + } | ||
| 794 | + }, 300) | ||
| 795 | + | ||
| 796 | + this.data.is_timer = 1; | ||
| 797 | + var ee = this, | ||
| 798 | + gid = this.data.gid, | ||
| 799 | + i = getApp().request; | ||
| 800 | + | ||
| 801 | + this.wait_for_store_config(); | ||
| 802 | + //先检验一下商品的活动情况 | ||
| 803 | + this.check_gd_prom_new(function () { | ||
| 804 | + i.get("/api/weshop/goods/get/" + o.stoid + "/" + ee.data.gid, { | ||
| 805 | + failRollback: !0, | ||
| 806 | + success: function (t) { | ||
| 807 | + console.log(t); | ||
| 808 | + if (t.data.code == 0) { | ||
| 809 | + if (t.data.data.is_on_sale != 1) { | ||
| 810 | + wx.showModal({ | ||
| 811 | + title: '商品已经下架', | ||
| 812 | + showCancel: !1, | ||
| 813 | + complete: function () { | ||
| 814 | + wx.navigateBack(); | ||
| 815 | + } | ||
| 816 | + }); | ||
| 817 | + } | ||
| 818 | + | ||
| 819 | + var timestamp = Date.parse(new Date()); | ||
| 820 | + timestamp = timestamp / 1000; | ||
| 821 | + if (t.data.data.on_time > timestamp) { | ||
| 822 | + wx.showModal({ | ||
| 823 | + title: '商品还未上架', | ||
| 824 | + showCancel: !1, | ||
| 825 | + complete: function () { | ||
| 826 | + wx.navigateBack(); | ||
| 827 | + } | ||
| 828 | + }); | ||
| 829 | + } | ||
| 830 | + | ||
| 831 | + if (t.data.data.down_time > 0) { | ||
| 832 | + if (t.data.data.down_time < timestamp) { | ||
| 833 | + wx.showModal({ | ||
| 834 | + title: '商品已经到期下架', | ||
| 835 | + showCancel: !1, | ||
| 836 | + complete: function () { | ||
| 837 | + wx.navigateBack(); | ||
| 838 | + } | ||
| 839 | + }); | ||
| 840 | + } | ||
| 841 | + } | ||
| 842 | + //动态获取商品名称 | ||
| 843 | + wx.setNavigationBarTitle({ | ||
| 844 | + title: t.data.data.goods_name, | ||
| 845 | + }); | ||
| 846 | + | ||
| 847 | + //-- 判断是不是组合购活动,必须要登录后才能判断 -- | ||
| 848 | + if (getApp().globalData.userInfo && t.data.data.prom_type == 7) { | ||
| 849 | + //获取活动信息 | ||
| 850 | + var url = "/api/weshop/prom/zhbuy/get/" + os.stoid + "/" + | ||
| 851 | + t.data.data.prom_id + "/" + getApp().globalData.user_id; | ||
| 852 | + getApp().request.get(url, { | ||
| 853 | + success: function (e) { | ||
| 854 | + if (e.data.code == 0 && e.data.data) { | ||
| 855 | + if (ut.gettimestamp() < e.data.data.start_time) { | ||
| 856 | + return false; | ||
| 857 | + } | ||
| 858 | + if (e.data.data.is_end == 0 && ut.gettimestamp() < e.data.data.end_time) { | ||
| 859 | + //-- 获取商品列表 -- | ||
| 860 | + th.setData({zh_act: e.data.data}); | ||
| 861 | + } | ||
| 862 | + | ||
| 863 | + } | ||
| 864 | + } | ||
| 865 | + }); | ||
| 866 | + } | ||
| 867 | + | ||
| 868 | + //-- 把商品的赋值,同时给活动赋值 -- | ||
| 869 | + ee.data.fir_goods = JSON.parse(JSON.stringify(t.data.data)); | ||
| 870 | + if (t.data.data.prom_type && t.data.data.prom_id) { | ||
| 871 | + ee.data.prom_type = t.data.data.prom_type; | ||
| 872 | + ee.data.prom_id = t.data.data.prom_id; | ||
| 873 | + } | ||
| 874 | + | ||
| 875 | + | ||
| 876 | + if (ee.data.prom_type != 1 && ee.data.prom_type != 4 && ee.data.prom_type != 6 && ee.data.prom_type != 2) { | ||
| 877 | + ee.check_is_youhui(ee.data.gid); | ||
| 878 | + } | ||
| 879 | + | ||
| 880 | + t.data.data.on_time = ut.formatTime(t.data.data.on_time, 'yyyy-MM-dd hh:mm:ss'); | ||
| 881 | + | ||
| 882 | + var cur_price = t.data.data.shop_price; | ||
| 883 | + if (getApp().globalData.userInfo && getApp().globalData.userInfo.card_field) { | ||
| 884 | + var cfile = getApp().globalData.userInfo.card_field; | ||
| 885 | + if (t.data.data[cfile]) { | ||
| 886 | + cur_price = t.data.data[cfile]; | ||
| 887 | + } | ||
| 888 | + } | ||
| 889 | + var txt = (cur_price / t.data.data.market_price * 10).toFixed(2).toString(); | ||
| 890 | + txt = parseFloat(txt); | ||
| 891 | + | ||
| 892 | + t.data.data['disc'] = txt; | ||
| 893 | + | ||
| 894 | + if (t.data.data.original_img.indexOf(o.imghost) == -1) | ||
| 895 | + t.data.data.original_img = o.imghost + t.data.data.original_img; | ||
| 896 | + | ||
| 897 | + if (t.data.data.goods_content == null) t.data.data.goods_content = ""; | ||
| 898 | + | ||
| 899 | + //-----商品详情--- | ||
| 900 | + if (!t.data.data.goods_content) t.data.data.goods_content = " "; | ||
| 901 | + a.wxParse("content", "html", t.data.data.goods_content, ee, 6); | ||
| 902 | + e.wxParseAddFullImageUrl(ee, "content"); | ||
| 903 | + | ||
| 904 | + if (ee.data.prom_type) { | ||
| 905 | + t.data.data.prom_type = ee.data.prom_type; | ||
| 906 | + t.data.data.prom_id = ee.data.prom_id; | ||
| 907 | + } | ||
| 908 | + ee.setData({ | ||
| 909 | + data: t.data.data, | ||
| 910 | + sele_g: t.data.data, | ||
| 911 | + userInfo: getApp().globalData.userInfo | ||
| 912 | + }); | ||
| 913 | + | ||
| 914 | + | ||
| 915 | + //获取统一条形码,普通商品和优惠促销的商品 | ||
| 916 | + if (ee.data.data.prom_type == 0 || ee.data.data.prom_type == 3 || ee.data.data.prom_type == 5 || ee.data.data.prom_type == 7 || ee.data.data.prom_type == 9 || ee.data.data.prom_type == 10) { | ||
| 917 | + //默认门店要拿下门店库存 | ||
| 918 | + if (that.data.sales_rules == 2 && that.data.is_newsales_rules) { | ||
| 919 | + //获取门店 | ||
| 920 | + ee.get_sto(); | ||
| 921 | + | ||
| 922 | + } else { | ||
| 923 | + //获取门店 | ||
| 924 | + ee.get_sto(); | ||
| 925 | + } | ||
| 926 | + | ||
| 927 | + ee.get_sku(o.stoid, t.data.data, gid); | ||
| 928 | + ee.check_has_flash(); | ||
| 929 | + | ||
| 930 | + } | ||
| 931 | + else { | ||
| 932 | + var gg = "", item = t.data.data; | ||
| 933 | + | ||
| 934 | + if (item.goods_spec == "null" || item.goods_spec == null) item.goods_spec = ""; | ||
| 935 | + if (item.goods_color == "null" || item.goods_color == null) item.goods_color = ""; | ||
| 936 | + | ||
| 937 | + if (item.goods_spec != "" && item.goods_color != "") { | ||
| 938 | + gg = item.goods_spec + "/" + item.goods_color; | ||
| 939 | + } else if (item.goods_spec != "" || item.goods_color != "") { | ||
| 940 | + gg = item.goods_spec + item.goods_color; | ||
| 941 | + } else { | ||
| 942 | + gg = "规格1"; | ||
| 943 | + } | ||
| 944 | + t.data.data.gg = gg; | ||
| 945 | + var uu = []; | ||
| 946 | + uu.push(t.data.data); | ||
| 947 | + ee.setData({ | ||
| 948 | + sku_g: uu, | ||
| 949 | + }); | ||
| 950 | + } | ||
| 951 | + ee.data.g_buy_num = new Map(); | ||
| 952 | + ee.check_prom(gid, ee.data.data.prom_type, ee.data.data.prom_id); | ||
| 953 | + | ||
| 954 | + var th = ee; | ||
| 955 | + if (ee.data.cat_name == '') { | ||
| 956 | + //过去国别,分类,品牌的名称 | ||
| 957 | + i.get("/api/weshop/goodscategory/get/" + o.stoid + "/" + th.data.data.cat_id, { | ||
| 958 | + success: function (t) { | ||
| 959 | + var dd = t.data.data; | ||
| 960 | + if (t.data.code == 0) { | ||
| 961 | + th.setData({ | ||
| 962 | + cat_name: dd.name | ||
| 963 | + }); | ||
| 964 | + } | ||
| 965 | + } | ||
| 966 | + }); | ||
| 967 | + //过去国别,分类,品牌的名称 | ||
| 968 | + i.get("/api/weshop/brand/get/" + o.stoid + "/" + th.data.data.brand_id, { | ||
| 969 | + success: function (t) { | ||
| 970 | + var dd = t.data.data; | ||
| 971 | + if (t.data.code == 0) { | ||
| 972 | + th.setData({ | ||
| 973 | + brand_name: dd.name | ||
| 974 | + }); | ||
| 975 | + } | ||
| 976 | + } | ||
| 977 | + }); | ||
| 978 | + //过去国别,分类,品牌的名称 | ||
| 979 | + i.get("/api/weshop/nation/get/" + o.stoid + "/" + th.data.data.nation_id, { | ||
| 980 | + success: function (t) { | ||
| 981 | + var dd = t.data.data; | ||
| 982 | + if (t.data.code == 0) { | ||
| 983 | + th.setData({ | ||
| 984 | + nation_name: dd.name | ||
| 985 | + }); | ||
| 986 | + } | ||
| 987 | + } | ||
| 988 | + }); | ||
| 989 | + } | ||
| 990 | + | ||
| 991 | + } | ||
| 992 | + else { | ||
| 993 | + wx.showModal({ | ||
| 994 | + title: t.data.msg, | ||
| 995 | + showCancel: !1, | ||
| 996 | + complete: function () { | ||
| 997 | + wx.navigateBack(); | ||
| 998 | + } | ||
| 999 | + }); | ||
| 1000 | + } | ||
| 1001 | + } | ||
| 1002 | + }); | ||
| 1003 | + }) | ||
| 1004 | + | ||
| 1005 | + this.data.enterAddressPage && (this.data.enterAddressPage = !1); | ||
| 1006 | + | ||
| 1007 | + | ||
| 1008 | + | ||
| 1009 | + }, | ||
| 1010 | + | ||
| 1011 | + onReady() { | ||
| 1012 | + | ||
| 1013 | + setTimeout(()=>{ | ||
| 1014 | + wx.createSelectorQuery().selectAll(".showArea, .hideArea").boundingClientRect(res => { | ||
| 1015 | + // console.log('node@@@@@@@', res); | ||
| 1016 | + if(res.length != 0) { | ||
| 1017 | + this.setData({ | ||
| 1018 | + showFold: res[0].height < res[1].height, | ||
| 1019 | + }); | ||
| 1020 | + }; | ||
| 1021 | + | ||
| 1022 | + }).exec(); | ||
| 1023 | + }, 1000); | ||
| 1024 | + | ||
| 1025 | + }, | ||
| 1026 | + | ||
| 1027 | + enterAddress: function () { | ||
| 1028 | + this.data.enterAddressPage = !0, wx.navigateTo({ | ||
| 1029 | + url: "/pages/user/address_list/address_list?operate=selectAddress" | ||
| 1030 | + }); | ||
| 1031 | + }, | ||
| 1032 | + onUnload: function () { | ||
| 1033 | + for (var i = 1; i < 100; i++) { | ||
| 1034 | + clearInterval(i); | ||
| 1035 | + } | ||
| 1036 | + }, | ||
| 1037 | + onHide: function () { | ||
| 1038 | + this.data.is_timer = 0; | ||
| 1039 | + for (var i = 1; i < 100; i++) { | ||
| 1040 | + clearInterval(i); | ||
| 1041 | + } | ||
| 1042 | + }, | ||
| 1043 | + //----------三个选项按钮----------- | ||
| 1044 | + tabClick: function (t) { | ||
| 1045 | + var e = t.currentTarget.id; | ||
| 1046 | + this.setData({ | ||
| 1047 | + activeCategoryId: e | ||
| 1048 | + }), 1 == e ? this.tabGoodsContent() : 2 == e && this.tabComment(); | ||
| 1049 | + }, | ||
| 1050 | + tabClick2: function (t) { | ||
| 1051 | + this.setData({ | ||
| 1052 | + activeCategoryId2: t.currentTarget.id | ||
| 1053 | + }); | ||
| 1054 | + }, | ||
| 1055 | + | ||
| 1056 | + tabClick3: function (t) { | ||
| 1057 | + var e = this; | ||
| 1058 | + if (t.currentTarget.id != this.data.activeCategoryId3) { | ||
| 1059 | + e.data.c_curr_p = 1; | ||
| 1060 | + this.setData({ | ||
| 1061 | + activeCategoryId3: t.currentTarget.id, | ||
| 1062 | + comments: null, comments_no_more: 0, get_c: 0, | ||
| 1063 | + }); | ||
| 1064 | + this.requestComments_new(); | ||
| 1065 | + } | ||
| 1066 | + }, | ||
| 1067 | + | ||
| 1068 | + doScrollTop: function () { | ||
| 1069 | + wx.pageScrollTo({ | ||
| 1070 | + scrollTop: 0 | ||
| 1071 | + }); | ||
| 1072 | + }, | ||
| 1073 | + | ||
| 1074 | + tabComment: function () { | ||
| 1075 | + this.setData({ | ||
| 1076 | + activeCategoryId: 2, comments_no_more: 0, get_c: 0 | ||
| 1077 | + }), this.data.comments || this.requestComments_new(); | ||
| 1078 | + }, | ||
| 1079 | + | ||
| 1080 | + //商品详情的时候调用 | ||
| 1081 | + tabGoodsContent: function () { | ||
| 1082 | + var th = this, | ||
| 1083 | + i = getApp().request; | ||
| 1084 | + this.setData({ | ||
| 1085 | + activeCategoryId: 1 | ||
| 1086 | + }); | ||
| 1087 | + | ||
| 1088 | + if (th.data.cat_name == '') { | ||
| 1089 | + //过去国别,分类,品牌的名称 | ||
| 1090 | + i.get("/api/weshop/goodscategory/get/" + o.stoid + "/" + th.data.data.cat_id, { | ||
| 1091 | + success: function (t) { | ||
| 1092 | + var dd = t.data.data; | ||
| 1093 | + if (t.data.code == 0) { | ||
| 1094 | + th.setData({ | ||
| 1095 | + cat_name: dd.name | ||
| 1096 | + }); | ||
| 1097 | + } | ||
| 1098 | + } | ||
| 1099 | + }); | ||
| 1100 | + //过去国别,分类,品牌的名称 | ||
| 1101 | + i.get("/api/weshop/brand/get/" + o.stoid + "/" + th.data.data.brand_id, { | ||
| 1102 | + success: function (t) { | ||
| 1103 | + var dd = t.data.data; | ||
| 1104 | + if (t.data.code == 0) { | ||
| 1105 | + th.setData({ | ||
| 1106 | + brand_name: dd.name | ||
| 1107 | + }); | ||
| 1108 | + } | ||
| 1109 | + } | ||
| 1110 | + }); | ||
| 1111 | + //过去国别,分类,品牌的名称 | ||
| 1112 | + i.get("/api/weshop/nation/get/" + o.stoid + "/" + th.data.data.nation_id, { | ||
| 1113 | + success: function (t) { | ||
| 1114 | + var dd = t.data.data; | ||
| 1115 | + if (t.data.code == 0) { | ||
| 1116 | + th.setData({ | ||
| 1117 | + nation_name: dd.name | ||
| 1118 | + }); | ||
| 1119 | + } | ||
| 1120 | + } | ||
| 1121 | + }); | ||
| 1122 | + } | ||
| 1123 | + }, | ||
| 1124 | + | ||
| 1125 | + //获取redis中的数量 | ||
| 1126 | + async getactLen(func) { | ||
| 1127 | + var r_num = 0, | ||
| 1128 | + prom_type = this.data.prom_type, | ||
| 1129 | + prom_id = this.data.prom_id; | ||
| 1130 | + await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + os.stoid + "/" + prom_type + "/" + prom_id, { | ||
| 1131 | + 1: 1 | ||
| 1132 | + }).then(res => { | ||
| 1133 | + var em = res; | ||
| 1134 | + if (em.data.code == 0) { | ||
| 1135 | + r_num = em.data.data; | ||
| 1136 | + } | ||
| 1137 | + }) | ||
| 1138 | + func(r_num); | ||
| 1139 | + }, | ||
| 1140 | + | ||
| 1141 | + //------------加入购物车-------------- | ||
| 1142 | + addCart: function (t) { | ||
| 1143 | + var th = this; | ||
| 1144 | + var ind = t.currentTarget.dataset.openSpecModal_ind; | ||
| 1145 | + if (!ind) ind = t.currentTarget.dataset.openspecmodal_ind; | ||
| 1146 | + th.setData({ | ||
| 1147 | + open_ind_store: ind | ||
| 1148 | + }); | ||
| 1149 | + | ||
| 1150 | + | ||
| 1151 | + if ("add" == t.currentTarget.dataset.action && getApp().is_sp_hao()) { | ||
| 1152 | + wx.showToast({ | ||
| 1153 | + title: "视频号商品不允许加入购物车", | ||
| 1154 | + icon: 'none', | ||
| 1155 | + duration: 2000 | ||
| 1156 | + }); | ||
| 1157 | + return false; | ||
| 1158 | + } | ||
| 1159 | + | ||
| 1160 | + | ||
| 1161 | + | ||
| 1162 | + //如果是秒杀的话,要看redis够不够 | ||
| 1163 | + if (this.data.prom_type == 1 || this.data.prom_type == 2) { | ||
| 1164 | + | ||
| 1165 | + if (this.data.openSpecModal_flash_normal) { | ||
| 1166 | + this.data.is_normal=1; //是普通购买 | ||
| 1167 | + th.add_cart_func(t); | ||
| 1168 | + return false; | ||
| 1169 | + } | ||
| 1170 | + | ||
| 1171 | + | ||
| 1172 | + this.getactLen(function (num) { | ||
| 1173 | + if (num < th.data.goodsInputNum) { | ||
| 1174 | + | ||
| 1175 | + // getApp().my_warnning("活动库存不足!", 0, th); | ||
| 1176 | + wx.showToast({ title: '活动库存不足!', icon: 'none', }); | ||
| 1177 | + return false; | ||
| 1178 | + } else { | ||
| 1179 | + th.add_cart_func(t); | ||
| 1180 | + } | ||
| 1181 | + }); | ||
| 1182 | + } else { | ||
| 1183 | + th.add_cart_func(t); | ||
| 1184 | + } | ||
| 1185 | + }, | ||
| 1186 | + | ||
| 1187 | + //-- 加入购物的函数 -- | ||
| 1188 | + add_cart_func_inte: function (t) { | ||
| 1189 | + var i = getApp().request; | ||
| 1190 | + if (oo.user_id == null) { | ||
| 1191 | + return s.my_warnning("还未登录!", 0, this); | ||
| 1192 | + } | ||
| 1193 | + if (!getApp().globalData.userInfo) { | ||
| 1194 | + return s.my_warnning("还未登录!", 0, this); | ||
| 1195 | + } | ||
| 1196 | + | ||
| 1197 | + var e = this, | ||
| 1198 | + th = e, | ||
| 1199 | + a = 0, | ||
| 1200 | + o = this.data.data; | ||
| 1201 | + a = o.goods_id; | ||
| 1202 | + | ||
| 1203 | + //----------添加到购物车时,要判断限购数量,-------- | ||
| 1204 | + e.get_buy_num(o, function (ee) { | ||
| 1205 | + //---判断商品是否超出限购--- | ||
| 1206 | + if (th.data.g_buy_num != null && th.data.sele_g.viplimited > 0) { | ||
| 1207 | + if (th.data.goodsInputNum + th.data.g_buy_num.get(th.data.sele_g.goods_id) > th.data.sele_g.viplimited) { | ||
| 1208 | + wx.showToast({ title: '超出商品限购', icon: 'none', }); | ||
| 1209 | + // s.my_warnning('超出商品限购', 0, th); | ||
| 1210 | + return false; | ||
| 1211 | + } | ||
| 1212 | + } | ||
| 1213 | + //---判断商品是否超出活动限购--- | ||
| 1214 | + if (th.data.prom_buy_num != -1 && th.data.prom_buy_limit > 0) { | ||
| 1215 | + if (th.data.goodsInputNum + th.data.prom_buy_num > th.data.prom_buy_limit) { | ||
| 1216 | + wx.showToast({ | ||
| 1217 | + title: '超出商品活动限购', | ||
| 1218 | + icon: 'none', | ||
| 1219 | + }); | ||
| 1220 | + // s.my_warnning('超出商品活动限购', 0, th); | ||
| 1221 | + return false; | ||
| 1222 | + } | ||
| 1223 | + } | ||
| 1224 | + | ||
| 1225 | + if (th.data.goodsInputNum <= 0) return s.my_warnning("商品数量不能为0", 0, th); | ||
| 1226 | + if (th.data.sto_sele_name == null || th.data.sto_sele_name == undefined) | ||
| 1227 | + this.setData({ | ||
| 1228 | + sto_sele_name: "" | ||
| 1229 | + }); | ||
| 1230 | + if (th.data.sto_sele_name == "") return s.my_warnning("请选择门店", 0, th); | ||
| 1231 | + | ||
| 1232 | + //--------------此时操作的数据------------ | ||
| 1233 | + var newd = { | ||
| 1234 | + goods_id: o.goods_id, | ||
| 1235 | + goods_num: th.data.goodsInputNum, | ||
| 1236 | + pick_id: th.data.sto_sele_id, | ||
| 1237 | + user_id: oo.user_id, | ||
| 1238 | + store_id: th.data.stoid, | ||
| 1239 | + goods_price: th.data.prom_price, | ||
| 1240 | + integral: th.data.prom_integral, | ||
| 1241 | + member_goods_price: o.shop_price, | ||
| 1242 | + goods_name: o.goods_name, | ||
| 1243 | + goods_sn: o.goods_sn, | ||
| 1244 | + sku: o.sku, | ||
| 1245 | + }; | ||
| 1246 | + | ||
| 1247 | + //---是不是从收藏夹出来的--- | ||
| 1248 | + if (th.data.c_guide_id) { | ||
| 1249 | + newd['guide_id'] = th.data.c_guide_id; | ||
| 1250 | + newd['guide_type'] = 2; | ||
| 1251 | + if ("add" == t.currentTarget.dataset.action) newd['guide_type'] = 3; | ||
| 1252 | + } else { | ||
| 1253 | + if (getApp().globalData.guide_id) { | ||
| 1254 | + newd['guide_id'] = getApp().globalData.guide_id; | ||
| 1255 | + newd['guide_type'] = 0; | ||
| 1256 | + if ("add" == t.currentTarget.dataset.action) newd['guide_type'] = 1; | ||
| 1257 | + } | ||
| 1258 | + } | ||
| 1259 | + | ||
| 1260 | + //让商品带上房间号 | ||
| 1261 | + //让商品带上房间号 | ||
| 1262 | + if (!th.data.sys_switch.is_skuroom_id && th.data.sys_switch.is_skuroom_id == 1) { | ||
| 1263 | + if (th.data.data.goods_id == getApp().globalData.room_goods_id) { | ||
| 1264 | + newd.room_id = getApp().globalData.room_id; | ||
| 1265 | + } | ||
| 1266 | + } else { | ||
| 1267 | + if (newd.goods_id == getApp().globalData.room_goods_id) newd.room_id = getApp().globalData.room_id; | ||
| 1268 | + } | ||
| 1269 | + | ||
| 1270 | + //如果是积分够,is_integral_normal就要有积分购普通购买字段 | ||
| 1271 | + //if(o.prom_type==4){ | ||
| 1272 | + //newd.is_integral_normal=1; | ||
| 1273 | + //} | ||
| 1274 | + | ||
| 1275 | + //-----如果是秒杀,团购,积分购,拼团----- | ||
| 1276 | + newd.prom_type = th.data.prom_type; | ||
| 1277 | + newd.prom_id = th.data.prom_id; | ||
| 1278 | + if (o.store_count <= 0) { | ||
| 1279 | + wx.showToast({ | ||
| 1280 | + title: '库存已为空!', | ||
| 1281 | + icon: 'none', | ||
| 1282 | + }); | ||
| 1283 | + return false; | ||
| 1284 | + // return s.my_warnning("库存已为空!", 0, th); | ||
| 1285 | + }; | ||
| 1286 | + if (o.store_count < e.data.goodsInputNum) { | ||
| 1287 | + wx.showToast({ | ||
| 1288 | + title: '库存不足!', | ||
| 1289 | + icon: 'none', | ||
| 1290 | + }); | ||
| 1291 | + return false; | ||
| 1292 | + // return s.my_warnning("库存不足!", 0, th); | ||
| 1293 | + }; | ||
| 1294 | + | ||
| 1295 | + var i_canbuy = th.data.prom_act.limitqty - th.data.prom_act.buy_num; | ||
| 1296 | + if (i_canbuy < e.data.goodsInputNum) { | ||
| 1297 | + wx.showToast({ | ||
| 1298 | + title: '活动库存不足!', | ||
| 1299 | + icon: 'none', | ||
| 1300 | + }); | ||
| 1301 | + return false; | ||
| 1302 | + // return s.my_warnning("活动库存不足!", 0, th); | ||
| 1303 | + } | ||
| 1304 | + th.add_cart_next(e, t, a, o, newd); //立即购买下一步 | ||
| 1305 | + | ||
| 1306 | + }) | ||
| 1307 | + }, | ||
| 1308 | + | ||
| 1309 | + //-- 加入购物的函数 -- | ||
| 1310 | + add_cart_func: function (t) { | ||
| 1311 | + var i = getApp().request; | ||
| 1312 | + if (oo.user_id == null) { | ||
| 1313 | + return s.my_warnning("还未登录!", 0, this); | ||
| 1314 | + } | ||
| 1315 | + | ||
| 1316 | + if (!getApp().globalData.userInfo) { | ||
| 1317 | + return s.my_warnning("还未登录!", 0, this); | ||
| 1318 | + } | ||
| 1319 | + | ||
| 1320 | + var e = this, | ||
| 1321 | + th = e, | ||
| 1322 | + a = 0, | ||
| 1323 | + o = this.data.sele_g; | ||
| 1324 | + a = o.goods_id; | ||
| 1325 | + | ||
| 1326 | + //----------添加到购物车时,要判断限购数量,-------- | ||
| 1327 | + e.get_buy_num(o, function (ee) { | ||
| 1328 | + //---判断商品是否超出限购--- | ||
| 1329 | + if (th.data.g_buy_num != null && th.data.sele_g.viplimited > 0) { | ||
| 1330 | + if (th.data.goodsInputNum + th.data.g_buy_num.get(th.data.sele_g.goods_id) > th.data.sele_g.viplimited) { | ||
| 1331 | + wx.showToast({ | ||
| 1332 | + title: '超出商品限购', | ||
| 1333 | + icon: 'none', | ||
| 1334 | + }); | ||
| 1335 | + // s.my_warnning('超出商品限购', 0, th); | ||
| 1336 | + return false; | ||
| 1337 | + } | ||
| 1338 | + } | ||
| 1339 | + //---判断商品是否超出活动限购--- | ||
| 1340 | + if ((th.data.prom_buy_num != -1 && th.data.prom_buy_limit > 0) && !th.data.is_normal) { | ||
| 1341 | + if (th.data.goodsInputNum + th.data.prom_buy_num > th.data.prom_buy_limit) { | ||
| 1342 | + wx.showToast({ | ||
| 1343 | + title: '超出商品活动限购', | ||
| 1344 | + icon: 'none', | ||
| 1345 | + }); | ||
| 1346 | + // s.my_warnning('超出商品活动限购', 0, th); | ||
| 1347 | + return false; | ||
| 1348 | + } | ||
| 1349 | + } | ||
| 1350 | + | ||
| 1351 | + if (th.data.goodsInputNum <= 0) return s.my_warnning("商品数量不能为0", 0, th); | ||
| 1352 | + if (th.data.sto_sele_name == null || th.data.sto_sele_name == undefined) | ||
| 1353 | + this.setData({ | ||
| 1354 | + sto_sele_name: "" | ||
| 1355 | + }); | ||
| 1356 | + if (th.data.sto_sele_name == "") return s.my_warnning("请选择门店", 0, th); | ||
| 1357 | + | ||
| 1358 | + //--------------此时操作的数据------------ | ||
| 1359 | + var newd = { | ||
| 1360 | + goods_id: o.goods_id, | ||
| 1361 | + goods_num: th.data.goodsInputNum, | ||
| 1362 | + pick_id: th.data.sto_sele_id, | ||
| 1363 | + user_id: oo.user_id, | ||
| 1364 | + store_id: th.data.stoid, | ||
| 1365 | + goods_price: o.shop_price, | ||
| 1366 | + member_goods_price: o.shop_price, | ||
| 1367 | + goods_name: o.goods_name, | ||
| 1368 | + goods_sn: o.goods_sn, | ||
| 1369 | + sku: o.sku, | ||
| 1370 | + prom_id: th.data.sele_g.prom_id, | ||
| 1371 | + prom_type: th.data.sele_g.prom_type, | ||
| 1372 | + }; | ||
| 1373 | + | ||
| 1374 | + //---是不是从收藏夹出来的--- | ||
| 1375 | + if (th.data.c_guide_id) { | ||
| 1376 | + newd['guide_id'] = th.data.c_guide_id; | ||
| 1377 | + newd['guide_type'] = 2; | ||
| 1378 | + if ("add" == t.currentTarget.dataset.action) newd['guide_type'] = 3; | ||
| 1379 | + } else { | ||
| 1380 | + if (getApp().globalData.guide_id) { | ||
| 1381 | + newd['guide_id'] = getApp().globalData.guide_id; | ||
| 1382 | + newd['guide_type'] = 0; | ||
| 1383 | + if ("add" == t.currentTarget.dataset.action) newd['guide_type'] = 1; | ||
| 1384 | + } | ||
| 1385 | + } | ||
| 1386 | + | ||
| 1387 | + //让商品带上房间号 | ||
| 1388 | + //让商品带上房间号 | ||
| 1389 | + if (!th.data.sys_switch.is_skuroom_id && th.data.sys_switch.is_skuroom_id == 1) { | ||
| 1390 | + if (th.data.data.goods_id == getApp().globalData.room_goods_id) { | ||
| 1391 | + newd.room_id = getApp().globalData.room_id; | ||
| 1392 | + } | ||
| 1393 | + } else { | ||
| 1394 | + if (newd.goods_id == getApp().globalData.room_goods_id) newd.room_id = getApp().globalData.room_id; | ||
| 1395 | + } | ||
| 1396 | + | ||
| 1397 | + //如果是积分够,is_integral_normal就要有积分购普通购买字段 | ||
| 1398 | + if (o.prom_type == 4) { | ||
| 1399 | + newd.is_integral_normal = 1; | ||
| 1400 | + } | ||
| 1401 | + | ||
| 1402 | + //如果有线下取价 | ||
| 1403 | + if (o.offline_price) { | ||
| 1404 | + newd.offline_price = o.offline_price; | ||
| 1405 | + newd.pricing_type = o.pricing_type; | ||
| 1406 | + } | ||
| 1407 | + | ||
| 1408 | + //-----如果是秒杀,团购,积分购,拼团----- | ||
| 1409 | + if (th.data.prom_type == 1 || th.data.prom_type == 2) { | ||
| 1410 | + | ||
| 1411 | + if (th.data.openSpecModal_flash_normal) { | ||
| 1412 | + | ||
| 1413 | + newd.prom_type = 0; | ||
| 1414 | + newd.prom_id = 0; | ||
| 1415 | + | ||
| 1416 | + //---如果是线下门店销售的时候--- | ||
| 1417 | + if (th.data.sales_rules == 2) { | ||
| 1418 | + var pick = th.get_pick_from_list(th.data.sto_sele_id) | ||
| 1419 | + //---通过接口获取门店的线下库存信息-- | ||
| 1420 | + getApp().request.get("/api/weshop/goods/getWareStorages", { | ||
| 1421 | + data: { | ||
| 1422 | + storageNos: pick.pickup_no, | ||
| 1423 | + wareIds: encodeURIComponent(th.data.sele_g.erpwareid), | ||
| 1424 | + storeId: os.stoid | ||
| 1425 | + }, | ||
| 1426 | + success: function (res) { | ||
| 1427 | + if (res.data.code == 0) { | ||
| 1428 | + if (res.data.data.pageData.length > 0) { | ||
| 1429 | + var CanOutQty = res.data.data.pageData[0].CanOutQty; | ||
| 1430 | + if (CanOutQty < e.data.goodsInputNum) { | ||
| 1431 | + wx.showToast({ title: '库存不足!', icon: 'none', }); | ||
| 1432 | + return false; | ||
| 1433 | + // return s.my_warnning("库存不足!", 0, th); | ||
| 1434 | + } | ||
| 1435 | + //在调一次接口,读取商品的预出库的数量,lock | ||
| 1436 | + getApp().request.get("/api/weshop/order/ware/lock/page", { | ||
| 1437 | + data: { | ||
| 1438 | + store_id: os.stoid, | ||
| 1439 | + wareId: th.data.sele_g.goods_id, | ||
| 1440 | + storageId: pick.pickup_id, | ||
| 1441 | + pageSize: 1000 | ||
| 1442 | + }, | ||
| 1443 | + success: function (res_data) { | ||
| 1444 | + if (res_data.data.code == 0 && res_data.data.data.total > 0) { | ||
| 1445 | + | ||
| 1446 | + var lock = 0; | ||
| 1447 | + for (var i in res_data.data.data.pageData) { | ||
| 1448 | + lock += res_data.data.data.pageData[i].outQty; | ||
| 1449 | + } | ||
| 1450 | + | ||
| 1451 | + if (CanOutQty <= lock) { | ||
| 1452 | + wx.showToast({ | ||
| 1453 | + title: '库存不足!', | ||
| 1454 | + icon: 'none', | ||
| 1455 | + }); | ||
| 1456 | + return false; | ||
| 1457 | + //return s.my_warnning("库存不足!", 0, th); | ||
| 1458 | + } | ||
| 1459 | + th.add_cart_next(e, t, a, o, newd, CanOutQty - lock); | ||
| 1460 | + } else { | ||
| 1461 | + th.add_cart_next(e, t, a, o, newd, CanOutQty); | ||
| 1462 | + } | ||
| 1463 | + } | ||
| 1464 | + }) | ||
| 1465 | + } else { | ||
| 1466 | + wx.showToast({ | ||
| 1467 | + title: '库存不足!', | ||
| 1468 | + icon: 'none', | ||
| 1469 | + }); | ||
| 1470 | + return false; | ||
| 1471 | + // return s.my_warnning("库存不足!", 0, th); | ||
| 1472 | + } | ||
| 1473 | + | ||
| 1474 | + } | ||
| 1475 | + } | ||
| 1476 | + }) | ||
| 1477 | + } else { | ||
| 1478 | + if (o.store_count <= 0) { | ||
| 1479 | + wx.showToast({ | ||
| 1480 | + title: '库存已为空!', | ||
| 1481 | + icon: 'none' | ||
| 1482 | + }); | ||
| 1483 | + return false; | ||
| 1484 | + // s.my_warnning("库存已为空!", 0, th); | ||
| 1485 | + }; | ||
| 1486 | + if (o.store_count < e.data.goodsInputNum) { | ||
| 1487 | + wx.showToast({ | ||
| 1488 | + title: '库存不足!', | ||
| 1489 | + icon: 'none', | ||
| 1490 | + }); | ||
| 1491 | + return false; | ||
| 1492 | + // return s.my_warnning("库存不足!", 0, th); | ||
| 1493 | + }; | ||
| 1494 | + th.add_cart_next(e, t, a, o, newd); //加入购物车下一步 | ||
| 1495 | + }; | ||
| 1496 | + | ||
| 1497 | + return false; | ||
| 1498 | + } | ||
| 1499 | + | ||
| 1500 | + | ||
| 1501 | + newd.goods_price = th.data.prom_price; | ||
| 1502 | + newd.member_goods_price = th.data.prom_price, | ||
| 1503 | + newd.prom_type = th.data.prom_type; | ||
| 1504 | + newd.prom_id = th.data.prom_id; | ||
| 1505 | + | ||
| 1506 | + if (o.store_count <= 0) { | ||
| 1507 | + wx.showToast({ | ||
| 1508 | + title: '库存已为空!', | ||
| 1509 | + icon: 'none', | ||
| 1510 | + }); | ||
| 1511 | + return false; | ||
| 1512 | + //return s.my_warnning("库存已为空!", 0, th); | ||
| 1513 | + }; | ||
| 1514 | + if (o.store_count < e.data.goodsInputNum) { | ||
| 1515 | + wx.showToast({ | ||
| 1516 | + title: '库存不足!', | ||
| 1517 | + icon: 'none', | ||
| 1518 | + }); | ||
| 1519 | + return false; | ||
| 1520 | + // return s.my_warnning("库存不足!", 0, th); | ||
| 1521 | + }; | ||
| 1522 | + | ||
| 1523 | + th.add_cart_next(e, t, a, o, newd); //加入购物车下一步 | ||
| 1524 | + | ||
| 1525 | + } else if (o.prom_type == 7) { | ||
| 1526 | + | ||
| 1527 | + //判断进行中的活动,是不是要判断线下库存 | ||
| 1528 | + th.check_zh_acting(function (ee) { | ||
| 1529 | + newd.prom_id = 0; | ||
| 1530 | + newd.prom_type = 0; | ||
| 1531 | + if (ee && th.data.sele_g.act) { | ||
| 1532 | + newd.prom_id = th.data.sele_g.act.id; | ||
| 1533 | + newd.prom_type = 7; | ||
| 1534 | + if (o.store_count <= 0) { | ||
| 1535 | + wx.showToast({ | ||
| 1536 | + title: '库存已为空!', | ||
| 1537 | + icon: 'none', | ||
| 1538 | + }); | ||
| 1539 | + return false; | ||
| 1540 | + //return s.my_warnning("库存已为空!", 0, th); | ||
| 1541 | + }; | ||
| 1542 | + if (o.store_count < e.data.goodsInputNum) { | ||
| 1543 | + wx.showToast({ | ||
| 1544 | + title: '库存不足!', | ||
| 1545 | + icon: 'none', | ||
| 1546 | + }); | ||
| 1547 | + return false; | ||
| 1548 | + //return s.my_warnning("库存不足!", 0, th); | ||
| 1549 | + }; | ||
| 1550 | + th.add_cart_next(e, t, a, o, newd); //加入购物车下一步 | ||
| 1551 | + return false; | ||
| 1552 | + } else { | ||
| 1553 | + //---如果是线下门店销售的时候--- | ||
| 1554 | + if (th.data.sales_rules == 2) { | ||
| 1555 | + var pick = th.get_pick_from_list(th.data.sto_sele_id) | ||
| 1556 | + //---通过接口获取门店的线下库存信息-- | ||
| 1557 | + getApp().request.get("/api/weshop/goods/getWareStorages", { | ||
| 1558 | + data: { | ||
| 1559 | + storageNos: pick.pickup_no, | ||
| 1560 | + wareIds: encodeURIComponent(th.data.sele_g.erpwareid), | ||
| 1561 | + storeId: os.stoid | ||
| 1562 | + }, | ||
| 1563 | + success: function (res) { | ||
| 1564 | + if (res.data.code == 0) { | ||
| 1565 | + if (res.data.data.pageData.length > 0) { | ||
| 1566 | + var CanOutQty = res.data.data.pageData[0].CanOutQty; | ||
| 1567 | + if (CanOutQty < e.data.goodsInputNum) { | ||
| 1568 | + wx.showToast({ | ||
| 1569 | + title: '库存不足!', | ||
| 1570 | + icon: 'none', | ||
| 1571 | + }); | ||
| 1572 | + return false; | ||
| 1573 | + //return s.my_warnning("库存不足!", 0, th); | ||
| 1574 | + } | ||
| 1575 | + //在调一次接口,读取商品的预出库的数量,lock | ||
| 1576 | + getApp().request.get("/api/weshop/order/ware/lock/page", { | ||
| 1577 | + data: { | ||
| 1578 | + store_id: os.stoid, | ||
| 1579 | + wareId: th.data.sele_g.goods_id, | ||
| 1580 | + storageId: pick.pickup_id, | ||
| 1581 | + pageSize: 1000 | ||
| 1582 | + }, | ||
| 1583 | + success: function (res_data) { | ||
| 1584 | + if (res_data.data.code == 0 && res_data.data.data.total > 0) { | ||
| 1585 | + | ||
| 1586 | + var lock = 0; | ||
| 1587 | + for (var i in res_data.data.data.pageData) { | ||
| 1588 | + lock += res_data.data.data.pageData[i].outQty; | ||
| 1589 | + } | ||
| 1590 | + | ||
| 1591 | + if (CanOutQty <= lock) { | ||
| 1592 | + wx.showToast({ | ||
| 1593 | + title: '库存不足!', | ||
| 1594 | + icon: 'none', | ||
| 1595 | + }); | ||
| 1596 | + return false; | ||
| 1597 | + //return s.my_warnning("库存不足!", 0, th); | ||
| 1598 | + } | ||
| 1599 | + th.add_cart_next(e, t, a, o, newd, CanOutQty - lock); | ||
| 1600 | + } else { | ||
| 1601 | + th.add_cart_next(e, t, a, o, newd, CanOutQty); | ||
| 1602 | + } | ||
| 1603 | + } | ||
| 1604 | + }) | ||
| 1605 | + } else { | ||
| 1606 | + return s.my_warnning("库存不足!", 0, th); | ||
| 1607 | + } | ||
| 1608 | + | ||
| 1609 | + } | ||
| 1610 | + } | ||
| 1611 | + }) | ||
| 1612 | + } else { | ||
| 1613 | + if (o.store_count <= 0) { | ||
| 1614 | + wx.showToast({ | ||
| 1615 | + title: '库存已为空!', | ||
| 1616 | + icon: 'none', | ||
| 1617 | + }); | ||
| 1618 | + return false; | ||
| 1619 | + //return s.my_warnning("库存已为空!", 0, th); | ||
| 1620 | + }; | ||
| 1621 | + if (o.store_count < e.data.goodsInputNum) { | ||
| 1622 | + wx.showToast({ | ||
| 1623 | + title: '库存不足!', | ||
| 1624 | + icon: 'none', | ||
| 1625 | + }); | ||
| 1626 | + return false; | ||
| 1627 | + //return s.my_warnning("库存不足!", 0, th); | ||
| 1628 | + }; | ||
| 1629 | + th.add_cart_next(e, t, a, o, newd); //加入购物车下一步 | ||
| 1630 | + } | ||
| 1631 | + } | ||
| 1632 | + }) | ||
| 1633 | + | ||
| 1634 | + } | ||
| 1635 | + else if (th.data.prom_type == 0 || th.data.prom_type == 3 || th.data.prom_type == 4 || th.data.prom_type == 5 || th.data.prom_type == 10) { | ||
| 1636 | + newd.prom_type = 0; | ||
| 1637 | + newd.prom_id = 0; | ||
| 1638 | + | ||
| 1639 | + if (th.data.prom_type == 10) { | ||
| 1640 | + newd.prom_type = th.data.prom_type; | ||
| 1641 | + newd.prom_id = th.data.prom_id; | ||
| 1642 | + } | ||
| 1643 | + | ||
| 1644 | + //---如果是线下门店销售的时候--- | ||
| 1645 | + if (th.data.sales_rules == 2) { | ||
| 1646 | + var pick = th.get_pick_from_list(th.data.sto_sele_id) | ||
| 1647 | + //---通过接口获取门店的线下库存信息-- | ||
| 1648 | + getApp().request.get("/api/weshop/goods/getWareStorages", { | ||
| 1649 | + data: { | ||
| 1650 | + storageNos: pick.pickup_no, | ||
| 1651 | + wareIds: encodeURIComponent(th.data.sele_g.erpwareid), | ||
| 1652 | + storeId: os.stoid | ||
| 1653 | + }, | ||
| 1654 | + success: function (res) { | ||
| 1655 | + if (res.data.code == 0) { | ||
| 1656 | + if (res.data.data.pageData.length > 0) { | ||
| 1657 | + var CanOutQty = res.data.data.pageData[0].CanOutQty; | ||
| 1658 | + if (CanOutQty < e.data.goodsInputNum) { | ||
| 1659 | + wx.showToast({ | ||
| 1660 | + title: '库存不足!', | ||
| 1661 | + icon: 'none', | ||
| 1662 | + }); | ||
| 1663 | + return false; | ||
| 1664 | + //return s.my_warnning("库存不足!", 0, th); | ||
| 1665 | + } | ||
| 1666 | + //在调一次接口,读取商品的预出库的数量,lock | ||
| 1667 | + getApp().request.get("/api/weshop/order/ware/lock/page", { | ||
| 1668 | + data: { | ||
| 1669 | + store_id: os.stoid, | ||
| 1670 | + wareId: th.data.sele_g.goods_id, | ||
| 1671 | + storageId: pick.pickup_id, | ||
| 1672 | + pageSize: 1000 | ||
| 1673 | + }, | ||
| 1674 | + success: function (res_data) { | ||
| 1675 | + if (res_data.data.code == 0 && res_data.data.data.total > 0) { | ||
| 1676 | + | ||
| 1677 | + var lock = 0; | ||
| 1678 | + for (var i in res_data.data.data.pageData) { | ||
| 1679 | + lock += res_data.data.data.pageData[i].outQty; | ||
| 1680 | + } | ||
| 1681 | + | ||
| 1682 | + if (CanOutQty <= lock) { | ||
| 1683 | + wx.showToast({ | ||
| 1684 | + title: '库存不足!', | ||
| 1685 | + icon: 'none', | ||
| 1686 | + }); | ||
| 1687 | + return false; | ||
| 1688 | + //return s.my_warnning("库存不足!", 0, th); | ||
| 1689 | + } | ||
| 1690 | + th.add_cart_next(e, t, a, o, newd, CanOutQty - lock); | ||
| 1691 | + } else { | ||
| 1692 | + th.add_cart_next(e, t, a, o, newd, CanOutQty); | ||
| 1693 | + } | ||
| 1694 | + } | ||
| 1695 | + }) | ||
| 1696 | + } else { | ||
| 1697 | + wx.showToast({ | ||
| 1698 | + title: '库存不足!', | ||
| 1699 | + icon: 'none', | ||
| 1700 | + }); | ||
| 1701 | + return false; | ||
| 1702 | + //return s.my_warnning("库存不足!", 0, th); | ||
| 1703 | + } | ||
| 1704 | + | ||
| 1705 | + } | ||
| 1706 | + } | ||
| 1707 | + }) | ||
| 1708 | + } else { | ||
| 1709 | + if (o.store_count <= 0) { | ||
| 1710 | + wx.showToast({ | ||
| 1711 | + title: '库存已为空!', | ||
| 1712 | + icon: 'none', | ||
| 1713 | + }); | ||
| 1714 | + return false; | ||
| 1715 | + //return s.my_warnning("库存已为空!", 0, th); | ||
| 1716 | + }; | ||
| 1717 | + if (o.store_count < e.data.goodsInputNum) { | ||
| 1718 | + wx.showToast({ | ||
| 1719 | + title: '库存不足!', | ||
| 1720 | + icon: 'none', | ||
| 1721 | + }); | ||
| 1722 | + return false; | ||
| 1723 | + //return s.my_warnning("库存不足!", 0, th); | ||
| 1724 | + }; | ||
| 1725 | + th.add_cart_next(e, t, a, o, newd); //加入购物车下一步 | ||
| 1726 | + } | ||
| 1727 | + } | ||
| 1728 | + }) | ||
| 1729 | + }, | ||
| 1730 | + | ||
| 1731 | + //---加入购物车的最后一步--- | ||
| 1732 | + add_cart_next(e, t, a, o, newd, CanOutQty) { | ||
| 1733 | + var th = this, i = getApp().request; | ||
| 1734 | + //---如果商品不是积分购和拼团,要判断一个是否要进行等级价的判断------ | ||
| 1735 | + if ((o.prom_type != 1 || o.prom_id <= 0) && ((o.prom_type != 6 && o.prom_type != 4 && o.prom_type != 2 ) || th.data.is_normal)) { | ||
| 1736 | + var conf = th.data.bconfig; | ||
| 1737 | + if (conf.switch_list && getApp().globalData.userInfo['card_field'] && getApp().globalData.userInfo['card_expiredate']) { | ||
| 1738 | + var s_list = JSON.parse(conf.switch_list); | ||
| 1739 | + var now = ut.gettimestamp(); | ||
| 1740 | + | ||
| 1741 | + | ||
| 1742 | + var str = getApp().globalData.userInfo['card_expiredate'].replace(/-/g, '/'); | ||
| 1743 | + var end = new Date(str); | ||
| 1744 | + end = Date.parse(end) / 1000; | ||
| 1745 | + | ||
| 1746 | + //--如果后台有开启等级价的功能,而且会员的等级没有过期的情况下-- | ||
| 1747 | + if (parseInt(s_list.rank_switch) == 2 && end > now) { | ||
| 1748 | + var card_price = o[getApp().globalData.userInfo['card_field']]; | ||
| 1749 | + //如果会员有等级价 | ||
| 1750 | + if (getApp().globalData.userInfo['card_field'] != undefined && getApp().globalData.userInfo['card_field'] != null | ||
| 1751 | + && getApp().globalData.userInfo['card_field'] != "" && card_price > 0) { | ||
| 1752 | + newd.goods_price = card_price; | ||
| 1753 | + newd.member_goods_price = card_price; | ||
| 1754 | + } | ||
| 1755 | + } | ||
| 1756 | + } | ||
| 1757 | + } | ||
| 1758 | + | ||
| 1759 | + //if (this.data.data.goods.is_virtual) return this.buyVirtualGoods(d); | ||
| 1760 | + if ("add" == t.currentTarget.dataset.action) { | ||
| 1761 | + | ||
| 1762 | + if (th.data.prom_goods) { | ||
| 1763 | + newd.prom_type = 3; | ||
| 1764 | + newd.prom_id = th.data.prom_goods[0].prom_id; | ||
| 1765 | + } | ||
| 1766 | + | ||
| 1767 | + //----先看会员在购物车中是否加入了该商品----- | ||
| 1768 | + i.get("/api/weshop/cart/page", { | ||
| 1769 | + data: { | ||
| 1770 | + store_id: e.data.stoid, | ||
| 1771 | + user_id: oo.user_id, | ||
| 1772 | + goods_id: a, | ||
| 1773 | + pick_id: e.data.sto_sele_id, | ||
| 1774 | + state: 0 | ||
| 1775 | + }, | ||
| 1776 | + success: function (re) { | ||
| 1777 | + | ||
| 1778 | + //-------如果购物车中有相关的数据--------- | ||
| 1779 | + if (re.data.data.total > 0) { | ||
| 1780 | + | ||
| 1781 | + var item = re.data.data.pageData[0]; | ||
| 1782 | + | ||
| 1783 | + //判断数量,要看下购物车中有没有该商品 | ||
| 1784 | + if (CanOutQty) { | ||
| 1785 | + if (item.goods_num + th.data.goodsInputNum > CanOutQty) { | ||
| 1786 | + wx.showToast({ | ||
| 1787 | + title: '库存不足!', | ||
| 1788 | + icon: 'none', | ||
| 1789 | + }); | ||
| 1790 | + return false; | ||
| 1791 | + // return s.my_warnning("库存不足!", 0, th); | ||
| 1792 | + } | ||
| 1793 | + } else { | ||
| 1794 | + if (item.goods_num + th.data.goodsInputNum > o.store_count) { | ||
| 1795 | + wx.showToast({ | ||
| 1796 | + title: '库存不足!', | ||
| 1797 | + icon: 'none', | ||
| 1798 | + }); | ||
| 1799 | + return false; | ||
| 1800 | + //return s.my_warnning("库存不足!", 0, th); | ||
| 1801 | + } | ||
| 1802 | + } | ||
| 1803 | + | ||
| 1804 | + var updata = { | ||
| 1805 | + id: item.id, | ||
| 1806 | + goods_num: e.data.goodsInputNum + item.goods_num, | ||
| 1807 | + goods_price: newd.goods_price, | ||
| 1808 | + member_goods_price: newd.goods_price, | ||
| 1809 | + store_id: th.data.stoid, | ||
| 1810 | + }; | ||
| 1811 | + | ||
| 1812 | + //---是不是从收藏夹出来的--- | ||
| 1813 | + if (th.data.c_guide_id) { | ||
| 1814 | + updata['guide_id'] = th.data.c_guide_id; | ||
| 1815 | + updata['guide_type'] = 3; //加入购物车之后就变成了3 | ||
| 1816 | + } else { | ||
| 1817 | + if (getApp().globalData.guide_id) { | ||
| 1818 | + updata['guide_id'] = getApp().globalData.guide_id; | ||
| 1819 | + updata['guide_type'] = 0; | ||
| 1820 | + } | ||
| 1821 | + } | ||
| 1822 | + | ||
| 1823 | + i.put("/api/weshop/cart/update", { | ||
| 1824 | + data: updata, | ||
| 1825 | + success: function (t) { | ||
| 1826 | + getApp().my_warnning('加入购物车成功', 1, th, 450); | ||
| 1827 | + var c_num = th.data.cartGoodsNum + th.data.goodsInputNum; | ||
| 1828 | + th.setData({ | ||
| 1829 | + cartGoodsNum: c_num | ||
| 1830 | + }); | ||
| 1831 | + th.closeSpecModal(); | ||
| 1832 | + } | ||
| 1833 | + }); | ||
| 1834 | + } else { | ||
| 1835 | + | ||
| 1836 | + | ||
| 1837 | + i.post("/api/weshop/cart/save", { | ||
| 1838 | + data: newd, | ||
| 1839 | + success: function (t) { | ||
| 1840 | + getApp().my_warnning('加入购物车成功', 1, th, 450); | ||
| 1841 | + var c_num = th.data.cartGoodsNum + e.data.goodsInputNum; | ||
| 1842 | + th.setData({ | ||
| 1843 | + cartGoodsNum: c_num | ||
| 1844 | + }); | ||
| 1845 | + th.closeSpecModal(); | ||
| 1846 | + } | ||
| 1847 | + }); | ||
| 1848 | + } | ||
| 1849 | + } | ||
| 1850 | + }); | ||
| 1851 | + | ||
| 1852 | + } | ||
| 1853 | + else { | ||
| 1854 | + | ||
| 1855 | + //这一步主要是要让立即购买 走 购物车的逻辑 参与活动 | ||
| 1856 | + if (newd.prom_type == 10 || newd.prom_type == 7) { | ||
| 1857 | + //----先看会员在购物车中是否加入了该商品,立即购买的----- | ||
| 1858 | + getApp().request.get("/api/weshop/cart/page", { | ||
| 1859 | + data: { | ||
| 1860 | + store_id: e.data.stoid, | ||
| 1861 | + user_id: oo.user_id, | ||
| 1862 | + state: 1 | ||
| 1863 | + }, | ||
| 1864 | + success: function (res) { | ||
| 1865 | + //-------如果购物车中有相关的数据--------- | ||
| 1866 | + if (res.data.code == 0 && res.data.data.total > 0) { | ||
| 1867 | + for (let j in res.data.data.pageData) { | ||
| 1868 | + let item_j = res.data.data.pageData[j]; | ||
| 1869 | + var url = '/api/weshop/cart/del/' + e.data.stoid + '/' + item_j.id; | ||
| 1870 | + getApp().request.delete(url, {}); | ||
| 1871 | + } | ||
| 1872 | + } | ||
| 1873 | + newd.state = 1; | ||
| 1874 | + getApp().request.post("/api/weshop/cart/save", { | ||
| 1875 | + data: newd, | ||
| 1876 | + success: function (t) { | ||
| 1877 | + th.closeSpecModal(); | ||
| 1878 | + getApp().goto("/pages/cart/cart2/cart2?state=1"); | ||
| 1879 | + } | ||
| 1880 | + }); | ||
| 1881 | + } | ||
| 1882 | + }) | ||
| 1883 | + return false; | ||
| 1884 | + } | ||
| 1885 | + | ||
| 1886 | + if (th.data.prom_goods) { | ||
| 1887 | + var prom_d = th.data.prom_goods; | ||
| 1888 | + for (var i in prom_d) { | ||
| 1889 | + //判断活动有俩种条件,0元 1件 | ||
| 1890 | + var condition_t = prom_d[i].prom_type; | ||
| 1891 | + switch (condition_t) { | ||
| 1892 | + case 0: //按钱 | ||
| 1893 | + if (newd.goods_price >= condition_t) { | ||
| 1894 | + newd.prom_type = 3; | ||
| 1895 | + newd.prom_id = prom_d[i].prom_id; | ||
| 1896 | + } | ||
| 1897 | + break | ||
| 1898 | + case 1://按购买数量 | ||
| 1899 | + if (newd.goods_num >= condition_t) { | ||
| 1900 | + newd.prom_type = 3; | ||
| 1901 | + newd.prom_id = prom_d[i].prom_id; | ||
| 1902 | + } | ||
| 1903 | + break; | ||
| 1904 | + } | ||
| 1905 | + } | ||
| 1906 | + | ||
| 1907 | + } | ||
| 1908 | + | ||
| 1909 | + newd['pick_name'] = th.data.sto_sele_name; | ||
| 1910 | + newd['pick_dis'] = th.data.sto_sele_distr; | ||
| 1911 | + th.buyNow(newd); | ||
| 1912 | + } | ||
| 1913 | + }, | ||
| 1914 | + | ||
| 1915 | + | ||
| 1916 | + //----------购买虚拟商品------ | ||
| 1917 | + buyVirtualGoods: function (e) { | ||
| 1918 | + Object.assign(e, { | ||
| 1919 | + goods_name: this.data.data.goods.goods_name, | ||
| 1920 | + spec_name: this.data.select.specName, | ||
| 1921 | + price: this.data.select.price | ||
| 1922 | + }), wx.navigateTo({ | ||
| 1923 | + url: "/pages/virtual/buy_step/buy_step?" + t.Obj2Str(e) | ||
| 1924 | + }); | ||
| 1925 | + }, | ||
| 1926 | + //----------积分兑换--------- | ||
| 1927 | + exchange: function (e) { | ||
| 1928 | + this.data.shippingCost < 0 || this.data.select.stock <= 0 || wx.navigateTo({ | ||
| 1929 | + url: "/pages/cart/integral/integral?" + t.Obj2Str(e) | ||
| 1930 | + }); | ||
| 1931 | + }, | ||
| 1932 | + | ||
| 1933 | + | ||
| 1934 | + //----------立即购买----------- | ||
| 1935 | + buyNow: function (e) { | ||
| 1936 | + // this.data.shippingCost < 0 || this.data.select.stock <= 0 || (Object.assign(e, { | ||
| 1937 | + // action: "buy_now" | ||
| 1938 | + // }), | ||
| 1939 | + this.setData({ | ||
| 1940 | + openSpecModal: 0, | ||
| 1941 | + openSpecModal_inte: 0, | ||
| 1942 | + openSpecModal_inte_normal: 0, | ||
| 1943 | + openSpecModal_pt: 0, | ||
| 1944 | + }) | ||
| 1945 | + | ||
| 1946 | + if (e.prom_type == 4) { | ||
| 1947 | + s.set_b_now(e); | ||
| 1948 | + var url = "/pages/cart/cart2_inte/cart2_inte?is_bnow=1&goods_id=" + e.goods_id; | ||
| 1949 | + getApp().goto(url); | ||
| 1950 | + } else { | ||
| 1951 | + //要判断积分购的普通购买有没有参加优惠活动 | ||
| 1952 | + if (e.is_integral_normal == 1) { | ||
| 1953 | + this.check_nor_promgood(e.goods_id, function (res) { | ||
| 1954 | + if (res && res.cat_id) { | ||
| 1955 | + e.prom_type = 3; | ||
| 1956 | + e.prom_id = res.cat_id | ||
| 1957 | + } | ||
| 1958 | + s.set_b_now(e); | ||
| 1959 | + /*-- | ||
| 1960 | + wx.redirectTo({ | ||
| 1961 | + url: "/pages/cart/cart2/cart2?is_bnow=1&goods_id=" + e.goods_id, | ||
| 1962 | + });--*/ | ||
| 1963 | + getApp().goto("/pages/cart/cart2/cart2?is_bnow=1&goods_id=" + e.goods_id) | ||
| 1964 | + | ||
| 1965 | + }) | ||
| 1966 | + } else { | ||
| 1967 | + s.set_b_now(e); | ||
| 1968 | + /*-- | ||
| 1969 | + wx.redirectTo({ | ||
| 1970 | + url: "/pages/cart/cart2/cart2?is_bnow=1&goods_id=" + e.goods_id, | ||
| 1971 | + });--*/ | ||
| 1972 | + getApp().goto("/pages/cart/cart2/cart2?is_bnow=1&goods_id=" + e.goods_id) | ||
| 1973 | + } | ||
| 1974 | + | ||
| 1975 | + } | ||
| 1976 | + }, | ||
| 1977 | + | ||
| 1978 | + //----------增加购买数量----------- | ||
| 1979 | + addCartNum: function (t) { | ||
| 1980 | + this.checkCartNum(this.data.goodsInputNum + 1); | ||
| 1981 | + }, | ||
| 1982 | + //----------减少购买数量----------- | ||
| 1983 | + subCartNum: function (t) { | ||
| 1984 | + this.checkCartNum(this.data.goodsInputNum - 1); | ||
| 1985 | + }, | ||
| 1986 | + //----------输入框输入购买数量----------- | ||
| 1987 | + inputCartNum: function (t) { | ||
| 1988 | + this.checkCartNum(Number(t.detail.value)); | ||
| 1989 | + }, | ||
| 1990 | + | ||
| 1991 | + //----------增加购买数量----------- | ||
| 1992 | + addCartNum_inte: function (t) { | ||
| 1993 | + this.checkCartNum_inte(this.data.goodsInputNum + 1); | ||
| 1994 | + }, | ||
| 1995 | + //----------减少购买数量----------- | ||
| 1996 | + subCartNum_inte: function (t) { | ||
| 1997 | + this.checkCartNum_inte(this.data.goodsInputNum - 1); | ||
| 1998 | + }, | ||
| 1999 | + //----------输入框输入购买数量----------- | ||
| 2000 | + inputCartNum_inte: function (t) { | ||
| 2001 | + this.checkCartNum_inte(Number(t.detail.value)); | ||
| 2002 | + }, | ||
| 2003 | + | ||
| 2004 | + | ||
| 2005 | + //------检查数量是不是超出限购------ | ||
| 2006 | + checkCartNum: function (t) { | ||
| 2007 | + var th = this; | ||
| 2008 | + this.get_buy_num(this.data.sele_g, async function () { | ||
| 2009 | + | ||
| 2010 | + //--判断商品是否超出限购-- | ||
| 2011 | + if (th.data.g_buy_num != null && th.data.sele_g.viplimited > 0) { | ||
| 2012 | + | ||
| 2013 | + var gd_buy_num = th.data.g_buy_num.get(th.data.sele_g.goods_id); | ||
| 2014 | + | ||
| 2015 | + if (t + gd_buy_num > th.data.sele_g.viplimited) { | ||
| 2016 | + wx.showToast({ title: '超出商品限购', icon: 'none', }); | ||
| 2017 | + // s.my_warnning('超出商品限购', 0, th); | ||
| 2018 | + var num = th.data.sele_g.viplimited - gd_buy_num; | ||
| 2019 | + if (num < 0) num = 0; | ||
| 2020 | + th.setData({goodsInputNum: num}) | ||
| 2021 | + return false; | ||
| 2022 | + } | ||
| 2023 | + } | ||
| 2024 | + | ||
| 2025 | + //如果是普通购买的情况下 | ||
| 2026 | + if(th.data.openSpecModal_flash_normal) th.data.is_normal=1; | ||
| 2027 | + | ||
| 2028 | + //--判断商品是否超出活动限购-- | ||
| 2029 | + if (th.data.prom_buy_num != -1 && th.data.prom_buy_limit > 0 && !th.data.is_normal) { | ||
| 2030 | + if (t + th.data.prom_buy_num > th.data.prom_buy_limit) { | ||
| 2031 | + wx.showToast({ | ||
| 2032 | + title: '超出商品活动限购', | ||
| 2033 | + icon: 'none', | ||
| 2034 | + }); | ||
| 2035 | + // s.my_warnning('超出商品活动限购', 0, th); | ||
| 2036 | + var num = th.data.prom_buy_limit - th.data.prom_buy_num; | ||
| 2037 | + if (num < 0) num = 0; | ||
| 2038 | + th.setData({goodsInputNum: num}) | ||
| 2039 | + return false; | ||
| 2040 | + } | ||
| 2041 | + } | ||
| 2042 | + | ||
| 2043 | + if ((th.data.sele_g.prom_type == 1 || th.data.sele_g.prom_type == 6) && !th.data.is_normal) { | ||
| 2044 | + var redis_num = 0; | ||
| 2045 | + //------判断活动是否抢光----- | ||
| 2046 | + await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + | ||
| 2047 | + os.stoid + "/" + th.data.sele_g.prom_type + "/" + th.data.sele_g.prom_id, { | ||
| 2048 | + 1: 1 | ||
| 2049 | + }).then(res => { | ||
| 2050 | + redis_num = res.data.data; | ||
| 2051 | + }); | ||
| 2052 | + | ||
| 2053 | + if (t > redis_num) { | ||
| 2054 | + wx.showToast({ | ||
| 2055 | + title: '超出商品活动库存', | ||
| 2056 | + icon: 'none', | ||
| 2057 | + }); | ||
| 2058 | + // s.my_warnning('超出商品活动库存', 0, th); | ||
| 2059 | + th.setData({goodsInputNum: redis_num}) | ||
| 2060 | + return false; | ||
| 2061 | + } | ||
| 2062 | + } | ||
| 2063 | + var e = th.data.sele_g.store_count; | ||
| 2064 | + var p_type = th.data.prom_type; //&& p_type!=1 && p_type!=4 | ||
| 2065 | + if (th.data.sales_rules == 2 && (p_type != 1 && p_type != 4 && p_type != 6 || th.data.openSpecModal_inte_normal == 1 || th.data.is_normal == 1)) { | ||
| 2066 | + if (!th.data.def_pick_store) { | ||
| 2067 | + wx.showToast({ | ||
| 2068 | + title: '请选择门店', | ||
| 2069 | + icon: 'none', | ||
| 2070 | + }); | ||
| 2071 | + // wx.showModal({title: '请选择门店',}); | ||
| 2072 | + return false; | ||
| 2073 | + } else { | ||
| 2074 | + e = th.data.def_pick_store.CanOutQty; | ||
| 2075 | + } | ||
| 2076 | + } | ||
| 2077 | + if (!e) e = 0; | ||
| 2078 | + //库存不足,不增加 | ||
| 2079 | + if (e < t) { | ||
| 2080 | + wx.showToast({ | ||
| 2081 | + title: '库存不足', | ||
| 2082 | + icon: 'none', | ||
| 2083 | + }); | ||
| 2084 | + // wx.showModal({title: '库存不足',}); | ||
| 2085 | + if (e < 0) e = 0; | ||
| 2086 | + th.setData({goodsInputNum: e}); | ||
| 2087 | + return false; | ||
| 2088 | + } | ||
| 2089 | + t > e || 0 == e ? t = e : t < 1 && (t = 1); | ||
| 2090 | + th.setData({goodsInputNum: t}); | ||
| 2091 | + th.is_show_more_buy(); | ||
| 2092 | + | ||
| 2093 | + }) | ||
| 2094 | + }, | ||
| 2095 | + | ||
| 2096 | + //----- 检查一下积分购的限购之类的问题 ----- | ||
| 2097 | + checkCartNum_inte: function (t) { | ||
| 2098 | + var th = this; | ||
| 2099 | + this.get_buy_num(this.data.data, async function () { | ||
| 2100 | + ; | ||
| 2101 | + //--判断商品是否超出限购-- | ||
| 2102 | + if (th.data.g_buy_num != null && th.data.data.viplimited > 0) { | ||
| 2103 | + | ||
| 2104 | + var gd_buy_num = th.data.g_buy_num.get(th.data.sele_g.goods_id); | ||
| 2105 | + | ||
| 2106 | + if (t + gd_buy_num > th.data.sele_g.viplimited) { | ||
| 2107 | + wx.showToast({ title: '超出商品限购', icon: 'none', }); | ||
| 2108 | + // s.my_warnning('超出商品限购', 0, th); | ||
| 2109 | + var num = th.data.sele_g.viplimited - gd_buy_num; | ||
| 2110 | + if (num < 0) num = 0; | ||
| 2111 | + th.setData({goodsInputNum: num}) | ||
| 2112 | + return false; | ||
| 2113 | + } | ||
| 2114 | + } | ||
| 2115 | + | ||
| 2116 | + //--判断商品是否超出活动限购-- | ||
| 2117 | + if (th.data.prom_buy_num != -1 && th.data.prom_buy_limit > 0) { | ||
| 2118 | + if (t + th.data.prom_buy_num > th.data.prom_buy_limit) { | ||
| 2119 | + wx.showToast({ | ||
| 2120 | + title: '超出商品活动限购', | ||
| 2121 | + icon: 'none', | ||
| 2122 | + }); | ||
| 2123 | + // s.my_warnning('超出商品活动限购', 0, th); | ||
| 2124 | + var num = th.data.prom_buy_limit - th.data.prom_buy_num; | ||
| 2125 | + if (num < 0) num = 0; | ||
| 2126 | + th.setData({goodsInputNum: num}) | ||
| 2127 | + return false; | ||
| 2128 | + } | ||
| 2129 | + } | ||
| 2130 | + | ||
| 2131 | + if (th.data.sele_g.prom_type == 1 || th.data.sele_g.prom_type == 6) { | ||
| 2132 | + var redis_num = 0; | ||
| 2133 | + //------判断活动是否抢光----- | ||
| 2134 | + await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + | ||
| 2135 | + os.stoid + "/" + th.data.sele_g.prom_type + "/" + th.data.sele_g.prom_id, { | ||
| 2136 | + 1: 1 | ||
| 2137 | + }).then(res => { | ||
| 2138 | + redis_num = res.data.data; | ||
| 2139 | + }); | ||
| 2140 | + | ||
| 2141 | + if (t > redis_num) { | ||
| 2142 | + wx.showToast({ | ||
| 2143 | + title: '超出商品活动库存', | ||
| 2144 | + icon: 'none', | ||
| 2145 | + }); | ||
| 2146 | + // s.my_warnning('超出商品活动库存', 0, th); | ||
| 2147 | + th.setData({goodsInputNum: redis_num}) | ||
| 2148 | + return false; | ||
| 2149 | + } | ||
| 2150 | + } | ||
| 2151 | + | ||
| 2152 | + | ||
| 2153 | + //判断积分购库存 | ||
| 2154 | + if (!th.data.is_normal && th.data.prom_type == 4) { | ||
| 2155 | + var i_canbuy = th.data.prom_act.limitqty - th.data.prom_act.buy_num; | ||
| 2156 | + if (t > i_canbuy) { | ||
| 2157 | + wx.showToast({ | ||
| 2158 | + title: '超出商品活动库存', | ||
| 2159 | + icon: 'none', | ||
| 2160 | + }); | ||
| 2161 | + // s.my_warnning('超出商品活动库存', 0, th); | ||
| 2162 | + return false; | ||
| 2163 | + } | ||
| 2164 | + } | ||
| 2165 | + | ||
| 2166 | + var e = th.data.sele_g.store_count; | ||
| 2167 | + var p_type = th.data.prom_type; //&& p_type!=1 && p_type!=4 | ||
| 2168 | + if (th.data.sales_rules == 2 && (p_type != 1 && p_type != 4 && p_type != 6 || th.data.openSpecModal_inte_normal == 1 || th.data.is_normal == 1)) { | ||
| 2169 | + if (!th.data.def_pick_store) { | ||
| 2170 | + wx.showModal({title: '请选择门店',}); | ||
| 2171 | + return false; | ||
| 2172 | + } else { | ||
| 2173 | + e = th.data.def_pick_store.CanOutQty; | ||
| 2174 | + } | ||
| 2175 | + } | ||
| 2176 | + if (!e) e = 0; | ||
| 2177 | + //库存不足,不增加 | ||
| 2178 | + if (e < t) { | ||
| 2179 | + wx.showToast({ | ||
| 2180 | + title: '库存不足', | ||
| 2181 | + icon: 'none', | ||
| 2182 | + }); | ||
| 2183 | + //wx.showModal({title: '库存不足',}); | ||
| 2184 | + if (e < 0) e = 0; | ||
| 2185 | + th.setData({goodsInputNum: e}); | ||
| 2186 | + return false; | ||
| 2187 | + } | ||
| 2188 | + t > e || 0 == e ? t = e : t < 1 && (t = 1); | ||
| 2189 | + th.setData({goodsInputNum: t}); | ||
| 2190 | + }) | ||
| 2191 | + }, | ||
| 2192 | + | ||
| 2193 | + | ||
| 2194 | + closeSpecModal: function () { | ||
| 2195 | + if (this.data.openSpecModal_pt && this.data.is_normal) { | ||
| 2196 | + this.get_sto(); | ||
| 2197 | + this.setData({ | ||
| 2198 | + sele_g: this.data.data, | ||
| 2199 | + gid: this.data.data.goods_id | ||
| 2200 | + }) | ||
| 2201 | + | ||
| 2202 | + this.sele_spec_chech_activity(); | ||
| 2203 | + | ||
| 2204 | + } | ||
| 2205 | + | ||
| 2206 | + this.setData({ | ||
| 2207 | + openSpecModal: !1, | ||
| 2208 | + openSpecModal_pt: !1 | ||
| 2209 | + }); | ||
| 2210 | + }, | ||
| 2211 | + | ||
| 2212 | + openSpecModel: function (t) { | ||
| 2213 | + var th = this; | ||
| 2214 | + var open_store = t.currentTarget.dataset.ind; | ||
| 2215 | + | ||
| 2216 | + if(getApp().is_sp_hao() && open_store==1){ | ||
| 2217 | + wx.showToast({ | ||
| 2218 | + title: "视频号商品不允许加入购物车", | ||
| 2219 | + icon: 'none', | ||
| 2220 | + duration: 2000 | ||
| 2221 | + }); | ||
| 2222 | + return false; | ||
| 2223 | + } | ||
| 2224 | + | ||
| 2225 | + this.setData({ | ||
| 2226 | + store: 0, | ||
| 2227 | + choice_sort_store: 0, | ||
| 2228 | + sort_store: 0, | ||
| 2229 | + open_ind_store: open_store, | ||
| 2230 | + }) | ||
| 2231 | + //--先判断会员状态-- | ||
| 2232 | + var user_info = getApp().globalData.userInfo; | ||
| 2233 | + if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { | ||
| 2234 | + wx.navigateTo({ | ||
| 2235 | + url: '/pages/togoin/togoin', | ||
| 2236 | + }) | ||
| 2237 | + return false; | ||
| 2238 | + } | ||
| 2239 | + | ||
| 2240 | + var check_up = 0; | ||
| 2241 | + if (th.data.more_flash) { | ||
| 2242 | + for (var i in th.data.more_flash) { | ||
| 2243 | + var item = th.data.more_flash[i]; | ||
| 2244 | + if (item.prom_type == 1) { | ||
| 2245 | + check_up = 1; | ||
| 2246 | + break | ||
| 2247 | + } | ||
| 2248 | + } | ||
| 2249 | + } | ||
| 2250 | + | ||
| 2251 | + | ||
| 2252 | + if (check_up && open_store == 1) { | ||
| 2253 | + th.setData({is_pop_more: 1}); | ||
| 2254 | + } else { | ||
| 2255 | + var ind = t.currentTarget.dataset.ind; | ||
| 2256 | + //回调。判断是不是优惠促销 | ||
| 2257 | + th.check_is_prom_goods(function () { | ||
| 2258 | + th.setData({ | ||
| 2259 | + openSpecModal: !0, | ||
| 2260 | + openSpecModal_ind: ind, | ||
| 2261 | + }); | ||
| 2262 | + //var is_open=th.data.config | ||
| 2263 | + th.get_off_price(); | ||
| 2264 | + }) | ||
| 2265 | + //--先判断会员状态-- | ||
| 2266 | + var user_info = getApp().globalData.userInfo; | ||
| 2267 | + if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { | ||
| 2268 | + wx.navigateTo({ | ||
| 2269 | + url: '/pages/togoin/togoin', | ||
| 2270 | + }) | ||
| 2271 | + return false; | ||
| 2272 | + } | ||
| 2273 | + var is_go_next = 1; | ||
| 2274 | + if (th.data.more_flash && th.data.more_flash.length > 1 && open_store == 1) { | ||
| 2275 | + is_go_next = 0; | ||
| 2276 | + } | ||
| 2277 | + if (is_go_next) { | ||
| 2278 | + var ind = t.currentTarget.dataset.ind; | ||
| 2279 | + //回调。判断是不是优惠促销 | ||
| 2280 | + th.check_is_prom_goods(function () { | ||
| 2281 | + th.setData({ | ||
| 2282 | + openSpecModal: !0, | ||
| 2283 | + openSpecModal_ind: ind, | ||
| 2284 | + }); | ||
| 2285 | + //var is_open=th.data.config | ||
| 2286 | + th.get_off_price(); | ||
| 2287 | + }) | ||
| 2288 | + } else { | ||
| 2289 | + th.setData({is_pop_more: 1}); | ||
| 2290 | + | ||
| 2291 | + } | ||
| 2292 | + } | ||
| 2293 | + }, | ||
| 2294 | + open_next(){ | ||
| 2295 | + var th = this; | ||
| 2296 | + //回调。判断是不是优惠促销 | ||
| 2297 | + th.check_is_prom_goods(function () { | ||
| 2298 | + th.setData({ | ||
| 2299 | + openSpecModal: !0, | ||
| 2300 | + openSpecModal_ind: 1, | ||
| 2301 | + is_pop_more: 0 | ||
| 2302 | + }); | ||
| 2303 | + th.get_off_price(); | ||
| 2304 | + }) | ||
| 2305 | + }, | ||
| 2306 | + | ||
| 2307 | + //判断是不是优惠促销 | ||
| 2308 | + check_is_prom_goods: function (callback) { | ||
| 2309 | + var th = this; | ||
| 2310 | + var usr = getApp().globalData.userInfo; | ||
| 2311 | + if (this.data.sele_g.prom_type != 0 && this.data.sele_g.prom_type != 3) { | ||
| 2312 | + callback(); | ||
| 2313 | + } else { | ||
| 2314 | + //-- 判断有没有优惠活动 -- | ||
| 2315 | + getApp().request.promiseGet("/api/weshop/goods/getGoodsPromList/" + os.stoid + "/" + th.data.sele_g.goods_id + "/0"+"/"+usr.user_id, {}).then(res => { | ||
| 2316 | + if (res.data.code == 0) { | ||
| 2317 | + var r_data = res.data.data; | ||
| 2318 | + th.data.prom_goods = r_data.promGoodsLists; | ||
| 2319 | + if (!th.data.prom_goods) { | ||
| 2320 | + callback(); | ||
| 2321 | + return false; | ||
| 2322 | + } | ||
| 2323 | + | ||
| 2324 | + ///api/weshop/order/getWPayOrder?store_id=1&user_id=5682366&prom_id=1&goods_id=1 | ||
| 2325 | + getApp().promiseGet("/api/weshop/order/getWPayOrder", { | ||
| 2326 | + data: { | ||
| 2327 | + store_id: os.stoid, | ||
| 2328 | + user_id: usr.user_id, | ||
| 2329 | + goods_id: th.data.sele_g.goods_id, | ||
| 2330 | + prom_id: th.data.prom_goods[0].prom_id | ||
| 2331 | + } | ||
| 2332 | + }).then(res => { | ||
| 2333 | + if (res.data.code == 0) { | ||
| 2334 | + wx.showToast({ | ||
| 2335 | + title: "您已经购买了该商品待支付中", | ||
| 2336 | + icon: 'none', | ||
| 2337 | + duration: 2000 | ||
| 2338 | + }) | ||
| 2339 | + setTimeout(function () { | ||
| 2340 | + getApp().goto("/pages/user/order_detail/order_detail?order_id=" + res.data.data.order_id,) | ||
| 2341 | + }, 1000) | ||
| 2342 | + } | ||
| 2343 | + //未找到相关记录 | ||
| 2344 | + else { | ||
| 2345 | + callback(); | ||
| 2346 | + } | ||
| 2347 | + }) | ||
| 2348 | + } | ||
| 2349 | + | ||
| 2350 | + }) | ||
| 2351 | + | ||
| 2352 | + } | ||
| 2353 | + }, | ||
| 2354 | + | ||
| 2355 | + | ||
| 2356 | + //----获取线下价格------- | ||
| 2357 | + get_off_price() { | ||
| 2358 | + var th = this; | ||
| 2359 | + //没有开启就返回 | ||
| 2360 | + if (!th.data.is_open_offline) return false; | ||
| 2361 | + //先看下购买的功能有没有到期 | ||
| 2362 | + getApp().request.promiseGet("/store/storemoduleendtime/page?store_id=" + os.stoid + "&type=6", {}).then(res => { | ||
| 2363 | + //未购买 | ||
| 2364 | + if (res.data.code != 0 || !res.data.data || !res.data.data.pageData || !res.data.data.pageData.length) { | ||
| 2365 | + return false; | ||
| 2366 | + } else { | ||
| 2367 | + //已经过期 | ||
| 2368 | + var item = res.data.data.pageData[0]; | ||
| 2369 | + if (item.end_time < ut.gettimestamp()) { | ||
| 2370 | + return false; | ||
| 2371 | + } | ||
| 2372 | + } | ||
| 2373 | + | ||
| 2374 | + | ||
| 2375 | + var cur_goods = this.data.sele_g; | ||
| 2376 | + var cur_price = cur_goods.shop_price; | ||
| 2377 | + if (th.data.card_field && cur_goods[th.data.card_field] > 0) { | ||
| 2378 | + cur_price = cur_goods[th.data.card_field]; | ||
| 2379 | + } | ||
| 2380 | + | ||
| 2381 | + var user_info = getApp().globalData.userInfo; | ||
| 2382 | + //获取一下接口,判断是不是有线下接口,必须是普通商品,全局优惠活动也是不行 | ||
| 2383 | + if (cur_goods.prom_type == 0 && !this.data.prom_goods) { | ||
| 2384 | + cur_goods.offline_price = null; | ||
| 2385 | + //如果没有门店,不用计算线下价格 | ||
| 2386 | + var def_pick_store = this.data.def_pick_store; | ||
| 2387 | + if (!def_pick_store) return false; | ||
| 2388 | + getApp().request.get("/api/weshop/goods/listWarePrice", { | ||
| 2389 | + data: { | ||
| 2390 | + VIPId: encodeURIComponent(user_info.erpvipid), | ||
| 2391 | + store_id: os.stoid, | ||
| 2392 | + PickupId: def_pick_store.pickup_id, | ||
| 2393 | + WareIds: encodeURIComponent(cur_goods.erpwareid) | ||
| 2394 | + }, | ||
| 2395 | + success: function (res) { | ||
| 2396 | + if (res.data.code == 0 && res.data.data && res.data.data.length > 0) { | ||
| 2397 | + var datalist = res.data.data; | ||
| 2398 | + if (datalist[0].WarePrice < cur_price) { | ||
| 2399 | + cur_goods.offline_price = datalist[0].WarePrice; //存储线下活动的价格 | ||
| 2400 | + cur_goods.pricing_type = datalist[0].PriceType; //存储线下活动的类型 | ||
| 2401 | + } | ||
| 2402 | + } | ||
| 2403 | + th.setData({sele_g: cur_goods}); | ||
| 2404 | + } | ||
| 2405 | + | ||
| 2406 | + }) | ||
| 2407 | + } | ||
| 2408 | + | ||
| 2409 | + }) | ||
| 2410 | + | ||
| 2411 | + | ||
| 2412 | + }, | ||
| 2413 | + | ||
| 2414 | + | ||
| 2415 | + //---------点击收藏和不收藏------------ | ||
| 2416 | + collectGoods: function () { | ||
| 2417 | + var t = this, | ||
| 2418 | + i = getApp().request; | ||
| 2419 | + var user_id = s.globalData.user_id; | ||
| 2420 | + if (user_id == '') { | ||
| 2421 | + getApp().getUserFir(function () { | ||
| 2422 | + }); | ||
| 2423 | + getApp().showWarning("未登录"); | ||
| 2424 | + return false; | ||
| 2425 | + } else { | ||
| 2426 | + | ||
| 2427 | + if (t.data.is_collect_load) return false; | ||
| 2428 | + t.data.is_collect_load = 1; | ||
| 2429 | + | ||
| 2430 | + if (t.data.is_collect == 1) { //删除收藏 | ||
| 2431 | + i.delete("/api/weshop/goodscollect/del/" + o.stoid + "/" + t.data.collect_id, { | ||
| 2432 | + success: function (e) { | ||
| 2433 | + t.data.is_collect_load = 0; | ||
| 2434 | + if (e.data.code == 0) { | ||
| 2435 | + t.setData({ | ||
| 2436 | + is_collect: 0, | ||
| 2437 | + collect_id: 0, | ||
| 2438 | + }); | ||
| 2439 | + } | ||
| 2440 | + } | ||
| 2441 | + }); | ||
| 2442 | + } else { | ||
| 2443 | + var timestamp = Date.parse(new Date()); | ||
| 2444 | + timestamp = timestamp / 1000; | ||
| 2445 | + var d = { | ||
| 2446 | + goods_id: t.data.data.goods_id, | ||
| 2447 | + user_id: s.globalData.user_id, | ||
| 2448 | + store_id: o.stoid, | ||
| 2449 | + add_time: timestamp, | ||
| 2450 | + }; | ||
| 2451 | + //加入收藏夹就是导购的ID | ||
| 2452 | + if (getApp().globalData.guide_id) { | ||
| 2453 | + d.guide_id = getApp().globalData.guide_id; | ||
| 2454 | + d.guide_type = 2; | ||
| 2455 | + } | ||
| 2456 | + | ||
| 2457 | + i.post("/api/weshop/goodscollect/save", { //添加收藏 | ||
| 2458 | + data: d, | ||
| 2459 | + success: function (e) { | ||
| 2460 | + t.data.is_collect_load = 0; | ||
| 2461 | + if (e.data.code == 0) { | ||
| 2462 | + t.setData({ | ||
| 2463 | + is_collect: 1, | ||
| 2464 | + collect_id: e.data.data.collect_id, | ||
| 2465 | + }); | ||
| 2466 | + } | ||
| 2467 | + } | ||
| 2468 | + }); | ||
| 2469 | + } | ||
| 2470 | + } | ||
| 2471 | + }, | ||
| 2472 | + | ||
| 2473 | + //---------联系客服------------ | ||
| 2474 | + contactService: function () { | ||
| 2475 | + getApp().com_call(this); | ||
| 2476 | + }, | ||
| 2477 | + | ||
| 2478 | + // 获取客服电话 | ||
| 2479 | + getTel() { | ||
| 2480 | + return new Promise((resolve, reject) => { | ||
| 2481 | + s.getConfig(function (t) { | ||
| 2482 | + if (t.store_tel == undefined) { | ||
| 2483 | + getApp().request.get("/api/weshop/store/get/" + os.stoid, { | ||
| 2484 | + isShowLoading: 1, | ||
| 2485 | + data: {}, | ||
| 2486 | + success: function (rs) { | ||
| 2487 | + getApp().globalData.config = rs.data.data; | ||
| 2488 | + if (rs.data.data.store_tel == null && rs.data.data.store_tel == undefined) { | ||
| 2489 | + getApp().my_warnning("商家未设置电话", 0, th); | ||
| 2490 | + return false; | ||
| 2491 | + } | ||
| 2492 | + self.setData({ | ||
| 2493 | + store_tel: rs.data.data.store_tel, | ||
| 2494 | + }); | ||
| 2495 | + // s.confirmBox("请联系客服:" + rs.data.data.store_tel); | ||
| 2496 | + } | ||
| 2497 | + }) | ||
| 2498 | + } else { | ||
| 2499 | + self.setData({ | ||
| 2500 | + store_tel: t.store_tel, | ||
| 2501 | + }); | ||
| 2502 | + // s.confirmBox("请联系客服:" + t.store_tel); | ||
| 2503 | + }; | ||
| 2504 | + resolve(); | ||
| 2505 | + }); | ||
| 2506 | + }); | ||
| 2507 | + }, | ||
| 2508 | + | ||
| 2509 | + //-------获取购物车数量---------- | ||
| 2510 | + requestCardNum: function () { | ||
| 2511 | + var t = this; | ||
| 2512 | + getApp().request.get("/api/weshop/cart/page", { | ||
| 2513 | + data: { | ||
| 2514 | + store_id: o.stoid, | ||
| 2515 | + user_id: s.globalData.user_id, | ||
| 2516 | + state: 0, | ||
| 2517 | + is_gift: 0 | ||
| 2518 | + }, | ||
| 2519 | + success: function (e) { | ||
| 2520 | + var num = 0; | ||
| 2521 | + for (var i = 0; i < e.data.data.pageData.length; i++) { | ||
| 2522 | + num += e.data.data.pageData[i].goods_num; | ||
| 2523 | + } | ||
| 2524 | + | ||
| 2525 | + //-- 读取服务卡的数量 -- | ||
| 2526 | + getApp().promiseGet("/api/weshop/cartService/page", { | ||
| 2527 | + data: { | ||
| 2528 | + store_id: s.globalData.setting.stoid, | ||
| 2529 | + user_id: s.globalData.user_id, | ||
| 2530 | + } | ||
| 2531 | + }).then(res => { | ||
| 2532 | + for (var i = 0; i < res.data.data.pageData.length; i++) { | ||
| 2533 | + num += res.data.data.pageData[i].goods_num; | ||
| 2534 | + } | ||
| 2535 | + t.setData({cartGoodsNum: num}); | ||
| 2536 | + }) | ||
| 2537 | + } | ||
| 2538 | + }); | ||
| 2539 | + }, | ||
| 2540 | + | ||
| 2541 | + previewCommentImgs: function (t) { | ||
| 2542 | + var e = this.data.comments[t.currentTarget.dataset.cidx].img; | ||
| 2543 | + var b = e.slice() | ||
| 2544 | + for (var i in b) { | ||
| 2545 | + b[i] = this.data.iurl + e[i]; | ||
| 2546 | + } | ||
| 2547 | + this.data.show_prew_img = 1; | ||
| 2548 | + getApp().pre_img2(b,t) | ||
| 2549 | + }, | ||
| 2550 | + | ||
| 2551 | + previewCommentImgs_w: function (t) { | ||
| 2552 | + var e = this.data.comments[t.currentTarget.dataset.cidx].weapp_img; | ||
| 2553 | + var b = e.slice() | ||
| 2554 | + for (var i in b) { | ||
| 2555 | + b[i] = this.data.iurl + e[i]; | ||
| 2556 | + } | ||
| 2557 | + this.data.show_prew_img = 1; | ||
| 2558 | + getApp().pre_img2(b,t) | ||
| 2559 | + }, | ||
| 2560 | + | ||
| 2561 | + previewGoodsCommentImgs: function (t) { | ||
| 2562 | + var e = this, | ||
| 2563 | + a = this.data.data.comment[t.currentTarget.dataset.cidx].img; | ||
| 2564 | + a = a.map(function (t) { | ||
| 2565 | + return e.data.url + t; | ||
| 2566 | + }), getApp().pre_img2(a,t); | ||
| 2567 | + this.data.show_prew_img = 1; | ||
| 2568 | + }, | ||
| 2569 | + closePromModal: function () { | ||
| 2570 | + this.setData({ | ||
| 2571 | + openPromModal: !1 | ||
| 2572 | + }); | ||
| 2573 | + }, | ||
| 2574 | + openPromModal: function () { | ||
| 2575 | + this.setData({ | ||
| 2576 | + openPromModal: !0 | ||
| 2577 | + }); | ||
| 2578 | + }, | ||
| 2579 | + | ||
| 2580 | + //--点击分享事件--- | ||
| 2581 | + onShareAppMessage: function (t) { | ||
| 2582 | + getApp().globalData.no_clear=1; | ||
| 2583 | + | ||
| 2584 | + var th = this; | ||
| 2585 | + var price = th.data.sele_g.shop_price; | ||
| 2586 | + if (th.data.prom_act) { | ||
| 2587 | + price = th.data.prom_act.price; | ||
| 2588 | + | ||
| 2589 | + } | ||
| 2590 | + var title = th.data.sele_g.goods_name; | ||
| 2591 | + var img = th.data.sele_g.original_img; | ||
| 2592 | + if (th.data.prom_type == 6 || th.data.prom_type == 1 || th.data.prom_type == 4) { | ||
| 2593 | + title = th.data.prom_act.share_title; | ||
| 2594 | + if (!title) title = th.data.prom_act.title; | ||
| 2595 | + if (th.data.prom_type == 4) title = th.data.prom_act.name; | ||
| 2596 | + | ||
| 2597 | + if (th.data.prom_act.share_imgurl) | ||
| 2598 | + img = th.data.iurl + th.data.prom_act.share_imgurl; | ||
| 2599 | + } | ||
| 2600 | + | ||
| 2601 | + | ||
| 2602 | + var url = "/pages/goods/goodsInfo/goodsInfo?goods_id=" | ||
| 2603 | + + th.data.sele_g.goods_id + "&prom_type=" + th.data.sele_g.prom_type + "&prom_id=" + th.data.sele_g.prom_id; | ||
| 2604 | + if (getApp().globalData.user_id) { | ||
| 2605 | + url += "&first_leader=" + getApp().globalData.user_id; | ||
| 2606 | + } | ||
| 2607 | + | ||
| 2608 | + //-- 如果房间分享,且不是会员分享的 -- | ||
| 2609 | + if (getApp().globalData.room_id && | ||
| 2610 | + th.data.sele_g.goods_id == getApp().globalData.room_goods_id && !getApp().globalData.room_user_share | ||
| 2611 | + ) { | ||
| 2612 | + url += "&room_id=" + getApp().globalData.room_id + "&room_user_share=1"; | ||
| 2613 | + } | ||
| 2614 | + | ||
| 2615 | + var ob = { | ||
| 2616 | + title: price + "元 " + title, | ||
| 2617 | + path: url, | ||
| 2618 | + imageUrl: img, | ||
| 2619 | + }; | ||
| 2620 | + if (th.data.prom_type == 6) { | ||
| 2621 | + title += '\n' + th.data.prom_act.share_remark; | ||
| 2622 | + ob.title = title; | ||
| 2623 | + ob.desc = th.data.prom_act.share_remark; | ||
| 2624 | + } | ||
| 2625 | + | ||
| 2626 | + //如果是积分购的时候 | ||
| 2627 | + if (th.data.prom_type == 4) { | ||
| 2628 | + var name = th.data.prom_act.name; | ||
| 2629 | + //-- 积分购的 -- | ||
| 2630 | + var pri0 = th.data.prom_act.addmoney; | ||
| 2631 | + var integral = th.data.prom_act.integral; | ||
| 2632 | + var text = ""; | ||
| 2633 | + if (integral) { text = integral + "积分"; } | ||
| 2634 | + if (pri0 && integral) { text += "+"; } | ||
| 2635 | + if (pri0) { text += "¥" + pri0; } | ||
| 2636 | + | ||
| 2637 | + ob.title = text + " " + name; | ||
| 2638 | + } | ||
| 2639 | + //-- 页面不能刷新 -- | ||
| 2640 | + this.data.show_prew_img=1; | ||
| 2641 | + | ||
| 2642 | + console.log("share.."); | ||
| 2643 | + console.log(ob); | ||
| 2644 | + return ob; | ||
| 2645 | + | ||
| 2646 | + }, | ||
| 2647 | + | ||
| 2648 | + //-----图片失败,默认图片----- | ||
| 2649 | + bind_bnerr: function (e) { | ||
| 2650 | + var _errImg = e.target.dataset.errorimg; | ||
| 2651 | + var _errObj = {}; | ||
| 2652 | + _errObj[_errImg] = this.data.iurl + "/miniapp/images/default_g_img.gif"; | ||
| 2653 | + this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ; | ||
| 2654 | + }, | ||
| 2655 | + | ||
| 2656 | + //-----图片失败,默认图片----- | ||
| 2657 | + bind_bnerr2: function (e) { | ||
| 2658 | + | ||
| 2659 | + var _errImg = e.target.dataset.errorimg; | ||
| 2660 | + var _errObj = {}; | ||
| 2661 | + _errObj[_errImg] = this.data.iurl + "/miniapp/images/hui_hear_pic.png" | ||
| 2662 | + this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ; | ||
| 2663 | + }, | ||
| 2664 | + | ||
| 2665 | + | ||
| 2666 | + //----------装载同一条形码的商品---------- | ||
| 2667 | + async get_sku(stoid, gd, g_id, is_normal, func) { | ||
| 2668 | + console.log('get_sku'); | ||
| 2669 | + var tt = this, arrdata = null; | ||
| 2670 | + var now = ut.gettimestamp(); | ||
| 2671 | + await getApp().request.promiseGet("/api/weshop/goods/page", { | ||
| 2672 | + data: { | ||
| 2673 | + store_id: o.stoid, | ||
| 2674 | + sku: gd.sku, | ||
| 2675 | + more_spec: gd.more_spec, | ||
| 2676 | + isonsale: 1, | ||
| 2677 | + is_on_sale: 1, | ||
| 2678 | + pageSize: 500, | ||
| 2679 | + orderField: 'gg_ordid,goods_spec,sort' | ||
| 2680 | + } | ||
| 2681 | + }).then(res => { | ||
| 2682 | + var e = res; | ||
| 2683 | + if (e.data.code == 0) arrdata = e.data.data.pageData; | ||
| 2684 | + }) | ||
| 2685 | + if (!arrdata) return false; | ||
| 2686 | + | ||
| 2687 | + var arrsku = new Array(); | ||
| 2688 | + var gitem = null; | ||
| 2689 | + var gb = 1, gg = ""; | ||
| 2690 | + for (var i = 0; i < arrdata.length; i++) { | ||
| 2691 | + var goodsinfo = arrdata[i], prom = null; | ||
| 2692 | + if (goodsinfo.goods_id != g_id) { | ||
| 2693 | + | ||
| 2694 | + switch (goodsinfo.prom_type) { | ||
| 2695 | + case 1: | ||
| 2696 | + | ||
| 2697 | + if(goodsinfo.prom_id) { | ||
| 2698 | + await getApp().request.promiseGet("/api/ms/flash_sale/get/" + os.stoid + "/" + goodsinfo.prom_id, {}).then(res => { | ||
| 2699 | + if (res.data.code == 0) prom = res.data.data; | ||
| 2700 | + }) | ||
| 2701 | + } | ||
| 2702 | + | ||
| 2703 | + | ||
| 2704 | + break; | ||
| 2705 | + case 6: | ||
| 2706 | + await getApp().request.promiseGet("/api/weshop/teamlist/get/" + os.stoid + "/" + goodsinfo.prom_id, {}).then(res => { | ||
| 2707 | + console.log(res); | ||
| 2708 | + if (res.data.code == 0) prom = res.data.data; | ||
| 2709 | + }) | ||
| 2710 | + | ||
| 2711 | + break; | ||
| 2712 | + case 2: | ||
| 2713 | + await getApp().request.promiseGet("/api/weshop/goods/groupBuy/getActInfo/" + os.stoid + "/" + goodsinfo.goods_id + "/" + goodsinfo.prom_id, {}).then(res => { | ||
| 2714 | + if (res.data.code == 0) prom = res.data.data; | ||
| 2715 | + }) | ||
| 2716 | + break; | ||
| 2717 | + case 4: | ||
| 2718 | + await getApp().request.promiseGet("/api/weshop/integralbuy/getActInfo/" + os.stoid + "/" + goodsinfo.goods_id + "/" + goodsinfo.prom_id, {}).then(res => { | ||
| 2719 | + if (res.data.code == 0) prom = res.data.data; | ||
| 2720 | + }) | ||
| 2721 | + break | ||
| 2722 | + //预售和幸运购不参与 | ||
| 2723 | + case 8: | ||
| 2724 | + case 9: | ||
| 2725 | + continue; | ||
| 2726 | + } | ||
| 2727 | + | ||
| 2728 | + } | ||
| 2729 | + //---如果有活动,不算在一起--- | ||
| 2730 | + if (prom) { | ||
| 2731 | + if (goodsinfo.prom_type == 1 || goodsinfo.prom_type == 6) { | ||
| 2732 | + console.log(prom); | ||
| 2733 | + if (prom.is_end == 0 && prom.end_time > now && prom.start_time < now) continue; | ||
| 2734 | + } else { | ||
| 2735 | + continue; | ||
| 2736 | + } | ||
| 2737 | + } | ||
| 2738 | + | ||
| 2739 | + | ||
| 2740 | + var item = arrdata[i], gg = ""; | ||
| 2741 | + if (item.goods_spec == "null" || item.goods_spec == null) item.goods_spec = ""; | ||
| 2742 | + if (item.goods_color == "null" || item.goods_color == null) item.goods_color = ""; | ||
| 2743 | + | ||
| 2744 | + if (item.goods_spec != "" && item.goods_color != "") { | ||
| 2745 | + gg = item.goods_spec + "/" + item.goods_color; | ||
| 2746 | + } else if (item.goods_spec != "" || item.goods_color != "") { | ||
| 2747 | + gg = item.goods_spec + item.goods_color; | ||
| 2748 | + } else { | ||
| 2749 | + gg = "规格" + gb; | ||
| 2750 | + gb++; | ||
| 2751 | + } | ||
| 2752 | + item.gg = gg; | ||
| 2753 | + | ||
| 2754 | + if (item.spec_img) | ||
| 2755 | + item.original_img = os.imghost + item.spec_img; | ||
| 2756 | + else | ||
| 2757 | + item.original_img = os.imghost + item.original_img; | ||
| 2758 | + | ||
| 2759 | + | ||
| 2760 | + if (item.goods_id == g_id) { | ||
| 2761 | + gitem = item; | ||
| 2762 | + } else { | ||
| 2763 | + arrsku.push(item); | ||
| 2764 | + } | ||
| 2765 | + } | ||
| 2766 | + //-----------排列在最前面------------- | ||
| 2767 | + arrsku.splice(0, 0, gitem); | ||
| 2768 | + if (is_normal == 1) { | ||
| 2769 | + tt.setData({ | ||
| 2770 | + sku_g_pt: arrsku, | ||
| 2771 | + sele_g: gitem | ||
| 2772 | + }); | ||
| 2773 | + func(); | ||
| 2774 | + } else { | ||
| 2775 | + tt.setData({ | ||
| 2776 | + sku_g: arrsku, | ||
| 2777 | + sele_g: gitem | ||
| 2778 | + }); | ||
| 2779 | + } | ||
| 2780 | + }, | ||
| 2781 | + | ||
| 2782 | + //-----------选择属性的按钮事件---------- | ||
| 2783 | + sele_spec: function (e) { | ||
| 2784 | + var that = this; | ||
| 2785 | + var gid = e.currentTarget.dataset.gid; | ||
| 2786 | + var nor = e.currentTarget.dataset.nor; | ||
| 2787 | + | ||
| 2788 | + var sku_g = this.data.sku_g; | ||
| 2789 | + if (nor) { | ||
| 2790 | + sku_g = this.data.sku_g_pt; | ||
| 2791 | + } | ||
| 2792 | + | ||
| 2793 | + var item = null; | ||
| 2794 | + for (var i in sku_g) { | ||
| 2795 | + if (sku_g[i].goods_id == gid) { | ||
| 2796 | + item = sku_g[i]; | ||
| 2797 | + if (item.original_img.indexOf(that.data.iurl) == -1) { | ||
| 2798 | + item.original_img = that.data.iurl + item.original_img; | ||
| 2799 | + } | ||
| 2800 | + break | ||
| 2801 | + } | ||
| 2802 | + } | ||
| 2803 | + console.log(item, 2000); | ||
| 2804 | + var cur_price = item.shop_price; | ||
| 2805 | + if (getApp().globalData.userInfo && getApp().globalData.userInfo.card_field) { | ||
| 2806 | + var cfile = getApp().globalData.userInfo.card_field; | ||
| 2807 | + console.log('cfile', cfile); | ||
| 2808 | + if (item[cfile]) { | ||
| 2809 | + cur_price = item[cfile]; | ||
| 2810 | + } | ||
| 2811 | + } | ||
| 2812 | + var txt = (cur_price / item.market_price * 10).toFixed(2).toString(); | ||
| 2813 | + txt = parseFloat(txt); | ||
| 2814 | + item['disc'] = txt; | ||
| 2815 | + if (item) this.setData({ | ||
| 2816 | + sele_g: item, | ||
| 2817 | + gid: gid, | ||
| 2818 | + data: item, | ||
| 2819 | + }); | ||
| 2820 | + | ||
| 2821 | + | ||
| 2822 | + that.check_is_youhui(gid, that.data.is_normal); | ||
| 2823 | + | ||
| 2824 | + //默认门店要拿下门店库存 | ||
| 2825 | + if (that.data.sales_rules == 2 && that.data.def_pick_store) { | ||
| 2826 | + var lock = 0, plist = null; | ||
| 2827 | + //先读取门店的lock,采用链式写法,少用await | ||
| 2828 | + getApp().request.promiseGet("/api/weshop/order/ware/lock/page", { | ||
| 2829 | + data: { | ||
| 2830 | + store_id: os.stoid, | ||
| 2831 | + wareId: that.data.sele_g.goods_id, | ||
| 2832 | + storageId: that.data.def_pick_store.pickup_id, | ||
| 2833 | + pageSize: 1000 | ||
| 2834 | + } | ||
| 2835 | + }).then(res => { | ||
| 2836 | + if (res.data.code == 0 && res.data.data.total > 0) { | ||
| 2837 | + for (var i in res.data.data.pageData) | ||
| 2838 | + lock += res.data.data.pageData[i].outQty | ||
| 2839 | + } | ||
| 2840 | + //---通过接口获取门店的线下库存信息-- | ||
| 2841 | + return getApp().request.promiseGet("/api/weshop/goods/getWareStorages", { | ||
| 2842 | + data: { | ||
| 2843 | + storageNos: that.data.def_pick_store.pickup_no, | ||
| 2844 | + wareIds: encodeURIComponent(that.data.sele_g.erpwareid), | ||
| 2845 | + storeId: os.stoid | ||
| 2846 | + } | ||
| 2847 | + }) | ||
| 2848 | + }).then(res => { | ||
| 2849 | + if (res.data.code == 0 && res.data.data.total > 0) { | ||
| 2850 | + plist = res.data.data.pageData[0]; | ||
| 2851 | + } | ||
| 2852 | + if (plist && plist.CanOutQty - lock > 0) { | ||
| 2853 | + that.data.def_pick_store.CanOutQty = plist.CanOutQty - lock; | ||
| 2854 | + } else { | ||
| 2855 | + that.data.def_pick_store.CanOutQty = 0; | ||
| 2856 | + } | ||
| 2857 | + //--给门店赋值线下库存-- | ||
| 2858 | + that.setData({def_pick_store: that.data.def_pick_store}); | ||
| 2859 | + }) | ||
| 2860 | + } | ||
| 2861 | + this.sele_spec_chech_activity(); | ||
| 2862 | + }, | ||
| 2863 | + | ||
| 2864 | + //选择了不同的规格的时候要判断是不是有活动正在进行中 | ||
| 2865 | + async sele_spec_chech_activity() { | ||
| 2866 | + //---如果是活动的时候--- | ||
| 2867 | + var prom = null, goodsinfo = this.data.sele_g, th = this; | ||
| 2868 | + var user_id = getApp().globalData.user_id; | ||
| 2869 | + if (!user_id) user_id = 0; | ||
| 2870 | + if (goodsinfo.prom_type == 1) { | ||
| 2871 | + await getApp().request.promiseGet("/api/ms/flash_sale/getNew/" + os.stoid + "/" + user_id + "/" + goodsinfo.prom_id, {}).then(res => { | ||
| 2872 | + if (res.data.code == 0) { | ||
| 2873 | + prom = res.data.data; | ||
| 2874 | + prom.price = prom.user_price; | ||
| 2875 | + } | ||
| 2876 | + }) | ||
| 2877 | + } | ||
| 2878 | + if (goodsinfo.prom_type == 6) { | ||
| 2879 | + await getApp().request.promiseGet("/api/weshop/teamlist/get/" + os.stoid + "/" + goodsinfo.prom_id, {}).then(res => { | ||
| 2880 | + if (res.data.code == 0) { | ||
| 2881 | + prom = res.data.data; | ||
| 2882 | + } | ||
| 2883 | + }) | ||
| 2884 | + } | ||
| 2885 | + | ||
| 2886 | + if (goodsinfo.prom_type == 4) { | ||
| 2887 | + await getApp().request.promiseGet("/api/weshop/integralbuy/getActInfo/" + os.stoid + "/" + goodsinfo.goods_id + "/" + goodsinfo.prom_id, {}).then(res => { | ||
| 2888 | + if (res.data.code == 0) { | ||
| 2889 | + prom = res.data.data; | ||
| 2890 | + } | ||
| 2891 | + }) | ||
| 2892 | + } | ||
| 2893 | + | ||
| 2894 | + //----------如果有活动,并且在进行中,就不计算线下库存--------------- | ||
| 2895 | + var now = ut.gettimestamp(); | ||
| 2896 | + if (prom) { | ||
| 2897 | + | ||
| 2898 | + var t1 = prom.start_time; | ||
| 2899 | + var prom_st = 1; | ||
| 2900 | + if (prom.show_time) { | ||
| 2901 | + t1 = prom.show_time; | ||
| 2902 | + if (prom.start_time > now) prom_st = 0; | ||
| 2903 | + } | ||
| 2904 | + if (prom.is_end == 0 && prom.end_time > now && t1 < now) { | ||
| 2905 | + th.setData({ | ||
| 2906 | + prom_type: goodsinfo.prom_type, | ||
| 2907 | + prom_price: prom.price, | ||
| 2908 | + prom_buy_limit: prom.buy_limit ? prom.buy_limit : (prom.limitvipqty ? prom.limitvipqty : 0), | ||
| 2909 | + prom_end_time: prom.end_time, | ||
| 2910 | + prom_start_time: prom.start_time, | ||
| 2911 | + prom_st: prom_st, | ||
| 2912 | + prom_act: prom, | ||
| 2913 | + prom_id: prom.id | ||
| 2914 | + }) | ||
| 2915 | + | ||
| 2916 | + //却换图片 | ||
| 2917 | + th.init(goodsinfo.goods_id); | ||
| 2918 | + var newTime = ut.gettimestamp(); | ||
| 2919 | + var endTime2 = prom.end_time; | ||
| 2920 | + var endTime1 = prom.start_time; | ||
| 2921 | + | ||
| 2922 | + this.data.is_timer = 0; | ||
| 2923 | + | ||
| 2924 | + setTimeout(function () { | ||
| 2925 | + th.data.is_timer = 1; | ||
| 2926 | + if (endTime1 > newTime) { | ||
| 2927 | + th.setData({ | ||
| 2928 | + prom_time_text: '距秒杀开始还有' | ||
| 2929 | + }) | ||
| 2930 | + th.countDown(endTime1, 0); | ||
| 2931 | + } else { | ||
| 2932 | + if (endTime2 > newTime) { | ||
| 2933 | + th.setData({ | ||
| 2934 | + prom_time_text: '距秒杀结束还有', | ||
| 2935 | + prom_st: 1 | ||
| 2936 | + }) | ||
| 2937 | + th.countDown(endTime2); | ||
| 2938 | + } | ||
| 2939 | + } | ||
| 2940 | + | ||
| 2941 | + }, 1000) | ||
| 2942 | + | ||
| 2943 | + return false; | ||
| 2944 | + } | ||
| 2945 | + } | ||
| 2946 | + //---设置普通商品--- | ||
| 2947 | + th.setData({ | ||
| 2948 | + prom_type: 0, | ||
| 2949 | + prom_price: null, | ||
| 2950 | + prom_buy_limit: null, | ||
| 2951 | + prom_end_time: null, | ||
| 2952 | + prom_start_time: null, | ||
| 2953 | + prom_st: null, | ||
| 2954 | + }) | ||
| 2955 | + | ||
| 2956 | + }, | ||
| 2957 | + | ||
| 2958 | + | ||
| 2959 | + //---------拿出门店分类和门店------------ | ||
| 2960 | + get_sto(e) { | ||
| 2961 | + console.log('get_sto') | ||
| 2962 | + var th = this, that = this; | ||
| 2963 | + var is_normal = e; | ||
| 2964 | + | ||
| 2965 | + if (e == 1) { | ||
| 2966 | + th.setData({is_normal: 1}) | ||
| 2967 | + } else { | ||
| 2968 | + th.setData({is_normal: 0}) | ||
| 2969 | + } | ||
| 2970 | + | ||
| 2971 | + var timer_get = setInterval(function () { | ||
| 2972 | + if (th.data.is_get_local_ok == 0) return false; | ||
| 2973 | + var dd = null, i = getApp().request; | ||
| 2974 | + if (!th.data.sele_g) return false; | ||
| 2975 | + | ||
| 2976 | + var g_distr_type = th.data.sele_g.distr_type; | ||
| 2977 | + if (g_distr_type != 0) { | ||
| 2978 | + dd = { | ||
| 2979 | + store_id: o.stoid, | ||
| 2980 | + distr_type: g_distr_type, | ||
| 2981 | + isstop: 0, | ||
| 2982 | + is_pos: 1, | ||
| 2983 | + pageSize: 2000 | ||
| 2984 | + } | ||
| 2985 | + } else { | ||
| 2986 | + dd = { | ||
| 2987 | + store_id: o.stoid, | ||
| 2988 | + isstop: 0, | ||
| 2989 | + is_pos: 1, | ||
| 2990 | + pageSize: 2000 | ||
| 2991 | + } | ||
| 2992 | + } | ||
| 2993 | + //如果有距离的话 | ||
| 2994 | + if (th.data.lat != null) { | ||
| 2995 | + dd.lat = th.data.lat; | ||
| 2996 | + dd.lon = th.data.lon; | ||
| 2997 | + } | ||
| 2998 | + clearInterval(timer_get); | ||
| 2999 | + | ||
| 3000 | + | ||
| 3001 | + //如果会员是有默认的门店话 | ||
| 3002 | + if (!th.data.def_pick_store && th.data.fir_def_store && Object.keys(th.data.fir_def_store).length>0) { | ||
| 3003 | + th.setData({def_pick_store: th.data.fir_def_store}); | ||
| 3004 | + } | ||
| 3005 | + wx.showLoading({ | ||
| 3006 | + title: '加载中.' | ||
| 3007 | + }); | ||
| 3008 | + //----------获取门店---------------- | ||
| 3009 | + getApp().request.promiseGet("/api/weshop/pickup/list", { | ||
| 3010 | + data: dd, | ||
| 3011 | + }).then(res => { | ||
| 3012 | + var e = res; | ||
| 3013 | + | ||
| 3014 | + if (e.data.code == 0 && e.data.data && e.data.data.pageData && e.data.data.pageData.length > 0) { | ||
| 3015 | + | ||
| 3016 | + var his_cate_num = 0; | ||
| 3017 | + for (let i in e.data.data.pageData) { | ||
| 3018 | + let item = e.data.data.pageData[i]; | ||
| 3019 | + if (item.category_id > 0) { | ||
| 3020 | + his_cate_num = 1; | ||
| 3021 | + break; | ||
| 3022 | + } | ||
| 3023 | + } | ||
| 3024 | + e.his_cate_num = his_cate_num; | ||
| 3025 | + | ||
| 3026 | + //如果有开启距离的功能,没有设置默认门店,要用最近的门店作为默认门店 | ||
| 3027 | + if (dd.lat && (!th.data.def_pick_store || JSON.stringify(th.data.def_pick_store) == '{}') && th.data.bconfig && th.data.bconfig.is_sort_storage) { | ||
| 3028 | + th.setData({ | ||
| 3029 | + def_pick_store: e.data.data.pageData[0], | ||
| 3030 | + sto_sele_name: e.data.data.pageData[0].pickup_name, | ||
| 3031 | + sto_sele_id: e.data.data.pageData[0].pickup_id, | ||
| 3032 | + sto_sele_distr: e.data.data.pageData[0].distr_type | ||
| 3033 | + }); | ||
| 3034 | + th.data.fir_def_store = e.data.data.pageData[0]; | ||
| 3035 | + } | ||
| 3036 | + | ||
| 3037 | + //-- 如果有默认选择门店的时候,要把默认门店放在第一位,修改不要配送方式的判断 -- | ||
| 3038 | + if (th.data.def_pick_store && JSON.stringify(th.data.def_pick_store) != '{}') { | ||
| 3039 | + for (var k = 0; k < e.data.data.pageData.length; k++) { | ||
| 3040 | + if (e.data.data.pageData[k].pickup_id == th.data.def_pick_store.pickup_id) { | ||
| 3041 | + e.data.data.pageData.splice(k, 1); //删除 | ||
| 3042 | + break; | ||
| 3043 | + } | ||
| 3044 | + } | ||
| 3045 | + e.data.data.pageData.splice(0, 0, th.data.def_pick_store); //添加 | ||
| 3046 | + } | ||
| 3047 | + | ||
| 3048 | + | ||
| 3049 | + th.setData({all_pick_list: e.data.data.pageData}); | ||
| 3050 | + | ||
| 3051 | + //--获取线下库存,而且不是新的门店规则, 同时是普通购买的时候,或者同时不能是活动,秒杀,拼团,积分购-- | ||
| 3052 | + if (th.data.sales_rules == 2 && !th.data.is_newsales_rules && ((th.data.prom_type != 1 && th.data.prom_type != 6 && th.data.prom_type != 4) || is_normal == 1)) { | ||
| 3053 | + setTimeout(function () { | ||
| 3054 | + th.deal_pickup_dline(e); | ||
| 3055 | + }, 800) | ||
| 3056 | + } else { | ||
| 3057 | + setTimeout(function () { | ||
| 3058 | + th.deal_pickup(e); //--普通门店排版-- | ||
| 3059 | + }, 800) | ||
| 3060 | + } | ||
| 3061 | + } | ||
| 3062 | + }) | ||
| 3063 | + }, 200) | ||
| 3064 | + | ||
| 3065 | + }, | ||
| 3066 | + | ||
| 3067 | + | ||
| 3068 | + //------------处理门店--------------- | ||
| 3069 | + deal_pickup(e) { | ||
| 3070 | + var th = this; | ||
| 3071 | + if (!th.data.sele_g) return false | ||
| 3072 | + | ||
| 3073 | + var g_distr_type = th.data.sele_g.distr_type; | ||
| 3074 | + wx.hideLoading(); | ||
| 3075 | + | ||
| 3076 | + //单总量超出10个的时候,同时门店有分类 | ||
| 3077 | + if (e.data.data.total > 10 && e.his_cate_num) { | ||
| 3078 | + getApp().request.get("/api/weshop/storagecategory/page", { | ||
| 3079 | + data: { | ||
| 3080 | + store_id: o.stoid, | ||
| 3081 | + pageSize: 1000, | ||
| 3082 | + orderField: "sort", | ||
| 3083 | + orderType: 'asc', | ||
| 3084 | + }, | ||
| 3085 | + success: function (ee) { | ||
| 3086 | + if (ee.data.code == 0) { | ||
| 3087 | + var check_all_cate = 0; | ||
| 3088 | + if (ee.data.data && ee.data.data.pageData && ee.data.data.pageData.length > 0) { | ||
| 3089 | + for (let i in ee.data.data.pageData) { | ||
| 3090 | + let item = ee.data.data.pageData[i]; | ||
| 3091 | + if (item.is_show == 1) { | ||
| 3092 | + check_all_cate = 1; | ||
| 3093 | + break | ||
| 3094 | + } | ||
| 3095 | + } | ||
| 3096 | + } | ||
| 3097 | + if (check_all_cate) { | ||
| 3098 | + var sto_cate = ee.data.data.pageData; | ||
| 3099 | + var sto_arr = e.data.data.pageData; | ||
| 3100 | + var newarr = new Array(); | ||
| 3101 | + var qita = new Array(); | ||
| 3102 | + | ||
| 3103 | + | ||
| 3104 | + var is_del_pk = 0; | ||
| 3105 | + //----要进行门店分组-------- | ||
| 3106 | + for (var i = 0; i < sto_arr.length; i++) { | ||
| 3107 | + //找一下这个门店有没有在分类数组内 | ||
| 3108 | + var find2 = 0, find2name = "", sort = 0; | ||
| 3109 | + is_del_pk = 0; | ||
| 3110 | + for (var m = 0; m < sto_cate.length; m++) { | ||
| 3111 | + if (sto_arr[i].category_id == sto_cate[m].cat_id) { | ||
| 3112 | + if (sto_cate[m].is_show != 1) { | ||
| 3113 | + is_del_pk = 1; | ||
| 3114 | + sto_arr.splice(i, 1); | ||
| 3115 | + i--; | ||
| 3116 | + } else { | ||
| 3117 | + find2 = sto_cate[m].cat_id; | ||
| 3118 | + find2name = sto_cate[m].cat_name; | ||
| 3119 | + sort = sto_cate[m].sort; | ||
| 3120 | + is_del_pk = 0; | ||
| 3121 | + } | ||
| 3122 | + break; | ||
| 3123 | + } | ||
| 3124 | + } | ||
| 3125 | + if (is_del_pk) continue; | ||
| 3126 | + | ||
| 3127 | + if (newarr.length > 0) { | ||
| 3128 | + var find = 0; | ||
| 3129 | + //如果有找到,那门店就在这个分组内,否则,分类就要排在其他 | ||
| 3130 | + if (find2 != 0) { | ||
| 3131 | + for (var ii = 0; ii < newarr.length; ii++) { | ||
| 3132 | + if (sto_arr[i].category_id == newarr[ii].cat_id) { | ||
| 3133 | + newarr[ii].s_arr.push(sto_arr[i]); | ||
| 3134 | + find = 1; | ||
| 3135 | + break; | ||
| 3136 | + } | ||
| 3137 | + } | ||
| 3138 | + if (find == 0) { | ||
| 3139 | + var arr0 = new Array(); | ||
| 3140 | + arr0.push(sto_arr[i]); | ||
| 3141 | + var item = { | ||
| 3142 | + cat_id: find2, | ||
| 3143 | + name: find2name, | ||
| 3144 | + sort: sort, | ||
| 3145 | + s_arr: arr0 | ||
| 3146 | + }; | ||
| 3147 | + newarr.push(item); | ||
| 3148 | + } | ||
| 3149 | + } else { | ||
| 3150 | + qita.push(sto_arr[i]); | ||
| 3151 | + } | ||
| 3152 | + } else { | ||
| 3153 | + //如果有找到,那门店就在这个分组内,否则,分类就要排在其他 | ||
| 3154 | + if (find2 != 0) { | ||
| 3155 | + var arr0 = new Array(); | ||
| 3156 | + arr0.push(sto_arr[i]); | ||
| 3157 | + var item = { | ||
| 3158 | + cat_id: find2, | ||
| 3159 | + name: find2name, | ||
| 3160 | + sort: sort, | ||
| 3161 | + s_arr: arr0 | ||
| 3162 | + }; | ||
| 3163 | + newarr.push(item); | ||
| 3164 | + } else { | ||
| 3165 | + qita.push(sto_arr[i]); | ||
| 3166 | + } | ||
| 3167 | + } | ||
| 3168 | + } | ||
| 3169 | + | ||
| 3170 | + var def_arr = new Array(); | ||
| 3171 | + //-- 开始就看10个门店 -- | ||
| 3172 | + for (var k = 0; k < 10; k++) { | ||
| 3173 | + if (k == sto_arr.length) break; | ||
| 3174 | + def_arr.push(sto_arr[k]); | ||
| 3175 | + } | ||
| 3176 | + | ||
| 3177 | + th.setData({ | ||
| 3178 | + def_pickpu_list: def_arr, | ||
| 3179 | + pickpu_list: ee.data.data.pageData | ||
| 3180 | + }); | ||
| 3181 | + | ||
| 3182 | + | ||
| 3183 | + //门店分类要排序下 | ||
| 3184 | + function compare(property) { | ||
| 3185 | + return function (a, b) { | ||
| 3186 | + var value1 = a[property]; | ||
| 3187 | + var value2 = b[property]; | ||
| 3188 | + return value1 - value2; | ||
| 3189 | + } | ||
| 3190 | + } | ||
| 3191 | + | ||
| 3192 | + if (newarr.length > 0) | ||
| 3193 | + newarr.sort(compare("sort")); | ||
| 3194 | + | ||
| 3195 | + | ||
| 3196 | + //----安排其他的分类----- | ||
| 3197 | + if (qita.length > 0) { | ||
| 3198 | + var item = { | ||
| 3199 | + cat_id: -1, | ||
| 3200 | + name: "其他", | ||
| 3201 | + s_arr: qita | ||
| 3202 | + }; | ||
| 3203 | + newarr.push(item); | ||
| 3204 | + } | ||
| 3205 | + | ||
| 3206 | + var sd = { | ||
| 3207 | + all_sto: newarr, | ||
| 3208 | + is_show_sto_cat: 1 | ||
| 3209 | + } | ||
| 3210 | + if (!sto_arr || sto_arr.length <= 10) { | ||
| 3211 | + sd.is_show_sto_cat = -1; | ||
| 3212 | + sd.only_pk = sto_arr; | ||
| 3213 | + } | ||
| 3214 | + th.setData(sd); | ||
| 3215 | + | ||
| 3216 | + } else { | ||
| 3217 | + th.setData({ | ||
| 3218 | + is_show_sto_cat: -1, | ||
| 3219 | + only_pk: e.data.data.pageData | ||
| 3220 | + }); | ||
| 3221 | + //-----如果没有默认门店,要取第一个门店作为默认店.此时没有门店分类的情况------ | ||
| 3222 | + if (!th.data.def_pick_store) { | ||
| 3223 | + th.setData({ | ||
| 3224 | + def_pick_store: e.data.data.pageData[0], | ||
| 3225 | + sto_sele_name: e.data.data.pageData[0].pickup_name, | ||
| 3226 | + sto_sele_id: e.data.data.pageData[0].pickup_id, | ||
| 3227 | + sto_sele_distr: e.data.data.pageData[0].distr_type | ||
| 3228 | + }) | ||
| 3229 | + } | ||
| 3230 | + } | ||
| 3231 | + } else { | ||
| 3232 | + th.setData({ | ||
| 3233 | + is_show_sto_cat: -1, | ||
| 3234 | + only_pk: e.data.data.pageData | ||
| 3235 | + }); | ||
| 3236 | + //-----如果没有默认门店,要取第一个门店作为默认店.此时没有门店分类的情况------ | ||
| 3237 | + if (!th.data.def_pick_store) { | ||
| 3238 | + th.setData({ | ||
| 3239 | + def_pick_store: e.data.data.pageData[0], | ||
| 3240 | + sto_sele_name: e.data.data.pageData[0].pickup_name, | ||
| 3241 | + sto_sele_id: e.data.data.pageData[0].pickup_id, | ||
| 3242 | + sto_sele_distr: e.data.data.pageData[0].distr_type | ||
| 3243 | + }) | ||
| 3244 | + } | ||
| 3245 | + | ||
| 3246 | + } | ||
| 3247 | + } | ||
| 3248 | + }); | ||
| 3249 | + } else { | ||
| 3250 | + th.setData({ | ||
| 3251 | + is_show_sto_cat: 0, | ||
| 3252 | + only_pk: e.data.data.pageData | ||
| 3253 | + }); | ||
| 3254 | + //-----如果没有默认门店,要取第一个门店作为默认店------ | ||
| 3255 | + if (!th.data.def_pick_store && th.data.bconfig && th.data.bconfig.is_sort_storage) { | ||
| 3256 | + th.setData({ | ||
| 3257 | + def_pick_store: e.data.data.pageData[0], | ||
| 3258 | + sto_sele_name: e.data.data.pageData[0].pickup_name, | ||
| 3259 | + sto_sele_id: e.data.data.pageData[0].pickup_id, | ||
| 3260 | + sto_sele_distr: e.data.data.pageData[0].distr_type | ||
| 3261 | + }) | ||
| 3262 | + } | ||
| 3263 | + } | ||
| 3264 | + }, | ||
| 3265 | + | ||
| 3266 | + //------------处理线下门店库存-------- | ||
| 3267 | + deal_pickup_dline(e) { | ||
| 3268 | + var pkno = [], th = this; | ||
| 3269 | + if (!th.data.sele_g) return false; | ||
| 3270 | + | ||
| 3271 | + if (this.data.def_pick_store) { | ||
| 3272 | + pkno.push(this.data.def_pick_store.pickup_no); | ||
| 3273 | + } | ||
| 3274 | + for (var i in e.data.data.pageData) { | ||
| 3275 | + var item = e.data.data.pageData[i]; | ||
| 3276 | + if (pkno.indexOf(item.pickup_no) < 0) | ||
| 3277 | + pkno.push(item.pickup_no); | ||
| 3278 | + } | ||
| 3279 | + pkno.sort(); | ||
| 3280 | + var pkno_str = pkno.join(","); | ||
| 3281 | + var o_plist = e.data.data.pageData; | ||
| 3282 | + var new_list = []; | ||
| 3283 | + var is_find_def_store = 0; | ||
| 3284 | + | ||
| 3285 | + | ||
| 3286 | + var g_distr_type = th.data.sele_g.distr_type; | ||
| 3287 | + var lock = []; | ||
| 3288 | + //先读取门店的lock,采用链式写法,少用await | ||
| 3289 | + getApp().request.promiseGet("/api/weshop/order/ware/lock/page", { | ||
| 3290 | + data: {store_id: os.stoid, wareId: th.data.sele_g.goods_id, pageSize: 1000} | ||
| 3291 | + }).then(res => { | ||
| 3292 | + if (res.data.code == 0 && res.data.data.total > 0) { | ||
| 3293 | + lock = res.data.data.pageData | ||
| 3294 | + } | ||
| 3295 | + //---通过接口获取门店的线下库存信息-- | ||
| 3296 | + return getApp().request.promiseGet("/api/weshop/goods/getWareStorages", { | ||
| 3297 | + data: { | ||
| 3298 | + storageNos: pkno_str, | ||
| 3299 | + wareIds: encodeURIComponent(th.data.sele_g.erpwareid), | ||
| 3300 | + storeId: os.stoid, | ||
| 3301 | + pageSize: 2000 | ||
| 3302 | + } | ||
| 3303 | + }) | ||
| 3304 | + }).then(res => { | ||
| 3305 | + | ||
| 3306 | + wx.hideLoading(); | ||
| 3307 | + if (res.data.code == 0) { | ||
| 3308 | + if (res.data.data.pageData && res.data.data.pageData.length > 0) { | ||
| 3309 | + var plist = res.data.data.pageData; | ||
| 3310 | + var def_pick_store = th.data.def_pick_store; | ||
| 3311 | + //以原来的数组为外循环,保证距离的顺序 | ||
| 3312 | + for (var kk in o_plist) { | ||
| 3313 | + for (var ii in plist) { | ||
| 3314 | + //线下的门店小心 | ||
| 3315 | + var n_item = plist[ii]; | ||
| 3316 | + if (n_item.StorageNo == o_plist[kk].pickup_no) { | ||
| 3317 | + | ||
| 3318 | + //拿到锁库的数量 | ||
| 3319 | + var lock_num = th.find_lock_num(o_plist[kk].pickup_id, lock); | ||
| 3320 | + //可出库数大于预出库库存的数量,可以判断为有库存 | ||
| 3321 | + if (n_item.CanOutQty > lock_num) { | ||
| 3322 | + o_plist[kk].CanOutQty = n_item.CanOutQty - lock_num; | ||
| 3323 | + new_list.push(o_plist[kk]); | ||
| 3324 | + //--如果找到默认门店,同时也应该判断配送方式对不对-- | ||
| 3325 | + if (th.data.fir_def_store && n_item.StorageNo == th.data.fir_def_store.pickup_no && (g_distr_type == 0 || th.data.fir_def_store.distr_type == 0 || th.data.def_pick_store.distr_type == g_distr_type)) { | ||
| 3326 | + th.data.fir_def_store.CanOutQty = n_item.CanOutQty - lock_num; | ||
| 3327 | + if (def_pick_store.pickup_id == th.data.fir_def_store.pickup_id) | ||
| 3328 | + th.setData({def_pick_store: th.data.fir_def_store}) | ||
| 3329 | + is_find_def_store = 1; | ||
| 3330 | + } | ||
| 3331 | + } | ||
| 3332 | + break; | ||
| 3333 | + } | ||
| 3334 | + } | ||
| 3335 | + } | ||
| 3336 | + | ||
| 3337 | + //数据组装下 | ||
| 3338 | + var em = {}; | ||
| 3339 | + em.data = {}; | ||
| 3340 | + em.data.data = {}; | ||
| 3341 | + em.data.data.total = new_list.length; | ||
| 3342 | + em.data.data.pageData = new_list; | ||
| 3343 | + em.data.data.pageData = new_list; | ||
| 3344 | + | ||
| 3345 | + //--如果找到默认门店,同时也应该判断配送方式对不对-- | ||
| 3346 | + if (th.data.fir_def_store && !is_find_def_store && th.data.fir_def_store.pickup_id && (g_distr_type == 0 || th.data.fir_def_store.distr_type == 0 || th.data.def_pick_store.distr_type == g_distr_type)) { | ||
| 3347 | + th.data.fir_def_store.CanOutQty = 0; | ||
| 3348 | + //--当选择的门店是客户默认的门店的时候-- | ||
| 3349 | + if (th.data.def_pick_store && th.data.fir_def_store.pickup_id == th.data.def_pick_store.pickup_id) { | ||
| 3350 | + th.setData({def_pick_store: th.data.fir_def_store}); | ||
| 3351 | + em.data.data.pageData.unshift(th.data.def_pick_store); | ||
| 3352 | + } else { | ||
| 3353 | + em.data.data.pageData.splice(1, 0, th.data.fir_def_store); | ||
| 3354 | + } | ||
| 3355 | + } | ||
| 3356 | + | ||
| 3357 | + //---把数组组装进去--- | ||
| 3358 | + th.deal_pickup(em); | ||
| 3359 | + } else { | ||
| 3360 | + th.setData({def_pick_store: null, all_sto: null, only_pk: null, def_pickpu_list: null}) | ||
| 3361 | + } | ||
| 3362 | + } else { | ||
| 3363 | + th.setData({def_pick_store: null, all_sto: null, only_pk: null, def_pickpu_list: null}) | ||
| 3364 | + } | ||
| 3365 | + }) | ||
| 3366 | + }, | ||
| 3367 | + | ||
| 3368 | + find_lock_num(pick_id, lock) { | ||
| 3369 | + var lock_num = 0; | ||
| 3370 | + if (!lock) return 0; | ||
| 3371 | + if (lock.length < 0) return 0; | ||
| 3372 | + for (var i in lock) { | ||
| 3373 | + if (pick_id == lock[i].pickupId) { | ||
| 3374 | + lock_num += lock[i].outQty; | ||
| 3375 | + } | ||
| 3376 | + } | ||
| 3377 | + return lock_num; | ||
| 3378 | + }, | ||
| 3379 | + | ||
| 3380 | + //----------取货门店被点击的效果------ | ||
| 3381 | + getmendian: function (t) { | ||
| 3382 | + this.setData({ | ||
| 3383 | + ismend: 1, | ||
| 3384 | + }); | ||
| 3385 | + }, | ||
| 3386 | + | ||
| 3387 | + //----------隐藏取货门店,选取门店---------- | ||
| 3388 | + hidemend: function (e) { | ||
| 3389 | + var pid = e.target.dataset.p_id; | ||
| 3390 | + var pname = e.target.dataset.p_name; | ||
| 3391 | + var p_distr_t = e.target.dataset.p_dis; | ||
| 3392 | + this.setData({ | ||
| 3393 | + ismend: 0, | ||
| 3394 | + is_sec_mend: 0, | ||
| 3395 | + sto_sele_id: pid, | ||
| 3396 | + sto_sele_name: pname, | ||
| 3397 | + sto_sele_distr: p_distr_t | ||
| 3398 | + }); | ||
| 3399 | + }, | ||
| 3400 | + | ||
| 3401 | + //------显示取货2级---------- | ||
| 3402 | + show_sec: function (t) { | ||
| 3403 | + var index = t.target.dataset.index; | ||
| 3404 | + var item = this.data.all_sto[index]; | ||
| 3405 | + this.setData({ | ||
| 3406 | + is_sec_mend: 1, | ||
| 3407 | + sec_sto: item | ||
| 3408 | + }); | ||
| 3409 | + }, | ||
| 3410 | + | ||
| 3411 | + //------隐藏取货门店2级---- | ||
| 3412 | + hide_sec_mend: function () { | ||
| 3413 | + this.setData({is_sec_mend: 0,}); | ||
| 3414 | + }, | ||
| 3415 | + | ||
| 3416 | + //评论的调用 | ||
| 3417 | + requestComments_new: async function () { | ||
| 3418 | + var e = this, th = e, ee = e; | ||
| 3419 | + var tp = e.data.activeCategoryId3; | ||
| 3420 | + var t = '/api/weshop/comment/pageComment?page=' + e.data.c_curr_p; | ||
| 3421 | + | ||
| 3422 | + wx.showLoading(); | ||
| 3423 | + var req_where = { | ||
| 3424 | + store_id: o.stoid, pageSize: 5, is_show: 1, | ||
| 3425 | + parent_id: 0, goods_id: th.data.gid, commenttype: tp, | ||
| 3426 | + } | ||
| 3427 | + if (getApp().globalData.userInfo) { | ||
| 3428 | + req_where.userId = getApp().globalData.user_id; | ||
| 3429 | + } | ||
| 3430 | + | ||
| 3431 | + var rs_data = null; | ||
| 3432 | + await getApp().request.promiseGet(t, {data: req_where}).then(res => { | ||
| 3433 | + var tot = res.data.data.total; | ||
| 3434 | + e.data.c_curr_p++; | ||
| 3435 | + e.setData({ | ||
| 3436 | + com_num: tot, //已经有加载 | ||
| 3437 | + }); | ||
| 3438 | + if (res.data.data && res.data.data.pageData && res.data.data.pageData.length > 0) { | ||
| 3439 | + rs_data = res.data.data.pageData; | ||
| 3440 | + } else { | ||
| 3441 | + th.setData({comments_no_more: 1, auto: 1}); | ||
| 3442 | + } | ||
| 3443 | + }) | ||
| 3444 | + | ||
| 3445 | + if (rs_data) { | ||
| 3446 | + //var cda = th.data.comments; | ||
| 3447 | + var cda = rs_data, com_data = th.data.comments; | ||
| 3448 | + for (var ind in cda) { | ||
| 3449 | + var ep = cda[ind]; | ||
| 3450 | + if (cda[ind].head_pic == '') { | ||
| 3451 | + cda[ind].head_pic = th.data.iurl + "/miniapp/images/hui_hear_pic.png"; | ||
| 3452 | + } | ||
| 3453 | + if (ep.weapp_img != "" && ut.isString(ep.weapp_img)) { | ||
| 3454 | + cda[ind].weapp_img = JSON.parse(ep.weapp_img); | ||
| 3455 | + } | ||
| 3456 | + if (ep.img != "" && ut.isString(ep.img)) { | ||
| 3457 | + cda[ind].img = ut.unserialize(ep.img); | ||
| 3458 | + } | ||
| 3459 | + | ||
| 3460 | + //--测量多有字的宽带,计算有多少行-- | ||
| 3461 | + var widh = ut.measureText(ep.content, 30); | ||
| 3462 | + var lines = widh / 712; | ||
| 3463 | + cda[ind].seeMore = false; | ||
| 3464 | + if (lines > 3) cda[ind].seeMore = true; | ||
| 3465 | + | ||
| 3466 | + await getApp().request.promiseGet("/api/weshop/comment/pageComment", { | ||
| 3467 | + data: {store_id: o.stoid, parent_id: ep.comment_id} | ||
| 3468 | + }).then(res => { | ||
| 3469 | + if (res.data.data.pageData && res.data.data.pageData.length > 0) { | ||
| 3470 | + cda[ind].replay_list = res.data.data.pageData; | ||
| 3471 | + } | ||
| 3472 | + }) | ||
| 3473 | + } | ||
| 3474 | + | ||
| 3475 | + if (!com_data) com_data = cda; | ||
| 3476 | + else com_data = com_data.concat(cda); | ||
| 3477 | + | ||
| 3478 | + th.setData({comments: com_data}); | ||
| 3479 | + } | ||
| 3480 | + th.setData({get_c: 1}); | ||
| 3481 | + wx.hideLoading(); | ||
| 3482 | + }, | ||
| 3483 | + | ||
| 3484 | + //加载更多是靠这个函数 | ||
| 3485 | + onReachBottom: function () { | ||
| 3486 | + if (this.data.activeCategoryId == 2) { | ||
| 3487 | + if (!this.data.comments_no_more) this.requestComments_new(); | ||
| 3488 | + } | ||
| 3489 | + | ||
| 3490 | + var goods_list = this.selectComponent("#goods_list"); //组件的id | ||
| 3491 | + if (goods_list) goods_list.get_list(); | ||
| 3492 | + }, | ||
| 3493 | + | ||
| 3494 | + //--------检查是否活动,活动是否开始,或者是否结束------- | ||
| 3495 | + async check_prom(gid, prom_type, prom_id) { | ||
| 3496 | + console.log('check_prom'); | ||
| 3497 | + var ee = this, th = ee; | ||
| 3498 | + var user_id = getApp().globalData.user_id; | ||
| 3499 | + if (!user_id) user_id = 0; | ||
| 3500 | + | ||
| 3501 | + if (prom_type == 3 || prom_type == 0 || prom_type == 5 || prom_type == 7 || prom_type == 9 || prom_type == 10) { | ||
| 3502 | + this.setData({ | ||
| 3503 | + prom_type: 0, isshow: 1, | ||
| 3504 | + }); | ||
| 3505 | + return false; | ||
| 3506 | + } | ||
| 3507 | + | ||
| 3508 | + if (prom_type == 2) { | ||
| 3509 | + //-------判断团购活动是否抢光--------- | ||
| 3510 | + await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + os.stoid + "/" + prom_type + "/" + prom_id, { | ||
| 3511 | + 1: 1 | ||
| 3512 | + }).then(res => { | ||
| 3513 | + var em = res; | ||
| 3514 | + if (em.data.code == 0) { | ||
| 3515 | + if (em.data.data <= 0) ee.setData({ | ||
| 3516 | + prom_r_null: 1 | ||
| 3517 | + }); | ||
| 3518 | + //拿取价格并且判断时间-- | ||
| 3519 | + getApp().request.get("/api/weshop/goods/groupBuy/getActInfo/" + os.stoid + "/" + gid + "/" + prom_id, { | ||
| 3520 | + success: function (t) { | ||
| 3521 | + if (t.data.code != 0) { | ||
| 3522 | + ee.get_normal(gid); | ||
| 3523 | + return false; | ||
| 3524 | + } | ||
| 3525 | + //----已经结束----- | ||
| 3526 | + if (t.data.data.is_end == 1) { | ||
| 3527 | + ee.get_normal(gid); | ||
| 3528 | + return false; | ||
| 3529 | + } | ||
| 3530 | + //----已经过期----- | ||
| 3531 | + var now = ut.gettimestamp(); | ||
| 3532 | + if (t.data.data.end_time < now || t.data.data.start_time > now) { | ||
| 3533 | + ee.get_normal(gid); | ||
| 3534 | + return false; | ||
| 3535 | + } | ||
| 3536 | + | ||
| 3537 | + /*-- 还没有开始预热的也不显示 --*/ | ||
| 3538 | + if (t.data.data.show_time > now) { | ||
| 3539 | + ee.get_normal(gid); | ||
| 3540 | + return false; | ||
| 3541 | + } | ||
| 3542 | + | ||
| 3543 | + var t_gd = ee.data.data; | ||
| 3544 | + var prom_end_time = ut.formatTime(t.data.data.end_time, "yyyy-MM-dd hh:mm:ss"); | ||
| 3545 | + var prom_start_time = ut.formatTime(t.data.data.start_time, "yyyy-MM-dd hh:mm:ss"); | ||
| 3546 | + | ||
| 3547 | + ee.setData({ | ||
| 3548 | + prom_price: t.data.data.price, | ||
| 3549 | + prom_type: 2, | ||
| 3550 | + prom_id: prom_id, | ||
| 3551 | + prom_buy_limit: t.data.data.buy_limit, | ||
| 3552 | + prom_act: t.data.data, | ||
| 3553 | + prom_end_time: prom_end_time, | ||
| 3554 | + prom_start_time: prom_start_time, | ||
| 3555 | + isshow: 1, | ||
| 3556 | + prom_act: t.data.data | ||
| 3557 | + }); | ||
| 3558 | + | ||
| 3559 | + ee.get_sto(); | ||
| 3560 | + var newTime = ut.gettimestamp(); | ||
| 3561 | + var endTime2 = t.data.data.end_time; | ||
| 3562 | + var endTime1 = t.data.data.start_time; | ||
| 3563 | + if (endTime1 > newTime) { | ||
| 3564 | + ee.setData({ | ||
| 3565 | + prom_time_text: '距团购开始还有' | ||
| 3566 | + }) | ||
| 3567 | + ee.countDown(endTime1, 0); | ||
| 3568 | + } else { | ||
| 3569 | + if (endTime2 > newTime) { | ||
| 3570 | + ee.setData({ | ||
| 3571 | + prom_time_text: '距团购结束还有', | ||
| 3572 | + prom_st: 1 | ||
| 3573 | + }) | ||
| 3574 | + ee.countDown(endTime2); | ||
| 3575 | + } | ||
| 3576 | + } | ||
| 3577 | + | ||
| 3578 | + } | ||
| 3579 | + }); | ||
| 3580 | + } | ||
| 3581 | + }) | ||
| 3582 | + } | ||
| 3583 | + | ||
| 3584 | + if (prom_type == 1 && prom_id == 0) { | ||
| 3585 | + this.setData({ | ||
| 3586 | + prom_type: 0, isshow: 1, | ||
| 3587 | + }); | ||
| 3588 | + | ||
| 3589 | + //获取门店 | ||
| 3590 | + this.get_sto(); | ||
| 3591 | + this.get_sku(o.stoid, this.data.data, gid); | ||
| 3592 | + this.check_has_flash(); | ||
| 3593 | + this.data.is_normal = 1; | ||
| 3594 | + this.check_is_youhui(gid, 1); | ||
| 3595 | + return false; | ||
| 3596 | + } | ||
| 3597 | + | ||
| 3598 | + //if (prom_type != 3 && prom_type!=0){ | ||
| 3599 | + //---判断秒杀---- | ||
| 3600 | + if (prom_type == 1 && prom_id > 0) { | ||
| 3601 | + //-------判断活动是否抢光--------- | ||
| 3602 | + await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + os.stoid + "/" + prom_type + "/" + prom_id, { | ||
| 3603 | + 1: 1 | ||
| 3604 | + }).then(res => { | ||
| 3605 | + var em = res; | ||
| 3606 | + if (em.data.code == 0) { | ||
| 3607 | + | ||
| 3608 | + if (em.data.data <= 0) ee.setData({ | ||
| 3609 | + prom_r_null: 1 | ||
| 3610 | + }); | ||
| 3611 | + //拿取价格并且判断时间-- | ||
| 3612 | + getApp().request.get("/api/ms/flash_sale/getNew/" + os.stoid + "/" + user_id + "/" + prom_id, { | ||
| 3613 | + success: function (t) { | ||
| 3614 | + if (t.data.code != 0) { | ||
| 3615 | + ee.get_normal(gid); | ||
| 3616 | + return false; | ||
| 3617 | + } | ||
| 3618 | + //----已经结束----- | ||
| 3619 | + if (t.data.data.is_end == 1) { | ||
| 3620 | + ee.get_normal(gid); | ||
| 3621 | + return false; | ||
| 3622 | + } | ||
| 3623 | + //----已经过期----- | ||
| 3624 | + var now = ut.gettimestamp(); | ||
| 3625 | + if (t.data.data.end_time < now) { | ||
| 3626 | + ee.get_normal(gid); | ||
| 3627 | + return false; | ||
| 3628 | + } | ||
| 3629 | + /*-- 还没有开始预热的也不显示 --*/ | ||
| 3630 | + if (t.data.data.show_time > now) { | ||
| 3631 | + ee.get_normal(gid); | ||
| 3632 | + return false; | ||
| 3633 | + } | ||
| 3634 | + | ||
| 3635 | + var t_gd = ee.data.data; | ||
| 3636 | + var prom_end_time = ut.formatTime(t.data.data.end_time, "yyyy-MM-dd hh:mm:ss"); | ||
| 3637 | + var prom_start_time = ut.formatTime(t.data.data.start_time, "yyyy-MM-dd hh:mm:ss"); | ||
| 3638 | + | ||
| 3639 | + ee.setData({ | ||
| 3640 | + prom_price: t.data.data.user_price, | ||
| 3641 | + prom_type: 1, | ||
| 3642 | + prom_id: prom_id, | ||
| 3643 | + prom_buy_limit: t.data.data.buy_limit, | ||
| 3644 | + prom_act: t.data.data, | ||
| 3645 | + prom_end_time: prom_end_time, | ||
| 3646 | + prom_start_time: prom_start_time, | ||
| 3647 | + isshow: 1, | ||
| 3648 | + }); | ||
| 3649 | + | ||
| 3650 | + ee.get_sto(); | ||
| 3651 | + var newTime = ut.gettimestamp(); | ||
| 3652 | + var endTime2 = t.data.data.end_time; | ||
| 3653 | + var endTime1 = t.data.data.start_time; | ||
| 3654 | + if (endTime1 > newTime) { | ||
| 3655 | + ee.setData({ | ||
| 3656 | + prom_time_text: '距秒杀开始还有' | ||
| 3657 | + }) | ||
| 3658 | + ee.countDown(endTime1, 0); | ||
| 3659 | + } else { | ||
| 3660 | + if (endTime2 > newTime) { | ||
| 3661 | + ee.setData({ | ||
| 3662 | + prom_time_text: '距秒杀结束还有', | ||
| 3663 | + prom_st: 1 | ||
| 3664 | + }) | ||
| 3665 | + ee.countDown(endTime2); | ||
| 3666 | + } | ||
| 3667 | + } | ||
| 3668 | + | ||
| 3669 | + //如果是进行中的话 | ||
| 3670 | + if (endTime1 < newTime) { | ||
| 3671 | + //-- 获取秒杀活动的多少规格 -- | ||
| 3672 | + ee.get_more_flahs(function (list) { | ||
| 3673 | + if (list && list.length > 1) { | ||
| 3674 | + | ||
| 3675 | + var n_item = list[0]; | ||
| 3676 | + var ind = list.findIndex(function (ele) { | ||
| 3677 | + return ele.goods_id == ee.data.data.goods_id; | ||
| 3678 | + }) | ||
| 3679 | + if (ind < 0) return false; | ||
| 3680 | + if (ind > 0) { | ||
| 3681 | + n_item = JSON.parse(JSON.stringify(list[ind])); | ||
| 3682 | + list.splice(ind, 1); | ||
| 3683 | + list.unshift(n_item); | ||
| 3684 | + } | ||
| 3685 | + | ||
| 3686 | + ee.data.sele_g.viplimited = n_item.viplimited; | ||
| 3687 | + ee.data.data.viplimited = n_item.viplimited; | ||
| 3688 | + | ||
| 3689 | + var gb = 1; | ||
| 3690 | + //-- 显示多规格 -- | ||
| 3691 | + for (let i in list) { | ||
| 3692 | + let item = list[i]; | ||
| 3693 | + var gg = ""; | ||
| 3694 | + if (item.goods_spec == "null" || item.goods_spec == null) item.goods_spec = ""; | ||
| 3695 | + if (item.goods_color == "null" || item.goods_color == null) item.goods_color = ""; | ||
| 3696 | + | ||
| 3697 | + if (item.goods_spec != "" && item.goods_color != "") { | ||
| 3698 | + gg = item.goods_spec + "/" + item.goods_color; | ||
| 3699 | + } else if (item.goods_spec != "" || item.goods_color != "") { | ||
| 3700 | + gg = item.goods_spec + item.goods_color; | ||
| 3701 | + } else { | ||
| 3702 | + gg = "规格" + gb; | ||
| 3703 | + gb++; | ||
| 3704 | + } | ||
| 3705 | + item.gg = gg; | ||
| 3706 | + item.prom_id = item.prom_id; | ||
| 3707 | + item.prom_type = 1; | ||
| 3708 | + } | ||
| 3709 | + | ||
| 3710 | + ee.setData({ | ||
| 3711 | + sku_g: list, | ||
| 3712 | + }); | ||
| 3713 | + | ||
| 3714 | + } | ||
| 3715 | + }) | ||
| 3716 | + } | ||
| 3717 | + | ||
| 3718 | + } | ||
| 3719 | + }); | ||
| 3720 | + } | ||
| 3721 | + }) | ||
| 3722 | + } | ||
| 3723 | + | ||
| 3724 | + if (prom_type == 4) { | ||
| 3725 | + //th.setData({is_integral_normal:1}); | ||
| 3726 | + var rdata = { | ||
| 3727 | + store_id: o.stoid, stype: 1, stypeup: 1, goods_id: gid | ||
| 3728 | + } | ||
| 3729 | + | ||
| 3730 | + var integrals = 0; | ||
| 3731 | + var get_datas = { | ||
| 3732 | + user_id: getApp().globalData.user_id, store_id: o.stoid, | ||
| 3733 | + }; | ||
| 3734 | + await getApp().request.promiseGet("/api/weshop/users/getAllPoints", { | ||
| 3735 | + data: get_datas | ||
| 3736 | + }).then(res => { | ||
| 3737 | + if (res.data.code == 0) { | ||
| 3738 | + integrals = res.data.data?.Integral?res.data.data?.Integral:0; | ||
| 3739 | + } | ||
| 3740 | + }) | ||
| 3741 | + | ||
| 3742 | + //获取一下积分活动 | ||
| 3743 | + await getApp().request.promiseGet("/api/weshop/integralbuy/pageIntegralBuyGoodsList", { | ||
| 3744 | + data: rdata | ||
| 3745 | + }).then(res => { | ||
| 3746 | + //调用接口有数据的时候 | ||
| 3747 | + if (res.data.code == 0 && res.data.data && res.data.data.pageData && res.data.data.pageData.length > 0) { | ||
| 3748 | + var inte_data = res.data.data.pageData[0]; | ||
| 3749 | + var can_integral = (parseFloat(integrals) >= parseFloat(inte_data.integral)); | ||
| 3750 | + ee.setData({ | ||
| 3751 | + prom_price: parseFloat(inte_data.addmoney), | ||
| 3752 | + prom_integral: parseFloat(inte_data.integral), | ||
| 3753 | + prom_type: 4, | ||
| 3754 | + prom_id: inte_data.id, | ||
| 3755 | + prom_buy_limit: inte_data.limitvipqty, | ||
| 3756 | + prom_act: inte_data, | ||
| 3757 | + isshow: 1, | ||
| 3758 | + can_integral: can_integral, | ||
| 3759 | + is_shopbuy: parseInt(inte_data.is_shopbuy ? inte_data.is_shopbuy : 0) | ||
| 3760 | + }); | ||
| 3761 | + ee.get_sto(); | ||
| 3762 | + | ||
| 3763 | + } else { | ||
| 3764 | + ee.get_normal(gid); | ||
| 3765 | + return false; | ||
| 3766 | + } | ||
| 3767 | + }) | ||
| 3768 | + | ||
| 3769 | + } | ||
| 3770 | + | ||
| 3771 | + //---判断拼单---- | ||
| 3772 | + if (prom_type == 6) { | ||
| 3773 | + //-------判断活动是否抢光--------- | ||
| 3774 | + await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + os.stoid + "/" + prom_type + "/" + prom_id, { | ||
| 3775 | + 1: 1 | ||
| 3776 | + }).then(res => { | ||
| 3777 | + var em = res; | ||
| 3778 | + var flag = null; | ||
| 3779 | + if (em.data.code == 0) { | ||
| 3780 | + if (em.data.data <= 0) ee.setData({ | ||
| 3781 | + prom_r_null: 1 | ||
| 3782 | + }); | ||
| 3783 | + //拿取价格并且判断时间-- | ||
| 3784 | + getApp().request.get("/api/weshop/teamlist/get/" + | ||
| 3785 | + os.stoid + "/" + prom_id, { | ||
| 3786 | + success: async function (t) { | ||
| 3787 | + if (t.data.code != 0) { | ||
| 3788 | + ee.get_normal(gid); | ||
| 3789 | + return false; | ||
| 3790 | + } | ||
| 3791 | + //----已经结束----- | ||
| 3792 | + if (t.data.data.is_end == 1) { | ||
| 3793 | + ee.get_normal(gid); | ||
| 3794 | + return false; | ||
| 3795 | + } | ||
| 3796 | + //----已经过期----- | ||
| 3797 | + var now = ut.gettimestamp(); | ||
| 3798 | + if (t.data.data.end_time < now) { | ||
| 3799 | + ee.get_normal(gid); | ||
| 3800 | + return false; | ||
| 3801 | + } | ||
| 3802 | + | ||
| 3803 | + /*-- 还没有开始预热的也不显示 --*/ | ||
| 3804 | + if (t.data.data.show_time > now) { | ||
| 3805 | + ee.get_normal(gid); | ||
| 3806 | + return false; | ||
| 3807 | + } | ||
| 3808 | + | ||
| 3809 | + /*-- 判断拼单是否启用 --*/ | ||
| 3810 | + if (!t.data.data.is_show) { | ||
| 3811 | + console.log('没启用'); | ||
| 3812 | + wx.setNavigationBarTitle({ | ||
| 3813 | + title: '系统提示', | ||
| 3814 | + }); | ||
| 3815 | + wx.showToast({ | ||
| 3816 | + title: '此商品暂时没有拼单活动', | ||
| 3817 | + icon: 'none', | ||
| 3818 | + success(){ | ||
| 3819 | + setTimeout(() => { | ||
| 3820 | + wx.navigateBack() | ||
| 3821 | + }, 2000) | ||
| 3822 | + } | ||
| 3823 | + }); | ||
| 3824 | + return false | ||
| 3825 | + } | ||
| 3826 | + | ||
| 3827 | + //判断拼团的---会员身份-- | ||
| 3828 | + await getApp().request.promiseGet("/api/weshop/teamlist/pageteam/2", { | ||
| 3829 | + data: { | ||
| 3830 | + store_id: os.stoid, | ||
| 3831 | + is_end: 0, | ||
| 3832 | + is_show: 1, | ||
| 3833 | + user_id: getApp().globalData.user_id, | ||
| 3834 | + pageSize: 1000 | ||
| 3835 | + } | ||
| 3836 | + }).then(res => { | ||
| 3837 | + let pd_list = res.data.data.pageData; | ||
| 3838 | + if (res.data.code == 0 && pd_list.length > 0) { | ||
| 3839 | + flag = pd_list.some(pd => { | ||
| 3840 | + return pd.goods_id == gid | ||
| 3841 | + }) | ||
| 3842 | + } | ||
| 3843 | + }) | ||
| 3844 | + if (!flag) { | ||
| 3845 | + ee.get_normal(gid); | ||
| 3846 | + return false; | ||
| 3847 | + | ||
| 3848 | + } | ||
| 3849 | + //-------查看自己是不是有买过该团的商品,并还为支付,或者在进行中------- | ||
| 3850 | + await getApp().request.promiseGet("/api/weshop/order/page", { | ||
| 3851 | + data: { | ||
| 3852 | + pt_prom_id: prom_id, | ||
| 3853 | + user_id: oo.user_id, | ||
| 3854 | + store_id: os.stoid, | ||
| 3855 | + pageSize: 1, | ||
| 3856 | + page: 1 | ||
| 3857 | + } | ||
| 3858 | + }).then(e => { | ||
| 3859 | + if (e.data.code == 0 && e.data.data.pageData.length > 0) { | ||
| 3860 | + var odr = e.data.data.pageData[0]; | ||
| 3861 | + th.data.buy_order = odr; | ||
| 3862 | + if (odr.pt_status == 0 && odr.order_status == 1) { | ||
| 3863 | + th.setData({ | ||
| 3864 | + user_order_pt_state: 1 | ||
| 3865 | + }); | ||
| 3866 | + } | ||
| 3867 | + if (odr.pt_status == 1 && odr.order_status == 1) { | ||
| 3868 | + if (odr.is_zsorder == 4) { | ||
| 3869 | + getApp().request.promiseGet("/api/weshop/teamgroup/page/", { | ||
| 3870 | + data: { | ||
| 3871 | + store_id: os.stoid, | ||
| 3872 | + team_id: odr.pt_prom_id, | ||
| 3873 | + listno: odr.pt_listno | ||
| 3874 | + } | ||
| 3875 | + }).then(res => { | ||
| 3876 | + var now = ut.gettimestamp(); | ||
| 3877 | + if (res.data.code == 0 && res.data.data && res.data.data.pageData && res.data.data.pageData.length > 0) { | ||
| 3878 | + var tgr = res.data.data.pageData[0]; | ||
| 3879 | + //如果团的时间已经到了 | ||
| 3880 | + if (now >= tgr.kt_end_time) { | ||
| 3881 | + th.update_jiti(tgr.id); | ||
| 3882 | + } else { | ||
| 3883 | + th.setData({ | ||
| 3884 | + user_order_pt_state: 2 | ||
| 3885 | + }); | ||
| 3886 | + } | ||
| 3887 | + } | ||
| 3888 | + }) | ||
| 3889 | + | ||
| 3890 | + } else { | ||
| 3891 | + th.setData({ | ||
| 3892 | + user_order_pt_state: 2 | ||
| 3893 | + }); | ||
| 3894 | + } | ||
| 3895 | + } | ||
| 3896 | + | ||
| 3897 | + if (odr.pt_status == 2 && odr.is_zsorder == 4) { | ||
| 3898 | + th.setData({ | ||
| 3899 | + user_order_pt_state: 3, | ||
| 3900 | + }); | ||
| 3901 | + th.data.wk_order_id = odr.order_id; | ||
| 3902 | + } | ||
| 3903 | + } | ||
| 3904 | + }) | ||
| 3905 | + | ||
| 3906 | + //----------查看阶梯团------------ | ||
| 3907 | + if (t.data.data.ct_rylist != "null" && t.data.data.ct_rylist != "" && t.data.data.ct_rylist != null && t.data.data.ct_rylist != undefined) { | ||
| 3908 | + t.data.data.ct_rylist = JSON.parse(t.data.data.ct_rylist); | ||
| 3909 | + var max_num = 0; | ||
| 3910 | + t.data.data.ct_rylist.forEach(function (val, ind) { | ||
| 3911 | + if (parseInt(val.rynum) > max_num) max_num = parseInt(val.rynum); | ||
| 3912 | + }) | ||
| 3913 | + t.data.data.max_ct_num = max_num; | ||
| 3914 | + } | ||
| 3915 | + | ||
| 3916 | + var prom_end_time = ut.formatTime(t.data.data.end_time, "yyyy-MM-dd hh:mm:ss"); | ||
| 3917 | + var prom_start_time = ut.formatTime(t.data.data.start_time, "yyyy-MM-dd hh:mm:ss"); | ||
| 3918 | + ee.setData({ | ||
| 3919 | + prom_price: t.data.data.price, | ||
| 3920 | + prom_type: 6, | ||
| 3921 | + prom_id: prom_id, | ||
| 3922 | + prom_buy_limit: t.data.data.buy_limit, | ||
| 3923 | + prom_act: t.data.data, | ||
| 3924 | + prom_end_time: prom_end_time, | ||
| 3925 | + prom_start_time: prom_start_time, | ||
| 3926 | + isshow: 1, | ||
| 3927 | + }); | ||
| 3928 | + | ||
| 3929 | + ee.get_sto(); | ||
| 3930 | + | ||
| 3931 | + var newTime = now; | ||
| 3932 | + var endTime2 = t.data.data.end_time; | ||
| 3933 | + var endTime1 = t.data.data.start_time; | ||
| 3934 | + | ||
| 3935 | + if (endTime1 > newTime) { | ||
| 3936 | + ee.setData({ | ||
| 3937 | + prom_time_text: '距拼单开始还剩:' | ||
| 3938 | + }) | ||
| 3939 | + ee.countDown(endTime1, 0); | ||
| 3940 | + } else { | ||
| 3941 | + if (endTime2 > newTime) { | ||
| 3942 | + ee.setData({ | ||
| 3943 | + prom_time_text: '距拼单结束还剩:', | ||
| 3944 | + prom_st: 1 | ||
| 3945 | + }) | ||
| 3946 | + ee.countDown(endTime2); | ||
| 3947 | + } | ||
| 3948 | + } | ||
| 3949 | + //-------查看有多少人在开这个团------- | ||
| 3950 | + th.get_team_group(prom_id); | ||
| 3951 | + } | ||
| 3952 | + }); | ||
| 3953 | + } | ||
| 3954 | + }) | ||
| 3955 | + } | ||
| 3956 | + }, | ||
| 3957 | + | ||
| 3958 | + //--获取有多少人在开团-- | ||
| 3959 | + async get_team_group(prom_id) { | ||
| 3960 | + var teamgroup = [], | ||
| 3961 | + th = this, | ||
| 3962 | + grounp_tatal = 0; | ||
| 3963 | + //如果活动是开团不是商家团 | ||
| 3964 | + if (this.data.prom_act.kttype > 1) { | ||
| 3965 | + | ||
| 3966 | + var req_data = { | ||
| 3967 | + store_id: os.stoid, | ||
| 3968 | + pageSize: 3, | ||
| 3969 | + page: 1, | ||
| 3970 | + state: 2, | ||
| 3971 | + team_id: prom_id, | ||
| 3972 | + ordernum: 1 | ||
| 3973 | + }; | ||
| 3974 | + | ||
| 3975 | + if (this.data.prom_act.kttype == 3 && this.data.prom_act.max_ct_num) { | ||
| 3976 | + req_data.max_num = this.data.prom_act.max_ct_num; | ||
| 3977 | + } | ||
| 3978 | + | ||
| 3979 | + //获取活动从表信息team_id | ||
| 3980 | + await getApp().request.promiseGet("/api/weshop/teamgroup/page", { | ||
| 3981 | + data: req_data | ||
| 3982 | + }).then(res => { | ||
| 3983 | + teamgroup = res.data.data.pageData; | ||
| 3984 | + grounp_tatal = res.data.data.total; | ||
| 3985 | + }) | ||
| 3986 | + //获取订单的总数这个接口不能用 | ||
| 3987 | + for (i = 0; i < teamgroup.length; i++) { | ||
| 3988 | + await getApp().request.promiseGet("/api/weshop/order/page", { | ||
| 3989 | + data: { | ||
| 3990 | + store_id: os.stoid, | ||
| 3991 | + pt_status: 1, | ||
| 3992 | + pt_listno: teamgroup[i].listno | ||
| 3993 | + } | ||
| 3994 | + }).then(res => { | ||
| 3995 | + var order = res.data.data.pageData; | ||
| 3996 | + teamgroup[i].open_num = order.length; | ||
| 3997 | + }) | ||
| 3998 | + await getApp().request.promiseGet("/api/weshop/users/get/" + os.stoid + "/" + teamgroup[i].openvipid, {}).then(res => { | ||
| 3999 | + var user = res.data.data; | ||
| 4000 | + teamgroup[i].user = user; | ||
| 4001 | + }) | ||
| 4002 | + } | ||
| 4003 | + | ||
| 4004 | + if (teamgroup.length > 0) { | ||
| 4005 | + th.setData({ | ||
| 4006 | + teamgroup: teamgroup, | ||
| 4007 | + grounp_tatal: grounp_tatal | ||
| 4008 | + }); | ||
| 4009 | + th.countDown2(); | ||
| 4010 | + } | ||
| 4011 | + } | ||
| 4012 | + }, | ||
| 4013 | + | ||
| 4014 | + //---小于10的格式化函数---- | ||
| 4015 | + timeFormat(param) { | ||
| 4016 | + return param < 10 ? '0' + param : param; | ||
| 4017 | + }, | ||
| 4018 | + | ||
| 4019 | + // 显示拼单规则 | ||
| 4020 | + showRules: function() { | ||
| 4021 | + this.setData({ | ||
| 4022 | + showRules: true, | ||
| 4023 | + }); | ||
| 4024 | + }, | ||
| 4025 | + | ||
| 4026 | + // 关闭拼单规则 | ||
| 4027 | + closeRules: function() { | ||
| 4028 | + this.setData({ | ||
| 4029 | + showRules: false, | ||
| 4030 | + }); | ||
| 4031 | + }, | ||
| 4032 | + | ||
| 4033 | + //----倒计时函数----- | ||
| 4034 | + countDown(time, prom_st) { | ||
| 4035 | + if (!this.data.is_timer) return false; | ||
| 4036 | + var th = this; | ||
| 4037 | + // 获取当前时间,同时得到活动结束时间数组 | ||
| 4038 | + var endTime = time; | ||
| 4039 | + var newTime = ut.gettimestamp(); | ||
| 4040 | + // 对结束时间进行处理渲染到页面 | ||
| 4041 | + var obj = null; | ||
| 4042 | + // 如果活动未结束,对时间进行处理 | ||
| 4043 | + if (endTime - newTime > 0) { | ||
| 4044 | + var time = (endTime - newTime); | ||
| 4045 | + // 获取天、时、分、秒 | ||
| 4046 | + var day = parseInt(time / (60 * 60 * 24)); | ||
| 4047 | + var hou = parseInt(time % (60 * 60 * 24) / 3600); | ||
| 4048 | + var min = parseInt(time % (60 * 60 * 24) % 3600 / 60); | ||
| 4049 | + var sec = parseInt(time % (60 * 60 * 24) % 3600 % 60); | ||
| 4050 | + obj = { | ||
| 4051 | + day: this.timeFormat(day), | ||
| 4052 | + hou: this.timeFormat(hou), | ||
| 4053 | + min: this.timeFormat(min), | ||
| 4054 | + sec: this.timeFormat(sec) | ||
| 4055 | + } | ||
| 4056 | + } else { | ||
| 4057 | + if (th.data.prom_st == 0) { | ||
| 4058 | + //var endTime2 = new Date(th.data.prom_end_time).getTime(); | ||
| 4059 | + var endTime2 = th.data.prom_act.end_time; | ||
| 4060 | + th.setData({ | ||
| 4061 | + prom_time_text: '距结束还剩:', | ||
| 4062 | + prom_st: 1 | ||
| 4063 | + }) | ||
| 4064 | + setTimeout(function () { | ||
| 4065 | + th.countDown(endTime2) | ||
| 4066 | + }, 1000); | ||
| 4067 | + return false; | ||
| 4068 | + | ||
| 4069 | + } else { | ||
| 4070 | + //活动已结束,全部设置为'00' | ||
| 4071 | + obj = { | ||
| 4072 | + day: '00', | ||
| 4073 | + hou: '00', | ||
| 4074 | + min: '00', | ||
| 4075 | + sec: '00' | ||
| 4076 | + } | ||
| 4077 | + th.setData({ | ||
| 4078 | + prom_time_text: '活动已经结束:', | ||
| 4079 | + prom_st: 3 | ||
| 4080 | + }) | ||
| 4081 | + th.setData({ | ||
| 4082 | + djs: obj | ||
| 4083 | + }); | ||
| 4084 | + return false; | ||
| 4085 | + } | ||
| 4086 | + } | ||
| 4087 | + | ||
| 4088 | + th.setData({ | ||
| 4089 | + djs: obj | ||
| 4090 | + }); | ||
| 4091 | + setTimeout(function () { | ||
| 4092 | + th.countDown(endTime) | ||
| 4093 | + }, 1000); | ||
| 4094 | + }, | ||
| 4095 | + | ||
| 4096 | + | ||
| 4097 | + //-------------获取购买数量的总函数---------------- | ||
| 4098 | + get_buy_num: function (gd, func) { | ||
| 4099 | + var map = this.data.g_buy_num, | ||
| 4100 | + th = this, | ||
| 4101 | + user_id = getApp().globalData.user_id; | ||
| 4102 | + if (user_id == null) { | ||
| 4103 | + map.set(gd.goods_id, 0); | ||
| 4104 | + th.setData({ | ||
| 4105 | + g_buy_num: map, | ||
| 4106 | + prom_buy_num: 0, | ||
| 4107 | + }); | ||
| 4108 | + "function" == typeof func && func(); | ||
| 4109 | + return false; | ||
| 4110 | + } | ||
| 4111 | + | ||
| 4112 | + if (map.has(gd.goods_id)) { | ||
| 4113 | + "function" == typeof func && func(); | ||
| 4114 | + } else { | ||
| 4115 | + //----获取商品购买数---- | ||
| 4116 | + getApp().request.get("/api/weshop/ordergoods/getUserBuyGoodsNum", { | ||
| 4117 | + data: { | ||
| 4118 | + store_id: os.stoid, | ||
| 4119 | + user_id: user_id, | ||
| 4120 | + goods_id: gd.goods_id | ||
| 4121 | + }, | ||
| 4122 | + success: function (t) { | ||
| 4123 | + if (t.data.code == 0) { | ||
| 4124 | + var g_buy_num = t.data.data.goodsbuynum; | ||
| 4125 | + | ||
| 4126 | + //如果是秒杀的时候 | ||
| 4127 | + if (th.data.prom_type == 0 && gd.prom_type == 1) { | ||
| 4128 | + gd.prom_type = 0; | ||
| 4129 | + } | ||
| 4130 | + //如果全场优惠,商品做了秒杀 | ||
| 4131 | + if (th.data.prom_type == 3 && gd.prom_type == 1) { | ||
| 4132 | + gd.prom_type = 0; | ||
| 4133 | + } | ||
| 4134 | + //如果全场阶梯优惠,商品做了秒杀 | ||
| 4135 | + if (th.data.prom_type == 10 && gd.prom_type == 1) { | ||
| 4136 | + gd.prom_type = 0; | ||
| 4137 | + } | ||
| 4138 | + | ||
| 4139 | + | ||
| 4140 | + if (!th.data.is_normal && ( gd.prom_type == 1 || gd.prom_type == 2 || gd.prom_type == 4 || gd.prom_type == 6)) { | ||
| 4141 | + //----获取活动购买数---- | ||
| 4142 | + getApp().request.get("/api/weshop/ordergoods/getUserBuyGoodsNum", { | ||
| 4143 | + data: { | ||
| 4144 | + store_id: os.stoid, | ||
| 4145 | + user_id: user_id, | ||
| 4146 | + goods_id: gd.goods_id, | ||
| 4147 | + prom_type: gd.prom_type, | ||
| 4148 | + prom_id: gd.prom_id | ||
| 4149 | + }, | ||
| 4150 | + //-----获取----- | ||
| 4151 | + success: function (tt) { | ||
| 4152 | + if (tt.data.code == 0) { | ||
| 4153 | + map.set(gd.goods_id, g_buy_num); | ||
| 4154 | + th.setData({ | ||
| 4155 | + g_buy_num: map, | ||
| 4156 | + prom_buy_num: tt.data.data.promgoodsbuynum, | ||
| 4157 | + }); | ||
| 4158 | + "function" == typeof func && func(); | ||
| 4159 | + } | ||
| 4160 | + } | ||
| 4161 | + }); | ||
| 4162 | + } else { | ||
| 4163 | + map.set(gd.goods_id, g_buy_num); | ||
| 4164 | + th.setData({ | ||
| 4165 | + g_buy_num: map | ||
| 4166 | + }); | ||
| 4167 | + "function" == typeof func && func(); | ||
| 4168 | + } | ||
| 4169 | + } | ||
| 4170 | + } | ||
| 4171 | + }); | ||
| 4172 | + } | ||
| 4173 | + }, | ||
| 4174 | + | ||
| 4175 | + //--拼单推荐的显示--- | ||
| 4176 | + tj_Click: function (e) { | ||
| 4177 | + var ind = parseInt(e.target.dataset.ind); | ||
| 4178 | + this.setData({ | ||
| 4179 | + is_show_gz: ind | ||
| 4180 | + }); | ||
| 4181 | + }, | ||
| 4182 | + | ||
| 4183 | + //--------拼团玩法显示详情-------- | ||
| 4184 | + show_pt_xx: function (e) { | ||
| 4185 | + this.setData({ | ||
| 4186 | + pd_xx: 1, | ||
| 4187 | + }) | ||
| 4188 | + }, | ||
| 4189 | + close_pt_xx: function () { | ||
| 4190 | + this.setData({ | ||
| 4191 | + pd_xx: 0, | ||
| 4192 | + }) | ||
| 4193 | + }, | ||
| 4194 | + | ||
| 4195 | + //--点击弹起拼单-- | ||
| 4196 | + openSpecModel_pt: function (e) { | ||
| 4197 | + | ||
| 4198 | + | ||
| 4199 | + this.setData({open_ind_store: 4, goodsInputNum: 1});//拼团直接给4 | ||
| 4200 | + | ||
| 4201 | + | ||
| 4202 | + //--先判断会员状态-- | ||
| 4203 | + var user_info = getApp().globalData.userInfo; | ||
| 4204 | + if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { | ||
| 4205 | + wx.navigateTo({ | ||
| 4206 | + url: '/pages/togoin/togoin', | ||
| 4207 | + }) | ||
| 4208 | + return false; | ||
| 4209 | + } | ||
| 4210 | + | ||
| 4211 | + var th = this; | ||
| 4212 | + var ind = parseInt(e.currentTarget.dataset.it); | ||
| 4213 | + | ||
| 4214 | + //如果是拼单活动的普通购买 | ||
| 4215 | + if (ind == 1) { | ||
| 4216 | + | ||
| 4217 | + if (!th.data.is_normal) { | ||
| 4218 | + th.data.g_buy_num = new Map(); | ||
| 4219 | + } | ||
| 4220 | + | ||
| 4221 | + //如果拼单的sku data是空的,就要先获取一下 | ||
| 4222 | + if (th.data.sku_g_pt) { | ||
| 4223 | + th.get_sto(1); | ||
| 4224 | + th.setData({ | ||
| 4225 | + is_normal: ind, | ||
| 4226 | + openSpecModal_pt: 1 | ||
| 4227 | + }); | ||
| 4228 | + } else { | ||
| 4229 | + th.get_sto(1); | ||
| 4230 | + th.get_sku(o.stoid, th.data.data, th.data.gid, 1, function () { | ||
| 4231 | + th.setData({ | ||
| 4232 | + is_normal: ind, | ||
| 4233 | + openSpecModal_pt: 1 | ||
| 4234 | + }); | ||
| 4235 | + }); | ||
| 4236 | + } | ||
| 4237 | + th.check_is_youhui(th.data.gid, 1); | ||
| 4238 | + } else { | ||
| 4239 | + | ||
| 4240 | + if (th.data.is_normal) { | ||
| 4241 | + th.data.g_buy_num = new Map(); | ||
| 4242 | + } | ||
| 4243 | + | ||
| 4244 | + //拼单商品从这里进,先判断有没有买过商品, | ||
| 4245 | + getApp().request.get("/api/weshop/order/page", { | ||
| 4246 | + data: { | ||
| 4247 | + pt_prom_id: th.data.prom_act.id, | ||
| 4248 | + user_id: oo.user_id, | ||
| 4249 | + store_id: os.stoid, | ||
| 4250 | + pageSize: 1, | ||
| 4251 | + page: 1 | ||
| 4252 | + }, | ||
| 4253 | + success: function (e) { | ||
| 4254 | + //--跳转到已经购买的情况-- | ||
| 4255 | + if (e.data.data.pageData.length > 0) { | ||
| 4256 | + var odr = e.data.data.pageData[0]; | ||
| 4257 | + //还未支付 | ||
| 4258 | + if (odr.pt_status == 0 && (odr.order_status == 1 || odr.order_status == 0)) { | ||
| 4259 | + wx.showModal({ | ||
| 4260 | + title: "您已经购买了该商品待支付中", | ||
| 4261 | + success: function (a) { | ||
| 4262 | + if (a.confirm) { | ||
| 4263 | + wx.navigateTo({ | ||
| 4264 | + url: "/pages/user/order_detail/order_detail?order_id=" + odr.order_id, | ||
| 4265 | + }); | ||
| 4266 | + } | ||
| 4267 | + } | ||
| 4268 | + }); | ||
| 4269 | + } else if (odr.pt_status == 1 && odr.order_status == 1) { | ||
| 4270 | + | ||
| 4271 | + if (this.data.is_go_to_team_show) return false; | ||
| 4272 | + this.data.is_go_to_team_show = 1; | ||
| 4273 | + wx.showLoading(); | ||
| 4274 | + | ||
| 4275 | + /*--- | ||
| 4276 | + wx.redirectTo({ | ||
| 4277 | + url: "/pages/team/team_success/team_success?ordersn=" + odr.order_sn, | ||
| 4278 | + });--*/ | ||
| 4279 | + getApp().goto("/pages/team/team_success/team_success?ordersn=" + odr.order_sn); | ||
| 4280 | + | ||
| 4281 | + } else { | ||
| 4282 | + th.setData({ | ||
| 4283 | + is_normal: ind, | ||
| 4284 | + openSpecModal_pt: 1 | ||
| 4285 | + }); | ||
| 4286 | + } | ||
| 4287 | + } | ||
| 4288 | + else { | ||
| 4289 | + th.setData({ | ||
| 4290 | + is_normal: ind, | ||
| 4291 | + openSpecModal_pt: 1 | ||
| 4292 | + }); | ||
| 4293 | + } | ||
| 4294 | + } | ||
| 4295 | + }) | ||
| 4296 | + } | ||
| 4297 | + }, | ||
| 4298 | + | ||
| 4299 | + //-----------------拼单生成方法--------------------- | ||
| 4300 | + addCart_pt: function () { | ||
| 4301 | + var th = this; | ||
| 4302 | + if (this.data.is_normal == 0) { | ||
| 4303 | + //看一下有没有起购数,如果有起购数,要计算起购数 | ||
| 4304 | + var qnum = parseFloat(th.data.prom_act.minbuynum); | ||
| 4305 | + if (qnum > 0 && th.data.goodsInputNum < qnum) { | ||
| 4306 | + getApp().confirmBox("拼团商品至少要买" + qnum + "件!"); | ||
| 4307 | + return false; | ||
| 4308 | + } | ||
| 4309 | + th.addcart_pt_func(); | ||
| 4310 | + } else { | ||
| 4311 | + th.addcart_pt_func(); | ||
| 4312 | + } | ||
| 4313 | + }, | ||
| 4314 | + | ||
| 4315 | + addcart_pt_func: function () { | ||
| 4316 | + if (oo.user_id == null) { | ||
| 4317 | + s.my_warnning("还未登录!", 0, this); | ||
| 4318 | + return; | ||
| 4319 | + } | ||
| 4320 | + var e = this, | ||
| 4321 | + th = e, | ||
| 4322 | + o = this.data.sele_g; | ||
| 4323 | + if (o.store_count <= 0) { | ||
| 4324 | + wx.showToast({ title: '库存已为空!', icon: 'none', }); | ||
| 4325 | + return false; | ||
| 4326 | + // return s.my_warnning("库存已为空!", 0, th); | ||
| 4327 | + }; | ||
| 4328 | + | ||
| 4329 | + //----------添加到购物车时,要判断限购数量,-------- | ||
| 4330 | + e.get_buy_num(o, async function (ee) { | ||
| 4331 | + | ||
| 4332 | + //---判断商品是否超出限购--- | ||
| 4333 | + if (th.data.g_buy_num != null && th.data.sele_g.viplimited > 0) { | ||
| 4334 | + if (th.data.goodsInputNum + th.data.g_buy_num.get(th.data.sele_g.goods_id) > th.data.sele_g.viplimited) { | ||
| 4335 | + wx.showToast({ | ||
| 4336 | + title: '超出商品限购', | ||
| 4337 | + icon: 'none', | ||
| 4338 | + }); | ||
| 4339 | + // s.my_warnning('超出商品限购', 0, th); | ||
| 4340 | + var num = th.data.prom_buy_limit - th.data.prom_buy_num; | ||
| 4341 | + if (num < 0) num = 0; | ||
| 4342 | + th.setData({goodsInputNum: num}) | ||
| 4343 | + return false; | ||
| 4344 | + } | ||
| 4345 | + } | ||
| 4346 | + //---判断商品是否超出活动限购,拼团的普通购买不计算活动的限购--- | ||
| 4347 | + if (th.data.prom_buy_num != -1 && th.data.prom_buy_limit > 0 && th.data.is_normal != 1) { | ||
| 4348 | + if (th.data.goodsInputNum + th.data.prom_buy_num > th.data.prom_buy_limit) { | ||
| 4349 | + wx.showToast({ | ||
| 4350 | + title: '超出商品活动限购', | ||
| 4351 | + icon: 'none', | ||
| 4352 | + }); | ||
| 4353 | + // s.my_warnning('超出商品活动限购', 0, th); | ||
| 4354 | + var num = th.data.prom_buy_limit - th.data.prom_buy_num; | ||
| 4355 | + if (num < 0) num = 0; | ||
| 4356 | + th.setData({goodsInputNum: num}) | ||
| 4357 | + return false; | ||
| 4358 | + } | ||
| 4359 | + } | ||
| 4360 | + | ||
| 4361 | + var redis_num = 0 | ||
| 4362 | + //不是普通购买的时候 | ||
| 4363 | + if (th.data.is_normal != 1) { | ||
| 4364 | + //-------判断活动是否抢光--------- | ||
| 4365 | + await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + os.stoid + "/6/" + th.data.sele_g.prom_id, { | ||
| 4366 | + 1: 1 | ||
| 4367 | + }).then(res => { | ||
| 4368 | + redis_num = res.data.data; | ||
| 4369 | + }) | ||
| 4370 | + | ||
| 4371 | + if (th.data.goodsInputNum > redis_num) { | ||
| 4372 | + wx.showToast({ | ||
| 4373 | + title: '超出商品活动库存', | ||
| 4374 | + icon: 'none', | ||
| 4375 | + }); | ||
| 4376 | + // s.my_warnning('超出商品活动库存', 0, th); | ||
| 4377 | + th.setData({goodsInputNum: redis_num}) | ||
| 4378 | + | ||
| 4379 | + return false; | ||
| 4380 | + } | ||
| 4381 | + } | ||
| 4382 | + | ||
| 4383 | + if (th.data.goodsInputNum <= 0) { | ||
| 4384 | + wx.showToast({ | ||
| 4385 | + title: '商品数量不能为0', | ||
| 4386 | + icon: 'none', | ||
| 4387 | + }); | ||
| 4388 | + return false; | ||
| 4389 | + // return s.my_warnning("商品数量不能为0", 0, th); | ||
| 4390 | + }; | ||
| 4391 | + if (th.data.goodsInputNum > o.store_count) { | ||
| 4392 | + th.setData({goodsInputNum: o.store_count}) | ||
| 4393 | + wx.showToast({ | ||
| 4394 | + title: '超出商品库存', | ||
| 4395 | + icon: 'none', | ||
| 4396 | + }); | ||
| 4397 | + return false; | ||
| 4398 | + // return s.my_warnning("超出商品库存", 0, th); | ||
| 4399 | + } | ||
| 4400 | + | ||
| 4401 | + if (th.data.sto_sele_name == null || th.data.sto_sele_name == undefined) | ||
| 4402 | + this.setData({ | ||
| 4403 | + sto_sele_name: "" | ||
| 4404 | + }); | ||
| 4405 | + if (th.data.sto_sele_name == "") return s.my_warnning("请选择门店", 0, th); | ||
| 4406 | + //--------------此时操作的数据------------ | ||
| 4407 | + var newd = { | ||
| 4408 | + goods_id: o.goods_id, | ||
| 4409 | + goods_num: th.data.goodsInputNum, | ||
| 4410 | + pick_id: th.data.sto_sele_id, | ||
| 4411 | + user_id: oo.user_id, | ||
| 4412 | + store_id: th.data.stoid, | ||
| 4413 | + goods_price: o.shop_price, | ||
| 4414 | + goods_name: o.goods_name, | ||
| 4415 | + goods_sn: o.goods_sn, | ||
| 4416 | + sku: o.sku, | ||
| 4417 | + }; | ||
| 4418 | + | ||
| 4419 | + //---是不是从收藏夹出来的--- | ||
| 4420 | + if (th.data.c_guide_id) { | ||
| 4421 | + newd['guide_id'] = th.data.c_guide_id; | ||
| 4422 | + newd['guide_type'] = 2; | ||
| 4423 | + | ||
| 4424 | + | ||
| 4425 | + | ||
| 4426 | + | ||
| 4427 | + } else { | ||
| 4428 | + if (getApp().globalData.guide_id) { | ||
| 4429 | + newd['guide_id'] = getApp().globalData.guide_id; | ||
| 4430 | + newd['guide_type'] = 0; | ||
| 4431 | + | ||
| 4432 | + | ||
| 4433 | + } | ||
| 4434 | + } | ||
| 4435 | + | ||
| 4436 | + //让商品带上房间号 | ||
| 4437 | + if (!th.data.sys_switch.is_skuroom_id && th.data.sys_switch.is_skuroom_id == 1) { | ||
| 4438 | + if (th.data.data.goods_id == getApp().globalData.room_goods_id) { | ||
| 4439 | + newd.room_id = getApp().globalData.room_id; | ||
| 4440 | + } | ||
| 4441 | + } else { | ||
| 4442 | + if (newd.goods_id == getApp().globalData.room_goods_id) { | ||
| 4443 | + newd.room_id = getApp().globalData.room_id; | ||
| 4444 | + } | ||
| 4445 | + } | ||
| 4446 | + | ||
| 4447 | + //---如果商品不是积分购和拼团,要判断一个是否要进行等级价的判断------ | ||
| 4448 | + | ||
| 4449 | + if (th.data.is_normal == 1) { | ||
| 4450 | + var conf = th.data.bconfig; | ||
| 4451 | + if (conf.switch_list) { | ||
| 4452 | + var s_list = JSON.parse(conf.switch_list); | ||
| 4453 | + //如果后台有开启等级价的功能 | ||
| 4454 | + if (parseInt(s_list.rank_switch) == 2) { | ||
| 4455 | + var card_price = o[getApp().globalData.userInfo['card_field']]; | ||
| 4456 | + //如果会员有等级价 | ||
| 4457 | + if (getApp().globalData.userInfo['card_field'] != undefined && getApp().globalData.userInfo['card_field'] != null | ||
| 4458 | + && getApp().globalData.userInfo['card_field'] != "" && card_price > 0) { | ||
| 4459 | + newd.goods_price = card_price; | ||
| 4460 | + } | ||
| 4461 | + } | ||
| 4462 | + } | ||
| 4463 | + } | ||
| 4464 | + | ||
| 4465 | + | ||
| 4466 | + //-----如果是秒杀,团购,积分购,拼团,且不是普通购买----- | ||
| 4467 | + if (th.data.prom_type == 6 && th.data.is_normal != 1) { | ||
| 4468 | + newd.goods_price = th.data.prom_price; | ||
| 4469 | + newd.prom_type = th.data.prom_type; | ||
| 4470 | + newd.prom_id = th.data.prom_id; | ||
| 4471 | + newd.kt_type = th.data.prom_act.kttype; //开团类型 | ||
| 4472 | + newd.is_pt_tz = 0; | ||
| 4473 | + //th.data.sto_sele_distr=1; //直接用自提的方式提交 | ||
| 4474 | + if (newd.kt_type > 1) { | ||
| 4475 | + newd.is_pt_tz = 1; //开团类型 | ||
| 4476 | + } | ||
| 4477 | + if (newd.kt_type == 3) { | ||
| 4478 | + th.data.sto_sele_distr = 1; | ||
| 4479 | + } | ||
| 4480 | + | ||
| 4481 | + } else if (th.data.prom_type == 3) { | ||
| 4482 | + newd.prom_type = 0; | ||
| 4483 | + newd.prom_id = 0; | ||
| 4484 | + } | ||
| 4485 | + | ||
| 4486 | + newd['pick_name'] = th.data.sto_sele_name; | ||
| 4487 | + newd['pick_dis'] = th.data.sto_sele_distr; | ||
| 4488 | + newd['is_normal'] = th.data.is_normal; | ||
| 4489 | + | ||
| 4490 | + if (newd['is_normal']) { | ||
| 4491 | + newd['is_pd_normal'] = 1; | ||
| 4492 | + //判断一下有没有全局优惠活动 | ||
| 4493 | + th.check_nor_promgood(newd.goods_id, function (e) { | ||
| 4494 | + if (e && e.act_id) { | ||
| 4495 | + newd['prom_type'] = 3; | ||
| 4496 | + newd['prom_id'] = e.act_id; | ||
| 4497 | + } | ||
| 4498 | + th.buyNow(newd) | ||
| 4499 | + }) | ||
| 4500 | + } | ||
| 4501 | + else th.buyNow_pt(newd); | ||
| 4502 | + }) | ||
| 4503 | + }, | ||
| 4504 | + | ||
| 4505 | + //----------立即购买_pt----------- | ||
| 4506 | + buyNow_pt: function (e) { | ||
| 4507 | + s.set_b_now(e); | ||
| 4508 | + wx.navigateTo({ | ||
| 4509 | + url: "/pages/cart/cart2_pt/cart2_pt?is_bnow=1&goods_id=" + e.goods_id, | ||
| 4510 | + }); | ||
| 4511 | + }, | ||
| 4512 | + | ||
| 4513 | + //-------跳转pt商品------- | ||
| 4514 | + go_to_nopay: function () { | ||
| 4515 | + var th = this; | ||
| 4516 | + url = "/pages/user/order_detail/order_detail?order_id=" + th.data.buy_order.order_id; | ||
| 4517 | + getApp().goto(url); | ||
| 4518 | + | ||
| 4519 | + }, | ||
| 4520 | + //-------跳转pt teamshow------- | ||
| 4521 | + go_to_team_show: function () { | ||
| 4522 | + | ||
| 4523 | + if (this.data.is_go_to_team_show) return false; | ||
| 4524 | + this.data.is_go_to_team_show = 1; | ||
| 4525 | + wx.showLoading(); | ||
| 4526 | + | ||
| 4527 | + var th = this; | ||
| 4528 | + var url = "/pages/team/team_success/team_success?ordersn=" + th.data.buy_order.order_sn; | ||
| 4529 | + /*-- | ||
| 4530 | + wx.redirectTo({ | ||
| 4531 | + url:url, | ||
| 4532 | + })--*/ | ||
| 4533 | + getApp().goto(url); | ||
| 4534 | + | ||
| 4535 | + }, | ||
| 4536 | + | ||
| 4537 | + //---拼团倒计时--- | ||
| 4538 | + countDown2() { | ||
| 4539 | + if (!this.data.is_timer) return false; | ||
| 4540 | + var th = this; | ||
| 4541 | + // 获取当前时间,同时得到活动结束时间数组 | ||
| 4542 | + var newTime = ut.gettimestamp(); | ||
| 4543 | + var List = th.data.teamgroup; | ||
| 4544 | + for (var j = 0; j < List.length; j++) { | ||
| 4545 | + // 对结束时间进行处理渲染到页面 | ||
| 4546 | + var endTime = List[j].kt_end_time; | ||
| 4547 | + let obj = null; | ||
| 4548 | + // 如果活动未结束,对时间进行处理 | ||
| 4549 | + if (endTime - newTime > 0) { | ||
| 4550 | + let time = (endTime - newTime); | ||
| 4551 | + // 获取天、时、分、秒 | ||
| 4552 | + let day = parseInt(time / (60 * 60 * 24)); | ||
| 4553 | + let hou = parseInt(time % (60 * 60 * 24) / 3600); | ||
| 4554 | + let min = parseInt(time % (60 * 60 * 24) % 3600 / 60); | ||
| 4555 | + let sec = parseInt(time % (60 * 60 * 24) % 3600 % 60); | ||
| 4556 | + obj = { | ||
| 4557 | + day: this.timeFormat(day), | ||
| 4558 | + hou: this.timeFormat(hou), | ||
| 4559 | + min: this.timeFormat(min), | ||
| 4560 | + sec: this.timeFormat(sec) | ||
| 4561 | + } | ||
| 4562 | + } else { | ||
| 4563 | + //活动已结束,全部设置为'00' | ||
| 4564 | + obj = { | ||
| 4565 | + day: '00', | ||
| 4566 | + hou: '00', | ||
| 4567 | + min: '00', | ||
| 4568 | + sec: '00' | ||
| 4569 | + } | ||
| 4570 | + } | ||
| 4571 | + var txt = "timer[" + j + "]"; | ||
| 4572 | + th.setData({ | ||
| 4573 | + [txt]: obj | ||
| 4574 | + }); | ||
| 4575 | + } | ||
| 4576 | + setTimeout(th.countDown2, 1000); | ||
| 4577 | + }, | ||
| 4578 | + //跳转参加团 | ||
| 4579 | + go_cj_team: function (e) { | ||
| 4580 | + var ind = e.currentTarget.dataset.ind; | ||
| 4581 | + var item = this.data.teamgroup[ind]; | ||
| 4582 | + var goods_id = e.currentTarget.dataset.goodsid; | ||
| 4583 | + var id = item.id; | ||
| 4584 | + var th = this; | ||
| 4585 | + | ||
| 4586 | + getApp().request.get("/api/weshop/order/page", { | ||
| 4587 | + data: { | ||
| 4588 | + pt_prom_id: item.team_id, | ||
| 4589 | + user_id: oo.user_id, | ||
| 4590 | + store_id: os.stoid, | ||
| 4591 | + pageSize: 1, | ||
| 4592 | + page: 1 | ||
| 4593 | + }, | ||
| 4594 | + success: function (e) { | ||
| 4595 | + if (e.data.code != 0) { | ||
| 4596 | + getApp().my_warnning("读取订单失败", 0, th); | ||
| 4597 | + return fasle; | ||
| 4598 | + } | ||
| 4599 | + //--跳转到已经购买的情况-- | ||
| 4600 | + if (e.data.data.pageData.length > 0) { | ||
| 4601 | + var odr = e.data.data.pageData[0]; | ||
| 4602 | + //还未支付 | ||
| 4603 | + if (odr.pt_status == 0 && (odr.order_status == 1 || odr.order_status == 0)) { | ||
| 4604 | + wx.showModal({ | ||
| 4605 | + title: "您已经购买了该商品待支付中", | ||
| 4606 | + success: function (a) { | ||
| 4607 | + if (a.confirm) { | ||
| 4608 | + wx.navigateTo({ | ||
| 4609 | + url: "/pages/user/order_detail/order_detail?order_id=" + odr.order_id, | ||
| 4610 | + }); | ||
| 4611 | + } | ||
| 4612 | + } | ||
| 4613 | + }); | ||
| 4614 | + } else if (odr.pt_status == 1 && odr.order_status == 1) { | ||
| 4615 | + | ||
| 4616 | + if (this.data.is_go_to_team_show) return false; | ||
| 4617 | + this.data.is_go_to_team_show = 1; | ||
| 4618 | + wx.showLoading(); | ||
| 4619 | + /*-- | ||
| 4620 | + wx.redirectTo({ | ||
| 4621 | + url: "/pages/team/team_success/team_success?ordersn=" + odr.order_sn, | ||
| 4622 | + });--*/ | ||
| 4623 | + | ||
| 4624 | + getApp().goto("/pages/team/team_success/team_success?ordersn=" + odr.order_sn); | ||
| 4625 | + | ||
| 4626 | + } else { | ||
| 4627 | + console.log(222,goods_id) | ||
| 4628 | + wx.navigateTo({ | ||
| 4629 | + url: "/pages/team/team_show/team_show?tg_id=" + id +"&goods_id="+goods_id, | ||
| 4630 | + }); | ||
| 4631 | + } | ||
| 4632 | + } | ||
| 4633 | + //--跳转到参团-- | ||
| 4634 | + else { | ||
| 4635 | + console.log(1111,th.data.goods_id) | ||
| 4636 | + wx.navigateTo({ | ||
| 4637 | + url: "/pages/team/team_show/team_show?tg_id=" + id+"&goods_id="+goods_id, | ||
| 4638 | + }); | ||
| 4639 | + } | ||
| 4640 | + } | ||
| 4641 | + }) | ||
| 4642 | + | ||
| 4643 | + }, | ||
| 4644 | + | ||
| 4645 | + //跳到团更多 | ||
| 4646 | + go_t_more: function () { | ||
| 4647 | + var team_id = this.data.prom_id; | ||
| 4648 | + wx.navigateTo({ | ||
| 4649 | + url: "/pages/team/team_more/team_more?team_id=" + team_id, | ||
| 4650 | + }); | ||
| 4651 | + }, | ||
| 4652 | + | ||
| 4653 | + //--点赞功能-- | ||
| 4654 | + click_zan: function (e) { | ||
| 4655 | + var com_id = e.currentTarget.dataset.com_id; | ||
| 4656 | + var item_id = e.currentTarget.dataset.item_id; | ||
| 4657 | + var app = getApp(), | ||
| 4658 | + th = this; | ||
| 4659 | + | ||
| 4660 | + if (app.globalData.userInfo == null || app.globalData.userInfo == undefined) { | ||
| 4661 | + app.confirmBox("您还未登录"); | ||
| 4662 | + return false; | ||
| 4663 | + } | ||
| 4664 | + | ||
| 4665 | + var iszan = th.data.comments[item_id].userZanNum; | ||
| 4666 | + if (this.data.iszaning) return false; | ||
| 4667 | + this.data.iszaning = 1; | ||
| 4668 | + | ||
| 4669 | + | ||
| 4670 | + app.request.post("/api/weshop/commentZan/save", { | ||
| 4671 | + data: { | ||
| 4672 | + store_id: o.stoid, | ||
| 4673 | + user_id: app.globalData.user_id, | ||
| 4674 | + goods_id: th.data.gid, | ||
| 4675 | + comment_id: com_id | ||
| 4676 | + }, | ||
| 4677 | + success: function (ee) { | ||
| 4678 | + | ||
| 4679 | + if (ee.data.code == "-1") { | ||
| 4680 | + app.my_warnning("不能给自己点赞", 0, th); | ||
| 4681 | + th.data.iszaning = 0; | ||
| 4682 | + return; | ||
| 4683 | + } | ||
| 4684 | + | ||
| 4685 | + if (ee.data.code == 0 && iszan != 1) { | ||
| 4686 | + var num = th.data.comments[item_id].zan_num; | ||
| 4687 | + num++; | ||
| 4688 | + var text = "comments[" + item_id + "].zan_num"; | ||
| 4689 | + var text1 = "comments[" + item_id + "].userZanNum"; | ||
| 4690 | + var _errObj = {}; | ||
| 4691 | + _errObj[text] = num; | ||
| 4692 | + _errObj[text1] = 1; | ||
| 4693 | + th.setData(_errObj); | ||
| 4694 | + | ||
| 4695 | + } else { | ||
| 4696 | + var num = th.data.comments[item_id].zan_num; | ||
| 4697 | + num--; | ||
| 4698 | + var text = "comments[" + item_id + "].zan_num"; | ||
| 4699 | + var text1 = "comments[" + item_id + "].userZanNum"; | ||
| 4700 | + var _errObj = {}; | ||
| 4701 | + _errObj[text] = num; | ||
| 4702 | + _errObj[text1] = 0; | ||
| 4703 | + th.setData(_errObj); | ||
| 4704 | + } | ||
| 4705 | + | ||
| 4706 | + setTimeout(function () { | ||
| 4707 | + th.data.iszaning = 0; | ||
| 4708 | + }, 500) | ||
| 4709 | + | ||
| 4710 | + } | ||
| 4711 | + }) | ||
| 4712 | + }, | ||
| 4713 | + | ||
| 4714 | + /*----券的开关---*/ | ||
| 4715 | + switchCoupon: async function (event) { | ||
| 4716 | + var coupon = event.currentTarget.dataset.coupon; | ||
| 4717 | + var app = getApp(); | ||
| 4718 | + var url = "/api/weshop/prom/coupon/pageCouponList"; | ||
| 4719 | + var quan_list = this.data.quan_list; | ||
| 4720 | + var th = this; | ||
| 4721 | + | ||
| 4722 | + //当开启,且列表为空的情况下要 | ||
| 4723 | + if (!quan_list && coupon == "1") { | ||
| 4724 | + wx.showLoading(); | ||
| 4725 | + await app.request.promiseGet(url, { | ||
| 4726 | + data: { | ||
| 4727 | + store_id: os.stoid, | ||
| 4728 | + type: 1, | ||
| 4729 | + pageSize: 100, | ||
| 4730 | + page: 1, | ||
| 4731 | + user_id: app.globalData.user_id, | ||
| 4732 | + is_share: 0 | ||
| 4733 | + } | ||
| 4734 | + }).then(res => { | ||
| 4735 | + wx.hideLoading(); | ||
| 4736 | + quan_list = res.data.data.pageData; | ||
| 4737 | + }) | ||
| 4738 | + | ||
| 4739 | + if (quan_list) { | ||
| 4740 | + for (var ind in quan_list) { | ||
| 4741 | + var ep = quan_list[ind]; | ||
| 4742 | + var start = ""; | ||
| 4743 | + var end = ""; | ||
| 4744 | + if(ep.endtype == 1){ | ||
| 4745 | + if(ep.starttype == 1) { | ||
| 4746 | + start = ut.formatTime(ut.gettimestamp()+3600*24*ep.startdays,"yyyy-MM-dd"); | ||
| 4747 | + }else{ | ||
| 4748 | + start = ut.formatTime(ut.gettimestamp(),"yyyy-MM-dd"); | ||
| 4749 | + } | ||
| 4750 | + if(ep.days > 0) { | ||
| 4751 | + end = ut.formatTime(ut.gettimestamp()+3600*24*ep.startdays+3600*24*ep.days,"yyyy-MM-dd"); | ||
| 4752 | + }else{ | ||
| 4753 | + end = "不限"; | ||
| 4754 | + } | ||
| 4755 | + }else { | ||
| 4756 | + if(ep.starttype == 1 ){ | ||
| 4757 | + start = ut.formatTime(ut.gettimestamp()+3600*24*ep.startdays,"yyyy-MM-dd"); | ||
| 4758 | + }else{ | ||
| 4759 | + if(ep.starttype == 0 && ep.use_start_time >0) { | ||
| 4760 | + start = ut.formatTime(ep.use_start_time ,"yyyy-MM-dd"); | ||
| 4761 | + }else{ | ||
| 4762 | + start = "不限" | ||
| 4763 | + } | ||
| 4764 | + } | ||
| 4765 | + | ||
| 4766 | + if(ep.use_end_time > 0 ) { | ||
| 4767 | + end = ut.formatTime(ep.use_end_time ,"yyyy-MM-dd"); | ||
| 4768 | + }else{ | ||
| 4769 | + end = "不限" | ||
| 4770 | + } | ||
| 4771 | + } | ||
| 4772 | + quan_list[ind].start = start; | ||
| 4773 | + quan_list[ind].end = end; | ||
| 4774 | + // var start = ut.formatTime(ep.use_start_time, "yyyy-MM-dd"); | ||
| 4775 | + // var end = ut.formatTime(ep.use_end_time, "yyyy-MM-dd"); | ||
| 4776 | + // start = start.replace("00:00:00", ""); | ||
| 4777 | + // end = end.replace("00:00:00", ""); | ||
| 4778 | + // quan_list[ind].start = start; | ||
| 4779 | + // quan_list[ind].end = end; | ||
| 4780 | + } | ||
| 4781 | + } | ||
| 4782 | + | ||
| 4783 | + th.setData({ | ||
| 4784 | + coupon: coupon, | ||
| 4785 | + quan_list: quan_list | ||
| 4786 | + }); | ||
| 4787 | + } else { | ||
| 4788 | + th.setData({ | ||
| 4789 | + coupon: coupon | ||
| 4790 | + }); | ||
| 4791 | + } | ||
| 4792 | + }, | ||
| 4793 | + | ||
| 4794 | + //--查看评价-- | ||
| 4795 | + look_pj: function () { | ||
| 4796 | + this.tabComment(); | ||
| 4797 | + this.doScrollTop(); | ||
| 4798 | + }, | ||
| 4799 | + | ||
| 4800 | + //-----领取券----- | ||
| 4801 | + get_quan: function (e) { | ||
| 4802 | + var cid = e.currentTarget.dataset.cid; | ||
| 4803 | + var index = e.currentTarget.dataset.ind; | ||
| 4804 | + var item = this.data.quan_list[index]; | ||
| 4805 | + | ||
| 4806 | + | ||
| 4807 | + //--先判断会员状态-- | ||
| 4808 | + var user_info = getApp().globalData.userInfo; | ||
| 4809 | + if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { | ||
| 4810 | + wx.navigateTo({ | ||
| 4811 | + url: '/pages/togoin/togoin', | ||
| 4812 | + }) | ||
| 4813 | + return false; | ||
| 4814 | + } | ||
| 4815 | + | ||
| 4816 | + | ||
| 4817 | + //如果券还在领取中,不能再点 | ||
| 4818 | + if (item.linging == 1) { | ||
| 4819 | + getApp().my_warnning('领取中..', 0, this); | ||
| 4820 | + return false; | ||
| 4821 | + } | ||
| 4822 | + | ||
| 4823 | + //如果领取的次数到了 | ||
| 4824 | + if (item.everyone_num > 0 && item.lqnum >= item.everyone_num) { | ||
| 4825 | + getApp().my_warnning('领取失败,您已领完该券', 0, this); | ||
| 4826 | + return false; | ||
| 4827 | + } | ||
| 4828 | + | ||
| 4829 | + var lq_num = item.lqnum; | ||
| 4830 | + | ||
| 4831 | + var pdata = { | ||
| 4832 | + 'uid': oo.user_id, | ||
| 4833 | + 'cid': cid, | ||
| 4834 | + 'store_id': os.stoid, | ||
| 4835 | + 'type': 5 | ||
| 4836 | + }; | ||
| 4837 | + | ||
| 4838 | + //-- 导购ID -- | ||
| 4839 | + if (getApp().globalData.guide_id) { | ||
| 4840 | + pdata.guide_id = getApp().globalData.guide_id; | ||
| 4841 | + } | ||
| 4842 | + | ||
| 4843 | + var app = getApp(), | ||
| 4844 | + th = this; | ||
| 4845 | + app.request.post("/api/weshop/couponList/saveCouponList", { | ||
| 4846 | + data: pdata, | ||
| 4847 | + success: function (res) { | ||
| 4848 | + if (res.data.code == 0) { | ||
| 4849 | + app.my_warnning("领取成功", 1, th); | ||
| 4850 | + lq_num++; | ||
| 4851 | + var text = "quan_list[" + index + "].lqnum"; | ||
| 4852 | + var text2 = "quan_list[" + index + "].linging"; | ||
| 4853 | + var obj = {}; | ||
| 4854 | + obj[text] = lq_num; | ||
| 4855 | + obj[text2] = 0; | ||
| 4856 | + th.setData(obj); | ||
| 4857 | + } else { | ||
| 4858 | + app.confirmBox(res.data.msg); | ||
| 4859 | + var text2 = "quan_list[" + index + "].linging"; | ||
| 4860 | + var obj = {}; | ||
| 4861 | + obj[text2] = 0; | ||
| 4862 | + th.setData(obj); | ||
| 4863 | + } | ||
| 4864 | + } | ||
| 4865 | + }) | ||
| 4866 | + }, | ||
| 4867 | + | ||
| 4868 | + | ||
| 4869 | + drawPoster(context, unit, img, vpath, type) { | ||
| 4870 | + // 1.灰色背景 | ||
| 4871 | + context.setFillStyle('#f2f1f6'); | ||
| 4872 | + context.rect(0, 0, 554 * unit, 899 * unit); | ||
| 4873 | + context.fill(); | ||
| 4874 | + | ||
| 4875 | + // 2.商城名称 | ||
| 4876 | + let shopName = this.data.sto_sele_name_1; | ||
| 4877 | + context.setTextAlign('center'); | ||
| 4878 | + context.setFontSize(26 * unit); | ||
| 4879 | + context.setFillStyle('black'); | ||
| 4880 | + context.fillText(shopName, 277 * unit, 60 * unit); | ||
| 4881 | + | ||
| 4882 | + // 3.推荐来源 | ||
| 4883 | + let fromText = `来自${getApp().globalData.userInfo.nickname}的推荐`; | ||
| 4884 | + context.setTextAlign('center'); | ||
| 4885 | + context.setFontSize(22 * unit); | ||
| 4886 | + context.setFillStyle('#96959a'); | ||
| 4887 | + context.fillText(fromText, 277 * unit, 105 * unit); | ||
| 4888 | + | ||
| 4889 | + // 4.海报背景 | ||
| 4890 | + context.setFillStyle('white'); | ||
| 4891 | + context.fillRect(37 * unit, 157 * unit, 480 * unit, 673 * unit); | ||
| 4892 | + | ||
| 4893 | + // 5.商品图片 | ||
| 4894 | + // 图片的x坐标 | ||
| 4895 | + let bg_x = 37 * unit | ||
| 4896 | + // 图片的y坐标 | ||
| 4897 | + let bg_y = 157 * unit | ||
| 4898 | + // 图片宽度 | ||
| 4899 | + let bg_w = 480 * unit | ||
| 4900 | + // 图片高度 | ||
| 4901 | + let bg_h = 474 * unit | ||
| 4902 | + // 图片圆角 | ||
| 4903 | + let bg_r = 4 | ||
| 4904 | + // 绘制海报背景图片圆角 | ||
| 4905 | + context.save() | ||
| 4906 | + context.beginPath() | ||
| 4907 | + context.arc(bg_x + bg_r, bg_y + bg_r, bg_r, Math.PI, Math.PI * 1.5) | ||
| 4908 | + context.arc(bg_x + bg_w - bg_r, bg_y + bg_r, bg_r, Math.PI * 1.5, Math.PI * 2) | ||
| 4909 | + context.arc(bg_x + bg_w, bg_y + bg_h, bg_r, 0, Math.PI * 0.5) | ||
| 4910 | + context.arc(bg_x, bg_y + bg_h, 0, Math.PI * 0.5, Math.PI) | ||
| 4911 | + context.clip() | ||
| 4912 | + context.drawImage(img, bg_x, bg_y, bg_w, bg_h); | ||
| 4913 | + context.restore(); | ||
| 4914 | + | ||
| 4915 | + // 6.强烈推荐 | ||
| 4916 | + let src = ''; | ||
| 4917 | + context.beginPath(); | ||
| 4918 | + if(type == 0) { // 普通 | ||
| 4919 | + src = '../../../images/share/q_tj.png'; | ||
| 4920 | + context.drawImage(src, 54 * unit, 648 * unit, 85 * unit, 30 * unit); | ||
| 4921 | + context.setFontSize(16 * unit) | ||
| 4922 | + context.setFillStyle("white") | ||
| 4923 | + context.setTextAlign('left'); | ||
| 4924 | + context.fillText('强烈推荐', 64 * unit, 668 * unit); | ||
| 4925 | + }; | ||
| 4926 | + if(type == 1) { // 秒杀 | ||
| 4927 | + src = '../../../images/share/miao_share.png'; | ||
| 4928 | + context.drawImage(src, 54 * unit, 648 * unit, 200 * unit, 36 * unit); | ||
| 4929 | + context.setTextAlign('left'); | ||
| 4930 | + }; | ||
| 4931 | + if(type == 2) { // 商家和会员团 | ||
| 4932 | + src = '../../../images/share/ct_num.png'; | ||
| 4933 | + context.drawImage(src, 54 * unit, 648 * unit, 120 * unit, 30 * unit); | ||
| 4934 | + context.setTextAlign('left'); | ||
| 4935 | + | ||
| 4936 | + let ct_num = self.data.prom_act.ct_num; | ||
| 4937 | + context.setFontSize(16 * unit) | ||
| 4938 | + context.font = 'normal'; | ||
| 4939 | + context.setFillStyle("red") | ||
| 4940 | + if (ct_num < 10) { | ||
| 4941 | + context.fillText(ct_num + "人拼团", 100 * unit, 670 * unit); | ||
| 4942 | + } else { | ||
| 4943 | + context.fillText(ct_num + "人拼团", 96 * unit, 670 * unit); | ||
| 4944 | + } | ||
| 4945 | + context.setFontSize(22 * unit) | ||
| 4946 | + context.fillText("已拼" + self.data.prom_act.buy_num + "份", 186 * unit, 672 * unit); | ||
| 4947 | + }; | ||
| 4948 | + if(type == 3) { // 阶梯团 | ||
| 4949 | + let list = self.data.prom_act.ct_rylist; | ||
| 4950 | + for (let i = 0; i < list.length; i++) { | ||
| 4951 | + let item = list[i]; | ||
| 4952 | + let wi = i * 90 * unit; | ||
| 4953 | + context.font = 'normal'; | ||
| 4954 | + context.setTextAlign('left'); | ||
| 4955 | + context.setFontSize(16 * unit) | ||
| 4956 | + context.setFillStyle("red") | ||
| 4957 | + context.fillText("¥", 50 * unit + wi, 680 * unit); | ||
| 4958 | + context.setFontSize(22 * unit) | ||
| 4959 | + let pri = parseFloat(item.price).toFixed(2); | ||
| 4960 | + context.fillText(pri, 66 * unit + wi, 680 * unit); | ||
| 4961 | + context.setFillStyle("gray") | ||
| 4962 | + context.fillText("满" + item.rynum + "人", 50 * unit + wi, 716 * unit); | ||
| 4963 | + } | ||
| 4964 | + }; | ||
| 4965 | + | ||
| 4966 | + // 7.商品价格 | ||
| 4967 | + if(type != 3) { | ||
| 4968 | + let price = this.data.data.shop_price; | ||
| 4969 | + if (this.data.card_field && this.data.data[this.data.card_field]) { | ||
| 4970 | + price = this.data.data[this.data.card_field]; | ||
| 4971 | + } | ||
| 4972 | + if (this.data.prom_act) price = this.data.prom_price; | ||
| 4973 | + price = parseFloat(price).toFixed(2); | ||
| 4974 | + context.setFontSize(32 * unit); | ||
| 4975 | + context.setFillStyle('#DE1117'); | ||
| 4976 | + context.fillText('¥' + price, 54 * unit, 735 * unit); | ||
| 4977 | + | ||
| 4978 | + | ||
| 4979 | + }; | ||
| 4980 | + | ||
| 4981 | + //---市场价划掉--- | ||
| 4982 | + context.setFillStyle("gray") | ||
| 4983 | + context.setFontSize(22 * unit) | ||
| 4984 | + var pri0 = "¥" + this.data.data.market_price.toFixed(2); | ||
| 4985 | + var wd2 = this.data.screenWidth - ut.measureText(pri0, 22 * unit) - 25; | ||
| 4986 | + context.fillText(pri0, 54 * unit, 770 * unit); | ||
| 4987 | + | ||
| 4988 | + context.setStrokeStyle('gray'); | ||
| 4989 | + context.setLineWidth(1 * unit); | ||
| 4990 | + context.moveTo(54 * unit, 763 * unit); | ||
| 4991 | + context.lineTo(ut.measureText(pri0, 22 * unit) + 50, 763 * unit); | ||
| 4992 | + context.stroke(); | ||
| 4993 | + | ||
| 4994 | + // 8.商品标题 | ||
| 4995 | + context.setFontSize(20 * unit); | ||
| 4996 | + context.setFillStyle('#898989'); | ||
| 4997 | + this.draw_Text(context, this.data.data.goods_name, 54 * unit, 800 * unit, 240 * unit, 280 * unit, unit, 1); | ||
| 4998 | + | ||
| 4999 | + // 9.小程序码 | ||
| 5000 | + context.drawImage(vpath, 375 * unit, 660 * unit, 120 * unit, 120 * unit); | ||
| 5001 | + context.setFontSize(16 * unit); | ||
| 5002 | + context.setFillStyle('#777'); | ||
| 5003 | + context.fillText('长按识别二维码', 378 * unit, 810 * unit); | ||
| 5004 | + | ||
| 5005 | + // 10.竖线 | ||
| 5006 | + context.beginPath(); | ||
| 5007 | + context.setFillStyle('#eee'); | ||
| 5008 | + context.rect(354 * unit, 670 * unit, 1 * unit, 130 * unit); | ||
| 5009 | + context.fill(); | ||
| 5010 | + }, | ||
| 5011 | + | ||
| 5012 | + | ||
| 5013 | + //--定义的保存图片方法,分享团--- | ||
| 5014 | + saveImageToPhotosAlbum: function () { | ||
| 5015 | + //--先判断会员状态-- | ||
| 5016 | + var user_info = getApp().globalData.userInfo; | ||
| 5017 | + if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { | ||
| 5018 | + //getApp().my_warnning("请先登录",0,this); | ||
| 5019 | + wx.navigateTo({url: '/pages/togoin/togoin',}) | ||
| 5020 | + return false; | ||
| 5021 | + } | ||
| 5022 | + | ||
| 5023 | + if (this.data.share_hidden) { | ||
| 5024 | + this.setData({share_hidden: false,}); | ||
| 5025 | + }; | ||
| 5026 | + | ||
| 5027 | + //类型 0普通商品 1秒杀商品 2商家和会员团 3阶梯团 4阶梯团 | ||
| 5028 | + var type = this.data.prom_type; | ||
| 5029 | + if (type == 2) type = -1; | ||
| 5030 | + if (type == 6) type = 2; // 6拼团 2团购 | ||
| 5031 | + | ||
| 5032 | + | ||
| 5033 | + if (this.data.prom_act && this.data.prom_act.kttype == 3) type = 3; | ||
| 5034 | + | ||
| 5035 | + wx.showLoading({title: '生成中...',}) | ||
| 5036 | + var that = this, th = that; | ||
| 5037 | + //设置画板显示,才能开始绘图 | ||
| 5038 | + that.setData({ | ||
| 5039 | + canvasHidden: false | ||
| 5040 | + }) | ||
| 5041 | + | ||
| 5042 | + var app = getApp(); | ||
| 5043 | + var unit = that.data.screenWidth / 750 * 1.35; //基础单位, | ||
| 5044 | + var path2 = that.data.data.original_img; | ||
| 5045 | + var scene = th.data.gid + ""; | ||
| 5046 | + scene += "." + th.data.sele_g.prom_type + "." + th.data.sele_g.prom_id; | ||
| 5047 | + | ||
| 5048 | + var user_id = getApp().globalData.user_id ? getApp().globalData.user_id : 0; | ||
| 5049 | + if (user_id > 0) { | ||
| 5050 | + scene += "_" + user_id; | ||
| 5051 | + } | ||
| 5052 | + //-- 如果不是会员分享过来的要分享给别人 -- | ||
| 5053 | + if (getApp().globalData.room_id && th.data.data.goods_id == getApp().globalData.room_goods_id && !getApp().globalData.room_user_share) { | ||
| 5054 | + //固定房间是第3个字符 | ||
| 5055 | + if (!user_id) scene += "_0"; | ||
| 5056 | + scene += "_" + getApp().globalData.room_id; | ||
| 5057 | + } | ||
| 5058 | + ///二微码 | ||
| 5059 | + var path3 = os.url + "/api/wx/open/app/user/getWeAppEwm/" + | ||
| 5060 | + os.stoid + "?sceneValue=" + scene + "&pageValue=pages/goods/goodsInfo/goodsInfo"; | ||
| 5061 | + | ||
| 5062 | + console.log(path3); | ||
| 5063 | + | ||
| 5064 | + | ||
| 5065 | + // 读取文件成功则OK-- | ||
| 5066 | + wx.getImageInfo({ | ||
| 5067 | + src: path3, | ||
| 5068 | + success: function (res) { | ||
| 5069 | + // 回调写法 | ||
| 5070 | + th.get_head_temp(th.get_goods_temp, function () { | ||
| 5071 | + var vpath = res.path; | ||
| 5072 | + var context = wx.createCanvasContext('share'); | ||
| 5073 | + // 先画背景 | ||
| 5074 | + var pg_path = "../../../images/share/share_bg.png"; | ||
| 5075 | + | ||
| 5076 | + | ||
| 5077 | + //-- 如果有自定义海报的时候,判断背景的图片 -- | ||
| 5078 | + if (th.data.share_b_img) { | ||
| 5079 | + pg_path = th.data.share_b_img; | ||
| 5080 | + } | ||
| 5081 | + // context.drawImage(pg_path, 0, 0, 554 * unit, 899 * unit); | ||
| 5082 | + | ||
| 5083 | + | ||
| 5084 | + if (type == 0 || type == 1 || type == 2 || type == 3) { // 如果是普通商品,绘制新海报 | ||
| 5085 | + th.drawPoster(context, unit, th.data.share_goods_img, vpath, type); | ||
| 5086 | + } else { | ||
| 5087 | + context.drawImage(pg_path, 0, 0, 554 * unit, 899 * unit); | ||
| 5088 | + }; | ||
| 5089 | + | ||
| 5090 | + // th.drawPoster(context, unit, th.data.share_goods_img, vpath); | ||
| 5091 | + | ||
| 5092 | + | ||
| 5093 | + //-- 是自定义海报的情况下 -- | ||
| 5094 | + if (type != 0 && type != 1 && type != 2 && type != 3) { | ||
| 5095 | + | ||
| 5096 | + if (th.data.poster && parseInt(th.data.poster.style) == 2) { | ||
| 5097 | + //在线上分享人的情况下 | ||
| 5098 | + if (parseInt(th.data.poster.show_headpic)) { | ||
| 5099 | + //获取坐标 | ||
| 5100 | + var x = parseFloat(th.data.poster.head_x) * 2; | ||
| 5101 | + var y = parseFloat(th.data.poster.head_y) * 2; | ||
| 5102 | + var x1 = (x + 90) * unit; | ||
| 5103 | + var y1 = (y + 50) * unit; | ||
| 5104 | + //--昵称--- | ||
| 5105 | + context.setFontSize(24 * unit) | ||
| 5106 | + context.setFillStyle("black") | ||
| 5107 | + context.fillText(app.globalData.userInfo.nickname, x1, y1); | ||
| 5108 | + var width = 24 * app.globalData.userInfo.nickname.length * unit + 4 * unit; | ||
| 5109 | + //强烈推荐 改许程 | ||
| 5110 | + var tj_path = "../../../images/share/q_tj.png"; | ||
| 5111 | + context.drawImage(tj_path, x1 + width, y1 - 22 * unit, 85 * unit, 30 * unit); | ||
| 5112 | + context.setFontSize(16 * unit); | ||
| 5113 | + context.setLineJoin('round'); //交点设置成圆角 | ||
| 5114 | + context.setFillStyle("white"); | ||
| 5115 | + context.fillText('强烈推荐', x1 + width + 8 * unit, y1 - 1 * unit); | ||
| 5116 | + | ||
| 5117 | + //context.setFillStyle("black") | ||
| 5118 | + //context.setFontSize(24 * unit) | ||
| 5119 | + //context.fillText(getApp().globalData.config.store_name, 40 * unit, 130 * unit); | ||
| 5120 | + } | ||
| 5121 | + } else { | ||
| 5122 | + //--昵称--- | ||
| 5123 | + context.setFontSize(24 * unit); | ||
| 5124 | + context.setFillStyle("black"); | ||
| 5125 | + context.fillText(app.globalData.userInfo.nickname, 152 * unit, 76 * unit); | ||
| 5126 | + var width = 24 * app.globalData.userInfo.nickname.length * unit + 2 * unit; | ||
| 5127 | + //强烈推荐 改许程 | ||
| 5128 | + var tj_path = "../../../images/share/q_tj.png"; | ||
| 5129 | + context.drawImage(tj_path, 152 * unit + width, 54 * unit, 85 * unit, 30 * unit); | ||
| 5130 | + context.setFontSize(16 * unit); | ||
| 5131 | + context.setLineJoin('round'); //交点设置成圆角 | ||
| 5132 | + context.setFillStyle("white"); | ||
| 5133 | + context.fillText('强烈推荐', 149 * unit + width + 15 * unit, 75 * unit); | ||
| 5134 | + } | ||
| 5135 | + | ||
| 5136 | + } | ||
| 5137 | + ; | ||
| 5138 | + | ||
| 5139 | + | ||
| 5140 | + var share_title = th.data.data.goods_name; | ||
| 5141 | + if (th.data.prom_type == 1 || th.data.prom_type == 2 || th.data.prom_type == 6 || th.data.prom_type == 4) { | ||
| 5142 | + share_title = th.data.prom_act.share_title; | ||
| 5143 | + if (!share_title) share_title = th.data.prom_act.title; | ||
| 5144 | + if (th.data.prom_type == 4) share_title = th.data.prom_act.name; | ||
| 5145 | + } | ||
| 5146 | + | ||
| 5147 | + //---产品名称--- | ||
| 5148 | + //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 | ||
| 5149 | + if (type != 4 && type != 0 && type != 1 && type != 2 && type != 3) { | ||
| 5150 | + context.setFillStyle("black"); | ||
| 5151 | + context.setFontSize(21.3 * unit) | ||
| 5152 | + th.draw_Text(context, share_title, | ||
| 5153 | + 38 * unit, 180 * unit, 200 * unit, 279 * unit, unit); | ||
| 5154 | + | ||
| 5155 | + //------产品的价格------- | ||
| 5156 | + context.setFontSize(23 * unit) | ||
| 5157 | + context.setFillStyle("red") | ||
| 5158 | + | ||
| 5159 | + var pri0 = th.data.data.shop_price; | ||
| 5160 | + if (th.data.card_field && th.data.data[th.data.card_field]) { | ||
| 5161 | + pri0 = th.data.data[th.data.card_field]; | ||
| 5162 | + } | ||
| 5163 | + | ||
| 5164 | + if (th.data.prom_act) | ||
| 5165 | + pri0 = th.data.prom_price; | ||
| 5166 | + pri0 = parseFloat(pri0).toFixed(2); | ||
| 5167 | + var wd1 = th.data.screenWidth - ut.measureText(pri0, 31 * unit) - 25; | ||
| 5168 | + context.fillText("¥", wd1 - 15, 185 * unit); | ||
| 5169 | + context.setFontSize(31 * unit) | ||
| 5170 | + context.fillText(pri0, wd1, 185 * unit); | ||
| 5171 | + | ||
| 5172 | + //---市场价划掉--- | ||
| 5173 | + context.setFillStyle("gray") | ||
| 5174 | + context.setFontSize(22 * unit) | ||
| 5175 | + pri0 = "¥" + th.data.data.market_price.toFixed(2); | ||
| 5176 | + var wd2 = th.data.screenWidth - ut.measureText(pri0, 22 * unit) - 25; | ||
| 5177 | + context.fillText(pri0, wd2, 213 * unit); | ||
| 5178 | + | ||
| 5179 | + context.setStrokeStyle('gray'); | ||
| 5180 | + context.setLineWidth(1 * unit); | ||
| 5181 | + context.moveTo(wd2 - 5, 206 * unit); | ||
| 5182 | + context.lineTo(wd2 + ut.measureText(pri0, 22 * unit) + 5, 206 * unit); | ||
| 5183 | + context.stroke(); | ||
| 5184 | + | ||
| 5185 | + } else if (type == 4 && type != 0 && type != 1 && type != 2 && type != 3) { | ||
| 5186 | + context.setFillStyle("black"); | ||
| 5187 | + context.setFontSize(21.3 * unit) | ||
| 5188 | + th.draw_Text(context, share_title, | ||
| 5189 | + 38 * unit, 170 * unit, 20 * unit, 300 * unit, unit); | ||
| 5190 | + //------ 产品的价格 ----- | ||
| 5191 | + var pri0 = th.data.prom_act.addmoney; | ||
| 5192 | + var integral = th.data.prom_act.integral; | ||
| 5193 | + var text = ""; | ||
| 5194 | + if (integral) { | ||
| 5195 | + text = integral + "积分"; | ||
| 5196 | + } | ||
| 5197 | + if (pri0 && integral) { | ||
| 5198 | + text += "+"; | ||
| 5199 | + } | ||
| 5200 | + if (pri0) { | ||
| 5201 | + text += "¥" + pri0; | ||
| 5202 | + } | ||
| 5203 | + | ||
| 5204 | + if (!pri0 && !integral) { | ||
| 5205 | + text = "0积分"; | ||
| 5206 | + } | ||
| 5207 | + context.setFillStyle("red"); | ||
| 5208 | + context.fillText(text, 38 * unit, 235 * unit); | ||
| 5209 | + | ||
| 5210 | + } | ||
| 5211 | + | ||
| 5212 | + //---中间大图--- | ||
| 5213 | + if (type != 0 && type != 1 && type != 2 && type != 3) { | ||
| 5214 | + context.drawImage(th.data.share_goods_img, 70 * unit, 250 * unit, 408 * unit, 408 * unit); | ||
| 5215 | + } | ||
| 5216 | + ; | ||
| 5217 | + | ||
| 5218 | + | ||
| 5219 | + //-------大图后面就不一样了----------- | ||
| 5220 | + switch (type) { | ||
| 5221 | + case 0: | ||
| 5222 | + break;//普通商品的展示 | ||
| 5223 | + case 4: | ||
| 5224 | + //中间的几个字 | ||
| 5225 | + if (th.data.poster && parseInt(th.data.poster.style) == 2) { | ||
| 5226 | + if (parseInt(th.data.poster.show_quality)) { | ||
| 5227 | + var g_path = "../../../images/share/s_gou.png"; | ||
| 5228 | + context.drawImage(g_path, 56 * unit, 670 * unit, 22 * unit, 22 * unit); | ||
| 5229 | + context.setFillStyle("red") | ||
| 5230 | + context.setFontSize(18 * unit) | ||
| 5231 | + context.fillText("正品保证", 84 * unit, 690 * unit); | ||
| 5232 | + | ||
| 5233 | + context.drawImage(g_path, 218 * unit, 670 * unit, 22 * unit, 22 * unit); | ||
| 5234 | + context.setFillStyle("red") | ||
| 5235 | + context.setFontSize(18 * unit) | ||
| 5236 | + context.fillText("纯实体店", 246 * unit, 690 * unit); | ||
| 5237 | + | ||
| 5238 | + context.drawImage(g_path, 388 * unit, 670 * unit, 22 * unit, 22 * unit); | ||
| 5239 | + context.setFillStyle("red") | ||
| 5240 | + context.setFontSize(18 * unit) | ||
| 5241 | + context.fillText("官方验证", 420 * unit, 690 * unit); | ||
| 5242 | + } | ||
| 5243 | + | ||
| 5244 | + } else { | ||
| 5245 | + var g_path = "../../../images/share/s_gou.png"; | ||
| 5246 | + context.drawImage(g_path, 56 * unit, 670 * unit, 22 * unit, 22 * unit); | ||
| 5247 | + context.setFillStyle("red") | ||
| 5248 | + context.setFontSize(18 * unit) | ||
| 5249 | + context.fillText("正品保证", 84 * unit, 690 * unit); | ||
| 5250 | + | ||
| 5251 | + context.drawImage(g_path, 218 * unit, 670 * unit, 22 * unit, 22 * unit); | ||
| 5252 | + context.setFillStyle("red") | ||
| 5253 | + context.setFontSize(18 * unit) | ||
| 5254 | + context.fillText("纯实体店", 246 * unit, 690 * unit); | ||
| 5255 | + | ||
| 5256 | + context.drawImage(g_path, 388 * unit, 670 * unit, 22 * unit, 22 * unit); | ||
| 5257 | + context.setFillStyle("red") | ||
| 5258 | + context.setFontSize(18 * unit) | ||
| 5259 | + context.fillText("官方验证", 420 * unit, 690 * unit); | ||
| 5260 | + } | ||
| 5261 | + | ||
| 5262 | + | ||
| 5263 | + //---画线--- | ||
| 5264 | + context.setLineWidth(1 * unit) | ||
| 5265 | + context.moveTo(32 * unit, 710 * unit) | ||
| 5266 | + context.lineTo(520 * unit, 710 * unit) | ||
| 5267 | + context.stroke(); | ||
| 5268 | + | ||
| 5269 | + //---文字--- | ||
| 5270 | + context.setFillStyle("black") | ||
| 5271 | + context.setFontSize(22 * unit) | ||
| 5272 | + | ||
| 5273 | + if (type == 0 || type == -1) { | ||
| 5274 | + // 原来start ---> | ||
| 5275 | + context.setFontSize(24 * unit) | ||
| 5276 | + context.fillText(th.data.sto_sele_name_1, 40 * unit, 766 * unit); | ||
| 5277 | + | ||
| 5278 | + context.setFontSize(22 * unit) | ||
| 5279 | + context.fillText("优惠乐翻天,精彩就在你身边", 40 * unit, 806 * unit); | ||
| 5280 | + context.fillText("长按识别二维码,立即开始抢购", 40 * unit, 846 * unit); | ||
| 5281 | + | ||
| 5282 | + } else { | ||
| 5283 | + context.setFontSize(24 * unit) | ||
| 5284 | + context.fillText(th.data.sto_sele_name_1, 40 * unit, 766 * unit); | ||
| 5285 | + context.setFontSize(22 * unit) | ||
| 5286 | + context.fillText("长按识别二维码", 40 * unit, 806 * unit); | ||
| 5287 | + context.fillText("立即开始兑换", 40 * unit, 846 * unit); | ||
| 5288 | + | ||
| 5289 | + } | ||
| 5290 | + | ||
| 5291 | + //---二维吗图--- | ||
| 5292 | + //-- 自定义海报 -- | ||
| 5293 | + if (th.data.poster) { | ||
| 5294 | + var erm_x = parseFloat(th.data.poster.ewm_x) * 2; | ||
| 5295 | + var erm_y = parseFloat(th.data.poster.ewm_y) * 2; | ||
| 5296 | + context.drawImage(vpath, erm_x * unit, erm_y * unit, 136 * unit, 136 * unit); | ||
| 5297 | + } else { | ||
| 5298 | + //---二维吗图--- | ||
| 5299 | + context.drawImage(vpath, 390 * unit, 726 * unit, 136 * unit, 136 * unit); | ||
| 5300 | + } | ||
| 5301 | + ; | ||
| 5302 | + | ||
| 5303 | + break; | ||
| 5304 | + case -12: //秒杀商品的展示 | ||
| 5305 | + //---画线--- | ||
| 5306 | + context.setLineWidth(1 * unit) | ||
| 5307 | + context.moveTo(32 * unit, 670 * unit) | ||
| 5308 | + context.lineTo(520 * unit, 670 * unit) | ||
| 5309 | + context.stroke(); | ||
| 5310 | + | ||
| 5311 | + //画秒杀的图片 | ||
| 5312 | + var miaos_path = '../../../images/share/miao_share.png'; | ||
| 5313 | + context.drawImage(miaos_path, 43 * unit, 700 * unit, 222 * unit, 40 * unit); | ||
| 5314 | + | ||
| 5315 | + context.setFillStyle("black") | ||
| 5316 | + context.setFontSize(24 * unit) | ||
| 5317 | + context.fillText(th.data.sto_sele_name_1, 40 * unit, 786 * unit); | ||
| 5318 | + //---文字--- | ||
| 5319 | + context.setFontSize(22 * unit) | ||
| 5320 | + context.setFillStyle("black") | ||
| 5321 | + context.fillText("特惠好物,限时秒杀", 40 * unit, 826 * unit); | ||
| 5322 | + context.fillText("长按识别二维码,立即开始抢购", 40 * unit, 866 * unit); | ||
| 5323 | + | ||
| 5324 | + | ||
| 5325 | + //---二维吗图--- | ||
| 5326 | + //-- 自定义海报 -- | ||
| 5327 | + if (th.data.poster) { | ||
| 5328 | + var erm_x = parseFloat(th.data.poster.ewm_x) * 2; | ||
| 5329 | + var erm_y = parseFloat(th.data.poster.ewm_y) * 2; | ||
| 5330 | + context.drawImage(vpath, erm_x * unit, erm_y * unit, 135 * unit, 135 * unit); | ||
| 5331 | + } else { | ||
| 5332 | + //---二维吗图--- | ||
| 5333 | + context.drawImage(vpath, 390 * unit, 726 * unit, 135 * unit, 135 * unit); | ||
| 5334 | + } | ||
| 5335 | + break; | ||
| 5336 | + | ||
| 5337 | + case -2: //会员团和商家团的展示 | ||
| 5338 | + //---画线--- | ||
| 5339 | + context.setLineWidth(1 * unit) | ||
| 5340 | + context.moveTo(32 * unit, 670 * unit) | ||
| 5341 | + context.lineTo(520 * unit, 670 * unit) | ||
| 5342 | + context.stroke(); | ||
| 5343 | + //---文字--- | ||
| 5344 | + context.setFillStyle("black") | ||
| 5345 | + context.setFontSize(24 * unit) | ||
| 5346 | + context.fillText(th.data.sto_sele_name_1, 40 * unit, 720 * unit); | ||
| 5347 | + | ||
| 5348 | + //绘制成团图片 | ||
| 5349 | + var ct_img = "../../../images/share/ct_num.png"; | ||
| 5350 | + context.drawImage(ct_img, 40 * unit, 740 * unit, 120 * unit, 30 * unit); | ||
| 5351 | + var ct_num = th.data.prom_act.ct_num; | ||
| 5352 | + context.setFontSize(14 * unit) | ||
| 5353 | + context.font = 'normal'; | ||
| 5354 | + context.setFillStyle("red") | ||
| 5355 | + if (ct_num < 10) { | ||
| 5356 | + context.fillText(ct_num + "人拼团", 92 * unit, 760 * unit); | ||
| 5357 | + } else { | ||
| 5358 | + context.fillText(ct_num + "人拼团", 86 * unit, 760 * unit); | ||
| 5359 | + } | ||
| 5360 | + context.setFontSize(22 * unit) | ||
| 5361 | + context.fillText("已拼" + th.data.prom_act.buy_num + "份", 166 * unit, 763 * unit); | ||
| 5362 | + | ||
| 5363 | + context.setFillStyle("gray") | ||
| 5364 | + context.fillText("快来和我一起拼团吧!", 40 * unit, 806 * unit); | ||
| 5365 | + context.setFillStyle("black") | ||
| 5366 | + context.font = 'normal bold 18px sans-serif'; | ||
| 5367 | + context.setFontSize(21.3 * unit) | ||
| 5368 | + context.fillText("长按识别二维码,立即参团", 40 * unit, 836 * unit); | ||
| 5369 | + | ||
| 5370 | + | ||
| 5371 | + //---二维吗图--- | ||
| 5372 | + //-- 自定义海报 -- | ||
| 5373 | + if (th.data.poster) { | ||
| 5374 | + var erm_x = parseFloat(th.data.poster.ewm_x) * 2; | ||
| 5375 | + var erm_y = parseFloat(th.data.poster.ewm_y) * 2; | ||
| 5376 | + context.drawImage(vpath, erm_x * unit, erm_y * unit, 136 * unit, 136 * unit); | ||
| 5377 | + } else { | ||
| 5378 | + //---二维吗图--- | ||
| 5379 | + context.drawImage(vpath, 390 * unit, 726 * unit, 136 * unit, 136 * unit); | ||
| 5380 | + } | ||
| 5381 | + break | ||
| 5382 | + case -3: //阶梯团的展示 | ||
| 5383 | + //---画线--- | ||
| 5384 | + context.setLineWidth(1 * unit) | ||
| 5385 | + context.moveTo(32 * unit, 670 * unit) | ||
| 5386 | + context.lineTo(520 * unit, 670 * unit) | ||
| 5387 | + context.stroke(); | ||
| 5388 | + //---文字--- | ||
| 5389 | + context.setFillStyle("black") | ||
| 5390 | + context.setFontSize(24 * unit) | ||
| 5391 | + context.fillText(th.data.sto_sele_name_1, 40 * unit, 720 * unit); | ||
| 5392 | + | ||
| 5393 | + //---绘制中间阶梯的价格--- | ||
| 5394 | + var list = th.data.prom_act.ct_rylist; | ||
| 5395 | + for (var i = 0; i < list.length; i++) { | ||
| 5396 | + var item = list[i]; | ||
| 5397 | + var wi = i * 90 * unit; | ||
| 5398 | + context.font = 'normal'; | ||
| 5399 | + context.setFontSize(16 * unit) | ||
| 5400 | + context.setFillStyle("red") | ||
| 5401 | + context.fillText("¥", 40 * unit + wi, 756 * unit); | ||
| 5402 | + context.setFontSize(22 * unit) | ||
| 5403 | + var pri = parseFloat(item.price).toFixed(2); | ||
| 5404 | + context.fillText(pri, 56 * unit + wi, 756 * unit); | ||
| 5405 | + context.setFillStyle("gray") | ||
| 5406 | + context.fillText("满" + item.rynum + "人", 40 * unit + wi, 786 * unit); | ||
| 5407 | + } | ||
| 5408 | + //----------------下面部分---------------- | ||
| 5409 | + // context.setFillStyle("gray") | ||
| 5410 | + // context.fillText("快来和我一起拼团吧!", 40 * unit, 830 * unit); | ||
| 5411 | + // context.setFillStyle("black") | ||
| 5412 | + // context.font = 'normal bold 18px sans-serif'; | ||
| 5413 | + // context.setFontSize(22 * unit) | ||
| 5414 | + // context.fillText("长按识别二维码,立即参团", 40 * unit, 860 * unit); | ||
| 5415 | + //context.setFillStyle("gray") | ||
| 5416 | + context.setFillStyle("black") | ||
| 5417 | + context.fillText("快来和我一起拼团吧!", 40 * unit, 820 * unit); | ||
| 5418 | + //context.font = 'normal bold 18px sans-serif'; | ||
| 5419 | + context.setFontSize(21 * unit) | ||
| 5420 | + context.fillText("长按识别二维码,立即参团", 40 * unit, 850 * unit); | ||
| 5421 | + | ||
| 5422 | + | ||
| 5423 | + //-- 自定义海报 -- | ||
| 5424 | + if (th.data.poster) { | ||
| 5425 | + var erm_x = parseFloat(th.data.poster.ewm_x) * 2; | ||
| 5426 | + var erm_y = parseFloat(th.data.poster.ewm_y) * 2; | ||
| 5427 | + context.drawImage(vpath, erm_x * unit, erm_y * unit, 136 * unit, 136 * unit); | ||
| 5428 | + } else { | ||
| 5429 | + //---二维吗图--- | ||
| 5430 | + context.drawImage(vpath, 390 * unit, 726 * unit, 136 * unit, 136 * unit); | ||
| 5431 | + } | ||
| 5432 | + break | ||
| 5433 | + | ||
| 5434 | + | ||
| 5435 | + case -1: //秒杀商品的展示 | ||
| 5436 | + //---画线--- | ||
| 5437 | + context.setLineWidth(1 * unit) | ||
| 5438 | + context.moveTo(32 * unit, 670 * unit) | ||
| 5439 | + context.lineTo(520 * unit, 670 * unit) | ||
| 5440 | + context.stroke(); | ||
| 5441 | + | ||
| 5442 | + | ||
| 5443 | + context.setFillStyle("black") | ||
| 5444 | + context.setFontSize(24 * unit) | ||
| 5445 | + context.fillText(th.data.sto_sele_name_1, 40 * unit, 744 * unit); | ||
| 5446 | + //---文字--- | ||
| 5447 | + context.setFontSize(22 * unit) | ||
| 5448 | + context.setFillStyle("black") | ||
| 5449 | + context.fillText("长按识别二维码", 40 * unit, 800 * unit); | ||
| 5450 | + context.fillText("立即开始抢购", 40 * unit, 846 * unit); | ||
| 5451 | + | ||
| 5452 | + | ||
| 5453 | + //---二维吗图--- | ||
| 5454 | + //-- 自定义海报 -- | ||
| 5455 | + if (th.data.poster) { | ||
| 5456 | + var erm_x = parseFloat(th.data.poster.ewm_x) * 2; | ||
| 5457 | + var erm_y = parseFloat(th.data.poster.ewm_y) * 2; | ||
| 5458 | + context.drawImage(vpath, erm_x * unit, erm_y * unit, 135 * unit, 135 * unit); | ||
| 5459 | + } else { | ||
| 5460 | + //---二维吗图--- | ||
| 5461 | + context.drawImage(vpath, 390 * unit, 726 * unit, 135 * unit, 135 * unit); | ||
| 5462 | + } | ||
| 5463 | + break; | ||
| 5464 | + | ||
| 5465 | + | ||
| 5466 | + } | ||
| 5467 | + | ||
| 5468 | + | ||
| 5469 | + //--- 如果是自定义海报的时候 --- | ||
| 5470 | + if (type != 0 && type != 1 && type != 2 && type != 3) { | ||
| 5471 | + | ||
| 5472 | + if (th.data.poster && parseInt(th.data.poster.style) == 2) { | ||
| 5473 | + | ||
| 5474 | + //如果显示会员信息的话 | ||
| 5475 | + if (parseInt(th.data.poster.show_headpic)) { | ||
| 5476 | + //获取坐标 | ||
| 5477 | + var x = parseFloat(th.data.poster.head_x) * 2; | ||
| 5478 | + var y = parseFloat(th.data.poster.head_y) * 2; | ||
| 5479 | + //---绘制圆形要放在最后---- | ||
| 5480 | + context.save(); | ||
| 5481 | + context.beginPath(); | ||
| 5482 | + var h_x = x * unit; | ||
| 5483 | + var h_y = y * unit; | ||
| 5484 | + var h_r = 40 * unit; | ||
| 5485 | + var cx = h_x + h_r; | ||
| 5486 | + var cy = h_y + h_r; | ||
| 5487 | + context.arc(cx, cy, h_r, 0, Math.PI * 2, false); | ||
| 5488 | + context.closePath(); | ||
| 5489 | + context.fill(); | ||
| 5490 | + context.clip(); | ||
| 5491 | + context.drawImage(th.data.share_head, h_x, h_y, h_r * 2, h_r * 2); | ||
| 5492 | + context.restore(); | ||
| 5493 | + } | ||
| 5494 | + | ||
| 5495 | + } else { | ||
| 5496 | + //---绘制圆形要放在最后---- | ||
| 5497 | + context.save(); | ||
| 5498 | + context.beginPath(); | ||
| 5499 | + var h_x = 60 * unit; | ||
| 5500 | + var h_y = 24 * unit; | ||
| 5501 | + var h_r = 40 * unit; | ||
| 5502 | + var cx = h_x + h_r; | ||
| 5503 | + var cy = h_y + h_r; | ||
| 5504 | + context.arc(cx, cy, h_r, 0, Math.PI * 2, false); | ||
| 5505 | + context.closePath(); | ||
| 5506 | + context.fill(); | ||
| 5507 | + context.clip(); | ||
| 5508 | + context.drawImage(th.data.share_head, h_x, h_y, h_r * 2, h_r * 2); | ||
| 5509 | + context.restore(); | ||
| 5510 | + } | ||
| 5511 | + | ||
| 5512 | + } | ||
| 5513 | + ; | ||
| 5514 | + | ||
| 5515 | + | ||
| 5516 | + //把画板内容绘制成图片,并回调 画板图片路径 | ||
| 5517 | + context.draw(false, function () { | ||
| 5518 | + setTimeout(function () { | ||
| 5519 | + wx.canvasToTempFilePath({ | ||
| 5520 | + x: 0, | ||
| 5521 | + y: 0, | ||
| 5522 | + width: 750, | ||
| 5523 | + height: 1217, | ||
| 5524 | + destWidth: 1.2 * 750 * 750 / that.data.screenWidth, | ||
| 5525 | + destHeight: 1.2 * 1217 * 750 / that.data.screenWidth, | ||
| 5526 | + canvasId: 'share', | ||
| 5527 | + success: function (res) { | ||
| 5528 | + | ||
| 5529 | + that.setData({ | ||
| 5530 | + shareImgPath: res.tempFilePath, | ||
| 5531 | + canvasHidden: true | ||
| 5532 | + }) | ||
| 5533 | + | ||
| 5534 | + if (!res.tempFilePath) { | ||
| 5535 | + wx.showModal({ | ||
| 5536 | + title: '提示', | ||
| 5537 | + content: '图片绘制中,请稍后重试', | ||
| 5538 | + showCancel: false | ||
| 5539 | + }) | ||
| 5540 | + return false; | ||
| 5541 | + } | ||
| 5542 | + | ||
| 5543 | + // wx.previewImage({ | ||
| 5544 | + // //将图片预览出来 | ||
| 5545 | + // urls: [that.data.shareImgPath] | ||
| 5546 | + // }); | ||
| 5547 | + that.setData({ | ||
| 5548 | + showPoster: true, | ||
| 5549 | + }); | ||
| 5550 | + wx.hideLoading(); | ||
| 5551 | + } | ||
| 5552 | + }) | ||
| 5553 | + }, 500) | ||
| 5554 | + | ||
| 5555 | + }); | ||
| 5556 | + }); | ||
| 5557 | + }, | ||
| 5558 | + fail: function (res) { | ||
| 5559 | + console.log(res); | ||
| 5560 | + wx.hideLoading(); | ||
| 5561 | + | ||
| 5562 | + } | ||
| 5563 | + }); | ||
| 5564 | + }, | ||
| 5565 | + | ||
| 5566 | + | ||
| 5567 | + //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 | ||
| 5568 | + draw_Text: function (ctx, str, leftWidth, initHeight, titleHeight, canvasWidth, unit, lineNum) { | ||
| 5569 | + var lineWidth = 0; | ||
| 5570 | + var lastSubStrIndex = 0; //每次开始截取的字符串的索引 | ||
| 5571 | + var han = 0; | ||
| 5572 | + for (let i = 0; i < str.length; i++) { | ||
| 5573 | + if(lineNum) { | ||
| 5574 | + if(han == lineNum) return; | ||
| 5575 | + }; | ||
| 5576 | + if (han == 2) return; | ||
| 5577 | + //lineWidth += ctx.measureText(str[i]).width; | ||
| 5578 | + lineWidth += ut.measureText(str[i], 21.3 * unit); | ||
| 5579 | + if (lineWidth > canvasWidth) { | ||
| 5580 | + han++; | ||
| 5581 | + | ||
| 5582 | + if (han == 2 || han == lineNum) | ||
| 5583 | + ctx.fillText(str.substring(lastSubStrIndex, i) + '...', leftWidth, initHeight); //绘制截取部分 | ||
| 5584 | + else | ||
| 5585 | + ctx.fillText(str.substring(lastSubStrIndex, i), leftWidth, initHeight); | ||
| 5586 | + | ||
| 5587 | + initHeight += 22; //22为字体的高度 | ||
| 5588 | + lineWidth = 0; | ||
| 5589 | + lastSubStrIndex = i; | ||
| 5590 | + titleHeight += 20; | ||
| 5591 | + } | ||
| 5592 | + if (i == str.length - 1) { //绘制剩余部分 | ||
| 5593 | + ctx.fillText(str.substring(lastSubStrIndex, i + 1), leftWidth, initHeight); | ||
| 5594 | + } | ||
| 5595 | + }; | ||
| 5596 | + }, | ||
| 5597 | + | ||
| 5598 | + // ----视频图片---- | ||
| 5599 | + // 图片计数器 | ||
| 5600 | + swiperChange: function (e) { | ||
| 5601 | + var that = this; | ||
| 5602 | + if (e.detail.current > 0) { | ||
| 5603 | + that.setData({ | ||
| 5604 | + hiddenn: 1, | ||
| 5605 | + videopicture: 1, | ||
| 5606 | + }) | ||
| 5607 | + } else { | ||
| 5608 | + that.setData({ | ||
| 5609 | + hiddenn: 0, | ||
| 5610 | + videopicture: 0, | ||
| 5611 | + }) | ||
| 5612 | + } | ||
| 5613 | + if (e.detail.source == 'touch') { | ||
| 5614 | + that.setData({ | ||
| 5615 | + current: e.detail.current | ||
| 5616 | + }) | ||
| 5617 | + } | ||
| 5618 | + }, | ||
| 5619 | + | ||
| 5620 | + /*---视频相关--*/ | ||
| 5621 | + videopicture: function (e) { | ||
| 5622 | + var vipi = e.currentTarget.dataset.vipi; | ||
| 5623 | + this.setData({ | ||
| 5624 | + videopicture: vipi, | ||
| 5625 | + swiperCurrent: vipi, | ||
| 5626 | + noon: 0, | ||
| 5627 | + current: 1 | ||
| 5628 | + }); | ||
| 5629 | + }, | ||
| 5630 | + | ||
| 5631 | + videoPlay: function (e) { | ||
| 5632 | + var _index = e.currentTarget.id | ||
| 5633 | + this.setData({ | ||
| 5634 | + _index: _index, | ||
| 5635 | + noon: 1 | ||
| 5636 | + }) | ||
| 5637 | + | ||
| 5638 | + setTimeout(function () { | ||
| 5639 | + //将点击视频进行播放 | ||
| 5640 | + var videoContext = wx.createVideoContext(_index) | ||
| 5641 | + videoContext.play(); | ||
| 5642 | + }, 500) | ||
| 5643 | + | ||
| 5644 | + }, | ||
| 5645 | + | ||
| 5646 | + //加载更多是靠这个函数 | ||
| 5647 | + onReachBottom: function () { | ||
| 5648 | + if (this.data.activeCategoryId == 2) { | ||
| 5649 | + if (!this.data.comments_no_more) this.requestComments_new(); | ||
| 5650 | + } | ||
| 5651 | + | ||
| 5652 | + var goods_list = this.selectComponent("#goods_list"); //组件的id | ||
| 5653 | + if (goods_list) goods_list.get_list(); | ||
| 5654 | + }, | ||
| 5655 | + | ||
| 5656 | + //--获取头像的本地缓存,回调写法-- | ||
| 5657 | + get_head_temp: function (tt, func) { | ||
| 5658 | + var ee = this; | ||
| 5659 | + if (ee.data.share_head) { | ||
| 5660 | + tt(func); | ||
| 5661 | + return false; | ||
| 5662 | + } | ||
| 5663 | + //---获取分享图片的本地地址,头像和商品图片---- | ||
| 5664 | + var path2 = getApp().globalData.userInfo.head_pic; | ||
| 5665 | + if (path2 == "") { | ||
| 5666 | + ee.data.share_head = "../../../images/share/hui_hear_pic.png"; | ||
| 5667 | + tt(func); | ||
| 5668 | + } else { | ||
| 5669 | + path2 = path2.replace("http://thirdwx.qlogo.cn", "https://wx.qlogo.cn"); | ||
| 5670 | + path2 = path2.replace("https://thirdwx.qlogo.cn", "https://wx.qlogo.cn"); | ||
| 5671 | + wx.getImageInfo({ | ||
| 5672 | + src: path2, | ||
| 5673 | + success: function (res) { | ||
| 5674 | + //res.path是网络图片的本地地址 | ||
| 5675 | + ee.data.share_head = res.path; | ||
| 5676 | + tt(func); | ||
| 5677 | + }, | ||
| 5678 | + fail: function (res) { | ||
| 5679 | + ee.data.share_head = "../../../images/share/hui_hear_pic.png"; //分享的图片不能用网络的 | ||
| 5680 | + tt(func); | ||
| 5681 | + } | ||
| 5682 | + }); | ||
| 5683 | + } | ||
| 5684 | + }, | ||
| 5685 | + //--获取商品图片的本地缓存,回调写法-- | ||
| 5686 | + get_goods_temp: function (tt) { | ||
| 5687 | + var ee = this; | ||
| 5688 | + if (ee.data.share_goods_img) { | ||
| 5689 | + tt(); | ||
| 5690 | + return false; | ||
| 5691 | + } | ||
| 5692 | + | ||
| 5693 | + var img_url = ee.data.data.original_img; | ||
| 5694 | + if ((this.data.prom_type == 1 || this.data.prom_type == 6) && this.data.prom_act.share_imgurl) { | ||
| 5695 | + img_url = this.data.iurl + this.data.prom_act.share_imgurl; | ||
| 5696 | + } | ||
| 5697 | + | ||
| 5698 | + //获取商品是分享图信息 | ||
| 5699 | + wx.getImageInfo({ | ||
| 5700 | + src: img_url, | ||
| 5701 | + success: function (res) { | ||
| 5702 | + //res.path是网络图片的本地地址 | ||
| 5703 | + ee.data.share_goods_img = res.path; | ||
| 5704 | + tt(); | ||
| 5705 | + }, | ||
| 5706 | + fail: function (res) { | ||
| 5707 | + ee.data.share_goods_img = "../../../images/share/default_g_img.gif"; //分享的图片不能用网络的 | ||
| 5708 | + tt(); | ||
| 5709 | + } | ||
| 5710 | + }); | ||
| 5711 | + }, | ||
| 5712 | + | ||
| 5713 | + //--外侧评价的点击效果--- | ||
| 5714 | + clik_evaluate: function (e) { | ||
| 5715 | + var val = e.currentTarget.dataset.val; | ||
| 5716 | + this.setData({ | ||
| 5717 | + activeCategoryId: 2, | ||
| 5718 | + activeCategoryId3: val, | ||
| 5719 | + comments: null | ||
| 5720 | + }); | ||
| 5721 | + this.requestComments_new(); | ||
| 5722 | + }, | ||
| 5723 | + | ||
| 5724 | + //--跳转到商品详情页面-- | ||
| 5725 | + go_goods: function (e) { | ||
| 5726 | + var gid = e.currentTarget.dataset.gid; | ||
| 5727 | + var url = "/pages/goods/goodsInfo/goodsInfo?goods_id=" + gid; | ||
| 5728 | + getApp().goto(url); | ||
| 5729 | + }, | ||
| 5730 | + | ||
| 5731 | + //--跳转到支付尾款界面-- | ||
| 5732 | + go_pay_wk: function () { | ||
| 5733 | + var url = "/pages/cart/cart_wk/cart_wk?order_id=" + this.data.wk_order_id; | ||
| 5734 | + getApp().goto(url); | ||
| 5735 | + }, | ||
| 5736 | + | ||
| 5737 | + pop_err_img: function (e) { | ||
| 5738 | + var txt = e.currentTarget.dataset.errorimg; | ||
| 5739 | + var ob = {}; | ||
| 5740 | + ob[txt] = this.data.iurl + "/miniapp/images/default_g_img.gif"; | ||
| 5741 | + this.setData(ob); | ||
| 5742 | + }, | ||
| 5743 | + | ||
| 5744 | + //--调用更新阶梯团的接口-- | ||
| 5745 | + update_jiti: function (id) { | ||
| 5746 | + var th = this; | ||
| 5747 | + //--更新阶梯团-- | ||
| 5748 | + getApp().request.put("/api/weshop/teamgroup/updateTeamOrder/" + os.stoid + "/" + id, { | ||
| 5749 | + success: function (ee) { | ||
| 5750 | + //--等于0是要去支付尾款,接口调用失败,就要去查看参团详情-- | ||
| 5751 | + if (ee.data.code == 0) { | ||
| 5752 | + th.setData({ | ||
| 5753 | + user_order_pt_state: 3, | ||
| 5754 | + }); | ||
| 5755 | + } else if (ee.data.code == -1) { | ||
| 5756 | + th.setData({ | ||
| 5757 | + user_order_pt_state: 2, | ||
| 5758 | + }); | ||
| 5759 | + } | ||
| 5760 | + } | ||
| 5761 | + }) | ||
| 5762 | + }, | ||
| 5763 | + // 选择门店 | ||
| 5764 | + choice_store: function (ee) { | ||
| 5765 | + var th = this; | ||
| 5766 | + var ind = ee.currentTarget.dataset.ind; | ||
| 5767 | + var bconfig = th.data.bconfig; | ||
| 5768 | + | ||
| 5769 | + if (!th.data.only_pk && !th.data.def_pickpu_list) { | ||
| 5770 | + // getApp().confirmBox("门店库存不足", null, 25000, !1); | ||
| 5771 | + wx.showToast({ title: '门店库存不足', icon: 'none', }); | ||
| 5772 | + return false; | ||
| 5773 | + } | ||
| 5774 | + | ||
| 5775 | + if (th.data.only_pk && !th.data.only_pk.length) { | ||
| 5776 | + // getApp().confirmBox("门店库存不足", null, 25000, !1); | ||
| 5777 | + wx.showToast({ | ||
| 5778 | + title: '门店库存不足', | ||
| 5779 | + icon: 'none', | ||
| 5780 | + }); | ||
| 5781 | + return false; | ||
| 5782 | + } | ||
| 5783 | + if (th.data.def_pickpu_list && !th.data.def_pickpu_list.length) { | ||
| 5784 | + // getApp().confirmBox("门店库存不足", null, 25000, !1); | ||
| 5785 | + wx.showToast({ | ||
| 5786 | + title: '门店库存不足', | ||
| 5787 | + icon: 'none', | ||
| 5788 | + }); | ||
| 5789 | + return false; | ||
| 5790 | + } | ||
| 5791 | + | ||
| 5792 | + | ||
| 5793 | + if (bconfig && bconfig.is_sort_storage) { | ||
| 5794 | + wx.getLocation({ | ||
| 5795 | + type: 'gcj02', | ||
| 5796 | + success: function (res) { | ||
| 5797 | + | ||
| 5798 | + th.data.lat = res.latitude; | ||
| 5799 | + th.data.lon = res.longitude; | ||
| 5800 | + th.data.is_get_local_ok = 1; | ||
| 5801 | + th.setData({ | ||
| 5802 | + is_gps: 1 | ||
| 5803 | + }); | ||
| 5804 | + //th.onShow(); | ||
| 5805 | + th.get_sto(th.data.is_normal); | ||
| 5806 | + }, | ||
| 5807 | + fail: function (res) { | ||
| 5808 | + //th.onShow(); | ||
| 5809 | + th.data.is_get_local_ok = 1; | ||
| 5810 | + th.get_sto(th.data.is_normal); | ||
| 5811 | + if (res.errCode == 2) { | ||
| 5812 | + th.setData({ | ||
| 5813 | + is_gps: 0 | ||
| 5814 | + }); | ||
| 5815 | + if (th.data.is_gps == 0) { | ||
| 5816 | + getApp().confirmBox("请开启GPS定位", null, 25000, !1); | ||
| 5817 | + } | ||
| 5818 | + } else { | ||
| 5819 | + th.setData({ | ||
| 5820 | + is_gps: "3" | ||
| 5821 | + }); | ||
| 5822 | + } | ||
| 5823 | + | ||
| 5824 | + } | ||
| 5825 | + }) | ||
| 5826 | + } else { | ||
| 5827 | + th.data.is_get_local_ok = 1; | ||
| 5828 | + th.get_sto(th.data.is_normal); | ||
| 5829 | + } | ||
| 5830 | + | ||
| 5831 | + if (ind != undefined && ind != null) { | ||
| 5832 | + this.setData({ | ||
| 5833 | + open_ind_store: ind, | ||
| 5834 | + store: 1, | ||
| 5835 | + openSpecModal: !1, | ||
| 5836 | + openSpecModal_pt: !1, | ||
| 5837 | + openSpecModal_flash_normal: !1, | ||
| 5838 | + }) | ||
| 5839 | + } else { | ||
| 5840 | + this.setData({ | ||
| 5841 | + store: 1, | ||
| 5842 | + openSpecModal: !1, | ||
| 5843 | + openSpecModal_pt: !1, | ||
| 5844 | + openSpecModal_flash_normal: !1 | ||
| 5845 | + | ||
| 5846 | + }) | ||
| 5847 | + } | ||
| 5848 | + }, | ||
| 5849 | + //关闭选择门店 | ||
| 5850 | + close_popup: function (e) { | ||
| 5851 | + var th = this; | ||
| 5852 | + this.setData({ | ||
| 5853 | + store: 0, | ||
| 5854 | + choice_sort_store: 0, | ||
| 5855 | + sort_store: 0, | ||
| 5856 | + fir_pick_index: 0, | ||
| 5857 | + sec_pick_index: 0 | ||
| 5858 | + }) | ||
| 5859 | + | ||
| 5860 | + var openindstore = this.data.open_ind_store; | ||
| 5861 | + if (openindstore == 1) { | ||
| 5862 | + th.setData({ | ||
| 5863 | + openSpecModal: !0, | ||
| 5864 | + openSpecModal_ind: openindstore, | ||
| 5865 | + }); | ||
| 5866 | + } else if (openindstore == 2) { | ||
| 5867 | + th.setData({ | ||
| 5868 | + openSpecModal: !0, | ||
| 5869 | + openSpecModal_ind: openindstore, | ||
| 5870 | + }); | ||
| 5871 | + } | ||
| 5872 | + else if (openindstore == 4) { //4就是拼团 | ||
| 5873 | + th.setData({ | ||
| 5874 | + openSpecModal_pt: 1, //打开拼团购买界面 | ||
| 5875 | + store: 0, //关闭门店 | ||
| 5876 | + choice_sort_store: 0, //关闭门店2级 | ||
| 5877 | + sort_store: 0, //关闭门店2级 | ||
| 5878 | + }); | ||
| 5879 | + } | ||
| 5880 | + else { | ||
| 5881 | + th.setData({ | ||
| 5882 | + store: 0, | ||
| 5883 | + choice_sort_store: 0, | ||
| 5884 | + sort_store: 0 | ||
| 5885 | + }) | ||
| 5886 | + } | ||
| 5887 | + | ||
| 5888 | + | ||
| 5889 | + }, | ||
| 5890 | + | ||
| 5891 | + //选择更多门店 | ||
| 5892 | + more_store: function () { | ||
| 5893 | + this.setData({ | ||
| 5894 | + sort_store: 1 | ||
| 5895 | + }); | ||
| 5896 | + }, | ||
| 5897 | + sort_store: function () { | ||
| 5898 | + | ||
| 5899 | + }, | ||
| 5900 | + // 返回按钮 | ||
| 5901 | + returns: function () { | ||
| 5902 | + this.setData({ | ||
| 5903 | + sort_store: 0, | ||
| 5904 | + choice_sort_store: 0 | ||
| 5905 | + }); | ||
| 5906 | + }, | ||
| 5907 | + //---选择分类门店--- | ||
| 5908 | + choice_sort_store: function (e) { | ||
| 5909 | + var index = e.currentTarget.dataset.index; | ||
| 5910 | + var region_name = e.currentTarget.dataset.region; | ||
| 5911 | + var item = this.data.all_sto[index]; | ||
| 5912 | + this.setData({ | ||
| 5913 | + region_name: region_name, | ||
| 5914 | + sort_store: 0, | ||
| 5915 | + choice_sort_store: 1, | ||
| 5916 | + sec_sto: item, | ||
| 5917 | + sec_pick_index: 0 | ||
| 5918 | + }); | ||
| 5919 | + }, | ||
| 5920 | + | ||
| 5921 | + choose_for_store_fir: function (e) { | ||
| 5922 | + var index_c = e.currentTarget.dataset.ind; | ||
| 5923 | + var th = this; | ||
| 5924 | + th.setData({ | ||
| 5925 | + fir_pick_index: index_c | ||
| 5926 | + }) | ||
| 5927 | + | ||
| 5928 | + }, | ||
| 5929 | + | ||
| 5930 | + //如果开启线下库存,已经急速库存才会使用 | ||
| 5931 | + async check_the_pick(item, func) { | ||
| 5932 | + var th = this; | ||
| 5933 | + var goodsinfo = th.data.sele_g; | ||
| 5934 | + var erpwareid = goodsinfo.erpwareid; | ||
| 5935 | + var plist = null; | ||
| 5936 | + var lock = 0; | ||
| 5937 | + | ||
| 5938 | + //---如果是活动的时候,同时不是普通购买--- | ||
| 5939 | + if ((th.data.prom_type == 1 || th.data.prom_type == 6 || th.data.prom_type == 4) && !th.data.is_normal) { | ||
| 5940 | + func(); | ||
| 5941 | + return false; | ||
| 5942 | + } | ||
| 5943 | + | ||
| 5944 | + if (this.data.sales_rules != 2) { | ||
| 5945 | + func(); | ||
| 5946 | + } else { | ||
| 5947 | + | ||
| 5948 | + //先读取门店的lock | ||
| 5949 | + await getApp().request.promiseGet("/api/weshop/order/ware/lock/page", { | ||
| 5950 | + data: {store_id: os.stoid, wareId: goodsinfo.goods_id, storageId: item.pickup_id, pageSize: 1000} | ||
| 5951 | + }).then(res => { | ||
| 5952 | + if (res.data.code == 0 && res.data.data.total > 0) { | ||
| 5953 | + for (var i in res.data.data.pageData) | ||
| 5954 | + lock += res.data.data.pageData[i].outQty; | ||
| 5955 | + } | ||
| 5956 | + }) | ||
| 5957 | + //读取线下的门店库存 | ||
| 5958 | + await getApp().request.promiseGet("/api/weshop/goods/getWareStorages", { | ||
| 5959 | + data: {storageNos: item.pickup_no, wareIds: encodeURIComponent(erpwareid), storeId: os.stoid} | ||
| 5960 | + }).then(res => { | ||
| 5961 | + if (res.data.code == 0 && res.data.data.total > 0) { | ||
| 5962 | + plist = res.data.data.pageData[0]; | ||
| 5963 | + } | ||
| 5964 | + }) | ||
| 5965 | + | ||
| 5966 | + if (plist && plist.CanOutQty - lock > 0) { | ||
| 5967 | + item.CanOutQty = plist.CanOutQty - lock; | ||
| 5968 | + func(); | ||
| 5969 | + return false; | ||
| 5970 | + } | ||
| 5971 | + // let str = item.pickup_name + '库存不足!'; | ||
| 5972 | + wx.showToast({ | ||
| 5973 | + title: item.pickup_name + '库存不足!', | ||
| 5974 | + icon: 'none', | ||
| 5975 | + }); | ||
| 5976 | + // getApp().my_warnning(item.pickup_name + "库存不足!", 0, th); | ||
| 5977 | + | ||
| 5978 | + } | ||
| 5979 | + }, | ||
| 5980 | + | ||
| 5981 | + | ||
| 5982 | + //确定def_pick为选择的门店 | ||
| 5983 | + sure_pick: function (e) { | ||
| 5984 | + var th = this; | ||
| 5985 | + var item = null; | ||
| 5986 | + var openindstore = th.data.open_ind_store; | ||
| 5987 | + | ||
| 5988 | + if (th.data.choice_sort_store == 0) { | ||
| 5989 | + var index = th.data.fir_pick_index; | ||
| 5990 | + if (th.data.is_show_sto_cat == 1) { | ||
| 5991 | + item = th.data.def_pickpu_list[index]; | ||
| 5992 | + } else { | ||
| 5993 | + item = th.data.only_pk[index]; //当没有门店分类的时候 | ||
| 5994 | + } | ||
| 5995 | + | ||
| 5996 | + } else { | ||
| 5997 | + var index = th.data.sec_pick_index; | ||
| 5998 | + item = th.data.sec_sto.s_arr[index]; | ||
| 5999 | + } | ||
| 6000 | + | ||
| 6001 | + if (!th.data.sele_g) return false; | ||
| 6002 | + //判断门店的配送方式是不是匹配 | ||
| 6003 | + var g_distr_type = th.data.sele_g.distr_type; | ||
| 6004 | + if (item.distr_type != 0 && g_distr_type != 0 && item.distr_type != g_distr_type) { | ||
| 6005 | + wx.showToast({ | ||
| 6006 | + title: "门店配送方式不匹配", | ||
| 6007 | + icon: 'none', | ||
| 6008 | + duration: 2000 | ||
| 6009 | + }); | ||
| 6010 | + return false; | ||
| 6011 | + } | ||
| 6012 | + | ||
| 6013 | + //--回调函数的用法-- | ||
| 6014 | + th.check_the_pick(item, function () { | ||
| 6015 | + th.setData({ | ||
| 6016 | + def_pick_store: item, | ||
| 6017 | + sto_sele_name: item.pickup_name, | ||
| 6018 | + sto_sele_id: item.pickup_id, | ||
| 6019 | + sto_sele_distr: item.distr_type, | ||
| 6020 | + store: 0, | ||
| 6021 | + choice_sort_store: 0, | ||
| 6022 | + fir_pick_index: 0 | ||
| 6023 | + }); | ||
| 6024 | + | ||
| 6025 | + switch (openindstore){ | ||
| 6026 | + case 1: | ||
| 6027 | + th.setData({ openSpecModal: !0,openSpecModal_ind: openindstore, }); | ||
| 6028 | + break; | ||
| 6029 | + case 2: | ||
| 6030 | + th.setData({openSpecModal: !0, openSpecModal_ind: openindstore, }); | ||
| 6031 | + break; | ||
| 6032 | + case 4: | ||
| 6033 | + th.setData({ | ||
| 6034 | + openSpecModal_pt: 1, //打开拼团购买界面 | ||
| 6035 | + store: 0, //关闭门店 | ||
| 6036 | + choice_sort_store: 0, //关闭门店2级 | ||
| 6037 | + sort_store: 0, //关闭门店2级 | ||
| 6038 | + }); | ||
| 6039 | + break; | ||
| 6040 | + case 5: | ||
| 6041 | + th.setData({ | ||
| 6042 | + openSpecModal_flash_normal: 1, //打开拼团购买界面 | ||
| 6043 | + store: 0, //关闭门店 | ||
| 6044 | + choice_sort_store: 0, //关闭门店2级 | ||
| 6045 | + sort_store: 0, //关闭门店2级 | ||
| 6046 | + }); | ||
| 6047 | + break; | ||
| 6048 | + default: | ||
| 6049 | + th.setData({ store: 0,choice_sort_store: 0, sort_store: 0}) | ||
| 6050 | + break | ||
| 6051 | + } | ||
| 6052 | + | ||
| 6053 | + /*-- | ||
| 6054 | + if (openindstore == 1) { | ||
| 6055 | + th.setData({ | ||
| 6056 | + openSpecModal: !0, | ||
| 6057 | + openSpecModal_ind: openindstore, | ||
| 6058 | + }); | ||
| 6059 | + } else if (openindstore == 2) { | ||
| 6060 | + th.setData({ | ||
| 6061 | + openSpecModal: !0, | ||
| 6062 | + openSpecModal_ind: openindstore, | ||
| 6063 | + }); | ||
| 6064 | + } | ||
| 6065 | + else if (openindstore == 4) { //4就是拼团 | ||
| 6066 | + th.setData({ | ||
| 6067 | + openSpecModal_pt: 1, //打开拼团购买界面 | ||
| 6068 | + store: 0, //关闭门店 | ||
| 6069 | + choice_sort_store: 0, //关闭门店2级 | ||
| 6070 | + sort_store: 0, //关闭门店2级 | ||
| 6071 | + }); | ||
| 6072 | + } | ||
| 6073 | + else { | ||
| 6074 | + th.setData({ | ||
| 6075 | + store: 0, | ||
| 6076 | + choice_sort_store: 0, | ||
| 6077 | + sort_store: 0 | ||
| 6078 | + }) | ||
| 6079 | + }--*/ | ||
| 6080 | + //如果商品没有其他活动,要取一下线下价格 | ||
| 6081 | + th.get_off_price(); | ||
| 6082 | + }) | ||
| 6083 | + }, | ||
| 6084 | + //---点击二级之后的选择--- | ||
| 6085 | + choose_for_store: function (e) { | ||
| 6086 | + var index_c = e.currentTarget.dataset.ind; | ||
| 6087 | + var th = this; | ||
| 6088 | + th.setData({ | ||
| 6089 | + sec_pick_index: index_c, | ||
| 6090 | + fir_pick_index: index_c | ||
| 6091 | + }) | ||
| 6092 | + | ||
| 6093 | + }, | ||
| 6094 | + //把选择的门店设置成默认的门店def_pick | ||
| 6095 | + set_def_pick: function (e) { | ||
| 6096 | + var th = this; | ||
| 6097 | + var item = null; | ||
| 6098 | + if (th.data.choice_sort_store == 0) { | ||
| 6099 | + var index = th.data.fir_pick_index; | ||
| 6100 | + if (th.data.is_show_sto_cat == 1) { | ||
| 6101 | + item = th.data.def_pickpu_list[index]; | ||
| 6102 | + } else { | ||
| 6103 | + item = th.data.only_pk[index]; //当没有门店分类的时候 | ||
| 6104 | + } | ||
| 6105 | + } else { | ||
| 6106 | + var index = th.data.sec_pick_index; | ||
| 6107 | + item = th.data.sec_sto.s_arr[index]; | ||
| 6108 | + } | ||
| 6109 | + | ||
| 6110 | + //判断门店的配送方式是不是匹配 | ||
| 6111 | + var g_distr_type = th.data.sele_g.distr_type; | ||
| 6112 | + if (item.distr_type != 0 && g_distr_type != 0 && item.distr_type != g_distr_type) { | ||
| 6113 | + wx.showToast({ | ||
| 6114 | + title: "门店配送方式不匹配", | ||
| 6115 | + icon: 'none', | ||
| 6116 | + duration: 2000 | ||
| 6117 | + }); | ||
| 6118 | + return false; | ||
| 6119 | + } | ||
| 6120 | + | ||
| 6121 | + //先设置之前,要判断是不是有库存 | ||
| 6122 | + th.check_the_pick(item, function () { | ||
| 6123 | + var store_id = o.stoid; | ||
| 6124 | + var user_id = getApp().globalData.user_id; | ||
| 6125 | + var def_pickup_id = item.pickup_id; | ||
| 6126 | + | ||
| 6127 | + getApp().request.put('/api/weshop/users/update', { | ||
| 6128 | + data: { | ||
| 6129 | + user_id: user_id, | ||
| 6130 | + def_pickup_id: def_pickup_id | ||
| 6131 | + }, | ||
| 6132 | + success: function (res) { | ||
| 6133 | + if (res.data.code == 0) { | ||
| 6134 | + if (th.data.choice_sort_store == 0) th.setData({ | ||
| 6135 | + fir_pick_index: 0 | ||
| 6136 | + }); | ||
| 6137 | + getApp().globalData.pk_store = item; | ||
| 6138 | + } else { | ||
| 6139 | + //s.showWarning("设置默认门店地址失败", null, 500, !1); | ||
| 6140 | + getApp().my_warnning("设置默认门店地址失败", 0, th) | ||
| 6141 | + } | ||
| 6142 | + | ||
| 6143 | + } | ||
| 6144 | + }); | ||
| 6145 | + | ||
| 6146 | + th.setData({ | ||
| 6147 | + def_pick_store: item, | ||
| 6148 | + sto_sele_name: item.pickup_name, | ||
| 6149 | + sto_sele_id: item.pickup_id, | ||
| 6150 | + sto_sele_distr: item.distr_type, | ||
| 6151 | + store: 0, | ||
| 6152 | + choice_sort_store: 0 | ||
| 6153 | + }); | ||
| 6154 | + | ||
| 6155 | + var openindstore = th.data.open_ind_store; | ||
| 6156 | + if (openindstore == 1) { | ||
| 6157 | + th.setData({ | ||
| 6158 | + openSpecModal: !0, | ||
| 6159 | + openSpecModal_ind: openindstore, | ||
| 6160 | + store: 0, | ||
| 6161 | + choice_sort_store: 0, | ||
| 6162 | + sort_store: 0, | ||
| 6163 | + }); | ||
| 6164 | + } else if (openindstore == 2) { | ||
| 6165 | + th.setData({ | ||
| 6166 | + openSpecModal: !0, | ||
| 6167 | + openSpecModal_ind: openindstore, | ||
| 6168 | + store: 0, | ||
| 6169 | + choice_sort_store: 0, | ||
| 6170 | + sort_store: 0, | ||
| 6171 | + }); | ||
| 6172 | + } | ||
| 6173 | + else if (openindstore == 4) { //4就是拼团 | ||
| 6174 | + th.setData({ | ||
| 6175 | + openSpecModal_pt: 1, //打开拼团购买界面 | ||
| 6176 | + store: 0, //关闭门店 | ||
| 6177 | + choice_sort_store: 0, //关闭门店2级 | ||
| 6178 | + sort_store: 0, //关闭门店2级 | ||
| 6179 | + }); | ||
| 6180 | + } | ||
| 6181 | + | ||
| 6182 | + else { | ||
| 6183 | + th.setData({ | ||
| 6184 | + store: 0, | ||
| 6185 | + choice_sort_store: 0, | ||
| 6186 | + sort_store: 0, | ||
| 6187 | + }) | ||
| 6188 | + } | ||
| 6189 | + | ||
| 6190 | + //如果商品没有其他活动,要取一下线下价格 | ||
| 6191 | + th.get_off_price(); | ||
| 6192 | + | ||
| 6193 | + }) | ||
| 6194 | + }, | ||
| 6195 | + | ||
| 6196 | + wait_for_store_config: function () { | ||
| 6197 | + var th = this; | ||
| 6198 | + //----获取系统参数----- | ||
| 6199 | + getApp().getConfig2(function (e) { | ||
| 6200 | + th.setData({ | ||
| 6201 | + bconfig: e, | ||
| 6202 | + }); | ||
| 6203 | + }) | ||
| 6204 | + var t_time = setInterval(function () { | ||
| 6205 | + if (th.data.bconfig == null) false; | ||
| 6206 | + var e = th.data.bconfig; | ||
| 6207 | + if (e && e.is_sort_storage) { | ||
| 6208 | + wx.getLocation({ | ||
| 6209 | + type: 'gcj02', | ||
| 6210 | + success: function (res) { | ||
| 6211 | + th.data.lat = res.latitude; | ||
| 6212 | + th.data.lon = res.longitude; | ||
| 6213 | + th.data.is_get_local_ok = 1; | ||
| 6214 | + }, | ||
| 6215 | + fail: function (res) { | ||
| 6216 | + if (res.errCode == 2) { | ||
| 6217 | + th.setData({ | ||
| 6218 | + is_gps: 0 | ||
| 6219 | + }); | ||
| 6220 | + if (th.data.is_gps == 0) { | ||
| 6221 | + getApp().confirmBox("请开启GPS定位", null, 10000, !1); | ||
| 6222 | + } | ||
| 6223 | + | ||
| 6224 | + } else { | ||
| 6225 | + th.setData({ | ||
| 6226 | + is_gps: "3" | ||
| 6227 | + }); | ||
| 6228 | + } | ||
| 6229 | + | ||
| 6230 | + th.data.is_get_local_ok = 1; | ||
| 6231 | + } | ||
| 6232 | + }) | ||
| 6233 | + } else { | ||
| 6234 | + th.data.is_get_local_ok = 1; | ||
| 6235 | + } | ||
| 6236 | + clearInterval(t_time); | ||
| 6237 | + }, 500) | ||
| 6238 | + }, | ||
| 6239 | + //显示全部 | ||
| 6240 | + toggleHandler: function (e) { | ||
| 6241 | + var that = this, | ||
| 6242 | + index = e.currentTarget.dataset.index; | ||
| 6243 | + for (var i = 0; i < that.data.comments.length; i++) { | ||
| 6244 | + if (index == i) { | ||
| 6245 | + for (var i = 0; i < that.data.comments.length; i++) { | ||
| 6246 | + that.data.comments[index].auto = true; | ||
| 6247 | + that.data.comments[index].seeMore = false; | ||
| 6248 | + } | ||
| 6249 | + } | ||
| 6250 | + } | ||
| 6251 | + that.setData({ | ||
| 6252 | + comments: that.data.comments | ||
| 6253 | + }) | ||
| 6254 | + }, | ||
| 6255 | + | ||
| 6256 | + //收起更多 | ||
| 6257 | + toggleContent: function (e) { | ||
| 6258 | + var that = this, | ||
| 6259 | + index = e.currentTarget.dataset.index; | ||
| 6260 | + for (var i = 0; i < that.data.comments.length; i++) { | ||
| 6261 | + if (index == i) { | ||
| 6262 | + that.data.comments[index].auto = true; | ||
| 6263 | + that.data.comments[index].seeMore = true; | ||
| 6264 | + } | ||
| 6265 | + } | ||
| 6266 | + that.setData({ | ||
| 6267 | + comments: that.data.comments | ||
| 6268 | + }) | ||
| 6269 | + }, | ||
| 6270 | + | ||
| 6271 | + //--- 获取卡类列表 --- | ||
| 6272 | + getPlusCardType: function (func) { | ||
| 6273 | + var storid = os.stoid; | ||
| 6274 | + var th = this; | ||
| 6275 | + var user = getApp().globalData.userInfo; | ||
| 6276 | + if (!user) return false; | ||
| 6277 | + getApp().request.promiseGet("/api/weshop/plus/vip/mem/bership/list?" + "storeId=" + storid, {}).then(res => { | ||
| 6278 | + var plusCard = res.data.data; | ||
| 6279 | + var arr = [1219, 2089, 3031]; | ||
| 6280 | + var new_arr = new Array(); | ||
| 6281 | + var card_name_map = new Map(); | ||
| 6282 | + | ||
| 6283 | + var list = []; | ||
| 6284 | + for (var i = 0; i < plusCard.length; i++) { | ||
| 6285 | + if ((!user || user.card_field == null || user.card_field == "") && plusCard[i].IsStopBuy == true) continue; | ||
| 6286 | + var name = "card" + plusCard[i].CorrPrice.toLowerCase(); | ||
| 6287 | + card_name_map.set(name, plusCard[i].CardName); | ||
| 6288 | + list.push(plusCard[i]); | ||
| 6289 | + } | ||
| 6290 | + | ||
| 6291 | + var ob = {"card_list": list, "name_map": card_name_map}; | ||
| 6292 | + func(ob); | ||
| 6293 | + }) | ||
| 6294 | + }, | ||
| 6295 | + | ||
| 6296 | + go_plus: function () { | ||
| 6297 | + getApp().goto("/pages/user/plus/plus"); | ||
| 6298 | + }, | ||
| 6299 | + go_card_info: function () { | ||
| 6300 | + getApp().goto("/pages/user/cardinfo/cardinfo"); | ||
| 6301 | + }, | ||
| 6302 | + //-- 根据ID拿出门店 -- | ||
| 6303 | + get_pick_from_list(pid) { | ||
| 6304 | + var all_pick_list = this.data.all_pick_list; | ||
| 6305 | + for (var i in all_pick_list) { | ||
| 6306 | + var item = all_pick_list[i]; | ||
| 6307 | + if (item.pickup_id == pid) { | ||
| 6308 | + return item; | ||
| 6309 | + } | ||
| 6310 | + } | ||
| 6311 | + }, | ||
| 6312 | + //-----显示优惠券的时候情况----- | ||
| 6313 | + show_more_cx: function () { | ||
| 6314 | + if (this.data.is_more_cx) { | ||
| 6315 | + this.setData({is_more_cx: 0}); | ||
| 6316 | + } else { | ||
| 6317 | + this.setData({is_more_cx: 1}); | ||
| 6318 | + } | ||
| 6319 | + }, | ||
| 6320 | + | ||
| 6321 | + //----跳转到搭配购买---- | ||
| 6322 | + go_prom_list: function () { | ||
| 6323 | + | ||
| 6324 | + var url = "../../../packageA/pages/prom_list/prom_list?goods_id=" + this.data.gid; | ||
| 6325 | + var room_id = getApp().globalData.room_id; | ||
| 6326 | + if (room_id && this.data.gid == getApp().globalData.room_goods_id) { | ||
| 6327 | + url += "&room_id=" + room_id; | ||
| 6328 | + } | ||
| 6329 | + wx.navigateTo({url: url,}) | ||
| 6330 | + }, | ||
| 6331 | + | ||
| 6332 | + //---检查有没有优惠活动--- | ||
| 6333 | + check_is_youhui: function (gid, is_nor) { | ||
| 6334 | + var th = this; | ||
| 6335 | + var user_id = getApp().globalData.user_id; | ||
| 6336 | + if (!user_id) user_id = 0; | ||
| 6337 | + //如果是普通购买的时候,要进行调用 | ||
| 6338 | + if (is_nor) { | ||
| 6339 | + getApp().request.get("/api/weshop/goods/getGoodsPromNormal/" + os.stoid + "/" + gid, { | ||
| 6340 | + success: function (res) { | ||
| 6341 | + if (res.data.code == 0) { | ||
| 6342 | + var r_data = res.data.data; | ||
| 6343 | + | ||
| 6344 | + if (r_data.ladderLists) { | ||
| 6345 | + var act_id = r_data.ladderLists[0].form_id; | ||
| 6346 | + //-- 判断会员能不能参与阶梯促销 -- | ||
| 6347 | + getApp().request.promiseGet("/api/weshop/prom/ladderForm/getNew/" + os.stoid + "/" + user_id + "/" + act_id, {}).then(res => { | ||
| 6348 | + if (res.data.code == 0 && res.data.data) { | ||
| 6349 | + var prom_content = ""; | ||
| 6350 | + for (let jj in r_data.ladderLists) { | ||
| 6351 | + if (r_data.ladderLists[jj].discount == 10) { | ||
| 6352 | + prom_content += "第" + (parseInt(jj) + 1) + "件原价,"; | ||
| 6353 | + } else { | ||
| 6354 | + prom_content += "第" + (parseInt(jj) + 1) + "件" + r_data.ladderLists[jj].discount + "折,"; | ||
| 6355 | + } | ||
| 6356 | + } | ||
| 6357 | + prom_content = ut.sub_last(prom_content); | ||
| 6358 | + th.data.prom_type = 10; | ||
| 6359 | + th.data.prom_id = act_id; | ||
| 6360 | + th.setData({ | ||
| 6361 | + jieti_prom: prom_content, | ||
| 6362 | + ladder_act_id: act_id | ||
| 6363 | + }) | ||
| 6364 | + } | ||
| 6365 | + }) | ||
| 6366 | + } | ||
| 6367 | + | ||
| 6368 | + th.setData({ | ||
| 6369 | + prom_goods: r_data.promGoodsLists, | ||
| 6370 | + }) | ||
| 6371 | + th.is_show_more_buy(); | ||
| 6372 | + } | ||
| 6373 | + }, | ||
| 6374 | + }) | ||
| 6375 | + | ||
| 6376 | + } else { | ||
| 6377 | + //调用接口判断订单优惠, | ||
| 6378 | + getApp().request.get("/api/weshop/goods/getGoodsPromList/" + os.stoid + "/" + gid + "/0"+"/"+user_id, { | ||
| 6379 | + success: function (res) { | ||
| 6380 | + if (res.data.code == 0 && res.data.data) { | ||
| 6381 | + var r_data = res.data.data; | ||
| 6382 | + var max = 0, min = 0; | ||
| 6383 | + if (r_data.collocationList) { | ||
| 6384 | + for (var i in r_data.collocationList) { | ||
| 6385 | + if (max == 0) max = r_data.collocationList[i].price; | ||
| 6386 | + if (min == 0) min = r_data.collocationList[i].price; | ||
| 6387 | + | ||
| 6388 | + if (max < parseFloat(r_data.collocationList[i].price)) max = r_data.collocationList[i].price; | ||
| 6389 | + if (min > parseFloat(r_data.collocationList[i].price)) min = r_data.collocationList[i].price; | ||
| 6390 | + } | ||
| 6391 | + r_data.collocationPromList.max = (max + th.data.data.shop_price).toFixed(2); | ||
| 6392 | + r_data.collocationPromList.min = (min + th.data.data.shop_price).toFixed(2); | ||
| 6393 | + } | ||
| 6394 | + | ||
| 6395 | + if (r_data.ladderLists) { | ||
| 6396 | + var act_id = r_data.ladderLists[0].form_id; | ||
| 6397 | + //-- 判断会员能不能参与阶梯促销 -- | ||
| 6398 | + getApp().request.promiseGet("/api/weshop/prom/ladderForm/getNew/" + os.stoid + "/" + user_id + "/" + act_id, {}).then(res => { | ||
| 6399 | + if (res.data.code == 0 && res.data.data) { | ||
| 6400 | + var prom_content = ""; | ||
| 6401 | + for (let jj in r_data.ladderLists) { | ||
| 6402 | + if (r_data.ladderLists[jj].discount == 10) { | ||
| 6403 | + prom_content += "第" + (parseInt(jj) + 1) + "件原价,"; | ||
| 6404 | + } else { | ||
| 6405 | + prom_content += "第" + (parseInt(jj) + 1) + "件" + r_data.ladderLists[jj].discount + "折,"; | ||
| 6406 | + } | ||
| 6407 | + } | ||
| 6408 | + prom_content = ut.sub_last(prom_content); | ||
| 6409 | + th.data.prom_type = 10; | ||
| 6410 | + th.data.prom_id = act_id; | ||
| 6411 | + th.setData({ | ||
| 6412 | + jieti_prom: prom_content, | ||
| 6413 | + ladder_act_id: act_id | ||
| 6414 | + }) | ||
| 6415 | + } | ||
| 6416 | + }) | ||
| 6417 | + } | ||
| 6418 | + | ||
| 6419 | + th.setData({ | ||
| 6420 | + order_prom: r_data.promOrder, | ||
| 6421 | + collocationGoods: r_data.collocationPromList, | ||
| 6422 | + prom_goods: r_data.promGoodsLists, | ||
| 6423 | + }) | ||
| 6424 | + th.is_show_more_buy(); | ||
| 6425 | + } | ||
| 6426 | + } | ||
| 6427 | + }) | ||
| 6428 | + } | ||
| 6429 | + }, | ||
| 6430 | + | ||
| 6431 | + closePoster() { | ||
| 6432 | + this.setData({ | ||
| 6433 | + showPoster: false, | ||
| 6434 | + }); | ||
| 6435 | + }, | ||
| 6436 | + | ||
| 6437 | + // 保存图片到手机 | ||
| 6438 | + savePic() { | ||
| 6439 | + console.log('保存图片'); | ||
| 6440 | + var self = this; | ||
| 6441 | + // 获取用户的当前设置,返回值中有小程序已经向用户请求过的权限 | ||
| 6442 | + this.getSetting().then((res) => { | ||
| 6443 | + // 判断用户是否授权了保存到相册的权限,如果没有发起授权 | ||
| 6444 | + if (!res.authSetting['scope.writePhotosAlbum']) { | ||
| 6445 | + this.authorize().then(() => { | ||
| 6446 | + // 同意授权后保存下载文件 | ||
| 6447 | + this.saveImage(self.data.shareImgPath) | ||
| 6448 | + .then(() => { | ||
| 6449 | + self.setData({ | ||
| 6450 | + showPoster: false | ||
| 6451 | + }); | ||
| 6452 | + }); | ||
| 6453 | + }) | ||
| 6454 | + } else { | ||
| 6455 | + // 如果已经授权,保存下载文件 | ||
| 6456 | + this.saveImage(self.data.shareImgPath) | ||
| 6457 | + .then(() => { | ||
| 6458 | + self.setData({ | ||
| 6459 | + showPoster: false | ||
| 6460 | + }); | ||
| 6461 | + }); | ||
| 6462 | + } | ||
| 6463 | + | ||
| 6464 | + }) | ||
| 6465 | + }, | ||
| 6466 | + | ||
| 6467 | + // 获取用户已经授予了哪些权限 | ||
| 6468 | + getSetting() { | ||
| 6469 | + return new Promise((resolve, reject) => { | ||
| 6470 | + wx.getSetting({ | ||
| 6471 | + success: res => { | ||
| 6472 | + resolve(res) | ||
| 6473 | + } | ||
| 6474 | + }) | ||
| 6475 | + }) | ||
| 6476 | + }, | ||
| 6477 | + | ||
| 6478 | + // 发起首次授权请求 | ||
| 6479 | + authorize() { | ||
| 6480 | + // isFirst 用来记录是否为首次发起授权, | ||
| 6481 | + // 如果首次授权拒绝后,isFirst赋值为1 | ||
| 6482 | + let isFirst = wx.getStorageSync('isFirst') || 0; | ||
| 6483 | + return new Promise((resolve, reject) => { | ||
| 6484 | + wx.authorize({ | ||
| 6485 | + scope: 'scope.writePhotosAlbum', | ||
| 6486 | + // 同意授权 | ||
| 6487 | + success: () => { | ||
| 6488 | + resolve(); | ||
| 6489 | + }, | ||
| 6490 | + // 拒绝授权,这里是用户拒绝授权后的回调 | ||
| 6491 | + fail: res => { | ||
| 6492 | + if (isFirst === 0) { | ||
| 6493 | + wx.setStorageSync('isFirst', 1); | ||
| 6494 | + wx.showToast({ | ||
| 6495 | + title: '保存失败', | ||
| 6496 | + icon: 'none', | ||
| 6497 | + duration: 1000 | ||
| 6498 | + }) | ||
| 6499 | + } else { | ||
| 6500 | + this.showModal(); | ||
| 6501 | + } | ||
| 6502 | + console.log('拒绝授权'); | ||
| 6503 | + reject(); | ||
| 6504 | + } | ||
| 6505 | + }) | ||
| 6506 | + }) | ||
| 6507 | + }, | ||
| 6508 | + | ||
| 6509 | + | ||
| 6510 | + // 保存图片到系统相册 | ||
| 6511 | + saveImage(saveUrl) { | ||
| 6512 | + var self = this; | ||
| 6513 | + return new Promise((resolve, reject) => { | ||
| 6514 | + wx.saveImageToPhotosAlbum({ | ||
| 6515 | + filePath: saveUrl, | ||
| 6516 | + success: (res) => { | ||
| 6517 | + wx.showToast({ | ||
| 6518 | + title: '保存成功', | ||
| 6519 | + duration: 1000, | ||
| 6520 | + }); | ||
| 6521 | + self.setData({ | ||
| 6522 | + showPlaybill: 'true' | ||
| 6523 | + }); | ||
| 6524 | + resolve(); | ||
| 6525 | + }, | ||
| 6526 | + fail: () => { | ||
| 6527 | + wx.showToast({ | ||
| 6528 | + title: '保存失败', | ||
| 6529 | + duration: 1000, | ||
| 6530 | + }); | ||
| 6531 | + } | ||
| 6532 | + }) | ||
| 6533 | + }) | ||
| 6534 | + }, | ||
| 6535 | + | ||
| 6536 | + previewImage(e) { | ||
| 6537 | + this.data.show_prew_img = 1; | ||
| 6538 | + getApp().pre_img(this.data.sele_g.original_img); | ||
| 6539 | + }, | ||
| 6540 | + | ||
| 6541 | + is_show_more_buy: function () { | ||
| 6542 | + var prom_goods = this.data.prom_goods; | ||
| 6543 | + var per_price = this.data.sele_g.shop_price | ||
| 6544 | + if (this.data.card_field && this.data.sele_g[this.data.card_field] > 0) { | ||
| 6545 | + per_price = this.data.sele_g[this.data.card_field]; | ||
| 6546 | + } | ||
| 6547 | + var all_price = per_price * this.data.goodsInputNum; | ||
| 6548 | + var con = null; | ||
| 6549 | + for (var i in prom_goods) { | ||
| 6550 | + var item = prom_goods[i]; | ||
| 6551 | + if (item.prom_type == 1) { | ||
| 6552 | + if (item.condition > this.data.goodsInputNum) { | ||
| 6553 | + con = item; | ||
| 6554 | + con.need = (item.condition - this.data.goodsInputNum).toFixed(2) + "件"; | ||
| 6555 | + break; | ||
| 6556 | + } | ||
| 6557 | + } else { | ||
| 6558 | + if (item.condition > all_price) { | ||
| 6559 | + con = item; | ||
| 6560 | + con.need = (item.condition - all_price).toFixed(2) + "元"; | ||
| 6561 | + break; | ||
| 6562 | + } | ||
| 6563 | + } | ||
| 6564 | + } | ||
| 6565 | + | ||
| 6566 | + this.setData({hui_condition: con}); | ||
| 6567 | + | ||
| 6568 | + }, | ||
| 6569 | + | ||
| 6570 | + //-- 积分购 -- | ||
| 6571 | + go_pay_integral: function () { | ||
| 6572 | + this.data.g_buy_num = new Map(); | ||
| 6573 | + this.get_sto(0) | ||
| 6574 | + this.setData({openSpecModal_inte: 1, goodsInputNum: 1}); | ||
| 6575 | + | ||
| 6576 | + | ||
| 6577 | + }, | ||
| 6578 | + //-- 积分购普通购买 -- | ||
| 6579 | + go_pay_integral_normal: function () { | ||
| 6580 | + | ||
| 6581 | + this.data.g_buy_num = new Map(); | ||
| 6582 | + var th = this; | ||
| 6583 | + if (th.data.sku_g_pt) { | ||
| 6584 | + this.get_sto(1) | ||
| 6585 | + this.setData({openSpecModal_inte_normal: 1}); | ||
| 6586 | + } else { | ||
| 6587 | + th.get_sto(1); | ||
| 6588 | + th.get_sku(o.stoid, th.data.data, th.data.gid, 1, function () { | ||
| 6589 | + th.setData({ | ||
| 6590 | + is_normal: 1, | ||
| 6591 | + openSpecModal_inte_normal: 1 | ||
| 6592 | + }); | ||
| 6593 | + }); | ||
| 6594 | + } | ||
| 6595 | + this.check_is_youhui(th.data.gid, 1); | ||
| 6596 | + }, | ||
| 6597 | + | ||
| 6598 | + closeSpecModal_inte: function () { | ||
| 6599 | + this.setData({openSpecModal_inte: 0}); | ||
| 6600 | + }, | ||
| 6601 | + closeSpecModal_inte_normal: function () { | ||
| 6602 | + this.setData({openSpecModal_inte_normal: 0}); | ||
| 6603 | + //要进行还原 | ||
| 6604 | + this.get_sto(); | ||
| 6605 | + this.setData({ | ||
| 6606 | + sele_g: this.data.data, | ||
| 6607 | + gid: this.data.data.goods_id | ||
| 6608 | + }) | ||
| 6609 | + | ||
| 6610 | + this.sele_spec_chech_activity(); | ||
| 6611 | + }, | ||
| 6612 | + | ||
| 6613 | + addCart_inte: function (t) { | ||
| 6614 | + this.add_cart_func_inte(t); | ||
| 6615 | + }, | ||
| 6616 | + | ||
| 6617 | + onShareTimeline() { | ||
| 6618 | + getApp().globalData.no_clear=1; | ||
| 6619 | + var store_name = getApp().globalData.config ? getApp().globalData.config.store_name : ''; | ||
| 6620 | + if (!store_name) | ||
| 6621 | + store_name = getApp().globalData.setting.appName; | ||
| 6622 | + return { | ||
| 6623 | + title: this.data.data.goods_name + '-' + store_name, | ||
| 6624 | + imageUrl: this.data.gallery[0].image_url, | ||
| 6625 | + } | ||
| 6626 | + }, | ||
| 6627 | + | ||
| 6628 | + | ||
| 6629 | + clickCollapse() { | ||
| 6630 | + this.setData({ | ||
| 6631 | + flag: !this.data.flag, | ||
| 6632 | + }) | ||
| 6633 | + }, | ||
| 6634 | + | ||
| 6635 | + clickShare() { | ||
| 6636 | + if(!getApp().globalData.user_id){ | ||
| 6637 | + getApp().goto("/pages/togoin/togoin"); | ||
| 6638 | + return false; | ||
| 6639 | + } | ||
| 6640 | + this.setData({ | ||
| 6641 | + share_hidden: true, | ||
| 6642 | + }); | ||
| 6643 | + }, | ||
| 6644 | + | ||
| 6645 | + send() { | ||
| 6646 | + this.setData({ | ||
| 6647 | + share_hidden: false, | ||
| 6648 | + }); | ||
| 6649 | + }, | ||
| 6650 | + | ||
| 6651 | + cancel() { | ||
| 6652 | + this.setData({ | ||
| 6653 | + share_hidden: false, | ||
| 6654 | + }); | ||
| 6655 | + }, | ||
| 6656 | + | ||
| 6657 | + //积分购和拼团的普通购买的的时候,要判断有没有全场优惠活动 | ||
| 6658 | + check_nor_promgood(goods_id, back) { | ||
| 6659 | + getApp().request.get("/api/weshop/goods/getGoodsPromNormal/" + os.stoid + "/" + goods_id, { | ||
| 6660 | + success: function (res) { | ||
| 6661 | + if (res.data.code == 0 && res.data.data && res.data.data.promGoodsLists && res.data.data.promGoodsLists.length > 0) { | ||
| 6662 | + var obj = { | ||
| 6663 | + act_id: res.data.data.promGoodsLists[0].prom_id, | ||
| 6664 | + } | ||
| 6665 | + back(obj); | ||
| 6666 | + } else { | ||
| 6667 | + back(0) | ||
| 6668 | + } | ||
| 6669 | + } | ||
| 6670 | + }) | ||
| 6671 | + }, | ||
| 6672 | + | ||
| 6673 | + go_zh: function (e) { | ||
| 6674 | + var id = e.currentTarget.dataset.id; | ||
| 6675 | + getApp().goto("/packageB/pages/zuhegou/index/index?id=" + id); | ||
| 6676 | + }, | ||
| 6677 | + | ||
| 6678 | + check_zh_acting: function (func) { | ||
| 6679 | + var isok = 1, item = this.data.sele_g; | ||
| 6680 | + //如果有组合购 | ||
| 6681 | + var url = "/api/weshop/prom/zhbuy/get/" + os.stoid + "/" + item.prom_id + "/" + getApp().globalData.user_id; | ||
| 6682 | + getApp().request.promiseGet(url, {}).then(res => { | ||
| 6683 | + if (res.data.code == 0 && res.data.data) { | ||
| 6684 | + if (res.data.data.is_show != 1) { | ||
| 6685 | + isok = 0; | ||
| 6686 | + } | ||
| 6687 | + //如果活动已经结束 | ||
| 6688 | + if (res.data.data.is_end == 1) { | ||
| 6689 | + isok = 0; | ||
| 6690 | + } | ||
| 6691 | + //已经结束 | ||
| 6692 | + if (ut.gettimestamp() > res.data.data.end_time) { | ||
| 6693 | + isok = 0; | ||
| 6694 | + } | ||
| 6695 | + //还未开始 | ||
| 6696 | + if (ut.gettimestamp() < res.data.data.start_time) { | ||
| 6697 | + isok = 0; | ||
| 6698 | + } | ||
| 6699 | + | ||
| 6700 | + } else { | ||
| 6701 | + //未找到商品的活动 | ||
| 6702 | + isok = 0; | ||
| 6703 | + } | ||
| 6704 | + item.act = res.data.data; | ||
| 6705 | + func(isok); | ||
| 6706 | + }) | ||
| 6707 | + }, | ||
| 6708 | + | ||
| 6709 | + //获取更多秒杀 | ||
| 6710 | + get_more_flahs: async function (func) { | ||
| 6711 | + var f_more = false; | ||
| 6712 | + var user_id = getApp().globalData.user_id; | ||
| 6713 | + if (!user_id) user_id = 0; | ||
| 6714 | + | ||
| 6715 | + var url = "/api/weshop/goods/listSkuFlash?store_id=" + os.stoid + "&goods_id=" + this.data.data.goods_id + "&user_id=" + user_id; | ||
| 6716 | + //获取秒杀的多规格 | ||
| 6717 | + await getApp().request.promiseGet(url, {}).then(res => { | ||
| 6718 | + if (res.data.code == 0 && res.data.data && res.data.data.length > 0) { | ||
| 6719 | + f_more = res.data.data; | ||
| 6720 | + } | ||
| 6721 | + }) | ||
| 6722 | + if (!f_more) { | ||
| 6723 | + func(false); | ||
| 6724 | + return false; | ||
| 6725 | + } | ||
| 6726 | + //-- 秒杀的价格要更新 -- | ||
| 6727 | + for (let i in f_more) { | ||
| 6728 | + | ||
| 6729 | + let item = f_more[i]; | ||
| 6730 | + f_more[i].prom_id = item.act_id; | ||
| 6731 | + f_more[i].prom_type = 1; | ||
| 6732 | + if (item.goods_id == this.data.data.goods_id) { | ||
| 6733 | + continue; | ||
| 6734 | + } | ||
| 6735 | + var url = "/api/ms/flash_sale/getNew/" + os.stoid + "/" + user_id + "/" + item.act_id; | ||
| 6736 | + await getApp().request.promiseGet(url, {}).then(rs => { | ||
| 6737 | + if (rs.data.code == 0) { | ||
| 6738 | + f_more[i].price = rs.data.data.user_price; | ||
| 6739 | + | ||
| 6740 | + } | ||
| 6741 | + }) | ||
| 6742 | + } | ||
| 6743 | + func(f_more); | ||
| 6744 | + | ||
| 6745 | + }, | ||
| 6746 | + | ||
| 6747 | + //-- 判断是否有秒杀 -- | ||
| 6748 | + check_has_flash: function () { | ||
| 6749 | + var th = this; | ||
| 6750 | + var url = "/api/weshop/activitylist/getGoodActInfo"; | ||
| 6751 | + var user_id = getApp().globalData.user_id; | ||
| 6752 | + if (!user_id) user_id = 0; | ||
| 6753 | + | ||
| 6754 | + var req_data = { | ||
| 6755 | + store_id: os.stoid, goodsidlist: this.data.data.goods_id, is_detail: 1, user_id: user_id | ||
| 6756 | + }; | ||
| 6757 | + //获取秒杀的多规格 | ||
| 6758 | + getApp().request.promiseGet(url, {data: req_data}).then(async function (res) { | ||
| 6759 | + if (res.data.code == 0 && res.data.data && res.data.data.length) { | ||
| 6760 | + var arr_data = res.data.data; | ||
| 6761 | + var new_arr = []; | ||
| 6762 | + for (let i in arr_data) { | ||
| 6763 | + let item = arr_data[i]; | ||
| 6764 | + //找不到活动要剔除 | ||
| 6765 | + if (!item.act_name) continue; | ||
| 6766 | + if (item.prom_type != 1) continue; | ||
| 6767 | + new_arr.push(item); | ||
| 6768 | + } | ||
| 6769 | + | ||
| 6770 | + if (new_arr.length == 1) { | ||
| 6771 | + th.data.prom_id = new_arr[0].act_id; | ||
| 6772 | + th.data.prom_type = new_arr[0].prom_type; | ||
| 6773 | + } | ||
| 6774 | + | ||
| 6775 | + th.setData({more_flash: new_arr}); | ||
| 6776 | + } | ||
| 6777 | + }) | ||
| 6778 | + }, | ||
| 6779 | + | ||
| 6780 | + //-- 跳转到秒杀商品详情页 -- | ||
| 6781 | + go_more_flash: function (e) { | ||
| 6782 | + var prom_id = e.currentTarget.dataset.id; | ||
| 6783 | + var goods_id = this.data.data.goods_id; | ||
| 6784 | + var url = "/pages/goods/goodsInfo/goodsInfo?goods_id=" + goods_id + "&prom_id=" + prom_id + "&prom_type=1"; | ||
| 6785 | + getApp().goto(url); | ||
| 6786 | + }, | ||
| 6787 | + | ||
| 6788 | + close_pop_more: function () { | ||
| 6789 | + this.setData({is_pop_more: 0}) | ||
| 6790 | + }, | ||
| 6791 | + | ||
| 6792 | + con_weixin: function () { | ||
| 6793 | + getApp().con_wx(this); | ||
| 6794 | + }, | ||
| 6795 | + | ||
| 6796 | + get_normal(gid){ | ||
| 6797 | + this.setData({ | ||
| 6798 | + prom_type: 0, | ||
| 6799 | + isshow: 1, | ||
| 6800 | + }); | ||
| 6801 | + this.get_sku(os.stoid, this.data.data, gid); | ||
| 6802 | + this.get_sto(); | ||
| 6803 | + this.check_is_youhui(gid, 1); | ||
| 6804 | + this.data.is_normal = 1; | ||
| 6805 | + }, | ||
| 6806 | + | ||
| 6807 | + | ||
| 6808 | + // 促销 -> 送礼包 -> 查看详情 | ||
| 6809 | + viewLbDetails(e) { | ||
| 6810 | + let id = e.currentTarget.dataset.id; // 获取礼包id | ||
| 6811 | + let flag = e.currentTarget.dataset.flag; | ||
| 6812 | + let url = ''; | ||
| 6813 | + if(flag == 1) { // flag =1 控制跳转到专享礼包 | ||
| 6814 | + url = `/pages/giftpack/giftpacklist/giftpacklist?lbId=${id}&flag=1`; | ||
| 6815 | + } else { | ||
| 6816 | + url = `/packageA/pages/myGiftDetails/myGiftDetails?btn=0&index=0&id=${id}`; // btn=0 控制跳转到的页面不显示按钮 | ||
| 6817 | + }; | ||
| 6818 | + // console.log('myurl', url); | ||
| 6819 | + getApp().goto(url); | ||
| 6820 | + }, | ||
| 6821 | + | ||
| 6822 | + | ||
| 6823 | + | ||
| 6824 | + go_more_ladder: function (e) { | ||
| 6825 | + var prom_id = e.currentTarget.dataset.id; | ||
| 6826 | + getApp().goto("/pages/goods/goodsList/goodsList?ladder_id=" + prom_id); | ||
| 6827 | + }, | ||
| 6828 | + | ||
| 6829 | + getHistoryBuy() { | ||
| 6830 | + let _this = this; | ||
| 6831 | + let req_data = { | ||
| 6832 | + store_id: os.stoid, | ||
| 6833 | + goods_id: this.data.gid, | ||
| 6834 | + pay_status: 1, | ||
| 6835 | + rndid: 1 | ||
| 6836 | + }; | ||
| 6837 | + getApp().request.promiseGet('/api/weshop/ordergoods/list', { | ||
| 6838 | + data: req_data, | ||
| 6839 | + }) | ||
| 6840 | + .then(res => { | ||
| 6841 | + if (t.ajax_ok(res)) { | ||
| 6842 | + _this.setData({ | ||
| 6843 | + historyBuyInfo: res.data.data.pageData, | ||
| 6844 | + }) | ||
| 6845 | + } | ||
| 6846 | + }) | ||
| 6847 | + }, | ||
| 6848 | + | ||
| 6849 | + //-- 检验商品的活动情况 -- | ||
| 6850 | + check_gd_prom_new: function (func) { | ||
| 6851 | + var th = this; | ||
| 6852 | + var user_id = getApp().globalData.user_id; | ||
| 6853 | + if (!user_id) user_id = 0; | ||
| 6854 | + | ||
| 6855 | + var url = '/api/weshop/activitylist/listGoodActInfo2'; | ||
| 6856 | + var req_d = { | ||
| 6857 | + "store_id": os.stoid, | ||
| 6858 | + "goods_id": this.data.gid, | ||
| 6859 | + "user_id": user_id, | ||
| 6860 | + } | ||
| 6861 | + getApp().request.get(url, { | ||
| 6862 | + data: req_d, | ||
| 6863 | + success: function (e) { | ||
| 6864 | + if (e.data.code == 0 && e.data.data && e.data.data.length > 0) { | ||
| 6865 | + var arr = e.data.data; | ||
| 6866 | + var arr2 = arr.filter(function (e) { | ||
| 6867 | + return e.s_time < ut.gettimestamp(); | ||
| 6868 | + }) | ||
| 6869 | + //-- 如果只有一个活动的话 -- | ||
| 6870 | + if (arr.length == 1) { | ||
| 6871 | + th.data.prom_type = arr[0].prom_type; | ||
| 6872 | + th.data.prom_id = arr[0].act_id; | ||
| 6873 | + } | ||
| 6874 | + //-- 如果只有一个进行中的活动的话 -- | ||
| 6875 | + else if (arr2.length == 1) { | ||
| 6876 | + th.data.prom_type = arr2[0].prom_type; | ||
| 6877 | + th.data.prom_id = arr2[0].act_id; | ||
| 6878 | + } | ||
| 6879 | + } | ||
| 6880 | + //-- 调用回调 -- | ||
| 6881 | + func(); | ||
| 6882 | + } | ||
| 6883 | + }); | ||
| 6884 | + }, | ||
| 6885 | + | ||
| 6886 | + //-- 秒杀的普通购买 -- | ||
| 6887 | + openSpecModel_Nor: function () { | ||
| 6888 | + this.data.g_buy_num = new Map(); | ||
| 6889 | + var th = this; | ||
| 6890 | + this.setData({open_ind_store: 5, goodsInputNum: 1});//拼团直接给4 | ||
| 6891 | + if (th.data.sku_g_pt) { | ||
| 6892 | + this.get_sto(1) | ||
| 6893 | + this.setData({openSpecModal_flash_normal: 1}); | ||
| 6894 | + } else { | ||
| 6895 | + th.get_sto(1); | ||
| 6896 | + th.get_sku(o.stoid, th.data.data, th.data.gid, 1, function () { | ||
| 6897 | + th.setData({ | ||
| 6898 | + openSpecModal_flash_normal: 1 | ||
| 6899 | + }); | ||
| 6900 | + }); | ||
| 6901 | + } | ||
| 6902 | + this.check_is_youhui(th.data.gid, 1); | ||
| 6903 | + }, | ||
| 6904 | + | ||
| 6905 | + closeSpecModal_flash_normal: function () { | ||
| 6906 | + this.setData({openSpecModal_flash_normal: 0}); | ||
| 6907 | + }, | ||
| 6908 | + | ||
| 6909 | + | ||
| 6910 | + // 预览海报 | ||
| 6911 | + previewPoster() { | ||
| 6912 | + getApp().globalData.no_clear=1; | ||
| 6913 | + wx.previewImage({ | ||
| 6914 | + current: this.data.shareImgPath, // 当前显示图片的http链接 | ||
| 6915 | + urls: [this.data.shareImgPath] ,// 需要预览的图片http链接列表 | ||
| 6916 | + }); | ||
| 6917 | + }, | ||
| 6918 | + | ||
| 6919 | + screenChange:function (e) { | ||
| 6920 | + let fullScreen = e.detail.fullScreen //值true为进入全屏,false为退出全屏 | ||
| 6921 | + if (fullScreen ){ //退出全屏 | ||
| 6922 | + getApp().globalData.no_clear=1; | ||
| 6923 | + this.data.show_video=1; | ||
| 6924 | + } | ||
| 6925 | + }, | ||
| 6926 | + | ||
| 6927 | + click_contact:function () { | ||
| 6928 | + getApp().globalData.no_clear=1; | ||
| 6929 | + }, | ||
| 6930 | + | ||
| 6931 | + //打开客服操作菜单 | ||
| 6932 | + openCS() { | ||
| 6933 | + // 判断会员状态 | ||
| 6934 | + let user_info = getApp().globalData.userInfo; | ||
| 6935 | + if (user_info == null || user_info.mobile == undefined || user_info.mobile == '' || user_info.mobile == null) { | ||
| 6936 | + wx.navigateTo({ | ||
| 6937 | + url: '/pages/togoin/togoin', | ||
| 6938 | + }) | ||
| 6939 | + return false; | ||
| 6940 | + }; | ||
| 6941 | + // csType/在线客服设置: | ||
| 6942 | + // 0关闭(如果有设置热线电话,则显示拨打热线电话)、 | ||
| 6943 | + // 1小程序客服、 | ||
| 6944 | + // 2企业微信客服 | ||
| 6945 | + if(this.data.sys_switch) { | ||
| 6946 | + let csType = this.data.sys_switch.weapp_customertype; | ||
| 6947 | + if(csType == 0) { | ||
| 6948 | + // 拨打电话号码 | ||
| 6949 | + this.contactService(); | ||
| 6950 | + } else { | ||
| 6951 | + this.getTel() | ||
| 6952 | + .then(() => { | ||
| 6953 | + self.setData({ | ||
| 6954 | + hiddenCS: false, | ||
| 6955 | + }); | ||
| 6956 | + }); | ||
| 6957 | + }; | ||
| 6958 | + }; | ||
| 6959 | + | ||
| 6960 | + }, | ||
| 6961 | + | ||
| 6962 | + //关闭客服操作菜单 | ||
| 6963 | + closeCS() { | ||
| 6964 | + this.setData({ | ||
| 6965 | + hiddenCS: true, | ||
| 6966 | + }); | ||
| 6967 | + }, | ||
| 6968 | + | ||
| 6969 | + | ||
| 6970 | + | ||
| 6971 | + | ||
| 6972 | + | ||
| 6973 | + | ||
| 6974 | + | ||
| 6975 | + | ||
| 6976 | +}) |