Explorar el Código

fix: 服务区信息联调

szr190 hace 2 meses
padre
commit
83831560a3
Se han modificado 6 ficheros con 738 adiciones y 537 borrados
  1. 8 0
      src/api/home.ts
  2. 1 1
      src/manifest.json
  3. 7 0
      src/pages.json
  4. 171 0
      src/pages/parkInfo.vue
  5. 550 535
      src/pages/questionnaire.vue
  6. 1 1
      vite.config.ts

+ 8 - 0
src/api/home.ts

@@ -195,3 +195,11 @@ export const getBannerApi = () => {
195
     url: '/operate/banner/web'
195
     url: '/operate/banner/web'
196
   })
196
   })
197
 }
197
 }
198
+
199
+// 服务区信息
200
+export function getParkInfo(id: string) {
201
+  return http({
202
+    url: '/space/park/' + id,
203
+    method: 'GET'
204
+  })
205
+}

+ 1 - 1
src/manifest.json

@@ -54,7 +54,7 @@
54
     "quickapp" : {},
54
     "quickapp" : {},
55
     "h5" : {
55
     "h5" : {
56
         "router" : {
56
         "router" : {
57
-            "base" : "/h5/",
57
+            "base" : "/",
58
             "mode" : "history"
58
             "mode" : "history"
59
         },
59
         },
60
         "sdkConfigs" : {
60
         "sdkConfigs" : {

+ 7 - 0
src/pages.json

@@ -30,6 +30,13 @@
30
         "enablePullDownRefresh": false,
30
         "enablePullDownRefresh": false,
31
         "navigationStyle": "custom"
31
         "navigationStyle": "custom"
32
       }
32
       }
33
+    },
34
+    {
35
+      "path": "pages/parkInfo",
36
+      "style": {
37
+        "navigationBarTitleText": "服务区信息",
38
+        "enablePullDownRefresh": false
39
+      }
33
     }
40
     }
34
   ],
41
   ],
35
   "subPackages": [
42
   "subPackages": [

+ 171 - 0
src/pages/parkInfo.vue

@@ -0,0 +1,171 @@
1
+<template>
2
+  <view>
3
+    <u-swiper :list="parkInfo.images" :height="400" border-radius="0"></u-swiper>
4
+    <view class="park-info-container">
5
+      <view class="park-info-wrapper">
6
+        <view class="info-title">基本信息</view>
7
+        <view class="info-item">
8
+          <view class="info-item-left">服务区类型</view>
9
+          <view class="info-item-value">{{ parkInfo.cate ? ['', '服务区', '停车区'][parkInfo.cate] : '' }}</view>
10
+        </view>
11
+        <view class="info-item">
12
+          <view class="info-item-left">地区</view>
13
+          <view class="info-item-value"> {{ parkInfo.provinceName }} {{ parkInfo.cityName }} {{ parkInfo.districtName || '' }} </view>
14
+        </view>
15
+        <view class="info-item">
16
+          <view class="info-item-left">负责人</view>
17
+          <view class="info-item-value">{{ parkInfo.leader }}</view>
18
+        </view>
19
+        <view class="info-item">
20
+          <view class="info-item-left">联系方式</view>
21
+          <view class="info-item-value">{{ parkInfo.mobile }}</view>
22
+        </view>
23
+        <view class="info-item">
24
+          <view class="info-item-left">服务区级别</view>
25
+          <view class="info-item-value">{{ parkInfo.level ? handleMate(parkInfo.level, levelList) : '' }}</view>
26
+        </view>
27
+        <view class="info-item">
28
+          <view class="info-item-left">排序</view>
29
+          <view class="info-item-value">{{ parkInfo.sort }}</view>
30
+        </view>
31
+        <view class="info-item">
32
+          <view class="info-item-left">占地面积</view>
33
+          <view class="info-item-value">{{ parkInfo.area }}</view>
34
+        </view>
35
+        <view class="info-item">
36
+          <view class="info-item-left">地址</view>
37
+          <view class="info-item-value">{{ parkInfo.address }}</view>
38
+        </view>
39
+        <!-- <view class="info-item">
40
+          <view class="info-item-left">服务区图片</view>
41
+          <view class="info-item-value">
42
+            <view v-for="(item, index) in parkInfo.images" :key="index">
43
+              <image :src="item" mode="aspectFill" style="width: 200rpx; height: 80rpx" @click="previewImage(parkInfo.images, index)" />
44
+            </view>
45
+          </view>
46
+        </view> -->
47
+        <view class="info-item" style="align-items: flex-start">
48
+          <view class="info-item-left">服务区介绍</view>
49
+          <view class="info-item-value">{{ parkInfo.points }}</view>
50
+        </view>
51
+        <view class="info-item">
52
+          <view class="info-item-left"></view>
53
+          <view class="info-item-value"></view>
54
+        </view>
55
+      </view>
56
+      <view class="park-info-wrapper">
57
+        <view class="info-title">详情信息</view>
58
+        <u-parse :html="parkInfo.introduce"></u-parse>
59
+      </view>
60
+    </view>
61
+  </view>
62
+</template>
63
+
64
+<script lang="ts" setup>
65
+import { ref } from 'vue'
66
+import { onLoad } from '@dcloudio/uni-app'
67
+import { getParkInfo } from '@/api/home'
68
+import { getDictTypeApi } from '@/api/system'
69
+
70
+const id = ref('')
71
+onLoad((options) => {
72
+  id.value = options?.id || '2001933922038382593'
73
+  getParkInfoFn()
74
+  getLevelListFn()
75
+})
76
+
77
+const parkInfo = ref<any>({})
78
+const getParkInfoFn = async () => {
79
+  const res = await getParkInfo(id.value)
80
+  if (res.code === 200) {
81
+    if (res.data) {
82
+      parkInfo.value = res.data
83
+      // 图片处理
84
+      parkInfo.value.images = parkInfo.value.images.map((item: { filePath: string }) => item.filePath)
85
+      // 标题处理
86
+      uni.setNavigationBarTitle({
87
+        title: parkInfo.value.name || ''
88
+      })
89
+    }
90
+  }
91
+}
92
+
93
+// 获取服务区级别
94
+const levelList = ref<any>([])
95
+const getLevelListFn = async () => {
96
+  const res = await getDictTypeApi('space_park_level')
97
+  if (res.code === 200) {
98
+    if (res.data) {
99
+      levelList.value = res.data
100
+    }
101
+  }
102
+}
103
+
104
+// 数组数据匹配
105
+const handleMate = (data: any, list: any[]) => {
106
+  const value = list.filter((item: { id: any; value: any; dictValue: string }) => {
107
+    return item.id === data || item.value === data || item.dictValue === String(data)
108
+  })
109
+  if (value && value.length) {
110
+    return value[0].name || value[0].label || value[0].dictLabel
111
+  }
112
+}
113
+
114
+// 图片预览功能
115
+const previewImage = (pics: string[], currentIndex: number) => {
116
+  // 将图片路径转换为完整路径
117
+  const fullImageList = pics.map((pic) => pic)
118
+
119
+  // 调用uni的图片预览API
120
+  uni.previewImage({
121
+    current: fullImageList[currentIndex], // 当前显示图片的http链接
122
+    urls: fullImageList, // 需要预览的图片http链接列表
123
+    loop: true // 是否可循环预览
124
+  })
125
+}
126
+</script>
127
+
128
+<style scoped lang="scss">
129
+.park-info-container {
130
+  box-sizing: border-box;
131
+  padding: 24rpx;
132
+  .park-info-wrapper {
133
+    background-color: #fff;
134
+    padding: 30rpx;
135
+    border-radius: 14rpx;
136
+    margin-bottom: 24rpx;
137
+    .info-title {
138
+      font-size: 32rpx;
139
+      color: #1d2129;
140
+      font-weight: bold;
141
+      margin-bottom: 24rpx;
142
+    }
143
+    .info-item {
144
+      display: flex;
145
+      align-items: center;
146
+      justify-content: space-between;
147
+      border-bottom: 1rpx solid #e5e8ed;
148
+      padding: 24rpx 0;
149
+      &:first-child {
150
+        padding-top: 0;
151
+      }
152
+      &:last-child {
153
+        border-bottom: none;
154
+        padding-bottom: 0;
155
+      }
156
+      .info-item-left {
157
+        font-size: 28rpx;
158
+        color: #1d2129;
159
+        width: 200rpx;
160
+      }
161
+      .info-item-value {
162
+        flex: 1;
163
+        font-size: 28rpx;
164
+        color: #737880;
165
+        display: flex;
166
+        justify-content: flex-end;
167
+      }
168
+    }
169
+  }
170
+}
171
+</style>

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 550 - 535
src/pages/questionnaire.vue


+ 1 - 1
vite.config.ts

@@ -8,7 +8,7 @@ export default defineConfig(({ command, mode }) => {
8
   if (mode === 'development' || mode === 'sandbox') {
8
   if (mode === 'development' || mode === 'sandbox') {
9
     // 测试环境配置
9
     // 测试环境配置
10
     return {
10
     return {
11
-      base: '/h5/',
11
+      // base: '/h5/',
12
       plugins: [uni()],
12
       plugins: [uni()],
13
       // envDir: resolve(__dirname, 'env'),
13
       // envDir: resolve(__dirname, 'env'),
14
       define: {
14
       define: {