diff --git a/packageC/pages/presell/cart/cart.js b/packageC/pages/presell/cart/cart.js index 212eac5..3496e3a 100644 --- a/packageC/pages/presell/cart/cart.js +++ b/packageC/pages/presell/cart/cart.js @@ -112,34 +112,34 @@ Page({ tabs: ['门店自提', '快递邮寄'], currentTabIndex: 1, - order_sn:'', - order_id:'', + order_sn: '', + order_id: '', }, onLoad: function (t) { - - if(t.order_id) this.data.order_id=t.order_id; - if(t.order_sn) this.data.order_sn=t.order_sn; - wx.setNavigationBarTitle({title: "订单详情",}) + if (t.order_id) this.data.order_id = t.order_id; + if (t.order_sn) this.data.order_sn = t.order_sn; + + wx.setNavigationBarTitle({ title: "订单详情", }) var th = this; - this.setData({is_b_now: t.is_bnow == undefined ? 0 : t.is_bnow,}); + this.setData({ is_b_now: t.is_bnow == undefined ? 0 : t.is_bnow, }); th.data.param = t; //清理一下,确保最新的系统配置 getApp().globalData.config2 = null; //清空is_pick_up getApp().request.put("/api/weshop/useraddress/updatePickUp", { - data: {user_id: getApp().globalData.user_id, is_pickup: 0}, + data: { user_id: getApp().globalData.user_id, is_pickup: 0 }, success: function (s) { } }); - if(!getApp().globalData.userInfo){ + if (!getApp().globalData.userInfo) { getApp().goto("/pages/togoin/togoin"); } }, onUnload: function () { - this.setData({isclose: 1}) + this.setData({ isclose: 1 }) }, onHide: function () { this.setData({ @@ -152,13 +152,13 @@ Page({ //----------子页返回父页触发---------- onShow: function () { var th = this; - th.setData({show_submit: 0}); //让提交先掩藏 + th.setData({ show_submit: 0 }); //让提交先掩藏 th.data.g_cart_q_time = null; if (th.data.isclose == 0) { wx.navigateTo({ - url:"/pages/index/index/index" + url: "/pages/index/index/index" }) - }else{ + } else { this.getuser_addr(function (ie) { //地址切换要把包邮券清空 if (!th.data.user_addr || !ie || th.data.user_addr.address_id != ie.address_id) { @@ -178,16 +178,16 @@ Page({ th.data.prom_goods_map = {}; th.data.is_summit_ing = 0; //更换地址回来要重新调用计算价钱的接口 - if (!th.data.user_addr || th.data.user_addr.address_id != ie.address_id){ - th.setData({user_addr: ie}); - th.setData({add_back: 1}); - th.calculatePrice2(); + if (!th.data.user_addr || th.data.user_addr.address_id != ie.address_id) { + th.setData({ user_addr: ie }); + th.setData({ add_back: 1 }); + th.calculatePrice2(); } else { - th.setData({user_addr: ie}); + th.setData({ user_addr: ie }); } var going = 0; }); - + var is_card_back = getApp().globalData.is_card_back; //--更新默认地址--,看一下是不是跳到地址页面,同时也不是购买等级卡返回的,这里很重要,否则会重新更新收货物流公司 if (!getApp().globalData.is_cart_old && !is_card_back && !getApp().globalData.plus_buy_back) { @@ -210,7 +210,7 @@ Page({ sales_rules: ee.sales_rules, rank_switch: json_d.rank_switch, is_default_logistics: is_default_logistics, - sys_switch:json_d, + sys_switch: json_d, }); var rank_switch = json_d.rank_switch; @@ -223,34 +223,34 @@ Page({ //-- 获取所有的等级卡, -- getApp().request.promiseGet("/api/weshop/plus/vip/mem/bership/list?storeId=" + os.stoid, {}).then(res => { - if (res.data.code == 0) { - var plusCard = res.data.data; - //-- 循环判断,拿到最贵的那张卡 -- - for (var ih in plusCard) { - if (plusCard[ih].IsStopBuy == true) { - continue; - } - if (max_price < 0) { - max_price = plusCard[ih].CardFee; - name = 'card' + plusCard[ih]['CorrPrice']; - show_card = plusCard[ih]; - } else { - if (max_price < plusCard[ih].CardFee) { + if (res.data.code == 0) { + var plusCard = res.data.data; + //-- 循环判断,拿到最贵的那张卡 -- + for (var ih in plusCard) { + if (plusCard[ih].IsStopBuy == true) { + continue; + } + if (max_price < 0) { max_price = plusCard[ih].CardFee; name = 'card' + plusCard[ih]['CorrPrice']; show_card = plusCard[ih]; + } else { + if (max_price < plusCard[ih].CardFee) { + max_price = plusCard[ih].CardFee; + name = 'card' + plusCard[ih]['CorrPrice']; + show_card = plusCard[ih]; + } } } - } - if (show_card) { - name = name.toLowerCase(); - th.setData({card_name: name, show_card: show_card}) + if (show_card) { + name = name.toLowerCase(); + th.setData({ card_name: name, show_card: show_card }) + } } - } - //-----先获取物流,再获取用户信息,再展示页面----- - th.get_wuliu(th.get_info(th.show_page)); - }) + //-----先获取物流,再获取用户信息,再展示页面----- + th.get_wuliu(th.get_info(th.show_page)); + }) } else { //-----先获取物流,再获取用户信息,再展示页面----- th.get_wuliu(th.get_info(th.show_page)); @@ -270,10 +270,10 @@ Page({ if (th.data.is_default_logistics) { //如果第一个不是开启默认,说明要让用户自己选 if (!e[0].is_default) { - th.setData({is_default_logistics: 0}); + th.setData({ is_default_logistics: 0 }); } } - th.setData({wu_arr: e}) + th.setData({ wu_arr: e }) typeof func == "function" && func(); }) }, @@ -287,9 +287,9 @@ Page({ getuser_addr: function (func) { var th = this; a.get("/api/weshop/useraddress/page", { - data: {user_id: to.globalData.user_id, store_id: oo.stoid, pageSize: 600, t: Math.random()}, + data: { user_id: to.globalData.user_id, store_id: oo.stoid, pageSize: 600, t: Math.random() }, success: function (su) { - + var item = null; if (su.data.code == 0 && su.data.data && su.data.data.pageData) { var user_addr = su.data.data.pageData; @@ -308,7 +308,7 @@ Page({ } if (item == undefined) item = null; - if (!item) th.setData({user_addr: null}); //地址为空的时候,要清空,因为返回的时候,有缓存 + if (!item) th.setData({ user_addr: null }); //地址为空的时候,要清空,因为返回的时候,有缓存 func(item); } @@ -336,7 +336,7 @@ Page({ }); } //获取立即购买的商品信息 - th.get_buy_goods(th.data.order_id,th.data.order_sn); + th.get_buy_goods(th.data.order_id, th.data.order_sn); }); //获取提现金额 getApp().request.get("/api/weshop/withdrawals/summoney", { @@ -360,30 +360,30 @@ Page({ }, //-----获取商品------ - async get_buy_goods(ord,o_sn) { + async get_buy_goods(ord, o_sn) { var order = null, order_goods = null, goods = null, pickup = null, distr_type = 0, exp_type = 0, - presell=null, //订单从表 - pre_arr=null, //订单内容 - act=null, //订单内容 + presell = null, //订单从表 + pre_arr = null, //订单内容 + act = null, //订单内容 th = this; - if(o_sn){ + if (o_sn) { //获取order信息根据订单编号order_sn await getApp().request.promiseGet("/api/weshop/order/page", { - data: { store_id: os.stoid, order_sn: o_sn,} + data: { store_id: os.stoid, order_sn: o_sn, } }).then(res => { order = res.data.data.pageData[0]; }) - ord=order.order_id; - }else{ + ord = order.order_id; + } else { //---获取订单--- await getApp().request.promiseGet("/api/weshop/order/get/" + oo.stoid + "/" + ord, {}).then(res => { order = res.data.data; @@ -399,94 +399,94 @@ Page({ order_goods = res.data.data.pageData[0]; }); - await getApp().request.promiseGet("/api/weshop/order/orderPresell/get/"+oo.stoid+"/"+order.order_id, {}).then(res => { + await getApp().request.promiseGet("/api/weshop/order/orderPresell/get/" + oo.stoid + "/" + order.order_id, {}).then(res => { presell = res.data.data; }); //等待定金 - if(order.order_status<2 && presell.deposit_pay_time<=0 ){ - th.setData({wait_dj:1}) + if (order.order_status < 2 && presell.deposit_pay_time <= 0) { + th.setData({ wait_dj: 1 }) } //等待尾款 - if(order.order_status<2 && presell.deposit_pay_time>0 && presell.tail_pay_state==0 && presell.presell_type!=1){ - th.setData({wait_wk:1}) - wx.setNavigationBarTitle({title: "支付尾款",}) + if (order.order_status < 2 && presell.deposit_pay_time > 0 && presell.tail_pay_state == 0 && presell.presell_type != 1) { + th.setData({ wait_wk: 1 }) + wx.setNavigationBarTitle({ title: "支付尾款", }) } //等待发货 - if(order.pay_status==1 && order.shipping_status==0){ - th.setData({wait_fh:1}) + if (order.pay_status == 1 && order.shipping_status == 0) { + th.setData({ wait_fh: 1 }) } - if(order.pay_status==1 && order.shipping_status==1 && order.order_status<2){ - th.setData({wait_sh:1}) + if (order.pay_status == 1 && order.shipping_status == 1 && order.order_status < 2) { + th.setData({ wait_sh: 1 }) } //------获取预售主表---------- - await getApp().request.promiseGet("/api/weshop/marketing/marketingPresellForm/get/"+os.stoid+"/"+presell.prom_id, {}).then(res => { + await getApp().request.promiseGet("/api/weshop/marketing/marketingPresellForm/get/" + os.stoid + "/" + presell.prom_id, {}).then(res => { if (res.data.code == 0 && res.data.data) { - act=res.data.data; + act = res.data.data; th.setData({ - act: res.data.data, + act: res.data.data, }); } }) //-- 判断一下会员的身份 -- - if(order.pay_status==0){ - var pre_data = { store_id: os.stoid, presell_id: presell.prom_id,timetype: 12, goods_id: order_goods.goods_id }; + if (order.pay_status == 0) { + var pre_data = { store_id: os.stoid, presell_id: presell.prom_id, timetype: 12, goods_id: order_goods.goods_id }; pre_data.user_id = order.user_id; - var isok=1; + var isok = 1; await getApp().request.promiseGet("/api/weshop/marketing/marketingPresellList/page", { data: pre_data, }).then(e => { if (e.data.code == 0 && e.data.data.pageData && e.data.data.pageData.length > 0) { pre_arr = e.data.data.pageData[0]; - }else{ - isok=0; + } else { + isok = 0; } }) - if(!isok){ + if (!isok) { getApp().confirmBox("会员身份不符合"); return false; } - if(th.data.wait_dj){ - if(act.is_end) { + if (th.data.wait_dj) { + if (act.is_end) { getApp().confirmBox("活动已经结束"); return false; } - if(!act.isuse) { + if (!act.isuse) { getApp().confirmBox("活动未启用"); return false; } - if(th.data.act.end_time{ + else { + await getApp().request.promiseGet("/api/weshop/marketing/marketingPresellList/list", { + data: { store_id: os.stoid, goods_id: order_goods.goods_id, presell_id: order_goods.prom_id } + }).then(re => { if (re.data.code == 0 && re.data.data && re.data.data.length > 0) { pre_arr = re.data.data[0]; } }) - if(!pre_arr){ + if (!pre_arr) { getApp().confirmBox("未找到商品"); return false; } @@ -498,28 +498,29 @@ Page({ order.market_price = goods.market_price; order.show_img = oo.imghost + goods.original_img; }); - - - var g_url="/packageC/pages/presell/goodsInfo/goodsInfo?goods_id="+order_goods.goods_id+"&pre_id="+pre_arr.id; - if(act.is_end || th.data.act.end_time{ - var ttd=rss; + await getApp().request.promiseGet("/api/weshop/order/returngoods/page", { + data: { + order_id: order.order_id, store_id: oo.stoid, + user_id: order.user_id, pageSize: 200 + } + }).then(rss => { + var ttd = rss; //----没有相关的退款记录---- - if (ttd.data.data.total==0){ + if (ttd.data.data.total == 0) { order['is_all_return'] = 0; - }else{ + } else { var eea = ttd.data.data.pageData[0]; //1.退款正在进行中, //2.退款被拒绝就要显示可以退款 //3.退款已经完成 - order['is_all_return']=1; + order['is_all_return'] = 1; order['is_all_return_status'] = ttd.data.data.pageData[0].status; if (order['order_status'] == 1 && order['pay_status'] == 1) { switch (eea.status) { case 0: case 1: - order.order_status_detail="退款中"; + order.order_status_detail = "退款中"; order['return_btn'] = 2; break; case 2: - order.order_status_detail="退款完成"; + order.order_status_detail = "退款完成"; order['return_btn'] = 4; break; case 3: order['return_btn'] = 3; break; @@ -563,8 +566,8 @@ Page({ } }) - var price=presell.presell_price; - if(!goods) return false; + var price = presell.presell_price; + if (!goods) return false; //--判断物流-- if (goods.distr_type) distr_type = goods.distr_type; @@ -587,50 +590,50 @@ Page({ } //等待发货的时候 - if(th.data.wait_fh){ - var send_time=th.data.act.delivery_date; - if(th.data.act.delivery_type==2){ - send_time=ut.gettimestamp()+th.data.act.delivery_daynum*3600*24; - } + if (th.data.wait_fh) { + var send_time = th.data.act.delivery_date; + if (th.data.act.delivery_type == 2) { + send_time = ut.gettimestamp() + th.data.act.delivery_daynum * 3600 * 24; + } } order.order_goods = order_goods; - var tail_pay=pre_arr.presell_price*order_goods.goods_num-presell.presell_deposit; + var tail_pay = pre_arr.presell_price * order_goods.goods_num - presell.presell_deposit; this.setData({ order: order, distr_type: distr_type, pickup: pickup, exp_type: exp_type, goods: goods, - presell:presell, - pre_arr:pre_arr, - show_submit:1, - userInfo:getApp().globalData.userInfo, - tail_pay:tail_pay, - order_goods:order_goods, - all_price:pre_arr.presell_price*order_goods.goods_num, - pickup_id:pickup.pickup_id, - send_time:send_time, - g_url:g_url + presell: presell, + pre_arr: pre_arr, + show_submit: 1, + userInfo: getApp().globalData.userInfo, + tail_pay: tail_pay, + order_goods: order_goods, + all_price: pre_arr.presell_price * order_goods.goods_num, + pickup_id: pickup.pickup_id, + send_time: send_time, + g_url: g_url }); th.get_diff(); //统一进行计算金额 th.calculatePrice2(); //如果可以 - if(th.data.act.is_usecoupon){ + if (th.data.act.is_usecoupon) { th.get_buy_now_quan(); } }, - async calculatePrice2(){ - var th=this; - if(!this.data.pre_arr) return false; + async calculatePrice2() { + var th = this; + if (!this.data.pre_arr) return false; //--计算物流-- if (this.data.exp_type == 0) { this.calculate_wuliu(); } else { - var allpice =this.data.pre_arr.presell_price*this.data.order_goods.goods_num; + var allpice = this.data.pre_arr.presell_price * this.data.order_goods.goods_num; allpice = allpice.toFixed(2); //--看一下有没有订单优惠-- var o_condition = parseFloat(allpice); @@ -654,37 +657,37 @@ Page({ quan_price = res.data.data[0].WareCashSum; } }) - }else{ - th.setData({quan_price:0}); - if(th.data.using_quan && th.data.using_quan[bn_pick] && th.data.using_quan[bn_pick].isby==1){ - var txt="using_quan["+bn_pick+"]"; - th.setData({[txt]:{}}); + } else { + th.setData({ quan_price: 0 }); + if (th.data.using_quan && th.data.using_quan[bn_pick] && th.data.using_quan[bn_pick].isby == 1) { + var txt = "using_quan[" + bn_pick + "]"; + th.setData({ [txt]: {} }); } } - if(quan_price>0){ - if (quan_price < th.data.tail_pay) th.setData({quan_price: quan_price}) - else { - th.setData({quan_price: th.data.tail_pay}) - } - o_condition=o_condition-quan_price; + if (quan_price > 0) { + if (quan_price < th.data.tail_pay) th.setData({ quan_price: quan_price }) + else { + th.setData({ quan_price: th.data.tail_pay }) + } + o_condition = o_condition - quan_price; - }else{ - th.setData({quan_price: 0}) + } else { + th.setData({ quan_price: 0 }) } - if(o_condition<0) o_condition=0; + if (o_condition < 0) o_condition = 0; //如果同意参与订单优惠 if (o_condition > 0 && this.data.pre_arr.is_useorderyh) { th.check_is_order_prom(o_condition, function (ord_price) { - var bn_pick=th.data.pickup.pickup_id + var bn_pick = th.data.pickup.pickup_id var order_prom_amount = 0; var order_prom_id = 0; - var o_condition1=0; + var o_condition1 = 0; if (th.data.order_prom[bn_pick]) { var ord_prom = th.data.order_prom[bn_pick]; - if(!ord_prom.is_xz_yh || quan_price<=0) { + if (!ord_prom.is_xz_yh || quan_price <= 0) { order_prom_id = ord_prom['id']; switch (ord_prom['type']) { case 0: @@ -703,19 +706,19 @@ Page({ var order_prom_txt1 = "order_prom_id"; var order_prom_txt2 = "order_prom_amount"; if (order_prom_id > 0) { - th.setData({[order_prom_txt1]: order_prom_id, [order_prom_txt2]: order_prom_amount}) - }else{ - o_condition1=ord_price; - th.setData({[order_prom_txt1]: 0, [order_prom_txt2]: 0}) + th.setData({ [order_prom_txt1]: order_prom_id, [order_prom_txt2]: order_prom_amount }) + } else { + o_condition1 = ord_price; + th.setData({ [order_prom_txt1]: 0, [order_prom_txt2]: 0 }) } - - o_condition1=parseFloat(o_condition1)-parseFloat(th.data.presell.presell_deposit); - if(o_condition1<0) o_condition1=0; - th.setData({ exp_price: 0, order_m: o_condition1 }) + + o_condition1 = parseFloat(o_condition1) - parseFloat(th.data.presell.presell_deposit); + if (o_condition1 < 0) o_condition1 = 0; + th.setData({ exp_price: 0, order_m: o_condition1 }) }) - }else{ - o_condition=parseFloat(o_condition)-parseFloat(th.data.presell.presell_deposit); - if(o_condition<0) o_condition=0; + } else { + o_condition = parseFloat(o_condition) - parseFloat(th.data.presell.presell_deposit); + if (o_condition < 0) o_condition = 0; th.setData({ exp_price: 0, order_m: o_condition }) } } @@ -725,14 +728,14 @@ Page({ checkAddressList: function () { var t = this; return !(!this.data.order || null == this.data.order.userAddress) || (wx.showModal({ - title: "请先填写或选择收货地址~", - success: function (a) { - a.confirm ? t.enterAddressPage() : wx.navigateBack(); - }, - fail: function () { - wx.navigateBack(); - } - }), !1); + title: "请先填写或选择收货地址~", + success: function (a) { + a.confirm ? t.enterAddressPage() : wx.navigateBack(); + }, + fail: function () { + wx.navigateBack(); + } + }), !1); }, showInvoice: function () { this.setData({ @@ -752,7 +755,7 @@ Page({ keyUpChangeNum: function (t) { this.setData({ maxWord: t.detail.value.length, - user_note:t.detail.value + user_note: t.detail.value }); }, @@ -781,7 +784,7 @@ Page({ } } var set_txt = "cartlist[" + iter + "].can_num"; - th.setData({[set_txt]: num}); + th.setData({ [set_txt]: num }); } }, useCoupon: function () { @@ -798,7 +801,7 @@ Page({ }); }, enterAddressPage: function () { - if(!this.data.wait_wk) return false; + if (!this.data.wait_wk) return false; getApp().globalData.is_cart_old = 1; this.data.isget_by_quan = {}; @@ -811,9 +814,9 @@ Page({ setexptype: function (t) { var th = this; var ty = t.currentTarget.dataset.t, def_exp_code = getApp().globalData.userInfo.def_exp_code; - th.setData({bn_exp_type: ty}); + th.setData({ bn_exp_type: ty }); if (ty == 0) { - th.setData({is_all_zt: 0}); + th.setData({ is_all_zt: 0 }); } //当物流为空的时候。 @@ -826,7 +829,7 @@ Page({ if (ty == 1) { th.data.isget_by_quan = {}; if (th.data.using_quan[bn_pick] && th.data.using_quan[bn_pick].isby == 1) { - th.setData({using_quan: {}}); + th.setData({ using_quan: {} }); } } @@ -836,7 +839,7 @@ Page({ if (wu_arr != null && wu_arr != "") { for (var i = 0; i < wu_arr.length; i++) { if (wu_arr[i].shipping_code == def_exp_code) { - th.setData({index: i}); + th.setData({ index: i }); } } } @@ -848,16 +851,16 @@ Page({ //--------立即购买时,使用余额-------- set_bn_useyuer: function () { var th = this; - th.setData({bn_use_money: !th.data.bn_use_money}); + th.setData({ bn_use_money: !th.data.bn_use_money }); th.calculatePrice2(); }, - //-------------------计算物流--------------- - calculatewuliu: function (code, o_shipping_price, goods_weight,out_of_weight, - goods_piece, user_addr, freight_free, o_price, rs) { + //-----------------计算物流------------- + calculatewuliu: function (code, o_shipping_price, goods_weight, out_of_weight, + goods_piece, user_addr, freight_free, o_price, rs, pickid) { var price = 0, th = this; price += parseFloat(o_shipping_price); //如果是包邮 - if (freight_free > 0 && o_price >= freight_free && out_of_weight>=0) { + if (freight_free > 0 && o_price >= freight_free && out_of_weight >= 0) { return 0; } if (user_addr == null) { @@ -884,7 +887,7 @@ Page({ } } //------超出重量---------- - if(out_of_weight < 0 && o_price >= freight_free){ + if (out_of_weight < 0 && o_price >= freight_free && !th.data.is_no_by[pickid]) { fw_price = parseFloat(item['money']); var out_of_weight = Math.abs(out_of_weight); if (out_of_weight > item['first_weight']) { @@ -930,7 +933,7 @@ Page({ //----------立即购买,选择物流------------- bindPickerChange: function (e) { var ind = e.detail.value - this.setData({index: ind}); + this.setData({ index: ind }); this.calculatePrice2(); }, /*----券的所有操作----*/ @@ -943,7 +946,7 @@ Page({ if (bn == 1) { - th.setData({open_quan: 1, selected_quan_pick: pickid, disabled: 1}); + th.setData({ open_quan: 1, selected_quan_pick: pickid, disabled: 1 }); } else { //---多单打开券的时候,就要判断券在其他门店是否有使用--- var quanlist = th.data.cartlist[cindx].quan_list; @@ -969,9 +972,9 @@ Page({ else get_by_quan_list_cart[i].show_red = 0; } - th.setData({by_quan_list_cart: get_by_quan_list_cart}); + th.setData({ by_quan_list_cart: get_by_quan_list_cart }); } else { - th.setData({by_quan_list_cart: null}); + th.setData({ by_quan_list_cart: null }); } th.setData({ @@ -986,7 +989,7 @@ Page({ }, close_coupon: function (e) { var th = this; - th.setData({open_quan: 0, disabled: 0}); + th.setData({ open_quan: 0, disabled: 0 }); }, //---判断券时候在已经选择的列表中--- @@ -1016,14 +1019,14 @@ Page({ for (var i in quanlist) { quanlist[i].show_red = 0; } - this.setData({selected_quan_list: quanlist}); + this.setData({ selected_quan_list: quanlist }); var by_quanlist = this.data.get_by_quan_list; if (by_quanlist) { //---所有的券的显示红色选择都清理一遍--- for (var inb in by_quanlist) { by_quanlist[inb].show_red = 0; } - this.setData({get_by_quan_list: by_quanlist}); + this.setData({ get_by_quan_list: by_quanlist }); } var by_cart_list = this.data.by_quan_list_cart; @@ -1032,7 +1035,7 @@ Page({ for (var inc in by_cart_list) { by_cart_list[inc].show_red = 0; } - this.setData({by_quan_list_cart: by_cart_list}); + this.setData({ by_quan_list_cart: by_cart_list }); } var using_quan = this.data.using_quan; @@ -1043,9 +1046,9 @@ Page({ using_quan[pickid].is_nouse_red = 1; } else { - using_quan[pickid] = {is_nouse_red: 1}; + using_quan[pickid] = { is_nouse_red: 1 }; } - this.setData({using_quan: using_quan, is_coupon: 2222}); + this.setData({ using_quan: using_quan, is_coupon: 2222 }); return; } @@ -1062,9 +1065,9 @@ Page({ using_quan[pickid].is_nouse_red = 0; } else { - using_quan[pickid] = {is_nouse_red: 0}; + using_quan[pickid] = { is_nouse_red: 0 }; } - this.setData({using_quan: using_quan}); + this.setData({ using_quan: using_quan }); }, /*----- 点击选择包邮券 -----*/ @@ -1077,7 +1080,7 @@ Page({ for (var ind in by_quanlist) { by_quanlist[ind].show_red = 0; } - this.setData({get_by_quan_list: by_quanlist}); + this.setData({ get_by_quan_list: by_quanlist }); } //--购物车过来的包邮券-- @@ -1087,7 +1090,7 @@ Page({ for (var ind in by_cart_list) { by_cart_list[ind].show_red = 0; } - this.setData({by_quan_list_cart: by_cart_list}); + this.setData({ by_quan_list_cart: by_cart_list }); } //普通券 var quanlist = this.data.selected_quan_list; @@ -1096,7 +1099,7 @@ Page({ for (var ind in quanlist) { quanlist[ind].show_red = 0; } - this.setData({selected_quan_list: quanlist}); + this.setData({ selected_quan_list: quanlist }); } var th = this; @@ -1107,9 +1110,9 @@ Page({ using_quan[th.data.selected_quan_pick].is_nouse_red = 1; } else { - using_quan[th.data.selected_quan_pick] = {is_nouse_red: 1}; + using_quan[th.data.selected_quan_pick] = { is_nouse_red: 1 }; } - this.setData({using_quan: using_quan, is_coupon: 2222}); + this.setData({ using_quan: using_quan, is_coupon: 2222 }); return; } @@ -1120,20 +1123,20 @@ Page({ var txt1 = ""; var quan_item = null; - quan_item = this.data.get_by_quan_list[ind]; - txt = "get_by_quan_list[" + ind + "].show_red"; - var obj = {}; - obj[txt] = 1; - this.setData(obj); + quan_item = this.data.get_by_quan_list[ind]; + txt = "get_by_quan_list[" + ind + "].show_red"; + var obj = {}; + obj[txt] = 1; + this.setData(obj); if (using_quan[th.data.selected_quan_pick]) { using_quan[th.data.selected_quan_pick].is_nouse_red = 0; } else { - using_quan[th.data.selected_quan_pick] = {is_nouse_red: 0}; + using_quan[th.data.selected_quan_pick] = { is_nouse_red: 0 }; } - this.setData({using_quan: using_quan}); + this.setData({ using_quan: using_quan }); }, //--确认使用券--- confirm_quan: function () { @@ -1190,10 +1193,10 @@ Page({ //选择了的券,看是不是点击了不使用券,点击了不使用优惠券 if (using_quan[pickid]) { if (using_quan[pickid].is_nouse_red == 1) { - using_quan[pickid] = {is_nouse_red: 1}; + using_quan[pickid] = { is_nouse_red: 1 }; th.calculatePrice2(); - th.setData({open_quan: 0}); - th.setData({using_quan: using_quan}); + th.setData({ open_quan: 0 }); + th.setData({ using_quan: using_quan }); } } @@ -1214,12 +1217,12 @@ Page({ }; using_quan[pickid].isby = 1; } else { - using_quan[pickid] = {coupon_no: item.CashRepNo, money: item.Sum, is_nouse_red: 0}; + using_quan[pickid] = { coupon_no: item.CashRepNo, money: item.Sum, is_nouse_red: 0 }; using_quan[pickid].isby = 0; } - this.setData({using_quan: using_quan}); + this.setData({ using_quan: using_quan }); th.calculatePrice2(); - th.setData({open_quan: 0}); + th.setData({ open_quan: 0 }); }, cart_set_err: function (e) { @@ -1256,7 +1259,7 @@ Page({ var wu_arr_txt = e.currentTarget.dataset.txt; var w_sele_index = e.currentTarget.dataset.w_sele_index; var is_express = null; - var ob = {open_express: 1, wu_arr_txt: wu_arr_txt, disabled: 1}; + var ob = { open_express: 1, wu_arr_txt: wu_arr_txt, disabled: 1 }; //--如果是多个门店的时候-- if (w_sele_index != undefined) { @@ -1267,21 +1270,21 @@ Page({ }, // 关闭物流的弹窗 close_express: function () { - this.setData({open_express: 0, disabled: 0}); + this.setData({ open_express: 0, disabled: 0 }); }, // 选择物流 click_express_name: function (e) { var express_name = e.currentTarget.dataset.name, shippingcode = e.currentTarget.dataset.shippingcode; var index = e.currentTarget.dataset.idxe; - var ob = {is_express: index, is_shipping_code: shippingcode, disabled: 0}; + var ob = { is_express: index, is_shipping_code: shippingcode, disabled: 0 }; ob[this.data.wu_arr_txt] = index; this.setData(ob); }, //点击确定物流 determine_expres: function (e) { - this.setData({open_express: 0}); - this.calculatePrice2(); + this.setData({ open_express: 0 }); + this.calculatePrice2(); }, //点击打开优惠券使用说明 @@ -1297,7 +1300,7 @@ Page({ obj[txt] = is_open; this.setData(obj); - this.setData({disabled: 1}) + this.setData({ disabled: 1 }) }, clik_coupons2: function (e) { @@ -1312,7 +1315,7 @@ Page({ obj[txt] = is_open; this.setData(obj); - this.setData({disabled: 1}) + this.setData({ disabled: 1 }) }, @@ -1321,11 +1324,11 @@ Page({ var th = this; var is_shipping_code = this.data.is_shipping_code getApp().request.put("/api/weshop/users/update", { - data: {user_id: getApp().globalData.user_id, store_id: oo.stoid, def_exp_code: is_shipping_code}, + data: { user_id: getApp().globalData.user_id, store_id: oo.stoid, def_exp_code: is_shipping_code }, success: function (rse) { if (rse.data.code == 0) { getApp().globalData.userInfo.def_exp_code = is_shipping_code; - th.setData({open_express: 0}); + th.setData({ open_express: 0 }); //----计算此时购物车的价格---- th.calculatePrice2(); @@ -1335,7 +1338,7 @@ Page({ }, //更新下默认,在onshow里面 - update_code(){ + update_code() { var th = this, m_wind = 0, def_exp_code = getApp().globalData.userInfo.def_exp_code; //--定时器,判断wu_arr不未空-- var uii = setInterval(function () { @@ -1349,7 +1352,7 @@ Page({ } //--如果是立即购买-- if (th.data.is_b_now == 1) { - th.setData({index: m_wind, is_express: m_wind}); + th.setData({ index: m_wind, is_express: m_wind }); } else { var ui = setInterval(function () { if (th.data.cartlist) { @@ -1357,7 +1360,7 @@ Page({ for (var i in c_arr) { c_arr[i].wind = m_wind; } - th.setData({cartlist: c_arr, is_express: m_wind}) + th.setData({ cartlist: c_arr, is_express: m_wind }) clearInterval(ui); } }, 500) @@ -1458,10 +1461,10 @@ Page({ if (th.data.is_b_now) { if (arr && arr.length > 0) { var quanlist = arr[0].quan_list; - th.setData({selected_quan_list: quanlist, cartlist: arr}) + th.setData({ selected_quan_list: quanlist, cartlist: arr }) } } else { - th.setData({cartlist: arr}) + th.setData({ cartlist: arr }) th.set_can_num(); } }, @@ -1469,14 +1472,14 @@ Page({ //------ 获取立即购买的购物车的劵 -------- get_buy_now_quan: function () { var quanlist = null, th = this, frozenQuan = null; - var allprice =this.data.pre_arr.presell_price*this.data.order_goods.goods_num; + var allprice = this.data.pre_arr.presell_price * this.data.order_goods.goods_num; th.data.ckeck_quan_price = allprice; //--如果商家后台没有限制使用优惠券,同时商品的优惠活动没有限制使用优惠券-- if (th.data.is_close_quan != 1) { var url0 = "/api/weshop/users/frozenQuan/listFrozenQuan/" + app.globalData.user_id; var url = "/api/weshop/couponList/getUseCouponList"; - app.request.promiseGet(url0, {1: 1}).then(res => { + app.request.promiseGet(url0, { 1: 1 }).then(res => { if (res.data.code == 0) { frozenQuan = res.data.data; th.data.frozenQuan = frozenQuan; @@ -1494,7 +1497,7 @@ Page({ quanlist = res.data.data.pageData; if (quanlist) { quanlist = th.check_is_frozenQuan(quanlist, frozenQuan); - th.setData({selected_quan_list: quanlist}) + th.setData({ selected_quan_list: quanlist }) } } } @@ -1522,7 +1525,7 @@ Page({ if (!goods_id) goods_id = this.data.bn_goods.goods_id; for (var i in arr) { var item = arr[i]; - if (goods_id == item) return 0; + if (goods_id == item) return 0; } return 1; }, @@ -1544,14 +1547,14 @@ Page({ pick = this.data.pickup.pickup_id; //---获取订单优惠--- getApp().request.promiseGet("/api/weshop/promorder/getOrderPromotion", { - data: {store_id: os.stoid, orderAmount: condition} + data: { store_id: os.stoid, orderAmount: condition } }).then(res => { if (res.data.code == 0) { var data = res.data.data; th.data.order_prom[pick] = data; - }else{ - th.data.order_prom[pick] = null; - } + } else { + th.data.order_prom[pick] = null; + } func(condition); }) }, @@ -1568,7 +1571,7 @@ Page({ var ob = map[pickid][item.prom_id]; ob.price += item.goods_price * item.goods_num; ob.goods_num += item.goods_num; - ob.goods.push({goods_id: item.goods_id, goods_price: item.goods_price, goods_num: item.goods_num}); + ob.goods.push({ goods_id: item.goods_id, goods_price: item.goods_price, goods_num: item.goods_num }); } else { var prom = null; @@ -1584,7 +1587,7 @@ Page({ ob.is_bz = prom.is_bz; ob.is_xz_yh = prom.is_xz_yh; ob.goods = new Array(); - ob.goods.push({goods_id: item.goods_id, goods_price: item.goods_price, goods_num: item.goods_num}); + ob.goods.push({ goods_id: item.goods_id, goods_price: item.goods_price, goods_num: item.goods_num }); map[pickid][item.prom_id] = ob; } } else { @@ -1601,7 +1604,7 @@ Page({ ob.is_bz = prom.is_bz; ob.is_xz_yh = prom.is_xz_yh; ob.goods = new Array(); - ob.goods.push({goods_id: item.goods_id, goods_price: item.goods_price, goods_num: item.goods_num}); + ob.goods.push({ goods_id: item.goods_id, goods_price: item.goods_price, goods_num: item.goods_num }); var obj = {}; obj[item.prom_id] = ob; @@ -1645,7 +1648,7 @@ Page({ if (no_by_data && no_by_data.region_list) { if (th.check_by_area(no_by_data.region_list)) { gift_freight_free = 0; - out_of_weight=0; + out_of_weight = 0; th.data.is_no_by[bn_pick] = 1; } } @@ -1653,13 +1656,14 @@ Page({ if (no_by_data && no_by_data.goods_list && gift_freight_free) { if (th.check_by_goods(no_by_data.goods_list, good.goods_id)) { gift_freight_free = 0; - out_of_weight=0; + out_of_weight = 0; + th.data.is_no_by[bn_pick] = 1; } } var t_shipping_price = - this.calculatewuliu(code, gift_shipping_price, goods_weight,out_of_weight, - goods_piece, user_addr, gift_freight_free, allpice, rs); + this.calculatewuliu(code, gift_shipping_price, goods_weight, out_of_weight, + goods_piece, user_addr, gift_freight_free, allpice, rs,th.data.bn_pick); return t_shipping_price; }, @@ -1719,13 +1723,13 @@ Page({ goods_weight = -1, goods_piece = -1, good = th.data.goods, - quan_price=0, - exp_price=0; + quan_price = 0, + exp_price = 0; var quan_no = null; - var bn_pick=th.data.pickup.pickup_id; - var allpice =th.data.all_price; - var out_of_weight=null; //超出多少重量 + var bn_pick = th.data.pickup.pickup_id; + var allpice = th.data.all_price; + var out_of_weight = null; //超出多少重量 var freight_free = ee.freight_free; //全场满多少包邮 var weight_free = ee.weight_free; //多少kg内包邮 @@ -1749,19 +1753,19 @@ Page({ }) if (quan_price > 0) { - if (quan_price < th.data.tail_pay) th.setData({quan_price: quan_price}) + if (quan_price < th.data.tail_pay) th.setData({ quan_price: quan_price }) else { - th.setData({quan_price: th.data.tail_pay}) + th.setData({ quan_price: th.data.tail_pay }) quan_price = th.data.tail_pay; } } else { - th.setData({quan_price: 0}) + th.setData({ quan_price: 0 }) } - }else{ - th.setData({quan_price: 0}) + } else { + th.setData({ quan_price: 0 }) } - }else{ - th.setData({quan_price: 0}) + } else { + th.setData({ quan_price: 0 }) } //-----------当地址不为空,且是物流时,计算物流费用---------- @@ -1790,15 +1794,15 @@ Page({ arr.push(item); } if (arr) { - th.setData({get_by_quan_list: arr}); + th.setData({ get_by_quan_list: arr }); } th.data.isget_by_quan[bn_pick] = 1; } }) } if (quan_no && th.data.using_quan[bn_pick].isby == 1) { - exp_price=0; - }else{ + exp_price = 0; + } else { switch (good['exp_sum_type']) { case 1: //统一运费 @@ -1808,8 +1812,8 @@ Page({ if (goods_weight < 0) goods_weight = 0; //累积商品重量 每种商品的重量 * 数量 goods_weight += good['weight'] * th.data.order.order_goods['goods_num']; - if(weight_free > 0){ - out_of_weight = (weight_free * 1000 ) - goods_weight; + if (weight_free > 0) { + out_of_weight = (weight_free * 1000) - goods_weight; } break; case 3: @@ -1821,33 +1825,33 @@ Page({ var code = th.data.wu_arr[th.data.index].code; var shipping_price = - th.calculatewuliu(code, o_shipping_price, goods_weight,out_of_weight, + th.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, goods_piece, th.data.user_addr, freight_free, allpice, rs); exp_price = parseFloat(shipping_price).toFixed(2); } - th.wuliu_next(allpice,quan_price,exp_price); + th.wuliu_next(allpice, quan_price, exp_price); } else { - th.wuliu_next(allpice,quan_price,exp_price); + th.wuliu_next(allpice, quan_price, exp_price); } }); }); }, //相同的东西统一在一起 - wuliu_next( allpice,quan_price,exp_price){ - var th=this; - var o_condition =parseFloat(allpice)-parseFloat(quan_price); - if(o_condition<0) o_condition=0; + wuliu_next(allpice, quan_price, exp_price) { + var th = this; + var o_condition = parseFloat(allpice) - parseFloat(quan_price); + if (o_condition < 0) o_condition = 0; //如果同意参与订单优惠 if (o_condition > 0 && this.data.pre_arr.is_useorderyh) { th.check_is_order_prom(o_condition, function (ord_price) { - var bn_pick=th.data.pickup.pickup_id + var bn_pick = th.data.pickup.pickup_id var order_prom_amount = 0; var order_prom_id = 0; - var order_m=0; + var order_m = 0; if (th.data.order_prom[bn_pick]) { var ord_prom = th.data.order_prom[bn_pick]; //么有使用券,或者活动没有限制使用优惠券 - if(quan_price<=0 || !ord_prom.is_xz_yh) { + if (quan_price <= 0 || !ord_prom.is_xz_yh) { order_prom_id = ord_prom['id']; switch (ord_prom['type']) { case 0: @@ -1867,37 +1871,37 @@ Page({ if (order_prom_id > 0) { var order_prom_txt1 = "order_prom_id"; var order_prom_txt2 = "order_prom_amount"; - th.setData({[order_prom_txt1]: order_prom_id, [order_prom_txt2]: order_prom_amount}) - }else{ - var order_prom_txt1 = "order_prom_id"; - var order_prom_txt2 = "order_prom_amount"; - th.setData({[order_prom_txt1]: 0, [order_prom_txt2]: 0}) - } - - - ord_price=parseFloat(ord_price)-parseFloat(th.data.presell.presell_deposit); - if(ord_price<0) ord_price=0; - th.setData({ exp_price: exp_price, order_m: ord_price +parseFloat(exp_price) }) + th.setData({ [order_prom_txt1]: order_prom_id, [order_prom_txt2]: order_prom_amount }) + } else { + var order_prom_txt1 = "order_prom_id"; + var order_prom_txt2 = "order_prom_amount"; + th.setData({ [order_prom_txt1]: 0, [order_prom_txt2]: 0 }) + } + + + ord_price = parseFloat(ord_price) - parseFloat(th.data.presell.presell_deposit); + if (ord_price < 0) ord_price = 0; + th.setData({ exp_price: exp_price, order_m: ord_price + parseFloat(exp_price) }) }) - }else{ - - var o_condition1=parseFloat(o_condition)-parseFloat(th.data.presell.presell_deposit); - if(o_condition1<0) o_condition1=0; - th.setData({ exp_price: exp_price, order_m: parseFloat(o_condition1)+parseFloat(exp_price) }) + } else { + + var o_condition1 = parseFloat(o_condition) - parseFloat(th.data.presell.presell_deposit); + if (o_condition1 < 0) o_condition1 = 0; + th.setData({ exp_price: exp_price, order_m: parseFloat(o_condition1) + parseFloat(exp_price) }) } }, //-- 获取时间差 -- - get_diff(){ + get_diff() { switch (this.data.act.presell_type) { //部分定金 case 0: if (this.data.act.pay_begindate > ut.gettimestamp()) { - this.setData({no_start: 1}) + this.setData({ no_start: 1 }) } else if (this.data.act.pay_enddate < ut.gettimestamp()) { - this.setData({is_end: 1}) + this.setData({ is_end: 1 }) } else { var end_time = this.data.act.pay_enddate; var e_str = ut.formatTime(end_time); @@ -1908,15 +1912,15 @@ Page({ var hours = parseInt(difftime / 3600) - 24 * days; // 小时 60*60 总小时数-过去的小时数=现在的小时数 var minutes = parseInt(difftime % 3600 / 60); // 分钟 -(day*24) 以60秒为一整份 取余 剩下秒数 秒数/60 就是分钟数 var seconds = parseInt(difftime % 60); // 以60秒为一整份 取余 剩下秒数 - this.setData({days: days, hours: hours, minutes: minutes, seconds: seconds}) + this.setData({ days: days, hours: hours, minutes: minutes, seconds: seconds }) } break; //全额付款 case 1: if (this.data.act.start_time > ut.gettimestamp()) { - this.setData({no_start: 1}) + this.setData({ no_start: 1 }) } else if (this.data.act.end_time < ut.gettimestamp()) { - this.setData({is_end: 1}) + this.setData({ is_end: 1 }) } else { var end_time = this.data.act.end_time; var e_str = ut.formatTime(end_time); @@ -1927,7 +1931,7 @@ Page({ var hours = parseInt(difftime / 3600) - 24 * days; // 小时 60*60 总小时数-过去的小时数=现在的小时数 var minutes = parseInt(difftime % 3600 / 60); // 分钟 -(day*24) 以60秒为一整份 取余 剩下秒数 秒数/60 就是分钟数 var seconds = parseInt(difftime % 60); // 以60秒为一整份 取余 剩下秒数 - this.setData({days: days, hours: hours, minutes: minutes, seconds: seconds}) + this.setData({ days: days, hours: hours, minutes: minutes, seconds: seconds }) } break; @@ -1938,16 +1942,16 @@ Page({ //显示支付选择 show_pay: function () { //不用钱直接支付 - if(this.data.order_m<=0){ + if (this.data.order_m <= 0) { this.to_pay_type(1); - }else{ - this.setData({show_pay_type: 1}); + } else { + this.setData({ show_pay_type: 1 }); } }, //关闭支付 close_show_pay: function () { - this.setData({show_pay_type: 0}); + this.setData({ show_pay_type: 0 }); }, //--弹起支付框-- to_pay() { @@ -1956,7 +1960,7 @@ Page({ return getApp().my_warnning("请选择收货地址", 0, this); } - this.setData({show_pay_type: 1}); + this.setData({ show_pay_type: 1 }); }, //选择支付方式 @@ -1992,26 +1996,26 @@ Page({ dd.addressid = th.data.user_addr.address_id; } - if(th.data.order_prom_amount>0){ - var e={ - order_prom_id:th.data.order_prom_id, - order_prom_amount:th.data.order_prom_amount, + if (th.data.order_prom_amount > 0) { + var e = { + order_prom_id: th.data.order_prom_id, + order_prom_amount: th.data.order_prom_amount, } - dd.order_prom_list=e; + dd.order_prom_list = e; } - var bn_pick=th.data.pickup_id; - var quan_no=''; + var bn_pick = th.data.pickup_id; + var quan_no = ''; if (th.data.using_quan[bn_pick] != null && th.data.using_quan[bn_pick] != undefined) quan_no = th.data.using_quan[bn_pick].coupon_no; - if(quan_no){ - dd.coupon_no=quan_no; - if(th.data.quan_price) dd.coupon_price=th.data.quan_price; + if (quan_no) { + dd.coupon_no = quan_no; + if (th.data.quan_price) dd.coupon_price = th.data.quan_price; } - if(th.data.user_note){ - dd.user_note=th.data.user_note; + if (th.data.user_note) { + dd.user_note = th.data.user_note; } - dd.order_amount= parseFloat(th.data.order_m).toFixed(2); + dd.order_amount = parseFloat(th.data.order_m).toFixed(2); console.log(JSON.stringify(dd)); wx.request({ @@ -2031,25 +2035,25 @@ Page({ function () { //---用余额支付--- getApp().my_warnning("支付成功", 1, th); - var send_time=th.data.pre_arr.delivery_date; - if(th.data.pre_arr.delivery_type==2){ - send_time=th.data.pre_arr.delivery_daynum*3600; - } - th.setData({isclose: 0,'order.order_status':1,'order.pay_status':1,'wait_wk':0,'presell.tail_pay_state':1,'wait_fh':1,send_time:send_time}); - + var send_time = th.data.pre_arr.delivery_date; + if (th.data.pre_arr.delivery_type == 2) { + send_time = th.data.pre_arr.delivery_daynum * 3600; + } + th.setData({ isclose: 0, 'order.order_status': 1, 'order.pay_status': 1, 'wait_wk': 0, 'presell.tail_pay_state': 1, 'wait_fh': 1, send_time: send_time }); + }, function () { getApp().my_warnning("支付失败", 0, th); }) } else { if (t.data.code == 0) { - var send_time=th.data.pre_arr.delivery_date; - if(th.data.pre_arr.delivery_type==2){ - send_time=th.data.pre_arr.delivery_daynum*3600; + var send_time = th.data.pre_arr.delivery_date; + if (th.data.pre_arr.delivery_type == 2) { + send_time = th.data.pre_arr.delivery_daynum * 3600; } //---用余额支付--- - getApp().my_warnning("支付成功", 1, th); - th.setData({isclose: 0,'order.order_status':1,'order.pay_status':1,'wait_wk':0,'presell.tail_pay_state':1,'wait_fh':1,send_time:send_time}); - + getApp().my_warnning("支付成功", 1, th); + th.setData({ isclose: 0, 'order.order_status': 1, 'order.pay_status': 1, 'wait_wk': 0, 'presell.tail_pay_state': 1, 'wait_fh': 1, send_time: send_time }); + } else { getApp().my_warnning(t.data.msg, 1, th); } @@ -2074,17 +2078,17 @@ Page({ }, fail: function (n) { 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), - "function" == typeof fail && fail(); + "function" == typeof fail && fail(); } }); }, - show_liuyan:function () { - this.setData({sh_liuyan:true}) + show_liuyan: function () { + this.setData({ sh_liuyan: true }) }, - close_liuyan(){ - this.setData({sh_liuyan:false}) + close_liuyan() { + this.setData({ sh_liuyan: false }) }, //--------点击选择---------- @@ -2098,83 +2102,83 @@ Page({ //--------立即支付---------- async jumpToCart4(e) { - var th=this; - if(this.data.optionIsGoup) + var th = this; + if (this.data.optionIsGoup) wx.navigateTo({ url: "/pages/team/team_confirm/team_confirm?orderSn=" + this.data.order.order_sn + "&orderPay=true" }) - var order=this.data.order; - var order_goods=this.data.order_goods; - var user_id=getApp().globalData.userInfo.user_id; - - var wlist=""; - - var good=order_goods; - //线下取价功能已经关闭或者过期 - if(!th.data.is_open_offline && good.offline_cut>0){ - wx.showModal({ - title: '提示', - content: '线下取价功能已经关闭或者过期!' - }); - return false; - } - //如果不是小程序有的功能,直接提示要去3.0处理 - if(good.prom_type==2 ){ - wx.showModal({ - title: '提示', - content: '小程序还未有该活动,请到3.0公众号支付' - }); - return false; - } + var order = this.data.order; + var order_goods = this.data.order_goods; + var user_id = getApp().globalData.userInfo.user_id; + + var wlist = ""; + + var good = order_goods; + //线下取价功能已经关闭或者过期 + if (!th.data.is_open_offline && good.offline_cut > 0) { + wx.showModal({ + title: '提示', + content: '线下取价功能已经关闭或者过期!' + }); + return false; + } + //如果不是小程序有的功能,直接提示要去3.0处理 + if (good.prom_type == 2) { + wx.showModal({ + title: '提示', + content: '小程序还未有该活动,请到3.0公众号支付' + }); + return false; + } - //要每件每件的商品进行检查,看有么有超出库存,超出限购 - var goodsbuynum=0,promgoodsbuynum=0,gg=null; - //获取单品的现在的活动状态 - await getApp().request.promiseGet("/api/weshop/goods/get/" + os.stoid + "/" + good.goods_id, { - }).then(res=>{ - gg=res.data.data; - }) - var limit = gg.viplimited; - var store_count = gg.store_count; - good.erpwareid=gg.erpwareid; + //要每件每件的商品进行检查,看有么有超出库存,超出限购 + var goodsbuynum = 0, promgoodsbuynum = 0, gg = null; + //获取单品的现在的活动状态 + await getApp().request.promiseGet("/api/weshop/goods/get/" + os.stoid + "/" + good.goods_id, { + }).then(res => { + gg = res.data.data; + }) + var limit = gg.viplimited; + var store_count = gg.store_count; + good.erpwareid = gg.erpwareid; - //---要获得商品,该用户买了多少件,同步应用--- - await getApp().request.promiseGet("/api/weshop/ordergoods/getUserBuyGoodsNum", { - data: { - store_id: os.stoid, - user_id: getApp().globalData.user_id, - goods_id: good.goods_id, - prom_type: good.prom_type, - prom_id: good.prom_id - }, - }).then(res => { - var buy_num_data = res.data.data; - if (buy_num_data.promgoodsbuynum) promgoodsbuynum = buy_num_data.promgoodsbuynum; - goodsbuynum = buy_num_data.goodsbuynum; - }) + //---要获得商品,该用户买了多少件,同步应用--- + await getApp().request.promiseGet("/api/weshop/ordergoods/getUserBuyGoodsNum", { + data: { + store_id: os.stoid, + user_id: getApp().globalData.user_id, + goods_id: good.goods_id, + prom_type: good.prom_type, + prom_id: good.prom_id + }, + }).then(res => { + var buy_num_data = res.data.data; + if (buy_num_data.promgoodsbuynum) promgoodsbuynum = buy_num_data.promgoodsbuynum; + goodsbuynum = buy_num_data.goodsbuynum; + }) - var buyed_mum2=goodsbuynum+good.goods_num; - if (buyed_mum2 > limit && limit > 0) { + var buyed_mum2 = goodsbuynum + good.goods_num; + if (buyed_mum2 > limit && limit > 0) { - var content=gg.goods_name+'购买数量超出商品限购,请取消订单'; - th.toast(content); - return false; - } + var content = gg.goods_name + '购买数量超出商品限购,请取消订单'; + th.toast(content); + return false; + } //如果是预售的时候, - if(good.prom_type==8){ - await getApp().request.promiseGet("/api/weshop/order/orderPresell/countBuyGoodsSum",{ - data: {store_id: os.stoid, user_id: user_id, goods_id: good.goods_id, prom_id: good.prom_id}, - }).then(e=>{ + if (good.prom_type == 8) { + await getApp().request.promiseGet("/api/weshop/order/orderPresell/countBuyGoodsSum", { + data: { store_id: os.stoid, user_id: user_id, goods_id: good.goods_id, prom_id: good.prom_id }, + }).then(e => { if (e.data.code == 0) { - promgoodsbuynum=e.data.data.sumgoodsnum; + promgoodsbuynum = e.data.data.sumgoodsnum; } }) - var presell_id =good.prom_id; - var presellList=null; + var presell_id = good.prom_id; + var presellList = null; var url = "/api/weshop/marketing/marketingPresellList/list" var rd = { store_id: os.stoid, @@ -2187,13 +2191,13 @@ Page({ }).then(res => { if (res.data.code == 0 && res.data.data && res.data.data.length > 0) { var arr = res.data.data[0]; - presellList=arr + presellList = arr } }) - if(presellList){ + if (presellList) { - if(good.goods_num>presellList.presell_sumqty-presellList.buy_goodnum){ + if (good.goods_num > presellList.presell_sumqty - presellList.buy_goodnum) { var content = gg.goods_name + '购买数量超出商品库存,请取消订单'; th.toast(content); return false; @@ -2209,247 +2213,248 @@ Page({ } - //如果优惠促销和搭配购的时候 - if((good.prom_type==3 || good.prom_type==5) && good.is_collocation!=1 && good.is_gift!=1){ - var p_ok=1; - await getApp().request.promiseGet("/api/weshop/goods/getGoodsPromList/" + os.stoid+"/"+good.goods_id+"/0", {}).then(res => { - if(res.data.code==0){ - var r_data=res.data.data; - if(!r_data.collocationPromList && good.prom_type==5){ - - var content=good.goods_name+'未找到活动,请取消订单重新购买'; - th.toast(content); - p_ok=0; - } - if(!r_data.promGoodsLists && good.prom_type==3){ - - var content=good.goods_name+'未找到活动,请取消订单重新购买'; - th.toast(content); - p_ok=0; - } - }else{ + //如果优惠促销和搭配购的时候 + if ((good.prom_type == 3 || good.prom_type == 5) && good.is_collocation != 1 && good.is_gift != 1) { + var p_ok = 1; + await getApp().request.promiseGet("/api/weshop/goods/getGoodsPromList/" + os.stoid + "/" + good.goods_id + "/0", {}).then(res => { + if (res.data.code == 0) { + var r_data = res.data.data; + if (!r_data.collocationPromList && good.prom_type == 5) { - var content=good.goods_name+'未找到活动,请取消订单重新购买'; + var content = good.goods_name + '未找到活动,请取消订单重新购买'; th.toast(content); - p_ok=0; + p_ok = 0; } - }) - if(!p_ok) return false; - } + if (!r_data.promGoodsLists && good.prom_type == 3) { - //商品的普通购买 ,不要进行判断 - 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){ - if(gg.prom_type!=good.prom_type) { + var content = good.goods_name + '未找到活动,请取消订单重新购买'; + th.toast(content); + p_ok = 0; + } + } else { - var content=gg.goods_name+'商品的活动发生了变化,请取消订单重新购买'; + var content = good.goods_name + '未找到活动,请取消订单重新购买'; th.toast(content); - return false; + p_ok = 0; } - }else{ - if((gg.prom_type==1 || gg.prom_type==3 || gg.prom_type==5 || gg.prom_type==6 || gg.prom_type==4) - && !good.is_collocation && !good.is_gift && !good.is_integral_normal && !good.is_pd_normal) { - var prom=null; - //---如果是活动的时候--- - var prom=null,th=this; - if(gg.prom_type==1){ - await getApp().request.promiseGet("/api/ms/flash_sale/get/"+os.stoid+"/"+gg.prom_id,{ - }).then(res=>{ - if(res.data.code==0){ - prom=res.data.data; - } - }) - } - if(gg.prom_type==6){ - await getApp().request.promiseGet("/api/weshop/teamlist/get/"+os.stoid+"/"+gg.prom_id,{ - }).then(res=>{ - if(res.data.code==0){ - prom=res.data.data; - } - }) - } - - if(gg.prom_type==4){ - await getApp().request.promiseGet("/api/weshop/integralbuy/pageIntegralBuyGoodsList?stype=1&stypeup=1",{ - data:{store_id:os.stoid,goods_id:gg.goods_id} - }).then(res=>{ - if(res.data.code==0 && res.data.data && res.data.data.pageData && res.data.data.pageData.length){ - prom=res.data.data.pageData[0]; - } - }) - } + }) + if (!p_ok) return false; + } - if(prom){ - var t_now=ut.gettimestamp(); - if(prom.is_end==0 && prom.start_timet_now){ + //商品的普通购买 ,不要进行判断 + 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) { + if (gg.prom_type != good.prom_type) { - var content=gg.goods_name+'商品的活动发生了变化,请取消订单重新购买'; - th.toast(content); - return false; + var content = gg.goods_name + '商品的活动发生了变化,请取消订单重新购买'; + th.toast(content); + return false; + } + } else { + if ((gg.prom_type == 1 || gg.prom_type == 3 || gg.prom_type == 5 || gg.prom_type == 6 || gg.prom_type == 4) + && !good.is_collocation && !good.is_gift && !good.is_integral_normal && !good.is_pd_normal) { + var prom = null; + //---如果是活动的时候--- + var prom = null, th = this; + if (gg.prom_type == 1) { + await getApp().request.promiseGet("/api/ms/flash_sale/get/" + os.stoid + "/" + gg.prom_id, { + }).then(res => { + if (res.data.code == 0) { + prom = res.data.data; } - } + }) + } + if (gg.prom_type == 6) { + await getApp().request.promiseGet("/api/weshop/teamlist/get/" + os.stoid + "/" + gg.prom_id, { + }).then(res => { + if (res.data.code == 0) { + prom = res.data.data; + } + }) } - else{ - //不是赠品的时候 - if(!good.is_gift && good.prom_type!=3){ - var t_ok=1; - await getApp().request.promiseGet("/api/weshop/goods/getGoodsPromList/" + os.stoid+"/"+good.goods_id+"/0", {}).then(res => { - if(res.data.code==0){ - var r_data=res.data.data; - //-- 参加了全局的优惠活动 -- - if(r_data.promGoodsLists){ - - var content=gg.goods_name+'商品的活动发生了变化,请取消订单重新购买'; - th.toast(content); - t_ok=0; - } - } - }) - if(!t_ok) return false; - } - //-- 如果有参加线下取价 -- - if(good.offline_cut>0) wlist+=encodeURIComponent(gg.erpwareid)+","; + if (gg.prom_type == 4) { + await getApp().request.promiseGet("/api/weshop/integralbuy/pageIntegralBuyGoodsList?stype=1&stypeup=1", { + data: { store_id: os.stoid, goods_id: gg.goods_id } + }).then(res => { + if (res.data.code == 0 && res.data.data && res.data.data.pageData && res.data.data.pageData.length) { + prom = res.data.data.pageData[0]; + } + }) } - //赠品和搭配购不判断商品金额 - var isok=1; - var card_field=th.data.card_field; - //如果会员是等级会员,商品有等级价,且不是活动商品 - if(!good.is_gift && !good.is_collocation && good.prom_type!=8) { - if (card_field && gg[card_field] > 0) { - if (good.goods_price != gg[card_field] && good.offline_cut<=0) isok = 0; - if (good.goods_price >gg[card_field] && good.offline_cut>0) isok = 0; //如果线下价格比较贵,则不通过 - } else { - if (good.goods_price != gg.shop_price && good.offline_cut<=0) isok = 0; - if (good.goods_price> gg.shop_price && good.offline_cut>0) isok = 0; //如果线下价格比较贵,则不通过 - } - var is_h=0; - if (!isok) { + if (prom) { + var t_now = ut.gettimestamp(); + if (prom.is_end == 0 && prom.start_time < t_now && prom.end_time > t_now) { - var content=gg.goods_name + '商品的价格发生了变化,请取消订单重新购买'; + var content = gg.goods_name + '商品的活动发生了变化,请取消订单重新购买'; th.toast(content); return false; } } + } + else { + //不是赠品的时候 + if (!good.is_gift && good.prom_type != 3) { + var t_ok = 1; + await getApp().request.promiseGet("/api/weshop/goods/getGoodsPromList/" + os.stoid + "/" + good.goods_id + "/0", {}).then(res => { + if (res.data.code == 0) { + var r_data = res.data.data; + //-- 参加了全局的优惠活动 -- + if (r_data.promGoodsLists) { + var content = gg.goods_name + '商品的活动发生了变化,请取消订单重新购买'; + th.toast(content); + t_ok = 0; + } + } + }) + if (!t_ok) return false; + } - if(good.goods_num>store_count){ - - var content=gg.goods_name+'商品的库存不足,请取消订单'; - th.toast(content); - return false; - } + //-- 如果有参加线下取价 -- + if (good.offline_cut > 0) wlist += encodeURIComponent(gg.erpwareid) + ","; + } + //赠品和搭配购不判断商品金额 + var isok = 1; + var card_field = th.data.card_field; + //如果会员是等级会员,商品有等级价,且不是活动商品 + if (!good.is_gift && !good.is_collocation && good.prom_type != 8) { + if (card_field && gg[card_field] > 0) { + if (good.goods_price != gg[card_field] && good.offline_cut <= 0) isok = 0; + if (good.goods_price > gg[card_field] && good.offline_cut > 0) isok = 0; //如果线下价格比较贵,则不通过 + } else { + if (good.goods_price != gg.shop_price && good.offline_cut <= 0) isok = 0; + if (good.goods_price > gg.shop_price && good.offline_cut > 0) isok = 0; //如果线下价格比较贵,则不通过 + } + var is_h = 0; + if (!isok) { + var content = gg.goods_name + '商品的价格发生了变化,请取消订单重新购买'; + th.toast(content); + return false; + } } - console.log("------------------------------------"); - //---如果是活动的时候--- - var prom=null,goodsinfo=good,th=this; - if(goodsinfo.prom_type==1){ - await getApp().request.promiseGet("/api/ms/flash_sale/get/"+os.stoid+"/"+goodsinfo.prom_id,{ - }).then(res=>{ - if(res.data.code==0){ - prom=res.data.data; - } - }) + + if (good.goods_num > store_count) { + + var content = gg.goods_name + '商品的库存不足,请取消订单'; + th.toast(content); + return false; } - if(goodsinfo.prom_type==6 && !good.is_pd_normal){ - await getApp().request.promiseGet("/api/weshop/teamlist/get/"+os.stoid+"/"+goodsinfo.prom_id,{ - }).then(res=>{ - if(res.data.code==0){ - prom=res.data.data; - } - }) + + + } + + console.log("------------------------------------"); + //---如果是活动的时候--- + var prom = null, goodsinfo = good, th = this; + if (goodsinfo.prom_type == 1) { + await getApp().request.promiseGet("/api/ms/flash_sale/get/" + os.stoid + "/" + goodsinfo.prom_id, { + }).then(res => { + if (res.data.code == 0) { + prom = res.data.data; + } + }) + } + if (goodsinfo.prom_type == 6 && !good.is_pd_normal) { + await getApp().request.promiseGet("/api/weshop/teamlist/get/" + os.stoid + "/" + goodsinfo.prom_id, { + }).then(res => { + if (res.data.code == 0) { + prom = res.data.data; + } + }) + } + + if (goodsinfo.prom_type == 4 && !good.is_integral_normal) { + await getApp().request.promiseGet("/api/weshop/integralbuy/pageIntegralBuyGoodsList?stype=1&stypeup=1", { + data: { store_id: os.stoid, goods_id: goodsinfo.goods_id } + }).then(res => { + if (res.data.code == 0 && res.data.data && res.data.data.pageData && res.data.data.pageData.length) { + prom = res.data.data.pageData[0]; + } + }) + } + + //----------如果有活动,并且在进行中,就不计算线下库存--------------- + if (prom) { + var now = ut.gettimestamp(); + if (prom.is_end == 1 && prom.end_time < now) { + + var content = goodsinfo.goods_name + '商品的活动已经结束,请取消订单重新购买'; + th.toast(content); + return false; } - if(goodsinfo.prom_type==4 && !good.is_integral_normal){ - await getApp().request.promiseGet("/api/weshop/integralbuy/pageIntegralBuyGoodsList?stype=1&stypeup=1",{ - data:{store_id:os.stoid,goods_id:goodsinfo.goods_id} - }).then(res=>{ - if(res.data.code==0 && res.data.data && res.data.data.pageData && res.data.data.pageData.length){ - prom=res.data.data.pageData[0]; - } - }) + buyed_mum2 = promgoodsbuynum + good.goods_num; + if (buyed_mum2 > prom.buy_limit && prom.buy_limit > 0) { + + var content = goodsinfo.goods_name + '购买数量超出商品活动限购,请取消订单重新购买'; + th.toast(content); + return false; } - //----------如果有活动,并且在进行中,就不计算线下库存--------------- - if(prom){ - var now=ut.gettimestamp(); - if(prom.is_end==1 && prom.end_time prom.limitqty - prom.buy_num) { - var content=goodsinfo.goods_name+'商品的活动已经结束,请取消订单重新购买'; + var content = goodsinfo.goods_name + '购买数量超出商品活动库存,请取消订单'; th.toast(content); return false; } + } else { + var redis_num = 0; + //------判断活动是否抢光----- + await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + + os.stoid + "/" + goodsinfo.prom_type + "/" + goodsinfo.prom_id, { + }).then(res => { + redis_num = res.data.data; + }); - buyed_mum2=promgoodsbuynum+good.goods_num; - if (buyed_mum2 > prom.buy_limit && prom.buy_limit > 0) { + if (good.goods_num > redis_num) { - var content=goodsinfo.goods_name+'购买数量超出商品活动限购,请取消订单重新购买'; + var content = gg.goods_name + '超出商品活动库存,请取消订单'; th.toast(content); return false; } - - if(goodsinfo.prom_type==4){ - if (good.goods_num > prom.limitqty-prom.buy_num) { - - var content=goodsinfo.goods_name+'购买数量超出商品活动库存,请取消订单'; - th.toast(content); - return false; - } - }else{ - var redis_num = 0; - //------判断活动是否抢光----- - await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + - os.stoid + "/" + goodsinfo.prom_type + "/" + goodsinfo.prom_id, { - }).then(res => { - redis_num = res.data.data; - }); - - if (good.goods_num > redis_num) { - - var content=gg.goods_name+'超出商品活动库存,请取消订单'; - th.toast(content); - return false; - } - } - } + } + //-- 要判断一下线下取价价格是不是发生改变 -- - if(wlist!="" && th.data.is_open_offline && th.data.is_open_offline>0){ - wlist=ut.sub_last(wlist); - var keyid=order.pickup_id; - var user_info=getApp().globalData.userInfo; - if(!keyid) return false; - var offarr=null; + if (wlist != "" && th.data.is_open_offline && th.data.is_open_offline > 0) { + wlist = ut.sub_last(wlist); + var keyid = order.pickup_id; + var user_info = getApp().globalData.userInfo; + if (!keyid) return false; + var offarr = null; await getApp().request.promiseGet("/api/weshop/goods/listWarePrice", { - data:{ - VIPId:encodeURIComponent(user_info.erpvipid), - store_id:os.stoid, - PickupId:keyid, - WareIds:wlist}, + data: { + VIPId: encodeURIComponent(user_info.erpvipid), + store_id: os.stoid, + PickupId: keyid, + WareIds: wlist }, - ).then(res=>{ - if(res.data.code==0 && res.data.data && res.data.data.length>0){ - offarr=res.data.data; + }, + ).then(res => { + if (res.data.code == 0 && res.data.data && res.data.data.length > 0) { + offarr = res.data.data; } }) - if(!offarr && offarr.length<=0 ){ - wx.showModal({ title: '获取线下取价失败',}); + if (!offarr && offarr.length <= 0) { + wx.showModal({ title: '获取线下取价失败', }); } - var newarr=ut.convert_arr_key(offarr,'WareId'); + var newarr = ut.convert_arr_key(offarr, 'WareId'); //-- 循环判断线下的价格 -- - for(var k in order_goods){ - var good=order_goods[k]; + for (var k in order_goods) { + var good = order_goods[k]; //判断线下取价是不是一样 - if(newarr[good.erpwareid] && - parseFloat(newarr[good.erpwareid].WarePrice)!=parseFloat(good.goods_price)){ + if (newarr[good.erpwareid] && + parseFloat(newarr[good.erpwareid].WarePrice) != parseFloat(good.goods_price)) { - var content=good.goods_name + '商品的价格发生了变化,请取消订单重新购买'; + var content = good.goods_name + '商品的价格发生了变化,请取消订单重新购买'; th.toast(content); return false; } @@ -2464,30 +2469,30 @@ Page({ type: 1 //正常单 }, 1);--*/ - util_pay.pay(this.data.order.order_sn, function() { - wx.showToast({title: '支付成功'}) + util_pay.pay(this.data.order.order_sn, function () { + wx.showToast({ title: '支付成功' }) wx.navigateBack(); - },null,os.stoid,1); + }, null, os.stoid, 1); }, //--------取消订单--------- - cancelOrder: function(e) { - var t = this,th=t, ord_id = this.data.order.order_id,order=this.data.order; + cancelOrder: function (e) { + var t = this, th = t, ord_id = this.data.order.order_id, order = this.data.order; wx.showModal({ title: "是否取消订单?", - success: function(e) { - if(!e.confirm) return false; + success: function (e) { + if (!e.confirm) return false; //如果是秒杀和拼单的商品,取消订单要返回redis,并取消订单 //if(is_skill==1 || is_zsorder>=2){ - getApp().request.post("/api/weshop/order/cancelOrder/"+os.stoid+"/"+ord_id+"/"+getApp().globalData.user_id,{ - data:{}, - success: function(t) { - if(t.data.code==0){ - th.setData({'order.order_status':3}); - wx.setStorageSync("order:order_list:update", !0); + getApp().request.post("/api/weshop/order/cancelOrder/" + os.stoid + "/" + ord_id + "/" + getApp().globalData.user_id, { + data: {}, + success: function (t) { + if (t.data.code == 0) { + th.setData({ 'order.order_status': 3 }); + wx.setStorageSync("order:order_list:update", !0); } }, @@ -2499,36 +2504,36 @@ Page({ //-----删除订单----- - deleteOrderData: function(t) { - var th=this; - var order_id=this.data.order.order_id; - var up_data={ - order_id: order_id,isdel:1 + deleteOrderData: function (t) { + var th = this; + var order_id = this.data.order.order_id; + var up_data = { + order_id: order_id, isdel: 1 }; - if(th.data.order.order_status!=6){ - up_data.order_status=5; + if (th.data.order.order_status != 6) { + up_data.order_status = 5; } wx.showModal({ title: "是否删除订单?", - success: function(tt) { + success: function (tt) { tt.confirm && getApp().request.put("/api/weshop/order/updatebyId", { data: up_data, success: function (t) { - getApp().my_warnning("删除成功",1,th); + getApp().my_warnning("删除成功", 1, th); setTimeout(function () { getApp().goto("/pages/user/order_list/order_list"); - },1000); + }, 1000); } }) } }); }, - go_goods:function (e) { - var url=e.currentTarget.dataset.url; + go_goods: function (e) { + var url = e.currentTarget.dataset.url; getApp().goto(url); }, - toast(msg){ + toast(msg) { wx.showToast({ title: msg, icon: 'none', @@ -2536,15 +2541,15 @@ Page({ }) }, //--------确认收货--------- - confirmOrder: function(e) { - var th=this; - var o = this.data.order.order_id,order=this.data.order; + confirmOrder: function (e) { + var th = this; + var o = this.data.order.order_id, order = this.data.order; wx.showModal({ title: "是否确认收货?", - success: function(t) { - t.confirm && getApp().request.post("/api/weshop/order/confirmOrder/"+os.stoid+"/"+o+"/"+getApp().globalData.user_id,{ - success:function (e) { - if(e.data.code==0){ + success: function (t) { + t.confirm && getApp().request.post("/api/weshop/order/confirmOrder/" + os.stoid + "/" + o + "/" + getApp().globalData.user_id, { + success: function (e) { + if (e.data.code == 0) { th.setData({}) } } @@ -2555,13 +2560,13 @@ Page({ //---------联系客服------------ - contactService: function() { - getApp().getConfig(function(t) { + contactService: function () { + getApp().getConfig(function (t) { if (t.store_tel == undefined) { getApp().request.get("/api/weshop/store/get/" + os.stoid, { isShowLoading: 1, data: {}, - success: function(rs) { + success: function (rs) { getApp().globalData.config = rs.data.data; if (rs.data.data.store_tel == null && rs.data.data.store_tel == undefined) { getApp().my_warnning("商家未设置电话", 0, th); @@ -2577,13 +2582,13 @@ Page({ }, //---------联系微信客服------------ - con_weixin:function () { - var url=this.data.sys_switch.weapp_customertype_url; - var id=this.data.sys_switch.weapp_customertype_appid; + con_weixin: function () { + var url = this.data.sys_switch.weapp_customertype_url; + var id = this.data.sys_switch.weapp_customertype_appid; wx.openCustomerServiceChat({ - extInfo: {url: url}, + extInfo: { url: url }, corpId: id, - success(res) {} + success(res) { } }) } diff --git a/packageC/pages/presell/cart/cart2.js b/packageC/pages/presell/cart/cart2.js index 3f01342..8b25596 100644 --- a/packageC/pages/presell/cart/cart2.js +++ b/packageC/pages/presell/cart/cart2.js @@ -121,25 +121,25 @@ Page({ tabs: ['门店自提', '快递邮寄'], currentTabIndex: 1, - in_zhact_gdmap:{}, //不同门店参与同一活动的限购 - hid_inp:1, - user_note:{}, + in_zhact_gdmap: {}, //不同门店参与同一活动的限购 + hid_inp: 1, + user_note: {}, }, onLoad: function (t) { - wx.setNavigationBarTitle({title: "填写订单",}) + wx.setNavigationBarTitle({ title: "填写订单", }) var th = this; //清理一下,确保最新的系统配置 getApp().globalData.config2 = null; //清空is_pick_up getApp().request.put("/api/weshop/useraddress/updatePickUp", { - data: {user_id: getApp().globalData.user_id, is_pickup: 0}, + data: { user_id: getApp().globalData.user_id, is_pickup: 0 }, success: function (s) { } }); }, onUnload: function () { - this.setData({isclose: 1}) + this.setData({ isclose: 1 }) }, onHide: function () { this.setData({ @@ -152,7 +152,7 @@ Page({ //----------子页返回父页触发---------- onShow: function () { var th = this; - th.setData({show_submit: 0}); //让提交先掩藏 + th.setData({ show_submit: 0 }); //让提交先掩藏 th.data.g_cart_q_time = null; if (th.data.isclose == 0) { @@ -182,20 +182,20 @@ Page({ th.data.is_summit_ing = 0; //更换地址回来要重新调用计算价钱的接口 if (!th.data.user_addr || th.data.user_addr.address_id != ie.address_id) { - th.setData({user_addr: ie}); + th.setData({ user_addr: ie }); if (th.data.is_b_now == 1) { if (th.data.bn_goods) { - th.setData({add_back: 1}); + th.setData({ add_back: 1 }); //th.calculatePrice2(); } } else { if (th.data.cartlist) { - th.setData({add_back: 1}); + th.setData({ add_back: 1 }); //th.calculatePrice(); } } } else { - th.setData({user_addr: ie}); + th.setData({ user_addr: ie }); } var going = 0; @@ -234,34 +234,34 @@ Page({ //-- 获取所有的等级卡, -- getApp().request.promiseGet("/api/weshop/plus/vip/mem/bership/list?storeId=" + os.stoid, {}).then(res => { - if (res.data.code == 0) { - var plusCard = res.data.data; - //-- 循环判断,拿到最贵的那张卡 -- - for (var ih in plusCard) { - if (plusCard[ih].IsStopBuy == true) { - continue; - } - if (max_price < 0) { - max_price = plusCard[ih].CardFee; - name = 'card' + plusCard[ih]['CorrPrice']; - show_card = plusCard[ih]; - } else { - if (max_price < plusCard[ih].CardFee) { + if (res.data.code == 0) { + var plusCard = res.data.data; + //-- 循环判断,拿到最贵的那张卡 -- + for (var ih in plusCard) { + if (plusCard[ih].IsStopBuy == true) { + continue; + } + if (max_price < 0) { max_price = plusCard[ih].CardFee; name = 'card' + plusCard[ih]['CorrPrice']; show_card = plusCard[ih]; + } else { + if (max_price < plusCard[ih].CardFee) { + max_price = plusCard[ih].CardFee; + name = 'card' + plusCard[ih]['CorrPrice']; + show_card = plusCard[ih]; + } } } - } - if (show_card) { - name = name.toLowerCase(); - th.setData({card_name: name, show_card: show_card}) + if (show_card) { + name = name.toLowerCase(); + th.setData({ card_name: name, show_card: show_card }) + } } - } - //-----先获取物流,再获取用户信息,再展示页面----- - th.get_wuliu(th.get_info(th.show_page)); - }) + //-----先获取物流,再获取用户信息,再展示页面----- + th.get_wuliu(th.get_info(th.show_page)); + }) } else { //-----先获取物流,再获取用户信息,再展示页面----- th.get_wuliu(th.get_info(th.show_page)); @@ -281,10 +281,10 @@ Page({ if (th.data.is_default_logistics) { //如果第一个不是开启默认,说明要让用户自己选 if (!e[0].is_default) { - th.setData({is_default_logistics: 0}); + th.setData({ is_default_logistics: 0 }); } } - th.setData({wu_arr: e}) + th.setData({ wu_arr: e }) typeof func == "function" && func(); }) }, @@ -298,7 +298,7 @@ Page({ getuser_addr: function (func) { var th = this; a.get("/api/weshop/useraddress/page", { - data: {user_id: to.globalData.user_id, store_id: oo.stoid, pageSize: 600, t: Math.random()}, + data: { user_id: to.globalData.user_id, store_id: oo.stoid, pageSize: 600, t: Math.random() }, success: function (su) { /*--- var user_addr=[ @@ -323,7 +323,7 @@ Page({ } if (item == undefined) item = null; - if (!item) th.setData({user_addr: null}); //地址为空的时候,要清空,因为返回的时候,有缓存 + if (!item) th.setData({ user_addr: null }); //地址为空的时候,要清空,因为返回的时候,有缓存 func(item); } @@ -338,32 +338,32 @@ Page({ //会员的信息,要获取最新 var user = getApp().globalData.userInfo; getApp().request.get("/api/weshop/users/get/" + oo.stoid + "/" + user.user_id, { - data: {r: Math.random()}, + data: { r: Math.random() }, success: function (e) { getApp().globalData.userInfo = e.data.data; - th.setData({userinfo: e.data.data}); + th.setData({ userinfo: e.data.data }); //选获取地址 th.getuser_addr(function (addr) { - th.setData({user_addr: addr}); - //--------------------------立即购买------------------ - //读取门店 - to.get_allsto(function (e) { - th.setData({allsto: e}); - //获取立即购买的商品信息 - th.get_buy_goods(); - }); + th.setData({ user_addr: addr }); + //--------------------------立即购买------------------ + //读取门店 + to.get_allsto(function (e) { + th.setData({ allsto: e }); + //获取立即购买的商品信息 + th.get_buy_goods(); + }); }); //获取提现金额 getApp().request.get("/api/weshop/withdrawals/summoney", { - data: {user_id: to.globalData.user_id, store_id: oo.stoid, status: 0}, + data: { user_id: to.globalData.user_id, store_id: oo.stoid, status: 0 }, success: function (su) { if (su.data.code == 0) { var yuer = parseFloat(th.data.userinfo.user_money - (th.data.userinfo.frozen_money > 0 ? th.data.userinfo.frozen_money : 0) - su.data.data.summoney).toFixed(2); - th.setData({txmon: su.data.data.summoney, yuer: yuer}); + th.setData({ txmon: su.data.data.summoney, yuer: yuer }); } } }); @@ -379,127 +379,127 @@ Page({ th.data.gg = to.get_b_now(); //--------如果goods_id一样,就是要立即购买----- getApp().request.get("/api/weshop/goods/get/" + oo.stoid + "/" + th.data.gg.goods_id, { - success: async function (t) { - var gd = t.data.data; - if (!gd) return false; - - t.data.data.original_img = oo.imghost + t.data.data.original_img; - t.data.data['buynum'] = th.data.gg.goods_num; - var distr_t = 0, et = 0 - if (t.data.data.distr_type == 0) { - distr_t = th.data.gg.pick_dis; - } else { - distr_t = t.data.data.distr_type; - } + success: async function (t) { + var gd = t.data.data; + if (!gd) return false; + + t.data.data.original_img = oo.imghost + t.data.data.original_img; + t.data.data['buynum'] = th.data.gg.goods_num; + var distr_t = 0, et = 0 + if (t.data.data.distr_type == 0) { + distr_t = th.data.gg.pick_dis; + } else { + distr_t = t.data.data.distr_type; + } - switch (distr_t) { - case 0: - et = 1; - //-- 系统后台有设置要默认的 -- - if (th.data.json_d.pickupway && th.data.json_d.pickupway == 1) et = 0; - break; - case 1: - et = 1; - break; - case 2: - et = 0; - break; - } + switch (distr_t) { + case 0: + et = 1; + //-- 系统后台有设置要默认的 -- + if (th.data.json_d.pickupway && th.data.json_d.pickupway == 1) et = 0; + break; + case 1: + et = 1; + break; + case 2: + et = 0; + break; + } - var m_wind = 0, def_exp_code = getApp().globalData.userInfo.def_exp_code; - if (et == 0 && def_exp_code) { - for (var k = 0; k < th.data.wu_arr.length; k++) { - var item = th.data.wu_arr[k]; - if (def_exp_code == item.code) { - m_wind = k; - } + var m_wind = 0, def_exp_code = getApp().globalData.userInfo.def_exp_code; + if (et == 0 && def_exp_code) { + for (var k = 0; k < th.data.wu_arr.length; k++) { + var item = th.data.wu_arr[k]; + if (def_exp_code == item.code) { + m_wind = k; } } + } - if (th.data.bn_goods) { - et = th.data.bn_exp_type; - m_wind = th.data.index; - } + if (th.data.bn_goods) { + et = th.data.bn_exp_type; + m_wind = th.data.index; + } - //---是不是购买等级卡成功的返回---等级卡显示的判断--- - var is_card_back = getApp().globalData.is_card_back; - if (is_card_back) { - th.data.card_name = th.data.userinfo.card_field; - th.data.gg.goods_price = gd[th.data.card_name]; - getApp().globalData.is_card_back = 0; - th.setData({card_cut_price: 0}); - //如果是秒杀的返回 - if (gd.prom_type == 1) gd.prom_type = 0; - } else { - //--- 商家等级卡开通的情况下, 会员不是等级会员的情况, 商品有设置等级卡价格,同时等级卡价格小于商品的价格 - //-- 搭配购的商品也可以单独购买,所以此时搭配购的商品要进行计算优惠 -- - if (!th.data.gg.collocation_goods && gd['prom_type'] != 6 && th.data.card_name && gd[th.data.card_name] > 0 && th.data.gg.goods_price > gd[th.data.card_name] && !th.data.userinfo.card_field) { - var cut_p = (th.data.gg.goods_price - gd[th.data.card_name]) * th.data.gg.goods_num; - th.setData({card_cut_price: cut_p}); - } + //---是不是购买等级卡成功的返回---等级卡显示的判断--- + var is_card_back = getApp().globalData.is_card_back; + if (is_card_back) { + th.data.card_name = th.data.userinfo.card_field; + th.data.gg.goods_price = gd[th.data.card_name]; + getApp().globalData.is_card_back = 0; + th.setData({ card_cut_price: 0 }); + //如果是秒杀的返回 + if (gd.prom_type == 1) gd.prom_type = 0; + } else { + //--- 商家等级卡开通的情况下, 会员不是等级会员的情况, 商品有设置等级卡价格,同时等级卡价格小于商品的价格 + //-- 搭配购的商品也可以单独购买,所以此时搭配购的商品要进行计算优惠 -- + if (!th.data.gg.collocation_goods && gd['prom_type'] != 6 && th.data.card_name && gd[th.data.card_name] > 0 && th.data.gg.goods_price > gd[th.data.card_name] && !th.data.userinfo.card_field) { + var cut_p = (th.data.gg.goods_price - gd[th.data.card_name]) * th.data.gg.goods_num; + th.setData({ card_cut_price: cut_p }); } + } - //定义变量 - var gg = th.data.gg,act = null,prelist = null; - var url = "/api/weshop/marketing/marketingPresellForm/get/" + os.stoid + "/" + gg.prom_id; - await getApp().request.promiseGet(url, {}).then(res => { - if (res.data.code == 0) { - act = res.data.data; - } - }) - if (!act) { - wx.showToast({title: "未找到活动", icon: 'none', duration: 3000}); - return false; - } - if (act.is_end==1 ) { - wx.showToast({title:'活动已经结束' , icon: 'none', duration: 3000}); - return false; - } - if( ut.gettimestamp()>act.end_time){ - wx.showToast({title:"活动定金支付时间已过期" , icon: 'none', duration: 3000}); - return false; + //定义变量 + var gg = th.data.gg, act = null, prelist = null; + var url = "/api/weshop/marketing/marketingPresellForm/get/" + os.stoid + "/" + gg.prom_id; + await getApp().request.promiseGet(url, {}).then(res => { + if (res.data.code == 0) { + act = res.data.data; } + }) + if (!act) { + wx.showToast({ title: "未找到活动", icon: 'none', duration: 3000 }); + return false; + } + if (act.is_end == 1) { + wx.showToast({ title: '活动已经结束', icon: 'none', duration: 3000 }); + return false; + } + if (ut.gettimestamp() > act.end_time) { + wx.showToast({ title: "活动定金支付时间已过期", icon: 'none', duration: 3000 }); + return false; + } - var url = "/api/weshop/marketing/marketingPresellList/get/" + os.stoid + "/" + gg.presell_list_id; - await getApp().request.promiseGet(url, {}).then(res => { - if (res.data.code == 0) { - prelist = res.data.data; - } - }) - if (!prelist) { - wx.showToast({title: "未找到商品", icon: 'none', duration: 3000}); - return false; + var url = "/api/weshop/marketing/marketingPresellList/get/" + os.stoid + "/" + gg.presell_list_id; + await getApp().request.promiseGet(url, {}).then(res => { + if (res.data.code == 0) { + prelist = res.data.data; } + }) + if (!prelist) { + wx.showToast({ title: "未找到商品", icon: 'none', duration: 3000 }); + return false; + } - //这个位置要拿活动的预售价 - t.data.data.shop_price = prelist.presell_money; - th.setData({ - bn_goods: t.data.data, - bn_pickname: gg.pick_name, - bn_exp_type: et, - index: m_wind, - bn_pick: gg.pick_id, - bn_t_exp_t: distr_t, - bn_exp_type: et, - act:act - }); + //这个位置要拿活动的预售价 + t.data.data.shop_price = prelist.presell_money; + th.setData({ + bn_goods: t.data.data, + bn_pickname: gg.pick_name, + bn_exp_type: et, + index: m_wind, + bn_pick: gg.pick_id, + bn_t_exp_t: distr_t, + bn_exp_type: et, + act: act + }); - if(act.is_usecoupon==1){ - th.data.ckeck_quan_price = t.data.data.shop_price * gg.goods_num; - th.data.check_quan_price_list = t.data.data.shop_price * gg.goods_num + ""; - th.data.check_quan_ware_list = t.data.data.erpwareid + ""; - } + if (act.is_usecoupon == 1) { + th.data.ckeck_quan_price = t.data.data.shop_price * gg.goods_num; + th.data.check_quan_price_list = t.data.data.shop_price * gg.goods_num + ""; + th.data.check_quan_ware_list = t.data.data.erpwareid + ""; + } - //计算价格 - th.calculatePrice2(); - //获取优惠券,如果有券的钱,就调用 - if(th.data.ckeck_quan_price>0) th.get_buy_now_quan(); + //计算价格 + th.calculatePrice2(); + //获取优惠券,如果有券的钱,就调用 + if (th.data.ckeck_quan_price > 0) th.get_buy_now_quan(); - }, - }); + }, + }); }, @@ -507,14 +507,14 @@ Page({ checkAddressList: function () { var t = this; return !(!this.data.order || null == this.data.order.userAddress) || (wx.showModal({ - title: "请先填写或选择收货地址~", - success: function (a) { - a.confirm ? t.enterAddressPage() : wx.navigateBack(); - }, - fail: function () { - wx.navigateBack(); - } - }), !1); + title: "请先填写或选择收货地址~", + success: function (a) { + a.confirm ? t.enterAddressPage() : wx.navigateBack(); + }, + fail: function () { + wx.navigateBack(); + } + }), !1); }, showInvoice: function () { this.setData({ @@ -533,7 +533,7 @@ Page({ }, keyUpChangeNum: function (t) { var index = t.currentTarget.dataset.index; - var txt="user_note."+index; + var txt = "user_note." + index; this.setData({ maxWord: t.detail.value.length, [txt]: t.detail.value @@ -564,7 +564,7 @@ Page({ } } var set_txt = "cartlist[" + iter + "].can_num"; - th.setData({[set_txt]: num}); + th.setData({ [set_txt]: num }); } }, @@ -595,10 +595,10 @@ Page({ allpice = parseFloat(allpice).toFixed(2); var txt = "formData.all_price"; - th.setData({[txt]: allpice,}); + th.setData({ [txt]: allpice, }); if (cut_price) { var c_txt = "formData.cut_price"; - th.setData({[c_txt]: cut_price,}); + th.setData({ [c_txt]: cut_price, }); } @@ -612,7 +612,7 @@ Page({ to.getwuliuprice(async function (rs) { var o_shipping_price = 0, goods_weight = -1, goods_piece = -1; - var out_of_weight=null; //超出多少重量 + var out_of_weight = null; //超出多少重量 var freight_free = ee.freight_free; //全场满多少包邮 var weight_free = ee.weight_free; //多少kg内包邮 var no_ex_id = ee.no_ex_id; @@ -666,7 +666,7 @@ Page({ arr.push(item); } if (arr) { - th.setData({get_by_quan_list: arr}); + th.setData({ get_by_quan_list: arr }); } th.data.isget_by_quan[th.data.bn_pick] = 1; } @@ -682,8 +682,8 @@ Page({ if (goods_weight < 0) goods_weight = 0; //累积商品重量 每种商品的重量 * 数量 goods_weight += good['weight'] * good['buynum']; - if( weight_free > 0){ - out_of_weight = (weight_free * 1000 ) - goods_weight; + if (weight_free > 0) { + out_of_weight = (weight_free * 1000) - goods_weight; } break; case 3: @@ -695,18 +695,17 @@ Page({ var code = ""; if (th.data.wu_arr && th.data.wu_arr[th.data.index]) code = th.data.wu_arr[th.data.index].code; - + th.data.is_no_by[th.data.bn_pick] = 0; var no_by_data = null; var gift_freight_free = freight_free; - //有不包邮区域,且不免运费 if (no_ex_id && freight_free > 0 && freight_free <= parseFloat(allpice) - cut_price - quan_price) { //-----------获取不包邮区域,不包邮商品------- await getApp().request.promiseGet("/api/weshop/areaFeemail/getAreaGoods", { - data: {store_id: os.stoid, id: no_ex_id} + data: { store_id: os.stoid, id: no_ex_id } }).then(res => { if (res.data.code == 0 && res.data.data && res.data.data.length > 0) { no_by_data = res.data.data[0]; @@ -714,7 +713,8 @@ Page({ if (res.data.data[0].region_list) { if (th.check_by_area(res.data.data[0].region_list)) { freight_free = 0; - out_of_weight=0; + out_of_weight = 0; + weight_free=-1; th.data.is_no_by[th.data.bn_pick] = 1; } } @@ -722,7 +722,8 @@ Page({ if (res.data.data[0].goods_list && freight_free) { if (th.check_by_goods(res.data.data[0].goods_list)) { freight_free = 0; - out_of_weight=0; + out_of_weight = 0; + weight_free=-1; th.data.is_no_by[th.data.bn_pick] = 1; } } @@ -733,13 +734,13 @@ Page({ th.data.is_by[th.data.bn_pick] = 0; //--------------开始计算物流------------------ var shipping_price = - th.calculatewuliu(code, o_shipping_price, goods_weight,out_of_weight, - goods_piece, th.data.user_addr, freight_free, parseFloat(allpice) - cut_price - quan_price, rs); + th.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, + goods_piece, th.data.user_addr, freight_free, parseFloat(allpice) - cut_price - quan_price, rs,th.data.bn_pick); //如果有赠品的时候,也要计算赠品的物流费用 if (th.data.buy_now_gift_goods) { - shipping_price = th.get_now_gift_goods_wuliu(code, o_shipping_price, th.data.user_addr, gift_freight_free,out_of_weight,gift_weight_free, - parseFloat(allpice) - cut_price - quan_price, rs, shipping_price, no_by_data, goods_weight, goods_piece); + shipping_price = th.get_now_gift_goods_wuliu(code, o_shipping_price, th.data.user_addr, gift_freight_free, out_of_weight, gift_weight_free, + parseFloat(allpice) - cut_price - quan_price, rs, shipping_price, no_by_data, goods_weight, goods_piece,th.data.bn_pick); } if (shipping_price <= 0) { @@ -748,18 +749,18 @@ Page({ shipping_price = parseFloat(shipping_price).toFixed(2); var wl_txt = "formData.shipping_price"; - th.setData({[wl_txt]: shipping_price,}) + th.setData({ [wl_txt]: shipping_price, }) } else { var wl_txt = "formData.shipping_price"; - th.setData({[wl_txt]: 0,}) + th.setData({ [wl_txt]: 0, }) } if (quan_no) { if (th.data.using_quan[bn_pick].isby == 1) { shipping_price = 0; var wl_txt = "formData.shipping_price"; - th.setData({[wl_txt]: 0,}) + th.setData({ [wl_txt]: 0, }) } } //-----------------支付价,优惠券不减物流----------------- @@ -778,7 +779,7 @@ Page({ var order_prom_id = 0; if (th.data.order_prom[th.data.bn_pick]) { var ord_prom = th.data.order_prom[th.data.bn_pick]; - if(!ord_prom.is_xz_yh || quan_price<=0) { + if (!ord_prom.is_xz_yh || quan_price <= 0) { order_prom_id = ord_prom['id']; switch (ord_prom['type']) { case 0: @@ -796,7 +797,7 @@ Page({ if (order_prom_id > 0) { var order_prom_txt1 = "formData.order_prom_id"; var order_prom_txt2 = "formData.order_prom_amount"; - th.setData({[order_prom_txt1]: order_prom_id, [order_prom_txt2]: order_prom_amount}) + th.setData({ [order_prom_txt1]: order_prom_id, [order_prom_txt2]: order_prom_amount }) } total_m = parseFloat(total_m) + parseFloat(th.data.formData.shipping_price); @@ -806,7 +807,7 @@ Page({ order_m = order_m.toFixed(2); var atxt = "formData.total_amount"; - th.setData({[atxt]: total_m,}) + th.setData({ [atxt]: total_m, }) var txt = "formData.user_money"; var txt2 = "formData.order_amount"; @@ -816,43 +817,43 @@ Page({ if (th.data.bn_use_money == 1) { if (amoney > order_m) { order_m = parseFloat(order_m).toFixed(2); - th.setData({[txt]: order_m, [txt2]: 0, [txt3]: coupon_price, show_submit: 1}) + th.setData({ [txt]: order_m, [txt2]: 0, [txt3]: coupon_price, show_submit: 1 }) } else { order_m = parseFloat(order_m) - parseFloat(amoney); order_m = order_m.toFixed(2); - th.setData({[txt]: amoney, [txt2]: order_m, [txt3]: coupon_price, show_submit: 1}) + th.setData({ [txt]: amoney, [txt2]: order_m, [txt3]: coupon_price, show_submit: 1 }) } } else { - th.setData({[txt]: 0, [txt2]: order_m, [txt3]: coupon_price, show_submit: 1}) + th.setData({ [txt]: 0, [txt2]: order_m, [txt3]: coupon_price, show_submit: 1 }) } //优惠活动送积分 if (good.s_intValue) { txt = "formData.give_integral"; - th.setData({[txt]: good.s_intValue}); + th.setData({ [txt]: good.s_intValue }); } //优惠送券 if (good.s_coupon_id) { var i_txt = "formData.give_coupon_id"; //这个是json格式的 var i_txt1 = "formData.g_coupon_num"; - var ob = [{"num": good.s_coupon_num, "c_id": good.s_coupon_id}]; + var ob = [{ "num": good.s_coupon_num, "c_id": good.s_coupon_id }]; ob = JSON.stringify(ob); - th.setData({[i_txt]: good.s_coupon_id, [i_txt1]: ob}); + th.setData({ [i_txt]: good.s_coupon_id, [i_txt1]: ob }); } //优惠礼包 if (good.s_libao) { var l_txt = "formData.give_lb_id"; //这个是json格式的 var l_txt1 = "formData.g_lb_num"; - var ob = [{"num": good.s_lb_num, "l_id": good.s_libao}]; + var ob = [{ "num": good.s_lb_num, "l_id": good.s_libao }]; ob = JSON.stringify(ob); - th.setData({[l_txt]: good.s_libao, [l_txt1]: ob}); + th.setData({ [l_txt]: good.s_libao, [l_txt1]: ob }); } }) } else { var order_prom_txt1 = "formData.order_prom_id"; var order_prom_txt2 = "formData.order_prom_amount"; - th.setData({[order_prom_txt1]: 0, [order_prom_txt2]: 0}) + th.setData({ [order_prom_txt1]: 0, [order_prom_txt2]: 0 }) total_m = parseFloat(total_m) + parseFloat(th.data.formData.shipping_price); order_m = parseFloat(order_m) + parseFloat(th.data.formData.shipping_price); @@ -861,7 +862,7 @@ Page({ total_m = total_m.toFixed(2); order_m = order_m.toFixed(2); - th.setData({[atxt]: total_m,}) + th.setData({ [atxt]: total_m, }) var txt = "formData.user_money"; var txt2 = "formData.order_amount"; @@ -871,37 +872,37 @@ Page({ if (th.data.bn_use_money == 1) { if (amoney > order_m) { order_m = parseFloat(order_m).toFixed(2); - th.setData({[txt]: order_m, [txt2]: 0, [txt3]: coupon_price, show_submit: 1}) + th.setData({ [txt]: order_m, [txt2]: 0, [txt3]: coupon_price, show_submit: 1 }) } else { order_m = parseFloat(order_m) - parseFloat(amoney); order_m = order_m.toFixed(2); - th.setData({[txt]: amoney, [txt2]: order_m, [txt3]: coupon_price, show_submit: 1}) + th.setData({ [txt]: amoney, [txt2]: order_m, [txt3]: coupon_price, show_submit: 1 }) } } else { - th.setData({[txt]: 0, [txt2]: order_m, [txt3]: coupon_price, show_submit: 1}) + th.setData({ [txt]: 0, [txt2]: order_m, [txt3]: coupon_price, show_submit: 1 }) } //优惠活动送积分 if (good.s_intValue) { txt = "formData.give_integral"; - th.setData({[txt]: good.s_intValue}); + th.setData({ [txt]: good.s_intValue }); } //优惠送券 if (good.s_coupon_id) { var i_txt = "formData.give_coupon_id"; //这个是json格式的 var i_txt1 = "formData.g_coupon_num"; - var ob = [{"num": good.s_coupon_num, "c_id": good.s_coupon_id}]; + var ob = [{ "num": good.s_coupon_num, "c_id": good.s_coupon_id }]; ob = JSON.stringify(ob); - th.setData({[i_txt]: good.s_coupon_id, [i_txt1]: ob}); + th.setData({ [i_txt]: good.s_coupon_id, [i_txt1]: ob }); } //优惠礼包 if (good.s_libao) { var l_txt = "formData.give_lb_id"; //这个是json格式的 var l_txt1 = "formData.g_lb_num"; - var ob = [{"num": good.s_lb_num, "l_id": good.s_libao}]; + var ob = [{ "num": good.s_lb_num, "l_id": good.s_libao }]; ob = JSON.stringify(ob); - th.setData({[l_txt]: good.s_coupon_id, [l_txt1]: ob}); + th.setData({ [l_txt]: good.s_coupon_id, [l_txt1]: ob }); } } @@ -912,7 +913,7 @@ Page({ }, //--------------------提交订单----------------------- - async submitForm(t){ + async submitForm(t) { var sub_value = t; if (this.data.is_summit_ing == 1) return false; //--提交中退出-- @@ -985,7 +986,7 @@ Page({ } //--判断优惠活动的提交-- - if (th.data.formData.cut_price > 0 ) { + if (th.data.formData.cut_price > 0) { order_prom_list.discount_amount = th.data.formData.cut_price.toFixed(2); var ob = [{ "prom_id": th.data.bn_goods.prom_id, @@ -1048,7 +1049,7 @@ Page({ goods.guide_id = gg.guide_id; goods.guide_type = gg.guide_type; //调用接口判断是不是会员 - await getApp().request.promiseGet("/api/weshop/shoppingGuide/getId/" + oo.stoid + "/" + gg.guide_id, {}).then(res => { + await getApp().request.promiseGet("/api/weshop/shoppingGuide/getId/" + oo.stoid + "/" + gg.guide_id, {}).then(res => { if (res.data.code == 0) { goods.guide_name = res.data.data.salesman; goods.guide_sn = res.data.data.salesman_no; @@ -1100,7 +1101,7 @@ Page({ } var pt_res = null; - await getApp().request.promisePost("/api/weshop/order/getGoodsSplit", { + await getApp().request.promisePost("/api/weshop/order/getGoodsSplit", { is_json: 1, data: pt_data }).then(res => { @@ -1220,14 +1221,14 @@ Page({ order_prom_list.order_prom_amount = t_item.order_prom_amount; } - order_prom_list.discount_amount =0; + order_prom_list.discount_amount = 0; //--判断优惠活动的提交-- if (t_item.cut_price > 0) { order_prom_list.discount_amount += t_item.cut_price; order_prom_list.prom_pt_json = JSON.stringify(t_item.prom_pt_json); } //--判断组合优惠活动的提交-- - if (t_item.zh_cut_price > 0 || t_item.zh_cut_price<0) { + if (t_item.zh_cut_price > 0 || t_item.zh_cut_price < 0) { order_prom_list.discount_amount += t_item.zh_cut_price; order_prom_list.zh_pt_json = JSON.stringify(t_item.zh_pt_json); } @@ -1242,11 +1243,11 @@ Page({ order_prom_list.give_lb_id = t_item.s_libao; order_prom_list.g_lb_num = JSON.stringify(t_item.g_lb_num); } - if (Object.keys(order_prom_list).length > 0){ - if(order_prom_list.discount_amount) - order_prom_list.discount_amount= parseFloat(order_prom_list.discount_amount).toFixed(2); - if(order_prom_list.order_prom_amount) - order_prom_list.order_prom_amount= parseFloat(order_prom_list.order_prom_amount).toFixed(2); + if (Object.keys(order_prom_list).length > 0) { + if (order_prom_list.discount_amount) + order_prom_list.discount_amount = parseFloat(order_prom_list.discount_amount).toFixed(2); + if (order_prom_list.order_prom_amount) + order_prom_list.order_prom_amount = parseFloat(order_prom_list.order_prom_amount).toFixed(2); item.order_prom_list = order_prom_list; } @@ -1270,7 +1271,7 @@ Page({ //-------------让商品添加到商品列表-------------------- for (var k = 0; k < t_item.goods.length; k++) { var g_item = t_item.goods[k]; - if(g_item.goods_num<=0) continue; + if (g_item.goods_num <= 0) continue; var goods = { 'goods_id': g_item.goods_id, 'goods_name': g_item.goods_name, @@ -1283,7 +1284,7 @@ Page({ }; //-- 线下取价也要写入,组合购的商品不能去线下价格 -- - if (g_item.offline_price && t_item.is_offline == 1 && g_item.prom_type!=7) { + if (g_item.offline_price && t_item.is_offline == 1 && g_item.prom_type != 7) { goods.goods_price = g_item.offline_price; goods.member_goods_price = g_item.offline_price; goods.offline_cut = (g_item.goods_price - g_item.offline_price).toFixed(2); @@ -1294,7 +1295,7 @@ Page({ if (t_item.quan_youhui_list && t_item.coupon_price) { for (var kk in t_item.quan_youhui_list) { var you_item = t_item.quan_youhui_list[kk]; - if (g_item.prom_type!=7 && g_item.erpwareid == you_item.WareId) { + if (g_item.prom_type != 7 && g_item.erpwareid == you_item.WareId) { goods.quan_num = you_item.WareCashSum; goods.quan_no = you_item.CashRepNo; } @@ -1345,7 +1346,7 @@ Page({ } //把优惠的平摊结果写进去 - if (g_item.account >= 0 || (g_item.account_yu != 0 && g_item.account!=undefined)) { + if (g_item.account >= 0 || (g_item.account_yu != 0 && g_item.account != undefined)) { if (g_item.account >= 0) goods.account = g_item.account; if (g_item.account_yu != 0) goods.account_yu = g_item.account_yu; item.is_discount_amount = 1; @@ -1356,7 +1357,7 @@ Page({ goods.guide_id = g_item.guide_id; goods.guide_type = g_item.guide_type; //调用接口判断是不是会员 - await getApp().request.promiseGet("/api/weshop/shoppingGuide/getId/" + oo.stoid + "/" + g_item.guide_id, {}).then(res => { + await getApp().request.promiseGet("/api/weshop/shoppingGuide/getId/" + oo.stoid + "/" + g_item.guide_id, {}).then(res => { if (res.data.code == 0) { goods.guide_name = res.data.data.salesman; goods.guide_sn = res.data.data.salesman_no; @@ -1382,7 +1383,7 @@ Page({ if (pdata.length == 0) return; var str = JSON.stringify(pdata); - wx.showLoading({title: "加载中"}); + wx.showLoading({ title: "加载中" }); wx.request({ url: oo.url + '/api/weshop/order/createWxdOrder', data: str, @@ -1413,7 +1414,7 @@ Page({ }) //要进行判断,如果是用微信支付,就要跳转到支付界面 if (order_amount > 0) { - th.setData({isclose: 0}); + th.setData({ isclose: 0 }); //void e.jumpToCart4({ // order_sn: data.data, //}, 1); @@ -1428,12 +1429,12 @@ Page({ }, function () { //支付失败 setTimeout(function () { - var cps=getCurrentPages(); - if(cps.length>1){ - wx.navigateBack({delta: 1}) - }else{ - getApp().goto("/pages/index/index/index"); - } + var cps = getCurrentPages(); + if (cps.length > 1) { + wx.navigateBack({ delta: 1 }) + } else { + getApp().goto("/pages/index/index/index"); + } }, 1000) }, oo.stoid); @@ -1451,7 +1452,7 @@ Page({ if (t.data.code == 0) { //app.my_warnning("支付成功",1,th); //setTimeout(function () { - th.setData({isclose: 0}); + th.setData({ isclose: 0 }); wx.redirectTo({ url: "/pages/payment/pay_success/pay_success?type=2&order_sn=" + data.data, }) @@ -1476,7 +1477,7 @@ Page({ cancelText: '取消', confirmText: '确定', showCancel: true, - success(res){ + success(res) { if (res.cancel) { return; } else if (res.confirm) { @@ -1510,11 +1511,11 @@ Page({ }, //---确认线下门店的数量足不足--- - async check_store_num(goods_id, pick, goods_num, func){ + async check_store_num(goods_id, pick, goods_num, func) { var lock = 0, pick_no, plist, erpwareid; //先读取门店的lock await getApp().request.promiseGet("/api/weshop/order/ware/lock/page", { - data: {store_id: os.stoid, wareId: goods_id, storageId: pick, pageSize: 1000} + data: { store_id: os.stoid, wareId: goods_id, storageId: pick, pageSize: 1000 } }).then(res => { if (res.data.code == 0 && res.data.data.total > 0) { for (var i in res.data.data.pageData) @@ -1523,7 +1524,7 @@ Page({ }) //先获取门店的编号 await getApp().request.promiseGet("/api/weshop/pickup/get/" + os.stoid + "/" + pick, { - data: {storeId: os.stoid, goodsId: t.goods_id, pickupId: pick} + data: { storeId: os.stoid, goodsId: t.goods_id, pickupId: pick } }).then(res => { if (res.data.code == 0) { pick_no = res.data.data.pickup_no; @@ -1531,7 +1532,7 @@ Page({ }) //先获取商品的线下库存 await getApp().request.promiseGet("/api/weshop/goods/get/" + os.stoid + "/" + goods_id, { - data: {storeId: os.stoid, goodsId: t.goods_id, pickupId: pick} + data: { storeId: os.stoid, goodsId: t.goods_id, pickupId: pick } }).then(res => { if (res.data.code == 0) { erpwareid = res.data.data.erpwareid; @@ -1539,7 +1540,7 @@ Page({ }) //读取线下的门店库存 await getApp().request.promiseGet("/api/weshop/goods/getWareStorages", { - data: {storageNos: pick_no, wareIds: encodeURIComponent(erpwareid), storeId: os.stoid, pageSize: 2000} + data: { storageNos: pick_no, wareIds: encodeURIComponent(erpwareid), storeId: os.stoid, pageSize: 2000 } }).then(res => { if (res.data.code == 0) { plist = res.data.data.pageData[0]; @@ -1581,11 +1582,11 @@ Page({ wl_txt = t.currentTarget.dataset.wl_txt, ont = t.currentTarget.dataset.ont; - th.setData({[txt]: ty}); + th.setData({ [txt]: ty }); var iszt = 1; if (ty == 0) { - th.setData({is_all_zt: 0}); + th.setData({ is_all_zt: 0 }); } else { for (var i = 0; i < th.data.cartlist.length; i++) { var item = th.data.cartlist[i]; @@ -1595,7 +1596,7 @@ Page({ } } - th.setData({is_all_zt: iszt}); + th.setData({ is_all_zt: iszt }); var ind = t.currentTarget.dataset.ind; var c_item = th.data.cartlist[ind]; @@ -1603,7 +1604,7 @@ Page({ if (th.data.using_quan[pickid] && th.data.using_quan[pickid].isby == 1) { th.data.using_quan[pickid] = {}; - th.setData({using_quan: th.data.using_quan}); + th.setData({ using_quan: th.data.using_quan }); } @@ -1615,7 +1616,7 @@ Page({ for (var i = 0; i < wu_arr.length; i++) { if (wu_arr[i].shipping_code == def_exp_code) { var set_txt = "cartlist" - th.setData({wl_txt: i}); + th.setData({ wl_txt: i }); } } } @@ -1628,9 +1629,9 @@ Page({ setexptype: function (t) { var th = this; var ty = t.currentTarget.dataset.t, def_exp_code = getApp().globalData.userInfo.def_exp_code; - th.setData({bn_exp_type: ty}); + th.setData({ bn_exp_type: ty }); if (ty == 0) { - th.setData({is_all_zt: 0}); + th.setData({ is_all_zt: 0 }); } //当物流为空的时候。 @@ -1643,7 +1644,7 @@ Page({ if (ty == 1) { th.data.isget_by_quan = {}; if (th.data.using_quan[th.data.bn_pick] && th.data.using_quan[th.data.bn_pick].isby == 1) { - th.setData({using_quan: {}}); + th.setData({ using_quan: {} }); } } @@ -1653,7 +1654,7 @@ Page({ if (wu_arr != null && wu_arr != "") { for (var i = 0; i < wu_arr.length; i++) { if (wu_arr[i].shipping_code == def_exp_code) { - th.setData({index: i}); + th.setData({ index: i }); } } } @@ -1665,17 +1666,17 @@ Page({ //--------立即购买时,使用余额-------- set_bn_useyuer: function () { var th = this; - th.setData({bn_use_money: !th.data.bn_use_money}); + th.setData({ bn_use_money: !th.data.bn_use_money }); th.calculatePrice2(); }, set_js_useyuer: function () { var th = this; - th.setData({js_use_money: !th.data.js_use_money}); + th.setData({ js_use_money: !th.data.js_use_money }); th.calculatePrice(); }, //-------------------计算物流--------------- - calculatewuliu: function (code, o_shipping_price, goods_weight,out_of_weight, - goods_piece, user_addr, freight_free, o_price, rs) { + calculatewuliu: function (code, o_shipping_price, goods_weight, out_of_weight, + goods_piece, user_addr, freight_free, o_price, rs,pickid) { var price = 0, th = this; price += parseFloat(o_shipping_price); //如果是包邮 @@ -1706,8 +1707,8 @@ Page({ } } - //------超出重量---------- - if(out_of_weight < 0 && o_price >= freight_free){ + //------超出重量---------- + if (out_of_weight < 0 && o_price >= freight_free && !th.data.is_no_by[pickid]) { fw_price = parseFloat(item['money']); var out_of_weight = Math.abs(out_of_weight); var n = Math.ceil(out_of_weight / item['second_weight']) @@ -1750,13 +1751,13 @@ Page({ //----------立即购买,选择物流------------- bindPickerChange: function (e) { var ind = e.detail.value - this.setData({index: ind}); + this.setData({ index: ind }); this.calculatePrice2(); }, //----------购物车结算,选择物流------------- bindPickerChange_w: function (e) { var ind = e.detail.value, txt = e.currentTarget.dataset.txt; - this.setData({[txt]: ind}); + this.setData({ [txt]: ind }); this.calculatePrice(); }, @@ -1770,7 +1771,7 @@ Page({ if (bn == 1) { - th.setData({open_quan: 1, selected_quan_pick: pickid, disabled: 1}); + th.setData({ open_quan: 1, selected_quan_pick: pickid, disabled: 1 }); } else { //---多单打开券的时候,就要判断券在其他门店是否有使用--- var quanlist = th.data.cartlist[cindx].quan_list; @@ -1796,9 +1797,9 @@ Page({ else get_by_quan_list_cart[i].show_red = 0; } - th.setData({by_quan_list_cart: get_by_quan_list_cart}); + th.setData({ by_quan_list_cart: get_by_quan_list_cart }); } else { - th.setData({by_quan_list_cart: null}); + th.setData({ by_quan_list_cart: null }); } console.log("2222222券的列表", quanlist); @@ -1814,7 +1815,7 @@ Page({ }, close_coupon: function (e) { var th = this; - th.setData({open_quan: 0, disabled: 0}); + th.setData({ open_quan: 0, disabled: 0 }); }, //---判断券时候在已经选择的列表中--- @@ -1885,14 +1886,14 @@ Page({ for (var i in quanlist) { quanlist[i].show_red = 0; } - this.setData({selected_quan_list: quanlist}); + this.setData({ selected_quan_list: quanlist }); var by_quanlist = this.data.get_by_quan_list; if (by_quanlist) { //---所有的券的显示红色选择都清理一遍--- for (var inb in by_quanlist) { by_quanlist[inb].show_red = 0; } - this.setData({get_by_quan_list: by_quanlist}); + this.setData({ get_by_quan_list: by_quanlist }); } var by_cart_list = this.data.by_quan_list_cart; @@ -1901,7 +1902,7 @@ Page({ for (var inc in by_cart_list) { by_cart_list[inc].show_red = 0; } - this.setData({by_quan_list_cart: by_cart_list}); + this.setData({ by_quan_list_cart: by_cart_list }); } var using_quan = this.data.using_quan; @@ -1913,9 +1914,9 @@ Page({ using_quan[th.data.selected_quan_pick].is_nouse_red = 1; } else { - using_quan[th.data.selected_quan_pick] = {is_nouse_red: 1}; + using_quan[th.data.selected_quan_pick] = { is_nouse_red: 1 }; } - this.setData({using_quan: using_quan, is_coupon: 2222}); + this.setData({ using_quan: using_quan, is_coupon: 2222 }); return; } @@ -1932,9 +1933,9 @@ Page({ using_quan[th.data.selected_quan_pick].is_nouse_red = 0; } else { - using_quan[th.data.selected_quan_pick] = {is_nouse_red: 0}; + using_quan[th.data.selected_quan_pick] = { is_nouse_red: 0 }; } - this.setData({using_quan: using_quan}); + this.setData({ using_quan: using_quan }); }, @@ -1949,7 +1950,7 @@ Page({ for (var ind in by_quanlist) { by_quanlist[ind].show_red = 0; } - this.setData({get_by_quan_list: by_quanlist}); + this.setData({ get_by_quan_list: by_quanlist }); } //--购物车过来的包邮券-- @@ -1959,7 +1960,7 @@ Page({ for (var ind in by_cart_list) { by_cart_list[ind].show_red = 0; } - this.setData({by_quan_list_cart: by_cart_list}); + this.setData({ by_quan_list_cart: by_cart_list }); } //普通券 var quanlist = this.data.selected_quan_list; @@ -1968,7 +1969,7 @@ Page({ for (var ind in quanlist) { quanlist[ind].show_red = 0; } - this.setData({selected_quan_list: quanlist}); + this.setData({ selected_quan_list: quanlist }); } var th = this; @@ -1979,9 +1980,9 @@ Page({ using_quan[th.data.selected_quan_pick].is_nouse_red = 1; } else { - using_quan[th.data.selected_quan_pick] = {is_nouse_red: 1}; + using_quan[th.data.selected_quan_pick] = { is_nouse_red: 1 }; } - this.setData({using_quan: using_quan, is_coupon: 2222}); + this.setData({ using_quan: using_quan, is_coupon: 2222 }); return; } @@ -1992,20 +1993,20 @@ Page({ var txt1 = ""; var quan_item = null; - quan_item = this.data.get_by_quan_list[ind]; - txt = "get_by_quan_list[" + ind + "].show_red"; - var obj = {}; - obj[txt] = 1; - this.setData(obj); + quan_item = this.data.get_by_quan_list[ind]; + txt = "get_by_quan_list[" + ind + "].show_red"; + var obj = {}; + obj[txt] = 1; + this.setData(obj); if (using_quan[th.data.selected_quan_pick]) { using_quan[th.data.selected_quan_pick].is_nouse_red = 0; } else { - using_quan[th.data.selected_quan_pick] = {is_nouse_red: 0}; + using_quan[th.data.selected_quan_pick] = { is_nouse_red: 0 }; } - this.setData({using_quan: using_quan}); + this.setData({ using_quan: using_quan }); }, //--确认使用券--- @@ -2065,14 +2066,14 @@ Page({ //选择了的券,看是不是点击了不使用券,点击了不使用优惠券 if (using_quan[pickid]) { if (using_quan[pickid].is_nouse_red == 1) { - using_quan[pickid] = {is_nouse_red: 1}; - th.setData({using_quan: using_quan}); + using_quan[pickid] = { is_nouse_red: 1 }; + th.setData({ using_quan: using_quan }); if (th.data.is_b_now == 1) { th.calculatePrice2(); } else { th.calculatePrice(); } - th.setData({open_quan: 0}); + th.setData({ open_quan: 0 }); return; } } @@ -2091,13 +2092,13 @@ Page({ }; using_quan[pickid].isby = 1; } else { - using_quan[pickid] = {coupon_no: item.CashRepNo, money: item.Sum, is_nouse_red: 0}; + using_quan[pickid] = { coupon_no: item.CashRepNo, money: item.Sum, is_nouse_red: 0 }; using_quan[pickid].isby = 0; } - this.setData({using_quan: using_quan}); + this.setData({ using_quan: using_quan }); th.calculatePrice2(); - th.setData({open_quan: 0}); + th.setData({ open_quan: 0 }); }, cart_set_err: function (e) { @@ -2134,7 +2135,7 @@ Page({ var wu_arr_txt = e.currentTarget.dataset.txt; var w_sele_index = e.currentTarget.dataset.w_sele_index; var is_express = null; - var ob = {open_express: 1, wu_arr_txt: wu_arr_txt, disabled: 1}; + var ob = { open_express: 1, wu_arr_txt: wu_arr_txt, disabled: 1 }; //--如果是多个门店的时候-- if (w_sele_index != undefined) { @@ -2145,20 +2146,20 @@ Page({ }, // 关闭物流的弹窗 close_express: function () { - this.setData({open_express: 0, disabled: 0}); + this.setData({ open_express: 0, disabled: 0 }); }, // 选择物流 click_express_name: function (e) { var express_name = e.currentTarget.dataset.name, shippingcode = e.currentTarget.dataset.shippingcode; var index = e.currentTarget.dataset.idxe; - var ob = {is_express: index, is_shipping_code: shippingcode, disabled: 0}; + var ob = { is_express: index, is_shipping_code: shippingcode, disabled: 0 }; ob[this.data.wu_arr_txt] = index; this.setData(ob); }, //点击确定物流 determine_expres: function (e) { - this.setData({open_express: 0}); + this.setData({ open_express: 0 }); if (this.data.is_b_now == 1) this.calculatePrice2(); else @@ -2178,7 +2179,7 @@ Page({ obj[txt] = is_open; this.setData(obj); - this.setData({disabled: 1}) + this.setData({ disabled: 1 }) }, clik_coupons2: function (e) { @@ -2193,7 +2194,7 @@ Page({ obj[txt] = is_open; this.setData(obj); - this.setData({disabled: 1}) + this.setData({ disabled: 1 }) }, @@ -2202,11 +2203,11 @@ Page({ var th = this; var is_shipping_code = this.data.is_shipping_code getApp().request.put("/api/weshop/users/update", { - data: {user_id: getApp().globalData.user_id, store_id: oo.stoid, def_exp_code: is_shipping_code}, + data: { user_id: getApp().globalData.user_id, store_id: oo.stoid, def_exp_code: is_shipping_code }, success: function (rse) { if (rse.data.code == 0) { getApp().globalData.userInfo.def_exp_code = is_shipping_code; - th.setData({open_express: 0}); + th.setData({ open_express: 0 }); //----计算此时购物车的价格---- if (th.data.is_b_now == 1) th.calculatePrice2(); else th.calculatePrice(); @@ -2216,7 +2217,7 @@ Page({ }, //更新下默认,在onshow里面 - update_code(){ + update_code() { var th = this, m_wind = 0, def_exp_code = getApp().globalData.userInfo.def_exp_code; //--定时器,判断wu_arr不未空-- var uii = setInterval(function () { @@ -2230,7 +2231,7 @@ Page({ } //--如果是立即购买-- if (th.data.is_b_now == 1) { - th.setData({index: m_wind, is_express: m_wind}); + th.setData({ index: m_wind, is_express: m_wind }); } else { var ui = setInterval(function () { if (th.data.cartlist) { @@ -2238,7 +2239,7 @@ Page({ for (var i in c_arr) { c_arr[i].wind = m_wind; } - th.setData({cartlist: c_arr, is_express: m_wind}) + th.setData({ cartlist: c_arr, is_express: m_wind }) clearInterval(ui); } }, 500) @@ -2339,10 +2340,10 @@ Page({ if (th.data.is_b_now) { if (arr && arr.length > 0) { var quanlist = arr[0].quan_list; - th.setData({selected_quan_list: quanlist, cartlist: arr}) + th.setData({ selected_quan_list: quanlist, cartlist: arr }) } } else { - th.setData({cartlist: arr}) + th.setData({ cartlist: arr }) th.set_can_num(); } @@ -2362,7 +2363,7 @@ Page({ if (th.data.is_close_quan != 1 && th.data.bn_goods.is_xz_yh != 1) { var url0 = "/api/weshop/users/frozenQuan/listFrozenQuan/" + app.globalData.user_id; var url = "/api/weshop/couponList/getUseCouponList"; - app.request.promiseGet(url0, {1: 1}).then(res => { + app.request.promiseGet(url0, { 1: 1 }).then(res => { if (res.data.code == 0) { frozenQuan = res.data.data; th.data.frozenQuan = frozenQuan; @@ -2380,7 +2381,7 @@ Page({ quanlist = res.data.data.pageData; if (quanlist) { quanlist = th.check_is_frozenQuan(quanlist, frozenQuan); - th.setData({selected_quan_list: quanlist}) + th.setData({ selected_quan_list: quanlist }) } } } @@ -2408,7 +2409,7 @@ Page({ if (!goods_id) goods_id = this.data.bn_goods.goods_id; for (var i in arr) { var item = arr[i]; - if (goods_id == item) return 0; + if (goods_id == item) return 0; } return 1; }, @@ -2479,7 +2480,7 @@ Page({ pick = this.data.bn_pick; //---获取订单优惠--- getApp().request.promiseGet("/api/weshop/promorder/getOrderPromotion", { - data: {store_id: os.stoid, orderAmount: condition} + data: { store_id: os.stoid, orderAmount: condition } }).then(res => { if (res.data.code == 0) { var data = res.data.data; @@ -2501,7 +2502,7 @@ Page({ var ob = map[pickid][item.prom_id]; ob.price += item.goods_price * item.goods_num; ob.goods_num += item.goods_num; - ob.goods.push({goods_id: item.goods_id, goods_price: item.goods_price, goods_num: item.goods_num}); + ob.goods.push({ goods_id: item.goods_id, goods_price: item.goods_price, goods_num: item.goods_num }); } else { var prom = null; @@ -2517,7 +2518,7 @@ Page({ ob.is_bz = prom.is_bz; ob.is_xz_yh = prom.is_xz_yh; ob.goods = new Array(); - ob.goods.push({goods_id: item.goods_id, goods_price: item.goods_price, goods_num: item.goods_num}); + ob.goods.push({ goods_id: item.goods_id, goods_price: item.goods_price, goods_num: item.goods_num }); map[pickid][item.prom_id] = ob; } } else { @@ -2534,7 +2535,7 @@ Page({ ob.is_bz = prom.is_bz; ob.is_xz_yh = prom.is_xz_yh; ob.goods = new Array(); - ob.goods.push({goods_id: item.goods_id, goods_price: item.goods_price, goods_num: item.goods_num}); + ob.goods.push({ goods_id: item.goods_id, goods_price: item.goods_price, goods_num: item.goods_num }); var obj = {}; obj[item.prom_id] = ob; @@ -2544,7 +2545,7 @@ Page({ }, //计算立即购买赠品的物流费用 - get_now_gift_goods_wuliu: function (code, o_shipping_price, user_addr, gift_freight_free,gift_weight_free,out_of_weight,allpice, rs, shipping_price, no_by_data, goods_weight1, goods_piece1) { + get_now_gift_goods_wuliu: function (code, o_shipping_price, user_addr, gift_freight_free, gift_weight_free, out_of_weight, allpice, rs, shipping_price, no_by_data, goods_weight1, goods_piece1,pickid) { var good = this.data.buy_now_gift_goods; var goods_weight = -1, goods_piece = -1; var gift_shipping_price = 0; @@ -2560,7 +2561,7 @@ Page({ //累积商品重量 每种商品的重量 * 数量 goods_weight += good['weight'] * good['buynum']; if (goods_weight1 > 0) { - out_of_weight = gift_weight_free - goods_weight; + out_of_weight = gift_weight_free - goods_weight; //不能调换位置 下面goods_weight会变大 goods_weight += goods_weight1; } @@ -2580,7 +2581,7 @@ Page({ if (no_by_data && no_by_data.region_list) { if (th.check_by_area(no_by_data.region_list)) { gift_freight_free = 0; - out_of_weight=0; + out_of_weight = 0; th.data.is_no_by[th.data.bn_pick] = 1; } } @@ -2588,14 +2589,14 @@ Page({ if (no_by_data && no_by_data.goods_list && gift_freight_free) { if (th.check_by_goods(no_by_data.goods_list, good.goods_id)) { gift_freight_free = 0; - out_of_weight=0; - //th.data.is_no_by[th.data.bn_pick]=1; + out_of_weight = 0; + th.data.is_no_by[th.data.bn_pick]=1; } } var t_shipping_price = - this.calculatewuliu(code, gift_shipping_price, goods_weight,out_of_weight, - goods_piece, user_addr, gift_freight_free, allpice, rs); + this.calculatewuliu(code, gift_shipping_price, goods_weight, out_of_weight, + goods_piece, user_addr, gift_freight_free, allpice, rs,th.data.bn_pick); return t_shipping_price; }, @@ -2652,7 +2653,7 @@ Page({ //跳转关闭弹出框的显示 close_offline: function () { - this.setData({is_offline_show: 0}); + this.setData({ is_offline_show: 0 }); }, //立即购买显示弹出框 @@ -2660,7 +2661,7 @@ Page({ var off_price = this.data.bn_goods.shop_price - this.data.bn_goods.offline_price; //是不是线下 var is_get_offline = this.data.bn_goods.is_offline; - this.setData({is_offline_show: 1, show_off_price: off_price.toFixed(2), is_get_offline: is_get_offline}); + this.setData({ is_offline_show: 1, show_off_price: off_price.toFixed(2), is_get_offline: is_get_offline }); }, //确定使用线下取价 @@ -2668,14 +2669,14 @@ Page({ var bn_goods = this.data.bn_goods; if (bn_goods && bn_goods.prom_type == 0) { bn_goods.is_offline = 1; - this.setData({is_offline_show: 0, bn_goods: bn_goods}); + this.setData({ is_offline_show: 0, bn_goods: bn_goods }); this.calculatePrice2(); } //就是购物车结算时的 else { var index = this.data.pop_offline_index; var txt = "cartlist[" + index + "].is_offline"; - this.setData({[txt]: 1, is_offline_show: 0,}); + this.setData({ [txt]: 1, is_offline_show: 0, }); this.data.old_cartlist[index].is_offline = 1; this.calculatePrice(); } @@ -2688,14 +2689,14 @@ Page({ var bn_goods = this.data.bn_goods; if (bn_goods && bn_goods.prom_type == 0) { bn_goods.is_offline = 0; - this.setData({is_offline_show: 0, bn_goods: bn_goods}); + this.setData({ is_offline_show: 0, bn_goods: bn_goods }); this.calculatePrice2(); } //就是购物车结算时的 else { var index = this.data.pop_offline_index; var txt = "cartlist[" + index + "].is_offline"; - this.setData({[txt]: 0, is_offline_show: 0,}) + this.setData({ [txt]: 0, is_offline_show: 0, }) this.data.old_cartlist[index].is_offline = 0; this.calculatePrice(); } @@ -2716,16 +2717,16 @@ Page({ }); }, - set_hid_inp:function (e) { + set_hid_inp: function (e) { var index = e.currentTarget.dataset.index; var txt = "cartlist[" + index + "].focus"; - this.setData({[txt]:1}) + this.setData({ [txt]: 1 }) }, - clear_hid_inp:function (e) { + clear_hid_inp: function (e) { var index = e.currentTarget.dataset.index; var txt = "cartlist[" + index + "].focus"; - this.setData({[txt]:0}) + this.setData({ [txt]: 0 }) }, diff --git a/packageC/pages/presell/cart/cart2_pre.js b/packageC/pages/presell/cart/cart2_pre.js index cbf65f4..71625c1 100644 --- a/packageC/pages/presell/cart/cart2_pre.js +++ b/packageC/pages/presell/cart/cart2_pre.js @@ -1,5 +1,5 @@ -var t = getApp(),app=t, a = t.request, ut = require("../../../../utils/util.js"); -var os=t.globalData.setting; +var t = getApp(), app = t, a = t.request, ut = require("../../../../utils/util.js"); +var os = t.globalData.setting; var regeneratorRuntime = require('../../../../utils/runtime.js'); var util_pay = require("../../../../utils/pay.js"); @@ -20,132 +20,132 @@ Page({ enterAddressPage: !1, firstEnter: !0, //页面获取的参数 - param:null, - postdata:null, + param: null, + postdata: null, //提交订单的格式 formData: { - order_amount:0,//支付金额 - total_amount:0,//总价 - all_price:0,//商品卖的总价 + order_amount: 0,//支付金额 + total_amount: 0,//总价 + all_price: 0,//商品卖的总价 pay_points: 0,//使用积分 user_money: 0,//使用余额 couponCode: "",//使用优惠券(多单就用逗号隔开) - shipping_price:0,//物流费用 + shipping_price: 0,//物流费用 }, /*----------------立即购买---------------------*/ - is_b_now:0, //0是购物车结算 1立即购买 - bn_goods:null, //立即购买时候的调用商品 - bn_use_money:0,//是否使用余额 - bn_exp_type:1, //0是物流 1自提 - bn_pick:0, //选择的门店 + is_b_now: 0, //0是购物车结算 1立即购买 + bn_goods: null, //立即购买时候的调用商品 + bn_use_money: 0,//是否使用余额 + bn_exp_type: 1, //0是物流 1自提 + bn_pick: 0, //选择的门店 bn_pickname: "", //选择的门店名称 - bn_t_exp_t:0, //判断商品和门店一起决定的物流自提的方式0 都可以 1自提 2物流 + bn_t_exp_t: 0, //判断商品和门店一起决定的物流自提的方式0 都可以 1自提 2物流 /*------------------------*/ - user_addr:null,//物流 - userinfo:null, //获取会员 + user_addr: null,//物流 + userinfo: null, //获取会员 /*----------物流选择--------*/ - wu_arr:null, - index:0, + wu_arr: null, + index: 0, //判断页面是返回回来的还是 首次进入的 - isclose:1, - is_express:0,//选择物流的控制器 - yuer:0, - agree_no_ref:0 + isclose: 1, + is_express: 0,//选择物流的控制器 + yuer: 0, + agree_no_ref: 0 }, - onLoad: function(t) { + onLoad: function (t) { wx.setNavigationBarTitle({ title: "填写订单", }); - var th = this; this.setData({ is_b_now: 1}); - th.data.postdata=getApp().get_b_now(); - th.data.param=t; - + var th = this; this.setData({ is_b_now: 1 }); + th.data.postdata = getApp().get_b_now(); + th.data.param = t; + }, - onUnload: function () { this.setData({ isclose: 1 })}, + onUnload: function () { this.setData({ isclose: 1 }) }, //------获取会员信息-----先获取用户信息,在进行下一步--- - get_info:function(func){ - var user_id = t.globalData.user_id; - app.auth.get_u(func); + get_info: function (func) { + var user_id = t.globalData.user_id; + app.auth.get_u(func); }, //-------------------获取物流--------------- get_wuliu(func) { - var th = this; - app.getwuliu(function (e) { - if (th.data.is_default_logistics) { - //如果第一个不是开启默认,说明要让用户自己选 - if (!e[0].is_default) { - th.setData({ is_default_logistics: 0 }); - } - } - th.setData({ wu_arr: e }) - typeof func == "function" && func(); - }) + var th = this; + app.getwuliu(function (e) { + if (th.data.is_default_logistics) { + //如果第一个不是开启默认,说明要让用户自己选 + if (!e[0].is_default) { + th.setData({ is_default_logistics: 0 }); + } + } + th.setData({ wu_arr: e }) + typeof func == "function" && func(); + }) }, //------获取会员收货地址----- - getuser_addr:function(func){ - if (app.globalData.baddr!=null){ - var user_addr =app.globalData.baddr; - app.globalData.baddr=null; - func(user_addr); - }else{ - a.get("/api/weshop/useraddress/page", { - data: { user_id:app.globalData.user_id, store_id: os.stoid, pageSize: 600 }, - success: function (su) { - - var user_addr = su.data.data.pageData; - var item = null; - var def_item=null; - for (var i = 0; i < user_addr.length; i++) { - if (user_addr[i]['is_default'] == 1) { def_item = user_addr[i]; } - if (user_addr[i]['is_pickup'] == 1) { item = user_addr[i]; } - } - if (item == null) item = def_item; - if (item == null) item = user_addr[0]; - if (item == undefined) item = null; - func(item); - } - }); - } + getuser_addr: function (func) { + if (app.globalData.baddr != null) { + var user_addr = app.globalData.baddr; + app.globalData.baddr = null; + func(user_addr); + } else { + a.get("/api/weshop/useraddress/page", { + data: { user_id: app.globalData.user_id, store_id: os.stoid, pageSize: 600 }, + success: function (su) { + + var user_addr = su.data.data.pageData; + var item = null; + var def_item = null; + for (var i = 0; i < user_addr.length; i++) { + if (user_addr[i]['is_default'] == 1) { def_item = user_addr[i]; } + if (user_addr[i]['is_pickup'] == 1) { item = user_addr[i]; } + } + if (item == null) item = def_item; + if (item == null) item = user_addr[0]; + if (item == undefined) item = null; + func(item); + } + }); + } }, //----------------展示页面,是再获取用户信息之后-------------- - show_page:function(){ - var th=this; - var user=getApp().globalData.userInfo; - getApp().request.get("/api/weshop/users/get/" + os.stoid + "/" + user.user_id, { - data:{r:Math.random()}, - success: function (e) { - - getApp().globalData.userInfo = e.data.data; - th.setData({userinfo:e.data.data}); - //获取立即购买的商品信息 - th.get_buy_goods(); - - //获取提现金额 - getApp().request.get("/api/weshop/withdrawals/summoney", { - data: { user_id:app.globalData.user_id, store_id: os.stoid, status: 0 }, - success: function (su) { - if (su.data.code == 0) { - var yuer = parseFloat(th.data.userinfo.user_money - - (th.data.userinfo.frozen_money>0?th.data.userinfo.frozen_money:0) - su.data.data.summoney).toFixed(2); - if(yuer<0) yuer=0; - th.setData({ txmon: su.data.data.summoney, yuer: yuer }); - } - } - }); - } - }); + show_page: function () { + var th = this; + var user = getApp().globalData.userInfo; + getApp().request.get("/api/weshop/users/get/" + os.stoid + "/" + user.user_id, { + data: { r: Math.random() }, + success: function (e) { + + getApp().globalData.userInfo = e.data.data; + th.setData({ userinfo: e.data.data }); + //获取立即购买的商品信息 + th.get_buy_goods(); + + //获取提现金额 + getApp().request.get("/api/weshop/withdrawals/summoney", { + data: { user_id: app.globalData.user_id, store_id: os.stoid, status: 0 }, + success: function (su) { + if (su.data.code == 0) { + var yuer = parseFloat(th.data.userinfo.user_money - + (th.data.userinfo.frozen_money > 0 ? th.data.userinfo.frozen_money : 0) - su.data.data.summoney).toFixed(2); + if (yuer < 0) yuer = 0; + th.setData({ txmon: su.data.data.summoney, yuer: yuer }); + } + } + }); + } + }); }, //-----获取立即购买的商品信息---- get_buy_goods: async function () { var th = this, a = getApp().request; //定义变量 - var gg = th.data.postdata,act = null,prelist = null; + var gg = th.data.postdata, act = null, prelist = null; var url = "/api/weshop/marketing/marketingPresellForm/get/" + os.stoid + "/" + gg.prom_id; await getApp().request.promiseGet(url, {}).then(res => { if (res.data.code == 0) { @@ -153,15 +153,15 @@ Page({ } }) if (!act) { - wx.showToast({title: "未找到活动", icon: 'none', duration: 3000}); + wx.showToast({ title: "未找到活动", icon: 'none', duration: 3000 }); return false; } - if (act.is_end==1 ) { - wx.showToast({title:'活动已经结束' , icon: 'none', duration: 3000}); + if (act.is_end == 1) { + wx.showToast({ title: '活动已经结束', icon: 'none', duration: 3000 }); return false; } - if( ut.gettimestamp()>act.end_time){ - wx.showToast({title:"活动定金支付时间已过期" , icon: 'none', duration: 3000}); + if (ut.gettimestamp() > act.end_time) { + wx.showToast({ title: "活动定金支付时间已过期", icon: 'none', duration: 3000 }); return false; } @@ -172,7 +172,7 @@ Page({ } }) if (!prelist) { - wx.showToast({title: "未找到商品", icon: 'none', duration: 3000}); + wx.showToast({ title: "未找到商品", icon: 'none', duration: 3000 }); return false; } //-- 调用商品 -- @@ -191,7 +191,7 @@ Page({ distr_t = t.data.data.distr_type; } - if(act.presell_type==1){ + if (act.presell_type == 1) { switch (distr_t) { case 0: et = 1; @@ -205,13 +205,13 @@ Page({ et = 0; break; } - }else{ - et=1; //要付定金的时候 + } else { + et = 1; //要付定金的时候 } t.data.data.shop_price = prelist.presell_money; th.setData({ - bn_goods: t.data.data, bn_pickname: gg.pick_name,prelist:prelist,act:act, + bn_goods: t.data.data, bn_pickname: gg.pick_name, prelist: prelist, act: act, bn_pick: gg.pick_id, bn_t_exp_t: distr_t, bn_exp_type: et }); //计算价格 @@ -222,270 +222,269 @@ Page({ //----------子页返回父页触发---------- onShow: function () { - var th = this; - if (th.data.isclose == 0) { - wx.navigateTo({ - url: "/pages/index/index/index" - }) - } else { - this.getuser_addr(function (ie) { - //更换地址回来要重新调用计算价钱的接口 - th.setData({ user_addr: ie }); - if (!th.data.user_addr || th.data.user_addr.address_id != ie.address_id) { - th.setData({ add_back: 1 }); - if (this.data.bn_goods) th.calculatePrice2(); - } - }) - //--更新默认地址--,看一下是不是跳到地址页面 - if (!getApp().globalData.is_cart_old) { - this.update_code(); + var th = this; + if (th.data.isclose == 0) { + wx.navigateTo({ + url: "/pages/index/index/index" + }) } else { - getApp().globalData.is_cart_old = 0; - } - } - - //先获取是否有关闭使用优惠券 - getApp().getConfig2(function (ee) { - var json_d = JSON.parse(ee.switch_list); - th.data.json_d = json_d; - th.data.ispt_goods = json_d.ispt_goods; //是不是平摊到单品的控制参数赋值 - var is_default_logistics = json_d.is_default_logistics; - - th.setData({ is_close_quan: json_d.is_close_quan, sales_rules: ee.sales_rules, rank_switch: json_d.rank_switch, is_default_logistics: is_default_logistics }); - - var rank_switch = json_d.rank_switch; - var max_price = -1; - var show_card = null; - var name = ""; - //如果有开等级卡的时候, - //因为都是调接口,要返回在计算 - if (rank_switch == 2) { - //-- 获取所有的等级卡, -- - getApp().request.promiseGet("/api/weshop/plus/vip/mem/bership/list?storeId=" + os.stoid, - {}).then(res => { - if (res.data.code == 0) { - var plusCard = res.data.data; - //-- 循环判断,拿到最贵的那张卡 -- - for (var ih in plusCard) { - if (plusCard[ih].IsStopBuy == true) { continue; } - if (max_price < 0) { - max_price = plusCard[ih].CardFee; - name = 'card' + plusCard[ih]['CorrPrice']; - show_card = plusCard[ih]; - } else { - if (max_price < plusCard[ih].CardFee) { - max_price = plusCard[ih].CardFee; - name = 'card' + plusCard[ih]['CorrPrice']; - show_card = plusCard[ih]; - } - } - } - - if (show_card) { - name = name.toLowerCase(); - th.setData({ card_name: name, show_card: show_card }) + this.getuser_addr(function (ie) { + //更换地址回来要重新调用计算价钱的接口 + th.setData({ user_addr: ie }); + if (!th.data.user_addr || th.data.user_addr.address_id != ie.address_id) { + th.setData({ add_back: 1 }); + if (this.data.bn_goods) th.calculatePrice2(); } - } - //-----先获取物流,再获取用户信息,再展示页面----- - th.get_wuliu(th.get_info(th.show_page)); }) - } else { - //-----先获取物流,再获取用户信息,再展示页面----- - th.get_wuliu(th.get_info(th.show_page)); + //--更新默认地址--,看一下是不是跳到地址页面 + if (!getApp().globalData.is_cart_old) { + this.update_code(); + } else { + getApp().globalData.is_cart_old = 0; + } } - }, 1) + + //先获取是否有关闭使用优惠券 + getApp().getConfig2(function (ee) { + var json_d = JSON.parse(ee.switch_list); + th.data.json_d = json_d; + th.data.ispt_goods = json_d.ispt_goods; //是不是平摊到单品的控制参数赋值 + var is_default_logistics = json_d.is_default_logistics; + + th.setData({ is_close_quan: json_d.is_close_quan, sales_rules: ee.sales_rules, rank_switch: json_d.rank_switch, is_default_logistics: is_default_logistics }); + + var rank_switch = json_d.rank_switch; + var max_price = -1; + var show_card = null; + var name = ""; + //如果有开等级卡的时候, + //因为都是调接口,要返回在计算 + if (rank_switch == 2) { + //-- 获取所有的等级卡, -- + getApp().request.promiseGet("/api/weshop/plus/vip/mem/bership/list?storeId=" + os.stoid, + {}).then(res => { + if (res.data.code == 0) { + var plusCard = res.data.data; + //-- 循环判断,拿到最贵的那张卡 -- + for (var ih in plusCard) { + if (plusCard[ih].IsStopBuy == true) { continue; } + if (max_price < 0) { + max_price = plusCard[ih].CardFee; + name = 'card' + plusCard[ih]['CorrPrice']; + show_card = plusCard[ih]; + } else { + if (max_price < plusCard[ih].CardFee) { + max_price = plusCard[ih].CardFee; + name = 'card' + plusCard[ih]['CorrPrice']; + show_card = plusCard[ih]; + } + } + } + + if (show_card) { + name = name.toLowerCase(); + th.setData({ card_name: name, show_card: show_card }) + } + } + //-----先获取物流,再获取用户信息,再展示页面----- + th.get_wuliu(th.get_info(th.show_page)); + }) + } else { + //-----先获取物流,再获取用户信息,再展示页面----- + th.get_wuliu(th.get_info(th.show_page)); + } + }, 1) }, //---------------检查是否有收货地址------------------- - checkAddressList: function() { + checkAddressList: function () { var t = this; return !(!this.data.order || null == this.data.order.userAddress) || (wx.showModal({ title: "请先填写或选择收货地址~", - success: function(a) { + success: function (a) { a.confirm ? t.enterAddressPage() : wx.navigateBack(); }, - fail: function() { + fail: function () { wx.navigateBack(); } }), !1); }, - showInvoice: function() { + showInvoice: function () { this.setData({ invoiceToggle: !this.data.invoiceToggle }); }, - keyUpChangePay1: function(t) { + keyUpChangePay1: function (t) { this.setData({ payWithUserMoney: !(t.detail.value.length > 0) }); }, - keyUpChangePay2: function(t) { + keyUpChangePay2: function (t) { this.setData({ payWithPoints: !(t.detail.value.length > 0) }); }, - keyUpChangeNum: function(t) { + keyUpChangeNum: function (t) { this.setData({ maxWord: t.detail.value.length }); }, //---------计算立即购买---------- calculatePrice2: function () { - console.log('calculatePrice2'); - var th = this, good = this.data.bn_goods; - //-----------计算商品总价-------------- - var allpice = good.shop_price * good.buynum; - allpice=parseFloat(allpice).toFixed(2); - var txt = "formData.all_price"; - th.setData({ [txt]: allpice, }); - console.log(th.data.formData); - - app.getConfig2(function (ee) { - app.getwuliuprice(function (rs) { + console.log('calculatePrice2'); + var th = this, good = this.data.bn_goods; + //-----------计算商品总价-------------- + var allpice = good.shop_price * good.buynum; + allpice = parseFloat(allpice).toFixed(2); + var txt = "formData.all_price"; + th.setData({ [txt]: allpice, }); + console.log(th.data.formData); + + app.getConfig2(function (ee) { + app.getwuliuprice(function (rs) { var o_shipping_price = 0, goods_weight = -1, goods_piece = -1; - var out_of_weight=null; //超出多少重量 + var out_of_weight = null; //超出多少重量 var freight_free = ee.freight_free; //全场满多少包邮 var weight_free = ee.weight_free; //多少kg内包邮 var no_ex_id = ee.no_ex_id; - //-----------当地址不为空,且是物流时,计算物流费用,同时阶梯团不计算拼团价格---------- - if (th.data.user_addr != null && th.data.bn_exp_type == 0 - && good.is_free_shipping == 0 && (th.data.kt_type!=3 || th.data.bn_goods.is_normal==1) ){ - switch (good['exp_sum_type']) { - case 1: - //统一运费 - o_shipping_price += good['uniform_exp_sum']; break; - case 2: - if (goods_weight < 0) goods_weight = 0; - //累积商品重量 每种商品的重量 * 数量 - goods_weight += good['weight'] * good['buynum']; - if(weight_free > 0){ - out_of_weight = (weight_free * 1000 ) - goods_weight; - } - break; - case 3: - if (goods_piece < 0) goods_piece = 0; - //累积商品数量 - goods_piece += good['buynum']; break; - } - - var code = th.data.wu_arr[th.data.index].code; - var shipping_price= - th.calculatewuliu(code, o_shipping_price, goods_weight,out_of_weight, + //-----------当地址不为空,且是物流时,计算物流费用,同时阶梯团不计算拼团价格---------- + if (th.data.user_addr != null && th.data.bn_exp_type == 0 + && good.is_free_shipping == 0 && (th.data.kt_type != 3 || th.data.bn_goods.is_normal == 1)) { + switch (good['exp_sum_type']) { + case 1: + //统一运费 + o_shipping_price += good['uniform_exp_sum']; break; + case 2: + if (goods_weight < 0) goods_weight = 0; + //累积商品重量 每种商品的重量 * 数量 + goods_weight += good['weight'] * good['buynum']; + if (weight_free > 0) { + out_of_weight = (weight_free * 1000) - goods_weight; + } + break; + case 3: + if (goods_piece < 0) goods_piece = 0; + //累积商品数量 + goods_piece += good['buynum']; break; + } + + var code = th.data.wu_arr[th.data.index].code; + var shipping_price = + th.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, goods_piece, th.data.user_addr, freight_free, allpice, rs); - shipping_price = parseFloat(shipping_price).toFixed(2); - var wl_txt = "formData.shipping_price"; - th.setData({ [wl_txt]: shipping_price, }) - - }else{ - var wl_txt = "formData.shipping_price"; - th.setData({ [wl_txt]: 0, }) - } - //-----------------总价----------------- - var total_m = parseFloat(allpice) + parseFloat( th.data.formData.shipping_price); - total_m = parseFloat(total_m).toFixed(2); - - var atxt= "formData.total_amount"; - th.setData({ [atxt]: total_m, }) - var order_m = total_m; - - var txt = "formData.user_money"; - var txt2 = "formData.order_amount"; - //--------------如果使用余额--------------------- - if (th.data.bn_use_money == 1 && th.data.yuer>0) { - if ( parseFloat(th.data.yuer) > total_m) { - th.setData({ [txt]: total_m, [txt2]:0 }) - }else{ - order_m = parseFloat(order_m) - parseFloat(th.data.yuer); - order_m = order_m.toFixed(2); - th.setData({ [txt]: th.data.yuer, [txt2]: order_m }) - } - }else{ + shipping_price = parseFloat(shipping_price).toFixed(2); + var wl_txt = "formData.shipping_price"; + th.setData({ [wl_txt]: shipping_price, }) + + } else { + var wl_txt = "formData.shipping_price"; + th.setData({ [wl_txt]: 0, }) + } + //-----------------总价----------------- + var total_m = parseFloat(allpice) + parseFloat(th.data.formData.shipping_price); + total_m = parseFloat(total_m).toFixed(2); + + var atxt = "formData.total_amount"; + th.setData({ [atxt]: total_m, }) + var order_m = total_m; + + var txt = "formData.user_money"; + var txt2 = "formData.order_amount"; + //--------------如果使用余额--------------------- + if (th.data.bn_use_money == 1 && th.data.yuer > 0) { + if (parseFloat(th.data.yuer) > total_m) { + th.setData({ [txt]: total_m, [txt2]: 0 }) + } else { + order_m = parseFloat(order_m) - parseFloat(th.data.yuer); + order_m = order_m.toFixed(2); + th.setData({ [txt]: th.data.yuer, [txt2]: order_m }) + } + } else { th.setData({ [txt]: 0, [txt2]: order_m }) - } + } - }); - }); + }); + }); }, // -- 支付的下一步 -- - submitForm_next:async function(t){ - if(this.data.is_summit_ing==1) return false; //--提交中退出-- - this.data.is_summit_ing=1; + submitForm_next: async function (t) { + if (this.data.is_summit_ing == 1) return false; //--提交中退出-- + this.data.is_summit_ing = 1; - var th=this,pdata=new Array(); - var ff=true; + var th = this, pdata = new Array(); + var ff = true; //------------立即购买------------- //如果不是阶梯团,或者是普通购买,商家选择了物流,以及地址为空的时候 - if(th.data.bn_exp_type == 0 && th.data.user_addr==null && (th.data.kt_type!=3 || th.data.bn_goods.is_normal==1) ){ + if (th.data.bn_exp_type == 0 && th.data.user_addr == null && (th.data.kt_type != 3 || th.data.bn_goods.is_normal == 1)) { ff = false; - getApp().my_warnning("请选择收货地址",0,this); + getApp().my_warnning("请选择收货地址", 0, this); this.data.is_summit_ing = 0; } if (!ff) return false; var addr = th.data.user_addr; - if (th.data.bn_exp_type == 1) addr=null; + if (th.data.bn_exp_type == 1) addr = null; - if(th.data.bn_exp_type==0 && (th.data.kt_type!=3)) { + if (th.data.bn_exp_type == 0 && (th.data.kt_type != 3)) { if (th.data.wu_arr == null || th.data.wu_arr.length <= 0) { - getApp().my_warnning("读取物流失败",0,this); + getApp().my_warnning("读取物流失败", 0, this); this.data.is_summit_ing = 0; return false; } } //阶梯团强制带1,自提~~~ - if(th.data.kt_type==3 ){ - th.data.bn_exp_type=1; + if (th.data.kt_type == 3) { + th.data.bn_exp_type = 1; } - var item={ - 'user_id':app.globalData.user_id, + var item = { + 'user_id': app.globalData.user_id, 'consignee': addr == null ? "" : addr.consignee, 'province': addr == null ? 0 : addr.province, 'city': addr == null ? 0 : addr.city, 'district': addr == null ? 0 : addr.district, 'twon': addr == null ? 0 : addr.twon, - 'address': addr == null ? "": addr.address, + 'address': addr == null ? "" : addr.address, 'more_address': addr == null ? "" : addr.more_address, - 'mobile': addr == null ? th.data.userinfo.mobile:addr.mobile, - 'email':'', - 'invoice_title':'', + 'mobile': addr == null ? th.data.userinfo.mobile : addr.mobile, + 'email': '', + 'invoice_title': '', 'goods_price': th.data.formData.all_price, //商品总价 'shipping_price': th.data.formData.shipping_price, //物流金额 'user_money': th.data.formData.user_money, //使用余额 'total_amount': th.data.formData.total_amount, //订单总价 'order_amount': th.data.formData.order_amount, //应付 'user_note': t.detail.value.user_note, //用户备注 - 'store_id':os.stoid, //商家 + 'store_id': os.stoid, //商家 'pickup_id': th.data.bn_pick, //门店 - 'prom_type':th.data.bn_goods.prom_type, //促销活动类型 + 'prom_type': th.data.bn_goods.prom_type, //促销活动类型 'prom_id': th.data.bn_goods.prom_id, //促销活动id - 'order_goods':new Array(), + 'order_goods': new Array(), }; //老会员成为分销下线需要的参数 - if(getApp().globalData.first_leader && !getApp().globalData.userInfo.first_leader){ + if (getApp().globalData.first_leader && !getApp().globalData.userInfo.first_leader) { //判断一下分享人是不是分享商 - await app.request.promiseGet("/api/weshop/users/get/" + os.stoid+"/"+getApp().globalData.first_leader,{}).then(res=>{ - if(res.data.code==0){ - var user= res.data.data; - if(user.is_distribut==1){ - item.first_leader=parseInt(getApp().globalData.first_leader); + await app.request.promiseGet("/api/weshop/users/get/" + os.stoid + "/" + getApp().globalData.first_leader, {}).then(res => { + if (res.data.code == 0) { + var user = res.data.data; + if (user.is_distribut == 1) { + item.first_leader = parseInt(getApp().globalData.first_leader); } } }) } - if(th.data.qh!='') - { - item.team_qh=th.data.qh; - item.pt_listno=th.data.qh; + if (th.data.qh != '') { + item.team_qh = th.data.qh; + item.pt_listno = th.data.qh; } - var gg =app.get_b_now(); - var goods={ + var gg = app.get_b_now(); + var goods = { 'goods_id': gg.goods_id, 'goods_name': gg.goods_name, 'goods_sn': gg.goods_sn, @@ -494,37 +493,37 @@ Page({ 'goods_price': th.data.bn_goods.shop_price, 'member_goods_price': th.data.bn_goods.shop_price, 'store_id': os.stoid, - 'prom_type':th.data.bn_goods.prom_type, //促销活动类型 + 'prom_type': th.data.bn_goods.prom_type, //促销活动类型 'prom_id': th.data.bn_goods.prom_id, //促销活动id }; //--导购分享过来的id-- - if(gg.guide_id){ - goods.guide_id=gg.guide_id; - goods.guide_type=gg.guide_type; + if (gg.guide_id) { + goods.guide_id = gg.guide_id; + goods.guide_type = gg.guide_type; //调用接口判断是不是会员 - await getApp().request.promiseGet("/api/weshop/shoppingGuide/getId/"+os.stoid+"/"+gg.guide_id,{}).then(res=>{ - if(res.data.code==0){ - goods.guide_name=res.data.data.salesman; - goods.guide_sn=res.data.data.salesman_no; + await getApp().request.promiseGet("/api/weshop/shoppingGuide/getId/" + os.stoid + "/" + gg.guide_id, {}).then(res => { + if (res.data.code == 0) { + goods.guide_name = res.data.data.salesman; + goods.guide_sn = res.data.data.salesman_no; } }) } //--商品的房间号-- - if(gg.room_id && gg.room_id>0){ - item.room_ids=gg.room_id; - goods.room_id=gg.room_id; + if (gg.room_id && gg.room_id > 0) { + item.room_ids = gg.room_id; + goods.room_id = gg.room_id; } - if(th.data.bn_goods.is_normal){goods.is_pd_normal=1;} + if (th.data.bn_goods.is_normal) { goods.is_pd_normal = 1; } item.order_goods.push(goods); pdata.push(item); - if (pdata.length==0) return; + if (pdata.length == 0) return; var str = JSON.stringify(pdata); - wx.showLoading({title: "加载中"}); + wx.showLoading({ title: "加载中" }); wx.request({ url: os.url + '/api/weshop/order/createWxdOrder', data: str, @@ -536,8 +535,8 @@ Page({ wx.hideLoading(); if (res.statusCode == 200) { - var data=res.data; - if(data.code==0){ + var data = res.data; + if (data.code == 0) { console.log(th.data.is_b_now); //如果是购物车结算,还要删除购物车 if (th.data.is_b_now == 0) { @@ -555,11 +554,11 @@ Page({ //要进行判断,如果是用微信支付,就要跳转到支付界面 if (order_amount > 0) { th.setData({ isclose: 0 }); - util_pay.pay(data.data, function() { - var url="/packageC/pages/presell/cart/cart?order_sn="+data.data; + util_pay.pay(data.data, function () { + var url = "/packageC/pages/presell/cart/cart?order_sn=" + data.data; setTimeout(function () { - wx.reLaunch({ url: url,}) - },1000) + wx.reLaunch({ url: url, }) + }, 1000) }, function () { //支付失败 setTimeout(function () { @@ -567,9 +566,9 @@ Page({ wx.reLaunch({ url: "/pages/user/order_list/order_list", }) - },1000) + }, 1000) - },os.stoid,1); + }, os.stoid, 1); } else { var dd = { @@ -582,15 +581,15 @@ Page({ data: dd, success: function (t) { console.log(t); - app.my_warnning("支付成功",1,th); + app.my_warnning("支付成功", 1, th); setTimeout(function () { th.setData({ isclose: 0 }); - var url="/packageC/pages/presell/cart/cart?order_sn="+data.data; - wx.reLaunch({ - url: url - }) + var url = "/packageC/pages/presell/cart/cart?order_sn=" + data.data; + wx.reLaunch({ + url: url + }) @@ -599,54 +598,54 @@ Page({ }); } } - else{ - th.data.is_summit_ing=0; //是否提交中 + else { + th.data.is_summit_ing = 0; //是否提交中 getApp().confirmBox(data.msg); } } else { - th.data.is_summit_ing=0; //是否提交中 + th.data.is_summit_ing = 0; //是否提交中 console.log("index.js wx.request CheckCallUser statusCode" + res.statusCode); } }, fail: function () { - th.data.is_summit_ing=0; //是否提交中 + th.data.is_summit_ing = 0; //是否提交中 wx.hideLoading(); console.log("index.js wx.request CheckCallUser fail"); }, - complete: function () {} + complete: function () { } }) }, //--------------------提交订单----------------------- - submitForm: function(t){ - var th=this; + submitForm: function (t) { + var th = this; //如果是部分定金,商家不同意退定金, - if(this.data.act.presell_type!=1 && !this.data.act.is_refundmoney && !th.agree_no_ref){ + if (this.data.act.presell_type != 1 && !this.data.act.is_refundmoney && !th.agree_no_ref) { wx.showModal({ content: ' 预售商品不允许退定金!是否继续下单?', showCancel: true,//是否显示取消按钮 - cancelText:"我在想想",//默认是“取消” - confirmText:"继续下单",//默认是“确定” + cancelText: "我在想想",//默认是“取消” + confirmText: "继续下单",//默认是“确定” success: function (res) { if (res.cancel) { //点击取消,默认隐藏弹框 } else { - th.setData({agree_no_ref:1}) - th.submitForm_next(t) + th.setData({ agree_no_ref: 1 }) + th.submitForm_next(t) } }, }) - }else{ - this.submitForm_next(t); + } else { + this.submitForm_next(t); } }, - useCoupon: function() { + useCoupon: function () { if (this.data.order.couponNum <= 0) { //return t.showWarning("无可用优惠券"); - getApp().my_warnning("无可用优惠券",0,this); + getApp().my_warnning("无可用优惠券", 0, this); return; } var a = { @@ -656,158 +655,158 @@ Page({ url: "/pages/user/checkcoupon/checkcoupon?" + s.Obj2Str(a) }); }, - enterAddressPage: function() { - getApp().globalData.is_cart_old=1; + enterAddressPage: function () { + getApp().globalData.is_cart_old = 1; this.data.enterAddressPage = !0, wx.navigateTo({ url: "/pages/user/address_list/address_list" }); }, - //--------立即购买时,选择自提和物流----------- - setexptype_w:function(t){ - var th=this; - var ty = t.currentTarget.dataset.t,txt = t.currentTarget.dataset.txt; - th.setData({ [txt]: ty }); - var iszt=1; - if(ty==0){ - th.setData({ is_all_zt: 0 }); - }else{ - for(var i=0;i 0 && o_price >= freight_free && out_of_weight>=0){ return 0;} - if (user_addr==null) { return 0; } - //计算物流的config item; - var item=null; - //先根据 镇 县 区找计算的config - item = th.get_wuliu_config(user_addr.district,code,rs); - if (item==null) item = th.get_wuliu_config(user_addr.city, code, rs); - if (item==null) item = th.get_wuliu_config(user_addr.province, code, rs); - if (item == null) item = th.get_wuliu_default(code,rs); - if (item == null) return o_shipping_price; - var fw_price = 0, fp_price=0; - item=item.config; - if (item == null) return o_shipping_price; - //------按重量---------- - if (goods_weight >= 0 && item['money']) { - fw_price =parseFloat(item['money']); - if (goods_weight > item['first_weight']){ - var fw = goods_weight - item['first_weight']; - var n = Math.ceil(fw/item['second_weight']) - fw_price = fw_price + n * parseFloat(item['add_money']); - } - } - //------超出重量---------- - if(out_of_weight < 0 && o_price >= freight_free){ - fw_price = parseFloat(item['money']); - var out_of_weight = Math.abs(out_of_weight); - if (out_of_weight > item['first_weight']) { - var fw = out_of_weight - item['first_weight']; - var n = Math.ceil(fw / item['second_weight']) - fw_price = fw_price + n * parseFloat(item['add_money']); + setexptype: function (t) { + var th = this; + var ty = t.currentTarget.dataset.t; + th.setData({ bn_exp_type: ty }); + //当物流为空的时候。 + if (ty == 0 && th.data.wu_arr == null) { + return th.get_wuliu(th.calculatePrice2()); } - } - //------按件数---------- - if (goods_piece > 0) { - fp_price = parseFloat(item['piecemoney']); - if (goods_piece > item['first_piece']) { - var fp = goods_piece - item['first_piece']; - var m = Math.ceil(fp / item['second_piece']) - fp_price = fp_price + m * parseFloat(item['add_piecemoney']); - } - } - var rspice =parseFloat(price + fw_price + fp_price); - return rspice; - }, - - //------------循环获取config----------- - get_wuliu_config:function(region_id,code,rs){ - var item=null,rslist = rs.pageData; - for (var i = 0; i < rslist.length;i++){ - if (rslist[i].code == code && rslist[i].region_id == region_id) { item = rslist[i];} - } - return item; - }, - //-------循环获取config,code default------- - get_wuliu_default: function (code, rs) { - var item = null, rslist=rs.pageData; - for (var i = 0; i < rslist.length; i++) { - if (rslist[i].shipping_code == code && rslist[i].is_default == 1) { item = rslist[i]; } - } - return item; - }, - - //----------立即购买,选择物流------------- - bindPickerChange:function(e){ - var ind = e.detail.value - this.setData({ index: ind }); - this.calculatePrice2(); - }, - - //----------购物车结算,选择物流------------- - bindPickerChange_w: function (e) { - var ind=e.detail.value, txt = e.currentTarget.dataset.txt; + th.calculatePrice2() + console.log('setexptype'); + }, + + //--------立即购买时,使用余额-------- + set_bn_useyuer: function () { + var th = this; + th.setData({ bn_use_money: !th.data.bn_use_money }); + th.calculatePrice2(); + }, + set_js_useyuer: function () { + var th = this; + th.setData({ js_use_money: !th.data.js_use_money }); + th.calculatePrice(); + }, + + //-------------------计算物流--------------- + calculatewuliu: function (code, o_shipping_price, goods_weight, out_of_weight, + goods_piece, user_addr, freight_free, o_price, rs) { + var price = 0, th = this; + price += parseFloat(o_shipping_price); + //如果是包邮 + if (freight_free > 0 && o_price >= freight_free && out_of_weight >= 0) { return 0; } + if (user_addr == null) { return 0; } + //计算物流的config item; + var item = null; + //先根据 镇 县 区找计算的config + item = th.get_wuliu_config(user_addr.district, code, rs); + if (item == null) item = th.get_wuliu_config(user_addr.city, code, rs); + if (item == null) item = th.get_wuliu_config(user_addr.province, code, rs); + if (item == null) item = th.get_wuliu_default(code, rs); + if (item == null) return o_shipping_price; + var fw_price = 0, fp_price = 0; + item = item.config; + if (item == null) return o_shipping_price; + //------按重量---------- + if (goods_weight >= 0 && item['money']) { + fw_price = parseFloat(item['money']); + if (goods_weight > item['first_weight']) { + var fw = goods_weight - item['first_weight']; + var n = Math.ceil(fw / item['second_weight']) + fw_price = fw_price + n * parseFloat(item['add_money']); + } + } + //------超出重量---------- + if (out_of_weight < 0 && o_price >= freight_free) { + fw_price = parseFloat(item['money']); + var out_of_weight = Math.abs(out_of_weight); + if (out_of_weight > item['first_weight']) { + var fw = out_of_weight - item['first_weight']; + var n = Math.ceil(fw / item['second_weight']) + fw_price = fw_price + n * parseFloat(item['add_money']); + } + } + //------按件数---------- + if (goods_piece > 0) { + fp_price = parseFloat(item['piecemoney']); + if (goods_piece > item['first_piece']) { + var fp = goods_piece - item['first_piece']; + var m = Math.ceil(fp / item['second_piece']) + fp_price = fp_price + m * parseFloat(item['add_piecemoney']); + } + } + var rspice = parseFloat(price + fw_price + fp_price); + return rspice; + }, + + //------------循环获取config----------- + get_wuliu_config: function (region_id, code, rs) { + var item = null, rslist = rs.pageData; + for (var i = 0; i < rslist.length; i++) { + if (rslist[i].code == code && rslist[i].region_id == region_id) { item = rslist[i]; } + } + return item; + }, + //-------循环获取config,code default------- + get_wuliu_default: function (code, rs) { + var item = null, rslist = rs.pageData; + for (var i = 0; i < rslist.length; i++) { + if (rslist[i].shipping_code == code && rslist[i].is_default == 1) { item = rslist[i]; } + } + return item; + }, + + //----------立即购买,选择物流------------- + bindPickerChange: function (e) { + var ind = e.detail.value + this.setData({ index: ind }); + this.calculatePrice2(); + }, + + //----------购物车结算,选择物流------------- + bindPickerChange_w: function (e) { + var ind = e.detail.value, txt = e.currentTarget.dataset.txt; this.setData({ [txt]: ind }); this.calculatePrice(); - }, - - cart_set_err: function (e) { - var txt = e.currentTarget.dataset.err; - var ob = {}; - ob[txt] = this.data.imgUrl + "/miniapp/images/default_g_img.gif"; - this.setData(ob); - }, + }, + + cart_set_err: function (e) { + var txt = e.currentTarget.dataset.err; + var ob = {}; + ob[txt] = this.data.imgUrl + "/miniapp/images/default_g_img.gif"; + this.setData(ob); + }, //// 开启物流的弹窗 - show_wu_arr:function(e){ - this.setData({ open_express: 1}); + show_wu_arr: function (e) { + this.setData({ open_express: 1 }); }, //更新下默认,在onshow里面 - update_code(){ - var th=this,m_wind=0,def_exp_code=getApp().globalData.userInfo.def_exp_code; + update_code() { + var th = this, m_wind = 0, def_exp_code = getApp().globalData.userInfo.def_exp_code; - var uii=setInterval(function () { - if(th.data.wu_arr){ - clearInterval(uii); + var uii = setInterval(function () { + if (th.data.wu_arr) { + clearInterval(uii); for (var k = 0; k < th.data.wu_arr.length; k++) { var item = th.data.wu_arr[k]; if (def_exp_code == item.code) { @@ -815,37 +814,37 @@ Page({ } } //--如果是立即购买-- - th.setData({ index: m_wind, is_express: m_wind}); + th.setData({ index: m_wind, is_express: m_wind }); } - },500) + }, 500) }, // 关闭物流的弹窗 - close_express:function(){ - this.setData({ open_express:0 }); + close_express: function () { + this.setData({ open_express: 0 }); }, // 选择物流 - click_express_name:function(e){ + click_express_name: function (e) { var express_name = e.currentTarget.dataset.name, shippingcode = e.currentTarget.dataset.shippingcode; - var index=e.currentTarget.dataset.idxe; - var ob={ is_express: index, is_shipping_code: shippingcode,index:index}; + var index = e.currentTarget.dataset.idxe; + var ob = { is_express: index, is_shipping_code: shippingcode, index: index }; this.setData(ob); }, //点击确定物流 - determine_expres:function(e){ - this.setData({ open_express: 0}); + determine_expres: function (e) { + this.setData({ open_express: 0 }); this.calculatePrice2(); }, //设置默认物流 select_default_logistics: function () { - var th=this; - var is_shipping_code=this.data.is_shipping_code - getApp().request.put("/api/weshop/users/update",{ - data: { user_id: getApp().globalData.user_id, store_id: os.stoid, def_exp_code: is_shipping_code}, - success:function(rse){ - if (rse.data.code==0){ - getApp().globalData.userInfo.def_exp_code=is_shipping_code; + var th = this; + var is_shipping_code = this.data.is_shipping_code + getApp().request.put("/api/weshop/users/update", { + data: { user_id: getApp().globalData.user_id, store_id: os.stoid, def_exp_code: is_shipping_code }, + success: function (rse) { + if (rse.data.code == 0) { + getApp().globalData.userInfo.def_exp_code = is_shipping_code; th.setData({ open_express: 0 }); //----计算此时购物车的价格,这个页面没有calculatePrice(),2021.7.19---- //if(th.data.is_b_now==1) th.calculatePrice2(); @@ -858,14 +857,14 @@ Page({ //跳转到购买卡 - buycard:function(){ - getApp().goto("/pages/user/plus/plus"); - getApp().globalData.plus_buy_back=1; - }, - - switchChange:function (e) { - console.log(e,111); - this.setData({agree_no_ref:e.detail.value}); + buycard: function () { + getApp().goto("/pages/user/plus/plus"); + getApp().globalData.plus_buy_back = 1; + }, + + switchChange: function (e) { + console.log(e, 111); + this.setData({ agree_no_ref: e.detail.value }); } - + }); diff --git a/pages/cart/cart2/cart2.js b/pages/cart/cart2/cart2.js index 0c69b6e..66080e8 100644 --- a/pages/cart/cart2/cart2.js +++ b/pages/cart/cart2/cart2.js @@ -123,46 +123,47 @@ Page({ tabs: ['门店自提', '快递邮寄'], currentTabIndex: 1, - in_zhact_gdmap:{}, //不同门店参与同一活动的限购 - hid_inp:1, - user_note:"", - zhhe_act_map:{}, //组合活动的map表 - zuhe_map_good:{}, //组合购的map表 - ladder_map:{}, //阶梯促销的map表 - - state:0, //阶梯促销的的立即购买也走购物车流程state=1 + in_zhact_gdmap: {}, //不同门店参与同一活动的限购 + hid_inp: 1, + user_note: "", + zhhe_act_map: {}, //组合活动的map表 + zuhe_map_good: {}, //组合购的map表 + ladder_map: {}, //阶梯促销的map表 + is_no_past: 1, + state: 0, //阶梯促销的的立即购买也走购物车流程state=1 }, onLoad: function (t) { - wx.setNavigationBarTitle({title: "填写订单",}) + wx.setNavigationBarTitle({ title: "填写订单", }) var th = this; - this.setData({is_b_now: t.is_bnow == undefined ? 0 : t.is_bnow,}); + this.setData({ is_b_now: t.is_bnow == undefined ? 0 : t.is_bnow, }); th.data.param = t; //清理一下,确保最新的系统配置 getApp().globalData.config2 = null; //清空is_pick_up getApp().request.put("/api/weshop/useraddress/updatePickUp", { - data: {user_id: getApp().globalData.user_id, is_pickup: 0}, + data: { user_id: getApp().globalData.user_id, is_pickup: 0 }, success: function (s) { } }); //阶梯购 或者 组合购的立即购买 - if(t.state){ - th.data.state=1; + if (t.state) { + th.data.state = 1; } getApp().promiseGet("/api/wx/weappSendlist/page", { data: { store_id: os.stoid, typeid: "1001" - }}).then(res=>{ + } + }).then(res => { if (res.data.code == 0 && res.data.data.pageData.length > 0) { var template_id = res.data.data.pageData[0].template_id; - th.setData({template_id:template_id}); + th.setData({ template_id: template_id }); } }) }, onUnload: function () { - this.setData({isclose: 1}) + this.setData({ isclose: 1 }) }, onHide: function () { this.setData({ @@ -175,7 +176,7 @@ Page({ //----------子页返回父页触发---------- onShow: function () { var th = this; - th.setData({show_submit: 0}); //让提交先掩藏 + th.setData({ show_submit: 0 }); //让提交先掩藏 th.data.g_cart_q_time = null; if (th.data.isclose == 0) { @@ -208,20 +209,20 @@ Page({ th.data.is_summit_ing = 0; //更换地址回来要重新调用计算价钱的接口 if (!th.data.user_addr || th.data.user_addr.address_id != ie.address_id) { - th.setData({user_addr: ie}); + th.setData({ user_addr: ie }); if (th.data.is_b_now == 1) { if (th.data.bn_goods) { - th.setData({add_back: 1}); + th.setData({ add_back: 1 }); //th.calculatePrice2(); } } else { if (th.data.cartlist) { - th.setData({add_back: 1}); + th.setData({ add_back: 1 }); //th.calculatePrice(); } } } else { - th.setData({user_addr: ie}); + th.setData({ user_addr: ie }); } var going = 0; @@ -275,34 +276,34 @@ Page({ //-- 获取所有的等级卡, -- getApp().request.promiseGet("/api/weshop/plus/vip/mem/bership/list?storeId=" + os.stoid, {}).then(res => { - if (res.data.code == 0) { - var plusCard = res.data.data; - //-- 循环判断,拿到最贵的那张卡 -- - for (var ih in plusCard) { - if (plusCard[ih].IsStopBuy == true) { - continue; - } - if (max_price < 0) { - max_price = plusCard[ih].CardFee; - name = 'card' + plusCard[ih]['CorrPrice']; - show_card = plusCard[ih]; - } else { - if (max_price < plusCard[ih].CardFee) { + if (res.data.code == 0) { + var plusCard = res.data.data; + //-- 循环判断,拿到最贵的那张卡 -- + for (var ih in plusCard) { + if (plusCard[ih].IsStopBuy == true) { + continue; + } + if (max_price < 0) { max_price = plusCard[ih].CardFee; name = 'card' + plusCard[ih]['CorrPrice']; show_card = plusCard[ih]; + } else { + if (max_price < plusCard[ih].CardFee) { + max_price = plusCard[ih].CardFee; + name = 'card' + plusCard[ih]['CorrPrice']; + show_card = plusCard[ih]; + } } } - } - if (show_card) { - name = name.toLowerCase(); - th.setData({card_name: name, show_card: show_card}) + if (show_card) { + name = name.toLowerCase(); + th.setData({ card_name: name, show_card: show_card }) + } } - } - //-----先获取物流,再获取用户信息,再展示页面----- - th.get_wuliu(th.get_info(th.show_page)); - }) + //-----先获取物流,再获取用户信息,再展示页面----- + th.get_wuliu(th.get_info(th.show_page)); + }) } else { //-----先获取物流,再获取用户信息,再展示页面----- th.get_wuliu(th.get_info(th.show_page)); @@ -321,10 +322,10 @@ Page({ if (th.data.is_default_logistics) { //如果第一个不是开启默认,说明要让用户自己选 if (!e[0].is_default) { - th.setData({is_default_logistics: 0}); + th.setData({ is_default_logistics: 0 }); } } - th.setData({wu_arr: e}) + th.setData({ wu_arr: e }) typeof func == "function" && func(); }) }, @@ -338,7 +339,7 @@ Page({ getuser_addr: function (func) { var th = this; a.get("/api/weshop/useraddress/page", { - data: {user_id: to.globalData.user_id, store_id: oo.stoid, pageSize: 600, t: Math.random()}, + data: { user_id: to.globalData.user_id, store_id: oo.stoid, pageSize: 600, t: Math.random() }, success: function (su) { /*--- var user_addr=[ @@ -363,7 +364,7 @@ Page({ } if (item == undefined) item = null; - if (!item) th.setData({user_addr: null}); //地址为空的时候,要清空,因为返回的时候,有缓存 + if (!item) th.setData({ user_addr: null }); //地址为空的时候,要清空,因为返回的时候,有缓存 func(item); } @@ -378,19 +379,19 @@ Page({ //会员的信息,要获取最新 var user = getApp().globalData.userInfo; getApp().request.get("/api/weshop/users/get/" + oo.stoid + "/" + user.user_id, { - data: {r: Math.random()}, + data: { r: Math.random() }, success: function (e) { getApp().globalData.userInfo = e.data.data; - th.setData({userinfo: e.data.data}); + th.setData({ userinfo: e.data.data }); //选获取地址 th.getuser_addr(function (addr) { - th.setData({user_addr: addr}); + th.setData({ user_addr: addr }); //--------------------------立即购买------------------ if (ta.is_bnow == 1) { //读取门店 to.get_allsto(function (e) { - th.setData({allsto: e}); + th.setData({ allsto: e }); //获取立即购买的商品信息 th.get_buy_goods(ta.goods_id); }); @@ -398,7 +399,7 @@ Page({ //------------------------购物车结算---------------------- //读取门店 to.get_allsto(function (e) { - th.setData({allsto: e}); + th.setData({ allsto: e }); //-------获取购物车已经选择的商品-------- th.get_cart(); }) @@ -407,12 +408,12 @@ Page({ //获取提现金额 getApp().request.get("/api/weshop/withdrawals/summoney", { - data: {user_id: to.globalData.user_id, store_id: oo.stoid, status: 0}, + data: { user_id: to.globalData.user_id, store_id: oo.stoid, status: 0 }, success: function (su) { if (su.data.code == 0) { var yuer = parseFloat(th.data.userinfo.user_money - (th.data.userinfo.frozen_money > 0 ? th.data.userinfo.frozen_money : 0) - su.data.data.summoney).toFixed(2); - th.setData({txmon: su.data.data.summoney, yuer: yuer}); + th.setData({ txmon: su.data.data.summoney, yuer: yuer }); } } }); @@ -426,8 +427,8 @@ Page({ //-----真的获取购物车,入口-------- get_cart: function () { var th = this, app = getApp(); - var state=0; - if(th.data.state) state=1; + var state = 0; + if (th.data.state) state = 1; a.get("/api/weshop/cart/list", { data: { user_id: to.globalData.user_id, selected: 1, state: state, @@ -438,7 +439,7 @@ Page({ var arr = new Array(); var carr = su.data.data.pageData; th.data.cartlist_y = carr; //存储原始购物车列表 - th.data.in_zhact_gdmap={}; + th.data.in_zhact_gdmap = {}; //---是不是购买等级卡成功的返回---等级卡显示的判断--- var is_card_back = getApp().globalData.is_card_back; @@ -447,7 +448,7 @@ Page({ var item1 = carr[i]; //把已经购买了多少见的内容填入 - var goodsbuynum=0,promgoodsbuynum=0; + var goodsbuynum = 0, promgoodsbuynum = 0; //--要获得商品,该用户买了多少件,同步应用-- await getApp().request.promiseGet("/api/weshop/ordergoods/getUserBuyGoodsNum", { data: { @@ -465,7 +466,7 @@ Page({ goodsbuynum = buy_num_data.goodsbuynum; }) //如果有购买活动 - item1.promgoodsbuynum=promgoodsbuynum; + item1.promgoodsbuynum = promgoodsbuynum; //要把优惠活动加入,prom_goods_map中,赠品不要运算 if (item1.prom_type == 3 && item1.is_gift != 1) { @@ -473,8 +474,8 @@ Page({ } //要把组合购的东西拿出来算一下 - if(item1.prom_type == 7) { - if(!th.data.zuhe_map_good[item1.prom_id]) { + if (item1.prom_type == 7) { + if (!th.data.zuhe_map_good[item1.prom_id]) { var isok = 1; var is_flag = 1; //如果有组合购 @@ -523,50 +524,49 @@ Page({ } }) } - else - { - item1.act = th.data.zhhe_act_map[item1.prom_id]; + else { + item1.act = th.data.zhhe_act_map[item1.prom_id]; } } - if(item1.prom_type==10){ - if(!th.data.ladder_map[item1.prom_id]){ + if (item1.prom_type == 10) { + if (!th.data.ladder_map[item1.prom_id]) { //如果有组合购 var isok = 1; - var is_flag=1; - var act=null; - var url="/api/weshop/prom/ladderForm/get/"+os.stoid+"/"+item1.prom_id; + var is_flag = 1; + var act = null; + var url = "/api/weshop/prom/ladderForm/get/" + os.stoid + "/" + item1.prom_id; await getApp().request.promiseGet(url, {}).then(res => { - console.log(res,1000); - if(res.data.code==0 && res.data.data){ - if(res.data.data.isuse!=1){ - isok=0; + console.log(res, 1000); + if (res.data.code == 0 && res.data.data) { + if (res.data.data.isuse != 1) { + isok = 0; } //如果活动已经结束 - if(res.data.data.is_end==1){ - isok=0; + if (res.data.data.is_end == 1) { + isok = 0; } //已经结束 - if(ut.gettimestamp()>res.data.data.end_time){ - isok=0; + if (ut.gettimestamp() > res.data.data.end_time) { + isok = 0; } //还未开始 - if(ut.gettimestamp() { - if (rs1.data.code==0 && rs1.data.data) { + if (rs1.data.code == 0 && rs1.data.data) { var gdlist = rs1.data.data; - th.data.ladder_map[item1.prom_id].ladder_list=gdlist; + th.data.ladder_map[item1.prom_id].ladder_list = gdlist; } }) } @@ -616,7 +616,7 @@ Page({ item.original_img = oo.imghost + item.original_img; - var car_item=item; + var car_item = item; /*----接口要弄出来的,先顶着-----*/ var pcid = car_item.pick_id; var find = 0; @@ -625,7 +625,7 @@ Page({ if (arr.length > 0) { for (var j = 0; j < arr.length; j++) { if (arr[j].pickup_id == pcid) { - if(item.is_gift!=1){ + if (item.is_gift != 1) { //确定配送方式 if (arr[j].distr_t == 0) { arr[j].distr_t = car_item.distr_type; @@ -644,8 +644,8 @@ Page({ break; } arr[j].exp_type = e_t; - if (e_t == 0) th.setData({is_all_zt: 0}); - else if(e_t==1) th.setData({is_all_zt: 1}); + if (e_t == 0) th.setData({ is_all_zt: 0 }); + else if (e_t == 1) th.setData({ is_all_zt: 1 }); } //-- 把等级卡会优惠多少钱装进去 -- @@ -688,8 +688,8 @@ Page({ break; } //如果是物流的话,全部自提的控制要弄成0 - if (e_t == 0) th.setData({is_all_zt: 0}); - else th.setData({is_all_zt: 1}); + if (e_t == 0) th.setData({ is_all_zt: 0 }); + else th.setData({ is_all_zt: 1 }); var narr = new Array(); narr.push(car_item); @@ -748,11 +748,11 @@ Page({ var offline_price = 0; var offline_num = 0; for (var c = 0; c < item.length; c++) { - if(th.data.sales_rules!=2){ - item[c].offline_price=0; + if (th.data.sales_rules != 2) { + item[c].offline_price = 0; } //-- 如果这个商品是线下取价的时候 -- - if (item[c].offline_price > 0 && item[c].prom_type != 7 ) { + if (item[c].offline_price > 0 && item[c].prom_type != 7) { offline_price += (item[c].goods_price - item[c].offline_price) * item[c].goods_num; offline_num += item[c].goods_num; } @@ -778,7 +778,7 @@ Page({ var h_item = obj[var1]; var gdlist = th.data.zuhe_map_good[h_item.prom_id]; //获取活动需要的商品列表 - u_item.zh_prom_goods[h_item.prom_id] = {gdlist: gdlist, act: h_item.act}; + u_item.zh_prom_goods[h_item.prom_id] = { gdlist: gdlist, act: h_item.act }; } zh_calc.fir_set_arr(u_item, th); } @@ -792,10 +792,10 @@ Page({ //存储不同阶梯促销活动的商品列表 u_item.ladder_map = {}; for (let var1 in obj) { - var h_item=obj[var1]; - var act= th.data.ladder_map[h_item.prom_id]; + var h_item = obj[var1]; + var act = th.data.ladder_map[h_item.prom_id]; //获取活动需要的商品列表 - u_item.ladder_map[h_item.prom_id] =act; + u_item.ladder_map[h_item.prom_id] = act; } ladder_calc.fir_set_arr(u_item, th); } @@ -809,7 +809,7 @@ Page({ setTimeout(function () { var frozenQuan = null; var url0 = "/api/weshop/users/frozenQuan/listFrozenQuan/" + app.globalData.user_id; - app.request.promiseGet(url0, {1: 1}).then(res => { + app.request.promiseGet(url0, { 1: 1 }).then(res => { if (res.data.code == 0) { frozenQuan = res.data.data; th.data.frozenQuan = frozenQuan; @@ -880,7 +880,7 @@ Page({ th.data.card_name = th.data.userinfo.card_field; gg.goods_price = gd[th.data.card_name]; getApp().globalData.is_card_back = 0; - th.setData({card_cut_price: 0}); + th.setData({ card_cut_price: 0 }); //如果是秒杀的返回 if (gd.prom_type == 1) gd.prom_type = 0; } else { @@ -888,12 +888,12 @@ Page({ //-- 搭配购的商品也可以单独购买,所以此时搭配购的商品要进行计算优惠 -- 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) { var cut_p = (gg.goods_price - gd[th.data.card_name]) * gg.goods_num; - th.setData({card_cut_price: cut_p}); + th.setData({ card_cut_price: cut_p }); } } - gd.prom_type=gg.prom_type?gg.prom_type:0; - gd.prom_id=gg.prom_id?gg.prom_id:0; + gd.prom_type = gg.prom_type ? gg.prom_type : 0; + gd.prom_id = gg.prom_id ? gg.prom_id : 0; switch (gd.prom_type) { case 0: @@ -956,7 +956,7 @@ Page({ ob.exp_sum_type = data.gift_exp_sum_type; //商品的物流计算方式 ob.uniform_exp_sum = data.gift_uniform_exp_sum //统一运费的金额 - th.setData({buy_now_gift_goods: ob}); + th.setData({ buy_now_gift_goods: ob }); } } @@ -990,7 +990,7 @@ Page({ t.data.data.guide_id = gg.guide_id; t.data.data.guide_type = gg.guide_type; } - th.setData({collocation_goods: gg.collocation_goods}); + th.setData({ collocation_goods: gg.collocation_goods }); var cart_arr = new Array(); //var narr=gg.collocation_goods; @@ -1003,9 +1003,9 @@ Page({ et = 1; distr_t = 0; // 配送方式 0=用户自选 1=自提 2=物流 for (var hi in narr) { - var dis_t = narr[hi].distr_type; + var dis_t = narr[hi].distr_type; if (dis_t == 2) { - th.setData({is_all_zt: 0}); + th.setData({ is_all_zt: 0 }); et = 0; } if (dis_t > 0) { @@ -1046,7 +1046,7 @@ Page({ if (gg.prom_type == 5) { var frozenQuan = null; var url0 = "/api/weshop/users/frozenQuan/listFrozenQuan/" + app.globalData.user_id; - app.request.promiseGet(url0, {1: 1}).then(res => { + app.request.promiseGet(url0, { 1: 1 }).then(res => { if (res.data.code == 0) { frozenQuan = res.data.data; th.data.frozenQuan = frozenQuan; @@ -1056,7 +1056,7 @@ Page({ th.get_cart_quan(); }); - + } else { //计算价格 @@ -1070,13 +1070,13 @@ Page({ case 1: //---秒杀----- var quanlist = null; getApp().request.get("/api/weshop/activitylist/getSJGoodsPriceNew/" + gd.store_id - + "/" + gd.goods_id + "/1/" + gd.prom_id+"/"+app.globalData.user_id, { + + "/" + gd.goods_id + "/1/" + gd.prom_id + "/" + app.globalData.user_id, { success: async function (tt) { if (tt.data.code == 0) { //t.data.data.shop_price = tt.data.data.prom_price; t.data.data.shop_price = tt.data.data.prom_user_price; - th.data.ckeck_quan_price=0; - gd.is_xz_yh=1; + th.data.ckeck_quan_price = 0; + gd.is_xz_yh = 1; } else { t.data.data.prom_id = 0; t.data.data.prom_type = 0; @@ -1098,7 +1098,7 @@ Page({ //计算价格 th.calculatePrice2(); //获取优惠券,如果有券的钱,就调用 - if(th.data.ckeck_quan_price>0) th.get_buy_now_quan(); + if (th.data.ckeck_quan_price > 0) th.get_buy_now_quan(); } }); @@ -1106,7 +1106,7 @@ Page({ case 2: //--- 团购 --- var quanlist = null; - getApp().request.get("/api/weshop/goods/groupBuy/getActInfo/" +os.stoid + "/" +gd.goods_id+"/"+ gd.prom_id, { + getApp().request.get("/api/weshop/goods/groupBuy/getActInfo/" + os.stoid + "/" + gd.goods_id + "/" + gd.prom_id, { success: async function (tt) { if (tt.data.code == 0) { //t.data.data.shop_price = tt.data.data.prom_price; @@ -1116,12 +1116,12 @@ Page({ t.data.data.prom_type = 0; } - if(tt.data.data.isQuan){ + if (tt.data.data.isQuan) { th.data.ckeck_quan_price = t.data.data.shop_price * gg.goods_num; th.data.check_quan_price_list = t.data.data.shop_price * gg.goods_num + ""; th.data.check_quan_ware_list = t.data.data.erpwareid + ""; - }else{ - gd.is_xz_yh=1; + } else { + gd.is_xz_yh = 1; } th.setData({ @@ -1137,7 +1137,7 @@ Page({ //-- 计算价格 -- th.calculatePrice2(); //获取优惠券,如果有券的钱,就调用 - if(th.data.ckeck_quan_price>0) th.get_buy_now_quan(); + if (th.data.ckeck_quan_price > 0) th.get_buy_now_quan(); } }); @@ -1152,14 +1152,14 @@ Page({ checkAddressList: function () { var t = this; return !(!this.data.order || null == this.data.order.userAddress) || (wx.showModal({ - title: "请先填写或选择收货地址~", - success: function (a) { - a.confirm ? t.enterAddressPage() : wx.navigateBack(); - }, - fail: function () { - wx.navigateBack(); - } - }), !1); + title: "请先填写或选择收货地址~", + success: function (a) { + a.confirm ? t.enterAddressPage() : wx.navigateBack(); + }, + fail: function () { + wx.navigateBack(); + } + }), !1); }, showInvoice: function () { this.setData({ @@ -1178,7 +1178,7 @@ Page({ }, keyUpChangeNum: function (t) { var index = t.currentTarget.dataset.index; - var txt="user_note."+index; + var txt = "user_note." + index; this.setData({ maxWord: t.detail.value.length, [txt]: t.detail.value @@ -1268,7 +1268,7 @@ Page({ } var pt_res = null; - await getApp().request.promisePost("/api/weshop/order/getGoodsSplit", { + await getApp().request.promisePost("/api/weshop/order/getGoodsSplit", { is_json: 1, data: pt_data }).then(res => { @@ -1323,11 +1323,11 @@ Page({ if (item_map.s_coupon_id) { if (!cart_item.s_coupon_id) { cart_item.s_coupon_id = item_map.s_coupon_id + ""; - cart_item.g_coupon_num = [{'c_id': item_map.s_coupon_id, "num": item_map.s_coupon_num}]; + cart_item.g_coupon_num = [{ 'c_id': item_map.s_coupon_id, "num": item_map.s_coupon_num }]; } else { cart_item.s_coupon_id += "," + item_map.s_coupon_id; - cart_item.g_coupon_num.push({'c_id': item_map.s_coupon_id, "num": item_map.s_coupon_num}) + cart_item.g_coupon_num.push({ 'c_id': item_map.s_coupon_id, "num": item_map.s_coupon_num }) } } @@ -1335,11 +1335,11 @@ Page({ if (item_map.s_libao) { if (!cart_item.s_libao) { cart_item.s_libao = item_map.s_libao + ""; - cart_item.g_lb_num = [{'l_id': item_map.s_libao, "num": item_map.s_lb_num}]; + cart_item.g_lb_num = [{ 'l_id': item_map.s_libao, "num": item_map.s_lb_num }]; } else { cart_item.s_libao += "," + item_map.s_libao; - cart_item.g_lb_num.push({'l_id': item_map.s_libao, "num": item_map.s_lb_num}) + cart_item.g_lb_num.push({ 'l_id': item_map.s_libao, "num": item_map.s_lb_num }) } } } @@ -1348,7 +1348,7 @@ Page({ }, //-------------------计算订单价格------------------- - calculatePrice : function (t, s) { + calculatePrice: function (t, s) { var th = this; to.getConfig2(function (ee) { to.getwuliuprice(async function (rs) { @@ -1372,11 +1372,11 @@ Page({ var no_ex_id = ee.no_ex_id; var no_ex_good = null; var by_qc = {}; - var out_of_weight=0; //超出多少重量 + var out_of_weight = 0; //超出多少重量 if (no_ex_id && freight_free > 0) { //-----------获取不包邮区域,不包邮商品------- await getApp().request.promiseGet("/api/weshop/areaFeemail/getAreaGoods", { - data: {store_id: os.stoid, id: no_ex_id} + data: { store_id: os.stoid, id: no_ex_id } }).then(res => { if (res.data.code == 0 && res.data.data && res.data.data.length > 0) { by_qc = res.data.data[0]; @@ -1395,9 +1395,9 @@ Page({ //调用函数计算每件商品的单价 await th.calc_per(c_arr); //调用函数计算每件组合购商品的单价, - await zh_calc.calc_zh_split_price(c_arr,th); + await zh_calc.calc_zh_split_price(c_arr, th); //调用函数计算每件阶梯促销商品的单价, - await ladder_calc.calc_split_price(c_arr,th); + await ladder_calc.calc_split_price(c_arr, th); //调用函数计算,优惠券优惠什么商品价格,优惠券优惠什么商品 await th.get_cart_quan(c_arr); //---循环购物车--- @@ -1420,7 +1420,7 @@ Page({ var cart_item = c_arr[i]; //就是每一单的意思 var pickid = cart_item.pickup_id; var o_price = 0; - var o_price_no_zh=0; //参与订单优惠叠加--组合购的金额汇总 + var o_price_no_zh = 0; //参与订单优惠叠加--组合购的金额汇总 var o_shipping_price = 0, goods_weight = -1, goods_piece = -1; var item = c_arr[i].goods; //就是每一单的从表的意思 @@ -1428,11 +1428,11 @@ Page({ var quan_price = 0; var coupon_price = 0; var quan_no = null; - var is_has_zh=c_arr[i].is_has_zh; - var is_has_ladder=c_arr[i].is_has_ladder; + var is_has_zh = c_arr[i].is_has_zh; + var is_has_ladder = c_arr[i].is_has_ladder; - var zh_prom_goods=c_arr[i].zh_prom_goods; //组合购计算的原始数据存储空间 - var ladder_prom_goods=c_arr[i].ladder_prom_goods; //组合购计算的原始数据存储空间 + var zh_prom_goods = c_arr[i].zh_prom_goods; //组合购计算的原始数据存储空间 + var ladder_prom_goods = c_arr[i].ladder_prom_goods; //组合购计算的原始数据存储空间 if (th.data.using_quan[pickid] != null && th.data.using_quan[pickid] != undefined) quan_no = th.data.using_quan[pickid].coupon_no; @@ -1461,66 +1461,65 @@ Page({ //--------循环计算总价----------- for (var j = 0; j < item.length; j++) { - var is_no_zh=0; - if(item[j].prom_type!=7 && item[j].prom_type!=10 ) is_no_zh=1; + var is_no_zh = 0; + if (item[j].prom_type != 7 && item[j].prom_type != 10) is_no_zh = 1; //组合购的商品,且有订单优惠的叠加,is_orderyh就是优惠叠加 - if(item[j].prom_type==7 && th.data.zhhe_act_map && th.data.zhhe_act_map[item[j].prom_id] - && th.data.zhhe_act_map[item[j].prom_id].is_orderyh ) - { - is_no_zh=1; + if (item[j].prom_type == 7 && th.data.zhhe_act_map && th.data.zhhe_act_map[item[j].prom_id] + && th.data.zhhe_act_map[item[j].prom_id].is_orderyh) { + is_no_zh = 1; } //阶梯购的商品,且有订单优惠的叠加,is_orderyh就是优惠叠加 - if(item[j].prom_type==10 && ladder_prom_goods && ladder_prom_goods[item[j].prom_id] - && th.data.ladder_map[item[j].prom_id].is_useorderyh ) - { - is_no_zh=1; + if (item[j].prom_type == 10 && ladder_prom_goods && ladder_prom_goods[item[j].prom_id] + && th.data.ladder_map[item[j].prom_id].is_useorderyh) { + is_no_zh = 1; } - if(is_no_zh){ + if (is_no_zh) { o_price_no_zh += item[j].goods_price * item[j].goods_num; } o_price += item[j].goods_price * item[j].goods_num; //判断是否有设置限制重量包邮,先看商品有没有包邮 - if(item[j]['is_past']!==1 && item[j]['exp_sum_type']==2){ + if (item[j]['is_past'] !== 1 && item[j]['exp_sum_type'] == 2) { if (goods_weight < 0) goods_weight = 0; - //累积商品重量 每种商品的重量 * 数量 + //累积商品重量 每种商品的重量 * 数量 goods_weight += item[j]['weight'] * item[j]['goods_num']; - if(weight_free > 0){ - out_of_weight = (weight_free*1000) - goods_weight; + if (weight_free > 0) { + out_of_weight = (weight_free * 1000) - goods_weight; } } + } //判断是不是有组合购的金额 var f_o_price = o_price; //如果又优惠的钱,就要减价 - if (c_arr[i].cut_price > 0){ + if (c_arr[i].cut_price > 0) { o_price -= c_arr[i].cut_price; - o_price_no_zh-=c_arr[i].cut_price; + o_price_no_zh -= c_arr[i].cut_price; } //如果有组合购优惠的钱,就要减价 - if (c_arr[i].zh_cut_price>0 || c_arr[i].zh_cut_price<0){ + if (c_arr[i].zh_cut_price > 0 || c_arr[i].zh_cut_price < 0) { o_price -= c_arr[i].zh_cut_price; - if(o_price_no_zh>0){ + if (o_price_no_zh > 0) { //找到那些可以订单优惠叠加的 - for(let ij in zh_prom_goods){ - let kitem=zh_prom_goods[ij]; - if(kitem.act.is_orderyh) - o_price_no_zh-=kitem.cut_price; + for (let ij in zh_prom_goods) { + let kitem = zh_prom_goods[ij]; + if (kitem.act.is_orderyh) + o_price_no_zh -= kitem.cut_price; } } } //如果有组合购优惠的钱,就要减价 - if (c_arr[i].ladder_cut_price>0 || c_arr[i].ladder_cut_price<0){ + if (c_arr[i].ladder_cut_price > 0 || c_arr[i].ladder_cut_price < 0) { o_price -= c_arr[i].ladder_cut_price; - if(o_price_no_zh>0){ + if (o_price_no_zh > 0) { //找到那些可以订单优惠叠加的 - for(let ij in ladder_prom_goods){ - let kitem=ladder_prom_goods[ij]; - if(th.data.ladder_map[ij].is_useorderyh ) - o_price_no_zh-=kitem.cut_price; + for (let ij in ladder_prom_goods) { + let kitem = ladder_prom_goods[ij]; + if (th.data.ladder_map[ij].is_useorderyh) + o_price_no_zh -= kitem.cut_price; } } } @@ -1528,32 +1527,37 @@ Page({ //-- 计算线下取价的功能 -- if (cart_item.is_offline == 1) { o_price = o_price - cart_item.offline_price; - o_price_no_zh-=c_arr[i].offline_price; + o_price_no_zh -= c_arr[i].offline_price; } //判断包邮券的钱,组合购的商品不使用优惠券 var q_conditin = 0; q_conditin = o_price - quan_price; - if(is_has_zh){ + if (is_has_zh) { q_conditin = o_price_no_zh - quan_price; } cart_item.goods_price = f_o_price.toFixed(2); //商品总费用,用f_o_price来计算 //计算物流费用 cart_item.shipping_price = 0; + th.data.is_no_past = 1; //不包邮标识符 + //--有不包邮区域,且不免运费,全场的计算,要减到优惠金额 和券的金额-- 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)) { //如果有设置不包邮区域的时候 if (by_qc.region_list != "" && by_qc.region_list != null && by_qc.region_list != undefined) { if (th.check_by_area(by_qc.region_list)) { freight_free = 0; + goods_weight = -1; + out_of_weight = 0; th.data.is_no_by[pickid] = 1; - out_of_weight=0; } } //如果有设置不包邮区商品 if (by_qc.goods_list != "" && by_qc.goods_list != undefined && by_qc != null && freight_free > 0) { freight_free = 0; - out_of_weight=0; + goods_weight = -1; + out_of_weight = 0; + th.data.is_no_by[pickid] = 1; no_ex_good = by_qc.goods_list; } } @@ -1568,7 +1572,7 @@ Page({ store_id: os.stoid, isuse: 0, //condition: q_conditin, - condition:cart_item.ckeck_quan_price, + condition: cart_item.ckeck_quan_price, user_id: getApp().globalData.user_id, pageSize: 2000 } @@ -1593,7 +1597,7 @@ Page({ } if (arr) { th.data.get_by_quan_list_cart[pickid] = arr; - th.setData({get_by_quan_list_cart:th.data.get_by_quan_list_cart}); + th.setData({ get_by_quan_list_cart: th.data.get_by_quan_list_cart }); //if (th.data.is_b_now) { // th.setData({get_by_quan_list: arr}); //} @@ -1618,7 +1622,7 @@ Page({ if (ut.isContained(arr, arr2)) { getApp().my_warnning("全场不包邮商品和包邮券的重复", 0, th); th.data.using_quan[pickid] = {}; - th.setData({using_quan: th.data.using_quan}) + th.setData({ using_quan: th.data.using_quan }) return false; } var n_arr = ut.mergeArray(arr, arr2); @@ -1657,7 +1661,7 @@ Page({ if (no_ex_good) no_ex_good_arr = no_ex_good.split(','); //----------------如果是选择了物流--------------------- - 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 )) { + 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)) { //如果地址不为空 if (th.data.user_addr != null) { @@ -1666,13 +1670,15 @@ Page({ //统一运费 o_shipping_price += item[j]['uniform_exp_sum']; break; - // case 2: //1464行已计算 不必重复计算 注释为:判断是否有设置限制重量包邮 - // +'' - // if (goods_weight < 0) goods_weight = 0; - // //累积商品重量 每种商品的重量 * 数量 - // goods_weight += item[j]['weight'] * item[j]['goods_num']; - // out_of_weight = (weight_free*1000) - goods_weight; - // break; + case 2: + +'' + if (goods_weight < 0) goods_weight = 0; + //累积商品重量 每种商品的重量 * 数量 + goods_weight += item[j]['weight'] * item[j]['goods_num']; + if (weight_free > 0) { + out_of_weight = (weight_free * 1000) - goods_weight; + } + break; case 3: if (goods_piece < 0) goods_piece = 0; //累积商品数量 @@ -1680,14 +1686,6 @@ Page({ break; } } - }else{ - if(item[j]['exp_sum_type']==2){ - if(out_of_weight !==0){ - goods_weight=-1; - out_of_weight=0; - } - } - } } @@ -1698,8 +1696,8 @@ Page({ if (th.data.wu_arr && th.data.wu_arr[cart_item.wind]) code = th.data.wu_arr[cart_item.wind].code; cart_item.shipping_price = - th.calculatewuliu(code, o_shipping_price, goods_weight,out_of_weight, - goods_piece, th.data.user_addr, freight_free, o_price - quan_price, rs); + th.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, + goods_piece, th.data.user_addr, freight_free, o_price - quan_price, rs, pickid); if (!th.data.using_quan[pickid] || th.data.using_quan[pickid].isby != 1) { if (cart_item.shipping_price == 0) th.data.is_by[pickid] = 1; //已经全场包邮,就不要选择券了 @@ -1718,26 +1716,26 @@ Page({ var order_prom_id = 0; var o_condition = cart_item.order_amount; //看一下是不是不用组合购的订单优惠的叠加 - if(is_has_zh){ - o_condition=o_price_no_zh-quan_price; + if (is_has_zh) { + o_condition = o_price_no_zh - quan_price; } //看一下是不是不用组合购的订单优惠的叠加 - if(is_has_ladder){ - o_condition=o_price_no_zh-quan_price; + if (is_has_ladder) { + o_condition = o_price_no_zh - quan_price; } var order_m = 0; //---判断是不是有订单优惠--- - await getApp().request.promiseGet("/api/weshop/promorder/getOrderPromotion", { - data: {store_id: os.stoid, orderAmount: o_condition} + await getApp().request.promiseGet("/api/weshop/promorder/getOrderPromotion", { + data: { store_id: os.stoid, orderAmount: o_condition } }).then(res => { if (res.data.code == 0) { var ord_prom = res.data.data; //么有使用券,或者活动没有限制使用优惠券 - if(quan_price<=0 || !ord_prom.is_xz_yh) { + if (quan_price <= 0 || !ord_prom.is_xz_yh) { order_prom_id = ord_prom['id']; switch (ord_prom['type']) { case 0: @@ -1881,13 +1879,13 @@ Page({ } } var set_txt = "cartlist[" + iter + "].can_num"; - th.setData({[set_txt]: num}); + th.setData({ [set_txt]: num }); } }, //---------计算立即购买---------- - calculatePrice2 : function () { + calculatePrice2: function () { var th = this, good = this.data.bn_goods; if (!good) return false; @@ -1913,10 +1911,10 @@ Page({ allpice = parseFloat(allpice).toFixed(2); var txt = "formData.all_price"; - th.setData({[txt]: allpice,}); + th.setData({ [txt]: allpice, }); if (cut_price) { var c_txt = "formData.cut_price"; - th.setData({[c_txt]: cut_price,}); + th.setData({ [c_txt]: cut_price, }); } @@ -1929,8 +1927,8 @@ Page({ to.getConfig2(function (ee) { to.getwuliuprice(async function (rs) { - var o_shipping_price = 0,goods_weight = -1,goods_piece = -1; - var out_of_weight=null; //超出多少重量 + var o_shipping_price = 0, goods_weight = -1, goods_piece = -1; + var out_of_weight = null; //超出多少重量 var freight_free = ee.freight_free; //全场满多少包邮 var weight_free = ee.weight_free; //多少kg内包邮 var no_ex_id = ee.no_ex_id; @@ -1985,7 +1983,7 @@ Page({ arr.push(item); } if (arr) { - th.setData({get_by_quan_list: arr}); + th.setData({ get_by_quan_list: arr }); } th.data.isget_by_quan[th.data.bn_pick] = 1; } @@ -2002,8 +2000,8 @@ Page({ //dw //累积商品重量 每种商品的重量 * 数量 goods_weight += good['weight'] * good['buynum']; - if(weight_free > 0){ - out_of_weight = (weight_free * 1000 ) - goods_weight; + if (weight_free > 0) { + out_of_weight = (weight_free * 1000) - goods_weight; } break; case 3: @@ -2026,7 +2024,7 @@ Page({ if (no_ex_id && freight_free > 0 && freight_free <= parseFloat(allpice) - cut_price - quan_price) { //-----------获取不包邮区域,不包邮商品------- await getApp().request.promiseGet("/api/weshop/areaFeemail/getAreaGoods", { - data: {store_id: os.stoid, id: no_ex_id} + data: { store_id: os.stoid, id: no_ex_id } }).then(res => { if (res.data.code == 0 && res.data.data && res.data.data.length > 0) { no_by_data = res.data.data[0]; @@ -2034,7 +2032,7 @@ Page({ if (res.data.data[0].region_list) { if (th.check_by_area(res.data.data[0].region_list)) { freight_free = 0; - out_of_weight=0; + out_of_weight = 0; th.data.is_no_by[th.data.bn_pick] = 1; } } @@ -2042,7 +2040,7 @@ Page({ if (res.data.data[0].goods_list && freight_free) { if (th.check_by_goods(res.data.data[0].goods_list)) { freight_free = 0; - out_of_weight=0; + out_of_weight = 0; th.data.is_no_by[th.data.bn_pick] = 1; } } @@ -2053,12 +2051,12 @@ Page({ th.data.is_by[th.data.bn_pick] = 0; //--------------开始计算物流------------------ var shipping_price = - th.calculatewuliu(code, o_shipping_price, goods_weight,out_of_weight, - goods_piece, th.data.user_addr, freight_free, parseFloat(allpice) - cut_price - quan_price, rs); + th.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, + goods_piece, th.data.user_addr, freight_free, parseFloat(allpice) - cut_price - quan_price, rs, th.data.bn_pick); //如果有赠品的时候,也要计算赠品的物流费用 if (th.data.buy_now_gift_goods) { - shipping_price = th.get_now_gift_goods_wuliu(code, o_shipping_price, th.data.user_addr, gift_freight_free,out_of_weight, + shipping_price = th.get_now_gift_goods_wuliu(code, o_shipping_price, th.data.user_addr, gift_freight_free, out_of_weight, parseFloat(allpice) - cut_price - quan_price, rs, shipping_price, no_by_data, goods_weight, goods_piece); } @@ -2068,18 +2066,18 @@ Page({ shipping_price = parseFloat(shipping_price).toFixed(2); var wl_txt = "formData.shipping_price"; - th.setData({[wl_txt]: shipping_price,}) + th.setData({ [wl_txt]: shipping_price, }) } else { var wl_txt = "formData.shipping_price"; - th.setData({[wl_txt]: 0,}) + th.setData({ [wl_txt]: 0, }) } if (quan_no) { if (th.data.using_quan[bn_pick].isby == 1) { shipping_price = 0; var wl_txt = "formData.shipping_price"; - th.setData({[wl_txt]: 0,}) + th.setData({ [wl_txt]: 0, }) } } //-----------------支付价,优惠券不减物流----------------- @@ -2099,7 +2097,7 @@ Page({ if (th.data.order_prom[th.data.bn_pick]) { var ord_prom = th.data.order_prom[th.data.bn_pick]; //么有使用券,或者活动没有限制使用优惠券 - if(coupon_price<=0 || !ord_prom.is_xz_yh) { + if (coupon_price <= 0 || !ord_prom.is_xz_yh) { order_prom_id = ord_prom['id']; switch (ord_prom['type']) { case 0: @@ -2117,9 +2115,9 @@ Page({ var order_prom_txt1 = "formData.order_prom_id"; var order_prom_txt2 = "formData.order_prom_amount"; if (order_prom_id > 0) { - th.setData({[order_prom_txt1]: order_prom_id, [order_prom_txt2]: order_prom_amount}) - }else{ - th.setData({[order_prom_txt1]: 0, [order_prom_txt2]: 0}) + th.setData({ [order_prom_txt1]: order_prom_id, [order_prom_txt2]: order_prom_amount }) + } else { + th.setData({ [order_prom_txt1]: 0, [order_prom_txt2]: 0 }) } total_m = parseFloat(total_m) + parseFloat(th.data.formData.shipping_price); @@ -2129,7 +2127,7 @@ Page({ order_m = order_m.toFixed(2); var atxt = "formData.total_amount"; - th.setData({[atxt]: total_m,}) + th.setData({ [atxt]: total_m, }) var txt = "formData.user_money"; var txt2 = "formData.order_amount"; @@ -2139,44 +2137,44 @@ Page({ if (th.data.bn_use_money == 1) { if (amoney > order_m) { order_m = parseFloat(order_m).toFixed(2); - th.setData({[txt]: order_m, [txt2]: 0, [txt3]: coupon_price, show_submit: 1}) + th.setData({ [txt]: order_m, [txt2]: 0, [txt3]: coupon_price, show_submit: 1 }) } else { order_m = parseFloat(order_m) - parseFloat(amoney); order_m = order_m.toFixed(2); - th.setData({[txt]: amoney, [txt2]: order_m, [txt3]: coupon_price, show_submit: 1}) + th.setData({ [txt]: amoney, [txt2]: order_m, [txt3]: coupon_price, show_submit: 1 }) } } else { - th.setData({[txt]: 0, [txt2]: order_m, [txt3]: coupon_price, show_submit: 1}) + th.setData({ [txt]: 0, [txt2]: order_m, [txt3]: coupon_price, show_submit: 1 }) } //优惠活动送积分 if (good.s_intValue) { txt = "formData.give_integral"; - th.setData({[txt]: good.s_intValue}); + th.setData({ [txt]: good.s_intValue }); } //优惠送券 if (good.s_coupon_id) { var i_txt = "formData.give_coupon_id"; //这个是json格式的 var i_txt1 = "formData.g_coupon_num"; - var ob = [{"num": good.s_coupon_num, "c_id": good.s_coupon_id}]; + var ob = [{ "num": good.s_coupon_num, "c_id": good.s_coupon_id }]; ob = JSON.stringify(ob); - th.setData({[i_txt]: good.s_coupon_id, [i_txt1]: ob}); + th.setData({ [i_txt]: good.s_coupon_id, [i_txt1]: ob }); } //优惠礼包 if (good.s_libao) { var l_txt = "formData.give_lb_id"; //这个是json格式的 var l_txt1 = "formData.g_lb_num"; - var ob = [{"num": good.s_lb_num, "l_id": good.s_libao}]; + var ob = [{ "num": good.s_lb_num, "l_id": good.s_libao }]; ob = JSON.stringify(ob); - th.setData({[l_txt]: good.s_libao, [l_txt1]: ob}); + th.setData({ [l_txt]: good.s_libao, [l_txt1]: ob }); } }) } else { var order_prom_txt1 = "formData.order_prom_id"; var order_prom_txt2 = "formData.order_prom_amount"; - th.setData({[order_prom_txt1]: 0, [order_prom_txt2]: 0}) + th.setData({ [order_prom_txt1]: 0, [order_prom_txt2]: 0 }) total_m = parseFloat(total_m) + parseFloat(th.data.formData.shipping_price); @@ -2186,7 +2184,7 @@ Page({ total_m = total_m.toFixed(2); order_m = order_m.toFixed(2); - th.setData({[atxt]: total_m,}) + th.setData({ [atxt]: total_m, }) var txt = "formData.user_money"; var txt2 = "formData.order_amount"; @@ -2196,37 +2194,37 @@ Page({ if (th.data.bn_use_money == 1) { if (amoney > order_m) { order_m = parseFloat(order_m).toFixed(2); - th.setData({[txt]: order_m, [txt2]: 0, [txt3]: coupon_price, show_submit: 1}) + th.setData({ [txt]: order_m, [txt2]: 0, [txt3]: coupon_price, show_submit: 1 }) } else { order_m = parseFloat(order_m) - parseFloat(amoney); order_m = order_m.toFixed(2); - th.setData({[txt]: amoney, [txt2]: order_m, [txt3]: coupon_price, show_submit: 1}) + th.setData({ [txt]: amoney, [txt2]: order_m, [txt3]: coupon_price, show_submit: 1 }) } } else { - th.setData({[txt]: 0, [txt2]: order_m, [txt3]: coupon_price, show_submit: 1}) + th.setData({ [txt]: 0, [txt2]: order_m, [txt3]: coupon_price, show_submit: 1 }) } //优惠活动送积分 if (good.s_intValue) { txt = "formData.give_integral"; - th.setData({[txt]: good.s_intValue}); + th.setData({ [txt]: good.s_intValue }); } //优惠送券 if (good.s_coupon_id) { var i_txt = "formData.give_coupon_id"; //这个是json格式的 var i_txt1 = "formData.g_coupon_num"; - var ob = [{"num": good.s_coupon_num, "c_id": good.s_coupon_id}]; + var ob = [{ "num": good.s_coupon_num, "c_id": good.s_coupon_id }]; ob = JSON.stringify(ob); - th.setData({[i_txt]: good.s_coupon_id, [i_txt1]: ob}); + th.setData({ [i_txt]: good.s_coupon_id, [i_txt1]: ob }); } //优惠礼包 if (good.s_libao) { var l_txt = "formData.give_lb_id"; //这个是json格式的 var l_txt1 = "formData.g_lb_num"; - var ob = [{"num": good.s_lb_num, "l_id": good.s_libao}]; + var ob = [{ "num": good.s_lb_num, "l_id": good.s_libao }]; ob = JSON.stringify(ob); - th.setData({[l_txt]: good.s_coupon_id, [l_txt1]: ob}); + th.setData({ [l_txt]: good.s_coupon_id, [l_txt1]: ob }); } } @@ -2236,17 +2234,17 @@ Page({ }); }, - requestSubscribe(){ - const th=this; + requestSubscribe() { + const th = this; const template_id = this.data.template_id; wx.getSetting({ - withSubscriptions:true, - success(res){ - let itemSettings=res.subscriptionsSetting.itemSettings; - if(itemSettings && itemSettings[template_id]=="accept"){ + withSubscriptions: true, + success(res) { + let itemSettings = res.subscriptionsSetting.itemSettings; + if (itemSettings && itemSettings[template_id] == "accept") { th.submit_func(); - }else{ - th.sendsm(function(){ + } else { + th.sendsm(function () { th.submit_func(); }) } @@ -2255,12 +2253,12 @@ Page({ }, //--------------------提交订单----------------------- - async submit_func(){ + async submit_func() { if (this.data.is_summit_ing == 1) return false; //--提交中退出-- this.data.is_summit_ing = 1; var th = this, pdata = new Array(); var ff = true; - + //------------立即购买------------- if (th.data.is_b_now == 1 && th.data.bn_goods.prom_type != 5) { if (th.data.bn_exp_type == 0 && th.data.user_addr == null) { @@ -2277,7 +2275,7 @@ Page({ th.data.is_summit_ing = 0; return false; } - + var item = { 'user_id': to.globalData.user_id, 'consignee': addr == null ? "" : addr.consignee, @@ -2298,7 +2296,7 @@ Page({ 'user_money': th.data.formData.user_money, //使用余额 'total_amount': th.data.formData.total_amount, //订单总价 'order_amount': th.data.formData.order_amount, //应付 - 'user_note': th.data.user_note['0']?th.data.user_note['0']:0, //用户备注 + 'user_note': th.data.user_note['0'] ? th.data.user_note['0'] : 0, //用户备注 'store_id': oo.stoid, //商家 'pickup_id': th.data.bn_pick, //门店 'exp_type': th.data.bn_exp_type, //配送方式 @@ -2324,7 +2322,7 @@ Page({ } //--判断优惠活动的提交-- - if (th.data.formData.cut_price > 0 ) { + if (th.data.formData.cut_price > 0) { order_prom_list.discount_amount = th.data.formData.cut_price.toFixed(2); var ob = [{ "prom_id": th.data.bn_goods.prom_id, @@ -2387,7 +2385,7 @@ Page({ goods.guide_id = gg.guide_id; goods.guide_type = gg.guide_type; //调用接口判断是不是会员 - await getApp().request.promiseGet("/api/weshop/shoppingGuide/getId/" + oo.stoid + "/" + gg.guide_id, {}).then(res => { + await getApp().request.promiseGet("/api/weshop/shoppingGuide/getId/" + oo.stoid + "/" + gg.guide_id, {}).then(res => { if (res.data.code == 0) { goods.guide_name = res.data.data.salesman; goods.guide_sn = res.data.data.salesman_no; @@ -2439,7 +2437,7 @@ Page({ } var pt_res = null; - await getApp().request.promisePost("/api/weshop/order/getGoodsSplit", { + await getApp().request.promisePost("/api/weshop/order/getGoodsSplit", { is_json: 1, data: pt_data }).then(res => { @@ -2497,7 +2495,7 @@ Page({ } pdata.push(item); } else { - + //---------购物车的结算--------- if (th.data.is_all_zt == 0 && th.data.user_addr == null) { th.data.is_summit_ing = 0; @@ -2518,7 +2516,7 @@ Page({ return false; } - var order_prom_list_cart =  th.data.order_prom_list_cart;; + var order_prom_list_cart = th.data.order_prom_list_cart;; console.log('xxxxxxxxxxxxxxxx', order_prom_list_cart) //--组装推送数据-- for (var i = 0; i < order_prom_list_cart.length; i++) { @@ -2571,23 +2569,23 @@ Page({ order_prom_list.order_prom_amount = t_item.order_prom_amount; } - order_prom_list.discount_amount =0; + order_prom_list.discount_amount = 0; //--判断优惠活动的提交-- if (t_item.cut_price > 0) { order_prom_list.discount_amount += t_item.cut_price; } //--判断组合优惠活动的提交-- - if (t_item.zh_cut_price > 0 || t_item.zh_cut_price<0) { + if (t_item.zh_cut_price > 0 || t_item.zh_cut_price < 0) { order_prom_list.discount_amount += t_item.zh_cut_price; order_prom_list.zh_pt_json = JSON.stringify(t_item.zh_pt_json); } //--判断阶梯优惠活动的提交-- - if (t_item.ladder_cut_price > 0 || t_item.ladder_cut_price<0) { + if (t_item.ladder_cut_price > 0 || t_item.ladder_cut_price < 0) { order_prom_list.discount_amount += t_item.ladder_cut_price; } - if(t_item.prom_pt_json){ + if (t_item.prom_pt_json) { order_prom_list.prom_pt_json = JSON.stringify(t_item.prom_pt_json); } @@ -2602,11 +2600,11 @@ Page({ order_prom_list.give_lb_id = t_item.s_libao; order_prom_list.g_lb_num = JSON.stringify(t_item.g_lb_num); } - if (Object.keys(order_prom_list).length > 0){ - if(order_prom_list.discount_amount) - order_prom_list.discount_amount= parseFloat(order_prom_list.discount_amount).toFixed(2); - if(order_prom_list.order_prom_amount) - order_prom_list.order_prom_amount= parseFloat(order_prom_list.order_prom_amount).toFixed(2); + if (Object.keys(order_prom_list).length > 0) { + if (order_prom_list.discount_amount) + order_prom_list.discount_amount = parseFloat(order_prom_list.discount_amount).toFixed(2); + if (order_prom_list.order_prom_amount) + order_prom_list.order_prom_amount = parseFloat(order_prom_list.order_prom_amount).toFixed(2); item.order_prom_list = order_prom_list; } @@ -2628,18 +2626,18 @@ Page({ //房间号的ids var room_ids = ""; - //-- 把券的钱,写入从表 --- - if (t_item.quan_youhui_list && t_item.coupon_price) { + //-- 把券的钱,写入从表 --- + if (t_item.quan_youhui_list && t_item.coupon_price) { for (var kk in t_item.quan_youhui_list) { var you_item = t_item.quan_youhui_list[kk]; //-- 对券的价格进行平摊 -- - await th.split_set_goods_quanprice(you_item,t_item); + await th.split_set_goods_quanprice(you_item, t_item); } } //-------------让商品添加到商品列表-------------------- for (var k = 0; k < t_item.goods.length; k++) { var g_item = t_item.goods[k]; - if(g_item.goods_num<=0) continue; + if (g_item.goods_num <= 0) continue; var goods = { 'goods_id': g_item.goods_id, 'goods_name': g_item.goods_name, @@ -2652,20 +2650,20 @@ Page({ }; //-- 线下取价也要写入,组合购的商品不能去线下价格 -- - if (g_item.offline_price && t_item.is_offline == 1 && g_item.prom_type!=7) { + if (g_item.offline_price && t_item.is_offline == 1 && g_item.prom_type != 7) { goods.goods_price = g_item.offline_price; goods.member_goods_price = g_item.offline_price; goods.offline_cut = (g_item.goods_price - g_item.offline_price).toFixed(2); goods.pricing_type = g_item.pricing_type; } - if(g_item.quan_num){ - goods.quan_num=g_item.quan_num; - goods.quan_no=g_item.quan_no; + if (g_item.quan_num) { + goods.quan_num = g_item.quan_num; + goods.quan_no = g_item.quan_no; } //--判断活动的类型-- switch (g_item.prom_type) { case 1: - case 2: + case 2: case 10: goods.prom_type = g_item.prom_type; goods.prom_id = g_item.prom_id; @@ -2708,7 +2706,7 @@ Page({ } //把优惠的平摊结果写进去 - if (g_item.account >= 0 || (g_item.account_yu != 0 && g_item.account!=undefined)) { + if (g_item.account >= 0 || (g_item.account_yu != 0 && g_item.account != undefined)) { if (g_item.account >= 0) goods.account = g_item.account; if (g_item.account_yu != 0) goods.account_yu = g_item.account_yu; item.is_discount_amount = 1; @@ -2719,7 +2717,7 @@ Page({ goods.guide_id = g_item.guide_id; goods.guide_type = g_item.guide_type; //调用接口判断是不是会员 - await getApp().request.promiseGet("/api/weshop/shoppingGuide/getId/" + oo.stoid + "/" + g_item.guide_id, {}).then(res => { + await getApp().request.promiseGet("/api/weshop/shoppingGuide/getId/" + oo.stoid + "/" + g_item.guide_id, {}).then(res => { if (res.data.code == 0) { goods.guide_name = res.data.data.salesman; goods.guide_sn = res.data.data.salesman_no; @@ -2733,8 +2731,8 @@ Page({ } //如果有阶梯促销 - if(g_item.ladder_list_id){ - goods.ladder_list_id=g_item.ladder_list_id; + if (g_item.ladder_list_id) { + goods.ladder_list_id = g_item.ladder_list_id; } item.order_goods.push(goods); @@ -2747,11 +2745,11 @@ Page({ } - + if (pdata.length == 0) return; var str = JSON.stringify(pdata); - wx.showLoading({title: "加载中"}); + wx.showLoading({ title: "加载中" }); wx.request({ url: oo.url + '/api/weshop/order/createWxdOrder', data: str, @@ -2780,7 +2778,7 @@ Page({ }) //要进行判断,如果是用微信支付,就要跳转到支付界面 if (order_amount > 0) { - th.setData({isclose: 0}); + th.setData({ isclose: 0 }); //void e.jumpToCart4({ // order_sn: data.data, //}, 1); @@ -2795,12 +2793,12 @@ Page({ }, function () { //支付失败 setTimeout(function () { - var cps=getCurrentPages(); - if(cps.length>1){ - wx.navigateBack({delta: 1}) - }else{ - getApp().goto("/pages/index/index/index"); - } + var cps = getCurrentPages(); + if (cps.length > 1) { + wx.navigateBack({ delta: 1 }) + } else { + getApp().goto("/pages/index/index/index"); + } }, 1000) }, oo.stoid); @@ -2818,7 +2816,7 @@ Page({ if (t.data.code == 0) { //app.my_warnning("支付成功",1,th); //setTimeout(function () { - th.setData({isclose: 0}); + th.setData({ isclose: 0 }); wx.redirectTo({ url: "/pages/payment/pay_success/pay_success?type=2&order_sn=" + data.data, }) @@ -2843,7 +2841,7 @@ Page({ cancelText: '取消', confirmText: '确定', showCancel: true, - success(res){ + success(res) { if (res.cancel) { return; } else if (res.confirm) { @@ -2877,11 +2875,11 @@ Page({ }, //---确认线下门店的数量足不足--- - async check_store_num(goods_id, pick, goods_num, func){ + async check_store_num(goods_id, pick, goods_num, func) { var lock = 0, pick_no, plist, erpwareid; //先读取门店的lock await getApp().request.promiseGet("/api/weshop/order/ware/lock/page", { - data: {store_id: os.stoid, wareId: goods_id, storageId: pick, pageSize: 1000} + data: { store_id: os.stoid, wareId: goods_id, storageId: pick, pageSize: 1000 } }).then(res => { if (res.data.code == 0 && res.data.data.total > 0) { for (var i in res.data.data.pageData) @@ -2890,7 +2888,7 @@ Page({ }) //先获取门店的编号 await getApp().request.promiseGet("/api/weshop/pickup/get/" + os.stoid + "/" + pick, { - data: {storeId: os.stoid, goodsId: t.goods_id, pickupId: pick} + data: { storeId: os.stoid, goodsId: t.goods_id, pickupId: pick } }).then(res => { if (res.data.code == 0) { pick_no = res.data.data.pickup_no; @@ -2898,7 +2896,7 @@ Page({ }) //先获取商品的线下库存 await getApp().request.promiseGet("/api/weshop/goods/get/" + os.stoid + "/" + goods_id, { - data: {storeId: os.stoid, goodsId: t.goods_id, pickupId: pick} + data: { storeId: os.stoid, goodsId: t.goods_id, pickupId: pick } }).then(res => { if (res.data.code == 0) { erpwareid = res.data.data.erpwareid; @@ -2906,7 +2904,7 @@ Page({ }) //读取线下的门店库存 await getApp().request.promiseGet("/api/weshop/goods/getWareStorages", { - data: {storageNos: pick_no, wareIds: encodeURIComponent(erpwareid), storeId: os.stoid, pageSize: 2000} + data: { storageNos: pick_no, wareIds: encodeURIComponent(erpwareid), storeId: os.stoid, pageSize: 2000 } }).then(res => { if (res.data.code == 0) { plist = res.data.data.pageData[0]; @@ -2948,11 +2946,11 @@ Page({ wl_txt = t.currentTarget.dataset.wl_txt, ont = t.currentTarget.dataset.ont; - th.setData({[txt]: ty}); + th.setData({ [txt]: ty }); var iszt = 1; if (ty == 0) { - th.setData({is_all_zt: 0}); + th.setData({ is_all_zt: 0 }); } else { for (var i = 0; i < th.data.cartlist.length; i++) { var item = th.data.cartlist[i]; @@ -2962,7 +2960,7 @@ Page({ } } - th.setData({is_all_zt: iszt}); + th.setData({ is_all_zt: iszt }); var ind = t.currentTarget.dataset.ind; var c_item = th.data.cartlist[ind]; @@ -2970,7 +2968,7 @@ Page({ if (th.data.using_quan[pickid] && th.data.using_quan[pickid].isby == 1) { th.data.using_quan[pickid] = {}; - th.setData({using_quan: th.data.using_quan}); + th.setData({ using_quan: th.data.using_quan }); } @@ -2982,7 +2980,7 @@ Page({ for (var i = 0; i < wu_arr.length; i++) { if (wu_arr[i].shipping_code == def_exp_code) { var set_txt = "cartlist" - th.setData({wl_txt: i}); + th.setData({ wl_txt: i }); } } } @@ -2995,9 +2993,9 @@ Page({ setexptype: function (t) { var th = this; var ty = t.currentTarget.dataset.t, def_exp_code = getApp().globalData.userInfo.def_exp_code; - th.setData({bn_exp_type: ty}); + th.setData({ bn_exp_type: ty }); if (ty == 0) { - th.setData({is_all_zt: 0}); + th.setData({ is_all_zt: 0 }); } //当物流为空的时候。 @@ -3010,7 +3008,7 @@ Page({ if (ty == 1) { th.data.isget_by_quan = {}; if (th.data.using_quan[th.data.bn_pick] && th.data.using_quan[th.data.bn_pick].isby == 1) { - th.setData({using_quan: {}}); + th.setData({ using_quan: {} }); } } @@ -3020,7 +3018,7 @@ Page({ if (wu_arr != null && wu_arr != "") { for (var i = 0; i < wu_arr.length; i++) { if (wu_arr[i].shipping_code == def_exp_code) { - th.setData({index: i}); + th.setData({ index: i }); } } } @@ -3032,21 +3030,21 @@ Page({ //--------立即购买时,使用余额-------- set_bn_useyuer: function () { var th = this; - th.setData({bn_use_money: !th.data.bn_use_money}); + th.setData({ bn_use_money: !th.data.bn_use_money }); th.calculatePrice2(); }, set_js_useyuer: function () { var th = this; - th.setData({js_use_money: !th.data.js_use_money}); + th.setData({ js_use_money: !th.data.js_use_money }); th.calculatePrice(); }, //-------------------计算物流--------------- - calculatewuliu: function (code, o_shipping_price, goods_weight,out_of_weight, - goods_piece, user_addr, freight_free, o_price, rs) { + calculatewuliu: function (code, o_shipping_price, goods_weight, out_of_weight, + goods_piece, user_addr, freight_free, o_price, rs, pickid) { var price = 0, th = this; price += parseFloat(o_shipping_price); //如果是包邮 - if (freight_free > 0 && o_price >= freight_free && out_of_weight>=0) { + if (freight_free > 0 && o_price >= freight_free && out_of_weight >= 0) { return 0; } if (user_addr == null) { @@ -3073,7 +3071,7 @@ Page({ } } //------超出重量---------- - if(out_of_weight < 0 && o_price >= freight_free){ + if (out_of_weight < 0 && o_price >= freight_free && !th.data.is_no_by[pickid]) { fw_price = parseFloat(item['money']); var out_of_weight = Math.abs(out_of_weight); if (out_of_weight > item['first_weight']) { @@ -3119,13 +3117,13 @@ Page({ //----------立即购买,选择物流------------- bindPickerChange: function (e) { var ind = e.detail.value - this.setData({index: ind}); + this.setData({ index: ind }); this.calculatePrice2(); }, //----------购物车结算,选择物流------------- bindPickerChange_w: function (e) { var ind = e.detail.value, txt = e.currentTarget.dataset.txt; - this.setData({[txt]: ind}); + this.setData({ [txt]: ind }); this.calculatePrice(); }, @@ -3139,7 +3137,7 @@ Page({ if (bn == 1) { - th.setData({open_quan: 1, selected_quan_pick: pickid, disabled: 1}); + th.setData({ open_quan: 1, selected_quan_pick: pickid, disabled: 1 }); } else { //---多单打开券的时候,就要判断券在其他门店是否有使用--- var quanlist = th.data.cartlist[cindx].quan_list; @@ -3165,9 +3163,9 @@ Page({ else get_by_quan_list_cart[i].show_red = 0; } - th.setData({by_quan_list_cart: get_by_quan_list_cart}); + th.setData({ by_quan_list_cart: get_by_quan_list_cart }); } else { - th.setData({by_quan_list_cart: null}); + th.setData({ by_quan_list_cart: null }); } console.log("2222222券的列表", quanlist); @@ -3183,7 +3181,7 @@ Page({ }, close_coupon: function (e) { var th = this; - th.setData({open_quan: 0, disabled: 0}); + th.setData({ open_quan: 0, disabled: 0 }); }, //---判断券时候在已经选择的列表中--- @@ -3254,14 +3252,14 @@ Page({ for (var i in quanlist) { quanlist[i].show_red = 0; } - this.setData({selected_quan_list: quanlist}); + this.setData({ selected_quan_list: quanlist }); var by_quanlist = this.data.get_by_quan_list; if (by_quanlist) { //---所有的券的显示红色选择都清理一遍--- for (var inb in by_quanlist) { by_quanlist[inb].show_red = 0; } - this.setData({get_by_quan_list: by_quanlist}); + this.setData({ get_by_quan_list: by_quanlist }); } var by_cart_list = this.data.by_quan_list_cart; @@ -3270,7 +3268,7 @@ Page({ for (var inc in by_cart_list) { by_cart_list[inc].show_red = 0; } - this.setData({by_quan_list_cart: by_cart_list}); + this.setData({ by_quan_list_cart: by_cart_list }); } var using_quan = this.data.using_quan; @@ -3282,9 +3280,9 @@ Page({ using_quan[th.data.selected_quan_pick].is_nouse_red = 1; } else { - using_quan[th.data.selected_quan_pick] = {is_nouse_red: 1}; + using_quan[th.data.selected_quan_pick] = { is_nouse_red: 1 }; } - this.setData({using_quan: using_quan, is_coupon: th.is_coupon}); + this.setData({ using_quan: using_quan, is_coupon: th.is_coupon }); return; } @@ -3301,9 +3299,9 @@ Page({ using_quan[th.data.selected_quan_pick].is_nouse_red = 0; } else { - using_quan[th.data.selected_quan_pick] = {is_nouse_red: 0}; + using_quan[th.data.selected_quan_pick] = { is_nouse_red: 0 }; } - this.setData({using_quan: using_quan}); + this.setData({ using_quan: using_quan }); }, @@ -3318,7 +3316,7 @@ Page({ for (var ind in by_quanlist) { by_quanlist[ind].show_red = 0; } - this.setData({get_by_quan_list: by_quanlist}); + this.setData({ get_by_quan_list: by_quanlist }); } //--购物车过来的包邮券-- @@ -3328,7 +3326,7 @@ Page({ for (var ind in by_cart_list) { by_cart_list[ind].show_red = 0; } - this.setData({by_quan_list_cart: by_cart_list}); + this.setData({ by_quan_list_cart: by_cart_list }); } //普通券 var quanlist = this.data.selected_quan_list; @@ -3337,7 +3335,7 @@ Page({ for (var ind in quanlist) { quanlist[ind].show_red = 0; } - this.setData({selected_quan_list: quanlist}); + this.setData({ selected_quan_list: quanlist }); } var th = this; @@ -3348,9 +3346,9 @@ Page({ using_quan[th.data.selected_quan_pick].is_nouse_red = 1; } else { - using_quan[th.data.selected_quan_pick] = {is_nouse_red: 1}; + using_quan[th.data.selected_quan_pick] = { is_nouse_red: 1 }; } - this.setData({using_quan: using_quan, is_coupon: th.is_coupon}); + this.setData({ using_quan: using_quan, is_coupon: th.is_coupon }); return; } @@ -3379,9 +3377,9 @@ Page({ using_quan[th.data.selected_quan_pick].is_nouse_red = 0; } else { - using_quan[th.data.selected_quan_pick] = {is_nouse_red: 0}; + using_quan[th.data.selected_quan_pick] = { is_nouse_red: 0 }; } - this.setData({using_quan: using_quan}); + this.setData({ using_quan: using_quan }); }, //--确认使用券--- @@ -3441,14 +3439,14 @@ Page({ //选择了的券,看是不是点击了不使用券,点击了不使用优惠券 if (using_quan[pickid]) { if (using_quan[pickid].is_nouse_red == 1) { - using_quan[pickid] = {is_nouse_red: 1}; - th.setData({using_quan: using_quan}); + using_quan[pickid] = { is_nouse_red: 1 }; + th.setData({ using_quan: using_quan }); if (th.data.is_b_now == 1) { th.calculatePrice2(); } else { th.calculatePrice(); } - th.setData({open_quan: 0}); + th.setData({ open_quan: 0 }); return; } } @@ -3467,16 +3465,16 @@ Page({ }; using_quan[pickid].isby = 1; } else { - using_quan[pickid] = {coupon_no: item.CashRepNo, money: item.Sum, is_nouse_red: 0}; + using_quan[pickid] = { coupon_no: item.CashRepNo, money: item.Sum, is_nouse_red: 0 }; using_quan[pickid].isby = 0; } - this.setData({using_quan: using_quan}); + this.setData({ using_quan: using_quan }); if (th.data.is_b_now == 1) { th.calculatePrice2(); } else { th.calculatePrice(); } - th.setData({open_quan: 0}); + th.setData({ open_quan: 0 }); }, cart_set_err: function (e) { @@ -3513,7 +3511,7 @@ Page({ var wu_arr_txt = e.currentTarget.dataset.txt; var w_sele_index = e.currentTarget.dataset.w_sele_index; var is_express = null; - var ob = {open_express: 1, wu_arr_txt: wu_arr_txt, disabled: 1}; + var ob = { open_express: 1, wu_arr_txt: wu_arr_txt, disabled: 1 }; //--如果是多个门店的时候-- if (w_sele_index != undefined) { @@ -3524,20 +3522,20 @@ Page({ }, // 关闭物流的弹窗 close_express: function () { - this.setData({open_express: 0, disabled: 0}); + this.setData({ open_express: 0, disabled: 0 }); }, // 选择物流 click_express_name: function (e) { var express_name = e.currentTarget.dataset.name, shippingcode = e.currentTarget.dataset.shippingcode; var index = e.currentTarget.dataset.idxe; - var ob = {is_express: index, is_shipping_code: shippingcode, disabled: 0}; + var ob = { is_express: index, is_shipping_code: shippingcode, disabled: 0 }; ob[this.data.wu_arr_txt] = index; this.setData(ob); }, //点击确定物流 determine_expres: function (e) { - this.setData({open_express: 0}); + this.setData({ open_express: 0 }); if (this.data.is_b_now == 1) this.calculatePrice2(); else @@ -3557,7 +3555,7 @@ Page({ obj[txt] = is_open; this.setData(obj); - this.setData({disabled: 1}) + this.setData({ disabled: 1 }) }, clik_coupons2: function (e) { @@ -3572,7 +3570,7 @@ Page({ obj[txt] = is_open; this.setData(obj); - this.setData({disabled: 1}) + this.setData({ disabled: 1 }) }, @@ -3581,11 +3579,11 @@ Page({ var th = this; var is_shipping_code = this.data.is_shipping_code getApp().request.put("/api/weshop/users/update", { - data: {user_id: getApp().globalData.user_id, store_id: oo.stoid, def_exp_code: is_shipping_code}, + data: { user_id: getApp().globalData.user_id, store_id: oo.stoid, def_exp_code: is_shipping_code }, success: function (rse) { if (rse.data.code == 0) { getApp().globalData.userInfo.def_exp_code = is_shipping_code; - th.setData({open_express: 0}); + th.setData({ open_express: 0 }); //----计算此时购物车的价格---- if (th.data.is_b_now == 1) th.calculatePrice2(); else th.calculatePrice(); @@ -3595,7 +3593,7 @@ Page({ }, //更新下默认,在onshow里面 - update_code(){ + update_code() { var th = this, m_wind = 0, def_exp_code = getApp().globalData.userInfo.def_exp_code; //--定时器,判断wu_arr不未空-- var uii = setInterval(function () { @@ -3609,7 +3607,7 @@ Page({ } //--如果是立即购买-- if (th.data.is_b_now == 1) { - th.setData({index: m_wind, is_express: m_wind}); + th.setData({ index: m_wind, is_express: m_wind }); } else { var ui = setInterval(function () { if (th.data.cartlist) { @@ -3617,7 +3615,7 @@ Page({ for (var i in c_arr) { c_arr[i].wind = m_wind; } - th.setData({cartlist: c_arr, is_express: m_wind}) + th.setData({ cartlist: c_arr, is_express: m_wind }) clearInterval(ui); } }, 500) @@ -3629,7 +3627,7 @@ Page({ get_cart_quan: async function (order_prom_list_cart) { var th = this; var is_xz_yh = 1; - var user_id=getApp().globalData.user_id; + var user_id = getApp().globalData.user_id; //等待值的出现 //getApp().waitfor2(this,"g_cart_q_time","order_prom_list_cart",async function () { //var arr=th.data.order_prom_list_cart; @@ -3648,8 +3646,8 @@ Page({ var ckeck_quan_price = 0, check_quan_price_list = '', check_quan_ware_list = '', - check_quan_price_list_arr=[], - check_quan_ware_list_arr=[]; + check_quan_price_list_arr = [], + check_quan_ware_list_arr = []; for (var i in goodlist) { var gd = goodlist[i]; @@ -3659,25 +3657,25 @@ Page({ } //--如果是团购,要判断有没有限制使用优惠券 - if(gd.prom_type == 2){ - var prom1=null; + if (gd.prom_type == 2) { + var prom1 = null; await getApp().request.promiseGet("/api/weshop/goods/groupBuy/getActInfo/" + os.stoid + "/" + gd.goods_id + "/" + gd.prom_id, { }).then(res => { if (res.data.code == 0) prom1 = res.data.data; }) - if(prom1 && !prom1.isQuan){ + if (prom1 && !prom1.isQuan) { continue; } } //--如果是团购,要判断有没有限制使用优惠券 - if(gd.prom_type == 10){ - var prom1=null; - await getApp().request.promiseGet("/api/weshop/prom/ladderForm/getNew/"+ os.stoid +"/"+user_id+"/"+ gd.prom_id, { + if (gd.prom_type == 10) { + var prom1 = null; + await getApp().request.promiseGet("/api/weshop/prom/ladderForm/getNew/" + os.stoid + "/" + user_id + "/" + gd.prom_id, { }).then(res => { if (res.data.code == 0) prom1 = res.data.data; }) - if(prom1 && prom1.isuse && prom1. is_usecoupon){ + if (prom1 && prom1.isuse && prom1.is_usecoupon) { continue; } } @@ -3689,43 +3687,43 @@ Page({ } is_xz_yh = 0; - var item_price = gd.goods_price * gd.goods_num; - var item_price2=item_price; + var item_price = gd.goods_price * gd.goods_num; + var item_price2 = item_price; //-- 如果有平摊下去,有实收价格的时候,就要用account来计算价格 -- if (gd.account_fir != null && gd.account_fir != undefined) { item_price2 = gd.account_fir * gd.goods_num; } - if(gd.ld_account){ + if (gd.ld_account) { item_price2 = gd.ld_account * gd.goods_num; } ckeck_quan_price += item_price; //如果商品有重复的过滤,一般是组合购和阶梯购的情况下 - var idx=check_quan_ware_list_arr.findIndex(function(ele){ - return ele== encodeURIComponent(gd['erpwareid']); + var idx = check_quan_ware_list_arr.findIndex(function (ele) { + return ele == encodeURIComponent(gd['erpwareid']); }) - if(idx>-1){ - check_quan_price_list_arr[idx]+=item_price2; - }else{ + if (idx > -1) { + check_quan_price_list_arr[idx] += item_price2; + } else { check_quan_ware_list_arr.push(encodeURIComponent(gd['erpwareid'])); check_quan_price_list_arr.push(item_price2); } - //--组装价格list-- - /*-- - if (check_quan_price_list) { - check_quan_price_list += "," + item_price; - } else { - check_quan_price_list = item_price; - } - //--组装商品的线下erpwareid-- - if (check_quan_ware_list) { - check_quan_ware_list += "," + encodeURIComponent(gd['erpwareid']); - } else { - check_quan_ware_list = encodeURIComponent(gd['erpwareid']); - }---*/ + //--组装价格list-- + /*-- + if (check_quan_price_list) { + check_quan_price_list += "," + item_price; + } else { + check_quan_price_list = item_price; + } + //--组装商品的线下erpwareid-- + if (check_quan_ware_list) { + check_quan_ware_list += "," + encodeURIComponent(gd['erpwareid']); + } else { + check_quan_ware_list = encodeURIComponent(gd['erpwareid']); + }---*/ } //优惠券优惠的金额要控制到优惠券的选择条件 var cut_price = 0; @@ -3736,16 +3734,16 @@ Page({ } } - var prom_pt_json= ep.prom_pt_json; - if(prom_pt_json){ - for(let oj in prom_pt_json){ - let item_j=prom_pt_json[oj]; + var prom_pt_json = ep.prom_pt_json; + if (prom_pt_json) { + for (let oj in prom_pt_json) { + let item_j = prom_pt_json[oj]; //要对一下阶梯优惠促销的功能 - if(item_j.ladder_prom_id){ + if (item_j.ladder_prom_id) { //看一下要不要限制使用优惠券 - if (th.data.ladder_map[item_j.ladder_prom_id] && th.data.ladder_map[item_j.ladder_prom_id].is_usecoupon){ + if (th.data.ladder_map[item_j.ladder_prom_id] && th.data.ladder_map[item_j.ladder_prom_id].is_usecoupon) { continue; } @@ -3754,10 +3752,10 @@ Page({ } } - if(check_quan_price_list_arr.length) check_quan_price_list=check_quan_price_list_arr.join(','); - if(check_quan_ware_list_arr.length) check_quan_ware_list=check_quan_ware_list_arr.join(',') + if (check_quan_price_list_arr.length) check_quan_price_list = check_quan_price_list_arr.join(','); + if (check_quan_ware_list_arr.length) check_quan_ware_list = check_quan_ware_list_arr.join(',') - arr[ind].ckeck_quan_price = ckeck_quan_price - (cut_price?cut_price:0); + arr[ind].ckeck_quan_price = ckeck_quan_price - (cut_price ? cut_price : 0); arr[ind].check_quan_ware_list = check_quan_ware_list; arr[ind].check_quan_price_list = check_quan_price_list; arr[ind].is_xz_yh = is_xz_yh; @@ -3787,10 +3785,10 @@ Page({ if (th.data.is_b_now) { if (arr && arr.length > 0) { var quanlist = arr[0].quan_list; - th.setData({selected_quan_list: quanlist, cartlist: arr}) + th.setData({ selected_quan_list: quanlist, cartlist: arr }) } } else { - th.setData({cartlist: arr}) + th.setData({ cartlist: arr }) th.set_can_num(); } @@ -3810,7 +3808,7 @@ Page({ if (th.data.is_close_quan != 1 && th.data.bn_goods.is_xz_yh != 1) { var url0 = "/api/weshop/users/frozenQuan/listFrozenQuan/" + app.globalData.user_id; var url = "/api/weshop/couponList/getUseCouponList"; - app.request.promiseGet(url0, {1: 1}).then(res => { + app.request.promiseGet(url0, { 1: 1 }).then(res => { if (res.data.code == 0) { frozenQuan = res.data.data; th.data.frozenQuan = frozenQuan; @@ -3828,7 +3826,7 @@ Page({ quanlist = res.data.data.pageData; if (quanlist) { quanlist = th.check_is_frozenQuan(quanlist, frozenQuan); - th.setData({selected_quan_list: quanlist}) + th.setData({ selected_quan_list: quanlist }) } } } @@ -3856,7 +3854,7 @@ Page({ if (!goods_id) goods_id = this.data.bn_goods.goods_id; for (var i in arr) { var item = arr[i]; - if (goods_id == item) return 0; + if (goods_id == item) return 0; } return 1; }, @@ -3927,7 +3925,7 @@ Page({ if (this.data.is_b_now == 1) pick = this.data.bn_pick; //---获取订单优惠--- getApp().request.promiseGet("/api/weshop/promorder/getOrderPromotion", { - data: {store_id: os.stoid, orderAmount: condition} + data: { store_id: os.stoid, orderAmount: condition } }).then(res => { if (res.data.code == 0) { var data = res.data.data; @@ -3949,7 +3947,7 @@ Page({ var ob = map[pickid][item.prom_id]; ob.price += item.goods_price * item.goods_num; ob.goods_num += item.goods_num; - ob.goods.push({goods_id: item.goods_id, goods_price: item.goods_price, goods_num: item.goods_num}); + ob.goods.push({ goods_id: item.goods_id, goods_price: item.goods_price, goods_num: item.goods_num }); } else { var prom = null; @@ -3965,7 +3963,7 @@ Page({ ob.is_bz = prom.is_bz; ob.is_xz_yh = prom.is_xz_yh; ob.goods = new Array(); - ob.goods.push({goods_id: item.goods_id, goods_price: item.goods_price, goods_num: item.goods_num}); + ob.goods.push({ goods_id: item.goods_id, goods_price: item.goods_price, goods_num: item.goods_num }); map[pickid][item.prom_id] = ob; } } else { @@ -3982,7 +3980,7 @@ Page({ ob.is_bz = prom.is_bz; ob.is_xz_yh = prom.is_xz_yh; ob.goods = new Array(); - ob.goods.push({goods_id: item.goods_id, goods_price: item.goods_price, goods_num: item.goods_num}); + ob.goods.push({ goods_id: item.goods_id, goods_price: item.goods_price, goods_num: item.goods_num }); var obj = {}; obj[item.prom_id] = ob; @@ -3992,12 +3990,12 @@ Page({ }, //计算立即购买赠品的物流费用 - get_now_gift_goods_wuliu: function (code, o_shipping_price, user_addr, gift_freight_free,out_of_weight, allpice, rs, shipping_price, no_by_data, goods_weight1, goods_piece1) { + get_now_gift_goods_wuliu: function (code, o_shipping_price, user_addr, gift_freight_free, out_of_weight, allpice, rs, shipping_price, no_by_data, goods_weight1, goods_piece1) { var good = this.data.buy_now_gift_goods; var goods_weight = -1, goods_piece = -1; var gift_shipping_price = 0; var th = this; - var out_of_weight=null; + var out_of_weight = null; switch (good['exp_sum_type']) { case 1: //统一运费 @@ -4009,7 +4007,7 @@ Page({ //累积商品重量 每种商品的重量 * 数量 goods_weight += good['weight'] * good['buynum']; if (goods_weight1 > 0) { - out_of_weight = gift_weight_free - goods_weight; + out_of_weight = gift_weight_free - goods_weight; //不能调换位置 下面goods_weight会变大 goods_weight += goods_weight1; } @@ -4029,7 +4027,7 @@ Page({ if (no_by_data && no_by_data.region_list) { if (th.check_by_area(no_by_data.region_list)) { gift_freight_free = 0; - out_of_weight=0 + out_of_weight = 0 th.data.is_no_by[th.data.bn_pick] = 1; } } @@ -4037,14 +4035,14 @@ Page({ if (no_by_data && no_by_data.goods_list && gift_freight_free) { if (th.check_by_goods(no_by_data.goods_list, good.goods_id)) { gift_freight_free = 0; - out_of_weight=0 - //th.data.is_no_by[th.data.bn_pick]=1; + out_of_weight = 0 + th.data.is_no_by[th.data.bn_pick]=1; } } var t_shipping_price = - this.calculatewuliu(code, gift_shipping_price, goods_weight,out_of_weight, - goods_piece, user_addr, gift_freight_free, allpice, rs); + this.calculatewuliu(code, gift_shipping_price, goods_weight, out_of_weight, + goods_piece, user_addr, gift_freight_free, allpice, rs,th.data.bn_pick); return t_shipping_price; }, @@ -4101,7 +4099,7 @@ Page({ //跳转关闭弹出框的显示 close_offline: function () { - this.setData({is_offline_show: 0}); + this.setData({ is_offline_show: 0 }); }, //立即购买显示弹出框 @@ -4109,7 +4107,7 @@ Page({ var off_price = this.data.bn_goods.shop_price - this.data.bn_goods.offline_price; //是不是线下 var is_get_offline = this.data.bn_goods.is_offline; - this.setData({is_offline_show: 1, show_off_price: off_price.toFixed(2), is_get_offline: is_get_offline}); + this.setData({ is_offline_show: 1, show_off_price: off_price.toFixed(2), is_get_offline: is_get_offline }); }, //确定使用线下取价 @@ -4117,14 +4115,14 @@ Page({ var bn_goods = this.data.bn_goods; if (bn_goods && bn_goods.prom_type == 0) { bn_goods.is_offline = 1; - this.setData({is_offline_show: 0, bn_goods: bn_goods}); + this.setData({ is_offline_show: 0, bn_goods: bn_goods }); this.calculatePrice2(); } //就是购物车结算时的 else { var index = this.data.pop_offline_index; var txt = "cartlist[" + index + "].is_offline"; - this.setData({[txt]: 1, is_offline_show: 0,}); + this.setData({ [txt]: 1, is_offline_show: 0, }); this.data.old_cartlist[index].is_offline = 1; this.calculatePrice(); } @@ -4136,14 +4134,14 @@ Page({ var bn_goods = this.data.bn_goods; if (bn_goods && bn_goods.prom_type == 0) { bn_goods.is_offline = 0; - this.setData({is_offline_show: 0, bn_goods: bn_goods}); + this.setData({ is_offline_show: 0, bn_goods: bn_goods }); this.calculatePrice2(); } //就是购物车结算时的 else { var index = this.data.pop_offline_index; var txt = "cartlist[" + index + "].is_offline"; - this.setData({[txt]: 0, is_offline_show: 0,}) + this.setData({ [txt]: 0, is_offline_show: 0, }) this.data.old_cartlist[index].is_offline = 0; this.calculatePrice(); } @@ -4176,34 +4174,34 @@ Page({ // this.setData({[txt]:0}) // }, - go_url:function (e) { + go_url: function (e) { var url = e.currentTarget.dataset.url; getApp().goto(url); }, - //进行对商品的平摊g_item是单个商品,you_item是这个商品分多少优惠券的钱,goods是商品列表 - split_set_goods_quanprice:async function (you_item,t_item) { - var coupon_price=you_item.WareCashSum; - var goods=t_item.goods; - var arr=[]; + //进行对商品的平摊g_item是单个商品,you_item是这个商品分多少优惠券的钱,goods是商品列表 + split_set_goods_quanprice: async function (you_item, t_item) { + var coupon_price = you_item.WareCashSum; + var goods = t_item.goods; + var arr = []; //判断是不是有goods_id重复 - for(var i=0;i { @@ -4226,21 +4224,21 @@ Page({ for (var i in pt_res) { var idx = pt_res[i].idx; //有account的实收价,就要用account实收价 - var price=(t_item.goods[idx].account?t_item.goods[idx].account:t_item.goods[idx].goods_price); - price=(price - pt_res[i].fisrt_account)* t_item.goods[idx].goods_num; - t_item.goods[idx].quan_num =price; + var price = (t_item.goods[idx].account ? t_item.goods[idx].account : t_item.goods[idx].goods_price); + price = (price - pt_res[i].fisrt_account) * t_item.goods[idx].goods_num; + t_item.goods[idx].quan_num = price; - t_item.goods[idx].quan_num =Math.floor(t_item.goods[idx].quan_num * 100) / 100; - t_item.goods[idx].quan_no=t_item.quan_no; + t_item.goods[idx].quan_num = Math.floor(t_item.goods[idx].quan_num * 100) / 100; + t_item.goods[idx].quan_no = t_item.quan_no; q_s_num += t_item.goods[idx].quan_num; } - if (q_s_num > parseFloat(coupon_price) || q_s_num < parseFloat(coupon_price)){ + if (q_s_num > parseFloat(coupon_price) || q_s_num < parseFloat(coupon_price)) { for (var ik in arr) { if (arr[ik].goods_num == 1) { var id = arr[ik].idx; - var pri=Math.floor(coupon_price*100)/100-Math.floor(q_s_num*100)/100 - t_item.goods[id].quan_num+=pri; + var pri = Math.floor(coupon_price * 100) / 100 - Math.floor(q_s_num * 100) / 100 + t_item.goods[id].quan_num += pri; break; } } @@ -4248,8 +4246,7 @@ Page({ } }, //订阅消息提醒 - sendsm:function(func) - { + sendsm: function (func) { var template_id = this.data.template_id; // //授权订阅 wx.requestSubscribeMessage({ diff --git a/pages/cart/cart2_inte/cart2_inte.js b/pages/cart/cart2_inte/cart2_inte.js index b57a966..bd33015 100644 --- a/pages/cart/cart2_inte/cart2_inte.js +++ b/pages/cart/cart2_inte/cart2_inte.js @@ -1,12 +1,12 @@ -var t = getApp(),app=t, a = t.request, e = require("../../../utils/common.js"), - s = require("../../../utils/util.js"),ut=s, o = require("../../../utils/md5.js"), to = getApp(); -var oo=t.globalData.setting,os=oo; +var t = getApp(), app = t, a = t.request, e = require("../../../utils/common.js"), + s = require("../../../utils/util.js"), ut = s, o = require("../../../utils/md5.js"), to = getApp(); +var oo = t.globalData.setting, os = oo; var regeneratorRuntime = require('../../../utils/runtime.js'); var util_pay = require("../../../utils/pay.js"); -Page({ +Page({ data: { - url: t.globalData.setting.url, + url: t.globalData.setting.url, imgUrl: t.globalData.setting.imghost, goods: null, order: null, @@ -20,361 +20,361 @@ Page({ enterAddressPage: !1, firstEnter: !0, //页面获取的参数 - param:null, + param: null, //提交订单的格式 formData: { - order_amount:0,//支付金额 - total_amount:0,//总价 - all_price:0,//商品卖的总价 + order_amount: 0,//支付金额 + total_amount: 0,//总价 + all_price: 0,//商品卖的总价 pay_points: 0,//使用积分 user_money: 0,//使用余额 couponCode: "",//使用优惠券(多单就用逗号隔开) - shipping_price:0,//物流费用 + shipping_price: 0,//物流费用 }, /*----------------立即购买---------------------*/ - is_b_now:1, //0是购物车结算 1立即购买 - bn_goods:null, //立即购买时候的调用商品 - bn_use_money:0,//是否使用余额 - bn_exp_type:1, //0是物流 1自提 - bn_pick:0, //选择的门店 + is_b_now: 1, //0是购物车结算 1立即购买 + bn_goods: null, //立即购买时候的调用商品 + bn_use_money: 0,//是否使用余额 + bn_exp_type: 1, //0是物流 1自提 + bn_pick: 0, //选择的门店 bn_pickname: "", //选择的门店名称 - bn_t_exp_t:0, //判断商品和门店一起决定的物流自提的方式0 都可以 1自提 2物流 - - bn_plus_cut_price:0, //显示等级卡会优惠多少钱 + bn_t_exp_t: 0, //判断商品和门店一起决定的物流自提的方式0 都可以 1自提 2物流 + + bn_plus_cut_price: 0, //显示等级卡会优惠多少钱 /*------------------------*/ - user_addr:null,//物流 - userinfo:null, //获取会员 + user_addr: null,//物流 + userinfo: null, //获取会员 /*----------物流选择--------*/ - wu_arr:null, - index:0, - w_sele_index:0, + wu_arr: null, + index: 0, + w_sele_index: 0, //判断页面是返回回来的还是 首次进入的 - isclose:1, + isclose: 1, //申请提现的金额 - txmon:0, - yuer:0, + txmon: 0, + yuer: 0, //提交中,不重复提交 - is_summit_ing:0, - - disabled:0, - open_express:0,//控制选择物流名列表 的属性 - - is_express:0, //选中物流的属性 - expres_name:"", //点击选定 - is_shipping_code:"",//插入用户默认地址 - wu_arr_txt:"", //要更新的物流的字段 - - //如果是全场包邮了,或者是全场不包邮了,就不要选包邮券 - is_no_by:{}, - is_by:{}, - is_quan_by:{}, + is_summit_ing: 0, + + disabled: 0, + open_express: 0,//控制选择物流名列表 的属性 + + is_express: 0, //选中物流的属性 + expres_name: "", //点击选定 + is_shipping_code: "",//插入用户默认地址 + wu_arr_txt: "", //要更新的物流的字段 + + //如果是全场包邮了,或者是全场不包邮了,就不要选包邮券 + is_no_by: {}, + is_by: {}, + is_quan_by: {}, //--购买赠送的商品-- - buy_now_gift_goods:null, + buy_now_gift_goods: null, //--订单优惠-- - order_prom:{}, - show_submit:0, //提交按钮变正常显示 + order_prom: {}, + show_submit: 0, //提交按钮变正常显示 }, - onLoad: function(t) { - wx.setNavigationBarTitle({ title: "填写订单",}) - var th = this; - th.data.param=t; + onLoad: function (t) { + wx.setNavigationBarTitle({ title: "填写订单", }) + var th = this; + th.data.param = t; //清空is_pick_up getApp().request.put("/api/weshop/useraddress/updatePickUp", { - data: {user_id: getApp().globalData.user_id, is_pickup: 0}, - success: function (s) { - } + data: { user_id: getApp().globalData.user_id, is_pickup: 0 }, + success: function (s) { + } }); - - //先获取是否有关闭使用优惠券 - getApp().getConfig2(function (ee) { - var json_d = JSON.parse(ee.switch_list); - th.data.json_d=json_d; - th.data.ispt_goods=json_d.ispt_goods; //是不是平摊到单品的控制参数赋值 - var is_default_logistics=json_d.is_default_logistics; - th.setData({ is_close_quan: json_d.is_close_quan,sales_rules:ee.sales_rules,rank_switch:json_d.rank_switch,is_default_logistics:is_default_logistics}); - - var rank_switch=json_d.rank_switch; - var max_price=-1; - var show_card=null; - var name=""; - //如果有开等级卡的时候, - //因为都是调接口,要返回在计算 - if(rank_switch==2){ - //-- 获取所有的等级卡, -- - getApp().request.promiseGet("/api/weshop/plus/vip/mem/bership/list?storeId=" + os.stoid, - {}).then(res => { - if(res.data.code==0){ - var plusCard = res.data.data; - //-- 循环判断,拿到最贵的那张卡 -- - for(var ih in plusCard){ - if(plusCard[ih].IsStopBuy == true){ continue; } - if(max_price<0){ - max_price=plusCard[ih].CardFee; - name='card'+plusCard[ih]['CorrPrice']; - show_card=plusCard[ih]; - }else{ - if(max_price0?th.data.userinfo.frozen_money:0) - su.data.data.summoney).toFixed(2); - th.setData({ txmon: su.data.data.summoney, yuer: yuer }); - } - } - }); - - }, - }) - - + + var user = getApp().globalData.userInfo; + getApp().request.get("/api/weshop/users/get/" + oo.stoid + "/" + user.user_id, { + data: { r: Math.random() }, + success: function (e) { + + getApp().globalData.userInfo = e.data.data; + th.setData({ userinfo: e.data.data }); + + //选获取地址 + th.getuser_addr(function (addr) { + th.setData({ user_addr: addr }); + //--------------------------立即购买------------------ + if (ta.is_bnow == 1) { + //读取门店 + to.get_allsto(function (e) { + th.setData({ allsto: e }); + //获取立即购买的商品信息 + th.get_buy_goods(ta.goods_id); + }); + } + }); + //获取提现金额 + getApp().request.get("/api/weshop/withdrawals/summoney", { + data: { user_id: to.globalData.user_id, store_id: oo.stoid, status: 0 }, + success: function (su) { + if (su.data.code == 0) { + var yuer = parseFloat(th.data.userinfo.user_money - + (th.data.userinfo.frozen_money > 0 ? th.data.userinfo.frozen_money : 0) - su.data.data.summoney).toFixed(2); + th.setData({ txmon: su.data.data.summoney, yuer: yuer }); + } + } + }); + + }, + }) + + }, - + //-----获取立即购买的商品信息,入口---- - get_buy_goods: function (e){ - var th=this; + get_buy_goods: function (e) { + var th = this; var gg = to.get_b_now(); //--------如果goods_id一样,就是要立即购买----- - if(e==gg.goods_id){ - a.get("/api/weshop/goods/get/" + oo.stoid+"/"+e, { - success:async function (t) { + if (e == gg.goods_id) { + a.get("/api/weshop/goods/get/" + oo.stoid + "/" + e, { + success: async function (t) { var gd = t.data.data; - if(!gd) return false; + if (!gd) return false; t.data.data.original_img = oo.imghost + t.data.data.original_img; t.data.data['buynum'] = gg.goods_num; - var distr_t=0,et=0 - if (t.data.data.distr_type==0){ + var distr_t = 0, et = 0 + if (t.data.data.distr_type == 0) { distr_t = gg.pick_dis; - }else{ + } else { distr_t = t.data.data.distr_type; } - switch (distr_t){ + switch (distr_t) { case 0: - et=1; - //-- 系统后台有设置要默认的 -- - if(th.data.json_d.pickupway && th.data.json_d.pickupway==1) et=0; - break; + et = 1; + //-- 系统后台有设置要默认的 -- + if (th.data.json_d.pickupway && th.data.json_d.pickupway == 1) et = 0; + break; case 1: et = 1; break; case 2: et = 0; break; } - - if(th.data.bn_goods) et=th.data.bn_exp_type - - var m_wind=0,def_exp_code=getApp().globalData.userInfo.def_exp_code; - if(et==0 && def_exp_code){ - for(var k=0;k 0 && gg.goods_price > gd[th.data.card_name] && !th.data.userinfo.card_field) { + var cut_p = (gg.goods_price - gd[th.data.card_name]) * gg.goods_num; + th.setData({ card_cut_price: cut_p }); + } } - - //---是不是购买等级卡成功的返回---等级卡显示的判断--- - var is_card_back=getApp().globalData.is_card_back; - if(is_card_back){ - th.data.card_name=th.data.userinfo.card_field; - gg.goods_price=gd[th.data.card_name]; - getApp().globalData.is_card_back=0; - th.setData({card_cut_price:0}); - //如果是秒杀的返回 - if(gd.prom_type==4) gd.prom_type=0; - }else{ - //--- 商家等级卡开通的情况下, 会员不是等级会员的情况, 商品有设置等级卡价格,同时等级卡价格小于商品的价格 - //-- 搭配购的商品也可以单独购买,所以此时搭配购的商品要进行计算优惠 -- - 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){ - var cut_p= (gg.goods_price-gd[th.data.card_name])*gg.goods_num; - th.setData({card_cut_price:cut_p}); - } - } - - switch (gd.prom_type){ + + switch (gd.prom_type) { case 0: case 2: case 3: case 5: case 6: - getApp().my_warnning("商品不是积分活动",0,th); - wx.navigateBack(); - break; + getApp().my_warnning("商品不是积分活动", 0, th); + wx.navigateBack(); + break; case 4: //-- 积分购 -- - getApp().request.get("/api/weshop/integralbuy/pageIntegralBuyGoodsList?stype=1&stypeup=1",{ - data:{store_id:os.stoid,goods_id:gg.goods_id}, + getApp().request.get("/api/weshop/integralbuy/pageIntegralBuyGoodsList?stype=1&stypeup=1", { + data: { store_id: os.stoid, goods_id: gg.goods_id }, success: async function (tt) { - if(tt.data.code==0 && tt.data.data && tt.data.data.pageData){ - var inte_data=tt.data.data.pageData[0]; - t.data.data.shop_price=inte_data.addmoney; - t.data.data.integral=inte_data.integral; - th.setData({ - bn_goods: t.data.data, bn_pickname: gg.pick_name, bn_exp_type: et,index:m_wind, - bn_pick: gg.pick_id, bn_t_exp_t: distr_t,bn_exp_type: et - }); - //计算价格 - th.calculatePrice2(); - }else{ - getApp().my_warnning("商品不是积分活动",0,th); - wx.navigateBack(); - } + if (tt.data.code == 0 && tt.data.data && tt.data.data.pageData) { + var inte_data = tt.data.data.pageData[0]; + t.data.data.shop_price = inte_data.addmoney; + t.data.data.integral = inte_data.integral; + th.setData({ + bn_goods: t.data.data, bn_pickname: gg.pick_name, bn_exp_type: et, index: m_wind, + bn_pick: gg.pick_id, bn_t_exp_t: distr_t, bn_exp_type: et + }); + //计算价格 + th.calculatePrice2(); + } else { + getApp().my_warnning("商品不是积分活动", 0, th); + wx.navigateBack(); + } } }); break; @@ -385,34 +385,34 @@ Page({ }, //---------------检查是否有收货地址------------------- - checkAddressList: function() { + checkAddressList: function () { var t = this; return !(!this.data.order || null == this.data.order.userAddress) || (wx.showModal({ title: "请先填写或选择收货地址~", - success: function(a) { + success: function (a) { a.confirm ? t.enterAddressPage() : wx.navigateBack(); }, - fail: function() { + fail: function () { wx.navigateBack(); } }), !1); }, - showInvoice: function() { + showInvoice: function () { this.setData({ invoiceToggle: !this.data.invoiceToggle }); }, - keyUpChangePay1: function(t) { + keyUpChangePay1: function (t) { this.setData({ payWithUserMoney: !(t.detail.value.length > 0) }); }, - keyUpChangePay2: function(t) { + keyUpChangePay2: function (t) { this.setData({ payWithPoints: !(t.detail.value.length > 0) }); }, - keyUpChangeNum: function(t) { + keyUpChangeNum: function (t) { this.setData({ maxWord: t.detail.value.length }); @@ -421,33 +421,33 @@ Page({ //---------计算立即购买---------- calculatePrice2: function () { - var th = this, good = this.data.bn_goods; - wx.showLoading({ title:"处理中.",}) + var th = this, good = this.data.bn_goods; + wx.showLoading({ title: "处理中.", }) //-----------计算商品总价-------------- var allpice = good.shop_price * good.buynum; - var all_integral=good.integral * good.buynum; - - var cut_price=0; - if(good.prom_type==3 && good.prom_price!==null){ - cut_price=allpice-good.prom_price; + var all_integral = good.integral * good.buynum; + + var cut_price = 0; + if (good.prom_type == 3 && good.prom_price !== null) { + cut_price = allpice - good.prom_price; } - allpice=parseFloat(allpice).toFixed(2); + allpice = parseFloat(allpice).toFixed(2); var txt = "formData.all_price"; th.setData({ [txt]: allpice, }); - if(cut_price){ - var c_txt="formData.cut_price"; + if (cut_price) { + var c_txt = "formData.cut_price"; th.setData({ [c_txt]: cut_price, }); } to.getConfig2(function (ee) { to.getwuliuprice(async function (rs) { var o_shipping_price = 0, goods_weight = -1, goods_piece = -1; - var out_of_weight=null; //超出多少重量 + var out_of_weight = null; //超出多少重量 var freight_free = ee.freight_free; //全场满多少包邮 var weight_free = ee.weight_free; //多少kg内包邮 //-----------当地址不为空,且是物流时,计算物流费用,并同时商品不是优惠活动的包邮---------- - if (th.data.user_addr != null && th.data.bn_exp_type == 0 && good.is_free_shipping == 0 && good.is_past!=1 ){ - + if (th.data.user_addr != null && th.data.bn_exp_type == 0 && good.is_free_shipping == 0 && good.is_past != 1) { + switch (good['exp_sum_type']) { case 1: //统一运费 @@ -456,8 +456,8 @@ Page({ if (goods_weight < 0) goods_weight = 0; //累积商品重量 每种商品的重量 * 数量 goods_weight += good['weight'] * good['buynum']; - if(weight_free > 0){ - out_of_weight = (weight_free * 1000 ) - goods_weight; + if (weight_free > 0) { + out_of_weight = (weight_free * 1000) - goods_weight; } break; case 3: @@ -466,94 +466,94 @@ Page({ goods_piece += good['buynum']; break; } - var code =""; - if(th.data.wu_arr && th.data.wu_arr[th.data.index]) code=th.data.wu_arr[th.data.index].code; - var no_ex_id=ee.no_ex_id; - th.data.is_no_by[th.data.bn_pick]=0; - - var no_by_data=null; - var gift_freight_free=freight_free; - //有不包邮区域,且不免运费 - if(no_ex_id && freight_free>0 && freight_free<=allpice-cut_price){ - //-----------获取不包邮区域,不包邮商品------- - await getApp().request.promiseGet("/api/weshop/areaFeemail/getAreaGoods",{ - data:{store_id:os.stoid,id:no_ex_id} - }).then(res=>{ - if(res.data.code==0){ - no_by_data=res.data.data[0]; - //如果有设置不包邮区域的时候 - if(res.data.data[0].region_list){ - if(th.check_by_area(res.data.data[0].region_list)){ - freight_free=0; - out_of_weight=0; - th.data.is_no_by[th.data.bn_pick]=1; - } - } - //如果有设置不包邮商品 - if(res.data.data[0].goods_list && freight_free){ - if(th.check_by_goods(res.data.data[0].goods_list)){ - freight_free=0; - out_of_weight=0; - th.data.is_no_by[th.data.bn_pick]=1; - } - } - } - }) - } - - th.data.is_by[th.data.bn_pick]=0; - //--------------开始计算物流------------------ - var shipping_price= - th.calculatewuliu(code, o_shipping_price, goods_weight,out_of_weight, - goods_piece, th.data.user_addr, freight_free, allpice-cut_price, rs); - if(shipping_price<=0){ - th.data.is_by[th.data.bn_pick]=1; //已经是包邮了,就不要选择包邮券 + var code = ""; + if (th.data.wu_arr && th.data.wu_arr[th.data.index]) code = th.data.wu_arr[th.data.index].code; + var no_ex_id = ee.no_ex_id; + th.data.is_no_by[th.data.bn_pick] = 0; + var no_by_data = null; + var gift_freight_free = freight_free; + //有不包邮区域,且不免运费 + if (no_ex_id && freight_free > 0 && freight_free <= allpice - cut_price) { + //-----------获取不包邮区域,不包邮商品------- + await getApp().request.promiseGet("/api/weshop/areaFeemail/getAreaGoods", { + data: { store_id: os.stoid, id: no_ex_id } + }).then(res => { + if (res.data.code == 0) { + no_by_data = res.data.data[0]; + //如果有设置不包邮区域的时候 + if (res.data.data[0].region_list) { + if (th.check_by_area(res.data.data[0].region_list)) { + freight_free = 0; + out_of_weight = 0; + weight_free = -1; + th.data.is_no_by[th.data.bn_pick] = 1; + } + } + //如果有设置不包邮商品 + if (res.data.data[0].goods_list && freight_free) { + if (th.check_by_goods(res.data.data[0].goods_list)) { + freight_free = 0; + out_of_weight = 0; + weight_free = -1; + th.data.is_no_by[th.data.bn_pick] = 1; + } + } + } + }) + } + + //--------------开始计算物流------------------ + var shipping_price = + th.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, + goods_piece, th.data.user_addr, freight_free, allpice - cut_price, rs, th.data.bn_pick); + if (shipping_price <= 0) { + th.data.is_by[th.data.bn_pick] = 1; //已经是包邮了,就不要选择包邮券 } shipping_price = parseFloat(shipping_price).toFixed(2); var wl_txt = "formData.shipping_price"; th.setData({ [wl_txt]: shipping_price, }) - - }else{ + + } else { var wl_txt = "formData.shipping_price"; th.setData({ [wl_txt]: 0, }) } //---如果有选择优惠券的情况下--- - var quan_price=0,bn_pick=th.data.bn_pick; - - //-----------------支付价,优惠券不减物流----------------- + var quan_price = 0, bn_pick = th.data.bn_pick; + + //-----------------支付价,优惠券不减物流----------------- var total_m = (parseFloat(allpice)).toFixed(2); - var order_m = (parseFloat(allpice-cut_price)-quan_price).toFixed(2); - var coupon_price=quan_price; //优惠券优惠了多少钱 - if(order_m<0) { - order_m=0;coupon_price=parseFloat(order_m).toFixed(2); + var order_m = (parseFloat(allpice - cut_price) - quan_price).toFixed(2); + var coupon_price = quan_price; //优惠券优惠了多少钱 + if (order_m < 0) { + order_m = 0; coupon_price = parseFloat(order_m).toFixed(2); } - - //--看一下有没有订单优惠-- - total_m= parseFloat( total_m)+ parseFloat( th.data.formData.shipping_price); - order_m = parseFloat(order_m)+ parseFloat( th.data.formData.shipping_price); - var atxt= "formData.total_amount"; - th.setData({ [atxt]: total_m, }) - - var txt = "formData.user_money"; - var txt2 = "formData.order_amount"; - var txt4="formData.integral"; - - var amoney = parseFloat(th.data.userinfo.user_money - th.data.txmon - th.data.userinfo.frozen_money); - //--------------如果使用余额--------------------- - if (th.data.bn_use_money == 1) { - if (amoney> order_m) { - order_m = order_m.toFixed(2); - th.setData({ [txt]: order_m, [txt2]:0,[txt4]:all_integral,show_submit:1 }) - }else{ - order_m =parseFloat(order_m - amoney); - order_m = order_m.toFixed(2); - th.setData({ [txt]: amoney, [txt2]: order_m,[txt4]:all_integral,show_submit:1 }) - } - }else{ - th.setData({ [txt]: 0, [txt2]: order_m,[txt4]:all_integral, show_submit:1 }) - } - + + //--看一下有没有订单优惠--0 + total_m = parseFloat(total_m) + parseFloat(th.data.formData.shipping_price); + order_m = parseFloat(order_m) + parseFloat(th.data.formData.shipping_price); + var atxt = "formData.total_amount"; + th.setData({ [atxt]: total_m, }) + + var txt = "formData.user_money"; + var txt2 = "formData.order_amount"; + var txt4 = "formData.integral"; + + var amoney = parseFloat(th.data.userinfo.user_money - th.data.txmon - th.data.userinfo.frozen_money); + //--------------如果使用余额--------------------- + if (th.data.bn_use_money == 1) { + if (amoney > order_m) { + order_m = order_m.toFixed(2); + th.setData({ [txt]: order_m, [txt2]: 0, [txt4]: all_integral, show_submit: 1 }) + } else { + order_m = parseFloat(order_m - amoney); + order_m = order_m.toFixed(2); + th.setData({ [txt]: amoney, [txt2]: order_m, [txt4]: all_integral, show_submit: 1 }) + } + } else { + th.setData({ [txt]: 0, [txt2]: order_m, [txt4]: all_integral, show_submit: 1 }) + } + wx.hideLoading(); }); @@ -561,104 +561,104 @@ Page({ }, //--------------------提交订单----------------------- - async submitForm(t){ - var sub_value=t; + async submitForm(t) { + var sub_value = t; - if(this.data.is_summit_ing==1) return false; //--提交中退出-- - this.data.is_summit_ing=1; - var th=this,pdata=new Array(); - var ff=true; + if (this.data.is_summit_ing == 1) return false; //--提交中退出-- + this.data.is_summit_ing = 1; + var th = this, pdata = new Array(); + var ff = true; //------------立即购买------------- - if (th.data.is_b_now==1 && th.data.bn_goods.prom_type!=5){ + if (th.data.is_b_now == 1 && th.data.bn_goods.prom_type != 5) { - if(th.data.bn_exp_type == 0 && th.data.user_addr==null ){ - ff = false; getApp().my_warnning("请选择收货地址",0,th); - th.data.is_summit_ing = 0; + if (th.data.bn_exp_type == 0 && th.data.user_addr == null) { + ff = false; getApp().my_warnning("请选择收货地址", 0, th); + th.data.is_summit_ing = 0; } if (!ff) return false; var addr = th.data.user_addr; - if (th.data.bn_exp_type == 1) addr=null; + if (th.data.bn_exp_type == 1) addr = null; - if(th.data.bn_exp_type==0) - if(th.data.wu_arr==null || th.data.wu_arr.length<=0){ - getApp().my_warnning("读取物流失败",0,th); - th.data.is_summit_ing = 0; + if (th.data.bn_exp_type == 0) + if (th.data.wu_arr == null || th.data.wu_arr.length <= 0) { + getApp().my_warnning("读取物流失败", 0, th); + th.data.is_summit_ing = 0; return false; } - - - var integrals=0; - var get_datas= { - user_id:getApp().globalData.user_id, store_id:o.stoid, - }; - await getApp().request.promiseGet("/api/weshop/users/getAllPoints", { - data: get_datas - }).then(res => { - if(res.data.code==0){ - integrals=res.data.data.Integral; - } - }) - - //判断积分的情况 - if(th.data.formData.integral && parseFloat(th.data.formData.integral)< parseFloat(integrals) ){ - getApp().my_warnning("积分不足",0,th); - th.data.is_summit_ing = 0; - return false; - } - - - var item={ + + + var integrals = 0; + var get_datas = { + user_id: getApp().globalData.user_id, store_id: o.stoid, + }; + await getApp().request.promiseGet("/api/weshop/users/getAllPoints", { + data: get_datas + }).then(res => { + if (res.data.code == 0) { + integrals = res.data.data.Integral; + } + }) + + //判断积分的情况 + if (th.data.formData.integral && parseFloat(th.data.formData.integral) < parseFloat(integrals)) { + getApp().my_warnning("积分不足", 0, th); + th.data.is_summit_ing = 0; + return false; + } + + + var item = { 'user_id': to.globalData.user_id, 'consignee': addr == null ? "" : addr.consignee, 'province': addr == null ? 0 : addr.province, 'city': addr == null ? 0 : addr.city, 'district': addr == null ? 0 : addr.district, 'twon': addr == null ? 0 : addr.twon, - 'address': addr == null ? "": addr.address, + 'address': addr == null ? "" : addr.address, 'more_address': addr == null ? "" : addr.more_address, //'mobile': th.data.userinfo.mobile, 'mobile': addr == null ? th.data.userinfo.mobile : addr.mobile, - 'email':'', + 'email': '', 'shipping_code': th.data.bn_exp_type == 1 ? 0 : th.data.wu_arr[th.data.index].code, 'shipping_name': th.data.bn_exp_type == 1 ? '' : th.data.wu_arr[th.data.index].name, - 'invoice_title':'', + 'invoice_title': '', 'goods_price': th.data.formData.all_price, //商品总价 'shipping_price': th.data.formData.shipping_price, //物流金额 'user_money': th.data.formData.user_money, //使用余额 'total_amount': th.data.formData.total_amount, //订单总价 'order_amount': th.data.formData.order_amount, //应付 'user_note': t.detail.value.user_note, //用户备注 - 'store_id':oo.stoid, //商家 + 'store_id': oo.stoid, //商家 'pickup_id': th.data.bn_pick, //门店 'exp_type': th.data.bn_exp_type, //配送方式 - 'order_goods':new Array(), - 'integral': th.data.formData.integral, + 'order_goods': new Array(), + 'integral': th.data.formData.integral, }; //是不是重新提交 - if(th.data.is_continue==1) item.is_continue=1; + if (th.data.is_continue == 1) item.is_continue = 1; //获取立即购买的商品的信息 var gg = to.get_b_now(); //--商品的房间号-- - if(gg.room_id && gg.room_id>0){ - item.room_ids=gg.room_id; + if (gg.room_id && gg.room_id > 0) { + item.room_ids = gg.room_id; + } + + //老会员成为分销下线需要的参数 + if (getApp().globalData.first_leader && !getApp().globalData.userInfo.first_leader) { + //判断一下分享人是不是分享商 + await app.request.promiseGet("/api/weshop/users/get/" + os.stoid + "/" + getApp().globalData.first_leader, {}).then(res => { + if (res.data.code == 0) { + var user = res.data.data; + if (user.is_distribut == 1) { + item.first_leader = parseInt(getApp().globalData.first_leader); + } + } + }) } - - //老会员成为分销下线需要的参数 - if(getApp().globalData.first_leader && !getApp().globalData.userInfo.first_leader){ - //判断一下分享人是不是分享商 - await app.request.promiseGet("/api/weshop/users/get/" + os.stoid+"/"+getApp().globalData.first_leader,{}).then(res=>{ - if(res.data.code==0){ - var user= res.data.data; - if(user.is_distribut==1){ - item.first_leader=parseInt(getApp().globalData.first_leader); - } - } - }) - } - - - var goods={ + + + var goods = { 'goods_id': gg.goods_id, 'goods_name': gg.goods_name, 'goods_sn': gg.goods_sn, @@ -667,37 +667,37 @@ Page({ 'goods_price': th.data.bn_goods.shop_price, 'member_goods_price': th.data.bn_goods.shop_price, 'store_id': oo.stoid, - 'prom_type':th.data.bn_goods.prom_type, //促销活动类型 + 'prom_type': th.data.bn_goods.prom_type, //促销活动类型 'prom_id': th.data.bn_goods.prom_id, //促销活动id }; //-- 把导购的信息填入-- - if(gg.guide_id){ - goods.guide_id=gg.guide_id; - goods.guide_type=gg.guide_type; - //调用接口判断是不是会员 - await getApp().request.promiseGet("/api/weshop/shoppingGuide/getId/"+oo.stoid+"/"+gg.guide_id,{}).then(res=>{ - if(res.data.code==0){ - goods.guide_name=res.data.data.salesman; - goods.guide_sn=res.data.data.salesman_no; - } - }) + if (gg.guide_id) { + goods.guide_id = gg.guide_id; + goods.guide_type = gg.guide_type; + //调用接口判断是不是会员 + await getApp().request.promiseGet("/api/weshop/shoppingGuide/getId/" + oo.stoid + "/" + gg.guide_id, {}).then(res => { + if (res.data.code == 0) { + goods.guide_name = res.data.data.salesman; + goods.guide_sn = res.data.data.salesman_no; + } + }) } //--商品的房间号-- - if(gg.room_id && gg.room_id>0){ - goods.room_id=gg.room_id; + if (gg.room_id && gg.room_id > 0) { + goods.room_id = gg.room_id; } - + item.order_goods.push(goods); - pdata.push(item); + pdata.push(item); } - - if (pdata.length==0) return; + + if (pdata.length == 0) return; var str = JSON.stringify(pdata); - - wx.showLoading({title: "加载中"}); + + wx.showLoading({ title: "加载中" }); wx.request({ url: oo.url + '/api/weshop/order/createWxdOrder', data: str, @@ -707,11 +707,11 @@ Page({ },// 设置请求的 header success: function (res) { - th.data.is_summit_ing=0; //是否提交中 + th.data.is_summit_ing = 0; //是否提交中 wx.hideLoading(); if (res.statusCode == 200) { - var data=res.data; - if(data.code==0){ + var data = res.data; + if (data.code == 0) { console.log(th.data.is_b_now); //如果是购物车结算,还要删除购物车 if (th.data.is_b_now == 0) { @@ -732,20 +732,20 @@ Page({ //void e.jumpToCart4({ // order_sn: data.data, //}, 1); - util_pay.pay(data.data, function() { - //app.my_warnning("支付成功",1,th); - //setTimeout(function () { - wx.redirectTo({ - url: "/pages/payment/pay_success/pay_success?type=2&order_sn="+data.data - }) - //},1000) - - }, function () { - //支付失败 - setTimeout(function () { - wx.navigateBack({ delta: 1 }) - },1000) - },oo.stoid); + util_pay.pay(data.data, function () { + //app.my_warnning("支付成功",1,th); + //setTimeout(function () { + wx.redirectTo({ + url: "/pages/payment/pay_success/pay_success?type=2&order_sn=" + data.data + }) + //},1000) + + }, function () { + //支付失败 + setTimeout(function () { + wx.navigateBack({ delta: 1 }) + }, 1000) + }, oo.stoid); } else { var dd = { @@ -757,110 +757,110 @@ Page({ data: dd, success: function (t) { //console.log(t); - if(t.data.code==0){ - //app.my_warnning("支付成功",1,th); - //setTimeout(function () { - th.setData({ isclose: 0 }); - wx.redirectTo({ - url: "/pages/payment/pay_success/pay_success?type=2&order_sn="+data.data, - }) - //}, 1000) + if (t.data.code == 0) { + //app.my_warnning("支付成功",1,th); + //setTimeout(function () { + th.setData({ isclose: 0 }); + wx.redirectTo({ + url: "/pages/payment/pay_success/pay_success?type=2&order_sn=" + data.data, + }) + //}, 1000) } }, - fail:function () { + fail: function () { } }); } } - else{ - //--内容换行-- - var msg=data.msg; - //赠品活动已经取消,无法赠送,是否继续买单? - if(msg.indexOf("是否继续买单")>0){ - wx.showModal({ - title:"提示", - content: data.msg, - cancelText:'取消', - confirmText:'确定', - showCancel: true, - success(res){ - if(res.cancel){ - return; - }else if(res.confirm){ - th.data.is_continue=1; - th.submitForm(sub_value); - } - } - }) - return; - } - if(msg.length>13){ - msg=msg.slice(0, 13) + "\r\n"+ msg.slice(13); - } - getApp().confirmBox(msg); - } - }else{ - console.log("index.js wx.request CheckCallUser statusCode" + res.statusCode); + else { + //--内容换行-- + var msg = data.msg; + //赠品活动已经取消,无法赠送,是否继续买单? + if (msg.indexOf("是否继续买单") > 0) { + wx.showModal({ + title: "提示", + content: data.msg, + cancelText: '取消', + confirmText: '确定', + showCancel: true, + success(res) { + if (res.cancel) { + return; + } else if (res.confirm) { + th.data.is_continue = 1; + th.submitForm(sub_value); + } + } + }) + return; + } + if (msg.length > 13) { + msg = msg.slice(0, 13) + "\r\n" + msg.slice(13); + } + getApp().confirmBox(msg); + } + } else { + console.log("index.js wx.request CheckCallUser statusCode" + res.statusCode); } }, fail: function () { - th.data.is_summit_ing=0; + th.data.is_summit_ing = 0; wx.hideLoading(); console.log("index.js wx.request CheckCallUser fail"); }, - complete: function () {} + complete: function () { } }) }, - + //---确认线下门店的数量足不足--- - async check_store_num(goods_id,pick,goods_num,func){ - var lock=0,pick_no,plist,erpwareid; - //先读取门店的lock - await getApp().request.promiseGet("/api/weshop/order/ware/lock/page",{ - data:{store_id:os.stoid,wareId:goods_id,storageId:pick,pageSize:1000} - }).then(res=>{ - if(res.data.code==0 && res.data.data.total>0){ - for(var i in res.data.data.pageData) - lock+=res.data.data.pageData[i].outQty; - } - }) - //先获取门店的编号 - await getApp().request.promiseGet("/api/weshop/pickup/get/"+os.stoid+"/"+pick,{ - data:{storeId:os.stoid,goodsId:t.goods_id,pickupId:pick} - }).then(res=>{ - if(res.data.code==0){ - pick_no=res.data.data.pickup_no; - } - }) - //先获取商品的线下库存 - await getApp().request.promiseGet("/api/weshop/goods/get/"+os.stoid+"/"+goods_id,{ - data:{storeId:os.stoid,goodsId:t.goods_id,pickupId:pick} - }).then(res=>{ - if(res.data.code==0){ - erpwareid=res.data.data.erpwareid; - } - }) - //读取线下的门店库存 - await getApp().request.promiseGet("/api/weshop/goods/getWareStorages",{ - data:{storageNos:pick_no,wareIds:encodeURIComponent(erpwareid),storeId:os.stoid} - }).then(res=>{ - if(res.data.code==0 && res.data.data && res.data.data.pageData && res.data.data.pageData.length){ - plist=res.data.data.pageData[0]; - } - }) - var isok=1; - if(goods_num>plist.CanOutQty-lock){ - isok=0; - } - func(isok); + async check_store_num(goods_id, pick, goods_num, func) { + var lock = 0, pick_no, plist, erpwareid; + //先读取门店的lock + await getApp().request.promiseGet("/api/weshop/order/ware/lock/page", { + data: { store_id: os.stoid, wareId: goods_id, storageId: pick, pageSize: 1000 } + }).then(res => { + if (res.data.code == 0 && res.data.data.total > 0) { + for (var i in res.data.data.pageData) + lock += res.data.data.pageData[i].outQty; + } + }) + //先获取门店的编号 + await getApp().request.promiseGet("/api/weshop/pickup/get/" + os.stoid + "/" + pick, { + data: { storeId: os.stoid, goodsId: t.goods_id, pickupId: pick } + }).then(res => { + if (res.data.code == 0) { + pick_no = res.data.data.pickup_no; + } + }) + //先获取商品的线下库存 + await getApp().request.promiseGet("/api/weshop/goods/get/" + os.stoid + "/" + goods_id, { + data: { storeId: os.stoid, goodsId: t.goods_id, pickupId: pick } + }).then(res => { + if (res.data.code == 0) { + erpwareid = res.data.data.erpwareid; + } + }) + //读取线下的门店库存 + await getApp().request.promiseGet("/api/weshop/goods/getWareStorages", { + data: { storageNos: pick_no, wareIds: encodeURIComponent(erpwareid), storeId: os.stoid } + }).then(res => { + if (res.data.code == 0 && res.data.data && res.data.data.pageData && res.data.data.pageData.length) { + plist = res.data.data.pageData[0]; + } + }) + var isok = 1; + if (goods_num > plist.CanOutQty - lock) { + isok = 0; + } + func(isok); }, - useCoupon: function() { + useCoupon: function () { if (this.data.order.couponNum <= 0) { - getApp().my_warnning("无可用优惠券",0,this); + getApp().my_warnning("无可用优惠券", 0, this); return; } @@ -871,97 +871,97 @@ Page({ url: "/pages/user/checkcoupon/checkcoupon?" + s.Obj2Str(a) }); }, - enterAddressPage: function() { - getApp().globalData.is_cart_old=1; - this.data.isget_by_quan={}; + enterAddressPage: function () { + getApp().globalData.is_cart_old = 1; + this.data.isget_by_quan = {}; this.data.enterAddressPage = !0, wx.navigateTo({ url: "/pages/user/address_list/address_list" }); }, - + //--------立即购买时,选择自提和物流---------- - setexptype:function(t){ - var th=this; - var ty = t.currentTarget.dataset.t,def_exp_code= getApp().globalData.userInfo.def_exp_code; - th.setData({ bn_exp_type:ty}); + setexptype: function (t) { + var th = this; + var ty = t.currentTarget.dataset.t, def_exp_code = getApp().globalData.userInfo.def_exp_code; + th.setData({ bn_exp_type: ty }); //当物流为空的时候。 - if (ty == 0 && th.data.wu_arr==null){ - th.data.isget_by_quan={}; + if (ty == 0 && th.data.wu_arr == null) { + th.data.isget_by_quan = {}; return th.get_wuliu(th.calculatePrice2()); } //--自提就要把包邮券清理掉-- - if(ty==1){ - th.data.isget_by_quan={}; - if(th.data.using_quan && th.data.using_quan[th.data.bn_pick] && th.data.using_quan[th.data.bn_pick].isby==1){ - th.setData({using_quan:{}}); + if (ty == 1) { + th.data.isget_by_quan = {}; + if (th.data.using_quan && th.data.using_quan[th.data.bn_pick] && th.data.using_quan[th.data.bn_pick].isby == 1) { + th.setData({ using_quan: {} }); } } - //判断有没有默认的物流地址值 - if (def_exp_code != "" && def_exp_code != null && def_exp_code !=undefined) { - var wu_arr=this.data.wu_arr; - if (wu_arr!= null && wu_arr!=""){ - for(var i=0;i 0 && o_price >= freight_free && out_of_weight>=0){ return 0;} - if (user_addr==null) { return 0; } + if (freight_free > 0 && o_price >= freight_free && out_of_weight >= 0) { return 0; } + if (user_addr == null) { return 0; } //计算物流的config item; - var item=null; + var item = null; //先根据 镇 县 区找计算的config - item = th.get_wuliu_config(user_addr.district,code,rs); - if (item==null) item = th.get_wuliu_config(user_addr.city, code, rs); - if (item==null) item = th.get_wuliu_config(user_addr.province, code, rs); - if (item == null) item = th.get_wuliu_default(code,rs); + item = th.get_wuliu_config(user_addr.district, code, rs); + if (item == null) item = th.get_wuliu_config(user_addr.city, code, rs); + if (item == null) item = th.get_wuliu_config(user_addr.province, code, rs); + if (item == null) item = th.get_wuliu_default(code, rs); + if (item == null) return o_shipping_price; + var fw_price = 0, fp_price = 0; + item = item.config; if (item == null) return o_shipping_price; - var fw_price = 0, fp_price=0; - item=item.config; - if (item == null) return o_shipping_price; //------按重量---------- if (goods_weight >= 0 && item['money']) { - fw_price =parseFloat(item['money']); - if (goods_weight > item['first_weight']){ + fw_price = parseFloat(item['money']); + if (goods_weight > item['first_weight']) { var fw = goods_weight - item['first_weight']; - var n = Math.ceil(fw/item['second_weight']) + var n = Math.ceil(fw / item['second_weight']) fw_price = fw_price + n * parseFloat(item['add_money']); } } - //------超出重量---------- - if(out_of_weight < 0 && o_price >= freight_free){ + //------超出重量---------- + if (out_of_weight < 0 && o_price >= freight_free && !th.data.is_no_by[pickid]) { fw_price = parseFloat(item['money']); var out_of_weight = Math.abs(out_of_weight); if (out_of_weight > item['first_weight']) { - var fw = out_of_weight - item['first_weight']; - var n = Math.ceil(fw / item['second_weight']) - fw_price = fw_price + n * parseFloat(item['add_money']); + var fw = out_of_weight - item['first_weight']; + var n = Math.ceil(fw / item['second_weight']) + fw_price = fw_price + n * parseFloat(item['add_money']); } } //------按件数---------- @@ -973,21 +973,21 @@ Page({ fp_price = fp_price + m * parseFloat(item['add_piecemoney']); } } - var rspice =parseFloat(price + fw_price + fp_price); + var rspice = parseFloat(price + fw_price + fp_price); return rspice; }, //------------循环获取config----------- - get_wuliu_config:function(region_id,code,rs){ - var item=null,rslist = rs.pageData; - for (var i = 0; i < rslist.length;i++){ - if (rslist[i].code == code && rslist[i].region_id == region_id) { item = rslist[i];} + get_wuliu_config: function (region_id, code, rs) { + var item = null, rslist = rs.pageData; + for (var i = 0; i < rslist.length; i++) { + if (rslist[i].code == code && rslist[i].region_id == region_id) { item = rslist[i]; } } return item; }, //-------循环获取config,code default------- get_wuliu_default: function (code, rs) { - var item = null, rslist=rs.pageData; + var item = null, rslist = rs.pageData; for (var i = 0; i < rslist.length; i++) { if (rslist[i].shipping_code == code && rslist[i].is_default == 1) { item = rslist[i]; } } @@ -995,141 +995,140 @@ Page({ }, //----------立即购买,选择物流------------- - bindPickerChange:function(e){ + bindPickerChange: function (e) { var ind = e.detail.value this.setData({ index: ind }); this.calculatePrice2(); }, //----------购物车结算,选择物流------------- bindPickerChange_w: function (e) { - var ind=e.detail.value, txt = e.currentTarget.dataset.txt; + var ind = e.detail.value, txt = e.currentTarget.dataset.txt; this.setData({ [txt]: ind }); this.calculatePrice(); }, - cart_set_err:function(e){ - var txt = e.currentTarget.dataset.err; - var ob={}; - ob[txt] = this.data.imgUrl + "/miniapp/images/default_g_img.gif"; - this.setData(ob); + cart_set_err: function (e) { + var txt = e.currentTarget.dataset.err; + var ob = {}; + ob[txt] = this.data.imgUrl + "/miniapp/images/default_g_img.gif"; + this.setData(ob); }, - + //// 开启物流的弹窗 - show_wu_arr:function(e){ - var wu_arr_txt=e.currentTarget.dataset.txt; - var w_sele_index=e.currentTarget.dataset.w_sele_index; - var is_express=null; - var ob={open_express: 1,wu_arr_txt:wu_arr_txt,disabled:1}; + show_wu_arr: function (e) { + var wu_arr_txt = e.currentTarget.dataset.txt; + var w_sele_index = e.currentTarget.dataset.w_sele_index; + var is_express = null; + var ob = { open_express: 1, wu_arr_txt: wu_arr_txt, disabled: 1 }; //--如果是多个门店的时候-- - if(w_sele_index!=undefined){ - is_express=this.data.cartlist[w_sele_index].wind; - ob['is_express']=is_express; + if (w_sele_index != undefined) { + is_express = this.data.cartlist[w_sele_index].wind; + ob['is_express'] = is_express; } this.setData(ob); }, - // 关闭物流的弹窗 - close_express:function(){ - this.setData({ open_express:0,disabled:0 }); + // 关闭物流的弹窗 + close_express: function () { + this.setData({ open_express: 0, disabled: 0 }); + }, + // 选择物流 + click_express_name: function (e) { + var express_name = e.currentTarget.dataset.name, shippingcode = e.currentTarget.dataset.shippingcode; + var index = e.currentTarget.dataset.idxe; + var ob = { is_express: index, is_shipping_code: shippingcode, disabled: 0 }; + ob[this.data.wu_arr_txt] = index; + this.setData(ob); }, - // 选择物流 - click_express_name:function(e){ - var express_name = e.currentTarget.dataset.name, shippingcode = e.currentTarget.dataset.shippingcode; - var index=e.currentTarget.dataset.idxe; - var ob={ is_express: index, is_shipping_code: shippingcode,disabled:0}; - ob[this.data.wu_arr_txt]=index; - this.setData(ob); - }, - //点击确定物流 - determine_expres:function(e){ - this.setData({ open_express: 0}); - this.calculatePrice2(); + //点击确定物流 + determine_expres: function (e) { + this.setData({ open_express: 0 }); + this.calculatePrice2(); }, - + //设置默认物流 select_default_logistics: function () { - var th=this; - var is_shipping_code=this.data.is_shipping_code - getApp().request.put("/api/weshop/users/update",{ - data: { user_id: getApp().globalData.user_id, store_id: oo.stoid, def_exp_code: is_shipping_code}, - success:function(rse){ - if (rse.data.code==0){ - getApp().globalData.userInfo.def_exp_code=is_shipping_code; + var th = this; + var is_shipping_code = this.data.is_shipping_code + getApp().request.put("/api/weshop/users/update", { + data: { user_id: getApp().globalData.user_id, store_id: oo.stoid, def_exp_code: is_shipping_code }, + success: function (rse) { + if (rse.data.code == 0) { + getApp().globalData.userInfo.def_exp_code = is_shipping_code; th.setData({ open_express: 0 }); //----计算此时购物车的价格,这个页面没有calculatePrice(),2021.7.19-------- //if(th.data.is_b_now==1) th.calculatePrice2(); //else th.calculatePrice(); th.calculatePrice2(); - } + } } }) }, //更新下默认,在onshow里面 - update_code(){ - var th=this,m_wind=0,def_exp_code=getApp().globalData.userInfo.def_exp_code; - //--定时器,判断wu_arr不未空-- - var uii=setInterval(function () { - if(th.data.wu_arr) - { - clearInterval(uii); - for (var k = 0; k < th.data.wu_arr.length; k++) { - var item = th.data.wu_arr[k]; - if (def_exp_code == item.code) { m_wind = k; } - } - //--如果是立即购买-- - th.setData({index: m_wind,is_express:m_wind}); - - } - },500); + update_code() { + var th = this, m_wind = 0, def_exp_code = getApp().globalData.userInfo.def_exp_code; + //--定时器,判断wu_arr不未空-- + var uii = setInterval(function () { + if (th.data.wu_arr) { + clearInterval(uii); + for (var k = 0; k < th.data.wu_arr.length; k++) { + var item = th.data.wu_arr[k]; + if (def_exp_code == item.code) { m_wind = k; } + } + //--如果是立即购买-- + th.setData({ index: m_wind, is_express: m_wind }); + + } + }, 500); }, - + //检查区域是不是包邮 - check_area:function(arr){ - var user_addr=this.data.user_addr; - for(var i in arr){ - var item=arr[i]; - if(user_addr.twon==item || user_addr.district==item - || user_addr.city==item|| user_addr.province==item ){ - return 0; - } - } - return 1; + check_area: function (arr) { + var user_addr = this.data.user_addr; + for (var i in arr) { + var item = arr[i]; + if (user_addr.twon == item || user_addr.district == item + || user_addr.city == item || user_addr.province == item) { + return 0; + } + } + return 1; }, - + //检查立即购买的商品是不是不包邮 - check_good:function(arr,goods_id){ - if(!goods_id) goods_id=this.data.bn_goods.goods_id; - for(var i in arr){ - var item=arr[i]; - if(goods_id==item) return 0; - } - return 1; + check_good: function (arr, goods_id) { + if (!goods_id) goods_id = this.data.bn_goods.goods_id; + for (var i in arr) { + var item = arr[i]; + if (goods_id == item) return 0; + } + return 1; }, - check_by_area:function(region_list){ - var arr=region_list.split(","); - var check=this.check_area(arr); - return !check; + check_by_area: function (region_list) { + var arr = region_list.split(","); + var check = this.check_area(arr); + return !check; }, - check_by_goods:function(goods_list,goods_id){ - var arr=goods_list.split(","); - var check=this.check_good(arr,goods_id); - return !check; + check_by_goods: function (goods_list, goods_id) { + var arr = goods_list.split(","); + var check = this.check_good(arr, goods_id); + return !check; }, - - //从优惠的映射中拿出商品从表的item - arr_get_goods:function(goods_id,arr){ - for(var i in arr){ - if(arr[i].goods_id==goods_id) return arr[i]; - } - }, - - //跳转到购买卡 - buycard:function(){ - getApp().goto("/pages/user/plus/plus"); - getApp().globalData.plus_buy_back=1; - } + + //从优惠的映射中拿出商品从表的item + arr_get_goods: function (goods_id, arr) { + for (var i in arr) { + if (arr[i].goods_id == goods_id) return arr[i]; + } + }, + + //跳转到购买卡 + buycard: function () { + getApp().goto("/pages/user/plus/plus"); + getApp().globalData.plus_buy_back = 1; + } }); diff --git a/pages/cart/cart2_pt/cart2_pt.js b/pages/cart/cart2_pt/cart2_pt.js index a7b4506..fd3f517 100644 --- a/pages/cart/cart2_pt/cart2_pt.js +++ b/pages/cart/cart2_pt/cart2_pt.js @@ -1,868 +1,866 @@ -var t = getApp(),app=t, a = t.request, e = require("../../../utils/common.js"), +var t = getApp(), app = t, a = t.request, e = require("../../../utils/common.js"), s = require("../../../utils/util.js"), o = require("../../../utils/md5.js"), to = getApp(); -var oo=t.globalData.setting,os=oo; +var oo = t.globalData.setting, os = oo; var regeneratorRuntime = require('../../../utils/runtime.js'); var util_pay = require("../../../utils/pay.js"); Page({ - data: { - url: t.globalData.setting.url, - resourceUrl: t.globalData.setting.resourceUrl, - imgUrl: t.globalData.setting.imghost, - goods: null, - order: null, - orderPrices: null, - coupons: null, - coupon: null, - invoiceToggle: !0, - payWithUserMoney: !0, - payWithPoints: !0, - maxWord: 0, - enterAddressPage: !1, - firstEnter: !0, - //页面获取的参数 - param:null, - postdata:null, - //提交订单的格式 - formData: { - order_amount:0,//支付金额 - total_amount:0,//总价 - all_price:0,//商品卖的总价 - pay_points: 0,//使用积分 - user_money: 0,//使用余额 - couponCode: "",//使用优惠券(多单就用逗号隔开) - shipping_price:0,//物流费用 - }, - - /*----------------立即购买---------------------*/ - is_b_now:0, //0是购物车结算 1立即购买 - bn_goods:null, //立即购买时候的调用商品 - bn_use_money:0,//是否使用余额 - bn_exp_type:1, //0是物流 1自提 - bn_pick:0, //选择的门店 - bn_pickname: "", //选择的门店名称 - bn_t_exp_t:0, //判断商品和门店一起决定的物流自提的方式0 都可以 1自提 2物流 - /*------------------------*/ - user_addr:null,//物流 - userinfo:null, //获取会员 - /*----------物流选择--------*/ - wu_arr:null, - index:0, - - //判断页面是返回回来的还是 首次进入的 - isclose:1, - kt_type:0, //开团类型 - is_pt_tz:0,//是否开团团长 - qh:'', //期号 - pt_listno:'',//期号 - is_normal:0, - is_express:0,//选择物流的控制器 - yuer:0, - - rank_switch:0, //是不是开同等级卡 - show_card:null, //显示的等级卡 - card_name:'', //显示的卡的名称 - card_cut_price:null,//减价多少钱 + data: { + url: t.globalData.setting.url, + resourceUrl: t.globalData.setting.resourceUrl, + imgUrl: t.globalData.setting.imghost, + goods: null, + order: null, + orderPrices: null, + coupons: null, + coupon: null, + invoiceToggle: !0, + payWithUserMoney: !0, + payWithPoints: !0, + maxWord: 0, + enterAddressPage: !1, + firstEnter: !0, + //页面获取的参数 + param: null, + postdata: null, + //提交订单的格式 + formData: { + order_amount: 0,//支付金额 + total_amount: 0,//总价 + all_price: 0,//商品卖的总价 + pay_points: 0,//使用积分 + user_money: 0,//使用余额 + couponCode: "",//使用优惠券(多单就用逗号隔开) + shipping_price: 0,//物流费用 }, - onLoad: function(t) { - console.log("onLoad_pt_cart"); - var th = this; this.setData({ is_b_now: t.is_bnow == undefined ? 0 : t.is_bnow,}); - var appD=getApp().get_b_now(); - - th.data.postdata=appD; - //如果期号有值 - if(appD.qh){ - th.data.qh=appD.qh; - th.data.pt_listno=appD.qh; - } - //th.data.kt_type=appD.kt_type; - th.setData({kt_type:appD.kt_type}); - if(appD.is_pt_tz) th.data.is_pt_tz=appD.is_pt_tz; - th.data.param=t; - //先获取物流,再获取用户信息,再展示页面 - //th.get_wuliu(th.get_info(th.show_page)); - }, - onUnload: function () { this.setData({ isclose: 1 })}, - //------获取会员信息-----先获取用户信息,在进行下一步--- - get_info:function(func){ - var user_id = t.globalData.user_id; - to.auth.get_u(func); - }, + /*----------------立即购买---------------------*/ + is_b_now: 0, //0是购物车结算 1立即购买 + bn_goods: null, //立即购买时候的调用商品 + bn_use_money: 0,//是否使用余额 + bn_exp_type: 1, //0是物流 1自提 + bn_pick: 0, //选择的门店 + bn_pickname: "", //选择的门店名称 + bn_t_exp_t: 0, //判断商品和门店一起决定的物流自提的方式0 都可以 1自提 2物流 + /*------------------------*/ + user_addr: null,//物流 + userinfo: null, //获取会员 + /*----------物流选择--------*/ + wu_arr: null, + index: 0, + + //判断页面是返回回来的还是 首次进入的 + isclose: 1, + kt_type: 0, //开团类型 + is_pt_tz: 0,//是否开团团长 + qh: '', //期号 + pt_listno: '',//期号 + is_normal: 0, + is_express: 0,//选择物流的控制器 + yuer: 0, + + rank_switch: 0, //是不是开同等级卡 + show_card: null, //显示的等级卡 + card_name: '', //显示的卡的名称 + card_cut_price: null,//减价多少钱 + }, + onLoad: function (t) { + console.log("onLoad_pt_cart"); + var th = this; this.setData({ is_b_now: t.is_bnow == undefined ? 0 : t.is_bnow, }); + var appD = getApp().get_b_now(); + + th.data.postdata = appD; + //如果期号有值 + if (appD.qh) { + th.data.qh = appD.qh; + th.data.pt_listno = appD.qh; + } + //th.data.kt_type=appD.kt_type; + th.setData({ kt_type: appD.kt_type }); + if (appD.is_pt_tz) th.data.is_pt_tz = appD.is_pt_tz; + th.data.param = t; + //先获取物流,再获取用户信息,再展示页面 + //th.get_wuliu(th.get_info(th.show_page)); + }, + onUnload: function () { this.setData({ isclose: 1 }) }, - //-------------------获取物流--------------- - get_wuliu(func) { - var th = this; - console.log("getwuliu4545"); - to.getwuliu(function (e) { - if (th.data.is_default_logistics) { - //如果第一个不是开启默认,说明要让用户自己选 - if (!e[0].is_default) { - th.setData({ is_default_logistics: 0 }); - } + //------获取会员信息-----先获取用户信息,在进行下一步--- + get_info: function (func) { + var user_id = t.globalData.user_id; + to.auth.get_u(func); + }, + + //-------------------获取物流--------------- + get_wuliu(func) { + var th = this; + console.log("getwuliu4545"); + to.getwuliu(function (e) { + if (th.data.is_default_logistics) { + //如果第一个不是开启默认,说明要让用户自己选 + if (!e[0].is_default) { + th.setData({ is_default_logistics: 0 }); } - th.setData({ wu_arr: e }) - typeof func == "function" && func(); - }) - }, + } + th.setData({ wu_arr: e }) + typeof func == "function" && func(); + }) + }, - //------获取会员收货地址----- - getuser_addr:function(func){ - if (to.globalData.baddr!=null){ - var user_addr = to.globalData.baddr; - to.globalData.baddr=null; - func(user_addr); - }else{ - a.get("/api/weshop/useraddress/page", { - data: { user_id: to.globalData.user_id, store_id: oo.stoid, pageSize: 600 }, + //------获取会员收货地址----- + getuser_addr: function (func) { + if (to.globalData.baddr != null) { + var user_addr = to.globalData.baddr; + to.globalData.baddr = null; + func(user_addr); + } else { + a.get("/api/weshop/useraddress/page", { + data: { user_id: to.globalData.user_id, store_id: oo.stoid, pageSize: 600 }, + success: function (su) { + + var user_addr = su.data.data.pageData; + var item = null; + var def_item = null; + for (var i = 0; i < user_addr.length; i++) { + if (user_addr[i]['is_default'] == 1) { def_item = user_addr[i]; } + if (user_addr[i]['is_pickup'] == 1) { item = user_addr[i]; } + } + if (item == null) item = def_item; + if (item == null) item = user_addr[0]; + if (item == undefined) item = null; + func(item); + } + }); + } + }, + //----------------展示页面,是再获取用户信息之后-------------- + show_page: function () { + var th = this; + //th.setData({ userinfo: to.globalData.userInfo}); 会员信息要时时获取 + var user = getApp().globalData.userInfo; + getApp().request.get("/api/weshop/users/get/" + oo.stoid + "/" + user.user_id, { + data: { r: Math.random() }, + success: function (e) { + + getApp().globalData.userInfo = e.data.data; + th.setData({ userinfo: e.data.data }); + //获取立即购买的商品信息 + th.get_buy_goods(); + + //获取提现金额 + getApp().request.get("/api/weshop/withdrawals/summoney", { + data: { user_id: to.globalData.user_id, store_id: oo.stoid, status: 0 }, success: function (su) { - - var user_addr = su.data.data.pageData; - var item = null; - var def_item=null; - for (var i = 0; i < user_addr.length; i++) { - if (user_addr[i]['is_default'] == 1) { def_item = user_addr[i]; } - if (user_addr[i]['is_pickup'] == 1) { item = user_addr[i]; } + if (su.data.code == 0) { + var yuer = parseFloat(th.data.userinfo.user_money - + (th.data.userinfo.frozen_money > 0 ? th.data.userinfo.frozen_money : 0) - su.data.data.summoney).toFixed(2); + if (yuer < 0) yuer = 0; + th.setData({ txmon: su.data.data.summoney, yuer: yuer }); } - if (item == null) item = def_item; - if (item == null) item = user_addr[0]; - if (item == undefined) item = null; - func(item); } }); } - }, - //----------------展示页面,是再获取用户信息之后-------------- - show_page:function(){ - var th=this; - //th.setData({ userinfo: to.globalData.userInfo}); 会员信息要时时获取 - var user=getApp().globalData.userInfo; - getApp().request.get("/api/weshop/users/get/" + oo.stoid + "/" + user.user_id, { - data:{r:Math.random()}, - success: function (e) { - - getApp().globalData.userInfo = e.data.data; - th.setData({userinfo:e.data.data}); - //获取立即购买的商品信息 - th.get_buy_goods(); - - //获取提现金额 - getApp().request.get("/api/weshop/withdrawals/summoney", { - data: { user_id: to.globalData.user_id, store_id: oo.stoid, status: 0 }, - success: function (su) { - if (su.data.code == 0) { - var yuer = parseFloat(th.data.userinfo.user_money - - (th.data.userinfo.frozen_money>0?th.data.userinfo.frozen_money:0) - su.data.data.summoney).toFixed(2); - if(yuer<0) yuer=0; - th.setData({ txmon: su.data.data.summoney, yuer: yuer }); - } - } - }); - } - }); - }, + }); + }, - //-----获取立即购买的商品信息---- - get_buy_goods: function (){ - var th=this,a=getApp().request; - var gg = th.data.postdata; - //调用商品 - a.get("/api/weshop/goods/get/" + oo.stoid+"/"+gg.goods_id, { - success: function (t) { - var gd = t.data.data; - if(!gd) return false; - - t.data.data.original_img = oo.imghost + t.data.data.original_img; - t.data.data['buynum'] = gg.goods_num; - console.log(t.data.data); - var distr_t = 0, et = 0 - if (t.data.data.distr_type == 0) { - distr_t = gg.pick_dis; - } else { - distr_t = t.data.data.distr_type; - } - switch (distr_t) { - case 0: - et = 1; - //-- 系统后台有设置要默认的 -- - if(th.data.json_d.pickupway && th.data.json_d.pickupway==1) et=0; - break; - case 1: - et = 1; - break; - case 2: - et = 0; - break; - } - - t.data.data.shop_price=gg.goods_price; - //--如果是普通购买的时候-- - if(gg.is_normal==1){ - t.data.data.prom_id = 0; - t.data.data.prom_type = 0; - t.data.data.is_normal=1; - - var gd=t.data.data; - //-- 用商品的手店价来显示 -- - gg.goods_price=gd.shop_price; - //---是不是购买等级卡成功的返回---等级卡显示的判断--- - var is_card_back=getApp().globalData.is_card_back; - if(is_card_back){ - gg.goods_price=gd[th.data.card_name]; - t.data.data.shop_price=gg.goods_price; - getApp().globalData.is_card_back=0; - th.setData({card_cut_price:0}); - }else{ - //--- 商品不能是搭配购,商家等级卡开通的情况下, 会员不是等级会员的情况, 商品有设置等级卡价格,同时等级卡价格小于商品的价格 - if(th.data.card_name && gd[th.data.card_name]>0 && gg.goods_price>gd[th.data.card_name] && !th.data.userinfo.card_field){ - var cut_p= gg.goods_price-gd[th.data.card_name]; - th.setData({card_cut_price:cut_p}); - } - } - - if(th.data.bn_goods){ - et=th.data.bn_exp_type; - } - - - th.setData({ - bn_goods: t.data.data, bn_pickname: gg.pick_name, - bn_pick: gg.pick_id, bn_t_exp_t: distr_t, is_normal:1,bn_exp_type:et - }); - - - - th.calculatePrice2(); - }else{ - - //--阶梯团很特殊,不能用总表来拿价格-- - getApp().request.get("/api/weshop/teamlist/get/"+oo.stoid+"/"+gd.prom_id, { - success: function (tt) { - - if (tt.data.code == 0) { - var pt_data=tt.data.data; - var now=s.gettimestamp(); - - if(pt_data.is_end==1){ - t.data.data.prom_id = 0; - t.data.data.prom_type = 0; - t.data.data.is_normal=1; - }else if(now>pt_data.end_time){ - t.data.data.prom_id = 0; - t.data.data.prom_type = 0; - t.data.data.is_normal=1; - }else{ - t.data.data.shop_price = tt.data.data.price; //活动价格 - t.data.data.is_normal=0; - if(pt_data.kttype==3){ - t.data.data.shop_price = tt.data.data.yf_price; //用定金来购买 - } - } - } else { - t.data.data.prom_id = 0; - t.data.data.prom_type = 0; - t.data.data.is_normal=1; - } - - if(th.data.bn_goods){ - et=th.data.bn_exp_type; - } - - th.setData({ - bn_goods: t.data.data, bn_pickname: gg.pick_name, - bn_pick: gg.pick_id, bn_t_exp_t: distr_t,bn_exp_type:et - }); - - - //计算价格 - th.calculatePrice2(); - } - }); - } - } - }); - }, + //-----获取立即购买的商品信息---- + get_buy_goods: function () { + var th = this, a = getApp().request; + var gg = th.data.postdata; + //调用商品 + a.get("/api/weshop/goods/get/" + oo.stoid + "/" + gg.goods_id, { + success: function (t) { + var gd = t.data.data; + if (!gd) return false; + + t.data.data.original_img = oo.imghost + t.data.data.original_img; + t.data.data['buynum'] = gg.goods_num; + console.log(t.data.data); + var distr_t = 0, et = 0 + if (t.data.data.distr_type == 0) { + distr_t = gg.pick_dis; + } else { + distr_t = t.data.data.distr_type; + } + switch (distr_t) { + case 0: + et = 1; + //-- 系统后台有设置要默认的 -- + if (th.data.json_d.pickupway && th.data.json_d.pickupway == 1) et = 0; + break; + case 1: + et = 1; + break; + case 2: + et = 0; + break; + } - //----------子页返回父页触发---------- - onShow: function () { - var th = this; - if (th.data.isclose == 0) { - wx.navigateTo({ - url: "/pages/index/index/index" - }) - } else { - this.getuser_addr(function (ie) { - //更换地址回来要重新调用计算价钱的接口 - th.setData({ user_addr: ie }); - if (!th.data.user_addr || th.data.user_addr.address_id != ie.address_id) { - th.setData({ add_back: 1 }); - if (th.data.bn_goods) th.calculatePrice2(); + t.data.data.shop_price = gg.goods_price; + //--如果是普通购买的时候-- + if (gg.is_normal == 1) { + t.data.data.prom_id = 0; + t.data.data.prom_type = 0; + t.data.data.is_normal = 1; + + var gd = t.data.data; + //-- 用商品的手店价来显示 -- + gg.goods_price = gd.shop_price; + //---是不是购买等级卡成功的返回---等级卡显示的判断--- + var is_card_back = getApp().globalData.is_card_back; + if (is_card_back) { + gg.goods_price = gd[th.data.card_name]; + t.data.data.shop_price = gg.goods_price; + getApp().globalData.is_card_back = 0; + th.setData({ card_cut_price: 0 }); + } else { + //--- 商品不能是搭配购,商家等级卡开通的情况下, 会员不是等级会员的情况, 商品有设置等级卡价格,同时等级卡价格小于商品的价格 + if (th.data.card_name && gd[th.data.card_name] > 0 && gg.goods_price > gd[th.data.card_name] && !th.data.userinfo.card_field) { + var cut_p = gg.goods_price - gd[th.data.card_name]; + th.setData({ card_cut_price: cut_p }); + } } - }) - //--更新默认地址--,看一下是不是跳到地址页面 - if (!getApp().globalData.is_cart_old) { - this.update_code(); + + if (th.data.bn_goods) { + et = th.data.bn_exp_type; + } + + + th.setData({ + bn_goods: t.data.data, bn_pickname: gg.pick_name, + bn_pick: gg.pick_id, bn_t_exp_t: distr_t, is_normal: 1, bn_exp_type: et + }); + + + + th.calculatePrice2(); } else { - getApp().globalData.is_cart_old = 0; + + //--阶梯团很特殊,不能用总表来拿价格-- + getApp().request.get("/api/weshop/teamlist/get/" + oo.stoid + "/" + gd.prom_id, { + success: function (tt) { + + if (tt.data.code == 0) { + var pt_data = tt.data.data; + var now = s.gettimestamp(); + + if (pt_data.is_end == 1) { + t.data.data.prom_id = 0; + t.data.data.prom_type = 0; + t.data.data.is_normal = 1; + } else if (now > pt_data.end_time) { + t.data.data.prom_id = 0; + t.data.data.prom_type = 0; + t.data.data.is_normal = 1; + } else { + t.data.data.shop_price = tt.data.data.price; //活动价格 + t.data.data.is_normal = 0; + if (pt_data.kttype == 3) { + t.data.data.shop_price = tt.data.data.yf_price; //用定金来购买 + } + } + } else { + t.data.data.prom_id = 0; + t.data.data.prom_type = 0; + t.data.data.is_normal = 1; + } + + if (th.data.bn_goods) { + et = th.data.bn_exp_type; + } + + th.setData({ + bn_goods: t.data.data, bn_pickname: gg.pick_name, + bn_pick: gg.pick_id, bn_t_exp_t: distr_t, bn_exp_type: et + }); + + + //计算价格 + th.calculatePrice2(); + } + }); + } + } + }); + }, + + //----------子页返回父页触发---------- + onShow: function () { + var th = this; + if (th.data.isclose == 0) { + wx.navigateTo({ + url: "/pages/index/index/index" + }) + } else { + this.getuser_addr(function (ie) { + //更换地址回来要重新调用计算价钱的接口 + th.setData({ user_addr: ie }); + if (!th.data.user_addr || th.data.user_addr.address_id != ie.address_id) { + th.setData({ add_back: 1 }); + if (th.data.bn_goods) th.calculatePrice2(); } + }) + //--更新默认地址--,看一下是不是跳到地址页面 + if (!getApp().globalData.is_cart_old) { + this.update_code(); + } else { + getApp().globalData.is_cart_old = 0; } + } - //先获取是否有关闭使用优惠券 - getApp().getConfig2(function (ee) { - var json_d = JSON.parse(ee.switch_list); - th.data.json_d = json_d; - th.data.ispt_goods = json_d.ispt_goods; //是不是平摊到单品的控制参数赋值 - var is_default_logistics = json_d.is_default_logistics; - - th.setData({ is_close_quan: json_d.is_close_quan, sales_rules: ee.sales_rules, rank_switch: json_d.rank_switch, is_default_logistics: is_default_logistics }); - - var rank_switch = json_d.rank_switch; - var max_price = -1; - var show_card = null; - var name = ""; - //如果有开等级卡的时候, - //因为都是调接口,要返回在计算 - if (rank_switch == 2) { - //-- 获取所有的等级卡, -- - getApp().request.promiseGet("/api/weshop/plus/vip/mem/bership/list?storeId=" + os.stoid, - {}).then(res => { - if (res.data.code == 0) { - var plusCard = res.data.data; - //-- 循环判断,拿到最贵的那张卡 -- - for (var ih in plusCard) { - if (plusCard[ih].IsStopBuy == true) { continue; } - if (max_price < 0) { + //先获取是否有关闭使用优惠券 + getApp().getConfig2(function (ee) { + var json_d = JSON.parse(ee.switch_list); + th.data.json_d = json_d; + th.data.ispt_goods = json_d.ispt_goods; //是不是平摊到单品的控制参数赋值 + var is_default_logistics = json_d.is_default_logistics; + + th.setData({ is_close_quan: json_d.is_close_quan, sales_rules: ee.sales_rules, rank_switch: json_d.rank_switch, is_default_logistics: is_default_logistics }); + + var rank_switch = json_d.rank_switch; + var max_price = -1; + var show_card = null; + var name = ""; + //如果有开等级卡的时候, + //因为都是调接口,要返回在计算 + if (rank_switch == 2) { + //-- 获取所有的等级卡, -- + getApp().request.promiseGet("/api/weshop/plus/vip/mem/bership/list?storeId=" + os.stoid, + {}).then(res => { + if (res.data.code == 0) { + var plusCard = res.data.data; + //-- 循环判断,拿到最贵的那张卡 -- + for (var ih in plusCard) { + if (plusCard[ih].IsStopBuy == true) { continue; } + if (max_price < 0) { + max_price = plusCard[ih].CardFee; + name = 'card' + plusCard[ih]['CorrPrice']; + show_card = plusCard[ih]; + } else { + if (max_price < plusCard[ih].CardFee) { max_price = plusCard[ih].CardFee; name = 'card' + plusCard[ih]['CorrPrice']; show_card = plusCard[ih]; - } else { - if (max_price < plusCard[ih].CardFee) { - max_price = plusCard[ih].CardFee; - name = 'card' + plusCard[ih]['CorrPrice']; - show_card = plusCard[ih]; - } } } + } - if (show_card) { - name = name.toLowerCase(); - th.setData({ card_name: name, show_card: show_card }) - } + if (show_card) { + name = name.toLowerCase(); + th.setData({ card_name: name, show_card: show_card }) } - //-----先获取物流,再获取用户信息,再展示页面----- - th.get_wuliu(th.get_info(th.show_page)); - }) + } + //-----先获取物流,再获取用户信息,再展示页面----- + th.get_wuliu(th.get_info(th.show_page)); + }) + } else { + //-----先获取物流,再获取用户信息,再展示页面----- + th.get_wuliu(th.get_info(th.show_page)); + } + }, 1) + + }, + //---------------检查是否有收货地址------------------- + checkAddressList: function () { + var t = this; + return !(!this.data.order || null == this.data.order.userAddress) || (wx.showModal({ + title: "请先填写或选择收货地址~", + success: function (a) { + a.confirm ? t.enterAddressPage() : wx.navigateBack(); + }, + fail: function () { + wx.navigateBack(); + } + }), !1); + }, + showInvoice: function () { + this.setData({ + invoiceToggle: !this.data.invoiceToggle + }); + }, + keyUpChangePay1: function (t) { + this.setData({ + payWithUserMoney: !(t.detail.value.length > 0) + }); + }, + keyUpChangePay2: function (t) { + this.setData({ + payWithPoints: !(t.detail.value.length > 0) + }); + }, + keyUpChangeNum: function (t) { + this.setData({ + maxWord: t.detail.value.length + }); + }, + //---------计算立即购买---------- + calculatePrice2: function () { + var th = this, good = this.data.bn_goods; + //-----------计算商品总价-------------- + var allpice = good.shop_price * good.buynum; + allpice = parseFloat(allpice).toFixed(2); + var txt = "formData.all_price"; + th.setData({ [txt]: allpice, }); + console.log(th.data.formData); + + to.getConfig2(function (ee) { + to.getwuliuprice(function (rs) { + console.log('calculatePrice2222'); + console.log(rs); + var o_shipping_price = 0, goods_weight = -1, goods_piece = -1; + var out_of_weight = null; //超出多少重量 + var freight_free = ee.freight_free; //全场满多少包邮 + var weight_free = ee.weight_free; //多少kg内包邮 + //-----------当地址不为空,且是物流时,计算物流费用,同时阶梯团不计算拼团价格---------- + if (th.data.user_addr != null && th.data.bn_exp_type == 0 && good.is_free_shipping == 0 && (th.data.kt_type != 3 || th.data.bn_goods.is_normal == 1)) { + switch (good['exp_sum_type']) { + case 1: + //统一运费 + o_shipping_price += good['uniform_exp_sum']; break; + case 2: + if (goods_weight < 0) goods_weight = 0; + //累积商品重量 每种商品的重量 * 数量 + goods_weight += good['weight'] * good['buynum']; + if (weight_free > 0) { + out_of_weight = (weight_free * 1000) - goods_weight; + } + break; + case 3: + if (goods_piece < 0) goods_piece = 0; + //累积商品数量 + goods_piece += good['buynum']; break; + } + + console.log(o_shipping_price + ":" + goods_weight + ":" + goods_piece); + console.log(th.data.wu_arr); + var code = th.data.wu_arr[th.data.index].code; + var freight_free = ee.freight_free; //全场满多少包邮 + var shipping_price = + th.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, + goods_piece, th.data.user_addr, freight_free, allpice, rs); + + shipping_price = parseFloat(shipping_price).toFixed(2); + var wl_txt = "formData.shipping_price"; + th.setData({ [wl_txt]: shipping_price, }) + } else { - //-----先获取物流,再获取用户信息,再展示页面----- - th.get_wuliu(th.get_info(th.show_page)); + var wl_txt = "formData.shipping_price"; + th.setData({ [wl_txt]: 0, }) + } + //-----------------总价----------------- + var total_m = parseFloat(allpice) + parseFloat(th.data.formData.shipping_price); + total_m = parseFloat(total_m).toFixed(2); + + var atxt = "formData.total_amount"; + th.setData({ [atxt]: total_m, }) + var order_m = total_m; + + var txt = "formData.user_money"; + var txt2 = "formData.order_amount"; + //--------------如果使用余额--------------------- + if (th.data.bn_use_money == 1 && th.data.yuer > 0) { + if (parseFloat(th.data.yuer) > total_m) { + th.setData({ [txt]: total_m, [txt2]: 0 }) + } else { + order_m = parseFloat(order_m) - parseFloat(th.data.yuer); + order_m = order_m.toFixed(2); + th.setData({ [txt]: th.data.yuer, [txt2]: order_m }) + } + } else { + th.setData({ [txt]: 0, [txt2]: order_m }) } - }, 1) - - }, - //---------------检查是否有收货地址------------------- - checkAddressList: function() { - var t = this; - return !(!this.data.order || null == this.data.order.userAddress) || (wx.showModal({ - title: "请先填写或选择收货地址~", - success: function(a) { - a.confirm ? t.enterAddressPage() : wx.navigateBack(); - }, - fail: function() { - wx.navigateBack(); - } - }), !1); - }, - showInvoice: function() { - this.setData({ - invoiceToggle: !this.data.invoiceToggle - }); - }, - keyUpChangePay1: function(t) { - this.setData({ - payWithUserMoney: !(t.detail.value.length > 0) - }); - }, - keyUpChangePay2: function(t) { - this.setData({ - payWithPoints: !(t.detail.value.length > 0) - }); - }, - keyUpChangeNum: function(t) { - this.setData({ - maxWord: t.detail.value.length - }); - }, - //---------计算立即购买---------- - calculatePrice2: function () { - var th = this, good = this.data.bn_goods; - //-----------计算商品总价-------------- - var allpice = good.shop_price * good.buynum; - allpice=parseFloat(allpice).toFixed(2); - var txt = "formData.all_price"; - th.setData({ [txt]: allpice, }); - console.log(th.data.formData); - - to.getConfig2(function (ee) { - to.getwuliuprice(function (rs) { - console.log('calculatePrice2222'); - console.log(rs); - var o_shipping_price = 0,goods_weight = -1,goods_piece = -1; - var out_of_weight=null; //超出多少重量 - var freight_free = ee.freight_free; //全场满多少包邮 - var weight_free = ee.weight_free; //多少kg内包邮 - //-----------当地址不为空,且是物流时,计算物流费用,同时阶梯团不计算拼团价格---------- - if (th.data.user_addr != null && th.data.bn_exp_type == 0 && good.is_free_shipping == 0 && (th.data.kt_type!=3 || th.data.bn_goods.is_normal==1) ){ - switch (good['exp_sum_type']) { - case 1: - //统一运费 - o_shipping_price += good['uniform_exp_sum']; break; - case 2: - if (goods_weight < 0) goods_weight = 0; - //累积商品重量 每种商品的重量 * 数量 - goods_weight += good['weight'] * good['buynum']; - if(weight_free > 0){ - out_of_weight = (weight_free * 1000 ) - goods_weight; - } - break; - // goods_weight += good['weight'] * good['buynum'];break; - case 3: - if (goods_piece < 0) goods_piece = 0; - //累积商品数量 - goods_piece += good['buynum']; break; - } - - console.log(o_shipping_price + ":" + goods_weight + ":" + goods_piece); - console.log(th.data.wu_arr); - var code = th.data.wu_arr[th.data.index].code; - var freight_free = ee.freight_free; //全场满多少包邮 - var shipping_price= - th.calculatewuliu(code, o_shipping_price, goods_weight,out_of_weight, - goods_piece, th.data.user_addr, freight_free, allpice, rs); - - shipping_price = parseFloat(shipping_price).toFixed(2); - var wl_txt = "formData.shipping_price"; - th.setData({ [wl_txt]: shipping_price, }) - - }else{ - var wl_txt = "formData.shipping_price"; - th.setData({ [wl_txt]: 0, }) - } - //-----------------总价----------------- - var total_m = parseFloat(allpice) + parseFloat( th.data.formData.shipping_price); - total_m = parseFloat(total_m).toFixed(2); - - var atxt= "formData.total_amount"; - th.setData({ [atxt]: total_m, }) - var order_m = total_m; - - var txt = "formData.user_money"; - var txt2 = "formData.order_amount"; - //--------------如果使用余额--------------------- - if (th.data.bn_use_money == 1 && th.data.yuer>0) { - if ( parseFloat(th.data.yuer) > total_m) { - th.setData({ [txt]: total_m, [txt2]:0 }) - }else{ - order_m = parseFloat(order_m) - parseFloat(th.data.yuer); - order_m = order_m.toFixed(2); - th.setData({ [txt]: th.data.yuer, [txt2]: order_m }) - } - }else{ - th.setData({ [txt]: 0, [txt2]: order_m }) - } - }); }); - }, - //--------------------提交订单----------------------- - submitForm: async function(t){ - if(this.data.is_summit_ing==1) return false; //--提交中退出-- - this.data.is_summit_ing=1; - - var th=this,pdata=new Array(); - var ff=true; - //------------立即购买------------- - console.log("buy_new"); - - //如果不是阶梯团,或者是普通购买,商家选择了物流,以及地址为空的时候 - if(th.data.bn_exp_type == 0 && th.data.user_addr==null && (th.data.kt_type!=3 || th.data.bn_goods.is_normal==1) ){ - ff = false; - getApp().my_warnning("请选择收货地址",0,this); - this.data.is_summit_ing = 0; - } - if (!ff) return false; - var addr = th.data.user_addr; - if (th.data.bn_exp_type == 1) addr=null; - - console.log(th.data.formData); - console.log(th.data.wu_arr); - console.log(th.data.bn_exp_type); - - if(th.data.bn_exp_type==0 && (th.data.kt_type!=3 || th.data.bn_goods.is_normal==1)) { - if (th.data.wu_arr == null || th.data.wu_arr.length <= 0) { - getApp().my_warnning("读取物流失败",0,this); - this.data.is_summit_ing = 0; - return false; + }); + }, + //--------------------提交订单----------------------- + submitForm: async function (t) { + if (this.data.is_summit_ing == 1) return false; //--提交中退出-- + this.data.is_summit_ing = 1; + + var th = this, pdata = new Array(); + var ff = true; + //------------立即购买------------- + console.log("buy_new"); + + //如果不是阶梯团,或者是普通购买,商家选择了物流,以及地址为空的时候 + if (th.data.bn_exp_type == 0 && th.data.user_addr == null && (th.data.kt_type != 3 || th.data.bn_goods.is_normal == 1)) { + ff = false; + getApp().my_warnning("请选择收货地址", 0, this); + this.data.is_summit_ing = 0; + } + if (!ff) return false; + var addr = th.data.user_addr; + if (th.data.bn_exp_type == 1) addr = null; + + console.log(th.data.formData); + console.log(th.data.wu_arr); + console.log(th.data.bn_exp_type); + + if (th.data.bn_exp_type == 0 && (th.data.kt_type != 3 || th.data.bn_goods.is_normal == 1)) { + if (th.data.wu_arr == null || th.data.wu_arr.length <= 0) { + getApp().my_warnning("读取物流失败", 0, this); + this.data.is_summit_ing = 0; + return false; + } + } + + //阶梯团强制带1,自提~~~ + if (th.data.kt_type == 3) { + th.data.bn_exp_type = 1; + } + + var item = { + 'user_id': to.globalData.user_id, + 'consignee': addr == null ? "" : addr.consignee, + 'province': addr == null ? 0 : addr.province, + 'city': addr == null ? 0 : addr.city, + 'district': addr == null ? 0 : addr.district, + 'twon': addr == null ? 0 : addr.twon, + 'address': addr == null ? "" : addr.address, + 'more_address': addr == null ? "" : addr.more_address, + 'mobile': addr == null ? th.data.userinfo.mobile : addr.mobile, + 'email': '', + 'invoice_title': '', + 'goods_price': th.data.formData.all_price, //商品总价 + 'shipping_price': th.data.formData.shipping_price, //物流金额 + 'user_money': th.data.formData.user_money, //使用余额 + 'total_amount': th.data.formData.total_amount, //订单总价 + 'order_amount': th.data.formData.order_amount, //应付 + 'user_note': t.detail.value.user_note, //用户备注 + 'store_id': oo.stoid, //商家 + 'pickup_id': th.data.bn_pick, //门店 + 'exp_type': th.data.bn_exp_type, //配送方式 + 'is_normal': th.data.bn_goods.is_normal, //是否是普通购买 + 'pt_prom_id': th.data.bn_goods.prom_id, //拼单ID + 'is_pt_tz': th.data.is_pt_tz, //开团类型 + 'order_goods': new Array(), + }; + + //如果不是阶梯团,或者是普通购买, + if ((th.data.kt_type != 3 || th.data.bn_goods.is_normal == 1)) { + item['shipping_code'] = th.data.bn_exp_type == 1 ? 0 : th.data.wu_arr[th.data.index].code; + item['shipping_name'] = th.data.bn_exp_type == 1 ? '' : th.data.wu_arr[th.data.index].name; + } + + if (!th.data.bn_goods.is_normal) { + item.is_zsorder = th.data.kt_type + 1; //开团类型 + } + //老会员成为分销下线需要的参数 + if (getApp().globalData.first_leader && !getApp().globalData.userInfo.first_leader) { + //判断一下分享人是不是分享商 + await app.request.promiseGet("/api/weshop/users/get/" + os.stoid + "/" + getApp().globalData.first_leader, {}).then(res => { + if (res.data.code == 0) { + var user = res.data.data; + if (user.is_distribut == 1) { + item.first_leader = parseInt(getApp().globalData.first_leader); } } - - //阶梯团强制带1,自提~~~ - if(th.data.kt_type==3 ){ - th.data.bn_exp_type=1; - } - - var item={ - 'user_id': to.globalData.user_id, - 'consignee': addr == null ? "" : addr.consignee, - 'province': addr == null ? 0 : addr.province, - 'city': addr == null ? 0 : addr.city, - 'district': addr == null ? 0 : addr.district, - 'twon': addr == null ? 0 : addr.twon, - 'address': addr == null ? "": addr.address, - 'more_address': addr == null ? "" : addr.more_address, - 'mobile': addr == null ? th.data.userinfo.mobile:addr.mobile, - 'email':'', - 'invoice_title':'', - 'goods_price': th.data.formData.all_price, //商品总价 - 'shipping_price': th.data.formData.shipping_price, //物流金额 - 'user_money': th.data.formData.user_money, //使用余额 - 'total_amount': th.data.formData.total_amount, //订单总价 - 'order_amount': th.data.formData.order_amount, //应付 - 'user_note': t.detail.value.user_note, //用户备注 - 'store_id':oo.stoid, //商家 - 'pickup_id': th.data.bn_pick, //门店 - 'exp_type': th.data.bn_exp_type, //配送方式 - 'is_normal':th.data.bn_goods.is_normal, //是否是普通购买 - 'pt_prom_id':th.data.bn_goods.prom_id, //拼单ID - 'is_pt_tz':th.data.is_pt_tz, //开团类型 - 'order_goods':new Array(), - }; - - //如果不是阶梯团,或者是普通购买, - if((th.data.kt_type!=3 || th.data.bn_goods.is_normal==1)){ - item['shipping_code']= th.data.bn_exp_type == 1 ? 0 : th.data.wu_arr[th.data.index].code; - item['shipping_name']= th.data.bn_exp_type == 1 ? '' : th.data.wu_arr[th.data.index].name; - } - - if(!th.data.bn_goods.is_normal){ - item.is_zsorder=th.data.kt_type+1; //开团类型 - } - //老会员成为分销下线需要的参数 - if(getApp().globalData.first_leader && !getApp().globalData.userInfo.first_leader){ - //判断一下分享人是不是分享商 - await app.request.promiseGet("/api/weshop/users/get/" + os.stoid+"/"+getApp().globalData.first_leader,{}).then(res=>{ - if(res.data.code==0){ - var user= res.data.data; - if(user.is_distribut==1){ - item.first_leader=parseInt(getApp().globalData.first_leader); - } - } - }) - } - - if(th.data.qh!='') - { - item.team_qh=th.data.qh; - item.pt_listno=th.data.qh; - } - - var gg = to.get_b_now(); - var goods={ - 'goods_id': gg.goods_id, - 'goods_name': gg.goods_name, - 'goods_sn': gg.goods_sn, - 'goods_num': gg.goods_num, - 'market_price': th.data.bn_goods.market_price, - 'goods_price': th.data.bn_goods.shop_price, - 'member_goods_price': th.data.bn_goods.shop_price, - 'store_id': oo.stoid, - 'prom_type':th.data.bn_goods.prom_type, //促销活动类型 - 'prom_id': th.data.bn_goods.prom_id, //促销活动id - }; - - //--导购分享过来的id-- - if(gg.guide_id){ - goods.guide_id=gg.guide_id; - goods.guide_type=gg.guide_type; - //调用接口判断是不是会员 - await getApp().request.promiseGet("/api/weshop/shoppingGuide/getId/"+oo.stoid+"/"+gg.guide_id,{}).then(res=>{ - if(res.data.code==0){ - goods.guide_name=res.data.data.salesman; - goods.guide_sn=res.data.data.salesman_no; - } - }) - } - - - //--商品的房间号-- - if(gg.room_id && gg.room_id>0){ - item.room_ids=gg.room_id; - goods.room_id=gg.room_id; + }) + } + + if (th.data.qh != '') { + item.team_qh = th.data.qh; + item.pt_listno = th.data.qh; + } + + var gg = to.get_b_now(); + var goods = { + 'goods_id': gg.goods_id, + 'goods_name': gg.goods_name, + 'goods_sn': gg.goods_sn, + 'goods_num': gg.goods_num, + 'market_price': th.data.bn_goods.market_price, + 'goods_price': th.data.bn_goods.shop_price, + 'member_goods_price': th.data.bn_goods.shop_price, + 'store_id': oo.stoid, + 'prom_type': th.data.bn_goods.prom_type, //促销活动类型 + 'prom_id': th.data.bn_goods.prom_id, //促销活动id + }; + + //--导购分享过来的id-- + if (gg.guide_id) { + goods.guide_id = gg.guide_id; + goods.guide_type = gg.guide_type; + //调用接口判断是不是会员 + await getApp().request.promiseGet("/api/weshop/shoppingGuide/getId/" + oo.stoid + "/" + gg.guide_id, {}).then(res => { + if (res.data.code == 0) { + goods.guide_name = res.data.data.salesman; + goods.guide_sn = res.data.data.salesman_no; } - - if(th.data.bn_goods.is_normal){goods.is_pd_normal=1;} - - item.order_goods.push(goods); - pdata.push(item); - - if (pdata.length==0) return; - var str = JSON.stringify(pdata); - console.log("支付数据"); - console.log(str); - //return false; - wx.showLoading({title: "加载中"}); - wx.request({ - url: oo.url + '/api/weshop/order/createWxdOrder', - data: str, - method: 'POST', - header: { - 'content-type': 'application/json' - },// 设置请求的 header - success: function (res) { - - wx.hideLoading(); - if (res.statusCode == 200) { - var data=res.data; - if(data.code==0){ - console.log(th.data.is_b_now); - //如果是购物车结算,还要删除购物车 - if (th.data.is_b_now == 0) { - console.log(th.data.cartlist_y); - var list = th.data.cartlist_y; - for (var i = 0; i < list.length; i++) { - //删除购物车 - getApp().request.delete("/api/weshop/cart/del/" + oo.stoid + "/" + list[i].id, {}); - } - } - var order_amount = 0; - pdata.forEach(function (em, ind) { - order_amount += em.order_amount; - }) - //要进行判断,如果是用微信支付,就要跳转到支付界面 - if (order_amount > 0) { + }) + } + + + //--商品的房间号-- + if (gg.room_id && gg.room_id > 0) { + item.room_ids = gg.room_id; + goods.room_id = gg.room_id; + } + + if (th.data.bn_goods.is_normal) { goods.is_pd_normal = 1; } + + item.order_goods.push(goods); + pdata.push(item); + + if (pdata.length == 0) return; + var str = JSON.stringify(pdata); + console.log("支付数据"); + console.log(str); + //return false; + wx.showLoading({ title: "加载中" }); + wx.request({ + url: oo.url + '/api/weshop/order/createWxdOrder', + data: str, + method: 'POST', + header: { + 'content-type': 'application/json' + },// 设置请求的 header + success: function (res) { + + wx.hideLoading(); + if (res.statusCode == 200) { + var data = res.data; + if (data.code == 0) { + console.log(th.data.is_b_now); + //如果是购物车结算,还要删除购物车 + if (th.data.is_b_now == 0) { + console.log(th.data.cartlist_y); + var list = th.data.cartlist_y; + for (var i = 0; i < list.length; i++) { + //删除购物车 + getApp().request.delete("/api/weshop/cart/del/" + oo.stoid + "/" + list[i].id, {}); + } + } + var order_amount = 0; + pdata.forEach(function (em, ind) { + order_amount += em.order_amount; + }) + //要进行判断,如果是用微信支付,就要跳转到支付界面 + if (order_amount > 0) { + th.setData({ isclose: 0 }); + //void e.jumpToCart4({ + // order_sn: data.data, + // type:1, + // }, 1); + util_pay.pay(data.data, function () { + setTimeout(function () { + wx.reLaunch({ + //url: "/pages/payment/pay_success/pay_success?type=1&order_sn="+data.data, + url: "/pages/team/team_success/team_success?ordersn=" + data.data, + }) + }, 1000) + }, function () { + //支付失败 + setTimeout(function () { + //wx.navigateBack({ delta: 1 }) + wx.reLaunch({ + url: "/pages/user/order_list/order_list", + }) + }, 1000) + + }, oo.stoid, 1); + + } else { + var dd = { + parent_sn: data.data, + store_id: oo.stoid, + type: 1, + }; + //return false; + getApp().request.post("/api/weshop/order/pay/createOrder", { + data: dd, + success: function (t) { + console.log(t); + app.my_warnning("支付成功", 1, th); + setTimeout(function () { th.setData({ isclose: 0 }); - //void e.jumpToCart4({ - // order_sn: data.data, - // type:1, - // }, 1); - util_pay.pay(data.data, function() { - setTimeout(function () { - wx.reLaunch({ - //url: "/pages/payment/pay_success/pay_success?type=1&order_sn="+data.data, - url: "/pages/team/team_success/team_success?ordersn=" + data.data, - }) - },1000) - }, function () { - //支付失败 - setTimeout(function () { - //wx.navigateBack({ delta: 1 }) - wx.reLaunch({ - url: "/pages/user/order_list/order_list", - }) - },1000) - - },oo.stoid,1); - } else { - var dd = { - parent_sn: data.data, - store_id: oo.stoid, - type: 1, - }; - //return false; - getApp().request.post("/api/weshop/order/pay/createOrder", { - data: dd, - success: function (t) { - console.log(t); - app.my_warnning("支付成功",1,th); - setTimeout(function () { - th.setData({ isclose: 0 }); - - if(th.data.is_normal==1){ - /*-- - wx.navigateTo({ - url: "/pages/user/order_list/order_list", - })--*/ - var url="/pages/payment/pay_success/pay_success?type=1&order_sn="+data.data; - wx.reLaunch({ - url: url - }) - - }else{ - wx.reLaunch({ - url: "/pages/team/team_success/team_success?ordersn=" + data.data, - }) - } - - - }, 1000) + if (th.data.is_normal == 1) { + /*-- + wx.navigateTo({ + url: "/pages/user/order_list/order_list", + })--*/ + var url = "/pages/payment/pay_success/pay_success?type=1&order_sn=" + data.data; + wx.reLaunch({ + url: url + }) + + } else { + wx.reLaunch({ + url: "/pages/team/team_success/team_success?ordersn=" + data.data, + }) } - }); + + + }, 1000) } - } - else{ - th.data.is_summit_ing=0; //是否提交中 - getApp().confirmBox(data.msg); - } - } else { - th.data.is_summit_ing=0; //是否提交中 - console.log("index.js wx.request CheckCallUser statusCode" + res.statusCode); + }); + } } - }, - fail: function () { - th.data.is_summit_ing=0; //是否提交中 - wx.hideLoading(); - console.log("index.js wx.request CheckCallUser fail"); - }, - complete: function () {} - }) - }, - useCoupon: function() { - if (this.data.order.couponNum <= 0) { - //return t.showWarning("无可用优惠券"); - getApp().my_warnning("无可用优惠券",0,this); - return; + else { + th.data.is_summit_ing = 0; //是否提交中 + getApp().confirmBox(data.msg); + } + } else { + th.data.is_summit_ing = 0; //是否提交中 + console.log("index.js wx.request CheckCallUser statusCode" + res.statusCode); } - var a = { - lid: this.data.coupon ? this.data.coupon.id : "0" - }; - wx.navigateTo({ - url: "/pages/user/checkcoupon/checkcoupon?" + s.Obj2Str(a) - }); - }, - enterAddressPage: function() { - getApp().globalData.is_cart_old=1; - this.data.enterAddressPage = !0, wx.navigateTo({ - url: "/pages/user/address_list/address_list" - }); - }, + }, + fail: function () { + th.data.is_summit_ing = 0; //是否提交中 + wx.hideLoading(); + console.log("index.js wx.request CheckCallUser fail"); + }, + complete: function () { } + }) + }, + useCoupon: function () { + if (this.data.order.couponNum <= 0) { + //return t.showWarning("无可用优惠券"); + getApp().my_warnning("无可用优惠券", 0, this); + return; + } + var a = { + lid: this.data.coupon ? this.data.coupon.id : "0" + }; + wx.navigateTo({ + url: "/pages/user/checkcoupon/checkcoupon?" + s.Obj2Str(a) + }); + }, + enterAddressPage: function () { + getApp().globalData.is_cart_old = 1; + this.data.enterAddressPage = !0, wx.navigateTo({ + url: "/pages/user/address_list/address_list" + }); + }, - //--------立即购买时,选择自提和物流----------- - setexptype_w:function(t){ - var th=this; - var ty = t.currentTarget.dataset.t,txt = t.currentTarget.dataset.txt; - th.setData({ [txt]: ty }); - var iszt=1; - if(ty==0){ - th.setData({ is_all_zt: 0 }); - }else{ - for(var i=0;i 0 && o_price >= freight_free && out_of_weight>=0){ return 0;} - if (user_addr==null) { return 0; } - //计算物流的config item; - var item=null; - //先根据 镇 县 区找计算的config - item = th.get_wuliu_config(user_addr.district,code,rs); - if (item==null) item = th.get_wuliu_config(user_addr.city, code, rs); - if (item==null) item = th.get_wuliu_config(user_addr.province, code, rs); - if (item == null) item = th.get_wuliu_default(code,rs); + calculatewuliu: function (code, o_shipping_price, goods_weight, out_of_weight, + goods_piece, user_addr, freight_free, o_price, rs, pickid) { + var price = 0, th = this; + price += parseFloat(o_shipping_price); + //如果是包邮 + if (freight_free > 0 && o_price >= freight_free && out_of_weight >= 0) { return 0; } + if (user_addr == null) { return 0; } + //计算物流的config item; + var item = null; + //先根据 镇 县 区找计算的config + item = th.get_wuliu_config(user_addr.district, code, rs); + if (item == null) item = th.get_wuliu_config(user_addr.city, code, rs); + if (item == null) item = th.get_wuliu_config(user_addr.province, code, rs); + if (item == null) item = th.get_wuliu_default(code, rs); + if (item == null) return o_shipping_price; + var fw_price = 0, fp_price = 0; + item = item.config; if (item == null) return o_shipping_price; - var fw_price = 0, fp_price=0; - item=item.config; - if (item == null) return o_shipping_price; //------按重量---------- if (goods_weight >= 0 && item['money']) { - fw_price =parseFloat(item['money']); - if (goods_weight > item['first_weight']){ - var fw = goods_weight - item['first_weight']; - var n = Math.ceil(fw/item['second_weight']) - fw_price = fw_price + n * parseFloat(item['add_money']); - } + fw_price = parseFloat(item['money']); + if (goods_weight > item['first_weight']) { + var fw = goods_weight - item['first_weight']; + var n = Math.ceil(fw / item['second_weight']) + fw_price = fw_price + n * parseFloat(item['add_money']); + } } - //------超出重量---------- - if(out_of_weight < 0 && o_price >= freight_free){ + //------超出重量---------- + if (out_of_weight < 0 && o_price >= freight_free) { fw_price = parseFloat(item['money']); var out_of_weight = Math.abs(out_of_weight); if (out_of_weight > item['first_weight']) { - var fw = out_of_weight - item['first_weight']; - var n = Math.ceil(fw / item['second_weight']) - fw_price = fw_price + n * parseFloat(item['add_money']); + var fw = out_of_weight - item['first_weight']; + var n = Math.ceil(fw / item['second_weight']) + fw_price = fw_price + n * parseFloat(item['add_money']); } } //------按件数---------- - if (goods_piece > 0 ) { + if (goods_piece > 0) { fp_price = parseFloat(item['piecemoney']); if (goods_piece > item['first_piece']) { - var fp = goods_piece - item['first_piece']; - var m = Math.ceil(fp / item['second_piece']) + var fp = goods_piece - item['first_piece']; + var m = Math.ceil(fp / item['second_piece']) fp_price = fp_price + m * parseFloat(item['add_piecemoney']); } } - var rspice =parseFloat(price + fw_price + fp_price); + var rspice = parseFloat(price + fw_price + fp_price); return rspice; }, //------------循环获取config----------- - get_wuliu_config:function(region_id,code,rs){ - var item=null,rslist = rs.pageData; - for (var i = 0; i < rslist.length;i++){ - if (rslist[i].code == code && rslist[i].region_id == region_id) { item = rslist[i];} - } - return item; + get_wuliu_config: function (region_id, code, rs) { + var item = null, rslist = rs.pageData; + for (var i = 0; i < rslist.length; i++) { + if (rslist[i].code == code && rslist[i].region_id == region_id) { item = rslist[i]; } + } + return item; }, //-------循环获取config,code default------- get_wuliu_default: function (code, rs) { - var item = null, rslist=rs.pageData; + var item = null, rslist = rs.pageData; for (var i = 0; i < rslist.length; i++) { if (rslist[i].shipping_code == code && rslist[i].is_default == 1) { item = rslist[i]; } } return item; }, - //----------立即购买,选择物流------------- - bindPickerChange:function(e){ - var ind = e.detail.value - this.setData({ index: ind }); - this.calculatePrice2(); - }, - - //----------购物车结算,选择物流------------- - bindPickerChange_w: function (e) { - var ind=e.detail.value, txt = e.currentTarget.dataset.txt; - this.setData({ [txt]: ind }); - this.calculatePrice(); - }, - + //----------立即购买,选择物流------------- + bindPickerChange: function (e) { + var ind = e.detail.value + this.setData({ index: ind }); + this.calculatePrice2(); + }, + + //----------购物车结算,选择物流------------- + bindPickerChange_w: function (e) { + var ind = e.detail.value, txt = e.currentTarget.dataset.txt; + this.setData({ [txt]: ind }); + this.calculatePrice(); + }, + cart_set_err: function (e) { var txt = e.currentTarget.dataset.err; var ob = {}; @@ -870,70 +868,70 @@ Page({ this.setData(ob); }, - //// 开启物流的弹窗 - show_wu_arr:function(e){ - this.setData({ open_express: 1}); - }, + //// 开启物流的弹窗 + show_wu_arr: function (e) { + this.setData({ open_express: 1 }); + }, - //更新下默认,在onshow里面 - update_code(){ - var th=this,m_wind=0,def_exp_code=getApp().globalData.userInfo.def_exp_code; - - var uii=setInterval(function () { - if(th.data.wu_arr){ - clearInterval(uii); - for (var k = 0; k < th.data.wu_arr.length; k++) { - var item = th.data.wu_arr[k]; - if (def_exp_code == item.code) { - m_wind = k; - } - } - //--如果是立即购买-- - th.setData({ index: m_wind, is_express: m_wind}); - } - },500) - }, + //更新下默认,在onshow里面 + update_code() { + var th = this, m_wind = 0, def_exp_code = getApp().globalData.userInfo.def_exp_code; + + var uii = setInterval(function () { + if (th.data.wu_arr) { + clearInterval(uii); + for (var k = 0; k < th.data.wu_arr.length; k++) { + var item = th.data.wu_arr[k]; + if (def_exp_code == item.code) { + m_wind = k; + } + } + //--如果是立即购买-- + th.setData({ index: m_wind, is_express: m_wind }); + } + }, 500) + }, - // 关闭物流的弹窗 - close_express:function(){ - this.setData({ open_express:0 }); - }, - // 选择物流 - click_express_name:function(e){ - var express_name = e.currentTarget.dataset.name, shippingcode = e.currentTarget.dataset.shippingcode; - var index=e.currentTarget.dataset.idxe; - var ob={ is_express: index, is_shipping_code: shippingcode,index:index}; - this.setData(ob); - }, + // 关闭物流的弹窗 + close_express: function () { + this.setData({ open_express: 0 }); + }, + // 选择物流 + click_express_name: function (e) { + var express_name = e.currentTarget.dataset.name, shippingcode = e.currentTarget.dataset.shippingcode; + var index = e.currentTarget.dataset.idxe; + var ob = { is_express: index, is_shipping_code: shippingcode, index: index }; + this.setData(ob); + }, - //点击确定物流 - determine_expres:function(e){ - this.setData({ open_express: 0}); - this.calculatePrice2(); - }, - //设置默认物流 - select_default_logistics: function () { - var th=this; - var is_shipping_code=this.data.is_shipping_code - getApp().request.put("/api/weshop/users/update",{ - data: { user_id: getApp().globalData.user_id, store_id: oo.stoid, def_exp_code: is_shipping_code}, - success:function(rse){ - if (rse.data.code==0){ - getApp().globalData.userInfo.def_exp_code=is_shipping_code; - th.setData({ open_express: 0 }); - //----计算此时购物车的价格,这个页面没有calculatePrice(),2021.7.19---- - //if(th.data.is_b_now==1) th.calculatePrice2(); - //else th.calculatePrice(); - th.calculatePrice2(); - } - } - }) - }, + //点击确定物流 + determine_expres: function (e) { + this.setData({ open_express: 0 }); + this.calculatePrice2(); + }, + //设置默认物流 + select_default_logistics: function () { + var th = this; + var is_shipping_code = this.data.is_shipping_code + getApp().request.put("/api/weshop/users/update", { + data: { user_id: getApp().globalData.user_id, store_id: oo.stoid, def_exp_code: is_shipping_code }, + success: function (rse) { + if (rse.data.code == 0) { + getApp().globalData.userInfo.def_exp_code = is_shipping_code; + th.setData({ open_express: 0 }); + //----计算此时购物车的价格,这个页面没有calculatePrice(),2021.7.19---- + //if(th.data.is_b_now==1) th.calculatePrice2(); + //else th.calculatePrice(); + th.calculatePrice2(); + } + } + }) + }, - //跳转到购买卡 - buycard:function(){ - getApp().goto("/pages/user/plus/plus"); - getApp().globalData.plus_buy_back=1; - } + //跳转到购买卡 + buycard: function () { + getApp().goto("/pages/user/plus/plus"); + getApp().globalData.plus_buy_back = 1; + } });