guhongwei 2 年之前
父節點
當前提交
7eb55ac1a5
共有 4 個文件被更改,包括 118 次插入0 次删除
  1. 55 0
      src/components/ValidCode.vue
  2. 11 0
      src/stores/users/admin.ts
  3. 23 0
      src/stores/users/unit.ts
  4. 29 0
      src/stores/users/users.ts

+ 55 - 0
src/components/ValidCode.vue

@@ -0,0 +1,55 @@
+<template>
+  <div id="validcode">
+    <div class="code" @click="resetCode()">
+      <span v-for="i in list" :key="i.code" :style="getStyle(i)">{{ i.code }}</span>
+    </div>
+  </div>
+</template>
+<script setup lang="ts">
+import type { Ref } from 'vue';
+import { ref, onMounted } from 'vue';
+const emit = defineEmits(['toCode']);
+const list: Ref<any> = ref([]);
+onMounted(() => {
+  // 创建验证码
+  createCode();
+});
+// 创建验证码
+const createCode = () => {
+  const len = 4;
+  const codeList = [];
+  const chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz0123456789';
+  const charsLen = chars.length;
+  for (let i = 0; i < len; i++) {
+    const rgb = [Math.round(Math.random() * 220), Math.round(Math.random() * 240), Math.round(Math.random() * 200)];
+    codeList.push({
+      code: chars.charAt(Math.floor(Math.random() * charsLen)),
+      color: `rgb(${rgb})`,
+      fontSize: `1${[Math.floor(Math.random() * 10)]}px`,
+      padding: `${[Math.floor(Math.random() * 10)]}px`,
+      transform: `rotate(${Math.floor(Math.random() * 90) - Math.floor(Math.random() * 90)}deg)`,
+    });
+  }
+  list.value = codeList;
+  const codeInfo = codeList.map((item) => item.code).join('');
+  emit('toCode', codeInfo);
+};
+// 验证码样式
+const getStyle = (e: any) => {
+  return `color: ${e.color}; font-size: ${e.fontSize}; padding: ${e.padding}; transform: ${e.transform}`;
+};
+// 重构验证码
+const resetCode = () => {
+  createCode();
+};
+</script>
+<style scoped lang="less">
+.code {
+  width: 100px;
+  height: 40px;
+  line-height: 40px;
+  text-align: center;
+  border-radius: 5px;
+  border: 1px solid #dcdfe6;
+}
+</style>

+ 11 - 0
src/stores/users/admin.ts

@@ -39,6 +39,15 @@ export const AdminStore = defineStore('admin', () => {
     const res = await axios.$delete(`${api.url}/${payload}`);
     return res;
   };
+  //password
+  const rp = async (payload: any): Promise<IQueryResult> => {
+    const res = await axios.$post(`${api.url}/rp`, payload);
+    return res;
+  };
+  const login = async (payload: any): Promise<IQueryResult> => {
+    const res = await axios.$post(`${api.url}/login`, payload);
+    return res;
+  };
   return {
     count,
     doubleCount,
@@ -48,5 +57,7 @@ export const AdminStore = defineStore('admin', () => {
     create,
     update,
     del,
+    rp,
+    login,
   };
 });

+ 23 - 0
src/stores/users/unit.ts

@@ -39,6 +39,25 @@ export const UnitStore = defineStore('unit', () => {
     const res = await axios.$delete(`${api.url}/${payload}`);
     return res;
   };
+  // account
+  const tfe = async (payload: any): Promise<IQueryResult> => {
+    const res = await axios.$post(`${api.url}/tfe`, payload);
+    return res;
+  };
+  // account code password
+  const erp = async (payload: any): Promise<IQueryResult> => {
+    const res = await axios.$post(`${api.url}/erp`, payload);
+    return res;
+  };
+  //password
+  const rp = async (payload: any): Promise<IQueryResult> => {
+    const res = await axios.$post(`${api.url}/rp`, payload);
+    return res;
+  };
+  const login = async (payload: any): Promise<IQueryResult> => {
+    const res = await axios.$post(`${api.url}/login`, payload);
+    return res;
+  };
   return {
     count,
     doubleCount,
@@ -48,5 +67,9 @@ export const UnitStore = defineStore('unit', () => {
     create,
     update,
     del,
+    tfe,
+    erp,
+    rp,
+    login,
   };
 });

+ 29 - 0
src/stores/users/users.ts

@@ -39,6 +39,30 @@ export const UsersStore = defineStore('user', () => {
     const res = await axios.$delete(`${api.url}/${payload}`);
     return res;
   };
+  // account
+  const tfe = async (payload: any): Promise<IQueryResult> => {
+    const res = await axios.$post(`${api.url}/tfe`, payload);
+    return res;
+  };
+  // account code password
+  const erp = async (payload: any): Promise<IQueryResult> => {
+    const res = await axios.$post(`${api.url}/erp`, payload);
+    return res;
+  };
+  //password
+  const rp = async (payload: any): Promise<IQueryResult> => {
+    const res = await axios.$post(`${api.url}/rp`, payload);
+    return res;
+  };
+  const refresh = async (): Promise<IQueryResult> => {
+    const res = await axios.$post(`${api.url}/refresh`);
+    return res;
+  };
+  const login = async (payload: any): Promise<IQueryResult> => {
+    const res = await axios.$post(`${api.url}/login`, payload);
+    return res;
+  };
+
   return {
     count,
     doubleCount,
@@ -48,5 +72,10 @@ export const UsersStore = defineStore('user', () => {
     create,
     update,
     del,
+    tfe,
+    erp,
+    rp,
+    refresh,
+    login,
   };
 });