123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220 |
- // 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 () {
- }
- })
|