diff --git a/gasStation-uni/pagesHome/order/order.vue b/gasStation-uni/pagesHome/order/order.vue index e8b9b2ba2..50f072c08 100644 --- a/gasStation-uni/pagesHome/order/order.vue +++ b/gasStation-uni/pagesHome/order/order.vue @@ -67,7 +67,8 @@ - + @@ -77,7 +78,8 @@ 共{{value}}件商品,合计: {{allPoints}} 积分 - +¥{{allAmout}} + +¥{{allAmout}} @@ -91,7 +93,7 @@ {{allPoints}} 积分 - +¥{{allAmout}} + +¥{{allAmout}} 积分账户{{myPoints}} @@ -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 + } + }) + } } }