|
@@ -1,10 +1,14 @@
|
|
|
<script lang="ts">
|
|
<script lang="ts">
|
|
|
import Vue from 'vue'
|
|
import Vue from 'vue'
|
|
|
import countryCode from '@/lib/countryCode.json'
|
|
import countryCode from '@/lib/countryCode.json'
|
|
|
-import { sendSmsCode, sentEmailCode, register, confirmEmail } from '@/api/user'
|
|
|
|
|
|
|
+import { sendSmsCode, sentEmailCode, register, confirmEmail, getGoogleStatus, getLinkedinStatus } from '@/api/user'
|
|
|
import { getExpoInfo } from '@/api/expo'
|
|
import { getExpoInfo } from '@/api/expo'
|
|
|
|
|
+import thirdLogin from '@/views/login/third-login.vue'
|
|
|
export default Vue.extend({
|
|
export default Vue.extend({
|
|
|
name: 'Index',
|
|
name: 'Index',
|
|
|
|
|
+ components: {
|
|
|
|
|
+ thirdLogin
|
|
|
|
|
+ },
|
|
|
data() {
|
|
data() {
|
|
|
return {
|
|
return {
|
|
|
regWay: 0, // 0:手机注册 1:邮箱注册
|
|
regWay: 0, // 0:手机注册 1:邮箱注册
|
|
@@ -28,7 +32,12 @@ export default Vue.extend({
|
|
|
expo_key: '',
|
|
expo_key: '',
|
|
|
subTimer: '',
|
|
subTimer: '',
|
|
|
subTime: '',
|
|
subTime: '',
|
|
|
- isLogin: false
|
|
|
|
|
|
|
+ isLogin: false,
|
|
|
|
|
+
|
|
|
|
|
+ third_login: '',
|
|
|
|
|
+ third_token: '',
|
|
|
|
|
+ need_bind: false,
|
|
|
|
|
+ is_back: false
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
computed: {
|
|
computed: {
|
|
@@ -62,6 +71,88 @@ export default Vue.extend({
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
|
|
+ tokenLogin(token) {
|
|
|
|
|
+ this.$store.dispatch('tokenLogin', { token: token }).then(res => {
|
|
|
|
|
+ this.gotoForm()
|
|
|
|
|
+ }).catch(err => {
|
|
|
|
|
+ this.$notify({
|
|
|
|
|
+ title: '提示',
|
|
|
|
|
+ message: '使用本地令牌登录失败'+err,
|
|
|
|
|
+ type: 'error'
|
|
|
|
|
+ })
|
|
|
|
|
+ this.$message.error(err.message)
|
|
|
|
|
+ })
|
|
|
|
|
+ },
|
|
|
|
|
+ openThirdLogin(type) {
|
|
|
|
|
+ this.is_back = false
|
|
|
|
|
+ this.third_login = type
|
|
|
|
|
+ },
|
|
|
|
|
+ closeThirdLogin() {
|
|
|
|
|
+ this.is_back = false
|
|
|
|
|
+ this.need_bind = false
|
|
|
|
|
+ this.third_login = ''
|
|
|
|
|
+ this.third_token = ''
|
|
|
|
|
+ },
|
|
|
|
|
+ parseQuery() {
|
|
|
|
|
+ const url = new URL(window.location.href.replace('#', '?'))
|
|
|
|
|
+ function showError() {
|
|
|
|
|
+ this.$notify({
|
|
|
|
|
+ title: '登录失败',
|
|
|
|
|
+ message: '登录失败,请稍后重试。',
|
|
|
|
|
+ type: 'error'
|
|
|
|
|
+ })
|
|
|
|
|
+ this.third_login = ''
|
|
|
|
|
+ this.is_back = false
|
|
|
|
|
+ }
|
|
|
|
|
+ if (url.searchParams.get('code')) {
|
|
|
|
|
+ this.is_back = true
|
|
|
|
|
+ this.third_login = 'linkin'
|
|
|
|
|
+ getLinkedinStatus(
|
|
|
|
|
+ url.searchParams.get('state'),
|
|
|
|
|
+ url.searchParams.get('code')
|
|
|
|
|
+ ).then(res => {
|
|
|
|
|
+ if (res.data.api_token) {
|
|
|
|
|
+ this.tokenLogin(res.data.api_token)
|
|
|
|
|
+ } else if (res.data.third_token) {
|
|
|
|
|
+ this.third_token = res.data.third_token
|
|
|
|
|
+ this.need_bind = true
|
|
|
|
|
+ } else {
|
|
|
|
|
+ showError()
|
|
|
|
|
+ }
|
|
|
|
|
+ }).catch(err => {
|
|
|
|
|
+ this.$notify({
|
|
|
|
|
+ title: '提示',
|
|
|
|
|
+ message: '领英授权登录失败'+err,
|
|
|
|
|
+ type: 'error'
|
|
|
|
|
+ })
|
|
|
|
|
+ showError()
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ 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 => {
|
|
|
|
|
+ if (res.data.api_token) {
|
|
|
|
|
+ this.tokenLogin(res.data.api_token)
|
|
|
|
|
+ } else if (res.data.third_token) {
|
|
|
|
|
+ this.third_token = res.data.third_token
|
|
|
|
|
+ this.need_bind = true
|
|
|
|
|
+ } else {
|
|
|
|
|
+ showError()
|
|
|
|
|
+ }
|
|
|
|
|
+ }).catch(err => {
|
|
|
|
|
+ this.$notify({
|
|
|
|
|
+ title: '提示',
|
|
|
|
|
+ message: '谷歌授权登录失败'+err,
|
|
|
|
|
+ type: 'error'
|
|
|
|
|
+ })
|
|
|
|
|
+ showError()
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
sentSms() {
|
|
sentSms() {
|
|
|
if (this.loginInfo.phone === '') {
|
|
if (this.loginInfo.phone === '') {
|
|
|
this.$message.error('请填写电话号码!')
|
|
this.$message.error('请填写电话号码!')
|
|
@@ -292,6 +383,20 @@ export default Vue.extend({
|
|
|
</div>
|
|
</div>
|
|
|
<el-button type="primary" @click="submitLogin()">登录</el-button>
|
|
<el-button type="primary" @click="submitLogin()">登录</el-button>
|
|
|
<el-button type="text" @click="isLogin=false">没有账号?去注册。</el-button>
|
|
<el-button type="text" @click="isLogin=false">没有账号?去注册。</el-button>
|
|
|
|
|
+ <div class="third-login">
|
|
|
|
|
+ <div @click="openThirdLogin('wechat')" class="button wechat">
|
|
|
|
|
+ <img class="icon" src="/static/image/icon/wechat.png">
|
|
|
|
|
+ 微信扫码登录
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div @click="openThirdLogin('google')" class="button google">
|
|
|
|
|
+ <img class="icon" src="/static/image/icon/google.png">
|
|
|
|
|
+ 谷歌授权登录
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div @click="openThirdLogin('linkin')" class="button linkin">
|
|
|
|
|
+ <img class="icon" src="/static/image/icon/linkin.png">
|
|
|
|
|
+ 领英授权登录
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
</div>
|
|
</div>
|
|
|
<div v-else class="register-body">
|
|
<div v-else class="register-body">
|
|
|
<div class="tab">
|
|
<div class="tab">
|
|
@@ -340,6 +445,20 @@ export default Vue.extend({
|
|
|
</div>
|
|
</div>
|
|
|
<el-button type="primary" @click="register()">注册</el-button>
|
|
<el-button type="primary" @click="register()">注册</el-button>
|
|
|
<el-button type="text" @click="isLogin=true">已有账号?去登陆。</el-button>
|
|
<el-button type="text" @click="isLogin=true">已有账号?去登陆。</el-button>
|
|
|
|
|
+ <div class="third-login">
|
|
|
|
|
+ <div @click="openThirdLogin('wechat')" class="button wechat">
|
|
|
|
|
+ <img class="icon" src="/static/image/icon/wechat.png">
|
|
|
|
|
+ 微信扫码登录
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div @click="openThirdLogin('google')" class="button google">
|
|
|
|
|
+ <img class="icon" src="/static/image/icon/google.png">
|
|
|
|
|
+ 谷歌授权登录
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div @click="openThirdLogin('linkin')" class="button linkin">
|
|
|
|
|
+ <img class="icon" src="/static/image/icon/linkin.png">
|
|
|
|
|
+ 领英授权登录
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
</div>
|
|
</div>
|
|
|
<el-dialog
|
|
<el-dialog
|
|
|
title="设置初始密码"
|
|
title="设置初始密码"
|
|
@@ -360,22 +479,118 @@ export default Vue.extend({
|
|
|
<el-button type="primary" @click="checkPassword()">确 定</el-button>
|
|
<el-button type="primary" @click="checkPassword()">确 定</el-button>
|
|
|
</span>
|
|
</span>
|
|
|
</el-dialog>
|
|
</el-dialog>
|
|
|
|
|
+ <div :class="['mask',third_login?'show':'']">
|
|
|
|
|
+ <div class="third-body">
|
|
|
|
|
+ <span class="el-icon-close" @click="closeThirdLogin()" />
|
|
|
|
|
+ <third-login
|
|
|
|
|
+ v-if="third_login"
|
|
|
|
|
+ :is_back="is_back"
|
|
|
|
|
+ :need_bind.sync="need_bind"
|
|
|
|
|
+ :third_token.sync="third_token"
|
|
|
|
|
+ :login_type="third_login"
|
|
|
|
|
+ @tokenLogin="tokenLogin"
|
|
|
|
|
+ />
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
</div>
|
|
</div>
|
|
|
</template>
|
|
</template>
|
|
|
<style scoped lang="scss">
|
|
<style scoped lang="scss">
|
|
|
.body{
|
|
.body{
|
|
|
- margin: 36px auto;
|
|
|
|
|
- max-width: 800px;
|
|
|
|
|
width: 100%;
|
|
width: 100%;
|
|
|
|
|
+ height: 100%;
|
|
|
|
|
+ overflow: hidden;
|
|
|
|
|
+ overflow-y: auto;
|
|
|
|
|
+ width: 100%;
|
|
|
|
|
+ .mask{
|
|
|
|
|
+ transition-duration: 300ms;
|
|
|
|
|
+ width: 100%;
|
|
|
|
|
+ height: 100%;
|
|
|
|
|
+ background-color: #00000044;
|
|
|
|
|
+ left: 0;
|
|
|
|
|
+ top: 0;
|
|
|
|
|
+ position: fixed;
|
|
|
|
|
+ display: flex;
|
|
|
|
|
+ justify-content: center;
|
|
|
|
|
+ align-items: center;
|
|
|
|
|
+ pointer-events: none;
|
|
|
|
|
+ opacity: 0;
|
|
|
|
|
+ .third-body{
|
|
|
|
|
+ position: relative;
|
|
|
|
|
+ transition-duration: 300ms;
|
|
|
|
|
+ background-color: white;
|
|
|
|
|
+ transform: translateY(40px);
|
|
|
|
|
+ width: 460px;
|
|
|
|
|
+ height: 600px;
|
|
|
|
|
+ .el-icon-close{
|
|
|
|
|
+ position: absolute;
|
|
|
|
|
+ right: 8px;
|
|
|
|
|
+ top: 8px;
|
|
|
|
|
+ border-radius: 4px;
|
|
|
|
|
+ padding: 8px;
|
|
|
|
|
+ transition-duration: 300ms;
|
|
|
|
|
+ cursor: pointer;
|
|
|
|
|
+ &:hover{
|
|
|
|
|
+ background-color: #00000011;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ &.show{
|
|
|
|
|
+ pointer-events: all;
|
|
|
|
|
+ opacity: 1;
|
|
|
|
|
+ .third-body{
|
|
|
|
|
+ transform: translateY(0);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
.register-body{
|
|
.register-body{
|
|
|
|
|
+ margin: 48px auto 64px;
|
|
|
|
|
+ max-width: 800px;
|
|
|
display: flex;
|
|
display: flex;
|
|
|
flex-direction: column;
|
|
flex-direction: column;
|
|
|
gap: 16px;
|
|
gap: 16px;
|
|
|
- margin-top: 32px;
|
|
|
|
|
padding: 40px 50px;
|
|
padding: 40px 50px;
|
|
|
border-radius: 4px;
|
|
border-radius: 4px;
|
|
|
box-shadow: 0px 1px 2px 0px rgba(0, 0, 0, 0.05);
|
|
box-shadow: 0px 1px 2px 0px rgba(0, 0, 0, 0.05);
|
|
|
background: white;
|
|
background: white;
|
|
|
|
|
+ .third-login{
|
|
|
|
|
+ display: grid;
|
|
|
|
|
+ grid-gap: 16px;
|
|
|
|
|
+ grid-template-columns: 1fr 1fr 1fr;
|
|
|
|
|
+ .button{
|
|
|
|
|
+ transition-duration: 300ms;
|
|
|
|
|
+ cursor: pointer;
|
|
|
|
|
+ display: flex;
|
|
|
|
|
+ align-items: center;
|
|
|
|
|
+ gap: 8px;
|
|
|
|
|
+ justify-content: center;
|
|
|
|
|
+ padding: 8px 16px;
|
|
|
|
|
+ font-size: 16px;
|
|
|
|
|
+ color: black;
|
|
|
|
|
+ background-color: #FFFFFF;
|
|
|
|
|
+ .icon{
|
|
|
|
|
+ transition-duration: 300ms;
|
|
|
|
|
+ width: 20px;
|
|
|
|
|
+ height: 20px;
|
|
|
|
|
+ object-fit: contain;
|
|
|
|
|
+ filter: brightness(1);
|
|
|
|
|
+ }
|
|
|
|
|
+ &:hover{
|
|
|
|
|
+ color: white;
|
|
|
|
|
+ .icon{
|
|
|
|
|
+ filter: brightness(100);
|
|
|
|
|
+ }
|
|
|
|
|
+ &.wechat{
|
|
|
|
|
+ background: #0E932E;
|
|
|
|
|
+ }
|
|
|
|
|
+ &.google{
|
|
|
|
|
+ background: #EA4335;
|
|
|
|
|
+ }
|
|
|
|
|
+ &.linkin{
|
|
|
|
|
+ background: #0B66C1;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
.piracy{
|
|
.piracy{
|
|
|
color: #6B7280;
|
|
color: #6B7280;
|
|
|
display: flex;
|
|
display: flex;
|
|
@@ -415,7 +630,8 @@ export default Vue.extend({
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
.time-counter{
|
|
.time-counter{
|
|
|
- margin-top: 32px;
|
|
|
|
|
|
|
+ max-width: 800px;
|
|
|
|
|
+ margin: 32px auto 0;
|
|
|
background: #4DA9FF22;
|
|
background: #4DA9FF22;
|
|
|
padding: 24px;
|
|
padding: 24px;
|
|
|
border-radius: 8px;
|
|
border-radius: 8px;
|
|
@@ -445,6 +661,8 @@ export default Vue.extend({
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
.head{
|
|
.head{
|
|
|
|
|
+ margin: 48px auto 0;
|
|
|
|
|
+ max-width: 800px;
|
|
|
.title{
|
|
.title{
|
|
|
text-align: center;
|
|
text-align: center;
|
|
|
font-size: 24px;
|
|
font-size: 24px;
|