fengyu пре 2 месеци
родитељ
комит
ba1f65e857
2 измењених фајлова са 88 додато и 9 уклоњено
  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 3
  * @Author: Fengyu
4 4
  * @Date: 2025-12-12 14:00:09
5 5
  * @LastEditors: Fengyu
6
- * @LastEditTime: 2025-12-15 17:16:22
6
+ * @LastEditTime: 2025-12-15 17:34:10
7 7
  */
8 8
 import { http } from '@/utils/http'
9 9
 
@@ -30,4 +30,17 @@ export const submitQuestionnaireApi = (data: any) => {
30 30
     url: '/questionnaire/answer',
31 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 3
  * @Author: Fengyu
4 4
  * @Date: 2025-12-12 10:12:59
5 5
  * @LastEditors: Fengyu
6
- * @LastEditTime: 2025-12-15 17:14:50
6
+ * @LastEditTime: 2025-12-17 10:26:23
7 7
 -->
8 8
 <template>
9 9
   <view class="questionnaire-container">
@@ -33,9 +33,18 @@
33 33
     <!-- 网格选择区域 -->
34 34
     <view class="grid-section">
35 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 45
         <view v-for="(item, index) in dataFilledIn" :key="item.id" class="grid-item">
37 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 48
             <view class="grid-desc">
40 49
               <u-radio-group v-model="item.value">
41 50
                 <u-radio
@@ -52,7 +61,7 @@
52 61
         <!-- 最好的高速 -->
53 62
         <view class="grid-item">
54 63
           <view class="grid-content">
55
-            <view class="grid-title">{{ dataFilledIn.length + 1 }}. 您认为本服务区的最好的高速是?</view>
64
+            <view class="grid-title">{{ dataFilledIn.length + 2 }}. 您认为本服务区的最好的高速是?</view>
56 65
             <view class="grid-desc">
57 66
               <u-input v-model="bestWay" type="textarea" :border="false" :height="100" :auto-height="true" placeholder="请输入您的评价" />
58 67
             </view>
@@ -61,7 +70,7 @@
61 70
         <!-- 最好的服务区 -->
62 71
         <view class="grid-item">
63 72
           <view class="grid-content">
64
-            <view class="grid-title">{{ dataFilledIn.length + 2 }}. 您认为本服务区的最好的服务区是?</view>
73
+            <view class="grid-title">{{ dataFilledIn.length + 3 }}. 您认为本服务区的最好的服务区是?</view>
65 74
             <view class="grid-desc">
66 75
               <u-input v-model="bestService" type="textarea" :border="false" :height="100" :auto-height="true" placeholder="请输入您的评价" />
67 76
             </view>
@@ -78,7 +87,7 @@
78 87
 
79 88
 <script setup>
80 89
   import { ref, onMounted } from 'vue'
81
-  import { getQuestionnaireDetailApi, submitQuestionnaireApi } from '@/api/investigation'
90
+  import { getQuestionnaireDetailApi, submitQuestionnaireApi, getParkList } from '@/api/investigation'
82 91
 
83 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 190
   const bestWay = ref('')
142 191
 
@@ -148,7 +197,7 @@
148 197
 
149 198
   // 问卷信息
150 199
   const questionnaireInfo = ref({
151
-    id: '',
200
+    // id: '',
152 201
     name: '',
153 202
     endAt: '',
154 203
     fileId: 0,
@@ -157,6 +206,7 @@
157 206
 
158 207
   // 根据页面参数获取问卷详情
159 208
   onMounted(() => {
209
+    getParkListApi()
160 210
     // 使用URLSearchParams正确解析URL参数
161 211
     const urlParams = new URLSearchParams(window.location.search);
162 212
     const questionnaireId = urlParams.get('id');
@@ -204,10 +254,19 @@
204 254
         });
205 255
         return;
206 256
       }
257
+
258
+      if (!parkId.value) {
259
+        uni.showToast({
260
+          title: '请选择服务区',
261
+          icon: 'none'
262
+        });
263
+        return;
264
+      }
207 265
       
208 266
       // 解析URL参数
209 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 270
       // const parkid = parseInt(urlParams.get('parkid')) || 0; // 与API参数名保持一致
212 271
       const mobile = urlParams.get('m') || '';
213 272
       
@@ -240,7 +299,9 @@
240 299
         targetF: parseInt(dataFilledIn.value.find(item => item.id === 6)?.value) || 0, // 车辆维修站
241 300
         targetG: parseInt(dataFilledIn.value.find(item => item.id === 7)?.value) || 0, // 总体评价
242 301
         bestWay: bestWay.value, // 最好的高速
243
-        bestService: bestService.value // 最好的服务区
302
+        bestService: bestService.value, // 最好的服务区
303
+        parkId: parkId.value,
304
+        // id: questionnaireId
244 305
       };
245 306
       
246 307
       // 构建完整参数对象,确保与API要求一致
@@ -260,6 +321,11 @@
260 321
             title: '感谢您的反馈!',
261 322
             icon: 'success'
262 323
           });
324
+          setTimeout(() => {
325
+            uni.redirectTo({
326
+              url: '/pages/index'
327
+            })
328
+          }, 2000);
263 329
         } else {
264 330
           uni.showToast({
265 331
             title: res.message || '提交失败,请重试',