Commit abdb489866fe5132d9e3a7b9a1a3acf497564a19

Authored by zhiyangdu
1 parent f1f739ea

轮播增加可以有播放按钮轮播

src/components/swiper/swiper.less
... ... @@ -63,6 +63,22 @@
63 63 }
64 64 }
65 65 }
  66 + .play-button-box {
  67 + position: absolute;
  68 + top: 0;
  69 + left: 0;
  70 + z-index: 1;
  71 + display: flex;
  72 + justify-content: center;
  73 + align-items: center;
  74 + width: 100%;
  75 + height: 100%;
  76 + .play-button-img {
  77 + display: block;
  78 + width: 100px;
  79 + height: 100px;
  80 + }
  81 + }
66 82 }
67 83 }
68 84 // 积分商城样式
... ...
src/components/swiper/swiper.vue
... ... @@ -2,12 +2,16 @@
2 2 <div class="swiper-box" :class="{'points-mall-swiper':isPointsMall}" v-if="swipers && swipers.length">
3 3 <swipe class="swipe" :autoplay="5000" :touchable="swipers.length===1 ? false : true" :show-indicators="options && options.showIndicators !== undefined ? options.showIndicators : showIndicators" @change="onChange">
4 4 <swipe-item class="swipe-item" v-for="(item, index) in swipers" :key="index">
5   - <div class="item" @click="$parent.$parent.gotoDetail(item)">
  5 + <div class="item" @click="item.type == 22 ? playNow(item.to) : $parent.$parent.gotoDetail(item)">
6 6 <div class="img-box">
7 7 <img v-if="isPointsMall" v-lazy="item + SIGN.BIG" class="img" mode="widthFix" />
8 8 <img v-else v-lazy="item.simg + SIGN.BIG" class="img" mode="widthFix" />
9 9 </div>
10 10 </div>
  11 + <!-- 展示播放按钮 -->
  12 + <div v-if="item.type == 22" class="play-button-box">
  13 + <img src="static/img/play_dark.png" class="play-button-img" />
  14 + </div>
11 15 </swipe-item>
12 16 <template v-if="isPointsMall" #indicator>
13 17 <div class="custom-indicator">
... ... @@ -44,7 +48,54 @@ export default {
44 48 onChange (index) {
45 49 this.current = index;
46 50 this.$emit("onChange", index);
47   - }
  51 + },
  52 + /**
  53 + * 播放视频
  54 + * @param {String} videoUrl [数据对象]
  55 + */
  56 + playNow(videoUrl) {
  57 + // 判断App内
  58 + if (this.isCNLive.value) {
  59 +
  60 + // 判断通用跳转函数是否存在
  61 + if (typeof this.$parent.gotoDetail === 'function') {
  62 +
  63 + // 设置跳转参数
  64 + let params = {
  65 + type: '22',
  66 + to: videoUrl,
  67 + shop_type: ''
  68 + };
  69 +
  70 + // 通用跳转
  71 + this.$parent.$parent.gotoDetail(params);
  72 + }
  73 + } else {
  74 +
  75 + // App外,唤起App
  76 + this.openApp();
  77 + }
  78 + },
  79 + /**
  80 + * 唤起App封装
  81 + */
  82 + openApp() {
  83 +
  84 + this.$nextTick(() => {
  85 +
  86 + // 唤起App
  87 + if (typeof this.$parent.$parent.callAppModal === 'function' && typeof this.$parent.$refs.callApp === 'object') {
  88 +
  89 + // 设置唤起参数
  90 + let options = {
  91 + success: this.$parent.$refs.callApp.callApp
  92 + }
  93 +
  94 + // 唤起App
  95 + this.$parent.$parent.callAppModal(options);
  96 + }
  97 + });
  98 + },
48 99 }
49 100 }
50 101 </script>
... ...