Commit 17888a7c authored by leon's avatar leon

feat: preview image use swiper current index

parent 5c929cbf
...@@ -11,7 +11,8 @@ ...@@ -11,7 +11,8 @@
v-if="show" v-if="show"
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: {
...@@ -78,16 +81,23 @@ export default { ...@@ -78,16 +81,23 @@ export default {
}, },
methods: { methods: {
close() { close() {
this.swiperIndex = -1
this.$emit('close') this.$emit('close')
}, },
seeImage(key) { seeImage(key) {
const images = this.popupData.map(item => item[key]) if(this.swiperIndex === -1) {
this.swiperIndex = this.currentIndex
}
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
}
} }
} }
</script> </script>
......
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