完成钱包模块
This commit is contained in:
parent
61c15f5d67
commit
8d60cb6200
4
api/wallet.js
Normal file
4
api/wallet.js
Normal file
@ -0,0 +1,4 @@
|
||||
export const apiArr = {
|
||||
walletList: "/api/v2/wechat/wallet/list", // 商户钱包
|
||||
walletChangeList: "/api/v2/wechat/wallet/change/list", // 商户钱包变更详情
|
||||
};
|
||||
@ -25,16 +25,16 @@
|
||||
<view class="walletBox">
|
||||
<view class="walletBox_top">钱包</view>
|
||||
<view class="walletBox_content">
|
||||
<view class="walletBox_item" @click="goWallet(1)">
|
||||
<view>999.00元</view>
|
||||
<view class="walletBox_item" @click="goWallet(1, walletInfo.guarantee.toFixed(2))">
|
||||
<view>{{ walletInfo.guarantee ? walletInfo.guarantee.toFixed(2) : "0.00" }}元</view>
|
||||
<view class="walletBox_item_text">保证金</view>
|
||||
</view>
|
||||
<view class="walletBox_item" @click="goWallet(2)">
|
||||
<view>999.00元</view>
|
||||
<view class="walletBox_item" @click="goWallet(2, walletInfo.receivable.toFixed(2))">
|
||||
<view>{{ walletInfo.receivable ? walletInfo.receivable.toFixed(2) : "0.00" }}元</view>
|
||||
<view class="walletBox_item_text">应收</view>
|
||||
</view>
|
||||
<view class="walletBox_item" @click="goWallet(3)">
|
||||
<view>999.00元</view>
|
||||
<view class="walletBox_item" @click="goWallet(3, walletInfo.handling_fee.toFixed(2))">
|
||||
<view>{{ walletInfo.handling_fee ? walletInfo.handling_fee.toFixed(2) : "0.00" }}元</view>
|
||||
<view class="walletBox_item_text">手续费</view>
|
||||
</view>
|
||||
</view>
|
||||
@ -98,6 +98,7 @@ import {
|
||||
import {
|
||||
apiArr
|
||||
} from '../../../api/community';
|
||||
import { apiArr as walletApi } from '../../../api/wallet';
|
||||
|
||||
|
||||
export default {
|
||||
@ -125,6 +126,7 @@ export default {
|
||||
url: "/packages/customerService/chattingRecords/index",
|
||||
}
|
||||
],
|
||||
walletInfo: {},
|
||||
}
|
||||
},
|
||||
onLoad(options) {
|
||||
@ -135,8 +137,16 @@ export default {
|
||||
this.getShopList();
|
||||
},
|
||||
|
||||
|
||||
methods: {
|
||||
// 获取钱包信息
|
||||
getWalletInfo() {
|
||||
const params = {
|
||||
merchant_id: this.selectedShop.id,
|
||||
}
|
||||
request(walletApi.walletList, 'POST', params, { silent: false }).then(res => {
|
||||
this.walletInfo = res;
|
||||
})
|
||||
},
|
||||
// 获取商家列表
|
||||
getShopList() {
|
||||
request(apiArr.getShopList, 'POST', {}, { silent: false }).then(res => {
|
||||
@ -146,11 +156,14 @@ export default {
|
||||
this.shopList = res.rows;
|
||||
if (this.shopList.length > 0) {
|
||||
this.selectedShop = this.shopList[0];
|
||||
// 确保selectedShop有值后再调用getWalletInfo()
|
||||
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) {
|
||||
this.active = index;
|
||||
|
||||
@ -15,11 +15,11 @@
|
||||
<view>
|
||||
<view class="balance-title">{{ topVal }}(元)</view>
|
||||
<view class="balance-amount">{{ balance }}</view>
|
||||
<view class="balance-icon" v-if="topVal != '保证金'">
|
||||
<image src="http://localhost:8080/user_wallet2.png" mode="widthFix" />
|
||||
</view>
|
||||
<view v-else class="balance-text">
|
||||
<!-- <view v-if="topVal == '保证金'" class="balance-text">
|
||||
去充值
|
||||
</view> -->
|
||||
<view class="balance-icon">
|
||||
<image src="http://localhost:8080/user_wallet2.png" mode="widthFix" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@ -27,44 +27,48 @@
|
||||
|
||||
<!-- 变动记录 -->
|
||||
<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"
|
||||
:class="['tabItem', selectedTab === item.id ? 'active2' : '']" @click="selectTab(index, item)">
|
||||
{{ item.tabName }}
|
||||
</view>
|
||||
</view> -->
|
||||
<view v-if="records.length == 0">
|
||||
<view class="records-list">暂无变动记录</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-info">
|
||||
<view class="record-name">{{ record.name }}</view>
|
||||
<view class="record-time">{{ record.time }}</view>
|
||||
<view class="record-name">{{ record.change_reason == 1 ? '下单' : '退单' }} - {{
|
||||
record.related_order }}</view>
|
||||
<view class="record-time">{{ record.change_time }}</view>
|
||||
</view>
|
||||
<view class="record-amount" v-if="topVal == '保证金'">
|
||||
<view>
|
||||
<text :class="['amount-sign', record.amount.startsWith('+') ? 'positive' : 'negative']">{{
|
||||
record.amount.startsWith('+') ? '+' : '-' }}</text>
|
||||
<text :class="['amount-value', record.amount.startsWith('+') ? 'positive' : 'negative']">¥{{
|
||||
record.amount.replace(/[+-]/, '') }}</text>
|
||||
<text :class="['amount-sign', record.change_reason == 1 ? 'positive' : 'negative']">{{
|
||||
record.change_reason == 1 ? '+' : '-' }}</text>
|
||||
<text :class="['amount-value', record.change_reason == 1 ? 'positive' : 'negative']">¥{{
|
||||
record.amount_change }}</text>
|
||||
</view>
|
||||
<view class="record-balance">余:¥{{ record.remain }}</view>
|
||||
<view class="record-balance">余:¥{{ record.balance_after }}</view>
|
||||
</view>
|
||||
|
||||
<view class="record-amount" v-else-if="topVal == '应收'">
|
||||
<view :class="['amount-sign', record.amount.startsWith('+') ? 'positive' : 'negative']">{{
|
||||
record.amount.startsWith('+') ? '收款' : '退款' }}</view>
|
||||
<view :class="['amount-sign', record.change_reason == 1 ? 'positive' : 'negative']">{{
|
||||
record.change_reason == 1 ? '收款' : '退款' }}</view>
|
||||
<view>
|
||||
<text :class="['amount-sign', record.amount.startsWith('+') ? 'positive' : 'negative']">{{
|
||||
record.amount.startsWith('+') ? '+' : '-' }}</text>
|
||||
<text :class="['amount-value', record.amount.startsWith('+') ? 'positive' : 'negative']">¥{{
|
||||
record.amount.replace(/[+-]/, '') }}</text>
|
||||
<text :class="['amount-sign', record.change_reason == 1 ? 'positive' : 'negative']">{{
|
||||
record.change_reason == 1 ? '+' : '-' }}</text>
|
||||
<text :class="['amount-value', record.change_reason == 1 ? 'positive' : 'negative']">¥{{
|
||||
record.amount_change }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="record-amount" v-else>
|
||||
<view class="record-balance">手续费</view>
|
||||
<view>
|
||||
<text class="amount-sign">{{ record.amount.startsWith('+') ? '+' : '-' }}</text>
|
||||
<text class="amount-sign">¥{{ record.amount.replace(/[+-]/, '') }}</text>
|
||||
<text class="amount-sign">{{ record.change_reason == 1 ? '+' : '-' }}</text>
|
||||
<text class="amount-sign">¥{{ record.amount_change }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@ -74,27 +78,16 @@
|
||||
</template>
|
||||
<script>
|
||||
import { menuButtonInfo, NavgateTo, picUrl, request } from '../../../utils/index';
|
||||
import { apiArr as walletApi } from '../../../api/wallet';
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
top: "",
|
||||
localHeight: "",
|
||||
topVal: "",
|
||||
balance: "160.80",
|
||||
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"
|
||||
}
|
||||
],
|
||||
balance: "",
|
||||
records: [],
|
||||
tabList: [
|
||||
{
|
||||
id: 0,
|
||||
@ -109,7 +102,8 @@ export default {
|
||||
tabName: '消费记录'
|
||||
}
|
||||
],
|
||||
selectedTab: 0
|
||||
selectedTab: 0,
|
||||
merchant_id: "",
|
||||
}
|
||||
},
|
||||
onLoad(options) {
|
||||
@ -117,6 +111,8 @@ export default {
|
||||
this.top = meun.top;
|
||||
this.localHeight = meun.height;
|
||||
this.topVal = options.type == 1 ? '保证金' : (options.type == 2 ? '应收' : '手续费');
|
||||
this.balance = options.amount;
|
||||
this.merchant_id = options.merchant_id;
|
||||
this.getWalletInfo();
|
||||
},
|
||||
methods: {
|
||||
@ -126,21 +122,24 @@ export default {
|
||||
});
|
||||
},
|
||||
selectTab(index, item) {
|
||||
console.log("🚀 ~ selectTab ~ item:", item)
|
||||
this.selectedTab = item.id;
|
||||
},
|
||||
// 获取钱包信息
|
||||
getWalletInfo() {
|
||||
// 这里应该是真实的接口调用
|
||||
// 暂时使用模拟数据
|
||||
console.log('获取钱包信息');
|
||||
// 实际项目中应该调用接口获取余额和交易记录
|
||||
// request('/api/wallet/info', 'GET').then(res => {
|
||||
// if (res.code === 0) {
|
||||
// this.balance = res.data.balance;
|
||||
// this.records = res.data.records;
|
||||
// }
|
||||
// })
|
||||
const params = {
|
||||
merchant_id: this.merchant_id,
|
||||
}
|
||||
request(walletApi.walletChangeList, 'POST', params, { silent: false }).then(res => {
|
||||
let filteredRows = res.rows;
|
||||
if (this.topVal == '保证金') {
|
||||
filteredRows = res.rows.filter(item => item.change_category == 5);
|
||||
} 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;
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -17,20 +17,20 @@
|
||||
<view class="walletBox">
|
||||
<view class="walletBox_top">钱包</view>
|
||||
<view class="walletBox_content">
|
||||
<view class="walletBox_item" @click="goWallet(1)">
|
||||
<view>999.00元</view>
|
||||
<view class="walletBox_item" @click="goWallet(1, walletInfo.receivable.toFixed(2))">
|
||||
<view>{{ walletInfo.receivable ? walletInfo.receivable.toFixed(2) : "0.00" }}元</view>
|
||||
<view class="walletBox_item_text">应收</view>
|
||||
</view>
|
||||
<view class="walletBox_item" @click="goWallet(2)">
|
||||
<view>999.00元</view>
|
||||
<view class="walletBox_item" @click="goWallet(2, walletInfo.received.toFixed(2))">
|
||||
<view>{{ walletInfo.received ? walletInfo.received.toFixed(2) : "0.00" }}元</view>
|
||||
<view class="walletBox_item_text">已收</view>
|
||||
</view>
|
||||
<view class="walletBox_item" @click="goWallet(3)">
|
||||
<view>999.00元</view>
|
||||
<view class="walletBox_item" @click="goWallet(3, walletInfo.pending.toFixed(2))">
|
||||
<view>{{ walletInfo.pending ? walletInfo.pending.toFixed(2) : "0.00" }}元</view>
|
||||
<view class="walletBox_item_text">待收物业公积金</view>
|
||||
</view>
|
||||
<view class="walletBox_item" @click="goWallet(4)">
|
||||
<view>999.00元</view>
|
||||
<view class="walletBox_item" @click="goWallet(4, walletInfo.handling_fee.toFixed(2))">
|
||||
<view>{{ walletInfo.handling_fee ? walletInfo.handling_fee.toFixed(2) : "0.00" }}元</view>
|
||||
<view class="walletBox_item_text">手续费</view>
|
||||
</view>
|
||||
</view>
|
||||
@ -64,13 +64,15 @@ import {
|
||||
} from "../../../utils";
|
||||
|
||||
import { apiArr } from "../../../api/community";
|
||||
import { apiArr as walletApi } from '../../../api/wallet';
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
communityVal: "切换小区",
|
||||
showWorkOrderSection: false,
|
||||
communityList: []
|
||||
communityList: [],
|
||||
walletInfo: {},
|
||||
}
|
||||
},
|
||||
async onLoad() {
|
||||
@ -92,6 +94,8 @@ export default {
|
||||
uni.setStorageSync('changeWorkOrderData', { id: res.rows[0].community_id, name: res.rows[0].name });
|
||||
this.communityVal = res.rows[0].name;
|
||||
}
|
||||
// 获取钱包信息
|
||||
this.getWalletInfo();
|
||||
});
|
||||
},
|
||||
async onShow() {
|
||||
@ -107,12 +111,33 @@ export default {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
goWallet(type) {
|
||||
if (type == 2) {
|
||||
return
|
||||
// 获取钱包信息
|
||||
getWalletInfo() {
|
||||
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() {
|
||||
NavgateTo("/packages/workOrderDashboard/myCommunity/index");
|
||||
},
|
||||
|
||||
@ -25,22 +25,26 @@
|
||||
<!-- 余额变动记录 -->
|
||||
<view class="records-container">
|
||||
<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-info">
|
||||
<view class="record-name">{{ record.name }}</view>
|
||||
<view class="record-time">{{ record.time }}</view>
|
||||
<view class="record-name">{{ record.change_reason == 1 ? '下单' : '退单' }} - {{
|
||||
record.related_order }}</view>
|
||||
<view class="record-time">{{ record.change_time }}</view>
|
||||
</view>
|
||||
<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 class="record-balance" v-else-if="topVal == '待收物业公积金'">待收</view>
|
||||
<view class="record-balance" v-else-if="topVal == '手续费'">手续费</view>
|
||||
<view>
|
||||
<text :class="['amount-sign', record.amount.startsWith('+') ? 'positive' : 'negative']">{{
|
||||
record.amount.startsWith('+') ? '+' : '-' }}</text>
|
||||
<text :class="['amount-value', record.amount.startsWith('+') ? 'positive' : 'negative']">¥{{
|
||||
record.amount.replace(/[+-]/, '') }}</text>
|
||||
<text :class="['amount-sign', record.change_reason == 1 ? 'positive' : 'negative']">{{
|
||||
record.change_reason == 1 ? '+' : '-' }}</text>
|
||||
<text :class="['amount-value', record.change_reason == 1 ? 'positive' : 'negative']">¥{{
|
||||
record.amount_change }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@ -50,27 +54,17 @@
|
||||
</template>
|
||||
<script>
|
||||
import { menuButtonInfo, NavgateTo, picUrl, request } from '../../../utils/index';
|
||||
import { apiArr as walletApi } from '../../../api/wallet';
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
top: "",
|
||||
localHeight: "",
|
||||
topVal: "",
|
||||
balance: "160.80",
|
||||
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"
|
||||
}
|
||||
]
|
||||
balance: "",
|
||||
records: [],
|
||||
community_id: "",
|
||||
}
|
||||
},
|
||||
onLoad(options) {
|
||||
@ -78,6 +72,8 @@ export default {
|
||||
this.top = meun.top;
|
||||
this.localHeight = meun.height;
|
||||
this.getTypeName(options.type);
|
||||
this.balance = options.amount;
|
||||
this.community_id = options.community_id;
|
||||
this.getWalletInfo();
|
||||
},
|
||||
methods: {
|
||||
@ -106,16 +102,22 @@ export default {
|
||||
},
|
||||
// 获取钱包信息
|
||||
getWalletInfo() {
|
||||
// 这里应该是真实的接口调用
|
||||
// 暂时使用模拟数据
|
||||
console.log('获取钱包信息');
|
||||
// 实际项目中应该调用接口获取余额和交易记录
|
||||
// request('/api/wallet/info', 'GET').then(res => {
|
||||
// if (res.code === 0) {
|
||||
// this.balance = res.data.balance;
|
||||
// this.records = res.data.records;
|
||||
// }
|
||||
// })
|
||||
const params = {
|
||||
community_id: this.community_id,
|
||||
}
|
||||
request(walletApi.walletChangeList, 'POST', params, { silent: false }).then(res => {
|
||||
let filteredRows = res.rows;
|
||||
if (this.topVal == '应收') {
|
||||
filteredRows = res.rows.filter(item => item.change_category == 2);
|
||||
} 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;
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user