123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988 |
- 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: ''
- },
- onLoad: function (options) {
- // 页面初始化 options为页面跳转所带来的参数
- // console.log(options.checkCart);
- this.setData({
- checkCart: options.checkCart
- });
- 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) {
- // console.log(e.detail.formId);
- if (wx.getStorageSync('storeId')) {} else {
- wx.switchTab({
- url: '/pages/cart/cart'
- })
- }
- if (!this.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 (this.data.idNoM == '') {
- this.setData({
- idNo: e.detail.value.idNo,
- userName: e.detail.value.userName
- });
- }
- if (!this.checkIdcard(this.data.idNo)) {
- wx.showModal({
- title: '提示信息',
- content: '请输入正确的身份证号',
- showCancel: false
- });
- return false;
- }
- // if (!this.data.checkStore || !this.data.checkStore) {
- // util.showErrorToast('超过门店配送范围');
- // return false;
- // }
- let that = this;
- // 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();
- });
- },
- // 校验门店
- 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;
- }
- }
- }
- }
- })
|