var util = require('../../../utils/util.js'); var api = require('../../../config/api.js'); var app = getApp(); var dateArray = []; Page({ data: { checkedGoodsList: [], addressVo: {}, checkedCoupon00: [], checkedCoupon02: [], checkedCoupon10: [], checkedCoupon11: [], couponList00: [], couponList02: [], couponList10: [], couponList11: [], goodsBizTypeList: ['00', '02', '10', '11'], goodsTotalPrice: 0.00, //商品总价 freightPrice00: 0.00, //备货业务快递费 freightPrice02: 0.00, //补货业务快递费 freightPrice10: 0.00, //现场发包快递费 freightPrice11: 0.00, //普通商品快递费 couponPrice: 0.00, //优惠券的价格 orderTotalPrice: 0.00, //订单总价 actualPrice: 0.00, //实际需要支付的总价 // userCouponId: 0, fullCutCouponId: 0, fullCutCouponDec: 0, //满减优惠券 goodsTotalByType00: 0, //备货业务商品总计 goodsTotalByType02: 0, //补货业务商品总计 goodsTotalByType10: 0, //现场发包商品总计 goodsTotalByType11: 0, //普通商品商品总计 goodsTotalPrice00: 0, goodsTotalPrice02: 0, goodsTotalPrice10: 0, goodsTotalPrice11: 0, postscript: "", postscript00: '', //备货业务备注 postscript02: '', //补货业务备注 postscript10: '', //现场发包备注 postscript11: '', //普通商品备注 checkStore: false, storeVo: {}, delivery_date: '', delivery_remark: '尽快送达', multiArray: [], multiIndex: [0, 0], timeArray: util.getNowTimeArray(), idNo: '', userName: '', idNoM: '', idNoDisabled: false, checkCart: '', ticketDiscountList: [], tickDiscId00: 0, tickDiscId02: 0, tickDiscId10: 0, tickDiscId11: 0, checkTickDiscId: 0, actualPrice00: 0.00, actualPrice02: 0.00, actualPrice10: 0.00, actualPrice11: 0.00, campId00: 0, campId02: 0, campId10: 0, campId11: 0, campList00: '', campList02: '', campList10: '', campList11: '', campMinusDto00: '', campMinusDto02: '', campMinusDto10: '', campMinusDto11: '', checkCampId: 0, storeCampMinusList: [], openCampMinusAttr: false, goodsId: '', number: '', isAgreed: false }, onLoad: function(options) { // 页面初始化 options为页面跳转所带来的参数 // console.log(options.checkCart); this.setData({ checkCart: options.checkCart }); if (options.isAgreed) { this.setData({ isAgreed: options.isAgreed }); } if (options.goodsId) { this.setData({ goodsId: options.goodsId, number: options.number }); console.log(this.data.goodsId); console.log(this.data.number); } }, onReady: function() { // 页面渲染完成 }, onShow: function() { let that = this; // 页面显示 wx.showLoading({ title: '加载中...', }) if (wx.getStorageSync('userInfo') || wx.getStorageSync('token')) { if (wx.getStorageSync('storeId')) { util.request(api.ChooseStoreId, { storeId: wx.getStorageSync('storeId'), merchSn: wx.getStorageSync('merchSn') }, 'POST').then(function(res) { if (res.errno === 0) { wx.setStorageSync('storeId', wx.getStorageSync('storeId')); wx.setStorageSync('merchSn', wx.getStorageSync('merchSn')); that.reLoad(); } }); that.getCheckoutInfo(); that.initPicker() } } else { wx.navigateTo({ url: '/pages/auth/btnAuth/btnAuth', }) } }, onHide: function() { // 页面隐藏 console.log('页面隐藏'); }, onUnload: function() { // 页面关闭 console.log('页面关闭'); }, bindMultiPickerColumnChange: function(e) { let that = this; // console.log('修改的列为', e.detail.column, ',值为', e.detail.value); var data = { multiArray: this.data.multiArray, multiIndex: this.data.multiIndex }; data.multiIndex[e.detail.column] = e.detail.value if (e.detail.column == 0) { data.multiIndex[1] = 0 } let timeArray = that.data.timeArray; if (data.multiIndex[0] == 1) { timeArray = util.timeArray.slice(0); } else { timeArray = util.getNowTimeArray(); } data.timeArray = timeArray; data.multiArray[1] = timeArray; this.setData(data) }, bindMultiPickerChange: function(e) { let that = this; // console.log('picker发送选择改变,携带值为', e.detail.value) this.setData({ multiIndex: e.detail.value, delivery_date: dateArray[e.detail.value[0]], delivery_remark: e.detail.value[0] == 0 ? that.data.timeArray[e.detail.value[1]] : that.data.timeArray[e.detail.value[1]] }) // console.log('delivery_date', this.data.delivery_date, ',delivery_remark', this.data.delivery_remark) }, initPicker() { let that = this; let date = new Date(); let hours = date.getHours(); let minutes = date.getMinutes(); let index = 0; var today = util.getNowTime(); var tomorrow = util.getDateStr(new Date(), 1); dateArray = [today, tomorrow]; this.setData({ 'multiArray[0]': dateArray, 'multiArray[1]': that.data.timeArray, }) }, formatidcard(idcard) { if (idcard.length == 15) { return idcard.replace(/(\d{6})\d{6}(\d{3})/, "$1******$2"); } else { return idcard.replace(/(\d{5})\d{6}(\d{6})/, "$1******$2"); } }, getCheckoutInfo: function() { let that = this; util.request(api.CartCheckout, { tickDiscId00: that.data.tickDiscId00, tickDiscId02: that.data.tickDiscId02, tickDiscId10: that.data.tickDiscId10, tickDiscId11: that.data.tickDiscId11, campId00: that.data.campId00, campId02: that.data.campId02, campId10: that.data.campId10, campId11: that.data.campId11, merchSn: wx.getStorageSync('merchSn'), checkCart: that.data.checkCart, isLoadStatus: 0, //是首次加载 goodsId: that.data.goodsId, number: that.data.number }, 'POST').then(function(res) { if (res.errno === 0) { console.log(res.data); that.setData({ checkedGoodsList: res.data.checkedGoodsList, actualPrice: res.data.actualPrice, actualPrice00: res.data.actualPrice00, actualPrice02: res.data.actualPrice02, actualPrice10: res.data.actualPrice10, actualPrice11: res.data.actualPrice11, addressVo: res.data.addressVo, checkedCoupon00: res.data.checkedCoupon00, checkedCoupon02: res.data.checkedCoupon02, checkedCoupon10: res.data.checkedCoupon10, checkedCoupon11: res.data.checkedCoupon11, couponList00: res.data.couponList00, couponList02: res.data.couponList02, couponList10: res.data.couponList10, couponList11: res.data.couponList11, // fullCutCouponId: res.data.fullCutCouponId, // fullCutCouponDec: res.data.fullCutCouponDec, couponPrice: res.data.couponPrice, freightPrice00: res.data.freightPrice00, freightPrice02: res.data.freightPrice02, freightPrice10: res.data.freightPrice10, freightPrice11: res.data.freightPrice11, goodsTotalPrice: res.data.goodsTotalPrice, orderTotalPrice: res.data.orderTotalPrice, userName: res.data.userName, idNo: res.data.idNo, campList00: res.data.campList00, campList02: res.data.campList02, campList10: res.data.campList10, campList11: res.data.campList11, campMinusDto00: res.data.campMinusDto00, campMinusDto02: res.data.campMinusDto02, campMinusDto10: res.data.campMinusDto10, campMinusDto11: res.data.campMinusDto11, campId00: res.data.campId00, campId02: res.data.campId02, campId10: res.data.campId10, campId11: res.data.campId11, tickDiscId00: res.data.tickDiscId00, tickDiscId02: res.data.tickDiscId02, tickDiscId10: res.data.tickDiscId10, tickDiscId11: res.data.tickDiscId11, isLoadStatus: 0 }); if (that.data.idNo) { that.setData({ idNoM: that.formatidcard(that.data.idNo) }); } if (that.data.idNo) { that.setData({ idNoDisabled: true }); } let num00 = 0; let num02 = 0; let num10 = 0; let num11 = 0; let goodsTotalPrice00 = 0; let goodsTotalPrice02 = 0; let goodsTotalPrice10 = 0; let goodsTotalPrice11 = 0; for (var i = 0; i < that.data.checkedGoodsList.length; i++) { if ('00' == that.data.checkedGoodsList[i].goodsBizType) { num00 = num00 + that.data.checkedGoodsList[i].number; goodsTotalPrice00 = goodsTotalPrice00 + (that.data.checkedGoodsList[i].retail_price * that.data.checkedGoodsList[i].number); } if ('02' == that.data.checkedGoodsList[i].goodsBizType) { num02 = num02 + that.data.checkedGoodsList[i].number; goodsTotalPrice02 = goodsTotalPrice02 + (that.data.checkedGoodsList[i].retail_price * that.data.checkedGoodsList[i].number); } if ('10' == that.data.checkedGoodsList[i].goodsBizType) { num10 = num10 + that.data.checkedGoodsList[i].number; goodsTotalPrice10 = goodsTotalPrice10 + (that.data.checkedGoodsList[i].retail_price * that.data.checkedGoodsList[i].number); } if ('11' == that.data.checkedGoodsList[i].goodsBizType) { num11 = num11 + that.data.checkedGoodsList[i].number; goodsTotalPrice11 = goodsTotalPrice11 + (that.data.checkedGoodsList[i].retail_price * that.data.checkedGoodsList[i].number); } } that.setData({ goodsTotalByType00: num00, goodsTotalByType02: num02, goodsTotalByType10: num10, goodsTotalByType11: num11, goodsTotalPrice00: (goodsTotalPrice00 + that.data.freightPrice00).toFixed(2), goodsTotalPrice02: (goodsTotalPrice02 + that.data.freightPrice02).toFixed(2), goodsTotalPrice10: (goodsTotalPrice10 + that.data.freightPrice10).toFixed(2), goodsTotalPrice11: (goodsTotalPrice11 + that.data.freightPrice11).toFixed(2) }); // console.log(that.data.goodsTotalByType00); // console.log(that.data.goodsTotalByType02); // console.log(that.data.goodsTotalByType10); // console.log(that.data.goodsTotalByType11); //选择促销 that.setCampMinus(); //选择优惠券 that.setTickDisc(); } wx.hideLoading(); that.checkStore(); }); }, selectAddress() { this.setData({ checkStore: false, openTicketAttr: false }); wx.navigateTo({ url: '/pages/shopping/address/address', }) }, addAddress() { wx.navigateTo({ url: '/pages/shopping/addressAdd/addressAdd', }) }, bindPostscriptBlur(e) { let goodsType = e.target.dataset.goodsType; if (goodsType == '00') { this.setData({ postscript00: e.detail.value }); } if (goodsType == '02') { this.setData({ postscript02: e.detail.value }); } if (goodsType == '10') { this.setData({ postscript10: e.detail.value }); } if (goodsType == '11') { this.setData({ postscript11: e.detail.value }); } }, submitOrder: function (e) { let that = this; // console.log(e.detail.formId); wx.showModal({ title: '消费者告知书', content: '为了您更好地选择境外商品,请您在下单前务必认真详细阅读并完全理解本告知书相关内容,对自身风险做出客观判断,完全同意本告知书内容后再下单。\r\n1、按照跨境电商进口税收政策(财关税[2018]49号)要求,跨境电子商务零售进口商品的单笔交易限额为人民币5000元,个人年底交易限额为人民币26000元。\r\n2、本平台所售境外商品是用户最终支付的金额,无需额外再支付税费。\r\n3、根据相关法律政策,您选购的境外商品仅限于个人自用,不得进行再次销售。\r\n4、您知晓商品的订购人(即支付人)将被记录为进口方,必须遵守中国的法律法规。\r\n5、跨境电商相关法律法规规定“合法的报关清关手续需验证个人身份信息”,提交订单时,需要用户填写个人真实身份信息。\r\n6、您购买的所有境外商品适用的品质、健康、安全、卫生、环保、标示等项目标准可能与我国质量安全标准不同,由此可能产生的危害和损失以及法律责任或其他风险,将由您个人承担。\r\n7、您在本网站购买的境外商品等同于原产地直接销售商品,因此商品本身可能无中文标签或者说明书,请在下单前认真阅读平台提供的物品信息。\r\n8、建议您对境外商品有一定了解并评估是否适合自己使用后再下单,感谢您的配合。\r\n9、您购买的跨境商品订单经海关清关成功放行后,便不可退单及修改收件地址,请确认信息后再下单,感谢您的理解和配合。', cancelText:'拒绝', confirmText:'同意', success(res) { if (res.confirm) { if (wx.getStorageSync('storeId')) {} else { wx.switchTab({ url: '/pages/cart/cart' }) } if (!that.data.addressVo) { util.showErrorToast('请选择收货地址'); return false; } if (!e.detail.value.idNo) { util.showErrorToast('身份证号不能为空'); return false; } if (!e.detail.value.userName) { util.showErrorToast('姓名不能为空'); return false; } if (that.data.idNoM == '') { that.setData({ idNo: e.detail.value.idNo, userName: e.detail.value.userName }); } if (!that.checkIdcard(that.data.idNo)) { wx.showModal({ title: '提示信息', content: '请输入正确的身份证号', showCancel: false }); return false; } // if (!this.data.checkStore || !this.data.checkStore) { // util.showErrorToast('超过门店配送范围'); // return false; // } // console.log(that.data.postscript00); // console.log(that.data.postscript02); // console.log(that.data.postscript10); // console.log(that.data.postscript11); wx.showLoading({ title: '加载中...', }); util.request(api.OrderSubmit, { checkedAddress: that.data.addressVo, tickDiscId00: that.data.tickDiscId00, tickDiscId02: that.data.tickDiscId02, tickDiscId10: that.data.tickDiscId10, tickDiscId11: that.data.tickDiscId11, // fullCutCouponId: that.data.fullCutCouponId, postscript00: that.data.postscript00, postscript02: that.data.postscript02, postscript10: that.data.postscript10, postscript11: that.data.postscript11, delivery_date: that.data.delivery_date, delivery_remark: that.data.delivery_remark, idNo: that.data.idNo, userName: that.data.userName, merchSn: wx.getStorageSync("merchSn"), checkCart: that.data.checkCart, campId00: that.data.campId00, campId02: that.data.campId02, campId10: that.data.campId10, campId11: that.data.campId11, isLoadStatus: that.data.isLoadStatus, goodsId: that.data.goodsId, number: that.data.number }, 'POST').then(function(res) { if (res.errno === 0) { let actualPrice = that.data.actualPrice; let orderIds = []; for (let i = 0; i < res.data.orderInfo.length; i++) { orderIds[i] = res.data.orderInfo[i].id; } wx.redirectTo({ url: '/pages/pay/pay?orderIds=' + orderIds + '&actualPrice=' + actualPrice + '&isMergePay=1' //此处提交支付属于合并支付 }) } else { wx.showModal({ title: '提示信息', content: res.errmsg, showCancel: false }); } wx.hideLoading(); }); } else if (res.cancel) { console.log('用户点击取消') } } }); }, // 校验门店 checkStore: function() { let that = this; util.request(api.CheckStore, { checkedAddress: that.data.addressVo, storeId: wx.getStorageSync('storeId') }, 'POST').then(function(res) { if (res.errno === 0) { that.setData({ storeVo: res.data, checkStore: true }); } else { // console.log(res.errmsg); // util.showErrorToast(res.errmsg); that.setData({ checkStore: false }); } }); }, reLoad: function() { let that = this; if (wx.getStorageSync('storeId')) { if (wx.getStorageSync('userId')) { wx.request({ url: api.updateLoginUser, data: { userId: wx.getStorageSync('userId'), storeId: wx.getStorageSync('storeId'), merchSn: wx.getStorageSync('merchSn') }, method: 'POST', header: { 'Content-Type': 'application/json' }, success: function(wxRes) { if (wxRes.data.errno === 0) { // console.log("用户信息更新成功"); } }, fail: function(err) { console.log("failed"); } }); } } }, // 校验身份证号 //校验码校验 checkCode: function(val) { var p = /^[1-9]\d{5}(18|19|20)\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/; var factor = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2]; var parity = [1, 0, 'X', 9, 8, 7, 6, 5, 4, 3, 2]; var code = val.substring(17); if (p.test(val)) { var sum = 0; for (var i = 0; i < 17; i++) { sum += val[i] * factor[i]; } if (parity[sum % 11] == code.toUpperCase()) { return true; } } return false; }, //省份校验 checkProv: function(val) { var pattern = /^[1-9][0-9]/; var provs = { 11: "北京", 12: "天津", 13: "河北", 14: "山西", 15: "内蒙古", 21: "辽宁", 22: "吉林", 23: "黑龙江 ", 31: "上海", 32: "江苏", 33: "浙江", 34: "安徽", 35: "福建", 36: "江西", 37: "山东", 41: "河南", 42: "湖北 ", 43: "湖南", 44: "广东", 45: "广西", 46: "海南", 50: "重庆", 51: "四川", 52: "贵州", 53: "云南", 54: "西藏 ", 61: "陕西", 62: "甘肃", 63: "青海", 64: "宁夏", 65: "新疆", 71: "台湾", 81: "香港", 82: "澳门" }; if (pattern.test(val)) { if (provs[val]) { return true; } } return false; }, //出生日期码校验 checkDate: function(val) { var pattern = /^(18|19|20)\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)$/; if (pattern.test(val)) { var year = val.substring(0, 4); var month = val.substring(4, 6); var date = val.substring(6, 8); var date2 = new Date(year + "-" + month + "-" + date); if (date2 && date2.getMonth() == (parseInt(month) - 1)) { return true; } } return false; }, checkIdcard: function(val) { if (this.checkCode(val)) { var date = val.substring(6, 14); if (this.checkDate(date)) { if (this.checkProv(val.substring(0, 2))) { return true; } } } // this.isError("请输入正确身份证号"); return false; }, // 通过身份证号获取出生日期和性别 getBirthAndSex: function(idCard) { var that = this; var info = {}; var birth = (idCard.length === 18) ? idCard.slice(6, 14) : idCard.slice(6, 12); var order = (idCard.length === 18) ? idCard.slice(-2, -1) : idCard.slice(-1); info.birthDay = (idCard.length === 18) ? ([birth.slice(0, 4), birth.slice(4, 6), birth.slice(-2)]).join('-') : (['19' + birth.slice(0, 2), birth.slice(2, 4), birth.slice(-2)]).join('-'); info.sex = (order % 2 === 0 ? 2 : 0); return info; }, selectCoupon(e) { let goodsBizType = e.currentTarget.dataset.goodsType; let that = this; // wx.navigateTo({ // url: '/pages/shopping/coupon/coupon', // }) that.setData({ openTicketAttr: !that.data.openTicketAttr, openCampMinusAttr: false }) if (that.data.openTicketAttr) { that.getTicketDiscountList(goodsBizType); } }, hideSwitchTicketPop: function() { this.setData({ openTicketAttr: false }) }, /** * 查看当前用户已领取的且购订单商品所支持的优惠券列表 */ getTicketDiscountList: function(bizType) { wx.showLoading({ title: '加载中...', }); let that = this; util.request(api.DiscountByCheckCartList, { storeId: wx.getStorageSync('storeId'), checkCart: that.data.checkCart, bizType: bizType, goodsId: that.data.goodsId, number: that.data.number }).then(function(res) { if (res.errno === 0) { that.setData({ ticketDiscountList: res.data }); wx.hideLoading(); } }); }, selectTicket(e) { let that = this; let id = e.currentTarget.dataset.ticketId; let goodsBizType = e.currentTarget.dataset.goodsType; // console.log(id); if (id != null) { if (goodsBizType == '00') { that.setData({ tickDiscId00: id, checkTickDiscId: id }); } if (goodsBizType == '02') { that.setData({ tickDiscId02: id, checkTickDiscId: id }); } if (goodsBizType == '10') { that.setData({ tickDiscId10: id, checkTickDiscId: id }); } if (goodsBizType == '11') { that.setData({ tickDiscId11: id, checkTickDiscId: id }); } } }, submitTicket() { let that = this; that.setData({ openTicketAttr: false }); wx.showLoading({ title: '加载中...', }); util.request(api.CartCheckout, { tickDiscId00: that.data.tickDiscId00, tickDiscId02: that.data.tickDiscId02, tickDiscId10: that.data.tickDiscId10, tickDiscId11: that.data.tickDiscId11, campId00: that.data.campId00, campId02: that.data.campId02, campId10: that.data.campId10, campId11: that.data.campId11, merchSn: wx.getStorageSync('merchSn'), checkCart: that.data.checkCart, isLoadStatus: 2, //2代表选择优惠券加载 goodsId: that.data.goodsId, number: that.data.number }, 'POST').then(function(res) { console.log(res.data); if (res.errno === 0) { that.setData({ checkedGoodsList: res.data.checkedGoodsList, actualPrice: res.data.actualPrice, actualPrice00: res.data.actualPrice00, actualPrice02: res.data.actualPrice02, actualPrice10: res.data.actualPrice10, actualPrice11: res.data.actualPrice11, checkedCoupon00: res.data.checkedCoupon00, checkedCoupon02: res.data.checkedCoupon02, checkedCoupon10: res.data.checkedCoupon10, checkedCoupon11: res.data.checkedCoupon11, couponList00: res.data.couponList00, couponList02: res.data.couponList02, couponList10: res.data.couponList10, couponList11: res.data.couponList11, goodsTotalPrice: res.data.goodsTotalPrice, orderTotalPrice: res.data.orderTotalPrice, // fullCutCouponDec: res.data.fullCutCouponDec, // fullCutCouponId: res.data.fullCutCouponId, campList00: res.data.campList00, campList02: res.data.campList02, campList10: res.data.campList10, campList11: res.data.campList11, campMinusDto00: res.data.campMinusDto00, campMinusDto02: res.data.campMinusDto02, campMinusDto10: res.data.campMinusDto10, campMinusDto11: res.data.campMinusDto11, campId00: res.data.campId00, campId02: res.data.campId02, campId10: res.data.campId10, campId11: res.data.campId11, tickDiscId00: res.data.tickDiscId00, tickDiscId02: res.data.tickDiscId02, tickDiscId10: res.data.tickDiscId10, tickDiscId11: res.data.tickDiscId11, isLoadStatus: 2 }); //选择促销 that.setCampMinus(); //选择优惠券 that.setTickDisc(); } wx.hideLoading(); }); }, selectCamp(e) { let goodsBizType = e.currentTarget.dataset.goodsType; let that = this; // wx.navigateTo({ // url: '/pages/shopping/coupon/coupon', // }) that.setData({ openCampMinusAttr: !that.data.openCampMinusAttr, openTicketAttr: false }) if (that.data.openCampMinusAttr) { that.getStoreCampMinusList(goodsBizType); } }, hideSwitchTicketPop: function() { this.setData({ openTicketAttr: false, openCampMinusAttr: false }) }, /** * 查看满减满折列表 */ getStoreCampMinusList(goodsBizType) { wx.showLoading({ title: '加载中...', }); let that = this; util.request(api.CampminusByCheckCartList, { storeId: wx.getStorageSync('storeId'), checkCart: that.data.checkCart, bizType: goodsBizType, goodsId: that.data.goodsId, number: that.data.number }).then(function(res) { if (res.errno === 0) { that.setData({ storeCampMinusList: res.data }); wx.hideLoading(); } }); }, selectUserCamp(e) { let that = this; let campId = e.currentTarget.dataset.campId; let goodsBizType = e.currentTarget.dataset.goodsType; if (campId != null) { if (goodsBizType == '00') { that.setData({ campId00: campId, checkCampId: campId }); } if (goodsBizType == '02') { that.setData({ campId02: campId, checkCampId: campId }); } if (goodsBizType == '10') { that.setData({ campId10: campId, checkCampId: campId }); } if (goodsBizType == '11') { that.setData({ campId11: campId, checkCampId: campId }); } } }, submitCampMinus() { let that = this; that.hideSwitchTicketPop(); wx.showLoading({ title: '加载中...', }); util.request(api.CartCheckout, { tickDiscId00: that.data.tickDiscId00, tickDiscId02: that.data.tickDiscId02, tickDiscId10: that.data.tickDiscId10, tickDiscId11: that.data.tickDiscId11, campId00: that.data.campId00, campId02: that.data.campId02, campId10: that.data.campId10, campId11: that.data.campId11, merchSn: wx.getStorageSync('merchSn'), checkCart: that.data.checkCart, isLoadStatus: 1, //1代表选择促销活动加载 goodsId: that.data.goodsId, number: that.data.number }, 'POST').then(function(res) { console.log(res.data); if (res.errno === 0) { that.setData({ checkedGoodsList: res.data.checkedGoodsList, actualPrice: res.data.actualPrice, actualPrice00: res.data.actualPrice00, actualPrice02: res.data.actualPrice02, actualPrice10: res.data.actualPrice10, actualPrice11: res.data.actualPrice11, checkedCoupon00: res.data.checkedCoupon00, checkedCoupon02: res.data.checkedCoupon02, checkedCoupon10: res.data.checkedCoupon10, checkedCoupon11: res.data.checkedCoupon11, couponList00: res.data.couponList00, couponList02: res.data.couponList02, couponList10: res.data.couponList10, couponList11: res.data.couponList11, goodsTotalPrice: res.data.goodsTotalPrice, orderTotalPrice: res.data.orderTotalPrice, // fullCutCouponDec: res.data.fullCutCouponDec, // fullCutCouponId: res.data.fullCutCouponId, campList00: res.data.campList00, campList02: res.data.campList02, campList10: res.data.campList10, campList11: res.data.campList11, campMinusDto00: res.data.campMinusDto00, campMinusDto02: res.data.campMinusDto02, campMinusDto10: res.data.campMinusDto10, campMinusDto11: res.data.campMinusDto11, campId00: res.data.campId00, campId02: res.data.campId02, campId10: res.data.campId10, campId11: res.data.campId11, tickDiscId00: res.data.tickDiscId00, tickDiscId02: res.data.tickDiscId02, tickDiscId10: res.data.tickDiscId10, tickDiscId11: res.data.tickDiscId11, isLoadStatus: 1 }); //选择促销 that.setCampMinus(); //选择优惠券 that.setTickDisc(); } wx.hideLoading(); }); }, /** * 选择促销 */ setCampMinus() { let that = this; // console.log(that.data.campMinusDto00); // console.log(that.data.campList00); // console.log(that.data.campId00); if (that.data.campMinusDto00 != null && that.data.campList00 != null && that.data.campList00.length > 0) { for (var i = 0; i < that.data.campList00.length; i++) { if (that.data.campId00 == that.data.campList00[i].campMinusId) { that.setData({ campMinusDto00: that.data.campList00[i], checkCampId: that.data.campId00 }); break; } } } if (that.data.campMinusDto02 != null && that.data.campList02 != null && that.data.campList02.length > 0) { for (var i = 0; i < that.data.campList02.length; i++) { if (that.data.campId02 == that.data.campList02[i].campMinusId) { that.setData({ campMinusDto02: that.data.campList02[i], checkCampId: that.data.campId02 }); break; } } } if (that.data.campMinusDto10 != null && that.data.campList10 != null && that.data.campList10.length > 0) { for (var i = 0; i < that.data.campList10.length; i++) { if (that.data.campId10 == that.data.campList10[i].campMinusId) { that.setData({ campMinusDto10: that.data.campList10[i], checkCampId: that.data.campId10 }); break; } } } if (that.data.campMinusDto11 != null && that.data.campList11 != null && that.data.campList11.length > 0) { for (var i = 0; i < that.data.campList11.length; i++) { if (that.data.campId11 == that.data.campList11[i].campMinusId) { that.setData({ campMinusDto11: that.data.campList11[i], checkCampId: that.data.campId11 }); break; } } } }, /** * 选择优惠券 */ setTickDisc() { let that = this; if (that.data.tickDiscId00 != null && that.data.couponList00 != null && that.data.couponList00.length > 0) { for (var i = 0; i < that.data.couponList00.length; i++) { if (that.data.tickDiscId00 == that.data.couponList00[i].id) { that.setData({ checkedCoupon00: that.data.couponList00[i], checkTickDiscId: that.data.tickDiscId00 }); break; } } } if (that.data.tickDiscId02 != null && that.data.couponList02 != null && that.data.couponList02.length > 0) { for (var i = 0; i < that.data.couponList02.length; i++) { if (that.data.tickDiscId02 == that.data.couponList02[i].id) { that.setData({ checkedCoupon02: that.data.couponList02[i], checkTickDiscId: that.data.tickDiscId02 }); break; } } } if (that.data.tickDiscId10 != null && that.data.couponList10 != null && that.data.couponList10.length > 0) { for (var i = 0; i < that.data.couponList10.length; i++) { if (that.data.tickDiscId10 == that.data.couponList10[i].id) { that.setData({ checkedCoupon10: that.data.couponList10[i], checkTickDiscId: that.data.tickDiscId10 }); break; } } } if (that.data.tickDiscId11 != null && that.data.couponList11 != null && that.data.couponList11.length > 0) { for (var i = 0; i < that.data.couponList11.length; i++) { if (that.data.tickDiscId11 == that.data.couponList11[i].id) { that.setData({ checkedCoupon11: that.data.couponList11[i], checkTickDiscId: that.data.tickDiscId11 }); break; } } } } })