lanan-repair/pages/login/login.vue
2024-09-28 00:17:38 +08:00

535 lines
11 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<view class="content">
<view class="kuang">
<view class="land">您好</view>
<view class="land">欢迎登录智修小助手</view>
</view>
<view class="xiaoannoi">
<u-button v-if="privacyPolicyChecked == true" text="手机号快捷登录" class="dl" :customStyle="{color:'#ffffff'}"
color="#0D2E8D" open-type='getPhoneNumber'
@getphonenumber="getPhone"></u-button>
<u-button v-else text="手机号快捷登录" class="dl" :customStyle="{color:'#ffffff'}"
color="#0D2E8D" @click="shibai()" ></u-button>
</view>
<view class="dbottom">
<view class="axquan" v-if="privacyPolicyChecked == false" @click="privacyPolicyChecked = true"></view>
<view class="axquanl" v-if="privacyPolicyChecked == true" @click="privacyPolicyChecked = false">
<uni-icons type="checkmarkempty" color="#ffffff" size="14"></uni-icons>
</view>
<text>请您认真阅读</text>
<text class="lan" @click="goPolicy()">《用户协议》</text>
<text>和</text>
<text class="lan" @click="goPolicy()">《隐私政策》</text>
</view>
</view>
</template>
<script>
import request from '../../utils/request';
import {setToken} from '@/utils/auth.js'
export default{
data(){
return{
yd : false,
shenfen:'jcyh',
show:false,
baseUrl:this.$baseUrl,
privacyPolicyChecked:false,
phoneNumber: "",
isButtonDisabled: false,
countdownTime: 60,
qh:[
{text:'密码登录'},
{text:'验证码登录'}
],
columns: [
['用户','代办' ]
],
tel:'',
yzm:'',
wrod:'',
activeid:0
}
},
onLoad() {
this.wxlogin()
},
computed: {
buttonText() {
if (this.isButtonDisabled) {
return `${this.countdownTime}s 后重新发送`;
} else {
return "获取验证码";
}
},
},
methods:{
async getsxshenfen(){
let data = {
roleCode : this.shenfen
}
let res = await request({
url:'/appInspection/userOwn/updateRole',
method:'post',
params: data
})
if(res.code == 200){
uni.redirectTo({
url: '/pages/detection/my'
})
}
},
getshenfen(text){
this.shenfen = text
},
open() {
// console.log('open');
},
close() {
// this.show = false
// uni.reLaunch({
// url: '/pages/detection/my'
// })
// // console.log('close');
},
goPolicy() {
uni.navigateTo({
url: "/pages/login/PrivacyPolicy"
})
},
wxlogin() {
uni.login({
provider: 'weixin',
success(res) {
console.log(543, res);
if (res.code) {
uni.setStorageSync('c1', res.code);
} else {
console.log('登录失败!' + res.errMsg)
}
}
})
},
async getAppinfo(){
let res = await request({
url:'/getAppInfo',
method:'get',
})
console.log('getappinfo',res);
},
//授权
authorize() {
uni.showToast({
icon: "none",
title: "请阅读并勾选用户协议",
duration: 2000
})
},
shibai(){
uni.showToast({
icon: "none",
title: "请阅读并勾选用户协议",
duration: 2000
})
},
getPhone(e) {
console.log('执行了');
if (this.privacyPolicyChecked == false) {
uni.showToast({
icon: "none",
title: "请阅读并勾选用户协议",
duration: 2000
})
return;
}
uni.checkSession({
success: () => {
uni.request({
url: this.baseUrl + "/userClient/repair/wxLogin",
method: "POST",
data: {
code: uni.getStorageSync('c1'),
encryptedIv: e.detail.iv,
encryptedData: e.detail.encryptedData,
inviteId: uni.getStorageSync('inviteId') ? uni.getStorageSync('inviteId') : null
},
success: (rex) => {
if (rex.data.code == 0) {
//设置token
setToken(rex.data.data.token)
if (rex.data.data.ifNeedFill) {
uni.reLaunch({
url: '/pages/my/register'
})
} else {
uni.reLaunch({
url: '/pages-home/home/home'
})
}
} else {
uni.showToast({
icon: 'none',
title: '登录失败,请联系管理人员'
})
}
},
fail: (res) => {
console.log("fail", res);
uni.showToast({
icon: "error",
title: "登录失败,请重新点击并授权!",
duration: 2000
})
}
})
},
fail: () => {
uni.showToast({
icon: 'error',
duration: 2000,
title: "登录状态过期,重新登录"
});
}
})
},
userinfo(){
console.log('执行了');
request({
url: '/getAppInfo',
method: 'get',
}).then((res)=>{
let userJson = {}
userJson.userId = res.user.userId
console.log('身份信息',res,res.role.length);
uni.setStorageSync('role',res.role)
uni.setStorageSync('userinfo',res.user)
if(!res.role||res.role.length==0){
this.show = true
}else{
uni.reLaunch({
url: '/pages/detection/my'
})
}
})
},
getxz(index){
this.activeid = index
},
goregister(){
uni.redirectTo({
url:'/pages/login/register'
})
},
goforgot(){
uni.redirectTo({
url:'/pages/login/forgot'
})
},
goselect(){
console.log('执行');
uni.redirectTo({
url:'/pages/index/index'
})
},
// 验证码方法
sendVerificationCode() {
let reg = /^((13[0-9])|(14[0-9])|(15[0-9])|(17[0-9])|(18[0-9]))\d{8}$/;
if (!reg.test(this.tel)) {
uni.showToast({
icon: 'none',
title: '请输入正确的11位手机号'
})
this.tel = '';
return false;
}
if (this.isButtonDisabled) {
return; // 如果按钮已禁用,则直接返回
}
const data = {
phone:this.tel,
}
request({
url: '/loginSmsCode',
method: 'post',
params: data
}).then((res)=>{
console.log('验证码',res);
if(res.code == 200){
uni.showToast({
title:'验证码已发送 请注意查收',
icon:'none'
})
}else{
uni.showToast({
title:'网络不佳请稍后再试',
icon:'none'
})
}
})
this.disableButton(); // 禁用按钮
this.startCountdown(); // 启动倒计时
},
disableButton() {
this.isButtonDisabled = true;
},
enableButton() {
this.isButtonDisabled = false;
},
startCountdown() {
let countdown = setInterval(() => {
this.countdownTime--;
if (this.countdownTime === 0) {
clearInterval(countdown);
this.enableButton(); // 启用按钮
}
}, 1000);
},
}
}
</script>
<style scoped lang="scss">
.jsq{
border: none !important;
font-size: 14px;
font-weight: 400;
color: #0078FF;
}
.anniu{
width: 150px;
height: 40px;
border-radius: 50px;
display: flex;
align-items: center;
justify-content: center;
color: white;
background: #0D2E8D;
color: #FFFFFF;
margin: 0 auto;
}
.cont-popup{
height: 250px;
width: 300px;
background-color: #FFFFFF;
box-sizing: border-box;
padding: 15px;
border-radius: 10px;
}
.popup-title{
width: 100%;
display: flex;
align-items: center;
justify-content: center;
font-size: 18px;
font-weight: bold;
color: #0D2E8D;
}
.dix{
width: 100%;
display: flex;
align-items: center;
justify-content: space-between;
margin: 20px 0px;
font-size: 18px;
font-weight: bold;
}
.lqiu{
width: 15px;
height: 15px;
border-radius: 50%;
border: 1px solid #0D2E8D;
background: #0D2E8D;
color: white;
display: flex;
align-items: center;
justify-content: center;
}
.qiu{
width: 15px;
height: 15px;
border-radius: 50%;
border: 1px solid #E8E8E8;
}
button {
border: none !important;
background: none !important;
margin: 0px;
display: block;
}
button:focus {
color: #0078FF;
outline: none;
box-shadow: none;
}
.content{
box-sizing: border-box;
padding-top: 1px;
background-image: url('http://www.nuoyunr.com/lananRsc/jdc-bj.png');
background-size: cover;
width: 100%;
height: calc(100vh);
}
.top{
box-sizing: border-box;
padding: 0px 27px;
padding-top: 100px;
// background-color:lightseagreen;
background-position: center;
width: 100%;
// height: 385px;
}
.touxiang{
width: 88px;
height: 88px;
border-radius: 10px;
background: #D7D7D7;
margin: 0 auto;
margin-bottom: 40px;
overflow: hidden;
image{
width: 100%;
height: 100%;
}
}
.twotap{
width: 100%;
display: flex;
align-items: center;
view{
font-size: 15px;
font-family: Microsoft YaHei;
font-weight: 400;
color: #666666;
margin-right: 38.5px;
}
}
.blck{
color: #333333 !important;
font-weight: bold !important;
}
.inputs{
box-sizing: border-box;
padding: 16px 0px;
display: flex;
align-items: center;
border-bottom: 2px solid #E8E8E8 ;
margin-top: 20px;
}
.wjworb{
margin-top: 5px;
width: 100%;
display: flex;
font-size: 12px;
color: #0078FF;
justify-content: flex-end;
align-items: center;
}
.dl{
width: 90%;
height: 44px;
background-color: #0D2E8D;
border-radius: 50px;
margin: 0 auto;
font-size: 16px;
color: #FFFFFF;
display: flex;
justify-content: center;
align-items: center;
margin-top: 300px;
}
.xiaoannoi{
width: 90%;
height: 40px;
margin: 0 auto;
border-radius: 50px;
overflow: hidden;
margin-top: 300px;
}
.hging{
width: 100%;
text-align: center;
font-size: 14px;
font-weight: 400;
color: #636363;
margin-top: 20px;
}
.wx{
width: 38px;
height: 38px;
overflow: hidden;
box-sizing: border-box;
margin: 0px auto;
margin-top: 20px;
image{
width: 100%;
height: 100%;
}
}
.hui{
font-size: 10px;
width: 100%;
text-align: center;
font-weight: 400;
color: #666666;
}
.dbottom{
width: 100%;
text-align: center;
font-size: 12px;
color: #333333;
margin-top: 40px;
position: fixed;
bottom: 25px;
display: flex;
justify-content: center;
align-items: center;
}
.lan{
color: #0D2E8D;
}
.land{
font-size: 25px;
font-weight: bold;
color: #0D2E8D;
margin-bottom: 5px;
}
.kuang{
width: 90%;
margin: 0 auto;
margin-top: 100px;
}
.axquan{
width: 18px;
height: 18px;
border-radius: 50%;
border: 1px solid #AAAAAA;
margin-right: 5px;
}
.axquanl{
width: 18px;
height: 18px;
border-radius: 50%;
border: 1px solid #AAAAAA;
margin-right: 5px;
background-color: #0D2E8D;
}
</style>