|
@@ -40,7 +40,8 @@
|
|
|
</view>
|
|
|
<view class="form-item">
|
|
|
<u-input height="80" placeholder="请输入密码" border-color="#d0d0d0" v-model="userNameForm.password"
|
|
|
- :border="true" class="form-item-input" @confirm="userNameLoginHandle" type="password" password-icon/>
|
|
|
+ :border="true" class="form-item-input" @confirm="userNameLoginHandle" type="password"
|
|
|
+ password-icon />
|
|
|
</view>
|
|
|
<view class="form-button" @click="userNameLoginHandle">
|
|
|
立即登录
|
|
@@ -60,19 +61,17 @@
|
|
|
half-width="200">使用第三方账号登录</u-divider>
|
|
|
<view class="app-icon mb-30">
|
|
|
<!-- v-if="canIUseGetUserProfile" -->
|
|
|
- <u-button @click="getUserProfile" class="custom-button"
|
|
|
- style="width: 40px;" plain :hair-line="false">
|
|
|
+ <!-- <u-button @click="getUserProfile" 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"
|
|
|
mode="aspectFit" style="width: 40px;height: 40px;" />
|
|
|
- </u-button>
|
|
|
+ </u-button> -->
|
|
|
<!-- v-else -->
|
|
|
- <u-button open-type="getPhoneNumber" @getphonenumber="decryptPhoneNumber" class="custom-button"
|
|
|
+ <!-- <u-button open-type="getPhoneNumber" @getphonenumber="decryptPhoneNumber" 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"
|
|
|
mode="aspectFit" style="width: 40px;height: 40px;" />
|
|
|
- </u-button>
|
|
|
- <u-button @click="handleWxLogin()" class="custom-button"
|
|
|
- style="width: 40px;" plain :hair-line="false">
|
|
|
+ </u-button> -->
|
|
|
+ <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"
|
|
|
mode="aspectFit" style="width: 40px;height: 40px;" />
|
|
|
</u-button>
|
|
@@ -113,7 +112,8 @@
|
|
|
getCaptchaImage,
|
|
|
checknumberCaptcha,
|
|
|
smsSend,
|
|
|
- loginPhone
|
|
|
+ loginPhone,
|
|
|
+ wxLoginOpenid
|
|
|
} from "@/api/user.js"
|
|
|
import {
|
|
|
msg,
|
|
@@ -180,49 +180,40 @@
|
|
|
phone,
|
|
|
captcha
|
|
|
} = this.phoneForm;
|
|
|
-
|
|
|
+
|
|
|
// 手机号正则验证
|
|
|
if (!/^1[3-9]\d{9}$/.test(phone)) {
|
|
|
msg("请输入正确的手机号");
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
- if(this.getPhoneCapt <= 0){
|
|
|
+
|
|
|
+ if (this.getPhoneCapt <= 0) {
|
|
|
msg("请先获取手机验证码");
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 验证码存在性检查
|
|
|
if (!captcha) {
|
|
|
msg("请输入验证码");
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
let checkUserBook = await this.checkUserBook()
|
|
|
if (!this.checkUserBook()) return;
|
|
|
- // console.log(this.phoneForm)
|
|
|
uni.showLoading({
|
|
|
title: '正在登录...'
|
|
|
})
|
|
|
- loginPhone(this.phoneForm).then(res=>{
|
|
|
- // msg("登录成功");
|
|
|
- console.log(res);
|
|
|
+ loginPhone(this.phoneForm).then(res => {
|
|
|
+ if (res.data.token) {
|
|
|
+ msgSuccess("登录成功!")
|
|
|
+ this.useAuthStore.setAuthToken(res.data.token)
|
|
|
+ setTimeout(() => {
|
|
|
+ uni.switchTab({
|
|
|
+ url: "/pages/index/index"
|
|
|
+ })
|
|
|
+ }, 1000)
|
|
|
+ }
|
|
|
})
|
|
|
- // 联调
|
|
|
- // 1.登录 发送请求
|
|
|
- // 2.保存 token
|
|
|
- // 3.获取个人信息,保存个人新
|
|
|
- msg("登录成功");
|
|
|
- // setTimeout(() => {
|
|
|
- // this.useAuthStore.setAuthToken("test")
|
|
|
- // uni.setStorageSync("userinfo", {
|
|
|
- // userId: "2121",
|
|
|
- // isMember: true
|
|
|
- // })
|
|
|
- // uni.switchTab({
|
|
|
- // url: "/pages/index/index"
|
|
|
- // })
|
|
|
- // }, 1000)
|
|
|
|
|
|
},
|
|
|
// 账号登录
|
|
@@ -309,9 +300,9 @@
|
|
|
uni.showLoading({
|
|
|
title: '正在校验验证码'
|
|
|
})
|
|
|
-
|
|
|
+
|
|
|
const checkRes = await checknumberCaptcha(this.numberCaptchaForm);
|
|
|
- if(!checkRes.data.valid){
|
|
|
+ if (!checkRes.data.valid) {
|
|
|
uni.showToast({
|
|
|
title: '验证码输入错误',
|
|
|
icon: 'none'
|
|
@@ -322,14 +313,15 @@
|
|
|
const codeRes = await smsSend({
|
|
|
phone: this.phoneForm.phone
|
|
|
});
|
|
|
-
|
|
|
- if(codeRes && codeResdata.captchaUuid){
|
|
|
+
|
|
|
+ if (codeRes && codeRes.data.captchaUuid) {
|
|
|
this.getPhoneCapt++;
|
|
|
- this.phoneForm.captchaUuid = codeRes.captchaUuid
|
|
|
+ this.phoneForm.captchaUuid = codeRes.data.captchaUuid
|
|
|
+ // console.log(this.phoneForm)
|
|
|
this.closePopup();
|
|
|
this.$refs.uCode1.start()
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
uni.hideLoading();
|
|
|
},
|
|
|
// 加载验证码图片
|
|
@@ -339,29 +331,37 @@
|
|
|
title: '正在获取图片'
|
|
|
})
|
|
|
const img = await getCaptchaImage();
|
|
|
- if(!img.data.numberCaptchaSrc){
|
|
|
+ if (!img.data.numberCaptchaSrc) {
|
|
|
return
|
|
|
}
|
|
|
this.numberCaptchaForm.numberCaptchaUuid = img.data.numberCaptchaUuid
|
|
|
this.numberCaptchaSrc = img.data.numberCaptchaSrc;
|
|
|
uni.hideLoading();
|
|
|
},
|
|
|
-
|
|
|
+
|
|
|
// --------验证码 end---------
|
|
|
async handleWxLogin() {
|
|
|
- try {
|
|
|
- // 获取code
|
|
|
- const loginRes = await uni.login({
|
|
|
- provider: 'weixin'
|
|
|
- });
|
|
|
- const code = loginRes.code;
|
|
|
- console.log(11, loginRes);
|
|
|
- } catch (error) {
|
|
|
- console.error('微信登录失败:', error);
|
|
|
- }
|
|
|
+ const loginRes = await wx.login();
|
|
|
+ const code = loginRes.code;
|
|
|
+ console.log("最新code", code)
|
|
|
+ wxLoginOpenid({code}).then(res=>{
|
|
|
+ console.log("weixinlogin", res)
|
|
|
+ })
|
|
|
+
|
|
|
+
|
|
|
+ // try {
|
|
|
+ // // 获取code
|
|
|
+ // const code = loginRes.code;
|
|
|
+ // console.log(code)
|
|
|
+ // wxLoginOpenid({code}).then(res=>{
|
|
|
+ // console.log("weixinlogin", res)
|
|
|
+ // })
|
|
|
+ // } catch (error) {
|
|
|
+ // console.log('微信登录失败:', error);
|
|
|
+ // }
|
|
|
},
|
|
|
decryptPhoneNumber(e) {
|
|
|
- console.log(1111,e)
|
|
|
+ console.log(1111, e)
|
|
|
if (e.detail.encryptedData) {
|
|
|
const {
|
|
|
encryptedData,
|