Commit 1bc3602c9638eec88b536e732f3c40a6a3fd5d65

Authored by WXD-SEASON\season
2 parents 3c7855ab a61378e5

Merge branch 'dev_oa_fucart' into dev

@@ -51,7 +51,7 @@ App({ @@ -51,7 +51,7 @@ App({
51 config: null, //门店参数 51 config: null, //门店参数
52 config2: null, //门店配置 52 config2: null, //门店配置
53 code: null, 53 code: null,
54 - user_id:null,//6520491,// 6519913,//6520352 54 + user_id:null, //6520509,//6520491,// 6519913,//6520352
55 // user_id:6520314,// qa-6519858,// 55 // user_id:6520314,// qa-6519858,//
56 // user_id:14148118,// qa-6519858,// 56 // user_id:14148118,// qa-6519858,//
57 buy_now: null, 57 buy_now: null,
@@ -1584,6 +1584,15 @@ App({ @@ -1584,6 +1584,15 @@ App({
1584 return cx_arr; 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 async go_to_page(is_reg,func){ 1597 async go_to_page(is_reg,func){
1589 if(!is_reg) { 1598 if(!is_reg) {
app.json
@@ -243,6 +243,14 @@ @@ -243,6 +243,14 @@
243 } 243 }
244 ], 244 ],
245 245
  246 + "preloadRule": {
  247 + "pages/index/index/index": {
  248 + "network": "all",
  249 + "packages": [
  250 + "pack5"
  251 + ]
  252 + }
  253 + },
246 254
247 "permission": { 255 "permission": {
248 "scope.userLocation": { 256 "scope.userLocation": {
packageE/pages/cart/cart2/cart2.js
@@ -170,7 +170,15 @@ Page({ @@ -170,7 +170,15 @@ Page({
170 showFold:true, 170 showFold:true,
171 171
172 ly_map:{}, 172 ly_map:{},
173 - template_id:[] 173 + template_id:[],
  174 +
  175 + //用于后台计算的多促销集合
  176 + show_can_cx_map:{},
  177 + //优惠促销活动的集合
  178 + yhcx_act_map: {},
  179 +
  180 + //优惠促销购买次数
  181 + yhcx_buy_map:{}
174 }, 182 },
175 183
176 184
@@ -909,7 +917,7 @@ Page({ @@ -909,7 +917,7 @@ Page({
909 var th = this, app = getApp(); 917 var th = this, app = getApp();
910 var state = 0; 918 var state = 0;
911 if (th.data.state) state = 1; 919 if (th.data.state) state = 1;
912 - a.get("/api/weshop/cart/list", { 920 + a.get("/api/weshop/cart/listNew1", {
913 data: { 921 data: {
914 user_id: to.globalData.user_id, selected: 1, state: state, 922 user_id: to.globalData.user_id, selected: 1, state: state,
915 store_id: oo.stoid, pageSize: 600, 923 store_id: oo.stoid, pageSize: 600,
@@ -926,18 +934,18 @@ Page({ @@ -926,18 +934,18 @@ Page({
926 if (pick_id_arr.length == 0 || pick_id_arr.indexOf(carr[i].pick_id) == -1) 934 if (pick_id_arr.length == 0 || pick_id_arr.indexOf(carr[i].pick_id) == -1)
927 pick_id_arr.push(carr[i].pick_id); 935 pick_id_arr.push(carr[i].pick_id);
928 } 936 }
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 - }) 937 + //-- 门店不在获取2024-2-3 --
  938 + // var req_d = {
  939 + // store_id: os.stoid, ids: pick_id_arr.join(',')
  940 + // }
  941 + // //-- 获取门店的列表 --
  942 + // await getApp().request.promiseGet("/api/weshop/pickup/list", { data: req_d }).then(res => {
  943 + // if (ut.ajax_ok(res)) {
  944 + // th.data.allsto = res.data.data.pageData;
  945 + // }
  946 + // })
938 947
939 th.data.cartlist_y =JSON.parse(JSON.stringify(carr)); //存储原始购物车列表 948 th.data.cartlist_y =JSON.parse(JSON.stringify(carr)); //存储原始购物车列表
940 -  
941 wx.showLoading(); 949 wx.showLoading();
942 950
943 th.get_cart_next(carr); 951 th.get_cart_next(carr);
@@ -950,7 +958,7 @@ Page({ @@ -950,7 +958,7 @@ Page({
950 is_last(gid,goods,map){ 958 is_last(gid,goods,map){
951 let last_id=0; 959 let last_id=0;
952 for (let i = 0; i <goods.length ; i++) { 960 for (let i = 0; i <goods.length ; i++) {
953 - if(map.indexOf(goods[i].goods_id)>-1){ 961 + if(map && map.indexOf(goods[i].goods_id)>-1){
954 last_id=goods[i].goods_id; 962 last_id=goods[i].goods_id;
955 } 963 }
956 } 964 }
@@ -958,6 +966,7 @@ Page({ @@ -958,6 +966,7 @@ Page({
958 return false; 966 return false;
959 }, 967 },
960 968
  969 +
961 //-- is_change是有没有切换活动的意思 -- 970 //-- is_change是有没有切换活动的意思 --
962 async get_cart_next(carr,is_change,old_prom){ 971 async get_cart_next(carr,is_change,old_prom){
963 972
@@ -973,7 +982,7 @@ Page({ @@ -973,7 +982,7 @@ Page({
973 982
974 var c_ok=1; 983 var c_ok=1;
975 if(old_prom && (carr[ir].prom_type!=old_prom.prom_type || carr[ir].prom_id!=old_prom.prom_id) ){ 984 if(old_prom && (carr[ir].prom_type!=old_prom.prom_type || carr[ir].prom_id!=old_prom.prom_id) ){
976 - c_ok=0; 985 + c_ok=0;
977 } 986 }
978 987
979 if(carr[ir].is_gift && carr[ir].id && c_ok) { 988 if(carr[ir].is_gift && carr[ir].id && c_ok) {
@@ -995,22 +1004,22 @@ Page({ @@ -995,22 +1004,22 @@ Page({
995 var map=this.data.prom_goods_map; 1004 var map=this.data.prom_goods_map;
996 if(map){ 1005 if(map){
997 for (var ky in map) { 1006 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 - } 1007 + if(map[ky]){
  1008 + var ob=map[ky];
  1009 + for (var ii in ob) {
  1010 + var item_map = ob[ii];
  1011 + if (item_map.hasOwnProperty('cy_cx')) {
  1012 + delete item_map.cy_cx;
  1013 + }
1006 } 1014 }
  1015 + }
1007 } 1016 }
1008 } 1017 }
1009 } 1018 }
1010 1019
1011 //按门店分类的数组 1020 //按门店分类的数组
1012 var arr = new Array(); 1021 var arr = new Array();
1013 - 1022 +
1014 var th=this; 1023 var th=this;
1015 th.data.in_zhact_gdmap = {}; 1024 th.data.in_zhact_gdmap = {};
1016 //---是不是购买等级卡成功的返回---等级卡显示的判断--- 1025 //---是不是购买等级卡成功的返回---等级卡显示的判断---
@@ -1018,40 +1027,40 @@ Page({ @@ -1018,40 +1027,40 @@ Page({
1018 1027
1019 //-- 判断组合购是总数量是不是存在 -- 1028 //-- 判断组合购是总数量是不是存在 --
1020 var no_zh_num={}; 1029 var no_zh_num={};
1021 - 1030 + //-- 多促销活动调用接口需要的参数,和商品的购买数量和活动的购买数量的请求参数 --
  1031 + var dug_cx_arr = [];
  1032 + //获取 限购 和 多活动的促销---2024-2-1
1022 for (var i = 0; i < carr.length; i++) { 1033 for (var i = 0; i < carr.length; i++) {
1023 1034
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; 1035 + let item1 = carr[i];
  1036 + //如果不是活动的时候,不是代发商品的时候,不是赠品的时候,不是阶梯商品拆分的,不是组合购拆分的
  1037 + if([1, 2, 4, 6, 8, 9].indexOf(item1.prom_type)== -1 && !item1.whsle_id
  1038 + && !item1.is_gift && !item1.is_ld_split && !item1.is_zh_split ){
  1039 + //-- 快速查找,组装查询多活动的列表 --
  1040 + let f_idx=dug_cx_arr.findIndex(function (ele) {
  1041 + return ele.goods_id == item1.goods_id
  1042 + });
  1043 + if(f_idx==-1) {
  1044 + let gd_ite={
  1045 + goods_id:carr[i].goods_id,
  1046 + goods_num:1,
  1047 + is_limit_show:1,
  1048 + is_state:0
  1049 + }
  1050 + dug_cx_arr.push(gd_ite);
1043 } 1051 }
1044 - goodsbuynum = buy_num_data.goodsbuynum;  
1045 - })  
1046 - //如果有购买活动  
1047 - item1.promgoodsbuynum = promgoodsbuynum; 1052 +
  1053 + }
1048 1054
1049 if(is_change){ 1055 if(is_change){
1050 carr[i].collocationList=null; 1056 carr[i].collocationList=null;
1051 } 1057 }
1052 -  
1053 } 1058 }
1054 1059
  1060 + //-- 对商品的多促销进行判断 ---2024-2-1--
  1061 + if(dug_cx_arr.length){
  1062 + await th.buy_pro_group(dug_cx_arr,carr);
  1063 + }
1055 //在分组的时候,就不要再调用接口,await 1064 //在分组的时候,就不要再调用接口,await
1056 for (var i = 0; i < carr.length; i++) { 1065 for (var i = 0; i < carr.length; i++) {
1057 var item = carr[i]; 1066 var item = carr[i];
@@ -1079,10 +1088,9 @@ Page({ @@ -1079,10 +1088,9 @@ Page({
1079 1088
1080 } 1089 }
1081 1090
1082 -  
1083 //商品的图片不能重复的赋值 1091 //商品的图片不能重复的赋值
1084 if(item.original_img.indexOf(oo.imghost)==-1) 1092 if(item.original_img.indexOf(oo.imghost)==-1)
1085 - item.original_img = oo.imghost + item.original_img; 1093 + item.original_img = oo.imghost + item.original_img;
1086 1094
1087 var car_item = item; 1095 var car_item = item;
1088 /*----接口要弄出来的,先顶着-----*/ 1096 /*----接口要弄出来的,先顶着-----*/
@@ -1095,10 +1103,10 @@ Page({ @@ -1095,10 +1103,10 @@ Page({
1095 1103
1096 if (arr[j].pickup_id == pcid) { 1104 if (arr[j].pickup_id == pcid) {
1097 if (item.is_gift != 1) { 1105 if (item.is_gift != 1) {
1098 - //确定配送方式  
1099 - if (arr[j].distr_t == 0) {  
1100 - arr[j].distr_t = car_item.distr_type;  
1101 - } 1106 + //确定配送方式
  1107 + if (arr[j].distr_t == 0) {
  1108 + arr[j].distr_t = car_item.distr_type;
  1109 + }
1102 }else{ 1110 }else{
1103 item.distr_type=0; //赠品不控制物流的方式 1111 item.distr_type=0; //赠品不控制物流的方式
1104 } 1112 }
@@ -1112,10 +1120,10 @@ Page({ @@ -1112,10 +1120,10 @@ Page({
1112 switch (dis_t) { 1120 switch (dis_t) {
1113 case 0: 1121 case 0:
1114 if(!arr[j].exp_sure){ 1122 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 1123 + e_t = 1;
  1124 + //-- 系统后台有设置要默认的 --
  1125 + if (th.data.json_d.pickupway && th.data.json_d.pickupway == 1) e_t = 0;
  1126 + arr[j].exp_type=e_t
1119 } 1127 }
1120 break; 1128 break;
1121 case 1: 1129 case 1:
@@ -1147,8 +1155,8 @@ Page({ @@ -1147,8 +1155,8 @@ Page({
1147 1155
1148 } 1156 }
1149 if(car_item.is_gift != 1){ 1157 if(car_item.is_gift != 1){
1150 - arr[j].exp_type = e_t;  
1151 - if (e_t == 0) th.setData({ is_all_zt: 0 }); 1158 + arr[j].exp_type = e_t;
  1159 + if (e_t == 0) th.setData({ is_all_zt: 0 });
1152 } 1160 }
1153 1161
1154 //else if (e_t == 1) th.setData({ is_all_zt: 1 }); 1162 //else if (e_t == 1) th.setData({ is_all_zt: 1 });
@@ -1176,13 +1184,12 @@ Page({ @@ -1176,13 +1184,12 @@ Page({
1176 if (find == 0) { 1184 if (find == 0) {
1177 var pikname = '', sto = null; 1185 var pikname = '', sto = null;
1178 //----找到门店名称----- 1186 //----找到门店名称-----
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 - } 1187 + pikname = item.pickup_name;
  1188 + sto ={
  1189 + pickup_id:item.pick_id,
  1190 + pickup_name:pikname,
  1191 + distr_type:item.pickup_distr_type
  1192 + };
1186 var e_t = 0, dis_t = 0;//物流方式,配送方式 1193 var e_t = 0, dis_t = 0;//物流方式,配送方式
1187 if (item.distr_type == 0) { 1194 if (item.distr_type == 0) {
1188 dis_t = sto.distr_type; 1195 dis_t = sto.distr_type;
@@ -1191,7 +1198,6 @@ Page({ @@ -1191,7 +1198,6 @@ Page({
1191 } 1198 }
1192 1199
1193 let exp_sure=0; 1200 let exp_sure=0;
1194 -  
1195 switch (dis_t) { 1201 switch (dis_t) {
1196 case 0: 1202 case 0:
1197 e_t = 1; 1203 e_t = 1;
@@ -1224,12 +1230,10 @@ Page({ @@ -1224,12 +1230,10 @@ Page({
1224 } 1230 }
1225 } 1231 }
1226 } 1232 }
1227 -  
1228 -  
1229 if (back_data && parseFloat(back_data)) { 1233 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 - } 1234 + c_item.can_usecommise = parseFloat(parseFloat(back_data).toFixed(2));
  1235 + cart_commission += c_item.can_usecommise;
  1236 + }
1233 1237
1234 var ie = { 1238 var ie = {
1235 pickup_id: pcid, 1239 pickup_id: pcid,
@@ -1285,6 +1289,8 @@ Page({ @@ -1285,6 +1289,8 @@ Page({
1285 1289
1286 } 1290 }
1287 1291
  1292 +
  1293 +
1288 var cart_commission = 0; 1294 var cart_commission = 0;
1289 //-- 循环计算一下线下取价 -- 1295 //-- 循环计算一下线下取价 --
1290 for (var k = 0; k < arr.length; k++) { 1296 for (var k = 0; k < arr.length; k++) {
@@ -1292,8 +1298,31 @@ Page({ @@ -1292,8 +1298,31 @@ Page({
1292 if (!is_change) { 1298 if (!is_change) {
1293 //-- 要进行归类一下活动 -- 1299 //-- 要进行归类一下活动 --
1294 await m_cx.cart_cx_group(th, arr[k].goods, c_item, 0, 0, (show_can_cx) => { 1300 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; 1301 + //后台计算使用
  1302 + th.data.show_can_cx_map[c_item.pickup_id]=show_can_cx;
  1303 + //-- 把活动组装进去 ---
  1304 + let show_can_cx1 = ut.deep_cp(show_can_cx);
  1305 + //前端处理渲染的时,要处理一些不需要的字段属性
  1306 + if(show_can_cx1){
  1307 + for (const key in show_can_cx1) {
  1308 + let element = show_can_cx1[key];
  1309 + if(element.cur_act){
  1310 + let c_act=element.cur_act;
  1311 + delete c_act.goods;
  1312 + }
  1313 + if(element.ch_map){
  1314 + delete element.ch_map;
  1315 + }
  1316 + if(element.act_arr && element.act_arr.length>0){
  1317 + for (var ij = 0; ij < element.act_arr.length; ij++) {
  1318 + var act_ite = element.act_arr[ij];
  1319 + delete act_ite.goods;
  1320 + delete act_ite.key;
  1321 + }
  1322 + }
  1323 + }
  1324 + }
  1325 + arr[k].show_can_cx = show_can_cx1;
1297 },2) 1326 },2)
1298 } else { 1327 } else {
1299 var show_can_cx = this.data.cartlist[k].show_can_cx; 1328 var show_can_cx = this.data.cartlist[k].show_can_cx;
@@ -1314,13 +1343,13 @@ Page({ @@ -1314,13 +1343,13 @@ Page({
1314 //-- 如果初始活动在计算的时候,是不满足的时候,就要把活动清理掉 -- 1343 //-- 如果初始活动在计算的时候,是不满足的时候,就要把活动清理掉 --
1315 var is_no_ok=arr[k].show_can_cx[key_o].cur_act.is_no_ok; 1344 var is_no_ok=arr[k].show_can_cx[key_o].cur_act.is_no_ok;
1316 if(is_no_ok==1){ 1345 if(is_no_ok==1){
1317 - item1.prom_id = 0;  
1318 - item1.prom_type = 0; 1346 + item1.prom_id = 0;
  1347 + item1.prom_type = 0;
1319 1348
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 - } 1349 + //这里要判断一下活动的最后一个商品,is_act_last
  1350 + if(th.is_last(item1.goods_id,arr[k].goods,arr[k].show_can_cx[key_o].ch_map)){
  1351 + item1.is_act_last=1; //这个是要在前端显示按钮切换的
  1352 + }
1324 1353
1325 } 1354 }
1326 } 1355 }
@@ -1331,14 +1360,17 @@ Page({ @@ -1331,14 +1360,17 @@ Page({
1331 if (item1.prom_type == 3 && item1.is_gift != 1 && !item1.whsle_id) { 1360 if (item1.prom_type == 3 && item1.is_gift != 1 && !item1.whsle_id) {
1332 // th.check_is_youhui(item1.goods_id, item1.pick_id); 1361 // th.check_is_youhui(item1.goods_id, item1.pick_id);
1333 //增加优惠活动次数限制 1362 //增加优惠活动次数限制
1334 - let limit_num = await th.getprom(item1) //活动限制次数 1363 + let limit_num = th.getprom(item1) //活动限制次数
1335 1364
1336 if (!limit_num) { 1365 if (!limit_num) {
1337 await th.add_prom_goods_map(item1); 1366 await th.add_prom_goods_map(item1);
1338 // item1.prom_id='' 1367 // item1.prom_id=''
1339 // item1.prom_type='' 1368 // item1.prom_type=''
1340 } else { 1369 } else {
  1370 +
1341 let user_pre_buynum = await th.getUserBuyPromNum_pre(item1.prom_id) //用户已经参与次数 1371 let user_pre_buynum = await th.getUserBuyPromNum_pre(item1.prom_id) //用户已经参与次数
  1372 +
  1373 +
1342 if (user_pre_buynum < limit_num) { 1374 if (user_pre_buynum < limit_num) {
1343 await th.add_prom_goods_map(item1); 1375 await th.add_prom_goods_map(item1);
1344 } else { 1376 } else {
@@ -1431,7 +1463,7 @@ Page({ @@ -1431,7 +1463,7 @@ Page({
1431 1463
1432 } else { 1464 } else {
1433 1465
1434 - 1466 +
1435 item1.act = th.data.zhhe_act_map[item1.prom_id]; 1467 item1.act = th.data.zhhe_act_map[item1.prom_id];
1436 } 1468 }
1437 } 1469 }
@@ -1511,29 +1543,48 @@ Page({ @@ -1511,29 +1543,48 @@ Page({
1511 //如果是秒杀,团购的时候,优惠促销和搭配购的时候 1543 //如果是秒杀,团购的时候,优惠促销和搭配购的时候
1512 if([1,2,3,5,6,7,10].indexOf(item1.prom_type)>-1){ 1544 if([1,2,3,5,6,7,10].indexOf(item1.prom_type)>-1){
1513 1545
  1546 + //由于是购物车购买,所以prom_type 基本不会员等于6
1514 if(item1.prom_type==1 || item1.prom_type==6) { 1547 if(item1.prom_type==1 || item1.prom_type==6) {
1515 item1.is_quan=0; 1548 item1.is_quan=0;
1516 } 1549 }
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 - 1550 + let t_goodsActinfo=item1.goodsActinfo;
  1551 + if(t_goodsActinfo && t_goodsActinfo.length){
  1552 + let ff_prom=t_goodsActinfo.find(function (e){
  1553 + return e.prom_type==item1.prom_type;
  1554 + })
  1555 + if(ff_prom){
1525 if(item1.prom_type!=7 && item1.prom_type!=10) { 1556 if(item1.prom_type!=7 && item1.prom_type!=10) {
1526 - item1.is_order_yh=res.data.data.is_order_yh; 1557 + item1.is_order_yh=ff_prom.is_order_yh;
1527 }else item1.is_order_yh=0; 1558 }else item1.is_order_yh=0;
1528 1559
1529 - item1.is_post_temp=res.data.data.is_post_temp; 1560 + item1.is_post_temp=ff_prom.is_post_temp;
1530 1561
  1562 + //由于是购物车购买,所以prom_type 基本不会员等于6
1531 if(item1.prom_type==1 || item1.prom_type==6) { 1563 if(item1.prom_type==1 || item1.prom_type==6) {
1532 - item1.is_quan=res.data.data.is_quan; 1564 + item1.is_quan=item1.cartActinfo.is_quan;
1533 } 1565 }
1534 -  
1535 } 1566 }
1536 - }) 1567 + }
  1568 +
  1569 + // var url= "/api/weshop/activitylist/getSJGoodsPriceNew/" + os.stoid
  1570 + // + "/" + item1.goods_id + "/"+item1.prom_type+"/" + item1.prom_id + "/" + app.globalData.user_id;
  1571 + // await app.request.promiseGet(url,{}).then(res=>{
  1572 + // if(res.data.code==0){
  1573 + // console.log(res.data.data,"111");
  1574 + // //组合促销有另外一个字段名is_orderyh,在控制订单促销的叠加
  1575 + //
  1576 + // if(item1.prom_type!=7 && item1.prom_type!=10) {
  1577 + // item1.is_order_yh=res.data.data.is_order_yh;
  1578 + // }else item1.is_order_yh=0;
  1579 + //
  1580 + // item1.is_post_temp=res.data.data.is_post_temp;
  1581 + //
  1582 + // if(item1.prom_type==1 || item1.prom_type==6) {
  1583 + // item1.is_quan=res.data.data.is_quan;
  1584 + // }
  1585 + //
  1586 + // }
  1587 + // })
1537 } 1588 }
1538 1589
1539 } 1590 }
@@ -1556,17 +1607,17 @@ Page({ @@ -1556,17 +1607,17 @@ Page({
1556 goods_num: item[c].goods_num, 1607 goods_num: item[c].goods_num,
1557 prom_type: item[c].prom_type, 1608 prom_type: item[c].prom_type,
1558 prom_id: item[c].prom_id, 1609 prom_id: item[c].prom_id,
1559 -  
1560 } 1610 }
  1611 +
1561 let req_d1 = { 1612 let req_d1 = {
1562 user_id: getApp().globalData.user_id, goods_ids: [hr], store_id: os.stoid 1613 user_id: getApp().globalData.user_id, goods_ids: [hr], store_id: os.stoid
1563 } 1614 }
1564 -  
1565 await getApp().request.promisePost("/api/weshop/order/getrebateSum", { 1615 await getApp().request.promisePost("/api/weshop/order/getrebateSum", {
1566 is_json: 1, data: req_d1 1616 is_json: 1, data: req_d1
1567 }).then(grs => { 1617 }).then(grs => {
1568 if (grs.data.code == 0) item[c].use_commission = grs.data.data; 1618 if (grs.data.code == 0) item[c].use_commission = grs.data.data;
1569 }); 1619 });
  1620 +
1570 commission_gds.push(hr); 1621 commission_gds.push(hr);
1571 } 1622 }
1572 } 1623 }
@@ -1662,12 +1713,37 @@ Page({ @@ -1662,12 +1713,37 @@ Page({
1662 } 1713 }
1663 } 1714 }
1664 } 1715 }
1665 -  
1666 //深拷贝 1716 //深拷贝
1667 th.data.old_cartlist = JSON.parse(JSON.stringify(arr)); 1717 th.data.old_cartlist = JSON.parse(JSON.stringify(arr));
1668 - th.setData({  
1669 - cartlist: arr,  
1670 - }); 1718 +
  1719 + th.data.cartlist=arr;
  1720 +
  1721 + //-- 大于20使用逐步渲染 --
  1722 + if(arr.length>10){
  1723 + for (let ib = 0; ib <arr.length ; ib++) {
  1724 + //-- 都用深拷贝 --
  1725 + var ite=ut.deep_cp(th.data.old_cartlist[ib]);
  1726 + delete ite.goods;
  1727 + var txt0="cartlist["+ib+"]";
  1728 + th.setData({
  1729 + [txt0]:ite
  1730 + })
  1731 + //都用深拷贝
  1732 + var tt_goods=ut.deep_cp(th.data.old_cartlist[ib].goods);
  1733 + for (let iz = 0; iz <tt_goods.length;iz++) {
  1734 + var txt="cartlist["+ib+"].goods["+iz+"]";
  1735 + setTimeout(()=>{
  1736 + th.setData({
  1737 + [txt]:tt_goods[iz]
  1738 + })
  1739 + },ib*200+iz*300+100)
  1740 + }
  1741 + }
  1742 + }else{
  1743 + th.setData({
  1744 + cartlist: arr,
  1745 + });
  1746 + }
1671 1747
1672 //--- 获取一下看有没有优惠券 ---- 1748 //--- 获取一下看有没有优惠券 ----
1673 setTimeout(function () { 1749 setTimeout(function () {
@@ -1684,6 +1760,7 @@ Page({ @@ -1684,6 +1760,7 @@ Page({
1684 }, 500) 1760 }, 500)
1685 }, 1761 },
1686 1762
  1763 +
1687 //-----单个商品购买的入口判断---- 1764 //-----单个商品购买的入口判断----
1688 get_buy_goods: function (e) { 1765 get_buy_goods: function (e) {
1689 var th = this; 1766 var th = this;
@@ -2202,60 +2279,68 @@ Page({ @@ -2202,60 +2279,68 @@ Page({
2202 } 2279 }
2203 }, 2280 },
2204 2281
  2282 +
2205 //-- 立即购买的时候,获取商品优惠活动,is_state判断是不是单个商品购买, 2283 //-- 立即购买的时候,获取商品优惠活动,is_state判断是不是单个商品购买,
2206 // 很多活动需要判断会员的plus等级, 权益登陆,user_id调用接口是必须的 -- 2284 // 很多活动需要判断会员的plus等级, 权益登陆,user_id调用接口是必须的 --
2207 //先用着,后面会用接口来代替 2285 //先用着,后面会用接口来代替
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 - 2286 + async buy_pro_group(g_arr,carr) {
2220 var th=this; 2287 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 - } 2288 + //获取商品参与的促销活,优惠促,搭配促,组合促,阶梯促销
  2289 + let cx_rs= await getApp().request.promisePost("/api/weshop/cart/listGoodsPromInfo",{
  2290 + is_json:1,
  2291 + data:{
  2292 + user_id:app.globalData.user_id,
  2293 + store_id:oo.stoid,
  2294 + goods:g_arr,
  2295 + }
  2296 + });
  2297 + //-- 判断返回结果有没有正确,有促销活动就要进行赋值 --
  2298 + if(cx_rs && cx_rs.data.code==0 && cx_rs.data.data && cx_rs.data.data.goods) {
  2299 + let g_list=cx_rs.data.data.goods;
  2300 + for (var ia = 0; ia < carr.length; ia++) {
  2301 + if (carr[ia].whsle_id) continue; //代发商品不进行赋值
  2302 + if (carr[ia].is_gift) continue; //赠品不进行赋值
  2303 + //有参与秒,团购之类的活动不进行赋值
  2304 + if([1, 2, 4, 6, 8, 9].indexOf(carr[ia].prom_type)> -1 ) continue;
  2305 + //再g_list中快速查找
  2306 + let i_fd=g_list.find(function (ele) {
  2307 + return ele.goods_id == carr[ia].goods_id
  2308 + });
  2309 + if(i_fd.goodsPromInfoRespDto){
  2310 + //-- 多促销活动的优化 --
  2311 + i_fd=i_fd.goodsPromInfoRespDto;
  2312 + //-- 赋值多促销活动的优化--
  2313 + carr[ia].more_cx=i_fd.more_cx;
  2314 +
  2315 + //商品优惠促销的缓存
  2316 + if (i_fd.yhcx_pro) {
  2317 + th.data.yhcx_act_map[i_fd.yhcx_pro.id] = i_fd.yhcx_pro;
  2318 + }
  2319 + //商品组合促销的缓存
  2320 + if (i_fd.zh_pro) {
  2321 + th.data.zhhe_act_map[i_fd.zh_pro.id] = i_fd.zh_pro;
  2322 + }
  2323 + //商品阶梯促销的缓存
  2324 + if (i_fd.ladder_pro) {
  2325 + var ladder_pro = i_fd.ladder_pro;
  2326 + th.data.ladder_map[ladder_pro.id] = ladder_pro;
  2327 + var fd_ite = i_fd.more_cx.find(function (e) {
  2328 + return e.prom_type == 10;
  2329 + })
  2330 + if (fd_ite) {
  2331 + th.data.ladder_map[ladder_pro.id].ladder_list = fd_ite.ladder_list;
2254 } 2332 }
2255 - }  
2256 - }) 2333 + }
  2334 +
  2335 + }
  2336 +
  2337 + }
  2338 + }
2257 }, 2339 },
2258 2340
  2341 +
  2342 +
  2343 +
2259 //---------------检查是否有收货地址------------------- 2344 //---------------检查是否有收货地址-------------------
2260 checkAddressList: function () { 2345 checkAddressList: function () {
2261 var t = this; 2346 var t = this;
@@ -2393,11 +2478,11 @@ Page({ @@ -2393,11 +2478,11 @@ Page({
2393 newd.is_past=1; 2478 newd.is_past=1;
2394 } 2479 }
2395 2480
2396 - ord_goods.splice(pos+1,0,newd); 2481 + //ord_goods.splice(pos+1,0,newd);
2397 th.data.old_cartlist[i].goods.splice(pos2+1,0,newd); 2482 th.data.old_cartlist[i].goods.splice(pos2+1,0,newd);
2398 2483
2399 - var txt9 = "cartlist[" + i + "].goods";  
2400 - th.setData({ [txt9]: ord_goods }) 2484 + var txt9 = "cartlist[" + i + "].goods["+(pos+1)+"]";
  2485 + th.setData({ [txt9]: newd })
2401 2486
2402 } 2487 }
2403 2488
@@ -3643,7 +3728,7 @@ Page({ @@ -3643,7 +3728,7 @@ Page({
3643 } 3728 }
3644 3729
3645 3730
3646 - if (th.data.cart_use_commission) { 3731 + if (th.data.cart_use_commission && cart_item.can_usecommise) {
3647 cart_item.order_amount -= cart_item.can_usecommise; 3732 cart_item.order_amount -= cart_item.can_usecommise;
3648 } 3733 }
3649 3734
@@ -6610,25 +6695,26 @@ Page({ @@ -6610,25 +6695,26 @@ Page({
6610 }).then(res => { 6695 }).then(res => {
6611 if (res.data.code == 0) { 6696 if (res.data.code == 0) {
6612 var quan_list = res.data.data.pageData; 6697 var quan_list = res.data.data.pageData;
6613 - arr[ind].quan_list = th.check_is_frozenQuan(quan_list, th.data.frozenQuan); 6698 + //arr[ind].quan_list = th.check_is_frozenQuan(quan_list, th.data.frozenQuan);
  6699 + quan_list= th.check_is_frozenQuan(quan_list, th.data.frozenQuan);
  6700 + var set_txt = "cartlist[" + ind + "].quan_list";
  6701 + th.setData({
  6702 + [set_txt]:quan_list
  6703 + })
6614 } 6704 }
6615 }) 6705 })
6616 } 6706 }
6617 -  
6618 -  
6619 } 6707 }
6620 6708
6621 6709
6622 -  
6623 -  
6624 //如果是搭配购的立即购买的时候 6710 //如果是搭配购的立即购买的时候
6625 if (th.data.is_b_now) { 6711 if (th.data.is_b_now) {
6626 if (arr && arr.length > 0) { 6712 if (arr && arr.length > 0) {
6627 var quanlist = arr[0].quan_list; 6713 var quanlist = arr[0].quan_list;
6628 - th.setData({ selected_quan_list: quanlist, cartlist: arr }) 6714 + th.setData({ selected_quan_list: quanlist })
6629 } 6715 }
6630 } else { 6716 } else {
6631 - th.setData({ cartlist: arr }) 6717 + //th.setData({ cartlist: arr })
6632 th.set_can_num(); 6718 th.set_can_num();
6633 } 6719 }
6634 6720
@@ -6888,6 +6974,12 @@ Page({ @@ -6888,6 +6974,12 @@ Page({
6888 }, 6974 },
6889 //优惠促销用户参与次数 6975 //优惠促销用户参与次数
6890 async getUserBuyPromNum_pre(prom_id){ 6976 async getUserBuyPromNum_pre(prom_id){
  6977 +
  6978 + //如果有缓存的数据,就用缓存的数据
  6979 + if(this.data.in_yhact[prom_id] && this.data.in_yhact[prom_id].buyed!=undefined){
  6980 + let user_pre_buynum=this.data.in_yhact[prom_id].buyed;
  6981 + return user_pre_buynum;
  6982 + }
6891 var userInfo = getApp().globalData.userInfo; 6983 var userInfo = getApp().globalData.userInfo;
6892 var url = `/api/weshop/ordergoods/getUserBuyPromNum?is_all=1&store_id=${os.stoid}&user_id=${userInfo.user_id}&prom_type=3&prom_id=${prom_id}`; 6984 var url = `/api/weshop/ordergoods/getUserBuyPromNum?is_all=1&store_id=${os.stoid}&user_id=${userInfo.user_id}&prom_type=3&prom_id=${prom_id}`;
6893 let res = await getApp().request.promiseGet(url, { 6985 let res = await getApp().request.promiseGet(url, {
@@ -6899,25 +6991,38 @@ Page({ @@ -6899,25 +6991,38 @@ Page({
6899 } 6991 }
6900 return user_pre_buynum 6992 return user_pre_buynum
6901 }, 6993 },
  6994 +
  6995 +
6902 //获取优惠活动 6996 //获取优惠活动
6903 - async getprom(item){  
6904 - 6997 + getprom(item){
  6998 +
6905 let prom_id=item.prom_id 6999 let prom_id=item.prom_id
6906 let pickup_id=item.pick_id 7000 let pickup_id=item.pick_id
6907 let limit_num=0 7001 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 - }) 7002 + //不再调用接口活动优惠促销活动的内容
  7003 + // await getApp().request.promiseGet("/api/weshop/promgoods/get/" + oo.stoid + "/" + prom_id, {}).then(res => {
  7004 + // if (res.data.code == 0) {
  7005 + // let prom = res.data.data;
  7006 + // limit_num =prom.limit_num
  7007 + // let yh_is_xz_yh=this.data.yh_is_xz_yh
  7008 + // yh_is_xz_yh[pickup_id]=prom.is_xz_yh
  7009 + // this.setData({
  7010 + // ['yh_is_xz_yh']:yh_is_xz_yh
  7011 + // })
  7012 + // }
  7013 + // })
  7014 + if(this.data.yhcx_act_map[prom_id]){
  7015 + let prom = this.data.yhcx_act_map[prom_id];
  7016 + limit_num =prom.limit_num
  7017 + let yh_is_xz_yh=this.data.yh_is_xz_yh
  7018 + yh_is_xz_yh[pickup_id]=prom.is_xz_yh
  7019 + this.setData({
  7020 + ['yh_is_xz_yh']:yh_is_xz_yh
  7021 + })
  7022 + }
6919 return limit_num 7023 return limit_num
6920 }, 7024 },
  7025 +
6921 //--检查订单优惠-- 7026 //--检查订单优惠--
6922 check_is_order_prom: function (condition, func, pick) { 7027 check_is_order_prom: function (condition, func, pick) {
6923 var th = this; 7028 var th = this;
@@ -6971,10 +7076,11 @@ Page({ @@ -6971,10 +7076,11 @@ Page({
6971 7076
6972 } else { 7077 } else {
6973 var prom = null; 7078 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; 7079 +
  7080 +
  7081 + if(th.data.yhcx_act_map[item.prom_id]){
  7082 +
  7083 + prom = th.data.yhcx_act_map[item.prom_id];
6978 7084
6979 let min_value = 0 7085 let min_value = 0
6980 if (prom && prom.is_xz_yh) { 7086 if (prom && prom.is_xz_yh) {
@@ -7001,7 +7107,8 @@ Page({ @@ -7001,7 +7107,8 @@ Page({
7001 } 7107 }
7002 } 7108 }
7003 } 7109 }
7004 - }) 7110 +
  7111 + if(!prom) return false;
7005 var ob = {}; 7112 var ob = {};
7006 ob.prom_id = item.prom_id; 7113 ob.prom_id = item.prom_id;
7007 ob.name = prom.name; 7114 ob.name = prom.name;
@@ -7033,11 +7140,9 @@ Page({ @@ -7033,11 +7140,9 @@ Page({
7033 } else { 7140 } else {
7034 var ob = {}; 7141 var ob = {};
7035 var prom = null; 7142 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 7143
  7144 + if(th.data.yhcx_act_map[item.prom_id]){
  7145 + prom = th.data.yhcx_act_map[item.prom_id];
7041 let min_value = 0 7146 let min_value = 0
7042 if (prom && prom.is_xz_yh) { 7147 if (prom && prom.is_xz_yh) {
7043 let arr = prom.promGoodsList || [] 7148 let arr = prom.promGoodsList || []
@@ -7063,9 +7168,8 @@ Page({ @@ -7063,9 +7168,8 @@ Page({
7063 } 7168 }
7064 } 7169 }
7065 } 7170 }
7066 - })  
7067 -  
7068 7171
  7172 + if(!prom) return false;
7069 //优惠促销取价的优化 7173 //优惠促销取价的优化
7070 let f_price=item.goods_price; 7174 let f_price=item.goods_price;
7071 7175
@@ -8283,6 +8387,7 @@ Page({ @@ -8283,6 +8387,7 @@ Page({
8283 pro_pop.set_init(1,cp_arr); 8387 pro_pop.set_init(1,cp_arr);
8284 }, 8388 },
8285 8389
  8390 +
8286 //--- 选择回来时候的选择 --- 8391 //--- 选择回来时候的选择 ---
8287 sure_cx_group:function(e){ 8392 sure_cx_group:function(e){
8288 var th=this; 8393 var th=this;
@@ -8291,8 +8396,10 @@ Page({ @@ -8291,8 +8396,10 @@ Page({
8291 //-- 获取到当前的show_can_cx-- 8396 //-- 获取到当前的show_can_cx--
8292 var idx=this.data.sele_cx_group_cidx; 8397 var idx=this.data.sele_cx_group_cidx;
8293 var gd_key= this.data.cx_group_gd_key; 8398 var gd_key= this.data.cx_group_gd_key;
8294 - var cx_prom_group=this.data.cartlist[idx].show_can_cx[gd_key].act_arr;  
8295 var pk=this.data.cartlist[idx].pickup_id; 8399 var pk=this.data.cartlist[idx].pickup_id;
  8400 + var cx_prom_group2= th.data.show_can_cx_map[pk][gd_key].act_arr;
  8401 +
  8402 + var cx_prom_group=this.data.cartlist[idx].show_can_cx[gd_key].act_arr;
8296 8403
8297 th.setData({ 8404 th.setData({
8298 send_lb:{}, 8405 send_lb:{},
@@ -8311,12 +8418,18 @@ Page({ @@ -8311,12 +8418,18 @@ Page({
8311 //如果活动不是选择的 8418 //如果活动不是选择的
8312 if(cx_prom_group[dx].prom_type!=sele_prom_type) cx_prom_group[dx].sele=0; 8419 if(cx_prom_group[dx].prom_type!=sele_prom_type) cx_prom_group[dx].sele=0;
8313 else cx_prom_group[dx].sele=1; 8420 else cx_prom_group[dx].sele=1;
  8421 +
  8422 + if(cx_prom_group2[dx].prom_type!=sele_prom_type) cx_prom_group2[dx].sele=0;
  8423 + else cx_prom_group2[dx].sele=1;
8314 } 8424 }
8315 //选择后就要把活动确定下来 8425 //选择后就要把活动确定下来
8316 //确定一下活动,先看一下有没有选择的活动 8426 //确定一下活动,先看一下有没有选择的活动
8317 var ck_prom_type=cx_prom_group.find(function (el){ 8427 var ck_prom_type=cx_prom_group.find(function (el){
8318 return el.sele; 8428 return el.sele;
8319 }) 8429 })
  8430 + var ck_prom_type2=cx_prom_group2.find(function (el){
  8431 + return el.sele;
  8432 + })
8320 8433
8321 this.cx_check_ok2(function (ck_res){ 8434 this.cx_check_ok2(function (ck_res){
8322 8435
@@ -8324,20 +8437,19 @@ Page({ @@ -8324,20 +8437,19 @@ Page({
8324 th.data.cartlist[idx].show_can_cx[gd_key].sele_prom_type=ck_prom_type.prom_type; 8437 th.data.cartlist[idx].show_can_cx[gd_key].sele_prom_type=ck_prom_type.prom_type;
8325 th.data.cartlist[idx].show_can_cx[gd_key].cur_act=ck_prom_type; 8438 th.data.cartlist[idx].show_can_cx[gd_key].cur_act=ck_prom_type;
8326 8439
8327 -  
8328 var goods0= JSON.parse(JSON.stringify(th.data.cartlist_y)); 8440 var goods0= JSON.parse(JSON.stringify(th.data.cartlist_y));
8329 var goods=[]; 8441 var goods=[];
8330 for(var ik=0;ik<goods0.length;ik++){ 8442 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); 8443 + var item_c=goods0[ik];
  8444 + if(item_c.pick_id==pk && item_c.is_collocation) continue;
  8445 + goods.push(item_c);
8334 } 8446 }
8335 8447
8336 //-- 此时要把购物车中的商品确定活动 -- 8448 //-- 此时要把购物车中的商品确定活动 --
8337 - for (var b=0; b<ck_prom_type.goods.length;b++){ 8449 + for (var b=0; b<ck_prom_type2.goods.length;b++){
8338 //-- 开始查找 -- 8450 //-- 开始查找 --
8339 var fg=goods.findIndex(function (g_item){ 8451 var fg=goods.findIndex(function (g_item){
8340 - return g_item.goods_id==ck_prom_type.goods[b].goods_id 8452 + return g_item.goods_id==ck_prom_type2.goods[b].goods_id
8341 && [0,3,5,7,10].indexOf(g_item.prom_type)>-1 8453 && [0,3,5,7,10].indexOf(g_item.prom_type)>-1
8342 && g_item.pick_id==pk && g_item.is_gift==0; 8454 && g_item.pick_id==pk && g_item.is_gift==0;
8343 }) 8455 })
@@ -8352,10 +8464,10 @@ Page({ @@ -8352,10 +8464,10 @@ Page({
8352 } 8464 }
8353 8465
8354 for(var ik=0;ik< th.data.cartlist[idx].goods.length;ik++){ 8466 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 - } 8467 + if(th.data.cartlist[idx].goods[ik].id==goods[fg].id){
  8468 + th.data.cartlist[idx].goods[ik].prom_type= goods[fg].prom_type;
  8469 + th.data.cartlist[idx].goods[ik].prom_id= goods[fg].prom_id;
  8470 + }
8359 } 8471 }
8360 8472
8361 //原始数据要有深拷贝不能有地址的牵连 8473 //原始数据要有深拷贝不能有地址的牵连
@@ -8518,6 +8630,9 @@ Page({ @@ -8518,6 +8630,9 @@ Page({
8518 let item = this.data.cartlist[pidx].show_can_cx[can_cx_idx]; //促销内容 8630 let item = this.data.cartlist[pidx].show_can_cx[can_cx_idx]; //促销内容
8519 let pk=this.data.cartlist[pidx].pickup_id; //门店ID 8631 let pk=this.data.cartlist[pidx].pickup_id; //门店ID
8520 8632
  8633 + //获取到后台计算多促销的数据
  8634 + var cx_prom_group2= this.data.show_can_cx_map[pk][can_cx_idx].act_arr;
  8635 +
8521 //给no_cj_prom进行赋值 8636 //给no_cj_prom进行赋值
8522 item.no_cj_prom = !item.no_cj_prom ? 1 : 0; 8637 item.no_cj_prom = !item.no_cj_prom ? 1 : 0;
8523 var txt = 'cartlist[' + pidx + '].show_can_cx'; 8638 var txt = 'cartlist[' + pidx + '].show_can_cx';
@@ -8525,7 +8640,16 @@ Page({ @@ -8525,7 +8640,16 @@ Page({
8525 [txt]: this.data.cartlist[pidx].show_can_cx, 8640 [txt]: this.data.cartlist[pidx].show_can_cx,
8526 }) 8641 })
8527 8642
8528 - let ck_prom_type=item.cur_act; 8643 + //使用深拷贝,生成临时的变量
  8644 + let ck_prom_type= ut.deep_cp(item.cur_act);
  8645 + var f_act=cx_prom_group2.find(function (ite){
  8646 + return ite.prom_type==ck_prom_type.prom_type
  8647 + })
  8648 + if(!ck_prom_type || !f_act){
  8649 + ut.m_toast('未找到活动');
  8650 + }
  8651 + ck_prom_type.goods=f_act.goods;
  8652 +
8529 //处理一下商品 8653 //处理一下商品
8530 let goods0 = JSON.parse(JSON.stringify(th.data.cartlist_y)); 8654 let goods0 = JSON.parse(JSON.stringify(th.data.cartlist_y));
8531 let goods = []; 8655 let goods = [];
pages/cart/cart/cart.js
@@ -59,58 +59,16 @@ Page({ @@ -59,58 +59,16 @@ Page({
59 59
60 is_cart:1, //标记是购物车计算的时候 60 is_cart:1, //标记是购物车计算的时候
61 61
62 - },  
63 -  
64 - //-- 立即购买的时候,获取商品优惠活动,is_state判断是不是单个商品购买,  
65 - // 很多活动需要判断会员的plus等级, 权益登陆,user_id调用接口是必须的 --  
66 - //先用着,后面会用接口来代替  
67 - async buy_pro_group(item1, is_state) {  
68 - //-- 代发商品不参与任何活动 --  
69 - if (item1.whsle_id) return false;  
70 - if (item1.is_gift) return false;  
71 -  
72 - var th = this;  
73 - var req_d = {  
74 - store_id: os.stoid,  
75 - user_id: getApp().globalData.user_id,  
76 - goods_id: item1.goods_id,  
77 - goods_num: item1.goods_num,  
78 - goods_price: item1.goods_price,  
79 - }  
80 - //--- 调用接口获取活动 ---  
81 - await getApp().promiseGet('/api/weshop/goods/getGoodsPromInfo', {  
82 - data: req_d  
83 - }).then(res => {  
84 - if (res.data.code == 0) {  
85 -  
86 - var more_cx = res.data.data.more_cx;  
87 - for (var i = 0; i < more_cx.length; i++) {  
88 - if (more_cx[i].prom_type == 5) {  
89 - more_cx[i].main_gid = more_cx[i].collocation.main_goods_id;  
90 - var min = more_cx[i].collocation_main_price + more_cx[i].collocation_min_price;  
91 - var max = more_cx[i].collocation_main_price + more_cx[i].collocation_max_price;  
92 - more_cx[i].show_price = "¥" + min + "-" + max;  
93 - }  
94 - }  
95 - item1.more_cx = more_cx  
96 - if (res.data.data.zh_pro) {  
97 - th.data.zuhe_map[res.data.data.zh_pro.id] = res.data.data.zh_pro;  
98 - }  
99 - if (res.data.data.ladder_pro) {  
100 - var ladder_pro = res.data.data.ladder_pro;  
101 - th.data.ladder_map[ladder_pro.id] = ladder_pro;  
102 - var fd = res.data.data.more_cx.find(function (e) {  
103 - return e.prom_type == 10;  
104 - })  
105 - if (fd) {  
106 - th.data.ladder_map[ladder_pro.id].ladder_list = fd.ladder_list;  
107 - }  
108 - }  
109 - }  
110 - }) 62 + //送赠品的优化
  63 + cart_zp:{},
  64 + //-- dp_cart深拷贝的缓存 --
  65 + dp_cart:null,
111 66
  67 + //优惠促销活动的集合
  68 + yhcx_act_map: {},
112 }, 69 },
113 70
  71 +
114 onLoad: function () { 72 onLoad: function () {
115 var a = this, 73 var a = this,
116 ee = a; 74 ee = a;
@@ -118,6 +76,7 @@ Page({ @@ -118,6 +76,7 @@ Page({
118 wx.setNavigationBarTitle({ 76 wx.setNavigationBarTitle({
119 title: "购物车", 77 title: "购物车",
120 }) 78 })
  79 +
121 //判断是否有登录 80 //判断是否有登录
122 t.auth.hadAuth() && t.getUserInfo(function () { 81 t.auth.hadAuth() && t.getUserInfo(function () {
123 //a.getCardList(); 82 //a.getCardList();
@@ -126,6 +85,9 @@ Page({ @@ -126,6 +85,9 @@ Page({
126 }, 85 },
127 onShow: function () { 86 onShow: function () {
128 87
  88 + //-- 清空 checkouting 结算的标记 --
  89 + this.data.checkouting=0;
  90 +
129 if(getApp().globalData.from_act_link){ 91 if(getApp().globalData.from_act_link){
130 this.data.from_act_link= ut.deep_cp(getApp().globalData.from_act_link); 92 this.data.from_act_link= ut.deep_cp(getApp().globalData.from_act_link);
131 getApp().globalData.from_act_link=null; 93 getApp().globalData.from_act_link=null;
@@ -140,7 +102,8 @@ Page({ @@ -140,7 +102,8 @@ Page({
140 //每次显示都清空 102 //每次显示都清空
141 this.data.in_zhact_gdmap = {}; 103 this.data.in_zhact_gdmap = {};
142 this.setData({ 104 this.setData({
143 - invalidList: [] 105 + invalidList: [],
  106 + cart_zp:{} //-- 赠品也要清理显示 --
144 }); 107 });
145 108
146 if (typeof this.getTabBar === 'function' && this.getTabBar()) { 109 if (typeof this.getTabBar === 'function' && this.getTabBar()) {
@@ -290,7 +253,6 @@ Page({ @@ -290,7 +253,6 @@ Page({
290 var user = getApp().globalData.userInfo; 253 var user = getApp().globalData.userInfo;
291 //如果后台有开启等级价的功能 254 //如果后台有开启等级价的功能
292 if (user && parseInt(s_list.rank_switch) == 2 && user['card_expiredate']) { 255 if (user && parseInt(s_list.rank_switch) == 2 && user['card_expiredate']) {
293 -  
294 var str = user['card_expiredate'].replace(/-/g, '/'); 256 var str = user['card_expiredate'].replace(/-/g, '/');
295 var end = new Date(str); 257 var end = new Date(str);
296 end = Date.parse(end) / 1000; 258 end = Date.parse(end) / 1000;
@@ -517,7 +479,18 @@ Page({ @@ -517,7 +479,18 @@ Page({
517 479
518 wx.showLoading(); 480 wx.showLoading();
519 481
520 - getApp().request.get("/api/weshop/cart/list", { 482 + //一次性把购物车selected状态变成0
  483 + var url = '/api/weshop/cart/updateUserCart';
  484 + getApp().request.put(url, {
  485 + data: {
  486 + user_id: app.globalData.user_id,
  487 + store_id: oo.stoid,
  488 + selected: 0,
  489 + state:0
  490 + }
  491 + });
  492 +
  493 + getApp().request.get("/api/weshop/cart/listNew1", {
521 data: { 494 data: {
522 user_id: app.globalData.user_id, 495 user_id: app.globalData.user_id,
523 rd: rd, 496 rd: rd,
@@ -534,65 +507,87 @@ Page({ @@ -534,65 +507,87 @@ Page({
534 507
535 if (carr && carr.length > 0) { 508 if (carr && carr.length > 0) {
536 var g_arr = []; 509 var g_arr = [];
  510 + var by_map = null;
  511 +
537 for (var i = 0; i < carr.length; i++) { 512 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 - }); 513 + //填充一下已经买了多少件,只有在商品是有限购条件的时候才进行计算good.viplimited>0
  514 + if(carr[i].viplimited>0){
  515 + if(!by_map) by_map={};
  516 + by_map[carr[i].goods_id] = carr[i].goodsbuynum?carr[i].goodsbuynum:0;
  517 + }
  518 +
  519 + //如果不是活动的时候,不是代发商品的时候,不是赠品的时候
  520 + if([1, 2, 4, 6, 8, 9].indexOf(carr[i].prom_type)== -1 && !carr[i].whsle_id && !carr[i].is_gift ){
547 521
548 - if (g_arr.length == 0) g_arr.push(carr[i].goods_id);  
549 - else {  
550 - var ind = g_arr.findIndex(function (ele) { 522 + //快速查找
  523 + let f_idx=g_arr.findIndex(function (ele) {
551 return ele.goods_id == carr[i].goods_id 524 return ele.goods_id == carr[i].goods_id
552 - })  
553 - if (ind > -1) continue;  
554 - g_arr.push(carr[i].goods_id) 525 + });
  526 + if(f_idx>-1) continue;
  527 +
  528 + let gd_ite={
  529 + goods_id:carr[i].goods_id,
  530 + goods_num:1,
  531 + is_limit_show:1,
  532 + is_state:0
  533 + }
  534 + g_arr.push(gd_ite);
555 } 535 }
556 } 536 }
557 537
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; 538 + //获取商品参与的促销活,优惠促,搭配促,组合促,阶梯促销
  539 + let cx_rs= await getApp().request.promisePost("/api/weshop/cart/listGoodsPromInfo",{
  540 + is_json:1,
  541 + data:{
  542 + user_id:app.globalData.user_id,
  543 + store_id:oo.stoid,
  544 + goods:g_arr,
  545 + }
  546 + });
  547 + //-- 判断返回结果有没有正确,有促销活动就要进行赋值 --
  548 + if(cx_rs && cx_rs.data.code==0 && cx_rs.data.data && cx_rs.data.data.goods) {
  549 + let g_list=cx_rs.data.data.goods;
  550 + for (var ia = 0; ia < carr.length; ia++) {
  551 + if (carr[ia].whsle_id) continue; //代发商品不进行赋值
  552 + if (carr[ia].is_gift) continue; //赠品不进行赋值
  553 + //有参与秒,团购之类的活动不进行赋值
  554 + if([1, 2, 4, 6, 8, 9].indexOf(carr[ia].prom_type)> -1 ) continue;
  555 + //再g_list中快速查找
  556 + let i_fd=g_list.find(function (ele) {
  557 + return ele.goods_id == carr[ia].goods_id
  558 + });
  559 + if(i_fd.goodsPromInfoRespDto){
  560 + //-- 多促销活动的优化 --
  561 + i_fd=i_fd.goodsPromInfoRespDto;
  562 + //-- 赋值多促销活动的优化--
  563 + carr[ia].more_cx=i_fd.more_cx;
  564 + //商品优惠促销的缓存
  565 + if (i_fd.yhcx_pro) {
  566 + th.data.yhcx_act_map[i_fd.yhcx_pro.id] = i_fd.yhcx_pro;
  567 + }
  568 + //商品组合促销的缓存
  569 + if (i_fd.zh_pro) {
  570 + th.data.zuhe_map[i_fd.zh_pro.id] = i_fd.zh_pro;
  571 + }
  572 + //商品阶梯促销的缓存
  573 + if (i_fd.ladder_pro) {
  574 + var ladder_pro = i_fd.ladder_pro;
  575 + th.data.ladder_map[ladder_pro.id] = ladder_pro;
  576 + var fd_ite = i_fd.more_cx.find(function (e) {
  577 + return e.prom_type == 10;
  578 + })
  579 + if (fd_ite) {
  580 + th.data.ladder_map[ladder_pro.id].ladder_list = fd_ite.ladder_list;
591 } 581 }
592 - }) 582 + }
  583 + }
  584 +
  585 + }
593 } 586 }
594 587
595 588
  589 +
  590 + let cart_up_data=[];
596 for (var i = 0; i < carr.length; i++) { 591 for (var i = 0; i < carr.length; i++) {
597 var item = carr[i]; 592 var item = carr[i];
598 var good = item; 593 var good = item;
@@ -622,7 +617,7 @@ Page({ @@ -622,7 +617,7 @@ Page({
622 promgoodsbuynum = 0, 617 promgoodsbuynum = 0,
623 limit = 0; 618 limit = 0;
624 if (by_map && by_map[good.goods_id]) { 619 if (by_map && by_map[good.goods_id]) {
625 - goodsbuynum = by_map[good.goods_id].goodsbuynum; 620 + goodsbuynum = by_map[good.goods_id];
626 //promgoodsbuynum = by_map[good.goods_id].promgoodsbuynum; 621 //promgoodsbuynum = by_map[good.goods_id].promgoodsbuynum;
627 } 622 }
628 623
@@ -662,19 +657,19 @@ Page({ @@ -662,19 +657,19 @@ Page({
662 } else { 657 } else {
663 item.goods_price = good.shop_price; 658 item.goods_price = good.shop_price;
664 } 659 }
665 -  
666 //-- 购物车更新 -- 660 //-- 购物车更新 --
667 var updata1 = { 661 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 662 + id: item.id,
  663 + prom_type: c_prom_type,
  664 + prom_id: c_prom_id,
  665 + store_id: os.stoid,
  666 + user_id: getApp().globalData.userInfo.user_id,
  667 + goods_price:item.goods_price
673 }; 668 };
674 - getApp().request.put("/api/weshop/cart/update", {  
675 - data: updata1,  
676 - })  
677 - 669 + // getApp().request.put("/api/weshop/cart/update", {
  670 + // data: updata1,
  671 + // })
  672 + cart_up_data.push(updata1);
678 } 673 }
679 674
680 //判断如果是普通商品,后面参加活动了,变成失效商品 675 //判断如果是普通商品,后面参加活动了,变成失效商品
@@ -682,24 +677,16 @@ Page({ @@ -682,24 +677,16 @@ Page({
682 677
683 var prom = null; 678 var prom = null;
684 var now = ut.gettimestamp(); 679 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 - } 680 + let prom_arr = item.goodsActinfo;
  681 + if(prom_arr && prom_arr.length){
  682 + for (var im = 0; im <prom_arr.length; im++) {
  683 + var a_item = prom_arr[im];
  684 + if (a_item.s_time < now) {
  685 + if (!prom) prom = [];
  686 + prom.push(a_item);
700 } 687 }
701 } 688 }
702 - }) 689 + }
703 690
704 //只有一种活动,但是又是秒杀之类是互动,就要失效。不能是普通购买 691 //只有一种活动,但是又是秒杀之类是互动,就要失效。不能是普通购买
705 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) { 692 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) {
@@ -720,41 +707,23 @@ Page({ @@ -720,41 +707,23 @@ Page({
720 th.disInvalid(item); 707 th.disInvalid(item);
721 continue; 708 continue;
722 } 709 }
723 -  
724 } 710 }
725 711
726 } 712 }
727 713
728 -  
729 //优化获取商品的活动购买了几件 714 //优化获取商品的活动购买了几件
730 if (item.prom_type == 1 || item.prom_type == 2) { 715 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 - }) 716 + if(item.promgoodsbuynum){
  717 + promgoodsbuynum=item.promgoodsbuynum;
  718 + }
744 } 719 }
745 -  
746 //如果秒杀活动都去掉了,或者结束了,那么这个商品也没有必要留着 720 //如果秒杀活动都去掉了,或者结束了,那么这个商品也没有必要留着
747 if (item.prom_type == 1) { 721 if (item.prom_type == 1) {
748 - var prom = null; 722 + var prom = item.cartActinfo;
749 var now = ut.gettimestamp(); 723 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 - }) 724 + if(prom){
  725 + prom.price = prom.user_price;
  726 + }
758 //---如果互动都已经过期,或者还未开始,或者无活动 727 //---如果互动都已经过期,或者还未开始,或者无活动
759 if (!prom || prom.is_end == 1 || prom.end_time < now || prom.start_time > now) { 728 if (!prom || prom.is_end == 1 || prom.end_time < now || prom.start_time > now) {
760 // var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id; 729 // var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id;
@@ -807,14 +776,12 @@ Page({ @@ -807,14 +776,12 @@ Page({
807 } 776 }
808 // 判断团购活动都去掉了,或者结束了,那么这个商品也没有必要留着 777 // 判断团购活动都去掉了,或者结束了,那么这个商品也没有必要留着
809 else if (item.prom_type == 2) { 778 else if (item.prom_type == 2) {
810 - var prom = null; 779 + var prom = item.cartActinfo;
811 var now = ut.gettimestamp(); 780 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 - }); 781 + if(prom){
  782 + prom.price = prom.user_price;
  783 + }
  784 +
818 //---如果互动都已经过期,或者还未开始,或者无活动 785 //---如果互动都已经过期,或者还未开始,或者无活动
819 if (!prom || prom.is_end == 1 || prom.end_time < now || prom.start_time > now) { 786 if (!prom || prom.is_end == 1 || prom.end_time < now || prom.start_time > now) {
820 // var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id; 787 // var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id;
@@ -863,8 +830,7 @@ Page({ @@ -863,8 +830,7 @@ Page({
863 item.init_goods_price=good.goods_price; 830 item.init_goods_price=good.goods_price;
864 831
865 //-- 读出每一种商品的所有的活动,方便后面的活动切换使用 -- 832 //-- 读出每一种商品的所有的活动,方便后面的活动切换使用 --
866 - if (item.prom_type == 0)  
867 - th.buy_pro_group(item, 0); 833 + //if (item.prom_type == 0) th.buy_pro_group(item, 0);
868 834
869 var pcid = item.pick_id; 835 var pcid = item.pick_id;
870 var find = 0; 836 var find = 0;
@@ -900,8 +866,15 @@ Page({ @@ -900,8 +866,15 @@ Page({
900 arr.push(ie); 866 arr.push(ie);
901 } 867 }
902 } 868 }
903 - }  
904 869
  870 + //更新一下购物车商品的活动信息
  871 + if(cart_up_data.length>0){
  872 + getApp().request.promisePost('/api/weshop/cart/updateCartPromInfo',{
  873 + is_json:1,
  874 + data:cart_up_data
  875 + })
  876 + }
  877 + }
905 if (th.data.is_open_offline && th.data.is_open_offline > 0 && th.data.sales_rules == 2) { 878 if (th.data.is_open_offline && th.data.is_open_offline > 0 && th.data.sales_rules == 2) {
906 //-- 此时要实时更新线下取价价格 -- 879 //-- 此时要实时更新线下取价价格 --
907 for (var i = 0; i < arr.length; i++) { 880 for (var i = 0; i < arr.length; i++) {
@@ -920,11 +893,14 @@ Page({ @@ -920,11 +893,14 @@ Page({
920 } 893 }
921 } 894 }
922 895
  896 + //-- 2024-2-3 深拷贝数据缓存 --
  897 + th.data.dp_car=ut.deep_cp(arr);
923 th.setData({ 898 th.setData({
924 requestData: arr, 899 requestData: arr,
925 all_num: all_num, 900 all_num: all_num,
926 is_load: 1, 901 is_load: 1,
927 - is_edit: 0 902 + is_edit: 0,
  903 + checkAllToggle:0
928 }), 904 }),
929 th.doCheckAll(), wx.stopPullDownRefresh(); 905 th.doCheckAll(), wx.stopPullDownRefresh();
930 906
@@ -1224,7 +1200,6 @@ Page({ @@ -1224,7 +1200,6 @@ Page({
1224 1200
1225 if (a = isNaN(t.detail.value) || t.detail.value < 1 ? 1 : parseInt(t.detail.value)) { 1201 if (a = isNaN(t.detail.value) || t.detail.value < 1 ? 1 : parseInt(t.detail.value)) {
1226 //this.clear_req(); 1202 //this.clear_req();
1227 -  
1228 var s = { 1203 var s = {
1229 goods_num: a, 1204 goods_num: a,
1230 goods_id: e.goods_id, 1205 goods_id: e.goods_id,
@@ -1237,14 +1212,14 @@ Page({ @@ -1237,14 +1212,14 @@ Page({
1237 1212
1238 //-------------加减数量的时候,要把show_can_cx清理掉, 1213 //-------------加减数量的时候,要把show_can_cx清理掉,
1239 // 同时应该记录一下当前是什么活动那个,如果切换后的活动有跟切换前的活动一样是,就要让切换后的活动的值匹配选中------------- 1214 // 同时应该记录一下当前是什么活动那个,如果切换后的活动有跟切换前的活动一样是,就要让切换后的活动的值匹配选中-------------
1240 -  
1241 clear_req: function () { 1215 clear_req: function () {
1242 var carr = this.data.requestData; 1216 var carr = this.data.requestData;
1243 for (var i = 0; i < carr.length; i++) { 1217 for (var i = 0; i < carr.length; i++) {
1244 - var txt = 'requestData[' + i + '].show_can_cx'  
1245 - this.setData({  
1246 - [txt]: null  
1247 - }); 1218 + var txt = 'requestData[' + i + '].show_can_cx1'
  1219 + this.setData({
  1220 + [txt]: null
  1221 + });
  1222 + this.data.requestData[i].show_can_cx=null;
1248 } 1223 }
1249 }, 1224 },
1250 1225
@@ -1282,7 +1257,7 @@ Page({ @@ -1282,7 +1257,7 @@ Page({
1282 var add_num = 1; 1257 var add_num = 1;
1283 //调用接口判断是不是促销活动的商品 1258 //调用接口判断是不是促销活动的商品
1284 if ([0, 3, 5, 7, 10].indexOf(a.prom_type) > -1) { 1259 if ([0, 3, 5, 7, 10].indexOf(a.prom_type) > -1) {
1285 - var cx_arr = await getApp().get_has_cx_act(a.goods_id); 1260 + var cx_arr = getApp().get_has_cx_act2(a.goodsActinfo);
1286 var steep = getApp().get_limit_qty(a, cx_arr.length, 1); 1261 var steep = getApp().get_limit_qty(a, cx_arr.length, 1);
1287 if (steep > 1) { 1262 if (steep > 1) {
1288 add_num = steep; 1263 add_num = steep;
@@ -1321,7 +1296,7 @@ Page({ @@ -1321,7 +1296,7 @@ Page({
1321 //this.clear_req(); 1296 //this.clear_req();
1322 var add_num = 1; 1297 var add_num = 1;
1323 if ([0, 3, 5, 7, 10].indexOf(a.prom_type) > -1) { 1298 if ([0, 3, 5, 7, 10].indexOf(a.prom_type) > -1) {
1324 - var cx_arr = await getApp().get_has_cx_act(a.goods_id); 1299 + var cx_arr = getApp().get_has_cx_act2(a.goodsActinfo);
1325 var steep = getApp().get_limit_qty(a, cx_arr.length, 1); 1300 var steep = getApp().get_limit_qty(a, cx_arr.length, 1);
1326 if (steep > 1) { 1301 if (steep > 1) {
1327 add_num = steep; 1302 add_num = steep;
@@ -1477,36 +1452,44 @@ Page({ @@ -1477,36 +1452,44 @@ Page({
1477 } 1452 }
1478 }, 1453 },
1479 1454
1480 -  
1481 //---------------全选,全选的时候要判断是否门店的匹配方式一致-------------- 1455 //---------------全选,全选的时候要判断是否门店的匹配方式一致--------------
1482 checkAll: async function () { 1456 checkAll: async function () {
  1457 +
  1458 + console.log('1111');
  1459 + console.log(this.data.clicking);
  1460 +
  1461 + //防止重复点击,弹出加载动画,转圈圈
  1462 + if(this.data.clicking) return false;
  1463 + this.data.clicking=1;
  1464 + this.set_clicking();
  1465 +
1483 var e = this, 1466 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 = ""; 1467 + th = this,
  1468 + dda = e.data.requestData,
  1469 + sdda = e.data.service_data,
  1470 + tfeel = 0,
  1471 + t_num = 0,
  1472 + text_arr = "";
1490 1473
1491 1474
1492 if(this.data.is_edit){ 1475 if(this.data.is_edit){
1493 let val=!e.data.checkAllToggle; 1476 let val=!e.data.checkAllToggle;
1494 if (dda && dda.length > 0) { 1477 if (dda && dda.length > 0) {
1495 - for (var i = 0; i < dda.length; i++) {  
1496 - var item = dda[i].goods; 1478 + for (var i = 0; i < dda.length; i++) {
  1479 + var item = dda[i].goods;
1497 1480
1498 - var txt0 = "requestData[" + i + "].selected";  
1499 - this.setData({  
1500 - [txt0]: val,  
1501 - }); 1481 + var txt0 = "requestData[" + i + "].selected";
  1482 + this.setData({
  1483 + [txt0]: val,
  1484 + });
1502 1485
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 - } 1486 + for (var j = 0; j < item.length; j++) {
  1487 + let txt = "requestData[" + i + "].goods[" + j + "].selected";
  1488 + e.setData({
  1489 + [txt]: val,
  1490 + });
1509 } 1491 }
  1492 + }
1510 } 1493 }
1511 if (sdda && sdda.length > 0) { 1494 if (sdda && sdda.length > 0) {
1512 for (i = 0; i < sdda.length; i++) { 1495 for (i = 0; i < sdda.length; i++) {
@@ -1529,15 +1512,18 @@ Page({ @@ -1529,15 +1512,18 @@ Page({
1529 e.setData({ 1512 e.setData({
1530 checkAllToggle: val, 1513 checkAllToggle: val,
1531 }) 1514 })
  1515 +
  1516 + th.clear_clicking();
1532 return false; 1517 return false;
1533 } 1518 }
1534 1519
1535 if (e.data.requestData && e.data.requestData.length > 0 && 1520 if (e.data.requestData && e.data.requestData.length > 0 &&
1536 - e.data.service_data && e.data.service_data.length > 0) { 1521 + e.data.service_data && e.data.service_data.length > 0) {
1537 wx.showModal({ 1522 wx.showModal({
1538 title: '提示', 1523 title: '提示',
1539 content: '服务卡项目不能和商品一起选择' 1524 content: '服务卡项目不能和商品一起选择'
1540 }); 1525 });
  1526 + th.clear_clicking();
1541 return false; 1527 return false;
1542 } 1528 }
1543 1529
@@ -1550,10 +1536,11 @@ Page({ @@ -1550,10 +1536,11 @@ Page({
1550 if (dda && dda.length > 0) { 1536 if (dda && dda.length > 0) {
1551 for (var i = 0; i < dda.length; i++) { 1537 for (var i = 0; i < dda.length; i++) {
1552 var item = dda[i].goods; 1538 var item = dda[i].goods;
1553 - var txt0 = "requestData[" + i + "].show_can_cx"; 1539 + var txt0 = "requestData[" + i + "].show_can_cx1";
1554 e.setData({ 1540 e.setData({
1555 [txt0]: {}, 1541 [txt0]: {},
1556 }); 1542 });
  1543 + th.data.requestData[i].show_can_cx=null; //清空需要的
1557 1544
1558 if (e.data.checkAllToggle) { 1545 if (e.data.checkAllToggle) {
1559 var txt = "requestData[" + i + "].selected"; 1546 var txt = "requestData[" + i + "].selected";
@@ -1579,43 +1566,44 @@ Page({ @@ -1579,43 +1566,44 @@ Page({
1579 }); 1566 });
1580 1567
1581 if (ob.code == -1) { 1568 if (ob.code == -1) {
1582 -  
1583 wx.showToast({ 1569 wx.showToast({
1584 title: gd_info.goods_name+'购买数量超出商品库存', 1570 title: gd_info.goods_name+'购买数量超出商品库存',
1585 icon: 'none', 1571 icon: 'none',
1586 }); 1572 });
1587 1573
  1574 + th.clear_clicking();
1588 return false; 1575 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 - } 1576 + }
1601 1577
1602 - if (num > ob.CanOutQty) {  
1603 - wx.showToast({  
1604 - title: gd_info.goods_name+'购买数量超出商品库存',  
1605 - icon: 'none',  
1606 - });  
1607 - return false;  
1608 - } 1578 + if (th.data.sales_rules == 3) {
  1579 + var goods_id = gd_info.goods_id;
  1580 + var num = 0;
  1581 +
  1582 + for (let ii = 0; ii< th.data.requestData.length; ii++) {
  1583 + if (i == ii) continue;
  1584 + var it = th.data.requestData[ii].goods.find((e) => {
  1585 + return e.goods_id == goods_id;
  1586 + })
  1587 + if (it && it.selected) num += it.goods_num
  1588 + }
  1589 +
  1590 + if (num > ob.CanOutQty) {
  1591 + wx.showToast({
  1592 + title: gd_info.goods_name+'购买数量超出商品库存',
  1593 + icon: 'none',
  1594 + });
  1595 + th.clear_clicking();
  1596 + return false;
1609 } 1597 }
1610 } 1598 }
1611 - }  
1612 1599
  1600 + }
1613 1601
1614 1602
1615 //-- 判断起购数量 -- 1603 //-- 判断起购数量 --
1616 if (!e.data.checkAllToggle) { 1604 if (!e.data.checkAllToggle) {
1617 //判断是不是有促销活动 1605 //判断是不是有促销活动
1618 - var act = await getApp().get_has_cx_act(obj.goods_id); 1606 + var act = getApp().get_has_cx_act2(obj.goodsActinfo);
1619 th.click_set_limit(obj, i, j, act); 1607 th.click_set_limit(obj, i, j, act);
1620 } 1608 }
1621 1609
@@ -1652,34 +1640,29 @@ Page({ @@ -1652,34 +1640,29 @@ Page({
1652 // if (obj.prom_type == 10) ladder_calc.add_ladder_prom(dda, i, obj); 1640 // if (obj.prom_type == 10) ladder_calc.add_ladder_prom(dda, i, obj);
1653 1641
1654 //多门店,多优惠次数控制 1642 //多门店,多优惠次数控制
1655 - let pro_off1 = false  
1656 - if (!e.data.checkAllToggle) {  
1657 - //判断多店优惠促销次数控制  
1658 - if (th.data.requestData.length > 1) {  
1659 - if (obj.prom_type == 3) {  
1660 -  
1661 - pro_off1 = await th.multiple_stores_pro(i, j)  
1662 - }  
1663 - }  
1664 - }  
1665 -  
1666 - if (pro_off1) {  
1667 - pro_off = true  
1668 - let txt1 = "requestData[" + i + "].pro_off";  
1669 - e.setData({  
1670 - [txt1]: true,  
1671 - [txt]: 0,  
1672 - });  
1673 -  
1674 - wx.showToast({  
1675 - title: '已超出优惠促销次数',  
1676 - icon: 'none',  
1677 - }); 1643 + // let pro_off1 = false
  1644 + // if (!e.data.checkAllToggle) {
  1645 + // //判断多店优惠促销次数控制
  1646 + // if (th.data.requestData.length > 1) {
  1647 + // if (obj.prom_type == 3) {
  1648 + // pro_off1 = await th.multiple_stores_pro(i, j)
  1649 + // }
  1650 + // }
  1651 + // }
  1652 + // if (pro_off1) {
  1653 + // pro_off = true
  1654 + // let txt1 = "requestData[" + i + "].pro_off";
  1655 + // e.setData({
  1656 + // [txt1]: true,
  1657 + // [txt]: 0,
  1658 + // });
  1659 + //
  1660 + // wx.showToast({
  1661 + // title: '已超出优惠促销次数',
  1662 + // icon: 'none',
  1663 + // });
1678 1664
1679 - } else {  
1680 - e.setData({  
1681 - [txt]: !e.data.checkAllToggle,  
1682 - }) 1665 + // } else {
1683 1666
1684 if (!e.data.checkAllToggle) { 1667 if (!e.data.checkAllToggle) {
1685 //组合购的金额要另外算 1668 //组合购的金额要另外算
@@ -1693,10 +1676,16 @@ Page({ @@ -1693,10 +1676,16 @@ Page({
1693 offline_price += (item[j].goods_price - item[j].offline_price) * item[j].goods_num; 1676 offline_price += (item[j].goods_price - item[j].offline_price) * item[j].goods_num;
1694 offline_num += item[j].goods_num; 1677 offline_num += item[j].goods_num;
1695 } 1678 }
1696 - }  
1697 - e.setData({  
1698 - [txt]: !e.data.checkAllToggle,  
1699 - }) 1679 +
  1680 + e.setData({
  1681 + [txt]: !e.data.checkAllToggle,
  1682 + })
  1683 +
  1684 + //}
  1685 +
  1686 +
  1687 +
  1688 +
1700 // if (!e.data.checkAllToggle) { 1689 // if (!e.data.checkAllToggle) {
1701 // //组合购的金额要另外算 1690 // //组合购的金额要另外算
1702 // if (item[j].prom_type != 7 && item[j].prom_type != 10) 1691 // if (item[j].prom_type != 7 && item[j].prom_type != 10)
@@ -1720,79 +1709,79 @@ Page({ @@ -1720,79 +1709,79 @@ Page({
1720 title: '提示', 1709 title: '提示',
1721 content: text_arr + '不能与门店中其他商品一起结算,配送方式不一致' 1710 content: text_arr + '不能与门店中其他商品一起结算,配送方式不一致'
1722 }); 1711 });
  1712 + th.clear_clicking();
1723 return false; 1713 return false;
1724 - } else { 1714 + }
1725 1715
1726 - for (var i = 0; i < dda.length; i++) {  
1727 1716
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 - // } 1717 + for (var i = 0; i < dda.length; i++) {
1742 1718
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) { 1719 + // if (!e.data.checkAllToggle) {
  1720 + //多门店优惠促销次数控制
  1721 + if (dda[i].pro_off || e.data.checkAllToggle) {
  1722 + var txt = "requestData[" + i + "].selected";
1776 e.setData({ 1723 e.setData({
1777 - checkAllToggle: false, 1724 + [txt]: 0,
1778 }); 1725 });
1779 } else { 1726 } else {
  1727 + var txt = "requestData[" + i + "].selected";
1780 e.setData({ 1728 e.setData({
1781 - checkAllToggle: !e.data.checkAllToggle, 1729 + [txt]: 1,
1782 }); 1730 });
1783 } 1731 }
1784 - e.setData({  
1785 - checkAllToggle: !e.data.checkAllToggle,  
1786 - // total_fee: tfeel.toFixed(2),  
1787 - // total_num: t_num, 1732 + // }
1788 1733
1789 - }); 1734 + //总的价格,把组合商品的价格拿出来
  1735 + // var zh_calc_res = zh_calc.calculate_zh(dda, i, this);
  1736 + // tfeel += zh_calc_res.tfeel;
  1737 + // offline_price += zh_calc_res.offline_price;
  1738 + // offline_num += zh_calc_res.offline_num;
  1739 + //
  1740 + // //总的价格,把阶梯促销的商品的价格拿出来
  1741 + // var ladder_calc_res = ladder_calc.calculate_ladder(dda, i, this);
  1742 + // tfeel += ladder_calc_res.tfeel;
  1743 + // offline_price += ladder_calc_res.offline_price;
  1744 + // offline_num += ladder_calc_res.offline_num;
  1745 + //
  1746 + // //当有线下取价的时候
  1747 + // if (offline_price) {
  1748 + // var txt1 = "requestData[" + i + "].offline_price";
  1749 + // var txt2 = "requestData[" + i + "].offline_num";
  1750 + // th.setData({
  1751 + // [txt1]: offline_price.toFixed(2),
  1752 + // [txt2]: offline_num,
  1753 + // });
  1754 + // } else {
  1755 + // if (dda[i].offline_price > 0) {
  1756 + // var txt1 = "requestData[" + i + "].offline_price";
  1757 + // var txt2 = "requestData[" + i + "].offline_num";
  1758 + // th.setData({
  1759 + // [txt1]: 0,
  1760 + // [txt2]: 0
  1761 + // });
  1762 + // }
  1763 + // }
  1764 + }
1790 1765
1791 - this.doCheckAll(function () {  
1792 - e.all_check_prom_activity();  
1793 - }); 1766 + //e.setData({
  1767 + //checkAllToggle: !e.data.checkAllToggle,
  1768 + // total_fee: tfeel.toFixed(2),
  1769 + // total_num: t_num,
  1770 + //});
  1771 +
  1772 + this.doCheckAll(async function () {
  1773 + await e.all_check_prom_activity();
  1774 +
  1775 + //多门店优惠次数控制
  1776 + if (pro_off) {
  1777 + e.setData({
  1778 + checkAllToggle: false,
  1779 + });
  1780 + }
  1781 + th.clear_clicking();
  1782 +
  1783 + });
1794 1784
1795 - }  
1796 } 1785 }
1797 1786
1798 if (sdda && sdda.length > 0) { 1787 if (sdda && sdda.length > 0) {
@@ -1822,28 +1811,40 @@ Page({ @@ -1822,28 +1811,40 @@ Page({
1822 total_fee: tfeel.toFixed(2), 1811 total_fee: tfeel.toFixed(2),
1823 total_num: t_num, 1812 total_num: t_num,
1824 }); 1813 });
1825 - }  
1826 1814
  1815 + th.clear_clicking();
  1816 +
  1817 + }
1827 }, 1818 },
  1819 +
  1820 +
1828 //------门店全选按钮,要判断是否门店的匹配方式一致--------- 1821 //------门店全选按钮,要判断是否门店的匹配方式一致---------
1829 check_th_all_item: async function (ele) { 1822 check_th_all_item: async function (ele) {
  1823 +
  1824 + //防止重复点击
  1825 + if(this.data.clicking) return false;
  1826 + this.data.clicking=1;
  1827 + //加载动画
  1828 + this.set_clicking();
  1829 +
1830 var e = this, 1830 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; 1831 + th = this,
  1832 + pitems = ele.currentTarget.dataset.pitems,
  1833 + item = this.data.requestData[pitems].goods,
  1834 + sele = this.data.requestData[pitems].selected;
1835 this.data.btn_click = 1; 1835 this.data.btn_click = 1;
1836 var garr = e.data.service_data; 1836 var garr = e.data.service_data;
1837 1837
1838 var isok = 1, 1838 var isok = 1,
1839 - fir = 0,  
1840 - iarr = item; 1839 + fir = 0,
  1840 + iarr = item;
1841 1841
1842 //清空-- 多个促销的切换 -- 1842 //清空-- 多个促销的切换 --
1843 - var txt0 = "requestData[" + pitems + "].show_can_cx"; 1843 + var txt0 = "requestData[" + pitems + "].show_can_cx1";
1844 e.setData({ 1844 e.setData({
1845 [txt0]: {}, 1845 [txt0]: {},
1846 }); 1846 });
  1847 + th.data.requestData[pitems].show_can_cx=null; //清空需要的
1847 1848
1848 if (!sele) { 1849 if (!sele) {
1849 1850
@@ -1857,6 +1858,8 @@ Page({ @@ -1857,6 +1858,8 @@ Page({
1857 1858
1858 var txt0 = "requestData[" + pitems + "].selected"; 1859 var txt0 = "requestData[" + pitems + "].selected";
1859 this.setData({[txt0]:1}) 1860 this.setData({[txt0]:1})
  1861 +
  1862 + th.clear_clicking();
1860 return false; 1863 return false;
1861 } 1864 }
1862 1865
@@ -1875,6 +1878,7 @@ Page({ @@ -1875,6 +1878,7 @@ Page({
1875 title: '提示', 1878 title: '提示',
1876 content: '服务卡项目不能和商品一起选择' 1879 content: '服务卡项目不能和商品一起选择'
1877 }); 1880 });
  1881 + th.clear_clicking();
1878 return false; 1882 return false;
1879 } 1883 }
1880 } 1884 }
@@ -1900,6 +1904,7 @@ Page({ @@ -1900,6 +1904,7 @@ Page({
1900 title: '提示', 1904 title: '提示',
1901 content: '同一门店自提和物流的商品不能同时结算' 1905 content: '同一门店自提和物流的商品不能同时结算'
1902 }); 1906 });
  1907 + th.clear_clicking();
1903 return false; 1908 return false;
1904 } 1909 }
1905 1910
@@ -1910,7 +1915,7 @@ Page({ @@ -1910,7 +1915,7 @@ Page({
1910 var gd_info = item[i]; 1915 var gd_info = item[i];
1911 1916
1912 if (!sele) { 1917 if (!sele) {
1913 - var act = await getApp().get_has_cx_act(gd_info.goods_id); 1918 + var act =getApp().get_has_cx_act2(gd_info.goodsActinfo);
1914 th.click_set_limit(gd_info, pitems, i, act) 1919 th.click_set_limit(gd_info, pitems, i, act)
1915 } 1920 }
1916 1921
@@ -1927,62 +1932,73 @@ Page({ @@ -1927,62 +1932,73 @@ Page({
1927 icon: 'none', 1932 icon: 'none',
1928 }); 1933 });
1929 1934
  1935 + th.clear_clicking();
1930 return false; 1936 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 - } 1937 + }
1943 1938
1944 - if (num > ob.CanOutQty) {  
1945 - wx.showToast({  
1946 - title: gd_info.goods_name+'购买数量超出商品库存',  
1947 - icon: 'none',  
1948 - });  
1949 - return false;  
1950 - } 1939 + if (th.data.sales_rules == 3) {
  1940 + var goods_id = gd_info.goods_id;
  1941 + var num = 0;
  1942 +
  1943 + for (let i = 0; i < th.data.requestData.length; i++) {
  1944 + if (pitems == i) continue;
  1945 + var it = th.data.requestData[i].goods.find((e) => {
  1946 + return e.goods_id == goods_id;
  1947 + })
  1948 + if (it && it.selected) num += it.goods_num
  1949 + }
  1950 +
  1951 + if (num > ob.CanOutQty) {
  1952 + wx.showToast({
  1953 + title: gd_info.goods_name+'购买数量超出商品库存',
  1954 + icon: 'none',
  1955 + });
  1956 + th.clear_clicking();
  1957 + return false;
1951 } 1958 }
1952 } 1959 }
  1960 +
1953 } 1961 }
1954 1962
1955 //判断多店优惠促销次数控制 1963 //判断多店优惠促销次数控制
1956 - if (th.data.requestData.length > 1) {  
1957 - if (gd_info.prom_type == 3) {  
1958 - pro_off1 = await th.multiple_stores_pro(pitems, i)  
1959 - }  
1960 - }  
1961 - if (pro_off1) {  
1962 - pro_off = true  
1963 - e.setData({  
1964 - [txt]: 0,  
1965 - });  
1966 - } else {  
1967 - e.setData({  
1968 - [txt]: Number(!sele),  
1969 - });  
1970 - }  
1971 - }  
1972 - var txt = "requestData[" + pitems + "].selected";  
1973 - if (pro_off) {  
1974 - wx.showToast({  
1975 - title: '已超出优惠促销次数',  
1976 - icon: 'none',  
1977 - });  
1978 - e.setData({  
1979 - [txt]: 0,  
1980 - });  
1981 - } else { 1964 + // if (th.data.requestData.length > 1) {
  1965 + // if (gd_info.prom_type == 3) {
  1966 + // pro_off1 = await th.multiple_stores_pro(pitems, i)
  1967 + // }
  1968 + // }
  1969 + // if (pro_off1) {
  1970 + // pro_off = true
  1971 + // e.setData({
  1972 + // [txt]: 0,
  1973 + // });
  1974 + // } else {
  1975 + // e.setData({
  1976 + // [txt]: Number(!sele),
  1977 + // });
  1978 + // }
1982 e.setData({ 1979 e.setData({
1983 [txt]: Number(!sele), 1980 [txt]: Number(!sele),
1984 }); 1981 });
  1982 +
1985 } 1983 }
  1984 + var txt = "requestData[" + pitems + "].selected";
  1985 + // if (pro_off) {
  1986 + // wx.showToast({
  1987 + // title: '已超出优惠促销次数',
  1988 + // icon: 'none',
  1989 + // });
  1990 + // e.setData({
  1991 + // [txt]: 0,
  1992 + // });
  1993 + // } else {
  1994 + // e.setData({
  1995 + // [txt]: Number(!sele),
  1996 + // });
  1997 + // }
  1998 +
  1999 + e.setData({
  2000 + [txt]: Number(!sele),
  2001 + });
1986 2002
1987 //-- 选择了什么商品,就用什么商品来判断 -- 2003 //-- 选择了什么商品,就用什么商品来判断 --
1988 var sele_arr = {}; 2004 var sele_arr = {};
@@ -2023,12 +2039,17 @@ Page({ @@ -2023,12 +2039,17 @@ Page({
2023 if (sele && i == pitems) continue; 2039 if (sele && i == pitems) continue;
2024 await e.check_prom_activity(i); 2040 await e.check_prom_activity(i);
2025 } 2041 }
  2042 +
  2043 + th.clear_clicking();
  2044 +
2026 }); 2045 });
2027 } else { 2046 } else {
  2047 + th.clear_clicking();
2028 wx.showToast({ 2048 wx.showToast({
2029 title: the_res.msg, 2049 title: the_res.msg,
2030 icon: 'none', 2050 icon: 'none',
2031 }); 2051 });
  2052 +
2032 } 2053 }
2033 }) 2054 })
2034 2055
@@ -2036,6 +2057,7 @@ Page({ @@ -2036,6 +2057,7 @@ Page({
2036 2057
2037 //判断多门店,优惠促销次数的控制 2058 //判断多门店,优惠促销次数的控制
2038 async multiple_stores_pro(pitems, item) { 2059 async multiple_stores_pro(pitems, item) {
  2060 +
2039 let a = this.data.requestData[pitems].goods[item]; 2061 let a = this.data.requestData[pitems].goods[item];
2040 let th = this 2062 let th = this
2041 let arr_pro = [] 2063 let arr_pro = []
@@ -2045,21 +2067,31 @@ Page({ @@ -2045,21 +2067,31 @@ Page({
2045 } 2067 }
2046 }) 2068 })
2047 let prom = null 2069 let prom = null
2048 - await getApp().request.promiseGet("/api/weshop/promgoods/get/" + os.stoid + "/" + a.prom_id, {}).then(res => {  
2049 - if (res.data.code == 0) {  
2050 - prom = res.data.data;  
2051 - }  
2052 - })  
2053 - let user_pre_buynum = await this.getUserBuyPromNum_pre(a.prom_id) 2070 + //使用缓存,不在调用接口
  2071 + if(!prom && th.data.yhcx_act_map && th.data.yhcx_act_map[a.prom_id] ){
  2072 + prom=th.data.yhcx_act_map[a.prom_id];
  2073 + }
  2074 + if(!prom) {
  2075 + await getApp().request.promiseGet("/api/weshop/promgoods/get/" + os.stoid + "/" + a.prom_id, {}).then(res => {
  2076 + if (res.data.code == 0) {
  2077 + prom = res.data.data;
  2078 + }
  2079 + })
  2080 + }
2054 2081
  2082 + let user_pre_buynum = await this.getUserBuyPromNum_pre(a.prom_id);
2055 if (user_pre_buynum >= prom.limit_num) { 2083 if (user_pre_buynum >= prom.limit_num) {
2056 return false 2084 return false
2057 } else { 2085 } else {
  2086 +
2058 let action_num = user_pre_buynum + 1; 2087 let action_num = user_pre_buynum + 1;
2059 arr_pro.map(item => { 2088 arr_pro.map(item => {
  2089 + let found = false;
2060 item.goods.map(ite => { 2090 item.goods.map(ite => {
  2091 + if(found) return;
2061 if (ite.prom_type == 3 && ite.prom_id == a.prom_id && !ite.is_gift && ite.selected) { 2092 if (ite.prom_type == 3 && ite.prom_id == a.prom_id && !ite.is_gift && ite.selected) {
2062 action_num += 1; 2093 action_num += 1;
  2094 + found=true;
2063 } 2095 }
2064 }) 2096 })
2065 }) 2097 })
@@ -2074,16 +2106,35 @@ Page({ @@ -2074,16 +2106,35 @@ Page({
2074 }, 2106 },
2075 2107
2076 2108
2077 - 2109 + //清理防止重复点击的状态函数---2024-2-1
  2110 + set_clicking(){
  2111 + wx.showLoading({
  2112 + mark:true
  2113 + });
  2114 + },
  2115 + //清理防止重复点击的状态函数---2024-2-1
  2116 + clear_clicking(){
  2117 + var th=this;
  2118 + wx.hideLoading({
  2119 + complete:function (){
  2120 + th.data.clicking=0;
  2121 + }
  2122 + });
  2123 + },
2078 //---------------单选,也要判断门店的配送方式是否一致-------------- 2124 //---------------单选,也要判断门店的配送方式是否一致--------------
2079 check_th_item: async function (t) { 2125 check_th_item: async function (t) {
  2126 +
  2127 + //防止重复点击
  2128 + if(this.data.clicking) return false;
  2129 + this.data.clicking=1;
  2130 +
2080 var e = this, 2131 var e = this,
2081 - th = this,  
2082 - item = t.currentTarget.dataset.item,  
2083 - pitems = t.currentTarget.dataset.pitems; 2132 + th = this,
  2133 + item = t.currentTarget.dataset.item,
  2134 + pitems = t.currentTarget.dataset.pitems;
2084 a = this.data.requestData[pitems].goods[item]; 2135 a = this.data.requestData[pitems].goods[item];
2085 var isok = 1, 2136 var isok = 1,
2086 - fir = 0; 2137 + fir = 0;
2087 var iarr = e.data.requestData[pitems].goods; 2138 var iarr = e.data.requestData[pitems].goods;
2088 this.data.btn_click = 1; 2139 this.data.btn_click = 1;
2089 var garr = e.data.service_data; 2140 var garr = e.data.service_data;
@@ -2093,9 +2144,10 @@ Page({ @@ -2093,9 +2144,10 @@ Page({
2093 2144
2094 //如果是标记的时候 2145 //如果是标记的时候
2095 if(this.data.is_edit){ 2146 if(this.data.is_edit){
2096 - var txt = "requestData[" + pitems + "].goods[" + item + "].selected";  
2097 - this.setData({[txt]:1})  
2098 - return false; 2147 + var txt = "requestData[" + pitems + "].goods[" + item + "].selected";
  2148 + this.setData({[txt]:1});
  2149 + th.clear_clicking();
  2150 + return false;
2099 } 2151 }
2100 2152
2101 2153
@@ -2113,6 +2165,7 @@ Page({ @@ -2113,6 +2165,7 @@ Page({
2113 title: '提示', 2165 title: '提示',
2114 content: '服务卡项目不能和商品一起选择' 2166 content: '服务卡项目不能和商品一起选择'
2115 }); 2167 });
  2168 + th.clear_clicking();
2116 return false; 2169 return false;
2117 } 2170 }
2118 } 2171 }
@@ -2142,112 +2195,119 @@ Page({ @@ -2142,112 +2195,119 @@ Page({
2142 title: '提示', 2195 title: '提示',
2143 content: '同一门店自提和物流的商品不能同时结算' 2196 content: '同一门店自提和物流的商品不能同时结算'
2144 }); 2197 });
2145 - } else {  
2146 - var txt = "requestData[" + pitems + "].goods[" + item + "].selected";  
2147 - var gd_info = a; 2198 + th.clear_clicking();
  2199 + return false;
  2200 + }
2148 2201
2149 - var erpwareid = gd_info.erpwareid;  
2150 2202
2151 - //-- 如果是选中的时候 --  
2152 - if (!a.selected) { 2203 + var txt = "requestData[" + pitems + "].goods[" + item + "].selected";
  2204 + var gd_info = a;
2153 2205
2154 - th.data.pitems=pitems; 2206 + var erpwareid = gd_info.erpwareid;
2155 2207
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) { 2208 + //-- 如果是选中的时候 --
  2209 + if (!a.selected) {
2161 2210
2162 - var ob = {};  
2163 - await th.check_down_line_next(gd_info, pitems, item, erpwareid, function (res) {  
2164 - ob = res; 2211 + th.data.pitems=pitems;
  2212 +
  2213 + //判断是不是有促销活动
  2214 + var act = getApp().get_has_cx_act2(gd_info.goodsActinfo);
  2215 + //-- 专门来设置商品订购数量 --
  2216 + th.click_set_limit(gd_info, pitems, item, act)
  2217 + if (th.data.sales_rules >= 2 && !gd_info.whsle_id && [1, 2, 4, 6, 8, 9].indexOf(gd_info.prom_type) == -1) {
  2218 +
  2219 + var ob = {};
  2220 + await th.check_down_line_next(gd_info, pitems, item, erpwareid, function (res) {
  2221 + ob = res;
  2222 + });
  2223 + if (ob.code == -1) {
  2224 + wx.showToast({
  2225 + title: '购买数量超出商品库存',
  2226 + icon: 'none',
2165 }); 2227 });
2166 - if (ob.code == -1) { 2228 + th.clear_clicking();
  2229 + return false;
  2230 + }
  2231 +
  2232 + if (th.data.sales_rules == 3) {
  2233 + var goods_id = gd_info.goods_id;
  2234 + var num = 0;
  2235 +
  2236 + for (let i = 0; i < th.data.requestData.length; i++) {
  2237 + if (pitems == i) continue;
  2238 + var it = th.data.requestData[i].goods.find((e) => {
  2239 + return e.goods_id == goods_id;
  2240 + })
  2241 + if (it && it.selected) num += it.goods_num
  2242 + }
2167 2243
  2244 + if (num > ob.CanOutQty) {
2168 wx.showToast({ 2245 wx.showToast({
2169 title: '购买数量超出商品库存', 2246 title: '购买数量超出商品库存',
2170 icon: 'none', 2247 icon: 'none',
2171 }); 2248 });
2172 - 2249 + th.clear_clicking();
2173 return false; 2250 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 } 2251 }
2197 -  
2198 } 2252 }
  2253 +
2199 } 2254 }
  2255 + }
2200 2256
  2257 + // let pro_off = false
  2258 + // //判断多店优惠促销次数控制
  2259 + // if (th.data.requestData.length > 1) {
  2260 + // if (a.prom_type == 3 && !a.selected) {
  2261 + // pro_off = await th.multiple_stores_pro(pitems, item)
  2262 + // }
  2263 + // }
  2264 + //
  2265 + // if (pro_off) {
  2266 + // wx.showToast({
  2267 + // title: '已超出优惠促销次数',
  2268 + // icon: 'none',
  2269 + // });
  2270 + // th.clear_clicking();
  2271 + // return false;
  2272 + // }
2201 2273
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 - }  
2208 - } 2274 + var txt0 = "requestData[" + pitems + "].show_can_cx";
  2275 + e.setData({
  2276 + [txt0]: {},
  2277 + });
  2278 + th.data.requestData[pitems].show_can_cx=null;
  2279 +
  2280 + //-- 选择了什么商品,就用什么商品来判断 --
  2281 + var sele_arr = {};
  2282 + sele_arr[item] = !a.selected;
  2283 + //回调判断活动有没有冲突
  2284 + this.cx_check_ok(pitems, sele_arr, function (the_res) {
  2285 + if (the_res.code == 0) {
  2286 + th.setData({
  2287 + [txt]: Number(!a.selected),
  2288 + });
  2289 + //要先处理了,再来判断要不要显示凑单
  2290 + th.doCheckAll(async function () {
  2291 + th.data.duo_zp_num_arr={};
  2292 + //判断商品是不是优惠活动
  2293 + for (var i in e.data.requestData) {
  2294 + await e.check_prom_activity(i);
  2295 + }
  2296 + //清理一下点击防止重复点击
  2297 + th.clear_clicking();
2209 2298
2210 - if (pro_off) { 2299 + });
  2300 + } else {
2211 wx.showToast({ 2301 wx.showToast({
2212 - title: '已超出优惠促销次数', 2302 + title: the_res.msg,
2213 icon: 'none', 2303 icon: 'none',
2214 }); 2304 });
2215 - return false;  
2216 } 2305 }
  2306 + })
2217 2307
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 - } 2308 + },
2239 2309
2240 - });  
2241 - } else {  
2242 - wx.showToast({  
2243 - title: the_res.msg,  
2244 - icon: 'none',  
2245 - });  
2246 - }  
2247 - })  
2248 2310
2249 - }  
2250 - },  
2251 2311
2252 //------门店全选按钮,要判断是否门店的匹配方式一致--------- 2312 //------门店全选按钮,要判断是否门店的匹配方式一致---------
2253 check_th_all_item_ser: async function (ele) { 2313 check_th_all_item_ser: async function (ele) {
@@ -2386,6 +2446,9 @@ Page({ @@ -2386,6 +2446,9 @@ Page({
2386 th.data.pitems=-1; 2446 th.data.pitems=-1;
2387 } 2447 }
2388 2448
  2449 +
  2450 +
  2451 + var cur_car_cp=ut.deep_cp(car);
2389 for (var a = 0; a < car.length; a++) { 2452 for (var a = 0; a < car.length; a++) {
2390 var ite1 = car[a].goods; 2453 var ite1 = car[a].goods;
2391 if(car.length>1 && c_ind>-1 && a==c_ind ){ 2454 if(car.length>1 && c_ind>-1 && a==c_ind ){
@@ -2410,6 +2473,29 @@ Page({ @@ -2410,6 +2473,29 @@ Page({
2410 for (var a = 0; a < car.length; a++) { 2473 for (var a = 0; a < car.length; a++) {
2411 //-- 把活动组装进去 --- 2474 //-- 把活动组装进去 ---
2412 var show_can_cx = rd_arr[a]; 2475 var show_can_cx = rd_arr[a];
  2476 + //-- 把活动组装进去 ---
  2477 + let show_can_cx1 = ut.deep_cp(rd_arr[a]);
  2478 + //前端处理渲染的时,要处理一些不需要的字段属性
  2479 + if(show_can_cx1){
  2480 + for (const key in show_can_cx1) {
  2481 + let element = show_can_cx1[key];
  2482 + if(element.cur_act ){
  2483 + delete element.cur_act;
  2484 + }
  2485 + if(element.ch_map){
  2486 + delete element.ch_map;
  2487 + }
  2488 + if(element.act_arr && element.act_arr.length>0){
  2489 + for (var ij = 0; ij < element.act_arr.length; ij++) {
  2490 + var act_ite = element.act_arr[ij];
  2491 + delete act_ite.goods;
  2492 + delete act_ite.act;
  2493 + delete act_ite.key;
  2494 + }
  2495 + }
  2496 + }
  2497 + }
  2498 +
2413 2499
2414 car[a].zh_map = null; 2500 car[a].zh_map = null;
2415 car[a].ladder_map = null; 2501 car[a].ladder_map = null;
@@ -2433,6 +2519,9 @@ Page({ @@ -2433,6 +2519,9 @@ Page({
2433 //-- 先批量判断一下活动的类型,同时要同步跟新 -- 2519 //-- 先批量判断一下活动的类型,同时要同步跟新 --
2434 var offline_price = 0; 2520 var offline_price = 0;
2435 var offline_num = 0; 2521 var offline_num = 0;
  2522 +
  2523 + //-- 优惠促销活动限购次数的优化 --
  2524 + var ch_yc_map={};
2436 for (var c = 0; c < item.length; c++) { 2525 for (var c = 0; c < item.length; c++) {
2437 //清理一下赠品 2526 //清理一下赠品
2438 if (item[c].is_gift) { 2527 if (item[c].is_gift) {
@@ -2445,6 +2534,20 @@ Page({ @@ -2445,6 +2534,20 @@ Page({
2445 continue; 2534 continue;
2446 } 2535 }
2447 2536
  2537 + let pro_off1 = false;
  2538 + //-- 判断活动超出限购,要有选中的情况 --
  2539 + if (item[c].prom_type == 3 && item[c].selected && !ch_yc_map[a.prom_id]) {
  2540 + //一个门店一个优惠促销就判断一次
  2541 + ch_yc_map[a.prom_id]=1;
  2542 + pro_off1 = await th.multiple_stores_pro(a, c)
  2543 + }
  2544 + if (pro_off1) {
  2545 + wx.showToast({
  2546 + title: '已超出优惠促销次数',
  2547 + icon: 'none',
  2548 + });
  2549 + }
  2550 +
2448 all_num += item[c].goods_num; 2551 all_num += item[c].goods_num;
2449 2552
2450 if (item[c].prom_type == 7) { 2553 if (item[c].prom_type == 7) {
@@ -2487,6 +2590,7 @@ Page({ @@ -2487,6 +2590,7 @@ Page({
2487 zh_calc.remove_zhprom(car, a, obj); 2590 zh_calc.remove_zhprom(car, a, obj);
2488 ladder_calc.remove_ladder_prom(car, a, obj); 2591 ladder_calc.remove_ladder_prom(car, a, obj);
2489 2592
  2593 + //-- 如果是未选中的时候 --
2490 if (item[c].selected == 0) { 2594 if (item[c].selected == 0) {
2491 ischeck = 0; 2595 ischeck = 0;
2492 is_s_sele = 0; 2596 is_s_sele = 0;
@@ -2500,9 +2604,18 @@ Page({ @@ -2500,9 +2604,18 @@ Page({
2500 ladder_calc.add_ladder_prom(car, a, obj); 2604 ladder_calc.add_ladder_prom(car, a, obj);
2501 } 2605 }
2502 2606
  2607 + if( cur_car_cp[a].goods[c].goods_price!=th.data.dp_car[a].goods[c].goods_price) {
  2608 + //-- 如果价格有发生变动,要更新界面中的价格显示,还原价格 --
  2609 + let txt = 'requestData[' + a + '].goods[' + c + '].goods_price';
  2610 + th.setData({
  2611 + [txt]: th.data.dp_car[a].goods[c].goods_price
  2612 + })
  2613 + }
  2614 +
2503 2615
2504 } else { 2616 } else {
2505 2617
  2618 + //-- 如果是选中的时候 --
2506 if (item[c].prom_type == 7) { 2619 if (item[c].prom_type == 7) {
2507 //先把商品放入组合计算的专用的区域 2620 //先把商品放入组合计算的专用的区域
2508 console.log('是组合商品---') 2621 console.log('是组合商品---')
@@ -2514,11 +2627,24 @@ Page({ @@ -2514,11 +2627,24 @@ Page({
2514 } else if (item[c].prom_type == 10) { 2627 } else if (item[c].prom_type == 10) {
2515 ladder_calc.add_ladder_prom(car, a, obj); 2628 ladder_calc.add_ladder_prom(car, a, obj);
2516 } else { 2629 } else {
  2630 + //console.log("索引:"+c+",数量:"+item[c].goods_num+",单价:"+item[c].goods_price+",合计:"+item[c].goods_num * item[c].goods_price+",商品:"+item[c].goods_name);
2517 tfeel += item[c].goods_num * item[c].goods_price; 2631 tfeel += item[c].goods_num * item[c].goods_price;
  2632 + //console.log("累计:"+tfeel);
  2633 +
  2634 + //-- 如果价格有发生变动,要更新界面中的价格显示 --
  2635 + if(item[c].goods_price!=th.data.dp_car[a].goods[c].goods_price){
  2636 + let txt='requestData['+a+'].goods['+c+'].goods_price';
  2637 + th.setData({
  2638 + [txt]:item[c].goods_price
  2639 + })
  2640 + }
  2641 +
2518 } 2642 }
2519 t_num += item[c].goods_num; 2643 t_num += item[c].goods_num;
2520 } 2644 }
2521 2645
  2646 +
  2647 +
2522 //-- 如果这个商品是线下取价的时候 -- 2648 //-- 如果这个商品是线下取价的时候 --
2523 if (item[c].is_offline && item[c].prom_type != 7) { 2649 if (item[c].is_offline && item[c].prom_type != 7) {
2524 offline_price += (item[c].goods_price - item[c].offline_price) * item[c].goods_num; 2650 offline_price += (item[c].goods_price - item[c].offline_price) * item[c].goods_num;
@@ -2526,6 +2652,13 @@ Page({ @@ -2526,6 +2652,13 @@ Page({
2526 } 2652 }
2527 } 2653 }
2528 2654
  2655 +
  2656 +
  2657 +
  2658 +
  2659 +
  2660 +
  2661 +
2529 //总的价格,把组合商品的价格拿出来 2662 //总的价格,把组合商品的价格拿出来
2530 var zh_calc_res = zh_calc.calculate_zh(car, a, th); 2663 var zh_calc_res = zh_calc.calculate_zh(car, a, th);
2531 console.log('.组合价-----------') 2664 console.log('.组合价-----------')
@@ -2546,11 +2679,11 @@ Page({ @@ -2546,11 +2679,11 @@ Page({
2546 [txt]: Number(is_s_sele) 2679 [txt]: Number(is_s_sele)
2547 }); 2680 });
2548 2681
2549 - var txt1 = "requestData[" + a + "].show_can_cx";  
2550 - var txt_g = "requestData[" + a + "].goods"; 2682 + var txt1 = "requestData[" + a + "].show_can_cx1";
  2683 + //-- 赋值不渲染 ,只后台计算 --
  2684 + th.data.requestData[a].show_can_cx=show_can_cx;
2551 th.setData({ 2685 th.setData({
2552 - [txt1]: show_can_cx,  
2553 - [txt_g]:item 2686 + [txt1]: show_can_cx1,
2554 }); 2687 });
2555 2688
2556 //-- var et={show_can_cx:show_can_cx}; 2689 //-- var et={show_can_cx:show_can_cx};
@@ -2859,7 +2992,7 @@ Page({ @@ -2859,7 +2992,7 @@ Page({
2859 //-- 这个函数在计算的时候,要包含限购的那一部分 -- 2992 //-- 这个函数在计算的时候,要包含限购的那一部分 --
2860 async normal_check(t, item, pitem, store_count, limit, goodsinfo, wareIds) { 2993 async normal_check(t, item, pitem, store_count, limit, goodsinfo, wareIds) {
2861 2994
2862 - var cx_arr = await getApp().get_has_cx_act(goodsinfo.goods_id); 2995 + var cx_arr = getApp().get_has_cx_act2(goodsinfo.goodsActinfo);
2863 2996
2864 var th = this; 2997 var th = this;
2865 // getApp().my_warnning('购买数量超出商品库存', 0, th); 2998 // getApp().my_warnning('购买数量超出商品库存', 0, th);
@@ -3386,6 +3519,12 @@ Page({ @@ -3386,6 +3519,12 @@ Page({
3386 this.getCardList(); 3519 this.getCardList();
3387 }, 3520 },
3388 3521
  3522 +
  3523 + clear_checkouting(){
  3524 + wx.hideLoading();
  3525 + this.data.checkouting=0;
  3526 + },
  3527 +
3389 //--------------去结算------------ 3528 //--------------去结算------------
3390 async checkout() { 3529 async checkout() {
3391 if (getApp().is_sp_hao()) { 3530 if (getApp().is_sp_hao()) {
@@ -3397,13 +3536,24 @@ Page({ @@ -3397,13 +3536,24 @@ Page({
3397 return false; 3536 return false;
3398 } 3537 }
3399 3538
3400 - if (!this.data.total_num || this.data.total_num <= 0) return false; 3539 + if (!this.data.total_num || this.data.total_num <= 0) {
  3540 + wx.showToast({
  3541 + title: "请选择商品",
  3542 + icon: 'none',
  3543 + duration: 2000
  3544 + });
  3545 + return false;
  3546 + }
3401 if (!this.data.is_load) return false; 3547 if (!this.data.is_load) return false;
3402 if (this.data.up_dating) { 3548 if (this.data.up_dating) {
3403 wx.showLoading({ 3549 wx.showLoading({
3404 title: "计算中" 3550 title: "计算中"
3405 }) 3551 })
3406 } 3552 }
  3553 + //--- 避免重复点击 ---
  3554 + if(this.data.checkouting) return false;
  3555 + this.data.checkouting=1;
  3556 +
3407 var garr = this.data.requestData; 3557 var garr = this.data.requestData;
3408 var check_is_goods_selected = 0; 3558 var check_is_goods_selected = 0;
3409 3559
@@ -3445,14 +3595,14 @@ Page({ @@ -3445,14 +3595,14 @@ Page({
3445 3595
3446 var pid=this.data.requestData[i].pid; 3596 var pid=this.data.requestData[i].pid;
3447 var _pick=null; 3597 var _pick=null;
3448 - //获取商品信息,包含线下商品ID,指定门店销售的信息  
3449 - var rh=await getApp().request.promiseGet("/api/weshop/pickup/get/"+os.stoid+"/"+pid, {});  
3450 - if(rh && rh.data.code==0){  
3451 - _pick=rh.data.data;  
3452 - }  
3453 -  
3454 var i_arr = this.data.requestData[i].goods; 3598 var i_arr = this.data.requestData[i].goods;
3455 3599
  3600 + //-- 优化不用调用接口 --
  3601 + _pick={
  3602 + pickup_id:pid,
  3603 + distr_type:i_arr[0].pickup_distr_type
  3604 + };
  3605 +
3456 //判断一下商品能不能满足优惠促销的条件 3606 //判断一下商品能不能满足优惠促销的条件
3457 await th.check_can_yh_pro(i_arr); 3607 await th.check_can_yh_pro(i_arr);
3458 3608
@@ -3498,15 +3648,14 @@ Page({ @@ -3498,15 +3648,14 @@ Page({
3498 if(yh_by_map[ky]){ 3648 if(yh_by_map[ky]){
3499 ky_n+=yh_by_map[ky]; 3649 ky_n+=yh_by_map[ky];
3500 } 3650 }
3501 -  
3502 //-- 判断优惠促销活动的商品的限购,can_yh 表示商品满足优惠促销的条件 -- 3651 //-- 判断优惠促销活动的商品的限购,can_yh 表示商品满足优惠促销的条件 --
3503 if(i_arr[j].prom_type==3 && fd1.act.goodslimit>0 && i_arr[j].can_yh ){ 3652 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 - } 3653 + var p_can_by=fd1.act.goodslimit-fd1.act.goodslimited;
  3654 + if(i_arr[j].goods_num+ky_n>p_can_by){
  3655 + getApp().confirmBox(i_arr[j].goods_name + "超出活动限购数量"+fd1.act.goodslimit+"件");
  3656 + wx.hideLoading();
  3657 + return false;
  3658 + }
3510 } 3659 }
3511 //-- 把购物数量记录到map表中 -- 3660 //-- 把购物数量记录到map表中 --
3512 if(!yh_by_map[ky]) yh_by_map[ky]=0; 3661 if(!yh_by_map[ky]) yh_by_map[ky]=0;
@@ -3516,10 +3665,8 @@ Page({ @@ -3516,10 +3665,8 @@ Page({
3516 } 3665 }
3517 3666
3518 3667
3519 -  
3520 -  
3521 -  
3522 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) ) { 3668 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) ) {
  3669 +
3523 let userbuynum = await this.getUserBuyPromNum(i_arr[j].prom_id); 3670 let userbuynum = await this.getUserBuyPromNum(i_arr[j].prom_id);
3524 3671
3525 if(!zh_buyed_m[i_arr[j].prom_id]) zh_buyed_m[i_arr[j].prom_id]=userbuynum; 3672 if(!zh_buyed_m[i_arr[j].prom_id]) zh_buyed_m[i_arr[j].prom_id]=userbuynum;
@@ -3537,10 +3684,10 @@ Page({ @@ -3537,10 +3684,10 @@ Page({
3537 checkArr7.push(i_arr[j]) 3684 checkArr7.push(i_arr[j])
3538 }else{ 3685 }else{
3539 if (zh_all_ck[i_arr[j].prom_id]) { 3686 if (zh_all_ck[i_arr[j].prom_id]) {
3540 - //相同门店只记录一单 3687 + //相同门店只记录一单
3541 if(zh_all_ck[i_arr[j].prom_id].indexOf(i)==-1) zh_all_ck[i_arr[j].prom_id].push(i); 3688 if(zh_all_ck[i_arr[j].prom_id].indexOf(i)==-1) zh_all_ck[i_arr[j].prom_id].push(i);
3542 } else { 3689 } else {
3543 - zh_all_ck[i_arr[j].prom_id] = [i]; 3690 + zh_all_ck[i_arr[j].prom_id] = [i];
3544 } 3691 }
3545 3692
3546 } 3693 }
@@ -3548,7 +3695,7 @@ Page({ @@ -3548,7 +3695,7 @@ Page({
3548 //-- 优惠活动次数限制,相同门店的相同prom_id只能算一次 -- 3695 //-- 优惠活动次数限制,相同门店的相同prom_id只能算一次 --
3549 if (i_arr[j].prom_type == 3) { 3696 if (i_arr[j].prom_type == 3) {
3550 if (checkObj3[i_arr[j].prom_id]) { 3697 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); 3698 + if(checkObj3[i_arr[j].prom_id].indexOf(i)==-1) checkObj3[i_arr[j].prom_id].push(i);
3552 } else { 3699 } else {
3553 checkObj3[i_arr[j].prom_id] = [i]; 3700 checkObj3[i_arr[j].prom_id] = [i];
3554 } 3701 }
@@ -3556,11 +3703,11 @@ Page({ @@ -3556,11 +3703,11 @@ Page({
3556 3703
3557 //如果是普通购买的时候。 3704 //如果是普通购买的时候。
3558 if(i_arr[j].is_integral_normal || i_arr[j].is_pd_normal ){ 3705 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 - } 3706 + //-- 四大促销 --
  3707 + if([3,5,7,10].indexOf(i_arr[j].prom_tyoe)==-1){
  3708 + i_arr[j].prom_id=0;
  3709 + i_arr[j].prom_type=0;
  3710 + }
3564 } 3711 }
3565 3712
3566 //map 的key是不会重复,会覆盖,, 3713 //map 的key是不会重复,会覆盖,,
@@ -3570,6 +3717,7 @@ Page({ @@ -3570,6 +3717,7 @@ Page({
3570 goods_price: i_arr[j].goods_price, 3717 goods_price: i_arr[j].goods_price,
3571 prom_id: i_arr[j].prom_id, 3718 prom_id: i_arr[j].prom_id,
3572 prom_type: i_arr[j].prom_type, 3719 prom_type: i_arr[j].prom_type,
  3720 + g_num:i_arr[j].goods_num //新增
3573 }; 3721 };
3574 //判断是不是线下取价 3722 //判断是不是线下取价
3575 if (i_arr[j].is_offline) { 3723 if (i_arr[j].is_offline) {
@@ -3579,35 +3727,33 @@ Page({ @@ -3579,35 +3727,33 @@ Page({
3579 } 3727 }
3580 g_arr.push(ie); 3728 g_arr.push(ie);
3581 3729
3582 - if (map.has(i_arr[j].goods_id + "")) {  
3583 - var num11 = map.get(i_arr[j].goods_id + "");  
3584 - var num22 = parseInt(i_arr[j].goods_num) + parseInt(num11);  
3585 - map.set(i_arr[j].goods_id + "", num22);  
3586 - } else {  
3587 - map.set(i_arr[j].goods_id + "", i_arr[j].goods_num); 3730 + //赠品不拿来计算库存
  3731 + if(!i_arr[j].is_gift) {
  3732 + if (map.has(i_arr[j].goods_id + "")) {
  3733 + var num11 = map.get(i_arr[j].goods_id + "");
  3734 + var num22 = parseInt(i_arr[j].goods_num) + parseInt(num11);
  3735 + map.set(i_arr[j].goods_id + "", num22);
  3736 + } else {
  3737 + map.set(i_arr[j].goods_id + "", i_arr[j].goods_num);
  3738 + }
3588 } 3739 }
3589 //glist += i_arr[j].goods_id + ","; 3740 //glist += i_arr[j].goods_id + ",";
3590 3741
3591 if(!i_arr[j].is_gift){ 3742 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); 3743 + var et= {"prom_type":i_arr[j].prom_type,"prom_id":i_arr[j].prom_id,"goods_id":i_arr[j].goods_id};
  3744 + glist.push(et);
3594 } 3745 }
3595 ab = 1; 3746 ab = 1;
3596 3747
3597 //-- 获取促销活动是不是有参与 -- 3748 //-- 获取促销活动是不是有参与 --
3598 - var act = await getApp().get_has_cx_act(i_arr[j].goods_id); 3749 + var act = getApp().get_has_cx_act2(i_arr[j].goodsActinfo);
3599 //-- 判断商品的起订数量 -- 3750 //-- 判断商品的起订数量 --
3600 var mo_num = getApp().get_limit_qty(i_arr[j], act.length); 3751 var mo_num = getApp().get_limit_qty(i_arr[j], act.length);
3601 var steep = getApp().get_limit_qty(i_arr[j], act.length, 1); 3752 var steep = getApp().get_limit_qty(i_arr[j], act.length, 1);
3602 var py_type = parseInt(i_arr[j].prom_type + ''); 3753 var py_type = parseInt(i_arr[j].prom_type + '');
3603 3754
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 - 3755 + //-- 商品只查一次。看一下有没有,门店之前第一次就赋值了 --
  3756 + var gd = i_arr[j];
3611 //判断秒杀的指定门店和团购的指定门店 3757 //判断秒杀的指定门店和团购的指定门店
3612 if([1,2].indexOf(py_type)>-1 && i_arr[j].prom && i_arr[j].prom.pick_up_lists){ 3758 if([1,2].indexOf(py_type)>-1 && i_arr[j].prom && i_arr[j].prom.pick_up_lists){
3613 var idx0=i_arr[j].prom.pick_up_lists.findIndex(function (e){ 3759 var idx0=i_arr[j].prom.pick_up_lists.findIndex(function (e){
@@ -3620,7 +3766,7 @@ Page({ @@ -3620,7 +3766,7 @@ Page({
3620 if(py_type==2) act_type='团购'; 3766 if(py_type==2) act_type='团购';
3621 3767
3622 getApp().confirmBox(i_arr[j].goods_name + act_type+"活动的门店不可售"); 3768 getApp().confirmBox(i_arr[j].goods_name + act_type+"活动的门店不可售");
3623 - wx.hideLoading(); 3769 + th.clear_checkouting();
3624 return false; 3770 return false;
3625 } 3771 }
3626 } 3772 }
@@ -3628,19 +3774,19 @@ Page({ @@ -3628,19 +3774,19 @@ Page({
3628 if ([0, 3, 5, 7, 10].indexOf(py_type) > -1) { 3774 if ([0, 3, 5, 7, 10].indexOf(py_type) > -1) {
3629 //如果是指定门店,就要判断 3775 //如果是指定门店,就要判断
3630 if(gd.pick_group_ids){ 3776 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 - } 3777 + var idx0=gd.pick_up_lists.findIndex(function (e){
  3778 + return e.pickup_id==i_arr[j].pick_id;
  3779 + })
  3780 + if(idx0<0){
  3781 + getApp().confirmBox(i_arr[j].goods_name + "的门店不可售");
  3782 + th.clear_checkouting();
  3783 + return false;
  3784 + }
3639 } 3785 }
3640 3786
3641 if (mo_num > i_arr[j].goods_num) { 3787 if (mo_num > i_arr[j].goods_num) {
3642 getApp().confirmBox(i_arr[j].goods_name + "的未达到起订数量"); 3788 getApp().confirmBox(i_arr[j].goods_name + "的未达到起订数量");
3643 - wx.hideLoading(); 3789 + th.clear_checkouting();
3644 return false; 3790 return false;
3645 } 3791 }
3646 if (steep > 1 && (i_arr[j].goods_num - mo_num) % steep != 0) { 3792 if (steep > 1 && (i_arr[j].goods_num - mo_num) % steep != 0) {
@@ -3655,7 +3801,7 @@ Page({ @@ -3655,7 +3801,7 @@ Page({
3655 3801
3656 th.postCardList(e, j, i); 3802 th.postCardList(e, j, i);
3657 3803
3658 - wx.hideLoading(); 3804 + th.clear_checkouting();
3659 return false; 3805 return false;
3660 } 3806 }
3661 3807
@@ -3672,7 +3818,7 @@ Page({ @@ -3672,7 +3818,7 @@ Page({
3672 }); 3818 });
3673 if (ob.code == -1) { 3819 if (ob.code == -1) {
3674 t.my_warnning(gd.goods_name + "门店库存不足", 0, th); 3820 t.my_warnning(gd.goods_name + "门店库存不足", 0, th);
3675 - wx.hideLoading(); 3821 + th.clear_checkouting();
3676 return false; 3822 return false;
3677 } 3823 }
3678 3824
@@ -3685,7 +3831,7 @@ Page({ @@ -3685,7 +3831,7 @@ Page({
3685 if (res.data.code == 0) { 3831 if (res.data.code == 0) {
3686 if (!res.data.data.promGoodsLists) { 3832 if (!res.data.data.promGoodsLists) {
3687 t.my_warnning(i_arr[j].goods_name + "优惠活动已经过期", 0, th); 3833 t.my_warnning(i_arr[j].goods_name + "优惠活动已经过期", 0, th);
3688 - wx.hideLoading(); 3834 + th.clear_checkouting();
3689 is_ok = 0; 3835 is_ok = 0;
3690 } 3836 }
3691 } 3837 }
@@ -3698,20 +3844,21 @@ Page({ @@ -3698,20 +3844,21 @@ Page({
3698 3844
3699 } else { 3845 } else {
3700 if (i_arr[j].is_gift == 1) continue; 3846 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 - }); 3847 + // rq.put("/api/weshop/cart/update", {
  3848 + // data: {
  3849 + // id: i_arr[j].id,
  3850 + // selected: 0,
  3851 + // store_id: oo.stoid
  3852 + // },
  3853 + // success: function (ee) {
  3854 + // console.log(ee);
  3855 + // }
  3856 + // });
3711 } 3857 }
3712 } 3858 }
3713 } 3859 }
3714 3860
  3861 +
3715 console.log(checkObj3); 3862 console.log(checkObj3);
3716 let checkObj3_off = false 3863 let checkObj3_off = false
3717 3864
@@ -3761,7 +3908,7 @@ Page({ @@ -3761,7 +3908,7 @@ Page({
3761 3908
3762 if (checkObj3_off) { 3909 if (checkObj3_off) {
3763 t.my_warnning("已超出优惠促销次数", 0, th); 3910 t.my_warnning("已超出优惠促销次数", 0, th);
3764 - wx.hideLoading(); 3911 + th.clear_checkouting();
3765 return false 3912 return false
3766 } 3913 }
3767 3914
@@ -3770,23 +3917,23 @@ Page({ @@ -3770,23 +3917,23 @@ Page({
3770 let zh_ck_arr = Object.keys(zh_limit_m); 3917 let zh_ck_arr = Object.keys(zh_limit_m);
3771 if(zh_ck_arr && zh_ck_arr.length ){ 3918 if(zh_ck_arr && zh_ck_arr.length ){
3772 for (let xg = 0; xg < zh_ck_arr.length; xg++) { 3919 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 - } 3920 + var ky=zh_ck_arr[xg];
  3921 + var zh_buyed=zh_buyed_m[ky]?zh_buyed_m[ky]:0;
  3922 + var zh_limit=zh_limit_m[ky]?zh_limit_m[ky]:0;
  3923 + var zh_all=zh_all_ck[ky]?zh_all_ck[ky].length:0;
  3924 + if(zh_limit<=0) continue;
  3925 +
  3926 + if(zh_all+zh_buyed>zh_limit){
  3927 + zh_off=true;
  3928 + break;
  3929 + }
3783 } 3930 }
3784 } 3931 }
3785 3932
3786 if (zh_off) { 3933 if (zh_off) {
3787 - t.my_warnning("已超出组合购优惠次数", 0, th);  
3788 - wx.hideLoading();  
3789 - return false 3934 + t.my_warnning("已超出组合购优惠次数", 0, th);
  3935 + th.clear_checkouting();
  3936 + return false
3790 } 3937 }
3791 3938
3792 3939
@@ -3839,7 +3986,7 @@ Page({ @@ -3839,7 +3986,7 @@ Page({
3839 }) 3986 })
3840 if (ab == 0) { 3987 if (ab == 0) {
3841 t.my_warnning("未选择商品", 0, th); 3988 t.my_warnning("未选择商品", 0, th);
3842 - wx.hideLoading(); 3989 + th.clear_checkouting();
3843 return false; 3990 return false;
3844 } 3991 }
3845 3992
@@ -3848,7 +3995,7 @@ Page({ @@ -3848,7 +3995,7 @@ Page({
3848 3995
3849 3996
3850 } else if (res.cancel) { 3997 } else if (res.cancel) {
3851 - wx.hideLoading(); 3998 + th.clear_checkouting();
3852 console.log('用户点击取消') 3999 console.log('用户点击取消')
3853 } 4000 }
3854 } 4001 }
@@ -3871,7 +4018,7 @@ Page({ @@ -3871,7 +4018,7 @@ Page({
3871 }) 4018 })
3872 if (ab == 0) { 4019 if (ab == 0) {
3873 t.my_warnning("未选择商品", 0, th); 4020 t.my_warnning("未选择商品", 0, th);
3874 - wx.hideLoading(); 4021 + th.clear_checkouting();
3875 return false; 4022 return false;
3876 } 4023 }
3877 4024
@@ -3903,7 +4050,7 @@ Page({ @@ -3903,7 +4050,7 @@ Page({
3903 }) 4050 })
3904 if(idx0<0){ 4051 if(idx0<0){
3905 getApp().confirmBox(i_arr[j].service_name + "秒杀活动的门店不可售"); 4052 getApp().confirmBox(i_arr[j].service_name + "秒杀活动的门店不可售");
3906 - wx.hideLoading(); 4053 + th.clear_checkouting();
3907 return false; 4054 return false;
3908 } 4055 }
3909 } 4056 }
@@ -3923,8 +4070,6 @@ Page({ @@ -3923,8 +4070,6 @@ Page({
3923 } 4070 }
3924 }) 4071 })
3925 4072
3926 -  
3927 - wx.hideLoading();  
3928 getApp().goto("/packageA/pages/cart2_ser/cart2_ser?is_cart=1"); 4073 getApp().goto("/packageA/pages/cart2_ser/cart2_ser?is_cart=1");
3929 } 4074 }
3930 }, 4075 },
@@ -3932,7 +4077,23 @@ Page({ @@ -3932,7 +4077,23 @@ Page({
3932 4077
3933 cart_buy_next(glist,map,g_arr,checkArr7){ 4078 cart_buy_next(glist,map,g_arr,checkArr7){
3934 var th=this; 4079 var th=this;
3935 - var map_limit = new Map(); //使用map值键进行存储限购 4080 + var map_limit = new Map(); //使用map值键进行存储限购,这里存的是活动的
  4081 + var act_buyed_map={}; //活动当前购买数量的map
  4082 + var up_cart_data=[];
  4083 +
  4084 + //获取活动的购买的数量
  4085 + for (let ig = 0; ig <g_arr.length ; ig++) {
  4086 + var t_iter = g_arr[ig];
  4087 + var ky=t_iter.goods_id + "-"+t_iter.prom_type + "-"+t_iter.prom_id;
  4088 + var obj = act_buyed_map[ky];
  4089 + if (obj){
  4090 + obj.g_num+=t_iter.g_num;
  4091 + continue;
  4092 + }
  4093 + var ie = { g_num:t_iter.g_num};
  4094 + act_buyed_map[ky]= ie;
  4095 + }
  4096 +
3936 //--取一下商品的限购 以及活动的限购,redis数量-- 4097 //--取一下商品的限购 以及活动的限购,redis数量--
3937 getApp().request.promisePost("/api/weshop/goods/listGoodsListNumNew", { 4098 getApp().request.promisePost("/api/weshop/goods/listGoodsListNumNew", {
3938 is_json:1, 4099 is_json:1,
@@ -3941,182 +4102,168 @@ Page({ @@ -3941,182 +4102,168 @@ Page({
3941 store_id: oo.stoid 4102 store_id: oo.stoid
3942 } 4103 }
3943 }).then(async ee=>{ 4104 }).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); 4105 + if (ee.data.code == 0 && ee.data.data && ee.data.data.length) {
  4106 + var ddata = ee.data.data,
  4107 + isok = 1,
  4108 + gname = "",
  4109 + err = "";
  4110 +
  4111 + //--组装活动购买的限购--
  4112 + for (var ij = 0; ij < ddata.length; ij++) {
  4113 + var val = ddata[ij];
  4114 + var ky=val.goods_id + "-"+val.prom_type + "-"+val.prom_id;
  4115 + var obj = map_limit.get(ky);
  4116 + if (obj){
  4117 + obj.g_num+=val.goods_num;
  4118 + continue;
3980 } 4119 }
  4120 + var promgoodsbuynum =val.promgoodsbuynum || 0;
  4121 + var goodsbuynum =val.goodsbuynum || 0;
  4122 + var ie = {
  4123 + promgoodsbuynum: promgoodsbuynum,
  4124 + goodsbuynum:goodsbuynum
  4125 + };
  4126 + map_limit.set(ky, ie);
  4127 + }
3981 4128
3982 - //try {  
3983 - for (var ind in ddata) {  
3984 - var val = ddata[ind];  
3985 - var num = map.get(val.goods_id + ""); 4129 + //try {
  4130 + for (var ind in ddata) {
  4131 + var val = ddata[ind];
  4132 + var num = map.get(val.goods_id + "");
3986 4133
3987 - var ky=val.goods_id + "-"+val.prom_type + "-"+val.prom_id;  
3988 - var buyed = map_limit.get(ky); 4134 + var ky=val.goods_id + "-"+val.prom_type + "-"+val.prom_id;
  4135 + var buyed = map_limit.get(ky);
  4136 + var cur_buyed=act_buyed_map[ky]
3989 4137
3990 - if (num <= 0) {  
3991 - isok = 0;  
3992 - gname = val.goods_name;  
3993 - throw "购买数量不能为0";  
3994 - return false;  
3995 - } 4138 + if (num <= 0) {
  4139 + isok = 0;
  4140 + gname = val.goods_name;
  4141 + err= "购买数量不能为0";
  4142 + return false;
  4143 + }
3996 4144
3997 - if (val.prom_type == 1 || val.prom_type == 2) { 4145 + if (val.prom_type == 1 || val.prom_type == 2) {
  4146 + var s_num=num;
  4147 + if(th.data.sales_rules> 1) s_num=buyed;
  4148 + if (s_num > val.store_count) {
  4149 + isok = 0;
  4150 + gname = val.goods_name;
  4151 + err="超出库存";
  4152 + return false;
  4153 + }
3998 4154
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 - } 4155 + if(cur_buyed && cur_buyed.g_num > val.redisnum && val.redisnum) {
  4156 + isok = 0;
  4157 + gname = val.goods_name;
  4158 + err="超出活动库存";
  4159 + break;
  4160 + }
4007 4161
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 - } 4162 + if(cur_buyed && buyed.g_num > val.goods_num - val.buy_num && val.goods_num) {
  4163 + isok = 0;
  4164 + gname = val.goods_name;
  4165 + err="超出活动库存";
  4166 + break;
  4167 + }
  4168 + }
4020 4169
4021 - } 4170 + if (th.data.sales_rules == 1 || val.prom_type == 1 || val.prom_type == 2) {
  4171 + if (num > val.store_count) {
  4172 + isok = 0;
  4173 + gname = val.goods_name;
  4174 + err="超出库存";
  4175 + break;
  4176 + }
  4177 + }
  4178 +
  4179 + if (num + buyed.goodsbuynum > val.viplimited && val.viplimited > 0) {
  4180 + isok = 0;
  4181 + gname = val.goods_name;
  4182 + err="超出商品限购";
  4183 + break;
  4184 + }
4022 4185
4023 - if (th.data.sales_rules == 1) {  
4024 - if (num > val.store_count) { 4186 + if (num + buyed.promgoodsbuynum > val.buy_limit && val.buy_limit > 0) {
  4187 + isok = 0;
  4188 + gname = val.goods_name;
  4189 + err="超出活动限购";
  4190 + break;
  4191 + }
  4192 +
  4193 + var card_field = th.data.card_field;
  4194 + for (var i = 0; i < g_arr.length; i++) {
  4195 + if (g_arr[i].goods_id == val.goods_id) {
  4196 +
  4197 + //如果会员是等级会员,商品有等级价,且不是活动商品
  4198 + if (card_field && val[card_field] > 0 &&
  4199 + ((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)) {
  4200 + if (g_arr[i].goods_price != val[card_field]) {
4025 isok = 0; 4201 isok = 0;
4026 gname = val.goods_name; 4202 gname = val.goods_name;
4027 - err="超出库存"; 4203 + err="商品价格已经变化";
  4204 + break;
  4205 + }
  4206 + } else {
  4207 + if (g_arr[i].goods_price != val.shop_price && g_arr[i].goods_price != val.prom_price && val.prom_price > 0) {
  4208 + isok = 0;
  4209 + gname = val.goods_name;
  4210 + err="商品价格已经变化";
4028 break; 4211 break;
4029 } 4212 }
4030 } 4213 }
4031 4214
  4215 + //-- 数据的更新 --
  4216 + var data = {
  4217 + id: g_arr[i].id,
  4218 + selected: 1,
  4219 + store_id: oo.stoid,
  4220 + prom_type: g_arr[i].prom_type,
  4221 + prom_id: g_arr[i].prom_id,
  4222 + };
4032 4223
  4224 + // let gitem = checkArr7.find(item => item.goods_id == g_arr[i].goods_id)
  4225 + // if (gitem) {
  4226 + // data.prom_type = 0
  4227 + // data.prom_id = 0
  4228 + // }
4033 4229
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 - } 4230 + //-- 如果有线下取价的时候 --
  4231 + if (g_arr[i].is_offline) {
  4232 + data.pricing_type = g_arr[i].pricing_type;
  4233 + data.offline_price = g_arr[i].offline_price;
4097 } 4234 }
4098 -  
4099 - if(!isok) break; 4235 + //把更新数组存起来
  4236 + up_cart_data.push(data);
4100 4237
4101 } 4238 }
4102 - // } catch (e) {  
4103 - // err = e;  
4104 - // }  
4105 - if (isok == 0) {  
4106 - t.confirmBox(gname + ":" + err);  
4107 - wx.hideLoading();  
4108 - return false;  
4109 } 4239 }
4110 4240
  4241 + if(!isok) break;
4111 4242
4112 - wx.hideLoading();  
4113 - wx.navigateTo({  
4114 - url: "/packageE/pages/cart/cart2/cart2"  
4115 - });  
4116 } 4243 }
  4244 + // } catch (e) {
  4245 + // err = e;
  4246 + // }
  4247 + if (isok == 0) {
  4248 + t.confirmBox(gname + ":" + err);
  4249 + th.clear_checkouting();
  4250 + return false;
  4251 + }
  4252 +
  4253 + getApp().request.promisePost("/api/weshop/cart/updateCartPromInfo", {
  4254 + is_json: 1,
  4255 + data: up_cart_data,
  4256 + });
  4257 +
  4258 + wx.navigateTo({
  4259 + url: "/packageE/pages/cart/cart2/cart2"
  4260 + });
  4261 + }
4117 }) 4262 })
4118 }, 4263 },
4119 4264
  4265 +
  4266 +
4120 //结算到最后一个商品 4267 //结算到最后一个商品
4121 set_last: function (ab, isok, gname) { 4268 set_last: function (ab, isok, gname) {
4122 if (isok == 0) { 4269 if (isok == 0) {
@@ -4312,10 +4459,15 @@ Page({ @@ -4312,10 +4459,15 @@ Page({
4312 4459
4313 //-- 所有的购物车的数据,要用拷贝的赖进行计算 -- 4460 //-- 所有的购物车的数据,要用拷贝的赖进行计算 --
4314 var alllist = JSON.parse(JSON.stringify(this.data.requestData)); 4461 var alllist = JSON.parse(JSON.stringify(this.data.requestData));
4315 - var list2 = alllist[cindex]; 4462 + //var list2 = alllist[cindex];
4316 var no_gift_arr = []; 4463 var no_gift_arr = [];
4317 4464
4318 - 4465 + //用来存销赠品的--2024-2-1
  4466 + let cart_zp=this.data.cart_zp;
  4467 + //要清空一下门店下的赠品
  4468 + if(cart_zp[list.pid]){
  4469 + cart_zp[list.pid]={};
  4470 + }
4319 //主要判断有没有促销活动 4471 //主要判断有没有促销活动
4320 var is_sele_prom = 0; 4472 var is_sele_prom = 0;
4321 var is_gift_del = 0; 4473 var is_gift_del = 0;
@@ -4343,17 +4495,24 @@ Page({ @@ -4343,17 +4495,24 @@ Page({
4343 map.set(item.prom_id + "", ob); 4495 map.set(item.prom_id + "", ob);
4344 } 4496 }
4345 } 4497 }
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 - } 4498 + //-- list中不再添加和删除赠品,优化list不再添加赠品,2024-02-01 --
  4499 + // if (item.is_gift == 1) {
  4500 + // var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id;
  4501 + // //getApp().request.delete(url, {});
  4502 + // await getApp().request.promiseDelete(url, {}) // 要用同步让赠品删除
  4503 + // list2.goods.splice(i, 1);
  4504 + // list.goods.splice(i--, 1);
  4505 + // is_gift_del = 1;
  4506 + // }
4354 } 4507 }
4355 //--如果没有选中的促销活动的,直接退出 -- 4508 //--如果没有选中的促销活动的,直接退出 --
4356 if (!is_sele_prom) { 4509 if (!is_sele_prom) {
  4510 +
  4511 + //--- 设置单赠品的显示---2024-2-1
  4512 + this.setData({
  4513 + cart_zp
  4514 + })
  4515 +
4357 //如果有赠品,要重新更新购物车的前台渲染-- 4516 //如果有赠品,要重新更新购物车的前台渲染--
4358 if (is_gift_del) { 4517 if (is_gift_del) {
4359 var rq_text = "requestData[" + cindex + "]"; 4518 var rq_text = "requestData[" + cindex + "]";
@@ -4374,6 +4533,10 @@ Page({ @@ -4374,6 +4533,10 @@ Page({
4374 4533
4375 return false; 4534 return false;
4376 } 4535 }
  4536 +
  4537 +
  4538 + //用来判断有没有list大小发生变化
  4539 + let is_change_list=0;
4377 //-- 循环判断活动 -- 4540 //-- 循环判断活动 --
4378 for (let p_item of map.entries()) { 4541 for (let p_item of map.entries()) {
4379 var prom = null; 4542 var prom = null;
@@ -4398,12 +4561,15 @@ Page({ @@ -4398,12 +4561,15 @@ Page({
4398 //如果活动已经结束 4561 //如果活动已经结束
4399 if (!prom || prom.is_end || prom.end_time < ut.gettimestamp()) { 4562 if (!prom || prom.is_end || prom.end_time < ut.gettimestamp()) {
4400 for (var ii in list.goods) { 4563 for (var ii in list.goods) {
4401 - var item = list.goods[ii];  
4402 - list.goods.splice(ii, 1); 4564 +
4403 if (item.prom_id == p_item[0] && item.prom_type == 3) { 4565 if (item.prom_id == p_item[0] && item.prom_type == 3) {
4404 // var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id; 4566 // var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id;
4405 // getApp().request.delete(url, {}); 4567 // getApp().request.delete(url, {});
4406 th.disInvalid(item); 4568 th.disInvalid(item);
  4569 +
  4570 + var item = list.goods[ii];
  4571 + list.goods.splice(ii, 1);
  4572 + is_change_list=1;
4407 } 4573 }
4408 } 4574 }
4409 continue; 4575 continue;
@@ -4479,7 +4645,7 @@ Page({ @@ -4479,7 +4645,7 @@ Page({
4479 4645
4480 if (discount) { 4646 if (discount) {
4481 if (!discount.zp_num || parseInt(discount.zp_num) == 0) discount.zp_num = 1; 4647 if (!discount.zp_num || parseInt(discount.zp_num) == 0) discount.zp_num = 1;
4482 - //判断一下赠品的模式 4648 + //判断一下赠品的模式,如果是多赠品的时候
4483 if (parseInt(discount.zp_mode) == 1) { 4649 if (parseInt(discount.zp_mode) == 1) {
4484 4650
4485 var can_zp_num = 0; 4651 var can_zp_num = 0;
@@ -4514,7 +4680,7 @@ Page({ @@ -4514,7 +4680,7 @@ Page({
4514 } else { 4680 } else {
4515 //---如果有打折的信息,赠送的信息,赠送的时候要判断是不是限购数量--- 4681 //---如果有打折的信息,赠送的信息,赠送的时候要判断是不是限购数量---
4516 if (discount && discount['goods_id'] && (!discount.limit_num || discount.limit_num >= discount.bs * discount.zp_num) && 4682 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) { 4683 + discount.gift_storecount >= discount.bs * discount.zp_num) {
4518 //如果这礼品超了情况下 4684 //如果这礼品超了情况下
4519 if (no_gift_arr.indexOf(discount.gift_id) != -1) continue; 4685 if (no_gift_arr.indexOf(discount.gift_id) != -1) continue;
4520 var o = discount.goodsinfo; 4686 var o = discount.goodsinfo;
@@ -4541,7 +4707,7 @@ Page({ @@ -4541,7 +4707,7 @@ Page({
4541 original_img: th.data.imgUrl + o.original_img 4707 original_img: th.data.imgUrl + o.original_img
4542 }; 4708 };
4543 4709
4544 - list2.goods.push(newd); 4710 + //list2.goods.push(newd);
4545 var all_num = 0; 4711 var all_num = 0;
4546 var all_limit_num = 0; 4712 var all_limit_num = 0;
4547 4713
@@ -4568,7 +4734,7 @@ Page({ @@ -4568,7 +4734,7 @@ Page({
4568 } 4734 }
4569 4735
4570 var url = "/api/weshop/cart/delGift?store_id=" + newd.store_id + "&user_id=" + 4736 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 4737 + newd.user_id + "&goods_id=" + newd.goods_id + "&is_gift=1&pick_id=" + newd.pick_id + "&prom_id=" + newd.prom_id
4572 await getApp().request.promiseDelete(url, {}) 4738 await getApp().request.promiseDelete(url, {})
4573 4739
4574 var add_data = null; 4740 var add_data = null;
@@ -4581,18 +4747,30 @@ Page({ @@ -4581,18 +4747,30 @@ Page({
4581 }) 4747 })
4582 if (add_data) { 4748 if (add_data) {
4583 newd.id = add_data.id; 4749 newd.id = add_data.id;
4584 - list.goods.push(newd); 4750 + //list.goods.push(newd);
  4751 + if(!cart_zp[list.pid]) cart_zp[list.pid]={};
  4752 + if(!cart_zp[list.pid].goods) cart_zp[list.pid].goods=[];
  4753 + cart_zp[list.pid].goods.push(newd);
4585 } 4754 }
4586 } 4755 }
4587 } 4756 }
4588 } 4757 }
4589 4758
4590 } 4759 }
4591 - //--更新购物车的前台渲染--  
4592 - var rq_text = "requestData[" + cindex + "]"; 4760 +
  4761 + //--- 设置单赠品的显示---2024-2-1
4593 this.setData({ 4762 this.setData({
4594 - [rq_text]: list  
4595 - }); 4763 + cart_zp
  4764 + })
  4765 +
  4766 + //list大小有变换,才会渲染list
  4767 + if(is_change_list) {
  4768 + //--更新购物车的前台渲染--
  4769 + var rq_text = "requestData[" + cindex + "]";
  4770 + this.setData({
  4771 + [rq_text]: list
  4772 + });
  4773 + }
4596 4774
4597 var diff_text = "requestData[" + cindex + "].make_up_arr"; 4775 var diff_text = "requestData[" + cindex + "].make_up_arr";
4598 //-- 如果有凑单的话 -- 4776 //-- 如果有凑单的话 --
@@ -4620,6 +4798,8 @@ Page({ @@ -4620,6 +4798,8 @@ Page({
4620 4798
4621 }, 4799 },
4622 4800
  4801 +
  4802 +
4623 //优惠促销用户参与次数 4803 //优惠促销用户参与次数
4624 async getUserBuyPromNum_pre(prom_id) { 4804 async getUserBuyPromNum_pre(prom_id) {
4625 var userInfo = getApp().globalData.userInfo; 4805 var userInfo = getApp().globalData.userInfo;
@@ -4634,8 +4814,14 @@ Page({ @@ -4634,8 +4814,14 @@ Page({
4634 return user_pre_buynum 4814 return user_pre_buynum
4635 }, 4815 },
4636 4816
  4817 +
4637 async all_check_prom_activity() { 4818 async all_check_prom_activity() {
4638 this.data.duo_zp_num_arr = {}; 4819 this.data.duo_zp_num_arr = {};
  4820 + //用来存销赠品的--2024-2-1
  4821 + let cart_zp=this.data.cart_zp;
  4822 + //要清空一下赠品数组
  4823 + cart_zp={};
  4824 +
4639 for (var i in this.data.requestData) { 4825 for (var i in this.data.requestData) {
4640 var cindex = i; 4826 var cindex = i;
4641 var make_up_arr = new Array(); 4827 var make_up_arr = new Array();
@@ -4647,9 +4833,9 @@ Page({ @@ -4647,9 +4833,9 @@ Page({
4647 4833
4648 //-- 所有的购物车的数据,要用拷贝的赖进行计算 -- 4834 //-- 所有的购物车的数据,要用拷贝的赖进行计算 --
4649 var alllist = JSON.parse(JSON.stringify(this.data.requestData)); 4835 var alllist = JSON.parse(JSON.stringify(this.data.requestData));
4650 - var list2 = alllist[cindex];  
4651 - var no_gift_arr = []; 4836 + //var list2 = alllist[cindex];
4652 4837
  4838 + var no_gift_arr = [];
4653 4839
4654 //主要判断有没有促销活动 4840 //主要判断有没有促销活动
4655 var is_sele_prom = 0; 4841 var is_sele_prom = 0;
@@ -4677,25 +4863,30 @@ Page({ @@ -4677,25 +4863,30 @@ Page({
4677 map.set(item.prom_id + "", ob); 4863 map.set(item.prom_id + "", ob);
4678 } 4864 }
4679 } 4865 }
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 - } 4866 +
  4867 + //-- list中不再添加和删除赠品,优化list不再添加赠品,2024-02-01 --
  4868 + // if (item.is_gift == 1) {
  4869 + // var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id;
  4870 + // //getApp().request.delete(url, {});
  4871 + // await getApp().request.promiseDelete(url, {}) // 要用同步让赠品删除
  4872 + // list2.goods.splice(i, 1);
  4873 + // list.goods.splice(i--, 1);
  4874 + // is_gift_del = 1;
  4875 + // }
4688 } 4876 }
4689 //--如果没有选中的促销活动的,直接退出 -- 4877 //--如果没有选中的促销活动的,直接退出 --
4690 if (!is_sele_prom) { 4878 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 - 4879 + //如果有赠品,要重新更新购物车的前台渲,list中不再显示--
  4880 + // if (is_gift_del) {
  4881 + // var rq_text = "requestData[" + cindex + "]";
  4882 + // this.setData({
  4883 + // [rq_text]: list
  4884 + // });
  4885 + // }
  4886 + //--- 设置单赠品的显示---2024-2-1
  4887 + this.setData({
  4888 + cart_zp
  4889 + })
4699 var rq_text2 = "requestData[" + cindex + "].make_up_arr"; 4890 var rq_text2 = "requestData[" + cindex + "].make_up_arr";
4700 this.setData({ 4891 this.setData({
4701 [rq_text2]: null, 4892 [rq_text2]: null,
@@ -4707,6 +4898,9 @@ Page({ @@ -4707,6 +4898,9 @@ Page({
4707 }) 4898 })
4708 continue; 4899 continue;
4709 } 4900 }
  4901 +
  4902 + //用来判断有没有list大小发生变化
  4903 + let is_change_list=0;
4710 //-- 循环判断活动 -- 4904 //-- 循环判断活动 --
4711 for (let p_item of map.entries()) { 4905 for (let p_item of map.entries()) {
4712 var prom = null; 4906 var prom = null;
@@ -4714,11 +4908,20 @@ Page({ @@ -4714,11 +4908,20 @@ Page({
4714 if (th.data.promgoods_map[p_item[0]]) { 4908 if (th.data.promgoods_map[p_item[0]]) {
4715 prom = th.data.promgoods_map[p_item[0]]; 4909 prom = th.data.promgoods_map[p_item[0]];
4716 } else { 4910 } else {
4717 - await getApp().request.promiseGet("/api/weshop/promgoods/get/" + os.stoid + "/" + p_item[0], {}).then(res => {  
4718 - if (res.data.code == 0) {  
4719 - prom = res.data.data;  
4720 - }  
4721 - }) 4911 +
  4912 + //使用缓存,不在调用接口
  4913 + if(!prom && th.data.yhcx_act_map && th.data.yhcx_act_map[p_item[0]] ){
  4914 + prom=th.data.yhcx_act_map[p_item[0]];
  4915 + }
  4916 + if(!prom){
  4917 + await getApp().request.promiseGet("/api/weshop/promgoods/get/" + os.stoid + "/" + p_item[0], {}).then(res => {
  4918 + if (res.data.code == 0) {
  4919 + prom = res.data.data;
  4920 + }
  4921 + })
  4922 + }
  4923 +
  4924 +
4722 } 4925 }
4723 let limit_num = 0 4926 let limit_num = 0
4724 let user_pre_buynum = 0 4927 let user_pre_buynum = 0
@@ -4728,13 +4931,17 @@ Page({ @@ -4728,13 +4931,17 @@ Page({
4728 } 4931 }
4729 //如果活动已经结束 4932 //如果活动已经结束
4730 if (!prom || prom.is_end || prom.end_time < ut.gettimestamp()) { 4933 if (!prom || prom.is_end || prom.end_time < ut.gettimestamp()) {
  4934 +
4731 for (var ii in list.goods) { 4935 for (var ii in list.goods) {
4732 - var item = list.goods[ii];  
4733 - list.goods.splice(ii, 1); 4936 +
4734 if (item.prom_id == p_item[0] && item.prom_type == 3) { 4937 if (item.prom_id == p_item[0] && item.prom_type == 3) {
4735 // var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id; 4938 // var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id;
4736 // getApp().request.delete(url, {}); 4939 // getApp().request.delete(url, {});
4737 th.disInvalid(item); 4940 th.disInvalid(item);
  4941 +
  4942 + var item = list.goods[ii];
  4943 + list.goods.splice(ii, 1);
  4944 + is_change_list=1;
4738 } 4945 }
4739 } 4946 }
4740 continue; 4947 continue;
@@ -4763,6 +4970,7 @@ Page({ @@ -4763,6 +4970,7 @@ Page({
4763 if (!promgoods_list) continue; 4970 if (!promgoods_list) continue;
4764 th.data.promgoods_list[p_item[0]] = promgoods_list; 4971 th.data.promgoods_list[p_item[0]] = promgoods_list;
4765 } 4972 }
  4973 +
4766 if (!limit_num || user_pre_buynum < limit_num) { 4974 if (!limit_num || user_pre_buynum < limit_num) {
4767 for (var i in promgoods_list) { 4975 for (var i in promgoods_list) {
4768 var item = promgoods_list[i]; 4976 var item = promgoods_list[i];
@@ -4792,8 +5000,6 @@ Page({ @@ -4792,8 +5000,6 @@ Page({
4792 } 5000 }
4793 } 5001 }
4794 5002
4795 -  
4796 -  
4797 //-- 只有在单赠品的时候,才要进行计算 -- 5003 //-- 只有在单赠品的时候,才要进行计算 --
4798 await getApp().request.promiseGet("/api/weshop/goods/getDiscount", { 5004 await getApp().request.promiseGet("/api/weshop/goods/getDiscount", {
4799 data: { 5005 data: {
@@ -4810,7 +5016,7 @@ Page({ @@ -4810,7 +5016,7 @@ Page({
4810 if (discount) { 5016 if (discount) {
4811 5017
4812 if (!discount.zp_num || parseInt(discount.zp_num) == 0) discount.zp_num = 1; 5018 if (!discount.zp_num || parseInt(discount.zp_num) == 0) discount.zp_num = 1;
4813 - //判断一下赠品的模式 5019 + //-- 判断一下赠品的模式,如果是多赠品的模式 --
4814 if (parseInt(discount.zp_mode) == 1) { 5020 if (parseInt(discount.zp_mode) == 1) {
4815 5021
4816 var can_zp_num = 0; 5022 var can_zp_num = 0;
@@ -4843,7 +5049,7 @@ Page({ @@ -4843,7 +5049,7 @@ Page({
4843 } else { 5049 } else {
4844 //---如果有打折的信息,赠送的信息,赠送的时候要判断是不是限购数量,因为增加了限购数量不限的情况--- 5050 //---如果有打折的信息,赠送的信息,赠送的时候要判断是不是限购数量,因为增加了限购数量不限的情况---
4845 if (discount && discount['goods_id'] && (!discount.limit_num || discount.limit_num >= discount.bs * discount.zp_num) && 5051 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) { 5052 + discount.gift_storecount >= discount.bs * discount.zp_num) {
4847 //如果这礼品超了情况下 5053 //如果这礼品超了情况下
4848 if (no_gift_arr.indexOf(discount.gift_id) != -1) continue; 5054 if (no_gift_arr.indexOf(discount.gift_id) != -1) continue;
4849 var o = discount.goodsinfo; 5055 var o = discount.goodsinfo;
@@ -4870,7 +5076,7 @@ Page({ @@ -4870,7 +5076,7 @@ Page({
4870 original_img: th.data.imgUrl + o.original_img 5076 original_img: th.data.imgUrl + o.original_img
4871 }; 5077 };
4872 5078
4873 - list2.goods.push(newd); 5079 + //list2.goods.push(newd);
4874 var all_num = 0; 5080 var all_num = 0;
4875 var all_limit_num = 0; 5081 var all_limit_num = 0;
4876 5082
@@ -4888,7 +5094,6 @@ Page({ @@ -4888,7 +5094,6 @@ Page({
4888 5094
4889 } 5095 }
4890 } 5096 }
4891 -  
4892 //-- 赠品的数量超出库存数量和会员的限制,这里是保证所有的赠品部会超出 -- 5097 //-- 赠品的数量超出库存数量和会员的限制,这里是保证所有的赠品部会超出 --
4893 if (discount.gift_storecount < all_num + newd.goods_num || (discount.limit_num && discount.limit_num < all_limit_num + newd.goods_num)) { 5098 if (discount.gift_storecount < all_num + newd.goods_num || (discount.limit_num && discount.limit_num < all_limit_num + newd.goods_num)) {
4894 no_gift_arr.push(discount.gift_id); 5099 no_gift_arr.push(discount.gift_id);
@@ -4898,7 +5103,7 @@ Page({ @@ -4898,7 +5103,7 @@ Page({
4898 5103
4899 5104
4900 var url = "/api/weshop/cart/delGift?store_id=" + newd.store_id + "&user_id=" + 5105 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 5106 + newd.user_id + "&goods_id=" + newd.goods_id + "&is_gift=1&pick_id=" + newd.pick_id + "&prom_id=" + newd.prom_id
4902 await getApp().request.promiseDelete(url, {}) 5107 await getApp().request.promiseDelete(url, {})
4903 5108
4904 var add_data = null; 5109 var add_data = null;
@@ -4911,18 +5116,29 @@ Page({ @@ -4911,18 +5116,29 @@ Page({
4911 }) 5116 })
4912 if (add_data) { 5117 if (add_data) {
4913 newd.id = add_data.id; 5118 newd.id = add_data.id;
4914 - list.goods.push(newd); 5119 + //list.goods.push(newd);
  5120 + if(!cart_zp[list.pid]) cart_zp[list.pid]={};
  5121 + if(!cart_zp[list.pid].goods) cart_zp[list.pid].goods=[];
  5122 + cart_zp[list.pid].goods.push(newd);
4915 } 5123 }
4916 } 5124 }
4917 } 5125 }
4918 } 5126 }
4919 -  
4920 } 5127 }
4921 - //--更新购物车的前台渲染--  
4922 - var rq_text = "requestData[" + cindex + "]"; 5128 +
  5129 + //--- 设置单赠品的显示---2024-2-1
4923 this.setData({ 5130 this.setData({
4924 - [rq_text]: list  
4925 - }); 5131 + cart_zp
  5132 + })
  5133 +
  5134 + //list大小有变换,才会渲染list
  5135 + if(is_change_list) {
  5136 + //--更新购物车的前台渲染--
  5137 + var rq_text = "requestData[" + cindex + "]";
  5138 + this.setData({
  5139 + [rq_text]: list
  5140 + });
  5141 + }
4926 5142
4927 var diff_text = "requestData[" + cindex + "].make_up_arr"; 5143 var diff_text = "requestData[" + cindex + "].make_up_arr";
4928 //-- 如果有凑单的话 -- 5144 //-- 如果有凑单的话 --
@@ -4952,6 +5168,8 @@ Page({ @@ -4952,6 +5168,8 @@ Page({
4952 } 5168 }
4953 }, 5169 },
4954 5170
  5171 +
  5172 +
4955 //去凑单 5173 //去凑单
4956 go_cou_dang: function (e) { 5174 go_cou_dang: function (e) {
4957 var prom_id = e.currentTarget.dataset.prom_id; 5175 var prom_id = e.currentTarget.dataset.prom_id;
pages/cart/cart/cart.wxml
@@ -60,7 +60,7 @@ @@ -60,7 +60,7 @@
60 60
61 </view> 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 <view class="order-item" data-item="{{idx}}"> 64 <view class="order-item" data-item="{{idx}}">
65 <block wx:if="{{!items.is_gift}}"> 65 <block wx:if="{{!items.is_gift}}">
66 <view bindtap="check_th_item" class="order-raido flex-vertical " data-check="{{items.selected}}" data-item="{{idx}}" data-pitems="{{pidx}}"> 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,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 <view class="bdb16"> 138 <view class="bdb16">
139 <view bindtap="switch_cx_group" 139 <view bindtap="switch_cx_group"
140 data-index="{{pidx}}" 140 data-index="{{pidx}}"
@@ -142,7 +142,7 @@ @@ -142,7 +142,7 @@
142 class="cx-frame flex" style="position: relative"> 142 class="cx-frame flex" style="position: relative">
143 <view class="cx-sizs fs30">可参促销</view> 143 <view class="cx-sizs fs30">可参促销</view>
144 <view class="flex ai_c f1 pdh20"> 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 <view wx:if="{{item.prom_type==3}}" class="xc-coupon t-c four-level-word {{!item.sele?'gray':'' }}">优惠促销</view> 146 <view wx:if="{{item.prom_type==3}}" class="xc-coupon t-c four-level-word {{!item.sele?'gray':'' }}">优惠促销</view>
147 <view wx:if="{{item.prom_type==5}}" class="xc-coupon t-c four-level-word {{!item.sele?'gray':'' }} ">搭配促销</view> 147 <view wx:if="{{item.prom_type==5}}" class="xc-coupon t-c four-level-word {{!item.sele?'gray':'' }} ">搭配促销</view>
148 <view wx:if="{{item.prom_type==7}}" class="xc-coupon t-c four-level-word {{!item.sele?'gray':'' }} ">组合购</view> 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,11 +159,35 @@
159 159
160 </block > 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 <view class="bdb16" wx:if="{{pitem.is_duo_gd && pitem.act_arr.length>1}}" > 191 <view class="bdb16" wx:if="{{pitem.is_duo_gd && pitem.act_arr.length>1}}" >
168 <view bindtap="switch_cx_group" 192 <view bindtap="switch_cx_group"
169 data-index="{{pidx}}" 193 data-index="{{pidx}}"
utils/more_cx.js
@@ -511,6 +511,10 @@ module.exports = { @@ -511,6 +511,10 @@ module.exports = {
511 } 511 }
512 //-- 判断优惠促销要不要限购 -- 512 //-- 判断优惠促销要不要限购 --
513 var fd=th.data.in_yhact[aid]; 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 if(!fd) { 518 if(!fd) {
515 var fd_res = await getApp().request.promiseGet('/api/weshop/promgoods/get/' + os.stoid + '/' + aid, {}) 519 var fd_res = await getApp().request.promiseGet('/api/weshop/promgoods/get/' + os.stoid + '/' + aid, {})
516 if (fd_res && fd_res.data.code == 0) { 520 if (fd_res && fd_res.data.code == 0) {
@@ -624,9 +628,8 @@ module.exports = { @@ -624,9 +628,8 @@ module.exports = {
624 zh_goods[h].zh_b_num=promgoodsbuynum; 628 zh_goods[h].zh_b_num=promgoodsbuynum;
625 th.data.in_zh_gd_buy_map[ky]=promgoodsbuynum; 629 th.data.in_zh_gd_buy_map[ky]=promgoodsbuynum;
626 } 630 }
627 -  
628 -  
629 } 631 }
  632 +
630 //-- 放到参与组合优惠促销的map中 -- 633 //-- 放到参与组合优惠促销的map中 --
631 th.data.zuhe_map_good[item_act_map.prom_id] = zhact_gdlist; 634 th.data.zuhe_map_good[item_act_map.prom_id] = zhact_gdlist;
632 if(!car_item.zh_prom_goods) car_item.zh_prom_goods={}; 635 if(!car_item.zh_prom_goods) car_item.zh_prom_goods={};
@@ -742,7 +745,7 @@ module.exports = { @@ -742,7 +745,7 @@ module.exports = {
742 }) 745 })
743 746
744 //-- 看一下是不是购物车已经选择好了,购物车选择好了,再确认订单页面也应该是购物车选择的结果,这个也很重要 -- 747 //-- 看一下是不是购物车已经选择好了,购物车选择好了,再确认订单页面也应该是购物车选择的结果,这个也很重要 --
745 - if(!ck_prom_type){ 748 + if(!ck_prom_type && th.data && ! th.data.is_cart){
746 for(var ij=0;ij<k_item.act_arr.length;ij++){ 749 for(var ij=0;ij<k_item.act_arr.length;ij++){
747 var act_gd=k_item.act_arr[ij].goods[0]; 750 var act_gd=k_item.act_arr[ij].goods[0];
748 if(act_gd.prom_type==k_item.act_arr[ij].prom_type){ 751 if(act_gd.prom_type==k_item.act_arr[ij].prom_type){