2023-07-19 11:58:18 +08:00
|
|
|
|
<template>
|
|
|
|
|
<view class="login">
|
|
|
|
|
<image class="bg-iamge" src="../../static/img/login/login_back_img.png"></image>
|
2023-07-20 16:32:30 +08:00
|
|
|
|
<!-- #ifdef APP-PLUS||H5 -->
|
|
|
|
|
<view style="height: var(--status-bar-height);"></view>
|
|
|
|
|
<!-- #endif -->
|
2023-07-19 11:58:18 +08:00
|
|
|
|
<view class="body">
|
|
|
|
|
<view class="title">欢迎进入里海供销平台!</view>
|
|
|
|
|
<view class="login-card">
|
|
|
|
|
<view class="top">
|
|
|
|
|
<view class="text item">
|
2023-07-19 18:51:31 +08:00
|
|
|
|
<u-tabs :list="[{name:'账号登录'},{name:'手机登录'}]" @click="changeTabs" lineColor="#3274F9"
|
|
|
|
|
itemStyle="padding-left: 15px; padding-right: 15px; height: 34px;font-size: 32rpx;"></u-tabs>
|
2023-07-19 11:58:18 +08:00
|
|
|
|
</view>
|
|
|
|
|
<input v-if="current==0" class="mobile item" v-model="formData.account" placeholder="输入账号" />
|
2023-07-25 15:53:06 +08:00
|
|
|
|
<input v-if="current==0" class="mobile item" v-model="formData.password" maxlength="26" placeholder="输入密码" password
|
2023-07-19 18:51:31 +08:00
|
|
|
|
type="safe-password" />
|
2023-07-19 11:58:18 +08:00
|
|
|
|
<input v-if="current==1" class="mobile item" v-model="formData.account" placeholder="输入手机号" />
|
|
|
|
|
<view v-if="current==1" class="code item">
|
2023-07-25 15:53:06 +08:00
|
|
|
|
<input placeholder="输入验证码" v-model="formData.code" maxlength="6" />
|
2023-07-22 10:13:49 +08:00
|
|
|
|
<u-code :seconds="seconds" @end="end" @start="start" ref="uCode"
|
|
|
|
|
@change="codeChange"></u-code>
|
|
|
|
|
<view class="get-code" @click="getCode">{{tips}}</view>
|
2023-07-19 11:58:18 +08:00
|
|
|
|
</view>
|
|
|
|
|
<view class="btn">
|
2023-07-22 10:13:49 +08:00
|
|
|
|
<!-- <view>新用户注册</view> -->
|
2023-07-25 15:53:06 +08:00
|
|
|
|
<view @click="forgetPWD">忘记密码?</view>
|
2023-07-19 11:58:18 +08:00
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
<button class="submit_btn" @click="login">登录</button>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2023-07-25 15:53:06 +08:00
|
|
|
|
import { loginAccount, userInfo, test } from "@/api/oaUser.js"
|
2023-07-22 10:13:49 +08:00
|
|
|
|
import { Toast } from "../../libs/uniApi";
|
2023-07-19 11:58:18 +08:00
|
|
|
|
export default {
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
current: 0,
|
|
|
|
|
formData: {
|
2023-07-22 16:47:21 +08:00
|
|
|
|
account: '',
|
|
|
|
|
password: '',
|
2023-07-19 11:58:18 +08:00
|
|
|
|
code: '',
|
2023-07-19 18:51:31 +08:00
|
|
|
|
terminal: 6, //6是APP端
|
2023-07-19 11:58:18 +08:00
|
|
|
|
scene: 1
|
2023-07-22 10:13:49 +08:00
|
|
|
|
},
|
|
|
|
|
tips: '获取验证码',
|
|
|
|
|
// refCode: null,
|
|
|
|
|
seconds: 60,
|
2023-07-19 11:58:18 +08:00
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
2023-07-19 18:51:31 +08:00
|
|
|
|
changeTabs(e) {
|
2023-07-19 11:58:18 +08:00
|
|
|
|
this.current = e.index;
|
2023-07-19 18:51:31 +08:00
|
|
|
|
this.formData.scene = e.index + 1;
|
2023-07-19 11:58:18 +08:00
|
|
|
|
},
|
|
|
|
|
async login() {
|
2023-07-22 10:13:49 +08:00
|
|
|
|
if(!this.formData.account)return Toast('账号不能为空');
|
|
|
|
|
if(this.formData.scene==1&&!this.formData.password)return Toast('密码不能为空');
|
|
|
|
|
if(this.formData.scene==2&&!this.formData.code)return Toast('验证码不能为空');
|
2023-07-19 11:58:18 +08:00
|
|
|
|
let that = this;
|
|
|
|
|
// let res = await test();
|
|
|
|
|
// console.log(res);
|
2023-07-25 15:53:06 +08:00
|
|
|
|
uni.showLoading({
|
|
|
|
|
title:'正在登录中'
|
|
|
|
|
})
|
2023-07-19 11:58:18 +08:00
|
|
|
|
let res = await loginAccount(that.formData);
|
|
|
|
|
this.$store.commit('SET_USERINFO', {
|
2023-07-20 13:48:26 +08:00
|
|
|
|
user: data,
|
2023-07-19 11:58:18 +08:00
|
|
|
|
token: res.data.token
|
|
|
|
|
})
|
2023-07-20 13:48:26 +08:00
|
|
|
|
let { data } = await userInfo();
|
|
|
|
|
this.$store.commit('setUserInfo', data);
|
2023-07-25 15:53:06 +08:00
|
|
|
|
uni.hideLoading()
|
2023-07-19 11:58:18 +08:00
|
|
|
|
uni.switchTab({
|
2023-07-19 18:51:31 +08:00
|
|
|
|
url: '/pages/oaHome/oaHome'
|
2023-07-19 11:58:18 +08:00
|
|
|
|
})
|
2023-07-19 18:51:31 +08:00
|
|
|
|
},
|
|
|
|
|
initTerminal() {
|
|
|
|
|
// #ifndef APP-PLUS
|
|
|
|
|
this.formData.terminal = 6;
|
|
|
|
|
// #endif
|
|
|
|
|
uni.getSystemInfo({
|
|
|
|
|
success: (res) => {
|
|
|
|
|
const platform = res.platform.toLowerCase();
|
|
|
|
|
if (platform === 'ios') {
|
|
|
|
|
this.formData.terminal = 5;
|
|
|
|
|
} else if (platform === 'windows') {
|
|
|
|
|
this.formData.terminal = 4;
|
|
|
|
|
} else if (platform === 'mac') {
|
|
|
|
|
this.formData.terminal = 4;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
// #ifdef H5
|
|
|
|
|
this.formData.terminal = 3;
|
|
|
|
|
// #endif
|
|
|
|
|
// #ifdef MP-WEIXIN
|
|
|
|
|
this.formData.terminal = 1;
|
|
|
|
|
// #endif
|
2023-07-22 10:13:49 +08:00
|
|
|
|
},
|
|
|
|
|
codeChange(text) {
|
|
|
|
|
this.tips = text;
|
|
|
|
|
},
|
|
|
|
|
getCode() {
|
|
|
|
|
if(this.$refs.uCode.canGetCode) {
|
|
|
|
|
// 模拟向后端请求验证码
|
|
|
|
|
uni.showLoading({
|
|
|
|
|
title: '正在获取验证码'
|
|
|
|
|
})
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
uni.hideLoading();
|
|
|
|
|
// 这里此提示会被this.start()方法中的提示覆盖
|
|
|
|
|
uni.$u.toast('验证码已发送');
|
|
|
|
|
// 通知验证码组件内部开始倒计时
|
|
|
|
|
this.$refs.uCode.start();
|
|
|
|
|
}, 2000);
|
|
|
|
|
} else {
|
|
|
|
|
uni.$u.toast('倒计时结束后再发送');
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
end() {
|
|
|
|
|
// uni.$u.toast('倒计时结束');
|
|
|
|
|
},
|
|
|
|
|
start() {
|
|
|
|
|
// uni.$u.toast('倒计时开始');
|
2023-07-25 15:53:06 +08:00
|
|
|
|
},
|
|
|
|
|
//忘记密码
|
|
|
|
|
forgetPWD(){
|
|
|
|
|
Toast('暂未开放')
|
2023-07-19 11:58:18 +08:00
|
|
|
|
}
|
2023-07-19 18:51:31 +08:00
|
|
|
|
},
|
|
|
|
|
mounted() {
|
|
|
|
|
this.initTerminal();
|
2023-07-19 11:58:18 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
|
.login {
|
|
|
|
|
width: 100vw;
|
|
|
|
|
height: 100vh;
|
|
|
|
|
position: relative;
|
|
|
|
|
/* #ifdef H5 */
|
|
|
|
|
background-image: url('../../static/img/login/login_back_img.png');
|
|
|
|
|
|
|
|
|
|
/* #endif */
|
|
|
|
|
.bg-iamge {
|
|
|
|
|
width: 100vw;
|
|
|
|
|
height: 100vh;
|
|
|
|
|
position: absolute;
|
|
|
|
|
z-index: -99;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.body {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
|
|
|
|
.title {
|
|
|
|
|
width: 694rpx;
|
|
|
|
|
height: 74rpx;
|
|
|
|
|
margin-top: 200rpx;
|
|
|
|
|
margin-bottom: 51rpx;
|
|
|
|
|
font-size: 53rpx;
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
color: #FFFFFF;
|
|
|
|
|
line-height: 68rpx;
|
|
|
|
|
-webkit-background-clip: text;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.login-card {
|
|
|
|
|
width: 694rpx;
|
|
|
|
|
height: 643rpx;
|
|
|
|
|
background: #FFFFFF;
|
|
|
|
|
border-radius: 21rpx 21rpx 21rpx 21rpx;
|
|
|
|
|
opacity: 1;
|
|
|
|
|
box-sizing: border-box;
|
|
|
|
|
padding: 38.5rpx 0;
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
|
|
|
|
|
.top {
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: space-evenly;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
|
|
|
|
|
.item {
|
|
|
|
|
margin-bottom: 35rpx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.text {
|
|
|
|
|
font-size: 32rpx;
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
color: rgba(0, 0, 0, 0.8);
|
|
|
|
|
line-height: 35rpx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.mobile,
|
|
|
|
|
.code {
|
|
|
|
|
width: 613rpx;
|
|
|
|
|
height: 112rpx;
|
|
|
|
|
background: #F5F5F5;
|
|
|
|
|
border-radius: 56rpx 56rpx 56rpx 56rpx;
|
|
|
|
|
opacity: 1;
|
|
|
|
|
padding: 0 45.56rpx;
|
|
|
|
|
box-sizing: border-box;
|
|
|
|
|
font-size: 28rpx;
|
|
|
|
|
font-weight: 400;
|
|
|
|
|
color: #333;
|
|
|
|
|
line-height: 35rpx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.code {
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
align-items: center;
|
2023-07-19 18:51:31 +08:00
|
|
|
|
|
|
|
|
|
input {
|
2023-07-19 11:58:18 +08:00
|
|
|
|
font-size: 28rpx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.get-code {
|
2023-07-25 17:44:18 +08:00
|
|
|
|
color: $theme-oa-color;
|
2023-07-19 11:58:18 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2023-07-19 18:51:31 +08:00
|
|
|
|
|
|
|
|
|
.btn {
|
2023-07-19 11:58:18 +08:00
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.submit_btn {
|
|
|
|
|
width: 613rpx;
|
|
|
|
|
height: 112rpx;
|
2023-07-25 17:44:18 +08:00
|
|
|
|
background: $theme-oa-color;
|
2023-07-19 11:58:18 +08:00
|
|
|
|
border-radius: 56rpx 56rpx 56rpx 56rpx;
|
|
|
|
|
opacity: 1;
|
|
|
|
|
text-align: center;
|
|
|
|
|
line-height: 112rpx;
|
|
|
|
|
color: #FFFFFF;
|
|
|
|
|
font-size: 35rpx;
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
</style>
|