|
|
@@ -1,9 +1,13 @@
|
|
|
<script>
|
|
|
import Vue from 'vue'
|
|
|
import countryCode from '@/lib/countryCode.json'
|
|
|
-import { sendSmsCode, sentEmailCode, register, confirmEmail } from '@/api/user'
|
|
|
+import thirdLogin from './third-login.vue'
|
|
|
+import { sendSmsCode, sentEmailCode, register, confirmEmail, getGoogleStatus, getLinkedinStatus } from '@/api/user'
|
|
|
export default Vue.extend({
|
|
|
name: 'Index',
|
|
|
+ components: {
|
|
|
+ thirdLogin
|
|
|
+ },
|
|
|
data() {
|
|
|
return {
|
|
|
countryCode,
|
|
|
@@ -22,13 +26,58 @@ export default Vue.extend({
|
|
|
timer: null,
|
|
|
count: 0,
|
|
|
pre_register_key: '',
|
|
|
+ third_login: '',
|
|
|
+ is_back: false,
|
|
|
env: process.env.NODE_ENV
|
|
|
}
|
|
|
},
|
|
|
mounted() {
|
|
|
this.getSavedAccount()
|
|
|
+ this.parseQuery()
|
|
|
},
|
|
|
methods: {
|
|
|
+ parseQuery() {
|
|
|
+ const url = new URL(window.location.href.replace('#', '?'))
|
|
|
+ if (url.searchParams.get('code')) {
|
|
|
+ this.is_back = true
|
|
|
+ this.third_login = 'linkin'
|
|
|
+ getLinkedinStatus(
|
|
|
+ url.searchParams.get('state'),
|
|
|
+ url.searchParams.get('code')
|
|
|
+ ).then(res => {
|
|
|
+ this.tokenLogin(res.data.api_token)
|
|
|
+ }).catch(err => {
|
|
|
+ this.$notify({
|
|
|
+ title: '登录失败',
|
|
|
+ message: '登录失败,请稍后重试。',
|
|
|
+ type: 'error'
|
|
|
+ })
|
|
|
+ this.third_login = ''
|
|
|
+ this.is_back = false
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if (url.searchParams.get('access_token')) {
|
|
|
+ this.is_back = true
|
|
|
+ this.third_login = 'google'
|
|
|
+ getGoogleStatus(
|
|
|
+ url.searchParams.get('state'),
|
|
|
+ url.searchParams.get('access_token')
|
|
|
+ ).then(res => {
|
|
|
+ this.tokenLogin(res.data.api_token)
|
|
|
+ }).catch(err => {
|
|
|
+ this.$notify({
|
|
|
+ title: '登录失败',
|
|
|
+ message: '登录失败,请稍后重试。',
|
|
|
+ type: 'error'
|
|
|
+ })
|
|
|
+ this.third_login = ''
|
|
|
+ this.is_back = false
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ openThirdLogin(type) {
|
|
|
+ this.third_login = type
|
|
|
+ },
|
|
|
sentSMSCode() {
|
|
|
if (this.loading || this.timer) {
|
|
|
return
|
|
|
@@ -98,9 +147,9 @@ export default Vue.extend({
|
|
|
})
|
|
|
}
|
|
|
this.loading = true
|
|
|
- register(this.email, '', this.code, 1, 0).then(res =>{
|
|
|
+ register(this.email, '', this.code, 1, 0).then(res => {
|
|
|
this.pre_register_key = res.data.pre_register_key
|
|
|
- confirmEmail(this.pre_register_key,this.password,this.confirmPassword).then(res => {
|
|
|
+ confirmEmail(this.pre_register_key, this.password, this.confirmPassword).then(res => {
|
|
|
this.isLogin = true
|
|
|
this.$notify({
|
|
|
title: '注册成功',
|
|
|
@@ -149,6 +198,13 @@ export default Vue.extend({
|
|
|
this.savePassword = true
|
|
|
}
|
|
|
},
|
|
|
+ tokenLogin(token) {
|
|
|
+ this.$store.dispatch('tokenLogin', { token: token }).then(res => {
|
|
|
+ this.$router.push('/dashboard')
|
|
|
+ }).catch(err => {
|
|
|
+ this.$message.error(err.message)
|
|
|
+ })
|
|
|
+ },
|
|
|
login() {
|
|
|
if (!this.username) {
|
|
|
this.$message.error('请输入用户名')
|
|
|
@@ -182,7 +238,7 @@ export default Vue.extend({
|
|
|
|
|
|
<template>
|
|
|
<div class="body">
|
|
|
- <div class="login-cont">
|
|
|
+ <div :style="{height:third_login?'64vh':'auto'}" class="login-cont">
|
|
|
<div class="image-left">
|
|
|
<img class="image" src="/static/image/login.webp" alt="">
|
|
|
<div class="title">展会服务系统</div>
|
|
|
@@ -224,18 +280,46 @@ export default Vue.extend({
|
|
|
<el-input v-model="password" prefix-icon="el-icon-unlock" placeholder="请输入密码" show-password class="input" />
|
|
|
<el-input v-model="confirmPassword" prefix-icon="el-icon-unlock" placeholder="请再次输入密码" show-password class="input" />
|
|
|
<div class="change-way" @click="isPhone=true">使用手机注册</div>
|
|
|
- <el-button @click="emailRegister()" type="primary" class="button">
|
|
|
+ <el-button type="primary" class="button" @click="emailRegister()">
|
|
|
<span>注册</span>
|
|
|
<span v-if="loading" class="el-icon-loading" />
|
|
|
</el-button>
|
|
|
</template>
|
|
|
</template>
|
|
|
+ <div class="third-login">
|
|
|
+ <div class="third-title">第三方登录/注册:</div>
|
|
|
+ <div class="button-list">
|
|
|
+ <div class="third-button" @click="openThirdLogin('wechat')">
|
|
|
+ <img class="icon" src="/static/image/icon/wechat.png">
|
|
|
+ </div>
|
|
|
+ <div class="third-button" @click="openThirdLogin('google')">
|
|
|
+ <img class="icon" src="/static/image/icon/google.png">
|
|
|
+ </div>
|
|
|
+ <div class="third-button" @click="openThirdLogin('linkin')">
|
|
|
+ <img class="icon" src="/static/image/icon/linkin.png">
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div :class="['third-window',third_login?'active':'']">
|
|
|
+ <div class="third-head">
|
|
|
+ <span class="third-title">第三方登录</span>
|
|
|
+ <span class="el-icon-close" @click="openThirdLogin('')" />
|
|
|
+ </div>
|
|
|
+ <div class="third-body">
|
|
|
+ <third-login
|
|
|
+ v-if="third_login"
|
|
|
+ :is_back="is_back"
|
|
|
+ :login_type="third_login"
|
|
|
+ @tokenLogin="tokenLogin"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
-<style scoped>
|
|
|
+<style scoped lang="scss">
|
|
|
.body{
|
|
|
width: 100%;
|
|
|
height: 100%;
|
|
|
@@ -270,10 +354,94 @@ export default Vue.extend({
|
|
|
}
|
|
|
}
|
|
|
.cont-right{
|
|
|
+ position: relative;
|
|
|
padding: 40px;
|
|
|
display: flex;
|
|
|
flex-direction: column;
|
|
|
grid-gap: 16px;
|
|
|
+ .third-window{
|
|
|
+ position: absolute;
|
|
|
+ top: 0;
|
|
|
+ right: 0;
|
|
|
+ width: 100%;
|
|
|
+ height: 100%;
|
|
|
+ background-color: white;
|
|
|
+ transition-duration: 300ms;
|
|
|
+ transform: translateX(100%);
|
|
|
+ z-index: 10;
|
|
|
+ display: grid;
|
|
|
+ grid-template-rows: auto 1fr;
|
|
|
+ &.active{
|
|
|
+ transform: translateX(0);
|
|
|
+ }
|
|
|
+ .third-body{
|
|
|
+ position: relative;
|
|
|
+ iframe{
|
|
|
+ border: none;
|
|
|
+ width: 100%;
|
|
|
+ height: 100%;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .third-head{
|
|
|
+ color: grey;
|
|
|
+ padding: 8px;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: space-between;
|
|
|
+ .third-title{
|
|
|
+ padding-left: 8px;
|
|
|
+ }
|
|
|
+ .el-icon-close{
|
|
|
+ border-radius: 8px;
|
|
|
+ width: 32px;
|
|
|
+ height: 32px;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: center;
|
|
|
+ cursor: pointer;
|
|
|
+ &:hover{
|
|
|
+ background-color: #eeeeee;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .third-login{
|
|
|
+ padding-top: 16px;
|
|
|
+ border-top: 1px solid #ececec;
|
|
|
+ .third-title{
|
|
|
+ font-size: 16px;
|
|
|
+ color: grey;
|
|
|
+ margin-bottom: 16px;
|
|
|
+ }
|
|
|
+ .button-list{
|
|
|
+ display: flex;
|
|
|
+ gap: 16px;
|
|
|
+ .third-button{
|
|
|
+ cursor: pointer;
|
|
|
+ width: 46px;
|
|
|
+ height: 46px;
|
|
|
+ border-radius: 50%;
|
|
|
+ background-color: #eeeeee;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: center;
|
|
|
+ .icon{
|
|
|
+ transition-duration: 300ms;
|
|
|
+ filter: brightness(0) opacity(0.5);
|
|
|
+ width: 22px;
|
|
|
+ height: 22px;
|
|
|
+ object-fit: contain;
|
|
|
+ }
|
|
|
+ &:hover{
|
|
|
+ background-color: #f4f4f4;
|
|
|
+ .icon{
|
|
|
+ scale: 1.04;
|
|
|
+ filter: brightness(1) opacity(1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
.title{
|
|
|
height: 36px;
|
|
|
font-weight: bold;
|