dingdong-mall/pages/my/my-money-bag.vue

190 lines
5.8 KiB
Vue
Raw Permalink 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="margin-bottom-lg">
<!-- 顶部操作条 -->
<cu-custom :bgColor="'bg-main-color'" :isBack="true">
<block slot="backText">返回</block>
<block slot="content">运营账单</block>
</cu-custom>
<!-- <view class="padding-tb bg-white solid-bottom">
<view class="flex justify-between align-center margin-top-xs padding-left">
<my-uni-combox class="flex-sub margin-right-xs" :candidates="billingStateList"
:showField="'name'" placeholder="筛选账单状态" v-model="billingStateObj"
@input="chooseBillingState($event)"></my-uni-combox>
<view class="text-xl text-bold">
<text class="cuIcon-search margin-right-sm" @click="searchBills"></text>
</view>
</view>
</view> -->
<uni-collapse ref="collapse">
<uni-collapse-item ref="collapseItem" :showArrow="false" v-for="(billItem, index) in bill" :key="index" :open="openStatusArr[index] === '0' ? true : false" >
<template v-slot:title>
<view class="padding bg-white" :data-index="index" @click="showStatement">
<view class="flex justify-between align-center">
<view>
<view class="margin-bottom-xs">{{billItem.createTime}}</view>
<view>
<text><text>收入:</text><text class="text-price text-black">{{billItem.incomeCount}}</text></text>
</view>
</view>
<view style="width: 200rpx;" @click.stop v-if="openStatusArr[index] === '0'">
<my-uni-combox class="margin-right-xs" :candidates="billingStateList"
:showField="'name'" placeholder="筛选" v-model="billingStateObj"
@input="chooseBillingState($event)"></my-uni-combox>
</view>
</view>
</view>
</template>
<view v-if="billItem.statement">
<view v-for="(item, index1) in billItem.statement.filter(i => filterCode.includes(i.orderStatus))"
:key="index1"
class="bg-white padding flex justify-between align-center solid-bottom" @click="showDetail(bill[index].statement[index1])">
<view>
<view class="flex margin-bottom-sm">
<view class="margin-right-sm">订单号:{{item.orderCode}}</view>
</view>
<view class="text-gray">{{item.createTime}}</view>
</view>
<view class="text-right">
<view class="text-price text-black margin-bottom-sm">{{item.payMoney}}</view>
<view class="text-black">{{item.orderStatusDesc}}</view>
</view>
</view>
</view>
</uni-collapse-item>
</uni-collapse>
</view>
</template>
<script>
import myUniCombox from '@/components/uni-combox/my-uni-combox.vue';
export default {
components: {
myUniCombox
},
data() {
return {
openStatusArr: [], //0打开1收起
bill: [],
curUserInfo: {},
billingStateList: [{
code: 0,
name: '全部'
},{
code: 1,
name: '待分帐'
},{
code: 6,
name: '已取消'
},{
code: 5,
name: '已到帐'
}],
filterCode: [0,1,2,3,4,5,6],
billingStateObj: null
}
},
onLoad() {
this.loadData();
},
methods: {
async loadData() {
this.curUserInfo = this.$request.getCurUserInfo();
// 查询账单
this.qryBills();
},
async qryBills(params = {}) {
let billRes = await this.$request.qryFinancialCount({
financialDetailTypes: [3],
workerId: this.curUserInfo.customerId,
...params
});
this.bill = billRes.data;
this.openStatusArr = [];
for (let i = 0; i < this.bill.length; i++) {
this.openStatusArr.push('1');
this.$nextTick(() => {
this.$refs.collapseItem[i].onClick(false, 'init');
})
}
this.$nextTick(() => {
this.$refs.collapse.resize();
})
},
async showStatement(e) {
let curIndex = e.currentTarget.dataset.index;
console.log(this.openStatusArr, curIndex);
// 1为缩起状态0为展开状态
if (this.openStatusArr[curIndex] == '1') {
if(!this.bill[curIndex].statement) {
let createTime = new Date(new Date(this.bill[curIndex].createTime).setHours(0));
let createMonth = createTime.getMonth() + 1;
let createYear = createTime.getFullYear();
let finishYear = createMonth === 12 ? createYear + 1 : createYear;
let finishMonth = createMonth === 12 ? 1 : createMonth + 1;
let createTimeStr = createYear + '-' + createMonth + '-1 00:00:00';
let finishTimeStr = finishYear + '-' + finishMonth + '-1 00:00:00';
uni.showLoading({
mask: true,
title: '加载中'
})
let res = await this.$request.qryFinancialDetail({
beginTime: createTimeStr,
endTime: finishTimeStr,
financialDetailTypes: [3],
customerId: this.curUserInfo.customerId
});
let newBill = this.bill.concat();
newBill[curIndex].statement = res.rows;
this.bill = newBill;
}
for(let k = 0; k < this.openStatusArr.length; k++) {
this.$set(this.openStatusArr, k, k === curIndex ? '0' : '1')
}
uni.hideLoading()
// #ifdef MP
this.$nextTick(() => {
this.$refs.collapse.resize();
uni.hideLoading();
})
// #endif
} else {
this.$set(this.openStatusArr, curIndex, '1')
this.billingStateObj = null
this.filterCode = [0,1,2,3,4,5,6]
}
},
showDetail(item) {
uni.navigateTo({
url: '/pages/my/statement-desc?statementDesc=' + encodeURIComponent(JSON.stringify(item))
})
},
chooseBillingState(e) {
console.log(e);
this.billingStateObj = e;
if(e.code === 0) {
this.filterCode = [0,1,2,3,4,5,6]
} else if(e.code === 1) {
this.filterCode = [0,1,2,3,4]
} else {
this.filterCode = [e.code]
}
this.$nextTick(() => {
this.$refs.collapse.resize();
})
},
searchBills() {
// this.qryBills({
// billingState: this.billingStateObj ? this.billingStateObj.code : null
// });
}
},
}
</script>
<style>
</style>