chore: establish V1.1 recovery baseline
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
/**
|
||||
* 实名认证页面
|
||||
* 用户提交姓名和身份证号码进行实名认证
|
||||
*/
|
||||
const api = require('../../utils/api');
|
||||
const { setAppStore } = require('../../stores/appStore');
|
||||
|
||||
Page({
|
||||
data: {
|
||||
realName: '',
|
||||
idNumber: '',
|
||||
loading: false,
|
||||
error: '',
|
||||
showAgreement: false,
|
||||
agreed: false
|
||||
},
|
||||
|
||||
onRealNameInput(e) {
|
||||
this.setData({ realName: e.detail.value, error: '' });
|
||||
},
|
||||
|
||||
onIdNumberInput(e) {
|
||||
this.setData({ idNumber: e.detail.value.replace(/\s/g, ''), error: '' });
|
||||
},
|
||||
|
||||
onAgreeChange(e) {
|
||||
this.setData({ agreed: e.detail.value[0] || false });
|
||||
},
|
||||
|
||||
async handleSubmit() {
|
||||
const { realName, idNumber, agreed } = this.data;
|
||||
|
||||
if (!agreed) {
|
||||
wx.showToast({ title: '请先阅读并同意协议', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
|
||||
if (!realName || realName.length < 2) {
|
||||
this.setData({ error: '请输入真实姓名' });
|
||||
return;
|
||||
}
|
||||
|
||||
if (!idNumber || idNumber.length !== 18) {
|
||||
this.setData({ error: '请输入正确的18位身份证号码' });
|
||||
return;
|
||||
}
|
||||
|
||||
this.setData({ loading: true, error: '' });
|
||||
|
||||
try {
|
||||
const token = wx.getStorageSync('accessToken');
|
||||
const res = await api.post('/verification/submit', { realName, idNumber }, {
|
||||
Authorization: `Bearer ${token}`
|
||||
});
|
||||
|
||||
wx.setStorageSync('isVerified', true);
|
||||
setAppStore('isVerified', true);
|
||||
|
||||
wx.showToast({ title: '认证成功', icon: 'success' });
|
||||
setTimeout(() => {
|
||||
wx.redirectTo({ url: '/pages/profile-basic/profile-basic' });
|
||||
}, 1500);
|
||||
} catch (err) {
|
||||
this.setData({
|
||||
loading: false,
|
||||
error: err.message || '认证失败,请重试'
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
// 检查是否已认证
|
||||
const { isVerified } = getApp().store || {};
|
||||
if (isVerified) {
|
||||
wx.redirectTo({ url: '/pages/profile-basic/profile-basic' });
|
||||
}
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user