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,
|
saving: false,
|
||||||
needPhone: false, // 没手机号:门槛,先验证才生成
|
needPhone: false, // 没手机号:门槛,先验证才生成
|
||||||
phoneRefused: false, // 用户拒绝了授权
|
phoneRefused: false, // 用户拒绝了授权
|
||||||
|
manualMode: false, // 手动填手机号(getPhoneNumber 唤不起时的兜底)
|
||||||
|
manualPhone: '',
|
||||||
},
|
},
|
||||||
onLoad(q) {
|
onLoad(q) {
|
||||||
store
|
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() {
|
onSave() {
|
||||||
if (!this.data.cardImg) return wx.showToast({ title: '还在生成,稍等一下', icon: 'none' });
|
if (!this.data.cardImg) return wx.showToast({ title: '还在生成,稍等一下', icon: 'none' });
|
||||||
if (this.data.saving) return;
|
if (this.data.saving) return;
|
||||||
|
|||||||
@@ -7,8 +7,17 @@
|
|||||||
<view class="ic-gate-ic"><pt-icon name="user" size="{{72}}"></pt-icon></view>
|
<view class="ic-gate-ic"><pt-icon name="user" size="{{72}}"></pt-icon></view>
|
||||||
<view class="ic-gate-t">生成身份卡需要手机号</view>
|
<view class="ic-gate-t">生成身份卡需要手机号</view>
|
||||||
<view class="ic-gate-p">身份卡背面的「联系电话」用于走失时联系你,验证后才能生成</view>
|
<view class="ic-gate-p">身份卡背面的「联系电话」用于走失时联系你,验证后才能生成</view>
|
||||||
<button wx:if="{{!phoneRefused}}" class="btn btn-primary btn-block ic-gate-btn" open-type="getPhoneNumber" bindgetphonenumber="onGetPhone">用微信验证手机号</button>
|
|
||||||
<view wx:else class="ic-gate-refuse">没有手机号,无法生成身份卡</view>
|
<block wx:if="{{!manualMode}}">
|
||||||
|
<button wx:if="{{!phoneRefused}}" class="btn btn-primary btn-block ic-gate-btn" open-type="getPhoneNumber" bindgetphonenumber="onGetPhone">用微信验证手机号</button>
|
||||||
|
<view wx:else class="ic-gate-refuse">没有手机号,无法生成身份卡</view>
|
||||||
|
<view class="ic-gate-manual" bindtap="showManual">唤不起来?手动填写手机号</view>
|
||||||
|
</block>
|
||||||
|
|
||||||
|
<block wx:else>
|
||||||
|
<input class="input ic-gate-input" type="number" maxlength="11" placeholder="输入 11 位手机号" placeholder-class="placeholder" value="{{manualPhone}}" bindinput="onManualPhone"/>
|
||||||
|
<button class="btn btn-primary btn-block ic-gate-btn" bindtap="submitManual">保存并生成</button>
|
||||||
|
</block>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 画好的卡当成图片展示。canvas 本身是离屏的(挪到屏幕外),只用来生成图 -->
|
<!-- 画好的卡当成图片展示。canvas 本身是离屏的(挪到屏幕外),只用来生成图 -->
|
||||||
|
|||||||
@@ -34,3 +34,5 @@ button.ic-btn::after{border:none}
|
|||||||
.ic-gate-p{font-size:var(--fs-sm);color:var(--muted);line-height:1.6;margin:var(--sp-2) 0 var(--sp-5)}
|
.ic-gate-p{font-size:var(--fs-sm);color:var(--muted);line-height:1.6;margin:var(--sp-2) 0 var(--sp-5)}
|
||||||
.ic-gate-refuse{color:var(--red-ink);font-weight:var(--fw-b);font-size:var(--fs-md)}
|
.ic-gate-refuse{color:var(--red-ink);font-weight:var(--fw-b);font-size:var(--fs-md)}
|
||||||
.ic-gate-btn{margin-top:var(--sp-2)}
|
.ic-gate-btn{margin-top:var(--sp-2)}
|
||||||
|
.ic-gate-manual{margin-top:var(--sp-4);color:var(--muted);font-size:var(--fs-sm);text-decoration:underline}
|
||||||
|
.ic-gate-input{margin-bottom:var(--sp-3);text-align:center}
|
||||||
|
|||||||
Reference in New Issue
Block a user