OfficeApp/pages/oaLogin/oaLogin.vue

328 lines
7.9 KiB
Vue
Raw Normal View History

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>
<!-- #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">
<u-tabs
:list="tabList"
@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="输入账号"
/>
<input
v-if="current == 0"
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>
2023-07-19 11:58:18 +08:00
</view>
<view class="btn">
<!-- <view>新用户注册</view> -->
2023-08-04 17:43:13 +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>
import {
loginAccount,
userInfo,
test
} from "@/api/oaUser.js"
import {
Toast
} from "../../libs/uniApi";
// #ifdef APP-PLUS
var jpushModule = uni.requireNativePlugin("JG-JPush");
2023-08-16 16:51:41 +08:00
// #endif
2023-08-16 16:51:41 +08:00
export default {
data () {
return {
2023-08-16 16:51:41 +08:00
tabList: [{
name: '账号登录'
2023-07-19 11:58:18 +08:00
},
// {name:'手机登录'},
],
current: 0,
formData: {
account: '',
password: '',
code: '',
terminal: 6, //6是APP端
scene: 1,
register_id: ""
},
tips: '获取验证码',
// refCode: null,
seconds: 60,
};
},
methods: {
changeTabs (e) {
this.current = e.index;
this.formData.scene = e.index + 1;
},
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) {
2023-07-25 15:53:06 +08:00
uni.showLoading({
mask: true,
title: '加载中'
2023-07-25 15:53:06 +08:00
})
uni.switchTab({
url: '/pages/oaHome/oaHome',
success: () => {
uni.$emit('initOaTask'); // 更新任务
uni.hideLoading()
2023-07-19 18:51:31 +08:00
}
})
} else uni.navigateTo({
url: '/pages/updatePasswprd/updatePasswprd'
});
2023-08-16 16:51:41 +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;
}
2023-08-15 18:27:07 +08:00
}
})
// #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('倒计时结束后再发送');
2023-07-19 11:58:18 +08:00
}
2023-07-19 18:51:31 +08:00
},
end () {
// uni.$u.toast('倒计时结束');
},
start () {
// uni.$u.toast('倒计时开始');
},
//忘记密码
forgetPWD () {
Toast('暂未开放')
2023-07-19 11:58:18 +08:00
}
},
mounted () {
2023-08-16 17:36:05 +08:00
// // #ifdef APP-PLUS
// jpushModule.initJPushService()
// jpushModule.getRegistrationID(result => {
// // 绑定极光设备id
// this.formData.register_id = result.registerID
// console.log("设备----", this.formData)
// })
// // #endif
this.initTerminal();
2023-07-19 11:58:18 +08:00
}
}
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");
2023-07-19 11:58:18 +08:00
/* #endif */
.bg-iamge {
2023-07-19 11:58:18 +08:00
width: 100vw;
height: 100vh;
position: absolute;
z-index: -99;
}
2023-07-19 11:58:18 +08:00
.body {
display: flex;
flex-direction: column;
align-items: center;
2023-07-19 11:58:18 +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
}
.login-card {
width: 694rpx;
height: 643rpx;
background: #ffffff;
border-radius: 21rpx 21rpx 21rpx 21rpx;
opacity: 1;
box-sizing: border-box;
padding: 38.5rpx 0;
2023-07-19 11:58:18 +08:00
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-between;
2023-07-19 11:58:18 +08:00
.top {
2023-07-19 11:58:18 +08:00
display: flex;
justify-content: space-evenly;
2023-07-19 11:58:18 +08:00
flex-direction: column;
.item {
margin-bottom: 35rpx;
}
2023-07-19 11:58:18 +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
.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
.code {
display: flex;
justify-content: space-between;
align-items: center;
2023-07-19 11:58:18 +08:00
input {
font-size: 28rpx;
2023-07-19 11:58:18 +08:00
}
2023-07-19 18:51:31 +08:00
.get-code {
color: $theme-oa-color;
2023-07-19 11:58:18 +08:00
}
}
.btn {
display: flex;
justify-content: space-between;
2023-07-19 11:58:18 +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
}
}
2023-07-19 11:58:18 +08:00
</style>