| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302 |
- <html>
- <head>
- <style>
- body{
- background-color: #f5f6fa;
- }
- #space-content{
- background-color: transparent;
- }
- .msg-list{
- box-sizing: border-box;
- width: 100%;
- padding: 20px;
- padding-bottom: 0;
- }
- .msg-list dl{
- margin-bottom: 20px;
- background-color: #fff;
- border-radius: 6px;
- overflow: hidden;
- }
- .msg-list dl:last-child{
- margin-bottom: 0;
- }
- .msg-list dt,
- .msg-list dt img{
- width: 100%;
- }
- .msg-list dt{
- text-align: center;
- }
- .msg-list dd{
- padding: 0 20px;
- color: #666;
- }
- .msg-list-title,
- .msg-list-desc{
- display: -webkit-box;
- -webkit-box-orient: vertical;
- -webkit-line-clamp: 2;
- overflow: hidden;
- }
- .msg-list .msg-list-title{
- font-size: 16px;
- color: #000;
- line-height: 24px;
- margin: 12px 0 6px;
- position: relative;
- }
- .msg-list-title i{
- display: inline-block;
- width: 6px;
- height: 6px;
- border-radius: 50%;
- background-color: #f56c6c;
- position: absolute;
- top: 10px;
- left: 10px;
- }
- .msg-list .msg-list-desc{
- -webkit-line-clamp: 2;
- line-height: 20px;
- font-size: 12px;
- }
- .msg-list .msg-list-time{
- margin-top: 10px;
- font-size: 14px;
- padding-top: 10px;
- padding-bottom: 10px;
- position: relative;
- overflow: hidden;
- }
- .msg-list .msg-list-time::before{
- content: "";
- position: absolute;
- top: 0;
- left: 15px;
- width: calc(100% - 30px);
- height: 1px;
- background-color: #eee;
- }
- .msg-list-time i{
- font-style: normal;
- float: right;
- margin-top: 1px;
- }
- .layui-laypage a, .layui-laypage span,
- .layui-laypage input, .layui-laypage button{
- background-color: transparent;
- }
- .image-slot{
- color: #ccc;
- }
- .image-slot i{
- font-size: 36px;
- padding-top: 20px;
- padding-bottom: 10px;
- }
- .footer-bottom {
- width: 100%;
- background-color: #fff;
- position: fixed;
- bottom: 0;
- left: 0;
- text-align: center;
- }
- </style>
- </head>
- <body>
- <div id="space-content">
- <div class="content-wrap">
- <div id="mescroll" class="mescroll">
- <div id="msgList" class="msg-list">
- <dl :id="item.smid" :data-view="item.isView" v-for="item in msgList" @click="msgInfo(item)">
- <dt v-if="item.thumbnail != null">
- <el-image :src="item.thumbnail" >
- <div slot="error" class="image-slot">
- <i class="el-icon-picture-outline"></i>
- <p>图片加载失败</p>
- </div>
- </el-image>
- </dt>
- <dd class="msg-list-title">
- <!-- 未读有i,已读没有i -->
- <i :id="'i_' + item.smid" v-if="!item.isView"></i>
- {{item.title}}
- </dd>
- <dd class="msg-list-desc">
- {{item.desc}}
- </dd>
- <dd class="msg-list-time">
- <span>{{item.source}}</span>
- <i>{{item.create_time}}</i>
- </dd>
- </dl>
- <div class="no-data" v-if="msgList.length<=0"></div>
- </div>
- </div>
- <!-- 全部已读按钮 -->
- <div class="footer-bottom">
- <van-button type="default" block :disabled="isViewAll" @click="readAll">全部已读</van-button>
- </div>
- </div>
- </div>
- </body>
- <script type="text/javascript">
- space.vue = new Vue({
- el: space.appContent,
- data: function() {
- return {
- msgList: [],
- isViewAll: true, //消息是否全读
- }
- },
- mounted: function() {
- this.initData();
- // 获取是否有未读的消息
- this.getMsgNotReadFlag();
- },
- methods: {
- initData: function () {
- var that = this;
- space.plugin.paging.init({
- url: '@service{name: "system_message_list" }@',
- data: that.obj,
- up: function (resp) {
- that.msgList.push.apply(that.msgList, resp.sysMsgList);
- },
- down: function () {
- that.msgList = [];
- },
- });
- },
- msgInfo: function(item) {
- var that = this;
- // 点击后不能刷新
- var view = $("#" + item.smid).attr("data-view");
- // 未读
- if(!item.isView && !view) {
- if(space.utils.isNull(item.smid)) {
- console.error("未获取到消息ID")
- return;
- }
- space.utils.ajax({
- url: '@service{ name:`system_message_have_read` }@',
- data: {
- smid: item.smid
- },
- dataType: 'json',
- callback: function(data) {
- if(data.code == "success") {
- $("#" + item.smid).attr("data-view", "true");
- $("#i_" + item.smid).remove();
- }else {
- space.message.error(data.msg);
- }
- }
- });
- }
- // 可以跳转
- if(item.jump_flag) {
- var params = JSON.parse(item.params);
- var paramsStr = "";
- for (var key in params) {
- paramsStr += "&" + key + "=" + params[key];
- }
- space.plugin.layer.open({
- url: "/apps?ark=" + item.name + "&destination=" + item.page + paramsStr +"",
- refresh: true,
- });
- }
-
- },
- //获取是否有未读的消息
- getMsgNotReadFlag: function() {
- var that = this;
- space.utils.ajax({
- url: '@service{ name:`system_message_not_read` }@',
- dataType: 'json',
- loadLayer: false,
- callback: function(data) {
- if(data.code == "success") {
- that.isViewAll = !data.notReadFlag;
- }else{
- space.message.error("消息接口异常");
- }
- }
- });
- },
- // 全部已读
- readAll: function () {
- this.$dialog.confirm({
- title: '全部已读',
- message: '标记所有消息为已读, 是否继续?',
- })
- .then(() => {
- // on confirm
- space.utils.ajax({
- url: '@service{ name:`system_message_all_have_read` }@',
- dataType: 'json',
- callback: function(data) {
- if(data.code == "success") {
- space.plugin.paging.refresh();
- }else{
- space.message.error(data.msg);
- }
- }
- });
-
- })
- .catch(() => {
- // on cancel
- });
- }
- },
-
- })
- </script>
- </html>
|