Commit 59d6c607 authored by zhengke's avatar zhengke

登录

parent aa929866
......@@ -58,7 +58,13 @@ class UserServices {
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 }
return Api.Post("Wechat_QrCode_GetShowQrcode", msg)
}
......
......@@ -109,9 +109,9 @@ export const useUserStore = defineStore('user', {
this.userInfo.logo = ENTERPRISE_DEFAULT_HEADER
}
},
async setUserVerifyLoginAsync(account:string,code:string,vtoken:string,tid:string='') {
async setUserWechatLoginAsync(scene_id:string) {
try {
let response = await UserService.VerifyLoginAsync(account,code,vtoken,tid)
let response = await UserService.WechatLoginAsync(scene_id)
if (response.data.resultCode == ApiResult.SUCCESS) {
if(!Array.isArray(response.data.data)) {
this.token = response.data.data.token
......
......@@ -61,15 +61,15 @@
</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>登录</span>
</div>
<div class="text-info text-small text-center q-pt-xs">你的创作空间</div>
<template v-if="!multipleUsers || multipleUsers.length==0">
<div class="q-mb-md" style="padding: 0 50px;">
<passwordLogin v-if="currentLogin==1"></passwordLogin>
<wechatLogin v-if="currentLogin==2" @passwordLogin="currentLogin=1"></wechatLogin>
<passwordLogin v-if="currentLogin==1" @submitForm="(multUser)=> multipleUsers=multUser"></passwordLogin>
<wechatLogin v-if="currentLogin==2"></wechatLogin>
<div class="q-pt-lg">
<el-divider class="q-pb-md"> <span class="fz12 PingFangSC" style="color:#7f8792">其他方式登录</span></el-divider>
</div>
......@@ -100,7 +100,7 @@
<strong><a>授权许可协议</a></strong>,如您成为稿定设计会员,成为会员即视为同意
<strong><a>会员服务协议</a></strong>
</div>
<div class="ServAgrelLoadR q-pl-lg cursor-pointer" @click="redicetToRegist">立即注册</div>
<div class="ServAgrelLoadR q-pl-lg cursor-pointer" @click="redicetToRegist">邮箱注册</div>
</div>
</template>
<template v-if="multipleUsers && multipleUsers.length>0">
......@@ -356,7 +356,7 @@ verifyCheckHandler()
}
.login-formCenter{
width: 480px;
height: 533px;
height: 531px;
border: 1px solid #ccc;
border-radius: 4px;
position: relative;
......
......@@ -66,6 +66,10 @@ if(localStorage.getItem("invite")){
inviteInfo.value = JSON.parse(localStorage.getItem("invite")??'{}')
}
const emit = defineEmits<{
(event: 'submitForm'): void,
}>()
const redicetToRegist = ()=>{
location.href='/regist'
}
......
......@@ -3,47 +3,17 @@
<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>
</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>
<script lang="ts" setup>
import { reactive, ref } from 'vue'
import { ElMessage, FormInstance, FormRules } from 'element-plus';
import VueHcaptcha from "@hcaptcha/vue3-hcaptcha";
import { ElMessage, FormInstance } from 'element-plus';
import { ApiResult } from '@/configs/axios';
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 user = useUserStore()
const multipleUsers = ref<any[]>([])
const inviteInfo = ref<any>()
const needVerify = ref(false)
const validateToken = ref('')
const invisibleHcaptcha = ref()
if(localStorage.getItem("invite")){
inviteInfo.value = JSON.parse(localStorage.getItem("invite")??'{}')
}
......@@ -51,53 +21,50 @@ if(localStorage.getItem("invite")){
const qrCode = ref('none')
const qrLoading = ref(false)
const emit = defineEmits<{
(event: 'passwordLogin'): void,
}>()
const scene_id = ref('')
const passwordLogin = () =>{
emit('passwordLogin')
}
const queryTimer = ref<any>(null)
const redicetToForgot = ()=>{
location.href='/forgot'
const beginTimerHandler = ()=>{
queryTimer.value = setInterval(async ()=>{
await userLoginHandler()
},3000)
}
const getQrcode = async () =>{
const result = await useUserStore.GetShowQrcode(1)
if(result.status==ApiResult.SUCCESS){
const stopTimerHandler = ()=>{
if(queryTimer.value){
clearInterval(queryTimer.value)
queryTimer.value=null
}
}
const submitForm = async (formEl: FormInstance | undefined) => {
if (!formEl || loading.value || (needVerify.value && validateToken.value=='')) return
loading.value=true
await formEl.validate(async (valid) => {
if (valid) {
await userLoginHandler()
const getQrcode = async () =>{
qrLoading.value = true
const result = await UserServices.GetShowQrcode(1)
if(result.data.resultCode==ApiResult.SUCCESS){
qrCode.value = result.data.data.url
scene_id.value = result.data.data.scene_id
}
loading.value=false
})
qrLoading.value = false
}
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'){
stopTimerHandler()
ElMessage.success({message:'登录成功'})
if(inviteInfo.value){
localStorage.removeItem('invite')
localStorage.setItem('sure_invite',JSON.stringify(inviteInfo.value))
}
location.href='/space';
}else if(result.status=='CHOSEN' && Array.isArray(result.data)){
multipleUsers.value = result.data
}else{
if(!needVerify.value) needVerify.value = result.verify
if(invisibleHcaptcha.value && needVerify.value) invisibleHcaptcha.value.reset()
ElMessage.error({message:'账号或密码错误'})
ElMessage.error({message:'出错啦,请稍后再试!'})
}
loading.value=false
}
getQrcode()
</script>
<style>
.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