lanan-app/pages/index/index.vue

529 lines
9.0 KiB
Vue
Raw Normal View History

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