Commit 238fb1839c0c234436c13ecf3ceb7344f1c24cd2
1 parent
6b519695
购物车要清理掉 赠品,凑单的信息后,才重新计算
Showing
1 changed file
with
45 additions
and
20 deletions
pages/cart/cart/cart.js
| ... | ... | @@ -1440,7 +1440,6 @@ Page({ |
| 1440 | 1440 | [txt0]: {}, |
| 1441 | 1441 | }); |
| 1442 | 1442 | |
| 1443 | - | |
| 1444 | 1443 | if (e.data.checkAllToggle) { |
| 1445 | 1444 | var txt = "requestData[" + i + "].selected"; |
| 1446 | 1445 | e.setData({ |
| ... | ... | @@ -1681,6 +1680,12 @@ Page({ |
| 1681 | 1680 | fir = 0, |
| 1682 | 1681 | iarr = item; |
| 1683 | 1682 | |
| 1683 | + //清空-- 多个促销的切换 -- | |
| 1684 | + var txt0 = "requestData[" + pitems + "].show_can_cx"; | |
| 1685 | + e.setData({ | |
| 1686 | + [txt0]: {}, | |
| 1687 | + }); | |
| 1688 | + | |
| 1684 | 1689 | if (!sele) { |
| 1685 | 1690 | var check_is_service_selected = 0; |
| 1686 | 1691 | for (var ii in garr) { |
| ... | ... | @@ -1837,8 +1842,6 @@ Page({ |
| 1837 | 1842 | |
| 1838 | 1843 | th.doCheckAll(async function () { |
| 1839 | 1844 | |
| 1840 | - | |
| 1841 | - | |
| 1842 | 1845 | e.data.duo_zp_num_arr = {}; |
| 1843 | 1846 | if (sele) { |
| 1844 | 1847 | await e.check_prom_activity(pitems); |
| ... | ... | @@ -2155,7 +2158,7 @@ Page({ |
| 2155 | 2158 | this.doCheckAll(); |
| 2156 | 2159 | }, |
| 2157 | 2160 | |
| 2158 | - //----------检查是否全选--------- | |
| 2161 | + //----------检查是否全选,同时检验各种活动--------- | |
| 2159 | 2162 | doCheckAll: async function (func, n_ok) { |
| 2160 | 2163 | var th = this, |
| 2161 | 2164 | tfeel = 0, |
| ... | ... | @@ -2198,6 +2201,7 @@ Page({ |
| 2198 | 2201 | |
| 2199 | 2202 | if(car.length>1 && c_ind>-1){ |
| 2200 | 2203 | var ite2 = car[c_ind].goods; |
| 2204 | + //检验和设置商品的最终是以 取用什么活动,因为多促销 | |
| 2201 | 2205 | await m_cx.cart_cx_group(th, ite2, car[c_ind], 0, n_ok, (show_can_cx) => { |
| 2202 | 2206 | rd_arr[c_ind]=show_can_cx; |
| 2203 | 2207 | }) |
| ... | ... | @@ -2210,19 +2214,37 @@ Page({ |
| 2210 | 2214 | car[a].zh_map = null; |
| 2211 | 2215 | car[a].ladder_map = null; |
| 2212 | 2216 | |
| 2217 | + //-- 这里是清理了组合购的去凑单 -- | |
| 2213 | 2218 | var txt = "requestData[" + a + "].need_list"; |
| 2214 | 2219 | //car[a].need_list = []; |
| 2215 | 2220 | th.setData({[txt]:[]}); |
| 2221 | + //-- 这里清理赠品 -- | |
| 2222 | + var txt2 = "requestData[" + a + "].send_gift_arr"; | |
| 2223 | + //car[a].need_list = []; | |
| 2224 | + th.setData({[txt2]:[]}); | |
| 2225 | + //-- 这里是清理了优惠的去凑单 -- | |
| 2226 | + var rq_text2 = "requestData[" + a + "].make_up_arr"; | |
| 2227 | + this.setData({ | |
| 2228 | + [rq_text2]: null, | |
| 2229 | + }) | |
| 2216 | 2230 | |
| 2231 | + var item = car[a].goods,is_s_sele = 1; | |
| 2217 | 2232 | |
| 2218 | - var item = car[a].goods, | |
| 2219 | - is_s_sele = 1; | |
| 2220 | 2233 | //-- 先批量判断一下活动的类型,同时要同步跟新 -- |
| 2221 | - | |
| 2222 | 2234 | var offline_price = 0; |
| 2223 | 2235 | var offline_num = 0; |
| 2224 | 2236 | for (var c = 0; c < item.length; c++) { |
| 2225 | - if (item[c].is_gift) continue; | |
| 2237 | + //清理一下赠品 | |
| 2238 | + if (item[c].is_gift) { | |
| 2239 | + var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item[c].id; | |
| 2240 | + //getApp().request.delete(url, {}); | |
| 2241 | + await getApp().request.promiseDelete(url, {}) // 要用同步让赠品删除 | |
| 2242 | + item.splice(c, 1); | |
| 2243 | + //索引要回退一下 | |
| 2244 | + --c; | |
| 2245 | + continue; | |
| 2246 | + } | |
| 2247 | + | |
| 2226 | 2248 | all_num += item[c].goods_num; |
| 2227 | 2249 | |
| 2228 | 2250 | if (item[c].prom_type == 7) { |
| ... | ... | @@ -2253,7 +2275,6 @@ Page({ |
| 2253 | 2275 | |
| 2254 | 2276 | } else { |
| 2255 | 2277 | |
| 2256 | - | |
| 2257 | 2278 | if (item[c].prom_type == 7) { |
| 2258 | 2279 | //先把商品放入组合计算的专用的区域 |
| 2259 | 2280 | console.log('是组合商品---') |
| ... | ... | @@ -2298,8 +2319,10 @@ Page({ |
| 2298 | 2319 | }); |
| 2299 | 2320 | |
| 2300 | 2321 | var txt1 = "requestData[" + a + "].show_can_cx"; |
| 2322 | + var txt_g = "requestData[" + a + "].goods"; | |
| 2301 | 2323 | th.setData({ |
| 2302 | - [txt1]: show_can_cx | |
| 2324 | + [txt1]: show_can_cx, | |
| 2325 | + [txt_g]:item | |
| 2303 | 2326 | }); |
| 2304 | 2327 | |
| 2305 | 2328 | //-- var et={show_can_cx:show_can_cx}; |
| ... | ... | @@ -3093,18 +3116,19 @@ Page({ |
| 3093 | 3116 | getApp().request.put("/api/weshop/cart/update", { |
| 3094 | 3117 | data: t, |
| 3095 | 3118 | success: async function (ee) { |
| 3096 | - var txt = "requestData[" + pitem + "].goods[" + item + "].goods_num"; | |
| 3097 | 3119 | |
| 3098 | - e.setData({ | |
| 3099 | - [txt]: t.goods_num, | |
| 3100 | - }); | |
| 3120 | + e.doCheckAll(async function (){ | |
| 3121 | + var txt = "requestData[" + pitem + "].goods[" + item + "].goods_num"; | |
| 3122 | + e.setData({ | |
| 3123 | + [txt]: t.goods_num, | |
| 3124 | + }); | |
| 3101 | 3125 | |
| 3102 | - e.data.duo_zp_num_arr = {}; | |
| 3103 | - //await e.check_prom_activity(pitem) | |
| 3104 | - for (var i in e.data.requestData) { | |
| 3105 | - await e.check_prom_activity(i) | |
| 3106 | - } | |
| 3107 | - e.doCheckAll(); | |
| 3126 | + e.data.duo_zp_num_arr = {}; | |
| 3127 | + //await e.check_prom_activity(pitem) | |
| 3128 | + for (var i in e.data.requestData) { | |
| 3129 | + await e.check_prom_activity(i) | |
| 3130 | + } | |
| 3131 | + }); | |
| 3108 | 3132 | getApp().requestCardNum(e); |
| 3109 | 3133 | } |
| 3110 | 3134 | }); |
| ... | ... | @@ -4673,6 +4697,7 @@ Page({ |
| 4673 | 4697 | else cx_prom_group[dx].sele = 1; |
| 4674 | 4698 | } |
| 4675 | 4699 | |
| 4700 | + // -- 判断 -- | |
| 4676 | 4701 | this.cx_check_ok2(async function (the_rs) { |
| 4677 | 4702 | if (the_rs.code == 0) { |
| 4678 | 4703 | th.data.change_act = 1; | ... | ... |