Browse Source

景点增加库存校验

master
chenkainan 4 years ago
parent
commit
8d742a2a34
  1. 127
      pages/info/sceneProductInfo/index.js

127
pages/info/sceneProductInfo/index.js

@ -251,65 +251,74 @@ Page({
})
},
order: function (e) {
// console.log(this.data.info,this.data.skuFlag)
app.globalData.postProduct = []
app.globalData.list = []
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;
// let sku = {sku:e.currentTarget.dataset.product.sku[this.data.skuIndex]},product = {product: e.currentTarget.dataset.product}
let sku = {sku:this.data.skuList[this.data.skuIndex]},product = {product:this.data.info.product[this.data.skuList[this.data.skuIndex].proIndex]}
app.globalData.product = {...sku,...product}
wx.navigateTo({
url: '/pages/order/scene/index',
})
}else {
commonApi.user_post("cart/add_sku", {
sku_id: this.data.skuList[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
})
})
// 加动效
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)
}
})
}
commonApi.user_post("/product/checkStock",{
sku_id: this.data.skuList[this.data.skuIndex].id,
}).then(res => {
console.log(res)
if(res && res.code != 1){
return;
}else{
// console.log(this.data.info,this.data.skuFlag)
app.globalData.postProduct = []
app.globalData.list = []
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;
// let sku = {sku:e.currentTarget.dataset.product.sku[this.data.skuIndex]},product = {product: e.currentTarget.dataset.product}
let sku = {sku:this.data.skuList[this.data.skuIndex]},product = {product:this.data.info.product[this.data.skuList[this.data.skuIndex].proIndex]}
app.globalData.product = {...sku,...product}
wx.navigateTo({
url: '/pages/order/scene/index',
})
}else {
commonApi.user_post("cart/add_sku", {
sku_id: this.data.skuList[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
})
})
// 加动效
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({

Loading…
Cancel
Save