Commit d3963a46d4574e5b4aa6f15587101268d662ae33
1 parent
1a59d68f
普通商品,积分购 不包邮地区
Showing
6 changed files
with
3434 additions
and
3435 deletions
packageC/pages/presell/cart/cart.js
... | ... | @@ -112,34 +112,34 @@ Page({ |
112 | 112 | tabs: ['门店自提', '快递邮寄'], |
113 | 113 | currentTabIndex: 1, |
114 | 114 | |
115 | - order_sn:'', | |
116 | - order_id:'', | |
115 | + order_sn: '', | |
116 | + order_id: '', | |
117 | 117 | |
118 | 118 | }, |
119 | 119 | onLoad: function (t) { |
120 | - | |
121 | - if(t.order_id) this.data.order_id=t.order_id; | |
122 | - if(t.order_sn) this.data.order_sn=t.order_sn; | |
123 | 120 | |
124 | - wx.setNavigationBarTitle({title: "订单详情",}) | |
121 | + if (t.order_id) this.data.order_id = t.order_id; | |
122 | + if (t.order_sn) this.data.order_sn = t.order_sn; | |
123 | + | |
124 | + wx.setNavigationBarTitle({ title: "订单详情", }) | |
125 | 125 | var th = this; |
126 | - this.setData({is_b_now: t.is_bnow == undefined ? 0 : t.is_bnow,}); | |
126 | + this.setData({ is_b_now: t.is_bnow == undefined ? 0 : t.is_bnow, }); | |
127 | 127 | th.data.param = t; |
128 | 128 | //清理一下,确保最新的系统配置 |
129 | 129 | getApp().globalData.config2 = null; |
130 | 130 | //清空is_pick_up |
131 | 131 | getApp().request.put("/api/weshop/useraddress/updatePickUp", { |
132 | - data: {user_id: getApp().globalData.user_id, is_pickup: 0}, | |
132 | + data: { user_id: getApp().globalData.user_id, is_pickup: 0 }, | |
133 | 133 | success: function (s) { |
134 | 134 | } |
135 | 135 | }); |
136 | - if(!getApp().globalData.userInfo){ | |
136 | + if (!getApp().globalData.userInfo) { | |
137 | 137 | getApp().goto("/pages/togoin/togoin"); |
138 | 138 | } |
139 | 139 | |
140 | 140 | }, |
141 | 141 | onUnload: function () { |
142 | - this.setData({isclose: 1}) | |
142 | + this.setData({ isclose: 1 }) | |
143 | 143 | }, |
144 | 144 | onHide: function () { |
145 | 145 | this.setData({ |
... | ... | @@ -152,13 +152,13 @@ Page({ |
152 | 152 | //----------子页返回父页触发---------- |
153 | 153 | onShow: function () { |
154 | 154 | var th = this; |
155 | - th.setData({show_submit: 0}); //让提交先掩藏 | |
155 | + th.setData({ show_submit: 0 }); //让提交先掩藏 | |
156 | 156 | th.data.g_cart_q_time = null; |
157 | 157 | if (th.data.isclose == 0) { |
158 | 158 | wx.navigateTo({ |
159 | - url:"/pages/index/index/index" | |
159 | + url: "/pages/index/index/index" | |
160 | 160 | }) |
161 | - }else{ | |
161 | + } else { | |
162 | 162 | this.getuser_addr(function (ie) { |
163 | 163 | //地址切换要把包邮券清空 |
164 | 164 | if (!th.data.user_addr || !ie || th.data.user_addr.address_id != ie.address_id) { |
... | ... | @@ -178,16 +178,16 @@ Page({ |
178 | 178 | th.data.prom_goods_map = {}; |
179 | 179 | th.data.is_summit_ing = 0; |
180 | 180 | //更换地址回来要重新调用计算价钱的接口 |
181 | - if (!th.data.user_addr || th.data.user_addr.address_id != ie.address_id){ | |
182 | - th.setData({user_addr: ie}); | |
183 | - th.setData({add_back: 1}); | |
184 | - th.calculatePrice2(); | |
181 | + if (!th.data.user_addr || th.data.user_addr.address_id != ie.address_id) { | |
182 | + th.setData({ user_addr: ie }); | |
183 | + th.setData({ add_back: 1 }); | |
184 | + th.calculatePrice2(); | |
185 | 185 | } else { |
186 | - th.setData({user_addr: ie}); | |
186 | + th.setData({ user_addr: ie }); | |
187 | 187 | } |
188 | 188 | var going = 0; |
189 | 189 | }); |
190 | - | |
190 | + | |
191 | 191 | var is_card_back = getApp().globalData.is_card_back; |
192 | 192 | //--更新默认地址--,看一下是不是跳到地址页面,同时也不是购买等级卡返回的,这里很重要,否则会重新更新收货物流公司 |
193 | 193 | if (!getApp().globalData.is_cart_old && !is_card_back && !getApp().globalData.plus_buy_back) { |
... | ... | @@ -210,7 +210,7 @@ Page({ |
210 | 210 | sales_rules: ee.sales_rules, |
211 | 211 | rank_switch: json_d.rank_switch, |
212 | 212 | is_default_logistics: is_default_logistics, |
213 | - sys_switch:json_d, | |
213 | + sys_switch: json_d, | |
214 | 214 | }); |
215 | 215 | |
216 | 216 | var rank_switch = json_d.rank_switch; |
... | ... | @@ -223,34 +223,34 @@ Page({ |
223 | 223 | //-- 获取所有的等级卡, -- |
224 | 224 | getApp().request.promiseGet("/api/weshop/plus/vip/mem/bership/list?storeId=" + os.stoid, |
225 | 225 | {}).then(res => { |
226 | - if (res.data.code == 0) { | |
227 | - var plusCard = res.data.data; | |
228 | - //-- 循环判断,拿到最贵的那张卡 -- | |
229 | - for (var ih in plusCard) { | |
230 | - if (plusCard[ih].IsStopBuy == true) { | |
231 | - continue; | |
232 | - } | |
233 | - if (max_price < 0) { | |
234 | - max_price = plusCard[ih].CardFee; | |
235 | - name = 'card' + plusCard[ih]['CorrPrice']; | |
236 | - show_card = plusCard[ih]; | |
237 | - } else { | |
238 | - if (max_price < plusCard[ih].CardFee) { | |
226 | + if (res.data.code == 0) { | |
227 | + var plusCard = res.data.data; | |
228 | + //-- 循环判断,拿到最贵的那张卡 -- | |
229 | + for (var ih in plusCard) { | |
230 | + if (plusCard[ih].IsStopBuy == true) { | |
231 | + continue; | |
232 | + } | |
233 | + if (max_price < 0) { | |
239 | 234 | max_price = plusCard[ih].CardFee; |
240 | 235 | name = 'card' + plusCard[ih]['CorrPrice']; |
241 | 236 | show_card = plusCard[ih]; |
237 | + } else { | |
238 | + if (max_price < plusCard[ih].CardFee) { | |
239 | + max_price = plusCard[ih].CardFee; | |
240 | + name = 'card' + plusCard[ih]['CorrPrice']; | |
241 | + show_card = plusCard[ih]; | |
242 | + } | |
242 | 243 | } |
243 | 244 | } |
244 | - } | |
245 | 245 | |
246 | - if (show_card) { | |
247 | - name = name.toLowerCase(); | |
248 | - th.setData({card_name: name, show_card: show_card}) | |
246 | + if (show_card) { | |
247 | + name = name.toLowerCase(); | |
248 | + th.setData({ card_name: name, show_card: show_card }) | |
249 | + } | |
249 | 250 | } |
250 | - } | |
251 | - //-----先获取物流,再获取用户信息,再展示页面----- | |
252 | - th.get_wuliu(th.get_info(th.show_page)); | |
253 | - }) | |
251 | + //-----先获取物流,再获取用户信息,再展示页面----- | |
252 | + th.get_wuliu(th.get_info(th.show_page)); | |
253 | + }) | |
254 | 254 | } else { |
255 | 255 | //-----先获取物流,再获取用户信息,再展示页面----- |
256 | 256 | th.get_wuliu(th.get_info(th.show_page)); |
... | ... | @@ -270,10 +270,10 @@ Page({ |
270 | 270 | if (th.data.is_default_logistics) { |
271 | 271 | //如果第一个不是开启默认,说明要让用户自己选 |
272 | 272 | if (!e[0].is_default) { |
273 | - th.setData({is_default_logistics: 0}); | |
273 | + th.setData({ is_default_logistics: 0 }); | |
274 | 274 | } |
275 | 275 | } |
276 | - th.setData({wu_arr: e}) | |
276 | + th.setData({ wu_arr: e }) | |
277 | 277 | typeof func == "function" && func(); |
278 | 278 | }) |
279 | 279 | }, |
... | ... | @@ -287,9 +287,9 @@ Page({ |
287 | 287 | getuser_addr: function (func) { |
288 | 288 | var th = this; |
289 | 289 | a.get("/api/weshop/useraddress/page", { |
290 | - data: {user_id: to.globalData.user_id, store_id: oo.stoid, pageSize: 600, t: Math.random()}, | |
290 | + data: { user_id: to.globalData.user_id, store_id: oo.stoid, pageSize: 600, t: Math.random() }, | |
291 | 291 | success: function (su) { |
292 | - | |
292 | + | |
293 | 293 | var item = null; |
294 | 294 | if (su.data.code == 0 && su.data.data && su.data.data.pageData) { |
295 | 295 | var user_addr = su.data.data.pageData; |
... | ... | @@ -308,7 +308,7 @@ Page({ |
308 | 308 | } |
309 | 309 | |
310 | 310 | if (item == undefined) item = null; |
311 | - if (!item) th.setData({user_addr: null}); //地址为空的时候,要清空,因为返回的时候,有缓存 | |
311 | + if (!item) th.setData({ user_addr: null }); //地址为空的时候,要清空,因为返回的时候,有缓存 | |
312 | 312 | |
313 | 313 | func(item); |
314 | 314 | } |
... | ... | @@ -336,7 +336,7 @@ Page({ |
336 | 336 | }); |
337 | 337 | } |
338 | 338 | //获取立即购买的商品信息 |
339 | - th.get_buy_goods(th.data.order_id,th.data.order_sn); | |
339 | + th.get_buy_goods(th.data.order_id, th.data.order_sn); | |
340 | 340 | }); |
341 | 341 | //获取提现金额 |
342 | 342 | getApp().request.get("/api/weshop/withdrawals/summoney", { |
... | ... | @@ -360,30 +360,30 @@ Page({ |
360 | 360 | }, |
361 | 361 | |
362 | 362 | //-----获取商品------ |
363 | - async get_buy_goods(ord,o_sn) { | |
363 | + async get_buy_goods(ord, o_sn) { | |
364 | 364 | var order = null, |
365 | 365 | order_goods = null, |
366 | 366 | goods = null, |
367 | 367 | pickup = null, |
368 | 368 | distr_type = 0, |
369 | 369 | exp_type = 0, |
370 | - presell=null, //订单从表 | |
371 | - pre_arr=null, //订单内容 | |
372 | - act=null, //订单内容 | |
370 | + presell = null, //订单从表 | |
371 | + pre_arr = null, //订单内容 | |
372 | + act = null, //订单内容 | |
373 | 373 | th = this; |
374 | 374 | |
375 | 375 | |
376 | - if(o_sn){ | |
376 | + if (o_sn) { | |
377 | 377 | //获取order信息根据订单编号order_sn |
378 | 378 | await getApp().request.promiseGet("/api/weshop/order/page", { |
379 | - data: { store_id: os.stoid, order_sn: o_sn,} | |
379 | + data: { store_id: os.stoid, order_sn: o_sn, } | |
380 | 380 | }).then(res => { |
381 | 381 | order = res.data.data.pageData[0]; |
382 | 382 | }) |
383 | 383 | |
384 | 384 | |
385 | - ord=order.order_id; | |
386 | - }else{ | |
385 | + ord = order.order_id; | |
386 | + } else { | |
387 | 387 | //---获取订单--- |
388 | 388 | await getApp().request.promiseGet("/api/weshop/order/get/" + oo.stoid + "/" + ord, {}).then(res => { |
389 | 389 | order = res.data.data; |
... | ... | @@ -399,94 +399,94 @@ Page({ |
399 | 399 | order_goods = res.data.data.pageData[0]; |
400 | 400 | }); |
401 | 401 | |
402 | - await getApp().request.promiseGet("/api/weshop/order/orderPresell/get/"+oo.stoid+"/"+order.order_id, {}).then(res => { | |
402 | + await getApp().request.promiseGet("/api/weshop/order/orderPresell/get/" + oo.stoid + "/" + order.order_id, {}).then(res => { | |
403 | 403 | presell = res.data.data; |
404 | 404 | }); |
405 | 405 | |
406 | 406 | //等待定金 |
407 | - if(order.order_status<2 && presell.deposit_pay_time<=0 ){ | |
408 | - th.setData({wait_dj:1}) | |
407 | + if (order.order_status < 2 && presell.deposit_pay_time <= 0) { | |
408 | + th.setData({ wait_dj: 1 }) | |
409 | 409 | } |
410 | 410 | //等待尾款 |
411 | - if(order.order_status<2 && presell.deposit_pay_time>0 && presell.tail_pay_state==0 && presell.presell_type!=1){ | |
412 | - th.setData({wait_wk:1}) | |
413 | - wx.setNavigationBarTitle({title: "支付尾款",}) | |
411 | + if (order.order_status < 2 && presell.deposit_pay_time > 0 && presell.tail_pay_state == 0 && presell.presell_type != 1) { | |
412 | + th.setData({ wait_wk: 1 }) | |
413 | + wx.setNavigationBarTitle({ title: "支付尾款", }) | |
414 | 414 | } |
415 | 415 | //等待发货 |
416 | - if(order.pay_status==1 && order.shipping_status==0){ | |
417 | - th.setData({wait_fh:1}) | |
416 | + if (order.pay_status == 1 && order.shipping_status == 0) { | |
417 | + th.setData({ wait_fh: 1 }) | |
418 | 418 | } |
419 | 419 | |
420 | - if(order.pay_status==1 && order.shipping_status==1 && order.order_status<2){ | |
421 | - th.setData({wait_sh:1}) | |
420 | + if (order.pay_status == 1 && order.shipping_status == 1 && order.order_status < 2) { | |
421 | + th.setData({ wait_sh: 1 }) | |
422 | 422 | } |
423 | 423 | //------获取预售主表---------- |
424 | - await getApp().request.promiseGet("/api/weshop/marketing/marketingPresellForm/get/"+os.stoid+"/"+presell.prom_id, {}).then(res => { | |
424 | + await getApp().request.promiseGet("/api/weshop/marketing/marketingPresellForm/get/" + os.stoid + "/" + presell.prom_id, {}).then(res => { | |
425 | 425 | if (res.data.code == 0 && res.data.data) { |
426 | - act=res.data.data; | |
426 | + act = res.data.data; | |
427 | 427 | |
428 | 428 | th.setData({ |
429 | - act: res.data.data, | |
429 | + act: res.data.data, | |
430 | 430 | }); |
431 | 431 | } |
432 | 432 | }) |
433 | 433 | |
434 | 434 | //-- 判断一下会员的身份 -- |
435 | - if(order.pay_status==0){ | |
436 | - var pre_data = { store_id: os.stoid, presell_id: presell.prom_id,timetype: 12, goods_id: order_goods.goods_id }; | |
435 | + if (order.pay_status == 0) { | |
436 | + var pre_data = { store_id: os.stoid, presell_id: presell.prom_id, timetype: 12, goods_id: order_goods.goods_id }; | |
437 | 437 | pre_data.user_id = order.user_id; |
438 | - var isok=1; | |
438 | + var isok = 1; | |
439 | 439 | await getApp().request.promiseGet("/api/weshop/marketing/marketingPresellList/page", { |
440 | 440 | data: pre_data, |
441 | 441 | }).then(e => { |
442 | 442 | if (e.data.code == 0 && e.data.data.pageData && e.data.data.pageData.length > 0) { |
443 | 443 | pre_arr = e.data.data.pageData[0]; |
444 | - }else{ | |
445 | - isok=0; | |
444 | + } else { | |
445 | + isok = 0; | |
446 | 446 | } |
447 | 447 | }) |
448 | 448 | |
449 | - if(!isok){ | |
449 | + if (!isok) { | |
450 | 450 | getApp().confirmBox("会员身份不符合"); |
451 | 451 | return false; |
452 | 452 | } |
453 | 453 | |
454 | - if(th.data.wait_dj){ | |
455 | - if(act.is_end) { | |
454 | + if (th.data.wait_dj) { | |
455 | + if (act.is_end) { | |
456 | 456 | getApp().confirmBox("活动已经结束"); |
457 | 457 | return false; |
458 | 458 | } |
459 | - if(!act.isuse) { | |
459 | + if (!act.isuse) { | |
460 | 460 | getApp().confirmBox("活动未启用"); |
461 | 461 | return false; |
462 | 462 | } |
463 | - if(th.data.act.end_time<ut.gettimestamp()) { | |
464 | - getApp().confirmBox("活动的定金时间已经结束",function () { | |
463 | + if (th.data.act.end_time < ut.gettimestamp()) { | |
464 | + getApp().confirmBox("活动的定金时间已经结束", function () { | |
465 | 465 | ut.wx_back(); |
466 | 466 | }); |
467 | 467 | return false; |
468 | 468 | } |
469 | 469 | |
470 | 470 | } |
471 | - if(th.data.wait_wk){ | |
472 | - if(th.data.act.pay_enddate<ut.gettimestamp()) { | |
473 | - getApp().confirmBox("活动的尾款时间已经结束",function () { | |
471 | + if (th.data.wait_wk) { | |
472 | + if (th.data.act.pay_enddate < ut.gettimestamp()) { | |
473 | + getApp().confirmBox("活动的尾款时间已经结束", function () { | |
474 | 474 | ut.wx_back(); |
475 | 475 | }); |
476 | 476 | return false; |
477 | 477 | } |
478 | 478 | } |
479 | 479 | } |
480 | - else{ | |
481 | - await getApp().request.promiseGet("/api/weshop/marketing/marketingPresellList/list",{ | |
482 | - data:{store_id:os.stoid,goods_id:order_goods.goods_id,presell_id:order_goods.prom_id} | |
483 | - }).then(re=>{ | |
480 | + else { | |
481 | + await getApp().request.promiseGet("/api/weshop/marketing/marketingPresellList/list", { | |
482 | + data: { store_id: os.stoid, goods_id: order_goods.goods_id, presell_id: order_goods.prom_id } | |
483 | + }).then(re => { | |
484 | 484 | if (re.data.code == 0 && re.data.data && re.data.data.length > 0) { |
485 | 485 | pre_arr = re.data.data[0]; |
486 | 486 | } |
487 | 487 | }) |
488 | 488 | |
489 | - if(!pre_arr){ | |
489 | + if (!pre_arr) { | |
490 | 490 | getApp().confirmBox("未找到商品"); |
491 | 491 | return false; |
492 | 492 | } |
... | ... | @@ -498,28 +498,29 @@ Page({ |
498 | 498 | order.market_price = goods.market_price; |
499 | 499 | order.show_img = oo.imghost + goods.original_img; |
500 | 500 | }); |
501 | - | |
502 | - | |
503 | - var g_url="/packageC/pages/presell/goodsInfo/goodsInfo?goods_id="+order_goods.goods_id+"&pre_id="+pre_arr.id; | |
504 | - if(act.is_end || th.data.act.end_time<ut.gettimestamp()) { | |
505 | - | |
506 | - if(goods.prom_type==8 && goods.prom_id==act.id){ | |
507 | - g_url="/pages/goods/goodsInfo/goodsInfo?goods_id="+order_goods.goods_id; | |
508 | - getApp().request.put("/api/weshop/goods/update", | |
509 | - { data:{goods_id:order_goods.goods_id,store_id:os.stoid,prom_id:0,prom_type:0}, | |
510 | - success: function(e) {} | |
511 | - }); | |
512 | - }else{ | |
513 | - g_url="/pages/goods/goodsInfo/goodsInfo?goods_id="+order_goods.goods_id; | |
514 | - if(goods.prom_type==8){ | |
515 | - g_url="/packageC/pages/presell/goodsInfo/goodsInfo?goods_id="+order_goods.goods_id+"&prom_id="+goods.prom_id; | |
516 | - } | |
517 | - | |
518 | - } | |
519 | - | |
520 | - } | |
521 | - | |
522 | - | |
501 | + | |
502 | + | |
503 | + var g_url = "/packageC/pages/presell/goodsInfo/goodsInfo?goods_id=" + order_goods.goods_id + "&pre_id=" + pre_arr.id; | |
504 | + if (act.is_end || th.data.act.end_time < ut.gettimestamp()) { | |
505 | + | |
506 | + if (goods.prom_type == 8 && goods.prom_id == act.id) { | |
507 | + g_url = "/pages/goods/goodsInfo/goodsInfo?goods_id=" + order_goods.goods_id; | |
508 | + getApp().request.put("/api/weshop/goods/update", | |
509 | + { | |
510 | + data: { goods_id: order_goods.goods_id, store_id: os.stoid, prom_id: 0, prom_type: 0 }, | |
511 | + success: function (e) { } | |
512 | + }); | |
513 | + } else { | |
514 | + g_url = "/pages/goods/goodsInfo/goodsInfo?goods_id=" + order_goods.goods_id; | |
515 | + if (goods.prom_type == 8) { | |
516 | + g_url = "/packageC/pages/presell/goodsInfo/goodsInfo?goods_id=" + order_goods.goods_id + "&prom_id=" + goods.prom_id; | |
517 | + } | |
518 | + | |
519 | + } | |
520 | + | |
521 | + } | |
522 | + | |
523 | + | |
523 | 524 | //判断使用优惠券的接口需要 |
524 | 525 | th.data.check_quan_ware_list = goods.erpwareid; |
525 | 526 | //---获取门店--- |
... | ... | @@ -529,30 +530,32 @@ Page({ |
529 | 530 | |
530 | 531 | order['is_all_return'] = 0; |
531 | 532 | //------------对比一下有没有退款记录------------ |
532 | - await getApp().request.promiseGet("/api/weshop/order/returngoods/page",{ | |
533 | - data: { order_id: order.order_id, store_id: oo.stoid, | |
534 | - user_id:order.user_id, pageSize: 200 } | |
535 | - }).then(rss=>{ | |
536 | - var ttd=rss; | |
533 | + await getApp().request.promiseGet("/api/weshop/order/returngoods/page", { | |
534 | + data: { | |
535 | + order_id: order.order_id, store_id: oo.stoid, | |
536 | + user_id: order.user_id, pageSize: 200 | |
537 | + } | |
538 | + }).then(rss => { | |
539 | + var ttd = rss; | |
537 | 540 | //----没有相关的退款记录---- |
538 | - if (ttd.data.data.total==0){ | |
541 | + if (ttd.data.data.total == 0) { | |
539 | 542 | order['is_all_return'] = 0; |
540 | - }else{ | |
543 | + } else { | |
541 | 544 | var eea = ttd.data.data.pageData[0]; |
542 | 545 | //1.退款正在进行中, |
543 | 546 | //2.退款被拒绝就要显示可以退款 |
544 | 547 | //3.退款已经完成 |
545 | - order['is_all_return']=1; | |
548 | + order['is_all_return'] = 1; | |
546 | 549 | order['is_all_return_status'] = ttd.data.data.pageData[0].status; |
547 | 550 | |
548 | 551 | if (order['order_status'] == 1 && order['pay_status'] == 1) { |
549 | 552 | switch (eea.status) { |
550 | 553 | case 0: |
551 | 554 | case 1: |
552 | - order.order_status_detail="退款中"; | |
555 | + order.order_status_detail = "退款中"; | |
553 | 556 | order['return_btn'] = 2; break; |
554 | 557 | case 2: |
555 | - order.order_status_detail="退款完成"; | |
558 | + order.order_status_detail = "退款完成"; | |
556 | 559 | order['return_btn'] = 4; break; |
557 | 560 | case 3: |
558 | 561 | order['return_btn'] = 3; break; |
... | ... | @@ -563,8 +566,8 @@ Page({ |
563 | 566 | } |
564 | 567 | }) |
565 | 568 | |
566 | - var price=presell.presell_price; | |
567 | - if(!goods) return false; | |
569 | + var price = presell.presell_price; | |
570 | + if (!goods) return false; | |
568 | 571 | //--判断物流-- |
569 | 572 | if (goods.distr_type) |
570 | 573 | distr_type = goods.distr_type; |
... | ... | @@ -587,50 +590,50 @@ Page({ |
587 | 590 | } |
588 | 591 | |
589 | 592 | //等待发货的时候 |
590 | - if(th.data.wait_fh){ | |
591 | - var send_time=th.data.act.delivery_date; | |
592 | - if(th.data.act.delivery_type==2){ | |
593 | - send_time=ut.gettimestamp()+th.data.act.delivery_daynum*3600*24; | |
594 | - } | |
593 | + if (th.data.wait_fh) { | |
594 | + var send_time = th.data.act.delivery_date; | |
595 | + if (th.data.act.delivery_type == 2) { | |
596 | + send_time = ut.gettimestamp() + th.data.act.delivery_daynum * 3600 * 24; | |
597 | + } | |
595 | 598 | } |
596 | 599 | |
597 | 600 | order.order_goods = order_goods; |
598 | - var tail_pay=pre_arr.presell_price*order_goods.goods_num-presell.presell_deposit; | |
601 | + var tail_pay = pre_arr.presell_price * order_goods.goods_num - presell.presell_deposit; | |
599 | 602 | this.setData({ |
600 | 603 | order: order, |
601 | 604 | distr_type: distr_type, |
602 | 605 | pickup: pickup, |
603 | 606 | exp_type: exp_type, |
604 | 607 | goods: goods, |
605 | - presell:presell, | |
606 | - pre_arr:pre_arr, | |
607 | - show_submit:1, | |
608 | - userInfo:getApp().globalData.userInfo, | |
609 | - tail_pay:tail_pay, | |
610 | - order_goods:order_goods, | |
611 | - all_price:pre_arr.presell_price*order_goods.goods_num, | |
612 | - pickup_id:pickup.pickup_id, | |
613 | - send_time:send_time, | |
614 | - g_url:g_url | |
608 | + presell: presell, | |
609 | + pre_arr: pre_arr, | |
610 | + show_submit: 1, | |
611 | + userInfo: getApp().globalData.userInfo, | |
612 | + tail_pay: tail_pay, | |
613 | + order_goods: order_goods, | |
614 | + all_price: pre_arr.presell_price * order_goods.goods_num, | |
615 | + pickup_id: pickup.pickup_id, | |
616 | + send_time: send_time, | |
617 | + g_url: g_url | |
615 | 618 | }); |
616 | 619 | th.get_diff(); |
617 | 620 | //统一进行计算金额 |
618 | 621 | th.calculatePrice2(); |
619 | 622 | //如果可以 |
620 | - if(th.data.act.is_usecoupon){ | |
623 | + if (th.data.act.is_usecoupon) { | |
621 | 624 | th.get_buy_now_quan(); |
622 | 625 | } |
623 | 626 | }, |
624 | 627 | |
625 | 628 | |
626 | - async calculatePrice2(){ | |
627 | - var th=this; | |
628 | - if(!this.data.pre_arr) return false; | |
629 | + async calculatePrice2() { | |
630 | + var th = this; | |
631 | + if (!this.data.pre_arr) return false; | |
629 | 632 | //--计算物流-- |
630 | 633 | if (this.data.exp_type == 0) { |
631 | 634 | this.calculate_wuliu(); |
632 | 635 | } else { |
633 | - var allpice =this.data.pre_arr.presell_price*this.data.order_goods.goods_num; | |
636 | + var allpice = this.data.pre_arr.presell_price * this.data.order_goods.goods_num; | |
634 | 637 | allpice = allpice.toFixed(2); |
635 | 638 | //--看一下有没有订单优惠-- |
636 | 639 | var o_condition = parseFloat(allpice); |
... | ... | @@ -654,37 +657,37 @@ Page({ |
654 | 657 | quan_price = res.data.data[0].WareCashSum; |
655 | 658 | } |
656 | 659 | }) |
657 | - }else{ | |
658 | - th.setData({quan_price:0}); | |
659 | - if(th.data.using_quan && th.data.using_quan[bn_pick] && th.data.using_quan[bn_pick].isby==1){ | |
660 | - var txt="using_quan["+bn_pick+"]"; | |
661 | - th.setData({[txt]:{}}); | |
660 | + } else { | |
661 | + th.setData({ quan_price: 0 }); | |
662 | + if (th.data.using_quan && th.data.using_quan[bn_pick] && th.data.using_quan[bn_pick].isby == 1) { | |
663 | + var txt = "using_quan[" + bn_pick + "]"; | |
664 | + th.setData({ [txt]: {} }); | |
662 | 665 | } |
663 | 666 | |
664 | 667 | } |
665 | 668 | |
666 | - if(quan_price>0){ | |
667 | - if (quan_price < th.data.tail_pay) th.setData({quan_price: quan_price}) | |
668 | - else { | |
669 | - th.setData({quan_price: th.data.tail_pay}) | |
670 | - } | |
671 | - o_condition=o_condition-quan_price; | |
669 | + if (quan_price > 0) { | |
670 | + if (quan_price < th.data.tail_pay) th.setData({ quan_price: quan_price }) | |
671 | + else { | |
672 | + th.setData({ quan_price: th.data.tail_pay }) | |
673 | + } | |
674 | + o_condition = o_condition - quan_price; | |
672 | 675 | |
673 | - }else{ | |
674 | - th.setData({quan_price: 0}) | |
676 | + } else { | |
677 | + th.setData({ quan_price: 0 }) | |
675 | 678 | } |
676 | - if(o_condition<0) o_condition=0; | |
679 | + if (o_condition < 0) o_condition = 0; | |
677 | 680 | |
678 | 681 | //如果同意参与订单优惠 |
679 | 682 | if (o_condition > 0 && this.data.pre_arr.is_useorderyh) { |
680 | 683 | th.check_is_order_prom(o_condition, function (ord_price) { |
681 | - var bn_pick=th.data.pickup.pickup_id | |
684 | + var bn_pick = th.data.pickup.pickup_id | |
682 | 685 | var order_prom_amount = 0; |
683 | 686 | var order_prom_id = 0; |
684 | - var o_condition1=0; | |
687 | + var o_condition1 = 0; | |
685 | 688 | if (th.data.order_prom[bn_pick]) { |
686 | 689 | var ord_prom = th.data.order_prom[bn_pick]; |
687 | - if(!ord_prom.is_xz_yh || quan_price<=0) { | |
690 | + if (!ord_prom.is_xz_yh || quan_price <= 0) { | |
688 | 691 | order_prom_id = ord_prom['id']; |
689 | 692 | switch (ord_prom['type']) { |
690 | 693 | case 0: |
... | ... | @@ -703,19 +706,19 @@ Page({ |
703 | 706 | var order_prom_txt1 = "order_prom_id"; |
704 | 707 | var order_prom_txt2 = "order_prom_amount"; |
705 | 708 | if (order_prom_id > 0) { |
706 | - th.setData({[order_prom_txt1]: order_prom_id, [order_prom_txt2]: order_prom_amount}) | |
707 | - }else{ | |
708 | - o_condition1=ord_price; | |
709 | - th.setData({[order_prom_txt1]: 0, [order_prom_txt2]: 0}) | |
709 | + th.setData({ [order_prom_txt1]: order_prom_id, [order_prom_txt2]: order_prom_amount }) | |
710 | + } else { | |
711 | + o_condition1 = ord_price; | |
712 | + th.setData({ [order_prom_txt1]: 0, [order_prom_txt2]: 0 }) | |
710 | 713 | } |
711 | - | |
712 | - o_condition1=parseFloat(o_condition1)-parseFloat(th.data.presell.presell_deposit); | |
713 | - if(o_condition1<0) o_condition1=0; | |
714 | - th.setData({ exp_price: 0, order_m: o_condition1 }) | |
714 | + | |
715 | + o_condition1 = parseFloat(o_condition1) - parseFloat(th.data.presell.presell_deposit); | |
716 | + if (o_condition1 < 0) o_condition1 = 0; | |
717 | + th.setData({ exp_price: 0, order_m: o_condition1 }) | |
715 | 718 | }) |
716 | - }else{ | |
717 | - o_condition=parseFloat(o_condition)-parseFloat(th.data.presell.presell_deposit); | |
718 | - if(o_condition<0) o_condition=0; | |
719 | + } else { | |
720 | + o_condition = parseFloat(o_condition) - parseFloat(th.data.presell.presell_deposit); | |
721 | + if (o_condition < 0) o_condition = 0; | |
719 | 722 | th.setData({ exp_price: 0, order_m: o_condition }) |
720 | 723 | } |
721 | 724 | } |
... | ... | @@ -725,14 +728,14 @@ Page({ |
725 | 728 | checkAddressList: function () { |
726 | 729 | var t = this; |
727 | 730 | return !(!this.data.order || null == this.data.order.userAddress) || (wx.showModal({ |
728 | - title: "请先填写或选择收货地址~", | |
729 | - success: function (a) { | |
730 | - a.confirm ? t.enterAddressPage() : wx.navigateBack(); | |
731 | - }, | |
732 | - fail: function () { | |
733 | - wx.navigateBack(); | |
734 | - } | |
735 | - }), !1); | |
731 | + title: "请先填写或选择收货地址~", | |
732 | + success: function (a) { | |
733 | + a.confirm ? t.enterAddressPage() : wx.navigateBack(); | |
734 | + }, | |
735 | + fail: function () { | |
736 | + wx.navigateBack(); | |
737 | + } | |
738 | + }), !1); | |
736 | 739 | }, |
737 | 740 | showInvoice: function () { |
738 | 741 | this.setData({ |
... | ... | @@ -752,7 +755,7 @@ Page({ |
752 | 755 | keyUpChangeNum: function (t) { |
753 | 756 | this.setData({ |
754 | 757 | maxWord: t.detail.value.length, |
755 | - user_note:t.detail.value | |
758 | + user_note: t.detail.value | |
756 | 759 | }); |
757 | 760 | }, |
758 | 761 | |
... | ... | @@ -781,7 +784,7 @@ Page({ |
781 | 784 | } |
782 | 785 | } |
783 | 786 | var set_txt = "cartlist[" + iter + "].can_num"; |
784 | - th.setData({[set_txt]: num}); | |
787 | + th.setData({ [set_txt]: num }); | |
785 | 788 | } |
786 | 789 | }, |
787 | 790 | useCoupon: function () { |
... | ... | @@ -798,7 +801,7 @@ Page({ |
798 | 801 | }); |
799 | 802 | }, |
800 | 803 | enterAddressPage: function () { |
801 | - if(!this.data.wait_wk) return false; | |
804 | + if (!this.data.wait_wk) return false; | |
802 | 805 | |
803 | 806 | getApp().globalData.is_cart_old = 1; |
804 | 807 | this.data.isget_by_quan = {}; |
... | ... | @@ -811,9 +814,9 @@ Page({ |
811 | 814 | setexptype: function (t) { |
812 | 815 | var th = this; |
813 | 816 | var ty = t.currentTarget.dataset.t, def_exp_code = getApp().globalData.userInfo.def_exp_code; |
814 | - th.setData({bn_exp_type: ty}); | |
817 | + th.setData({ bn_exp_type: ty }); | |
815 | 818 | if (ty == 0) { |
816 | - th.setData({is_all_zt: 0}); | |
819 | + th.setData({ is_all_zt: 0 }); | |
817 | 820 | } |
818 | 821 | |
819 | 822 | //当物流为空的时候。 |
... | ... | @@ -826,7 +829,7 @@ Page({ |
826 | 829 | if (ty == 1) { |
827 | 830 | th.data.isget_by_quan = {}; |
828 | 831 | if (th.data.using_quan[bn_pick] && th.data.using_quan[bn_pick].isby == 1) { |
829 | - th.setData({using_quan: {}}); | |
832 | + th.setData({ using_quan: {} }); | |
830 | 833 | } |
831 | 834 | } |
832 | 835 | |
... | ... | @@ -836,7 +839,7 @@ Page({ |
836 | 839 | if (wu_arr != null && wu_arr != "") { |
837 | 840 | for (var i = 0; i < wu_arr.length; i++) { |
838 | 841 | if (wu_arr[i].shipping_code == def_exp_code) { |
839 | - th.setData({index: i}); | |
842 | + th.setData({ index: i }); | |
840 | 843 | } |
841 | 844 | } |
842 | 845 | } |
... | ... | @@ -848,16 +851,16 @@ Page({ |
848 | 851 | //--------立即购买时,使用余额-------- |
849 | 852 | set_bn_useyuer: function () { |
850 | 853 | var th = this; |
851 | - th.setData({bn_use_money: !th.data.bn_use_money}); | |
854 | + th.setData({ bn_use_money: !th.data.bn_use_money }); | |
852 | 855 | th.calculatePrice2(); |
853 | 856 | }, |
854 | - //-------------------计算物流--------------- | |
855 | - calculatewuliu: function (code, o_shipping_price, goods_weight,out_of_weight, | |
856 | - goods_piece, user_addr, freight_free, o_price, rs) { | |
857 | + //-----------------计算物流------------- | |
858 | + calculatewuliu: function (code, o_shipping_price, goods_weight, out_of_weight, | |
859 | + goods_piece, user_addr, freight_free, o_price, rs, pickid) { | |
857 | 860 | var price = 0, th = this; |
858 | 861 | price += parseFloat(o_shipping_price); |
859 | 862 | //如果是包邮 |
860 | - if (freight_free > 0 && o_price >= freight_free && out_of_weight>=0) { | |
863 | + if (freight_free > 0 && o_price >= freight_free && out_of_weight >= 0) { | |
861 | 864 | return 0; |
862 | 865 | } |
863 | 866 | if (user_addr == null) { |
... | ... | @@ -884,7 +887,7 @@ Page({ |
884 | 887 | } |
885 | 888 | } |
886 | 889 | //------超出重量---------- |
887 | - if(out_of_weight < 0 && o_price >= freight_free){ | |
890 | + if (out_of_weight < 0 && o_price >= freight_free && !th.data.is_no_by[pickid]) { | |
888 | 891 | fw_price = parseFloat(item['money']); |
889 | 892 | var out_of_weight = Math.abs(out_of_weight); |
890 | 893 | if (out_of_weight > item['first_weight']) { |
... | ... | @@ -930,7 +933,7 @@ Page({ |
930 | 933 | //----------立即购买,选择物流------------- |
931 | 934 | bindPickerChange: function (e) { |
932 | 935 | var ind = e.detail.value |
933 | - this.setData({index: ind}); | |
936 | + this.setData({ index: ind }); | |
934 | 937 | this.calculatePrice2(); |
935 | 938 | }, |
936 | 939 | /*----券的所有操作----*/ |
... | ... | @@ -943,7 +946,7 @@ Page({ |
943 | 946 | |
944 | 947 | |
945 | 948 | if (bn == 1) { |
946 | - th.setData({open_quan: 1, selected_quan_pick: pickid, disabled: 1}); | |
949 | + th.setData({ open_quan: 1, selected_quan_pick: pickid, disabled: 1 }); | |
947 | 950 | } else { |
948 | 951 | //---多单打开券的时候,就要判断券在其他门店是否有使用--- |
949 | 952 | var quanlist = th.data.cartlist[cindx].quan_list; |
... | ... | @@ -969,9 +972,9 @@ Page({ |
969 | 972 | else |
970 | 973 | get_by_quan_list_cart[i].show_red = 0; |
971 | 974 | } |
972 | - th.setData({by_quan_list_cart: get_by_quan_list_cart}); | |
975 | + th.setData({ by_quan_list_cart: get_by_quan_list_cart }); | |
973 | 976 | } else { |
974 | - th.setData({by_quan_list_cart: null}); | |
977 | + th.setData({ by_quan_list_cart: null }); | |
975 | 978 | } |
976 | 979 | |
977 | 980 | th.setData({ |
... | ... | @@ -986,7 +989,7 @@ Page({ |
986 | 989 | }, |
987 | 990 | close_coupon: function (e) { |
988 | 991 | var th = this; |
989 | - th.setData({open_quan: 0, disabled: 0}); | |
992 | + th.setData({ open_quan: 0, disabled: 0 }); | |
990 | 993 | }, |
991 | 994 | |
992 | 995 | //---判断券时候在已经选择的列表中--- |
... | ... | @@ -1016,14 +1019,14 @@ Page({ |
1016 | 1019 | for (var i in quanlist) { |
1017 | 1020 | quanlist[i].show_red = 0; |
1018 | 1021 | } |
1019 | - this.setData({selected_quan_list: quanlist}); | |
1022 | + this.setData({ selected_quan_list: quanlist }); | |
1020 | 1023 | var by_quanlist = this.data.get_by_quan_list; |
1021 | 1024 | if (by_quanlist) { |
1022 | 1025 | //---所有的券的显示红色选择都清理一遍--- |
1023 | 1026 | for (var inb in by_quanlist) { |
1024 | 1027 | by_quanlist[inb].show_red = 0; |
1025 | 1028 | } |
1026 | - this.setData({get_by_quan_list: by_quanlist}); | |
1029 | + this.setData({ get_by_quan_list: by_quanlist }); | |
1027 | 1030 | } |
1028 | 1031 | |
1029 | 1032 | var by_cart_list = this.data.by_quan_list_cart; |
... | ... | @@ -1032,7 +1035,7 @@ Page({ |
1032 | 1035 | for (var inc in by_cart_list) { |
1033 | 1036 | by_cart_list[inc].show_red = 0; |
1034 | 1037 | } |
1035 | - this.setData({by_quan_list_cart: by_cart_list}); | |
1038 | + this.setData({ by_quan_list_cart: by_cart_list }); | |
1036 | 1039 | } |
1037 | 1040 | |
1038 | 1041 | var using_quan = this.data.using_quan; |
... | ... | @@ -1043,9 +1046,9 @@ Page({ |
1043 | 1046 | using_quan[pickid].is_nouse_red = 1; |
1044 | 1047 | } |
1045 | 1048 | else { |
1046 | - using_quan[pickid] = {is_nouse_red: 1}; | |
1049 | + using_quan[pickid] = { is_nouse_red: 1 }; | |
1047 | 1050 | } |
1048 | - this.setData({using_quan: using_quan, is_coupon: 2222}); | |
1051 | + this.setData({ using_quan: using_quan, is_coupon: 2222 }); | |
1049 | 1052 | return; |
1050 | 1053 | } |
1051 | 1054 | |
... | ... | @@ -1062,9 +1065,9 @@ Page({ |
1062 | 1065 | using_quan[pickid].is_nouse_red = 0; |
1063 | 1066 | } |
1064 | 1067 | else { |
1065 | - using_quan[pickid] = {is_nouse_red: 0}; | |
1068 | + using_quan[pickid] = { is_nouse_red: 0 }; | |
1066 | 1069 | } |
1067 | - this.setData({using_quan: using_quan}); | |
1070 | + this.setData({ using_quan: using_quan }); | |
1068 | 1071 | |
1069 | 1072 | }, |
1070 | 1073 | /*----- 点击选择包邮券 -----*/ |
... | ... | @@ -1077,7 +1080,7 @@ Page({ |
1077 | 1080 | for (var ind in by_quanlist) { |
1078 | 1081 | by_quanlist[ind].show_red = 0; |
1079 | 1082 | } |
1080 | - this.setData({get_by_quan_list: by_quanlist}); | |
1083 | + this.setData({ get_by_quan_list: by_quanlist }); | |
1081 | 1084 | } |
1082 | 1085 | |
1083 | 1086 | //--购物车过来的包邮券-- |
... | ... | @@ -1087,7 +1090,7 @@ Page({ |
1087 | 1090 | for (var ind in by_cart_list) { |
1088 | 1091 | by_cart_list[ind].show_red = 0; |
1089 | 1092 | } |
1090 | - this.setData({by_quan_list_cart: by_cart_list}); | |
1093 | + this.setData({ by_quan_list_cart: by_cart_list }); | |
1091 | 1094 | } |
1092 | 1095 | //普通券 |
1093 | 1096 | var quanlist = this.data.selected_quan_list; |
... | ... | @@ -1096,7 +1099,7 @@ Page({ |
1096 | 1099 | for (var ind in quanlist) { |
1097 | 1100 | quanlist[ind].show_red = 0; |
1098 | 1101 | } |
1099 | - this.setData({selected_quan_list: quanlist}); | |
1102 | + this.setData({ selected_quan_list: quanlist }); | |
1100 | 1103 | } |
1101 | 1104 | |
1102 | 1105 | var th = this; |
... | ... | @@ -1107,9 +1110,9 @@ Page({ |
1107 | 1110 | using_quan[th.data.selected_quan_pick].is_nouse_red = 1; |
1108 | 1111 | } |
1109 | 1112 | else { |
1110 | - using_quan[th.data.selected_quan_pick] = {is_nouse_red: 1}; | |
1113 | + using_quan[th.data.selected_quan_pick] = { is_nouse_red: 1 }; | |
1111 | 1114 | } |
1112 | - this.setData({using_quan: using_quan, is_coupon: 2222}); | |
1115 | + this.setData({ using_quan: using_quan, is_coupon: 2222 }); | |
1113 | 1116 | return; |
1114 | 1117 | } |
1115 | 1118 | |
... | ... | @@ -1120,20 +1123,20 @@ Page({ |
1120 | 1123 | var txt1 = ""; |
1121 | 1124 | var quan_item = null; |
1122 | 1125 | |
1123 | - quan_item = this.data.get_by_quan_list[ind]; | |
1124 | - txt = "get_by_quan_list[" + ind + "].show_red"; | |
1125 | - var obj = {}; | |
1126 | - obj[txt] = 1; | |
1127 | - this.setData(obj); | |
1126 | + quan_item = this.data.get_by_quan_list[ind]; | |
1127 | + txt = "get_by_quan_list[" + ind + "].show_red"; | |
1128 | + var obj = {}; | |
1129 | + obj[txt] = 1; | |
1130 | + this.setData(obj); | |
1128 | 1131 | |
1129 | 1132 | |
1130 | 1133 | if (using_quan[th.data.selected_quan_pick]) { |
1131 | 1134 | using_quan[th.data.selected_quan_pick].is_nouse_red = 0; |
1132 | 1135 | } |
1133 | 1136 | else { |
1134 | - using_quan[th.data.selected_quan_pick] = {is_nouse_red: 0}; | |
1137 | + using_quan[th.data.selected_quan_pick] = { is_nouse_red: 0 }; | |
1135 | 1138 | } |
1136 | - this.setData({using_quan: using_quan}); | |
1139 | + this.setData({ using_quan: using_quan }); | |
1137 | 1140 | }, |
1138 | 1141 | //--确认使用券--- |
1139 | 1142 | confirm_quan: function () { |
... | ... | @@ -1190,10 +1193,10 @@ Page({ |
1190 | 1193 | //选择了的券,看是不是点击了不使用券,点击了不使用优惠券 |
1191 | 1194 | if (using_quan[pickid]) { |
1192 | 1195 | if (using_quan[pickid].is_nouse_red == 1) { |
1193 | - using_quan[pickid] = {is_nouse_red: 1}; | |
1196 | + using_quan[pickid] = { is_nouse_red: 1 }; | |
1194 | 1197 | th.calculatePrice2(); |
1195 | - th.setData({open_quan: 0}); | |
1196 | - th.setData({using_quan: using_quan}); | |
1198 | + th.setData({ open_quan: 0 }); | |
1199 | + th.setData({ using_quan: using_quan }); | |
1197 | 1200 | } |
1198 | 1201 | } |
1199 | 1202 | |
... | ... | @@ -1214,12 +1217,12 @@ Page({ |
1214 | 1217 | }; |
1215 | 1218 | using_quan[pickid].isby = 1; |
1216 | 1219 | } else { |
1217 | - using_quan[pickid] = {coupon_no: item.CashRepNo, money: item.Sum, is_nouse_red: 0}; | |
1220 | + using_quan[pickid] = { coupon_no: item.CashRepNo, money: item.Sum, is_nouse_red: 0 }; | |
1218 | 1221 | using_quan[pickid].isby = 0; |
1219 | 1222 | } |
1220 | - this.setData({using_quan: using_quan}); | |
1223 | + this.setData({ using_quan: using_quan }); | |
1221 | 1224 | th.calculatePrice2(); |
1222 | - th.setData({open_quan: 0}); | |
1225 | + th.setData({ open_quan: 0 }); | |
1223 | 1226 | }, |
1224 | 1227 | |
1225 | 1228 | cart_set_err: function (e) { |
... | ... | @@ -1256,7 +1259,7 @@ Page({ |
1256 | 1259 | var wu_arr_txt = e.currentTarget.dataset.txt; |
1257 | 1260 | var w_sele_index = e.currentTarget.dataset.w_sele_index; |
1258 | 1261 | var is_express = null; |
1259 | - var ob = {open_express: 1, wu_arr_txt: wu_arr_txt, disabled: 1}; | |
1262 | + var ob = { open_express: 1, wu_arr_txt: wu_arr_txt, disabled: 1 }; | |
1260 | 1263 | |
1261 | 1264 | //--如果是多个门店的时候-- |
1262 | 1265 | if (w_sele_index != undefined) { |
... | ... | @@ -1267,21 +1270,21 @@ Page({ |
1267 | 1270 | }, |
1268 | 1271 | // 关闭物流的弹窗 |
1269 | 1272 | close_express: function () { |
1270 | - this.setData({open_express: 0, disabled: 0}); | |
1273 | + this.setData({ open_express: 0, disabled: 0 }); | |
1271 | 1274 | }, |
1272 | 1275 | // 选择物流 |
1273 | 1276 | click_express_name: function (e) { |
1274 | 1277 | var express_name = e.currentTarget.dataset.name, shippingcode = e.currentTarget.dataset.shippingcode; |
1275 | 1278 | var index = e.currentTarget.dataset.idxe; |
1276 | - var ob = {is_express: index, is_shipping_code: shippingcode, disabled: 0}; | |
1279 | + var ob = { is_express: index, is_shipping_code: shippingcode, disabled: 0 }; | |
1277 | 1280 | ob[this.data.wu_arr_txt] = index; |
1278 | 1281 | this.setData(ob); |
1279 | 1282 | }, |
1280 | 1283 | |
1281 | 1284 | //点击确定物流 |
1282 | 1285 | determine_expres: function (e) { |
1283 | - this.setData({open_express: 0}); | |
1284 | - this.calculatePrice2(); | |
1286 | + this.setData({ open_express: 0 }); | |
1287 | + this.calculatePrice2(); | |
1285 | 1288 | }, |
1286 | 1289 | |
1287 | 1290 | //点击打开优惠券使用说明 |
... | ... | @@ -1297,7 +1300,7 @@ Page({ |
1297 | 1300 | obj[txt] = is_open; |
1298 | 1301 | |
1299 | 1302 | this.setData(obj); |
1300 | - this.setData({disabled: 1}) | |
1303 | + this.setData({ disabled: 1 }) | |
1301 | 1304 | }, |
1302 | 1305 | |
1303 | 1306 | clik_coupons2: function (e) { |
... | ... | @@ -1312,7 +1315,7 @@ Page({ |
1312 | 1315 | obj[txt] = is_open; |
1313 | 1316 | |
1314 | 1317 | this.setData(obj); |
1315 | - this.setData({disabled: 1}) | |
1318 | + this.setData({ disabled: 1 }) | |
1316 | 1319 | }, |
1317 | 1320 | |
1318 | 1321 | |
... | ... | @@ -1321,11 +1324,11 @@ Page({ |
1321 | 1324 | var th = this; |
1322 | 1325 | var is_shipping_code = this.data.is_shipping_code |
1323 | 1326 | getApp().request.put("/api/weshop/users/update", { |
1324 | - data: {user_id: getApp().globalData.user_id, store_id: oo.stoid, def_exp_code: is_shipping_code}, | |
1327 | + data: { user_id: getApp().globalData.user_id, store_id: oo.stoid, def_exp_code: is_shipping_code }, | |
1325 | 1328 | success: function (rse) { |
1326 | 1329 | if (rse.data.code == 0) { |
1327 | 1330 | getApp().globalData.userInfo.def_exp_code = is_shipping_code; |
1328 | - th.setData({open_express: 0}); | |
1331 | + th.setData({ open_express: 0 }); | |
1329 | 1332 | //----计算此时购物车的价格---- |
1330 | 1333 | th.calculatePrice2(); |
1331 | 1334 | |
... | ... | @@ -1335,7 +1338,7 @@ Page({ |
1335 | 1338 | }, |
1336 | 1339 | |
1337 | 1340 | //更新下默认,在onshow里面 |
1338 | - update_code(){ | |
1341 | + update_code() { | |
1339 | 1342 | var th = this, m_wind = 0, def_exp_code = getApp().globalData.userInfo.def_exp_code; |
1340 | 1343 | //--定时器,判断wu_arr不未空-- |
1341 | 1344 | var uii = setInterval(function () { |
... | ... | @@ -1349,7 +1352,7 @@ Page({ |
1349 | 1352 | } |
1350 | 1353 | //--如果是立即购买-- |
1351 | 1354 | if (th.data.is_b_now == 1) { |
1352 | - th.setData({index: m_wind, is_express: m_wind}); | |
1355 | + th.setData({ index: m_wind, is_express: m_wind }); | |
1353 | 1356 | } else { |
1354 | 1357 | var ui = setInterval(function () { |
1355 | 1358 | if (th.data.cartlist) { |
... | ... | @@ -1357,7 +1360,7 @@ Page({ |
1357 | 1360 | for (var i in c_arr) { |
1358 | 1361 | c_arr[i].wind = m_wind; |
1359 | 1362 | } |
1360 | - th.setData({cartlist: c_arr, is_express: m_wind}) | |
1363 | + th.setData({ cartlist: c_arr, is_express: m_wind }) | |
1361 | 1364 | clearInterval(ui); |
1362 | 1365 | } |
1363 | 1366 | }, 500) |
... | ... | @@ -1458,10 +1461,10 @@ Page({ |
1458 | 1461 | if (th.data.is_b_now) { |
1459 | 1462 | if (arr && arr.length > 0) { |
1460 | 1463 | var quanlist = arr[0].quan_list; |
1461 | - th.setData({selected_quan_list: quanlist, cartlist: arr}) | |
1464 | + th.setData({ selected_quan_list: quanlist, cartlist: arr }) | |
1462 | 1465 | } |
1463 | 1466 | } else { |
1464 | - th.setData({cartlist: arr}) | |
1467 | + th.setData({ cartlist: arr }) | |
1465 | 1468 | th.set_can_num(); |
1466 | 1469 | } |
1467 | 1470 | }, |
... | ... | @@ -1469,14 +1472,14 @@ Page({ |
1469 | 1472 | //------ 获取立即购买的购物车的劵 -------- |
1470 | 1473 | get_buy_now_quan: function () { |
1471 | 1474 | var quanlist = null, th = this, frozenQuan = null; |
1472 | - var allprice =this.data.pre_arr.presell_price*this.data.order_goods.goods_num; | |
1475 | + var allprice = this.data.pre_arr.presell_price * this.data.order_goods.goods_num; | |
1473 | 1476 | th.data.ckeck_quan_price = allprice; |
1474 | 1477 | |
1475 | 1478 | //--如果商家后台没有限制使用优惠券,同时商品的优惠活动没有限制使用优惠券-- |
1476 | 1479 | if (th.data.is_close_quan != 1) { |
1477 | 1480 | var url0 = "/api/weshop/users/frozenQuan/listFrozenQuan/" + app.globalData.user_id; |
1478 | 1481 | var url = "/api/weshop/couponList/getUseCouponList"; |
1479 | - app.request.promiseGet(url0, {1: 1}).then(res => { | |
1482 | + app.request.promiseGet(url0, { 1: 1 }).then(res => { | |
1480 | 1483 | if (res.data.code == 0) { |
1481 | 1484 | frozenQuan = res.data.data; |
1482 | 1485 | th.data.frozenQuan = frozenQuan; |
... | ... | @@ -1494,7 +1497,7 @@ Page({ |
1494 | 1497 | quanlist = res.data.data.pageData; |
1495 | 1498 | if (quanlist) { |
1496 | 1499 | quanlist = th.check_is_frozenQuan(quanlist, frozenQuan); |
1497 | - th.setData({selected_quan_list: quanlist}) | |
1500 | + th.setData({ selected_quan_list: quanlist }) | |
1498 | 1501 | } |
1499 | 1502 | } |
1500 | 1503 | } |
... | ... | @@ -1522,7 +1525,7 @@ Page({ |
1522 | 1525 | if (!goods_id) goods_id = this.data.bn_goods.goods_id; |
1523 | 1526 | for (var i in arr) { |
1524 | 1527 | var item = arr[i]; |
1525 | - if (goods_id == item) return 0; | |
1528 | + if (goods_id == item) return 0; | |
1526 | 1529 | } |
1527 | 1530 | return 1; |
1528 | 1531 | }, |
... | ... | @@ -1544,14 +1547,14 @@ Page({ |
1544 | 1547 | pick = this.data.pickup.pickup_id; |
1545 | 1548 | //---获取订单优惠--- |
1546 | 1549 | getApp().request.promiseGet("/api/weshop/promorder/getOrderPromotion", { |
1547 | - data: {store_id: os.stoid, orderAmount: condition} | |
1550 | + data: { store_id: os.stoid, orderAmount: condition } | |
1548 | 1551 | }).then(res => { |
1549 | 1552 | if (res.data.code == 0) { |
1550 | 1553 | var data = res.data.data; |
1551 | 1554 | th.data.order_prom[pick] = data; |
1552 | - }else{ | |
1553 | - th.data.order_prom[pick] = null; | |
1554 | - } | |
1555 | + } else { | |
1556 | + th.data.order_prom[pick] = null; | |
1557 | + } | |
1555 | 1558 | func(condition); |
1556 | 1559 | }) |
1557 | 1560 | }, |
... | ... | @@ -1568,7 +1571,7 @@ Page({ |
1568 | 1571 | var ob = map[pickid][item.prom_id]; |
1569 | 1572 | ob.price += item.goods_price * item.goods_num; |
1570 | 1573 | ob.goods_num += item.goods_num; |
1571 | - ob.goods.push({goods_id: item.goods_id, goods_price: item.goods_price, goods_num: item.goods_num}); | |
1574 | + ob.goods.push({ goods_id: item.goods_id, goods_price: item.goods_price, goods_num: item.goods_num }); | |
1572 | 1575 | |
1573 | 1576 | } else { |
1574 | 1577 | var prom = null; |
... | ... | @@ -1584,7 +1587,7 @@ Page({ |
1584 | 1587 | ob.is_bz = prom.is_bz; |
1585 | 1588 | ob.is_xz_yh = prom.is_xz_yh; |
1586 | 1589 | ob.goods = new Array(); |
1587 | - ob.goods.push({goods_id: item.goods_id, goods_price: item.goods_price, goods_num: item.goods_num}); | |
1590 | + ob.goods.push({ goods_id: item.goods_id, goods_price: item.goods_price, goods_num: item.goods_num }); | |
1588 | 1591 | map[pickid][item.prom_id] = ob; |
1589 | 1592 | } |
1590 | 1593 | } else { |
... | ... | @@ -1601,7 +1604,7 @@ Page({ |
1601 | 1604 | ob.is_bz = prom.is_bz; |
1602 | 1605 | ob.is_xz_yh = prom.is_xz_yh; |
1603 | 1606 | ob.goods = new Array(); |
1604 | - ob.goods.push({goods_id: item.goods_id, goods_price: item.goods_price, goods_num: item.goods_num}); | |
1607 | + ob.goods.push({ goods_id: item.goods_id, goods_price: item.goods_price, goods_num: item.goods_num }); | |
1605 | 1608 | |
1606 | 1609 | var obj = {}; |
1607 | 1610 | obj[item.prom_id] = ob; |
... | ... | @@ -1645,7 +1648,7 @@ Page({ |
1645 | 1648 | if (no_by_data && no_by_data.region_list) { |
1646 | 1649 | if (th.check_by_area(no_by_data.region_list)) { |
1647 | 1650 | gift_freight_free = 0; |
1648 | - out_of_weight=0; | |
1651 | + out_of_weight = 0; | |
1649 | 1652 | th.data.is_no_by[bn_pick] = 1; |
1650 | 1653 | } |
1651 | 1654 | } |
... | ... | @@ -1653,13 +1656,14 @@ Page({ |
1653 | 1656 | if (no_by_data && no_by_data.goods_list && gift_freight_free) { |
1654 | 1657 | if (th.check_by_goods(no_by_data.goods_list, good.goods_id)) { |
1655 | 1658 | gift_freight_free = 0; |
1656 | - out_of_weight=0; | |
1659 | + out_of_weight = 0; | |
1660 | + th.data.is_no_by[bn_pick] = 1; | |
1657 | 1661 | } |
1658 | 1662 | } |
1659 | 1663 | |
1660 | 1664 | var t_shipping_price = |
1661 | - this.calculatewuliu(code, gift_shipping_price, goods_weight,out_of_weight, | |
1662 | - goods_piece, user_addr, gift_freight_free, allpice, rs); | |
1665 | + this.calculatewuliu(code, gift_shipping_price, goods_weight, out_of_weight, | |
1666 | + goods_piece, user_addr, gift_freight_free, allpice, rs,th.data.bn_pick); | |
1663 | 1667 | return t_shipping_price; |
1664 | 1668 | |
1665 | 1669 | }, |
... | ... | @@ -1719,13 +1723,13 @@ Page({ |
1719 | 1723 | goods_weight = -1, |
1720 | 1724 | goods_piece = -1, |
1721 | 1725 | good = th.data.goods, |
1722 | - quan_price=0, | |
1723 | - exp_price=0; | |
1726 | + quan_price = 0, | |
1727 | + exp_price = 0; | |
1724 | 1728 | |
1725 | 1729 | var quan_no = null; |
1726 | - var bn_pick=th.data.pickup.pickup_id; | |
1727 | - var allpice =th.data.all_price; | |
1728 | - var out_of_weight=null; //超出多少重量 | |
1730 | + var bn_pick = th.data.pickup.pickup_id; | |
1731 | + var allpice = th.data.all_price; | |
1732 | + var out_of_weight = null; //超出多少重量 | |
1729 | 1733 | var freight_free = ee.freight_free; //全场满多少包邮 |
1730 | 1734 | var weight_free = ee.weight_free; //多少kg内包邮 |
1731 | 1735 | |
... | ... | @@ -1749,19 +1753,19 @@ Page({ |
1749 | 1753 | }) |
1750 | 1754 | |
1751 | 1755 | if (quan_price > 0) { |
1752 | - if (quan_price < th.data.tail_pay) th.setData({quan_price: quan_price}) | |
1756 | + if (quan_price < th.data.tail_pay) th.setData({ quan_price: quan_price }) | |
1753 | 1757 | else { |
1754 | - th.setData({quan_price: th.data.tail_pay}) | |
1758 | + th.setData({ quan_price: th.data.tail_pay }) | |
1755 | 1759 | quan_price = th.data.tail_pay; |
1756 | 1760 | } |
1757 | 1761 | } else { |
1758 | - th.setData({quan_price: 0}) | |
1762 | + th.setData({ quan_price: 0 }) | |
1759 | 1763 | } |
1760 | - }else{ | |
1761 | - th.setData({quan_price: 0}) | |
1764 | + } else { | |
1765 | + th.setData({ quan_price: 0 }) | |
1762 | 1766 | } |
1763 | - }else{ | |
1764 | - th.setData({quan_price: 0}) | |
1767 | + } else { | |
1768 | + th.setData({ quan_price: 0 }) | |
1765 | 1769 | } |
1766 | 1770 | |
1767 | 1771 | //-----------当地址不为空,且是物流时,计算物流费用---------- |
... | ... | @@ -1790,15 +1794,15 @@ Page({ |
1790 | 1794 | arr.push(item); |
1791 | 1795 | } |
1792 | 1796 | if (arr) { |
1793 | - th.setData({get_by_quan_list: arr}); | |
1797 | + th.setData({ get_by_quan_list: arr }); | |
1794 | 1798 | } |
1795 | 1799 | th.data.isget_by_quan[bn_pick] = 1; |
1796 | 1800 | } |
1797 | 1801 | }) |
1798 | 1802 | } |
1799 | 1803 | if (quan_no && th.data.using_quan[bn_pick].isby == 1) { |
1800 | - exp_price=0; | |
1801 | - }else{ | |
1804 | + exp_price = 0; | |
1805 | + } else { | |
1802 | 1806 | switch (good['exp_sum_type']) { |
1803 | 1807 | case 1: |
1804 | 1808 | //统一运费 |
... | ... | @@ -1808,8 +1812,8 @@ Page({ |
1808 | 1812 | if (goods_weight < 0) goods_weight = 0; |
1809 | 1813 | //累积商品重量 每种商品的重量 * 数量 |
1810 | 1814 | goods_weight += good['weight'] * th.data.order.order_goods['goods_num']; |
1811 | - if(weight_free > 0){ | |
1812 | - out_of_weight = (weight_free * 1000 ) - goods_weight; | |
1815 | + if (weight_free > 0) { | |
1816 | + out_of_weight = (weight_free * 1000) - goods_weight; | |
1813 | 1817 | } |
1814 | 1818 | break; |
1815 | 1819 | case 3: |
... | ... | @@ -1821,33 +1825,33 @@ Page({ |
1821 | 1825 | |
1822 | 1826 | var code = th.data.wu_arr[th.data.index].code; |
1823 | 1827 | var shipping_price = |
1824 | - th.calculatewuliu(code, o_shipping_price, goods_weight,out_of_weight, | |
1828 | + th.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, | |
1825 | 1829 | goods_piece, th.data.user_addr, freight_free, allpice, rs); |
1826 | 1830 | exp_price = parseFloat(shipping_price).toFixed(2); |
1827 | 1831 | } |
1828 | - th.wuliu_next(allpice,quan_price,exp_price); | |
1832 | + th.wuliu_next(allpice, quan_price, exp_price); | |
1829 | 1833 | } else { |
1830 | - th.wuliu_next(allpice,quan_price,exp_price); | |
1834 | + th.wuliu_next(allpice, quan_price, exp_price); | |
1831 | 1835 | } |
1832 | 1836 | }); |
1833 | 1837 | }); |
1834 | 1838 | }, |
1835 | 1839 | //相同的东西统一在一起 |
1836 | - wuliu_next( allpice,quan_price,exp_price){ | |
1837 | - var th=this; | |
1838 | - var o_condition =parseFloat(allpice)-parseFloat(quan_price); | |
1839 | - if(o_condition<0) o_condition=0; | |
1840 | + wuliu_next(allpice, quan_price, exp_price) { | |
1841 | + var th = this; | |
1842 | + var o_condition = parseFloat(allpice) - parseFloat(quan_price); | |
1843 | + if (o_condition < 0) o_condition = 0; | |
1840 | 1844 | //如果同意参与订单优惠 |
1841 | 1845 | if (o_condition > 0 && this.data.pre_arr.is_useorderyh) { |
1842 | 1846 | th.check_is_order_prom(o_condition, function (ord_price) { |
1843 | - var bn_pick=th.data.pickup.pickup_id | |
1847 | + var bn_pick = th.data.pickup.pickup_id | |
1844 | 1848 | var order_prom_amount = 0; |
1845 | 1849 | var order_prom_id = 0; |
1846 | - var order_m=0; | |
1850 | + var order_m = 0; | |
1847 | 1851 | if (th.data.order_prom[bn_pick]) { |
1848 | 1852 | var ord_prom = th.data.order_prom[bn_pick]; |
1849 | 1853 | //么有使用券,或者活动没有限制使用优惠券 |
1850 | - if(quan_price<=0 || !ord_prom.is_xz_yh) { | |
1854 | + if (quan_price <= 0 || !ord_prom.is_xz_yh) { | |
1851 | 1855 | order_prom_id = ord_prom['id']; |
1852 | 1856 | switch (ord_prom['type']) { |
1853 | 1857 | case 0: |
... | ... | @@ -1867,37 +1871,37 @@ Page({ |
1867 | 1871 | if (order_prom_id > 0) { |
1868 | 1872 | var order_prom_txt1 = "order_prom_id"; |
1869 | 1873 | var order_prom_txt2 = "order_prom_amount"; |
1870 | - th.setData({[order_prom_txt1]: order_prom_id, [order_prom_txt2]: order_prom_amount}) | |
1871 | - }else{ | |
1872 | - var order_prom_txt1 = "order_prom_id"; | |
1873 | - var order_prom_txt2 = "order_prom_amount"; | |
1874 | - th.setData({[order_prom_txt1]: 0, [order_prom_txt2]: 0}) | |
1875 | - } | |
1876 | - | |
1877 | - | |
1878 | - ord_price=parseFloat(ord_price)-parseFloat(th.data.presell.presell_deposit); | |
1879 | - if(ord_price<0) ord_price=0; | |
1880 | - th.setData({ exp_price: exp_price, order_m: ord_price +parseFloat(exp_price) }) | |
1874 | + th.setData({ [order_prom_txt1]: order_prom_id, [order_prom_txt2]: order_prom_amount }) | |
1875 | + } else { | |
1876 | + var order_prom_txt1 = "order_prom_id"; | |
1877 | + var order_prom_txt2 = "order_prom_amount"; | |
1878 | + th.setData({ [order_prom_txt1]: 0, [order_prom_txt2]: 0 }) | |
1879 | + } | |
1880 | + | |
1881 | + | |
1882 | + ord_price = parseFloat(ord_price) - parseFloat(th.data.presell.presell_deposit); | |
1883 | + if (ord_price < 0) ord_price = 0; | |
1884 | + th.setData({ exp_price: exp_price, order_m: ord_price + parseFloat(exp_price) }) | |
1881 | 1885 | |
1882 | 1886 | }) |
1883 | - }else{ | |
1884 | - | |
1885 | - var o_condition1=parseFloat(o_condition)-parseFloat(th.data.presell.presell_deposit); | |
1886 | - if(o_condition1<0) o_condition1=0; | |
1887 | - th.setData({ exp_price: exp_price, order_m: parseFloat(o_condition1)+parseFloat(exp_price) }) | |
1887 | + } else { | |
1888 | + | |
1889 | + var o_condition1 = parseFloat(o_condition) - parseFloat(th.data.presell.presell_deposit); | |
1890 | + if (o_condition1 < 0) o_condition1 = 0; | |
1891 | + th.setData({ exp_price: exp_price, order_m: parseFloat(o_condition1) + parseFloat(exp_price) }) | |
1888 | 1892 | } |
1889 | 1893 | }, |
1890 | 1894 | |
1891 | 1895 | //-- 获取时间差 -- |
1892 | - get_diff(){ | |
1896 | + get_diff() { | |
1893 | 1897 | |
1894 | 1898 | switch (this.data.act.presell_type) { |
1895 | 1899 | //部分定金 |
1896 | 1900 | case 0: |
1897 | 1901 | if (this.data.act.pay_begindate > ut.gettimestamp()) { |
1898 | - this.setData({no_start: 1}) | |
1902 | + this.setData({ no_start: 1 }) | |
1899 | 1903 | } else if (this.data.act.pay_enddate < ut.gettimestamp()) { |
1900 | - this.setData({is_end: 1}) | |
1904 | + this.setData({ is_end: 1 }) | |
1901 | 1905 | } else { |
1902 | 1906 | var end_time = this.data.act.pay_enddate; |
1903 | 1907 | var e_str = ut.formatTime(end_time); |
... | ... | @@ -1908,15 +1912,15 @@ Page({ |
1908 | 1912 | var hours = parseInt(difftime / 3600) - 24 * days; // 小时 60*60 总小时数-过去的小时数=现在的小时数 |
1909 | 1913 | var minutes = parseInt(difftime % 3600 / 60); // 分钟 -(day*24) 以60秒为一整份 取余 剩下秒数 秒数/60 就是分钟数 |
1910 | 1914 | var seconds = parseInt(difftime % 60); // 以60秒为一整份 取余 剩下秒数 |
1911 | - this.setData({days: days, hours: hours, minutes: minutes, seconds: seconds}) | |
1915 | + this.setData({ days: days, hours: hours, minutes: minutes, seconds: seconds }) | |
1912 | 1916 | } |
1913 | 1917 | break; |
1914 | 1918 | //全额付款 |
1915 | 1919 | case 1: |
1916 | 1920 | if (this.data.act.start_time > ut.gettimestamp()) { |
1917 | - this.setData({no_start: 1}) | |
1921 | + this.setData({ no_start: 1 }) | |
1918 | 1922 | } else if (this.data.act.end_time < ut.gettimestamp()) { |
1919 | - this.setData({is_end: 1}) | |
1923 | + this.setData({ is_end: 1 }) | |
1920 | 1924 | } else { |
1921 | 1925 | var end_time = this.data.act.end_time; |
1922 | 1926 | var e_str = ut.formatTime(end_time); |
... | ... | @@ -1927,7 +1931,7 @@ Page({ |
1927 | 1931 | var hours = parseInt(difftime / 3600) - 24 * days; // 小时 60*60 总小时数-过去的小时数=现在的小时数 |
1928 | 1932 | var minutes = parseInt(difftime % 3600 / 60); // 分钟 -(day*24) 以60秒为一整份 取余 剩下秒数 秒数/60 就是分钟数 |
1929 | 1933 | var seconds = parseInt(difftime % 60); // 以60秒为一整份 取余 剩下秒数 |
1930 | - this.setData({days: days, hours: hours, minutes: minutes, seconds: seconds}) | |
1934 | + this.setData({ days: days, hours: hours, minutes: minutes, seconds: seconds }) | |
1931 | 1935 | } |
1932 | 1936 | break; |
1933 | 1937 | |
... | ... | @@ -1938,16 +1942,16 @@ Page({ |
1938 | 1942 | //显示支付选择 |
1939 | 1943 | show_pay: function () { |
1940 | 1944 | //不用钱直接支付 |
1941 | - if(this.data.order_m<=0){ | |
1945 | + if (this.data.order_m <= 0) { | |
1942 | 1946 | this.to_pay_type(1); |
1943 | - }else{ | |
1944 | - this.setData({show_pay_type: 1}); | |
1947 | + } else { | |
1948 | + this.setData({ show_pay_type: 1 }); | |
1945 | 1949 | } |
1946 | 1950 | |
1947 | 1951 | }, |
1948 | 1952 | //关闭支付 |
1949 | 1953 | close_show_pay: function () { |
1950 | - this.setData({show_pay_type: 0}); | |
1954 | + this.setData({ show_pay_type: 0 }); | |
1951 | 1955 | }, |
1952 | 1956 | //--弹起支付框-- |
1953 | 1957 | to_pay() { |
... | ... | @@ -1956,7 +1960,7 @@ Page({ |
1956 | 1960 | return getApp().my_warnning("请选择收货地址", 0, this); |
1957 | 1961 | } |
1958 | 1962 | |
1959 | - this.setData({show_pay_type: 1}); | |
1963 | + this.setData({ show_pay_type: 1 }); | |
1960 | 1964 | }, |
1961 | 1965 | |
1962 | 1966 | //选择支付方式 |
... | ... | @@ -1992,26 +1996,26 @@ Page({ |
1992 | 1996 | dd.addressid = th.data.user_addr.address_id; |
1993 | 1997 | } |
1994 | 1998 | |
1995 | - if(th.data.order_prom_amount>0){ | |
1996 | - var e={ | |
1997 | - order_prom_id:th.data.order_prom_id, | |
1998 | - order_prom_amount:th.data.order_prom_amount, | |
1999 | + if (th.data.order_prom_amount > 0) { | |
2000 | + var e = { | |
2001 | + order_prom_id: th.data.order_prom_id, | |
2002 | + order_prom_amount: th.data.order_prom_amount, | |
1999 | 2003 | } |
2000 | - dd.order_prom_list=e; | |
2004 | + dd.order_prom_list = e; | |
2001 | 2005 | } |
2002 | 2006 | |
2003 | - var bn_pick=th.data.pickup_id; | |
2004 | - var quan_no=''; | |
2007 | + var bn_pick = th.data.pickup_id; | |
2008 | + var quan_no = ''; | |
2005 | 2009 | if (th.data.using_quan[bn_pick] != null && th.data.using_quan[bn_pick] != undefined) |
2006 | 2010 | quan_no = th.data.using_quan[bn_pick].coupon_no; |
2007 | - if(quan_no){ | |
2008 | - dd.coupon_no=quan_no; | |
2009 | - if(th.data.quan_price) dd.coupon_price=th.data.quan_price; | |
2011 | + if (quan_no) { | |
2012 | + dd.coupon_no = quan_no; | |
2013 | + if (th.data.quan_price) dd.coupon_price = th.data.quan_price; | |
2010 | 2014 | } |
2011 | - if(th.data.user_note){ | |
2012 | - dd.user_note=th.data.user_note; | |
2015 | + if (th.data.user_note) { | |
2016 | + dd.user_note = th.data.user_note; | |
2013 | 2017 | } |
2014 | - dd.order_amount= parseFloat(th.data.order_m).toFixed(2); | |
2018 | + dd.order_amount = parseFloat(th.data.order_m).toFixed(2); | |
2015 | 2019 | |
2016 | 2020 | console.log(JSON.stringify(dd)); |
2017 | 2021 | wx.request({ |
... | ... | @@ -2031,25 +2035,25 @@ Page({ |
2031 | 2035 | function () { |
2032 | 2036 | //---用余额支付--- |
2033 | 2037 | getApp().my_warnning("支付成功", 1, th); |
2034 | - var send_time=th.data.pre_arr.delivery_date; | |
2035 | - if(th.data.pre_arr.delivery_type==2){ | |
2036 | - send_time=th.data.pre_arr.delivery_daynum*3600; | |
2037 | - } | |
2038 | - th.setData({isclose: 0,'order.order_status':1,'order.pay_status':1,'wait_wk':0,'presell.tail_pay_state':1,'wait_fh':1,send_time:send_time}); | |
2039 | - | |
2038 | + var send_time = th.data.pre_arr.delivery_date; | |
2039 | + if (th.data.pre_arr.delivery_type == 2) { | |
2040 | + send_time = th.data.pre_arr.delivery_daynum * 3600; | |
2041 | + } | |
2042 | + th.setData({ isclose: 0, 'order.order_status': 1, 'order.pay_status': 1, 'wait_wk': 0, 'presell.tail_pay_state': 1, 'wait_fh': 1, send_time: send_time }); | |
2043 | + | |
2040 | 2044 | }, function () { |
2041 | 2045 | getApp().my_warnning("支付失败", 0, th); |
2042 | 2046 | }) |
2043 | 2047 | } else { |
2044 | 2048 | if (t.data.code == 0) { |
2045 | - var send_time=th.data.pre_arr.delivery_date; | |
2046 | - if(th.data.pre_arr.delivery_type==2){ | |
2047 | - send_time=th.data.pre_arr.delivery_daynum*3600; | |
2049 | + var send_time = th.data.pre_arr.delivery_date; | |
2050 | + if (th.data.pre_arr.delivery_type == 2) { | |
2051 | + send_time = th.data.pre_arr.delivery_daynum * 3600; | |
2048 | 2052 | } |
2049 | 2053 | //---用余额支付--- |
2050 | - getApp().my_warnning("支付成功", 1, th); | |
2051 | - th.setData({isclose: 0,'order.order_status':1,'order.pay_status':1,'wait_wk':0,'presell.tail_pay_state':1,'wait_fh':1,send_time:send_time}); | |
2052 | - | |
2054 | + getApp().my_warnning("支付成功", 1, th); | |
2055 | + th.setData({ isclose: 0, 'order.order_status': 1, 'order.pay_status': 1, 'wait_wk': 0, 'presell.tail_pay_state': 1, 'wait_fh': 1, send_time: send_time }); | |
2056 | + | |
2053 | 2057 | } else { |
2054 | 2058 | getApp().my_warnning(t.data.msg, 1, th); |
2055 | 2059 | } |
... | ... | @@ -2074,17 +2078,17 @@ Page({ |
2074 | 2078 | }, |
2075 | 2079 | fail: function (n) { |
2076 | 2080 | console.log(n), "requestPayment:fail" == n.errMsg ? getApp().my_warnning("支付失败", 0, th) : "requestPayment:fail cancel" == n.errMsg ? getApp().my_warnning("您已取消支付", 0, th) : getApp().my_warnning("支付失败:" + n.errMsg.substr("requestPayment:fail ".length), 0, th), |
2077 | - "function" == typeof fail && fail(); | |
2081 | + "function" == typeof fail && fail(); | |
2078 | 2082 | } |
2079 | 2083 | }); |
2080 | 2084 | }, |
2081 | 2085 | |
2082 | 2086 | |
2083 | - show_liuyan:function () { | |
2084 | - this.setData({sh_liuyan:true}) | |
2087 | + show_liuyan: function () { | |
2088 | + this.setData({ sh_liuyan: true }) | |
2085 | 2089 | }, |
2086 | - close_liuyan(){ | |
2087 | - this.setData({sh_liuyan:false}) | |
2090 | + close_liuyan() { | |
2091 | + this.setData({ sh_liuyan: false }) | |
2088 | 2092 | }, |
2089 | 2093 | |
2090 | 2094 | //--------点击选择---------- |
... | ... | @@ -2098,83 +2102,83 @@ Page({ |
2098 | 2102 | |
2099 | 2103 | //--------立即支付---------- |
2100 | 2104 | async jumpToCart4(e) { |
2101 | - var th=this; | |
2102 | - if(this.data.optionIsGoup) | |
2105 | + var th = this; | |
2106 | + if (this.data.optionIsGoup) | |
2103 | 2107 | wx.navigateTo({ |
2104 | 2108 | url: "/pages/team/team_confirm/team_confirm?orderSn=" + this.data.order.order_sn + "&orderPay=true" |
2105 | 2109 | }) |
2106 | - var order=this.data.order; | |
2107 | - var order_goods=this.data.order_goods; | |
2108 | - var user_id=getApp().globalData.userInfo.user_id; | |
2109 | - | |
2110 | - var wlist=""; | |
2111 | - | |
2112 | - var good=order_goods; | |
2113 | - //线下取价功能已经关闭或者过期 | |
2114 | - if(!th.data.is_open_offline && good.offline_cut>0){ | |
2115 | - wx.showModal({ | |
2116 | - title: '提示', | |
2117 | - content: '线下取价功能已经关闭或者过期!' | |
2118 | - }); | |
2119 | - return false; | |
2120 | - } | |
2121 | - //如果不是小程序有的功能,直接提示要去3.0处理 | |
2122 | - if(good.prom_type==2 ){ | |
2123 | - wx.showModal({ | |
2124 | - title: '提示', | |
2125 | - content: '小程序还未有该活动,请到3.0公众号支付' | |
2126 | - }); | |
2127 | - return false; | |
2128 | - } | |
2110 | + var order = this.data.order; | |
2111 | + var order_goods = this.data.order_goods; | |
2112 | + var user_id = getApp().globalData.userInfo.user_id; | |
2113 | + | |
2114 | + var wlist = ""; | |
2115 | + | |
2116 | + var good = order_goods; | |
2117 | + //线下取价功能已经关闭或者过期 | |
2118 | + if (!th.data.is_open_offline && good.offline_cut > 0) { | |
2119 | + wx.showModal({ | |
2120 | + title: '提示', | |
2121 | + content: '线下取价功能已经关闭或者过期!' | |
2122 | + }); | |
2123 | + return false; | |
2124 | + } | |
2125 | + //如果不是小程序有的功能,直接提示要去3.0处理 | |
2126 | + if (good.prom_type == 2) { | |
2127 | + wx.showModal({ | |
2128 | + title: '提示', | |
2129 | + content: '小程序还未有该活动,请到3.0公众号支付' | |
2130 | + }); | |
2131 | + return false; | |
2132 | + } | |
2129 | 2133 | |
2130 | - //要每件每件的商品进行检查,看有么有超出库存,超出限购 | |
2131 | - var goodsbuynum=0,promgoodsbuynum=0,gg=null; | |
2132 | - //获取单品的现在的活动状态 | |
2133 | - await getApp().request.promiseGet("/api/weshop/goods/get/" + os.stoid + "/" + good.goods_id, { | |
2134 | - }).then(res=>{ | |
2135 | - gg=res.data.data; | |
2136 | - }) | |
2137 | - var limit = gg.viplimited; | |
2138 | - var store_count = gg.store_count; | |
2139 | - good.erpwareid=gg.erpwareid; | |
2134 | + //要每件每件的商品进行检查,看有么有超出库存,超出限购 | |
2135 | + var goodsbuynum = 0, promgoodsbuynum = 0, gg = null; | |
2136 | + //获取单品的现在的活动状态 | |
2137 | + await getApp().request.promiseGet("/api/weshop/goods/get/" + os.stoid + "/" + good.goods_id, { | |
2138 | + }).then(res => { | |
2139 | + gg = res.data.data; | |
2140 | + }) | |
2141 | + var limit = gg.viplimited; | |
2142 | + var store_count = gg.store_count; | |
2143 | + good.erpwareid = gg.erpwareid; | |
2140 | 2144 | |
2141 | - //---要获得商品,该用户买了多少件,同步应用--- | |
2142 | - await getApp().request.promiseGet("/api/weshop/ordergoods/getUserBuyGoodsNum", { | |
2143 | - data: { | |
2144 | - store_id: os.stoid, | |
2145 | - user_id: getApp().globalData.user_id, | |
2146 | - goods_id: good.goods_id, | |
2147 | - prom_type: good.prom_type, | |
2148 | - prom_id: good.prom_id | |
2149 | - }, | |
2150 | - }).then(res => { | |
2151 | - var buy_num_data = res.data.data; | |
2152 | - if (buy_num_data.promgoodsbuynum) promgoodsbuynum = buy_num_data.promgoodsbuynum; | |
2153 | - goodsbuynum = buy_num_data.goodsbuynum; | |
2154 | - }) | |
2145 | + //---要获得商品,该用户买了多少件,同步应用--- | |
2146 | + await getApp().request.promiseGet("/api/weshop/ordergoods/getUserBuyGoodsNum", { | |
2147 | + data: { | |
2148 | + store_id: os.stoid, | |
2149 | + user_id: getApp().globalData.user_id, | |
2150 | + goods_id: good.goods_id, | |
2151 | + prom_type: good.prom_type, | |
2152 | + prom_id: good.prom_id | |
2153 | + }, | |
2154 | + }).then(res => { | |
2155 | + var buy_num_data = res.data.data; | |
2156 | + if (buy_num_data.promgoodsbuynum) promgoodsbuynum = buy_num_data.promgoodsbuynum; | |
2157 | + goodsbuynum = buy_num_data.goodsbuynum; | |
2158 | + }) | |
2155 | 2159 | |
2156 | - var buyed_mum2=goodsbuynum+good.goods_num; | |
2157 | - if (buyed_mum2 > limit && limit > 0) { | |
2160 | + var buyed_mum2 = goodsbuynum + good.goods_num; | |
2161 | + if (buyed_mum2 > limit && limit > 0) { | |
2158 | 2162 | |
2159 | - var content=gg.goods_name+'购买数量超出商品限购,请取消订单'; | |
2160 | - th.toast(content); | |
2161 | - return false; | |
2162 | - } | |
2163 | + var content = gg.goods_name + '购买数量超出商品限购,请取消订单'; | |
2164 | + th.toast(content); | |
2165 | + return false; | |
2166 | + } | |
2163 | 2167 | |
2164 | 2168 | |
2165 | 2169 | |
2166 | 2170 | //如果是预售的时候, |
2167 | - if(good.prom_type==8){ | |
2168 | - await getApp().request.promiseGet("/api/weshop/order/orderPresell/countBuyGoodsSum",{ | |
2169 | - data: {store_id: os.stoid, user_id: user_id, goods_id: good.goods_id, prom_id: good.prom_id}, | |
2170 | - }).then(e=>{ | |
2171 | + if (good.prom_type == 8) { | |
2172 | + await getApp().request.promiseGet("/api/weshop/order/orderPresell/countBuyGoodsSum", { | |
2173 | + data: { store_id: os.stoid, user_id: user_id, goods_id: good.goods_id, prom_id: good.prom_id }, | |
2174 | + }).then(e => { | |
2171 | 2175 | if (e.data.code == 0) { |
2172 | - promgoodsbuynum=e.data.data.sumgoodsnum; | |
2176 | + promgoodsbuynum = e.data.data.sumgoodsnum; | |
2173 | 2177 | } |
2174 | 2178 | }) |
2175 | 2179 | |
2176 | - var presell_id =good.prom_id; | |
2177 | - var presellList=null; | |
2180 | + var presell_id = good.prom_id; | |
2181 | + var presellList = null; | |
2178 | 2182 | var url = "/api/weshop/marketing/marketingPresellList/list" |
2179 | 2183 | var rd = { |
2180 | 2184 | store_id: os.stoid, |
... | ... | @@ -2187,13 +2191,13 @@ Page({ |
2187 | 2191 | }).then(res => { |
2188 | 2192 | if (res.data.code == 0 && res.data.data && res.data.data.length > 0) { |
2189 | 2193 | var arr = res.data.data[0]; |
2190 | - presellList=arr | |
2194 | + presellList = arr | |
2191 | 2195 | } |
2192 | 2196 | }) |
2193 | 2197 | |
2194 | - if(presellList){ | |
2198 | + if (presellList) { | |
2195 | 2199 | |
2196 | - if(good.goods_num>presellList.presell_sumqty-presellList.buy_goodnum){ | |
2200 | + if (good.goods_num > presellList.presell_sumqty - presellList.buy_goodnum) { | |
2197 | 2201 | var content = gg.goods_name + '购买数量超出商品库存,请取消订单'; |
2198 | 2202 | th.toast(content); |
2199 | 2203 | return false; |
... | ... | @@ -2209,247 +2213,248 @@ Page({ |
2209 | 2213 | } |
2210 | 2214 | |
2211 | 2215 | |
2212 | - //如果优惠促销和搭配购的时候 | |
2213 | - if((good.prom_type==3 || good.prom_type==5) && good.is_collocation!=1 && good.is_gift!=1){ | |
2214 | - var p_ok=1; | |
2215 | - await getApp().request.promiseGet("/api/weshop/goods/getGoodsPromList/" + os.stoid+"/"+good.goods_id+"/0", {}).then(res => { | |
2216 | - if(res.data.code==0){ | |
2217 | - var r_data=res.data.data; | |
2218 | - if(!r_data.collocationPromList && good.prom_type==5){ | |
2219 | - | |
2220 | - var content=good.goods_name+'未找到活动,请取消订单重新购买'; | |
2221 | - th.toast(content); | |
2222 | - p_ok=0; | |
2223 | - } | |
2224 | - if(!r_data.promGoodsLists && good.prom_type==3){ | |
2225 | - | |
2226 | - var content=good.goods_name+'未找到活动,请取消订单重新购买'; | |
2227 | - th.toast(content); | |
2228 | - p_ok=0; | |
2229 | - } | |
2230 | - }else{ | |
2216 | + //如果优惠促销和搭配购的时候 | |
2217 | + if ((good.prom_type == 3 || good.prom_type == 5) && good.is_collocation != 1 && good.is_gift != 1) { | |
2218 | + var p_ok = 1; | |
2219 | + await getApp().request.promiseGet("/api/weshop/goods/getGoodsPromList/" + os.stoid + "/" + good.goods_id + "/0", {}).then(res => { | |
2220 | + if (res.data.code == 0) { | |
2221 | + var r_data = res.data.data; | |
2222 | + if (!r_data.collocationPromList && good.prom_type == 5) { | |
2231 | 2223 | |
2232 | - var content=good.goods_name+'未找到活动,请取消订单重新购买'; | |
2224 | + var content = good.goods_name + '未找到活动,请取消订单重新购买'; | |
2233 | 2225 | th.toast(content); |
2234 | - p_ok=0; | |
2226 | + p_ok = 0; | |
2235 | 2227 | } |
2236 | - }) | |
2237 | - if(!p_ok) return false; | |
2238 | - } | |
2228 | + if (!r_data.promGoodsLists && good.prom_type == 3) { | |
2239 | 2229 | |
2240 | - //商品的普通购买 ,不要进行判断 | |
2241 | - if((good.prom_type==1 || good.prom_type==6 || good.prom_type==4) && !good.is_gift && !good.is_collocation && !good.is_integral_normal && !good.is_pd_normal){ | |
2242 | - if(gg.prom_type!=good.prom_type) { | |
2230 | + var content = good.goods_name + '未找到活动,请取消订单重新购买'; | |
2231 | + th.toast(content); | |
2232 | + p_ok = 0; | |
2233 | + } | |
2234 | + } else { | |
2243 | 2235 | |
2244 | - var content=gg.goods_name+'商品的活动发生了变化,请取消订单重新购买'; | |
2236 | + var content = good.goods_name + '未找到活动,请取消订单重新购买'; | |
2245 | 2237 | th.toast(content); |
2246 | - return false; | |
2238 | + p_ok = 0; | |
2247 | 2239 | } |
2248 | - }else{ | |
2249 | - if((gg.prom_type==1 || gg.prom_type==3 || gg.prom_type==5 || gg.prom_type==6 || gg.prom_type==4) | |
2250 | - && !good.is_collocation && !good.is_gift && !good.is_integral_normal && !good.is_pd_normal) { | |
2251 | - var prom=null; | |
2252 | - //---如果是活动的时候--- | |
2253 | - var prom=null,th=this; | |
2254 | - if(gg.prom_type==1){ | |
2255 | - await getApp().request.promiseGet("/api/ms/flash_sale/get/"+os.stoid+"/"+gg.prom_id,{ | |
2256 | - }).then(res=>{ | |
2257 | - if(res.data.code==0){ | |
2258 | - prom=res.data.data; | |
2259 | - } | |
2260 | - }) | |
2261 | - } | |
2262 | - if(gg.prom_type==6){ | |
2263 | - await getApp().request.promiseGet("/api/weshop/teamlist/get/"+os.stoid+"/"+gg.prom_id,{ | |
2264 | - }).then(res=>{ | |
2265 | - if(res.data.code==0){ | |
2266 | - prom=res.data.data; | |
2267 | - } | |
2268 | - }) | |
2269 | - } | |
2270 | - | |
2271 | - if(gg.prom_type==4){ | |
2272 | - await getApp().request.promiseGet("/api/weshop/integralbuy/pageIntegralBuyGoodsList?stype=1&stypeup=1",{ | |
2273 | - data:{store_id:os.stoid,goods_id:gg.goods_id} | |
2274 | - }).then(res=>{ | |
2275 | - if(res.data.code==0 && res.data.data && res.data.data.pageData && res.data.data.pageData.length){ | |
2276 | - prom=res.data.data.pageData[0]; | |
2277 | - } | |
2278 | - }) | |
2279 | - } | |
2240 | + }) | |
2241 | + if (!p_ok) return false; | |
2242 | + } | |
2280 | 2243 | |
2281 | - if(prom){ | |
2282 | - var t_now=ut.gettimestamp(); | |
2283 | - if(prom.is_end==0 && prom.start_time<t_now && prom.end_time>t_now){ | |
2244 | + //商品的普通购买 ,不要进行判断 | |
2245 | + if ((good.prom_type == 1 || good.prom_type == 6 || good.prom_type == 4) && !good.is_gift && !good.is_collocation && !good.is_integral_normal && !good.is_pd_normal) { | |
2246 | + if (gg.prom_type != good.prom_type) { | |
2284 | 2247 | |
2285 | - var content=gg.goods_name+'商品的活动发生了变化,请取消订单重新购买'; | |
2286 | - th.toast(content); | |
2287 | - return false; | |
2248 | + var content = gg.goods_name + '商品的活动发生了变化,请取消订单重新购买'; | |
2249 | + th.toast(content); | |
2250 | + return false; | |
2251 | + } | |
2252 | + } else { | |
2253 | + if ((gg.prom_type == 1 || gg.prom_type == 3 || gg.prom_type == 5 || gg.prom_type == 6 || gg.prom_type == 4) | |
2254 | + && !good.is_collocation && !good.is_gift && !good.is_integral_normal && !good.is_pd_normal) { | |
2255 | + var prom = null; | |
2256 | + //---如果是活动的时候--- | |
2257 | + var prom = null, th = this; | |
2258 | + if (gg.prom_type == 1) { | |
2259 | + await getApp().request.promiseGet("/api/ms/flash_sale/get/" + os.stoid + "/" + gg.prom_id, { | |
2260 | + }).then(res => { | |
2261 | + if (res.data.code == 0) { | |
2262 | + prom = res.data.data; | |
2288 | 2263 | } |
2289 | - } | |
2264 | + }) | |
2265 | + } | |
2266 | + if (gg.prom_type == 6) { | |
2267 | + await getApp().request.promiseGet("/api/weshop/teamlist/get/" + os.stoid + "/" + gg.prom_id, { | |
2268 | + }).then(res => { | |
2269 | + if (res.data.code == 0) { | |
2270 | + prom = res.data.data; | |
2271 | + } | |
2272 | + }) | |
2290 | 2273 | } |
2291 | - else{ | |
2292 | - //不是赠品的时候 | |
2293 | - if(!good.is_gift && good.prom_type!=3){ | |
2294 | - var t_ok=1; | |
2295 | - await getApp().request.promiseGet("/api/weshop/goods/getGoodsPromList/" + os.stoid+"/"+good.goods_id+"/0", {}).then(res => { | |
2296 | - if(res.data.code==0){ | |
2297 | - var r_data=res.data.data; | |
2298 | - //-- 参加了全局的优惠活动 -- | |
2299 | - if(r_data.promGoodsLists){ | |
2300 | - | |
2301 | - var content=gg.goods_name+'商品的活动发生了变化,请取消订单重新购买'; | |
2302 | - th.toast(content); | |
2303 | - t_ok=0; | |
2304 | - } | |
2305 | - } | |
2306 | - }) | |
2307 | - if(!t_ok) return false; | |
2308 | - } | |
2309 | 2274 | |
2310 | - //-- 如果有参加线下取价 -- | |
2311 | - if(good.offline_cut>0) wlist+=encodeURIComponent(gg.erpwareid)+","; | |
2275 | + if (gg.prom_type == 4) { | |
2276 | + await getApp().request.promiseGet("/api/weshop/integralbuy/pageIntegralBuyGoodsList?stype=1&stypeup=1", { | |
2277 | + data: { store_id: os.stoid, goods_id: gg.goods_id } | |
2278 | + }).then(res => { | |
2279 | + if (res.data.code == 0 && res.data.data && res.data.data.pageData && res.data.data.pageData.length) { | |
2280 | + prom = res.data.data.pageData[0]; | |
2281 | + } | |
2282 | + }) | |
2312 | 2283 | } |
2313 | - //赠品和搭配购不判断商品金额 | |
2314 | - var isok=1; | |
2315 | - var card_field=th.data.card_field; | |
2316 | - //如果会员是等级会员,商品有等级价,且不是活动商品 | |
2317 | - if(!good.is_gift && !good.is_collocation && good.prom_type!=8) { | |
2318 | - if (card_field && gg[card_field] > 0) { | |
2319 | - if (good.goods_price != gg[card_field] && good.offline_cut<=0) isok = 0; | |
2320 | - if (good.goods_price >gg[card_field] && good.offline_cut>0) isok = 0; //如果线下价格比较贵,则不通过 | |
2321 | 2284 | |
2322 | - } else { | |
2323 | - if (good.goods_price != gg.shop_price && good.offline_cut<=0) isok = 0; | |
2324 | - if (good.goods_price> gg.shop_price && good.offline_cut>0) isok = 0; //如果线下价格比较贵,则不通过 | |
2325 | - } | |
2326 | - var is_h=0; | |
2327 | - if (!isok) { | |
2285 | + if (prom) { | |
2286 | + var t_now = ut.gettimestamp(); | |
2287 | + if (prom.is_end == 0 && prom.start_time < t_now && prom.end_time > t_now) { | |
2328 | 2288 | |
2329 | - var content=gg.goods_name + '商品的价格发生了变化,请取消订单重新购买'; | |
2289 | + var content = gg.goods_name + '商品的活动发生了变化,请取消订单重新购买'; | |
2330 | 2290 | th.toast(content); |
2331 | 2291 | return false; |
2332 | 2292 | } |
2333 | 2293 | } |
2294 | + } | |
2295 | + else { | |
2296 | + //不是赠品的时候 | |
2297 | + if (!good.is_gift && good.prom_type != 3) { | |
2298 | + var t_ok = 1; | |
2299 | + await getApp().request.promiseGet("/api/weshop/goods/getGoodsPromList/" + os.stoid + "/" + good.goods_id + "/0", {}).then(res => { | |
2300 | + if (res.data.code == 0) { | |
2301 | + var r_data = res.data.data; | |
2302 | + //-- 参加了全局的优惠活动 -- | |
2303 | + if (r_data.promGoodsLists) { | |
2334 | 2304 | |
2305 | + var content = gg.goods_name + '商品的活动发生了变化,请取消订单重新购买'; | |
2306 | + th.toast(content); | |
2307 | + t_ok = 0; | |
2308 | + } | |
2309 | + } | |
2310 | + }) | |
2311 | + if (!t_ok) return false; | |
2312 | + } | |
2335 | 2313 | |
2336 | - if(good.goods_num>store_count){ | |
2337 | - | |
2338 | - var content=gg.goods_name+'商品的库存不足,请取消订单'; | |
2339 | - th.toast(content); | |
2340 | - return false; | |
2341 | - } | |
2314 | + //-- 如果有参加线下取价 -- | |
2315 | + if (good.offline_cut > 0) wlist += encodeURIComponent(gg.erpwareid) + ","; | |
2316 | + } | |
2317 | + //赠品和搭配购不判断商品金额 | |
2318 | + var isok = 1; | |
2319 | + var card_field = th.data.card_field; | |
2320 | + //如果会员是等级会员,商品有等级价,且不是活动商品 | |
2321 | + if (!good.is_gift && !good.is_collocation && good.prom_type != 8) { | |
2322 | + if (card_field && gg[card_field] > 0) { | |
2323 | + if (good.goods_price != gg[card_field] && good.offline_cut <= 0) isok = 0; | |
2324 | + if (good.goods_price > gg[card_field] && good.offline_cut > 0) isok = 0; //如果线下价格比较贵,则不通过 | |
2342 | 2325 | |
2326 | + } else { | |
2327 | + if (good.goods_price != gg.shop_price && good.offline_cut <= 0) isok = 0; | |
2328 | + if (good.goods_price > gg.shop_price && good.offline_cut > 0) isok = 0; //如果线下价格比较贵,则不通过 | |
2329 | + } | |
2330 | + var is_h = 0; | |
2331 | + if (!isok) { | |
2343 | 2332 | |
2333 | + var content = gg.goods_name + '商品的价格发生了变化,请取消订单重新购买'; | |
2334 | + th.toast(content); | |
2335 | + return false; | |
2336 | + } | |
2344 | 2337 | } |
2345 | 2338 | |
2346 | - console.log("------------------------------------"); | |
2347 | - //---如果是活动的时候--- | |
2348 | - var prom=null,goodsinfo=good,th=this; | |
2349 | - if(goodsinfo.prom_type==1){ | |
2350 | - await getApp().request.promiseGet("/api/ms/flash_sale/get/"+os.stoid+"/"+goodsinfo.prom_id,{ | |
2351 | - }).then(res=>{ | |
2352 | - if(res.data.code==0){ | |
2353 | - prom=res.data.data; | |
2354 | - } | |
2355 | - }) | |
2339 | + | |
2340 | + if (good.goods_num > store_count) { | |
2341 | + | |
2342 | + var content = gg.goods_name + '商品的库存不足,请取消订单'; | |
2343 | + th.toast(content); | |
2344 | + return false; | |
2356 | 2345 | } |
2357 | - if(goodsinfo.prom_type==6 && !good.is_pd_normal){ | |
2358 | - await getApp().request.promiseGet("/api/weshop/teamlist/get/"+os.stoid+"/"+goodsinfo.prom_id,{ | |
2359 | - }).then(res=>{ | |
2360 | - if(res.data.code==0){ | |
2361 | - prom=res.data.data; | |
2362 | - } | |
2363 | - }) | |
2346 | + | |
2347 | + | |
2348 | + } | |
2349 | + | |
2350 | + console.log("------------------------------------"); | |
2351 | + //---如果是活动的时候--- | |
2352 | + var prom = null, goodsinfo = good, th = this; | |
2353 | + if (goodsinfo.prom_type == 1) { | |
2354 | + await getApp().request.promiseGet("/api/ms/flash_sale/get/" + os.stoid + "/" + goodsinfo.prom_id, { | |
2355 | + }).then(res => { | |
2356 | + if (res.data.code == 0) { | |
2357 | + prom = res.data.data; | |
2358 | + } | |
2359 | + }) | |
2360 | + } | |
2361 | + if (goodsinfo.prom_type == 6 && !good.is_pd_normal) { | |
2362 | + await getApp().request.promiseGet("/api/weshop/teamlist/get/" + os.stoid + "/" + goodsinfo.prom_id, { | |
2363 | + }).then(res => { | |
2364 | + if (res.data.code == 0) { | |
2365 | + prom = res.data.data; | |
2366 | + } | |
2367 | + }) | |
2368 | + } | |
2369 | + | |
2370 | + if (goodsinfo.prom_type == 4 && !good.is_integral_normal) { | |
2371 | + await getApp().request.promiseGet("/api/weshop/integralbuy/pageIntegralBuyGoodsList?stype=1&stypeup=1", { | |
2372 | + data: { store_id: os.stoid, goods_id: goodsinfo.goods_id } | |
2373 | + }).then(res => { | |
2374 | + if (res.data.code == 0 && res.data.data && res.data.data.pageData && res.data.data.pageData.length) { | |
2375 | + prom = res.data.data.pageData[0]; | |
2376 | + } | |
2377 | + }) | |
2378 | + } | |
2379 | + | |
2380 | + //----------如果有活动,并且在进行中,就不计算线下库存--------------- | |
2381 | + if (prom) { | |
2382 | + var now = ut.gettimestamp(); | |
2383 | + if (prom.is_end == 1 && prom.end_time < now) { | |
2384 | + | |
2385 | + var content = goodsinfo.goods_name + '商品的活动已经结束,请取消订单重新购买'; | |
2386 | + th.toast(content); | |
2387 | + return false; | |
2364 | 2388 | } |
2365 | 2389 | |
2366 | - if(goodsinfo.prom_type==4 && !good.is_integral_normal){ | |
2367 | - await getApp().request.promiseGet("/api/weshop/integralbuy/pageIntegralBuyGoodsList?stype=1&stypeup=1",{ | |
2368 | - data:{store_id:os.stoid,goods_id:goodsinfo.goods_id} | |
2369 | - }).then(res=>{ | |
2370 | - if(res.data.code==0 && res.data.data && res.data.data.pageData && res.data.data.pageData.length){ | |
2371 | - prom=res.data.data.pageData[0]; | |
2372 | - } | |
2373 | - }) | |
2390 | + buyed_mum2 = promgoodsbuynum + good.goods_num; | |
2391 | + if (buyed_mum2 > prom.buy_limit && prom.buy_limit > 0) { | |
2392 | + | |
2393 | + var content = goodsinfo.goods_name + '购买数量超出商品活动限购,请取消订单重新购买'; | |
2394 | + th.toast(content); | |
2395 | + return false; | |
2374 | 2396 | } |
2375 | 2397 | |
2376 | - //----------如果有活动,并且在进行中,就不计算线下库存--------------- | |
2377 | - if(prom){ | |
2378 | - var now=ut.gettimestamp(); | |
2379 | - if(prom.is_end==1 && prom.end_time<now){ | |
2398 | + if (goodsinfo.prom_type == 4) { | |
2399 | + if (good.goods_num > prom.limitqty - prom.buy_num) { | |
2380 | 2400 | |
2381 | - var content=goodsinfo.goods_name+'商品的活动已经结束,请取消订单重新购买'; | |
2401 | + var content = goodsinfo.goods_name + '购买数量超出商品活动库存,请取消订单'; | |
2382 | 2402 | th.toast(content); |
2383 | 2403 | return false; |
2384 | 2404 | } |
2405 | + } else { | |
2406 | + var redis_num = 0; | |
2407 | + //------判断活动是否抢光----- | |
2408 | + await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + | |
2409 | + os.stoid + "/" + goodsinfo.prom_type + "/" + goodsinfo.prom_id, { | |
2410 | + }).then(res => { | |
2411 | + redis_num = res.data.data; | |
2412 | + }); | |
2385 | 2413 | |
2386 | - buyed_mum2=promgoodsbuynum+good.goods_num; | |
2387 | - if (buyed_mum2 > prom.buy_limit && prom.buy_limit > 0) { | |
2414 | + if (good.goods_num > redis_num) { | |
2388 | 2415 | |
2389 | - var content=goodsinfo.goods_name+'购买数量超出商品活动限购,请取消订单重新购买'; | |
2416 | + var content = gg.goods_name + '超出商品活动库存,请取消订单'; | |
2390 | 2417 | th.toast(content); |
2391 | 2418 | return false; |
2392 | 2419 | } |
2393 | - | |
2394 | - if(goodsinfo.prom_type==4){ | |
2395 | - if (good.goods_num > prom.limitqty-prom.buy_num) { | |
2396 | - | |
2397 | - var content=goodsinfo.goods_name+'购买数量超出商品活动库存,请取消订单'; | |
2398 | - th.toast(content); | |
2399 | - return false; | |
2400 | - } | |
2401 | - }else{ | |
2402 | - var redis_num = 0; | |
2403 | - //------判断活动是否抢光----- | |
2404 | - await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + | |
2405 | - os.stoid + "/" + goodsinfo.prom_type + "/" + goodsinfo.prom_id, { | |
2406 | - }).then(res => { | |
2407 | - redis_num = res.data.data; | |
2408 | - }); | |
2409 | - | |
2410 | - if (good.goods_num > redis_num) { | |
2411 | - | |
2412 | - var content=gg.goods_name+'超出商品活动库存,请取消订单'; | |
2413 | - th.toast(content); | |
2414 | - return false; | |
2415 | - } | |
2416 | - } | |
2417 | - | |
2418 | 2420 | } |
2419 | 2421 | |
2422 | + } | |
2423 | + | |
2420 | 2424 | |
2421 | 2425 | |
2422 | 2426 | //-- 要判断一下线下取价价格是不是发生改变 -- |
2423 | - if(wlist!="" && th.data.is_open_offline && th.data.is_open_offline>0){ | |
2424 | - wlist=ut.sub_last(wlist); | |
2425 | - var keyid=order.pickup_id; | |
2426 | - var user_info=getApp().globalData.userInfo; | |
2427 | - if(!keyid) return false; | |
2428 | - var offarr=null; | |
2427 | + if (wlist != "" && th.data.is_open_offline && th.data.is_open_offline > 0) { | |
2428 | + wlist = ut.sub_last(wlist); | |
2429 | + var keyid = order.pickup_id; | |
2430 | + var user_info = getApp().globalData.userInfo; | |
2431 | + if (!keyid) return false; | |
2432 | + var offarr = null; | |
2429 | 2433 | await getApp().request.promiseGet("/api/weshop/goods/listWarePrice", { |
2430 | - data:{ | |
2431 | - VIPId:encodeURIComponent(user_info.erpvipid), | |
2432 | - store_id:os.stoid, | |
2433 | - PickupId:keyid, | |
2434 | - WareIds:wlist}, | |
2434 | + data: { | |
2435 | + VIPId: encodeURIComponent(user_info.erpvipid), | |
2436 | + store_id: os.stoid, | |
2437 | + PickupId: keyid, | |
2438 | + WareIds: wlist | |
2435 | 2439 | }, |
2436 | - ).then(res=>{ | |
2437 | - if(res.data.code==0 && res.data.data && res.data.data.length>0){ | |
2438 | - offarr=res.data.data; | |
2440 | + }, | |
2441 | + ).then(res => { | |
2442 | + if (res.data.code == 0 && res.data.data && res.data.data.length > 0) { | |
2443 | + offarr = res.data.data; | |
2439 | 2444 | } |
2440 | 2445 | }) |
2441 | - if(!offarr && offarr.length<=0 ){ | |
2442 | - wx.showModal({ title: '获取线下取价失败',}); | |
2446 | + if (!offarr && offarr.length <= 0) { | |
2447 | + wx.showModal({ title: '获取线下取价失败', }); | |
2443 | 2448 | } |
2444 | - var newarr=ut.convert_arr_key(offarr,'WareId'); | |
2449 | + var newarr = ut.convert_arr_key(offarr, 'WareId'); | |
2445 | 2450 | //-- 循环判断线下的价格 -- |
2446 | - for(var k in order_goods){ | |
2447 | - var good=order_goods[k]; | |
2451 | + for (var k in order_goods) { | |
2452 | + var good = order_goods[k]; | |
2448 | 2453 | //判断线下取价是不是一样 |
2449 | - if(newarr[good.erpwareid] && | |
2450 | - parseFloat(newarr[good.erpwareid].WarePrice)!=parseFloat(good.goods_price)){ | |
2454 | + if (newarr[good.erpwareid] && | |
2455 | + parseFloat(newarr[good.erpwareid].WarePrice) != parseFloat(good.goods_price)) { | |
2451 | 2456 | |
2452 | - var content=good.goods_name + '商品的价格发生了变化,请取消订单重新购买'; | |
2457 | + var content = good.goods_name + '商品的价格发生了变化,请取消订单重新购买'; | |
2453 | 2458 | th.toast(content); |
2454 | 2459 | return false; |
2455 | 2460 | } |
... | ... | @@ -2464,30 +2469,30 @@ Page({ |
2464 | 2469 | type: 1 //正常单 |
2465 | 2470 | }, 1);--*/ |
2466 | 2471 | |
2467 | - util_pay.pay(this.data.order.order_sn, function() { | |
2468 | - wx.showToast({title: '支付成功'}) | |
2472 | + util_pay.pay(this.data.order.order_sn, function () { | |
2473 | + wx.showToast({ title: '支付成功' }) | |
2469 | 2474 | wx.navigateBack(); |
2470 | - },null,os.stoid,1); | |
2475 | + }, null, os.stoid, 1); | |
2471 | 2476 | |
2472 | 2477 | |
2473 | 2478 | }, |
2474 | 2479 | |
2475 | 2480 | //--------取消订单--------- |
2476 | - cancelOrder: function(e) { | |
2477 | - var t = this,th=t, ord_id = this.data.order.order_id,order=this.data.order; | |
2481 | + cancelOrder: function (e) { | |
2482 | + var t = this, th = t, ord_id = this.data.order.order_id, order = this.data.order; | |
2478 | 2483 | |
2479 | 2484 | wx.showModal({ |
2480 | 2485 | title: "是否取消订单?", |
2481 | - success: function(e) { | |
2482 | - if(!e.confirm) return false; | |
2486 | + success: function (e) { | |
2487 | + if (!e.confirm) return false; | |
2483 | 2488 | //如果是秒杀和拼单的商品,取消订单要返回redis,并取消订单 |
2484 | 2489 | //if(is_skill==1 || is_zsorder>=2){ |
2485 | - getApp().request.post("/api/weshop/order/cancelOrder/"+os.stoid+"/"+ord_id+"/"+getApp().globalData.user_id,{ | |
2486 | - data:{}, | |
2487 | - success: function(t) { | |
2488 | - if(t.data.code==0){ | |
2489 | - th.setData({'order.order_status':3}); | |
2490 | - wx.setStorageSync("order:order_list:update", !0); | |
2490 | + getApp().request.post("/api/weshop/order/cancelOrder/" + os.stoid + "/" + ord_id + "/" + getApp().globalData.user_id, { | |
2491 | + data: {}, | |
2492 | + success: function (t) { | |
2493 | + if (t.data.code == 0) { | |
2494 | + th.setData({ 'order.order_status': 3 }); | |
2495 | + wx.setStorageSync("order:order_list:update", !0); | |
2491 | 2496 | } |
2492 | 2497 | |
2493 | 2498 | }, |
... | ... | @@ -2499,36 +2504,36 @@ Page({ |
2499 | 2504 | |
2500 | 2505 | |
2501 | 2506 | //-----删除订单----- |
2502 | - deleteOrderData: function(t) { | |
2503 | - var th=this; | |
2504 | - var order_id=this.data.order.order_id; | |
2505 | - var up_data={ | |
2506 | - order_id: order_id,isdel:1 | |
2507 | + deleteOrderData: function (t) { | |
2508 | + var th = this; | |
2509 | + var order_id = this.data.order.order_id; | |
2510 | + var up_data = { | |
2511 | + order_id: order_id, isdel: 1 | |
2507 | 2512 | }; |
2508 | - if(th.data.order.order_status!=6){ | |
2509 | - up_data.order_status=5; | |
2513 | + if (th.data.order.order_status != 6) { | |
2514 | + up_data.order_status = 5; | |
2510 | 2515 | } |
2511 | 2516 | wx.showModal({ |
2512 | 2517 | title: "是否删除订单?", |
2513 | - success: function(tt) { | |
2518 | + success: function (tt) { | |
2514 | 2519 | tt.confirm && getApp().request.put("/api/weshop/order/updatebyId", { |
2515 | 2520 | data: up_data, |
2516 | 2521 | success: function (t) { |
2517 | - getApp().my_warnning("删除成功",1,th); | |
2522 | + getApp().my_warnning("删除成功", 1, th); | |
2518 | 2523 | setTimeout(function () { |
2519 | 2524 | getApp().goto("/pages/user/order_list/order_list"); |
2520 | - },1000); | |
2525 | + }, 1000); | |
2521 | 2526 | } |
2522 | 2527 | }) |
2523 | 2528 | } |
2524 | 2529 | }); |
2525 | 2530 | }, |
2526 | 2531 | |
2527 | - go_goods:function (e) { | |
2528 | - var url=e.currentTarget.dataset.url; | |
2532 | + go_goods: function (e) { | |
2533 | + var url = e.currentTarget.dataset.url; | |
2529 | 2534 | getApp().goto(url); |
2530 | 2535 | }, |
2531 | - toast(msg){ | |
2536 | + toast(msg) { | |
2532 | 2537 | wx.showToast({ |
2533 | 2538 | title: msg, |
2534 | 2539 | icon: 'none', |
... | ... | @@ -2536,15 +2541,15 @@ Page({ |
2536 | 2541 | }) |
2537 | 2542 | }, |
2538 | 2543 | //--------确认收货--------- |
2539 | - confirmOrder: function(e) { | |
2540 | - var th=this; | |
2541 | - var o = this.data.order.order_id,order=this.data.order; | |
2544 | + confirmOrder: function (e) { | |
2545 | + var th = this; | |
2546 | + var o = this.data.order.order_id, order = this.data.order; | |
2542 | 2547 | wx.showModal({ |
2543 | 2548 | title: "是否确认收货?", |
2544 | - success: function(t) { | |
2545 | - t.confirm && getApp().request.post("/api/weshop/order/confirmOrder/"+os.stoid+"/"+o+"/"+getApp().globalData.user_id,{ | |
2546 | - success:function (e) { | |
2547 | - if(e.data.code==0){ | |
2549 | + success: function (t) { | |
2550 | + t.confirm && getApp().request.post("/api/weshop/order/confirmOrder/" + os.stoid + "/" + o + "/" + getApp().globalData.user_id, { | |
2551 | + success: function (e) { | |
2552 | + if (e.data.code == 0) { | |
2548 | 2553 | th.setData({}) |
2549 | 2554 | } |
2550 | 2555 | } |
... | ... | @@ -2555,13 +2560,13 @@ Page({ |
2555 | 2560 | |
2556 | 2561 | |
2557 | 2562 | //---------联系客服------------ |
2558 | - contactService: function() { | |
2559 | - getApp().getConfig(function(t) { | |
2563 | + contactService: function () { | |
2564 | + getApp().getConfig(function (t) { | |
2560 | 2565 | if (t.store_tel == undefined) { |
2561 | 2566 | getApp().request.get("/api/weshop/store/get/" + os.stoid, { |
2562 | 2567 | isShowLoading: 1, |
2563 | 2568 | data: {}, |
2564 | - success: function(rs) { | |
2569 | + success: function (rs) { | |
2565 | 2570 | getApp().globalData.config = rs.data.data; |
2566 | 2571 | if (rs.data.data.store_tel == null && rs.data.data.store_tel == undefined) { |
2567 | 2572 | getApp().my_warnning("商家未设置电话", 0, th); |
... | ... | @@ -2577,13 +2582,13 @@ Page({ |
2577 | 2582 | }, |
2578 | 2583 | |
2579 | 2584 | //---------联系微信客服------------ |
2580 | - con_weixin:function () { | |
2581 | - var url=this.data.sys_switch.weapp_customertype_url; | |
2582 | - var id=this.data.sys_switch.weapp_customertype_appid; | |
2585 | + con_weixin: function () { | |
2586 | + var url = this.data.sys_switch.weapp_customertype_url; | |
2587 | + var id = this.data.sys_switch.weapp_customertype_appid; | |
2583 | 2588 | wx.openCustomerServiceChat({ |
2584 | - extInfo: {url: url}, | |
2589 | + extInfo: { url: url }, | |
2585 | 2590 | corpId: id, |
2586 | - success(res) {} | |
2591 | + success(res) { } | |
2587 | 2592 | }) |
2588 | 2593 | } |
2589 | 2594 | ... | ... |
packageC/pages/presell/cart/cart2.js
... | ... | @@ -121,25 +121,25 @@ Page({ |
121 | 121 | tabs: ['门店自提', '快递邮寄'], |
122 | 122 | currentTabIndex: 1, |
123 | 123 | |
124 | - in_zhact_gdmap:{}, //不同门店参与同一活动的限购 | |
125 | - hid_inp:1, | |
126 | - user_note:{}, | |
124 | + in_zhact_gdmap: {}, //不同门店参与同一活动的限购 | |
125 | + hid_inp: 1, | |
126 | + user_note: {}, | |
127 | 127 | }, |
128 | 128 | onLoad: function (t) { |
129 | - wx.setNavigationBarTitle({title: "填写订单",}) | |
129 | + wx.setNavigationBarTitle({ title: "填写订单", }) | |
130 | 130 | var th = this; |
131 | 131 | //清理一下,确保最新的系统配置 |
132 | 132 | getApp().globalData.config2 = null; |
133 | 133 | //清空is_pick_up |
134 | 134 | getApp().request.put("/api/weshop/useraddress/updatePickUp", { |
135 | - data: {user_id: getApp().globalData.user_id, is_pickup: 0}, | |
135 | + data: { user_id: getApp().globalData.user_id, is_pickup: 0 }, | |
136 | 136 | success: function (s) { |
137 | 137 | } |
138 | 138 | }); |
139 | 139 | |
140 | 140 | }, |
141 | 141 | onUnload: function () { |
142 | - this.setData({isclose: 1}) | |
142 | + this.setData({ isclose: 1 }) | |
143 | 143 | }, |
144 | 144 | onHide: function () { |
145 | 145 | this.setData({ |
... | ... | @@ -152,7 +152,7 @@ Page({ |
152 | 152 | //----------子页返回父页触发---------- |
153 | 153 | onShow: function () { |
154 | 154 | var th = this; |
155 | - th.setData({show_submit: 0}); //让提交先掩藏 | |
155 | + th.setData({ show_submit: 0 }); //让提交先掩藏 | |
156 | 156 | th.data.g_cart_q_time = null; |
157 | 157 | |
158 | 158 | if (th.data.isclose == 0) { |
... | ... | @@ -182,20 +182,20 @@ Page({ |
182 | 182 | th.data.is_summit_ing = 0; |
183 | 183 | //更换地址回来要重新调用计算价钱的接口 |
184 | 184 | if (!th.data.user_addr || th.data.user_addr.address_id != ie.address_id) { |
185 | - th.setData({user_addr: ie}); | |
185 | + th.setData({ user_addr: ie }); | |
186 | 186 | if (th.data.is_b_now == 1) { |
187 | 187 | if (th.data.bn_goods) { |
188 | - th.setData({add_back: 1}); | |
188 | + th.setData({ add_back: 1 }); | |
189 | 189 | //th.calculatePrice2(); |
190 | 190 | } |
191 | 191 | } else { |
192 | 192 | if (th.data.cartlist) { |
193 | - th.setData({add_back: 1}); | |
193 | + th.setData({ add_back: 1 }); | |
194 | 194 | //th.calculatePrice(); |
195 | 195 | } |
196 | 196 | } |
197 | 197 | } else { |
198 | - th.setData({user_addr: ie}); | |
198 | + th.setData({ user_addr: ie }); | |
199 | 199 | } |
200 | 200 | var going = 0; |
201 | 201 | |
... | ... | @@ -234,34 +234,34 @@ Page({ |
234 | 234 | //-- 获取所有的等级卡, -- |
235 | 235 | getApp().request.promiseGet("/api/weshop/plus/vip/mem/bership/list?storeId=" + os.stoid, |
236 | 236 | {}).then(res => { |
237 | - if (res.data.code == 0) { | |
238 | - var plusCard = res.data.data; | |
239 | - //-- 循环判断,拿到最贵的那张卡 -- | |
240 | - for (var ih in plusCard) { | |
241 | - if (plusCard[ih].IsStopBuy == true) { | |
242 | - continue; | |
243 | - } | |
244 | - if (max_price < 0) { | |
245 | - max_price = plusCard[ih].CardFee; | |
246 | - name = 'card' + plusCard[ih]['CorrPrice']; | |
247 | - show_card = plusCard[ih]; | |
248 | - } else { | |
249 | - if (max_price < plusCard[ih].CardFee) { | |
237 | + if (res.data.code == 0) { | |
238 | + var plusCard = res.data.data; | |
239 | + //-- 循环判断,拿到最贵的那张卡 -- | |
240 | + for (var ih in plusCard) { | |
241 | + if (plusCard[ih].IsStopBuy == true) { | |
242 | + continue; | |
243 | + } | |
244 | + if (max_price < 0) { | |
250 | 245 | max_price = plusCard[ih].CardFee; |
251 | 246 | name = 'card' + plusCard[ih]['CorrPrice']; |
252 | 247 | show_card = plusCard[ih]; |
248 | + } else { | |
249 | + if (max_price < plusCard[ih].CardFee) { | |
250 | + max_price = plusCard[ih].CardFee; | |
251 | + name = 'card' + plusCard[ih]['CorrPrice']; | |
252 | + show_card = plusCard[ih]; | |
253 | + } | |
253 | 254 | } |
254 | 255 | } |
255 | - } | |
256 | 256 | |
257 | - if (show_card) { | |
258 | - name = name.toLowerCase(); | |
259 | - th.setData({card_name: name, show_card: show_card}) | |
257 | + if (show_card) { | |
258 | + name = name.toLowerCase(); | |
259 | + th.setData({ card_name: name, show_card: show_card }) | |
260 | + } | |
260 | 261 | } |
261 | - } | |
262 | - //-----先获取物流,再获取用户信息,再展示页面----- | |
263 | - th.get_wuliu(th.get_info(th.show_page)); | |
264 | - }) | |
262 | + //-----先获取物流,再获取用户信息,再展示页面----- | |
263 | + th.get_wuliu(th.get_info(th.show_page)); | |
264 | + }) | |
265 | 265 | } else { |
266 | 266 | //-----先获取物流,再获取用户信息,再展示页面----- |
267 | 267 | th.get_wuliu(th.get_info(th.show_page)); |
... | ... | @@ -281,10 +281,10 @@ Page({ |
281 | 281 | if (th.data.is_default_logistics) { |
282 | 282 | //如果第一个不是开启默认,说明要让用户自己选 |
283 | 283 | if (!e[0].is_default) { |
284 | - th.setData({is_default_logistics: 0}); | |
284 | + th.setData({ is_default_logistics: 0 }); | |
285 | 285 | } |
286 | 286 | } |
287 | - th.setData({wu_arr: e}) | |
287 | + th.setData({ wu_arr: e }) | |
288 | 288 | typeof func == "function" && func(); |
289 | 289 | }) |
290 | 290 | }, |
... | ... | @@ -298,7 +298,7 @@ Page({ |
298 | 298 | getuser_addr: function (func) { |
299 | 299 | var th = this; |
300 | 300 | a.get("/api/weshop/useraddress/page", { |
301 | - data: {user_id: to.globalData.user_id, store_id: oo.stoid, pageSize: 600, t: Math.random()}, | |
301 | + data: { user_id: to.globalData.user_id, store_id: oo.stoid, pageSize: 600, t: Math.random() }, | |
302 | 302 | success: function (su) { |
303 | 303 | /*--- |
304 | 304 | var user_addr=[ |
... | ... | @@ -323,7 +323,7 @@ Page({ |
323 | 323 | } |
324 | 324 | |
325 | 325 | if (item == undefined) item = null; |
326 | - if (!item) th.setData({user_addr: null}); //地址为空的时候,要清空,因为返回的时候,有缓存 | |
326 | + if (!item) th.setData({ user_addr: null }); //地址为空的时候,要清空,因为返回的时候,有缓存 | |
327 | 327 | |
328 | 328 | func(item); |
329 | 329 | } |
... | ... | @@ -338,32 +338,32 @@ Page({ |
338 | 338 | //会员的信息,要获取最新 |
339 | 339 | var user = getApp().globalData.userInfo; |
340 | 340 | getApp().request.get("/api/weshop/users/get/" + oo.stoid + "/" + user.user_id, { |
341 | - data: {r: Math.random()}, | |
341 | + data: { r: Math.random() }, | |
342 | 342 | success: function (e) { |
343 | 343 | getApp().globalData.userInfo = e.data.data; |
344 | - th.setData({userinfo: e.data.data}); | |
344 | + th.setData({ userinfo: e.data.data }); | |
345 | 345 | |
346 | 346 | //选获取地址 |
347 | 347 | th.getuser_addr(function (addr) { |
348 | - th.setData({user_addr: addr}); | |
349 | - //--------------------------立即购买------------------ | |
350 | - //读取门店 | |
351 | - to.get_allsto(function (e) { | |
352 | - th.setData({allsto: e}); | |
353 | - //获取立即购买的商品信息 | |
354 | - th.get_buy_goods(); | |
355 | - }); | |
348 | + th.setData({ user_addr: addr }); | |
349 | + //--------------------------立即购买------------------ | |
350 | + //读取门店 | |
351 | + to.get_allsto(function (e) { | |
352 | + th.setData({ allsto: e }); | |
353 | + //获取立即购买的商品信息 | |
354 | + th.get_buy_goods(); | |
355 | + }); | |
356 | 356 | |
357 | 357 | }); |
358 | 358 | |
359 | 359 | //获取提现金额 |
360 | 360 | getApp().request.get("/api/weshop/withdrawals/summoney", { |
361 | - data: {user_id: to.globalData.user_id, store_id: oo.stoid, status: 0}, | |
361 | + data: { user_id: to.globalData.user_id, store_id: oo.stoid, status: 0 }, | |
362 | 362 | success: function (su) { |
363 | 363 | if (su.data.code == 0) { |
364 | 364 | var yuer = parseFloat(th.data.userinfo.user_money - |
365 | 365 | (th.data.userinfo.frozen_money > 0 ? th.data.userinfo.frozen_money : 0) - su.data.data.summoney).toFixed(2); |
366 | - th.setData({txmon: su.data.data.summoney, yuer: yuer}); | |
366 | + th.setData({ txmon: su.data.data.summoney, yuer: yuer }); | |
367 | 367 | } |
368 | 368 | } |
369 | 369 | }); |
... | ... | @@ -379,127 +379,127 @@ Page({ |
379 | 379 | th.data.gg = to.get_b_now(); |
380 | 380 | //--------如果goods_id一样,就是要立即购买----- |
381 | 381 | getApp().request.get("/api/weshop/goods/get/" + oo.stoid + "/" + th.data.gg.goods_id, { |
382 | - success: async function (t) { | |
383 | - var gd = t.data.data; | |
384 | - if (!gd) return false; | |
385 | - | |
386 | - t.data.data.original_img = oo.imghost + t.data.data.original_img; | |
387 | - t.data.data['buynum'] = th.data.gg.goods_num; | |
388 | - var distr_t = 0, et = 0 | |
389 | - if (t.data.data.distr_type == 0) { | |
390 | - distr_t = th.data.gg.pick_dis; | |
391 | - } else { | |
392 | - distr_t = t.data.data.distr_type; | |
393 | - } | |
382 | + success: async function (t) { | |
383 | + var gd = t.data.data; | |
384 | + if (!gd) return false; | |
385 | + | |
386 | + t.data.data.original_img = oo.imghost + t.data.data.original_img; | |
387 | + t.data.data['buynum'] = th.data.gg.goods_num; | |
388 | + var distr_t = 0, et = 0 | |
389 | + if (t.data.data.distr_type == 0) { | |
390 | + distr_t = th.data.gg.pick_dis; | |
391 | + } else { | |
392 | + distr_t = t.data.data.distr_type; | |
393 | + } | |
394 | 394 | |
395 | - switch (distr_t) { | |
396 | - case 0: | |
397 | - et = 1; | |
398 | - //-- 系统后台有设置要默认的 -- | |
399 | - if (th.data.json_d.pickupway && th.data.json_d.pickupway == 1) et = 0; | |
400 | - break; | |
401 | - case 1: | |
402 | - et = 1; | |
403 | - break; | |
404 | - case 2: | |
405 | - et = 0; | |
406 | - break; | |
407 | - } | |
395 | + switch (distr_t) { | |
396 | + case 0: | |
397 | + et = 1; | |
398 | + //-- 系统后台有设置要默认的 -- | |
399 | + if (th.data.json_d.pickupway && th.data.json_d.pickupway == 1) et = 0; | |
400 | + break; | |
401 | + case 1: | |
402 | + et = 1; | |
403 | + break; | |
404 | + case 2: | |
405 | + et = 0; | |
406 | + break; | |
407 | + } | |
408 | 408 | |
409 | 409 | |
410 | - var m_wind = 0, def_exp_code = getApp().globalData.userInfo.def_exp_code; | |
411 | - if (et == 0 && def_exp_code) { | |
412 | - for (var k = 0; k < th.data.wu_arr.length; k++) { | |
413 | - var item = th.data.wu_arr[k]; | |
414 | - if (def_exp_code == item.code) { | |
415 | - m_wind = k; | |
416 | - } | |
410 | + var m_wind = 0, def_exp_code = getApp().globalData.userInfo.def_exp_code; | |
411 | + if (et == 0 && def_exp_code) { | |
412 | + for (var k = 0; k < th.data.wu_arr.length; k++) { | |
413 | + var item = th.data.wu_arr[k]; | |
414 | + if (def_exp_code == item.code) { | |
415 | + m_wind = k; | |
417 | 416 | } |
418 | 417 | } |
418 | + } | |
419 | 419 | |
420 | - if (th.data.bn_goods) { | |
421 | - et = th.data.bn_exp_type; | |
422 | - m_wind = th.data.index; | |
423 | - } | |
420 | + if (th.data.bn_goods) { | |
421 | + et = th.data.bn_exp_type; | |
422 | + m_wind = th.data.index; | |
423 | + } | |
424 | 424 | |
425 | - //---是不是购买等级卡成功的返回---等级卡显示的判断--- | |
426 | - var is_card_back = getApp().globalData.is_card_back; | |
427 | - if (is_card_back) { | |
428 | - th.data.card_name = th.data.userinfo.card_field; | |
429 | - th.data.gg.goods_price = gd[th.data.card_name]; | |
430 | - getApp().globalData.is_card_back = 0; | |
431 | - th.setData({card_cut_price: 0}); | |
432 | - //如果是秒杀的返回 | |
433 | - if (gd.prom_type == 1) gd.prom_type = 0; | |
434 | - } else { | |
435 | - //--- 商家等级卡开通的情况下, 会员不是等级会员的情况, 商品有设置等级卡价格,同时等级卡价格小于商品的价格 | |
436 | - //-- 搭配购的商品也可以单独购买,所以此时搭配购的商品要进行计算优惠 -- | |
437 | - if (!th.data.gg.collocation_goods && gd['prom_type'] != 6 && th.data.card_name && gd[th.data.card_name] > 0 && th.data.gg.goods_price > gd[th.data.card_name] && !th.data.userinfo.card_field) { | |
438 | - var cut_p = (th.data.gg.goods_price - gd[th.data.card_name]) * th.data.gg.goods_num; | |
439 | - th.setData({card_cut_price: cut_p}); | |
440 | - } | |
425 | + //---是不是购买等级卡成功的返回---等级卡显示的判断--- | |
426 | + var is_card_back = getApp().globalData.is_card_back; | |
427 | + if (is_card_back) { | |
428 | + th.data.card_name = th.data.userinfo.card_field; | |
429 | + th.data.gg.goods_price = gd[th.data.card_name]; | |
430 | + getApp().globalData.is_card_back = 0; | |
431 | + th.setData({ card_cut_price: 0 }); | |
432 | + //如果是秒杀的返回 | |
433 | + if (gd.prom_type == 1) gd.prom_type = 0; | |
434 | + } else { | |
435 | + //--- 商家等级卡开通的情况下, 会员不是等级会员的情况, 商品有设置等级卡价格,同时等级卡价格小于商品的价格 | |
436 | + //-- 搭配购的商品也可以单独购买,所以此时搭配购的商品要进行计算优惠 -- | |
437 | + if (!th.data.gg.collocation_goods && gd['prom_type'] != 6 && th.data.card_name && gd[th.data.card_name] > 0 && th.data.gg.goods_price > gd[th.data.card_name] && !th.data.userinfo.card_field) { | |
438 | + var cut_p = (th.data.gg.goods_price - gd[th.data.card_name]) * th.data.gg.goods_num; | |
439 | + th.setData({ card_cut_price: cut_p }); | |
441 | 440 | } |
441 | + } | |
442 | 442 | |
443 | - //定义变量 | |
444 | - var gg = th.data.gg,act = null,prelist = null; | |
445 | - var url = "/api/weshop/marketing/marketingPresellForm/get/" + os.stoid + "/" + gg.prom_id; | |
446 | - await getApp().request.promiseGet(url, {}).then(res => { | |
447 | - if (res.data.code == 0) { | |
448 | - act = res.data.data; | |
449 | - } | |
450 | - }) | |
451 | - if (!act) { | |
452 | - wx.showToast({title: "未找到活动", icon: 'none', duration: 3000}); | |
453 | - return false; | |
454 | - } | |
455 | - if (act.is_end==1 ) { | |
456 | - wx.showToast({title:'活动已经结束' , icon: 'none', duration: 3000}); | |
457 | - return false; | |
458 | - } | |
459 | - if( ut.gettimestamp()>act.end_time){ | |
460 | - wx.showToast({title:"活动定金支付时间已过期" , icon: 'none', duration: 3000}); | |
461 | - return false; | |
443 | + //定义变量 | |
444 | + var gg = th.data.gg, act = null, prelist = null; | |
445 | + var url = "/api/weshop/marketing/marketingPresellForm/get/" + os.stoid + "/" + gg.prom_id; | |
446 | + await getApp().request.promiseGet(url, {}).then(res => { | |
447 | + if (res.data.code == 0) { | |
448 | + act = res.data.data; | |
462 | 449 | } |
450 | + }) | |
451 | + if (!act) { | |
452 | + wx.showToast({ title: "未找到活动", icon: 'none', duration: 3000 }); | |
453 | + return false; | |
454 | + } | |
455 | + if (act.is_end == 1) { | |
456 | + wx.showToast({ title: '活动已经结束', icon: 'none', duration: 3000 }); | |
457 | + return false; | |
458 | + } | |
459 | + if (ut.gettimestamp() > act.end_time) { | |
460 | + wx.showToast({ title: "活动定金支付时间已过期", icon: 'none', duration: 3000 }); | |
461 | + return false; | |
462 | + } | |
463 | 463 | |
464 | - var url = "/api/weshop/marketing/marketingPresellList/get/" + os.stoid + "/" + gg.presell_list_id; | |
465 | - await getApp().request.promiseGet(url, {}).then(res => { | |
466 | - if (res.data.code == 0) { | |
467 | - prelist = res.data.data; | |
468 | - } | |
469 | - }) | |
470 | - if (!prelist) { | |
471 | - wx.showToast({title: "未找到商品", icon: 'none', duration: 3000}); | |
472 | - return false; | |
464 | + var url = "/api/weshop/marketing/marketingPresellList/get/" + os.stoid + "/" + gg.presell_list_id; | |
465 | + await getApp().request.promiseGet(url, {}).then(res => { | |
466 | + if (res.data.code == 0) { | |
467 | + prelist = res.data.data; | |
473 | 468 | } |
469 | + }) | |
470 | + if (!prelist) { | |
471 | + wx.showToast({ title: "未找到商品", icon: 'none', duration: 3000 }); | |
472 | + return false; | |
473 | + } | |
474 | 474 | |
475 | - //这个位置要拿活动的预售价 | |
476 | - t.data.data.shop_price = prelist.presell_money; | |
477 | - th.setData({ | |
478 | - bn_goods: t.data.data, | |
479 | - bn_pickname: gg.pick_name, | |
480 | - bn_exp_type: et, | |
481 | - index: m_wind, | |
482 | - bn_pick: gg.pick_id, | |
483 | - bn_t_exp_t: distr_t, | |
484 | - bn_exp_type: et, | |
485 | - act:act | |
486 | - }); | |
475 | + //这个位置要拿活动的预售价 | |
476 | + t.data.data.shop_price = prelist.presell_money; | |
477 | + th.setData({ | |
478 | + bn_goods: t.data.data, | |
479 | + bn_pickname: gg.pick_name, | |
480 | + bn_exp_type: et, | |
481 | + index: m_wind, | |
482 | + bn_pick: gg.pick_id, | |
483 | + bn_t_exp_t: distr_t, | |
484 | + bn_exp_type: et, | |
485 | + act: act | |
486 | + }); | |
487 | 487 | |
488 | - if(act.is_usecoupon==1){ | |
489 | - th.data.ckeck_quan_price = t.data.data.shop_price * gg.goods_num; | |
490 | - th.data.check_quan_price_list = t.data.data.shop_price * gg.goods_num + ""; | |
491 | - th.data.check_quan_ware_list = t.data.data.erpwareid + ""; | |
492 | - } | |
488 | + if (act.is_usecoupon == 1) { | |
489 | + th.data.ckeck_quan_price = t.data.data.shop_price * gg.goods_num; | |
490 | + th.data.check_quan_price_list = t.data.data.shop_price * gg.goods_num + ""; | |
491 | + th.data.check_quan_ware_list = t.data.data.erpwareid + ""; | |
492 | + } | |
493 | 493 | |
494 | 494 | |
495 | - //计算价格 | |
496 | - th.calculatePrice2(); | |
497 | - //获取优惠券,如果有券的钱,就调用 | |
498 | - if(th.data.ckeck_quan_price>0) th.get_buy_now_quan(); | |
495 | + //计算价格 | |
496 | + th.calculatePrice2(); | |
497 | + //获取优惠券,如果有券的钱,就调用 | |
498 | + if (th.data.ckeck_quan_price > 0) th.get_buy_now_quan(); | |
499 | 499 | |
500 | 500 | |
501 | - }, | |
502 | - }); | |
501 | + }, | |
502 | + }); | |
503 | 503 | |
504 | 504 | }, |
505 | 505 | |
... | ... | @@ -507,14 +507,14 @@ Page({ |
507 | 507 | checkAddressList: function () { |
508 | 508 | var t = this; |
509 | 509 | return !(!this.data.order || null == this.data.order.userAddress) || (wx.showModal({ |
510 | - title: "请先填写或选择收货地址~", | |
511 | - success: function (a) { | |
512 | - a.confirm ? t.enterAddressPage() : wx.navigateBack(); | |
513 | - }, | |
514 | - fail: function () { | |
515 | - wx.navigateBack(); | |
516 | - } | |
517 | - }), !1); | |
510 | + title: "请先填写或选择收货地址~", | |
511 | + success: function (a) { | |
512 | + a.confirm ? t.enterAddressPage() : wx.navigateBack(); | |
513 | + }, | |
514 | + fail: function () { | |
515 | + wx.navigateBack(); | |
516 | + } | |
517 | + }), !1); | |
518 | 518 | }, |
519 | 519 | showInvoice: function () { |
520 | 520 | this.setData({ |
... | ... | @@ -533,7 +533,7 @@ Page({ |
533 | 533 | }, |
534 | 534 | keyUpChangeNum: function (t) { |
535 | 535 | var index = t.currentTarget.dataset.index; |
536 | - var txt="user_note."+index; | |
536 | + var txt = "user_note." + index; | |
537 | 537 | this.setData({ |
538 | 538 | maxWord: t.detail.value.length, |
539 | 539 | [txt]: t.detail.value |
... | ... | @@ -564,7 +564,7 @@ Page({ |
564 | 564 | } |
565 | 565 | } |
566 | 566 | var set_txt = "cartlist[" + iter + "].can_num"; |
567 | - th.setData({[set_txt]: num}); | |
567 | + th.setData({ [set_txt]: num }); | |
568 | 568 | } |
569 | 569 | }, |
570 | 570 | |
... | ... | @@ -595,10 +595,10 @@ Page({ |
595 | 595 | |
596 | 596 | allpice = parseFloat(allpice).toFixed(2); |
597 | 597 | var txt = "formData.all_price"; |
598 | - th.setData({[txt]: allpice,}); | |
598 | + th.setData({ [txt]: allpice, }); | |
599 | 599 | if (cut_price) { |
600 | 600 | var c_txt = "formData.cut_price"; |
601 | - th.setData({[c_txt]: cut_price,}); | |
601 | + th.setData({ [c_txt]: cut_price, }); | |
602 | 602 | |
603 | 603 | } |
604 | 604 | |
... | ... | @@ -612,7 +612,7 @@ Page({ |
612 | 612 | to.getwuliuprice(async function (rs) { |
613 | 613 | |
614 | 614 | var o_shipping_price = 0, goods_weight = -1, goods_piece = -1; |
615 | - var out_of_weight=null; //超出多少重量 | |
615 | + var out_of_weight = null; //超出多少重量 | |
616 | 616 | var freight_free = ee.freight_free; //全场满多少包邮 |
617 | 617 | var weight_free = ee.weight_free; //多少kg内包邮 |
618 | 618 | var no_ex_id = ee.no_ex_id; |
... | ... | @@ -666,7 +666,7 @@ Page({ |
666 | 666 | arr.push(item); |
667 | 667 | } |
668 | 668 | if (arr) { |
669 | - th.setData({get_by_quan_list: arr}); | |
669 | + th.setData({ get_by_quan_list: arr }); | |
670 | 670 | } |
671 | 671 | th.data.isget_by_quan[th.data.bn_pick] = 1; |
672 | 672 | } |
... | ... | @@ -682,8 +682,8 @@ Page({ |
682 | 682 | if (goods_weight < 0) goods_weight = 0; |
683 | 683 | //累积商品重量 每种商品的重量 * 数量 |
684 | 684 | goods_weight += good['weight'] * good['buynum']; |
685 | - if( weight_free > 0){ | |
686 | - out_of_weight = (weight_free * 1000 ) - goods_weight; | |
685 | + if (weight_free > 0) { | |
686 | + out_of_weight = (weight_free * 1000) - goods_weight; | |
687 | 687 | } |
688 | 688 | break; |
689 | 689 | case 3: |
... | ... | @@ -695,18 +695,17 @@ Page({ |
695 | 695 | |
696 | 696 | var code = ""; |
697 | 697 | if (th.data.wu_arr && th.data.wu_arr[th.data.index]) code = th.data.wu_arr[th.data.index].code; |
698 | - | |
698 | + | |
699 | 699 | th.data.is_no_by[th.data.bn_pick] = 0; |
700 | 700 | |
701 | 701 | var no_by_data = null; |
702 | 702 | var gift_freight_free = freight_free; |
703 | 703 | |
704 | - | |
705 | 704 | //有不包邮区域,且不免运费 |
706 | 705 | if (no_ex_id && freight_free > 0 && freight_free <= parseFloat(allpice) - cut_price - quan_price) { |
707 | 706 | //-----------获取不包邮区域,不包邮商品------- |
708 | 707 | await getApp().request.promiseGet("/api/weshop/areaFeemail/getAreaGoods", { |
709 | - data: {store_id: os.stoid, id: no_ex_id} | |
708 | + data: { store_id: os.stoid, id: no_ex_id } | |
710 | 709 | }).then(res => { |
711 | 710 | if (res.data.code == 0 && res.data.data && res.data.data.length > 0) { |
712 | 711 | no_by_data = res.data.data[0]; |
... | ... | @@ -714,7 +713,8 @@ Page({ |
714 | 713 | if (res.data.data[0].region_list) { |
715 | 714 | if (th.check_by_area(res.data.data[0].region_list)) { |
716 | 715 | freight_free = 0; |
717 | - out_of_weight=0; | |
716 | + out_of_weight = 0; | |
717 | + weight_free=-1; | |
718 | 718 | th.data.is_no_by[th.data.bn_pick] = 1; |
719 | 719 | } |
720 | 720 | } |
... | ... | @@ -722,7 +722,8 @@ Page({ |
722 | 722 | if (res.data.data[0].goods_list && freight_free) { |
723 | 723 | if (th.check_by_goods(res.data.data[0].goods_list)) { |
724 | 724 | freight_free = 0; |
725 | - out_of_weight=0; | |
725 | + out_of_weight = 0; | |
726 | + weight_free=-1; | |
726 | 727 | th.data.is_no_by[th.data.bn_pick] = 1; |
727 | 728 | } |
728 | 729 | } |
... | ... | @@ -733,13 +734,13 @@ Page({ |
733 | 734 | th.data.is_by[th.data.bn_pick] = 0; |
734 | 735 | //--------------开始计算物流------------------ |
735 | 736 | var shipping_price = |
736 | - th.calculatewuliu(code, o_shipping_price, goods_weight,out_of_weight, | |
737 | - goods_piece, th.data.user_addr, freight_free, parseFloat(allpice) - cut_price - quan_price, rs); | |
737 | + th.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, | |
738 | + goods_piece, th.data.user_addr, freight_free, parseFloat(allpice) - cut_price - quan_price, rs,th.data.bn_pick); | |
738 | 739 | |
739 | 740 | //如果有赠品的时候,也要计算赠品的物流费用 |
740 | 741 | if (th.data.buy_now_gift_goods) { |
741 | - shipping_price = th.get_now_gift_goods_wuliu(code, o_shipping_price, th.data.user_addr, gift_freight_free,out_of_weight,gift_weight_free, | |
742 | - parseFloat(allpice) - cut_price - quan_price, rs, shipping_price, no_by_data, goods_weight, goods_piece); | |
742 | + shipping_price = th.get_now_gift_goods_wuliu(code, o_shipping_price, th.data.user_addr, gift_freight_free, out_of_weight, gift_weight_free, | |
743 | + parseFloat(allpice) - cut_price - quan_price, rs, shipping_price, no_by_data, goods_weight, goods_piece,th.data.bn_pick); | |
743 | 744 | } |
744 | 745 | |
745 | 746 | if (shipping_price <= 0) { |
... | ... | @@ -748,18 +749,18 @@ Page({ |
748 | 749 | |
749 | 750 | shipping_price = parseFloat(shipping_price).toFixed(2); |
750 | 751 | var wl_txt = "formData.shipping_price"; |
751 | - th.setData({[wl_txt]: shipping_price,}) | |
752 | + th.setData({ [wl_txt]: shipping_price, }) | |
752 | 753 | |
753 | 754 | } else { |
754 | 755 | var wl_txt = "formData.shipping_price"; |
755 | - th.setData({[wl_txt]: 0,}) | |
756 | + th.setData({ [wl_txt]: 0, }) | |
756 | 757 | } |
757 | 758 | |
758 | 759 | if (quan_no) { |
759 | 760 | if (th.data.using_quan[bn_pick].isby == 1) { |
760 | 761 | shipping_price = 0; |
761 | 762 | var wl_txt = "formData.shipping_price"; |
762 | - th.setData({[wl_txt]: 0,}) | |
763 | + th.setData({ [wl_txt]: 0, }) | |
763 | 764 | } |
764 | 765 | } |
765 | 766 | //-----------------支付价,优惠券不减物流----------------- |
... | ... | @@ -778,7 +779,7 @@ Page({ |
778 | 779 | var order_prom_id = 0; |
779 | 780 | if (th.data.order_prom[th.data.bn_pick]) { |
780 | 781 | var ord_prom = th.data.order_prom[th.data.bn_pick]; |
781 | - if(!ord_prom.is_xz_yh || quan_price<=0) { | |
782 | + if (!ord_prom.is_xz_yh || quan_price <= 0) { | |
782 | 783 | order_prom_id = ord_prom['id']; |
783 | 784 | switch (ord_prom['type']) { |
784 | 785 | case 0: |
... | ... | @@ -796,7 +797,7 @@ Page({ |
796 | 797 | if (order_prom_id > 0) { |
797 | 798 | var order_prom_txt1 = "formData.order_prom_id"; |
798 | 799 | var order_prom_txt2 = "formData.order_prom_amount"; |
799 | - th.setData({[order_prom_txt1]: order_prom_id, [order_prom_txt2]: order_prom_amount}) | |
800 | + th.setData({ [order_prom_txt1]: order_prom_id, [order_prom_txt2]: order_prom_amount }) | |
800 | 801 | } |
801 | 802 | |
802 | 803 | total_m = parseFloat(total_m) + parseFloat(th.data.formData.shipping_price); |
... | ... | @@ -806,7 +807,7 @@ Page({ |
806 | 807 | order_m = order_m.toFixed(2); |
807 | 808 | |
808 | 809 | var atxt = "formData.total_amount"; |
809 | - th.setData({[atxt]: total_m,}) | |
810 | + th.setData({ [atxt]: total_m, }) | |
810 | 811 | |
811 | 812 | var txt = "formData.user_money"; |
812 | 813 | var txt2 = "formData.order_amount"; |
... | ... | @@ -816,43 +817,43 @@ Page({ |
816 | 817 | if (th.data.bn_use_money == 1) { |
817 | 818 | if (amoney > order_m) { |
818 | 819 | order_m = parseFloat(order_m).toFixed(2); |
819 | - th.setData({[txt]: order_m, [txt2]: 0, [txt3]: coupon_price, show_submit: 1}) | |
820 | + th.setData({ [txt]: order_m, [txt2]: 0, [txt3]: coupon_price, show_submit: 1 }) | |
820 | 821 | } else { |
821 | 822 | order_m = parseFloat(order_m) - parseFloat(amoney); |
822 | 823 | order_m = order_m.toFixed(2); |
823 | - th.setData({[txt]: amoney, [txt2]: order_m, [txt3]: coupon_price, show_submit: 1}) | |
824 | + th.setData({ [txt]: amoney, [txt2]: order_m, [txt3]: coupon_price, show_submit: 1 }) | |
824 | 825 | } |
825 | 826 | } else { |
826 | - th.setData({[txt]: 0, [txt2]: order_m, [txt3]: coupon_price, show_submit: 1}) | |
827 | + th.setData({ [txt]: 0, [txt2]: order_m, [txt3]: coupon_price, show_submit: 1 }) | |
827 | 828 | } |
828 | 829 | //优惠活动送积分 |
829 | 830 | if (good.s_intValue) { |
830 | 831 | txt = "formData.give_integral"; |
831 | - th.setData({[txt]: good.s_intValue}); | |
832 | + th.setData({ [txt]: good.s_intValue }); | |
832 | 833 | } |
833 | 834 | //优惠送券 |
834 | 835 | if (good.s_coupon_id) { |
835 | 836 | var i_txt = "formData.give_coupon_id"; |
836 | 837 | //这个是json格式的 |
837 | 838 | var i_txt1 = "formData.g_coupon_num"; |
838 | - var ob = [{"num": good.s_coupon_num, "c_id": good.s_coupon_id}]; | |
839 | + var ob = [{ "num": good.s_coupon_num, "c_id": good.s_coupon_id }]; | |
839 | 840 | ob = JSON.stringify(ob); |
840 | - th.setData({[i_txt]: good.s_coupon_id, [i_txt1]: ob}); | |
841 | + th.setData({ [i_txt]: good.s_coupon_id, [i_txt1]: ob }); | |
841 | 842 | } |
842 | 843 | //优惠礼包 |
843 | 844 | if (good.s_libao) { |
844 | 845 | var l_txt = "formData.give_lb_id"; |
845 | 846 | //这个是json格式的 |
846 | 847 | var l_txt1 = "formData.g_lb_num"; |
847 | - var ob = [{"num": good.s_lb_num, "l_id": good.s_libao}]; | |
848 | + var ob = [{ "num": good.s_lb_num, "l_id": good.s_libao }]; | |
848 | 849 | ob = JSON.stringify(ob); |
849 | - th.setData({[l_txt]: good.s_libao, [l_txt1]: ob}); | |
850 | + th.setData({ [l_txt]: good.s_libao, [l_txt1]: ob }); | |
850 | 851 | } |
851 | 852 | }) |
852 | 853 | } else { |
853 | 854 | var order_prom_txt1 = "formData.order_prom_id"; |
854 | 855 | var order_prom_txt2 = "formData.order_prom_amount"; |
855 | - th.setData({[order_prom_txt1]: 0, [order_prom_txt2]: 0}) | |
856 | + th.setData({ [order_prom_txt1]: 0, [order_prom_txt2]: 0 }) | |
856 | 857 | |
857 | 858 | total_m = parseFloat(total_m) + parseFloat(th.data.formData.shipping_price); |
858 | 859 | order_m = parseFloat(order_m) + parseFloat(th.data.formData.shipping_price); |
... | ... | @@ -861,7 +862,7 @@ Page({ |
861 | 862 | total_m = total_m.toFixed(2); |
862 | 863 | order_m = order_m.toFixed(2); |
863 | 864 | |
864 | - th.setData({[atxt]: total_m,}) | |
865 | + th.setData({ [atxt]: total_m, }) | |
865 | 866 | |
866 | 867 | var txt = "formData.user_money"; |
867 | 868 | var txt2 = "formData.order_amount"; |
... | ... | @@ -871,37 +872,37 @@ Page({ |
871 | 872 | if (th.data.bn_use_money == 1) { |
872 | 873 | if (amoney > order_m) { |
873 | 874 | order_m = parseFloat(order_m).toFixed(2); |
874 | - th.setData({[txt]: order_m, [txt2]: 0, [txt3]: coupon_price, show_submit: 1}) | |
875 | + th.setData({ [txt]: order_m, [txt2]: 0, [txt3]: coupon_price, show_submit: 1 }) | |
875 | 876 | } else { |
876 | 877 | order_m = parseFloat(order_m) - parseFloat(amoney); |
877 | 878 | order_m = order_m.toFixed(2); |
878 | - th.setData({[txt]: amoney, [txt2]: order_m, [txt3]: coupon_price, show_submit: 1}) | |
879 | + th.setData({ [txt]: amoney, [txt2]: order_m, [txt3]: coupon_price, show_submit: 1 }) | |
879 | 880 | } |
880 | 881 | } else { |
881 | - th.setData({[txt]: 0, [txt2]: order_m, [txt3]: coupon_price, show_submit: 1}) | |
882 | + th.setData({ [txt]: 0, [txt2]: order_m, [txt3]: coupon_price, show_submit: 1 }) | |
882 | 883 | } |
883 | 884 | //优惠活动送积分 |
884 | 885 | if (good.s_intValue) { |
885 | 886 | txt = "formData.give_integral"; |
886 | - th.setData({[txt]: good.s_intValue}); | |
887 | + th.setData({ [txt]: good.s_intValue }); | |
887 | 888 | } |
888 | 889 | //优惠送券 |
889 | 890 | if (good.s_coupon_id) { |
890 | 891 | var i_txt = "formData.give_coupon_id"; |
891 | 892 | //这个是json格式的 |
892 | 893 | var i_txt1 = "formData.g_coupon_num"; |
893 | - var ob = [{"num": good.s_coupon_num, "c_id": good.s_coupon_id}]; | |
894 | + var ob = [{ "num": good.s_coupon_num, "c_id": good.s_coupon_id }]; | |
894 | 895 | ob = JSON.stringify(ob); |
895 | - th.setData({[i_txt]: good.s_coupon_id, [i_txt1]: ob}); | |
896 | + th.setData({ [i_txt]: good.s_coupon_id, [i_txt1]: ob }); | |
896 | 897 | } |
897 | 898 | //优惠礼包 |
898 | 899 | if (good.s_libao) { |
899 | 900 | var l_txt = "formData.give_lb_id"; |
900 | 901 | //这个是json格式的 |
901 | 902 | var l_txt1 = "formData.g_lb_num"; |
902 | - var ob = [{"num": good.s_lb_num, "l_id": good.s_libao}]; | |
903 | + var ob = [{ "num": good.s_lb_num, "l_id": good.s_libao }]; | |
903 | 904 | ob = JSON.stringify(ob); |
904 | - th.setData({[l_txt]: good.s_coupon_id, [l_txt1]: ob}); | |
905 | + th.setData({ [l_txt]: good.s_coupon_id, [l_txt1]: ob }); | |
905 | 906 | } |
906 | 907 | } |
907 | 908 | |
... | ... | @@ -912,7 +913,7 @@ Page({ |
912 | 913 | }, |
913 | 914 | |
914 | 915 | //--------------------提交订单----------------------- |
915 | - async submitForm(t){ | |
916 | + async submitForm(t) { | |
916 | 917 | var sub_value = t; |
917 | 918 | |
918 | 919 | if (this.data.is_summit_ing == 1) return false; //--提交中退出-- |
... | ... | @@ -985,7 +986,7 @@ Page({ |
985 | 986 | } |
986 | 987 | |
987 | 988 | //--判断优惠活动的提交-- |
988 | - if (th.data.formData.cut_price > 0 ) { | |
989 | + if (th.data.formData.cut_price > 0) { | |
989 | 990 | order_prom_list.discount_amount = th.data.formData.cut_price.toFixed(2); |
990 | 991 | var ob = [{ |
991 | 992 | "prom_id": th.data.bn_goods.prom_id, |
... | ... | @@ -1048,7 +1049,7 @@ Page({ |
1048 | 1049 | goods.guide_id = gg.guide_id; |
1049 | 1050 | goods.guide_type = gg.guide_type; |
1050 | 1051 | //调用接口判断是不是会员 |
1051 | - await getApp().request.promiseGet("/api/weshop/shoppingGuide/getId/" + oo.stoid + "/" + gg.guide_id, {}).then(res => { | |
1052 | + await getApp().request.promiseGet("/api/weshop/shoppingGuide/getId/" + oo.stoid + "/" + gg.guide_id, {}).then(res => { | |
1052 | 1053 | if (res.data.code == 0) { |
1053 | 1054 | goods.guide_name = res.data.data.salesman; |
1054 | 1055 | goods.guide_sn = res.data.data.salesman_no; |
... | ... | @@ -1100,7 +1101,7 @@ Page({ |
1100 | 1101 | } |
1101 | 1102 | |
1102 | 1103 | var pt_res = null; |
1103 | - await getApp().request.promisePost("/api/weshop/order/getGoodsSplit", { | |
1104 | + await getApp().request.promisePost("/api/weshop/order/getGoodsSplit", { | |
1104 | 1105 | is_json: 1, |
1105 | 1106 | data: pt_data |
1106 | 1107 | }).then(res => { |
... | ... | @@ -1220,14 +1221,14 @@ Page({ |
1220 | 1221 | order_prom_list.order_prom_amount = t_item.order_prom_amount; |
1221 | 1222 | } |
1222 | 1223 | |
1223 | - order_prom_list.discount_amount =0; | |
1224 | + order_prom_list.discount_amount = 0; | |
1224 | 1225 | //--判断优惠活动的提交-- |
1225 | 1226 | if (t_item.cut_price > 0) { |
1226 | 1227 | order_prom_list.discount_amount += t_item.cut_price; |
1227 | 1228 | order_prom_list.prom_pt_json = JSON.stringify(t_item.prom_pt_json); |
1228 | 1229 | } |
1229 | 1230 | //--判断组合优惠活动的提交-- |
1230 | - if (t_item.zh_cut_price > 0 || t_item.zh_cut_price<0) { | |
1231 | + if (t_item.zh_cut_price > 0 || t_item.zh_cut_price < 0) { | |
1231 | 1232 | order_prom_list.discount_amount += t_item.zh_cut_price; |
1232 | 1233 | order_prom_list.zh_pt_json = JSON.stringify(t_item.zh_pt_json); |
1233 | 1234 | } |
... | ... | @@ -1242,11 +1243,11 @@ Page({ |
1242 | 1243 | order_prom_list.give_lb_id = t_item.s_libao; |
1243 | 1244 | order_prom_list.g_lb_num = JSON.stringify(t_item.g_lb_num); |
1244 | 1245 | } |
1245 | - if (Object.keys(order_prom_list).length > 0){ | |
1246 | - if(order_prom_list.discount_amount) | |
1247 | - order_prom_list.discount_amount= parseFloat(order_prom_list.discount_amount).toFixed(2); | |
1248 | - if(order_prom_list.order_prom_amount) | |
1249 | - order_prom_list.order_prom_amount= parseFloat(order_prom_list.order_prom_amount).toFixed(2); | |
1246 | + if (Object.keys(order_prom_list).length > 0) { | |
1247 | + if (order_prom_list.discount_amount) | |
1248 | + order_prom_list.discount_amount = parseFloat(order_prom_list.discount_amount).toFixed(2); | |
1249 | + if (order_prom_list.order_prom_amount) | |
1250 | + order_prom_list.order_prom_amount = parseFloat(order_prom_list.order_prom_amount).toFixed(2); | |
1250 | 1251 | item.order_prom_list = order_prom_list; |
1251 | 1252 | } |
1252 | 1253 | |
... | ... | @@ -1270,7 +1271,7 @@ Page({ |
1270 | 1271 | //-------------让商品添加到商品列表-------------------- |
1271 | 1272 | for (var k = 0; k < t_item.goods.length; k++) { |
1272 | 1273 | var g_item = t_item.goods[k]; |
1273 | - if(g_item.goods_num<=0) continue; | |
1274 | + if (g_item.goods_num <= 0) continue; | |
1274 | 1275 | var goods = { |
1275 | 1276 | 'goods_id': g_item.goods_id, |
1276 | 1277 | 'goods_name': g_item.goods_name, |
... | ... | @@ -1283,7 +1284,7 @@ Page({ |
1283 | 1284 | }; |
1284 | 1285 | |
1285 | 1286 | //-- 线下取价也要写入,组合购的商品不能去线下价格 -- |
1286 | - if (g_item.offline_price && t_item.is_offline == 1 && g_item.prom_type!=7) { | |
1287 | + if (g_item.offline_price && t_item.is_offline == 1 && g_item.prom_type != 7) { | |
1287 | 1288 | goods.goods_price = g_item.offline_price; |
1288 | 1289 | goods.member_goods_price = g_item.offline_price; |
1289 | 1290 | goods.offline_cut = (g_item.goods_price - g_item.offline_price).toFixed(2); |
... | ... | @@ -1294,7 +1295,7 @@ Page({ |
1294 | 1295 | if (t_item.quan_youhui_list && t_item.coupon_price) { |
1295 | 1296 | for (var kk in t_item.quan_youhui_list) { |
1296 | 1297 | var you_item = t_item.quan_youhui_list[kk]; |
1297 | - if (g_item.prom_type!=7 && g_item.erpwareid == you_item.WareId) { | |
1298 | + if (g_item.prom_type != 7 && g_item.erpwareid == you_item.WareId) { | |
1298 | 1299 | goods.quan_num = you_item.WareCashSum; |
1299 | 1300 | goods.quan_no = you_item.CashRepNo; |
1300 | 1301 | } |
... | ... | @@ -1345,7 +1346,7 @@ Page({ |
1345 | 1346 | } |
1346 | 1347 | |
1347 | 1348 | //把优惠的平摊结果写进去 |
1348 | - if (g_item.account >= 0 || (g_item.account_yu != 0 && g_item.account!=undefined)) { | |
1349 | + if (g_item.account >= 0 || (g_item.account_yu != 0 && g_item.account != undefined)) { | |
1349 | 1350 | if (g_item.account >= 0) goods.account = g_item.account; |
1350 | 1351 | if (g_item.account_yu != 0) goods.account_yu = g_item.account_yu; |
1351 | 1352 | item.is_discount_amount = 1; |
... | ... | @@ -1356,7 +1357,7 @@ Page({ |
1356 | 1357 | goods.guide_id = g_item.guide_id; |
1357 | 1358 | goods.guide_type = g_item.guide_type; |
1358 | 1359 | //调用接口判断是不是会员 |
1359 | - await getApp().request.promiseGet("/api/weshop/shoppingGuide/getId/" + oo.stoid + "/" + g_item.guide_id, {}).then(res => { | |
1360 | + await getApp().request.promiseGet("/api/weshop/shoppingGuide/getId/" + oo.stoid + "/" + g_item.guide_id, {}).then(res => { | |
1360 | 1361 | if (res.data.code == 0) { |
1361 | 1362 | goods.guide_name = res.data.data.salesman; |
1362 | 1363 | goods.guide_sn = res.data.data.salesman_no; |
... | ... | @@ -1382,7 +1383,7 @@ Page({ |
1382 | 1383 | if (pdata.length == 0) return; |
1383 | 1384 | var str = JSON.stringify(pdata); |
1384 | 1385 | |
1385 | - wx.showLoading({title: "加载中"}); | |
1386 | + wx.showLoading({ title: "加载中" }); | |
1386 | 1387 | wx.request({ |
1387 | 1388 | url: oo.url + '/api/weshop/order/createWxdOrder', |
1388 | 1389 | data: str, |
... | ... | @@ -1413,7 +1414,7 @@ Page({ |
1413 | 1414 | }) |
1414 | 1415 | //要进行判断,如果是用微信支付,就要跳转到支付界面 |
1415 | 1416 | if (order_amount > 0) { |
1416 | - th.setData({isclose: 0}); | |
1417 | + th.setData({ isclose: 0 }); | |
1417 | 1418 | //void e.jumpToCart4({ |
1418 | 1419 | // order_sn: data.data, |
1419 | 1420 | //}, 1); |
... | ... | @@ -1428,12 +1429,12 @@ Page({ |
1428 | 1429 | }, function () { |
1429 | 1430 | //支付失败 |
1430 | 1431 | setTimeout(function () { |
1431 | - var cps=getCurrentPages(); | |
1432 | - if(cps.length>1){ | |
1433 | - wx.navigateBack({delta: 1}) | |
1434 | - }else{ | |
1435 | - getApp().goto("/pages/index/index/index"); | |
1436 | - } | |
1432 | + var cps = getCurrentPages(); | |
1433 | + if (cps.length > 1) { | |
1434 | + wx.navigateBack({ delta: 1 }) | |
1435 | + } else { | |
1436 | + getApp().goto("/pages/index/index/index"); | |
1437 | + } | |
1437 | 1438 | |
1438 | 1439 | }, 1000) |
1439 | 1440 | }, oo.stoid); |
... | ... | @@ -1451,7 +1452,7 @@ Page({ |
1451 | 1452 | if (t.data.code == 0) { |
1452 | 1453 | //app.my_warnning("支付成功",1,th); |
1453 | 1454 | //setTimeout(function () { |
1454 | - th.setData({isclose: 0}); | |
1455 | + th.setData({ isclose: 0 }); | |
1455 | 1456 | wx.redirectTo({ |
1456 | 1457 | url: "/pages/payment/pay_success/pay_success?type=2&order_sn=" + data.data, |
1457 | 1458 | }) |
... | ... | @@ -1476,7 +1477,7 @@ Page({ |
1476 | 1477 | cancelText: '取消', |
1477 | 1478 | confirmText: '确定', |
1478 | 1479 | showCancel: true, |
1479 | - success(res){ | |
1480 | + success(res) { | |
1480 | 1481 | if (res.cancel) { |
1481 | 1482 | return; |
1482 | 1483 | } else if (res.confirm) { |
... | ... | @@ -1510,11 +1511,11 @@ Page({ |
1510 | 1511 | |
1511 | 1512 | }, |
1512 | 1513 | //---确认线下门店的数量足不足--- |
1513 | - async check_store_num(goods_id, pick, goods_num, func){ | |
1514 | + async check_store_num(goods_id, pick, goods_num, func) { | |
1514 | 1515 | var lock = 0, pick_no, plist, erpwareid; |
1515 | 1516 | //先读取门店的lock |
1516 | 1517 | await getApp().request.promiseGet("/api/weshop/order/ware/lock/page", { |
1517 | - data: {store_id: os.stoid, wareId: goods_id, storageId: pick, pageSize: 1000} | |
1518 | + data: { store_id: os.stoid, wareId: goods_id, storageId: pick, pageSize: 1000 } | |
1518 | 1519 | }).then(res => { |
1519 | 1520 | if (res.data.code == 0 && res.data.data.total > 0) { |
1520 | 1521 | for (var i in res.data.data.pageData) |
... | ... | @@ -1523,7 +1524,7 @@ Page({ |
1523 | 1524 | }) |
1524 | 1525 | //先获取门店的编号 |
1525 | 1526 | await getApp().request.promiseGet("/api/weshop/pickup/get/" + os.stoid + "/" + pick, { |
1526 | - data: {storeId: os.stoid, goodsId: t.goods_id, pickupId: pick} | |
1527 | + data: { storeId: os.stoid, goodsId: t.goods_id, pickupId: pick } | |
1527 | 1528 | }).then(res => { |
1528 | 1529 | if (res.data.code == 0) { |
1529 | 1530 | pick_no = res.data.data.pickup_no; |
... | ... | @@ -1531,7 +1532,7 @@ Page({ |
1531 | 1532 | }) |
1532 | 1533 | //先获取商品的线下库存 |
1533 | 1534 | await getApp().request.promiseGet("/api/weshop/goods/get/" + os.stoid + "/" + goods_id, { |
1534 | - data: {storeId: os.stoid, goodsId: t.goods_id, pickupId: pick} | |
1535 | + data: { storeId: os.stoid, goodsId: t.goods_id, pickupId: pick } | |
1535 | 1536 | }).then(res => { |
1536 | 1537 | if (res.data.code == 0) { |
1537 | 1538 | erpwareid = res.data.data.erpwareid; |
... | ... | @@ -1539,7 +1540,7 @@ Page({ |
1539 | 1540 | }) |
1540 | 1541 | //读取线下的门店库存 |
1541 | 1542 | await getApp().request.promiseGet("/api/weshop/goods/getWareStorages", { |
1542 | - data: {storageNos: pick_no, wareIds: encodeURIComponent(erpwareid), storeId: os.stoid, pageSize: 2000} | |
1543 | + data: { storageNos: pick_no, wareIds: encodeURIComponent(erpwareid), storeId: os.stoid, pageSize: 2000 } | |
1543 | 1544 | }).then(res => { |
1544 | 1545 | if (res.data.code == 0) { |
1545 | 1546 | plist = res.data.data.pageData[0]; |
... | ... | @@ -1581,11 +1582,11 @@ Page({ |
1581 | 1582 | wl_txt = t.currentTarget.dataset.wl_txt, |
1582 | 1583 | ont = t.currentTarget.dataset.ont; |
1583 | 1584 | |
1584 | - th.setData({[txt]: ty}); | |
1585 | + th.setData({ [txt]: ty }); | |
1585 | 1586 | var iszt = 1; |
1586 | 1587 | |
1587 | 1588 | if (ty == 0) { |
1588 | - th.setData({is_all_zt: 0}); | |
1589 | + th.setData({ is_all_zt: 0 }); | |
1589 | 1590 | } else { |
1590 | 1591 | for (var i = 0; i < th.data.cartlist.length; i++) { |
1591 | 1592 | var item = th.data.cartlist[i]; |
... | ... | @@ -1595,7 +1596,7 @@ Page({ |
1595 | 1596 | } |
1596 | 1597 | } |
1597 | 1598 | |
1598 | - th.setData({is_all_zt: iszt}); | |
1599 | + th.setData({ is_all_zt: iszt }); | |
1599 | 1600 | |
1600 | 1601 | var ind = t.currentTarget.dataset.ind; |
1601 | 1602 | var c_item = th.data.cartlist[ind]; |
... | ... | @@ -1603,7 +1604,7 @@ Page({ |
1603 | 1604 | |
1604 | 1605 | if (th.data.using_quan[pickid] && th.data.using_quan[pickid].isby == 1) { |
1605 | 1606 | th.data.using_quan[pickid] = {}; |
1606 | - th.setData({using_quan: th.data.using_quan}); | |
1607 | + th.setData({ using_quan: th.data.using_quan }); | |
1607 | 1608 | } |
1608 | 1609 | |
1609 | 1610 | |
... | ... | @@ -1615,7 +1616,7 @@ Page({ |
1615 | 1616 | for (var i = 0; i < wu_arr.length; i++) { |
1616 | 1617 | if (wu_arr[i].shipping_code == def_exp_code) { |
1617 | 1618 | var set_txt = "cartlist" |
1618 | - th.setData({wl_txt: i}); | |
1619 | + th.setData({ wl_txt: i }); | |
1619 | 1620 | } |
1620 | 1621 | } |
1621 | 1622 | } |
... | ... | @@ -1628,9 +1629,9 @@ Page({ |
1628 | 1629 | setexptype: function (t) { |
1629 | 1630 | var th = this; |
1630 | 1631 | var ty = t.currentTarget.dataset.t, def_exp_code = getApp().globalData.userInfo.def_exp_code; |
1631 | - th.setData({bn_exp_type: ty}); | |
1632 | + th.setData({ bn_exp_type: ty }); | |
1632 | 1633 | if (ty == 0) { |
1633 | - th.setData({is_all_zt: 0}); | |
1634 | + th.setData({ is_all_zt: 0 }); | |
1634 | 1635 | } |
1635 | 1636 | |
1636 | 1637 | //当物流为空的时候。 |
... | ... | @@ -1643,7 +1644,7 @@ Page({ |
1643 | 1644 | if (ty == 1) { |
1644 | 1645 | th.data.isget_by_quan = {}; |
1645 | 1646 | if (th.data.using_quan[th.data.bn_pick] && th.data.using_quan[th.data.bn_pick].isby == 1) { |
1646 | - th.setData({using_quan: {}}); | |
1647 | + th.setData({ using_quan: {} }); | |
1647 | 1648 | } |
1648 | 1649 | } |
1649 | 1650 | |
... | ... | @@ -1653,7 +1654,7 @@ Page({ |
1653 | 1654 | if (wu_arr != null && wu_arr != "") { |
1654 | 1655 | for (var i = 0; i < wu_arr.length; i++) { |
1655 | 1656 | if (wu_arr[i].shipping_code == def_exp_code) { |
1656 | - th.setData({index: i}); | |
1657 | + th.setData({ index: i }); | |
1657 | 1658 | } |
1658 | 1659 | } |
1659 | 1660 | } |
... | ... | @@ -1665,17 +1666,17 @@ Page({ |
1665 | 1666 | //--------立即购买时,使用余额-------- |
1666 | 1667 | set_bn_useyuer: function () { |
1667 | 1668 | var th = this; |
1668 | - th.setData({bn_use_money: !th.data.bn_use_money}); | |
1669 | + th.setData({ bn_use_money: !th.data.bn_use_money }); | |
1669 | 1670 | th.calculatePrice2(); |
1670 | 1671 | }, |
1671 | 1672 | set_js_useyuer: function () { |
1672 | 1673 | var th = this; |
1673 | - th.setData({js_use_money: !th.data.js_use_money}); | |
1674 | + th.setData({ js_use_money: !th.data.js_use_money }); | |
1674 | 1675 | th.calculatePrice(); |
1675 | 1676 | }, |
1676 | 1677 | //-------------------计算物流--------------- |
1677 | - calculatewuliu: function (code, o_shipping_price, goods_weight,out_of_weight, | |
1678 | - goods_piece, user_addr, freight_free, o_price, rs) { | |
1678 | + calculatewuliu: function (code, o_shipping_price, goods_weight, out_of_weight, | |
1679 | + goods_piece, user_addr, freight_free, o_price, rs,pickid) { | |
1679 | 1680 | var price = 0, th = this; |
1680 | 1681 | price += parseFloat(o_shipping_price); |
1681 | 1682 | //如果是包邮 |
... | ... | @@ -1706,8 +1707,8 @@ Page({ |
1706 | 1707 | } |
1707 | 1708 | } |
1708 | 1709 | |
1709 | - //------超出重量---------- | |
1710 | - if(out_of_weight < 0 && o_price >= freight_free){ | |
1710 | + //------超出重量---------- | |
1711 | + if (out_of_weight < 0 && o_price >= freight_free && !th.data.is_no_by[pickid]) { | |
1711 | 1712 | fw_price = parseFloat(item['money']); |
1712 | 1713 | var out_of_weight = Math.abs(out_of_weight); |
1713 | 1714 | var n = Math.ceil(out_of_weight / item['second_weight']) |
... | ... | @@ -1750,13 +1751,13 @@ Page({ |
1750 | 1751 | //----------立即购买,选择物流------------- |
1751 | 1752 | bindPickerChange: function (e) { |
1752 | 1753 | var ind = e.detail.value |
1753 | - this.setData({index: ind}); | |
1754 | + this.setData({ index: ind }); | |
1754 | 1755 | this.calculatePrice2(); |
1755 | 1756 | }, |
1756 | 1757 | //----------购物车结算,选择物流------------- |
1757 | 1758 | bindPickerChange_w: function (e) { |
1758 | 1759 | var ind = e.detail.value, txt = e.currentTarget.dataset.txt; |
1759 | - this.setData({[txt]: ind}); | |
1760 | + this.setData({ [txt]: ind }); | |
1760 | 1761 | this.calculatePrice(); |
1761 | 1762 | }, |
1762 | 1763 | |
... | ... | @@ -1770,7 +1771,7 @@ Page({ |
1770 | 1771 | |
1771 | 1772 | |
1772 | 1773 | if (bn == 1) { |
1773 | - th.setData({open_quan: 1, selected_quan_pick: pickid, disabled: 1}); | |
1774 | + th.setData({ open_quan: 1, selected_quan_pick: pickid, disabled: 1 }); | |
1774 | 1775 | } else { |
1775 | 1776 | //---多单打开券的时候,就要判断券在其他门店是否有使用--- |
1776 | 1777 | var quanlist = th.data.cartlist[cindx].quan_list; |
... | ... | @@ -1796,9 +1797,9 @@ Page({ |
1796 | 1797 | else |
1797 | 1798 | get_by_quan_list_cart[i].show_red = 0; |
1798 | 1799 | } |
1799 | - th.setData({by_quan_list_cart: get_by_quan_list_cart}); | |
1800 | + th.setData({ by_quan_list_cart: get_by_quan_list_cart }); | |
1800 | 1801 | } else { |
1801 | - th.setData({by_quan_list_cart: null}); | |
1802 | + th.setData({ by_quan_list_cart: null }); | |
1802 | 1803 | } |
1803 | 1804 | |
1804 | 1805 | console.log("2222222券的列表", quanlist); |
... | ... | @@ -1814,7 +1815,7 @@ Page({ |
1814 | 1815 | }, |
1815 | 1816 | close_coupon: function (e) { |
1816 | 1817 | var th = this; |
1817 | - th.setData({open_quan: 0, disabled: 0}); | |
1818 | + th.setData({ open_quan: 0, disabled: 0 }); | |
1818 | 1819 | }, |
1819 | 1820 | |
1820 | 1821 | //---判断券时候在已经选择的列表中--- |
... | ... | @@ -1885,14 +1886,14 @@ Page({ |
1885 | 1886 | for (var i in quanlist) { |
1886 | 1887 | quanlist[i].show_red = 0; |
1887 | 1888 | } |
1888 | - this.setData({selected_quan_list: quanlist}); | |
1889 | + this.setData({ selected_quan_list: quanlist }); | |
1889 | 1890 | var by_quanlist = this.data.get_by_quan_list; |
1890 | 1891 | if (by_quanlist) { |
1891 | 1892 | //---所有的券的显示红色选择都清理一遍--- |
1892 | 1893 | for (var inb in by_quanlist) { |
1893 | 1894 | by_quanlist[inb].show_red = 0; |
1894 | 1895 | } |
1895 | - this.setData({get_by_quan_list: by_quanlist}); | |
1896 | + this.setData({ get_by_quan_list: by_quanlist }); | |
1896 | 1897 | } |
1897 | 1898 | |
1898 | 1899 | var by_cart_list = this.data.by_quan_list_cart; |
... | ... | @@ -1901,7 +1902,7 @@ Page({ |
1901 | 1902 | for (var inc in by_cart_list) { |
1902 | 1903 | by_cart_list[inc].show_red = 0; |
1903 | 1904 | } |
1904 | - this.setData({by_quan_list_cart: by_cart_list}); | |
1905 | + this.setData({ by_quan_list_cart: by_cart_list }); | |
1905 | 1906 | } |
1906 | 1907 | |
1907 | 1908 | var using_quan = this.data.using_quan; |
... | ... | @@ -1913,9 +1914,9 @@ Page({ |
1913 | 1914 | using_quan[th.data.selected_quan_pick].is_nouse_red = 1; |
1914 | 1915 | } |
1915 | 1916 | else { |
1916 | - using_quan[th.data.selected_quan_pick] = {is_nouse_red: 1}; | |
1917 | + using_quan[th.data.selected_quan_pick] = { is_nouse_red: 1 }; | |
1917 | 1918 | } |
1918 | - this.setData({using_quan: using_quan, is_coupon: 2222}); | |
1919 | + this.setData({ using_quan: using_quan, is_coupon: 2222 }); | |
1919 | 1920 | return; |
1920 | 1921 | } |
1921 | 1922 | |
... | ... | @@ -1932,9 +1933,9 @@ Page({ |
1932 | 1933 | using_quan[th.data.selected_quan_pick].is_nouse_red = 0; |
1933 | 1934 | } |
1934 | 1935 | else { |
1935 | - using_quan[th.data.selected_quan_pick] = {is_nouse_red: 0}; | |
1936 | + using_quan[th.data.selected_quan_pick] = { is_nouse_red: 0 }; | |
1936 | 1937 | } |
1937 | - this.setData({using_quan: using_quan}); | |
1938 | + this.setData({ using_quan: using_quan }); | |
1938 | 1939 | |
1939 | 1940 | }, |
1940 | 1941 | |
... | ... | @@ -1949,7 +1950,7 @@ Page({ |
1949 | 1950 | for (var ind in by_quanlist) { |
1950 | 1951 | by_quanlist[ind].show_red = 0; |
1951 | 1952 | } |
1952 | - this.setData({get_by_quan_list: by_quanlist}); | |
1953 | + this.setData({ get_by_quan_list: by_quanlist }); | |
1953 | 1954 | } |
1954 | 1955 | |
1955 | 1956 | //--购物车过来的包邮券-- |
... | ... | @@ -1959,7 +1960,7 @@ Page({ |
1959 | 1960 | for (var ind in by_cart_list) { |
1960 | 1961 | by_cart_list[ind].show_red = 0; |
1961 | 1962 | } |
1962 | - this.setData({by_quan_list_cart: by_cart_list}); | |
1963 | + this.setData({ by_quan_list_cart: by_cart_list }); | |
1963 | 1964 | } |
1964 | 1965 | //普通券 |
1965 | 1966 | var quanlist = this.data.selected_quan_list; |
... | ... | @@ -1968,7 +1969,7 @@ Page({ |
1968 | 1969 | for (var ind in quanlist) { |
1969 | 1970 | quanlist[ind].show_red = 0; |
1970 | 1971 | } |
1971 | - this.setData({selected_quan_list: quanlist}); | |
1972 | + this.setData({ selected_quan_list: quanlist }); | |
1972 | 1973 | } |
1973 | 1974 | |
1974 | 1975 | var th = this; |
... | ... | @@ -1979,9 +1980,9 @@ Page({ |
1979 | 1980 | using_quan[th.data.selected_quan_pick].is_nouse_red = 1; |
1980 | 1981 | } |
1981 | 1982 | else { |
1982 | - using_quan[th.data.selected_quan_pick] = {is_nouse_red: 1}; | |
1983 | + using_quan[th.data.selected_quan_pick] = { is_nouse_red: 1 }; | |
1983 | 1984 | } |
1984 | - this.setData({using_quan: using_quan, is_coupon: 2222}); | |
1985 | + this.setData({ using_quan: using_quan, is_coupon: 2222 }); | |
1985 | 1986 | return; |
1986 | 1987 | } |
1987 | 1988 | |
... | ... | @@ -1992,20 +1993,20 @@ Page({ |
1992 | 1993 | var txt1 = ""; |
1993 | 1994 | var quan_item = null; |
1994 | 1995 | |
1995 | - quan_item = this.data.get_by_quan_list[ind]; | |
1996 | - txt = "get_by_quan_list[" + ind + "].show_red"; | |
1997 | - var obj = {}; | |
1998 | - obj[txt] = 1; | |
1999 | - this.setData(obj); | |
1996 | + quan_item = this.data.get_by_quan_list[ind]; | |
1997 | + txt = "get_by_quan_list[" + ind + "].show_red"; | |
1998 | + var obj = {}; | |
1999 | + obj[txt] = 1; | |
2000 | + this.setData(obj); | |
2000 | 2001 | |
2001 | 2002 | |
2002 | 2003 | if (using_quan[th.data.selected_quan_pick]) { |
2003 | 2004 | using_quan[th.data.selected_quan_pick].is_nouse_red = 0; |
2004 | 2005 | } |
2005 | 2006 | else { |
2006 | - using_quan[th.data.selected_quan_pick] = {is_nouse_red: 0}; | |
2007 | + using_quan[th.data.selected_quan_pick] = { is_nouse_red: 0 }; | |
2007 | 2008 | } |
2008 | - this.setData({using_quan: using_quan}); | |
2009 | + this.setData({ using_quan: using_quan }); | |
2009 | 2010 | }, |
2010 | 2011 | |
2011 | 2012 | //--确认使用券--- |
... | ... | @@ -2065,14 +2066,14 @@ Page({ |
2065 | 2066 | //选择了的券,看是不是点击了不使用券,点击了不使用优惠券 |
2066 | 2067 | if (using_quan[pickid]) { |
2067 | 2068 | if (using_quan[pickid].is_nouse_red == 1) { |
2068 | - using_quan[pickid] = {is_nouse_red: 1}; | |
2069 | - th.setData({using_quan: using_quan}); | |
2069 | + using_quan[pickid] = { is_nouse_red: 1 }; | |
2070 | + th.setData({ using_quan: using_quan }); | |
2070 | 2071 | if (th.data.is_b_now == 1) { |
2071 | 2072 | th.calculatePrice2(); |
2072 | 2073 | } else { |
2073 | 2074 | th.calculatePrice(); |
2074 | 2075 | } |
2075 | - th.setData({open_quan: 0}); | |
2076 | + th.setData({ open_quan: 0 }); | |
2076 | 2077 | return; |
2077 | 2078 | } |
2078 | 2079 | } |
... | ... | @@ -2091,13 +2092,13 @@ Page({ |
2091 | 2092 | }; |
2092 | 2093 | using_quan[pickid].isby = 1; |
2093 | 2094 | } else { |
2094 | - using_quan[pickid] = {coupon_no: item.CashRepNo, money: item.Sum, is_nouse_red: 0}; | |
2095 | + using_quan[pickid] = { coupon_no: item.CashRepNo, money: item.Sum, is_nouse_red: 0 }; | |
2095 | 2096 | using_quan[pickid].isby = 0; |
2096 | 2097 | } |
2097 | - this.setData({using_quan: using_quan}); | |
2098 | + this.setData({ using_quan: using_quan }); | |
2098 | 2099 | th.calculatePrice2(); |
2099 | 2100 | |
2100 | - th.setData({open_quan: 0}); | |
2101 | + th.setData({ open_quan: 0 }); | |
2101 | 2102 | }, |
2102 | 2103 | |
2103 | 2104 | cart_set_err: function (e) { |
... | ... | @@ -2134,7 +2135,7 @@ Page({ |
2134 | 2135 | var wu_arr_txt = e.currentTarget.dataset.txt; |
2135 | 2136 | var w_sele_index = e.currentTarget.dataset.w_sele_index; |
2136 | 2137 | var is_express = null; |
2137 | - var ob = {open_express: 1, wu_arr_txt: wu_arr_txt, disabled: 1}; | |
2138 | + var ob = { open_express: 1, wu_arr_txt: wu_arr_txt, disabled: 1 }; | |
2138 | 2139 | |
2139 | 2140 | //--如果是多个门店的时候-- |
2140 | 2141 | if (w_sele_index != undefined) { |
... | ... | @@ -2145,20 +2146,20 @@ Page({ |
2145 | 2146 | }, |
2146 | 2147 | // 关闭物流的弹窗 |
2147 | 2148 | close_express: function () { |
2148 | - this.setData({open_express: 0, disabled: 0}); | |
2149 | + this.setData({ open_express: 0, disabled: 0 }); | |
2149 | 2150 | }, |
2150 | 2151 | // 选择物流 |
2151 | 2152 | click_express_name: function (e) { |
2152 | 2153 | var express_name = e.currentTarget.dataset.name, shippingcode = e.currentTarget.dataset.shippingcode; |
2153 | 2154 | var index = e.currentTarget.dataset.idxe; |
2154 | - var ob = {is_express: index, is_shipping_code: shippingcode, disabled: 0}; | |
2155 | + var ob = { is_express: index, is_shipping_code: shippingcode, disabled: 0 }; | |
2155 | 2156 | ob[this.data.wu_arr_txt] = index; |
2156 | 2157 | this.setData(ob); |
2157 | 2158 | }, |
2158 | 2159 | |
2159 | 2160 | //点击确定物流 |
2160 | 2161 | determine_expres: function (e) { |
2161 | - this.setData({open_express: 0}); | |
2162 | + this.setData({ open_express: 0 }); | |
2162 | 2163 | if (this.data.is_b_now == 1) |
2163 | 2164 | this.calculatePrice2(); |
2164 | 2165 | else |
... | ... | @@ -2178,7 +2179,7 @@ Page({ |
2178 | 2179 | obj[txt] = is_open; |
2179 | 2180 | |
2180 | 2181 | this.setData(obj); |
2181 | - this.setData({disabled: 1}) | |
2182 | + this.setData({ disabled: 1 }) | |
2182 | 2183 | }, |
2183 | 2184 | |
2184 | 2185 | clik_coupons2: function (e) { |
... | ... | @@ -2193,7 +2194,7 @@ Page({ |
2193 | 2194 | obj[txt] = is_open; |
2194 | 2195 | |
2195 | 2196 | this.setData(obj); |
2196 | - this.setData({disabled: 1}) | |
2197 | + this.setData({ disabled: 1 }) | |
2197 | 2198 | }, |
2198 | 2199 | |
2199 | 2200 | |
... | ... | @@ -2202,11 +2203,11 @@ Page({ |
2202 | 2203 | var th = this; |
2203 | 2204 | var is_shipping_code = this.data.is_shipping_code |
2204 | 2205 | getApp().request.put("/api/weshop/users/update", { |
2205 | - data: {user_id: getApp().globalData.user_id, store_id: oo.stoid, def_exp_code: is_shipping_code}, | |
2206 | + data: { user_id: getApp().globalData.user_id, store_id: oo.stoid, def_exp_code: is_shipping_code }, | |
2206 | 2207 | success: function (rse) { |
2207 | 2208 | if (rse.data.code == 0) { |
2208 | 2209 | getApp().globalData.userInfo.def_exp_code = is_shipping_code; |
2209 | - th.setData({open_express: 0}); | |
2210 | + th.setData({ open_express: 0 }); | |
2210 | 2211 | //----计算此时购物车的价格---- |
2211 | 2212 | if (th.data.is_b_now == 1) th.calculatePrice2(); |
2212 | 2213 | else th.calculatePrice(); |
... | ... | @@ -2216,7 +2217,7 @@ Page({ |
2216 | 2217 | }, |
2217 | 2218 | |
2218 | 2219 | //更新下默认,在onshow里面 |
2219 | - update_code(){ | |
2220 | + update_code() { | |
2220 | 2221 | var th = this, m_wind = 0, def_exp_code = getApp().globalData.userInfo.def_exp_code; |
2221 | 2222 | //--定时器,判断wu_arr不未空-- |
2222 | 2223 | var uii = setInterval(function () { |
... | ... | @@ -2230,7 +2231,7 @@ Page({ |
2230 | 2231 | } |
2231 | 2232 | //--如果是立即购买-- |
2232 | 2233 | if (th.data.is_b_now == 1) { |
2233 | - th.setData({index: m_wind, is_express: m_wind}); | |
2234 | + th.setData({ index: m_wind, is_express: m_wind }); | |
2234 | 2235 | } else { |
2235 | 2236 | var ui = setInterval(function () { |
2236 | 2237 | if (th.data.cartlist) { |
... | ... | @@ -2238,7 +2239,7 @@ Page({ |
2238 | 2239 | for (var i in c_arr) { |
2239 | 2240 | c_arr[i].wind = m_wind; |
2240 | 2241 | } |
2241 | - th.setData({cartlist: c_arr, is_express: m_wind}) | |
2242 | + th.setData({ cartlist: c_arr, is_express: m_wind }) | |
2242 | 2243 | clearInterval(ui); |
2243 | 2244 | } |
2244 | 2245 | }, 500) |
... | ... | @@ -2339,10 +2340,10 @@ Page({ |
2339 | 2340 | if (th.data.is_b_now) { |
2340 | 2341 | if (arr && arr.length > 0) { |
2341 | 2342 | var quanlist = arr[0].quan_list; |
2342 | - th.setData({selected_quan_list: quanlist, cartlist: arr}) | |
2343 | + th.setData({ selected_quan_list: quanlist, cartlist: arr }) | |
2343 | 2344 | } |
2344 | 2345 | } else { |
2345 | - th.setData({cartlist: arr}) | |
2346 | + th.setData({ cartlist: arr }) | |
2346 | 2347 | th.set_can_num(); |
2347 | 2348 | } |
2348 | 2349 | |
... | ... | @@ -2362,7 +2363,7 @@ Page({ |
2362 | 2363 | if (th.data.is_close_quan != 1 && th.data.bn_goods.is_xz_yh != 1) { |
2363 | 2364 | var url0 = "/api/weshop/users/frozenQuan/listFrozenQuan/" + app.globalData.user_id; |
2364 | 2365 | var url = "/api/weshop/couponList/getUseCouponList"; |
2365 | - app.request.promiseGet(url0, {1: 1}).then(res => { | |
2366 | + app.request.promiseGet(url0, { 1: 1 }).then(res => { | |
2366 | 2367 | if (res.data.code == 0) { |
2367 | 2368 | frozenQuan = res.data.data; |
2368 | 2369 | th.data.frozenQuan = frozenQuan; |
... | ... | @@ -2380,7 +2381,7 @@ Page({ |
2380 | 2381 | quanlist = res.data.data.pageData; |
2381 | 2382 | if (quanlist) { |
2382 | 2383 | quanlist = th.check_is_frozenQuan(quanlist, frozenQuan); |
2383 | - th.setData({selected_quan_list: quanlist}) | |
2384 | + th.setData({ selected_quan_list: quanlist }) | |
2384 | 2385 | } |
2385 | 2386 | } |
2386 | 2387 | } |
... | ... | @@ -2408,7 +2409,7 @@ Page({ |
2408 | 2409 | if (!goods_id) goods_id = this.data.bn_goods.goods_id; |
2409 | 2410 | for (var i in arr) { |
2410 | 2411 | var item = arr[i]; |
2411 | - if (goods_id == item) return 0; | |
2412 | + if (goods_id == item) return 0; | |
2412 | 2413 | } |
2413 | 2414 | return 1; |
2414 | 2415 | }, |
... | ... | @@ -2479,7 +2480,7 @@ Page({ |
2479 | 2480 | pick = this.data.bn_pick; |
2480 | 2481 | //---获取订单优惠--- |
2481 | 2482 | getApp().request.promiseGet("/api/weshop/promorder/getOrderPromotion", { |
2482 | - data: {store_id: os.stoid, orderAmount: condition} | |
2483 | + data: { store_id: os.stoid, orderAmount: condition } | |
2483 | 2484 | }).then(res => { |
2484 | 2485 | if (res.data.code == 0) { |
2485 | 2486 | var data = res.data.data; |
... | ... | @@ -2501,7 +2502,7 @@ Page({ |
2501 | 2502 | var ob = map[pickid][item.prom_id]; |
2502 | 2503 | ob.price += item.goods_price * item.goods_num; |
2503 | 2504 | ob.goods_num += item.goods_num; |
2504 | - ob.goods.push({goods_id: item.goods_id, goods_price: item.goods_price, goods_num: item.goods_num}); | |
2505 | + ob.goods.push({ goods_id: item.goods_id, goods_price: item.goods_price, goods_num: item.goods_num }); | |
2505 | 2506 | |
2506 | 2507 | } else { |
2507 | 2508 | var prom = null; |
... | ... | @@ -2517,7 +2518,7 @@ Page({ |
2517 | 2518 | ob.is_bz = prom.is_bz; |
2518 | 2519 | ob.is_xz_yh = prom.is_xz_yh; |
2519 | 2520 | ob.goods = new Array(); |
2520 | - ob.goods.push({goods_id: item.goods_id, goods_price: item.goods_price, goods_num: item.goods_num}); | |
2521 | + ob.goods.push({ goods_id: item.goods_id, goods_price: item.goods_price, goods_num: item.goods_num }); | |
2521 | 2522 | map[pickid][item.prom_id] = ob; |
2522 | 2523 | } |
2523 | 2524 | } else { |
... | ... | @@ -2534,7 +2535,7 @@ Page({ |
2534 | 2535 | ob.is_bz = prom.is_bz; |
2535 | 2536 | ob.is_xz_yh = prom.is_xz_yh; |
2536 | 2537 | ob.goods = new Array(); |
2537 | - ob.goods.push({goods_id: item.goods_id, goods_price: item.goods_price, goods_num: item.goods_num}); | |
2538 | + ob.goods.push({ goods_id: item.goods_id, goods_price: item.goods_price, goods_num: item.goods_num }); | |
2538 | 2539 | |
2539 | 2540 | var obj = {}; |
2540 | 2541 | obj[item.prom_id] = ob; |
... | ... | @@ -2544,7 +2545,7 @@ Page({ |
2544 | 2545 | }, |
2545 | 2546 | |
2546 | 2547 | //计算立即购买赠品的物流费用 |
2547 | - get_now_gift_goods_wuliu: function (code, o_shipping_price, user_addr, gift_freight_free,gift_weight_free,out_of_weight,allpice, rs, shipping_price, no_by_data, goods_weight1, goods_piece1) { | |
2548 | + get_now_gift_goods_wuliu: function (code, o_shipping_price, user_addr, gift_freight_free, gift_weight_free, out_of_weight, allpice, rs, shipping_price, no_by_data, goods_weight1, goods_piece1,pickid) { | |
2548 | 2549 | var good = this.data.buy_now_gift_goods; |
2549 | 2550 | var goods_weight = -1, goods_piece = -1; |
2550 | 2551 | var gift_shipping_price = 0; |
... | ... | @@ -2560,7 +2561,7 @@ Page({ |
2560 | 2561 | //累积商品重量 每种商品的重量 * 数量 |
2561 | 2562 | goods_weight += good['weight'] * good['buynum']; |
2562 | 2563 | if (goods_weight1 > 0) { |
2563 | - out_of_weight = gift_weight_free - goods_weight; | |
2564 | + out_of_weight = gift_weight_free - goods_weight; | |
2564 | 2565 | //不能调换位置 下面goods_weight会变大 |
2565 | 2566 | goods_weight += goods_weight1; |
2566 | 2567 | } |
... | ... | @@ -2580,7 +2581,7 @@ Page({ |
2580 | 2581 | if (no_by_data && no_by_data.region_list) { |
2581 | 2582 | if (th.check_by_area(no_by_data.region_list)) { |
2582 | 2583 | gift_freight_free = 0; |
2583 | - out_of_weight=0; | |
2584 | + out_of_weight = 0; | |
2584 | 2585 | th.data.is_no_by[th.data.bn_pick] = 1; |
2585 | 2586 | } |
2586 | 2587 | } |
... | ... | @@ -2588,14 +2589,14 @@ Page({ |
2588 | 2589 | if (no_by_data && no_by_data.goods_list && gift_freight_free) { |
2589 | 2590 | if (th.check_by_goods(no_by_data.goods_list, good.goods_id)) { |
2590 | 2591 | gift_freight_free = 0; |
2591 | - out_of_weight=0; | |
2592 | - //th.data.is_no_by[th.data.bn_pick]=1; | |
2592 | + out_of_weight = 0; | |
2593 | + th.data.is_no_by[th.data.bn_pick]=1; | |
2593 | 2594 | } |
2594 | 2595 | } |
2595 | 2596 | |
2596 | 2597 | var t_shipping_price = |
2597 | - this.calculatewuliu(code, gift_shipping_price, goods_weight,out_of_weight, | |
2598 | - goods_piece, user_addr, gift_freight_free, allpice, rs); | |
2598 | + this.calculatewuliu(code, gift_shipping_price, goods_weight, out_of_weight, | |
2599 | + goods_piece, user_addr, gift_freight_free, allpice, rs,th.data.bn_pick); | |
2599 | 2600 | return t_shipping_price; |
2600 | 2601 | |
2601 | 2602 | }, |
... | ... | @@ -2652,7 +2653,7 @@ Page({ |
2652 | 2653 | |
2653 | 2654 | //跳转关闭弹出框的显示 |
2654 | 2655 | close_offline: function () { |
2655 | - this.setData({is_offline_show: 0}); | |
2656 | + this.setData({ is_offline_show: 0 }); | |
2656 | 2657 | }, |
2657 | 2658 | |
2658 | 2659 | //立即购买显示弹出框 |
... | ... | @@ -2660,7 +2661,7 @@ Page({ |
2660 | 2661 | var off_price = this.data.bn_goods.shop_price - this.data.bn_goods.offline_price; |
2661 | 2662 | //是不是线下 |
2662 | 2663 | var is_get_offline = this.data.bn_goods.is_offline; |
2663 | - this.setData({is_offline_show: 1, show_off_price: off_price.toFixed(2), is_get_offline: is_get_offline}); | |
2664 | + this.setData({ is_offline_show: 1, show_off_price: off_price.toFixed(2), is_get_offline: is_get_offline }); | |
2664 | 2665 | }, |
2665 | 2666 | |
2666 | 2667 | //确定使用线下取价 |
... | ... | @@ -2668,14 +2669,14 @@ Page({ |
2668 | 2669 | var bn_goods = this.data.bn_goods; |
2669 | 2670 | if (bn_goods && bn_goods.prom_type == 0) { |
2670 | 2671 | bn_goods.is_offline = 1; |
2671 | - this.setData({is_offline_show: 0, bn_goods: bn_goods}); | |
2672 | + this.setData({ is_offline_show: 0, bn_goods: bn_goods }); | |
2672 | 2673 | this.calculatePrice2(); |
2673 | 2674 | } |
2674 | 2675 | //就是购物车结算时的 |
2675 | 2676 | else { |
2676 | 2677 | var index = this.data.pop_offline_index; |
2677 | 2678 | var txt = "cartlist[" + index + "].is_offline"; |
2678 | - this.setData({[txt]: 1, is_offline_show: 0,}); | |
2679 | + this.setData({ [txt]: 1, is_offline_show: 0, }); | |
2679 | 2680 | this.data.old_cartlist[index].is_offline = 1; |
2680 | 2681 | this.calculatePrice(); |
2681 | 2682 | } |
... | ... | @@ -2688,14 +2689,14 @@ Page({ |
2688 | 2689 | var bn_goods = this.data.bn_goods; |
2689 | 2690 | if (bn_goods && bn_goods.prom_type == 0) { |
2690 | 2691 | bn_goods.is_offline = 0; |
2691 | - this.setData({is_offline_show: 0, bn_goods: bn_goods}); | |
2692 | + this.setData({ is_offline_show: 0, bn_goods: bn_goods }); | |
2692 | 2693 | this.calculatePrice2(); |
2693 | 2694 | } |
2694 | 2695 | //就是购物车结算时的 |
2695 | 2696 | else { |
2696 | 2697 | var index = this.data.pop_offline_index; |
2697 | 2698 | var txt = "cartlist[" + index + "].is_offline"; |
2698 | - this.setData({[txt]: 0, is_offline_show: 0,}) | |
2699 | + this.setData({ [txt]: 0, is_offline_show: 0, }) | |
2699 | 2700 | this.data.old_cartlist[index].is_offline = 0; |
2700 | 2701 | this.calculatePrice(); |
2701 | 2702 | } |
... | ... | @@ -2716,16 +2717,16 @@ Page({ |
2716 | 2717 | }); |
2717 | 2718 | }, |
2718 | 2719 | |
2719 | - set_hid_inp:function (e) { | |
2720 | + set_hid_inp: function (e) { | |
2720 | 2721 | var index = e.currentTarget.dataset.index; |
2721 | 2722 | var txt = "cartlist[" + index + "].focus"; |
2722 | - this.setData({[txt]:1}) | |
2723 | + this.setData({ [txt]: 1 }) | |
2723 | 2724 | }, |
2724 | 2725 | |
2725 | - clear_hid_inp:function (e) { | |
2726 | + clear_hid_inp: function (e) { | |
2726 | 2727 | var index = e.currentTarget.dataset.index; |
2727 | 2728 | var txt = "cartlist[" + index + "].focus"; |
2728 | - this.setData({[txt]:0}) | |
2729 | + this.setData({ [txt]: 0 }) | |
2729 | 2730 | }, |
2730 | 2731 | |
2731 | 2732 | ... | ... |
packageC/pages/presell/cart/cart2_pre.js
1 | -var t = getApp(),app=t, a = t.request, ut = require("../../../../utils/util.js"); | |
2 | -var os=t.globalData.setting; | |
1 | +var t = getApp(), app = t, a = t.request, ut = require("../../../../utils/util.js"); | |
2 | +var os = t.globalData.setting; | |
3 | 3 | var regeneratorRuntime = require('../../../../utils/runtime.js'); |
4 | 4 | var util_pay = require("../../../../utils/pay.js"); |
5 | 5 | |
... | ... | @@ -20,132 +20,132 @@ Page({ |
20 | 20 | enterAddressPage: !1, |
21 | 21 | firstEnter: !0, |
22 | 22 | //页面获取的参数 |
23 | - param:null, | |
24 | - postdata:null, | |
23 | + param: null, | |
24 | + postdata: null, | |
25 | 25 | //提交订单的格式 |
26 | 26 | formData: { |
27 | - order_amount:0,//支付金额 | |
28 | - total_amount:0,//总价 | |
29 | - all_price:0,//商品卖的总价 | |
27 | + order_amount: 0,//支付金额 | |
28 | + total_amount: 0,//总价 | |
29 | + all_price: 0,//商品卖的总价 | |
30 | 30 | pay_points: 0,//使用积分 |
31 | 31 | user_money: 0,//使用余额 |
32 | 32 | couponCode: "",//使用优惠券(多单就用逗号隔开) |
33 | - shipping_price:0,//物流费用 | |
33 | + shipping_price: 0,//物流费用 | |
34 | 34 | }, |
35 | 35 | |
36 | 36 | /*----------------立即购买---------------------*/ |
37 | - is_b_now:0, //0是购物车结算 1立即购买 | |
38 | - bn_goods:null, //立即购买时候的调用商品 | |
39 | - bn_use_money:0,//是否使用余额 | |
40 | - bn_exp_type:1, //0是物流 1自提 | |
41 | - bn_pick:0, //选择的门店 | |
37 | + is_b_now: 0, //0是购物车结算 1立即购买 | |
38 | + bn_goods: null, //立即购买时候的调用商品 | |
39 | + bn_use_money: 0,//是否使用余额 | |
40 | + bn_exp_type: 1, //0是物流 1自提 | |
41 | + bn_pick: 0, //选择的门店 | |
42 | 42 | bn_pickname: "", //选择的门店名称 |
43 | - bn_t_exp_t:0, //判断商品和门店一起决定的物流自提的方式0 都可以 1自提 2物流 | |
43 | + bn_t_exp_t: 0, //判断商品和门店一起决定的物流自提的方式0 都可以 1自提 2物流 | |
44 | 44 | /*------------------------*/ |
45 | - user_addr:null,//物流 | |
46 | - userinfo:null, //获取会员 | |
45 | + user_addr: null,//物流 | |
46 | + userinfo: null, //获取会员 | |
47 | 47 | /*----------物流选择--------*/ |
48 | - wu_arr:null, | |
49 | - index:0, | |
48 | + wu_arr: null, | |
49 | + index: 0, | |
50 | 50 | |
51 | 51 | //判断页面是返回回来的还是 首次进入的 |
52 | - isclose:1, | |
53 | - is_express:0,//选择物流的控制器 | |
54 | - yuer:0, | |
55 | - agree_no_ref:0 | |
52 | + isclose: 1, | |
53 | + is_express: 0,//选择物流的控制器 | |
54 | + yuer: 0, | |
55 | + agree_no_ref: 0 | |
56 | 56 | }, |
57 | - onLoad: function(t) { | |
57 | + onLoad: function (t) { | |
58 | 58 | wx.setNavigationBarTitle({ |
59 | 59 | title: "填写订单", |
60 | 60 | }); |
61 | - var th = this; this.setData({ is_b_now: 1}); | |
62 | - th.data.postdata=getApp().get_b_now(); | |
63 | - th.data.param=t; | |
64 | - | |
61 | + var th = this; this.setData({ is_b_now: 1 }); | |
62 | + th.data.postdata = getApp().get_b_now(); | |
63 | + th.data.param = t; | |
64 | + | |
65 | 65 | }, |
66 | - onUnload: function () { this.setData({ isclose: 1 })}, | |
66 | + onUnload: function () { this.setData({ isclose: 1 }) }, | |
67 | 67 | |
68 | 68 | //------获取会员信息-----先获取用户信息,在进行下一步--- |
69 | - get_info:function(func){ | |
70 | - var user_id = t.globalData.user_id; | |
71 | - app.auth.get_u(func); | |
69 | + get_info: function (func) { | |
70 | + var user_id = t.globalData.user_id; | |
71 | + app.auth.get_u(func); | |
72 | 72 | }, |
73 | 73 | |
74 | 74 | //-------------------获取物流--------------- |
75 | 75 | get_wuliu(func) { |
76 | - var th = this; | |
77 | - app.getwuliu(function (e) { | |
78 | - if (th.data.is_default_logistics) { | |
79 | - //如果第一个不是开启默认,说明要让用户自己选 | |
80 | - if (!e[0].is_default) { | |
81 | - th.setData({ is_default_logistics: 0 }); | |
82 | - } | |
83 | - } | |
84 | - th.setData({ wu_arr: e }) | |
85 | - typeof func == "function" && func(); | |
86 | - }) | |
76 | + var th = this; | |
77 | + app.getwuliu(function (e) { | |
78 | + if (th.data.is_default_logistics) { | |
79 | + //如果第一个不是开启默认,说明要让用户自己选 | |
80 | + if (!e[0].is_default) { | |
81 | + th.setData({ is_default_logistics: 0 }); | |
82 | + } | |
83 | + } | |
84 | + th.setData({ wu_arr: e }) | |
85 | + typeof func == "function" && func(); | |
86 | + }) | |
87 | 87 | }, |
88 | 88 | |
89 | 89 | //------获取会员收货地址----- |
90 | - getuser_addr:function(func){ | |
91 | - if (app.globalData.baddr!=null){ | |
92 | - var user_addr =app.globalData.baddr; | |
93 | - app.globalData.baddr=null; | |
94 | - func(user_addr); | |
95 | - }else{ | |
96 | - a.get("/api/weshop/useraddress/page", { | |
97 | - data: { user_id:app.globalData.user_id, store_id: os.stoid, pageSize: 600 }, | |
98 | - success: function (su) { | |
99 | - | |
100 | - var user_addr = su.data.data.pageData; | |
101 | - var item = null; | |
102 | - var def_item=null; | |
103 | - for (var i = 0; i < user_addr.length; i++) { | |
104 | - if (user_addr[i]['is_default'] == 1) { def_item = user_addr[i]; } | |
105 | - if (user_addr[i]['is_pickup'] == 1) { item = user_addr[i]; } | |
106 | - } | |
107 | - if (item == null) item = def_item; | |
108 | - if (item == null) item = user_addr[0]; | |
109 | - if (item == undefined) item = null; | |
110 | - func(item); | |
111 | - } | |
112 | - }); | |
113 | - } | |
90 | + getuser_addr: function (func) { | |
91 | + if (app.globalData.baddr != null) { | |
92 | + var user_addr = app.globalData.baddr; | |
93 | + app.globalData.baddr = null; | |
94 | + func(user_addr); | |
95 | + } else { | |
96 | + a.get("/api/weshop/useraddress/page", { | |
97 | + data: { user_id: app.globalData.user_id, store_id: os.stoid, pageSize: 600 }, | |
98 | + success: function (su) { | |
99 | + | |
100 | + var user_addr = su.data.data.pageData; | |
101 | + var item = null; | |
102 | + var def_item = null; | |
103 | + for (var i = 0; i < user_addr.length; i++) { | |
104 | + if (user_addr[i]['is_default'] == 1) { def_item = user_addr[i]; } | |
105 | + if (user_addr[i]['is_pickup'] == 1) { item = user_addr[i]; } | |
106 | + } | |
107 | + if (item == null) item = def_item; | |
108 | + if (item == null) item = user_addr[0]; | |
109 | + if (item == undefined) item = null; | |
110 | + func(item); | |
111 | + } | |
112 | + }); | |
113 | + } | |
114 | 114 | }, |
115 | 115 | //----------------展示页面,是再获取用户信息之后-------------- |
116 | - show_page:function(){ | |
117 | - var th=this; | |
118 | - var user=getApp().globalData.userInfo; | |
119 | - getApp().request.get("/api/weshop/users/get/" + os.stoid + "/" + user.user_id, { | |
120 | - data:{r:Math.random()}, | |
121 | - success: function (e) { | |
122 | - | |
123 | - getApp().globalData.userInfo = e.data.data; | |
124 | - th.setData({userinfo:e.data.data}); | |
125 | - //获取立即购买的商品信息 | |
126 | - th.get_buy_goods(); | |
127 | - | |
128 | - //获取提现金额 | |
129 | - getApp().request.get("/api/weshop/withdrawals/summoney", { | |
130 | - data: { user_id:app.globalData.user_id, store_id: os.stoid, status: 0 }, | |
131 | - success: function (su) { | |
132 | - if (su.data.code == 0) { | |
133 | - var yuer = parseFloat(th.data.userinfo.user_money - | |
134 | - (th.data.userinfo.frozen_money>0?th.data.userinfo.frozen_money:0) - su.data.data.summoney).toFixed(2); | |
135 | - if(yuer<0) yuer=0; | |
136 | - th.setData({ txmon: su.data.data.summoney, yuer: yuer }); | |
137 | - } | |
138 | - } | |
139 | - }); | |
140 | - } | |
141 | - }); | |
116 | + show_page: function () { | |
117 | + var th = this; | |
118 | + var user = getApp().globalData.userInfo; | |
119 | + getApp().request.get("/api/weshop/users/get/" + os.stoid + "/" + user.user_id, { | |
120 | + data: { r: Math.random() }, | |
121 | + success: function (e) { | |
122 | + | |
123 | + getApp().globalData.userInfo = e.data.data; | |
124 | + th.setData({ userinfo: e.data.data }); | |
125 | + //获取立即购买的商品信息 | |
126 | + th.get_buy_goods(); | |
127 | + | |
128 | + //获取提现金额 | |
129 | + getApp().request.get("/api/weshop/withdrawals/summoney", { | |
130 | + data: { user_id: app.globalData.user_id, store_id: os.stoid, status: 0 }, | |
131 | + success: function (su) { | |
132 | + if (su.data.code == 0) { | |
133 | + var yuer = parseFloat(th.data.userinfo.user_money - | |
134 | + (th.data.userinfo.frozen_money > 0 ? th.data.userinfo.frozen_money : 0) - su.data.data.summoney).toFixed(2); | |
135 | + if (yuer < 0) yuer = 0; | |
136 | + th.setData({ txmon: su.data.data.summoney, yuer: yuer }); | |
137 | + } | |
138 | + } | |
139 | + }); | |
140 | + } | |
141 | + }); | |
142 | 142 | }, |
143 | 143 | |
144 | 144 | //-----获取立即购买的商品信息---- |
145 | 145 | get_buy_goods: async function () { |
146 | 146 | var th = this, a = getApp().request; |
147 | 147 | //定义变量 |
148 | - var gg = th.data.postdata,act = null,prelist = null; | |
148 | + var gg = th.data.postdata, act = null, prelist = null; | |
149 | 149 | var url = "/api/weshop/marketing/marketingPresellForm/get/" + os.stoid + "/" + gg.prom_id; |
150 | 150 | await getApp().request.promiseGet(url, {}).then(res => { |
151 | 151 | if (res.data.code == 0) { |
... | ... | @@ -153,15 +153,15 @@ Page({ |
153 | 153 | } |
154 | 154 | }) |
155 | 155 | if (!act) { |
156 | - wx.showToast({title: "未找到活动", icon: 'none', duration: 3000}); | |
156 | + wx.showToast({ title: "未找到活动", icon: 'none', duration: 3000 }); | |
157 | 157 | return false; |
158 | 158 | } |
159 | - if (act.is_end==1 ) { | |
160 | - wx.showToast({title:'活动已经结束' , icon: 'none', duration: 3000}); | |
159 | + if (act.is_end == 1) { | |
160 | + wx.showToast({ title: '活动已经结束', icon: 'none', duration: 3000 }); | |
161 | 161 | return false; |
162 | 162 | } |
163 | - if( ut.gettimestamp()>act.end_time){ | |
164 | - wx.showToast({title:"活动定金支付时间已过期" , icon: 'none', duration: 3000}); | |
163 | + if (ut.gettimestamp() > act.end_time) { | |
164 | + wx.showToast({ title: "活动定金支付时间已过期", icon: 'none', duration: 3000 }); | |
165 | 165 | return false; |
166 | 166 | } |
167 | 167 | |
... | ... | @@ -172,7 +172,7 @@ Page({ |
172 | 172 | } |
173 | 173 | }) |
174 | 174 | if (!prelist) { |
175 | - wx.showToast({title: "未找到商品", icon: 'none', duration: 3000}); | |
175 | + wx.showToast({ title: "未找到商品", icon: 'none', duration: 3000 }); | |
176 | 176 | return false; |
177 | 177 | } |
178 | 178 | //-- 调用商品 -- |
... | ... | @@ -191,7 +191,7 @@ Page({ |
191 | 191 | distr_t = t.data.data.distr_type; |
192 | 192 | } |
193 | 193 | |
194 | - if(act.presell_type==1){ | |
194 | + if (act.presell_type == 1) { | |
195 | 195 | switch (distr_t) { |
196 | 196 | case 0: |
197 | 197 | et = 1; |
... | ... | @@ -205,13 +205,13 @@ Page({ |
205 | 205 | et = 0; |
206 | 206 | break; |
207 | 207 | } |
208 | - }else{ | |
209 | - et=1; //要付定金的时候 | |
208 | + } else { | |
209 | + et = 1; //要付定金的时候 | |
210 | 210 | } |
211 | 211 | |
212 | 212 | t.data.data.shop_price = prelist.presell_money; |
213 | 213 | th.setData({ |
214 | - bn_goods: t.data.data, bn_pickname: gg.pick_name,prelist:prelist,act:act, | |
214 | + bn_goods: t.data.data, bn_pickname: gg.pick_name, prelist: prelist, act: act, | |
215 | 215 | bn_pick: gg.pick_id, bn_t_exp_t: distr_t, bn_exp_type: et |
216 | 216 | }); |
217 | 217 | //计算价格 |
... | ... | @@ -222,270 +222,269 @@ Page({ |
222 | 222 | |
223 | 223 | //----------子页返回父页触发---------- |
224 | 224 | onShow: function () { |
225 | - var th = this; | |
226 | - if (th.data.isclose == 0) { | |
227 | - wx.navigateTo({ | |
228 | - url: "/pages/index/index/index" | |
229 | - }) | |
230 | - } else { | |
231 | - this.getuser_addr(function (ie) { | |
232 | - //更换地址回来要重新调用计算价钱的接口 | |
233 | - th.setData({ user_addr: ie }); | |
234 | - if (!th.data.user_addr || th.data.user_addr.address_id != ie.address_id) { | |
235 | - th.setData({ add_back: 1 }); | |
236 | - if (this.data.bn_goods) th.calculatePrice2(); | |
237 | - } | |
238 | - }) | |
239 | - //--更新默认地址--,看一下是不是跳到地址页面 | |
240 | - if (!getApp().globalData.is_cart_old) { | |
241 | - this.update_code(); | |
225 | + var th = this; | |
226 | + if (th.data.isclose == 0) { | |
227 | + wx.navigateTo({ | |
228 | + url: "/pages/index/index/index" | |
229 | + }) | |
242 | 230 | } else { |
243 | - getApp().globalData.is_cart_old = 0; | |
244 | - } | |
245 | - } | |
246 | - | |
247 | - //先获取是否有关闭使用优惠券 | |
248 | - getApp().getConfig2(function (ee) { | |
249 | - var json_d = JSON.parse(ee.switch_list); | |
250 | - th.data.json_d = json_d; | |
251 | - th.data.ispt_goods = json_d.ispt_goods; //是不是平摊到单品的控制参数赋值 | |
252 | - var is_default_logistics = json_d.is_default_logistics; | |
253 | - | |
254 | - th.setData({ is_close_quan: json_d.is_close_quan, sales_rules: ee.sales_rules, rank_switch: json_d.rank_switch, is_default_logistics: is_default_logistics }); | |
255 | - | |
256 | - var rank_switch = json_d.rank_switch; | |
257 | - var max_price = -1; | |
258 | - var show_card = null; | |
259 | - var name = ""; | |
260 | - //如果有开等级卡的时候, | |
261 | - //因为都是调接口,要返回在计算 | |
262 | - if (rank_switch == 2) { | |
263 | - //-- 获取所有的等级卡, -- | |
264 | - getApp().request.promiseGet("/api/weshop/plus/vip/mem/bership/list?storeId=" + os.stoid, | |
265 | - {}).then(res => { | |
266 | - if (res.data.code == 0) { | |
267 | - var plusCard = res.data.data; | |
268 | - //-- 循环判断,拿到最贵的那张卡 -- | |
269 | - for (var ih in plusCard) { | |
270 | - if (plusCard[ih].IsStopBuy == true) { continue; } | |
271 | - if (max_price < 0) { | |
272 | - max_price = plusCard[ih].CardFee; | |
273 | - name = 'card' + plusCard[ih]['CorrPrice']; | |
274 | - show_card = plusCard[ih]; | |
275 | - } else { | |
276 | - if (max_price < plusCard[ih].CardFee) { | |
277 | - max_price = plusCard[ih].CardFee; | |
278 | - name = 'card' + plusCard[ih]['CorrPrice']; | |
279 | - show_card = plusCard[ih]; | |
280 | - } | |
281 | - } | |
282 | - } | |
283 | - | |
284 | - if (show_card) { | |
285 | - name = name.toLowerCase(); | |
286 | - th.setData({ card_name: name, show_card: show_card }) | |
231 | + this.getuser_addr(function (ie) { | |
232 | + //更换地址回来要重新调用计算价钱的接口 | |
233 | + th.setData({ user_addr: ie }); | |
234 | + if (!th.data.user_addr || th.data.user_addr.address_id != ie.address_id) { | |
235 | + th.setData({ add_back: 1 }); | |
236 | + if (this.data.bn_goods) th.calculatePrice2(); | |
287 | 237 | } |
288 | - } | |
289 | - //-----先获取物流,再获取用户信息,再展示页面----- | |
290 | - th.get_wuliu(th.get_info(th.show_page)); | |
291 | 238 | }) |
292 | - } else { | |
293 | - //-----先获取物流,再获取用户信息,再展示页面----- | |
294 | - th.get_wuliu(th.get_info(th.show_page)); | |
239 | + //--更新默认地址--,看一下是不是跳到地址页面 | |
240 | + if (!getApp().globalData.is_cart_old) { | |
241 | + this.update_code(); | |
242 | + } else { | |
243 | + getApp().globalData.is_cart_old = 0; | |
244 | + } | |
295 | 245 | } |
296 | - }, 1) | |
246 | + | |
247 | + //先获取是否有关闭使用优惠券 | |
248 | + getApp().getConfig2(function (ee) { | |
249 | + var json_d = JSON.parse(ee.switch_list); | |
250 | + th.data.json_d = json_d; | |
251 | + th.data.ispt_goods = json_d.ispt_goods; //是不是平摊到单品的控制参数赋值 | |
252 | + var is_default_logistics = json_d.is_default_logistics; | |
253 | + | |
254 | + th.setData({ is_close_quan: json_d.is_close_quan, sales_rules: ee.sales_rules, rank_switch: json_d.rank_switch, is_default_logistics: is_default_logistics }); | |
255 | + | |
256 | + var rank_switch = json_d.rank_switch; | |
257 | + var max_price = -1; | |
258 | + var show_card = null; | |
259 | + var name = ""; | |
260 | + //如果有开等级卡的时候, | |
261 | + //因为都是调接口,要返回在计算 | |
262 | + if (rank_switch == 2) { | |
263 | + //-- 获取所有的等级卡, -- | |
264 | + getApp().request.promiseGet("/api/weshop/plus/vip/mem/bership/list?storeId=" + os.stoid, | |
265 | + {}).then(res => { | |
266 | + if (res.data.code == 0) { | |
267 | + var plusCard = res.data.data; | |
268 | + //-- 循环判断,拿到最贵的那张卡 -- | |
269 | + for (var ih in plusCard) { | |
270 | + if (plusCard[ih].IsStopBuy == true) { continue; } | |
271 | + if (max_price < 0) { | |
272 | + max_price = plusCard[ih].CardFee; | |
273 | + name = 'card' + plusCard[ih]['CorrPrice']; | |
274 | + show_card = plusCard[ih]; | |
275 | + } else { | |
276 | + if (max_price < plusCard[ih].CardFee) { | |
277 | + max_price = plusCard[ih].CardFee; | |
278 | + name = 'card' + plusCard[ih]['CorrPrice']; | |
279 | + show_card = plusCard[ih]; | |
280 | + } | |
281 | + } | |
282 | + } | |
283 | + | |
284 | + if (show_card) { | |
285 | + name = name.toLowerCase(); | |
286 | + th.setData({ card_name: name, show_card: show_card }) | |
287 | + } | |
288 | + } | |
289 | + //-----先获取物流,再获取用户信息,再展示页面----- | |
290 | + th.get_wuliu(th.get_info(th.show_page)); | |
291 | + }) | |
292 | + } else { | |
293 | + //-----先获取物流,再获取用户信息,再展示页面----- | |
294 | + th.get_wuliu(th.get_info(th.show_page)); | |
295 | + } | |
296 | + }, 1) | |
297 | 297 | |
298 | 298 | }, |
299 | 299 | //---------------检查是否有收货地址------------------- |
300 | - checkAddressList: function() { | |
300 | + checkAddressList: function () { | |
301 | 301 | var t = this; |
302 | 302 | return !(!this.data.order || null == this.data.order.userAddress) || (wx.showModal({ |
303 | 303 | title: "请先填写或选择收货地址~", |
304 | - success: function(a) { | |
304 | + success: function (a) { | |
305 | 305 | a.confirm ? t.enterAddressPage() : wx.navigateBack(); |
306 | 306 | }, |
307 | - fail: function() { | |
307 | + fail: function () { | |
308 | 308 | wx.navigateBack(); |
309 | 309 | } |
310 | 310 | }), !1); |
311 | 311 | }, |
312 | - showInvoice: function() { | |
312 | + showInvoice: function () { | |
313 | 313 | this.setData({ |
314 | 314 | invoiceToggle: !this.data.invoiceToggle |
315 | 315 | }); |
316 | 316 | }, |
317 | - keyUpChangePay1: function(t) { | |
317 | + keyUpChangePay1: function (t) { | |
318 | 318 | this.setData({ |
319 | 319 | payWithUserMoney: !(t.detail.value.length > 0) |
320 | 320 | }); |
321 | 321 | }, |
322 | - keyUpChangePay2: function(t) { | |
322 | + keyUpChangePay2: function (t) { | |
323 | 323 | this.setData({ |
324 | 324 | payWithPoints: !(t.detail.value.length > 0) |
325 | 325 | }); |
326 | 326 | }, |
327 | - keyUpChangeNum: function(t) { | |
327 | + keyUpChangeNum: function (t) { | |
328 | 328 | this.setData({ |
329 | 329 | maxWord: t.detail.value.length |
330 | 330 | }); |
331 | 331 | }, |
332 | 332 | //---------计算立即购买---------- |
333 | 333 | calculatePrice2: function () { |
334 | - console.log('calculatePrice2'); | |
335 | - var th = this, good = this.data.bn_goods; | |
336 | - //-----------计算商品总价-------------- | |
337 | - var allpice = good.shop_price * good.buynum; | |
338 | - allpice=parseFloat(allpice).toFixed(2); | |
339 | - var txt = "formData.all_price"; | |
340 | - th.setData({ [txt]: allpice, }); | |
341 | - console.log(th.data.formData); | |
342 | - | |
343 | - app.getConfig2(function (ee) { | |
344 | - app.getwuliuprice(function (rs) { | |
334 | + console.log('calculatePrice2'); | |
335 | + var th = this, good = this.data.bn_goods; | |
336 | + //-----------计算商品总价-------------- | |
337 | + var allpice = good.shop_price * good.buynum; | |
338 | + allpice = parseFloat(allpice).toFixed(2); | |
339 | + var txt = "formData.all_price"; | |
340 | + th.setData({ [txt]: allpice, }); | |
341 | + console.log(th.data.formData); | |
342 | + | |
343 | + app.getConfig2(function (ee) { | |
344 | + app.getwuliuprice(function (rs) { | |
345 | 345 | var o_shipping_price = 0, goods_weight = -1, goods_piece = -1; |
346 | - var out_of_weight=null; //超出多少重量 | |
346 | + var out_of_weight = null; //超出多少重量 | |
347 | 347 | var freight_free = ee.freight_free; //全场满多少包邮 |
348 | 348 | var weight_free = ee.weight_free; //多少kg内包邮 |
349 | 349 | var no_ex_id = ee.no_ex_id; |
350 | - //-----------当地址不为空,且是物流时,计算物流费用,同时阶梯团不计算拼团价格---------- | |
351 | - if (th.data.user_addr != null && th.data.bn_exp_type == 0 | |
352 | - && good.is_free_shipping == 0 && (th.data.kt_type!=3 || th.data.bn_goods.is_normal==1) ){ | |
353 | - switch (good['exp_sum_type']) { | |
354 | - case 1: | |
355 | - //统一运费 | |
356 | - o_shipping_price += good['uniform_exp_sum']; break; | |
357 | - case 2: | |
358 | - if (goods_weight < 0) goods_weight = 0; | |
359 | - //累积商品重量 每种商品的重量 * 数量 | |
360 | - goods_weight += good['weight'] * good['buynum']; | |
361 | - if(weight_free > 0){ | |
362 | - out_of_weight = (weight_free * 1000 ) - goods_weight; | |
363 | - } | |
364 | - break; | |
365 | - case 3: | |
366 | - if (goods_piece < 0) goods_piece = 0; | |
367 | - //累积商品数量 | |
368 | - goods_piece += good['buynum']; break; | |
369 | - } | |
370 | - | |
371 | - var code = th.data.wu_arr[th.data.index].code; | |
372 | - var shipping_price= | |
373 | - th.calculatewuliu(code, o_shipping_price, goods_weight,out_of_weight, | |
350 | + //-----------当地址不为空,且是物流时,计算物流费用,同时阶梯团不计算拼团价格---------- | |
351 | + if (th.data.user_addr != null && th.data.bn_exp_type == 0 | |
352 | + && good.is_free_shipping == 0 && (th.data.kt_type != 3 || th.data.bn_goods.is_normal == 1)) { | |
353 | + switch (good['exp_sum_type']) { | |
354 | + case 1: | |
355 | + //统一运费 | |
356 | + o_shipping_price += good['uniform_exp_sum']; break; | |
357 | + case 2: | |
358 | + if (goods_weight < 0) goods_weight = 0; | |
359 | + //累积商品重量 每种商品的重量 * 数量 | |
360 | + goods_weight += good['weight'] * good['buynum']; | |
361 | + if (weight_free > 0) { | |
362 | + out_of_weight = (weight_free * 1000) - goods_weight; | |
363 | + } | |
364 | + break; | |
365 | + case 3: | |
366 | + if (goods_piece < 0) goods_piece = 0; | |
367 | + //累积商品数量 | |
368 | + goods_piece += good['buynum']; break; | |
369 | + } | |
370 | + | |
371 | + var code = th.data.wu_arr[th.data.index].code; | |
372 | + var shipping_price = | |
373 | + th.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, | |
374 | 374 | goods_piece, th.data.user_addr, freight_free, allpice, rs); |
375 | 375 | |
376 | - shipping_price = parseFloat(shipping_price).toFixed(2); | |
377 | - var wl_txt = "formData.shipping_price"; | |
378 | - th.setData({ [wl_txt]: shipping_price, }) | |
379 | - | |
380 | - }else{ | |
381 | - var wl_txt = "formData.shipping_price"; | |
382 | - th.setData({ [wl_txt]: 0, }) | |
383 | - } | |
384 | - //-----------------总价----------------- | |
385 | - var total_m = parseFloat(allpice) + parseFloat( th.data.formData.shipping_price); | |
386 | - total_m = parseFloat(total_m).toFixed(2); | |
387 | - | |
388 | - var atxt= "formData.total_amount"; | |
389 | - th.setData({ [atxt]: total_m, }) | |
390 | - var order_m = total_m; | |
391 | - | |
392 | - var txt = "formData.user_money"; | |
393 | - var txt2 = "formData.order_amount"; | |
394 | - //--------------如果使用余额--------------------- | |
395 | - if (th.data.bn_use_money == 1 && th.data.yuer>0) { | |
396 | - if ( parseFloat(th.data.yuer) > total_m) { | |
397 | - th.setData({ [txt]: total_m, [txt2]:0 }) | |
398 | - }else{ | |
399 | - order_m = parseFloat(order_m) - parseFloat(th.data.yuer); | |
400 | - order_m = order_m.toFixed(2); | |
401 | - th.setData({ [txt]: th.data.yuer, [txt2]: order_m }) | |
402 | - } | |
403 | - }else{ | |
376 | + shipping_price = parseFloat(shipping_price).toFixed(2); | |
377 | + var wl_txt = "formData.shipping_price"; | |
378 | + th.setData({ [wl_txt]: shipping_price, }) | |
379 | + | |
380 | + } else { | |
381 | + var wl_txt = "formData.shipping_price"; | |
382 | + th.setData({ [wl_txt]: 0, }) | |
383 | + } | |
384 | + //-----------------总价----------------- | |
385 | + var total_m = parseFloat(allpice) + parseFloat(th.data.formData.shipping_price); | |
386 | + total_m = parseFloat(total_m).toFixed(2); | |
387 | + | |
388 | + var atxt = "formData.total_amount"; | |
389 | + th.setData({ [atxt]: total_m, }) | |
390 | + var order_m = total_m; | |
391 | + | |
392 | + var txt = "formData.user_money"; | |
393 | + var txt2 = "formData.order_amount"; | |
394 | + //--------------如果使用余额--------------------- | |
395 | + if (th.data.bn_use_money == 1 && th.data.yuer > 0) { | |
396 | + if (parseFloat(th.data.yuer) > total_m) { | |
397 | + th.setData({ [txt]: total_m, [txt2]: 0 }) | |
398 | + } else { | |
399 | + order_m = parseFloat(order_m) - parseFloat(th.data.yuer); | |
400 | + order_m = order_m.toFixed(2); | |
401 | + th.setData({ [txt]: th.data.yuer, [txt2]: order_m }) | |
402 | + } | |
403 | + } else { | |
404 | 404 | th.setData({ [txt]: 0, [txt2]: order_m }) |
405 | - } | |
405 | + } | |
406 | 406 | |
407 | - }); | |
408 | - }); | |
407 | + }); | |
408 | + }); | |
409 | 409 | }, |
410 | 410 | |
411 | 411 | // -- 支付的下一步 -- |
412 | - submitForm_next:async function(t){ | |
413 | - if(this.data.is_summit_ing==1) return false; //--提交中退出-- | |
414 | - this.data.is_summit_ing=1; | |
412 | + submitForm_next: async function (t) { | |
413 | + if (this.data.is_summit_ing == 1) return false; //--提交中退出-- | |
414 | + this.data.is_summit_ing = 1; | |
415 | 415 | |
416 | - var th=this,pdata=new Array(); | |
417 | - var ff=true; | |
416 | + var th = this, pdata = new Array(); | |
417 | + var ff = true; | |
418 | 418 | //------------立即购买------------- |
419 | 419 | |
420 | 420 | //如果不是阶梯团,或者是普通购买,商家选择了物流,以及地址为空的时候 |
421 | - if(th.data.bn_exp_type == 0 && th.data.user_addr==null && (th.data.kt_type!=3 || th.data.bn_goods.is_normal==1) ){ | |
421 | + if (th.data.bn_exp_type == 0 && th.data.user_addr == null && (th.data.kt_type != 3 || th.data.bn_goods.is_normal == 1)) { | |
422 | 422 | ff = false; |
423 | - getApp().my_warnning("请选择收货地址",0,this); | |
423 | + getApp().my_warnning("请选择收货地址", 0, this); | |
424 | 424 | this.data.is_summit_ing = 0; |
425 | 425 | } |
426 | 426 | if (!ff) return false; |
427 | 427 | var addr = th.data.user_addr; |
428 | - if (th.data.bn_exp_type == 1) addr=null; | |
428 | + if (th.data.bn_exp_type == 1) addr = null; | |
429 | 429 | |
430 | - if(th.data.bn_exp_type==0 && (th.data.kt_type!=3)) { | |
430 | + if (th.data.bn_exp_type == 0 && (th.data.kt_type != 3)) { | |
431 | 431 | if (th.data.wu_arr == null || th.data.wu_arr.length <= 0) { |
432 | - getApp().my_warnning("读取物流失败",0,this); | |
432 | + getApp().my_warnning("读取物流失败", 0, this); | |
433 | 433 | this.data.is_summit_ing = 0; |
434 | 434 | return false; |
435 | 435 | } |
436 | 436 | } |
437 | 437 | |
438 | 438 | //阶梯团强制带1,自提~~~ |
439 | - if(th.data.kt_type==3 ){ | |
440 | - th.data.bn_exp_type=1; | |
439 | + if (th.data.kt_type == 3) { | |
440 | + th.data.bn_exp_type = 1; | |
441 | 441 | } |
442 | 442 | |
443 | - var item={ | |
444 | - 'user_id':app.globalData.user_id, | |
443 | + var item = { | |
444 | + 'user_id': app.globalData.user_id, | |
445 | 445 | 'consignee': addr == null ? "" : addr.consignee, |
446 | 446 | 'province': addr == null ? 0 : addr.province, |
447 | 447 | 'city': addr == null ? 0 : addr.city, |
448 | 448 | 'district': addr == null ? 0 : addr.district, |
449 | 449 | 'twon': addr == null ? 0 : addr.twon, |
450 | - 'address': addr == null ? "": addr.address, | |
450 | + 'address': addr == null ? "" : addr.address, | |
451 | 451 | 'more_address': addr == null ? "" : addr.more_address, |
452 | - 'mobile': addr == null ? th.data.userinfo.mobile:addr.mobile, | |
453 | - 'email':'', | |
454 | - 'invoice_title':'', | |
452 | + 'mobile': addr == null ? th.data.userinfo.mobile : addr.mobile, | |
453 | + 'email': '', | |
454 | + 'invoice_title': '', | |
455 | 455 | 'goods_price': th.data.formData.all_price, //商品总价 |
456 | 456 | 'shipping_price': th.data.formData.shipping_price, //物流金额 |
457 | 457 | 'user_money': th.data.formData.user_money, //使用余额 |
458 | 458 | 'total_amount': th.data.formData.total_amount, //订单总价 |
459 | 459 | 'order_amount': th.data.formData.order_amount, //应付 |
460 | 460 | 'user_note': t.detail.value.user_note, //用户备注 |
461 | - 'store_id':os.stoid, //商家 | |
461 | + 'store_id': os.stoid, //商家 | |
462 | 462 | 'pickup_id': th.data.bn_pick, //门店 |
463 | - 'prom_type':th.data.bn_goods.prom_type, //促销活动类型 | |
463 | + 'prom_type': th.data.bn_goods.prom_type, //促销活动类型 | |
464 | 464 | 'prom_id': th.data.bn_goods.prom_id, //促销活动id |
465 | - 'order_goods':new Array(), | |
465 | + 'order_goods': new Array(), | |
466 | 466 | }; |
467 | 467 | |
468 | 468 | //老会员成为分销下线需要的参数 |
469 | - if(getApp().globalData.first_leader && !getApp().globalData.userInfo.first_leader){ | |
469 | + if (getApp().globalData.first_leader && !getApp().globalData.userInfo.first_leader) { | |
470 | 470 | //判断一下分享人是不是分享商 |
471 | - await app.request.promiseGet("/api/weshop/users/get/" + os.stoid+"/"+getApp().globalData.first_leader,{}).then(res=>{ | |
472 | - if(res.data.code==0){ | |
473 | - var user= res.data.data; | |
474 | - if(user.is_distribut==1){ | |
475 | - item.first_leader=parseInt(getApp().globalData.first_leader); | |
471 | + await app.request.promiseGet("/api/weshop/users/get/" + os.stoid + "/" + getApp().globalData.first_leader, {}).then(res => { | |
472 | + if (res.data.code == 0) { | |
473 | + var user = res.data.data; | |
474 | + if (user.is_distribut == 1) { | |
475 | + item.first_leader = parseInt(getApp().globalData.first_leader); | |
476 | 476 | } |
477 | 477 | } |
478 | 478 | }) |
479 | 479 | } |
480 | 480 | |
481 | - if(th.data.qh!='') | |
482 | - { | |
483 | - item.team_qh=th.data.qh; | |
484 | - item.pt_listno=th.data.qh; | |
481 | + if (th.data.qh != '') { | |
482 | + item.team_qh = th.data.qh; | |
483 | + item.pt_listno = th.data.qh; | |
485 | 484 | } |
486 | 485 | |
487 | - var gg =app.get_b_now(); | |
488 | - var goods={ | |
486 | + var gg = app.get_b_now(); | |
487 | + var goods = { | |
489 | 488 | 'goods_id': gg.goods_id, |
490 | 489 | 'goods_name': gg.goods_name, |
491 | 490 | 'goods_sn': gg.goods_sn, |
... | ... | @@ -494,37 +493,37 @@ Page({ |
494 | 493 | 'goods_price': th.data.bn_goods.shop_price, |
495 | 494 | 'member_goods_price': th.data.bn_goods.shop_price, |
496 | 495 | 'store_id': os.stoid, |
497 | - 'prom_type':th.data.bn_goods.prom_type, //促销活动类型 | |
496 | + 'prom_type': th.data.bn_goods.prom_type, //促销活动类型 | |
498 | 497 | 'prom_id': th.data.bn_goods.prom_id, //促销活动id |
499 | 498 | }; |
500 | 499 | |
501 | 500 | //--导购分享过来的id-- |
502 | - if(gg.guide_id){ | |
503 | - goods.guide_id=gg.guide_id; | |
504 | - goods.guide_type=gg.guide_type; | |
501 | + if (gg.guide_id) { | |
502 | + goods.guide_id = gg.guide_id; | |
503 | + goods.guide_type = gg.guide_type; | |
505 | 504 | //调用接口判断是不是会员 |
506 | - await getApp().request.promiseGet("/api/weshop/shoppingGuide/getId/"+os.stoid+"/"+gg.guide_id,{}).then(res=>{ | |
507 | - if(res.data.code==0){ | |
508 | - goods.guide_name=res.data.data.salesman; | |
509 | - goods.guide_sn=res.data.data.salesman_no; | |
505 | + await getApp().request.promiseGet("/api/weshop/shoppingGuide/getId/" + os.stoid + "/" + gg.guide_id, {}).then(res => { | |
506 | + if (res.data.code == 0) { | |
507 | + goods.guide_name = res.data.data.salesman; | |
508 | + goods.guide_sn = res.data.data.salesman_no; | |
510 | 509 | } |
511 | 510 | }) |
512 | 511 | } |
513 | 512 | |
514 | 513 | //--商品的房间号-- |
515 | - if(gg.room_id && gg.room_id>0){ | |
516 | - item.room_ids=gg.room_id; | |
517 | - goods.room_id=gg.room_id; | |
514 | + if (gg.room_id && gg.room_id > 0) { | |
515 | + item.room_ids = gg.room_id; | |
516 | + goods.room_id = gg.room_id; | |
518 | 517 | } |
519 | 518 | |
520 | - if(th.data.bn_goods.is_normal){goods.is_pd_normal=1;} | |
519 | + if (th.data.bn_goods.is_normal) { goods.is_pd_normal = 1; } | |
521 | 520 | |
522 | 521 | item.order_goods.push(goods); |
523 | 522 | pdata.push(item); |
524 | 523 | |
525 | - if (pdata.length==0) return; | |
524 | + if (pdata.length == 0) return; | |
526 | 525 | var str = JSON.stringify(pdata); |
527 | - wx.showLoading({title: "加载中"}); | |
526 | + wx.showLoading({ title: "加载中" }); | |
528 | 527 | wx.request({ |
529 | 528 | url: os.url + '/api/weshop/order/createWxdOrder', |
530 | 529 | data: str, |
... | ... | @@ -536,8 +535,8 @@ Page({ |
536 | 535 | |
537 | 536 | wx.hideLoading(); |
538 | 537 | if (res.statusCode == 200) { |
539 | - var data=res.data; | |
540 | - if(data.code==0){ | |
538 | + var data = res.data; | |
539 | + if (data.code == 0) { | |
541 | 540 | console.log(th.data.is_b_now); |
542 | 541 | //如果是购物车结算,还要删除购物车 |
543 | 542 | if (th.data.is_b_now == 0) { |
... | ... | @@ -555,11 +554,11 @@ Page({ |
555 | 554 | //要进行判断,如果是用微信支付,就要跳转到支付界面 |
556 | 555 | if (order_amount > 0) { |
557 | 556 | th.setData({ isclose: 0 }); |
558 | - util_pay.pay(data.data, function() { | |
559 | - var url="/packageC/pages/presell/cart/cart?order_sn="+data.data; | |
557 | + util_pay.pay(data.data, function () { | |
558 | + var url = "/packageC/pages/presell/cart/cart?order_sn=" + data.data; | |
560 | 559 | setTimeout(function () { |
561 | - wx.reLaunch({ url: url,}) | |
562 | - },1000) | |
560 | + wx.reLaunch({ url: url, }) | |
561 | + }, 1000) | |
563 | 562 | }, function () { |
564 | 563 | //支付失败 |
565 | 564 | setTimeout(function () { |
... | ... | @@ -567,9 +566,9 @@ Page({ |
567 | 566 | wx.reLaunch({ |
568 | 567 | url: "/pages/user/order_list/order_list", |
569 | 568 | }) |
570 | - },1000) | |
569 | + }, 1000) | |
571 | 570 | |
572 | - },os.stoid,1); | |
571 | + }, os.stoid, 1); | |
573 | 572 | |
574 | 573 | } else { |
575 | 574 | var dd = { |
... | ... | @@ -582,15 +581,15 @@ Page({ |
582 | 581 | data: dd, |
583 | 582 | success: function (t) { |
584 | 583 | console.log(t); |
585 | - app.my_warnning("支付成功",1,th); | |
584 | + app.my_warnning("支付成功", 1, th); | |
586 | 585 | setTimeout(function () { |
587 | 586 | th.setData({ isclose: 0 }); |
588 | 587 | |
589 | 588 | |
590 | - var url="/packageC/pages/presell/cart/cart?order_sn="+data.data; | |
591 | - wx.reLaunch({ | |
592 | - url: url | |
593 | - }) | |
589 | + var url = "/packageC/pages/presell/cart/cart?order_sn=" + data.data; | |
590 | + wx.reLaunch({ | |
591 | + url: url | |
592 | + }) | |
594 | 593 | |
595 | 594 | |
596 | 595 | |
... | ... | @@ -599,54 +598,54 @@ Page({ |
599 | 598 | }); |
600 | 599 | } |
601 | 600 | } |
602 | - else{ | |
603 | - th.data.is_summit_ing=0; //是否提交中 | |
601 | + else { | |
602 | + th.data.is_summit_ing = 0; //是否提交中 | |
604 | 603 | getApp().confirmBox(data.msg); |
605 | 604 | } |
606 | 605 | } else { |
607 | - th.data.is_summit_ing=0; //是否提交中 | |
606 | + th.data.is_summit_ing = 0; //是否提交中 | |
608 | 607 | console.log("index.js wx.request CheckCallUser statusCode" + res.statusCode); |
609 | 608 | } |
610 | 609 | }, |
611 | 610 | fail: function () { |
612 | - th.data.is_summit_ing=0; //是否提交中 | |
611 | + th.data.is_summit_ing = 0; //是否提交中 | |
613 | 612 | wx.hideLoading(); |
614 | 613 | console.log("index.js wx.request CheckCallUser fail"); |
615 | 614 | }, |
616 | - complete: function () {} | |
615 | + complete: function () { } | |
617 | 616 | }) |
618 | 617 | }, |
619 | 618 | |
620 | 619 | |
621 | 620 | //--------------------提交订单----------------------- |
622 | - submitForm: function(t){ | |
623 | - var th=this; | |
621 | + submitForm: function (t) { | |
622 | + var th = this; | |
624 | 623 | //如果是部分定金,商家不同意退定金, |
625 | - if(this.data.act.presell_type!=1 && !this.data.act.is_refundmoney && !th.agree_no_ref){ | |
624 | + if (this.data.act.presell_type != 1 && !this.data.act.is_refundmoney && !th.agree_no_ref) { | |
626 | 625 | wx.showModal({ |
627 | 626 | content: ' 预售商品不允许退定金!是否继续下单?', |
628 | 627 | showCancel: true,//是否显示取消按钮 |
629 | - cancelText:"我在想想",//默认是“取消” | |
630 | - confirmText:"继续下单",//默认是“确定” | |
628 | + cancelText: "我在想想",//默认是“取消” | |
629 | + confirmText: "继续下单",//默认是“确定” | |
631 | 630 | success: function (res) { |
632 | 631 | if (res.cancel) { |
633 | 632 | //点击取消,默认隐藏弹框 |
634 | 633 | } else { |
635 | - th.setData({agree_no_ref:1}) | |
636 | - th.submitForm_next(t) | |
634 | + th.setData({ agree_no_ref: 1 }) | |
635 | + th.submitForm_next(t) | |
637 | 636 | } |
638 | 637 | }, |
639 | 638 | }) |
640 | 639 | |
641 | - }else{ | |
642 | - this.submitForm_next(t); | |
640 | + } else { | |
641 | + this.submitForm_next(t); | |
643 | 642 | } |
644 | 643 | }, |
645 | 644 | |
646 | - useCoupon: function() { | |
645 | + useCoupon: function () { | |
647 | 646 | if (this.data.order.couponNum <= 0) { |
648 | 647 | //return t.showWarning("无可用优惠券"); |
649 | - getApp().my_warnning("无可用优惠券",0,this); | |
648 | + getApp().my_warnning("无可用优惠券", 0, this); | |
650 | 649 | return; |
651 | 650 | } |
652 | 651 | var a = { |
... | ... | @@ -656,158 +655,158 @@ Page({ |
656 | 655 | url: "/pages/user/checkcoupon/checkcoupon?" + s.Obj2Str(a) |
657 | 656 | }); |
658 | 657 | }, |
659 | - enterAddressPage: function() { | |
660 | - getApp().globalData.is_cart_old=1; | |
658 | + enterAddressPage: function () { | |
659 | + getApp().globalData.is_cart_old = 1; | |
661 | 660 | this.data.enterAddressPage = !0, wx.navigateTo({ |
662 | 661 | url: "/pages/user/address_list/address_list" |
663 | 662 | }); |
664 | 663 | }, |
665 | 664 | |
666 | - //--------立即购买时,选择自提和物流----------- | |
667 | - setexptype_w:function(t){ | |
668 | - var th=this; | |
669 | - var ty = t.currentTarget.dataset.t,txt = t.currentTarget.dataset.txt; | |
670 | - th.setData({ [txt]: ty }); | |
671 | - var iszt=1; | |
672 | - if(ty==0){ | |
673 | - th.setData({ is_all_zt: 0 }); | |
674 | - }else{ | |
675 | - for(var i=0;i<th.data.cartlist.length;i++){ | |
676 | - var item = th.data.cartlist[i]; | |
677 | - if (item.exp_type==0){ iszt=0;break;} | |
678 | - } | |
679 | - th.setData({ is_all_zt: iszt }); | |
680 | - } | |
681 | - //----计算此时购物车的价格---- | |
682 | - th.calculatePrice(); | |
665 | + //--------立即购买时,选择自提和物流----------- | |
666 | + setexptype_w: function (t) { | |
667 | + var th = this; | |
668 | + var ty = t.currentTarget.dataset.t, txt = t.currentTarget.dataset.txt; | |
669 | + th.setData({ [txt]: ty }); | |
670 | + var iszt = 1; | |
671 | + if (ty == 0) { | |
672 | + th.setData({ is_all_zt: 0 }); | |
673 | + } else { | |
674 | + for (var i = 0; i < th.data.cartlist.length; i++) { | |
675 | + var item = th.data.cartlist[i]; | |
676 | + if (item.exp_type == 0) { iszt = 0; break; } | |
677 | + } | |
678 | + th.setData({ is_all_zt: iszt }); | |
679 | + } | |
680 | + //----计算此时购物车的价格---- | |
681 | + th.calculatePrice(); | |
683 | 682 | }, |
684 | 683 | |
685 | 684 | //--------立即购买时,选择自提和物流---------- |
686 | - setexptype:function(t){ | |
687 | - var th=this; | |
688 | - var ty = t.currentTarget.dataset.t; | |
689 | - th.setData({ bn_exp_type:ty}); | |
690 | - //当物流为空的时候。 | |
691 | - if (ty == 0 && th.data.wu_arr==null){ | |
692 | - return th.get_wuliu(th.calculatePrice2()); | |
693 | - } | |
694 | - th.calculatePrice2() | |
695 | - console.log('setexptype'); | |
696 | - }, | |
697 | - | |
698 | - //--------立即购买时,使用余额-------- | |
699 | - set_bn_useyuer:function(){ | |
700 | - var th=this; | |
701 | - th.setData({ bn_use_money: !th.data.bn_use_money}); | |
702 | - th.calculatePrice2(); | |
703 | - }, | |
704 | - set_js_useyuer:function(){ | |
705 | - var th = this; | |
706 | - th.setData({ js_use_money: !th.data.js_use_money }); | |
707 | - th.calculatePrice(); | |
708 | - }, | |
709 | - | |
710 | - //-------------------计算物流--------------- | |
711 | - calculatewuliu:function(code, o_shipping_price, goods_weight,out_of_weight, | |
712 | - goods_piece,user_addr, freight_free, o_price, rs){ | |
713 | - var price =0,th=this; | |
714 | - price +=parseFloat(o_shipping_price); | |
715 | - //如果是包邮 | |
716 | - if (freight_free > 0 && o_price >= freight_free && out_of_weight>=0){ return 0;} | |
717 | - if (user_addr==null) { return 0; } | |
718 | - //计算物流的config item; | |
719 | - var item=null; | |
720 | - //先根据 镇 县 区找计算的config | |
721 | - item = th.get_wuliu_config(user_addr.district,code,rs); | |
722 | - if (item==null) item = th.get_wuliu_config(user_addr.city, code, rs); | |
723 | - if (item==null) item = th.get_wuliu_config(user_addr.province, code, rs); | |
724 | - if (item == null) item = th.get_wuliu_default(code,rs); | |
725 | - if (item == null) return o_shipping_price; | |
726 | - var fw_price = 0, fp_price=0; | |
727 | - item=item.config; | |
728 | - if (item == null) return o_shipping_price; | |
729 | - //------按重量---------- | |
730 | - if (goods_weight >= 0 && item['money']) { | |
731 | - fw_price =parseFloat(item['money']); | |
732 | - if (goods_weight > item['first_weight']){ | |
733 | - var fw = goods_weight - item['first_weight']; | |
734 | - var n = Math.ceil(fw/item['second_weight']) | |
735 | - fw_price = fw_price + n * parseFloat(item['add_money']); | |
736 | - } | |
737 | - } | |
738 | - //------超出重量---------- | |
739 | - if(out_of_weight < 0 && o_price >= freight_free){ | |
740 | - fw_price = parseFloat(item['money']); | |
741 | - var out_of_weight = Math.abs(out_of_weight); | |
742 | - if (out_of_weight > item['first_weight']) { | |
743 | - var fw = out_of_weight - item['first_weight']; | |
744 | - var n = Math.ceil(fw / item['second_weight']) | |
745 | - fw_price = fw_price + n * parseFloat(item['add_money']); | |
685 | + setexptype: function (t) { | |
686 | + var th = this; | |
687 | + var ty = t.currentTarget.dataset.t; | |
688 | + th.setData({ bn_exp_type: ty }); | |
689 | + //当物流为空的时候。 | |
690 | + if (ty == 0 && th.data.wu_arr == null) { | |
691 | + return th.get_wuliu(th.calculatePrice2()); | |
746 | 692 | } |
747 | - } | |
748 | - //------按件数---------- | |
749 | - if (goods_piece > 0) { | |
750 | - fp_price = parseFloat(item['piecemoney']); | |
751 | - if (goods_piece > item['first_piece']) { | |
752 | - var fp = goods_piece - item['first_piece']; | |
753 | - var m = Math.ceil(fp / item['second_piece']) | |
754 | - fp_price = fp_price + m * parseFloat(item['add_piecemoney']); | |
755 | - } | |
756 | - } | |
757 | - var rspice =parseFloat(price + fw_price + fp_price); | |
758 | - return rspice; | |
759 | - }, | |
760 | - | |
761 | - //------------循环获取config----------- | |
762 | - get_wuliu_config:function(region_id,code,rs){ | |
763 | - var item=null,rslist = rs.pageData; | |
764 | - for (var i = 0; i < rslist.length;i++){ | |
765 | - if (rslist[i].code == code && rslist[i].region_id == region_id) { item = rslist[i];} | |
766 | - } | |
767 | - return item; | |
768 | - }, | |
769 | - //-------循环获取config,code default------- | |
770 | - get_wuliu_default: function (code, rs) { | |
771 | - var item = null, rslist=rs.pageData; | |
772 | - for (var i = 0; i < rslist.length; i++) { | |
773 | - if (rslist[i].shipping_code == code && rslist[i].is_default == 1) { item = rslist[i]; } | |
774 | - } | |
775 | - return item; | |
776 | - }, | |
777 | - | |
778 | - //----------立即购买,选择物流------------- | |
779 | - bindPickerChange:function(e){ | |
780 | - var ind = e.detail.value | |
781 | - this.setData({ index: ind }); | |
782 | - this.calculatePrice2(); | |
783 | - }, | |
784 | - | |
785 | - //----------购物车结算,选择物流------------- | |
786 | - bindPickerChange_w: function (e) { | |
787 | - var ind=e.detail.value, txt = e.currentTarget.dataset.txt; | |
693 | + th.calculatePrice2() | |
694 | + console.log('setexptype'); | |
695 | + }, | |
696 | + | |
697 | + //--------立即购买时,使用余额-------- | |
698 | + set_bn_useyuer: function () { | |
699 | + var th = this; | |
700 | + th.setData({ bn_use_money: !th.data.bn_use_money }); | |
701 | + th.calculatePrice2(); | |
702 | + }, | |
703 | + set_js_useyuer: function () { | |
704 | + var th = this; | |
705 | + th.setData({ js_use_money: !th.data.js_use_money }); | |
706 | + th.calculatePrice(); | |
707 | + }, | |
708 | + | |
709 | + //-------------------计算物流--------------- | |
710 | + calculatewuliu: function (code, o_shipping_price, goods_weight, out_of_weight, | |
711 | + goods_piece, user_addr, freight_free, o_price, rs) { | |
712 | + var price = 0, th = this; | |
713 | + price += parseFloat(o_shipping_price); | |
714 | + //如果是包邮 | |
715 | + if (freight_free > 0 && o_price >= freight_free && out_of_weight >= 0) { return 0; } | |
716 | + if (user_addr == null) { return 0; } | |
717 | + //计算物流的config item; | |
718 | + var item = null; | |
719 | + //先根据 镇 县 区找计算的config | |
720 | + item = th.get_wuliu_config(user_addr.district, code, rs); | |
721 | + if (item == null) item = th.get_wuliu_config(user_addr.city, code, rs); | |
722 | + if (item == null) item = th.get_wuliu_config(user_addr.province, code, rs); | |
723 | + if (item == null) item = th.get_wuliu_default(code, rs); | |
724 | + if (item == null) return o_shipping_price; | |
725 | + var fw_price = 0, fp_price = 0; | |
726 | + item = item.config; | |
727 | + if (item == null) return o_shipping_price; | |
728 | + //------按重量---------- | |
729 | + if (goods_weight >= 0 && item['money']) { | |
730 | + fw_price = parseFloat(item['money']); | |
731 | + if (goods_weight > item['first_weight']) { | |
732 | + var fw = goods_weight - item['first_weight']; | |
733 | + var n = Math.ceil(fw / item['second_weight']) | |
734 | + fw_price = fw_price + n * parseFloat(item['add_money']); | |
735 | + } | |
736 | + } | |
737 | + //------超出重量---------- | |
738 | + if (out_of_weight < 0 && o_price >= freight_free) { | |
739 | + fw_price = parseFloat(item['money']); | |
740 | + var out_of_weight = Math.abs(out_of_weight); | |
741 | + if (out_of_weight > item['first_weight']) { | |
742 | + var fw = out_of_weight - item['first_weight']; | |
743 | + var n = Math.ceil(fw / item['second_weight']) | |
744 | + fw_price = fw_price + n * parseFloat(item['add_money']); | |
745 | + } | |
746 | + } | |
747 | + //------按件数---------- | |
748 | + if (goods_piece > 0) { | |
749 | + fp_price = parseFloat(item['piecemoney']); | |
750 | + if (goods_piece > item['first_piece']) { | |
751 | + var fp = goods_piece - item['first_piece']; | |
752 | + var m = Math.ceil(fp / item['second_piece']) | |
753 | + fp_price = fp_price + m * parseFloat(item['add_piecemoney']); | |
754 | + } | |
755 | + } | |
756 | + var rspice = parseFloat(price + fw_price + fp_price); | |
757 | + return rspice; | |
758 | + }, | |
759 | + | |
760 | + //------------循环获取config----------- | |
761 | + get_wuliu_config: function (region_id, code, rs) { | |
762 | + var item = null, rslist = rs.pageData; | |
763 | + for (var i = 0; i < rslist.length; i++) { | |
764 | + if (rslist[i].code == code && rslist[i].region_id == region_id) { item = rslist[i]; } | |
765 | + } | |
766 | + return item; | |
767 | + }, | |
768 | + //-------循环获取config,code default------- | |
769 | + get_wuliu_default: function (code, rs) { | |
770 | + var item = null, rslist = rs.pageData; | |
771 | + for (var i = 0; i < rslist.length; i++) { | |
772 | + if (rslist[i].shipping_code == code && rslist[i].is_default == 1) { item = rslist[i]; } | |
773 | + } | |
774 | + return item; | |
775 | + }, | |
776 | + | |
777 | + //----------立即购买,选择物流------------- | |
778 | + bindPickerChange: function (e) { | |
779 | + var ind = e.detail.value | |
780 | + this.setData({ index: ind }); | |
781 | + this.calculatePrice2(); | |
782 | + }, | |
783 | + | |
784 | + //----------购物车结算,选择物流------------- | |
785 | + bindPickerChange_w: function (e) { | |
786 | + var ind = e.detail.value, txt = e.currentTarget.dataset.txt; | |
788 | 787 | this.setData({ [txt]: ind }); |
789 | 788 | this.calculatePrice(); |
790 | - }, | |
791 | - | |
792 | - cart_set_err: function (e) { | |
793 | - var txt = e.currentTarget.dataset.err; | |
794 | - var ob = {}; | |
795 | - ob[txt] = this.data.imgUrl + "/miniapp/images/default_g_img.gif"; | |
796 | - this.setData(ob); | |
797 | - }, | |
789 | + }, | |
790 | + | |
791 | + cart_set_err: function (e) { | |
792 | + var txt = e.currentTarget.dataset.err; | |
793 | + var ob = {}; | |
794 | + ob[txt] = this.data.imgUrl + "/miniapp/images/default_g_img.gif"; | |
795 | + this.setData(ob); | |
796 | + }, | |
798 | 797 | |
799 | 798 | //// 开启物流的弹窗 |
800 | - show_wu_arr:function(e){ | |
801 | - this.setData({ open_express: 1}); | |
799 | + show_wu_arr: function (e) { | |
800 | + this.setData({ open_express: 1 }); | |
802 | 801 | }, |
803 | 802 | |
804 | 803 | //更新下默认,在onshow里面 |
805 | - update_code(){ | |
806 | - var th=this,m_wind=0,def_exp_code=getApp().globalData.userInfo.def_exp_code; | |
804 | + update_code() { | |
805 | + var th = this, m_wind = 0, def_exp_code = getApp().globalData.userInfo.def_exp_code; | |
807 | 806 | |
808 | - var uii=setInterval(function () { | |
809 | - if(th.data.wu_arr){ | |
810 | - clearInterval(uii); | |
807 | + var uii = setInterval(function () { | |
808 | + if (th.data.wu_arr) { | |
809 | + clearInterval(uii); | |
811 | 810 | for (var k = 0; k < th.data.wu_arr.length; k++) { |
812 | 811 | var item = th.data.wu_arr[k]; |
813 | 812 | if (def_exp_code == item.code) { |
... | ... | @@ -815,37 +814,37 @@ Page({ |
815 | 814 | } |
816 | 815 | } |
817 | 816 | //--如果是立即购买-- |
818 | - th.setData({ index: m_wind, is_express: m_wind}); | |
817 | + th.setData({ index: m_wind, is_express: m_wind }); | |
819 | 818 | } |
820 | - },500) | |
819 | + }, 500) | |
821 | 820 | }, |
822 | 821 | |
823 | 822 | // 关闭物流的弹窗 |
824 | - close_express:function(){ | |
825 | - this.setData({ open_express:0 }); | |
823 | + close_express: function () { | |
824 | + this.setData({ open_express: 0 }); | |
826 | 825 | }, |
827 | 826 | // 选择物流 |
828 | - click_express_name:function(e){ | |
827 | + click_express_name: function (e) { | |
829 | 828 | var express_name = e.currentTarget.dataset.name, shippingcode = e.currentTarget.dataset.shippingcode; |
830 | - var index=e.currentTarget.dataset.idxe; | |
831 | - var ob={ is_express: index, is_shipping_code: shippingcode,index:index}; | |
829 | + var index = e.currentTarget.dataset.idxe; | |
830 | + var ob = { is_express: index, is_shipping_code: shippingcode, index: index }; | |
832 | 831 | this.setData(ob); |
833 | 832 | }, |
834 | 833 | |
835 | 834 | //点击确定物流 |
836 | - determine_expres:function(e){ | |
837 | - this.setData({ open_express: 0}); | |
835 | + determine_expres: function (e) { | |
836 | + this.setData({ open_express: 0 }); | |
838 | 837 | this.calculatePrice2(); |
839 | 838 | }, |
840 | 839 | //设置默认物流 |
841 | 840 | select_default_logistics: function () { |
842 | - var th=this; | |
843 | - var is_shipping_code=this.data.is_shipping_code | |
844 | - getApp().request.put("/api/weshop/users/update",{ | |
845 | - data: { user_id: getApp().globalData.user_id, store_id: os.stoid, def_exp_code: is_shipping_code}, | |
846 | - success:function(rse){ | |
847 | - if (rse.data.code==0){ | |
848 | - getApp().globalData.userInfo.def_exp_code=is_shipping_code; | |
841 | + var th = this; | |
842 | + var is_shipping_code = this.data.is_shipping_code | |
843 | + getApp().request.put("/api/weshop/users/update", { | |
844 | + data: { user_id: getApp().globalData.user_id, store_id: os.stoid, def_exp_code: is_shipping_code }, | |
845 | + success: function (rse) { | |
846 | + if (rse.data.code == 0) { | |
847 | + getApp().globalData.userInfo.def_exp_code = is_shipping_code; | |
849 | 848 | th.setData({ open_express: 0 }); |
850 | 849 | //----计算此时购物车的价格,这个页面没有calculatePrice(),2021.7.19---- |
851 | 850 | //if(th.data.is_b_now==1) th.calculatePrice2(); |
... | ... | @@ -858,14 +857,14 @@ Page({ |
858 | 857 | |
859 | 858 | |
860 | 859 | //跳转到购买卡 |
861 | - buycard:function(){ | |
862 | - getApp().goto("/pages/user/plus/plus"); | |
863 | - getApp().globalData.plus_buy_back=1; | |
864 | - }, | |
865 | - | |
866 | - switchChange:function (e) { | |
867 | - console.log(e,111); | |
868 | - this.setData({agree_no_ref:e.detail.value}); | |
860 | + buycard: function () { | |
861 | + getApp().goto("/pages/user/plus/plus"); | |
862 | + getApp().globalData.plus_buy_back = 1; | |
863 | + }, | |
864 | + | |
865 | + switchChange: function (e) { | |
866 | + console.log(e, 111); | |
867 | + this.setData({ agree_no_ref: e.detail.value }); | |
869 | 868 | } |
870 | - | |
869 | + | |
871 | 870 | }); | ... | ... |
pages/cart/cart2/cart2.js
... | ... | @@ -123,46 +123,47 @@ Page({ |
123 | 123 | tabs: ['门店自提', '快递邮寄'], |
124 | 124 | currentTabIndex: 1, |
125 | 125 | |
126 | - in_zhact_gdmap:{}, //不同门店参与同一活动的限购 | |
127 | - hid_inp:1, | |
128 | - user_note:"", | |
129 | - zhhe_act_map:{}, //组合活动的map表 | |
130 | - zuhe_map_good:{}, //组合购的map表 | |
131 | - ladder_map:{}, //阶梯促销的map表 | |
132 | - | |
133 | - state:0, //阶梯促销的的立即购买也走购物车流程state=1 | |
126 | + in_zhact_gdmap: {}, //不同门店参与同一活动的限购 | |
127 | + hid_inp: 1, | |
128 | + user_note: "", | |
129 | + zhhe_act_map: {}, //组合活动的map表 | |
130 | + zuhe_map_good: {}, //组合购的map表 | |
131 | + ladder_map: {}, //阶梯促销的map表 | |
132 | + is_no_past: 1, | |
133 | + state: 0, //阶梯促销的的立即购买也走购物车流程state=1 | |
134 | 134 | }, |
135 | 135 | onLoad: function (t) { |
136 | - wx.setNavigationBarTitle({title: "填写订单",}) | |
136 | + wx.setNavigationBarTitle({ title: "填写订单", }) | |
137 | 137 | var th = this; |
138 | - this.setData({is_b_now: t.is_bnow == undefined ? 0 : t.is_bnow,}); | |
138 | + this.setData({ is_b_now: t.is_bnow == undefined ? 0 : t.is_bnow, }); | |
139 | 139 | th.data.param = t; |
140 | 140 | //清理一下,确保最新的系统配置 |
141 | 141 | getApp().globalData.config2 = null; |
142 | 142 | //清空is_pick_up |
143 | 143 | getApp().request.put("/api/weshop/useraddress/updatePickUp", { |
144 | - data: {user_id: getApp().globalData.user_id, is_pickup: 0}, | |
144 | + data: { user_id: getApp().globalData.user_id, is_pickup: 0 }, | |
145 | 145 | success: function (s) { |
146 | 146 | } |
147 | 147 | }); |
148 | 148 | |
149 | 149 | //阶梯购 或者 组合购的立即购买 |
150 | - if(t.state){ | |
151 | - th.data.state=1; | |
150 | + if (t.state) { | |
151 | + th.data.state = 1; | |
152 | 152 | } |
153 | 153 | getApp().promiseGet("/api/wx/weappSendlist/page", { |
154 | 154 | data: { |
155 | 155 | store_id: os.stoid, |
156 | 156 | typeid: "1001" |
157 | - }}).then(res=>{ | |
157 | + } | |
158 | + }).then(res => { | |
158 | 159 | if (res.data.code == 0 && res.data.data.pageData.length > 0) { |
159 | 160 | var template_id = res.data.data.pageData[0].template_id; |
160 | - th.setData({template_id:template_id}); | |
161 | + th.setData({ template_id: template_id }); | |
161 | 162 | } |
162 | 163 | }) |
163 | 164 | }, |
164 | 165 | onUnload: function () { |
165 | - this.setData({isclose: 1}) | |
166 | + this.setData({ isclose: 1 }) | |
166 | 167 | }, |
167 | 168 | onHide: function () { |
168 | 169 | this.setData({ |
... | ... | @@ -175,7 +176,7 @@ Page({ |
175 | 176 | //----------子页返回父页触发---------- |
176 | 177 | onShow: function () { |
177 | 178 | var th = this; |
178 | - th.setData({show_submit: 0}); //让提交先掩藏 | |
179 | + th.setData({ show_submit: 0 }); //让提交先掩藏 | |
179 | 180 | th.data.g_cart_q_time = null; |
180 | 181 | |
181 | 182 | if (th.data.isclose == 0) { |
... | ... | @@ -208,20 +209,20 @@ Page({ |
208 | 209 | th.data.is_summit_ing = 0; |
209 | 210 | //更换地址回来要重新调用计算价钱的接口 |
210 | 211 | if (!th.data.user_addr || th.data.user_addr.address_id != ie.address_id) { |
211 | - th.setData({user_addr: ie}); | |
212 | + th.setData({ user_addr: ie }); | |
212 | 213 | if (th.data.is_b_now == 1) { |
213 | 214 | if (th.data.bn_goods) { |
214 | - th.setData({add_back: 1}); | |
215 | + th.setData({ add_back: 1 }); | |
215 | 216 | //th.calculatePrice2(); |
216 | 217 | } |
217 | 218 | } else { |
218 | 219 | if (th.data.cartlist) { |
219 | - th.setData({add_back: 1}); | |
220 | + th.setData({ add_back: 1 }); | |
220 | 221 | //th.calculatePrice(); |
221 | 222 | } |
222 | 223 | } |
223 | 224 | } else { |
224 | - th.setData({user_addr: ie}); | |
225 | + th.setData({ user_addr: ie }); | |
225 | 226 | } |
226 | 227 | var going = 0; |
227 | 228 | |
... | ... | @@ -275,34 +276,34 @@ Page({ |
275 | 276 | //-- 获取所有的等级卡, -- |
276 | 277 | getApp().request.promiseGet("/api/weshop/plus/vip/mem/bership/list?storeId=" + os.stoid, |
277 | 278 | {}).then(res => { |
278 | - if (res.data.code == 0) { | |
279 | - var plusCard = res.data.data; | |
280 | - //-- 循环判断,拿到最贵的那张卡 -- | |
281 | - for (var ih in plusCard) { | |
282 | - if (plusCard[ih].IsStopBuy == true) { | |
283 | - continue; | |
284 | - } | |
285 | - if (max_price < 0) { | |
286 | - max_price = plusCard[ih].CardFee; | |
287 | - name = 'card' + plusCard[ih]['CorrPrice']; | |
288 | - show_card = plusCard[ih]; | |
289 | - } else { | |
290 | - if (max_price < plusCard[ih].CardFee) { | |
279 | + if (res.data.code == 0) { | |
280 | + var plusCard = res.data.data; | |
281 | + //-- 循环判断,拿到最贵的那张卡 -- | |
282 | + for (var ih in plusCard) { | |
283 | + if (plusCard[ih].IsStopBuy == true) { | |
284 | + continue; | |
285 | + } | |
286 | + if (max_price < 0) { | |
291 | 287 | max_price = plusCard[ih].CardFee; |
292 | 288 | name = 'card' + plusCard[ih]['CorrPrice']; |
293 | 289 | show_card = plusCard[ih]; |
290 | + } else { | |
291 | + if (max_price < plusCard[ih].CardFee) { | |
292 | + max_price = plusCard[ih].CardFee; | |
293 | + name = 'card' + plusCard[ih]['CorrPrice']; | |
294 | + show_card = plusCard[ih]; | |
295 | + } | |
294 | 296 | } |
295 | 297 | } |
296 | - } | |
297 | 298 | |
298 | - if (show_card) { | |
299 | - name = name.toLowerCase(); | |
300 | - th.setData({card_name: name, show_card: show_card}) | |
299 | + if (show_card) { | |
300 | + name = name.toLowerCase(); | |
301 | + th.setData({ card_name: name, show_card: show_card }) | |
302 | + } | |
301 | 303 | } |
302 | - } | |
303 | - //-----先获取物流,再获取用户信息,再展示页面----- | |
304 | - th.get_wuliu(th.get_info(th.show_page)); | |
305 | - }) | |
304 | + //-----先获取物流,再获取用户信息,再展示页面----- | |
305 | + th.get_wuliu(th.get_info(th.show_page)); | |
306 | + }) | |
306 | 307 | } else { |
307 | 308 | //-----先获取物流,再获取用户信息,再展示页面----- |
308 | 309 | th.get_wuliu(th.get_info(th.show_page)); |
... | ... | @@ -321,10 +322,10 @@ Page({ |
321 | 322 | if (th.data.is_default_logistics) { |
322 | 323 | //如果第一个不是开启默认,说明要让用户自己选 |
323 | 324 | if (!e[0].is_default) { |
324 | - th.setData({is_default_logistics: 0}); | |
325 | + th.setData({ is_default_logistics: 0 }); | |
325 | 326 | } |
326 | 327 | } |
327 | - th.setData({wu_arr: e}) | |
328 | + th.setData({ wu_arr: e }) | |
328 | 329 | typeof func == "function" && func(); |
329 | 330 | }) |
330 | 331 | }, |
... | ... | @@ -338,7 +339,7 @@ Page({ |
338 | 339 | getuser_addr: function (func) { |
339 | 340 | var th = this; |
340 | 341 | a.get("/api/weshop/useraddress/page", { |
341 | - data: {user_id: to.globalData.user_id, store_id: oo.stoid, pageSize: 600, t: Math.random()}, | |
342 | + data: { user_id: to.globalData.user_id, store_id: oo.stoid, pageSize: 600, t: Math.random() }, | |
342 | 343 | success: function (su) { |
343 | 344 | /*--- |
344 | 345 | var user_addr=[ |
... | ... | @@ -363,7 +364,7 @@ Page({ |
363 | 364 | } |
364 | 365 | |
365 | 366 | if (item == undefined) item = null; |
366 | - if (!item) th.setData({user_addr: null}); //地址为空的时候,要清空,因为返回的时候,有缓存 | |
367 | + if (!item) th.setData({ user_addr: null }); //地址为空的时候,要清空,因为返回的时候,有缓存 | |
367 | 368 | |
368 | 369 | func(item); |
369 | 370 | } |
... | ... | @@ -378,19 +379,19 @@ Page({ |
378 | 379 | //会员的信息,要获取最新 |
379 | 380 | var user = getApp().globalData.userInfo; |
380 | 381 | getApp().request.get("/api/weshop/users/get/" + oo.stoid + "/" + user.user_id, { |
381 | - data: {r: Math.random()}, | |
382 | + data: { r: Math.random() }, | |
382 | 383 | success: function (e) { |
383 | 384 | getApp().globalData.userInfo = e.data.data; |
384 | - th.setData({userinfo: e.data.data}); | |
385 | + th.setData({ userinfo: e.data.data }); | |
385 | 386 | |
386 | 387 | //选获取地址 |
387 | 388 | th.getuser_addr(function (addr) { |
388 | - th.setData({user_addr: addr}); | |
389 | + th.setData({ user_addr: addr }); | |
389 | 390 | //--------------------------立即购买------------------ |
390 | 391 | if (ta.is_bnow == 1) { |
391 | 392 | //读取门店 |
392 | 393 | to.get_allsto(function (e) { |
393 | - th.setData({allsto: e}); | |
394 | + th.setData({ allsto: e }); | |
394 | 395 | //获取立即购买的商品信息 |
395 | 396 | th.get_buy_goods(ta.goods_id); |
396 | 397 | }); |
... | ... | @@ -398,7 +399,7 @@ Page({ |
398 | 399 | //------------------------购物车结算---------------------- |
399 | 400 | //读取门店 |
400 | 401 | to.get_allsto(function (e) { |
401 | - th.setData({allsto: e}); | |
402 | + th.setData({ allsto: e }); | |
402 | 403 | //-------获取购物车已经选择的商品-------- |
403 | 404 | th.get_cart(); |
404 | 405 | }) |
... | ... | @@ -407,12 +408,12 @@ Page({ |
407 | 408 | |
408 | 409 | //获取提现金额 |
409 | 410 | getApp().request.get("/api/weshop/withdrawals/summoney", { |
410 | - data: {user_id: to.globalData.user_id, store_id: oo.stoid, status: 0}, | |
411 | + data: { user_id: to.globalData.user_id, store_id: oo.stoid, status: 0 }, | |
411 | 412 | success: function (su) { |
412 | 413 | if (su.data.code == 0) { |
413 | 414 | var yuer = parseFloat(th.data.userinfo.user_money - |
414 | 415 | (th.data.userinfo.frozen_money > 0 ? th.data.userinfo.frozen_money : 0) - su.data.data.summoney).toFixed(2); |
415 | - th.setData({txmon: su.data.data.summoney, yuer: yuer}); | |
416 | + th.setData({ txmon: su.data.data.summoney, yuer: yuer }); | |
416 | 417 | } |
417 | 418 | } |
418 | 419 | }); |
... | ... | @@ -426,8 +427,8 @@ Page({ |
426 | 427 | //-----真的获取购物车,入口-------- |
427 | 428 | get_cart: function () { |
428 | 429 | var th = this, app = getApp(); |
429 | - var state=0; | |
430 | - if(th.data.state) state=1; | |
430 | + var state = 0; | |
431 | + if (th.data.state) state = 1; | |
431 | 432 | a.get("/api/weshop/cart/list", { |
432 | 433 | data: { |
433 | 434 | user_id: to.globalData.user_id, selected: 1, state: state, |
... | ... | @@ -438,7 +439,7 @@ Page({ |
438 | 439 | var arr = new Array(); |
439 | 440 | var carr = su.data.data.pageData; |
440 | 441 | th.data.cartlist_y = carr; //存储原始购物车列表 |
441 | - th.data.in_zhact_gdmap={}; | |
442 | + th.data.in_zhact_gdmap = {}; | |
442 | 443 | |
443 | 444 | //---是不是购买等级卡成功的返回---等级卡显示的判断--- |
444 | 445 | var is_card_back = getApp().globalData.is_card_back; |
... | ... | @@ -447,7 +448,7 @@ Page({ |
447 | 448 | var item1 = carr[i]; |
448 | 449 | //把已经购买了多少见的内容填入 |
449 | 450 | |
450 | - var goodsbuynum=0,promgoodsbuynum=0; | |
451 | + var goodsbuynum = 0, promgoodsbuynum = 0; | |
451 | 452 | //--要获得商品,该用户买了多少件,同步应用-- |
452 | 453 | await getApp().request.promiseGet("/api/weshop/ordergoods/getUserBuyGoodsNum", { |
453 | 454 | data: { |
... | ... | @@ -465,7 +466,7 @@ Page({ |
465 | 466 | goodsbuynum = buy_num_data.goodsbuynum; |
466 | 467 | }) |
467 | 468 | //如果有购买活动 |
468 | - item1.promgoodsbuynum=promgoodsbuynum; | |
469 | + item1.promgoodsbuynum = promgoodsbuynum; | |
469 | 470 | |
470 | 471 | //要把优惠活动加入,prom_goods_map中,赠品不要运算 |
471 | 472 | if (item1.prom_type == 3 && item1.is_gift != 1) { |
... | ... | @@ -473,8 +474,8 @@ Page({ |
473 | 474 | } |
474 | 475 | |
475 | 476 | //要把组合购的东西拿出来算一下 |
476 | - if(item1.prom_type == 7) { | |
477 | - if(!th.data.zuhe_map_good[item1.prom_id]) { | |
477 | + if (item1.prom_type == 7) { | |
478 | + if (!th.data.zuhe_map_good[item1.prom_id]) { | |
478 | 479 | var isok = 1; |
479 | 480 | var is_flag = 1; |
480 | 481 | //如果有组合购 |
... | ... | @@ -523,50 +524,49 @@ Page({ |
523 | 524 | } |
524 | 525 | }) |
525 | 526 | } |
526 | - else | |
527 | - { | |
528 | - item1.act = th.data.zhhe_act_map[item1.prom_id]; | |
527 | + else { | |
528 | + item1.act = th.data.zhhe_act_map[item1.prom_id]; | |
529 | 529 | } |
530 | 530 | } |
531 | - if(item1.prom_type==10){ | |
532 | - if(!th.data.ladder_map[item1.prom_id]){ | |
531 | + if (item1.prom_type == 10) { | |
532 | + if (!th.data.ladder_map[item1.prom_id]) { | |
533 | 533 | //如果有组合购 |
534 | 534 | var isok = 1; |
535 | - var is_flag=1; | |
536 | - var act=null; | |
537 | - var url="/api/weshop/prom/ladderForm/get/"+os.stoid+"/"+item1.prom_id; | |
535 | + var is_flag = 1; | |
536 | + var act = null; | |
537 | + var url = "/api/weshop/prom/ladderForm/get/" + os.stoid + "/" + item1.prom_id; | |
538 | 538 | await getApp().request.promiseGet(url, {}).then(res => { |
539 | - console.log(res,1000); | |
540 | - if(res.data.code==0 && res.data.data){ | |
541 | - if(res.data.data.isuse!=1){ | |
542 | - isok=0; | |
539 | + console.log(res, 1000); | |
540 | + if (res.data.code == 0 && res.data.data) { | |
541 | + if (res.data.data.isuse != 1) { | |
542 | + isok = 0; | |
543 | 543 | } |
544 | 544 | //如果活动已经结束 |
545 | - if(res.data.data.is_end==1){ | |
546 | - isok=0; | |
545 | + if (res.data.data.is_end == 1) { | |
546 | + isok = 0; | |
547 | 547 | } |
548 | 548 | //已经结束 |
549 | - if(ut.gettimestamp()>res.data.data.end_time){ | |
550 | - isok=0; | |
549 | + if (ut.gettimestamp() > res.data.data.end_time) { | |
550 | + isok = 0; | |
551 | 551 | } |
552 | 552 | //还未开始 |
553 | - if(ut.gettimestamp()<res.data.data.start_time){ | |
554 | - isok=0; | |
553 | + if (ut.gettimestamp() < res.data.data.start_time) { | |
554 | + isok = 0; | |
555 | 555 | } |
556 | - act=res.data.data; | |
556 | + act = res.data.data; | |
557 | 557 | |
558 | - }else{ | |
558 | + } else { | |
559 | 559 | //未找到商品的活动 |
560 | 560 | is_flag = 0; |
561 | 561 | } |
562 | 562 | }) |
563 | - if (!isok){ | |
563 | + if (!isok) { | |
564 | 564 | var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id; |
565 | 565 | getApp().request.delete(url, {}); |
566 | - th.data.ladder_map[item1.prom_id]=-1; | |
566 | + th.data.ladder_map[item1.prom_id] = -1; | |
567 | 567 | continue; |
568 | 568 | } |
569 | - th.data.ladder_map[item1.prom_id]=act; | |
569 | + th.data.ladder_map[item1.prom_id] = act; | |
570 | 570 | |
571 | 571 | //-- 获取阶梯规则 -- |
572 | 572 | var url1 = "/api/weshop/prom/ladderList/list"; |
... | ... | @@ -577,9 +577,9 @@ Page({ |
577 | 577 | await getApp().request.promiseGet(url1, { |
578 | 578 | data: req_data |
579 | 579 | }).then(rs1 => { |
580 | - if (rs1.data.code==0 && rs1.data.data) { | |
580 | + if (rs1.data.code == 0 && rs1.data.data) { | |
581 | 581 | var gdlist = rs1.data.data; |
582 | - th.data.ladder_map[item1.prom_id].ladder_list=gdlist; | |
582 | + th.data.ladder_map[item1.prom_id].ladder_list = gdlist; | |
583 | 583 | } |
584 | 584 | }) |
585 | 585 | } |
... | ... | @@ -616,7 +616,7 @@ Page({ |
616 | 616 | |
617 | 617 | item.original_img = oo.imghost + item.original_img; |
618 | 618 | |
619 | - var car_item=item; | |
619 | + var car_item = item; | |
620 | 620 | /*----接口要弄出来的,先顶着-----*/ |
621 | 621 | var pcid = car_item.pick_id; |
622 | 622 | var find = 0; |
... | ... | @@ -625,7 +625,7 @@ Page({ |
625 | 625 | if (arr.length > 0) { |
626 | 626 | for (var j = 0; j < arr.length; j++) { |
627 | 627 | if (arr[j].pickup_id == pcid) { |
628 | - if(item.is_gift!=1){ | |
628 | + if (item.is_gift != 1) { | |
629 | 629 | //确定配送方式 |
630 | 630 | if (arr[j].distr_t == 0) { |
631 | 631 | arr[j].distr_t = car_item.distr_type; |
... | ... | @@ -644,8 +644,8 @@ Page({ |
644 | 644 | break; |
645 | 645 | } |
646 | 646 | arr[j].exp_type = e_t; |
647 | - if (e_t == 0) th.setData({is_all_zt: 0}); | |
648 | - else if(e_t==1) th.setData({is_all_zt: 1}); | |
647 | + if (e_t == 0) th.setData({ is_all_zt: 0 }); | |
648 | + else if (e_t == 1) th.setData({ is_all_zt: 1 }); | |
649 | 649 | } |
650 | 650 | |
651 | 651 | //-- 把等级卡会优惠多少钱装进去 -- |
... | ... | @@ -688,8 +688,8 @@ Page({ |
688 | 688 | break; |
689 | 689 | } |
690 | 690 | //如果是物流的话,全部自提的控制要弄成0 |
691 | - if (e_t == 0) th.setData({is_all_zt: 0}); | |
692 | - else th.setData({is_all_zt: 1}); | |
691 | + if (e_t == 0) th.setData({ is_all_zt: 0 }); | |
692 | + else th.setData({ is_all_zt: 1 }); | |
693 | 693 | |
694 | 694 | var narr = new Array(); |
695 | 695 | narr.push(car_item); |
... | ... | @@ -748,11 +748,11 @@ Page({ |
748 | 748 | var offline_price = 0; |
749 | 749 | var offline_num = 0; |
750 | 750 | for (var c = 0; c < item.length; c++) { |
751 | - if(th.data.sales_rules!=2){ | |
752 | - item[c].offline_price=0; | |
751 | + if (th.data.sales_rules != 2) { | |
752 | + item[c].offline_price = 0; | |
753 | 753 | } |
754 | 754 | //-- 如果这个商品是线下取价的时候 -- |
755 | - if (item[c].offline_price > 0 && item[c].prom_type != 7 ) { | |
755 | + if (item[c].offline_price > 0 && item[c].prom_type != 7) { | |
756 | 756 | offline_price += (item[c].goods_price - item[c].offline_price) * item[c].goods_num; |
757 | 757 | offline_num += item[c].goods_num; |
758 | 758 | } |
... | ... | @@ -778,7 +778,7 @@ Page({ |
778 | 778 | var h_item = obj[var1]; |
779 | 779 | var gdlist = th.data.zuhe_map_good[h_item.prom_id]; |
780 | 780 | //获取活动需要的商品列表 |
781 | - u_item.zh_prom_goods[h_item.prom_id] = {gdlist: gdlist, act: h_item.act}; | |
781 | + u_item.zh_prom_goods[h_item.prom_id] = { gdlist: gdlist, act: h_item.act }; | |
782 | 782 | } |
783 | 783 | zh_calc.fir_set_arr(u_item, th); |
784 | 784 | } |
... | ... | @@ -792,10 +792,10 @@ Page({ |
792 | 792 | //存储不同阶梯促销活动的商品列表 |
793 | 793 | u_item.ladder_map = {}; |
794 | 794 | for (let var1 in obj) { |
795 | - var h_item=obj[var1]; | |
796 | - var act= th.data.ladder_map[h_item.prom_id]; | |
795 | + var h_item = obj[var1]; | |
796 | + var act = th.data.ladder_map[h_item.prom_id]; | |
797 | 797 | //获取活动需要的商品列表 |
798 | - u_item.ladder_map[h_item.prom_id] =act; | |
798 | + u_item.ladder_map[h_item.prom_id] = act; | |
799 | 799 | } |
800 | 800 | ladder_calc.fir_set_arr(u_item, th); |
801 | 801 | } |
... | ... | @@ -809,7 +809,7 @@ Page({ |
809 | 809 | setTimeout(function () { |
810 | 810 | var frozenQuan = null; |
811 | 811 | var url0 = "/api/weshop/users/frozenQuan/listFrozenQuan/" + app.globalData.user_id; |
812 | - app.request.promiseGet(url0, {1: 1}).then(res => { | |
812 | + app.request.promiseGet(url0, { 1: 1 }).then(res => { | |
813 | 813 | if (res.data.code == 0) { |
814 | 814 | frozenQuan = res.data.data; |
815 | 815 | th.data.frozenQuan = frozenQuan; |
... | ... | @@ -880,7 +880,7 @@ Page({ |
880 | 880 | th.data.card_name = th.data.userinfo.card_field; |
881 | 881 | gg.goods_price = gd[th.data.card_name]; |
882 | 882 | getApp().globalData.is_card_back = 0; |
883 | - th.setData({card_cut_price: 0}); | |
883 | + th.setData({ card_cut_price: 0 }); | |
884 | 884 | //如果是秒杀的返回 |
885 | 885 | if (gd.prom_type == 1) gd.prom_type = 0; |
886 | 886 | } else { |
... | ... | @@ -888,12 +888,12 @@ Page({ |
888 | 888 | //-- 搭配购的商品也可以单独购买,所以此时搭配购的商品要进行计算优惠 -- |
889 | 889 | if (!gg.collocation_goods && gd['prom_type'] != 6 && th.data.card_name && gd[th.data.card_name] > 0 && gg.goods_price > gd[th.data.card_name] && !th.data.userinfo.card_field) { |
890 | 890 | var cut_p = (gg.goods_price - gd[th.data.card_name]) * gg.goods_num; |
891 | - th.setData({card_cut_price: cut_p}); | |
891 | + th.setData({ card_cut_price: cut_p }); | |
892 | 892 | } |
893 | 893 | } |
894 | 894 | |
895 | - gd.prom_type=gg.prom_type?gg.prom_type:0; | |
896 | - gd.prom_id=gg.prom_id?gg.prom_id:0; | |
895 | + gd.prom_type = gg.prom_type ? gg.prom_type : 0; | |
896 | + gd.prom_id = gg.prom_id ? gg.prom_id : 0; | |
897 | 897 | |
898 | 898 | switch (gd.prom_type) { |
899 | 899 | case 0: |
... | ... | @@ -956,7 +956,7 @@ Page({ |
956 | 956 | ob.exp_sum_type = data.gift_exp_sum_type; //商品的物流计算方式 |
957 | 957 | ob.uniform_exp_sum = data.gift_uniform_exp_sum //统一运费的金额 |
958 | 958 | |
959 | - th.setData({buy_now_gift_goods: ob}); | |
959 | + th.setData({ buy_now_gift_goods: ob }); | |
960 | 960 | } |
961 | 961 | } |
962 | 962 | |
... | ... | @@ -990,7 +990,7 @@ Page({ |
990 | 990 | t.data.data.guide_id = gg.guide_id; |
991 | 991 | t.data.data.guide_type = gg.guide_type; |
992 | 992 | } |
993 | - th.setData({collocation_goods: gg.collocation_goods}); | |
993 | + th.setData({ collocation_goods: gg.collocation_goods }); | |
994 | 994 | |
995 | 995 | var cart_arr = new Array(); |
996 | 996 | //var narr=gg.collocation_goods; |
... | ... | @@ -1003,9 +1003,9 @@ Page({ |
1003 | 1003 | et = 1; |
1004 | 1004 | distr_t = 0; // 配送方式 0=用户自选 1=自提 2=物流 |
1005 | 1005 | for (var hi in narr) { |
1006 | - var dis_t = narr[hi].distr_type; | |
1006 | + var dis_t = narr[hi].distr_type; | |
1007 | 1007 | if (dis_t == 2) { |
1008 | - th.setData({is_all_zt: 0}); | |
1008 | + th.setData({ is_all_zt: 0 }); | |
1009 | 1009 | et = 0; |
1010 | 1010 | } |
1011 | 1011 | if (dis_t > 0) { |
... | ... | @@ -1046,7 +1046,7 @@ Page({ |
1046 | 1046 | if (gg.prom_type == 5) { |
1047 | 1047 | var frozenQuan = null; |
1048 | 1048 | var url0 = "/api/weshop/users/frozenQuan/listFrozenQuan/" + app.globalData.user_id; |
1049 | - app.request.promiseGet(url0, {1: 1}).then(res => { | |
1049 | + app.request.promiseGet(url0, { 1: 1 }).then(res => { | |
1050 | 1050 | if (res.data.code == 0) { |
1051 | 1051 | frozenQuan = res.data.data; |
1052 | 1052 | th.data.frozenQuan = frozenQuan; |
... | ... | @@ -1056,7 +1056,7 @@ Page({ |
1056 | 1056 | th.get_cart_quan(); |
1057 | 1057 | }); |
1058 | 1058 | |
1059 | - | |
1059 | + | |
1060 | 1060 | |
1061 | 1061 | } else { |
1062 | 1062 | //计算价格 |
... | ... | @@ -1070,13 +1070,13 @@ Page({ |
1070 | 1070 | case 1: //---秒杀----- |
1071 | 1071 | var quanlist = null; |
1072 | 1072 | getApp().request.get("/api/weshop/activitylist/getSJGoodsPriceNew/" + gd.store_id |
1073 | - + "/" + gd.goods_id + "/1/" + gd.prom_id+"/"+app.globalData.user_id, { | |
1073 | + + "/" + gd.goods_id + "/1/" + gd.prom_id + "/" + app.globalData.user_id, { | |
1074 | 1074 | success: async function (tt) { |
1075 | 1075 | if (tt.data.code == 0) { |
1076 | 1076 | //t.data.data.shop_price = tt.data.data.prom_price; |
1077 | 1077 | t.data.data.shop_price = tt.data.data.prom_user_price; |
1078 | - th.data.ckeck_quan_price=0; | |
1079 | - gd.is_xz_yh=1; | |
1078 | + th.data.ckeck_quan_price = 0; | |
1079 | + gd.is_xz_yh = 1; | |
1080 | 1080 | } else { |
1081 | 1081 | t.data.data.prom_id = 0; |
1082 | 1082 | t.data.data.prom_type = 0; |
... | ... | @@ -1098,7 +1098,7 @@ Page({ |
1098 | 1098 | //计算价格 |
1099 | 1099 | th.calculatePrice2(); |
1100 | 1100 | //获取优惠券,如果有券的钱,就调用 |
1101 | - if(th.data.ckeck_quan_price>0) th.get_buy_now_quan(); | |
1101 | + if (th.data.ckeck_quan_price > 0) th.get_buy_now_quan(); | |
1102 | 1102 | } |
1103 | 1103 | }); |
1104 | 1104 | |
... | ... | @@ -1106,7 +1106,7 @@ Page({ |
1106 | 1106 | |
1107 | 1107 | case 2: //--- 团购 --- |
1108 | 1108 | var quanlist = null; |
1109 | - getApp().request.get("/api/weshop/goods/groupBuy/getActInfo/" +os.stoid + "/" +gd.goods_id+"/"+ gd.prom_id, { | |
1109 | + getApp().request.get("/api/weshop/goods/groupBuy/getActInfo/" + os.stoid + "/" + gd.goods_id + "/" + gd.prom_id, { | |
1110 | 1110 | success: async function (tt) { |
1111 | 1111 | if (tt.data.code == 0) { |
1112 | 1112 | //t.data.data.shop_price = tt.data.data.prom_price; |
... | ... | @@ -1116,12 +1116,12 @@ Page({ |
1116 | 1116 | t.data.data.prom_type = 0; |
1117 | 1117 | } |
1118 | 1118 | |
1119 | - if(tt.data.data.isQuan){ | |
1119 | + if (tt.data.data.isQuan) { | |
1120 | 1120 | th.data.ckeck_quan_price = t.data.data.shop_price * gg.goods_num; |
1121 | 1121 | th.data.check_quan_price_list = t.data.data.shop_price * gg.goods_num + ""; |
1122 | 1122 | th.data.check_quan_ware_list = t.data.data.erpwareid + ""; |
1123 | - }else{ | |
1124 | - gd.is_xz_yh=1; | |
1123 | + } else { | |
1124 | + gd.is_xz_yh = 1; | |
1125 | 1125 | } |
1126 | 1126 | |
1127 | 1127 | th.setData({ |
... | ... | @@ -1137,7 +1137,7 @@ Page({ |
1137 | 1137 | //-- 计算价格 -- |
1138 | 1138 | th.calculatePrice2(); |
1139 | 1139 | //获取优惠券,如果有券的钱,就调用 |
1140 | - if(th.data.ckeck_quan_price>0) th.get_buy_now_quan(); | |
1140 | + if (th.data.ckeck_quan_price > 0) th.get_buy_now_quan(); | |
1141 | 1141 | } |
1142 | 1142 | }); |
1143 | 1143 | |
... | ... | @@ -1152,14 +1152,14 @@ Page({ |
1152 | 1152 | checkAddressList: function () { |
1153 | 1153 | var t = this; |
1154 | 1154 | return !(!this.data.order || null == this.data.order.userAddress) || (wx.showModal({ |
1155 | - title: "请先填写或选择收货地址~", | |
1156 | - success: function (a) { | |
1157 | - a.confirm ? t.enterAddressPage() : wx.navigateBack(); | |
1158 | - }, | |
1159 | - fail: function () { | |
1160 | - wx.navigateBack(); | |
1161 | - } | |
1162 | - }), !1); | |
1155 | + title: "请先填写或选择收货地址~", | |
1156 | + success: function (a) { | |
1157 | + a.confirm ? t.enterAddressPage() : wx.navigateBack(); | |
1158 | + }, | |
1159 | + fail: function () { | |
1160 | + wx.navigateBack(); | |
1161 | + } | |
1162 | + }), !1); | |
1163 | 1163 | }, |
1164 | 1164 | showInvoice: function () { |
1165 | 1165 | this.setData({ |
... | ... | @@ -1178,7 +1178,7 @@ Page({ |
1178 | 1178 | }, |
1179 | 1179 | keyUpChangeNum: function (t) { |
1180 | 1180 | var index = t.currentTarget.dataset.index; |
1181 | - var txt="user_note."+index; | |
1181 | + var txt = "user_note." + index; | |
1182 | 1182 | this.setData({ |
1183 | 1183 | maxWord: t.detail.value.length, |
1184 | 1184 | [txt]: t.detail.value |
... | ... | @@ -1268,7 +1268,7 @@ Page({ |
1268 | 1268 | } |
1269 | 1269 | |
1270 | 1270 | var pt_res = null; |
1271 | - await getApp().request.promisePost("/api/weshop/order/getGoodsSplit", { | |
1271 | + await getApp().request.promisePost("/api/weshop/order/getGoodsSplit", { | |
1272 | 1272 | is_json: 1, |
1273 | 1273 | data: pt_data |
1274 | 1274 | }).then(res => { |
... | ... | @@ -1323,11 +1323,11 @@ Page({ |
1323 | 1323 | if (item_map.s_coupon_id) { |
1324 | 1324 | if (!cart_item.s_coupon_id) { |
1325 | 1325 | cart_item.s_coupon_id = item_map.s_coupon_id + ""; |
1326 | - cart_item.g_coupon_num = [{'c_id': item_map.s_coupon_id, "num": item_map.s_coupon_num}]; | |
1326 | + cart_item.g_coupon_num = [{ 'c_id': item_map.s_coupon_id, "num": item_map.s_coupon_num }]; | |
1327 | 1327 | } |
1328 | 1328 | else { |
1329 | 1329 | cart_item.s_coupon_id += "," + item_map.s_coupon_id; |
1330 | - cart_item.g_coupon_num.push({'c_id': item_map.s_coupon_id, "num": item_map.s_coupon_num}) | |
1330 | + cart_item.g_coupon_num.push({ 'c_id': item_map.s_coupon_id, "num": item_map.s_coupon_num }) | |
1331 | 1331 | } |
1332 | 1332 | } |
1333 | 1333 | |
... | ... | @@ -1335,11 +1335,11 @@ Page({ |
1335 | 1335 | if (item_map.s_libao) { |
1336 | 1336 | if (!cart_item.s_libao) { |
1337 | 1337 | cart_item.s_libao = item_map.s_libao + ""; |
1338 | - cart_item.g_lb_num = [{'l_id': item_map.s_libao, "num": item_map.s_lb_num}]; | |
1338 | + cart_item.g_lb_num = [{ 'l_id': item_map.s_libao, "num": item_map.s_lb_num }]; | |
1339 | 1339 | } |
1340 | 1340 | else { |
1341 | 1341 | cart_item.s_libao += "," + item_map.s_libao; |
1342 | - cart_item.g_lb_num.push({'l_id': item_map.s_libao, "num": item_map.s_lb_num}) | |
1342 | + cart_item.g_lb_num.push({ 'l_id': item_map.s_libao, "num": item_map.s_lb_num }) | |
1343 | 1343 | } |
1344 | 1344 | } |
1345 | 1345 | } |
... | ... | @@ -1348,7 +1348,7 @@ Page({ |
1348 | 1348 | }, |
1349 | 1349 | |
1350 | 1350 | //-------------------计算订单价格------------------- |
1351 | - calculatePrice : function (t, s) { | |
1351 | + calculatePrice: function (t, s) { | |
1352 | 1352 | var th = this; |
1353 | 1353 | to.getConfig2(function (ee) { |
1354 | 1354 | to.getwuliuprice(async function (rs) { |
... | ... | @@ -1372,11 +1372,11 @@ Page({ |
1372 | 1372 | var no_ex_id = ee.no_ex_id; |
1373 | 1373 | var no_ex_good = null; |
1374 | 1374 | var by_qc = {}; |
1375 | - var out_of_weight=0; //超出多少重量 | |
1375 | + var out_of_weight = 0; //超出多少重量 | |
1376 | 1376 | if (no_ex_id && freight_free > 0) { |
1377 | 1377 | //-----------获取不包邮区域,不包邮商品------- |
1378 | 1378 | await getApp().request.promiseGet("/api/weshop/areaFeemail/getAreaGoods", { |
1379 | - data: {store_id: os.stoid, id: no_ex_id} | |
1379 | + data: { store_id: os.stoid, id: no_ex_id } | |
1380 | 1380 | }).then(res => { |
1381 | 1381 | if (res.data.code == 0 && res.data.data && res.data.data.length > 0) { |
1382 | 1382 | by_qc = res.data.data[0]; |
... | ... | @@ -1395,9 +1395,9 @@ Page({ |
1395 | 1395 | //调用函数计算每件商品的单价 |
1396 | 1396 | await th.calc_per(c_arr); |
1397 | 1397 | //调用函数计算每件组合购商品的单价, |
1398 | - await zh_calc.calc_zh_split_price(c_arr,th); | |
1398 | + await zh_calc.calc_zh_split_price(c_arr, th); | |
1399 | 1399 | //调用函数计算每件阶梯促销商品的单价, |
1400 | - await ladder_calc.calc_split_price(c_arr,th); | |
1400 | + await ladder_calc.calc_split_price(c_arr, th); | |
1401 | 1401 | //调用函数计算,优惠券优惠什么商品价格,优惠券优惠什么商品 |
1402 | 1402 | await th.get_cart_quan(c_arr); |
1403 | 1403 | //---循环购物车--- |
... | ... | @@ -1420,7 +1420,7 @@ Page({ |
1420 | 1420 | var cart_item = c_arr[i]; //就是每一单的意思 |
1421 | 1421 | var pickid = cart_item.pickup_id; |
1422 | 1422 | var o_price = 0; |
1423 | - var o_price_no_zh=0; //参与订单优惠叠加--组合购的金额汇总 | |
1423 | + var o_price_no_zh = 0; //参与订单优惠叠加--组合购的金额汇总 | |
1424 | 1424 | var o_shipping_price = 0, goods_weight = -1, goods_piece = -1; |
1425 | 1425 | var item = c_arr[i].goods; //就是每一单的从表的意思 |
1426 | 1426 | |
... | ... | @@ -1428,11 +1428,11 @@ Page({ |
1428 | 1428 | var quan_price = 0; |
1429 | 1429 | var coupon_price = 0; |
1430 | 1430 | var quan_no = null; |
1431 | - var is_has_zh=c_arr[i].is_has_zh; | |
1432 | - var is_has_ladder=c_arr[i].is_has_ladder; | |
1431 | + var is_has_zh = c_arr[i].is_has_zh; | |
1432 | + var is_has_ladder = c_arr[i].is_has_ladder; | |
1433 | 1433 | |
1434 | - var zh_prom_goods=c_arr[i].zh_prom_goods; //组合购计算的原始数据存储空间 | |
1435 | - var ladder_prom_goods=c_arr[i].ladder_prom_goods; //组合购计算的原始数据存储空间 | |
1434 | + var zh_prom_goods = c_arr[i].zh_prom_goods; //组合购计算的原始数据存储空间 | |
1435 | + var ladder_prom_goods = c_arr[i].ladder_prom_goods; //组合购计算的原始数据存储空间 | |
1436 | 1436 | |
1437 | 1437 | if (th.data.using_quan[pickid] != null && th.data.using_quan[pickid] != undefined) |
1438 | 1438 | quan_no = th.data.using_quan[pickid].coupon_no; |
... | ... | @@ -1461,66 +1461,65 @@ Page({ |
1461 | 1461 | //--------循环计算总价----------- |
1462 | 1462 | for (var j = 0; j < item.length; j++) { |
1463 | 1463 | |
1464 | - var is_no_zh=0; | |
1465 | - if(item[j].prom_type!=7 && item[j].prom_type!=10 ) is_no_zh=1; | |
1464 | + var is_no_zh = 0; | |
1465 | + if (item[j].prom_type != 7 && item[j].prom_type != 10) is_no_zh = 1; | |
1466 | 1466 | |
1467 | 1467 | //组合购的商品,且有订单优惠的叠加,is_orderyh就是优惠叠加 |
1468 | - if(item[j].prom_type==7 && th.data.zhhe_act_map && th.data.zhhe_act_map[item[j].prom_id] | |
1469 | - && th.data.zhhe_act_map[item[j].prom_id].is_orderyh ) | |
1470 | - { | |
1471 | - is_no_zh=1; | |
1468 | + if (item[j].prom_type == 7 && th.data.zhhe_act_map && th.data.zhhe_act_map[item[j].prom_id] | |
1469 | + && th.data.zhhe_act_map[item[j].prom_id].is_orderyh) { | |
1470 | + is_no_zh = 1; | |
1472 | 1471 | } |
1473 | 1472 | //阶梯购的商品,且有订单优惠的叠加,is_orderyh就是优惠叠加 |
1474 | - if(item[j].prom_type==10 && ladder_prom_goods && ladder_prom_goods[item[j].prom_id] | |
1475 | - && th.data.ladder_map[item[j].prom_id].is_useorderyh ) | |
1476 | - { | |
1477 | - is_no_zh=1; | |
1473 | + if (item[j].prom_type == 10 && ladder_prom_goods && ladder_prom_goods[item[j].prom_id] | |
1474 | + && th.data.ladder_map[item[j].prom_id].is_useorderyh) { | |
1475 | + is_no_zh = 1; | |
1478 | 1476 | } |
1479 | 1477 | |
1480 | - if(is_no_zh){ | |
1478 | + if (is_no_zh) { | |
1481 | 1479 | o_price_no_zh += item[j].goods_price * item[j].goods_num; |
1482 | 1480 | } |
1483 | 1481 | o_price += item[j].goods_price * item[j].goods_num; |
1484 | 1482 | |
1485 | 1483 | //判断是否有设置限制重量包邮,先看商品有没有包邮 |
1486 | - if(item[j]['is_past']!==1 && item[j]['exp_sum_type']==2){ | |
1484 | + if (item[j]['is_past'] !== 1 && item[j]['exp_sum_type'] == 2) { | |
1487 | 1485 | if (goods_weight < 0) goods_weight = 0; |
1488 | - //累积商品重量 每种商品的重量 * 数量 | |
1486 | + //累积商品重量 每种商品的重量 * 数量 | |
1489 | 1487 | goods_weight += item[j]['weight'] * item[j]['goods_num']; |
1490 | - if(weight_free > 0){ | |
1491 | - out_of_weight = (weight_free*1000) - goods_weight; | |
1488 | + if (weight_free > 0) { | |
1489 | + out_of_weight = (weight_free * 1000) - goods_weight; | |
1492 | 1490 | } |
1493 | 1491 | } |
1492 | + | |
1494 | 1493 | } |
1495 | 1494 | //判断是不是有组合购的金额 |
1496 | 1495 | var f_o_price = o_price; |
1497 | 1496 | //如果又优惠的钱,就要减价 |
1498 | - if (c_arr[i].cut_price > 0){ | |
1497 | + if (c_arr[i].cut_price > 0) { | |
1499 | 1498 | o_price -= c_arr[i].cut_price; |
1500 | - o_price_no_zh-=c_arr[i].cut_price; | |
1499 | + o_price_no_zh -= c_arr[i].cut_price; | |
1501 | 1500 | } |
1502 | 1501 | //如果有组合购优惠的钱,就要减价 |
1503 | - if (c_arr[i].zh_cut_price>0 || c_arr[i].zh_cut_price<0){ | |
1502 | + if (c_arr[i].zh_cut_price > 0 || c_arr[i].zh_cut_price < 0) { | |
1504 | 1503 | o_price -= c_arr[i].zh_cut_price; |
1505 | - if(o_price_no_zh>0){ | |
1504 | + if (o_price_no_zh > 0) { | |
1506 | 1505 | //找到那些可以订单优惠叠加的 |
1507 | - for(let ij in zh_prom_goods){ | |
1508 | - let kitem=zh_prom_goods[ij]; | |
1509 | - if(kitem.act.is_orderyh) | |
1510 | - o_price_no_zh-=kitem.cut_price; | |
1506 | + for (let ij in zh_prom_goods) { | |
1507 | + let kitem = zh_prom_goods[ij]; | |
1508 | + if (kitem.act.is_orderyh) | |
1509 | + o_price_no_zh -= kitem.cut_price; | |
1511 | 1510 | } |
1512 | 1511 | } |
1513 | 1512 | } |
1514 | 1513 | |
1515 | 1514 | //如果有组合购优惠的钱,就要减价 |
1516 | - if (c_arr[i].ladder_cut_price>0 || c_arr[i].ladder_cut_price<0){ | |
1515 | + if (c_arr[i].ladder_cut_price > 0 || c_arr[i].ladder_cut_price < 0) { | |
1517 | 1516 | o_price -= c_arr[i].ladder_cut_price; |
1518 | - if(o_price_no_zh>0){ | |
1517 | + if (o_price_no_zh > 0) { | |
1519 | 1518 | //找到那些可以订单优惠叠加的 |
1520 | - for(let ij in ladder_prom_goods){ | |
1521 | - let kitem=ladder_prom_goods[ij]; | |
1522 | - if(th.data.ladder_map[ij].is_useorderyh ) | |
1523 | - o_price_no_zh-=kitem.cut_price; | |
1519 | + for (let ij in ladder_prom_goods) { | |
1520 | + let kitem = ladder_prom_goods[ij]; | |
1521 | + if (th.data.ladder_map[ij].is_useorderyh) | |
1522 | + o_price_no_zh -= kitem.cut_price; | |
1524 | 1523 | } |
1525 | 1524 | } |
1526 | 1525 | } |
... | ... | @@ -1528,32 +1527,37 @@ Page({ |
1528 | 1527 | //-- 计算线下取价的功能 -- |
1529 | 1528 | if (cart_item.is_offline == 1) { |
1530 | 1529 | o_price = o_price - cart_item.offline_price; |
1531 | - o_price_no_zh-=c_arr[i].offline_price; | |
1530 | + o_price_no_zh -= c_arr[i].offline_price; | |
1532 | 1531 | } |
1533 | 1532 | //判断包邮券的钱,组合购的商品不使用优惠券 |
1534 | 1533 | var q_conditin = 0; |
1535 | 1534 | q_conditin = o_price - quan_price; |
1536 | - if(is_has_zh){ | |
1535 | + if (is_has_zh) { | |
1537 | 1536 | q_conditin = o_price_no_zh - quan_price; |
1538 | 1537 | } |
1539 | 1538 | cart_item.goods_price = f_o_price.toFixed(2); //商品总费用,用f_o_price来计算 |
1540 | 1539 | //计算物流费用 |
1541 | 1540 | cart_item.shipping_price = 0; |
1542 | 1541 | |
1542 | + th.data.is_no_past = 1; //不包邮标识符 | |
1543 | + | |
1543 | 1544 | //--有不包邮区域,且不免运费,全场的计算,要减到优惠金额 和券的金额-- |
1544 | 1545 | if (no_ex_id && freight_free > 0 && (o_price - quan_price) >= freight_free && cart_item.exp_type == 0 && (by_qc.region_list || by_qc.goods_list)) { |
1545 | 1546 | //如果有设置不包邮区域的时候 |
1546 | 1547 | if (by_qc.region_list != "" && by_qc.region_list != null && by_qc.region_list != undefined) { |
1547 | 1548 | if (th.check_by_area(by_qc.region_list)) { |
1548 | 1549 | freight_free = 0; |
1550 | + goods_weight = -1; | |
1551 | + out_of_weight = 0; | |
1549 | 1552 | th.data.is_no_by[pickid] = 1; |
1550 | - out_of_weight=0; | |
1551 | 1553 | } |
1552 | 1554 | } |
1553 | 1555 | //如果有设置不包邮区商品 |
1554 | 1556 | if (by_qc.goods_list != "" && by_qc.goods_list != undefined && by_qc != null && freight_free > 0) { |
1555 | 1557 | freight_free = 0; |
1556 | - out_of_weight=0; | |
1558 | + goods_weight = -1; | |
1559 | + out_of_weight = 0; | |
1560 | + th.data.is_no_by[pickid] = 1; | |
1557 | 1561 | no_ex_good = by_qc.goods_list; |
1558 | 1562 | } |
1559 | 1563 | } |
... | ... | @@ -1568,7 +1572,7 @@ Page({ |
1568 | 1572 | store_id: os.stoid, |
1569 | 1573 | isuse: 0, |
1570 | 1574 | //condition: q_conditin, |
1571 | - condition:cart_item.ckeck_quan_price, | |
1575 | + condition: cart_item.ckeck_quan_price, | |
1572 | 1576 | user_id: getApp().globalData.user_id, |
1573 | 1577 | pageSize: 2000 |
1574 | 1578 | } |
... | ... | @@ -1593,7 +1597,7 @@ Page({ |
1593 | 1597 | } |
1594 | 1598 | if (arr) { |
1595 | 1599 | th.data.get_by_quan_list_cart[pickid] = arr; |
1596 | - th.setData({get_by_quan_list_cart:th.data.get_by_quan_list_cart}); | |
1600 | + th.setData({ get_by_quan_list_cart: th.data.get_by_quan_list_cart }); | |
1597 | 1601 | //if (th.data.is_b_now) { |
1598 | 1602 | // th.setData({get_by_quan_list: arr}); |
1599 | 1603 | //} |
... | ... | @@ -1618,7 +1622,7 @@ Page({ |
1618 | 1622 | if (ut.isContained(arr, arr2)) { |
1619 | 1623 | getApp().my_warnning("全场不包邮商品和包邮券的重复", 0, th); |
1620 | 1624 | th.data.using_quan[pickid] = {}; |
1621 | - th.setData({using_quan: th.data.using_quan}) | |
1625 | + th.setData({ using_quan: th.data.using_quan }) | |
1622 | 1626 | return false; |
1623 | 1627 | } |
1624 | 1628 | var n_arr = ut.mergeArray(arr, arr2); |
... | ... | @@ -1657,7 +1661,7 @@ Page({ |
1657 | 1661 | if (no_ex_good) no_ex_good_arr = no_ex_good.split(','); |
1658 | 1662 | |
1659 | 1663 | //----------------如果是选择了物流--------------------- |
1660 | - if (cart_item.exp_type == 0 && item[j].is_free_shipping == 0 && (!no_ex_good_arr || no_ex_good_arr.indexOf(item[j].goods_id + '') > -1 )) { | |
1664 | + if (cart_item.exp_type == 0 && item[j].is_free_shipping == 0 && (!no_ex_good_arr || no_ex_good_arr.indexOf(item[j].goods_id + '') > -1)) { | |
1661 | 1665 | |
1662 | 1666 | //如果地址不为空 |
1663 | 1667 | if (th.data.user_addr != null) { |
... | ... | @@ -1666,13 +1670,15 @@ Page({ |
1666 | 1670 | //统一运费 |
1667 | 1671 | o_shipping_price += item[j]['uniform_exp_sum']; |
1668 | 1672 | break; |
1669 | - // case 2: //1464行已计算 不必重复计算 注释为:判断是否有设置限制重量包邮 | |
1670 | - // +'' | |
1671 | - // if (goods_weight < 0) goods_weight = 0; | |
1672 | - // //累积商品重量 每种商品的重量 * 数量 | |
1673 | - // goods_weight += item[j]['weight'] * item[j]['goods_num']; | |
1674 | - // out_of_weight = (weight_free*1000) - goods_weight; | |
1675 | - // break; | |
1673 | + case 2: | |
1674 | + +'' | |
1675 | + if (goods_weight < 0) goods_weight = 0; | |
1676 | + //累积商品重量 每种商品的重量 * 数量 | |
1677 | + goods_weight += item[j]['weight'] * item[j]['goods_num']; | |
1678 | + if (weight_free > 0) { | |
1679 | + out_of_weight = (weight_free * 1000) - goods_weight; | |
1680 | + } | |
1681 | + break; | |
1676 | 1682 | case 3: |
1677 | 1683 | if (goods_piece < 0) goods_piece = 0; |
1678 | 1684 | //累积商品数量 |
... | ... | @@ -1680,14 +1686,6 @@ Page({ |
1680 | 1686 | break; |
1681 | 1687 | } |
1682 | 1688 | } |
1683 | - }else{ | |
1684 | - if(item[j]['exp_sum_type']==2){ | |
1685 | - if(out_of_weight !==0){ | |
1686 | - goods_weight=-1; | |
1687 | - out_of_weight=0; | |
1688 | - } | |
1689 | - } | |
1690 | - | |
1691 | 1689 | } |
1692 | 1690 | } |
1693 | 1691 | |
... | ... | @@ -1698,8 +1696,8 @@ Page({ |
1698 | 1696 | if (th.data.wu_arr && th.data.wu_arr[cart_item.wind]) |
1699 | 1697 | code = th.data.wu_arr[cart_item.wind].code; |
1700 | 1698 | cart_item.shipping_price = |
1701 | - th.calculatewuliu(code, o_shipping_price, goods_weight,out_of_weight, | |
1702 | - goods_piece, th.data.user_addr, freight_free, o_price - quan_price, rs); | |
1699 | + th.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, | |
1700 | + goods_piece, th.data.user_addr, freight_free, o_price - quan_price, rs, pickid); | |
1703 | 1701 | |
1704 | 1702 | if (!th.data.using_quan[pickid] || th.data.using_quan[pickid].isby != 1) { |
1705 | 1703 | if (cart_item.shipping_price == 0) th.data.is_by[pickid] = 1; //已经全场包邮,就不要选择券了 |
... | ... | @@ -1718,26 +1716,26 @@ Page({ |
1718 | 1716 | var order_prom_id = 0; |
1719 | 1717 | var o_condition = cart_item.order_amount; |
1720 | 1718 | //看一下是不是不用组合购的订单优惠的叠加 |
1721 | - if(is_has_zh){ | |
1722 | - o_condition=o_price_no_zh-quan_price; | |
1719 | + if (is_has_zh) { | |
1720 | + o_condition = o_price_no_zh - quan_price; | |
1723 | 1721 | } |
1724 | 1722 | |
1725 | 1723 | //看一下是不是不用组合购的订单优惠的叠加 |
1726 | - if(is_has_ladder){ | |
1727 | - o_condition=o_price_no_zh-quan_price; | |
1724 | + if (is_has_ladder) { | |
1725 | + o_condition = o_price_no_zh - quan_price; | |
1728 | 1726 | } |
1729 | 1727 | |
1730 | 1728 | |
1731 | 1729 | |
1732 | 1730 | var order_m = 0; |
1733 | 1731 | //---判断是不是有订单优惠--- |
1734 | - await getApp().request.promiseGet("/api/weshop/promorder/getOrderPromotion", { | |
1735 | - data: {store_id: os.stoid, orderAmount: o_condition} | |
1732 | + await getApp().request.promiseGet("/api/weshop/promorder/getOrderPromotion", { | |
1733 | + data: { store_id: os.stoid, orderAmount: o_condition } | |
1736 | 1734 | }).then(res => { |
1737 | 1735 | if (res.data.code == 0) { |
1738 | 1736 | var ord_prom = res.data.data; |
1739 | 1737 | //么有使用券,或者活动没有限制使用优惠券 |
1740 | - if(quan_price<=0 || !ord_prom.is_xz_yh) { | |
1738 | + if (quan_price <= 0 || !ord_prom.is_xz_yh) { | |
1741 | 1739 | order_prom_id = ord_prom['id']; |
1742 | 1740 | switch (ord_prom['type']) { |
1743 | 1741 | case 0: |
... | ... | @@ -1881,13 +1879,13 @@ Page({ |
1881 | 1879 | } |
1882 | 1880 | } |
1883 | 1881 | var set_txt = "cartlist[" + iter + "].can_num"; |
1884 | - th.setData({[set_txt]: num}); | |
1882 | + th.setData({ [set_txt]: num }); | |
1885 | 1883 | } |
1886 | 1884 | }, |
1887 | 1885 | |
1888 | 1886 | |
1889 | 1887 | //---------计算立即购买---------- |
1890 | - calculatePrice2 : function () { | |
1888 | + calculatePrice2: function () { | |
1891 | 1889 | var th = this, good = this.data.bn_goods; |
1892 | 1890 | |
1893 | 1891 | if (!good) return false; |
... | ... | @@ -1913,10 +1911,10 @@ Page({ |
1913 | 1911 | |
1914 | 1912 | allpice = parseFloat(allpice).toFixed(2); |
1915 | 1913 | var txt = "formData.all_price"; |
1916 | - th.setData({[txt]: allpice,}); | |
1914 | + th.setData({ [txt]: allpice, }); | |
1917 | 1915 | if (cut_price) { |
1918 | 1916 | var c_txt = "formData.cut_price"; |
1919 | - th.setData({[c_txt]: cut_price,}); | |
1917 | + th.setData({ [c_txt]: cut_price, }); | |
1920 | 1918 | |
1921 | 1919 | } |
1922 | 1920 | |
... | ... | @@ -1929,8 +1927,8 @@ Page({ |
1929 | 1927 | to.getConfig2(function (ee) { |
1930 | 1928 | to.getwuliuprice(async function (rs) { |
1931 | 1929 | |
1932 | - var o_shipping_price = 0,goods_weight = -1,goods_piece = -1; | |
1933 | - var out_of_weight=null; //超出多少重量 | |
1930 | + var o_shipping_price = 0, goods_weight = -1, goods_piece = -1; | |
1931 | + var out_of_weight = null; //超出多少重量 | |
1934 | 1932 | var freight_free = ee.freight_free; //全场满多少包邮 |
1935 | 1933 | var weight_free = ee.weight_free; //多少kg内包邮 |
1936 | 1934 | var no_ex_id = ee.no_ex_id; |
... | ... | @@ -1985,7 +1983,7 @@ Page({ |
1985 | 1983 | arr.push(item); |
1986 | 1984 | } |
1987 | 1985 | if (arr) { |
1988 | - th.setData({get_by_quan_list: arr}); | |
1986 | + th.setData({ get_by_quan_list: arr }); | |
1989 | 1987 | } |
1990 | 1988 | th.data.isget_by_quan[th.data.bn_pick] = 1; |
1991 | 1989 | } |
... | ... | @@ -2002,8 +2000,8 @@ Page({ |
2002 | 2000 | //dw |
2003 | 2001 | //累积商品重量 每种商品的重量 * 数量 |
2004 | 2002 | goods_weight += good['weight'] * good['buynum']; |
2005 | - if(weight_free > 0){ | |
2006 | - out_of_weight = (weight_free * 1000 ) - goods_weight; | |
2003 | + if (weight_free > 0) { | |
2004 | + out_of_weight = (weight_free * 1000) - goods_weight; | |
2007 | 2005 | } |
2008 | 2006 | break; |
2009 | 2007 | case 3: |
... | ... | @@ -2026,7 +2024,7 @@ Page({ |
2026 | 2024 | if (no_ex_id && freight_free > 0 && freight_free <= parseFloat(allpice) - cut_price - quan_price) { |
2027 | 2025 | //-----------获取不包邮区域,不包邮商品------- |
2028 | 2026 | await getApp().request.promiseGet("/api/weshop/areaFeemail/getAreaGoods", { |
2029 | - data: {store_id: os.stoid, id: no_ex_id} | |
2027 | + data: { store_id: os.stoid, id: no_ex_id } | |
2030 | 2028 | }).then(res => { |
2031 | 2029 | if (res.data.code == 0 && res.data.data && res.data.data.length > 0) { |
2032 | 2030 | no_by_data = res.data.data[0]; |
... | ... | @@ -2034,7 +2032,7 @@ Page({ |
2034 | 2032 | if (res.data.data[0].region_list) { |
2035 | 2033 | if (th.check_by_area(res.data.data[0].region_list)) { |
2036 | 2034 | freight_free = 0; |
2037 | - out_of_weight=0; | |
2035 | + out_of_weight = 0; | |
2038 | 2036 | th.data.is_no_by[th.data.bn_pick] = 1; |
2039 | 2037 | } |
2040 | 2038 | } |
... | ... | @@ -2042,7 +2040,7 @@ Page({ |
2042 | 2040 | if (res.data.data[0].goods_list && freight_free) { |
2043 | 2041 | if (th.check_by_goods(res.data.data[0].goods_list)) { |
2044 | 2042 | freight_free = 0; |
2045 | - out_of_weight=0; | |
2043 | + out_of_weight = 0; | |
2046 | 2044 | th.data.is_no_by[th.data.bn_pick] = 1; |
2047 | 2045 | } |
2048 | 2046 | } |
... | ... | @@ -2053,12 +2051,12 @@ Page({ |
2053 | 2051 | th.data.is_by[th.data.bn_pick] = 0; |
2054 | 2052 | //--------------开始计算物流------------------ |
2055 | 2053 | var shipping_price = |
2056 | - th.calculatewuliu(code, o_shipping_price, goods_weight,out_of_weight, | |
2057 | - goods_piece, th.data.user_addr, freight_free, parseFloat(allpice) - cut_price - quan_price, rs); | |
2054 | + th.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, | |
2055 | + goods_piece, th.data.user_addr, freight_free, parseFloat(allpice) - cut_price - quan_price, rs, th.data.bn_pick); | |
2058 | 2056 | |
2059 | 2057 | //如果有赠品的时候,也要计算赠品的物流费用 |
2060 | 2058 | if (th.data.buy_now_gift_goods) { |
2061 | - shipping_price = th.get_now_gift_goods_wuliu(code, o_shipping_price, th.data.user_addr, gift_freight_free,out_of_weight, | |
2059 | + shipping_price = th.get_now_gift_goods_wuliu(code, o_shipping_price, th.data.user_addr, gift_freight_free, out_of_weight, | |
2062 | 2060 | parseFloat(allpice) - cut_price - quan_price, rs, shipping_price, no_by_data, goods_weight, goods_piece); |
2063 | 2061 | } |
2064 | 2062 | |
... | ... | @@ -2068,18 +2066,18 @@ Page({ |
2068 | 2066 | |
2069 | 2067 | shipping_price = parseFloat(shipping_price).toFixed(2); |
2070 | 2068 | var wl_txt = "formData.shipping_price"; |
2071 | - th.setData({[wl_txt]: shipping_price,}) | |
2069 | + th.setData({ [wl_txt]: shipping_price, }) | |
2072 | 2070 | |
2073 | 2071 | } else { |
2074 | 2072 | var wl_txt = "formData.shipping_price"; |
2075 | - th.setData({[wl_txt]: 0,}) | |
2073 | + th.setData({ [wl_txt]: 0, }) | |
2076 | 2074 | } |
2077 | 2075 | |
2078 | 2076 | if (quan_no) { |
2079 | 2077 | if (th.data.using_quan[bn_pick].isby == 1) { |
2080 | 2078 | shipping_price = 0; |
2081 | 2079 | var wl_txt = "formData.shipping_price"; |
2082 | - th.setData({[wl_txt]: 0,}) | |
2080 | + th.setData({ [wl_txt]: 0, }) | |
2083 | 2081 | } |
2084 | 2082 | } |
2085 | 2083 | //-----------------支付价,优惠券不减物流----------------- |
... | ... | @@ -2099,7 +2097,7 @@ Page({ |
2099 | 2097 | if (th.data.order_prom[th.data.bn_pick]) { |
2100 | 2098 | var ord_prom = th.data.order_prom[th.data.bn_pick]; |
2101 | 2099 | //么有使用券,或者活动没有限制使用优惠券 |
2102 | - if(coupon_price<=0 || !ord_prom.is_xz_yh) { | |
2100 | + if (coupon_price <= 0 || !ord_prom.is_xz_yh) { | |
2103 | 2101 | order_prom_id = ord_prom['id']; |
2104 | 2102 | switch (ord_prom['type']) { |
2105 | 2103 | case 0: |
... | ... | @@ -2117,9 +2115,9 @@ Page({ |
2117 | 2115 | var order_prom_txt1 = "formData.order_prom_id"; |
2118 | 2116 | var order_prom_txt2 = "formData.order_prom_amount"; |
2119 | 2117 | if (order_prom_id > 0) { |
2120 | - th.setData({[order_prom_txt1]: order_prom_id, [order_prom_txt2]: order_prom_amount}) | |
2121 | - }else{ | |
2122 | - th.setData({[order_prom_txt1]: 0, [order_prom_txt2]: 0}) | |
2118 | + th.setData({ [order_prom_txt1]: order_prom_id, [order_prom_txt2]: order_prom_amount }) | |
2119 | + } else { | |
2120 | + th.setData({ [order_prom_txt1]: 0, [order_prom_txt2]: 0 }) | |
2123 | 2121 | } |
2124 | 2122 | |
2125 | 2123 | total_m = parseFloat(total_m) + parseFloat(th.data.formData.shipping_price); |
... | ... | @@ -2129,7 +2127,7 @@ Page({ |
2129 | 2127 | order_m = order_m.toFixed(2); |
2130 | 2128 | |
2131 | 2129 | var atxt = "formData.total_amount"; |
2132 | - th.setData({[atxt]: total_m,}) | |
2130 | + th.setData({ [atxt]: total_m, }) | |
2133 | 2131 | |
2134 | 2132 | var txt = "formData.user_money"; |
2135 | 2133 | var txt2 = "formData.order_amount"; |
... | ... | @@ -2139,44 +2137,44 @@ Page({ |
2139 | 2137 | if (th.data.bn_use_money == 1) { |
2140 | 2138 | if (amoney > order_m) { |
2141 | 2139 | order_m = parseFloat(order_m).toFixed(2); |
2142 | - th.setData({[txt]: order_m, [txt2]: 0, [txt3]: coupon_price, show_submit: 1}) | |
2140 | + th.setData({ [txt]: order_m, [txt2]: 0, [txt3]: coupon_price, show_submit: 1 }) | |
2143 | 2141 | } else { |
2144 | 2142 | order_m = parseFloat(order_m) - parseFloat(amoney); |
2145 | 2143 | order_m = order_m.toFixed(2); |
2146 | - th.setData({[txt]: amoney, [txt2]: order_m, [txt3]: coupon_price, show_submit: 1}) | |
2144 | + th.setData({ [txt]: amoney, [txt2]: order_m, [txt3]: coupon_price, show_submit: 1 }) | |
2147 | 2145 | } |
2148 | 2146 | } else { |
2149 | - th.setData({[txt]: 0, [txt2]: order_m, [txt3]: coupon_price, show_submit: 1}) | |
2147 | + th.setData({ [txt]: 0, [txt2]: order_m, [txt3]: coupon_price, show_submit: 1 }) | |
2150 | 2148 | } |
2151 | 2149 | //优惠活动送积分 |
2152 | 2150 | if (good.s_intValue) { |
2153 | 2151 | txt = "formData.give_integral"; |
2154 | - th.setData({[txt]: good.s_intValue}); | |
2152 | + th.setData({ [txt]: good.s_intValue }); | |
2155 | 2153 | } |
2156 | 2154 | //优惠送券 |
2157 | 2155 | if (good.s_coupon_id) { |
2158 | 2156 | var i_txt = "formData.give_coupon_id"; |
2159 | 2157 | //这个是json格式的 |
2160 | 2158 | var i_txt1 = "formData.g_coupon_num"; |
2161 | - var ob = [{"num": good.s_coupon_num, "c_id": good.s_coupon_id}]; | |
2159 | + var ob = [{ "num": good.s_coupon_num, "c_id": good.s_coupon_id }]; | |
2162 | 2160 | ob = JSON.stringify(ob); |
2163 | - th.setData({[i_txt]: good.s_coupon_id, [i_txt1]: ob}); | |
2161 | + th.setData({ [i_txt]: good.s_coupon_id, [i_txt1]: ob }); | |
2164 | 2162 | } |
2165 | 2163 | //优惠礼包 |
2166 | 2164 | if (good.s_libao) { |
2167 | 2165 | var l_txt = "formData.give_lb_id"; |
2168 | 2166 | //这个是json格式的 |
2169 | 2167 | var l_txt1 = "formData.g_lb_num"; |
2170 | - var ob = [{"num": good.s_lb_num, "l_id": good.s_libao}]; | |
2168 | + var ob = [{ "num": good.s_lb_num, "l_id": good.s_libao }]; | |
2171 | 2169 | ob = JSON.stringify(ob); |
2172 | - th.setData({[l_txt]: good.s_libao, [l_txt1]: ob}); | |
2170 | + th.setData({ [l_txt]: good.s_libao, [l_txt1]: ob }); | |
2173 | 2171 | } |
2174 | 2172 | }) |
2175 | 2173 | } else { |
2176 | 2174 | |
2177 | 2175 | var order_prom_txt1 = "formData.order_prom_id"; |
2178 | 2176 | var order_prom_txt2 = "formData.order_prom_amount"; |
2179 | - th.setData({[order_prom_txt1]: 0, [order_prom_txt2]: 0}) | |
2177 | + th.setData({ [order_prom_txt1]: 0, [order_prom_txt2]: 0 }) | |
2180 | 2178 | |
2181 | 2179 | |
2182 | 2180 | total_m = parseFloat(total_m) + parseFloat(th.data.formData.shipping_price); |
... | ... | @@ -2186,7 +2184,7 @@ Page({ |
2186 | 2184 | total_m = total_m.toFixed(2); |
2187 | 2185 | order_m = order_m.toFixed(2); |
2188 | 2186 | |
2189 | - th.setData({[atxt]: total_m,}) | |
2187 | + th.setData({ [atxt]: total_m, }) | |
2190 | 2188 | |
2191 | 2189 | var txt = "formData.user_money"; |
2192 | 2190 | var txt2 = "formData.order_amount"; |
... | ... | @@ -2196,37 +2194,37 @@ Page({ |
2196 | 2194 | if (th.data.bn_use_money == 1) { |
2197 | 2195 | if (amoney > order_m) { |
2198 | 2196 | order_m = parseFloat(order_m).toFixed(2); |
2199 | - th.setData({[txt]: order_m, [txt2]: 0, [txt3]: coupon_price, show_submit: 1}) | |
2197 | + th.setData({ [txt]: order_m, [txt2]: 0, [txt3]: coupon_price, show_submit: 1 }) | |
2200 | 2198 | } else { |
2201 | 2199 | order_m = parseFloat(order_m) - parseFloat(amoney); |
2202 | 2200 | order_m = order_m.toFixed(2); |
2203 | - th.setData({[txt]: amoney, [txt2]: order_m, [txt3]: coupon_price, show_submit: 1}) | |
2201 | + th.setData({ [txt]: amoney, [txt2]: order_m, [txt3]: coupon_price, show_submit: 1 }) | |
2204 | 2202 | } |
2205 | 2203 | } else { |
2206 | - th.setData({[txt]: 0, [txt2]: order_m, [txt3]: coupon_price, show_submit: 1}) | |
2204 | + th.setData({ [txt]: 0, [txt2]: order_m, [txt3]: coupon_price, show_submit: 1 }) | |
2207 | 2205 | } |
2208 | 2206 | //优惠活动送积分 |
2209 | 2207 | if (good.s_intValue) { |
2210 | 2208 | txt = "formData.give_integral"; |
2211 | - th.setData({[txt]: good.s_intValue}); | |
2209 | + th.setData({ [txt]: good.s_intValue }); | |
2212 | 2210 | } |
2213 | 2211 | //优惠送券 |
2214 | 2212 | if (good.s_coupon_id) { |
2215 | 2213 | var i_txt = "formData.give_coupon_id"; |
2216 | 2214 | //这个是json格式的 |
2217 | 2215 | var i_txt1 = "formData.g_coupon_num"; |
2218 | - var ob = [{"num": good.s_coupon_num, "c_id": good.s_coupon_id}]; | |
2216 | + var ob = [{ "num": good.s_coupon_num, "c_id": good.s_coupon_id }]; | |
2219 | 2217 | ob = JSON.stringify(ob); |
2220 | - th.setData({[i_txt]: good.s_coupon_id, [i_txt1]: ob}); | |
2218 | + th.setData({ [i_txt]: good.s_coupon_id, [i_txt1]: ob }); | |
2221 | 2219 | } |
2222 | 2220 | //优惠礼包 |
2223 | 2221 | if (good.s_libao) { |
2224 | 2222 | var l_txt = "formData.give_lb_id"; |
2225 | 2223 | //这个是json格式的 |
2226 | 2224 | var l_txt1 = "formData.g_lb_num"; |
2227 | - var ob = [{"num": good.s_lb_num, "l_id": good.s_libao}]; | |
2225 | + var ob = [{ "num": good.s_lb_num, "l_id": good.s_libao }]; | |
2228 | 2226 | ob = JSON.stringify(ob); |
2229 | - th.setData({[l_txt]: good.s_coupon_id, [l_txt1]: ob}); | |
2227 | + th.setData({ [l_txt]: good.s_coupon_id, [l_txt1]: ob }); | |
2230 | 2228 | } |
2231 | 2229 | } |
2232 | 2230 | |
... | ... | @@ -2236,17 +2234,17 @@ Page({ |
2236 | 2234 | }); |
2237 | 2235 | }, |
2238 | 2236 | |
2239 | - requestSubscribe(){ | |
2240 | - const th=this; | |
2237 | + requestSubscribe() { | |
2238 | + const th = this; | |
2241 | 2239 | const template_id = this.data.template_id; |
2242 | 2240 | wx.getSetting({ |
2243 | - withSubscriptions:true, | |
2244 | - success(res){ | |
2245 | - let itemSettings=res.subscriptionsSetting.itemSettings; | |
2246 | - if(itemSettings && itemSettings[template_id]=="accept"){ | |
2241 | + withSubscriptions: true, | |
2242 | + success(res) { | |
2243 | + let itemSettings = res.subscriptionsSetting.itemSettings; | |
2244 | + if (itemSettings && itemSettings[template_id] == "accept") { | |
2247 | 2245 | th.submit_func(); |
2248 | - }else{ | |
2249 | - th.sendsm(function(){ | |
2246 | + } else { | |
2247 | + th.sendsm(function () { | |
2250 | 2248 | th.submit_func(); |
2251 | 2249 | }) |
2252 | 2250 | } |
... | ... | @@ -2255,12 +2253,12 @@ Page({ |
2255 | 2253 | }, |
2256 | 2254 | |
2257 | 2255 | //--------------------提交订单----------------------- |
2258 | - async submit_func(){ | |
2256 | + async submit_func() { | |
2259 | 2257 | if (this.data.is_summit_ing == 1) return false; //--提交中退出-- |
2260 | 2258 | this.data.is_summit_ing = 1; |
2261 | 2259 | var th = this, pdata = new Array(); |
2262 | 2260 | var ff = true; |
2263 | - | |
2261 | + | |
2264 | 2262 | //------------立即购买------------- |
2265 | 2263 | if (th.data.is_b_now == 1 && th.data.bn_goods.prom_type != 5) { |
2266 | 2264 | if (th.data.bn_exp_type == 0 && th.data.user_addr == null) { |
... | ... | @@ -2277,7 +2275,7 @@ Page({ |
2277 | 2275 | th.data.is_summit_ing = 0; |
2278 | 2276 | return false; |
2279 | 2277 | } |
2280 | - | |
2278 | + | |
2281 | 2279 | var item = { |
2282 | 2280 | 'user_id': to.globalData.user_id, |
2283 | 2281 | 'consignee': addr == null ? "" : addr.consignee, |
... | ... | @@ -2298,7 +2296,7 @@ Page({ |
2298 | 2296 | 'user_money': th.data.formData.user_money, //使用余额 |
2299 | 2297 | 'total_amount': th.data.formData.total_amount, //订单总价 |
2300 | 2298 | 'order_amount': th.data.formData.order_amount, //应付 |
2301 | - 'user_note': th.data.user_note['0']?th.data.user_note['0']:0, //用户备注 | |
2299 | + 'user_note': th.data.user_note['0'] ? th.data.user_note['0'] : 0, //用户备注 | |
2302 | 2300 | 'store_id': oo.stoid, //商家 |
2303 | 2301 | 'pickup_id': th.data.bn_pick, //门店 |
2304 | 2302 | 'exp_type': th.data.bn_exp_type, //配送方式 |
... | ... | @@ -2324,7 +2322,7 @@ Page({ |
2324 | 2322 | } |
2325 | 2323 | |
2326 | 2324 | //--判断优惠活动的提交-- |
2327 | - if (th.data.formData.cut_price > 0 ) { | |
2325 | + if (th.data.formData.cut_price > 0) { | |
2328 | 2326 | order_prom_list.discount_amount = th.data.formData.cut_price.toFixed(2); |
2329 | 2327 | var ob = [{ |
2330 | 2328 | "prom_id": th.data.bn_goods.prom_id, |
... | ... | @@ -2387,7 +2385,7 @@ Page({ |
2387 | 2385 | goods.guide_id = gg.guide_id; |
2388 | 2386 | goods.guide_type = gg.guide_type; |
2389 | 2387 | //调用接口判断是不是会员 |
2390 | - await getApp().request.promiseGet("/api/weshop/shoppingGuide/getId/" + oo.stoid + "/" + gg.guide_id, {}).then(res => { | |
2388 | + await getApp().request.promiseGet("/api/weshop/shoppingGuide/getId/" + oo.stoid + "/" + gg.guide_id, {}).then(res => { | |
2391 | 2389 | if (res.data.code == 0) { |
2392 | 2390 | goods.guide_name = res.data.data.salesman; |
2393 | 2391 | goods.guide_sn = res.data.data.salesman_no; |
... | ... | @@ -2439,7 +2437,7 @@ Page({ |
2439 | 2437 | } |
2440 | 2438 | |
2441 | 2439 | var pt_res = null; |
2442 | - await getApp().request.promisePost("/api/weshop/order/getGoodsSplit", { | |
2440 | + await getApp().request.promisePost("/api/weshop/order/getGoodsSplit", { | |
2443 | 2441 | is_json: 1, |
2444 | 2442 | data: pt_data |
2445 | 2443 | }).then(res => { |
... | ... | @@ -2497,7 +2495,7 @@ Page({ |
2497 | 2495 | } |
2498 | 2496 | pdata.push(item); |
2499 | 2497 | } else { |
2500 | - | |
2498 | + | |
2501 | 2499 | //---------购物车的结算--------- |
2502 | 2500 | if (th.data.is_all_zt == 0 && th.data.user_addr == null) { |
2503 | 2501 | th.data.is_summit_ing = 0; |
... | ... | @@ -2518,7 +2516,7 @@ Page({ |
2518 | 2516 | return false; |
2519 | 2517 | } |
2520 | 2518 | |
2521 | - var order_prom_list_cart = th.data.order_prom_list_cart;; | |
2519 | + var order_prom_list_cart = th.data.order_prom_list_cart;; | |
2522 | 2520 | console.log('xxxxxxxxxxxxxxxx', order_prom_list_cart) |
2523 | 2521 | //--组装推送数据-- |
2524 | 2522 | for (var i = 0; i < order_prom_list_cart.length; i++) { |
... | ... | @@ -2571,23 +2569,23 @@ Page({ |
2571 | 2569 | order_prom_list.order_prom_amount = t_item.order_prom_amount; |
2572 | 2570 | } |
2573 | 2571 | |
2574 | - order_prom_list.discount_amount =0; | |
2572 | + order_prom_list.discount_amount = 0; | |
2575 | 2573 | //--判断优惠活动的提交-- |
2576 | 2574 | if (t_item.cut_price > 0) { |
2577 | 2575 | order_prom_list.discount_amount += t_item.cut_price; |
2578 | 2576 | } |
2579 | 2577 | //--判断组合优惠活动的提交-- |
2580 | - if (t_item.zh_cut_price > 0 || t_item.zh_cut_price<0) { | |
2578 | + if (t_item.zh_cut_price > 0 || t_item.zh_cut_price < 0) { | |
2581 | 2579 | order_prom_list.discount_amount += t_item.zh_cut_price; |
2582 | 2580 | order_prom_list.zh_pt_json = JSON.stringify(t_item.zh_pt_json); |
2583 | 2581 | } |
2584 | 2582 | |
2585 | 2583 | //--判断阶梯优惠活动的提交-- |
2586 | - if (t_item.ladder_cut_price > 0 || t_item.ladder_cut_price<0) { | |
2584 | + if (t_item.ladder_cut_price > 0 || t_item.ladder_cut_price < 0) { | |
2587 | 2585 | order_prom_list.discount_amount += t_item.ladder_cut_price; |
2588 | 2586 | } |
2589 | 2587 | |
2590 | - if(t_item.prom_pt_json){ | |
2588 | + if (t_item.prom_pt_json) { | |
2591 | 2589 | order_prom_list.prom_pt_json = JSON.stringify(t_item.prom_pt_json); |
2592 | 2590 | } |
2593 | 2591 | |
... | ... | @@ -2602,11 +2600,11 @@ Page({ |
2602 | 2600 | order_prom_list.give_lb_id = t_item.s_libao; |
2603 | 2601 | order_prom_list.g_lb_num = JSON.stringify(t_item.g_lb_num); |
2604 | 2602 | } |
2605 | - if (Object.keys(order_prom_list).length > 0){ | |
2606 | - if(order_prom_list.discount_amount) | |
2607 | - order_prom_list.discount_amount= parseFloat(order_prom_list.discount_amount).toFixed(2); | |
2608 | - if(order_prom_list.order_prom_amount) | |
2609 | - order_prom_list.order_prom_amount= parseFloat(order_prom_list.order_prom_amount).toFixed(2); | |
2603 | + if (Object.keys(order_prom_list).length > 0) { | |
2604 | + if (order_prom_list.discount_amount) | |
2605 | + order_prom_list.discount_amount = parseFloat(order_prom_list.discount_amount).toFixed(2); | |
2606 | + if (order_prom_list.order_prom_amount) | |
2607 | + order_prom_list.order_prom_amount = parseFloat(order_prom_list.order_prom_amount).toFixed(2); | |
2610 | 2608 | item.order_prom_list = order_prom_list; |
2611 | 2609 | } |
2612 | 2610 | |
... | ... | @@ -2628,18 +2626,18 @@ Page({ |
2628 | 2626 | //房间号的ids |
2629 | 2627 | var room_ids = ""; |
2630 | 2628 | |
2631 | - //-- 把券的钱,写入从表 --- | |
2632 | - if (t_item.quan_youhui_list && t_item.coupon_price) { | |
2629 | + //-- 把券的钱,写入从表 --- | |
2630 | + if (t_item.quan_youhui_list && t_item.coupon_price) { | |
2633 | 2631 | for (var kk in t_item.quan_youhui_list) { |
2634 | 2632 | var you_item = t_item.quan_youhui_list[kk]; |
2635 | 2633 | //-- 对券的价格进行平摊 -- |
2636 | - await th.split_set_goods_quanprice(you_item,t_item); | |
2634 | + await th.split_set_goods_quanprice(you_item, t_item); | |
2637 | 2635 | } |
2638 | 2636 | } |
2639 | 2637 | //-------------让商品添加到商品列表-------------------- |
2640 | 2638 | for (var k = 0; k < t_item.goods.length; k++) { |
2641 | 2639 | var g_item = t_item.goods[k]; |
2642 | - if(g_item.goods_num<=0) continue; | |
2640 | + if (g_item.goods_num <= 0) continue; | |
2643 | 2641 | var goods = { |
2644 | 2642 | 'goods_id': g_item.goods_id, |
2645 | 2643 | 'goods_name': g_item.goods_name, |
... | ... | @@ -2652,20 +2650,20 @@ Page({ |
2652 | 2650 | }; |
2653 | 2651 | |
2654 | 2652 | //-- 线下取价也要写入,组合购的商品不能去线下价格 -- |
2655 | - if (g_item.offline_price && t_item.is_offline == 1 && g_item.prom_type!=7) { | |
2653 | + if (g_item.offline_price && t_item.is_offline == 1 && g_item.prom_type != 7) { | |
2656 | 2654 | goods.goods_price = g_item.offline_price; |
2657 | 2655 | goods.member_goods_price = g_item.offline_price; |
2658 | 2656 | goods.offline_cut = (g_item.goods_price - g_item.offline_price).toFixed(2); |
2659 | 2657 | goods.pricing_type = g_item.pricing_type; |
2660 | 2658 | } |
2661 | - if(g_item.quan_num){ | |
2662 | - goods.quan_num=g_item.quan_num; | |
2663 | - goods.quan_no=g_item.quan_no; | |
2659 | + if (g_item.quan_num) { | |
2660 | + goods.quan_num = g_item.quan_num; | |
2661 | + goods.quan_no = g_item.quan_no; | |
2664 | 2662 | } |
2665 | 2663 | //--判断活动的类型-- |
2666 | 2664 | switch (g_item.prom_type) { |
2667 | 2665 | case 1: |
2668 | - case 2: | |
2666 | + case 2: | |
2669 | 2667 | case 10: |
2670 | 2668 | goods.prom_type = g_item.prom_type; |
2671 | 2669 | goods.prom_id = g_item.prom_id; |
... | ... | @@ -2708,7 +2706,7 @@ Page({ |
2708 | 2706 | } |
2709 | 2707 | |
2710 | 2708 | //把优惠的平摊结果写进去 |
2711 | - if (g_item.account >= 0 || (g_item.account_yu != 0 && g_item.account!=undefined)) { | |
2709 | + if (g_item.account >= 0 || (g_item.account_yu != 0 && g_item.account != undefined)) { | |
2712 | 2710 | if (g_item.account >= 0) goods.account = g_item.account; |
2713 | 2711 | if (g_item.account_yu != 0) goods.account_yu = g_item.account_yu; |
2714 | 2712 | item.is_discount_amount = 1; |
... | ... | @@ -2719,7 +2717,7 @@ Page({ |
2719 | 2717 | goods.guide_id = g_item.guide_id; |
2720 | 2718 | goods.guide_type = g_item.guide_type; |
2721 | 2719 | //调用接口判断是不是会员 |
2722 | - await getApp().request.promiseGet("/api/weshop/shoppingGuide/getId/" + oo.stoid + "/" + g_item.guide_id, {}).then(res => { | |
2720 | + await getApp().request.promiseGet("/api/weshop/shoppingGuide/getId/" + oo.stoid + "/" + g_item.guide_id, {}).then(res => { | |
2723 | 2721 | if (res.data.code == 0) { |
2724 | 2722 | goods.guide_name = res.data.data.salesman; |
2725 | 2723 | goods.guide_sn = res.data.data.salesman_no; |
... | ... | @@ -2733,8 +2731,8 @@ Page({ |
2733 | 2731 | } |
2734 | 2732 | |
2735 | 2733 | //如果有阶梯促销 |
2736 | - if(g_item.ladder_list_id){ | |
2737 | - goods.ladder_list_id=g_item.ladder_list_id; | |
2734 | + if (g_item.ladder_list_id) { | |
2735 | + goods.ladder_list_id = g_item.ladder_list_id; | |
2738 | 2736 | } |
2739 | 2737 | |
2740 | 2738 | item.order_goods.push(goods); |
... | ... | @@ -2747,11 +2745,11 @@ Page({ |
2747 | 2745 | |
2748 | 2746 | |
2749 | 2747 | } |
2750 | - | |
2748 | + | |
2751 | 2749 | if (pdata.length == 0) return; |
2752 | 2750 | var str = JSON.stringify(pdata); |
2753 | 2751 | |
2754 | - wx.showLoading({title: "加载中"}); | |
2752 | + wx.showLoading({ title: "加载中" }); | |
2755 | 2753 | wx.request({ |
2756 | 2754 | url: oo.url + '/api/weshop/order/createWxdOrder', |
2757 | 2755 | data: str, |
... | ... | @@ -2780,7 +2778,7 @@ Page({ |
2780 | 2778 | }) |
2781 | 2779 | //要进行判断,如果是用微信支付,就要跳转到支付界面 |
2782 | 2780 | if (order_amount > 0) { |
2783 | - th.setData({isclose: 0}); | |
2781 | + th.setData({ isclose: 0 }); | |
2784 | 2782 | //void e.jumpToCart4({ |
2785 | 2783 | // order_sn: data.data, |
2786 | 2784 | //}, 1); |
... | ... | @@ -2795,12 +2793,12 @@ Page({ |
2795 | 2793 | }, function () { |
2796 | 2794 | //支付失败 |
2797 | 2795 | setTimeout(function () { |
2798 | - var cps=getCurrentPages(); | |
2799 | - if(cps.length>1){ | |
2800 | - wx.navigateBack({delta: 1}) | |
2801 | - }else{ | |
2802 | - getApp().goto("/pages/index/index/index"); | |
2803 | - } | |
2796 | + var cps = getCurrentPages(); | |
2797 | + if (cps.length > 1) { | |
2798 | + wx.navigateBack({ delta: 1 }) | |
2799 | + } else { | |
2800 | + getApp().goto("/pages/index/index/index"); | |
2801 | + } | |
2804 | 2802 | |
2805 | 2803 | }, 1000) |
2806 | 2804 | }, oo.stoid); |
... | ... | @@ -2818,7 +2816,7 @@ Page({ |
2818 | 2816 | if (t.data.code == 0) { |
2819 | 2817 | //app.my_warnning("支付成功",1,th); |
2820 | 2818 | //setTimeout(function () { |
2821 | - th.setData({isclose: 0}); | |
2819 | + th.setData({ isclose: 0 }); | |
2822 | 2820 | wx.redirectTo({ |
2823 | 2821 | url: "/pages/payment/pay_success/pay_success?type=2&order_sn=" + data.data, |
2824 | 2822 | }) |
... | ... | @@ -2843,7 +2841,7 @@ Page({ |
2843 | 2841 | cancelText: '取消', |
2844 | 2842 | confirmText: '确定', |
2845 | 2843 | showCancel: true, |
2846 | - success(res){ | |
2844 | + success(res) { | |
2847 | 2845 | if (res.cancel) { |
2848 | 2846 | return; |
2849 | 2847 | } else if (res.confirm) { |
... | ... | @@ -2877,11 +2875,11 @@ Page({ |
2877 | 2875 | |
2878 | 2876 | }, |
2879 | 2877 | //---确认线下门店的数量足不足--- |
2880 | - async check_store_num(goods_id, pick, goods_num, func){ | |
2878 | + async check_store_num(goods_id, pick, goods_num, func) { | |
2881 | 2879 | var lock = 0, pick_no, plist, erpwareid; |
2882 | 2880 | //先读取门店的lock |
2883 | 2881 | await getApp().request.promiseGet("/api/weshop/order/ware/lock/page", { |
2884 | - data: {store_id: os.stoid, wareId: goods_id, storageId: pick, pageSize: 1000} | |
2882 | + data: { store_id: os.stoid, wareId: goods_id, storageId: pick, pageSize: 1000 } | |
2885 | 2883 | }).then(res => { |
2886 | 2884 | if (res.data.code == 0 && res.data.data.total > 0) { |
2887 | 2885 | for (var i in res.data.data.pageData) |
... | ... | @@ -2890,7 +2888,7 @@ Page({ |
2890 | 2888 | }) |
2891 | 2889 | //先获取门店的编号 |
2892 | 2890 | await getApp().request.promiseGet("/api/weshop/pickup/get/" + os.stoid + "/" + pick, { |
2893 | - data: {storeId: os.stoid, goodsId: t.goods_id, pickupId: pick} | |
2891 | + data: { storeId: os.stoid, goodsId: t.goods_id, pickupId: pick } | |
2894 | 2892 | }).then(res => { |
2895 | 2893 | if (res.data.code == 0) { |
2896 | 2894 | pick_no = res.data.data.pickup_no; |
... | ... | @@ -2898,7 +2896,7 @@ Page({ |
2898 | 2896 | }) |
2899 | 2897 | //先获取商品的线下库存 |
2900 | 2898 | await getApp().request.promiseGet("/api/weshop/goods/get/" + os.stoid + "/" + goods_id, { |
2901 | - data: {storeId: os.stoid, goodsId: t.goods_id, pickupId: pick} | |
2899 | + data: { storeId: os.stoid, goodsId: t.goods_id, pickupId: pick } | |
2902 | 2900 | }).then(res => { |
2903 | 2901 | if (res.data.code == 0) { |
2904 | 2902 | erpwareid = res.data.data.erpwareid; |
... | ... | @@ -2906,7 +2904,7 @@ Page({ |
2906 | 2904 | }) |
2907 | 2905 | //读取线下的门店库存 |
2908 | 2906 | await getApp().request.promiseGet("/api/weshop/goods/getWareStorages", { |
2909 | - data: {storageNos: pick_no, wareIds: encodeURIComponent(erpwareid), storeId: os.stoid, pageSize: 2000} | |
2907 | + data: { storageNos: pick_no, wareIds: encodeURIComponent(erpwareid), storeId: os.stoid, pageSize: 2000 } | |
2910 | 2908 | }).then(res => { |
2911 | 2909 | if (res.data.code == 0) { |
2912 | 2910 | plist = res.data.data.pageData[0]; |
... | ... | @@ -2948,11 +2946,11 @@ Page({ |
2948 | 2946 | wl_txt = t.currentTarget.dataset.wl_txt, |
2949 | 2947 | ont = t.currentTarget.dataset.ont; |
2950 | 2948 | |
2951 | - th.setData({[txt]: ty}); | |
2949 | + th.setData({ [txt]: ty }); | |
2952 | 2950 | var iszt = 1; |
2953 | 2951 | |
2954 | 2952 | if (ty == 0) { |
2955 | - th.setData({is_all_zt: 0}); | |
2953 | + th.setData({ is_all_zt: 0 }); | |
2956 | 2954 | } else { |
2957 | 2955 | for (var i = 0; i < th.data.cartlist.length; i++) { |
2958 | 2956 | var item = th.data.cartlist[i]; |
... | ... | @@ -2962,7 +2960,7 @@ Page({ |
2962 | 2960 | } |
2963 | 2961 | } |
2964 | 2962 | |
2965 | - th.setData({is_all_zt: iszt}); | |
2963 | + th.setData({ is_all_zt: iszt }); | |
2966 | 2964 | |
2967 | 2965 | var ind = t.currentTarget.dataset.ind; |
2968 | 2966 | var c_item = th.data.cartlist[ind]; |
... | ... | @@ -2970,7 +2968,7 @@ Page({ |
2970 | 2968 | |
2971 | 2969 | if (th.data.using_quan[pickid] && th.data.using_quan[pickid].isby == 1) { |
2972 | 2970 | th.data.using_quan[pickid] = {}; |
2973 | - th.setData({using_quan: th.data.using_quan}); | |
2971 | + th.setData({ using_quan: th.data.using_quan }); | |
2974 | 2972 | } |
2975 | 2973 | |
2976 | 2974 | |
... | ... | @@ -2982,7 +2980,7 @@ Page({ |
2982 | 2980 | for (var i = 0; i < wu_arr.length; i++) { |
2983 | 2981 | if (wu_arr[i].shipping_code == def_exp_code) { |
2984 | 2982 | var set_txt = "cartlist" |
2985 | - th.setData({wl_txt: i}); | |
2983 | + th.setData({ wl_txt: i }); | |
2986 | 2984 | } |
2987 | 2985 | } |
2988 | 2986 | } |
... | ... | @@ -2995,9 +2993,9 @@ Page({ |
2995 | 2993 | setexptype: function (t) { |
2996 | 2994 | var th = this; |
2997 | 2995 | var ty = t.currentTarget.dataset.t, def_exp_code = getApp().globalData.userInfo.def_exp_code; |
2998 | - th.setData({bn_exp_type: ty}); | |
2996 | + th.setData({ bn_exp_type: ty }); | |
2999 | 2997 | if (ty == 0) { |
3000 | - th.setData({is_all_zt: 0}); | |
2998 | + th.setData({ is_all_zt: 0 }); | |
3001 | 2999 | } |
3002 | 3000 | |
3003 | 3001 | //当物流为空的时候。 |
... | ... | @@ -3010,7 +3008,7 @@ Page({ |
3010 | 3008 | if (ty == 1) { |
3011 | 3009 | th.data.isget_by_quan = {}; |
3012 | 3010 | if (th.data.using_quan[th.data.bn_pick] && th.data.using_quan[th.data.bn_pick].isby == 1) { |
3013 | - th.setData({using_quan: {}}); | |
3011 | + th.setData({ using_quan: {} }); | |
3014 | 3012 | } |
3015 | 3013 | } |
3016 | 3014 | |
... | ... | @@ -3020,7 +3018,7 @@ Page({ |
3020 | 3018 | if (wu_arr != null && wu_arr != "") { |
3021 | 3019 | for (var i = 0; i < wu_arr.length; i++) { |
3022 | 3020 | if (wu_arr[i].shipping_code == def_exp_code) { |
3023 | - th.setData({index: i}); | |
3021 | + th.setData({ index: i }); | |
3024 | 3022 | } |
3025 | 3023 | } |
3026 | 3024 | } |
... | ... | @@ -3032,21 +3030,21 @@ Page({ |
3032 | 3030 | //--------立即购买时,使用余额-------- |
3033 | 3031 | set_bn_useyuer: function () { |
3034 | 3032 | var th = this; |
3035 | - th.setData({bn_use_money: !th.data.bn_use_money}); | |
3033 | + th.setData({ bn_use_money: !th.data.bn_use_money }); | |
3036 | 3034 | th.calculatePrice2(); |
3037 | 3035 | }, |
3038 | 3036 | set_js_useyuer: function () { |
3039 | 3037 | var th = this; |
3040 | - th.setData({js_use_money: !th.data.js_use_money}); | |
3038 | + th.setData({ js_use_money: !th.data.js_use_money }); | |
3041 | 3039 | th.calculatePrice(); |
3042 | 3040 | }, |
3043 | 3041 | //-------------------计算物流--------------- |
3044 | - calculatewuliu: function (code, o_shipping_price, goods_weight,out_of_weight, | |
3045 | - goods_piece, user_addr, freight_free, o_price, rs) { | |
3042 | + calculatewuliu: function (code, o_shipping_price, goods_weight, out_of_weight, | |
3043 | + goods_piece, user_addr, freight_free, o_price, rs, pickid) { | |
3046 | 3044 | var price = 0, th = this; |
3047 | 3045 | price += parseFloat(o_shipping_price); |
3048 | 3046 | //如果是包邮 |
3049 | - if (freight_free > 0 && o_price >= freight_free && out_of_weight>=0) { | |
3047 | + if (freight_free > 0 && o_price >= freight_free && out_of_weight >= 0) { | |
3050 | 3048 | return 0; |
3051 | 3049 | } |
3052 | 3050 | if (user_addr == null) { |
... | ... | @@ -3073,7 +3071,7 @@ Page({ |
3073 | 3071 | } |
3074 | 3072 | } |
3075 | 3073 | //------超出重量---------- |
3076 | - if(out_of_weight < 0 && o_price >= freight_free){ | |
3074 | + if (out_of_weight < 0 && o_price >= freight_free && !th.data.is_no_by[pickid]) { | |
3077 | 3075 | fw_price = parseFloat(item['money']); |
3078 | 3076 | var out_of_weight = Math.abs(out_of_weight); |
3079 | 3077 | if (out_of_weight > item['first_weight']) { |
... | ... | @@ -3119,13 +3117,13 @@ Page({ |
3119 | 3117 | //----------立即购买,选择物流------------- |
3120 | 3118 | bindPickerChange: function (e) { |
3121 | 3119 | var ind = e.detail.value |
3122 | - this.setData({index: ind}); | |
3120 | + this.setData({ index: ind }); | |
3123 | 3121 | this.calculatePrice2(); |
3124 | 3122 | }, |
3125 | 3123 | //----------购物车结算,选择物流------------- |
3126 | 3124 | bindPickerChange_w: function (e) { |
3127 | 3125 | var ind = e.detail.value, txt = e.currentTarget.dataset.txt; |
3128 | - this.setData({[txt]: ind}); | |
3126 | + this.setData({ [txt]: ind }); | |
3129 | 3127 | this.calculatePrice(); |
3130 | 3128 | }, |
3131 | 3129 | |
... | ... | @@ -3139,7 +3137,7 @@ Page({ |
3139 | 3137 | |
3140 | 3138 | |
3141 | 3139 | if (bn == 1) { |
3142 | - th.setData({open_quan: 1, selected_quan_pick: pickid, disabled: 1}); | |
3140 | + th.setData({ open_quan: 1, selected_quan_pick: pickid, disabled: 1 }); | |
3143 | 3141 | } else { |
3144 | 3142 | //---多单打开券的时候,就要判断券在其他门店是否有使用--- |
3145 | 3143 | var quanlist = th.data.cartlist[cindx].quan_list; |
... | ... | @@ -3165,9 +3163,9 @@ Page({ |
3165 | 3163 | else |
3166 | 3164 | get_by_quan_list_cart[i].show_red = 0; |
3167 | 3165 | } |
3168 | - th.setData({by_quan_list_cart: get_by_quan_list_cart}); | |
3166 | + th.setData({ by_quan_list_cart: get_by_quan_list_cart }); | |
3169 | 3167 | } else { |
3170 | - th.setData({by_quan_list_cart: null}); | |
3168 | + th.setData({ by_quan_list_cart: null }); | |
3171 | 3169 | } |
3172 | 3170 | |
3173 | 3171 | console.log("2222222券的列表", quanlist); |
... | ... | @@ -3183,7 +3181,7 @@ Page({ |
3183 | 3181 | }, |
3184 | 3182 | close_coupon: function (e) { |
3185 | 3183 | var th = this; |
3186 | - th.setData({open_quan: 0, disabled: 0}); | |
3184 | + th.setData({ open_quan: 0, disabled: 0 }); | |
3187 | 3185 | }, |
3188 | 3186 | |
3189 | 3187 | //---判断券时候在已经选择的列表中--- |
... | ... | @@ -3254,14 +3252,14 @@ Page({ |
3254 | 3252 | for (var i in quanlist) { |
3255 | 3253 | quanlist[i].show_red = 0; |
3256 | 3254 | } |
3257 | - this.setData({selected_quan_list: quanlist}); | |
3255 | + this.setData({ selected_quan_list: quanlist }); | |
3258 | 3256 | var by_quanlist = this.data.get_by_quan_list; |
3259 | 3257 | if (by_quanlist) { |
3260 | 3258 | //---所有的券的显示红色选择都清理一遍--- |
3261 | 3259 | for (var inb in by_quanlist) { |
3262 | 3260 | by_quanlist[inb].show_red = 0; |
3263 | 3261 | } |
3264 | - this.setData({get_by_quan_list: by_quanlist}); | |
3262 | + this.setData({ get_by_quan_list: by_quanlist }); | |
3265 | 3263 | } |
3266 | 3264 | |
3267 | 3265 | var by_cart_list = this.data.by_quan_list_cart; |
... | ... | @@ -3270,7 +3268,7 @@ Page({ |
3270 | 3268 | for (var inc in by_cart_list) { |
3271 | 3269 | by_cart_list[inc].show_red = 0; |
3272 | 3270 | } |
3273 | - this.setData({by_quan_list_cart: by_cart_list}); | |
3271 | + this.setData({ by_quan_list_cart: by_cart_list }); | |
3274 | 3272 | } |
3275 | 3273 | |
3276 | 3274 | var using_quan = this.data.using_quan; |
... | ... | @@ -3282,9 +3280,9 @@ Page({ |
3282 | 3280 | using_quan[th.data.selected_quan_pick].is_nouse_red = 1; |
3283 | 3281 | } |
3284 | 3282 | else { |
3285 | - using_quan[th.data.selected_quan_pick] = {is_nouse_red: 1}; | |
3283 | + using_quan[th.data.selected_quan_pick] = { is_nouse_red: 1 }; | |
3286 | 3284 | } |
3287 | - this.setData({using_quan: using_quan, is_coupon: th.is_coupon}); | |
3285 | + this.setData({ using_quan: using_quan, is_coupon: th.is_coupon }); | |
3288 | 3286 | return; |
3289 | 3287 | } |
3290 | 3288 | |
... | ... | @@ -3301,9 +3299,9 @@ Page({ |
3301 | 3299 | using_quan[th.data.selected_quan_pick].is_nouse_red = 0; |
3302 | 3300 | } |
3303 | 3301 | else { |
3304 | - using_quan[th.data.selected_quan_pick] = {is_nouse_red: 0}; | |
3302 | + using_quan[th.data.selected_quan_pick] = { is_nouse_red: 0 }; | |
3305 | 3303 | } |
3306 | - this.setData({using_quan: using_quan}); | |
3304 | + this.setData({ using_quan: using_quan }); | |
3307 | 3305 | |
3308 | 3306 | }, |
3309 | 3307 | |
... | ... | @@ -3318,7 +3316,7 @@ Page({ |
3318 | 3316 | for (var ind in by_quanlist) { |
3319 | 3317 | by_quanlist[ind].show_red = 0; |
3320 | 3318 | } |
3321 | - this.setData({get_by_quan_list: by_quanlist}); | |
3319 | + this.setData({ get_by_quan_list: by_quanlist }); | |
3322 | 3320 | } |
3323 | 3321 | |
3324 | 3322 | //--购物车过来的包邮券-- |
... | ... | @@ -3328,7 +3326,7 @@ Page({ |
3328 | 3326 | for (var ind in by_cart_list) { |
3329 | 3327 | by_cart_list[ind].show_red = 0; |
3330 | 3328 | } |
3331 | - this.setData({by_quan_list_cart: by_cart_list}); | |
3329 | + this.setData({ by_quan_list_cart: by_cart_list }); | |
3332 | 3330 | } |
3333 | 3331 | //普通券 |
3334 | 3332 | var quanlist = this.data.selected_quan_list; |
... | ... | @@ -3337,7 +3335,7 @@ Page({ |
3337 | 3335 | for (var ind in quanlist) { |
3338 | 3336 | quanlist[ind].show_red = 0; |
3339 | 3337 | } |
3340 | - this.setData({selected_quan_list: quanlist}); | |
3338 | + this.setData({ selected_quan_list: quanlist }); | |
3341 | 3339 | } |
3342 | 3340 | |
3343 | 3341 | var th = this; |
... | ... | @@ -3348,9 +3346,9 @@ Page({ |
3348 | 3346 | using_quan[th.data.selected_quan_pick].is_nouse_red = 1; |
3349 | 3347 | } |
3350 | 3348 | else { |
3351 | - using_quan[th.data.selected_quan_pick] = {is_nouse_red: 1}; | |
3349 | + using_quan[th.data.selected_quan_pick] = { is_nouse_red: 1 }; | |
3352 | 3350 | } |
3353 | - this.setData({using_quan: using_quan, is_coupon: th.is_coupon}); | |
3351 | + this.setData({ using_quan: using_quan, is_coupon: th.is_coupon }); | |
3354 | 3352 | return; |
3355 | 3353 | } |
3356 | 3354 | |
... | ... | @@ -3379,9 +3377,9 @@ Page({ |
3379 | 3377 | using_quan[th.data.selected_quan_pick].is_nouse_red = 0; |
3380 | 3378 | } |
3381 | 3379 | else { |
3382 | - using_quan[th.data.selected_quan_pick] = {is_nouse_red: 0}; | |
3380 | + using_quan[th.data.selected_quan_pick] = { is_nouse_red: 0 }; | |
3383 | 3381 | } |
3384 | - this.setData({using_quan: using_quan}); | |
3382 | + this.setData({ using_quan: using_quan }); | |
3385 | 3383 | }, |
3386 | 3384 | |
3387 | 3385 | //--确认使用券--- |
... | ... | @@ -3441,14 +3439,14 @@ Page({ |
3441 | 3439 | //选择了的券,看是不是点击了不使用券,点击了不使用优惠券 |
3442 | 3440 | if (using_quan[pickid]) { |
3443 | 3441 | if (using_quan[pickid].is_nouse_red == 1) { |
3444 | - using_quan[pickid] = {is_nouse_red: 1}; | |
3445 | - th.setData({using_quan: using_quan}); | |
3442 | + using_quan[pickid] = { is_nouse_red: 1 }; | |
3443 | + th.setData({ using_quan: using_quan }); | |
3446 | 3444 | if (th.data.is_b_now == 1) { |
3447 | 3445 | th.calculatePrice2(); |
3448 | 3446 | } else { |
3449 | 3447 | th.calculatePrice(); |
3450 | 3448 | } |
3451 | - th.setData({open_quan: 0}); | |
3449 | + th.setData({ open_quan: 0 }); | |
3452 | 3450 | return; |
3453 | 3451 | } |
3454 | 3452 | } |
... | ... | @@ -3467,16 +3465,16 @@ Page({ |
3467 | 3465 | }; |
3468 | 3466 | using_quan[pickid].isby = 1; |
3469 | 3467 | } else { |
3470 | - using_quan[pickid] = {coupon_no: item.CashRepNo, money: item.Sum, is_nouse_red: 0}; | |
3468 | + using_quan[pickid] = { coupon_no: item.CashRepNo, money: item.Sum, is_nouse_red: 0 }; | |
3471 | 3469 | using_quan[pickid].isby = 0; |
3472 | 3470 | } |
3473 | - this.setData({using_quan: using_quan}); | |
3471 | + this.setData({ using_quan: using_quan }); | |
3474 | 3472 | if (th.data.is_b_now == 1) { |
3475 | 3473 | th.calculatePrice2(); |
3476 | 3474 | } else { |
3477 | 3475 | th.calculatePrice(); |
3478 | 3476 | } |
3479 | - th.setData({open_quan: 0}); | |
3477 | + th.setData({ open_quan: 0 }); | |
3480 | 3478 | }, |
3481 | 3479 | |
3482 | 3480 | cart_set_err: function (e) { |
... | ... | @@ -3513,7 +3511,7 @@ Page({ |
3513 | 3511 | var wu_arr_txt = e.currentTarget.dataset.txt; |
3514 | 3512 | var w_sele_index = e.currentTarget.dataset.w_sele_index; |
3515 | 3513 | var is_express = null; |
3516 | - var ob = {open_express: 1, wu_arr_txt: wu_arr_txt, disabled: 1}; | |
3514 | + var ob = { open_express: 1, wu_arr_txt: wu_arr_txt, disabled: 1 }; | |
3517 | 3515 | |
3518 | 3516 | //--如果是多个门店的时候-- |
3519 | 3517 | if (w_sele_index != undefined) { |
... | ... | @@ -3524,20 +3522,20 @@ Page({ |
3524 | 3522 | }, |
3525 | 3523 | // 关闭物流的弹窗 |
3526 | 3524 | close_express: function () { |
3527 | - this.setData({open_express: 0, disabled: 0}); | |
3525 | + this.setData({ open_express: 0, disabled: 0 }); | |
3528 | 3526 | }, |
3529 | 3527 | // 选择物流 |
3530 | 3528 | click_express_name: function (e) { |
3531 | 3529 | var express_name = e.currentTarget.dataset.name, shippingcode = e.currentTarget.dataset.shippingcode; |
3532 | 3530 | var index = e.currentTarget.dataset.idxe; |
3533 | - var ob = {is_express: index, is_shipping_code: shippingcode, disabled: 0}; | |
3531 | + var ob = { is_express: index, is_shipping_code: shippingcode, disabled: 0 }; | |
3534 | 3532 | ob[this.data.wu_arr_txt] = index; |
3535 | 3533 | this.setData(ob); |
3536 | 3534 | }, |
3537 | 3535 | |
3538 | 3536 | //点击确定物流 |
3539 | 3537 | determine_expres: function (e) { |
3540 | - this.setData({open_express: 0}); | |
3538 | + this.setData({ open_express: 0 }); | |
3541 | 3539 | if (this.data.is_b_now == 1) |
3542 | 3540 | this.calculatePrice2(); |
3543 | 3541 | else |
... | ... | @@ -3557,7 +3555,7 @@ Page({ |
3557 | 3555 | obj[txt] = is_open; |
3558 | 3556 | |
3559 | 3557 | this.setData(obj); |
3560 | - this.setData({disabled: 1}) | |
3558 | + this.setData({ disabled: 1 }) | |
3561 | 3559 | }, |
3562 | 3560 | |
3563 | 3561 | clik_coupons2: function (e) { |
... | ... | @@ -3572,7 +3570,7 @@ Page({ |
3572 | 3570 | obj[txt] = is_open; |
3573 | 3571 | |
3574 | 3572 | this.setData(obj); |
3575 | - this.setData({disabled: 1}) | |
3573 | + this.setData({ disabled: 1 }) | |
3576 | 3574 | }, |
3577 | 3575 | |
3578 | 3576 | |
... | ... | @@ -3581,11 +3579,11 @@ Page({ |
3581 | 3579 | var th = this; |
3582 | 3580 | var is_shipping_code = this.data.is_shipping_code |
3583 | 3581 | getApp().request.put("/api/weshop/users/update", { |
3584 | - data: {user_id: getApp().globalData.user_id, store_id: oo.stoid, def_exp_code: is_shipping_code}, | |
3582 | + data: { user_id: getApp().globalData.user_id, store_id: oo.stoid, def_exp_code: is_shipping_code }, | |
3585 | 3583 | success: function (rse) { |
3586 | 3584 | if (rse.data.code == 0) { |
3587 | 3585 | getApp().globalData.userInfo.def_exp_code = is_shipping_code; |
3588 | - th.setData({open_express: 0}); | |
3586 | + th.setData({ open_express: 0 }); | |
3589 | 3587 | //----计算此时购物车的价格---- |
3590 | 3588 | if (th.data.is_b_now == 1) th.calculatePrice2(); |
3591 | 3589 | else th.calculatePrice(); |
... | ... | @@ -3595,7 +3593,7 @@ Page({ |
3595 | 3593 | }, |
3596 | 3594 | |
3597 | 3595 | //更新下默认,在onshow里面 |
3598 | - update_code(){ | |
3596 | + update_code() { | |
3599 | 3597 | var th = this, m_wind = 0, def_exp_code = getApp().globalData.userInfo.def_exp_code; |
3600 | 3598 | //--定时器,判断wu_arr不未空-- |
3601 | 3599 | var uii = setInterval(function () { |
... | ... | @@ -3609,7 +3607,7 @@ Page({ |
3609 | 3607 | } |
3610 | 3608 | //--如果是立即购买-- |
3611 | 3609 | if (th.data.is_b_now == 1) { |
3612 | - th.setData({index: m_wind, is_express: m_wind}); | |
3610 | + th.setData({ index: m_wind, is_express: m_wind }); | |
3613 | 3611 | } else { |
3614 | 3612 | var ui = setInterval(function () { |
3615 | 3613 | if (th.data.cartlist) { |
... | ... | @@ -3617,7 +3615,7 @@ Page({ |
3617 | 3615 | for (var i in c_arr) { |
3618 | 3616 | c_arr[i].wind = m_wind; |
3619 | 3617 | } |
3620 | - th.setData({cartlist: c_arr, is_express: m_wind}) | |
3618 | + th.setData({ cartlist: c_arr, is_express: m_wind }) | |
3621 | 3619 | clearInterval(ui); |
3622 | 3620 | } |
3623 | 3621 | }, 500) |
... | ... | @@ -3629,7 +3627,7 @@ Page({ |
3629 | 3627 | get_cart_quan: async function (order_prom_list_cart) { |
3630 | 3628 | var th = this; |
3631 | 3629 | var is_xz_yh = 1; |
3632 | - var user_id=getApp().globalData.user_id; | |
3630 | + var user_id = getApp().globalData.user_id; | |
3633 | 3631 | //等待值的出现 |
3634 | 3632 | //getApp().waitfor2(this,"g_cart_q_time","order_prom_list_cart",async function () { |
3635 | 3633 | //var arr=th.data.order_prom_list_cart; |
... | ... | @@ -3648,8 +3646,8 @@ Page({ |
3648 | 3646 | var ckeck_quan_price = 0, |
3649 | 3647 | check_quan_price_list = '', |
3650 | 3648 | check_quan_ware_list = '', |
3651 | - check_quan_price_list_arr=[], | |
3652 | - check_quan_ware_list_arr=[]; | |
3649 | + check_quan_price_list_arr = [], | |
3650 | + check_quan_ware_list_arr = []; | |
3653 | 3651 | |
3654 | 3652 | for (var i in goodlist) { |
3655 | 3653 | var gd = goodlist[i]; |
... | ... | @@ -3659,25 +3657,25 @@ Page({ |
3659 | 3657 | } |
3660 | 3658 | |
3661 | 3659 | //--如果是团购,要判断有没有限制使用优惠券 |
3662 | - if(gd.prom_type == 2){ | |
3663 | - var prom1=null; | |
3660 | + if (gd.prom_type == 2) { | |
3661 | + var prom1 = null; | |
3664 | 3662 | await getApp().request.promiseGet("/api/weshop/goods/groupBuy/getActInfo/" + os.stoid + "/" + gd.goods_id + "/" + gd.prom_id, { |
3665 | 3663 | }).then(res => { |
3666 | 3664 | if (res.data.code == 0) prom1 = res.data.data; |
3667 | 3665 | }) |
3668 | - if(prom1 && !prom1.isQuan){ | |
3666 | + if (prom1 && !prom1.isQuan) { | |
3669 | 3667 | continue; |
3670 | 3668 | } |
3671 | 3669 | } |
3672 | 3670 | |
3673 | 3671 | //--如果是团购,要判断有没有限制使用优惠券 |
3674 | - if(gd.prom_type == 10){ | |
3675 | - var prom1=null; | |
3676 | - await getApp().request.promiseGet("/api/weshop/prom/ladderForm/getNew/"+ os.stoid +"/"+user_id+"/"+ gd.prom_id, { | |
3672 | + if (gd.prom_type == 10) { | |
3673 | + var prom1 = null; | |
3674 | + await getApp().request.promiseGet("/api/weshop/prom/ladderForm/getNew/" + os.stoid + "/" + user_id + "/" + gd.prom_id, { | |
3677 | 3675 | }).then(res => { |
3678 | 3676 | if (res.data.code == 0) prom1 = res.data.data; |
3679 | 3677 | }) |
3680 | - if(prom1 && prom1.isuse && prom1. is_usecoupon){ | |
3678 | + if (prom1 && prom1.isuse && prom1.is_usecoupon) { | |
3681 | 3679 | continue; |
3682 | 3680 | } |
3683 | 3681 | } |
... | ... | @@ -3689,43 +3687,43 @@ Page({ |
3689 | 3687 | } |
3690 | 3688 | is_xz_yh = 0; |
3691 | 3689 | |
3692 | - var item_price = gd.goods_price * gd.goods_num; | |
3693 | - var item_price2=item_price; | |
3690 | + var item_price = gd.goods_price * gd.goods_num; | |
3691 | + var item_price2 = item_price; | |
3694 | 3692 | |
3695 | 3693 | //-- 如果有平摊下去,有实收价格的时候,就要用account来计算价格 -- |
3696 | 3694 | if (gd.account_fir != null && gd.account_fir != undefined) { |
3697 | 3695 | item_price2 = gd.account_fir * gd.goods_num; |
3698 | 3696 | } |
3699 | 3697 | |
3700 | - if(gd.ld_account){ | |
3698 | + if (gd.ld_account) { | |
3701 | 3699 | item_price2 = gd.ld_account * gd.goods_num; |
3702 | 3700 | } |
3703 | 3701 | |
3704 | 3702 | ckeck_quan_price += item_price; |
3705 | 3703 | //如果商品有重复的过滤,一般是组合购和阶梯购的情况下 |
3706 | - var idx=check_quan_ware_list_arr.findIndex(function(ele){ | |
3707 | - return ele== encodeURIComponent(gd['erpwareid']); | |
3704 | + var idx = check_quan_ware_list_arr.findIndex(function (ele) { | |
3705 | + return ele == encodeURIComponent(gd['erpwareid']); | |
3708 | 3706 | }) |
3709 | 3707 | |
3710 | - if(idx>-1){ | |
3711 | - check_quan_price_list_arr[idx]+=item_price2; | |
3712 | - }else{ | |
3708 | + if (idx > -1) { | |
3709 | + check_quan_price_list_arr[idx] += item_price2; | |
3710 | + } else { | |
3713 | 3711 | check_quan_ware_list_arr.push(encodeURIComponent(gd['erpwareid'])); |
3714 | 3712 | check_quan_price_list_arr.push(item_price2); |
3715 | 3713 | } |
3716 | - //--组装价格list-- | |
3717 | - /*-- | |
3718 | - if (check_quan_price_list) { | |
3719 | - check_quan_price_list += "," + item_price; | |
3720 | - } else { | |
3721 | - check_quan_price_list = item_price; | |
3722 | - } | |
3723 | - //--组装商品的线下erpwareid-- | |
3724 | - if (check_quan_ware_list) { | |
3725 | - check_quan_ware_list += "," + encodeURIComponent(gd['erpwareid']); | |
3726 | - } else { | |
3727 | - check_quan_ware_list = encodeURIComponent(gd['erpwareid']); | |
3728 | - }---*/ | |
3714 | + //--组装价格list-- | |
3715 | + /*-- | |
3716 | + if (check_quan_price_list) { | |
3717 | + check_quan_price_list += "," + item_price; | |
3718 | + } else { | |
3719 | + check_quan_price_list = item_price; | |
3720 | + } | |
3721 | + //--组装商品的线下erpwareid-- | |
3722 | + if (check_quan_ware_list) { | |
3723 | + check_quan_ware_list += "," + encodeURIComponent(gd['erpwareid']); | |
3724 | + } else { | |
3725 | + check_quan_ware_list = encodeURIComponent(gd['erpwareid']); | |
3726 | + }---*/ | |
3729 | 3727 | } |
3730 | 3728 | //优惠券优惠的金额要控制到优惠券的选择条件 |
3731 | 3729 | var cut_price = 0; |
... | ... | @@ -3736,16 +3734,16 @@ Page({ |
3736 | 3734 | } |
3737 | 3735 | } |
3738 | 3736 | |
3739 | - var prom_pt_json= ep.prom_pt_json; | |
3740 | - if(prom_pt_json){ | |
3741 | - for(let oj in prom_pt_json){ | |
3742 | - let item_j=prom_pt_json[oj]; | |
3737 | + var prom_pt_json = ep.prom_pt_json; | |
3738 | + if (prom_pt_json) { | |
3739 | + for (let oj in prom_pt_json) { | |
3740 | + let item_j = prom_pt_json[oj]; | |
3743 | 3741 | |
3744 | 3742 | //要对一下阶梯优惠促销的功能 |
3745 | - if(item_j.ladder_prom_id){ | |
3743 | + if (item_j.ladder_prom_id) { | |
3746 | 3744 | |
3747 | 3745 | //看一下要不要限制使用优惠券 |
3748 | - if (th.data.ladder_map[item_j.ladder_prom_id] && th.data.ladder_map[item_j.ladder_prom_id].is_usecoupon){ | |
3746 | + if (th.data.ladder_map[item_j.ladder_prom_id] && th.data.ladder_map[item_j.ladder_prom_id].is_usecoupon) { | |
3749 | 3747 | continue; |
3750 | 3748 | } |
3751 | 3749 | |
... | ... | @@ -3754,10 +3752,10 @@ Page({ |
3754 | 3752 | } |
3755 | 3753 | } |
3756 | 3754 | |
3757 | - if(check_quan_price_list_arr.length) check_quan_price_list=check_quan_price_list_arr.join(','); | |
3758 | - if(check_quan_ware_list_arr.length) check_quan_ware_list=check_quan_ware_list_arr.join(',') | |
3755 | + if (check_quan_price_list_arr.length) check_quan_price_list = check_quan_price_list_arr.join(','); | |
3756 | + if (check_quan_ware_list_arr.length) check_quan_ware_list = check_quan_ware_list_arr.join(',') | |
3759 | 3757 | |
3760 | - arr[ind].ckeck_quan_price = ckeck_quan_price - (cut_price?cut_price:0); | |
3758 | + arr[ind].ckeck_quan_price = ckeck_quan_price - (cut_price ? cut_price : 0); | |
3761 | 3759 | arr[ind].check_quan_ware_list = check_quan_ware_list; |
3762 | 3760 | arr[ind].check_quan_price_list = check_quan_price_list; |
3763 | 3761 | arr[ind].is_xz_yh = is_xz_yh; |
... | ... | @@ -3787,10 +3785,10 @@ Page({ |
3787 | 3785 | if (th.data.is_b_now) { |
3788 | 3786 | if (arr && arr.length > 0) { |
3789 | 3787 | var quanlist = arr[0].quan_list; |
3790 | - th.setData({selected_quan_list: quanlist, cartlist: arr}) | |
3788 | + th.setData({ selected_quan_list: quanlist, cartlist: arr }) | |
3791 | 3789 | } |
3792 | 3790 | } else { |
3793 | - th.setData({cartlist: arr}) | |
3791 | + th.setData({ cartlist: arr }) | |
3794 | 3792 | th.set_can_num(); |
3795 | 3793 | } |
3796 | 3794 | |
... | ... | @@ -3810,7 +3808,7 @@ Page({ |
3810 | 3808 | if (th.data.is_close_quan != 1 && th.data.bn_goods.is_xz_yh != 1) { |
3811 | 3809 | var url0 = "/api/weshop/users/frozenQuan/listFrozenQuan/" + app.globalData.user_id; |
3812 | 3810 | var url = "/api/weshop/couponList/getUseCouponList"; |
3813 | - app.request.promiseGet(url0, {1: 1}).then(res => { | |
3811 | + app.request.promiseGet(url0, { 1: 1 }).then(res => { | |
3814 | 3812 | if (res.data.code == 0) { |
3815 | 3813 | frozenQuan = res.data.data; |
3816 | 3814 | th.data.frozenQuan = frozenQuan; |
... | ... | @@ -3828,7 +3826,7 @@ Page({ |
3828 | 3826 | quanlist = res.data.data.pageData; |
3829 | 3827 | if (quanlist) { |
3830 | 3828 | quanlist = th.check_is_frozenQuan(quanlist, frozenQuan); |
3831 | - th.setData({selected_quan_list: quanlist}) | |
3829 | + th.setData({ selected_quan_list: quanlist }) | |
3832 | 3830 | } |
3833 | 3831 | } |
3834 | 3832 | } |
... | ... | @@ -3856,7 +3854,7 @@ Page({ |
3856 | 3854 | if (!goods_id) goods_id = this.data.bn_goods.goods_id; |
3857 | 3855 | for (var i in arr) { |
3858 | 3856 | var item = arr[i]; |
3859 | - if (goods_id == item) return 0; | |
3857 | + if (goods_id == item) return 0; | |
3860 | 3858 | } |
3861 | 3859 | return 1; |
3862 | 3860 | }, |
... | ... | @@ -3927,7 +3925,7 @@ Page({ |
3927 | 3925 | if (this.data.is_b_now == 1) pick = this.data.bn_pick; |
3928 | 3926 | //---获取订单优惠--- |
3929 | 3927 | getApp().request.promiseGet("/api/weshop/promorder/getOrderPromotion", { |
3930 | - data: {store_id: os.stoid, orderAmount: condition} | |
3928 | + data: { store_id: os.stoid, orderAmount: condition } | |
3931 | 3929 | }).then(res => { |
3932 | 3930 | if (res.data.code == 0) { |
3933 | 3931 | var data = res.data.data; |
... | ... | @@ -3949,7 +3947,7 @@ Page({ |
3949 | 3947 | var ob = map[pickid][item.prom_id]; |
3950 | 3948 | ob.price += item.goods_price * item.goods_num; |
3951 | 3949 | ob.goods_num += item.goods_num; |
3952 | - ob.goods.push({goods_id: item.goods_id, goods_price: item.goods_price, goods_num: item.goods_num}); | |
3950 | + ob.goods.push({ goods_id: item.goods_id, goods_price: item.goods_price, goods_num: item.goods_num }); | |
3953 | 3951 | |
3954 | 3952 | } else { |
3955 | 3953 | var prom = null; |
... | ... | @@ -3965,7 +3963,7 @@ Page({ |
3965 | 3963 | ob.is_bz = prom.is_bz; |
3966 | 3964 | ob.is_xz_yh = prom.is_xz_yh; |
3967 | 3965 | ob.goods = new Array(); |
3968 | - ob.goods.push({goods_id: item.goods_id, goods_price: item.goods_price, goods_num: item.goods_num}); | |
3966 | + ob.goods.push({ goods_id: item.goods_id, goods_price: item.goods_price, goods_num: item.goods_num }); | |
3969 | 3967 | map[pickid][item.prom_id] = ob; |
3970 | 3968 | } |
3971 | 3969 | } else { |
... | ... | @@ -3982,7 +3980,7 @@ Page({ |
3982 | 3980 | ob.is_bz = prom.is_bz; |
3983 | 3981 | ob.is_xz_yh = prom.is_xz_yh; |
3984 | 3982 | ob.goods = new Array(); |
3985 | - ob.goods.push({goods_id: item.goods_id, goods_price: item.goods_price, goods_num: item.goods_num}); | |
3983 | + ob.goods.push({ goods_id: item.goods_id, goods_price: item.goods_price, goods_num: item.goods_num }); | |
3986 | 3984 | |
3987 | 3985 | var obj = {}; |
3988 | 3986 | obj[item.prom_id] = ob; |
... | ... | @@ -3992,12 +3990,12 @@ Page({ |
3992 | 3990 | }, |
3993 | 3991 | |
3994 | 3992 | //计算立即购买赠品的物流费用 |
3995 | - get_now_gift_goods_wuliu: function (code, o_shipping_price, user_addr, gift_freight_free,out_of_weight, allpice, rs, shipping_price, no_by_data, goods_weight1, goods_piece1) { | |
3993 | + get_now_gift_goods_wuliu: function (code, o_shipping_price, user_addr, gift_freight_free, out_of_weight, allpice, rs, shipping_price, no_by_data, goods_weight1, goods_piece1) { | |
3996 | 3994 | var good = this.data.buy_now_gift_goods; |
3997 | 3995 | var goods_weight = -1, goods_piece = -1; |
3998 | 3996 | var gift_shipping_price = 0; |
3999 | 3997 | var th = this; |
4000 | - var out_of_weight=null; | |
3998 | + var out_of_weight = null; | |
4001 | 3999 | switch (good['exp_sum_type']) { |
4002 | 4000 | case 1: |
4003 | 4001 | //统一运费 |
... | ... | @@ -4009,7 +4007,7 @@ Page({ |
4009 | 4007 | //累积商品重量 每种商品的重量 * 数量 |
4010 | 4008 | goods_weight += good['weight'] * good['buynum']; |
4011 | 4009 | if (goods_weight1 > 0) { |
4012 | - out_of_weight = gift_weight_free - goods_weight; | |
4010 | + out_of_weight = gift_weight_free - goods_weight; | |
4013 | 4011 | //不能调换位置 下面goods_weight会变大 |
4014 | 4012 | goods_weight += goods_weight1; |
4015 | 4013 | } |
... | ... | @@ -4029,7 +4027,7 @@ Page({ |
4029 | 4027 | if (no_by_data && no_by_data.region_list) { |
4030 | 4028 | if (th.check_by_area(no_by_data.region_list)) { |
4031 | 4029 | gift_freight_free = 0; |
4032 | - out_of_weight=0 | |
4030 | + out_of_weight = 0 | |
4033 | 4031 | th.data.is_no_by[th.data.bn_pick] = 1; |
4034 | 4032 | } |
4035 | 4033 | } |
... | ... | @@ -4037,14 +4035,14 @@ Page({ |
4037 | 4035 | if (no_by_data && no_by_data.goods_list && gift_freight_free) { |
4038 | 4036 | if (th.check_by_goods(no_by_data.goods_list, good.goods_id)) { |
4039 | 4037 | gift_freight_free = 0; |
4040 | - out_of_weight=0 | |
4041 | - //th.data.is_no_by[th.data.bn_pick]=1; | |
4038 | + out_of_weight = 0 | |
4039 | + th.data.is_no_by[th.data.bn_pick]=1; | |
4042 | 4040 | } |
4043 | 4041 | } |
4044 | 4042 | |
4045 | 4043 | var t_shipping_price = |
4046 | - this.calculatewuliu(code, gift_shipping_price, goods_weight,out_of_weight, | |
4047 | - goods_piece, user_addr, gift_freight_free, allpice, rs); | |
4044 | + this.calculatewuliu(code, gift_shipping_price, goods_weight, out_of_weight, | |
4045 | + goods_piece, user_addr, gift_freight_free, allpice, rs,th.data.bn_pick); | |
4048 | 4046 | return t_shipping_price; |
4049 | 4047 | |
4050 | 4048 | }, |
... | ... | @@ -4101,7 +4099,7 @@ Page({ |
4101 | 4099 | |
4102 | 4100 | //跳转关闭弹出框的显示 |
4103 | 4101 | close_offline: function () { |
4104 | - this.setData({is_offline_show: 0}); | |
4102 | + this.setData({ is_offline_show: 0 }); | |
4105 | 4103 | }, |
4106 | 4104 | |
4107 | 4105 | //立即购买显示弹出框 |
... | ... | @@ -4109,7 +4107,7 @@ Page({ |
4109 | 4107 | var off_price = this.data.bn_goods.shop_price - this.data.bn_goods.offline_price; |
4110 | 4108 | //是不是线下 |
4111 | 4109 | var is_get_offline = this.data.bn_goods.is_offline; |
4112 | - this.setData({is_offline_show: 1, show_off_price: off_price.toFixed(2), is_get_offline: is_get_offline}); | |
4110 | + this.setData({ is_offline_show: 1, show_off_price: off_price.toFixed(2), is_get_offline: is_get_offline }); | |
4113 | 4111 | }, |
4114 | 4112 | |
4115 | 4113 | //确定使用线下取价 |
... | ... | @@ -4117,14 +4115,14 @@ Page({ |
4117 | 4115 | var bn_goods = this.data.bn_goods; |
4118 | 4116 | if (bn_goods && bn_goods.prom_type == 0) { |
4119 | 4117 | bn_goods.is_offline = 1; |
4120 | - this.setData({is_offline_show: 0, bn_goods: bn_goods}); | |
4118 | + this.setData({ is_offline_show: 0, bn_goods: bn_goods }); | |
4121 | 4119 | this.calculatePrice2(); |
4122 | 4120 | } |
4123 | 4121 | //就是购物车结算时的 |
4124 | 4122 | else { |
4125 | 4123 | var index = this.data.pop_offline_index; |
4126 | 4124 | var txt = "cartlist[" + index + "].is_offline"; |
4127 | - this.setData({[txt]: 1, is_offline_show: 0,}); | |
4125 | + this.setData({ [txt]: 1, is_offline_show: 0, }); | |
4128 | 4126 | this.data.old_cartlist[index].is_offline = 1; |
4129 | 4127 | this.calculatePrice(); |
4130 | 4128 | } |
... | ... | @@ -4136,14 +4134,14 @@ Page({ |
4136 | 4134 | var bn_goods = this.data.bn_goods; |
4137 | 4135 | if (bn_goods && bn_goods.prom_type == 0) { |
4138 | 4136 | bn_goods.is_offline = 0; |
4139 | - this.setData({is_offline_show: 0, bn_goods: bn_goods}); | |
4137 | + this.setData({ is_offline_show: 0, bn_goods: bn_goods }); | |
4140 | 4138 | this.calculatePrice2(); |
4141 | 4139 | } |
4142 | 4140 | //就是购物车结算时的 |
4143 | 4141 | else { |
4144 | 4142 | var index = this.data.pop_offline_index; |
4145 | 4143 | var txt = "cartlist[" + index + "].is_offline"; |
4146 | - this.setData({[txt]: 0, is_offline_show: 0,}) | |
4144 | + this.setData({ [txt]: 0, is_offline_show: 0, }) | |
4147 | 4145 | this.data.old_cartlist[index].is_offline = 0; |
4148 | 4146 | this.calculatePrice(); |
4149 | 4147 | } |
... | ... | @@ -4176,34 +4174,34 @@ Page({ |
4176 | 4174 | // this.setData({[txt]:0}) |
4177 | 4175 | // }, |
4178 | 4176 | |
4179 | - go_url:function (e) { | |
4177 | + go_url: function (e) { | |
4180 | 4178 | var url = e.currentTarget.dataset.url; |
4181 | 4179 | getApp().goto(url); |
4182 | 4180 | }, |
4183 | 4181 | |
4184 | - //进行对商品的平摊g_item是单个商品,you_item是这个商品分多少优惠券的钱,goods是商品列表 | |
4185 | - split_set_goods_quanprice:async function (you_item,t_item) { | |
4186 | - var coupon_price=you_item.WareCashSum; | |
4187 | - var goods=t_item.goods; | |
4188 | - var arr=[]; | |
4182 | + //进行对商品的平摊g_item是单个商品,you_item是这个商品分多少优惠券的钱,goods是商品列表 | |
4183 | + split_set_goods_quanprice: async function (you_item, t_item) { | |
4184 | + var coupon_price = you_item.WareCashSum; | |
4185 | + var goods = t_item.goods; | |
4186 | + var arr = []; | |
4189 | 4187 | //判断是不是有goods_id重复 |
4190 | - for(var i=0;i<goods.length;i++){ | |
4191 | - if(goods[i].prom_type!=7 && goods[i].erpwareid==you_item.WareId){ | |
4192 | - var gg_ite={ | |
4193 | - goods_id:goods[i].goods_id, | |
4194 | - goods_num:goods[i].goods_num, | |
4195 | - goods_price:goods[i].goods_price, | |
4188 | + for (var i = 0; i < goods.length; i++) { | |
4189 | + if (goods[i].prom_type != 7 && goods[i].erpwareid == you_item.WareId) { | |
4190 | + var gg_ite = { | |
4191 | + goods_id: goods[i].goods_id, | |
4192 | + goods_num: goods[i].goods_num, | |
4193 | + goods_price: goods[i].goods_price, | |
4196 | 4194 | }; |
4197 | - if(goods[i].account) gg_ite.goods_price=goods[i].account; | |
4198 | - gg_ite.idx=i;arr.push(gg_ite); | |
4195 | + if (goods[i].account) gg_ite.goods_price = goods[i].account; | |
4196 | + gg_ite.idx = i; arr.push(gg_ite); | |
4199 | 4197 | } |
4200 | 4198 | } |
4201 | 4199 | |
4202 | - if(arr.length<=0) return false; | |
4203 | - if(arr.length==1){ | |
4204 | - var idx=arr[0].idx; | |
4205 | - t_item.goods[idx].quan_num =Math.floor(coupon_price* 100) / 100; | |
4206 | - t_item.goods[idx].quan_no=t_item.quan_no; | |
4200 | + if (arr.length <= 0) return false; | |
4201 | + if (arr.length == 1) { | |
4202 | + var idx = arr[0].idx; | |
4203 | + t_item.goods[idx].quan_num = Math.floor(coupon_price * 100) / 100; | |
4204 | + t_item.goods[idx].quan_no = t_item.quan_no; | |
4207 | 4205 | return false; |
4208 | 4206 | } |
4209 | 4207 | |
... | ... | @@ -4213,7 +4211,7 @@ Page({ |
4213 | 4211 | } |
4214 | 4212 | |
4215 | 4213 | var pt_res = null; |
4216 | - await getApp().request.promisePost("/api/weshop/order/getGoodsSplit", { | |
4214 | + await getApp().request.promisePost("/api/weshop/order/getGoodsSplit", { | |
4217 | 4215 | is_json: 1, |
4218 | 4216 | data: pt_data |
4219 | 4217 | }).then(res => { |
... | ... | @@ -4226,21 +4224,21 @@ Page({ |
4226 | 4224 | for (var i in pt_res) { |
4227 | 4225 | var idx = pt_res[i].idx; |
4228 | 4226 | //有account的实收价,就要用account实收价 |
4229 | - var price=(t_item.goods[idx].account?t_item.goods[idx].account:t_item.goods[idx].goods_price); | |
4230 | - price=(price - pt_res[i].fisrt_account)* t_item.goods[idx].goods_num; | |
4231 | - t_item.goods[idx].quan_num =price; | |
4227 | + var price = (t_item.goods[idx].account ? t_item.goods[idx].account : t_item.goods[idx].goods_price); | |
4228 | + price = (price - pt_res[i].fisrt_account) * t_item.goods[idx].goods_num; | |
4229 | + t_item.goods[idx].quan_num = price; | |
4232 | 4230 | |
4233 | - t_item.goods[idx].quan_num =Math.floor(t_item.goods[idx].quan_num * 100) / 100; | |
4234 | - t_item.goods[idx].quan_no=t_item.quan_no; | |
4231 | + t_item.goods[idx].quan_num = Math.floor(t_item.goods[idx].quan_num * 100) / 100; | |
4232 | + t_item.goods[idx].quan_no = t_item.quan_no; | |
4235 | 4233 | q_s_num += t_item.goods[idx].quan_num; |
4236 | 4234 | } |
4237 | 4235 | |
4238 | - if (q_s_num > parseFloat(coupon_price) || q_s_num < parseFloat(coupon_price)){ | |
4236 | + if (q_s_num > parseFloat(coupon_price) || q_s_num < parseFloat(coupon_price)) { | |
4239 | 4237 | for (var ik in arr) { |
4240 | 4238 | if (arr[ik].goods_num == 1) { |
4241 | 4239 | var id = arr[ik].idx; |
4242 | - var pri=Math.floor(coupon_price*100)/100-Math.floor(q_s_num*100)/100 | |
4243 | - t_item.goods[id].quan_num+=pri; | |
4240 | + var pri = Math.floor(coupon_price * 100) / 100 - Math.floor(q_s_num * 100) / 100 | |
4241 | + t_item.goods[id].quan_num += pri; | |
4244 | 4242 | break; |
4245 | 4243 | } |
4246 | 4244 | } |
... | ... | @@ -4248,8 +4246,7 @@ Page({ |
4248 | 4246 | } |
4249 | 4247 | }, |
4250 | 4248 | //订阅消息提醒 |
4251 | - sendsm:function(func) | |
4252 | - { | |
4249 | + sendsm: function (func) { | |
4253 | 4250 | var template_id = this.data.template_id; |
4254 | 4251 | // //授权订阅 |
4255 | 4252 | wx.requestSubscribeMessage({ | ... | ... |
pages/cart/cart2_inte/cart2_inte.js
1 | -var t = getApp(),app=t, a = t.request, e = require("../../../utils/common.js"), | |
2 | - s = require("../../../utils/util.js"),ut=s, o = require("../../../utils/md5.js"), to = getApp(); | |
3 | -var oo=t.globalData.setting,os=oo; | |
1 | +var t = getApp(), app = t, a = t.request, e = require("../../../utils/common.js"), | |
2 | + s = require("../../../utils/util.js"), ut = s, o = require("../../../utils/md5.js"), to = getApp(); | |
3 | +var oo = t.globalData.setting, os = oo; | |
4 | 4 | var regeneratorRuntime = require('../../../utils/runtime.js'); |
5 | 5 | var util_pay = require("../../../utils/pay.js"); |
6 | 6 | |
7 | -Page({ | |
7 | +Page({ | |
8 | 8 | data: { |
9 | - url: t.globalData.setting.url, | |
9 | + url: t.globalData.setting.url, | |
10 | 10 | imgUrl: t.globalData.setting.imghost, |
11 | 11 | goods: null, |
12 | 12 | order: null, |
... | ... | @@ -20,361 +20,361 @@ Page({ |
20 | 20 | enterAddressPage: !1, |
21 | 21 | firstEnter: !0, |
22 | 22 | //页面获取的参数 |
23 | - param:null, | |
23 | + param: null, | |
24 | 24 | //提交订单的格式 |
25 | 25 | formData: { |
26 | - order_amount:0,//支付金额 | |
27 | - total_amount:0,//总价 | |
28 | - all_price:0,//商品卖的总价 | |
26 | + order_amount: 0,//支付金额 | |
27 | + total_amount: 0,//总价 | |
28 | + all_price: 0,//商品卖的总价 | |
29 | 29 | pay_points: 0,//使用积分 |
30 | 30 | user_money: 0,//使用余额 |
31 | 31 | couponCode: "",//使用优惠券(多单就用逗号隔开) |
32 | - shipping_price:0,//物流费用 | |
32 | + shipping_price: 0,//物流费用 | |
33 | 33 | }, |
34 | 34 | |
35 | 35 | |
36 | 36 | /*----------------立即购买---------------------*/ |
37 | - is_b_now:1, //0是购物车结算 1立即购买 | |
38 | - bn_goods:null, //立即购买时候的调用商品 | |
39 | - bn_use_money:0,//是否使用余额 | |
40 | - bn_exp_type:1, //0是物流 1自提 | |
41 | - bn_pick:0, //选择的门店 | |
37 | + is_b_now: 1, //0是购物车结算 1立即购买 | |
38 | + bn_goods: null, //立即购买时候的调用商品 | |
39 | + bn_use_money: 0,//是否使用余额 | |
40 | + bn_exp_type: 1, //0是物流 1自提 | |
41 | + bn_pick: 0, //选择的门店 | |
42 | 42 | bn_pickname: "", //选择的门店名称 |
43 | - bn_t_exp_t:0, //判断商品和门店一起决定的物流自提的方式0 都可以 1自提 2物流 | |
44 | - | |
45 | - bn_plus_cut_price:0, //显示等级卡会优惠多少钱 | |
43 | + bn_t_exp_t: 0, //判断商品和门店一起决定的物流自提的方式0 都可以 1自提 2物流 | |
44 | + | |
45 | + bn_plus_cut_price: 0, //显示等级卡会优惠多少钱 | |
46 | 46 | /*------------------------*/ |
47 | - user_addr:null,//物流 | |
48 | - userinfo:null, //获取会员 | |
47 | + user_addr: null,//物流 | |
48 | + userinfo: null, //获取会员 | |
49 | 49 | /*----------物流选择--------*/ |
50 | - wu_arr:null, | |
51 | - index:0, | |
52 | - w_sele_index:0, | |
50 | + wu_arr: null, | |
51 | + index: 0, | |
52 | + w_sele_index: 0, | |
53 | 53 | |
54 | 54 | //判断页面是返回回来的还是 首次进入的 |
55 | - isclose:1, | |
55 | + isclose: 1, | |
56 | 56 | //申请提现的金额 |
57 | - txmon:0, | |
58 | - yuer:0, | |
57 | + txmon: 0, | |
58 | + yuer: 0, | |
59 | 59 | //提交中,不重复提交 |
60 | - is_summit_ing:0, | |
61 | - | |
62 | - disabled:0, | |
63 | - open_express:0,//控制选择物流名列表 的属性 | |
64 | - | |
65 | - is_express:0, //选中物流的属性 | |
66 | - expres_name:"", //点击选定 | |
67 | - is_shipping_code:"",//插入用户默认地址 | |
68 | - wu_arr_txt:"", //要更新的物流的字段 | |
69 | - | |
70 | - //如果是全场包邮了,或者是全场不包邮了,就不要选包邮券 | |
71 | - is_no_by:{}, | |
72 | - is_by:{}, | |
73 | - is_quan_by:{}, | |
60 | + is_summit_ing: 0, | |
61 | + | |
62 | + disabled: 0, | |
63 | + open_express: 0,//控制选择物流名列表 的属性 | |
64 | + | |
65 | + is_express: 0, //选中物流的属性 | |
66 | + expres_name: "", //点击选定 | |
67 | + is_shipping_code: "",//插入用户默认地址 | |
68 | + wu_arr_txt: "", //要更新的物流的字段 | |
69 | + | |
70 | + //如果是全场包邮了,或者是全场不包邮了,就不要选包邮券 | |
71 | + is_no_by: {}, | |
72 | + is_by: {}, | |
73 | + is_quan_by: {}, | |
74 | 74 | //--购买赠送的商品-- |
75 | - buy_now_gift_goods:null, | |
75 | + buy_now_gift_goods: null, | |
76 | 76 | //--订单优惠-- |
77 | - order_prom:{}, | |
78 | - show_submit:0, //提交按钮变正常显示 | |
77 | + order_prom: {}, | |
78 | + show_submit: 0, //提交按钮变正常显示 | |
79 | 79 | |
80 | 80 | }, |
81 | - onLoad: function(t) { | |
82 | - wx.setNavigationBarTitle({ title: "填写订单",}) | |
83 | - var th = this; | |
84 | - th.data.param=t; | |
81 | + onLoad: function (t) { | |
82 | + wx.setNavigationBarTitle({ title: "填写订单", }) | |
83 | + var th = this; | |
84 | + th.data.param = t; | |
85 | 85 | //清空is_pick_up |
86 | 86 | getApp().request.put("/api/weshop/useraddress/updatePickUp", { |
87 | - data: {user_id: getApp().globalData.user_id, is_pickup: 0}, | |
88 | - success: function (s) { | |
89 | - } | |
87 | + data: { user_id: getApp().globalData.user_id, is_pickup: 0 }, | |
88 | + success: function (s) { | |
89 | + } | |
90 | 90 | }); |
91 | - | |
92 | - //先获取是否有关闭使用优惠券 | |
93 | - getApp().getConfig2(function (ee) { | |
94 | - var json_d = JSON.parse(ee.switch_list); | |
95 | - th.data.json_d=json_d; | |
96 | - th.data.ispt_goods=json_d.ispt_goods; //是不是平摊到单品的控制参数赋值 | |
97 | - var is_default_logistics=json_d.is_default_logistics; | |
98 | - th.setData({ is_close_quan: json_d.is_close_quan,sales_rules:ee.sales_rules,rank_switch:json_d.rank_switch,is_default_logistics:is_default_logistics}); | |
99 | - | |
100 | - var rank_switch=json_d.rank_switch; | |
101 | - var max_price=-1; | |
102 | - var show_card=null; | |
103 | - var name=""; | |
104 | - //如果有开等级卡的时候, | |
105 | - //因为都是调接口,要返回在计算 | |
106 | - if(rank_switch==2){ | |
107 | - //-- 获取所有的等级卡, -- | |
108 | - getApp().request.promiseGet("/api/weshop/plus/vip/mem/bership/list?storeId=" + os.stoid, | |
109 | - {}).then(res => { | |
110 | - if(res.data.code==0){ | |
111 | - var plusCard = res.data.data; | |
112 | - //-- 循环判断,拿到最贵的那张卡 -- | |
113 | - for(var ih in plusCard){ | |
114 | - if(plusCard[ih].IsStopBuy == true){ continue; } | |
115 | - if(max_price<0){ | |
116 | - max_price=plusCard[ih].CardFee; | |
117 | - name='card'+plusCard[ih]['CorrPrice']; | |
118 | - show_card=plusCard[ih]; | |
119 | - }else{ | |
120 | - if(max_price<plusCard[ih].CardFee){ | |
121 | - max_price=plusCard[ih].CardFee; | |
122 | - name='card'+plusCard[ih]['CorrPrice']; | |
123 | - show_card=plusCard[ih]; | |
124 | - } | |
125 | - } | |
126 | - } | |
127 | - | |
128 | - if(show_card){ | |
129 | - name=name.toLowerCase(); | |
130 | - th.setData({card_name:name,show_card:show_card}) | |
131 | - } | |
132 | - } | |
133 | - //-----先获取物流,再获取用户信息,再展示页面----- | |
134 | - th.get_wuliu(th.get_info(th.show_page)); | |
135 | - }) | |
136 | - }else{ | |
137 | - //-----先获取物流,再获取用户信息,再展示页面----- | |
138 | - th.get_wuliu(th.get_info(th.show_page)); | |
139 | - } | |
140 | - },1); | |
141 | - | |
142 | - | |
91 | + | |
92 | + //先获取是否有关闭使用优惠券 | |
93 | + getApp().getConfig2(function (ee) { | |
94 | + var json_d = JSON.parse(ee.switch_list); | |
95 | + th.data.json_d = json_d; | |
96 | + th.data.ispt_goods = json_d.ispt_goods; //是不是平摊到单品的控制参数赋值 | |
97 | + var is_default_logistics = json_d.is_default_logistics; | |
98 | + th.setData({ is_close_quan: json_d.is_close_quan, sales_rules: ee.sales_rules, rank_switch: json_d.rank_switch, is_default_logistics: is_default_logistics }); | |
99 | + | |
100 | + var rank_switch = json_d.rank_switch; | |
101 | + var max_price = -1; | |
102 | + var show_card = null; | |
103 | + var name = ""; | |
104 | + //如果有开等级卡的时候, | |
105 | + //因为都是调接口,要返回在计算 | |
106 | + if (rank_switch == 2) { | |
107 | + //-- 获取所有的等级卡, -- | |
108 | + getApp().request.promiseGet("/api/weshop/plus/vip/mem/bership/list?storeId=" + os.stoid, | |
109 | + {}).then(res => { | |
110 | + if (res.data.code == 0) { | |
111 | + var plusCard = res.data.data; | |
112 | + //-- 循环判断,拿到最贵的那张卡 -- | |
113 | + for (var ih in plusCard) { | |
114 | + if (plusCard[ih].IsStopBuy == true) { continue; } | |
115 | + if (max_price < 0) { | |
116 | + max_price = plusCard[ih].CardFee; | |
117 | + name = 'card' + plusCard[ih]['CorrPrice']; | |
118 | + show_card = plusCard[ih]; | |
119 | + } else { | |
120 | + if (max_price < plusCard[ih].CardFee) { | |
121 | + max_price = plusCard[ih].CardFee; | |
122 | + name = 'card' + plusCard[ih]['CorrPrice']; | |
123 | + show_card = plusCard[ih]; | |
124 | + } | |
125 | + } | |
126 | + } | |
127 | + | |
128 | + if (show_card) { | |
129 | + name = name.toLowerCase(); | |
130 | + th.setData({ card_name: name, show_card: show_card }) | |
131 | + } | |
132 | + } | |
133 | + //-----先获取物流,再获取用户信息,再展示页面----- | |
134 | + th.get_wuliu(th.get_info(th.show_page)); | |
135 | + }) | |
136 | + } else { | |
137 | + //-----先获取物流,再获取用户信息,再展示页面----- | |
138 | + th.get_wuliu(th.get_info(th.show_page)); | |
139 | + } | |
140 | + }, 1); | |
141 | + | |
142 | + | |
143 | 143 | }, |
144 | - onUnload: function () { this.setData({ isclose: 1 })}, | |
144 | + onUnload: function () { this.setData({ isclose: 1 }) }, | |
145 | 145 | onHide: function () { |
146 | - this.setData({ | |
147 | - is_no_by:{}, | |
148 | - is_by:{} | |
149 | - }) | |
146 | + this.setData({ | |
147 | + is_no_by: {}, | |
148 | + is_by: {} | |
149 | + }) | |
150 | 150 | }, |
151 | 151 | |
152 | 152 | //----------子页返回父页触发---------- |
153 | - onShow: function() { | |
154 | - var th=this; | |
155 | - th.data.g_cart_q_time=null; | |
156 | - | |
157 | - if (th.data.isclose==0){ | |
153 | + onShow: function () { | |
154 | + var th = this; | |
155 | + th.data.g_cart_q_time = null; | |
156 | + | |
157 | + if (th.data.isclose == 0) { | |
158 | 158 | wx.navigateTo({ |
159 | 159 | url: "/pages/index/index/index" |
160 | 160 | }) |
161 | 161 | |
162 | - }else{ | |
163 | - this.getuser_addr(function(ie){ | |
164 | - /*-- | |
165 | - //地址切换要把包邮券清空 | |
166 | - if( !th.data.user_addr || !ie || th.data.user_addr.address_id!=ie.address_id){ | |
167 | - var using_quan=th.data.using_quan; | |
168 | - for(var i in using_quan){ | |
169 | - var item=using_quan[i]; | |
170 | - if(item.isby==1){ | |
171 | - var ob={},txt="using_quan["+i+"]";ob[txt]={}; | |
172 | - th.setData(ob); | |
173 | - } | |
162 | + } else { | |
163 | + this.getuser_addr(function (ie) { | |
164 | + /*-- | |
165 | + //地址切换要把包邮券清空 | |
166 | + if( !th.data.user_addr || !ie || th.data.user_addr.address_id!=ie.address_id){ | |
167 | + var using_quan=th.data.using_quan; | |
168 | + for(var i in using_quan){ | |
169 | + var item=using_quan[i]; | |
170 | + if(item.isby==1){ | |
171 | + var ob={},txt="using_quan["+i+"]";ob[txt]={}; | |
172 | + th.setData(ob); | |
173 | + } | |
174 | + } | |
175 | + | |
176 | + }--*/ | |
177 | + | |
178 | + //th.data.prom_goods_map={}; | |
179 | + //更换地址回来要重新调用计算价钱的接口 | |
180 | + if (!th.data.user_addr || th.data.user_addr.address_id != ie.address_id) { | |
181 | + th.setData({ user_addr: ie, show_submit: 0 }); | |
182 | + if (th.data.is_b_now == 1) { | |
183 | + if (th.data.bn_goods) { | |
184 | + th.setData({ add_back: 1 }); | |
185 | + th.calculatePrice2(); | |
174 | 186 | } |
175 | - | |
176 | - }--*/ | |
177 | - | |
178 | - //th.data.prom_goods_map={}; | |
179 | - //更换地址回来要重新调用计算价钱的接口 | |
180 | - if(!th.data.user_addr || th.data.user_addr.address_id!=ie.address_id){ | |
181 | - th.setData({user_addr: ie,show_submit:0 }); | |
182 | - if (th.data.is_b_now == 1) { | |
183 | - if(th.data.bn_goods) { | |
184 | - th.setData({add_back:1}); | |
185 | - th.calculatePrice2(); | |
186 | - } | |
187 | - } | |
188 | - }else{ | |
189 | - th.setData({user_addr: ie }); | |
190 | - } | |
191 | - var going=0; | |
192 | - | |
193 | - }); | |
194 | - //--更新默认地址--,看一下是不是跳到地址页面 | |
195 | - if(!getApp().globalData.is_cart_old){ | |
196 | - this.update_code(); | |
197 | - }else{ | |
198 | - getApp().globalData.is_cart_old=0; | |
187 | + } | |
188 | + } else { | |
189 | + th.setData({ user_addr: ie }); | |
199 | 190 | } |
191 | + var going = 0; | |
192 | + | |
193 | + }); | |
194 | + //--更新默认地址--,看一下是不是跳到地址页面 | |
195 | + if (!getApp().globalData.is_cart_old) { | |
196 | + this.update_code(); | |
197 | + } else { | |
198 | + getApp().globalData.is_cart_old = 0; | |
199 | + } | |
200 | 200 | } |
201 | - | |
201 | + | |
202 | 202 | }, |
203 | 203 | |
204 | 204 | //-------------------获取物流--------------- |
205 | 205 | get_wuliu(func) { |
206 | 206 | var th = this; |
207 | 207 | to.getwuliu(function (e) { |
208 | - if(th.data.is_default_logistics){ | |
209 | - //如果第一个不是开启默认,说明要让用户自己选 | |
210 | - if(!e[0].is_default){ | |
211 | - th.setData({is_default_logistics:0}); | |
212 | - } | |
213 | - } | |
214 | - th.setData({ wu_arr: e }) | |
215 | - typeof func == "function" && func(); | |
208 | + if (th.data.is_default_logistics) { | |
209 | + //如果第一个不是开启默认,说明要让用户自己选 | |
210 | + if (!e[0].is_default) { | |
211 | + th.setData({ is_default_logistics: 0 }); | |
212 | + } | |
213 | + } | |
214 | + th.setData({ wu_arr: e }) | |
215 | + typeof func == "function" && func(); | |
216 | 216 | }) |
217 | 217 | }, |
218 | 218 | //------获取会员信息-----先获取用户信息,在进行下一步--- |
219 | - get_info:function(func){ | |
219 | + get_info: function (func) { | |
220 | 220 | var user_id = t.globalData.user_id; |
221 | 221 | to.auth.get_u(func); |
222 | 222 | }, |
223 | 223 | |
224 | 224 | //------获取会员收货地址----- |
225 | - getuser_addr:function(func){ | |
226 | - var th=this; | |
227 | - a.get("/api/weshop/useraddress/page", { | |
228 | - data: { user_id: to.globalData.user_id, store_id: oo.stoid, pageSize: 600,t:Math.random()}, | |
229 | - success: function (su) { | |
230 | - | |
231 | - var item = null; | |
232 | - if(su.data.code==0 && su.data.data && su.data.data.pageData){ | |
233 | - var user_addr = su.data.data.pageData; | |
234 | - var def_item=null; | |
235 | - for (var i = 0; i < user_addr.length; i++) { | |
236 | - if (user_addr[i]['is_default'] == 1) { def_item = user_addr[i];} | |
237 | - if (user_addr[i]['is_pickup'] == 1) { item = user_addr[i]; } | |
238 | - } | |
239 | - | |
240 | - if (item == null) item = def_item; | |
241 | - if (item == null) item = user_addr[0]; | |
242 | - } | |
243 | - | |
244 | - if(item==undefined) item=null; | |
245 | - if(!item) th.setData({user_addr:null}); //地址为空的时候,要清空,因为返回的时候,有缓存 | |
246 | - func(item); | |
225 | + getuser_addr: function (func) { | |
226 | + var th = this; | |
227 | + a.get("/api/weshop/useraddress/page", { | |
228 | + data: { user_id: to.globalData.user_id, store_id: oo.stoid, pageSize: 600, t: Math.random() }, | |
229 | + success: function (su) { | |
230 | + | |
231 | + var item = null; | |
232 | + if (su.data.code == 0 && su.data.data && su.data.data.pageData) { | |
233 | + var user_addr = su.data.data.pageData; | |
234 | + var def_item = null; | |
235 | + for (var i = 0; i < user_addr.length; i++) { | |
236 | + if (user_addr[i]['is_default'] == 1) { def_item = user_addr[i]; } | |
237 | + if (user_addr[i]['is_pickup'] == 1) { item = user_addr[i]; } | |
238 | + } | |
239 | + | |
240 | + if (item == null) item = def_item; | |
241 | + if (item == null) item = user_addr[0]; | |
247 | 242 | } |
248 | - }); | |
243 | + | |
244 | + if (item == undefined) item = null; | |
245 | + if (!item) th.setData({ user_addr: null }); //地址为空的时候,要清空,因为返回的时候,有缓存 | |
246 | + func(item); | |
247 | + } | |
248 | + }); | |
249 | 249 | }, |
250 | - | |
250 | + | |
251 | 251 | //----------------展示页面,是再获取用户信息之后-------------- |
252 | - show_page:function(){ | |
253 | - var th=this,ta = this.data.param; | |
252 | + show_page: function () { | |
253 | + var th = this, ta = this.data.param; | |
254 | 254 | //th.setData({ userinfo: getApp().globalData.userInfo,}); |
255 | - | |
256 | - var user=getApp().globalData.userInfo; | |
257 | - getApp().request.get("/api/weshop/users/get/" + oo.stoid + "/" + user.user_id, { | |
258 | - data:{r:Math.random()}, | |
259 | - success: function (e) { | |
260 | - | |
261 | - getApp().globalData.userInfo = e.data.data; | |
262 | - th.setData({userinfo:e.data.data}); | |
263 | - | |
264 | - //选获取地址 | |
265 | - th.getuser_addr(function(addr){ | |
266 | - th.setData({user_addr: addr}); | |
267 | - //--------------------------立即购买------------------ | |
268 | - if(ta.is_bnow== 1){ | |
269 | - //读取门店 | |
270 | - to.get_allsto(function (e) { | |
271 | - th.setData({ allsto: e }); | |
272 | - //获取立即购买的商品信息 | |
273 | - th.get_buy_goods(ta.goods_id); | |
274 | - }); | |
275 | - } | |
276 | - }); | |
277 | - //获取提现金额 | |
278 | - getApp().request.get("/api/weshop/withdrawals/summoney", { | |
279 | - data: { user_id: to.globalData.user_id, store_id: oo.stoid, status: 0 }, | |
280 | - success: function (su) { | |
281 | - if (su.data.code == 0) { | |
282 | - var yuer = parseFloat(th.data.userinfo.user_money - | |
283 | - (th.data.userinfo.frozen_money>0?th.data.userinfo.frozen_money:0) - su.data.data.summoney).toFixed(2); | |
284 | - th.setData({ txmon: su.data.data.summoney, yuer: yuer }); | |
285 | - } | |
286 | - } | |
287 | - }); | |
288 | - | |
289 | - }, | |
290 | - }) | |
291 | - | |
292 | - | |
255 | + | |
256 | + var user = getApp().globalData.userInfo; | |
257 | + getApp().request.get("/api/weshop/users/get/" + oo.stoid + "/" + user.user_id, { | |
258 | + data: { r: Math.random() }, | |
259 | + success: function (e) { | |
260 | + | |
261 | + getApp().globalData.userInfo = e.data.data; | |
262 | + th.setData({ userinfo: e.data.data }); | |
263 | + | |
264 | + //选获取地址 | |
265 | + th.getuser_addr(function (addr) { | |
266 | + th.setData({ user_addr: addr }); | |
267 | + //--------------------------立即购买------------------ | |
268 | + if (ta.is_bnow == 1) { | |
269 | + //读取门店 | |
270 | + to.get_allsto(function (e) { | |
271 | + th.setData({ allsto: e }); | |
272 | + //获取立即购买的商品信息 | |
273 | + th.get_buy_goods(ta.goods_id); | |
274 | + }); | |
275 | + } | |
276 | + }); | |
277 | + //获取提现金额 | |
278 | + getApp().request.get("/api/weshop/withdrawals/summoney", { | |
279 | + data: { user_id: to.globalData.user_id, store_id: oo.stoid, status: 0 }, | |
280 | + success: function (su) { | |
281 | + if (su.data.code == 0) { | |
282 | + var yuer = parseFloat(th.data.userinfo.user_money - | |
283 | + (th.data.userinfo.frozen_money > 0 ? th.data.userinfo.frozen_money : 0) - su.data.data.summoney).toFixed(2); | |
284 | + th.setData({ txmon: su.data.data.summoney, yuer: yuer }); | |
285 | + } | |
286 | + } | |
287 | + }); | |
288 | + | |
289 | + }, | |
290 | + }) | |
291 | + | |
292 | + | |
293 | 293 | }, |
294 | - | |
294 | + | |
295 | 295 | //-----获取立即购买的商品信息,入口---- |
296 | - get_buy_goods: function (e){ | |
297 | - var th=this; | |
296 | + get_buy_goods: function (e) { | |
297 | + var th = this; | |
298 | 298 | var gg = to.get_b_now(); |
299 | 299 | //--------如果goods_id一样,就是要立即购买----- |
300 | - if(e==gg.goods_id){ | |
301 | - a.get("/api/weshop/goods/get/" + oo.stoid+"/"+e, { | |
302 | - success:async function (t) { | |
300 | + if (e == gg.goods_id) { | |
301 | + a.get("/api/weshop/goods/get/" + oo.stoid + "/" + e, { | |
302 | + success: async function (t) { | |
303 | 303 | var gd = t.data.data; |
304 | - if(!gd) return false; | |
304 | + if (!gd) return false; | |
305 | 305 | |
306 | 306 | t.data.data.original_img = oo.imghost + t.data.data.original_img; |
307 | 307 | t.data.data['buynum'] = gg.goods_num; |
308 | - var distr_t=0,et=0 | |
309 | - if (t.data.data.distr_type==0){ | |
308 | + var distr_t = 0, et = 0 | |
309 | + if (t.data.data.distr_type == 0) { | |
310 | 310 | distr_t = gg.pick_dis; |
311 | - }else{ | |
311 | + } else { | |
312 | 312 | distr_t = t.data.data.distr_type; |
313 | 313 | } |
314 | - switch (distr_t){ | |
314 | + switch (distr_t) { | |
315 | 315 | case 0: |
316 | - et=1; | |
317 | - //-- 系统后台有设置要默认的 -- | |
318 | - if(th.data.json_d.pickupway && th.data.json_d.pickupway==1) et=0; | |
319 | - break; | |
316 | + et = 1; | |
317 | + //-- 系统后台有设置要默认的 -- | |
318 | + if (th.data.json_d.pickupway && th.data.json_d.pickupway == 1) et = 0; | |
319 | + break; | |
320 | 320 | case 1: et = 1; break; |
321 | 321 | case 2: et = 0; break; |
322 | 322 | } |
323 | - | |
324 | - if(th.data.bn_goods) et=th.data.bn_exp_type | |
325 | - | |
326 | - var m_wind=0,def_exp_code=getApp().globalData.userInfo.def_exp_code; | |
327 | - if(et==0 && def_exp_code){ | |
328 | - for(var k=0;k<th.data.wu_arr.length;k++){ | |
329 | - var item=th.data.wu_arr[k]; if(def_exp_code==item.code){ m_wind=k; } | |
330 | - } | |
323 | + | |
324 | + if (th.data.bn_goods) et = th.data.bn_exp_type | |
325 | + | |
326 | + var m_wind = 0, def_exp_code = getApp().globalData.userInfo.def_exp_code; | |
327 | + if (et == 0 && def_exp_code) { | |
328 | + for (var k = 0; k < th.data.wu_arr.length; k++) { | |
329 | + var item = th.data.wu_arr[k]; if (def_exp_code == item.code) { m_wind = k; } | |
330 | + } | |
331 | + } | |
332 | + | |
333 | + //---是不是购买等级卡成功的返回---等级卡显示的判断--- | |
334 | + var is_card_back = getApp().globalData.is_card_back; | |
335 | + if (is_card_back) { | |
336 | + th.data.card_name = th.data.userinfo.card_field; | |
337 | + gg.goods_price = gd[th.data.card_name]; | |
338 | + getApp().globalData.is_card_back = 0; | |
339 | + th.setData({ card_cut_price: 0 }); | |
340 | + //如果是秒杀的返回 | |
341 | + if (gd.prom_type == 4) gd.prom_type = 0; | |
342 | + } else { | |
343 | + //--- 商家等级卡开通的情况下, 会员不是等级会员的情况, 商品有设置等级卡价格,同时等级卡价格小于商品的价格 | |
344 | + //-- 搭配购的商品也可以单独购买,所以此时搭配购的商品要进行计算优惠 -- | |
345 | + if (!gg.collocation_goods && gd['prom_type'] != 6 && th.data.card_name && gd[th.data.card_name] > 0 && gg.goods_price > gd[th.data.card_name] && !th.data.userinfo.card_field) { | |
346 | + var cut_p = (gg.goods_price - gd[th.data.card_name]) * gg.goods_num; | |
347 | + th.setData({ card_cut_price: cut_p }); | |
348 | + } | |
331 | 349 | } |
332 | - | |
333 | - //---是不是购买等级卡成功的返回---等级卡显示的判断--- | |
334 | - var is_card_back=getApp().globalData.is_card_back; | |
335 | - if(is_card_back){ | |
336 | - th.data.card_name=th.data.userinfo.card_field; | |
337 | - gg.goods_price=gd[th.data.card_name]; | |
338 | - getApp().globalData.is_card_back=0; | |
339 | - th.setData({card_cut_price:0}); | |
340 | - //如果是秒杀的返回 | |
341 | - if(gd.prom_type==4) gd.prom_type=0; | |
342 | - }else{ | |
343 | - //--- 商家等级卡开通的情况下, 会员不是等级会员的情况, 商品有设置等级卡价格,同时等级卡价格小于商品的价格 | |
344 | - //-- 搭配购的商品也可以单独购买,所以此时搭配购的商品要进行计算优惠 -- | |
345 | - if(!gg.collocation_goods && gd['prom_type']!=6 && th.data.card_name && gd[th.data.card_name]>0 && gg.goods_price>gd[th.data.card_name] && !th.data.userinfo.card_field){ | |
346 | - var cut_p= (gg.goods_price-gd[th.data.card_name])*gg.goods_num; | |
347 | - th.setData({card_cut_price:cut_p}); | |
348 | - } | |
349 | - } | |
350 | - | |
351 | - switch (gd.prom_type){ | |
350 | + | |
351 | + switch (gd.prom_type) { | |
352 | 352 | case 0: |
353 | 353 | case 2: |
354 | 354 | case 3: |
355 | 355 | case 5: |
356 | 356 | case 6: |
357 | - getApp().my_warnning("商品不是积分活动",0,th); | |
358 | - wx.navigateBack(); | |
359 | - break; | |
357 | + getApp().my_warnning("商品不是积分活动", 0, th); | |
358 | + wx.navigateBack(); | |
359 | + break; | |
360 | 360 | case 4: //-- 积分购 -- |
361 | - getApp().request.get("/api/weshop/integralbuy/pageIntegralBuyGoodsList?stype=1&stypeup=1",{ | |
362 | - data:{store_id:os.stoid,goods_id:gg.goods_id}, | |
361 | + getApp().request.get("/api/weshop/integralbuy/pageIntegralBuyGoodsList?stype=1&stypeup=1", { | |
362 | + data: { store_id: os.stoid, goods_id: gg.goods_id }, | |
363 | 363 | success: async function (tt) { |
364 | - if(tt.data.code==0 && tt.data.data && tt.data.data.pageData){ | |
365 | - var inte_data=tt.data.data.pageData[0]; | |
366 | - t.data.data.shop_price=inte_data.addmoney; | |
367 | - t.data.data.integral=inte_data.integral; | |
368 | - th.setData({ | |
369 | - bn_goods: t.data.data, bn_pickname: gg.pick_name, bn_exp_type: et,index:m_wind, | |
370 | - bn_pick: gg.pick_id, bn_t_exp_t: distr_t,bn_exp_type: et | |
371 | - }); | |
372 | - //计算价格 | |
373 | - th.calculatePrice2(); | |
374 | - }else{ | |
375 | - getApp().my_warnning("商品不是积分活动",0,th); | |
376 | - wx.navigateBack(); | |
377 | - } | |
364 | + if (tt.data.code == 0 && tt.data.data && tt.data.data.pageData) { | |
365 | + var inte_data = tt.data.data.pageData[0]; | |
366 | + t.data.data.shop_price = inte_data.addmoney; | |
367 | + t.data.data.integral = inte_data.integral; | |
368 | + th.setData({ | |
369 | + bn_goods: t.data.data, bn_pickname: gg.pick_name, bn_exp_type: et, index: m_wind, | |
370 | + bn_pick: gg.pick_id, bn_t_exp_t: distr_t, bn_exp_type: et | |
371 | + }); | |
372 | + //计算价格 | |
373 | + th.calculatePrice2(); | |
374 | + } else { | |
375 | + getApp().my_warnning("商品不是积分活动", 0, th); | |
376 | + wx.navigateBack(); | |
377 | + } | |
378 | 378 | } |
379 | 379 | }); |
380 | 380 | break; |
... | ... | @@ -385,34 +385,34 @@ Page({ |
385 | 385 | }, |
386 | 386 | |
387 | 387 | //---------------检查是否有收货地址------------------- |
388 | - checkAddressList: function() { | |
388 | + checkAddressList: function () { | |
389 | 389 | var t = this; |
390 | 390 | return !(!this.data.order || null == this.data.order.userAddress) || (wx.showModal({ |
391 | 391 | title: "请先填写或选择收货地址~", |
392 | - success: function(a) { | |
392 | + success: function (a) { | |
393 | 393 | a.confirm ? t.enterAddressPage() : wx.navigateBack(); |
394 | 394 | }, |
395 | - fail: function() { | |
395 | + fail: function () { | |
396 | 396 | wx.navigateBack(); |
397 | 397 | } |
398 | 398 | }), !1); |
399 | 399 | }, |
400 | - showInvoice: function() { | |
400 | + showInvoice: function () { | |
401 | 401 | this.setData({ |
402 | 402 | invoiceToggle: !this.data.invoiceToggle |
403 | 403 | }); |
404 | 404 | }, |
405 | - keyUpChangePay1: function(t) { | |
405 | + keyUpChangePay1: function (t) { | |
406 | 406 | this.setData({ |
407 | 407 | payWithUserMoney: !(t.detail.value.length > 0) |
408 | 408 | }); |
409 | 409 | }, |
410 | - keyUpChangePay2: function(t) { | |
410 | + keyUpChangePay2: function (t) { | |
411 | 411 | this.setData({ |
412 | 412 | payWithPoints: !(t.detail.value.length > 0) |
413 | 413 | }); |
414 | 414 | }, |
415 | - keyUpChangeNum: function(t) { | |
415 | + keyUpChangeNum: function (t) { | |
416 | 416 | this.setData({ |
417 | 417 | maxWord: t.detail.value.length |
418 | 418 | }); |
... | ... | @@ -421,33 +421,33 @@ Page({ |
421 | 421 | |
422 | 422 | //---------计算立即购买---------- |
423 | 423 | calculatePrice2: function () { |
424 | - var th = this, good = this.data.bn_goods; | |
425 | - wx.showLoading({ title:"处理中.",}) | |
424 | + var th = this, good = this.data.bn_goods; | |
425 | + wx.showLoading({ title: "处理中.", }) | |
426 | 426 | //-----------计算商品总价-------------- |
427 | 427 | var allpice = good.shop_price * good.buynum; |
428 | - var all_integral=good.integral * good.buynum; | |
429 | - | |
430 | - var cut_price=0; | |
431 | - if(good.prom_type==3 && good.prom_price!==null){ | |
432 | - cut_price=allpice-good.prom_price; | |
428 | + var all_integral = good.integral * good.buynum; | |
429 | + | |
430 | + var cut_price = 0; | |
431 | + if (good.prom_type == 3 && good.prom_price !== null) { | |
432 | + cut_price = allpice - good.prom_price; | |
433 | 433 | } |
434 | - allpice=parseFloat(allpice).toFixed(2); | |
434 | + allpice = parseFloat(allpice).toFixed(2); | |
435 | 435 | var txt = "formData.all_price"; |
436 | 436 | th.setData({ [txt]: allpice, }); |
437 | - if(cut_price){ | |
438 | - var c_txt="formData.cut_price"; | |
437 | + if (cut_price) { | |
438 | + var c_txt = "formData.cut_price"; | |
439 | 439 | th.setData({ [c_txt]: cut_price, }); |
440 | 440 | } |
441 | 441 | to.getConfig2(function (ee) { |
442 | 442 | to.getwuliuprice(async function (rs) { |
443 | 443 | |
444 | 444 | var o_shipping_price = 0, goods_weight = -1, goods_piece = -1; |
445 | - var out_of_weight=null; //超出多少重量 | |
445 | + var out_of_weight = null; //超出多少重量 | |
446 | 446 | var freight_free = ee.freight_free; //全场满多少包邮 |
447 | 447 | var weight_free = ee.weight_free; //多少kg内包邮 |
448 | 448 | //-----------当地址不为空,且是物流时,计算物流费用,并同时商品不是优惠活动的包邮---------- |
449 | - if (th.data.user_addr != null && th.data.bn_exp_type == 0 && good.is_free_shipping == 0 && good.is_past!=1 ){ | |
450 | - | |
449 | + if (th.data.user_addr != null && th.data.bn_exp_type == 0 && good.is_free_shipping == 0 && good.is_past != 1) { | |
450 | + | |
451 | 451 | switch (good['exp_sum_type']) { |
452 | 452 | case 1: |
453 | 453 | //统一运费 |
... | ... | @@ -456,8 +456,8 @@ Page({ |
456 | 456 | if (goods_weight < 0) goods_weight = 0; |
457 | 457 | //累积商品重量 每种商品的重量 * 数量 |
458 | 458 | goods_weight += good['weight'] * good['buynum']; |
459 | - if(weight_free > 0){ | |
460 | - out_of_weight = (weight_free * 1000 ) - goods_weight; | |
459 | + if (weight_free > 0) { | |
460 | + out_of_weight = (weight_free * 1000) - goods_weight; | |
461 | 461 | } |
462 | 462 | break; |
463 | 463 | case 3: |
... | ... | @@ -466,94 +466,94 @@ Page({ |
466 | 466 | goods_piece += good['buynum']; break; |
467 | 467 | } |
468 | 468 | |
469 | - var code =""; | |
470 | - if(th.data.wu_arr && th.data.wu_arr[th.data.index]) code=th.data.wu_arr[th.data.index].code; | |
471 | - var no_ex_id=ee.no_ex_id; | |
472 | - th.data.is_no_by[th.data.bn_pick]=0; | |
473 | - | |
474 | - var no_by_data=null; | |
475 | - var gift_freight_free=freight_free; | |
476 | - //有不包邮区域,且不免运费 | |
477 | - if(no_ex_id && freight_free>0 && freight_free<=allpice-cut_price){ | |
478 | - //-----------获取不包邮区域,不包邮商品------- | |
479 | - await getApp().request.promiseGet("/api/weshop/areaFeemail/getAreaGoods",{ | |
480 | - data:{store_id:os.stoid,id:no_ex_id} | |
481 | - }).then(res=>{ | |
482 | - if(res.data.code==0){ | |
483 | - no_by_data=res.data.data[0]; | |
484 | - //如果有设置不包邮区域的时候 | |
485 | - if(res.data.data[0].region_list){ | |
486 | - if(th.check_by_area(res.data.data[0].region_list)){ | |
487 | - freight_free=0; | |
488 | - out_of_weight=0; | |
489 | - th.data.is_no_by[th.data.bn_pick]=1; | |
490 | - } | |
491 | - } | |
492 | - //如果有设置不包邮商品 | |
493 | - if(res.data.data[0].goods_list && freight_free){ | |
494 | - if(th.check_by_goods(res.data.data[0].goods_list)){ | |
495 | - freight_free=0; | |
496 | - out_of_weight=0; | |
497 | - th.data.is_no_by[th.data.bn_pick]=1; | |
498 | - } | |
499 | - } | |
500 | - } | |
501 | - }) | |
502 | - } | |
503 | - | |
504 | - th.data.is_by[th.data.bn_pick]=0; | |
505 | - //--------------开始计算物流------------------ | |
506 | - var shipping_price= | |
507 | - th.calculatewuliu(code, o_shipping_price, goods_weight,out_of_weight, | |
508 | - goods_piece, th.data.user_addr, freight_free, allpice-cut_price, rs); | |
509 | - if(shipping_price<=0){ | |
510 | - th.data.is_by[th.data.bn_pick]=1; //已经是包邮了,就不要选择包邮券 | |
469 | + var code = ""; | |
470 | + if (th.data.wu_arr && th.data.wu_arr[th.data.index]) code = th.data.wu_arr[th.data.index].code; | |
471 | + var no_ex_id = ee.no_ex_id; | |
472 | + th.data.is_no_by[th.data.bn_pick] = 0; | |
473 | + var no_by_data = null; | |
474 | + var gift_freight_free = freight_free; | |
475 | + //有不包邮区域,且不免运费 | |
476 | + if (no_ex_id && freight_free > 0 && freight_free <= allpice - cut_price) { | |
477 | + //-----------获取不包邮区域,不包邮商品------- | |
478 | + await getApp().request.promiseGet("/api/weshop/areaFeemail/getAreaGoods", { | |
479 | + data: { store_id: os.stoid, id: no_ex_id } | |
480 | + }).then(res => { | |
481 | + if (res.data.code == 0) { | |
482 | + no_by_data = res.data.data[0]; | |
483 | + //如果有设置不包邮区域的时候 | |
484 | + if (res.data.data[0].region_list) { | |
485 | + if (th.check_by_area(res.data.data[0].region_list)) { | |
486 | + freight_free = 0; | |
487 | + out_of_weight = 0; | |
488 | + weight_free = -1; | |
489 | + th.data.is_no_by[th.data.bn_pick] = 1; | |
490 | + } | |
491 | + } | |
492 | + //如果有设置不包邮商品 | |
493 | + if (res.data.data[0].goods_list && freight_free) { | |
494 | + if (th.check_by_goods(res.data.data[0].goods_list)) { | |
495 | + freight_free = 0; | |
496 | + out_of_weight = 0; | |
497 | + weight_free = -1; | |
498 | + th.data.is_no_by[th.data.bn_pick] = 1; | |
499 | + } | |
500 | + } | |
501 | + } | |
502 | + }) | |
503 | + } | |
504 | + | |
505 | + //--------------开始计算物流------------------ | |
506 | + var shipping_price = | |
507 | + th.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, | |
508 | + goods_piece, th.data.user_addr, freight_free, allpice - cut_price, rs, th.data.bn_pick); | |
509 | + if (shipping_price <= 0) { | |
510 | + th.data.is_by[th.data.bn_pick] = 1; //已经是包邮了,就不要选择包邮券 | |
511 | 511 | } |
512 | 512 | |
513 | 513 | shipping_price = parseFloat(shipping_price).toFixed(2); |
514 | 514 | var wl_txt = "formData.shipping_price"; |
515 | 515 | th.setData({ [wl_txt]: shipping_price, }) |
516 | - | |
517 | - }else{ | |
516 | + | |
517 | + } else { | |
518 | 518 | var wl_txt = "formData.shipping_price"; |
519 | 519 | th.setData({ [wl_txt]: 0, }) |
520 | 520 | } |
521 | 521 | //---如果有选择优惠券的情况下--- |
522 | - var quan_price=0,bn_pick=th.data.bn_pick; | |
523 | - | |
524 | - //-----------------支付价,优惠券不减物流----------------- | |
522 | + var quan_price = 0, bn_pick = th.data.bn_pick; | |
523 | + | |
524 | + //-----------------支付价,优惠券不减物流----------------- | |
525 | 525 | var total_m = (parseFloat(allpice)).toFixed(2); |
526 | - var order_m = (parseFloat(allpice-cut_price)-quan_price).toFixed(2); | |
527 | - var coupon_price=quan_price; //优惠券优惠了多少钱 | |
528 | - if(order_m<0) { | |
529 | - order_m=0;coupon_price=parseFloat(order_m).toFixed(2); | |
526 | + var order_m = (parseFloat(allpice - cut_price) - quan_price).toFixed(2); | |
527 | + var coupon_price = quan_price; //优惠券优惠了多少钱 | |
528 | + if (order_m < 0) { | |
529 | + order_m = 0; coupon_price = parseFloat(order_m).toFixed(2); | |
530 | 530 | } |
531 | - | |
532 | - //--看一下有没有订单优惠-- | |
533 | - total_m= parseFloat( total_m)+ parseFloat( th.data.formData.shipping_price); | |
534 | - order_m = parseFloat(order_m)+ parseFloat( th.data.formData.shipping_price); | |
535 | - var atxt= "formData.total_amount"; | |
536 | - th.setData({ [atxt]: total_m, }) | |
537 | - | |
538 | - var txt = "formData.user_money"; | |
539 | - var txt2 = "formData.order_amount"; | |
540 | - var txt4="formData.integral"; | |
541 | - | |
542 | - var amoney = parseFloat(th.data.userinfo.user_money - th.data.txmon - th.data.userinfo.frozen_money); | |
543 | - //--------------如果使用余额--------------------- | |
544 | - if (th.data.bn_use_money == 1) { | |
545 | - if (amoney> order_m) { | |
546 | - order_m = order_m.toFixed(2); | |
547 | - th.setData({ [txt]: order_m, [txt2]:0,[txt4]:all_integral,show_submit:1 }) | |
548 | - }else{ | |
549 | - order_m =parseFloat(order_m - amoney); | |
550 | - order_m = order_m.toFixed(2); | |
551 | - th.setData({ [txt]: amoney, [txt2]: order_m,[txt4]:all_integral,show_submit:1 }) | |
552 | - } | |
553 | - }else{ | |
554 | - th.setData({ [txt]: 0, [txt2]: order_m,[txt4]:all_integral, show_submit:1 }) | |
555 | - } | |
556 | - | |
531 | + | |
532 | + //--看一下有没有订单优惠--0 | |
533 | + total_m = parseFloat(total_m) + parseFloat(th.data.formData.shipping_price); | |
534 | + order_m = parseFloat(order_m) + parseFloat(th.data.formData.shipping_price); | |
535 | + var atxt = "formData.total_amount"; | |
536 | + th.setData({ [atxt]: total_m, }) | |
537 | + | |
538 | + var txt = "formData.user_money"; | |
539 | + var txt2 = "formData.order_amount"; | |
540 | + var txt4 = "formData.integral"; | |
541 | + | |
542 | + var amoney = parseFloat(th.data.userinfo.user_money - th.data.txmon - th.data.userinfo.frozen_money); | |
543 | + //--------------如果使用余额--------------------- | |
544 | + if (th.data.bn_use_money == 1) { | |
545 | + if (amoney > order_m) { | |
546 | + order_m = order_m.toFixed(2); | |
547 | + th.setData({ [txt]: order_m, [txt2]: 0, [txt4]: all_integral, show_submit: 1 }) | |
548 | + } else { | |
549 | + order_m = parseFloat(order_m - amoney); | |
550 | + order_m = order_m.toFixed(2); | |
551 | + th.setData({ [txt]: amoney, [txt2]: order_m, [txt4]: all_integral, show_submit: 1 }) | |
552 | + } | |
553 | + } else { | |
554 | + th.setData({ [txt]: 0, [txt2]: order_m, [txt4]: all_integral, show_submit: 1 }) | |
555 | + } | |
556 | + | |
557 | 557 | wx.hideLoading(); |
558 | 558 | |
559 | 559 | }); |
... | ... | @@ -561,104 +561,104 @@ Page({ |
561 | 561 | }, |
562 | 562 | |
563 | 563 | //--------------------提交订单----------------------- |
564 | - async submitForm(t){ | |
565 | - var sub_value=t; | |
564 | + async submitForm(t) { | |
565 | + var sub_value = t; | |
566 | 566 | |
567 | - if(this.data.is_summit_ing==1) return false; //--提交中退出-- | |
568 | - this.data.is_summit_ing=1; | |
569 | - var th=this,pdata=new Array(); | |
570 | - var ff=true; | |
567 | + if (this.data.is_summit_ing == 1) return false; //--提交中退出-- | |
568 | + this.data.is_summit_ing = 1; | |
569 | + var th = this, pdata = new Array(); | |
570 | + var ff = true; | |
571 | 571 | //------------立即购买------------- |
572 | - if (th.data.is_b_now==1 && th.data.bn_goods.prom_type!=5){ | |
572 | + if (th.data.is_b_now == 1 && th.data.bn_goods.prom_type != 5) { | |
573 | 573 | |
574 | - if(th.data.bn_exp_type == 0 && th.data.user_addr==null ){ | |
575 | - ff = false; getApp().my_warnning("请选择收货地址",0,th); | |
576 | - th.data.is_summit_ing = 0; | |
574 | + if (th.data.bn_exp_type == 0 && th.data.user_addr == null) { | |
575 | + ff = false; getApp().my_warnning("请选择收货地址", 0, th); | |
576 | + th.data.is_summit_ing = 0; | |
577 | 577 | } |
578 | 578 | if (!ff) return false; |
579 | 579 | var addr = th.data.user_addr; |
580 | - if (th.data.bn_exp_type == 1) addr=null; | |
580 | + if (th.data.bn_exp_type == 1) addr = null; | |
581 | 581 | |
582 | - if(th.data.bn_exp_type==0) | |
583 | - if(th.data.wu_arr==null || th.data.wu_arr.length<=0){ | |
584 | - getApp().my_warnning("读取物流失败",0,th); | |
585 | - th.data.is_summit_ing = 0; | |
582 | + if (th.data.bn_exp_type == 0) | |
583 | + if (th.data.wu_arr == null || th.data.wu_arr.length <= 0) { | |
584 | + getApp().my_warnning("读取物流失败", 0, th); | |
585 | + th.data.is_summit_ing = 0; | |
586 | 586 | return false; |
587 | 587 | } |
588 | - | |
589 | - | |
590 | - var integrals=0; | |
591 | - var get_datas= { | |
592 | - user_id:getApp().globalData.user_id, store_id:o.stoid, | |
593 | - }; | |
594 | - await getApp().request.promiseGet("/api/weshop/users/getAllPoints", { | |
595 | - data: get_datas | |
596 | - }).then(res => { | |
597 | - if(res.data.code==0){ | |
598 | - integrals=res.data.data.Integral; | |
599 | - } | |
600 | - }) | |
601 | - | |
602 | - //判断积分的情况 | |
603 | - if(th.data.formData.integral && parseFloat(th.data.formData.integral)< parseFloat(integrals) ){ | |
604 | - getApp().my_warnning("积分不足",0,th); | |
605 | - th.data.is_summit_ing = 0; | |
606 | - return false; | |
607 | - } | |
608 | - | |
609 | - | |
610 | - var item={ | |
588 | + | |
589 | + | |
590 | + var integrals = 0; | |
591 | + var get_datas = { | |
592 | + user_id: getApp().globalData.user_id, store_id: o.stoid, | |
593 | + }; | |
594 | + await getApp().request.promiseGet("/api/weshop/users/getAllPoints", { | |
595 | + data: get_datas | |
596 | + }).then(res => { | |
597 | + if (res.data.code == 0) { | |
598 | + integrals = res.data.data.Integral; | |
599 | + } | |
600 | + }) | |
601 | + | |
602 | + //判断积分的情况 | |
603 | + if (th.data.formData.integral && parseFloat(th.data.formData.integral) < parseFloat(integrals)) { | |
604 | + getApp().my_warnning("积分不足", 0, th); | |
605 | + th.data.is_summit_ing = 0; | |
606 | + return false; | |
607 | + } | |
608 | + | |
609 | + | |
610 | + var item = { | |
611 | 611 | 'user_id': to.globalData.user_id, |
612 | 612 | 'consignee': addr == null ? "" : addr.consignee, |
613 | 613 | 'province': addr == null ? 0 : addr.province, |
614 | 614 | 'city': addr == null ? 0 : addr.city, |
615 | 615 | 'district': addr == null ? 0 : addr.district, |
616 | 616 | 'twon': addr == null ? 0 : addr.twon, |
617 | - 'address': addr == null ? "": addr.address, | |
617 | + 'address': addr == null ? "" : addr.address, | |
618 | 618 | 'more_address': addr == null ? "" : addr.more_address, |
619 | 619 | //'mobile': th.data.userinfo.mobile, |
620 | 620 | 'mobile': addr == null ? th.data.userinfo.mobile : addr.mobile, |
621 | - 'email':'', | |
621 | + 'email': '', | |
622 | 622 | 'shipping_code': th.data.bn_exp_type == 1 ? 0 : th.data.wu_arr[th.data.index].code, |
623 | 623 | 'shipping_name': th.data.bn_exp_type == 1 ? '' : th.data.wu_arr[th.data.index].name, |
624 | - 'invoice_title':'', | |
624 | + 'invoice_title': '', | |
625 | 625 | 'goods_price': th.data.formData.all_price, //商品总价 |
626 | 626 | 'shipping_price': th.data.formData.shipping_price, //物流金额 |
627 | 627 | 'user_money': th.data.formData.user_money, //使用余额 |
628 | 628 | 'total_amount': th.data.formData.total_amount, //订单总价 |
629 | 629 | 'order_amount': th.data.formData.order_amount, //应付 |
630 | 630 | 'user_note': t.detail.value.user_note, //用户备注 |
631 | - 'store_id':oo.stoid, //商家 | |
631 | + 'store_id': oo.stoid, //商家 | |
632 | 632 | 'pickup_id': th.data.bn_pick, //门店 |
633 | 633 | 'exp_type': th.data.bn_exp_type, //配送方式 |
634 | - 'order_goods':new Array(), | |
635 | - 'integral': th.data.formData.integral, | |
634 | + 'order_goods': new Array(), | |
635 | + 'integral': th.data.formData.integral, | |
636 | 636 | }; |
637 | 637 | //是不是重新提交 |
638 | - if(th.data.is_continue==1) item.is_continue=1; | |
638 | + if (th.data.is_continue == 1) item.is_continue = 1; | |
639 | 639 | |
640 | 640 | //获取立即购买的商品的信息 |
641 | 641 | var gg = to.get_b_now(); |
642 | 642 | //--商品的房间号-- |
643 | - if(gg.room_id && gg.room_id>0){ | |
644 | - item.room_ids=gg.room_id; | |
643 | + if (gg.room_id && gg.room_id > 0) { | |
644 | + item.room_ids = gg.room_id; | |
645 | + } | |
646 | + | |
647 | + //老会员成为分销下线需要的参数 | |
648 | + if (getApp().globalData.first_leader && !getApp().globalData.userInfo.first_leader) { | |
649 | + //判断一下分享人是不是分享商 | |
650 | + await app.request.promiseGet("/api/weshop/users/get/" + os.stoid + "/" + getApp().globalData.first_leader, {}).then(res => { | |
651 | + if (res.data.code == 0) { | |
652 | + var user = res.data.data; | |
653 | + if (user.is_distribut == 1) { | |
654 | + item.first_leader = parseInt(getApp().globalData.first_leader); | |
655 | + } | |
656 | + } | |
657 | + }) | |
645 | 658 | } |
646 | - | |
647 | - //老会员成为分销下线需要的参数 | |
648 | - if(getApp().globalData.first_leader && !getApp().globalData.userInfo.first_leader){ | |
649 | - //判断一下分享人是不是分享商 | |
650 | - await app.request.promiseGet("/api/weshop/users/get/" + os.stoid+"/"+getApp().globalData.first_leader,{}).then(res=>{ | |
651 | - if(res.data.code==0){ | |
652 | - var user= res.data.data; | |
653 | - if(user.is_distribut==1){ | |
654 | - item.first_leader=parseInt(getApp().globalData.first_leader); | |
655 | - } | |
656 | - } | |
657 | - }) | |
658 | - } | |
659 | - | |
660 | - | |
661 | - var goods={ | |
659 | + | |
660 | + | |
661 | + var goods = { | |
662 | 662 | 'goods_id': gg.goods_id, |
663 | 663 | 'goods_name': gg.goods_name, |
664 | 664 | 'goods_sn': gg.goods_sn, |
... | ... | @@ -667,37 +667,37 @@ Page({ |
667 | 667 | 'goods_price': th.data.bn_goods.shop_price, |
668 | 668 | 'member_goods_price': th.data.bn_goods.shop_price, |
669 | 669 | 'store_id': oo.stoid, |
670 | - 'prom_type':th.data.bn_goods.prom_type, //促销活动类型 | |
670 | + 'prom_type': th.data.bn_goods.prom_type, //促销活动类型 | |
671 | 671 | 'prom_id': th.data.bn_goods.prom_id, //促销活动id |
672 | 672 | }; |
673 | 673 | |
674 | 674 | //-- 把导购的信息填入-- |
675 | - if(gg.guide_id){ | |
676 | - goods.guide_id=gg.guide_id; | |
677 | - goods.guide_type=gg.guide_type; | |
678 | - //调用接口判断是不是会员 | |
679 | - await getApp().request.promiseGet("/api/weshop/shoppingGuide/getId/"+oo.stoid+"/"+gg.guide_id,{}).then(res=>{ | |
680 | - if(res.data.code==0){ | |
681 | - goods.guide_name=res.data.data.salesman; | |
682 | - goods.guide_sn=res.data.data.salesman_no; | |
683 | - } | |
684 | - }) | |
675 | + if (gg.guide_id) { | |
676 | + goods.guide_id = gg.guide_id; | |
677 | + goods.guide_type = gg.guide_type; | |
678 | + //调用接口判断是不是会员 | |
679 | + await getApp().request.promiseGet("/api/weshop/shoppingGuide/getId/" + oo.stoid + "/" + gg.guide_id, {}).then(res => { | |
680 | + if (res.data.code == 0) { | |
681 | + goods.guide_name = res.data.data.salesman; | |
682 | + goods.guide_sn = res.data.data.salesman_no; | |
683 | + } | |
684 | + }) | |
685 | 685 | } |
686 | 686 | |
687 | 687 | //--商品的房间号-- |
688 | - if(gg.room_id && gg.room_id>0){ | |
689 | - goods.room_id=gg.room_id; | |
688 | + if (gg.room_id && gg.room_id > 0) { | |
689 | + goods.room_id = gg.room_id; | |
690 | 690 | } |
691 | - | |
691 | + | |
692 | 692 | item.order_goods.push(goods); |
693 | - pdata.push(item); | |
693 | + pdata.push(item); | |
694 | 694 | } |
695 | - | |
696 | 695 | |
697 | - if (pdata.length==0) return; | |
696 | + | |
697 | + if (pdata.length == 0) return; | |
698 | 698 | var str = JSON.stringify(pdata); |
699 | - | |
700 | - wx.showLoading({title: "加载中"}); | |
699 | + | |
700 | + wx.showLoading({ title: "加载中" }); | |
701 | 701 | wx.request({ |
702 | 702 | url: oo.url + '/api/weshop/order/createWxdOrder', |
703 | 703 | data: str, |
... | ... | @@ -707,11 +707,11 @@ Page({ |
707 | 707 | },// 设置请求的 header |
708 | 708 | success: function (res) { |
709 | 709 | |
710 | - th.data.is_summit_ing=0; //是否提交中 | |
710 | + th.data.is_summit_ing = 0; //是否提交中 | |
711 | 711 | wx.hideLoading(); |
712 | 712 | if (res.statusCode == 200) { |
713 | - var data=res.data; | |
714 | - if(data.code==0){ | |
713 | + var data = res.data; | |
714 | + if (data.code == 0) { | |
715 | 715 | console.log(th.data.is_b_now); |
716 | 716 | //如果是购物车结算,还要删除购物车 |
717 | 717 | if (th.data.is_b_now == 0) { |
... | ... | @@ -732,20 +732,20 @@ Page({ |
732 | 732 | //void e.jumpToCart4({ |
733 | 733 | // order_sn: data.data, |
734 | 734 | //}, 1); |
735 | - util_pay.pay(data.data, function() { | |
736 | - //app.my_warnning("支付成功",1,th); | |
737 | - //setTimeout(function () { | |
738 | - wx.redirectTo({ | |
739 | - url: "/pages/payment/pay_success/pay_success?type=2&order_sn="+data.data | |
740 | - }) | |
741 | - //},1000) | |
742 | - | |
743 | - }, function () { | |
744 | - //支付失败 | |
745 | - setTimeout(function () { | |
746 | - wx.navigateBack({ delta: 1 }) | |
747 | - },1000) | |
748 | - },oo.stoid); | |
735 | + util_pay.pay(data.data, function () { | |
736 | + //app.my_warnning("支付成功",1,th); | |
737 | + //setTimeout(function () { | |
738 | + wx.redirectTo({ | |
739 | + url: "/pages/payment/pay_success/pay_success?type=2&order_sn=" + data.data | |
740 | + }) | |
741 | + //},1000) | |
742 | + | |
743 | + }, function () { | |
744 | + //支付失败 | |
745 | + setTimeout(function () { | |
746 | + wx.navigateBack({ delta: 1 }) | |
747 | + }, 1000) | |
748 | + }, oo.stoid); | |
749 | 749 | |
750 | 750 | } else { |
751 | 751 | var dd = { |
... | ... | @@ -757,110 +757,110 @@ Page({ |
757 | 757 | data: dd, |
758 | 758 | success: function (t) { |
759 | 759 | //console.log(t); |
760 | - if(t.data.code==0){ | |
761 | - //app.my_warnning("支付成功",1,th); | |
762 | - //setTimeout(function () { | |
763 | - th.setData({ isclose: 0 }); | |
764 | - wx.redirectTo({ | |
765 | - url: "/pages/payment/pay_success/pay_success?type=2&order_sn="+data.data, | |
766 | - }) | |
767 | - //}, 1000) | |
760 | + if (t.data.code == 0) { | |
761 | + //app.my_warnning("支付成功",1,th); | |
762 | + //setTimeout(function () { | |
763 | + th.setData({ isclose: 0 }); | |
764 | + wx.redirectTo({ | |
765 | + url: "/pages/payment/pay_success/pay_success?type=2&order_sn=" + data.data, | |
766 | + }) | |
767 | + //}, 1000) | |
768 | 768 | } |
769 | 769 | }, |
770 | - fail:function () { | |
770 | + fail: function () { | |
771 | 771 | |
772 | 772 | } |
773 | 773 | }); |
774 | 774 | } |
775 | 775 | |
776 | 776 | } |
777 | - else{ | |
778 | - //--内容换行-- | |
779 | - var msg=data.msg; | |
780 | - //赠品活动已经取消,无法赠送,是否继续买单? | |
781 | - if(msg.indexOf("是否继续买单")>0){ | |
782 | - wx.showModal({ | |
783 | - title:"提示", | |
784 | - content: data.msg, | |
785 | - cancelText:'取消', | |
786 | - confirmText:'确定', | |
787 | - showCancel: true, | |
788 | - success(res){ | |
789 | - if(res.cancel){ | |
790 | - return; | |
791 | - }else if(res.confirm){ | |
792 | - th.data.is_continue=1; | |
793 | - th.submitForm(sub_value); | |
794 | - } | |
795 | - } | |
796 | - }) | |
797 | - return; | |
798 | - } | |
799 | - if(msg.length>13){ | |
800 | - msg=msg.slice(0, 13) + "\r\n"+ msg.slice(13); | |
801 | - } | |
802 | - getApp().confirmBox(msg); | |
803 | - } | |
804 | - }else{ | |
805 | - console.log("index.js wx.request CheckCallUser statusCode" + res.statusCode); | |
777 | + else { | |
778 | + //--内容换行-- | |
779 | + var msg = data.msg; | |
780 | + //赠品活动已经取消,无法赠送,是否继续买单? | |
781 | + if (msg.indexOf("是否继续买单") > 0) { | |
782 | + wx.showModal({ | |
783 | + title: "提示", | |
784 | + content: data.msg, | |
785 | + cancelText: '取消', | |
786 | + confirmText: '确定', | |
787 | + showCancel: true, | |
788 | + success(res) { | |
789 | + if (res.cancel) { | |
790 | + return; | |
791 | + } else if (res.confirm) { | |
792 | + th.data.is_continue = 1; | |
793 | + th.submitForm(sub_value); | |
794 | + } | |
795 | + } | |
796 | + }) | |
797 | + return; | |
798 | + } | |
799 | + if (msg.length > 13) { | |
800 | + msg = msg.slice(0, 13) + "\r\n" + msg.slice(13); | |
801 | + } | |
802 | + getApp().confirmBox(msg); | |
803 | + } | |
804 | + } else { | |
805 | + console.log("index.js wx.request CheckCallUser statusCode" + res.statusCode); | |
806 | 806 | } |
807 | 807 | }, |
808 | 808 | fail: function () { |
809 | - th.data.is_summit_ing=0; | |
809 | + th.data.is_summit_ing = 0; | |
810 | 810 | wx.hideLoading(); |
811 | 811 | console.log("index.js wx.request CheckCallUser fail"); |
812 | 812 | }, |
813 | - complete: function () {} | |
813 | + complete: function () { } | |
814 | 814 | }) |
815 | 815 | |
816 | 816 | }, |
817 | - | |
817 | + | |
818 | 818 | //---确认线下门店的数量足不足--- |
819 | - async check_store_num(goods_id,pick,goods_num,func){ | |
820 | - var lock=0,pick_no,plist,erpwareid; | |
821 | - //先读取门店的lock | |
822 | - await getApp().request.promiseGet("/api/weshop/order/ware/lock/page",{ | |
823 | - data:{store_id:os.stoid,wareId:goods_id,storageId:pick,pageSize:1000} | |
824 | - }).then(res=>{ | |
825 | - if(res.data.code==0 && res.data.data.total>0){ | |
826 | - for(var i in res.data.data.pageData) | |
827 | - lock+=res.data.data.pageData[i].outQty; | |
828 | - } | |
829 | - }) | |
830 | - //先获取门店的编号 | |
831 | - await getApp().request.promiseGet("/api/weshop/pickup/get/"+os.stoid+"/"+pick,{ | |
832 | - data:{storeId:os.stoid,goodsId:t.goods_id,pickupId:pick} | |
833 | - }).then(res=>{ | |
834 | - if(res.data.code==0){ | |
835 | - pick_no=res.data.data.pickup_no; | |
836 | - } | |
837 | - }) | |
838 | - //先获取商品的线下库存 | |
839 | - await getApp().request.promiseGet("/api/weshop/goods/get/"+os.stoid+"/"+goods_id,{ | |
840 | - data:{storeId:os.stoid,goodsId:t.goods_id,pickupId:pick} | |
841 | - }).then(res=>{ | |
842 | - if(res.data.code==0){ | |
843 | - erpwareid=res.data.data.erpwareid; | |
844 | - } | |
845 | - }) | |
846 | - //读取线下的门店库存 | |
847 | - await getApp().request.promiseGet("/api/weshop/goods/getWareStorages",{ | |
848 | - data:{storageNos:pick_no,wareIds:encodeURIComponent(erpwareid),storeId:os.stoid} | |
849 | - }).then(res=>{ | |
850 | - if(res.data.code==0 && res.data.data && res.data.data.pageData && res.data.data.pageData.length){ | |
851 | - plist=res.data.data.pageData[0]; | |
852 | - } | |
853 | - }) | |
854 | - var isok=1; | |
855 | - if(goods_num>plist.CanOutQty-lock){ | |
856 | - isok=0; | |
857 | - } | |
858 | - func(isok); | |
819 | + async check_store_num(goods_id, pick, goods_num, func) { | |
820 | + var lock = 0, pick_no, plist, erpwareid; | |
821 | + //先读取门店的lock | |
822 | + await getApp().request.promiseGet("/api/weshop/order/ware/lock/page", { | |
823 | + data: { store_id: os.stoid, wareId: goods_id, storageId: pick, pageSize: 1000 } | |
824 | + }).then(res => { | |
825 | + if (res.data.code == 0 && res.data.data.total > 0) { | |
826 | + for (var i in res.data.data.pageData) | |
827 | + lock += res.data.data.pageData[i].outQty; | |
828 | + } | |
829 | + }) | |
830 | + //先获取门店的编号 | |
831 | + await getApp().request.promiseGet("/api/weshop/pickup/get/" + os.stoid + "/" + pick, { | |
832 | + data: { storeId: os.stoid, goodsId: t.goods_id, pickupId: pick } | |
833 | + }).then(res => { | |
834 | + if (res.data.code == 0) { | |
835 | + pick_no = res.data.data.pickup_no; | |
836 | + } | |
837 | + }) | |
838 | + //先获取商品的线下库存 | |
839 | + await getApp().request.promiseGet("/api/weshop/goods/get/" + os.stoid + "/" + goods_id, { | |
840 | + data: { storeId: os.stoid, goodsId: t.goods_id, pickupId: pick } | |
841 | + }).then(res => { | |
842 | + if (res.data.code == 0) { | |
843 | + erpwareid = res.data.data.erpwareid; | |
844 | + } | |
845 | + }) | |
846 | + //读取线下的门店库存 | |
847 | + await getApp().request.promiseGet("/api/weshop/goods/getWareStorages", { | |
848 | + data: { storageNos: pick_no, wareIds: encodeURIComponent(erpwareid), storeId: os.stoid } | |
849 | + }).then(res => { | |
850 | + if (res.data.code == 0 && res.data.data && res.data.data.pageData && res.data.data.pageData.length) { | |
851 | + plist = res.data.data.pageData[0]; | |
852 | + } | |
853 | + }) | |
854 | + var isok = 1; | |
855 | + if (goods_num > plist.CanOutQty - lock) { | |
856 | + isok = 0; | |
857 | + } | |
858 | + func(isok); | |
859 | 859 | }, |
860 | 860 | |
861 | - useCoupon: function() { | |
861 | + useCoupon: function () { | |
862 | 862 | if (this.data.order.couponNum <= 0) { |
863 | - getApp().my_warnning("无可用优惠券",0,this); | |
863 | + getApp().my_warnning("无可用优惠券", 0, this); | |
864 | 864 | return; |
865 | 865 | } |
866 | 866 | |
... | ... | @@ -871,97 +871,97 @@ Page({ |
871 | 871 | url: "/pages/user/checkcoupon/checkcoupon?" + s.Obj2Str(a) |
872 | 872 | }); |
873 | 873 | }, |
874 | - enterAddressPage: function() { | |
875 | - getApp().globalData.is_cart_old=1; | |
876 | - this.data.isget_by_quan={}; | |
874 | + enterAddressPage: function () { | |
875 | + getApp().globalData.is_cart_old = 1; | |
876 | + this.data.isget_by_quan = {}; | |
877 | 877 | this.data.enterAddressPage = !0, wx.navigateTo({ |
878 | 878 | url: "/pages/user/address_list/address_list" |
879 | 879 | }); |
880 | 880 | }, |
881 | 881 | |
882 | - | |
882 | + | |
883 | 883 | |
884 | 884 | //--------立即购买时,选择自提和物流---------- |
885 | - setexptype:function(t){ | |
886 | - var th=this; | |
887 | - var ty = t.currentTarget.dataset.t,def_exp_code= getApp().globalData.userInfo.def_exp_code; | |
888 | - th.setData({ bn_exp_type:ty}); | |
885 | + setexptype: function (t) { | |
886 | + var th = this; | |
887 | + var ty = t.currentTarget.dataset.t, def_exp_code = getApp().globalData.userInfo.def_exp_code; | |
888 | + th.setData({ bn_exp_type: ty }); | |
889 | 889 | //当物流为空的时候。 |
890 | - if (ty == 0 && th.data.wu_arr==null){ | |
891 | - th.data.isget_by_quan={}; | |
890 | + if (ty == 0 && th.data.wu_arr == null) { | |
891 | + th.data.isget_by_quan = {}; | |
892 | 892 | return th.get_wuliu(th.calculatePrice2()); |
893 | 893 | } |
894 | 894 | |
895 | 895 | //--自提就要把包邮券清理掉-- |
896 | - if(ty==1){ | |
897 | - th.data.isget_by_quan={}; | |
898 | - if(th.data.using_quan && th.data.using_quan[th.data.bn_pick] && th.data.using_quan[th.data.bn_pick].isby==1){ | |
899 | - th.setData({using_quan:{}}); | |
896 | + if (ty == 1) { | |
897 | + th.data.isget_by_quan = {}; | |
898 | + if (th.data.using_quan && th.data.using_quan[th.data.bn_pick] && th.data.using_quan[th.data.bn_pick].isby == 1) { | |
899 | + th.setData({ using_quan: {} }); | |
900 | 900 | } |
901 | 901 | } |
902 | 902 | |
903 | - //判断有没有默认的物流地址值 | |
904 | - if (def_exp_code != "" && def_exp_code != null && def_exp_code !=undefined) { | |
905 | - var wu_arr=this.data.wu_arr; | |
906 | - if (wu_arr!= null && wu_arr!=""){ | |
907 | - for(var i=0;i<wu_arr.length;i++){ | |
908 | - if (wu_arr[i].shipping_code == def_exp_code){ | |
909 | - th.setData({index:i}); | |
910 | - } | |
911 | - } | |
903 | + //判断有没有默认的物流地址值 | |
904 | + if (def_exp_code != "" && def_exp_code != null && def_exp_code != undefined) { | |
905 | + var wu_arr = this.data.wu_arr; | |
906 | + if (wu_arr != null && wu_arr != "") { | |
907 | + for (var i = 0; i < wu_arr.length; i++) { | |
908 | + if (wu_arr[i].shipping_code == def_exp_code) { | |
909 | + th.setData({ index: i }); | |
912 | 910 | } |
911 | + } | |
913 | 912 | } |
914 | - th.calculatePrice2() | |
913 | + } | |
914 | + th.calculatePrice2() | |
915 | 915 | |
916 | 916 | }, |
917 | 917 | |
918 | 918 | //--------立即购买时,使用余额-------- |
919 | - set_bn_useyuer:function(){ | |
920 | - var th=this; | |
921 | - th.setData({ bn_use_money: !th.data.bn_use_money}); | |
919 | + set_bn_useyuer: function () { | |
920 | + var th = this; | |
921 | + th.setData({ bn_use_money: !th.data.bn_use_money }); | |
922 | 922 | th.calculatePrice2(); |
923 | 923 | }, |
924 | - set_js_useyuer:function(){ | |
924 | + set_js_useyuer: function () { | |
925 | 925 | var th = this; |
926 | 926 | th.setData({ js_use_money: !th.data.js_use_money }); |
927 | 927 | th.calculatePrice(); |
928 | 928 | }, |
929 | 929 | //-------------------计算物流--------------- |
930 | - calculatewuliu:function(code, o_shipping_price, goods_weight,out_of_weight, | |
931 | - goods_piece,user_addr, freight_free, o_price, rs){ | |
932 | - var price =0,th=this; | |
933 | - price +=parseFloat(o_shipping_price); | |
930 | + calculatewuliu: function (code, o_shipping_price, goods_weight, out_of_weight, | |
931 | + goods_piece, user_addr, freight_free, o_price, rs, pickid = null) { | |
932 | + var price = 0, th = this; | |
933 | + price += parseFloat(o_shipping_price); | |
934 | 934 | //如果是包邮 |
935 | - if (freight_free > 0 && o_price >= freight_free && out_of_weight>=0){ return 0;} | |
936 | - if (user_addr==null) { return 0; } | |
935 | + if (freight_free > 0 && o_price >= freight_free && out_of_weight >= 0) { return 0; } | |
936 | + if (user_addr == null) { return 0; } | |
937 | 937 | //计算物流的config item; |
938 | - var item=null; | |
938 | + var item = null; | |
939 | 939 | //先根据 镇 县 区找计算的config |
940 | - item = th.get_wuliu_config(user_addr.district,code,rs); | |
941 | - if (item==null) item = th.get_wuliu_config(user_addr.city, code, rs); | |
942 | - if (item==null) item = th.get_wuliu_config(user_addr.province, code, rs); | |
943 | - if (item == null) item = th.get_wuliu_default(code,rs); | |
940 | + item = th.get_wuliu_config(user_addr.district, code, rs); | |
941 | + if (item == null) item = th.get_wuliu_config(user_addr.city, code, rs); | |
942 | + if (item == null) item = th.get_wuliu_config(user_addr.province, code, rs); | |
943 | + if (item == null) item = th.get_wuliu_default(code, rs); | |
944 | + if (item == null) return o_shipping_price; | |
945 | + var fw_price = 0, fp_price = 0; | |
946 | + item = item.config; | |
944 | 947 | if (item == null) return o_shipping_price; |
945 | - var fw_price = 0, fp_price=0; | |
946 | - item=item.config; | |
947 | - if (item == null) return o_shipping_price; | |
948 | 948 | //------按重量---------- |
949 | 949 | if (goods_weight >= 0 && item['money']) { |
950 | - fw_price =parseFloat(item['money']); | |
951 | - if (goods_weight > item['first_weight']){ | |
950 | + fw_price = parseFloat(item['money']); | |
951 | + if (goods_weight > item['first_weight']) { | |
952 | 952 | var fw = goods_weight - item['first_weight']; |
953 | - var n = Math.ceil(fw/item['second_weight']) | |
953 | + var n = Math.ceil(fw / item['second_weight']) | |
954 | 954 | fw_price = fw_price + n * parseFloat(item['add_money']); |
955 | 955 | } |
956 | 956 | } |
957 | - //------超出重量---------- | |
958 | - if(out_of_weight < 0 && o_price >= freight_free){ | |
957 | + //------超出重量---------- | |
958 | + if (out_of_weight < 0 && o_price >= freight_free && !th.data.is_no_by[pickid]) { | |
959 | 959 | fw_price = parseFloat(item['money']); |
960 | 960 | var out_of_weight = Math.abs(out_of_weight); |
961 | 961 | if (out_of_weight > item['first_weight']) { |
962 | - var fw = out_of_weight - item['first_weight']; | |
963 | - var n = Math.ceil(fw / item['second_weight']) | |
964 | - fw_price = fw_price + n * parseFloat(item['add_money']); | |
962 | + var fw = out_of_weight - item['first_weight']; | |
963 | + var n = Math.ceil(fw / item['second_weight']) | |
964 | + fw_price = fw_price + n * parseFloat(item['add_money']); | |
965 | 965 | } |
966 | 966 | } |
967 | 967 | //------按件数---------- |
... | ... | @@ -973,21 +973,21 @@ Page({ |
973 | 973 | fp_price = fp_price + m * parseFloat(item['add_piecemoney']); |
974 | 974 | } |
975 | 975 | } |
976 | - var rspice =parseFloat(price + fw_price + fp_price); | |
976 | + var rspice = parseFloat(price + fw_price + fp_price); | |
977 | 977 | return rspice; |
978 | 978 | }, |
979 | 979 | |
980 | 980 | //------------循环获取config----------- |
981 | - get_wuliu_config:function(region_id,code,rs){ | |
982 | - var item=null,rslist = rs.pageData; | |
983 | - for (var i = 0; i < rslist.length;i++){ | |
984 | - if (rslist[i].code == code && rslist[i].region_id == region_id) { item = rslist[i];} | |
981 | + get_wuliu_config: function (region_id, code, rs) { | |
982 | + var item = null, rslist = rs.pageData; | |
983 | + for (var i = 0; i < rslist.length; i++) { | |
984 | + if (rslist[i].code == code && rslist[i].region_id == region_id) { item = rslist[i]; } | |
985 | 985 | } |
986 | 986 | return item; |
987 | 987 | }, |
988 | 988 | //-------循环获取config,code default------- |
989 | 989 | get_wuliu_default: function (code, rs) { |
990 | - var item = null, rslist=rs.pageData; | |
990 | + var item = null, rslist = rs.pageData; | |
991 | 991 | for (var i = 0; i < rslist.length; i++) { |
992 | 992 | if (rslist[i].shipping_code == code && rslist[i].is_default == 1) { item = rslist[i]; } |
993 | 993 | } |
... | ... | @@ -995,141 +995,140 @@ Page({ |
995 | 995 | }, |
996 | 996 | |
997 | 997 | //----------立即购买,选择物流------------- |
998 | - bindPickerChange:function(e){ | |
998 | + bindPickerChange: function (e) { | |
999 | 999 | var ind = e.detail.value |
1000 | 1000 | this.setData({ index: ind }); |
1001 | 1001 | this.calculatePrice2(); |
1002 | 1002 | }, |
1003 | 1003 | //----------购物车结算,选择物流------------- |
1004 | 1004 | bindPickerChange_w: function (e) { |
1005 | - var ind=e.detail.value, txt = e.currentTarget.dataset.txt; | |
1005 | + var ind = e.detail.value, txt = e.currentTarget.dataset.txt; | |
1006 | 1006 | this.setData({ [txt]: ind }); |
1007 | 1007 | this.calculatePrice(); |
1008 | 1008 | }, |
1009 | 1009 | |
1010 | - cart_set_err:function(e){ | |
1011 | - var txt = e.currentTarget.dataset.err; | |
1012 | - var ob={}; | |
1013 | - ob[txt] = this.data.imgUrl + "/miniapp/images/default_g_img.gif"; | |
1014 | - this.setData(ob); | |
1010 | + cart_set_err: function (e) { | |
1011 | + var txt = e.currentTarget.dataset.err; | |
1012 | + var ob = {}; | |
1013 | + ob[txt] = this.data.imgUrl + "/miniapp/images/default_g_img.gif"; | |
1014 | + this.setData(ob); | |
1015 | 1015 | }, |
1016 | - | |
1016 | + | |
1017 | 1017 | //// 开启物流的弹窗 |
1018 | - show_wu_arr:function(e){ | |
1019 | - var wu_arr_txt=e.currentTarget.dataset.txt; | |
1020 | - var w_sele_index=e.currentTarget.dataset.w_sele_index; | |
1021 | - var is_express=null; | |
1022 | - var ob={open_express: 1,wu_arr_txt:wu_arr_txt,disabled:1}; | |
1018 | + show_wu_arr: function (e) { | |
1019 | + var wu_arr_txt = e.currentTarget.dataset.txt; | |
1020 | + var w_sele_index = e.currentTarget.dataset.w_sele_index; | |
1021 | + var is_express = null; | |
1022 | + var ob = { open_express: 1, wu_arr_txt: wu_arr_txt, disabled: 1 }; | |
1023 | 1023 | |
1024 | 1024 | //--如果是多个门店的时候-- |
1025 | - if(w_sele_index!=undefined){ | |
1026 | - is_express=this.data.cartlist[w_sele_index].wind; | |
1027 | - ob['is_express']=is_express; | |
1025 | + if (w_sele_index != undefined) { | |
1026 | + is_express = this.data.cartlist[w_sele_index].wind; | |
1027 | + ob['is_express'] = is_express; | |
1028 | 1028 | } |
1029 | 1029 | this.setData(ob); |
1030 | 1030 | }, |
1031 | - // 关闭物流的弹窗 | |
1032 | - close_express:function(){ | |
1033 | - this.setData({ open_express:0,disabled:0 }); | |
1031 | + // 关闭物流的弹窗 | |
1032 | + close_express: function () { | |
1033 | + this.setData({ open_express: 0, disabled: 0 }); | |
1034 | + }, | |
1035 | + // 选择物流 | |
1036 | + click_express_name: function (e) { | |
1037 | + var express_name = e.currentTarget.dataset.name, shippingcode = e.currentTarget.dataset.shippingcode; | |
1038 | + var index = e.currentTarget.dataset.idxe; | |
1039 | + var ob = { is_express: index, is_shipping_code: shippingcode, disabled: 0 }; | |
1040 | + ob[this.data.wu_arr_txt] = index; | |
1041 | + this.setData(ob); | |
1034 | 1042 | }, |
1035 | - // 选择物流 | |
1036 | - click_express_name:function(e){ | |
1037 | - var express_name = e.currentTarget.dataset.name, shippingcode = e.currentTarget.dataset.shippingcode; | |
1038 | - var index=e.currentTarget.dataset.idxe; | |
1039 | - var ob={ is_express: index, is_shipping_code: shippingcode,disabled:0}; | |
1040 | - ob[this.data.wu_arr_txt]=index; | |
1041 | - this.setData(ob); | |
1042 | - }, | |
1043 | 1043 | |
1044 | - //点击确定物流 | |
1045 | - determine_expres:function(e){ | |
1046 | - this.setData({ open_express: 0}); | |
1047 | - this.calculatePrice2(); | |
1044 | + //点击确定物流 | |
1045 | + determine_expres: function (e) { | |
1046 | + this.setData({ open_express: 0 }); | |
1047 | + this.calculatePrice2(); | |
1048 | 1048 | }, |
1049 | - | |
1049 | + | |
1050 | 1050 | //设置默认物流 |
1051 | 1051 | select_default_logistics: function () { |
1052 | - var th=this; | |
1053 | - var is_shipping_code=this.data.is_shipping_code | |
1054 | - getApp().request.put("/api/weshop/users/update",{ | |
1055 | - data: { user_id: getApp().globalData.user_id, store_id: oo.stoid, def_exp_code: is_shipping_code}, | |
1056 | - success:function(rse){ | |
1057 | - if (rse.data.code==0){ | |
1058 | - getApp().globalData.userInfo.def_exp_code=is_shipping_code; | |
1052 | + var th = this; | |
1053 | + var is_shipping_code = this.data.is_shipping_code | |
1054 | + getApp().request.put("/api/weshop/users/update", { | |
1055 | + data: { user_id: getApp().globalData.user_id, store_id: oo.stoid, def_exp_code: is_shipping_code }, | |
1056 | + success: function (rse) { | |
1057 | + if (rse.data.code == 0) { | |
1058 | + getApp().globalData.userInfo.def_exp_code = is_shipping_code; | |
1059 | 1059 | th.setData({ open_express: 0 }); |
1060 | 1060 | //----计算此时购物车的价格,这个页面没有calculatePrice(),2021.7.19-------- |
1061 | 1061 | //if(th.data.is_b_now==1) th.calculatePrice2(); |
1062 | 1062 | //else th.calculatePrice(); |
1063 | 1063 | th.calculatePrice2(); |
1064 | - } | |
1064 | + } | |
1065 | 1065 | } |
1066 | 1066 | }) |
1067 | 1067 | }, |
1068 | 1068 | |
1069 | 1069 | //更新下默认,在onshow里面 |
1070 | - update_code(){ | |
1071 | - var th=this,m_wind=0,def_exp_code=getApp().globalData.userInfo.def_exp_code; | |
1072 | - //--定时器,判断wu_arr不未空-- | |
1073 | - var uii=setInterval(function () { | |
1074 | - if(th.data.wu_arr) | |
1075 | - { | |
1076 | - clearInterval(uii); | |
1077 | - for (var k = 0; k < th.data.wu_arr.length; k++) { | |
1078 | - var item = th.data.wu_arr[k]; | |
1079 | - if (def_exp_code == item.code) { m_wind = k; } | |
1080 | - } | |
1081 | - //--如果是立即购买-- | |
1082 | - th.setData({index: m_wind,is_express:m_wind}); | |
1083 | - | |
1084 | - } | |
1085 | - },500); | |
1070 | + update_code() { | |
1071 | + var th = this, m_wind = 0, def_exp_code = getApp().globalData.userInfo.def_exp_code; | |
1072 | + //--定时器,判断wu_arr不未空-- | |
1073 | + var uii = setInterval(function () { | |
1074 | + if (th.data.wu_arr) { | |
1075 | + clearInterval(uii); | |
1076 | + for (var k = 0; k < th.data.wu_arr.length; k++) { | |
1077 | + var item = th.data.wu_arr[k]; | |
1078 | + if (def_exp_code == item.code) { m_wind = k; } | |
1079 | + } | |
1080 | + //--如果是立即购买-- | |
1081 | + th.setData({ index: m_wind, is_express: m_wind }); | |
1082 | + | |
1083 | + } | |
1084 | + }, 500); | |
1086 | 1085 | }, |
1087 | - | |
1086 | + | |
1088 | 1087 | //检查区域是不是包邮 |
1089 | - check_area:function(arr){ | |
1090 | - var user_addr=this.data.user_addr; | |
1091 | - for(var i in arr){ | |
1092 | - var item=arr[i]; | |
1093 | - if(user_addr.twon==item || user_addr.district==item | |
1094 | - || user_addr.city==item|| user_addr.province==item ){ | |
1095 | - return 0; | |
1096 | - } | |
1097 | - } | |
1098 | - return 1; | |
1088 | + check_area: function (arr) { | |
1089 | + var user_addr = this.data.user_addr; | |
1090 | + for (var i in arr) { | |
1091 | + var item = arr[i]; | |
1092 | + if (user_addr.twon == item || user_addr.district == item | |
1093 | + || user_addr.city == item || user_addr.province == item) { | |
1094 | + return 0; | |
1095 | + } | |
1096 | + } | |
1097 | + return 1; | |
1099 | 1098 | }, |
1100 | - | |
1099 | + | |
1101 | 1100 | //检查立即购买的商品是不是不包邮 |
1102 | - check_good:function(arr,goods_id){ | |
1103 | - if(!goods_id) goods_id=this.data.bn_goods.goods_id; | |
1104 | - for(var i in arr){ | |
1105 | - var item=arr[i]; | |
1106 | - if(goods_id==item) return 0; | |
1107 | - } | |
1108 | - return 1; | |
1101 | + check_good: function (arr, goods_id) { | |
1102 | + if (!goods_id) goods_id = this.data.bn_goods.goods_id; | |
1103 | + for (var i in arr) { | |
1104 | + var item = arr[i]; | |
1105 | + if (goods_id == item) return 0; | |
1106 | + } | |
1107 | + return 1; | |
1109 | 1108 | }, |
1110 | - check_by_area:function(region_list){ | |
1111 | - var arr=region_list.split(","); | |
1112 | - var check=this.check_area(arr); | |
1113 | - return !check; | |
1109 | + check_by_area: function (region_list) { | |
1110 | + var arr = region_list.split(","); | |
1111 | + var check = this.check_area(arr); | |
1112 | + return !check; | |
1114 | 1113 | }, |
1115 | - check_by_goods:function(goods_list,goods_id){ | |
1116 | - var arr=goods_list.split(","); | |
1117 | - var check=this.check_good(arr,goods_id); | |
1118 | - return !check; | |
1114 | + check_by_goods: function (goods_list, goods_id) { | |
1115 | + var arr = goods_list.split(","); | |
1116 | + var check = this.check_good(arr, goods_id); | |
1117 | + return !check; | |
1119 | 1118 | }, |
1120 | - | |
1121 | 1119 | |
1122 | - //从优惠的映射中拿出商品从表的item | |
1123 | - arr_get_goods:function(goods_id,arr){ | |
1124 | - for(var i in arr){ | |
1125 | - if(arr[i].goods_id==goods_id) return arr[i]; | |
1126 | - } | |
1127 | - }, | |
1128 | - | |
1129 | - //跳转到购买卡 | |
1130 | - buycard:function(){ | |
1131 | - getApp().goto("/pages/user/plus/plus"); | |
1132 | - getApp().globalData.plus_buy_back=1; | |
1133 | - } | |
1120 | + | |
1121 | + //从优惠的映射中拿出商品从表的item | |
1122 | + arr_get_goods: function (goods_id, arr) { | |
1123 | + for (var i in arr) { | |
1124 | + if (arr[i].goods_id == goods_id) return arr[i]; | |
1125 | + } | |
1126 | + }, | |
1127 | + | |
1128 | + //跳转到购买卡 | |
1129 | + buycard: function () { | |
1130 | + getApp().goto("/pages/user/plus/plus"); | |
1131 | + getApp().globalData.plus_buy_back = 1; | |
1132 | + } | |
1134 | 1133 | |
1135 | 1134 | }); | ... | ... |
pages/cart/cart2_pt/cart2_pt.js
1 | -var t = getApp(),app=t, a = t.request, e = require("../../../utils/common.js"), | |
1 | +var t = getApp(), app = t, a = t.request, e = require("../../../utils/common.js"), | |
2 | 2 | s = require("../../../utils/util.js"), o = require("../../../utils/md5.js"), to = getApp(); |
3 | -var oo=t.globalData.setting,os=oo; | |
3 | +var oo = t.globalData.setting, os = oo; | |
4 | 4 | var regeneratorRuntime = require('../../../utils/runtime.js'); |
5 | 5 | var util_pay = require("../../../utils/pay.js"); |
6 | 6 | |
7 | 7 | Page({ |
8 | - data: { | |
9 | - url: t.globalData.setting.url, | |
10 | - resourceUrl: t.globalData.setting.resourceUrl, | |
11 | - imgUrl: t.globalData.setting.imghost, | |
12 | - goods: null, | |
13 | - order: null, | |
14 | - orderPrices: null, | |
15 | - coupons: null, | |
16 | - coupon: null, | |
17 | - invoiceToggle: !0, | |
18 | - payWithUserMoney: !0, | |
19 | - payWithPoints: !0, | |
20 | - maxWord: 0, | |
21 | - enterAddressPage: !1, | |
22 | - firstEnter: !0, | |
23 | - //页面获取的参数 | |
24 | - param:null, | |
25 | - postdata:null, | |
26 | - //提交订单的格式 | |
27 | - formData: { | |
28 | - order_amount:0,//支付金额 | |
29 | - total_amount:0,//总价 | |
30 | - all_price:0,//商品卖的总价 | |
31 | - pay_points: 0,//使用积分 | |
32 | - user_money: 0,//使用余额 | |
33 | - couponCode: "",//使用优惠券(多单就用逗号隔开) | |
34 | - shipping_price:0,//物流费用 | |
35 | - }, | |
36 | - | |
37 | - /*----------------立即购买---------------------*/ | |
38 | - is_b_now:0, //0是购物车结算 1立即购买 | |
39 | - bn_goods:null, //立即购买时候的调用商品 | |
40 | - bn_use_money:0,//是否使用余额 | |
41 | - bn_exp_type:1, //0是物流 1自提 | |
42 | - bn_pick:0, //选择的门店 | |
43 | - bn_pickname: "", //选择的门店名称 | |
44 | - bn_t_exp_t:0, //判断商品和门店一起决定的物流自提的方式0 都可以 1自提 2物流 | |
45 | - /*------------------------*/ | |
46 | - user_addr:null,//物流 | |
47 | - userinfo:null, //获取会员 | |
48 | - /*----------物流选择--------*/ | |
49 | - wu_arr:null, | |
50 | - index:0, | |
51 | - | |
52 | - //判断页面是返回回来的还是 首次进入的 | |
53 | - isclose:1, | |
54 | - kt_type:0, //开团类型 | |
55 | - is_pt_tz:0,//是否开团团长 | |
56 | - qh:'', //期号 | |
57 | - pt_listno:'',//期号 | |
58 | - is_normal:0, | |
59 | - is_express:0,//选择物流的控制器 | |
60 | - yuer:0, | |
61 | - | |
62 | - rank_switch:0, //是不是开同等级卡 | |
63 | - show_card:null, //显示的等级卡 | |
64 | - card_name:'', //显示的卡的名称 | |
65 | - card_cut_price:null,//减价多少钱 | |
8 | + data: { | |
9 | + url: t.globalData.setting.url, | |
10 | + resourceUrl: t.globalData.setting.resourceUrl, | |
11 | + imgUrl: t.globalData.setting.imghost, | |
12 | + goods: null, | |
13 | + order: null, | |
14 | + orderPrices: null, | |
15 | + coupons: null, | |
16 | + coupon: null, | |
17 | + invoiceToggle: !0, | |
18 | + payWithUserMoney: !0, | |
19 | + payWithPoints: !0, | |
20 | + maxWord: 0, | |
21 | + enterAddressPage: !1, | |
22 | + firstEnter: !0, | |
23 | + //页面获取的参数 | |
24 | + param: null, | |
25 | + postdata: null, | |
26 | + //提交订单的格式 | |
27 | + formData: { | |
28 | + order_amount: 0,//支付金额 | |
29 | + total_amount: 0,//总价 | |
30 | + all_price: 0,//商品卖的总价 | |
31 | + pay_points: 0,//使用积分 | |
32 | + user_money: 0,//使用余额 | |
33 | + couponCode: "",//使用优惠券(多单就用逗号隔开) | |
34 | + shipping_price: 0,//物流费用 | |
66 | 35 | }, |
67 | - onLoad: function(t) { | |
68 | - console.log("onLoad_pt_cart"); | |
69 | - var th = this; this.setData({ is_b_now: t.is_bnow == undefined ? 0 : t.is_bnow,}); | |
70 | - var appD=getApp().get_b_now(); | |
71 | - | |
72 | - th.data.postdata=appD; | |
73 | - //如果期号有值 | |
74 | - if(appD.qh){ | |
75 | - th.data.qh=appD.qh; | |
76 | - th.data.pt_listno=appD.qh; | |
77 | - } | |
78 | - //th.data.kt_type=appD.kt_type; | |
79 | - th.setData({kt_type:appD.kt_type}); | |
80 | - if(appD.is_pt_tz) th.data.is_pt_tz=appD.is_pt_tz; | |
81 | - th.data.param=t; | |
82 | - //先获取物流,再获取用户信息,再展示页面 | |
83 | - //th.get_wuliu(th.get_info(th.show_page)); | |
84 | - }, | |
85 | - onUnload: function () { this.setData({ isclose: 1 })}, | |
86 | 36 | |
87 | - //------获取会员信息-----先获取用户信息,在进行下一步--- | |
88 | - get_info:function(func){ | |
89 | - var user_id = t.globalData.user_id; | |
90 | - to.auth.get_u(func); | |
91 | - }, | |
37 | + /*----------------立即购买---------------------*/ | |
38 | + is_b_now: 0, //0是购物车结算 1立即购买 | |
39 | + bn_goods: null, //立即购买时候的调用商品 | |
40 | + bn_use_money: 0,//是否使用余额 | |
41 | + bn_exp_type: 1, //0是物流 1自提 | |
42 | + bn_pick: 0, //选择的门店 | |
43 | + bn_pickname: "", //选择的门店名称 | |
44 | + bn_t_exp_t: 0, //判断商品和门店一起决定的物流自提的方式0 都可以 1自提 2物流 | |
45 | + /*------------------------*/ | |
46 | + user_addr: null,//物流 | |
47 | + userinfo: null, //获取会员 | |
48 | + /*----------物流选择--------*/ | |
49 | + wu_arr: null, | |
50 | + index: 0, | |
51 | + | |
52 | + //判断页面是返回回来的还是 首次进入的 | |
53 | + isclose: 1, | |
54 | + kt_type: 0, //开团类型 | |
55 | + is_pt_tz: 0,//是否开团团长 | |
56 | + qh: '', //期号 | |
57 | + pt_listno: '',//期号 | |
58 | + is_normal: 0, | |
59 | + is_express: 0,//选择物流的控制器 | |
60 | + yuer: 0, | |
61 | + | |
62 | + rank_switch: 0, //是不是开同等级卡 | |
63 | + show_card: null, //显示的等级卡 | |
64 | + card_name: '', //显示的卡的名称 | |
65 | + card_cut_price: null,//减价多少钱 | |
66 | + }, | |
67 | + onLoad: function (t) { | |
68 | + console.log("onLoad_pt_cart"); | |
69 | + var th = this; this.setData({ is_b_now: t.is_bnow == undefined ? 0 : t.is_bnow, }); | |
70 | + var appD = getApp().get_b_now(); | |
71 | + | |
72 | + th.data.postdata = appD; | |
73 | + //如果期号有值 | |
74 | + if (appD.qh) { | |
75 | + th.data.qh = appD.qh; | |
76 | + th.data.pt_listno = appD.qh; | |
77 | + } | |
78 | + //th.data.kt_type=appD.kt_type; | |
79 | + th.setData({ kt_type: appD.kt_type }); | |
80 | + if (appD.is_pt_tz) th.data.is_pt_tz = appD.is_pt_tz; | |
81 | + th.data.param = t; | |
82 | + //先获取物流,再获取用户信息,再展示页面 | |
83 | + //th.get_wuliu(th.get_info(th.show_page)); | |
84 | + }, | |
85 | + onUnload: function () { this.setData({ isclose: 1 }) }, | |
92 | 86 | |
93 | - //-------------------获取物流--------------- | |
94 | - get_wuliu(func) { | |
95 | - var th = this; | |
96 | - console.log("getwuliu4545"); | |
97 | - to.getwuliu(function (e) { | |
98 | - if (th.data.is_default_logistics) { | |
99 | - //如果第一个不是开启默认,说明要让用户自己选 | |
100 | - if (!e[0].is_default) { | |
101 | - th.setData({ is_default_logistics: 0 }); | |
102 | - } | |
87 | + //------获取会员信息-----先获取用户信息,在进行下一步--- | |
88 | + get_info: function (func) { | |
89 | + var user_id = t.globalData.user_id; | |
90 | + to.auth.get_u(func); | |
91 | + }, | |
92 | + | |
93 | + //-------------------获取物流--------------- | |
94 | + get_wuliu(func) { | |
95 | + var th = this; | |
96 | + console.log("getwuliu4545"); | |
97 | + to.getwuliu(function (e) { | |
98 | + if (th.data.is_default_logistics) { | |
99 | + //如果第一个不是开启默认,说明要让用户自己选 | |
100 | + if (!e[0].is_default) { | |
101 | + th.setData({ is_default_logistics: 0 }); | |
103 | 102 | } |
104 | - th.setData({ wu_arr: e }) | |
105 | - typeof func == "function" && func(); | |
106 | - }) | |
107 | - }, | |
103 | + } | |
104 | + th.setData({ wu_arr: e }) | |
105 | + typeof func == "function" && func(); | |
106 | + }) | |
107 | + }, | |
108 | 108 | |
109 | - //------获取会员收货地址----- | |
110 | - getuser_addr:function(func){ | |
111 | - if (to.globalData.baddr!=null){ | |
112 | - var user_addr = to.globalData.baddr; | |
113 | - to.globalData.baddr=null; | |
114 | - func(user_addr); | |
115 | - }else{ | |
116 | - a.get("/api/weshop/useraddress/page", { | |
117 | - data: { user_id: to.globalData.user_id, store_id: oo.stoid, pageSize: 600 }, | |
109 | + //------获取会员收货地址----- | |
110 | + getuser_addr: function (func) { | |
111 | + if (to.globalData.baddr != null) { | |
112 | + var user_addr = to.globalData.baddr; | |
113 | + to.globalData.baddr = null; | |
114 | + func(user_addr); | |
115 | + } else { | |
116 | + a.get("/api/weshop/useraddress/page", { | |
117 | + data: { user_id: to.globalData.user_id, store_id: oo.stoid, pageSize: 600 }, | |
118 | + success: function (su) { | |
119 | + | |
120 | + var user_addr = su.data.data.pageData; | |
121 | + var item = null; | |
122 | + var def_item = null; | |
123 | + for (var i = 0; i < user_addr.length; i++) { | |
124 | + if (user_addr[i]['is_default'] == 1) { def_item = user_addr[i]; } | |
125 | + if (user_addr[i]['is_pickup'] == 1) { item = user_addr[i]; } | |
126 | + } | |
127 | + if (item == null) item = def_item; | |
128 | + if (item == null) item = user_addr[0]; | |
129 | + if (item == undefined) item = null; | |
130 | + func(item); | |
131 | + } | |
132 | + }); | |
133 | + } | |
134 | + }, | |
135 | + //----------------展示页面,是再获取用户信息之后-------------- | |
136 | + show_page: function () { | |
137 | + var th = this; | |
138 | + //th.setData({ userinfo: to.globalData.userInfo}); 会员信息要时时获取 | |
139 | + var user = getApp().globalData.userInfo; | |
140 | + getApp().request.get("/api/weshop/users/get/" + oo.stoid + "/" + user.user_id, { | |
141 | + data: { r: Math.random() }, | |
142 | + success: function (e) { | |
143 | + | |
144 | + getApp().globalData.userInfo = e.data.data; | |
145 | + th.setData({ userinfo: e.data.data }); | |
146 | + //获取立即购买的商品信息 | |
147 | + th.get_buy_goods(); | |
148 | + | |
149 | + //获取提现金额 | |
150 | + getApp().request.get("/api/weshop/withdrawals/summoney", { | |
151 | + data: { user_id: to.globalData.user_id, store_id: oo.stoid, status: 0 }, | |
118 | 152 | success: function (su) { |
119 | - | |
120 | - var user_addr = su.data.data.pageData; | |
121 | - var item = null; | |
122 | - var def_item=null; | |
123 | - for (var i = 0; i < user_addr.length; i++) { | |
124 | - if (user_addr[i]['is_default'] == 1) { def_item = user_addr[i]; } | |
125 | - if (user_addr[i]['is_pickup'] == 1) { item = user_addr[i]; } | |
153 | + if (su.data.code == 0) { | |
154 | + var yuer = parseFloat(th.data.userinfo.user_money - | |
155 | + (th.data.userinfo.frozen_money > 0 ? th.data.userinfo.frozen_money : 0) - su.data.data.summoney).toFixed(2); | |
156 | + if (yuer < 0) yuer = 0; | |
157 | + th.setData({ txmon: su.data.data.summoney, yuer: yuer }); | |
126 | 158 | } |
127 | - if (item == null) item = def_item; | |
128 | - if (item == null) item = user_addr[0]; | |
129 | - if (item == undefined) item = null; | |
130 | - func(item); | |
131 | 159 | } |
132 | 160 | }); |
133 | 161 | } |
134 | - }, | |
135 | - //----------------展示页面,是再获取用户信息之后-------------- | |
136 | - show_page:function(){ | |
137 | - var th=this; | |
138 | - //th.setData({ userinfo: to.globalData.userInfo}); 会员信息要时时获取 | |
139 | - var user=getApp().globalData.userInfo; | |
140 | - getApp().request.get("/api/weshop/users/get/" + oo.stoid + "/" + user.user_id, { | |
141 | - data:{r:Math.random()}, | |
142 | - success: function (e) { | |
143 | - | |
144 | - getApp().globalData.userInfo = e.data.data; | |
145 | - th.setData({userinfo:e.data.data}); | |
146 | - //获取立即购买的商品信息 | |
147 | - th.get_buy_goods(); | |
148 | - | |
149 | - //获取提现金额 | |
150 | - getApp().request.get("/api/weshop/withdrawals/summoney", { | |
151 | - data: { user_id: to.globalData.user_id, store_id: oo.stoid, status: 0 }, | |
152 | - success: function (su) { | |
153 | - if (su.data.code == 0) { | |
154 | - var yuer = parseFloat(th.data.userinfo.user_money - | |
155 | - (th.data.userinfo.frozen_money>0?th.data.userinfo.frozen_money:0) - su.data.data.summoney).toFixed(2); | |
156 | - if(yuer<0) yuer=0; | |
157 | - th.setData({ txmon: su.data.data.summoney, yuer: yuer }); | |
158 | - } | |
159 | - } | |
160 | - }); | |
161 | - } | |
162 | - }); | |
163 | - }, | |
162 | + }); | |
163 | + }, | |
164 | 164 | |
165 | - //-----获取立即购买的商品信息---- | |
166 | - get_buy_goods: function (){ | |
167 | - var th=this,a=getApp().request; | |
168 | - var gg = th.data.postdata; | |
169 | - //调用商品 | |
170 | - a.get("/api/weshop/goods/get/" + oo.stoid+"/"+gg.goods_id, { | |
171 | - success: function (t) { | |
172 | - var gd = t.data.data; | |
173 | - if(!gd) return false; | |
174 | - | |
175 | - t.data.data.original_img = oo.imghost + t.data.data.original_img; | |
176 | - t.data.data['buynum'] = gg.goods_num; | |
177 | - console.log(t.data.data); | |
178 | - var distr_t = 0, et = 0 | |
179 | - if (t.data.data.distr_type == 0) { | |
180 | - distr_t = gg.pick_dis; | |
181 | - } else { | |
182 | - distr_t = t.data.data.distr_type; | |
183 | - } | |
184 | - switch (distr_t) { | |
185 | - case 0: | |
186 | - et = 1; | |
187 | - //-- 系统后台有设置要默认的 -- | |
188 | - if(th.data.json_d.pickupway && th.data.json_d.pickupway==1) et=0; | |
189 | - break; | |
190 | - case 1: | |
191 | - et = 1; | |
192 | - break; | |
193 | - case 2: | |
194 | - et = 0; | |
195 | - break; | |
196 | - } | |
197 | - | |
198 | - t.data.data.shop_price=gg.goods_price; | |
199 | - //--如果是普通购买的时候-- | |
200 | - if(gg.is_normal==1){ | |
201 | - t.data.data.prom_id = 0; | |
202 | - t.data.data.prom_type = 0; | |
203 | - t.data.data.is_normal=1; | |
204 | - | |
205 | - var gd=t.data.data; | |
206 | - //-- 用商品的手店价来显示 -- | |
207 | - gg.goods_price=gd.shop_price; | |
208 | - //---是不是购买等级卡成功的返回---等级卡显示的判断--- | |
209 | - var is_card_back=getApp().globalData.is_card_back; | |
210 | - if(is_card_back){ | |
211 | - gg.goods_price=gd[th.data.card_name]; | |
212 | - t.data.data.shop_price=gg.goods_price; | |
213 | - getApp().globalData.is_card_back=0; | |
214 | - th.setData({card_cut_price:0}); | |
215 | - }else{ | |
216 | - //--- 商品不能是搭配购,商家等级卡开通的情况下, 会员不是等级会员的情况, 商品有设置等级卡价格,同时等级卡价格小于商品的价格 | |
217 | - if(th.data.card_name && gd[th.data.card_name]>0 && gg.goods_price>gd[th.data.card_name] && !th.data.userinfo.card_field){ | |
218 | - var cut_p= gg.goods_price-gd[th.data.card_name]; | |
219 | - th.setData({card_cut_price:cut_p}); | |
220 | - } | |
221 | - } | |
222 | - | |
223 | - if(th.data.bn_goods){ | |
224 | - et=th.data.bn_exp_type; | |
225 | - } | |
226 | - | |
227 | - | |
228 | - th.setData({ | |
229 | - bn_goods: t.data.data, bn_pickname: gg.pick_name, | |
230 | - bn_pick: gg.pick_id, bn_t_exp_t: distr_t, is_normal:1,bn_exp_type:et | |
231 | - }); | |
232 | - | |
233 | - | |
234 | - | |
235 | - th.calculatePrice2(); | |
236 | - }else{ | |
237 | - | |
238 | - //--阶梯团很特殊,不能用总表来拿价格-- | |
239 | - getApp().request.get("/api/weshop/teamlist/get/"+oo.stoid+"/"+gd.prom_id, { | |
240 | - success: function (tt) { | |
241 | - | |
242 | - if (tt.data.code == 0) { | |
243 | - var pt_data=tt.data.data; | |
244 | - var now=s.gettimestamp(); | |
245 | - | |
246 | - if(pt_data.is_end==1){ | |
247 | - t.data.data.prom_id = 0; | |
248 | - t.data.data.prom_type = 0; | |
249 | - t.data.data.is_normal=1; | |
250 | - }else if(now>pt_data.end_time){ | |
251 | - t.data.data.prom_id = 0; | |
252 | - t.data.data.prom_type = 0; | |
253 | - t.data.data.is_normal=1; | |
254 | - }else{ | |
255 | - t.data.data.shop_price = tt.data.data.price; //活动价格 | |
256 | - t.data.data.is_normal=0; | |
257 | - if(pt_data.kttype==3){ | |
258 | - t.data.data.shop_price = tt.data.data.yf_price; //用定金来购买 | |
259 | - } | |
260 | - } | |
261 | - } else { | |
262 | - t.data.data.prom_id = 0; | |
263 | - t.data.data.prom_type = 0; | |
264 | - t.data.data.is_normal=1; | |
265 | - } | |
266 | - | |
267 | - if(th.data.bn_goods){ | |
268 | - et=th.data.bn_exp_type; | |
269 | - } | |
270 | - | |
271 | - th.setData({ | |
272 | - bn_goods: t.data.data, bn_pickname: gg.pick_name, | |
273 | - bn_pick: gg.pick_id, bn_t_exp_t: distr_t,bn_exp_type:et | |
274 | - }); | |
275 | - | |
276 | - | |
277 | - //计算价格 | |
278 | - th.calculatePrice2(); | |
279 | - } | |
280 | - }); | |
281 | - } | |
282 | - } | |
283 | - }); | |
284 | - }, | |
165 | + //-----获取立即购买的商品信息---- | |
166 | + get_buy_goods: function () { | |
167 | + var th = this, a = getApp().request; | |
168 | + var gg = th.data.postdata; | |
169 | + //调用商品 | |
170 | + a.get("/api/weshop/goods/get/" + oo.stoid + "/" + gg.goods_id, { | |
171 | + success: function (t) { | |
172 | + var gd = t.data.data; | |
173 | + if (!gd) return false; | |
174 | + | |
175 | + t.data.data.original_img = oo.imghost + t.data.data.original_img; | |
176 | + t.data.data['buynum'] = gg.goods_num; | |
177 | + console.log(t.data.data); | |
178 | + var distr_t = 0, et = 0 | |
179 | + if (t.data.data.distr_type == 0) { | |
180 | + distr_t = gg.pick_dis; | |
181 | + } else { | |
182 | + distr_t = t.data.data.distr_type; | |
183 | + } | |
184 | + switch (distr_t) { | |
185 | + case 0: | |
186 | + et = 1; | |
187 | + //-- 系统后台有设置要默认的 -- | |
188 | + if (th.data.json_d.pickupway && th.data.json_d.pickupway == 1) et = 0; | |
189 | + break; | |
190 | + case 1: | |
191 | + et = 1; | |
192 | + break; | |
193 | + case 2: | |
194 | + et = 0; | |
195 | + break; | |
196 | + } | |
285 | 197 | |
286 | - //----------子页返回父页触发---------- | |
287 | - onShow: function () { | |
288 | - var th = this; | |
289 | - if (th.data.isclose == 0) { | |
290 | - wx.navigateTo({ | |
291 | - url: "/pages/index/index/index" | |
292 | - }) | |
293 | - } else { | |
294 | - this.getuser_addr(function (ie) { | |
295 | - //更换地址回来要重新调用计算价钱的接口 | |
296 | - th.setData({ user_addr: ie }); | |
297 | - if (!th.data.user_addr || th.data.user_addr.address_id != ie.address_id) { | |
298 | - th.setData({ add_back: 1 }); | |
299 | - if (th.data.bn_goods) th.calculatePrice2(); | |
198 | + t.data.data.shop_price = gg.goods_price; | |
199 | + //--如果是普通购买的时候-- | |
200 | + if (gg.is_normal == 1) { | |
201 | + t.data.data.prom_id = 0; | |
202 | + t.data.data.prom_type = 0; | |
203 | + t.data.data.is_normal = 1; | |
204 | + | |
205 | + var gd = t.data.data; | |
206 | + //-- 用商品的手店价来显示 -- | |
207 | + gg.goods_price = gd.shop_price; | |
208 | + //---是不是购买等级卡成功的返回---等级卡显示的判断--- | |
209 | + var is_card_back = getApp().globalData.is_card_back; | |
210 | + if (is_card_back) { | |
211 | + gg.goods_price = gd[th.data.card_name]; | |
212 | + t.data.data.shop_price = gg.goods_price; | |
213 | + getApp().globalData.is_card_back = 0; | |
214 | + th.setData({ card_cut_price: 0 }); | |
215 | + } else { | |
216 | + //--- 商品不能是搭配购,商家等级卡开通的情况下, 会员不是等级会员的情况, 商品有设置等级卡价格,同时等级卡价格小于商品的价格 | |
217 | + if (th.data.card_name && gd[th.data.card_name] > 0 && gg.goods_price > gd[th.data.card_name] && !th.data.userinfo.card_field) { | |
218 | + var cut_p = gg.goods_price - gd[th.data.card_name]; | |
219 | + th.setData({ card_cut_price: cut_p }); | |
220 | + } | |
300 | 221 | } |
301 | - }) | |
302 | - //--更新默认地址--,看一下是不是跳到地址页面 | |
303 | - if (!getApp().globalData.is_cart_old) { | |
304 | - this.update_code(); | |
222 | + | |
223 | + if (th.data.bn_goods) { | |
224 | + et = th.data.bn_exp_type; | |
225 | + } | |
226 | + | |
227 | + | |
228 | + th.setData({ | |
229 | + bn_goods: t.data.data, bn_pickname: gg.pick_name, | |
230 | + bn_pick: gg.pick_id, bn_t_exp_t: distr_t, is_normal: 1, bn_exp_type: et | |
231 | + }); | |
232 | + | |
233 | + | |
234 | + | |
235 | + th.calculatePrice2(); | |
305 | 236 | } else { |
306 | - getApp().globalData.is_cart_old = 0; | |
237 | + | |
238 | + //--阶梯团很特殊,不能用总表来拿价格-- | |
239 | + getApp().request.get("/api/weshop/teamlist/get/" + oo.stoid + "/" + gd.prom_id, { | |
240 | + success: function (tt) { | |
241 | + | |
242 | + if (tt.data.code == 0) { | |
243 | + var pt_data = tt.data.data; | |
244 | + var now = s.gettimestamp(); | |
245 | + | |
246 | + if (pt_data.is_end == 1) { | |
247 | + t.data.data.prom_id = 0; | |
248 | + t.data.data.prom_type = 0; | |
249 | + t.data.data.is_normal = 1; | |
250 | + } else if (now > pt_data.end_time) { | |
251 | + t.data.data.prom_id = 0; | |
252 | + t.data.data.prom_type = 0; | |
253 | + t.data.data.is_normal = 1; | |
254 | + } else { | |
255 | + t.data.data.shop_price = tt.data.data.price; //活动价格 | |
256 | + t.data.data.is_normal = 0; | |
257 | + if (pt_data.kttype == 3) { | |
258 | + t.data.data.shop_price = tt.data.data.yf_price; //用定金来购买 | |
259 | + } | |
260 | + } | |
261 | + } else { | |
262 | + t.data.data.prom_id = 0; | |
263 | + t.data.data.prom_type = 0; | |
264 | + t.data.data.is_normal = 1; | |
265 | + } | |
266 | + | |
267 | + if (th.data.bn_goods) { | |
268 | + et = th.data.bn_exp_type; | |
269 | + } | |
270 | + | |
271 | + th.setData({ | |
272 | + bn_goods: t.data.data, bn_pickname: gg.pick_name, | |
273 | + bn_pick: gg.pick_id, bn_t_exp_t: distr_t, bn_exp_type: et | |
274 | + }); | |
275 | + | |
276 | + | |
277 | + //计算价格 | |
278 | + th.calculatePrice2(); | |
279 | + } | |
280 | + }); | |
281 | + } | |
282 | + } | |
283 | + }); | |
284 | + }, | |
285 | + | |
286 | + //----------子页返回父页触发---------- | |
287 | + onShow: function () { | |
288 | + var th = this; | |
289 | + if (th.data.isclose == 0) { | |
290 | + wx.navigateTo({ | |
291 | + url: "/pages/index/index/index" | |
292 | + }) | |
293 | + } else { | |
294 | + this.getuser_addr(function (ie) { | |
295 | + //更换地址回来要重新调用计算价钱的接口 | |
296 | + th.setData({ user_addr: ie }); | |
297 | + if (!th.data.user_addr || th.data.user_addr.address_id != ie.address_id) { | |
298 | + th.setData({ add_back: 1 }); | |
299 | + if (th.data.bn_goods) th.calculatePrice2(); | |
307 | 300 | } |
301 | + }) | |
302 | + //--更新默认地址--,看一下是不是跳到地址页面 | |
303 | + if (!getApp().globalData.is_cart_old) { | |
304 | + this.update_code(); | |
305 | + } else { | |
306 | + getApp().globalData.is_cart_old = 0; | |
308 | 307 | } |
308 | + } | |
309 | 309 | |
310 | 310 | |
311 | - //先获取是否有关闭使用优惠券 | |
312 | - getApp().getConfig2(function (ee) { | |
313 | - var json_d = JSON.parse(ee.switch_list); | |
314 | - th.data.json_d = json_d; | |
315 | - th.data.ispt_goods = json_d.ispt_goods; //是不是平摊到单品的控制参数赋值 | |
316 | - var is_default_logistics = json_d.is_default_logistics; | |
317 | - | |
318 | - th.setData({ is_close_quan: json_d.is_close_quan, sales_rules: ee.sales_rules, rank_switch: json_d.rank_switch, is_default_logistics: is_default_logistics }); | |
319 | - | |
320 | - var rank_switch = json_d.rank_switch; | |
321 | - var max_price = -1; | |
322 | - var show_card = null; | |
323 | - var name = ""; | |
324 | - //如果有开等级卡的时候, | |
325 | - //因为都是调接口,要返回在计算 | |
326 | - if (rank_switch == 2) { | |
327 | - //-- 获取所有的等级卡, -- | |
328 | - getApp().request.promiseGet("/api/weshop/plus/vip/mem/bership/list?storeId=" + os.stoid, | |
329 | - {}).then(res => { | |
330 | - if (res.data.code == 0) { | |
331 | - var plusCard = res.data.data; | |
332 | - //-- 循环判断,拿到最贵的那张卡 -- | |
333 | - for (var ih in plusCard) { | |
334 | - if (plusCard[ih].IsStopBuy == true) { continue; } | |
335 | - if (max_price < 0) { | |
311 | + //先获取是否有关闭使用优惠券 | |
312 | + getApp().getConfig2(function (ee) { | |
313 | + var json_d = JSON.parse(ee.switch_list); | |
314 | + th.data.json_d = json_d; | |
315 | + th.data.ispt_goods = json_d.ispt_goods; //是不是平摊到单品的控制参数赋值 | |
316 | + var is_default_logistics = json_d.is_default_logistics; | |
317 | + | |
318 | + th.setData({ is_close_quan: json_d.is_close_quan, sales_rules: ee.sales_rules, rank_switch: json_d.rank_switch, is_default_logistics: is_default_logistics }); | |
319 | + | |
320 | + var rank_switch = json_d.rank_switch; | |
321 | + var max_price = -1; | |
322 | + var show_card = null; | |
323 | + var name = ""; | |
324 | + //如果有开等级卡的时候, | |
325 | + //因为都是调接口,要返回在计算 | |
326 | + if (rank_switch == 2) { | |
327 | + //-- 获取所有的等级卡, -- | |
328 | + getApp().request.promiseGet("/api/weshop/plus/vip/mem/bership/list?storeId=" + os.stoid, | |
329 | + {}).then(res => { | |
330 | + if (res.data.code == 0) { | |
331 | + var plusCard = res.data.data; | |
332 | + //-- 循环判断,拿到最贵的那张卡 -- | |
333 | + for (var ih in plusCard) { | |
334 | + if (plusCard[ih].IsStopBuy == true) { continue; } | |
335 | + if (max_price < 0) { | |
336 | + max_price = plusCard[ih].CardFee; | |
337 | + name = 'card' + plusCard[ih]['CorrPrice']; | |
338 | + show_card = plusCard[ih]; | |
339 | + } else { | |
340 | + if (max_price < plusCard[ih].CardFee) { | |
336 | 341 | max_price = plusCard[ih].CardFee; |
337 | 342 | name = 'card' + plusCard[ih]['CorrPrice']; |
338 | 343 | show_card = plusCard[ih]; |
339 | - } else { | |
340 | - if (max_price < plusCard[ih].CardFee) { | |
341 | - max_price = plusCard[ih].CardFee; | |
342 | - name = 'card' + plusCard[ih]['CorrPrice']; | |
343 | - show_card = plusCard[ih]; | |
344 | - } | |
345 | 344 | } |
346 | 345 | } |
346 | + } | |
347 | 347 | |
348 | - if (show_card) { | |
349 | - name = name.toLowerCase(); | |
350 | - th.setData({ card_name: name, show_card: show_card }) | |
351 | - } | |
348 | + if (show_card) { | |
349 | + name = name.toLowerCase(); | |
350 | + th.setData({ card_name: name, show_card: show_card }) | |
352 | 351 | } |
353 | - //-----先获取物流,再获取用户信息,再展示页面----- | |
354 | - th.get_wuliu(th.get_info(th.show_page)); | |
355 | - }) | |
352 | + } | |
353 | + //-----先获取物流,再获取用户信息,再展示页面----- | |
354 | + th.get_wuliu(th.get_info(th.show_page)); | |
355 | + }) | |
356 | + } else { | |
357 | + //-----先获取物流,再获取用户信息,再展示页面----- | |
358 | + th.get_wuliu(th.get_info(th.show_page)); | |
359 | + } | |
360 | + }, 1) | |
361 | + | |
362 | + }, | |
363 | + //---------------检查是否有收货地址------------------- | |
364 | + checkAddressList: function () { | |
365 | + var t = this; | |
366 | + return !(!this.data.order || null == this.data.order.userAddress) || (wx.showModal({ | |
367 | + title: "请先填写或选择收货地址~", | |
368 | + success: function (a) { | |
369 | + a.confirm ? t.enterAddressPage() : wx.navigateBack(); | |
370 | + }, | |
371 | + fail: function () { | |
372 | + wx.navigateBack(); | |
373 | + } | |
374 | + }), !1); | |
375 | + }, | |
376 | + showInvoice: function () { | |
377 | + this.setData({ | |
378 | + invoiceToggle: !this.data.invoiceToggle | |
379 | + }); | |
380 | + }, | |
381 | + keyUpChangePay1: function (t) { | |
382 | + this.setData({ | |
383 | + payWithUserMoney: !(t.detail.value.length > 0) | |
384 | + }); | |
385 | + }, | |
386 | + keyUpChangePay2: function (t) { | |
387 | + this.setData({ | |
388 | + payWithPoints: !(t.detail.value.length > 0) | |
389 | + }); | |
390 | + }, | |
391 | + keyUpChangeNum: function (t) { | |
392 | + this.setData({ | |
393 | + maxWord: t.detail.value.length | |
394 | + }); | |
395 | + }, | |
396 | + //---------计算立即购买---------- | |
397 | + calculatePrice2: function () { | |
398 | + var th = this, good = this.data.bn_goods; | |
399 | + //-----------计算商品总价-------------- | |
400 | + var allpice = good.shop_price * good.buynum; | |
401 | + allpice = parseFloat(allpice).toFixed(2); | |
402 | + var txt = "formData.all_price"; | |
403 | + th.setData({ [txt]: allpice, }); | |
404 | + console.log(th.data.formData); | |
405 | + | |
406 | + to.getConfig2(function (ee) { | |
407 | + to.getwuliuprice(function (rs) { | |
408 | + console.log('calculatePrice2222'); | |
409 | + console.log(rs); | |
410 | + var o_shipping_price = 0, goods_weight = -1, goods_piece = -1; | |
411 | + var out_of_weight = null; //超出多少重量 | |
412 | + var freight_free = ee.freight_free; //全场满多少包邮 | |
413 | + var weight_free = ee.weight_free; //多少kg内包邮 | |
414 | + //-----------当地址不为空,且是物流时,计算物流费用,同时阶梯团不计算拼团价格---------- | |
415 | + if (th.data.user_addr != null && th.data.bn_exp_type == 0 && good.is_free_shipping == 0 && (th.data.kt_type != 3 || th.data.bn_goods.is_normal == 1)) { | |
416 | + switch (good['exp_sum_type']) { | |
417 | + case 1: | |
418 | + //统一运费 | |
419 | + o_shipping_price += good['uniform_exp_sum']; break; | |
420 | + case 2: | |
421 | + if (goods_weight < 0) goods_weight = 0; | |
422 | + //累积商品重量 每种商品的重量 * 数量 | |
423 | + goods_weight += good['weight'] * good['buynum']; | |
424 | + if (weight_free > 0) { | |
425 | + out_of_weight = (weight_free * 1000) - goods_weight; | |
426 | + } | |
427 | + break; | |
428 | + case 3: | |
429 | + if (goods_piece < 0) goods_piece = 0; | |
430 | + //累积商品数量 | |
431 | + goods_piece += good['buynum']; break; | |
432 | + } | |
433 | + | |
434 | + console.log(o_shipping_price + ":" + goods_weight + ":" + goods_piece); | |
435 | + console.log(th.data.wu_arr); | |
436 | + var code = th.data.wu_arr[th.data.index].code; | |
437 | + var freight_free = ee.freight_free; //全场满多少包邮 | |
438 | + var shipping_price = | |
439 | + th.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, | |
440 | + goods_piece, th.data.user_addr, freight_free, allpice, rs); | |
441 | + | |
442 | + shipping_price = parseFloat(shipping_price).toFixed(2); | |
443 | + var wl_txt = "formData.shipping_price"; | |
444 | + th.setData({ [wl_txt]: shipping_price, }) | |
445 | + | |
356 | 446 | } else { |
357 | - //-----先获取物流,再获取用户信息,再展示页面----- | |
358 | - th.get_wuliu(th.get_info(th.show_page)); | |
447 | + var wl_txt = "formData.shipping_price"; | |
448 | + th.setData({ [wl_txt]: 0, }) | |
449 | + } | |
450 | + //-----------------总价----------------- | |
451 | + var total_m = parseFloat(allpice) + parseFloat(th.data.formData.shipping_price); | |
452 | + total_m = parseFloat(total_m).toFixed(2); | |
453 | + | |
454 | + var atxt = "formData.total_amount"; | |
455 | + th.setData({ [atxt]: total_m, }) | |
456 | + var order_m = total_m; | |
457 | + | |
458 | + var txt = "formData.user_money"; | |
459 | + var txt2 = "formData.order_amount"; | |
460 | + //--------------如果使用余额--------------------- | |
461 | + if (th.data.bn_use_money == 1 && th.data.yuer > 0) { | |
462 | + if (parseFloat(th.data.yuer) > total_m) { | |
463 | + th.setData({ [txt]: total_m, [txt2]: 0 }) | |
464 | + } else { | |
465 | + order_m = parseFloat(order_m) - parseFloat(th.data.yuer); | |
466 | + order_m = order_m.toFixed(2); | |
467 | + th.setData({ [txt]: th.data.yuer, [txt2]: order_m }) | |
468 | + } | |
469 | + } else { | |
470 | + th.setData({ [txt]: 0, [txt2]: order_m }) | |
359 | 471 | } |
360 | - }, 1) | |
361 | - | |
362 | - }, | |
363 | - //---------------检查是否有收货地址------------------- | |
364 | - checkAddressList: function() { | |
365 | - var t = this; | |
366 | - return !(!this.data.order || null == this.data.order.userAddress) || (wx.showModal({ | |
367 | - title: "请先填写或选择收货地址~", | |
368 | - success: function(a) { | |
369 | - a.confirm ? t.enterAddressPage() : wx.navigateBack(); | |
370 | - }, | |
371 | - fail: function() { | |
372 | - wx.navigateBack(); | |
373 | - } | |
374 | - }), !1); | |
375 | - }, | |
376 | - showInvoice: function() { | |
377 | - this.setData({ | |
378 | - invoiceToggle: !this.data.invoiceToggle | |
379 | - }); | |
380 | - }, | |
381 | - keyUpChangePay1: function(t) { | |
382 | - this.setData({ | |
383 | - payWithUserMoney: !(t.detail.value.length > 0) | |
384 | - }); | |
385 | - }, | |
386 | - keyUpChangePay2: function(t) { | |
387 | - this.setData({ | |
388 | - payWithPoints: !(t.detail.value.length > 0) | |
389 | - }); | |
390 | - }, | |
391 | - keyUpChangeNum: function(t) { | |
392 | - this.setData({ | |
393 | - maxWord: t.detail.value.length | |
394 | - }); | |
395 | - }, | |
396 | - //---------计算立即购买---------- | |
397 | - calculatePrice2: function () { | |
398 | - var th = this, good = this.data.bn_goods; | |
399 | - //-----------计算商品总价-------------- | |
400 | - var allpice = good.shop_price * good.buynum; | |
401 | - allpice=parseFloat(allpice).toFixed(2); | |
402 | - var txt = "formData.all_price"; | |
403 | - th.setData({ [txt]: allpice, }); | |
404 | - console.log(th.data.formData); | |
405 | - | |
406 | - to.getConfig2(function (ee) { | |
407 | - to.getwuliuprice(function (rs) { | |
408 | - console.log('calculatePrice2222'); | |
409 | - console.log(rs); | |
410 | - var o_shipping_price = 0,goods_weight = -1,goods_piece = -1; | |
411 | - var out_of_weight=null; //超出多少重量 | |
412 | - var freight_free = ee.freight_free; //全场满多少包邮 | |
413 | - var weight_free = ee.weight_free; //多少kg内包邮 | |
414 | - //-----------当地址不为空,且是物流时,计算物流费用,同时阶梯团不计算拼团价格---------- | |
415 | - if (th.data.user_addr != null && th.data.bn_exp_type == 0 && good.is_free_shipping == 0 && (th.data.kt_type!=3 || th.data.bn_goods.is_normal==1) ){ | |
416 | - switch (good['exp_sum_type']) { | |
417 | - case 1: | |
418 | - //统一运费 | |
419 | - o_shipping_price += good['uniform_exp_sum']; break; | |
420 | - case 2: | |
421 | - if (goods_weight < 0) goods_weight = 0; | |
422 | - //累积商品重量 每种商品的重量 * 数量 | |
423 | - goods_weight += good['weight'] * good['buynum']; | |
424 | - if(weight_free > 0){ | |
425 | - out_of_weight = (weight_free * 1000 ) - goods_weight; | |
426 | - } | |
427 | - break; | |
428 | - // goods_weight += good['weight'] * good['buynum'];break; | |
429 | - case 3: | |
430 | - if (goods_piece < 0) goods_piece = 0; | |
431 | - //累积商品数量 | |
432 | - goods_piece += good['buynum']; break; | |
433 | - } | |
434 | - | |
435 | - console.log(o_shipping_price + ":" + goods_weight + ":" + goods_piece); | |
436 | - console.log(th.data.wu_arr); | |
437 | - var code = th.data.wu_arr[th.data.index].code; | |
438 | - var freight_free = ee.freight_free; //全场满多少包邮 | |
439 | - var shipping_price= | |
440 | - th.calculatewuliu(code, o_shipping_price, goods_weight,out_of_weight, | |
441 | - goods_piece, th.data.user_addr, freight_free, allpice, rs); | |
442 | - | |
443 | - shipping_price = parseFloat(shipping_price).toFixed(2); | |
444 | - var wl_txt = "formData.shipping_price"; | |
445 | - th.setData({ [wl_txt]: shipping_price, }) | |
446 | - | |
447 | - }else{ | |
448 | - var wl_txt = "formData.shipping_price"; | |
449 | - th.setData({ [wl_txt]: 0, }) | |
450 | - } | |
451 | - //-----------------总价----------------- | |
452 | - var total_m = parseFloat(allpice) + parseFloat( th.data.formData.shipping_price); | |
453 | - total_m = parseFloat(total_m).toFixed(2); | |
454 | - | |
455 | - var atxt= "formData.total_amount"; | |
456 | - th.setData({ [atxt]: total_m, }) | |
457 | - var order_m = total_m; | |
458 | - | |
459 | - var txt = "formData.user_money"; | |
460 | - var txt2 = "formData.order_amount"; | |
461 | - //--------------如果使用余额--------------------- | |
462 | - if (th.data.bn_use_money == 1 && th.data.yuer>0) { | |
463 | - if ( parseFloat(th.data.yuer) > total_m) { | |
464 | - th.setData({ [txt]: total_m, [txt2]:0 }) | |
465 | - }else{ | |
466 | - order_m = parseFloat(order_m) - parseFloat(th.data.yuer); | |
467 | - order_m = order_m.toFixed(2); | |
468 | - th.setData({ [txt]: th.data.yuer, [txt2]: order_m }) | |
469 | - } | |
470 | - }else{ | |
471 | - th.setData({ [txt]: 0, [txt2]: order_m }) | |
472 | - } | |
473 | 472 | |
474 | - }); | |
475 | 473 | }); |
476 | - }, | |
477 | - //--------------------提交订单----------------------- | |
478 | - submitForm: async function(t){ | |
479 | - if(this.data.is_summit_ing==1) return false; //--提交中退出-- | |
480 | - this.data.is_summit_ing=1; | |
481 | - | |
482 | - var th=this,pdata=new Array(); | |
483 | - var ff=true; | |
484 | - //------------立即购买------------- | |
485 | - console.log("buy_new"); | |
486 | - | |
487 | - //如果不是阶梯团,或者是普通购买,商家选择了物流,以及地址为空的时候 | |
488 | - if(th.data.bn_exp_type == 0 && th.data.user_addr==null && (th.data.kt_type!=3 || th.data.bn_goods.is_normal==1) ){ | |
489 | - ff = false; | |
490 | - getApp().my_warnning("请选择收货地址",0,this); | |
491 | - this.data.is_summit_ing = 0; | |
492 | - } | |
493 | - if (!ff) return false; | |
494 | - var addr = th.data.user_addr; | |
495 | - if (th.data.bn_exp_type == 1) addr=null; | |
496 | - | |
497 | - console.log(th.data.formData); | |
498 | - console.log(th.data.wu_arr); | |
499 | - console.log(th.data.bn_exp_type); | |
500 | - | |
501 | - if(th.data.bn_exp_type==0 && (th.data.kt_type!=3 || th.data.bn_goods.is_normal==1)) { | |
502 | - if (th.data.wu_arr == null || th.data.wu_arr.length <= 0) { | |
503 | - getApp().my_warnning("读取物流失败",0,this); | |
504 | - this.data.is_summit_ing = 0; | |
505 | - return false; | |
474 | + }); | |
475 | + }, | |
476 | + //--------------------提交订单----------------------- | |
477 | + submitForm: async function (t) { | |
478 | + if (this.data.is_summit_ing == 1) return false; //--提交中退出-- | |
479 | + this.data.is_summit_ing = 1; | |
480 | + | |
481 | + var th = this, pdata = new Array(); | |
482 | + var ff = true; | |
483 | + //------------立即购买------------- | |
484 | + console.log("buy_new"); | |
485 | + | |
486 | + //如果不是阶梯团,或者是普通购买,商家选择了物流,以及地址为空的时候 | |
487 | + if (th.data.bn_exp_type == 0 && th.data.user_addr == null && (th.data.kt_type != 3 || th.data.bn_goods.is_normal == 1)) { | |
488 | + ff = false; | |
489 | + getApp().my_warnning("请选择收货地址", 0, this); | |
490 | + this.data.is_summit_ing = 0; | |
491 | + } | |
492 | + if (!ff) return false; | |
493 | + var addr = th.data.user_addr; | |
494 | + if (th.data.bn_exp_type == 1) addr = null; | |
495 | + | |
496 | + console.log(th.data.formData); | |
497 | + console.log(th.data.wu_arr); | |
498 | + console.log(th.data.bn_exp_type); | |
499 | + | |
500 | + if (th.data.bn_exp_type == 0 && (th.data.kt_type != 3 || th.data.bn_goods.is_normal == 1)) { | |
501 | + if (th.data.wu_arr == null || th.data.wu_arr.length <= 0) { | |
502 | + getApp().my_warnning("读取物流失败", 0, this); | |
503 | + this.data.is_summit_ing = 0; | |
504 | + return false; | |
505 | + } | |
506 | + } | |
507 | + | |
508 | + //阶梯团强制带1,自提~~~ | |
509 | + if (th.data.kt_type == 3) { | |
510 | + th.data.bn_exp_type = 1; | |
511 | + } | |
512 | + | |
513 | + var item = { | |
514 | + 'user_id': to.globalData.user_id, | |
515 | + 'consignee': addr == null ? "" : addr.consignee, | |
516 | + 'province': addr == null ? 0 : addr.province, | |
517 | + 'city': addr == null ? 0 : addr.city, | |
518 | + 'district': addr == null ? 0 : addr.district, | |
519 | + 'twon': addr == null ? 0 : addr.twon, | |
520 | + 'address': addr == null ? "" : addr.address, | |
521 | + 'more_address': addr == null ? "" : addr.more_address, | |
522 | + 'mobile': addr == null ? th.data.userinfo.mobile : addr.mobile, | |
523 | + 'email': '', | |
524 | + 'invoice_title': '', | |
525 | + 'goods_price': th.data.formData.all_price, //商品总价 | |
526 | + 'shipping_price': th.data.formData.shipping_price, //物流金额 | |
527 | + 'user_money': th.data.formData.user_money, //使用余额 | |
528 | + 'total_amount': th.data.formData.total_amount, //订单总价 | |
529 | + 'order_amount': th.data.formData.order_amount, //应付 | |
530 | + 'user_note': t.detail.value.user_note, //用户备注 | |
531 | + 'store_id': oo.stoid, //商家 | |
532 | + 'pickup_id': th.data.bn_pick, //门店 | |
533 | + 'exp_type': th.data.bn_exp_type, //配送方式 | |
534 | + 'is_normal': th.data.bn_goods.is_normal, //是否是普通购买 | |
535 | + 'pt_prom_id': th.data.bn_goods.prom_id, //拼单ID | |
536 | + 'is_pt_tz': th.data.is_pt_tz, //开团类型 | |
537 | + 'order_goods': new Array(), | |
538 | + }; | |
539 | + | |
540 | + //如果不是阶梯团,或者是普通购买, | |
541 | + if ((th.data.kt_type != 3 || th.data.bn_goods.is_normal == 1)) { | |
542 | + item['shipping_code'] = th.data.bn_exp_type == 1 ? 0 : th.data.wu_arr[th.data.index].code; | |
543 | + item['shipping_name'] = th.data.bn_exp_type == 1 ? '' : th.data.wu_arr[th.data.index].name; | |
544 | + } | |
545 | + | |
546 | + if (!th.data.bn_goods.is_normal) { | |
547 | + item.is_zsorder = th.data.kt_type + 1; //开团类型 | |
548 | + } | |
549 | + //老会员成为分销下线需要的参数 | |
550 | + if (getApp().globalData.first_leader && !getApp().globalData.userInfo.first_leader) { | |
551 | + //判断一下分享人是不是分享商 | |
552 | + await app.request.promiseGet("/api/weshop/users/get/" + os.stoid + "/" + getApp().globalData.first_leader, {}).then(res => { | |
553 | + if (res.data.code == 0) { | |
554 | + var user = res.data.data; | |
555 | + if (user.is_distribut == 1) { | |
556 | + item.first_leader = parseInt(getApp().globalData.first_leader); | |
506 | 557 | } |
507 | 558 | } |
508 | - | |
509 | - //阶梯团强制带1,自提~~~ | |
510 | - if(th.data.kt_type==3 ){ | |
511 | - th.data.bn_exp_type=1; | |
512 | - } | |
513 | - | |
514 | - var item={ | |
515 | - 'user_id': to.globalData.user_id, | |
516 | - 'consignee': addr == null ? "" : addr.consignee, | |
517 | - 'province': addr == null ? 0 : addr.province, | |
518 | - 'city': addr == null ? 0 : addr.city, | |
519 | - 'district': addr == null ? 0 : addr.district, | |
520 | - 'twon': addr == null ? 0 : addr.twon, | |
521 | - 'address': addr == null ? "": addr.address, | |
522 | - 'more_address': addr == null ? "" : addr.more_address, | |
523 | - 'mobile': addr == null ? th.data.userinfo.mobile:addr.mobile, | |
524 | - 'email':'', | |
525 | - 'invoice_title':'', | |
526 | - 'goods_price': th.data.formData.all_price, //商品总价 | |
527 | - 'shipping_price': th.data.formData.shipping_price, //物流金额 | |
528 | - 'user_money': th.data.formData.user_money, //使用余额 | |
529 | - 'total_amount': th.data.formData.total_amount, //订单总价 | |
530 | - 'order_amount': th.data.formData.order_amount, //应付 | |
531 | - 'user_note': t.detail.value.user_note, //用户备注 | |
532 | - 'store_id':oo.stoid, //商家 | |
533 | - 'pickup_id': th.data.bn_pick, //门店 | |
534 | - 'exp_type': th.data.bn_exp_type, //配送方式 | |
535 | - 'is_normal':th.data.bn_goods.is_normal, //是否是普通购买 | |
536 | - 'pt_prom_id':th.data.bn_goods.prom_id, //拼单ID | |
537 | - 'is_pt_tz':th.data.is_pt_tz, //开团类型 | |
538 | - 'order_goods':new Array(), | |
539 | - }; | |
540 | - | |
541 | - //如果不是阶梯团,或者是普通购买, | |
542 | - if((th.data.kt_type!=3 || th.data.bn_goods.is_normal==1)){ | |
543 | - item['shipping_code']= th.data.bn_exp_type == 1 ? 0 : th.data.wu_arr[th.data.index].code; | |
544 | - item['shipping_name']= th.data.bn_exp_type == 1 ? '' : th.data.wu_arr[th.data.index].name; | |
545 | - } | |
546 | - | |
547 | - if(!th.data.bn_goods.is_normal){ | |
548 | - item.is_zsorder=th.data.kt_type+1; //开团类型 | |
549 | - } | |
550 | - //老会员成为分销下线需要的参数 | |
551 | - if(getApp().globalData.first_leader && !getApp().globalData.userInfo.first_leader){ | |
552 | - //判断一下分享人是不是分享商 | |
553 | - await app.request.promiseGet("/api/weshop/users/get/" + os.stoid+"/"+getApp().globalData.first_leader,{}).then(res=>{ | |
554 | - if(res.data.code==0){ | |
555 | - var user= res.data.data; | |
556 | - if(user.is_distribut==1){ | |
557 | - item.first_leader=parseInt(getApp().globalData.first_leader); | |
558 | - } | |
559 | - } | |
560 | - }) | |
561 | - } | |
562 | - | |
563 | - if(th.data.qh!='') | |
564 | - { | |
565 | - item.team_qh=th.data.qh; | |
566 | - item.pt_listno=th.data.qh; | |
567 | - } | |
568 | - | |
569 | - var gg = to.get_b_now(); | |
570 | - var goods={ | |
571 | - 'goods_id': gg.goods_id, | |
572 | - 'goods_name': gg.goods_name, | |
573 | - 'goods_sn': gg.goods_sn, | |
574 | - 'goods_num': gg.goods_num, | |
575 | - 'market_price': th.data.bn_goods.market_price, | |
576 | - 'goods_price': th.data.bn_goods.shop_price, | |
577 | - 'member_goods_price': th.data.bn_goods.shop_price, | |
578 | - 'store_id': oo.stoid, | |
579 | - 'prom_type':th.data.bn_goods.prom_type, //促销活动类型 | |
580 | - 'prom_id': th.data.bn_goods.prom_id, //促销活动id | |
581 | - }; | |
582 | - | |
583 | - //--导购分享过来的id-- | |
584 | - if(gg.guide_id){ | |
585 | - goods.guide_id=gg.guide_id; | |
586 | - goods.guide_type=gg.guide_type; | |
587 | - //调用接口判断是不是会员 | |
588 | - await getApp().request.promiseGet("/api/weshop/shoppingGuide/getId/"+oo.stoid+"/"+gg.guide_id,{}).then(res=>{ | |
589 | - if(res.data.code==0){ | |
590 | - goods.guide_name=res.data.data.salesman; | |
591 | - goods.guide_sn=res.data.data.salesman_no; | |
592 | - } | |
593 | - }) | |
594 | - } | |
595 | - | |
596 | - | |
597 | - //--商品的房间号-- | |
598 | - if(gg.room_id && gg.room_id>0){ | |
599 | - item.room_ids=gg.room_id; | |
600 | - goods.room_id=gg.room_id; | |
559 | + }) | |
560 | + } | |
561 | + | |
562 | + if (th.data.qh != '') { | |
563 | + item.team_qh = th.data.qh; | |
564 | + item.pt_listno = th.data.qh; | |
565 | + } | |
566 | + | |
567 | + var gg = to.get_b_now(); | |
568 | + var goods = { | |
569 | + 'goods_id': gg.goods_id, | |
570 | + 'goods_name': gg.goods_name, | |
571 | + 'goods_sn': gg.goods_sn, | |
572 | + 'goods_num': gg.goods_num, | |
573 | + 'market_price': th.data.bn_goods.market_price, | |
574 | + 'goods_price': th.data.bn_goods.shop_price, | |
575 | + 'member_goods_price': th.data.bn_goods.shop_price, | |
576 | + 'store_id': oo.stoid, | |
577 | + 'prom_type': th.data.bn_goods.prom_type, //促销活动类型 | |
578 | + 'prom_id': th.data.bn_goods.prom_id, //促销活动id | |
579 | + }; | |
580 | + | |
581 | + //--导购分享过来的id-- | |
582 | + if (gg.guide_id) { | |
583 | + goods.guide_id = gg.guide_id; | |
584 | + goods.guide_type = gg.guide_type; | |
585 | + //调用接口判断是不是会员 | |
586 | + await getApp().request.promiseGet("/api/weshop/shoppingGuide/getId/" + oo.stoid + "/" + gg.guide_id, {}).then(res => { | |
587 | + if (res.data.code == 0) { | |
588 | + goods.guide_name = res.data.data.salesman; | |
589 | + goods.guide_sn = res.data.data.salesman_no; | |
601 | 590 | } |
602 | - | |
603 | - if(th.data.bn_goods.is_normal){goods.is_pd_normal=1;} | |
604 | - | |
605 | - item.order_goods.push(goods); | |
606 | - pdata.push(item); | |
607 | - | |
608 | - if (pdata.length==0) return; | |
609 | - var str = JSON.stringify(pdata); | |
610 | - console.log("支付数据"); | |
611 | - console.log(str); | |
612 | - //return false; | |
613 | - wx.showLoading({title: "加载中"}); | |
614 | - wx.request({ | |
615 | - url: oo.url + '/api/weshop/order/createWxdOrder', | |
616 | - data: str, | |
617 | - method: 'POST', | |
618 | - header: { | |
619 | - 'content-type': 'application/json' | |
620 | - },// 设置请求的 header | |
621 | - success: function (res) { | |
622 | - | |
623 | - wx.hideLoading(); | |
624 | - if (res.statusCode == 200) { | |
625 | - var data=res.data; | |
626 | - if(data.code==0){ | |
627 | - console.log(th.data.is_b_now); | |
628 | - //如果是购物车结算,还要删除购物车 | |
629 | - if (th.data.is_b_now == 0) { | |
630 | - console.log(th.data.cartlist_y); | |
631 | - var list = th.data.cartlist_y; | |
632 | - for (var i = 0; i < list.length; i++) { | |
633 | - //删除购物车 | |
634 | - getApp().request.delete("/api/weshop/cart/del/" + oo.stoid + "/" + list[i].id, {}); | |
635 | - } | |
636 | - } | |
637 | - var order_amount = 0; | |
638 | - pdata.forEach(function (em, ind) { | |
639 | - order_amount += em.order_amount; | |
640 | - }) | |
641 | - //要进行判断,如果是用微信支付,就要跳转到支付界面 | |
642 | - if (order_amount > 0) { | |
591 | + }) | |
592 | + } | |
593 | + | |
594 | + | |
595 | + //--商品的房间号-- | |
596 | + if (gg.room_id && gg.room_id > 0) { | |
597 | + item.room_ids = gg.room_id; | |
598 | + goods.room_id = gg.room_id; | |
599 | + } | |
600 | + | |
601 | + if (th.data.bn_goods.is_normal) { goods.is_pd_normal = 1; } | |
602 | + | |
603 | + item.order_goods.push(goods); | |
604 | + pdata.push(item); | |
605 | + | |
606 | + if (pdata.length == 0) return; | |
607 | + var str = JSON.stringify(pdata); | |
608 | + console.log("支付数据"); | |
609 | + console.log(str); | |
610 | + //return false; | |
611 | + wx.showLoading({ title: "加载中" }); | |
612 | + wx.request({ | |
613 | + url: oo.url + '/api/weshop/order/createWxdOrder', | |
614 | + data: str, | |
615 | + method: 'POST', | |
616 | + header: { | |
617 | + 'content-type': 'application/json' | |
618 | + },// 设置请求的 header | |
619 | + success: function (res) { | |
620 | + | |
621 | + wx.hideLoading(); | |
622 | + if (res.statusCode == 200) { | |
623 | + var data = res.data; | |
624 | + if (data.code == 0) { | |
625 | + console.log(th.data.is_b_now); | |
626 | + //如果是购物车结算,还要删除购物车 | |
627 | + if (th.data.is_b_now == 0) { | |
628 | + console.log(th.data.cartlist_y); | |
629 | + var list = th.data.cartlist_y; | |
630 | + for (var i = 0; i < list.length; i++) { | |
631 | + //删除购物车 | |
632 | + getApp().request.delete("/api/weshop/cart/del/" + oo.stoid + "/" + list[i].id, {}); | |
633 | + } | |
634 | + } | |
635 | + var order_amount = 0; | |
636 | + pdata.forEach(function (em, ind) { | |
637 | + order_amount += em.order_amount; | |
638 | + }) | |
639 | + //要进行判断,如果是用微信支付,就要跳转到支付界面 | |
640 | + if (order_amount > 0) { | |
641 | + th.setData({ isclose: 0 }); | |
642 | + //void e.jumpToCart4({ | |
643 | + // order_sn: data.data, | |
644 | + // type:1, | |
645 | + // }, 1); | |
646 | + util_pay.pay(data.data, function () { | |
647 | + setTimeout(function () { | |
648 | + wx.reLaunch({ | |
649 | + //url: "/pages/payment/pay_success/pay_success?type=1&order_sn="+data.data, | |
650 | + url: "/pages/team/team_success/team_success?ordersn=" + data.data, | |
651 | + }) | |
652 | + }, 1000) | |
653 | + }, function () { | |
654 | + //支付失败 | |
655 | + setTimeout(function () { | |
656 | + //wx.navigateBack({ delta: 1 }) | |
657 | + wx.reLaunch({ | |
658 | + url: "/pages/user/order_list/order_list", | |
659 | + }) | |
660 | + }, 1000) | |
661 | + | |
662 | + }, oo.stoid, 1); | |
663 | + | |
664 | + } else { | |
665 | + var dd = { | |
666 | + parent_sn: data.data, | |
667 | + store_id: oo.stoid, | |
668 | + type: 1, | |
669 | + }; | |
670 | + //return false; | |
671 | + getApp().request.post("/api/weshop/order/pay/createOrder", { | |
672 | + data: dd, | |
673 | + success: function (t) { | |
674 | + console.log(t); | |
675 | + app.my_warnning("支付成功", 1, th); | |
676 | + setTimeout(function () { | |
643 | 677 | th.setData({ isclose: 0 }); |
644 | - //void e.jumpToCart4({ | |
645 | - // order_sn: data.data, | |
646 | - // type:1, | |
647 | - // }, 1); | |
648 | - util_pay.pay(data.data, function() { | |
649 | - setTimeout(function () { | |
650 | - wx.reLaunch({ | |
651 | - //url: "/pages/payment/pay_success/pay_success?type=1&order_sn="+data.data, | |
652 | - url: "/pages/team/team_success/team_success?ordersn=" + data.data, | |
653 | - }) | |
654 | - },1000) | |
655 | - }, function () { | |
656 | - //支付失败 | |
657 | - setTimeout(function () { | |
658 | - //wx.navigateBack({ delta: 1 }) | |
659 | - wx.reLaunch({ | |
660 | - url: "/pages/user/order_list/order_list", | |
661 | - }) | |
662 | - },1000) | |
663 | - | |
664 | - },oo.stoid,1); | |
665 | 678 | |
666 | - } else { | |
667 | - var dd = { | |
668 | - parent_sn: data.data, | |
669 | - store_id: oo.stoid, | |
670 | - type: 1, | |
671 | - }; | |
672 | - //return false; | |
673 | - getApp().request.post("/api/weshop/order/pay/createOrder", { | |
674 | - data: dd, | |
675 | - success: function (t) { | |
676 | - console.log(t); | |
677 | - app.my_warnning("支付成功",1,th); | |
678 | - setTimeout(function () { | |
679 | - th.setData({ isclose: 0 }); | |
680 | - | |
681 | - if(th.data.is_normal==1){ | |
682 | - /*-- | |
683 | - wx.navigateTo({ | |
684 | - url: "/pages/user/order_list/order_list", | |
685 | - })--*/ | |
686 | - var url="/pages/payment/pay_success/pay_success?type=1&order_sn="+data.data; | |
687 | - wx.reLaunch({ | |
688 | - url: url | |
689 | - }) | |
690 | - | |
691 | - }else{ | |
692 | - wx.reLaunch({ | |
693 | - url: "/pages/team/team_success/team_success?ordersn=" + data.data, | |
694 | - }) | |
695 | - } | |
696 | - | |
697 | - | |
698 | - }, 1000) | |
679 | + if (th.data.is_normal == 1) { | |
680 | + /*-- | |
681 | + wx.navigateTo({ | |
682 | + url: "/pages/user/order_list/order_list", | |
683 | + })--*/ | |
684 | + var url = "/pages/payment/pay_success/pay_success?type=1&order_sn=" + data.data; | |
685 | + wx.reLaunch({ | |
686 | + url: url | |
687 | + }) | |
688 | + | |
689 | + } else { | |
690 | + wx.reLaunch({ | |
691 | + url: "/pages/team/team_success/team_success?ordersn=" + data.data, | |
692 | + }) | |
699 | 693 | } |
700 | - }); | |
694 | + | |
695 | + | |
696 | + }, 1000) | |
701 | 697 | } |
702 | - } | |
703 | - else{ | |
704 | - th.data.is_summit_ing=0; //是否提交中 | |
705 | - getApp().confirmBox(data.msg); | |
706 | - } | |
707 | - } else { | |
708 | - th.data.is_summit_ing=0; //是否提交中 | |
709 | - console.log("index.js wx.request CheckCallUser statusCode" + res.statusCode); | |
698 | + }); | |
699 | + } | |
710 | 700 | } |
711 | - }, | |
712 | - fail: function () { | |
713 | - th.data.is_summit_ing=0; //是否提交中 | |
714 | - wx.hideLoading(); | |
715 | - console.log("index.js wx.request CheckCallUser fail"); | |
716 | - }, | |
717 | - complete: function () {} | |
718 | - }) | |
719 | - }, | |
720 | - useCoupon: function() { | |
721 | - if (this.data.order.couponNum <= 0) { | |
722 | - //return t.showWarning("无可用优惠券"); | |
723 | - getApp().my_warnning("无可用优惠券",0,this); | |
724 | - return; | |
701 | + else { | |
702 | + th.data.is_summit_ing = 0; //是否提交中 | |
703 | + getApp().confirmBox(data.msg); | |
704 | + } | |
705 | + } else { | |
706 | + th.data.is_summit_ing = 0; //是否提交中 | |
707 | + console.log("index.js wx.request CheckCallUser statusCode" + res.statusCode); | |
725 | 708 | } |
726 | - var a = { | |
727 | - lid: this.data.coupon ? this.data.coupon.id : "0" | |
728 | - }; | |
729 | - wx.navigateTo({ | |
730 | - url: "/pages/user/checkcoupon/checkcoupon?" + s.Obj2Str(a) | |
731 | - }); | |
732 | - }, | |
733 | - enterAddressPage: function() { | |
734 | - getApp().globalData.is_cart_old=1; | |
735 | - this.data.enterAddressPage = !0, wx.navigateTo({ | |
736 | - url: "/pages/user/address_list/address_list" | |
737 | - }); | |
738 | - }, | |
709 | + }, | |
710 | + fail: function () { | |
711 | + th.data.is_summit_ing = 0; //是否提交中 | |
712 | + wx.hideLoading(); | |
713 | + console.log("index.js wx.request CheckCallUser fail"); | |
714 | + }, | |
715 | + complete: function () { } | |
716 | + }) | |
717 | + }, | |
718 | + useCoupon: function () { | |
719 | + if (this.data.order.couponNum <= 0) { | |
720 | + //return t.showWarning("无可用优惠券"); | |
721 | + getApp().my_warnning("无可用优惠券", 0, this); | |
722 | + return; | |
723 | + } | |
724 | + var a = { | |
725 | + lid: this.data.coupon ? this.data.coupon.id : "0" | |
726 | + }; | |
727 | + wx.navigateTo({ | |
728 | + url: "/pages/user/checkcoupon/checkcoupon?" + s.Obj2Str(a) | |
729 | + }); | |
730 | + }, | |
731 | + enterAddressPage: function () { | |
732 | + getApp().globalData.is_cart_old = 1; | |
733 | + this.data.enterAddressPage = !0, wx.navigateTo({ | |
734 | + url: "/pages/user/address_list/address_list" | |
735 | + }); | |
736 | + }, | |
739 | 737 | |
740 | - //--------立即购买时,选择自提和物流----------- | |
741 | - setexptype_w:function(t){ | |
742 | - var th=this; | |
743 | - var ty = t.currentTarget.dataset.t,txt = t.currentTarget.dataset.txt; | |
744 | - th.setData({ [txt]: ty }); | |
745 | - var iszt=1; | |
746 | - if(ty==0){ | |
747 | - th.setData({ is_all_zt: 0 }); | |
748 | - }else{ | |
749 | - for(var i=0;i<th.data.cartlist.length;i++){ | |
750 | - var item = th.data.cartlist[i]; | |
751 | - if (item.exp_type==0){ iszt=0;break;} | |
752 | - } | |
753 | - th.setData({ is_all_zt: iszt }); | |
738 | + //--------立即购买时,选择自提和物流----------- | |
739 | + setexptype_w: function (t) { | |
740 | + var th = this; | |
741 | + var ty = t.currentTarget.dataset.t, txt = t.currentTarget.dataset.txt; | |
742 | + th.setData({ [txt]: ty }); | |
743 | + var iszt = 1; | |
744 | + if (ty == 0) { | |
745 | + th.setData({ is_all_zt: 0 }); | |
746 | + } else { | |
747 | + for (var i = 0; i < th.data.cartlist.length; i++) { | |
748 | + var item = th.data.cartlist[i]; | |
749 | + if (item.exp_type == 0) { iszt = 0; break; } | |
754 | 750 | } |
755 | - //----计算此时购物车的价格---- | |
756 | - th.calculatePrice(); | |
757 | - }, | |
751 | + th.setData({ is_all_zt: iszt }); | |
752 | + } | |
753 | + //----计算此时购物车的价格---- | |
754 | + th.calculatePrice(); | |
755 | + }, | |
758 | 756 | |
759 | - //--------立即购买时,选择自提和物流---------- | |
760 | - setexptype:function(t){ | |
761 | - var th=this; | |
762 | - var ty = t.currentTarget.dataset.t; | |
763 | - th.setData({ bn_exp_type:ty}); | |
764 | - //当物流为空的时候。 | |
765 | - if (ty == 0 && th.data.wu_arr==null){ | |
766 | - return th.get_wuliu(th.calculatePrice2()); | |
767 | - } | |
768 | - th.calculatePrice2() | |
769 | - console.log('setexptype'); | |
770 | - }, | |
757 | + //--------立即购买时,选择自提和物流---------- | |
758 | + setexptype: function (t) { | |
759 | + var th = this; | |
760 | + var ty = t.currentTarget.dataset.t; | |
761 | + th.setData({ bn_exp_type: ty }); | |
762 | + //当物流为空的时候。 | |
763 | + if (ty == 0 && th.data.wu_arr == null) { | |
764 | + return th.get_wuliu(th.calculatePrice2()); | |
765 | + } | |
766 | + th.calculatePrice2() | |
767 | + console.log('setexptype'); | |
768 | + }, | |
771 | 769 | |
772 | - //--------立即购买时,使用余额-------- | |
773 | - set_bn_useyuer:function(){ | |
774 | - var th=this; | |
775 | - th.setData({ bn_use_money: !th.data.bn_use_money}); | |
776 | - th.calculatePrice2(); | |
777 | - }, | |
778 | - set_js_useyuer:function(){ | |
779 | - var th = this; | |
780 | - th.setData({ js_use_money: !th.data.js_use_money }); | |
781 | - th.calculatePrice(); | |
782 | - }, | |
770 | + //--------立即购买时,使用余额-------- | |
771 | + set_bn_useyuer: function () { | |
772 | + var th = this; | |
773 | + th.setData({ bn_use_money: !th.data.bn_use_money }); | |
774 | + th.calculatePrice2(); | |
775 | + }, | |
776 | + set_js_useyuer: function () { | |
777 | + var th = this; | |
778 | + th.setData({ js_use_money: !th.data.js_use_money }); | |
779 | + th.calculatePrice(); | |
780 | + }, | |
783 | 781 | |
784 | 782 | //-------------------计算物流--------------- |
785 | - calculatewuliu:function(code, o_shipping_price, goods_weight,out_of_weight, | |
786 | - goods_piece,user_addr, freight_free, o_price, rs){ | |
787 | - var price =0,th=this; | |
788 | - price +=parseFloat(o_shipping_price); | |
789 | - //如果是包邮 | |
790 | - if (freight_free > 0 && o_price >= freight_free && out_of_weight>=0){ return 0;} | |
791 | - if (user_addr==null) { return 0; } | |
792 | - //计算物流的config item; | |
793 | - var item=null; | |
794 | - //先根据 镇 县 区找计算的config | |
795 | - item = th.get_wuliu_config(user_addr.district,code,rs); | |
796 | - if (item==null) item = th.get_wuliu_config(user_addr.city, code, rs); | |
797 | - if (item==null) item = th.get_wuliu_config(user_addr.province, code, rs); | |
798 | - if (item == null) item = th.get_wuliu_default(code,rs); | |
783 | + calculatewuliu: function (code, o_shipping_price, goods_weight, out_of_weight, | |
784 | + goods_piece, user_addr, freight_free, o_price, rs, pickid) { | |
785 | + var price = 0, th = this; | |
786 | + price += parseFloat(o_shipping_price); | |
787 | + //如果是包邮 | |
788 | + if (freight_free > 0 && o_price >= freight_free && out_of_weight >= 0) { return 0; } | |
789 | + if (user_addr == null) { return 0; } | |
790 | + //计算物流的config item; | |
791 | + var item = null; | |
792 | + //先根据 镇 县 区找计算的config | |
793 | + item = th.get_wuliu_config(user_addr.district, code, rs); | |
794 | + if (item == null) item = th.get_wuliu_config(user_addr.city, code, rs); | |
795 | + if (item == null) item = th.get_wuliu_config(user_addr.province, code, rs); | |
796 | + if (item == null) item = th.get_wuliu_default(code, rs); | |
797 | + if (item == null) return o_shipping_price; | |
798 | + var fw_price = 0, fp_price = 0; | |
799 | + item = item.config; | |
799 | 800 | if (item == null) return o_shipping_price; |
800 | - var fw_price = 0, fp_price=0; | |
801 | - item=item.config; | |
802 | - if (item == null) return o_shipping_price; | |
803 | 801 | //------按重量---------- |
804 | 802 | if (goods_weight >= 0 && item['money']) { |
805 | - fw_price =parseFloat(item['money']); | |
806 | - if (goods_weight > item['first_weight']){ | |
807 | - var fw = goods_weight - item['first_weight']; | |
808 | - var n = Math.ceil(fw/item['second_weight']) | |
809 | - fw_price = fw_price + n * parseFloat(item['add_money']); | |
810 | - } | |
803 | + fw_price = parseFloat(item['money']); | |
804 | + if (goods_weight > item['first_weight']) { | |
805 | + var fw = goods_weight - item['first_weight']; | |
806 | + var n = Math.ceil(fw / item['second_weight']) | |
807 | + fw_price = fw_price + n * parseFloat(item['add_money']); | |
808 | + } | |
811 | 809 | } |
812 | - //------超出重量---------- | |
813 | - if(out_of_weight < 0 && o_price >= freight_free){ | |
810 | + //------超出重量---------- | |
811 | + if (out_of_weight < 0 && o_price >= freight_free) { | |
814 | 812 | fw_price = parseFloat(item['money']); |
815 | 813 | var out_of_weight = Math.abs(out_of_weight); |
816 | 814 | if (out_of_weight > item['first_weight']) { |
817 | - var fw = out_of_weight - item['first_weight']; | |
818 | - var n = Math.ceil(fw / item['second_weight']) | |
819 | - fw_price = fw_price + n * parseFloat(item['add_money']); | |
815 | + var fw = out_of_weight - item['first_weight']; | |
816 | + var n = Math.ceil(fw / item['second_weight']) | |
817 | + fw_price = fw_price + n * parseFloat(item['add_money']); | |
820 | 818 | } |
821 | 819 | } |
822 | 820 | //------按件数---------- |
823 | - if (goods_piece > 0 ) { | |
821 | + if (goods_piece > 0) { | |
824 | 822 | fp_price = parseFloat(item['piecemoney']); |
825 | 823 | if (goods_piece > item['first_piece']) { |
826 | - var fp = goods_piece - item['first_piece']; | |
827 | - var m = Math.ceil(fp / item['second_piece']) | |
824 | + var fp = goods_piece - item['first_piece']; | |
825 | + var m = Math.ceil(fp / item['second_piece']) | |
828 | 826 | fp_price = fp_price + m * parseFloat(item['add_piecemoney']); |
829 | 827 | } |
830 | 828 | } |
831 | - var rspice =parseFloat(price + fw_price + fp_price); | |
829 | + var rspice = parseFloat(price + fw_price + fp_price); | |
832 | 830 | return rspice; |
833 | 831 | }, |
834 | 832 | |
835 | 833 | //------------循环获取config----------- |
836 | - get_wuliu_config:function(region_id,code,rs){ | |
837 | - var item=null,rslist = rs.pageData; | |
838 | - for (var i = 0; i < rslist.length;i++){ | |
839 | - if (rslist[i].code == code && rslist[i].region_id == region_id) { item = rslist[i];} | |
840 | - } | |
841 | - return item; | |
834 | + get_wuliu_config: function (region_id, code, rs) { | |
835 | + var item = null, rslist = rs.pageData; | |
836 | + for (var i = 0; i < rslist.length; i++) { | |
837 | + if (rslist[i].code == code && rslist[i].region_id == region_id) { item = rslist[i]; } | |
838 | + } | |
839 | + return item; | |
842 | 840 | }, |
843 | 841 | //-------循环获取config,code default------- |
844 | 842 | get_wuliu_default: function (code, rs) { |
845 | - var item = null, rslist=rs.pageData; | |
843 | + var item = null, rslist = rs.pageData; | |
846 | 844 | for (var i = 0; i < rslist.length; i++) { |
847 | 845 | if (rslist[i].shipping_code == code && rslist[i].is_default == 1) { item = rslist[i]; } |
848 | 846 | } |
849 | 847 | return item; |
850 | 848 | }, |
851 | 849 | |
852 | - //----------立即购买,选择物流------------- | |
853 | - bindPickerChange:function(e){ | |
854 | - var ind = e.detail.value | |
855 | - this.setData({ index: ind }); | |
856 | - this.calculatePrice2(); | |
857 | - }, | |
858 | - | |
859 | - //----------购物车结算,选择物流------------- | |
860 | - bindPickerChange_w: function (e) { | |
861 | - var ind=e.detail.value, txt = e.currentTarget.dataset.txt; | |
862 | - this.setData({ [txt]: ind }); | |
863 | - this.calculatePrice(); | |
864 | - }, | |
865 | - | |
850 | + //----------立即购买,选择物流------------- | |
851 | + bindPickerChange: function (e) { | |
852 | + var ind = e.detail.value | |
853 | + this.setData({ index: ind }); | |
854 | + this.calculatePrice2(); | |
855 | + }, | |
856 | + | |
857 | + //----------购物车结算,选择物流------------- | |
858 | + bindPickerChange_w: function (e) { | |
859 | + var ind = e.detail.value, txt = e.currentTarget.dataset.txt; | |
860 | + this.setData({ [txt]: ind }); | |
861 | + this.calculatePrice(); | |
862 | + }, | |
863 | + | |
866 | 864 | cart_set_err: function (e) { |
867 | 865 | var txt = e.currentTarget.dataset.err; |
868 | 866 | var ob = {}; |
... | ... | @@ -870,70 +868,70 @@ Page({ |
870 | 868 | this.setData(ob); |
871 | 869 | }, |
872 | 870 | |
873 | - //// 开启物流的弹窗 | |
874 | - show_wu_arr:function(e){ | |
875 | - this.setData({ open_express: 1}); | |
876 | - }, | |
871 | + //// 开启物流的弹窗 | |
872 | + show_wu_arr: function (e) { | |
873 | + this.setData({ open_express: 1 }); | |
874 | + }, | |
877 | 875 | |
878 | - //更新下默认,在onshow里面 | |
879 | - update_code(){ | |
880 | - var th=this,m_wind=0,def_exp_code=getApp().globalData.userInfo.def_exp_code; | |
881 | - | |
882 | - var uii=setInterval(function () { | |
883 | - if(th.data.wu_arr){ | |
884 | - clearInterval(uii); | |
885 | - for (var k = 0; k < th.data.wu_arr.length; k++) { | |
886 | - var item = th.data.wu_arr[k]; | |
887 | - if (def_exp_code == item.code) { | |
888 | - m_wind = k; | |
889 | - } | |
890 | - } | |
891 | - //--如果是立即购买-- | |
892 | - th.setData({ index: m_wind, is_express: m_wind}); | |
893 | - } | |
894 | - },500) | |
895 | - }, | |
876 | + //更新下默认,在onshow里面 | |
877 | + update_code() { | |
878 | + var th = this, m_wind = 0, def_exp_code = getApp().globalData.userInfo.def_exp_code; | |
879 | + | |
880 | + var uii = setInterval(function () { | |
881 | + if (th.data.wu_arr) { | |
882 | + clearInterval(uii); | |
883 | + for (var k = 0; k < th.data.wu_arr.length; k++) { | |
884 | + var item = th.data.wu_arr[k]; | |
885 | + if (def_exp_code == item.code) { | |
886 | + m_wind = k; | |
887 | + } | |
888 | + } | |
889 | + //--如果是立即购买-- | |
890 | + th.setData({ index: m_wind, is_express: m_wind }); | |
891 | + } | |
892 | + }, 500) | |
893 | + }, | |
896 | 894 | |
897 | - // 关闭物流的弹窗 | |
898 | - close_express:function(){ | |
899 | - this.setData({ open_express:0 }); | |
900 | - }, | |
901 | - // 选择物流 | |
902 | - click_express_name:function(e){ | |
903 | - var express_name = e.currentTarget.dataset.name, shippingcode = e.currentTarget.dataset.shippingcode; | |
904 | - var index=e.currentTarget.dataset.idxe; | |
905 | - var ob={ is_express: index, is_shipping_code: shippingcode,index:index}; | |
906 | - this.setData(ob); | |
907 | - }, | |
895 | + // 关闭物流的弹窗 | |
896 | + close_express: function () { | |
897 | + this.setData({ open_express: 0 }); | |
898 | + }, | |
899 | + // 选择物流 | |
900 | + click_express_name: function (e) { | |
901 | + var express_name = e.currentTarget.dataset.name, shippingcode = e.currentTarget.dataset.shippingcode; | |
902 | + var index = e.currentTarget.dataset.idxe; | |
903 | + var ob = { is_express: index, is_shipping_code: shippingcode, index: index }; | |
904 | + this.setData(ob); | |
905 | + }, | |
908 | 906 | |
909 | - //点击确定物流 | |
910 | - determine_expres:function(e){ | |
911 | - this.setData({ open_express: 0}); | |
912 | - this.calculatePrice2(); | |
913 | - }, | |
914 | - //设置默认物流 | |
915 | - select_default_logistics: function () { | |
916 | - var th=this; | |
917 | - var is_shipping_code=this.data.is_shipping_code | |
918 | - getApp().request.put("/api/weshop/users/update",{ | |
919 | - data: { user_id: getApp().globalData.user_id, store_id: oo.stoid, def_exp_code: is_shipping_code}, | |
920 | - success:function(rse){ | |
921 | - if (rse.data.code==0){ | |
922 | - getApp().globalData.userInfo.def_exp_code=is_shipping_code; | |
923 | - th.setData({ open_express: 0 }); | |
924 | - //----计算此时购物车的价格,这个页面没有calculatePrice(),2021.7.19---- | |
925 | - //if(th.data.is_b_now==1) th.calculatePrice2(); | |
926 | - //else th.calculatePrice(); | |
927 | - th.calculatePrice2(); | |
928 | - } | |
929 | - } | |
930 | - }) | |
931 | - }, | |
907 | + //点击确定物流 | |
908 | + determine_expres: function (e) { | |
909 | + this.setData({ open_express: 0 }); | |
910 | + this.calculatePrice2(); | |
911 | + }, | |
912 | + //设置默认物流 | |
913 | + select_default_logistics: function () { | |
914 | + var th = this; | |
915 | + var is_shipping_code = this.data.is_shipping_code | |
916 | + getApp().request.put("/api/weshop/users/update", { | |
917 | + data: { user_id: getApp().globalData.user_id, store_id: oo.stoid, def_exp_code: is_shipping_code }, | |
918 | + success: function (rse) { | |
919 | + if (rse.data.code == 0) { | |
920 | + getApp().globalData.userInfo.def_exp_code = is_shipping_code; | |
921 | + th.setData({ open_express: 0 }); | |
922 | + //----计算此时购物车的价格,这个页面没有calculatePrice(),2021.7.19---- | |
923 | + //if(th.data.is_b_now==1) th.calculatePrice2(); | |
924 | + //else th.calculatePrice(); | |
925 | + th.calculatePrice2(); | |
926 | + } | |
927 | + } | |
928 | + }) | |
929 | + }, | |
932 | 930 | |
933 | 931 | |
934 | - //跳转到购买卡 | |
935 | - buycard:function(){ | |
936 | - getApp().goto("/pages/user/plus/plus"); | |
937 | - getApp().globalData.plus_buy_back=1; | |
938 | - } | |
932 | + //跳转到购买卡 | |
933 | + buycard: function () { | |
934 | + getApp().goto("/pages/user/plus/plus"); | |
935 | + getApp().globalData.plus_buy_back = 1; | |
936 | + } | |
939 | 937 | }); | ... | ... |