|
@@ -11,6 +11,8 @@ Page({
|
|
data: {
|
|
data: {
|
|
imgUrls: [],
|
|
imgUrls: [],
|
|
datas: {},
|
|
datas: {},
|
|
|
|
+ goodsIdMap: '',
|
|
|
|
+ bundleList: '', // 套餐
|
|
getOneSummary: [],
|
|
getOneSummary: [],
|
|
webViewUrl: '',
|
|
webViewUrl: '',
|
|
indicatorDots: true,
|
|
indicatorDots: true,
|
|
@@ -34,7 +36,8 @@ Page({
|
|
current: 0,
|
|
current: 0,
|
|
carouselImgs: [],
|
|
carouselImgs: [],
|
|
currentPrice: '', // 商品当前价格,
|
|
currentPrice: '', // 商品当前价格,
|
|
- promotionDays: ''
|
|
|
|
|
|
+ promotionDays: '',
|
|
|
|
+ bundleIndex: -1
|
|
},
|
|
},
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -42,16 +45,16 @@ Page({
|
|
*/
|
|
*/
|
|
onLoad: function (options) {
|
|
onLoad: function (options) {
|
|
// let webViewUrl = `https://passport.lrlz.com/mobile/index.php?act=goods_common&op=detail&goods_id=${options.goods_id}&client_type=ios`
|
|
// let webViewUrl = `https://passport.lrlz.com/mobile/index.php?act=goods_common&op=detail&goods_id=${options.goods_id}&client_type=ios`
|
|
- // this.setData({
|
|
|
|
- // webViewUrl,
|
|
|
|
- // options_goods_id: options.goods_id
|
|
|
|
- // })
|
|
|
|
|
|
+ this.setData({
|
|
|
|
+ // webViewUrl,
|
|
|
|
+ options_goods_id: options.goods_id
|
|
|
|
+ })
|
|
setInterval(() => {
|
|
setInterval(() => {
|
|
this.setData({
|
|
this.setData({
|
|
countTime: --this.data.countTime
|
|
countTime: --this.data.countTime
|
|
})
|
|
})
|
|
}, 1000);
|
|
}, 1000);
|
|
-
|
|
|
|
|
|
+
|
|
|
|
|
|
// console.log(options.goods_id);
|
|
// console.log(options.goods_id);
|
|
this.getDatas(options.goods_id)
|
|
this.getDatas(options.goods_id)
|
|
@@ -67,9 +70,9 @@ Page({
|
|
// goods_id: 7636
|
|
// goods_id: 7636
|
|
// goods_id: 4807
|
|
// goods_id: 4807
|
|
// goods_id: 2
|
|
// goods_id: 2
|
|
- }, function(res) {
|
|
|
|
|
|
+ }, function (res) {
|
|
var str = res.split(/<[\/]?body>/gi)[1];
|
|
var str = res.split(/<[\/]?body>/gi)[1];
|
|
- WxParse.wxParse('article', 'html', str, that);
|
|
|
|
|
|
+ WxParse.wxParse('article', 'html', str, that);
|
|
});
|
|
});
|
|
|
|
|
|
},
|
|
},
|
|
@@ -87,17 +90,36 @@ Page({
|
|
if (res.code == 200) {
|
|
if (res.code == 200) {
|
|
console.log(res);
|
|
console.log(res);
|
|
self.createStars(res.datas.common_info.comments_rate)
|
|
self.createStars(res.datas.common_info.comments_rate)
|
|
- if(res.datas.comments) {
|
|
|
|
|
|
+ if (res.datas.comments) {
|
|
self.createComments(res.datas.comments)
|
|
self.createComments(res.datas.comments)
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ let goodsIdMap
|
|
|
|
+ if (!self.data.goodsIdMap) {
|
|
|
|
+ goodsIdMap = new Map()
|
|
|
|
+ res.datas.summary.map(item => {
|
|
|
|
+ goodsIdMap.set(item['goods_id'], item)
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
let oneSummary = self.getOneSummary(res.datas.summary, goods_id)
|
|
let oneSummary = self.getOneSummary(res.datas.summary, goods_id)
|
|
- console.log('oneSummary:', oneSummary);
|
|
|
|
|
|
+ // console.log('oneSummary:', oneSummary);
|
|
|
|
+ let bundleList = ''
|
|
|
|
+ if (oneSummary['have_bundle']) {
|
|
|
|
+ let bundlingMap = new Map()
|
|
|
|
+ res.datas['bundling'].map(item => {
|
|
|
|
+ bundlingMap.set(item['bl_id'], item)
|
|
|
|
+ })
|
|
|
|
+ let goodsSumaryMap = goodsIdMap ? goodsIdMap : self.data.goodsIdMap
|
|
|
|
+ bundleList = self.createBundles(oneSummary['bundles'], bundlingMap, goodsSumaryMap)
|
|
|
|
+ console.log('bundleList:', bundleList);
|
|
|
|
+ }
|
|
let getgift = self.getgift(res.datas.summary, goods_id)
|
|
let getgift = self.getgift(res.datas.summary, goods_id)
|
|
let differencePrice = (oneSummary.goods_price - oneSummary.bonus_price).toFixed(2)
|
|
let differencePrice = (oneSummary.goods_price - oneSummary.bonus_price).toFixed(2)
|
|
oneSummary = Object.assign({}, { differencePrice }, oneSummary)
|
|
oneSummary = Object.assign({}, { differencePrice }, oneSummary)
|
|
let promotionDays = ''
|
|
let promotionDays = ''
|
|
- if(oneSummary['act_type'] == 2) {
|
|
|
|
|
|
+ if (oneSummary['act_type'] == 2) {
|
|
promotionDays = self.getPromotionDays(oneSummary['act_id'], res.datas.limitime)
|
|
promotionDays = self.getPromotionDays(oneSummary['act_id'], res.datas.limitime)
|
|
}
|
|
}
|
|
self.setData({
|
|
self.setData({
|
|
@@ -105,7 +127,9 @@ Page({
|
|
getOneSummary: oneSummary,
|
|
getOneSummary: oneSummary,
|
|
imgUrls: res.datas.common_info.images,
|
|
imgUrls: res.datas.common_info.images,
|
|
getgift,
|
|
getgift,
|
|
- promotionDays
|
|
|
|
|
|
+ promotionDays,
|
|
|
|
+ goodsIdMap,
|
|
|
|
+ bundleList
|
|
})
|
|
})
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
@@ -147,6 +171,31 @@ Page({
|
|
getgift
|
|
getgift
|
|
})
|
|
})
|
|
},
|
|
},
|
|
|
|
+ // self.createBundles(oneSummary['bundles'],bundlingMap,goodsIdMap)
|
|
|
|
+
|
|
|
|
+ createBundles(bundles, bundlingMap, goodsIdMap) {
|
|
|
|
+ let bundlesList = []
|
|
|
|
+ bundles.map(item => {
|
|
|
|
+ if (bundlingMap.get(item)) {
|
|
|
|
+ let bundlesSumary = []
|
|
|
|
+ let bundling = bundlingMap.get(item)
|
|
|
|
+ let goodsTotalPrice = 0
|
|
|
|
+ bundling['goods'].map(good => {
|
|
|
|
+ let resultGood = goodsIdMap.get(good['goods_id'])
|
|
|
|
+ resultGood['bl_goods_price'] = good['bl_goods_price']
|
|
|
|
+ goodsTotalPrice += parseFloat(resultGood['goods_price'])
|
|
|
|
+ bundlesSumary.push(resultGood)
|
|
|
|
+ })
|
|
|
|
+ let reduce_price = goodsTotalPrice - bundling['bl_price']
|
|
|
|
+ bundling['reduce_price'] = reduce_price
|
|
|
|
+ bundlesList.push({
|
|
|
|
+ bundling,
|
|
|
|
+ bundlesSumary
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ return bundlesList
|
|
|
|
+ },
|
|
goodsNumHandle(e) {
|
|
goodsNumHandle(e) {
|
|
let type = e.currentTarget.dataset.type
|
|
let type = e.currentTarget.dataset.type
|
|
if (type == 'minus') {
|
|
if (type == 'minus') {
|
|
@@ -290,17 +339,17 @@ Page({
|
|
},
|
|
},
|
|
createStars(rate) {
|
|
createStars(rate) {
|
|
let starSrcs = []
|
|
let starSrcs = []
|
|
- for(let i = 0; i < 5; i++) {
|
|
|
|
- if(i < Math.floor(rate)) {
|
|
|
|
|
|
+ for (let i = 0; i < 5; i++) {
|
|
|
|
+ if (i < Math.floor(rate)) {
|
|
starSrcs.push(this.data.activeStar)
|
|
starSrcs.push(this.data.activeStar)
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
- if(i < Math.round(rate)) {
|
|
|
|
|
|
+ if (i < Math.round(rate)) {
|
|
starSrcs.push(this.data.halfStar)
|
|
starSrcs.push(this.data.halfStar)
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
starSrcs.push(this.data.basicStar)
|
|
starSrcs.push(this.data.basicStar)
|
|
- }
|
|
|
|
|
|
+ }
|
|
this.setData({
|
|
this.setData({
|
|
starSrcs
|
|
starSrcs
|
|
})
|
|
})
|
|
@@ -319,7 +368,6 @@ Page({
|
|
}
|
|
}
|
|
return item
|
|
return item
|
|
})
|
|
})
|
|
- // console.log(comments);
|
|
|
|
this.setData({
|
|
this.setData({
|
|
comments
|
|
comments
|
|
})
|
|
})
|
|
@@ -344,6 +392,50 @@ Page({
|
|
show_carousel: false
|
|
show_carousel: false
|
|
})
|
|
})
|
|
},
|
|
},
|
|
|
|
+ // 套装切换展开样式
|
|
|
|
+ toggleBundle(e) {
|
|
|
|
+ let { index } = e.currentTarget.dataset
|
|
|
|
+ if (index == this.data.bundleIndex) {
|
|
|
|
+ index = -1
|
|
|
|
+ }
|
|
|
|
+ this.setData({
|
|
|
|
+ bundleIndex: index
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ bundleDetail(e) {
|
|
|
|
+ let { id } = e.currentTarget.dataset
|
|
|
|
+ if (id == this.data.options_goods_id) return;
|
|
|
|
+ wx.navigateTo({
|
|
|
|
+ url: `/pages/details/details?goods_id=${id}&title=商品详情`
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ addBundleCart(e) {
|
|
|
|
+ console.log(e);
|
|
|
|
+ let bl_id = e.currentTarget.dataset.blid
|
|
|
|
+ getReq({
|
|
|
|
+ act: 'cart',
|
|
|
|
+ op: 'addex',
|
|
|
|
+ quantity: 1,
|
|
|
|
+ bl_id
|
|
|
|
+ }, function (res) {
|
|
|
|
+ console.log(res);
|
|
|
|
+ wx.hideLoading()
|
|
|
|
+ if (res.code == 200) {
|
|
|
|
+ wx.showToast({
|
|
|
|
+ icon: 'none',
|
|
|
|
+ title: '添加成功!',
|
|
|
|
+ duration: 1500
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ wx.showToast({
|
|
|
|
+ icon: 'none',
|
|
|
|
+ title: res.message,
|
|
|
|
+ duration: 1500
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
|
|
/**
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
* 生命周期函数--监听页面初次渲染完成
|