|
@@ -2,7 +2,7 @@
|
|
|
<view class="app-login-page">
|
|
|
<view class="app-login">
|
|
|
<view class="app-icon mb-30">
|
|
|
- <image src="https://sylwt.top/api/visitor/resources/image?name=/ydl/menber-center/login-icon.png"
|
|
|
+ <image :src="`${FILE_URL}/login-icon.png`"
|
|
|
mode="aspectFit" style="height: 40px;"></image>
|
|
|
</view>
|
|
|
<view class="app-title mb-30">
|
|
@@ -57,14 +57,22 @@
|
|
|
<u-checkbox v-model="userBook" name="yes" shape="circle">我已阅读《用户手册》及隐私政策</u-checkbox>
|
|
|
</u-checkbox-group>
|
|
|
</view>
|
|
|
- <!-- <u-divider bg-color="transparent" margin-bottom="30" color="#010101" border-color="#010101"
|
|
|
- half-width="200">使用第三方账号登录</u-divider> -->
|
|
|
- <!-- <view class="app-icon mb-30">
|
|
|
- <u-button @click="handleWxLogin()" class="custom-button" style="width: 40px;" plain :hair-line="false">
|
|
|
- <image src="https://sylwt.top/api/visitor/resources/image?name=/ydl/menber-center/weixin.png"
|
|
|
+ <u-divider bg-color="transparent" margin-bottom="30" color="#010101" border-color="#010101"
|
|
|
+ half-width="200">使用第三方账号登录</u-divider>
|
|
|
+ <view class="app-icon mb-30">
|
|
|
+ <!-- <u-button @click="handleWxLogin()" class="custom-button" style="width: 40px;" plain :hair-line="false">
|
|
|
+ <image :src="`${FILE_URL}/weixin.png`"
|
|
|
+ mode="aspectFit" style="width: 40px;height: 40px;" />
|
|
|
+ </u-button> -->
|
|
|
+ <u-button v-if="userBook" open-type="getPhoneNumber" @getphonenumber="decryptPhoneNumber" class="custom-button" style="width: 40px;" plain :hair-line="false">
|
|
|
+ <image :src="`${FILE_URL}/weixin.png`"
|
|
|
+ mode="aspectFit" style="width: 40px;height: 40px;" />
|
|
|
+ </u-button>
|
|
|
+ <u-button v-else class="custom-button" style="width: 40px;" plain :hair-line="false" @click="checkBook">
|
|
|
+ <image :src="`${FILE_URL}/weixin.png`"
|
|
|
mode="aspectFit" style="width: 40px;height: 40px;" />
|
|
|
</u-button>
|
|
|
- </view> -->
|
|
|
+ </view>
|
|
|
</view>
|
|
|
<u-verification-code :seconds="seconds" ref="uCode1" @change="codeChange"></u-verification-code>
|
|
|
<u-popup v-model="show" mode="center" border-radius="10">
|
|
@@ -90,6 +98,13 @@
|
|
|
<text class="content-a">《用户手册》及隐私政策</text>
|
|
|
</view>
|
|
|
</u-modal>
|
|
|
+ <u-modal v-model="weixinUserBookModal" mask-close-able class="modal" show-cancel-button
|
|
|
+ :title-style="{fontWeight: 'bold'}" @confirm="confirmModalWeixin">
|
|
|
+ <view class="modal-content">
|
|
|
+ 为了更好地保障你的合法权益,进行下一步前,请阅读并同意
|
|
|
+ <text class="content-a">《用户手册》及隐私政策</text>
|
|
|
+ </view>
|
|
|
+ </u-modal>
|
|
|
</view>
|
|
|
</template>
|
|
|
|
|
@@ -100,7 +115,7 @@
|
|
|
checknumberCaptcha,
|
|
|
smsSend,
|
|
|
loginPhone,
|
|
|
- wxLoginOpenid
|
|
|
+ wxLoginOpenid, wxloginPhone
|
|
|
} from "@/api/login.js"
|
|
|
import {
|
|
|
msg,
|
|
@@ -112,13 +127,16 @@
|
|
|
import {
|
|
|
encryptAESCBC
|
|
|
} from "@/utils/crypto.js"
|
|
|
+ import configService from '@/utils/baseurl.js'
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
|
+ FILE_URL: configService.FILE_URL,
|
|
|
getPhoneCapt: 0,
|
|
|
canIUseGetUserProfile: false,
|
|
|
loginCode: '',
|
|
|
userBookModal: false,
|
|
|
+ weixinUserBookModal: false,
|
|
|
// ----验证码 start -----
|
|
|
numberCaptchaForm: {
|
|
|
numberCaptcha: '',
|
|
@@ -151,6 +169,13 @@
|
|
|
}
|
|
|
return true
|
|
|
},
|
|
|
+ checkWeixinUserBook(){
|
|
|
+ if (!this.userBook) {
|
|
|
+ this.weixinUserBookModal = true
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return true
|
|
|
+ },
|
|
|
// 用户手册模拟态确认勾选
|
|
|
confirmModal() {
|
|
|
this.userBook = true;
|
|
@@ -161,6 +186,9 @@
|
|
|
// 调用相应的登录处理函数
|
|
|
(loginTypeHandler[this.loginType] || (() => {})).call(this);
|
|
|
},
|
|
|
+ confirmModalWeixin() {
|
|
|
+ this.userBook = true;
|
|
|
+ },
|
|
|
// 手机登录
|
|
|
async phoneLoginHandle() {
|
|
|
const {
|
|
@@ -308,7 +336,7 @@
|
|
|
this.closePopup();
|
|
|
this.$refs.uCode1.start()
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
uni.hideLoading();
|
|
|
},
|
|
|
// 加载验证码图片
|
|
@@ -335,8 +363,8 @@
|
|
|
const { openid, sessionKey } = res.data
|
|
|
}
|
|
|
})
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
// try {
|
|
|
// // 获取code
|
|
|
// const code = loginRes.code;
|
|
@@ -348,15 +376,52 @@
|
|
|
// console.log('微信登录失败:', error);
|
|
|
// }
|
|
|
},
|
|
|
- decryptPhoneNumber(e) {
|
|
|
- console.log(1111, e)
|
|
|
+ async checkBook(){
|
|
|
+ let checkUserBook = await this.checkWeixinUserBook()
|
|
|
+ if (!this.checkWeixinUserBook()) {
|
|
|
+ return;
|
|
|
+ };
|
|
|
+ },
|
|
|
+ async decryptPhoneNumber(e){
|
|
|
if (e.detail.encryptedData) {
|
|
|
const {
|
|
|
encryptedData,
|
|
|
iv,
|
|
|
code
|
|
|
} = e.detail;
|
|
|
- console.log(code)
|
|
|
+ const loginRes = await wx.login();
|
|
|
+ const wxcode = loginRes.code;
|
|
|
+ try{
|
|
|
+ const openidRes = await wxLoginOpenid({code : wxcode})
|
|
|
+ if(openidRes?.data){
|
|
|
+ const { openid, sessionKey } = openidRes.data
|
|
|
+ const phoneRes = await wxloginPhone({ openid, phoneCode: code})
|
|
|
+ const { phone, token, isNewUser } = phoneRes.data;
|
|
|
+ this.useAuthStore.setPhone(phone);
|
|
|
+ this.useAuthStore.setAuthToken(token);
|
|
|
+ // uni.reLaunch({
|
|
|
+ // url: "/pages/register/register?mode=refine"
|
|
|
+ // })
|
|
|
+ if(isNewUser){
|
|
|
+ //新用户,跳转:完善用户信息
|
|
|
+ // console.log("完善用户信息")
|
|
|
+ uni.reLaunch({
|
|
|
+ url: "/pages/register/register?mode=refine"
|
|
|
+ })
|
|
|
+ }else{
|
|
|
+ // 老用户,跳转至:首页
|
|
|
+ msgSuccess("授权成功!")
|
|
|
+ setTimeout(()=>{
|
|
|
+ uni.switchTab({
|
|
|
+ url: "/pages/index/index"
|
|
|
+ })
|
|
|
+ }, 1000)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }catch(err){
|
|
|
+ console.log("ee", err)
|
|
|
+ }
|
|
|
+
|
|
|
// 将 encryptedData 和 iv 发送到后端进行解密
|
|
|
} else {
|
|
|
msg('取消授权手机号');
|
|
@@ -555,4 +620,4 @@
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-</style>
|
|
|
+</style>
|