Commit d70e54c5b1a38e68a0efa742b3236986a82f2010
1 parent
64abb759
预存支付添加搭配购使用场景
Showing
2 changed files
with
78 additions
and
15 deletions
packageE/pages/cart/cart2/cart2.js
... | ... | @@ -357,7 +357,20 @@ Page({ |
357 | 357 | } else if (this.data.bn_goods.yck_off == 1) { |
358 | 358 | this.setData({ [txt]: 2 }) |
359 | 359 | } |
360 | - this.calculatePrice2()//计算金额 | |
360 | + //搭配购直接购买特殊处理 | |
361 | + if(this.data.collocation_goods){ | |
362 | + let txt = 'cartlist[0].yck_off'; | |
363 | + let txt1 = 'old_cartlist[0].yck_off'; | |
364 | + if (this.data.cartlist[0].yck_off == 2) { | |
365 | + this.setData({ [txt]: 1, [txt1]: 1 }) | |
366 | + } else if (this.data.cartlist[0].yck_off == 1) { | |
367 | + this.setData({ [txt]: 2, [txt1]: 2 }) | |
368 | + } | |
369 | + this.calculatePrice()//计算金额 | |
370 | + }else{ | |
371 | + this.calculatePrice2()//计算金额 | |
372 | + } | |
373 | + | |
361 | 374 | }, |
362 | 375 | //计算商品预存款前置方法------------------------------------ |
363 | 376 | async beforAdvancesum(cartList) { |
... | ... | @@ -1895,7 +1908,7 @@ Page({ |
1895 | 1908 | calculatePrice: async function (qfunc) { |
1896 | 1909 | var th = this; |
1897 | 1910 | th.setData({ submit: 1 }); |
1898 | - | |
1911 | + | |
1899 | 1912 | wx.showLoading({ |
1900 | 1913 | title: "处理中.", |
1901 | 1914 | mask: true |
... | ... | @@ -2102,7 +2115,7 @@ Page({ |
2102 | 2115 | |
2103 | 2116 | var back_data = null; |
2104 | 2117 | var quan_no_goods_arr = null; |
2105 | - var ord_prom =null; | |
2118 | + var ord_prom = null; | |
2106 | 2119 | |
2107 | 2120 | //---判断是不是有订单优惠--- |
2108 | 2121 | await getApp().request.promiseGet("/api/weshop/promorder/getOrderPromotion", { |
... | ... | @@ -2160,7 +2173,7 @@ Page({ |
2160 | 2173 | |
2161 | 2174 | |
2162 | 2175 | //-- 如果没有订单优惠,或者订单优惠中有勾选包邮模板 -- |
2163 | - if(!ord_prom || ord_prom.is_post_temp) { | |
2176 | + if (!ord_prom || ord_prom.is_post_temp) { | |
2164 | 2177 | var user_addr = th.data.user_addr; |
2165 | 2178 | var req_d = { |
2166 | 2179 | province: user_addr.province, city: user_addr.city, district: user_addr.district, |
... | ... | @@ -2351,7 +2364,7 @@ Page({ |
2351 | 2364 | var order_m = 0; |
2352 | 2365 | |
2353 | 2366 | //么有使用券,或者活动没有限制使用优惠券 |
2354 | - if(ord_prom && (quan_price <= 0 || !ord_prom.is_xz_yh)){ | |
2367 | + if (ord_prom && (quan_price <= 0 || !ord_prom.is_xz_yh)) { | |
2355 | 2368 | order_prom_id = ord_prom['id']; |
2356 | 2369 | switch (ord_prom['type']) { |
2357 | 2370 | case 0: |
... | ... | @@ -2438,7 +2451,33 @@ Page({ |
2438 | 2451 | |
2439 | 2452 | //预存金额使用参与计算 |
2440 | 2453 | if (th.data.udata && th.data.udata.Balance > 0 && cart_item.order_amount * 1 > 0) { |
2454 | + | |
2455 | + if (!cart_item.sto) { | |
2456 | + console.log('没有线下门店id'); | |
2457 | + //获取门店信息 | |
2458 | + await getApp().request.promiseGet("/api/weshop/pickup/list", { | |
2459 | + data: { | |
2460 | + store_id: os.stoid, | |
2461 | + ids: th.data.bn_pick | |
2462 | + } | |
2463 | + }).then(res => { | |
2464 | + if (ut.ajax_ok(res)) { | |
2465 | + console.log(res); | |
2466 | + if (res.data.code == 0) { | |
2467 | + let resData = res.data.data.pageData | |
2468 | + if (resData && resData[0]) { | |
2469 | + let keyid = resData[0].keyid | |
2470 | + | |
2471 | + cart_item.sto={ | |
2472 | + keyid | |
2473 | + } | |
2474 | + } | |
2475 | + } | |
2476 | + } | |
2477 | + }) | |
2478 | + } | |
2441 | 2479 | let cart_yc = await th.beforAdvancesum(cart_item) |
2480 | + | |
2442 | 2481 | if (!cart_item.yck_off) { |
2443 | 2482 | cart_item.yck_off = cart_yc.yck_off |
2444 | 2483 | } |
... | ... | @@ -2463,7 +2502,20 @@ Page({ |
2463 | 2502 | [yct4]: cart_item.pre_json, |
2464 | 2503 | [yct44]: cart_item.pre_json, |
2465 | 2504 | }) |
2466 | - | |
2505 | + //搭配购直接购买特殊处理 | |
2506 | + if(th.data.collocation_goods){ | |
2507 | + let yct1 = 'bn_goods.yck_off'; | |
2508 | + let yct2 = 'bn_goods.yck'; | |
2509 | + let yct3 = 'bn_goods.yckid'; | |
2510 | + let yct4 = 'bn_goods.pre_json'; | |
2511 | + th.setData({ | |
2512 | + [yct1]: cart_item.yck_off, | |
2513 | + [yct2]: cart_item.yck, | |
2514 | + [yct3]: cart_item.yckid, | |
2515 | + [yct4]: cart_item.pre_json, | |
2516 | + }) | |
2517 | + } | |
2518 | + //-------------------- | |
2467 | 2519 | if (cart_item.yck_off && cart_item.yck_off == 2) { |
2468 | 2520 | let order_amount = (cart_item.order_amount - cart_item.yck).toFixed(2); |
2469 | 2521 | let yck = 0 |
... | ... | @@ -2702,7 +2754,7 @@ Page({ |
2702 | 2754 | var quan_no = null; |
2703 | 2755 | if (th.data.using_quan[bn_pick] != null && th.data.using_quan[bn_pick] != undefined) |
2704 | 2756 | quan_no = th.data.using_quan[bn_pick].coupon_no; |
2705 | - | |
2757 | + | |
2706 | 2758 | if (quan_no) { |
2707 | 2759 | //如果是一件代发就不要找商品 |
2708 | 2760 | if (th.data.using_quan[bn_pick].isby != 1 && !good.whsle_id) { |
... | ... | @@ -2715,7 +2767,7 @@ Page({ |
2715 | 2767 | WareIds: th.data.check_quan_ware_list |
2716 | 2768 | } |
2717 | 2769 | }).then(res => { |
2718 | - | |
2770 | + | |
2719 | 2771 | if (res.data.code == 0 && res.data.data && res.data.data.length > 0) { |
2720 | 2772 | quan_price = res.data.data[0].WareCashSum; |
2721 | 2773 | } |
... | ... | @@ -2734,9 +2786,9 @@ Page({ |
2734 | 2786 | var ord_prom = null; |
2735 | 2787 | var is_ord_prom_post = 0; |
2736 | 2788 | |
2737 | - if(condition>0 && th.data.bn_is_order_yh) { | |
2789 | + if (condition > 0 && th.data.bn_is_order_yh) { | |
2738 | 2790 | await getApp().request.promiseGet("/api/weshop/promorder/getOrderPromotion", { |
2739 | - data: {store_id: os.stoid, orderAmount: condition, user_id: getApp().globalData.user_id} | |
2791 | + data: { store_id: os.stoid, orderAmount: condition, user_id: getApp().globalData.user_id } | |
2740 | 2792 | }).then(res => { |
2741 | 2793 | if (res.data.code == 0) { |
2742 | 2794 | var data = res.data.data; |
... | ... | @@ -2810,7 +2862,7 @@ Page({ |
2810 | 2862 | var back_data = null; |
2811 | 2863 | |
2812 | 2864 | //判断是不是包邮模板,bn_is_post_temp 和 订单优惠的包邮模板一起控制 |
2813 | - if(th.data.bn_is_post_temp && (!ord_prom || is_ord_prom_post)){ | |
2865 | + if (th.data.bn_is_post_temp && (!ord_prom || is_ord_prom_post)) { | |
2814 | 2866 | |
2815 | 2867 | await getApp().request.promisePost("/api/weshop/order/areaFreight", { |
2816 | 2868 | is_json: 1, data: req_d |
... | ... | @@ -2966,7 +3018,7 @@ Page({ |
2966 | 3018 | |
2967 | 3019 | var order_prom_amount = 0; |
2968 | 3020 | var order_prom_id = 0; |
2969 | - if (ord_prom && o_condition>0) { | |
3021 | + if (ord_prom && o_condition > 0) { | |
2970 | 3022 | //么有使用券,或者活动没有限制使用优惠券 |
2971 | 3023 | if (coupon_price <= 0 || !ord_prom.is_xz_yh) { |
2972 | 3024 | order_prom_id = ord_prom['id']; |
... | ... | @@ -3022,12 +3074,13 @@ Page({ |
3022 | 3074 | } |
3023 | 3075 | }) |
3024 | 3076 | } |
3077 | + | |
3025 | 3078 | if (th.data.bn_goods.keyid) { |
3026 | 3079 | let cart_yc = await th.beforAdvancesum({ |
3027 | 3080 | order_amount: order_m, |
3028 | 3081 | goods: [{ |
3029 | 3082 | goods_sn: th.data.bn_goods.goods_sn, |
3030 | - goods_price: th.data.bn_goods.shop_price || th.data.bn_goods.goods_price, | |
3083 | + goods_price: th.data.bn_goods.shop_price || th.data.bn_goods.goods_price, | |
3031 | 3084 | goods_num: th.data.bn_goods.buynum || th.data.bn_goods.goods_num, |
3032 | 3085 | }], |
3033 | 3086 | sto: { |
... | ... | @@ -3076,6 +3129,15 @@ Page({ |
3076 | 3129 | // all_yck_arr.push(yck) //真实预存款抵扣金额 |
3077 | 3130 | // all_pre_json.push(good.pre_json) |
3078 | 3131 | // all_prestore = parseFloat(all_prestore); //真实预存款抵扣金额总和 |
3132 | + }else{ | |
3133 | + let atxt10 = "formData.prestore"; //预存金额 | |
3134 | + let atxt11 = "formData.pre_json"; //预存json | |
3135 | + let atxt12 = "formData.all_yck_arr"; //预存真实抵扣列表 | |
3136 | + th.setData({ | |
3137 | + [atxt10]: 0, | |
3138 | + [atxt11]: '', | |
3139 | + [atxt12]: [], | |
3140 | + }) | |
3079 | 3141 | } |
3080 | 3142 | } |
3081 | 3143 | } else { |
... | ... | @@ -3476,7 +3538,7 @@ Page({ |
3476 | 3538 | order_prom_list.order_prom_id = th.data.formData.order_prom_id; |
3477 | 3539 | order_prom_list.order_prom_amount = th.data.formData.order_prom_amount; |
3478 | 3540 | } |
3479 | - | |
3541 | + | |
3480 | 3542 | |
3481 | 3543 | //--判断优惠活动的提交-- |
3482 | 3544 | if (th.data.formData.cut_price > 0) { |
... | ... | @@ -4055,7 +4117,7 @@ Page({ |
4055 | 4117 | |
4056 | 4118 | if (pdata.length == 0) return; |
4057 | 4119 | //如果有使用预存,要处理 |
4058 | - if (th.data.formData && th.data.formData.prestore * 1 > 0 && th.data.bn_goods.yck_off==2) { | |
4120 | + if (th.data.formData && th.data.formData.prestore * 1 > 0 ) { | |
4059 | 4121 | let formData = th.data.formData |
4060 | 4122 | let pre_json = formData.pre_json |
4061 | 4123 | let all_yck_arr = formData.all_yck_arr | ... | ... |