111
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

715 lines
22 KiB

2 years ago
<template>
<view>
<cu-custom class="main-totextbar bg-main-oil" :isPay='true' :isBack="true" bgColor="bg-main-oil">
<block slot="backText">返回</block>
<block slot="content">星油收银台</block>
</cu-custom>
<view class="">
<view class="padding-xl text-center">
1 year ago
<text class="text-xxl text-bold oil-main-color" v-if='type == "oil"'>
2 years ago
{{order.realAmount>0?order.realAmount:'xxx.x'|moneyFormat}}
</text>
<text class="text-xxl text-bold oil-main-color" v-if='type == "urea"'>
{{order.oldRealAmount>0?order.oldRealAmount:'xxx.x'|moneyFormat}}
</text>
<view class="text-gray">
支付剩余时间 <time-down :is-day="false" :is-hour="false" :tip-text="' '" :day-text="' '" :hour-text="':'"
:minute-text="':'" :second-text="' '" :datatime="datatime"></time-down>
</view>
</view>
<view class=" radius my-shadow solid-top margin margin-top-0">
<view class="cu-list menu" v-if="!isCompany">
<view class="cu-item" v-show="order.personalStatus" @tap="selectPersonCard(order.personalAccount)">
<view class="content">
<view class="text-left">
<view class="site-icon-sm">
<image :src="imgURL+'pay-gr.png'" mode="widthFix" width="100upx"></image>
</view>
<text
class="padding-left-sm">个人油卡支付余额{{order.personalAccount.balance|moneyFormat}}</text>
</view>
</view>
<view class="action">
<view class="site-icon-sm">
<image :src="imgURL+ (checked == 'person'?'pay-xz.png':'pay-qx.png')" mode="widthFix"
width="100upx"></image>
<!-- <image :src="imgURL+'pay-qx.png'" mode="widthFix" width="100upx"></image> -->
</view>
</view>
</view>
<!-- <view class="cu-item" v-show="order.wxPayStatus" @tap="selWX">
<view class="content">
<view class="text-left">
<view class="site-icon-sm">
<image :src="imgURL+'pay-wx.png'" mode="widthFix" width="100upx"></image>
</view>
<text class="padding-left-sm">微信支付</text>
</view>
</view>
<view class="action">
<view class="site-icon-sm check-icon">
<image :src="imgURL+(checked == 'weixin'?'pay-xz.png':'pay-qx.png') " mode="widthFix"
width="100upx"></image>
</view>
</view>
</view> -->
</view>
<view class="cu-list menu" v-if="isCompany">
<view class="cu-item" v-show="order.companyStatus" @tap="selectCompanyCard(item)"
v-for="item in companyList" :key="item.id">
<view class="content padding-tb-sm">
<view class="text-left">
<view class="site-icon-sm">
1 year ago
<image src="https://xoi-support.oss-cn-hangzhou.aliyuncs.com/星油运营小程序/gr.png"
mode="widthFix" width="100upx"></image>
2 years ago
</view>
<text class="padding-left-sm">自营企业油卡支付 <text
v-if="item.shareCompanyQuota==0">余额{{item.balance|moneyFormat}}</text></text>
<!-- <text class="padding-left-sm">企业油卡支付</text> -->
</view>
<view class="text-sm padding-left-xl margin-left-xs">
{{item.companyName}} {{item.shareCompanyQuota==1?'共享额度':'非共享'}}
</view>
<view class="text-sm padding-left-xl margin-left-xs">
<text class="">
(单次金额上限{{item.orderAmountToplimit}};单笔加油升数上限{{item.orderVolumeToplimit}}L)</text>
</view>
</view>
<view class="action">
<view class="site-icon-sm">
<image :src="imgURL+(checked == item.accountCardCode?'pay-xz.png':'pay-qx.png')"
mode="widthFix" width="100upx"></image>
<!-- <image :src="imgURL+'pay-qx.png'" mode="widthFix" width="100upx"></image> -->
</view>
</view>
</view>
<view class="cu-item" v-show="order.companyStatus" @tap="selectCompanyCard(itemx)"
v-for="itemx in companyOtherList" :key="itemx.id">
<view class="content padding-tb-sm">
<view class="text-left">
<view class="site-icon-sm">
<image :src="imgURL+'pay-qy.png'" mode="widthFix" width="100upx"></image>
</view>
<text class="padding-left-sm">外请油卡支付余额{{itemx.balance|moneyFormat}}</text>
<!-- <text class="padding-left-sm">企业油卡支付</text> -->
</view>
<view class="text-sm padding-left-xl margin-left-xs">
{{itemx.companyName}}
</view>
</view>
<view class="action">
<view class="site-icon-sm">
<image
:src="imgURL+(card.accountCardCode == itemx.accountCardCode?'pay-xz.png':'pay-qx.png')"
mode="widthFix" width="100upx"></image>
<!-- <image :src="imgURL+'pay-qx.png'" mode="widthFix" width="100upx"></image> -->
</view>
</view>
</view>
1 year ago
<!-- 尿素 -->
<view class="cu-item" v-if='type == "urea"' @tap="ureaSelectCompanyCard(itemx)"
v-for="itemx in ureaCompanyOtherList" :key="itemx.id">
<view class="content padding-tb-sm">
<view class="text-left">
2 years ago
<view class="site-icon-sm">
1 year ago
<image :src="imgURL+'pay-qy.png'" mode="widthFix" width="100upx"
v-if='itemx.companyNature =="0"'></image>
<image src="https://xoi-support.oss-cn-hangzhou.aliyuncs.com/星油运营小程序/gr.png"
mode="widthFix" width="100upx" v-if='itemx.companyNature =="1"'></image>
2 years ago
</view>
1 year ago
<text class="padding-left-sm"
v-if='itemx.companyNature =="0"'>外请油卡支付余额{{itemx.balance|moneyFormat}}</text>
<text class="padding-left-sm" v-if='itemx.companyNature =="1"'>企业油卡支付
{{itemx.companyNature =="1" ? itemx.shareCompanyQuota==0? '(余额:'+itemx.balance+')' :'':''}}
</text>
2 years ago
</view>
1 year ago
<view class="text-sm padding-left-xl margin-left-xs">
{{itemx.name}} {{itemx.shareCompanyQuota==1?'共享额度':'非共享'}}
</view>
</view>
<view class="action">
<view class="site-icon-sm">
<image
:src="imgURL+(card.accountCardCode == itemx.accountCardCode?'pay-xz.png':'pay-qx.png')"
mode="widthFix" width="100upx"></image>
<!-- <image :src="imgURL+'pay-qx.png'" mode="widthFix" width="100upx"></image> -->
</view>
</view>
</view>
2 years ago
</view>
</view>
<view class=" radius my-shadow solid-top margin margin-top-0">
<view class="bg-gray text-center padding-sm margin-bottom-sm">
请提醒加油员使用
<text class="oil-main-color">{{showtitles}}</text>
进行订单核销
</view>
<view class="padding" v-if='type == "oil"'>
<view class="padding-bottom-xs margin-bottom-xs dashed-bottom">
<view class="padding-tb-xs text-left" @tap="onCopy(order.orderSerialNumber)">
订单编号
<text class="fr">{{order.orderSerialNumber?order.orderSerialNumber:''}} <text
class="cuIcon-copy padding-left-xs"></text></text>
</view>
</view>
<view class="padding-tb-xs text-left">
油站
1 year ago
<view class="fr">{{order.siteName?order.siteName:''}}
<!-- <text v-if="order.siteLevel" class="cu-tag text-xs tag-red" style="margin-left: 20px;">{{order.siteLevel}}</text> -->
2 years ago
</view>
2 years ago
</view>
<view class="padding-tb-xs text-left">
油品油枪
<text
2 years ago
class="fr nowrap">{{order.oilsCode?order.oilsCode+' ':''}}&{{ order.gunName?order.gunName+'号枪': order.oilsBar?order.oilsBar+'号枪':'未选择油枪'}}</text>
2 years ago
</view>
<view class="padding-tb-xs text-left">
加油升数
<text class="fr">{{order.volume?order.volume :'xxx.x' | moneyFormath}} L</text>
</view>
<view class="dashed-top margin-top-xs padding-top-sm">
<view class="padding-tb-xs text-left">
加油金额
<!-- <text
class="fr">{{order.oilDiscountAmount>0?order.realAmount+order.oilDiscountAmount:order.realAmount|moneyFormat}}</text> -->
1 year ago
<text class="fr">{{ moneyIntercept(order.xoilAmountGun )}}</text>
2 years ago
</view>
</view>
<view class="padding-tb-xs text-left">
星油优惠
2 years ago
<!-- order.oilDiscountAmount>0?order.oilDiscountAmount:'xxx.x'|moneyFormat -->
1 year ago
<text class="text-red fr">{{ moneyIntercept(order.oilDiscountAmount)}}</text>
2 years ago
</view>
<view class="padding-tb-xs text-left">
优惠券
<text
class="text-red fr">{{order.couponDiscountAmount>0?order.couponDiscountAmount:'xxx.x'|moneyFormat}}</text>
</view>
<view class="padding-tb-xs text-left">
合计
<text
class="text-red text-bold text-lg fr">{{order.realAmount>0? '¥'+ order.realAmount:'xxx.x'|}}</text>
</view>
</view>
<view class="padding" v-if='type == "urea"'>
<view class="padding-bottom-xs margin-bottom-xs dashed-bottom">
<view class="padding-tb-xs text-left" @tap="onCopy(order.orderId)">
订单编号
<text class="fr">{{order.orderId?order.orderId:''}} <text
class="cuIcon-copy padding-left-xs"></text></text>
</view>
</view>
<view class="padding-tb-xs text-left">
油站
1 year ago
<view class="fr">{{order.siteName?order.siteName:''}}
<!-- <text v-if="order.siteLevel" class="cu-tag text-xs tag-red" style="margin-left: 20px;">{{order.siteLevel}}</text> -->
2 years ago
</view>
2 years ago
</view>
<view class="padding-tb-xs text-left">
加注类型
1 year ago
<text class="fr nowrap">{{order.formats | ureaFormats }}</text>
</view>
2 years ago
<view class="padding-tb-xs formats_box" v-if='order.formats == "2"'>
<view class="formats_box_list" v-for="(list,i) in order.xoilUreaOrderRelations " :key='i'>
<view class="formats_box_list_left w30">
{{list.brandName}}
</view>
1 year ago
<view class="formats_box_list_main w30">{{list.options}}/<text
style="color: red;">X{{list.goodsQuantity}}</text> </view>
2 years ago
<view class="formats_box_list_right w30">&#165;{{list.totalPrice}}</view>
</view>
</view>
1 year ago
<view class="padding-tb-xs text-left" v-if='order.formats != "2"'>
2 years ago
加注量
<text class="fr">{{order.oldRealLiter?order.oldRealLiter :'xxx.x' }}</text>
1 year ago
</view>
2 years ago
<view class="padding-tb-xs text-left">
合计
1 year ago
<text
class="text-red text-bold text-lg fr">{{order.oldRealAmount>0? '¥'+ order.oldRealAmount:'xxx.x'|}}</text>
2 years ago
</view>
</view>
</view>
<view class="padding placeholder-hidden">
1 year ago
<button class="cu-btn block lg bg-main-oil" :disabled='isdisabled' @tap="payOrder">立即支付</button>
2 years ago
<button class="cu-btn margin-top block lg " @tap="cancelOrder(order.orderSerialNumber)">取消订单</button>
</view>
<view class="padding fixed-bar-bottom">
1 year ago
<button class="cu-btn block lg bg-main-oil" :disabled='isdisabled' @tap="payOrder">立即支付</button>
2 years ago
<button class="cu-btn margin-top block lg " @tap="cancelOrder(order.orderSerialNumber)">取消订单</button>
</view>
<view class="padding fixed-bar-bottom" v-if='type == "urea"'>
1 year ago
<button class="cu-btn block lg bg-main-oil" :disabled='isdisabled' @tap="payOrder">立即支付</button>
2 years ago
<button class="cu-btn margin-top block lg " @tap="ureaCancelOrder(order.orderId)">取消订单</button>
</view>
</view>
1 year ago
<AbnormalPopup :types='PopupType' :checkType='checkType' @hidenPopup='hidenPopup' :PopupShows='PopupShow'
@getureaFinanceApi='getureaFinanceApi'></AbnormalPopup>
2 years ago
</view>
</template>
<script>
import timeDown from '@/components/xw-CountDown'
import oilOrderApi from '@/api/oil-order.js'
import oilFinanceApi from '@/api/oil-finance.js'
import ureaFinanceApi from '../../../api/urea_finance.js'
import AbnormalPopup from '../../../components/AbnormalPopup.vue'
export default {
components: {
timeDown,
AbnormalPopup
},
data() {
1 year ago
return {
checkType: false,
PopupType: null,
PopupShow: false,
ureaInfo: {
accountCardCode: '',
companyId: ''
2 years ago
},
1 year ago
isdisabled: false,
showtitles: "",
2 years ago
imgURL: this.global.imgURL,
1 year ago
order: {},
2 years ago
activePay: 0,
isCompany: uni.getStorageSync('accountStatus'),
accountCardCode: '',
card: {},
datatime: "",
checked: '',
cooling: false,
1 year ago
payMethod: 0,
user: uni.getStorageSync('user'),
type: '',
ureaCompanyOtherList: [],
companyNature: '',
shareCompanyQuota: ''
2 years ago
}
},
onLoad(option) {
1 year ago
if (option.type == 'urea') {
this.order = uni.getStorageSync('ureaOrderMade')
2 years ago
this.order.companyStatus = true
this.type = 'urea'
this.findUreaAccount()
1 year ago
} else {
2 years ago
let oilItem = uni.getStorageSync('oilItem')
2 years ago
// console.log
1 year ago
this.order = uni.getStorageSync('orderMade')
2 years ago
this.type = 'oil'
1 year ago
this.showtitles = oilItem.listTag
if (option.payMethod == null) {
this.payMethod = oilItem.payMethod
2 years ago
// console.log(this.payMethod )
1 year ago
} else {
this.payMethod = option.payMethod
2 years ago
}
1 year ago
}
2 years ago
},
computed: {
companyList() {
if (this.isCompany) {
return this.order.companyAccounts
}
},
companyOtherList() {
if (this.isCompany) {
1 year ago
// return this.order.otherAccounts
let target = this.sortParticulars(this.order.otherAccounts,'balance')
return target
2 years ago
}
}
},
onShow() {
this.datatime = this.timF(this.order.createTime)
},
onReady() {
if (this.isCompany) {
this.card = this.order.companyAccounts[0]
this.checked = this.card.accountCardCode
this.accountCardCode = this.card.accountCardCode
} else {
this.card = this.order.personalAccount
this.checked = 'person'
this.accountCardCode = this.card.accountCardCode
}
},
1 year ago
methods: {
sortParticulars(arr, field) {
let map = new Map()
let keys = [],
values = [],
target = []
arr.forEach(item => {
map.set(item, item[field])
})
for (let key of map.keys()) {
keys.push(key)
}
for (let value of map.values()) {
values.push(value)
}
values.sort()
values.reverse()
values.forEach(value => {
keys.forEach(key => {
if (map.get(key) == value) {
target.push(key)
map.set(key, new Date().getTime())
}
})
})
return target
},
getureaFinanceApi() {
ureaFinanceApi.queryWhetherToHangUp(this.order.orderId).then(res => {
if (res.data == '2') {
this.checkType = true
2 years ago
}
})
},
1 year ago
hidenPopup(e) {
2 years ago
console.log(e)
1 year ago
this.PopupShow = e
2 years ago
},
1 year ago
findUreaAccount() {
2 years ago
ureaFinanceApi.findUreaAccount(this.order.driverId).then(res => {
console.log(res)
this.ureaCompanyOtherList = res.data
})
},
timF(date) {
date = date.substring(0, 19)
date = date.replace(/-/g, '/')
var timestampDeadline = (new Date(date).getTime()) / 1000 + 60 * 10
return timestampDeadline
},
ureaCancelOrder(id) {
1 year ago
console.log(id)
2 years ago
ureaFinanceApi.cancelTheOrder(id).then(res => {
console.log(res)
if (res.code == 20000) {
uni.showToast({
title: res.msg,
icon: 'none',
duration: 1000
})
setTimeout(() => {
uni.navigateBack(2)
}, 1000)
1 year ago
2 years ago
}
})
},
cancelOrder(id) {
oilOrderApi.cancelOrder(id).then(res => {
if (res.code == 20000) {
uni.showToast({
title: res.msg,
icon: 'none',
duration: 1000
})
setTimeout(() => {
uni.navigateBack(2)
}, 1000)
}
})
},
selWX() {
this.activePay = 2
this.checked = 'weixin'
},
selectPersonCard(card) {
this.activePay = 0
this.card = card
this.checked = 'person'
},
1 year ago
ureaSelectCompanyCard(card) {
2 years ago
this.ureaInfo.accountCardCode = card.accountCardCode
this.ureaInfo.companyId = card.companyId
this.card = card
this.checked = card.accountCardCode
this.accountCardCode = card.accountCardCode
this.companyNature = card.companyNature
1 year ago
this.shareCompanyQuota = card.shareCompanyQuota
2 years ago
},
selectCompanyCard(card) {
1 year ago
console.log(card)
2 years ago
this.card = card
this.checked = card.accountCardCode
this.accountCardCode = card.accountCardCode
},
payOrder() {
this.isdisabled = true
if (!this.cooling) {
this.cooling = true
setTimeout(() => {
this.cooling = false
}, 5000)
1 year ago
if (this.activePay == 0) {
this.selfCardPay()
2 years ago
} else if (this.activePay == 2) {
this.selfWxPay()
}
} else {
uni.showToast({
title: '操作频繁',
icon: 'none'
})
this.isdisabled = false
1 year ago
}
2 years ago
},
selfWxPay() {
let payData = {
payChannel: 'WECHAT_MINIAPPS_PAYMENT', //微信小程序支付 WECHAT_APP_PAYMENT微信APP支付
openId: uni.getStorageSync('openid'),
unionId: uni.getStorageSync('unionid'),
appId: 'wx7a939c19b270cc3d',
payCode: 'WECHAT_ORDER_PAY_WECHAT', //APP填WECHAT_ORDER_PAY_APP,小程序填
orderId: this.order.orderSerialNumber,
payClient: 'XOIL_DRIVER_COMPANY_WECHAT_APPLET' //"支付端。安卓XOIL_DRIVER_ANDROID,小程序
}
oilFinanceApi.aggregatePay(payData).then(res => {
if (res.code == 20000) {
uni.requestPayment({
provider: 'wxpay',
...res.data.baseWxOrderVo,
success: (res) => {
1 year ago
this.isdisabled = false
2 years ago
// this.getPayStatus(this.outTradeNo)
// this.getLastMoney()
// this.getCards()
// console.log('success:' + JSON.stringify(res));
uni.showToast({
title: res.msg
})
uni.redirectTo({
1 year ago
url: '/BagStation/pages/makeOrder/payResult?status=success&&payMethod=' +
this.payMethod,
2 years ago
fail: (err) => {
// console.log(err)
}
})
},
fail: function(err) {
// console.log('fail:' + JSON.stringify(err));
}
})
// uni.showToast({
// title: res.msg
// })
// uni.redirectTo({
// url: '/BagStation/pages/makeOrder/payResult?status=success',
// fail: (err) => {
// console.log(err)
// }
// })
} else {
// uni.redirectTo({
// url: '/BagStation/pages/makeOrder/payResult?status=fail'
// })
}
})
},
selfCardPay() {
let _that = this
if (!this.card.accountCardCode) {
uni.showToast({
title: '请选择支付油卡',
icon: 'none'
})
this.isdisabled = false
return false
}
1 year ago
if (this.card.balance < this.order.realAmount && this.card.shareCompanyQuota != 1) {
2 years ago
console.log(this.type)
1 year ago
if (this.type == 'urea') {
2 years ago
this.PopupShow = true
this.PopupType = 2
this.isdisabled = false
return
1 year ago
} else if (this.type == 'oil') {
2 years ago
uni.showToast({
title: '该油卡余额不足',
icon: 'none'
})
this.isdisabled = false
return false
}
1 year ago
2 years ago
}
let payData
1 year ago
if (this.type == 'oil') {
payData = {
2 years ago
...this.card,
"orderSerialNumber": this.order.orderSerialNumber, //类型:String 必有字段 备注:订单编号
"payChannel": "BALANCE_PAYMENT", //类型:String 必有字段 备注:支付渠道(BALANCE_PAYMENT:余额支付)
"orderMethod": "CUSTOMER_ACTIVE", //类型:String 必有字段 备注:订单产生方式(CUSTOMER_ACTIVE:客户扫码支付:客户扫描油站二维码完成支付)
"createSource": "XOIL_DRIVER_COMPANY_WECHAT_APPLET"
}
oilOrderApi.payOrder(payData).then(res => {
this.isdisabled = false
if (res.code == 20000) {
this.isdisabled = false
uni.showToast({
title: res.msg
})
setTimeout(() => {
uni.redirectTo({
1 year ago
url: '/BagStation/pages/makeOrder/payResult?status=success&&payMethod=' +
this.payMethod,
2 years ago
fail: (err) => {
// console.log(err)
}
})
}, 1000)
1 year ago
2 years ago
} else {
this.isdisabled = false
uni.showToast({
title: res.msg,
icon: 'none'
})
setTimeout(() => {
let msg = res.msg
uni.redirectTo({
1 year ago
url: `/BagStation/pages/makeOrder/payResult?status=fail&&errMsg=${msg}payMethod=` +
this.payMethod
2 years ago
})
}, 1000)
}
1 year ago
2 years ago
})
1 year ago
} else if (this.type = 'urea') {
payData = {
belongCompanyId: this.ureaInfo.companyId,
driverId: this.user.id,
accountCardCode: this.ureaInfo.accountCardCode,
driverPhone: this.user.userPhone,
oldRealAmount: this.order.oldRealAmount,
vehicleNo: this.order.vehicleNo,
orderId: this.order.orderId,
driverName: this.order.driverName,
userSource: 'urea',
formats: this.order.formats,
oilCardNature: this.companyNature,
companyShared: this.shareCompanyQuota
2 years ago
}
ureaFinanceApi.orderPay(payData).then(res => {
console.log(res)
1 year ago
if (res.code == 20000) {
uni.setStorageSync('ureaOrderMade', res.data)
if (res.data.formats == '2') {
2 years ago
uni.redirectTo({
url: '/BagStation/orderDetail/orderDetailUrea?type=orderPay',
fail: (err) => {}
})
return
}
_that.PopupShow = true
_that.PopupType = 5
this.isdisabled = false
1 year ago
} else if (res.code == 40000 && res.msg == '余额不足') {
2 years ago
_that.PopupShow = true
_that.PopupType = 2
this.isdisabled = false
}
console.log(res)
})
1 year ago
}
2 years ago
},
onCopy(id) {
uni.setClipboardData({
data: id,
success: () => {
uni.showToast({
icon: 'none',
title: '订单号复制成功'
})
}
})
}
},
filters: {
1 year ago
ureaFormats(value) {
if (value == 1) {
2 years ago
return '加注站'
1 year ago
} else {
2 years ago
return '桶装'
}
},
moneyFormath(value) {
1 year ago
console.log(value)
if (value != 'xxx.x') {
2 years ago
let number = value.toFixed(2)
return number
} else {
return value
}
},
1 year ago
moneyFormat(value) {
if (value != 'xxx.x') {
let realAmount = Math.round(value * 100) / 100;
return realAmount
} else {
return value
2 years ago
}
}
}
}
</script>
<style scoped>
1 year ago
.w30 {
2 years ago
width: 30%;
flex: 0 0 auto;
text-align: center;
font-weight: 700;
font-size: 28rpx;
}
1 year ago
.formats_box {
2 years ago
display: flex;
justify-content: space-between;
1 year ago
align-items: center;
2 years ago
padding: 2%;
box-sizing: border-box;
flex-direction: column;
}
1 year ago
.formats_box_list {
2 years ago
display: flex;
justify-content: space-around;
align-items: center;
margin-bottom: 3%;
font-size: 30rpx;
color: #333;
1 year ago
align-items: center;
2 years ago
width: 100%;
1 year ago
}
2 years ago
.site-icon-sm {
width: 40upx;
vertical-align: middle;
display: inline-block;
margin-top: 5px;
height: 40upx;
}
.action .site-icon-sm {
width: 30upx;
/* display: inline-block; */
}
.fixed-bar-bottom {
width: 750upx;
position: fixed;
bottom: 0;
}
</style>