OfficeApp/pages/oaLogin/oaLogin.vue

317 lines
7.4 KiB
Vue
Raw Normal View History

2023-07-19 11:58:18 +08:00
<template>
2023-08-21 11:35:12 +08:00
<view class="login">
<!-- <image class="bg-iamge" src="../../static/img/login/login_back_img.png"></image> -->
2023-08-23 10:14:17 +08:00
<hx-lottie :options="options" ref="lottie" style="width: 100vw;height: 100vh;transform: scale(1.1)"/>
2023-08-21 11:35:12 +08:00
<!-- #ifdef APP-PLUS||H5 -->
2023-08-23 10:14:17 +08:00
<!-- <view style="height: var(--status-bar-height)"></view> -->
2023-08-21 11:35:12 +08:00
<!-- #endif -->
<view class="body">
<view class="title">欢迎进入里海供销平台</view>
<view class="login-card">
<view class="top">
<view class="text item">
<u-tabs :list="tabList" @click="changeTabs" lineColor="#0122c7"
itemStyle="padding-left: 15px; padding-right: 15px; height: 34px;font-size: 32rpx;"></u-tabs>
</view>
<input v-if="current == 0" @click="getId" class="mobile item" v-model="formData.account"
placeholder="输入账号" />
<input v-if="current == 0" @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>
2023-07-19 11:58:18 +08:00
</template>
<script>
2023-08-21 11:35:12 +08:00
import {
loginAccount,
userInfo,
test
} from "@/api/oaUser.js"
import {
Toast
} from "../../libs/uniApi";
2023-08-23 10:14:17 +08:00
import bj from "@/static/animation/bj2.json"
2023-08-21 11:35:12 +08:00
// #ifdef APP-PLUS
var jpushModule = uni.requireNativePlugin("JG-JPush");
2023-08-16 16:51:41 +08:00
2023-08-21 11:35:12 +08:00
// #endif
2023-08-16 16:51:41 +08:00
2023-08-21 11:35:12 +08:00
export default {
data() {
return {
2023-08-23 10:14:17 +08:00
options: {
data: '',
rendererSettings: {
preserveAspectRatio: 'xMidYMid meet', // 调整动画的对齐方式
},
},
2023-08-21 11:35:12 +08:00
tabList: [{
name: '账号登录'
},
// {name:'手机登录'},
],
current: 0,
formData: {
account: '',
password: '',
code: '',
terminal: 6, //6是APP端
scene: 1,
register_id: ""
},
tips: '获取验证码',
// refCode: null,
seconds: 60,
};
},
2023-08-23 10:14:17 +08:00
onLoad() {
this.options.data = bj;
this.$refs.lottie.call('play');
},
2023-08-21 11:35:12 +08:00
methods: {
changeTabs(e) {
this.current = e.index;
this.formData.scene = e.index + 1;
},
// 获取设备id
getId() {
// #ifdef APP-PLUS
if (this.formData.register_id) return
jpushModule.initJPushService()
jpushModule.getRegistrationID(result => {
// 绑定极光设备id
this.formData.register_id = result.registerID || 0
2023-08-18 09:00:40 +08:00
2023-08-21 11:35:12 +08:00
console.log("设备----", this.formData)
})
// #endif
},
async login() {
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('验证码不能为空');
let that = this;
// let res = await test();
// console.log(res);
uni.showLoading({
title: '正在登录中'
})
let res = await loginAccount(that.formData);
console.log(that.formData)
this.$store.commit('SET_USERINFO', {
user: data,
token: res.data.token
})
let {
data
} = await userInfo();
this.$store.commit('setUserInfo', data);
uni.hideLoading()
if (data.is_new_user) {
uni.showLoading({
mask: true,
title: '加载中'
})
uni.switchTab({
url: '/pages/oaHome/oaHome',
success: () => {
uni.$emit('initOaTask'); // 更新任务
uni.hideLoading()
}
})
} else uni.navigateTo({
url: '/pages/updatePasswprd/updatePasswprd'
});
},
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('暂未开放')
}
},
mounted() {
2023-08-18 09:00:40 +08:00
2023-08-21 11:35:12 +08:00
this.initTerminal();
2023-08-21 11:35:12 +08:00
}
}
2023-07-19 11:58:18 +08:00
</script>
<style lang="scss">
2023-08-21 11:35:12 +08:00
.login {
width: 100vw;
height: 100vh;
position: relative;
2023-08-23 10:14:17 +08:00
overflow: hidden;
2023-08-21 11:35:12 +08:00
background-color: $theme-oa-color;
/* #ifdef H5 */
// background-image: url("../../static/img/login/login_back_img.png");
background-color: $theme-oa-color;
2023-07-19 11:58:18 +08:00
2023-08-21 11:35:12 +08:00
/* #endif */
// .bg-iamge {
// width: 100vw;
// height: 100vh;
// position: absolute;
// z-index: -99;
// }
2023-07-19 11:58:18 +08:00
2023-08-21 11:35:12 +08:00
.body {
2023-08-23 10:14:17 +08:00
position: absolute;
top: 200rpx;
left: 28rpx;
2023-08-21 11:35:12 +08:00
display: flex;
flex-direction: column;
align-items: center;
2023-07-19 11:58:18 +08:00
2023-08-21 11:35:12 +08:00
.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;
}
2023-07-19 11:58:18 +08:00
2023-08-21 11:35:12 +08:00
.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;
2023-07-19 11:58:18 +08:00
2023-08-21 11:35:12 +08:00
.top {
display: flex;
justify-content: space-evenly;
flex-direction: column;
2023-07-19 11:58:18 +08:00
2023-08-21 11:35:12 +08:00
.item {
margin-bottom: 35rpx;
}
2023-07-19 11:58:18 +08:00
2023-08-21 11:35:12 +08:00
.text {
font-size: 32rpx;
font-weight: 500;
color: rgba(0, 0, 0, 0.8);
line-height: 35rpx;
}
2023-07-19 11:58:18 +08:00
2023-08-21 11:35:12 +08:00
.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;
}
2023-07-19 18:51:31 +08:00
2023-08-21 11:35:12 +08:00
.code {
display: flex;
justify-content: space-between;
align-items: center;
2023-07-19 11:58:18 +08:00
2023-08-21 11:35:12 +08:00
input {
font-size: 28rpx;
}
2023-07-19 18:51:31 +08:00
2023-08-21 11:35:12 +08:00
.get-code {
color: $theme-oa-color;
}
}
2023-07-19 11:58:18 +08:00
2023-08-21 11:35:12 +08:00
.btn {
display: flex;
justify-content: space-between;
}
}
2023-07-19 11:58:18 +08:00
2023-08-21 11:35:12 +08:00
.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;
}
}
}
}
2023-07-19 11:58:18 +08:00
</style>