Przeglądaj źródła

Merge branch 'develop' of http://gogs.zlhuiyun.com/szr190/ShenhaiH5 into develop

szr190 2 miesięcy temu
rodzic
commit
327c670160
2 zmienionych plików z 88 dodań i 9 usunięć
  1. 14 1
      src/api/investigation.ts
  2. 74 8
      src/pages/questionnaire.vue

+ 14 - 1
src/api/investigation.ts

@@ -3,7 +3,7 @@
3
  * @Author: Fengyu
3
  * @Author: Fengyu
4
  * @Date: 2025-12-12 14:00:09
4
  * @Date: 2025-12-12 14:00:09
5
  * @LastEditors: Fengyu
5
  * @LastEditors: Fengyu
6
- * @LastEditTime: 2025-12-15 17:16:22
6
+ * @LastEditTime: 2025-12-15 17:34:10
7
  */
7
  */
8
 import { http } from '@/utils/http'
8
 import { http } from '@/utils/http'
9
 
9
 
@@ -30,4 +30,17 @@ export const submitQuestionnaireApi = (data: any) => {
30
     url: '/questionnaire/answer',
30
     url: '/questionnaire/answer',
31
     data
31
     data
32
   })
32
   })
33
+}
34
+
35
+/**
36
+ * @description: 获取服务区
37
+ * @param {*} data
38
+ * @return {*}
39
+ */
40
+export const getParkList = (data: any) => {
41
+  return http({
42
+    method: 'GET',
43
+    url: '/space/park/select/web',
44
+    data
45
+  })
33
 }
46
 }

+ 74 - 8
src/pages/questionnaire.vue

@@ -3,7 +3,7 @@
3
  * @Author: Fengyu
3
  * @Author: Fengyu
4
  * @Date: 2025-12-12 10:12:59
4
  * @Date: 2025-12-12 10:12:59
5
  * @LastEditors: Fengyu
5
  * @LastEditors: Fengyu
6
- * @LastEditTime: 2025-12-15 17:14:50
6
+ * @LastEditTime: 2025-12-17 10:26:23
7
 -->
7
 -->
8
 <template>
8
 <template>
9
   <view class="questionnaire-container">
9
   <view class="questionnaire-container">
@@ -33,9 +33,18 @@
33
     <!-- 网格选择区域 -->
33
     <!-- 网格选择区域 -->
34
     <view class="grid-section">
34
     <view class="grid-section">
35
       <view class="grid-container">
35
       <view class="grid-container">
36
+        <view class="grid-item">
37
+          <view class="grid-content flex j-sb a-center">
38
+            <view class="grid-title">1.您所在的服务区</view>
39
+            <view class="grid-desc">
40
+              <u-select v-model="parkSelectShow" :list="parkList" @confirm="confirm"></u-select>
41
+              <span @click="parkSelectShow = true">{{ parkName || '请选择' }}</span>
42
+            </view>
43
+          </view>
44
+        </view>
36
         <view v-for="(item, index) in dataFilledIn" :key="item.id" class="grid-item">
45
         <view v-for="(item, index) in dataFilledIn" :key="item.id" class="grid-item">
37
           <view class="grid-content">
46
           <view class="grid-content">
38
-            <view class="grid-title">{{ index + 1 }}. {{ item.name }}</view>
47
+            <view class="grid-title">{{ index + 2 }}. {{ item.name }}</view>
39
             <view class="grid-desc">
48
             <view class="grid-desc">
40
               <u-radio-group v-model="item.value">
49
               <u-radio-group v-model="item.value">
41
                 <u-radio
50
                 <u-radio
@@ -52,7 +61,7 @@
52
         <!-- 最好的高速 -->
61
         <!-- 最好的高速 -->
53
         <view class="grid-item">
62
         <view class="grid-item">
54
           <view class="grid-content">
63
           <view class="grid-content">
55
-            <view class="grid-title">{{ dataFilledIn.length + 1 }}. 您认为本服务区的最好的高速是?</view>
64
+            <view class="grid-title">{{ dataFilledIn.length + 2 }}. 您认为本服务区的最好的高速是?</view>
56
             <view class="grid-desc">
65
             <view class="grid-desc">
57
               <u-input v-model="bestWay" type="textarea" :border="false" :height="100" :auto-height="true" placeholder="请输入您的评价" />
66
               <u-input v-model="bestWay" type="textarea" :border="false" :height="100" :auto-height="true" placeholder="请输入您的评价" />
58
             </view>
67
             </view>
@@ -61,7 +70,7 @@
61
         <!-- 最好的服务区 -->
70
         <!-- 最好的服务区 -->
62
         <view class="grid-item">
71
         <view class="grid-item">
63
           <view class="grid-content">
72
           <view class="grid-content">
64
-            <view class="grid-title">{{ dataFilledIn.length + 2 }}. 您认为本服务区的最好的服务区是?</view>
73
+            <view class="grid-title">{{ dataFilledIn.length + 3 }}. 您认为本服务区的最好的服务区是?</view>
65
             <view class="grid-desc">
74
             <view class="grid-desc">
66
               <u-input v-model="bestService" type="textarea" :border="false" :height="100" :auto-height="true" placeholder="请输入您的评价" />
75
               <u-input v-model="bestService" type="textarea" :border="false" :height="100" :auto-height="true" placeholder="请输入您的评价" />
67
             </view>
76
             </view>
@@ -78,7 +87,7 @@
78
 
87
 
79
 <script setup>
88
 <script setup>
80
   import { ref, onMounted } from 'vue'
89
   import { ref, onMounted } from 'vue'
81
-  import { getQuestionnaireDetailApi, submitQuestionnaireApi } from '@/api/investigation'
90
+  import { getQuestionnaireDetailApi, submitQuestionnaireApi, getParkList } from '@/api/investigation'
82
 
91
 
83
   const dataList = ref([
92
   const dataList = ref([
84
     {
93
     {
@@ -137,6 +146,46 @@
137
     }
146
     }
138
   ])
147
   ])
139
 
148
 
149
+  // 服务区选择框是否显示
150
+  const parkSelectShow = ref(false)
151
+
152
+  // 服务区列表
153
+  const parkList = ref([])
154
+
155
+  const parkId = ref('')
156
+  const parkName = ref('')
157
+
158
+  // 获取服务区列表
159
+  const getParkListApi = () => {
160
+    getParkList().then(res => {
161
+      if (res.code === 200) {
162
+        parkList.value = res.data.map(item => ({
163
+          label: item.name,
164
+          value: item.id
165
+        }))
166
+      } else {
167
+        uni.showToast({
168
+          title: res.message || '获取服务区列表失败',
169
+          icon: 'none'
170
+        });
171
+      }
172
+    }).catch(err => {
173
+      console.error('获取服务区列表失败:', err);
174
+      uni.showToast({
175
+        title: err.data.msg ||'网络错误,请重试',
176
+        icon: 'none'
177
+      });
178
+    });
179
+  }
180
+
181
+  // 选择服务区
182
+  const confirm = (e) => {
183
+    console.log(e[0].value, e[0].label)
184
+    parkId.value = e[0].value
185
+    parkName.value = e[0].label
186
+  }
187
+  
188
+
140
   // 最好的高速
189
   // 最好的高速
141
   const bestWay = ref('')
190
   const bestWay = ref('')
142
 
191
 
@@ -148,7 +197,7 @@
148
 
197
 
149
   // 问卷信息
198
   // 问卷信息
150
   const questionnaireInfo = ref({
199
   const questionnaireInfo = ref({
151
-    id: '',
200
+    // id: '',
152
     name: '',
201
     name: '',
153
     endAt: '',
202
     endAt: '',
154
     fileId: 0,
203
     fileId: 0,
@@ -157,6 +206,7 @@
157
 
206
 
158
   // 根据页面参数获取问卷详情
207
   // 根据页面参数获取问卷详情
159
   onMounted(() => {
208
   onMounted(() => {
209
+    getParkListApi()
160
     // 使用URLSearchParams正确解析URL参数
210
     // 使用URLSearchParams正确解析URL参数
161
     const urlParams = new URLSearchParams(window.location.search);
211
     const urlParams = new URLSearchParams(window.location.search);
162
     const questionnaireId = urlParams.get('id');
212
     const questionnaireId = urlParams.get('id');
@@ -204,10 +254,19 @@
204
         });
254
         });
205
         return;
255
         return;
206
       }
256
       }
257
+
258
+      if (!parkId.value) {
259
+        uni.showToast({
260
+          title: '请选择服务区',
261
+          icon: 'none'
262
+        });
263
+        return;
264
+      }
207
       
265
       
208
       // 解析URL参数
266
       // 解析URL参数
209
       const urlParams = new URLSearchParams(window.location.search);
267
       const urlParams = new URLSearchParams(window.location.search);
210
-      const questionnaireId = parseInt(questionnaireInfo.value.id) || 0;
268
+      const questionnaireId = questionnaireInfo.value.id || 0;
269
+      // const questionnaireId = '2000476937984221185' || 0;
211
       // const parkid = parseInt(urlParams.get('parkid')) || 0; // 与API参数名保持一致
270
       // const parkid = parseInt(urlParams.get('parkid')) || 0; // 与API参数名保持一致
212
       const mobile = urlParams.get('m') || '';
271
       const mobile = urlParams.get('m') || '';
213
       
272
       
@@ -240,7 +299,9 @@
240
         targetF: parseInt(dataFilledIn.value.find(item => item.id === 6)?.value) || 0, // 车辆维修站
299
         targetF: parseInt(dataFilledIn.value.find(item => item.id === 6)?.value) || 0, // 车辆维修站
241
         targetG: parseInt(dataFilledIn.value.find(item => item.id === 7)?.value) || 0, // 总体评价
300
         targetG: parseInt(dataFilledIn.value.find(item => item.id === 7)?.value) || 0, // 总体评价
242
         bestWay: bestWay.value, // 最好的高速
301
         bestWay: bestWay.value, // 最好的高速
243
-        bestService: bestService.value // 最好的服务区
302
+        bestService: bestService.value, // 最好的服务区
303
+        parkId: parkId.value,
304
+        // id: questionnaireId
244
       };
305
       };
245
       
306
       
246
       // 构建完整参数对象,确保与API要求一致
307
       // 构建完整参数对象,确保与API要求一致
@@ -260,6 +321,11 @@
260
             title: '感谢您的反馈!',
321
             title: '感谢您的反馈!',
261
             icon: 'success'
322
             icon: 'success'
262
           });
323
           });
324
+          setTimeout(() => {
325
+            uni.redirectTo({
326
+              url: '/pages/index'
327
+            })
328
+          }, 2000);
263
         } else {
329
         } else {
264
           uni.showToast({
330
           uni.showToast({
265
             title: res.message || '提交失败,请重试',
331
             title: res.message || '提交失败,请重试',