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