881 lines
29 KiB
Vue
881 lines
29 KiB
Vue
<template>
|
||
<!-- 订单详情页 -->
|
||
<view class="content">
|
||
<view class="container">
|
||
<view class="my-header">
|
||
<view class="my-icons" @click="goBack"> <uni-icons type="left" size="16"></uni-icons> </view>
|
||
<view class="my-text">支付订单</view>
|
||
<view class="my-icons"></view>
|
||
</view>
|
||
<!-- 顶部区域 -->
|
||
<view style="background-color: white;width: 94%;margin: 15px auto;">
|
||
<view style="font-weight: bold;height: 40px;line-height: 40px;margin-left: 10px;margin-top: 20px;">订单详情
|
||
</view>
|
||
<view class="desc">
|
||
<view>油站名称</view>
|
||
<view>{{store.name}}{{store.description ? "("+store.description+")" : ""}}</view>
|
||
</view>
|
||
<view class="desc">
|
||
<view>油号油枪</view>
|
||
<view>{{oilName}}/{{oilOrder.oilGunNum}}</view>
|
||
</view>
|
||
<view class="desc">
|
||
<view>加油金额</view>
|
||
<view>{{oilOrder.orderAmount}}</view>
|
||
</view>
|
||
<view class="desc">
|
||
<view>加油数量</view>
|
||
<view>{{oilOrder.oilNum}}</view>
|
||
</view>
|
||
<view class="desc">
|
||
<view>油品单价</view>
|
||
<view>{{oilPrice}}/元</view>
|
||
</view>
|
||
<view class="desc">
|
||
<view>加油员工</view>
|
||
<view>{{staff.realName}}</view>
|
||
</view>
|
||
</view>
|
||
|
||
<view style="background-color: white;width: 94%;margin: 15px auto;">
|
||
<view class="desc">
|
||
<view style="display: flex;">
|
||
储值卡
|
||
<span style="color: red;display: flex;">(余额:{{user.cardBalance}})<u-icon name="question-circle"
|
||
color="red"></u-icon></span>
|
||
</view>
|
||
<view style="display: flex;">
|
||
<span style="margin-right: 10px;">-¥{{balanceRedece}}</span>
|
||
<u-checkbox-group>
|
||
<u-checkbox v-model="balance"></u-checkbox>
|
||
</u-checkbox-group>
|
||
</view>
|
||
</view>
|
||
|
||
<view class="desc" v-if="isOilStorageCard == true && refuelMoney.length > 0">
|
||
<view style="display: flex;">
|
||
<u-collapse>
|
||
<u-collapse-item title="囤油卡" :open="true">
|
||
<view v-for="(item,index) in refuelMoney" :key="index">
|
||
{{item.type}}{{item.oilType}}:{{item.refuelMoney}}L
|
||
</view>
|
||
</u-collapse-item>
|
||
</u-collapse>
|
||
<!-- 囤油卡
|
||
<span style="color: red;display: flex;">(余额:0.00)<u-icon name="question-circle"
|
||
color="red"></u-icon></span> -->
|
||
</view>
|
||
<view style="display: flex;">
|
||
<span style="margin-right: 10px;">- {{oilCardRedece}}L</span>
|
||
<u-checkbox-group>
|
||
<u-checkbox v-model="oilCard"></u-checkbox>
|
||
</u-checkbox-group>
|
||
</view>
|
||
</view>
|
||
|
||
<view class="desc">
|
||
<view style="display: flex;">
|
||
<u-collapse>
|
||
<u-collapse-item title="会员等级优惠" :open="true">
|
||
<view v-for="(item,index) in gradeDiscount" :key="index">
|
||
<span v-if="item.type=='满减优惠'">
|
||
{{item.type}}:满{{item.full}}元,减{{item.reduce}}元
|
||
</span>
|
||
<span v-else>
|
||
{{item.type}}:满{{item.full}}元,每升<br/>优惠{{item.liters}}元
|
||
</span>
|
||
</view>
|
||
</u-collapse-item>
|
||
</u-collapse>
|
||
<!-- 会员等级优惠gradeDiscount -->
|
||
</view>
|
||
<view style="display: flex;">
|
||
<span style="margin-right: 10px;">-¥{{gradeRedece}}</span>
|
||
<u-checkbox-group>
|
||
<u-checkbox v-model="grade"></u-checkbox>
|
||
</u-checkbox-group>
|
||
</view>
|
||
</view>
|
||
|
||
<view class="desc" v-if="fullRedece >= couponRedece && exclusion == 0">
|
||
<view style="display: flex;">
|
||
<u-collapse>
|
||
<u-collapse-item title="满减优惠" :open="true">
|
||
<view v-for="(item,index) in fullReduceDiscount" :key="index">
|
||
<span v-if="item.discount!=0">
|
||
{{item.type}}:满{{ item.full }}元,打{{ item.discount }}折
|
||
</span>
|
||
<span v-else>满{{ item.full }}元,减{{ item.reduce }}元</span>
|
||
</view>
|
||
</u-collapse-item>
|
||
</u-collapse>
|
||
<!-- 满减优惠fullReduceDiscount -->
|
||
</view>
|
||
<view style="display: flex;">
|
||
<span style="margin-right: 10px;">-¥{{fullRedece}}</span>
|
||
<u-checkbox-group>
|
||
<u-checkbox v-model="coupon"></u-checkbox>
|
||
</u-checkbox-group>
|
||
</view>
|
||
</view>
|
||
|
||
<view class="desc" v-else>
|
||
<view style="display: flex;">
|
||
<u-collapse>
|
||
<u-collapse-item title="优惠券" :open="true">
|
||
<view v-for="(item,index) in couponDiscount" :key="index">
|
||
满{{ item.full }}元,减{{ item.reduce }}元
|
||
</view>
|
||
</u-collapse-item>
|
||
</u-collapse>
|
||
<!-- 优惠券 couponDiscount -->
|
||
</view>
|
||
<view style="display: flex;">
|
||
<span style="margin-right: 10px;">-¥{{couponRedece}}</span>
|
||
<u-checkbox-group>
|
||
<u-checkbox v-model="coupon"></u-checkbox>
|
||
</u-checkbox-group>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
|
||
<view style="background-color: white;width: 94%;margin: 15px auto;">
|
||
<view style="font-weight: bold;height: 40px;line-height: 40px;margin-left: 10px;margin-top: 20px;">支付方式
|
||
</view>
|
||
<view class="desc">
|
||
<view>微信支付</view>
|
||
<u-radio-group v-model="value">
|
||
<u-radio name="wx"></u-radio>
|
||
</u-radio-group>
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 支付信息 -->
|
||
<view class="bar">
|
||
<view style="margin-left: 20px;">
|
||
<view>
|
||
¥<span style="font-size: 22px;font-weight: bold;">{{payAmount}}</span>
|
||
</view>
|
||
<view style="color: red;font-size: 12px;">应付金额</view>
|
||
</view>
|
||
<view
|
||
style="margin-right: 20px;width: 30%;border-radius:30px;background-color: #1879ff;height: 40px;line-height: 40px;text-align: center;color: white">
|
||
确认支付
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</template>
|
||
|
||
<script>
|
||
import request from '../../utils/request'
|
||
export default {
|
||
data() {
|
||
return {
|
||
title: '',
|
||
value: '',
|
||
orderNo: "",
|
||
// 油品订单信息
|
||
oilOrder: {},
|
||
// 员工列表信息
|
||
staff: {},
|
||
// 店铺信息
|
||
store: {},
|
||
oilPrice: 0,
|
||
// 油品名称
|
||
oilName: "",
|
||
// 油品类型
|
||
oilType:"",
|
||
// 用户信息
|
||
user:{
|
||
cardBalance:0,
|
||
},
|
||
balance:false,
|
||
grade:false,
|
||
oilCard:false,
|
||
coupon:false,
|
||
// 会员等级信息
|
||
userGrade:{},
|
||
balanceRedece:0,
|
||
oilCardRedece:0,
|
||
gradeRedece:0,
|
||
fullRedece:0,
|
||
couponRedece:0,
|
||
hoardAmount:0,
|
||
// 囤油卡信息
|
||
refuelMoney:[],
|
||
// 会员等级优惠信息
|
||
gradeDiscount:[],
|
||
// 优惠券优惠信息
|
||
couponDiscount:[],
|
||
// 满减优惠信息
|
||
fullReduceDiscount:[],
|
||
payAmount:0,
|
||
// 查询优惠活动信息所需参数
|
||
preferentialData:{
|
||
userId:"",
|
||
storeId:"",
|
||
gradeId:"",
|
||
oilName:"",
|
||
oilPrice:"",
|
||
oilLiters:"",
|
||
},
|
||
// 互斥限制 -1没有限制 0满减互斥 1储值卡互斥
|
||
exclusion:-1,
|
||
// 是否为满减互斥
|
||
isUseFull:false,
|
||
// 是否为储值卡互斥
|
||
isUseBalance:false,
|
||
// 是否使用囤油卡
|
||
isOilStorageCard:false,
|
||
}
|
||
},
|
||
onLoad(e) {
|
||
this.orderNo = e.orderNo
|
||
// this.orderNo = "20231201114800ebe24b"
|
||
},
|
||
onShow() {
|
||
this.getOilOrder();
|
||
this.testPay();
|
||
},
|
||
components: {
|
||
|
||
},
|
||
methods: {
|
||
// 测试支付接口
|
||
testPay(){
|
||
request({
|
||
url: "api/wechat/pay",
|
||
method: 'post',
|
||
}).then(res => {
|
||
console.log(res)
|
||
})
|
||
},
|
||
// 囤油卡变化后总金额的变化
|
||
changeRefuelMoney(){
|
||
let _this = this;
|
||
_this.consumeRefuelMoney = 0;
|
||
_this.oilActualPay = 0;
|
||
_this.hoardAmount = 0;
|
||
let conRefMon = 0;
|
||
let hoardAmount = 0;
|
||
if (_this.refuelMoney!=null){
|
||
_this.refuelMoney.forEach(item => {
|
||
if (item.oilType == _this.oilName){
|
||
_this.isOilStorageCard = true
|
||
if ((item.refuelMoney-_this.oilOrder.oilNum)>=0){
|
||
conRefMon = _this.oilOrder.oilNum
|
||
}else {
|
||
conRefMon = item.refuelMoney
|
||
// 扣除升数后需要消费的金额
|
||
hoardAmount = _this.oilOrder.orderAmount - (item.refuelMoney * _this.oilPrice).toFixed(2)
|
||
}
|
||
}
|
||
})
|
||
}
|
||
_this.oilCardRedece += +conRefMon
|
||
if (_this.oilCardRedece!=0){
|
||
_this.isOilStorageCard = true;
|
||
_this.balanceRedece = 0;
|
||
}
|
||
_this.hoardAmount += +hoardAmount
|
||
_this.isExclusion();
|
||
},
|
||
// 使用囤油卡 囤油卡不参与任何优惠
|
||
countOilCard(){
|
||
if (this.hoardAmount!=0){
|
||
if (this.user.cardBalance!=0 && this.user.cardBalance >= (this.oilOrder.orderAmount - this.hoardAmount)) {
|
||
this.payAmount = 0
|
||
this.balanceRedece = this.hoardAmount
|
||
}else{
|
||
this.payAmount = (this.oilOrder.orderAmount - this.hoardAmount - this.user.cardBalance).toFixed(2)
|
||
}
|
||
}else{
|
||
this.payAmount = 0
|
||
this.balanceRedece = 0
|
||
}
|
||
console.log("oil",this.hoardAmount,this.payAmount)
|
||
},
|
||
// 使用优惠券不使用满减
|
||
countAmountFull(){
|
||
if (this.user.cardBalance >= (this.oilOrder.orderAmount-this.gradeRedece - this.couponRedece)) {
|
||
this.payAmount = 0
|
||
this.balanceRedece = (this.oilOrder.orderAmount-this.gradeRedece - this.couponRedece).toFixed(2)
|
||
}else{
|
||
this.balanceRedece = this.user.cardBalance
|
||
this.payAmount = (this.oilOrder.orderAmount - this.gradeRedece - this.couponRedece - this.user.cardBalance).toFixed(2)
|
||
}
|
||
console.log("coup",this.payAmount)
|
||
},
|
||
// 使用优惠券和满减不使用储值卡
|
||
countAmountUnBalance(){
|
||
if (this.fullRedece >= this.couponRedece && this.exclusion == 0) {
|
||
this.payAmount = (this.oilOrder.orderAmount - this.gradeRedece - this.fullRedece).toFixed(2)
|
||
}else if (this.fullRedece < this.couponRedece && this.exclusion == 0) {
|
||
this.payAmount = (this.oilOrder.orderAmount - this.gradeRedece - this.couponRedece).toFixed(2)
|
||
}else{
|
||
this.payAmount = (this.oilOrder.orderAmount - this.gradeRedece - this.couponRedece - this.fullRedece).toFixed(2)
|
||
}
|
||
this.balanceRedece = 0
|
||
console.log("full",this.payAmount,this.exclusion)
|
||
},
|
||
// 使用储值卡不使用优惠券 || 使用满减不使用优惠券
|
||
countAmountBalance(){
|
||
if (this.user.cardBalance >= (this.oilOrder.orderAmount-this.gradeRedece - this.fullRedece)) {
|
||
this.payAmount = 0
|
||
this.balanceRedece = (this.oilOrder.orderAmount-this.gradeRedece - this.fullRedece).toFixed(2)
|
||
}else{
|
||
this.balanceRedece = this.user.cardBalance
|
||
this.payAmount = (this.oilOrder.orderAmount-this.gradeRedece - this.fullRedece - this.user.cardBalance).toFixed(2)
|
||
}
|
||
console.log("balance",this.payAmount)
|
||
},
|
||
// 判断互斥限制
|
||
isExclusion(){
|
||
if (this.exclusion == 1){
|
||
// 不使用满减
|
||
if (this.isUseBalance){
|
||
this.countAmountFull()
|
||
return;
|
||
}
|
||
// 储值卡互斥
|
||
if (this.isUseBalance){
|
||
this.countAmountUnBalance()
|
||
return;
|
||
}else {
|
||
this.countAmountBalance()
|
||
return;
|
||
}
|
||
}else if (this.exclusion == 0){
|
||
// 满减互斥
|
||
// 不使用储值卡
|
||
if (this.isUseBalance){
|
||
this.countAmountUnBalance()
|
||
return;
|
||
}
|
||
if (this.isUseFull){
|
||
this.countAmountFull()
|
||
return;
|
||
}else {
|
||
this.countAmountBalance()
|
||
return;
|
||
}
|
||
}else {
|
||
// 无互斥
|
||
// 不使用储值卡
|
||
if (this.isUseBalance){
|
||
this.countAmountUnBalance()
|
||
return;
|
||
}
|
||
// 不使用满减
|
||
if (this.isUseBalance){
|
||
this.countAmountFull()
|
||
return;
|
||
}
|
||
// 使用囤油卡
|
||
if (this.isOilStorageCard){
|
||
this.fullRedece = 0;
|
||
this.gradeRedece = 0;
|
||
this.couponRedece = 0;
|
||
this.countOilCard();
|
||
return;
|
||
}
|
||
this.countAmountBalance();
|
||
}
|
||
},
|
||
// 调用优惠券接口
|
||
getCoupon(){
|
||
let _this = this;
|
||
_this.couponDiscount =[];
|
||
request({
|
||
url: "business/marketingActivity/activeExchange/selectCardFavorableList",
|
||
method: 'get',
|
||
params: _this.preferentialData,
|
||
}).then(response => {
|
||
_this.couponRedece = 0;
|
||
if (response.data.length>0){
|
||
response.data.forEach(item => {
|
||
_this.useCouponIds = item.id
|
||
let discount = {type:item.type,discountType:item.discountType,name:item.name,oilName:_this.oilOrder.oils,full:0,reduce:0,discount:0}
|
||
discount.full = item.satisfiedAmount
|
||
if (item.type==0){
|
||
// 油品券
|
||
if (item.discountType==0){
|
||
// 满减券
|
||
discount.reduce = item.discountAmount
|
||
}else {
|
||
// 折扣券
|
||
discount.discount = item.specialDiscount
|
||
discount.reduce = item.discountOffset
|
||
}
|
||
}else if (item.type==1){
|
||
// 商品券
|
||
if (item.discountType==0){
|
||
// 满减券
|
||
discount.reduce = item.discountAmount
|
||
}else {
|
||
// 折扣券
|
||
discount.discount = item.specialDiscount
|
||
discount.reduce = item.discountOffset
|
||
}
|
||
}else {
|
||
// 通用券
|
||
if (item.discountType==0){
|
||
// 满减券
|
||
discount.reduce = item.discountAmount
|
||
}else {
|
||
// 折扣券
|
||
discount.discount = item.specialDiscount
|
||
discount.reduce = item.discountOffset
|
||
}
|
||
}
|
||
if (discount.reduce!=0){
|
||
if (_this.couponDiscount.length!=0){
|
||
_this.couponDiscount.forEach(item2 => {
|
||
if (item2.oilName!=discount.oilName) {
|
||
_this.couponDiscount.push(discount)
|
||
_this.couponRedece = discount.reduce
|
||
}
|
||
if (item2.name!=discount.name && item2.oilName==discount.oilName) {
|
||
_this.couponDiscount.push(discount)
|
||
_this.couponRedece = discount.reduce
|
||
}
|
||
})
|
||
}else {
|
||
_this.couponDiscount.push(discount)
|
||
_this.couponRedece = discount.reduce
|
||
}
|
||
}
|
||
if (item.exclusiveFunction == 0){
|
||
// 满减互斥
|
||
_this.fullRedece = 0
|
||
_this.isUseFull = true;
|
||
}else {
|
||
// 储值卡付款互斥
|
||
_this.couponRedece = 0;
|
||
_this.isUseBalance = true;
|
||
}
|
||
_this.exclusion = item.exclusiveFunction
|
||
})
|
||
}
|
||
_this.isExclusion();
|
||
})
|
||
},
|
||
// 获取优惠活动信息
|
||
preferential(){
|
||
let _this = this;
|
||
let fullReduction = 0;
|
||
_this.fullReduction = 0;
|
||
|
||
request({
|
||
url: "business/marketingActivity/activeExchange/selectConsumptionList",
|
||
method: 'get',
|
||
params: _this.preferentialData,
|
||
}).then( response => {
|
||
if (response.data.length>0){
|
||
_this.fullReduceDiscount = []
|
||
response.data.forEach(item => {
|
||
if (item.participationCondition==1){
|
||
_this.exclusion = 0
|
||
}
|
||
let discount = {type:item.name,full:0,reduce:0,discount:0,exclusion:item.participationCondition}
|
||
let activeList = item.activeDiscountChildList;
|
||
for (let i = 1;i<=activeList.length;i++){
|
||
if (activeList.length>0){
|
||
if (activeList[0].discount != null){
|
||
// 折扣营销
|
||
if (_this.oilOrder.orderAmount>=activeList[0].amount){
|
||
discount.full = activeList[0].amount;
|
||
discount.discount = activeList[0].discount;
|
||
discount.reduce = _this.oilOrder.orderAmount - (_this.oilOrder.orderAmount * (activeList[0].discount / 10)).toFixed(2)
|
||
fullReduction = _this.oilOrder.orderAmount - (_this.oilOrder.orderAmount * (activeList[0].discount / 10)).toFixed(2);
|
||
}
|
||
}else {
|
||
// 满减
|
||
if (_this.oilOrder.orderAmount>=activeList[0].amount){
|
||
discount.full = activeList[0].amount;
|
||
discount.reduce = activeList[0].deductionAmount;
|
||
fullReduction = activeList[0].deductionAmount;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
if (activeList.length==0){
|
||
fullReduction = 0
|
||
}
|
||
if (discount.reduce!=0){
|
||
_this.fullReduceDiscount.push(discount)
|
||
}
|
||
_this.fullRedece += +fullReduction
|
||
})
|
||
}
|
||
if (_this.isUseFull){
|
||
_this.fullReduction = 0
|
||
}
|
||
})
|
||
},
|
||
changeAmount(){
|
||
this.balanceRedece = (this.oilOrder.orderAmount - this.gradeRedece).toFixed(2)
|
||
},
|
||
// 根据等级id获取会员等级信息
|
||
getGrade(id){
|
||
let _this = this;
|
||
request({
|
||
url: "business/userManager/userGrade/isUse/" + id,
|
||
method: 'get',
|
||
}).then((response) => {
|
||
let gasolineDiscount = 0;
|
||
let dieselDiscount = 0;
|
||
let naturalGasDiscount = 0;
|
||
_this.gradeDiscount = [];
|
||
_this.userGrade = response.data
|
||
|
||
if (response.data != null) {
|
||
let discount = {type: "", full: 0, reduce: 0, liters: 0}
|
||
if (response.data.preferential == '自定义优惠' && response.data.status == 'qy') {
|
||
if (_this.oilType == "汽油") {
|
||
let gasolineRule = JSON.parse(response.data.gasolineRule);
|
||
if (response.data.gasolineDiscount == "满减优惠") {
|
||
let oilDiscount = 0;
|
||
discount.type = "满减优惠"
|
||
for (let i = 1; i <= gasolineRule.length; i++) {
|
||
// 将满减条件加入等级优惠列表
|
||
if (gasolineRule.length > 1) {
|
||
if (_this.oilOrder.orderAmount >= gasolineRule[gasolineRule.length - 1].gasolineRule1) {
|
||
discount.full = gasolineRule[gasolineRule.length - 1].gasolineRule1
|
||
oilDiscount = gasolineRule[gasolineRule.length - 1].gasolineRule2
|
||
discount.reduce = gasolineRule[gasolineRule.length - 1].gasolineRule2
|
||
break;
|
||
}
|
||
if (_this.oilOrder.orderAmount >= gasolineRule[i - 1].gasolineRule1 && _this.oilOrder.orderAmount < gasolineRule[i].gasolineRule1) {
|
||
discount.full = gasolineRule[i - 1].gasolineRule1
|
||
oilDiscount = gasolineRule[i - 1].gasolineRule2
|
||
discount.reduce = gasolineRule[i - 1].gasolineRule2
|
||
}
|
||
} else {
|
||
if (_this.oilOrder.orderAmount >= gasolineRule[i - 1].gasolineRule1) {
|
||
discount.full = gasolineRule[i - 1].gasolineRule1
|
||
oilDiscount = gasolineRule[i - 1].gasolineRule2
|
||
discount.reduce = gasolineRule[i - 1].gasolineRule2
|
||
}
|
||
}
|
||
}
|
||
if (discount.reduce != 0) {
|
||
_this.gradeDiscount.push(discount)
|
||
}
|
||
gasolineDiscount += +oilDiscount
|
||
} else if (response.data.gasolineDiscount == "每升优惠") {
|
||
discount.type = "每升优惠"
|
||
let oilDiscount = 0;
|
||
for (let i = 1; i <= gasolineRule.length; i++) {
|
||
// 将满减条件加入等级优惠列表
|
||
if (gasolineRule.length > 1) {
|
||
if (_this.oilOrder.orderAmount >= gasolineRule[gasolineRule.length - 1].gasolineRule1) {
|
||
discount.full = gasolineRule[gasolineRule.length - 1].gasolineRule1
|
||
oilDiscount = (_this.oilOrder.oilNum * gasolineRule[gasolineRule.length - 1].gasolineRule3).toFixed(2);
|
||
discount.reduce = (_this.oilOrder.oilNum * gasolineRule[gasolineRule.length - 1].gasolineRule3).toFixed(2);
|
||
discount.liters = gasolineRule[i - 1].gasolineRule3
|
||
break;
|
||
}
|
||
if (_this.oilOrder.orderAmount >= gasolineRule[i - 1].gasolineRule1 && _this.oilOrder.orderAmount < gasolineRule[i].gasolineRule1) {
|
||
discount.full = gasolineRule[i - 1].gasolineRule1
|
||
oilDiscount = (_this.oilOrder.oilNum * gasolineRule[i - 1].gasolineRule3).toFixed(2)
|
||
discount.reduce = (_this.oilOrder.oilNum * gasolineRule[i - 1].gasolineRule3).toFixed(2)
|
||
discount.liters = gasolineRule[i - 1].gasolineRule3
|
||
}
|
||
} else {
|
||
if (_this.oilOrder.orderAmount >= gasolineRule[i - 1].gasolineRule1) {
|
||
discount.full = gasolineRule[i - 1].gasolineRule1
|
||
oilDiscount = (_this.oilOrder.oilNum * gasolineRule[i - 1].gasolineRule3).toFixed(2)
|
||
discount.reduce = (_this.oilOrder.oilNum * gasolineRule[i - 1].gasolineRule3).toFixed(2)
|
||
discount.liters = gasolineRule[i - 1].gasolineRule3
|
||
}
|
||
}
|
||
}
|
||
if (discount.reduce != 0) {
|
||
_this.gradeDiscount.push(discount)
|
||
}
|
||
gasolineDiscount += +oilDiscount
|
||
} else {
|
||
gasolineDiscount = 0;
|
||
}
|
||
}
|
||
if (_this.oilType == "柴油") {
|
||
let dieselRule = JSON.parse(response.data.dieselRule);
|
||
if (response.data.dieselDiscount == "满减优惠") {
|
||
let oilDiscount = 0;
|
||
discount.type = "满减优惠"
|
||
for (let i = 1; i <= dieselRule.length; i++) {
|
||
// 将满减条件加入等级优惠列表
|
||
if (dieselRule.length > 1) {
|
||
if (_this.oilOrder.orderAmount >= dieselRule[dieselRule.length - 1].dieselRule1) {
|
||
discount.full = dieselRule[dieselRule.length - 1].dieselRule1
|
||
oilDiscount = dieselRule[dieselRule.length - 1].dieselRule2
|
||
discount.reduce = dieselRule[dieselRule.length - 1].dieselRule2
|
||
break;
|
||
}
|
||
if (_this.oilOrder.orderAmount >= dieselRule[i - 1].dieselRule1 && _this.oilOrder.orderAmount < dieselRule[i].dieselRule1) {
|
||
discount.full = dieselRule[i - 1].dieselRule1
|
||
oilDiscount = dieselRule[i - 1].dieselRule2
|
||
discount.reduce = dieselRule[i - 1].dieselRule2
|
||
}
|
||
} else {
|
||
discount.full = dieselRule[i - 1].dieselRule1
|
||
if (_this.oilOrder.orderAmount >= dieselRule[i - 1].dieselRule1) {
|
||
oilDiscount = dieselRule[i - 1].dieselRule2
|
||
discount.reduce = dieselRule[i - 1].dieselRule2
|
||
}
|
||
}
|
||
}
|
||
if (discount.reduce != 0) {
|
||
_this.gradeDiscount.push(discount)
|
||
}
|
||
dieselDiscount += +oilDiscount
|
||
} else if (response.data.dieselDiscount == "每升优惠") {
|
||
let oilDiscount = 0;
|
||
for (let i = 1; i <= dieselRule.length; i++) {
|
||
discount.type = "每升优惠"
|
||
// 将满减条件加入等级优惠列表
|
||
if (dieselRule.length > 1) {
|
||
if (_this.oilOrder.orderAmount >= dieselRule[dieselRule.length - 1].dieselRule1) {
|
||
discount.full = dieselRule[dieselRule.length - 1].dieselRule1
|
||
oilDiscount = (_this.oilOrder.oilNum * dieselRule[dieselRule.length - 1].dieselRule3).toFixed(2);
|
||
discount.reduce = (_this.oilOrder.oilNum * dieselRule[dieselRule.length - 1].dieselRule3).toFixed(2);
|
||
discount.liters = dieselRule[dieselRule.length - 1].dieselRule3
|
||
break;
|
||
}
|
||
if (_this.oilOrder.orderAmount >= dieselRule[i - 1].dieselRule1 && _this.oilOrder.orderAmount < dieselRule[i].dieselRule1) {
|
||
discount.full = dieselRule[i - 1].dieselRule1
|
||
oilDiscount = (_this.oilOrder.oilNum * dieselRule[i - 1].dieselRule3).toFixed(2)
|
||
discount.reduce = (_this.oilOrder.oilNum * dieselRule[i - 1].dieselRule3).toFixed(2)
|
||
discount.liters = dieselRule[i - 1].dieselRule3
|
||
}
|
||
} else {
|
||
discount.full = dieselRule[i - 1].dieselRule1
|
||
if (_this.oilOrder.orderAmount >= dieselRule[i - 1].dieselRule1) {
|
||
oilDiscount = (_this.oilOrder.oilNum * dieselRule[i - 1].dieselRule3).toFixed(2)
|
||
discount.reduce = (_this.oilOrder.oilNum * dieselRule[i - 1].dieselRule3).toFixed(2)
|
||
discount.liters = dieselRule[i - 1].dieselRule3
|
||
}
|
||
}
|
||
}
|
||
if (discount.reduce != 0) {
|
||
_this.gradeDiscount.push(discount)
|
||
}
|
||
dieselDiscount += +oilDiscount
|
||
} else {
|
||
dieselDiscount = 0;
|
||
}
|
||
}
|
||
if(_this.oilType == "天然气") {
|
||
let naturalGasRule = JSON.parse(response.data.naturalGasRule);
|
||
if (response.data.naturalGasDiscount == "满减优惠") {
|
||
let oilDiscount = 0;
|
||
discount.type = "满减优惠"
|
||
for (let i = 1; i <= naturalGasRule.length; i++) {
|
||
// 将满减条件加入等级优惠列表
|
||
if (naturalGasRule.length > 1) {
|
||
if (_this.oilOrder.orderAmount >= naturalGasRule[naturalGasRule.length - 1].naturalGasRule1) {
|
||
discount.full = naturalGasRule[naturalGasRule.length - 1].naturalGasRule1
|
||
oilDiscount = naturalGasRule[naturalGasRule.length - 1].naturalGasRule2;
|
||
discount.reduce = naturalGasRule[naturalGasRule.length - 1].naturalGasRule2
|
||
break;
|
||
}
|
||
if (_this.oilOrder.orderAmount >= naturalGasRule[i - 1].naturalGasRule1 && _this.oilOrder.orderAmount < naturalGasRule[i].naturalGasRule1) {
|
||
discount.full = naturalGasRule[i - 1].naturalGasRule1
|
||
oilDiscount = naturalGasRule[i - 1].naturalGasRule2
|
||
discount.reduce = naturalGasRule[i - 1].naturalGasRule2
|
||
}
|
||
} else {
|
||
if (_this.oilOrder.orderAmount >= naturalGasRule[i - 1].naturalGasRule1) {
|
||
discount.full = naturalGasRule[i - 1].naturalGasRule1
|
||
oilDiscount = naturalGasRule[i - 1].naturalGasRule2
|
||
discount.reduce = naturalGasRule[i - 1].naturalGasRule2
|
||
}
|
||
}
|
||
}
|
||
if (discount.reduce != 0) {
|
||
_this.gradeDiscount.push(discount)
|
||
}
|
||
naturalGasDiscount += +oilDiscount
|
||
} else if (response.data.naturalGasDiscount == "每单位优惠") {
|
||
let oilDiscount = 0;
|
||
discount.type = "每单位优惠"
|
||
for (let i = 1; i <= naturalGasRule.length; i++) {
|
||
// 将满减条件加入等级优惠列表
|
||
if (naturalGasRule.length > 1) {
|
||
if (_this.oilOrder.orderAmount >= naturalGasRule[naturalGasRule.length - 1].naturalGasRule1) {
|
||
discount.full = naturalGasRule[naturalGasRule.length - 1].naturalGasRule1
|
||
oilDiscount = (_this.oilOrder.oilNum * naturalGasRule[gasolineRule.length - 1].naturalGasRule3).toFixed(2)
|
||
discount.reduce = (_this.oilOrder.oilNum * naturalGasRule[gasolineRule.length - 1].naturalGasRule3).toFixed(2)
|
||
discount.liters = naturalGasRule[naturalGasRule.length - 1].naturalGasRule3
|
||
break;
|
||
}
|
||
if (_this.oilOrder.orderAmount >= naturalGasRule[i - 1].naturalGasRule1 && _this.oilOrder.orderAmount < naturalGasRule[i].naturalGasRule1) {
|
||
discount.full = naturalGasRule[i - 1].naturalGasRule1
|
||
oilDiscount = (_this.oilOrder.oilNum * naturalGasRule[i - 1].naturalGasRule3).toFixed(2)
|
||
discount.reduce = (_this.oilOrder.oilNum * naturalGasRule[i - 1].naturalGasRule3).toFixed(2)
|
||
discount.liters = naturalGasRule[i - 1].naturalGasRule3
|
||
}
|
||
} else {
|
||
if (_this.oilOrder.orderAmount >= naturalGasRule[i - 1].naturalGasRule1) {
|
||
discount.full = naturalGasRule[i - 1].naturalGasRule1
|
||
oilDiscount = (_this.oilOrder.oilNum * naturalGasRule[i - 1].naturalGasRule3).toFixed(2)
|
||
discount.reduce = (_this.oilOrder.oilNum * naturalGasRule[i - 1].naturalGasRule3).toFixed(2)
|
||
discount.liters = naturalGasRule[i - 1].naturalGasRule3
|
||
}
|
||
}
|
||
}
|
||
if (discount.reduce != 0) {
|
||
_this.gradeDiscount.push(discount)
|
||
}
|
||
naturalGasDiscount += +oilDiscount
|
||
} else {
|
||
naturalGasDiscount = 0;
|
||
}
|
||
}
|
||
}
|
||
_this.gradeRedece = gasolineDiscount + dieselDiscount + naturalGasDiscount
|
||
_this.changeAmount()
|
||
}
|
||
})
|
||
},
|
||
// 根据用户id查询用户信息
|
||
getUser(id){
|
||
let _this = this;
|
||
request({
|
||
url: "business/userManager/user/" + id,
|
||
method: 'get',
|
||
}).then((res) => {
|
||
_this.user = res.data;
|
||
_this.refuelMoney = JSON.parse(res.data.refuelMoney)
|
||
_this.changeRefuelMoney()
|
||
_this.getGrade(res.data.gradeId)
|
||
_this.preferentialData.oilPrice = _this.oilPrice
|
||
_this.preferentialData.gradeId = res.data.gradeId
|
||
_this.preferential()
|
||
_this.getCoupon()
|
||
})
|
||
},
|
||
// 获取油品订单
|
||
getOilOrder() {
|
||
let _this = this;
|
||
request({
|
||
url: "business/oilOrder/orderNo",
|
||
method: 'post',
|
||
data: {
|
||
orderNo: _this.orderNo
|
||
},
|
||
}).then((res) => {
|
||
_this.oilOrder = res.data
|
||
_this.getStaffList(res.data.staffId)
|
||
_this.getStore(res.data.storeId)
|
||
_this.getOilNumber(res.data.storeId)
|
||
_this.getUser(res.data.userId)
|
||
_this.preferentialData.storeId = res.data.storeId
|
||
_this.preferentialData.userId = res.data.userId
|
||
_this.preferentialData.oilName = res.data.oils
|
||
_this.preferentialData.oilLiters = res.data.oilNum
|
||
})
|
||
},
|
||
// 获取门店信息
|
||
getStore(id) {
|
||
let _this = this;
|
||
request({
|
||
url: "business/storeInformation/store/queryStoreById",
|
||
method: 'post',
|
||
data: {
|
||
"storeId": id
|
||
},
|
||
}).then((res) => {
|
||
_this.store = res.data;
|
||
})
|
||
},
|
||
// 根据员工id获取员工信息
|
||
getStaffList(staffId) {
|
||
let _this = this;
|
||
request({
|
||
url: "business/member/staff/" + staffId,
|
||
method: 'get',
|
||
}).then((res) => {
|
||
_this.staff = res.data
|
||
})
|
||
},
|
||
// 获取当前店铺油号信息
|
||
getOilNumber(storeId) {
|
||
let _this = this;
|
||
request({
|
||
url: "business/petrolStationManagement/oilNumber/getOilNumberName/" + storeId,
|
||
method: 'get',
|
||
}).then((res) => {
|
||
res.data.forEach(item => {
|
||
if (item.oilName == _this.oilOrder.oils) {
|
||
_this.oilPrice = item.gbPrice;
|
||
_this.oilName = item.oilNames;
|
||
_this.oilType = item.oilType;
|
||
}
|
||
})
|
||
})
|
||
},
|
||
goBack() {
|
||
uni.navigateBack()
|
||
}
|
||
}
|
||
}
|
||
</script>
|
||
|
||
<style scoped lang="scss">
|
||
.desc {
|
||
height: 35px;
|
||
line-height: 35px;
|
||
margin-left: 20px;
|
||
margin-right: 20px;
|
||
display: flex;
|
||
justify-content: space-between;
|
||
font-size: 15px;
|
||
color: rgba(0, 0, 0, 0.65);
|
||
}
|
||
|
||
.bar {
|
||
width: 100%;
|
||
height: 70px;
|
||
background-color: white;
|
||
position: fixed;
|
||
bottom: 0px;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
}
|
||
|
||
.content {
|
||
background: #f4f5f6;
|
||
}
|
||
|
||
.container {
|
||
width: 100%;
|
||
height: 100vh;
|
||
box-sizing: border-box;
|
||
padding-top: 88px;
|
||
}
|
||
|
||
.my-header {
|
||
width: 100%;
|
||
height: 88px;
|
||
background: #ffffff;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
color: #000;
|
||
box-sizing: border-box;
|
||
padding: 0px 15px;
|
||
padding-top: 40px;
|
||
|
||
.my-icons {
|
||
width: 20px;
|
||
|
||
}
|
||
|
||
position: fixed;
|
||
top: 0px;
|
||
}
|
||
</style> |