Commit 12e17a5e5588b07a19498134d94a13edcef0dba7
Merge branch 'test' of http://git.vipzhuang.cn/wxd/MShopWeApp into qa
Showing
39 changed files
with
3028 additions
and
921 deletions
packageA/pages/goodsInfo/goodsInfo.js
... | ... | @@ -27,6 +27,7 @@ Page({ |
27 | 27 | color_type: 0, //线条控制 |
28 | 28 | color_type_one: 0, |
29 | 29 | color_type_two: 1, |
30 | + is_share_text: 1, | |
30 | 31 | |
31 | 32 | gid: "", |
32 | 33 | stoid: o.stoid, |
... | ... | @@ -38,6 +39,8 @@ Page({ |
38 | 39 | data: null, |
39 | 40 | content: "", //商品详情 |
40 | 41 | |
42 | + | |
43 | + | |
41 | 44 | gallery: null, //图片滚动 |
42 | 45 | is_collect: 0, |
43 | 46 | collect_id: 0, |
... | ... | @@ -236,6 +239,8 @@ Page({ |
236 | 239 | th = ee, |
237 | 240 | gid = t.goods_id, |
238 | 241 | first_leader=t.first_leader, |
242 | + prom_type=t.prom_type, | |
243 | + prom_id=t.prom_id, | |
239 | 244 | room_id = t.room_id, |
240 | 245 | room_user_share = t.room_user_share; //如果是会员分享带有room_id的话,那么接下来会员分享就不传room_id |
241 | 246 | |
... | ... | @@ -250,21 +255,27 @@ Page({ |
250 | 255 | var gid_str = decodeURIComponent(t.scene); |
251 | 256 | gid_str=gid_str.split("_"); |
252 | 257 | gid=gid_str[0]; |
253 | - if(gid_str.length>1){ | |
258 | + if(gid_str.length>1 && gid_str[1] && parseInt(gid_str[1])>0){ | |
254 | 259 | first_leader=gid_str[1]; |
255 | 260 | } |
256 | 261 | //-- 如果有room_id的获取 -- |
257 | - if(gid_str.length>2 && gid_str[2]) { | |
262 | + if(gid_str.length>2 && gid_str[2] && parseInt(gid_str[2])>0) { | |
258 | 263 | room_id=gid_str[2]; |
259 | 264 | room_user_share=1; |
260 | 265 | }; |
266 | + | |
267 | + if(gid_str.length>3 && gid_str[3] && parseInt(gid_str[3])>0) { | |
268 | + prom_type=gid_str[3]; | |
269 | + prom_id=gid_str[4]; | |
270 | + } | |
271 | + | |
261 | 272 | }; |
262 | 273 | |
263 | 274 | //-- 设置顶部高度 -- |
264 | 275 | let height= getApp().globalData.navBarHeight; |
265 | 276 | ee.setData({ gid: gid,top_nav:height}); |
266 | 277 | |
267 | - if(first_leader) { | |
278 | + if(first_leader>0) { | |
268 | 279 | getApp().globalData.first_leader=first_leader; |
269 | 280 | //调用接口判断是不是会员 |
270 | 281 | getApp().request.promiseGet("/api/weshop/shoppingGuide/get/"+os.stoid+"/"+first_leader,{}).then(res=>{ |
... | ... | @@ -347,7 +358,37 @@ Page({ |
347 | 358 | } |
348 | 359 | }); |
349 | 360 | |
350 | - }, | |
361 | + //-- 自定义海报 -- | |
362 | + getApp().request.promiseGet("/api/weshop/goods/poster/page", { | |
363 | + data: { store_id: os.stoid, type: 1, is_use: 1 } | |
364 | + }).then(res => { | |
365 | + if (res.data.code == 0 && res.data.data && res.data.data.pageData && res.data.data.pageData[0]) { | |
366 | + | |
367 | + var poster_data = res.data.data.pageData[0]; | |
368 | + var json_str = poster_data.jsonStr; | |
369 | + | |
370 | + if (json_str) { | |
371 | + var json_data = JSON.parse(json_str); | |
372 | + if (json_data.bg_img) { | |
373 | + | |
374 | + //-- 把图片那到本地 -- | |
375 | + wx.getImageInfo({ | |
376 | + src: json_data.bg_img, | |
377 | + success: function (res) { | |
378 | + var path = res.path; | |
379 | + th.setData({ share_b_img: path }) | |
380 | + }, | |
381 | + fail: function (res) { } | |
382 | + }); | |
383 | + } | |
384 | + th.setData({ poster: json_data }) | |
385 | + | |
386 | + } | |
387 | + } | |
388 | + }) | |
389 | + | |
390 | + | |
391 | + }, | |
351 | 392 | |
352 | 393 | //-- 获取直播的分享人的导购信息 -- |
353 | 394 | async get_room_share_guide(share_openid) { |
... | ... | @@ -568,14 +609,13 @@ Page({ |
568 | 609 | // gid 在onload阶段已经保存在this.data中 |
569 | 610 | onShow: function() { |
570 | 611 | |
612 | + getApp().check_can_share(this); | |
571 | 613 | //-- 看一下隐私政策要不要显示 -- |
572 | 614 | var privacy_pop = this.selectComponent("#privacy_pop"); //组件的id |
573 | 615 | if (privacy_pop) { |
574 | 616 | privacy_pop.check_pri_show(); |
575 | 617 | } |
576 | 618 | |
577 | - getApp().check_can_share(); | |
578 | - | |
579 | 619 | var that=this;var th=this; |
580 | 620 | var ee = this,gid = this.data.gid, i = getApp().request; |
581 | 621 | |
... | ... | @@ -1386,6 +1426,9 @@ Page({ |
1386 | 1426 | }, |
1387 | 1427 | |
1388 | 1428 | openSpecModel: function(t) { |
1429 | + | |
1430 | + if(this.data.get_sto_ing) return false; | |
1431 | + | |
1389 | 1432 | var th=this; var open_store = t.currentTarget.dataset.ind; |
1390 | 1433 | if(getApp().is_sp_hao() && open_store==1){ |
1391 | 1434 | wx.showToast({ |
... | ... | @@ -1657,6 +1700,8 @@ Page({ |
1657 | 1700 | }) |
1658 | 1701 | } |
1659 | 1702 | |
1703 | + this.data.get_sto_ing=1; | |
1704 | + | |
1660 | 1705 | var timer_get = setInterval(function() { |
1661 | 1706 | if (th.data.is_get_local_ok == 0) return false; |
1662 | 1707 | if (!th.data.fir_def_store) return false; |
... | ... | @@ -1772,6 +1817,7 @@ Page({ |
1772 | 1817 | th.deal_pickup(e); |
1773 | 1818 | } |
1774 | 1819 | else{ |
1820 | + th.data.get_sto_ing=0; | |
1775 | 1821 | th.setData({ |
1776 | 1822 | isshow:1 |
1777 | 1823 | }) |
... | ... | @@ -1901,160 +1947,162 @@ Page({ |
1901 | 1947 | orderType:'asc', |
1902 | 1948 | }, |
1903 | 1949 | success: function(ee) { |
1904 | - if (ee.data.code == 0) { | |
1905 | - | |
1906 | - var check_all_cate=0; | |
1907 | - if (ee.data.data && ee.data.data.pageData && ee.data.data.pageData.length > 0){ | |
1908 | - for(let i in ee.data.data.pageData){ | |
1909 | - let item=ee.data.data.pageData[i]; | |
1910 | - if(item.is_show==1){ | |
1911 | - check_all_cate=1;break | |
1950 | + if (ee.data.code == 0) { | |
1951 | + | |
1952 | + var check_all_cate=0; | |
1953 | + if (ee.data.data && ee.data.data.pageData && ee.data.data.pageData.length > 0){ | |
1954 | + for(let i in ee.data.data.pageData){ | |
1955 | + let item=ee.data.data.pageData[i]; | |
1956 | + if(item.is_show==1){ | |
1957 | + check_all_cate=1;break | |
1958 | + } | |
1912 | 1959 | } |
1913 | 1960 | } |
1914 | - } | |
1915 | - | |
1916 | - if (check_all_cate) { | |
1917 | - | |
1918 | - | |
1919 | - var sto_cate = ee.data.data.pageData; | |
1920 | - var sto_arr = e.data.data.pageData; | |
1921 | - var newarr = new Array(); | |
1922 | - var qita = new Array(); | |
1923 | - | |
1924 | - var is_del_pk=0; | |
1925 | - | |
1926 | - //----要进行门店分组-------- | |
1927 | - for (var i = 0; i < sto_arr.length; i++) { | |
1928 | - //找一下这个门店有没有在分类数组内 | |
1929 | - var find2 = 0, find2name = "",sort=0; | |
1930 | - is_del_pk=0; | |
1931 | - for (var m = 0; m < sto_cate.length; m++) { | |
1932 | - if (sto_arr[i].category_id == sto_cate[m].cat_id) { | |
1933 | - if (sto_cate[m].is_show != 1) { | |
1934 | - is_del_pk = 1; | |
1935 | - sto_arr.splice(i, 1); | |
1936 | - i--; | |
1937 | - } else { | |
1938 | - find2 = sto_cate[m].cat_id; | |
1939 | - find2name = sto_cate[m].cat_name; | |
1940 | - sort = sto_cate[m].sort; | |
1941 | - is_del_pk = 0; | |
1961 | + | |
1962 | + if (check_all_cate) { | |
1963 | + | |
1964 | + | |
1965 | + var sto_cate = ee.data.data.pageData; | |
1966 | + var sto_arr = e.data.data.pageData; | |
1967 | + var newarr = new Array(); | |
1968 | + var qita = new Array(); | |
1969 | + | |
1970 | + var is_del_pk=0; | |
1971 | + | |
1972 | + //----要进行门店分组-------- | |
1973 | + for (var i = 0; i < sto_arr.length; i++) { | |
1974 | + //找一下这个门店有没有在分类数组内 | |
1975 | + var find2 = 0, find2name = "",sort=0; | |
1976 | + is_del_pk=0; | |
1977 | + for (var m = 0; m < sto_cate.length; m++) { | |
1978 | + if (sto_arr[i].category_id == sto_cate[m].cat_id) { | |
1979 | + if (sto_cate[m].is_show != 1) { | |
1980 | + is_del_pk = 1; | |
1981 | + sto_arr.splice(i, 1); | |
1982 | + i--; | |
1983 | + } else { | |
1984 | + find2 = sto_cate[m].cat_id; | |
1985 | + find2name = sto_cate[m].cat_name; | |
1986 | + sort = sto_cate[m].sort; | |
1987 | + is_del_pk = 0; | |
1988 | + } | |
1989 | + break; | |
1942 | 1990 | } |
1943 | - break; | |
1944 | 1991 | } |
1945 | - } | |
1946 | - if(is_del_pk) continue; | |
1947 | - | |
1948 | - if (newarr.length > 0) { | |
1949 | - var find = 0; | |
1950 | - //如果有找到,那门店就在这个分组内,否则,分类就要排在其他 | |
1951 | - if (find2 != 0) { | |
1952 | - for (var ii = 0; ii < newarr.length; ii++) { | |
1953 | - if (sto_arr[i].category_id == newarr[ii].cat_id) { | |
1954 | - newarr[ii].s_arr.push(sto_arr[i]); | |
1955 | - find = 1; | |
1956 | - break; | |
1992 | + if(is_del_pk) continue; | |
1993 | + | |
1994 | + if (newarr.length > 0) { | |
1995 | + var find = 0; | |
1996 | + //如果有找到,那门店就在这个分组内,否则,分类就要排在其他 | |
1997 | + if (find2 != 0) { | |
1998 | + for (var ii = 0; ii < newarr.length; ii++) { | |
1999 | + if (sto_arr[i].category_id == newarr[ii].cat_id) { | |
2000 | + newarr[ii].s_arr.push(sto_arr[i]); | |
2001 | + find = 1; | |
2002 | + break; | |
2003 | + } | |
2004 | + } | |
2005 | + if (find == 0) { | |
2006 | + var arr0 = new Array(); | |
2007 | + arr0.push(sto_arr[i]); | |
2008 | + var item = { | |
2009 | + cat_id: find2, | |
2010 | + name: find2name, | |
2011 | + sort:sort, | |
2012 | + s_arr: arr0 | |
2013 | + }; | |
2014 | + newarr.push(item); | |
2015 | + } | |
2016 | + } else { | |
2017 | + qita.push(sto_arr[i]); | |
2018 | + } | |
2019 | + } else { | |
2020 | + //如果有找到,那门店就在这个分组内,否则,分类就要排在其他 | |
2021 | + if (find2 != 0) { | |
2022 | + var arr0 = new Array(); | |
2023 | + arr0.push(sto_arr[i]); | |
2024 | + var item = { | |
2025 | + cat_id: find2, | |
2026 | + name: find2name, | |
2027 | + sort:sort, | |
2028 | + s_arr: arr0 | |
2029 | + }; | |
2030 | + newarr.push(item); | |
2031 | + } else { | |
2032 | + qita.push(sto_arr[i]); | |
1957 | 2033 | } |
1958 | 2034 | } |
1959 | - if (find == 0) { | |
1960 | - var arr0 = new Array(); | |
1961 | - arr0.push(sto_arr[i]); | |
1962 | - var item = { | |
1963 | - cat_id: find2, | |
1964 | - name: find2name, | |
1965 | - sort:sort, | |
1966 | - s_arr: arr0 | |
1967 | - }; | |
1968 | - newarr.push(item); | |
2035 | + } | |
2036 | + | |
2037 | + var def_arr = new Array(); | |
2038 | + //-- 开始就看10个门店 -- | |
2039 | + for (var k = 0; k < 10; k++) { | |
2040 | + if (k == sto_arr.length) break; | |
2041 | + def_arr.push(sto_arr[k]); | |
1969 | 2042 | } |
1970 | - } else { | |
1971 | - qita.push(sto_arr[i]); | |
2043 | + | |
2044 | + th.setData({ | |
2045 | + def_pickpu_list: def_arr, | |
2046 | + pickpu_list: ee.data.data.pageData | |
2047 | + }); | |
2048 | + | |
2049 | + //门店分类要排序下 | |
2050 | + function compare(property){ | |
2051 | + return function(a,b){ | |
2052 | + var value1 = a[property]; | |
2053 | + var value2 = b[property]; | |
2054 | + return value1 - value2; | |
2055 | + } | |
1972 | 2056 | } |
1973 | - } else { | |
1974 | - //如果有找到,那门店就在这个分组内,否则,分类就要排在其他 | |
1975 | - if (find2 != 0) { | |
1976 | - var arr0 = new Array(); | |
1977 | - arr0.push(sto_arr[i]); | |
2057 | + if(newarr.length>0) | |
2058 | + newarr.sort(compare("sort")); | |
2059 | + | |
2060 | + //----安排其他的分类----- | |
2061 | + if (qita.length > 0) { | |
1978 | 2062 | var item = { |
1979 | - cat_id: find2, | |
1980 | - name: find2name, | |
1981 | - sort:sort, | |
1982 | - s_arr: arr0 | |
2063 | + cat_id: -1, | |
2064 | + name: "其他", | |
2065 | + s_arr: qita | |
1983 | 2066 | }; |
1984 | 2067 | newarr.push(item); |
1985 | - } else { | |
1986 | - qita.push(sto_arr[i]); | |
1987 | 2068 | } |
1988 | - } | |
1989 | - } | |
1990 | 2069 | |
1991 | - var def_arr = new Array(); | |
1992 | - //-- 开始就看10个门店 -- | |
1993 | - for (var k = 0; k < 10; k++) { | |
1994 | - if (k == sto_arr.length) break; | |
1995 | - def_arr.push(sto_arr[k]); | |
1996 | - } | |
2070 | + var sd={ | |
2071 | + all_sto: newarr, | |
2072 | + is_show_sto_cat:1 | |
2073 | + } | |
2074 | + if(!sto_arr || sto_arr.length<=10){ | |
2075 | + sd.is_show_sto_cat=-1; | |
2076 | + sd.only_pk=sto_arr; | |
2077 | + } | |
2078 | + th.setData(sd); | |
1997 | 2079 | |
2080 | + } else { | |
2081 | + th.setData({ | |
2082 | + is_show_sto_cat: -1, | |
2083 | + only_pk: e.data.data.pageData | |
2084 | + }); | |
2085 | + //-----如果没有默认门店,要取第一个门店作为默认店.此时没有门店分类的情况------ | |
2086 | + if (!th.data.def_pick_store) { | |
2087 | + th.setData({def_pick_store:e.data.data.pageData[0]}) | |
2088 | + } | |
2089 | + } | |
2090 | + } else { | |
1998 | 2091 | th.setData({ |
1999 | - def_pickpu_list: def_arr, | |
2000 | - pickpu_list: ee.data.data.pageData | |
2092 | + is_show_sto_cat: -1, | |
2093 | + only_pk: e.data.data.pageData | |
2001 | 2094 | }); |
2002 | - | |
2003 | - //门店分类要排序下 | |
2004 | - function compare(property){ | |
2005 | - return function(a,b){ | |
2006 | - var value1 = a[property]; | |
2007 | - var value2 = b[property]; | |
2008 | - return value1 - value2; | |
2009 | - } | |
2010 | - } | |
2011 | - if(newarr.length>0) | |
2012 | - newarr.sort(compare("sort")); | |
2013 | - | |
2014 | - //----安排其他的分类----- | |
2015 | - if (qita.length > 0) { | |
2016 | - var item = { | |
2017 | - cat_id: -1, | |
2018 | - name: "其他", | |
2019 | - s_arr: qita | |
2020 | - }; | |
2021 | - newarr.push(item); | |
2022 | - } | |
2023 | - | |
2024 | - var sd={ | |
2025 | - all_sto: newarr, | |
2026 | - is_show_sto_cat:1 | |
2027 | - } | |
2028 | - if(!sto_arr || sto_arr.length<=10){ | |
2029 | - sd.is_show_sto_cat=-1; | |
2030 | - sd.only_pk=sto_arr; | |
2095 | + //-----如果没有默认门店,要取第一个门店作为默认店.此时没有门店分类的情况------ | |
2096 | + if (!th.data.def_pick_store) { | |
2097 | + th.setData({def_pick_store:e.data.data.pageData[0]}) | |
2031 | 2098 | } |
2032 | - th.setData(sd); | |
2033 | - | |
2034 | - } else { | |
2035 | - th.setData({ | |
2036 | - is_show_sto_cat: -1, | |
2037 | - only_pk: e.data.data.pageData | |
2038 | - }); | |
2039 | - //-----如果没有默认门店,要取第一个门店作为默认店.此时没有门店分类的情况------ | |
2040 | - if (!th.data.def_pick_store) { | |
2041 | - th.setData({def_pick_store:e.data.data.pageData[0]}) | |
2042 | 2099 | } |
2043 | - } | |
2044 | - } else { | |
2045 | - th.setData({ | |
2046 | - is_show_sto_cat: -1, | |
2047 | - only_pk: e.data.data.pageData | |
2048 | - }); | |
2049 | - //-----如果没有默认门店,要取第一个门店作为默认店.此时没有门店分类的情况------ | |
2050 | - if (!th.data.def_pick_store) { | |
2051 | - th.setData({def_pick_store:e.data.data.pageData[0]}) | |
2052 | - } | |
2053 | - | |
2054 | - } | |
2100 | + th.data.get_sto_ing=0; | |
2055 | 2101 | } |
2056 | 2102 | }); |
2057 | - } else { | |
2103 | + } else { | |
2104 | + th.data.get_sto_ing=0; | |
2105 | + | |
2058 | 2106 | th.setData({ |
2059 | 2107 | is_show_sto_cat: 0, |
2060 | 2108 | only_pk: e.data.data.pageData |
... | ... | @@ -2092,494 +2140,7 @@ Page({ |
2092 | 2140 | return param < 10 ? '0' + param : param; |
2093 | 2141 | }, |
2094 | 2142 | |
2095 | - | |
2096 | - //--定义的保存图片方法,分享团--- | |
2097 | - saveImageToPhotosAlbum: function() { | |
2098 | - //--先判断会员状态-- | |
2099 | - // var user_info = getApp().globalData.userInfo; | |
2100 | - // if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { | |
2101 | - // //getApp().my_warnning("请先登录",0,this); | |
2102 | - // wx.navigateTo({ url: '/packageE/pages/togoin/togoin', }) | |
2103 | - // return false; | |
2104 | - // } | |
2105 | - | |
2106 | - //类型 0普通商品 1秒杀商品 2商家和会员团 3阶梯团 4阶梯团 | |
2107 | - var type = this.data.prom_type; | |
2108 | - if (type == 6) type = 2; | |
2109 | - if (this.data.prom_act && this.data.prom_act.kttype == 3) type = 3; | |
2110 | 2143 | |
2111 | - wx.showLoading({ | |
2112 | - title: '生成中...', | |
2113 | - }) | |
2114 | - var that = this, | |
2115 | - th = that; | |
2116 | - //设置画板显示,才能开始绘图 | |
2117 | - that.setData({ | |
2118 | - canvasHidden: false | |
2119 | - }) | |
2120 | - | |
2121 | - var app = getApp(); | |
2122 | - var unit = that.data.screenWidth / 750 * 1.35; //基础单位, | |
2123 | - var path2 = that.data.data.original_img; | |
2124 | - var scene = th.data.gid+""; | |
2125 | - var user_id = getApp().globalData.user_id?getApp().globalData.user_id:0; | |
2126 | - if(user_id>0) { | |
2127 | - scene+="_"+user_id; | |
2128 | - } | |
2129 | - //-- 如果不是会员分享过来的要分享给别人 -- | |
2130 | - if(getApp().globalData.room_id && th.data.data.goods_id==getApp().globalData.room_goods_id && !getApp().globalData.room_user_share) { | |
2131 | - //固定房间是第3个字符 | |
2132 | - if(!user_id) scene+="_0"; | |
2133 | - scene+="_"+getApp().globalData.room_id ; | |
2134 | - } | |
2135 | - ///二微码 | |
2136 | - var path3 = os.url + "/api/wx/open/app/user/getWeAppEwm/" + | |
2137 | - os.stoid + "?sceneValue=" + scene + "&pageValue=pages/goods/goodsInfo/goodsInfo"; | |
2138 | - | |
2139 | - console.log(path3); | |
2140 | - | |
2141 | - //读取文件成功则OK-- | |
2142 | - wx.getImageInfo({ | |
2143 | - src: path3, | |
2144 | - success: function(res) { | |
2145 | - //回调写法 | |
2146 | - th.get_head_temp(th.get_goods_temp, function() { | |
2147 | - var vpath = res.path; | |
2148 | - var context = wx.createCanvasContext('share'); | |
2149 | - //先画背景 | |
2150 | - var pg_path = "../../../images/share/share_bg.png"; | |
2151 | - | |
2152 | - // context.fillStyle="#FFFFFF"; | |
2153 | - // context.fillRect(0,0,554 * unit, 899 * unit); | |
2154 | - | |
2155 | - //-- 如果有自定义海报的时候,判断背景的图片 -- | |
2156 | - if(th.data.share_b_img){ | |
2157 | - pg_path=th.data.share_b_img; | |
2158 | - } | |
2159 | - context.drawImage(pg_path, 0, 0, 554 * unit, 899 * unit); | |
2160 | - | |
2161 | - //-- 是自定义海报的情况下 -- | |
2162 | - if(th.data.poster && parseInt(th.data.poster.style)==2) { | |
2163 | - //在线上分享人的情况下 | |
2164 | - if(parseInt(th.data.poster.show_headpic)){ | |
2165 | - //获取坐标 | |
2166 | - var x=parseFloat(th.data.poster.head_x)*2; | |
2167 | - var y=parseFloat(th.data.poster.head_y)*2; | |
2168 | - var x1=(x+90) *unit; | |
2169 | - var y1=(y+50) *unit; | |
2170 | - //--昵称--- | |
2171 | - context.setFontSize(24 * unit) | |
2172 | - context.setFillStyle("black") | |
2173 | - context.fillText(app.globalData.userInfo.nickname, x1, y1); | |
2174 | - var width = 24 * app.globalData.userInfo.nickname.length * unit + 4 * unit; | |
2175 | - //强烈推荐 改许程 | |
2176 | - var tj_path = "../../../images/share/q_tj.png"; | |
2177 | - context.drawImage(tj_path, x1 + width, y1-22*unit, 85 * unit, 30 * unit); | |
2178 | - context.setFontSize(16 * unit) | |
2179 | - context.setLineJoin('round'); //交点设置成圆角 | |
2180 | - context.setFillStyle("white") | |
2181 | - context.fillText('强烈推荐', x1 + width+8*unit, y1-1*unit); | |
2182 | - | |
2183 | - //context.setFillStyle("black") | |
2184 | - //context.setFontSize(24 * unit) | |
2185 | - //context.fillText(getApp().globalData.config.store_name, 40 * unit, 130 * unit); | |
2186 | - } | |
2187 | - } else { | |
2188 | - //--昵称--- | |
2189 | - context.setFontSize(24 * unit) | |
2190 | - context.setFillStyle("black") | |
2191 | - context.fillText(app.globalData.userInfo.nickname, 152 * unit, 76 * unit); | |
2192 | - var width = 24 * app.globalData.userInfo.nickname.length * unit + 2 * unit; | |
2193 | - //强烈推荐 改许程 | |
2194 | - var tj_path = "../../../images/share/q_tj.png"; | |
2195 | - context.drawImage(tj_path, 152 * unit + width, 54 * unit, 85 * unit, 30 * unit); | |
2196 | - context.setFontSize(16 * unit); | |
2197 | - context.setLineJoin('round'); //交点设置成圆角 | |
2198 | - context.setFillStyle("white"); | |
2199 | - context.fillText('强烈推荐', 149 * unit + width + 15 * unit, 75 * unit); | |
2200 | - } | |
2201 | - | |
2202 | - | |
2203 | - //---产品名称--- | |
2204 | - //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 | |
2205 | - if(type!=4){ | |
2206 | - context.setFillStyle("black"); | |
2207 | - context.setFontSize(21.3 * unit) | |
2208 | - th.draw_Text(context, th.data.data.goods_name, | |
2209 | - 38 * unit, 180 * unit, 200 * unit, 279 * unit, unit); | |
2210 | - //------产品的价格------- | |
2211 | - context.setFontSize(23 * unit) | |
2212 | - context.setFillStyle("red") | |
2213 | - context.fillText("¥", 416 * unit, 185 * unit); | |
2214 | - context.setFontSize(31 * unit) | |
2215 | - var pri0 = th.data.data.shop_price; | |
2216 | - if (th.data.prom_act) | |
2217 | - pri0 = th.data.prom_act.price; | |
2218 | - pri0 = parseFloat(pri0).toFixed(2); | |
2219 | - context.fillText(pri0, 438 * unit, 185 * unit); | |
2220 | - //---市场价划掉--- | |
2221 | - context.setFillStyle("gray") | |
2222 | - context.setFontSize(22 * unit) | |
2223 | - context.fillText("¥" + th.data.data.market_price, 426 * unit, 213 * unit); | |
2224 | - context.setStrokeStyle('gray'); | |
2225 | - context.setLineWidth(1 * unit); | |
2226 | - context.moveTo(426 * unit, 206 * unit); | |
2227 | - context.lineTo(510 * unit, 206 * unit); | |
2228 | - context.stroke(); | |
2229 | - | |
2230 | - }else{ | |
2231 | - context.setFillStyle("black"); | |
2232 | - context.setFontSize(21.3 * unit) | |
2233 | - th.draw_Text(context, th.data.data.goods_name, | |
2234 | - 38 * unit, 170 * unit, 20 * unit, 300*unit, unit); | |
2235 | - //------ 产品的价格 ----- | |
2236 | - var pri0 = th.data.prom_act.addmoney; | |
2237 | - var integral=th.data.prom_act.integral; | |
2238 | - var text= ""; | |
2239 | - if(integral){text=integral+"积分"; } | |
2240 | - if(pri0 && integral){ text+="+";} | |
2241 | - if(pri0){ text+="¥"+pri0;} | |
2242 | - | |
2243 | - if(!pri0 && !integral){ text="0积分";} | |
2244 | - context.setFillStyle("red"); | |
2245 | - context.fillText(text, 38 * unit, 235 * unit); | |
2246 | - | |
2247 | - } | |
2248 | - | |
2249 | - //---中间大图--- | |
2250 | - context.drawImage(th.data.share_goods_img, 70 * unit, 250 * unit, 408 * unit, 408 * unit); | |
2251 | - //-------大图后面就不一样了----------- | |
2252 | - switch (type) { | |
2253 | - case 0: //普通商品的展示 | |
2254 | - case 4: | |
2255 | - //中间的几个字 | |
2256 | - if(th.data.poster && parseInt(th.data.poster.style)==2 ){ | |
2257 | - if(parseInt(th.data.poster.show_quality)){ | |
2258 | - var g_path = "../../../images/share/s_gou.png"; | |
2259 | - context.drawImage(g_path, 56 * unit, 670 * unit, 22 * unit, 22 * unit); | |
2260 | - context.setFillStyle("red") | |
2261 | - context.setFontSize(18 * unit) | |
2262 | - context.fillText("正品保证", 84 * unit, 690 * unit); | |
2263 | - | |
2264 | - context.drawImage(g_path, 218 * unit, 670 * unit, 22 * unit, 22 * unit); | |
2265 | - context.setFillStyle("red") | |
2266 | - context.setFontSize(18 * unit) | |
2267 | - context.fillText("纯实体店", 246 * unit, 690 * unit); | |
2268 | - | |
2269 | - context.drawImage(g_path, 388 * unit, 670 * unit, 22 * unit, 22 * unit); | |
2270 | - context.setFillStyle("red") | |
2271 | - context.setFontSize(18 * unit) | |
2272 | - context.fillText("官方验证", 420 * unit, 690 * unit); | |
2273 | - } | |
2274 | - | |
2275 | - }else{ | |
2276 | - var g_path = "../../../images/share/s_gou.png"; | |
2277 | - context.drawImage(g_path, 56 * unit, 670 * unit, 22 * unit, 22 * unit); | |
2278 | - context.setFillStyle("red") | |
2279 | - context.setFontSize(18 * unit) | |
2280 | - context.fillText("正品保证", 84 * unit, 690 * unit); | |
2281 | - | |
2282 | - context.drawImage(g_path, 218 * unit, 670 * unit, 22 * unit, 22 * unit); | |
2283 | - context.setFillStyle("red") | |
2284 | - context.setFontSize(18 * unit) | |
2285 | - context.fillText("纯实体店", 246 * unit, 690 * unit); | |
2286 | - | |
2287 | - context.drawImage(g_path, 388 * unit, 670 * unit, 22 * unit, 22 * unit); | |
2288 | - context.setFillStyle("red") | |
2289 | - context.setFontSize(18 * unit) | |
2290 | - context.fillText("官方验证", 420 * unit, 690 * unit); | |
2291 | - } | |
2292 | - | |
2293 | - | |
2294 | - //---画线--- | |
2295 | - context.setLineWidth(1 * unit) | |
2296 | - context.moveTo(32 * unit, 710 * unit) | |
2297 | - context.lineTo(520 * unit, 710 * unit) | |
2298 | - context.stroke(); | |
2299 | - | |
2300 | - //---文字--- | |
2301 | - context.setFillStyle("black") | |
2302 | - context.setFontSize(22 * unit) | |
2303 | - | |
2304 | - if(type==0){ | |
2305 | - // 原来start ---> | |
2306 | - context.setFontSize(24 * unit) | |
2307 | - context.fillText(th.data.sto_sele_name_1, 40 * unit, 766 * unit); | |
2308 | - | |
2309 | - context.setFontSize(22 * unit) | |
2310 | - context.fillText("优惠乐翻天,精彩就在你身边", 40 * unit, 806 * unit); | |
2311 | - context.fillText("长按识别二维码,立即开始抢购", 40 * unit, 846 * unit); | |
2312 | - | |
2313 | - }else{ | |
2314 | - context.setFontSize(24 * unit) | |
2315 | - context.fillText(th.data.sto_sele_name_1, 40 * unit, 766 * unit); | |
2316 | - context.setFontSize(22 * unit) | |
2317 | - context.fillText("长按识别二维码", 40 * unit, 806 * unit); | |
2318 | - context.fillText("立即开始兑换", 40 * unit, 846 * unit); | |
2319 | - | |
2320 | - | |
2321 | - } | |
2322 | - | |
2323 | - //---二维吗图--- | |
2324 | - //-- 自定义海报 -- | |
2325 | - if(th.data.poster){ | |
2326 | - var erm_x= parseFloat(th.data.poster.ewm_x)*2; | |
2327 | - var erm_y= parseFloat(th.data.poster.ewm_y)*2; | |
2328 | - context.drawImage(vpath, erm_x * unit, erm_y * unit, 120 * unit, 120 * unit); | |
2329 | - }else{ | |
2330 | - //---二维吗图--- | |
2331 | - context.drawImage(vpath, 410 * unit, 726 * unit, 115 * unit, 125 * unit); | |
2332 | - } | |
2333 | - | |
2334 | - break; | |
2335 | - case 1: //秒杀商品的展示 | |
2336 | - //---画线--- | |
2337 | - context.setLineWidth(1 * unit) | |
2338 | - context.moveTo(32 * unit, 670 * unit) | |
2339 | - context.lineTo(520 * unit, 670 * unit) | |
2340 | - context.stroke(); | |
2341 | - | |
2342 | - //画秒杀的图片 | |
2343 | - var miaos_path = '../../../images/share/miao_share.png'; | |
2344 | - context.drawImage(miaos_path, 43 * unit, 700 * unit, 222 * unit, 40 * unit); | |
2345 | - | |
2346 | - context.setFillStyle("black") | |
2347 | - context.setFontSize(24 * unit) | |
2348 | - context.fillText(th.data.sto_sele_name_1, 40 * unit, 786 * unit); | |
2349 | - //---文字--- | |
2350 | - context.setFontSize(22 * unit) | |
2351 | - context.setFillStyle("black") | |
2352 | - context.fillText("特惠好物,限时秒杀", 40 * unit, 826 * unit); | |
2353 | - context.fillText("长按识别二维码,立即开始抢购", 40 * unit, 866 * unit); | |
2354 | - | |
2355 | - | |
2356 | - //---二维吗图--- | |
2357 | - //-- 自定义海报 -- | |
2358 | - if(th.data.poster){ | |
2359 | - var erm_x= parseFloat(th.data.poster.ewm_x)*2; | |
2360 | - var erm_y= parseFloat(th.data.poster.ewm_y)*2; | |
2361 | - context.drawImage(vpath, erm_x * unit, erm_y * unit, 120 * unit, 120 * unit); | |
2362 | - }else{ | |
2363 | - //---二维吗图--- | |
2364 | - context.drawImage(vpath, 420 * unit, 726 * unit, 120 * unit, 120 * unit); | |
2365 | - } | |
2366 | - break; | |
2367 | - | |
2368 | - case 2: //会员团和商家团的展示 | |
2369 | - //---画线--- | |
2370 | - context.setLineWidth(1 * unit) | |
2371 | - context.moveTo(32 * unit, 670 * unit) | |
2372 | - context.lineTo(520 * unit, 670 * unit) | |
2373 | - context.stroke(); | |
2374 | - //---文字--- | |
2375 | - | |
2376 | - context.setFillStyle("black") | |
2377 | - context.setFontSize(24 * unit) | |
2378 | - context.fillText(th.data.sto_sele_name_1, 40 * unit, 720 * unit); | |
2379 | - | |
2380 | - //绘制成团图片 | |
2381 | - var ct_img = "../../../images/share/ct_num.png"; | |
2382 | - context.drawImage(ct_img, 40 * unit, 740 * unit, 120 * unit, 30 * unit); | |
2383 | - var ct_num = th.data.prom_act.ct_num; | |
2384 | - context.setFontSize(14 * unit) | |
2385 | - context.font = 'normal'; | |
2386 | - context.setFillStyle("red") | |
2387 | - if (ct_num < 10) { | |
2388 | - context.fillText(ct_num + "人拼团", 92 * unit, 760 * unit); | |
2389 | - } else { | |
2390 | - context.fillText(ct_num + "人拼团", 86 * unit, 760 * unit); | |
2391 | - } | |
2392 | - context.setFontSize(22 * unit) | |
2393 | - context.fillText("已拼" + th.data.prom_act.buy_num + "份", 166 * unit, 763 * unit); | |
2394 | - | |
2395 | - context.setFillStyle("gray") | |
2396 | - context.fillText("快来和我一起拼团吧!", 40 * unit, 806 * unit); | |
2397 | - context.setFillStyle("black") | |
2398 | - context.font = 'normal bold 18px sans-serif'; | |
2399 | - context.setFontSize(21.3 * unit) | |
2400 | - context.fillText("长按识别二维码,立即参团", 40 * unit, 836 * unit); | |
2401 | - | |
2402 | - | |
2403 | - //---二维吗图--- | |
2404 | - //-- 自定义海报 -- | |
2405 | - if(th.data.poster){ | |
2406 | - var erm_x= parseFloat(th.data.poster.ewm_x)*2; | |
2407 | - var erm_y= parseFloat(th.data.poster.ewm_y)*2; | |
2408 | - context.drawImage(vpath, erm_x * unit, erm_y * unit, 120 * unit, 120 * unit); | |
2409 | - }else{ | |
2410 | - //---二维吗图--- | |
2411 | - context.drawImage(vpath, 420 * unit, 726 * unit, 120 * unit, 120 * unit); | |
2412 | - } | |
2413 | - break | |
2414 | - case 3: //阶梯团的展示 | |
2415 | - //---画线--- | |
2416 | - context.setLineWidth(1 * unit) | |
2417 | - context.moveTo(32 * unit, 670 * unit) | |
2418 | - context.lineTo(520 * unit, 670 * unit) | |
2419 | - context.stroke(); | |
2420 | - //---文字--- | |
2421 | - | |
2422 | - context.setFillStyle("black") | |
2423 | - context.setFontSize(24 * unit) | |
2424 | - context.fillText(th.data.sto_sele_name_1, 40 * unit, 720 * unit); | |
2425 | - | |
2426 | - //---绘制中间阶梯的价格--- | |
2427 | - var list = th.data.prom_act.ct_rylist; | |
2428 | - for (var i = 0; i < list.length; i++) { | |
2429 | - var item = list[i]; | |
2430 | - var wi = i * 90 * unit; | |
2431 | - context.font = 'normal'; | |
2432 | - context.setFontSize(16 * unit) | |
2433 | - context.setFillStyle("red") | |
2434 | - context.fillText("¥", 40 * unit + wi, 756 * unit); | |
2435 | - context.setFontSize(22 * unit) | |
2436 | - var pri = parseFloat(item.price).toFixed(2); | |
2437 | - context.fillText(pri, 56 * unit + wi, 756 * unit); | |
2438 | - context.setFillStyle("gray") | |
2439 | - context.fillText("满" + item.rynum + "人", 40 * unit + wi, 786 * unit); | |
2440 | - } | |
2441 | - //----------------下面部分---------------- | |
2442 | - // context.setFillStyle("gray") | |
2443 | - // context.fillText("快来和我一起拼团吧!", 40 * unit, 830 * unit); | |
2444 | - // context.setFillStyle("black") | |
2445 | - // context.font = 'normal bold 18px sans-serif'; | |
2446 | - // context.setFontSize(22 * unit) | |
2447 | - // context.fillText("长按识别二维码,立即参团", 40 * unit, 860 * unit); | |
2448 | - //context.setFillStyle("gray") | |
2449 | - context.setFillStyle("black") | |
2450 | - context.fillText("快来和我一起拼团吧!", 40 * unit, 820 * unit); | |
2451 | - //context.font = 'normal bold 18px sans-serif'; | |
2452 | - context.setFontSize(22 * unit) | |
2453 | - context.fillText("长按识别二维码,立即参团", 40 * unit, 850 * unit); | |
2454 | - | |
2455 | - | |
2456 | - //-- 自定义海报 -- | |
2457 | - if(th.data.poster){ | |
2458 | - var erm_x= parseFloat(th.data.poster.ewm_x)*2; | |
2459 | - var erm_y= parseFloat(th.data.poster.ewm_y)*2; | |
2460 | - context.drawImage(vpath, erm_x * unit, erm_y * unit, 120 * unit, 120 * unit); | |
2461 | - }else{ | |
2462 | - //---二维吗图--- | |
2463 | - context.drawImage(vpath, 420 * unit, 726 * unit, 120 * unit, 120 * unit); | |
2464 | - } | |
2465 | - break | |
2466 | - | |
2467 | - | |
2468 | - } | |
2469 | - | |
2470 | - | |
2471 | - //--- 如果是自定义海报的时候 --- | |
2472 | - if(th.data.poster && parseInt(th.data.poster.style)==2){ | |
2473 | - | |
2474 | - //如果显示会员信息的话 | |
2475 | - if(parseInt(th.data.poster.show_headpic)){ | |
2476 | - //获取坐标 | |
2477 | - var x= parseFloat(th.data.poster.head_x)*2; | |
2478 | - var y=parseFloat(th.data.poster.head_y)*2; | |
2479 | - //---绘制圆形要放在最后---- | |
2480 | - context.save(); | |
2481 | - context.beginPath(); | |
2482 | - var h_x = x* unit; | |
2483 | - var h_y = y * unit; | |
2484 | - var h_r = 40 * unit; | |
2485 | - var cx = h_x + h_r; | |
2486 | - var cy = h_y + h_r; | |
2487 | - context.arc(cx, cy, h_r, 0, Math.PI * 2, false); | |
2488 | - context.closePath(); | |
2489 | - context.fill(); | |
2490 | - context.clip(); | |
2491 | - context.drawImage(th.data.share_head, h_x, h_y, h_r * 2, h_r * 2); | |
2492 | - context.restore(); | |
2493 | - } | |
2494 | - | |
2495 | - }else{ | |
2496 | - //---绘制圆形要放在最后---- | |
2497 | - context.save(); | |
2498 | - context.beginPath(); | |
2499 | - var h_x = 60 * unit; | |
2500 | - var h_y = 24 * unit; | |
2501 | - var h_r = 40 * unit; | |
2502 | - var cx = h_x + h_r; | |
2503 | - var cy = h_y + h_r; | |
2504 | - context.arc(cx, cy, h_r, 0, Math.PI * 2, false); | |
2505 | - context.closePath(); | |
2506 | - context.fill(); | |
2507 | - context.clip(); | |
2508 | - context.drawImage(th.data.share_head, h_x, h_y, h_r * 2, h_r * 2); | |
2509 | - context.restore(); | |
2510 | - } | |
2511 | - | |
2512 | - | |
2513 | - //把画板内容绘制成图片,并回调 画板图片路径 | |
2514 | - context.draw(false, function() { | |
2515 | - setTimeout(function() { | |
2516 | - wx.canvasToTempFilePath({ | |
2517 | - x: 0, | |
2518 | - y: 0, | |
2519 | - width: 750, | |
2520 | - height: 1217, | |
2521 | - destWidth: 1.2 * 750 * 750 / that.data.screenWidth, | |
2522 | - destHeight: 1.2 * 1217 * 750 / that.data.screenWidth, | |
2523 | - canvasId: 'share', | |
2524 | - success: function(res) { | |
2525 | - that.setData({ | |
2526 | - shareImgPath: res.tempFilePath, | |
2527 | - canvasHidden: true | |
2528 | - }) | |
2529 | - if (!res.tempFilePath) { | |
2530 | - wx.showModal({ | |
2531 | - title: '提示', | |
2532 | - content: '图片绘制中,请稍后重试', | |
2533 | - showCancel: false | |
2534 | - }) | |
2535 | - return false; | |
2536 | - } | |
2537 | - // wx.previewImage({ | |
2538 | - // //将图片预览出来 | |
2539 | - // urls: [that.data.shareImgPath] | |
2540 | - // }); | |
2541 | - that.setData({ | |
2542 | - showPoster: true, | |
2543 | - }); | |
2544 | - wx.hideLoading(); | |
2545 | - } | |
2546 | - }) | |
2547 | - }, 500) | |
2548 | - | |
2549 | - }); | |
2550 | - }); | |
2551 | - } | |
2552 | - }); | |
2553 | - }, | |
2554 | - | |
2555 | - | |
2556 | - //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 | |
2557 | - draw_Text: function(ctx, str, leftWidth, initHeight, titleHeight, canvasWidth, unit) { | |
2558 | - var lineWidth = 0; | |
2559 | - var lastSubStrIndex = 0; //每次开始截取的字符串的索引 | |
2560 | - var han = 0; | |
2561 | - for (let i = 0; i < str.length; i++) { | |
2562 | - if (han == 2) return; | |
2563 | - //lineWidth += ctx.measureText(str[i]).width; | |
2564 | - lineWidth += ut.measureText(str[i], 21.3 * unit); | |
2565 | - if (lineWidth > canvasWidth) { | |
2566 | - han++; | |
2567 | - | |
2568 | - if (han == 2) | |
2569 | - ctx.fillText(str.substring(lastSubStrIndex, i) + '...', leftWidth, initHeight); //绘制截取部分 | |
2570 | - else | |
2571 | - ctx.fillText(str.substring(lastSubStrIndex, i), leftWidth, initHeight); | |
2572 | - | |
2573 | - initHeight += 22; //22为字体的高度 | |
2574 | - lineWidth = 0; | |
2575 | - lastSubStrIndex = i; | |
2576 | - titleHeight += 20; | |
2577 | - } | |
2578 | - if (i == str.length - 1) { //绘制剩余部分 | |
2579 | - ctx.fillText(str.substring(lastSubStrIndex, i + 1), leftWidth, initHeight); | |
2580 | - } | |
2581 | - } | |
2582 | - }, | |
2583 | 2144 | |
2584 | 2145 | // ----视频图片---- |
2585 | 2146 | // 图片计数器 |
... | ... | @@ -2636,7 +2197,7 @@ Page({ |
2636 | 2197 | return false; |
2637 | 2198 | } |
2638 | 2199 | //---获取分享图片的本地地址,头像和商品图片---- |
2639 | - var path2 = getApp().globalData.userInfo.head_pic; | |
2200 | + var path2 = getApp().globalData.userInfo?getApp().globalData.userInfo.head_pic:''; | |
2640 | 2201 | if (path2 == "") { |
2641 | 2202 | ee.data.share_head = "../../../images/share/hui_hear_pic.png"; |
2642 | 2203 | tt(func); |
... | ... | @@ -2657,37 +2218,44 @@ Page({ |
2657 | 2218 | }); |
2658 | 2219 | } |
2659 | 2220 | }, |
2221 | + | |
2660 | 2222 | //--获取商品图片的本地缓存,回调写法-- |
2661 | 2223 | get_goods_temp: function(tt) { |
2662 | - var ee = this; | |
2663 | - if (ee.data.share_goods_img) { | |
2664 | - tt(); | |
2665 | - return false; | |
2666 | - } | |
2667 | - //获取商品是分享图信息 | |
2668 | - wx.getImageInfo({ | |
2669 | - src: ee.data.data.original_img, | |
2670 | - success: function(res) { | |
2671 | - //res.path是网络图片的本地地址 | |
2672 | - ee.data.share_goods_img = res.path; | |
2673 | - tt(); | |
2674 | - }, | |
2675 | - fail: function(res) { | |
2676 | - //获取默认空白图 | |
2677 | - wx.getImageInfo({ | |
2678 | - src: ee.data.iurl+'/miniapp/images/default_g_img.gif', | |
2679 | - success: function(res) { | |
2680 | - ee.data.share_goods_img = res.path; //分享的图片不能用网络的 | |
2681 | - tt(); | |
2682 | - } | |
2683 | - }) | |
2224 | + var ee = this; | |
2225 | + if (ee.data.share_goods_img) { | |
2226 | + tt(); | |
2227 | + return false; | |
2228 | + } | |
2684 | 2229 | |
2685 | - } | |
2686 | - }); | |
2687 | - }, | |
2230 | + var img=ee.data.iurl+ee.data.data.image_url; | |
2231 | + if(ee.data.prom_act && ee.data.prom_act.share_img){ | |
2232 | + img=ee.data.iurl+ee.data.prom_act.share_img; | |
2233 | + } | |
2234 | + | |
2235 | + //获取商品是分享图信息 | |
2236 | + wx.getImageInfo({ | |
2237 | + src: img, | |
2238 | + success: function(res) { | |
2239 | + //res.path是网络图片的本地地址 | |
2240 | + ee.data.share_goods_img = res.path; | |
2241 | + tt(); | |
2242 | + }, | |
2243 | + fail: function(res) { | |
2244 | + //获取默认空白图 | |
2245 | + wx.getImageInfo({ | |
2246 | + src: ee.data.iurl+'/miniapp/images/default_g_img.gif', | |
2247 | + success: function(res) { | |
2248 | + ee.data.share_goods_img = res.path; //分享的图片不能用网络的 | |
2249 | + tt(); | |
2250 | + } | |
2251 | + }) | |
2688 | 2252 | |
2253 | + } | |
2254 | + }); | |
2255 | + }, | |
2689 | 2256 | |
2690 | - //--跳转到商品详情页面-- | |
2257 | + | |
2258 | + //--跳转到商品详情页面-- | |
2691 | 2259 | go_goods: function(e) { |
2692 | 2260 | var gid = e.currentTarget.dataset.gid; |
2693 | 2261 | var url = "/pages/goods/goodsInfo/goodsInfo?goods_id=" + gid; |
... | ... | @@ -2713,12 +2281,12 @@ Page({ |
2713 | 2281 | |
2714 | 2282 | //--先判断会员状态-- |
2715 | 2283 | var user_info = getApp().globalData.userInfo; |
2716 | - if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { | |
2717 | - wx.navigateTo({ | |
2718 | - url: '/packageE/pages/togoin/togoin', | |
2719 | - }) | |
2720 | - return false; | |
2721 | - } | |
2284 | + // if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { | |
2285 | + // wx.navigateTo({ | |
2286 | + // url: '/packageE/pages/togoin/togoin', | |
2287 | + // }) | |
2288 | + // return false; | |
2289 | + // } | |
2722 | 2290 | |
2723 | 2291 | |
2724 | 2292 | //如果开启了,则不在选择门店 |
... | ... | @@ -3673,7 +3241,7 @@ Page({ |
3673 | 3241 | ee.get_normal(gid); |
3674 | 3242 | return false; |
3675 | 3243 | } |
3676 | - | |
3244 | + | |
3677 | 3245 | var t_gd = ee.data.data; |
3678 | 3246 | var prom_end_time = ut.formatTime(t.data.data.end_time, "yyyy-MM-dd hh:mm:ss"); |
3679 | 3247 | var prom_start_time = ut.formatTime(t.data.data.start_time, "yyyy-MM-dd hh:mm:ss"); |
... | ... | @@ -3686,6 +3254,7 @@ Page({ |
3686 | 3254 | prom_act: t.data.data, |
3687 | 3255 | prom_end_time: prom_end_time, |
3688 | 3256 | prom_start_time: prom_start_time, |
3257 | + is_share_text: t.data.data.is_share_text | |
3689 | 3258 | }); |
3690 | 3259 | |
3691 | 3260 | ee.get_sto(); |
... | ... | @@ -3957,6 +3526,8 @@ Page({ |
3957 | 3526 | openSpecModel_Nor: function () { |
3958 | 3527 | var th=this; |
3959 | 3528 | |
3529 | + if(th.data.get_sto_ing) return false; | |
3530 | + | |
3960 | 3531 | // 是否授权登陆 |
3961 | 3532 | var user_info = getApp().globalData.userInfo; |
3962 | 3533 | if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { |
... | ... | @@ -4095,9 +3666,776 @@ Page({ |
4095 | 3666 | }) |
4096 | 3667 | } |
4097 | 3668 | }, |
4098 | - | |
4099 | - | |
4100 | - | |
3669 | + | |
3670 | + clickShare() { | |
3671 | + this.setData({ | |
3672 | + share_hidden: true, | |
3673 | + }); | |
3674 | + }, | |
3675 | + send() { | |
3676 | + this.setData({ | |
3677 | + share_hidden: false, | |
3678 | + }); | |
3679 | + }, | |
3680 | + cancel() { | |
3681 | + this.setData({ | |
3682 | + share_hidden: false, | |
3683 | + }); | |
3684 | + }, | |
3685 | + | |
3686 | + | |
3687 | + saveImageFn(){ | |
3688 | + if(this.data.share_b_img){ | |
3689 | + this.saveImageToPhotosAlbum() | |
3690 | + }else{ | |
3691 | + this.saveImageToPhotosAlbumDef() | |
3692 | + } | |
3693 | + }, | |
3694 | + | |
3695 | + | |
3696 | + //--定义的保存图片方法,分享团--- | |
3697 | + saveImageToPhotosAlbum: function () { | |
3698 | + //--先判断会员状态-- | |
3699 | + // var user_info = getApp().globalData.userInfo; | |
3700 | + // if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { | |
3701 | + // //getApp().my_warnning("请先登录",0,this); | |
3702 | + // wx.navigateTo({ url: '/packageE/pages/togoin/togoin', }) | |
3703 | + // return false; | |
3704 | + // } | |
3705 | + | |
3706 | + if (this.data.share_hidden) { | |
3707 | + this.setData({ | |
3708 | + share_hidden: false, | |
3709 | + }); | |
3710 | + }; | |
3711 | + | |
3712 | + //类型 0普通商品 1秒杀商品 2商家和会员团 3阶梯团 4阶梯团 | |
3713 | + var type = this.data.prom_type || 0; | |
3714 | + console.log('商品类型-----'); | |
3715 | + console.log(type); | |
3716 | + // if (type == 2) type = -1; | |
3717 | + if (type == 4) type = 0; | |
3718 | + if (type == 8) type = 0; | |
3719 | + if (type == 2) type = 0; | |
3720 | + if (type == 6) type = 2; // 6拼团 2团购 | |
3721 | + if (type == 10) type = -1; | |
3722 | + | |
3723 | + wx.showLoading({ | |
3724 | + title: '生成中...', | |
3725 | + }) | |
3726 | + var that = this, | |
3727 | + th = that; | |
3728 | + //设置画板显示,才能开始绘图 | |
3729 | + that.setData({ | |
3730 | + canvasHidden: false | |
3731 | + }) | |
3732 | + | |
3733 | + var app = getApp(); | |
3734 | + var unit = that.data.screenWidth / 750 * 1.35; //基础单位, | |
3735 | + var path2 = that.data.data.original_img; | |
3736 | + | |
3737 | + var scene = th.data.gid; | |
3738 | + var user_id = getApp().globalData.user_id ? getApp().globalData.user_id : 0; | |
3739 | + if (user_id > 0) { | |
3740 | + scene += "_" + user_id; | |
3741 | + } | |
3742 | + //-- 如果不是会员分享过来的要分享给别人 -- | |
3743 | + if (getApp().globalData.room_id && th.data.data.goods_id == getApp().globalData.room_goods_id && !getApp().globalData.room_user_share) { | |
3744 | + //固定房间是第3个字符 | |
3745 | + if (!user_id) scene += "_0"; | |
3746 | + scene += "_" + getApp().globalData.room_id; | |
3747 | + }else{ | |
3748 | + if (!user_id) scene += "_0"; | |
3749 | + scene += "_0"; | |
3750 | + } | |
3751 | + if(this.data.prom_type){ | |
3752 | + scene += "_" + this.data.prom_type+"_"+th.data.prom_id; | |
3753 | + } | |
3754 | + | |
3755 | + | |
3756 | + ///二微码 | |
3757 | + var path3 = os.url + "/api/wx/open/app/user/getWeAppEwm/" + | |
3758 | + os.stoid + "?sceneValue=" + scene + "&pageValue=packageA/pages/goodsInfo/goodsInfo"; | |
3759 | + | |
3760 | + | |
3761 | + console.log(path3); | |
3762 | + | |
3763 | + //读取文件成功则OK-- | |
3764 | + wx.getImageInfo({ | |
3765 | + src: path3, | |
3766 | + success: function (res) { | |
3767 | + //回调写法 | |
3768 | + th.get_head_temp(th.get_goods_temp, function () { | |
3769 | + var vpath = res.path; | |
3770 | + var context = wx.createCanvasContext('share'); | |
3771 | + //先画背景 | |
3772 | + var pg_path = "../../../images/share/share_bg.png"; | |
3773 | + | |
3774 | + //-- 如果有自定义海报的时候,判断背景的图片 -- | |
3775 | + if (th.data.share_b_img) { | |
3776 | + pg_path = th.data.share_b_img; | |
3777 | + } | |
3778 | + context.drawImage(pg_path, 0, 0, 554 * unit, 899 * unit); | |
3779 | + | |
3780 | + let nick=app.globalData.userInfo?app.globalData.userInfo.nickname:''; | |
3781 | + | |
3782 | + //-- 是自定义海报的情况下 -- | |
3783 | + if (th.data.poster && parseInt(th.data.poster.style) == 2) { | |
3784 | + //在线上分享人的情况下 | |
3785 | + if (parseInt(th.data.poster.show_headpic)) { | |
3786 | + //获取坐标 | |
3787 | + var x = parseFloat(th.data.poster.head_x) * 2; | |
3788 | + var y = parseFloat(th.data.poster.head_y) * 2; | |
3789 | + var x1 = (x + 90) * unit; | |
3790 | + var y1 = (y + 50) * unit; | |
3791 | + //--昵称--- | |
3792 | + context.setFontSize(24 * unit) | |
3793 | + context.setFillStyle("black") | |
3794 | + context.fillText(nick, x1, y1); | |
3795 | + var width = 24 * nick.length * unit + 4 * unit; | |
3796 | + //强烈推荐 改许程 | |
3797 | + var tj_path = "../../../images/share/q_tj.png"; | |
3798 | + context.drawImage(tj_path, x1 + width, y1 - 22 * unit, 85 * unit, 30 * unit); | |
3799 | + context.setFontSize(16 * unit) | |
3800 | + context.setLineJoin('round'); //交点设置成圆角 | |
3801 | + context.setFillStyle("white") | |
3802 | + context.fillText('强烈推荐', x1 + width + 8 * unit, y1 - 1 * unit); | |
3803 | + | |
3804 | + //context.setFillStyle("black") | |
3805 | + //context.setFontSize(24 * unit) | |
3806 | + //context.fillText(getApp().globalData.config.store_name, 40 * unit, 130 * unit); | |
3807 | + } | |
3808 | + } else { | |
3809 | + //--昵称--- | |
3810 | + context.setFontSize(24 * unit) | |
3811 | + context.setFillStyle("black") | |
3812 | + context.fillText(nick, 152 * unit, 76 * unit); | |
3813 | + var width = 24 * nick.length * unit + 2 * unit; | |
3814 | + //强烈推荐 改许程 | |
3815 | + var tj_path = "../../../images/share/q_tj.png"; | |
3816 | + context.drawImage(tj_path, 152 * unit + width, 54 * unit, 85 * unit, 30 * unit); | |
3817 | + context.setFontSize(16 * unit); | |
3818 | + context.setLineJoin('round'); //交点设置成圆角 | |
3819 | + context.setFillStyle("white"); | |
3820 | + context.fillText('强烈推荐', 149 * unit + width + 15 * unit, 75 * unit); | |
3821 | + } | |
3822 | + | |
3823 | + var share_title = th.data.data.goods_name; | |
3824 | + | |
3825 | + if (th.data.prom_type == 1 || th.data.prom_type == 2 || th.data.prom_type == 6 || th.data.prom_type == 4) { | |
3826 | + share_title = th.data.prom_act.share_title; | |
3827 | + if (!share_title) share_title = th.data.prom_act.title; | |
3828 | + if (th.data.prom_type == 4) share_title = th.data.prom_act.name; | |
3829 | + | |
3830 | + //-- 显示活动时间 -- | |
3831 | + if (th.data.share_b_img) { | |
3832 | + act_time = "截止时间:" + ut.formatTime(th.data.prom_act.end_time); | |
3833 | + } | |
3834 | + } | |
3835 | + | |
3836 | + //---产品名称--- | |
3837 | + //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 | |
3838 | + | |
3839 | + context.setFillStyle("black"); | |
3840 | + context.setFontSize(21.3 * unit) | |
3841 | + th.draw_Text(context, share_title, | |
3842 | + 80 * unit, 160 * unit, 200 * unit, 279 * unit, unit); | |
3843 | + | |
3844 | + //------产品的价格------- | |
3845 | + context.setFontSize(23 * unit) | |
3846 | + context.setFillStyle("red") | |
3847 | + | |
3848 | + // 7.商品价格 | |
3849 | + let price = th.data.data.shop_price; | |
3850 | + if (th.data.card_field && th.data.data[th.data.card_field]) { | |
3851 | + price = th.data.data[th.data.card_field]; | |
3852 | + } | |
3853 | + if (th.data.prom_act) price = th.data.prom_price; | |
3854 | + price = parseFloat(price).toFixed(2); | |
3855 | + | |
3856 | + var wd1 = th.data.screenWidth - ut.measureText(price, 31 * unit) - 25; | |
3857 | + context.fillText("¥", wd1 - 15, 160 * unit); | |
3858 | + context.setFontSize(31 * unit) | |
3859 | + context.fillText(price, wd1, 165 * unit); | |
3860 | + | |
3861 | + //---市场价划掉--- | |
3862 | + // context.setFillStyle("red") | |
3863 | + // context.setFontSize(22 * unit) | |
3864 | + // pri0 = "¥" + th.data.data.market_price.toFixed(2); | |
3865 | + // var wd2 = th.data.screenWidth - ut.measureText(pri0, 22 * unit) - 25; | |
3866 | + | |
3867 | + | |
3868 | + | |
3869 | + // context.setStrokeStyle('gray'); | |
3870 | + // context.fillText(pri0, wd2, 213 * unit); | |
3871 | + // context.setLineWidth(1 * unit); | |
3872 | + // context.moveTo(wd2 - 5, 206 * unit); | |
3873 | + // context.lineTo(wd2 + ut.measureText(pri0, 22 * unit) + 5, 206 * unit); | |
3874 | + // context.stroke(); | |
3875 | + | |
3876 | + //-- 零售价的优化 -- | |
3877 | + var wp = wd1; | |
3878 | + var hp = 203 * unit; | |
3879 | + if (th.data.prom_type != 4) wp -= 12; | |
3880 | + th.draw_pos_price(context,wp,hp,th.data.data.show_price,unit); | |
3881 | + | |
3882 | + | |
3883 | + //console.log(th.data.share_goods_img); | |
3884 | + //let share_goods_img=th.data.presellForm.share_img; | |
3885 | + //share_goods_img?share_goods_img:th.data.data.share_goods_img; | |
3886 | + //---中间大图--- | |
3887 | + context.drawImage(th.data.share_goods_img, 70 * unit, 220 * unit, 408 * unit, 408 * unit); | |
3888 | + //---自定义海报 产品质量保证 | |
3889 | + if(th.data.poster.show_quality==1 ){ | |
3890 | + var g_path = "../../../images/share/s_gou.png"; | |
3891 | + context.drawImage(g_path, 56 * unit, 644 * unit, 22 * unit, 22 * unit); | |
3892 | + context.setFillStyle("red") | |
3893 | + context.setFontSize(18 * unit) | |
3894 | + context.fillText("正品保证", 84 * unit, 664 * unit); | |
3895 | + | |
3896 | + context.drawImage(g_path, 218 * unit, 644 * unit, 22 * unit, 22 * unit); | |
3897 | + context.setFillStyle("red") | |
3898 | + context.setFontSize(18 * unit) | |
3899 | + context.fillText("纯实体店", 246 * unit, 664 * unit); | |
3900 | + | |
3901 | + context.drawImage(g_path, 388 * unit, 644 * unit, 22 * unit, 22 * unit); | |
3902 | + context.setFillStyle("red") | |
3903 | + context.setFontSize(18 * unit) | |
3904 | + context.fillText("官方验证", 420 * unit, 664 * unit); | |
3905 | + | |
3906 | + } | |
3907 | + | |
3908 | + //---画线--- | |
3909 | + // context.setLineWidth(1 * unit) | |
3910 | + // context.moveTo(32 * unit, 662 * unit) | |
3911 | + // context.lineTo(520 * unit, 662 * unit) | |
3912 | + // context.stroke(); | |
3913 | + | |
3914 | + //-- 图片底部文字 -- | |
3915 | + switch (type){ | |
3916 | + case 0: | |
3917 | + //---文字--- | |
3918 | + //---文字--- | |
3919 | + context.setFillStyle("black"); | |
3920 | + context.setFontSize(22 * unit); | |
3921 | + | |
3922 | + context.fillText("优惠乐翻天,精彩就在你身边", 40 * unit, 776 * unit); | |
3923 | + context.fillText("长按识别二维码,立即开始抢购", 40 * unit, 826 * unit); | |
3924 | + | |
3925 | + break; | |
3926 | + | |
3927 | + case 1: | |
3928 | + | |
3929 | + //画秒杀的图片 | |
3930 | + if (th.data.is_share_text) { | |
3931 | + var miaos_path = '../../../images/share/miao_share.png'; | |
3932 | + context.drawImage(miaos_path, 43 * unit, 690 * unit, 222 * unit, 40 * unit); | |
3933 | + } | |
3934 | + | |
3935 | + context.setFillStyle("black") | |
3936 | + context.setFontSize(24 * unit) | |
3937 | + context.fillText(th.data.sto_sele_name_1, 40 * unit, 770 * unit); | |
3938 | + //---文字--- | |
3939 | + context.setFontSize(22 * unit) | |
3940 | + context.setFillStyle("black") | |
3941 | + if (th.data.is_share_text) { | |
3942 | + context.fillText("特惠好物,限时秒杀", 40 * unit, 807 * unit); | |
3943 | + } | |
3944 | + context.fillText("长按识别二维码,立即开始抢购", 40 * unit, 844 * unit); | |
3945 | + | |
3946 | + break; | |
3947 | + | |
3948 | + } | |
3949 | + | |
3950 | + | |
3951 | + | |
3952 | + //---二维吗图--- | |
3953 | + //-- 自定义海报 -- | |
3954 | + if (th.data.poster) { | |
3955 | + var erm_x = parseFloat(th.data.poster.ewm_x) * 2; | |
3956 | + var erm_y = parseFloat(th.data.poster.ewm_y) * 2; | |
3957 | + context.drawImage(vpath, erm_x * unit, erm_y * unit, 136 * unit, 136 * unit); | |
3958 | + } else { | |
3959 | + //---二维吗图--- | |
3960 | + context.drawImage(vpath, 390 * unit, 746 * unit, 130 * unit, 116 * unit); | |
3961 | + } | |
3962 | + | |
3963 | + //--- 如果是自定义海报的时候 --- | |
3964 | + if (th.data.poster && parseInt(th.data.poster.style) == 2) { | |
3965 | + | |
3966 | + //如果显示会员信息的话 | |
3967 | + if (parseInt(th.data.poster.show_headpic)) { | |
3968 | + //获取坐标 | |
3969 | + var x = parseFloat(th.data.poster.head_x) * 2; | |
3970 | + var y = parseFloat(th.data.poster.head_y) * 2; | |
3971 | + //---绘制圆形要放在最后---- | |
3972 | + context.save(); | |
3973 | + context.beginPath(); | |
3974 | + var h_x = x * unit; | |
3975 | + var h_y = y * unit; | |
3976 | + var h_r = 40 * unit; | |
3977 | + var cx = h_x + h_r; | |
3978 | + var cy = h_y + h_r; | |
3979 | + context.arc(cx, cy, h_r, 0, Math.PI * 2, false); | |
3980 | + context.closePath(); | |
3981 | + context.fill(); | |
3982 | + context.clip(); | |
3983 | + context.drawImage(th.data.share_head, h_x, h_y, h_r * 2, h_r * 2); | |
3984 | + context.restore(); | |
3985 | + } | |
3986 | + | |
3987 | + } else { | |
3988 | + //---绘制圆形要放在最后---- | |
3989 | + context.save(); | |
3990 | + context.beginPath(); | |
3991 | + var h_x = 60 * unit; | |
3992 | + var h_y = 24 * unit; | |
3993 | + var h_r = 40 * unit; | |
3994 | + var cx = h_x + h_r; | |
3995 | + var cy = h_y + h_r; | |
3996 | + context.arc(cx, cy, h_r, 0, Math.PI * 2, false); | |
3997 | + context.closePath(); | |
3998 | + context.fill(); | |
3999 | + context.clip(); | |
4000 | + context.drawImage(th.data.share_head, h_x, h_y, h_r * 2, h_r * 2); | |
4001 | + context.restore(); | |
4002 | + } | |
4003 | + | |
4004 | + | |
4005 | + if(th.data.poster.show_time==1 && th.data.prom_act){ | |
4006 | + var act_time=''; | |
4007 | + act_time="截止时间:"+ ut.formatTime(th.data.prom_act.end_time); | |
4008 | + context.setFillStyle("red") | |
4009 | + getApp().draw_Text(context, act_time,38 * unit, 880 * unit, 200 * unit, 340 * unit, unit); | |
4010 | + } | |
4011 | + | |
4012 | + //把画板内容绘制成图片,并回调 画板图片路径 | |
4013 | + context.draw(false, function () { | |
4014 | + setTimeout(function () { | |
4015 | + wx.canvasToTempFilePath({ | |
4016 | + x: 0, | |
4017 | + y: 0, | |
4018 | + width: 750, | |
4019 | + height: 1217, | |
4020 | + destWidth: 1.2 * 750 * 750 / that.data.screenWidth, | |
4021 | + destHeight: 1.2 * 1217 * 750 / that.data.screenWidth, | |
4022 | + canvasId: 'share', | |
4023 | + success: function (res) { | |
4024 | + | |
4025 | + that.setData({ | |
4026 | + shareImgPath: res.tempFilePath, | |
4027 | + canvasHidden: true | |
4028 | + }) | |
4029 | + | |
4030 | + if (!res.tempFilePath) { | |
4031 | + wx.showModal({ | |
4032 | + title: '提示', | |
4033 | + content: '图片绘制中,请稍后重试', | |
4034 | + showCancel: false | |
4035 | + }) | |
4036 | + return false; | |
4037 | + } | |
4038 | + | |
4039 | + // wx.previewImage({ | |
4040 | + // //将图片预览出来 | |
4041 | + // urls: [that.data.shareImgPath] | |
4042 | + // }); | |
4043 | + that.setData({ | |
4044 | + showPoster: true, | |
4045 | + }); | |
4046 | + wx.hideLoading(); | |
4047 | + } | |
4048 | + }) | |
4049 | + }, 500) | |
4050 | + | |
4051 | + }); | |
4052 | + }); | |
4053 | + }, | |
4054 | + fail: function (res) { | |
4055 | + console.log(res); | |
4056 | + wx.hideLoading(); | |
4057 | + | |
4058 | + } | |
4059 | + }); | |
4060 | + }, | |
4061 | + //--定义的保存图片方法,分享团--- | |
4062 | + saveImageToPhotosAlbumDef: function () { | |
4063 | + //--先判断会员状态-- | |
4064 | + // var user_info = getApp().globalData.userInfo; | |
4065 | + // if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { | |
4066 | + // //getApp().my_warnning("请先登录",0,this); | |
4067 | + // wx.navigateTo({url: '/packageE/pages/togoin/togoin',}) | |
4068 | + // return false; | |
4069 | + // } | |
4070 | + | |
4071 | + if (this.data.share_hidden) { | |
4072 | + this.setData({share_hidden: false,}); | |
4073 | + }; | |
4074 | + | |
4075 | + //类型 0普通商品 1秒杀商品 2商家和会员团 3阶梯团 4阶梯团 | |
4076 | + var type = this.data.prom_type || 0; | |
4077 | + console.log('商品类型-----'); | |
4078 | + console.log(type); | |
4079 | + // if (type == 2) type = -1; | |
4080 | + if (type == 4) type = 0; | |
4081 | + if (type == 8) type = 0; | |
4082 | + if (type == 2) type = 0; | |
4083 | + if (type == 6) type = 2; // 6拼团 2团购 | |
4084 | + if (type == 10) type = -1; | |
4085 | + | |
4086 | + if (this.data.prom_act && this.data.prom_act.kttype == 3) type = 3; | |
4087 | + console.log('商品类型。。。。。'); | |
4088 | + console.log(type); | |
4089 | + wx.showLoading({title: '生成中...',}) | |
4090 | + var that = this, th = that; | |
4091 | + //设置画板显示,才能开始绘图 | |
4092 | + that.setData({ | |
4093 | + canvasHidden: false | |
4094 | + }) | |
4095 | + | |
4096 | + var app = getApp(); | |
4097 | + var unit = that.data.screenWidth / 750 * 1.35; //基础单位, | |
4098 | + var path2 = that.data.data.original_img; | |
4099 | + | |
4100 | + var scene = th.data.gid; | |
4101 | + var user_id = getApp().globalData.user_id ? getApp().globalData.user_id : 0; | |
4102 | + if (user_id > 0) { | |
4103 | + scene += "_" + user_id; | |
4104 | + } | |
4105 | + //-- 如果不是会员分享过来的要分享给别人 -- | |
4106 | + if (getApp().globalData.room_id && th.data.data.goods_id == getApp().globalData.room_goods_id && !getApp().globalData.room_user_share) { | |
4107 | + //固定房间是第3个字符 | |
4108 | + if (!user_id) scene += "_0"; | |
4109 | + scene += "_" + getApp().globalData.room_id; | |
4110 | + }else{ | |
4111 | + if (!user_id) scene += "_0"; | |
4112 | + scene += "_0"; | |
4113 | + } | |
4114 | + if(this.data.prom_type){ | |
4115 | + scene += "_" + this.data.prom_type+"_"+th.data.prom_id; | |
4116 | + } | |
4117 | + | |
4118 | + ///二微码 | |
4119 | + var path3 = os.url + "/api/wx/open/app/user/getWeAppEwm/" + | |
4120 | + os.stoid + "?sceneValue=" + scene + "&pageValue=packageA/pages/goodsInfo/goodsInfo"; | |
4121 | + | |
4122 | + console.log(path3); | |
4123 | + | |
4124 | + | |
4125 | + // 读取文件成功则OK-- | |
4126 | + wx.getImageInfo({ | |
4127 | + src: path3, | |
4128 | + success: function (res) { | |
4129 | + // 回调写法 | |
4130 | + th.get_head_temp(th.get_goods_temp, function () { | |
4131 | + var vpath = res.path; | |
4132 | + var context = wx.createCanvasContext('share'); | |
4133 | + // 先画背景 | |
4134 | + var pg_path = "../../../../images/share/share_bg.png"; | |
4135 | + th.drawPoster(context, unit, th.data.share_goods_img, vpath, type); | |
4136 | + | |
4137 | + //把画板内容绘制成图片,并回调 画板图片路径 | |
4138 | + context.draw(false, function () { | |
4139 | + setTimeout(function () { | |
4140 | + wx.canvasToTempFilePath({ | |
4141 | + x: 0, | |
4142 | + y: 0, | |
4143 | + width: 750, | |
4144 | + height: 1217, | |
4145 | + destWidth: 1.2 * 750 * 750 / that.data.screenWidth, | |
4146 | + destHeight: 1.2 * 1217 * 750 / that.data.screenWidth, | |
4147 | + canvasId: 'share', | |
4148 | + success: function (res) { | |
4149 | + | |
4150 | + that.setData({ | |
4151 | + shareImgPath: res.tempFilePath, | |
4152 | + canvasHidden: true | |
4153 | + }) | |
4154 | + | |
4155 | + if (!res.tempFilePath) { | |
4156 | + wx.showModal({ | |
4157 | + title: '提示', | |
4158 | + content: '图片绘制中,请稍后重试', | |
4159 | + showCancel: false | |
4160 | + }) | |
4161 | + return false; | |
4162 | + } | |
4163 | + | |
4164 | + that.setData({ | |
4165 | + showPoster: true, | |
4166 | + }); | |
4167 | + wx.hideLoading(); | |
4168 | + } | |
4169 | + }) | |
4170 | + }, 500) | |
4171 | + | |
4172 | + }); | |
4173 | + }); | |
4174 | + }, | |
4175 | + fail: function (res) { | |
4176 | + console.log(res); | |
4177 | + wx.hideLoading(); | |
4178 | + | |
4179 | + } | |
4180 | + }); | |
4181 | + }, | |
4182 | + | |
4183 | + //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 | |
4184 | + draw_Text: function (ctx, str, leftWidth, initHeight, titleHeight, canvasWidth, unit) { | |
4185 | + var lineWidth = 0; | |
4186 | + var lastSubStrIndex = 0; //每次开始截取的字符串的索引 | |
4187 | + var han = 0; | |
4188 | + for (let i = 0; i < str.length; i++) { | |
4189 | + if (han == 2) return; | |
4190 | + //lineWidth += ctx.measureText(str[i]).width; | |
4191 | + lineWidth += ut.measureText(str[i], 21.3 * unit); | |
4192 | + if (lineWidth > canvasWidth) { | |
4193 | + han++; | |
4194 | + | |
4195 | + if (han == 2) | |
4196 | + ctx.fillText(str.substring(lastSubStrIndex, i) + '...', leftWidth, initHeight); //绘制截取部分 | |
4197 | + else | |
4198 | + ctx.fillText(str.substring(lastSubStrIndex, i), leftWidth, initHeight); | |
4199 | + | |
4200 | + initHeight += 22; //22为字体的高度 | |
4201 | + lineWidth = 0; | |
4202 | + lastSubStrIndex = i; | |
4203 | + titleHeight += 20; | |
4204 | + } | |
4205 | + if (i == str.length - 1) { //绘制剩余部分 | |
4206 | + ctx.fillText(str.substring(lastSubStrIndex, i + 1), leftWidth, initHeight); | |
4207 | + } | |
4208 | + } | |
4209 | + }, | |
4210 | + | |
4211 | + drawPoster(context, unit, img, vpath, type) { | |
4212 | + // 1.灰色背景 | |
4213 | + context.setFillStyle('#f2f1f6'); | |
4214 | + context.rect(0, 0, 554 * unit, 899 * unit); | |
4215 | + context.fill(); | |
4216 | + | |
4217 | + // 2.商城名称 | |
4218 | + let shopName = this.data.sto_sele_name_1; | |
4219 | + context.setTextAlign('center'); | |
4220 | + context.setFontSize(26 * unit); | |
4221 | + context.setFillStyle('black'); | |
4222 | + context.fillText(shopName, 277 * unit, 60 * unit); | |
4223 | + | |
4224 | + // 3.推荐来源 | |
4225 | + if(getApp().globalData.userInfo) { | |
4226 | + let fromText = `来自${getApp().globalData.userInfo.nickname}的推荐`; | |
4227 | + context.setTextAlign('center'); | |
4228 | + context.setFontSize(22 * unit); | |
4229 | + context.setFillStyle('#96959a'); | |
4230 | + context.fillText(fromText, 277 * unit, 105 * unit); | |
4231 | + } | |
4232 | + // 4.海报背景 | |
4233 | + context.setFillStyle('white'); | |
4234 | + context.fillRect(37 * unit, 157 * unit, 480 * unit, 673 * unit); | |
4235 | + | |
4236 | + // 5.商品图片 | |
4237 | + // 图片的x坐标 | |
4238 | + let bg_x = 37 * unit | |
4239 | + // 图片的y坐标 | |
4240 | + let bg_y = 157 * unit | |
4241 | + // 图片宽度 | |
4242 | + let bg_w = 480 * unit | |
4243 | + // 图片高度 | |
4244 | + let bg_h = 474 * unit | |
4245 | + // 图片圆角 | |
4246 | + let bg_r = 4 | |
4247 | + // 绘制海报背景图片圆角 | |
4248 | + context.save() | |
4249 | + context.beginPath() | |
4250 | + context.arc(bg_x + bg_r, bg_y + bg_r, bg_r, Math.PI, Math.PI * 1.5) | |
4251 | + context.arc(bg_x + bg_w - bg_r, bg_y + bg_r, bg_r, Math.PI * 1.5, Math.PI * 2) | |
4252 | + context.arc(bg_x + bg_w, bg_y + bg_h, bg_r, 0, Math.PI * 0.5) | |
4253 | + context.arc(bg_x, bg_y + bg_h, 0, Math.PI * 0.5, Math.PI) | |
4254 | + context.clip() | |
4255 | + context.drawImage(img, bg_x, bg_y, bg_w, bg_h); | |
4256 | + context.restore(); | |
4257 | + | |
4258 | + // 6.强烈推荐 | |
4259 | + let src = ''; | |
4260 | + context.beginPath(); | |
4261 | + if (type == 0) { // 普通 | |
4262 | + src = '../../../images/share/q_tj.png'; | |
4263 | + context.drawImage(src, 54 * unit, 648 * unit, 85 * unit, 30 * unit); | |
4264 | + context.setFontSize(16 * unit) | |
4265 | + context.setFillStyle("white") | |
4266 | + context.setTextAlign('left'); | |
4267 | + context.fillText('强烈推荐', 64 * unit, 668 * unit); | |
4268 | + } | |
4269 | + if (type == 1) { // 秒杀 | |
4270 | + | |
4271 | + if (this.data.is_share_text == 1) { | |
4272 | + src = '../../../images/share/miao_share.png'; | |
4273 | + context.drawImage(src, 54 * unit, 648 * unit, 200 * unit, 36 * unit); | |
4274 | + } | |
4275 | + context.setTextAlign('left'); | |
4276 | + } | |
4277 | + | |
4278 | + | |
4279 | + // 7.商品价格 | |
4280 | + let price = this.data.data.shop_price; | |
4281 | + if (this.data.card_field && this.data.data[this.data.card_field]) { | |
4282 | + price = this.data.data[this.data.card_field]; | |
4283 | + } | |
4284 | + if (this.data.prom_act) price = this.data.prom_price; | |
4285 | + price = parseFloat(price).toFixed(2); | |
4286 | + context.setFontSize(32 * unit); | |
4287 | + context.setFillStyle('#DE1117'); | |
4288 | + | |
4289 | + //price = this.data.presellList.presell_price | |
4290 | + context.fillText('¥' + price, 54 * unit, 735 * unit); | |
4291 | + //-- 零售价的优化 -- | |
4292 | + var wp= 62 * unit+ut.measureText('¥' + price, 32 * unit); | |
4293 | + var hp=735 * unit | |
4294 | + this.draw_pos_price(context,wp,hp,this.data.data.show_price,unit); | |
4295 | + | |
4296 | + | |
4297 | + // 8.商品标题 | |
4298 | + context.setFontSize(20 * unit); | |
4299 | + context.setFillStyle('#898989'); | |
4300 | + getApp().draw_Text(context, this.data.data.goods_name, 54 * unit, 800 * unit, 240 * unit, 280 * unit, unit, 1); | |
4301 | + | |
4302 | + // 9.小程序码 | |
4303 | + context.drawImage(vpath, 375 * unit, 660 * unit, 120 * unit, 120 * unit); | |
4304 | + context.setFontSize(16 * unit); | |
4305 | + context.setFillStyle('#777'); | |
4306 | + context.fillText('长按识别二维码', 378 * unit, 810 * unit); | |
4307 | + | |
4308 | + // 10.竖线 | |
4309 | + context.beginPath(); | |
4310 | + context.setFillStyle('#eee'); | |
4311 | + context.rect(354 * unit, 670 * unit, 1 * unit, 130 * unit); | |
4312 | + context.fill(); | |
4313 | + }, | |
4314 | + | |
4315 | + //---市场价划掉--- | |
4316 | + draw_pos_price(context,w,h,market_price,unit){ | |
4317 | + | |
4318 | + if(!this.data.sys_switch) return false; | |
4319 | + if(!this.data.sys_switch.is_retail_price) return false; | |
4320 | + | |
4321 | + context.setFillStyle("gray") | |
4322 | + context.setFontSize(22 * unit) | |
4323 | + var pri0 = "¥" + market_price.toFixed(2); | |
4324 | + context.fillText(pri0, w, h); | |
4325 | + | |
4326 | + var c_h=h-6; | |
4327 | + context.setStrokeStyle('gray'); | |
4328 | + context.setLineWidth(1 * unit); | |
4329 | + context.moveTo(w - 5, c_h); | |
4330 | + context.lineTo(w + ut.measureText(pri0, 22 * unit) + 5, c_h); | |
4331 | + context.stroke(); | |
4332 | + | |
4333 | + }, | |
4334 | + | |
4335 | + | |
4336 | + closePoster() { | |
4337 | + this.setData({ | |
4338 | + showPoster: false, | |
4339 | + }); | |
4340 | + }, | |
4341 | + | |
4342 | + // 保存图片到手机 | |
4343 | + savePic() { | |
4344 | + console.log('保存图片'); | |
4345 | + var self = this; | |
4346 | + // 获取用户的当前设置,返回值中有小程序已经向用户请求过的权限 | |
4347 | + this.getSetting().then((res) => { | |
4348 | + // 判断用户是否授权了保存到相册的权限,如果没有发起授权 | |
4349 | + if (!res.authSetting['scope.writePhotosAlbum']) { | |
4350 | + this.authorize().then(() => { | |
4351 | + // 同意授权后保存下载文件 | |
4352 | + this.saveImage(self.data.shareImgPath) | |
4353 | + .then(() => { | |
4354 | + self.setData({ | |
4355 | + showPoster: false | |
4356 | + }); | |
4357 | + }); | |
4358 | + }) | |
4359 | + } else { | |
4360 | + // 如果已经授权,保存下载文件 | |
4361 | + this.saveImage(self.data.shareImgPath) | |
4362 | + .then(() => { | |
4363 | + self.setData({ | |
4364 | + showPoster: false | |
4365 | + }); | |
4366 | + }); | |
4367 | + } | |
4368 | + | |
4369 | + }) | |
4370 | + }, | |
4371 | + | |
4372 | + // 发起首次授权请求 | |
4373 | + authorize() { | |
4374 | + // isFirst 用来记录是否为首次发起授权, | |
4375 | + // 如果首次授权拒绝后,isFirst赋值为1 | |
4376 | + let isFirst = wx.getStorageSync('isFirst') || 0; | |
4377 | + return new Promise((resolve, reject) => { | |
4378 | + wx.authorize({ | |
4379 | + scope: 'scope.writePhotosAlbum', | |
4380 | + // 同意授权 | |
4381 | + success: () => { | |
4382 | + resolve(); | |
4383 | + }, | |
4384 | + // 拒绝授权,这里是用户拒绝授权后的回调 | |
4385 | + fail: res => { | |
4386 | + if (isFirst === 0) { | |
4387 | + wx.setStorageSync('isFirst', 1); | |
4388 | + wx.showToast({ | |
4389 | + title: '保存失败', | |
4390 | + icon: 'none', | |
4391 | + duration: 1000 | |
4392 | + }) | |
4393 | + } else { | |
4394 | + this.showModal(); | |
4395 | + } | |
4396 | + console.log('拒绝授权'); | |
4397 | + reject(); | |
4398 | + } | |
4399 | + }) | |
4400 | + }) | |
4401 | + }, | |
4402 | + | |
4403 | + | |
4404 | + // 保存图片到系统相册 | |
4405 | + saveImage(saveUrl) { | |
4406 | + var self = this; | |
4407 | + return new Promise((resolve, reject) => { | |
4408 | + wx.saveImageToPhotosAlbum({ | |
4409 | + filePath: saveUrl, | |
4410 | + success: (res) => { | |
4411 | + wx.showToast({ | |
4412 | + title: '保存成功', | |
4413 | + duration: 1000, | |
4414 | + }); | |
4415 | + self.setData({ | |
4416 | + showPlaybill: 'true' | |
4417 | + }); | |
4418 | + resolve(); | |
4419 | + }, | |
4420 | + fail: () => { | |
4421 | + wx.showToast({ | |
4422 | + title: '保存失败', | |
4423 | + duration: 1000, | |
4424 | + }); | |
4425 | + } | |
4426 | + }) | |
4427 | + }) | |
4428 | + }, | |
4429 | + | |
4430 | + // 预览海报 | |
4431 | + previewPoster() { | |
4432 | + getApp().globalData.no_clear = 1; | |
4433 | + wx.previewImage({ | |
4434 | + current: this.data.shareImgPath, // 当前显示图片的http链接 | |
4435 | + urls: [this.data.shareImgPath], // 需要预览的图片http链接列表 | |
4436 | + }); | |
4437 | + }, | |
4438 | + | |
4101 | 4439 | |
4102 | 4440 | }); |
4103 | 4441 | ... | ... |
packageA/pages/goodsInfo/goodsInfo.json
... | ... | @@ -6,7 +6,8 @@ |
6 | 6 | "warn": "/components/long_warn/long_warn", |
7 | 7 | "serviceCard_recommend": "/components/serviceCard_list/serviceCard_list", |
8 | 8 | "privacy_pop": "/components/privacy_pop/privacy_pop", |
9 | - "top_nav": "/components/diy_top_nav/diy_top_nav" | |
9 | + "top_nav": "/components/diy_top_nav/diy_top_nav", | |
10 | + "share": "/components/share/share" | |
10 | 11 | }, |
11 | 12 | "navigationStyle": "custom" |
12 | 13 | } |
13 | 14 | \ No newline at end of file | ... | ... |
packageA/pages/goodsInfo/goodsInfo.wxml
... | ... | @@ -11,7 +11,7 @@ |
11 | 11 | <view class="container"> |
12 | 12 | |
13 | 13 | <view class="type-navbar_box"> |
14 | - <top_nav id="my-nav" bindclickShare="clickShare" nav_type="{{nav_type}}" is_share="{{false}}" | |
14 | + <top_nav id="my-nav" bindclickShare="clickShare" nav_type="{{nav_type}}" is_share="{{true}}" | |
15 | 15 | nav_frontColor="{{nav_frontColor}}" istop="{{(istop && searchbox_transparent && activeCategoryId==0) ? 1 : 0 }}" nav_backgroundColor="{{nav_backgroundColor}}" nav_title="{{gtitle}}"></top_nav> |
16 | 16 | </view> |
17 | 17 | |
... | ... | @@ -106,16 +106,25 @@ |
106 | 106 | <view class="market-price" style="overflow: hidden"></view> |
107 | 107 | </view> |
108 | 108 | |
109 | - <view> | |
110 | - <!-- 秒杀价 --> | |
111 | - <view class="co-red" wx:if="{{options.prom_type == 1}}"><text class="rel yuan fs28">¥</text>{{filters.toFix(prom_price,2)}}</view> | |
112 | - <!-- 手店价 --> | |
113 | - <view class="co-red" wx:else><text class="rel yuan fs28">¥</text>{{filters.toFix(data.shop_price,2)}}</view> | |
114 | - <!-- <view class="word-line fs20 xc-qtunit-price"> | |
115 | - 零售价¥{{filters.toFix(data.market_price,2)}} | |
116 | - </view> --> | |
117 | - <view class="goods-title"> | |
118 | - <view class="goods-name elli">{{data.goods_name}}</view> | |
109 | + | |
110 | + <view class="flex jc_sb"> | |
111 | + <view> | |
112 | + <!-- 秒杀价 --> | |
113 | + <view class="co-red" wx:if="{{options.prom_type == 1}}"><text class="rel yuan fs28">¥</text>{{filters.toFix(prom_price,2)}}</view> | |
114 | + <!-- 手店价 --> | |
115 | + <view class="co-red" wx:else><text class="rel yuan fs28">¥</text>{{filters.toFix(data.shop_price,2)}}</view> | |
116 | + <!-- <view class="word-line fs20 xc-qtunit-price"> | |
117 | + 零售价¥{{filters.toFix(data.market_price,2)}} | |
118 | + </view> --> | |
119 | + <view class="goods-title"> | |
120 | + <view class="goods-name elli">{{data.goods_name}}</view> | |
121 | + </view> | |
122 | + </view> | |
123 | + | |
124 | + <!-- 这个是分享按钮 --> | |
125 | + <view wx:if="{{isLogin}}" class="xc-share-frame t-c shrink0" bindtap="clickShare"> | |
126 | + <view class="iconfont icon-share"></view> | |
127 | + <view class="fs22 c-7b">分享</view> | |
119 | 128 | </view> |
120 | 129 | </view> |
121 | 130 | |
... | ... | @@ -970,14 +979,20 @@ |
970 | 979 | <canvas canvas-id='share' style='width:750rpx;height:1217rpx;background-color:white;' wx:if='{{!canvasHidden}}'></canvas> |
971 | 980 | <warn id="warn"></warn> |
972 | 981 | |
973 | - | |
974 | 982 | <view wx:if="{{showPoster}}"> |
975 | 983 | <view class="mask" catchtap="closePoster"></view> |
976 | 984 | <view class="poster-container"> |
977 | 985 | <view class="poster-wrapper"> |
978 | - <view class="poster"> | |
986 | + <view class="poster" bindtap="previewPoster"> | |
987 | + <!-- <view class="poster" bindtap="previewImage"> --> | |
979 | 988 | <image src="{{shareImgPath}}" class="poster-img" show-menu-by-longpress></image> |
980 | - <view class="btn-close" catchtap="closePoster"><text class="iconfont icon-close"></text></view> | |
989 | + <view class="btn-close" catchtap="closePoster"> | |
990 | + <text class="iconfont icon-close"></text> | |
991 | + </view> | |
992 | + </view> | |
993 | + <view class="btn-container"> | |
994 | + <!-- <button class="btn-share" open-type="share" bindtap="">微信好友分享</button> --> | |
995 | + <button class="btn-share" bindtap="savePic">保存到相册</button> | |
981 | 996 | </view> |
982 | 997 | </view> |
983 | 998 | </view> |
... | ... | @@ -1015,3 +1030,5 @@ |
1015 | 1030 | </view> |
1016 | 1031 | |
1017 | 1032 | <view class="mask2" bindtap="closeCS"></view> |
1033 | +<!-- 分享控件,底部弹出 --> | |
1034 | +<share id="share_button" bind:send="send" bind:cancel="cancel" bind:share_img="saveImageFn" wx:if="{{share_hidden}}"></share> | ... | ... |
packageA/pages/serviceCard_pd/goodsInfo/goodsInfo.js
... | ... | @@ -12,6 +12,7 @@ var more = function (e) { |
12 | 12 | }(require("../../../../utils/LoadMore.js")), |
13 | 13 | n = new more.default(); |
14 | 14 | var regeneratorRuntime = require('../../../../utils/runtime.js'); |
15 | +var self=null; | |
15 | 16 | |
16 | 17 | Page({ |
17 | 18 | data: { |
... | ... | @@ -1256,6 +1257,8 @@ Page({ |
1256 | 1257 | }) |
1257 | 1258 | } |
1258 | 1259 | |
1260 | + this.data.get_sto_ing=1; | |
1261 | + | |
1259 | 1262 | var timer_get = setInterval(function () { |
1260 | 1263 | if (th.data.is_get_local_ok == 0) return false; |
1261 | 1264 | if (!th.data.fir_def_store) return false; |
... | ... | @@ -1374,13 +1377,19 @@ Page({ |
1374 | 1377 | th.setData({all_pick_list: e.data.data.pageData}); |
1375 | 1378 | th.deal_pickup(e); |
1376 | 1379 | }else{ |
1380 | + th.data.get_sto_ing=0; | |
1377 | 1381 | th.setData({all_pick_list: null, only_pk:null,def_pickpu_list:null }); |
1378 | - | |
1379 | 1382 | wx.hideLoading(); |
1380 | 1383 | } |
1381 | 1384 | }, 800) |
1382 | 1385 | |
1383 | 1386 | } |
1387 | + else{ | |
1388 | + th.data.get_sto_ing=0; | |
1389 | + th.setData({all_pick_list: null, only_pk:null,def_pickpu_list:null }); | |
1390 | + | |
1391 | + wx.hideLoading(); | |
1392 | + } | |
1384 | 1393 | }) |
1385 | 1394 | }, 200) |
1386 | 1395 | }, |
... | ... | @@ -1554,9 +1563,11 @@ Page({ |
1554 | 1563 | } |
1555 | 1564 | |
1556 | 1565 | } |
1566 | + th.data.get_sto_ing=0; | |
1557 | 1567 | } |
1558 | 1568 | }); |
1559 | 1569 | } else { |
1570 | + th.data.get_sto_ing=0; | |
1560 | 1571 | th.setData({ |
1561 | 1572 | is_show_sto_cat: 0, |
1562 | 1573 | only_pk: e.data.data.pageData |
... | ... | @@ -1605,6 +1616,12 @@ Page({ |
1605 | 1616 | // return false; |
1606 | 1617 | // } |
1607 | 1618 | |
1619 | + if (this.data.share_hidden) { | |
1620 | + this.setData({ | |
1621 | + share_hidden: false, | |
1622 | + }); | |
1623 | + }; | |
1624 | + | |
1608 | 1625 | //类型 0普通商品 1秒杀商品 2商家和会员团 3阶梯团 4积分购 |
1609 | 1626 | var type = 2 |
1610 | 1627 | if (this.data.prom_act && this.data.prom_act.kttype == 3) type = 3; |
... | ... | @@ -3569,6 +3586,9 @@ Page({ |
3569 | 3586 | }); |
3570 | 3587 | }, |
3571 | 3588 | |
3589 | + send() { | |
3590 | + this.setData({ share_hidden: false, }); | |
3591 | + }, | |
3572 | 3592 | cancel() { |
3573 | 3593 | this.setData({ |
3574 | 3594 | share_hidden: false, |
... | ... | @@ -3965,6 +3985,15 @@ Page({ |
3965 | 3985 | } |
3966 | 3986 | }, |
3967 | 3987 | |
3988 | + // 预览海报 | |
3989 | + previewPoster() { | |
3990 | + getApp().globalData.no_clear = 1; | |
3991 | + wx.previewImage({ | |
3992 | + current: this.data.shareImgPath, // 当前显示图片的http链接 | |
3993 | + urls: [this.data.shareImgPath], // 需要预览的图片http链接列表 | |
3994 | + }); | |
3995 | + }, | |
3996 | + | |
3968 | 3997 | }); |
3969 | 3998 | |
3970 | 3999 | ... | ... |
packageA/pages/serviceCard_pd/goodsInfo/goodsInfo.wxml
... | ... | @@ -807,14 +807,20 @@ |
807 | 807 | <canvas canvas-id='share' style='width:750rpx;height:1217rpx;background-color:white;' wx:if='{{!canvasHidden}}'></canvas> |
808 | 808 | <warn id="warn"></warn> |
809 | 809 | |
810 | - | |
811 | 810 | <view wx:if="{{showPoster}}"> |
812 | 811 | <view class="mask" catchtap="closePoster"></view> |
813 | 812 | <view class="poster-container"> |
814 | 813 | <view class="poster-wrapper"> |
815 | - <view class="poster"> | |
814 | + <view class="poster" bindtap="previewPoster"> | |
815 | + <!-- <view class="poster" bindtap="previewImage"> --> | |
816 | 816 | <image src="{{shareImgPath}}" class="poster-img" show-menu-by-longpress></image> |
817 | - <view class="btn-close" catchtap="closePoster"><text class="iconfont icon-close"></text></view> | |
817 | + <view class="btn-close" catchtap="closePoster"> | |
818 | + <text class="iconfont icon-close"></text> | |
819 | + </view> | |
820 | + </view> | |
821 | + <view class="btn-container"> | |
822 | + <!-- <button class="btn-share" open-type="share" bindtap="">微信好友分享</button> --> | |
823 | + <button class="btn-share" bindtap="savePic">保存到相册</button> | |
818 | 824 | </view> |
819 | 825 | </view> |
820 | 826 | </view> | ... | ... |
packageA/pages/serviceCard_pd/goodsInfo/goodsInfo.wxss
... | ... | @@ -2744,7 +2744,7 @@ button.custom-service::after{ |
2744 | 2744 | left: 50%; |
2745 | 2745 | transform: translate(-50%, -50%); |
2746 | 2746 | width: calc(100% - 120rpx); |
2747 | - z-index: 1000; | |
2747 | + z-index: 10001; | |
2748 | 2748 | } |
2749 | 2749 | .mask { |
2750 | 2750 | position: fixed; |
... | ... | @@ -2752,7 +2752,7 @@ button.custom-service::after{ |
2752 | 2752 | left: 0; |
2753 | 2753 | width: 100%; |
2754 | 2754 | height: 100%; |
2755 | - z-index: 999; | |
2755 | + z-index: 10000; | |
2756 | 2756 | background-color: rgba(0,0,0,.4); |
2757 | 2757 | } |
2758 | 2758 | .poster-wrapper { | ... | ... |
packageA/pages/serviceCard_pd/team_success/team_success.js
... | ... | @@ -823,7 +823,7 @@ Page({ |
823 | 823 | tt(func);; |
824 | 824 | }, |
825 | 825 | fail: function (res) { |
826 | - ee.data.share_head = "../../../images/share/hui_hear_pic.png"; //分享的图片不能用网络的 | |
826 | + ee.data.share_head = "../../../../images/share/hui_hear_pic.png"; //分享的图片不能用网络的 | |
827 | 827 | tt(func); |
828 | 828 | } |
829 | 829 | }); | ... | ... |
packageB/pages/luckactivity/luckinfo/luckinfo.js
... | ... | @@ -262,9 +262,9 @@ Page({ |
262 | 262 | let first_leader = null; |
263 | 263 | this.data.options = options; |
264 | 264 | |
265 | - // wx.setNavigationBarTitle({ | |
266 | - // title: options.title, | |
267 | - // }); | |
265 | + wx.setNavigationBarTitle({ | |
266 | + title: options.title, | |
267 | + }); | |
268 | 268 | this.setData({l_title:options.title}) |
269 | 269 | |
270 | 270 | app.isLogin().then(function (data) {//进入页面前已经授权登录成功 | ... | ... |
packageC/pages/luckyGo/luckyGo_cart_ct/luckyGo_cart_ct.js
... | ... | @@ -80,6 +80,13 @@ Page({ |
80 | 80 | bconfig: null, |
81 | 81 | showFold:true, |
82 | 82 | template_id:[], |
83 | + | |
84 | + //-- 订单促销判断积累 ---2024-2-20 | |
85 | + order_prom_map_ck: {}, | |
86 | + //能不能使用订单促销 | |
87 | + can_use_ord_prom:{}, | |
88 | + //存储订单促销的取价,按照门店进行索引 | |
89 | + show_ord_prom:{}, | |
83 | 90 | }, |
84 | 91 | |
85 | 92 | |
... | ... | @@ -513,6 +520,7 @@ Page({ |
513 | 520 | } |
514 | 521 | |
515 | 522 | |
523 | + t.data.data.shop_price_y = t.data.data.shop_price; | |
516 | 524 | t.data.data.shop_price = gg.goods_price; |
517 | 525 | //--如果是普通购买的时候-- |
518 | 526 | if (gg.is_normal == 1) { |
... | ... | @@ -569,7 +577,10 @@ Page({ |
569 | 577 | } |
570 | 578 | |
571 | 579 | |
580 | + t.data.data.goods_price=th.data.param.goods_price; | |
572 | 581 | |
582 | + //用深拷贝把商品缓存起来,方便后面使用 | |
583 | + th.data.old_bn_goods=ut.deep_cp(t.data.data); | |
573 | 584 | |
574 | 585 | th.setData({ |
575 | 586 | bn_goods: t.data.data, |
... | ... | @@ -642,6 +653,9 @@ Page({ |
642 | 653 | |
643 | 654 | } |
644 | 655 | |
656 | + t.data.data.goods_price=th.data.param.goods_price; | |
657 | + //用深拷贝把商品缓存起来,方便后面使用 | |
658 | + th.data.old_bn_goods=ut.deep_cp(t.data.data); | |
645 | 659 | |
646 | 660 | th.setData({ |
647 | 661 | bn_goods: t.data.data, |
... | ... | @@ -651,7 +665,6 @@ Page({ |
651 | 665 | bn_exp_type: et |
652 | 666 | }); |
653 | 667 | |
654 | - | |
655 | 668 | //计算价格 |
656 | 669 | th.calculatePrice2(); |
657 | 670 | } |
... | ... | @@ -842,7 +855,9 @@ Page({ |
842 | 855 | //-----------计算商品总价-------------- |
843 | 856 | //var allpice = th.data.param.goods_price; |
844 | 857 | var allpice = (th.data.act.group_price/100).toFixed(2); |
845 | - | |
858 | + if(th.data.can_use_ord_prom[th.data.bn_pick]){ | |
859 | + allpice=th.data.param.goods_price*th.data.bn_goods.buynum; | |
860 | + } | |
846 | 861 | |
847 | 862 | allpice = parseFloat(allpice).toFixed(2); |
848 | 863 | var txt = "formData.all_price"; |
... | ... | @@ -868,14 +883,18 @@ Page({ |
868 | 883 | var ord_prom=null; |
869 | 884 | var o_condition=allpice; |
870 | 885 | if(th.data.act.is_order_yh){ |
886 | + // await getApp().request.promiseGet("/api/weshop/promorder/getOrderPromotion", { | |
887 | + // data: { store_id: os.stoid, orderAmount: o_condition, user_id: getApp().globalData.user_id } | |
888 | + // }).then(res => { | |
889 | + // if (res.data.code == 0) { | |
890 | + // ord_prom = res.data.data; | |
891 | + // } | |
892 | + // }) | |
893 | + | |
894 | + th.set_by_now_ord_prom(th.data.bn_goods); | |
895 | + th.data.order_prom_map_ck[th.data.bn_pick].goods_price_all=o_condition; | |
896 | + ord_prom=await th.get_cur_ord_prom(th.data.bn_pick); | |
871 | 897 | |
872 | - await getApp().request.promiseGet("/api/weshop/promorder/getOrderPromotion", { | |
873 | - data: { store_id: os.stoid, orderAmount: o_condition, user_id: getApp().globalData.user_id } | |
874 | - }).then(res => { | |
875 | - if (res.data.code == 0) { | |
876 | - ord_prom = res.data.data; | |
877 | - } | |
878 | - }) | |
879 | 898 | } |
880 | 899 | |
881 | 900 | |
... | ... | @@ -964,7 +983,7 @@ Page({ |
964 | 983 | title: "物流配置未启用物流公司", icon: 'none', duration: 2000 |
965 | 984 | }) |
966 | 985 | //th.setData({ show_submit:0, }); |
967 | - th.setData({show_submit:1, submit: 0,same_ok:0 }) | |
986 | + th.setData({show_submit:1, submit: 0,same_ok:0,sub:0 }) | |
968 | 987 | return false; |
969 | 988 | } |
970 | 989 | |
... | ... | @@ -996,7 +1015,7 @@ Page({ |
996 | 1015 | wx.showToast({ |
997 | 1016 | title: "计算物流错误", icon: 'none', duration: 2000 |
998 | 1017 | }) |
999 | - th.setData({show_submit:1, submit: 0,same_ok:0 }) | |
1018 | + th.setData({show_submit:1, submit: 0,same_ok:0,sub:0 }) | |
1000 | 1019 | return false; |
1001 | 1020 | } |
1002 | 1021 | |
... | ... | @@ -1289,7 +1308,7 @@ Page({ |
1289 | 1308 | // 提交订单前弹出确认对话框 |
1290 | 1309 | submitConfirm(e) { |
1291 | 1310 | // is_show为0不显示温馨提示,为1显示温馨提示 |
1292 | - if (this.data.param.is_show == 1) { | |
1311 | + if (this.data.param.is_show == 1 && !this.data.can_use_ord_prom[this.data.bn_pick]) { | |
1293 | 1312 | wx.showModal({ |
1294 | 1313 | title: '温馨提示', |
1295 | 1314 | content: this.data.param.alert, |
... | ... | @@ -1451,6 +1470,61 @@ Page({ |
1451 | 1470 | 'prom_id': th.data.param.group_id, //促销活动id |
1452 | 1471 | }; |
1453 | 1472 | |
1473 | + | |
1474 | + if(th.data.bn_goods.discount_field){ | |
1475 | + goods.discount_field=th.data.bn_goods.discount_field; | |
1476 | + } | |
1477 | + | |
1478 | + //如果有参与非实收的订单促销,那么就相当于是普通购买 | |
1479 | + if(th.data.can_use_ord_prom[th.data.bn_pick]){ | |
1480 | + goods.is_integral_normal=1; | |
1481 | + goods.prom_type=0; | |
1482 | + goods.prom_id=0; | |
1483 | + | |
1484 | + //如果是指定门店,就要判断 | |
1485 | + if (th.data.bn_goods.pick_group_ids) { | |
1486 | + var idx0 = th.data.bn_goods.pick_up_lists.findIndex(function (e) { | |
1487 | + return e.pickup_id == th.data.bn_pick; | |
1488 | + }) | |
1489 | + if (idx0 < 0) { | |
1490 | + getApp().my_warnning(th.data.bn_goods.goods_name + "的门店不可售", 0, th); | |
1491 | + th.data.is_summit_ing = 0; | |
1492 | + th.setData({ | |
1493 | + submit: 0 | |
1494 | + }) | |
1495 | + return false; | |
1496 | + } | |
1497 | + } | |
1498 | + | |
1499 | + if (th.data.sales_rules==1 && th.data.bn_goods.store_count<oods.goods_num){ | |
1500 | + getApp().confirmBox("商品的门店库存不足"); | |
1501 | + th.data.is_summit_ing = 0; | |
1502 | + th.setData({ | |
1503 | + submit: 0 | |
1504 | + }) | |
1505 | + return false; | |
1506 | + } | |
1507 | + //如果不立即购买或者秒杀,如果是线下库存购买的时候 | |
1508 | + if (th.data.sales_rules >= 2 && !th.data.bn_goods.whsle_id && !getApp().is_virtual(th.data.bn_goods)) { | |
1509 | + var isok = 1; | |
1510 | + await th.check_store_num(goods.goods_id, th.data.bn_pick, goods.goods_num, function (res) { | |
1511 | + isok = res; | |
1512 | + }); | |
1513 | + if (!isok) { | |
1514 | + getApp().confirmBox("商品的门店库存不足"); | |
1515 | + th.data.is_summit_ing = 0; | |
1516 | + th.setData({ | |
1517 | + submit: 0 | |
1518 | + }) | |
1519 | + return false; | |
1520 | + } | |
1521 | + } | |
1522 | + | |
1523 | + | |
1524 | + | |
1525 | + | |
1526 | + } | |
1527 | + | |
1454 | 1528 | if (getApp().globalData.skinface_id) { |
1455 | 1529 | goods.skinface_id = getApp().globalData.skinface_id; |
1456 | 1530 | } |
... | ... | @@ -2085,9 +2159,191 @@ Page({ |
2085 | 2159 | th.calculatePrice2(); |
2086 | 2160 | }, |
2087 | 2161 | |
2162 | + //-- 获取订单促销的判断结构 -- | |
2163 | + set_by_now_ord_prom(item){ | |
2164 | + let pickid=this.data.bn_pick; | |
2165 | + let order_prom_map_ck= this.data.order_prom_map_ck; | |
2166 | + order_prom_map_ck[pickid]={ | |
2167 | + shop_price_all:0, //手店价的累计 | |
2168 | + market_price_all:0, //市场价的累计 | |
2169 | + goods_price_all:0, //实收价的累计 | |
2170 | + no_ord_price:0, //要累计上不参与订单促销的金额 | |
2171 | + goodsList:[], | |
2172 | + } | |
2173 | + | |
2174 | + let pk_ord_map=order_prom_map_ck[pickid]; | |
2175 | + pk_ord_map.shop_price_all += item.shop_price_y * item.buynum; | |
2176 | + pk_ord_map.market_price_all += item.market_price * item.buynum; | |
2177 | + | |
2178 | + }, | |
2179 | + | |
2180 | + //获取当前进行中订单促销,同时带入相应的金额判断订单促销是不是运行,同时订单促销的条件不是实收价判断的话,默认的时候,订单促销是不参与运算的 | |
2181 | + async get_cur_ord_prom(pickid) { | |
2182 | + let ord_prom = null; | |
2183 | + let order_prom_map_ck = this.data.order_prom_map_ck[pickid]; | |
2184 | + if(!order_prom_map_ck) return null; | |
2185 | + | |
2186 | + //获取当前进行中的优惠促销 | |
2187 | + await getApp().request.promiseGet("/api/weshop/promorder/getPromOrder", { | |
2188 | + data: { | |
2189 | + store_id: os.stoid, | |
2190 | + orderAmount: -1, //-1为不判断金额条件 | |
2191 | + user_id: getApp().globalData.user_id | |
2192 | + } | |
2193 | + }).then(res => { | |
2194 | + if (res.data.code == 0) { | |
2195 | + ord_prom = res.data.data; | |
2196 | + } | |
2197 | + }) | |
2198 | + | |
2199 | + if (!ord_prom) return null; | |
2200 | + //用于计算订单促销的金额 | |
2201 | + let calculate_price=0; | |
2202 | + | |
2203 | + let txt1='show_ord_prom['+pickid+']'; | |
2204 | + //-- 此时判断活动的金额满足与否 -- | |
2205 | + switch (ord_prom.discount_field) { | |
2206 | + //实收价的时候 | |
2207 | + case 0: | |
2208 | + //要先还原 | |
2209 | + this.setData({ | |
2210 | + [txt1]: 0 | |
2211 | + }); | |
2212 | + | |
2213 | + if (ord_prom.money > order_prom_map_ck.goods_price_all){ | |
2214 | + return null; | |
2215 | + } | |
2216 | + break; | |
2217 | + //手店价的时候 | |
2218 | + case 1: | |
2219 | + if (ord_prom.money > order_prom_map_ck.shop_price_all){ | |
2220 | + //要先还原 | |
2221 | + this.setData({ | |
2222 | + [txt1]: 0 | |
2223 | + }); | |
2224 | + return null; | |
2225 | + } | |
2226 | + //要显示订单促销使用的按钮 | |
2227 | + this.setData({ | |
2228 | + [txt1]: 1 | |
2229 | + }); | |
2230 | + break; | |
2231 | + //市场价的时候 | |
2232 | + case 2: | |
2233 | + if (ord_prom.money > order_prom_map_ck.market_price_all){ | |
2234 | + //要先还原 | |
2235 | + this.setData({ | |
2236 | + [txt1]: 0 | |
2237 | + }); | |
2238 | + return null; | |
2239 | + } | |
2240 | + //要显示订单促销使用的按钮 | |
2241 | + this.setData({ | |
2242 | + [txt1]: 2 | |
2243 | + }); | |
2244 | + break; | |
2245 | + } | |
2246 | + //如果订单促销是不参与订单促销的,那么就直接返回null(订单促销不是实收价的时候) | |
2247 | + if(ord_prom.discount_field>0 && !this.data.can_use_ord_prom[pickid]){ | |
2248 | + return null; | |
2249 | + } | |
2250 | + return ord_prom; | |
2251 | + }, | |
2252 | + | |
2253 | + //立即购买的时候,点击订单促销的参与 | |
2254 | + set_can_use_ord_prom_now:function (e){ | |
2255 | + | |
2256 | + if(this.data.sub) return false; | |
2257 | + this.setData({ sub: 1,same_ok:1 }); | |
2258 | + | |
2259 | + let pickid=this.data.bn_pick; | |
2260 | + let txt = 'can_use_ord_prom[' + pickid + ']'; | |
2261 | + let can_use = this.data.can_use_ord_prom[pickid] ? this.data.can_use_ord_prom[pickid] : 0; | |
2262 | + this.setData({ | |
2263 | + [txt]: !can_use | |
2264 | + }) | |
2265 | + | |
2266 | + let th=this; | |
2267 | + let good=th.data.bn_goods; | |
2268 | + let param=th.data.param; | |
2269 | + | |
2270 | + //如果有要参与订单促销的按钮点击后,要修改商品的价格 | |
2271 | + if(th.data.can_use_ord_prom[pickid]){ | |
2272 | + let discount_field=th.data.show_ord_prom[pickid]; | |
2273 | + switch (discount_field){ | |
2274 | + case 1: | |
2275 | + good.shop_price=good.shop_price_y; | |
2276 | + param.goods_price=good.shop_price_y; | |
2277 | + break; | |
2278 | + case 2: | |
2279 | + good.shop_price=good.market_price; | |
2280 | + param.goods_price=good.market_price; | |
2281 | + break; | |
2282 | + } | |
2283 | + //-- 转成普通商品 --- | |
2284 | + good.prom_type=0; | |
2285 | + good.prom_id=0; | |
2286 | + good.discount_field=discount_field; | |
2287 | + | |
2088 | 2288 | |
2289 | + }else{ | |
2290 | + good=ut.deep_cp(th.data.old_bn_goods); | |
2291 | + param.goods_price=good.goods_price; | |
2292 | + } | |
2089 | 2293 | |
2294 | + th.setData({ | |
2295 | + bn_goods:good, | |
2296 | + param | |
2297 | + }) | |
2298 | + wx.showLoading({ | |
2299 | + title: "处理中.", | |
2300 | + mark:true | |
2301 | + }) | |
2302 | + th.calculatePrice2() | |
2303 | + }, | |
2090 | 2304 | |
2305 | + //---确认线下门店的数量足不足--- | |
2306 | + async check_store_num(goods_id, pick, goods_num, func) { | |
2307 | + var lock = 0, pick_no, plist, erpwareid; | |
2308 | + //先读取门店的lock | |
2309 | + await getApp().request.promiseGet("/api/weshop/order/ware/lock/page", { | |
2310 | + data: { store_id: os.stoid, wareId: goods_id, storageId: pick, pageSize: 1000 } | |
2311 | + }).then(res => { | |
2312 | + if (res.data.code == 0 && res.data.data.total > 0) { | |
2313 | + for (var i in res.data.data.pageData) | |
2314 | + lock += res.data.data.pageData[i].outQty; | |
2315 | + } | |
2316 | + }) | |
2317 | + //先获取门店的编号 | |
2318 | + await getApp().request.promiseGet("/api/weshop/pickup/get/" + os.stoid + "/" + pick, { | |
2319 | + data: { storeId: os.stoid, goodsId: t.goods_id, pickupId: pick } | |
2320 | + }).then(res => { | |
2321 | + if (res.data.code == 0) { | |
2322 | + pick_no = res.data.data.pickup_no; | |
2323 | + } | |
2324 | + }) | |
2325 | + //先获取商品的线下库存 | |
2326 | + await getApp().request.promiseGet("/api/weshop/goods/get/" + os.stoid + "/" + goods_id, { | |
2327 | + data: { storeId: os.stoid, goodsId: t.goods_id, pickupId: pick } | |
2328 | + }).then(res => { | |
2329 | + if (res.data.code == 0) { | |
2330 | + erpwareid = res.data.data.erpwareid; | |
2331 | + } | |
2332 | + }) | |
2333 | + //读取线下的门店库存 | |
2334 | + await getApp().request.promiseGet("/api/weshop/goods/getWareStorages", { | |
2335 | + data: { storageNos: pick_no, wareIds: encodeURIComponent(erpwareid), storeId: os.stoid } | |
2336 | + }).then(res => { | |
2337 | + if (res.data.code == 0 && res.data.data && res.data.data.pageData && res.data.data.pageData.length) { | |
2338 | + plist = res.data.data.pageData[0]; | |
2339 | + } | |
2340 | + }) | |
2341 | + var isok = 1; | |
2342 | + if (!plist || goods_num > plist.CanOutQty - lock) { | |
2343 | + isok = 0; | |
2344 | + } | |
2345 | + func(isok); | |
2346 | + }, | |
2091 | 2347 | |
2092 | 2348 | |
2093 | 2349 | }); | ... | ... |
packageC/pages/luckyGo/luckyGo_cart_ct/luckyGo_cart_ct.wxml
... | ... | @@ -100,6 +100,14 @@ |
100 | 100 | <icon color="#f23030" size="16" type="info"></icon>{{order.store_prom}} |
101 | 101 | </view> |
102 | 102 | |
103 | + <!-- 订单促销取价规则的优化 --> | |
104 | + <view class="set-mes" wx:if="{{show_ord_prom[bn_pick]}}"> | |
105 | + <view class="use-item" > | |
106 | + <icon bindtap='set_can_use_ord_prom_now' color="{{can_use_ord_prom[bn_pick]?'red':'gray'}}" size="16" type="success"></icon> | |
107 | + <view bindtap='set_can_use_ord_prom_now' class="yu_er">参与订单促销</view> | |
108 | + </view> | |
109 | + </view> | |
110 | + | |
103 | 111 | <!--阶梯团是不显示的--> |
104 | 112 | <block wx:if="{{bn_exp_type==0 && !is_default_logistics}}"> |
105 | 113 | <view class="use-item flex-space-between" wx:if="{{kt_type!=3 || is_normal==1}}"> | ... | ... |
packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.js
... | ... | @@ -3129,6 +3129,7 @@ Page({ |
3129 | 3129 | |
3130 | 3130 | //---------拿出门店分类和门店------------ |
3131 | 3131 | get_sto(e,func) { |
3132 | + | |
3132 | 3133 | var th = this, that = this; |
3133 | 3134 | var is_normal = e; |
3134 | 3135 | |
... | ... | @@ -3137,12 +3138,13 @@ Page({ |
3137 | 3138 | } else { |
3138 | 3139 | th.setData({ is_normal: 0 }) |
3139 | 3140 | } |
3141 | + th.data.get_sto_ing=1; | |
3140 | 3142 | |
3141 | 3143 | var timer_get = setInterval(function () { |
3142 | 3144 | if (th.data.is_get_local_ok == 0) return false; |
3143 | 3145 | if (!th.data.fir_def_store) return false; |
3144 | 3146 | var dd = null, i = getApp().request; |
3145 | - if (!th.data.sele_g) return false; | |
3147 | + if (!th.data.sele_g){th.data.get_sto_ing=0; return false;} | |
3146 | 3148 | |
3147 | 3149 | var g_distr_type = th.data.sele_g.distr_type; |
3148 | 3150 | if (g_distr_type != 0) { |
... | ... | @@ -3277,6 +3279,7 @@ Page({ |
3277 | 3279 | |
3278 | 3280 | } |
3279 | 3281 | },err=>{ |
3282 | + th.data.get_sto_ing=0; | |
3280 | 3283 | ut.m_toast('网络繁忙,请稍后重试'); |
3281 | 3284 | wx.hideLoading(); |
3282 | 3285 | }) |
... | ... | @@ -3403,12 +3406,15 @@ Page({ |
3403 | 3406 | front_is_show_sto_cat:th.data.is_show_sto_cat, |
3404 | 3407 | }) |
3405 | 3408 | } |
3409 | + | |
3410 | + this.data.get_sto_ing=0; | |
3411 | + | |
3406 | 3412 | }, |
3407 | 3413 | |
3408 | 3414 | //------------处理门店--------------- |
3409 | 3415 | deal_pickup(e) { |
3410 | 3416 | var th = this; |
3411 | - if (!th.data.sele_g) return false | |
3417 | + if (!th.data.sele_g){th.data.get_sto_ing=0;return false} | |
3412 | 3418 | |
3413 | 3419 | var g_distr_type = th.data.sele_g.distr_type; |
3414 | 3420 | wx.hideLoading(); |
... | ... | @@ -3580,7 +3586,7 @@ Page({ |
3580 | 3586 | //------------处理线下门店库存-------- |
3581 | 3587 | deal_pickup_dline(e) { |
3582 | 3588 | var pkno = [], th = this; |
3583 | - if (!th.data.sele_g) return false; | |
3589 | + if (!th.data.sele_g){th.data.get_sto_ing=0;return false;} | |
3584 | 3590 | |
3585 | 3591 | if (this.data.def_pick_store) { |
3586 | 3592 | pkno.push(this.data.def_pick_store.pickup_no); |
... | ... | @@ -3673,6 +3679,7 @@ Page({ |
3673 | 3679 | |
3674 | 3680 | |
3675 | 3681 | } else { |
3682 | + th.data.get_sto_ing=0; | |
3676 | 3683 | th.setData({ |
3677 | 3684 | all_sto: null, |
3678 | 3685 | only_pk: null, |
... | ... | @@ -3739,9 +3746,11 @@ Page({ |
3739 | 3746 | //---把数组组装进去--- |
3740 | 3747 | th.deal_pickup(em); |
3741 | 3748 | } else { |
3749 | + th.data.get_sto_ing=0; | |
3742 | 3750 | th.setData({ def_pick_store: null, all_sto: null, only_pk: null, def_pickpu_list: null }) |
3743 | 3751 | } |
3744 | 3752 | } else { |
3753 | + th.data.get_sto_ing=0; | |
3745 | 3754 | th.setData({ def_pick_store: null, all_sto: null, only_pk: null, def_pickpu_list: null }) |
3746 | 3755 | } |
3747 | 3756 | }) |
... | ... | @@ -4504,6 +4513,7 @@ Page({ |
4504 | 4513 | // ind == 1 为普通购买 |
4505 | 4514 | openSpecModel_pt: function (e) { |
4506 | 4515 | |
4516 | + if(this.data.get_sto_ing) return false; | |
4507 | 4517 | this.setData({ open_ind_store: 9 }); |
4508 | 4518 | // 判断是否有待支付订单 |
4509 | 4519 | var aid = this.data.group_id; |
... | ... | @@ -4546,7 +4556,11 @@ Page({ |
4546 | 4556 | var th = this; |
4547 | 4557 | var ind = parseInt(e.currentTarget.dataset.ind); |
4548 | 4558 | |
4549 | - th.setData({def_pick_store: ut.deep_cp(th.data.front_pick)}); | |
4559 | + if(th.data.front_pick && th.data.front_pick.pickup_id){ | |
4560 | + th.setData({def_pick_store: ut.deep_cp(th.data.front_pick)}); | |
4561 | + } | |
4562 | + | |
4563 | + | |
4550 | 4564 | |
4551 | 4565 | //ind == 1是普通购买 |
4552 | 4566 | if (ind == 1) { |
... | ... | @@ -5981,12 +5995,12 @@ Page({ |
5981 | 5995 | }) |
5982 | 5996 | //--先判断会员状态-- |
5983 | 5997 | var user_info = getApp().globalData.userInfo; |
5984 | - if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { | |
5985 | - wx.navigateTo({ | |
5986 | - url: '/packageE/pages/togoin/togoin', | |
5987 | - }) | |
5988 | - return false; | |
5989 | - } | |
5998 | + // if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { | |
5999 | + // wx.navigateTo({ | |
6000 | + // url: '/packageE/pages/togoin/togoin', | |
6001 | + // }) | |
6002 | + // return false; | |
6003 | + // } | |
5990 | 6004 | |
5991 | 6005 | var th = this; |
5992 | 6006 | var ind = ee.currentTarget.dataset.ind; | ... | ... |
packageC/pages/presell/cardInfo/goodsInfo.js
... | ... | @@ -1186,6 +1186,9 @@ Page({ |
1186 | 1186 | }, |
1187 | 1187 | |
1188 | 1188 | openSpecModel: function(t) { |
1189 | + | |
1190 | + if(this.data.get_sto_ing) return false; | |
1191 | + | |
1189 | 1192 | var th=this; var open_store = t.currentTarget.dataset.ind; |
1190 | 1193 | if(getApp().is_sp_hao() && open_store==1){ |
1191 | 1194 | wx.showToast({ |
... | ... | @@ -1443,6 +1446,8 @@ Page({ |
1443 | 1446 | }) |
1444 | 1447 | } |
1445 | 1448 | |
1449 | + this.data.get_sto_ing=1; | |
1450 | + | |
1446 | 1451 | var timer_get = setInterval(function() { |
1447 | 1452 | if (th.data.is_get_local_ok == 0) return false; |
1448 | 1453 | if (!th.data.fir_def_store) return false; |
... | ... | @@ -1557,6 +1562,9 @@ Page({ |
1557 | 1562 | th.deal_pickup(e); |
1558 | 1563 | } |
1559 | 1564 | else{ |
1565 | + | |
1566 | + th.data.get_sto_ing=0; | |
1567 | + | |
1560 | 1568 | th.setData({ |
1561 | 1569 | isshow:1 |
1562 | 1570 | }) |
... | ... | @@ -1835,11 +1843,14 @@ Page({ |
1835 | 1843 | if (!th.data.def_pick_store) { |
1836 | 1844 | th.setData({def_pick_store:e.data.data.pageData[0]}) |
1837 | 1845 | } |
1838 | - | |
1839 | 1846 | } |
1847 | + | |
1848 | + th.data.get_sto_ing=0; | |
1840 | 1849 | } |
1841 | 1850 | }); |
1842 | - } else { | |
1851 | + } else { | |
1852 | + | |
1853 | + th.data.get_sto_ing=0; | |
1843 | 1854 | th.setData({ |
1844 | 1855 | is_show_sto_cat: 0, |
1845 | 1856 | only_pk: e.data.data.pageData |
... | ... | @@ -1991,8 +2002,8 @@ Page({ |
1991 | 2002 | return false; |
1992 | 2003 | } |
1993 | 2004 | |
1994 | - var img=ee.data.iurl+ee.data.data.img_url; | |
1995 | - if(ee.data.prom_act){ | |
2005 | + var img=ee.data.iurl+ee.data.data.image_url; | |
2006 | + if(ee.data.prom_act && ee.data.prom_act.share_img){ | |
1996 | 2007 | img=ee.data.iurl+ee.data.prom_act.share_img; |
1997 | 2008 | } |
1998 | 2009 | |
... | ... | @@ -2045,12 +2056,12 @@ Page({ |
2045 | 2056 | |
2046 | 2057 | //--先判断会员状态-- |
2047 | 2058 | var user_info = getApp().globalData.userInfo; |
2048 | - if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { | |
2049 | - wx.navigateTo({ | |
2050 | - url: '/packageE/pages/togoin/togoin', | |
2051 | - }) | |
2052 | - return false; | |
2053 | - } | |
2059 | + // if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { | |
2060 | + // wx.navigateTo({ | |
2061 | + // url: '/packageE/pages/togoin/togoin', | |
2062 | + // }) | |
2063 | + // return false; | |
2064 | + // } | |
2054 | 2065 | |
2055 | 2066 | |
2056 | 2067 | //如果开启了,则不在选择门店 |
... | ... | @@ -4062,7 +4073,14 @@ Page({ |
4062 | 4073 | }) |
4063 | 4074 | }, |
4064 | 4075 | |
4065 | - | |
4076 | + // 预览海报 | |
4077 | + previewPoster() { | |
4078 | + getApp().globalData.no_clear = 1; | |
4079 | + wx.previewImage({ | |
4080 | + current: this.data.shareImgPath, // 当前显示图片的http链接 | |
4081 | + urls: [this.data.shareImgPath], // 需要预览的图片http链接列表 | |
4082 | + }); | |
4083 | + }, | |
4066 | 4084 | |
4067 | 4085 | |
4068 | 4086 | ... | ... |
packageC/pages/presell/cardInfo/goodsInfo.wxml
... | ... | @@ -990,6 +990,7 @@ |
990 | 990 | <warn id="warn"></warn> |
991 | 991 | <!-- 分享控件,底部弹出 --> |
992 | 992 | <share id="share_button" bind:send="send" bind:cancel="cancel" bind:share_img="saveImageFn" wx:if="{{share_hidden}}"></share> |
993 | + | |
993 | 994 | <view wx:if="{{showPoster}}"> |
994 | 995 | <view class="mask" catchtap="closePoster"></view> |
995 | 996 | <view class="poster-container"> | ... | ... |
packageC/pages/presell/cart/cart.js
packageC/pages/presell/cart/cart2.js
... | ... | @@ -134,7 +134,14 @@ Page({ |
134 | 134 | bconfig:null, |
135 | 135 | showFold:true, |
136 | 136 | |
137 | - is_fwk:0 //-- 判断是不是服务卡项订单 -- | |
137 | + is_fwk:0, //-- 判断是不是服务卡项订单 -- | |
138 | + | |
139 | + //-- 订单促销判断积累 ---2024-2-20 | |
140 | + order_prom_map_ck: {}, | |
141 | + //能不能使用订单促销 | |
142 | + can_use_ord_prom:{}, | |
143 | + //存储订单促销的取价,按照门店进行索引 | |
144 | + show_ord_prom:{}, | |
138 | 145 | }, |
139 | 146 | |
140 | 147 | |
... | ... | @@ -595,7 +602,7 @@ Page({ |
595 | 602 | }); |
596 | 603 | }, |
597 | 604 | |
598 | - //-- 获取到服务卡项的详情 -- | |
605 | + //-- 获取到商品的详情 -- | |
599 | 606 | get_goods_detail(act, prelist,gg){ |
600 | 607 | var th = this; |
601 | 608 | //--------如果goods_id一样,就是要立即购买----- |
... | ... | @@ -728,7 +735,10 @@ Page({ |
728 | 735 | } |
729 | 736 | |
730 | 737 | //这个位置要拿活动的预售价 |
738 | + t.data.data.shop_price_y = t.data.data.shop_price; | |
731 | 739 | t.data.data.shop_price = prelist.presell_money; |
740 | + th.data.old_bn_goods=ut.deep_cp(t.data.data); | |
741 | + | |
732 | 742 | th.setData({ |
733 | 743 | bn_goods: t.data.data, |
734 | 744 | bn_pickname: gg.pick_name, |
... | ... | @@ -832,6 +842,7 @@ Page({ |
832 | 842 | // } |
833 | 843 | |
834 | 844 | th.setData({dis_btn:1}) |
845 | + this.data.submit=0; | |
835 | 846 | |
836 | 847 | wx.showLoading({ |
837 | 848 | title: "处理中.",mask:true |
... | ... | @@ -901,20 +912,24 @@ Page({ |
901 | 912 | //-- 判断订单优惠的叠加 -- |
902 | 913 | var ord_prom=null; |
903 | 914 | var o_condition=allpice; |
904 | - if (o_condition > 0 && th.data.act.is_useorderyh) { | |
905 | - await getApp().request.promiseGet("/api/weshop/promorder/getOrderPromotion", { | |
906 | - data: { store_id: os.stoid, orderAmount: o_condition, user_id: getApp().globalData.user_id } | |
907 | - }).then(res => { | |
908 | - if (res.data.code == 0) { | |
909 | - ord_prom = res.data.data; | |
910 | - } | |
911 | - }) | |
915 | + if (th.data.act.is_useorderyh) { | |
916 | + // await getApp().request.promiseGet("/api/weshop/promorder/getOrderPromotion", { | |
917 | + // data: { store_id: os.stoid, orderAmount: o_condition, user_id: getApp().globalData.user_id } | |
918 | + // }).then(res => { | |
919 | + // if (res.data.code == 0) { | |
920 | + // ord_prom = res.data.data; | |
921 | + // } | |
922 | + // }) | |
923 | + | |
924 | + th.set_by_now_ord_prom(th.data.bn_goods); | |
925 | + th.data.order_prom_map_ck[bn_pick].goods_price_all=o_condition; | |
926 | + ord_prom=await th.get_cur_ord_prom(bn_pick); | |
912 | 927 | } |
913 | 928 | |
914 | 929 | //-----------当地址不为空,且是物流时,计算物流费用,并同时商品不是优惠活动的包邮,同时商品购买时候,服务卡项购买不计算运费---------- |
915 | 930 | if (th.data.user_addr != null && th.data.bn_exp_type == 0 && good.is_past != 1 && th.data.act.goods_type==0) { |
916 | 931 | //看是不是有调用过包邮券 |
917 | - if (!th.data.isget_by_quan[th.data.bn_pick] && good.is_xz_yh != 1) { | |
932 | + if (!th.data.isget_by_quan[th.data.bn_pick] && good.is_xz_yh != 1 && !th.data.can_use_ord_prom[th.data.bn_pick] ) { | |
918 | 933 | var condition = allpice - cut_price - quan_price; |
919 | 934 | //--判断要不要显示包邮券,链式调用接口,调取包邮券,已经是减了优惠的金额,见到优惠券的钱--- |
920 | 935 | getApp().request.promiseGet("/api/weshop/userfeemail/pageAndArea", { |
... | ... | @@ -944,6 +959,12 @@ Page({ |
944 | 959 | }) |
945 | 960 | } |
946 | 961 | |
962 | + //要让包邮券消失,在使用非实收包邮券的时候 | |
963 | + if(th.data.can_use_ord_prom[th.data.bn_pick]){ | |
964 | + th.setData({ get_by_quan_list: null }); | |
965 | + th.data.isget_by_quan[th.data.bn_pick] = 0; | |
966 | + } | |
967 | + | |
947 | 968 | var shipping_price =0; |
948 | 969 | if(good.is_free_shipping == 0 ) { |
949 | 970 | //-- 在没有使用包邮券的时候 -- |
... | ... | @@ -1568,6 +1589,57 @@ Page({ |
1568 | 1589 | 'prom_id': th.data.bn_goods.prom_id, //促销活动id |
1569 | 1590 | }; |
1570 | 1591 | |
1592 | + if(th.data.bn_goods.discount_field){ | |
1593 | + goods.discount_field=th.data.bn_goods.discount_field; | |
1594 | + } | |
1595 | + | |
1596 | + //如果有参与非实收的订单促销,那么就相当于是普通购买 | |
1597 | + if(th.data.can_use_ord_prom[th.data.bn_pick]){ | |
1598 | + goods.is_integral_normal=1; | |
1599 | + //如果是指定门店,就要判断 | |
1600 | + if (th.data.bn_goods.pick_group_ids) { | |
1601 | + var idx0 = th.data.bn_goods.pick_up_lists.findIndex(function (e) { | |
1602 | + return e.pickup_id == th.data.bn_pick; | |
1603 | + }) | |
1604 | + if (idx0 < 0) { | |
1605 | + getApp().my_warnning(th.data.bn_goods.goods_name + "的门店不可售", 0, th); | |
1606 | + th.data.is_summit_ing = 0; | |
1607 | + th.setData({ | |
1608 | + submit: 0 | |
1609 | + }) | |
1610 | + return false; | |
1611 | + } | |
1612 | + } | |
1613 | + | |
1614 | + if (th.data.sales_rules==1 && th.data.bn_goods.store_count<oods.goods_num){ | |
1615 | + getApp().confirmBox("商品的门店库存不足"); | |
1616 | + th.data.is_summit_ing = 0; | |
1617 | + th.setData({ | |
1618 | + submit: 0 | |
1619 | + }) | |
1620 | + return false; | |
1621 | + } | |
1622 | + //如果不立即购买或者秒杀,如果是线下库存购买的时候 | |
1623 | + if (th.data.sales_rules >= 2 && !th.data.bn_goods.whsle_id && !getApp().is_virtual(th.data.bn_goods)) { | |
1624 | + var isok = 1; | |
1625 | + await th.check_store_num(goods.goods_id, th.data.bn_pick, goods.goods_num, function (res) { | |
1626 | + isok = res; | |
1627 | + }); | |
1628 | + if (!isok) { | |
1629 | + getApp().confirmBox("商品的门店库存不足"); | |
1630 | + th.data.is_summit_ing = 0; | |
1631 | + th.setData({ | |
1632 | + submit: 0 | |
1633 | + }) | |
1634 | + return false; | |
1635 | + } | |
1636 | + } | |
1637 | + | |
1638 | + | |
1639 | + } | |
1640 | + | |
1641 | + | |
1642 | + | |
1571 | 1643 | if(getApp().globalData.skinface_id){ |
1572 | 1644 | goods.skinface_id=getApp().globalData.skinface_id; |
1573 | 1645 | } |
... | ... | @@ -2107,7 +2179,7 @@ Page({ |
2107 | 2179 | } |
2108 | 2180 | }) |
2109 | 2181 | var isok = 1; |
2110 | - if (goods_num > plist.CanOutQty - lock) { | |
2182 | + if (!plist || goods_num > plist.CanOutQty - lock) { | |
2111 | 2183 | isok = 0; |
2112 | 2184 | } |
2113 | 2185 | func(isok); |
... | ... | @@ -3179,8 +3251,158 @@ Page({ |
3179 | 3251 | url= "/pages/goods/goodsInfo/goodsInfo?goods_id="+gid; |
3180 | 3252 | } |
3181 | 3253 | getApp().goto(url); |
3254 | + }, | |
3255 | + | |
3256 | + | |
3257 | + //-- 获取订单促销的判断结构 -- | |
3258 | + set_by_now_ord_prom(item){ | |
3259 | + let pickid=this.data.bn_pick; | |
3260 | + let order_prom_map_ck= this.data.order_prom_map_ck; | |
3261 | + order_prom_map_ck[pickid]={ | |
3262 | + shop_price_all:0, //手店价的累计 | |
3263 | + market_price_all:0, //市场价的累计 | |
3264 | + goods_price_all:0, //实收价的累计 | |
3265 | + no_ord_price:0, //要累计上不参与订单促销的金额 | |
3266 | + goodsList:[], | |
3267 | + } | |
3268 | + | |
3269 | + let pk_ord_map=order_prom_map_ck[pickid]; | |
3270 | + pk_ord_map.shop_price_all += item.shop_price_y * item.buynum; | |
3271 | + pk_ord_map.market_price_all += item.market_price * item.buynum; | |
3272 | + | |
3273 | + }, | |
3274 | + | |
3275 | + //获取当前进行中订单促销,同时带入相应的金额判断订单促销是不是运行,同时订单促销的条件不是实收价判断的话,默认的时候,订单促销是不参与运算的 | |
3276 | + async get_cur_ord_prom(pickid) { | |
3277 | + let ord_prom = null; | |
3278 | + let order_prom_map_ck = this.data.order_prom_map_ck[pickid]; | |
3279 | + if(!order_prom_map_ck) return null; | |
3280 | + | |
3281 | + //获取当前进行中的优惠促销 | |
3282 | + await getApp().request.promiseGet("/api/weshop/promorder/getPromOrder", { | |
3283 | + data: { | |
3284 | + store_id: os.stoid, | |
3285 | + orderAmount: -1, //-1为不判断金额条件 | |
3286 | + user_id: getApp().globalData.user_id | |
3287 | + } | |
3288 | + }).then(res => { | |
3289 | + if (res.data.code == 0) { | |
3290 | + ord_prom = res.data.data; | |
3291 | + } | |
3292 | + }) | |
3293 | + | |
3294 | + if (!ord_prom) return null; | |
3295 | + //用于计算订单促销的金额 | |
3296 | + let calculate_price=0; | |
3297 | + | |
3298 | + let txt1='show_ord_prom['+pickid+']'; | |
3299 | + //-- 此时判断活动的金额满足与否 -- | |
3300 | + switch (ord_prom.discount_field) { | |
3301 | + //实收价的时候 | |
3302 | + case 0: | |
3303 | + //要先还原 | |
3304 | + this.setData({ | |
3305 | + [txt1]: 0 | |
3306 | + }); | |
3307 | + | |
3308 | + if (ord_prom.money > order_prom_map_ck.goods_price_all){ | |
3309 | + return null; | |
3310 | + } | |
3311 | + break; | |
3312 | + //手店价的时候 | |
3313 | + case 1: | |
3314 | + if (ord_prom.money > order_prom_map_ck.shop_price_all){ | |
3315 | + //要先还原 | |
3316 | + this.setData({ | |
3317 | + [txt1]: 0 | |
3318 | + }); | |
3319 | + return null; | |
3320 | + } | |
3321 | + //要显示订单促销使用的按钮 | |
3322 | + this.setData({ | |
3323 | + [txt1]: 1 | |
3324 | + }); | |
3325 | + break; | |
3326 | + //市场价的时候 | |
3327 | + case 2: | |
3328 | + if (ord_prom.money > order_prom_map_ck.market_price_all){ | |
3329 | + //要先还原 | |
3330 | + this.setData({ | |
3331 | + [txt1]: 0 | |
3332 | + }); | |
3333 | + return null; | |
3334 | + } | |
3335 | + //要显示订单促销使用的按钮 | |
3336 | + this.setData({ | |
3337 | + [txt1]: 2 | |
3338 | + }); | |
3339 | + break; | |
3340 | + } | |
3341 | + //如果订单促销是不参与订单促销的,那么就直接返回null(订单促销不是实收价的时候) | |
3342 | + if(ord_prom.discount_field>0 && !this.data.can_use_ord_prom[pickid]){ | |
3343 | + return null; | |
3344 | + } | |
3345 | + return ord_prom; | |
3346 | + }, | |
3347 | + | |
3348 | + //立即购买的时候,点击订单促销的参与 | |
3349 | + set_can_use_ord_prom_now:function (e){ | |
3350 | + | |
3351 | + if(this.data.submit || this.data.dis_btn) return false; | |
3352 | + this.data.submit=1; | |
3353 | + | |
3354 | + let pickid=this.data.bn_pick; | |
3355 | + let txt = 'can_use_ord_prom[' + pickid + ']'; | |
3356 | + let can_use = this.data.can_use_ord_prom[pickid] ? this.data.can_use_ord_prom[pickid] : 0; | |
3357 | + this.setData({ | |
3358 | + [txt]: !can_use | |
3359 | + }) | |
3360 | + | |
3361 | + let th=this; | |
3362 | + let good=th.data.bn_goods; | |
3363 | + | |
3364 | + //如果有要参与订单促销的按钮点击后,要修改商品的价格 | |
3365 | + if(th.data.can_use_ord_prom[pickid]){ | |
3366 | + let discount_field=th.data.show_ord_prom[pickid]; | |
3367 | + switch (discount_field){ | |
3368 | + case 1: | |
3369 | + good.shop_price=good.shop_price_y; | |
3370 | + break; | |
3371 | + case 2: | |
3372 | + good.shop_price=good.market_price; | |
3373 | + break; | |
3374 | + } | |
3375 | + //-- 转成普通商品 --- | |
3376 | + good.prom_type=0; | |
3377 | + good.prom_id=0; | |
3378 | + good.integral=0; | |
3379 | + good.discount_field=discount_field; | |
3380 | + | |
3381 | + //把优惠券的使用还原 | |
3382 | + th.setData({ | |
3383 | + selected_quan_list: null, | |
3384 | + using_quan: {} | |
3385 | + }) | |
3386 | + | |
3387 | + }else{ | |
3388 | + good=ut.deep_cp(th.data.old_bn_goods); | |
3389 | + } | |
3390 | + | |
3391 | + th.setData({ | |
3392 | + bn_goods:good | |
3393 | + }) | |
3394 | + wx.showLoading({ | |
3395 | + title: "处理中.", | |
3396 | + mark:true | |
3397 | + }) | |
3398 | + th.calculatePrice2() | |
3399 | + | |
3400 | + if(!th.data.can_use_ord_prom[pickid]){ | |
3401 | + th.get_buy_now_quan(); | |
3402 | + } | |
3182 | 3403 | } |
3183 | 3404 | |
3184 | 3405 | |
3185 | 3406 | |
3407 | + | |
3186 | 3408 | }); | ... | ... |
packageC/pages/presell/cart/cart2.wxml
... | ... | @@ -150,6 +150,15 @@ |
150 | 150 | <icon color="#f23030" size="16" type="info"></icon>{{order.store_prom}} |
151 | 151 | </view> |
152 | 152 | |
153 | + <!-- 订单促销取价规则的优化 --> | |
154 | + <view class="set-mes" wx:if="{{show_ord_prom[bn_pick]}}"> | |
155 | + <view class="use-item" > | |
156 | + <icon bindtap='set_can_use_ord_prom_now' color="{{can_use_ord_prom[bn_pick]?'red':'gray'}}" size="16" type="success"></icon> | |
157 | + <view bindtap='set_can_use_ord_prom_now' class="yu_er">参与订单促销</view> | |
158 | + </view> | |
159 | + </view> | |
160 | + | |
161 | + | |
153 | 162 | <view class="xc-coupon-frame flex-center" data-bn="1" bindtap="open_coupon_list" data-pickid="{{bn_pick}}" hidden="{{is_fwk}}" |
154 | 163 | wx:if="{{(selected_quan_list && selected_quan_list.length>0) || get_by_quan_list!=null}}"> |
155 | 164 | <view class="work-frame flex-space-between"> | ... | ... |
packageC/pages/presell/goodsInfo/goodsInfo.js
... | ... | @@ -1439,6 +1439,9 @@ Page({ |
1439 | 1439 | }, |
1440 | 1440 | |
1441 | 1441 | openSpecModel: function (t) { |
1442 | + | |
1443 | + if(this.data.get_sto_ing) return false; | |
1444 | + | |
1442 | 1445 | var th = this; |
1443 | 1446 | var open_store = t.currentTarget.dataset.ind; |
1444 | 1447 | this.setData({ |
... | ... | @@ -1993,6 +1996,9 @@ Page({ |
1993 | 1996 | |
1994 | 1997 | //---------拿出门店分类和门店------------ |
1995 | 1998 | get_sto(e) { |
1999 | + | |
2000 | + this.data.get_sto_ing=1; | |
2001 | + | |
1996 | 2002 | var th = this, is_normal = e; |
1997 | 2003 | var that=th; |
1998 | 2004 | |
... | ... | @@ -2007,7 +2013,7 @@ Page({ |
2007 | 2013 | if (!th.data.fir_def_store) return false; |
2008 | 2014 | |
2009 | 2015 | var dd = null, i = getApp().request; |
2010 | - if (!th.data.sele_g) return false; | |
2016 | + if (!th.data.sele_g) {th.data.get_sto_ing=0; return false;} | |
2011 | 2017 | |
2012 | 2018 | var g_distr_type = th.data.sele_g.distr_type; |
2013 | 2019 | if (g_distr_type != 0) { |
... | ... | @@ -2149,10 +2155,12 @@ Page({ |
2149 | 2155 | } |
2150 | 2156 | } |
2151 | 2157 | else{ |
2158 | + th.data.get_sto_ing=0; | |
2152 | 2159 | wx.hideLoading(); |
2153 | 2160 | } |
2154 | 2161 | } |
2155 | 2162 | else{ |
2163 | + th.data.get_sto_ing=0; | |
2156 | 2164 | wx.hideLoading(); |
2157 | 2165 | } |
2158 | 2166 | }) |
... | ... | @@ -2263,7 +2271,7 @@ Page({ |
2263 | 2271 | //------------处理门店--------------- |
2264 | 2272 | deal_pickup(e) { |
2265 | 2273 | var th = this; |
2266 | - if (!th.data.sele_g) return false | |
2274 | + if (!th.data.sele_g) { th.data.get_sto_ing=0; return false } | |
2267 | 2275 | |
2268 | 2276 | var g_distr_type = th.data.sele_g.distr_type; |
2269 | 2277 | wx.hideLoading(); |
... | ... | @@ -2419,6 +2427,9 @@ Page({ |
2419 | 2427 | th.setData({ def_pick_store: e.data.data.pageData[0] }) |
2420 | 2428 | } |
2421 | 2429 | } |
2430 | + | |
2431 | + th.data.get_sto_ing=0; | |
2432 | + | |
2422 | 2433 | } else { |
2423 | 2434 | th.setData({ |
2424 | 2435 | is_show_sto_cat: -1, |
... | ... | @@ -2429,10 +2440,12 @@ Page({ |
2429 | 2440 | th.setData({ def_pick_store: e.data.data.pageData[0] }) |
2430 | 2441 | } |
2431 | 2442 | |
2443 | + th.data.get_sto_ing=0; | |
2432 | 2444 | } |
2433 | 2445 | } |
2434 | 2446 | }); |
2435 | 2447 | } else { |
2448 | + th.data.get_sto_ing=0; | |
2436 | 2449 | th.setData({ |
2437 | 2450 | is_show_sto_cat: 0, |
2438 | 2451 | only_pk: e.data.data.pageData |
... | ... | @@ -2453,7 +2466,7 @@ Page({ |
2453 | 2466 | deal_pickup_dline(e) { |
2454 | 2467 | var pkno = [], |
2455 | 2468 | th = this; |
2456 | - if (!th.data.sele_g) return false; | |
2469 | + if (!th.data.sele_g){ th.data.get_sto_ing=0; return false;} | |
2457 | 2470 | |
2458 | 2471 | if (this.data.def_pick_store) { |
2459 | 2472 | pkno.push(this.data.def_pick_store.pickup_no); |
... | ... | @@ -2539,6 +2552,7 @@ Page({ |
2539 | 2552 | } |
2540 | 2553 | |
2541 | 2554 | } else { |
2555 | + th.data.get_sto_ing=0; | |
2542 | 2556 | th.setData({ |
2543 | 2557 | all_sto: null, |
2544 | 2558 | only_pk: null, |
... | ... | @@ -2613,6 +2627,7 @@ Page({ |
2613 | 2627 | th.deal_pickup(em); |
2614 | 2628 | |
2615 | 2629 | } else { |
2630 | + th.data.get_sto_ing=0; | |
2616 | 2631 | th.setData({ |
2617 | 2632 | all_sto: null, |
2618 | 2633 | only_pk: null, |
... | ... | @@ -2621,6 +2636,7 @@ Page({ |
2621 | 2636 | } |
2622 | 2637 | |
2623 | 2638 | } else { |
2639 | + th.data.get_sto_ing=0; | |
2624 | 2640 | th.setData({ |
2625 | 2641 | all_sto: null, |
2626 | 2642 | only_pk: null, |
... | ... | @@ -3998,12 +4014,12 @@ Page({ |
3998 | 4014 | }) |
3999 | 4015 | //--先判断会员状态-- |
4000 | 4016 | var user_info = getApp().globalData.userInfo; |
4001 | - if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { | |
4002 | - wx.navigateTo({ | |
4003 | - url: '/packageE/pages/togoin/togoin', | |
4004 | - }) | |
4005 | - return false; | |
4006 | - } | |
4017 | + // if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { | |
4018 | + // wx.navigateTo({ | |
4019 | + // url: '/packageE/pages/togoin/togoin', | |
4020 | + // }) | |
4021 | + // return false; | |
4022 | + // } | |
4007 | 4023 | |
4008 | 4024 | var th = this; |
4009 | 4025 | var ind = ee.currentTarget.dataset.ind; | ... | ... |
packageE/pages/cart/cart2/cart2.js
... | ... | @@ -178,7 +178,15 @@ Page({ |
178 | 178 | yhcx_act_map: {}, |
179 | 179 | |
180 | 180 | //优惠促销购买次数 |
181 | - yhcx_buy_map:{} | |
181 | + yhcx_buy_map:{}, | |
182 | + | |
183 | + //-- 订单促销判断积累 ---2024-2-20 | |
184 | + order_prom_map_ck: {}, | |
185 | + //能不能使用订单促销 | |
186 | + can_use_ord_prom:{}, | |
187 | + //存储订单促销的取价,按照门店进行索引 | |
188 | + show_ord_prom:{}, | |
189 | + | |
182 | 190 | }, |
183 | 191 | |
184 | 192 | |
... | ... | @@ -944,7 +952,8 @@ Page({ |
944 | 952 | // } |
945 | 953 | // }) |
946 | 954 | |
947 | - th.data.cartlist_y =JSON.parse(JSON.stringify(carr)); //存储原始购物车列表 | |
955 | + th.data.cartlist_y =JSON.parse(JSON.stringify(carr)); //存储原始购物车列表,这个数据还会收到污染 | |
956 | + th.data.cartlist_old =JSON.parse(JSON.stringify(carr)); //存储原始购物车列表 | |
948 | 957 | wx.showLoading(); |
949 | 958 | |
950 | 959 | th.get_cart_next(carr); |
... | ... | @@ -1028,33 +1037,35 @@ Page({ |
1028 | 1037 | var no_zh_num={}; |
1029 | 1038 | //-- 多促销活动调用接口需要的参数,和商品的购买数量和活动的购买数量的请求参数 -- |
1030 | 1039 | |
1031 | - if(!is_change){ | |
1040 | + if(!is_change) { | |
1041 | + //-- 多促销活动调用接口需要的参数,和商品的购买数量和活动的购买数量的请求参数 -- | |
1032 | 1042 | var dug_cx_arr = []; |
1033 | 1043 | //获取 限购 和 多活动的促销---2024-2-1 |
1034 | - for (var i = 0; i < carr.length; i++) { | |
1044 | + for (var iv = 0; iv < carr.length; iv++) { | |
1035 | 1045 | |
1036 | - let item1 = carr[i]; | |
1046 | + let item1 = carr[iv]; | |
1037 | 1047 | //如果不是活动的时候,不是代发商品的时候,不是赠品的时候,不是阶梯商品拆分的,不是组合购拆分的 |
1038 | - if([1, 2, 4, 6, 8, 9].indexOf(item1.prom_type)== -1 && !item1.whsle_id | |
1039 | - && !item1.is_gift && !item1.is_ld_split && !item1.is_zh_split ){ | |
1048 | + if ([1, 2, 4, 6, 8, 9].indexOf(item1.prom_type) == -1 && !item1.whsle_id | |
1049 | + && !item1.is_gift && !item1.is_ld_split && !item1.is_zh_split) { | |
1040 | 1050 | //-- 快速查找,组装查询多活动的列表 -- |
1041 | - let f_idx=dug_cx_arr.findIndex(function (ele) { | |
1051 | + let f_idx = dug_cx_arr.findIndex(function (ele) { | |
1042 | 1052 | return ele.goods_id == item1.goods_id |
1043 | 1053 | }); |
1044 | - if(f_idx==-1) { | |
1045 | - let gd_ite={ | |
1046 | - goods_id:carr[i].goods_id, | |
1047 | - goods_num:1, | |
1048 | - is_limit_show:1, | |
1049 | - is_state:0 | |
1054 | + if (f_idx == -1) { | |
1055 | + let gd_ite = { | |
1056 | + goods_id: carr[iv].goods_id, | |
1057 | + goods_num: 1, | |
1058 | + is_limit_show: 0, | |
1059 | + is_state: 0 | |
1050 | 1060 | } |
1051 | 1061 | dug_cx_arr.push(gd_ite); |
1052 | 1062 | } |
1053 | 1063 | |
1054 | 1064 | } |
1055 | 1065 | |
1056 | - if(is_change){ | |
1057 | - carr[i].collocationList=null; | |
1066 | + | |
1067 | + if (is_change) { | |
1068 | + carr[iv].collocationList = null; | |
1058 | 1069 | } |
1059 | 1070 | } |
1060 | 1071 | //-- 对商品的多促销进行判断 ---2024-2-1-- |
... | ... | @@ -1062,11 +1073,45 @@ Page({ |
1062 | 1073 | await th.buy_pro_group(dug_cx_arr,carr); |
1063 | 1074 | } |
1064 | 1075 | } |
1065 | - | |
1066 | - | |
1067 | 1076 | //在分组的时候,就不要再调用接口,await |
1068 | 1077 | for (var i = 0; i < carr.length; i++) { |
1069 | 1078 | var item = carr[i]; |
1079 | + | |
1080 | + //如果有户有点击参与订单促销的话,那么可以参与订单促销的商品的活动都要清理成0,订单促销在使用过程中的重要方法 | |
1081 | + if (this.data.can_use_ord_prom[item.pick_id]) { | |
1082 | + //从订单促销的order_prom_map_ck数据结构中获取到可以参与的商品列表 | |
1083 | + let gdlist = this.data.order_prom_map_ck[item.pick_id] ? this.data.order_prom_map_ck[item.pick_id].goodsList : null; | |
1084 | + if (gdlist && gdlist.length) { | |
1085 | + //查找商品item1有没有在gdlist中,就要把商品的prom_type清理0 | |
1086 | + let f_idx = gdlist.findIndex(function (ele) { | |
1087 | + return ele.id == item.id | |
1088 | + }); | |
1089 | + if (f_idx != -1) { | |
1090 | + //开始变换商品的价格显示 | |
1091 | + switch (th.data.show_ord_prom[item.pick_id]) { | |
1092 | + case 1: | |
1093 | + carr[i].goods_price = item.shop_price; | |
1094 | + break; | |
1095 | + case 2: | |
1096 | + carr[i].goods_price = item.goods_market_price; | |
1097 | + break; | |
1098 | + } | |
1099 | + | |
1100 | + if(!carr[i].prom_type) carr[i].prom_type=0; | |
1101 | + switch (parseInt(carr[i].prom_type)){ | |
1102 | + case 4: | |
1103 | + carr[i].is_integral_normal = 1; | |
1104 | + break; | |
1105 | + default: | |
1106 | + carr[i].is_pd_normal = 1; | |
1107 | + break; | |
1108 | + } | |
1109 | + carr[i].prom_type = 0; | |
1110 | + carr[i].discount_field = th.data.show_ord_prom[item.pick_id]; | |
1111 | + } | |
1112 | + } | |
1113 | + } | |
1114 | + | |
1070 | 1115 | //-- 如果是等级会员注册返回 -- |
1071 | 1116 | if (is_card_back) { |
1072 | 1117 | th.data.card_name = th.data.userinfo.card_field; |
... | ... | @@ -1192,7 +1237,8 @@ Page({ |
1192 | 1237 | pickup_id:item.pick_id, |
1193 | 1238 | pickup_name:pikname, |
1194 | 1239 | distr_type:item.pickup_distr_type, |
1195 | - keyid:item.keyid | |
1240 | + keyid:item.keyid, | |
1241 | + is_same_city:item.is_same_city, | |
1196 | 1242 | }; |
1197 | 1243 | var e_t = 0, dis_t = 0;//物流方式,配送方式 |
1198 | 1244 | if (item.distr_type == 0) { |
... | ... | @@ -1290,11 +1336,8 @@ Page({ |
1290 | 1336 | if (ie.exp_type == 0 || ie.exp_type == 2) is_a_zt= 0; |
1291 | 1337 | } |
1292 | 1338 | th.setData({ is_all_zt: is_a_zt}); |
1293 | - | |
1294 | 1339 | } |
1295 | 1340 | |
1296 | - | |
1297 | - | |
1298 | 1341 | var cart_commission = 0; |
1299 | 1342 | //-- 循环计算一下线下取价 -- |
1300 | 1343 | for (var k = 0; k < arr.length; k++) { |
... | ... | @@ -1344,6 +1387,24 @@ Page({ |
1344 | 1387 | //-- 如果初始活动在计算的时候,是不满足的时候,就要把活动清理掉 -- |
1345 | 1388 | var is_no_ok=arr[k].show_can_cx[key_o].cur_act.is_no_ok; |
1346 | 1389 | if(is_no_ok==1){ |
1390 | + | |
1391 | + let temp_id=arr[k].show_can_cx[key_o].cur_act.prom_id; | |
1392 | + switch (parseInt(arr[k].show_can_cx[key_o].cur_act.prom_type+'')){ | |
1393 | + case 3: | |
1394 | + var yhcx_act_map=th.data.yhcx_act_map?th.data.yhcx_act_map[temp_id]:null; | |
1395 | + if(yhcx_act_map && !yhcx_act_map.is_order_yh){ | |
1396 | + item1.is_no_order_yh=1; | |
1397 | + } | |
1398 | + break; | |
1399 | + case 7: | |
1400 | + var zhhe_act=th.data.zhhe_act_map?th.data.zhhe_act_map[temp_id]:null; | |
1401 | + if(zhhe_act && !zhhe_act.is_orderyh){ | |
1402 | + item1.is_no_order_yh=1; | |
1403 | + } | |
1404 | + break; | |
1405 | + } | |
1406 | + | |
1407 | + | |
1347 | 1408 | item1.prom_id = 0; |
1348 | 1409 | item1.prom_type = 0; |
1349 | 1410 | |
... | ... | @@ -1352,6 +1413,16 @@ Page({ |
1352 | 1413 | item1.is_act_last=1; //这个是要在前端显示按钮切换的 |
1353 | 1414 | } |
1354 | 1415 | |
1416 | + }else{ | |
1417 | + | |
1418 | + let obj=arr[k].show_can_cx[key_o]; | |
1419 | + //不是优惠促销的不参与 不是订单促销参与(订单促销不是实收价的时候) | |
1420 | + let ck1=obj.no_cj_prom && obj.cur_act.prom_type==3; | |
1421 | + let ck2=th.data.can_use_ord_prom[arr[k].pickup_id]; | |
1422 | + if( !ck1 && !ck2){ | |
1423 | + item1.prom_id = arr[k].show_can_cx[key_o].cur_act.prom_id; | |
1424 | + item1.prom_type = arr[k].show_can_cx[key_o].cur_act.prom_type; | |
1425 | + } | |
1355 | 1426 | } |
1356 | 1427 | } |
1357 | 1428 | } |
... | ... | @@ -1463,8 +1534,6 @@ Page({ |
1463 | 1534 | |
1464 | 1535 | |
1465 | 1536 | } else { |
1466 | - | |
1467 | - | |
1468 | 1537 | item1.act = th.data.zhhe_act_map[item1.prom_id]; |
1469 | 1538 | } |
1470 | 1539 | } |
... | ... | @@ -1609,7 +1678,6 @@ Page({ |
1609 | 1678 | prom_type: item[c].prom_type, |
1610 | 1679 | prom_id: item[c].prom_id, |
1611 | 1680 | } |
1612 | - //单个就不调用了 | |
1613 | 1681 | // let req_d1 = { |
1614 | 1682 | // user_id: getApp().globalData.user_id, goods_ids: [hr], store_id: os.stoid |
1615 | 1683 | // } |
... | ... | @@ -1701,6 +1769,7 @@ Page({ |
1701 | 1769 | ladder_calc.fir_set_arr(u_item1, th); |
1702 | 1770 | } |
1703 | 1771 | |
1772 | + | |
1704 | 1773 | //-- 要判断总开关有没有同城配送 -- |
1705 | 1774 | if(th.data.is_same_city) { |
1706 | 1775 | //----- 判断每一个商品的配送方式,和门店的配送方式 ------- |
... | ... | @@ -2094,6 +2163,8 @@ Page({ |
2094 | 2163 | success: async function (tt) { |
2095 | 2164 | if (tt.data.code == 0) { |
2096 | 2165 | //t.data.data.shop_price = tt.data.data.prom_price; |
2166 | + | |
2167 | + gd.shop_price_y=gd.shop_price; | |
2097 | 2168 | gd.shop_price=t.data.data.shop_price = tt.data.data.prom_user_price; |
2098 | 2169 | th.data.ckeck_quan_price = 0; |
2099 | 2170 | |
... | ... | @@ -2142,6 +2213,9 @@ Page({ |
2142 | 2213 | } |
2143 | 2214 | |
2144 | 2215 | |
2216 | + //用深拷贝把商品缓存起来,方便后面使用 | |
2217 | + th.data.old_bn_goods=ut.deep_cp(gd); | |
2218 | + | |
2145 | 2219 | th.setData({ |
2146 | 2220 | bn_goods: gd, |
2147 | 2221 | bn_pickname: gg.pick_name, |
... | ... | @@ -2170,6 +2244,7 @@ Page({ |
2170 | 2244 | ut.get_active_info(2,gd.prom_id,os.stoid,function(e){ |
2171 | 2245 | |
2172 | 2246 | //t.data.data.shop_price = tt.data.data.prom_price; |
2247 | + gd.shop_price_y=gd.shop_price; | |
2173 | 2248 | gd.shop_price=t.data.data.shop_price = tt.data.data.price; |
2174 | 2249 | |
2175 | 2250 | t.data.data.fir_rate = tt.data.data.fir_rate; |
... | ... | @@ -2209,6 +2284,10 @@ Page({ |
2209 | 2284 | gd.is_xz_yh = 1; |
2210 | 2285 | } |
2211 | 2286 | |
2287 | + | |
2288 | + //用深拷贝把商品缓存起来,方便后面使用 | |
2289 | + th.data.old_bn_goods=ut.deep_cp(gd); | |
2290 | + | |
2212 | 2291 | th.setData({ |
2213 | 2292 | bn_goods: gd, |
2214 | 2293 | bn_pickname: gg.pick_name, |
... | ... | @@ -2980,6 +3059,9 @@ Page({ |
2980 | 3059 | } |
2981 | 3060 | } |
2982 | 3061 | |
3062 | + //重置订单促销判断累计 | |
3063 | + this.re_set_order_prom_map_ck(); | |
3064 | + | |
2983 | 3065 | for (var i in c_arr) { |
2984 | 3066 | var cart_item = c_arr[i]; |
2985 | 3067 | cart_item.prom_pt_json=[]; |
... | ... | @@ -2996,6 +3078,7 @@ Page({ |
2996 | 3078 | |
2997 | 3079 | } |
2998 | 3080 | |
3081 | + | |
2999 | 3082 | //调用函数计算每件商品的单价 |
3000 | 3083 | await th.calc_per(c_arr); |
3001 | 3084 | |
... | ... | @@ -3009,7 +3092,7 @@ Page({ |
3009 | 3092 | |
3010 | 3093 | //-- 经纬度不循环调用接口 -- |
3011 | 3094 | var lon = 0; var lat = 0; |
3012 | - //---循环购物车--- | |
3095 | + //---循环购物车,按照门店订单进行循环--- | |
3013 | 3096 | for (var i in c_arr) { |
3014 | 3097 | //因为搭配购买也是再这里计算,搭配购的is_b_now==1 |
3015 | 3098 | if (th.data.is_b_now == 0) { |
... | ... | @@ -3047,15 +3130,15 @@ Page({ |
3047 | 3130 | |
3048 | 3131 | var no_order_yh = 0; //-- 有些活动不能和订单优惠叠加的金额 -- |
3049 | 3132 | var no_post_temp = 0; //-- 有些活动不能和包邮模板的金额 -- |
3133 | + var no_post_temp_shop_price = 0; //-- 有些活动不能和包邮模板的金额 --因为订单促销有手店价取价 | |
3134 | + var no_post_temp_market_price = 0; //-- 有些活动不能和包邮模板的金额 --因为订单促销有市场价取价 | |
3050 | 3135 | |
3051 | 3136 | if (th.data.using_quan[pickid] != null && th.data.using_quan[pickid] != undefined) |
3052 | 3137 | quan_no = th.data.using_quan[pickid].coupon_no; |
3053 | 3138 | |
3054 | 3139 | //普通券的时候 |
3055 | 3140 | if (quan_no && th.data.using_quan[pickid].isby != 1) { |
3056 | - | |
3057 | 3141 | var IsUserWare=1; |
3058 | - | |
3059 | 3142 | //---获取优惠券优惠--- |
3060 | 3143 | await getApp().request.promiseGet("/api/weshop/couponList/getUseCouponPrice", { |
3061 | 3144 | data: { |
... | ... | @@ -3076,13 +3159,10 @@ Page({ |
3076 | 3159 | quan_price=0; |
3077 | 3160 | break; |
3078 | 3161 | } |
3079 | - | |
3080 | 3162 | } |
3081 | - | |
3082 | 3163 | } |
3083 | 3164 | }) |
3084 | 3165 | |
3085 | - | |
3086 | 3166 | if(!IsUserWare){ |
3087 | 3167 | |
3088 | 3168 | wx.showToast({ |
... | ... | @@ -3112,6 +3192,11 @@ Page({ |
3112 | 3192 | |
3113 | 3193 | //--------循环计算总价----------- |
3114 | 3194 | for (var jc = 0; jc < item.length; jc++) { |
3195 | + //如果item的prom_type==0,没有如果活动的时候,如果是优惠促销和组合促销不满足的时候 | |
3196 | + //或者是组合购和阶梯购多出来的商品 | |
3197 | + if (item[jc].prom_type == 0 && !item[jc].whsle_id && !item[jc].is_no_order_yh) { | |
3198 | + th.get_order_prom_map_ck(item[jc],pickid); | |
3199 | + } | |
3115 | 3200 | |
3116 | 3201 | if (item[jc].whsle_id > 0) { |
3117 | 3202 | whsle_goods_price += item[jc].goods_price * item[jc].goods_num; |
... | ... | @@ -3124,11 +3209,13 @@ Page({ |
3124 | 3209 | if (item[jc].prom_type == 7 && th.data.zhhe_act_map && th.data.zhhe_act_map[item[jc].prom_id] |
3125 | 3210 | && th.data.zhhe_act_map[item[jc].prom_id].is_orderyh) { |
3126 | 3211 | is_no_zh = 1; |
3212 | + th.get_order_prom_map_ck(item[jc],pickid); //有订单优惠叠加的时候,就要构建数据解救 | |
3127 | 3213 | } |
3128 | 3214 | //阶梯购的商品,且有订单优惠的叠加,is_orderyh就是优惠叠加,就要累积阶梯促销的金额 |
3129 | 3215 | if (item[jc].prom_type == 10 && ladder_prom_goods && ladder_prom_goods[item[jc].prom_id] |
3130 | 3216 | && th.data.ladder_map[item[jc].prom_id].is_useorderyh) { |
3131 | 3217 | is_no_zh = 1; |
3218 | + th.get_order_prom_map_ck(item[jc],pickid); //有订单优惠叠加的时候,就要构建数据解救 | |
3132 | 3219 | } |
3133 | 3220 | |
3134 | 3221 | if (is_no_zh) { |
... | ... | @@ -3144,20 +3231,28 @@ Page({ |
3144 | 3231 | var gd_price=item[jc].goods_price; |
3145 | 3232 | if(item[jc].account_fir) gd_price=item[jc].account_fir; |
3146 | 3233 | |
3147 | - | |
3148 | - //组合购和阶梯购是订单优惠是另外算的 | |
3234 | + //组合购和阶梯购是订单优惠是另外算的,不参与订单促销的时候 | |
3149 | 3235 | if(!item[jc].is_order_yh && !item[jc].whsle_id && item[jc].prom_type!=7 && item[jc].prom_type!=10){ |
3150 | 3236 | no_order_yh+=gd_price * item[jc].goods_num; |
3151 | 3237 | if(item[jc].quan_num) no_order_yh-=item[jc].quan_num; //券要把他补回去 |
3152 | - | |
3153 | 3238 | } |
3239 | + //参与订单促销的时候 | |
3240 | + if(item[jc].is_order_yh && !item[jc].whsle_id && item[jc].prom_type!=7 && item[jc].prom_type!=10){ | |
3241 | + th.get_order_prom_map_ck(item[jc],pickid); //有订单优惠叠加的时候,就要构建数据解救 | |
3242 | + } | |
3243 | + | |
3154 | 3244 | if(!item[jc].is_post_temp){ |
3155 | 3245 | no_post_temp+=gd_price * item[jc].goods_num; |
3246 | + no_post_temp_shop_price+=item[jc].shop_price * item[jc].goods_num; | |
3247 | + no_post_temp_market_price+=item[jc].goods_market_price * item[jc].goods_num; | |
3156 | 3248 | if(item[jc].quan_num) no_post_temp-=item[jc].quan_num; //券要把他补回去 |
3157 | 3249 | } |
3158 | 3250 | } |
3251 | + | |
3159 | 3252 | } |
3160 | 3253 | |
3254 | + | |
3255 | + | |
3161 | 3256 | //判断是不是有组合购的金额 |
3162 | 3257 | var f_o_price = o_price; |
3163 | 3258 | //如果又优惠的钱,就要减价 |
... | ... | @@ -3236,26 +3331,38 @@ Page({ |
3236 | 3331 | ord_prom_condition=o_price - quan_price - whsle_goods_price - no_order_yh; |
3237 | 3332 | } |
3238 | 3333 | |
3239 | - //---判断是不是有订单优惠--- | |
3240 | - await getApp().request.promiseGet("/api/weshop/promorder/getOrderPromotion", { | |
3241 | - data: { store_id: os.stoid, orderAmount: parseFloat(ord_prom_condition).toFixed(2), user_id: getApp().globalData.user_id } | |
3242 | - }).then(res => { | |
3243 | - if (res.data.code == 0) { | |
3244 | - ord_prom = res.data.data; | |
3334 | + //判断订单促销的实收价的累计 | |
3335 | + if(!this.data.order_prom_map_ck[pickid]){ | |
3336 | + this.data.order_prom_map_ck[pickid]={ | |
3337 | + shop_price_all:0, //手店价的累计 | |
3338 | + market_price_all:0, //市场价的累计 | |
3339 | + goods_price_all:0, //实收价的累计 | |
3340 | + no_ord_price:0, //要累计上不参与订单促销的金额 | |
3341 | + goodsList:[], | |
3245 | 3342 | } |
3246 | - }) | |
3343 | + } | |
3344 | + this.data.order_prom_map_ck[pickid].goods_price_all=ord_prom_condition; | |
3345 | + //---判断是不是有订单优惠--- | |
3346 | + // await getApp().request.promiseGet("/api/weshop/promorder/getOrderPromotion", { | |
3347 | + // data: { store_id: os.stoid, orderAmount: parseFloat(ord_prom_condition).toFixed(2), user_id: getApp().globalData.user_id } | |
3348 | + // }).then(res => { | |
3349 | + // if (res.data.code == 0) { | |
3350 | + // ord_prom = res.data.data; | |
3351 | + // } | |
3352 | + // }) | |
3353 | + //获取当前时间段的进行中的订单促销 | |
3354 | + ord_prom=await th.get_cur_ord_prom(pickid); | |
3247 | 3355 | |
3248 | 3356 | //如果有使用优惠券,如何订单促销有控制使用优惠券不参与此活动的话 |
3249 | 3357 | if(quan_price>0 && ord_prom && ord_prom.is_xz_yh ){ |
3250 | 3358 | ord_prom=null; |
3251 | 3359 | } |
3252 | 3360 | |
3253 | - | |
3254 | 3361 | //--如果是物流,且选择了地址,就要开始显示包邮券,且包邮券也已经优惠了优惠活动的金额-- |
3255 | 3362 | if (cart_item.exp_type == 0 && th.data.user_addr != null && !cart_item.is_xz_yh) { |
3256 | 3363 | |
3257 | - //看是不是有调用过包邮券 | |
3258 | - if (!th.data.isget_by_quan[pickid]) { | |
3364 | + //看是不是有调用过包邮券,同时有使用非实收的订单促销,就也不能显示包邮券 | |
3365 | + if (!th.data.isget_by_quan[pickid] && !this.data.can_use_ord_prom[pickid]) { | |
3259 | 3366 | //--判断要不要显示包邮券,调用接口,因为有for循环--- |
3260 | 3367 | await getApp().request.promiseGet("/api/weshop/userfeemail/pageAndArea", { |
3261 | 3368 | data: { |
... | ... | @@ -3297,13 +3404,24 @@ Page({ |
3297 | 3404 | }) |
3298 | 3405 | } |
3299 | 3406 | |
3407 | + //要让包邮券消失,在使用非实收包邮券的时候 | |
3408 | + if(th.data.can_use_ord_prom[pickid]){ | |
3409 | + var tt_by='get_by_quan_list_cart['+pickid+']'; | |
3410 | + th.setData({ [tt_by]: null }); | |
3411 | + th.data.isget_by_quan[pickid] = 0; | |
3412 | + } | |
3413 | + | |
3300 | 3414 | |
3301 | 3415 | //-- 如果没有订单优惠,或者订单优惠中有勾选包邮模板 -- |
3302 | 3416 | if (!ord_prom || ord_prom.is_post_temp) { |
3303 | - var user_addr = th.data.user_addr; | |
3417 | + | |
3418 | + let user_addr = th.data.user_addr; | |
3419 | + let c_wuliu=parseFloat(o_price - quan_price - whsle_goods_price - no_post_temp).toFixed(2); | |
3420 | + | |
3421 | + | |
3304 | 3422 | var req_d = { |
3305 | 3423 | province: user_addr.province, city: user_addr.city, district: user_addr.district, |
3306 | - wuliu: parseFloat(o_price - quan_price - whsle_goods_price - no_post_temp).toFixed(2), store_id: os.stoid | |
3424 | + wuliu: c_wuliu, store_id: os.stoid | |
3307 | 3425 | } |
3308 | 3426 | await getApp().request.promisePost("/api/weshop/order/areaFreight", { |
3309 | 3427 | is_json: 1, data: req_d |
... | ... | @@ -3313,7 +3431,6 @@ Page({ |
3313 | 3431 | } |
3314 | 3432 | } |
3315 | 3433 | |
3316 | - | |
3317 | 3434 | //如果是包邮券的时候,要看看券的情况 |
3318 | 3435 | if (quan_no && th.data.using_quan[pickid].isby == 1) { |
3319 | 3436 | var quan = th.data.using_quan[pickid]; |
... | ... | @@ -3504,24 +3621,25 @@ Page({ |
3504 | 3621 | } |
3505 | 3622 | |
3506 | 3623 | var order_m = 0; |
3507 | - | |
3508 | 3624 | //么有使用券,或者活动没有限制使用优惠券 |
3509 | 3625 | if (ord_prom && (quan_price <= 0 || !ord_prom.is_xz_yh)) { |
3510 | - order_prom_id = ord_prom['id']; | |
3511 | - switch (ord_prom['type']) { | |
3512 | - case 0: | |
3513 | - order_m = Math.round(o_condition * ord_prom['expression']) / 100;//满额打折 | |
3514 | - order_prom_amount = (o_condition - order_m).toFixed(2); | |
3515 | - break; | |
3516 | - case 1: | |
3517 | - //order_m = o_condition - ord_prom['expression'];//满额优惠金额 | |
3518 | - var bs = 1; | |
3519 | - if (ord_prom.is_bz) { | |
3520 | - bs = Math.floor(o_condition / ord_prom.money); | |
3521 | - } | |
3522 | - order_prom_amount = ord_prom['expression']; | |
3523 | - break; | |
3524 | - } | |
3626 | + order_prom_id = ord_prom['id']; | |
3627 | + //-- 订单促销是按照实收价格进行计算的时候 -- | |
3628 | + switch (ord_prom['type']) { | |
3629 | + case 0: | |
3630 | + order_m = Math.round(o_condition * ord_prom['expression']) / 100;//满额打折 | |
3631 | + order_prom_amount = (o_condition - order_m).toFixed(2); | |
3632 | + break; | |
3633 | + case 1: | |
3634 | + //order_m = o_condition - ord_prom['expression'];//满额优惠金额 | |
3635 | + var bs = 1; | |
3636 | + if (ord_prom.is_bz) { | |
3637 | + bs = Math.floor(o_condition / ord_prom.money); | |
3638 | + } | |
3639 | + order_prom_amount = ord_prom['expression']; | |
3640 | + break; | |
3641 | + } | |
3642 | + | |
3525 | 3643 | } |
3526 | 3644 | |
3527 | 3645 | cart_item.order_prom_amount = 0; |
... | ... | @@ -3930,7 +4048,7 @@ Page({ |
3930 | 4048 | //---如果有选择优惠券的情况下--- |
3931 | 4049 | var quan_price = 0, bn_pick = th.data.bn_pick; |
3932 | 4050 | var quan_no = null; |
3933 | - if (th.data.using_quan[bn_pick] != null && th.data.using_quan[bn_pick] != undefined) | |
4051 | + if (th.data.using_quan && th.data.using_quan[bn_pick] != null && th.data.using_quan[bn_pick] != undefined) | |
3934 | 4052 | quan_no = th.data.using_quan[bn_pick].coupon_no; |
3935 | 4053 | |
3936 | 4054 | if (quan_no) { |
... | ... | @@ -3964,15 +4082,22 @@ Page({ |
3964 | 4082 | var ord_prom = null; |
3965 | 4083 | var is_ord_prom_post = 0; |
3966 | 4084 | |
3967 | - if (condition > 0 && th.data.bn_is_order_yh && !th.data.bn_goods.whsle_id) { | |
3968 | - await getApp().request.promiseGet("/api/weshop/promorder/getOrderPromotion", { | |
3969 | - data: { store_id: os.stoid, orderAmount: condition, user_id: getApp().globalData.user_id } | |
3970 | - }).then(res => { | |
3971 | - if (res.data.code == 0) { | |
3972 | - var data = res.data.data; | |
3973 | - ord_prom = data; | |
3974 | - } | |
3975 | - }) | |
4085 | + //一件代发商品不参与订单优惠, 本身商品的活动也有要不要参与优惠促销的设置bn_is_order_yh | |
4086 | + if (th.data.bn_is_order_yh && !th.data.bn_goods.whsle_id) { | |
4087 | + | |
4088 | + th.set_by_now_ord_prom(th.data.bn_goods); | |
4089 | + th.data.order_prom_map_ck[bn_pick].goods_price_all=condition; | |
4090 | + | |
4091 | + // await getApp().request.promiseGet("/api/weshop/promorder/getOrderPromotion", { | |
4092 | + // data: { store_id: os.stoid, orderAmount: condition, user_id: getApp().globalData.user_id } | |
4093 | + // }).then(res => { | |
4094 | + // if (res.data.code == 0) { | |
4095 | + // var data = res.data.data; | |
4096 | + // ord_prom = data; | |
4097 | + // } | |
4098 | + // }) | |
4099 | + ord_prom=await th.get_cur_ord_prom(bn_pick); | |
4100 | + | |
3976 | 4101 | if (ord_prom && ord_prom.is_post_temp) { |
3977 | 4102 | is_ord_prom_post = 1; |
3978 | 4103 | } |
... | ... | @@ -3985,8 +4110,8 @@ Page({ |
3985 | 4110 | |
3986 | 4111 | //-----------当地址不为空,且是物流时,计算物流费用,并同时商品不是优惠活动的包邮---------- |
3987 | 4112 | if (th.data.user_addr != null && th.data.bn_exp_type == 0 && good.is_past != 1) { |
3988 | - //看是不是有调用过包邮券 | |
3989 | - if (!th.data.isget_by_quan[th.data.bn_pick] && good.is_xz_yh != 1) { | |
4113 | + //看是不是有调用过包邮券,同时非实收订单促销也不用使用包邮券 | |
4114 | + if (!th.data.isget_by_quan[th.data.bn_pick] && good.is_xz_yh != 1 && !th.data.can_use_ord_prom[th.data.bn_pick]) { | |
3990 | 4115 | |
3991 | 4116 | //--判断要不要显示包邮券,链式调用接口,调取包邮券,已经是减了优惠的金额,见到优惠券的钱--- |
3992 | 4117 | getApp().request.promiseGet("/api/weshop/userfeemail/pageAndArea", { |
... | ... | @@ -4019,6 +4144,14 @@ Page({ |
4019 | 4144 | }) |
4020 | 4145 | } |
4021 | 4146 | |
4147 | + | |
4148 | + //要让包邮券消失,在使用非实收包邮券的时候 | |
4149 | + if(th.data.can_use_ord_prom[th.data.bn_pick]){ | |
4150 | + th.setData({ get_by_quan_list: null }); | |
4151 | + th.data.isget_by_quan[th.data.bn_pick] = 0; | |
4152 | + } | |
4153 | + | |
4154 | + | |
4022 | 4155 | var shipping_price = 0; |
4023 | 4156 | var quan_no_goods_arr = null; |
4024 | 4157 | var is_by_quan = 0; |
... | ... | @@ -4280,6 +4413,10 @@ Page({ |
4280 | 4413 | goods_sn: th.data.bn_goods.goods_sn, |
4281 | 4414 | goods_price: th.data.bn_goods.shop_price || th.data.bn_goods.goods_price, |
4282 | 4415 | goods_num: th.data.bn_goods.buynum || th.data.bn_goods.goods_num, |
4416 | + | |
4417 | + account_fir:th.data.bn_goods.shop_price || th.data.bn_goods.goods_price, | |
4418 | + account_yu_fir:0 | |
4419 | + | |
4283 | 4420 | }], |
4284 | 4421 | sto: { |
4285 | 4422 | keyid: th.data.bn_goods.keyid |
... | ... | @@ -4717,6 +4854,9 @@ Page({ |
4717 | 4854 | if (th.data.wu_arr == null || th.data.wu_arr.length <= 0) { |
4718 | 4855 | getApp().my_warnning("读取物流失败", 0, th); |
4719 | 4856 | th.data.is_summit_ing = 0; |
4857 | + th.setData({ | |
4858 | + submit: 0 | |
4859 | + }) | |
4720 | 4860 | return false; |
4721 | 4861 | } |
4722 | 4862 | |
... | ... | @@ -4853,6 +4993,29 @@ Page({ |
4853 | 4993 | 'prom_id': th.data.bn_goods.prom_id, //促销活动id |
4854 | 4994 | }; |
4855 | 4995 | |
4996 | + //如果有参与非实收的订单促销,那么就相当于是普通购买 | |
4997 | + if (th.data.can_use_ord_prom[th.data.bn_pick]) { | |
4998 | + goods.is_pd_normal = 1; | |
4999 | + goods.discount_field = th.data.show_ord_prom[th.data.bn_pick]; | |
5000 | + | |
5001 | + //如果是指定门店,就要判断 | |
5002 | + if (th.data.bn_goods.pick_group_ids) { | |
5003 | + var idx0 = th.data.bn_goods.pick_up_lists.findIndex(function (e) { | |
5004 | + return e.pickup_id == th.data.bn_pick; | |
5005 | + }) | |
5006 | + if (idx0 < 0) { | |
5007 | + getApp().my_warnning(th.data.bn_goods.goods_name + "的门店不可售", 0, th); | |
5008 | + th.data.is_summit_ing = 0; | |
5009 | + th.setData({ | |
5010 | + submit: 0 | |
5011 | + }) | |
5012 | + return false; | |
5013 | + } | |
5014 | + } | |
5015 | + } | |
5016 | + | |
5017 | + | |
5018 | + | |
4856 | 5019 | if (th.data.bn_goods.whsle_id) { |
4857 | 5020 | item.is_whsle = 1; |
4858 | 5021 | item.whsle_id = th.data.bn_goods.whsle_id; |
... | ... | @@ -4903,11 +5066,17 @@ Page({ |
4903 | 5066 | if(mo_num>goods.goods_num){ |
4904 | 5067 | getApp().confirmBox(goods.goods_name + "的未达到起订数量"); |
4905 | 5068 | th.data.is_summit_ing = 0; |
5069 | + th.setData({ | |
5070 | + submit: 0 | |
5071 | + }) | |
4906 | 5072 | return false; |
4907 | 5073 | } |
4908 | 5074 | if(steep>1 && (goods.goods_num-mo_num)%steep!=0 ){ |
4909 | 5075 | getApp().confirmBox(goods.goods_name + "的购买的数量不是起订量的倍数"); |
4910 | 5076 | th.data.is_summit_ing = 0; |
5077 | + th.setData({ | |
5078 | + submit: 0 | |
5079 | + }) | |
4911 | 5080 | return false; |
4912 | 5081 | } |
4913 | 5082 | } |
... | ... | @@ -4916,16 +5085,21 @@ Page({ |
4916 | 5085 | if (goods.prom_type != 1 && goods.prom_type != 6 && goods.prom_type != 2 |
4917 | 5086 | && th.data.sales_rules >= 2 && !th.data.bn_goods.whsle_id && !getApp().is_virtual(th.data.bn_goods)) { |
4918 | 5087 | var isok = 1; |
5088 | + | |
4919 | 5089 | await th.check_store_num(goods.goods_id, th.data.bn_pick, gg.goods_num, function (res) { |
4920 | 5090 | isok = res; |
4921 | 5091 | }); |
4922 | 5092 | if (!isok) { |
4923 | 5093 | getApp().confirmBox("商品的门店库存不足"); |
4924 | 5094 | th.data.is_summit_ing = 0; |
5095 | + th.setData({ | |
5096 | + submit: 0 | |
5097 | + }) | |
4925 | 5098 | return false; |
4926 | 5099 | } |
4927 | 5100 | } |
4928 | 5101 | |
5102 | + | |
4929 | 5103 | //-- 如果有线下取价的话 -- |
4930 | 5104 | if (th.data.bn_goods.is_offline) { |
4931 | 5105 | item.sum_offline_cut = (th.data.bn_goods.shop_price - th.data.bn_goods.offline_price).toFixed(2); |
... | ... | @@ -5040,6 +5214,9 @@ Page({ |
5040 | 5214 | if (th.data.wu_arr == null || th.data.wu_arr.length <= 0) { |
5041 | 5215 | th.data.is_summit_ing = 0; |
5042 | 5216 | getApp().confirmBox("读取物流失败"); |
5217 | + th.setData({ | |
5218 | + submit: 0 | |
5219 | + }) | |
5043 | 5220 | return false; |
5044 | 5221 | } |
5045 | 5222 | } |
... | ... | @@ -5246,6 +5423,26 @@ Page({ |
5246 | 5423 | 'store_id': oo.stoid, |
5247 | 5424 | }; |
5248 | 5425 | |
5426 | + //订单促销取价规则使用 | |
5427 | + if (g_item.discount_field) { | |
5428 | + goods.discount_field =g_item.discount_field; | |
5429 | + //此时要判断商品的门店是不是匹配 | |
5430 | + if(g_item.prom_type==0 && g_item.pick_group_ids){ | |
5431 | + var idx0 = g_item.pick_up_lists.findIndex(function (e) { | |
5432 | + return e.pickup_id == item.pickup_id; | |
5433 | + }) | |
5434 | + if (idx0 < 0) { | |
5435 | + getApp().my_warnning(g_item.goods_name + "的门店不可售", 0, th); | |
5436 | + th.data.is_summit_ing = 0; | |
5437 | + th.setData({ | |
5438 | + submit: 0 | |
5439 | + }) | |
5440 | + return false; | |
5441 | + } | |
5442 | + } | |
5443 | + | |
5444 | + } | |
5445 | + | |
5249 | 5446 | if (g_item.is_pd_normal) { |
5250 | 5447 | goods.is_pd_normal = 1; |
5251 | 5448 | } |
... | ... | @@ -5841,7 +6038,7 @@ Page({ |
5841 | 6038 | }) |
5842 | 6039 | |
5843 | 6040 | var isok = 1; |
5844 | - if (goods_num > plist.CanOutQty - lock) { | |
6041 | + if (!plist || goods_num > plist.CanOutQty - lock) { | |
5845 | 6042 | isok = 0; |
5846 | 6043 | } |
5847 | 6044 | func(isok); |
... | ... | @@ -6531,6 +6728,7 @@ Page({ |
6531 | 6728 | get_cart_quan: async function (order_prom_list_cart) { |
6532 | 6729 | var th = this; |
6533 | 6730 | var user_id = getApp().globalData.user_id; |
6731 | + | |
6534 | 6732 | //等待值的出现 |
6535 | 6733 | //getApp().waitfor2(this,"g_cart_q_time","order_prom_list_cart",async function () { |
6536 | 6734 | //var arr=th.data.order_prom_list_cart; |
... | ... | @@ -6542,6 +6740,12 @@ Page({ |
6542 | 6740 | //------------开始计算使用优惠券相关------------ |
6543 | 6741 | for (var ind in arr) { |
6544 | 6742 | var ep = arr[ind]; |
6743 | + | |
6744 | + //如果门店订单使用订单促销(此订单促销取价规则不是实收价的时候) | |
6745 | + if(th.data.can_use_ord_prom[ep.pickup_id]){ | |
6746 | + continue; | |
6747 | + } | |
6748 | + | |
6545 | 6749 | var goodlist = ep.goods; |
6546 | 6750 | var pickup_id = ep.pickup_id; |
6547 | 6751 | //--更优惠券抵用有关,立即购买的,如果是购物车,如果有等级价还有考虑等级价的东西 |
... | ... | @@ -8423,10 +8627,13 @@ Page({ |
8423 | 8627 | |
8424 | 8628 | var cx_prom_group=this.data.cartlist[idx].show_can_cx[gd_key].act_arr; |
8425 | 8629 | |
8630 | + //-- 切换活动的时候,让订单促销参与不选中 -- | |
8631 | + let tt_wd="can_use_ord_prom["+pk+"]"; | |
8426 | 8632 | th.setData({ |
8427 | 8633 | send_lb:{}, |
8428 | 8634 | month_lb:{}, |
8429 | - send_gf:{} | |
8635 | + send_gf:{}, | |
8636 | + [tt_wd]:0 | |
8430 | 8637 | }) |
8431 | 8638 | |
8432 | 8639 | th.data.prom_goods_map={}; |
... | ... | @@ -8635,6 +8842,9 @@ Page({ |
8635 | 8842 | |
8636 | 8843 | //--- 不参与优惠促销的开关 --- |
8637 | 8844 | no_cj_prom: function (e) { |
8845 | + //避免重复点击 | |
8846 | + if(this.data.submit) return false; | |
8847 | + this.setData({ submit: 1,same_ok:1 }); | |
8638 | 8848 | |
8639 | 8849 | //重新调用cart_next,进行下一步计算 |
8640 | 8850 | wx.showLoading({ |
... | ... | @@ -8719,16 +8929,244 @@ Page({ |
8719 | 8929 | if(!goods[ig].is_gift){ |
8720 | 8930 | n_goods.push(goods[ig]); |
8721 | 8931 | } |
8722 | - } | |
8932 | + } | |
8933 | + | |
8723 | 8934 | //原始数据要有深拷贝不能有地址的牵连 |
8724 | 8935 | th.data.cartlist_y = JSON.parse(JSON.stringify(n_goods)) |
8936 | + //重新调用cart_next,进行下一步计算 | |
8937 | + wx.showLoading({ | |
8938 | + title: "处理中.", | |
8939 | + }) | |
8940 | + this.get_cart_next(null, 1, {prom_type: 0, prom_id: 0}); | |
8941 | + | |
8942 | + }, | |
8943 | + | |
8944 | + //---订单促销累计的数据结构的构建,购物车计算流程的那一部分 | |
8945 | + get_order_prom_map_ck(item,pickid) { | |
8946 | + | |
8947 | + //赠品不计算 | |
8948 | + if(item.is_gift) return false; | |
8949 | + | |
8950 | + var order_prom_map_ck= this.data.order_prom_map_ck; | |
8951 | + if(!order_prom_map_ck[pickid]){ | |
8952 | + order_prom_map_ck[pickid]={ | |
8953 | + shop_price_all:0, //手店价的累计 | |
8954 | + market_price_all:0, //市场价的累计 | |
8955 | + goods_price_all:0, //实收价的累计 | |
8956 | + no_ord_price:0, //要累计上不参与订单促销的金额 | |
8957 | + goodsList:[], | |
8958 | + } | |
8959 | + } | |
8960 | + | |
8961 | + let pk_ord_map=order_prom_map_ck[pickid]; | |
8962 | + pk_ord_map.shop_price_all += item.shop_price * item.goods_num; | |
8963 | + pk_ord_map.market_price_all += item.goods_market_price * item.goods_num; | |
8964 | + | |
8965 | + let ite = { | |
8966 | + id: item.id, | |
8967 | + goods_id: item.goods_id, | |
8968 | + goods_num: item.goods_num, | |
8969 | + prom_type: item.prom_type | |
8970 | + } | |
8971 | + pk_ord_map.goodsList.push(ite); | |
8972 | + }, | |
8973 | + | |
8974 | + | |
8975 | + //-- 秒杀和团购使用 -- | |
8976 | + set_by_now_ord_prom(item){ | |
8977 | + let pickid=this.data.bn_pick; | |
8978 | + let order_prom_map_ck= this.data.order_prom_map_ck; | |
8979 | + order_prom_map_ck[pickid]={ | |
8980 | + shop_price_all:0, //手店价的累计 | |
8981 | + market_price_all:0, //市场价的累计 | |
8982 | + goods_price_all:0, //实收价的累计 | |
8983 | + no_ord_price:0, //要累计上不参与订单促销的金额 | |
8984 | + goodsList:[], | |
8985 | + } | |
8986 | + | |
8987 | + let pk_ord_map=order_prom_map_ck[pickid]; | |
8988 | + pk_ord_map.shop_price_all += item.shop_price_y * item.buynum; | |
8989 | + pk_ord_map.market_price_all += item.market_price * item.buynum; | |
8990 | + | |
8991 | + }, | |
8992 | + | |
8993 | + //重置订单促销判断累计 | |
8994 | + re_set_order_prom_map_ck() { | |
8995 | + this.data.order_prom_map_ck = {} | |
8996 | + }, | |
8997 | + | |
8998 | + //获取当前进行中订单促销,同时带入相应的金额判断订单促销是不是运行,同时订单促销的条件不是实收价判断的话,默认的时候,订单促销是不参与运算的 | |
8999 | + async get_cur_ord_prom(pickid) { | |
9000 | + let ord_prom = null; | |
9001 | + let order_prom_map_ck = this.data.order_prom_map_ck[pickid]; | |
9002 | + if(!order_prom_map_ck) return null; | |
9003 | + | |
9004 | + //获取当前进行中的优惠促销 | |
9005 | + await getApp().request.promiseGet("/api/weshop/promorder/getPromOrder", { | |
9006 | + data: { | |
9007 | + store_id: os.stoid, | |
9008 | + orderAmount: -1, //-1为不判断金额条件 | |
9009 | + user_id: getApp().globalData.user_id | |
9010 | + } | |
9011 | + }).then(res => { | |
9012 | + if (res.data.code == 0) { | |
9013 | + ord_prom = res.data.data; | |
9014 | + } | |
9015 | + }) | |
9016 | + | |
9017 | + if (!ord_prom) return null; | |
9018 | + //用于计算订单促销的金额 | |
9019 | + let calculate_price=0; | |
9020 | + | |
9021 | + let txt1='show_ord_prom['+pickid+']'; | |
9022 | + //-- 此时判断活动的金额满足与否 -- | |
9023 | + switch (ord_prom.discount_field) { | |
9024 | + //实收价的时候 | |
9025 | + case 0: | |
9026 | + //要先还原 | |
9027 | + this.setData({ | |
9028 | + [txt1]: 0 | |
9029 | + }); | |
9030 | + | |
9031 | + if (ord_prom.money > order_prom_map_ck.goods_price_all){ | |
9032 | + return null; | |
9033 | + } | |
9034 | + break; | |
9035 | + //手店价的时候 | |
9036 | + case 1: | |
9037 | + if (ord_prom.money > order_prom_map_ck.shop_price_all){ | |
9038 | + //要先还原 | |
9039 | + this.setData({ | |
9040 | + [txt1]: 0 | |
9041 | + }); | |
9042 | + return null; | |
9043 | + } | |
9044 | + //要显示订单促销使用的按钮 | |
9045 | + this.setData({ | |
9046 | + [txt1]: 1 | |
9047 | + }); | |
9048 | + break; | |
9049 | + //市场价的时候 | |
9050 | + case 2: | |
9051 | + if (ord_prom.money > order_prom_map_ck.market_price_all){ | |
9052 | + //要先还原 | |
9053 | + this.setData({ | |
9054 | + [txt1]: 0 | |
9055 | + }); | |
9056 | + return null; | |
9057 | + } | |
9058 | + //要显示订单促销使用的按钮 | |
9059 | + this.setData({ | |
9060 | + [txt1]: 2 | |
9061 | + }); | |
9062 | + break; | |
9063 | + } | |
9064 | + //如果订单促销是不参与订单促销的,那么就直接返回null(订单促销不是实收价的时候) | |
9065 | + if(ord_prom.discount_field>0 && !this.data.can_use_ord_prom[pickid]){ | |
9066 | + return null; | |
9067 | + } | |
9068 | + return ord_prom; | |
9069 | + }, | |
9070 | + | |
9071 | + //设置能够参与订单促销 | |
9072 | + set_can_use_ord_prom: function (e) { | |
8725 | 9073 | |
9074 | + if(this.data.submit) return false; | |
9075 | + this.setData({ submit: 1,same_ok:1 }); | |
9076 | + | |
9077 | + let pickid = e.currentTarget.dataset.pd; | |
9078 | + let txt = 'can_use_ord_prom[' + pickid + ']'; | |
9079 | + let can_use = this.data.can_use_ord_prom[pickid] ? this.data.can_use_ord_prom[pickid] : 0; | |
9080 | + this.setData({ | |
9081 | + [txt]: !can_use | |
9082 | + }) | |
9083 | + | |
9084 | + //购物车进行还原,一下数据的清理的必须的 | |
9085 | + this.setData({ | |
9086 | + send_lb: {}, | |
9087 | + month_lb: {}, | |
9088 | + send_gf: {} | |
9089 | + }) | |
9090 | + //清空优惠促销的内容 | |
9091 | + this.data.prom_goods_map = {}; | |
8726 | 9092 | |
9093 | + //处理一下商品 | |
9094 | + let goods0 = JSON.parse(JSON.stringify(this.data.cartlist_y)); | |
9095 | + let goods = []; | |
9096 | + for (var ik = 0; ik < goods0.length; ik++) { | |
9097 | + var item_c = goods0[ik]; | |
9098 | + if(item_c.pick_id == pickid && item_c.is_collocation) continue; | |
9099 | + if(item_c.is_gift) continue | |
9100 | + goods.push(item_c); | |
9101 | + } | |
8727 | 9102 | |
9103 | + //原始数据要有深拷贝不能有地址的牵连 | |
9104 | + this.data.cartlist_y = JSON.parse(JSON.stringify(goods)) | |
9105 | + //重新调用cart_next,进行下一步计算 | |
9106 | + wx.showLoading({ | |
9107 | + title: "处理中.", | |
9108 | + mark:true | |
9109 | + }) | |
9110 | + //-- 重新计算一下价格 -- | |
8728 | 9111 | this.get_cart_next(null, 1, {prom_type: 0, prom_id: 0}); |
9112 | + }, | |
8729 | 9113 | |
9114 | + //立即购买的时候,点击订单促销的参与 | |
9115 | + set_can_use_ord_prom_now:function (e){ | |
8730 | 9116 | |
9117 | + if(this.data.submit) return false; | |
9118 | + this.setData({ submit: 1,same_ok:1 }); | |
9119 | + | |
9120 | + let pickid=this.data.bn_pick; | |
9121 | + let txt = 'can_use_ord_prom[' + pickid + ']'; | |
9122 | + let can_use = this.data.can_use_ord_prom[pickid] ? this.data.can_use_ord_prom[pickid] : 0; | |
9123 | + this.setData({ | |
9124 | + [txt]: !can_use | |
9125 | + }) | |
9126 | + | |
9127 | + let th=this; | |
9128 | + let good=th.data.bn_goods; | |
9129 | + | |
9130 | + //如果有要参与订单促销的按钮点击后,要修改商品的价格 | |
9131 | + if(th.data.can_use_ord_prom[pickid]){ | |
9132 | + let discount_field=th.data.show_ord_prom[pickid]; | |
9133 | + switch (discount_field){ | |
9134 | + case 1: | |
9135 | + good.shop_price=good.shop_price_y; | |
9136 | + break; | |
9137 | + case 2: | |
9138 | + good.shop_price=good.market_price; | |
9139 | + break; | |
9140 | + } | |
9141 | + | |
9142 | + //-- 转成普通商品 --- | |
9143 | + good.prom_type=0; | |
9144 | + good.prom_id=0; | |
9145 | + | |
9146 | + th.setData({ | |
9147 | + selected_quan_list: null, | |
9148 | + using_quan:{} | |
9149 | + }) | |
9150 | + | |
9151 | + }else{ | |
9152 | + good=ut.deep_cp(th.data.old_bn_goods); | |
9153 | + } | |
9154 | + | |
9155 | + th.setData({ | |
9156 | + bn_goods:good | |
9157 | + }) | |
9158 | + wx.showLoading({ | |
9159 | + title: "处理中.", | |
9160 | + mark:true | |
9161 | + }) | |
9162 | + th.calculatePrice2() | |
9163 | + | |
9164 | + if(!th.data.can_use_ord_prom[pickid]){ | |
9165 | + th.get_buy_now_quan(); | |
9166 | + } | |
8731 | 9167 | } |
8732 | 9168 | |
8733 | 9169 | |
9170 | + | |
9171 | + | |
8734 | 9172 | }); | ... | ... |
packageE/pages/cart/cart2/cart2.wxml
... | ... | @@ -104,9 +104,9 @@ |
104 | 104 | <block><text>{{filters.show_gui_ge(items.goods_spec,items.goods_color)}}</text></block> |
105 | 105 | </view> |
106 | 106 | </view> |
107 | - | |
108 | 107 | <!-----商品名称规格------> |
109 | 108 | <view class="order-num flex-space-between"> |
109 | + <!-- 动态显示商品的价格 --> | |
110 | 110 | <view wx:if="{{items.prom_type==10}}" class="co-red">¥<text class="fs36">{{filters.toFix(items.goods_price,2)}}</text><text>({{items.discount}}折)</text></view> |
111 | 111 | <view wx:else class="co-red">¥<text class="fs36">{{filters.toFix(items.goods_price,2)}}</text></view> |
112 | 112 | <view style="color: red;" wx:if="{{items.use_commission && items.use_commission*1>0}}">佣金:{{filters.toFix(items.use_commission/items.goods_num,2)}}*{{items.goods_num}}</view> |
... | ... | @@ -171,8 +171,10 @@ |
171 | 171 | </block> |
172 | 172 | </block> |
173 | 173 | |
174 | - <block wx:if="{{!items.is_gift}}"> | |
175 | - <view class="set-mes" wx:if="{{items.prom_type==3 || (items.prom_type==0 && item.show_can_cx[items.goods_id].no_cj_prom && item.show_can_cx[items.goods_id].sele_prom_type==3) }}"> | |
174 | + <!-- 如果不是点击使用订单促销的话 --> | |
175 | + <block wx:if="{{!can_use_ord_prom[item.pickup_id] && !items.is_gift}}"> | |
176 | + <view class="set-mes" wx:if="{{items.prom_type==3 || (items.prom_type==0 && item.show_can_cx[items.goods_id].no_cj_prom && item.show_can_cx[items.goods_id].sele_prom_type==3) }}"> | |
177 | + | |
176 | 178 | <view class="use-item" data-pidx="{{pidx}}" data-can_cx_idx="{{items.goods_id}}" bindtap='no_cj_prom'> |
177 | 179 | <icon color="{{!item.show_can_cx[items.goods_id].no_cj_prom?'red':'gray'}}" size="16" type="success"></icon> |
178 | 180 | <view class="yu_er">参与优惠活动</view> |
... | ... | @@ -180,6 +182,7 @@ |
180 | 182 | </view> |
181 | 183 | </block> |
182 | 184 | |
185 | + | |
183 | 186 | </block> |
184 | 187 | |
185 | 188 | <!--此时是多个商品参与活动的切换 验证活动是不是多个,要不要显示切换,同时要最后一个商品显示 --> |
... | ... | @@ -234,12 +237,15 @@ |
234 | 237 | </block> |
235 | 238 | |
236 | 239 | |
237 | - <view class="set-mes" wx:if="{{pitem.is_duo_gd && pitem.sele_prom_type==3 && util.check_is_last(index,items.goods_id) && !items.is_gift }}"> | |
238 | - <view class="use-item" data-pidx="{{pidx}}" data-can_cx_idx="{{index}}" bindtap='no_cj_prom'> | |
239 | - <icon color="{{!pitem.no_cj_prom?'red':'gray'}}" size="16" type="success"></icon> | |
240 | - <view class="yu_er">参与优惠活动</view> | |
240 | + | |
241 | + <block wx:if="{{!can_use_ord_prom[item.pickup_id]}}"> | |
242 | + <view class="set-mes" wx:if="{{pitem.is_duo_gd && pitem.sele_prom_type==3 && util.check_is_last(index,items.goods_id) && !items.is_gift }}"> | |
243 | + <view class="use-item" data-pidx="{{pidx}}" data-can_cx_idx="{{index}}" bindtap='no_cj_prom'> | |
244 | + <icon color="{{!pitem.no_cj_prom?'red':'gray'}}" size="16" type="success"></icon> | |
245 | + <view class="yu_er">参与优惠活动</view> | |
246 | + </view> | |
241 | 247 | </view> |
242 | - </view> | |
248 | + </block> | |
243 | 249 | |
244 | 250 | </block> |
245 | 251 | </block> |
... | ... | @@ -348,6 +354,14 @@ |
348 | 354 | </block> |
349 | 355 | </view> |
350 | 356 | |
357 | + <!-- 订单促销取价规则的优化 --> | |
358 | + <view class="set-mes" wx:if="{{show_ord_prom[item.pickup_id]}}"> | |
359 | + <view class="use-item" > | |
360 | + <icon data-pd="{{item.pickup_id}}" bindtap='set_can_use_ord_prom' color="{{can_use_ord_prom[item.pickup_id]?'red':'gray'}}" size="16" type="success"></icon> | |
361 | + <view data-pd="{{item.pickup_id}}" bindtap='set_can_use_ord_prom' class="yu_er">参与订单促销</view> | |
362 | + </view> | |
363 | + </view> | |
364 | + | |
351 | 365 | <!-----使用优惠券------> |
352 | 366 | <view class="xc-coupon-frame flex-center" data-bn="0" bindtap="open_coupon_list" wx:if="{{!(yh_is_xz_yh[item.pickup_id]) && ((item.quan_list && item.quan_list.length>0 ) || get_by_quan_list_cart[item.pickup_id]!=null && item.can_num>0)}}" data-cind="{{pidx}}" data-pickid="{{item.pickup_id}}"> |
353 | 367 | <view class="work-frame flex-space-between"> |
... | ... | @@ -679,6 +693,14 @@ |
679 | 693 | <icon color="#f23030" size="16" type="info"></icon>{{order.store_prom}} |
680 | 694 | </view> |
681 | 695 | |
696 | + <!-- 订单促销取价规则的优化 --> | |
697 | + <view class="set-mes" wx:if="{{show_ord_prom[bn_pick]}}"> | |
698 | + <view class="use-item" > | |
699 | + <icon bindtap='set_can_use_ord_prom_now' color="{{can_use_ord_prom[bn_pick]?'red':'gray'}}" size="16" type="success"></icon> | |
700 | + <view bindtap='set_can_use_ord_prom_now' class="yu_er">参与订单促销</view> | |
701 | + </view> | |
702 | + </view> | |
703 | + | |
682 | 704 | <view class="xc-coupon-frame flex-center" data-bn="1" bindtap="open_coupon_list" data-pickid="{{bn_pick}}" hidden="{{(selected_quan_list?selected_quan_list.length:0)+ (get_by_quan_list && bn_exp_type==0?get_by_quan_list.length:0)<=0}}" wx:if="{{is_coupon > 0 && ((selected_quan_list && selected_quan_list.length>0) || get_by_quan_list!=null)}}"> |
683 | 705 | <view class="work-frame flex-space-between"> |
684 | 706 | <view class="work"> |
... | ... | @@ -1096,7 +1118,7 @@ |
1096 | 1118 | </view> |
1097 | 1119 | <view class="count"> |
1098 | 1120 | <view bindtap="{{items.goods_num <= 1 ? '':'subNum'}}" class="sub fs28 {{items.goods_num <= 1 ? 'active':''}}" data-pitems="{{pidx}}" data-item="{{idx}}">一</view> |
1099 | - <input class="goodadd" bindblur="valueToNum" data-item="{{idx}}" bindinput="refresh_input" data-item="{{idx}}" type="number" value="{{items.goods_num}}"></input> | |
1121 | + <input class="goodadd" bindblur="valueToNum" data-item="{{idx}}" bindinput="refresh_input" type="number" value="{{items.goods_num}}"></input> | |
1100 | 1122 | <view class="add" bindtap="addNum" data-item="{{idx}}">+</view> |
1101 | 1123 | </view> |
1102 | 1124 | </view> | ... | ... |
packageE/pages/cart/cart2/filter.wxs
... | ... | @@ -49,14 +49,11 @@ function check_is_last(index,goods_id){ |
49 | 49 | return true; |
50 | 50 | } |
51 | 51 | return false; |
52 | - | |
53 | 52 | } |
54 | 53 | |
55 | - | |
56 | - | |
57 | 54 | module.exports = { |
58 | 55 | format: format, |
59 | 56 | is_more_act:is_more_act, |
60 | 57 | check_show:check_show, |
61 | - check_is_last:check_is_last | |
58 | + check_is_last:check_is_last, | |
62 | 59 | } | ... | ... |
packageE/pages/cart/cart2/ladder_calculate.js
... | ... | @@ -115,6 +115,11 @@ module.exports = { |
115 | 115 | }) |
116 | 116 | //goods[idx].goods_num -= num; |
117 | 117 | let new_g = JSON.parse(JSON.stringify(goods[idx])); |
118 | + | |
119 | + //多余的商品如果活动不参与订单促销,那么变成普通商品的也不能参与订单促销,2024-2-26 | |
120 | + if(!ladder_map.is_useorderyh){ | |
121 | + new_g.is_no_order_yh=1; | |
122 | + } | |
118 | 123 | new_g.goods_num = num; |
119 | 124 | new_g.prom_type = 0; |
120 | 125 | new_g.prom_id = 0; | ... | ... |
packageE/pages/cart/cart2/zh_calculate.js
... | ... | @@ -270,6 +270,11 @@ module.exports = { |
270 | 270 | let new_g = JSON.parse(JSON.stringify(goods[idx])); |
271 | 271 | |
272 | 272 | if(new_g.more_cx) delete new_g.more_cx; |
273 | + | |
274 | + //多余的商品如果活动不参与订单促销,那么变成普通商品的也不能参与订单促销,2024-2-26 | |
275 | + if(!act.is_orderyh){ | |
276 | + new_g.is_no_order_yh=1; | |
277 | + } | |
273 | 278 | new_g.goods_num = num; |
274 | 279 | new_g.prom_type = 0; |
275 | 280 | new_g.prom_id = 0; |
... | ... | @@ -331,6 +336,11 @@ module.exports = { |
331 | 336 | offline_price += item.goods_price - item.offline_price; |
332 | 337 | offline_num += 1; |
333 | 338 | } |
339 | + | |
340 | + //多余的商品如果活动不参与订单促销,那么变成普通商品的也不能参与订单促销,2024-2-26 | |
341 | + if(!act.is_orderyh){ | |
342 | + item.is_no_order_yh=1; | |
343 | + } | |
334 | 344 | item.prom_type = 0; |
335 | 345 | item.prom_id = 0; |
336 | 346 | } | ... | ... |
packageE/pages/cart/cart2_inte/cart2_inte.js
... | ... | @@ -85,7 +85,14 @@ Page({ |
85 | 85 | same_ok:1, //同城配送的控制,默认ok |
86 | 86 | bconfig: null, |
87 | 87 | showFold:true, |
88 | - template_id:[] | |
88 | + template_id:[], | |
89 | + | |
90 | + //-- 订单促销判断积累 ---2024-2-20 | |
91 | + order_prom_map_ck: {}, | |
92 | + //能不能使用订单促销 | |
93 | + can_use_ord_prom:{}, | |
94 | + //存储订单促销的取价,按照门店进行索引 | |
95 | + show_ord_prom:{}, | |
89 | 96 | }, |
90 | 97 | |
91 | 98 | |
... | ... | @@ -632,6 +639,8 @@ Page({ |
632 | 639 | success: async function (tt) { |
633 | 640 | if (tt.data.code == 0 && tt.data.data && tt.data.data.pageData) { |
634 | 641 | var inte_data = tt.data.data.pageData[0]; |
642 | + | |
643 | + gd.shop_price_y=gd.shop_price; | |
635 | 644 | t.data.data.shop_price = inte_data.addmoney; |
636 | 645 | t.data.data.integral = inte_data.integral; |
637 | 646 | |
... | ... | @@ -658,6 +667,9 @@ Page({ |
658 | 667 | |
659 | 668 | |
660 | 669 | |
670 | + //用深拷贝把商品缓存起来,方便后面使用 | |
671 | + th.data.old_bn_goods=ut.deep_cp(t.data.data); | |
672 | + | |
661 | 673 | th.setData({ |
662 | 674 | bn_goods: t.data.data, bn_pickname: gg.pick_name, bn_exp_type: et, index: m_wind, |
663 | 675 | bn_pick: gg.pick_id, bn_t_exp_t: distr_t, bn_exp_type: et,inv_is_post:inte_data.is_post |
... | ... | @@ -742,16 +754,23 @@ Page({ |
742 | 754 | var condition = parseFloat(allpice-cut_price).toFixed(2); |
743 | 755 | var ord_prom = null; |
744 | 756 | var is_ord_prom_post = 0; |
757 | + //---如果有选择优惠券的情况下--- | |
758 | + var quan_price = 0, bn_pick = th.data.bn_pick; | |
759 | + | |
760 | + if (th.data.bn_is_order_yh && !th.data.bn_goods.whsle_id) { | |
761 | + // await getApp().request.promiseGet("/api/weshop/promorder/getOrderPromotion", { | |
762 | + // data: { store_id: os.stoid, orderAmount: condition, user_id: getApp().globalData.user_id } | |
763 | + // }).then(res => { | |
764 | + // if (res.data.code == 0) { | |
765 | + // var data = res.data.data; | |
766 | + // ord_prom = data; | |
767 | + // } | |
768 | + // }) | |
769 | + | |
770 | + th.set_by_now_ord_prom(th.data.bn_goods); | |
771 | + th.data.order_prom_map_ck[bn_pick].goods_price_all=condition; | |
772 | + ord_prom=await th.get_cur_ord_prom(bn_pick); | |
745 | 773 | |
746 | - if (condition > 0 && th.data.bn_is_order_yh && !th.data.bn_goods.whsle_id) { | |
747 | - await getApp().request.promiseGet("/api/weshop/promorder/getOrderPromotion", { | |
748 | - data: { store_id: os.stoid, orderAmount: condition, user_id: getApp().globalData.user_id } | |
749 | - }).then(res => { | |
750 | - if (res.data.code == 0) { | |
751 | - var data = res.data.data; | |
752 | - ord_prom = data; | |
753 | - } | |
754 | - }) | |
755 | 774 | if (ord_prom && ord_prom.is_post_temp) { |
756 | 775 | is_ord_prom_post = 1; |
757 | 776 | } |
... | ... | @@ -894,8 +913,7 @@ Page({ |
894 | 913 | var wl_txt = "formData.shipping_price"; |
895 | 914 | th.setData({ [wl_txt]: 0, }) |
896 | 915 | } |
897 | - //---如果有选择优惠券的情况下--- | |
898 | - var quan_price = 0, bn_pick = th.data.bn_pick; | |
916 | + | |
899 | 917 | |
900 | 918 | //-----------------支付价,优惠券不减物流----------------- |
901 | 919 | var total_m = (parseFloat(allpice)).toFixed(2); |
... | ... | @@ -1281,7 +1299,6 @@ Page({ |
1281 | 1299 | item.samecity_order_amount=th.data.bn_samecity_order_amount; |
1282 | 1300 | } |
1283 | 1301 | |
1284 | - | |
1285 | 1302 | //获取立即购买的商品的信息 |
1286 | 1303 | var gg = to.get_b_now(); |
1287 | 1304 | //--商品的房间号-- |
... | ... | @@ -1319,6 +1336,56 @@ Page({ |
1319 | 1336 | 'prom_id': th.data.bn_goods.prom_id, //促销活动id |
1320 | 1337 | }; |
1321 | 1338 | |
1339 | + if(th.data.bn_goods.discount_field){ | |
1340 | + goods.discount_field=th.data.bn_goods.discount_field; | |
1341 | + } | |
1342 | + | |
1343 | + //如果有参与非实收的订单促销,那么就相当于是普通购买 | |
1344 | + if(th.data.can_use_ord_prom[th.data.bn_pick]){ | |
1345 | + goods.is_integral_normal=1; | |
1346 | + | |
1347 | + //如果是指定门店,就要判断 | |
1348 | + if (th.data.bn_goods.pick_group_ids) { | |
1349 | + var idx0 = th.data.bn_goods.pick_up_lists.findIndex(function (e) { | |
1350 | + return e.pickup_id == th.data.bn_pick; | |
1351 | + }) | |
1352 | + if (idx0 < 0) { | |
1353 | + getApp().my_warnning(th.data.bn_goods.goods_name + "的门店不可售", 0, th); | |
1354 | + th.data.is_summit_ing = 0; | |
1355 | + th.setData({ | |
1356 | + submit: 0 | |
1357 | + }) | |
1358 | + return false; | |
1359 | + } | |
1360 | + } | |
1361 | + | |
1362 | + | |
1363 | + if (th.data.sales_rules==1 && th.data.bn_goods.store_count<oods.goods_num){ | |
1364 | + getApp().confirmBox("商品的门店库存不足"); | |
1365 | + th.data.is_summit_ing = 0; | |
1366 | + th.setData({ | |
1367 | + submit: 0 | |
1368 | + }) | |
1369 | + return false; | |
1370 | + } | |
1371 | + //如果不立即购买或者秒杀,如果是线下库存购买的时候 | |
1372 | + if (th.data.sales_rules >= 2 && !th.data.bn_goods.whsle_id && !getApp().is_virtual(th.data.bn_goods)) { | |
1373 | + var isok = 1; | |
1374 | + await th.check_store_num(goods.goods_id, th.data.bn_pick, goods.goods_num, function (res) { | |
1375 | + isok = res; | |
1376 | + }); | |
1377 | + if (!isok) { | |
1378 | + getApp().confirmBox("商品的门店库存不足"); | |
1379 | + th.data.is_summit_ing = 0; | |
1380 | + th.setData({ | |
1381 | + submit: 0 | |
1382 | + }) | |
1383 | + return false; | |
1384 | + } | |
1385 | + } | |
1386 | + | |
1387 | + } | |
1388 | + | |
1322 | 1389 | if(getApp().globalData.skinface_id){ |
1323 | 1390 | goods.skinface_id=getApp().globalData.skinface_id; |
1324 | 1391 | } |
... | ... | @@ -1535,7 +1602,7 @@ Page({ |
1535 | 1602 | } |
1536 | 1603 | }) |
1537 | 1604 | var isok = 1; |
1538 | - if (goods_num > plist.CanOutQty - lock) { | |
1605 | + if (!plist || goods_num > plist.CanOutQty - lock) { | |
1539 | 1606 | isok = 0; |
1540 | 1607 | } |
1541 | 1608 | func(isok); |
... | ... | @@ -1757,7 +1824,146 @@ Page({ |
1757 | 1824 | var th = this; |
1758 | 1825 | th.setData({bn_use_commission: !th.data.bn_use_commission}); |
1759 | 1826 | th.calculatePrice2(); |
1827 | + }, | |
1828 | + | |
1829 | + //-- 获取订单促销的判断结构 -- | |
1830 | + set_by_now_ord_prom(item){ | |
1831 | + let pickid=this.data.bn_pick; | |
1832 | + let order_prom_map_ck= this.data.order_prom_map_ck; | |
1833 | + order_prom_map_ck[pickid]={ | |
1834 | + shop_price_all:0, //手店价的累计 | |
1835 | + market_price_all:0, //市场价的累计 | |
1836 | + goods_price_all:0, //实收价的累计 | |
1837 | + no_ord_price:0, //要累计上不参与订单促销的金额 | |
1838 | + goodsList:[], | |
1839 | + } | |
1840 | + | |
1841 | + let pk_ord_map=order_prom_map_ck[pickid]; | |
1842 | + pk_ord_map.shop_price_all += item.shop_price_y * item.buynum; | |
1843 | + pk_ord_map.market_price_all += item.market_price * item.buynum; | |
1844 | + | |
1845 | + }, | |
1846 | + | |
1847 | + //获取当前进行中订单促销,同时带入相应的金额判断订单促销是不是运行,同时订单促销的条件不是实收价判断的话,默认的时候,订单促销是不参与运算的 | |
1848 | + async get_cur_ord_prom(pickid) { | |
1849 | + let ord_prom = null; | |
1850 | + let order_prom_map_ck = this.data.order_prom_map_ck[pickid]; | |
1851 | + if(!order_prom_map_ck) return null; | |
1852 | + | |
1853 | + //获取当前进行中的优惠促销 | |
1854 | + await getApp().request.promiseGet("/api/weshop/promorder/getPromOrder", { | |
1855 | + data: { | |
1856 | + store_id: os.stoid, | |
1857 | + orderAmount: -1, //-1为不判断金额条件 | |
1858 | + user_id: getApp().globalData.user_id | |
1859 | + } | |
1860 | + }).then(res => { | |
1861 | + if (res.data.code == 0) { | |
1862 | + ord_prom = res.data.data; | |
1863 | + } | |
1864 | + }) | |
1865 | + | |
1866 | + if (!ord_prom) return null; | |
1867 | + //用于计算订单促销的金额 | |
1868 | + let calculate_price=0; | |
1869 | + | |
1870 | + let txt1='show_ord_prom['+pickid+']'; | |
1871 | + //-- 此时判断活动的金额满足与否 -- | |
1872 | + switch (ord_prom.discount_field) { | |
1873 | + //实收价的时候 | |
1874 | + case 0: | |
1875 | + //要先还原 | |
1876 | + this.setData({ | |
1877 | + [txt1]: 0 | |
1878 | + }); | |
1879 | + | |
1880 | + if (ord_prom.money > order_prom_map_ck.goods_price_all){ | |
1881 | + return null; | |
1882 | + } | |
1883 | + break; | |
1884 | + //手店价的时候 | |
1885 | + case 1: | |
1886 | + if (ord_prom.money > order_prom_map_ck.shop_price_all){ | |
1887 | + //要先还原 | |
1888 | + this.setData({ | |
1889 | + [txt1]: 0 | |
1890 | + }); | |
1891 | + return null; | |
1892 | + } | |
1893 | + //要显示订单促销使用的按钮 | |
1894 | + this.setData({ | |
1895 | + [txt1]: 1 | |
1896 | + }); | |
1897 | + break; | |
1898 | + //市场价的时候 | |
1899 | + case 2: | |
1900 | + if (ord_prom.money > order_prom_map_ck.market_price_all){ | |
1901 | + //要先还原 | |
1902 | + this.setData({ | |
1903 | + [txt1]: 0 | |
1904 | + }); | |
1905 | + return null; | |
1906 | + } | |
1907 | + //要显示订单促销使用的按钮 | |
1908 | + this.setData({ | |
1909 | + [txt1]: 2 | |
1910 | + }); | |
1911 | + break; | |
1912 | + } | |
1913 | + //如果订单促销是不参与订单促销的,那么就直接返回null(订单促销不是实收价的时候) | |
1914 | + if(ord_prom.discount_field>0 && !this.data.can_use_ord_prom[pickid]){ | |
1915 | + return null; | |
1916 | + } | |
1917 | + return ord_prom; | |
1918 | + }, | |
1919 | + | |
1920 | + //立即购买的时候,点击订单促销的参与 | |
1921 | + set_can_use_ord_prom_now:function (e){ | |
1922 | + | |
1923 | + if(this.data.submit) return false; | |
1924 | + this.setData({ submit: 1,same_ok:1 }); | |
1925 | + | |
1926 | + let pickid=this.data.bn_pick; | |
1927 | + let txt = 'can_use_ord_prom[' + pickid + ']'; | |
1928 | + let can_use = this.data.can_use_ord_prom[pickid] ? this.data.can_use_ord_prom[pickid] : 0; | |
1929 | + this.setData({ | |
1930 | + [txt]: !can_use | |
1931 | + }) | |
1932 | + | |
1933 | + let th=this; | |
1934 | + let good=th.data.bn_goods; | |
1935 | + | |
1936 | + //如果有要参与订单促销的按钮点击后,要修改商品的价格 | |
1937 | + if(th.data.can_use_ord_prom[pickid]){ | |
1938 | + let discount_field=th.data.show_ord_prom[pickid]; | |
1939 | + switch (discount_field){ | |
1940 | + case 1: | |
1941 | + good.shop_price=good.shop_price_y; | |
1942 | + break; | |
1943 | + case 2: | |
1944 | + good.shop_price=good.market_price; | |
1945 | + break; | |
1946 | + } | |
1947 | + //-- 转成普通商品 --- | |
1948 | + good.prom_type=0; | |
1949 | + good.prom_id=0; | |
1950 | + good.integral=0; | |
1951 | + good.discount_field=discount_field; | |
1952 | + | |
1953 | + }else{ | |
1954 | + good=ut.deep_cp(th.data.old_bn_goods); | |
1955 | + } | |
1956 | + | |
1957 | + th.setData({ | |
1958 | + bn_goods:good | |
1959 | + }) | |
1960 | + wx.showLoading({ | |
1961 | + title: "处理中.", | |
1962 | + mark:true | |
1963 | + }) | |
1964 | + th.calculatePrice2() | |
1760 | 1965 | } |
1761 | 1966 | |
1762 | 1967 | |
1968 | + | |
1763 | 1969 | }); | ... | ... |
packageE/pages/cart/cart2_inte/cart2_inte.wxml
... | ... | @@ -94,6 +94,14 @@ |
94 | 94 | <icon color="#f23030" size="16" type="info"></icon>{{order.store_prom}} |
95 | 95 | </view> |
96 | 96 | |
97 | + <!-- 订单促销取价规则的优化 --> | |
98 | + <view class="set-mes" wx:if="{{show_ord_prom[bn_pick]}}"> | |
99 | + <view class="use-item" > | |
100 | + <icon bindtap='set_can_use_ord_prom_now' color="{{can_use_ord_prom[bn_pick]?'red':'gray'}}" size="16" type="success"></icon> | |
101 | + <view bindtap='set_can_use_ord_prom_now' class="yu_er">参与订单促销</view> | |
102 | + </view> | |
103 | + </view> | |
104 | + | |
97 | 105 | <view class="xc-coupon-frame flex-center" data-bn="1" bindtap="open_coupon_list" data-pickid="{{bn_pick}}" wx:if="{{(selected_quan_list && selected_quan_list.length>0) || get_by_quan_list!=null}}"> |
98 | 106 | <view class="work-frame flex-space-between"> |
99 | 107 | <view class="work"> | ... | ... |
packageE/pages/cart/cart2_pt/cart2_pt.js
... | ... | @@ -90,6 +90,13 @@ Page({ |
90 | 90 | is_no_by: {}, |
91 | 91 | is_by: {}, |
92 | 92 | is_quan_by: {}, |
93 | + | |
94 | + //-- 订单促销判断积累 ---2024-2-20 | |
95 | + order_prom_map_ck: {}, | |
96 | + //能不能使用订单促销 | |
97 | + can_use_ord_prom:{}, | |
98 | + //存储订单促销的取价,按照门店进行索引 | |
99 | + show_ord_prom:{}, | |
93 | 100 | }, |
94 | 101 | |
95 | 102 | |
... | ... | @@ -444,7 +451,9 @@ Page({ |
444 | 451 | et = 2; |
445 | 452 | } |
446 | 453 | |
454 | + t.data.data.shop_price_y=t.data.data.shop_price | |
447 | 455 | t.data.data.shop_price = gg.goods_price; |
456 | + | |
448 | 457 | //--如果是普通购买的时候-- |
449 | 458 | if (gg.is_normal == 1) { |
450 | 459 | t.data.data.prom_id = 0; |
... | ... | @@ -485,6 +494,8 @@ Page({ |
485 | 494 | |
486 | 495 | } |
487 | 496 | |
497 | + //用深拷贝把商品缓存起来,方便后面使用 | |
498 | + th.data.old_bn_goods=ut.deep_cp(t.data.data); | |
488 | 499 | |
489 | 500 | th.setData({ |
490 | 501 | bn_goods: t.data.data, bn_pickname: gg.pick_name, |
... | ... | @@ -568,7 +579,6 @@ Page({ |
568 | 579 | et = th.data.bn_exp_type; |
569 | 580 | } |
570 | 581 | |
571 | - | |
572 | 582 | //-- 计算获得佣金的金额 -- |
573 | 583 | if (getApp().globalData.userInfo.is_distribut |
574 | 584 | && th.data.dis_config && th.data.dis_config.is_yongjin_dk) { |
... | ... | @@ -591,6 +601,8 @@ Page({ |
591 | 601 | |
592 | 602 | } |
593 | 603 | |
604 | + //用深拷贝把商品缓存起来,方便后面使用 | |
605 | + th.data.old_bn_goods=ut.deep_cp(t.data.data); | |
594 | 606 | |
595 | 607 | th.setData({ |
596 | 608 | bn_goods: t.data.data, bn_pickname: gg.pick_name, |
... | ... | @@ -834,13 +846,17 @@ Page({ |
834 | 846 | |
835 | 847 | if(th.data.bn_is_order_yh && th.data.kt_type != 3 ){ |
836 | 848 | |
837 | - await getApp().request.promiseGet("/api/weshop/promorder/getOrderPromotion", { | |
838 | - data: { store_id: os.stoid, orderAmount: o_condition, user_id: getApp().globalData.user_id } | |
839 | - }).then(res => { | |
840 | - if (res.data.code == 0) { | |
841 | - ord_prom = res.data.data; | |
842 | - } | |
843 | - }) | |
849 | + // await getApp().request.promiseGet("/api/weshop/promorder/getOrderPromotion", { | |
850 | + // data: { store_id: os.stoid, orderAmount: o_condition, user_id: getApp().globalData.user_id } | |
851 | + // }).then(res => { | |
852 | + // if (res.data.code == 0) { | |
853 | + // ord_prom = res.data.data; | |
854 | + // } | |
855 | + // }) | |
856 | + | |
857 | + th.set_by_now_ord_prom(th.data.bn_goods); | |
858 | + th.data.order_prom_map_ck[bn_pick].goods_price_all=o_condition; | |
859 | + ord_prom=await th.get_cur_ord_prom(bn_pick); | |
844 | 860 | } |
845 | 861 | |
846 | 862 | |
... | ... | @@ -853,7 +869,7 @@ Page({ |
853 | 869 | if (th.data.user_addr != null && th.data.bn_exp_type == 0 && (th.data.kt_type != 3 || th.data.bn_goods.is_normal == 1)) { |
854 | 870 | |
855 | 871 | //看是不是有调用过包邮券 |
856 | - if (!th.data.isget_by_quan[th.data.bn_pick] && good.is_xz_yh != 1) { | |
872 | + if (!th.data.isget_by_quan[th.data.bn_pick] && good.is_xz_yh != 1 && !th.data.can_use_ord_prom[th.data.bn_pick] ) { | |
857 | 873 | |
858 | 874 | //--判断要不要显示包邮券,链式调用接口,调取包邮券,已经是减了优惠的金额,见到优惠券的钱--- |
859 | 875 | getApp().request.promiseGet("/api/weshop/userfeemail/pageAndArea", { |
... | ... | @@ -886,6 +902,12 @@ Page({ |
886 | 902 | }) |
887 | 903 | } |
888 | 904 | |
905 | + //要让包邮券消失,在使用非实收包邮券的时候 | |
906 | + if(th.data.can_use_ord_prom[th.data.bn_pick]){ | |
907 | + th.setData({ get_by_quan_list: null }); | |
908 | + th.data.isget_by_quan[th.data.bn_pick] = 0; | |
909 | + } | |
910 | + | |
889 | 911 | if(good.is_free_shipping){ |
890 | 912 | var wl_txt = "formData.shipping_price"; |
891 | 913 | th.setData({ [wl_txt]: 0 }) |
... | ... | @@ -1468,6 +1490,55 @@ Page({ |
1468 | 1490 | 'prom_id': th.data.bn_goods.prom_id, //促销活动id |
1469 | 1491 | }; |
1470 | 1492 | |
1493 | + if(th.data.bn_goods.discount_field){ | |
1494 | + goods.discount_field=th.data.bn_goods.discount_field; | |
1495 | + } | |
1496 | + | |
1497 | + //如果有参与非实收的订单促销,那么就相当于是普通购买 | |
1498 | + if(th.data.can_use_ord_prom[th.data.bn_pick]){ | |
1499 | + goods.is_integral_normal=1; | |
1500 | + | |
1501 | + //如果是指定门店,就要判断 | |
1502 | + if (th.data.bn_goods.pick_group_ids) { | |
1503 | + var idx0 = th.data.bn_goods.pick_up_lists.findIndex(function (e) { | |
1504 | + return e.pickup_id == th.data.bn_pick; | |
1505 | + }) | |
1506 | + if (idx0 < 0) { | |
1507 | + getApp().my_warnning(th.data.bn_goods.goods_name + "的门店不可售", 0, th); | |
1508 | + th.data.is_summit_ing = 0; | |
1509 | + th.setData({ | |
1510 | + submit: 0 | |
1511 | + }) | |
1512 | + return false; | |
1513 | + } | |
1514 | + } | |
1515 | + | |
1516 | + if (th.data.sales_rules==1 && th.data.bn_goods.store_count<goods.goods_num){ | |
1517 | + getApp().confirmBox("商品的门店库存不足"); | |
1518 | + th.data.is_summit_ing = 0; | |
1519 | + th.setData({ | |
1520 | + submit: 0 | |
1521 | + }) | |
1522 | + return false; | |
1523 | + } | |
1524 | + //如果不立即购买或者秒杀,如果是线下库存购买的时候 | |
1525 | + if (th.data.sales_rules >= 2 && !th.data.bn_goods.whsle_id && !getApp().is_virtual(th.data.bn_goods)) { | |
1526 | + var isok = 1; | |
1527 | + await th.check_store_num(goods.goods_id, th.data.bn_pick, goods.goods_num, function (res) { | |
1528 | + isok = res; | |
1529 | + }); | |
1530 | + if (!isok) { | |
1531 | + getApp().confirmBox("商品的门店库存不足"); | |
1532 | + th.data.is_summit_ing = 0; | |
1533 | + th.setData({ | |
1534 | + submit: 0 | |
1535 | + }) | |
1536 | + return false; | |
1537 | + } | |
1538 | + } | |
1539 | + | |
1540 | + } | |
1541 | + | |
1471 | 1542 | if (getApp().globalData.skinface_id) { |
1472 | 1543 | goods.skinface_id = getApp().globalData.skinface_id; |
1473 | 1544 | } |
... | ... | @@ -2260,6 +2331,214 @@ Page({ |
2260 | 2331 | th.setData({ open_quan: 0 }); |
2261 | 2332 | }, |
2262 | 2333 | |
2334 | + //-- 获取订单促销的判断结构 -- | |
2335 | + set_by_now_ord_prom(item){ | |
2336 | + let pickid=this.data.bn_pick; | |
2337 | + let order_prom_map_ck= this.data.order_prom_map_ck; | |
2338 | + order_prom_map_ck[pickid]={ | |
2339 | + shop_price_all:0, //手店价的累计 | |
2340 | + market_price_all:0, //市场价的累计 | |
2341 | + goods_price_all:0, //实收价的累计 | |
2342 | + no_ord_price:0, //要累计上不参与订单促销的金额 | |
2343 | + goodsList:[], | |
2344 | + } | |
2345 | + | |
2346 | + let pk_ord_map=order_prom_map_ck[pickid]; | |
2347 | + pk_ord_map.shop_price_all += item.shop_price_y * item.buynum; | |
2348 | + pk_ord_map.market_price_all += item.market_price * item.buynum; | |
2349 | + | |
2350 | + }, | |
2351 | + | |
2352 | + //获取当前进行中订单促销,同时带入相应的金额判断订单促销是不是运行,同时订单促销的条件不是实收价判断的话,默认的时候,订单促销是不参与运算的 | |
2353 | + async get_cur_ord_prom(pickid) { | |
2354 | + let ord_prom = null; | |
2355 | + let order_prom_map_ck = this.data.order_prom_map_ck[pickid]; | |
2356 | + if(!order_prom_map_ck) return null; | |
2357 | + | |
2358 | + //获取当前进行中的优惠促销 | |
2359 | + await getApp().request.promiseGet("/api/weshop/promorder/getPromOrder", { | |
2360 | + data: { | |
2361 | + store_id: os.stoid, | |
2362 | + orderAmount: -1, //-1为不判断金额条件 | |
2363 | + user_id: getApp().globalData.user_id | |
2364 | + } | |
2365 | + }).then(res => { | |
2366 | + if (res.data.code == 0) { | |
2367 | + ord_prom = res.data.data; | |
2368 | + } | |
2369 | + }) | |
2370 | + | |
2371 | + if (!ord_prom) return null; | |
2372 | + //用于计算订单促销的金额 | |
2373 | + let calculate_price=0; | |
2374 | + | |
2375 | + let txt1='show_ord_prom['+pickid+']'; | |
2376 | + //-- 此时判断活动的金额满足与否 -- | |
2377 | + switch (ord_prom.discount_field) { | |
2378 | + //实收价的时候 | |
2379 | + case 0: | |
2380 | + //要先还原 | |
2381 | + this.setData({ | |
2382 | + [txt1]: 0 | |
2383 | + }); | |
2384 | + | |
2385 | + if (ord_prom.money > order_prom_map_ck.goods_price_all){ | |
2386 | + return null; | |
2387 | + } | |
2388 | + break; | |
2389 | + //手店价的时候 | |
2390 | + case 1: | |
2391 | + if (ord_prom.money > order_prom_map_ck.shop_price_all){ | |
2392 | + //要先还原 | |
2393 | + this.setData({ | |
2394 | + [txt1]: 0 | |
2395 | + }); | |
2396 | + return null; | |
2397 | + } | |
2398 | + //要显示订单促销使用的按钮 | |
2399 | + this.setData({ | |
2400 | + [txt1]: 1 | |
2401 | + }); | |
2402 | + break; | |
2403 | + //市场价的时候 | |
2404 | + case 2: | |
2405 | + if (ord_prom.money > order_prom_map_ck.market_price_all){ | |
2406 | + //要先还原 | |
2407 | + this.setData({ | |
2408 | + [txt1]: 0 | |
2409 | + }); | |
2410 | + return null; | |
2411 | + } | |
2412 | + //要显示订单促销使用的按钮 | |
2413 | + this.setData({ | |
2414 | + [txt1]: 2 | |
2415 | + }); | |
2416 | + break; | |
2417 | + } | |
2418 | + //如果订单促销是不参与订单促销的,那么就直接返回null(订单促销不是实收价的时候) | |
2419 | + if(ord_prom.discount_field>0 && !this.data.can_use_ord_prom[pickid]){ | |
2420 | + return null; | |
2421 | + } | |
2422 | + return ord_prom; | |
2423 | + }, | |
2424 | + | |
2425 | + //立即购买的时候,点击订单促销的参与 | |
2426 | + set_can_use_ord_prom_now:function (e){ | |
2427 | + | |
2428 | + if(this.data.submit) return false; | |
2429 | + this.setData({ submit: 1,same_ok:1 }); | |
2430 | + | |
2431 | + let pickid=this.data.bn_pick; | |
2432 | + let txt = 'can_use_ord_prom[' + pickid + ']'; | |
2433 | + let can_use = this.data.can_use_ord_prom[pickid] ? this.data.can_use_ord_prom[pickid] : 0; | |
2434 | + this.setData({ | |
2435 | + [txt]: !can_use | |
2436 | + }) | |
2437 | + | |
2438 | + let th=this; | |
2439 | + let good=th.data.bn_goods; | |
2440 | + | |
2441 | + //如果有要参与订单促销的按钮点击后,要修改商品的价格 | |
2442 | + if(th.data.can_use_ord_prom[pickid]){ | |
2443 | + let discount_field=th.data.show_ord_prom[pickid]; | |
2444 | + switch (discount_field){ | |
2445 | + case 1: | |
2446 | + good.shop_price=good.shop_price_y; | |
2447 | + break; | |
2448 | + case 2: | |
2449 | + good.shop_price=good.market_price; | |
2450 | + break; | |
2451 | + } | |
2452 | + //-- 转成普通商品 --- | |
2453 | + good.prom_type=0; | |
2454 | + good.prom_id=0; | |
2455 | + good.discount_field=discount_field; | |
2456 | + | |
2457 | + //把优惠券的使用还原 | |
2458 | + th.setData({ | |
2459 | + selected_quan_list: null, | |
2460 | + using_quan: {} | |
2461 | + }) | |
2462 | + }else{ | |
2463 | + good=ut.deep_cp(th.data.old_bn_goods); | |
2464 | + } | |
2465 | + | |
2466 | + th.setData({ | |
2467 | + bn_goods:good | |
2468 | + }) | |
2469 | + wx.showLoading({ | |
2470 | + title: "处理中.", | |
2471 | + mark:true | |
2472 | + }) | |
2473 | + th.calculatePrice2() | |
2474 | + | |
2475 | + if(!th.data.can_use_ord_prom[pickid]){ | |
2476 | + th.get_buy_now_quan(); | |
2477 | + } | |
2478 | + }, | |
2479 | + | |
2480 | + //---确认线下门店的数量足不足--- | |
2481 | + async check_store_num(goods_id, pick, goods_num, func) { | |
2482 | + var lock = 0, pick_no, plist, erpwareid; | |
2483 | + | |
2484 | + var lock_rq = { store_id: os.stoid, wareId: goods_id, storageId: pick, pageSize: 1000 }; | |
2485 | + if (this.data.sales_rules == 3) { | |
2486 | + lock_rq.appoint_pick_keyid = this.data.appoint_pick_keyid; | |
2487 | + delete lock_rq.storageId | |
2488 | + } | |
2489 | + //先读取门店的lock | |
2490 | + await getApp().request.promiseGet("/api/weshop/order/ware/lock/page", { | |
2491 | + data: lock_rq | |
2492 | + }).then(res => { | |
2493 | + if (res.data.code == 0 && res.data.data.total > 0) { | |
2494 | + for (var i in res.data.data.pageData) | |
2495 | + lock += res.data.data.pageData[i].outQty; | |
2496 | + } | |
2497 | + }) | |
2498 | + | |
2499 | + if (this.data.sales_rules == 2) { | |
2500 | + //先获取门店的编号 | |
2501 | + await getApp().request.promiseGet("/api/weshop/pickup/get/" + os.stoid + "/" + pick, { | |
2502 | + data: { storeId: os.stoid, goodsId: t.goods_id, pickupId: pick } | |
2503 | + }).then(res => { | |
2504 | + if (res.data.code == 0) { | |
2505 | + pick_no = res.data.data.pickup_no; | |
2506 | + } | |
2507 | + }) | |
2508 | + } | |
2509 | + | |
2510 | + //先获取商品的线下库存 | |
2511 | + await getApp().request.promiseGet("/api/weshop/goods/get/" + os.stoid + "/" + goods_id, { | |
2512 | + data: { storeId: os.stoid, goodsId: t.goods_id, pickupId: pick } | |
2513 | + }).then(res => { | |
2514 | + if (res.data.code == 0) { | |
2515 | + erpwareid = res.data.data.erpwareid; | |
2516 | + } | |
2517 | + }) | |
2518 | + | |
2519 | + | |
2520 | + var sto_rq = { storageNos: pick_no, wareIds: encodeURIComponent(erpwareid), storeId: os.stoid, pageSize: 2000 }; | |
2521 | + if (this.data.sales_rules == 3) { | |
2522 | + sto_rq.storageIds = this.data.appoint_pick_keyid; | |
2523 | + delete sto_rq.storageNos | |
2524 | + } | |
2525 | + | |
2526 | + //读取线下的门店库存 | |
2527 | + await getApp().request.promiseGet("/api/weshop/goods/getWareStorages", { | |
2528 | + data: sto_rq | |
2529 | + }).then(res => { | |
2530 | + if (res.data.code == 0) { | |
2531 | + plist = res.data.data.pageData[0]; | |
2532 | + } | |
2533 | + }) | |
2534 | + | |
2535 | + var isok = 1; | |
2536 | + if (!plist || goods_num > plist.CanOutQty - lock) { | |
2537 | + isok = 0; | |
2538 | + } | |
2539 | + func(isok); | |
2540 | + }, | |
2541 | + | |
2263 | 2542 | |
2264 | 2543 | |
2265 | 2544 | ... | ... |
packageE/pages/cart/cart2_pt/cart2_pt.wxml
... | ... | @@ -102,6 +102,13 @@ |
102 | 102 | <icon color="#f23030" size="16" type="info"></icon>{{order.store_prom}} |
103 | 103 | </view> |
104 | 104 | |
105 | + <!-- 订单促销取价规则的优化 --> | |
106 | + <view class="set-mes" wx:if="{{show_ord_prom[bn_pick]}}"> | |
107 | + <view class="use-item" > | |
108 | + <icon bindtap='set_can_use_ord_prom_now' color="{{can_use_ord_prom[bn_pick]?'red':'gray'}}" size="16" type="success"></icon> | |
109 | + <view bindtap='set_can_use_ord_prom_now' class="yu_er">参与订单促销</view> | |
110 | + </view> | |
111 | + </view> | |
105 | 112 | |
106 | 113 | <view class="xc-coupon-frame flex-center" data-bn="1" bindtap="open_coupon_list" data-pickid="{{bn_pick}}" hidden="{{(selected_quan_list?selected_quan_list.length:0)+ (get_by_quan_list && bn_exp_type==0?get_by_quan_list.length:0)<=0}}" wx:if="{{(selected_quan_list && selected_quan_list.length>0) || get_by_quan_list!=null}}"> |
107 | 114 | <view class="work-frame flex-space-between"> | ... | ... |
packageE/pages/cart/cart_wk/cart_wk.js
packageE/pages/togoin/togoin.js
packageG/pages/goods/search/search.wxml
packageG/pages/user/order_detail/order_detail.js
... | ... | @@ -1157,13 +1157,39 @@ Page({ |
1157 | 1157 | //-- 优惠促销的时候控制取价规则 -- |
1158 | 1158 | // gg.prom_type!=3 && gg.prom_type!=10 同时商品不是普通购买的时候,又参与优惠促销,阶梯促销 |
1159 | 1159 | if((gg.prom_type!=3 && gg.prom_type!=10) || gg.discount_field==undefined || gg.discount_field==0 ) { |
1160 | - if (card_field && gg[card_field] > 0) { | |
1161 | - if (good.goods_price != gg[card_field] && good.offline_cut <= 0) isok = 0; | |
1162 | - if (good.goods_price > gg[card_field] && good.offline_cut > 0) isok = 0; //如果线下价格比较贵,则不通过 | |
1163 | 1160 | |
1164 | - } else { | |
1165 | - if (good.goods_price != gg.shop_price && good.offline_cut <= 0) isok = 0; | |
1166 | - if (good.goods_price > gg.shop_price && good.offline_cut > 0) isok = 0; //如果线下价格比较贵,则不通过 | |
1161 | + | |
1162 | + //判断一下活动是不是有参与订单促销,并且订单促销的活动是不是实收取价,2024-2-23 | |
1163 | + let ordprom_price_type=0; | |
1164 | + if(order.order_prom_id && good.prom_type==0){ | |
1165 | + let p_rs= await getApp().request.promiseGet("/api/weshop/promorder/get/"+os.stoid+"/"+order.order_prom_id, {}); | |
1166 | + if(p_rs && p_rs.data.code==0 && p_rs.data.data){ | |
1167 | + let ord_p=p_rs.data.data; | |
1168 | + if(ord_p && ord_p.discount_field>0){ | |
1169 | + ordprom_price_type=ord_p.discount_field | |
1170 | + } | |
1171 | + } | |
1172 | + } | |
1173 | + if(ordprom_price_type>0){ | |
1174 | + //-- 看一下订单促销的取价规则 -- | |
1175 | + switch (ordprom_price_type){ | |
1176 | + case 1: | |
1177 | + if (good.goods_price != gg.shop_price) isok = 0; | |
1178 | + break; | |
1179 | + case 2: | |
1180 | + if (good.goods_price != gg.market_price) isok = 0; | |
1181 | + break; | |
1182 | + } | |
1183 | + | |
1184 | + }else { | |
1185 | + if (card_field && gg[card_field] > 0) { | |
1186 | + if (good.goods_price != gg[card_field] && good.offline_cut <= 0) isok = 0; | |
1187 | + if (good.goods_price > gg[card_field] && good.offline_cut > 0) isok = 0; //如果线下价格比较贵,则不通过 | |
1188 | + | |
1189 | + } else { | |
1190 | + if (good.goods_price != gg.shop_price && good.offline_cut <= 0) isok = 0; | |
1191 | + if (good.goods_price > gg.shop_price && good.offline_cut > 0) isok = 0; //如果线下价格比较贵,则不通过 | |
1192 | + } | |
1167 | 1193 | } |
1168 | 1194 | }else{ |
1169 | 1195 | if(good.prom_type==3 && good.prom_type==10){ | ... | ... |
pages/cart/cart/cart.js
... | ... | @@ -492,6 +492,21 @@ Page({ |
492 | 492 | } |
493 | 493 | }); |
494 | 494 | |
495 | + if(!app.globalData.user_id){ | |
496 | + | |
497 | + th.setData({ | |
498 | + requestData: [], | |
499 | + all_num: 0, | |
500 | + is_load: 1, | |
501 | + is_edit: 0, | |
502 | + checkAllToggle:0 | |
503 | + }),wx.stopPullDownRefresh(); | |
504 | + | |
505 | + wx.hideLoading(); | |
506 | + | |
507 | + return false; | |
508 | + } | |
509 | + | |
495 | 510 | getApp().request.get("/api/weshop/cart/listNew1", { |
496 | 511 | data: { |
497 | 512 | user_id: app.globalData.user_id, |
... | ... | @@ -503,8 +518,11 @@ Page({ |
503 | 518 | success: async function (su) { |
504 | 519 | console.log(su, 10000); |
505 | 520 | //按门店分类的数组 |
506 | - var arr = new Array(), | |
507 | - carr = su.data.data.pageData; | |
521 | + var arr = new Array(); | |
522 | + var carr=[]; | |
523 | + | |
524 | + if(ut.ajax_ok(su)) | |
525 | + carr = su.data.data.pageData; | |
508 | 526 | var all_num = 0; |
509 | 527 | |
510 | 528 | if (carr && carr.length > 0) { |
... | ... | @@ -530,7 +548,7 @@ Page({ |
530 | 548 | let gd_ite={ |
531 | 549 | goods_id:carr[i].goods_id, |
532 | 550 | goods_num:1, |
533 | - is_limit_show:1, | |
551 | + is_limit_show:0, | |
534 | 552 | is_state:0 |
535 | 553 | } |
536 | 554 | g_arr.push(gd_ite); |
... | ... | @@ -1192,10 +1210,10 @@ Page({ |
1192 | 1210 | // if (this.data.btn_click) { |
1193 | 1211 | // return false; |
1194 | 1212 | // } |
1213 | + | |
1195 | 1214 | setTimeout(() => { |
1196 | 1215 | if (this.data.up_dating == 1) return false; |
1197 | 1216 | this.data.up_dating=1 |
1198 | - | |
1199 | 1217 | this.data.btn_click = 1; |
1200 | 1218 | var a = t.currentTarget.dataset.item; |
1201 | 1219 | var b = t.currentTarget.dataset.pitems; |
... | ... | @@ -2064,6 +2082,8 @@ Page({ |
2064 | 2082 | //判断多门店,优惠促销次数的控制 |
2065 | 2083 | async multiple_stores_pro(pitems, item) { |
2066 | 2084 | |
2085 | + if(!this.data.requestData || !this.data.requestData[pitems]) return false | |
2086 | + | |
2067 | 2087 | let a = this.data.requestData[pitems].goods[item]; |
2068 | 2088 | let th = this |
2069 | 2089 | let arr_pro = [] | ... | ... |
pages/goods/goodsInfo/goodsInfo.js
... | ... | @@ -293,6 +293,8 @@ Page({ |
293 | 293 | |
294 | 294 | fir_set_sto:1, //最初始的一下,获取门店 |
295 | 295 | front_pick:null, //在详情页面上显示的门店 |
296 | + | |
297 | + get_sto_ing:1, //默认是不让弹出框的 | |
296 | 298 | }, |
297 | 299 | |
298 | 300 | //------初始化加载---------- |
... | ... | @@ -2761,6 +2763,8 @@ Page({ |
2761 | 2763 | }, |
2762 | 2764 | |
2763 | 2765 | openSpecModel: function (t) { |
2766 | + | |
2767 | + if(this.data.get_sto_ing) return false; | |
2764 | 2768 | |
2765 | 2769 | var th = this; |
2766 | 2770 | var open_store = t.currentTarget.dataset.ind; |
... | ... | @@ -2774,7 +2778,9 @@ Page({ |
2774 | 2778 | return false; |
2775 | 2779 | } |
2776 | 2780 | |
2777 | - th.setData({def_pick_store: ut.deep_cp(th.data.front_pick)}); | |
2781 | + if(th.data.front_pick && th.data.front_pick.pickup_id>0 ){ | |
2782 | + th.setData({def_pick_store: ut.deep_cp(th.data.front_pick)}); | |
2783 | + } | |
2778 | 2784 | |
2779 | 2785 | this.setData({ |
2780 | 2786 | store: 0, |
... | ... | @@ -3748,6 +3754,7 @@ Page({ |
3748 | 3754 | sp_seleing:0 |
3749 | 3755 | }) |
3750 | 3756 | |
3757 | + | |
3751 | 3758 | }, |
3752 | 3759 | |
3753 | 3760 | |
... | ... | @@ -3758,6 +3765,8 @@ Page({ |
3758 | 3765 | that = this; |
3759 | 3766 | var is_normal = e; |
3760 | 3767 | |
3768 | + th.data.get_sto_ing=1; | |
3769 | + | |
3761 | 3770 | if (e == 1) { |
3762 | 3771 | th.setData({ |
3763 | 3772 | is_normal: 1 |
... | ... | @@ -3772,9 +3781,10 @@ Page({ |
3772 | 3781 | if (th.data.is_get_local_ok == 0) return false; |
3773 | 3782 | if (!th.data.fir_def_store) return false; |
3774 | 3783 | |
3784 | + | |
3775 | 3785 | var dd = null, |
3776 | 3786 | i = getApp().request; |
3777 | - if (!th.data.sele_g) return false; | |
3787 | + if (!th.data.sele_g) {th.data.get_sto_ing=0; return false; } | |
3778 | 3788 | |
3779 | 3789 | var g_distr_type = th.data.sele_g.distr_type; |
3780 | 3790 | if (g_distr_type != 0) { |
... | ... | @@ -3959,12 +3969,14 @@ Page({ |
3959 | 3969 | th.setData({sp_seleing:0}) |
3960 | 3970 | wx.hideLoading(); |
3961 | 3971 | th.data.fir_set_sto=0; |
3972 | + th.data.get_sto_ing=0; | |
3962 | 3973 | } |
3963 | 3974 | } else { |
3964 | 3975 | if(func) func(); |
3965 | 3976 | th.setData({sp_seleing:0}) |
3966 | 3977 | wx.hideLoading(); |
3967 | 3978 | th.data.fir_set_sto=0; |
3979 | + th.data.get_sto_ing=0; | |
3968 | 3980 | } |
3969 | 3981 | },err=>{ |
3970 | 3982 | ut.m_toast('网络繁忙,请稍后重试'); |
... | ... | @@ -3972,6 +3984,7 @@ Page({ |
3972 | 3984 | th.setData({sp_seleing:0}) |
3973 | 3985 | wx.hideLoading(); |
3974 | 3986 | th.data.fir_set_sto=0; |
3987 | + th.data.get_sto_ing=0; | |
3975 | 3988 | }) |
3976 | 3989 | }, 200) |
3977 | 3990 | |
... | ... | @@ -4105,6 +4118,7 @@ Page({ |
4105 | 4118 | var th = this; |
4106 | 4119 | if (!th.data.sele_g){ |
4107 | 4120 | wx.hideLoading(); |
4121 | + th.data.get_sto_ing=0; | |
4108 | 4122 | return false |
4109 | 4123 | } |
4110 | 4124 | |
... | ... | @@ -4337,6 +4351,8 @@ Page({ |
4337 | 4351 | th.deal_front_pk(); |
4338 | 4352 | } |
4339 | 4353 | |
4354 | + th.data.get_sto_ing=0; | |
4355 | + | |
4340 | 4356 | }, |
4341 | 4357 | |
4342 | 4358 | //------------处理线下门店库存-------- |
... | ... | @@ -4443,6 +4459,7 @@ Page({ |
4443 | 4459 | |
4444 | 4460 | |
4445 | 4461 | } else { |
4462 | + th.data.get_sto_ing=0; | |
4446 | 4463 | th.data.fir_set_sto=0; |
4447 | 4464 | th.setData({ |
4448 | 4465 | all_sto: null, |
... | ... | @@ -4542,6 +4559,7 @@ Page({ |
4542 | 4559 | |
4543 | 4560 | } else { |
4544 | 4561 | |
4562 | + th.data.get_sto_ing=0; | |
4545 | 4563 | th.data.fir_set_sto=0; |
4546 | 4564 | th.setData({ |
4547 | 4565 | all_sto: null, |
... | ... | @@ -4552,6 +4570,7 @@ Page({ |
4552 | 4570 | |
4553 | 4571 | } else { |
4554 | 4572 | |
4573 | + th.data.get_sto_ing=0; | |
4555 | 4574 | th.data.fir_set_sto=0; |
4556 | 4575 | th.setData({ |
4557 | 4576 | all_sto: null, |
... | ... | @@ -5488,6 +5507,8 @@ Page({ |
5488 | 5507 | //--点击弹起拼单-- |
5489 | 5508 | openSpecModel_pt:function (e) { |
5490 | 5509 | |
5510 | + if(this.data.get_sto_ing) return false; | |
5511 | + | |
5491 | 5512 | this.setData({ |
5492 | 5513 | open_ind_store: 4, |
5493 | 5514 | goodsInputNum: 1 |
... | ... | @@ -5507,7 +5528,7 @@ Page({ |
5507 | 5528 | //如果是拼单活动的普通购买 |
5508 | 5529 | if (ind == 1) { |
5509 | 5530 | |
5510 | - if(th.data.front_pick){ | |
5531 | + if(th.data.front_pick && th.data.front_pick.pickup_id){ | |
5511 | 5532 | th.setData({def_pick_store: ut.deep_cp(th.data.front_pick)}); |
5512 | 5533 | }else if (th.data.def_pick_store && JSON.stringify(th.data.def_pick_store) != '{}'){ //要把不匹配还原 |
5513 | 5534 | th.data.def_pick_store.is_no_dis_nor=0; |
... | ... | @@ -5710,7 +5731,7 @@ Page({ |
5710 | 5731 | }); |
5711 | 5732 | |
5712 | 5733 | // s.my_warnning('超出商品限购', 0, th); |
5713 | - var num = th.data.prom_buy_limit - th.data.prom_buy_num; | |
5734 | + var num = 0;//th.data.prom_buy_limit - th.data.prom_buy_num; | |
5714 | 5735 | if (num < 0) num = 0; |
5715 | 5736 | th.setData({ |
5716 | 5737 | goodsInputNum: num |
... | ... | @@ -6842,8 +6863,17 @@ Page({ |
6842 | 6863 | // context.fillText("优惠乐翻天,精彩就在你身边", 40 * unit, 816 * unit); |
6843 | 6864 | // context.setFontSize(18 * unit) |
6844 | 6865 | // context.fillText("长按识别二维码,立即开始抢购", 40 * unit, 850 * unit); |
6845 | - //---二维吗图--- | |
6846 | - context.drawImage(vpath, 380 * unit, 736 * unit, 120 * unit, 120 * unit); | |
6866 | + | |
6867 | + if (th.data.share_b_img || th.data.poster) { | |
6868 | + var erm_x = parseFloat(th.data.poster.ewm_x) * 2; | |
6869 | + var erm_y = parseFloat(th.data.poster.ewm_y) * 2; | |
6870 | + context.drawImage(vpath, erm_x * unit, erm_y * unit, 136 * unit, 136 * unit); | |
6871 | + }else{ | |
6872 | + //---二维吗图--- | |
6873 | + context.drawImage(vpath, 380 * unit, 736 * unit, 120 * unit, 120 * unit); | |
6874 | + } | |
6875 | + | |
6876 | + | |
6847 | 6877 | break; //普通商品的展示 |
6848 | 6878 | case 4: |
6849 | 6879 | |
... | ... | @@ -7415,12 +7445,12 @@ Page({ |
7415 | 7445 | }) |
7416 | 7446 | //--先判断会员状态-- |
7417 | 7447 | var user_info = getApp().globalData.userInfo; |
7418 | - if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { | |
7419 | - wx.navigateTo({ | |
7420 | - url: '/packageE/pages/togoin/togoin', | |
7421 | - }) | |
7422 | - return false; | |
7423 | - } | |
7448 | + // if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { | |
7449 | + // wx.navigateTo({ | |
7450 | + // url: '/packageE/pages/togoin/togoin', | |
7451 | + // }) | |
7452 | + // return false; | |
7453 | + // } | |
7424 | 7454 | |
7425 | 7455 | |
7426 | 7456 | //如果开启了,则不在选择门店 |
... | ... | @@ -8559,7 +8589,8 @@ Page({ |
8559 | 8589 | |
8560 | 8590 | //-- 积分购购买弹出框 -- |
8561 | 8591 | go_pay_integral: function () { |
8562 | - | |
8592 | + | |
8593 | + if(this.data.get_sto_ing) return false; | |
8563 | 8594 | //-- 在打开弹出框的时候,front_pk门店要赋值 -- |
8564 | 8595 | this.setData({def_pick_store: ut.deep_cp(this.data.front_pick)}); |
8565 | 8596 | |
... | ... | @@ -8574,10 +8605,11 @@ Page({ |
8574 | 8605 | //-- 积分购普通购买弹出框 -- |
8575 | 8606 | go_pay_integral_normal:async function () { |
8576 | 8607 | |
8608 | + if(this.data.get_sto_ing) return false; | |
8577 | 8609 | this.data.g_buy_num = new Map(); |
8578 | 8610 | var th = this; |
8579 | 8611 | |
8580 | - if(th.data.front_pick){ | |
8612 | + if(th.data.front_pick && th.data.front_pick.pickup_id){ | |
8581 | 8613 | th.setData({def_pick_store: ut.deep_cp(th.data.front_pick)}); |
8582 | 8614 | }else if (th.data.def_pick_store && JSON.stringify(th.data.def_pick_store) != '{}'){ //要把不匹配还原 |
8583 | 8615 | th.data.def_pick_store.is_no_dis_nor=0; |
... | ... | @@ -9148,6 +9180,9 @@ Page({ |
9148 | 9180 | |
9149 | 9181 | //-- 秒杀的普通购买 -- |
9150 | 9182 | openSpecModel_Nor: function () { |
9183 | + | |
9184 | + if(this.data.get_sto_ing) return false; | |
9185 | + | |
9151 | 9186 | this.data.g_buy_num = new Map(); |
9152 | 9187 | var th = this; |
9153 | 9188 | ... | ... |
pages/goods/goodsList/goodsList.js
... | ... | @@ -317,14 +317,14 @@ Page({ |
317 | 317 | //-- 获取 -- |
318 | 318 | await getApp().request.promiseGet("/api/weshop/prom/gift/page?id="+content.gift+"&store_id="+oo.stoid, { |
319 | 319 | }).then(res => { |
320 | - if(ut.ajax_ok(res)) | |
320 | + if(ut.ajax_ok(res)) { | |
321 | + arr[i].content.gift_name = res.data.data.pageData[0].goods_name; | |
322 | + if (!content.zpname_type) content.zpname_type = ''; | |
321 | 323 | |
322 | - arr[i].content.gift_name=res.data.data.pageData[0].goods_name; | |
323 | - if(!content.zpname_type) content.zpname_type=''; | |
324 | - | |
325 | - if(parseInt(content.zpname_type)>0){ | |
326 | - arr[i].content.gift_name=res.data.data.pageData[0].title; | |
324 | + if (parseInt(content.zpname_type) > 0) { | |
325 | + arr[i].content.gift_name = res.data.data.pageData[0].title; | |
327 | 326 | } |
327 | + } | |
328 | 328 | }) |
329 | 329 | } |
330 | 330 | ... | ... |
pages/user/index/iconfont.ttf
0 → 100644
No preview for this file type
pages/user/index/index.js
... | ... | @@ -55,14 +55,18 @@ Page({ |
55 | 55 | showvipcode:false, |
56 | 56 | pshow:0, |
57 | 57 | |
58 | - | |
59 | 58 | is_show_yq:0, //是不是要显示邀请 |
59 | + show_erm_u:1,//弹出框显示会员二维码 | |
60 | 60 | }, |
61 | 61 | goto_nav: function (e) { |
62 | 62 | var th = this; |
63 | 63 | var url = e.currentTarget.dataset.url; |
64 | - if (th.data.userInfo != null) { | |
65 | - console.log('跳转'); | |
64 | + | |
65 | + //附件的门店不用判断会员 | |
66 | + var is_fj_store= url.indexOf('store/index')>-1; | |
67 | + | |
68 | + if (th.data.userInfo != null || is_fj_store) { | |
69 | + console.log('跳转'); | |
66 | 70 | getApp().goto(url); |
67 | 71 | } else { |
68 | 72 | wx.navigateTo({ |
... | ... | @@ -542,22 +546,25 @@ Page({ |
542 | 546 | }) |
543 | 547 | //th.requestRecommend(); |
544 | 548 | |
545 | - //自定义组件一定要等到页面加载完了,才来调用selectComponnent | |
546 | - setTimeout(function () { | |
547 | 549 | |
548 | - th.setData({ is_show_recommend:true }) | |
549 | - if (getApp().globalData.user_id) getApp().requestCardNum(th); | |
550 | - var goods_list = th.selectComponent("#goods_recommend"); //组件的id | |
551 | 550 | |
552 | - if(goods_list){ | |
553 | - goods_list.init(); | |
554 | - goods_list.get_list(); | |
555 | - } | |
551 | + } | |
552 | + } | |
556 | 553 | |
557 | - }, 1200) | |
554 | + //自定义组件一定要等到页面加载完了,才来调用selectComponnent | |
555 | + setTimeout(function () { | |
558 | 556 | |
557 | + th.setData({ is_show_recommend:true }) | |
558 | + if (getApp().globalData.user_id) getApp().requestCardNum(th); | |
559 | + var goods_list = th.selectComponent("#goods_recommend"); //组件的id | |
560 | + | |
561 | + if(goods_list){ | |
562 | + goods_list.init(); | |
563 | + goods_list.get_list(); | |
559 | 564 | } |
560 | - } | |
565 | + | |
566 | + }, 1200) | |
567 | + | |
561 | 568 | |
562 | 569 | setTimeout(()=>{ |
563 | 570 | th.setData({ pshow:1 }) |
... | ... | @@ -626,14 +633,14 @@ Page({ |
626 | 633 | */ |
627 | 634 | onReachBottom: function () { |
628 | 635 | //!this.nomore && this.requestRecommend(); |
629 | - var e = getApp().globalData.userInfo; | |
630 | - if (e != undefined && e != null && e.mobile) { | |
636 | + //var e = getApp().globalData.userInfo; | |
637 | + //if (e != undefined && e != null && e.mobile) { | |
631 | 638 | var goods_list = this.selectComponent("#goods_recommend"); //组件的id |
632 | 639 | goods_list.init(); |
633 | 640 | setTimeout(function () { |
634 | 641 | goods_list.get_list(); |
635 | 642 | }, 300) |
636 | - } | |
643 | + //} | |
637 | 644 | }, |
638 | 645 | |
639 | 646 | /** |
... | ... | @@ -1237,6 +1244,38 @@ Page({ |
1237 | 1244 | }) |
1238 | 1245 | }, |
1239 | 1246 | |
1247 | + hide_u_ewm(){ | |
1248 | + this.setData({show_erm_u:0}) | |
1249 | + }, | |
1250 | + show_u_ewm(){ | |
1251 | + var th=this; | |
1252 | + | |
1253 | + var getnowtime; | |
1254 | + rq.get("/api/weshop/users/getServerTime", { | |
1255 | + success: function (res) { | |
1256 | + if (res.data.code == 0) | |
1257 | + { | |
1258 | + th.setData({show_erm_u:1}) | |
1259 | + getnowtime=res.data.data; | |
1260 | + if (!getnowtime) | |
1261 | + { | |
1262 | + getApp().showWarning("获取服务时间失败"); | |
1263 | + return; | |
1264 | + } | |
1265 | + //base64_encode($user.mobile.'|'.date('Y-m-d H:i:s') | |
1266 | + var val = th.data.userInfo.mobile + "|" +getnowtime+"|"+th.data.getusercode_vailtime; | |
1267 | + val = "^" + ut.base64_encode(val); | |
1268 | + | |
1269 | + qrcode('qrcode', val, 350, 350, th); | |
1270 | + | |
1271 | + | |
1272 | + } | |
1273 | + } | |
1274 | + }) | |
1275 | + | |
1276 | + | |
1277 | + } | |
1278 | + | |
1240 | 1279 | |
1241 | 1280 | |
1242 | 1281 | ... | ... |
pages/user/index/index.wxml
... | ... | @@ -435,7 +435,7 @@ |
435 | 435 | <!--弹出层内容,其中的“我知道”中绑定让弹出层消失的函数:bindtap="hide"--> |
436 | 436 | <view class="tc_view" hidden='{{tc_hide}}' bindtap='hide_tc'> |
437 | 437 | <view class="modal-box" hidden="{{flag}}" bindtap="hide" catchtouchmove="true"></view> |
438 | - <view class="modal-body" catchtouchmove="true"> | |
438 | + <view class="modal-body {{show_erm_u?'':'low'}} " catchtouchmove="true"> | |
439 | 439 | <view class="modal-content"> |
440 | 440 | <view class="flex"> |
441 | 441 | <image src="{{userInfo.head_pic}}" class="hd_img"></image> |
... | ... | @@ -448,11 +448,24 @@ |
448 | 448 | </view> |
449 | 449 | </view> |
450 | 450 | |
451 | - <view class="canvas_box"> | |
452 | - <!--<image class='g_img' src='https://mshop.yolipai.net//index.php?m=Home&c=Index&a=qr_code&data={{userInfo.mobile}}'></image>--> | |
453 | - <canvas class="g_img" canvas-id="qrcode" /> | |
451 | + | |
452 | + <block wx:if="{{show_erm_u}}"> | |
453 | + <view class="canvas_box"> | |
454 | + <!--<image class='g_img' src='https://mshop.yolipai.net//index.php?m=Home&c=Index&a=qr_code&data={{userInfo.mobile}}'></image>--> | |
455 | + <canvas class="g_img" canvas-id="qrcode" /> | |
456 | + </view> | |
457 | + </block> | |
458 | + | |
459 | + <view style=" position: relative;top: -25rpx;"> | |
460 | + <view wx:if="{{show_erm_u}}" catchtap="hide_u_ewm" class="fs24 flex ai-center jc-center" style="width: 100%;color: #898989;line-height: normal; "> | |
461 | + 点击隐藏<text class="icon_yan icon-yanjing_yincang_o fs36"></text> | |
462 | + </view> | |
463 | + <view wx:else catchtap="show_u_ewm" class="fs24 flex ai-center jc-center" style="width: 100%;color: #898989; line-height: normal; "> | |
464 | + 点击显示<text class="icon_yan icon-yanjing_xianshi_o fs36"></text> | |
465 | + </view> | |
454 | 466 | </view> |
455 | - <view style="width: 100%;display: flex;justify-content: center;"> | |
467 | + | |
468 | + <view style="width: 100%;display: flex;justify-content: center; margin-top: 8rpx;" > | |
456 | 469 | <canvas class="barcode" style="width: 100%;height: 140rpx;" canvas-id="barcode" /> |
457 | 470 | </view> |
458 | 471 | <view wx:if="{{showvipcode}}" class="fs24" style="width: 100%;color: #898989;display: flex;text-align: center;align-content: center;justify-content: center;"> | ... | ... |
pages/user/index/index.wxss
... | ... | @@ -553,11 +553,15 @@ |
553 | 553 | background: #fff; |
554 | 554 | /* margin-left: 73rpx; */ |
555 | 555 | width: 600rpx; |
556 | - height: 860rpx; | |
556 | + height:860rpx; | |
557 | 557 | border-radius: 8px; |
558 | 558 | text-align: center; |
559 | 559 | } |
560 | 560 | |
561 | +.modal-body.low{ | |
562 | + height:600rpx; | |
563 | +} | |
564 | + | |
561 | 565 | .modal-content { |
562 | 566 | width: 480rpx; |
563 | 567 | margin: 0 auto; |
... | ... | @@ -784,4 +788,31 @@ button::after { |
784 | 788 | align-items: center; |
785 | 789 | justify-content: center; |
786 | 790 | /* margin-top: 20rpx; */ |
787 | -} | |
788 | 791 | \ No newline at end of file |
792 | + | |
793 | + position: relative;top: -10rpx; | |
794 | +} | |
795 | + | |
796 | + | |
797 | +@font-face { | |
798 | + font-family: "iconfont_yan"; /* Project id 4449681 */ | |
799 | + src: url('data:font/woff2;charset=utf-8;base64,d09GMgABAAAAAANUAA0AAAAAB4wAAAL+AAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP0ZGVE0cGh4GYACCQhEICoJYgj4LDAABNgIkAxIEIAWFAgdQG38GyB6D424J0UpZYooBbRj+ksfDf2P97pt5s18lmcPpoknEknhJRJJ5pURKIorVLWF/8k/fFWKMLamk8Er8bJV3au6kCdLWTXPif+CcvCJMnkvmj2+Pokq7RgIdD3bMoCih64UOehC/MH1w3m4lM1lHIeC3CUcLwH9TUgD/bIRhzAJFqFJIFGSKFxrlWTkCnoP3R5ck+ilaxf8Lz7n74WWw/X30fWxI9AjqTwQCAEsQKirmILCfocAcI0tASkH3WE/3SD+9CxAQHQIQBQUAEMBLRU8BDQxiAE+AD4AEQGpDQwMj4w6OJvmk9yrt+rrvNvPmJqv3JuP2duA6/eoqo+9Sd9F7Rpz7957s6vZO+453iO2j0sBry1DODK6/bEGwYWlbwmG/ecakRRqB5EzuBJv6Helicpa7BMFXsZi/MnMbSSSVsstk+rTWrapglURr5h8V13LVe9MVDdOw6QQHe5ap9hFwBoc24h7lPhIFJ8Kprw4RzjHxR6kjcb74uSognogKm96bbHx6O0waqOCSev149g6kTa8g318RrJLE/eyNP9e5UO2pVq2z/mzCprlPUQ0fd1PCw6iGPxffn/XzAAJBefP7qdDW779/KHWS7dIRdaWsoF8BQcOOvZUAPqXcb4ZMQCK5LB1Cc4gxKBg0iB6ASS+AAFNYEAj9zkCg6PMAAlW/pwKkfl8EaIZ8E6Cj3w9AYNDO2A8IDJmKF6rIAWwAHQ3j/NBi1FW0GoeBRHrRZtYc2jFuHx10xde4IRvxEELVKlesXiOXISnRQlUohWlVtNWDA3t24GQH9hoQQnKeCxeUq9RArVgt+Jet2uDVQ9QrytWqo8glERMQgRVd/2KBKCpwdLBWudo6nlKnUSWJevUqkFSohWmQRCTxiXJqahhJtVqYUrlS9QTgMiCxrrFSUl9fsQZ0RWDtJG3iP4LdAA/Tp/nhZISEKlJ2C5TmacAC3aiIzI5x0hBaj0H8soZQokSdaCnWKhXaysJmRbG2rkpRiG1yi+ooLaZUDAAA') format('woff2'), | |
800 | + url('data:font/woff;charset=utf-8;base64,d09GRgABAAAAAAU8AA0AAAAAB4wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABGRlRNAAAFIAAAABoAAAAcohRq60dERUYAAAUAAAAAHgAAAB4AKQALT1MvMgAAAaAAAABGAAAAYEIBTpxjbWFwAAAB/AAAAEIAAAFCAA/veGdhc3AAAAT4AAAACAAAAAj//wADZ2x5ZgAAAkwAAAEsAAABWH3W0xtoZWFkAAABMAAAADAAAAA2JyyEpGhoZWEAAAFgAAAAHQAAACQHiQOFaG10eAAAAegAAAARAAAAEgxVAFVsb2NhAAACQAAAAAwAAAAMAEgArG1heHAAAAGAAAAAHgAAACABFABLbmFtZQAAA3gAAAFGAAACgl6CAQJwb3N0AAAEwAAAADYAAABQUf1A0HjaY2BkYGAAYqEpty7E89t8ZeBmYQCBR+wKdnA6lKGBeTXTaiCXg4EJJAoAB0UIyXjaY2BkYGBu+N/AEMPCAALMqxkYGVABCwBTpwMXAAAAeNpjYGRgYGBlsAdiEGACYi4gZGD4D+YzAAAPawFgAAB42mNgYWFgnMDAysDA1Ml0hoGBoR9CM75mMGLkAIoysDIzYAUBaa4pDAden3l9lrnhfwMDA/MdBiDJwIikRIGBEQCTww4iAAB42mNhgAAWCA5lCAUAAe4AtwAAAHjaY2BgYGaAYBkGRgYQsAHyGMF8FgYFIM0ChED+67P//wPJM///i5hDVTIwsjHAmAyMTECCiQEVMDIMewAAJFcIcgAAAAAAAAAAAAAASACseNotjzFLw0AUx9/LpYlIrVTTZJFD72yCBDrcpQ1UTUuhtQbqIHR1cUpNwbnTiZP9IF3yEbr6Ady6+xmci3fQB++/vN+D3x9smIMilaXgGFpAIQZA5rgURS/tIGFhlOGlHzQwEr0kZI7nB6yDSYaCotdAC1bb0Wj7Z2K13uX5Dj2Tay7ERAh+3WesPzVhzYuyLMzuY3WYyjATER8QHVDTPp9kY1VwCleQQB8ygHbqS+0TRqkx4U5krKQI3DAKubb1gwEaopt0DdPSYtwgqee2A4xwxh5y7Tl9ocXT4279/DMeasU7yc7O6xf6IIff9MjnAgltslvefCMTqWvTPbAN94vlu6CDD6Wc12Sh1AkjiItyJpvUFrxecx0a3Oie9pcc2+T+V39R+AdnzksMeNp9kM1Kw0AUhc/0T21BxILrWRVBSH+WpbtC3blwUddtOklbkkyYTAtdunXlA7j1MXwAn0Fw5YN4Gq8IFZqQyzfn3nNmJgAu8QmFn6eNa2GFU9wJV3CCWLhK/VG4Rn4RrqOFN+EG9Q/hJm7USLiFtnpmgqqdcdUp0/ascIGRcAXneBCuUrfCNfKTcB1XeBVuUH8XbmKKL+EWOmqJMRwMZvCsC2jMsWNdIWRuhqisHhg7M/Nmoec7vQptFtmM4r+pv9Y942JskDDacWniTTJzRy1HWlOmORQc2bc0+gjQo2xcsbKZ7ge9o/Zb2rMy4vCeBbY85oCqp1Hzc7SnpInEGF4hIWvkZW9NJaQeMNZkxv3+lWIbD7yPdORsqifc1iSJ1bmzaxN6Di/LPXIM0eUbHaQH5eFTjnmfD7vdSAKC0Kb4Bg9qcIcAAHjaY2BigAAuMMnIgA5YwaJMjEyMzIKViXlZmXnp8RWZiXnFGZnx+XCRysy85EQgnQ8ACQsOVgAAAAAAAf//AAIAAQAAAAwAAAAWAAAAAgABAAMABAABAAQAAAACAAAAAHjaY2BgYGQAgntsWnkg+hG7gh2MBgAurwQMAAA=') format('woff'), | |
801 | + url('iconfont.ttf?999') format('truetype'); | |
802 | +} | |
803 | +.icon_yan{ | |
804 | + font-family: "iconfont_yan" !important; | |
805 | + font-style: normal; | |
806 | + -webkit-font-smoothing: antialiased; | |
807 | + -moz-osx-font-smoothing: grayscale; | |
808 | +} | |
809 | +.icon-yanjing_xianshi_o:before { | |
810 | + content: "\ebcc"; | |
811 | +} | |
812 | +.icon-yanjing_yincang_o:before { | |
813 | + content: "\ebcd"; | |
814 | +} | |
815 | + | |
816 | +.fs36{ font-size: 36rpx} | |
817 | + | |
818 | + | |
819 | + | ... | ... |
pages/user/order_list/order_list.js
... | ... | @@ -1446,14 +1446,43 @@ Page({ |
1446 | 1446 | //-- 优惠促销的时候控制取价规则 -- |
1447 | 1447 | // gg.prom_type!=3 && gg.prom_type!=10 同时商品不是普通购买的时候,又参与优惠促销,阶梯促销 |
1448 | 1448 | if((gg.prom_type!=3 && gg.prom_type!=10) || gg.discount_field==undefined || gg.discount_field==0 ){ |
1449 | - if (card_field && gg[card_field] > 0) { | |
1450 | - if (good.goods_price != gg[card_field] && good.offline_cut <= 0) isok = 0; | |
1451 | - if (good.goods_price > gg[card_field] && good.offline_cut > 0) isok = 0; //如果线下价格比较贵,则不通过 | |
1452 | 1449 | |
1453 | - } else { | |
1454 | - if (good.goods_price != gg.shop_price && good.offline_cut <= 0) isok = 0; | |
1455 | - if (good.goods_price > gg.shop_price && good.offline_cut > 0) isok = 0; //如果线下价格比较贵,则不通过 | |
1450 | + //判断一下活动是不是有参与订单促销,并且订单促销的活动是不是实收取价,2024-2-23 | |
1451 | + let ordprom_price_type=0; | |
1452 | + if(order.order_prom_id && good.prom_type==0){ | |
1453 | + let p_rs= await getApp().request.promiseGet("/api/weshop/promorder/get/"+os.stoid+"/"+order.order_prom_id, {}); | |
1454 | + if(p_rs && p_rs.data.code==0 && p_rs.data.data){ | |
1455 | + let ord_p=p_rs.data.data; | |
1456 | + if(ord_p && ord_p.discount_field>0){ | |
1457 | + ordprom_price_type=ord_p.discount_field | |
1458 | + } | |
1459 | + } | |
1460 | + } | |
1461 | + if(ordprom_price_type>0){ | |
1462 | + //-- 看一下订单促销的取价规则 -- | |
1463 | + switch (ordprom_price_type){ | |
1464 | + case 1: | |
1465 | + if (good.goods_price != gg.shop_price) isok = 0; | |
1466 | + break; | |
1467 | + case 2: | |
1468 | + if (good.goods_price != gg.market_price) isok = 0; | |
1469 | + break; | |
1470 | + } | |
1471 | + | |
1472 | + }else{ | |
1473 | + if (card_field && gg[card_field] > 0) { | |
1474 | + if (good.goods_price != gg[card_field] && good.offline_cut <= 0) isok = 0; | |
1475 | + if (good.goods_price > gg[card_field] && good.offline_cut > 0) isok = 0; //如果线下价格比较贵,则不通过 | |
1476 | + | |
1477 | + } else { | |
1478 | + if (good.goods_price != gg.shop_price && good.offline_cut <= 0) isok = 0; | |
1479 | + if (good.goods_price > gg.shop_price && good.offline_cut > 0) isok = 0; //如果线下价格比较贵,则不通过 | |
1480 | + } | |
1456 | 1481 | } |
1482 | + | |
1483 | + | |
1484 | + | |
1485 | + | |
1457 | 1486 | }else{ |
1458 | 1487 | |
1459 | 1488 | if(good.prom_type==3 || good.prom_type==10 ){ | ... | ... |