<template>
|
<div class="wx">
|
<img class="wx_bg" src="@/assets/background/login_bg@2x.png" alt="" />
|
<div class="wx_login">
|
<img class="wx_login_icon" src="@/assets/icon/logo@2x.png" alt="" />
|
<span>DM云工厂</span>
|
<div class="wx_login_list">
|
<div class="wx_login_list_item">
|
<img src="@/assets/icon/login_ic_code@2x.png" alt="" />
|
<input type="text" v-model="from.companyId" placeholder="企业代码" />
|
</div>
|
<div class="wx_login_list_item">
|
<img src="@/assets/icon/login_ic_phone@2x.png" alt="" />
|
<input type="text" maxlength="11" v-model="from.username" placeholder="手机号" />
|
</div>
|
<div class="wx_login_list_item">
|
<img src="@/assets/icon/login_ic_password@2x.png" alt="" />
|
<input type="password" v-model="from.password" placeholder="密码" />
|
</div>
|
</div>
|
<div class="wx_login_footer">
|
<div class="wx_login_footer_btn" @click="login">立即登录</div>
|
</div>
|
</div>
|
</div>
|
</template>
|
|
<script setup lang="ts">
|
import { onMounted, reactive } from 'vue';
|
import { useRoute, useRouter } from 'vue-router';
|
import { useStore } from 'vuex';
|
import { wxAccountLogin, getUserInfo, wxProgramLogin } from '@/apis/index';
|
import { Toast } from 'vant';
|
|
const route = useRoute()
|
const router = useRouter()
|
const store = useStore()
|
|
let from: any = reactive({
|
openid: '',
|
unionid: '',
|
companyId: '',
|
username: '',
|
password: ''
|
})
|
|
const login = async () => {
|
// if (!from.openid) return Toast('openid不能为空')
|
// if (!from.unionid) return Toast('unionid不能为空')
|
if (!from.companyId) return Toast('企业代码不能为空')
|
if (!from.username) return Toast('手机号不能为空')
|
if (!from.password) return Toast('密码不能为空')
|
Toast.loading({
|
message: '登录中...',
|
forbidClick: true
|
});
|
let res = await wxAccountLogin(from)
|
if (res.code === 200) {
|
let info = await getUserInfo()
|
if (info.code === 200) {
|
await store.commit('setEntrance', 'XCX')
|
await store.commit('setUserInfo', info.data)
|
await store.dispatch('getMenuList', 2)
|
await router.replace('/workbench')
|
}
|
}
|
Toast.clear();
|
}
|
|
onMounted(() => {
|
wxProgramLogin({ code: route.query.code })
|
.then(async (res) => {
|
if (res.code === 200) {
|
// 免登录,直接跳首页
|
if (res.data.loginStatus == 0) {
|
let info = await getUserInfo()
|
if (info.code === 200) {
|
await store.commit('setEntrance', 'XCX')
|
await store.commit('setUserInfo', info.data)
|
await store.dispatch('getMenuList', 2)
|
await router.replace('/workbench')
|
}
|
} else {
|
from.openid = res.data.openid
|
from.unionid = res.data.unionid
|
}
|
}
|
})
|
})
|
</script>
|
|
<style lang="scss" scoped>
|
.wx {
|
width: 100vw;
|
height: 100vh;
|
display: flex;
|
align-items: center;
|
justify-content: center;
|
background: #FFFFFF linear-gradient(180deg, rgba(66,117,252,0.2) 0%, rgba(66,117,252,0) 100%);
|
.wx_bg {
|
width: 100vw;
|
height: 812px;
|
position: fixed;
|
top: 0;
|
left: 0;
|
}
|
.wx_login {
|
width: 100vw;
|
height: auto;
|
display: flex;
|
align-items: center;
|
justify-content: center;
|
flex-direction: column;
|
.wx_login_icon {
|
width: 180px;
|
height: 180px;
|
}
|
span {
|
font-size: 44px;
|
font-family: PingFangSC-Semibold, PingFang SC;
|
font-weight: 600;
|
color: #333333;
|
margin-top: 40px;
|
}
|
.wx_login_list {
|
width: 100vw;
|
padding: 0 60px;
|
box-sizing: border-box;
|
margin-top: 80px;
|
position: relative;
|
z-index: 9;
|
.wx_login_list_item {
|
width: 100%;
|
height: 98px;
|
background: #FFFFFF;
|
border-radius: 8px;
|
padding: 0 40px;
|
box-sizing: border-box;
|
display: flex;
|
align-items: center;
|
margin-bottom: 40px;
|
&:last-child {
|
margin-bottom: 0 !important;
|
}
|
img {
|
width: 40px;
|
height: 40px;
|
flex-shrink: 0;
|
margin-right: 24px;
|
}
|
input::-webkit-input-placeholder {
|
font-size: 30px;
|
font-family: PingFangSC-Regular, PingFang SC;
|
font-weight: 400;
|
color: #B7BBC5;
|
}
|
input {
|
flex: 1;
|
height: 100%;
|
padding: 0 !important;
|
font-size: 30px;
|
font-family: PingFangSC-Regular, PingFang SC;
|
font-weight: 400;
|
color: #222222;
|
border: none;
|
outline: none;
|
}
|
}
|
}
|
.wx_login_footer {
|
width: 100vw;
|
padding: 0 60px;
|
box-sizing: border-box;
|
margin-top: 80px;
|
.wx_login_footer_btn {
|
width: 100%;
|
height: 98px;
|
line-height: 98px;
|
text-align: center;
|
background: #4275FC;
|
box-shadow: 0px 12px 24px 0px rgba(66,117,252,0.2);
|
border-radius: 8px;
|
font-size: 32px;
|
font-family: PingFangSC-Medium, PingFang SC;
|
font-weight: 500;
|
color: #FFFFFF;
|
}
|
}
|
}
|
}
|
</style>
|