Commit 59d6c607 authored by zhengke's avatar zhengke

登录

parent aa929866
...@@ -58,7 +58,13 @@ class UserServices { ...@@ -58,7 +58,13 @@ class UserServices {
return Api.Post("travel_set_signout", msg) return Api.Post("travel_set_signout", msg)
} }
static async GetShowQrcode(QrCodeType: string): Promise<HttpResponse> {
static async WechatLoginAsync(scene_id: string): Promise<HttpResponse> {
let msg = { scene_id }
return Api.Post("Wechat_QrCode_GetSceneId", msg)
}
static async GetShowQrcode(QrCodeType: Number): Promise<HttpResponse> {
let msg = { QrCodeType } let msg = { QrCodeType }
return Api.Post("Wechat_QrCode_GetShowQrcode", msg) return Api.Post("Wechat_QrCode_GetShowQrcode", msg)
} }
......
...@@ -109,9 +109,9 @@ export const useUserStore = defineStore('user', { ...@@ -109,9 +109,9 @@ export const useUserStore = defineStore('user', {
this.userInfo.logo = ENTERPRISE_DEFAULT_HEADER this.userInfo.logo = ENTERPRISE_DEFAULT_HEADER
} }
}, },
async setUserVerifyLoginAsync(account:string,code:string,vtoken:string,tid:string='') { async setUserWechatLoginAsync(scene_id:string) {
try { try {
let response = await UserService.VerifyLoginAsync(account,code,vtoken,tid) let response = await UserService.WechatLoginAsync(scene_id)
if (response.data.resultCode == ApiResult.SUCCESS) { if (response.data.resultCode == ApiResult.SUCCESS) {
if(!Array.isArray(response.data.data)) { if(!Array.isArray(response.data.data)) {
this.token = response.data.data.token this.token = response.data.data.token
......
...@@ -61,15 +61,15 @@ ...@@ -61,15 +61,15 @@
</div> </div>
</div> </div>
</div> </div>
<div style="font-size: 20px; margin-top: 40px;font-weight: 600;" class="text-dark text-center" @click="currentLogin=1"> <div style="font-size: 20px; margin-top: 40px;font-weight: 600;" class="text-dark text-center PingFangSC">
<span style="color: #564becCC">{{currentLogin==1?'账号/邮箱密码':'微信扫码一键'}}</span> <span style="color: #564becCC">{{currentLogin==1?'账号/邮箱密码':'微信扫码一键'}}</span>
<span>登录</span> <span>登录</span>
</div> </div>
<div class="text-info text-small text-center q-pt-xs">你的创作空间</div> <div class="text-info text-small text-center q-pt-xs">你的创作空间</div>
<template v-if="!multipleUsers || multipleUsers.length==0"> <template v-if="!multipleUsers || multipleUsers.length==0">
<div class="q-mb-md" style="padding: 0 50px;"> <div class="q-mb-md" style="padding: 0 50px;">
<passwordLogin v-if="currentLogin==1"></passwordLogin> <passwordLogin v-if="currentLogin==1" @submitForm="(multUser)=> multipleUsers=multUser"></passwordLogin>
<wechatLogin v-if="currentLogin==2" @passwordLogin="currentLogin=1"></wechatLogin> <wechatLogin v-if="currentLogin==2"></wechatLogin>
<div class="q-pt-lg"> <div class="q-pt-lg">
<el-divider class="q-pb-md"> <span class="fz12 PingFangSC" style="color:#7f8792">其他方式登录</span></el-divider> <el-divider class="q-pb-md"> <span class="fz12 PingFangSC" style="color:#7f8792">其他方式登录</span></el-divider>
</div> </div>
...@@ -100,7 +100,7 @@ ...@@ -100,7 +100,7 @@
<strong><a>授权许可协议</a></strong>,如您成为稿定设计会员,成为会员即视为同意 <strong><a>授权许可协议</a></strong>,如您成为稿定设计会员,成为会员即视为同意
<strong><a>会员服务协议</a></strong> <strong><a>会员服务协议</a></strong>
</div> </div>
<div class="ServAgrelLoadR q-pl-lg cursor-pointer" @click="redicetToRegist">立即注册</div> <div class="ServAgrelLoadR q-pl-lg cursor-pointer" @click="redicetToRegist">邮箱注册</div>
</div> </div>
</template> </template>
<template v-if="multipleUsers && multipleUsers.length>0"> <template v-if="multipleUsers && multipleUsers.length>0">
...@@ -356,7 +356,7 @@ verifyCheckHandler() ...@@ -356,7 +356,7 @@ verifyCheckHandler()
} }
.login-formCenter{ .login-formCenter{
width: 480px; width: 480px;
height: 533px; height: 531px;
border: 1px solid #ccc; border: 1px solid #ccc;
border-radius: 4px; border-radius: 4px;
position: relative; position: relative;
......
...@@ -66,6 +66,10 @@ if(localStorage.getItem("invite")){ ...@@ -66,6 +66,10 @@ if(localStorage.getItem("invite")){
inviteInfo.value = JSON.parse(localStorage.getItem("invite")??'{}') inviteInfo.value = JSON.parse(localStorage.getItem("invite")??'{}')
} }
const emit = defineEmits<{
(event: 'submitForm'): void,
}>()
const redicetToRegist = ()=>{ const redicetToRegist = ()=>{
location.href='/regist' location.href='/regist'
} }
......
...@@ -3,47 +3,17 @@ ...@@ -3,47 +3,17 @@
<QRCode :value="qrCode" style="width: 159px;height: 159px;border: 1px solid #EBEBEB;" v-if="!qrLoading"></QRCode> <QRCode :value="qrCode" style="width: 159px;height: 159px;border: 1px solid #EBEBEB;" v-if="!qrLoading"></QRCode>
<QRCode value="http://www.viitto.com" style="width: 159px;height: 159px;border: 1px solid #EBEBEB;" v-if="qrLoading"></QRCode> <QRCode value="http://www.viitto.com" style="width: 159px;height: 159px;border: 1px solid #EBEBEB;" v-if="qrLoading"></QRCode>
</div> </div>
<!-- <div class="text-info text-small row flex-center q-pt-lg">
<span>账户/邮箱登录?</span>
<el-button link type="primary" class="q-mb-lg" @click="passwordLogin">立即登录</el-button>
</div> -->
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { reactive, ref } from 'vue' import { reactive, ref } from 'vue'
import { ElMessage, FormInstance, FormRules } from 'element-plus'; import { ElMessage, FormInstance } from 'element-plus';
import VueHcaptcha from "@hcaptcha/vue3-hcaptcha";
import { ApiResult } from '@/configs/axios'; import { ApiResult } from '@/configs/axios';
import UserServices from '@/services/UserService'; import UserServices from '@/services/UserService';
import { useUserStore } from '@/store/user';
interface RuleForm {
account: string
password: string
}
const model = ref<{account:string,password:string,tid:string}>({
account:'',
password:'',
tid:''
})
const rules = reactive<FormRules<RuleForm>>({
account: [
{ required: true, message: '请输入你的账号/邮箱', trigger: 'blur' },
{ min: 6, message: '请输入正确的账号', trigger: 'blur' },
],
password: [
{ required: true, message: '请输入你的密码', trigger: 'blur' },
{ min: 6,max:20, message: '请输入正确的密码', trigger: 'blur' },
]
})
const loginFormRef = ref<FormInstance>()
const loading = ref(false) const loading = ref(false)
const user = useUserStore()
const multipleUsers = ref<any[]>([]) const multipleUsers = ref<any[]>([])
const inviteInfo = ref<any>() const inviteInfo = ref<any>()
const needVerify = ref(false)
const validateToken = ref('')
const invisibleHcaptcha = ref()
if(localStorage.getItem("invite")){ if(localStorage.getItem("invite")){
inviteInfo.value = JSON.parse(localStorage.getItem("invite")??'{}') inviteInfo.value = JSON.parse(localStorage.getItem("invite")??'{}')
} }
...@@ -51,53 +21,50 @@ if(localStorage.getItem("invite")){ ...@@ -51,53 +21,50 @@ if(localStorage.getItem("invite")){
const qrCode = ref('none') const qrCode = ref('none')
const qrLoading = ref(false) const qrLoading = ref(false)
const emit = defineEmits<{ const scene_id = ref('')
(event: 'passwordLogin'): void,
}>()
const passwordLogin = () =>{ const queryTimer = ref<any>(null)
emit('passwordLogin')
}
const redicetToForgot = ()=>{ const beginTimerHandler = ()=>{
location.href='/forgot' queryTimer.value = setInterval(async ()=>{
await userLoginHandler()
},3000)
} }
const getQrcode = async () =>{ const stopTimerHandler = ()=>{
const result = await useUserStore.GetShowQrcode(1) if(queryTimer.value){
if(result.status==ApiResult.SUCCESS){ clearInterval(queryTimer.value)
queryTimer.value=null
} }
} }
const submitForm = async (formEl: FormInstance | undefined) => { const getQrcode = async () =>{
if (!formEl || loading.value || (needVerify.value && validateToken.value=='')) return qrLoading.value = true
loading.value=true const result = await UserServices.GetShowQrcode(1)
await formEl.validate(async (valid) => { if(result.data.resultCode==ApiResult.SUCCESS){
if (valid) { qrCode.value = result.data.data.url
await userLoginHandler() scene_id.value = result.data.data.scene_id
} }
loading.value=false qrLoading.value = false
})
} }
const userLoginHandler = async ()=>{ const userLoginHandler = async ()=>{
const result = await user.setUserPasswordLoginAsync(model.value.account,model.value.password,validateToken.value,model.value.tid) loading.value=true
const result = await user.setUserWechatLoginAsync(scene_id.value)
if(result.status=='SUCCESS'){ if(result.status=='SUCCESS'){
stopTimerHandler()
ElMessage.success({message:'登录成功'}) ElMessage.success({message:'登录成功'})
if(inviteInfo.value){ if(inviteInfo.value){
localStorage.removeItem('invite') localStorage.removeItem('invite')
localStorage.setItem('sure_invite',JSON.stringify(inviteInfo.value)) localStorage.setItem('sure_invite',JSON.stringify(inviteInfo.value))
} }
location.href='/space'; location.href='/space';
}else if(result.status=='CHOSEN' && Array.isArray(result.data)){
multipleUsers.value = result.data
}else{ }else{
if(!needVerify.value) needVerify.value = result.verify ElMessage.error({message:'出错啦,请稍后再试!'})
if(invisibleHcaptcha.value && needVerify.value) invisibleHcaptcha.value.reset()
ElMessage.error({message:'账号或密码错误'})
} }
loading.value=false
} }
getQrcode()
</script> </script>
<style> <style>
.wechatLoginForm{ .wechatLoginForm{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment