完成钱包模块

This commit is contained in:
赵毅 2025-10-10 11:41:43 +08:00
parent 61c15f5d67
commit 8d60cb6200
5 changed files with 146 additions and 103 deletions

4
api/wallet.js Normal file
View File

@ -0,0 +1,4 @@
export const apiArr = {
walletList: "/api/v2/wechat/wallet/list", // 商户钱包
walletChangeList: "/api/v2/wechat/wallet/change/list", // 商户钱包变更详情
};

View File

@ -25,16 +25,16 @@
<view class="walletBox"> <view class="walletBox">
<view class="walletBox_top">钱包</view> <view class="walletBox_top">钱包</view>
<view class="walletBox_content"> <view class="walletBox_content">
<view class="walletBox_item" @click="goWallet(1)"> <view class="walletBox_item" @click="goWallet(1, walletInfo.guarantee.toFixed(2))">
<view>999.00</view> <view>{{ walletInfo.guarantee ? walletInfo.guarantee.toFixed(2) : "0.00" }}</view>
<view class="walletBox_item_text">保证金</view> <view class="walletBox_item_text">保证金</view>
</view> </view>
<view class="walletBox_item" @click="goWallet(2)"> <view class="walletBox_item" @click="goWallet(2, walletInfo.receivable.toFixed(2))">
<view>999.00</view> <view>{{ walletInfo.receivable ? walletInfo.receivable.toFixed(2) : "0.00" }}</view>
<view class="walletBox_item_text">应收</view> <view class="walletBox_item_text">应收</view>
</view> </view>
<view class="walletBox_item" @click="goWallet(3)"> <view class="walletBox_item" @click="goWallet(3, walletInfo.handling_fee.toFixed(2))">
<view>999.00</view> <view>{{ walletInfo.handling_fee ? walletInfo.handling_fee.toFixed(2) : "0.00" }}</view>
<view class="walletBox_item_text">手续费</view> <view class="walletBox_item_text">手续费</view>
</view> </view>
</view> </view>
@ -98,6 +98,7 @@ import {
import { import {
apiArr apiArr
} from '../../../api/community'; } from '../../../api/community';
import { apiArr as walletApi } from '../../../api/wallet';
export default { export default {
@ -125,6 +126,7 @@ export default {
url: "/packages/customerService/chattingRecords/index", url: "/packages/customerService/chattingRecords/index",
} }
], ],
walletInfo: {},
} }
}, },
onLoad(options) { onLoad(options) {
@ -135,8 +137,16 @@ export default {
this.getShopList(); this.getShopList();
}, },
methods: { methods: {
//
getWalletInfo() {
const params = {
merchant_id: this.selectedShop.id,
}
request(walletApi.walletList, 'POST', params, { silent: false }).then(res => {
this.walletInfo = res;
})
},
// //
getShopList() { getShopList() {
request(apiArr.getShopList, 'POST', {}, { silent: false }).then(res => { request(apiArr.getShopList, 'POST', {}, { silent: false }).then(res => {
@ -146,11 +156,14 @@ export default {
this.shopList = res.rows; this.shopList = res.rows;
if (this.shopList.length > 0) { if (this.shopList.length > 0) {
this.selectedShop = this.shopList[0]; this.selectedShop = this.shopList[0];
// selectedShopgetWalletInfo()
this.getWalletInfo();
} }
}) })
}, },
goWallet(type) { //
NavgateTo('/packages/storeManagement/wallet/index?type=' + type); goWallet(type, amount) {
NavgateTo('/packages/storeManagement/wallet/index?type=' + type + '&merchant_id=' + this.selectedShop.id + '&amount=' + amount);
}, },
changeTab(index) { changeTab(index) {
this.active = index; this.active = index;

View File

@ -15,11 +15,11 @@
<view> <view>
<view class="balance-title">{{ topVal }}</view> <view class="balance-title">{{ topVal }}</view>
<view class="balance-amount">{{ balance }}</view> <view class="balance-amount">{{ balance }}</view>
<view class="balance-icon" v-if="topVal != '保证金'"> <!-- <view v-if="topVal == '保证金'" class="balance-text">
<image src="http://localhost:8080/user_wallet2.png" mode="widthFix" />
</view>
<view v-else class="balance-text">
去充值 去充值
</view> -->
<view class="balance-icon">
<image src="http://localhost:8080/user_wallet2.png" mode="widthFix" />
</view> </view>
</view> </view>
</view> </view>
@ -27,44 +27,48 @@
<!-- 变动记录 --> <!-- 变动记录 -->
<view class="records-container"> <view class="records-container">
<view class="tabs" v-if="topVal == '保证金'"> <!-- <view class="tabs" v-if="topVal == '保证金' && records.length > 0">
<view v-for="(item, index) in tabList" :key="index" <view v-for="(item, index) in tabList" :key="index"
:class="['tabItem', selectedTab === item.id ? 'active2' : '']" @click="selectTab(index, item)"> :class="['tabItem', selectedTab === item.id ? 'active2' : '']" @click="selectTab(index, item)">
{{ item.tabName }} {{ item.tabName }}
</view> </view>
</view> -->
<view v-if="records.length == 0">
<view class="records-list">暂无变动记录</view>
</view> </view>
<view class="records-list"> <view class="records-list" v-else>
<view class="record-item" v-for="(record, index) in records" :key="index"> <view class="record-item" v-for="(record, index) in records" :key="index">
<view class="record-info"> <view class="record-info">
<view class="record-name">{{ record.name }}</view> <view class="record-name">{{ record.change_reason == 1 ? '下单' : '退单' }} - {{
<view class="record-time">{{ record.time }}</view> record.related_order }}</view>
<view class="record-time">{{ record.change_time }}</view>
</view> </view>
<view class="record-amount" v-if="topVal == '保证金'"> <view class="record-amount" v-if="topVal == '保证金'">
<view> <view>
<text :class="['amount-sign', record.amount.startsWith('+') ? 'positive' : 'negative']">{{ <text :class="['amount-sign', record.change_reason == 1 ? 'positive' : 'negative']">{{
record.amount.startsWith('+') ? '+' : '-' }}</text> record.change_reason == 1 ? '+' : '-' }}</text>
<text :class="['amount-value', record.amount.startsWith('+') ? 'positive' : 'negative']">¥{{ <text :class="['amount-value', record.change_reason == 1 ? 'positive' : 'negative']">¥{{
record.amount.replace(/[+-]/, '') }}</text> record.amount_change }}</text>
</view> </view>
<view class="record-balance">:¥{{ record.remain }}</view> <view class="record-balance">:¥{{ record.balance_after }}</view>
</view> </view>
<view class="record-amount" v-else-if="topVal == '应收'"> <view class="record-amount" v-else-if="topVal == '应收'">
<view :class="['amount-sign', record.amount.startsWith('+') ? 'positive' : 'negative']">{{ <view :class="['amount-sign', record.change_reason == 1 ? 'positive' : 'negative']">{{
record.amount.startsWith('+') ? '收款' : '退款' }}</view> record.change_reason == 1 ? '收款' : '退款' }}</view>
<view> <view>
<text :class="['amount-sign', record.amount.startsWith('+') ? 'positive' : 'negative']">{{ <text :class="['amount-sign', record.change_reason == 1 ? 'positive' : 'negative']">{{
record.amount.startsWith('+') ? '+' : '-' }}</text> record.change_reason == 1 ? '+' : '-' }}</text>
<text :class="['amount-value', record.amount.startsWith('+') ? 'positive' : 'negative']">¥{{ <text :class="['amount-value', record.change_reason == 1 ? 'positive' : 'negative']">¥{{
record.amount.replace(/[+-]/, '') }}</text> record.amount_change }}</text>
</view> </view>
</view> </view>
<view class="record-amount" v-else> <view class="record-amount" v-else>
<view class="record-balance">手续费</view> <view class="record-balance">手续费</view>
<view> <view>
<text class="amount-sign">{{ record.amount.startsWith('+') ? '+' : '-' }}</text> <text class="amount-sign">{{ record.change_reason == 1 ? '+' : '-' }}</text>
<text class="amount-sign">¥{{ record.amount.replace(/[+-]/, '') }}</text> <text class="amount-sign">¥{{ record.amount_change }}</text>
</view> </view>
</view> </view>
</view> </view>
@ -74,27 +78,16 @@
</template> </template>
<script> <script>
import { menuButtonInfo, NavgateTo, picUrl, request } from '../../../utils/index'; import { menuButtonInfo, NavgateTo, picUrl, request } from '../../../utils/index';
import { apiArr as walletApi } from '../../../api/wallet';
export default { export default {
data() { data() {
return { return {
top: "", top: "",
localHeight: "", localHeight: "",
topVal: "", topVal: "",
balance: "160.80", balance: "",
records: [ records: [],
{
name: "退单-1312312317972",
time: "2025-08-12 13:00:00",
amount: "-1808.5",
remain: "286.79"
},
{
name: "退单-1312312317972",
time: "2025-08-12 13:00:00",
amount: "-1808.5",
remain: "286.79"
}
],
tabList: [ tabList: [
{ {
id: 0, id: 0,
@ -109,7 +102,8 @@ export default {
tabName: '消费记录' tabName: '消费记录'
} }
], ],
selectedTab: 0 selectedTab: 0,
merchant_id: "",
} }
}, },
onLoad(options) { onLoad(options) {
@ -117,6 +111,8 @@ export default {
this.top = meun.top; this.top = meun.top;
this.localHeight = meun.height; this.localHeight = meun.height;
this.topVal = options.type == 1 ? '保证金' : (options.type == 2 ? '应收' : '手续费'); this.topVal = options.type == 1 ? '保证金' : (options.type == 2 ? '应收' : '手续费');
this.balance = options.amount;
this.merchant_id = options.merchant_id;
this.getWalletInfo(); this.getWalletInfo();
}, },
methods: { methods: {
@ -126,21 +122,24 @@ export default {
}); });
}, },
selectTab(index, item) { selectTab(index, item) {
console.log("🚀 ~ selectTab ~ item:", item)
this.selectedTab = item.id; this.selectedTab = item.id;
}, },
// //
getWalletInfo() { getWalletInfo() {
// const params = {
// 使 merchant_id: this.merchant_id,
console.log('获取钱包信息'); }
// request(walletApi.walletChangeList, 'POST', params, { silent: false }).then(res => {
// request('/api/wallet/info', 'GET').then(res => { let filteredRows = res.rows;
// if (res.code === 0) { if (this.topVal == '保证金') {
// this.balance = res.data.balance; filteredRows = res.rows.filter(item => item.change_category == 5);
// this.records = res.data.records; } else if (this.topVal == '应收') {
// } filteredRows = res.rows.filter(item => item.change_category == 2);
// }) } else {
filteredRows = res.rows.filter(item => item.change_category == 3);
}
this.records = filteredRows;
})
} }
} }
} }

View File

@ -17,20 +17,20 @@
<view class="walletBox"> <view class="walletBox">
<view class="walletBox_top">钱包</view> <view class="walletBox_top">钱包</view>
<view class="walletBox_content"> <view class="walletBox_content">
<view class="walletBox_item" @click="goWallet(1)"> <view class="walletBox_item" @click="goWallet(1, walletInfo.receivable.toFixed(2))">
<view>999.00</view> <view>{{ walletInfo.receivable ? walletInfo.receivable.toFixed(2) : "0.00" }}</view>
<view class="walletBox_item_text">应收</view> <view class="walletBox_item_text">应收</view>
</view> </view>
<view class="walletBox_item" @click="goWallet(2)"> <view class="walletBox_item" @click="goWallet(2, walletInfo.received.toFixed(2))">
<view>999.00</view> <view>{{ walletInfo.received ? walletInfo.received.toFixed(2) : "0.00" }}</view>
<view class="walletBox_item_text">已收</view> <view class="walletBox_item_text">已收</view>
</view> </view>
<view class="walletBox_item" @click="goWallet(3)"> <view class="walletBox_item" @click="goWallet(3, walletInfo.pending.toFixed(2))">
<view>999.00</view> <view>{{ walletInfo.pending ? walletInfo.pending.toFixed(2) : "0.00" }}</view>
<view class="walletBox_item_text">待收物业公积金</view> <view class="walletBox_item_text">待收物业公积金</view>
</view> </view>
<view class="walletBox_item" @click="goWallet(4)"> <view class="walletBox_item" @click="goWallet(4, walletInfo.handling_fee.toFixed(2))">
<view>999.00</view> <view>{{ walletInfo.handling_fee ? walletInfo.handling_fee.toFixed(2) : "0.00" }}</view>
<view class="walletBox_item_text">手续费</view> <view class="walletBox_item_text">手续费</view>
</view> </view>
</view> </view>
@ -64,13 +64,15 @@ import {
} from "../../../utils"; } from "../../../utils";
import { apiArr } from "../../../api/community"; import { apiArr } from "../../../api/community";
import { apiArr as walletApi } from '../../../api/wallet';
export default { export default {
data() { data() {
return { return {
communityVal: "切换小区", communityVal: "切换小区",
showWorkOrderSection: false, showWorkOrderSection: false,
communityList: [] communityList: [],
walletInfo: {},
} }
}, },
async onLoad() { async onLoad() {
@ -92,6 +94,8 @@ export default {
uni.setStorageSync('changeWorkOrderData', { id: res.rows[0].community_id, name: res.rows[0].name }); uni.setStorageSync('changeWorkOrderData', { id: res.rows[0].community_id, name: res.rows[0].name });
this.communityVal = res.rows[0].name; this.communityVal = res.rows[0].name;
} }
//
this.getWalletInfo();
}); });
}, },
async onShow() { async onShow() {
@ -107,11 +111,32 @@ export default {
} }
}, },
methods: { methods: {
goWallet(type) { //
if (type == 2) { getWalletInfo() {
return const changeCommData = uni.getStorageSync('changeWorkOrderData');
if (!changeCommData) {
return;
} }
NavgateTo('/packages/workOrderDashboard/wallet/index?type=' + type); const params = {
community_id: changeCommData.id,
}
request(walletApi.walletList, 'POST', params, { silent: false }).then(res => {
this.walletInfo = res;
})
},
goWallet(type, amount) {
const changeCommData = uni.getStorageSync('changeWorkOrderData');
if (!changeCommData) {
uni.showToast({
title: '请先选择小区',
icon: 'none'
});
return;
}
// if (type == 2) {
// return
// }
NavgateTo('/packages/workOrderDashboard/wallet/index?type=' + type + '&community_id=' + changeCommData.id + '&amount=' + amount);
}, },
addCommunity() { addCommunity() {
NavgateTo("/packages/workOrderDashboard/myCommunity/index"); NavgateTo("/packages/workOrderDashboard/myCommunity/index");

View File

@ -25,22 +25,26 @@
<!-- 余额变动记录 --> <!-- 余额变动记录 -->
<view class="records-container"> <view class="records-container">
<view class="records-title" v-if="topVal == '待收物业公积金'">物业费公积金变动记录</view> <view class="records-title" v-if="topVal == '待收物业公积金'">物业费公积金变动记录</view>
<view class="records-list"> <view v-if="records.length == 0">
<view class="records-list">暂无变动记录</view>
</view>
<view class="records-list" v-else>
<view class="record-item" v-for="(record, index) in records" :key="index"> <view class="record-item" v-for="(record, index) in records" :key="index">
<view class="record-info"> <view class="record-info">
<view class="record-name">{{ record.name }}</view> <view class="record-name">{{ record.change_reason == 1 ? '下单' : '退单' }} - {{
<view class="record-time">{{ record.time }}</view> record.related_order }}</view>
<view class="record-time">{{ record.change_time }}</view>
</view> </view>
<view class="record-amount"> <view class="record-amount">
<view class="record-balance" v-if="topVal == '应收'">{{ record.amount.startsWith('+') ? '收款' : <view class="record-balance" v-if="topVal == '应收' || topVal == '已收'">{{ record.change_reason == 1 ? '收款' :
'退款' }}</view> '退款' }}</view>
<view class="record-balance" v-else-if="topVal == '待收物业公积金'">待收</view> <view class="record-balance" v-else-if="topVal == '待收物业公积金'">待收</view>
<view class="record-balance" v-else-if="topVal == '手续费'">手续费</view> <view class="record-balance" v-else-if="topVal == '手续费'">手续费</view>
<view> <view>
<text :class="['amount-sign', record.amount.startsWith('+') ? 'positive' : 'negative']">{{ <text :class="['amount-sign', record.change_reason == 1 ? 'positive' : 'negative']">{{
record.amount.startsWith('+') ? '+' : '-' }}</text> record.change_reason == 1 ? '+' : '-' }}</text>
<text :class="['amount-value', record.amount.startsWith('+') ? 'positive' : 'negative']">¥{{ <text :class="['amount-value', record.change_reason == 1 ? 'positive' : 'negative']">¥{{
record.amount.replace(/[+-]/, '') }}</text> record.amount_change }}</text>
</view> </view>
</view> </view>
</view> </view>
@ -50,27 +54,17 @@
</template> </template>
<script> <script>
import { menuButtonInfo, NavgateTo, picUrl, request } from '../../../utils/index'; import { menuButtonInfo, NavgateTo, picUrl, request } from '../../../utils/index';
import { apiArr as walletApi } from '../../../api/wallet';
export default { export default {
data() { data() {
return { return {
top: "", top: "",
localHeight: "", localHeight: "",
topVal: "", topVal: "",
balance: "160.80", balance: "",
records: [ records: [],
{ community_id: "",
name: "退单-1312312317972",
time: "2025-08-12 13:00:00",
amount: "-1808.5",
remain: "286.79"
},
{
name: "退单-1312312317972",
time: "2025-08-12 13:00:00",
amount: "-1808.5",
remain: "286.79"
}
]
} }
}, },
onLoad(options) { onLoad(options) {
@ -78,6 +72,8 @@ export default {
this.top = meun.top; this.top = meun.top;
this.localHeight = meun.height; this.localHeight = meun.height;
this.getTypeName(options.type); this.getTypeName(options.type);
this.balance = options.amount;
this.community_id = options.community_id;
this.getWalletInfo(); this.getWalletInfo();
}, },
methods: { methods: {
@ -106,16 +102,22 @@ export default {
}, },
// //
getWalletInfo() { getWalletInfo() {
// const params = {
// 使 community_id: this.community_id,
console.log('获取钱包信息'); }
// request(walletApi.walletChangeList, 'POST', params, { silent: false }).then(res => {
// request('/api/wallet/info', 'GET').then(res => { let filteredRows = res.rows;
// if (res.code === 0) { if (this.topVal == '应收') {
// this.balance = res.data.balance; filteredRows = res.rows.filter(item => item.change_category == 2);
// this.records = res.data.records; } else if (this.topVal == '已收') {
// } filteredRows = res.rows.filter(item => item.change_category == 1);
// }) } else if (this.topVal == '待收物业公积金') {
filteredRows = res.rows.filter(item => item.change_category == 4);
} else {
filteredRows = res.rows.filter(item => item.change_category == 3);
}
this.records = filteredRows;
})
} }
} }
} }