OA/pages/oaLogin/oaLogin.vue

338 lines
8.0 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="login">
<!-- <image class="bg-iamge" src="../../static/img/login/login_back_img.png"></image> -->
<hx-lottie :options="options" ref="lottie"
style="width: 100vw;height: 100vh;transform: scale(1.3);background-color: #3274F9;" />
<u-navbar v-if="uniMP" @leftClick="leftClick" bgColor="rgba(0,0,0,0)" leftIconColor=" #fff" :autoBack="false">
</u-navbar>
<!-- #ifdef APP-PLUS||H5 -->
<!-- <view style="height: var(--status-bar-height)"></view> -->
<!-- #endif -->
<view class="body">
<view class="title">欢迎进入OA</view>
<view class="login-card">
<view class="top">
<view class="text item">
<u-tabs :list="tabList" @click="changeTabs" lineColor="#3274F9"
itemStyle="padding-left: 15px; padding-right: 15px; height: 34px;font-size: 32rpx;"></u-tabs>
</view>
<input @click="getId" class="mobile item" v-model="formData.username" type="tel"
placeholder="输入账号" />
<input style="width: 0;height: 0;opacity: 0;margin: 0;padding: 0;" v-model="formData.username"
type="tel" placeholder="输入账号" />
<input @click="getId" class="mobile item" v-model="formData.password" maxlength="26"
placeholder="输入密码" password type="safe-password" />
<!-- <input v-if="current == 1" class="mobile item" v-model="formData.account" placeholder="输入手机号" />
<view v-if="current == 1" class="code item">
<input placeholder="输入验证码" v-model="formData.code" maxlength="6" />
<u-code :seconds="seconds" @end="end" @start="start" ref="uCode" @change="codeChange"></u-code>
<view class="get-code" @click="getCode">{{ tips }}</view>
</view>
<view class="btn">
</view> -->
</view>
<button class="submit_btn" @click="login">登录</button>
</view>
</view>
</view>
</template>
<script>
import {
loginAccount,
userInfo
} from "@/api/oaUser.js"
import {
Toast
} from "../../libs/uniApi";
import bj from "@/static/animation/bj2.json"
import encrypt from "@/utils/encrypt.js"
export default {
data() {
return {
options: {
data: '',
},
uniMP: false,
APP_token: '',
tabList: [{
name: '账号登录'
},
// {name:'手机登录'},
],
current: 0,
formData: {
username: '',
password: '',
// code: '',
// terminal: 6, //6是APP端
// scene: 1,
// register_id: "",
// shop_token: ""
},
tips: '获取验证码',
// refCode: null,
seconds: 60,
};
},
onLoad() {
this.APP_token = uni.getStorageSync('APP_token');
this.options.data = bj;
// this.$refs.lottie.call('play');
this.initTerminal();
},
onShow() {
if (uni.getStorageSync('uniMP')) this.uniMP = true;
},
methods: {
changeTabs(e) {
this.current = e.index;
this.formData.scene = e.index + 1;
},
leftClick(e) {
uni.sendHostEvent('closeApp', e, (ret) => {
//发送消息成功回调
console.log('关闭应用' + JSON.stringify(ret));
});
},
// 获取设备id
getId() {
// #ifdef APP-PLUS
if (this.formData.register_id) return
// #endif
},
async login() {
if (!this.formData.username) return Toast('账号不能为空');
if (this.formData.scene == 1 && !this.formData.password) return Toast('密码不能为空');
if (this.formData.scene == 2 && !this.formData.code) return Toast('验证码不能为空');
this.formData.shop_token = uni.getStorageSync('APP_token');
let that = this;
uni.showLoading({
title: '正在登录中'
})
let res = await loginAccount(that.formData);
encrypt.encode('ACT', that.formData);
this.$store.commit('SET_USERINFO', {
user: data,
token: res.data.token
})
let {
data
} = await userInfo();
console.log(data,'11111111')
this.$store.commit('setUserInfo', data);
uni.hideLoading()
if (data.id) {
uni.showLoading({
mask: true,
title: '加载中'
})
// #ifdef APP-PLUS
return uni.switchTab({
url: '/pages/index/index',
success: () => {
uni.$emit('initOaTask'); // 更新任务
uni.hideLoading()
}
})
// #endif
return uni.reLaunch({
url: '/pages/index/index',
success: () => {
uni.$emit('initOaTask'); // 更新任务
uni.hideLoading()
}
})
} else uni.navigateTo({
url: '/pages/updatePassword/updatePassword'
});
},
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
},
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('倒计时开始');
},
//忘记密码
forgetPWD() {
Toast('暂未开放')
}
},
}
</script>
<style lang="scss">
.login {
width: 100vw;
height: 100vh;
position: relative;
overflow: hidden;
background-color: $theme-oa-color;
/* #ifdef H5 */
// background-image: url("../../static/img/login/login_back_img.png");
background-color: $theme-oa-color;
/* #endif */
// .bg-iamge {
// width: 100vw;
// height: 100vh;
// position: absolute;
// z-index: -99;
// }
.body {
position: absolute;
top: 45%;
left: 50%;
transform: translate(-50%, -50%);
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;
}
::v-deep uni-input {
min-height: 0 !important;
}
.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;
input {
font-size: 28rpx;
}
.get-code {
color: $theme-oa-color;
}
}
.btn {
display: flex;
justify-content: space-between;
}
}
.submit_btn {
width: 613rpx;
height: 112rpx;
background: $theme-oa-color;
border-radius: 56rpx 56rpx 56rpx 56rpx;
opacity: 1;
text-align: center;
line-height: 112rpx;
color: #ffffff;
font-size: 35rpx;
font-weight: 500;
}
}
}
}
</style>