杨磊
4 天以前 ef37c59e055a990ce247b265b27d3fcef430a243
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
133
134
<template>
  <div class="minWidth">
    <el-carousel :height="screenheight + 'px'" v-show="bannerState">
      <el-carousel-item v-for="item in bannerList" :key="item.id">
        <div class="bannerBox imgBox" :style="item.caupress_link ? 'cursor: pointer' : ''">
          <img class="bannerImg" :src="item.icon" @click="bannerLink(item)" />
        </div>
      </el-carousel-item>
    </el-carousel>
    <div
      :class="!bannerState ? 'show stow' : 'stow'"
      @click="bannerState = !bannerState"
    >
      {{ bannerState ? "收起" : "显示" }}
      轮播图
      <i
        :class="bannerState ? 'el-icon-caret-top' : 'el-icon-caret-bottom'"
      ></i>
    </div>
    <div class="contentBox">
      <List
        :channel="
          this.$route.query.searchPath
            ? this.$route.query.searchPath
            : 'caupress_bookMall'
        "
        :searchOptionHidden="searchOptionHidden"
        :detailRoute="detailRoute"
      ></List>
    </div>
  </div>
</template>
 
<script>
import List from "@/components/list";
export default {
  name: "bookStore-index",
  components: {
    List,
  },
  data() {
    return {
      bannerList: [],
      detailRoute: "bookStore-detail",
      searchOptionHidden: this.$route.query.searchOptionHidden
        ? this.$route.query.searchOptionHidden
        : false,
      bannerState: true,
      screenheight: document.documentElement.clientWidth / 2.628,
    };
  },
  created() {
    window.onresize = () => {
      let c = 2.628;
      if (document.documentElement.clientWidth >= 1220) {
        this.screenheight = document.documentElement.clientWidth / c;
      }
    };
    this.getBanner();
    setTimeout(() => {
      this.bannerState = false;
    }, 15000);
  },
  methods: {
    bannerLink(val) {
      if (val.caupress_link) {
        window.open(val.caupress_link);
      }
    },
    getBanner() {
      this.MG.resource
        .getItem({
          path: "caupress_banner\\caupress_mall",
          fields: {
            caupress_link: [],
          },
          coverSize: {
            height: 750,
          },
          paging: {
            start: 0,
            size: 999,
          },
        })
        .then((res) => {
          this.bannerList = res.datas;
        });
    },
  },
  // 如果跳转页面不是详情,则将当前页面不缓存
  beforeRouteLeave(to, from, next) {
    if (to.name != "bookStore-detail") {
      this.$store.commit("delKeepAlive", from.name);
    }
    next();
  },
};
</script>
 
<style lang="less" scoped>
.autoImg {
  max-height: none;
}
.minWidth {
  min-width: 1220px;
}
.stow {
  width: 160px;
  margin: 0 auto;
  text-align: center;
  border: 1px solid #b3b3b3;
  font-size: 16px;
  line-height: 40px;
  border-radius: 21px;
  color: #b3b3b3;
  cursor: pointer;
  margin-top: 5px;
}
.show {
  margin-top: 20px;
}
.bannerBox {
  background: #f3f3f3;
}
.imgBox {
  position: relative;
  width: 100%;
  height: 100%;
}
.contentBox {
  background-color: rgb(241, 248, 244);
  margin-top: 20px;
}
</style>