|
@@ -27,6 +27,11 @@
|
|
|
<uni-easyinput placeholder="请输入验证码" v-model="state.sms.code" :inputBorder="false" type="number" maxlength="6"></uni-easyinput>
|
|
|
</uni-forms-item>
|
|
|
</uni-forms>
|
|
|
+ <view>
|
|
|
+ <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>
|
|
|
+
|
|
|
<button class="send-button" @tap="handleLogin"> 登录/注册 </button>
|
|
|
<view class="agreement-box ss-flex ss-row-center">
|
|
|
<uni-icons size="20" :type="protocol ? 'checkbox-filled' : 'circle'" :color="protocol ? '#00897B' : '#ccc'" @tap="protocol = !protocol"></uni-icons>
|
|
@@ -129,6 +134,32 @@ const handleLogin = async () => {
|
|
|
}
|
|
|
await useUserStore.handleShareUserRegister(state.value.sms)
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+const showProtocolToast = () => {
|
|
|
+ uni.showToast({ title: '请先阅读并同意用户协议和隐私政策', icon: 'none' })
|
|
|
+}
|
|
|
+
|
|
|
+// 微信登录
|
|
|
+const getPhoneNumber = async (e) => {
|
|
|
+ if (e?.detail?.errMsg !== 'getPhoneNumber:ok') {
|
|
|
+ uni.showToast({ title: '微信登录失败', icon: 'none' })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ changeType.value = 'login'
|
|
|
+ wx.login({
|
|
|
+ success: async (result) => {
|
|
|
+ const wxLoginCode = result?.code || ''
|
|
|
+ const query = {
|
|
|
+ loginCode: wxLoginCode,
|
|
|
+ phoneCode: e.detail.code,
|
|
|
+ state: e.detail.encryptedData,
|
|
|
+ }
|
|
|
+ await useUserStore.handleSmsLogin(query, 2)
|
|
|
+ },
|
|
|
+ fail:(res)=> { console.log("获取登录凭证code失败!", res) }
|
|
|
+ })
|
|
|
+}
|
|
|
</script>
|
|
|
|
|
|
<style scoped lang="scss">
|
|
@@ -148,4 +179,15 @@ const handleLogin = async () => {
|
|
|
text-align: center;
|
|
|
color: #00897B;
|
|
|
}
|
|
|
+.wxLogon {
|
|
|
+ text-align: center;
|
|
|
+ font-size: .85em;
|
|
|
+ color: #00897B;
|
|
|
+ border: none;
|
|
|
+ margin: 0;
|
|
|
+ padding: 0;
|
|
|
+ // margin: 40rpx;
|
|
|
+ margin-top: -20px;
|
|
|
+ margin-bottom: -15px;
|
|
|
+}
|
|
|
</style>
|