Browse Source

登录+配送联调

hlp 1 year ago
parent
commit
35d1107ced

+ 3 - 1
fhKeeper/formulahousekeeper/customerBuler-crm/src/pages/api.ts

@@ -1 +1,3 @@
-export const SENDVCODE = "/user/sendVcode"; //发送验证码
+export const SENDVCODE = "/user/sendVcode";     //发送验证码
+export const REGISTER = "/user/insertCompany";  //注册
+export const LOGIN = "/user/loginAdmin";        //登录

+ 15 - 3
fhKeeper/formulahousekeeper/customerBuler-crm/src/pages/login.vue

@@ -7,8 +7,8 @@
       <h2 class="text-xl text-center pt-4 font-bold">客户管家</h2>
       <h2 class="text-xl text-center pt-4 font-bold">客户管家</h2>
       <el-form class="pt-4" ref="ruleFormRef" :model="ruleForm" :rules="rules">
       <el-form class="pt-4" ref="ruleFormRef" :model="ruleForm" :rules="rules">
         <el-form-item prop="username">
         <el-form-item prop="username">
-          <el-input clearable :prefix-icon="UserFilled" size="large" class="mt-2" v-model="ruleForm.username" autocomplete="off"
-            placeholder="账号/手机号" />
+          <el-input clearable :prefix-icon="UserFilled" size="large" class="mt-2" v-model="ruleForm.username"
+            autocomplete="off" placeholder="账号/手机号" />
         </el-form-item>
         </el-form-item>
         <el-form-item prop="password">
         <el-form-item prop="password">
           <el-input clearable :prefix-icon="Lock" show-password size="large" class="mt-4" v-model="ruleForm.password"
           <el-input clearable :prefix-icon="Lock" show-password size="large" class="mt-4" v-model="ruleForm.password"
@@ -47,6 +47,8 @@ import qiyeweixin from "@/assets/login/qiyeweixin.png";
 import { UserFilled, Lock } from '@element-plus/icons-vue'
 import { UserFilled, Lock } from '@element-plus/icons-vue'
 import type { FormInstance, FormRules } from 'element-plus'
 import type { FormInstance, FormRules } from 'element-plus'
 import { useStore } from '@/store/index'
 import { useStore } from '@/store/index'
+import { post } from "@/utils/request";
+import { LOGIN } from "./api";
 const { setRouters } = useStore()
 const { setRouters } = useStore()
 const router = useRouter();
 const router = useRouter();
 const ruleFormRef = ref<FormInstance>();
 const ruleFormRef = ref<FormInstance>();
@@ -71,8 +73,18 @@ const login = (formEl: FormInstance | undefined) => {
     }
     }
     loginLoading.value = true;
     loginLoading.value = true;
     console.log(ruleForm.value);
     console.log(ruleForm.value);
+    post(LOGIN, { ...ruleForm.value }).then(res => {
+      console.log(res);
+      setTimeout(() => {
+        loginLoading.value = false;
+      }, 1000)
+      // loginLoading.value = false;
+    }).catch(err => {
+      loginLoading.value = false;
+    })
+    return
     let newRouter = [
     let newRouter = [
-      { 
+      {
         path: '/thread',
         path: '/thread',
         name: 'thread'
         name: 'thread'
       }
       }

+ 46 - 28
fhKeeper/formulahousekeeper/customerBuler-crm/src/pages/register.vue

@@ -53,7 +53,7 @@ import { HomeFilled, UserFilled, Lock, Iphone, Tickets } from '@element-plus/ico
 import { ElNotification, ElMessage, type FormInstance, type FormRules } from 'element-plus'
 import { ElNotification, ElMessage, type FormInstance, type FormRules } from 'element-plus'
 import { isValueEmpty } from "@/utils/tools";
 import { isValueEmpty } from "@/utils/tools";
 import { post } from "@/utils/request";
 import { post } from "@/utils/request";
-import { SENDVCODE } from "./api";
+import { REGISTER, SENDVCODE } from "./api";
 const router = useRouter();
 const router = useRouter();
 const route = useRoute();
 const route = useRoute();
 const ruleFormRef = ref<FormInstance>();
 const ruleFormRef = ref<FormInstance>();
@@ -118,19 +118,19 @@ const sendVcode = () => {
     })
     })
     return
     return
   }
   }
-  // post(SENDVCODE, {
-  //   mobile: ruleForm.value.phone
-  // }).then(res => {
-  //   if (res.code == "ok") { 
-  //     ElMessage.success({
-  //       message: "发送成功",
-  //       type: "success",
-  //       duration: 2000,
-  //     })
-  //     showTimer.value = true;
-  //   countDown();
-  //   }
-  // })
+  post(SENDVCODE, {
+    mobile: ruleForm.value.phone
+  }).then(res => {
+    if (res.code == "ok") {
+      ElMessage.success({
+        message: "发送成功",
+        type: "success",
+        duration: 2000,
+      })
+      showTimer.value = true;
+      countDown();
+    }
+  })
 }
 }
 const register = (formEl: FormInstance | undefined) => {
 const register = (formEl: FormInstance | undefined) => {
   if (!formEl) {
   if (!formEl) {
@@ -145,27 +145,45 @@ const register = (formEl: FormInstance | undefined) => {
     let params = {
     let params = {
       ...ruleForm.value,
       ...ruleForm.value,
     }
     }
+    /* 如果地址栏有参数,就带上 */
     if (!isValueEmpty(route.query)) {
     if (!isValueEmpty(route.query)) {
       params = {
       params = {
         ...params,
         ...params,
         ...route.query
         ...route.query
       }
       }
     }
     }
-    console.log(params);
-    // if (res.code == "ok") { 
-    //   ElNotification.success({
-    //     title: "注册成功",
-    //     message: "注册成功",
-    //     type: "success",
-    //     duration: 1000,
-    //     onClose: () => {
-    //       router.push('/login')
-    //     }
-    //   })
-    // }
-
+    // console.log(params);
+    post(REGISTER, params).then(res => {
+      if (res.code == "ok") {
+        ElNotification.success({
+          title: "提示",
+          message: "注册成功",
+          type: "success",
+          duration:3000,
+          onClose: () => {
+            registerLoading.value = false;
+            router.back()
+          }
+        })
+      } else {
+        ElNotification.error({
+          title: "提示",
+          message: res.message || res.msg,
+          type: "success",
+          duration: 3000,
+        })
+        registerLoading.value = false;
+      }
+    }).catch(err => {
+      ElNotification.error({
+        title: "提示",
+        message: err.message || err.msg,
+        type: "success",
+        duration: 3000,
+      })
+      registerLoading.value = false;
+    })
 
 
-    registerLoading.value = false;
   })
   })
 
 
 };
 };

+ 5 - 5
fhKeeper/formulahousekeeper/customerBuler-crm/src/utils/request.ts

@@ -2,7 +2,7 @@ import axios from "axios";
 import { showMessage } from "./errorStatusCode"; // 引入状态码文件
 import { showMessage } from "./errorStatusCode"; // 引入状态码文件
 import type { AxiosRequestConfig, AxiosResponse, AxiosError } from "axios";
 import type { AxiosRequestConfig, AxiosResponse, AxiosError } from "axios";
 import { ElNotification } from "element-plus";
 import { ElNotification } from "element-plus";
-const baseURL='/api'
+const baseURL = "/api";
 // 创建axios实例
 // 创建axios实例
 const instance = axios.create({
 const instance = axios.create({
   baseURL, // 设置API的基础URL
   baseURL, // 设置API的基础URL
@@ -42,9 +42,9 @@ instance.interceptors.response.use(
 );
 );
 
 
 // 封装GET请求
 // 封装GET请求
-export async function get<T>(url: string, params?: any): Promise<T> {
+export async function get(url: string, params?: any): Promise<any> {
   return instance
   return instance
-    .get<T>(url, { params })
+    .get(url, { params })
     .then((response) => response.data)
     .then((response) => response.data)
     .catch((error) => {
     .catch((error) => {
       throw error;
       throw error;
@@ -52,9 +52,9 @@ export async function get<T>(url: string, params?: any): Promise<T> {
 }
 }
 
 
 // 封装POST请求
 // 封装POST请求
-export async function post<T>(url: string, data?: any): Promise<T> {
+export async function post(url: string, data?: any): Promise<any> {
   return instance
   return instance
-    .post<T>(url, data, {
+    .post(url, data, {
       headers: {
       headers: {
         "Content-type": " application/x-www-form-urlencoded; charset=UTF-8",
         "Content-type": " application/x-www-form-urlencoded; charset=UTF-8",
       },
       },