my_news.html 5.4 KB
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <script src="../../assets/js/fontsize.js"></script>
    <link rel="stylesheet" href="../../assets/css/api.css"/>
    <link rel="stylesheet" href="../../assets/css/style.css">
    <link rel="stylesheet" href="../../assets/css/index.css">
    <link rel="stylesheet" href="../../assets/css/doc.css">
    <link rel="stylesheet" href="../../assets/css/pay.css">
    <link rel="stylesheet" href="../../assets/css/my_news.css">
    <link rel="stylesheet" href="../../assets/icon/iconfont.css">
    <title></title>
    <style>
        body, html {
            background-color: #F6F5F5;
            height: 100%;
        }

        .dot {
            position: absolute;
            left: 0.3rem;
            top: 50%;
            width: 0.15rem;
            height: 0.15rem;
            background-color: #ce3c39;
            border-radius: 50%;
        }
    </style>
</head>
<body>
<div id="loadStart"></div>
<div id="app">
    <div class="new_top">
        <div @click="alls" :class="{sapn_active:all}">全部</div>
        <div @click="noRead" :class="{sapn_active:no_read}">未读
            <span v-if='newList.unread.length!=0' :class="['news',newList.unread.length>=1?'new_num2':'']">{{newList.unread.length}}</span>
        </div>
        <div @click="reads" :class="{sapn_active:read}">已读</div>
    </div>
    <div class="all" v-show="all">
        <div class="all_item" v-if="newList.all.length==0">
            <div class="all_content">【暂无消息】</div>
        </div>
        <div class="all_item" v-for="(item,index) in newList.all" v-else @click="go_detail(item.title,item.message_id)">
            <div class="all_content">【{{item.title}}】{{item.description}}</div>
            <div class="all_time">{{timestampToTime(item.published_time)}}</div>
            <div class="dot" v-if="item.status==0"></div>
        </div>
    </div>
    <div class="all" v-show="no_read">
        <div class="all_item" v-if="newList.unread.length==0">
            <div class="all_content">【暂无消息】</div>
        </div>
        <div class="all_item" v-for="(item,index) in newList.unread" v-else
             @click="go_detail(item.title,item.message_id)">
            <div class="all_content">【{{item.title}}】{{item.description}}</div>
            <div class="all_time">{{timestampToTime(item.published_time)}}</div>
        </div>
    </div>
    <div class="all" v-show="read">
        <div class="all_item" v-if="newList.readed.length==0">
            <div class="all_content">【暂无消息】</div>
        </div>
        <div class="all_item" v-for="(item,index) in newList.readed" v-else
             @click="go_detail(item.title,item.message_id)">
            <div class="all_content">【{{item.title}}】{{item.description}}</div>
            <div class="all_time">{{timestampToTime(item.published_time)}}</div>
        </div>
    </div>
</div>
</body>
</html>
<script type="text/javascript" src="../../assets/js/api.js"></script>
<script type="text/javascript" src="../../assets/js/public.js"></script>
<script type="text/javascript" src="../../assets/js/fastclick.js"></script>
<script>
    new FastClick(document.body);
</script>
<script type="text/javascript" src="../../assets/js/vue.min.js"></script>
<script type="text/javascript" src="../../assets/js/axios.min.js"></script>
<script type="text/javascript" src="../../assets/icon/iconfont.js"></script>
<script>
    var app = new Vue({
        el: '#app',
        data: {
            all: true,
            no_read: false,
            read: false,
            new_num: 0,
            newList: [],
            new_type: ''
        },
        created: function () {
            apiready = function () {
                app.new_type = api.pageParam.new_type;
                app.getNews();
            }
        },
        methods: {
            alls: function () {
                app.all = true;
                app.no_read = false;
                app.read = false;
            },
            noRead: function () {
                app.all = false;
                app.no_read = true;
                app.read = false;
            },
            reads: function () {
                app.all = false;
                app.no_read = false;
                app.read = true;
            },
            // 获取消息列表
            getNews: function () {
                var header = {
                    "XX-Device-Type": getDevice(),
                    'XX-Token': getToken()
                };
                var post={
                    user_type:app.new_type
                }
                getRequest('post', 'user/index/getUserMessageList', post, header).then(function (res) {
                    if (res.data.code == 1) {
                        app.newList = res.data.data;
                    } else {
                        toastMsg(res.data.msg)
                    }
                    loadEnd();
                })
            },
            // 消息详情
            go_detail: function (name, id) {
                openView('new_detail', 'my/new_detail', name, 'new_detail', false, {message_id: id})
            }
        }
    })
</script>