Browse Source

购物车

master
chenkainan 4 years ago
parent
commit
c9a1ef5e27
  1. 144
      pages/info/sceneProductInfo/index.js
  2. 4
      pages/info/sceneProductInfo/index.wxml

144
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(() => {

4
pages/info/sceneProductInfo/index.wxml

@ -57,9 +57,9 @@
</view>
<view class="product-right">
<view class="price"><text>¥</text><text>{{sku.price?sku.price/100:0}}</text><text>起</text></view>
<view bindtap="order" data-sku="{{sku}}" data-product="{{item}}"
<!-- <view bindtap="order" data-sku="{{sku}}" data-product="{{item}}"
data-disable="{{item.flag==0 || sku.flag=='off'?1:0}}"
class="btn{{item.flag==0 || sku.flag=='off'?' disable':''}}">立即预订</view>
class="btn{{item.flag==0 || sku.flag=='off'?' disable':''}}">立即预订</view> -->
</view>
</view>
</view>

Loading…
Cancel
Save