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

141 lines
4.8 KiB
Vue
Raw Normal View History

2022-05-26 20:24:33 +08:00
<template>
2022-06-01 23:58:02 +08:00
<view class="margin-bottom-lg">
2022-05-26 20:24:33 +08:00
<!-- 顶部操作条 -->
<cu-custom :bgColor="'bg-main-color'" :isBack="true">
<block slot="backText">返回</block>
<block slot="content">我的钱包</block>
</cu-custom>
<view class="margin-sm shadow-warp">
<view class="padding-tb-lg padding-lr bg-gradual-color light">
<view>账户余额</view>
<view class="flex justify-between margin-top-sm">
2022-06-01 23:58:02 +08:00
<!-- <view class="text-xxl">{{myMoneyBag.balance}}</view> -->
<view class="text-xxl">--</view>
2022-05-26 20:24:33 +08:00
</view>
2022-05-28 00:30:47 +08:00
<view v-if="bindBankCard && bindBankCard.bankNum" class="flex justify-end margin-top-sm align-center">
<view class="margin-lr-sm text-lg">{{bindBankCard.encodeBankNum}}</view>
<view class="cu-btn bg-white radius" @click="bindBankAccount">账户另绑</view>
</view>
<view v-else class="flex justify-end margin-top-sm align-center">
2022-05-26 20:24:33 +08:00
<view class="cu-btn bg-white radius" @click="bindBankAccount">账户绑定</view>
</view>
</view>
</view>
2022-06-01 23:58:02 +08:00
<uni-collapse v-model="openStatusArr[index]" ref="collapse" v-for="(billItem, index) in bill">
<uni-collapse-item>
<template v-slot:title>
<view class="padding bg-white" :data-index="index" @click="showStatement">
<view class="margin-bottom-xs">{{billItem.createTime}}</view>
2022-05-26 20:24:33 +08:00
<view>
2022-06-01 23:58:02 +08:00
<text class="margin-right"><text>支出</text><text class="text-price text-black">{{billItem.payCount}}</text></text>
<text><text>收入</text><text class="text-price text-black">{{billItem.incomeCount}}</text></text>
2022-05-26 20:24:33 +08:00
</view>
2022-06-01 23:58:02 +08:00
</view>
</template>
<view>
2022-06-06 22:09:43 +08:00
<view v-for="(item, index1) in billItem.statement" class="bg-white padding flex justify-between align-center" @click="showDetail(bill[index].statement[index1])">
2022-06-01 23:58:02 +08:00
<view>
<view class="margin-bottom-xs" v-if="item.financialDetailType == 1">师傅转派</view>
<view class="margin-bottom-xs" v-else-if="item.financialDetailType == 2">多级分销</view>
<view class="margin-bottom-xs" v-else-if="item.financialDetailType == 3">平台抽成</view>
<view>{{item.createTime}}</view>
</view>
<view class="text-price text-black">{{item.payMoney}}</view>
</view>
</view>
</uni-collapse-item>
</uni-collapse>
2022-05-26 20:24:33 +08:00
</view>
</template>
<script>
export default {
data() {
return {
2022-06-01 23:58:02 +08:00
openStatusArr: [], //0打开1收起
2022-05-28 00:30:47 +08:00
myMoneyBag: {},
curUserInfo: {},
2022-06-01 23:58:02 +08:00
bindBankCard: null,
bill: []
2022-05-26 20:24:33 +08:00
}
},
onLoad() {
this.loadData();
},
onShow() {
2022-05-28 00:30:47 +08:00
this.reloadData();
2022-05-26 20:24:33 +08:00
},
methods: {
async loadData() {
this.myMoneyBag = await this.$api.data('myMoneyBag');
2022-06-01 23:58:02 +08:00
// 查询账单
let billRes = await this.$request.qryFinancialCount();
this.bill = billRes.data;
for (let i = 0; i < this.bill.length; i++) {
this.openStatusArr.push('1');
2022-05-26 20:24:33 +08:00
}
2022-05-28 00:30:47 +08:00
this.curUserInfo = this.$request.getCurUserInfo();
this.loadBindBankCard();
},
async reloadData() {
this.loadBindBankCard();
},
async loadBindBankCard() {
let res = await this.$request.getBindBankCardByCustomerId({
customerId: this.curUserInfo.customerId
});
this.bindBankCard = res.data;
this.bindBankCard.encodeBankNum = '****' + this.bindBankCard.bankNum.substring(this.bindBankCard.bankNum.length - 4);
2022-05-26 20:24:33 +08:00
},
2022-06-01 23:58:02 +08:00
async showStatement(e) {
let curIndex = e.currentTarget.dataset.index;
// 1为缩起状态0为展开状态
if (this.openStatusArr[curIndex] == '1' && !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
});
// let newStatements = this.statements.concat();
// newStatements[curIndex] = res.rows;
// this.statements = newStatements;
let newBill = this.bill.concat();
newBill[curIndex].statement = res.rows;
this.bill = newBill;
// #ifdef MP
this.$nextTick(() => {
this.$refs.collapse[curIndex].resize();
uni.hideLoading();
})
// #endif
}
},
2022-06-06 22:09:43 +08:00
showDetail(item) {
2022-05-26 20:24:33 +08:00
uni.navigateTo({
2022-06-06 22:09:43 +08:00
url: '/pages/my/statement-desc?statementDesc=' + encodeURIComponent(JSON.stringify(item))
2022-05-26 20:24:33 +08:00
})
},
bindBankAccount() {
uni.navigateTo({
url: '/pages/my/bank-account-bind'
})
}
},
}
</script>
<style>
</style>