From 319b37fe98d04df1e3af0f0d956ab42cb057680c Mon Sep 17 00:00:00 2001
From: LiuHao <liuhaoai545@gmail.com>
Date: 星期二, 20 六月 2023 19:15:58 +0800
Subject: [PATCH] 合并 ts

---
 src/views/login.vue |   38 ++++++++++++++++++++++++++++++++++----
 1 files changed, 34 insertions(+), 4 deletions(-)

diff --git a/src/views/login.vue b/src/views/login.vue
index 11f3aae..709b0ce 100644
--- a/src/views/login.vue
+++ b/src/views/login.vue
@@ -4,7 +4,7 @@
       <h3 class="title">RuoYi-Vue-Plus澶氱鎴风鐞嗙郴缁�</h3>
       <el-form-item prop="tenantId" v-if="tenantEnabled">
         <el-select v-model="loginForm.tenantId" filterable placeholder="璇烽�夋嫨/杈撳叆鍏徃鍚嶇О" style="width: 100%">
-          <el-option v-for="item in tenantList" :key="item.tenantId" :label="item.companyName" :value="item.tenantId"> </el-option>
+          <el-option v-for="item in tenantList" :key="item.tenantId" :label="item.companyName" :value="item.tenantId"></el-option>
           <template #prefix><svg-icon icon-class="company" class="el-input__icon input-icon" /></template>
         </el-select>
       </el-form-item>
@@ -36,6 +36,20 @@
           <router-link class="link-type" :to="'/register'">绔嬪嵆娉ㄥ唽</router-link>
         </div>
       </el-form-item>
+      <div style="display: flex;justify-content: flex-end;flex-direction: row;">
+        <el-button circle>
+          <svg-icon icon-class="qq" @click="doSocialLogin('qq')" />
+        </el-button>
+        <el-button circle>
+          <svg-icon icon-class="wechat" @click="doSocialLogin('wechat')" />
+        </el-button>
+        <el-button circle>
+          <svg-icon icon-class="gitee" @click="doSocialLogin('gitee')" />
+        </el-button>
+        <el-button circle>
+          <svg-icon icon-class="github" @click="doSocialLogin('github')" />
+        </el-button>
+      </div>
     </el-form>
     <!--  搴曢儴  -->
     <div class="el-login-footer">
@@ -46,11 +60,13 @@
 
 <script setup lang="ts">
 import { getCodeImg, getTenantList } from '@/api/login';
+import { authBinding } from '@/api/system/social/auth';
 import Cookies from 'js-cookie';
 import { encrypt, decrypt } from '@/utils/jsencrypt';
 import { useUserStore } from '@/store/modules/user';
 import { LoginData, TenantVO } from '@/api/types';
 import { to } from 'await-to-js';
+import { HttpStatus } from "@/enums/RespEnum";
 
 const userStore = useUserStore();
 const router = useRouter();
@@ -82,12 +98,12 @@
 // 娉ㄥ唽寮�鍏�
 const register = ref(false);
 const redirect = ref(undefined);
-const loginRef = ref(ElForm);
+const loginRef = ref<ElFormInstance>();
 // 绉熸埛鍒楄〃
 const tenantList = ref<TenantVO[]>([]);
 
 const handleLogin = () => {
-  loginRef.value.validate(async (valid: boolean, fields: any) => {
+  loginRef.value?.validate(async (valid: boolean, fields: any) => {
     if (valid) {
       loading.value = true;
       // 鍕鹃�変簡闇�瑕佽浣忓瘑鐮佽缃湪 cookie 涓缃浣忕敤鎴峰悕鍜屽瘑鐮�
@@ -104,7 +120,6 @@
         Cookies.remove('rememberMe');
       }
       // 璋冪敤action鐨勭櫥褰曟柟娉�
-      // prittier-ignore
       const [err] = await to(userStore.login(loginForm.value));
       if (!err) {
         await router.push({ path: redirect.value || '/' });
@@ -161,6 +176,21 @@
     }
   }
 }
+/**
+ * 绗笁鏂圭櫥褰�
+ * @param type
+ */
+const doSocialLogin = (type: string) => {
+  authBinding(type).then((res: any) => {
+    if (res.code === HttpStatus.SUCCESS) {
+      window.location.href = res.msg;
+  } else {
+      ElMessage.error(res.msg);
+    }
+  });
+};
+
+
 
 onMounted(() => {
   getCode();

--
Gitblit v1.9.3