|
@@ -8,6 +8,7 @@
|
|
:buttonGroup="buttonGroup"
|
|
:buttonGroup="buttonGroup"
|
|
@click="onClick"
|
|
@click="onClick"
|
|
@buttonClick="buttonClick"
|
|
@buttonClick="buttonClick"
|
|
|
|
+ :navType="navType"
|
|
/>
|
|
/>
|
|
</view>
|
|
</view>
|
|
<cm-drawer :visible="countVisible" @close="drawerClose" position="bottom">
|
|
<cm-drawer :visible="countVisible" @close="drawerClose" position="bottom">
|
|
@@ -47,14 +48,16 @@ export default {
|
|
},
|
|
},
|
|
filters: {
|
|
filters: {
|
|
priceFormat(price) {
|
|
priceFormat(price) {
|
|
|
|
+ if (!price) return ''
|
|
return Number(price).toFixed(2)
|
|
return Number(price).toFixed(2)
|
|
}
|
|
}
|
|
},
|
|
},
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
count: 1,
|
|
count: 1,
|
|
|
|
+ navType: 2,
|
|
countVisible: false,
|
|
countVisible: false,
|
|
- buyRetailPrice: 0,
|
|
|
|
|
|
+ buyPrice: 0,
|
|
btnClickType: -1,
|
|
btnClickType: -1,
|
|
options: [
|
|
options: [
|
|
{
|
|
{
|
|
@@ -74,33 +77,41 @@ export default {
|
|
infoColor: '#ffffff'
|
|
infoColor: '#ffffff'
|
|
}
|
|
}
|
|
],
|
|
],
|
|
- buttonGroup: [
|
|
|
|
- {
|
|
|
|
- text: '加入购物车',
|
|
|
|
- backgroundColor: '#FFEFF4',
|
|
|
|
- color: '#FF457B'
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- text: '立即购买',
|
|
|
|
- backgroundColor: 'linear-gradient(90deg, #FC32B4 0%, #F83C6C 100%)',
|
|
|
|
- color: '#fff'
|
|
|
|
- }
|
|
|
|
- ]
|
|
|
|
|
|
+
|
|
|
|
+ leftButton: {
|
|
|
|
+ text: '加入购物车',
|
|
|
|
+ price: 1000,
|
|
|
|
+ backgroundColor: '#FFEFF4',
|
|
|
|
+ color: '#FF457B'
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ rightButton: {
|
|
|
|
+ text: '立即购买',
|
|
|
|
+ price: 800,
|
|
|
|
+ backgroundColor: 'linear-gradient(90deg, #FC32B4 0%, #F83C6C 100%)',
|
|
|
|
+ color: '#fff'
|
|
|
|
+ }
|
|
}
|
|
}
|
|
},
|
|
},
|
|
computed: {
|
|
computed: {
|
|
- ...mapGetters(['isIphoneX', 'kindCount', 'hasLogin'])
|
|
|
|
|
|
+ ...mapGetters(['isIphoneX', 'kindCount', 'hasLogin']),
|
|
|
|
+ buttonGroup() {
|
|
|
|
+ return [this.leftButton, this.rightButton]
|
|
|
|
+ },
|
|
|
|
+ buyRetailPrice() {
|
|
|
|
+ return this.processActivityPrice()
|
|
|
|
+ }
|
|
},
|
|
},
|
|
watch: {
|
|
watch: {
|
|
kindCount(newCount) {
|
|
kindCount(newCount) {
|
|
this.options[2].info = newCount
|
|
this.options[2].info = newCount
|
|
},
|
|
},
|
|
- count() {
|
|
|
|
- if (!this.productInfo) return
|
|
|
|
- this.processActivityPrice()
|
|
|
|
- },
|
|
|
|
- countVisible(newVal) {
|
|
|
|
- if (newVal) this.processActivityPrice()
|
|
|
|
|
|
+ productInfo: {
|
|
|
|
+ deep: true,
|
|
|
|
+ handler: function(nVal) {
|
|
|
|
+ console.log(nVal)
|
|
|
|
+ this.resetButtonInfo()
|
|
|
|
+ }
|
|
}
|
|
}
|
|
},
|
|
},
|
|
created() {
|
|
created() {
|
|
@@ -109,6 +120,21 @@ export default {
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
...mapActions('cart', ['addToCart', 'getCartNumber']),
|
|
...mapActions('cart', ['addToCart', 'getCartNumber']),
|
|
|
|
+
|
|
|
|
+ // 处理购买按钮信息
|
|
|
|
+ resetButtonInfo() {
|
|
|
|
+ if (this.navType === 1) {
|
|
|
|
+ this.leftButton.text = '加入购物车'
|
|
|
|
+ this.rightButton.text = '立即购买'
|
|
|
|
+ }
|
|
|
|
+ if (this.navType === 2) {
|
|
|
|
+ this.leftButton.text = '单独购买'
|
|
|
|
+ this.leftButton.price = this.buyRetailPrice
|
|
|
|
+ this.rightButton.text = '拼团购买'
|
|
|
|
+ this.rightButton.price = this.productInfo.price
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+
|
|
countChange(value) {
|
|
countChange(value) {
|
|
this.count = value
|
|
this.count = value
|
|
},
|
|
},
|
|
@@ -136,16 +162,24 @@ export default {
|
|
buttonClick(e) {
|
|
buttonClick(e) {
|
|
this.countVisible = true
|
|
this.countVisible = true
|
|
this.btnClickType = e.index
|
|
this.btnClickType = e.index
|
|
- this.processActivityPrice()
|
|
|
|
},
|
|
},
|
|
// 确认
|
|
// 确认
|
|
confirm() {
|
|
confirm() {
|
|
this.countVisible = false
|
|
this.countVisible = false
|
|
- const clickFns = {
|
|
|
|
- 0: this.joinCart,
|
|
|
|
- 1: this.buyNow
|
|
|
|
|
|
+ if(this.navType === 1){
|
|
|
|
+ const clickFns = {
|
|
|
|
+ 0: this.joinCart,
|
|
|
|
+ 1: this.buyNow
|
|
|
|
+ }
|
|
|
|
+ clickFns[this.btnClickType]()
|
|
|
|
+ }
|
|
|
|
+ if(this.navType === 2){
|
|
|
|
+ const clickFns = {
|
|
|
|
+ 0: this.buyNow,
|
|
|
|
+ 1: this.buyGroupNow
|
|
|
|
+ }
|
|
|
|
+ clickFns[this.btnClickType]()
|
|
}
|
|
}
|
|
- clickFns[this.btnClickType]()
|
|
|
|
},
|
|
},
|
|
// 跳转首页
|
|
// 跳转首页
|
|
toHome() {
|
|
toHome() {
|
|
@@ -189,16 +223,22 @@ export default {
|
|
)
|
|
)
|
|
this.countVisible = false
|
|
this.countVisible = false
|
|
},
|
|
},
|
|
|
|
+ // 拼团购买
|
|
|
|
+ buyGroupNow(){
|
|
|
|
+ if (!this.hasLogin) return this.toLogin()
|
|
|
|
+ console.log('拼团购买')
|
|
|
|
+ this.countVisible = false
|
|
|
|
+ },
|
|
//单独处理活动价格和阶梯价格
|
|
//单独处理活动价格和阶梯价格
|
|
processActivityPrice() {
|
|
processActivityPrice() {
|
|
- this.buyRetailPrice = this.productInfo.price
|
|
|
|
if (this.productInfo.activeStatus === 1 && this.productInfo.ladderList) {
|
|
if (this.productInfo.activeStatus === 1 && this.productInfo.ladderList) {
|
|
this.productInfo.ladderList.forEach((item, index) => {
|
|
this.productInfo.ladderList.forEach((item, index) => {
|
|
if (this.count >= item.buyNum) {
|
|
if (this.count >= item.buyNum) {
|
|
- this.buyRetailPrice = item.buyPrice
|
|
|
|
|
|
+ return item.buyPrice
|
|
}
|
|
}
|
|
})
|
|
})
|
|
}
|
|
}
|
|
|
|
+ return this.productInfo.price
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|