123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210 |
- <!-- 园区公告-->
- <template>
- <div class="notice">
- <div class="title_box">
- <div class="title">
- <span class="chinese">园区公告</span>
- <span class="english">park announcement</span>
- </div>
- <div class="more pointer" v-if="lists.length < 5">
- <img src="@assets/image/index/icon_more.png" alt="更多" />
- </div>
- </div>
-
- <template v-if="lists.length >= 5">
- <section class="content">
- <div class="main_notice pointer">
- <div class="notice_title">国务院关于推进物联网有序健康发展指导者</div>
- <div class="notice_content">
- 小昆山园区经过不断改革发展,园区已经具备大规模开发建设的总体框架,形成了良性循环的软硬投资环境,吸引了多地区企业的投资。园区地理交通条件优越,区内交通四通八达,道路宽敞平坦。
- 小昆山园区经过不断改革发展,园区已经具备大规模开发建设的总体框架,形成了良性循环的软硬投资环境,吸引了多地区企业的投资。园区地理交通条件优越,区内交通四通八达,道路宽敞平坦。
- </div>
- </div>
- <ul class="notice_ul">
- <li class="notice_item pointer" v-for="item in lists" :key="item">
- <div class="notice_detail">
- <div>
- {{ item }}
- </div>
- </div>
- <div>2022.09.17</div>
- </li>
- </ul>
- </section>
- <div class="more width_100 pointer">
- <img src="@assets/image/index/icon_more.png" alt="更多" />
- </div>
- </template>
- <template v-else>
- <div class="notice_box">
- <ul :class="['notice_list', animate ? 'content_top' : '']">
- <li class="notice_item " v-for="item in lists" :key="item">
- <div class="notice_detail">
- <div>
- {{ item }}
- </div>
- </div>
- <div>2022.09.17</div>
- </li>
- </ul>
- </div>
- </template>
- </div>
- </template>
-
- <script>
- //这里可以导入其他文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
- //例如:import 《组件名称》 from '《组件路径》';
-
- export default {
- //import引入的组件需要注入到对象中才能使用
- components: {},
- props: ["lists"],
-
- data() {
- //这里存放数据
- return {
- animate: false,
- };
- },
- //监听属性 类似于data概念
- computed: {},
- //监控data中的数据变化
- watch: {},
- //方法集合
- methods: {
- scroll() {
- if (this.lists.length < 5) {
- this.animate = true; // 因为在消息向上滚动的时候需要添加css3过渡动画,所以这里需要设置true
- setTimeout(() => {
- // 这里直接使用了es6的箭头函数,省去了处理this指向偏移问题,代码也比之前简化了很多
- this.lists.push(this.lists[0]); // 将数组的第一个元素添加到数组的
- this.lists.shift(); //删除数组的第一个元素
- this.animate = false; // margin-top 为0 的时候取消过渡动画,实现无缝滚动
- }, 1000);
- }
- },
- },
- //生命周期 - 创建完成(可以访问当前this实例)
- created() {
- setInterval(this.scroll, 5000);
- },
- //生命周期 - 挂载完成(可以访问DOM元素)
- mounted() {},
- };
- </script>
- <style lang="scss" scoped>
- //@import url(); 引入公共css类
- .notice {
- width: 100%;
- height: 100%;
- @include flex(column, space-between, flex-start, null);
- }
- .title_box {
- width: 100%;
- @include flex(row, space-between, center, null);
- margin-bottom: 30px;
- }
- .title {
- flex: 1;
-
- .chinese {
- @include font(24px, #334a5f);
- }
- .english {
- @include font(14px, #637485);
- margin-left: 10px;
- }
- }
- .content {
- width: 100%;
- flex: 1;
- background-image: linear-gradient(180deg, #e5f3fc 0%, #fcfefe 100%);
- padding: 35px 30px 0 40px;
- @include border-box;
- .main_notice {
- border-bottom: solid 1px #abcee4;
- padding-bottom: 12px;
- @include border-box;
- .notice_title {
- @include font(16px, #334a5f);
- font-weight: 600;
- padding-bottom: 15px;
- @include border-box;
- }
- .notice_content {
- height: 100%;
- @include font(16px, #334a5f);
- // padding-bottom: 12px;
- // @include border-box;
- @include text-ellipsis-multiple(2);
- }
- }
- .notice_ul {
- width: 100%;
- .notice_item {
- padding-top: 25px;
- @include border-box;
- }
- }
- }
- .notice_item {
- width: 100%;
- @include font(16px, #334a5f);
- @include flex(row, space-between, center, nowrap);
- }
- .notice_detail {
- overflow: hidden;
- flex: 1;
- padding: 0 40px 0 26px;
- position: relative;
- @include border-box;
- > div {
- @include text-ellipsis;
- }
- }
- .notice_detail::before {
- content: "";
- width: 15px;
- height: 15px;
- border: 2px solid #0086e7;
- border-radius: 50%;
- @include border-box;
- position: absolute;
- left: 0;
- top: 50%;
- transform: translateY(-50%);
- }
- .width_100 {
- width: 100%;
- padding-right: 30px;
- margin-top: 20px;
- @include border-box;
- }
- .more {
- height: 25px;
- @include flex(row, flex-end, center, null);
- img {
- width: 73px;
- height: 25px;
- }
- }
- .notice_box {
- @include size(100%, 60px);
- background: #eef7fd;
- padding: 0 20px;
- @include border-box;
- overflow: hidden;
- .notice_list {
- @include size(100%, 100%);
- overflow: hidden;
- li {
- height: 100%;
- }
- }
- }
- .content_top {
- transition: all 0.5s;
- margin-top: -60px;
- }
- </style>
|