交易所前端蓝色ui 4.5 jiem
jhzh
2025-05-19 c5487881d04780e03f4dd86ed1606c587f2c7952
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
<!-- 公告 -->
<template>
  <div class="roll content-view-box">
    <img
      src="@/assets/images/home/trumpet.png"
      alt=""
      class="el-icon-bell"
      style="width: 28px; height: 28px"
    />
    <ul class="list">
      <li
        v-for="(item, index) in ulList"
        :key="item.id"
        :class="!index && play ? 'toUp' : ''"
        @click="toDetail(item)"
      >
        {{ item.title }}
      </li>
    </ul>
    <!-- <img src="../../assets/newImages/home/noticeMore.png" alt="" class="el-icon-bell" style="width:28px;height:28px;" /> -->
  </div>
</template>
<script>
import Axios from "@/api/my";
export default {
  data() {
    return {
      ulList: [],
      play: false,
      timer: null, // //接收定时器
    };
  },
  mounted() {
    Axios.news({
      page_no: 1,
    }).then((res) => {
      this.ulList = res.data;
    });
    //页面挂载完成时就开始定时器,公告文字滚动
    setInterval(this.startPlay, 4000);
  },
  unmounted() {
    // 页面销毁时清除定时器
    clearInterval(this.timer);
  },
  methods: {
    startPlay() {
      let that = this;
      that.play = true; //开始播放
      that.timer = setTimeout(() => {
        //创建并执行定时器
        that.ulList.push(that.ulList[0]); //将第一条数据塞到最后一个
        that.ulList.shift(); //删除第一条数据
        that.play = false; //暂停播放
      }, 500);
    },
    toDetail(item) {
      this.$router.push({
        path: "/my/announcement",
        query: { type: "announcement" },
      });
      console.log(item);
    },
  },
};
</script>
 
<style scoped>
.roll {
  height: 50px; /*关键样式*/
  line-height: 50px; /*关键样式*/
  background: #fff;
  margin-bottom: 24px;
  padding: 0 20px;
  color: 707A8A;
  font-size: 14px;
  display: flex;
  align-items: center;
}
 
.el-icon-bell {
  margin-right: 10px;
  display: inline-block;
}
 
.toUp {
  margin-top: -50px; /*关键样式*/
  transition: all 1s; /*关键样式*/
}
.list {
  list-style: none;
  width: 100%;
  text-align: center;
  overflow: hidden; /*关键样式*/
  height: 50px; /*关键样式*/
  padding: 0;
  margin: 0;
}
.list > li {
  text-align: left;
  height: 50px; /*关键样式*/
  line-height: 50px; /*关键样式*/
  font-size: 18px;
  color: #707a8a;
}
</style>