|
|
|
@ -24,6 +24,14 @@ Page({ |
|
|
|
showShareFlag: false, |
|
|
|
showAllowance: false, |
|
|
|
allowance_data:null, |
|
|
|
//购物车数量
|
|
|
|
producNum: 1, |
|
|
|
skuIndex: 0, |
|
|
|
aniSkuIndex: -1, |
|
|
|
cartCount: 0, |
|
|
|
cartImgInfo: null, |
|
|
|
cartTop: 0, |
|
|
|
top: 0 |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
@ -155,7 +163,6 @@ Page({ |
|
|
|
scene_id: id |
|
|
|
}).then(res => { |
|
|
|
if (res.code == 1) { |
|
|
|
console.log(isLike) |
|
|
|
wx.showToast({ |
|
|
|
title: '操作成功', |
|
|
|
}) |
|
|
|
@ -197,24 +204,83 @@ Page({ |
|
|
|
}) |
|
|
|
}, |
|
|
|
order: function (e) { |
|
|
|
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 (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', |
|
|
|
}) |
|
|
|
}, |
|
|
|
// 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, |
|
|
|
@ -480,6 +546,65 @@ Page({ |
|
|
|
ctx.fillText(row[b], x, y + b * 40 * ratio, canvasWidth); |
|
|
|
} |
|
|
|
}, |
|
|
|
//加入购物车
|
|
|
|
showCart: function () { |
|
|
|
console.log(this.data) |
|
|
|
if (this.data.info.product[0].sku.length == 0) { |
|
|
|
wx.showToast({ |
|
|
|
title: '该产品未设置规格,不能加购', |
|
|
|
icon: 'none' |
|
|
|
}) |
|
|
|
return; |
|
|
|
} |
|
|
|
this.setData({ |
|
|
|
skuFlag: "cart" |
|
|
|
}) |
|
|
|
let that = this |
|
|
|
wx.createSelectorQuery().select('#skuImg').boundingClientRect(function (res) { |
|
|
|
console.log(res) |
|
|
|
that.setData({ |
|
|
|
cartImgInfo: 'top:' + res.top + 'px;left:' + res.left + 'px;' |
|
|
|
}) |
|
|
|
}).exec() |
|
|
|
|
|
|
|
}, |
|
|
|
hideSku: function () { |
|
|
|
this.setData({ |
|
|
|
skuFlag: null, |
|
|
|
cartImgInfo: null |
|
|
|
}) |
|
|
|
}, |
|
|
|
//加减数量
|
|
|
|
minus: function () { |
|
|
|
if (this.data.producNum == 1) return; |
|
|
|
this.setData({ |
|
|
|
producNum: this.data.producNum - 1 |
|
|
|
}) |
|
|
|
}, |
|
|
|
add: function () { |
|
|
|
this.setData({ |
|
|
|
producNum: this.data.producNum + 1 |
|
|
|
}) |
|
|
|
}, |
|
|
|
//立即预定
|
|
|
|
showOrder: function () { |
|
|
|
if (this.data.info.product[0].sku.length == 0) { |
|
|
|
wx.showToast({ |
|
|
|
title: '该产品未设置规格,不能购买', |
|
|
|
icon: 'none' |
|
|
|
}) |
|
|
|
return; |
|
|
|
} |
|
|
|
this.setData({ |
|
|
|
skuFlag: 'order' |
|
|
|
}) |
|
|
|
}, |
|
|
|
selectSku: function (e) { |
|
|
|
let index = e.currentTarget.dataset.index; |
|
|
|
this.setData({ |
|
|
|
skuIndex: index |
|
|
|
}) |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
* 生命周期函数--监听页面初次渲染完成 |
|
|
|
@ -539,6 +664,12 @@ Page({ |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
commonApi.user_post('cart/get_list', {}).then(res => { |
|
|
|
console.log(res,res.data) |
|
|
|
this.setData({ |
|
|
|
cartCount: res.data.length |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
else { |
|
|
|
setTimeout(() => { |
|
|
|
|