fuliqi
2024-01-24 29c1e7eb5ac16e90d8991a86c1c071bc312ec8d9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<!--
 * @Author: 张嘉彬
 * @Date: 2021-09-28 14:42:15
 * @Description:
-->
<template>
  <div class="notice-bar" ref="swiper" :style="{
      width: infoData.width,
      height: infoData.height,
      position: 'absolute',
      top: infoData.codeY,
      left: infoData.codeX,
      zIndex: infoData.z,
    }">
    <swiper :options="swiperOption" class="swiper-container" ref="noticeSwiper"
            v-if="infoData.noticeList.length != 0" :style="{height: infoData.height}">
      <swiper-slide v-for="item in infoData.noticeList" :key="item.id">
        <div class="notice-box" @click="swiperclickfn(item)" :style="{height: infoData.height}">
          {{ item.title }}</div>
      </swiper-slide>
    </swiper>
  </div>
</template>
 
<script>
export default {
  name: 'Notice',
  props: {
    infoData: {
      type: Object,
      default: () => {
        return {}
      }
    }
  },
  data () {
    return {
      swiperOption: {
        direction: 'vertical',
        autoplay: {
          delay: 2000,
          disableOnInteraction: false
        }
      }
    }
  },
  methods: {
    // "消息类型:1 商品推送,2 文章推送,3 系统消息,4 活动消息,5 账号通知 6 物流消息"
    swiperclickfn (active) {
      if (this.$route.query.isPreview) return
      // 商品详情
      if (active.messageType === '1') {
        const _obj = { shopSpuId: active.shopSpuId }
        const params = active.shopSkuId ? { ..._obj, ...{ shopSkuId: active.shopSkuId } } : _obj
        console.log(params, '====商品详情传参')
        if (this.$root.isIos) {
          const _strP = `?shopSpuId=${params.shopSpuId}`
          window.webkit.messageHandlers.iosRouter.postMessage(
            `wlyxls://product_detail${params.shopSkuId ? `${_strP}&shopSkuId=${params.shopSkuId}` : _strP}`
          )
        } else {
          window.wlyxls.toCommodityDetailPage(JSON.stringify(params))
        }
      }
      if (active.messageType === '2') {
        this.goMsgCentre(active, 1)
      }
      if (active.messageType === '5' || active.messageType === '3') {
        this.goMsgCentre(active, 2)
      }
      // 满减满赠
      if (active.messageType === '4') {
        const params = { promotionId: active.promotionId || '' }
        if (this.$root.isIos) {
          window.webkit.messageHandlers.iosRouter.postMessage(
            `wlyxls://category_search_result?promotionId=${params.promotionId}`
          )
        } else {
          window.wlyxls.toActivityCommodityListPage(JSON.stringify(params))
        }
      }
      // 订单详情
      if (active.messageType === '6') {
        const params = { orderId: active.prodNo }
        if (this.$root.isIos) {
          window.webkit.messageHandlers.iosRouter.postMessage(
            `wlyxls://order_detail?orderId=${params.orderId}`
          )
        } else {
          window.wlyxls.toOrderDetailPage(JSON.stringify(params))
        }
      }
    },
    /*
     * @Author: huangpan
     * @params: active:选中的详细信息 position:选中项 0-物流列表/1-活动列表/2-系统消息
     * @Description:跳转到消息中心
     * @Date: 2022-01-18 09:24:47
     */
    goMsgCentre (active, position) {
      const p1 = { url: active.jumpLink, isShowTitle: true }
      const p2 = { position: position }
      if (this.$root.isIos) {
        if (p1.url) {
          console.log(`wlyxls://browser?url=${encodeURIComponent(p1.url)}&isShowTitle=${p1.isShowTitle}`)
          window.webkit.messageHandlers.iosRouter.postMessage(
            `wlyxls://browser?url=${encodeURIComponent(p1.url)}&isShowTitle=${p1.isShowTitle}`
          )
        } else {
          window.webkit.messageHandlers.iosRouter.postMessage(
            `wlyxls://message_center?position=${p2.position}`
          )
        }
      } else {
        if (p1.url) {
          window.wlyxls.openUrlOnNewPage(JSON.stringify(p1))
        } else {
          window.wlyxls.toMessageCenterPage(JSON.stringify(p2))
        }
      }
    }
  }
}
</script>
 
<style scoped>
.notice-box {
  height: 100%;
  display: flex;
  align-items: center;
}
</style>