oil-station/gasStation-uni/pagesRefuel/orderDetail/index.vue

493 lines
13 KiB
Vue
Raw Normal View History

2023-12-01 15:47:01 +08:00
<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;">
2023-12-01 16:40:20 +08:00
<view style="font-weight: bold;height: 40px;line-height: 40px;margin-left: 10px;margin-top: 20px;">订单详情
</view>
2023-12-01 15:47:01 +08:00
<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>
2023-12-26 18:44:50 +08:00
<view>{{oilOrder.orderAmount}}</view>
2023-12-01 15:47:01 +08:00
</view>
<view class="desc">
<view>加油数量</view>
2023-12-26 18:44:50 +08:00
<view>{{oilOrder.oilNum}}L</view>
2023-12-01 15:47:01 +08:00
</view>
<view class="desc">
<view>油品单价</view>
2023-12-26 18:44:50 +08:00
<view>{{oilPrice}}/L</view>
2023-12-01 15:47:01 +08:00
</view>
<view class="desc">
<view>加油员工</view>
<view>{{staff.realName}}</view>
</view>
</view>
2023-12-01 16:40:20 +08:00
2023-12-01 15:47:01 +08:00
<view style="background-color: white;width: 94%;margin: 15px auto;">
2023-12-26 18:44:50 +08:00
<view class="desc" v-if="isOilStorageCard">
2023-12-04 16:35:09 +08:00
<view style="display: flex;">
2023-12-26 18:44:50 +08:00
囤油卡
<span style="display: flex;">(余额{{refuelBalance}}L)</span>
2023-12-04 16:35:09 +08:00
</view>
<view style="display: flex;">
2023-12-26 18:44:50 +08:00
<span style="margin-right: 10px;">- {{oilCardRedece}}L</span>
2023-12-04 16:35:09 +08:00
</view>
2023-12-01 15:47:01 +08:00
</view>
2023-12-04 16:35:09 +08:00
2023-12-26 18:44:50 +08:00
<view class="desc" v-if="isStoreValueCard">
2023-12-01 15:47:01 +08:00
<view style="display: flex;">
2023-12-26 18:44:50 +08:00
储值卡
<span style="display: flex;">(余额{{user.cardBalance}})</span>
2023-12-04 16:35:09 +08:00
</view>
<view style="display: flex;">
2023-12-26 18:44:50 +08:00
<span style="margin-right: 10px;">-{{balanceRedece}}</span>
2023-12-04 16:35:09 +08:00
</view>
</view>
2023-12-26 18:44:50 +08:00
<view class="desc">
2023-12-04 16:35:09 +08:00
<view style="display: flex;">
2023-12-26 18:44:50 +08:00
会员等级优惠
<span style="display: flex;">(会员等级)</span>
2023-12-04 16:35:09 +08:00
</view>
<view style="display: flex;">
<span style="margin-right: 10px;">-{{gradeRedece}}</span>
</view>
</view>
2023-12-08 15:48:54 +08:00
<view style="margin: 10px 20px 0;color: red;font-size: 12px;">囤油卡不参与任何优惠活动</view>
2023-12-01 15:47:01 +08:00
</view>
2023-12-01 16:40:20 +08:00
2023-12-26 18:44:50 +08:00
<view style="background-color: white;width: 94%;margin: 15px auto;height: 100px;">
2023-12-01 16:40:20 +08:00
<view style="font-weight: bold;height: 40px;line-height: 40px;margin-left: 10px;margin-top: 20px;">支付方式
</view>
2023-12-18 18:44:02 +08:00
<!-- <view class="desc">
2023-12-01 15:47:01 +08:00
<view>微信支付</view>
<u-radio-group v-model="value">
<u-radio name="wx"></u-radio>
</u-radio-group>
2023-12-18 18:44:02 +08:00
</view> -->
<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" />
2023-12-01 15:47:01 +08:00
</view>
</view>
<!-- 支付信息 -->
<view class="bar">
<view style="margin-left: 20px;">
<view>
2023-12-04 16:35:09 +08:00
<span style="font-size: 22px;font-weight: bold;">{{payAmount}}</span>
2023-12-01 15:47:01 +08:00
</view>
<view style="color: red;font-size: 12px;">应付金额</view>
</view>
2023-12-06 18:36:10 +08:00
<view @click="payment"
2023-12-01 16:40:20 +08:00
style="margin-right: 20px;width: 30%;border-radius:30px;background-color: #1879ff;height: 40px;line-height: 40px;text-align: center;color: white">
2023-12-01 15:47:01 +08:00
确认支付
</view>
</view>
</view>
</view>
</template>
<script>
import request from '../../utils/request'
export default {
data() {
return {
2023-12-07 18:28:31 +08:00
gradeDis:"",
2023-12-01 15:47:01 +08:00
title: '',
2023-12-08 15:48:54 +08:00
value: true,
2023-12-01 16:40:20 +08:00
orderNo: "",
2023-12-01 15:47:01 +08:00
// 油品订单信息
2023-12-01 16:40:20 +08:00
oilOrder: {},
2023-12-01 15:47:01 +08:00
// 员工列表信息
staff: {},
// 店铺信息
2023-12-01 16:40:20 +08:00
store: {},
oilPrice: 0,
2023-12-01 15:47:01 +08:00
// 油品名称
2023-12-01 16:40:20 +08:00
oilName: "",
2023-12-04 16:35:09 +08:00
// 油品类型
oilType:"",
// 用户信息
user:{
cardBalance:0,
},
2023-12-26 18:44:50 +08:00
// 储值卡升数
refuelBalance:0,
2023-12-04 16:35:09 +08:00
// 会员等级信息
userGrade:{},
balanceRedece:0,
oilCardRedece:0,
gradeRedece:0,
fullRedece:0,
couponRedece:0,
hoardAmount:0,
// 囤油卡信息
refuelMoney:[],
// 会员等级优惠信息
gradeDiscount:[],
// 优惠券优惠信息
couponDiscount:[],
// 满减优惠信息
fullReduceDiscount:[],
2023-12-26 18:44:50 +08:00
// 支付金额
2023-12-04 16:35:09 +08:00
payAmount:0,
2023-12-26 18:44:50 +08:00
// 调起支付所需的数据
orderInfo:{},
2023-12-04 16:35:09 +08:00
// 是否使用囤油卡
isOilStorageCard:false,
2023-12-26 18:44:50 +08:00
// 是否使用储值卡
isStoreValueCard:false,
2023-12-01 15:47:01 +08:00
}
},
onLoad(e) {
2023-12-26 18:44:50 +08:00
// this.orderNo = e.orderNo
this.orderNo = "234520231226154037a1f53b"
2023-12-01 15:47:01 +08:00
},
onShow() {
this.getOilOrder();
},
components: {
},
methods: {
2023-12-06 18:36:10 +08:00
// 支付接口
payment(){
2023-12-08 15:48:54 +08:00
let refuel = this.refuelMoney
refuel.refuelMoney = this.refuelMoney.refuelMoney - this.oilCardRedece
2023-12-06 18:36:10 +08:00
let map = {
2023-12-08 15:48:54 +08:00
orderNo : this.orderNo,
payAmount : this.payAmount,
// payAmount : "0.01",
discountAmount : this.fullRedece+this.gradeRedece+this.couponRedece,
oilCardAmount : JSON.stringify(refuel),
oilCardLiters : this.oilCardRedece,
2023-12-06 18:36:10 +08:00
balanceAmount : this.balanceRedece,
2023-12-08 15:48:54 +08:00
isOilStorageCard : this.isOilStorageCard,
tankId : uni.getStorageSync("tankId"),
// tankId : 6,
2023-12-06 18:36:10 +08:00
};
let _this = this;
2023-12-05 17:18:27 +08:00
request({
2023-12-06 18:36:10 +08:00
url: "business/oilOrder/appletPay",
2023-12-05 17:18:27 +08:00
method: 'post',
2023-12-06 18:36:10 +08:00
data: map,
2023-12-05 17:18:27 +08:00
}).then(res => {
console.log(res)
2023-12-20 16:04:56 +08:00
let payProvider = "wxpay"
// if (_this.appltType== "WECHAT"){
// payProvider = "wxpay"
// }else{
// payProvider = "alipay"
// }
2023-12-25 18:10:00 +08:00
if (res.data.reservedPayInfo!=null && res.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:',res);
uni.reLaunch({
url: '/pagesRefuel/orderSuccess/index'
2023-12-20 16:04:56 +08:00
})
2023-12-25 18:10:00 +08:00
},
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);
}
});
}else{
2023-12-26 18:44:50 +08:00
my.tradePay({ tradeNO: res.data.data.reservedTransactionId }, function(resp){
if(resp.resultCode == '9000'){
console.log("支付成功")
}else{
request({
url: "/business/allOrderInfo/orderStatus",
method: 'post',
data: {"orderNo":res.data.data.orderNo,"status":"payFail"},
}).then((res)=>{
uni.showToast({
title:"支付失败!",
icon:"error"
2023-12-25 18:10:00 +08:00
})
2023-12-26 18:44:50 +08:00
})
console.log('支付失败,'+resp.resultCode);
2023-12-04 16:35:09 +08:00
}
2023-12-26 18:44:50 +08:00
});
2023-12-04 16:35:09 +08:00
}
2023-12-26 18:44:50 +08:00
})
2023-12-04 16:35:09 +08:00
},
2023-12-26 18:44:50 +08:00
// 查看是否有可使用的囤油卡
chooseRefuelMoney(){
let falg = false;
this.refuelMoney.forEach(item => {
if (item.oilType == this.oilName){
falg = true
this.refuelBalance = item.refuelMoney
this.isOilStorageCard = true
if (this.oilCardRedece >= this.oilOrder.oilNum){
this.oilCardRedece = this.oilOrder.oilNum
}else{
this.oilCardRedece = item.refuelMoney
this.chooseCardBalance(1)
}
2023-12-04 16:35:09 +08:00
}
2023-12-26 18:44:50 +08:00
})
if (falg == false) {
this.chooseCardBalance(0)
2023-12-04 16:35:09 +08:00
}
},
2023-12-26 18:44:50 +08:00
// 查看是否有可使用的储值卡金额
chooseCardBalance(val){
if (this.user.cardBalance>0) {
this.isStoreValueCard = true;
if (val == 0) {
// 没有使用囤油卡
if (this.user.cardBalance >= this.oilOrder.orderAmount){
this.balanceRedece = this.oilOrder.orderAmount
} else {
this.balanceRedece = this.user.cardBalance
this.payAmount = this.oilOrder.orderAmount - this.balanceRedece
2023-12-04 16:35:09 +08:00
}
2023-12-26 18:44:50 +08:00
}else{
// 使用囤油卡
// 扣除囤油卡金额后需要支付的金额
let residueAmount = (this.oilOrder.oilNum - this.oilCardRedece) * this.oilPrice
if (this.user.cardBalance >= residueAmount){
this.balanceRedece = residueAmount
} else {
this.balanceRedece = this.user.cardBalance
this.payAmount = (this.oilOrder.orderAmount - residueAmount - this.balanceRedece).toFixed(2)
2023-12-04 16:35:09 +08:00
}
2023-12-26 18:44:50 +08:00
}
}
2023-12-04 16:35:09 +08:00
},
2023-12-26 18:44:50 +08:00
// 查看是否有可使用的会员等级优惠
chooseGrade(id){
let that = this;
2023-12-04 16:35:09 +08:00
request({
url: "business/userManager/userGrade/isUse/" + id,
method: 'get',
2023-12-26 18:44:50 +08:00
}).then((res) => {
console.log(res,that.oilType)
if (res.data != null && res.data != ""){
if (res.data.preferential== "自定义优惠"){
if (that.oilType == "汽油"){
// 将数组按照金额从小到大排序
let gasolineRule = JSON.parse(res.data.gasolineRule).sort((a,b) => a.gasolineRule1 - b.gasolineRule1);
console.log(gasolineRule,222)
if (res.data.gasolineDiscount == "满减优惠"){
for (let i = 0; i<gasolineRule.length; i++){
if (that.oilOrder.orderAmount >= gasolineRule[gasolineRule.length-1].gasolineRule1){
that.gradeRedece = gasolineRule[gasolineRule.length-1].gasolineRule2
break;
}
if (item.amount >= gasolineRule[i - 1].gasolineRule1 && item.amount < gasolineRule[i].gasolineRule1) {
discount.full = gasolineRule[i - 1].gasolineRule1
oilDiscount = gasolineRule[i - 1].gasolineRule2
discount.reduce = gasolineRule[i - 1].gasolineRule2
}
}
2023-12-04 16:35:09 +08:00
}
2023-12-26 18:44:50 +08:00
if (res.data.gasolineDiscount == "每升优惠"){
2023-12-04 16:35:09 +08:00
}
}
2023-12-26 18:44:50 +08:00
if (that.oilType == "柴油"){
2023-12-04 16:35:09 +08:00
}
2023-12-26 18:44:50 +08:00
if (that.oilType == "天然气"){
2023-12-04 16:35:09 +08:00
}
}
}
})
},
2023-12-26 18:44:50 +08:00
2023-12-04 16:35:09 +08:00
// 根据用户id查询用户信息
getUser(id){
let _this = this;
request({
url: "business/userManager/user/" + id,
method: 'get',
}).then((res) => {
2023-12-26 18:44:50 +08:00
// console.log(res)
2023-12-04 16:35:09 +08:00
_this.user = res.data;
2023-12-06 18:36:10 +08:00
if (res.data.refuelMoney!=null && res.data.refuelMoney!=""){
_this.refuelMoney = JSON.parse(res.data.refuelMoney)
2023-12-26 18:44:50 +08:00
_this.chooseRefuelMoney()
}else{
_this.chooseCardBalance(0)
2023-12-06 18:36:10 +08:00
}
2023-12-26 18:44:50 +08:00
_this.chooseGrade(res.data.gradeId)
2023-12-04 16:35:09 +08:00
})
},
2023-12-01 15:47:01 +08:00
// 获取油品订单
2023-12-01 16:40:20 +08:00
getOilOrder() {
2023-12-01 15:47:01 +08:00
let _this = this;
request({
url: "business/oilOrder/orderNo",
method: 'post',
2023-12-01 16:40:20 +08:00
data: {
orderNo: _this.orderNo
},
}).then((res) => {
2023-12-01 15:47:01 +08:00
_this.oilOrder = res.data
_this.getStaffList(res.data.staffId)
_this.getStore(res.data.storeId)
_this.getOilNumber(res.data.storeId)
2023-12-04 16:35:09 +08:00
_this.getUser(res.data.userId)
2023-12-01 15:47:01 +08:00
})
},
// 获取门店信息
2023-12-01 16:40:20 +08:00
getStore(id) {
2023-12-01 15:47:01 +08:00
let _this = this;
request({
url: "business/storeInformation/store/queryStoreById",
method: 'post',
2023-12-01 16:40:20 +08:00
data: {
"storeId": id
},
}).then((res) => {
2023-12-01 15:47:01 +08:00
_this.store = res.data;
})
},
// 根据员工id获取员工信息
2023-12-01 16:40:20 +08:00
getStaffList(staffId) {
2023-12-01 15:47:01 +08:00
let _this = this;
request({
url: "business/member/staff/" + staffId,
method: 'get',
2023-12-01 16:40:20 +08:00
}).then((res) => {
2023-12-01 15:47:01 +08:00
_this.staff = res.data
})
},
// 获取当前店铺油号信息
2023-12-01 16:40:20 +08:00
getOilNumber(storeId) {
2023-12-01 15:47:01 +08:00
let _this = this;
request({
url: "business/petrolStationManagement/oilNumber/getOilNumberName/" + storeId,
method: 'get',
2023-12-01 16:40:20 +08:00
}).then((res) => {
2023-12-01 15:47:01 +08:00
res.data.forEach(item => {
2023-12-01 16:40:20 +08:00
if (item.oilName == _this.oilOrder.oils) {
2023-12-01 15:47:01 +08:00
_this.oilPrice = item.gbPrice;
_this.oilName = item.oilNames;
2023-12-04 16:35:09 +08:00
_this.oilType = item.oilType;
2023-12-01 15:47:01 +08:00
}
})
})
},
2023-12-26 18:44:50 +08:00
// 返回
2023-12-01 15:47:01 +08:00
goBack() {
uni.navigateBack()
}
}
}
</script>
<style scoped lang="scss">
2023-12-18 18:44:02 +08:00
.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;
}
2023-12-01 16:40:20 +08:00
.desc {
2023-12-01 15:47:01 +08:00
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);
}
2023-12-01 16:40:20 +08:00
2023-12-01 15:47:01 +08:00
.bar {
width: 100%;
height: 70px;
background-color: white;
position: fixed;
bottom: 0px;
display: flex;
align-items: center;
justify-content: space-between;
}
2023-12-01 16:40:20 +08:00
2023-12-01 15:47:01 +08:00
.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>