diff --git a/BagMoney/pages/oilCards/oilCards.vue b/BagMoney/pages/oilCards/oilCards.vue index 464efa4..5127a55 100644 --- a/BagMoney/pages/oilCards/oilCards.vue +++ b/BagMoney/pages/oilCards/oilCards.vue @@ -162,9 +162,9 @@ this.TowerSwiper('swiperList'); }, onLoad(option) { - this.getCards() - this.getTotalOilCardInfo() - this.TowerSwiper('swiperList'); + // this.getCards() + // this.getTotalOilCardInfo() + // this.TowerSwiper('swiperList'); // 初始化towerSwiper 传已有的数组名即可 }, onReachBottom() { @@ -180,14 +180,6 @@ } }, methods: { - - getAmount() { - accountApi.getTotalOilCardInfo().then(res => { - if (res.code == 20000) { - this.userTotal = res.data - } - }) - }, getTotalOilCardInfo() { accountApi.getTotalOilCardInfo().then(res => { if (res.code == 20000) { @@ -233,15 +225,17 @@ await accountApi.getUserAccount().then(res => { if (res.code == 20000) { if (res.data.length > 0) { - this.cardList = res.data - this.cardList = this.cardList.filter(item => !this.hideCard.includes(item + + let staging = res.data.filter(item => !this.hideCard.includes(item .companyId)) - this.cardList.forEach(item => { + staging.forEach(item => { this.$set(item, 'currentPage', 1) this.$set(item, 'loadStatus', 'more') this.$set(item, 'historyList', []) }) - console.log(this.cardList) + let target = this.sortHandler(staging) + this.cardList = target + setTimeout(() => { this.getMoneyDetail(this.cardList[0], 0) }, 100) @@ -249,6 +243,41 @@ } }) }, + sortHandler(arr) { + let internalArr = arr.filter(item => item.oilCardType == 2) + let externalArr = arr.filter(item => item.oilCardType == 3) + // let internalTarget = this.sortParticulars(internalArr, 'shareCompanyQuota') + let externalTarget = this.sortParticulars(externalArr, 'balance') + if (internalArr.length || externalTarget.length) return [...internalArr, ...externalTarget] + else return arr + }, + sortParticulars(arr, field) { + let target = [] + let map = new Map() + let keys = [], + values = [] + 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 + }, + DotStyle(e) { this.dotStyle = e.detail.value }, diff --git a/BagStation/pages/makeOrder/orderPaying.vue b/BagStation/pages/makeOrder/orderPaying.vue index cf73af7..c601ce5 100644 --- a/BagStation/pages/makeOrder/orderPaying.vue +++ b/BagStation/pages/makeOrder/orderPaying.vue @@ -6,7 +6,7 @@ - + {{order.realAmount>0?order.realAmount:'xxx.x'|moneyFormat}} @@ -61,7 +61,8 @@ - + 自营企业油卡支付 (余额:{{item.balance|moneyFormat}}) @@ -107,31 +108,36 @@ - - - - - - - - - 外请油卡支付(余额:{{itemx.balance|moneyFormat}}) - 企业油卡支付 {{itemx.companyNature =="1" ? itemx.shareCompanyQuota==0? '(余额:'+itemx.balance+')' :'':''}} - - - {{itemx.name}} {{itemx.shareCompanyQuota==1?'共享额度':'非共享'}} - - - + + + + - - + + + 外请油卡支付(余额:{{itemx.balance|moneyFormat}}) + 企业油卡支付 + {{itemx.companyNature =="1" ? itemx.shareCompanyQuota==0? '(余额:'+itemx.balance+')' :'':''}} + - + + {{itemx.name}} {{itemx.shareCompanyQuota==1?'共享额度':'非共享'}} + + + + + + + + + @@ -150,8 +156,8 @@ 油站: - {{order.siteName?order.siteName:''}} - + {{order.siteName?order.siteName:''}} + @@ -168,14 +174,13 @@ 加油金额: - {{ moneyIntercept(order.xoilAmountGun )}} + {{ moneyIntercept(order.xoilAmountGun )}} 星油优惠: - {{ moneyIntercept(order.oilDiscountAmount)}} + {{ moneyIntercept(order.oilDiscountAmount)}} 优惠券: @@ -198,48 +203,50 @@ 油站: - {{order.siteName?order.siteName:''}} - + {{order.siteName?order.siteName:''}} + 加注类型: - {{order.formats | ureaFormats }} - + {{order.formats | ureaFormats }} + {{list.brandName}} - {{list.options}}/桶X{{list.goodsQuantity}} + {{list.options}}/桶X{{list.goodsQuantity}} ¥{{list.totalPrice}} - + 加注量: {{order.oldRealLiter?order.oldRealLiter :'xxx.x' }} - + 合计: - {{order.oldRealAmount>0? '¥'+ order.oldRealAmount:'xxx.x'|}} + {{order.oldRealAmount>0? '¥'+ order.oldRealAmount:'xxx.x'|}} - + - + - + - + @@ -255,18 +262,18 @@ AbnormalPopup }, data() { - return { - checkType:false, - PopupType:null, - PopupShow:false, - ureaInfo:{ - accountCardCode:'', - companyId:'' + return { + checkType: false, + PopupType: null, + PopupShow: false, + ureaInfo: { + accountCardCode: '', + companyId: '' }, - isdisabled:false, - showtitles:"", + isdisabled: false, + showtitles: "", imgURL: this.global.imgURL, - order:{}, + order: {}, activePay: 0, isCompany: uni.getStorageSync('accountStatus'), accountCardCode: '', @@ -274,33 +281,33 @@ datatime: "", checked: '', cooling: false, - payMethod:0, - user:uni.getStorageSync('user'), - type:'', - ureaCompanyOtherList:[], - companyNature:'', - shareCompanyQuota:'' + payMethod: 0, + user: uni.getStorageSync('user'), + type: '', + ureaCompanyOtherList: [], + companyNature: '', + shareCompanyQuota: '' } }, onLoad(option) { - if(option.type == 'urea'){ - this.order = uni.getStorageSync('ureaOrderMade') + if (option.type == 'urea') { + this.order = uni.getStorageSync('ureaOrderMade') this.order.companyStatus = true this.type = 'urea' this.findUreaAccount() - }else{ + } else { let oilItem = uni.getStorageSync('oilItem') // console.log - this.order = uni.getStorageSync('orderMade') + this.order = uni.getStorageSync('orderMade') this.type = 'oil' - this.showtitles = oilItem.listTag - if(option.payMethod == null){ - this.payMethod =oilItem.payMethod + this.showtitles = oilItem.listTag + if (option.payMethod == null) { + this.payMethod = oilItem.payMethod // console.log(this.payMethod ) - }else { - this.payMethod =option.payMethod + } else { + this.payMethod = option.payMethod } - } + } }, computed: { companyList() { @@ -310,7 +317,9 @@ }, companyOtherList() { if (this.isCompany) { - return this.order.otherAccounts + // return this.order.otherAccounts + let target = this.sortParticulars(this.order.otherAccounts,'balance') + return target } } }, @@ -328,19 +337,45 @@ this.accountCardCode = this.card.accountCardCode } }, - methods: { - getureaFinanceApi(){ - ureaFinanceApi.queryWhetherToHangUp(this.order.orderId).then(res=>{ - if(res.data == '2'){ - this.checkType = true + 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 } }) }, - hidenPopup(e){ + hidenPopup(e) { console.log(e) - this.PopupShow =e + this.PopupShow = e }, - findUreaAccount(){ + findUreaAccount() { ureaFinanceApi.findUreaAccount(this.order.driverId).then(res => { console.log(res) this.ureaCompanyOtherList = res.data @@ -353,7 +388,7 @@ return timestampDeadline }, ureaCancelOrder(id) { - console.log(id) + console.log(id) ureaFinanceApi.cancelTheOrder(id).then(res => { console.log(res) if (res.code == 20000) { @@ -365,7 +400,7 @@ setTimeout(() => { uni.navigateBack(2) }, 1000) - + } }) }, @@ -393,17 +428,17 @@ this.card = card this.checked = 'person' }, - ureaSelectCompanyCard(card){ + ureaSelectCompanyCard(card) { 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 - this.shareCompanyQuota =card.shareCompanyQuota + this.shareCompanyQuota = card.shareCompanyQuota }, selectCompanyCard(card) { - console.log(card) + console.log(card) this.card = card this.checked = card.accountCardCode this.accountCardCode = card.accountCardCode @@ -415,8 +450,8 @@ setTimeout(() => { this.cooling = false }, 5000) - if (this.activePay == 0) { - this.selfCardPay() + if (this.activePay == 0) { + this.selfCardPay() } else if (this.activePay == 2) { this.selfWxPay() } @@ -426,7 +461,7 @@ icon: 'none' }) this.isdisabled = false - } + } }, selfWxPay() { let payData = { @@ -444,7 +479,7 @@ provider: 'wxpay', ...res.data.baseWxOrderVo, success: (res) => { - this.isdisabled=false + this.isdisabled = false // this.getPayStatus(this.outTradeNo) // this.getLastMoney() // this.getCards() @@ -453,7 +488,8 @@ title: res.msg }) uni.redirectTo({ - url: '/BagStation/pages/makeOrder/payResult?status=success&&payMethod='+this.payMethod, + url: '/BagStation/pages/makeOrder/payResult?status=success&&payMethod=' + + this.payMethod, fail: (err) => { // console.log(err) } @@ -490,14 +526,14 @@ this.isdisabled = false return false } - if (this.card.balance < this.order.realAmount&& this.card.shareCompanyQuota!=1) { + if (this.card.balance < this.order.realAmount && this.card.shareCompanyQuota != 1) { console.log(this.type) - if(this.type =='urea'){ + if (this.type == 'urea') { this.PopupShow = true this.PopupType = 2 this.isdisabled = false return - }else if(this.type =='oil'){ + } else if (this.type == 'oil') { uni.showToast({ title: '该油卡余额不足', icon: 'none' @@ -505,11 +541,11 @@ this.isdisabled = false return false } - + } let payData - if(this.type == 'oil'){ - payData = { + if (this.type == 'oil') { + payData = { ...this.card, "orderSerialNumber": this.order.orderSerialNumber, //类型:String 必有字段 备注:订单编号 "payChannel": "BALANCE_PAYMENT", //类型:String 必有字段 备注:支付渠道(BALANCE_PAYMENT:余额支付) @@ -525,13 +561,14 @@ }) setTimeout(() => { uni.redirectTo({ - url: '/BagStation/pages/makeOrder/payResult?status=success&&payMethod='+this.payMethod, + url: '/BagStation/pages/makeOrder/payResult?status=success&&payMethod=' + + this.payMethod, fail: (err) => { // console.log(err) } }) }, 1000) - + } else { this.isdisabled = false uni.showToast({ @@ -541,32 +578,33 @@ setTimeout(() => { let msg = res.msg uni.redirectTo({ - url: `/BagStation/pages/makeOrder/payResult?status=fail&&errMsg=${msg}payMethod=`+this.payMethod + url: `/BagStation/pages/makeOrder/payResult?status=fail&&errMsg=${msg}payMethod=` + + this.payMethod }) }, 1000) } - + }) - }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 + } 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 } ureaFinanceApi.orderPay(payData).then(res => { console.log(res) - if(res.code == 20000){ - uni.setStorageSync('ureaOrderMade',res.data) - if(res.data.formats == '2'){ + if (res.code == 20000) { + uni.setStorageSync('ureaOrderMade', res.data) + if (res.data.formats == '2') { uni.redirectTo({ url: '/BagStation/orderDetail/orderDetailUrea?type=orderPay', fail: (err) => {} @@ -576,14 +614,14 @@ _that.PopupShow = true _that.PopupType = 5 this.isdisabled = false - } else if(res.code == 40000 && res.msg == '余额不足'){ + } else if (res.code == 40000 && res.msg == '余额不足') { _that.PopupShow = true _that.PopupType = 2 this.isdisabled = false } console.log(res) }) - } + } }, onCopy(id) { uni.setClipboardData({ @@ -598,28 +636,28 @@ } }, filters: { - ureaFormats(value){ - if(value == 1){ + ureaFormats(value) { + if (value == 1) { return '加注站' - }else{ + } else { return '桶装' } }, moneyFormath(value) { - console.log(value) - if (value != 'xxx.x') { + console.log(value) + if (value != 'xxx.x') { let number = value.toFixed(2) return number } else { return value } }, - moneyFormat(value) { - if (value != 'xxx.x') { - let realAmount = Math.round(value * 100) / 100; - return realAmount - } else { - return value + moneyFormat(value) { + if (value != 'xxx.x') { + let realAmount = Math.round(value * 100) / 100; + return realAmount + } else { + return value } } } @@ -627,31 +665,34 @@