502 lines
9.0 KiB
Vue
502 lines
9.0 KiB
Vue
<template>
|
||
<view class="content">
|
||
<view class="top">
|
||
<view class="dalan">你好,</view>
|
||
<view class="dalan">欢迎来到机动车救援</view>
|
||
</view>
|
||
|
||
</view>
|
||
</template>
|
||
|
||
<script>
|
||
import request from '../../utils/request';
|
||
import {setToken} from '@/utils/auth.js'
|
||
import { getToken } from '@/utils/auth'
|
||
export default{
|
||
data(){
|
||
return{
|
||
phoneNumber: "",
|
||
shopinfo:0,
|
||
yd:false,
|
||
isButtonDisabled: false,
|
||
countdownTime: 60,
|
||
qh:[
|
||
{text:'密码登录'},
|
||
{text:'验证码登录'},
|
||
// {text:'忘记密码'}
|
||
],
|
||
tel:'',
|
||
yzm:'',
|
||
wrod:'',
|
||
activeid:0
|
||
}
|
||
},
|
||
onLoad() {
|
||
// #ifdef APP-PLUS || H5
|
||
if(getToken()){
|
||
|
||
let info = uni.getStorageSync('userInfo')
|
||
if(info){
|
||
|
||
uni.navigateTo({
|
||
url:'/pages/rescue/rescue'
|
||
})
|
||
}
|
||
else{
|
||
uni.navigateTo({
|
||
url:'/pages/login/login'
|
||
})
|
||
}
|
||
|
||
}else{
|
||
uni.navigateTo({
|
||
// url:'/pages/login/login'
|
||
url: '/pages/rescue/rescue'
|
||
// url: '/pages/rescue/trafficPolice'
|
||
})
|
||
}
|
||
// #endif
|
||
|
||
// #ifdef MP-WEIXIN
|
||
uni.navigateTo({
|
||
url:'/pages/rescue/rescue'
|
||
})
|
||
// #endif
|
||
|
||
|
||
},
|
||
computed: {
|
||
buttonText() {
|
||
if (this.isButtonDisabled) {
|
||
return `${this.countdownTime}s 后重新发送`;
|
||
} else {
|
||
return "获取验证码";
|
||
}
|
||
},
|
||
},
|
||
methods:{
|
||
//登录请求
|
||
getlogin(){
|
||
if(this.yd == false){
|
||
uni.showToast({
|
||
title:'请仔细阅读用户协议与隐私政策!',
|
||
icon:'none'
|
||
})
|
||
return
|
||
}
|
||
if(this.tel == ''){
|
||
uni.showToast({
|
||
title:'输入框不能为空!',
|
||
icon:'none'
|
||
})
|
||
return
|
||
}
|
||
|
||
if(this.activeid == 0){
|
||
const data ={
|
||
username:this.tel,
|
||
password:this.wrod,
|
||
type:0
|
||
}
|
||
request({
|
||
url: '/loginApp',
|
||
method: 'post',
|
||
data: data
|
||
}).then((res)=>{
|
||
console.log('密码请求',res);
|
||
if(res.code == 200){
|
||
setToken(res.token)
|
||
// uni.showToast({
|
||
// title:'登录成功',
|
||
// icon:'none'
|
||
// })
|
||
this.userinfo()
|
||
|
||
}
|
||
})
|
||
|
||
}
|
||
if(this.activeid == 1){
|
||
const data ={
|
||
phone:this.tel,
|
||
code:this.yzm,
|
||
type:1
|
||
}
|
||
request({
|
||
url: '/loginApp',
|
||
method: 'post',
|
||
data: data
|
||
}).then((res)=>{
|
||
console.log('验证码请求',res);
|
||
if(res.code == 200){
|
||
setToken(res.token)
|
||
|
||
this.userinfo()
|
||
|
||
|
||
|
||
}
|
||
})
|
||
}
|
||
},
|
||
userinfo(){
|
||
if(this.shopinfo == 0){
|
||
uni.showLoading({
|
||
title: '加载中'
|
||
});
|
||
console.log('商户');
|
||
request({
|
||
url: '/getJcPartnerInfo',
|
||
method: 'get',
|
||
|
||
}).then((res)=>{
|
||
if(res.code == 500){
|
||
uni.showToast({
|
||
title:"信息有误"
|
||
})
|
||
return
|
||
}
|
||
let userJson = {}
|
||
userJson.userId = res.user.userId
|
||
console.log('身份信息',res);
|
||
uni.setStorageSync('userinfo',res.user)
|
||
this.goselect()
|
||
if(res.code == 200){
|
||
uni.hideLoading();
|
||
this.goselect()
|
||
}
|
||
})
|
||
|
||
}
|
||
if(this.shopinfo == 1){
|
||
uni.showLoading({
|
||
title: '加载中'
|
||
});
|
||
console.log('员工');
|
||
request({
|
||
url: '/getJcWorkerInfo',
|
||
method: 'get',
|
||
|
||
}).then((res)=>{
|
||
let userJson = {}
|
||
userJson.userId = res.user.userId
|
||
console.log('身份信息',res);
|
||
uni.setStorageSync('userinfo',res.user)
|
||
uni.setStorageSync('partnerId',res.partnerInfo.partnerId)
|
||
if(res.code == 200){
|
||
uni.hideLoading();
|
||
uni.navigateTo({
|
||
url:'/pages/staff/staff'
|
||
})
|
||
}
|
||
})
|
||
|
||
}
|
||
|
||
|
||
},
|
||
getxz(index){
|
||
this.activeid = index
|
||
|
||
},
|
||
getxz1(){
|
||
|
||
uni.navigateTo({
|
||
url:'/pages/Login/modify'
|
||
})
|
||
|
||
},
|
||
goregister(){
|
||
uni.navigateTo({
|
||
url:'/pages/login/register'
|
||
})
|
||
},
|
||
goforgot(){
|
||
uni.navigateTo({
|
||
url:'/pages/login/forgot'
|
||
})
|
||
},
|
||
goselect(){
|
||
console.log('执行');
|
||
uni.navigateTo({
|
||
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: 12px;
|
||
height: 30px;
|
||
font-weight: 400;
|
||
color: #0078FF;
|
||
}
|
||
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;
|
||
background: linear-gradient(180deg, rgba(13,46,141,0.2) 0%, rgba(255,255,255,0) 100%);
|
||
}
|
||
|
||
.top{
|
||
box-sizing: border-box;
|
||
padding: 0px 27px;
|
||
padding-top: 100px;
|
||
// background-color:lightseagreen;
|
||
background-image: url('../../static/detection/loginbj.png');
|
||
background-size: cover;
|
||
// background-position: center;
|
||
|
||
width: 100%;
|
||
height: calc(100vh);
|
||
}
|
||
.touxiang{
|
||
width: 88px;
|
||
height: 88px;
|
||
border-radius: 10px;
|
||
background: #D7D7D7;
|
||
margin: 0 auto;
|
||
margin-bottom: 40px;
|
||
overflow: hidden;
|
||
image{
|
||
width: 100%;
|
||
height: 100%;
|
||
}
|
||
}
|
||
.twotap{
|
||
margin-top: 10px;
|
||
width: 100%;
|
||
display: flex;
|
||
align-items: center;
|
||
view{
|
||
font-size: 12px;
|
||
font-family: Microsoft YaHei;
|
||
font-weight: 400;
|
||
color: #666666;
|
||
margin-right: 38.5px;
|
||
}
|
||
}
|
||
.blck{
|
||
color: #333333 !important;
|
||
font-weight: bold !important;
|
||
}
|
||
.inputs{
|
||
height: 54px;
|
||
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: linear-gradient(-46deg, #0853C4 0%, #4282D8 80%);
|
||
border-radius: 5px;
|
||
margin: 0 auto;
|
||
font-size: 16px;
|
||
color: #FFFFFF;
|
||
display: flex;
|
||
justify-content: center;
|
||
align-items: center;
|
||
margin-top: 22px;
|
||
}
|
||
.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{
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
width: 100%;
|
||
text-align: center;
|
||
font-size: 12px;
|
||
color: #333333;
|
||
margin-top: 40px;
|
||
position: fixed;
|
||
bottom: 25px;
|
||
}
|
||
|
||
.lan{
|
||
color: #0D2E8D;
|
||
}
|
||
.box-box{
|
||
width: 95%;
|
||
margin: 20px auto;
|
||
border-radius: 8px;
|
||
overflow: hidden;
|
||
}
|
||
.bb-top{
|
||
height: 65px;
|
||
width: 100%;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
}
|
||
.bb-bai{
|
||
width: 50%;
|
||
height: 100%;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
font-size: 17px;
|
||
font-weight: bold;
|
||
background: #FFFFFF;
|
||
color: #0D2E8D;
|
||
}
|
||
.bb-hui{
|
||
height: 100%;
|
||
width: 50%;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
background: #B5BACA;
|
||
font-size: 17px;
|
||
font-weight: 400;
|
||
color: #FFFFFF;
|
||
}
|
||
.bb-baibox{
|
||
box-sizing: border-box;
|
||
width: 100%;
|
||
padding: 15px;
|
||
background-color: white;
|
||
}
|
||
.anniulanan{
|
||
width: 90%;
|
||
height: 42px;
|
||
margin: 20px auto;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
border-radius: 50px;
|
||
background-color: #0D2E8D;
|
||
color: white;
|
||
}
|
||
.dalan{
|
||
font-size: 25px;
|
||
font-weight: bold;
|
||
color: #0D2E8D;
|
||
margin-left: 10px;
|
||
}
|
||
.axquan{
|
||
width: 14px;
|
||
height: 14px;
|
||
border-radius: 50%;
|
||
border: 1px solid #AAAAAA;
|
||
margin-right: 5px;
|
||
}
|
||
.axquanl{
|
||
width: 14px;
|
||
height: 14px;
|
||
border-radius: 50%;
|
||
border: 1px solid #AAAAAA;
|
||
margin-right: 5px;
|
||
background-color: #0D2E8D;
|
||
}
|
||
|
||
</style>
|