1008310527_edit.jsp 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. <html>
  2. <head>
  3. <style>
  4. body{
  5. background-color: #f5f6fa;
  6. }
  7. #space-content{
  8. background-color: transparent;
  9. }
  10. .msg-list{
  11. box-sizing: border-box;
  12. width: 100%;
  13. padding: 20px;
  14. padding-bottom: 0;
  15. }
  16. .msg-list dl{
  17. margin-bottom: 20px;
  18. background-color: #fff;
  19. border-radius: 6px;
  20. overflow: hidden;
  21. }
  22. .msg-list dl:last-child{
  23. margin-bottom: 0;
  24. }
  25. .msg-list dt,
  26. .msg-list dt img{
  27. width: 100%;
  28. }
  29. .msg-list dt{
  30. text-align: center;
  31. }
  32. .msg-list dd{
  33. padding: 0 20px;
  34. color: #666;
  35. }
  36. .msg-list-title,
  37. .msg-list-desc{
  38. display: -webkit-box;
  39. -webkit-box-orient: vertical;
  40. -webkit-line-clamp: 2;
  41. overflow: hidden;
  42. }
  43. .msg-list .msg-list-title{
  44. font-size: 16px;
  45. color: #000;
  46. line-height: 24px;
  47. margin: 12px 0 6px;
  48. position: relative;
  49. }
  50. .msg-list-title i{
  51. display: inline-block;
  52. width: 6px;
  53. height: 6px;
  54. border-radius: 50%;
  55. background-color: #f56c6c;
  56. position: absolute;
  57. top: 10px;
  58. left: 10px;
  59. }
  60. .msg-list .msg-list-desc{
  61. -webkit-line-clamp: 2;
  62. line-height: 20px;
  63. font-size: 12px;
  64. }
  65. .msg-list .msg-list-time{
  66. margin-top: 10px;
  67. font-size: 14px;
  68. padding-top: 10px;
  69. padding-bottom: 10px;
  70. position: relative;
  71. overflow: hidden;
  72. }
  73. .msg-list .msg-list-time::before{
  74. content: "";
  75. position: absolute;
  76. top: 0;
  77. left: 15px;
  78. width: calc(100% - 30px);
  79. height: 1px;
  80. background-color: #eee;
  81. }
  82. .msg-list-time i{
  83. font-style: normal;
  84. float: right;
  85. margin-top: 1px;
  86. }
  87. .layui-laypage a, .layui-laypage span,
  88. .layui-laypage input, .layui-laypage button{
  89. background-color: transparent;
  90. }
  91. .image-slot{
  92. color: #ccc;
  93. }
  94. .image-slot i{
  95. font-size: 36px;
  96. padding-top: 20px;
  97. padding-bottom: 10px;
  98. }
  99. .footer-bottom {
  100. width: 100%;
  101. background-color: #fff;
  102. position: fixed;
  103. bottom: 0;
  104. left: 0;
  105. text-align: center;
  106. }
  107. </style>
  108. </head>
  109. <body>
  110. <div id="space-content">
  111. <div class="content-wrap">
  112. <div id="mescroll" class="mescroll">
  113. <div id="msgList" class="msg-list">
  114. <dl :id="item.smid" :data-view="item.isView" v-for="item in msgList" @click="msgInfo(item)">
  115. <dt v-if="item.thumbnail != null">
  116. <el-image :src="item.thumbnail" >
  117. <div slot="error" class="image-slot">
  118. <i class="el-icon-picture-outline"></i>
  119. <p>图片加载失败</p>
  120. </div>
  121. </el-image>
  122. </dt>
  123. <dd class="msg-list-title">
  124. <!-- 未读有i,已读没有i -->
  125. <i :id="'i_' + item.smid" v-if="!item.isView"></i>
  126. {{item.title}}
  127. </dd>
  128. <dd class="msg-list-desc">
  129. {{item.desc}}
  130. </dd>
  131. <dd class="msg-list-time">
  132. <span>{{item.source}}</span>
  133. <i>{{item.create_time}}</i>
  134. </dd>
  135. </dl>
  136. <div class="no-data" v-if="msgList.length<=0"></div>
  137. </div>
  138. </div>
  139. <!-- 全部已读按钮 -->
  140. <div class="footer-bottom">
  141. <van-button type="default" block :disabled="isViewAll" @click="readAll">全部已读</van-button>
  142. </div>
  143. </div>
  144. </div>
  145. </body>
  146. <script type="text/javascript">
  147. space.vue = new Vue({
  148. el: space.appContent,
  149. data: function() {
  150. return {
  151. msgList: [],
  152. isViewAll: true, //消息是否全读
  153. }
  154. },
  155. mounted: function() {
  156. this.initData();
  157. // 获取是否有未读的消息
  158. this.getMsgNotReadFlag();
  159. },
  160. methods: {
  161. initData: function () {
  162. var that = this;
  163. space.plugin.paging.init({
  164. url: '@service{name: "system_message_list" }@',
  165. data: that.obj,
  166. up: function (resp) {
  167. that.msgList.push.apply(that.msgList, resp.sysMsgList);
  168. },
  169. down: function () {
  170. that.msgList = [];
  171. },
  172. });
  173. },
  174. msgInfo: function(item) {
  175. var that = this;
  176. // 点击后不能刷新
  177. var view = $("#" + item.smid).attr("data-view");
  178. // 未读
  179. if(!item.isView && !view) {
  180. if(space.utils.isNull(item.smid)) {
  181. console.error("未获取到消息ID")
  182. return;
  183. }
  184. space.utils.ajax({
  185. url: '@service{ name:`system_message_have_read` }@',
  186. data: {
  187. smid: item.smid
  188. },
  189. dataType: 'json',
  190. callback: function(data) {
  191. if(data.code == "success") {
  192. $("#" + item.smid).attr("data-view", "true");
  193. $("#i_" + item.smid).remove();
  194. }else {
  195. space.message.error(data.msg);
  196. }
  197. }
  198. });
  199. }
  200. // 可以跳转
  201. if(item.jump_flag) {
  202. var params = JSON.parse(item.params);
  203. var paramsStr = "";
  204. for (var key in params) {
  205. paramsStr += "&" + key + "=" + params[key];
  206. }
  207. space.plugin.layer.open({
  208. url: "/apps?ark=" + item.name + "&destination=" + item.page + paramsStr +"",
  209. refresh: true,
  210. });
  211. }
  212. },
  213. //获取是否有未读的消息
  214. getMsgNotReadFlag: function() {
  215. var that = this;
  216. space.utils.ajax({
  217. url: '@service{ name:`system_message_not_read` }@',
  218. dataType: 'json',
  219. loadLayer: false,
  220. callback: function(data) {
  221. if(data.code == "success") {
  222. that.isViewAll = !data.notReadFlag;
  223. }else{
  224. space.message.error("消息接口异常");
  225. }
  226. }
  227. });
  228. },
  229. // 全部已读
  230. readAll: function () {
  231. this.$dialog.confirm({
  232. title: '全部已读',
  233. message: '标记所有消息为已读, 是否继续?',
  234. })
  235. .then(() => {
  236. // on confirm
  237. space.utils.ajax({
  238. url: '@service{ name:`system_message_all_have_read` }@',
  239. dataType: 'json',
  240. callback: function(data) {
  241. if(data.code == "success") {
  242. space.plugin.paging.refresh();
  243. }else{
  244. space.message.error(data.msg);
  245. }
  246. }
  247. });
  248. })
  249. .catch(() => {
  250. // on cancel
  251. });
  252. }
  253. },
  254. })
  255. </script>
  256. </html>