fix: make phone authorization skippable in registration

getPhoneNumber requires verified enterprise miniprogram account.
Allow users to skip phone auth and complete registration without it.
这个提交包含在:
Guoguo
2026-05-06 06:29:03 -07:00
父节点 52456d850e
当前提交 c065d3fdce
修改 4 个文件,包含 46 行新增8 行删除
+1 -1
查看文件
@@ -16,7 +16,7 @@ Page({
app.doLogin().then(function (data) { app.doLogin().then(function (data) {
self.setData({ loading: false }) self.setData({ loading: false })
if (data && (data.is_new_user || !data.user_info || !data.user_info.phone)) { if (data && data.is_new_user) {
wx.redirectTo({ url: '/pages/register/register' }) wx.redirectTo({ url: '/pages/register/register' })
} else { } else {
wx.switchTab({ url: '/pages/index/index' }) wx.switchTab({ url: '/pages/index/index' })
+18 -4
查看文件
@@ -18,7 +18,8 @@ Page({
loading: false, loading: false,
avatarUrl: DEFAULT_AVATAR, avatarUrl: DEFAULT_AVATAR,
nickname: '', nickname: '',
phone: '' phone: '',
phoneSkipped: false
}, },
onLoad: function () { onLoad: function () {
@@ -47,10 +48,23 @@ Page({
} }
}, },
onSkipPhone: function () {
var self = this
wx.showModal({
title: '跳过手机号',
content: '跳过后部分功能可能受限,确定跳过吗?',
success: function (res) {
if (res.confirm) {
self.setData({ phoneSkipped: true })
}
}
})
},
onGetPhoneNumber: function (e) { onGetPhoneNumber: function (e) {
var self = this var self = this
if (!e.detail || !e.detail.code) { if (!e.detail || !e.detail.code) {
wx.showToast({ title: '需要授权手机号才能完成注册', icon: 'none' }) wx.showToast({ title: '手机号授权未成功,可跳过此步骤', icon: 'none' })
return return
} }
self.setData({ loading: true }) self.setData({ loading: true })
@@ -96,8 +110,8 @@ Page({
var nickname = (self.data.nickname || '').trim() var nickname = (self.data.nickname || '').trim()
var avatarUrl = self.data.avatarUrl var avatarUrl = self.data.avatarUrl
if (!self.data.phone) { if (!self.data.phone && !self.data.phoneSkipped) {
wx.showToast({ title: '请先授权手机号', icon: 'none' }) wx.showToast({ title: '请先授权手机号,或点击跳过', icon: 'none' })
return return
} }
+9 -1
查看文件
@@ -26,11 +26,19 @@
<text class="phone-text">{{phone}}</text> <text class="phone-text">{{phone}}</text>
</view> </view>
</block> </block>
<block wx:elif="{{phoneSkipped}}">
<view class="phone-done phone-skipped">
<text class="phone-text">已跳过,可稍后在设置中授权</text>
</view>
</block>
<block wx:else> <block wx:else>
<button class="phone-btn" open-type="getPhoneNumber" bindgetphonenumber="onGetPhoneNumber" disabled="{{loading}}"> <button class="phone-btn" open-type="getPhoneNumber" bindgetphonenumber="onGetPhoneNumber" disabled="{{loading}}">
授权手机号 授权手机号
</button> </button>
<view class="phone-hint">手机号用于接收服务通知,必须授权</view> <view class="phone-actions">
<view class="phone-hint">手机号用于接收服务通知</view>
<view class="phone-skip" bindtap="onSkipPhone">跳过</view>
</view>
</block> </block>
</view> </view>
+18 -2
查看文件
@@ -84,11 +84,27 @@
border: none; border: none;
} }
.phone-actions {
display: flex;
justify-content: space-between;
align-items: center;
margin-top: 12rpx;
padding: 0 8rpx;
}
.phone-hint { .phone-hint {
font-size: 24rpx; font-size: 24rpx;
color: #999999; color: #999999;
text-align: center; }
margin-top: 12rpx;
.phone-skip {
font-size: 24rpx;
color: #E6508C;
}
.phone-skipped {
background: #f5f5f5;
border-color: #d9d9d9;
} }
.phone-done { .phone-done {