Commit 1252ddc3c9fbd8f5e182bf44d098a2ca029fa59a

Authored by antploy
2 parents 83bc7109 e6de7bb2

Merge branch 'dev' of http://git.vipzhuang.cn/wxd/MShopWeApp into dev

packageC/pages/presell/cart/cart.js
Changes suppressed. Click to show
... ... @@ -3,7 +3,7 @@ var t = getApp(), app = t, a = t.request, e = require("../../../../utils/common.
3 3 var oo = t.globalData.setting, os = oo;
4 4 var regeneratorRuntime = require('../../../../utils/runtime.js');
5 5 var util_pay = require("../../../../utils/pay.js");
6   -var zh_calc = require("zh_calculate.js");
  6 +
7 7  
8 8 Page({
9 9 data: {
... ... @@ -24,15 +24,6 @@ Page({
24 24 //页面获取的参数
25 25 param: null,
26 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 27 /*-----------当是购物车结算的时候-------------*/
37 28 cartlist: null,
38 29 old_cartlist: null,
... ... @@ -69,7 +60,7 @@ Page({
69 60 ckeck_quan_price: 0,
70 61 check_quan_price_list: '',
71 62 check_quan_ware_list: '',
72   -
  63 + isget_by_quan: {}, //是否调用了接口获取包邮券
73 64 // 设计一个数组来存放已经选择了的券编号,coupon_no是券号,money是面值,coupon_price是真正优惠的价格,数组的下标是pickid
74 65 //using_quan[11]={coupon_no:"1212121",money:"20",coupon_price:"45"}
75 66 using_quan: {},
... ... @@ -120,9 +111,17 @@ Page({
120 111  
121 112 tabs: ['门店自提', '快递邮寄'],
122 113 currentTabIndex: 1,
  114 +
  115 + order_sn:'',
  116 + order_id:'',
  117 +
123 118 },
124 119 onLoad: function (t) {
125   - wx.setNavigationBarTitle({title: "填写订单",})
  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 +
  124 + wx.setNavigationBarTitle({title: "订单详情",})
126 125 var th = this;
127 126 this.setData({is_b_now: t.is_bnow == undefined ? 0 : t.is_bnow,});
128 127 th.data.param = t;
... ... @@ -134,7 +133,9 @@ Page({
134 133 success: function (s) {
135 134 }
136 135 });
137   -
  136 + if(!getApp().globalData.userInfo){
  137 + getApp().goto("/pages/togoin/togoin");
  138 + }
138 139  
139 140 },
140 141 onUnload: function () {
... ... @@ -153,18 +154,12 @@ Page({
153 154 var th = this;
154 155 th.setData({show_submit: 0}); //让提交先掩藏
155 156 th.data.g_cart_q_time = null;
156   -
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   -
162   - } else {
  161 + }else{
163 162 this.getuser_addr(function (ie) {
164   -
165   - console.log("getuser_addr")
166   - console.log(ie)
167   -
168 163 //地址切换要把包邮券清空
169 164 if (!th.data.user_addr || !ie || th.data.user_addr.address_id != ie.address_id) {
170 165 var using_quan = th.data.using_quan;
... ... @@ -183,40 +178,16 @@ Page({
183 178 th.data.prom_goods_map = {};
184 179 th.data.is_summit_ing = 0;
185 180 //更换地址回来要重新调用计算价钱的接口
186   - if (!th.data.user_addr || th.data.user_addr.address_id != ie.address_id) {
187   - th.setData({user_addr: ie});
188   - if (th.data.is_b_now == 1) {
189   - if (th.data.bn_goods) {
190   - th.setData({add_back: 1});
191   - //th.calculatePrice2();
192   - }
193   - } else {
194   - if (th.data.cartlist) {
195   - th.setData({add_back: 1});
196   - //th.calculatePrice();
197   - }
198   - }
  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();
199 185 } else {
200 186 th.setData({user_addr: ie});
201 187 }
202 188 var going = 0;
203   -
204   -
205   - //使用计时器,避免空现象
206   - /*---
207   - var jishi= setInterval(function () {
208   - if (th.data.is_b_now == 1 && going==0) {
209   - if(th.data.bn_goods) {
210   - th.calculatePrice2();going=1;clearInterval(jishi);
211   - }
212   - }else if(going==0) {
213   - if (th.data.cartlist){
214   - th.calculatePrice();going = 1; clearInterval(jishi);
215   - }
216   - }
217   - },500)--*/
218   -
219 189 });
  190 +
220 191 var is_card_back = getApp().globalData.is_card_back;
221 192 //--更新默认地址--,看一下是不是跳到地址页面,同时也不是购买等级卡返回的,这里很重要,否则会重新更新收货物流公司
222 193 if (!getApp().globalData.is_cart_old && !is_card_back && !getApp().globalData.plus_buy_back) {
... ... @@ -238,7 +209,8 @@ Page({
238 209 is_close_quan: json_d.is_close_quan,
239 210 sales_rules: ee.sales_rules,
240 211 rank_switch: json_d.rank_switch,
241   - is_default_logistics: is_default_logistics
  212 + is_default_logistics: is_default_logistics,
  213 + sys_switch:json_d,
242 214 });
243 215  
244 216 var rank_switch = json_d.rank_switch;
... ... @@ -317,11 +289,7 @@ Page({
317 289 a.get("/api/weshop/useraddress/page", {
318 290 data: {user_id: to.globalData.user_id, store_id: oo.stoid, pageSize: 600, t: Math.random()},
319 291 success: function (su) {
320   - /*---
321   - var user_addr=[
322   - { 'address_id': 882, 'user_id': 2661, 'consignee': '测试测试测', 'province': 3102, 'city': 3431, 'district': 3466,
323   - 'address': 'ed', 'more_address': '山西-长治市-襄垣县-虎(音si)亭镇', 'mobile': 13012345678,'is_default':1},
324   - ];---*/
  292 +
325 293 var item = null;
326 294 if (su.data.code == 0 && su.data.data && su.data.data.pageData) {
327 295 var user_addr = su.data.data.pageData;
... ... @@ -349,634 +317,317 @@ Page({
349 317  
350 318 //----------------展示页面,是再获取用户信息之后--------------
351 319 show_page: function () {
352   - var th = this, ta = this.data.param;
353   - //th.setData({ userinfo: getApp().globalData.userInfo,}); //这个余额被缓存了
354   -
355   - //会员的信息,要获取最新
356   - var user = getApp().globalData.userInfo;
357   - getApp().request.get("/api/weshop/users/get/" + oo.stoid + "/" + user.user_id, {
358   - data: {r: Math.random()},
359   - success: function (e) {
360   - getApp().globalData.userInfo = e.data.data;
361   - th.setData({userinfo: e.data.data});
362   -
363   - //选获取地址
364   - th.getuser_addr(function (addr) {
365   - th.setData({user_addr: addr});
366   - //--------------------------立即购买------------------
367   - if (ta.is_bnow == 1) {
368   - //读取门店
369   - to.get_allsto(function (e) {
370   - th.setData({allsto: e});
371   - //获取立即购买的商品信息
372   - th.get_buy_goods(ta.goods_id);
373   - });
374   - } else {
375   - //------------------------购物车结算----------------------
376   - //读取门店
377   - to.get_allsto(function (e) {
378   - th.setData({allsto: e});
379   - //-------获取购物车已经选择的商品--------
380   - th.get_cart();
381   - })
382   - }
383   - });
  320 + var th = this,
  321 + to = getApp();
  322 + th.setData({
  323 + userinfo: to.globalData.userInfo,
  324 + });
  325 + //选获取地址
  326 + th.getuser_addr(function (addr) {
384 327  
385   - //获取提现金额
386   - getApp().request.get("/api/weshop/withdrawals/summoney", {
387   - data: {user_id: to.globalData.user_id, store_id: oo.stoid, status: 0},
388   - success: function (su) {
389   - if (su.data.code == 0) {
390   - var yuer = parseFloat(th.data.userinfo.user_money -
391   - (th.data.userinfo.frozen_money > 0 ? th.data.userinfo.frozen_money : 0) - su.data.data.summoney).toFixed(2);
392   - th.setData({txmon: su.data.data.summoney, yuer: yuer});
393   - }
394   - }
  328 + if (addr == null || addr == undefined || addr.length == 0) {
  329 + th.setData({
  330 + enterAddressPage: 1,
395 331 });
396 332  
  333 + } else {
  334 + th.setData({
  335 + user_addr: addr, enterAddressPage: 0,
  336 + });
  337 + }
  338 + //获取立即购买的商品信息
  339 + th.get_buy_goods(th.data.order_id,th.data.order_sn);
  340 + });
  341 + //获取提现金额
  342 + getApp().request.get("/api/weshop/withdrawals/summoney", {
  343 + data: {
  344 + user_id: to.globalData.user_id,
  345 + store_id: oo.stoid,
  346 + status: 0
397 347 },
  348 + success: function (su) {
  349 + console.log("withdrawals");
  350 + if (su.data.code == 0) {
  351 + var yuer = parseFloat(th.data.userinfo.user_money -
  352 + th.data.userinfo.frozen_money - su.data.data.summoney).toFixed(2);
  353 + th.setData({
  354 + txmon: su.data.data.summoney,
  355 + yuer: yuer
  356 + });
  357 + }
  358 + }
398 359 });
399   -
400 360 },
401 361  
  362 + //-----获取商品------
  363 + async get_buy_goods(ord,o_sn) {
  364 + var order = null,
  365 + order_goods = null,
  366 + goods = null,
  367 + pickup = null,
  368 + distr_type = 0,
  369 + exp_type = 0,
  370 + presell=null, //订单从表
  371 + pre_arr=null, //订单内容
  372 + th = this;
  373 +
  374 +
  375 + if(o_sn){
  376 + //获取order信息根据订单编号order_sn
  377 + await getApp().request.promiseGet("/api/weshop/order/page", {
  378 + data: { store_id: os.stoid, order_sn: o_sn,}
  379 + }).then(res => {
  380 + order = res.data.data.pageData[0];
  381 + })
  382 +
402 383  
403   - //-----真的获取购物车,入口--------
404   - get_cart: function () {
405   - var th = this, app = getApp();
406   - a.get("/api/weshop/cart/list", {
  384 + ord=order.order_id;
  385 + }else{
  386 + //---获取订单---
  387 + await getApp().request.promiseGet("/api/weshop/order/get/" + oo.stoid + "/" + ord, {}).then(res => {
  388 + order = res.data.data;
  389 + });
  390 + }
  391 + //---获取订单从表---
  392 + await getApp().request.promiseGet("/api/weshop/ordergoods/page", {
407 393 data: {
408   - user_id: to.globalData.user_id, selected: 1, state: 0,
409   - store_id: oo.stoid, pageSize: 600
410   - },
411   - success: async function (su) {
412   - //按门店分类的数组
413   - var arr = new Array();
414   - var carr = su.data.data.pageData;
415   - th.data.cartlist_y = carr; //存储原始购物车列表
416   -
417   - //---是不是购买等级卡成功的返回---等级卡显示的判断---
418   - var is_card_back = getApp().globalData.is_card_back;
419   -
420   - for (var i = 0; i < carr.length; i++) {
421   - var item1 = carr[i];
422   - //把已经购买了多少见的内容填入
423   -
424   - var goodsbuynum=0,promgoodsbuynum=0;
425   - //--要获得商品,该用户买了多少件,同步应用--
426   - await getApp().request.promiseGet("/api/weshop/ordergoods/getUserBuyGoodsNum", {
427   - data: {
428   - store_id: os.stoid,
429   - user_id: getApp().globalData.user_id,
430   - goods_id: item1.goods_id,
431   - prom_type: item1.prom_type,
432   - prom_id: item1.prom_id
433   - },
434   - }).then(res => {
435   - var buy_num_data = res.data.data;
436   - if (buy_num_data.promgoodsbuynum) {
437   - promgoodsbuynum = buy_num_data.promgoodsbuynum;
438   - }
439   - goodsbuynum = buy_num_data.goodsbuynum;
440   - })
441   - //如果有购买活动
442   - item1.promgoodsbuynum=promgoodsbuynum;
443   -
444   - //要把优惠活动加入,prom_goods_map中,赠品不要运算
445   - if (item1.prom_type == 3 && item1.is_gift != 1) {
446   - await th.add_prom_goods_map(item1);
447   - }
  394 + store_id: oo.stoid,
  395 + order_id: ord
  396 + }
  397 + }).then(res => {
  398 + order_goods = res.data.data.pageData[0];
  399 + });
448 400  
449   - //要把组合购的东西拿出来算一下
450   - if (item1.prom_type == 7) {
451   - var isok = 1;
452   - //如果有组合购
453   - var url = "/api/weshop/prom/zhbuy/get/" + os.stoid + "/" + item1.prom_id+'/'+getApp().globalData.userInfo.user_id;
454   - await getApp().request.promiseGet(url, {}).then(res => {
455   - if (res.data.code == 0 && res.data.data) {
456   - //如果活动已经结束
457   - if (res.data.data.is_end == 1) {
458   - isok = 0;
459   - }
460   - if (ut.gettimestamp() > res.data.data.end_time) {
461   - isok = 0;
462   - }
463   - } else {
464   - //未找到商品的活动
465   - isok = 0;
466   - }
467   - item1.act = res.data.data;
468   - })
469 401  
470   - if (!isok) {
471   - getApp().my_warnning("组合购的活动已经过期", 0, th);
472   - return false;
473   - }
  402 + var pre_data = { store_id: os.stoid, is_end: 0, timetype: 1, isuse: 1, goods_id: order_goods.goods_id };
  403 + pre_data.user_id = order.user_id;
  404 + var isok=1;
  405 + await getApp().request.promiseGet("/api/weshop/marketing/marketingPresellList/page", {
  406 + data: pre_data,
  407 + }).then(e => {
  408 + if (e.data.code == 0 && e.data.data.pageData && e.data.data.pageData.length > 0) {
  409 + pre_arr = e.data.data.pageData[0];
  410 + }else{
  411 + isok=0;
  412 + }
  413 + })
  414 + if(!isok){
  415 + getApp().confirmBox("活动已经结束,或者会员身份不符合");
  416 + return false;
  417 + }
474 418  
475   - }
476   - }
477 419  
478   - //在分组的时候,就不要再调用接口,await
479   - for (var i = 0; i < carr.length; i++) {
480   - var item = carr[i];
481   -
482   - //-- 如果是等级会员注册返回 --
483   - if (is_card_back) {
484   - th.data.card_name = th.data.userinfo.card_field;
485   - //如果是秒杀的返回,就要把活动弄回0
486   - if (item['prom_type'] == 1) {
487   - item['prom_type'] = 0;
488   - item['prom_id'] = 0;
489   - }
490   - // 拼团,搭配购不计算,赠品也不计算
491   - if (item['prom_type'] != 5 && item['prom_type'] != 6 && !item.is_gift && !item['is_collocation'] && item.goods_price > item[th.data.card_name]) {
492   - item.goods_price = item[th.data.card_name];
493   - carr[i].goods_price = item[th.data.card_name];
494 420  
495   - }
496   - } else {
497   - // 拼团,搭配购不计算,赠品也不计算,同时会员还未购买等级会员
498   - if (item[th.data.card_name] > 0 && item['prom_type'] != 5 && item['prom_type'] != 6 && !th.data.userinfo.card_field
499   - && !item.is_gift && !item['is_collocation'] && item.goods_price > item[th.data.card_name]) {
500   - item.cut_price1 = item.goods_price - item[th.data.card_name];
501   - carr[i].cut_price1 = (item.goods_price - item[th.data.card_name]) * item.goods_num;
502   - }
503 421  
504   - }
  422 + await getApp().request.promiseGet("/api/weshop/order/orderPresell/get/"+oo.stoid+"/"+order.order_id, {}).then(res => {
  423 + presell = res.data.data;
  424 + });
505 425  
506   - item.original_img = oo.imghost + item.original_img;
507   -
508   - var car_item=item;
509   - /*----接口要弄出来的,先顶着-----*/
510   - var pcid = car_item.pick_id;
511   - var find = 0;
512   - //----如果有就加进去,没有就新增一个----
513   - //-----------循环查找门店-------------
514   - if (arr.length > 0) {
515   - for (var j = 0; j < arr.length; j++) {
516   - if (arr[j].pickup_id == pcid) {
517   - //if(item.is_gift!=1){
518   - //确定配送方式
519   - if (arr[j].distr_t == 0) {
520   - arr[j].distr_t = car_item.distr_type;
521   - }
522   - var e_t = 0
523   - switch (arr[j].distr_t) {
524   - case 0:
525   - e_t = 1;
526   - if (th.data.json_d.pickupway && th.data.json_d.pickupway == 1) e_t = 0;
527   - break;
528   - case 1:
529   - e_t = 1;
530   - break;
531   - case 2:
532   - e_t = 0;
533   - break;
534   - }
535   - arr[j].exp_type = e_t;
536   - if (e_t == 0) th.setData({is_all_zt: 0});
537   - //}
  426 + //等待定金
  427 + if(order.order_status<2 && presell.deposit_pay_time<=0 ){
  428 + th.setData({wait_dj:1})
  429 + }
  430 + //等待尾款
  431 + if(order.order_status<2 && presell.deposit_pay_time>0 && presell.tail_pay_state==0 && presell.presell_type!=1){
  432 + th.setData({wait_wk:1})
  433 + wx.setNavigationBarTitle({title: "支付尾款",})
  434 + }
  435 + //等待发货
  436 + if(order.pay_status==1 && order.shipping_status==0){
  437 + th.setData({wait_fh:1})
  438 + }
538 439  
539   - //-- 把等级卡会优惠多少钱装进去 --
540   - if (car_item.cut_price1) arr[j].card_cut_price += car_item.cut_price1;
  440 + if(order.pay_status==1 && order.shipping_status==1 && order.order_status<2){
  441 + th.setData({wait_sh:1})
  442 + }
541 443  
542   - arr[j].goods.push(car_item);
543   - find = 1;
544   - break;
545   - }
546   - }
547   - }
548   - //------如果没有找到-----
549   - if (find == 0) {
550   - var pikname = '', sto = null;
551   - //----找到门店名称-----
552   - for (var k = 0; k < th.data.allsto.length; k++) {
553   - if (pcid == th.data.allsto[k].pickup_id) {
554   - pikname = th.data.allsto[k].pickup_name;
555   - sto = th.data.allsto[k];
556   - break;
557   - }
558   - }
559   - var e_t = 0, dis_t = 0;//物流方式,配送方式
560   - if (item.distr_type == 0) {
561   - dis_t = sto.distr_type;
562   - } else {
563   - dis_t = item.distr_type;
564   - }
565   - switch (dis_t) {
566   - case 0:
567   - e_t = 1;
568   - //-- 系统后台有设置要默认的 --
569   - if (th.data.json_d.pickupway && th.data.json_d.pickupway == 1) e_t = 0;
570   - break;
571   - case 1:
572   - e_t = 1;
573   - break;
574   - case 2:
575   - e_t = 0;
576   - break;
577   - }
578   - //如果是物流的话,全部自提的控制要弄成0
579   - if (e_t == 0) th.setData({is_all_zt: 0});
580   -
581   - var narr = new Array();
582   - narr.push(car_item);
583   -
584   - //-----------拼装购物车结算的数组,如果有默认物流时要用默认物流编号,计算默认的物流,不管是不是自提都算一下-----------------
585   - var m_wind = 0, def_exp_code = getApp().globalData.userInfo.def_exp_code;
586   - if (def_exp_code) {
587   - for (var k = 0; k < th.data.wu_arr.length; k++) {
588   - var item = th.data.wu_arr[k];
589   - if (def_exp_code == item.code) {
590   - m_wind = k;
591   - }
592   - }
593   - }
594 444  
595   - var ie = {
596   - pickup_id: pcid,
597   - pname: pikname,
598   - goods: narr,
599   - wind: m_wind,
600   - distr_t: dis_t,
601   - card_cut_price: 0,
602   - exp_type: e_t,
603   - goods_price: 0,
604   - shipping_price: 0,
605   - user_money: 0,
606   - total_amount: 0,
607   - order_amount: 0,
608   - user_note: 0
609   - };
610   -
611   - //-- 把等级卡会优惠多少钱装进去 --
612   - if (car_item.cut_price1) ie.card_cut_price += car_item.cut_price1;
613   - arr.push(ie);
  445 + //---获取商品---
  446 + await getApp().request.promiseGet("/api/weshop/goods/get/" + oo.stoid + "/" + order_goods.goods_id, {}).then(res => {
  447 + goods = res.data.data;
  448 + order.market_price = goods.market_price;
  449 + order.show_img = oo.imghost + goods.original_img;
  450 + });
  451 + //判断使用优惠券的接口需要
  452 + th.data.check_quan_ware_list = goods.erpwareid;
  453 + //---获取门店---
  454 + await getApp().request.promiseGet("/api/weshop/pickup/get/" + oo.stoid + "/" + order.pickup_id, {}).then(res => {
  455 + pickup = res.data.data;
  456 + });
614 457  
  458 + order['is_all_return'] = 0;
  459 + //------------对比一下有没有退款记录------------
  460 + await getApp().request.promiseGet("/api/weshop/order/returngoods/page",{
  461 + data: { order_id: order.order_id, store_id: oo.stoid,
  462 + user_id:order.user_id, pageSize: 200 }
  463 + }).then(rss=>{
  464 + var ttd=rss;
  465 + //----没有相关的退款记录----
  466 + if (ttd.data.data.total==0){
  467 + order['is_all_return'] = 0;
  468 + }else{
  469 + var eea = ttd.data.data.pageData[0];
  470 + //1.退款正在进行中,
  471 + //2.退款被拒绝就要显示可以退款
  472 + //3.退款已经完成
  473 + order['is_all_return']=1;
  474 + order['is_all_return_status'] = ttd.data.data.pageData[0].status;
  475 +
  476 + if (order['order_status'] == 1 && order['pay_status'] == 1) {
  477 + switch (eea.status) {
  478 + case 0:
  479 + case 1:
  480 + order.order_status_detail="退款中";
  481 + order['return_btn'] = 2; break;
  482 + case 2:
  483 + order.order_status_detail="退款完成";
  484 + order['return_btn'] = 4; break;
  485 + case 3:
  486 + order['return_btn'] = 3; break;
  487 + default:
  488 + order['return_btn'] = 0;
615 489 }
616 490 }
617   - //-- 如果是回退回来的情况 --
618   - if (th.data.cartlist && th.data.cartlist.length > 0) {
619   - for (var kj in th.data.cartlist) {
620   - for (var ih in arr) {
621   - var ie = arr[ih];
622   - if (ie.pickup_id == th.data.cartlist[kj].pickup_id) {
623   - ie.exp_type = parseInt(th.data.cartlist[kj].exp_type);
624   - ie.wind = parseInt(th.data.cartlist[kj].wind);
625   - break;
626   - }
627   - }
628   - }
629   - }
  491 + }
  492 + })
630 493  
631   - //-- 循环计算一下线下取价 --
632   - for (var k = 0; k < arr.length; k++) {
633   - var c_item = arr[k];
634   - var item = arr[k].goods;
635   - var offline_price = 0;
636   - var offline_num = 0;
637   - for (var c = 0; c < item.length; c++) {
638   - if(th.data.sales_rules!=2){
639   - item[c].offline_price=0;
640   - }
641   - //-- 如果这个商品是线下取价的时候 --
642   - if (item[c].offline_price > 0 && item[c].prom_type != 7 ) {
643   - offline_price += (item[c].goods_price - item[c].offline_price) * item[c].goods_num;
644   - offline_num += item[c].goods_num;
645   - }
646   - }
647   - if (offline_price > 0) {
648   - c_item.offline_price = offline_price;
649   - c_item.offline_num = offline_num;
650   - c_item.is_offline = 1;
651   - }
652   - }
  494 + var price=presell.presell_price;
  495 + if(!goods) return false;
  496 + //--判断物流--
  497 + if (goods.distr_type)
  498 + distr_type = goods.distr_type;
  499 + else
  500 + distr_type = pickup.distr_type;
  501 +
  502 + switch (distr_type) {
  503 + case 0:
  504 + exp_type = 1;
  505 + //-- 系统后台有设置要默认的 --
  506 + if (th.data.sys_switch.pickupway && th.data.sys_switch.pickupway == 1) exp_type = 0;
  507 + break; //自选
  508 + case 1:
  509 + exp_type = 1;
653 510  
654   - //每一个门店内的组合购要进行拆分,
655   - //还得把组合商品的多余商品的线下价格算一算
656   - for (let var1 in arr) {
657   - var u_item = arr[var1];
658   - //把组合购进行分组
659   - var obj = zh_calc.find_split(u_item);
660   - if (!obj) continue;
661   - //存储不同活动的商品列表
662   - u_item.zh_prom_goods = {};
663   - for (let var1 in obj) {
664   - var h_item = obj[var1];
665   - var gdlist = null;
666   - var url1 = "/api/weshop/prom/zhbuyGoods/page";
667   - var req_data = {
668   - page: 1,
669   - pageSize: 2000,
670   - store_id: os.stoid,
671   - zh_id: h_item.prom_id,
672   - }
673   - await getApp().request.promiseGet(url1, {
674   - data: req_data
675   - }).then(res => {
676   - if (ut.ajax_ok(res)) {
677   - gdlist = res.data.data.pageData;
678   - }
679   - })
680   - //获取活动需要的商品列表
681   - u_item.zh_prom_goods[h_item.prom_id] = {gdlist: gdlist, act: h_item.act};
682   - }
683   - zh_calc.fir_set_arr(u_item, th);
684   - }
685   - //深拷贝
686   - th.data.old_cartlist = JSON.parse(JSON.stringify(arr));
687   - th.setData({
688   - cartlist: arr,
689   - });
690   - //--- 获取一下看有没有优惠券 ----
691   - setTimeout(function () {
692   - var frozenQuan = null;
693   - var url0 = "/api/weshop/users/frozenQuan/listFrozenQuan/" + app.globalData.user_id;
694   - app.request.promiseGet(url0, {1: 1}).then(res => {
695   - if (res.data.code == 0) {
696   - frozenQuan = res.data.data;
697   - th.data.frozenQuan = frozenQuan;
698   - }
699   - th.calculatePrice();
700   - th.get_cart_quan();
701   - })
  511 + break //自提
  512 + case 2:
  513 + exp_type = 0;
  514 + break; //物流
  515 + }
702 516  
703   - }, 500)
  517 + //等待发货的时候
  518 + if(th.data.wait_fh){
  519 + var send_time=pre_arr.delivery_date;
  520 + if(pre_arr.delivery_type==2){
  521 + send_time=pre_arr.delivery_daynum*3600;
  522 + }
704 523  
705   - }
  524 + }
  525 +
  526 +
  527 + order.order_goods = order_goods;
  528 + var tail_pay=pre_arr.presell_price*order_goods.goods_num-presell.presell_deposit;
  529 + this.setData({
  530 + order: order,
  531 + distr_type: distr_type,
  532 + pickup: pickup,
  533 + exp_type: exp_type,
  534 + goods: goods,
  535 + presell:presell,
  536 + pre_arr:pre_arr,
  537 + show_submit:1,
  538 + userInfo:getApp().globalData.userInfo,
  539 + tail_pay:tail_pay,
  540 + order_goods:order_goods,
  541 + all_price:pre_arr.presell_price*order_goods.goods_num,
  542 + pickup_id:pickup.pickup_id,
  543 + send_time:send_time
706 544 });
  545 + th.get_diff();
  546 + //统一进行计算金额
  547 + th.calculatePrice2();
  548 + //如果可以
  549 + if(pre_arr.is_usecoupon){
  550 + th.get_buy_now_quan();
  551 + }
707 552 },
708 553  
709   - //-----获取立即购买的商品信息,入口----
710   - get_buy_goods: function (e) {
711   - var th = this;
712   - var gg = to.get_b_now();
713   - //--------如果goods_id一样,就是要立即购买-----
714   - if (e == gg.goods_id) {
715   - a.get("/api/weshop/goods/get/" + oo.stoid + "/" + e, {
716   - success: async function (t) {
717   - var gd = t.data.data;
718   - if (!gd) return false;
719   -
720   - t.data.data.original_img = oo.imghost + t.data.data.original_img;
721   - t.data.data['buynum'] = gg.goods_num;
722   - var distr_t = 0, et = 0
723   - if (t.data.data.distr_type == 0) {
724   - distr_t = gg.pick_dis;
725   - } else {
726   - distr_t = t.data.data.distr_type;
727   - }
728 554  
729   - switch (distr_t) {
730   - case 0:
731   - et = 1;
732   - //-- 系统后台有设置要默认的 --
733   - if (th.data.json_d.pickupway && th.data.json_d.pickupway == 1) et = 0;
734   - break;
735   - case 1:
736   - et = 1;
737   - break;
738   - case 2:
739   - et = 0;
740   - break;
  555 + async calculatePrice2(){
  556 + var th=this;
  557 + if(!this.data.pre_arr) return false;
  558 + //--计算物流--
  559 + if (this.data.exp_type == 0) {
  560 + this.calculate_wuliu();
  561 + } else {
  562 + var allpice =this.data.pre_arr.presell_price*this.data.order_goods.goods_num;
  563 + allpice = allpice.toFixed(2);
  564 + //--看一下有没有订单优惠--
  565 + var o_condition = parseFloat(allpice);
  566 + //---如果有选择优惠券的情况下---
  567 + var quan_price = 0, bn_pick = th.data.pickup.pickup_id;
  568 + var quan_no = null;
  569 + if (th.data.using_quan[bn_pick] != null && th.data.using_quan[bn_pick] != undefined)
  570 + quan_no = th.data.using_quan[bn_pick].coupon_no;
  571 + //-- 如果使用的券不是包邮券的时候 --
  572 + if (quan_no && th.data.using_quan[bn_pick].isby != 1) {
  573 + //---获取优惠券优惠---
  574 + await getApp().request.promiseGet("/api/weshop/couponList/getUseCouponPrice", {
  575 + data: {
  576 + storeId: oo.stoid,
  577 + CashRepNo: quan_no,
  578 + WaresSum: th.data.ckeck_quan_price,
  579 + WareIds: th.data.check_quan_ware_list
741 580 }
742   -
743   -
744   - var m_wind = 0, def_exp_code = getApp().globalData.userInfo.def_exp_code;
745   - if (et == 0 && def_exp_code) {
746   - for (var k = 0; k < th.data.wu_arr.length; k++) {
747   - var item = th.data.wu_arr[k];
748   - if (def_exp_code == item.code) {
749   - m_wind = k;
750   - }
751   - }
  581 + }).then(res => {
  582 + if (res.data.code == 0 && res.data.data && res.data.data.length > 0) {
  583 + quan_price = res.data.data[0].WareCashSum;
752 584 }
  585 + })
  586 + }
753 587  
754   - if (th.data.bn_goods) {
755   - et = th.data.bn_exp_type;
756   - m_wind = th.data.index;
  588 + if(quan_price>0){
  589 + if (quan_price < o_condition) th.setData({quan_price: quan_price})
  590 + else {
  591 + th.setData({quan_price: o_condition})
757 592 }
  593 + o_condition=o_condition-quan_price;
758 594  
759   - //---是不是购买等级卡成功的返回---等级卡显示的判断---
760   - var is_card_back = getApp().globalData.is_card_back;
761   - if (is_card_back) {
762   - th.data.card_name = th.data.userinfo.card_field;
763   - gg.goods_price = gd[th.data.card_name];
764   - getApp().globalData.is_card_back = 0;
765   - th.setData({card_cut_price: 0});
766   - //如果是秒杀的返回
767   - if (gd.prom_type == 1) gd.prom_type = 0;
768   - } else {
769   - //--- 商家等级卡开通的情况下, 会员不是等级会员的情况, 商品有设置等级卡价格,同时等级卡价格小于商品的价格
770   - //-- 搭配购的商品也可以单独购买,所以此时搭配购的商品要进行计算优惠 --
771   - 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) {
772   - var cut_p = (gg.goods_price - gd[th.data.card_name]) * gg.goods_num;
773   - th.setData({card_cut_price: cut_p});
  595 + }else{
  596 + th.setData({quan_price: 0})
  597 + }
  598 + if(o_condition<0) o_condition=0;
  599 +
  600 + //如果同意参与订单优惠
  601 + if (o_condition > 0 && this.data.pre_arr.is_useorderyh) {
  602 + th.check_is_order_prom(o_condition, function () {
  603 + var bn_pick=th.data.pickup.pickup_id
  604 + var order_prom_amount = 0;
  605 + var order_prom_id = 0;
  606 + if (th.data.order_prom[bn_pick]) {
  607 + var ord_prom = th.data.order_prom[bn_pick];
  608 + order_prom_id = ord_prom['id'];
  609 + switch (ord_prom['type']) {
  610 + case 0:
  611 + o_condition = Math.round(o_condition * ord_prom['expression']) / 100;//满额打折
  612 + order_prom_amount = (o_condition - order_m).toFixed(2);
  613 + break;
  614 + case 1:
  615 + o_condition = o_condition - ord_prom['expression'];//满额优惠金额
  616 + order_prom_amount = ord_prom['expression'];
  617 + break;
774 618 }
775 619 }
776   -
777   - switch (gd.prom_type) {
778   - case 0:
779   - case 2:
780   - case 3:
781   - case 4:
782   - case 5:
783   - case 6:
784   - case 7:
785   - //--此时开始计算商品的使用券相关,如果有等级价还要计算和等级价相关的,
786   - // 如果有优惠促销,还要把促销的部分计算在内,因为促销还有不能使用优惠券--
787   - t.data.data.shop_price = gg.goods_price;
788   - t.data.data.goods_price = gg.goods_price;
789   - t.data.data.goods_num = gg.goods_num;
790   - th.data.ckeck_quan_price = t.data.data.shop_price * gg.goods_num;
791   - th.data.check_quan_price_list = t.data.data.shop_price * gg.goods_num + "";
792   - th.data.check_quan_ware_list = t.data.data.erpwareid + "";
793   -
794   - //-- 如果有线下取价的时候 --
795   - if (gg.offline_price) {
796   - t.data.data.offline_price = gg.offline_price;
797   - t.data.data.pricing_type = gg.pricing_type;
798   - t.data.data.is_offline = 1;
799   -
800   - th.data.ckeck_quan_price = t.data.data.offline_price * gg.goods_num;
801   - th.data.check_quan_price_list = t.data.data.offline_price * gg.goods_num + "";
802   - th.data.check_quan_ware_list = t.data.data.erpwareid + "";
803   - }
804   -
805   - t.data.data.prom_id = 0;
806   - t.data.data.prom_type = 0;
807   -
808   - //如果立即购买那边过来,就要读取接口,查看活动的优惠内容
809   - if (gg.prom_type == 3) {
810   - t.data.data.prom_id = gg.prom_id;
811   - t.data.data.prom_type = 3;
812   - //如果是优惠活动,就要调用活动,计算价格
813   - th.buy_now_prom_goods(gg.prom_id, t.data.data, function (data) {
814   - //判断一下购买商品的数量是不是超过
815   - if (data.gift_goods_id) {
816   - var num = 1;
817   - if (data.is_bz == 1) {
818   - num = data.bs;
819   - if (num > data.gift_limit_num) num = 0;
820   - }
821   - //如果赠品数量超出礼品库存,就取消
822   - if (num > data['gift_storecount']) num = 0;
823   - if (num > 0) {
824   - var ob = {};
825   - ob.is_gift = 1;
826   - ob.prom_id = data.prom_id;
827   - ob.goods_id = data.gift_goods_id;
828   - ob.goods_name = data.gift_goods_name;
829   - ob.goods_color = data.gift_goods_color;
830   - ob.goods_spec = data.gift_goods_spec;
831   - ob.original_img = os.imghost + data.gift_original_img;
832   - ob.market_price = data.gift_market_price;
833   - ob.gift_id = data.gift_id;
834   - ob.shop_price = 0;
835   - ob.buynum = num;
836   - ob.weight = data.gift_weight; //商品的重量
837   - ob.exp_sum_type = data.gift_exp_sum_type; //商品的物流计算方式
838   - ob.uniform_exp_sum = data.gift_uniform_exp_sum //统一运费的金额
839   -
840   - th.setData({buy_now_gift_goods: ob});
841   - }
842   - }
843   -
844   - th.setData({
845   - bn_goods: data, bn_pickname: gg.pick_name, index: m_wind,
846   - bn_pick: gg.pick_id, bn_t_exp_t: distr_t, bn_exp_type: et
847   - });
848   -
849   - //计算价格
850   - th.calculatePrice2();
851   - //获取优惠券
852   - th.get_buy_now_quan();
853   -
854   - })
855   - } else {
856   - //--看是不是搭配促销--
857   - if (gg.prom_type == 5) {
858   - t.data.data.prom_id = gg.prom_id;
859   - t.data.data.prom_type = 5;
860   - if (gg.room_id) {
861   - t.data.data.room_id = gg.room_id;
862   - }
863   - //--主商品要有导购id和导购类型--
864   - if (gg.guide_id) {
865   - t.data.data.guide_id = gg.guide_id;
866   - t.data.data.guide_type = gg.guide_type;
867   - }
868   - th.setData({collocation_goods: gg.collocation_goods});
869   -
870   - var cart_arr = new Array();
871   - //var narr=gg.collocation_goods;
872   - //修改成深拷贝,确保返回是数据正确
873   - var narr = JSON.parse(JSON.stringify(gg.collocation_goods));
874   -
875   - narr.push(t.data.data);
876   -
877   - //-- 搭配促销的门店配送方式的修复 --
878   - et = 1;
879   - distr_t = 0;
880   - for (var hi in narr) {
881   - var dis_t = narr[hi].distr_type;
882   - if (dis_t == 2) {
883   - th.setData({is_all_zt: 0});
884   - et = 0;
885   - }
886   - if (dis_t > 0) {
887   - distr_t = dis_t;
888   - }
889   - }
890   -
891   - //自选的时候,系统配置了默认的配送方式是物流的时候
892   - if (distr_t == 0 && th.data.json_d.pickupway && th.data.json_d.pickupway == 1) {
893   - et = 0;
894   - }
895   -
896   -
897   - var ie = {
898   - pickup_id: gg.pick_id,
899   - pname: gg.pick_name,
900   - goods: narr,
901   - exp_type: et,
902   - wind: m_wind,
903   - distr_t: distr_t,
904   - bn_t_exp_t: distr_t,
905   - goods_price: 0,
906   - shipping_price: 0,
907   - user_money: 0,
908   - total_amount: 0,
909   - order_amount: 0,
910   - user_note: 0
911   - };
912   - cart_arr.push(ie);
913   - th.data.old_cartlist = cart_arr;
914   - }
915   - th.setData({
916   - bn_goods: t.data.data, bn_pickname: gg.pick_name, index: m_wind,
917   - bn_pick: gg.pick_id, bn_t_exp_t: distr_t, bn_exp_type: et
918   - });
919   -
920   -
921   - //--搭配促销也是按照购物车的方式来计算优惠券--
922   - if (gg.prom_type == 5) {
923   - var frozenQuan = null;
924   - var url0 = "/api/weshop/users/frozenQuan/listFrozenQuan/" + app.globalData.user_id;
925   - app.request.promiseGet(url0, {1: 1}).then(res => {
926   - if (res.data.code == 0) {
927   - frozenQuan = res.data.data;
928   - th.data.frozenQuan = frozenQuan;
929   - }
930   - //计算价格
931   - th.calculatePrice2();
932   - th.get_cart_quan();
933   - });
934   - } else {
935   - //计算价格
936   - th.calculatePrice2();
937   - //获取优惠券,
938   - th.get_buy_now_quan();
939   - }
940   - }
941   -
942   - break;
943   - case 1: //---秒杀-----
944   - var quanlist = null;
945   - getApp().request.get("/api/weshop/activitylist/getSJGoodsPrice/" + gd.store_id
946   - + "/" + gd.goods_id + "/1/" + gd.prom_id, {
947   - success: async function (tt) {
948   - if (tt.data.code == 0) {
949   - t.data.data.shop_price = tt.data.data.prom_price;
950   - } else {
951   - t.data.data.prom_id = 0;
952   - t.data.data.prom_type = 0;
953   -
954   - th.data.ckeck_quan_price = t.data.data.shop_price * gg.goods_num;
955   - th.data.check_quan_price_list = t.data.data.shop_price * gg.goods_num + "";
956   - th.data.check_quan_ware_list = t.data.data.erpwareid + "";
957   - }
958   -
959   - th.setData({
960   - bn_goods: t.data.data,
961   - bn_pickname: gg.pick_name,
962   - bn_exp_type: et,
963   - index: m_wind,
964   - bn_pick: gg.pick_id,
965   - bn_t_exp_t: distr_t,
966   - bn_exp_type: et
967   - });
968   -
969   - //计算价格
970   - th.calculatePrice2();
971   - //获取优惠券,如果有券的钱,就调用
972   - if(th.data.ckeck_quan_price>0) th.get_buy_now_quan();
973   - }
974   - });
975   -
976   - break;
  620 + //--订单优惠的显示--
  621 + if (order_prom_id > 0) {
  622 + var order_prom_txt1 = "order_prom_id";
  623 + var order_prom_txt2 = "order_prom_amount";
  624 + th.setData({[order_prom_txt1]: order_prom_id, [order_prom_txt2]: order_prom_amount})
977 625 }
978   - },
979   - });
  626 + th.setData({ exp_price: 0, order_m: o_condition })
  627 + })
  628 + }else{
  629 + th.setData({ exp_price: 0, order_m: o_condition })
  630 + }
980 631 }
981 632 },
982 633  
... ... @@ -1010,7 +661,8 @@ Page({
1010 661 },
1011 662 keyUpChangeNum: function (t) {
1012 663 this.setData({
1013   - maxWord: t.detail.value.length
  664 + maxWord: t.detail.value.length,
  665 + user_note:t.detail.value
1014 666 });
1015 667 },
1016 668  
... ... @@ -1176,2618 +828,1763 @@ Page({
1176 828 }
1177 829 },
1178 830  
1179   - //-------------------计算订单价格-------------------
1180   - calculatePrice: function (t, s) {
  831 + set_can_num: function () {
1181 832 var th = this;
1182   - to.getConfig2(function (ee) {
1183   - to.getwuliuprice(async function (rs) {
1184   - wx.showLoading({
1185   - title: "处理中."
1186   - })
1187   - var all_price = 0; //所有的商品总价
1188   - var all_shipping_m = 0; //所有的物流总价
1189   - var all_total_m = 0; //所有的订单应付总价
1190   - var all_order_m = 0; //所有的订单应付总价
1191   - var all_user_m = 0; //所有的订单用户使用金额
1192   - var all_coupon_price_m = 0; //所有的订单用户使用优惠券价格
1193   - var all_cutprice = 0; //所有的优惠减
1194   - var all_zh_cutprice = 0; //所有的组合优惠减
1195   - var all_order_prom = 0; //所有的订单优惠
1196   -
1197   - var umoney = th.data.userinfo.user_money - th.data.txmon - (th.data.userinfo.frozen_money ? th.data.userinfo.frozen_money : 0);
1198   - var freight_free = ee.freight_free; //全场满多少包邮
1199   - var no_ex_id = ee.no_ex_id;
1200   - var no_ex_good = null;
1201   - var by_qc = {};
1202   -
1203   - if (no_ex_id && freight_free > 0) {
1204   - //-----------获取不包邮区域,不包邮商品-------
1205   - await getApp().request.promiseGet("/api/weshop/areaFeemail/getAreaGoods", {
1206   - data: {store_id: os.stoid, id: no_ex_id}
1207   - }).then(res => {
1208   - if (res.data.code == 0 && res.data.data && res.data.data.length > 0) {
1209   - by_qc = res.data.data[0];
1210   - }
1211   - })
  833 + //-- 这个地方,循环计算几张优惠券可用--
  834 + for (var iter in th.data.cartlist) {
  835 + var num = 0;
  836 + var c_item = th.data.cartlist[iter];
  837 + var pkid = c_item.pickup_id;
  838 + //-- 普通券 --
  839 + if (c_item.quan_list) {
  840 + for (var iter1 in c_item.quan_list) {
  841 + //判断是不是其他订单有选用
  842 + var is_other_is_use = th.check_other_use(c_item.quan_list[iter1], pkid);
  843 + if (!is_other_is_use) num++;
1212 844 }
1213   - ;
1214   - var c_arr = JSON.parse(JSON.stringify(th.data.old_cartlist));
1215   -
1216   - if (th.data.cartlist && th.data.cartlist.length > 0) {
1217   - for (var i = 0; i < c_arr.length; i++) {
1218   - c_arr[i].exp_type = th.data.cartlist[i].exp_type;
1219   - c_arr[i].wind = th.data.cartlist[i].wind;
1220   - }
  845 + }
  846 + //-- 包邮券 --
  847 + var by_quan = th.data.get_by_quan_list_cart[pkid];
  848 + if (by_quan) {
  849 + for (var iter2 in by_quan) {
  850 + //判断是不是其他订单有选用
  851 + var is_other_is_use = th.check_other_use_by(by_quan[iter2], pkid);
  852 + if (!is_other_is_use) num++;
1221 853 }
  854 + }
  855 + var set_txt = "cartlist[" + iter + "].can_num";
  856 + th.setData({[set_txt]: num});
  857 + }
  858 + },
  859 + useCoupon: function () {
  860 + if (this.data.order.couponNum <= 0) {
  861 + getApp().my_warnning("无可用优惠券", 0, this);
  862 + return;
  863 + }
1222 864  
1223   - //调用函数计算每件商品的单价
1224   - await th.calc_per(c_arr);
1225   - //调用函数计算每件组合购商品的单价,
1226   - await zh_calc.calc_zh_split_price(c_arr,th);
1227   - //调用函数计算,优惠券优惠什么商品价格,优惠券优惠什么商品
1228   - await th.get_cart_quan(c_arr);
1229   - //---循环购物车---
1230   - for (var i in c_arr) {
1231   - //因为搭配购买也是再这里计算,搭配购的is_b_now==1
1232   - if (th.data.is_b_now == 0) {
1233   - //此时物流的选择方式要用th.data.cartlist;
1234   - c_arr[i].exp_type = th.data.cartlist[i].exp_type;
1235   - c_arr[i].wind = th.data.cartlist[i].wind;
1236   - if (th.data.cartlist[i].check_quan_price_list) c_arr[i].check_quan_price_list = th.data.cartlist[i].check_quan_price_list; //优惠券优惠什么商品价格
1237   - if (th.data.cartlist[i].check_quan_ware_list) c_arr[i].check_quan_ware_list = th.data.cartlist[i].check_quan_ware_list; //优惠券优惠什么商品
1238   - } else {
1239   - c_arr[i].exp_type = th.data.bn_exp_type; //配送方式
1240   - c_arr[i].wind = th.data.index; //立即购买选择的物流
1241   - //c_arr[i].=th.data. //立即购买的使用余额
1242   - if (th.data.cartlist) c_arr[i].check_quan_price_list = th.data.cartlist[i].check_quan_price_list; //优惠券优惠什么商品价格
1243   - if (th.data.cartlist) c_arr[i].check_quan_ware_list = th.data.cartlist[i].check_quan_ware_list; //优惠券优惠什么商品
1244   - }
  865 + var a = {
  866 + lid: this.data.coupon ? this.data.coupon.id : "0"
  867 + };
  868 + wx.navigateTo({
  869 + url: "/pages/user/checkcoupon/checkcoupon?" + s.Obj2Str(a)
  870 + });
  871 + },
  872 + enterAddressPage: function () {
  873 + if(!this.data.wait_wk) return false;
1245 874  
1246   - var cart_item = c_arr[i]; //就是每一单的意思
1247   - var pickid = cart_item.pickup_id;
1248   - var o_price = 0;
1249   - var o_price_no_zh=0; //不包含限制优惠叠加组合购的金额汇总
1250   - var o_shipping_price = 0, goods_weight = -1, goods_piece = -1;
1251   - var item = c_arr[i].goods; //就是每一单的从表的意思
1252   -
1253   - //---如果有选择优惠券的情况下---
1254   - var quan_price = 0;
1255   - var coupon_price = 0;
1256   - var quan_no = null;
1257   - var is_has_zh=c_arr[i].is_has_zh;
1258   - var zh_prom_goods=c_arr[i].zh_prom_goods; //组合购计算的原始数据存储空间
1259   -
1260   - if (th.data.using_quan[pickid] != null && th.data.using_quan[pickid] != undefined)
1261   - quan_no = th.data.using_quan[pickid].coupon_no;
1262   -
1263   - //普通券的时候
1264   - if (quan_no && th.data.using_quan[pickid].isby != 1) {
1265   - //---获取优惠券优惠---
1266   - await getApp().request.promiseGet("/api/weshop/couponList/getUseCouponPrice", {
1267   - data: {
1268   - storeId: oo.stoid,
1269   - CashRepNo: quan_no,
1270   - WaresSum: cart_item.check_quan_price_list,
1271   - WareIds: cart_item.check_quan_ware_list
1272   - }
1273   - }).then(res => {
1274   - if (res.data.code == 0 && res.data.data && res.data.data.length > 0) {
1275   - var q_data = res.data.data;
1276   - //--存储商品优惠的内容--
1277   - cart_item.quan_youhui_list = q_data;
1278   - for (var k in q_data)
1279   - quan_price += q_data[k].WareCashSum;
1280   - }
1281   - })
1282   - }
  875 + getApp().globalData.is_cart_old = 1;
  876 + this.data.isget_by_quan = {};
  877 + this.data.enterAddressPage = !0, wx.navigateTo({
  878 + url: "/pages/user/address_list/address_list"
  879 + });
  880 + },
1283 881  
1284   - //--------循环计算总价-----------
1285   - for (var j = 0; j < item.length; j++) {
1286   - if(item[j].prom_type!=7){
1287   - o_price_no_zh += item[j].goods_price * item[j].goods_num;
1288   - }
1289   - //组合购的商品,且有订单优惠的叠加,is_orderyh就是优惠叠加
1290   - else if(zh_prom_goods && zh_prom_goods[item[j].prom_id] && zh_prom_goods[item[j].prom_id].act.is_orderyh )
1291   - {
1292   - o_price_no_zh += item[j].goods_price * item[j].goods_num;
1293   - }
1294   - o_price += item[j].goods_price * item[j].goods_num;
1295   - }
1296   - //判断是不是有组合购的金额
1297   - var f_o_price = o_price;
1298   - //如果又优惠的钱,就要减价
1299   - if (c_arr[i].cut_price > 0){
1300   - o_price -= c_arr[i].cut_price;
1301   - o_price_no_zh-=c_arr[i].cut_price;
1302   - }
1303   - //如果有组合购优惠的钱,就要减价
1304   - if (c_arr[i].zh_cut_price>0 || c_arr[i].zh_cut_price<0){
1305   - o_price -= c_arr[i].zh_cut_price;
1306   - if(o_price_no_zh>0){
1307   - //找到那些可以订单优惠叠加的
1308   - for(let ij in zh_prom_goods){
1309   - let kitem=zh_prom_goods[ij];
1310   - if(kitem.act.is_orderyh) continue;
1311   - o_price_no_zh-=kitem.cut_price;
1312   - }
1313   - }
1314   - }
1315   -
1316   - //-- 计算线下取价的功能 --
1317   - if (cart_item.is_offline == 1) {
1318   - o_price = o_price - cart_item.offline_price;
1319   - o_price_no_zh-=c_arr[i].offline_price;
1320   - }
1321   - //判断包邮券的钱,组合购的商品不使用优惠券
1322   - var q_conditin = 0;
1323   - q_conditin = o_price - quan_price;
1324   - if(is_has_zh){
1325   - q_conditin = o_price_no_zh - quan_price;
1326   - }
1327   - cart_item.goods_price = f_o_price.toFixed(2); //商品总费用,用f_o_price来计算
1328   - //计算物流费用
1329   - cart_item.shipping_price = 0;
1330   -
1331   -
1332   - //--有不包邮区域,且不免运费,全场的计算,要减到优惠金额 和券的金额--
1333   - 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)) {
1334   - //如果有设置不包邮区域的时候
1335   - if (by_qc.region_list != "" && by_qc.region_list != null && by_qc.region_list != undefined) {
1336   - if (th.check_by_area(by_qc.region_list)) {
1337   - freight_free = 0;
1338   - th.data.is_no_by[pickid] = 1;
1339   - }
1340   - }
1341   - //如果有设置不包邮区商品
1342   - if (by_qc.goods_list != "" && by_qc.goods_list != undefined && by_qc != null && freight_free > 0) {
1343   - freight_free = 0;
1344   - no_ex_good = by_qc.goods_list;
1345   - }
1346   - }
1347   -
1348   - //--如果是物流,且选择了地址,就要开始显示包邮券,且包邮券也已经优惠了优惠活动的金额--
1349   - if (cart_item.exp_type == 0 && th.data.user_addr != null) {
1350   - //看是不是有调用过包邮券
1351   - if (!th.data.isget_by_quan[pickid]) {
1352   - //--判断要不要显示包邮券,调用接口,因为有for循环---
1353   - await getApp().request.promiseGet("/api/weshop/userfeemail/pageAndArea", {
1354   - data: {
1355   - store_id: os.stoid,
1356   - isuse: 0,
1357   - condition: q_conditin,
1358   - user_id: getApp().globalData.user_id,
1359   - pageSize: 2000
1360   - }
1361   - }).then(res => {
1362   - if (res.data.code == 0 && res.data.data.total > 0) {
1363   - //此时要循环判断包邮的地区,不包邮商品是不是符合
1364   - var arr = [], quanlist = res.data.data.pageData;
1365   - quanlist = th.check_is_frozenQuan(quanlist, th.data.frozenQuan, 1);
1366   - for (var i in quanlist) {
1367   - var item = quanlist[i];
1368   - var goods = cart_item.goods;
1369   - var g_arr = [];
1370   - for (var ii in goods) {
1371   - g_arr.push(goods[ii].goods_id);
1372   - }
1373   - if (item.region_list && th.check_by_area(item.region_list)) continue; //如果是不包邮区域
1374   - if (item.goods_list) {
1375   - var no_goods_arr = item.goods_list.split(",");
1376   - if (ut.isContained(no_goods_arr, g_arr)) continue; //如果是不包邮商品
1377   - }
1378   - arr.push(item);
1379   - }
1380   - if (arr) {
1381   - th.data.get_by_quan_list_cart[pickid] = arr;
1382   - //th.setData({get_by_quan_list_cart:th.data.get_by_quan_list_cart});
1383   - if (th.data.is_b_now) {
1384   - th.setData({get_by_quan_list: arr});
1385   - }
1386   - }
1387   - th.data.isget_by_quan[pickid] = 1;
1388   - }
1389   - })
1390   - }
1391   - }
1392   -
1393   - //如果是包邮券的时候,要看看券的情况
1394   - if (quan_no && th.data.using_quan[pickid].isby == 1) {
1395   - var quan = th.data.using_quan[pickid];
1396   - if (!quan.goods_list) {
1397   - th.data.is_quan_by[pickid] = 1; //专门给券的判断用的
1398   - } else {
1399   - th.data.is_quan_by[pickid] = 0;
1400   - //看有没有模板的包邮
1401   - if (no_ex_good) {
1402   - var arr = no_ex_good.split(",");
1403   - var arr2 = quan.goods_list.split(",");
1404   - if (ut.isContained(arr, arr2)) {
1405   - getApp().my_warnning("全场不包邮商品和包邮券的重复", 0, th);
1406   - th.data.using_quan[pickid] = {};
1407   - th.setData({using_quan: th.data.using_quan})
1408   - return false;
1409   - }
1410   - var n_arr = ut.mergeArray(arr, arr2);
1411   - no_ex_good = n_arr.join(",");
1412   - } else {
1413   - no_ex_good = quan.goods_list;
1414   - }
1415   - }
1416   - } else {
1417   - th.data.is_quan_by[pickid] = 0; //专门给券的判断用的
1418   - }
1419   -
1420   - //--------循环计算总价-----------
1421   - for (var j = 0; j < item.length; j++) {
1422   - //如果都包邮,都没必要等级数量了
1423   - if (th.data.is_quan_by[pickid]) continue;
1424   - //如果是优惠活动是包邮,就不用计算包邮的费用了
1425   - if (item[j].is_past) continue;
1426   - //是不是不包邮的商品
1427   - var is_good_no_by = 0;
1428   - if (no_ex_good) {
1429   - is_good_no_by = th.check_by_goods(no_ex_good, item[j].goods_id);
1430   - }
1431   -
1432   - //如果达到全场包邮的条件,同时,没有地区不包邮,或者商品不包邮
1433   - if (o_price - quan_price >= freight_free && freight_free > 0 && !is_good_no_by && th.data.is_no_by[pickid] != 1) {
1434   - continue;
1435   - }
1436   -
1437   - //--如果是包邮券使用的情况下,如果商品是包邮的,那么就不进行计算--
1438   - if (th.data.using_quan[pickid] && th.data.using_quan[pickid].isby == 1 && !is_good_no_by) {
1439   - continue;
1440   - }
1441   -
1442   - var no_ex_good_arr = null;
1443   - if (no_ex_good) no_ex_good_arr = no_ex_good.split(',');
1444   -
1445   - //----------------如果是选择了物流---------------------
1446   - 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 )) {
1447   -
1448   - //如果地址不为空
1449   - if (th.data.user_addr != null) {
1450   - switch (item[j]['exp_sum_type']) {
1451   - case 1:
1452   - //统一运费
1453   - o_shipping_price += item[j]['uniform_exp_sum'];
1454   - break;
1455   - case 2:
1456   - +''
1457   - if (goods_weight < 0) goods_weight = 0;
1458   - //累积商品重量 每种商品的重量 * 数量
1459   - goods_weight += item[j]['weight'] * item[j]['goods_num'];
1460   -
1461   - break;
1462   - case 3:
1463   - if (goods_piece < 0) goods_piece = 0;
1464   - //累积商品数量
1465   - goods_piece += item[j]['goods_num'];
1466   - break;
1467   - }
1468   - }
1469   -
1470   - }
1471   - }
1472   -
1473   - //计算物流价格
1474   - if (cart_item.exp_type == 0) {
1475   - //freight_free=0; //后面不在进行判断
1476   - var code = "";
1477   - if (th.data.wu_arr && th.data.wu_arr[cart_item.wind])
1478   - code = th.data.wu_arr[cart_item.wind].code;
1479   - cart_item.shipping_price =
1480   - th.calculatewuliu(code, o_shipping_price, goods_weight,
1481   - goods_piece, th.data.user_addr, freight_free, o_price - quan_price, rs);
1482   -
1483   - if (!th.data.using_quan[pickid] || th.data.using_quan[pickid].isby != 1) {
1484   - if (cart_item.shipping_price == 0) th.data.is_by[pickid] = 1; //已经全场包邮,就不要选择券了
1485   - }
1486   - } else {
1487   - cart_item.shipping_price = 0;
1488   - }
  882 + //--------立即购买时,选择自提和物流----------
  883 + setexptype: function (t) {
  884 + var th = this;
  885 + var ty = t.currentTarget.dataset.t, def_exp_code = getApp().globalData.userInfo.def_exp_code;
  886 + th.setData({bn_exp_type: ty});
  887 + if (ty == 0) {
  888 + th.setData({is_all_zt: 0});
  889 + }
1489 890  
1490   - cart_item.shipping_price = cart_item.shipping_price.toFixed(2);
  891 + //当物流为空的时候。
  892 + if (ty == 0 && th.data.wu_arr == null) {
  893 + th.data.isget_by_quan = {};
  894 + return th.get_wuliu(th.calculatePrice2());
  895 + }
1491 896  
1492   - //总价计算,总价不包含运费
1493   - cart_item.order_amount = (o_price - quan_price).toFixed(2);
1494   - cart_item.total_amount = f_o_price.toFixed(2);
  897 + //--自提就要把包邮券清理掉--
  898 + if (ty == 1) {
  899 + th.data.isget_by_quan = {};
  900 + if (th.data.using_quan[bn_pick] && th.data.using_quan[bn_pick].isby == 1) {
  901 + th.setData({using_quan: {}});
  902 + }
  903 + }
1495 904  
1496   - var order_prom_amount = 0;
1497   - var order_prom_id = 0;
1498   - var o_condition = cart_item.order_amount;
1499   - //看一下是不是不用组合购的订单优惠的叠加
1500   - if(is_has_zh){
1501   - o_condition=o_price_no_zh-quan_price;
  905 + //判断有没有默认的物流地址值
  906 + if (def_exp_code != "" && def_exp_code != null && def_exp_code != undefined) {
  907 + var wu_arr = this.data.wu_arr;
  908 + if (wu_arr != null && wu_arr != "") {
  909 + for (var i = 0; i < wu_arr.length; i++) {
  910 + if (wu_arr[i].shipping_code == def_exp_code) {
  911 + th.setData({index: i});
1502 912 }
  913 + }
  914 + }
  915 + }
  916 + th.calculatePrice2()
1503 917  
1504   - var order_m = 0;
1505   - //---判断是不是有订单优惠---
1506   - await getApp().request.promiseGet("/api/weshop/promorder/getOrderPromotion", {
1507   - data: {store_id: os.stoid, orderAmount: o_condition}
1508   - }).then(res => {
1509   - if (res.data.code == 0) {
1510   - var ord_prom = res.data.data;
1511   - order_prom_id = ord_prom['id'];
1512   - switch (ord_prom['type']) {
1513   - case 0:
1514   - order_m = Math.round(o_condition * ord_prom['expression']) / 100;//满额打折
1515   - order_prom_amount = (o_condition - order_m).toFixed(2);
1516   - break;
1517   - case 1:
1518   - //order_m = o_condition - ord_prom['expression'];//满额优惠金额
1519   - order_prom_amount = ord_prom['expression'];
1520   - break;
1521   - }
1522   - }
1523   - })
1524   -
1525   - cart_item.order_prom_amount = 0;
1526   - //--订单优惠的显示--
1527   - if (order_prom_id > 0) {
1528   - cart_item.order_amount = (o_price - quan_price - order_prom_amount).toFixed(2);
1529   - cart_item.order_prom_id = order_prom_id;
1530   - cart_item.order_prom_amount = order_prom_amount;
1531   - }
1532   - coupon_price = quan_price;
1533   - if (cart_item.order_amount < 0) {
1534   - cart_item.order_amount = 0;
1535   - coupon_price = o_price;
1536   - }
  918 + },
1537 919  
1538   - cart_item.total_amount = parseFloat(cart_item.total_amount) + parseFloat(cart_item.shipping_price); //总金额
1539   - cart_item.order_amount = parseFloat(cart_item.order_amount) + parseFloat(cart_item.shipping_price); //总金额
1540   - cart_item.total_amount = cart_item.total_amount.toFixed(2);
1541   - cart_item.order_amount = cart_item.order_amount.toFixed(2);
  920 + //--------立即购买时,使用余额--------
  921 + set_bn_useyuer: function () {
  922 + var th = this;
  923 + th.setData({bn_use_money: !th.data.bn_use_money});
  924 + th.calculatePrice2();
  925 + },
  926 + //-------------------计算物流---------------
  927 + calculatewuliu: function (code, o_shipping_price, goods_weight,
  928 + goods_piece, user_addr, freight_free, o_price, rs) {
  929 + var price = 0, th = this;
  930 + price += parseFloat(o_shipping_price);
  931 + //如果是包邮
  932 + if (freight_free > 0 && o_price >= freight_free) {
  933 + return 0;
  934 + }
  935 + if (user_addr == null) {
  936 + return 0;
  937 + }
  938 + //计算物流的config item;
  939 + var item = null;
  940 + //先根据 镇 县 区找计算的config
  941 + item = th.get_wuliu_config(user_addr.district, code, rs);
  942 + if (item == null) item = th.get_wuliu_config(user_addr.city, code, rs);
  943 + if (item == null) item = th.get_wuliu_config(user_addr.province, code, rs);
  944 + if (item == null) item = th.get_wuliu_default(code, rs);
  945 + if (item == null) return o_shipping_price;
  946 + var fw_price = 0, fp_price = 0;
  947 + item = item.config;
  948 + if (item == null) return o_shipping_price;
  949 + //------按重量----------
  950 + if (goods_weight >= 0 && item['money']) {
  951 + fw_price = parseFloat(item['money']);
  952 + if (goods_weight > item['first_weight']) {
  953 + var fw = goods_weight - item['first_weight'];
  954 + var n = Math.ceil(fw / item['second_weight'])
  955 + fw_price = fw_price + n * parseFloat(item['add_money']);
  956 + }
  957 + }
  958 + //------按件数----------
  959 + if (goods_piece > 0 && item['piecemoney']) {
  960 + fp_price = parseFloat(item['piecemoney']);
  961 + if (goods_piece > item['first_piece']) {
  962 + var fp = goods_piece - item['first_piece'];
  963 + var m = Math.ceil(fp / item['second_piece'])
  964 + fp_price = fp_price + m * parseFloat(item['add_piecemoney']);
  965 + }
  966 + }
  967 + var rspice = parseFloat(price + fw_price + fp_price);
  968 + return rspice;
  969 + },
1542 970  
1543   - //搭配购在使用余额
1544   - if (th.data.bn_use_money == 1 && th.data.is_b_now == 1) {
  971 + //------------循环获取config-----------
  972 + get_wuliu_config: function (region_id, code, rs) {
  973 + var item = null, rslist = rs.pageData;
  974 + for (var i = 0; i < rslist.length; i++) {
  975 + if (rslist[i].code == code && rslist[i].region_id == region_id) {
  976 + item = rslist[i];
  977 + }
  978 + }
  979 + return item;
  980 + },
  981 + //-------循环获取config,code default-------
  982 + get_wuliu_default: function (code, rs) {
  983 + var item = null, rslist = rs.pageData;
  984 + for (var i = 0; i < rslist.length; i++) {
  985 + if (rslist[i].shipping_code == code && rslist[i].is_default == 1) {
  986 + item = rslist[i];
  987 + }
  988 + }
  989 + return item;
  990 + },
1545 991  
1546   - if (umoney > cart_item.order_amount) {
1547   - cart_item.user_money = cart_item.order_amount;
1548   - umoney = umoney - cart_item.order_amount;
1549   - } else {
1550   - cart_item.user_money = umoney;
1551   - umoney = 0;
1552   - }
  992 + //----------立即购买,选择物流-------------
  993 + bindPickerChange: function (e) {
  994 + var ind = e.detail.value
  995 + this.setData({index: ind});
  996 + this.calculatePrice2();
  997 + },
  998 + /*----券的所有操作----*/
  999 + open_coupon_list: function (e) {
  1000 + var th = this;
  1001 + var pickid = e.currentTarget.dataset.pickid;
  1002 + var bn = e.currentTarget.dataset.bn;
  1003 + var cindx = e.currentTarget.dataset.cind;
  1004 + var get_by_quan_list_cart = th.data.get_by_quan_list_cart[pickid];
1553 1005  
1554   - } else {
1555   - //--------------如果使用余额,购物车购买---------------------
1556   - if (th.data.js_use_money == 1) {
1557   - if (umoney > cart_item.order_amount) {
1558   - cart_item.user_money = cart_item.order_amount;
1559   - umoney = umoney - cart_item.order_amount;
1560   - } else {
1561   - cart_item.user_money = umoney;
1562   - umoney = 0;
1563   - }
1564   - } else {
1565   - cart_item.user_money = 0;
1566   - }
1567   - }
1568 1006  
1569   - cart_item.user_money = parseFloat(cart_item.user_money).toFixed(2);
1570   - if (coupon_price > 0) cart_item.coupon_price = coupon_price.toFixed(2);
1571   - else cart_item.coupon_price = coupon_price
1572   - if (quan_no) cart_item.quan_no = quan_no;
  1007 + if (bn == 1) {
  1008 + th.setData({open_quan: 1, selected_quan_pick: pickid, disabled: 1});
  1009 + } else {
  1010 + //---多单打开券的时候,就要判断券在其他门店是否有使用---
  1011 + var quanlist = th.data.cartlist[cindx].quan_list;
  1012 + var exp_type = th.data.cartlist[cindx].exp_type;
1573 1013  
1574 1014  
1575   - //cart_item.goods_price = o_price.toFixed(2);
1576   - cart_item.order_amount = cart_item.order_amount - cart_item.user_money; //会员使用余额
  1015 + //对于在其他门店已经选择了的券 要判断是否显示到界面
  1016 + var t_user = th.data.using_quan[pickid];
1577 1017  
  1018 + for (var i in quanlist) {
  1019 + quanlist[i].is_using = th.check_in_sele(quanlist[i].CashRepNo, pickid);
  1020 + if (t_user && quanlist[i].CashRepNo == t_user.coupon_no)
  1021 + quanlist[i].show_red = 1;
  1022 + else
  1023 + quanlist[i].show_red = 0;
  1024 + }
1578 1025  
1579   - all_price += parseFloat(f_o_price);
1580   - all_total_m += parseFloat(cart_item.total_amount);
1581   - all_shipping_m += parseFloat(cart_item.shipping_price);
1582   - all_order_m += parseFloat(cart_item.order_amount);
1583   - all_user_m += parseFloat(cart_item.user_money);
1584   - all_coupon_price_m += parseFloat(cart_item.coupon_price);
1585   - all_cutprice += parseFloat(cart_item.cut_price);
1586   - all_zh_cutprice += parseFloat(cart_item.zh_cut_price);
1587   - all_order_prom += parseFloat(cart_item.order_prom_amount);
  1026 + if (get_by_quan_list_cart) {
  1027 + for (var i in get_by_quan_list_cart) {
  1028 + get_by_quan_list_cart[i].is_using = th.check_in_sele(get_by_quan_list_cart[i].no, pickid);
  1029 + if (t_user && get_by_quan_list_cart[i].no == t_user.coupon_no)
  1030 + get_by_quan_list_cart[i].show_red = 1;
  1031 + else
  1032 + get_by_quan_list_cart[i].show_red = 0;
1588 1033 }
  1034 + th.setData({by_quan_list_cart: get_by_quan_list_cart});
  1035 + } else {
  1036 + th.setData({by_quan_list_cart: null});
  1037 + }
1589 1038  
1590   - all_shipping_m = parseFloat(all_shipping_m).toFixed(2);
1591   - all_total_m = parseFloat(all_total_m).toFixed(2);
1592   - all_order_m = parseFloat(all_order_m).toFixed(2);
1593   - all_price = parseFloat(all_price).toFixed(2);
1594   - all_user_m = parseFloat(all_user_m).toFixed(2);
1595   - all_total_m = parseFloat(all_total_m).toFixed(2);
1596   - all_coupon_price_m = parseFloat(all_coupon_price_m).toFixed(2);
1597   - all_cutprice = all_cutprice.toFixed(2);
1598   - all_order_prom = all_order_prom.toFixed(2);
1599   - all_zh_cutprice = parseFloat(all_zh_cutprice).toFixed(2);
1600   -
1601   - var atxt = "formData.total_amount";
1602   - var atxt1 = "formData.order_amount";
1603   - var atxt2 = "formData.all_price";
1604   - var atxt3 = "formData.user_money";
1605   - var atxt4 = "formData.shipping_price";
1606   - var atxt5 = "formData.coupon_price";
1607   - var atxt6 = "formData.cut_price";
1608   - var atxt7 = "formData.order_prom_amount";
1609   - var atxt8 = "formData.zh_cut_price";
1610   -
1611   - th.setData({
1612   - [atxt]: all_total_m, [atxt1]: all_order_m,
1613   - [atxt2]: all_price, [atxt3]: all_user_m, [atxt4]: all_shipping_m,
1614   - [atxt5]: all_coupon_price_m, [atxt6]: all_cutprice,
1615   - [atxt7]: all_order_prom, show_submit: 1, [atxt8]: all_zh_cutprice
1616   - })
1617   - th.data.order_prom_list_cart = c_arr;
1618   - th.set_can_num();
1619   - wx.hideLoading();
1620   -
  1039 + th.setData({
  1040 + sele_cart_ind: cindx,
  1041 + sele_exp_type: exp_type,
  1042 + open_quan: 1,
  1043 + selected_quan_pick: pickid,
  1044 + selected_quan_list: quanlist,
  1045 + disabled: 1
1621 1046 });
1622   - });
  1047 + }
  1048 + },
  1049 + close_coupon: function (e) {
  1050 + var th = this;
  1051 + th.setData({open_quan: 0, disabled: 0});
1623 1052 },
1624 1053  
1625   - set_can_num: function () {
  1054 + //---判断券时候在已经选择的列表中---
  1055 + check_in_sele: function (no, pick_id) {
1626 1056 var th = this;
1627   - //-- 这个地方,循环计算几张优惠券可用--
1628   - for (var iter in th.data.cartlist) {
1629   - var num = 0;
1630   - var c_item = th.data.cartlist[iter];
1631   - var pkid = c_item.pickup_id;
1632   - //-- 普通券 --
1633   - if (c_item.quan_list) {
1634   - for (var iter1 in c_item.quan_list) {
1635   - //判断是不是其他订单有选用
1636   - var is_other_is_use = th.check_other_use(c_item.quan_list[iter1], pkid);
1637   - if (!is_other_is_use) num++;
1638   - }
1639   - }
1640   - //-- 包邮券 --
1641   - var by_quan = th.data.get_by_quan_list_cart[pkid];
1642   - if (by_quan) {
1643   - for (var iter2 in by_quan) {
1644   - //判断是不是其他订单有选用
1645   - var is_other_is_use = th.check_other_use_by(by_quan[iter2], pkid);
1646   - if (!is_other_is_use) num++;
1647   - }
  1057 + if (th.data.using_quan.length <= 0) return false;
  1058 + for (var i in th.data.using_quan) {
  1059 + //--如果键值等于本身就要跳出--
  1060 + if (parseInt(i) == parseInt(pick_id)) continue;
  1061 + var item = th.data.using_quan[i];
  1062 + if (item.coupon_no == no) {
  1063 + return true;
1648 1064 }
1649   - var set_txt = "cartlist[" + iter + "].can_num";
1650   - th.setData({[set_txt]: num});
1651 1065 }
  1066 + return false;
1652 1067 },
1653 1068  
  1069 + /*--点击选择券--*/
  1070 + sele_quan_item: function (e) {
  1071 + var th = this;
  1072 + var ind = e.currentTarget.dataset.ind;
  1073 + var quan_item = this.data.selected_quan_list[ind];
  1074 + var pickid = this.data.pickup.pickup_id; //现在选择的是哪一个门店
1654 1075  
1655   - //---------计算立即购买----------
1656   - calculatePrice2: function () {
1657   - var th = this, good = this.data.bn_goods;
1658   -
1659   - if (!good) return false;
1660   -
1661   - //搭配的计算要用购物的车计算方法
1662   - if (good.prom_type == 5) {
1663   - th.calculatePrice();
1664   - return false;
1665   - }
1666   -
1667   - wx.showLoading({
1668   - title: "处理中."
1669   - })
1670   - //-----------计算商品总价--------------
1671   - var allpice = good.shop_price * good.buynum;
1672   - var cut_price = 0;
1673   - var allpice1 = allpice;
1674   -
1675   -
1676   - if (good.prom_type == 3 && good.prom_price !== null) {
1677   - cut_price = allpice - good.prom_price;
1678   - }
1679   -
1680   - allpice = parseFloat(allpice).toFixed(2);
1681   - var txt = "formData.all_price";
1682   - th.setData({[txt]: allpice,});
1683   - if (cut_price) {
1684   - var c_txt = "formData.cut_price";
1685   - th.setData({[c_txt]: cut_price,});
1686   -
1687   - }
1688   -
1689   - //如果有线下取价的时候
1690   - if (good.is_offline) {
1691   - allpice = good.offline_price * good.buynum;
  1076 + var no_use = e.currentTarget.dataset.no, quanlist = this.data.selected_quan_list;
  1077 + //---所有的券的显示红色选择都清理一遍---
  1078 + for (var i in quanlist) {
  1079 + quanlist[i].show_red = 0;
1692 1080 }
1693   -
1694   -
1695   - to.getConfig2(function (ee) {
1696   - to.getwuliuprice(async function (rs) {
1697   -
1698   - var o_shipping_price = 0, goods_weight = -1, goods_piece = -1;
1699   -
1700   - //---如果有选择优惠券的情况下---
1701   - var quan_price = 0, bn_pick = th.data.bn_pick;
1702   - var quan_no = null;
1703   - if (th.data.using_quan[bn_pick] != null && th.data.using_quan[bn_pick] != undefined)
1704   - quan_no = th.data.using_quan[bn_pick].coupon_no;
1705   -
1706   - if (quan_no) {
1707   - if (th.data.using_quan[bn_pick].isby != 1) {
1708   - //---获取优惠券优惠---
1709   - await getApp().request.promiseGet("/api/weshop/couponList/getUseCouponPrice", {
1710   - data: {
1711   - storeId: oo.stoid,
1712   - CashRepNo: quan_no,
1713   - WaresSum: th.data.ckeck_quan_price,
1714   - WareIds: th.data.check_quan_ware_list
1715   - }
1716   - }).then(res => {
1717   - if (res.data.code == 0 && res.data.data && res.data.data.length > 0) {
1718   - quan_price = res.data.data[0].WareCashSum;
1719   - }
1720   - })
1721   - }
1722   - }
1723   -
1724   - //-----------当地址不为空,且是物流时,计算物流费用,并同时商品不是优惠活动的包邮----------
1725   - if (th.data.user_addr != null && th.data.bn_exp_type == 0 && good.is_free_shipping == 0 && good.is_past != 1) {
1726   - //看是不是有调用过包邮券
1727   - if (!th.data.isget_by_quan[th.data.bn_pick] && good.is_xz_yh != 1) {
1728   - var condition = allpice - cut_price - quan_price;
1729   - //--判断要不要显示包邮券,链式调用接口,调取包邮券,已经是减了优惠的金额,见到优惠券的钱---
1730   - getApp().request.promiseGet("/api/weshop/userfeemail/pageAndArea", {
1731   - data: {
1732   - store_id: os.stoid,
1733   - isuse: 0,
1734   - condition: condition,
1735   - user_id: getApp().globalData.user_id,
1736   - pageSize: 2000
1737   - }
1738   - }).then(res => {
1739   - if (res.data.code == 0 && res.data.data.total > 0) {
1740   - //此时要循环判断包邮的地区,不包邮商品是不是符合
1741   - var arr = [], quanlist = res.data.data.pageData;
1742   - quanlist = th.check_is_frozenQuan(quanlist, th.data.frozenQuan, 1);
1743   - for (var i in quanlist) {
1744   - var item = quanlist[i];
1745   - if (item.region_list && th.check_by_area(item.region_list)) continue; //如果是不包邮区域
1746   - if (item.goods_list && th.check_by_goods(item.goods_list)) continue; //如果是不包邮商品
1747   - arr.push(item);
1748   - }
1749   - if (arr) {
1750   - th.setData({get_by_quan_list: arr});
1751   - }
1752   - th.data.isget_by_quan[th.data.bn_pick] = 1;
1753   - }
1754   - })
1755   - }
1756   -
1757   - switch (good['exp_sum_type']) {
1758   - case 1:
1759   - //统一运费
1760   - o_shipping_price += good['uniform_exp_sum'];
1761   - break;
1762   - case 2:
1763   - if (goods_weight < 0) goods_weight = 0;
1764   - //累积商品重量 每种商品的重量 * 数量
1765   - goods_weight += good['weight'] * good['buynum'];
1766   - break;
1767   - case 3:
1768   - if (goods_piece < 0) goods_piece = 0;
1769   - //累积商品数量
1770   - goods_piece += good['buynum'];
1771   - break;
1772   - }
1773   -
1774   - var code = "";
1775   - if (th.data.wu_arr && th.data.wu_arr[th.data.index]) code = th.data.wu_arr[th.data.index].code;
1776   - var freight_free = ee.freight_free; //全场满多少包邮
1777   - var no_ex_id = ee.no_ex_id;
1778   - th.data.is_no_by[th.data.bn_pick] = 0;
1779   -
1780   - var no_by_data = null;
1781   - var gift_freight_free = freight_free;
1782   -
1783   -
1784   - //有不包邮区域,且不免运费
1785   - if (no_ex_id && freight_free > 0 && freight_free <= parseFloat(allpice) - cut_price - quan_price) {
1786   - //-----------获取不包邮区域,不包邮商品-------
1787   - await getApp().request.promiseGet("/api/weshop/areaFeemail/getAreaGoods", {
1788   - data: {store_id: os.stoid, id: no_ex_id}
1789   - }).then(res => {
1790   - if (res.data.code == 0 && res.data.data && res.data.data.length > 0) {
1791   - no_by_data = res.data.data[0];
1792   - //如果有设置不包邮区域的时候
1793   - if (res.data.data[0].region_list) {
1794   - if (th.check_by_area(res.data.data[0].region_list)) {
1795   - freight_free = 0;
1796   - th.data.is_no_by[th.data.bn_pick] = 1;
1797   - }
1798   - }
1799   - //如果有设置不包邮商品
1800   - if (res.data.data[0].goods_list && freight_free) {
1801   - if (th.check_by_goods(res.data.data[0].goods_list)) {
1802   - freight_free = 0;
1803   - th.data.is_no_by[th.data.bn_pick] = 1;
1804   - }
1805   - }
1806   - }
1807   - })
1808   - }
1809   -
1810   - th.data.is_by[th.data.bn_pick] = 0;
1811   - //--------------开始计算物流------------------
1812   - var shipping_price =
1813   - th.calculatewuliu(code, o_shipping_price, goods_weight,
1814   - goods_piece, th.data.user_addr, freight_free, parseFloat(allpice) - cut_price - quan_price, rs);
1815   -
1816   - //如果有赠品的时候,也要计算赠品的物流费用
1817   - if (th.data.buy_now_gift_goods) {
1818   - shipping_price = th.get_now_gift_goods_wuliu(code, o_shipping_price, th.data.user_addr, gift_freight_free,
1819   - parseFloat(allpice) - cut_price - quan_price, rs, shipping_price, no_by_data, goods_weight, goods_piece);
1820   - }
1821   -
1822   - if (shipping_price <= 0) {
1823   - th.data.is_by[th.data.bn_pick] = 1; //已经是包邮了,就不要选择包邮券
1824   - }
1825   -
1826   - shipping_price = parseFloat(shipping_price).toFixed(2);
1827   - var wl_txt = "formData.shipping_price";
1828   - th.setData({[wl_txt]: shipping_price,})
1829   -
1830   - } else {
1831   - var wl_txt = "formData.shipping_price";
1832   - th.setData({[wl_txt]: 0,})
1833   - }
1834   -
1835   - if (quan_no) {
1836   - if (th.data.using_quan[bn_pick].isby == 1) {
1837   - shipping_price = 0;
1838   - var wl_txt = "formData.shipping_price";
1839   - th.setData({[wl_txt]: 0,})
1840   - }
1841   - }
1842   - //-----------------支付价,优惠券不减物流-----------------
1843   - var total_m = (parseFloat(allpice1)).toFixed(2);
1844   - var order_m = (parseFloat(allpice - cut_price) - quan_price).toFixed(2);
1845   - var coupon_price = quan_price; //优惠券优惠了多少钱
1846   - if (order_m < 0) {
1847   - order_m = 0;
1848   - coupon_price = parseFloat(order_m).toFixed(2);
1849   - }
1850   - //--看一下有没有订单优惠--
1851   - var o_condition = parseFloat(order_m);
1852   - if (o_condition > 0) {
1853   - th.check_is_order_prom(o_condition, function () {
1854   - var order_prom_amount = 0;
1855   - var order_prom_id = 0;
1856   - if (th.data.order_prom[th.data.bn_pick]) {
1857   - var ord_prom = th.data.order_prom[th.data.bn_pick];
1858   - order_prom_id = ord_prom['id'];
1859   - switch (ord_prom['type']) {
1860   - case 0:
1861   - order_m = Math.round(o_condition * ord_prom['expression']) / 100;//满额打折
1862   - order_prom_amount = (o_condition - order_m).toFixed(2);
1863   - break;
1864   - case 1:
1865   - order_m = o_condition - ord_prom['expression'];//满额优惠金额
1866   - order_prom_amount = ord_prom['expression'];
1867   - break;
1868   - }
1869   - }
1870   - //--订单优惠的显示--
1871   - if (order_prom_id > 0) {
1872   - var order_prom_txt1 = "formData.order_prom_id";
1873   - var order_prom_txt2 = "formData.order_prom_amount";
1874   - th.setData({[order_prom_txt1]: order_prom_id, [order_prom_txt2]: order_prom_amount})
1875   - }
1876   -
1877   - total_m = parseFloat(total_m) + parseFloat(th.data.formData.shipping_price);
1878   - order_m = parseFloat(order_m) + parseFloat(th.data.formData.shipping_price);
1879   -
1880   - total_m = total_m.toFixed(2);
1881   - order_m = order_m.toFixed(2);
1882   -
1883   - var atxt = "formData.total_amount";
1884   - th.setData({[atxt]: total_m,})
1885   -
1886   - var txt = "formData.user_money";
1887   - var txt2 = "formData.order_amount";
1888   - var txt3 = "formData.coupon_price";
1889   - var amoney = parseFloat(th.data.userinfo.user_money - th.data.txmon - th.data.userinfo.frozen_money);
1890   - //--------------如果使用余额---------------------
1891   - if (th.data.bn_use_money == 1) {
1892   - if (amoney > order_m) {
1893   - order_m = parseFloat(order_m).toFixed(2);
1894   - th.setData({[txt]: order_m, [txt2]: 0, [txt3]: coupon_price, show_submit: 1})
1895   - } else {
1896   - order_m = parseFloat(order_m) - parseFloat(amoney);
1897   - order_m = order_m.toFixed(2);
1898   - th.setData({[txt]: amoney, [txt2]: order_m, [txt3]: coupon_price, show_submit: 1})
1899   - }
1900   - } else {
1901   - th.setData({[txt]: 0, [txt2]: order_m, [txt3]: coupon_price, show_submit: 1})
1902   - }
1903   - //优惠活动送积分
1904   - if (good.s_intValue) {
1905   - txt = "formData.give_integral";
1906   - th.setData({[txt]: good.s_intValue});
1907   - }
1908   - //优惠送券
1909   - if (good.s_coupon_id) {
1910   - var i_txt = "formData.give_coupon_id";
1911   - //这个是json格式的
1912   - var i_txt1 = "formData.g_coupon_num";
1913   - var ob = [{"num": good.s_coupon_num, "c_id": good.s_coupon_id}];
1914   - ob = JSON.stringify(ob);
1915   - th.setData({[i_txt]: good.s_coupon_id, [i_txt1]: ob});
1916   - }
1917   - //优惠礼包
1918   - if (good.s_libao) {
1919   - var l_txt = "formData.give_lb_id";
1920   - //这个是json格式的
1921   - var l_txt1 = "formData.g_lb_num";
1922   - var ob = [{"num": good.s_lb_num, "l_id": good.s_libao}];
1923   - ob = JSON.stringify(ob);
1924   - th.setData({[l_txt]: good.s_libao, [l_txt1]: ob});
1925   - }
1926   - })
1927   - } else {
1928   - total_m = parseFloat(total_m) + parseFloat(th.data.formData.shipping_price);
1929   - order_m = parseFloat(order_m) + parseFloat(th.data.formData.shipping_price);
1930   - var atxt = "formData.total_amount";
1931   -
1932   - total_m = total_m.toFixed(2);
1933   - order_m = order_m.toFixed(2);
1934   -
1935   - th.setData({[atxt]: total_m,})
1936   -
1937   - var txt = "formData.user_money";
1938   - var txt2 = "formData.order_amount";
1939   - var txt3 = "formData.coupon_price";
1940   - var amoney = parseFloat(th.data.userinfo.user_money - th.data.txmon - th.data.userinfo.frozen_money);
1941   - //--------------如果使用余额---------------------
1942   - if (th.data.bn_use_money == 1) {
1943   - if (amoney > order_m) {
1944   - order_m = parseFloat(order_m).toFixed(2);
1945   - th.setData({[txt]: order_m, [txt2]: 0, [txt3]: coupon_price, show_submit: 1})
1946   - } else {
1947   - order_m = parseFloat(order_m) - parseFloat(amoney);
1948   - order_m = order_m.toFixed(2);
1949   - th.setData({[txt]: amoney, [txt2]: order_m, [txt3]: coupon_price, show_submit: 1})
1950   - }
1951   - } else {
1952   - th.setData({[txt]: 0, [txt2]: order_m, [txt3]: coupon_price, show_submit: 1})
1953   - }
1954   - //优惠活动送积分
1955   - if (good.s_intValue) {
1956   - txt = "formData.give_integral";
1957   - th.setData({[txt]: good.s_intValue});
1958   - }
1959   - //优惠送券
1960   - if (good.s_coupon_id) {
1961   - var i_txt = "formData.give_coupon_id";
1962   - //这个是json格式的
1963   - var i_txt1 = "formData.g_coupon_num";
1964   - var ob = [{"num": good.s_coupon_num, "c_id": good.s_coupon_id}];
1965   - ob = JSON.stringify(ob);
1966   - th.setData({[i_txt]: good.s_coupon_id, [i_txt1]: ob});
1967   - }
1968   - //优惠礼包
1969   - if (good.s_libao) {
1970   - var l_txt = "formData.give_lb_id";
1971   - //这个是json格式的
1972   - var l_txt1 = "formData.g_lb_num";
1973   - var ob = [{"num": good.s_lb_num, "l_id": good.s_libao}];
1974   - ob = JSON.stringify(ob);
1975   - th.setData({[l_txt]: good.s_coupon_id, [l_txt1]: ob});
1976   - }
1977   - }
1978   -
1979   - wx.hideLoading();
1980   -
1981   - });
1982   - });
1983   - },
1984   -
1985   - //--------------------提交订单-----------------------
1986   - async submitForm(t){
1987   - var sub_value = t;
1988   -
1989   - if (this.data.is_summit_ing == 1) return false; //--提交中退出--
1990   - this.data.is_summit_ing = 1;
1991   - var th = this, pdata = new Array();
1992   - var ff = true;
1993   - //------------立即购买-------------
1994   - if (th.data.is_b_now == 1 && th.data.bn_goods.prom_type != 5) {
1995   -
1996   - if (th.data.bn_exp_type == 0 && th.data.user_addr == null) {
1997   - ff = false;
1998   - getApp().my_warnning("请选择收货地址", 0, th);
1999   - th.data.is_summit_ing = 0;
2000   - }
2001   - if (!ff) return false;
2002   - var addr = th.data.user_addr;
2003   - if (th.data.bn_exp_type == 1) addr = null;
2004   -
2005   - if (th.data.bn_exp_type == 0)
2006   - if (th.data.wu_arr == null || th.data.wu_arr.length <= 0) {
2007   - getApp().my_warnning("读取物流失败", 0, th);
2008   - th.data.is_summit_ing = 0;
2009   - return false;
2010   - }
2011   -
2012   - var item = {
2013   - 'user_id': to.globalData.user_id,
2014   - 'consignee': addr == null ? "" : addr.consignee,
2015   - 'province': addr == null ? 0 : addr.province,
2016   - 'city': addr == null ? 0 : addr.city,
2017   - 'district': addr == null ? 0 : addr.district,
2018   - 'twon': addr == null ? 0 : addr.twon,
2019   - 'address': addr == null ? "" : addr.address,
2020   - 'more_address': addr == null ? "" : addr.more_address,
2021   - //'mobile': th.data.userinfo.mobile,
2022   - 'mobile': addr == null ? th.data.userinfo.mobile : addr.mobile,
2023   - 'email': '',
2024   - 'shipping_code': th.data.bn_exp_type == 1 ? 0 : th.data.wu_arr[th.data.index].code,
2025   - 'shipping_name': th.data.bn_exp_type == 1 ? '' : th.data.wu_arr[th.data.index].name,
2026   - 'invoice_title': '',
2027   - 'goods_price': th.data.formData.all_price, //商品总价
2028   - 'shipping_price': th.data.formData.shipping_price, //物流金额
2029   - 'user_money': th.data.formData.user_money, //使用余额
2030   - 'total_amount': th.data.formData.total_amount, //订单总价
2031   - 'order_amount': th.data.formData.order_amount, //应付
2032   - 'user_note': t.detail.value.user_note, //用户备注
2033   - 'store_id': oo.stoid, //商家
2034   - 'pickup_id': th.data.bn_pick, //门店
2035   - 'exp_type': th.data.bn_exp_type, //配送方式
2036   - 'order_goods': new Array(),
2037   - };
2038   - //是不是重新提交
2039   - if (th.data.is_continue == 1) item.is_continue = 1;
2040   -
2041   - //获取立即购买的商品的信息
2042   - var gg = to.get_b_now();
2043   - //--商品的房间号--
2044   - if (gg.room_id && gg.room_id > 0) {
2045   - item.room_ids = gg.room_id;
2046   - }
2047   -
2048   - var order_prom_list = {};
2049   - //--判断有没有优惠活动--
2050   - if (th.data.order_prom[item.pickup_id]) {
2051   - if (th.data.formData.order_prom_amount > 0) {
2052   - order_prom_list.order_prom_id = th.data.formData.order_prom_id;
2053   - order_prom_list.order_prom_amount = th.data.formData.order_prom_amount;
2054   - }
2055   - }
2056   -
2057   - //--判断优惠活动的提交--
2058   - if (th.data.formData.cut_price > 0 ) {
2059   - order_prom_list.discount_amount = th.data.formData.cut_price.toFixed(2);
2060   - var ob = [{
2061   - "prom_id": th.data.bn_goods.prom_id,
2062   - "dis": parseFloat(th.data.formData.cut_price).toFixed(2),
2063   - "ispt": 0
2064   - }]
2065   - order_prom_list.prom_pt_json = JSON.stringify(ob);
2066   - }
2067   - if (th.data.formData.give_integral > 0) {
2068   - order_prom_list.give_integral = th.data.formData.give_integral;
2069   - }
2070   - if (th.data.formData.give_coupon_id > 0) {
2071   - order_prom_list.give_coupon_id = th.data.formData.give_coupon_id;
2072   - order_prom_list.g_coupon_num = th.data.formData.g_coupon_num;
2073   - }
2074   - if (th.data.formData.give_lb_id > 0) {
2075   - order_prom_list.give_lb_id = th.data.formData.give_lb_id;
2076   - order_prom_list.g_lb_num = th.data.formData.g_lb_num;
2077   - }
2078   - item.order_prom_list = order_prom_list;
2079   -
2080   - //组装优惠券的钱
2081   - if (parseFloat(th.data.formData.coupon_price) > 0) {
2082   - item.coupon_price = th.data.formData.coupon_price;
2083   - item.coupon_no = th.data.using_quan[th.data.bn_pick].coupon_no;
2084   - }
2085   - if (th.data.using_quan[th.data.bn_pick] && th.data.using_quan[th.data.bn_pick].coupon_no && th.data.using_quan[th.data.bn_pick].isby) {
2086   - item.coupon_no = th.data.using_quan[th.data.bn_pick].coupon_no;
2087   - item.coupon_price = 0;
2088   - }
2089   -
2090   - //老会员成为分销下线需要的参数
2091   - if (getApp().globalData.first_leader && !getApp().globalData.userInfo.first_leader) {
2092   - //判断一下分享人是不是分享商
2093   - await app.request.promiseGet("/api/weshop/users/get/" + os.stoid + "/" + getApp().globalData.first_leader, {}).then(res => {
2094   - if (res.data.code == 0) {
2095   - var user = res.data.data;
2096   - if (user.is_distribut == 1) {
2097   - item.first_leader = parseInt(getApp().globalData.first_leader);
2098   - }
2099   - }
2100   - })
2101   - }
2102   -
2103   - var goods = {
2104   - 'goods_id': gg.goods_id,
2105   - 'goods_name': gg.goods_name,
2106   - 'goods_sn': gg.goods_sn,
2107   - 'goods_num': gg.goods_num,
2108   - 'market_price': th.data.bn_goods.market_price,
2109   - 'goods_price': th.data.bn_goods.shop_price,
2110   - 'member_goods_price': th.data.bn_goods.shop_price,
2111   - 'store_id': oo.stoid,
2112   - 'prom_type': th.data.bn_goods.prom_type, //促销活动类型
2113   - 'prom_id': th.data.bn_goods.prom_id, //促销活动id
2114   - };
2115   -
2116   - //-- 把导购的信息填入--
2117   - if (gg.guide_id) {
2118   - goods.guide_id = gg.guide_id;
2119   - goods.guide_type = gg.guide_type;
2120   - //调用接口判断是不是会员
2121   - await getApp().request.promiseGet("/api/weshop/shoppingGuide/getId/" + oo.stoid + "/" + gg.guide_id, {}).then(res => {
2122   - if (res.data.code == 0) {
2123   - goods.guide_name = res.data.data.salesman;
2124   - goods.guide_sn = res.data.data.salesman_no;
2125   - }
2126   - })
2127   - }
2128   -
2129   - //--商品的房间号--
2130   - if (gg.room_id && gg.room_id > 0) {
2131   - goods.room_id = gg.room_id;
2132   - }
2133   -
2134   - //积分购,先要带is_integral_normal=1
2135   - if (gg.is_integral_normal) goods.is_integral_normal = 1;
2136   -
2137   - //先要带is_pd_normal=1
2138   - if (gg.is_pd_normal) goods.is_pd_normal = 1;
2139   -
2140   - //如果不立即购买或者秒杀,如果是线下库存购买的时候
2141   - if (goods.prom_type != 1 && goods.prom_type != 6 && th.data.sales_rules == 2) {
2142   - var isok = 1;
2143   - await th.check_store_num(goods.goods_id, th.data.bn_pick, gg.goods_num, function (res) {
2144   - isok = res;
2145   - });
2146   - if (!isok) {
2147   - getApp().confirmBox("商品的门店库存不足");
2148   - th.data.is_summit_ing = 0;
2149   - return false;
2150   - }
  1081 + this.setData({selected_quan_list: quanlist});
  1082 + var by_quanlist = this.data.get_by_quan_list;
  1083 + if (by_quanlist) {
  1084 + //---所有的券的显示红色选择都清理一遍---
  1085 + for (var inb in by_quanlist) {
  1086 + by_quanlist[inb].show_red = 0;
2151 1087 }
  1088 + this.setData({get_by_quan_list: by_quanlist});
  1089 + }
2152 1090  
2153   - //-- 如果有线下取价的话 --
2154   - if (th.data.bn_goods.is_offline) {
2155   - item.sum_offline_cut = (th.data.bn_goods.shop_price - th.data.bn_goods.offline_price).toFixed(2);
2156   - goods.offline_cut = item.sum_offline_cut;
2157   - goods.pricing_type = th.data.bn_goods.pricing_type;
2158   - goods.goods_price = th.data.bn_goods.offline_price;
2159   - goods.member_goods_price = th.data.bn_goods.offline_price;
  1091 + var by_cart_list = this.data.by_quan_list_cart;
  1092 + if (by_cart_list) {
  1093 + //---所有的券的显示红色选择都清理一遍---
  1094 + for (var inc in by_cart_list) {
  1095 + by_cart_list[inc].show_red = 0;
2160 1096 }
  1097 + this.setData({by_quan_list_cart: by_cart_list});
  1098 + }
2161 1099  
2162   - //--- 如果有优惠促销的金额,要把金额先平摊下去 ---
2163   - if (th.data.formData.cut_price > 0 && !th.data.ispt_goods) {
2164   - var g_arr = new Array();
2165   - g_arr.push(goods);
2166   - var pt_data = {
2167   - 'prom_id': goods.prom_id,
2168   - 'dis': parseFloat(th.data.formData.cut_price),
2169   - 'goods': g_arr,
2170   - }
2171   -
2172   - var pt_res = null;
2173   - await getApp().request.promisePost("/api/weshop/order/getGoodsSplit", {
2174   - is_json: 1,
2175   - data: pt_data
2176   - }).then(res => {
2177   - if (res.data.code == 0) {
2178   - pt_res = res.data.data;
2179   - }
2180   - })
2181   - if (pt_res) {
2182   - //平摊赋值
2183   - goods.account = pt_res[0].fisrt_account;
2184   - goods.account_yu = pt_res[0].fisrt_account_yu;
2185   - item.is_discount_amount = 1;
2186   - }
2187   - }
  1100 + var using_quan = this.data.using_quan;
2188 1101  
2189   - //--组装优惠券的钱--
2190   - if (th.data.formData.coupon_price) {
2191   - item.coupon_price = th.data.formData.coupon_price;
2192   - item.coupon_no = th.data.using_quan[th.data.bn_pick].coupon_no;
2193   - goods.quan_num = th.data.formData.coupon_price;
2194   - goods.quan_no = item.coupon_no;
2195   - }
2196   -
2197   - item.order_goods.push(goods);
2198   -
2199   - //--如果有赠品的时候,赠品也要提交---
2200   - if (th.data.buy_now_gift_goods) {
2201   - var gift_gg = th.data.buy_now_gift_goods;
2202   - var g_goods = {
2203   - 'goods_id': gift_gg.goods_id,
2204   - 'goods_name': gift_gg.goods_name,
2205   - 'goods_sn': gift_gg.goods_sn,
2206   - 'goods_num': gift_gg.buynum,
2207   - 'market_price': gift_gg.market_price,
2208   - 'goods_price': 0,
2209   - 'member_goods_price': 0,
2210   - 'store_id': oo.stoid,
2211   - 'is_gift': 1,
2212   - 'gift_id': gift_gg.gift_id,
2213   - 'prom_id': gift_gg.prom_id,
2214   - };
2215   - item.order_goods.push(g_goods);
2216   - }
2217   - pdata.push(item);
2218   -
2219   - console.log(pdata);
2220   - } else {
2221   - //---------购物车的结算---------
2222   - if (th.data.is_all_zt == 0 && th.data.user_addr == null) {
2223   - th.data.is_summit_ing = 0;
2224   - ff = false;
2225   - getApp().confirmBox("请新建收货地址");
  1102 + //---如果是不使用优惠券---
  1103 + if (no_use == 1) {
  1104 + if (using_quan[pickid]) {
  1105 + using_quan[pickid].is_nouse_red = 1;
2226 1106 }
2227   - if (!ff) return false;
2228   -
2229   - var addr = th.data.user_addr;
2230   - if (th.data.is_all_zt == 1) addr = null;
2231   - var val_arr = t.detail.value;
2232   -
2233   -
2234   - if (th.data.is_all_zt != 1)
2235   - if (th.data.wu_arr == null || th.data.wu_arr.length <= 0) {
2236   - th.data.is_summit_ing = 0;
2237   - getApp().confirmBox("读取物流失败");
2238   - return false;
2239   - }
2240   -
2241   - var order_prom_list_cart = th.data.order_prom_list_cart;
2242   -
2243   - //--组装推送数据--
2244   - for (var i = 0; i < order_prom_list_cart.length; i++) {
2245   - var t_item = order_prom_list_cart[i];
2246   - var item = {
2247   - 'user_id': to.globalData.user_id,
2248   - 'consignee': addr == null ? th.data.userinfo.mobile : addr.consignee,
2249   - 'province': addr == null ? 0 : addr.province,
2250   - 'city': addr == null ? 0 : addr.city,
2251   - 'district': addr == null ? 0 : addr.district,
2252   - 'twon': addr == null ? 0 : addr.twon,
2253   - 'address': addr == null ? "" : addr.address,
2254   - 'more_address': addr == null ? "" : addr.more_address,
2255   - 'mobile': addr == null ? th.data.userinfo.mobile : addr.mobile,
2256   - 'email': '',
2257   - 'shipping_code': th.data.is_all_zt == 1 ? 0 : th.data.wu_arr[t_item.wind].code,
2258   - 'shipping_name': th.data.is_all_zt == 1 ? '' : th.data.wu_arr[t_item.wind].name,
2259   - 'invoice_title': '',
2260   - 'goods_price': t_item.goods_price, //商品总价
2261   - 'shipping_price': t_item.shipping_price, //物流金额
2262   - 'user_money': t_item.user_money, //使用余额
2263   - 'total_amount': t_item.total_amount, //订单总价
2264   - 'order_amount': t_item.order_amount, //应付
2265   - 'user_note': val_arr['user_note_' + t_item.pickup_id], //用户备注
2266   - 'store_id': oo.stoid, //商家
2267   - 'pickup_id': t_item.pickup_id, //门店
2268   - 'exp_type': t_item.exp_type, //配送方式
2269   - 'order_goods': new Array(),
2270   - };
2271   - //是不是重新提交
2272   - if (th.data.is_continue == 1) item.is_continue = 1;
2273   - //----- 如果有线下取价的话 ----
2274   - if (t_item.is_offline == 1) {
2275   - item.sum_offline_cut = t_item.offline_price.toFixed(2);
2276   - }
2277   -
2278   - //组装优惠券的钱
2279   - if (t_item.coupon_price) {
2280   - item.coupon_price = t_item.coupon_price;
2281   - item.coupon_no = th.data.using_quan[t_item.pickup_id].coupon_no;
2282   - } else if (t_item.quan_no) {
2283   - item.coupon_no = t_item.quan_no;
2284   - item.coupon_price = 0;
2285   - }
2286   -
2287   - var order_prom_list = {};
2288   - //--判断有没有优惠活动--
2289   - if (t_item.order_prom_amount > 0) {
2290   - order_prom_list.order_prom_id = t_item.order_prom_id;
2291   - order_prom_list.order_prom_amount = t_item.order_prom_amount;
2292   - }
2293   -
2294   - order_prom_list.discount_amount =0;
2295   - //--判断优惠活动的提交--
2296   - if (t_item.cut_price > 0) {
2297   - order_prom_list.discount_amount += t_item.cut_price;
2298   - order_prom_list.prom_pt_json = JSON.stringify(t_item.prom_pt_json);
2299   - }
2300   - //--判断组合优惠活动的提交--
2301   - if (t_item.zh_cut_price > 0 || t_item.zh_cut_price<0) {
2302   - order_prom_list.discount_amount += t_item.zh_cut_price;
2303   - order_prom_list.zh_pt_json = JSON.stringify(t_item.zh_pt_json);
2304   - }
2305   - if (t_item.s_intValue > 0) {
2306   - order_prom_list.give_integral = t_item.s_intValue;
2307   - }
2308   - if (t_item.s_coupon_id) {
2309   - order_prom_list.give_coupon_id = t_item.s_coupon_id;
2310   - order_prom_list.g_coupon_num = JSON.stringify(t_item.g_coupon_num);
2311   - }
2312   - if (t_item.s_libao) {
2313   - order_prom_list.give_lb_id = t_item.s_libao;
2314   - order_prom_list.g_lb_num = JSON.stringify(t_item.g_lb_num);
2315   - }
2316   - if (Object.keys(order_prom_list).length > 0){
2317   - if(order_prom_list.discount_amount)
2318   - order_prom_list.discount_amount= parseFloat(order_prom_list.discount_amount).toFixed(2);
2319   - if(order_prom_list.order_prom_amount)
2320   - order_prom_list.order_prom_amount= parseFloat(order_prom_list.order_prom_amount).toFixed(2);
2321   - item.order_prom_list = order_prom_list;
2322   - }
2323   -
2324   -
2325   - //老会员成为分销下线需要的参数
2326   - if (getApp().globalData.first_leader && !getApp().globalData.userInfo.first_leader) {
2327   - //判断一下分享人是不是分享商
2328   - await app.request.promiseGet("/api/weshop/users/get/" + os.stoid + "/" + getApp().globalData.first_leader, {}).then(res => {
2329   - if (res.data.code == 0) {
2330   - var user = res.data.data;
2331   - if (user.is_distribut == 1) {
2332   - item.first_leader = parseInt(getApp().globalData.first_leader);
2333   - }
2334   - }
2335   - })
2336   - }
2337   -
2338   -
2339   - //房间号的ids
2340   - var room_ids = "";
2341   - //-------------让商品添加到商品列表--------------------
2342   - for (var k = 0; k < t_item.goods.length; k++) {
2343   - var g_item = t_item.goods[k];
2344   - var goods = {
2345   - 'goods_id': g_item.goods_id,
2346   - 'goods_name': g_item.goods_name,
2347   - 'goods_sn': g_item.goods_sn,
2348   - 'goods_num': g_item.goods_num,
2349   - 'market_price': g_item.market_price,
2350   - 'goods_price': g_item.goods_price,
2351   - 'member_goods_price': g_item.goods_price,
2352   - 'store_id': oo.stoid,
2353   - };
2354   -
2355   - //-- 线下取价也要写入,组合购的商品不能去线下价格 --
2356   - if (g_item.offline_price && t_item.is_offline == 1 && g_item.prom_type!=7) {
2357   - goods.goods_price = g_item.offline_price;
2358   - goods.member_goods_price = g_item.offline_price;
2359   - goods.offline_cut = (g_item.goods_price - g_item.offline_price).toFixed(2);
2360   - goods.pricing_type = g_item.pricing_type;
2361   - }
2362   -
2363   - //--把券的钱,写入从表---
2364   - if (t_item.quan_youhui_list && t_item.coupon_price) {
2365   - for (var kk in t_item.quan_youhui_list) {
2366   - var you_item = t_item.quan_youhui_list[kk];
2367   - if (g_item.prom_type!=7 && g_item.erpwareid == you_item.WareId) {
2368   - goods.quan_num = you_item.WareCashSum;
2369   - goods.quan_no = you_item.CashRepNo;
2370   - }
2371   - }
2372   - }
2373   -
2374   - //--判断活动的类型--
2375   - switch (g_item.prom_type) {
2376   - case 1:
2377   - goods.prom_type = g_item.prom_type;
2378   - goods.prom_id = g_item.prom_id;
2379   - break;
2380   - case 3:
2381   - goods.prom_type = 3;
2382   - goods.prom_id = g_item.prom_id;
2383   - if (g_item.is_gift) {
2384   - goods.is_gift = g_item.is_gift;
2385   - goods.gift_id = g_item.gift_id;
2386   - }
2387   - break;
2388   - case 5:
2389   - goods.prom_type = 5;
2390   - goods.prom_id = g_item.prom_id;
2391   - if (g_item.is_collocation) {
2392   - goods.is_collocation = g_item.is_collocation;
2393   - }
2394   - break
2395   - case 7:
2396   - goods.prom_type = 7;
2397   - goods.prom_id = g_item.prom_id;
2398   - break
2399   - default:
2400   - goods.prom_type = 0;
2401   - goods.prom_id = 0;
2402   - }
2403   -
2404   - //如果不立即购买或者秒杀,如果是线下库存购买的时候
2405   - if (goods.prom_type == 0 && th.data.sales_rules == 2) {
2406   - var isok = 1;
2407   - await th.check_store_num(goods.goods_id, t_item.pickup_id, goods.goods_num, function (res) {
2408   - isok = res;
2409   - });
2410   - if (!isok) {
2411   - getApp().confirmBox(goods.goods_name + "的门店库存不足");
2412   - th.data.is_summit_ing = 0;
2413   - return false;
2414   - }
2415   - }
2416   -
2417   - //把优惠的平摊结果写进去
2418   - if (g_item.account >= 0 || g_item.account_yu != 0) {
2419   - if (g_item.account >= 0) goods.account = g_item.account;
2420   - if (g_item.account_yu != 0) goods.account_yu = g_item.account_yu;
2421   - item.is_discount_amount = 1;
2422   - }
2423   -
2424   - //导购ID
2425   - if (g_item.guide_id) {
2426   - goods.guide_id = g_item.guide_id;
2427   - goods.guide_type = g_item.guide_type;
2428   - //调用接口判断是不是会员
2429   - await getApp().request.promiseGet("/api/weshop/shoppingGuide/getId/" + oo.stoid + "/" + g_item.guide_id, {}).then(res => {
2430   - if (res.data.code == 0) {
2431   - goods.guide_name = res.data.data.salesman;
2432   - goods.guide_sn = res.data.data.salesman_no;
2433   - }
2434   - })
2435   - }
2436   - //如果房间号不为空的时候
2437   - if (g_item.room_id) {
2438   - goods.room_id = g_item.room_id;
2439   - room_ids += g_item.room_id + ",";
2440   - }
2441   - item.order_goods.push(goods);
2442   - }
2443   -
2444   - //如果房间号不为空的时候
2445   - if (room_ids != "") item.room_ids = ut.sub_last(room_ids);
2446   - pdata.push(item);
  1107 + else {
  1108 + using_quan[pickid] = {is_nouse_red: 1};
2447 1109 }
2448   -
2449   -
  1110 + this.setData({using_quan: using_quan, is_coupon: 2222});
  1111 + return;
2450 1112 }
2451 1113  
2452   - if (pdata.length == 0) return;
2453   - var str = JSON.stringify(pdata);
2454   -
2455   - wx.showLoading({title: "加载中"});
2456   - wx.request({
2457   - url: oo.url + '/api/weshop/order/createWxdOrder',
2458   - data: str,
2459   - method: 'POST',
2460   - header: {
2461   - 'content-type': 'application/json'
2462   - },// 设置请求的 header
2463   - success: function (res) {
2464   -
2465   -
2466   - wx.hideLoading();
2467   - if (res.statusCode == 200) {
2468   - var data = res.data;
2469   - if (data.code == 0) {
2470   - console.log(th.data.is_b_now);
2471   - //如果是购物车结算,还要删除购物车
2472   - if (th.data.is_b_now == 0) {
2473   - console.log(th.data.cartlist_y);
2474   - var list = th.data.cartlist_y;
2475   - for (var i = 0; i < list.length; i++) {
2476   - //删除购物车
2477   - a.delete("/api/weshop/cart/del/" + oo.stoid + "/" + list[i].id, {});
2478   - }
2479   - }
2480   - var order_amount = 0;
2481   - pdata.forEach(function (em, ind) {
2482   - order_amount += em.order_amount;
2483   - })
2484   - //要进行判断,如果是用微信支付,就要跳转到支付界面
2485   - if (order_amount > 0) {
2486   - th.setData({isclose: 0});
2487   - //void e.jumpToCart4({
2488   - // order_sn: data.data,
2489   - //}, 1);
2490   - util_pay.pay(data.data, function () {
2491   - //app.my_warnning("支付成功",1,th);
2492   - //setTimeout(function () {
2493   - wx.redirectTo({
2494   - url: "/pages/payment/pay_success/pay_success?type=2&order_sn=" + data.data
2495   - })
2496   - //},1000)
2497   -
2498   - }, function () {
2499   - //支付失败
2500   - setTimeout(function () {
2501   - var cps=getCurrentPages();
2502   - if(cps.length>1){
2503   - wx.navigateBack({delta: 1})
2504   - }else{
2505   - getApp().goto("/pages/index/index/index");
2506   - }
2507   -
2508   - }, 1000)
2509   - }, oo.stoid);
2510   -
2511   - } else {
2512   - var dd = {
2513   - parent_sn: data.data,
2514   - store_id: oo.stoid,
2515   - type: 2,
2516   - };
2517   - a.post("/api/weshop/order/pay/createOrder", {
2518   - data: dd,
2519   - success: function (t) {
2520   - //console.log(t);
2521   - if (t.data.code == 0) {
2522   - //app.my_warnning("支付成功",1,th);
2523   - //setTimeout(function () {
2524   - th.setData({isclose: 0});
2525   - wx.redirectTo({
2526   - url: "/pages/payment/pay_success/pay_success?type=2&order_sn=" + data.data,
2527   - })
2528   - //}, 1000)
2529   - }
2530   - },
2531   - fail: function () {
2532   -
2533   - }
2534   - });
2535   - }
2536 1114  
2537   - }
2538   - else {
2539   - //--内容换行--
2540   - var msg = data.msg;
2541   - //赠品活动已经取消,无法赠送,是否继续买单?
2542   - if (msg.indexOf("是否继续买单") > 0) {
2543   - wx.showModal({
2544   - title: "提示",
2545   - content: data.msg,
2546   - cancelText: '取消',
2547   - confirmText: '确定',
2548   - showCancel: true,
2549   - success(res){
2550   - if (res.cancel) {
2551   - return;
2552   - } else if (res.confirm) {
2553   - th.data.is_continue = 1;
2554   - th.data.is_summit_ing = 0; //是否提交中
2555   - th.submitForm(sub_value);
2556   - }
2557   - }
2558   - })
2559   - return;
2560   - }
2561   - if (msg.length > 13) {
2562   - msg = msg.slice(0, 13) + "\r\n" + msg.slice(13);
2563   - }
2564   - getApp().confirmBox(msg);
2565   - th.data.is_summit_ing = 0; //是否提交中
2566   - }
2567   - } else {
2568   - th.data.is_summit_ing = 0; //是否提交中
2569   - console.log("index.js wx.request CheckCallUser statusCode" + res.statusCode);
2570   - }
2571   - },
2572   - fail: function () {
2573   - th.data.is_summit_ing = 0;
2574   - wx.hideLoading();
2575   - console.log("index.js wx.request CheckCallUser fail");
2576   - },
2577   - complete: function () {
2578   - }
2579   - })
  1115 + var txt = "selected_quan_list[" + ind + "].show_red";
  1116 + var obj = {};
  1117 + obj[txt] = 1;
  1118 + if (quan_item.show_red) {
  1119 + obj[txt] = 0;
  1120 + }
  1121 + this.setData(obj);
  1122 + console.log(this.data.selected_quan_list, "选中的券的下标", quan_item, "数据都在这里", txt);
  1123 + if (using_quan[pickid]) {
  1124 + using_quan[pickid].is_nouse_red = 0;
  1125 + }
  1126 + else {
  1127 + using_quan[pickid] = {is_nouse_red: 0};
  1128 + }
  1129 + this.setData({using_quan: using_quan});
2580 1130  
2581 1131 },
2582   - //---确认线下门店的数量足不足---
2583   - async check_store_num(goods_id, pick, goods_num, func){
2584   - var lock = 0, pick_no, plist, erpwareid;
2585   - //先读取门店的lock
2586   - await getApp().request.promiseGet("/api/weshop/order/ware/lock/page", {
2587   - data: {store_id: os.stoid, wareId: goods_id, storageId: pick, pageSize: 1000}
2588   - }).then(res => {
2589   - if (res.data.code == 0 && res.data.data.total > 0) {
2590   - for (var i in res.data.data.pageData)
2591   - lock += res.data.data.pageData[i].outQty;
2592   - }
2593   - })
2594   - //先获取门店的编号
2595   - await getApp().request.promiseGet("/api/weshop/pickup/get/" + os.stoid + "/" + pick, {
2596   - data: {storeId: os.stoid, goodsId: t.goods_id, pickupId: pick}
2597   - }).then(res => {
2598   - if (res.data.code == 0) {
2599   - pick_no = res.data.data.pickup_no;
  1132 + /*----- 点击选择包邮券 -----*/
  1133 + sele_quan_item_by: function (e) {
  1134 + var no_use = e.currentTarget.dataset.no;
  1135 + //立即购买的包邮券
  1136 + var by_quanlist = this.data.get_by_quan_list;
  1137 + if (by_quanlist) {
  1138 + //---所有的券的显示红色选择都清理一遍---
  1139 + for (var ind in by_quanlist) {
  1140 + by_quanlist[ind].show_red = 0;
2600 1141 }
2601   - })
2602   - //先获取商品的线下库存
2603   - await getApp().request.promiseGet("/api/weshop/goods/get/" + os.stoid + "/" + goods_id, {
2604   - data: {storeId: os.stoid, goodsId: t.goods_id, pickupId: pick}
2605   - }).then(res => {
2606   - if (res.data.code == 0) {
2607   - erpwareid = res.data.data.erpwareid;
  1142 + this.setData({get_by_quan_list: by_quanlist});
  1143 + }
  1144 +
  1145 + //--购物车过来的包邮券--
  1146 + var by_cart_list = this.data.by_quan_list_cart;
  1147 + if (by_cart_list) {
  1148 + //---所有的券的显示红色选择都清理一遍---
  1149 + for (var ind in by_cart_list) {
  1150 + by_cart_list[ind].show_red = 0;
2608 1151 }
2609   - })
2610   - //读取线下的门店库存
2611   - await getApp().request.promiseGet("/api/weshop/goods/getWareStorages", {
2612   - data: {storageNos: pick_no, wareIds: encodeURIComponent(erpwareid), storeId: os.stoid, pageSize: 2000}
2613   - }).then(res => {
2614   - if (res.data.code == 0) {
2615   - plist = res.data.data.pageData[0];
  1152 + this.setData({by_quan_list_cart: by_cart_list});
  1153 + }
  1154 + //普通券
  1155 + var quanlist = this.data.selected_quan_list;
  1156 + if (quanlist) {
  1157 + //---所有的券的显示红色选择都清理一遍---
  1158 + for (var ind in quanlist) {
  1159 + quanlist[ind].show_red = 0;
2616 1160 }
2617   - })
2618   - var isok = 1;
2619   - if (goods_num > plist.CanOutQty - lock) {
2620   - isok = 0;
  1161 + this.setData({selected_quan_list: quanlist});
2621 1162 }
2622   - func(isok);
2623   - },
2624 1163  
2625   - useCoupon: function () {
2626   - if (this.data.order.couponNum <= 0) {
2627   - getApp().my_warnning("无可用优惠券", 0, this);
  1164 + var th = this;
  1165 + var using_quan = this.data.using_quan;
  1166 + //---如果是不使用优惠券---
  1167 + if (no_use == 1) {
  1168 + if (using_quan[th.data.selected_quan_pick]) {
  1169 + using_quan[th.data.selected_quan_pick].is_nouse_red = 1;
  1170 + }
  1171 + else {
  1172 + using_quan[th.data.selected_quan_pick] = {is_nouse_red: 1};
  1173 + }
  1174 + this.setData({using_quan: using_quan, is_coupon: 2222});
2628 1175 return;
2629 1176 }
2630 1177  
2631   - var a = {
2632   - lid: this.data.coupon ? this.data.coupon.id : "0"
2633   - };
2634   - wx.navigateTo({
2635   - url: "/pages/user/checkcoupon/checkcoupon?" + s.Obj2Str(a)
2636   - });
2637   - },
2638   - enterAddressPage: function () {
2639   - getApp().globalData.is_cart_old = 1;
2640   - this.data.isget_by_quan = {};
2641   - this.data.enterAddressPage = !0, wx.navigateTo({
2642   - url: "/pages/user/address_list/address_list"
2643   - });
2644   - },
2645   -
2646   - //--------购物车购买时,选择自提和物流-----------
2647   - setexptype_w: function (t) {
2648   -
2649   - var def_exp_code = getApp().globalData.userInfo.def_exp_code, th = this;
2650   - var ty = t.currentTarget.dataset.t, txt = t.currentTarget.dataset.txt,
2651   - wl_txt = t.currentTarget.dataset.wl_txt,
2652   - ont = t.currentTarget.dataset.ont;
2653   -
2654   - th.setData({[txt]: ty});
2655   - var iszt = 1;
2656   -
2657   - if (ty == 0) {
2658   - th.setData({is_all_zt: 0});
  1178 + var pickid = th.data.selected_quan_pick; //现在选择的是哪一个门店
  1179 + var ind = e.currentTarget.dataset.ind;
  1180 + //--如果是立即购买的部分--
  1181 + var txt = "";
  1182 + var txt1 = "";
  1183 + var quan_item = null;
  1184 + if (th.data.is_b_now) {
  1185 + quan_item = this.data.get_by_quan_list[ind];
  1186 + txt = "get_by_quan_list[" + ind + "].show_red";
  1187 + var obj = {};
  1188 + obj[txt] = 1;
  1189 + this.setData(obj);
2659 1190 } else {
2660   - for (var i = 0; i < th.data.cartlist.length; i++) {
2661   - var item = th.data.cartlist[i];
2662   - if (item.exp_type == 0) {
2663   - iszt = 0;
2664   - break;
2665   - }
2666   - }
2667   -
2668   - th.setData({is_all_zt: iszt});
2669   -
2670   - var ind = t.currentTarget.dataset.ind;
2671   - var c_item = th.data.cartlist[ind];
2672   - var pickid = c_item.pickup_id;
2673   -
2674   - if (th.data.using_quan[pickid] && th.data.using_quan[pickid].isby == 1) {
2675   - th.data.using_quan[pickid] = {};
2676   - th.setData({using_quan: th.data.using_quan});
2677   - }
2678   -
  1191 + txt = "by_quan_list_cart[" + ind + "].show_red";
  1192 + quan_item = th.data.by_quan_list_cart[ind];
  1193 + var obj = {};
  1194 + obj[txt] = 1;
  1195 + this.setData(obj);
  1196 + th.data.get_by_quan_list_cart[pickid] = JSON.parse(JSON.stringify(th.data.by_quan_list_cart)); //要把选中的弄回数组
  1197 + }
2679 1198  
  1199 + if (using_quan[th.data.selected_quan_pick]) {
  1200 + using_quan[th.data.selected_quan_pick].is_nouse_red = 0;
2680 1201 }
2681   - //判断有没有默认的物流地址值
2682   - if (def_exp_code != "" && def_exp_code != null && def_exp_code != undefined) {
2683   - var wu_arr = this.data.wu_arr;
2684   - if (wu_arr != null && wu_arr != "") {
2685   - for (var i = 0; i < wu_arr.length; i++) {
2686   - if (wu_arr[i].shipping_code == def_exp_code) {
2687   - var set_txt = "cartlist"
2688   - th.setData({wl_txt: i});
2689   - }
2690   - }
2691   - }
  1202 + else {
  1203 + using_quan[th.data.selected_quan_pick] = {is_nouse_red: 0};
2692 1204 }
2693   - //----计算此时购物车的价格----
2694   - th.calculatePrice();
  1205 + this.setData({using_quan: using_quan});
2695 1206 },
2696   -
2697   - //--------立即购买时,选择自提和物流----------
2698   - setexptype: function (t) {
  1207 + //--确认使用券---
  1208 + confirm_quan: function () {
  1209 + var using_quan = this.data.using_quan; //正在使用中的券列表
  1210 + var pickid = this.data.pickup.pickup_id; //选中的门店ID
2699 1211 var th = this;
2700   - var ty = t.currentTarget.dataset.t, def_exp_code = getApp().globalData.userInfo.def_exp_code;
2701   - th.setData({bn_exp_type: ty});
2702   - if (ty == 0) {
2703   - th.setData({is_all_zt: 0});
2704   - }
  1212 + var selected_quan_list = this.data.selected_quan_list; //选择了那个门店的券列表
  1213 + var get_by_quan_list = this.data.get_by_quan_list; //立即购买的包邮券列表
  1214 + var by_quan_list_cart = this.data.by_quan_list_cart; //购物车购买的包邮券列表
2705 1215  
2706   - //当物流为空的时候。
2707   - if (ty == 0 && th.data.wu_arr == null) {
2708   - th.data.isget_by_quan = {};
2709   - return th.get_wuliu(th.calculatePrice2());
  1216 + //循环普通的券
  1217 + for (var i in selected_quan_list) {
  1218 + var item = selected_quan_list[i];
  1219 + if (item.show_red) {
  1220 + th.insert_into_using_quan(item, using_quan, pickid);
  1221 + return;
  1222 + }
2710 1223 }
  1224 + //循环包邮的券,立即购买的
  1225 + for (var i in get_by_quan_list) {
  1226 + var item = get_by_quan_list[i];
  1227 + if (item.show_red) {
  1228 + if (th.data.is_no_by[pickid] == 1) {
  1229 + getApp().my_warnning("已全场不能包邮,不能选择包邮券", 0, th);
  1230 + return false;
  1231 + }
  1232 + if (th.data.is_by[pickid] == 1) {
  1233 + getApp().my_warnning("已全场包邮,不能选择包邮券", 0, th);
  1234 + return false;
  1235 + }
2711 1236  
2712   - //--自提就要把包邮券清理掉--
2713   - if (ty == 1) {
2714   - th.data.isget_by_quan = {};
2715   - if (th.data.using_quan[th.data.bn_pick] && th.data.using_quan[th.data.bn_pick].isby == 1) {
2716   - th.setData({using_quan: {}});
  1237 + th.insert_into_using_quan(item, using_quan, pickid, 1);
  1238 + return;
2717 1239 }
2718 1240 }
2719 1241  
2720   - //判断有没有默认的物流地址值
2721   - if (def_exp_code != "" && def_exp_code != null && def_exp_code != undefined) {
2722   - var wu_arr = this.data.wu_arr;
2723   - if (wu_arr != null && wu_arr != "") {
2724   - for (var i = 0; i < wu_arr.length; i++) {
2725   - if (wu_arr[i].shipping_code == def_exp_code) {
2726   - th.setData({index: i});
2727   - }
  1242 + //循环包邮的券
  1243 + for (var i in by_quan_list_cart) {
  1244 + var item = by_quan_list_cart[i];
  1245 + if (item.show_red) {
  1246 + if (th.data.is_no_by[pickid] == 1) {
  1247 + getApp().my_warnning("已全场不能包邮,不能选择包邮券", 0, th);
  1248 + return false;
  1249 + }
  1250 + if (th.data.is_by[pickid] == 1) {
  1251 + getApp().my_warnning("已全场包邮,不能选择包邮券", 0, th);
  1252 + return false;
2728 1253 }
  1254 + th.insert_into_using_quan(item, using_quan, pickid, 1);
  1255 + return;
2729 1256 }
2730 1257 }
2731   - th.calculatePrice2()
2732 1258  
2733   - },
  1259 + //选择了的券,看是不是点击了不使用券,点击了不使用优惠券
  1260 + if (using_quan[pickid]) {
  1261 + if (using_quan[pickid].is_nouse_red == 1) {
  1262 + using_quan[pickid] = {is_nouse_red: 1};
  1263 + th.calculatePrice2();
  1264 + th.setData({open_quan: 0});
  1265 + th.setData({using_quan: using_quan});
  1266 + }
  1267 + }
  1268 +
  1269 +
2734 1270  
2735   - //--------立即购买时,使用余额--------
2736   - set_bn_useyuer: function () {
2737   - var th = this;
2738   - th.setData({bn_use_money: !th.data.bn_use_money});
2739   - th.calculatePrice2();
2740 1271 },
2741   - set_js_useyuer: function () {
  1272 +
  1273 + //----把券插入之后的操作,同时还要重新计算价格----
  1274 + insert_into_using_quan: function (item, using_quan, pickid, isby) {
2742 1275 var th = this;
2743   - th.setData({js_use_money: !th.data.js_use_money});
2744   - th.calculatePrice();
2745   - },
2746   - //-------------------计算物流---------------
2747   - calculatewuliu: function (code, o_shipping_price, goods_weight,
2748   - goods_piece, user_addr, freight_free, o_price, rs) {
2749   - var price = 0, th = this;
2750   - price += parseFloat(o_shipping_price);
2751   - //如果是包邮
2752   - if (freight_free > 0 && o_price >= freight_free) {
2753   - return 0;
2754   - }
2755   - if (user_addr == null) {
2756   - return 0;
2757   - }
2758   - //计算物流的config item;
2759   - var item = null;
2760   - //先根据 镇 县 区找计算的config
2761   - item = th.get_wuliu_config(user_addr.district, code, rs);
2762   - if (item == null) item = th.get_wuliu_config(user_addr.city, code, rs);
2763   - if (item == null) item = th.get_wuliu_config(user_addr.province, code, rs);
2764   - if (item == null) item = th.get_wuliu_default(code, rs);
2765   - if (item == null) return o_shipping_price;
2766   - var fw_price = 0, fp_price = 0;
2767   - item = item.config;
2768   - if (item == null) return o_shipping_price;
2769   - //------按重量----------
2770   - if (goods_weight >= 0 && item['money']) {
2771   - fw_price = parseFloat(item['money']);
2772   - if (goods_weight > item['first_weight']) {
2773   - var fw = goods_weight - item['first_weight'];
2774   - var n = Math.ceil(fw / item['second_weight'])
2775   - fw_price = fw_price + n * parseFloat(item['add_money']);
2776   - }
2777   - }
2778   - //------按件数----------
2779   - if (goods_piece > 0 && item['piecemoney']) {
2780   - fp_price = parseFloat(item['piecemoney']);
2781   - if (goods_piece > item['first_piece']) {
2782   - var fp = goods_piece - item['first_piece'];
2783   - var m = Math.ceil(fp / item['second_piece'])
2784   - fp_price = fp_price + m * parseFloat(item['add_piecemoney']);
2785   - }
  1276 + if (isby == 1) {
  1277 + using_quan[pickid] = {
  1278 + coupon_no: item.no,
  1279 + money: 0,
  1280 + is_nouse_red: 0,
  1281 + region_list: item.region_list,
  1282 + goods_list: item.goods_list
  1283 + };
  1284 + using_quan[pickid].isby = 1;
  1285 + } else {
  1286 + using_quan[pickid] = {coupon_no: item.CashRepNo, money: item.Sum, is_nouse_red: 0};
  1287 + using_quan[pickid].isby = 0;
2786 1288 }
2787   - var rspice = parseFloat(price + fw_price + fp_price);
2788   - return rspice;
  1289 + this.setData({using_quan: using_quan});
  1290 + th.calculatePrice2();
  1291 + th.setData({open_quan: 0});
2789 1292 },
2790 1293  
2791   - //------------循环获取config-----------
2792   - get_wuliu_config: function (region_id, code, rs) {
2793   - var item = null, rslist = rs.pageData;
2794   - for (var i = 0; i < rslist.length; i++) {
2795   - if (rslist[i].code == code && rslist[i].region_id == region_id) {
2796   - item = rslist[i];
2797   - }
2798   - }
2799   - return item;
  1294 + cart_set_err: function (e) {
  1295 + var txt = e.currentTarget.dataset.err;
  1296 + var ob = {};
  1297 + ob[txt] = this.data.imgUrl + "/miniapp/images/default_g_img.gif";
  1298 + this.setData(ob);
2800 1299 },
2801   - //-------循环获取config,code default-------
2802   - get_wuliu_default: function (code, rs) {
2803   - var item = null, rslist = rs.pageData;
2804   - for (var i = 0; i < rslist.length; i++) {
2805   - if (rslist[i].shipping_code == code && rslist[i].is_default == 1) {
2806   - item = rslist[i];
  1300 + //--验证是否已经冻结--
  1301 + check_is_frozenQuan: function (quanlist, frozenQuan, isby) {
  1302 + console.log("券列表", quanlist);
  1303 + if (!quanlist) return null;
  1304 + if (!frozenQuan) return quanlist;
  1305 + var arr = [];
  1306 + for (var i = 0; i < quanlist.length; i++) {
  1307 + var item = quanlist[i];
  1308 + var is_find = 0;
  1309 + var Q_no = quanlist[i].CashRepNo;
  1310 + if (isby) Q_no = quanlist[i].no;
  1311 + for (var j = 0; j < frozenQuan.length; j++) {
  1312 + var q_no = frozenQuan[j].cashRepNo;
  1313 + if (Q_no == q_no) {
  1314 + is_find = 1;
  1315 + break;
  1316 + }
2807 1317 }
  1318 + if (!is_find) arr.push(item);
2808 1319 }
2809   - return item;
  1320 + return arr;
2810 1321 },
2811 1322  
2812   - //----------立即购买,选择物流-------------
2813   - bindPickerChange: function (e) {
2814   - var ind = e.detail.value
2815   - this.setData({index: ind});
2816   - this.calculatePrice2();
  1323 + //// 开启物流的弹窗
  1324 + show_wu_arr: function (e) {
  1325 + var wu_arr_txt = e.currentTarget.dataset.txt;
  1326 + var w_sele_index = e.currentTarget.dataset.w_sele_index;
  1327 + var is_express = null;
  1328 + var ob = {open_express: 1, wu_arr_txt: wu_arr_txt, disabled: 1};
  1329 +
  1330 + //--如果是多个门店的时候--
  1331 + if (w_sele_index != undefined) {
  1332 + is_express = this.data.cartlist[w_sele_index].wind;
  1333 + ob['is_express'] = is_express;
  1334 + }
  1335 + this.setData(ob);
2817 1336 },
2818   - //----------购物车结算,选择物流-------------
2819   - bindPickerChange_w: function (e) {
2820   - var ind = e.detail.value, txt = e.currentTarget.dataset.txt;
2821   - this.setData({[txt]: ind});
2822   - this.calculatePrice();
  1337 + // 关闭物流的弹窗
  1338 + close_express: function () {
  1339 + this.setData({open_express: 0, disabled: 0});
  1340 + },
  1341 + // 选择物流
  1342 + click_express_name: function (e) {
  1343 + var express_name = e.currentTarget.dataset.name, shippingcode = e.currentTarget.dataset.shippingcode;
  1344 + var index = e.currentTarget.dataset.idxe;
  1345 + var ob = {is_express: index, is_shipping_code: shippingcode, disabled: 0};
  1346 + ob[this.data.wu_arr_txt] = index;
  1347 + this.setData(ob);
2823 1348 },
2824 1349  
2825   - /*----券的所有操作----*/
2826   - open_coupon_list: function (e) {
2827   - var th = this;
2828   - var pickid = e.currentTarget.dataset.pickid;
2829   - var bn = e.currentTarget.dataset.bn;
2830   - var cindx = e.currentTarget.dataset.cind;
2831   - var get_by_quan_list_cart = th.data.get_by_quan_list_cart[pickid];
  1350 + //点击确定物流
  1351 + determine_expres: function (e) {
  1352 + this.setData({open_express: 0});
  1353 + this.calculatePrice2();
  1354 + },
2832 1355  
  1356 + //点击打开优惠券使用说明
  1357 + clik_coupons: function (e) {
  1358 + var ind = e.currentTarget.dataset.idx;
  1359 + var is_open = this.data.selected_quan_list[ind].is_open;
2833 1360  
2834   - if (bn == 1) {
2835   - th.setData({open_quan: 1, selected_quan_pick: pickid, disabled: 1});
2836   - } else {
2837   - //---多单打开券的时候,就要判断券在其他门店是否有使用---
2838   - var quanlist = th.data.cartlist[cindx].quan_list;
2839   - var exp_type = th.data.cartlist[cindx].exp_type;
  1361 + if (is_open == 1) is_open = 0;
  1362 + else is_open = 1;
2840 1363  
  1364 + var txt = "selected_quan_list[" + ind + "].is_open"
  1365 + var obj = {};
  1366 + obj[txt] = is_open;
2841 1367  
2842   - //对于在其他门店已经选择了的券 要判断是否显示到界面
2843   - var t_user = th.data.using_quan[pickid];
  1368 + this.setData(obj);
  1369 + this.setData({disabled: 1})
  1370 + },
2844 1371  
2845   - for (var i in quanlist) {
2846   - quanlist[i].is_using = th.check_in_sele(quanlist[i].CashRepNo, pickid);
2847   - if (t_user && quanlist[i].CashRepNo == t_user.coupon_no)
2848   - quanlist[i].show_red = 1;
2849   - else
2850   - quanlist[i].show_red = 0;
2851   - }
  1372 + clik_coupons2: function (e) {
  1373 + var ind = e.currentTarget.dataset.idx;
  1374 + var is_open = this.data.get_by_quan_list[ind].is_open;
2852 1375  
2853   - if (get_by_quan_list_cart) {
2854   - for (var i in get_by_quan_list_cart) {
2855   - get_by_quan_list_cart[i].is_using = th.check_in_sele(get_by_quan_list_cart[i].no, pickid);
2856   - if (t_user && get_by_quan_list_cart[i].no == t_user.coupon_no)
2857   - get_by_quan_list_cart[i].show_red = 1;
2858   - else
2859   - get_by_quan_list_cart[i].show_red = 0;
2860   - }
2861   - th.setData({by_quan_list_cart: get_by_quan_list_cart});
2862   - } else {
2863   - th.setData({by_quan_list_cart: null});
2864   - }
  1376 + if (is_open == 1) is_open = 0;
  1377 + else is_open = 1;
2865 1378  
2866   - console.log("2222222券的列表", quanlist);
2867   - th.setData({
2868   - sele_cart_ind: cindx,
2869   - sele_exp_type: exp_type,
2870   - open_quan: 1,
2871   - selected_quan_pick: pickid,
2872   - selected_quan_list: quanlist,
2873   - disabled: 1
2874   - });
2875   - }
2876   - },
2877   - close_coupon: function (e) {
2878   - var th = this;
2879   - th.setData({open_quan: 0, disabled: 0});
  1379 + var txt = "get_by_quan_list[" + ind + "].is_open"
  1380 + var obj = {};
  1381 + obj[txt] = is_open;
  1382 +
  1383 + this.setData(obj);
  1384 + this.setData({disabled: 1})
2880 1385 },
2881 1386  
2882   - //---判断券时候在已经选择的列表中---
2883   - check_in_sele: function (no, pick_id) {
  1387 +
  1388 + //设置默认物流
  1389 + select_default_logistics: function () {
2884 1390 var th = this;
2885   - if (th.data.using_quan.length <= 0) return false;
2886   - for (var i in th.data.using_quan) {
2887   - //--如果键值等于本身就要跳出--
2888   - if (parseInt(i) == parseInt(pick_id)) continue;
2889   - var item = th.data.using_quan[i];
2890   - if (item.coupon_no == no) {
2891   - return true;
  1391 + var is_shipping_code = this.data.is_shipping_code
  1392 + getApp().request.put("/api/weshop/users/update", {
  1393 + data: {user_id: getApp().globalData.user_id, store_id: oo.stoid, def_exp_code: is_shipping_code},
  1394 + success: function (rse) {
  1395 + if (rse.data.code == 0) {
  1396 + getApp().globalData.userInfo.def_exp_code = is_shipping_code;
  1397 + th.setData({open_express: 0});
  1398 + //----计算此时购物车的价格----
  1399 + th.calculatePrice2();
  1400 +
  1401 + }
2892 1402 }
2893   - }
2894   - return false;
  1403 + })
2895 1404 },
2896 1405  
2897   - /*--点击选择券--*/
2898   - sele_quan_item: function (e) {
2899   -
2900   - var ind = e.currentTarget.dataset.ind;
2901   - var quan_item = this.data.selected_quan_list[ind];
2902   - var pickid = this.data.selected_quan_pick; //现在选择的是哪一个门店
2903   - //--如果券是单品使用的时候--
2904   - if (quan_item && quan_item.UseObjectType && quan_item.UseObjectType == "20") {
2905   - //---只有多件购买的时候才要计算,//购物车购买和搭配勾的时候---
2906   - var gg = getApp().get_b_now();
2907   - if (this.data.is_b_now == 0 || gg.prom_type == 5) {
2908   - var arr = this.data.order_prom_list_cart;
2909   - var t_pk_item = null;
2910   - for (var ii in arr) {
2911   - var ep = arr[ii];
2912   - if (pickid == ep.pickup_id) {
2913   - t_pk_item = ep;
2914   - break;
  1406 + //更新下默认,在onshow里面
  1407 + update_code(){
  1408 + var th = this, m_wind = 0, def_exp_code = getApp().globalData.userInfo.def_exp_code;
  1409 + //--定时器,判断wu_arr不未空--
  1410 + var uii = setInterval(function () {
  1411 + if (th.data.wu_arr) {
  1412 + clearInterval(uii);
  1413 + for (var k = 0; k < th.data.wu_arr.length; k++) {
  1414 + var item = th.data.wu_arr[k];
  1415 + if (def_exp_code == item.code) {
  1416 + m_wind = k;
2915 1417 }
2916 1418 }
2917   - //--寻找券指定的商品--
2918   - var gd = null;
2919   - if (t_pk_item) {
2920   - var goods = t_pk_item.goods;
2921   - for (var gid in goods) {
2922   - if (quan_item.UseObjectID == goods[gid].erpwareid) {
2923   - gd = goods[gid];
  1419 + //--如果是立即购买--
  1420 + if (th.data.is_b_now == 1) {
  1421 + th.setData({index: m_wind, is_express: m_wind});
  1422 + } else {
  1423 + var ui = setInterval(function () {
  1424 + if (th.data.cartlist) {
  1425 + var c_arr = th.data.cartlist;
  1426 + for (var i in c_arr) {
  1427 + c_arr[i].wind = m_wind;
  1428 + }
  1429 + th.setData({cartlist: c_arr, is_express: m_wind})
  1430 + clearInterval(ui);
2924 1431 }
2925   - }
  1432 + }, 500)
2926 1433 }
2927   - if (!gd) {
2928   - getApp().my_warnning("未找到指定商品使用", 0, this, 600);
2929   - return false;
  1434 + }
  1435 + }, 500);
  1436 + },
  1437 + //-----获取购物车进来的劵-------
  1438 + get_cart_quan: async function (order_prom_list_cart) {
  1439 + var th = this;
  1440 + var is_xz_yh = 1;
  1441 + //等待值的出现
  1442 + //getApp().waitfor2(this,"g_cart_q_time","order_prom_list_cart",async function () {
  1443 + //var arr=th.data.order_prom_list_cart;
  1444 + var arr = order_prom_list_cart;
  1445 + if (!arr) arr = [];
  1446 + //如果系统有限制使用优惠券
  1447 + if (th.data.is_close_quan) return false;
  1448 +
  1449 + //------------开始计算使用优惠券相关------------
  1450 + for (var ind in arr) {
  1451 + var ep = arr[ind];
  1452 + var goodlist = ep.goods;
  1453 + var pickup_id = ep.pickup_id;
  1454 + //--更优惠券抵用有关,立即购买的,如果是购物车,如果有等级价还有考虑等级价的东西
  1455 + //就要把相应的值,写入cartlist数组中--
  1456 + var ckeck_quan_price = 0,
  1457 + check_quan_price_list = '',
  1458 + check_quan_ware_list = '';
  1459 +
  1460 + for (var i in goodlist) {
  1461 + var gd = goodlist[i];
  1462 + //--如果是秒杀就跳出,如果是赠品,如果是组合购,如果是限制使用优惠券--
  1463 + if (gd.prom_type == 1 || gd.is_gift || gd.prom_type == 7) {
  1464 + continue;
  1465 + }
  1466 + //如果有限制使用优惠券,就要返回
  1467 + if (gd.prom_type == 3) {
  1468 + if (th.data.prom_goods_map[pickup_id][gd.prom_id].is_xz_yh) continue;
  1469 + th.data.prom_goods_map[pickup_id][gd.prom_id].coupon_sele = 1;
2930 1470 }
2931   - //计算价格,如果有平摊的实收要计算实收的金额
  1471 + is_xz_yh = 0;
2932 1472 var item_price = gd.goods_price * gd.goods_num;
2933   - //-- 如果有平摊下去,有实收价格的时候,就要用account_fir来计算价格 --
  1473 + //-- 如果有平摊下去,有实收价格的时候,就要用account来计算价格 --
2934 1474 if (gd.account_fir != null && gd.account_fir != undefined) {
2935 1475 item_price = gd.account_fir * gd.goods_num;
2936 1476 }
  1477 + ckeck_quan_price += item_price;
2937 1478  
2938   - if (item_price < parseFloat(quan_item.BuySum)) {
2939   - getApp().my_warnning("该单品金额没有大于等于" + quan_item.BuySum + "元时不能使用优惠券", 0, this, 600);
2940   - return false;
  1479 + //--组装价格list--
  1480 + if (check_quan_price_list) {
  1481 + check_quan_price_list += "," + item_price;
  1482 + } else {
  1483 + check_quan_price_list = item_price;
  1484 + }
  1485 + //--组装商品的线下erpwareid--
  1486 + if (check_quan_ware_list) {
  1487 + check_quan_ware_list += "," + encodeURIComponent(gd['erpwareid']);
  1488 + } else {
  1489 + check_quan_ware_list = encodeURIComponent(gd['erpwareid']);
2941 1490 }
2942 1491 }
2943   - }
2944   -
2945   - var no_use = e.currentTarget.dataset.no, quanlist = this.data.selected_quan_list;
2946   - //---所有的券的显示红色选择都清理一遍---
2947   - for (var i in quanlist) {
2948   - quanlist[i].show_red = 0;
2949   - }
2950   - this.setData({selected_quan_list: quanlist});
2951   - var by_quanlist = this.data.get_by_quan_list;
2952   - if (by_quanlist) {
2953   - //---所有的券的显示红色选择都清理一遍---
2954   - for (var inb in by_quanlist) {
2955   - by_quanlist[inb].show_red = 0;
  1492 + //优惠券优惠的金额要控制到优惠券的选择条件
  1493 + var cut_price = 0;
  1494 + for (var i in th.data.prom_goods_map[pickup_id]) {
  1495 + var obj = th.data.prom_goods_map[pickup_id][i];
  1496 + if (obj.coupon_sele) {
  1497 + cut_price += obj.price - obj.prom_price;
  1498 + }
2956 1499 }
2957   - this.setData({get_by_quan_list: by_quanlist});
2958   - }
2959 1500  
2960   - var by_cart_list = this.data.by_quan_list_cart;
2961   - if (by_cart_list) {
2962   - //---所有的券的显示红色选择都清理一遍---
2963   - for (var inc in by_cart_list) {
2964   - by_cart_list[inc].show_red = 0;
  1501 + arr[ind].ckeck_quan_price = ckeck_quan_price - cut_price;
  1502 + arr[ind].check_quan_ware_list = check_quan_ware_list;
  1503 + arr[ind].check_quan_price_list = check_quan_price_list;
  1504 +
  1505 + //是否关闭使用优惠券
  1506 + if (th.data.is_close_quan != 1 && !is_xz_yh) {
  1507 + //--调用接口,获取优惠券的列表,3秒钟内控制接口请求--
  1508 + var url = "/api/weshop/couponList/getUseCouponList";
  1509 + await app.request.promiseGet(url, {
  1510 + data: {
  1511 + storeId: oo.stoid,
  1512 + userId: app.globalData.user_id,
  1513 + BuySum: ckeck_quan_price,
  1514 + WareIds: check_quan_ware_list,
  1515 + pageSize: 100
  1516 + }
  1517 + }).then(res => {
  1518 + if (res.data.code == 0) {
  1519 + var quan_list = res.data.data.pageData;
  1520 + arr[ind].quan_list = th.check_is_frozenQuan(quan_list, th.data.frozenQuan);
  1521 + }
  1522 + })
2965 1523 }
2966   - this.setData({by_quan_list_cart: by_cart_list});
2967 1524 }
2968 1525  
2969   - var using_quan = this.data.using_quan;
2970   - var th = this;
2971   - //---如果是不使用优惠券---
2972   - if (no_use == 1) {
2973   - console.log("有进来吗券", no_use);
2974   - if (using_quan[th.data.selected_quan_pick]) {
2975   - using_quan[th.data.selected_quan_pick].is_nouse_red = 1;
2976   - }
2977   - else {
2978   - using_quan[th.data.selected_quan_pick] = {is_nouse_red: 1};
  1526 + //如果是搭配购的立即购买的时候
  1527 + if (th.data.is_b_now) {
  1528 + if (arr && arr.length > 0) {
  1529 + var quanlist = arr[0].quan_list;
  1530 + th.setData({selected_quan_list: quanlist, cartlist: arr})
2979 1531 }
2980   - this.setData({using_quan: using_quan, is_coupon: 2222});
2981   - return;
  1532 + } else {
  1533 + th.setData({cartlist: arr})
  1534 + th.set_can_num();
2982 1535 }
  1536 + },
2983 1537  
  1538 + //------ 获取立即购买的购物车的劵 --------
  1539 + get_buy_now_quan: function () {
  1540 + var quanlist = null, th = this, frozenQuan = null;
  1541 + var allprice =this.data.pre_arr.presell_price*this.data.order_goods.goods_num;
  1542 + th.data.ckeck_quan_price = allprice;
2984 1543  
2985   - var txt = "selected_quan_list[" + ind + "].show_red";
2986   - var obj = {};
2987   - obj[txt] = 1;
2988   - if (quan_item.show_red) {
2989   - obj[txt] = 0;
2990   - }
2991   - this.setData(obj);
2992   - console.log(this.data.selected_quan_list, "选中的券的下标", quan_item, "数据都在这里", txt);
2993   - if (using_quan[th.data.selected_quan_pick]) {
2994   - using_quan[th.data.selected_quan_pick].is_nouse_red = 0;
2995   - }
2996   - else {
2997   - using_quan[th.data.selected_quan_pick] = {is_nouse_red: 0};
  1544 + //--如果商家后台没有限制使用优惠券,同时商品的优惠活动没有限制使用优惠券--
  1545 + if (th.data.is_close_quan != 1) {
  1546 + var url0 = "/api/weshop/users/frozenQuan/listFrozenQuan/" + app.globalData.user_id;
  1547 + var url = "/api/weshop/couponList/getUseCouponList";
  1548 + app.request.promiseGet(url0, {1: 1}).then(res => {
  1549 + if (res.data.code == 0) {
  1550 + frozenQuan = res.data.data;
  1551 + th.data.frozenQuan = frozenQuan;
  1552 + }
  1553 + app.request.time_limit_get(6, url, {
  1554 + data: {
  1555 + storeId: oo.stoid,
  1556 + userId: app.globalData.user_id,
  1557 + BuySum: th.data.ckeck_quan_price,
  1558 + WareIds: encodeURIComponent(th.data.check_quan_ware_list),
  1559 + pageSize: 100
  1560 + },
  1561 + success: function (res) {
  1562 + if (res.data.code == 0) {
  1563 + quanlist = res.data.data.pageData;
  1564 + if (quanlist) {
  1565 + quanlist = th.check_is_frozenQuan(quanlist, frozenQuan);
  1566 + th.setData({selected_quan_list: quanlist})
  1567 + }
  1568 + }
  1569 + }
  1570 + })
  1571 + })
2998 1572 }
2999   - this.setData({using_quan: using_quan});
3000   -
3001 1573 },
3002 1574  
3003   -
3004   - /*----- 点击选择包邮券 -----*/
3005   - sele_quan_item_by: function (e) {
3006   - var no_use = e.currentTarget.dataset.no;
3007   - //立即购买的包邮券
3008   - var by_quanlist = this.data.get_by_quan_list;
3009   - if (by_quanlist) {
3010   - //---所有的券的显示红色选择都清理一遍---
3011   - for (var ind in by_quanlist) {
3012   - by_quanlist[ind].show_red = 0;
  1575 + //检查区域是不是包邮
  1576 + check_area: function (arr) {
  1577 + var user_addr = this.data.user_addr;
  1578 + if (!user_addr) return 0;
  1579 + for (var i in arr) {
  1580 + var item = arr[i];
  1581 + if (user_addr.twon == item || user_addr.district == item
  1582 + || user_addr.city == item || user_addr.province == item) {
  1583 + return 0;
3013 1584 }
3014   - this.setData({get_by_quan_list: by_quanlist});
3015 1585 }
  1586 + return 1;
  1587 + },
3016 1588  
3017   - //--购物车过来的包邮券--
3018   - var by_cart_list = this.data.by_quan_list_cart;
3019   - if (by_cart_list) {
3020   - //---所有的券的显示红色选择都清理一遍---
3021   - for (var ind in by_cart_list) {
3022   - by_cart_list[ind].show_red = 0;
3023   - }
3024   - this.setData({by_quan_list_cart: by_cart_list});
3025   - }
3026   - //普通券
3027   - var quanlist = this.data.selected_quan_list;
3028   - if (quanlist) {
3029   - //---所有的券的显示红色选择都清理一遍---
3030   - for (var ind in quanlist) {
3031   - quanlist[ind].show_red = 0;
3032   - }
3033   - this.setData({selected_quan_list: quanlist});
  1589 + //检查立即购买的商品是不是不包邮
  1590 + check_good: function (arr, goods_id) {
  1591 + if (!goods_id) goods_id = this.data.bn_goods.goods_id;
  1592 + for (var i in arr) {
  1593 + var item = arr[i];
  1594 + if (goods_id == item) return 0;
3034 1595 }
  1596 + return 1;
  1597 + },
  1598 + check_by_area: function (region_list) {
  1599 + var arr = region_list.split(",");
  1600 + var check = this.check_area(arr);
  1601 + return !check;
  1602 + },
  1603 + check_by_goods: function (goods_list, goods_id) {
  1604 + var arr = goods_list.split(",");
  1605 + var check = this.check_good(arr, goods_id);
  1606 + return !check;
  1607 + },
3035 1608  
  1609 +
  1610 + //--检查订单优惠--
  1611 + check_is_order_prom: function (condition, func, pick) {
3036 1612 var th = this;
3037   - var using_quan = this.data.using_quan;
3038   - //---如果是不使用优惠券---
3039   - if (no_use == 1) {
3040   - if (using_quan[th.data.selected_quan_pick]) {
3041   - using_quan[th.data.selected_quan_pick].is_nouse_red = 1;
3042   - }
3043   - else {
3044   - using_quan[th.data.selected_quan_pick] = {is_nouse_red: 1};
  1613 + pick = this.data.pickup.pickup_id;
  1614 + //---获取订单优惠---
  1615 + getApp().request.promiseGet("/api/weshop/promorder/getOrderPromotion", {
  1616 + data: {store_id: os.stoid, orderAmount: condition}
  1617 + }).then(res => {
  1618 + if (res.data.code == 0) {
  1619 + var data = res.data.data;
  1620 + th.data.order_prom[pick] = data;
3045 1621 }
3046   - this.setData({using_quan: using_quan, is_coupon: 2222});
3047   - return;
3048   - }
3049   -
3050   - var pickid = th.data.selected_quan_pick; //现在选择的是哪一个门店
3051   - var ind = e.currentTarget.dataset.ind;
3052   - //--如果是立即购买的部分--
3053   - var txt = "";
3054   - var txt1 = "";
3055   - var quan_item = null;
3056   - if (th.data.is_b_now) {
3057   - quan_item = this.data.get_by_quan_list[ind];
3058   - txt = "get_by_quan_list[" + ind + "].show_red";
3059   - var obj = {};
3060   - obj[txt] = 1;
3061   - this.setData(obj);
3062   - } else {
3063   - txt = "by_quan_list_cart[" + ind + "].show_red";
3064   - quan_item = th.data.by_quan_list_cart[ind];
3065   - var obj = {};
3066   - obj[txt] = 1;
3067   - this.setData(obj);
3068   - th.data.get_by_quan_list_cart[pickid] = JSON.parse(JSON.stringify(th.data.by_quan_list_cart)); //要把选中的弄回数组
3069   - }
3070   -
3071   - if (using_quan[th.data.selected_quan_pick]) {
3072   - using_quan[th.data.selected_quan_pick].is_nouse_red = 0;
3073   - }
3074   - else {
3075   - using_quan[th.data.selected_quan_pick] = {is_nouse_red: 0};
3076   - }
3077   - this.setData({using_quan: using_quan});
  1622 + func();
  1623 + })
3078 1624 },
3079 1625  
3080   - //--确认使用券---
3081   - confirm_quan: function () {
3082   - var using_quan = this.data.using_quan; //正在使用中的券列表
3083   - var pickid = this.data.selected_quan_pick; //选中的门店ID
  1626 + //--- 加入优惠活动的映射中,同时要有一个good列表 ---
  1627 + add_prom_goods_map: async function (item) {
3084 1628 var th = this;
3085   - var selected_quan_list = this.data.selected_quan_list; //选择了那个门店的券列表
3086   - var get_by_quan_list = this.data.get_by_quan_list; //立即购买的包邮券列表
3087   - var by_quan_list_cart = this.data.by_quan_list_cart; //购物车购买的包邮券列表
3088   - //选择了的券
3089   - var sele_quan = null;
  1629 + var pickid = item.pick_id;
  1630 + var map = th.data.prom_goods_map;
  1631 + var obj = map[pickid];
3090 1632  
3091   - //循环普通的券
3092   - for (var i in selected_quan_list) {
3093   - var item = selected_quan_list[i];
3094   - if (item.show_red) {
3095   - th.insert_into_using_quan(item, using_quan, pickid);
3096   - return;
  1633 + if (map[pickid]) {
  1634 + if (map[pickid][item.prom_id]) {
  1635 + var ob = map[pickid][item.prom_id];
  1636 + ob.price += item.goods_price * item.goods_num;
  1637 + ob.goods_num += item.goods_num;
  1638 + ob.goods.push({goods_id: item.goods_id, goods_price: item.goods_price, goods_num: item.goods_num});
  1639 +
  1640 + } else {
  1641 + var prom = null;
  1642 + await getApp().request.promiseGet("/api/weshop/promgoods/get/" + os.stoid + "/" + item.prom_id, {}).then(res => {
  1643 + if (res.data.code == 0) {
  1644 + prom = res.data.data;
  1645 + }
  1646 + })
  1647 + var ob = {};
  1648 + ob.prom_id = item.prom_id;
  1649 + ob.price = item.goods_price * item.goods_num;
  1650 + ob.goods_num = item.goods_num;
  1651 + ob.is_bz = prom.is_bz;
  1652 + ob.is_xz_yh = prom.is_xz_yh;
  1653 + ob.goods = new Array();
  1654 + ob.goods.push({goods_id: item.goods_id, goods_price: item.goods_price, goods_num: item.goods_num});
  1655 + map[pickid][item.prom_id] = ob;
3097 1656 }
3098   - }
3099   - //循环包邮的券,立即购买的
3100   - for (var i in get_by_quan_list) {
3101   - var item = get_by_quan_list[i];
3102   - if (item.show_red) {
3103   - if (th.data.is_no_by[pickid] == 1) {
3104   - getApp().my_warnning("已全场不能包邮,不能选择包邮券", 0, th);
3105   - return false;
3106   - }
3107   - if (th.data.is_by[pickid] == 1) {
3108   - getApp().my_warnning("已全场包邮,不能选择包邮券", 0, th);
3109   - return false;
  1657 + } else {
  1658 + var ob = {};
  1659 + var prom = null;
  1660 + await getApp().request.promiseGet("/api/weshop/promgoods/get/" + os.stoid + "/" + item.prom_id, {}).then(res => {
  1661 + if (res.data.code == 0) {
  1662 + prom = res.data.data;
3110 1663 }
  1664 + })
  1665 + ob.prom_id = item.prom_id;
  1666 + ob.price = item.goods_price * item.goods_num;
  1667 + ob.goods_num = item.goods_num;
  1668 + ob.is_bz = prom.is_bz;
  1669 + ob.is_xz_yh = prom.is_xz_yh;
  1670 + ob.goods = new Array();
  1671 + ob.goods.push({goods_id: item.goods_id, goods_price: item.goods_price, goods_num: item.goods_num});
  1672 +
  1673 + var obj = {};
  1674 + obj[item.prom_id] = ob;
  1675 + map[pickid] = obj;
3111 1676  
3112   - th.insert_into_using_quan(item, using_quan, pickid, 1);
3113   - return;
3114   - }
3115 1677 }
  1678 + },
3116 1679  
3117   - //循环包邮的券
3118   - for (var i in by_quan_list_cart) {
3119   - var item = by_quan_list_cart[i];
3120   - if (item.show_red) {
3121   - if (th.data.is_no_by[pickid] == 1) {
3122   - getApp().my_warnning("已全场不能包邮,不能选择包邮券", 0, th);
3123   - return false;
  1680 + //计算立即购买赠品的物流费用
  1681 + get_now_gift_goods_wuliu: function (code, o_shipping_price, user_addr, gift_freight_free, allpice, rs, shipping_price, no_by_data, goods_weight1, goods_piece1) {
  1682 + var good = this.data.buy_now_gift_goods;
  1683 + var goods_weight = -1, goods_piece = -1;
  1684 + var gift_shipping_price = 0;
  1685 + var th = this;
  1686 + switch (good['exp_sum_type']) {
  1687 + case 1:
  1688 + //统一运费
  1689 + gift_shipping_price += good['uniform_exp_sum'];
  1690 + gift_shipping_price += o_shipping_price;
  1691 + break;
  1692 + case 2:
  1693 + if (goods_weight < 0) goods_weight = 0;
  1694 + //累积商品重量 每种商品的重量 * 数量
  1695 + goods_weight += good['weight'] * good['buynum'];
  1696 + if (goods_weight1 > 0) {
  1697 + goods_weight += goods_weight1;
3124 1698 }
3125   - if (th.data.is_by[pickid] == 1) {
3126   - getApp().my_warnning("已全场包邮,不能选择包邮券", 0, th);
3127   - return false;
  1699 + break;
  1700 + case 3:
  1701 + if (goods_piece < 0) goods_piece = 0;
  1702 + //累积商品数量
  1703 + goods_piece += good['buynum'];
  1704 + if (goods_piece1) {
  1705 + goods_piece += goods_piece1;
3128 1706 }
3129   - th.insert_into_using_quan(item, using_quan, pickid, 1);
3130   - return;
3131   - }
  1707 + break;
3132 1708 }
3133 1709  
3134   - //选择了的券,看是不是点击了不使用券,点击了不使用优惠券
3135   - if (using_quan[pickid]) {
3136   - if (using_quan[pickid].is_nouse_red == 1) {
3137   - using_quan[pickid] = {is_nouse_red: 1};
3138   - th.setData({using_quan: using_quan});
3139   - if (th.data.is_b_now == 1) {
3140   - th.calculatePrice2();
3141   - } else {
3142   - th.calculatePrice();
3143   - }
3144   - th.setData({open_quan: 0});
3145   - return;
  1710 +
  1711 + //如果有设置不包邮区域的时候
  1712 + if (no_by_data && no_by_data.region_list) {
  1713 + if (th.check_by_area(no_by_data.region_list)) {
  1714 + gift_freight_free = 0;
  1715 + th.data.is_no_by[bn_pick] = 1;
  1716 + }
  1717 + }
  1718 + //如果有设置不包邮商品
  1719 + if (no_by_data && no_by_data.goods_list && gift_freight_free) {
  1720 + if (th.check_by_goods(no_by_data.goods_list, good.goods_id)) {
  1721 + gift_freight_free = 0;
3146 1722 }
3147 1723 }
  1724 +
  1725 + var t_shipping_price =
  1726 + this.calculatewuliu(code, gift_shipping_price, goods_weight,
  1727 + goods_piece, user_addr, gift_freight_free, allpice, rs);
  1728 + return t_shipping_price;
  1729 +
3148 1730 },
3149 1731  
3150   - //----把券插入之后的操作,同时还要重新计算价格----
3151   - insert_into_using_quan: function (item, using_quan, pickid, isby) {
3152   - var th = this;
3153   - if (isby == 1) {
3154   - using_quan[pickid] = {
3155   - coupon_no: item.no,
3156   - money: 0,
3157   - is_nouse_red: 0,
3158   - region_list: item.region_list,
3159   - goods_list: item.goods_list
3160   - };
3161   - using_quan[pickid].isby = 1;
3162   - } else {
3163   - using_quan[pickid] = {coupon_no: item.CashRepNo, money: item.Sum, is_nouse_red: 0};
3164   - using_quan[pickid].isby = 0;
  1732 + //从优惠的映射中拿出商品从表的item
  1733 + item_map_get_goods: function (goods_id, map) {
  1734 + for (var i in map.goods) {
  1735 + if (map.goods[i].goods_id == goods_id) return map.goods[i];
3165 1736 }
3166   - this.setData({using_quan: using_quan});
3167   - if (th.data.is_b_now == 1) {
3168   - th.calculatePrice2();
3169   - } else {
3170   - th.calculatePrice();
  1737 + },
  1738 + //从优惠的映射中拿出商品从表的item
  1739 + arr_get_goods: function (goods_id, arr) {
  1740 + for (var i in arr) {
  1741 + if (arr[i].goods_id == goods_id) return arr[i];
3171 1742 }
3172   - th.setData({open_quan: 0});
3173 1743 },
3174 1744  
3175   - cart_set_err: function (e) {
3176   - var txt = e.currentTarget.dataset.err;
3177   - var ob = {};
3178   - ob[txt] = this.data.imgUrl + "/miniapp/images/default_g_img.gif";
3179   - this.setData(ob);
  1745 + //检查是不是有其他门店的订单在选择了券
  1746 + check_other_use: function (iter, pkid) {
  1747 + var using = this.data.using_quan;
  1748 + var is_use = 0;
  1749 + if (using) {
  1750 + for (var i in using) {
  1751 + if (i == pkid) continue;
  1752 + if (iter.CashRepNo == using[i].coupon_no) {
  1753 + is_use = 1;
  1754 + break;
  1755 + }
  1756 + }
  1757 + }
  1758 + return is_use;
3180 1759 },
3181   - //--验证是否已经冻结--
3182   - check_is_frozenQuan: function (quanlist, frozenQuan, isby) {
3183   - console.log("券列表", quanlist);
3184   - if (!quanlist) return null;
3185   - if (!frozenQuan) return quanlist;
3186   - var arr = [];
3187   - for (var i = 0; i < quanlist.length; i++) {
3188   - var item = quanlist[i];
3189   - var is_find = 0;
3190   - var Q_no = quanlist[i].CashRepNo;
3191   - if (isby) Q_no = quanlist[i].no;
3192   - for (var j = 0; j < frozenQuan.length; j++) {
3193   - var q_no = frozenQuan[j].cashRepNo;
3194   - if (Q_no == q_no) {
3195   - is_find = 1;
  1760 + //检查是不是有其他门店的订单在选择了包邮券
  1761 + check_other_use_by: function (iter, pkid) {
  1762 + var using = this.data.using_quan;
  1763 + var is_use = 0;
  1764 + if (using) {
  1765 + for (var i in using) {
  1766 + if (i == pkid) continue;
  1767 + if (iter.no == using[i].coupon_no) {
  1768 + is_use = 1;
3196 1769 break;
3197 1770 }
3198 1771 }
3199   - if (!is_find) arr.push(item);
3200 1772 }
3201   - return arr;
  1773 + return is_use;
3202 1774 },
3203 1775  
3204   - //// 开启物流的弹窗
3205   - show_wu_arr: function (e) {
3206   - var wu_arr_txt = e.currentTarget.dataset.txt;
3207   - var w_sele_index = e.currentTarget.dataset.w_sele_index;
3208   - var is_express = null;
3209   - var ob = {open_express: 1, wu_arr_txt: wu_arr_txt, disabled: 1};
3210 1776  
3211   - //--如果是多个门店的时候--
3212   - if (w_sele_index != undefined) {
3213   - is_express = this.data.cartlist[w_sele_index].wind;
3214   - ob['is_express'] = is_express;
3215   - }
3216   - this.setData(ob);
3217   - },
3218   - // 关闭物流的弹窗
3219   - close_express: function () {
3220   - this.setData({open_express: 0, disabled: 0});
3221   - },
3222   - // 选择物流
3223   - click_express_name: function (e) {
3224   - var express_name = e.currentTarget.dataset.name, shippingcode = e.currentTarget.dataset.shippingcode;
3225   - var index = e.currentTarget.dataset.idxe;
3226   - var ob = {is_express: index, is_shipping_code: shippingcode, disabled: 0};
3227   - ob[this.data.wu_arr_txt] = index;
3228   - this.setData(ob);
3229   - },
3230 1777  
3231   - //点击确定物流
3232   - determine_expres: function (e) {
3233   - this.setData({open_express: 0});
3234   - if (this.data.is_b_now == 1)
3235   - this.calculatePrice2();
3236   - else
3237   - this.calculatePrice();
3238   - },
  1778 + //----计算物流的钱----
  1779 + calculate_wuliu() {
  1780 + var to = getApp(), th = this;
  1781 + to.getConfig2(function (ee) {
  1782 + to.getwuliuprice(async function (rs) {
  1783 + var o_shipping_price = 0,
  1784 + goods_weight = -1,
  1785 + goods_piece = -1,
  1786 + good = th.data.goods,
  1787 + quan_price=0,
  1788 + exp_price=0;
3239 1789  
3240   - //点击打开优惠券使用说明
3241   - clik_coupons: function (e) {
3242   - var ind = e.currentTarget.dataset.idx;
3243   - var is_open = this.data.selected_quan_list[ind].is_open;
  1790 + var quan_no = null;
  1791 + var bn_pick=th.data.pickup.pickup_id;
  1792 + var allpice =th.data.all_price;
3244 1793  
3245   - if (is_open == 1) is_open = 0;
3246   - else is_open = 1;
  1794 + if (th.data.using_quan[bn_pick] != null && th.data.using_quan[bn_pick] != undefined)
  1795 + quan_no = th.data.using_quan[bn_pick].coupon_no;
3247 1796  
3248   - var txt = "selected_quan_list[" + ind + "].is_open"
3249   - var obj = {};
3250   - obj[txt] = is_open;
  1797 + if (quan_no) {
  1798 + if (th.data.using_quan[bn_pick].isby != 1) {
  1799 + //---获取优惠券优惠---
  1800 + await getApp().request.promiseGet("/api/weshop/couponList/getUseCouponPrice", {
  1801 + data: {
  1802 + storeId: oo.stoid,
  1803 + CashRepNo: quan_no,
  1804 + WaresSum: th.data.ckeck_quan_price,
  1805 + WareIds: th.data.check_quan_ware_list
  1806 + }
  1807 + }).then(res => {
  1808 + if (res.data.code == 0 && res.data.data && res.data.data.length > 0) {
  1809 + quan_price = res.data.data[0].WareCashSum;
  1810 + }
  1811 + })
3251 1812  
3252   - this.setData(obj);
3253   - this.setData({disabled: 1})
  1813 + if(quan_price>0) {
  1814 + if (quan_price < allpice) th.setData({quan_price: quan_price})
  1815 + else {
  1816 + th.setData({quan_price: allpice})
  1817 + }
  1818 + }else{
  1819 + th.setData({quan_price: 0})
  1820 + }
  1821 + }
  1822 + }else{
  1823 + th.setData({quan_price: 0})
  1824 + }
  1825 +
  1826 + //-----------当地址不为空,且是物流时,计算物流费用----------
  1827 + if (th.data.user_addr != null && th.data.exp_type == 0 && good.is_free_shipping == 0) {
  1828 + //看是不是有调用过包邮券,如果活动可以使用优化券的情况下
  1829 + if (!th.data.isget_by_quan[bn_pick] && th.data.is_usecoupon) {
  1830 + var condition = allpice - quan_price;
  1831 + //--判断要不要显示包邮券,链式调用接口,调取包邮券,已经是减了优惠的金额,见到优惠券的钱---
  1832 + getApp().request.promiseGet("/api/weshop/userfeemail/pageAndArea", {
  1833 + data: {
  1834 + store_id: os.stoid,
  1835 + isuse: 0,
  1836 + condition: condition,
  1837 + user_id: getApp().globalData.user_id,
  1838 + pageSize: 2000
  1839 + }
  1840 + }).then(res => {
  1841 + if (res.data.code == 0 && res.data.data.total > 0) {
  1842 + //此时要循环判断包邮的地区,不包邮商品是不是符合
  1843 + var arr = [], quanlist = res.data.data.pageData;
  1844 + quanlist = th.check_is_frozenQuan(quanlist, th.data.frozenQuan, 1);
  1845 + for (var i in quanlist) {
  1846 + var item = quanlist[i];
  1847 + if (item.region_list && th.check_by_area(item.region_list)) continue; //如果是不包邮区域
  1848 + if (item.goods_list && th.check_by_goods(item.goods_list)) continue; //如果是不包邮商品
  1849 + arr.push(item);
  1850 + }
  1851 + if (arr) {
  1852 + th.setData({get_by_quan_list: arr});
  1853 + }
  1854 + th.data.isget_by_quan[bn_pick] = 1;
  1855 + }
  1856 + })
  1857 + }
  1858 + if (quan_no && th.data.using_quan[bn_pick].isby == 1) {
  1859 + exp_price=0;
  1860 + }else{
  1861 + switch (good['exp_sum_type']) {
  1862 + case 1:
  1863 + //统一运费
  1864 + o_shipping_price += good['uniform_exp_sum'];
  1865 + break;
  1866 + case 2:
  1867 + if (goods_weight < 0) goods_weight = 0;
  1868 + //累积商品重量 每种商品的重量 * 数量
  1869 + goods_weight += good['weight'] * th.data.order.order_goods['goods_num'];
  1870 + break;
  1871 + case 3:
  1872 + if (goods_piece < 0) goods_piece = 0;
  1873 + //累积商品数量
  1874 + goods_piece += th.data.order.order_goods['goods_num'];
  1875 + break;
  1876 + }
  1877 +
  1878 + var code = th.data.wu_arr[th.data.index].code;
  1879 + var freight_free = ee.freight_free; //全场满多少包邮
  1880 + var shipping_price =
  1881 + th.calculatewuliu(code, o_shipping_price, goods_weight,
  1882 + goods_piece, th.data.user_addr, freight_free, allpice, rs);
  1883 + exp_price = parseFloat(shipping_price).toFixed(2);
  1884 + }
  1885 + th.wuliu_next(allpice,quan_price,exp_price);
  1886 + } else {
  1887 + th.wuliu_next(allpice,quan_price,exp_price);
  1888 + }
  1889 + });
  1890 + });
3254 1891 },
  1892 + //相同的东西统一在一起
  1893 + wuliu_next( allpice,quan_price,exp_price){
  1894 + var th=this;
  1895 + var o_condition =parseFloat(allpice)-parseFloat(quan_price);
  1896 + if(o_condition<0) o_condition=0;
  1897 + //如果同意参与订单优惠
  1898 + if (o_condition > 0 && this.data.pre_arr.is_useorderyh) {
  1899 + th.check_is_order_prom(o_condition, function () {
  1900 + var bn_pick=th.data.pickup.pickup_id
  1901 + var order_prom_amount = 0;
  1902 + var order_prom_id = 0;
  1903 + var order_m=0;
  1904 + if (th.data.order_prom[bn_pick]) {
  1905 + var ord_prom = th.data.order_prom[bn_pick];
  1906 + order_prom_id = ord_prom['id'];
  1907 + switch (ord_prom['type']) {
  1908 + case 0:
  1909 + order_m = Math.round(o_condition * ord_prom['expression']) / 100;//满额打折
  1910 + order_prom_amount = (o_condition - order_m).toFixed(2);
  1911 + break;
  1912 + case 1:
  1913 + order_m = o_condition - ord_prom['expression'];//满额优惠金额
  1914 + order_prom_amount = ord_prom['expression'];
  1915 + break;
  1916 + }
  1917 + o_condition=order_m;
  1918 + }
3255 1919  
3256   - clik_coupons2: function (e) {
3257   - var ind = e.currentTarget.dataset.idx;
3258   - var is_open = this.data.get_by_quan_list[ind].is_open;
  1920 + //--订单优惠的显示--
  1921 + if (order_prom_id > 0) {
  1922 + var order_prom_txt1 = "order_prom_id";
  1923 + var order_prom_txt2 = "order_prom_amount";
  1924 + th.setData({[order_prom_txt1]: order_prom_id, [order_prom_txt2]: order_prom_amount})
  1925 + }
3259 1926  
3260   - if (is_open == 1) is_open = 0;
3261   - else is_open = 1;
  1927 + th.setData({ exp_price: exp_price, order_m: parseFloat(o_condition) +parseFloat(exp_price) })
3262 1928  
3263   - var txt = "get_by_quan_list[" + ind + "].is_open"
3264   - var obj = {};
3265   - obj[txt] = is_open;
  1929 + })
  1930 + }else{
  1931 + th.setData({ exp_price: exp_price, order_m: parseFloat(o_condition)+parseFloat(exp_price) })
  1932 + }
  1933 + },
3266 1934  
3267   - this.setData(obj);
3268   - this.setData({disabled: 1})
  1935 + //-- 获取时间差 --
  1936 + get_diff(){
  1937 + if(this.data.presell.kw_start_time>ut.gettimestamp()){
  1938 + this.setData({no_start:1})
  1939 + }else if(this.data.presell.kw_end_time<ut.gettimestamp()){
  1940 + this.setData({is_end:1})
  1941 + }else {
  1942 + var end_time=this.data.presell.kw_end_time;
  1943 + var e_str=ut.formatTime(end_time);
  1944 + var new_date = new Date(); //新建一个日期对象,默认现在的时间
  1945 + var old_date = new Date(e_str.replace(/-/g,'/')); //设置过去的一个时间点,"yyyy-MM-dd HH:mm:ss"格式化日期
  1946 + var difftime = (new_date - old_date)/1000; //计算时间差,并把毫秒转换成秒
  1947 + var days = parseInt(difftime/86400); // 天 24*60*60*1000
  1948 + var hours = parseInt(difftime/3600)-24*days; // 小时 60*60 总小时数-过去的小时数=现在的小时数
  1949 + var minutes = parseInt(difftime%3600/60); // 分钟 -(day*24) 以60秒为一整份 取余 剩下秒数 秒数/60 就是分钟数
  1950 + var seconds = parseInt(difftime%60); // 以60秒为一整份 取余 剩下秒数
  1951 + this.setData({days:days,hours:hours,minutes:minutes,seconds:seconds})
  1952 + }
3269 1953 },
3270 1954  
3271 1955  
3272   - //设置默认物流
3273   - select_default_logistics: function () {
3274   - var th = this;
3275   - var is_shipping_code = this.data.is_shipping_code
3276   - getApp().request.put("/api/weshop/users/update", {
3277   - data: {user_id: getApp().globalData.user_id, store_id: oo.stoid, def_exp_code: is_shipping_code},
3278   - success: function (rse) {
3279   - if (rse.data.code == 0) {
3280   - getApp().globalData.userInfo.def_exp_code = is_shipping_code;
3281   - th.setData({open_express: 0});
3282   - //----计算此时购物车的价格----
3283   - if (th.data.is_b_now == 1) th.calculatePrice2();
3284   - else th.calculatePrice();
3285   - }
3286   - }
3287   - })
  1956 + //显示支付选择
  1957 + show_pay: function () {
  1958 + this.setData({show_pay_type: 1});
3288 1959 },
3289   -
3290   - //更新下默认,在onshow里面
3291   - update_code(){
3292   - var th = this, m_wind = 0, def_exp_code = getApp().globalData.userInfo.def_exp_code;
3293   - //--定时器,判断wu_arr不未空--
3294   - var uii = setInterval(function () {
3295   - if (th.data.wu_arr) {
3296   - clearInterval(uii);
3297   - for (var k = 0; k < th.data.wu_arr.length; k++) {
3298   - var item = th.data.wu_arr[k];
3299   - if (def_exp_code == item.code) {
3300   - m_wind = k;
3301   - }
3302   - }
3303   - //--如果是立即购买--
3304   - if (th.data.is_b_now == 1) {
3305   - th.setData({index: m_wind, is_express: m_wind});
3306   - } else {
3307   - var ui = setInterval(function () {
3308   - if (th.data.cartlist) {
3309   - var c_arr = th.data.cartlist;
3310   - for (var i in c_arr) {
3311   - c_arr[i].wind = m_wind;
3312   - }
3313   - th.setData({cartlist: c_arr, is_express: m_wind})
3314   - clearInterval(ui);
3315   - }
3316   - }, 500)
3317   - }
3318   - }
3319   - }, 500);
  1960 + //关闭支付
  1961 + close_show_pay: function () {
  1962 + this.setData({show_pay_type: 0});
3320 1963 },
3321   - //-----获取购物车进来的劵-------
3322   - get_cart_quan: async function (order_prom_list_cart) {
3323   - var th = this;
3324   - var is_xz_yh = 1;
3325   - //等待值的出现
3326   - //getApp().waitfor2(this,"g_cart_q_time","order_prom_list_cart",async function () {
3327   - //var arr=th.data.order_prom_list_cart;
3328   - var arr = order_prom_list_cart;
3329   - if (!arr) arr = [];
3330   - //如果系统有限制使用优惠券
3331   - if (th.data.is_close_quan) return false;
  1964 + //--弹起支付框--
  1965 + to_pay() {
  1966 + //--物流支付时要有地址--
  1967 + if (this.data.exp_type == 0 && this.data.user_addr == null) {
  1968 + return getApp().my_warnning("请选择收货地址", 0, this);
  1969 + }
3332 1970  
3333   - //------------开始计算使用优惠券相关------------
3334   - for (var ind in arr) {
3335   - var ep = arr[ind];
3336   - var goodlist = ep.goods;
3337   - var pickup_id = ep.pickup_id;
3338   - //--更优惠券抵用有关,立即购买的,如果是购物车,如果有等级价还有考虑等级价的东西
3339   - //就要把相应的值,写入cartlist数组中--
3340   - var ckeck_quan_price = 0,
3341   - check_quan_price_list = '',
3342   - check_quan_ware_list = '';
  1971 + this.setData({show_pay_type: 1});
  1972 + },
3343 1973  
3344   - for (var i in goodlist) {
3345   - var gd = goodlist[i];
3346   - //--如果是秒杀就跳出,如果是赠品,如果是组合购,如果是限制使用优惠券--
3347   - if (gd.prom_type == 1 || gd.is_gift || gd.prom_type == 7) {
3348   - continue;
3349   - }
3350   - //如果有限制使用优惠券,就要返回
3351   - if (gd.prom_type == 3) {
3352   - if (th.data.prom_goods_map[pickup_id][gd.prom_id].is_xz_yh) continue;
3353   - th.data.prom_goods_map[pickup_id][gd.prom_id].coupon_sele = 1;
3354   - }
3355   - is_xz_yh = 0;
3356   - var item_price = gd.goods_price * gd.goods_num;
3357   - //-- 如果有平摊下去,有实收价格的时候,就要用account来计算价格 --
3358   - if (gd.account_fir != null && gd.account_fir != undefined) {
3359   - item_price = gd.account_fir * gd.goods_num;
3360   - }
3361   - ckeck_quan_price += item_price;
  1974 + //选择支付方式
  1975 + set_pay_type: function (e) {
  1976 + var type = e.currentTarget.dataset.type;
  1977 + this.to_pay_type(type);
  1978 + },
3362 1979  
3363   - //--组装价格list--
3364   - if (check_quan_price_list) {
3365   - check_quan_price_list += "," + item_price;
3366   - } else {
3367   - check_quan_price_list = item_price;
3368   - }
3369   - //--组装商品的线下erpwareid--
3370   - if (check_quan_ware_list) {
3371   - check_quan_ware_list += "," + encodeURIComponent(gd['erpwareid']);
3372   - } else {
3373   - check_quan_ware_list = encodeURIComponent(gd['erpwareid']);
3374   - }
3375   - }
3376   - //优惠券优惠的金额要控制到优惠券的选择条件
3377   - var cut_price = 0;
3378   - for (var i in th.data.prom_goods_map[pickup_id]) {
3379   - var obj = th.data.prom_goods_map[pickup_id][i];
3380   - if (obj.coupon_sele) {
3381   - cut_price += obj.price - obj.prom_price;
3382   - }
3383   - }
  1980 + //--立即支付--
  1981 + to_pay_type: function (ind) {
  1982 + var th = this;
  1983 + //--物流支付时要有地址--
  1984 + if (th.data.exp_type == 0 && th.data.user_addr == null) {
  1985 + return getApp().my_warnning("请选择收货地址", 0, th);
  1986 + }
  1987 +
  1988 + //---支付参数--
  1989 + var dd = {
  1990 + order_sn: th.data.order.order_sn,
  1991 + order_id: th.data.order.order_id,
  1992 + store_id: oo.stoid,
  1993 + exp_type: th.data.exp_type,
  1994 + user_id: getApp().globalData.userInfo.user_id,
  1995 + prom_id: th.data.pre_arr.presell_id,
  1996 + tail_pay_type: ind,//0微信支付 1余额支付
  1997 + };
3384 1998  
3385   - arr[ind].ckeck_quan_price = ckeck_quan_price - cut_price;
3386   - arr[ind].check_quan_ware_list = check_quan_ware_list;
3387   - arr[ind].check_quan_price_list = check_quan_price_list;
  1999 + if (th.data.exp_type == 0) {
  2000 + var index = th.data.index;
  2001 + dd.shipping_code = th.data.wu_arr[index].code;
  2002 + dd.shipping_name = th.data.wu_arr[index].name;
  2003 + dd.shipping_price = parseFloat(th.data.exp_price);
  2004 + dd.addressid = th.data.user_addr.address_id;
  2005 + }
3388 2006  
3389   - //是否关闭使用优惠券
3390   - if (th.data.is_close_quan != 1 && !is_xz_yh) {
3391   - //--调用接口,获取优惠券的列表,3秒钟内控制接口请求--
3392   - var url = "/api/weshop/couponList/getUseCouponList";
3393   - await app.request.promiseGet(url, {
3394   - data: {
3395   - storeId: oo.stoid,
3396   - userId: app.globalData.user_id,
3397   - BuySum: ckeck_quan_price,
3398   - WareIds: check_quan_ware_list,
3399   - pageSize: 100
3400   - }
3401   - }).then(res => {
3402   - if (res.data.code == 0) {
3403   - var quan_list = res.data.data.pageData;
3404   - arr[ind].quan_list = th.check_is_frozenQuan(quan_list, th.data.frozenQuan);
3405   - }
3406   - })
  2007 + if(th.data.order_prom_amount>0){
  2008 + var e={
  2009 + order_prom_id:th.data.order_prom_id,
  2010 + order_prom_amount:th.data.order_prom_amount,
3407 2011 }
  2012 + dd.order_prom_list=e;
3408 2013 }
3409 2014  
3410   - //如果是搭配购的立即购买的时候
3411   - if (th.data.is_b_now) {
3412   - if (arr && arr.length > 0) {
3413   - var quanlist = arr[0].quan_list;
3414   - th.setData({selected_quan_list: quanlist, cartlist: arr})
3415   - }
3416   - } else {
3417   - th.setData({cartlist: arr})
3418   - th.set_can_num();
  2015 + var bn_pick=th.data.pickup_id;
  2016 + var quan_no='';
  2017 + if (th.data.using_quan[bn_pick] != null && th.data.using_quan[bn_pick] != undefined)
  2018 + quan_no = th.data.using_quan[bn_pick].coupon_no;
  2019 + if(quan_no){
  2020 + dd.coupon_no=quan_no;
  2021 + if(th.data.quan_price) dd.coupon_price=th.data.quan_price;
3419 2022 }
  2023 + if(th.data.user_note){
  2024 + dd.user_note=th.data.user_note;
  2025 + }
  2026 + dd.order_amount=th.data.order_m-th.data.presell.presell_deposit;
3420 2027  
3421   - //})
3422   - },
  2028 + console.log(JSON.stringify(dd));
  2029 + wx.request({
  2030 + url: oo.url + '/api/weshop/order/pay/payPresellWk',
  2031 + data: JSON.stringify(dd),
  2032 + method: 'POST',
  2033 + header: {
  2034 + 'content-type': 'application/json'
  2035 + },// 设置请求的 header
  2036 + success: function (t) {
  2037 + th.close_show_pay();
  2038 +
  2039 + //---用微信支付---
  2040 + if (dd.tail_pay_type == 0) {
  2041 + var n = t.data.data;
  2042 + th.weixinPay(n,
  2043 + function () {
  2044 + //---用余额支付---
  2045 + getApp().my_warnning("支付成功", 1, th);
  2046 + setTimeout(function () {
  2047 + th.setData({isclose: 0});
  2048 + th.onShow();
  2049 + }, 1000)
  2050 +
  2051 +
  2052 + }, function () {
  2053 + getApp().my_warnning("支付失败", 0, th);
  2054 + })
  2055 + } else {
  2056 + if (t.data.code == 0) {
  2057 + //---用余额支付---
  2058 + getApp().my_warnning("支付成功", 1, th);
  2059 + setTimeout(function () {
  2060 + th.setData({isclose: 0});
3423 2061  
3424   - //------ 获取立即购买的购物车的劵 --------
3425   - get_buy_now_quan: function () {
3426   - var quanlist = null, th = this, frozenQuan = null;
3427   - var good = this.data.bn_goods;
3428   - if (good.prom_price) {
3429   - th.data.ckeck_quan_price = good.prom_price; //如果有优惠价,就用优惠价
3430   - } else if (good.is_offline) {
3431   - th.data.ckeck_quan_price = good.offline_price; //如果有线下取价,就用线下价
3432   - }
3433   - //--如果商家后台没有限制使用优惠券,同时商品的优惠活动没有限制使用优惠券--
3434   - if (th.data.is_close_quan != 1 && th.data.bn_goods.is_xz_yh != 1) {
3435   - var url0 = "/api/weshop/users/frozenQuan/listFrozenQuan/" + app.globalData.user_id;
3436   - var url = "/api/weshop/couponList/getUseCouponList";
3437   - app.request.promiseGet(url0, {1: 1}).then(res => {
3438   - if (res.data.code == 0) {
3439   - frozenQuan = res.data.data;
3440   - th.data.frozenQuan = frozenQuan;
3441   - }
3442   - app.request.time_limit_get(6, url, {
3443   - data: {
3444   - storeId: oo.stoid,
3445   - userId: app.globalData.user_id,
3446   - BuySum: th.data.ckeck_quan_price,
3447   - WareIds: encodeURIComponent(th.data.check_quan_ware_list),
3448   - pageSize: 100
3449   - },
3450   - success: function (res) {
3451   - if (res.data.code == 0) {
3452   - quanlist = res.data.data.pageData;
3453   - if (quanlist) {
3454   - quanlist = th.check_is_frozenQuan(quanlist, frozenQuan);
3455   - th.setData({selected_quan_list: quanlist})
3456   - }
3457   - }
  2062 + th.onShow();
  2063 + }, 1000)
  2064 + } else {
  2065 + getApp().my_warnning(t.data.msg, 1, th);
3458 2066 }
3459   - })
3460   - })
3461   - }
  2067 + }
  2068 + }
  2069 + });
3462 2070 },
3463 2071  
3464   - //检查区域是不是包邮
3465   - check_area: function (arr) {
3466   - var user_addr = this.data.user_addr;
3467   - if (!user_addr) return 0;
3468   - for (var i in arr) {
3469   - var item = arr[i];
3470   - if (user_addr.twon == item || user_addr.district == item
3471   - || user_addr.city == item || user_addr.province == item) {
3472   - return 0;
  2072 + //------调起支付框--------
  2073 + weixinPay: function (n, success, fail) {
  2074 + if (!n) return false;
  2075 + var th = this;
  2076 + wx.requestPayment({
  2077 + timeStamp: String(n.timeStamp),
  2078 + nonceStr: n.nonceStr,
  2079 + package: n.packageValue,
  2080 + signType: n.signType,
  2081 + paySign: n.paySign,
  2082 + success: function (n) {
  2083 + console.log(n), getApp().showSuccess("支付成功!");
  2084 + "function" == typeof success && success();
  2085 + },
  2086 + fail: function (n) {
  2087 + 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),
  2088 + "function" == typeof fail && fail();
3473 2089 }
3474   - }
3475   - return 1;
  2090 + });
3476 2091 },
3477 2092  
3478   - //检查立即购买的商品是不是不包邮
3479   - check_good: function (arr, goods_id) {
3480   - if (!goods_id) goods_id = this.data.bn_goods.goods_id;
3481   - for (var i in arr) {
3482   - var item = arr[i];
3483   - if (goods_id == item) return 0;
3484   - }
3485   - return 1;
  2093 +
  2094 + show_liuyan:function () {
  2095 + this.setData({sh_liuyan:true})
3486 2096 },
3487   - check_by_area: function (region_list) {
3488   - var arr = region_list.split(",");
3489   - var check = this.check_area(arr);
3490   - return !check;
  2097 + close_liuyan(){
  2098 + this.setData({sh_liuyan:false})
3491 2099 },
3492   - check_by_goods: function (goods_list, goods_id) {
3493   - var arr = goods_list.split(",");
3494   - var check = this.check_good(arr, goods_id);
3495   - return !check;
  2100 +
  2101 + //--------点击选择----------
  2102 + set_wuliu: function (e) {
  2103 + var type = e.currentTarget.dataset.type;
  2104 + this.setData({
  2105 + exp_type: type
  2106 + });
  2107 + this.calculatePrice2();
3496 2108 },
3497   - //立即购买获取优惠活动的内容
3498   - buy_now_prom_goods: function (prom_id, arr, func) {
3499   - var price = arr.shop_price * arr.goods_num;
3500   - var prom = null;
3501   - getApp().request.promiseGet("/api/weshop/promgoods/get/" + os.stoid + "/" + prom_id, {}).then(res => {
3502   - if (res.data.code == 0) {
3503   - prom = res.data.data;
3504   - return getApp().request.promiseGet("/api/weshop/goods/getDiscount", {
3505   - data: {
3506   - price: price,
3507   - prom_id: prom_id,
3508   - goods_num: arr.goods_num,
3509   - user_id: getApp().globalData.user_id,
3510   - is_bz: prom.is_bz
  2109 +
  2110 +
  2111 + //--------立即支付----------
  2112 + async jumpToCart4(e) {
  2113 + var th=this;
  2114 + if(this.data.optionIsGoup)
  2115 + wx.navigateTo({
  2116 + url: "/pages/team/team_confirm/team_confirm?orderSn=" + this.data.order.order_sn + "&orderPay=true"
  2117 + })
  2118 + var order=this.data.order;
  2119 + var order_goods=this.data.order_goods;
  2120 +
  2121 + var wlist="";
  2122 +
  2123 + var good=order_goods;
  2124 + //线下取价功能已经关闭或者过期
  2125 + if(!th.data.is_open_offline && good.offline_cut>0){
  2126 + wx.showModal({
  2127 + title: '提示',
  2128 + content: '线下取价功能已经关闭或者过期!'
  2129 + });
  2130 + return false;
  2131 + }
  2132 + //如果不是小程序有的功能,直接提示要去3.0处理
  2133 + if(good.prom_type==2 ){
  2134 + wx.showModal({
  2135 + title: '提示',
  2136 + content: '小程序还未有该活动,请到3.0公众号支付'
  2137 + });
  2138 + return false;
  2139 + }
  2140 +
  2141 + //要每件每件的商品进行检查,看有么有超出库存,超出限购
  2142 + var goodsbuynum=0,promgoodsbuynum=0,gg=null;
  2143 + //获取单品的现在的活动状态
  2144 + await getApp().request.promiseGet("/api/weshop/goods/get/" + os.stoid + "/" + good.goods_id, {
  2145 + }).then(res=>{
  2146 + gg=res.data.data;
  2147 + })
  2148 + var limit = gg.viplimited;
  2149 + var store_count = gg.store_count;
  2150 + good.erpwareid=gg.erpwareid;
  2151 +
  2152 + //---要获得商品,该用户买了多少件,同步应用---
  2153 + await getApp().request.promiseGet("/api/weshop/ordergoods/getUserBuyGoodsNum", {
  2154 + data: {
  2155 + store_id: os.stoid,
  2156 + user_id: getApp().globalData.user_id,
  2157 + goods_id: good.goods_id,
  2158 + prom_type: good.prom_type,
  2159 + prom_id: good.prom_id
  2160 + },
  2161 + }).then(res => {
  2162 + var buy_num_data = res.data.data;
  2163 + if (buy_num_data.promgoodsbuynum) promgoodsbuynum = buy_num_data.promgoodsbuynum;
  2164 + goodsbuynum = buy_num_data.goodsbuynum;
  2165 + })
  2166 +
  2167 + var buyed_mum2=goodsbuynum+good.goods_num;
  2168 + if (buyed_mum2 > limit && limit > 0) {
  2169 +
  2170 + var content=gg.goods_name+'购买数量超出商品限购,请取消订单';
  2171 + th.toast(content);
  2172 + return false;
  2173 + }
  2174 +
  2175 + //当是组合优惠的时候
  2176 + if(good.prom_type==7){
  2177 + //如果有组合购
  2178 + var isok = 1;
  2179 + var url="/api/weshop/prom/zhbuy/get/"+os.stoid+"/"+good.prom_id+"/"+getApp().globalData.userInfo.user_id;
  2180 + await getApp().request.promiseGet(url, {}).then(res => {
  2181 + if(res.data.code==0 && res.data.data){
  2182 + if(res.data.data.is_show!=1){
  2183 + isok=0;
  2184 + }
  2185 + //如果活动已经结束
  2186 + if(res.data.data.is_end==1){
  2187 + isok=0;
  2188 + }
  2189 + //已经结束
  2190 + if(ut.gettimestamp()>res.data.data.end_time){
  2191 + isok=0;
  2192 + }
  2193 + //还未开始
  2194 + if(ut.gettimestamp()<res.data.data.start_time){
  2195 + isok=0;
  2196 + }
  2197 +
  2198 + }else{
  2199 + //未找到商品的活动
  2200 + isok = 0;
3511 2201 }
  2202 +
3512 2203 })
3513   - } else {
3514   - func(arr);
3515   - }
3516   - }).then(res => {
3517   - if (res.data.code == 0) {
3518   - var get_data = res.data.data;
3519   - arr.is_bz = prom.is_bz; //是不是倍增
3520   - arr.is_xz_yh = prom.is_xz_yh; //是不是优惠
3521   - arr.bs = get_data.bs; //是不是倍数
3522   - arr.is_past = get_data.is_past; //是不是包邮
3523   - arr.prom_price = get_data.price >= 0 ? get_data.price : price;
3524   - arr.s_intValue = get_data.intValue;
3525   - arr.s_coupon_id = get_data.coupon_id;
3526   - arr.s_coupon_num = get_data.coupon_num;
3527   - //-- 看是不是有赠品 --
3528   - if (get_data.gift_id) {
3529   - arr.gift_id = get_data.gift_id;
3530   - arr.gift_goods_id = get_data.goods_id;
3531   - arr.gift_goods_name = get_data.goods_name;
3532   - arr.gift_goods_color = get_data.goodsinfo.goods_color;
3533   - arr.gift_goods_spec = get_data.goodsinfo.goods_spec;
3534   - arr.gift_original_img = get_data.goodsinfo.original_img;
3535   - arr.gift_weight = get_data.goodsinfo.weight;
3536   - arr.gift_exp_sum_type = get_data.goodsinfo.exp_sum_type;
3537   - arr.gift_uniform_exp_sum = get_data.goodsinfo.uniform_exp_sum;
3538   - arr.gift_limit_num = get_data.limit_num;
3539   - arr.gift_storecount = get_data.gift_storecount;
  2204 + if (!isok){
  2205 + var content=gg.goods_name+'活动已经结束,请取消订单';
  2206 + th.toast(content);
  2207 + return false;
  2208 + }
  2209 +
  2210 + var url1 = "/api/weshop/prom/zhbuyGoods/page";
  2211 + var req_data = {
  2212 + page: 1,
  2213 + pageSize: 1,
  2214 + store_id: os.stoid,
  2215 + zh_id: good.prom_id,
  2216 + goods_id:good.goods_id
  2217 + }
  2218 + await getApp().request.promiseGet(url1, {
  2219 + data: req_data
  2220 + }).then(res => {
  2221 + if (ut.ajax_ok(res)) {
  2222 + var gdlist = res.data.data.pageData[0];
  2223 + good.buyqty=gdlist.buyqty;
  2224 + }
  2225 + })
  2226 +
  2227 + var num=good['buyqty'];
  2228 + console.log(1111);
  2229 + console.log(num);
  2230 + //---- 要计算商品的限购 -----
  2231 + if(good['buyqty']>0){
  2232 + if(good.goods_num+promgoodsbuynum>good['buyqty']){
  2233 +
  2234 + var content= good['goods_name']+"超出活动限购\n";
  2235 + th.toast(content);
  2236 + return false;
  2237 + }
3540 2238 }
3541   - arr.s_libao = get_data.libao;
3542   - arr.s_lb_num = get_data.lb_num;
3543   - arr.prom_id = prom_id;
3544   - }
3545   - func(arr);
3546   - })
3547   - },
3548   - //--检查订单优惠--
3549   - check_is_order_prom: function (condition, func, pick) {
3550   - var th = this;
3551   - if (this.data.is_b_now == 1) pick = this.data.bn_pick;
3552   - //---获取订单优惠---
3553   - getApp().request.promiseGet("/api/weshop/promorder/getOrderPromotion", {
3554   - data: {store_id: os.stoid, orderAmount: condition}
3555   - }).then(res => {
3556   - if (res.data.code == 0) {
3557   - var data = res.data.data;
3558   - th.data.order_prom[pick] = data;
3559 2239 }
3560   - func();
3561   - })
3562   - },
3563 2240  
3564   - //--- 加入优惠活动的映射中,同时要有一个good列表 ---
3565   - add_prom_goods_map: async function (item) {
3566   - var th = this;
3567   - var pickid = item.pick_id;
3568   - var map = th.data.prom_goods_map;
3569   - var obj = map[pickid];
  2241 + //如果优惠促销和搭配购的时候
  2242 + if((good.prom_type==3 || good.prom_type==5) && good.is_collocation!=1 && good.is_gift!=1){
  2243 + var p_ok=1;
  2244 + await getApp().request.promiseGet("/api/weshop/goods/getGoodsPromList/" + os.stoid+"/"+good.goods_id+"/0", {}).then(res => {
  2245 + if(res.data.code==0){
  2246 + var r_data=res.data.data;
  2247 + if(!r_data.collocationPromList && good.prom_type==5){
3570 2248  
3571   - if (map[pickid]) {
3572   - if (map[pickid][item.prom_id]) {
3573   - var ob = map[pickid][item.prom_id];
3574   - ob.price += item.goods_price * item.goods_num;
3575   - ob.goods_num += item.goods_num;
3576   - ob.goods.push({goods_id: item.goods_id, goods_price: item.goods_price, goods_num: item.goods_num});
  2249 + var content=good.goods_name+'未找到活动,请取消订单重新购买';
  2250 + th.toast(content);
  2251 + p_ok=0;
  2252 + }
  2253 + if(!r_data.promGoodsLists && good.prom_type==3){
3577 2254  
3578   - } else {
3579   - var prom = null;
3580   - await getApp().request.promiseGet("/api/weshop/promgoods/get/" + os.stoid + "/" + item.prom_id, {}).then(res => {
3581   - if (res.data.code == 0) {
3582   - prom = res.data.data;
  2255 + var content=good.goods_name+'未找到活动,请取消订单重新购买';
  2256 + th.toast(content);
  2257 + p_ok=0;
  2258 + }
  2259 + }else{
  2260 +
  2261 + var content=good.goods_name+'未找到活动,请取消订单重新购买';
  2262 + th.toast(content);
  2263 + p_ok=0;
3583 2264 }
3584 2265 })
3585   - var ob = {};
3586   - ob.prom_id = item.prom_id;
3587   - ob.price = item.goods_price * item.goods_num;
3588   - ob.goods_num = item.goods_num;
3589   - ob.is_bz = prom.is_bz;
3590   - ob.is_xz_yh = prom.is_xz_yh;
3591   - ob.goods = new Array();
3592   - ob.goods.push({goods_id: item.goods_id, goods_price: item.goods_price, goods_num: item.goods_num});
3593   - map[pickid][item.prom_id] = ob;
  2266 + if(!p_ok) return false;
3594 2267 }
3595   - } else {
3596   - var ob = {};
3597   - var prom = null;
3598   - await getApp().request.promiseGet("/api/weshop/promgoods/get/" + os.stoid + "/" + item.prom_id, {}).then(res => {
3599   - if (res.data.code == 0) {
3600   - prom = res.data.data;
  2268 +
  2269 + //商品的普通购买 ,不要进行判断
  2270 + 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){
  2271 + if(gg.prom_type!=good.prom_type) {
  2272 +
  2273 + var content=gg.goods_name+'商品的活动发生了变化,请取消订单重新购买';
  2274 + th.toast(content);
  2275 + return false;
3601 2276 }
3602   - })
3603   - ob.prom_id = item.prom_id;
3604   - ob.price = item.goods_price * item.goods_num;
3605   - ob.goods_num = item.goods_num;
3606   - ob.is_bz = prom.is_bz;
3607   - ob.is_xz_yh = prom.is_xz_yh;
3608   - ob.goods = new Array();
3609   - ob.goods.push({goods_id: item.goods_id, goods_price: item.goods_price, goods_num: item.goods_num});
  2277 + }else{
  2278 + if((gg.prom_type==1 || gg.prom_type==3 || gg.prom_type==5 || gg.prom_type==6 || gg.prom_type==4)
  2279 + && !good.is_collocation && !good.is_gift && !good.is_integral_normal && !good.is_pd_normal) {
  2280 + var prom=null;
  2281 + //---如果是活动的时候---
  2282 + var prom=null,th=this;
  2283 + if(gg.prom_type==1){
  2284 + await getApp().request.promiseGet("/api/ms/flash_sale/get/"+os.stoid+"/"+gg.prom_id,{
  2285 + }).then(res=>{
  2286 + if(res.data.code==0){
  2287 + prom=res.data.data;
  2288 + }
  2289 + })
  2290 + }
  2291 + if(gg.prom_type==6){
  2292 + await getApp().request.promiseGet("/api/weshop/teamlist/get/"+os.stoid+"/"+gg.prom_id,{
  2293 + }).then(res=>{
  2294 + if(res.data.code==0){
  2295 + prom=res.data.data;
  2296 + }
  2297 + })
  2298 + }
3610 2299  
3611   - var obj = {};
3612   - obj[item.prom_id] = ob;
3613   - map[pickid] = obj;
  2300 + if(gg.prom_type==4){
  2301 + await getApp().request.promiseGet("/api/weshop/integralbuy/pageIntegralBuyGoodsList?stype=1&stypeup=1",{
  2302 + data:{store_id:os.stoid,goods_id:gg.goods_id}
  2303 + }).then(res=>{
  2304 + if(res.data.code==0 && res.data.data && res.data.data.pageData){
  2305 + prom=res.data.data.pageData[0];
  2306 + }
  2307 + })
  2308 + }
3614 2309  
3615   - }
3616   - },
  2310 + if(prom){
  2311 + var t_now=ut.gettimestamp();
  2312 + if(prom.is_end==0 && prom.start_time<t_now && prom.end_time>t_now){
3617 2313  
3618   - //计算立即购买赠品的物流费用
3619   - get_now_gift_goods_wuliu: function (code, o_shipping_price, user_addr, gift_freight_free, allpice, rs, shipping_price, no_by_data, goods_weight1, goods_piece1) {
3620   - var good = this.data.buy_now_gift_goods;
3621   - var goods_weight = -1, goods_piece = -1;
3622   - var gift_shipping_price = 0;
3623   - var th = this;
3624   - switch (good['exp_sum_type']) {
3625   - case 1:
3626   - //统一运费
3627   - gift_shipping_price += good['uniform_exp_sum'];
3628   - gift_shipping_price += o_shipping_price;
3629   - break;
3630   - case 2:
3631   - if (goods_weight < 0) goods_weight = 0;
3632   - //累积商品重量 每种商品的重量 * 数量
3633   - goods_weight += good['weight'] * good['buynum'];
3634   - if (goods_weight1 > 0) {
3635   - goods_weight += goods_weight1;
  2314 + var content=gg.goods_name+'商品的活动发生了变化,请取消订单重新购买';
  2315 + th.toast(content);
  2316 + return false;
  2317 + }
  2318 + }
3636 2319 }
3637   - break;
3638   - case 3:
3639   - if (goods_piece < 0) goods_piece = 0;
3640   - //累积商品数量
3641   - goods_piece += good['buynum'];
3642   - if (goods_piece1) {
3643   - goods_piece += goods_piece1;
  2320 + else{
  2321 + //不是赠品的时候
  2322 + if(!good.is_gift && good.prom_type!=3){
  2323 + var t_ok=1;
  2324 + await getApp().request.promiseGet("/api/weshop/goods/getGoodsPromList/" + os.stoid+"/"+good.goods_id+"/0", {}).then(res => {
  2325 + if(res.data.code==0){
  2326 + var r_data=res.data.data;
  2327 + //-- 参加了全局的优惠活动 --
  2328 + if(r_data.promGoodsLists){
  2329 +
  2330 + var content=gg.goods_name+'商品的活动发生了变化,请取消订单重新购买';
  2331 + th.toast(content);
  2332 + t_ok=0;
  2333 + }
  2334 + }
  2335 + })
  2336 + if(!t_ok) return false;
  2337 + }
  2338 +
  2339 + //-- 如果有参加线下取价 --
  2340 + if(good.offline_cut>0) wlist+=encodeURIComponent(gg.erpwareid)+",";
3644 2341 }
3645   - break;
3646   - }
  2342 + //赠品和搭配购不判断商品金额
  2343 + var isok=1;
  2344 + var card_field=th.data.card_field;
  2345 + //如果会员是等级会员,商品有等级价,且不是活动商品
  2346 + if(!good.is_gift && !good.is_collocation && good.prom_type!=8) {
  2347 + if (card_field && gg[card_field] > 0) {
  2348 + if (good.goods_price != gg[card_field] && good.offline_cut<=0) isok = 0;
  2349 + if (good.goods_price >gg[card_field] && good.offline_cut>0) isok = 0; //如果线下价格比较贵,则不通过
  2350 +
  2351 + } else {
  2352 + if (good.goods_price != gg.shop_price && good.offline_cut<=0) isok = 0;
  2353 + if (good.goods_price> gg.shop_price && good.offline_cut>0) isok = 0; //如果线下价格比较贵,则不通过
  2354 + }
  2355 + var is_h=0;
  2356 + if (!isok) {
  2357 +
  2358 + var content=gg.goods_name + '商品的价格发生了变化,请取消订单重新购买';
  2359 + th.toast(content);
  2360 + return false;
  2361 + }
  2362 + }
  2363 +
  2364 +
  2365 + if(good.goods_num>store_count){
  2366 +
  2367 + var content=gg.goods_name+'商品的库存不足,请取消订单';
  2368 + th.toast(content);
  2369 + return false;
  2370 + }
3647 2371  
3648 2372  
3649   - //如果有设置不包邮区域的时候
3650   - if (no_by_data && no_by_data.region_list) {
3651   - if (th.check_by_area(no_by_data.region_list)) {
3652   - gift_freight_free = 0;
3653   - th.data.is_no_by[th.data.bn_pick] = 1;
3654 2373 }
3655   - }
3656   - //如果有设置不包邮商品
3657   - if (no_by_data && no_by_data.goods_list && gift_freight_free) {
3658   - if (th.check_by_goods(no_by_data.goods_list, good.goods_id)) {
3659   - gift_freight_free = 0;
3660   - //th.data.is_no_by[th.data.bn_pick]=1;
  2374 +
  2375 + console.log("------------------------------------");
  2376 + //---如果是活动的时候---
  2377 + var prom=null,goodsinfo=good,th=this;
  2378 + if(goodsinfo.prom_type==1){
  2379 + await getApp().request.promiseGet("/api/ms/flash_sale/get/"+os.stoid+"/"+goodsinfo.prom_id,{
  2380 + }).then(res=>{
  2381 + if(res.data.code==0){
  2382 + prom=res.data.data;
  2383 + }
  2384 + })
  2385 + }
  2386 + if(goodsinfo.prom_type==6 && !good.is_pd_normal){
  2387 + await getApp().request.promiseGet("/api/weshop/teamlist/get/"+os.stoid+"/"+goodsinfo.prom_id,{
  2388 + }).then(res=>{
  2389 + if(res.data.code==0){
  2390 + prom=res.data.data;
  2391 + }
  2392 + })
3661 2393 }
3662   - }
3663 2394  
3664   - var t_shipping_price =
3665   - this.calculatewuliu(code, gift_shipping_price, goods_weight,
3666   - goods_piece, user_addr, gift_freight_free, allpice, rs);
3667   - return t_shipping_price;
  2395 + if(goodsinfo.prom_type==4 && !good.is_integral_normal){
  2396 + await getApp().request.promiseGet("/api/weshop/integralbuy/pageIntegralBuyGoodsList?stype=1&stypeup=1",{
  2397 + data:{store_id:os.stoid,goods_id:goodsinfo.goods_id}
  2398 + }).then(res=>{
  2399 + if(res.data.code==0 && res.data.data && res.data.data.pageData){
  2400 + prom=res.data.data.pageData[0];
  2401 + }
  2402 + })
  2403 + }
3668 2404  
3669   - },
  2405 + //----------如果有活动,并且在进行中,就不计算线下库存---------------
  2406 + if(prom){
  2407 + var now=ut.gettimestamp();
  2408 + if(prom.is_end==1 && prom.end_time<now){
3670 2409  
3671   - //从优惠的映射中拿出商品从表的item
3672   - item_map_get_goods: function (goods_id, map) {
3673   - for (var i in map.goods) {
3674   - if (map.goods[i].goods_id == goods_id) return map.goods[i];
3675   - }
3676   - },
3677   - //从优惠的映射中拿出商品从表的item
3678   - arr_get_goods: function (goods_id, arr) {
3679   - for (var i in arr) {
3680   - if (arr[i].goods_id == goods_id) return arr[i];
3681   - }
3682   - },
  2410 + var content=goodsinfo.goods_name+'商品的活动已经结束,请取消订单重新购买';
  2411 + th.toast(content);
  2412 + return false;
  2413 + }
3683 2414  
3684   - //检查是不是有其他门店的订单在选择了券
3685   - check_other_use: function (iter, pkid) {
3686   - var using = this.data.using_quan;
3687   - var is_use = 0;
3688   - if (using) {
3689   - for (var i in using) {
3690   - if (i == pkid) continue;
3691   - if (iter.CashRepNo == using[i].coupon_no) {
3692   - is_use = 1;
3693   - break;
  2415 + buyed_mum2=promgoodsbuynum+good.goods_num;
  2416 + if (buyed_mum2 > prom.buy_limit && prom.buy_limit > 0) {
  2417 +
  2418 + var content=goodsinfo.goods_name+'购买数量超出商品活动限购,请取消订单重新购买';
  2419 + th.toast(content);
  2420 + return false;
  2421 + }
  2422 +
  2423 + if(goodsinfo.prom_type==4){
  2424 + if (good.goods_num > prom.limitqty-prom.buy_num) {
  2425 +
  2426 + var content=goodsinfo.goods_name+'购买数量超出商品活动库存,请取消订单';
  2427 + th.toast(content);
  2428 + return false;
  2429 + }
  2430 + }else{
  2431 + var redis_num = 0;
  2432 + //------判断活动是否抢光-----
  2433 + await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" +
  2434 + os.stoid + "/" + goodsinfo.prom_type + "/" + goodsinfo.prom_id, {
  2435 + }).then(res => {
  2436 + redis_num = res.data.data;
  2437 + });
  2438 +
  2439 + if (good.goods_num > redis_num) {
  2440 +
  2441 + var content=gg.goods_name+'超出商品活动库存,请取消订单';
  2442 + th.toast(content);
  2443 + return false;
  2444 + }
3694 2445 }
  2446 +
3695 2447 }
3696   - }
3697   - return is_use;
3698   - },
3699   - //检查是不是有其他门店的订单在选择了包邮券
3700   - check_other_use_by: function (iter, pkid) {
3701   - var using = this.data.using_quan;
3702   - var is_use = 0;
3703   - if (using) {
3704   - for (var i in using) {
3705   - if (i == pkid) continue;
3706   - if (iter.no == using[i].coupon_no) {
3707   - is_use = 1;
3708   - break;
  2448 +
  2449 +
  2450 +
  2451 + //-- 要判断一下线下取价价格是不是发生改变 --
  2452 + if(wlist!="" && th.data.is_open_offline && th.data.is_open_offline>0){
  2453 + wlist=ut.sub_last(wlist);
  2454 + var keyid=order.pickup_id;
  2455 + var user_info=getApp().globalData.userInfo;
  2456 + if(!keyid) return false;
  2457 + var offarr=null;
  2458 + await getApp().request.promiseGet("/api/weshop/goods/listWarePrice", {
  2459 + data:{
  2460 + VIPId:encodeURIComponent(user_info.erpvipid),
  2461 + store_id:os.stoid,
  2462 + PickupId:keyid,
  2463 + WareIds:wlist},
  2464 + },
  2465 + ).then(res=>{
  2466 + if(res.data.code==0 && res.data.data && res.data.data.length>0){
  2467 + offarr=res.data.data;
  2468 + }
  2469 + })
  2470 + if(!offarr && offarr.length<=0 ){
  2471 + wx.showModal({ title: '获取线下取价失败',});
  2472 + }
  2473 + var newarr=ut.convert_arr_key(offarr,'WareId');
  2474 + //-- 循环判断线下的价格 --
  2475 + for(var k in order_goods){
  2476 + var good=order_goods[k];
  2477 + //判断线下取价是不是一样
  2478 + if(newarr[good.erpwareid] &&
  2479 + parseFloat(newarr[good.erpwareid].WarePrice)!=parseFloat(good.goods_price)){
  2480 +
  2481 + var content=good.goods_name + '商品的价格发生了变化,请取消订单重新购买';
  2482 + th.toast(content);
  2483 + return false;
3709 2484 }
3710 2485 }
  2486 +
3711 2487 }
3712   - return is_use;
3713   - },
3714 2488  
3715   - //跳转到购买卡
3716   - buycard: function () {
3717   - getApp().goto("/pages/user/plus/plus");
3718   - getApp().globalData.plus_buy_back = 1;
3719   - },
  2489 + /*---
  2490 + o.jumpToCart4({
  2491 + order_sn: this.data.order.order_sn,
  2492 + order_amount: this.data.order.order_amount,
  2493 + type: 1 //正常单
  2494 + }, 1);--*/
  2495 +
  2496 + util_pay.pay(this.data.order.order_sn, function() {
  2497 + wx.showToast({title: '支付成功'})
  2498 + wx.navigateBack();
  2499 + },null,os.stoid,1);
3720 2500  
3721   - //跳转关闭弹出框的显示
3722   - close_offline: function () {
3723   - this.setData({is_offline_show: 0});
3724   - },
3725 2501  
3726   - //立即购买显示弹出框
3727   - bn_pop_offline: function () {
3728   - var off_price = this.data.bn_goods.shop_price - this.data.bn_goods.offline_price;
3729   - //是不是线下
3730   - var is_get_offline = this.data.bn_goods.is_offline;
3731   - this.setData({is_offline_show: 1, show_off_price: off_price.toFixed(2), is_get_offline: is_get_offline});
3732 2502 },
3733 2503  
3734   - //确定使用线下取价
3735   - sure_offline: function () {
3736   - var bn_goods = this.data.bn_goods;
3737   - if (bn_goods && bn_goods.prom_type == 0) {
3738   - bn_goods.is_offline = 1;
3739   - this.setData({is_offline_show: 0, bn_goods: bn_goods});
3740   - this.calculatePrice2();
3741   - }
3742   - //就是购物车结算时的
3743   - else {
3744   - var index = this.data.pop_offline_index;
3745   - var txt = "cartlist[" + index + "].is_offline";
3746   - this.setData({[txt]: 1, is_offline_show: 0,});
3747   - this.data.old_cartlist[index].is_offline = 1;
3748   - this.calculatePrice();
3749   - }
  2504 +
  2505 + //--------取消订单---------
  2506 + cancelOrder: function(e) {
  2507 + var t = this,th=t, ord_id = this.data.order.order_id,order=this.data.order;
  2508 +
  2509 + wx.showModal({
  2510 + title: "是否取消订单?",
  2511 + success: function(e) {
  2512 + if(!e.confirm) return false;
  2513 + //如果是秒杀和拼单的商品,取消订单要返回redis,并取消订单
  2514 + //if(is_skill==1 || is_zsorder>=2){
  2515 + getApp().request.post("/api/weshop/order/cancelOrder/"+os.stoid+"/"+ord_id+"/"+getApp().globalData.user_id,{
  2516 + data:{},
  2517 + success: function(t) {
  2518 + if(t.data.code==0){
  2519 + th.setData({'order.order_status':3});
  2520 + wx.setStorageSync("order:order_list:update", !0);
  2521 + }
  2522 +
  2523 + },
  2524 + })
  2525 +
  2526 + }
  2527 + });
3750 2528 },
3751 2529  
3752 2530  
3753   - //取消使用线下取价
3754   - cancle_offline: function () {
3755   - //判断是不是立即购买
3756   - var bn_goods = this.data.bn_goods;
3757   - if (bn_goods && bn_goods.prom_type == 0) {
3758   - bn_goods.is_offline = 0;
3759   - this.setData({is_offline_show: 0, bn_goods: bn_goods});
3760   - this.calculatePrice2();
3761   - }
3762   - //就是购物车结算时的
3763   - else {
3764   - var index = this.data.pop_offline_index;
3765   - var txt = "cartlist[" + index + "].is_offline";
3766   - this.setData({[txt]: 0, is_offline_show: 0,})
3767   - this.data.old_cartlist[index].is_offline = 0;
3768   - this.calculatePrice();
3769   - }
  2531 + //-----删除订单-----
  2532 + deleteOrderData: function(t) {
  2533 + var th=this;
  2534 + var order_id=this.data.order.order_id;
  2535 + var up_data={
  2536 + order_id: order_id,isdel:1
  2537 + };
  2538 + if(th.data.order.order_status!=6){
  2539 + up_data.order_status=5;
  2540 + }
  2541 + wx.showModal({
  2542 + title: "是否删除订单?",
  2543 + success: function(tt) {
  2544 + tt.confirm && getApp().request.put("/api/weshop/order/updatebyId", {
  2545 + data: up_data,
  2546 + success: function (t) {
  2547 + getApp().my_warnning("删除成功",1,th);
  2548 + setTimeout(function () {
  2549 + getApp().goto("/pages/user/order_list/order_list");
  2550 + },1000);
  2551 + }
  2552 + })
  2553 + }
  2554 + });
3770 2555 },
3771 2556  
3772   - //-- 弹出购物车选择是不是要店铺优惠 --
3773   - cart_pop_offline: function (e) {
3774   - var index = e.currentTarget.dataset.index;
3775   - var item = this.data.cartlist[index];
3776   - var off_price = item.offline_price;
3777   - //是不是线下
3778   - var is_get_offline = item.is_offline;
3779   - this.setData({
3780   - pop_offline_index: index,
3781   - is_offline_show: 1,
3782   - show_off_price: off_price.toFixed(2),
3783   - is_get_offline: is_get_offline
  2557 + go_goods:function (e) {
  2558 + var url=e.currentTarget.dataset.url;
  2559 + getApp().goto(url);
  2560 + },
  2561 + toast(msg){
  2562 + wx.showToast({
  2563 + title: msg,
  2564 + icon: 'none',
  2565 + duration: 3000
  2566 + })
  2567 + },
  2568 + //--------确认收货---------
  2569 + confirmOrder: function(e) {
  2570 + var th=this;
  2571 + var o = this.data.order.order_id,order=this.data.order;
  2572 + wx.showModal({
  2573 + title: "是否确认收货?",
  2574 + success: function(t) {
  2575 + t.confirm && getApp().request.post("/api/weshop/order/confirmOrder/"+os.stoid+"/"+o+"/"+getApp().globalData.user_id,{
  2576 + success:function (e) {
  2577 + if(e.data.code==0){
  2578 + th.setData({})
  2579 + }
  2580 + }
  2581 + })
  2582 + }
3784 2583 });
3785 2584 },
3786   -
3787   - // 是否同意预售商品不退定金
3788   - switchChange(e) {
3789   - let isSwitchOn = e.detail;
3790   - }
  2585 +
  2586 +
  2587 +
3791 2588  
3792 2589  
3793 2590 });
... ...
packageC/pages/presell/cart/cart.json
1 1 {
2   - "navigationBarTitleText": "填写订单",
  2 + "navigationBarTitleText": "订单详情",
3 3 "enablePullDownRefresh": false,
4 4 "usingComponents": {
5 5 "warn": "/components/long_warn/long_warn"
... ...
packageC/pages/presell/cart/cart.wxml
... ... @@ -2,747 +2,658 @@
2 2 <wxs src="filter.wxs" module="util"></wxs>
3 3 <wxs module="filters" src="../../../../utils/filter.wxs"></wxs>
4 4  
5   -<form bindsubmit="submitForm">
6   - <view class="container">
7   -
8   - <!-- 支付进度 -->
9   - <view class="information bdr14 mgt20">
10   - <view class="item ai-center" style="justify-content: flex-start;">
11   - <view class="pdr20"><text class="iconfont icon-qianbao fs60"></text></view>
12   - <!-- <view class="">
13   - <view>等待尾款支付开始</view>
14   - <view>2021.10.01 00:00:00 - 2021.10.10 23:59:59</view>
15   - </view> -->
16   - <view class="">
17   - <view>等待买家付尾款</view>
18   - <view class="fs22">请于*天**小时**分**秒内付款完成,超时订单将自动取消</view>
19   - </view>
20   - </view>
21   - <view class="pdb20 flex t-c fs22 c-7b">
22   - <view class="f1">
23   - <view>付定金</view>
24   - <view class="box">
25   - <text class="iconfont icon-yes"></text>
26   - </view>
27   - </view>
28   - <view class="f1">
29   - <view>付尾款</view>
30   - <view class="box line"><text class="circle"></text></view>
31   - </view>
32   - <view class="f1">
33   - <view>商家发货</view>
34   - <view class="box line"><text class="circle"></text></view>
35   - </view>
36   - <view class="f1">
37   - <view>交易完成</view>
38   - <view class="box line"><text class="circle"></text></view>
39   - </view>
40   - </view>
41   - </view>
42   -
43   - <!-- 退款完成 -->
44   - <view class="information bdr14 mgt20">
45   - <view class="item ai-center" style="justify-content: flex-start;">
46   - <view class="pdr20"><text class="iconfont icon-tkcg fs60"></text></view>
47   - <view class="">退款完成(定金)</view>
48   - </view>
49   - </view>
50   -
51   - <!-- 立即购买的时候 -->
52   - <block wx:if="{{is_b_now==1}}">
53   - <view class="tab-container">
54   - <view class="tab-wrapper">
55   - <view hidden="{{bn_t_exp_t==2}}" bindtap='setexptype' data-t='1' class="tab {{bn_exp_type == 1? 'active':''}}"
56   - data-txt='cartlist[0].exp_type' data-wl_txt='cartlist[0].wind' data-index="{{index}}" >门店自提</view>
57   -
58   - <view hidden="{{bn_t_exp_t==1}}" bindtap='setexptype' data-t='0' class="tab {{bn_exp_type== 0 ? 'active':''}}"
59   - data-txt='cartlist[0].exp_type' data-wl_txt='cartlist[0].wind' data-index="{{index}}" >快递邮寄</view>
60   -
61   - </view>
62   - </view>
63   - </block>
64   - <!-- 购物购买只有一单的时候 -->
65   - <block wx:if="{{is_b_now==0 && cartlist.length==1}}">
66   - <view class="tab-container">
67   - <view class="tab-wrapper">
68   - <view hidden="{{cartlist[0].distr_t==2}}" bindtap='setexptype_w' data-ind="0" data-t='1' class="tab {{cartlist[0].exp_type == 1? 'active':''}}"
69   - data-txt='cartlist[0].exp_type' data-wl_txt='cartlist[0].wind' data-index="{{index}}" >门店自提</view>
70   -
71   - <view hidden="{{cartlist[0].distr_t==1}}" bindtap='setexptype_w' data-ind="0" data-t='0' class="tab {{cartlist[0].exp_type== 0 ? 'active':''}}"
72   - data-txt='cartlist[0].exp_type' data-wl_txt='cartlist[0].wind' data-index="{{index}}" >快递邮寄</view>
73   -
74   - </view>
75   - </view>
76   - </block>
77   -
78   -
79   - <!--要进行判断地址是否显示---->
80   - <view bindtap="enterAddressPage" class="user-mes mgt20" hidden='{{(bn_exp_type==1 && is_b_now==1) || (is_all_zt==1 && is_b_now==0)}}'>
81   - <!---默认地址显示------>
82   - <block wx:if="{{user_addr!=null}}">
83   -
84   - <view class="user-contact">
85   - <text class="bold fs36 pdr20">{{user_addr.consignee}}</text>
86   - <text class="fs28">{{user_addr.mobile}}</text>
87   - </view>
88   - <view class="location">
89   - <view class="address fs26 pdt20">
90   - <view class="pos-icon">
91   - <image class="wh100 bdr14" src="{{imgUrl}}/miniapp/images/goodscategory/new_position.png"></image>
92   - </view>
93   - {{user_addr.more_address}}{{' '}}{{user_addr.address}}
94   - </view>
95   -
96   - </view>
97   - <view class="update-logistics">
98   - <!-- <image class="arrow-rigth" src="{{imgUrl}}/miniapp/images/new_position.png"></image> -->
99   - <view class="xc-right"></view>
100   - </view>
101   - </block>
102   - <!---先增地址------>
103   - <block wx:else>
104   - <view class="add_new">
105   - <image class="addr_jia" src="{{imgUrl}}/miniapp/images/jia.png"></image>添加地址
106   - </view>
107   - </block>
108   - <!-- <view class="border-img">
109   - <image class="wh100" src="{{imgUrl}}/miniapp/images/order/new_dividing_line.png"></image>
110   - </view> -->
111   - </view>
112   -
113   - <!-- -------------------购物车进来,有可能多单-------------------- -->
114   - <block wx:if="{{is_b_now==0}}">
115   - <!-- <view class="xc-border main-top"></view> -->
116   - <view wx:for="{{cartlist}}" wx:for-index="pidx">
117   - <view class="use-item bfff bdr_t-14 mgt20">
118   - <image class="dp" src='{{imgUrl}}/miniapp/images/goodscategory/new_store.png'></image>
119   - <!-- <view>门店:{{item.pname}}</view> -->
120   - <view>{{item.pname}}</view>
121   - </view>
122   - <view class="order-detail" wx:for="{{item.goods}}" wx:for-index="idx" wx:for-item="items">
123   - <!----商品图片----->
124   - <view class="goods-img" style="position: relative">
125   - <image wx:if="{{items.is_gift}}" src="{{imgUrl}}/miniapp/images/giveaway.png" class="gift_image"></image>
126   - <image class="wh100 bdr14" src="{{items.original_img}}" binderror='cart_set_err' data-err='cartlist[{{pidx}}].goods[{{idx}}].original_img'></image>
127   - </view>
128   - <!----商品名称规格---->
129   - <navigator class="order-cont" url="/pages/goods/goodsInfo/goodsInfo?goods_id={{items.goods_id}}">
130   - <view class="goods-name ellipsis-2">{{items.goods_name}}</view>
131   - <!-- 商品属性 -->
132   - <view class="flex-vertical fs28 color-gray n_guige">
133   - <view class="goods-color">
134   - <block><text>{{filters.show_gui_ge(items.goods_spec,items.goods_color)}}</text></block>
135   - <!--<block wx:if="{{!items.goods_spec && !items.goods_color}}"><text>规格1</text></block>-->
136   - <!--<block wx:else>-->
137   - <!--<text wx:if="{{items.goods_spec!=''}}">{{items.goods_spec}}<text wx:if="{{items.goods_color}}">/</text></text>-->
138   - <!--<text wx:if="{{items.goods_color}}">{{items.goods_color}}</text>-->
139   - <!--</block>-->
140   - </view>
141   - </view>
142   -
143   -
144   - <!-----商品名称规格------>
145   - <view class="order-num flex-space-between">
146   - <view class="co-red">¥<text class="fs36">{{filters.toFix(items.goods_price,2)}}</text></view>
147   - <view class="goods-num">x{{items.goods_num}}</view>
148   - </view>
149   - </navigator>
150   - </view>
151   -
152   - <!-- 如果是等级卡的商品,会员没有注册,要提醒注册 -->
153   - <view class="plus_buy fs28" wx:if="{{item.card_cut_price>0}}">
154   - <view class="flex">
155   - <view class="card_bg ellipsis-1" style="margin-right: 10rpx;">
156   - <image src="{{imgUrl}}/miniapp/images/plus/dj_icon.png"></ image>
157   - <text class="card_name">{{show_card.CardName}}</text>
158   - </view>
159   - <view>立减 <text style="color:#f23030;">{{filters.toFix(item.card_cut_price,2) }}</text> 元</view>
160   - </view>
161   - <view>
162   - <text style="color: #999;margin-left: 4rpx;">vip超级会员仅需{{show_card.CardFee}}元</text>
163   - </view>
164   - <!-- 三角形 -->
165   - <view class="car_tri_up"></view>
166   - <!-- 立即开通跳转 -->
167   - <view bindtap="buycard" class="card_op">立即开通</view>
168   - </view>
169   -
170   -
171   - <!-----使用优惠券------>
172   - <view class="xc-coupon-frame flex-center" data-bn="0" bindtap="open_coupon_list" wx:if="{{(item.quan_list && item.quan_list.length>0) || get_by_quan_list_cart[item.pickup_id]!=null}}"
173   - data-cind="{{pidx}}" data-pickid="{{item.pickup_id}}">
174   - <view class="work-frame flex-space-between">
175   - <view class="work">优惠券<text class="quan_num_show fs20">{{item.can_num}}张可用</text></view>
176   - <view class="xc-right-frame">
177   - <text wx:if="{{using_quan[item.pickup_id].is_nouse}}">不使用</text>
178   - <text wx:if="{{using_quan[item.pickup_id].money}}">¥{{using_quan[item.pickup_id].money}}元优惠券</text>
179   - <text wx:if="{{using_quan[item.pickup_id].isby}}">包邮券</text>
180   - <view class="xc-right"></view>
181   - </view>
182   - </view>
183   - </view>
184   -
185   -
186   - <view class="set-mes bdr_b-14">
187   - <view wx:if="{{order.store_prom}}">
188   - <icon color="#f23030" size="16" type="info"></icon>
189   - {{order.store_prom}}
190   - </view>
191   -
192   - <!-- 当是物流很多单的时候 -->
193   - <view class="use-item flex-space-between" wx:if="{{cartlist.length>1}}">
194   - <view class="flex-vertical" >
195   - <view bindtap='setexptype_w' data-ind="{{pidx}}" data-t='1' data-txt='cartlist[{{pidx}}].exp_type'
196   - style="padding-right:26rpx;display:{{item.distr_t==2?'none':'flex;align-items: center'}};">
197   - <!-- <icon bindtap='setexptype_w' data-t='1' data-txt='cartlist[{{pidx}}].exp_type' color="{{item.exp_type==1?'red':'gray'}}" size="16" type="success"></icon> -->
198   -
199   - <block wx:if="{{item.exp_type==1}}">
200   - <!-- <view class="circle white xc-hookt fs20 red-b sn"><text>Γ</text></view> -->
201   - <icon data-t='0' data-txt='cartlist[{{pidx}}].exp_type' color="red" size="16" type="success"></icon>
202   - </block>
203   - <block wx:else>
204   - <view class="circle xc-hookts on"></view>
205   - </block>
206   - <view bindtap='setexptype_w' data-ind="{{pidx}}" data-t='1' data-txt='cartlist[{{pidx}}].exp_type' class="yu_er">门店自提</view>
207   - </view>
208   -
209   - <view data-t='0' data-txt='cartlist[{{pidx}}].exp_type' data-ind="{{pidx}}" bindtap="setexptype_w" style="display:{{item.distr_t==1?'none':'flex;align-items: center'}};">
210   - <!-- <icon bindtap='setexptype_w' data-t='0' data-txt='cartlist[{{pidx}}].exp_type' color="{{item.exp_type==0?'red':'gray'}}" size="16" type="success"></icon> -->
211   - <block wx:if="{{item.exp_type==0}}">
212   - <!-- <view class="circle white xc-hookt fs20 red-b sn"><text>Γ</text></view> -->
213   - <icon data-t='0' data-txt='cartlist[{{pidx}}].exp_type' color="red" size="16" type="success"></icon>
214   - </block>
215   - <block wx:else>
216   - <view class="circle xc-hookts on"></view>
217   - </block>
218   -
219   - <view bindtap='setexptype_w' data-t='0' data-ind="{{pidx}}" data-txt='cartlist[{{pidx}}].exp_type' data-wl_txt='cartlist[{{pidx}}].wind'
220   - class="yu_er">快递邮寄</view>
221   - </view>
222   - </view>
223   -
224   -
225   - <!-- 点击显示物流选择,如果是默认使用的情况不成立 -->
226   - <view wx:if="{{!is_default_logistics && item.exp_type!=1}}" class="flex-vertical" bindtap="show_wu_arr" data-txt='cartlist[{{pidx}}].wind' data-w_sele_index="{{pidx}}" style="padding-right:6rpx;">
227   - <view>{{wu_arr[item.wind].name}}</view>
228   - <view class="xc-right"></view>
229   - </view>
230   -
231   - </view>
232   -
233   - <!-- 当是物流,只有一单的时候 -->
234   - <block wx:else >
235   - <view class="use-item flex-space-between" wx:if="{{item.exp_type==0 && !is_default_logistics}}">
236   - <view class="flex jc_sb" style="width: 100%; padding: 0 13rpx;">
237   - <view>选择物流</view>
238   - <view class="flex-vertical" bindtap="show_wu_arr" data-txt='cartlist[{{pidx}}].wind' data-w_sele_index="{{pidx}}" style="padding-right:6rpx;">
239   - <view>{{wu_arr[item.wind].name}}</view>
240   - <view class="xc-right"></view>
241   - </view>
242   - </view>
243   - </view>
244   - </block>
245   -
246   -
247   - </view>
248   -
249   - <!-- 留言 -->
250   - <view class="coupon-mes flex-vertical">
251   - <view>留言</view>
252   - <view class="leave-word">
253   - <input placeholder-class="fs28" placeholder='给商家留言,最多100字' bindinput="keyUpChangeNum" disabled="{{disabled}}"
254   - class="word-box" maxlength="100" name="user_note_{{item.pickup_id}}"></input>
255   -
256   - </view>
257   - </view>
  5 +<form bindsubmit="submitForm" wx:if="{{show_submit}}">
  6 + <view class="container">
  7 + <!-- 支付进度 -->
  8 + <view class="information bdr14 mgt20">
  9 + <view class="item ai-center" style="justify-content: flex-start;">
  10 + <view class="pdr20">
  11 + <text class="iconfont icon-qianbao fs60"></text>
  12 + </view>
  13 +
  14 + <view wx:if="{{wait_dj}}">
  15 + <view>等待买家付定金</view>
  16 + <view>{{filters.format_time(presell.kw_start_time,1)}} -
  17 + {{filters.format_time(presell.kw_end_time,1)}}
  18 + </view>
  19 + </view>
  20 +
  21 + <view wx:if="{{wait_wk && no_start}}">
  22 + <view>等待尾款支付开始</view>
  23 + <view>{{filters.format_time(presell.kw_start_time,1)}} -
  24 + {{filters.format_time(presell.kw_end_time,1)}}
  25 + </view>
  26 + </view>
  27 +
  28 +
  29 + <view wx:if="{{wait_sh}}">
  30 + <view>等待收货</view>
  31 + <view>{{order.order_sn}}</view>
  32 + </view>
  33 +
  34 + <view wx:if="{{wait_wk && !no_start}}">
  35 + <view>等待买家付尾款</view>
  36 + <view class="fs22">请于{{days}}天{{hours}}小时{{minutes}}分{{seconds}}秒内付款完成,超时订单将自动取消</view>
  37 + </view>
  38 + <view wx:if="{{wait_fh}}">
  39 + <view>等待商家发货</view>
  40 + <view class="fs22">将在{{filters.format_time(send_time,1)}}后发货</view>
  41 + </view>
  42 + <view wx:if="{{order.order_status==2}}">
  43 + <view>待评价</view>
  44 + <view>{{order.order_sn}}</view>
  45 + </view>
  46 + <view wx:if="{{order.order_status==3}}">
  47 + <view>已取消</view>
  48 + <view>{{order.order_sn}}</view>
  49 + </view>
  50 + <view wx:if="{{order.order_status==4}}">
  51 + <view>已完成</view>
  52 + <view>{{order.order_sn}}</view>
  53 + </view>
  54 + <view wx:if="{{order.order_status==5}}">
  55 + <view>已作废</view>
  56 + <view>{{order.order_sn}}</view>
  57 + </view>
  58 + <view wx:if="{{order.order_status==6}}">
  59 + <view>退款退货完成</view>
  60 + <view>{{order.order_sn}}</view>
  61 + </view>
  62 + </view>
  63 +
  64 +
  65 + <view class="pdb20 flex t-c fs22 c-7b">
  66 + <view class="f1">
  67 + <view>付定金</view>
  68 + <view wx:if="{{presell.deposit_pay_time>0}}" class="box">
  69 + <text class="iconfont icon-yes"></text>
  70 + </view>
  71 + <view wx:else class="box">
  72 + <text class="circle1"></text>
  73 + </view>
  74 + </view>
  75 + <view class="f1" wx:if="{{presell.presell_type!=1}}">
  76 + <view>付尾款</view>
  77 + <view wx:if="{{presell.tail_pay_state==1}}" class="box line">
  78 + <text class="iconfont icon-yes"></text>
  79 + </view>
  80 + <view wx:else class="box line">
  81 + <text class="circle1"></text>
  82 + </view>
  83 + </view>
  84 + <view class="f1">
  85 + <view>商家发货</view>
  86 + <view wx:if="{{order.pay_status==2 || order.shipping_status==1}}" class="box line">
  87 + <text class="iconfont icon-yes"></text>
  88 + </view>
  89 + <view wx:else class="box line">
  90 + <text class="circle1"></text>
  91 + </view>
  92 + </view>
  93 + <view class="f1">
  94 + <view>交易完成</view>
  95 + <view wx:if="{{order.order_status==4}}" class="box line">
  96 + <text class="iconfont icon-yes"></text>
  97 + </view>
  98 + <view wx:else class="box line">
  99 + <text class="circle1"></text>
  100 + </view>
  101 + </view>
  102 + </view>
  103 + </view>
  104 +
  105 + <!-- 退款完成 -->
  106 + <!--
  107 + <view class="information bdr14 mgt20">
  108 + <view class="item ai-center" style="justify-content: flex-start;">
  109 + <view class="pdr20"><text class="iconfont icon-tkcg fs60"></text></view>
  110 + <view class="">退款完成(定金)</view>
  111 + </view>
  112 + </view>-->
  113 +
  114 + <block wx:if="{{wait_wk}}">
  115 + <!-- 立即购买的时候 -->
  116 + <view class="tab-wrapper">
  117 + <view hidden="{{distr_type==2}}" bindtap='set_wuliu' data-type='1'
  118 + class="tab {{exp_type == 1? 'active':''}}"
  119 + data-txt='cartlist[0].exp_type' data-wl_txt='cartlist[0].wind' data-index="{{index}}">门店自提
  120 + </view>
  121 +
  122 + <view hidden="{{distr_type==1}}" bindtap='set_wuliu' data-type='0'
  123 + class="tab {{exp_type== 0 ? 'active':''}}"
  124 + data-txt='cartlist[0].exp_type' data-wl_txt='cartlist[0].wind' data-index="{{index}}">快递邮寄
  125 + </view>
  126 + </view>
  127 + <!----要进行判断地址是否显示---->
  128 + <view bindtap="enterAddressPage" class="user-mes mgt20"
  129 + hidden='{{exp_type==1 }}'>
  130 + <!-----默认地址显示---->
  131 + <block wx:if="{{user_addr!=null}}">
  132 + <view class="user-contact">
  133 + <text class="bold fs36 pdr20">{{user_addr.consignee}}</text>
  134 + <text class="fs28">{{user_addr.mobile}}</text>
  135 + </view>
  136 + <view class="location flex ai_c" style="font-size: 28rpx">
  137 + <view class="pos-icon">
  138 + <image class="wh100" style="vertical-align: top"
  139 + src="{{imgUrl}}/miniapp/images/goodscategory/new_position.png"></image>
  140 + </view>
  141 + <view class="address">{{user_addr.more_address}}{{' '}}{{user_addr.address}}</view>
  142 +
  143 + </view>
  144 + <view class="update-logistics">
  145 + <image class="arrow-rigth" src="{{imgUrl}}/miniapp/images/icon-arrowdown.png"></image>
  146 + </view>
  147 + </block>
  148 + <!-----先增地址------>
  149 + <block wx:else>
  150 + <view class="add_new">
  151 + <image class="addr_jia" src="{{imgUrl}}/miniapp/images/jia.png"></image>
  152 + 添加地址
  153 + </view>
  154 + </block>
  155 + </view>
  156 + </block>
  157 +
  158 + <view class="user-mes" style="margin-top: 20rpx" wx:if="{{order.pay_status==1 && order.exp_type==0}}">
  159 + <view class="user-contact" style=" margin-left: 20rpx">
  160 + {{order.consignee}}{{'  '}}{{order.mobile}}
  161 + </view>
  162 + <view class="location flex ">
  163 +
  164 + <view class="pos-icon" style="width: 26rpx; height: 26rpx">
  165 + <image class="wh100" src="{{imgUrl}}/miniapp/images/iconfont-shouhuodizhi.png"></image>
  166 + </view>
  167 + <view class="address">{{order.more_address}} {{order.address}}</view>
  168 + </view>
  169 +
  170 + </view>
  171 +
  172 +
  173 +
  174 + <view class="use-item bfff bdr_t-14 mgt20">
  175 + <image class="dp" src='{{imgUrl}}/miniapp/images/goodscategory/new_store.png'></image>
  176 + <view>{{pickup.pickup_name}}</view>
  177 + </view>
  178 + <view class="order-detail">
  179 + <view class="goods-img" bindtap="go_goods" data-url="/packageC/pages/presell/goodsInfo/goodsInfo?goods_id={{goods.goods_id}}&pre_id={{pre_arr.id}}">
  180 + <image class="wh100 bdr14" src="{{imgUrl}}{{goods.original_img}}" binderror='cart_set_err'
  181 + data-err="goods.original_img"></image>
  182 + </view>
  183 + <navigator class="order-cont"
  184 + url="/packageC/pages/presell/goodsInfo/goodsInfo?goods_id={{goods.goods_id}}&pre_id={{pre_arr.id}}">
  185 + <view class="goods-name ellipsis-2">{{goods.goods_name}}</view>
  186 + <!-- 商品属性 -->
  187 + <view class="flex-vertical fs28 xc-ash color-gray n_guige">
  188 + <view class="goods-color">
  189 + <block>
  190 + <text>{{filters.show_gui_ge(goods.goods_spec,goods.goods_color)}}</text>
  191 + </block>
  192 + </view>
  193 + </view>
  194 + <!-- ---商品名称规格---- -->
  195 + <view class="order-num flex-space-between">
  196 + <view class="co-red">¥
  197 + <text class="fs36">{{filters.toFix(pre_arr.presell_price,2)}}</text>
  198 + </view>
  199 + <view class="goods-num">×{{order.order_goods.goods_num}}</view>
  200 + </view>
  201 + </navigator>
  202 +
  203 + </view>
  204 +
  205 + <!-- 如果是等级卡的商品,会员没有注册,要提醒注册 -->
  206 + <view class="plus_buy fs28" wx:if="{{card_cut_price>0}}">
  207 + <view class="flex">
  208 + <view class="card_bg ellipsis-1" style="margin-right: 10rpx;">
  209 + <image src="{{imgUrl}}/miniapp/images/plus/dj_icon.png"></
  210 + image>
  211 + <text class="card_name">{{show_card.CardName}}</text>
  212 + </view>
  213 + <view>立减
  214 + <text style="color:#f23030;">{{filters.toFix(card_cut_price,2) }}</text>
  215 + 元
  216 + </view>
  217 + </view>
  218 + <view>
  219 + <text style="color: #999;margin-left: 4rpx;">vip超级会员仅需{{show_card.CardFee}}元</text>
  220 + </view>
  221 + <!-- 三角形 -->
  222 + <view class="car_tri_up"></view>
  223 + <!-- 立即开通跳转 -->
  224 + <view bindtap="buycard" class="card_op">立即开通</view>
  225 + </view>
  226 +
  227 +
  228 + <view class="set-mes bdr_b-14" wx:if="{{presell.deposit_pay_time>0 && presell.tail_pay_state==0 && !no_start && !wait_dj}}">
  229 + <view wx:if="{{order.store_prom}}">
  230 + <icon color="#f23030" size="16" type="info"></icon>
  231 + {{order.store_prom}}
  232 + </view>
  233 +
  234 + <view class="xc-coupon-frame flex-center" data-bn="1" bindtap="open_coupon_list" data-pickid="{{pickup_id}}"
  235 + wx:if="{{(selected_quan_list && selected_quan_list.length>0) || get_by_quan_list!=null}}">
  236 + <view class="work-frame flex-space-between">
  237 + <view class="work">
  238 + 优惠券
  239 + <text class="quan_num_show">{{(selected_quan_list?selected_quan_list.length:0)+
  240 + (get_by_quan_list?get_by_quan_list.length:0)}}张可用
  241 + </text>
  242 + </view>
  243 + <view class="xc-right-frame">
  244 + <text wx:if="{{using_quan[pickup_id].is_nouse_red}}">不使用</text>
  245 + <block wx:else>
  246 + <text wx:if="{{using_quan[pickup_id].money}}">¥{{using_quan[pickup_id].money}}元优惠券</text>
  247 + <text wx:if="{{using_quan[pickup_id].isby}}">包邮券</text>
  248 + </block>
  249 + <view class="xc-right"></view>
  250 + </view>
  251 + </view>
  252 + </view>
  253 +
  254 + <view class="xc-coupon-frame" wx:if="{{bn_exp_type==0 && !is_default_logistics}}">
  255 + <view class="flex-space-between" style="padding: 20rpx 25rpx; font-size: 30rpx;">
  256 + <view>选择物流</view>
  257 + <view class="flex-vertical" bindtap="show_wu_arr" data-txt='index' style="margin-right: 12rpx;">
  258 + <view class="logistics-name">{{wu_arr[index].name}}</view>
  259 + <view class="xc-right"></view>
  260 + </view>
  261 + </view>
  262 + </view>
  263 + </view>
  264 + <!-- 留言 -->
  265 + <view class="coupon-mes flex-vertical">
  266 + <view>留言</view>
  267 + <view class="leave-word" wx:if="{{sh_liuyan}}">
  268 + <input placeholder-class="fs28" bindblur="close_liuyan" focus="{{sh_liuyan}}" bindinput="keyUpChangeNum"
  269 + value="{{user_note}}"
  270 + class="word-box" maxlength="100" name="user_note"></input>
  271 + </view>
  272 +
  273 + <view wx:if="{{!sh_liuyan}}" bindtap="show_liuyan">
  274 + <text class="fs26 {{user_note?'':'gray'}} note_text">{{user_note?user_note:'给商家留言,最多100字'}}</text>
  275 + </view>
  276 +
  277 + </view>
258 278  
259 279 <!-- 是否参与店铺优惠 -->
260   - <view class="coupon-mes flex-vertical" data-index="{{index}}" bindtap="cart_pop_offline" wx:if="{{item.offline_price}}">
261   - <view>店铺优惠</view>
262   - <view class="leave-word fs32" style="color: #999;">
263   - 省{{filters.toFix(item.offline_price,2)}}元
264   - </view>
265   - <block wx:if="{{item.is_offline}}">
266   - <text style="color: #d7642b;">-¥{{filters.toFix(item.offline_price,2)}}</text>
267   - </block>
268   - <block wx:else>
269   - <text style="color: #d7642b;">不使用优惠</text>
270   - </block>
271   - <!-- 右边点击 -->
272   - <view class="xc-right" style="margin-right: 12rpx; border-color: #d7642b;"></view>
  280 + <view class="coupon-mes flex-vertical" bindtap="bn_pop_offline" wx:if="{{bn_goods.offline_price}}">
  281 + <view>店铺优惠</view>
  282 + <view class="leave-word fs32" style="color: #999;">
  283 + 省{{filters.toFix(bn_goods.shop_price-bn_goods.offline_price,2)}}元
  284 + </view>
  285 + <block wx:if="{{bn_goods.is_offline}}">
  286 + <text style="color: #d7642b;">-¥{{filters.toFix(bn_goods.shop_price-bn_goods.offline_price,2)}}</text>
  287 + </block>
  288 + <block wx:else>
  289 + <text style="color: #d7642b;">不使用优惠</text>
  290 + </block>
  291 + <!-- 右边点击 -->
  292 + <view class="xc-right" style="margin-right: 12rpx; border-color: #d7642b;"></view>
273 293 </view>
274 294  
275   - </view>
276   -
277   - <!-- ---使用余额---- -->
278   - <view class="set-mes bdr_t-14" wx:if="{{yuer>0}}">
279   - <view class="use-item" bindtap='set_js_useyuer'>
280   - <icon color="{{js_use_money?'red':'gray'}}" size="16" type="success"></icon>
281   - <view class="yu_er">使用余额 :¥{{yuer}} </view>
282   - </view>
283   - </view>
284   -
285   - </block>
286   -
287   - <!-- ----立即购买------ -->
288   - <!-- <view class="xc-border xc-border"></view> -->
289   - <block wx:if="{{is_b_now==1}}">
290   - <view class="use-item bfff bdr_t-14 mgt20">
291   - <image class="dp" src='{{imgUrl}}/miniapp/images/goodscategory/new_store.png'> </image>
292   - <view>{{bn_pickname}}</view>
293   - <!-- <view>门店:{{bn_pickname}}</view> -->
294   - </view>
295   - <view class="order-detail">
296   - <view class="goods-img">
297   - <image class="wh100 bdr14" src="{{bn_goods.original_img}}" binderror='cart_set_err' data-err="bn_goods.original_img"></image>
298   - </view>
299   - <navigator class="order-cont" url="/pages/goods/goodsInfo/goodsInfo?goods_id={{bn_goods.goods_id}}">
300   - <view class="goods-name ellipsis-2">{{bn_goods.goods_name}}</view>
301   - <!-- 商品属性 -->
302   - <view class="flex-vertical fs28 xc-ash color-gray n_guige">
303   - <view class="goods-color">
304   - <block><text>{{filters.show_gui_ge(bn_goods.goods_spec,bn_goods.goods_color)}}</text></block>
305   - <!--<block wx:if="{{!bn_goods.goods_spec && !bn_goods.goods_color}}"><text>规格1</text></block>-->
306   - <!--<block wx:else>-->
307   - <!--<text wx:if="{{bn_goods.goods_spec!=''}}">{{bn_goods.goods_spec}}<text wx:if="{{bn_goods.goods_color}}">/</text></text>-->
308   - <!--<text wx:if="{{bn_goods.goods_color}}">{{bn_goods.goods_color}}</text>-->
309   - <!--</block>-->
310   - </view>
311   - </view>
312   -
313   - <!-- ---商品名称规格---- -->
314   - <view class="order-num flex-space-between">
315   - <view class="co-red">¥<text class="fs36">{{filters.toFix(bn_goods.shop_price,2)}}</text></view>
316   - <view class="goods-num">x{{bn_goods.buynum}}</view>
317   - </view>
318   - </navigator>
319   -
320   - </view>
321   - <!-- 赠品的显示 -->
322   - <view class="order-detail" wx:if="{{buy_now_gift_goods}}">
323   - <view class="goods-img" style="position: relative">
324   - <image src="{{imgUrl}}/miniapp/images/giveaway.png" class="gift_image"></image>
325   -
326   - <image class="wh100 bdr14" src="{{buy_now_gift_goods.original_img}}" binderror='cart_set_err' data-err="buy_now_gift_goods.original_img"></image>
327   - </view>
328   - <navigator class="order-cont" url="/pages/goods/goodsInfo/goodsInfo?goods_id={{buy_now_gift_goods.goods_id}}">
329   - <view class="goods-name ellipsis-2">{{buy_now_gift_goods.goods_name}}</view>
330   - <!-- 商品属性 -->
331   - <view class="flex-vertical fs28 xc-ash color-gray n_guige">
332   - <view class="goods-color">
333   - <block><text>{{filters.show_gui_ge(buy_now_gift_goods.goods_spec,buy_now_gift_goods.goods_color)}}</text></block>
334   - </view>
335   - </view>
336   - <!-- ---商品名称规格---- -->
337   - <view class="order-num flex-space-between">
338   - <view class="co-red">¥<text class="fs36">0</text></view>
339   - <view class="goods-num">x{{buy_now_gift_goods.buynum}}</view>
340   - </view>
341   - </navigator>
342   - </view>
343   -
344   -
345   - <block wx:if="{{collocation_goods}}">
346   - <!-- 搭配购买的功能实现 -->
347   - <view class="order-detail" wx:for="{{collocation_goods}}">
348   - <view class="goods-img">
349   - <image class="wh100 bdr14" src="{{imgUrl+item.original_img}}" binderror='err_img_collocation' data-err="item.original_img"></image>
350   - </view>
351   - <navigator class="order-cont" url="/pages/goods/goodsInfo/goodsInfo?goods_id={{item.goods_id}}">
352   - <view class="goods-name ellipsis-2">{{item.goods_name}}</view>
353   - <!-- 商品属性 -->
354   - <view class="flex-vertical fs28 xc-ash color-gray n_guige">
355   - <view class="goods-color">
356   - <block><text>{{filters.show_gui_ge(item.goods_spec,item.goods_color)}}</text></block>
357   - </view>
358   - </view>
359   - <!-- ---商品名称规格---- -->
360   - <view class="order-num flex-space-between">
361   - <view class="co-red">¥<text class="fs36">{{item.price}}</text></view>
362   - <view class="goods-num">x{{item.goods_num}}</view>
363   - </view>
364   - </navigator>
365   - </view>
366   - </block>
367   -
368   - <!-- 如果是等级卡的商品,会员没有注册,要提醒注册 -->
369   - <view class="plus_buy fs28" wx:if="{{card_cut_price>0}}">
370   - <view class="flex">
371   - <view class="card_bg ellipsis-1" style="margin-right: 10rpx;">
372   - <image src="{{imgUrl}}/miniapp/images/plus/dj_icon.png"></ image>
373   - <text class="card_name">{{show_card.CardName}}</text>
374   - </view>
375   - <view>立减 <text style="color:#f23030;">{{filters.toFix(card_cut_price,2) }}</text> 元</view>
376   - </view>
377   - <view>
378   - <text style="color: #999;margin-left: 4rpx;">vip超级会员仅需{{show_card.CardFee}}元</text>
379   - </view>
380   - <!-- 三角形 -->
381   - <view class="car_tri_up"></view>
382   - <!-- 立即开通跳转 -->
383   - <view bindtap="buycard" class="card_op">立即开通</view>
384   - </view>
385   -
386   -
387   - <view class="set-mes bdr_b-14">
388   - <view wx:if="{{order.store_prom}}">
389   - <icon color="#f23030" size="16" type="info"></icon>{{order.store_prom}}
390   - </view>
391   -
392   - <view class="xc-coupon-frame flex-center" data-bn="1" bindtap="open_coupon_list" data-pickid="{{bn_pick}}" wx:if="{{(selected_quan_list && selected_quan_list.length>0) || get_by_quan_list!=null}}">
393   - <view class="work-frame flex-space-between">
394   - <view class="work">
395   - 优惠券 <text class="quan_num_show">{{(selected_quan_list?selected_quan_list.length:0)+ (get_by_quan_list?get_by_quan_list.length:0)}}张可用</text>
396   - </view>
397   - <view class="xc-right-frame">
398   - <text wx:if="{{using_quan[bn_pick].is_nouse}}">不使用</text>
399   - <block wx:else>
400   - <text wx:if="{{using_quan[bn_pick].money}}">¥{{using_quan[bn_pick].money}}元优惠券</text>
401   - <text wx:if="{{using_quan[bn_pick].isby}}">包邮券</text>
402   - </block>
403   - <view class="xc-right"></view>
404   - </view>
405   - </view>
406   - </view>
407   -
408   - <view class="xc-coupon-frame" wx:if="{{bn_exp_type==0 && !is_default_logistics}}">
409   - <view class="flex-space-between" style="padding: 20rpx 25rpx; font-size: 30rpx;">
410   - <view>选择物流</view>
411   - <view class="flex-vertical" bindtap="show_wu_arr" data-txt='index' style="margin-right: 12rpx;">
412   - <view class="logistics-name">{{wu_arr[index].name}}</view>
413   - <view class="xc-right"></view>
414   - </view>
415   - </view>
416   - </view>
417   - </view>
418   - <!-- 留言 -->
419   - <view class="coupon-mes flex-vertical">
420   - <view>留言</view>
421   - <view class="leave-word">
422   - <input placeholder-class="fs28" placeholder='给商家留言,最多100字' bindinput="keyUpChangeNum" disabled="{{disabled}}"
423   - class="word-box" maxlength="100" name="user_note"></input>
424   - </view>
425   - </view>
426   -
427   - <!-- 是否参与店铺优惠 -->
428   - <view class="coupon-mes flex-vertical" bindtap="bn_pop_offline" wx:if="{{bn_goods.offline_price}}">
429   - <view>店铺优惠</view>
430   - <view class="leave-word fs32" style="color: #999;">
431   - 省{{filters.toFix(bn_goods.shop_price-bn_goods.offline_price,2)}}元
432   - </view>
433   - <block wx:if="{{bn_goods.is_offline}}">
434   - <text style="color: #d7642b;">-¥{{filters.toFix(bn_goods.shop_price-bn_goods.offline_price,2)}}</text>
435   - </block>
436   - <block wx:else>
437   - <text style="color: #d7642b;">不使用优惠</text>
438   - </block>
439   - <!-- 右边点击 -->
440   - <view class="xc-right" style="margin-right: 12rpx; border-color: #d7642b;"></view>
441   - </view>
442   -
443   -
444   - <!-----使用余额------>
445   - <view class="set-mes bdr_t-14" wx:if="{{yuer>0}}">
446   - <view class="use-item" bindtap='set_bn_useyuer'>
447   - <icon color="{{bn_use_money?'red':'gray'}}" size="16" type="success"></icon>
448   - <view class="yu_er">使用余额 :¥{{yuer}} </view>
449   - </view>
450   - </view>
451   -
452   - </block>
453   -
454   - <view class="information bdr14">
455   - <view class="item" wx:if="{{formData.all_price>0}}">
456   - <view>商品金额</view>
457   - <view class="co-red">¥ {{formData.all_price}}元</view>
458   - </view>
459   - <view class="item" wx:if="{{formData.shipping_price>0}}">
460   - <view>配送费用</view>
461   - <view class="co-red">¥ {{formData.shipping_price}}元</view>
462   - </view>
463   - <view class="item" wx:if="{{formData.coupon_price>0}}">
464   - <view>使用优惠券</view>
465   - <view class="co-red">- ¥ {{formData.coupon_price}}元</view>
466   - </view>
467   - <!-- 优惠活动优惠金额 -->
468   - <view class="item" wx:if="{{formData.cut_price>0}}">
469   - <view>优惠活动</view>
470   - <view class="co-red">- ¥ {{filters.toFix(formData.cut_price,2)}}元</view>
471   - </view>
472   - <!-- 组合购优惠金额 -->
473   - <view class="item" wx:if="{{formData.zh_cut_price>0 || formData.zh_cut_price<0}}">
474   - <view>组合购优惠</view>
475   - <view class="co-red">- ¥ {{filters.toFix(formData.zh_cut_price,2)}}元</view>
476   - </view>
477   -
478   - <!-- 订单优惠优惠金额 -->
479   - <view class="item" wx:if="{{formData.order_prom_amount>0}}">
480   - <view>订单优惠</view>
481   - <view class="co-red">- ¥ {{filters.toFix(formData.order_prom_amount,2)}}元</view>
482   - </view>
483   - <view class="item" wx:if="{{formData.user_money>0}}">
484   - <view>使用余额</view>
485   - <view class="co-red">- ¥ {{formData.user_money}}元</view>
486   - </view>
487   - </view>
488   -
489   - <view class="information bdr14 mgt20">
490   - <view class="item">
491   - <view>阶段一:定金(待付款)</view>
492   - <view class="co-red">¥9.99元</view>
493   - </view>
494   - <view class="item">
495   - <view>阶段二:尾款</view>
496   - <view class="co-red">¥88元</view>
497   - </view>
498   - </view>
499   -
500   - <view class="information bdr14 mgt20">
501   - <view class="item ai-center">
502   - <view>我同意预售商品不退定金</view>
503   - <switch type="switch" checked="" bindchange="switchChange"/>
504   - </view>
505   - </view>
506   -
507   - </view>
508   -
509   - <view class="fixedToBottom shadow-1" wx:if="{{show_submit}}">
510   - <!-- <view class="date-container">尾款时间:2021.10.01 00:00:00 - 2021.10.10 23:59:59</view> -->
511   - <view class="date-container">请于*天**小时**分**秒内付款完成,超时订单将自动取消</view>
512   - <view class="btn-wrap">
513   - <view class="pay-amount">
514   - <view class="payable">应付金额:<text class="co-red"><text class="fs24">¥</text>{{formData.order_amount}}</text></view>
515   - <!-- 预售 -->
516   - <!-- <view class="payable">尾款:<text class="co-red"><text class="fs24">¥</text>{{formData.order_amount}}</text></view> -->
517   - </view>
518   - <button class="tips-btn" formType="submit" id="submitOrder">提交订单</button>
519   - <!-- 预售 -->
520   - <!-- <button class="tips-btn" formType="submit" id="submitOrder">立即支付</button> -->
521   - </view>
522   - </view>
  295 +
  296 + <view class="information bdr14">
  297 + <view class="item" wx:if="{{allpice>0}}">
  298 + <view>商品金额</view>
  299 + <view class="co-red">¥ {{filters.toFix(allpice,2)}}元</view>
  300 + </view>
  301 + <view class="item" wx:if="{{exp_price>0}}">
  302 + <view>配送费用</view>
  303 + <view class="co-red">¥ {{filters.toFix(exp_price,2)}}元</view>
  304 + </view>
  305 +
  306 + <view class="item" wx:if="{{quan_price>0}}">
  307 + <view>优惠券优惠</view>
  308 + <view class="co-red">¥ -{{filters.toFix(quan_price,2)}}元</view>
  309 + </view>
  310 +
  311 + <view class="item" wx:if="{{order_prom_amount>0}}">
  312 + <view>订单优惠</view>
  313 + <view class="co-red">¥ -{{filters.toFix(order_prom_amount,2)}}元</view>
  314 + </view>
  315 +
  316 + </view>
  317 +
  318 + <view class="information bdr14 mgt20">
  319 + <view class="item">
  320 + <view>阶段一:定金(待付款)</view>
  321 + <view class="co-red">¥{{filters.toFix(pre_arr.presell_money*order.order_goods.goods_num,2)}}元</view>
  322 + </view>
  323 + <view class="item">
  324 + <view>阶段二:尾款</view>
  325 + <view class="co-red">¥{{filters.toFix(tail_pay,2)}}元</view>
  326 + </view>
  327 + </view>
  328 + </view>
  329 +
  330 + <!-- 要支付尾款的时候 -->
  331 + <view class="fixedToBottom shadow-1" wx:if="{{wait_wk}}">
  332 + <view wx:if="{{no_start}}" class="date-container">尾款时间{{filters.format_time(presell.kw_start_time,1)}} -
  333 + {{filters.format_time(presell.kw_end_time,1)}}
  334 + </view>
  335 + <view wx:elif="{{is_end}}" class="date-container">尾款时间已经结束</view>
  336 + <view wx:elif="{{wait_wk && !no_start}}" class="date-container">
  337 + 请于{{days}}天{{hours}}小时{{minutes}}分{{seconds}}秒内付款完成,超时订单将自动取消
  338 + </view>
  339 +
  340 + <view class="btn-wrap">
  341 + <view class="pay-amount">
  342 + <view class="payable">应付金额:
  343 + <text class="co-red"> <text class="fs24">¥</text>{{filters.toFix(order_m-presell.presell_deposit,2)}}</text>
  344 + </view>
  345 + </view>
  346 + <button wx:if="{{no_start || is_end || is_complete}}" class="tips-btn gray">提交订单</button>
  347 + <button wx:else class="tips-btn" bindtap="show_pay">提交订单</button>
  348 + <!-- 预售 -->
  349 + <!-- <button class="tips-btn" formType="submit" id="submitOrder">立即支付</button> -->
  350 + </view>
  351 + </view>
  352 + <!-- 当订单不是支付尾款的时候 -->
  353 + <view class="fixedToBottom shadow-1" wx:else style="background-color: #fff;display: flex; justify-content: flex-end; padding: 10rpx 0">
  354 + <view bindtap="cancelOrder" data-id="{{order.order_id}}" class="tips-btn2" wx:if="{{wait_dj}}">取消订单</view>
  355 + <view bindtap="jumpToCart4" class="tips-btn2" wx:if="{{wait_dj}}">立即付款</view>
  356 + <block wx:if="{{!(order.has_rt || order.return_btn==2 || order.return_btn==4)}}">
  357 + <navigator bindtap="confirmOrder" class="tips-btn2" hidden="{{!wait_sh}}">收货确认</navigator>
  358 + </block>
  359 +
  360 + <view class="tips-btn2" wx:if="{{order.order_status==3}}" bindtap="deleteOrderData" data-order_id="{{order.order_id}}" >删除订单</view>
  361 +
  362 +
  363 + <navigator class="tips-btn2" hidden="{{!order.shipping_btn}}" url="/pages/user/express/express?order_id={{order.order_id}}">查看物流</navigator>
  364 +
  365 +
  366 + <block wx:if="{{order.return_btn==undefined && order.is_all_return!=1}}">
  367 + <navigator class="tips-btn2" wx:if="{{(order.order_status==0&&order.pay_status==1) && !order.is_bedistri}}" url="/pages/order/refund_order/refund_order?order_id={{order.order_id}}">申请退款</navigator>
  368 + <navigator class="tips-btn2" wx:if="{{(order.order_status==1&&order.pay_status==1) && !order.is_bedistri}}" url="/pages/order/refund_order/refund_order?order_id={{order.order_id}}">申请退款</navigator>
  369 + </block>
  370 + <block wx:else>
  371 + <view class="tips-btn2" wx:if="{{order.is_all_return_status==2 && order.isdel==0}}" bindtap="deleteOrderData" data-order_id="{{order.order_id}}" >删除订单</view>
  372 + <navigator class="tips-btn2" wx:if="{{order.is_all_return_status==3 && order.order_status<2}}" url="/pages/order/refund_order/refund_order?order_id={{order.order_id}}">重新退款</navigator>
  373 + <navigator class="tips-btn2" wx:if="{{order.is_all_return_status==0 || order.is_all_return_status==1}}"
  374 + url="/pages/user/return_goods_info/return_goods_info?order_id={{order.order_id}}">退款详情</navigator>
  375 + </block>
  376 +
  377 +
  378 + <block wx:if="{{order.order_status==2 }}">
  379 + <navigator class="tips-btn2" url="/packageB/pages/user/add_comment/add_comment?goods_id={{order_goods.goods_id}}&order_id={{order.order_id}}}">去评价</navigator>
  380 + </block>
  381 +
  382 + </view>
  383 +
  384 +
523 385 </form>
524 386  
525 387 <!-- 使用券列表的弹窗 -->
526 388 <view wx:if='{{open_quan==1}}'>
527   - <view class="cover-layer flex-center " bindtap='close_coupon'> </view>
528   - <view class="cx-popup {{open_quan==true?'up' : 'down'}}">
529   - <!-- 最上面 -->
530   - <view class="top flex">
531   - <view class="xc-top-content t-c">
532   - <view class="xc-title">优惠券使用</view>
533   - </view>
534   - <view class="xc-close-frame" bindtap='close_coupon'>
535   - <view class="xc-close">×</view>
536   - </view>
537   - </view>
538   - <!-- 使用优惠券和不使用优惠券层-->
539   - <view class="may_use_coupon fs28 flex"> 可使用的优惠券
540   - <view class=" is_use_coupon flex-vertical" bindtap="sele_quan_item" data-no="1">不使用优惠券
541   - <block wx:if="{{using_quan[selected_quan_pick].is_nouse_red}}">
542   - <view class="circle white xc-hooka fs20 red-b sn"><text>Γ</text></view>
543   - </block>
544   - <block wx:else>
545   - <view class="circle xc-hookst ons"></view>
546   - </block>
547   - </view>
548   - </view>
549   -
550   - <!-- 中间券内容显示 -->
551   - <view class="xc-frame flex-level">
552   - <view class="list-frame">
553   - <view wx:for="{{selected_quan_list}}" bindtap="sele_quan_item" wx:if="{{!item.is_using}}" data-ind="{{q_index}}"
554   - wx:for-item="item" wx:for-index="q_index">
555   - <view class="xc-coupon-frame flex-center" data-ind="{{q_index}}">
556   - <view class="coupon-frame flex rel">
557   - <!-- 锯齿 -->
558   - <include src="juchi_part.wxml" />
559   - <!-- 左边 -->
560   - <view class="coupon-left rel {{filter.setcolor(item.UseObjectType)}} flex-center">
561   - <view class="white xc-money-frames">
562   - <view class="f_text"><text class="xc-rmb-symbol">¥</text><text class="xc-rmb-val">{{item.Sum}}</text></view>
563   - <view class="coupon-explain t-c" wx:if="{{item.BuySum>0}}">满{{item.BuySum}}元可用</view>
564   - <view class="coupon-explain t-c" wx:else>满0元可用</view>
565   - </view>
566   - </view>
567   - <!-- 右边 -->
568   - <view class="coupon-right flex-center rel">
569   - <view class="coupon-annotation flex">
570   - <view class="flex top-frame">
571   - <view class="frame">
572   - <view class="coupon-wode ib flex ellipsis-2 ">
573   - <text class="xc-brand t-c ib white {{filter.setcolor(item.UseObjectType)}}">{{filter.get_type_card(item.UseObjectType)}}</text>
574   - <block>{{item.Sum}}元优惠券</block>
575   - </view>
576   - <view class="coupon-time">{{filters.replace_time2(item.BeginDate)}}至{{item.ValidDate?filters.replace_time2(item.ValidDate):'不限'}}</view>
577   - </view>
578   - </view>
579   - <block wx:if="{{item.show_red}}">
580   - <view class="circle white xc-hook fs20 red-b sn"><text>Γ</text></view>
581   - </block>
582   - <block wx:else>
583   - <view class="circle xc-hooks on"></view>
584   - </block>
585   - </view>
586   - <include src="remark_click_part.wxml" />
587   - </view>
588   - </view>
589   - </view>
590   - <!-- 打开是说明 -->
591   - <include src="remark_part.wxml" />
592   - </view>
593   - <!-- 包邮券的显示,立即购买 -->
594   - <block wx:if="{{ is_b_now && bn_exp_type==0}}">
595   - <view wx:for="{{get_by_quan_list}}" bindtap="sele_quan_item_by" wx:if="{{!item.is_using}}" data-ind="{{byq_index}}"
596   - wx:for-item="item" wx:for-index="byq_index">
597   - <view class="xc-coupon-frame flex-center" data-ind="{{byq_index}}">
598   - <view class="coupon-frame flex rel">
599   - <!-- 锯齿 -->
600   - <include src="juchi_part.wxml" />
601   - <!-- 左边 -->
602   - <view class="coupon-left rel {{filter.setcolor(item.UseObjectType)}} flex-center">
603   - <view class="white xc-money-frames">
604   - <view class="f_text"><text class="xc-rmb-val">包邮券</text></view>
605   - <view class="coupon-explain t-c" wx:if="{{item.condition>0}}">满{{item.condition}}元可用</view>
606   - <view class="coupon-explain t-c" wx:else>满0元可用</view>
607   - </view>
608   - </view>
609   - <!-- 右边 -->
610   - <view class="coupon-right flex-center rel">
611   - <view class="coupon-annotation flex">
612   - <view class="flex top-frame">
613   - <view class="frame">
614   - <view class="coupon-wode ib flex ellipsis-2 ">
615   - <text class="xc-brand t-c ib white {{filter.setcolor(item.UseObjectType)}}">{{filter.get_type_card(0)}}</text>
616   - <block>包邮券</block>
617   - </view>
618   - <view class="coupon-time">{{filters.format_time(item.use_start_time)}}至{{item.use_end_time?filters.format_time(item.use_end_time):'不限'}}</view>
619   - </view>
620   - </view>
621   - <block wx:if="{{item.show_red}}">
622   - <view class="circle white xc-hook fs20 red-b sn"><text>Γ</text></view>
623   - </block>
624   - <block wx:else>
625   - <view class="circle xc-hooks on"></view>
626   - </block>
627   - </view>
628   - <include src="remark_click_part2.wxml" />
629   - </view>
630   - </view>
631   - </view>
632   - <!-- 打开是说明 -->
633   - <include src="remark_part.wxml" />
634   - </view>
635   - </block>
636   -
637   - <!-- 包邮券的显示,购物车购买 -->
638   - <block wx:if="{{!is_b_now && sele_exp_type==0}}">
639   - <view wx:for="{{by_quan_list_cart}}" bindtap="sele_quan_item_by" wx:if="{{!item.is_using}}" data-ind="{{byq_index}}"
640   - wx:for-item="item" wx:for-index="byq_index">
641   - <view class="xc-coupon-frame flex-center" data-ind="{{byq_index}}">
642   - <view class="coupon-frame flex rel">
643   - <!-- 锯齿 -->
644   - <include src="juchi_part.wxml" />
645   - <!-- 左边 -->
646   - <view class="coupon-left rel {{filter.setcolor(item.UseObjectType)}} flex-center">
647   - <view class="white xc-money-frames">
648   - <view class="f_text"><text class="xc-rmb-val">包邮券</text></view>
649   - <view class="coupon-explain t-c" wx:if="{{item.condition>0}}">满{{item.condition}}元可用</view>
650   - <view class="coupon-explain t-c" wx:else>满0元可用</view>
651   - </view>
652   - </view>
653   - <!-- 右边 -->
654   - <view class="coupon-right flex-center rel">
655   - <view class="coupon-annotation flex">
656   - <view class="flex top-frame">
657   - <view class="frame">
658   - <view class="coupon-wode ib flex ellipsis-2 ">
659   - <text class="xc-brand t-c ib white {{filter.setcolor(item.UseObjectType)}}">{{filter.get_type_card(0)}}</text>
660   - <block>包邮券</block>
661   - </view>
662   - <view class="coupon-time">{{filters.format_time(item.use_start_time)}}至{{item.use_end_time?filters.format_time(item.use_end_time):'不限'}}</view>
663   - </view>
664   - </view>
665   - <block wx:if="{{item.show_red}}">
666   - <view class="circle white xc-hook fs20 red-b sn"><text>Γ</text></view>
667   - </block>
668   - <block wx:else>
669   - <view class="circle xc-hooks on"></view>
670   - </block>
671   - </view>
672   - <include src="remark_click_part2.wxml" />
673   - </view>
674   - </view>
675   - </view>
676   - <!-- 打开是说明 -->
677   - <include src="remark_part.wxml" />
678   - </view>
679   - </block>
680   -
681   -
682   - </view>
683   - </view>
684   - <!-- 最底下确定层-->
685   - <view class="determine-frame">
686   - <view class="xc-confirm flex-center" bindtap="confirm_quan"> 确定 </view>
687   - </view>
688   - </view>
  389 + <view class="cover-layer flex-center " bindtap='close_coupon'></view>
  390 + <view class="cx-popup {{open_quan==true?'up' : 'down'}}">
  391 + <!-- 最上面 -->
  392 + <view class="top flex">
  393 + <view class="xc-top-content t-c">
  394 + <view class="xc-title">优惠券使用</view>
  395 + </view>
  396 + <view class="xc-close-frame" bindtap='close_coupon'>
  397 + <view class="xc-close">×</view>
  398 + </view>
  399 + </view>
  400 + <!-- 使用优惠券和不使用优惠券层-->
  401 + <view class="may_use_coupon fs28 flex"> 可使用的优惠券
  402 + <view class=" is_use_coupon flex-vertical" bindtap="sele_quan_item" data-no="1">不使用优惠券
  403 + <block wx:if="{{using_quan[selected_quan_pick].is_nouse_red}}">
  404 + <view class="circle white xc-hooka fs20 red-b sn">
  405 + <text>Γ</text>
  406 + </view>
  407 + </block>
  408 + <block wx:else>
  409 + <view class="circle xc-hookst ons"></view>
  410 + </block>
  411 + </view>
  412 + </view>
  413 +
  414 + <!-- 中间券内容显示 -->
  415 + <view class="xc-frame flex-level">
  416 + <view class="list-frame">
  417 + <view wx:for="{{selected_quan_list}}" bindtap="sele_quan_item" wx:if="{{!item.is_using}}"
  418 + data-ind="{{q_index}}"
  419 + wx:for-item="item" wx:for-index="q_index">
  420 + <view class="xc-coupon-frame flex-center" data-ind="{{q_index}}">
  421 + <view class="coupon-frame flex rel">
  422 + <!-- 锯齿 -->
  423 + <include src="juchi_part.wxml"/>
  424 + <!-- 左边 -->
  425 + <view class="coupon-left rel {{filter.setcolor(item.UseObjectType)}} flex-center">
  426 + <view class="white xc-money-frames">
  427 + <view class="f_text">
  428 + <text class="xc-rmb-symbol">¥</text>
  429 + <text class="xc-rmb-val">{{item.Sum}}</text>
  430 + </view>
  431 + <view class="coupon-explain t-c" wx:if="{{item.BuySum>0}}">满{{item.BuySum}}元可用
  432 + </view>
  433 + <view class="coupon-explain t-c" wx:else>满0元可用</view>
  434 + </view>
  435 + </view>
  436 + <!-- 右边 -->
  437 + <view class="coupon-right flex-center rel">
  438 + <view class="coupon-annotation flex">
  439 + <view class="flex top-frame">
  440 + <view class="frame">
  441 + <view class="coupon-wode ib flex ellipsis-2 ">
  442 + <text class="xc-brand t-c ib white {{filter.setcolor(item.UseObjectType)}}">
  443 + {{filter.get_type_card(item.UseObjectType)}}
  444 + </text>
  445 + <block>{{item.Sum}}元优惠券</block>
  446 + </view>
  447 + <view class="coupon-time">
  448 + {{filters.replace_time2(item.BeginDate)}}至{{item.ValidDate?filters.replace_time2(item.ValidDate):'不限'}}
  449 + </view>
  450 + </view>
  451 + </view>
  452 + <block wx:if="{{item.show_red}}">
  453 + <view class="circle white xc-hook fs20 red-b sn">
  454 + <text>Γ</text>
  455 + </view>
  456 + </block>
  457 + <block wx:else>
  458 + <view class="circle xc-hooks on"></view>
  459 + </block>
  460 + </view>
  461 + <include src="remark_click_part.wxml"/>
  462 + </view>
  463 + </view>
  464 + </view>
  465 + <!-- 打开是说明 -->
  466 + <include src="remark_part.wxml"/>
  467 + </view>
  468 + <!-- 包邮券的显示,立即购买 -->
  469 + <block wx:if="{{ is_b_now && bn_exp_type==0}}">
  470 + <view wx:for="{{get_by_quan_list}}" bindtap="sele_quan_item_by" wx:if="{{!item.is_using}}"
  471 + data-ind="{{byq_index}}"
  472 + wx:for-item="item" wx:for-index="byq_index">
  473 + <view class="xc-coupon-frame flex-center" data-ind="{{byq_index}}">
  474 + <view class="coupon-frame flex rel">
  475 + <!-- 锯齿 -->
  476 + <include src="juchi_part.wxml"/>
  477 + <!-- 左边 -->
  478 + <view class="coupon-left rel {{filter.setcolor(item.UseObjectType)}} flex-center">
  479 + <view class="white xc-money-frames">
  480 + <view class="f_text">
  481 + <text class="xc-rmb-val">包邮券</text>
  482 + </view>
  483 + <view class="coupon-explain t-c" wx:if="{{item.condition>0}}">
  484 + 满{{item.condition}}元可用
  485 + </view>
  486 + <view class="coupon-explain t-c" wx:else>满0元可用</view>
  487 + </view>
  488 + </view>
  489 + <!-- 右边 -->
  490 + <view class="coupon-right flex-center rel">
  491 + <view class="coupon-annotation flex">
  492 + <view class="flex top-frame">
  493 + <view class="frame">
  494 + <view class="coupon-wode ib flex ellipsis-2 ">
  495 + <text class="xc-brand t-c ib white {{filter.setcolor(item.UseObjectType)}}">
  496 + {{filter.get_type_card(0)}}
  497 + </text>
  498 + <block>包邮券</block>
  499 + </view>
  500 + <view class="coupon-time">
  501 + {{filters.format_time(item.use_start_time)}}至{{item.use_end_time?filters.format_time(item.use_end_time):'不限'}}
  502 + </view>
  503 + </view>
  504 + </view>
  505 + <block wx:if="{{item.show_red}}">
  506 + <view class="circle white xc-hook fs20 red-b sn">
  507 + <text>Γ</text>
  508 + </view>
  509 + </block>
  510 + <block wx:else>
  511 + <view class="circle xc-hooks on"></view>
  512 + </block>
  513 + </view>
  514 + <include src="remark_click_part2.wxml"/>
  515 + </view>
  516 + </view>
  517 + </view>
  518 + <!-- 打开是说明 -->
  519 + <include src="remark_part.wxml"/>
  520 + </view>
  521 + </block>
  522 +
  523 + <!-- 包邮券的显示,购物车购买 -->
  524 + <block wx:if="{{!is_b_now && sele_exp_type==0}}">
  525 + <view wx:for="{{by_quan_list_cart}}" bindtap="sele_quan_item_by" wx:if="{{!item.is_using}}"
  526 + data-ind="{{byq_index}}"
  527 + wx:for-item="item" wx:for-index="byq_index">
  528 + <view class="xc-coupon-frame flex-center" data-ind="{{byq_index}}">
  529 + <view class="coupon-frame flex rel">
  530 + <!-- 锯齿 -->
  531 + <include src="juchi_part.wxml"/>
  532 + <!-- 左边 -->
  533 + <view class="coupon-left rel {{filter.setcolor(item.UseObjectType)}} flex-center">
  534 + <view class="white xc-money-frames">
  535 + <view class="f_text">
  536 + <text class="xc-rmb-val">包邮券</text>
  537 + </view>
  538 + <view class="coupon-explain t-c" wx:if="{{item.condition>0}}">
  539 + 满{{item.condition}}元可用
  540 + </view>
  541 + <view class="coupon-explain t-c" wx:else>满0元可用</view>
  542 + </view>
  543 + </view>
  544 + <!-- 右边 -->
  545 + <view class="coupon-right flex-center rel">
  546 + <view class="coupon-annotation flex">
  547 + <view class="flex top-frame">
  548 + <view class="frame">
  549 + <view class="coupon-wode ib flex ellipsis-2 ">
  550 + <text class="xc-brand t-c ib white {{filter.setcolor(item.UseObjectType)}}">
  551 + {{filter.get_type_card(0)}}
  552 + </text>
  553 + <block>包邮券</block>
  554 + </view>
  555 + <view class="coupon-time">
  556 + {{filters.format_time(item.use_start_time)}}至{{item.use_end_time?filters.format_time(item.use_end_time):'不限'}}
  557 + </view>
  558 + </view>
  559 + </view>
  560 + <block wx:if="{{item.show_red}}">
  561 + <view class="circle white xc-hook fs20 red-b sn">
  562 + <text>Γ</text>
  563 + </view>
  564 + </block>
  565 + <block wx:else>
  566 + <view class="circle xc-hooks on"></view>
  567 + </block>
  568 + </view>
  569 + <include src="remark_click_part2.wxml"/>
  570 + </view>
  571 + </view>
  572 + </view>
  573 + <!-- 打开是说明 -->
  574 + <include src="remark_part.wxml"/>
  575 + </view>
  576 + </block>
  577 +
  578 +
  579 + </view>
  580 + </view>
  581 + <!-- 最底下确定层-->
  582 + <view class="determine-frame">
  583 + <view class="xc-confirm flex-center" bindtap="confirm_quan"> 确定</view>
  584 + </view>
  585 + </view>
689 586 </view>
  587 +
690 588 <!----弹起选择物流名的列表---->
691 589 <view wx:if='{{open_express==1}}'>
692   - <view class="cover-layer flex-center " bindtap='close_express'>
693   - </view>
694   -
695   - <view class="cx-popup radius {{open_express==1?'up' : 'down'}}">
696   - <view class="tops flex">
697   - <view class="top-content fs32">
698   - <view>选择物流名字</view>
699   - </view>
700   - <view class="close-frame" bindtap='close_express'>
701   - <view class="xc-close-express">×</view>
702   - </view>
703   - </view>
704   - <view class="express_list">
705   - <view wx:for="{{wu_arr}}" wx:for-item="express_list" wx:for-index="idx">
706   - <view class="express_list_frame" bindtap="click_express_name" data-shippingcode="{{express_list.shipping_code}}"
707   - data-name="{{express_list.name}}" data-idxe="{{idx}}">
708   -
709   - <block wx:if="{{is_express==idx}}">
710   - <view class="circle white xc-hook fs20 red-b"><text>Γ</text></view>
711   - </block>
712   - <block wx:else>
713   - <view class="circle xc-hooks"></view>
714   - </block>
715   - <view class="fs30">{{express_list.name}}</view>
716   -
717   - </view>
718   - </view>
719   - </view>
720   - <view class="flex click-buttem">
721   - <view class="xc-determine flex-center" bindtap="determine_expres">
722   - <view class="flex-vertical t-c">确定</view>
723   - </view>
724   - <view class="xc-confirms flex-center" bindtap="select_default_logistics">
725   - <view class="flex-vertical t-c">设为默认</view>
726   - </view>
727   - </view>
728   -
729   - </view>
  590 + <view class="cover-layer flex-center " bindtap='close_express'>
  591 + </view>
  592 +
  593 + <view class="cx-popup radius {{open_express==1?'up' : 'down'}}">
  594 + <view class="tops flex">
  595 + <view class="top-content fs32">
  596 + <view>选择物流名字</view>
  597 + </view>
  598 + <view class="close-frame" bindtap='close_express'>
  599 + <view class="xc-close-express">×</view>
  600 + </view>
  601 + </view>
  602 + <view class="express_list">
  603 + <view wx:for="{{wu_arr}}" wx:for-item="express_list" wx:for-index="idx">
  604 + <view class="express_list_frame" bindtap="click_express_name"
  605 + data-shippingcode="{{express_list.shipping_code}}"
  606 + data-name="{{express_list.name}}" data-idxe="{{idx}}">
  607 +
  608 + <block wx:if="{{is_express==idx}}">
  609 + <view class="circle white xc-hook fs20 red-b">
  610 + <text>Γ</text>
  611 + </view>
  612 + </block>
  613 + <block wx:else>
  614 + <view class="circle xc-hooks"></view>
  615 + </block>
  616 + <view class="fs30">{{express_list.name}}</view>
  617 +
  618 + </view>
  619 + </view>
  620 + </view>
  621 + <view class="flex click-buttem">
  622 + <view class="xc-determine flex-center" bindtap="determine_expres">
  623 + <view class="flex-vertical t-c">确定</view>
  624 + </view>
  625 + <view class="xc-confirms flex-center" bindtap="select_default_logistics">
  626 + <view class="flex-vertical t-c">设为默认</view>
  627 + </view>
  628 + </view>
  629 +
  630 + </view>
730 631 </view>
731 632 <warn id="warn"></warn>
732   -<!-- 是不是使用店铺优惠pop -->
733   -<view class="cover-layer flex ai-center" bindtap="close_offline" wx:if="{{is_offline_show}}">
734   - <view style="background-color: #fff; width: 540rpx; margin: 0 auto; border-radius: 20rpx;">
735   - <view class="fs32" style="text-align: center;height: 80rpx; line-height: 80rpx;">店铺优惠</view>
736   - <view class="flex jc_sb ai-center fs28" style="height: 80rpx; width: 400rpx; margin-left: 70rpx;">
737   - <view catchtap="sure_offline" class="flex ai-center" >优惠¥{{show_off_price}}
738   - <icon style="margin-left: 10rpx;" color="{{is_get_offline?'red':'gray'}}" size="14" type="success" role="img"></icon></view>
739   - <view catchtap="cancle_offline" class="flex ai-center" >不用优惠
740   - <icon style="margin-left: 10rpx;" color="{{is_get_offline!=1?'red':'gray'}}" size="14" type="success" role="img"></icon> </view>
741   - </view>
742   - </view>
743   -</view>
  633 +
744 634  
745 635 <!-- 客服 -->
746 636 <view class="kefu-container shadow-1">
747   - <text class="iconfont icon-kefu fs60 co-red"></text>
  637 + <block wx:if="{{sys_switch.weapp_customertype}}">
  638 + <button wx:if="{{sys_switch.weapp_customertype}}" class="kefu-btn"
  639 + open-type="contact"
  640 + session-from="wechat|{{userInfo.user_id}}|{{userInfo.nickname}}|{{userInfo.head_pic}}">
  641 + <text class="iconfont icon-kefu fs60 co-red"></text>
  642 + </button>
  643 + </block>
  644 + <block wx:else>
  645 + <text class="iconfont icon-kefu fs60 co-red"></text>
  646 + </block>
748 647 </view>
  648 +
  649 +<!--支付的方式选择,0微信支付 1余额支付-->
  650 +<block wx:if="{{show_pay_type}}">
  651 + <view class="cover-layer" bindtap="close_show_pay"></view>
  652 + <view class="pay_type_view">
  653 + <view class="title">请选择支付方式</view>
  654 + <view class="anniu_view">
  655 + <view bindtap="set_pay_type" data-type="0">微信支付</view>
  656 + <view bindtap="set_pay_type" data-type="1">余额支付</view>
  657 + </view>
  658 + </view>
  659 +</block>
... ...
packageC/pages/presell/cart/cart.wxss
... ... @@ -42,13 +42,17 @@ page {
42 42  
43 43 .tab-wrapper {
44 44 background-color: #ccc;
45   - display: flex;
46   - border-radius: 40rpx;
47   - overflow: hidden;
  45 + display: flex;
  46 + border-radius: 40rpx;
  47 + overflow: hidden;
  48 + width: auto;
  49 + margin-top: 20rpx;
  50 + align-self: baseline;
  51 + font-size: 30rpx;
48 52 }
49 53  
50 54 .tab {
51   - padding: 20rpx 30rpx;
  55 + padding: 15rpx 25rpx;
52 56  
53 57 }
54 58  
... ... @@ -66,7 +70,7 @@ page {
66 70 color: #444;
67 71 /* margin-top: 28rpx; */
68 72 border-radius: 14rpx;
69   - padding: 20rpx 70rpx 20rpx 20rpx;
  73 + padding: 20rpx;
70 74 }
71 75 .user-contact {
72 76 /* padding: 24rpx 26rpx;
... ... @@ -320,6 +324,10 @@ margin:auto; */
320 324 margin-right: 0;
321 325 }
322 326  
  327 +.tips-btn.gray{
  328 +background-color:#e5e5e5;color: #666;
  329 +}
  330 +
323 331 .pay-amount {
324 332 /* float: right;
325 333 display: flex;
... ... @@ -996,12 +1004,22 @@ margin-left: 20rpx;
996 1004 }
997 1005  
998 1006  
  1007 +
  1008 +.circle1 {
  1009 + display: block;
  1010 + width: 10rpx;
  1011 + height: 10rpx;
  1012 + border-radius: 50%;
  1013 + margin: 0 auto;
  1014 + background-color: #ccc;
  1015 +}
  1016 +
  1017 +
999 1018 .circle {
1000 1019 display: block;
1001 1020 width: 10rpx;
1002 1021 height: 10rpx;
1003 1022 border-radius: 50%;
1004   - background-color: #ccc;
1005 1023 margin: 0 auto;
1006 1024 }
1007 1025  
... ... @@ -1056,7 +1074,42 @@ margin-left: 20rpx;
1056 1074 box-shadow: 0 4rpx 12px #e7e9eb;
1057 1075 }
1058 1076  
1059   -/* .icon-kefu {
1060   - font-size: 40rpx;
  1077 +.kefu-btn{
  1078 + width: 100%;
  1079 + height: 100%;
  1080 + text-align: center;
  1081 + line-height: 100rpx;
  1082 + border: none;
  1083 + background: none;
  1084 + border-radius: 50rpx;
  1085 +}
  1086 +
  1087 +.pay_type_view{width: 500rpx;height: 220rpx; position: fixed; background: #fff;z-index: 12;
  1088 + left: 50%; margin-left: -250rpx; top: 50%; margin-top: -110rpx; text-align: center; border-radius: 12rpx;}
  1089 +.pay_type_view .title{ height:100rpx; line-height: 100rpx; border-bottom: 1rpx solid #ededed;}
  1090 +.anniu_view{display: flex;height: 120rpx; line-height: 120rpx;}
  1091 +.anniu_view>view{width: 50%; border-right:1rpx solid #ededed;}
  1092 +
  1093 +.gray{color:#aaa}
  1094 +.note_text{
  1095 + width: 300rpx;margin-left: 20rpx;height: 52rpx; line-height: 52rpx; display: inline-block
1061 1096 }
1062   - */
  1097 +
  1098 +
  1099 +
  1100 +.tips-btn2 {
  1101 + display: inline-block;
  1102 + width: 140rpx;
  1103 + height: 60rpx;
  1104 + line-height: 60rpx;
  1105 + text-align: center;
  1106 + font-size: 30rpx;
  1107 + color: #fff;
  1108 + background-color: #f23030;
  1109 + /* margin-left: 2rpx; */
  1110 + margin-right: 12rpx;
  1111 + border-radius: 10rpx;
  1112 +
  1113 +}
  1114 +
  1115 +
... ...
packageC/pages/presell/cart/cart2_pre.js
... ... @@ -52,7 +52,7 @@ Page({
52 52 isclose:1,
53 53 is_express:0,//选择物流的控制器
54 54 yuer:0,
55   -
  55 + agree_no_ref:0
56 56 },
57 57 onLoad: function(t) {
58 58 var th = this; this.setData({ is_b_now: 1});
... ... @@ -241,7 +241,6 @@ Page({
241 241 }
242 242 }
243 243  
244   -
245 244 //先获取是否有关闭使用优惠券
246 245 getApp().getConfig2(function (ee) {
247 246 var json_d = JSON.parse(ee.switch_list);
... ... @@ -398,8 +397,9 @@ Page({
398 397 });
399 398 });
400 399 },
401   - //--------------------提交订单-----------------------
402   - submitForm: async function(t){
  400 +
  401 + // -- 支付的下一步 --
  402 + submitForm_next:async function(t){
403 403 if(this.data.is_summit_ing==1) return false; //--提交中退出--
404 404 this.data.is_summit_ing=1;
405 405  
... ... @@ -409,217 +409,230 @@ Page({
409 409  
410 410 //如果不是阶梯团,或者是普通购买,商家选择了物流,以及地址为空的时候
411 411 if(th.data.bn_exp_type == 0 && th.data.user_addr==null && (th.data.kt_type!=3 || th.data.bn_goods.is_normal==1) ){
412   - ff = false;
413   - getApp().my_warnning("请选择收货地址",0,this);
414   - this.data.is_summit_ing = 0;
  412 + ff = false;
  413 + getApp().my_warnning("请选择收货地址",0,this);
  414 + this.data.is_summit_ing = 0;
415 415 }
416 416 if (!ff) return false;
417 417 var addr = th.data.user_addr;
418 418 if (th.data.bn_exp_type == 1) addr=null;
419 419  
420 420 if(th.data.bn_exp_type==0 && (th.data.kt_type!=3)) {
421   - if (th.data.wu_arr == null || th.data.wu_arr.length <= 0) {
422   - getApp().my_warnning("读取物流失败",0,this);
423   - this.data.is_summit_ing = 0;
424   - return false;
425   - }
  421 + if (th.data.wu_arr == null || th.data.wu_arr.length <= 0) {
  422 + getApp().my_warnning("读取物流失败",0,this);
  423 + this.data.is_summit_ing = 0;
  424 + return false;
  425 + }
426 426 }
427   -
428   - //阶梯团强制带1,自提~~~
429   - if(th.data.kt_type==3 ){
430   - th.data.bn_exp_type=1;
431   - }
432   -
  427 +
  428 + //阶梯团强制带1,自提~~~
  429 + if(th.data.kt_type==3 ){
  430 + th.data.bn_exp_type=1;
  431 + }
  432 +
433 433 var item={
434   - 'user_id':app.globalData.user_id,
435   - 'consignee': addr == null ? "" : addr.consignee,
436   - 'province': addr == null ? 0 : addr.province,
437   - 'city': addr == null ? 0 : addr.city,
438   - 'district': addr == null ? 0 : addr.district,
439   - 'twon': addr == null ? 0 : addr.twon,
440   - 'address': addr == null ? "": addr.address,
441   - 'more_address': addr == null ? "" : addr.more_address,
442   - 'mobile': addr == null ? th.data.userinfo.mobile:addr.mobile,
443   - 'email':'',
444   - 'invoice_title':'',
445   - 'goods_price': th.data.formData.all_price, //商品总价
446   - 'shipping_price': th.data.formData.shipping_price, //物流金额
447   - 'user_money': th.data.formData.user_money, //使用余额
448   - 'total_amount': th.data.formData.total_amount, //订单总价
449   - 'order_amount': th.data.formData.order_amount, //应付
450   - 'user_note': t.detail.value.user_note, //用户备注
451   - 'store_id':os.stoid, //商家
452   - 'pickup_id': th.data.bn_pick, //门店
453   - 'prom_type':th.data.bn_goods.prom_type, //促销活动类型
454   - 'prom_id': th.data.bn_goods.prom_id, //促销活动id
455   - 'order_goods':new Array(),
456   - };
457   -
458   - //老会员成为分销下线需要的参数
459   - if(getApp().globalData.first_leader && !getApp().globalData.userInfo.first_leader){
460   - //判断一下分享人是不是分享商
461   - await app.request.promiseGet("/api/weshop/users/get/" + os.stoid+"/"+getApp().globalData.first_leader,{}).then(res=>{
462   - if(res.data.code==0){
463   - var user= res.data.data;
464   - if(user.is_distribut==1){
465   - item.first_leader=parseInt(getApp().globalData.first_leader);
466   - }
467   - }
468   - })
469   - }
470   -
471   - if(th.data.qh!='')
472   - {
473   - item.team_qh=th.data.qh;
474   - item.pt_listno=th.data.qh;
475   - }
476   -
477   - var gg =app.get_b_now();
478   - var goods={
479   - 'goods_id': gg.goods_id,
480   - 'goods_name': gg.goods_name,
481   - 'goods_sn': gg.goods_sn,
482   - 'goods_num': gg.goods_num,
483   - 'market_price': th.data.bn_goods.market_price,
484   - 'goods_price': th.data.bn_goods.shop_price,
485   - 'member_goods_price': th.data.bn_goods.shop_price,
486   - 'store_id': os.stoid,
487   - 'prom_type':th.data.bn_goods.prom_type, //促销活动类型
488   - 'prom_id': th.data.bn_goods.prom_id, //促销活动id
489   - };
490   -
491   - //--导购分享过来的id--
492   - if(gg.guide_id){
  434 + 'user_id':app.globalData.user_id,
  435 + 'consignee': addr == null ? "" : addr.consignee,
  436 + 'province': addr == null ? 0 : addr.province,
  437 + 'city': addr == null ? 0 : addr.city,
  438 + 'district': addr == null ? 0 : addr.district,
  439 + 'twon': addr == null ? 0 : addr.twon,
  440 + 'address': addr == null ? "": addr.address,
  441 + 'more_address': addr == null ? "" : addr.more_address,
  442 + 'mobile': addr == null ? th.data.userinfo.mobile:addr.mobile,
  443 + 'email':'',
  444 + 'invoice_title':'',
  445 + 'goods_price': th.data.formData.all_price, //商品总价
  446 + 'shipping_price': th.data.formData.shipping_price, //物流金额
  447 + 'user_money': th.data.formData.user_money, //使用余额
  448 + 'total_amount': th.data.formData.total_amount, //订单总价
  449 + 'order_amount': th.data.formData.order_amount, //应付
  450 + 'user_note': t.detail.value.user_note, //用户备注
  451 + 'store_id':os.stoid, //商家
  452 + 'pickup_id': th.data.bn_pick, //门店
  453 + 'prom_type':th.data.bn_goods.prom_type, //促销活动类型
  454 + 'prom_id': th.data.bn_goods.prom_id, //促销活动id
  455 + 'order_goods':new Array(),
  456 + };
  457 +
  458 + //老会员成为分销下线需要的参数
  459 + if(getApp().globalData.first_leader && !getApp().globalData.userInfo.first_leader){
  460 + //判断一下分享人是不是分享商
  461 + await app.request.promiseGet("/api/weshop/users/get/" + os.stoid+"/"+getApp().globalData.first_leader,{}).then(res=>{
  462 + if(res.data.code==0){
  463 + var user= res.data.data;
  464 + if(user.is_distribut==1){
  465 + item.first_leader=parseInt(getApp().globalData.first_leader);
  466 + }
  467 + }
  468 + })
  469 + }
  470 +
  471 + if(th.data.qh!='')
  472 + {
  473 + item.team_qh=th.data.qh;
  474 + item.pt_listno=th.data.qh;
  475 + }
  476 +
  477 + var gg =app.get_b_now();
  478 + var goods={
  479 + 'goods_id': gg.goods_id,
  480 + 'goods_name': gg.goods_name,
  481 + 'goods_sn': gg.goods_sn,
  482 + 'goods_num': gg.goods_num,
  483 + 'market_price': th.data.bn_goods.market_price,
  484 + 'goods_price': th.data.bn_goods.shop_price,
  485 + 'member_goods_price': th.data.bn_goods.shop_price,
  486 + 'store_id': os.stoid,
  487 + 'prom_type':th.data.bn_goods.prom_type, //促销活动类型
  488 + 'prom_id': th.data.bn_goods.prom_id, //促销活动id
  489 + };
  490 +
  491 + //--导购分享过来的id--
  492 + if(gg.guide_id){
493 493 goods.guide_id=gg.guide_id;
494 494 goods.guide_type=gg.guide_type;
495 495 //调用接口判断是不是会员
496 496 await getApp().request.promiseGet("/api/weshop/shoppingGuide/getId/"+os.stoid+"/"+gg.guide_id,{}).then(res=>{
497   - if(res.data.code==0){
498   - goods.guide_name=res.data.data.salesman;
499   - goods.guide_sn=res.data.data.salesman_no;
500   - }
501   - })
502   - }
  497 + if(res.data.code==0){
  498 + goods.guide_name=res.data.data.salesman;
  499 + goods.guide_sn=res.data.data.salesman_no;
  500 + }
  501 + })
  502 + }
503 503  
504 504 //--商品的房间号--
505 505 if(gg.room_id && gg.room_id>0){
506 506 item.room_ids=gg.room_id;
507 507 goods.room_id=gg.room_id;
508 508 }
509   -
510   - if(th.data.bn_goods.is_normal){goods.is_pd_normal=1;}
511   -
512   - item.order_goods.push(goods);
513   - pdata.push(item);
514   -
515   - if (pdata.length==0) return;
516   - var str = JSON.stringify(pdata);
517   - wx.showLoading({title: "加载中"});
518   - wx.request({
519   - url: os.url + '/api/weshop/order/createWxdOrder',
520   - data: str,
521   - method: 'POST',
522   - header: {
523   - 'content-type': 'application/json'
524   - },// 设置请求的 header
525   - success: function (res) {
526   -
527   - wx.hideLoading();
528   - if (res.statusCode == 200) {
529   - var data=res.data;
530   - if(data.code==0){
531   - console.log(th.data.is_b_now);
532   - //如果是购物车结算,还要删除购物车
533   - if (th.data.is_b_now == 0) {
534   - console.log(th.data.cartlist_y);
535   - var list = th.data.cartlist_y;
536   - for (var i = 0; i < list.length; i++) {
537   - //删除购物车
538   - getApp().request.delete("/api/weshop/cart/del/" + os.stoid + "/" + list[i].id, {});
539   - }
540   - }
541   - var order_amount = 0;
542   - pdata.forEach(function (em, ind) {
543   - order_amount += em.order_amount;
544   - })
545   - //要进行判断,如果是用微信支付,就要跳转到支付界面
546   - if (order_amount > 0) {
547   - th.setData({ isclose: 0 });
548   - //void e.jumpToCart4({
549   - // order_sn: data.data,
550   - // type:1,
551   - // }, 1);
552   - util_pay.pay(data.data, function() {
553   - setTimeout(function () {
554   - wx.reLaunch({
555   - //url: "/pages/payment/pay_success/pay_success?type=1&order_sn="+data.data,
556   - url: "/pages/team/team_success/team_success?ordersn=" + data.data,
557   - })
558   - },1000)
559   - }, function () {
560   - //支付失败
561   - setTimeout(function () {
562   - //wx.navigateBack({ delta: 1 })
563   - wx.reLaunch({
564   - url: "/pages/user/order_list/order_list",
565   - })
566   - },1000)
567   -
568   - },os.stoid,1);
569 509  
570   - } else {
571   - var dd = {
572   - parent_sn: data.data,
573   - store_id: os.stoid,
574   - type: 1,
575   - };
576   - //return false;
577   - getApp().request.post("/api/weshop/order/pay/createOrder", {
578   - data: dd,
579   - success: function (t) {
580   - console.log(t);
581   - app.my_warnning("支付成功",1,th);
582   - setTimeout(function () {
583   - th.setData({ isclose: 0 });
584   -
585   - if(th.data.is_normal==1){
586   - /*--
587   - wx.navigateTo({
588   - url: "/pages/user/order_list/order_list",
589   - })--*/
590   - var url="/pages/payment/pay_success/pay_success?type=1&order_sn="+data.data;
591   - wx.reLaunch({
592   - url: url
593   - })
594   -
595   - }else{
596   - wx.reLaunch({
597   - url: "/pages/team/team_success/team_success?ordersn=" + data.data,
598   - })
  510 + if(th.data.bn_goods.is_normal){goods.is_pd_normal=1;}
  511 +
  512 + item.order_goods.push(goods);
  513 + pdata.push(item);
  514 +
  515 + if (pdata.length==0) return;
  516 + var str = JSON.stringify(pdata);
  517 + wx.showLoading({title: "加载中"});
  518 + wx.request({
  519 + url: os.url + '/api/weshop/order/createWxdOrder',
  520 + data: str,
  521 + method: 'POST',
  522 + header: {
  523 + 'content-type': 'application/json'
  524 + },// 设置请求的 header
  525 + success: function (res) {
  526 +
  527 + wx.hideLoading();
  528 + if (res.statusCode == 200) {
  529 + var data=res.data;
  530 + if(data.code==0){
  531 + console.log(th.data.is_b_now);
  532 + //如果是购物车结算,还要删除购物车
  533 + if (th.data.is_b_now == 0) {
  534 + console.log(th.data.cartlist_y);
  535 + var list = th.data.cartlist_y;
  536 + for (var i = 0; i < list.length; i++) {
  537 + //删除购物车
  538 + getApp().request.delete("/api/weshop/cart/del/" + os.stoid + "/" + list[i].id, {});
  539 + }
  540 + }
  541 + var order_amount = 0;
  542 + pdata.forEach(function (em, ind) {
  543 + order_amount += em.order_amount;
  544 + })
  545 + //要进行判断,如果是用微信支付,就要跳转到支付界面
  546 + if (order_amount > 0) {
  547 + th.setData({ isclose: 0 });
  548 + util_pay.pay(data.data, function() {
  549 + var url="/packageC/pages/presell/cart/cart?order_sn="+data.data;
  550 + setTimeout(function () {
  551 + wx.reLaunch({ url: url,})
  552 + },1000)
  553 + }, function () {
  554 + //支付失败
  555 + setTimeout(function () {
  556 + //wx.navigateBack({ delta: 1 })
  557 + wx.reLaunch({
  558 + url: "/pages/user/order_list/order_list",
  559 + })
  560 + },1000)
  561 +
  562 + },os.stoid,1);
  563 +
  564 + } else {
  565 + var dd = {
  566 + parent_sn: data.data,
  567 + store_id: os.stoid,
  568 + type: 1,
  569 + };
  570 + //return false;
  571 + getApp().request.post("/api/weshop/order/pay/createOrder", {
  572 + data: dd,
  573 + success: function (t) {
  574 + console.log(t);
  575 + app.my_warnning("支付成功",1,th);
  576 + setTimeout(function () {
  577 + th.setData({ isclose: 0 });
  578 +
  579 +
  580 + var url="/packageC/pages/presell/cart/cart?order_sn="+data.data;
  581 + wx.reLaunch({
  582 + url: url
  583 + })
  584 +
  585 +
  586 +
  587 + }, 1000)
  588 + }
  589 + });
599 590 }
600   -
601   - }, 1000)
602 591 }
603   - });
  592 + else{
  593 + th.data.is_summit_ing=0; //是否提交中
  594 + getApp().confirmBox(data.msg);
  595 + }
  596 + } else {
  597 + th.data.is_summit_ing=0; //是否提交中
  598 + console.log("index.js wx.request CheckCallUser statusCode" + res.statusCode);
604 599 }
605   - }
606   - else{
607   - th.data.is_summit_ing=0; //是否提交中
608   - getApp().confirmBox(data.msg);
609   - }
610   - } else {
611   - th.data.is_summit_ing=0; //是否提交中
612   - console.log("index.js wx.request CheckCallUser statusCode" + res.statusCode);
613   - }
614   - },
615   - fail: function () {
616   - th.data.is_summit_ing=0; //是否提交中
617   - wx.hideLoading();
618   - console.log("index.js wx.request CheckCallUser fail");
619   - },
620   - complete: function () {}
621   - })
  600 + },
  601 + fail: function () {
  602 + th.data.is_summit_ing=0; //是否提交中
  603 + wx.hideLoading();
  604 + console.log("index.js wx.request CheckCallUser fail");
  605 + },
  606 + complete: function () {}
  607 + })
622 608 },
  609 +
  610 +
  611 + //--------------------提交订单-----------------------
  612 + submitForm: function(t){
  613 + var th=this;
  614 + //如果商家不同意退定义
  615 + if(!this.data.act.is_refundmoney && !th.agree_no_ref){
  616 + wx.showModal({
  617 + content: ' 预售商品不允许退定金!是否继续下单?',
  618 + showCancel: true,//是否显示取消按钮
  619 + cancelText:"我在想想",//默认是“取消”
  620 + confirmText:"继续下单",//默认是“确定”
  621 + success: function (res) {
  622 + if (res.cancel) {
  623 + //点击取消,默认隐藏弹框
  624 + } else {
  625 + th.setData({agree_no_ref:1})
  626 + th.submitForm_next(t)
  627 + }
  628 + },
  629 + })
  630 +
  631 + }else{
  632 + this.submitForm_next(t);
  633 + }
  634 + },
  635 +
623 636 useCoupon: function() {
624 637 if (this.data.order.couponNum <= 0) {
625 638 //return t.showWarning("无可用优惠券");
... ... @@ -828,5 +841,11 @@ Page({
828 841 buycard:function(){
829 842 getApp().goto("/pages/user/plus/plus");
830 843 getApp().globalData.plus_buy_back=1;
831   - }
  844 + },
  845 +
  846 + switchChange:function (e) {
  847 + console.log(e,111);
  848 + this.setData({agree_no_ref:e.detail.value});
  849 + }
  850 +
832 851 });
... ...
packageC/pages/presell/cart/cart2_pre.wxml
1   -<wxs module="filters" src="../../../utils/filter.wxs"></wxs>
  1 +<wxs module="filters" src="../../../../utils/filter.wxs"></wxs>
2 2 <form bindsubmit="submitForm">
3 3 <view class="container">
4 4 <view class="tab-container" wx:if="{{act.presell_type==1}}">
... ... @@ -99,7 +99,6 @@
99 99 </view>
100 100 </view>
101 101 </block>
102   -
103 102 <!--阶梯团是不显示的
104 103 <block wx:if="{{kt_type!=3 || is_normal==1 }}">
105 104 <view class="use-item" hidden='{{bn_exp_type==1}}'>
... ... @@ -109,7 +108,6 @@
109 108 </picker>
110 109 </view>
111 110 </block>-->
112   -
113 111 </view>
114 112  
115 113  
... ... @@ -122,6 +120,14 @@
122 120 </view>
123 121 </block>
124 122  
  123 + <!-- 不下单的时候退款定金 -->
  124 + <view class="information bdr14" style="margin-bottom: 20rpx" wx:if="{{!act.is_refundmoney}}">
  125 + <view class="item ai-center">
  126 + <view>我同意预售商品不退定金</view>
  127 + <switch style="transform: scale(0.7);position: relative; right: -24rpx" type="switch" checked="{{agree_no_ref?true:false}}" bindchange="switchChange"/>
  128 + </view>
  129 + </view>
  130 +
125 131 <view class="information bdr14">
126 132 <!-----使用余额------>
127 133 <view class="set-mes" wx:if="{{userinfo.user_money>0 && yuer>0}}">
... ...
packageC/pages/presell/cart/cart2_pre.wxss
... ... @@ -245,8 +245,8 @@ margin:auto; */
245 245 .information .item {
246 246 display: flex;
247 247 justify-content: space-between;
248   - height: 60rpx;
249   - line-height: 60rpx;
  248 + height: 80rpx;
  249 + line-height: 80rpx;
250 250 font-size: 26rpx;
251 251 color: #777;
252 252 }
... ...
packageC/pages/presell/cart/zh_calculate.js deleted
1   -var regeneratorRuntime = require('../../../../utils/runtime.js');
2   -module.exports = {
3   - //主要的作用,就是把组合购多余的商品进行拆分,
4   - //如果没有达成组合购的要求,所有的商品都打回原价购买
5   - fir_set_arr: function (c_item) {
6   - //组合活动,以及组合活动从表的商品
7   - let zh_prom_goods = c_item.zh_prom_goods;
8   - let goods = c_item.goods; //一个门店中所有的商品
9   - let tfeel = 0,cut_price=0, offline_price = 0, offline_num = 0;
10   - let txt_ite = c_item.need_list;
11   - //多个活动要拿来循环一下
12   - for (let i in zh_prom_goods) {
13   - let title = ""; //提示语;
14   - //其中的一个活动
15   - let act_item = zh_prom_goods[i];
16   - let act_goos = act_item.gdlist;
17   - let act = act_item.act;
18   -
19   - let all_num = 0; //商品数量之和
20   - let all_price0 = 0; //商品数量之和
21   - let aprice=0; //达到活动条件的购买价格
22   - let need_to_buy = 0;
23   - let all_zhqty = 0; //所有商品要求起购数之和
24   - let no_in_arr = []; //剩余的未加入组合购
25   - let out_arr=[]; //超出活动限购的商品放入
26   -
27   - //-- 寻找一下 --
28   - function get_num2(ite) {
29   - for (let v2 in goods) {
30   - var vh = goods[v2];
31   - if (vh.goods_id == ite.goods_id) {
32   - return vh;
33   - }
34   - }
35   - return 0;
36   - }
37   -
38   - for (let j in act_goos) {
39   - let item = act_goos[j];
40   - let item_j = goods.find(function (ele) {
41   - return ele.goods_id == act_goos[j].goods_id;
42   - })
43   - //-- 如果有找到的话 --
44   - if (item_j) {
45   - act_goos[j].num = item_j.goods_num;
46   - act_goos[j].goods_price = item_j.goods_price;
47   - var cart_num=item.cart_num =item_j.goods_num;
48   - var zh_b_num=item_j.promgoodsbuynum;
49   - if(item.buyqty>0){
50   - var cbuy=item.buyqty-zh_b_num;
51   - //当可买的数量为0
52   - if(cbuy<=0){
53   - item.num=0;
54   - out_arr.push({
55   - price: item.goods_price,offline_price:item.offline_price,goods_id:item.goods_id,num:cart_num
56   - })
57   - }else{
58   - if(cbuy>=cart_num) item.num =cart_num;
59   - else{
60   - item.num =cbuy;
61   - out_arr.push({
62   - price: item.goods_price,offline_price:item.offline_price,goods_id:item.goods_id,num:cart_num-cbuy
63   - })
64   - }
65   - }
66   - }
67   -
68   - all_num += item.num;
69   - //当有起购数的控制的时候
70   - if (item.zhqty) {
71   - all_zhqty += item.zhqty;
72   - if (item.num < item.zhqty) {
73   - need_to_buy += item.zhqty - item.num;
74   - }
75   - if (item.num > item.zhqty) {
76   - for (let i = 0; i < item.num - item.zhqty; i++) {
77   - no_in_arr.push({
78   - price: item.goods_price, goods_id: item.goods_id, offline_price: item_j.offline_price
79   - })
80   - }
81   - }
82   - } else {
83   - for (let j = 0; j < item.num; j++) {
84   - no_in_arr.push({
85   - price: item.goods_price, goods_id: item.goods_id, offline_price: item_j.offline_price
86   - })
87   - }
88   - }
89   - } else {
90   - if (item.zhqty) {
91   - title = "必买商品未加购,下单立享【" + act.zhprice + "元任选" + act.zhbuyqty + "件】";
92   - need_to_buy += item.zhqty;
93   - }
94   - }
95   -
96   - }
97   -
98   - //当满足组合的要求:总数要满足,起购数要满足
99   - if (all_num >= act.zhbuyqty && !need_to_buy) {
100   - function sortData(a, b) {
101   - return a.price - b.price
102   - }
103   -
104   - if(no_in_arr.length>0) no_in_arr.sort(sortData);
105   -
106   - aprice = act.zhprice;
107   - if (act.zhbuyqty > all_zhqty) {
108   - for (let n = 0; n < act.zhbuyqty-all_zhqty; n++) {
109   - no_in_arr.pop();
110   - }
111   - }
112   - //看一下剩下的数量有没有满足组合购的要求,以及要不要倍增
113   - if (act.is_bz && no_in_arr.length >= act.zhbuyqty) {
114   - //看一下是几倍
115   - let be = parseInt(no_in_arr.length / act.zhbuyqty);
116   - aprice += be * act.zhprice;
117   - for (let m = 0; m < be * act.zhbuyqty; m++) {
118   - no_in_arr.pop();
119   - }
120   - }
121   -
122   -
123   - let goods_map = {};
124   - //算一下剩余的商品
125   - if(no_in_arr.length) {
126   - for (let ii in no_in_arr) {
127   - let item = no_in_arr[ii];
128   - if (item.offline_price) {
129   - offline_price += item.price - item.offline_price;
130   - offline_num += 1;
131   - }
132   - if (goods_map[item.goods_id]) {
133   - var num = goods_map[item.goods_id];
134   - goods_map[item.goods_id] = ++num;
135   - } else {
136   - goods_map[item.goods_id] = 1;
137   - }
138   - }
139   - }
140   -
141   - //超量的部分也要计算一下
142   - if(out_arr.length){
143   - for (var m in out_arr) {
144   - var item = out_arr[m];
145   - if (item.offline_price) {
146   - offline_price += (item.price - item.offline_price)*item.num;
147   - offline_num += item.num;
148   - }
149   - if (goods_map[item.goods_id]) {
150   - var num = goods_map[item.goods_id];
151   - num+=item.num
152   - goods_map[item.goods_id] =num;
153   - } else {
154   - goods_map[item.goods_id] = item.num;
155   - }
156   - }
157   - }
158   -
159   - if(Object.keys(goods_map).length) {
160   - //这里就开始拆分提交订单时的列表
161   - for (let j in goods_map) {
162   - //map中存的就是商品的数量
163   - let num = goods_map[j];
164   - //找到相应的商品
165   - let idx = goods.findIndex(function (ele) {
166   - return ele.goods_id == j;
167   - })
168   - goods[idx].goods_num -= num;
169   - let new_g = JSON.parse(JSON.stringify(goods[idx]));
170   - new_g.goods_num = num;
171   - new_g.prom_type = 0;
172   - new_g.prom_id = 0;
173   - goods.push(new_g);
174   - }
175   - }
176   -
177   -
178   - //-- 只统计是参与活动的商品 --
179   - for(var ij in goods){
180   - var iter=goods[ij];
181   - if(iter.prom_type!=7 || iter.prom_id!=act.id){ continue; }
182   - all_price0+=iter.goods_num*iter.goods_price;
183   - }
184   - //-- 活动的条件已经满足 --
185   - c_item.zh_prom_goods[act.id].is_has_zh = 1;
186   - c_item.is_has_zh = 1;
187   - c_item.zh_prom_goods[act.id].actual_price = aprice;
188   - c_item.zh_prom_goods[act.id].cut_price =all_price0-aprice;
189   -
190   - //-- 设置还需要购买多少件,享受活动,前段显示 --
191   - let need_to = c_item.need_list;
192   - let index = this.find_need_to(need_to, act);
193   - if (index > -1) {
194   - need_to.splice(index, 1);
195   - txt_ite = need_to
196   - }
197   -
198   -
199   - } else {
200   - for (let ii in goods) {
201   - let item = goods[ii];
202   - if (item.prom_type != 7) continue;
203   - if (item.prom_id != act.id) continue;
204   - if (item.offline_price) {
205   - offline_price += item.goods_price - item.offline_price;
206   - offline_num += 1;
207   - }
208   - item.prom_type = 0;
209   - item.prom_id = 0;
210   - }
211   - if (act.zhbuyqty - all_num > need_to_buy) {
212   - need_to_buy = act.zhbuyqty - all_num;
213   - }
214   - //-- 设置还需要购买多少件享受活动,前端显示 --
215   - let need_to = c_item.need_list;
216   - let index = this.find_need_to(need_to, act);
217   - if (title == '') title = "再买" + need_to_buy + "件,下单立享【" + act.zhprice + "元任选" + act.zhbuyqty + "件】";
218   - if (index != -1) {
219   - need_to[index].title = title;
220   - } else {
221   - if (!need_to) need_to = [];
222   - let it = {
223   - id: act.id,
224   - pickup_id: c_item.pickup_id,
225   - title: title
226   - };
227   - need_to.push(it);
228   - }
229   - txt_ite = need_to;
230   - }
231   - tfeel += aprice;
232   - cut_price+=all_price0-aprice;;
233   - }
234   -
235   - c_item.zh_all_price = tfeel;
236   - c_item.zh_cut_price = cut_price;
237   -
238   - if (c_item.is_offline == 1) {
239   - c_item.offline_price += offline_price;
240   - c_item.offline_num += offline_num;
241   - } else {
242   - c_item.is_offline == 1;
243   - c_item.offline_price = offline_price;
244   - c_item.offline_num = offline_num;
245   - }
246   -
247   - },
248   - //筛选组合购,纯粹的数组按活动id分组
249   - find_split: function (arr) {
250   - //过滤只有团购的商品
251   - let oarr = arr.goods.filter(function (ele) {
252   - return ele.prom_type == 7
253   - })
254   - if (!oarr || oarr.length == 0) return null;
255   - //看一下有多少个不同的团购
256   - let map = {},
257   - dest = [];
258   - for (let i = 0; i < oarr.length; i++) {
259   - let ai = oarr[i];
260   - let index = map[ai.prom_id]
261   - if (!index) {
262   - dest.push({
263   - prom_id: ai.prom_id,
264   - act: ai.act,
265   - data: [ai]
266   - });
267   - map[ai.prom_id] = dest.length; //存储下标
268   - } else {
269   - let dj = dest[index - 1];
270   - dj.data.push(ai);
271   - }
272   - }
273   - return dest;
274   - },
275   -
276   - find_need_to: function (list, iter) {
277   - if (!list || list.length <= 0) return -1;
278   - for (var i in list) {
279   - var item = list[i];
280   - if (item.id == iter.id) {
281   - return i;
282   - }
283   - }
284   - return -1;
285   - },
286   - //-- 平摊组合购的价格 --
287   - calc_zh_split_price: async function (c_arr, th) {
288   - //-- 循环处理 --
289   - for (var k in c_arr) {
290   - var cart_item = c_arr[k]; //就是每一单的意思
291   - var ord_goods = c_arr[k].goods; //就是每一单的从表的意思
292   -
293   - var zh_prom_goods = cart_item.zh_prom_goods; //一单中所有的组合购的集合
294   - var item_map = {};
295   - for (let i in zh_prom_goods) {
296   - let item = zh_prom_goods[i];
297   - let prom_id = i;
298   - //如果这个活动还没有达到要求,继续下一个计算
299   - if (!item.is_has_zh) continue;
300   - //过滤出相应组合购活动的商品
301   - let glist = ord_goods.filter(function (ele) {
302   - return ele.prom_type == 7 && ele.prom_id == i;
303   - })
304   - var all_good_price = 0;
305   - var post_gd=[];
306   - for (let j in glist) {
307   - let item = glist[j];
308   - all_good_price += item.goods_price * item.goods_num;
309   - var gitem={
310   - goods_id:item.goods_id,
311   - goods_num:item.goods_num,
312   - goods_price:item.goods_price
313   - }
314   - post_gd.push(gitem);
315   - }
316   - //要进行优惠的计算
317   - if (all_good_price - item.actual_price) {
318   - if (cart_item.prom_pt_json) {
319   - cart_item.prom_pt_json.push({
320   - "zhprom_id": prom_id,
321   - "dis": (all_good_price - item.actual_price).toFixed(2),
322   - "ispt": 0
323   - })
324   - } else {
325   - cart_item.prom_pt_json = [{
326   - "zhprom_id": prom_id,
327   - "dis": (all_good_price - item.actual_price).toFixed(2),
328   - "ispt": 0
329   - }];
330   - }
331   - }
332   -
333   - //-- 如果系统要平摊到单品 --
334   - var pt_data = {
335   - 'prom_id': prom_id,
336   - 'dis': parseFloat(all_good_price - item.actual_price).toFixed(2),
337   - 'goods': post_gd
338   - }
339   - var pt_res = null;
340   - await getApp().request.promisePost("/api/weshop/order/getGoodsSplit", {
341   - is_json: 1,
342   - data: pt_data
343   - }).then(res => {
344   - if (res.data.code == 0) {
345   - pt_res = res.data.data;
346   - }
347   - })
348   - if (pt_res) {
349   - for (var io in glist) {
350   - var goods_id = glist[io].goods_id;
351   - item_map[goods_id]={};
352   - //平摊赋值
353   - item_map[goods_id].account_fir = th.arr_get_goods(goods_id, pt_res).fisrt_account;
354   - item_map[goods_id].account_yu_fir = th.arr_get_goods(goods_id, pt_res).fisrt_account_yu;
355   - if (!th.data.ispt_goods) {
356   - item_map[goods_id].account = item_map[goods_id].account_fir;
357   - item_map[goods_id].account_yu = item_map[goods_id].account_yu_fir;
358   - }
359   - }
360   - }
361   - }
362   -
363   - //--------循环计算商品是不是包邮,是不是使用优惠券,此时循环是商品从表-----------
364   - for (var jj = 0; jj < ord_goods.length; jj++) {
365   - if (ord_goods[jj].is_gift) continue;
366   - if (ord_goods[jj].prom_type == 7 && item_map[ord_goods[jj].goods_id]) {
367   - ord_goods[jj].account_fir = item_map[ord_goods[jj].goods_id].account_fir;
368   - ord_goods[jj].account_yu_fir = item_map[ord_goods[jj].goods_id].account_yu_fir;
369   - ord_goods[jj].account = item_map[ord_goods[jj].goods_id].account;
370   - ord_goods[jj].account_yu = item_map[ord_goods[jj].goods_id].account_yu;
371   - }
372   - }
373   - }
374   -
375   -
376   - }
377   -
378   -
379   -}
packageC/pages/presell/goodsInfo/goodsInfo.js
... ... @@ -305,8 +305,9 @@ Page({
305 305 }
306 306 }
307 307  
308   - this.data.gid = gid;
309   - this.data.pre_id = pre_id;
  308 + this.setData({
  309 + gid:gid,pre_id:pre_id
  310 + })
310 311  
311 312 if (first_leader) {
312 313 console.log("log---".first_leader);
... ... @@ -659,6 +660,8 @@ Page({
659 660  
660 661 //-- 把商品的赋值 --
661 662 ee.data.fir_goods = JSON.parse(JSON.stringify(t.data.data));
  663 + ee.data.sele_g_id=t.data.data.goods_id;
  664 + ee.data.sele_g=t.data.data;
662 665  
663 666 //获取用户的默认门店
664 667 getApp().get_user_store(function (e) {
... ... @@ -1011,7 +1014,6 @@ Page({
1011 1014 }
1012 1015  
1013 1016 //让商品带上房间号
1014   - //让商品带上房间号
1015 1017 if (th.data.sys_switch.is_skuroom_id == 1) {
1016 1018 if (th.data.data.goods_id == getApp().globalData.room_goods_id) {
1017 1019 newd.room_id = getApp().globalData.room_id;
... ... @@ -1020,10 +1022,6 @@ Page({
1020 1022 if (newd.goods_id == getApp().globalData.room_goods_id) newd.room_id = getApp().globalData.room_id;
1021 1023 }
1022 1024  
1023   - //如果是积分够,is_integral_normal就要有积分购普通购买字段
1024   - if (o.prom_type == 4) {
1025   - newd.is_integral_normal = 1;
1026   - }
1027 1025  
1028 1026 //如果有线下取价
1029 1027 if (o.offline_price) {
... ... @@ -1033,7 +1031,7 @@ Page({
1033 1031  
1034 1032 newd.goods_price = th.data.prom_price;
1035 1033 newd.member_goods_price = th.data.prom_price,
1036   - newd.prom_type = 8;
  1034 + newd.prom_type = 8;
1037 1035 newd.prom_id = o.prom_id;
1038 1036  
1039 1037 if (o.store_count <= 0) return s.my_warnning("库存已为空!", 0, th);
... ... @@ -1164,20 +1162,6 @@ Page({
1164 1162 this.checkCartNum(Number(t.detail.value));
1165 1163 },
1166 1164  
1167   - //----------增加购买数量-----------
1168   - addCartNum_inte: function (t) {
1169   - this.checkCartNum_inte(this.data.goodsInputNum + 1);
1170   - },
1171   - //----------减少购买数量-----------
1172   - subCartNum_inte: function (t) {
1173   - this.checkCartNum_inte(this.data.goodsInputNum - 1);
1174   - },
1175   - //----------输入框输入购买数量-----------
1176   - inputCartNum_inte: function (t) {
1177   - this.checkCartNum_inte(Number(t.detail.value));
1178   - },
1179   -
1180   -
1181 1165 //------检查数量是不是超出限购------
1182 1166 checkCartNum: function (t) {
1183 1167 var th = this;
... ... @@ -1214,18 +1198,7 @@ Page({
1214 1198 }
1215 1199 }
1216 1200  
1217   -
1218   -
1219 1201 var e = th.data.sele_g.store_count;
1220   - var p_type = th.data.prom_type; //&& p_type!=1 && p_type!=4
1221   - if (th.data.sales_rules == 2 && (p_type != 1 && p_type != 4 && p_type != 6 || th.data.openSpecModal_inte_normal == 1 || th.data.is_normal == 1)) {
1222   - if (!th.data.def_pick_store) {
1223   - wx.showModal({ title: '请选择门店', });
1224   - return false;
1225   - } else {
1226   - e = th.data.def_pick_store.CanOutQty;
1227   - }
1228   - }
1229 1202 if (!e) e = 0;
1230 1203 //库存不足,不增加
1231 1204 if (e < t) {
... ... @@ -1235,90 +1208,11 @@ Page({
1235 1208 }
1236 1209 t > e || 0 == e ? t = e : t < 1 && (t = 1);
1237 1210 th.setData({ goodsInputNum: t });
1238   - th.is_show_more_buy();
1239   -
1240   - })
1241   - },
1242   -
1243   - //----- 检查一下积分购的限购之类的问题 -----
1244   - checkCartNum_inte: function (t) {
1245   - var th = this;
1246   - this.get_buy_num(this.data.data, async function () {
1247   -
1248   - //--判断商品是否超出限购--
1249   - if (th.data.g_buy_num != null && th.data.data.viplimited > 0) {
1250   -
1251   - var gd_buy_num = th.data.g_buy_num.get(th.data.sele_g.goods_id);
1252   -
1253   - if (t + gd_buy_num > th.data.sele_g.viplimited) {
1254   - wx.showModal({
1255   - title: '超出商品限购',
1256   - });
1257   -
1258   - var num = th.data.sele_g.viplimited - gd_buy_num;
1259   - if (num < 0) num = 0;
1260   - th.setData({ goodsInputNum: num })
1261   - return false;
1262   - }
1263   - }
  1211 + //th.is_show_more_buy();
1264 1212  
1265   - //--判断商品是否超出活动限购--
1266   - if (th.data.prom_buy_num != -1 && th.data.prom_buy_limit > 0) {
1267   - if (t + th.data.prom_buy_num > th.data.prom_buy_limit) {
1268   - wx.showModal({
1269   - title: '超出商品活动限购',
1270   - });
1271   -
1272   - var num = th.data.prom_buy_limit - th.data.prom_buy_num;
1273   - if (num < 0) num = 0;
1274   - th.setData({ goodsInputNum: num })
1275   - return false;
1276   - }
1277   - }
1278   -
1279   - if (th.data.sele_g.prom_type == 1 || th.data.sele_g.prom_type == 6) {
1280   - var redis_num = 0;
1281   - //------判断活动是否抢光-----
1282   - await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" +
1283   - os.stoid + "/" + th.data.sele_g.prom_type + "/" + th.data.sele_g.prom_id, {
1284   - 1: 1
1285   - }).then(res => {
1286   - redis_num = res.data.data;
1287   - });
1288   -
1289   - if (t > redis_num) {
1290   - wx.showModal({
1291   - title: '超出商品活动库存',
1292   - });
1293   - th.setData({ goodsInputNum: redis_num })
1294   - return false;
1295   - }
1296   -
1297   - }
1298   -
1299   - var e = th.data.sele_g.store_count;
1300   - var p_type = th.data.prom_type; //&& p_type!=1 && p_type!=4
1301   - if (th.data.sales_rules == 2 && (p_type != 1 && p_type != 4 && p_type != 6 || th.data.openSpecModal_inte_normal == 1 || th.data.is_normal == 1)) {
1302   - if (!th.data.def_pick_store) {
1303   - wx.showModal({ title: '请选择门店', });
1304   - return false;
1305   - } else {
1306   - e = th.data.def_pick_store.CanOutQty;
1307   - }
1308   - }
1309   - if (!e) e = 0;
1310   - //库存不足,不增加
1311   - if (e < t) {
1312   - wx.showModal({ title: '库存不足', });
1313   - if (e < 0) e = 0;
1314   - th.setData({ goodsInputNum: e }); return false;
1315   - }
1316   - t > e || 0 == e ? t = e : t < 1 && (t = 1);
1317   - th.setData({ goodsInputNum: t });
1318 1213 })
1319 1214 },
1320 1215  
1321   -
1322 1216 closeSpecModal: function () {
1323 1217 if (this.data.openSpecModal_pt && this.data.is_normal) {
1324 1218 this.get_sto();
... ... @@ -1852,59 +1746,32 @@ Page({
1852 1746  
1853 1747 //选择了不同的规格的时候要判断是不是有活动正在进行中
1854 1748 async sele_spec_chech_activity() {
1855   - //---如果是活动的时候---
1856   - var prom = null, goodsinfo = this.data.sele_g, th = this;
1857   - if (goodsinfo.prom_type == 1) {
1858   - await getApp().request.promiseGet("/api/ms/flash_sale/get/" + os.stoid + "/" + goodsinfo.prom_id, {
1859   - }).then(res => {
1860   - if (res.data.code == 0) {
1861   - prom = res.data.data;
1862   - }
1863   - })
1864   - }
1865   - if (goodsinfo.prom_type == 6) {
1866   - await getApp().request.promiseGet("/api/weshop/teamlist/get/" + os.stoid + "/" + goodsinfo.prom_id, {
1867   - }).then(res => {
1868   - if (res.data.code == 0) {
1869   - prom = res.data.data;
1870   - }
1871   - })
1872   - }
1873   -
1874   - if (goodsinfo.prom_type == 4) {
1875   - await getApp().request.promiseGet("/api/weshop/integralbuy/getActInfo/" + os.stoid + "/" + goodsinfo.goods_id + "/" + goodsinfo.prom_id, {
1876   - }).then(res => {
1877   - if (res.data.code == 0) {
1878   - prom = res.data.data;
1879   - }
1880   - })
1881   - }
1882   -
1883   - //----------如果有活动,并且在进行中,就不计算线下库存---------------
1884   - var now = ut.gettimestamp();
1885   - if (prom) {
1886   - if (prom.is_end == 0 && prom.end_time > now && prom.start_time < now) {
1887   - th.setData({
1888   - prom_type: goodsinfo.prom_type,
1889   - prom_price: prom.price,
1890   - prom_buy_limit: prom.buy_limit,
1891   - prom_end_time: prom.end_time,
1892   - prom_start_time: prom.start_time,
1893   - prom_st: 1,
1894   - })
1895   - return false;
  1749 + var prom = null, goodsinfo = this.data.sele_g, th = this;
  1750 +
  1751 + var all_pre_goods=th.data.all_pre_goods;
  1752 + if(all_pre_goods){
  1753 + var userInfo = getApp().globalData.userInfo;
  1754 + var pre_data = { store_id: os.stoid, is_end: 0, timetype: 1, isuse: 1, goods_id: th.data.gid };
  1755 + if (userInfo) {
  1756 + pre_data.user_id = userInfo.user_id;
  1757 + }
  1758 + await getApp().request.promiseGet("/api/weshop/marketing/marketingPresellList/page", {
  1759 + data: pre_data,
  1760 + }).then(e => {
  1761 + if (e.data.code == 0 && e.data.data.pageData && e.data.data.pageData.length > 0) {
  1762 + all_pre_goods=e.data.data.pageData;
  1763 + th.data.all_pre_goods=e.data.data.pageData;
  1764 + }
  1765 + })
1896 1766 }
1897   - }
1898   - //---设置普通商品---
1899   - th.setData({
1900   - prom_type: 0,
1901   - prom_price: null,
1902   - prom_buy_limit: null,
1903   - prom_end_time: null,
1904   - prom_start_time: null,
1905   - prom_st: null,
1906   - })
1907 1767  
  1768 +
  1769 + var idx=all_pre_goods.findIndex(function (ele) {
  1770 + return ele.goods_id==goodsinfo.goods_id;
  1771 + })
  1772 + var pre_arr =all_pre_goods[idx];
  1773 + th.setData({ pre_arr: pre_arr })
  1774 + th.data.prom_buy_limit=pre_arr.vip_butyqty;
1908 1775 },
1909 1776  
1910 1777  
... ... @@ -3987,54 +3854,6 @@ Page({
3987 3854 });
3988 3855 },
3989 3856  
3990   - is_show_more_buy: function () {
3991   - var prom_goods = this.data.prom_goods;
3992   - var per_price = this.data.sele_g.shop_price
3993   - if (this.data.card_field && this.data.sele_g[this.data.card_field] > 0) {
3994   - per_price = this.data.sele_g[this.data.card_field];
3995   - }
3996   - var all_price = per_price * this.data.goodsInputNum;
3997   - var con = null;
3998   - for (var i in prom_goods) {
3999   - var item = prom_goods[i];
4000   - if (item.prom_type == 1) {
4001   - if (item.condition > this.data.goodsInputNum) {
4002   - con = item;
4003   - con.need = (item.condition - this.data.goodsInputNum).toFixed(2) + "件";
4004   - break;
4005   - }
4006   - } else {
4007   - if (item.condition > all_price) {
4008   - con = item;
4009   - con.need = (item.condition - all_price).toFixed(2) + "元";
4010   - break;
4011   - }
4012   - }
4013   - }
4014   -
4015   - this.setData({ hui_condition: con });
4016   -
4017   - },
4018   -
4019   - closeSpecModal_inte: function () {
4020   - this.setData({ openSpecModal_inte: 0 });
4021   - },
4022   - closeSpecModal_inte_normal: function () {
4023   - this.setData({ openSpecModal_inte_normal: 0 });
4024   - //要进行还原
4025   - this.get_sto();
4026   - this.setData({
4027   - sele_g: this.data.data,
4028   - gid: this.data.data.goods_id
4029   - })
4030   -
4031   - this.sele_spec_chech_activity();
4032   - },
4033   -
4034   - addCart_inte: function (t) {
4035   - this.add_cart_func_inte(t);
4036   - },
4037   -
4038 3857  
4039 3858 onShareTimeline() {
4040 3859 var store_name = getApp().globalData.config ? getApp().globalData.config.store_name : '';
... ... @@ -4080,6 +3899,7 @@ Page({
4080 3899 })
4081 3900 },
4082 3901  
  3902 + //获取预售的信息
4083 3903 async get_pre_prom(func) {
4084 3904 var th = this;
4085 3905 var presell_id = null;
... ... @@ -4108,7 +3928,7 @@ Page({
4108 3928 }
4109 3929 })
4110 3930 var userInfo = getApp().globalData.userInfo;
4111   - var pre_data = { store_id: os.stoid, is_end: 0, timetype: 1, isuse: 1, goods_id: th.data.gid };
  3931 + var pre_data = { store_id: os.stoid, is_end: 0, timetype: 1, isuse: 1,prom_type:8,prom_id:presell_id };
4112 3932 if (userInfo) {
4113 3933 pre_data.user_id = userInfo.user_id;
4114 3934 }
... ... @@ -4116,8 +3936,17 @@ Page({
4116 3936 data: pre_data,
4117 3937 }).then(e => {
4118 3938 if (e.data.code == 0 && e.data.data.pageData && e.data.data.pageData.length > 0) {
4119   - pre_arr = e.data.data.pageData[0];
  3939 +
  3940 + th.data.all_pre_goods=e.data.data.pageData;
  3941 +
  3942 + var idx=e.data.data.pageData.findIndex(function (ele) {
  3943 + return ele.id== th.data.pre_id;
  3944 + })
  3945 + pre_arr = e.data.data.pageData[idx];
4120 3946 th.setData({ pre_arr: pre_arr })
  3947 + th.data.prom_buy_limit=pre_arr.vip_butyqty;
  3948 +
  3949 +
4121 3950 }
4122 3951 })
4123 3952 if (!pre_arr) {
... ...
packageC/pages/presell/goodsInfo/goodsInfo.wxml
... ... @@ -534,29 +534,15 @@
534 534 券后¥<text class="fs32">{{sele_g.offline_price}}</text>
535 535 </view>
536 536 </view>
537   - <block wx:if="{{prom_type==0}}">
538   - <view class="flex">
539   - <view class="spec-goods-stock">已售:{{sele_g.sales_sum}}</view>
540   - <block wx:if="{{sales_rules==2}}">
541   - <view class="spec-goods-stock" wx:if="{{def_pick_store && def_pick_store.CanOutQty}}">
542   - 可售:{{def_pick_store.CanOutQty}}
543   - </view>
544   - <view class="spec-goods-stock" wx:else>可售:0</view>
545   - </block>
546   - <block wx:else>
547   - <view class="spec-goods-stock">可售:{{sele_g.store_count}}</view>
548   - </block>
549   - </view>
550   - </block>
551   - <block wx:if="{{prom_type==1}}">
  537 +
552 538 <view class="flex">
553   - <view class="spec-goods-stock" wx:if="{{prom_st>0}}">
554   - 已售:{{prom_act.buy_num+prom_act.virtual}}
  539 + <view class="spec-goods-stock">
  540 + 已售:{{pre_arr.buy_goodnum+pre_arr.virtual_qty}}
555 541 </view>
556   - <view class="spec-goods-stock" wx:else>已售:{{prom_act.buy_num}}</view>
557   - <view class="spec-goods-stock">可售:{{prom_act.goods_num-prom_act.buy_num}}</view>
  542 + <view class="spec-goods-stock">可售:{{pre_arr.presell_sumqty-pre_arr.buy_goodnum}}</view>
558 543 </view>
559   - </block>
  544 +
  545 +
560 546 </view>
561 547 <!-- 选择门店模块 -->
562 548 <view class="flex-space-between address ai_end xc-width ">
... ... @@ -653,7 +639,7 @@
653 639 <block wx:else>
654 640 <view wx:if="{{openSpecModal_ind==2}}" bindtap="addCart"
655 641 data-openSpecModal_ind="{{openSpecModal_ind}}" class="spec-cart-btn spec-buy" data-action="buy">
656   - 支付定金(¥{{presellList.presell_money}})
  642 + 支付定金(¥{{pre_arr.presell_money}})
657 643 </view>
658 644 </block>
659 645  
... ...
pages/cart/cart/cart.js
... ... @@ -301,11 +301,12 @@ Page({
301 301 //如果秒杀活动都去掉了,或者结束了,那么这个商品也没有必要留着
302 302 if (item.prom_type == 1) {
303 303 var prom = null;
  304 + var now = ut.gettimestamp();
304 305 await getApp().request.promiseGet("/api/ms/flash_sale/get/" + os.stoid + "/" + item.prom_id, {}).then(res => {
305 306 if (res.data.code == 0) prom = res.data.data;
306 307 })
307   - //---如果有活动,不算在一起---
308   - if (!prom && prom.is_end == 0 && prom.end_time > now && prom.start_time < now) {
  308 + //---如果互动都已经过期,或者还未开始,或者无活动
  309 + if (!prom || prom.is_end == 1 || prom.end_time < now || prom.start_time > now) {
309 310 var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id;
310 311 a.delete(url, {
311 312 success: function (t) {
... ... @@ -513,9 +514,9 @@ Page({
513 514 }
514 515 }else{
515 516 //-- 此时要实时更新线下取价价格 --
516   - for(var i=0;i<arr.length;i++){
  517 + for(var ij in arr){
517 518 //每个门店都去看下线下取价
518   - var list=arr[i];
  519 + var list=arr[ij];
519 520 for(var i in list.goods){
520 521 list.goods[i].offline_price=0
521 522 }
... ...
pages/cart/cart_wk/cart_wk.js
... ... @@ -350,7 +350,6 @@ Page({
350 350 //--立即支付--
351 351 to_pay_type: function (ind) {
352 352 var th = this;
353   -
354 353 //--物流支付时要有地址--
355 354 if (th.data.exp_type == 0 && th.data.user_addr == null) {
356 355 return getApp().my_warnning("请选择收货地址", 0, th);
... ...
pages/cart/cart_wk/cart_wk.wxml
... ... @@ -46,7 +46,6 @@
46 46  
47 47 <!--商品图片显示-->
48 48 <view class='center'>
49   -
50 49 <view class='cen_img'>
51 50 <image src="{{order.show_img}}" binderror="bind_bnerr" data-errorimg="order.show_img"></image>
52 51 </view>
... ... @@ -61,22 +60,6 @@
61 60  
62 61 </view>
63 62  
64   -<!--取货方式-->
65   -
66   -<!-- <view class='quhou bdr_b-14'>
67   - <view bindtap="set_wuliu" data-type="1" class='qu_fs' wx:if="{{distr_type==0 || distr_type==1}}">
68   - <image wx:if="{{exp_type==0}}" src='{{imgUrl}}/miniapp/images/kon.png'></image>
69   - <image wx:if="{{exp_type==1}}" src='{{imgUrl}}/miniapp/images/dd.png'></image>
70   - <text class='qu_wz'>门店自提</text>
71   - </view>
72   -
73   - <view bindtap="set_wuliu" data-type="0" class='qu_fs' wx:if="{{distr_type==0 || distr_type==2}}">
74   - <image wx:if="{{exp_type==0}}" src='{{imgUrl}}/miniapp/images/dd.png'></image>
75   - <image wx:if="{{exp_type==1}}" src='{{imgUrl}}/miniapp/images/kon.png'></image>
76   - <text class='qu_wz'>快递邮寄</text>
77   - </view>
78   -</view> -->
79   -
80 63 <view class="use-item bdr_b-14 jc_sb" wx:if='{{exp_type==0 && !is_default_logistics}}'>
81 64 <view>选择物流:</view>
82 65 <view class="flex-vertical" bindtap="show_wu_arr" data-txt='index' style="margin-right: 8rpx;">
... ...
pages/goods/goodsInfo/goodsInfo.wxml
... ... @@ -900,6 +900,7 @@
900 900 <image class="cs-img" src="{{iurl}}/miniapp/images/custom-service.png"></image>
901 901 <view>客服</view>
902 902 </view>
  903 +
903 904 <view bindtap="collectGoods" class="custom-service cart-ico new_split">
904 905 <image hidden="{{is_collect}}" class="cs-img" src="{{iurl}}/miniapp/images/heart.png"></image>
905 906 <image hidden="{{!is_collect}}" class="cs-img" src="{{iurl}}/miniapp/images/heart-h.png"></image>
... ...
pages/index/index/index.js
... ... @@ -48,6 +48,7 @@ Page({
48 48 pindGoods: null, //拼单数据
49 49 newGoods: null, //新商品
50 50 hotGoods: null, //hot商品
  51 + preGoods:null, //预售商品
51 52 //----控制是是否显示计时器---
52 53 is_timer: 1,
53 54 ishow: 0,
... ... @@ -302,7 +303,30 @@ Page({
302 303 }
303 304 }
304 305  
305   - //优惠券要实时更新
  306 + var pre_data={store_id:os.stoid,is_end:0,timetype:1,isuse:1};
  307 + if(userInfo){
  308 + pre_data.user_id= userInfo.user_id;
  309 + }
  310 +
  311 + getApp().request.get("/api/weshop/marketing/marketingPresellList/page",{
  312 + data:pre_data,
  313 + success:function (e) {
  314 + if(e.data.code==0 && e.data.data.pageData && e.data.data.pageData.length>0 ){
  315 + var pre_data=e.data.data.pageData;
  316 + var arr = new Array();
  317 + //--三个三个一组---
  318 + for (var i = 0; i < pre_data.length; i += 3) {
  319 + arr.push(pre_data.slice(i, i + 3));
  320 + }
  321 + th.setData({
  322 + preGoods: arr
  323 + });
  324 + }
  325 + }
  326 + })
  327 +
  328 +
  329 + //优惠券要实时更新
306 330 getApp().getConfig2(function (e) {
307 331 var json_d = JSON.parse(e.switch_list);
308 332 th.setData({ is_closecoupon: json_d.is_closecoupon })
... ... @@ -1121,4 +1145,14 @@ Page({
1121 1145 this.close_full_screen();
1122 1146 },
1123 1147  
  1148 + go_pre:function (e) {
  1149 + var userInfo=getApp().globalData.userInfo;
  1150 + if(!userInfo){
  1151 + getApp().goto("/pages/togoin/togoin");
  1152 + return false;
  1153 + }
  1154 + var url=e.currentTarget.dataset.url;
  1155 + getApp().goto(url);
  1156 + }
  1157 +
1124 1158 });
1125 1159 \ No newline at end of file
... ...
pages/index/index/index.wxml
... ... @@ -181,9 +181,8 @@
181 181  
182 182  
183 183 <!--预售-->
184   - <!--
185 184 <view class="seckill" wx:if="{{preGoods!=null && preGoods.length!=0 }}">
186   - <navigator url="/packageC/pages/presell/list/list" hover-class="none">
  185 + <navigator bindtap="go_pre" data-url="/packageC/pages/presell/list/list" hover-class="none">
187 186 <view class="seckill-time">
188 187 <view class="classname flex ai_c">
189 188 <i class="iconfont icon-presell"></i>
... ... @@ -198,7 +197,9 @@
198 197 <view class="seckill-list">
199 198 <swiper class="s_prom" indicator-dots="{{false}}" bindchange="flashSwiperChange" next-margin="25rpx">
200 199 <swiper-item wx:for="{{preGoods}}" wx:key="*this" class="p_swiper" >
201   - <navigator class="nav" hover-class="none" url="/packageC/pages/presell/goodsInfo/goodsInfo?goods_id={{aitem.goods_id}}&title={{aitem.goods_name}}" wx:for="{{item}}" wx:key="item" wx:for-item="aitem" wx:for-index="aind">
  200 + <navigator bindtap="go_pre" class="nav" hover-class="none"
  201 + data-url="/packageC/pages/presell/goodsInfo/goodsInfo?goods_id={{aitem.goods_id}}&pre_id={{aitem.id}}"
  202 + wx:for="{{item}}" wx:key="item" wx:for-item="aitem" wx:for-index="aind">
202 203 <view class="imgview presell">
203 204 <image src="{{url+aitem.original_img}}" mode="aspectFill" lazy-load="true" data-errorimg="preGoods[{{index}}][{{aind}}].original_img" binderror="bind_bnerr3" data-img="{{aitem.original_img}}"></image>
204 205 </view>
... ... @@ -215,7 +216,7 @@
215 216 </swiper>
216 217 </view>
217 218 </view>
218   - - -->
  219 +
219 220  
220 221  
221 222 <!----拼单---->
... ...
pages/user/order_list/order_list.js
... ... @@ -135,150 +135,171 @@ Page({
135 135 },
136 136  
137 137  
138   - /*---------获取订单列表--------*/
139   - requestOrderList: function (t) {
140   - var rd = Math.random() * 100;
141   - var e = this, th = e, r = e.data.url + "/api/weshop/order/page?rd=" + rd, a = "";
142   - switch (t) {
143   - case "1":
144   - r += "&wait_status=0"; break;
145   - case "2":
146   - r += "&wait_status=1"; break;
147   - case "3":
148   - r += "&wait_status=2"; break;
149   - case "4":
150   - r += "&order_status=2"; break;
151   - }
152   - r+="&isdel=0";
153   - if(this.data.searchContent) {
154   - r+="&keyWord=" + this.data.searchContent;
155   - }
156   - this.setData({ activeCategoryId: t }); r = r + "&page=" + e.data.currentPage;
157   - s.request(r, function (t) {
158   -
159   - th.setData({ is_get: 1 });
160   - var data = e.data.orderList;
161   - data.forEach(async function (item, ind) {
162   - var tt = null;
163   - await getApp().request.promiseGet('/api/weshop/ordergoods/list', {
164   - data: { order_id: item.order_id, store_id: os.stoid, pageSize: 600 },
165   - }).then(res => {
166   - tt = res;
167   - })
168   -
169   - var glist = tt.data.data.pageData;
170   - for(var i in glist){
171   - if(glist[i].is_gift){
172   - data[ind].is_prom=1;
173   - }
  138 + /*---------获取订单列表--------*/
  139 + requestOrderList: function (t) {
  140 + var rd = Math.random() * 100;
  141 + var e = this, th = e, r = e.data.url + "/api/weshop/order/page?rd=" + rd, a = "";
  142 + switch (t) {
  143 + case "1":
  144 + r += "&wait_status=0";
  145 + break;
  146 + case "2":
  147 + r += "&wait_status=1";
  148 + break;
  149 + case "3":
  150 + r += "&wait_status=2";
  151 + break;
  152 + case "4":
  153 + r += "&order_status=2";
  154 + break;
174 155 }
175   -
176   -
177   - //------------对比一下有没有退款记录------------
178   - await getApp().request.promiseGet("/api/weshop/order/returngoods/page", {
179   - data: {
180   - order_id: item.order_id, store_id: os.stoid,
181   - user_id: oo.user_id, pageSize: 20
182   - }
183   - }).then(rs => {
184   - var ttd = rs;
185   - //--看一下订单的总数量--
186   - var gtype_num = tt.data.data.total;
187   - if (ttd.data.data.pageData == undefined) return false;
188   - var goodslist = tt.data.data.pageData;
189   -
190   - //----没有相关的退款记录----
191   - if (ttd.data.data.total == 0) {
192   - data[ind]['is_all_return'] = 0;
193   - goodslist.forEach(function (ee, ii) {
194   - if (data[ind]['order_status'] == 1 && data[ind]['pay_status'] == 1 && gtype_num > 1) {
195   - item.goodslist = goodslist;
196   - if (th.check_for_return_btn(item)) {
197   - goodslist[ii]['return_btn'] = 1;
  156 + r += "&isdel=0";
  157 + if (this.data.searchContent) {
  158 + r += "&keyWord=" + this.data.searchContent;
  159 + }
  160 + this.setData({activeCategoryId: t});
  161 + r = r + "&page=" + e.data.currentPage;
  162 + s.request(r, function (t) {
  163 +
  164 + th.setData({is_get: 1});
  165 + var data = e.data.orderList;
  166 + data.forEach(async function (item, ind) {
  167 + var tt = null;
  168 + await getApp().request.promiseGet('/api/weshop/ordergoods/list', {
  169 + data: {order_id: item.order_id, store_id: os.stoid, pageSize: 600},
  170 + }).then(res => {
  171 + tt = res;
  172 + })
  173 + var glist = tt.data.data.pageData;
  174 + for (var i in glist) {
  175 + if (glist[i].is_gift) {
  176 + data[ind].is_prom = 1;
  177 + }
198 178 }
199   - }
200 179  
201   - });
202   - } else {
203   - //--------整单退--------
204   - if (ttd.data.data.pageData[0]['goods_id_list'] != null
205   - && ttd.data.data.pageData[0]['goods_id_list'] != '') {
206   - var eea = ttd.data.data.pageData[0];
207   - //1.退款正在进行中,
208   - //2.退款被拒绝就要显示可以退款
209   - //3.退款已经完成
210   - data[ind]['is_all_return'] = 1;
211   - data[ind]['is_all_return_status'] = ttd.data.data.pageData[0].status;
212   -
213   - if (data[ind]['order_status'] == 1 && data[ind]['pay_status'] == 1) {
214   - switch (eea.status) {
215   - case 0:
216   - case 1:
217   - data[ind]['return_btn'] = 2; break;
218   - case 2:
219   - data[ind]['return_btn'] = 4; break;
220   - case 3:
221   - data[ind]['return_btn'] = 3; break;
222   - default:
223   - data[ind]['return_btn'] = 0;
  180 + data[ind]['ord_url']='/pages/user/order_detail/order_detail';
  181 + //-- 如果是优惠活动 --
  182 + if(glist[0].prom_type==8){
  183 + await getApp().request.promiseGet('/api/weshop/order/orderPresell/get/'+os.stoid+'/'+item.order_id, {
  184 + }).then(res => {
  185 + if(res.data.code==0){
  186 + data[ind]['presell'] = res.data.data;
  187 + data[ind]['ord_url']='/packageC/pages/presell/cart/cart';
  188 + }
  189 + })
224 190 }
225   - }
226   - } else {
227   - //1.退款正在进行中,
228   - //2.退款被拒绝就要显示可以退款
229   - //3.退款已经完成
230   - data[ind]['is_all_return'] = 0;
231   - var rt_ok_num = 0;
232   - //if(data[ind]['order_status'] == 1 && data[ind]['pay_status'] == 1) {
233   - goodslist.forEach(function (eeb, iii) {
234   - if (data[ind]['order_status'] == 1 && data[ind]['pay_status'] == 1)
235   - goodslist[iii]['return_btn'] = 1; //申请退款
236   - ttd.data.data.pageData.forEach(function (eea, ii) {
237   - var st = eea.status;
238   - if (eea.goods_id == eeb.goods_id) {
239   - switch (eea.status) {
240   - case 0:
241   - case 1://退款处理中
242   - data[ind]['has_rt'] = 1; //有部分退
243   - goodslist[iii]['return_btn'] = 2; break;
244   - case 2://退款完成
245   - data[ind]['has_rt'] = 1; //有部分退
246   - goodslist[iii]['return_btn'] = 4; rt_ok_num++; break;
247   - case 3://已拒绝,重新退款
248   - goodslist[iii]['return_btn'] = 3; break;
249   - default:
250   - if (data[ind]['order_status'] == 1 && data[ind]['pay_status'] == 1)
251   - goodslist[iii]['return_btn'] = 1; //申请退款
  191 + //------------对比一下有没有退款记录------------
  192 + await getApp().request.promiseGet("/api/weshop/order/returngoods/page", {
  193 + data: {
  194 + order_id: item.order_id, store_id: os.stoid,
  195 + user_id: oo.user_id, pageSize: 20
  196 + }
  197 + }).then(rs => {
  198 + var ttd = rs;
  199 + //--看一下订单的总数量--
  200 + var gtype_num = tt.data.data.total;
  201 + if (ttd.data.data.pageData == undefined) return false;
  202 + var goodslist = tt.data.data.pageData;
  203 +
  204 + //----没有相关的退款记录----
  205 + if (ttd.data.data.total == 0) {
  206 + data[ind]['is_all_return'] = 0;
  207 + goodslist.forEach(function (ee, ii) {
  208 + if (data[ind]['order_status'] == 1 && data[ind]['pay_status'] == 1 && gtype_num > 1) {
  209 + item.goodslist = goodslist;
  210 + if (th.check_for_return_btn(item)) {
  211 + goodslist[ii]['return_btn'] = 1;
  212 + }
  213 + }
  214 +
  215 + });
  216 + } else {
  217 + //--------整单退--------
  218 + if (ttd.data.data.pageData[0]['goods_id_list'] != null
  219 + && ttd.data.data.pageData[0]['goods_id_list'] != '') {
  220 + var eea = ttd.data.data.pageData[0];
  221 + //1.退款正在进行中,
  222 + //2.退款被拒绝就要显示可以退款
  223 + //3.退款已经完成
  224 + data[ind]['is_all_return'] = 1;
  225 + data[ind]['is_all_return_status'] = ttd.data.data.pageData[0].status;
  226 +
  227 + if (data[ind]['order_status'] == 1 && data[ind]['pay_status'] == 1) {
  228 + switch (eea.status) {
  229 + case 0:
  230 + case 1:
  231 + data[ind]['return_btn'] = 2;
  232 + break;
  233 + case 2:
  234 + data[ind]['return_btn'] = 4;
  235 + break;
  236 + case 3:
  237 + data[ind]['return_btn'] = 3;
  238 + break;
  239 + default:
  240 + data[ind]['return_btn'] = 0;
  241 + }
  242 + }
  243 + } else {
  244 + //1.退款正在进行中,
  245 + //2.退款被拒绝就要显示可以退款
  246 + //3.退款已经完成
  247 + data[ind]['is_all_return'] = 0;
  248 + var rt_ok_num = 0;
  249 + //if(data[ind]['order_status'] == 1 && data[ind]['pay_status'] == 1) {
  250 + goodslist.forEach(function (eeb, iii) {
  251 + if (data[ind]['order_status'] == 1 && data[ind]['pay_status'] == 1)
  252 + goodslist[iii]['return_btn'] = 1; //申请退款
  253 + ttd.data.data.pageData.forEach(function (eea, ii) {
  254 + var st = eea.status;
  255 + if (eea.goods_id == eeb.goods_id) {
  256 + switch (eea.status) {
  257 + case 0:
  258 + case 1://退款处理中
  259 + data[ind]['has_rt'] = 1; //有部分退
  260 + goodslist[iii]['return_btn'] = 2;
  261 + break;
  262 + case 2://退款完成
  263 + data[ind]['has_rt'] = 1; //有部分退
  264 + goodslist[iii]['return_btn'] = 4;
  265 + rt_ok_num++;
  266 + break;
  267 + case 3://已拒绝,重新退款
  268 + goodslist[iii]['return_btn'] = 3;
  269 + break;
  270 + default:
  271 + if (data[ind]['order_status'] == 1 && data[ind]['pay_status'] == 1)
  272 + goodslist[iii]['return_btn'] = 1; //申请退款
  273 + }
  274 + return;
  275 + }
  276 + });
  277 + });
  278 + //}
  279 + }
252 280 }
253   - return;
254   - }
255   - });
256   - });
257   - //}
258   - }
259   - }
260 281  
261   - //--如果是全部退款,也就可以删除--
262   - if (rt_ok_num == goodslist.length) {
263   - data[ind]['is_all_return_status'] = 2;
264   - }
  282 + //--如果是全部退款,也就可以删除--
  283 + if (rt_ok_num == goodslist.length) {
  284 + data[ind]['is_all_return_status'] = 2;
  285 + }
265 286  
266 287  
267   - data[ind]['order_goods'] = goodslist;
268   - var g_num = 0;
269   - goodslist.forEach(function (ee, ii) {
270   - if (ee.return_btn != 4)
271   - g_num += ee.goods_num;
272   - });
273   - data[ind]['g_num'] = g_num;
274   - })
275   - th.setData({ orderList: data, });
  288 + data[ind]['order_goods'] = goodslist;
  289 + var g_num = 0;
  290 + goodslist.forEach(function (ee, ii) {
  291 + if (ee.return_btn != 4)
  292 + g_num += ee.goods_num;
  293 + });
  294 + data[ind]['g_num'] = g_num;
  295 + })
  296 + th.setData({orderList: data,});
276 297  
277   - });
278   - e.data.currentPage++ ,
279   - wx.stopPullDownRefresh();
280   - }, null, { store_id: os.stoid, user_id: oo.user_id });
281   - },
  298 + });
  299 + e.data.currentPage++ ,
  300 + wx.stopPullDownRefresh();
  301 + }, null, {store_id: os.stoid, user_id: oo.user_id});
  302 + },
282 303 //滑倒底部
283 304 onReachBottom: function() {
284 305 if(this.data.currentIndex == 0) {
... ... @@ -433,398 +454,387 @@ Page({
433 454 });
434 455 },
435 456  
436   - /*----------跳转支付-----------*/
437   - async jumpToCart4(t) {
438   - var o_index = t.currentTarget.dataset.idx;
439   - var e = this.data.orderList[o_index];
440   - var th = this;
441   - var order=e ;
442   - var order_goods=e.order_goods;
443   -
444   - var wlist="";
445   - for(var i in order_goods){
446   - var good=order_goods[i];
447   - //线下取价功能已经关闭或者过期
448   - if(!th.data.is_open_offline && good.offline_cut>0){
449   - wx.showModal({
450   - title: '提示',
451   - content: '线下取价功能已经关闭或者过期!'
452   - });
453   - return false;
454   - }
455   - //如果不是小程序有的功能,直接提示要去3.0处理
456   - if(good.prom_type==2 ){
457   - wx.showModal({
458   - title: '提示',
459   - content: '小程序还未有该活动,请到3.0公众号支付'
460   - });
461   - return false;
462   - }
463   - //要每件每件的商品进行检查,看有么有超出库存,超出限购
464   - var good= order_goods[i],goodsbuynum=0,promgoodsbuynum=0,gg=null;
465   - //获取单品的现在的活动状态
466   - await getApp().request.promiseGet("/api/weshop/goods/get/" + os.stoid + "/" + good.goods_id, {
467   - }).then(res=>{
468   - gg=res.data.data;
469   - })
470   - var limit = gg.viplimited;
471   - var store_count = gg.store_count;
472   - good.erpwareid=gg.erpwareid;
473   -
474   - //---要获得商品,该用户买了多少件,同步应用---
475   - await getApp().request.promiseGet("/api/weshop/ordergoods/getUserBuyGoodsNum", {
476   - data: {
477   - store_id: os.stoid,
478   - user_id: getApp().globalData.user_id,
479   - goods_id: good.goods_id,
480   - prom_type: good.prom_type,
481   - prom_id: good.prom_id
482   - },
483   - }).then(res => {
484   - var buy_num_data = res.data.data;
485   - if (buy_num_data.promgoodsbuynum) promgoodsbuynum = buy_num_data.promgoodsbuynum;
486   - goodsbuynum = buy_num_data.goodsbuynum;
487   - })
488   -
489   - var buyed_mum2=goodsbuynum+good.goods_num;
490   - if (buyed_mum2 > limit && limit > 0) {
491   - var content=gg.goods_name+'购买数量超出商品限购,请取消订单';
492   - th.toast(content);
493   - return false;
494   - }
  457 + /*----------跳转支付-----------*/
  458 + async jumpToCart4(t) {
  459 + var o_index = t.currentTarget.dataset.idx;
  460 + var e = this.data.orderList[o_index];
  461 + var th = this;
  462 + var order = e;
  463 + var order_goods = e.order_goods;
  464 +
  465 + var wlist = "";
  466 + for (var i in order_goods) {
  467 + var good = order_goods[i];
  468 + //线下取价功能已经关闭或者过期
  469 + if (!th.data.is_open_offline && good.offline_cut > 0) {
  470 + wx.showModal({
  471 + title: '提示',
  472 + content: '线下取价功能已经关闭或者过期!'
  473 + });
  474 + return false;
  475 + }
  476 + //如果不是小程序有的功能,直接提示要去3.0处理
  477 + if (good.prom_type == 2) {
  478 + wx.showModal({
  479 + title: '提示',
  480 + content: '小程序还未有该活动,请到3.0公众号支付'
  481 + });
  482 + return false;
  483 + }
  484 + //要每件每件的商品进行检查,看有么有超出库存,超出限购
  485 + var good = order_goods[i], goodsbuynum = 0, promgoodsbuynum = 0, gg = null;
  486 + //获取单品的现在的活动状态
  487 + await getApp().request.promiseGet("/api/weshop/goods/get/" + os.stoid + "/" + good.goods_id, {}).then(res => {
  488 + gg = res.data.data;
  489 + })
  490 + var limit = gg.viplimited;
  491 + var store_count = gg.store_count;
  492 + good.erpwareid = gg.erpwareid;
  493 +
  494 + //---要获得商品,该用户买了多少件,同步应用---
  495 + await getApp().request.promiseGet("/api/weshop/ordergoods/getUserBuyGoodsNum", {
  496 + data: {
  497 + store_id: os.stoid,
  498 + user_id: getApp().globalData.user_id,
  499 + goods_id: good.goods_id,
  500 + prom_type: good.prom_type,
  501 + prom_id: good.prom_id
  502 + },
  503 + }).then(res => {
  504 + var buy_num_data = res.data.data;
  505 + if (buy_num_data.promgoodsbuynum) promgoodsbuynum = buy_num_data.promgoodsbuynum;
  506 + goodsbuynum = buy_num_data.goodsbuynum;
  507 + })
  508 +
  509 + var buyed_mum2 = goodsbuynum + good.goods_num;
  510 + if (buyed_mum2 > limit && limit > 0) {
  511 + var content = gg.goods_name + '购买数量超出商品限购,请取消订单';
  512 + th.toast(content);
  513 + return false;
  514 + }
495 515  
496   - //当是组合优惠的时候
497   - if(good.prom_type==7){
498   - //如果有组合购
499   - var isok = 1;
500   - var url="/api/weshop/prom/zhbuy/get/"+os.stoid+"/"+good.prom_id+"/"+getApp().globalData.userInfo.user_id;
501   - await getApp().request.promiseGet(url, {}).then(res => {
502   - if(res.data.code==0 && res.data.data){
503   - if(res.data.data.is_show!=1){
504   - isok=0;
  516 + //当是组合优惠的时候
  517 + if (good.prom_type == 7) {
  518 + //如果有组合购
  519 + var isok = 1;
  520 + var url = "/api/weshop/prom/zhbuy/get/" + os.stoid + "/" + good.prom_id + "/" + getApp().globalData.userInfo.user_id;
  521 + await getApp().request.promiseGet(url, {}).then(res => {
  522 + if (res.data.code == 0 && res.data.data) {
  523 + if (res.data.data.is_show != 1) {
  524 + isok = 0;
  525 + }
  526 + //如果活动已经结束
  527 + if (res.data.data.is_end == 1) {
  528 + isok = 0;
  529 + }
  530 + //已经结束
  531 + if (ut.gettimestamp() > res.data.data.end_time) {
  532 + isok = 0;
  533 + }
  534 + //还未开始
  535 + if (ut.gettimestamp() < res.data.data.start_time) {
  536 + isok = 0;
  537 + }
  538 +
  539 + } else {
  540 + //未找到商品的活动
  541 + isok = 0;
505 542 }
506   - //如果活动已经结束
507   - if(res.data.data.is_end==1){
508   - isok=0;
  543 +
  544 + })
  545 + if (!isok) {
  546 + var content = gg.goods_name + '活动已经结束,请取消订单';
  547 + th.toast(content);
  548 + return false;
  549 + }
  550 +
  551 + var url1 = "/api/weshop/prom/zhbuyGoods/page";
  552 + var req_data = {
  553 + page: 1,
  554 + pageSize: 1,
  555 + store_id: os.stoid,
  556 + zh_id: good.prom_id,
  557 + goods_id: good.goods_id
  558 + }
  559 + await getApp().request.promiseGet(url1, {
  560 + data: req_data
  561 + }).then(res => {
  562 + if (ut.ajax_ok(res)) {
  563 + var gdlist = res.data.data.pageData[0];
  564 + good.buyqty = gdlist.buyqty;
509 565 }
510   - //已经结束
511   - if(ut.gettimestamp()>res.data.data.end_time){
512   - isok=0;
  566 + })
  567 +
  568 + var num = good['buyqty'];
  569 + console.log(1111);
  570 + console.log(num);
  571 + //---- 要计算商品的限购 -----
  572 + if (good['buyqty'] > 0) {
  573 + if (good.goods_num + promgoodsbuynum > good['buyqty']) {
  574 +
  575 + var content = good['goods_name'] + "超出活动限购\n";
  576 + th.toast(content);
  577 + return false;
513 578 }
514   - //还未开始
515   - if(ut.gettimestamp()<res.data.data.start_time){
516   - isok=0;
  579 + }
  580 + }
  581 +
  582 + //如果优惠促销和搭配购的时候
  583 + if ((good.prom_type == 3 || good.prom_type == 5) && good.is_gift != 1 && good.is_collocation != 1) {
  584 + var p_ok = 1;
  585 + await getApp().request.promiseGet("/api/weshop/goods/getGoodsPromList/" + os.stoid + "/" + good.goods_id + "/0", {}).then(res => {
  586 + if (res.data.code == 0) {
  587 + var r_data = res.data.data;
  588 + if (!r_data.collocationPromList && good.prom_type == 5) {
  589 +
  590 + var content = good.goods_name + '未找到活动,请取消订单重新购买';
  591 + th.toast(content)
  592 +
  593 + p_ok = 0;
  594 + }
  595 + if (!r_data.promGoodsLists && good.prom_type == 3) {
  596 +
  597 + var content = good.goods_name + '未找到活动,请取消订单重新购买';
  598 + th.toast(content);
  599 + p_ok = 0;
  600 + }
  601 + } else {
  602 +
  603 + var content = good.goods_name + '未找到活动,请取消订单重新购买'
  604 + th.toast(content);
  605 + p_ok = 0;
517 606 }
  607 + })
  608 + if (!p_ok) return false;
  609 + }
518 610  
519   - }else{
520   - //未找到商品的活动
521   - isok = 0;
  611 + //商品的普通购买 ,不要进行判断
  612 + if ((good.prom_type == 1 || good.prom_type == 6 || good.prom_type == 4 || good.prom_type == 8)
  613 + && !good.is_gift && !good.is_collocation && !good.is_integral_normal && !good.is_pd_normal) {
  614 + if (gg.prom_type != good.prom_type) {
  615 + var content = gg.goods_name + '商品的活动发生了变化,请取消订单重新购买';
  616 + th.toast(content);
  617 + return false;
522 618 }
523 619  
524   - })
525   - if (!isok){
526   - var content=gg.goods_name+'活动已经结束,请取消订单';
527   - th.toast(content);
528   - return false;
  620 + } else {
  621 + if ((gg.prom_type == 1 || gg.prom_type == 3 || gg.prom_type == 5 || gg.prom_type == 6 || gg.prom_type == 4)
  622 + && !good.is_collocation && !good.is_gift && !good.is_integral_normal && !good.is_pd_normal) {
  623 + var prom = null;
  624 + //---如果是活动的时候---
  625 + var prom = null, th = this;
  626 + if (gg.prom_type == 1) {
  627 + await getApp().request.promiseGet("/api/ms/flash_sale/get/" + os.stoid + "/" + gg.prom_id, {}).then(res => {
  628 + if (res.data.code == 0) {
  629 + prom = res.data.data;
  630 + }
  631 + })
  632 + }
  633 + if (gg.prom_type == 6) {
  634 + await getApp().request.promiseGet("/api/weshop/teamlist/get/" + os.stoid + "/" + gg.prom_id, {}).then(res => {
  635 + if (res.data.code == 0) {
  636 + prom = res.data.data;
  637 + }
  638 + })
  639 + }
  640 +
  641 + if (gg.prom_type == 4) {
  642 + await getApp().request.promiseGet("/api/weshop/integralbuy/pageIntegralBuyGoodsList?stype=1&stypeup=1", {
  643 + data: {store_id: os.stoid, goods_id: gg.goods_id}
  644 + }).then(res => {
  645 + if (res.data.code == 0 && res.data.data && res.data.data.pageData) {
  646 + prom = res.data.data.pageData[0];
  647 + }
  648 + })
  649 + }
  650 +
  651 + if (prom) {
  652 + var t_now = ut.gettimestamp();
  653 + if (prom.is_end == 0 && prom.start_time < t_now && prom.end_time > t_now) {
  654 +
  655 + var content = gg.goods_name + '商品的活动发生了变化,请取消订单重新购买';
  656 + th.toast(content);
  657 + return false;
  658 + }
  659 + }
  660 + }
  661 + else {
  662 + if (!good.is_gift && good.prom_type != 3) {
  663 + var t_ok = 1;
  664 + await getApp().request.promiseGet("/api/weshop/goods/getGoodsPromList/" + os.stoid + "/" + good.goods_id + "/0", {}).then(res => {
  665 + if (res.data.code == 0) {
  666 + var r_data = res.data.data;
  667 + //-- 参加了全局的优惠活动 --
  668 + if (r_data.promGoodsLists) {
  669 + var content = gg.goods_name + '商品的活动发生了变化,请取消订单重新购买';
  670 + th.toast(content);
  671 + t_ok = 0;
  672 + }
  673 + }
  674 + })
  675 + if (!t_ok) return false;
  676 + }
  677 + //-- 如果有参加线下取价 --
  678 + if (good.offline_cut > 0) wlist += encodeURIComponent(gg.erpwareid) + ",";
  679 + }
  680 + //赠品和搭配购不判断商品金额
  681 + var isok = 1;
  682 + var card_field = th.data.card_field;
  683 +
  684 + //-- 如果会员是等级会员,商品有等级价,且不是活动商品,同时线下取价的要放在最后来判断 --
  685 + if (!good.is_gift && !good.is_collocation) {
  686 + if (card_field && gg[card_field] > 0) {
  687 + if (good.goods_price != gg[card_field] && good.offline_cut <= 0) isok = 0;
  688 + if (good.goods_price > gg[card_field] && good.offline_cut > 0) isok = 0; //如果线下价格比较贵,则不通过
  689 +
  690 + } else {
  691 + if (good.goods_price != gg.shop_price && good.offline_cut <= 0) isok = 0;
  692 + if (good.goods_price > gg.shop_price && good.offline_cut > 0) isok = 0; //如果线下价格比较贵,则不通过
  693 + }
  694 + var is_h = 0;
  695 + if (!isok) {
  696 +
  697 + var content = gg.goods_name + '商品的价格发生了变化,请取消订单重新购买1'
  698 + th.toast(content);
  699 + return false;
  700 + }
  701 + }
  702 +
  703 + //--如果是线下库存的时候--
  704 + if (th.data.conf.sales_rules == 2) {
  705 + var ob = {};
  706 + await th.check_down_line_next(gg, good.goods_num, order.pickup_id, function (obj) {
  707 + ob = obj;
  708 + })
  709 + if (ob.code == -1) {
  710 +
  711 + var content = gg.goods_name + '门店库存不足,请取消订单';
  712 + th.toast(content);
  713 + return false;
  714 + }
  715 +
  716 + } else {
  717 + if (good.goods_num > store_count) {
  718 +
  719 + var content = gg.goods_name + '商品的库存不足,请取消订单';
  720 + th.toast(content);
  721 + return false;
  722 + }
  723 +
  724 + }
  725 + }
  726 +
  727 + console.log("------------------------------------");
  728 + //---如果是活动的时候---
  729 + var prom = null, goodsinfo = good, th = this;
  730 + if (goodsinfo.prom_type == 1) {
  731 + await getApp().request.promiseGet("/api/ms/flash_sale/get/" + os.stoid + "/" + goodsinfo.prom_id, {}).then(res => {
  732 + if (res.data.code == 0) {
  733 + prom = res.data.data;
  734 + }
  735 + })
  736 + }
  737 + if (goodsinfo.prom_type == 6 && !good.is_pd_normal) {
  738 + await getApp().request.promiseGet("/api/weshop/teamlist/get/" + os.stoid + "/" + goodsinfo.prom_id, {}).then(res => {
  739 + if (res.data.code == 0) {
  740 + prom = res.data.data;
  741 + }
  742 + })
529 743 }
530 744  
531   - var url1 = "/api/weshop/prom/zhbuyGoods/page";
532   - var req_data = {
533   - page: 1,
534   - pageSize: 1,
535   - store_id: os.stoid,
536   - zh_id: good.prom_id,
537   - goods_id:good.goods_id
  745 + if (goodsinfo.prom_type == 4 && !good.is_integral_normal) {
  746 + await getApp().request.promiseGet("/api/weshop/integralbuy/pageIntegralBuyGoodsList?stype=1&stypeup=1", {
  747 + data: {store_id: os.stoid, goods_id: goodsinfo.goods_id}
  748 + }).then(res => {
  749 + if (res.data.code == 0 && res.data.data && res.data.data.pageData) {
  750 + prom = res.data.data.pageData[0];
  751 + }
  752 + })
538 753 }
539   - await getApp().request.promiseGet(url1, {
540   - data: req_data
541   - }).then(res => {
542   - if (ut.ajax_ok(res)) {
543   - var gdlist = res.data.data.pageData[0];
544   - good.buyqty=gdlist.buyqty;
  754 +
  755 + //----------如果有活动,并且在进行中,就不计算线下库存---------------
  756 + if (prom) {
  757 + var now = ut.gettimestamp();
  758 + if (prom.is_end == 1 && prom.end_time < now) {
  759 +
  760 + var content = goodsinfo.goods_name + '商品的活动已经结束,请取消订单'
  761 + th.toast(content);
  762 + return false;
545 763 }
546   - })
547 764  
548   - var num=good['buyqty'];
549   - console.log(1111);
550   - console.log(num);
551   - //---- 要计算商品的限购 -----
552   - if(good['buyqty']>0){
553   - if(good.goods_num+promgoodsbuynum>good['buyqty']){
  765 + buyed_mum2 = promgoodsbuynum + good.goods_num;
  766 + if (buyed_mum2 > prom.buy_limit && prom.buy_limit > 0) {
554 767  
555   - var content= good['goods_name']+"超出活动限购\n";
  768 + var content = goodsinfo.goods_name + '购买数量超出商品活动限购,请取消订单'
556 769 th.toast(content);
557 770 return false;
558 771 }
559   - }
560   - }
561 772  
  773 + if (goodsinfo.prom_type == 4) {
  774 + if (good.goods_num > prom.limitqty - prom.buy_num) {
562 775  
563   -
564   - //如果优惠促销和搭配购的时候
565   - if((good.prom_type==3 || good.prom_type==5) && good.is_gift!=1 && good.is_collocation!=1){
566   - var p_ok=1;
567   - await getApp().request.promiseGet("/api/weshop/goods/getGoodsPromList/" + os.stoid+"/"+good.goods_id+"/0", {}).then(res => {
568   - if(res.data.code==0){
569   - var r_data=res.data.data;
570   - if(!r_data.collocationPromList && good.prom_type==5){
571   -
572   - var content=good.goods_name+'未找到活动,请取消订单重新购买';
573   - th.toast(content)
574   -
575   - p_ok=0;
576   - }
577   - if(!r_data.promGoodsLists && good.prom_type==3){
578   -
579   - var content=good.goods_name+'未找到活动,请取消订单重新购买';
580   - th.toast(content);
581   - p_ok=0;
582   - }
583   - }else{
584   -
585   - var content=good.goods_name+'未找到活动,请取消订单重新购买'
586   - th.toast(content);
587   - p_ok=0;
588   - }
589   - })
590   - if(!p_ok) return false;
591   - }
592   -
593   - //商品的普通购买 ,不要进行判断
594   - if((good.prom_type==1 || good.prom_type==6 || good.prom_type==4 )
595   - && !good.is_gift && !good.is_collocation && !good.is_integral_normal && !good.is_pd_normal){
596   - if(gg.prom_type!=good.prom_type) {
597   - var content=gg.goods_name+'商品的活动发生了变化,请取消订单重新购买';
598   - th.toast(content);
599   - return false;
600   - }
601   -
602   - }else{
603   - if((gg.prom_type==1 || gg.prom_type==3 || gg.prom_type==5 || gg.prom_type==6 || gg.prom_type==4)
604   - && !good.is_collocation && !good.is_gift && !good.is_integral_normal && !good.is_pd_normal) {
605   - var prom=null;
606   - //---如果是活动的时候---
607   - var prom=null,th=this;
608   - if(gg.prom_type==1){
609   - await getApp().request.promiseGet("/api/ms/flash_sale/get/"+os.stoid+"/"+gg.prom_id,{
610   - }).then(res=>{
611   - if(res.data.code==0){
612   - prom=res.data.data;
613   - }
614   - })
615   - }
616   - if(gg.prom_type==6){
617   - await getApp().request.promiseGet("/api/weshop/teamlist/get/"+os.stoid+"/"+gg.prom_id,{
618   - }).then(res=>{
619   - if(res.data.code==0){
620   - prom=res.data.data;
621   - }
622   - })
623   - }
624   -
625   - if(gg.prom_type==4){
626   - await getApp().request.promiseGet("/api/weshop/integralbuy/pageIntegralBuyGoodsList?stype=1&stypeup=1",{
627   - data:{store_id:os.stoid,goods_id:gg.goods_id}
628   - }).then(res=>{
629   - if(res.data.code==0 && res.data.data && res.data.data.pageData){
630   - prom=res.data.data.pageData[0];
631   - }
632   - })
633   - }
634   -
635   - if(prom){
636   - var t_now=ut.gettimestamp();
637   - if(prom.is_end==0 && prom.start_time<t_now && prom.end_time>t_now){
638   -
639   - var content=gg.goods_name+'商品的活动发生了变化,请取消订单重新购买';
640   - th.toast(content);
641   - return false;
642   - }
643   - }
644   - }
645   - else{
646   - if(!good.is_gift && good.prom_type!=3 ){
647   - var t_ok=1;
648   - await getApp().request.promiseGet("/api/weshop/goods/getGoodsPromList/" + os.stoid+"/"+good.goods_id+"/0", {}).then(res => {
649   - if(res.data.code==0){
650   - var r_data=res.data.data;
651   - //-- 参加了全局的优惠活动 --
652   - if(r_data.promGoodsLists){
653   - var content=gg.goods_name+'商品的活动发生了变化,请取消订单重新购买';
654   - th.toast(content);
655   - t_ok=0;
656   - }
657   - }
658   - })
659   - if(!t_ok) return false;
660   - }
661   - //-- 如果有参加线下取价 --
662   - if(good.offline_cut>0) wlist+=encodeURIComponent(gg.erpwareid)+",";
663   - }
664   - //赠品和搭配购不判断商品金额
665   - var isok=1;
666   - var card_field=th.data.card_field;
667   -
668   - //-- 如果会员是等级会员,商品有等级价,且不是活动商品,同时线下取价的要放在最后来判断 --
669   - if(!good.is_gift && !good.is_collocation) {
670   - if (card_field && gg[card_field] > 0) {
671   - if (good.goods_price != gg[card_field] && good.offline_cut<=0) isok = 0;
672   - if (good.goods_price >gg[card_field] && good.offline_cut>0) isok = 0; //如果线下价格比较贵,则不通过
673   -
674   - } else {
675   - if (good.goods_price != gg.shop_price && good.offline_cut<=0) isok = 0;
676   - if (good.goods_price> gg.shop_price && good.offline_cut>0) isok = 0; //如果线下价格比较贵,则不通过
677   - }
678   - var is_h=0;
679   - if (!isok) {
680   -
681   - var content=gg.goods_name + '商品的价格发生了变化,请取消订单重新购买'
682   - th.toast(content);
683   - return false;
684   - }
685   - }
686   -
687   - //--如果是线下库存的时候--
688   - if(th.data.conf.sales_rules==2){
689   - var ob={};
690   - await th.check_down_line_next(gg,good.goods_num,order.pickup_id,function(obj){
691   - ob=obj;
692   - })
693   - if(ob.code==-1){
694   -
695   - var content=gg.goods_name+'门店库存不足,请取消订单';
696   - th.toast(content);
697   - return false;
698   - }
699   -
700   - }else{
701   - if(good.goods_num>store_count){
702   -
703   - var content=gg.goods_name+'商品的库存不足,请取消订单';
704   - th.toast(content);
705   - return false;
706   - }
707   -
708   - }
709   - }
710   -
711   - console.log("------------------------------------");
712   - //---如果是活动的时候---
713   - var prom=null,goodsinfo=good,th=this;
714   - if(goodsinfo.prom_type==1){
715   - await getApp().request.promiseGet("/api/ms/flash_sale/get/"+os.stoid+"/"+goodsinfo.prom_id,{
716   - }).then(res=>{
717   - if(res.data.code==0){
718   - prom=res.data.data;
719   - }
720   - })
721   - }
722   - if(goodsinfo.prom_type==6 && !good.is_pd_normal){
723   - await getApp().request.promiseGet("/api/weshop/teamlist/get/"+os.stoid+"/"+goodsinfo.prom_id,{
724   - }).then(res=>{
725   - if(res.data.code==0){
726   - prom=res.data.data;
727   - }
728   - })
729   - }
730   -
731   - if(goodsinfo.prom_type==4 && !good.is_integral_normal){
732   - await getApp().request.promiseGet("/api/weshop/integralbuy/pageIntegralBuyGoodsList?stype=1&stypeup=1",{
733   - data:{store_id:os.stoid,goods_id:goodsinfo.goods_id}
734   - }).then(res=>{
735   - if(res.data.code==0 && res.data.data && res.data.data.pageData){
736   - prom=res.data.data.pageData[0];
737   - }
738   - })
739   - }
740   -
741   - //----------如果有活动,并且在进行中,就不计算线下库存---------------
742   - if(prom){
743   - var now=ut.gettimestamp();
744   - if(prom.is_end==1 && prom.end_time<now){
745   -
746   - var content=goodsinfo.goods_name+'商品的活动已经结束,请取消订单'
747   - th.toast(content);
748   - return false;
749   - }
750   -
751   - buyed_mum2=promgoodsbuynum+good.goods_num;
752   - if (buyed_mum2 > prom.buy_limit && prom.buy_limit > 0) {
753   -
754   - var content=goodsinfo.goods_name+'购买数量超出商品活动限购,请取消订单'
755   - th.toast(content);
756   - return false;
757   - }
758   -
759   - if(goodsinfo.prom_type==4){
760   - if (good.goods_num > prom.limitqty-prom.buy_num) {
761   -
762   - var content=goodsinfo.goods_name+'购买数量超出商品活动库存,请取消订单'
763   - th.toast(content);
764   - return false;
765   - }
766   - }else{
767   - var redis_num = 0;
768   - //------判断活动是否抢光-----
769   - await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" +
770   - os.stoid + "/" + goodsinfo.prom_type + "/" + goodsinfo.prom_id, {
771   - }).then(res => {
772   - redis_num = res.data.data;
773   - });
774   -
775   - if (good.goods_num > redis_num) {
776   -
777   - var content=gg.goods_name+'超出商品活动库存,请取消订单';
778   - th.toast(content);
779   - return false;
780   - }
781   - }
782   -
783   - }
784   - }
785   -
786   - //-- 要判断一下线下取价价格是不是发生改变 --
787   - if(wlist!="" && th.data.is_open_offline && th.data.is_open_offline>0){
788   - wlist=ut.sub_last(wlist);
789   - var keyid=order.pickup_id;
790   - var user_info=getApp().globalData.userInfo;
791   - if(!keyid) return false;
792   - var offarr=null;
793   - await getApp().request.promiseGet("/api/weshop/goods/listWarePrice", {
794   - data:{
795   - VIPId:encodeURIComponent(user_info.erpvipid),
796   - store_id:os.stoid,
797   - PickupId:keyid,
798   - WareIds:wlist},
799   - },
800   - ).then(res=>{
801   - if(res.data.code==0 && res.data.data && res.data.data.length>0){
802   - offarr=res.data.data;
803   - }
804   - })
805   - if(!offarr && offarr.length<=0){
806   - th.toast('获取线下取价失败');
807   - }
808   - var newarr=ut.convert_arr_key(offarr,'WareId');
809   - //-- 循环判断线下的价格 --
810   - for(var k in order_goods){
811   - var good=order_goods[k];
812   - //判断线下取价是不是一样
813   - if(newarr[good.erpwareid] &&
814   - parseFloat(newarr[good.erpwareid].WarePrice)!=parseFloat(good.goods_price)){
815   -
816   - var content=good.goods_name + '商品的价格发生了变化,请取消订单重新购买';
817   - th.toast(content);
818   - return false;
819   - }
820   - }
821   -
822   - }
  776 + var content = goodsinfo.goods_name + '购买数量超出商品活动库存,请取消订单'
  777 + th.toast(content);
  778 + return false;
  779 + }
  780 + } else {
  781 + var redis_num = 0;
  782 + //------判断活动是否抢光-----
  783 + await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" +
  784 + os.stoid + "/" + goodsinfo.prom_type + "/" + goodsinfo.prom_id, {}).then(res => {
  785 + redis_num = res.data.data;
  786 + });
  787 +
  788 + if (good.goods_num > redis_num) {
  789 +
  790 + var content = gg.goods_name + '超出商品活动库存,请取消订单';
  791 + th.toast(content);
  792 + return false;
  793 + }
  794 + }
823 795  
824   - return false;
825   -
826   - th.pay_next(e,o_index);
827   - },
  796 + }
  797 + }
  798 +
  799 + //-- 要判断一下线下取价价格是不是发生改变 --
  800 + if (wlist != "" && th.data.is_open_offline && th.data.is_open_offline > 0) {
  801 + wlist = ut.sub_last(wlist);
  802 + var keyid = order.pickup_id;
  803 + var user_info = getApp().globalData.userInfo;
  804 + if (!keyid) return false;
  805 + var offarr = null;
  806 + await getApp().request.promiseGet("/api/weshop/goods/listWarePrice", {
  807 + data: {
  808 + VIPId: encodeURIComponent(user_info.erpvipid),
  809 + store_id: os.stoid,
  810 + PickupId: keyid,
  811 + WareIds: wlist
  812 + },
  813 + },
  814 + ).then(res => {
  815 + if (res.data.code == 0 && res.data.data && res.data.data.length > 0) {
  816 + offarr = res.data.data;
  817 + }
  818 + })
  819 + if (!offarr && offarr.length <= 0) {
  820 + th.toast('获取线下取价失败');
  821 + }
  822 + var newarr = ut.convert_arr_key(offarr, 'WareId');
  823 + //-- 循环判断线下的价格 --
  824 + for (var k in order_goods) {
  825 + var good = order_goods[k];
  826 + //判断线下取价是不是一样
  827 + if (newarr[good.erpwareid] &&
  828 + parseFloat(newarr[good.erpwareid].WarePrice) != parseFloat(good.goods_price)) {
  829 +
  830 + var content = good.goods_name + '商品的价格发生了变化,请取消订单重新购买';
  831 + th.toast(content);
  832 + return false;
  833 + }
  834 + }
  835 + }
  836 + th.pay_next(e, o_index);
  837 + },
828 838  
829 839  
830 840 pay_next(e,o_index){
... ...
pages/user/order_list/order_list.wxml
... ... @@ -40,27 +40,46 @@
40 40 <text selectable='true'>订单编号:{{item.order_sn}}</text>
41 41 <!-- 商品评价状态 -->
42 42 <view class="flex-center c-r">
43   - <!-- 订单状态 -->
44   - <view wx:if="{{item.pt_status==1 && item.pt_prom_id>0}}">组团中</view>
45   - <view wx:if="{{(item.order_status==0&&item.pay_status==0)}}">未支付</view>
46   - <block wx:if="{{!(item.is_all_return_status==0 || item.is_all_return_status==1)}}">
47   - <view wx:if="{{(item.order_status==1&&item.pay_status==1&&item.shipping_status==0)}}">待发货</view>
48   - <view wx:if="{{(item.order_status==1&&item.pay_status==1&&item.shipping_status==1)}}">待收货</view>
49   - <view wx:if="{{(item.order_status==2)}}">待评价</view>
50   - <view wx:if="{{item.order_status==4}}">已评价</view>
51   - <view wx:if="{{item.order_status==3 && item.pt_status!=6}}" class="flex-center" >已取消<view class="lin"></view>
52   - <image src="{{iurl}}miniapp/images/trash.png" bindtap="deleteOrderData" data-index="{{index}}" data-order_id="{{item.order_id}}"></image>
53   - </view>
54   - <view wx:if="{{item.pt_status==2 && item.pt_tail_money>0}}">待支付尾款</view>
55   - <view wx:if="{{item.order_status==6}}">退款成功</view>
56   - <view wx:if="{{item.pt_status==6}}"><text style="font-size: 26rpx;">支付尾款失败</text></view>
57   - </block>
58   - <block wx:else>退款中</block>
59   - <!--
60   - <view class="flex" wx:if="{{(item.order_status==0&&item.pay_status==0)}}">
61   - <view class="lin"></view>
62   - <image src="{{iurl}}miniapp/images/trash.png" bindtap="deleteOrderData" data-index="{{index}}" data-order_id="{{item.order_id}}"></image>
63   - </view>-->
  43 +
  44 + <block wx:if="{{item.presell}}">
  45 + <block wx:if="{{item.order_status==3}}">
  46 + <text wx:if="{{item.presell.tail_pay_state==2}}">尾款支付失败</text>
  47 + </block>
  48 + <block wx:else>
  49 + <text wx:if="{{!item.presell.deposit_pay_time}}">待支付定金</text>
  50 + <text wx:if="{{item.presell.presell_type!=1 && item.presell.deposit_pay_time && !item.presell.tail_pay_state}}">待尾款</text>
  51 + </block>
  52 +
  53 + <block wx:if="{{!(item.is_all_return_status==0 || item.is_all_return_status==1)}}">
  54 + <view wx:if="{{(item.order_status==1&&item.pay_status==1&&item.shipping_status==0)}}">待发货</view>
  55 + <view wx:if="{{(item.order_status==1&&item.pay_status==1&&item.shipping_status==1)}}">待收货</view>
  56 + <view wx:if="{{(item.order_status==2)}}">待评价</view>
  57 + <view wx:if="{{item.order_status==4}}">已评价</view>
  58 + <view wx:if="{{item.order_status==3 && item.pt_status!=6}}" class="flex-center" >已取消<view class="lin"></view>
  59 + <image src="{{iurl}}miniapp/images/trash.png" bindtap="deleteOrderData" data-index="{{index}}" data-order_id="{{item.order_id}}"></image>
  60 + </view>
  61 + </block>
  62 + <block wx:else>退款中</block>
  63 +
  64 + </block>
  65 + <block wx:else>
  66 + <!-- 订单状态 -->
  67 + <view wx:if="{{item.pt_status==1 && item.pt_prom_id>0}}">组团中</view>
  68 + <view wx:if="{{(item.order_status==0&&item.pay_status==0)}}">未支付</view>
  69 + <block wx:if="{{!(item.is_all_return_status==0 || item.is_all_return_status==1)}}">
  70 + <view wx:if="{{(item.order_status==1&&item.pay_status==1&&item.shipping_status==0)}}">待发货</view>
  71 + <view wx:if="{{(item.order_status==1&&item.pay_status==1&&item.shipping_status==1)}}">待收货</view>
  72 + <view wx:if="{{(item.order_status==2)}}">待评价</view>
  73 + <view wx:if="{{item.order_status==4}}">已评价</view>
  74 + <view wx:if="{{item.order_status==3 && item.pt_status!=6}}" class="flex-center" >已取消<view class="lin"></view>
  75 + <image src="{{iurl}}miniapp/images/trash.png" bindtap="deleteOrderData" data-index="{{index}}" data-order_id="{{item.order_id}}"></image>
  76 + </view>
  77 + <view wx:if="{{item.pt_status==2 && item.pt_tail_money>0}}">待支付尾款</view>
  78 + <view wx:if="{{item.order_status==6}}">退款成功</view>
  79 + <view wx:if="{{item.pt_status==6}}"><text style="font-size: 26rpx;">支付尾款失败</text></view>
  80 + </block>
  81 + <block wx:else>退款中</block>
  82 + </block>
64 83  
65 84 </view>
66 85 </view>
... ... @@ -70,7 +89,7 @@
70 89 <!-- 单个商品 -->
71 90 <!-- wx:if="{{goods.return_btn!=4}}" -->
72 91 <view>
73   - <navigator class="detail_commodity flex-vertical padding" wx:for="{{item.order_goods}}" wx:for-item="goods" wx:for-index="pinx" url="/pages/user/order_detail/order_detail?order_id={{item.order_id}}">
  92 + <navigator class="detail_commodity flex-vertical padding" wx:for="{{item.order_goods}}" wx:for-item="goods" wx:for-index="pinx" url="{{item.ord_url}}?order_id={{item.order_id}}">
74 93 <!-- 商品图片 -->
75 94 <navigator class="rel">
76 95 <image src="{{resourceUrl+goods.original_img}}" binderror="bind_bnerr" lazy-load="{{true}}" data-errorimg="orderList[{{index}}].order_goods[{{pinx}}].original_img"></image>
... ... @@ -173,15 +192,22 @@
173 192 </block>
174 193 <navigator class="commodity_To_evaluate flex-level View_evaluation" hidden="{{!(item.exp_type==0&&item.pay_status==1&&item.shipping_status==1)}}" url="/pages/user/express/express?order_id={{item.order_id}}">查看物流</navigator>
175 194 <navigator class="commodity_To_evaluate flex-level View_evaluation" hidden="{{!(item.exp_type==0&&item.pay_status==1&&item.shipping_status==2)}}" url="/pages/user/express/express?order_id={{item.order_id}}">查看物流</navigator>
176   - <navigator class="commodity_To_evaluate flex-level View_evaluation" url="/pages/user/order_detail/order_detail?order_id={{item.order_id}}">订单详情</navigator>
  195 +
  196 + <navigator class="commodity_To_evaluate flex-level View_evaluation" url="{{item.ord_url}}?order_id={{item.order_id}}">订单详情</navigator>
177 197  
178 198 <block wx:if="{{!(item.has_rt || item.return_btn==2 || item.return_btn==4)}}">
179 199 <view bindtap="confirmOrder" data-zsorder="{{item.is_zsorder}}" class="commodity_To_evaluate flex-level comment_go" data-id="{{item.order_id}}" hidden="{{!(item.order_status==1&&item.pay_status==1&&item.shipping_status==1)}}">确认收货</view>
180 200 <view bindtap="confirmOrder" data-zsorder="{{item.is_zsorder}}" class="commodity_To_evaluate flex-level comment_go" data-id="{{item.order_id}}" hidden="{{!(item.order_status==1&&item.pay_status==1&&item.shipping_status==2)}}">确认收货</view>
181 201 </block>
182   -
183   -
184   - <block wx:if="{{item.order_status==2 && item.is_zsorder!=4}}">
  202 +
  203 + <block wx:if="{{item.presell && item.presell.presell_type!=1}}">
  204 + <navigator class="commodity_To_evaluate flex-level comment_go" url="/packageC/pages/presell/cart/cart?order_id={{item.order_id}}" data-idx="{{index}}" wx:if="{{item.order_status<3 && item.presell.deposit_pay_time>0 && item.presell.tail_pay_state==0}}">支付尾款</navigator>
  205 +
  206 + </block>
  207 +
  208 +
  209 +
  210 + <block wx:if="{{item.order_status==2 && item.is_zsorder!=4}}">
185 211 <navigator wx:if="{{item.order_goods.length>1}}" class="order-btn white"
186 212 url="/packageB/pages/user/comment/comment?status=0&order_id={{item.order_id}}">评价</navigator>
187 213 <navigator wx:else class="order-btn white red-b"
... ... @@ -193,10 +219,15 @@
193 219 <navigator class="commodity_To_evaluate flex-level comment_go" bindtap="jumpToCart4" data-idx="{{index}}" wx:if="{{(item.order_status==0&&item.pay_status==0)}}">立即支付</navigator>
194 220  
195 221 <!-- 积分购 拼团 搭配购没有有再来一单 -->
196   - <block wx:if="{{(item.pay_status==1 || item.order_status==3) && item.pt_prom_id<=0 && item.integral<=0 && item.order_goods[0].prom_type!=5 }}">
  222 + <block wx:if="{{(item.pay_status==1 || item.order_status==3) && !item.presell && item.pt_prom_id<=0 && item.integral<=0 && item.order_goods[0].prom_type!=5 }}">
197 223 <view bindtap="moreOrder" class="commodity_To_evaluate flex-level comment_go"
198 224 data-index="{{index}}" >再来一单</view>
199 225 </block>
  226 +
  227 +
  228 +
  229 +
  230 +
200 231  
201 232 </view>
202 233 </view>
... ...
pages/user/order_list/order_list.wxss
... ... @@ -533,11 +533,14 @@ page {
533 533 }
534 534 .search-btn {
535 535 color: white;
536   - font-size: 14px;
  536 + font-size: 28rpx;
537 537 background-color: #FF3B3D;
538   - padding: 8px 20px;
539   - border-radius: 0 4px 4px 0;
  538 + padding: 6rpx 40rpx;
  539 + border-radius: 0 4px 4px 0;
  540 + line-height: 60rpx;
540 541 }
  542 +
  543 +
541 544 .picker-container {
542 545 padding-right: 10rpx;
543 546 align-items: center;
... ...