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