Commit 14a040bfbd20c06839394a4848060764e15f81d3
1 parent
d415d0a8
预存款支付增加拼团使用场景
Showing
7 changed files
with
1347 additions
and
1088 deletions
packageC/pages/luckyGo/luckyGo_cart_ct/luckyGo_cart_ct.js
| ... | ... | @@ -1229,7 +1229,7 @@ Page({ |
| 1229 | 1229 | if (pdata.length == 0) return; |
| 1230 | 1230 | |
| 1231 | 1231 | //如果有使用预存,要处理 |
| 1232 | - if (th.data.formData && th.data.formData.prestore * 1 > 0) { | |
| 1232 | + if (th.data.formData && th.data.formData.prestore * 1 > 0 && th.data.bn_goods.yck_off==2) { | |
| 1233 | 1233 | let formData = th.data.formData |
| 1234 | 1234 | let pre_json = formData.pre_json |
| 1235 | 1235 | let all_yck_arr = formData.all_yck_arr |
| ... | ... | @@ -1239,6 +1239,13 @@ Page({ |
| 1239 | 1239 | item.pre_json = pre_json[i] ? JSON.stringify(pre_json[i]) : '' |
| 1240 | 1240 | }) |
| 1241 | 1241 | } |
| 1242 | + | |
| 1243 | + if (!pdata.keyid && th.data.bn_goods) { | |
| 1244 | + pdata.map(ite => { | |
| 1245 | + ite.keyid = th.data.bn_goods.keyid | |
| 1246 | + }) | |
| 1247 | + // pdata.keyid = th.data.bn_goods.keyid | |
| 1248 | + } | |
| 1242 | 1249 | var str = JSON.stringify(pdata); |
| 1243 | 1250 | console.log("支付数据"); |
| 1244 | 1251 | console.log(str); | ... | ... |
packageC/pages/presell/cart/cart2_pre.js
| ... | ... | @@ -813,7 +813,7 @@ Page({ |
| 813 | 813 | if (pdata.length == 0) return; |
| 814 | 814 | |
| 815 | 815 | //如果有使用预存,要处理 |
| 816 | - if (th.data.formData && th.data.formData.prestore * 1 > 0) { | |
| 816 | + if (th.data.formData && th.data.formData.prestore * 1 > 0 && th.data.bn_goods.yck_off==2) { | |
| 817 | 817 | let formData = th.data.formData |
| 818 | 818 | let pre_json = formData.pre_json |
| 819 | 819 | let all_yck_arr = formData.all_yck_arr | ... | ... |
packageE/pages/cart/cart2/cart2.js
| ... | ... | @@ -4055,7 +4055,7 @@ Page({ |
| 4055 | 4055 | |
| 4056 | 4056 | if (pdata.length == 0) return; |
| 4057 | 4057 | //如果有使用预存,要处理 |
| 4058 | - if (th.data.formData && th.data.formData.prestore * 1 > 0) { | |
| 4058 | + if (th.data.formData && th.data.formData.prestore * 1 > 0 && th.data.bn_goods.yck_off==2) { | |
| 4059 | 4059 | let formData = th.data.formData |
| 4060 | 4060 | let pre_json = formData.pre_json |
| 4061 | 4061 | let all_yck_arr = formData.all_yck_arr | ... | ... |
pages/cart/cart2_inte/cart2_inte.js
| ... | ... | @@ -1085,7 +1085,7 @@ Page({ |
| 1085 | 1085 | |
| 1086 | 1086 | if (pdata.length == 0) return; |
| 1087 | 1087 | //如果有使用预存,要处理 |
| 1088 | - if (th.data.formData && th.data.formData.prestore * 1 > 0) { | |
| 1088 | + if (th.data.formData && th.data.formData.prestore * 1 > 0 && th.data.bn_goods.yck_off==2) { | |
| 1089 | 1089 | let formData = th.data.formData |
| 1090 | 1090 | let pre_json = formData.pre_json |
| 1091 | 1091 | let all_yck_arr = formData.all_yck_arr | ... | ... |
pages/cart/cart2_pt/cart2_pt.js
| 1 | 1 | var t = getApp(), app = t, a = t.request, e = require("../../../utils/common.js"), |
| 2 | - s = require("../../../utils/util.js"), ut = s, o = require("../../../utils/md5.js"), to = getApp(); | |
| 2 | + s = require("../../../utils/util.js"), ut = s, o = require("../../../utils/md5.js"), to = getApp(); | |
| 3 | 3 | var oo = t.globalData.setting, os = oo; |
| 4 | 4 | var regeneratorRuntime = require('../../../utils/runtime.js'); |
| 5 | 5 | var util_pay = require("../../../utils/pay.js"); |
| 6 | 6 | |
| 7 | 7 | Page({ |
| 8 | - data: { | |
| 9 | - url: t.globalData.setting.url, | |
| 10 | - resourceUrl: t.globalData.setting.resourceUrl, | |
| 11 | - imgUrl: t.globalData.setting.imghost, | |
| 12 | - goods: null, | |
| 13 | - order: null, | |
| 14 | - orderPrices: null, | |
| 15 | - coupons: null, | |
| 16 | - coupon: null, | |
| 17 | - invoiceToggle: !0, | |
| 18 | - payWithUserMoney: !0, | |
| 19 | - payWithPoints: !0, | |
| 20 | - maxWord: 0, | |
| 21 | - enterAddressPage: !1, | |
| 22 | - firstEnter: !0, | |
| 23 | - //页面获取的参数 | |
| 24 | - param: null, | |
| 25 | - postdata: null, | |
| 26 | - //提交订单的格式 | |
| 27 | - formData: { | |
| 28 | - order_amount: 0,//支付金额 | |
| 29 | - total_amount: 0,//总价 | |
| 30 | - all_price: 0,//商品卖的总价 | |
| 31 | - pay_points: 0,//使用积分 | |
| 32 | - user_money: 0,//使用余额 | |
| 33 | - couponCode: "",//使用优惠券(多单就用逗号隔开) | |
| 34 | - shipping_price: 0,//物流费用 | |
| 35 | - }, | |
| 36 | - is_no_by: {}, | |
| 37 | - /*----------------立即购买---------------------*/ | |
| 38 | - is_b_now: 0, //0是购物车结算 1立即购买 | |
| 39 | - bn_goods: null, //立即购买时候的调用商品 | |
| 40 | - bn_use_money: 0,//是否使用余额 | |
| 41 | - bn_exp_type: 1, //0是物流 1自提 | |
| 42 | - bn_pick: 0, //选择的门店 | |
| 43 | - bn_pickname: "", //选择的门店名称 | |
| 44 | - bn_t_exp_t: 0, //判断商品和门店一起决定的物流自提的方式0 都可以 1自提 2物流 | |
| 45 | - /*------------------------*/ | |
| 46 | - user_addr: null,//物流 | |
| 47 | - userinfo: null, //获取会员 | |
| 48 | - /*----------物流选择--------*/ | |
| 49 | - wu_arr: null, | |
| 50 | - index: 0, | |
| 51 | - | |
| 52 | - //判断页面是返回回来的还是 首次进入的 | |
| 53 | - isclose: 1, | |
| 54 | - kt_type: 0, //开团类型 | |
| 55 | - is_pt_tz: 0,//是否开团团长 | |
| 56 | - qh: '', //期号 | |
| 57 | - pt_listno: '',//期号 | |
| 58 | - is_normal: 0, | |
| 59 | - is_express: 0,//选择物流的控制器 | |
| 60 | - yuer: 0, | |
| 61 | - | |
| 62 | - rank_switch: 0, //是不是开同等级卡 | |
| 63 | - show_card: null, //显示的等级卡 | |
| 64 | - card_name: '', //显示的卡的名称 | |
| 65 | - card_cut_price: null,//减价多少钱 | |
| 66 | - show_btn: 0, | |
| 67 | - | |
| 68 | - dis_config: null, | |
| 69 | - bn_use_commission: 0 //是不是使用佣金 | |
| 70 | - | |
| 8 | + data: { | |
| 9 | + url: t.globalData.setting.url, | |
| 10 | + resourceUrl: t.globalData.setting.resourceUrl, | |
| 11 | + imgUrl: t.globalData.setting.imghost, | |
| 12 | + goods: null, | |
| 13 | + order: null, | |
| 14 | + orderPrices: null, | |
| 15 | + coupons: null, | |
| 16 | + coupon: null, | |
| 17 | + invoiceToggle: !0, | |
| 18 | + payWithUserMoney: !0, | |
| 19 | + payWithPoints: !0, | |
| 20 | + maxWord: 0, | |
| 21 | + enterAddressPage: !1, | |
| 22 | + firstEnter: !0, | |
| 23 | + //页面获取的参数 | |
| 24 | + param: null, | |
| 25 | + postdata: null, | |
| 26 | + //提交订单的格式 | |
| 27 | + formData: { | |
| 28 | + order_amount: 0,//支付金额 | |
| 29 | + total_amount: 0,//总价 | |
| 30 | + all_price: 0,//商品卖的总价 | |
| 31 | + pay_points: 0,//使用积分 | |
| 32 | + user_money: 0,//使用余额 | |
| 33 | + couponCode: "",//使用优惠券(多单就用逗号隔开) | |
| 34 | + shipping_price: 0,//物流费用 | |
| 71 | 35 | }, |
| 72 | - onLoad: function (t) { | |
| 73 | - console.log("onLoad_pt_cart"); | |
| 74 | - var th = this; | |
| 75 | - this.setData({is_b_now: t.is_bnow == undefined ? 0 : t.is_bnow,}); | |
| 76 | - var appD = getApp().get_b_now(); | |
| 77 | - | |
| 78 | - th.data.postdata = appD; | |
| 79 | - //如果期号有值 | |
| 80 | - if (appD.qh) { | |
| 81 | - th.data.qh = appD.qh; | |
| 82 | - th.data.pt_listno = appD.qh; | |
| 36 | + is_no_by: {}, | |
| 37 | + /*----------------立即购买---------------------*/ | |
| 38 | + is_b_now: 0, //0是购物车结算 1立即购买 | |
| 39 | + bn_goods: null, //立即购买时候的调用商品 | |
| 40 | + bn_use_money: 0,//是否使用余额 | |
| 41 | + bn_exp_type: 1, //0是物流 1自提 | |
| 42 | + bn_pick: 0, //选择的门店 | |
| 43 | + bn_pickname: "", //选择的门店名称 | |
| 44 | + bn_t_exp_t: 0, //判断商品和门店一起决定的物流自提的方式0 都可以 1自提 2物流 | |
| 45 | + /*------------------------*/ | |
| 46 | + user_addr: null,//物流 | |
| 47 | + userinfo: null, //获取会员 | |
| 48 | + /*----------物流选择--------*/ | |
| 49 | + wu_arr: null, | |
| 50 | + index: 0, | |
| 51 | + | |
| 52 | + //判断页面是返回回来的还是 首次进入的 | |
| 53 | + isclose: 1, | |
| 54 | + kt_type: 0, //开团类型 | |
| 55 | + is_pt_tz: 0,//是否开团团长 | |
| 56 | + qh: '', //期号 | |
| 57 | + pt_listno: '',//期号 | |
| 58 | + is_normal: 0, | |
| 59 | + is_express: 0,//选择物流的控制器 | |
| 60 | + yuer: 0, | |
| 61 | + | |
| 62 | + rank_switch: 0, //是不是开同等级卡 | |
| 63 | + show_card: null, //显示的等级卡 | |
| 64 | + card_name: '', //显示的卡的名称 | |
| 65 | + card_cut_price: null,//减价多少钱 | |
| 66 | + show_btn: 0, | |
| 67 | + udata: null,//用户预存值,数据 | |
| 68 | + dis_config: null, | |
| 69 | + bn_use_commission: 0 //是不是使用佣金 | |
| 70 | + | |
| 71 | + }, | |
| 72 | + onLoad: function (t) { | |
| 73 | + console.log("onLoad_pt_cart"); | |
| 74 | + var th = this; | |
| 75 | + this.setData({ is_b_now: t.is_bnow == undefined ? 0 : t.is_bnow, }); | |
| 76 | + var appD = getApp().get_b_now(); | |
| 77 | + | |
| 78 | + th.data.postdata = appD; | |
| 79 | + //如果期号有值 | |
| 80 | + if (appD.qh) { | |
| 81 | + th.data.qh = appD.qh; | |
| 82 | + th.data.pt_listno = appD.qh; | |
| 83 | + } | |
| 84 | + //th.data.kt_type=appD.kt_type; | |
| 85 | + th.setData({ kt_type: appD.kt_type }); | |
| 86 | + if (appD.is_pt_tz) th.data.is_pt_tz = appD.is_pt_tz; | |
| 87 | + th.data.param = t; | |
| 88 | + //先获取物流,再获取用户信息,再展示页面 | |
| 89 | + //th.get_wuliu(th.get_info(th.show_page)); | |
| 90 | + //判断是不是佣金抵扣 | |
| 91 | + getApp().is_distribut(this); | |
| 92 | + }, | |
| 93 | + onUnload: function () { | |
| 94 | + this.setData({ isclose: 1 }) | |
| 95 | + }, | |
| 96 | + | |
| 97 | + //------获取会员信息-----先获取用户信息,在进行下一步--- | |
| 98 | + get_info: function (func) { | |
| 99 | + var user_id = t.globalData.user_id; | |
| 100 | + to.auth.get_u(func); | |
| 101 | + }, | |
| 102 | + | |
| 103 | + //-------------------获取物流--------------- | |
| 104 | + get_wuliu(func) { | |
| 105 | + var th = this; | |
| 106 | + console.log("getwuliu4545"); | |
| 107 | + to.getwuliu(function (e) { | |
| 108 | + if (th.data.is_default_logistics) { | |
| 109 | + //如果第一个不是开启默认,说明要让用户自己选 | |
| 110 | + if (!e[0].is_default) { | |
| 111 | + th.setData({ is_default_logistics: 0 }); | |
| 83 | 112 | } |
| 84 | - //th.data.kt_type=appD.kt_type; | |
| 85 | - th.setData({kt_type: appD.kt_type}); | |
| 86 | - if (appD.is_pt_tz) th.data.is_pt_tz = appD.is_pt_tz; | |
| 87 | - th.data.param = t; | |
| 88 | - //先获取物流,再获取用户信息,再展示页面 | |
| 89 | - //th.get_wuliu(th.get_info(th.show_page)); | |
| 90 | - //判断是不是佣金抵扣 | |
| 91 | - getApp().is_distribut(this); | |
| 92 | - }, | |
| 93 | - onUnload: function () { | |
| 94 | - this.setData({isclose: 1}) | |
| 95 | - }, | |
| 96 | - | |
| 97 | - //------获取会员信息-----先获取用户信息,在进行下一步--- | |
| 98 | - get_info: function (func) { | |
| 99 | - var user_id = t.globalData.user_id; | |
| 100 | - to.auth.get_u(func); | |
| 101 | - }, | |
| 102 | - | |
| 103 | - //-------------------获取物流--------------- | |
| 104 | - get_wuliu(func) { | |
| 105 | - var th = this; | |
| 106 | - console.log("getwuliu4545"); | |
| 107 | - to.getwuliu(function (e) { | |
| 108 | - if (th.data.is_default_logistics) { | |
| 109 | - //如果第一个不是开启默认,说明要让用户自己选 | |
| 110 | - if (!e[0].is_default) { | |
| 111 | - th.setData({is_default_logistics: 0}); | |
| 112 | - } | |
| 113 | + } | |
| 114 | + th.setData({ wu_arr: e }) | |
| 115 | + typeof func == "function" && func(); | |
| 116 | + }) | |
| 117 | + }, | |
| 118 | + | |
| 119 | + //------获取会员收货地址----- | |
| 120 | + getuser_addr: function (func) { | |
| 121 | + if (to.globalData.baddr != null) { | |
| 122 | + var user_addr = to.globalData.baddr; | |
| 123 | + to.globalData.baddr = null; | |
| 124 | + func(user_addr); | |
| 125 | + } else { | |
| 126 | + a.get("/api/weshop/useraddress/page", { | |
| 127 | + data: { user_id: to.globalData.user_id, store_id: oo.stoid, pageSize: 600 }, | |
| 128 | + success: function (su) { | |
| 129 | + | |
| 130 | + var user_addr = su.data.data.pageData; | |
| 131 | + var item = null; | |
| 132 | + var def_item = null; | |
| 133 | + for (var i = 0; i < user_addr.length; i++) { | |
| 134 | + if (user_addr[i]['is_default'] == 1) { | |
| 135 | + def_item = user_addr[i]; | |
| 113 | 136 | } |
| 114 | - th.setData({wu_arr: e}) | |
| 115 | - typeof func == "function" && func(); | |
| 116 | - }) | |
| 117 | - }, | |
| 118 | - | |
| 119 | - //------获取会员收货地址----- | |
| 120 | - getuser_addr: function (func) { | |
| 121 | - if (to.globalData.baddr != null) { | |
| 122 | - var user_addr = to.globalData.baddr; | |
| 123 | - to.globalData.baddr = null; | |
| 124 | - func(user_addr); | |
| 125 | - } else { | |
| 126 | - a.get("/api/weshop/useraddress/page", { | |
| 127 | - data: {user_id: to.globalData.user_id, store_id: oo.stoid, pageSize: 600}, | |
| 128 | - success: function (su) { | |
| 129 | - | |
| 130 | - var user_addr = su.data.data.pageData; | |
| 131 | - var item = null; | |
| 132 | - var def_item = null; | |
| 133 | - for (var i = 0; i < user_addr.length; i++) { | |
| 134 | - if (user_addr[i]['is_default'] == 1) { | |
| 135 | - def_item = user_addr[i]; | |
| 136 | - } | |
| 137 | - if (user_addr[i]['is_pickup'] == 1) { | |
| 138 | - item = user_addr[i]; | |
| 139 | - } | |
| 140 | - } | |
| 141 | - if (item == null) item = def_item; | |
| 142 | - if (item == null) item = user_addr[0]; | |
| 143 | - if (item == undefined) item = null; | |
| 144 | - func(item); | |
| 145 | - } | |
| 146 | - }); | |
| 137 | + if (user_addr[i]['is_pickup'] == 1) { | |
| 138 | + item = user_addr[i]; | |
| 139 | + } | |
| 140 | + } | |
| 141 | + if (item == null) item = def_item; | |
| 142 | + if (item == null) item = user_addr[0]; | |
| 143 | + if (item == undefined) item = null; | |
| 144 | + func(item); | |
| 147 | 145 | } |
| 148 | - }, | |
| 149 | - //----------------展示页面,是再获取用户信息之后-------------- | |
| 150 | - show_page: function () { | |
| 151 | - var th = this; | |
| 152 | - //th.setData({ userinfo: to.globalData.userInfo}); 会员信息要时时获取 | |
| 153 | - var user = getApp().globalData.userInfo; | |
| 154 | - getApp().request.get("/api/weshop/users/get/" + oo.stoid + "/" + user.user_id, { | |
| 155 | - data: {r: Math.random()}, | |
| 156 | - success: function (e) { | |
| 157 | - | |
| 158 | - getApp().globalData.userInfo = e.data.data; | |
| 159 | - th.setData({userinfo: e.data.data}); | |
| 160 | - //获取立即购买的商品信息 | |
| 161 | - th.get_buy_goods(); | |
| 162 | - | |
| 163 | - //获取提现金额 | |
| 164 | - //noinspection JSUnresolvedFunction | |
| 165 | - getApp().request.get("/api/weshop/withdrawals/summoney", { | |
| 166 | - data: {user_id: to.globalData.user_id, store_id: oo.stoid, status: 0}, | |
| 167 | - success: function (su) { | |
| 168 | - if (su.data.code == 0) { | |
| 169 | - var yuer = parseFloat(th.data.userinfo.user_money - | |
| 170 | - (th.data.userinfo.frozen_money > 0 ? th.data.userinfo.frozen_money : 0) - su.data.data.summoney).toFixed(2); | |
| 171 | - if (yuer < 0) yuer = 0; | |
| 172 | - //noinspection JSUnresolvedVariable | |
| 173 | - th.setData({txmon: su.data.data.summoney, yuer: yuer}); | |
| 174 | - } | |
| 175 | - } | |
| 176 | - }); | |
| 146 | + }); | |
| 147 | + } | |
| 148 | + }, | |
| 149 | + //获取预存款余额 | |
| 150 | + async getAdvancesum() { | |
| 151 | + /*-----获取线下会员的预存款和优惠券的数量-----*/ | |
| 152 | + let url = "/api/weshop/users/getinfo/" + os.stoid + "/" + getApp().globalData.userInfo.user_id | |
| 153 | + await getApp().request.promiseGet(url, { | |
| 154 | + data: { | |
| 155 | + isShowLoading: 0, | |
| 156 | + }, | |
| 157 | + }).then(su => { | |
| 158 | + if (su.data.code == 0 && su.data.data) { | |
| 159 | + var data = su.data.data; | |
| 160 | + if (!data) data = {}; | |
| 161 | + data.cashcount = parseInt(data.cashcount); | |
| 162 | + this.setData({ | |
| 163 | + udata: data, | |
| 164 | + }); | |
| 165 | + } | |
| 166 | + }) | |
| 167 | + | |
| 168 | + }, | |
| 169 | + //购物车预存开启关闭 | |
| 170 | + prestore(e) { | |
| 171 | + let ind = e.currentTarget.dataset.ind; | |
| 172 | + let item = e.currentTarget.dataset.item | |
| 173 | + let txt = 'cartlist[' + ind + '].yck_off'; | |
| 174 | + let txt1 = 'old_cartlist[' + ind + '].yck_off'; | |
| 175 | + if (item.yck_off == 2) { | |
| 176 | + this.setData({ [txt]: 1, [txt1]: 1 }) | |
| 177 | + } else if (item.yck_off == 1) { | |
| 178 | + this.setData({ [txt]: 2, [txt1]: 2 }) | |
| 179 | + } | |
| 180 | + this.calculatePrice()//计算金额 | |
| 181 | + }, | |
| 182 | + //直接购买预存开启关闭 | |
| 183 | + prestore2() { | |
| 184 | + let txt = 'bn_goods.yck_off'; | |
| 185 | + if (this.data.bn_goods.yck_off == 2) { | |
| 186 | + this.setData({ [txt]: 1 }) | |
| 187 | + } else if (this.data.bn_goods.yck_off == 1) { | |
| 188 | + this.setData({ [txt]: 2 }) | |
| 189 | + } | |
| 190 | + this.calculatePrice2()//计算金额 | |
| 191 | + }, | |
| 192 | + //计算商品预存款前置方法------------------------------------ | |
| 193 | + async beforAdvancesum(cartList) { | |
| 194 | + // let cartList= this.data.cartlist | |
| 195 | + // let cartList= arr | |
| 196 | + // let length = cartList.length | |
| 197 | + wx.showLoading({ | |
| 198 | + title: '加载中', | |
| 199 | + mask: true | |
| 200 | + }) | |
| 201 | + // for (let i = 0; i < length; i++) { | |
| 202 | + let item = cartList; | |
| 203 | + let goods = item.goods | |
| 204 | + let keyid = item.sto.keyid | |
| 205 | + let listform = [] | |
| 206 | + goods.map(ite => { | |
| 207 | + let obj = { | |
| 208 | + wareno: ite.goods_sn, | |
| 209 | + price: ite.goods_price, | |
| 210 | + qty: ite.goods_num | |
| 211 | + } | |
| 212 | + listform.push(obj) | |
| 213 | + }) | |
| 214 | + let arr = await this.getGoodsAdvancesum(keyid, listform, cartList) | |
| 215 | + // } | |
| 216 | + wx.hideLoading() | |
| 217 | + return arr | |
| 218 | + }, | |
| 219 | + //计算商品预存款请求方法------------------------------------ | |
| 220 | + async getGoodsAdvancesum(storageid, listform, cartList) { | |
| 221 | + let res = await getApp().request.promisePost(`/api/weshop/delphiapi/saveErpApi`, { | |
| 222 | + data: { | |
| 223 | + accdb: getApp().globalData.config.erpid, | |
| 224 | + ApiName: 'api.pos.shop.advancesum.seek', | |
| 225 | + usercode: "admin", | |
| 226 | + vipid: this.data.userinfo.erpvipid, | |
| 227 | + oddsum: "0", | |
| 228 | + advancesum: cartList.order_amount, | |
| 229 | + storageid: storageid, | |
| 230 | + listform | |
| 231 | + }, | |
| 232 | + is_json: 1 | |
| 233 | + }) | |
| 234 | + console.log('计算商品的预存款'); | |
| 235 | + console.log(res); | |
| 236 | + let yck = 0 | |
| 237 | + let yckid = "" | |
| 238 | + let yckIdArr = [] | |
| 239 | + let pre_json = null | |
| 240 | + if (res.data.code == 0 && res.data.data && res.data.data.length > 0) { | |
| 241 | + let resData = res.data.data | |
| 242 | + resData.map(ite => { | |
| 243 | + yck += ite.advancesum | |
| 244 | + yckIdArr.push(ite.advanceitemid) | |
| 245 | + }) | |
| 246 | + pre_json = resData | |
| 247 | + } | |
| 248 | + yckid = yckIdArr.join() | |
| 249 | + let obj = {} | |
| 250 | + if (yck * 1 > 0) { | |
| 251 | + obj.yck_off = 1 | |
| 252 | + } else { | |
| 253 | + obj.yck_off = 0 | |
| 254 | + } | |
| 255 | + obj.yck = yck | |
| 256 | + obj.yckid = yckid | |
| 257 | + obj.pre_json = pre_json | |
| 258 | + return obj | |
| 259 | + }, | |
| 260 | + //----------------展示页面,是再获取用户信息之后-------------- | |
| 261 | + show_page: async function () { | |
| 262 | + var th = this; | |
| 263 | + //获取用户预存款 | |
| 264 | + await th.getAdvancesum() | |
| 265 | + //th.setData({ userinfo: to.globalData.userInfo}); 会员信息要时时获取 | |
| 266 | + var user = getApp().globalData.userInfo; | |
| 267 | + getApp().request.get("/api/weshop/users/get/" + oo.stoid + "/" + user.user_id, { | |
| 268 | + data: { r: Math.random() }, | |
| 269 | + success: function (e) { | |
| 270 | + | |
| 271 | + getApp().globalData.userInfo = e.data.data; | |
| 272 | + th.setData({ userinfo: e.data.data }); | |
| 273 | + //获取立即购买的商品信息 | |
| 274 | + th.get_buy_goods(); | |
| 275 | + | |
| 276 | + //获取提现金额 | |
| 277 | + //noinspection JSUnresolvedFunction | |
| 278 | + getApp().request.get("/api/weshop/withdrawals/summoney", { | |
| 279 | + data: { user_id: to.globalData.user_id, store_id: oo.stoid, status: 0 }, | |
| 280 | + success: function (su) { | |
| 281 | + if (su.data.code == 0) { | |
| 282 | + var yuer = parseFloat(th.data.userinfo.user_money - | |
| 283 | + (th.data.userinfo.frozen_money > 0 ? th.data.userinfo.frozen_money : 0) - su.data.data.summoney).toFixed(2); | |
| 284 | + if (yuer < 0) yuer = 0; | |
| 285 | + //noinspection JSUnresolvedVariable | |
| 286 | + th.setData({ txmon: su.data.data.summoney, yuer: yuer }); | |
| 177 | 287 | } |
| 288 | + } | |
| 178 | 289 | }); |
| 179 | - }, | |
| 180 | - | |
| 181 | - //-----获取立即购买的商品信息---- | |
| 182 | - get_buy_goods: function () { | |
| 183 | - var th = this, a = getApp().request; | |
| 184 | - var gg = th.data.postdata; | |
| 185 | - //调用商品 | |
| 186 | - a.get("/api/weshop/goods/get/" + oo.stoid + "/" + gg.goods_id, { | |
| 187 | - success: async function (t) { | |
| 188 | - var gd = t.data.data; | |
| 189 | - if (!gd) return false; | |
| 290 | + } | |
| 291 | + }); | |
| 292 | + }, | |
| 293 | + | |
| 294 | + //-----获取立即购买的商品信息---- | |
| 295 | + get_buy_goods: function () { | |
| 296 | + var th = this, a = getApp().request; | |
| 297 | + var gg = th.data.postdata; | |
| 298 | + //调用商品 | |
| 299 | + a.get("/api/weshop/goods/get/" + oo.stoid + "/" + gg.goods_id, { | |
| 300 | + success: async function (t) { | |
| 301 | + var gd = t.data.data; | |
| 302 | + if (!gd) return false; | |
| 303 | + | |
| 304 | + | |
| 305 | + //-- 如果商品有同城配送的参数的时候,一件代发商品不能显示同城配送按钮 -- | |
| 306 | + if (gd.is_same_city && th.data.is_same_city && gd.whsle_id <= 0) { | |
| 307 | + | |
| 308 | + await getApp().request.promiseGet("/api/weshop/pickup/get/" + os.stoid + "/" + gg.pick_id, {}).then(res => { | |
| 309 | + if (res.data.code == 0) { | |
| 310 | + var pk = res.data.data; | |
| 311 | + if (pk && pk.is_same_city) { | |
| 312 | + th.setData({ show_same_city: 1 }) | |
| 313 | + } | |
| 314 | + } | |
| 190 | 315 | |
| 316 | + }) | |
| 191 | 317 | |
| 192 | - //-- 如果商品有同城配送的参数的时候,一件代发商品不能显示同城配送按钮 -- | |
| 193 | - if (gd.is_same_city && th.data.is_same_city && gd.whsle_id <= 0) { | |
| 318 | + } | |
| 194 | 319 | |
| 195 | - await getApp().request.promiseGet("/api/weshop/pickup/get/" + os.stoid + "/" + gg.pick_id, {}).then(res => { | |
| 196 | - if (res.data.code == 0) { | |
| 197 | - var pk = res.data.data; | |
| 198 | - if (pk && pk.is_same_city) { | |
| 199 | - th.setData({show_same_city: 1}) | |
| 200 | - } | |
| 201 | - } | |
| 320 | + t.data.data.original_img = oo.imghost + t.data.data.original_img; | |
| 321 | + t.data.data['buynum'] = gg.goods_num; | |
| 322 | + console.log(t.data.data); | |
| 323 | + var distr_t = 0, et = 0; | |
| 202 | 324 | |
| 203 | - }) | |
| 325 | + if (t.data.data.is_minishop == 1 && getApp().is_sp_hao()) { | |
| 204 | 326 | |
| 205 | - } | |
| 327 | + if (t.data.data.distr_type == 1 || gg.pick_dis == 1) { | |
| 328 | + wx.showToast({ | |
| 329 | + title: "视频号仅支持物流", | |
| 330 | + icon: 'none', | |
| 331 | + duration: 2000 | |
| 332 | + }) | |
| 206 | 333 | |
| 207 | - t.data.data.original_img = oo.imghost + t.data.data.original_img; | |
| 208 | - t.data.data['buynum'] = gg.goods_num; | |
| 209 | - console.log(t.data.data); | |
| 210 | - var distr_t = 0, et = 0; | |
| 334 | + setTimeout(function () { | |
| 335 | + wx.navigateBack({ delta: 1 }) | |
| 336 | + }, 1000) | |
| 211 | 337 | |
| 212 | - if (t.data.data.is_minishop == 1 && getApp().is_sp_hao()) { | |
| 213 | 338 | |
| 214 | - if (t.data.data.distr_type == 1 || gg.pick_dis == 1) { | |
| 215 | - wx.showToast({ | |
| 216 | - title: "视频号仅支持物流", | |
| 217 | - icon: 'none', | |
| 218 | - duration: 2000 | |
| 219 | - }) | |
| 339 | + return false | |
| 340 | + } | |
| 220 | 341 | |
| 221 | - setTimeout(function () { | |
| 222 | - wx.navigateBack({delta: 1}) | |
| 223 | - }, 1000) | |
| 342 | + t.data.data.distr_type = 2; | |
| 343 | + th.setData({ show_same_city: 0 }) | |
| 224 | 344 | |
| 345 | + } | |
| 225 | 346 | |
| 226 | - return false | |
| 227 | - } | |
| 347 | + if (t.data.data.distr_type == 0) { | |
| 348 | + distr_t = gg.pick_dis; | |
| 349 | + } else { | |
| 350 | + distr_t = t.data.data.distr_type; | |
| 351 | + } | |
| 352 | + switch (distr_t) { | |
| 353 | + case 0: | |
| 354 | + et = 1; | |
| 355 | + //-- 系统后台有设置要默认的 -- | |
| 356 | + if (th.data.json_d.pickupway && th.data.json_d.pickupway == 1) et = 0; | |
| 357 | + break; | |
| 358 | + case 1: | |
| 359 | + et = 1; | |
| 360 | + break; | |
| 361 | + case 2: | |
| 362 | + et = 0; | |
| 363 | + break; | |
| 364 | + } | |
| 228 | 365 | |
| 229 | - t.data.data.distr_type = 2; | |
| 230 | - th.setData({show_same_city: 0}) | |
| 366 | + t.data.data.shop_price = gg.goods_price; | |
| 367 | + //--如果是普通购买的时候-- | |
| 368 | + if (gg.is_normal == 1) { | |
| 369 | + t.data.data.prom_id = 0; | |
| 370 | + t.data.data.prom_type = 0; | |
| 371 | + t.data.data.is_normal = 1; | |
| 372 | + | |
| 373 | + var gd = t.data.data; | |
| 374 | + //-- 用商品的手店价来显示 -- | |
| 375 | + gg.goods_price = gd.shop_price; | |
| 376 | + //---是不是购买等级卡成功的返回---等级卡显示的判断--- | |
| 377 | + var is_card_back = getApp().globalData.is_card_back; | |
| 378 | + if (is_card_back) { | |
| 379 | + gg.goods_price = gd[th.data.card_name]; | |
| 380 | + t.data.data.shop_price = gg.goods_price; | |
| 381 | + getApp().globalData.is_card_back = 0; | |
| 382 | + th.setData({ card_cut_price: 0 }); | |
| 383 | + } else { | |
| 384 | + //--- 商品不能是搭配购,商家等级卡开通的情况下, 会员不是等级会员的情况, 商品有设置等级卡价格,同时等级卡价格小于商品的价格 | |
| 385 | + if (th.data.card_name && gd[th.data.card_name] > 0 && gg.goods_price > gd[th.data.card_name] && !th.data.userinfo.card_field) { | |
| 386 | + var cut_p = gg.goods_price - gd[th.data.card_name]; | |
| 387 | + th.setData({ card_cut_price: cut_p }); | |
| 388 | + } | |
| 389 | + } | |
| 231 | 390 | |
| 232 | - } | |
| 391 | + if (th.data.bn_goods) { | |
| 392 | + et = th.data.bn_exp_type; | |
| 393 | + } | |
| 233 | 394 | |
| 234 | - if (t.data.data.distr_type == 0) { | |
| 235 | - distr_t = gg.pick_dis; | |
| 236 | - } else { | |
| 237 | - distr_t = t.data.data.distr_type; | |
| 238 | - } | |
| 239 | - switch (distr_t) { | |
| 240 | - case 0: | |
| 241 | - et = 1; | |
| 242 | - //-- 系统后台有设置要默认的 -- | |
| 243 | - if (th.data.json_d.pickupway && th.data.json_d.pickupway == 1) et = 0; | |
| 244 | - break; | |
| 245 | - case 1: | |
| 246 | - et = 1; | |
| 247 | - break; | |
| 248 | - case 2: | |
| 249 | - et = 0; | |
| 250 | - break; | |
| 251 | - } | |
| 252 | 395 | |
| 253 | - t.data.data.shop_price = gg.goods_price; | |
| 254 | - //--如果是普通购买的时候-- | |
| 255 | - if (gg.is_normal == 1) { | |
| 256 | - t.data.data.prom_id = 0; | |
| 257 | - t.data.data.prom_type = 0; | |
| 258 | - t.data.data.is_normal = 1; | |
| 259 | - | |
| 260 | - var gd = t.data.data; | |
| 261 | - //-- 用商品的手店价来显示 -- | |
| 262 | - gg.goods_price = gd.shop_price; | |
| 263 | - //---是不是购买等级卡成功的返回---等级卡显示的判断--- | |
| 264 | - var is_card_back = getApp().globalData.is_card_back; | |
| 265 | - if (is_card_back) { | |
| 266 | - gg.goods_price = gd[th.data.card_name]; | |
| 267 | - t.data.data.shop_price = gg.goods_price; | |
| 268 | - getApp().globalData.is_card_back = 0; | |
| 269 | - th.setData({card_cut_price: 0}); | |
| 270 | - } else { | |
| 271 | - //--- 商品不能是搭配购,商家等级卡开通的情况下, 会员不是等级会员的情况, 商品有设置等级卡价格,同时等级卡价格小于商品的价格 | |
| 272 | - if (th.data.card_name && gd[th.data.card_name] > 0 && gg.goods_price > gd[th.data.card_name] && !th.data.userinfo.card_field) { | |
| 273 | - var cut_p = gg.goods_price - gd[th.data.card_name]; | |
| 274 | - th.setData({card_cut_price: cut_p}); | |
| 275 | - } | |
| 276 | - } | |
| 396 | + //-- 计算获得佣金的金额 -- | |
| 397 | + if (getApp().globalData.userInfo.is_distribut | |
| 398 | + && th.data.dis_config && th.data.dis_config.is_yongjin_dk) { | |
| 277 | 399 | |
| 278 | - if (th.data.bn_goods) { | |
| 279 | - et = th.data.bn_exp_type; | |
| 280 | - } | |
| 400 | + var c_num = getApp().get_commission2(th.data.dis_config, t.data.data, gg.goods_num); | |
| 281 | 401 | |
| 402 | + gd.use_commission = c_num; | |
| 403 | + t.data.data.use_commission = c_num; | |
| 282 | 404 | |
| 283 | - //-- 计算获得佣金的金额 -- | |
| 284 | - if (getApp().globalData.userInfo.is_distribut | |
| 285 | - && th.data.dis_config && th.data.dis_config.is_yongjin_dk) { | |
| 405 | + } | |
| 286 | 406 | |
| 287 | - var c_num = getApp().get_commission2(th.data.dis_config, t.data.data, gg.goods_num); | |
| 288 | 407 | |
| 289 | - gd.use_commission = c_num; | |
| 290 | - t.data.data.use_commission = c_num; | |
| 408 | + th.setData({ | |
| 409 | + bn_goods: t.data.data, bn_pickname: gg.pick_name, | |
| 410 | + bn_pick: gg.pick_id, bn_t_exp_t: distr_t, is_normal: 1, bn_exp_type: et | |
| 411 | + }); | |
| 291 | 412 | |
| 292 | - } | |
| 293 | 413 | |
| 414 | + th.calculatePrice2(); | |
| 415 | + } else { | |
| 294 | 416 | |
| 295 | - th.setData({ | |
| 296 | - bn_goods: t.data.data, bn_pickname: gg.pick_name, | |
| 297 | - bn_pick: gg.pick_id, bn_t_exp_t: distr_t, is_normal: 1, bn_exp_type: et | |
| 298 | - }); | |
| 417 | + //--阶梯团很特殊,不能用总表来拿价格-- | |
| 418 | + getApp().request.get("/api/weshop/teamlist/get/" + oo.stoid + "/" + gd.prom_id, { | |
| 419 | + success: function (tt) { | |
| 420 | + | |
| 421 | + if (tt.data.code == 0) { | |
| 422 | + var pt_data = tt.data.data; | |
| 423 | + var now = s.gettimestamp(); | |
| 424 | + | |
| 425 | + if (pt_data.is_end == 1) { | |
| 426 | + t.data.data.prom_id = 0; | |
| 427 | + t.data.data.prom_type = 0; | |
| 428 | + t.data.data.is_normal = 1; | |
| 429 | + } else if (now > pt_data.end_time) { | |
| 430 | + t.data.data.prom_id = 0; | |
| 431 | + t.data.data.prom_type = 0; | |
| 432 | + t.data.data.is_normal = 1; | |
| 433 | + } else { | |
| 434 | + t.data.data.shop_price = tt.data.data.price; //活动价格 | |
| 435 | + t.data.data.is_normal = 0; | |
| 299 | 436 | |
| 437 | + t.data.data.fir_rate = tt.data.data.fir_rate; | |
| 438 | + t.data.data.sec_rate = tt.data.data.sec_rate; | |
| 439 | + t.data.data.thi_rate = tt.data.data.thi_rate; | |
| 440 | + t.data.data.commission = tt.data.data.commission; | |
| 300 | 441 | |
| 301 | - th.calculatePrice2(); | |
| 302 | - } else { | |
| 303 | 442 | |
| 304 | - //--阶梯团很特殊,不能用总表来拿价格-- | |
| 305 | - getApp().request.get("/api/weshop/teamlist/get/" + oo.stoid + "/" + gd.prom_id, { | |
| 306 | - success: function (tt) { | |
| 307 | - | |
| 308 | - if (tt.data.code == 0) { | |
| 309 | - var pt_data = tt.data.data; | |
| 310 | - var now = s.gettimestamp(); | |
| 311 | - | |
| 312 | - if (pt_data.is_end == 1) { | |
| 313 | - t.data.data.prom_id = 0; | |
| 314 | - t.data.data.prom_type = 0; | |
| 315 | - t.data.data.is_normal = 1; | |
| 316 | - } else if (now > pt_data.end_time) { | |
| 317 | - t.data.data.prom_id = 0; | |
| 318 | - t.data.data.prom_type = 0; | |
| 319 | - t.data.data.is_normal = 1; | |
| 320 | - } else { | |
| 321 | - t.data.data.shop_price = tt.data.data.price; //活动价格 | |
| 322 | - t.data.data.is_normal = 0; | |
| 323 | - | |
| 324 | - t.data.data.fir_rate = tt.data.data.fir_rate; | |
| 325 | - t.data.data.sec_rate = tt.data.data.sec_rate; | |
| 326 | - t.data.data.thi_rate = tt.data.data.thi_rate; | |
| 327 | - t.data.data.commission = tt.data.data.commission; | |
| 328 | - | |
| 329 | - | |
| 330 | - if (pt_data.kttype == 3) { | |
| 331 | - t.data.data.shop_price = tt.data.data.yf_price; //用定金来购买 | |
| 332 | - } | |
| 333 | - } | |
| 334 | - } else { | |
| 335 | - t.data.data.prom_id = 0; | |
| 336 | - t.data.data.prom_type = 0; | |
| 337 | - t.data.data.is_normal = 1; | |
| 338 | - } | |
| 339 | - | |
| 340 | - if (th.data.bn_goods) { | |
| 341 | - et = th.data.bn_exp_type; | |
| 342 | - } | |
| 343 | - | |
| 344 | - | |
| 345 | - //-- 计算获得佣金的金额 -- | |
| 346 | - if (getApp().globalData.userInfo.is_distribut | |
| 347 | - && th.data.dis_config && th.data.dis_config.is_yongjin_dk) { | |
| 348 | - var fir_num = 0; | |
| 349 | - var sec_num = 0; | |
| 350 | - var thi_num = 0; | |
| 351 | - if (th.data.dis_config.pattern == 1) { | |
| 352 | - fir_num = (t.data.data.fir_rate || 0) * gg.goods_num; | |
| 353 | - sec_num = (t.data.data.sec_rate || 0) * gg.goods_num; | |
| 354 | - thi_num = (t.data.data.thi_rate || 0) * gg.goods_num; | |
| 355 | - } else { | |
| 356 | - fir_num = parseFloat((t.data.data.commission || 0) * gg.goods_num * (th.data.dis_config.firstRate || 0) / 100).toFixed(2); | |
| 357 | - sec_num = parseFloat((t.data.data.commission || 0) * gg.goods_num * (th.data.dis_config.secondRate || 0) / 100).toFixed(2); | |
| 358 | - thi_num = parseFloat((t.data.data.commission || 0) * gg.goods_num * (th.data.dis_config.thirdRate || 0) / 100).toFixed(2); | |
| 359 | - } | |
| 360 | - var c_num = getApp().get_commission(fir_num, sec_num, thi_num, th); | |
| 361 | - | |
| 362 | - gd.use_commission = c_num; | |
| 363 | - t.data.data.use_commission = c_num; | |
| 364 | - | |
| 365 | - } | |
| 366 | - | |
| 367 | - | |
| 368 | - th.setData({ | |
| 369 | - bn_goods: t.data.data, bn_pickname: gg.pick_name, | |
| 370 | - bn_pick: gg.pick_id, bn_t_exp_t: distr_t, bn_exp_type: et | |
| 371 | - }); | |
| 372 | - | |
| 373 | - | |
| 374 | - //计算价格 | |
| 375 | - th.calculatePrice2(); | |
| 376 | - } | |
| 377 | - }); | |
| 443 | + if (pt_data.kttype == 3) { | |
| 444 | + t.data.data.shop_price = tt.data.data.yf_price; //用定金来购买 | |
| 445 | + } | |
| 378 | 446 | } |
| 379 | - } | |
| 380 | - }); | |
| 381 | - }, | |
| 382 | - | |
| 383 | - //----------子页返回父页触发---------- | |
| 384 | - onShow: function () { | |
| 385 | - var th = this; | |
| 386 | - if (th.data.isclose == 0) { | |
| 387 | - wx.navigateTo({ | |
| 388 | - url: "/pages/index/index/index" | |
| 389 | - }) | |
| 390 | - } else { | |
| 391 | - this.getuser_addr(function (ie) { | |
| 392 | - //更换地址回来要重新调用计算价钱的接口 | |
| 393 | - th.setData({user_addr: ie}); | |
| 394 | - if (!th.data.user_addr || th.data.user_addr.address_id != ie.address_id) { | |
| 395 | - th.setData({add_back: 1}); | |
| 396 | - if (th.data.bn_goods) th.calculatePrice2(); | |
| 447 | + } else { | |
| 448 | + t.data.data.prom_id = 0; | |
| 449 | + t.data.data.prom_type = 0; | |
| 450 | + t.data.data.is_normal = 1; | |
| 451 | + } | |
| 452 | + | |
| 453 | + if (th.data.bn_goods) { | |
| 454 | + et = th.data.bn_exp_type; | |
| 455 | + } | |
| 456 | + | |
| 457 | + | |
| 458 | + //-- 计算获得佣金的金额 -- | |
| 459 | + if (getApp().globalData.userInfo.is_distribut | |
| 460 | + && th.data.dis_config && th.data.dis_config.is_yongjin_dk) { | |
| 461 | + var fir_num = 0; | |
| 462 | + var sec_num = 0; | |
| 463 | + var thi_num = 0; | |
| 464 | + if (th.data.dis_config.pattern == 1) { | |
| 465 | + fir_num = (t.data.data.fir_rate || 0) * gg.goods_num; | |
| 466 | + sec_num = (t.data.data.sec_rate || 0) * gg.goods_num; | |
| 467 | + thi_num = (t.data.data.thi_rate || 0) * gg.goods_num; | |
| 468 | + } else { | |
| 469 | + fir_num = parseFloat((t.data.data.commission || 0) * gg.goods_num * (th.data.dis_config.firstRate || 0) / 100).toFixed(2); | |
| 470 | + sec_num = parseFloat((t.data.data.commission || 0) * gg.goods_num * (th.data.dis_config.secondRate || 0) / 100).toFixed(2); | |
| 471 | + thi_num = parseFloat((t.data.data.commission || 0) * gg.goods_num * (th.data.dis_config.thirdRate || 0) / 100).toFixed(2); | |
| 397 | 472 | } |
| 398 | - }) | |
| 399 | - //--更新默认地址--,看一下是不是跳到地址页面 | |
| 400 | - if (!getApp().globalData.is_cart_old) { | |
| 401 | - this.update_code(); | |
| 402 | - } else { | |
| 403 | - getApp().globalData.is_cart_old = 0; | |
| 404 | - } | |
| 405 | - } | |
| 473 | + var c_num = getApp().get_commission(fir_num, sec_num, thi_num, th); | |
| 406 | 474 | |
| 475 | + gd.use_commission = c_num; | |
| 476 | + t.data.data.use_commission = c_num; | |
| 407 | 477 | |
| 408 | - //先获取是否有关闭使用优惠券 | |
| 409 | - getApp().getConfig2(function (ee) { | |
| 410 | - var json_d = JSON.parse(ee.switch_list); | |
| 411 | - th.data.json_d = json_d; | |
| 412 | - th.data.ispt_goods = json_d.ispt_goods; //是不是平摊到单品的控制参数赋值 | |
| 413 | - var is_default_logistics = json_d.is_default_logistics; | |
| 414 | - var is_same_city = json_d.is_same_city; | |
| 415 | - | |
| 416 | - th.setData({ | |
| 417 | - is_close_quan: json_d.is_close_quan, sales_rules: ee.sales_rules, is_same_city: is_same_city, | |
| 418 | - rank_switch: json_d.rank_switch, is_default_logistics: is_default_logistics | |
| 419 | - }); | |
| 420 | - | |
| 421 | - var rank_switch = json_d.rank_switch; | |
| 422 | - var max_price = -1; | |
| 423 | - var show_card = null; | |
| 424 | - var name = ""; | |
| 425 | - //如果有开等级卡的时候, | |
| 426 | - //因为都是调接口,要返回在计算 | |
| 427 | - if (rank_switch == 2) { | |
| 428 | - //-- 获取所有的等级卡, -- | |
| 429 | - getApp().request.promiseGet("/api/weshop/plus/vip/mem/bership/list?storeId=" + os.stoid, | |
| 430 | - {}).then(res => { | |
| 431 | - if (res.data.code == 0) { | |
| 432 | - var plusCard = res.data.data; | |
| 433 | - //-- 循环判断,拿到最贵的那张卡 -- | |
| 434 | - for (var ih in plusCard) { | |
| 435 | - if (plusCard[ih].IsStopBuy == true) { | |
| 436 | - continue; | |
| 437 | - } | |
| 438 | - if (max_price < 0) { | |
| 439 | - max_price = plusCard[ih].CardFee; | |
| 440 | - name = 'card' + plusCard[ih]['CorrPrice']; | |
| 441 | - show_card = plusCard[ih]; | |
| 442 | - } else { | |
| 443 | - if (max_price < plusCard[ih].CardFee) { | |
| 444 | - max_price = plusCard[ih].CardFee; | |
| 445 | - name = 'card' + plusCard[ih]['CorrPrice']; | |
| 446 | - show_card = plusCard[ih]; | |
| 447 | - } | |
| 448 | - } | |
| 449 | - } | |
| 450 | - | |
| 451 | - if (show_card) { | |
| 452 | - name = name.toLowerCase(); | |
| 453 | - th.setData({card_name: name, show_card: show_card}) | |
| 454 | - } | |
| 455 | - } | |
| 456 | - //-----先获取物流,再获取用户信息,再展示页面----- | |
| 457 | - th.get_wuliu(th.get_info(th.show_page)); | |
| 458 | - }) | |
| 459 | - } else { | |
| 460 | - //-----先获取物流,再获取用户信息,再展示页面----- | |
| 461 | - th.get_wuliu(th.get_info(th.show_page)); | |
| 462 | - } | |
| 463 | - }, 1) | |
| 478 | + } | |
| 464 | 479 | |
| 465 | - }, | |
| 466 | - //---------------检查是否有收货地址------------------- | |
| 467 | - checkAddressList: function () { | |
| 468 | - var t = this; | |
| 469 | - return !(!this.data.order || null == this.data.order.userAddress) || (wx.showModal({ | |
| 470 | - title: "请先填写或选择收货地址~", | |
| 471 | - success: function (a) { | |
| 472 | - a.confirm ? t.enterAddressPage() : wx.navigateBack(); | |
| 473 | - }, | |
| 474 | - fail: function () { | |
| 475 | - wx.navigateBack(); | |
| 476 | - } | |
| 477 | - }), !1); | |
| 478 | - }, | |
| 479 | - showInvoice: function () { | |
| 480 | - this.setData({ | |
| 481 | - invoiceToggle: !this.data.invoiceToggle | |
| 482 | - }); | |
| 483 | - }, | |
| 484 | - keyUpChangePay1: function (t) { | |
| 485 | - this.setData({ | |
| 486 | - payWithUserMoney: !(t.detail.value.length > 0) | |
| 487 | - }); | |
| 488 | - }, | |
| 489 | - keyUpChangePay2: function (t) { | |
| 490 | - this.setData({ | |
| 491 | - payWithPoints: !(t.detail.value.length > 0) | |
| 492 | - }); | |
| 493 | - }, | |
| 494 | - keyUpChangeNum: function (t) { | |
| 495 | - this.setData({ | |
| 496 | - maxWord: t.detail.value.length | |
| 497 | - }); | |
| 498 | - }, | |
| 499 | - //---------计算立即购买---------- | |
| 500 | - calculatePrice2: async function () { | |
| 501 | - | |
| 502 | - this.setData({submit: 1}); | |
| 503 | - wx.showLoading({ | |
| 504 | - title: "处理中.", | |
| 505 | - mask: true | |
| 506 | - }) | |
| 507 | 480 | |
| 508 | - var th = this, good = this.data.bn_goods; | |
| 509 | - //-----------计算商品总价-------------- | |
| 510 | - var allpice = good.shop_price * good.buynum; | |
| 511 | - allpice = parseFloat(allpice).toFixed(2); | |
| 512 | - var txt = "formData.all_price"; | |
| 513 | - th.setData({[txt]: allpice,}); | |
| 481 | + th.setData({ | |
| 482 | + bn_goods: t.data.data, bn_pickname: gg.pick_name, | |
| 483 | + bn_pick: gg.pick_id, bn_t_exp_t: distr_t, bn_exp_type: et | |
| 484 | + }); | |
| 514 | 485 | |
| 515 | - //to.getwuliuprice(async function (rs) { | |
| 516 | - console.log('calculatePrice2222'); | |
| 517 | - //console.log(rs); | |
| 518 | 486 | |
| 519 | - var o_shipping_price = 0, goods_weight = -1, goods_piece = -1; | |
| 520 | - var out_of_weight = null; //超出多少重量 | |
| 521 | - | |
| 522 | - //-----------当地址不为空,且是物流时,计算物流费用,同时阶梯团不计算拼团价格---------- | |
| 523 | - if (th.data.user_addr != null && th.data.bn_exp_type == 0 && good.is_free_shipping == 0 && (th.data.kt_type != 3 || th.data.bn_goods.is_normal == 1)) { | |
| 524 | - | |
| 525 | - var user_addr = th.data.user_addr; | |
| 526 | - var req_d = { | |
| 527 | - province: user_addr.province, city: user_addr.city, district: user_addr.district, | |
| 528 | - wuliu: parseFloat(allpice).toFixed(2), store_id: os.stoid | |
| 487 | + //计算价格 | |
| 488 | + th.calculatePrice2(); | |
| 529 | 489 | } |
| 530 | - var back_data = null; | |
| 531 | - await getApp().request.promisePost("/api/weshop/order/areaFreight", { | |
| 532 | - is_json: 1, data: req_d | |
| 533 | - }).then(rs => { | |
| 534 | - if (rs.data.code == 0) back_data = rs.data.data; | |
| 535 | - }); | |
| 536 | - | |
| 537 | - var gd_arr_list = []; | |
| 538 | - gd_arr_list.push(good); | |
| 539 | - var cut_good_weight = 0; | |
| 540 | - for (let i in gd_arr_list) { | |
| 541 | - let item = gd_arr_list[i]; | |
| 542 | - | |
| 543 | - if (back_data && back_data['is_by_all'] && (!back_data.no_free_goods || back_data.no_free_goods.indexOf(item.goods_id) == -1)) { | |
| 544 | - | |
| 545 | - if (item['exp_sum_type'] == 2 && back_data.weight_free > 0) { | |
| 546 | - if (goods_weight < 0) goods_weight = 0; | |
| 547 | - cut_good_weight += item['weight'] * item['buynum']; | |
| 548 | - goods_weight += item['weight'] * item['buynum']; | |
| 549 | - } | |
| 550 | - if (back_data.weight_free > 0) { | |
| 551 | - out_of_weight = (back_data.weight_free * 1000) - cut_good_weight; | |
| 552 | - } | |
| 553 | - continue; | |
| 554 | - } | |
| 555 | - | |
| 556 | - switch (item['exp_sum_type']) { | |
| 557 | - case 1: | |
| 558 | - //统一运费 | |
| 559 | - o_shipping_price += item['uniform_exp_sum']; | |
| 560 | - break; | |
| 561 | - case 2: | |
| 562 | - if (goods_weight < 0) goods_weight = 0; | |
| 563 | - //累积商品重量 每种商品的重量 * 数量 | |
| 564 | - goods_weight += item['weight'] * item['buynum']; | |
| 565 | - | |
| 566 | - if (back_data && back_data.is_by_all && !back_data.no_free_goods) { | |
| 567 | - cut_good_weight += item['weight'] * item['buynum']; | |
| 568 | - if (back_data.weight_free > 0) { | |
| 569 | - out_of_weight = (back_data.weight_free * 1000) - cut_good_weight; | |
| 570 | - } | |
| 571 | - } | |
| 572 | - break; | |
| 573 | - case 3: | |
| 574 | - if (goods_piece < 0) goods_piece = 0; | |
| 575 | - //累积商品数量 | |
| 576 | - goods_piece += item['buynum']; | |
| 577 | - break; | |
| 578 | - } | |
| 579 | - } | |
| 580 | - | |
| 581 | - //如果是正值的时候 | |
| 582 | - if (out_of_weight >= 0) out_of_weight = -cut_good_weight; | |
| 583 | - else out_of_weight = -back_data.weight_free * 1000; | |
| 584 | - | |
| 585 | - | |
| 586 | - var code = th.data.wu_arr[th.data.index].code; | |
| 587 | - | |
| 588 | - //--------------开始计算物流------------------ | |
| 589 | - var shipping_price = 0; | |
| 590 | - // var shipping_price = ut.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, | |
| 591 | - // goods_piece, th.data.user_addr, back_data, rs); | |
| 490 | + }); | |
| 491 | + } | |
| 492 | + } | |
| 493 | + }); | |
| 494 | + }, | |
| 495 | + | |
| 496 | + //----------子页返回父页触发---------- | |
| 497 | + onShow: function () { | |
| 498 | + var th = this; | |
| 499 | + if (th.data.isclose == 0) { | |
| 500 | + wx.navigateTo({ | |
| 501 | + url: "/pages/index/index/index" | |
| 502 | + }) | |
| 503 | + } else { | |
| 504 | + this.getuser_addr(function (ie) { | |
| 505 | + //更换地址回来要重新调用计算价钱的接口 | |
| 506 | + th.setData({ user_addr: ie }); | |
| 507 | + if (!th.data.user_addr || th.data.user_addr.address_id != ie.address_id) { | |
| 508 | + th.setData({ add_back: 1 }); | |
| 509 | + if (th.data.bn_goods) th.calculatePrice2(); | |
| 510 | + } | |
| 511 | + }) | |
| 512 | + //--更新默认地址--,看一下是不是跳到地址页面 | |
| 513 | + if (!getApp().globalData.is_cart_old) { | |
| 514 | + this.update_code(); | |
| 515 | + } else { | |
| 516 | + getApp().globalData.is_cart_old = 0; | |
| 517 | + } | |
| 518 | + } | |
| 592 | 519 | |
| 593 | - var w_data = { | |
| 594 | - store_id: os.stoid, code: code, | |
| 595 | - o_shipping_price: o_shipping_price, | |
| 596 | - goods_weight: goods_weight, | |
| 597 | - out_of_weight: out_of_weight, goods_piece: goods_piece, | |
| 598 | - user_addr_province: th.data.user_addr.province, | |
| 599 | - user_addr_city: th.data.user_addr.city, | |
| 600 | - user_addr_district: th.data.user_addr.district, | |
| 601 | - is_by_all: back_data && back_data.is_by_all ? 1 : 0, | |
| 602 | - no_free_goods: back_data && back_data.no_free_goods && back_data.no_free_goods.length > 0 ? 1 : 0, | |
| 603 | - } | |
| 604 | 520 | |
| 605 | - var is_ok = 0; | |
| 606 | - await getApp().request.promisePost('/api/weshop/order/getOrderWuLiPrice', { | |
| 607 | - data: w_data, | |
| 608 | - is_json: 1 | |
| 609 | - }).then(res => { | |
| 610 | - if (res.data.code == 0) { | |
| 611 | - shipping_price = res.data.data; | |
| 612 | - is_ok = 1; | |
| 521 | + //先获取是否有关闭使用优惠券 | |
| 522 | + getApp().getConfig2(function (ee) { | |
| 523 | + var json_d = JSON.parse(ee.switch_list); | |
| 524 | + th.data.json_d = json_d; | |
| 525 | + th.data.ispt_goods = json_d.ispt_goods; //是不是平摊到单品的控制参数赋值 | |
| 526 | + var is_default_logistics = json_d.is_default_logistics; | |
| 527 | + var is_same_city = json_d.is_same_city; | |
| 528 | + | |
| 529 | + th.setData({ | |
| 530 | + is_close_quan: json_d.is_close_quan, sales_rules: ee.sales_rules, is_same_city: is_same_city, | |
| 531 | + rank_switch: json_d.rank_switch, is_default_logistics: is_default_logistics | |
| 532 | + }); | |
| 533 | + | |
| 534 | + var rank_switch = json_d.rank_switch; | |
| 535 | + var max_price = -1; | |
| 536 | + var show_card = null; | |
| 537 | + var name = ""; | |
| 538 | + //如果有开等级卡的时候, | |
| 539 | + //因为都是调接口,要返回在计算 | |
| 540 | + if (rank_switch == 2) { | |
| 541 | + //-- 获取所有的等级卡, -- | |
| 542 | + getApp().request.promiseGet("/api/weshop/plus/vip/mem/bership/list?storeId=" + os.stoid, | |
| 543 | + {}).then(res => { | |
| 544 | + if (res.data.code == 0) { | |
| 545 | + var plusCard = res.data.data; | |
| 546 | + //-- 循环判断,拿到最贵的那张卡 -- | |
| 547 | + for (var ih in plusCard) { | |
| 548 | + if (plusCard[ih].IsStopBuy == true) { | |
| 549 | + continue; | |
| 613 | 550 | } |
| 614 | - }) | |
| 615 | - if (!is_ok) { | |
| 616 | - wx.hideLoading(); | |
| 617 | - wx.showToast({ | |
| 618 | - title: "计算物流错误", icon: 'none', duration: 2000 | |
| 619 | - }) | |
| 620 | - //th.setData({ show_submit:0 }); | |
| 551 | + if (max_price < 0) { | |
| 552 | + max_price = plusCard[ih].CardFee; | |
| 553 | + name = 'card' + plusCard[ih]['CorrPrice']; | |
| 554 | + show_card = plusCard[ih]; | |
| 555 | + } else { | |
| 556 | + if (max_price < plusCard[ih].CardFee) { | |
| 557 | + max_price = plusCard[ih].CardFee; | |
| 558 | + name = 'card' + plusCard[ih]['CorrPrice']; | |
| 559 | + show_card = plusCard[ih]; | |
| 560 | + } | |
| 561 | + } | |
| 562 | + } | |
| 621 | 563 | |
| 622 | - return false; | |
| 564 | + if (show_card) { | |
| 565 | + name = name.toLowerCase(); | |
| 566 | + th.setData({ card_name: name, show_card: show_card }) | |
| 567 | + } | |
| 623 | 568 | } |
| 624 | - | |
| 625 | - shipping_price = parseFloat(shipping_price).toFixed(2); | |
| 626 | - var wl_txt = "formData.shipping_price"; | |
| 627 | - th.setData({[wl_txt]: shipping_price,}) | |
| 628 | - | |
| 629 | - } else if (th.data.bn_exp_type == 1) { | |
| 630 | - var wl_txt = "formData.shipping_price"; | |
| 631 | - th.setData({[wl_txt]: 0,}) | |
| 569 | + //-----先获取物流,再获取用户信息,再展示页面----- | |
| 570 | + th.get_wuliu(th.get_info(th.show_page)); | |
| 571 | + }) | |
| 572 | + } else { | |
| 573 | + //-----先获取物流,再获取用户信息,再展示页面----- | |
| 574 | + th.get_wuliu(th.get_info(th.show_page)); | |
| 575 | + } | |
| 576 | + }, 1) | |
| 577 | + | |
| 578 | + }, | |
| 579 | + //---------------检查是否有收货地址------------------- | |
| 580 | + checkAddressList: function () { | |
| 581 | + var t = this; | |
| 582 | + return !(!this.data.order || null == this.data.order.userAddress) || (wx.showModal({ | |
| 583 | + title: "请先填写或选择收货地址~", | |
| 584 | + success: function (a) { | |
| 585 | + a.confirm ? t.enterAddressPage() : wx.navigateBack(); | |
| 586 | + }, | |
| 587 | + fail: function () { | |
| 588 | + wx.navigateBack(); | |
| 589 | + } | |
| 590 | + }), !1); | |
| 591 | + }, | |
| 592 | + showInvoice: function () { | |
| 593 | + this.setData({ | |
| 594 | + invoiceToggle: !this.data.invoiceToggle | |
| 595 | + }); | |
| 596 | + }, | |
| 597 | + keyUpChangePay1: function (t) { | |
| 598 | + this.setData({ | |
| 599 | + payWithUserMoney: !(t.detail.value.length > 0) | |
| 600 | + }); | |
| 601 | + }, | |
| 602 | + keyUpChangePay2: function (t) { | |
| 603 | + this.setData({ | |
| 604 | + payWithPoints: !(t.detail.value.length > 0) | |
| 605 | + }); | |
| 606 | + }, | |
| 607 | + keyUpChangeNum: function (t) { | |
| 608 | + this.setData({ | |
| 609 | + maxWord: t.detail.value.length | |
| 610 | + }); | |
| 611 | + }, | |
| 612 | + //---------计算立即购买---------- | |
| 613 | + calculatePrice2: async function () { | |
| 614 | + | |
| 615 | + this.setData({ submit: 1 }); | |
| 616 | + wx.showLoading({ | |
| 617 | + title: "处理中.", | |
| 618 | + mask: true | |
| 619 | + }) | |
| 620 | + | |
| 621 | + var th = this, good = this.data.bn_goods; | |
| 622 | + //-----------计算商品总价-------------- | |
| 623 | + var allpice = good.shop_price * good.buynum; | |
| 624 | + allpice = parseFloat(allpice).toFixed(2); | |
| 625 | + var txt = "formData.all_price"; | |
| 626 | + th.setData({ [txt]: allpice, }); | |
| 627 | + | |
| 628 | + //to.getwuliuprice(async function (rs) { | |
| 629 | + console.log('calculatePrice2222'); | |
| 630 | + //console.log(rs); | |
| 631 | + | |
| 632 | + var o_shipping_price = 0, goods_weight = -1, goods_piece = -1; | |
| 633 | + var out_of_weight = null; //超出多少重量 | |
| 634 | + | |
| 635 | + //-----------当地址不为空,且是物流时,计算物流费用,同时阶梯团不计算拼团价格---------- | |
| 636 | + if (th.data.user_addr != null && th.data.bn_exp_type == 0 && good.is_free_shipping == 0 && (th.data.kt_type != 3 || th.data.bn_goods.is_normal == 1)) { | |
| 637 | + | |
| 638 | + var user_addr = th.data.user_addr; | |
| 639 | + var req_d = { | |
| 640 | + province: user_addr.province, city: user_addr.city, district: user_addr.district, | |
| 641 | + wuliu: parseFloat(allpice).toFixed(2), store_id: os.stoid | |
| 642 | + } | |
| 643 | + var back_data = null; | |
| 644 | + await getApp().request.promisePost("/api/weshop/order/areaFreight", { | |
| 645 | + is_json: 1, data: req_d | |
| 646 | + }).then(rs => { | |
| 647 | + if (rs.data.code == 0) back_data = rs.data.data; | |
| 648 | + }); | |
| 649 | + | |
| 650 | + var gd_arr_list = []; | |
| 651 | + gd_arr_list.push(good); | |
| 652 | + var cut_good_weight = 0; | |
| 653 | + for (let i in gd_arr_list) { | |
| 654 | + let item = gd_arr_list[i]; | |
| 655 | + | |
| 656 | + if (back_data && back_data['is_by_all'] && (!back_data.no_free_goods || back_data.no_free_goods.indexOf(item.goods_id) == -1)) { | |
| 657 | + | |
| 658 | + if (item['exp_sum_type'] == 2 && back_data.weight_free > 0) { | |
| 659 | + if (goods_weight < 0) goods_weight = 0; | |
| 660 | + cut_good_weight += item['weight'] * item['buynum']; | |
| 661 | + goods_weight += item['weight'] * item['buynum']; | |
| 662 | + } | |
| 663 | + if (back_data.weight_free > 0) { | |
| 664 | + out_of_weight = (back_data.weight_free * 1000) - cut_good_weight; | |
| 665 | + } | |
| 666 | + continue; | |
| 632 | 667 | } |
| 633 | 668 | |
| 634 | - //判断是否同城配送,而且没有调用过 | |
| 635 | - if (th.data.bn_exp_type == 2 && th.data.user_addr) { | |
| 636 | - var lon = 0; | |
| 637 | - var lat = 0; | |
| 638 | - //-- 获取距离 -- | |
| 639 | - await getApp().request.promisePost("/api/weshop/order/sameCityExp/getGeocoder", { | |
| 640 | - is_json: 1, data: {address: th.data.user_addr.more_address + th.data.user_addr.address} | |
| 641 | - }).then(res => { | |
| 642 | - if (res.data.code == 0) { | |
| 643 | - var data = JSON.parse(res.data.data); | |
| 644 | - if (data.status == 0) { | |
| 645 | - lon = data.result.location.lng; | |
| 646 | - lat = data.result.location.lat; | |
| 647 | - } | |
| 648 | - } | |
| 649 | - }) | |
| 650 | - | |
| 651 | - var gd_w = good['weight'] * good['buynum']; | |
| 652 | - //-- 获取距离 -- | |
| 653 | - var req_data = { | |
| 654 | - store_id: os.stoid, | |
| 655 | - order_amount: allpice, | |
| 656 | - lon: lon, lat: lat, | |
| 657 | - pickup_id: th.data.bn_pick, | |
| 658 | - goods_weight: gd_w | |
| 669 | + switch (item['exp_sum_type']) { | |
| 670 | + case 1: | |
| 671 | + //统一运费 | |
| 672 | + o_shipping_price += item['uniform_exp_sum']; | |
| 673 | + break; | |
| 674 | + case 2: | |
| 675 | + if (goods_weight < 0) goods_weight = 0; | |
| 676 | + //累积商品重量 每种商品的重量 * 数量 | |
| 677 | + goods_weight += item['weight'] * item['buynum']; | |
| 678 | + | |
| 679 | + if (back_data && back_data.is_by_all && !back_data.no_free_goods) { | |
| 680 | + cut_good_weight += item['weight'] * item['buynum']; | |
| 681 | + if (back_data.weight_free > 0) { | |
| 682 | + out_of_weight = (back_data.weight_free * 1000) - cut_good_weight; | |
| 683 | + } | |
| 659 | 684 | } |
| 660 | - | |
| 661 | - var is_next = 1; | |
| 662 | - //获取同城配送参数 | |
| 663 | - await getApp().request.promisePost("/api/weshop/order/sameCityExp/getMoney", { | |
| 664 | - is_json: 1, | |
| 665 | - data: req_data | |
| 666 | - }).then(res => { | |
| 667 | - if (res.data.code == 0) { | |
| 668 | - var wl_txt = "formData.shipping_price"; | |
| 669 | - th.setData({[wl_txt]: res.data.data,}) | |
| 670 | - } else { | |
| 671 | - is_next = 0; | |
| 672 | - wx.showToast({ | |
| 673 | - title: res.data.msg, icon: 'none', duration: 2000 | |
| 674 | - }) | |
| 675 | - } | |
| 676 | - }) | |
| 677 | - if (!is_next) return false | |
| 685 | + break; | |
| 686 | + case 3: | |
| 687 | + if (goods_piece < 0) goods_piece = 0; | |
| 688 | + //累积商品数量 | |
| 689 | + goods_piece += item['buynum']; | |
| 690 | + break; | |
| 678 | 691 | } |
| 692 | + } | |
| 693 | + | |
| 694 | + //如果是正值的时候 | |
| 695 | + if (out_of_weight >= 0) out_of_weight = -cut_good_weight; | |
| 696 | + else out_of_weight = -back_data.weight_free * 1000; | |
| 697 | + | |
| 698 | + | |
| 699 | + var code = th.data.wu_arr[th.data.index].code; | |
| 700 | + | |
| 701 | + //--------------开始计算物流------------------ | |
| 702 | + var shipping_price = 0; | |
| 703 | + // var shipping_price = ut.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, | |
| 704 | + // goods_piece, th.data.user_addr, back_data, rs); | |
| 705 | + | |
| 706 | + var w_data = { | |
| 707 | + store_id: os.stoid, code: code, | |
| 708 | + o_shipping_price: o_shipping_price, | |
| 709 | + goods_weight: goods_weight, | |
| 710 | + out_of_weight: out_of_weight, goods_piece: goods_piece, | |
| 711 | + user_addr_province: th.data.user_addr.province, | |
| 712 | + user_addr_city: th.data.user_addr.city, | |
| 713 | + user_addr_district: th.data.user_addr.district, | |
| 714 | + is_by_all: back_data && back_data.is_by_all ? 1 : 0, | |
| 715 | + no_free_goods: back_data && back_data.no_free_goods && back_data.no_free_goods.length > 0 ? 1 : 0, | |
| 716 | + } | |
| 717 | + | |
| 718 | + var is_ok = 0; | |
| 719 | + await getApp().request.promisePost('/api/weshop/order/getOrderWuLiPrice', { | |
| 720 | + data: w_data, | |
| 721 | + is_json: 1 | |
| 722 | + }).then(res => { | |
| 723 | + if (res.data.code == 0) { | |
| 724 | + shipping_price = res.data.data; | |
| 725 | + is_ok = 1; | |
| 726 | + } | |
| 727 | + }) | |
| 728 | + if (!is_ok) { | |
| 729 | + wx.hideLoading(); | |
| 730 | + wx.showToast({ | |
| 731 | + title: "计算物流错误", icon: 'none', duration: 2000 | |
| 732 | + }) | |
| 733 | + //th.setData({ show_submit:0 }); | |
| 734 | + | |
| 735 | + return false; | |
| 736 | + } | |
| 679 | 737 | |
| 738 | + shipping_price = parseFloat(shipping_price).toFixed(2); | |
| 739 | + var wl_txt = "formData.shipping_price"; | |
| 740 | + th.setData({ [wl_txt]: shipping_price, }) | |
| 680 | 741 | |
| 681 | - //-----------------总价----------------- | |
| 682 | - var total_m = parseFloat(allpice) + parseFloat(th.data.formData.shipping_price); | |
| 683 | - total_m = parseFloat(total_m).toFixed(2); | |
| 742 | + } else if (th.data.bn_exp_type == 1) { | |
| 743 | + var wl_txt = "formData.shipping_price"; | |
| 744 | + th.setData({ [wl_txt]: 0, }) | |
| 745 | + } | |
| 684 | 746 | |
| 685 | - var atxt = "formData.total_amount"; | |
| 686 | - th.setData({[atxt]: total_m,}) | |
| 687 | - var order_m = total_m; | |
| 747 | + //判断是否同城配送,而且没有调用过 | |
| 748 | + if (th.data.bn_exp_type == 2 && th.data.user_addr) { | |
| 749 | + var lon = 0; | |
| 750 | + var lat = 0; | |
| 751 | + //-- 获取距离 -- | |
| 752 | + await getApp().request.promisePost("/api/weshop/order/sameCityExp/getGeocoder", { | |
| 753 | + is_json: 1, data: { address: th.data.user_addr.more_address + th.data.user_addr.address } | |
| 754 | + }).then(res => { | |
| 755 | + if (res.data.code == 0) { | |
| 756 | + var data = JSON.parse(res.data.data); | |
| 757 | + if (data.status == 0) { | |
| 758 | + lon = data.result.location.lng; | |
| 759 | + lat = data.result.location.lat; | |
| 760 | + } | |
| 761 | + } | |
| 762 | + }) | |
| 763 | + | |
| 764 | + var gd_w = good['weight'] * good['buynum']; | |
| 765 | + //-- 获取距离 -- | |
| 766 | + var req_data = { | |
| 767 | + store_id: os.stoid, | |
| 768 | + order_amount: allpice, | |
| 769 | + lon: lon, lat: lat, | |
| 770 | + pickup_id: th.data.bn_pick, | |
| 771 | + goods_weight: gd_w | |
| 772 | + } | |
| 773 | + | |
| 774 | + var is_next = 1; | |
| 775 | + //获取同城配送参数 | |
| 776 | + await getApp().request.promisePost("/api/weshop/order/sameCityExp/getMoney", { | |
| 777 | + is_json: 1, | |
| 778 | + data: req_data | |
| 779 | + }).then(res => { | |
| 780 | + if (res.data.code == 0) { | |
| 781 | + var wl_txt = "formData.shipping_price"; | |
| 782 | + th.setData({ [wl_txt]: res.data.data, }) | |
| 783 | + } else { | |
| 784 | + is_next = 0; | |
| 785 | + wx.showToast({ | |
| 786 | + title: res.data.msg, icon: 'none', duration: 2000 | |
| 787 | + }) | |
| 788 | + } | |
| 789 | + }) | |
| 790 | + if (!is_next) return false | |
| 791 | + } | |
| 688 | 792 | |
| 689 | - var txt = "formData.user_money"; | |
| 690 | - var txt2 = "formData.order_amount"; | |
| 691 | - var txt4 = "formData.use_commission"; | |
| 692 | 793 | |
| 693 | - if(parseFloat(order_m)<parseFloat(th.data.bn_goods.use_commission)){ | |
| 694 | - if(th.data.bn_use_commission){ | |
| 695 | - wx.showToast({ | |
| 696 | - title: '应付金额小于本单佣金,不可使用!', | |
| 697 | - icon: 'none', | |
| 698 | - duration: 2000 | |
| 794 | + //-----------------总价----------------- | |
| 795 | + var total_m = parseFloat(allpice) + parseFloat(th.data.formData.shipping_price); | |
| 796 | + total_m = parseFloat(total_m).toFixed(2); | |
| 797 | + | |
| 798 | + var atxt = "formData.total_amount"; | |
| 799 | + th.setData({ [atxt]: total_m, }) | |
| 800 | + var order_m = total_m; | |
| 801 | + | |
| 802 | + | |
| 803 | + //预存金额使用参与计算 | |
| 804 | + if (th.data.udata && th.data.udata.Balance > 0 && order_m * 1 > 0) { | |
| 805 | + if (!th.data.bn_goods.keyid) { | |
| 806 | + //获取门店信息 | |
| 807 | + await getApp().request.promiseGet("/api/weshop/pickup/list", { | |
| 808 | + data: { | |
| 809 | + store_id: os.stoid, | |
| 810 | + ids: th.data.bn_pick | |
| 811 | + } | |
| 812 | + }).then(res => { | |
| 813 | + if (ut.ajax_ok(res)) { | |
| 814 | + console.log(res); | |
| 815 | + if (res.data.code == 0) { | |
| 816 | + let resData = res.data.data.pageData | |
| 817 | + if (resData && resData[0]) { | |
| 818 | + let keyid = resData[0].keyid | |
| 819 | + let txt = 'bn_goods.keyid' | |
| 820 | + th.setData({ | |
| 821 | + [txt]: keyid | |
| 699 | 822 | }) |
| 823 | + } | |
| 700 | 824 | } |
| 825 | + } | |
| 826 | + }) | |
| 827 | + } | |
| 828 | + if (th.data.bn_goods.keyid) { | |
| 829 | + let cart_yc = await th.beforAdvancesum({ | |
| 830 | + order_amount: order_m, | |
| 831 | + goods: [{ | |
| 832 | + goods_sn: th.data.bn_goods.goods_sn, | |
| 833 | + goods_price: th.data.bn_goods.shop_price || th.data.bn_goods.goods_price, | |
| 834 | + goods_num: th.data.bn_goods.buynum || th.data.bn_goods.goods_num, | |
| 835 | + }], | |
| 836 | + sto: { | |
| 837 | + keyid: th.data.bn_goods.keyid | |
| 838 | + } | |
| 839 | + }) | |
| 701 | 840 | |
| 702 | - th.setData({ | |
| 703 | - bn_use_commission:0 | |
| 704 | - }); | |
| 841 | + if (!good.yck_off) { | |
| 842 | + good.yck_off = cart_yc.yck_off | |
| 705 | 843 | } |
| 844 | + good.yck = cart_yc.yck | |
| 845 | + good.yckid = cart_yc.yckid | |
| 846 | + good.pre_json = cart_yc.pre_json | |
| 847 | + let yct1 = 'bn_goods.yck_off'; | |
| 848 | + let yct2 = 'bn_goods.yck'; | |
| 849 | + let yct3 = 'bn_goods.yckid'; | |
| 850 | + let yct4 = 'bn_goods.pre_json'; | |
| 851 | + th.setData({ | |
| 852 | + [yct1]: good.yck_off, | |
| 853 | + [yct2]: good.yck, | |
| 854 | + [yct3]: good.yckid, | |
| 855 | + [yct4]: good.pre_json, | |
| 856 | + }) | |
| 706 | 857 | |
| 707 | - | |
| 708 | - if(th.data.bn_use_commission){ | |
| 709 | - order_m= (parseFloat(order_m)- parseFloat(th.data.bn_goods.use_commission)).toFixed(2); | |
| 710 | - th.setData({[txt4]:th.data.bn_goods.use_commission}) | |
| 858 | + if (good.yck_off && good.yck_off == 2) { | |
| 859 | + let order_amount = (order_m - good.yck).toFixed(2); | |
| 860 | + let yck = 0 | |
| 861 | + if (order_amount * 1 > 0) { | |
| 862 | + order_m = order_amount; | |
| 863 | + // all_prestore+=parseFloat(good.yck); | |
| 864 | + yck = parseFloat(good.yck) | |
| 865 | + } else { | |
| 866 | + // all_prestore+=order_m*1 | |
| 867 | + yck = parseFloat(order_m) | |
| 868 | + order_m = 0 | |
| 869 | + } | |
| 870 | + let atxt10 = "formData.prestore"; //预存金额 | |
| 871 | + let atxt11 = "formData.pre_json"; //预存json | |
| 872 | + let atxt12 = "formData.all_yck_arr"; //预存真实抵扣列表 | |
| 873 | + th.setData({ | |
| 874 | + [atxt10]: yck, | |
| 875 | + [atxt11]: [good.pre_json], | |
| 876 | + [atxt12]: [yck], | |
| 877 | + }) | |
| 878 | + // formData.prestore | |
| 879 | + // all_yck_arr.push(yck) //真实预存款抵扣金额 | |
| 880 | + // all_pre_json.push(good.pre_json) | |
| 881 | + // all_prestore = parseFloat(all_prestore); //真实预存款抵扣金额总和 | |
| 711 | 882 | } |
| 883 | + } | |
| 884 | + } else { | |
| 885 | + let yct1 = 'bn_goods.yck_off'; | |
| 886 | + let yct2 = 'bn_goods.yck'; | |
| 887 | + let yct3 = 'bn_goods.yckid'; | |
| 888 | + let yct4 = 'bn_goods.pre_json'; | |
| 889 | + let atxt10 = "formData.prestore"; //预存金额 | |
| 890 | + let atxt11 = "formData.pre_json"; //预存json | |
| 891 | + let atxt12 = "formData.all_yck_arr"; //预存真实抵扣列表 | |
| 892 | + th.setData({ | |
| 893 | + [yct2]: 0, | |
| 894 | + [yct3]: '', | |
| 895 | + [yct4]: '', | |
| 896 | + [atxt10]: 0, | |
| 897 | + [atxt11]: '', | |
| 898 | + [atxt12]: [], | |
| 899 | + }) | |
| 900 | + } | |
| 712 | 901 | |
| 713 | - //--------------如果使用余额--------------------- | |
| 714 | - if (th.data.bn_use_money == 1 && th.data.yuer > 0) { | |
| 715 | - if (parseFloat(th.data.yuer) > parseFloat(order_m)) { | |
| 716 | - th.setData({[txt]: order_m, [txt2]: 0, submit: 0, show_btn: 1}) | |
| 717 | - } else { | |
| 718 | - order_m = parseFloat(order_m) - parseFloat(th.data.yuer); | |
| 719 | - order_m = order_m.toFixed(2); | |
| 720 | - th.setData({[txt]: th.data.yuer, [txt2]: order_m, submit: 0, show_btn: 1}) | |
| 721 | - } | |
| 722 | - } else { | |
| 723 | - th.setData({[txt]: 0, [txt2]: order_m, submit: 0, show_btn: 1}) | |
| 724 | - } | |
| 725 | 902 | |
| 726 | - wx.hideLoading(); | |
| 727 | 903 | |
| 728 | - //}); | |
| 729 | 904 | |
| 730 | - }, | |
| 731 | - //--------------------提交订单----------------------- | |
| 732 | - submitForm: async function (t) { | |
| 733 | - if (this.data.is_summit_ing == 1) return false; //--提交中退出-- | |
| 734 | - this.data.is_summit_ing = 1; | |
| 735 | - | |
| 736 | - var th = this, pdata = new Array(); | |
| 737 | - var ff = true; | |
| 738 | - //------------立即购买------------- | |
| 739 | - console.log("buy_new"); | |
| 740 | - | |
| 741 | - //如果不是阶梯团,或者是普通购买,商家选择了物流,以及地址为空的时候 | |
| 742 | - if (th.data.bn_exp_type == 0 && th.data.user_addr == null && (th.data.kt_type != 3 || th.data.bn_goods.is_normal == 1)) { | |
| 743 | - ff = false; | |
| 744 | - getApp().my_warnning("请选择收货地址", 0, this); | |
| 745 | - this.data.is_summit_ing = 0; | |
| 746 | - } | |
| 747 | - if (!ff) return false; | |
| 748 | - var addr = th.data.user_addr; | |
| 749 | - if (th.data.bn_exp_type == 1) addr = null; | |
| 750 | - | |
| 751 | - console.log(th.data.formData); | |
| 752 | - console.log(th.data.wu_arr); | |
| 753 | - console.log(th.data.bn_exp_type); | |
| 754 | - | |
| 755 | - if (th.data.bn_exp_type == 0 && (th.data.kt_type != 3 || th.data.bn_goods.is_normal == 1)) { | |
| 756 | - if (th.data.wu_arr == null || th.data.wu_arr.length <= 0) { | |
| 757 | - getApp().my_warnning("读取物流失败", 0, this); | |
| 758 | - this.data.is_summit_ing = 0; | |
| 759 | - return false; | |
| 760 | - } | |
| 761 | - } | |
| 905 | + var txt = "formData.user_money"; | |
| 906 | + var txt2 = "formData.order_amount"; | |
| 907 | + var txt4 = "formData.use_commission"; | |
| 762 | 908 | |
| 763 | - //阶梯团强制带1,自提~~~ | |
| 764 | - if (th.data.kt_type == 3) { | |
| 765 | - th.data.bn_exp_type = 1; | |
| 766 | - } | |
| 909 | + if (parseFloat(order_m) < parseFloat(th.data.bn_goods.use_commission)) { | |
| 910 | + if (th.data.bn_use_commission) { | |
| 911 | + wx.showToast({ | |
| 912 | + title: '应付金额小于本单佣金,不可使用!', | |
| 913 | + icon: 'none', | |
| 914 | + duration: 2000 | |
| 915 | + }) | |
| 916 | + } | |
| 767 | 917 | |
| 768 | - var item = { | |
| 769 | - 'user_id': to.globalData.user_id, | |
| 770 | - 'consignee': addr == null ? "" : addr.consignee, | |
| 771 | - 'province': addr == null ? 0 : addr.province, | |
| 772 | - 'city': addr == null ? 0 : addr.city, | |
| 773 | - 'district': addr == null ? 0 : addr.district, | |
| 774 | - 'twon': addr == null ? 0 : addr.twon, | |
| 775 | - 'address': addr == null ? "" : addr.address, | |
| 776 | - 'more_address': addr == null ? "" : addr.more_address, | |
| 777 | - 'mobile': addr == null ? th.data.userinfo.mobile : addr.mobile, | |
| 778 | - 'email': '', | |
| 779 | - 'invoice_title': '', | |
| 780 | - 'goods_price': th.data.formData.all_price, //商品总价 | |
| 781 | - 'shipping_price': th.data.formData.shipping_price, //物流金额 | |
| 782 | - 'user_money': th.data.formData.user_money, //使用余额 | |
| 783 | - 'total_amount': th.data.formData.total_amount, //订单总价 | |
| 784 | - 'order_amount': th.data.formData.order_amount, //应付 | |
| 785 | - 'user_note': t.detail.value.user_note, //用户备注 | |
| 786 | - 'store_id': oo.stoid, //商家 | |
| 787 | - 'pickup_id': th.data.bn_pick, //门店 | |
| 788 | - 'exp_type': th.data.bn_exp_type, //配送方式 | |
| 789 | - 'is_normal': th.data.bn_goods.is_normal, //是否是普通购买 | |
| 790 | - 'pt_prom_id': th.data.bn_goods.prom_id, //拼单ID | |
| 791 | - 'is_pt_tz': th.data.is_pt_tz, //开团类型 | |
| 792 | - 'order_goods': new Array(), | |
| 793 | - }; | |
| 794 | - | |
| 795 | - //如果不是阶梯团,或者是普通购买, | |
| 796 | - if ((th.data.kt_type != 3 || th.data.bn_goods.is_normal == 1)) { | |
| 797 | - item['shipping_code'] = th.data.bn_exp_type == 1 ? 0 : th.data.wu_arr[th.data.index].code; | |
| 798 | - item['shipping_name'] = th.data.bn_exp_type == 1 ? '' : th.data.wu_arr[th.data.index].name; | |
| 799 | - } | |
| 918 | + th.setData({ | |
| 919 | + bn_use_commission: 0 | |
| 920 | + }); | |
| 921 | + } | |
| 800 | 922 | |
| 801 | - if (!th.data.bn_goods.is_normal) { | |
| 802 | - item.is_zsorder = th.data.kt_type + 1; //开团类型 | |
| 803 | - } | |
| 804 | - //老会员成为分销下线需要的参数 | |
| 805 | - if (getApp().globalData.first_leader && !getApp().globalData.userInfo.first_leader) { | |
| 806 | - //判断一下分享人是不是分享商 | |
| 807 | - await app.request.promiseGet("/api/weshop/users/get/" + os.stoid + "/" + getApp().globalData.first_leader, {}).then(res => { | |
| 808 | - if (res.data.code == 0) { | |
| 809 | - var user = res.data.data; | |
| 810 | - if (user.is_distribut == 1) { | |
| 811 | - item.first_leader = parseInt(getApp().globalData.first_leader); | |
| 812 | - } | |
| 813 | - } | |
| 814 | - }) | |
| 815 | - } | |
| 816 | 923 | |
| 817 | - if (th.data.qh != '') { | |
| 818 | - item.team_qh = th.data.qh; | |
| 819 | - item.pt_listno = th.data.qh; | |
| 820 | - } | |
| 924 | + if (th.data.bn_use_commission) { | |
| 925 | + order_m = (parseFloat(order_m) - parseFloat(th.data.bn_goods.use_commission)).toFixed(2); | |
| 926 | + th.setData({ [txt4]: th.data.bn_goods.use_commission }) | |
| 927 | + } | |
| 821 | 928 | |
| 822 | - //-- 如果有使用佣金抵扣的话 -- | |
| 823 | - if(th.data.bn_use_commission){ | |
| 824 | - item.use_commission=th.data.bn_goods.use_commission; | |
| 825 | - } | |
| 929 | + //--------------如果使用余额--------------------- | |
| 930 | + if (th.data.bn_use_money == 1 && th.data.yuer > 0) { | |
| 931 | + if (parseFloat(th.data.yuer) > parseFloat(order_m)) { | |
| 932 | + th.setData({ [txt]: order_m, [txt2]: 0, submit: 0, show_btn: 1 }) | |
| 933 | + } else { | |
| 934 | + order_m = parseFloat(order_m) - parseFloat(th.data.yuer); | |
| 935 | + order_m = order_m.toFixed(2); | |
| 936 | + th.setData({ [txt]: th.data.yuer, [txt2]: order_m, submit: 0, show_btn: 1 }) | |
| 937 | + } | |
| 938 | + } else { | |
| 939 | + th.setData({ [txt]: 0, [txt2]: order_m, submit: 0, show_btn: 1 }) | |
| 940 | + } | |
| 826 | 941 | |
| 942 | + wx.hideLoading(); | |
| 827 | 943 | |
| 944 | + //}); | |
| 828 | 945 | |
| 829 | - var gg = to.get_b_now(); | |
| 830 | - var goods = { | |
| 831 | - 'goods_id': gg.goods_id, | |
| 832 | - 'goods_name': gg.goods_name, | |
| 833 | - 'goods_sn': gg.goods_sn, | |
| 834 | - 'goods_num': gg.goods_num, | |
| 835 | - 'market_price': th.data.bn_goods.market_price, | |
| 836 | - 'goods_price': th.data.bn_goods.shop_price, | |
| 837 | - 'member_goods_price': th.data.bn_goods.shop_price, | |
| 838 | - 'store_id': oo.stoid, | |
| 839 | - 'prom_type': th.data.bn_goods.prom_type, //促销活动类型 | |
| 840 | - 'prom_id': th.data.bn_goods.prom_id, //促销活动id | |
| 841 | - }; | |
| 946 | + }, | |
| 947 | + //--------------------提交订单----------------------- | |
| 948 | + submitForm: async function (t) { | |
| 949 | + if (this.data.is_summit_ing == 1) return false; //--提交中退出-- | |
| 950 | + this.data.is_summit_ing = 1; | |
| 842 | 951 | |
| 843 | - if (getApp().globalData.skinface_id) { | |
| 844 | - goods.skinface_id = getApp().globalData.skinface_id; | |
| 845 | - } | |
| 952 | + var th = this, pdata = new Array(); | |
| 953 | + var ff = true; | |
| 954 | + //------------立即购买------------- | |
| 955 | + console.log("buy_new"); | |
| 846 | 956 | |
| 847 | - if (th.data.bn_goods.whsle_id) { | |
| 848 | - item.is_whsle = 1; | |
| 849 | - goods.is_whsle_goods = 1; | |
| 850 | - } | |
| 957 | + //如果不是阶梯团,或者是普通购买,商家选择了物流,以及地址为空的时候 | |
| 958 | + if (th.data.bn_exp_type == 0 && th.data.user_addr == null && (th.data.kt_type != 3 || th.data.bn_goods.is_normal == 1)) { | |
| 959 | + ff = false; | |
| 960 | + getApp().my_warnning("请选择收货地址", 0, this); | |
| 961 | + this.data.is_summit_ing = 0; | |
| 962 | + } | |
| 963 | + if (!ff) return false; | |
| 964 | + var addr = th.data.user_addr; | |
| 965 | + if (th.data.bn_exp_type == 1) addr = null; | |
| 966 | + | |
| 967 | + console.log(th.data.formData); | |
| 968 | + console.log(th.data.wu_arr); | |
| 969 | + console.log(th.data.bn_exp_type); | |
| 970 | + | |
| 971 | + if (th.data.bn_exp_type == 0 && (th.data.kt_type != 3 || th.data.bn_goods.is_normal == 1)) { | |
| 972 | + if (th.data.wu_arr == null || th.data.wu_arr.length <= 0) { | |
| 973 | + getApp().my_warnning("读取物流失败", 0, this); | |
| 974 | + this.data.is_summit_ing = 0; | |
| 975 | + return false; | |
| 976 | + } | |
| 977 | + } | |
| 851 | 978 | |
| 852 | - //--导购分享过来的id-- | |
| 853 | - if (gg.guide_id) { | |
| 854 | - goods.guide_id = gg.guide_id; | |
| 855 | - goods.guide_type = gg.guide_type; | |
| 856 | - //调用接口判断是不是会员 | |
| 857 | - await getApp().request.promiseGet("/api/weshop/shoppingGuide/getId/" + oo.stoid + "/" + gg.guide_id, {}).then(res => { | |
| 858 | - if (res.data.code == 0) { | |
| 859 | - goods.guide_name = res.data.data.salesman; | |
| 860 | - goods.guide_sn = res.data.data.salesman_no; | |
| 861 | - } | |
| 862 | - }) | |
| 863 | - } | |
| 979 | + //阶梯团强制带1,自提~~~ | |
| 980 | + if (th.data.kt_type == 3) { | |
| 981 | + th.data.bn_exp_type = 1; | |
| 982 | + } | |
| 864 | 983 | |
| 984 | + var item = { | |
| 985 | + 'user_id': to.globalData.user_id, | |
| 986 | + 'consignee': addr == null ? "" : addr.consignee, | |
| 987 | + 'province': addr == null ? 0 : addr.province, | |
| 988 | + 'city': addr == null ? 0 : addr.city, | |
| 989 | + 'district': addr == null ? 0 : addr.district, | |
| 990 | + 'twon': addr == null ? 0 : addr.twon, | |
| 991 | + 'address': addr == null ? "" : addr.address, | |
| 992 | + 'more_address': addr == null ? "" : addr.more_address, | |
| 993 | + 'mobile': addr == null ? th.data.userinfo.mobile : addr.mobile, | |
| 994 | + 'email': '', | |
| 995 | + 'invoice_title': '', | |
| 996 | + 'goods_price': th.data.formData.all_price, //商品总价 | |
| 997 | + 'shipping_price': th.data.formData.shipping_price, //物流金额 | |
| 998 | + 'user_money': th.data.formData.user_money, //使用余额 | |
| 999 | + 'total_amount': th.data.formData.total_amount, //订单总价 | |
| 1000 | + 'order_amount': th.data.formData.order_amount, //应付 | |
| 1001 | + 'user_note': t.detail.value.user_note, //用户备注 | |
| 1002 | + 'store_id': oo.stoid, //商家 | |
| 1003 | + 'pickup_id': th.data.bn_pick, //门店 | |
| 1004 | + 'exp_type': th.data.bn_exp_type, //配送方式 | |
| 1005 | + 'is_normal': th.data.bn_goods.is_normal, //是否是普通购买 | |
| 1006 | + 'pt_prom_id': th.data.bn_goods.prom_id, //拼单ID | |
| 1007 | + 'is_pt_tz': th.data.is_pt_tz, //开团类型 | |
| 1008 | + 'order_goods': new Array(), | |
| 1009 | + }; | |
| 1010 | + | |
| 1011 | + //如果不是阶梯团,或者是普通购买, | |
| 1012 | + if ((th.data.kt_type != 3 || th.data.bn_goods.is_normal == 1)) { | |
| 1013 | + item['shipping_code'] = th.data.bn_exp_type == 1 ? 0 : th.data.wu_arr[th.data.index].code; | |
| 1014 | + item['shipping_name'] = th.data.bn_exp_type == 1 ? '' : th.data.wu_arr[th.data.index].name; | |
| 1015 | + } | |
| 865 | 1016 | |
| 866 | - //--商品的房间号-- | |
| 867 | - if (gg.room_id && gg.room_id > 0) { | |
| 868 | - item.room_ids = gg.room_id; | |
| 869 | - goods.room_id = gg.room_id; | |
| 1017 | + if (!th.data.bn_goods.is_normal) { | |
| 1018 | + item.is_zsorder = th.data.kt_type + 1; //开团类型 | |
| 1019 | + } | |
| 1020 | + //老会员成为分销下线需要的参数 | |
| 1021 | + if (getApp().globalData.first_leader && !getApp().globalData.userInfo.first_leader) { | |
| 1022 | + //判断一下分享人是不是分享商 | |
| 1023 | + await app.request.promiseGet("/api/weshop/users/get/" + os.stoid + "/" + getApp().globalData.first_leader, {}).then(res => { | |
| 1024 | + if (res.data.code == 0) { | |
| 1025 | + var user = res.data.data; | |
| 1026 | + if (user.is_distribut == 1) { | |
| 1027 | + item.first_leader = parseInt(getApp().globalData.first_leader); | |
| 1028 | + } | |
| 870 | 1029 | } |
| 1030 | + }) | |
| 1031 | + } | |
| 871 | 1032 | |
| 872 | - if (th.data.bn_goods.is_normal) { | |
| 873 | - goods.is_pd_normal = 1; | |
| 874 | - } | |
| 1033 | + if (th.data.qh != '') { | |
| 1034 | + item.team_qh = th.data.qh; | |
| 1035 | + item.pt_listno = th.data.qh; | |
| 1036 | + } | |
| 875 | 1037 | |
| 876 | - item.order_goods.push(goods); | |
| 877 | - pdata.push(item); | |
| 878 | - | |
| 879 | - if (pdata.length == 0) return; | |
| 880 | - var str = JSON.stringify(pdata); | |
| 881 | - console.log("支付数据"); | |
| 882 | - console.log(str); | |
| 883 | - //return false; | |
| 884 | - wx.showLoading({title: "加载中"}); | |
| 885 | - wx.request({ | |
| 886 | - url: oo.url + '/api/weshop/order/createWxdOrder', | |
| 887 | - data: str, | |
| 888 | - method: 'POST', | |
| 889 | - header: { | |
| 890 | - 'content-type': 'application/json' | |
| 891 | - },// 设置请求的 header | |
| 892 | - success: function (res) { | |
| 893 | - | |
| 894 | - wx.hideLoading(); | |
| 895 | - if (res.statusCode == 200) { | |
| 896 | - var data = res.data; | |
| 897 | - if (data.code == 0) { | |
| 898 | - console.log(th.data.is_b_now); | |
| 899 | - //如果是购物车结算,还要删除购物车 | |
| 900 | - if (th.data.is_b_now == 0) { | |
| 901 | - console.log(th.data.cartlist_y); | |
| 902 | - var list = th.data.cartlist_y; | |
| 903 | - for (var i = 0; i < list.length; i++) { | |
| 904 | - //删除购物车 | |
| 905 | - getApp().request.delete("/api/weshop/cart/del/" + oo.stoid + "/" + list[i].id, {}); | |
| 906 | - } | |
| 907 | - } | |
| 908 | - var order_amount = 0; | |
| 909 | - pdata.forEach(function (em, ind) { | |
| 910 | - order_amount += em.order_amount; | |
| 911 | - }) | |
| 912 | - //要进行判断,如果是用微信支付,就要跳转到支付界面 | |
| 913 | - if (order_amount > 0) { | |
| 914 | - th.setData({isclose: 0}); | |
| 915 | - //void e.jumpToCart4({ | |
| 916 | - // order_sn: data.data, | |
| 917 | - // type:1, | |
| 918 | - // }, 1); | |
| 919 | - util_pay.pay(data.data, function () { | |
| 920 | - setTimeout(function () { | |
| 921 | - wx.reLaunch({ | |
| 922 | - //url: "/pages/payment/pay_success/pay_success?type=1&order_sn="+data.data, | |
| 923 | - url: "/pages/team/team_success/team_success?ordersn=" + data.data, | |
| 924 | - }) | |
| 925 | - }, 1000) | |
| 926 | - }, function () { | |
| 927 | - //支付失败 | |
| 928 | - setTimeout(function () { | |
| 929 | - //wx.navigateBack({ delta: 1 }) | |
| 930 | - wx.reLaunch({ | |
| 931 | - url: "/pages/user/order_list/order_list", | |
| 932 | - }) | |
| 933 | - }, 1000) | |
| 934 | - | |
| 935 | - }, oo.stoid, 1); | |
| 936 | - | |
| 937 | - } else { | |
| 938 | - var dd = { | |
| 939 | - parent_sn: data.data, | |
| 940 | - store_id: oo.stoid, | |
| 941 | - type: 1, | |
| 942 | - }; | |
| 943 | - //return false; | |
| 944 | - getApp().request.post("/api/weshop/order/pay/createOrder", { | |
| 945 | - data: dd, | |
| 946 | - success: function (t) { | |
| 947 | - console.log(t); | |
| 948 | - // app.my_warnning("支付成功", 1, th); | |
| 949 | - wx.showToast({ | |
| 950 | - title: '支付成功', | |
| 951 | - icon: 'success', | |
| 952 | - duration: 2000 | |
| 953 | - }); | |
| 954 | - setTimeout(function () { | |
| 955 | - th.setData({isclose: 0}); | |
| 956 | - | |
| 957 | - if (th.data.is_normal == 1) { | |
| 958 | - /*-- | |
| 959 | - wx.navigateTo({ | |
| 960 | - url: "/pages/user/order_list/order_list", | |
| 961 | - })--*/ | |
| 962 | - var url = "/pages/payment/pay_success/pay_success?type=1&order_sn=" + data.data; | |
| 963 | - wx.reLaunch({ | |
| 964 | - url: url | |
| 965 | - }) | |
| 966 | - | |
| 967 | - } else { | |
| 968 | - wx.reLaunch({ | |
| 969 | - url: "/pages/team/team_success/team_success?ordersn=" + data.data, | |
| 970 | - }) | |
| 971 | - } | |
| 972 | - | |
| 973 | - | |
| 974 | - }, 1000) | |
| 975 | - } | |
| 976 | - }); | |
| 977 | - } | |
| 978 | - } else { | |
| 979 | - th.data.is_summit_ing = 0; //是否提交中 | |
| 980 | - getApp().confirmBox(data.msg); | |
| 981 | - } | |
| 982 | - } else { | |
| 983 | - th.data.is_summit_ing = 0; //是否提交中 | |
| 984 | - console.log("index.js wx.request CheckCallUser statusCode" + res.statusCode); | |
| 985 | - } | |
| 986 | - }, | |
| 987 | - fail: function () { | |
| 988 | - th.data.is_summit_ing = 0; //是否提交中 | |
| 989 | - wx.hideLoading(); | |
| 990 | - console.log("index.js wx.request CheckCallUser fail"); | |
| 991 | - }, | |
| 992 | - complete: function () { | |
| 993 | - } | |
| 994 | - }) | |
| 995 | - }, | |
| 996 | - useCoupon: function () { | |
| 997 | - if (this.data.order.couponNum <= 0) { | |
| 998 | - //return t.showWarning("无可用优惠券"); | |
| 999 | - getApp().my_warnning("无可用优惠券", 0, this); | |
| 1000 | - return; | |
| 1001 | - } | |
| 1002 | - var a = { | |
| 1003 | - lid: this.data.coupon ? this.data.coupon.id : "0" | |
| 1004 | - }; | |
| 1005 | - wx.navigateTo({ | |
| 1006 | - url: "/pages/user/checkcoupon/checkcoupon?" + s.Obj2Str(a) | |
| 1007 | - }); | |
| 1008 | - }, | |
| 1009 | - //检查区域是不是包邮 | |
| 1010 | - check_area: function (arr) { | |
| 1011 | - var user_addr = this.data.user_addr; | |
| 1012 | - if (!user_addr) return 0; | |
| 1013 | - for (var i in arr) { | |
| 1014 | - var item = arr[i]; | |
| 1015 | - if (user_addr.twon == item || user_addr.district == item | |
| 1016 | - || user_addr.city == item || user_addr.province == item) { | |
| 1017 | - return 0; | |
| 1018 | - } | |
| 1019 | - } | |
| 1020 | - return 1; | |
| 1021 | - }, | |
| 1038 | + //-- 如果有使用佣金抵扣的话 -- | |
| 1039 | + if (th.data.bn_use_commission) { | |
| 1040 | + item.use_commission = th.data.bn_goods.use_commission; | |
| 1041 | + } | |
| 1022 | 1042 | |
| 1023 | - //检查立即购买的商品是不是不包邮 | |
| 1024 | - check_good: function (arr, goods_id) { | |
| 1025 | - if (!goods_id) goods_id = this.data.goods.goods_id; | |
| 1026 | - for (var i in arr) { | |
| 1027 | - var item = arr[i]; | |
| 1028 | - if (goods_id == item) return 0; | |
| 1029 | - } | |
| 1030 | - return 1; | |
| 1031 | - }, | |
| 1032 | - check_by_area: function (region_list) { | |
| 1033 | - var arr = region_list.split(","); | |
| 1034 | - var check = this.check_area(arr); | |
| 1035 | - return !check; | |
| 1036 | - }, | |
| 1037 | - check_by_goods: function (goods_list, goods_id) { | |
| 1038 | - var arr = goods_list.split(","); | |
| 1039 | - var check = this.check_good(arr, goods_id); | |
| 1040 | - return !check; | |
| 1041 | - }, | |
| 1042 | - enterAddressPage: function () { | |
| 1043 | - getApp().globalData.is_cart_old = 1; | |
| 1044 | - this.data.enterAddressPage = !0, wx.navigateTo({ | |
| 1045 | - url: "/pages/user/address_list/address_list" | |
| 1046 | - }); | |
| 1047 | - }, | |
| 1048 | 1043 | |
| 1049 | - //--------立即购买时,选择自提和物流----------- | |
| 1050 | - setexptype_w: function (t) { | |
| 1051 | - var th = this; | |
| 1052 | - var ty = t.currentTarget.dataset.t, txt = t.currentTarget.dataset.txt; | |
| 1053 | - th.setData({[txt]: ty}); | |
| 1054 | - var iszt = 1; | |
| 1055 | - if (ty == 0) { | |
| 1056 | - th.setData({is_all_zt: 0}); | |
| 1057 | - } else { | |
| 1058 | - for (var i = 0; i < th.data.cartlist.length; i++) { | |
| 1059 | - var item = th.data.cartlist[i]; | |
| 1060 | - if (item.exp_type == 0) { | |
| 1061 | - iszt = 0; | |
| 1062 | - break; | |
| 1063 | - } | |
| 1064 | - } | |
| 1065 | - th.setData({is_all_zt: iszt}); | |
| 1066 | - } | |
| 1067 | - //----计算此时购物车的价格---- | |
| 1068 | - th.calculatePrice(); | |
| 1069 | - }, | |
| 1070 | 1044 | |
| 1071 | - //--------立即购买时,选择自提和物流---------- | |
| 1072 | - setexptype: function (t) { | |
| 1073 | - var th = this; | |
| 1074 | - var ty = t.currentTarget.dataset.t; | |
| 1075 | - th.setData({bn_exp_type: ty}); | |
| 1076 | - //当物流为空的时候。 | |
| 1077 | - if (ty == 0 && th.data.wu_arr == null) { | |
| 1078 | - return th.get_wuliu(th.calculatePrice2()); | |
| 1045 | + var gg = to.get_b_now(); | |
| 1046 | + var goods = { | |
| 1047 | + 'goods_id': gg.goods_id, | |
| 1048 | + 'goods_name': gg.goods_name, | |
| 1049 | + 'goods_sn': gg.goods_sn, | |
| 1050 | + 'goods_num': gg.goods_num, | |
| 1051 | + 'market_price': th.data.bn_goods.market_price, | |
| 1052 | + 'goods_price': th.data.bn_goods.shop_price, | |
| 1053 | + 'member_goods_price': th.data.bn_goods.shop_price, | |
| 1054 | + 'store_id': oo.stoid, | |
| 1055 | + 'prom_type': th.data.bn_goods.prom_type, //促销活动类型 | |
| 1056 | + 'prom_id': th.data.bn_goods.prom_id, //促销活动id | |
| 1057 | + }; | |
| 1058 | + | |
| 1059 | + if (getApp().globalData.skinface_id) { | |
| 1060 | + goods.skinface_id = getApp().globalData.skinface_id; | |
| 1061 | + } | |
| 1062 | + | |
| 1063 | + if (th.data.bn_goods.whsle_id) { | |
| 1064 | + item.is_whsle = 1; | |
| 1065 | + goods.is_whsle_goods = 1; | |
| 1066 | + } | |
| 1067 | + | |
| 1068 | + //--导购分享过来的id-- | |
| 1069 | + if (gg.guide_id) { | |
| 1070 | + goods.guide_id = gg.guide_id; | |
| 1071 | + goods.guide_type = gg.guide_type; | |
| 1072 | + //调用接口判断是不是会员 | |
| 1073 | + await getApp().request.promiseGet("/api/weshop/shoppingGuide/getId/" + oo.stoid + "/" + gg.guide_id, {}).then(res => { | |
| 1074 | + if (res.data.code == 0) { | |
| 1075 | + goods.guide_name = res.data.data.salesman; | |
| 1076 | + goods.guide_sn = res.data.data.salesman_no; | |
| 1079 | 1077 | } |
| 1080 | - th.calculatePrice2() | |
| 1081 | - console.log('setexptype'); | |
| 1082 | - }, | |
| 1078 | + }) | |
| 1079 | + } | |
| 1083 | 1080 | |
| 1084 | - //--------立即购买时,使用余额-------- | |
| 1085 | - set_bn_useyuer: function () { | |
| 1086 | - var th = this; | |
| 1087 | - th.setData({bn_use_money: !th.data.bn_use_money}); | |
| 1088 | - th.calculatePrice2(); | |
| 1089 | - }, | |
| 1090 | 1081 | |
| 1091 | - set_bn_commission: function () { | |
| 1092 | - var th = this; | |
| 1093 | - th.setData({bn_use_commission: !th.data.bn_use_commission}); | |
| 1094 | - th.calculatePrice2(); | |
| 1095 | - }, | |
| 1082 | + //--商品的房间号-- | |
| 1083 | + if (gg.room_id && gg.room_id > 0) { | |
| 1084 | + item.room_ids = gg.room_id; | |
| 1085 | + goods.room_id = gg.room_id; | |
| 1086 | + } | |
| 1096 | 1087 | |
| 1088 | + if (th.data.bn_goods.is_normal) { | |
| 1089 | + goods.is_pd_normal = 1; | |
| 1090 | + } | |
| 1097 | 1091 | |
| 1098 | - set_js_useyuer: function () { | |
| 1099 | - var th = this; | |
| 1100 | - th.setData({js_use_money: !th.data.js_use_money}); | |
| 1101 | - th.calculatePrice(); | |
| 1102 | - }, | |
| 1092 | + item.order_goods.push(goods); | |
| 1093 | + pdata.push(item); | |
| 1094 | + | |
| 1095 | + if (pdata.length == 0) return; | |
| 1096 | + //如果有使用预存,要处理 | |
| 1097 | + if (th.data.formData && th.data.formData.prestore * 1 > 0 && th.data.bn_goods.yck_off==2) { | |
| 1098 | + let formData = th.data.formData | |
| 1099 | + let pre_json = formData.pre_json | |
| 1100 | + let all_yck_arr = formData.all_yck_arr | |
| 1101 | + pdata.map((item, i) => { | |
| 1102 | + item.pre_cut = all_yck_arr[i] ? all_yck_arr[i] : 0 | |
| 1103 | + item.pre_preferential = 0 | |
| 1104 | + item.pre_json = pre_json[i] ? JSON.stringify(pre_json[i]) : '' | |
| 1105 | + }) | |
| 1106 | + } | |
| 1103 | 1107 | |
| 1104 | - //----------立即购买,选择物流------------- | |
| 1105 | - bindPickerChange: function (e) { | |
| 1106 | - var ind = e.detail.value | |
| 1107 | - this.setData({index: ind}); | |
| 1108 | - this.calculatePrice2(); | |
| 1109 | - }, | |
| 1110 | 1108 | |
| 1111 | - //----------购物车结算,选择物流------------- | |
| 1112 | - bindPickerChange_w: function (e) { | |
| 1113 | - var ind = e.detail.value, txt = e.currentTarget.dataset.txt; | |
| 1114 | - this.setData({[txt]: ind}); | |
| 1115 | - this.calculatePrice(); | |
| 1116 | - }, | |
| 1109 | + if (!pdata.keyid && th.data.bn_goods) { | |
| 1110 | + pdata.map(ite => { | |
| 1111 | + ite.keyid = th.data.bn_goods.keyid | |
| 1112 | + }) | |
| 1113 | + // pdata.keyid = th.data.bn_goods.keyid | |
| 1114 | + } | |
| 1115 | + var str = JSON.stringify(pdata); | |
| 1116 | + console.log("支付数据"); | |
| 1117 | + console.log(str); | |
| 1118 | + //return false; | |
| 1119 | + wx.showLoading({ title: "加载中" }); | |
| 1120 | + wx.request({ | |
| 1121 | + url: oo.url + '/api/weshop/order/createWxdOrder', | |
| 1122 | + data: str, | |
| 1123 | + method: 'POST', | |
| 1124 | + header: { | |
| 1125 | + 'content-type': 'application/json' | |
| 1126 | + },// 设置请求的 header | |
| 1127 | + success: function (res) { | |
| 1117 | 1128 | |
| 1118 | - cart_set_err: function (e) { | |
| 1119 | - var txt = e.currentTarget.dataset.err; | |
| 1120 | - var ob = {}; | |
| 1121 | - ob[txt] = this.data.imgUrl + "/miniapp/images/default_g_img.gif"; | |
| 1122 | - this.setData(ob); | |
| 1123 | - }, | |
| 1129 | + wx.hideLoading(); | |
| 1130 | + if (res.statusCode == 200) { | |
| 1131 | + var data = res.data; | |
| 1132 | + if (data.code == 0) { | |
| 1133 | + console.log(th.data.is_b_now); | |
| 1134 | + //如果是购物车结算,还要删除购物车 | |
| 1135 | + if (th.data.is_b_now == 0) { | |
| 1136 | + console.log(th.data.cartlist_y); | |
| 1137 | + var list = th.data.cartlist_y; | |
| 1138 | + for (var i = 0; i < list.length; i++) { | |
| 1139 | + //删除购物车 | |
| 1140 | + getApp().request.delete("/api/weshop/cart/del/" + oo.stoid + "/" + list[i].id, {}); | |
| 1141 | + } | |
| 1142 | + } | |
| 1143 | + var order_amount = 0; | |
| 1144 | + pdata.forEach(function (em, ind) { | |
| 1145 | + order_amount += em.order_amount; | |
| 1146 | + }) | |
| 1147 | + //要进行判断,如果是用微信支付,就要跳转到支付界面 | |
| 1148 | + if (order_amount > 0) { | |
| 1149 | + th.setData({ isclose: 0 }); | |
| 1150 | + //void e.jumpToCart4({ | |
| 1151 | + // order_sn: data.data, | |
| 1152 | + // type:1, | |
| 1153 | + // }, 1); | |
| 1154 | + util_pay.pay(data.data, function () { | |
| 1155 | + setTimeout(function () { | |
| 1156 | + wx.reLaunch({ | |
| 1157 | + //url: "/pages/payment/pay_success/pay_success?type=1&order_sn="+data.data, | |
| 1158 | + url: "/pages/team/team_success/team_success?ordersn=" + data.data, | |
| 1159 | + }) | |
| 1160 | + }, 1000) | |
| 1161 | + }, function () { | |
| 1162 | + //支付失败 | |
| 1163 | + setTimeout(function () { | |
| 1164 | + //wx.navigateBack({ delta: 1 }) | |
| 1165 | + wx.reLaunch({ | |
| 1166 | + url: "/pages/user/order_list/order_list", | |
| 1167 | + }) | |
| 1168 | + }, 1000) | |
| 1169 | + | |
| 1170 | + }, oo.stoid, 1); | |
| 1124 | 1171 | |
| 1125 | - //// 开启物流的弹窗 | |
| 1126 | - show_wu_arr: function (e) { | |
| 1127 | - this.setData({open_express: 1}); | |
| 1128 | - }, | |
| 1172 | + } else { | |
| 1173 | + var dd = { | |
| 1174 | + parent_sn: data.data, | |
| 1175 | + store_id: oo.stoid, | |
| 1176 | + type: 1, | |
| 1177 | + }; | |
| 1178 | + //return false; | |
| 1179 | + getApp().request.post("/api/weshop/order/pay/createOrder", { | |
| 1180 | + data: dd, | |
| 1181 | + success: function (t) { | |
| 1182 | + console.log(t); | |
| 1183 | + // app.my_warnning("支付成功", 1, th); | |
| 1184 | + wx.showToast({ | |
| 1185 | + title: '支付成功', | |
| 1186 | + icon: 'success', | |
| 1187 | + duration: 2000 | |
| 1188 | + }); | |
| 1189 | + setTimeout(function () { | |
| 1190 | + th.setData({ isclose: 0 }); | |
| 1191 | + | |
| 1192 | + if (th.data.is_normal == 1) { | |
| 1193 | + /*-- | |
| 1194 | + wx.navigateTo({ | |
| 1195 | + url: "/pages/user/order_list/order_list", | |
| 1196 | + })--*/ | |
| 1197 | + var url = "/pages/payment/pay_success/pay_success?type=1&order_sn=" + data.data; | |
| 1198 | + wx.reLaunch({ | |
| 1199 | + url: url | |
| 1200 | + }) | |
| 1129 | 1201 | |
| 1130 | - //更新下默认,在onshow里面 | |
| 1131 | - update_code() { | |
| 1132 | - var th = this, m_wind = 0, def_exp_code = getApp().globalData.userInfo.def_exp_code; | |
| 1133 | - | |
| 1134 | - var uii = setInterval(function () { | |
| 1135 | - if (th.data.wu_arr) { | |
| 1136 | - clearInterval(uii); | |
| 1137 | - for (var k = 0; k < th.data.wu_arr.length; k++) { | |
| 1138 | - var item = th.data.wu_arr[k]; | |
| 1139 | - if (def_exp_code == item.code) { | |
| 1140 | - m_wind = k; | |
| 1202 | + } else { | |
| 1203 | + wx.reLaunch({ | |
| 1204 | + url: "/pages/team/team_success/team_success?ordersn=" + data.data, | |
| 1205 | + }) | |
| 1141 | 1206 | } |
| 1142 | - } | |
| 1143 | - //--如果是立即购买-- | |
| 1144 | - th.setData({index: m_wind, is_express: m_wind}); | |
| 1145 | - } | |
| 1146 | - }, 500) | |
| 1147 | - }, | |
| 1148 | 1207 | |
| 1149 | - // 关闭物流的弹窗 | |
| 1150 | - close_express: function () { | |
| 1151 | - this.setData({open_express: 0}); | |
| 1152 | - }, | |
| 1153 | - // 选择物流 | |
| 1154 | - click_express_name: function (e) { | |
| 1155 | - var express_name = e.currentTarget.dataset.name, shippingcode = e.currentTarget.dataset.shippingcode; | |
| 1156 | - var index = e.currentTarget.dataset.idxe; | |
| 1157 | - var ob = {is_express: index, is_shipping_code: shippingcode, index: index}; | |
| 1158 | - this.setData(ob); | |
| 1159 | - }, | |
| 1160 | 1208 | |
| 1161 | - //点击确定物流 | |
| 1162 | - determine_expres: function (e) { | |
| 1163 | - this.setData({open_express: 0}); | |
| 1164 | - this.calculatePrice2(); | |
| 1165 | - }, | |
| 1166 | - //设置默认物流 | |
| 1167 | - select_default_logistics: function () { | |
| 1168 | - var th = this; | |
| 1169 | - var is_shipping_code = this.data.is_shipping_code | |
| 1170 | - getApp().request.put("/api/weshop/users/update", { | |
| 1171 | - data: {user_id: getApp().globalData.user_id, store_id: oo.stoid, def_exp_code: is_shipping_code}, | |
| 1172 | - success: function (rse) { | |
| 1173 | - if (rse.data.code == 0) { | |
| 1174 | - getApp().globalData.userInfo.def_exp_code = is_shipping_code; | |
| 1175 | - th.setData({open_express: 0}); | |
| 1176 | - //----计算此时购物车的价格,这个页面没有calculatePrice(),2021.7.19---- | |
| 1177 | - //if(th.data.is_b_now==1) th.calculatePrice2(); | |
| 1178 | - //else th.calculatePrice(); | |
| 1179 | - th.calculatePrice2(); | |
| 1209 | + }, 1000) | |
| 1180 | 1210 | } |
| 1211 | + }); | |
| 1181 | 1212 | } |
| 1182 | - }) | |
| 1183 | - }, | |
| 1213 | + } else { | |
| 1214 | + th.data.is_summit_ing = 0; //是否提交中 | |
| 1215 | + getApp().confirmBox(data.msg); | |
| 1216 | + } | |
| 1217 | + } else { | |
| 1218 | + th.data.is_summit_ing = 0; //是否提交中 | |
| 1219 | + console.log("index.js wx.request CheckCallUser statusCode" + res.statusCode); | |
| 1220 | + } | |
| 1221 | + }, | |
| 1222 | + fail: function () { | |
| 1223 | + th.data.is_summit_ing = 0; //是否提交中 | |
| 1224 | + wx.hideLoading(); | |
| 1225 | + console.log("index.js wx.request CheckCallUser fail"); | |
| 1226 | + }, | |
| 1227 | + complete: function () { | |
| 1228 | + } | |
| 1229 | + }) | |
| 1230 | + }, | |
| 1231 | + useCoupon: function () { | |
| 1232 | + if (this.data.order.couponNum <= 0) { | |
| 1233 | + //return t.showWarning("无可用优惠券"); | |
| 1234 | + getApp().my_warnning("无可用优惠券", 0, this); | |
| 1235 | + return; | |
| 1236 | + } | |
| 1237 | + var a = { | |
| 1238 | + lid: this.data.coupon ? this.data.coupon.id : "0" | |
| 1239 | + }; | |
| 1240 | + wx.navigateTo({ | |
| 1241 | + url: "/pages/user/checkcoupon/checkcoupon?" + s.Obj2Str(a) | |
| 1242 | + }); | |
| 1243 | + }, | |
| 1244 | + //检查区域是不是包邮 | |
| 1245 | + check_area: function (arr) { | |
| 1246 | + var user_addr = this.data.user_addr; | |
| 1247 | + if (!user_addr) return 0; | |
| 1248 | + for (var i in arr) { | |
| 1249 | + var item = arr[i]; | |
| 1250 | + if (user_addr.twon == item || user_addr.district == item | |
| 1251 | + || user_addr.city == item || user_addr.province == item) { | |
| 1252 | + return 0; | |
| 1253 | + } | |
| 1254 | + } | |
| 1255 | + return 1; | |
| 1256 | + }, | |
| 1257 | + | |
| 1258 | + //检查立即购买的商品是不是不包邮 | |
| 1259 | + check_good: function (arr, goods_id) { | |
| 1260 | + if (!goods_id) goods_id = this.data.goods.goods_id; | |
| 1261 | + for (var i in arr) { | |
| 1262 | + var item = arr[i]; | |
| 1263 | + if (goods_id == item) return 0; | |
| 1264 | + } | |
| 1265 | + return 1; | |
| 1266 | + }, | |
| 1267 | + check_by_area: function (region_list) { | |
| 1268 | + var arr = region_list.split(","); | |
| 1269 | + var check = this.check_area(arr); | |
| 1270 | + return !check; | |
| 1271 | + }, | |
| 1272 | + check_by_goods: function (goods_list, goods_id) { | |
| 1273 | + var arr = goods_list.split(","); | |
| 1274 | + var check = this.check_good(arr, goods_id); | |
| 1275 | + return !check; | |
| 1276 | + }, | |
| 1277 | + enterAddressPage: function () { | |
| 1278 | + getApp().globalData.is_cart_old = 1; | |
| 1279 | + this.data.enterAddressPage = !0, wx.navigateTo({ | |
| 1280 | + url: "/pages/user/address_list/address_list" | |
| 1281 | + }); | |
| 1282 | + }, | |
| 1283 | + | |
| 1284 | + //--------立即购买时,选择自提和物流----------- | |
| 1285 | + setexptype_w: function (t) { | |
| 1286 | + var th = this; | |
| 1287 | + var ty = t.currentTarget.dataset.t, txt = t.currentTarget.dataset.txt; | |
| 1288 | + th.setData({ [txt]: ty }); | |
| 1289 | + var iszt = 1; | |
| 1290 | + if (ty == 0) { | |
| 1291 | + th.setData({ is_all_zt: 0 }); | |
| 1292 | + } else { | |
| 1293 | + for (var i = 0; i < th.data.cartlist.length; i++) { | |
| 1294 | + var item = th.data.cartlist[i]; | |
| 1295 | + if (item.exp_type == 0) { | |
| 1296 | + iszt = 0; | |
| 1297 | + break; | |
| 1298 | + } | |
| 1299 | + } | |
| 1300 | + th.setData({ is_all_zt: iszt }); | |
| 1301 | + } | |
| 1302 | + //----计算此时购物车的价格---- | |
| 1303 | + th.calculatePrice(); | |
| 1304 | + }, | |
| 1305 | + | |
| 1306 | + //--------立即购买时,选择自提和物流---------- | |
| 1307 | + setexptype: function (t) { | |
| 1308 | + var th = this; | |
| 1309 | + var ty = t.currentTarget.dataset.t; | |
| 1310 | + th.setData({ bn_exp_type: ty }); | |
| 1311 | + //当物流为空的时候。 | |
| 1312 | + if (ty == 0 && th.data.wu_arr == null) { | |
| 1313 | + return th.get_wuliu(th.calculatePrice2()); | |
| 1314 | + } | |
| 1315 | + th.calculatePrice2() | |
| 1316 | + console.log('setexptype'); | |
| 1317 | + }, | |
| 1318 | + | |
| 1319 | + //--------立即购买时,使用余额-------- | |
| 1320 | + set_bn_useyuer: function () { | |
| 1321 | + var th = this; | |
| 1322 | + th.setData({ bn_use_money: !th.data.bn_use_money }); | |
| 1323 | + th.calculatePrice2(); | |
| 1324 | + }, | |
| 1325 | + | |
| 1326 | + set_bn_commission: function () { | |
| 1327 | + var th = this; | |
| 1328 | + th.setData({ bn_use_commission: !th.data.bn_use_commission }); | |
| 1329 | + th.calculatePrice2(); | |
| 1330 | + }, | |
| 1331 | + | |
| 1332 | + | |
| 1333 | + set_js_useyuer: function () { | |
| 1334 | + var th = this; | |
| 1335 | + th.setData({ js_use_money: !th.data.js_use_money }); | |
| 1336 | + th.calculatePrice(); | |
| 1337 | + }, | |
| 1338 | + | |
| 1339 | + //----------立即购买,选择物流------------- | |
| 1340 | + bindPickerChange: function (e) { | |
| 1341 | + var ind = e.detail.value | |
| 1342 | + this.setData({ index: ind }); | |
| 1343 | + this.calculatePrice2(); | |
| 1344 | + }, | |
| 1345 | + | |
| 1346 | + //----------购物车结算,选择物流------------- | |
| 1347 | + bindPickerChange_w: function (e) { | |
| 1348 | + var ind = e.detail.value, txt = e.currentTarget.dataset.txt; | |
| 1349 | + this.setData({ [txt]: ind }); | |
| 1350 | + this.calculatePrice(); | |
| 1351 | + }, | |
| 1352 | + | |
| 1353 | + cart_set_err: function (e) { | |
| 1354 | + var txt = e.currentTarget.dataset.err; | |
| 1355 | + var ob = {}; | |
| 1356 | + ob[txt] = this.data.imgUrl + "/miniapp/images/default_g_img.gif"; | |
| 1357 | + this.setData(ob); | |
| 1358 | + }, | |
| 1359 | + | |
| 1360 | + //// 开启物流的弹窗 | |
| 1361 | + show_wu_arr: function (e) { | |
| 1362 | + this.setData({ open_express: 1 }); | |
| 1363 | + }, | |
| 1364 | + | |
| 1365 | + //更新下默认,在onshow里面 | |
| 1366 | + update_code() { | |
| 1367 | + var th = this, m_wind = 0, def_exp_code = getApp().globalData.userInfo.def_exp_code; | |
| 1368 | + | |
| 1369 | + var uii = setInterval(function () { | |
| 1370 | + if (th.data.wu_arr) { | |
| 1371 | + clearInterval(uii); | |
| 1372 | + for (var k = 0; k < th.data.wu_arr.length; k++) { | |
| 1373 | + var item = th.data.wu_arr[k]; | |
| 1374 | + if (def_exp_code == item.code) { | |
| 1375 | + m_wind = k; | |
| 1376 | + } | |
| 1377 | + } | |
| 1378 | + //--如果是立即购买-- | |
| 1379 | + th.setData({ index: m_wind, is_express: m_wind }); | |
| 1380 | + } | |
| 1381 | + }, 500) | |
| 1382 | + }, | |
| 1383 | + | |
| 1384 | + // 关闭物流的弹窗 | |
| 1385 | + close_express: function () { | |
| 1386 | + this.setData({ open_express: 0 }); | |
| 1387 | + }, | |
| 1388 | + // 选择物流 | |
| 1389 | + click_express_name: function (e) { | |
| 1390 | + var express_name = e.currentTarget.dataset.name, shippingcode = e.currentTarget.dataset.shippingcode; | |
| 1391 | + var index = e.currentTarget.dataset.idxe; | |
| 1392 | + var ob = { is_express: index, is_shipping_code: shippingcode, index: index }; | |
| 1393 | + this.setData(ob); | |
| 1394 | + }, | |
| 1395 | + | |
| 1396 | + //点击确定物流 | |
| 1397 | + determine_expres: function (e) { | |
| 1398 | + this.setData({ open_express: 0 }); | |
| 1399 | + this.calculatePrice2(); | |
| 1400 | + }, | |
| 1401 | + //设置默认物流 | |
| 1402 | + select_default_logistics: function () { | |
| 1403 | + var th = this; | |
| 1404 | + var is_shipping_code = this.data.is_shipping_code | |
| 1405 | + getApp().request.put("/api/weshop/users/update", { | |
| 1406 | + data: { user_id: getApp().globalData.user_id, store_id: oo.stoid, def_exp_code: is_shipping_code }, | |
| 1407 | + success: function (rse) { | |
| 1408 | + if (rse.data.code == 0) { | |
| 1409 | + getApp().globalData.userInfo.def_exp_code = is_shipping_code; | |
| 1410 | + th.setData({ open_express: 0 }); | |
| 1411 | + //----计算此时购物车的价格,这个页面没有calculatePrice(),2021.7.19---- | |
| 1412 | + //if(th.data.is_b_now==1) th.calculatePrice2(); | |
| 1413 | + //else th.calculatePrice(); | |
| 1414 | + th.calculatePrice2(); | |
| 1415 | + } | |
| 1416 | + } | |
| 1417 | + }) | |
| 1418 | + }, | |
| 1184 | 1419 | |
| 1185 | 1420 | |
| 1186 | - //跳转到购买卡 | |
| 1187 | - buycard: function () { | |
| 1188 | - getApp().goto("/pages/user/plus/plus"); | |
| 1189 | - getApp().globalData.plus_buy_back = 1; | |
| 1190 | - } | |
| 1421 | + //跳转到购买卡 | |
| 1422 | + buycard: function () { | |
| 1423 | + getApp().goto("/pages/user/plus/plus"); | |
| 1424 | + getApp().globalData.plus_buy_back = 1; | |
| 1425 | + } | |
| 1191 | 1426 | }); | ... | ... |
pages/cart/cart2_pt/cart2_pt.wxml
| ... | ... | @@ -145,6 +145,17 @@ |
| 145 | 145 | <view class="yu_er">使用余额 :¥{{yuer}} </view> |
| 146 | 146 | </view> |
| 147 | 147 | </view> |
| 148 | + <!-- 预存款 --> | |
| 149 | + <view class="set-mes" catchtap="prestore2" wx:if="{{bn_goods.yck_off}}"> | |
| 150 | + <view class="use-item" style="justify-content: space-between;padding: 0;"> | |
| 151 | + <view> | |
| 152 | + <icon color="{{bn_goods.yck_off==2 ? 'red' : '#808080'}}" size="16" type="success"></icon> | |
| 153 | + <view class="yu_er">使用预存</view> | |
| 154 | + </view> | |
| 155 | + <view wx:if="{{bn_goods.yck_off==2 }}">¥{{filters.toFix(bn_goods.yck,2)}}</view> | |
| 156 | + </view> | |
| 157 | + </view> | |
| 158 | + | |
| 148 | 159 | <view class="item" wx:if="{{kt_type<3 || is_normal==1}}"> |
| 149 | 160 | <view>商品金额</view> |
| 150 | 161 | <view class="co-red">¥ {{formData.all_price}}元</view> |
| ... | ... | @@ -159,6 +170,11 @@ |
| 159 | 170 | <view>配送费用</view> |
| 160 | 171 | <view class="co-red">¥ {{formData.shipping_price}}元</view> |
| 161 | 172 | </view> |
| 173 | + <!-- 使用预存优惠金额 --> | |
| 174 | + <view class="item" wx:if="{{formData.prestore>0}}"> | |
| 175 | + <view>使用预存</view> | |
| 176 | + <view class="co-red">- ¥ {{filters.toFix(formData.prestore,2)}}元</view> | |
| 177 | + </view> | |
| 162 | 178 | <view class="item" wx:if="{{formData.user_money>0}}"> |
| 163 | 179 | <view>使用余额</view> |
| 164 | 180 | <view class="co-red">- ¥ {{formData.user_money}}元</view> | ... | ... |
pages/cart/cart2_pt/cart2_pt.wxss