From 6595e00ff1b25b0f693a790ff076627da3e789cf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=BE=90=E9=A3=9E=E6=B4=8B?=
<15778543+xufeiyang6017@user.noreply.gitee.com>
Date: Fri, 30 Jan 2026 09:55:09 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=8C=E5=96=84=E8=AE=A4=E8=AF=81?=
=?UTF-8?q?=E7=8A=B6=E6=80=81=E6=98=BE=E7=A4=BA=E5=92=8C=E5=AE=A1=E6=A0=B8?=
=?UTF-8?q?=E5=A4=B1=E8=B4=A5=E5=8E=9F=E5=9B=A0=E5=B1=95=E7=A4=BA?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pages/index/index.js | 5 +++
pages/profile/authentication/index.js | 54 ++++++++++++++++++------
pages/profile/authentication/index.wxml | 7 +++
pages/profile/authentication/index.wxss | 22 ++++++++++
pages/profile/index.js | 4 ++
pages/profile/index.wxml | 15 +++++--
server-example/fix_settlement_fields.sql | 10 +++++
server-example/server-mysql.js | 8 +++-
8 files changed, 107 insertions(+), 18 deletions(-)
diff --git a/pages/index/index.js b/pages/index/index.js
index f3c4868..47502b2 100644
--- a/pages/index/index.js
+++ b/pages/index/index.js
@@ -3414,11 +3414,16 @@ Page({
// 调用服务器验证登录状态
const validateRes = await API.validateUserLogin()
+ console.log('验证登录状态响应:', validateRes)
+ console.log('验证登录状态响应完整数据:', JSON.stringify(validateRes))
if (validateRes.success && validateRes.userInfo) {
// 服务器返回了用户信息,同步到本地
const app = getApp()
const userInfo = validateRes.userInfo
+ console.log('登录时服务器返回的用户信息:', JSON.stringify(userInfo))
+ console.log('登录时是否包含idcardstatus:', 'idcardstatus' in userInfo)
+ console.log('登录时是否包含reason:', 'reason' in userInfo)
// 更新全局用户信息
app.globalData.userInfo = userInfo
diff --git a/pages/profile/authentication/index.js b/pages/profile/authentication/index.js
index 703dea0..8d6b6c5 100644
--- a/pages/profile/authentication/index.js
+++ b/pages/profile/authentication/index.js
@@ -15,7 +15,9 @@ Page({
idNumber: '', // 身份证号
address: '', // 居住地址
validStart: '', // 有效期开始
- validEnd: '' // 有效期结束
+ validEnd: '', // 有效期结束
+ idcardstatus: 0, // 身份证认证状态:0-待审核,1-审核通过,2-审核失败
+ reason: '' // 审核失败原因
},
/**
@@ -216,18 +218,40 @@ Page({
console.log('认证提交结果:', result);
if (result && result.success) {
- // 更新本地存储的用户信息
- const userInfo = wx.getStorageSync('userInfo') || {};
- const updatedUserInfo = {
- ...userInfo,
- idcard1: idcard1Url,
- idcard2: idcard2Url,
- businesslicenseurl: businessLicenseUrl,
- name: this.data.name,
- idNumber: this.data.idNumber,
- address: this.data.address
- };
- wx.setStorageSync('userInfo', updatedUserInfo);
+ // 认证成功后,获取最新的用户信息,包括认证状态
+ API.getUserInfo(openid).then(userInfoRes => {
+ if (userInfoRes.success && userInfoRes.data) {
+ const latestUserInfo = userInfoRes.data;
+ // 更新本地存储的用户信息
+ const userInfo = wx.getStorageSync('userInfo') || {};
+ const updatedUserInfo = {
+ ...userInfo,
+ ...latestUserInfo,
+ idcard1: idcard1Url,
+ idcard2: idcard2Url,
+ businesslicenseurl: businessLicenseUrl,
+ name: this.data.name,
+ idNumber: this.data.idNumber,
+ address: this.data.address
+ };
+ wx.setStorageSync('userInfo', updatedUserInfo);
+ console.log('认证成功,用户信息已更新,包括认证状态:', updatedUserInfo);
+ }
+ }).catch(err => {
+ console.error('获取最新用户信息失败:', err);
+ // 即使获取失败,也要更新基本认证信息
+ const userInfo = wx.getStorageSync('userInfo') || {};
+ const updatedUserInfo = {
+ ...userInfo,
+ idcard1: idcard1Url,
+ idcard2: idcard2Url,
+ businesslicenseurl: businessLicenseUrl,
+ name: this.data.name,
+ idNumber: this.data.idNumber,
+ address: this.data.address
+ };
+ wx.setStorageSync('userInfo', updatedUserInfo);
+ });
wx.hideLoading();
wx.showToast({
@@ -310,7 +334,9 @@ Page({
idNumber: userData.idNumber || userData.id_number || '',
address: userData.address || '',
validStart: userData.validStart || userData.valid_start || '',
- validEnd: userData.validEnd || userData.valid_end || ''
+ validEnd: userData.validEnd || userData.valid_end || '',
+ idcardstatus: userData.idcardstatus || 0,
+ reason: userData.reason || userData.reasonforfailure || ''
};
// 处理身份证正面图片
diff --git a/pages/profile/authentication/index.wxml b/pages/profile/authentication/index.wxml
index 70b8964..8bde99e 100644
--- a/pages/profile/authentication/index.wxml
+++ b/pages/profile/authentication/index.wxml
@@ -64,6 +64,13 @@
+
+
+
+ 审核失败原因
+ {{reason}}
+
+
提交审核
diff --git a/pages/profile/authentication/index.wxss b/pages/profile/authentication/index.wxss
index 92133ec..0165e20 100644
--- a/pages/profile/authentication/index.wxss
+++ b/pages/profile/authentication/index.wxss
@@ -167,6 +167,28 @@
line-height: 1.5;
}
+/* 审核失败原因 */
+.failure-reason {
+ background-color: #fff2f0;
+ border: 2rpx solid #ffccc7;
+ border-radius: 12rpx;
+ margin: 20rpx 30rpx;
+ padding: 24rpx;
+}
+
+.failure-title {
+ font-size: 28rpx;
+ font-weight: bold;
+ color: #ff4d4f;
+ margin-bottom: 16rpx;
+}
+
+.failure-content {
+ font-size: 24rpx;
+ color: #ff4d4f;
+ line-height: 1.5;
+}
+
/* 认证按钮 */
.auth-btn {
background-color: #07c160;
diff --git a/pages/profile/index.js b/pages/profile/index.js
index b3c1f8d..e9d015c 100644
--- a/pages/profile/index.js
+++ b/pages/profile/index.js
@@ -290,9 +290,13 @@ Page({
API.getUserInfo(openid).then(res => {
console.log('从服务器获取用户信息成功:', res)
+ console.log('服务器返回的完整数据:', JSON.stringify(res))
if (res.success && res.data) {
const serverUserInfo = res.data
+ console.log('服务器返回的用户信息:', JSON.stringify(serverUserInfo))
+ console.log('是否包含idcardstatus:', 'idcardstatus' in serverUserInfo)
+ console.log('是否包含reason:', 'reason' in serverUserInfo)
// 更新本地用户信息
const app = getApp()
diff --git a/pages/profile/index.wxml b/pages/profile/index.wxml
index b3762cc..5a42402 100644
--- a/pages/profile/index.wxml
+++ b/pages/profile/index.wxml
@@ -56,9 +56,18 @@
-
- 个人认证
- >
+
+
+ 个人认证
+
+ 待审核
+ 审核通过
+
+ {{userInfo.reasonforfailure ? '审核失败: ' + userInfo.reasonforfailure : '审核失败'}}
+
+ >
+
+
diff --git a/server-example/fix_settlement_fields.sql b/server-example/fix_settlement_fields.sql
index a793384..3694ab9 100644
--- a/server-example/fix_settlement_fields.sql
+++ b/server-example/fix_settlement_fields.sql
@@ -88,6 +88,16 @@ IF NOT EXISTS (
ALTER TABLE users ADD COLUMN reasonforfailure TEXT COMMENT '审核失败原因' AFTER partnerstatus;
END IF;
+-- 检查 idcardstatus 字段(身份证认证状态)
+IF NOT EXISTS (
+ SELECT * FROM information_schema.COLUMNS
+ WHERE TABLE_SCHEMA = 'wechat_app'
+ AND TABLE_NAME = 'users'
+ AND COLUMN_NAME = 'idcardstatus'
+) THEN
+ ALTER TABLE users ADD COLUMN idcardstatus INT DEFAULT 0 COMMENT '身份证认证状态(0:待审核,1:审核通过,2:审核失败)' AFTER reasonforfailure;
+END IF;
+
-- 检查 audit_time 字段(审核时间)
IF NOT EXISTS (
SELECT * FROM information_schema.COLUMNS
diff --git a/server-example/server-mysql.js b/server-example/server-mysql.js
index b210614..dfffffa 100644
--- a/server-example/server-mysql.js
+++ b/server-example/server-mysql.js
@@ -1199,6 +1199,12 @@ User.init({
partnerstatus: {
type: DataTypes.STRING(255) // 合作商状态
},
+ // 身份证认证状态字段
+ idcardstatus: {
+ type: DataTypes.INTEGER, // 0: 待审核, 1: 审核通过, 2: 审核失败
+ defaultValue: 0, // 默认值为待审核
+ comment: '身份证认证状态'
+ },
// 授权区域字段 - 用于存储用户位置信息
authorized_region: {
type: DataTypes.TEXT // 存储用户位置信息的JSON字符串
@@ -2468,7 +2474,7 @@ app.post('/api/user/validate', async (req, res) => {
// 查找用户
const user = await User.findOne({
where: { openid },
- attributes: ['openid', 'userId', 'name', 'avatarUrl', 'phoneNumber', 'type']
+ attributes: ['openid', 'userId', 'name', 'avatarUrl', 'phoneNumber', 'type', 'partnerstatus', 'reasonforfailure', 'idcardstatus']
});
if (!user) {