Browse Source

商品详情页轮播图和加入购物车属性图无法点击放大

master
Gao xiaosong 4 years ago
parent
commit
de217d7f6f
  1. 30
      components/ProductConSwiper.vue
  2. 40
      components/ProductWindow.vue

30
components/ProductConSwiper.vue

@ -1,9 +1,13 @@
<template> <template>
<view class="slider-banner product-bg"> <view class="slider-banner product-bg">
<swiper class="swiper-wrapper" @change="handleChange" v-if="imgUrls.length > 0"> <swiper
class="swiper-wrapper"
@change="handleChange"
v-if="imgUrls.length > 0"
>
<block v-for="(item, imgUrlsIndex) in imgUrls" :key="imgUrlsIndex"> <block v-for="(item, imgUrlsIndex) in imgUrls" :key="imgUrlsIndex">
<swiper-item> <swiper-item>
<image :src="item" class="slide-image" /> <image :src="item" @tap="previewImage(imgUrlsIndex)" class="slide-image" />
</swiper-item> </swiper-item>
</block> </block>
</swiper> </swiper>
@ -27,8 +31,8 @@ export default {
props: { props: {
imgUrls: { imgUrls: {
type: Array, type: Array,
default: () => [] default: () => [],
} },
}, },
data: function () { data: function () {
let that = this; let that = this;
@ -37,7 +41,7 @@ export default {
ProductConSwiper: { ProductConSwiper: {
autoplay: { autoplay: {
disableOnInteraction: false, disableOnInteraction: false,
delay: 2000 delay: 2000,
}, },
loop: true, loop: true,
speed: 1000, speed: 1000,
@ -46,16 +50,22 @@ export default {
on: { on: {
slideChangeTransitionStart: function () { slideChangeTransitionStart: function () {
that.currents = this.realIndex + 1; that.currents = this.realIndex + 1;
} },
} },
} },
}; };
}, },
mounted: function () {}, mounted: function () {},
methods: { methods: {
handleChange(event) { handleChange(event) {
this.currents = event.mp.detail.current + 1; this.currents = event.mp.detail.current + 1;
} },
} previewImage(current) {
uni.previewImage({
current,
urls: this.imgUrls,
});
},
},
}; };
</script> </script>

40
components/ProductWindow.vue

@ -3,7 +3,7 @@
<view class="product-window" :class="attr.cartAttr === true ? 'on' : ''"> <view class="product-window" :class="attr.cartAttr === true ? 'on' : ''">
<view class="textpic acea-row row-between-wrapper"> <view class="textpic acea-row row-between-wrapper">
<view class="pictrue"> <view class="pictrue">
<image :src="attr.productSelect.image" class="image" /> <image @tap="previewImage" :src="attr.productSelect.image" class="image" />
</view> </view>
<view class="text"> <view class="text">
<view class="line1">{{ attr.productSelect.store_name }}</view> <view class="line1">{{ attr.productSelect.store_name }}</view>
@ -16,7 +16,11 @@
<view class="iconfont icon-guanbi" @click="closeAttr"></view> <view class="iconfont icon-guanbi" @click="closeAttr"></view>
</view> </view>
<view class="productWinList"> <view class="productWinList">
<view class="item" v-for="(item, indexw) in attr.productAttr" :key="indexw"> <view
class="item"
v-for="(item, indexw) in attr.productAttr"
:key="indexw"
>
<view class="title">{{ item.attrName }}</view> <view class="title">{{ item.attrName }}</view>
<view class="listn acea-row row-middle"> <view class="listn acea-row row-middle">
<view <view
@ -25,28 +29,36 @@
v-for="(itemn, indexn) in item.attrValue" v-for="(itemn, indexn) in item.attrValue"
@click="tapAttr(indexw, indexn)" @click="tapAttr(indexw, indexn)"
:key="indexn" :key="indexn"
>{{ itemn.attr }}</view> >{{ itemn.attr }}</view
>
</view> </view>
</view> </view>
</view> </view>
<view class="cart"> <view class="cart">
<view class="title">数量</view> <view class="title">数量</view>
<view class="carnum acea-row row-left"> <view class="carnum acea-row row-left">
<view class="item reduce" :class="cartNum <= 1 ? 'on' : ''" @click="CartNumDes">-</view> <view
class="item reduce"
:class="cartNum <= 1 ? 'on' : ''"
@click="CartNumDes"
>-</view
>
<view class="item num">{{ cartNum }}</view> <view class="item num">{{ cartNum }}</view>
<view <view
class="item plus" class="item plus"
:class=" :class="cartNum >= attr.productSelect.stock ? 'on' : ''"
cartNum >= attr.productSelect.stock
? 'on'
: ''
"
@click="CartNumAdd" @click="CartNumAdd"
>+</view> >+</view
>
</view> </view>
</view> </view>
</view> </view>
<view class="mask" @touchmove.prevent :hidden="attr.cartAttr === false" @click="closeAttr"></view> <view
class="mask"
@touchmove.prevent
:hidden="attr.cartAttr === false"
@click="closeAttr"
></view>
</view> </view>
</template> </template>
<script> <script>
@ -114,6 +126,12 @@ export default {
} }
return value; return value;
}, },
previewImage() {
uni.previewImage({
current: 0,
urls: [this.attr.productSelect.image],
});
},
}, },
}; };
</script> </script>

Loading…
Cancel
Save