detection-business/pages/Login/login.vue

628 lines
13 KiB
Vue
Raw Normal View History

2024-09-11 15:55:28 +08:00
<template>
<view class="content">
<view class="top">
2025-04-30 15:05:20 +08:00
<!-- <view class="touxiang">
2024-09-11 15:55:28 +08:00
<image src="../../static/logo.png" mode=""></image>
</view> -->
<view class="dalan">你好</view>
<view class="dalan">欢迎登陆商户端</view>
2024-11-11 13:18:56 +08:00
2024-09-11 15:55:28 +08:00
<view class="box-box">
<!-- <view class="bb-top" v-if="shopinfo == 0" @click="shopinfo = 1">
<view class="bb-bai">
<text>商户登录</text>
</view>
<view class="bb-hui">
<text>员工登录</text>
</view>
</view>
<view class="bb-top" v-if="shopinfo == 1" @click="shopinfo = 0">
<view class="bb-hui">
<text>商户登录</text>
</view>
<view class="bb-bai">
<text>员工登录</text>
</view>
</view> -->
2025-04-30 15:05:20 +08:00
<view class="bb-top">
2024-09-11 15:55:28 +08:00
<view class="bb-bai" :class="{'shendu' : shopinfo == 0}" @click="shopinfo = 0">
<text>商户登录</text>
</view>
2025-04-30 15:05:20 +08:00
<view class="bb-bai" :class="{'shendu' : shopinfo == 1}" @click="shopinfo = 1">
2024-09-11 15:55:28 +08:00
<text>官方登录</text>
</view>
2025-04-30 15:05:20 +08:00
<view class="bb-bai" :class="{'shendu' : shopinfo == 2}" @click="shopinfo = 2">
2024-09-11 15:55:28 +08:00
<text>员工登录</text>
</view>
2025-06-10 17:53:26 +08:00
<view class="bb-bai" :class="{'shendu' : shopinfo == 3}" @click="shopinfo = 3">
<text>业务登录</text>
</view>
2024-11-11 13:18:56 +08:00
2024-09-11 15:55:28 +08:00
</view>
<view class="bb-baibox">
2025-04-30 15:05:20 +08:00
<view class="inputs" v-if="activeid == 0">
2024-09-11 15:55:28 +08:00
<input type="text" v-model="tel" placeholder="请输入手机号">
</view>
2025-04-30 15:05:20 +08:00
<view class="inputs" v-if="activeid == 1">
2024-09-11 15:55:28 +08:00
<input type="text" v-model="tel" placeholder="请输入手机号">
</view>
2025-04-30 15:05:20 +08:00
<view class="inputs" style="justify-content: space-between; " v-if="activeid == 1">
2024-09-11 15:55:28 +08:00
<input type="text" v-model="yzm" placeholder="请输入验证码">
2025-04-30 15:05:20 +08:00
<button class="jsq" :disabled="isButtonDisabled"
@click="sendVerificationCode">{{ buttonText }}</button>
2024-09-11 15:55:28 +08:00
</view>
<view class="inputs" v-if="activeid == 0">
2025-04-30 15:05:20 +08:00
<input type="password" v-model="wrod" placeholder="请输入密码">
2024-09-11 15:55:28 +08:00
</view>
2025-04-30 15:05:20 +08:00
<view class="twotap">
<view :class="{'blck':activeid == index}" v-for="(item,index) in qh " :key="index"
@click="getxz(index)">{{item.text}}</view>
<view @click="getxz1()">忘记密码</view>
2024-09-11 15:55:28 +08:00
</view>
<view class="anniulanan" @click="getlogin()">
<text>登录</text>
</view>
</view>
</view>
2024-11-11 13:18:56 +08:00
2024-09-11 15:55:28 +08:00
</view>
2024-11-11 13:18:56 +08:00
2024-09-11 15:55:28 +08:00
<view class="dbottom">
2025-04-30 15:05:20 +08:00
<view class="axquan" v-if="yd == false" @click="yd = true"></view>
2024-09-11 15:55:28 +08:00
<view class="axquanl" v-if="yd == true" @click="yd = false">
<uni-icons type="checkmarkempty" color="#ffffff" size="14"></uni-icons>
</view>
<text>请您认真阅读</text>
<text class="lan">用户协议</text>
<text></text>
<text class="lan">隐私政策</text>
</view>
</view>
</template>
<script>
import request from '../../utils/request';
import {
2025-04-30 15:05:20 +08:00
setToken,
setTenantId,
getToken
} from '@/utils/auth.js'
import {
getTenantIdByWebsite
2024-09-11 15:55:28 +08:00
} from '@/api/login.js'
2025-04-30 15:05:20 +08:00
export default {
data() {
return {
2024-09-11 15:55:28 +08:00
phoneNumber: "",
2025-04-30 15:05:20 +08:00
shopinfo: 0,
yd: false,
2024-09-11 15:55:28 +08:00
isButtonDisabled: false,
countdownTime: 60,
2025-04-30 15:05:20 +08:00
qh: [{
text: '密码登录'
},
{
text: '验证码登录'
},
2024-09-11 15:55:28 +08:00
// {text:'忘记密码'}
],
2025-04-30 15:05:20 +08:00
tel: '',
yzm: '',
wrod: '',
activeid: 0,
tenantCode: 'lanan'
2024-09-11 15:55:28 +08:00
}
},
2025-04-30 15:05:20 +08:00
mounted() {
getTenantIdByWebsite(this.tenantCode).then(res => {
const tenantId = res.data;
if (tenantId && tenantId >= 0) {
setTenantId(tenantId)
}
})
2024-09-11 15:55:28 +08:00
},
onLoad() {
2024-10-23 16:53:40 +08:00
2024-09-11 15:55:28 +08:00
},
computed: {
2025-04-30 15:05:20 +08:00
buttonText() {
if (this.isButtonDisabled) {
return `${this.countdownTime}s 后重新发送`;
} else {
return "获取验证码";
}
},
},
methods: {
2024-09-11 15:55:28 +08:00
//登录请求
2025-04-30 15:05:20 +08:00
getlogin() {
if (this.yd == false) {
2024-09-11 15:55:28 +08:00
uni.showToast({
2025-04-30 15:05:20 +08:00
title: '请仔细阅读用户协议与隐私政策!',
icon: 'none'
2024-09-11 15:55:28 +08:00
})
return
}
2025-04-30 15:05:20 +08:00
if (this.tel == '') {
2024-09-11 15:55:28 +08:00
uni.showToast({
2025-04-30 15:05:20 +08:00
title: '输入框不能为空!',
icon: 'none'
2024-09-11 15:55:28 +08:00
})
return
}
2024-11-11 13:18:56 +08:00
2025-04-30 15:05:20 +08:00
if (this.activeid == 0) {
const data = {
username: this.tel,
password: this.wrod,
type: 0
2024-09-11 15:55:28 +08:00
}
request({
2024-09-18 19:09:42 +08:00
url: '/rescue/loginJcApp',
2024-09-11 15:55:28 +08:00
method: 'post',
data: data
2025-04-30 15:05:20 +08:00
}).then((res) => {
if (res.code == 200) {
2024-09-11 15:55:28 +08:00
setToken(res.data.accessToken)
this.userinfo()
2024-11-11 13:18:56 +08:00
2024-09-11 15:55:28 +08:00
}
})
2024-11-11 13:18:56 +08:00
2024-09-11 15:55:28 +08:00
}
2025-04-30 15:05:20 +08:00
if (this.activeid == 1) {
const data = {
phone: this.tel,
code: this.yzm,
type: 1
2024-09-11 15:55:28 +08:00
}
request({
url: '/rescue/loginApp',
method: 'post',
data: data
2025-04-30 15:05:20 +08:00
}).then((res) => {
if (res.code == 200) {
2024-09-11 15:55:28 +08:00
setToken(res.data.accessToken)
2024-11-11 13:18:56 +08:00
this.userinfo()
2024-09-11 15:55:28 +08:00
}
})
}
},
2025-04-30 15:05:20 +08:00
userinfo() {
uni.setStorageSync("chooseIdx", this.shopinfo)
if (this.shopinfo == 0) {
2024-09-11 15:55:28 +08:00
uni.showLoading({
title: '加载中'
});
request({
url: '/getJcPartnerInfo',
method: 'get',
2024-11-11 13:18:56 +08:00
2025-04-30 15:05:20 +08:00
}).then((res) => {
if (res.code == 500) {
2024-09-11 15:55:28 +08:00
uni.showToast({
2025-04-30 15:05:20 +08:00
title: "信息有误"
2024-09-11 15:55:28 +08:00
})
return
}
2025-04-30 15:05:20 +08:00
if (res.code == 200) {
if (res.data.shop == true) {
uni.setStorageSync('userinfo', res.data.user)
uni.setStorageSync('roleSelect', 'shop')
uni.hideLoading();
this.$startSocketConnect(res.data.user.id)
uni.setStorageSync('userId', res.data.user.id)
this.goselect()
} else {
uni.showToast({
title: '您不是商户,请选择员工登录',
icon: 'none'
})
}
2024-09-11 15:55:28 +08:00
}
})
2024-11-11 13:18:56 +08:00
2024-09-11 15:55:28 +08:00
}
2025-04-30 15:05:20 +08:00
if (this.shopinfo == 2) {
2024-09-11 15:55:28 +08:00
uni.showLoading({
title: '加载中'
});
request({
2024-11-04 16:47:54 +08:00
url: '/rescue/getJcWorkerInfo',
2024-09-11 15:55:28 +08:00
method: 'get',
2024-11-11 13:18:56 +08:00
2025-04-30 15:05:20 +08:00
}).then((res) => {
if (res.code == 200) {
2025-06-10 17:53:26 +08:00
uni.setStorageSync('staffinfo', res.data)
2025-04-30 15:05:20 +08:00
uni.setStorageSync('partnerId', res.data.partnerId)
uni.setStorageSync('roleSelect', 'worker')
uni.setStorageSync('userId', res.data.user.id)
2024-09-11 15:55:28 +08:00
uni.hideLoading();
2024-11-11 09:32:28 +08:00
this.$startSocketConnect(res.data.user.id)
2024-09-11 15:55:28 +08:00
uni.redirectTo({
2025-04-30 15:05:20 +08:00
url: '/pages/staff/staff'
2024-09-11 15:55:28 +08:00
})
}
})
2024-11-11 13:18:56 +08:00
2025-06-10 17:53:26 +08:00
}
if (this.shopinfo == 3) {
uni.showLoading({
title: '加载中'
});
request({
url: '/rescue/getJcWorkerInfo',
method: 'get',
}).then((res) => {
if (res.code == 200) {
uni.setStorageSync('staffinfo', res.data)
uni.setStorageSync('partnerId', res.data.partnerId)
uni.setStorageSync('roleSelect', 'businessManager')
uni.setStorageSync('userId', res.data.user.id)
uni.hideLoading();
this.$startSocketConnect(res.data.user.id)
uni.redirectTo({
url: '/pages/businessManager/businessManager'
})
}
})
2024-09-11 15:55:28 +08:00
}
2025-04-30 15:05:20 +08:00
if (this.shopinfo == 1) {
2024-09-11 15:55:28 +08:00
uni.showLoading({
title: '加载中'
});
request({
url: '/rescue/getJcgfInfo',
method: 'get',
2024-11-11 13:18:56 +08:00
2025-04-30 15:05:20 +08:00
}).then((res) => {
if (res.code == 200) {
2024-09-11 15:55:28 +08:00
// uni.setStorageSync('staffinfo',res.user)
// uni.setStorageSync('partnerId',res.partnerInfo.partnerId)
2025-04-30 15:05:20 +08:00
uni.setStorageSync('roleSelect', 'jcgf')
uni.setStorageSync('userinfo', res.user)
2024-09-11 15:55:28 +08:00
uni.hideLoading();
uni.redirectTo({
2025-04-30 15:05:20 +08:00
url: '/pages/authority/authority'
2024-09-11 15:55:28 +08:00
})
}
})
2024-11-11 13:18:56 +08:00
2024-09-11 15:55:28 +08:00
}
2024-11-11 13:18:56 +08:00
2024-09-11 15:55:28 +08:00
},
2025-04-30 15:05:20 +08:00
getxz(index) {
2024-09-11 15:55:28 +08:00
this.activeid = index
2024-11-11 13:18:56 +08:00
2024-09-11 15:55:28 +08:00
},
2025-04-30 15:05:20 +08:00
getxz1() {
2024-11-11 13:18:56 +08:00
2024-09-11 15:55:28 +08:00
uni.navigateTo({
2025-04-30 15:05:20 +08:00
url: '/pages/Login/modify'
2024-09-11 15:55:28 +08:00
})
2024-11-11 13:18:56 +08:00
2024-09-11 15:55:28 +08:00
},
2025-04-30 15:05:20 +08:00
goregister() {
2024-09-11 15:55:28 +08:00
uni.navigateTo({
2025-04-30 15:05:20 +08:00
url: '/pages/login/register'
2024-09-11 15:55:28 +08:00
})
},
2025-04-30 15:05:20 +08:00
goforgot() {
2024-09-11 15:55:28 +08:00
uni.navigateTo({
2025-04-30 15:05:20 +08:00
url: '/pages/login/forgot'
2024-09-11 15:55:28 +08:00
})
},
2025-04-30 15:05:20 +08:00
goselect() {
2024-09-11 15:55:28 +08:00
uni.reLaunch({
2025-04-30 15:05:20 +08:00
url: '/pages/index/newindex'
2024-09-11 15:55:28 +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-04-30 15:05:20 +08:00
if (this.isButtonDisabled) {
return; // 如果按钮已禁用,则直接返回
}
const data = {
phone: this.tel,
}
request({
url: '/loginSmsCode',
method: 'post',
params: data
}).then((res) => {
if (res.code == 200) {
uni.showToast({
title: '验证码已发送 请注意查收',
icon: 'none'
})
} else {
uni.showToast({
title: '网络不佳请稍后再试',
icon: 'none'
2024-09-11 15:55:28 +08:00
})
2025-04-30 15:05:20 +08:00
}
})
2024-09-11 15:55:28 +08:00
2024-11-11 13:18:56 +08:00
2025-04-30 15:05:20 +08:00
this.disableButton(); // 禁用按钮
this.startCountdown(); // 启动倒计时
2024-11-11 13:18:56 +08:00
2024-09-11 15:55:28 +08:00
},
disableButton() {
2025-04-30 15:05:20 +08:00
this.isButtonDisabled = true;
2024-09-11 15:55:28 +08:00
},
enableButton() {
2025-04-30 15:05:20 +08:00
this.isButtonDisabled = false;
2024-09-11 15:55:28 +08:00
},
startCountdown() {
2025-04-30 15:05:20 +08:00
let countdown = setInterval(() => {
this.countdownTime--;
if (this.countdownTime === 0) {
clearInterval(countdown);
this.enableButton(); // 启用按钮
}
}, 1000);
2024-09-11 15:55:28 +08:00
},
}
}
</script>
<style scoped lang="scss">
2025-04-30 15:05:20 +08:00
.jsq {
2024-09-11 15:55:28 +08:00
border: none !important;
font-size: 12px;
height: 30px;
font-weight: 400;
color: #0078FF;
}
2025-04-30 15:05:20 +08:00
2024-09-11 15:55:28 +08:00
button {
2025-04-30 15:05:20 +08:00
border: none !important;
background: none !important;
margin: 0px;
display: block;
2024-09-11 15:55:28 +08:00
}
2025-04-30 15:05:20 +08:00
2024-09-11 15:55:28 +08:00
button:focus {
color: #0078FF;
2025-04-30 15:05:20 +08:00
outline: none;
box-shadow: none;
2024-09-11 15:55:28 +08:00
}
2025-04-30 15:05:20 +08:00
.content {
2024-09-11 15:55:28 +08:00
box-sizing: border-box;
2025-04-30 15:05:20 +08:00
background: linear-gradient(180deg, rgba(13, 46, 141, 0.2) 0%, rgba(255, 255, 255, 0) 100%);
2024-09-11 15:55:28 +08:00
}
2024-11-11 13:18:56 +08:00
2025-04-30 15:05:20 +08:00
.top {
2024-09-11 15:55:28 +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-04-30 15:05:20 +08:00
.touxiang {
2024-09-11 15:55:28 +08:00
width: 88px;
height: 88px;
border-radius: 10px;
background: #D7D7D7;
margin: 0 auto;
margin-bottom: 40px;
overflow: hidden;
2025-04-30 15:05:20 +08:00
image {
2024-09-11 15:55:28 +08:00
width: 100%;
height: 100%;
}
}
2025-04-30 15:05:20 +08:00
.twotap {
2024-09-11 15:55:28 +08:00
margin-top: 10px;
width: 100%;
display: flex;
align-items: center;
2025-04-30 15:05:20 +08:00
view {
2024-09-11 15:55:28 +08:00
font-size: 12px;
font-family: Microsoft YaHei;
font-weight: 400;
color: #666666;
margin-right: 38.5px;
}
}
2025-04-30 15:05:20 +08:00
.blck {
2024-09-11 15:55:28 +08:00
color: #333333 !important;
font-weight: bold !important;
}
2025-04-30 15:05:20 +08:00
.inputs {
2024-09-11 15:55:28 +08:00
height: 54px;
box-sizing: border-box;
padding: 16px 0px;
display: flex;
align-items: center;
2025-04-30 15:05:20 +08:00
border-bottom: 2px solid #E8E8E8;
2024-09-11 15:55:28 +08:00
// margin-top: 20px;
}
2025-04-30 15:05:20 +08:00
.wjworb {
2024-09-11 15:55:28 +08:00
margin-top: 5px;
width: 100%;
display: flex;
font-size: 12px;
color: #0078FF;
justify-content: flex-end;
align-items: center;
2024-11-11 13:18:56 +08:00
2024-09-11 15:55:28 +08:00
}
2025-04-30 15:05:20 +08:00
.dl {
2024-09-11 15:55:28 +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-04-30 15:05:20 +08:00
.hging {
2024-09-11 15:55:28 +08:00
width: 100%;
text-align: center;
font-size: 14px;
font-weight: 400;
color: #636363;
margin-top: 20px;
}
2025-04-30 15:05:20 +08:00
.wx {
2024-09-11 15:55:28 +08:00
width: 38px;
height: 38px;
overflow: hidden;
box-sizing: border-box;
margin: 0px auto;
margin-top: 20px;
2025-04-30 15:05:20 +08:00
image {
2024-09-11 15:55:28 +08:00
width: 100%;
height: 100%;
}
}
2025-04-30 15:05:20 +08:00
.hui {
2024-09-11 15:55:28 +08:00
font-size: 10px;
width: 100%;
text-align: center;
font-weight: 400;
color: #666666;
}
2025-04-30 15:05:20 +08:00
.dbottom {
2024-09-11 15:55:28 +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;
}
2024-11-11 13:18:56 +08:00
2025-04-30 15:05:20 +08:00
.lan {
2024-09-11 15:55:28 +08:00
color: #0D2E8D;
}
2025-04-30 15:05:20 +08:00
.box-box {
2024-09-11 15:55:28 +08:00
width: 95%;
margin: 20px auto;
border-radius: 8px;
overflow: hidden;
}
2025-04-30 15:05:20 +08:00
.bb-top {
2024-09-11 15:55:28 +08:00
height: 55px;
width: 100%;
display: flex;
align-items: center;
justify-content: space-between;
background: #FFFFFF;
}
2025-04-30 15:05:20 +08:00
.bb-bai {
2024-09-11 15:55:28 +08:00
width: 33%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
font-size: 17px;
font-weight: bold;
background: #FFFFFF;
// color: #0D2E8D;
color: #B5BACA;
}
2025-04-30 15:05:20 +08:00
.shendu {
2024-09-11 15:55:28 +08:00
color: #0D2E8D !important;
}
2025-04-30 15:05:20 +08:00
.bb-hui {
height: 100%;
2024-09-11 15:55:28 +08:00
width: 50%;
display: flex;
align-items: center;
justify-content: center;
background: #B5BACA;
2024-11-11 13:18:56 +08:00
font-size: 17px;
2024-09-11 15:55:28 +08:00
font-weight: 400;
color: #FFFFFF;
}
2025-04-30 15:05:20 +08:00
.bb-baibox {
2024-09-11 15:55:28 +08:00
box-sizing: border-box;
width: 100%;
padding: 15px;
background-color: white;
2024-11-11 13:18:56 +08:00
2024-09-11 15:55:28 +08:00
}
2025-04-30 15:05:20 +08:00
.anniulanan {
2024-09-11 15:55:28 +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-04-30 15:05:20 +08:00
.dalan {
2024-09-11 15:55:28 +08:00
font-size: 25px;
font-weight: bold;
color: #0D2E8D;
margin-left: 10px;
}
2025-04-30 15:05:20 +08:00
.axquan {
2024-09-11 15:55:28 +08:00
width: 14px;
height: 14px;
border-radius: 50%;
border: 1px solid #AAAAAA;
margin-right: 5px;
}
2025-04-30 15:05:20 +08:00
.axquanl {
2024-09-11 15:55:28 +08:00
width: 14px;
height: 14px;
border-radius: 50%;
border: 1px solid #AAAAAA;
margin-right: 5px;
background-color: #0D2E8D;
}
2025-04-30 15:05:20 +08:00
</style>