Kaynağa Gözat

Merge remote-tracking branch 'origin/feature-user-page' into feature-user-page

# Conflicts:
#	src/components/Register.vue
Nivek 2 yıl önce
ebeveyn
işleme
98dbba2063

+ 4 - 4
src/api/_prefix.ts

@@ -3,8 +3,8 @@ export const API_MODULE = '/api'
 //用户模块
 export const USER_MODULE= `${API_MODULE}/users`
 //商店模块
-export const STORE_MODULE= `${API_MODULE}/store`
+export const STORE_MODULE= `${API_MODULE}/stores`
 //商品模块
-export const PRODUCT_MODULE= `${API_MODULE}/product`
-//工具模块
-export const TOOL_MODULE= `${API_MODULE}/tool`
+export const PRODUCT_MODULE= `${API_MODULE}/products`
+//图片模块
+export const IMAGE_MODULE= `${API_MODULE}/images`

+ 10 - 0
src/api/image.ts

@@ -0,0 +1,10 @@
+import {axios} from '../utils/request'
+import {IMAGE_MODULE} from './_prefix'
+
+// 上传文件
+export const uploadImage = payload => {
+    return axios.post(`${IMAGE_MODULE}`, null, {params: payload})
+        .then(res => {
+            return res;
+        })
+}

+ 0 - 10
src/api/tool.ts

@@ -1,10 +0,0 @@
-import {axios} from '../utils/request'
-import {TOOL_MODULE} from './_prefix'
-
-// 上传文件
-export const uploadFile = payload => {
-    return axios.post(`${TOOL_MODULE}/upload`, payload)
-        .then(res => {
-            return res;
-        })
-}

+ 1 - 3
src/components/Dashboard.vue

@@ -11,8 +11,6 @@
   const isStaff = ''
 
   onMounted(() => {
-
-
     const res = axios.get('/api/users', {
       headers: {token: document.cookie.split(";")[0].split("=")[1]}
     }).then(res => {
@@ -216,4 +214,4 @@
 
 <style scoped>
 
-</style>
+</style>

+ 5 - 1
src/components/Header.vue

@@ -1,5 +1,5 @@
 <script setup lang="ts">
-import {UserFilled, SwitchButton} from "@element-plus/icons-vue";
+import {CirclePlus, UserFilled, SwitchButton} from "@element-plus/icons-vue";
 import {ref} from 'vue';
 
 const searchContent = ref('')
@@ -48,6 +48,10 @@ function search() {
 
 
         <div class="flex items-center space-x-4 mx-3">
+          <router-link to="/manager/createStore" v-slot="{navigate}">
+            <el-icon @click="navigate" :size="30" color="white" ><CirclePlus /></el-icon>
+          </router-link>
+
           <router-link to="/dashboard" v-slot="{navigate}">
             <el-icon @click="navigate" :size="30" color="white" ><UserFilled /></el-icon>
           </router-link>

+ 24 - 12
src/views/MANAGER/createStore.vue

@@ -1,12 +1,13 @@
 <script setup lang="ts">
-import {ElForm, ElFormItem, ElMessage} from "element-plus";
-import {ref, computed} from 'vue';
-import {createStore} from "../../api/store.ts";
-import {uploadFile} from "../../api/tool.ts";
+import {ElForm, ElFormItem, ElMessage} from "element-plus"
+import {computed, ref} from 'vue'
+import {createStore} from "../../api/store.ts"
+import {uploadImage} from "../../api/image.ts"
 
 // 输入框值
-const name = ref('');
+const name = ref('')
 const location = ref('')
+const logoURL = ref('')
 
 // 用于前端阻拦不合法输入
 const hasNameInput = computed(() => name.value != '')
@@ -40,11 +41,22 @@ function drop(e) {
 }
 
 function generateURL(file) {
-  let fileSrc = URL.createObjectURL(file);
-  setTimeout(() => {
-    URL.revokeObjectURL(fileSrc);
-  }, 1000);
-  return fileSrc;
+  console.log(document.cookie.split(";")[0].split("=")[1])
+  const payload = {
+    file: files[0]
+  };
+  uploadImage(payload).then(res => {
+    console.log(res);
+    this.logoURL = res.value;
+    console.log(this.logoURL);
+    return this.logoUrl;
+  });
+  // let fileSrc = URL.createObjectURL(file);
+  // setTimeout(() => {
+  //   URL.revokeObjectURL(fileSrc);
+  // }, 1000);
+  // console.log(fileSrc);
+  // return fileSrc;
 }
 
 function remove(i) {
@@ -66,7 +78,7 @@ function handleCreateStore() {
     file: files[0]
   };
   createStore(payload1).then(res => {
-    uploadFile(payload2).then(res => {
+    uploadImage(payload2).then(res => {
       ElMessage.success(`添加商户成功!`);
     });
   });
@@ -76,7 +88,7 @@ function handleCreateStore() {
 </script>
 
 <template>
-  <div class="flex flex-col items-center justify-center px-6 py-6 space-y-10 min-h-screen">
+  <div class="flex flex-col items-center justify-center px-6 py-6 space-y-10">
 
     <span class="flex items-center text-2xl font-semibold text-gray-900">
       Blue Whale Shopping Online