Commit 1b940ef9282ff8d14c511c4f06e6cd9219d86d5e

Authored by yvan.ni
1 parent aed8e658

购物车和确认订单页面的优化

... ... @@ -51,7 +51,7 @@ App({
51 51 config: null, //门店参数
52 52 config2: null, //门店配置
53 53 code: null,
54   - user_id:null,//6520491,// 6519913,//6520352
  54 + user_id:null, //6520509,//6520491,// 6519913,//6520352
55 55 // user_id:6520314,// qa-6519858,//
56 56 // user_id:14148118,// qa-6519858,//
57 57 buy_now: null,
... ... @@ -1584,6 +1584,15 @@ App({
1584 1584 return cx_arr;
1585 1585 },
1586 1586  
  1587 + get_has_cx_act2(act_arr){
  1588 + var cx_arr=[];
  1589 + if(act_arr && act_arr.length)
  1590 + cx_arr=act_arr.filter(function (e) {
  1591 + return e.s_time < ut.gettimestamp() && [3,5,7,10].indexOf(e.prom_type)>-1;
  1592 + })
  1593 + return cx_arr;
  1594 + },
  1595 +
1587 1596 //-- 获取判断注册成功后,是跳转等级卡,还是新人有礼 --
1588 1597 async go_to_page(is_reg,func){
1589 1598 if(!is_reg) {
... ...
packageE/pages/cart/cart2/cart2.js
... ... @@ -170,7 +170,12 @@ Page({
170 170 showFold:true,
171 171  
172 172 ly_map:{},
173   - template_id:[]
  173 + template_id:[],
  174 +
  175 + //用于后台计算的多促销集合
  176 + show_can_cx_map:{},
  177 + //优惠促销活动的集合
  178 + yhcx_act_map: {},
174 179 },
175 180  
176 181  
... ... @@ -909,7 +914,7 @@ Page({
909 914 var th = this, app = getApp();
910 915 var state = 0;
911 916 if (th.data.state) state = 1;
912   - a.get("/api/weshop/cart/list", {
  917 + a.get("/api/weshop/cart/listNew1", {
913 918 data: {
914 919 user_id: to.globalData.user_id, selected: 1, state: state,
915 920 store_id: oo.stoid, pageSize: 600,
... ... @@ -926,18 +931,18 @@ Page({
926 931 if (pick_id_arr.length == 0 || pick_id_arr.indexOf(carr[i].pick_id) == -1)
927 932 pick_id_arr.push(carr[i].pick_id);
928 933 }
929   - var req_d = {
930   - store_id: os.stoid, ids: pick_id_arr.join(',')
931   - }
932   - //-- 获取门店的列表 --
933   - await getApp().request.promiseGet("/api/weshop/pickup/list", { data: req_d }).then(res => {
934   - if (ut.ajax_ok(res)) {
935   - th.data.allsto = res.data.data.pageData;
936   - }
937   - })
  934 + //-- 门店不在获取2024-2-3 --
  935 + // var req_d = {
  936 + // store_id: os.stoid, ids: pick_id_arr.join(',')
  937 + // }
  938 + // //-- 获取门店的列表 --
  939 + // await getApp().request.promiseGet("/api/weshop/pickup/list", { data: req_d }).then(res => {
  940 + // if (ut.ajax_ok(res)) {
  941 + // th.data.allsto = res.data.data.pageData;
  942 + // }
  943 + // })
938 944  
939 945 th.data.cartlist_y =JSON.parse(JSON.stringify(carr)); //存储原始购物车列表
940   -
941 946 wx.showLoading();
942 947  
943 948 th.get_cart_next(carr);
... ... @@ -950,7 +955,7 @@ Page({
950 955 is_last(gid,goods,map){
951 956 let last_id=0;
952 957 for (let i = 0; i <goods.length ; i++) {
953   - if(map.indexOf(goods[i].goods_id)>-1){
  958 + if(map && map.indexOf(goods[i].goods_id)>-1){
954 959 last_id=goods[i].goods_id;
955 960 }
956 961 }
... ... @@ -958,6 +963,7 @@ Page({
958 963 return false;
959 964 },
960 965  
  966 +
961 967 //-- is_change是有没有切换活动的意思 --
962 968 async get_cart_next(carr,is_change,old_prom){
963 969  
... ... @@ -973,7 +979,7 @@ Page({
973 979  
974 980 var c_ok=1;
975 981 if(old_prom && (carr[ir].prom_type!=old_prom.prom_type || carr[ir].prom_id!=old_prom.prom_id) ){
976   - c_ok=0;
  982 + c_ok=0;
977 983 }
978 984  
979 985 if(carr[ir].is_gift && carr[ir].id && c_ok) {
... ... @@ -995,22 +1001,22 @@ Page({
995 1001 var map=this.data.prom_goods_map;
996 1002 if(map){
997 1003 for (var ky in map) {
998   - if(map[ky]){
999   - var ob=map[ky];
1000   - for (var ii in ob) {
1001   - var item_map = ob[ii];
1002   - if (item_map.hasOwnProperty('cy_cx')) {
1003   - delete item_map.cy_cx;
1004   - }
1005   - }
  1004 + if(map[ky]){
  1005 + var ob=map[ky];
  1006 + for (var ii in ob) {
  1007 + var item_map = ob[ii];
  1008 + if (item_map.hasOwnProperty('cy_cx')) {
  1009 + delete item_map.cy_cx;
  1010 + }
1006 1011 }
  1012 + }
1007 1013 }
1008 1014 }
1009 1015 }
1010 1016  
1011 1017 //按门店分类的数组
1012 1018 var arr = new Array();
1013   -
  1019 +
1014 1020 var th=this;
1015 1021 th.data.in_zhact_gdmap = {};
1016 1022 //---是不是购买等级卡成功的返回---等级卡显示的判断---
... ... @@ -1018,40 +1024,40 @@ Page({
1018 1024  
1019 1025 //-- 判断组合购是总数量是不是存在 --
1020 1026 var no_zh_num={};
1021   -
  1027 + //-- 多促销活动调用接口需要的参数,和商品的购买数量和活动的购买数量的请求参数 --
  1028 + var dug_cx_arr = [];
  1029 + //获取 限购 和 多活动的促销---2024-2-1
1022 1030 for (var i = 0; i < carr.length; i++) {
1023 1031  
1024   - var item1 = carr[i];
1025   - //-- 获取一下商品的所有活动 --
1026   - await th.buy_pro_group(item1);
1027   - //把已经购买了多少见的内容填入
1028   - var goodsbuynum = 0, promgoodsbuynum = 0;
1029   - //--要获得商品,该用户买了多少件,同步应用--
1030   - await getApp().request.promiseGet("/api/weshop/ordergoods/getUserBuyGoodsNum", {
1031   - data: {
1032   - store_id: os.stoid,
1033   - user_id: getApp().globalData.user_id,
1034   - goods_id: item1.goods_id,
1035   - prom_type: item1.prom_type,
1036   - prom_id: item1.prom_id,
1037   - isnew:1
1038   - },
1039   - }).then(res => {
1040   - var buy_num_data = res.data.data;
1041   - if (buy_num_data.promgoodsbuynum) {
1042   - promgoodsbuynum = buy_num_data.promgoodsbuynum;
  1032 + let item1 = carr[i];
  1033 + //如果不是活动的时候,不是代发商品的时候,不是赠品的时候,不是阶梯商品拆分的,不是组合购拆分的
  1034 + if([1, 2, 4, 6, 8, 9].indexOf(item1.prom_type)== -1 && !item1.whsle_id
  1035 + && !item1.is_gift && !item1.is_ld_split && !item1.is_zh_split ){
  1036 + //-- 快速查找,组装查询多活动的列表 --
  1037 + let f_idx=dug_cx_arr.findIndex(function (ele) {
  1038 + return ele.goods_id == item1.goods_id
  1039 + });
  1040 + if(f_idx==-1) {
  1041 + let gd_ite={
  1042 + goods_id:carr[i].goods_id,
  1043 + goods_num:1,
  1044 + is_limit_show:1,
  1045 + is_state:0
  1046 + }
  1047 + dug_cx_arr.push(gd_ite);
1043 1048 }
1044   - goodsbuynum = buy_num_data.goodsbuynum;
1045   - })
1046   - //如果有购买活动
1047   - item1.promgoodsbuynum = promgoodsbuynum;
  1049 +
  1050 + }
1048 1051  
1049 1052 if(is_change){
1050 1053 carr[i].collocationList=null;
1051 1054 }
1052   -
1053 1055 }
1054 1056  
  1057 + //-- 对商品的多促销进行判断 ---2024-2-1--
  1058 + if(dug_cx_arr.length){
  1059 + await th.buy_pro_group(dug_cx_arr,carr);
  1060 + }
1055 1061 //在分组的时候,就不要再调用接口,await
1056 1062 for (var i = 0; i < carr.length; i++) {
1057 1063 var item = carr[i];
... ... @@ -1079,10 +1085,9 @@ Page({
1079 1085  
1080 1086 }
1081 1087  
1082   -
1083 1088 //商品的图片不能重复的赋值
1084 1089 if(item.original_img.indexOf(oo.imghost)==-1)
1085   - item.original_img = oo.imghost + item.original_img;
  1090 + item.original_img = oo.imghost + item.original_img;
1086 1091  
1087 1092 var car_item = item;
1088 1093 /*----接口要弄出来的,先顶着-----*/
... ... @@ -1095,10 +1100,10 @@ Page({
1095 1100  
1096 1101 if (arr[j].pickup_id == pcid) {
1097 1102 if (item.is_gift != 1) {
1098   - //确定配送方式
1099   - if (arr[j].distr_t == 0) {
1100   - arr[j].distr_t = car_item.distr_type;
1101   - }
  1103 + //确定配送方式
  1104 + if (arr[j].distr_t == 0) {
  1105 + arr[j].distr_t = car_item.distr_type;
  1106 + }
1102 1107 }else{
1103 1108 item.distr_type=0; //赠品不控制物流的方式
1104 1109 }
... ... @@ -1112,10 +1117,10 @@ Page({
1112 1117 switch (dis_t) {
1113 1118 case 0:
1114 1119 if(!arr[j].exp_sure){
1115   - e_t = 1;
1116   - //-- 系统后台有设置要默认的 --
1117   - if (th.data.json_d.pickupway && th.data.json_d.pickupway == 1) e_t = 0;
1118   - arr[j].exp_type=e_t
  1120 + e_t = 1;
  1121 + //-- 系统后台有设置要默认的 --
  1122 + if (th.data.json_d.pickupway && th.data.json_d.pickupway == 1) e_t = 0;
  1123 + arr[j].exp_type=e_t
1119 1124 }
1120 1125 break;
1121 1126 case 1:
... ... @@ -1147,8 +1152,8 @@ Page({
1147 1152  
1148 1153 }
1149 1154 if(car_item.is_gift != 1){
1150   - arr[j].exp_type = e_t;
1151   - if (e_t == 0) th.setData({ is_all_zt: 0 });
  1155 + arr[j].exp_type = e_t;
  1156 + if (e_t == 0) th.setData({ is_all_zt: 0 });
1152 1157 }
1153 1158  
1154 1159 //else if (e_t == 1) th.setData({ is_all_zt: 1 });
... ... @@ -1176,13 +1181,12 @@ Page({
1176 1181 if (find == 0) {
1177 1182 var pikname = '', sto = null;
1178 1183 //----找到门店名称-----
1179   - for (var k = 0; k < th.data.allsto.length; k++) {
1180   - if (pcid == th.data.allsto[k].pickup_id) {
1181   - pikname = th.data.allsto[k].pickup_name;
1182   - sto = th.data.allsto[k];
1183   - break;
1184   - }
1185   - }
  1184 + pikname = item.pickup_name;
  1185 + sto ={
  1186 + pickup_id:item.pick_id,
  1187 + pickup_name:pikname,
  1188 + distr_type:item.pickup_distr_type
  1189 + };
1186 1190 var e_t = 0, dis_t = 0;//物流方式,配送方式
1187 1191 if (item.distr_type == 0) {
1188 1192 dis_t = sto.distr_type;
... ... @@ -1191,7 +1195,6 @@ Page({
1191 1195 }
1192 1196  
1193 1197 let exp_sure=0;
1194   -
1195 1198 switch (dis_t) {
1196 1199 case 0:
1197 1200 e_t = 1;
... ... @@ -1224,12 +1227,10 @@ Page({
1224 1227 }
1225 1228 }
1226 1229 }
1227   -
1228   -
1229 1230 if (back_data && parseFloat(back_data)) {
1230   - c_item.can_usecommise = parseFloat(parseFloat(back_data).toFixed(2));
1231   - cart_commission += c_item.can_usecommise;
1232   - }
  1231 + c_item.can_usecommise = parseFloat(parseFloat(back_data).toFixed(2));
  1232 + cart_commission += c_item.can_usecommise;
  1233 + }
1233 1234  
1234 1235 var ie = {
1235 1236 pickup_id: pcid,
... ... @@ -1285,6 +1286,8 @@ Page({
1285 1286  
1286 1287 }
1287 1288  
  1289 +
  1290 +
1288 1291 var cart_commission = 0;
1289 1292 //-- 循环计算一下线下取价 --
1290 1293 for (var k = 0; k < arr.length; k++) {
... ... @@ -1292,8 +1295,31 @@ Page({
1292 1295 if (!is_change) {
1293 1296 //-- 要进行归类一下活动 --
1294 1297 await m_cx.cart_cx_group(th, arr[k].goods, c_item, 0, 0, (show_can_cx) => {
1295   -
1296   - arr[k].show_can_cx = show_can_cx;
  1298 + //后台计算使用
  1299 + th.data.show_can_cx_map[c_item.pickup_id]=show_can_cx;
  1300 + //-- 把活动组装进去 ---
  1301 + let show_can_cx1 = ut.deep_cp(show_can_cx);
  1302 + //前端处理渲染的时,要处理一些不需要的字段属性
  1303 + if(show_can_cx1){
  1304 + for (const key in show_can_cx1) {
  1305 + let element = show_can_cx1[key];
  1306 + if(element.cur_act){
  1307 + let c_act=element.cur_act;
  1308 + delete c_act.goods;
  1309 + }
  1310 + if(element.ch_map){
  1311 + delete element.ch_map;
  1312 + }
  1313 + if(element.act_arr && element.act_arr.length>0){
  1314 + for (var ij = 0; ij < element.act_arr.length; ij++) {
  1315 + var act_ite = element.act_arr[ij];
  1316 + delete act_ite.goods;
  1317 + delete act_ite.key;
  1318 + }
  1319 + }
  1320 + }
  1321 + }
  1322 + arr[k].show_can_cx = show_can_cx1;
1297 1323 },2)
1298 1324 } else {
1299 1325 var show_can_cx = this.data.cartlist[k].show_can_cx;
... ... @@ -1314,13 +1340,13 @@ Page({
1314 1340 //-- 如果初始活动在计算的时候,是不满足的时候,就要把活动清理掉 --
1315 1341 var is_no_ok=arr[k].show_can_cx[key_o].cur_act.is_no_ok;
1316 1342 if(is_no_ok==1){
1317   - item1.prom_id = 0;
1318   - item1.prom_type = 0;
  1343 + item1.prom_id = 0;
  1344 + item1.prom_type = 0;
1319 1345  
1320   - //这里要判断一下活动的最后一个商品,is_act_last
1321   - if(th.is_last(item1.goods_id,arr[k].goods,arr[k].show_can_cx[key_o].ch_map)){
1322   - item1.is_act_last=1; //这个是要在前端显示按钮切换的
1323   - }
  1346 + //这里要判断一下活动的最后一个商品,is_act_last
  1347 + if(th.is_last(item1.goods_id,arr[k].goods,arr[k].show_can_cx[key_o].ch_map)){
  1348 + item1.is_act_last=1; //这个是要在前端显示按钮切换的
  1349 + }
1324 1350  
1325 1351 }
1326 1352 }
... ... @@ -1331,7 +1357,7 @@ Page({
1331 1357 if (item1.prom_type == 3 && item1.is_gift != 1 && !item1.whsle_id) {
1332 1358 // th.check_is_youhui(item1.goods_id, item1.pick_id);
1333 1359 //增加优惠活动次数限制
1334   - let limit_num = await th.getprom(item1) //活动限制次数
  1360 + let limit_num = th.getprom(item1) //活动限制次数
1335 1361  
1336 1362 if (!limit_num) {
1337 1363 await th.add_prom_goods_map(item1);
... ... @@ -1431,7 +1457,7 @@ Page({
1431 1457  
1432 1458 } else {
1433 1459  
1434   -
  1460 +
1435 1461 item1.act = th.data.zhhe_act_map[item1.prom_id];
1436 1462 }
1437 1463 }
... ... @@ -1511,29 +1537,48 @@ Page({
1511 1537 //如果是秒杀,团购的时候,优惠促销和搭配购的时候
1512 1538 if([1,2,3,5,6,7,10].indexOf(item1.prom_type)>-1){
1513 1539  
  1540 + //由于是购物车购买,所以prom_type 基本不会员等于6
1514 1541 if(item1.prom_type==1 || item1.prom_type==6) {
1515 1542 item1.is_quan=0;
1516 1543 }
1517   -
1518   - var url= "/api/weshop/activitylist/getSJGoodsPriceNew/" + os.stoid
1519   - + "/" + item1.goods_id + "/"+item1.prom_type+"/" + item1.prom_id + "/" + app.globalData.user_id;
1520   - await app.request.promiseGet(url,{}).then(res=>{
1521   - if(res.data.code==0){
1522   - console.log(res.data.data,"111");
1523   - //组合促销有另外一个字段名is_orderyh,在控制订单促销的叠加
1524   -
  1544 + let t_goodsActinfo=item1.goodsActinfo;
  1545 + if(t_goodsActinfo && t_goodsActinfo.length){
  1546 + let ff_prom=t_goodsActinfo.find(function (e){
  1547 + return e.prom_type==item1.prom_type;
  1548 + })
  1549 + if(ff_prom){
1525 1550 if(item1.prom_type!=7 && item1.prom_type!=10) {
1526   - item1.is_order_yh=res.data.data.is_order_yh;
  1551 + item1.is_order_yh=ff_prom.is_order_yh;
1527 1552 }else item1.is_order_yh=0;
1528 1553  
1529   - item1.is_post_temp=res.data.data.is_post_temp;
  1554 + item1.is_post_temp=ff_prom.is_post_temp;
1530 1555  
  1556 + //由于是购物车购买,所以prom_type 基本不会员等于6
1531 1557 if(item1.prom_type==1 || item1.prom_type==6) {
1532   - item1.is_quan=res.data.data.is_quan;
  1558 + item1.is_quan=item1.cartActinfo.is_quan;
1533 1559 }
1534   -
1535 1560 }
1536   - })
  1561 + }
  1562 +
  1563 + // var url= "/api/weshop/activitylist/getSJGoodsPriceNew/" + os.stoid
  1564 + // + "/" + item1.goods_id + "/"+item1.prom_type+"/" + item1.prom_id + "/" + app.globalData.user_id;
  1565 + // await app.request.promiseGet(url,{}).then(res=>{
  1566 + // if(res.data.code==0){
  1567 + // console.log(res.data.data,"111");
  1568 + // //组合促销有另外一个字段名is_orderyh,在控制订单促销的叠加
  1569 + //
  1570 + // if(item1.prom_type!=7 && item1.prom_type!=10) {
  1571 + // item1.is_order_yh=res.data.data.is_order_yh;
  1572 + // }else item1.is_order_yh=0;
  1573 + //
  1574 + // item1.is_post_temp=res.data.data.is_post_temp;
  1575 + //
  1576 + // if(item1.prom_type==1 || item1.prom_type==6) {
  1577 + // item1.is_quan=res.data.data.is_quan;
  1578 + // }
  1579 + //
  1580 + // }
  1581 + // })
1537 1582 }
1538 1583  
1539 1584 }
... ... @@ -1662,12 +1707,37 @@ Page({
1662 1707 }
1663 1708 }
1664 1709 }
1665   -
1666 1710 //深拷贝
1667 1711 th.data.old_cartlist = JSON.parse(JSON.stringify(arr));
1668   - th.setData({
1669   - cartlist: arr,
1670   - });
  1712 +
  1713 + th.data.cartlist=arr;
  1714 +
  1715 + //-- 大于20使用逐步渲染 --
  1716 + if(arr.length>10){
  1717 + for (let ib = 0; ib <arr.length ; ib++) {
  1718 + //-- 都用深拷贝 --
  1719 + var ite=ut.deep_cp(th.data.old_cartlist[ib]);
  1720 + delete ite.goods;
  1721 + var txt0="cartlist["+ib+"]";
  1722 + th.setData({
  1723 + [txt0]:ite
  1724 + })
  1725 + //都用深拷贝
  1726 + var tt_goods=ut.deep_cp(th.data.old_cartlist[ib].goods);
  1727 + for (let iz = 0; iz <tt_goods.length;iz++) {
  1728 + var txt="cartlist["+ib+"].goods["+iz+"]";
  1729 + setTimeout(()=>{
  1730 + th.setData({
  1731 + [txt]:tt_goods[iz]
  1732 + })
  1733 + },ib*200+iz*300+100)
  1734 + }
  1735 + }
  1736 + }else{
  1737 + th.setData({
  1738 + cartlist: arr,
  1739 + });
  1740 + }
1671 1741  
1672 1742 //--- 获取一下看有没有优惠券 ----
1673 1743 setTimeout(function () {
... ... @@ -1684,6 +1754,7 @@ Page({
1684 1754 }, 500)
1685 1755 },
1686 1756  
  1757 +
1687 1758 //-----单个商品购买的入口判断----
1688 1759 get_buy_goods: function (e) {
1689 1760 var th = this;
... ... @@ -2202,60 +2273,68 @@ Page({
2202 2273 }
2203 2274 },
2204 2275  
  2276 +
2205 2277 //-- 立即购买的时候,获取商品优惠活动,is_state判断是不是单个商品购买,
2206 2278 // 很多活动需要判断会员的plus等级, 权益登陆,user_id调用接口是必须的 --
2207 2279 //先用着,后面会用接口来代替
2208   - async buy_pro_group(item1, is_state) {
2209   - //-- 代发商品不参与任何活动 --
2210   - if (item1.whsle_id) return false;
2211   - if (item1.is_gift) return false;
2212   - if (item1.is_collocation) return false;
2213   - if (item1.is_ld_split) return false; //是阶梯
2214   - if (item1.is_zh_split) return false;
2215   -
2216   - //-- 购物车的秒杀和团购不计算 --
2217   - var p_type=parseInt(item1.prom_type);
2218   - if([1,2].indexOf(p_type)>-1) return false;
2219   -
  2280 + async buy_pro_group(g_arr,carr) {
2220 2281 var th=this;
2221   - var req_d = {
2222   - store_id: os.stoid,
2223   - user_id: getApp().globalData.user_id,
2224   - goods_id: item1.goods_id,
2225   - goods_num: item1.goods_num,
2226   - goods_price: item1.goods_price,
2227   - }
2228   - //--- 调用接口获取活动 ---
2229   - await getApp().promiseGet('/api/weshop/goods/getGoodsPromInfo', {data:req_d}).then(res => {
2230   - if(res.data.code==0){
2231   - var more_cx=res.data.data.more_cx;
2232   - for(var i=0;i<more_cx.length;i++){
2233   - if(more_cx[i].prom_type==5){
2234   - more_cx[i].main_gid= more_cx[i].collocation.main_goods_id;
2235   - var min=more_cx[i].collocation_main_price+more_cx[i].collocation_min_price;
2236   - var max=more_cx[i].collocation_main_price+more_cx[i].collocation_max_price;
2237   - more_cx[i].show_price="¥"+min+"-"+max;
2238   - }
2239   - }
2240   - item1.more_cx=more_cx;
2241   -
2242   - if(res.data.data.zh_pro){
2243   - th.data.zhhe_act_map[res.data.data.zh_pro.id]=res.data.data.zh_pro;
2244   - }
2245   - if(res.data.data.ladder_pro){
2246   - var ladder_pro=res.data.data.ladder_pro;
2247   - th.data.ladder_map[ladder_pro.id]=ladder_pro;
2248   - var fd=res.data.data.more_cx.find(function (e){
2249   - return e.prom_type==10;
2250   - })
2251   - if(fd){
2252   - th.data.ladder_map[ladder_pro.id].ladder_list=fd.ladder_list;
2253   - }
  2282 + //获取商品参与的促销活,优惠促,搭配促,组合促,阶梯促销
  2283 + let cx_rs= await getApp().request.promisePost("/api/weshop/cart/listGoodsPromInfo",{
  2284 + is_json:1,
  2285 + data:{
  2286 + user_id:app.globalData.user_id,
  2287 + store_id:oo.stoid,
  2288 + goods:g_arr,
  2289 + }
  2290 + });
  2291 + //-- 判断返回结果有没有正确,有促销活动就要进行赋值 --
  2292 + if(cx_rs && cx_rs.data.code==0 && cx_rs.data.data && cx_rs.data.data.goods) {
  2293 + let g_list=cx_rs.data.data.goods;
  2294 + for (var ia = 0; ia < carr.length; ia++) {
  2295 + if (carr[ia].whsle_id) continue; //代发商品不进行赋值
  2296 + if (carr[ia].is_gift) continue; //赠品不进行赋值
  2297 + //有参与秒,团购之类的活动不进行赋值
  2298 + if([1, 2, 4, 6, 8, 9].indexOf(carr[ia].prom_type)> -1 ) continue;
  2299 + //再g_list中快速查找
  2300 + let i_fd=g_list.find(function (ele) {
  2301 + return ele.goods_id == carr[ia].goods_id
  2302 + });
  2303 + if(i_fd.goodsPromInfoRespDto){
  2304 + //-- 多促销活动的优化 --
  2305 + i_fd=i_fd.goodsPromInfoRespDto;
  2306 + //-- 赋值多促销活动的优化--
  2307 + carr[ia].more_cx=i_fd.more_cx;
  2308 +
  2309 + //商品优惠促销的缓存
  2310 + if (i_fd.yhcx_pro) {
  2311 + th.data.yhcx_act_map[i_fd.yhcx_pro.id] = i_fd.yhcx_pro;
  2312 + }
  2313 + //商品组合促销的缓存
  2314 + if (i_fd.zh_pro) {
  2315 + th.data.zhhe_act_map[i_fd.zh_pro.id] = i_fd.zh_pro;
  2316 + }
  2317 + //商品阶梯促销的缓存
  2318 + if (i_fd.ladder_pro) {
  2319 + var ladder_pro = i_fd.ladder_pro;
  2320 + th.data.ladder_map[ladder_pro.id] = ladder_pro;
  2321 + var fd_ite = i_fd.more_cx.find(function (e) {
  2322 + return e.prom_type == 10;
  2323 + })
  2324 + if (fd_ite) {
  2325 + th.data.ladder_map[ladder_pro.id].ladder_list = fd_ite.ladder_list;
2254 2326 }
2255   - }
2256   - })
  2327 + }
  2328 +
  2329 + }
  2330 +
  2331 + }
  2332 + }
2257 2333 },
2258 2334  
  2335 +
  2336 +
  2337 +
2259 2338 //---------------检查是否有收货地址-------------------
2260 2339 checkAddressList: function () {
2261 2340 var t = this;
... ... @@ -2393,11 +2472,11 @@ Page({
2393 2472 newd.is_past=1;
2394 2473 }
2395 2474  
2396   - ord_goods.splice(pos+1,0,newd);
  2475 + //ord_goods.splice(pos+1,0,newd);
2397 2476 th.data.old_cartlist[i].goods.splice(pos2+1,0,newd);
2398 2477  
2399   - var txt9 = "cartlist[" + i + "].goods";
2400   - th.setData({ [txt9]: ord_goods })
  2478 + var txt9 = "cartlist[" + i + "].goods["+(pos+1)+"]";
  2479 + th.setData({ [txt9]: newd })
2401 2480  
2402 2481 }
2403 2482  
... ... @@ -6610,25 +6689,26 @@ Page({
6610 6689 }).then(res => {
6611 6690 if (res.data.code == 0) {
6612 6691 var quan_list = res.data.data.pageData;
6613   - arr[ind].quan_list = th.check_is_frozenQuan(quan_list, th.data.frozenQuan);
  6692 + //arr[ind].quan_list = th.check_is_frozenQuan(quan_list, th.data.frozenQuan);
  6693 + quan_list= th.check_is_frozenQuan(quan_list, th.data.frozenQuan);
  6694 + var set_txt = "cartlist[" + ind + "].quan_list";
  6695 + th.setData({
  6696 + [set_txt]:quan_list
  6697 + })
6614 6698 }
6615 6699 })
6616 6700 }
6617   -
6618   -
6619 6701 }
6620 6702  
6621 6703  
6622   -
6623   -
6624 6704 //如果是搭配购的立即购买的时候
6625 6705 if (th.data.is_b_now) {
6626 6706 if (arr && arr.length > 0) {
6627 6707 var quanlist = arr[0].quan_list;
6628   - th.setData({ selected_quan_list: quanlist, cartlist: arr })
  6708 + th.setData({ selected_quan_list: quanlist })
6629 6709 }
6630 6710 } else {
6631   - th.setData({ cartlist: arr })
  6711 + //th.setData({ cartlist: arr })
6632 6712 th.set_can_num();
6633 6713 }
6634 6714  
... ... @@ -6899,25 +6979,38 @@ Page({
6899 6979 }
6900 6980 return user_pre_buynum
6901 6981 },
  6982 +
  6983 +
6902 6984 //获取优惠活动
6903   - async getprom(item){
6904   -
  6985 + getprom(item){
  6986 +
6905 6987 let prom_id=item.prom_id
6906 6988 let pickup_id=item.pick_id
6907 6989 let limit_num=0
6908   - await getApp().request.promiseGet("/api/weshop/promgoods/get/" + oo.stoid + "/" + prom_id, {}).then(res => {
6909   - if (res.data.code == 0) {
6910   - let prom = res.data.data;
6911   - limit_num =prom.limit_num
6912   - let yh_is_xz_yh=this.data.yh_is_xz_yh
6913   - yh_is_xz_yh[pickup_id]=prom.is_xz_yh
6914   - this.setData({
6915   - ['yh_is_xz_yh']:yh_is_xz_yh
6916   - })
6917   - }
6918   - })
  6990 + //不再调用接口活动优惠促销活动的内容
  6991 + // await getApp().request.promiseGet("/api/weshop/promgoods/get/" + oo.stoid + "/" + prom_id, {}).then(res => {
  6992 + // if (res.data.code == 0) {
  6993 + // let prom = res.data.data;
  6994 + // limit_num =prom.limit_num
  6995 + // let yh_is_xz_yh=this.data.yh_is_xz_yh
  6996 + // yh_is_xz_yh[pickup_id]=prom.is_xz_yh
  6997 + // this.setData({
  6998 + // ['yh_is_xz_yh']:yh_is_xz_yh
  6999 + // })
  7000 + // }
  7001 + // })
  7002 + if(this.data.yhcx_act_map[prom_id]){
  7003 + let prom = this.data.yhcx_act_map[prom_id];
  7004 + limit_num =prom.limit_num
  7005 + let yh_is_xz_yh=this.data.yh_is_xz_yh
  7006 + yh_is_xz_yh[pickup_id]=prom.is_xz_yh
  7007 + this.setData({
  7008 + ['yh_is_xz_yh']:yh_is_xz_yh
  7009 + })
  7010 + }
6919 7011 return limit_num
6920 7012 },
  7013 +
6921 7014 //--检查订单优惠--
6922 7015 check_is_order_prom: function (condition, func, pick) {
6923 7016 var th = this;
... ... @@ -6971,10 +7064,11 @@ Page({
6971 7064  
6972 7065 } else {
6973 7066 var prom = null;
6974   -
6975   - await getApp().request.promiseGet("/api/weshop/promgoods/get/" + os.stoid + "/" + item.prom_id, {}).then(res => {
6976   - if (res.data.code == 0) {
6977   - prom = res.data.data;
  7067 +
  7068 +
  7069 + if(th.data.yhcx_act_map[item.prom_id]){
  7070 +
  7071 + prom = th.data.yhcx_act_map[item.prom_id];
6978 7072  
6979 7073 let min_value = 0
6980 7074 if (prom && prom.is_xz_yh) {
... ... @@ -7001,7 +7095,8 @@ Page({
7001 7095 }
7002 7096 }
7003 7097 }
7004   - })
  7098 +
  7099 + if(!prom) return false;
7005 7100 var ob = {};
7006 7101 ob.prom_id = item.prom_id;
7007 7102 ob.name = prom.name;
... ... @@ -7033,11 +7128,9 @@ Page({
7033 7128 } else {
7034 7129 var ob = {};
7035 7130 var prom = null;
7036   -
7037   - await getApp().request.promiseGet("/api/weshop/promgoods/get/" + os.stoid + "/" + item.prom_id, {}).then(res => {
7038   - if (res.data.code == 0) {
7039   - prom = res.data.data;
7040 7131  
  7132 + if(th.data.yhcx_act_map[item.prom_id]){
  7133 + prom = th.data.yhcx_act_map[item.prom_id];
7041 7134 let min_value = 0
7042 7135 if (prom && prom.is_xz_yh) {
7043 7136 let arr = prom.promGoodsList || []
... ... @@ -7063,9 +7156,8 @@ Page({
7063 7156 }
7064 7157 }
7065 7158 }
7066   - })
7067   -
7068 7159  
  7160 + if(!prom) return false;
7069 7161 //优惠促销取价的优化
7070 7162 let f_price=item.goods_price;
7071 7163  
... ... @@ -8283,6 +8375,7 @@ Page({
8283 8375 pro_pop.set_init(1,cp_arr);
8284 8376 },
8285 8377  
  8378 +
8286 8379 //--- 选择回来时候的选择 ---
8287 8380 sure_cx_group:function(e){
8288 8381 var th=this;
... ... @@ -8291,8 +8384,12 @@ Page({
8291 8384 //-- 获取到当前的show_can_cx--
8292 8385 var idx=this.data.sele_cx_group_cidx;
8293 8386 var gd_key= this.data.cx_group_gd_key;
  8387 +
  8388 +
  8389 + var pk_id=this.data.cartlist[idx].pickup_id;
  8390 + var cx_prom_group2= th.data.show_can_cx_map[pk_id][gd_key].act_arr;
  8391 +
8294 8392 var cx_prom_group=this.data.cartlist[idx].show_can_cx[gd_key].act_arr;
8295   - var pk=this.data.cartlist[idx].pickup_id;
8296 8393  
8297 8394 th.setData({
8298 8395 send_lb:{},
... ... @@ -8311,12 +8408,19 @@ Page({
8311 8408 //如果活动不是选择的
8312 8409 if(cx_prom_group[dx].prom_type!=sele_prom_type) cx_prom_group[dx].sele=0;
8313 8410 else cx_prom_group[dx].sele=1;
  8411 +
  8412 + if(cx_prom_group2[dx].prom_type!=sele_prom_type) cx_prom_group2[dx].sele=0;
  8413 + else cx_prom_group2[dx].sele=1;
8314 8414 }
8315 8415 //选择后就要把活动确定下来
8316 8416 //确定一下活动,先看一下有没有选择的活动
8317 8417 var ck_prom_type=cx_prom_group.find(function (el){
8318 8418 return el.sele;
8319 8419 })
  8420 + var ck_prom_type2=cx_prom_group2.find(function (el){
  8421 + return el.sele;
  8422 + })
  8423 +
8320 8424  
8321 8425 this.cx_check_ok2(function (ck_res){
8322 8426  
... ... @@ -8328,16 +8432,16 @@ Page({
8328 8432 var goods0= JSON.parse(JSON.stringify(th.data.cartlist_y));
8329 8433 var goods=[];
8330 8434 for(var ik=0;ik<goods0.length;ik++){
8331   - var item_c=goods0[ik];
8332   - if(item_c.pick_id==pk && item_c.is_collocation) continue;
8333   - goods.push(item_c);
  8435 + var item_c=goods0[ik];
  8436 + if(item_c.pick_id==pk && item_c.is_collocation) continue;
  8437 + goods.push(item_c);
8334 8438 }
8335 8439  
8336 8440 //-- 此时要把购物车中的商品确定活动 --
8337   - for (var b=0; b<ck_prom_type.goods.length;b++){
  8441 + for (var b=0; b<ck_prom_type2.goods.length;b++){
8338 8442 //-- 开始查找 --
8339 8443 var fg=goods.findIndex(function (g_item){
8340   - return g_item.goods_id==ck_prom_type.goods[b].goods_id
  8444 + return g_item.goods_id==ck_prom_type2.goods[b].goods_id
8341 8445 && [0,3,5,7,10].indexOf(g_item.prom_type)>-1
8342 8446 && g_item.pick_id==pk && g_item.is_gift==0;
8343 8447 })
... ... @@ -8352,10 +8456,10 @@ Page({
8352 8456 }
8353 8457  
8354 8458 for(var ik=0;ik< th.data.cartlist[idx].goods.length;ik++){
8355   - if(th.data.cartlist[idx].goods[ik].id==goods[fg].id){
8356   - th.data.cartlist[idx].goods[ik].prom_type= goods[fg].prom_type;
8357   - th.data.cartlist[idx].goods[ik].prom_id= goods[fg].prom_id;
8358   - }
  8459 + if(th.data.cartlist[idx].goods[ik].id==goods[fg].id){
  8460 + th.data.cartlist[idx].goods[ik].prom_type= goods[fg].prom_type;
  8461 + th.data.cartlist[idx].goods[ik].prom_id= goods[fg].prom_id;
  8462 + }
8359 8463 }
8360 8464  
8361 8465 //原始数据要有深拷贝不能有地址的牵连
... ...
pages/cart/cart/cart.js
... ... @@ -59,6 +59,9 @@ Page({
59 59  
60 60 is_cart:1, //标记是购物车计算的时候
61 61  
  62 + //送赠品的优化
  63 + cart_zp:{}
  64 +
62 65 },
63 66  
64 67 //-- 立即购买的时候,获取商品优惠活动,is_state判断是不是单个商品购买,
... ... @@ -126,6 +129,9 @@ Page({
126 129 },
127 130 onShow: function () {
128 131  
  132 + //-- 清空 checkouting 结算的标记 --
  133 + this.data.checkouting=0;
  134 +
129 135 if(getApp().globalData.from_act_link){
130 136 this.data.from_act_link= ut.deep_cp(getApp().globalData.from_act_link);
131 137 getApp().globalData.from_act_link=null;
... ... @@ -140,7 +146,8 @@ Page({
140 146 //每次显示都清空
141 147 this.data.in_zhact_gdmap = {};
142 148 this.setData({
143   - invalidList: []
  149 + invalidList: [],
  150 + cart_zp:{} //-- 赠品也要清理显示 --
144 151 });
145 152  
146 153 if (typeof this.getTabBar === 'function' && this.getTabBar()) {
... ... @@ -290,7 +297,6 @@ Page({
290 297 var user = getApp().globalData.userInfo;
291 298 //如果后台有开启等级价的功能
292 299 if (user && parseInt(s_list.rank_switch) == 2 && user['card_expiredate']) {
293   -
294 300 var str = user['card_expiredate'].replace(/-/g, '/');
295 301 var end = new Date(str);
296 302 end = Date.parse(end) / 1000;
... ... @@ -517,7 +523,18 @@ Page({
517 523  
518 524 wx.showLoading();
519 525  
520   - getApp().request.get("/api/weshop/cart/list", {
  526 + //一次性把购物车selected状态变成0
  527 + var url = '/api/weshop/cart/updateUserCart';
  528 + getApp().request.put(url, {
  529 + data: {
  530 + user_id: app.globalData.user_id,
  531 + store_id: oo.stoid,
  532 + selected: 0,
  533 + state:0
  534 + }
  535 + });
  536 +
  537 + getApp().request.get("/api/weshop/cart/listNew1", {
521 538 data: {
522 539 user_id: app.globalData.user_id,
523 540 rd: rd,
... ... @@ -534,65 +551,81 @@ Page({
534 551  
535 552 if (carr && carr.length > 0) {
536 553 var g_arr = [];
  554 + var by_map = null;
  555 +
537 556 for (var i = 0; i < carr.length; i++) {
538   - //-- 清理购物车的选中状态 --
539   - var url = '/api/weshop/cart/update';
540   - getApp().request.put(url, {
541   - data: {
542   - id: carr[i].id,
543   - store_id: oo.stoid,
544   - selected: 0,
545   - }
546   - });
  557 + //填充一下已经买了多少件,只有在商品是有限购条件的时候才进行计算good.viplimited>0
  558 + if(carr[i].viplimited>0){
  559 + if(!by_map) by_map={};
  560 + by_map[carr[i].goods_id] = carr[i].goodsbuynum?carr[i].goodsbuynum:0;
  561 + }
547 562  
548   - if (g_arr.length == 0) g_arr.push(carr[i].goods_id);
549   - else {
550   - var ind = g_arr.findIndex(function (ele) {
  563 + //如果不是活动的时候,不是代发商品的时候,不是赠品的时候
  564 + if([1, 2, 4, 6, 8, 9].indexOf(carr[i].prom_type)== -1 && !carr[i].whsle_id && !carr[i].is_gift ){
  565 +
  566 + //快速查找
  567 + let f_idx=g_arr.findIndex(function (ele) {
551 568 return ele.goods_id == carr[i].goods_id
552   - })
553   - if (ind > -1) continue;
554   - g_arr.push(carr[i].goods_id)
  569 + });
  570 + if(f_idx>-1) continue;
  571 +
  572 + let gd_ite={
  573 + goods_id:carr[i].goods_id,
  574 + goods_num:1,
  575 + is_limit_show:1,
  576 + is_state:0
  577 + }
  578 + g_arr.push(gd_ite);
555 579 }
556 580 }
557 581  
558   - var by_map = null;
559   -
560   - // //--要获得商品,该用户买了多少件,同步应用--
561   - // await getApp().request.promiseGet("/api/weshop/ordergoods/listUserBuyGoodsNum", {
562   - // data: {
563   - // store_id: oo.stoid,
564   - // user_id: user_id,
565   - // goods_ids: g_arr.join(','),
566   - //
567   - // },
568   - // }).then(res => {
569   - // if (ut.ajax_ok2(res)) {
570   - // by_map = {};
571   - // for (let i in res.data.data) {
572   - // let item = res.data.data[i];
573   - // by_map[item.goods_id] = item;
574   - // }
575   - // }
576   - // })
577   -
578   - for (let ir = 0; ir < g_arr.length; ir++) {
579   - let gg_it=g_arr[ir];
580   - await getApp().request.promiseGet("/api/weshop/ordergoods/getUserBuyGoodsNum", {
581   - data: {
582   - store_id: oo.stoid,
583   - user_id: user_id,
584   - goods_id: gg_it,
585   - isnew:1
586   - },
587   - }).then(tt => {
588   - if (tt.data.code == 0) {
589   - if(!by_map) by_map={};
590   - by_map[gg_it] = tt.data.data;
  582 + //获取商品参与的促销活,优惠促,搭配促,组合促,阶梯促销
  583 + let cx_rs= await getApp().request.promisePost("/api/weshop/cart/listGoodsPromInfo",{
  584 + is_json:1,
  585 + data:{
  586 + user_id:app.globalData.user_id,
  587 + store_id:oo.stoid,
  588 + goods:g_arr,
  589 + }
  590 + });
  591 + //-- 判断返回结果有没有正确,有促销活动就要进行赋值 --
  592 + if(cx_rs && cx_rs.data.code==0 && cx_rs.data.data && cx_rs.data.data.goods) {
  593 + let g_list=cx_rs.data.data.goods;
  594 + for (var ia = 0; ia < carr.length; ia++) {
  595 + if (carr[ia].whsle_id) continue; //代发商品不进行赋值
  596 + if (carr[ia].is_gift) continue; //赠品不进行赋值
  597 + //有参与秒,团购之类的活动不进行赋值
  598 + if([1, 2, 4, 6, 8, 9].indexOf(carr[ia].prom_type)> -1 ) continue;
  599 + //再g_list中快速查找
  600 + let i_fd=g_list.find(function (ele) {
  601 + return ele.goods_id == carr[ia].goods_id
  602 + });
  603 + if(i_fd.goodsPromInfoRespDto){
  604 + //-- 多促销活动的优化 --
  605 + i_fd=i_fd.goodsPromInfoRespDto;
  606 + //-- 赋值多促销活动的优化--
  607 + carr[ia].more_cx=i_fd.more_cx;
  608 + if (i_fd.zh_pro) {
  609 + th.data.zuhe_map[i_fd.zh_pro.id] = i_fd.zh_pro;
  610 + }
  611 + if (i_fd.ladder_pro) {
  612 + var ladder_pro = i_fd.ladder_pro;
  613 + th.data.ladder_map[ladder_pro.id] = ladder_pro;
  614 + var fd_ite = i_fd.more_cx.find(function (e) {
  615 + return e.prom_type == 10;
  616 + })
  617 + if (fd_ite) {
  618 + th.data.ladder_map[ladder_pro.id].ladder_list = fd_ite.ladder_list;
591 619 }
592   - })
  620 + }
  621 + }
  622 +
  623 + }
593 624 }
594 625  
595 626  
  627 +
  628 + let cart_up_data=[];
596 629 for (var i = 0; i < carr.length; i++) {
597 630 var item = carr[i];
598 631 var good = item;
... ... @@ -622,7 +655,7 @@ Page({
622 655 promgoodsbuynum = 0,
623 656 limit = 0;
624 657 if (by_map && by_map[good.goods_id]) {
625   - goodsbuynum = by_map[good.goods_id].goodsbuynum;
  658 + goodsbuynum = by_map[good.goods_id];
626 659 //promgoodsbuynum = by_map[good.goods_id].promgoodsbuynum;
627 660 }
628 661  
... ... @@ -662,19 +695,19 @@ Page({
662 695 } else {
663 696 item.goods_price = good.shop_price;
664 697 }
665   -
666 698 //-- 购物车更新 --
667 699 var updata1 = {
668   - id: item.id,
669   - prom_type: c_prom_type,
670   - prom_id: c_prom_id,
671   - store_id: os.stoid,
672   - user_id: getApp().globalData.userInfo.user_id
  700 + id: item.id,
  701 + prom_type: c_prom_type,
  702 + prom_id: c_prom_id,
  703 + store_id: os.stoid,
  704 + user_id: getApp().globalData.userInfo.user_id,
  705 + goods_price:item.goods_price
673 706 };
674   - getApp().request.put("/api/weshop/cart/update", {
675   - data: updata1,
676   - })
677   -
  707 + // getApp().request.put("/api/weshop/cart/update", {
  708 + // data: updata1,
  709 + // })
  710 + cart_up_data.push(updata1);
678 711 }
679 712  
680 713 //判断如果是普通商品,后面参加活动了,变成失效商品
... ... @@ -682,24 +715,16 @@ Page({
682 715  
683 716 var prom = null;
684 717 var now = ut.gettimestamp();
685   - await getApp().request.promiseGet(`/api/weshop/activitylist/listGoodActInfo2New`, {
686   - data: {
687   - "store_id": oo.stoid,
688   - "goods_id": item.goods_id,
689   - "user_id": user_id,
690   - }
691   - }).then(res => {
692   - if (res.data.code == 0) {
693   - //开始时间已经开始的情况
694   - for (var i = 0; i < res.data.data.length; i++) {
695   - var a_item = res.data.data[i];
696   - if (a_item.s_time < now) {
697   - if (!prom) prom = [];
698   - prom.push(a_item);
699   - }
  718 + let prom_arr = item.goodsActinfo;
  719 + if(prom_arr && prom_arr.length){
  720 + for (var im = 0; im <prom_arr.length; im++) {
  721 + var a_item = prom_arr[im];
  722 + if (a_item.s_time < now) {
  723 + if (!prom) prom = [];
  724 + prom.push(a_item);
700 725 }
701 726 }
702   - })
  727 + }
703 728  
704 729 //只有一种活动,但是又是秒杀之类是互动,就要失效。不能是普通购买
705 730 if (prom && prom.length == 1 && [1, 2, 4, 6, 8, 9].indexOf(prom[0].prom_type) > -1 && !item.is_integral_normal && !item.is_pd_normal) {
... ... @@ -725,36 +750,19 @@ Page({
725 750  
726 751 }
727 752  
728   -
729 753 //优化获取商品的活动购买了几件
730 754 if (item.prom_type == 1 || item.prom_type == 2) {
731   - await getApp().request.promiseGet("/api/weshop/ordergoods/getUserBuyPromNum", {
732   - data: {
733   - store_id: oo.stoid,
734   - user_id: user_id,
735   - goods_id: item.goods_id,
736   - prom_type: item.prom_type,
737   - prom_id: item.prom_id
738   - },
739   - }).then(res => {
740   - if (res.data.code == 0) {
741   - promgoodsbuynum = res.data.data.userbuynum;
742   - }
743   - })
  755 + if(item.promgoodsbuynum){
  756 + promgoodsbuynum=item.promgoodsbuynum;
  757 + }
744 758 }
745   -
746 759 //如果秒杀活动都去掉了,或者结束了,那么这个商品也没有必要留着
747 760 if (item.prom_type == 1) {
748   - var prom = null;
  761 + var prom = item.cartActinfo;
749 762 var now = ut.gettimestamp();
750   - await getApp().request.promiseGet("/api/ms/flash_sale/getNew/" + os.stoid + '/' + user_id + "/" + item.prom_id, {}).then(res => {
751   - console.log('活动情况----------------')
752   - console.log(res)
753   - if (res.data.code == 0 && res.data.data) {
754   - prom = res.data.data;
755   - prom.price = prom.user_price;
756   - }
757   - })
  763 + if(prom){
  764 + prom.price = prom.user_price;
  765 + }
758 766 //---如果互动都已经过期,或者还未开始,或者无活动
759 767 if (!prom || prom.is_end == 1 || prom.end_time < now || prom.start_time > now) {
760 768 // var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id;
... ... @@ -807,14 +815,12 @@ Page({
807 815 }
808 816 // 判断团购活动都去掉了,或者结束了,那么这个商品也没有必要留着
809 817 else if (item.prom_type == 2) {
810   - var prom = null;
  818 + var prom = item.cartActinfo;
811 819 var now = ut.gettimestamp();
812   - await getApp().request.promiseGet('/api/weshop/goods/groupBuy/getActInfo/' + oo.stoid + '/' + item.goods_id + '/' + item.prom_id, {}).then(res => {
813   - if (res.data.code == 0) {
814   - prom = res.data.data;
815   - prom.price = prom.user_price;
816   - }
817   - });
  820 + if(prom){
  821 + prom.price = prom.user_price;
  822 + }
  823 +
818 824 //---如果互动都已经过期,或者还未开始,或者无活动
819 825 if (!prom || prom.is_end == 1 || prom.end_time < now || prom.start_time > now) {
820 826 // var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id;
... ... @@ -863,8 +869,7 @@ Page({
863 869 item.init_goods_price=good.goods_price;
864 870  
865 871 //-- 读出每一种商品的所有的活动,方便后面的活动切换使用 --
866   - if (item.prom_type == 0)
867   - th.buy_pro_group(item, 0);
  872 + //if (item.prom_type == 0) th.buy_pro_group(item, 0);
868 873  
869 874 var pcid = item.pick_id;
870 875 var find = 0;
... ... @@ -900,8 +905,15 @@ Page({
900 905 arr.push(ie);
901 906 }
902 907 }
903   - }
904 908  
  909 + //更新一下购物车商品的活动信息
  910 + if(cart_up_data.length>0){
  911 + getApp().request.promisePost('/api/weshop/cart/updateCartPromInfo',{
  912 + is_json:1,
  913 + data:cart_up_data
  914 + })
  915 + }
  916 + }
905 917 if (th.data.is_open_offline && th.data.is_open_offline > 0 && th.data.sales_rules == 2) {
906 918 //-- 此时要实时更新线下取价价格 --
907 919 for (var i = 0; i < arr.length; i++) {
... ... @@ -1224,7 +1236,6 @@ Page({
1224 1236  
1225 1237 if (a = isNaN(t.detail.value) || t.detail.value < 1 ? 1 : parseInt(t.detail.value)) {
1226 1238 //this.clear_req();
1227   -
1228 1239 var s = {
1229 1240 goods_num: a,
1230 1241 goods_id: e.goods_id,
... ... @@ -1237,14 +1248,14 @@ Page({
1237 1248  
1238 1249 //-------------加减数量的时候,要把show_can_cx清理掉,
1239 1250 // 同时应该记录一下当前是什么活动那个,如果切换后的活动有跟切换前的活动一样是,就要让切换后的活动的值匹配选中-------------
1240   -
1241 1251 clear_req: function () {
1242 1252 var carr = this.data.requestData;
1243 1253 for (var i = 0; i < carr.length; i++) {
1244   - var txt = 'requestData[' + i + '].show_can_cx'
1245   - this.setData({
1246   - [txt]: null
1247   - });
  1254 + var txt = 'requestData[' + i + '].show_can_cx1'
  1255 + this.setData({
  1256 + [txt]: null
  1257 + });
  1258 + this.data.requestData[i].show_can_cx=null;
1248 1259 }
1249 1260 },
1250 1261  
... ... @@ -1282,7 +1293,7 @@ Page({
1282 1293 var add_num = 1;
1283 1294 //调用接口判断是不是促销活动的商品
1284 1295 if ([0, 3, 5, 7, 10].indexOf(a.prom_type) > -1) {
1285   - var cx_arr = await getApp().get_has_cx_act(a.goods_id);
  1296 + var cx_arr = getApp().get_has_cx_act2(a.goodsActinfo);
1286 1297 var steep = getApp().get_limit_qty(a, cx_arr.length, 1);
1287 1298 if (steep > 1) {
1288 1299 add_num = steep;
... ... @@ -1321,7 +1332,7 @@ Page({
1321 1332 //this.clear_req();
1322 1333 var add_num = 1;
1323 1334 if ([0, 3, 5, 7, 10].indexOf(a.prom_type) > -1) {
1324   - var cx_arr = await getApp().get_has_cx_act(a.goods_id);
  1335 + var cx_arr = getApp().get_has_cx_act2(a.goodsActinfo);
1325 1336 var steep = getApp().get_limit_qty(a, cx_arr.length, 1);
1326 1337 if (steep > 1) {
1327 1338 add_num = steep;
... ... @@ -1477,36 +1488,44 @@ Page({
1477 1488 }
1478 1489 },
1479 1490  
1480   -
1481 1491 //---------------全选,全选的时候要判断是否门店的匹配方式一致--------------
1482 1492 checkAll: async function () {
  1493 +
  1494 + console.log('1111');
  1495 + console.log(this.data.clicking);
  1496 +
  1497 + //防止重复点击,弹出加载动画,转圈圈
  1498 + if(this.data.clicking) return false;
  1499 + this.data.clicking=1;
  1500 + this.set_clicking();
  1501 +
1483 1502 var e = this,
1484   - th = this,
1485   - dda = e.data.requestData,
1486   - sdda = e.data.service_data,
1487   - tfeel = 0,
1488   - t_num = 0,
1489   - text_arr = "";
  1503 + th = this,
  1504 + dda = e.data.requestData,
  1505 + sdda = e.data.service_data,
  1506 + tfeel = 0,
  1507 + t_num = 0,
  1508 + text_arr = "";
1490 1509  
1491 1510  
1492 1511 if(this.data.is_edit){
1493 1512 let val=!e.data.checkAllToggle;
1494 1513 if (dda && dda.length > 0) {
1495   - for (var i = 0; i < dda.length; i++) {
1496   - var item = dda[i].goods;
  1514 + for (var i = 0; i < dda.length; i++) {
  1515 + var item = dda[i].goods;
1497 1516  
1498   - var txt0 = "requestData[" + i + "].selected";
1499   - this.setData({
1500   - [txt0]: val,
1501   - });
  1517 + var txt0 = "requestData[" + i + "].selected";
  1518 + this.setData({
  1519 + [txt0]: val,
  1520 + });
1502 1521  
1503   - for (var j = 0; j < item.length; j++) {
1504   - let txt = "requestData[" + i + "].goods[" + j + "].selected";
1505   - e.setData({
1506   - [txt]: val,
1507   - });
1508   - }
  1522 + for (var j = 0; j < item.length; j++) {
  1523 + let txt = "requestData[" + i + "].goods[" + j + "].selected";
  1524 + e.setData({
  1525 + [txt]: val,
  1526 + });
1509 1527 }
  1528 + }
1510 1529 }
1511 1530 if (sdda && sdda.length > 0) {
1512 1531 for (i = 0; i < sdda.length; i++) {
... ... @@ -1529,15 +1548,18 @@ Page({
1529 1548 e.setData({
1530 1549 checkAllToggle: val,
1531 1550 })
  1551 +
  1552 + th.clear_clicking();
1532 1553 return false;
1533 1554 }
1534 1555  
1535 1556 if (e.data.requestData && e.data.requestData.length > 0 &&
1536   - e.data.service_data && e.data.service_data.length > 0) {
  1557 + e.data.service_data && e.data.service_data.length > 0) {
1537 1558 wx.showModal({
1538 1559 title: '提示',
1539 1560 content: '服务卡项目不能和商品一起选择'
1540 1561 });
  1562 + th.clear_clicking();
1541 1563 return false;
1542 1564 }
1543 1565  
... ... @@ -1550,10 +1572,11 @@ Page({
1550 1572 if (dda && dda.length > 0) {
1551 1573 for (var i = 0; i < dda.length; i++) {
1552 1574 var item = dda[i].goods;
1553   - var txt0 = "requestData[" + i + "].show_can_cx";
  1575 + var txt0 = "requestData[" + i + "].show_can_cx1";
1554 1576 e.setData({
1555 1577 [txt0]: {},
1556 1578 });
  1579 + th.data.requestData[i].show_can_cx=null; //清空需要的
1557 1580  
1558 1581 if (e.data.checkAllToggle) {
1559 1582 var txt = "requestData[" + i + "].selected";
... ... @@ -1579,35 +1602,37 @@ Page({
1579 1602 });
1580 1603  
1581 1604 if (ob.code == -1) {
1582   -
1583 1605 wx.showToast({
1584 1606 title: gd_info.goods_name+'购买数量超出商品库存',
1585 1607 icon: 'none',
1586 1608 });
1587 1609  
  1610 + th.clear_clicking();
1588 1611 return false;
1589   - } else {
1590   - if (th.data.sales_rules == 3) {
1591   - var goods_id = gd_info.goods_id;
1592   - var num = 0;
1593   -
1594   - for (let ii = 0; ii< th.data.requestData.length; ii++) {
1595   - if (i == ii) continue;
1596   - var it = th.data.requestData[ii].goods.find((e) => {
1597   - return e.goods_id == goods_id;
1598   - })
1599   - if (it && it.selected) num += it.goods_num
1600   - }
  1612 + }
1601 1613  
1602   - if (num > ob.CanOutQty) {
1603   - wx.showToast({
1604   - title: gd_info.goods_name+'购买数量超出商品库存',
1605   - icon: 'none',
1606   - });
1607   - return false;
1608   - }
  1614 + if (th.data.sales_rules == 3) {
  1615 + var goods_id = gd_info.goods_id;
  1616 + var num = 0;
  1617 +
  1618 + for (let ii = 0; ii< th.data.requestData.length; ii++) {
  1619 + if (i == ii) continue;
  1620 + var it = th.data.requestData[ii].goods.find((e) => {
  1621 + return e.goods_id == goods_id;
  1622 + })
  1623 + if (it && it.selected) num += it.goods_num
  1624 + }
  1625 +
  1626 + if (num > ob.CanOutQty) {
  1627 + wx.showToast({
  1628 + title: gd_info.goods_name+'购买数量超出商品库存',
  1629 + icon: 'none',
  1630 + });
  1631 + th.clear_clicking();
  1632 + return false;
1609 1633 }
1610 1634 }
  1635 +
1611 1636 }
1612 1637  
1613 1638  
... ... @@ -1615,7 +1640,7 @@ Page({
1615 1640 //-- 判断起购数量 --
1616 1641 if (!e.data.checkAllToggle) {
1617 1642 //判断是不是有促销活动
1618   - var act = await getApp().get_has_cx_act(obj.goods_id);
  1643 + var act = getApp().get_has_cx_act2(obj.goodsActinfo);
1619 1644 th.click_set_limit(obj, i, j, act);
1620 1645 }
1621 1646  
... ... @@ -1677,9 +1702,6 @@ Page({
1677 1702 });
1678 1703  
1679 1704 } else {
1680   - e.setData({
1681   - [txt]: !e.data.checkAllToggle,
1682   - })
1683 1705  
1684 1706 if (!e.data.checkAllToggle) {
1685 1707 //组合购的金额要另外算
... ... @@ -1694,6 +1716,7 @@ Page({
1694 1716 offline_num += item[j].goods_num;
1695 1717 }
1696 1718 }
  1719 +
1697 1720 e.setData({
1698 1721 [txt]: !e.data.checkAllToggle,
1699 1722 })
... ... @@ -1720,79 +1743,79 @@ Page({
1720 1743 title: '提示',
1721 1744 content: text_arr + '不能与门店中其他商品一起结算,配送方式不一致'
1722 1745 });
  1746 + th.clear_clicking();
1723 1747 return false;
1724   - } else {
  1748 + }
1725 1749  
1726   - for (var i = 0; i < dda.length; i++) {
1727 1750  
1728   - // if (!e.data.checkAllToggle) {
1729   - //多门店优惠促销次数控制
1730   - if (dda[i].pro_off || e.data.checkAllToggle) {
1731   - var txt = "requestData[" + i + "].selected";
1732   - e.setData({
1733   - [txt]: 0,
1734   - });
1735   - } else {
1736   - var txt = "requestData[" + i + "].selected";
1737   - e.setData({
1738   - [txt]: 1,
1739   - });
1740   - }
1741   - // }
  1751 + for (var i = 0; i < dda.length; i++) {
1742 1752  
1743   - //总的价格,把组合商品的价格拿出来
1744   - // var zh_calc_res = zh_calc.calculate_zh(dda, i, this);
1745   - // tfeel += zh_calc_res.tfeel;
1746   - // offline_price += zh_calc_res.offline_price;
1747   - // offline_num += zh_calc_res.offline_num;
1748   - //
1749   - // //总的价格,把阶梯促销的商品的价格拿出来
1750   - // var ladder_calc_res = ladder_calc.calculate_ladder(dda, i, this);
1751   - // tfeel += ladder_calc_res.tfeel;
1752   - // offline_price += ladder_calc_res.offline_price;
1753   - // offline_num += ladder_calc_res.offline_num;
1754   - //
1755   - // //当有线下取价的时候
1756   - // if (offline_price) {
1757   - // var txt1 = "requestData[" + i + "].offline_price";
1758   - // var txt2 = "requestData[" + i + "].offline_num";
1759   - // th.setData({
1760   - // [txt1]: offline_price.toFixed(2),
1761   - // [txt2]: offline_num,
1762   - // });
1763   - // } else {
1764   - // if (dda[i].offline_price > 0) {
1765   - // var txt1 = "requestData[" + i + "].offline_price";
1766   - // var txt2 = "requestData[" + i + "].offline_num";
1767   - // th.setData({
1768   - // [txt1]: 0,
1769   - // [txt2]: 0
1770   - // });
1771   - // }
1772   - // }
1773   - }
1774   - //多门店优惠次数控制
1775   - if (pro_off) {
  1753 + // if (!e.data.checkAllToggle) {
  1754 + //多门店优惠促销次数控制
  1755 + if (dda[i].pro_off || e.data.checkAllToggle) {
  1756 + var txt = "requestData[" + i + "].selected";
1776 1757 e.setData({
1777   - checkAllToggle: false,
  1758 + [txt]: 0,
1778 1759 });
1779 1760 } else {
  1761 + var txt = "requestData[" + i + "].selected";
1780 1762 e.setData({
1781   - checkAllToggle: !e.data.checkAllToggle,
  1763 + [txt]: 1,
1782 1764 });
1783 1765 }
1784   - e.setData({
1785   - checkAllToggle: !e.data.checkAllToggle,
1786   - // total_fee: tfeel.toFixed(2),
1787   - // total_num: t_num,
  1766 + // }
1788 1767  
1789   - });
  1768 + //总的价格,把组合商品的价格拿出来
  1769 + // var zh_calc_res = zh_calc.calculate_zh(dda, i, this);
  1770 + // tfeel += zh_calc_res.tfeel;
  1771 + // offline_price += zh_calc_res.offline_price;
  1772 + // offline_num += zh_calc_res.offline_num;
  1773 + //
  1774 + // //总的价格,把阶梯促销的商品的价格拿出来
  1775 + // var ladder_calc_res = ladder_calc.calculate_ladder(dda, i, this);
  1776 + // tfeel += ladder_calc_res.tfeel;
  1777 + // offline_price += ladder_calc_res.offline_price;
  1778 + // offline_num += ladder_calc_res.offline_num;
  1779 + //
  1780 + // //当有线下取价的时候
  1781 + // if (offline_price) {
  1782 + // var txt1 = "requestData[" + i + "].offline_price";
  1783 + // var txt2 = "requestData[" + i + "].offline_num";
  1784 + // th.setData({
  1785 + // [txt1]: offline_price.toFixed(2),
  1786 + // [txt2]: offline_num,
  1787 + // });
  1788 + // } else {
  1789 + // if (dda[i].offline_price > 0) {
  1790 + // var txt1 = "requestData[" + i + "].offline_price";
  1791 + // var txt2 = "requestData[" + i + "].offline_num";
  1792 + // th.setData({
  1793 + // [txt1]: 0,
  1794 + // [txt2]: 0
  1795 + // });
  1796 + // }
  1797 + // }
  1798 + }
1790 1799  
1791   - this.doCheckAll(function () {
1792   - e.all_check_prom_activity();
1793   - });
  1800 + //e.setData({
  1801 + //checkAllToggle: !e.data.checkAllToggle,
  1802 + // total_fee: tfeel.toFixed(2),
  1803 + // total_num: t_num,
  1804 + //});
  1805 +
  1806 + this.doCheckAll(async function () {
  1807 + await e.all_check_prom_activity();
  1808 +
  1809 + //多门店优惠次数控制
  1810 + if (pro_off) {
  1811 + e.setData({
  1812 + checkAllToggle: false,
  1813 + });
  1814 + }
  1815 + th.clear_clicking();
  1816 +
  1817 + });
1794 1818  
1795   - }
1796 1819 }
1797 1820  
1798 1821 if (sdda && sdda.length > 0) {
... ... @@ -1822,28 +1845,40 @@ Page({
1822 1845 total_fee: tfeel.toFixed(2),
1823 1846 total_num: t_num,
1824 1847 });
1825   - }
1826 1848  
  1849 + th.clear_clicking();
  1850 +
  1851 + }
1827 1852 },
  1853 +
  1854 +
1828 1855 //------门店全选按钮,要判断是否门店的匹配方式一致---------
1829 1856 check_th_all_item: async function (ele) {
  1857 +
  1858 + //防止重复点击
  1859 + if(this.data.clicking) return false;
  1860 + this.data.clicking=1;
  1861 + //加载动画
  1862 + this.set_clicking();
  1863 +
1830 1864 var e = this,
1831   - th = this,
1832   - pitems = ele.currentTarget.dataset.pitems,
1833   - item = this.data.requestData[pitems].goods,
1834   - sele = this.data.requestData[pitems].selected;
  1865 + th = this,
  1866 + pitems = ele.currentTarget.dataset.pitems,
  1867 + item = this.data.requestData[pitems].goods,
  1868 + sele = this.data.requestData[pitems].selected;
1835 1869 this.data.btn_click = 1;
1836 1870 var garr = e.data.service_data;
1837 1871  
1838 1872 var isok = 1,
1839   - fir = 0,
1840   - iarr = item;
  1873 + fir = 0,
  1874 + iarr = item;
1841 1875  
1842 1876 //清空-- 多个促销的切换 --
1843   - var txt0 = "requestData[" + pitems + "].show_can_cx";
  1877 + var txt0 = "requestData[" + pitems + "].show_can_cx1";
1844 1878 e.setData({
1845 1879 [txt0]: {},
1846 1880 });
  1881 + th.data.requestData[pitems].show_can_cx=null; //清空需要的
1847 1882  
1848 1883 if (!sele) {
1849 1884  
... ... @@ -1857,6 +1892,8 @@ Page({
1857 1892  
1858 1893 var txt0 = "requestData[" + pitems + "].selected";
1859 1894 this.setData({[txt0]:1})
  1895 +
  1896 + th.clear_clicking();
1860 1897 return false;
1861 1898 }
1862 1899  
... ... @@ -1875,6 +1912,7 @@ Page({
1875 1912 title: '提示',
1876 1913 content: '服务卡项目不能和商品一起选择'
1877 1914 });
  1915 + th.clear_clicking();
1878 1916 return false;
1879 1917 }
1880 1918 }
... ... @@ -1900,6 +1938,7 @@ Page({
1900 1938 title: '提示',
1901 1939 content: '同一门店自提和物流的商品不能同时结算'
1902 1940 });
  1941 + th.clear_clicking();
1903 1942 return false;
1904 1943 }
1905 1944  
... ... @@ -1910,7 +1949,7 @@ Page({
1910 1949 var gd_info = item[i];
1911 1950  
1912 1951 if (!sele) {
1913   - var act = await getApp().get_has_cx_act(gd_info.goods_id);
  1952 + var act =getApp().get_has_cx_act2(gd_info.goodsActinfo);
1914 1953 th.click_set_limit(gd_info, pitems, i, act)
1915 1954 }
1916 1955  
... ... @@ -1927,29 +1966,32 @@ Page({
1927 1966 icon: 'none',
1928 1967 });
1929 1968  
  1969 + th.clear_clicking();
1930 1970 return false;
1931   - } else {
1932   - if (th.data.sales_rules == 3) {
1933   - var goods_id = gd_info.goods_id;
1934   - var num = 0;
1935   -
1936   - for (let i = 0; i < th.data.requestData.length; i++) {
1937   - if (pitems == i) continue;
1938   - var it = th.data.requestData[i].goods.find((e) => {
1939   - return e.goods_id == goods_id;
1940   - })
1941   - if (it && it.selected) num += it.goods_num
1942   - }
  1971 + }
1943 1972  
1944   - if (num > ob.CanOutQty) {
1945   - wx.showToast({
1946   - title: gd_info.goods_name+'购买数量超出商品库存',
1947   - icon: 'none',
1948   - });
1949   - return false;
1950   - }
  1973 + if (th.data.sales_rules == 3) {
  1974 + var goods_id = gd_info.goods_id;
  1975 + var num = 0;
  1976 +
  1977 + for (let i = 0; i < th.data.requestData.length; i++) {
  1978 + if (pitems == i) continue;
  1979 + var it = th.data.requestData[i].goods.find((e) => {
  1980 + return e.goods_id == goods_id;
  1981 + })
  1982 + if (it && it.selected) num += it.goods_num
  1983 + }
  1984 +
  1985 + if (num > ob.CanOutQty) {
  1986 + wx.showToast({
  1987 + title: gd_info.goods_name+'购买数量超出商品库存',
  1988 + icon: 'none',
  1989 + });
  1990 + th.clear_clicking();
  1991 + return false;
1951 1992 }
1952 1993 }
  1994 +
1953 1995 }
1954 1996  
1955 1997 //判断多店优惠促销次数控制
... ... @@ -2023,12 +2065,17 @@ Page({
2023 2065 if (sele && i == pitems) continue;
2024 2066 await e.check_prom_activity(i);
2025 2067 }
  2068 +
  2069 + th.clear_clicking();
  2070 +
2026 2071 });
2027 2072 } else {
  2073 + th.clear_clicking();
2028 2074 wx.showToast({
2029 2075 title: the_res.msg,
2030 2076 icon: 'none',
2031 2077 });
  2078 +
2032 2079 }
2033 2080 })
2034 2081  
... ... @@ -2074,16 +2121,35 @@ Page({
2074 2121 },
2075 2122  
2076 2123  
2077   -
  2124 + //清理防止重复点击的状态函数---2024-2-1
  2125 + set_clicking(){
  2126 + wx.showLoading({
  2127 + mark:true
  2128 + });
  2129 + },
  2130 + //清理防止重复点击的状态函数---2024-2-1
  2131 + clear_clicking(){
  2132 + var th=this;
  2133 + wx.hideLoading({
  2134 + complete:function (){
  2135 + th.data.clicking=0;
  2136 + }
  2137 + });
  2138 + },
2078 2139 //---------------单选,也要判断门店的配送方式是否一致--------------
2079 2140 check_th_item: async function (t) {
  2141 +
  2142 + //防止重复点击
  2143 + if(this.data.clicking) return false;
  2144 + this.data.clicking=1;
  2145 +
2080 2146 var e = this,
2081   - th = this,
2082   - item = t.currentTarget.dataset.item,
2083   - pitems = t.currentTarget.dataset.pitems;
  2147 + th = this,
  2148 + item = t.currentTarget.dataset.item,
  2149 + pitems = t.currentTarget.dataset.pitems;
2084 2150 a = this.data.requestData[pitems].goods[item];
2085 2151 var isok = 1,
2086   - fir = 0;
  2152 + fir = 0;
2087 2153 var iarr = e.data.requestData[pitems].goods;
2088 2154 this.data.btn_click = 1;
2089 2155 var garr = e.data.service_data;
... ... @@ -2093,9 +2159,10 @@ Page({
2093 2159  
2094 2160 //如果是标记的时候
2095 2161 if(this.data.is_edit){
2096   - var txt = "requestData[" + pitems + "].goods[" + item + "].selected";
2097   - this.setData({[txt]:1})
2098   - return false;
  2162 + var txt = "requestData[" + pitems + "].goods[" + item + "].selected";
  2163 + this.setData({[txt]:1});
  2164 + th.clear_clicking();
  2165 + return false;
2099 2166 }
2100 2167  
2101 2168  
... ... @@ -2113,6 +2180,7 @@ Page({
2113 2180 title: '提示',
2114 2181 content: '服务卡项目不能和商品一起选择'
2115 2182 });
  2183 + th.clear_clicking();
2116 2184 return false;
2117 2185 }
2118 2186 }
... ... @@ -2142,112 +2210,120 @@ Page({
2142 2210 title: '提示',
2143 2211 content: '同一门店自提和物流的商品不能同时结算'
2144 2212 });
2145   - } else {
2146   - var txt = "requestData[" + pitems + "].goods[" + item + "].selected";
2147   - var gd_info = a;
  2213 + th.clear_clicking();
  2214 + return false;
  2215 + }
2148 2216  
2149   - var erpwareid = gd_info.erpwareid;
2150 2217  
2151   - //-- 如果是选中的时候 --
2152   - if (!a.selected) {
  2218 + var txt = "requestData[" + pitems + "].goods[" + item + "].selected";
  2219 + var gd_info = a;
2153 2220  
2154   - th.data.pitems=pitems;
  2221 + var erpwareid = gd_info.erpwareid;
2155 2222  
2156   - //判断是不是有促销活动
2157   - var act = await getApp().get_has_cx_act(gd_info.goods_id);
2158   - //-- 专门来设置商品订购数量 --
2159   - th.click_set_limit(gd_info, pitems, item, act)
2160   - if (th.data.sales_rules >= 2 && !gd_info.whsle_id && [1, 2, 4, 6, 8, 9].indexOf(gd_info.prom_type) == -1) {
  2223 + //-- 如果是选中的时候 --
  2224 + if (!a.selected) {
2161 2225  
2162   - var ob = {};
2163   - await th.check_down_line_next(gd_info, pitems, item, erpwareid, function (res) {
2164   - ob = res;
  2226 + th.data.pitems=pitems;
  2227 +
  2228 + //判断是不是有促销活动
  2229 + var act = getApp().get_has_cx_act2(gd_info.goodsActinfo);
  2230 + //-- 专门来设置商品订购数量 --
  2231 + th.click_set_limit(gd_info, pitems, item, act)
  2232 + if (th.data.sales_rules >= 2 && !gd_info.whsle_id && [1, 2, 4, 6, 8, 9].indexOf(gd_info.prom_type) == -1) {
  2233 +
  2234 + var ob = {};
  2235 + await th.check_down_line_next(gd_info, pitems, item, erpwareid, function (res) {
  2236 + ob = res;
  2237 + });
  2238 + if (ob.code == -1) {
  2239 + wx.showToast({
  2240 + title: '购买数量超出商品库存',
  2241 + icon: 'none',
2165 2242 });
2166   - if (ob.code == -1) {
  2243 + th.clear_clicking();
  2244 + return false;
  2245 + }
2167 2246  
  2247 + if (th.data.sales_rules == 3) {
  2248 + var goods_id = gd_info.goods_id;
  2249 + var num = 0;
  2250 +
  2251 + for (let i = 0; i < th.data.requestData.length; i++) {
  2252 + if (pitems == i) continue;
  2253 + var it = th.data.requestData[i].goods.find((e) => {
  2254 + return e.goods_id == goods_id;
  2255 + })
  2256 + if (it && it.selected) num += it.goods_num
  2257 + }
  2258 +
  2259 + if (num > ob.CanOutQty) {
2168 2260 wx.showToast({
2169 2261 title: '购买数量超出商品库存',
2170 2262 icon: 'none',
2171 2263 });
2172   -
  2264 + th.clear_clicking();
2173 2265 return false;
2174   - } else {
2175   - if (th.data.sales_rules == 3) {
2176   - var goods_id = gd_info.goods_id;
2177   - var num = 0;
2178   -
2179   - for (let i = 0; i < th.data.requestData.length; i++) {
2180   - if (pitems == i) continue;
2181   - var it = th.data.requestData[i].goods.find((e) => {
2182   - return e.goods_id == goods_id;
2183   - })
2184   - if (it && it.selected) num += it.goods_num
2185   - }
2186   -
2187   - if (num > ob.CanOutQty) {
2188   - wx.showToast({
2189   - title: '购买数量超出商品库存',
2190   - icon: 'none',
2191   - });
2192   -
2193   - return false;
2194   - }
2195   - }
2196 2266 }
2197   -
2198 2267 }
  2268 +
2199 2269 }
  2270 + }
2200 2271  
2201 2272  
2202   - let pro_off = false
2203   - //判断多店优惠促销次数控制
2204   - if (th.data.requestData.length > 1) {
2205   - if (a.prom_type == 3 && !a.selected) {
2206   - //pro_off = await th.multiple_stores_pro(pitems, item)
2207   - }
  2273 + let pro_off = false
  2274 + //判断多店优惠促销次数控制
  2275 + if (th.data.requestData.length > 1) {
  2276 + if (a.prom_type == 3 && !a.selected) {
  2277 + //pro_off = await th.multiple_stores_pro(pitems, item)
2208 2278 }
  2279 + }
  2280 +
  2281 + if (pro_off) {
  2282 + wx.showToast({
  2283 + title: '已超出优惠促销次数',
  2284 + icon: 'none',
  2285 + });
  2286 + th.clear_clicking();
  2287 + return false;
  2288 + }
  2289 +
  2290 + var txt0 = "requestData[" + pitems + "].show_can_cx";
  2291 + e.setData({
  2292 + [txt0]: {},
  2293 + });
  2294 + th.data.requestData[pitems].show_can_cx=null;
2209 2295  
2210   - if (pro_off) {
  2296 + //-- 选择了什么商品,就用什么商品来判断 --
  2297 + var sele_arr = {};
  2298 + sele_arr[item] = !a.selected;
  2299 + //回调判断活动有没有冲突
  2300 + this.cx_check_ok(pitems, sele_arr, function (the_res) {
  2301 + if (the_res.code == 0) {
  2302 + th.setData({
  2303 + [txt]: Number(!a.selected),
  2304 + });
  2305 + //要先处理了,再来判断要不要显示凑单
  2306 + th.doCheckAll(async function () {
  2307 + th.data.duo_zp_num_arr={};
  2308 + //判断商品是不是优惠活动
  2309 + for (var i in e.data.requestData) {
  2310 + await e.check_prom_activity(i);
  2311 + }
  2312 + //清理一下点击防止重复点击
  2313 + th.clear_clicking();
  2314 +
  2315 + });
  2316 + } else {
2211 2317 wx.showToast({
2212   - title: '已超出优惠促销次数',
  2318 + title: the_res.msg,
2213 2319 icon: 'none',
2214 2320 });
2215   - return false;
2216 2321 }
  2322 + })
2217 2323  
2218   - var txt0 = "requestData[" + pitems + "].show_can_cx";
2219   - e.setData({
2220   - [txt0]: {},
2221   - });
2222   -
2223   - //-- 选择了什么商品,就用什么商品来判断 --
2224   - var sele_arr = {};
2225   - sele_arr[item] = !a.selected;
2226   - //回调判断活动有没有冲突
2227   - this.cx_check_ok(pitems, sele_arr, function (the_res) {
2228   - if (the_res.code == 0) {
2229   - th.setData({
2230   - [txt]: Number(!a.selected),
2231   - });
2232   - //要先处理了,再来判断要不要显示凑单
2233   - th.doCheckAll(async function () {
2234   - th.data.duo_zp_num_arr={};
2235   - //判断商品是不是优惠活动
2236   - for (var i in e.data.requestData) {
2237   - await e.check_prom_activity(i);
2238   - }
  2324 + },
2239 2325  
2240   - });
2241   - } else {
2242   - wx.showToast({
2243   - title: the_res.msg,
2244   - icon: 'none',
2245   - });
2246   - }
2247   - })
2248 2326  
2249   - }
2250   - },
2251 2327  
2252 2328 //------门店全选按钮,要判断是否门店的匹配方式一致---------
2253 2329 check_th_all_item_ser: async function (ele) {
... ... @@ -2410,6 +2486,29 @@ Page({
2410 2486 for (var a = 0; a < car.length; a++) {
2411 2487 //-- 把活动组装进去 ---
2412 2488 var show_can_cx = rd_arr[a];
  2489 + //-- 把活动组装进去 ---
  2490 + let show_can_cx1 = ut.deep_cp(rd_arr[a]);
  2491 + //前端处理渲染的时,要处理一些不需要的字段属性
  2492 + if(show_can_cx1){
  2493 + for (const key in show_can_cx1) {
  2494 + let element = show_can_cx1[key];
  2495 + if(element.cur_act ){
  2496 + delete element.cur_act;
  2497 + }
  2498 + if(element.ch_map){
  2499 + delete element.ch_map;
  2500 + }
  2501 + if(element.act_arr && element.act_arr.length>0){
  2502 + for (var ij = 0; ij < element.act_arr.length; ij++) {
  2503 + var act_ite = element.act_arr[ij];
  2504 + delete act_ite.goods;
  2505 + delete act_ite.act;
  2506 + delete act_ite.key;
  2507 + }
  2508 + }
  2509 + }
  2510 + }
  2511 +
2413 2512  
2414 2513 car[a].zh_map = null;
2415 2514 car[a].ladder_map = null;
... ... @@ -2514,7 +2613,9 @@ Page({
2514 2613 } else if (item[c].prom_type == 10) {
2515 2614 ladder_calc.add_ladder_prom(car, a, obj);
2516 2615 } else {
  2616 + console.log("索引:"+c+",数量:"+item[c].goods_num+",单价:"+item[c].goods_price+",合计:"+item[c].goods_num * item[c].goods_price+",商品:"+item[c].goods_name);
2517 2617 tfeel += item[c].goods_num * item[c].goods_price;
  2618 + console.log("累计:"+tfeel);
2518 2619 }
2519 2620 t_num += item[c].goods_num;
2520 2621 }
... ... @@ -2546,11 +2647,11 @@ Page({
2546 2647 [txt]: Number(is_s_sele)
2547 2648 });
2548 2649  
2549   - var txt1 = "requestData[" + a + "].show_can_cx";
2550   - var txt_g = "requestData[" + a + "].goods";
  2650 + var txt1 = "requestData[" + a + "].show_can_cx1";
  2651 + //-- 赋值不渲染 ,只后台计算 --
  2652 + th.data.requestData[a].show_can_cx=show_can_cx;
2551 2653 th.setData({
2552   - [txt1]: show_can_cx,
2553   - [txt_g]:item
  2654 + [txt1]: show_can_cx1,
2554 2655 });
2555 2656  
2556 2657 //-- var et={show_can_cx:show_can_cx};
... ... @@ -2859,7 +2960,7 @@ Page({
2859 2960 //-- 这个函数在计算的时候,要包含限购的那一部分 --
2860 2961 async normal_check(t, item, pitem, store_count, limit, goodsinfo, wareIds) {
2861 2962  
2862   - var cx_arr = await getApp().get_has_cx_act(goodsinfo.goods_id);
  2963 + var cx_arr = getApp().get_has_cx_act2(goodsinfo.goodsActinfo);
2863 2964  
2864 2965 var th = this;
2865 2966 // getApp().my_warnning('购买数量超出商品库存', 0, th);
... ... @@ -3386,6 +3487,12 @@ Page({
3386 3487 this.getCardList();
3387 3488 },
3388 3489  
  3490 +
  3491 + clear_checkouting(){
  3492 + wx.hideLoading();
  3493 + this.data.checkouting=0;
  3494 + },
  3495 +
3389 3496 //--------------去结算------------
3390 3497 async checkout() {
3391 3498 if (getApp().is_sp_hao()) {
... ... @@ -3397,13 +3504,24 @@ Page({
3397 3504 return false;
3398 3505 }
3399 3506  
3400   - if (!this.data.total_num || this.data.total_num <= 0) return false;
  3507 + if (!this.data.total_num || this.data.total_num <= 0) {
  3508 + wx.showToast({
  3509 + title: "请选择商品",
  3510 + icon: 'none',
  3511 + duration: 2000
  3512 + });
  3513 + return false;
  3514 + }
3401 3515 if (!this.data.is_load) return false;
3402 3516 if (this.data.up_dating) {
3403 3517 wx.showLoading({
3404 3518 title: "计算中"
3405 3519 })
3406 3520 }
  3521 +
  3522 + if(this.data.checkouting) return false;
  3523 + this.data.checkouting=1;
  3524 +
3407 3525 var garr = this.data.requestData;
3408 3526 var check_is_goods_selected = 0;
3409 3527  
... ... @@ -3498,15 +3616,14 @@ Page({
3498 3616 if(yh_by_map[ky]){
3499 3617 ky_n+=yh_by_map[ky];
3500 3618 }
3501   -
3502 3619 //-- 判断优惠促销活动的商品的限购,can_yh 表示商品满足优惠促销的条件 --
3503 3620 if(i_arr[j].prom_type==3 && fd1.act.goodslimit>0 && i_arr[j].can_yh ){
3504   - var p_can_by=fd1.act.goodslimit-fd1.act.goodslimited;
3505   - if(i_arr[j].goods_num+ky_n>p_can_by){
3506   - getApp().confirmBox(i_arr[j].goods_name + "超出活动限购数量"+fd1.act.goodslimit+"件");
3507   - wx.hideLoading();
3508   - return false;
3509   - }
  3621 + var p_can_by=fd1.act.goodslimit-fd1.act.goodslimited;
  3622 + if(i_arr[j].goods_num+ky_n>p_can_by){
  3623 + getApp().confirmBox(i_arr[j].goods_name + "超出活动限购数量"+fd1.act.goodslimit+"件");
  3624 + wx.hideLoading();
  3625 + return false;
  3626 + }
3510 3627 }
3511 3628 //-- 把购物数量记录到map表中 --
3512 3629 if(!yh_by_map[ky]) yh_by_map[ky]=0;
... ... @@ -3516,10 +3633,8 @@ Page({
3516 3633 }
3517 3634  
3518 3635  
3519   -
3520   -
3521   -
3522 3636 if (i_arr[j].prom_type == 7 && i_arr[j].act && (i_arr[j].act.buy_limit>0 || i_arr[j].act.zh_num>0) ) {
  3637 +
3523 3638 let userbuynum = await this.getUserBuyPromNum(i_arr[j].prom_id);
3524 3639  
3525 3640 if(!zh_buyed_m[i_arr[j].prom_id]) zh_buyed_m[i_arr[j].prom_id]=userbuynum;
... ... @@ -3537,10 +3652,10 @@ Page({
3537 3652 checkArr7.push(i_arr[j])
3538 3653 }else{
3539 3654 if (zh_all_ck[i_arr[j].prom_id]) {
3540   - //相同门店只记录一单
  3655 + //相同门店只记录一单
3541 3656 if(zh_all_ck[i_arr[j].prom_id].indexOf(i)==-1) zh_all_ck[i_arr[j].prom_id].push(i);
3542 3657 } else {
3543   - zh_all_ck[i_arr[j].prom_id] = [i];
  3658 + zh_all_ck[i_arr[j].prom_id] = [i];
3544 3659 }
3545 3660  
3546 3661 }
... ... @@ -3548,7 +3663,7 @@ Page({
3548 3663 //-- 优惠活动次数限制,相同门店的相同prom_id只能算一次 --
3549 3664 if (i_arr[j].prom_type == 3) {
3550 3665 if (checkObj3[i_arr[j].prom_id]) {
3551   - if(checkObj3[i_arr[j].prom_id].indexOf(i)==-1) checkObj3[i_arr[j].prom_id].push(i);
  3666 + if(checkObj3[i_arr[j].prom_id].indexOf(i)==-1) checkObj3[i_arr[j].prom_id].push(i);
3552 3667 } else {
3553 3668 checkObj3[i_arr[j].prom_id] = [i];
3554 3669 }
... ... @@ -3556,11 +3671,11 @@ Page({
3556 3671  
3557 3672 //如果是普通购买的时候。
3558 3673 if(i_arr[j].is_integral_normal || i_arr[j].is_pd_normal ){
3559   - //-- 四大促销 --
3560   - if([3,5,7,10].indexOf(i_arr[j].prom_tyoe)==-1){
3561   - i_arr[j].prom_id=0;
3562   - i_arr[j].prom_type=0;
3563   - }
  3674 + //-- 四大促销 --
  3675 + if([3,5,7,10].indexOf(i_arr[j].prom_tyoe)==-1){
  3676 + i_arr[j].prom_id=0;
  3677 + i_arr[j].prom_type=0;
  3678 + }
3564 3679 }
3565 3680  
3566 3681 //map 的key是不会重复,会覆盖,,
... ... @@ -3589,25 +3704,20 @@ Page({
3589 3704 //glist += i_arr[j].goods_id + ",";
3590 3705  
3591 3706 if(!i_arr[j].is_gift){
3592   - var et= {"prom_type":i_arr[j].prom_type,"prom_id":i_arr[j].prom_id,"goods_id":i_arr[j].goods_id};
3593   - glist.push(et);
  3707 + var et= {"prom_type":i_arr[j].prom_type,"prom_id":i_arr[j].prom_id,"goods_id":i_arr[j].goods_id};
  3708 + glist.push(et);
3594 3709 }
3595 3710 ab = 1;
3596 3711  
3597 3712 //-- 获取促销活动是不是有参与 --
3598   - var act = await getApp().get_has_cx_act(i_arr[j].goods_id);
  3713 + var act = getApp().get_has_cx_act2(i_arr[j].goodsActinfo);
3599 3714 //-- 判断商品的起订数量 --
3600 3715 var mo_num = getApp().get_limit_qty(i_arr[j], act.length);
3601 3716 var steep = getApp().get_limit_qty(i_arr[j], act.length, 1);
3602 3717 var py_type = parseInt(i_arr[j].prom_type + '');
3603 3718  
3604   - //商品只查一次。看一下有没有
3605   - var gd = null;
3606   - //获取商品信息,包含线下商品ID,指定门店销售的信息
3607   - await getApp().request.promiseGet("/api/weshop/goods/get/" + oo.stoid + "/" + i_arr[j].goods_id, {}).then(res => {
3608   - if (res.data.code == 0) gd = res.data.data;
3609   - })
3610   -
  3719 + //-- 商品只查一次。看一下有没有,门店之前第一次就赋值了 --
  3720 + var gd = i_arr[j];
3611 3721 //判断秒杀的指定门店和团购的指定门店
3612 3722 if([1,2].indexOf(py_type)>-1 && i_arr[j].prom && i_arr[j].prom.pick_up_lists){
3613 3723 var idx0=i_arr[j].prom.pick_up_lists.findIndex(function (e){
... ... @@ -3620,7 +3730,7 @@ Page({
3620 3730 if(py_type==2) act_type='团购';
3621 3731  
3622 3732 getApp().confirmBox(i_arr[j].goods_name + act_type+"活动的门店不可售");
3623   - wx.hideLoading();
  3733 + th.clear_checkouting();
3624 3734 return false;
3625 3735 }
3626 3736 }
... ... @@ -3628,19 +3738,19 @@ Page({
3628 3738 if ([0, 3, 5, 7, 10].indexOf(py_type) > -1) {
3629 3739 //如果是指定门店,就要判断
3630 3740 if(gd.pick_group_ids){
3631   - var idx0=gd.pick_up_lists.findIndex(function (e){
3632   - return e.pickup_id==i_arr[j].pick_id;
3633   - })
3634   - if(idx0<0){
3635   - getApp().confirmBox(i_arr[j].goods_name + "的门店不可售");
3636   - wx.hideLoading();
3637   - return false;
3638   - }
  3741 + var idx0=gd.pick_up_lists.findIndex(function (e){
  3742 + return e.pickup_id==i_arr[j].pick_id;
  3743 + })
  3744 + if(idx0<0){
  3745 + getApp().confirmBox(i_arr[j].goods_name + "的门店不可售");
  3746 + th.clear_checkouting();
  3747 + return false;
  3748 + }
3639 3749 }
3640 3750  
3641 3751 if (mo_num > i_arr[j].goods_num) {
3642 3752 getApp().confirmBox(i_arr[j].goods_name + "的未达到起订数量");
3643   - wx.hideLoading();
  3753 + th.clear_checkouting();
3644 3754 return false;
3645 3755 }
3646 3756 if (steep > 1 && (i_arr[j].goods_num - mo_num) % steep != 0) {
... ... @@ -3655,7 +3765,7 @@ Page({
3655 3765  
3656 3766 th.postCardList(e, j, i);
3657 3767  
3658   - wx.hideLoading();
  3768 + th.clear_checkouting();
3659 3769 return false;
3660 3770 }
3661 3771  
... ... @@ -3672,7 +3782,7 @@ Page({
3672 3782 });
3673 3783 if (ob.code == -1) {
3674 3784 t.my_warnning(gd.goods_name + "门店库存不足", 0, th);
3675   - wx.hideLoading();
  3785 + th.clear_checkouting();
3676 3786 return false;
3677 3787 }
3678 3788  
... ... @@ -3685,7 +3795,7 @@ Page({
3685 3795 if (res.data.code == 0) {
3686 3796 if (!res.data.data.promGoodsLists) {
3687 3797 t.my_warnning(i_arr[j].goods_name + "优惠活动已经过期", 0, th);
3688   - wx.hideLoading();
  3798 + th.clear_checkouting();
3689 3799 is_ok = 0;
3690 3800 }
3691 3801 }
... ... @@ -3698,20 +3808,21 @@ Page({
3698 3808  
3699 3809 } else {
3700 3810 if (i_arr[j].is_gift == 1) continue;
3701   - rq.put("/api/weshop/cart/update", {
3702   - data: {
3703   - id: i_arr[j].id,
3704   - selected: 0,
3705   - store_id: oo.stoid
3706   - },
3707   - success: function (ee) {
3708   - console.log(ee);
3709   - }
3710   - });
  3811 + // rq.put("/api/weshop/cart/update", {
  3812 + // data: {
  3813 + // id: i_arr[j].id,
  3814 + // selected: 0,
  3815 + // store_id: oo.stoid
  3816 + // },
  3817 + // success: function (ee) {
  3818 + // console.log(ee);
  3819 + // }
  3820 + // });
3711 3821 }
3712 3822 }
3713 3823 }
3714 3824  
  3825 +
3715 3826 console.log(checkObj3);
3716 3827 let checkObj3_off = false
3717 3828  
... ... @@ -3761,7 +3872,7 @@ Page({
3761 3872  
3762 3873 if (checkObj3_off) {
3763 3874 t.my_warnning("已超出优惠促销次数", 0, th);
3764   - wx.hideLoading();
  3875 + th.clear_checkouting();
3765 3876 return false
3766 3877 }
3767 3878  
... ... @@ -3770,23 +3881,23 @@ Page({
3770 3881 let zh_ck_arr = Object.keys(zh_limit_m);
3771 3882 if(zh_ck_arr && zh_ck_arr.length ){
3772 3883 for (let xg = 0; xg < zh_ck_arr.length; xg++) {
3773   - var ky=zh_ck_arr[xg];
3774   - var zh_buyed=zh_buyed_m[ky]?zh_buyed_m[ky]:0;
3775   - var zh_limit=zh_limit_m[ky]?zh_limit_m[ky]:0;
3776   - var zh_all=zh_all_ck[ky]?zh_all_ck[ky].length:0;
3777   - if(zh_limit<=0) continue;
3778   -
3779   - if(zh_all+zh_buyed>zh_limit){
3780   - zh_off=true;
3781   - break;
3782   - }
  3884 + var ky=zh_ck_arr[xg];
  3885 + var zh_buyed=zh_buyed_m[ky]?zh_buyed_m[ky]:0;
  3886 + var zh_limit=zh_limit_m[ky]?zh_limit_m[ky]:0;
  3887 + var zh_all=zh_all_ck[ky]?zh_all_ck[ky].length:0;
  3888 + if(zh_limit<=0) continue;
  3889 +
  3890 + if(zh_all+zh_buyed>zh_limit){
  3891 + zh_off=true;
  3892 + break;
  3893 + }
3783 3894 }
3784 3895 }
3785 3896  
3786 3897 if (zh_off) {
3787   - t.my_warnning("已超出组合购优惠次数", 0, th);
3788   - wx.hideLoading();
3789   - return false
  3898 + t.my_warnning("已超出组合购优惠次数", 0, th);
  3899 + th.clear_checkouting();
  3900 + return false
3790 3901 }
3791 3902  
3792 3903  
... ... @@ -3839,7 +3950,7 @@ Page({
3839 3950 })
3840 3951 if (ab == 0) {
3841 3952 t.my_warnning("未选择商品", 0, th);
3842   - wx.hideLoading();
  3953 + th.clear_checkouting();
3843 3954 return false;
3844 3955 }
3845 3956  
... ... @@ -3848,7 +3959,7 @@ Page({
3848 3959  
3849 3960  
3850 3961 } else if (res.cancel) {
3851   - wx.hideLoading();
  3962 + th.clear_checkouting();
3852 3963 console.log('用户点击取消')
3853 3964 }
3854 3965 }
... ... @@ -3871,7 +3982,7 @@ Page({
3871 3982 })
3872 3983 if (ab == 0) {
3873 3984 t.my_warnning("未选择商品", 0, th);
3874   - wx.hideLoading();
  3985 + th.clear_checkouting();
3875 3986 return false;
3876 3987 }
3877 3988  
... ... @@ -3903,7 +4014,7 @@ Page({
3903 4014 })
3904 4015 if(idx0<0){
3905 4016 getApp().confirmBox(i_arr[j].service_name + "秒杀活动的门店不可售");
3906   - wx.hideLoading();
  4017 + th.clear_checkouting();
3907 4018 return false;
3908 4019 }
3909 4020 }
... ... @@ -3923,8 +4034,6 @@ Page({
3923 4034 }
3924 4035 })
3925 4036  
3926   -
3927   - wx.hideLoading();
3928 4037 getApp().goto("/packageA/pages/cart2_ser/cart2_ser?is_cart=1");
3929 4038 }
3930 4039 },
... ... @@ -3933,6 +4042,7 @@ Page({
3933 4042 cart_buy_next(glist,map,g_arr,checkArr7){
3934 4043 var th=this;
3935 4044 var map_limit = new Map(); //使用map值键进行存储限购
  4045 + var up_cart_data=[];
3936 4046 //--取一下商品的限购 以及活动的限购,redis数量--
3937 4047 getApp().request.promisePost("/api/weshop/goods/listGoodsListNumNew", {
3938 4048 is_json:1,
... ... @@ -3941,182 +4051,166 @@ Page({
3941 4051 store_id: oo.stoid
3942 4052 }
3943 4053 }).then(async ee=>{
3944   - if (ee.data.code == 0) {
3945   - var ddata = ee.data.data,
3946   - isok = 1,
3947   - gname = "",
3948   - err = "";
3949   - //--组装--
3950   - for (var ij = 0; ij < ddata.length; ij++) {
3951   - var val = ddata[ij];
3952   -
3953   - var ky=val.goods_id + "-"+val.prom_type + "-"+val.prom_id;
3954   - var obj = map_limit.get(ky);
3955   - if (obj) continue;
3956   -
3957   - var promgoodsbuynum = 0;
3958   - var goodsbuynum = 0;
3959   -
3960   - //--要获得商品,该用户买了多少件,同步应用--
3961   - await getApp().request.promiseGet("/api/weshop/ordergoods/getUserBuyGoodsNum", {
3962   - data: {
3963   - store_id: oo.stoid,
3964   - user_id:getApp().globalData.user_id,
3965   - goods_id: val.goods_id,
3966   - prom_type: val.prom_type,
3967   - prom_id: val.prom_id,
3968   - isnew:1
3969   - },
3970   - }).then(res => {
3971   - var buy_num_data = res.data.data;
3972   - if (buy_num_data.promgoodsbuynum) promgoodsbuynum = buy_num_data.promgoodsbuynum;
3973   - goodsbuynum = buy_num_data.goodsbuynum;
3974   - })
3975   - var ie = {
3976   - promgoodsbuynum: promgoodsbuynum,
3977   - goodsbuynum: goodsbuynum
3978   - };
3979   - map_limit.set(ky, ie);
  4054 + if (ee.data.code == 0 && ee.data.data && ee.data.data.length) {
  4055 + var ddata = ee.data.data,
  4056 + isok = 1,
  4057 + gname = "",
  4058 + err = "";
  4059 + //--组装--
  4060 + for (var ij = 0; ij < ddata.length; ij++) {
  4061 + var val = ddata[ij];
  4062 +
  4063 + var ky=val.goods_id + "-"+val.prom_type + "-"+val.prom_id;
  4064 + var obj = map_limit.get(ky);
  4065 + if (obj) continue;
  4066 +
  4067 + var promgoodsbuynum =val.promgoodsbuynum || 0;
  4068 + var goodsbuynum =val.goodsbuynum || 0;
  4069 +
  4070 + var ie = {
  4071 + promgoodsbuynum: promgoodsbuynum,
  4072 + goodsbuynum: goodsbuynum
  4073 + };
  4074 + map_limit.set(ky, ie);
  4075 + }
  4076 +
  4077 + //try {
  4078 + for (var ind in ddata) {
  4079 + var val = ddata[ind];
  4080 + var num = map.get(val.goods_id + "");
  4081 +
  4082 + var ky=val.goods_id + "-"+val.prom_type + "-"+val.prom_id;
  4083 + var buyed = map_limit.get(ky);
  4084 +
  4085 + if (num <= 0) {
  4086 + isok = 0;
  4087 + gname = val.goods_name;
  4088 + err= "购买数量不能为0";
  4089 + return false;
3980 4090 }
3981 4091  
3982   - //try {
3983   - for (var ind in ddata) {
3984   - var val = ddata[ind];
3985   - var num = map.get(val.goods_id + "");
  4092 + if (val.prom_type == 1 || val.prom_type == 2) {
3986 4093  
3987   - var ky=val.goods_id + "-"+val.prom_type + "-"+val.prom_id;
3988   - var buyed = map_limit.get(ky);
  4094 + var s_num=num;
  4095 + if(th.data.sales_rules> 1) s_num=buyed;
  4096 + if (s_num > val.store_count) {
  4097 + isok = 0;
  4098 + gname = val.goods_name;
  4099 + err="超出库存";
  4100 + return false;
  4101 + }
3989 4102  
3990   - if (num <= 0) {
3991   - isok = 0;
3992   - gname = val.goods_name;
3993   - throw "购买数量不能为0";
3994   - return false;
3995   - }
  4103 + if (buyed > val.redisnum && val.redisnum) {
  4104 + isok = 0;
  4105 + gname = val.goods_name;
  4106 + err="超出活动库存";
  4107 + break;
  4108 + }
  4109 + if (buyed > val.goods_num - val.buy_num && val.goods_num) {
  4110 + isok = 0;
  4111 + gname = val.goods_name;
  4112 + err="超出活动库存";
  4113 + break;
  4114 + }
  4115 + }
3996 4116  
3997   - if (val.prom_type == 1 || val.prom_type == 2) {
  4117 + if (th.data.sales_rules == 1) {
  4118 + if (num > val.store_count) {
  4119 + isok = 0;
  4120 + gname = val.goods_name;
  4121 + err="超出库存";
  4122 + break;
  4123 + }
  4124 + }
3998 4125  
3999   - var s_num=num;
4000   - if(th.data.sales_rules> 1) s_num=buyed;
4001   - if (s_num > val.store_count) {
4002   - isok = 0;
4003   - gname = val.goods_name;
4004   - throw "超出库存";
4005   - return false;
4006   - }
  4126 + if (num + buyed.goodsbuynum > val.viplimited && val.viplimited > 0) {
  4127 + isok = 0;
  4128 + gname = val.goods_name;
  4129 + err="超出商品限购";
  4130 + break;
  4131 + }
4007 4132  
4008   - if (buyed > val.redisnum && val.redisnum) {
4009   - isok = 0;
4010   - gname = val.goods_name;
4011   - err="超出活动库存";
4012   - break;
4013   - }
4014   - if (buyed > val.goods_num - val.buy_num && val.goods_num) {
4015   - isok = 0;
4016   - gname = val.goods_name;
4017   - err="超出活动库存";
4018   - break;
4019   - }
  4133 + if (num + buyed.promgoodsbuynum > val.buy_limit && val.buy_limit > 0) {
  4134 + isok = 0;
  4135 + gname = val.goods_name;
  4136 + err="超出活动限购";
  4137 + break;
  4138 + }
4020 4139  
4021   - }
  4140 + var card_field = th.data.card_field;
  4141 + for (var i = 0; i < g_arr.length; i++) {
  4142 + if (g_arr[i].goods_id == val.goods_id) {
4022 4143  
4023   - if (th.data.sales_rules == 1) {
4024   - if (num > val.store_count) {
  4144 + //如果会员是等级会员,商品有等级价,且不是活动商品
  4145 + if (card_field && val[card_field] > 0 &&
  4146 + ((val.prom_type == 0 && g_arr[i].prom_type == 0) || g_arr[i].prom_type == 5 || g_arr[i].prom_type == 7 || g_arr[i].prom_type == 10)) {
  4147 + if (g_arr[i].goods_price != val[card_field]) {
4025 4148 isok = 0;
4026 4149 gname = val.goods_name;
4027   - err="超出库存";
  4150 + err="商品价格已经变化";
  4151 + break;
  4152 + }
  4153 + } else {
  4154 + if (g_arr[i].goods_price != val.shop_price && g_arr[i].goods_price != val.prom_price && val.prom_price > 0) {
  4155 + isok = 0;
  4156 + gname = val.goods_name;
  4157 + err="商品价格已经变化";
4028 4158 break;
4029 4159 }
4030 4160 }
4031 4161  
  4162 + //-- 数据的更新 --
  4163 + var data = {
  4164 + id: g_arr[i].id,
  4165 + selected: 1,
  4166 + store_id: oo.stoid,
  4167 + prom_type: g_arr[i].prom_type,
  4168 + prom_id: g_arr[i].prom_id,
  4169 + };
4032 4170  
  4171 + // let gitem = checkArr7.find(item => item.goods_id == g_arr[i].goods_id)
  4172 + // if (gitem) {
  4173 + // data.prom_type = 0
  4174 + // data.prom_id = 0
  4175 + // }
4033 4176  
4034   - if (num + buyed.goodsbuynum > val.viplimited && val.viplimited > 0) {
4035   - isok = 0;
4036   - gname = val.goods_name;
4037   - err="超出商品限购";
4038   - break;
4039   - }
4040   -
4041   - if (num + buyed.promgoodsbuynum > val.buy_limit && val.buy_limit > 0) {
4042   - isok = 0;
4043   - gname = val.goods_name;
4044   - err="超出活动限购";
4045   - break;
4046   - }
4047   -
4048   - var card_field = th.data.card_field;
4049   - for (var i = 0; i < g_arr.length; i++) {
4050   - if (g_arr[i].goods_id == val.goods_id) {
4051   -
4052   - //如果会员是等级会员,商品有等级价,且不是活动商品
4053   - if (card_field && val[card_field] > 0 &&
4054   - ((val.prom_type == 0 && g_arr[i].prom_type == 0) || g_arr[i].prom_type == 5 || g_arr[i].prom_type == 7 || g_arr[i].prom_type == 10)) {
4055   - if (g_arr[i].goods_price != val[card_field]) {
4056   - isok = 0;
4057   - gname = val.goods_name;
4058   - err="商品价格已经变化";
4059   - break;
4060   - }
4061   - } else {
4062   - if (g_arr[i].goods_price != val.shop_price && g_arr[i].goods_price != val.prom_price && val.prom_price > 0) {
4063   - isok = 0;
4064   - gname = val.goods_name;
4065   - err="商品价格已经变化";
4066   - break;
4067   - }
4068   - }
4069   -
4070   - //-- 数据的更新 --
4071   - var data = {
4072   - id: g_arr[i].id,
4073   - selected: 1,
4074   - store_id: oo.stoid,
4075   - prom_type: g_arr[i].prom_type,
4076   - prom_id: g_arr[i].prom_id,
4077   - };
4078   -
4079   - // let gitem = checkArr7.find(item => item.goods_id == g_arr[i].goods_id)
4080   - // if (gitem) {
4081   - // data.prom_type = 0
4082   - // data.prom_id = 0
4083   - // }
4084   -
4085   - //-- 如果有线下取价的时候 --
4086   - if (g_arr[i].is_offline) {
4087   - data.pricing_type = g_arr[i].pricing_type;
4088   - data.offline_price = g_arr[i].offline_price;
4089   - }
4090   - rq.put("/api/weshop/cart/update", {
4091   - data: data,
4092   - success: function (ee) {
4093   - console.log(ee);
4094   - }
4095   - });
4096   - }
  4177 + //-- 如果有线下取价的时候 --
  4178 + if (g_arr[i].is_offline) {
  4179 + data.pricing_type = g_arr[i].pricing_type;
  4180 + data.offline_price = g_arr[i].offline_price;
4097 4181 }
4098   -
4099   - if(!isok) break;
  4182 + //把更新数组存起来
  4183 + up_cart_data.push(data);
4100 4184  
4101 4185 }
4102   - // } catch (e) {
4103   - // err = e;
4104   - // }
4105   - if (isok == 0) {
4106   - t.confirmBox(gname + ":" + err);
4107   - wx.hideLoading();
4108   - return false;
4109 4186 }
4110 4187  
  4188 + if(!isok) break;
4111 4189  
4112   - wx.hideLoading();
4113   - wx.navigateTo({
4114   - url: "/packageE/pages/cart/cart2/cart2"
4115   - });
4116 4190 }
  4191 + // } catch (e) {
  4192 + // err = e;
  4193 + // }
  4194 + if (isok == 0) {
  4195 + t.confirmBox(gname + ":" + err);
  4196 + th.clear_checkouting();
  4197 + return false;
  4198 + }
  4199 +
  4200 + getApp().request.promisePost("/api/weshop/cart/updateCartPromInfo", {
  4201 + is_json: 1,
  4202 + data: up_cart_data,
  4203 + });
  4204 +
  4205 + wx.navigateTo({
  4206 + url: "/packageE/pages/cart/cart2/cart2"
  4207 + });
  4208 + }
4117 4209 })
4118 4210 },
4119 4211  
  4212 +
  4213 +
4120 4214 //结算到最后一个商品
4121 4215 set_last: function (ab, isok, gname) {
4122 4216 if (isok == 0) {
... ... @@ -4312,10 +4406,15 @@ Page({
4312 4406  
4313 4407 //-- 所有的购物车的数据,要用拷贝的赖进行计算 --
4314 4408 var alllist = JSON.parse(JSON.stringify(this.data.requestData));
4315   - var list2 = alllist[cindex];
  4409 + //var list2 = alllist[cindex];
4316 4410 var no_gift_arr = [];
4317 4411  
4318   -
  4412 + //用来存销赠品的--2024-2-1
  4413 + let cart_zp=this.data.cart_zp;
  4414 + //要清空一下门店下的赠品
  4415 + if(cart_zp[list.pid]){
  4416 + cart_zp[list.pid]={};
  4417 + }
4319 4418 //主要判断有没有促销活动
4320 4419 var is_sele_prom = 0;
4321 4420 var is_gift_del = 0;
... ... @@ -4343,17 +4442,24 @@ Page({
4343 4442 map.set(item.prom_id + "", ob);
4344 4443 }
4345 4444 }
4346   - if (item.is_gift == 1) {
4347   - var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id;
4348   - //getApp().request.delete(url, {});
4349   - await getApp().request.promiseDelete(url, {}) // 要用同步让赠品删除
4350   - list2.goods.splice(i, 1);
4351   - list.goods.splice(i--, 1);
4352   - is_gift_del = 1;
4353   - }
  4445 + //-- list中不再添加和删除赠品,优化list不再添加赠品,2024-02-01 --
  4446 + // if (item.is_gift == 1) {
  4447 + // var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id;
  4448 + // //getApp().request.delete(url, {});
  4449 + // await getApp().request.promiseDelete(url, {}) // 要用同步让赠品删除
  4450 + // list2.goods.splice(i, 1);
  4451 + // list.goods.splice(i--, 1);
  4452 + // is_gift_del = 1;
  4453 + // }
4354 4454 }
4355 4455 //--如果没有选中的促销活动的,直接退出 --
4356 4456 if (!is_sele_prom) {
  4457 +
  4458 + //--- 设置单赠品的显示---2024-2-1
  4459 + this.setData({
  4460 + cart_zp
  4461 + })
  4462 +
4357 4463 //如果有赠品,要重新更新购物车的前台渲染--
4358 4464 if (is_gift_del) {
4359 4465 var rq_text = "requestData[" + cindex + "]";
... ... @@ -4374,6 +4480,10 @@ Page({
4374 4480  
4375 4481 return false;
4376 4482 }
  4483 +
  4484 +
  4485 + //用来判断有没有list大小发生变化
  4486 + let is_change_list=0;
4377 4487 //-- 循环判断活动 --
4378 4488 for (let p_item of map.entries()) {
4379 4489 var prom = null;
... ... @@ -4398,12 +4508,15 @@ Page({
4398 4508 //如果活动已经结束
4399 4509 if (!prom || prom.is_end || prom.end_time < ut.gettimestamp()) {
4400 4510 for (var ii in list.goods) {
4401   - var item = list.goods[ii];
4402   - list.goods.splice(ii, 1);
  4511 +
4403 4512 if (item.prom_id == p_item[0] && item.prom_type == 3) {
4404 4513 // var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id;
4405 4514 // getApp().request.delete(url, {});
4406 4515 th.disInvalid(item);
  4516 +
  4517 + var item = list.goods[ii];
  4518 + list.goods.splice(ii, 1);
  4519 + is_change_list=1;
4407 4520 }
4408 4521 }
4409 4522 continue;
... ... @@ -4479,7 +4592,7 @@ Page({
4479 4592  
4480 4593 if (discount) {
4481 4594 if (!discount.zp_num || parseInt(discount.zp_num) == 0) discount.zp_num = 1;
4482   - //判断一下赠品的模式
  4595 + //判断一下赠品的模式,如果是多赠品的时候
4483 4596 if (parseInt(discount.zp_mode) == 1) {
4484 4597  
4485 4598 var can_zp_num = 0;
... ... @@ -4514,7 +4627,7 @@ Page({
4514 4627 } else {
4515 4628 //---如果有打折的信息,赠送的信息,赠送的时候要判断是不是限购数量---
4516 4629 if (discount && discount['goods_id'] && (!discount.limit_num || discount.limit_num >= discount.bs * discount.zp_num) &&
4517   - discount.gift_storecount >= discount.bs * discount.zp_num) {
  4630 + discount.gift_storecount >= discount.bs * discount.zp_num) {
4518 4631 //如果这礼品超了情况下
4519 4632 if (no_gift_arr.indexOf(discount.gift_id) != -1) continue;
4520 4633 var o = discount.goodsinfo;
... ... @@ -4541,7 +4654,7 @@ Page({
4541 4654 original_img: th.data.imgUrl + o.original_img
4542 4655 };
4543 4656  
4544   - list2.goods.push(newd);
  4657 + //list2.goods.push(newd);
4545 4658 var all_num = 0;
4546 4659 var all_limit_num = 0;
4547 4660  
... ... @@ -4568,7 +4681,7 @@ Page({
4568 4681 }
4569 4682  
4570 4683 var url = "/api/weshop/cart/delGift?store_id=" + newd.store_id + "&user_id=" +
4571   - newd.user_id + "&goods_id=" + newd.goods_id + "&is_gift=1&pick_id=" + newd.pick_id + "&prom_id=" + newd.prom_id
  4684 + newd.user_id + "&goods_id=" + newd.goods_id + "&is_gift=1&pick_id=" + newd.pick_id + "&prom_id=" + newd.prom_id
4572 4685 await getApp().request.promiseDelete(url, {})
4573 4686  
4574 4687 var add_data = null;
... ... @@ -4581,18 +4694,30 @@ Page({
4581 4694 })
4582 4695 if (add_data) {
4583 4696 newd.id = add_data.id;
4584   - list.goods.push(newd);
  4697 + //list.goods.push(newd);
  4698 + if(!cart_zp[list.pid]) cart_zp[list.pid]={};
  4699 + if(!cart_zp[list.pid].goods) cart_zp[list.pid].goods=[];
  4700 + cart_zp[list.pid].goods.push(newd);
4585 4701 }
4586 4702 }
4587 4703 }
4588 4704 }
4589 4705  
4590 4706 }
4591   - //--更新购物车的前台渲染--
4592   - var rq_text = "requestData[" + cindex + "]";
  4707 +
  4708 + //--- 设置单赠品的显示---2024-2-1
4593 4709 this.setData({
4594   - [rq_text]: list
4595   - });
  4710 + cart_zp
  4711 + })
  4712 +
  4713 + //list大小有变换,才会渲染list
  4714 + if(is_change_list) {
  4715 + //--更新购物车的前台渲染--
  4716 + var rq_text = "requestData[" + cindex + "]";
  4717 + this.setData({
  4718 + [rq_text]: list
  4719 + });
  4720 + }
4596 4721  
4597 4722 var diff_text = "requestData[" + cindex + "].make_up_arr";
4598 4723 //-- 如果有凑单的话 --
... ... @@ -4620,6 +4745,8 @@ Page({
4620 4745  
4621 4746 },
4622 4747  
  4748 +
  4749 +
4623 4750 //优惠促销用户参与次数
4624 4751 async getUserBuyPromNum_pre(prom_id) {
4625 4752 var userInfo = getApp().globalData.userInfo;
... ... @@ -4634,6 +4761,7 @@ Page({
4634 4761 return user_pre_buynum
4635 4762 },
4636 4763  
  4764 +
4637 4765 async all_check_prom_activity() {
4638 4766 this.data.duo_zp_num_arr = {};
4639 4767 for (var i in this.data.requestData) {
... ... @@ -4647,9 +4775,14 @@ Page({
4647 4775  
4648 4776 //-- 所有的购物车的数据,要用拷贝的赖进行计算 --
4649 4777 var alllist = JSON.parse(JSON.stringify(this.data.requestData));
4650   - var list2 = alllist[cindex];
  4778 + //var list2 = alllist[cindex];
  4779 +
4651 4780 var no_gift_arr = [];
4652 4781  
  4782 + //用来存销赠品的--2024-2-1
  4783 + let cart_zp=this.data.cart_zp;
  4784 + //要清空一下赠品数组
  4785 + cart_zp={};
4653 4786  
4654 4787 //主要判断有没有促销活动
4655 4788 var is_sele_prom = 0;
... ... @@ -4677,25 +4810,30 @@ Page({
4677 4810 map.set(item.prom_id + "", ob);
4678 4811 }
4679 4812 }
4680   - if (item.is_gift == 1) {
4681   - var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id;
4682   - //getApp().request.delete(url, {});
4683   - await getApp().request.promiseDelete(url, {}) // 要用同步让赠品删除
4684   - list2.goods.splice(i, 1);
4685   - list.goods.splice(i--, 1);
4686   - is_gift_del = 1;
4687   - }
  4813 +
  4814 + //-- list中不再添加和删除赠品,优化list不再添加赠品,2024-02-01 --
  4815 + // if (item.is_gift == 1) {
  4816 + // var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id;
  4817 + // //getApp().request.delete(url, {});
  4818 + // await getApp().request.promiseDelete(url, {}) // 要用同步让赠品删除
  4819 + // list2.goods.splice(i, 1);
  4820 + // list.goods.splice(i--, 1);
  4821 + // is_gift_del = 1;
  4822 + // }
4688 4823 }
4689 4824 //--如果没有选中的促销活动的,直接退出 --
4690 4825 if (!is_sele_prom) {
4691   - //如果有赠品,要重新更新购物车的前台渲染--
4692   - if (is_gift_del) {
4693   - var rq_text = "requestData[" + cindex + "]";
4694   - this.setData({
4695   - [rq_text]: list
4696   - });
4697   - }
4698   -
  4826 + //如果有赠品,要重新更新购物车的前台渲,list中不再显示--
  4827 + // if (is_gift_del) {
  4828 + // var rq_text = "requestData[" + cindex + "]";
  4829 + // this.setData({
  4830 + // [rq_text]: list
  4831 + // });
  4832 + // }
  4833 + //--- 设置单赠品的显示---2024-2-1
  4834 + this.setData({
  4835 + cart_zp
  4836 + })
4699 4837 var rq_text2 = "requestData[" + cindex + "].make_up_arr";
4700 4838 this.setData({
4701 4839 [rq_text2]: null,
... ... @@ -4707,6 +4845,9 @@ Page({
4707 4845 })
4708 4846 continue;
4709 4847 }
  4848 +
  4849 + //用来判断有没有list大小发生变化
  4850 + let is_change_list=0;
4710 4851 //-- 循环判断活动 --
4711 4852 for (let p_item of map.entries()) {
4712 4853 var prom = null;
... ... @@ -4728,13 +4869,17 @@ Page({
4728 4869 }
4729 4870 //如果活动已经结束
4730 4871 if (!prom || prom.is_end || prom.end_time < ut.gettimestamp()) {
  4872 +
4731 4873 for (var ii in list.goods) {
4732   - var item = list.goods[ii];
4733   - list.goods.splice(ii, 1);
  4874 +
4734 4875 if (item.prom_id == p_item[0] && item.prom_type == 3) {
4735 4876 // var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id;
4736 4877 // getApp().request.delete(url, {});
4737 4878 th.disInvalid(item);
  4879 +
  4880 + var item = list.goods[ii];
  4881 + list.goods.splice(ii, 1);
  4882 + is_change_list=1;
4738 4883 }
4739 4884 }
4740 4885 continue;
... ... @@ -4792,8 +4937,6 @@ Page({
4792 4937 }
4793 4938 }
4794 4939  
4795   -
4796   -
4797 4940 //-- 只有在单赠品的时候,才要进行计算 --
4798 4941 await getApp().request.promiseGet("/api/weshop/goods/getDiscount", {
4799 4942 data: {
... ... @@ -4810,7 +4953,7 @@ Page({
4810 4953 if (discount) {
4811 4954  
4812 4955 if (!discount.zp_num || parseInt(discount.zp_num) == 0) discount.zp_num = 1;
4813   - //判断一下赠品的模式
  4956 + //-- 判断一下赠品的模式,如果是多赠品的模式 --
4814 4957 if (parseInt(discount.zp_mode) == 1) {
4815 4958  
4816 4959 var can_zp_num = 0;
... ... @@ -4843,7 +4986,7 @@ Page({
4843 4986 } else {
4844 4987 //---如果有打折的信息,赠送的信息,赠送的时候要判断是不是限购数量,因为增加了限购数量不限的情况---
4845 4988 if (discount && discount['goods_id'] && (!discount.limit_num || discount.limit_num >= discount.bs * discount.zp_num) &&
4846   - discount.gift_storecount >= discount.bs * discount.zp_num) {
  4989 + discount.gift_storecount >= discount.bs * discount.zp_num) {
4847 4990 //如果这礼品超了情况下
4848 4991 if (no_gift_arr.indexOf(discount.gift_id) != -1) continue;
4849 4992 var o = discount.goodsinfo;
... ... @@ -4870,7 +5013,7 @@ Page({
4870 5013 original_img: th.data.imgUrl + o.original_img
4871 5014 };
4872 5015  
4873   - list2.goods.push(newd);
  5016 + //list2.goods.push(newd);
4874 5017 var all_num = 0;
4875 5018 var all_limit_num = 0;
4876 5019  
... ... @@ -4888,7 +5031,6 @@ Page({
4888 5031  
4889 5032 }
4890 5033 }
4891   -
4892 5034 //-- 赠品的数量超出库存数量和会员的限制,这里是保证所有的赠品部会超出 --
4893 5035 if (discount.gift_storecount < all_num + newd.goods_num || (discount.limit_num && discount.limit_num < all_limit_num + newd.goods_num)) {
4894 5036 no_gift_arr.push(discount.gift_id);
... ... @@ -4898,7 +5040,7 @@ Page({
4898 5040  
4899 5041  
4900 5042 var url = "/api/weshop/cart/delGift?store_id=" + newd.store_id + "&user_id=" +
4901   - newd.user_id + "&goods_id=" + newd.goods_id + "&is_gift=1&pick_id=" + newd.pick_id + "&prom_id=" + newd.prom_id
  5043 + newd.user_id + "&goods_id=" + newd.goods_id + "&is_gift=1&pick_id=" + newd.pick_id + "&prom_id=" + newd.prom_id
4902 5044 await getApp().request.promiseDelete(url, {})
4903 5045  
4904 5046 var add_data = null;
... ... @@ -4911,18 +5053,29 @@ Page({
4911 5053 })
4912 5054 if (add_data) {
4913 5055 newd.id = add_data.id;
4914   - list.goods.push(newd);
  5056 + //list.goods.push(newd);
  5057 + if(!cart_zp[list.pid]) cart_zp[list.pid]={};
  5058 + if(!cart_zp[list.pid].goods) cart_zp[list.pid].goods=[];
  5059 + cart_zp[list.pid].goods.push(newd);
4915 5060 }
4916 5061 }
4917 5062 }
4918 5063 }
4919   -
4920 5064 }
4921   - //--更新购物车的前台渲染--
4922   - var rq_text = "requestData[" + cindex + "]";
  5065 +
  5066 + //--- 设置单赠品的显示---2024-2-1
4923 5067 this.setData({
4924   - [rq_text]: list
4925   - });
  5068 + cart_zp
  5069 + })
  5070 +
  5071 + //list大小有变换,才会渲染list
  5072 + if(is_change_list) {
  5073 + //--更新购物车的前台渲染--
  5074 + var rq_text = "requestData[" + cindex + "]";
  5075 + this.setData({
  5076 + [rq_text]: list
  5077 + });
  5078 + }
4926 5079  
4927 5080 var diff_text = "requestData[" + cindex + "].make_up_arr";
4928 5081 //-- 如果有凑单的话 --
... ... @@ -4952,6 +5105,8 @@ Page({
4952 5105 }
4953 5106 },
4954 5107  
  5108 +
  5109 +
4955 5110 //去凑单
4956 5111 go_cou_dang: function (e) {
4957 5112 var prom_id = e.currentTarget.dataset.prom_id;
... ...
pages/cart/cart/cart.wxml
... ... @@ -60,7 +60,7 @@
60 60  
61 61 </view>
62 62  
63   - <block wx:for="{{item.goods}}" wx:for-item="items" wx:for-index="idx" wx:key="{{idx}}">
  63 + <block wx:for="{{item.goods}}" wx:for-item="items" wx:for-index="idx" wx:key="{{idx}}">
64 64 <view class="order-item" data-item="{{idx}}">
65 65 <block wx:if="{{!items.is_gift}}">
66 66 <view bindtap="check_th_item" class="order-raido flex-vertical " data-check="{{items.selected}}" data-item="{{idx}}" data-pitems="{{pidx}}">
... ... @@ -134,7 +134,7 @@
134 134  
135 135 <!-- 验证活动是不是多个,要不要显示切换 -->
136 136 <!-- 新增促销多活动的排版 -->
137   - <block wx:if="{{g_filter.is_more_act(items,item.show_can_cx) && item.show_can_cx[items.goods_id] && item.show_can_cx[items.goods_id].act_arr.length>1}}">
  137 + <block wx:if="{{g_filter.is_more_act(items,item.show_can_cx1) && item.show_can_cx1[items.goods_id] && item.show_can_cx1[items.goods_id].act_arr.length>1}}">
138 138 <view class="bdb16">
139 139 <view bindtap="switch_cx_group"
140 140 data-index="{{pidx}}"
... ... @@ -142,7 +142,7 @@
142 142 class="cx-frame flex" style="position: relative">
143 143 <view class="cx-sizs fs30">可参促销</view>
144 144 <view class="flex ai_c f1 pdh20">
145   - <view class="xc-coupon-fram" wx:for="{{item.show_can_cx[items.goods_id].act_arr}}" >
  145 + <view class="xc-coupon-fram" wx:for="{{item.show_can_cx1[items.goods_id].act_arr}}" >
146 146 <view wx:if="{{item.prom_type==3}}" class="xc-coupon t-c four-level-word {{!item.sele?'gray':'' }}">优惠促销</view>
147 147 <view wx:if="{{item.prom_type==5}}" class="xc-coupon t-c four-level-word {{!item.sele?'gray':'' }} ">搭配促销</view>
148 148 <view wx:if="{{item.prom_type==7}}" class="xc-coupon t-c four-level-word {{!item.sele?'gray':'' }} ">组合购</view>
... ... @@ -159,11 +159,35 @@
159 159  
160 160 </block >
161 161  
  162 + <!-- 判断有没有赠品2024-2-1 -->
  163 + <block wx:if="{{cart_zp[item.pid] && cart_zp[item.pid].goods.length>0 }}">
  164 + <block wx:for="{{cart_zp[item.pid].goods}}" wx:for-item="items" wx:for-index="idx" wx:key="{{idx}}">
  165 + <view class="order-item" data-item="{{idx}}">
  166 + <view class="order-raido flex-vertical " style="width: 45rpx"></view>
  167 + <navigator class="goods-img rel" bindtap="go_gd" data-item="{{items}}" data-gd="{{items.goods_id}}">
  168 + <image class="wh100" src="{{items.original_img}}" binderror="bind_bnerr2" data-errorimg="requestData[{{pidx}}].goods[{{idx}}].original_img" data-url="{{items.original_img}}"></image>
  169 + <view style="background-color:red" class="abs flex-center fs26" wx:if="{{items.is_gift==1}}">赠品</view>
  170 + </navigator>
  171 + <view class="goods-cont">
  172 + <view class="goods-name">
  173 + <navigator bindtap="go_gd" class="ellipsis-2 fs30" data-item="{{items}}" data-gd="{{items.goods_id}}">{{items.goods_name}}</navigator>
  174 +
  175 + <view class="specifications ellipsis-1">
  176 + <view wx:if="{{items.goods_color || items.goods_spec}}">
  177 + {{items.goods_color}}{{items.goods_color?"/":''}}{{items.goods_spec}}</view>
  178 + <view wx:else>规格1</view>
  179 + </view>
  180 + <view>{{items.goods_num}}件</view>
  181 + </view>
  182 + </view>
  183 + </view>
  184 + </block>
  185 + </block>
162 186  
163 187 <!--此时是多个商品参与活动的切换 验证活动是不是多个,要不要显示切换 -->
164 188 <!-- 新增促销多活动的排版 -->
165   - <block wx:if="{{item.show_can_cx}}">
166   - <block wx:for="{{item.show_can_cx}}" wx:for-item="pitem">
  189 + <block wx:if="{{item.show_can_cx1}}">
  190 + <block wx:for="{{item.show_can_cx1}}" wx:for-item="pitem">
167 191 <view class="bdb16" wx:if="{{pitem.is_duo_gd && pitem.act_arr.length>1}}" >
168 192 <view bindtap="switch_cx_group"
169 193 data-index="{{pidx}}"
... ...
utils/more_cx.js
... ... @@ -511,6 +511,10 @@ module.exports = {
511 511 }
512 512 //-- 判断优惠促销要不要限购 --
513 513 var fd=th.data.in_yhact[aid];
  514 + if(!fd && th.data.yhcx_act_map && th.data.yhcx_act_map[aid] ){
  515 + fd=th.data.yhcx_act_map[aid];
  516 + th.data.in_yhact[aid]=fd;
  517 + }
514 518 if(!fd) {
515 519 var fd_res = await getApp().request.promiseGet('/api/weshop/promgoods/get/' + os.stoid + '/' + aid, {})
516 520 if (fd_res && fd_res.data.code == 0) {
... ... @@ -624,9 +628,8 @@ module.exports = {
624 628 zh_goods[h].zh_b_num=promgoodsbuynum;
625 629 th.data.in_zh_gd_buy_map[ky]=promgoodsbuynum;
626 630 }
627   -
628   -
629 631 }
  632 +
630 633 //-- 放到参与组合优惠促销的map中 --
631 634 th.data.zuhe_map_good[item_act_map.prom_id] = zhact_gdlist;
632 635 if(!car_item.zh_prom_goods) car_item.zh_prom_goods={};
... ...