feat(fe): 身份卡手机号门槛加「手动填写」兜底
getPhoneNumber 需企业认证 + 手机号验证权限,个人/未认证小程序唤不起。 门槛卡加「手动填写手机号」入口:填 11 位号 → updateProfile 存库 → 重取卡生成。 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -27,6 +27,8 @@ Page({
|
||||
saving: false,
|
||||
needPhone: false, // 没手机号:门槛,先验证才生成
|
||||
phoneRefused: false, // 用户拒绝了授权
|
||||
manualMode: false, // 手动填手机号(getPhoneNumber 唤不起时的兜底)
|
||||
manualPhone: '',
|
||||
},
|
||||
onLoad(q) {
|
||||
store
|
||||
@@ -347,6 +349,32 @@ Page({
|
||||
});
|
||||
},
|
||||
|
||||
// 手动填手机号兜底(getPhoneNumber 需企业认证,唤不起时用这个)
|
||||
showManual() {
|
||||
this.setData({ manualMode: true });
|
||||
},
|
||||
onManualPhone(e) {
|
||||
this.setData({ manualPhone: e.detail.value });
|
||||
},
|
||||
submitManual() {
|
||||
const p = (this.data.manualPhone || '').trim();
|
||||
if (!/^1\d{10}$/.test(p)) return wx.showToast({ title: '手机号格式不对', icon: 'none' });
|
||||
wx.showLoading({ title: '保存中…', mask: true });
|
||||
api
|
||||
.updateProfile({ phone: p })
|
||||
.then(() => api.petIDCard(this.data.petId))
|
||||
.then((card) => {
|
||||
wx.hideLoading();
|
||||
if (!card) return;
|
||||
this.setData({ card, qrReady: !!card.qr_ready, needPhone: false, manualMode: false });
|
||||
wx.nextTick(() => this.draw());
|
||||
})
|
||||
.catch((err) => {
|
||||
wx.hideLoading();
|
||||
toastErr(err, '保存失败');
|
||||
});
|
||||
},
|
||||
|
||||
onSave() {
|
||||
if (!this.data.cardImg) return wx.showToast({ title: '还在生成,稍等一下', icon: 'none' });
|
||||
if (this.data.saving) return;
|
||||
|
||||
Reference in New Issue
Block a user