diff --git a/BagMoney/pages/oilCards/oilCards.vue b/BagMoney/pages/oilCards/oilCards.vue index 6f3320c..41269e0 100644 --- a/BagMoney/pages/oilCards/oilCards.vue +++ b/BagMoney/pages/oilCards/oilCards.vue @@ -6,19 +6,17 @@ - - 我的油卡 - 总余额:{{userTotal.oilCardTotalPrice|moneyFormat}}元{{cardList.length>0?cardList.length:1}}张 + 总余额:{{userTotal.oilCardTotalPrice|moneyFormat}}元{{cardList.length>0?cardList.length:1}}张 - - - - + @@ -58,16 +54,13 @@ 共享企业余额 - - 单日加油额度:{{cardList[cardCur].orderAmountToplimit}}元;单日加油升数额度:{{cardList[cardCur].orderVolumeToplimit}}L + 单日加油额度:{{cardList[cardCur].orderAmountToplimit}}元;单日加油升数额度:{{cardList[cardCur].orderVolumeToplimit}}L - - - 交易记录 @@ -75,7 +68,6 @@ - {{detail.createTime}} @@ -109,7 +101,7 @@ }, data() { return { - hideCard:[], + hideCard: [], loadStatus: 'load', userTotal: {}, historyList: [], @@ -170,15 +162,15 @@ this.TowerSwiper('swiperList'); }, onLoad(option) { - this.getCards() - this.getTotalOilCardInfo() - this.TowerSwiper('swiperList'); + // this.getCards() + // this.getTotalOilCardInfo() + // this.TowerSwiper('swiperList'); // 初始化towerSwiper 传已有的数组名即可 }, onReachBottom() { if (this.cardList[this.cardCur].loadStatus == 'more') { setTimeout(() => { - this.getMoneyDetail(this.cardList[this.cardCur],this.cardCur) + this.getMoneyDetail(this.cardList[this.cardCur], this.cardCur) }, 100) } else { uni.showToast({ @@ -188,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) { @@ -213,13 +197,7 @@ oilCardType: card.oilCardType } } - console.log('++++++++++++++') - console.log(data2) - console.log('++++++++++++++') accountApi.getOilCardRecordByPage(data2).then(res => { - console.log('++++++++++++++') - console.log(res) - console.log('++++++++++++++') if (res.code == 20000) { if (res.data.list.length < 20) { this.cardList[index].loadStatus = 'nomore' @@ -228,33 +206,36 @@ this.cardList[index].currentPage++ } // this.cardList[index].historyList = [] - - if(this.cardList[index].currentPage!==1){ - this.cardList[index].historyList = this.cardList[index].historyList.concat(res.data.list) - } else{ + if (this.cardList[index].currentPage !== 1) { + this.cardList[index].historyList = this.cardList[index].historyList.concat(res.data + .list) + } else { this.cardList[index].historyList = res.data.list } - + } }) }, async getCards() { - await accountApi.getSyncDeductions().then(res => { - if (res.code == 20000) { - this.hideCard = res.data.companyIds - } - }) - await accountApi.getUserAccount().then(res => { + await accountApi.getSyncDeductions().then(res => { + if (res.code == 20000) { + this.hideCard = res.data.companyIds + } + }) + 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.companyId)) - this.cardList.forEach(item => { - this.$set(item,'currentPage',1) - this.$set(item,'loadStatus','more') - this.$set(item,'historyList',[]) + + let staging = res.data.filter(item => item.companyType != 5).filter(item => !this.hideCard.includes(item + .companyId)) + 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) @@ -262,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((a,b)=>{return a - b}) + 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 }, @@ -332,10 +348,11 @@