hookehuyr

feat(收款设置): 将银行字段从名称改为ID并添加银行列表接口

修改用户信息中的银行字段从名称(bank)改为ID(bank_id)
添加获取银行列表接口并在收款设置页面使用
更新相关权限检查和字段验证逻辑
......@@ -37,7 +37,7 @@ export const payCheckAPI = (params) => fn(fetch.post(Api.PAY_CHECK, params));
* @param sms_code 短信验证码
* @param school_id 学校id
* @param name 真实姓名
* @param bank 开户行
* @param bank_id 开户行id
* @param bank_no 银行卡号
* @param idcard 身份证号
* @param is_signed 是否阅读协议
......
/*
* @Date: 2025-07-10 16:13:08
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2025-07-14 19:45:14
* @LastEditTime: 2025-08-06 17:34:27
* @FilePath: /jgdl/src/api/other.js
* @Description: 文件描述
*/
......@@ -12,6 +12,7 @@ const Api = {
GET_BRANDS_MODELS: '/srv/?a=common&t=get_brands_models',
GET_VEHICLE_BRANDS: '/srv/?a=common&t=get_vehicle_brands',
GET_VERIFICATION_PRICE: '/srv/?a=common&t=get_verification_price',
GET_BANKS: '/srv/?a=common&t=get_banks',
SUBMIT_FEEDBACK: '/srv/?a=feedback&t=add',
GET_FEEDBACK_LIST: '/srv/?a=feedback&t=list',
GET_FAVORITE_LIST: '/srv/?a=favorite&t=list',
......@@ -83,3 +84,11 @@ export const getFeedbackListAPI = (params) => fn(fetch.get(Api.GET_FEEDBACK_LIST
* @returns
*/
export const submitFeedbackAPI = (params) => fn(fetch.post(Api.SUBMIT_FEEDBACK, params));
/**
* @description: 获取银行列表
* @param {*} params
* @param {string} params.data[{ id, name }] - 银行列表
* @returns
*/
export const getBanksAPI = (params) => fn(fetch.get(Api.GET_BANKS, params));
......
<!--
* @Date: 2022-09-19 14:11:06
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2025-08-06 12:40:14
* @LastEditTime: 2025-08-06 17:43:18
* @FilePath: /jgdl/src/pages/collectionSettings/index.vue
* @Description: 收款设置
-->
......@@ -58,7 +58,7 @@
<text class="form-label">银行名称</text>
<view class="bank-selector" @click="showBankPicker">
<text class="bank-text" :class="{ 'bank-selected': tempAccountInfo.bankName }">
{{ tempAccountInfo.bankName || '请选择银行' }}
{{ getBankNameById(tempAccountInfo.bankName) || '请选择银行' }}
</text>
<text class="arrow-down">></text>
</view>
......@@ -186,6 +186,8 @@ import "./index.less";
// 导入接口
import { updateProfileAPI, getProfileAPI } from '@/api/index'
import { getBanksAPI } from '@/api/other'
// 导入用户状态管理
import { useUserStore } from '@/stores/user'
......@@ -252,27 +254,27 @@ const idCardError = ref('');
const bankPickerValue = ref([]);
/**
* 银行列表数据(模拟数据,后期从接口获取)
* 银行列表数据(从接口获取)
*/
const bankOptions = ref([
{ text: '中国工商银行', value: '中国工商银行' },
{ text: '中国建设银行', value: '中国建设银行' },
{ text: '中国农业银行', value: '中国农业银行' },
{ text: '中国银行', value: '中国银行' },
{ text: '交通银行', value: '交通银行' },
{ text: '招商银行', value: '招商银行' },
{ text: '中信银行', value: '中信银行' },
{ text: '光大银行', value: '光大银行' },
{ text: '华夏银行', value: '华夏银行' },
{ text: '民生银行', value: '民生银行' },
{ text: '广发银行', value: '广发银行' },
{ text: '平安银行', value: '平安银行' },
{ text: '浦发银行', value: '浦发银行' },
{ text: '兴业银行', value: '兴业银行' },
{ text: '邮储银行', value: '邮储银行' }
]);
const bankOptions = ref([]);
/**
* 获取银行列表
*/
const getBanksList = async () => {
try {
const result = await getBanksAPI();
if (result.code && result.data) {
// 适配数据格式:将 {id, name} 转换为 {text: name, value: id}
bankOptions.value = result.data.map(bank => ({
text: bank.name,
value: bank.id
}));
}
} catch (error) {
console.error('获取银行列表失败:', error);
}
};
/**
* 获取用户信息
......@@ -284,9 +286,9 @@ const getUserInfo = async () => {
const userInfo = result.data;
// 设置收款账号信息
if (userInfo.bank && userInfo.bank_no) {
if (userInfo.bank_id && userInfo.bank_no) {
accountInfo.value = {
bankName: userInfo.bank,
bankName: userInfo.bank_id, // 存储银行ID
bankAccount: userInfo.bank_no
};
}
......@@ -305,9 +307,10 @@ const getUserInfo = async () => {
};
/**
* 页面加载时获取用户信息
* 页面加载时获取数据
*/
onMounted(() => {
getBanksList();
getUserInfo();
});
......@@ -361,13 +364,24 @@ const handleIdCardBlur = () => {
};
/**
* 根据银行ID获取银行名称
* @param {string} bankId - 银行ID
* @returns {string} - 银行名称
*/
const getBankNameById = (bankId) => {
if (!bankId || !bankOptions.value.length) return '';
const bank = bankOptions.value.find(item => item.value === bankId);
return bank ? bank.text : bankId;
};
/**
* 显示银行选择弹窗
*/
const showBankPicker = () => {
// 设置当前选中的值
if (tempAccountInfo.value.bankName) {
bankPickerValue.value = [tempAccountInfo.value.bankName];
} else {
} else if (bankOptions.value.length > 0) {
bankPickerValue.value = [bankOptions.value[0].value];
}
showBankModal.value = true;
......@@ -414,7 +428,7 @@ const saveAccountInfo = async () => {
try {
// 调用API保存收款账号信息
const result = await updateProfileAPI({
bank: tempAccountInfo.value.bankName,
bank_id: tempAccountInfo.value.bankName, // 发送银行ID
bank_no: tempAccountInfo.value.bankAccount
});
......@@ -423,7 +437,7 @@ const saveAccountInfo = async () => {
// 更新全局用户状态
userStore.updateUserInfo({
bank: tempAccountInfo.value.bankName,
bank_id: tempAccountInfo.value.bankName, // 存储银行ID
bank_no: tempAccountInfo.value.bankAccount
});
......
<!--
* @Date: 2022-09-19 14:11:06
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2025-08-06 14:03:17
* @LastEditTime: 2025-08-06 15:30:03
* @FilePath: /jgdl/src/pages/myOrders/index.vue
* @Description: 订单管理页面
-->
......@@ -627,7 +627,7 @@ const loadOrderData = async (isLoadMore = false) => {
loading.value = true
const type = viewMode.value === 'buy' ? 'buy' : viewMode.value === 'verification' ? 'verification' : 'sell'
// 处理状态筛选逻辑
let status = undefined
if (activeTab.value === 'completed') {
......@@ -643,42 +643,8 @@ const loadOrderData = async (isLoadMore = false) => {
// 其他单一状态
status = activeTab.value
}
const page = isLoadMore ? currentPage.value + 1 : 0
// TAG: 添加mock数据用于测试
// if (page === 0) {
// const mockOrder = {
// id: `mock_${type}_${Date.now()}`,
// status: 9, // 已发货/待收货状态
// created_time: new Date().toLocaleString('zh-CN'),
// total_amount: 15000,
// details: {
// id: `detail_${Date.now()}`,
// vehicle: {
// id: `vehicle_${Date.now()}`,
// brand: '雅迪',
// model: 'DE2',
// manufacture_year: 2023,
// range_km: 60,
// battery_capacity_ah: 48,
// price: 15000,
// front_photo: DEFAULT_COVER_IMG,
// seller: {
// nickname: '测试卖家',
// phone: '138****8888'
// }
// }
// },
// buyer: {
// nickname: '测试买家',
// phone: '139****9999'
// },
// is_sold: false
// }
// const targetOrders = viewMode.value === 'buy' ? boughtOrders : soldOrders
// targetOrders.value = [mockOrder]
// }
const page = isLoadMore ? currentPage.value + 1 : 0
const response = await getOrderListAPI({
type,
......@@ -1330,7 +1296,6 @@ const performConfirmReceive = async (orderId) => {
const response = await receiveOrderAPI({ order_id: order.id })
if (response.code) {
// 接口返回状态为11,确认收货成功
order.status = 11 // 更新为已完成状态
Taro.showToast({
......
......@@ -1165,7 +1165,7 @@ const checkUserPermission = async () => {
Taro.navigateTo({
url: '/pages/register/index'
})
} else if (permissionResult.missingFields.includes('name') || permissionResult.missingFields.includes('bank') || permissionResult.missingFields.includes('bank_no') || permissionResult.missingFields.includes('idcard')) {
} else if (permissionResult.missingFields.includes('name') || permissionResult.missingFields.includes('bank_id') || permissionResult.missingFields.includes('bank_no') || permissionResult.missingFields.includes('idcard')) {
// 收款信息未填写
Taro.redirectTo({
url: '/pages/collectionSettings/index?target=sell'
......
/*
* @Date: 2025-01-08 18:00:00
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2025-08-05 18:16:58
* @LastEditTime: 2025-08-06 17:43:41
* @FilePath: /jgdl/src/stores/user.js
* @Description: 用户状态管理
*/
......@@ -25,7 +25,7 @@ export const useUserStore = defineStore('user', {
favorite_count: 0,
message_count: 0,
name: '',
bank: '',
bank_id: '',
bank_no: '',
idcard: '',
is_signed: false,
......@@ -48,8 +48,8 @@ export const useUserStore = defineStore('user', {
*/
hasCompleteCollectionInfo: (state) => {
return !!(
state.userInfo.bank && state.userInfo.bank.trim() &&
state.userInfo.bank_no && state.userInfo.bank_no.trim() &&
state.userInfo.bank_id && state.userInfo.bank_id &&
state.userInfo.bank_no && state.userInfo.bank_no &&
state.userInfo.name && state.userInfo.name.trim() &&
state.userInfo.idcard && state.userInfo.idcard.trim()
)
......@@ -120,7 +120,7 @@ export const useUserStore = defineStore('user', {
favorite_count: 0,
message_count: 0,
name: '',
bank: '',
bank_id: '',
bank_no: '',
idcard: '',
is_signed: false,
......
/*
* @Date: 2025-01-08 18:00:00
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2025-08-05 17:46:11
* @LastEditTime: 2025-08-06 17:43:47
* @FilePath: /jgdl/src/utils/permission.js
* @Description: 权限控制工具函数
*/
......@@ -40,7 +40,7 @@ const PERMISSION_CONFIG = {
[PERMISSION_TYPES.SELL_CAR]: {
message: '发布车源需要先完善个人信息',
redirectUrl: '/pages/register/index',
checkFields: ['phone', 'name', 'bank', 'bank_no', 'idcard']
checkFields: ['phone', 'name', 'bank_id', 'bank_no', 'idcard']
},
[PERMISSION_TYPES.BUY_CAR]: {
message: '购买车辆需要先完善个人信息',
......