|
|
@@ -31,13 +31,17 @@
|
|
|
<button
|
|
|
class="phone-btn"
|
|
|
:loading="loading"
|
|
|
- open-type="getPhoneNumber"
|
|
|
- @getphonenumber="onGetPhoneNumber"
|
|
|
+ @click="handleWechatLogin"
|
|
|
>
|
|
|
<text>手机号快捷登录</text>
|
|
|
</button>
|
|
|
</view>
|
|
|
|
|
|
+ <!-- 暂不登录 -->
|
|
|
+ <view class="skip-section">
|
|
|
+ <text class="skip-btn" @click="handleSkipLogin">暂不登录,先逛逛</text>
|
|
|
+ </view>
|
|
|
+
|
|
|
<view class="agreement">
|
|
|
<checkbox-group @change="onAgreementChange">
|
|
|
<label>
|
|
|
@@ -63,7 +67,6 @@ export default {
|
|
|
agreed: false,
|
|
|
nickname: '',
|
|
|
avatar: '',
|
|
|
- phoneCode: '',
|
|
|
redirectUrl: ''
|
|
|
}
|
|
|
},
|
|
|
@@ -95,12 +98,9 @@ export default {
|
|
|
url: '/pages/policy/privacy'
|
|
|
})
|
|
|
},
|
|
|
- onGetPhoneNumber(e) {
|
|
|
- if (e.detail && e.detail.code) {
|
|
|
- this.phoneCode = e.detail.code
|
|
|
- }
|
|
|
- // 无论是否授权手机号,都执行微信登录
|
|
|
- this.handleWechatLogin()
|
|
|
+ handleSkipLogin() {
|
|
|
+ // 不登录直接进入首页
|
|
|
+ uni.switchTab({ url: '/pages/index-home/index' })
|
|
|
},
|
|
|
handleWechatLogin() {
|
|
|
if (!this.agreed) {
|
|
|
@@ -125,12 +125,11 @@ export default {
|
|
|
fail: function() { reject(new Error('微信登录失败')) }
|
|
|
})
|
|
|
})]).then(function(loginRes) {
|
|
|
- var phoneCodeToSend = self.phoneCode
|
|
|
- self.phoneCode = '' // 使用后清空
|
|
|
+ // 静默登录:仅获取 openid,不强制索取手机号
|
|
|
wechatLogin(loginRes.code, {
|
|
|
nickname: self.nickname || '用户',
|
|
|
avatar: self.avatar || ''
|
|
|
- }, phoneCodeToSend).then(function(res) {
|
|
|
+ }, '').then(function(res) {
|
|
|
// 保存 token 和用户信息(只写一次)
|
|
|
uni.setStorageSync('token', res.data.token)
|
|
|
uni.setStorageSync('userId', res.data.userId)
|
|
|
@@ -398,6 +397,19 @@ export default {
|
|
|
font-size: 32rpx;
|
|
|
}
|
|
|
|
|
|
+/* ===== 跳过登录 ===== */
|
|
|
+.skip-section {
|
|
|
+ text-align: center;
|
|
|
+ margin-bottom: 20rpx;
|
|
|
+}
|
|
|
+
|
|
|
+.skip-btn {
|
|
|
+ font-size: 28rpx;
|
|
|
+ color: #999;
|
|
|
+ text-decoration: underline;
|
|
|
+ padding: 16rpx 0;
|
|
|
+}
|
|
|
+
|
|
|
.agreement {
|
|
|
margin-top: 16rpx;
|
|
|
text-align: center;
|