|
@@ -16,10 +16,11 @@ Page({
|
|
|
autoplay: true,
|
|
|
interval: 2000,
|
|
|
duration: 500,
|
|
|
- animation_flag: false,
|
|
|
+ animation_flag: true,
|
|
|
sec_index: 0,
|
|
|
goodsNumber: 1,
|
|
|
- cartOrBuy: ''
|
|
|
+ cartOrBuy: '',
|
|
|
+ getgift: ''
|
|
|
},
|
|
|
|
|
|
/**
|
|
@@ -30,8 +31,8 @@ Page({
|
|
|
this.setData({
|
|
|
webViewUrl
|
|
|
})
|
|
|
- // this.getDatas(options.goods_id)
|
|
|
- this.getDatas(6779)
|
|
|
+ this.getDatas(options.goods_id)
|
|
|
+ // this.getDatas(6779)
|
|
|
},
|
|
|
getDatas(goods_id) {
|
|
|
wx.showLoading({
|
|
@@ -46,10 +47,12 @@ Page({
|
|
|
wx.hideLoading()
|
|
|
if (res.code == 200) {
|
|
|
let oneSummary = self.getOneSummary(res.datas.summary, goods_id)
|
|
|
+ let getgift = self.getgift(res.datas.summary, goods_id)
|
|
|
self.setData({
|
|
|
datas: res.datas,
|
|
|
getOneSummary: oneSummary,
|
|
|
- imgUrls: res.datas.common_info.images
|
|
|
+ imgUrls: res.datas.common_info.images,
|
|
|
+ getgift
|
|
|
})
|
|
|
|
|
|
}
|
|
@@ -57,7 +60,7 @@ Page({
|
|
|
wx.showToast({
|
|
|
icon: 'none',
|
|
|
title: res.message,
|
|
|
- duration: 2000
|
|
|
+ duration: 1500
|
|
|
})
|
|
|
}
|
|
|
})
|
|
@@ -75,10 +78,20 @@ Page({
|
|
|
return
|
|
|
}
|
|
|
let getOneSummary = this.getOneSummary(this.data.datas.summary, goodsId)
|
|
|
+ let getgift = this.getgift(this.data.datas.summary, goodsId)
|
|
|
+ if (getOneSummary.goods_storage < 1) {
|
|
|
+ wx.showToast({
|
|
|
+ title: '客官!暂时没有库存!',
|
|
|
+ icon: 'none',
|
|
|
+ duration: 1500
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
this.setData({
|
|
|
sec_index,
|
|
|
getOneSummary,
|
|
|
- goodsNumber: 1
|
|
|
+ goodsNumber: 1,
|
|
|
+ getgift
|
|
|
})
|
|
|
},
|
|
|
goodsNumHandle(e) {
|
|
@@ -88,7 +101,7 @@ Page({
|
|
|
wx.showToast({
|
|
|
title: '客官!不能再少了!',
|
|
|
icon: 'none',
|
|
|
- duration: 2000
|
|
|
+ duration: 1500
|
|
|
})
|
|
|
return
|
|
|
}
|
|
@@ -103,7 +116,7 @@ Page({
|
|
|
wx.showToast({
|
|
|
title: '客官!只有这么多了!',
|
|
|
icon: 'none',
|
|
|
- duration: 2000
|
|
|
+ duration: 1500
|
|
|
})
|
|
|
return
|
|
|
}
|
|
@@ -133,19 +146,19 @@ Page({
|
|
|
if (res.code == 200) {
|
|
|
wx.showToast({
|
|
|
title: '添加成功!',
|
|
|
- duration: 2000
|
|
|
+ duration: 1500
|
|
|
})
|
|
|
}
|
|
|
else {
|
|
|
wx.showToast({
|
|
|
icon: 'none',
|
|
|
title: res.message,
|
|
|
- duration: 2000
|
|
|
+ duration: 1500
|
|
|
})
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
- else if (cartOrBuy == 'isBuy') {
|
|
|
+ else if (cartOrBuy == 'isBuy') {
|
|
|
wx.navigateTo({
|
|
|
url: `/pages/confirmOrder/confirmOrder?goods_id=${this.data.getOneSummary.goods_id}&iscart=0&num=${this.data.goodsNumber}`
|
|
|
})
|
|
@@ -170,6 +183,28 @@ Page({
|
|
|
cartOrBuy
|
|
|
})
|
|
|
},
|
|
|
+ getgift(sumarys, goods_id) {
|
|
|
+ let goods = this.getOneSummary(sumarys, goods_id)
|
|
|
+ let giftSummary = ''
|
|
|
+ if (goods.have_gift) {
|
|
|
+ giftSummary = this.getGiftSummary(sumarys, goods.gifts)
|
|
|
+ }
|
|
|
+ return giftSummary
|
|
|
+ },
|
|
|
+ getGiftSummary(sumarys, gifts) {
|
|
|
+ let arr = []
|
|
|
+ gifts.map(item => {
|
|
|
+ sumarys.filter(sum => {
|
|
|
+ if(item.gift_goods_id == sum.goods_id) {
|
|
|
+ arr.push({
|
|
|
+ sum,
|
|
|
+ gifts: item
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
+ return arr
|
|
|
+ },
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面初次渲染完成
|