|
@@ -59,7 +59,10 @@
|
|
</uni-forms-item>
|
|
</uni-forms-item>
|
|
</uni-forms>
|
|
</uni-forms>
|
|
<view class="quickLogon">
|
|
<view class="quickLogon">
|
|
- <button v-if="showWxLogon" class="wxLogon" type="text" :plain="true" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">微信登录</button>
|
|
|
|
|
|
+ <view v-if="showWxLogon">
|
|
|
|
+ <button v-if="!protocol" class="wxLogon" type="text" :plain="true" @click="showProtocolToast">微信一键登录</button>
|
|
|
|
+ <button v-else class="wxLogon" type="text" :plain="true" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">微信一键登录</button>
|
|
|
|
+ </view>
|
|
<view v-else></view>
|
|
<view v-else></view>
|
|
<view class="register" @tap="handleChangeRegister">还没有登录账户?去注册</view>
|
|
<view class="register" @tap="handleChangeRegister">还没有登录账户?去注册</view>
|
|
</view>
|
|
</view>
|
|
@@ -232,10 +235,13 @@ function handleChangeLogin () {
|
|
changeType.value = 'login'
|
|
changeType.value = 'login'
|
|
}
|
|
}
|
|
|
|
|
|
-const showWxLogon = false
|
|
|
|
|
|
+const showProtocolToast = () => {
|
|
|
|
+ uni.showToast({ title: '请先阅读并同意用户协议和隐私政策', icon: 'none' })
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+const showWxLogon = true
|
|
// 微信登录
|
|
// 微信登录
|
|
const getPhoneNumber = async (e) => {
|
|
const getPhoneNumber = async (e) => {
|
|
- if (!protocol.value) return await uni.showToast({ title: '请先阅读并同意用户协议和隐私政策', icon: 'none' })
|
|
|
|
if (e?.detail?.errMsg !== 'getPhoneNumber:ok') {
|
|
if (e?.detail?.errMsg !== 'getPhoneNumber:ok') {
|
|
uni.showToast({ title: '微信登录失败', icon: 'none' })
|
|
uni.showToast({ title: '微信登录失败', icon: 'none' })
|
|
return
|
|
return
|
|
@@ -245,11 +251,11 @@ const getPhoneNumber = async (e) => {
|
|
success: async (result) => {
|
|
success: async (result) => {
|
|
const wxLoginCode = result?.code || ''
|
|
const wxLoginCode = result?.code || ''
|
|
const query = {
|
|
const query = {
|
|
- wxLoginCode,
|
|
|
|
- iv: e.detail.iv,
|
|
|
|
- encryptedData: e.detail.encryptedData,
|
|
|
|
|
|
+ loginCode: wxLoginCode,
|
|
|
|
+ phoneCode: e.detail.code,
|
|
|
|
+ state: e.detail.encryptedData,
|
|
}
|
|
}
|
|
- await useUserStore.handleSmsLogin(query, current.value === 0)
|
|
|
|
|
|
+ await useUserStore.handleSmsLogin(query, 2)
|
|
},
|
|
},
|
|
fail:(res)=> { console.log("获取登录凭证code失败!", res) }
|
|
fail:(res)=> { console.log("获取登录凭证code失败!", res) }
|
|
})
|
|
})
|
|
@@ -276,7 +282,7 @@ const handleLogin = async () => {
|
|
account: query.phone
|
|
account: query.phone
|
|
})
|
|
})
|
|
|
|
|
|
- await useUserStore.handleSmsLogin(query, current.value === 0)
|
|
|
|
|
|
+ await useUserStore.handleSmsLogin(query, current.value)
|
|
}
|
|
}
|
|
</script>
|
|
</script>
|
|
|
|
|