zhengnaiwen_citu 5 mesi fa
parent
commit
cc6ad11002
2 ha cambiato i file con 54 aggiunte e 17 eliminazioni
  1. 14 0
      api/common.js
  2. 40 17
      pagesB/headhunting/pages/contact.vue

+ 14 - 0
api/common.js

@@ -319,4 +319,18 @@ export const getWebContent = async () => {
       auth: false
     }
   })
+}
+
+// 联系我们
+// 提交猎寻服务
+export const huntSubmit = async (data) => {
+  return request({
+    url: '/admin-api/menduner/system/hunt/submit',
+    method: 'POST',
+    data,
+    custom: {
+      showLoading: false,
+      auth: false
+    }
+  })
 }

+ 40 - 17
pagesB/headhunting/pages/contact.vue

@@ -1,38 +1,61 @@
 <template>
   <view class="pa-3">
-    <uni-forms ref="baseForm" :modelValue="baseFormData">
-      <uni-forms-item label="姓名" required  label-width="100">
+    <uni-forms ref="baseForm" v-model="baseFormData" validateTrigger="bind" :rules="rules" label-width="100px" label-align="right">
+      <uni-forms-item label="姓名" required  >
         <uni-easyinput v-model="baseFormData.name" placeholder="请输入姓名" />
       </uni-forms-item>
-      <uni-forms-item label="手机号" required  label-width="100">
+      <uni-forms-item label="联系手机号" required >
         <uni-easyinput v-model="baseFormData.phone" placeholder="请输入联系手机号" />
       </uni-forms-item>
-      <uni-forms-item label="企业名称" required  label-width="100">
+      <uni-forms-item label="企业名称" required>
         <uni-easyinput v-model="baseFormData.enterpriseName" placeholder="请输入企业名称" />
       </uni-forms-item>
+      <button type="primary" @click="submit">提交</button>
     </uni-forms>
-    <button type="primary" @click="submit">提交</button>
   </view>
 </template>
 
 <script setup>
-import { ref } from 'vue'
+import { ref, unref } from 'vue'
+import { huntSubmit } from '@/api/common'
 const baseForm = ref()
 const baseFormData = ref({
-  name: '',
-  phone: '',
-  enterpriseName: ''
+  name: null,
+  phone: null,
+  enterpriseName: null
 })
+const rules = {
+  name: {
+    rules: [{
+      required: true,
+      errorMessage: '姓名不能为空'
+    }]
+  },
+  phone: {
+    rules: [{required: true, errorMessage: '请输入手机号码' }]
+  },
+  enterpriseName: {
+    rules: [{required: true, errorMessage: '请输入企业名称' }]
+  }
+}
 const submit = async () => {
-  await baseForm.value.validate()
+  try {
+    const valid = await unref(baseForm).validate()
+    if (!valid) return
 
-  uni.showToast({ title: '保存成功', icon: 'none' })
-  // baseForm.value.validate().then((res) => {
-  //   console.log('表单数据:', res)
-  //   uni.showToast({ title: '保存成功', icon: 'none' })
-  // }).catch((err) => {
-  //   // uni.showToast({ title: err?.msg || '保存失败', icon: 'none' })
-  // })
+    const { code, msg } = await huntSubmit(baseFormData.value)
+    if (code !== 0) {
+      uni.showToast({ title: msg, icon: 'none' })
+      return
+    }
+    uni.showToast({ title: '提交成功,我们会尽快与您联系', icon: 'none', success: () => {
+      setTimeout(() => {
+        uni.navigateBack()
+      }, 1000)
+    } })
+  } catch (error) {
+    console.log('error', error)
+  }
 }
 </script>