// pages/groupmeallist/submitOrder/submitOrder.js import storeGoods from '../../../api/storeGoods' const cache = require('../../../utils/cache.js'); import base from '../../../utils/base' Page({ /** * 页面的初始数据 */ data: { orderGoodList: [{}, {}, {}, {}], store: {}, phone: '', storeWay: '', addressvaule:'', addressId:'', showAllSku: false, isShowPannel: false, forSelectList: [], discoutTitle: '', couponSn: '', orderMode: '', discountPriceY: '' }, //全部显示和收起 handleFlodExtend() { this.setData({ showAllSku: !this.data.showAllSku }) }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { let addressvaule = options.addressvalue let addressId = options.addressId if(addressvaule !=null && addressId!=null ){ this.setData({ addressvaule:addressvaule, addressId:addressId }) } }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { let store = cache.getCurrStore(); let storeWay = cache.getStoreWay() console.log(store) console.log(storeWay) if (store != null) { this.setData({ store: store, storeWay: storeWay }) } this.loadCartData(); this.getUseConfirmOrderCoupon() }, // 自动获取手机号 getPhone() { let phone = cache.getMobile() this.setData({ phone: phone }) }, // 选择收货地址 chooseAdress() { wx.redirectTo({ url: '../address/address?isreturn=' + 'true', }) }, getUseConfirmOrderCoupon() { storeGoods.orderCouponForSelect({ storeId: cache.getStoreId(), mobile: cache.getMobile(), // tableId: 1 }).then(res => { if (res.code == 200) { this.setData({ forSelectList: res.data }) } }).catch(_ => { // // this.setData({ // // isShowPannel: true // // }) // this.tapSex() console.log(_) }) }, /** * 加载购物车数据 */ loadCartData() { storeGoods.getCartData(cache.getStoreId(), cache.getMobile(), null, null).then(res => { if (res.code == 200) { this.cartDataMapToView(res.data) } }).catch(_ => { console.log(_) }) }, cartDataMapToView(data) { var isShowCartPannel = true; if (base.isEmpty(data.skuList) || data.skuList.length == 0) { isShowCartPannel = false data.totalPriceY = "0.00" data.totalNum = 0 } // let skuList = data.skuList || [] // skuList.forEach(sku => { // if (!base.isEmpty(sku.specList)) { // let specValueList = [] // sku.specList.forEach(spec => { // specValueList.push(spec.specValue) // }) // sku.specDes = specValueList.join("、") // } else { // sku.specDes = "" // } // sku.allFee = base.fenToYuan(sku.num * sku.price) // sku.allOriFee = base.fenToYuan(sku.num * sku.oriPrice) // }) this.setData({ isValid: data.skuList.length > 0, skuList: data.skuList, areaName: data.areaName, tableCode: data.tableCode, totalNum: data.totalNum, totalOriPriceY: data.totalOriPriceY, totalPriceY: data.totalPriceY - data.discountPriceY, totalPrice: data.totalPrice, totalOriPrice: data.totalOriPrice, discountPriceY: data.discountPriceY }) }, // 详情和收起 changeCollapseOrDetail: function (e) { let idx = e.currentTarget.dataset.idx; var that = this; that.data.skuList[idx].show = !that.data.skuList[idx].show that.setData({ skuList: that.data.skuList }); console.log("购物车详情"); console.log(that.data.skuList); }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })