no message
This commit is contained in:
parent
2937f621fc
commit
8163e11ded
@ -67,7 +67,8 @@
|
||||
|
||||
</view>
|
||||
<view class="">
|
||||
<u-number-box v-model="value" @change="valChange" button-size="18"></u-number-box>
|
||||
<u-number-box v-model="value" @change="valChange" button-size="18"
|
||||
:disablePlus="flag"></u-number-box>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
@ -77,7 +78,8 @@
|
||||
<view style="color: #666666;font-size: 14px;">共{{value}}件商品,合计:</view>
|
||||
<view style="color: red;"> <text style="font-weight: bold;font-size: 20px;">{{allPoints}}</text> 积分
|
||||
</view>
|
||||
<view style="color: red;"> <text style="font-weight: bold;font-size: 20px;">+¥{{allAmout}}</text>
|
||||
<view v-if="allAmout>0" style="color: red;"> <text
|
||||
style="font-weight: bold;font-size: 20px;">+¥{{allAmout}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@ -91,7 +93,7 @@
|
||||
<view class="">
|
||||
<view style="color: red;">
|
||||
<text style="font-weight: bold;font-size: 20px;">{{allPoints}}</text> 积分
|
||||
<text style="font-weight: bold;font-size: 20px;">+¥{{allAmout}}</text>
|
||||
<text v-if="allAmout>0" style="font-weight: bold;font-size: 20px;">+¥{{allAmout}}</text>
|
||||
</view>
|
||||
<view style="color: #9d9d9d; font-size: 12px; ">积分账户{{myPoints}}</view>
|
||||
</view>
|
||||
@ -118,6 +120,7 @@
|
||||
return {
|
||||
myPoints: 0, //我的积分
|
||||
goodsInfo: '',
|
||||
flag: false, // 禁用
|
||||
title: '',
|
||||
qhindex: 0,
|
||||
value: 1,
|
||||
@ -125,7 +128,7 @@
|
||||
allPoints: 0,
|
||||
allAmout: 0,
|
||||
addrInfo: {
|
||||
address: '请填写地址'
|
||||
address: ''
|
||||
},
|
||||
|
||||
tapList: [{
|
||||
@ -145,27 +148,30 @@
|
||||
onLoad() {
|
||||
uni.$on('goodsInfo', (data) => {
|
||||
this.goodsInfo = data
|
||||
console.log("from 11", data)
|
||||
if (this.goodsInfo != null) {
|
||||
this.dataProcessing()
|
||||
this.allData()
|
||||
}
|
||||
})
|
||||
uni.$emit('un')
|
||||
|
||||
|
||||
},
|
||||
|
||||
onShow() {
|
||||
uni.$on('chooseAddr', (data) => {
|
||||
this.addrInfo = data
|
||||
})
|
||||
uni.$emit('unChooseAddr')
|
||||
|
||||
if (this.addrInfo == '' || this.addrInfo == null) {
|
||||
if (this.addrInfo.address == '' || this.addrInfo == null) {
|
||||
this.getAddr()
|
||||
}
|
||||
// 查询剩余积分
|
||||
this.getUserInfoList()
|
||||
|
||||
|
||||
this.transferIndex(0)
|
||||
|
||||
},
|
||||
|
||||
|
||||
@ -183,10 +189,36 @@
|
||||
|
||||
},
|
||||
valChange(e) {
|
||||
|
||||
|
||||
// remaining_inventory
|
||||
console.log('当前值为: ' + e.value)
|
||||
console.log('当前值为123: ' + this.goodsInfo.remainingInventory)
|
||||
if (e.value >= this.goodsInfo.remainingInventory) {
|
||||
e.value = this.goodsInfo.remainingInventory
|
||||
this.value = this.goodsInfo.remainingInventory
|
||||
this.flag = true
|
||||
this.allData()
|
||||
} else {
|
||||
this.value = e.value
|
||||
this.allData()
|
||||
}
|
||||
|
||||
},
|
||||
transferIndex(index) {
|
||||
this.qhindex = index
|
||||
// this.qhindex = index
|
||||
|
||||
const deliveryData = JSON.parse(this.goodsInfo.deliveryMethod);
|
||||
console.log("deliveryData", deliveryData)
|
||||
if (deliveryData.length >= 2) {
|
||||
this.qhindex = index
|
||||
} else if (deliveryData[0] == '到店自提') {
|
||||
this.qhindex = 0
|
||||
} else if (deliveryData[0] == '物流配送') {
|
||||
this.qhindex = 1
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
goAdd() {
|
||||
uni.navigateTo({
|
||||
@ -198,30 +230,64 @@
|
||||
},
|
||||
// 金额计算
|
||||
allData() {
|
||||
|
||||
console.log("hhhhhhhhhhhhhhhhhhhhhhhhh")
|
||||
this.allPoints = 0
|
||||
this.allAmout = 0
|
||||
let allPoints = new BigNumber(this.goodsInfo.exchangePoints)
|
||||
let allAmout = new BigNumber(this.goodsInfo.exchangeAmount)
|
||||
|
||||
// 数量
|
||||
if (this.value < 1) {
|
||||
this.value = 1
|
||||
}
|
||||
// if (this.value < 1) {
|
||||
// this.value = 1
|
||||
// }
|
||||
let value = new BigNumber(this.value)
|
||||
|
||||
allPoints = allPoints.times(value)
|
||||
console.log("allPoints", allPoints)
|
||||
if (this.goodsInfo.exchangeMethod == '积分+金额') {
|
||||
let allAmout = new BigNumber(this.goodsInfo.exchangeAmount)
|
||||
|
||||
allAmout = allAmout.times(value)
|
||||
if (this.goodsInfo.exchangePoints < 0) {
|
||||
allAmout = 0
|
||||
}
|
||||
this.allAmout = Number(allAmout).toFixed(2);
|
||||
|
||||
}
|
||||
|
||||
|
||||
// 计算加钱购
|
||||
|
||||
console.log("hhhhhhhhhhhhhhhhhhhhhhhhh11", allPoints)
|
||||
if (this.goodsInfo.exchangeMethod === '积分+加钱购') {
|
||||
// 积分相减
|
||||
|
||||
let data = this.shoppingCart[0]; //
|
||||
// 计算加钱购商品一共多少积分
|
||||
let markPurchases = new BigNumber(data.markPurchases);
|
||||
let exchangePoints = allPoints.multipliedBy(new BigNumber(data.exchangePoints));
|
||||
// 拿到总的积分
|
||||
this.member.points = this.member.points ? this.member.points : 0
|
||||
let points = this.myPoints - allPoints; // 使用 toNumber() 获取 BigNumber 的数值
|
||||
|
||||
// 以及分等一多少
|
||||
if (points < 0) {
|
||||
|
||||
// 计算需要的金额
|
||||
points = Math.abs(points);
|
||||
|
||||
|
||||
allAmout = points * this.goodsInfo.moneyRatio; // 直接使用 JavaScript 中的乘法
|
||||
this.allAmout = allAmout.toFixed(2);
|
||||
// this.allAmout = Number(allAmout).toFixed(2);
|
||||
|
||||
} else {
|
||||
|
||||
this.allAmout = 0
|
||||
this.allPoints = exchangePoints.toNumber();
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 更新组件的值
|
||||
this.allPoints = Number(allPoints).toFixed(2);
|
||||
this.allAmout = Number(allAmout).toFixed(2);
|
||||
},
|
||||
|
||||
|
||||
@ -248,13 +314,28 @@
|
||||
request({
|
||||
url: '/business/userManager/user/getByUniApp',
|
||||
method: 'get',
|
||||
// params:{}
|
||||
params: {
|
||||
chainStoreId: uni.getStorageSync('chainStoreId')
|
||||
}
|
||||
}).then((res) => {
|
||||
if (res.code == 200) {
|
||||
this.myPoints = res.data.points
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
// 根据storeid 查找店铺信息
|
||||
getStroeById() {
|
||||
request({
|
||||
url: 'business/storeInformation/store',
|
||||
method: 'get',
|
||||
// params:{}
|
||||
}).then((res) => {
|
||||
if (res.code == 200) {
|
||||
this.myPoints = res.data.points
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
Loading…
Reference in New Issue
Block a user