hookehuyr

✨ feat: Bob新增需求

1、轮播图能否点开看原图,可以放大缩小
2、轮播图比例4x3显示
3、详情页图片有5个像素的圆角; 4、介绍、故事、体验,如果没有就不显示tab; 靠左对齐;
5、前往按钮根据设置来定,有路径的才显示;
1 <!-- 1 <!--
2 * @Date: 2024-09-15 22:08:49 2 * @Date: 2024-09-15 22:08:49
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2024-09-25 17:24:19 4 + * @LastEditTime: 2024-10-08 10:30:17
5 * @FilePath: /map-demo/src/views/bieyuan/info.vue 5 * @FilePath: /map-demo/src/views/bieyuan/info.vue
6 * @Description: 文件描述 6 * @Description: 文件描述
7 --> 7 -->
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
13 </div> 13 </div>
14 <van-config-provider :theme-vars="themeVars"> 14 <van-config-provider :theme-vars="themeVars">
15 <van-swipe class="my-swipe" indicator-color="#DD7850" lazy-render :autoplay="5000"> 15 <van-swipe class="my-swipe" indicator-color="#DD7850" lazy-render :autoplay="5000">
16 - <van-swipe-item v-for="image in page_details.banner" :key="image"> 16 + <van-swipe-item v-for="(image, index) in page_details.banner" :key="index">
17 - <van-image fit="fill" width="100%" height="15rem" :src="image" /> 17 + <van-image fit="cover" width="100%" :height="img_height" :src="image" @click="onClickImg(index)" />
18 </van-swipe-item> 18 </van-swipe-item>
19 </van-swipe> 19 </van-swipe>
20 </van-config-provider> 20 </van-config-provider>
...@@ -24,24 +24,24 @@ ...@@ -24,24 +24,24 @@
24 <div class="info-header"> 24 <div class="info-header">
25 <div style="display: flex; justify-content: space-between;"> 25 <div style="display: flex; justify-content: space-between;">
26 <p class="info-title">{{ page_details.name }}</p> 26 <p class="info-title">{{ page_details.name }}</p>
27 - <div @click="goTo()" class="info-btn">前往</div> 27 + <div v-if="page_details.path?.length > 1" @click="goTo()" class="info-btn">前往</div>
28 </div> 28 </div>
29 <div class="info-sub-title">{{ page_details.note }}</div> 29 <div class="info-sub-title">{{ page_details.note }}</div>
30 </div> 30 </div>
31 <div style="margin-top: 0.5rem;"> 31 <div style="margin-top: 0.5rem;">
32 <van-config-provider :theme-vars="themeVars"> 32 <van-config-provider :theme-vars="themeVars">
33 - <van-tabs ref="tabsRef" v-model:active="active" @click-tab="clickTab" color="#DD7850" title-active-color="#DD7850" title-inactive-color="#DD7850" sticky animated> 33 + <van-tabs ref="tabsRef" v-model:active="active" @click-tab="clickTab" color="#DD7850" title-active-color="#DD7850" title-inactive-color="#DD7850" :shrink="show_shrink" sticky animated>
34 - <van-tab title="介 绍"> 34 + <van-tab title="介 绍" v-if="page_details.introduction">
35 <div class="info-content"> 35 <div class="info-content">
36 <div id="introduction" v-html="page_details.introduction" style="padding: 0 1rem;"></div> 36 <div id="introduction" v-html="page_details.introduction" style="padding: 0 1rem;"></div>
37 </div> 37 </div>
38 </van-tab> 38 </van-tab>
39 - <van-tab title="故 事"> 39 + <van-tab title="故 事" v-if="page_details.story">
40 <div class="info-content"> 40 <div class="info-content">
41 <div id="story" v-html="page_details.story" style="padding: 0 1rem;"></div> 41 <div id="story" v-html="page_details.story" style="padding: 0 1rem;"></div>
42 </div> 42 </div>
43 </van-tab> 43 </van-tab>
44 - <van-tab title="体 验" id="tab-3"> 44 + <van-tab title="体 验" v-if="page_details.experience">
45 <div class="info-content"> 45 <div class="info-content">
46 <div id="experience" v-html="page_details.experience" style="padding: 0 1rem;"></div> 46 <div id="experience" v-html="page_details.experience" style="padding: 0 1rem;"></div>
47 </div> 47 </div>
...@@ -171,6 +171,7 @@ const stopAudio = (item, index) => { ...@@ -171,6 +171,7 @@ const stopAudio = (item, index) => {
171 } 171 }
172 172
173 const audio = ref(new Audio()); 173 const audio = ref(new Audio());
174 +const img_height = ref('15rem');
174 175
175 onMounted(async () => { 176 onMounted(async () => {
176 // 通过ID查询到标记点详情 177 // 通过ID查询到标记点详情
...@@ -200,8 +201,17 @@ onMounted(async () => { ...@@ -200,8 +201,17 @@ onMounted(async () => {
200 // console.log('close'); 201 // console.log('close');
201 } 202 }
202 }) 203 })
203 - }) 204 + });
205 + // 图片有2个像素的圆角
206 + $(img).css('border-radius', '5px');
204 }); 207 });
208 + // 获取屏幕宽度,设置高度4:3
209 + // 获取屏幕的宽度
210 + var screenWidth = $(window).width();
211 + // 计算4:3比例的高度
212 + var screenHeight = screenWidth * 3 / 4;
213 + // 设置容器的高度
214 + img_height.value = screenHeight + 'px';
205 }); 215 });
206 216
207 onUnmounted(() => { // 离开页面时关闭音频播放 217 onUnmounted(() => { // 离开页面时关闭音频播放
...@@ -287,6 +297,8 @@ const clickTab = (evt) => { // 标签切换 ...@@ -287,6 +297,8 @@ const clickTab = (evt) => { // 标签切换
287 } 297 }
288 }) 298 })
289 }) 299 })
300 + // 图片有5个像素的圆角
301 + $(img).css('border-radius', '5px');
290 }); 302 });
291 }); 303 });
292 } 304 }
...@@ -313,6 +325,32 @@ const preview_images = []; ...@@ -313,6 +325,32 @@ const preview_images = [];
313 const onChange = (newIndex) => { 325 const onChange = (newIndex) => {
314 index.value = newIndex; 326 index.value = newIndex;
315 }; 327 };
328 +
329 +const onClickImg = (idx) => {
330 + showImagePreview({
331 + images: page_details.value.banner,
332 + startPosition: idx,
333 + showIndex: true,
334 + onClose: () => {
335 + // console.log('close');
336 + }
337 + })
338 +};
339 +
340 +const show_shrink = computed(() => {
341 + // 统计非空字段的个数
342 + let filledFields = 0;
343 +
344 + if (page_details.value.introduction) filledFields++;
345 + if (page_details.value.story) filledFields++;
346 + if (page_details.value.experience) filledFields++;
347 +
348 + // 判断是否只有一个字段有值
349 + if (filledFields === 1) {
350 + return true;
351 + }
352 + return false;
353 +})
316 </script> 354 </script>
317 355
318 <style lang="less"> 356 <style lang="less">
...@@ -431,6 +469,10 @@ const onChange = (newIndex) => { ...@@ -431,6 +469,10 @@ const onChange = (newIndex) => {
431 .van-tabs__wrap { 469 .van-tabs__wrap {
432 border-bottom: 1px solid #F3F3F3; 470 border-bottom: 1px solid #F3F3F3;
433 } 471 }
472 +
473 + .van-tabs__nav--line.van-tabs__nav--shrink {
474 + padding-left: 2rem;
475 + }
434 } 476 }
435 477
436 .van-back-top { 478 .van-back-top {
......