Commit 17888a7c authored by leon's avatar leon

feat: preview image use swiper current index

parent 5c929cbf
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
class="swiper" class="swiper"
circular circular
:current="currentIndex" :current="currentIndex"
@change="changed"
:style="{ height: `${height}px` }" :style="{ height: `${height}px` }"
> >
<swiper-item v-for="(item, index) in popupData" :key="index"> <swiper-item v-for="(item, index) in popupData" :key="index">
...@@ -39,7 +40,9 @@ ...@@ -39,7 +40,9 @@
export default { export default {
name: 'ModelData', name: 'ModelData',
data() { data() {
return {} return {
swiperIndex: -1
}
}, },
props: { props: {
popupData: { popupData: {
...@@ -79,14 +82,21 @@ export default { ...@@ -79,14 +82,21 @@ export default {
methods: { methods: {
close() { close() {
this.swiperIndex = -1
this.$emit('close') this.$emit('close')
}, },
seeImage(key) { seeImage(key) {
if(this.swiperIndex === -1) {
this.swiperIndex = this.currentIndex
}
const images = this.popupData.map(item => item[key]) const images = this.popupData.map(item => item[key])
uni.previewImage({ uni.previewImage({
current: this.currentIndex, current: this.swiperIndex,
urls: images urls: images
}) })
},
changed(event) {
this.swiperIndex = event.detail.current
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment