Commit 98b211ef1cb943181d268042361a0b38b7172b24
1 parent
93d7e854
幸运购多活动的优化
Showing
2 changed files
with
108 additions
and
15 deletions
packageC/pages/luckyGo/luckyGo_cart_ct/luckyGo_cart_ct.js
| ... | ... | @@ -75,6 +75,7 @@ Page({ |
| 75 | 75 | card_name: '', //显示的卡的名称 |
| 76 | 76 | card_cut_price: null, //减价多少钱 |
| 77 | 77 | is_pre_cut:0, //是否可以使用预存 0是不可以1的可以 |
| 78 | + act:null, //幸运购的活动 | |
| 78 | 79 | }, |
| 79 | 80 | |
| 80 | 81 | onLoad: function (t) { |
| ... | ... | @@ -95,11 +96,11 @@ Page({ |
| 95 | 96 | |
| 96 | 97 | |
| 97 | 98 | // 获取幸运购活动团team_id |
| 98 | - this.get_teamId({ | |
| 99 | - store_id: oo.stoid, | |
| 100 | - user_id: getApp().globalData.user_id, | |
| 101 | - aid: t.group_id, | |
| 102 | - }); | |
| 99 | + // this.get_teamId({ | |
| 100 | + // store_id: oo.stoid, | |
| 101 | + // user_id: getApp().globalData.user_id, | |
| 102 | + // aid: t.group_id, | |
| 103 | + // }); | |
| 103 | 104 | |
| 104 | 105 | |
| 105 | 106 | |
| ... | ... | @@ -335,7 +336,19 @@ Page({ |
| 335 | 336 | userinfo: e.data.data |
| 336 | 337 | }); |
| 337 | 338 | //获取立即购买的商品信息 |
| 338 | - th.get_buy_goods(); | |
| 339 | + | |
| 340 | + | |
| 341 | + var op_data={ | |
| 342 | + store_id: oo.stoid, | |
| 343 | + user_id: getApp().globalData.user_id, | |
| 344 | + aid: th.data.param.group_id, | |
| 345 | + }; | |
| 346 | + | |
| 347 | + th.get_teamId(op_data,function (){ | |
| 348 | + th.get_buy_goods(); | |
| 349 | + }) | |
| 350 | + | |
| 351 | + | |
| 339 | 352 | |
| 340 | 353 | //获取提现金额 |
| 341 | 354 | getApp().request.get("/api/weshop/withdrawals/summoney", { |
| ... | ... | @@ -715,7 +728,10 @@ Page({ |
| 715 | 728 | good = this.data.bn_goods; |
| 716 | 729 | |
| 717 | 730 | //-----------计算商品总价-------------- |
| 718 | - var allpice = th.data.param.goods_price; | |
| 731 | + //var allpice = th.data.param.goods_price; | |
| 732 | + var allpice = (th.data.act.group_price/100).toFixed(2); | |
| 733 | + | |
| 734 | + | |
| 719 | 735 | allpice = parseFloat(allpice).toFixed(2); |
| 720 | 736 | var txt = "formData.all_price"; |
| 721 | 737 | th.setData({ |
| ... | ... | @@ -735,6 +751,22 @@ Page({ |
| 735 | 751 | goods_piece = -1; |
| 736 | 752 | var out_of_weight = null; //超出多少重量 |
| 737 | 753 | |
| 754 | + | |
| 755 | + //-- 判断订单优惠的叠加 -- | |
| 756 | + var ord_prom=null; | |
| 757 | + var o_condition=allpice; | |
| 758 | + if(th.data.act.is_order_yh){ | |
| 759 | + | |
| 760 | + await getApp().request.promiseGet("/api/weshop/promorder/getOrderPromotion", { | |
| 761 | + data: { store_id: os.stoid, orderAmount: o_condition, user_id: getApp().globalData.user_id } | |
| 762 | + }).then(res => { | |
| 763 | + if (res.data.code == 0) { | |
| 764 | + ord_prom = res.data.data; | |
| 765 | + } | |
| 766 | + }) | |
| 767 | + } | |
| 768 | + | |
| 769 | + | |
| 738 | 770 | //-----------当地址不为空,且是物流时,计算物流费用,同时阶梯团不计算拼团价格---------- |
| 739 | 771 | if (th.data.user_addr != null && th.data.bn_exp_type == 0 && good.is_free_shipping == 0 && (th.data.kt_type != |
| 740 | 772 | 3 || th.data.bn_goods.is_normal == 1)) { |
| ... | ... | @@ -744,12 +776,18 @@ Page({ |
| 744 | 776 | province: user_addr.province, city: user_addr.city, district: user_addr.district, |
| 745 | 777 | wuliu: parseFloat(allpice).toFixed(2), store_id: os.stoid |
| 746 | 778 | } |
| 779 | + | |
| 780 | + //-- 判断包邮 -- | |
| 747 | 781 | var back_data = null; |
| 748 | - await getApp().request.promisePost("/api/weshop/order/areaFreight", { | |
| 749 | - is_json: 1, data: req_d | |
| 750 | - }).then(rs => { | |
| 751 | - if (rs.data.code == 0) back_data = rs.data.data; | |
| 752 | - }); | |
| 782 | + if(!ord_prom || ord_prom.is_post_temp) { | |
| 783 | + if (th.data.act.is_post_temp ) { | |
| 784 | + await getApp().request.promisePost("/api/weshop/order/areaFreight", { | |
| 785 | + is_json: 1, data: req_d | |
| 786 | + }).then(rs => { | |
| 787 | + if (rs.data.code == 0) back_data = rs.data.data; | |
| 788 | + }); | |
| 789 | + } | |
| 790 | + } | |
| 753 | 791 | |
| 754 | 792 | var gd_arr_list = []; |
| 755 | 793 | gd_arr_list.push(good); |
| ... | ... | @@ -893,11 +931,43 @@ Page({ |
| 893 | 931 | if (!is_next) return false |
| 894 | 932 | } |
| 895 | 933 | |
| 934 | + //-- 如果是订单优惠的时候,allpice要拿来减掉一些 -- | |
| 935 | + var order_prom_id=0; | |
| 936 | + var order_prom_amount=0; | |
| 937 | + if(ord_prom){ | |
| 938 | + order_prom_id = ord_prom['id']; | |
| 939 | + switch (ord_prom['type']) { | |
| 940 | + case 0: | |
| 941 | + allpice = Math.round(o_condition * ord_prom['expression']) / 100;//满额打折 | |
| 942 | + order_prom_amount = (o_condition - allpice).toFixed(2); | |
| 943 | + break; | |
| 944 | + case 1: | |
| 945 | + //-- 如果有优惠促销倍减的时候 -- | |
| 946 | + var bs = 1; | |
| 947 | + if (ord_prom.is_bz) { | |
| 948 | + bs = Math.floor(o_condition / ord_prom.money); | |
| 949 | + } | |
| 950 | + allpice = o_condition - bs * ord_prom['expression'];//满额优惠金额 | |
| 951 | + order_prom_amount = ord_prom['expression']; | |
| 952 | + break; | |
| 953 | + } | |
| 954 | + } | |
| 955 | + | |
| 956 | + //--订单优惠的显示-- | |
| 957 | + var order_prom_txt1 = "formData.order_prom_id"; | |
| 958 | + var order_prom_txt2 = "formData.order_prom_amount"; | |
| 959 | + if (order_prom_amount > 0) { | |
| 960 | + th.setData({ [order_prom_txt1]: order_prom_id, [order_prom_txt2]: order_prom_amount }) | |
| 961 | + } else { | |
| 962 | + th.setData({ [order_prom_txt1]: 0, [order_prom_txt2]: 0 }) | |
| 963 | + } | |
| 964 | + | |
| 965 | + | |
| 896 | 966 | |
| 897 | 967 | //-----------------总价----------------- |
| 898 | 968 | // 幸运购 01 |
| 899 | - // var total_m = parseFloat(allpice) + parseFloat( th.data.formData.shipping_price); | |
| 900 | - var total_m = parseFloat(th.data.param.goods_price) + parseFloat(th.data.formData.shipping_price); | |
| 969 | + var total_m = parseFloat(allpice) + parseFloat( th.data.formData.shipping_price); | |
| 970 | + //var total_m = parseFloat(th.data.param.goods_price) + parseFloat(th.data.formData.shipping_price); | |
| 901 | 971 | total_m = parseFloat(total_m).toFixed(2); |
| 902 | 972 | |
| 903 | 973 | var atxt = "formData.total_amount"; |
| ... | ... | @@ -1151,6 +1221,15 @@ Page({ |
| 1151 | 1221 | 'order_goods': new Array(), |
| 1152 | 1222 | }; |
| 1153 | 1223 | |
| 1224 | + //--判断有没有优惠活动-- | |
| 1225 | + if (th.data.formData.order_prom_amount > 0) { | |
| 1226 | + var order_prom_list = {}; | |
| 1227 | + order_prom_list.order_prom_id = th.data.formData.order_prom_id; | |
| 1228 | + order_prom_list.order_prom_amount = th.data.formData.order_prom_amount; | |
| 1229 | + item.order_prom_list = order_prom_list; | |
| 1230 | + } | |
| 1231 | + | |
| 1232 | + | |
| 1154 | 1233 | //如果不是阶梯团,或者是普通购买,01 |
| 1155 | 1234 | // if ((th.data.kt_type != 3 || th.data.bn_goods.is_normal == 1)) { |
| 1156 | 1235 | if (th.data.bn_goods.is_normal == 1) { |
| ... | ... | @@ -1805,7 +1884,8 @@ Page({ |
| 1805 | 1884 | |
| 1806 | 1885 | |
| 1807 | 1886 | // 获取team_id |
| 1808 | - get_teamId(options) { | |
| 1887 | + get_teamId(options,func) { | |
| 1888 | + var th=this; | |
| 1809 | 1889 | let aid = options.aid; |
| 1810 | 1890 | let store_id = options.store_id; |
| 1811 | 1891 | let user_id = options.user_id; |
| ... | ... | @@ -1814,10 +1894,16 @@ Page({ |
| 1814 | 1894 | success: function (res) { |
| 1815 | 1895 | if (res.data.code == 0) { |
| 1816 | 1896 | let team_id = res.data.data.pageData[0]['team_id']; |
| 1897 | + th.setData({ | |
| 1898 | + act:res.data.data.pageData[0] | |
| 1899 | + }) | |
| 1900 | + | |
| 1817 | 1901 | wx.setStorage({ |
| 1818 | 1902 | key: 'team_id', |
| 1819 | 1903 | data: team_id, |
| 1820 | 1904 | }); |
| 1905 | + | |
| 1906 | + func(); | |
| 1821 | 1907 | }; |
| 1822 | 1908 | } |
| 1823 | 1909 | }); | ... | ... |
packageC/pages/luckyGo/luckyGo_cart_ct/luckyGo_cart_ct.wxml
| ... | ... | @@ -189,6 +189,13 @@ |
| 189 | 189 | <view class="co-red">- ¥ {{formData.user_money}}元</view> |
| 190 | 190 | </view> |
| 191 | 191 | |
| 192 | + <!-- 订单优惠优惠金额 --> | |
| 193 | + <view class="item" wx:if="{{formData.order_prom_amount>0}}"> | |
| 194 | + <view>订单优惠</view> | |
| 195 | + <view class="co-red">- ¥ {{filters.toFix(formData.order_prom_amount,2)}}元</view> | |
| 196 | + </view> | |
| 197 | + | |
| 198 | + | |
| 192 | 199 | </view> |
| 193 | 200 | </view> |
| 194 | 201 | ... | ... |