|
|
|
@ -25,13 +25,14 @@ Page({ |
|
|
|
showAllowance: false, |
|
|
|
allowance_data:null, |
|
|
|
//购物车数量
|
|
|
|
producNum: 1, |
|
|
|
skuIndex: 0, |
|
|
|
aniSkuIndex: -1, |
|
|
|
cartCount: 0, |
|
|
|
cartImgInfo: null, |
|
|
|
cartTop: 0, |
|
|
|
top: 0 |
|
|
|
producNum: 1, |
|
|
|
skuIndex: 0, |
|
|
|
aniSkuIndex: -1, |
|
|
|
cartCount: 0, |
|
|
|
cartImgInfo: null, |
|
|
|
cartTop: 0, |
|
|
|
top: 0, |
|
|
|
skuList:[],//立即预定的列表
|
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
@ -96,7 +97,16 @@ Page({ |
|
|
|
this.setData({ |
|
|
|
info: res.data |
|
|
|
}) |
|
|
|
var arr = [] |
|
|
|
console.log(this.data.info); |
|
|
|
res.data.product.forEach(item => { |
|
|
|
item.sku.forEach(itemB=>{ |
|
|
|
arr.push(itemB) |
|
|
|
}) |
|
|
|
}); |
|
|
|
this.setData({ |
|
|
|
skuList:arr |
|
|
|
}) |
|
|
|
util.pagePoint({ event: 'scene_view', param: { type: res.data.type, id: res.data.id } }, 1) |
|
|
|
this.BroswerRecord() |
|
|
|
}) |
|
|
|
@ -118,7 +128,6 @@ Page({ |
|
|
|
this.setData({ |
|
|
|
ask: res.data.rows |
|
|
|
}) |
|
|
|
console.log(res) |
|
|
|
}) |
|
|
|
// 获取评价列表
|
|
|
|
commonApi._post("scene/get_comment", { |
|
|
|
@ -171,7 +180,6 @@ Page({ |
|
|
|
}, |
|
|
|
like: function () { |
|
|
|
let id = this.data.id, isLike = Number(this.data.isLike); |
|
|
|
console.log(isLike) |
|
|
|
commonApi.user_post(isLike != 1 ? "scene/scene_collection" : "scene/scene_cancel_collection", { |
|
|
|
scene_id: id |
|
|
|
}).then(res => { |
|
|
|
@ -237,14 +245,12 @@ Page({ |
|
|
|
// })
|
|
|
|
// },
|
|
|
|
selectSku: function (e) { |
|
|
|
console.log(e) |
|
|
|
let index = e.currentTarget.dataset.index; |
|
|
|
this.setData({ |
|
|
|
skuIndex: index |
|
|
|
}) |
|
|
|
}, |
|
|
|
order: function (e) { |
|
|
|
console.log(e,e.currentTarget.dataset.product.sku[this.data.skuIndex]) |
|
|
|
// console.log(this.data.info,this.data.skuFlag)
|
|
|
|
app.globalData.postProduct = [] |
|
|
|
app.globalData.list = [] |
|
|
|
@ -261,16 +267,20 @@ Page({ |
|
|
|
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} |
|
|
|
app.globalData.product = {...sku,...product} |
|
|
|
// 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: e.currentTarget.dataset.product} |
|
|
|
app.globalData.product = {...sku,...product} |
|
|
|
console.log(this.data.skuIndex); |
|
|
|
console.log(app.globalData.product); |
|
|
|
// app.globalData.product = e.currentTarget.dataset;
|
|
|
|
wx.navigateTo({ |
|
|
|
url: '/pages/order/scene/index', |
|
|
|
}) |
|
|
|
}else { |
|
|
|
console.log('111'); |
|
|
|
commonApi.user_post("cart/add_sku", { |
|
|
|
sku_id: this.data.info.product[0].sku[this.data.skuIndex].id, |
|
|
|
sku_id: this.data.skuList[this.data.skuIndex].id, |
|
|
|
num: this.data.producNum |
|
|
|
}).then(res => { |
|
|
|
if (res.code == 1) { |
|
|
|
@ -280,7 +290,6 @@ Page({ |
|
|
|
}) |
|
|
|
}) |
|
|
|
// 加动效
|
|
|
|
console.log(this.data.skuIndex) |
|
|
|
this.setData({ |
|
|
|
skuFlag: null, |
|
|
|
aniSkuIndex: this.data.skuIndex, |
|
|
|
@ -573,7 +582,6 @@ Page({ |
|
|
|
}, |
|
|
|
//加入购物车
|
|
|
|
showCart: function () { |
|
|
|
console.log(this.data) |
|
|
|
if (this.data.info.product[0].sku.length == 0) { |
|
|
|
wx.showToast({ |
|
|
|
title: '该产品未设置规格,不能加购', |
|
|
|
@ -586,7 +594,6 @@ Page({ |
|
|
|
}) |
|
|
|
let that = this |
|
|
|
wx.createSelectorQuery().select('#skuImg').boundingClientRect(function (res) { |
|
|
|
console.log(res) |
|
|
|
that.setData({ |
|
|
|
cartImgInfo: 'top:' + res.top + 'px;left:' + res.left + 'px;' |
|
|
|
}) |
|
|
|
@ -646,7 +653,6 @@ Page({ |
|
|
|
*/ |
|
|
|
onShow: function () { |
|
|
|
commonApi.user_post('cart/get_list', {}).then(res => { |
|
|
|
console.log(res,res.data) |
|
|
|
this.setData({ |
|
|
|
cartCount: res.data.length |
|
|
|
}) |
|
|
|
@ -661,15 +667,12 @@ Page({ |
|
|
|
commonApi.user_post("product/getProductAllowancePrice", { |
|
|
|
product_code: this.data.product[0].product.product_code |
|
|
|
}).then(resTwo => { |
|
|
|
console.log(resTwo) |
|
|
|
if (resTwo && resTwo.code == 1) { |
|
|
|
this.setData({ |
|
|
|
allowance_data: resTwo.data |
|
|
|
}) |
|
|
|
let spread_price = Number(this.data.allowance_data.discount_limit_price - this.data.allowance_data.user_used_price) |
|
|
|
let sInfo = this.data.product[0].sku |
|
|
|
console.log(9999, this.data.allowance_data.discount_rate / 100 * sInfo.price) |
|
|
|
console.log(9999, spread_price) |
|
|
|
if (spread_price > 0) { |
|
|
|
if (spread_price < this.data.allowance_data.discount_rate / 100 * sInfo.price) { |
|
|
|
this.setData({ |
|
|
|
|