Переглянути джерело

feat: 新增咨询接口请求

Lee 1 день тому
батько
коміт
d31f618fb7
7 змінених файлів з 74 додано та 61 видалено
  1. 4 15
      .env.development
  2. 6 12
      .env.production
  3. 5 13
      .env.test
  4. 25 0
      app/api/index.ts
  5. 29 15
      app/components/consultation-modal.vue
  6. 1 2
      app/constants/index.ts
  7. 4 4
      nuxt.config.ts

+ 4 - 15
.env.development

@@ -5,23 +5,12 @@
  # @LastEditTime: 2026-01-09 14:32:31
  # @Description: 
 ### 
-NUXT_ENV = 'development'
+NUXT_ENV='development'
 
-# base url
-NUXT_APP_BASE_URL = '/'
+# 接口请求基础路径 (指向本地代理)
+NUXT_PUBLIC_API_BASE='/api'
 
-# # 官网地址
-# VITE_INDEX_URL = "https://wisdomcity.eu.org:30032"
-
-# # 评价系统地址
-# VITE_ADMIN_URL = "https://wisdomcity.eu.org:3003"
 
 # # api地址
-# VITE_API_URL = "/yyds"
-
-# # base api
-# NUXT_PUBLIC_API_BASE = 'https://wisdomcity.eu.org:30032/yyds'
-
+VITE_API_URL="/api"
 
-# # local proxy pre url
-# NUXT_APP_PROXY_PRE_URL = '/'

+ 6 - 12
.env.production

@@ -6,22 +6,16 @@
  # @Description: 
 ### 
 # mode
-NUXT_ENV = 'production'
+NUXT_ENV='production'
 
 # base url
-NUXT_APP_BASE_URL = '/'
+NUXT_APP_BASE_URL='/'
 
-# # 官网地址
-# VITE_INDEX_URL = "https://www.hnwx.org.cn"
-
-# # 评价系统地址
-# VITE_ADMIN_URL = "https://cr.hnwx.org.cn"
+# 生产环境后端完整地址
+NUXT_PUBLIC_API_BASE='https://wy.huiguanjia.cn/9ad134a361f8d778'
 
 # # api地址
-# VITE_API_URL = "https://www.hnwx.org.cn/yyds"
+VITE_API_URL='https://wy.huiguanjia.cn/9ad134a361f8d778'
+
 
-# # base api
-# NUXT_PUBLIC_API_BASE = 'https://www.hnwx.org.cn/yyds'
 
-# # local proxy pre url
-# NUXT_APP_PROXY_PRE_URL = ''

+ 5 - 13
.env.test

@@ -5,22 +5,14 @@
  # @LastEditTime: 2026-01-09 14:32:42
  # @Description: 
 ### 
-NUXT_ENV = 'test'
+NUXT_ENV='test'
 
 # base url
-NUXT_APP_BASE_URL = '/'
+NUXT_APP_BASE_URL='/'
 
-# # 官网地址
-# VITE_INDEX_URL = "https://wisdomcity.eu.org:30032"
 
-# # 评价系统地址
-# VITE_ADMIN_URL = "https://wisdomcity.eu.org:3003"
+# 测试环境后端完整地址
+NUXT_PUBLIC_API_BASE='https://wy-test.huiguanjia.cn/9ad134a361f8d778'
 
 # # api地址
-# VITE_API_URL = "https://wisdomcity.eu.org:30032/yyds"
-
-# # base api
-# NUXT_PUBLIC_API_BASE = 'https://wisdomcity.eu.org:30030/yyds'
-
-# # local proxy pre url
-# NUXT_APP_PROXY_PRE_URL = '/'
+VITE_API_URL='https://wy-test.huiguanjia.cn/9ad134a361f8d778'

+ 25 - 0
app/api/index.ts

@@ -0,0 +1,25 @@
+/*
+ * @Author: LiZhiWei
+ * @Date: 2026-01-15 17:49:31
+ * @LastEditors: LiZhiWei
+ * @LastEditTime: 2026-01-23 16:09:37
+ * @Description:
+ */
+import { http } from '~/utils/fetch'
+
+/**
+ * 申请入驻
+ * @param params { company: string, contacts: string, phone: string, remark: string }
+ */
+export const applyPartner = (data: {
+  company: string
+  contacts: string
+  phone: string
+  remark: string
+}) => {
+  return http.request({
+    url: '/app/hgj/partners',
+    method: 'POST',
+    data,
+  })
+}

+ 29 - 15
app/components/consultation-modal.vue

@@ -46,7 +46,7 @@
                   @submit.prevent="handleSubmit"
                 >
                   <!-- Name -->
-                  <el-form-item prop="name" class="custom-form-item">
+                  <el-form-item prop="contacts" class="custom-form-item">
                     <template #label>
                       <span class="form-label">
                         您的称谓
@@ -55,7 +55,7 @@
                     </template>
                     <div class="flex gap-28px w-full lt-sm:flex-col lt-sm:gap-12px">
                       <el-input
-                        v-model="form.name"
+                        v-model="form.contacts"
                         placeholder="请输入您的称谓"
                         class="custom-input flex-1 lt-sm:w-full"
                       />
@@ -63,8 +63,8 @@
                         v-model="form.gender"
                         class="shrink-0 flex-1 lt-sm:w-full lt-sm:justify-start"
                       >
-                        <el-radio value="mr">先生</el-radio>
-                        <el-radio value="ms">女士</el-radio>
+                        <el-radio value="先生">先生</el-radio>
+                        <el-radio value="女士">女士</el-radio>
                       </el-radio-group>
                     </div>
                   </el-form-item>
@@ -101,7 +101,7 @@
                   <!-- Description -->
                   <el-form-item prop="desc" class="custom-form-item">
                     <el-input
-                      v-model="form.desc"
+                      v-model="form.remark"
                       type="textarea"
                       placeholder="简要描述您的需求 (可选)"
                       class="custom-textarea w-full"
@@ -113,8 +113,9 @@
                   <!-- Submit Button -->
                   <button
                     v-loading="loading"
-                    class="mt-56px h-48px w-268px bg-#0F67F8 text-white pf-sc-regular rounded-8px px-16px flex items-center justify-between hover:opacity-80 lt-sm:w-453px lt-sm:m-auto lt-sm:rounded-16px lt-sm:h-84px lt-sm:mt-60px lt-sm:justify-between lt-sm:gap-8px"
-                    @click="handleSubmit"
+                    type="submit"
+                    :disabled="loading"
+                    class="mt-56px h-48px w-268px bg-#0F67F8 text-white pf-sc-regular rounded-8px px-16px flex items-center justify-between hover:opacity-80 disabled:opacity-50 disabled:cursor-not-allowed lt-sm:w-453px lt-sm:m-auto lt-sm:rounded-16px lt-sm:h-84px lt-sm:mt-60px lt-sm:justify-between lt-sm:gap-8px"
                   >
                     <span class="font-s-16px lt-sm:hidden">立即咨询</span>
                     <span class="hidden lt-sm:block lt-sm:font-s-26px">提交需求,获取专属方案</span>
@@ -159,7 +160,7 @@
 
 <script setup lang="ts">
   import type { FormInstance, FormRules } from 'element-plus'
-
+  import { applyPartner } from '~/api'
   const props = defineProps<{
     modelValue: boolean
   }>()
@@ -175,15 +176,15 @@
   const loading = ref(false)
 
   const form = reactive({
-    name: '',
-    gender: 'mr',
+    contacts: '',
+    gender: '先生',
     phone: '',
     company: '',
-    desc: '',
+    remark: '',
   })
 
   const rules = reactive<FormRules>({
-    name: [{ required: true, message: '请输入您的称谓', trigger: 'blur' }],
+    contacts: [{ required: true, message: '请输入您的称谓', trigger: 'blur' }],
     phone: [{ required: true, message: '请输入您的手机号码', trigger: 'blur' }],
     company: [{ required: true, message: '请输入公司名称或项目地址', trigger: 'blur' }],
   })
@@ -194,12 +195,25 @@
     emit('update:modelValue', false)
   }
 
-  const handleSubmit = async () => {
+  const handleSubmit = () => {
     if (!formRef.value) return
 
-    await formRef.value.validate((valid) => {
+    formRef.value.validate((valid) => {
       if (valid) {
-        close()
+        loading.value = true
+        applyPartner({
+          company: form.company,
+          contacts: form.contacts + form.gender,
+          phone: form.phone,
+          remark: form.remark || '无',
+        })
+          .then(() => {
+            ElMessage.success('提交成功,我们会尽快与您联系')
+          })
+          .finally(() => {
+            close()
+            loading.value = false
+          })
       }
     })
   }

+ 1 - 2
app/constants/index.ts

@@ -2,7 +2,7 @@
  * @Author: LiZhiWei
  * @Date: 2026-01-13 15:01:49
  * @LastEditors: LiZhiWei
- * @LastEditTime: 2026-01-15 17:50:20
+ * @LastEditTime: 2026-01-23 14:58:37
  * @Description:
  */
 import type { Config } from '~/types/config'
@@ -44,7 +44,6 @@ const config: Config = {
      * If you want to also use it in dev, you can pass ['production', 'development']
      */
     errorLog: ['production', 'development'],
-    fileUrl: '/yyds/file/download/',
   },
 }
 

+ 4 - 4
nuxt.config.ts

@@ -3,7 +3,7 @@
  * @Author: wjc
  * @Date: 2023-10-25 19:39:32
  * @LastEditors: LiZhiWei
- * @LastEditTime: 2026-01-23 10:00:14
+ * @LastEditTime: 2026-01-23 14:53:26
  * @Description:
  */
 import { loadEnv } from 'vite'
@@ -65,11 +65,11 @@ export default defineNuxtConfig({
   },
   nitro: {
     devProxy: {
-      '/yyds': {
-        target: 'https://wisdomcity.eu.org:30032/yyds',
+      '/api': {
+        target: 'https://wy-test.huiguanjia.cn/9ad134a361f8d778',
         changeOrigin: true,
         prependPath: true,
-        secure: false,
+        secure: true,
       },
     },
   },