Commit 674924edb3372a347ae9b6b4bd03032458a069b2
1 parent
cc3629d6
cart2 多活动的优化
Showing
1 changed file
with
205 additions
and
434 deletions
packageE/pages/cart/cart2/cart2.js
| ... | ... | @@ -1940,15 +1940,12 @@ Page({ |
| 1940 | 1940 | |
| 1941 | 1941 | //调用函数计算每件组合购商品的单价, |
| 1942 | 1942 | await zh_calc.calc_zh_split_price(c_arr, th); |
| 1943 | - | |
| 1944 | 1943 | //调用函数计算每件阶梯促销商品的单价, |
| 1945 | 1944 | await ladder_calc.calc_split_price(c_arr, th); |
| 1946 | 1945 | //调用函数计算,优惠券优惠什么商品价格,优惠券优惠什么商品 |
| 1947 | - | |
| 1948 | 1946 | await th.get_cart_quan(c_arr); |
| 1949 | 1947 | |
| 1950 | 1948 | |
| 1951 | - | |
| 1952 | 1949 | //-- 经纬度不循环调用接口 -- |
| 1953 | 1950 | var lon = 0; var lat = 0; |
| 1954 | 1951 | //---循环购物车--- |
| ... | ... | @@ -2105,6 +2102,17 @@ Page({ |
| 2105 | 2102 | |
| 2106 | 2103 | var back_data = null; |
| 2107 | 2104 | var quan_no_goods_arr = null; |
| 2105 | + var ord_prom =null; | |
| 2106 | + | |
| 2107 | + //---判断是不是有订单优惠--- | |
| 2108 | + await getApp().request.promiseGet("/api/weshop/promorder/getOrderPromotion", { | |
| 2109 | + data: { store_id: os.stoid, orderAmount: parseFloat(o_price - quan_price - whsle_goods_price - no_order_yh).toFixed(2), user_id: getApp().globalData.user_id } | |
| 2110 | + }).then(res => { | |
| 2111 | + if (res.data.code == 0) { | |
| 2112 | + ord_prom = res.data.data; | |
| 2113 | + } | |
| 2114 | + }) | |
| 2115 | + | |
| 2108 | 2116 | //--如果是物流,且选择了地址,就要开始显示包邮券,且包邮券也已经优惠了优惠活动的金额-- |
| 2109 | 2117 | if (cart_item.exp_type == 0 && th.data.user_addr != null && !cart_item.is_xz_yh) { |
| 2110 | 2118 | //看是不是有调用过包邮券 |
| ... | ... | @@ -2150,16 +2158,21 @@ Page({ |
| 2150 | 2158 | }) |
| 2151 | 2159 | } |
| 2152 | 2160 | |
| 2153 | - var user_addr = th.data.user_addr; | |
| 2154 | - var req_d = { | |
| 2155 | - province: user_addr.province, city: user_addr.city, district: user_addr.district, | |
| 2156 | - wuliu: parseFloat(o_price - quan_price - whsle_goods_price - no_post_temp).toFixed(2), store_id: os.stoid | |
| 2161 | + | |
| 2162 | + //-- 如果没有订单优惠,或者订单优惠中有勾选包邮模板 -- | |
| 2163 | + if(!ord_prom || ord_prom.is_post_temp) { | |
| 2164 | + var user_addr = th.data.user_addr; | |
| 2165 | + var req_d = { | |
| 2166 | + province: user_addr.province, city: user_addr.city, district: user_addr.district, | |
| 2167 | + wuliu: parseFloat(o_price - quan_price - whsle_goods_price - no_post_temp).toFixed(2), store_id: os.stoid | |
| 2168 | + } | |
| 2169 | + await getApp().request.promisePost("/api/weshop/order/areaFreight", { | |
| 2170 | + is_json: 1, data: req_d | |
| 2171 | + }).then(rs => { | |
| 2172 | + if (rs.data.code == 0) back_data = rs.data.data; | |
| 2173 | + }); | |
| 2157 | 2174 | } |
| 2158 | - await getApp().request.promisePost("/api/weshop/order/areaFreight", { | |
| 2159 | - is_json: 1, data: req_d | |
| 2160 | - }).then(rs => { | |
| 2161 | - if (rs.data.code == 0) back_data = rs.data.data; | |
| 2162 | - }); | |
| 2175 | + | |
| 2163 | 2176 | |
| 2164 | 2177 | } |
| 2165 | 2178 | |
| ... | ... | @@ -2336,32 +2349,27 @@ Page({ |
| 2336 | 2349 | } |
| 2337 | 2350 | |
| 2338 | 2351 | var order_m = 0; |
| 2339 | - //---判断是不是有订单优惠--- | |
| 2340 | - await getApp().request.promiseGet("/api/weshop/promorder/getOrderPromotion", { | |
| 2341 | - data: { store_id: os.stoid, orderAmount: o_condition, user_id: getApp().globalData.user_id } | |
| 2342 | - }).then(res => { | |
| 2343 | - if (res.data.code == 0) { | |
| 2344 | - var ord_prom = res.data.data; | |
| 2345 | - //么有使用券,或者活动没有限制使用优惠券 | |
| 2346 | - if (quan_price <= 0 || !ord_prom.is_xz_yh) { | |
| 2347 | - order_prom_id = ord_prom['id']; | |
| 2348 | - switch (ord_prom['type']) { | |
| 2349 | - case 0: | |
| 2350 | - order_m = Math.round(o_condition * ord_prom['expression']) / 100;//满额打折 | |
| 2351 | - order_prom_amount = (o_condition - order_m).toFixed(2); | |
| 2352 | - break; | |
| 2353 | - case 1: | |
| 2354 | - //order_m = o_condition - ord_prom['expression'];//满额优惠金额 | |
| 2355 | - var bs = 1; | |
| 2356 | - if (ord_prom.is_bz) { | |
| 2357 | - bs = Math.floor(o_condition / ord_prom.money); | |
| 2358 | - } | |
| 2359 | - order_prom_amount = ord_prom['expression']; | |
| 2360 | - break; | |
| 2352 | + | |
| 2353 | + //么有使用券,或者活动没有限制使用优惠券 | |
| 2354 | + if (quan_price <= 0 || !ord_prom.is_xz_yh) { | |
| 2355 | + order_prom_id = ord_prom['id']; | |
| 2356 | + switch (ord_prom['type']) { | |
| 2357 | + case 0: | |
| 2358 | + order_m = Math.round(o_condition * ord_prom['expression']) / 100;//满额打折 | |
| 2359 | + order_prom_amount = (o_condition - order_m).toFixed(2); | |
| 2360 | + break; | |
| 2361 | + case 1: | |
| 2362 | + //order_m = o_condition - ord_prom['expression'];//满额优惠金额 | |
| 2363 | + var bs = 1; | |
| 2364 | + if (ord_prom.is_bz) { | |
| 2365 | + bs = Math.floor(o_condition / ord_prom.money); | |
| 2361 | 2366 | } |
| 2362 | - } | |
| 2367 | + order_prom_amount = ord_prom['expression']; | |
| 2368 | + break; | |
| 2363 | 2369 | } |
| 2364 | - }) | |
| 2370 | + } | |
| 2371 | + | |
| 2372 | + | |
| 2365 | 2373 | |
| 2366 | 2374 | cart_item.order_prom_amount = 0; |
| 2367 | 2375 | //--订单优惠的显示-- |
| ... | ... | @@ -2642,7 +2650,6 @@ Page({ |
| 2642 | 2650 | } |
| 2643 | 2651 | }, |
| 2644 | 2652 | |
| 2645 | - | |
| 2646 | 2653 | //---------计算立即购买---------- |
| 2647 | 2654 | calculatePrice2: async function (qfunc) { |
| 2648 | 2655 | var th = this, good = this.data.bn_goods; |
| ... | ... | @@ -2721,11 +2728,30 @@ Page({ |
| 2721 | 2728 | gd_arr_list = [...gd_arr_list, ...th.data.buy_now_gift_goods]; |
| 2722 | 2729 | } |
| 2723 | 2730 | |
| 2731 | + //-- 把订单优惠的判断提前,bn_is_order_yh是确定要不要订单优惠的控制 -- | |
| 2732 | + var condition = parseFloat(parseFloat(allpice) - cut_price - quan_price).toFixed(2); | |
| 2733 | + var ord_prom = null; | |
| 2734 | + var is_ord_prom_post = 0; | |
| 2735 | + | |
| 2736 | + if(condition>0 && th.data.bn_is_order_yh) { | |
| 2737 | + await getApp().request.promiseGet("/api/weshop/promorder/getOrderPromotion", { | |
| 2738 | + data: {store_id: os.stoid, orderAmount: condition, user_id: getApp().globalData.user_id} | |
| 2739 | + }).then(res => { | |
| 2740 | + if (res.data.code == 0) { | |
| 2741 | + var data = res.data.data; | |
| 2742 | + ord_prom = data; | |
| 2743 | + } | |
| 2744 | + }) | |
| 2745 | + if (ord_prom && ord_prom.is_post_temp) { | |
| 2746 | + is_ord_prom_post = 1; | |
| 2747 | + } | |
| 2748 | + } | |
| 2749 | + | |
| 2724 | 2750 | //-----------当地址不为空,且是物流时,计算物流费用,并同时商品不是优惠活动的包邮---------- |
| 2725 | 2751 | if (th.data.user_addr != null && th.data.bn_exp_type == 0 && good.is_past != 1) { |
| 2726 | 2752 | //看是不是有调用过包邮券 |
| 2727 | 2753 | if (!th.data.isget_by_quan[th.data.bn_pick] && good.is_xz_yh != 1) { |
| 2728 | - var condition = allpice - cut_price - quan_price; | |
| 2754 | + | |
| 2729 | 2755 | //--判断要不要显示包邮券,链式调用接口,调取包邮券,已经是减了优惠的金额,见到优惠券的钱--- |
| 2730 | 2756 | getApp().request.promiseGet("/api/weshop/userfeemail/pageAndArea", { |
| 2731 | 2757 | data: { |
| ... | ... | @@ -2782,8 +2808,9 @@ Page({ |
| 2782 | 2808 | } |
| 2783 | 2809 | var back_data = null; |
| 2784 | 2810 | |
| 2785 | - //判断是不是包邮模板 | |
| 2786 | - if (th.data.bn_is_post_temp) { | |
| 2811 | + //判断是不是包邮模板,bn_is_post_temp 和 订单优惠的包邮模板一起控制 | |
| 2812 | + if(th.data.bn_is_post_temp && (!ord_prom || is_ord_prom_post)){ | |
| 2813 | + | |
| 2787 | 2814 | await getApp().request.promisePost("/api/weshop/order/areaFreight", { |
| 2788 | 2815 | is_json: 1, data: req_d |
| 2789 | 2816 | }).then(rs => { |
| ... | ... | @@ -2936,46 +2963,38 @@ Page({ |
| 2936 | 2963 | o_condition = 0; |
| 2937 | 2964 | } |
| 2938 | 2965 | |
| 2939 | - | |
| 2940 | - | |
| 2941 | - | |
| 2942 | - | |
| 2943 | - if (o_condition > 0 && th.data.bn_is_order_yh) { | |
| 2944 | - | |
| 2945 | - th.check_is_order_prom(o_condition, async function () { | |
| 2946 | - var order_prom_amount = 0; | |
| 2947 | - var order_prom_id = 0; | |
| 2948 | - if (th.data.order_prom[th.data.bn_pick] && th.data.order_prom[th.data.bn_pick]['money'] <= o_condition) { | |
| 2949 | - var ord_prom = th.data.order_prom[th.data.bn_pick]; | |
| 2950 | - //么有使用券,或者活动没有限制使用优惠券 | |
| 2951 | - if (coupon_price <= 0 || !ord_prom.is_xz_yh) { | |
| 2952 | - order_prom_id = ord_prom['id']; | |
| 2953 | - switch (ord_prom['type']) { | |
| 2954 | - case 0: | |
| 2955 | - order_m = Math.round(o_condition * ord_prom['expression']) / 100;//满额打折 | |
| 2956 | - order_prom_amount = (o_condition - order_m).toFixed(2); | |
| 2957 | - break; | |
| 2958 | - case 1: | |
| 2959 | - //-- 如果有优惠促销倍减的时候 -- | |
| 2960 | - var bs = 1; | |
| 2961 | - if (ord_prom.is_bz) { | |
| 2962 | - bs = Math.floor(o_condition / ord_prom.money); | |
| 2963 | - } | |
| 2964 | - | |
| 2965 | - order_m = o_condition - bs * ord_prom['expression'];//满额优惠金额 | |
| 2966 | - order_prom_amount = ord_prom['expression']; | |
| 2967 | - break; | |
| 2966 | + var order_prom_amount = 0; | |
| 2967 | + var order_prom_id = 0; | |
| 2968 | + if (ord_prom) { | |
| 2969 | + //么有使用券,或者活动没有限制使用优惠券 | |
| 2970 | + if (coupon_price <= 0 || !ord_prom.is_xz_yh) { | |
| 2971 | + order_prom_id = ord_prom['id']; | |
| 2972 | + switch (ord_prom['type']) { | |
| 2973 | + case 0: | |
| 2974 | + order_m = Math.round(o_condition * ord_prom['expression']) / 100;//满额打折 | |
| 2975 | + order_prom_amount = (o_condition - order_m).toFixed(2); | |
| 2976 | + break; | |
| 2977 | + case 1: | |
| 2978 | + //-- 如果有优惠促销倍减的时候 -- | |
| 2979 | + var bs = 1; | |
| 2980 | + if (ord_prom.is_bz) { | |
| 2981 | + bs = Math.floor(o_condition / ord_prom.money); | |
| 2968 | 2982 | } |
| 2969 | - } | |
| 2970 | - } | |
| 2971 | - //--订单优惠的显示-- | |
| 2972 | - var order_prom_txt1 = "formData.order_prom_id"; | |
| 2973 | - var order_prom_txt2 = "formData.order_prom_amount"; | |
| 2974 | - if (order_prom_id > 0) { | |
| 2975 | - th.setData({ [order_prom_txt1]: order_prom_id, [order_prom_txt2]: order_prom_amount }) | |
| 2976 | - } else { | |
| 2977 | - th.setData({ [order_prom_txt1]: 0, [order_prom_txt2]: 0 }) | |
| 2983 | + | |
| 2984 | + order_m = o_condition - bs * ord_prom['expression'];//满额优惠金额 | |
| 2985 | + order_prom_amount = ord_prom['expression']; | |
| 2986 | + break; | |
| 2978 | 2987 | } |
| 2988 | + } | |
| 2989 | + } | |
| 2990 | + //--订单优惠的显示-- | |
| 2991 | + var order_prom_txt1 = "formData.order_prom_id"; | |
| 2992 | + var order_prom_txt2 = "formData.order_prom_amount"; | |
| 2993 | + if (order_prom_id > 0) { | |
| 2994 | + th.setData({ [order_prom_txt1]: order_prom_id, [order_prom_txt2]: order_prom_amount }) | |
| 2995 | + } else { | |
| 2996 | + th.setData({ [order_prom_txt1]: 0, [order_prom_txt2]: 0 }) | |
| 2997 | + } | |
| 2979 | 2998 | |
| 2980 | 2999 | //预存金额使用参与计算 |
| 2981 | 3000 | if (th.data.udata && th.data.udata.Balance > 0 && order_m * 1 > 0) { |
| ... | ... | @@ -3014,7 +3033,7 @@ Page({ |
| 3014 | 3033 | keyid: th.data.bn_goods.keyid |
| 3015 | 3034 | } |
| 3016 | 3035 | }) |
| 3017 | - | |
| 3036 | + | |
| 3018 | 3037 | if (!good.yck_off) { |
| 3019 | 3038 | good.yck_off = cart_yc.yck_off |
| 3020 | 3039 | } |
| ... | ... | @@ -3077,394 +3096,145 @@ Page({ |
| 3077 | 3096 | } |
| 3078 | 3097 | |
| 3079 | 3098 | |
| 3080 | - //判断是否同城配送,而且没有调用过 | |
| 3081 | - if (th.data.bn_exp_type == 2 && th.data.user_addr) { | |
| 3082 | - var gd_w = 0, lon = 0, lat = 0; | |
| 3083 | - for (let ib in gd_arr_list) { | |
| 3084 | - let item_b = gd_arr_list[ib]; | |
| 3085 | - gd_w += item_b['weight'] * item_b['buynum']; | |
| 3086 | - } | |
| 3087 | - | |
| 3088 | - //-- 获取距离 -- | |
| 3089 | - await getApp().request.promisePost("/api/weshop/order/sameCityExp/getGeocoder", { | |
| 3090 | - is_json: 1, data: { address: th.data.user_addr.more_address + th.data.user_addr.address } | |
| 3091 | - }).then(res => { | |
| 3092 | - if (res.data.code == 0) { | |
| 3093 | - var data = JSON.parse(res.data.data); | |
| 3094 | - if (data.status == 0) { | |
| 3095 | - lon = data.result.location.lng; | |
| 3096 | - lat = data.result.location.lat; | |
| 3097 | - } | |
| 3098 | - } | |
| 3099 | - }) | |
| 3099 | + //判断是否同城配送,而且没有调用过 | |
| 3100 | + if (th.data.bn_exp_type == 2 && th.data.user_addr) { | |
| 3101 | + var gd_w = 0, lon = 0, lat = 0; | |
| 3102 | + for (let ib in gd_arr_list) { | |
| 3103 | + let item_b = gd_arr_list[ib]; | |
| 3104 | + gd_w += item_b['weight'] * item_b['buynum']; | |
| 3105 | + } | |
| 3100 | 3106 | |
| 3101 | - var req_data = { | |
| 3102 | - store_id: os.stoid, order_amount: parseFloat(order_m), | |
| 3103 | - lon: lon, lat: lat, pickup_id: bn_pick, goods_weight: gd_w | |
| 3107 | + //-- 获取距离 -- | |
| 3108 | + await getApp().request.promisePost("/api/weshop/order/sameCityExp/getGeocoder", { | |
| 3109 | + is_json: 1, data: { address: th.data.user_addr.more_address + th.data.user_addr.address } | |
| 3110 | + }).then(res => { | |
| 3111 | + if (res.data.code == 0) { | |
| 3112 | + var data = JSON.parse(res.data.data); | |
| 3113 | + if (data.status == 0) { | |
| 3114 | + lon = data.result.location.lng; | |
| 3115 | + lat = data.result.location.lat; | |
| 3104 | 3116 | } |
| 3105 | - | |
| 3106 | - var is_next = 1; | |
| 3107 | - | |
| 3108 | - //获取同城配送参数 | |
| 3109 | - await getApp().request.promisePost("/api/weshop/order/sameCityExp/getMoney", { | |
| 3110 | - is_json: 1, data: req_data | |
| 3111 | - }).then(res => { | |
| 3112 | - if (res.data.code == 0) { | |
| 3113 | - var wl_txt = "formData.shipping_price"; | |
| 3114 | - th.setData({ [wl_txt]: res.data.data, }) | |
| 3115 | - | |
| 3116 | - } else { | |
| 3117 | - is_next = 0; | |
| 3118 | - if (qfunc) { | |
| 3119 | - qfunc(); | |
| 3120 | - } else { | |
| 3121 | - wx.showToast({ | |
| 3122 | - title: res.data.msg, | |
| 3123 | - icon: 'none', | |
| 3124 | - duration: 2000 | |
| 3125 | - }) | |
| 3126 | - } | |
| 3127 | - | |
| 3128 | - } | |
| 3129 | - }) | |
| 3130 | - if (!is_next) return false | |
| 3131 | 3117 | } |
| 3118 | + }) | |
| 3132 | 3119 | |
| 3120 | + var req_data = { | |
| 3121 | + store_id: os.stoid, order_amount: parseFloat(order_m), | |
| 3122 | + lon: lon, lat: lat, pickup_id: bn_pick, goods_weight: gd_w | |
| 3123 | + } | |
| 3133 | 3124 | |
| 3134 | - total_m = parseFloat(total_m) + parseFloat(th.data.formData.shipping_price); | |
| 3135 | - order_m = parseFloat(order_m) + parseFloat(th.data.formData.shipping_price); | |
| 3136 | - | |
| 3137 | - total_m = total_m.toFixed(2); | |
| 3138 | - order_m = order_m.toFixed(2); | |
| 3139 | - | |
| 3140 | - var atxt = "formData.total_amount"; | |
| 3141 | - th.setData({ [atxt]: total_m, }) | |
| 3142 | - | |
| 3143 | - var txt = "formData.user_money"; | |
| 3144 | - var txt2 = "formData.order_amount"; | |
| 3145 | - var txt3 = "formData.coupon_price"; | |
| 3125 | + var is_next = 1; | |
| 3146 | 3126 | |
| 3147 | - //-- 最后的金额小于佣金 -- | |
| 3148 | - if (parseFloat(order_m) < parseFloat(th.data.bn_goods.use_commission)) { | |
| 3127 | + //获取同城配送参数 | |
| 3128 | + await getApp().request.promisePost("/api/weshop/order/sameCityExp/getMoney", { | |
| 3129 | + is_json: 1, data: req_data | |
| 3130 | + }).then(res => { | |
| 3131 | + if (res.data.code == 0) { | |
| 3132 | + var wl_txt = "formData.shipping_price"; | |
| 3133 | + th.setData({ [wl_txt]: res.data.data, }) | |
| 3149 | 3134 | |
| 3150 | - if (th.data.bn_use_commission) { | |
| 3135 | + } else { | |
| 3136 | + is_next = 0; | |
| 3137 | + if (qfunc) { | |
| 3138 | + qfunc(); | |
| 3139 | + } else { | |
| 3151 | 3140 | wx.showToast({ |
| 3152 | - title: '应付金额小于本单佣金,不可使用!', | |
| 3141 | + title: res.data.msg, | |
| 3153 | 3142 | icon: 'none', |
| 3154 | 3143 | duration: 2000 |
| 3155 | 3144 | }) |
| 3156 | 3145 | } |
| 3157 | 3146 | |
| 3158 | - th.setData({ | |
| 3159 | - bn_use_commission: 0 | |
| 3160 | - }); | |
| 3161 | - | |
| 3162 | - | |
| 3163 | - } | |
| 3164 | - | |
| 3165 | - var txt4 = "formData.use_commission"; | |
| 3166 | - | |
| 3167 | - if (th.data.bn_use_commission) { | |
| 3168 | - order_m = (parseFloat(order_m) - parseFloat(th.data.bn_goods.use_commission)).toFixed(2); | |
| 3169 | - th.setData({ [txt4]: th.data.bn_goods.use_commission }) | |
| 3170 | - } | |
| 3171 | - | |
| 3172 | - | |
| 3173 | - var amoney = parseFloat(th.data.userinfo.user_money - th.data.txmon - th.data.userinfo.frozen_money); | |
| 3174 | - //--------------如果使用余额--------------------- | |
| 3175 | - if (th.data.bn_use_money == 1) { | |
| 3176 | - if (amoney > parseFloat(order_m)) { | |
| 3177 | - order_m = parseFloat(order_m).toFixed(2); | |
| 3178 | - th.setData({ [txt]: order_m, [txt2]: 0, [txt3]: coupon_price, show_submit: 1, submit: 0 }) | |
| 3179 | - } else { | |
| 3180 | - order_m = parseFloat(order_m) - parseFloat(amoney); | |
| 3181 | - order_m = order_m.toFixed(2); | |
| 3182 | - th.setData({ [txt]: amoney, [txt2]: order_m, [txt3]: coupon_price, show_submit: 1, submit: 0 }) | |
| 3183 | - } | |
| 3184 | - } else { | |
| 3185 | - th.setData({ [txt]: 0, [txt2]: order_m, [txt3]: coupon_price, show_submit: 1, submit: 0 }) | |
| 3186 | - } | |
| 3187 | - //优惠活动送积分 | |
| 3188 | - if (good.s_intValue) { | |
| 3189 | - txt = "formData.give_integral"; | |
| 3190 | - th.setData({ [txt]: good.s_intValue }); | |
| 3191 | - } | |
| 3192 | - //优惠送券 | |
| 3193 | - if (good.s_coupon_id) { | |
| 3194 | - var i_txt = "formData.give_coupon_id"; | |
| 3195 | - //这个是json格式的 | |
| 3196 | - var i_txt1 = "formData.g_coupon_num"; | |
| 3197 | - var ob = [{ "num": good.s_coupon_num, "c_id": good.s_coupon_id }]; | |
| 3198 | - ob = JSON.stringify(ob); | |
| 3199 | - th.setData({ [i_txt]: good.s_coupon_id, [i_txt1]: ob }); | |
| 3200 | - } | |
| 3201 | - //优惠礼包 | |
| 3202 | - if (good.s_libao) { | |
| 3203 | - var l_txt = "formData.give_lb_id"; | |
| 3204 | - //这个是json格式的 | |
| 3205 | - var l_txt1 = "formData.g_lb_num"; | |
| 3206 | - var ob = [{ "num": good.s_lb_num, "l_id": good.s_libao }]; | |
| 3207 | - ob = JSON.stringify(ob); | |
| 3208 | - th.setData({ [l_txt]: good.s_libao, [l_txt1]: ob }); | |
| 3209 | - } | |
| 3210 | - | |
| 3211 | - //专享礼包 | |
| 3212 | - if (good.zx_libao) { | |
| 3213 | - var l_txt = "formData.give_zxlb_id"; | |
| 3214 | - //这个是json格式的 | |
| 3215 | - var l_txt1 = "formData.g_zxlb_num"; | |
| 3216 | - var ob = [{ "num": good.zx_lb_num, "l_id": good.zx_libao }]; | |
| 3217 | - ob = JSON.stringify(ob); | |
| 3218 | - th.setData({ [l_txt]: good.zx_libao, [l_txt1]: ob }); | |
| 3219 | 3147 | } |
| 3220 | 3148 | }) |
| 3221 | - } else { | |
| 3222 | - | |
| 3223 | - var order_prom_txt1 = "formData.order_prom_id"; | |
| 3224 | - var order_prom_txt2 = "formData.order_prom_amount"; | |
| 3225 | - th.setData({ [order_prom_txt1]: 0, [order_prom_txt2]: 0 }) | |
| 3226 | - | |
| 3227 | - //预存金额使用参与计算 | |
| 3228 | - if (th.data.udata && th.data.udata.Balance > 0 && order_m * 1 > 0) { | |
| 3229 | - if (!th.data.bn_goods.keyid) { | |
| 3230 | - //获取门店信息 | |
| 3231 | - await getApp().request.promiseGet("/api/weshop/pickup/list", { | |
| 3232 | - data: { | |
| 3233 | - store_id: os.stoid, | |
| 3234 | - ids: th.data.bn_pick | |
| 3235 | - } | |
| 3236 | - }).then(res => { | |
| 3237 | - if (ut.ajax_ok(res)) { | |
| 3238 | - console.log(res); | |
| 3239 | - if (res.data.code == 0) { | |
| 3240 | - let resData = res.data.data.pageData | |
| 3241 | - if (resData && resData[0]) { | |
| 3242 | - let keyid = resData[0].keyid | |
| 3243 | - let txt = 'bn_goods.keyid' | |
| 3244 | - th.setData({ | |
| 3245 | - [txt]: keyid | |
| 3246 | - }) | |
| 3247 | - } | |
| 3248 | - } | |
| 3249 | - } | |
| 3250 | - }) | |
| 3251 | - } | |
| 3252 | - if (th.data.bn_goods.keyid) { | |
| 3253 | - let cart_yc = await th.beforAdvancesum({ | |
| 3254 | - order_amount: order_m, | |
| 3255 | - goods: [{ | |
| 3256 | - goods_sn: th.data.bn_goods.goods_sn, | |
| 3257 | - goods_price: th.data.bn_goods.goods_price, | |
| 3258 | - goods_num: th.data.bn_goods.goods_num, | |
| 3259 | - }], | |
| 3260 | - sto: { | |
| 3261 | - keyid: th.data.bn_goods.keyid | |
| 3262 | - } | |
| 3263 | - }) | |
| 3264 | - | |
| 3265 | - if (!good.yck_off) { | |
| 3266 | - good.yck_off = cart_yc.yck_off | |
| 3267 | - } | |
| 3268 | - good.yck = cart_yc.yck | |
| 3269 | - good.yckid = cart_yc.yckid | |
| 3270 | - good.pre_json = cart_yc.pre_json | |
| 3271 | - let yct1 = 'bn_goods.yck_off'; | |
| 3272 | - let yct2 = 'bn_goods.yck'; | |
| 3273 | - let yct3 = 'bn_goods.yckid'; | |
| 3274 | - let yct4 = 'bn_goods.pre_json'; | |
| 3275 | - th.setData({ | |
| 3276 | - [yct1]: good.yck_off, | |
| 3277 | - [yct2]: good.yck, | |
| 3278 | - [yct3]: good.yckid, | |
| 3279 | - [yct4]: good.pre_json, | |
| 3280 | - }) | |
| 3281 | - | |
| 3282 | - if (good.yck_off && good.yck_off == 2) { | |
| 3283 | - let order_amount = (order_m - good.yck).toFixed(2); | |
| 3284 | - let yck = 0 | |
| 3285 | - if (order_amount * 1 > 0) { | |
| 3286 | - order_m = order_amount; | |
| 3287 | - // all_prestore+=parseFloat(good.yck); | |
| 3288 | - yck = parseFloat(good.yck) | |
| 3289 | - } else { | |
| 3290 | - // all_prestore+=order_m*1 | |
| 3291 | - yck = parseFloat(order_m) | |
| 3292 | - order_m = 0 | |
| 3293 | - } | |
| 3294 | - let atxt10 = "formData.prestore"; //预存金额 | |
| 3295 | - let atxt11 = "formData.pre_json"; //预存json | |
| 3296 | - let atxt12 = "formData.all_yck_arr"; //预存真实抵扣列表 | |
| 3297 | - th.setData({ | |
| 3298 | - [atxt10]: yck, | |
| 3299 | - [atxt11]: [good.pre_json], | |
| 3300 | - [atxt12]: [yck], | |
| 3301 | - }) | |
| 3302 | - // formData.prestore | |
| 3303 | - // all_yck_arr.push(yck) //真实预存款抵扣金额 | |
| 3304 | - // all_pre_json.push(good.pre_json) | |
| 3305 | - // all_prestore = parseFloat(all_prestore); //真实预存款抵扣金额总和 | |
| 3306 | - } | |
| 3307 | - } | |
| 3308 | - } else { | |
| 3309 | - let yct1 = 'bn_goods.yck_off'; | |
| 3310 | - let yct2 = 'bn_goods.yck'; | |
| 3311 | - let yct3 = 'bn_goods.yckid'; | |
| 3312 | - let yct4 = 'bn_goods.pre_json'; | |
| 3313 | - let atxt10 = "formData.prestore"; //预存金额 | |
| 3314 | - let atxt11 = "formData.pre_json"; //预存json | |
| 3315 | - let atxt12 = "formData.all_yck_arr"; //预存真实抵扣列表 | |
| 3316 | - th.setData({ | |
| 3317 | - [yct2]: 0, | |
| 3318 | - [yct3]: '', | |
| 3319 | - [yct4]: '', | |
| 3320 | - [atxt10]: 0, | |
| 3321 | - [atxt11]: '', | |
| 3322 | - [atxt12]: [], | |
| 3323 | - }) | |
| 3324 | - } | |
| 3149 | + if (!is_next) return false | |
| 3150 | + } | |
| 3325 | 3151 | |
| 3326 | - //判断是否同城配送,而且没有调用过 | |
| 3327 | - if (th.data.bn_exp_type == 2 && th.data.user_addr) { | |
| 3328 | - var gd_w = 0, lon = 0, lat = 0; | |
| 3329 | - for (let ib in gd_arr_list) { | |
| 3330 | - let item_b = gd_arr_list[ib]; | |
| 3331 | - gd_w += item_b['weight'] * item_b['buynum']; | |
| 3332 | - } | |
| 3333 | 3152 | |
| 3334 | - //-- 获取距离 -- | |
| 3335 | - await getApp().request.promisePost("/api/weshop/order/sameCityExp/getGeocoder", { | |
| 3336 | - is_json: 1, data: { address: th.data.user_addr.more_address + th.data.user_addr.address } | |
| 3337 | - }).then(res => { | |
| 3338 | - if (res.data.code == 0) { | |
| 3339 | - var data = JSON.parse(res.data.data); | |
| 3340 | - if (data.status == 0) { | |
| 3341 | - lon = data.result.location.lng; | |
| 3342 | - lat = data.result.location.lat; | |
| 3343 | - } | |
| 3344 | - } | |
| 3345 | - }) | |
| 3153 | + total_m = parseFloat(total_m) + parseFloat(th.data.formData.shipping_price); | |
| 3154 | + order_m = parseFloat(order_m) + parseFloat(th.data.formData.shipping_price); | |
| 3346 | 3155 | |
| 3347 | - var req_data = { | |
| 3348 | - store_id: os.stoid, order_amount: parseFloat(order_m), | |
| 3349 | - lon: lon, lat: lat, pickup_id: bn_pick, goods_weight: gd_w | |
| 3350 | - } | |
| 3156 | + total_m = total_m.toFixed(2); | |
| 3157 | + order_m = order_m.toFixed(2); | |
| 3351 | 3158 | |
| 3352 | - var is_next = 1; | |
| 3159 | + var atxt = "formData.total_amount"; | |
| 3160 | + th.setData({ [atxt]: total_m, }) | |
| 3353 | 3161 | |
| 3354 | - //获取同城配送参数 | |
| 3355 | - await getApp().request.promisePost("/api/weshop/order/sameCityExp/getMoney", { | |
| 3356 | - is_json: 1, data: req_data | |
| 3357 | - }).then(res => { | |
| 3358 | - if (res.data.code == 0) { | |
| 3359 | - var wl_txt = "formData.shipping_price"; | |
| 3360 | - th.setData({ [wl_txt]: res.data.data, }) | |
| 3162 | + var txt = "formData.user_money"; | |
| 3163 | + var txt2 = "formData.order_amount"; | |
| 3164 | + var txt3 = "formData.coupon_price"; | |
| 3361 | 3165 | |
| 3362 | - } else { | |
| 3363 | - is_next = 0; | |
| 3364 | - if (qfunc) { | |
| 3365 | - qfunc(); | |
| 3366 | - } else { | |
| 3367 | - wx.showToast({ | |
| 3368 | - title: res.data.msg, | |
| 3369 | - icon: 'none', | |
| 3370 | - duration: 2000 | |
| 3371 | - }) | |
| 3372 | - } | |
| 3166 | + //-- 最后的金额小于佣金 -- | |
| 3167 | + if (parseFloat(order_m) < parseFloat(th.data.bn_goods.use_commission)) { | |
| 3373 | 3168 | |
| 3374 | - } | |
| 3169 | + if (th.data.bn_use_commission) { | |
| 3170 | + wx.showToast({ | |
| 3171 | + title: '应付金额小于本单佣金,不可使用!', | |
| 3172 | + icon: 'none', | |
| 3173 | + duration: 2000 | |
| 3375 | 3174 | }) |
| 3376 | - if (!is_next) return false | |
| 3377 | 3175 | } |
| 3378 | 3176 | |
| 3177 | + th.setData({ | |
| 3178 | + bn_use_commission: 0 | |
| 3179 | + }); | |
| 3379 | 3180 | |
| 3380 | 3181 | |
| 3381 | - total_m = parseFloat(total_m) + parseFloat(th.data.formData.shipping_price); | |
| 3382 | - order_m = parseFloat(order_m) + parseFloat(th.data.formData.shipping_price); | |
| 3383 | - var atxt = "formData.total_amount"; | |
| 3384 | - | |
| 3385 | - total_m = total_m.toFixed(2); | |
| 3386 | - order_m = order_m.toFixed(2); | |
| 3387 | - | |
| 3388 | - th.setData({ [atxt]: total_m, }) | |
| 3389 | - | |
| 3390 | - var txt = "formData.user_money"; | |
| 3391 | - var txt2 = "formData.order_amount"; | |
| 3392 | - var txt3 = "formData.coupon_price"; | |
| 3393 | - | |
| 3394 | - //-- 最后的金额小于佣金 -- | |
| 3395 | - if (parseFloat(order_m) < parseFloat(th.data.bn_goods.use_commission)) { | |
| 3396 | - | |
| 3397 | - if (th.data.bn_use_commission) { | |
| 3398 | - wx.showToast({ | |
| 3399 | - title: '应付金额小于本单佣金,不可使用!', | |
| 3400 | - icon: 'none', | |
| 3401 | - duration: 2000 | |
| 3402 | - }) | |
| 3403 | - } | |
| 3404 | - | |
| 3405 | - th.setData({ | |
| 3406 | - bn_use_commission: 0 | |
| 3407 | - }); | |
| 3408 | - } | |
| 3409 | - | |
| 3182 | + } | |
| 3410 | 3183 | |
| 3411 | - var txt4 = "formData.use_commission"; | |
| 3412 | - | |
| 3413 | - if (th.data.bn_use_commission) { | |
| 3414 | - order_m = (parseFloat(order_m) - parseFloat(th.data.bn_goods.use_commission)).toFixed(2); | |
| 3415 | - th.setData({ [txt4]: th.data.bn_goods.use_commission }) | |
| 3416 | - } | |
| 3184 | + var txt4 = "formData.use_commission"; | |
| 3417 | 3185 | |
| 3186 | + if (th.data.bn_use_commission) { | |
| 3187 | + order_m = (parseFloat(order_m) - parseFloat(th.data.bn_goods.use_commission)).toFixed(2); | |
| 3188 | + th.setData({ [txt4]: th.data.bn_goods.use_commission }) | |
| 3189 | + } | |
| 3418 | 3190 | |
| 3419 | - var amoney = parseFloat(th.data.userinfo.user_money - th.data.txmon - th.data.userinfo.frozen_money); | |
| 3420 | 3191 | |
| 3421 | - //--------------如果使用余额--------------------- | |
| 3422 | - if (th.data.bn_use_money == 1) { | |
| 3423 | - if (amoney > parseFloat(order_m)) { | |
| 3424 | - order_m = parseFloat(order_m).toFixed(2); | |
| 3425 | - th.setData({ [txt]: order_m, [txt2]: 0, [txt3]: coupon_price, show_submit: 1, submit: 0 }) | |
| 3426 | - } else { | |
| 3427 | - order_m = parseFloat(order_m) - parseFloat(amoney); | |
| 3428 | - order_m = order_m.toFixed(2); | |
| 3429 | - th.setData({ [txt]: amoney, [txt2]: order_m, [txt3]: coupon_price, show_submit: 1, submit: 0 }) | |
| 3430 | - } | |
| 3192 | + var amoney = parseFloat(th.data.userinfo.user_money - th.data.txmon - th.data.userinfo.frozen_money); | |
| 3193 | + //--------------如果使用余额--------------------- | |
| 3194 | + if (th.data.bn_use_money == 1) { | |
| 3195 | + if (amoney > parseFloat(order_m)) { | |
| 3196 | + order_m = parseFloat(order_m).toFixed(2); | |
| 3197 | + th.setData({ [txt]: order_m, [txt2]: 0, [txt3]: coupon_price, show_submit: 1, submit: 0 }) | |
| 3431 | 3198 | } else { |
| 3432 | - th.setData({ [txt]: 0, [txt2]: order_m, [txt3]: coupon_price, show_submit: 1, submit: 0 }) | |
| 3433 | - } | |
| 3434 | - //优惠活动送积分 | |
| 3435 | - if (good.s_intValue) { | |
| 3436 | - txt = "formData.give_integral"; | |
| 3437 | - th.setData({ [txt]: good.s_intValue }); | |
| 3438 | - } | |
| 3439 | - //优惠送券 | |
| 3440 | - if (good.s_coupon_id) { | |
| 3441 | - var i_txt = "formData.give_coupon_id"; | |
| 3442 | - //这个是json格式的 | |
| 3443 | - var i_txt1 = "formData.g_coupon_num"; | |
| 3444 | - var ob = [{ "num": good.s_coupon_num, "c_id": good.s_coupon_id }]; | |
| 3445 | - ob = JSON.stringify(ob); | |
| 3446 | - th.setData({ [i_txt]: good.s_coupon_id, [i_txt1]: ob }); | |
| 3447 | - } | |
| 3448 | - //优惠礼包 | |
| 3449 | - if (good.s_libao) { | |
| 3450 | - var l_txt = "formData.give_lb_id"; | |
| 3451 | - //这个是json格式的 | |
| 3452 | - var l_txt1 = "formData.g_lb_num"; | |
| 3453 | - var ob = [{ "num": good.s_lb_num, "l_id": good.s_libao }]; | |
| 3454 | - ob = JSON.stringify(ob); | |
| 3455 | - th.setData({ [l_txt]: good.s_libao, [l_txt1]: ob }); | |
| 3456 | - } | |
| 3457 | - | |
| 3458 | - //专享礼包 | |
| 3459 | - if (good.zx_libao) { | |
| 3460 | - var l_txt = "formData.give_zxlb_id"; | |
| 3461 | - //这个是json格式的 | |
| 3462 | - var l_txt1 = "formData.g_zxlb_num"; | |
| 3463 | - var ob = [{ "num": good.zx_lb_num, "l_id": good.zx_libao }]; | |
| 3464 | - ob = JSON.stringify(ob); | |
| 3465 | - th.setData({ [l_txt]: good.zx_libao, [l_txt1]: ob }); | |
| 3466 | - | |
| 3199 | + order_m = parseFloat(order_m) - parseFloat(amoney); | |
| 3200 | + order_m = order_m.toFixed(2); | |
| 3201 | + th.setData({ [txt]: amoney, [txt2]: order_m, [txt3]: coupon_price, show_submit: 1, submit: 0 }) | |
| 3467 | 3202 | } |
| 3203 | + } else { | |
| 3204 | + th.setData({ [txt]: 0, [txt2]: order_m, [txt3]: coupon_price, show_submit: 1, submit: 0 }) | |
| 3205 | + } | |
| 3206 | + //优惠活动送积分 | |
| 3207 | + if (good.s_intValue) { | |
| 3208 | + txt = "formData.give_integral"; | |
| 3209 | + th.setData({ [txt]: good.s_intValue }); | |
| 3210 | + } | |
| 3211 | + //优惠送券 | |
| 3212 | + if (good.s_coupon_id) { | |
| 3213 | + var i_txt = "formData.give_coupon_id"; | |
| 3214 | + //这个是json格式的 | |
| 3215 | + var i_txt1 = "formData.g_coupon_num"; | |
| 3216 | + var ob = [{ "num": good.s_coupon_num, "c_id": good.s_coupon_id }]; | |
| 3217 | + ob = JSON.stringify(ob); | |
| 3218 | + th.setData({ [i_txt]: good.s_coupon_id, [i_txt1]: ob }); | |
| 3219 | + } | |
| 3220 | + //优惠礼包 | |
| 3221 | + if (good.s_libao) { | |
| 3222 | + var l_txt = "formData.give_lb_id"; | |
| 3223 | + //这个是json格式的 | |
| 3224 | + var l_txt1 = "formData.g_lb_num"; | |
| 3225 | + var ob = [{ "num": good.s_lb_num, "l_id": good.s_libao }]; | |
| 3226 | + ob = JSON.stringify(ob); | |
| 3227 | + th.setData({ [l_txt]: good.s_libao, [l_txt1]: ob }); | |
| 3228 | + } | |
| 3229 | + | |
| 3230 | + //专享礼包 | |
| 3231 | + if (good.zx_libao) { | |
| 3232 | + var l_txt = "formData.give_zxlb_id"; | |
| 3233 | + //这个是json格式的 | |
| 3234 | + var l_txt1 = "formData.g_zxlb_num"; | |
| 3235 | + var ob = [{ "num": good.zx_lb_num, "l_id": good.zx_libao }]; | |
| 3236 | + ob = JSON.stringify(ob); | |
| 3237 | + th.setData({ [l_txt]: good.zx_libao, [l_txt1]: ob }); | |
| 3468 | 3238 | } |
| 3469 | 3239 | |
| 3470 | 3240 | wx.hideLoading(); |
| ... | ... | @@ -3473,6 +3243,7 @@ Page({ |
| 3473 | 3243 | |
| 3474 | 3244 | }, |
| 3475 | 3245 | |
| 3246 | + | |
| 3476 | 3247 | requestSubscribe() { |
| 3477 | 3248 | const th = this; |
| 3478 | 3249 | const template_id = this.data.template_id; | ... | ... |