oil-station/gasStation-uni/pagesRefuel/orderDetail/index.vue
2024-03-06 13:39:10 +08:00

974 lines
31 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<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>{{oilOrder.storeName}}{{oilOrder.description ? "("+oilOrder.description+")" : ""}}</view>
</view>
<view class="desc">
<view>油号油枪</view>
<view>{{oilOrder.oilName}}/{{oilOrder.gunName}}</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}}/L</view>
</view>
<view class="desc">
<view>加油员工</view>
<view>{{oilOrder.realName || "--"}}</view>
</view>
</view>
<view style="background-color: white;width: 94%;margin: 15px auto;" v-if="AppToken">
<view class="desc">
<view style="display: flex;">
储值卡
<span style="display: flex;">(<span v-if="isUseChildCard">主卡</span>余额{{user.cardBalance}})</span>
</view>
<view style="display: flex;">
<span style="margin-right: 10px;display: flex;">
-{{balanceRedece}}
</span>
</view>
</view>
<view class="desc">
<view style="display: flex;">
囤油卡
<span style="display: flex;">(余额{{refuelBalance}}L)</span>
</view>
<view style="display: flex;">
<span style="margin-right: 10px;display: flex;">
- {{oilCardRedece}}L
<span style="margin-left: 8px;margin-top: 8px;">
<u-checkbox-group>
<u-checkbox v-model="checkOilCard" :checked="checkOilCard" @change="changeOilCard" :disabled="refuelBalance==0"></u-checkbox>
</u-checkbox-group>
</span>
</span>
</view>
</view>
<view class="desc" v-if="preferentialData.activeFavorableAmount">
<view style="display: flex;">
活动优惠
<!-- <span style="display: flex;">(满减活动)</span> -->
</view>
<view style="display: flex;">
<span style="margin-right: 10px;display: flex;">
-¥{{fullRedece}}
<!-- <span style="margin-left: 8px;margin-top: 8px;">
<u-checkbox-group>
<u-checkbox v-model="checkFull" :checked="checkFull" @change="changeFull"></u-checkbox>
</u-checkbox-group>
</span> -->
</span>
</view>
</view>
<view class="desc" v-if="preferentialData.cardFavorableAmount">
<view style="display: flex;">
优惠券优惠
<!-- <span style="display: flex;">(优惠券)</span> -->
</view>
<view style="display: flex;">
<span style="margin-right: 10px;display: flex;">
-¥{{couponRedece}}
</span>
</view>
</view>
<view class="desc" v-if="gradeRedece>0">
<view style="display: flex;">
会员等级优惠
<!-- <span style="display: flex;">({{userGrade.name}})</span> -->
</view>
<view style="display: flex;">
<span style="margin-right: 10px;display: flex;">
-¥{{gradeRedece}}
</span>
</view>
</view>
<!-- <view class="desc" v-if="!isFullPreferential && !isGradePreferential && !isOilStorageCard && !isStoreValueCard">无优惠</view> -->
<view style="margin: 10px 20px 0;color: red;font-size: 12px;" v-if="fullRedece>0 || gradeRedece>0 || couponRedece>0">已为您计算出最大优惠</view>
<view style="margin: 10px 20px 0;color: red;font-size: 12px;">注:囤油卡不参与任何优惠活动</view>
</view>
<view style="background-color: white;width: 94%;margin: 15px auto;height: 100px;">
<view style="font-weight: bold;height: 40px;line-height: 40px;margin-left: 10px;margin-top: 20px;">支付方式
</view>
<!-- #ifdef MP-WEIXIN -->
<view class="scc">
<image src="@/static/imgs/wechat.png" class="imgIcon"></image>
<span style="width: 70%;margin-top: 5px;">微信支付</span>
<radio value="r1" checked="true" />
</view>
<!-- #endif -->
<!-- #ifdef MP-ALIPAY -->
<view class="scc">
<image src="@/static/imgs/alipay.png" class="imgIcon"></image>
<span style="width: 70%;margin-top: 5px;">支付宝支付</span>
<radio value="r1" checked="true" />
</view>
<!-- #endif -->
</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 @click="payment"
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 {
// 小程序类型 微信 WECHAT 支付宝 ALIPAY
appltType: uni.getStorageSync("appltType"),
// 判断是否有登录token
AppToken: uni.getStorageSync("App-Token"),
// 是否登录
ifLogin:false,
gradeDis:"",
title: '',
value: true,
orderNo: "",
// 油品订单信息
oilOrder: {},
// 员工列表信息
staff: {},
// 店铺信息
store: {},
oilPrice: 0,
// 油品名称
oilName: "",
oilNameId:"",
// 油品类型
oilType:"",
// 油品id
oilId:"",
// 用户信息
user:{
cardBalance:0,
},
// 储值卡升数
refuelBalance:0,
// 会员等级信息
userGrade:{},
balanceRedece:0,
oilCardRedece:0,
gradeRedece:0,
fullRedece:0,
couponRedece:0,
// 消费储值卡后的金额(未扣除优惠金额前的金额)
deductAmount:0,
// 囤油卡信息
refuelMoney:[],
refuelMoneyAfter:[],
// 会员等级优惠信息
gradeDiscount:[],
// 优惠券优惠信息
couponDiscount:[],
// 满减优惠信息
fullReduceDiscount:[],
// 支付金额
payAmount:0,
// 调起支付所需的数据
orderInfo:{},
// 是否使用囤油卡
isOilStorageCard:false,
// 是否使用储值卡
isStoreValueCard:false,
// 是否存在可使用的等级优惠
isGradePreferential:false,
// 是否存在可使用的满减或折扣优惠
isFullPreferential:false,
// 是否存在可使用的优惠券
isCoupons:false,
transferDTO:{
type:0,
amount:0,
oilId:"",
mtUserLevel:"",
storeId:uni.getStorageSync("storeId")
},
fixingLevel:{},
isUseChildCard:false,
cardsList:[],
query: {
storeId: uni.getStorageSync("storeId"),
couponType: '',
useStatus: 0,
pageNo: 1,
pageSize: 10
},
checkBalance:false,
checkOilCard:false,
checkFull:false,
checkCoupon:false,
checkGrade:false,
preferentialData:{
activeFavorableAmount: "",
activeId: "",
activeInfo: "",
cardFavorableAmount: "",
cardFavorableId: "",
cardFavorableInfo: "",
memberFavorableAmount: "",
type: "",
},
// 是否为固定等级会员
isFixingLevel:false,
}
},
onLoad(e) {
this.orderNo = e.orderNo
// this.orderNo = "2345202401261502301206e6"
},
onShow() {
this.getOilOrder();
},
components: {
},
methods: {
// 选择囤油卡
changeOilCard(val){
this.checkOilCard = val
if (val){
this.chooseRefuelMoney()
this.fullRedece = 0;
this.gradeRedece = 0;
this.couponRedece = 0;
this.preferentialData = {
activeFavorableAmount: "",
activeId: "",
activeInfo: "",
cardFavorableAmount: "",
cardFavorableId: "",
cardFavorableInfo: "",
memberFavorableAmount: "",
type: "",
};
}else{
this.oilCardRedece = 0
if (!this.isFixingLevel){
this.getPaymentPreferential(this.user.gradeId)
}
}
},
// 支付接口
payment(){
if (this.isUseChildCard){
if(this.balanceRedece>0){
this.isUseChildCard = true
}else{
this.isUseChildCard = false
}
}
let map = {
orderNo : this.orderNo,
payAmount : this.payAmount,
// payAmount : "0.01",
discountAmount : (this.fullRedece*100+this.gradeRedece*100+this.couponRedece*100)/100,
oilCardAmount : JSON.stringify(this.refuelMoneyAfter),
oilCardLiters : this.oilCardRedece,
balanceAmount : this.balanceRedece,
isOilStorageCard : this.isOilStorageCard,
tankId : uni.getStorageSync("tankId"),
// tankId : 6,
isUseChildCard:this.isUseChildCard,
activeId:this.preferentialData.activeId,
cardFavorableId:this.preferentialData.cardFavorableId,
recordId:this.preferentialData.recordId,
type:this.preferentialData.type,
balanceAmountSale:this.balanceRedece,
oilCardAmountSale:this.oilCardRedece,
ifLogin:this.ifLogin
};
let _this = this;
request({
url: "business/oilOrder/appletPay",
method: 'post',
data: map,
}).then(res => {
let payProvider = "wxpay"
if (_this.appltType== "WECHAT"){
payProvider = "wxpay"
}else{
payProvider = "alipay"
}
if(res.data.error){
request({
url: "/business/allOrderInfo/orderStatus",
method: 'post',
data: {"orderNo":_this.orderNo,"status":"payFail"},
}).then((ress)=>{})
uni.showToast({
title:res.data.error,
icon:"none"
})
// _this.goBack()
return;
}
if(res.data.code=="error"){
request({
url: "/business/allOrderInfo/orderStatus",
method: 'post',
data: {"orderNo":_this.orderNo,"status":"payFail"},
}).then((ress)=>{})
uni.showToast({
// title:res.data.msg,
title:"支付失败,请联系商家",
icon:"none"
})
// _this.goBack()
return;
}
if(res.data.success == "ok"){
// _this.preferentialData.storeId = _this.oilOrder.storeId
// _this.preferentialData.orderAmount = _this.oilOrder.orderAmount
// _this.preferentialData.oilId = _this.oilOrder.oils
// _this.preferentialData.mtUserLevel = _this.user.gradeId
// request({
// url: "business/marketingActivity/cardFavorableRecord/updateCardAndActiveById",
// method: 'post',
// data: _this.preferentialData,
// }).then((res)=>{})
// uni.reLaunch({
// url: '/pagesRefuel/orderSuccess/index'
// })
uni.navigateTo({
url: '/pagesRefuel/orderSuccess/index?orderNo='+_this.orderNo,
})
return;
}
if(res.data.resultMsg == "商户订单号重复"){
uni.showToast({
title:"商户订单号重复,请重新选择订单信息进行支付!",
icon:"none"
})
}
if (res.data.data.reservedPayInfo){
_this.orderInfo = JSON.parse(res.data.data.reservedPayInfo);
uni.requestPayment({
// 微信支付provider: 'wxpay' 支付宝支付 'alipay'
provider: payProvider,
// 时间戳
timeStamp: _this.orderInfo.timeStamp,
// 随机字符串
nonceStr: _this.orderInfo.nonceStr,
// 固定值
package: _this.orderInfo.package,
// 解密方式
signType: 'MD5',
// 支付签名
paySign: _this.orderInfo.paySign,
success: function (res) {
console.log('success');
// 支付成功后调用修改使用后的优惠券情况
// _this.preferentialData.storeId = _this.oilOrder.storeId
// _this.preferentialData.orderAmount = _this.oilOrder.orderAmount
// _this.preferentialData.oilId = _this.oilOrder.oils
// _this.preferentialData.mtUserLevel = _this.user.gradeId
// request({
// url: "business/marketingActivity/cardFavorableRecord/updateCardAndActiveById",
// method: 'post',
// data: _this.preferentialData,
// }).then((res)=>{
// console.log(res);
// })
// uni.reLaunch({
// url: '/pagesRefuel/orderSuccess/index'
// })
uni.navigateTo({
url: '/pagesRefuel/orderSuccess/index?orderNo='+_this.orderNo,
})
},
fail: function (err) {
request({
url: "/business/allOrderInfo/orderStatus",
method: 'post',
data: {"orderNo":res.data.data.orderNo,"status":"payFail"},
}).then((res)=>{
uni.showToast({
title:"支付失败!",
icon:"error"
})
})
console.log('fail:',err);
}
});
}
if (_this.appltType== "ALIPAY") {
my.tradePay({ tradeNO: res.data.data.reservedTransactionId }, function(resp){
if(resp.resultCode == '9000'){
console.log("支付成功")
// 支付成功后调用修改使用后的优惠券情况
// _this.preferentialData.storeId = _this.oilOrder.storeId
// _this.preferentialData.orderAmount = _this.oilOrder.orderAmount
// _this.preferentialData.oilId = _this.oilOrder.oils
// _this.preferentialData.mtUserLevel = _this.user.gradeId
// request({
// url: "business/marketingActivity/cardFavorableRecord/updateCardAndActiveById",
// method: 'post',
// data: _this.preferentialData,
// }).then((res)=>{})
// uni.reLaunch({
// url: '/pagesRefuel/orderSuccess/index'
// })
uni.navigateTo({
url: '/pagesRefuel/orderSuccess/index?orderNo='+_this.orderNo,
})
}else{
request({
url: "/business/allOrderInfo/orderStatus",
method: 'post',
data: {"orderNo":res.data.data.orderNo,"status":"payFail"},
}).then((res)=>{
uni.showToast({
title:"支付失败!",
icon:"error"
})
})
console.log('支付失败,'+resp.resultCode);
}
});
}
})
},
// 查看是否有可使用的囤油卡
chooseRefuelMoney(){
console.log("oilCard");
let falg = false;
for(let i = 0;i<this.refuelMoney.length;i++){
if (this.refuelMoney[i].oilType == this.oilNameId){
if( this.refuelMoney[i].refuelMoney>0 ){
falg = true
}
this.refuelBalance = this.refuelMoney[i].refuelMoney
if (this.refuelMoney[i].refuelMoney>0){
this.isOilStorageCard = true
}
if (this.refuelMoney[i].refuelMoney >= this.oilOrder.oilNum){
this.oilCardRedece = this.oilOrder.oilNum
this.refuelMoneyAfter[i].refuelMoney = this.refuelMoney[i].refuelMoney - this.oilOrder.oilNum
this.payAmount = 0
this.checkOilCard = true
}else{
this.oilCardRedece = this.refuelMoney[i].refuelMoney
this.refuelMoneyAfter[i].refuelMoney = 0
if (falg) {
this.checkOilCard = true
this.chooseCardBalance(1)
}
}
}
}
if (falg == false) {
// this.chooseCardBalance(0)
// this.chooseGrade(this.user.id,this.user.gradeId)
}
if (this.oilCardRedece==0){
if (!this.isFixingLevel){
this.getPaymentPreferential(this.user.gradeId)
}else{
this.chooseCardBalance(0)
}
}
},
// 查看是否有可使用的储值卡金额
chooseCardBalance(val){
console.log("balance");
if (this.user.cardBalance>0) {
this.isStoreValueCard = true;
if (val == 0) {
// 没有使用囤油卡
if (this.user.cardBalance >= (this.oilOrder.orderAmount - this.fullRedece - this.couponRedece - this.gradeRedece)){
this.balanceRedece = (this.oilOrder.orderAmount - this.fullRedece - this.couponRedece - this.gradeRedece).toFixed(2)
} else {
this.balanceRedece = this.user.cardBalance
this.deductAmount = (this.oilOrder.orderAmount - this.fullRedece - this.couponRedece - this.gradeRedece-this.balanceRedece).toFixed(2)
this.payAmount = (this.oilOrder.orderAmount - this.fullRedece - this.couponRedece - this.gradeRedece-this.balanceRedece).toFixed(2)
console.log(this.oilOrder.orderAmount, this.fullRedece, this.couponRedece, this.gradeRedece,this.balanceRedece,111);
}
}else{
// 使用囤油卡
// 扣除囤油卡金额后需要支付的金额
let residueAmount = 0
if(this.oilCardRedece>0){
residueAmount = ((this.oilOrder.oilNum - this.oilCardRedece) * this.oilPrice).toFixed(2)
}else{
residueAmount = this.oilOrder.orderAmount
}
if (this.user.cardBalance >= residueAmount){
this.balanceRedece = residueAmount
} else {
this.balanceRedece = this.user.cardBalance
this.payAmount = ((residueAmount*100).toFixed(0) - (this.balanceRedece*100).toFixed(0))/100
}
}
}else{
this.deductAmount = (this.oilOrder.orderAmount - this.fullRedece - this.couponRedece - this.gradeRedece).toFixed(2)
this.payAmount = (this.oilOrder.orderAmount - this.fullRedece - this.couponRedece - this.gradeRedece).toFixed(2)
console.log(this.oilOrder.orderAmount, this.fullRedece, this.couponRedece, this.gradeRedece,this.balanceRedece,222);
}
},
// 查看是否有可使用的会员等级优惠
chooseGrade(userId,gradeId){
console.log("userGrade");
let that = this;
request({
url: "business/userManager/userGrade/isUse",
method: 'post',
data:{userId:userId,gradeId:gradeId,storeId:that.oilOrder.storeId}
}).then((res) => {
if (res.data){
if (res.data.fixingLevel){
if (res.data.fixingLevel.discountType== "自定义优惠"){
if (that.oilType == "汽油"){
// 将数组按照金额从小到大排序
let gasolineRule = JSON.parse(res.data.fixingLevel.gasolineRule).sort((a,b) => a.gasolineRule1 - b.gasolineRule1);
if (res.data.fixingLevel.gasolineDiscount == "满减优惠"){
if (gasolineRule.length > 1){
for (let i = 1; i<gasolineRule.length; i++){
if (that.oilOrder.orderAmount >= gasolineRule[gasolineRule.length-1].gasolineRule1){
that.gradeRedece = gasolineRule[gasolineRule.length-1].gasolineRule2
that.isGradePreferential = true
break;
}
if (that.oilOrder.orderAmount >= gasolineRule[i - 1].gasolineRule1 && that.oilOrder.orderAmount < gasolineRule[i].gasolineRule1) {
that.gradeRedece = gasolineRule[i - 1].gasolineRule2
that.isGradePreferential = true
}
}
}else{
if (that.oilOrder.orderAmount >= gasolineRule[gasolineRule.length-1].gasolineRule1){
that.gradeRedece = gasolineRule[gasolineRule.length-1].gasolineRule2
that.isGradePreferential = true
}
}
}
if (res.data.fixingLevel.gasolineDiscount == "每升优惠"){
if (gasolineRule.length > 1){
for (let i = 1; i<gasolineRule.length; i++){
if (that.oilOrder.orderAmount >= gasolineRule[gasolineRule.length-1].gasolineRule1){
// 计算升数 和 优惠金额
that.gradeRedece = (that.oilOrder.orderAmount/that.oilPrice * gasolineRule[gasolineRule.length-1].gasolineRule3).toFixed(2)
that.isGradePreferential = true
break;
}
if (that.oilOrder.orderAmount >= gasolineRule[i - 1].gasolineRule1 && that.oilOrder.orderAmount < gasolineRule[i].gasolineRule1) {
that.gradeRedece = (that.oilOrder.orderAmount/that.oilPrice * gasolineRule[i - 1].gasolineRule3).toFixed(2)
that.isGradePreferential = true
}
}
}else{
if (that.oilOrder.orderAmount >= gasolineRule[gasolineRule.length-1].gasolineRule1){
that.gradeRedece = (that.oilOrder.orderAmount/that.oilPrice * gasolineRule[gasolineRule.length-1].gasolineRule3).toFixed(2)
that.isGradePreferential = true
}
}
}
}
if (that.oilType == "柴油"){
// 将数组按照金额从小到大排序
let dieselRule = JSON.parse(res.data.fixingLevel.dieselRule).sort((a,b) => a.dieselRule1 - b.dieselRule1);
if (res.data.fixingLevel.dieselDiscount == "满减优惠"){
if (dieselRule.length > 1){
for (let i = 1; i<dieselRule.length; i++){
if (that.oilOrder.orderAmount >= dieselRule[dieselRule.length-1].dieselRule1){
that.gradeRedece = dieselRule[dieselRule.length-1].dieselRule2
that.isGradePreferential = true
break;
}
if (that.oilOrder.orderAmount >= dieselRule[i - 1].dieselRule1 && that.oilOrder.orderAmount < dieselRule[i].dieselRule1) {
that.gradeRedece = dieselRule[i - 1].dieselRule2
that.isGradePreferential = true
}
}
}else{
if (that.oilOrder.orderAmount >= dieselRule[dieselRule.length-1].dieselRule1){
that.gradeRedece = dieselRule[dieselRule.length-1].dieselRule2
that.isGradePreferential = true
}
}
}
if (res.data.fixingLevel.dieselDiscount == "每升优惠"){
if (dieselRule.length > 1){
for (let i = 1; i<dieselRule.length; i++){
if (that.oilOrder.orderAmount >= dieselRule[dieselRule.length-1].dieselRule1){
// 计算升数 和 优惠金额
that.gradeRedece = (that.oilOrder.orderAmount/that.oilPrice * dieselRule[dieselRule.length-1].dieselRule3).toFixed(2)
that.isGradePreferential = true
break;
}
if (that.oilOrder.orderAmount >= dieselRule[i - 1].dieselRule1 && that.oilOrder.orderAmount < dieselRule[i].dieselRule1) {
that.gradeRedece = (that.oilOrder.orderAmount/that.oilPrice * dieselRule[i - 1].dieselRule3).toFixed(2)
that.isGradePreferential = true
}
}
}else{
if (that.oilOrder.orderAmount >= dieselRule[dieselRule.length-1].dieselRule1){
that.gradeRedece = (that.oilOrder.orderAmount/that.oilPrice * dieselRule[dieselRule.length-1].dieselRule3).toFixed(2)
that.isGradePreferential = true
}
}
}
}
if (that.oilType == "天然气"){
// 将数组按照金额从小到大排序
let naturalGasRule = JSON.parse(res.data.fixingLevel.naturalGasRule).sort((a,b) => a.naturalGasRule1 - b.naturalGasRule1);
if (res.data.fixingLevel.naturalGasDiscount == "满减优惠"){
if (naturalGasRule.length > 1){
for (let i = 1; i<naturalGasRule.length; i++){
if (that.oilOrder.orderAmount >= naturalGasRule[naturalGasRule.length-1].naturalGasRule1){
that.gradeRedece = naturalGasRule[naturalGasRule.length-1].naturalGasRule2
that.isGradePreferential = true
break;
}
if (that.oilOrder.orderAmount >= naturalGasRule[i - 1].naturalGasRule1 && that.oilOrder.orderAmount < naturalGasRule[i].naturalGasRule1) {
that.gradeRedece = naturalGasRule[i - 1].naturalGasRule2
that.isGradePreferential = true
}
}
}else{
if (that.oilOrder.orderAmount >= naturalGasRule[naturalGasRule.length-1].naturalGasRule1){
that.gradeRedece = naturalGasRule[naturalGasRule.length-1].naturalGasRule2
that.isGradePreferential = true
}
}
}
if (res.data.fixingLevel.naturalGasDiscount == "每升优惠"){
if (naturalGasRule.length > 1){
for (let i = 1; i<naturalGasRule.length; i++){
if (that.oilOrder.orderAmount >= naturalGasRule[naturalGasRule.length-1].naturalGasRule1){
// 计算升数 和 优惠金额
that.gradeRedece = (that.oilOrder.orderAmount/that.oilPrice * naturalGasRule[naturalGasRule.length-1].naturalGasRule3).toFixed(2)
that.isGradePreferential = true
break;
}
if (that.oilOrder.orderAmount >= naturalGasRule[i - 1].naturalGasRule1 && that.oilOrder.orderAmount < naturalGasRule[i].naturalGasRule1) {
that.gradeRedece = (that.oilOrder.orderAmount/that.oilPrice * naturalGasRule[i - 1].naturalGasRule3).toFixed(2)
that.isGradePreferential = true
}
}
}else{
if (that.oilOrder.orderAmount >= naturalGasRule[naturalGasRule.length-1].naturalGasRule1){
that.gradeRedece = (that.oilOrder.orderAmount/that.oilPrice * naturalGasRule[naturalGasRule.length-1].naturalGasRule3).toFixed(2)
that.isGradePreferential = true
}
}
}
}
}
that.isFixingLevel = true
// if (res.data.fixingLevel.storeValue=="no" && that.balanceRedece>0){
// that.gradeRedece = 0
// }
}
}
})
},
// 查看是否有可使用的优惠活动
chooseFullOrCoupon(){
console.log("full");
this.transferDTO.amount = this.deductAmount
this.transferDTO.mtUserLevel = this.userGrade.id
this.transferDTO.oilId = this.oilId
let _this = this;
request({
url: "business/marketingActivity/activeExchange/test",
method: 'post',
data:_this.transferDTO,
}).then((res) => {
if (res.data.amount>0){
_this.payAmount = res.data.amount - _this.gradeRedece
_this.fullRedece = res.data.favorableAmount
_this.isFullPreferential = true
}
})
},
// 查看是否有可使用的优惠券
chooseCoupons(){
console.log("coupons");
request({
url: 'business/marketingActivity/cardFavorable/applet',
method: 'get',
params: this.query
}).then(res => {
if (res.data.records) {
console.log(res.data.records);
this.cardsList = res.data.records
if (this.cardsList.length>0){
this.couponRedece = this.cardsList[0].couponAmount
}
}
})
},
// 计算用户应付金额
countPayMent(){
this.payAmount = this.deductAmount;
// console.log("111",this.deductAmount, this.gradeRedece, this.fullRedece, this.couponRedece);
},
// 根据店铺id查询用户信息
async getUser(id){
let _this = this;
request({
url: "business/userManager/user/storeUser",
method: 'post',
data:{storeId:_this.oilOrder.storeId,userId:id}
}).then((res) => {
if (res.data.isUseChild=='yes'){
_this.isUseChildCard = true
}else{
_this.isUseChildCard = false
}
_this.user = res.data.userVo;
_this.user = res.data.userVo;
_this.chooseGrade(_this.user.id,_this.user.gradeId);
if (res.data.userVo.refuelMoney && res.data.userVo.refuelMoney!='null'){
_this.refuelMoney = JSON.parse(res.data.userVo.refuelMoney)
_this.refuelMoneyAfter = JSON.parse(res.data.userVo.refuelMoney)
_this.chooseRefuelMoney()
}else{
if (!this.isFixingLevel){
_this.getPaymentPreferential(this.user.gradeId)
}else{
_this.chooseCardBalance(0)
}
}
console.log("afterGrade");
// _this.chooseGrade(res.data.userVo.id,res.data.userVo.gradeId)
})
},
getPaymentPreferential(gradeId){
let type = 0;
if (this.balanceRedece==0){
type = 1
}else{
type = 0
}
let map = {
//支付类型 0储值卡 1囤油卡
type: type,
//支付金额
amount: this.oilOrder.orderAmount,
//可用油品Id
oilId: this.oilOrder.oils,
//店铺id
storeId: this.oilOrder.storeId,
//会员等级
mtUserLevel: gradeId,
//用户id
userId: this.oilOrder.userId,
}
request({
url: "business/marketingActivity/activeExchange/getPaymentActive",
method: 'get',
params:map,
}).then((res) => {
this.preferentialData = res.data
if (res.data.memberFavorableAmount){
this.gradeRedece = res.data.memberFavorableAmount
}
if (res.data.cardFavorableAmount){
this.couponRedece = res.data.cardFavorableAmount
}
if (res.data.activeFavorableAmount){
this.fullRedece = res.data.activeFavorableAmount
}
console.log(this.gradeRedece,this.couponRedece,this.fullRedece,res.data.memberFavorableAmount,"2231");
this.chooseCardBalance(0)
// this.payAmount = (this.payAmount - this.fullRedece - this.couponRedece - this.gradeRedece).toFixed(2)
})
},
// 获取油品订单
getOilOrder() {
let _this = this;
request({
// url: "business/oilOrder/orderNo",
url: "business/oilOrder/oilOrderNo",
method: 'post',
data: {
orderNo: _this.orderNo
},
}).then((res) => {
if(res.data){
// console.log(res);
_this.oilOrder = res.data
// _this.getStaffList(res.data.staffId)
// _this.getStore(res.data.storeId)
_this.getOilNumber(res.data.storeId)
// _this.chooseCoupons()
// 判断是否登录
if (_this.AppToken) {
_this.getUser(res.data.userId)
_this.ifLogin = true
}else{
_this.ifLogin = false
_this.payAmount = _this.oilOrder.orderAmount
}
}
})
},
// 获取门店信息
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.oilPrice;
_this.oilName = item.oilNames;
_this.oilNameId = item.oilName;
_this.oilType = item.oilType;
_this.oilId = item.oilId;
}
})
})
},
// 返回
goBack() {
uni.navigateBack()
}
}
}
</script>
<style scoped lang="scss">
.scc{
display: flex;
justify-content: space-around;
margin-top: 10px;
height: 40px;
font-size: 18px;
line-height: 40px;
}
.imgIcon{
width: 30px;
height: 30px;
border-radius: 50%;
margin-top: 10px;
}
.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>