diff --git a/pages/info/sceneProductInfo/index.js b/pages/info/sceneProductInfo/index.js index 1cd11a6..241bde8 100644 --- a/pages/info/sceneProductInfo/index.js +++ b/pages/info/sceneProductInfo/index.js @@ -204,83 +204,63 @@ Page({ }) }, order: function (e) { - console.log(this.data.info,this.data.skuFlag) - if (e.currentTarget.dataset.disable == 1) return; - util.pagePoint({ - event: 'scene_order', - param: { - type: this.data.info.type, - id: this.data.info.id - } - }, 1) - wx.setStorageSync('login_from', 'scene_order_login') - wx.setStorageSync('order_from', 'scene_order_submit') - app.globalData.couponInfo = null; - app.globalData.retailId = this.data.retailId; - // let sku = e.currentTarget.dataset.sku,product = e.currentTarget.dataset.product; - app.globalData.product = e.currentTarget.dataset; - wx.navigateTo({ - url: '/pages/order/scene/index', - }) + console.log(this.data.info,this.data.skuFlag) + if (this.data.skuFlag == 'order'){ + if (e.currentTarget.dataset.disable == 1) return; + util.pagePoint({ + event: 'scene_order', + param: { + type: this.data.info.type, + id: this.data.info.id + } + }, 1) + wx.setStorageSync('login_from', 'scene_order_login') + wx.setStorageSync('order_from', 'scene_order_submit') + app.globalData.couponInfo = null; + app.globalData.retailId = this.data.retailId; + // let sku = e.currentTarget.dataset.sku,product = e.currentTarget.dataset.product; + app.globalData.product = e.currentTarget.dataset; + wx.navigateTo({ + url: '/pages/order/scene/index', + }) + }else { + commonApi.user_post("cart/add_sku", { + sku_id: this.data.info.product[0].sku[this.data.skuIndex].id, + num: this.data.producNum + }).then(res => { + if (res.code == 1) { + commonApi.user_post('cart/get_list', {}).then(res => { + this.setData({ + cartCount: res.data.length + }) + }) + // 加动效 + console.log(this.data.skuIndex) + this.setData({ + skuFlag: null, + aniSkuIndex: this.data.skuIndex, + cartImgInfo: null + }) + setTimeout(() => { + this.setData({ + aniSkuIndex: -1 + }) + wx.showModal({ + title: "提示", + content: "去购物车结算?", + success: function (res) { + if (res.confirm) { + wx.navigateTo({ + url: '/pages/user/cartlist/list', + }) + } + } + }) + }, 650) + } + }) + } }, - // order: function (e) { - // console.log(this.data.info,this.data.skuFlag) - // if (this.data.skuFlag == 'order'){ - // if (e.currentTarget.dataset.disable == 1) return; - // util.pagePoint({ - // event: 'scene_order', - // param: { - // type: this.data.info.type, - // id: this.data.info.id - // } - // }, 1) - // wx.setStorageSync('login_from', 'scene_order_login') - // wx.setStorageSync('order_from', 'scene_order_submit') - // app.globalData.couponInfo = null; - // app.globalData.retailId = this.data.retailId; - // // let sku = e.currentTarget.dataset.sku,product = e.currentTarget.dataset.product; - // app.globalData.product = e.currentTarget.dataset; - // wx.navigateTo({ - // url: '/pages/order/scene/index', - // }) - // }else { - // commonApi.user_post("cart/add_sku", { - // sku_id: this.data.info.product[0].sku[this.data.skuIndex].id, - // num: this.data.producNum - // }).then(res => { - // if (res.code == 1) { - // commonApi.user_post('cart/get_list', {}).then(res => { - // this.setData({ - // cartCount: res.data.length - // }) - // }) - // // 加动效 - // console.log(this.data.skuIndex) - // this.setData({ - // skuFlag: null, - // aniSkuIndex: this.data.skuIndex, - // cartImgInfo: null - // }) - // setTimeout(() => { - // this.setData({ - // aniSkuIndex: -1 - // }) - // wx.showModal({ - // title: "提示", - // content: "去购物车结算?", - // success: function (res) { - // if (res.confirm) { - // wx.navigateTo({ - // url: '/pages/user/cartlist/list', - // }) - // } - // } - // }) - // }, 650) - // } - // }) - // } - // }, pagePoint: function (e) { util.pagePoint({ event: e.currentTarget.dataset.event, @@ -626,6 +606,12 @@ Page({ * 生命周期函数--监听页面显示 */ onShow: function () { + commonApi.user_post('cart/get_list', {}).then(res => { + console.log(res,res.data) + this.setData({ + cartCount: res.data.length + }) + }) if (!wx.getStorageSync('jstrip_token')) { return; } @@ -664,12 +650,6 @@ Page({ } }) } - commonApi.user_post('cart/get_list', {}).then(res => { - console.log(res,res.data) - this.setData({ - cartCount: res.data.length - }) - }) } else { setTimeout(() => { diff --git a/pages/info/sceneProductInfo/index.wxml b/pages/info/sceneProductInfo/index.wxml index 2279ba9..a2d5f8d 100644 --- a/pages/info/sceneProductInfo/index.wxml +++ b/pages/info/sceneProductInfo/index.wxml @@ -57,9 +57,9 @@ {{sku.price?sku.price/100:0}} - 立即预订 + class="btn{{item.flag==0 || sku.flag=='off'?' disable':''}}">立即预订 -->