Showing
2 changed files
with
56 additions
and
7 deletions
| ... | @@ -30,6 +30,7 @@ declare module '@vue/runtime-core' { | ... | @@ -30,6 +30,7 @@ declare module '@vue/runtime-core' { |
| 30 | VanFloatingPanel: typeof import('vant/es')['FloatingPanel'] | 30 | VanFloatingPanel: typeof import('vant/es')['FloatingPanel'] |
| 31 | VanIcon: typeof import('vant/es')['Icon'] | 31 | VanIcon: typeof import('vant/es')['Icon'] |
| 32 | VanImage: typeof import('vant/es')['Image'] | 32 | VanImage: typeof import('vant/es')['Image'] |
| 33 | + VanImagePreview: typeof import('vant/es')['ImagePreview'] | ||
| 33 | VanOverlay: typeof import('vant/es')['Overlay'] | 34 | VanOverlay: typeof import('vant/es')['Overlay'] |
| 34 | VanPopup: typeof import('vant/es')['Popup'] | 35 | VanPopup: typeof import('vant/es')['Popup'] |
| 35 | VanRow: typeof import('vant/es')['Row'] | 36 | VanRow: typeof import('vant/es')['Row'] | ... | ... |
| 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-23 18:22:34 | 4 | + * @LastEditTime: 2024-09-25 14:07:44 |
| 5 | * @FilePath: /map-demo/src/views/bieyuan/info.vue | 5 | * @FilePath: /map-demo/src/views/bieyuan/info.vue |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | --> | 7 | --> |
| ... | @@ -33,17 +33,17 @@ | ... | @@ -33,17 +33,17 @@ |
| 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" sticky animated> |
| 34 | <van-tab title="介 绍"> | 34 | <van-tab title="介 绍"> |
| 35 | <div class="info-content"> | 35 | <div class="info-content"> |
| 36 | - <div 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="故 事"> |
| 40 | <div class="info-content"> | 40 | <div class="info-content"> |
| 41 | - <div 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="体 验" id="tab-3"> |
| 45 | <div class="info-content"> | 45 | <div class="info-content"> |
| 46 | - <div 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> |
| 48 | <div v-if="page_details.experience_audio.length" class="audio-wrapper"> | 48 | <div v-if="page_details.experience_audio.length" class="audio-wrapper"> |
| 49 | <div :class="['audio-item', play_audio_index === index ? 'click' : '']" v-for="(item, index) in page_details.experience_audio" :key="index"> | 49 | <div :class="['audio-item', play_audio_index === index ? 'click' : '']" v-for="(item, index) in page_details.experience_audio" :key="index"> |
| ... | @@ -67,13 +67,17 @@ | ... | @@ -67,13 +67,17 @@ |
| 67 | <p style="padding: 0.5rem 1rem;">{{ toast_text }}</p> | 67 | <p style="padding: 0.5rem 1rem;">{{ toast_text }}</p> |
| 68 | </template> | 68 | </template> |
| 69 | </van-toast> | 69 | </van-toast> |
| 70 | + | ||
| 71 | + <van-image-preview v-model:show="show_preview" :images="preview_images" @change="onChange" doubleScale> | ||
| 72 | + <template v-slot:index>第{{ index + 1 }}张</template> | ||
| 73 | + </van-image-preview> | ||
| 70 | </div> | 74 | </div> |
| 71 | </template> | 75 | </template> |
| 72 | 76 | ||
| 73 | <script setup> | 77 | <script setup> |
| 74 | import { ref, watch } from 'vue' | 78 | import { ref, watch } from 'vue' |
| 75 | import { useRoute, useRouter } from 'vue-router' | 79 | import { useRoute, useRouter } from 'vue-router' |
| 76 | - | 80 | +import { showImagePreview } from 'vant'; |
| 77 | import { storeToRefs } from 'pinia' | 81 | import { storeToRefs } from 'pinia' |
| 78 | import { mainStore } from '@/store'; | 82 | import { mainStore } from '@/store'; |
| 79 | 83 | ||
| ... | @@ -180,8 +184,21 @@ onMounted(async () => { | ... | @@ -180,8 +184,21 @@ onMounted(async () => { |
| 180 | page_details.value.introduction = page_details.value.introduction?.replace(/\<hr\>/g, '<div class="van-hairline--bottom" style="margin: 1rem 0;"></div>') | 184 | page_details.value.introduction = page_details.value.introduction?.replace(/\<hr\>/g, '<div class="van-hairline--bottom" style="margin: 1rem 0;"></div>') |
| 181 | page_details.value.story = page_details.value.story?.replace(/\<hr\>/g, '<div class="van-hairline--bottom" style="margin: 1rem 0;"></div>') | 185 | page_details.value.story = page_details.value.story?.replace(/\<hr\>/g, '<div class="van-hairline--bottom" style="margin: 1rem 0;"></div>') |
| 182 | page_details.value.experience = page_details.value.experience?.replace(/\<hr\>/g, '<div class="van-hairline--bottom" style="margin: 1rem 0;"></div>') | 186 | page_details.value.experience = page_details.value.experience?.replace(/\<hr\>/g, '<div class="van-hairline--bottom" style="margin: 1rem 0;"></div>') |
| 183 | - console.log("🚀 ~ file: info.vue:177 ~ onMounted ~ page_details.value:", page_details.value); | ||
| 184 | } | 187 | } |
| 188 | + // 介绍栏目,图片点击事件 | ||
| 189 | + var imgs = $('#introduction').find('img'); | ||
| 190 | + // 图片点击事件 | ||
| 191 | + imgs.each(function(index, img) { | ||
| 192 | + $(img).on('click', function (e) { | ||
| 193 | + showImagePreview({ | ||
| 194 | + images: [$(img).attr('src')], | ||
| 195 | + startPosition: 0, | ||
| 196 | + onClose: () => { | ||
| 197 | + // console.log('close'); | ||
| 198 | + } | ||
| 199 | + }) | ||
| 200 | + }) | ||
| 201 | + }); | ||
| 185 | }); | 202 | }); |
| 186 | 203 | ||
| 187 | onUnmounted(() => { // 离开页面时关闭音频播放 | 204 | onUnmounted(() => { // 离开页面时关闭音频播放 |
| ... | @@ -238,8 +255,31 @@ const voicePause = () => { | ... | @@ -238,8 +255,31 @@ const voicePause = () => { |
| 238 | } | 255 | } |
| 239 | 256 | ||
| 240 | const tabsRef = ref(null); | 257 | const tabsRef = ref(null); |
| 241 | -const clickTab = (evt) => { | 258 | +const clickTab = (evt) => { // 标签切换 |
| 242 | tabsRef.value.resize(); | 259 | tabsRef.value.resize(); |
| 260 | + nextTick(() => { | ||
| 261 | + if (evt.name === 0) { // 介绍 | ||
| 262 | + var imgs = $('#introduction').find('img'); | ||
| 263 | + } | ||
| 264 | + if (evt.name === 1) { // 故事 | ||
| 265 | + var imgs = $('#story').find('img'); | ||
| 266 | + } | ||
| 267 | + if (evt.name === 2) { // 体验 | ||
| 268 | + var imgs = $('#experience').find('img'); | ||
| 269 | + } | ||
| 270 | + // 图片点击事件 | ||
| 271 | + imgs.each(function(index, img) { | ||
| 272 | + $(img).on('click', function (e) { | ||
| 273 | + showImagePreview({ | ||
| 274 | + images: [$(img).attr('src')], | ||
| 275 | + startPosition: 0, | ||
| 276 | + onClose: () => { | ||
| 277 | + // console.log('close'); | ||
| 278 | + } | ||
| 279 | + }) | ||
| 280 | + }) | ||
| 281 | + }); | ||
| 282 | + }); | ||
| 243 | } | 283 | } |
| 244 | 284 | ||
| 245 | watch( | 285 | watch( |
| ... | @@ -256,6 +296,14 @@ watch( | ... | @@ -256,6 +296,14 @@ watch( |
| 256 | defineExpose({ | 296 | defineExpose({ |
| 257 | outerStopAudio | 297 | outerStopAudio |
| 258 | }) | 298 | }) |
| 299 | + | ||
| 300 | + | ||
| 301 | +const show_preview = ref(false); | ||
| 302 | +const index = ref(0); | ||
| 303 | +const preview_images = []; | ||
| 304 | +const onChange = (newIndex) => { | ||
| 305 | + index.value = newIndex; | ||
| 306 | +}; | ||
| 259 | </script> | 307 | </script> |
| 260 | 308 | ||
| 261 | <style lang="less"> | 309 | <style lang="less"> | ... | ... |
-
Please register or login to post a comment