Explorar o código

feat:消息中心接口联调

zhangsiya %!s(int64=2) %!d(string=hai) anos
pai
achega
b064900e7e

+ 75 - 69
src/web/staticres/frontRouter/pc/mesgCenter/js/index-pc.js

@@ -5,18 +5,17 @@ var vm = new Vue({
   data: function () {
     return {
       loading: false,
-      activeName: '0',
+      activeName: '-1',
       counts: [],
       kfCount: 0,
-      isTabs: '',
       shuntData: {},
       shunted: true,
       imgSrcs: [
-        { type: '0', title: '全部', url: '/images/pc/quanbu@2x.png' }, { type: '1', title: '活动通知', url: '/images/pc/huodong@2x.png' },
+        { type: '-1', title: '全部', url: '/images/pc/quanbu@2x.png' }, { type: '1', title: '活动通知', url: '/images/pc/huodong@2x.png' },
         { type: '2', title: '服务通知', url: '/images/pc/fuwu@2x.png' }, { type: '3', title: '订阅消息', url: '/images/pc/dingyue@2x.png' },
         { type: '4', title: '项目动态', url: '/images/pc/xiangmu@2x.png' }, { type: '5', title: '企业动态', url: '/images/pc/qiye@2x.png' },
         { type: '6', title: '分析报告', url: '/images/pc/fenxi@2x.png' }, { type: '7', title: '系统通知', url: '/images/pc/xitong@2x.png' },
-        { type: '8', title: '私信', url: '/images/pc/sixin@2x.png' }, { type: '9', title: '剑鱼学堂', url: '/images/pc/xuetang@2x.png' }
+        { type: '8', title: '剑鱼学堂', url: '/images/pc/xuetang@2x.png' }, { type: '9', title: '私信', url: '/images/pc/sixin@2x.png' }
       ],
       tabsList: {
         lasts: [],
@@ -24,16 +23,52 @@ var vm = new Vue({
         offset: 1,
         pageSize: 20,
         totals: 0,
-      }
+      },
+      // 全部的时候未读消息条数
+      unread: 0
     }
   },
   created() {
-    this.tabsCount()
-    this.tabsData('0')
+    this.getList()
     this.kfContacts()
     this.kfData()
   },
   methods: {
+    getList (msgType) {
+      var _this = this
+      var type = msgType !== null && msgType !== undefined ? Number(msgType) : -1
+      var params =  {
+        isColumn: true,
+        isColumnNewMsg: false,
+        isMsgList: true,
+        msgType: type,
+        isRead: -1,
+        offset: this.tabsList.offset,
+        size: this.tabsList.pageSize
+      }
+      this.loading = true
+      $.ajax({
+        url: '/messageCenter/MessageList',
+        type: 'POST',
+        data: JSON.stringify(params),
+        dataType: 'json',
+        headers: {'Content-Type': 'application/json'},
+        success:function (res) {
+          setTimeout(() => {
+            _this.loading = false
+          }, 300)
+           if(res.code === 0) {
+             _this.counts = res.column || []
+             _this.tabsList.lists = []
+             _this.tabsList.lasts = $.isEmptyObject(res.last) ? false : res.last
+             _this.tabsList.lists = $.isEmptyObject(res.data) ? false : res.data
+             _this.tabsList.totals = res.total
+             if(type === -1 ) _this.unread = res.unread
+           }
+        },
+        error:function () {}
+      })
+    },
     // 私信显示、隐藏
     kfContacts() {
       const _this = this
@@ -69,75 +104,35 @@ var vm = new Vue({
       goCustomerUrl({ openNewWindow: true })
     },
     tabClick(val) {
-      console.log(val)
-      this.isTabs = val.name
       this.tabsList.offset = 1
-      this.tabsData(val.name)
-    },
-    tabsCount() {
-      const _this = this
-      $.ajax({
-        type: 'GET',
-        url: '/jymessageCenter/ClassCount',
-        data: {},
-        success: function (res) {
-          if (res && res.status == 1) {
-            _this.counts = res.data
-          }
-        }
-      })
-    },
-    tabsData(num) {
-      const _this = this
-      this.loading = true
-      $.ajax({
-        type: 'POST',
-        url: '/jymessageCenter/messageList',
-        data: {
-          needFilter: 0,
-          msgType: num,
-          isRead: '-1',
-          offset: this.tabsList.offset,
-          pageSize: this.tabsList.pageSize
-        },
-        success: function (res) {
-          setTimeout(() => {
-            _this.loading = false
-          }, 300)
-          if (res && res.status == 1) {
-            _this.tabsList.lists = []
-            _this.tabsList.lasts = $.isEmptyObject(res.data.last) ? false : res.data.last
-            _this.tabsList.lists = $.isEmptyObject(res.data.list) ? false : res.data.list
-            _this.tabsList.totals = res.data.total
-          }
-        }
-      })
+      this.getList(val.name)
     },
     onPageChange(page) {
       this.tabsList.offset = page
-      this.tabsData(this.isTabs)
+      this.getList(this.activeName)
     },
-    readed(ids, type, url) {
+    readed(id, url) {
       const _this = this
       $.ajax({
         type: 'POST',
-        url: '/jymessageCenter/markRead',
-        data: {
-          msgId: ids,
-          msgType: type
-        },
+        url: '/messageCenter/markRead',
+        data: JSON.stringify({
+          msgId: id ? Number(id) : null
+        }),
+        headers: {'Content-Type': 'application/json'},
         success: function () {
-          _this.tabsData(_this.isTabs)
-          _this.tabsCount()
-          message.checkOpened()
-          message.checkMessage()
+          window.__canNextReadMessageStatus = false
+          _this.getList(_this.activeName)
+          if(message){
+            message.getMessageList()
+          }
           if (url) {
             location.href = url
-            window.__canNextReadMessageStatus = false
           }
         }
       })
     },
+    // 消息统计
     clickMesg(logid) {
       $.ajax({
         type: 'GET',
@@ -149,24 +144,35 @@ var vm = new Vue({
         success: function () { }
       })
     },
-    linked(id, url, str, num, type, msgLogid) {
+    linked(item) {
       if (window.__canNextReadMessageStatus) {
         return
       }
       window.__canNextReadMessageStatus = true
-      this.clickMesg(msgLogid)
-      if (str == 0) {
-        this.readed(id, type, url)
+      // this.clickMesg(item.msgLogid)
+      if (item.isRead == 0) {
+        this.readed(item.id, item.link)
       } else {
-        if (url) {
-          location.href = url
-          window.__canNextReadMessageStatus = false
+        window.__canNextReadMessageStatus = false
+        if (item.link) {
+          location.href = item.link
         }
       }
     },
     // 清楚未读
     cleanNoRead() {
-      console.dir('清除未读')
+      var _this = this
+      $.ajax({
+        url: '/messageCenter/ClearUnreadMsg',
+        type: 'POST',
+        success:function (res) {
+          _this.getList()
+          if(message){
+            message.getMessageList()
+          }
+        },
+        error:function () {}
+      })
     },
     jumpPushPage () {
       location.href = '/big/push_setting'

+ 22 - 22
src/web/templates/frontRouter/pc/messageCenter/sess/index.html

@@ -30,13 +30,12 @@
                         <span>推送设置</span>
                     </span>
                     <span class="handle-span flex" @click="cleanNoRead">
-                       <img class="clean-icon" src="/images/pc/msg_clean.png" alt="">
-<!--                        <img class="clean-icon" src="/images/pc/msg_no_clean.png" alt="">-->
-                        <span>清除未读</span>
+                       <img class="clean-icon" :src="unread > 0 ? '/images/pc/msg_clean.png' : '/images/pc/msg_no_clean.png'" alt="">
+                        <span :style="unread > 0 ? 'color:#1d1d1d;' : 'color: #aaa;'">清除未读</span>
                     </span>
                 </p>
             </div>
-          <div class="tips" @click="linked(tabsList.lasts.id, tabsList.lasts.link, tabsList.lasts.isRead,1,tabsList.lasts.msg_type,tabsList.lasts.msgLogId)" v-show="tabsList.lasts">
+          <div class="tips" @click="linked(tabsList.lasts)" v-show="tabsList.lasts">
             <div class="imgs">
               <img :src='imgSrcs[tabsList.lasts.msg_type].url' v-if="tabsList.lasts.msg_type">
               <i class="dots" v-if="tabsList.lasts.isRead == 0"></i>
@@ -51,29 +50,30 @@
           </div>
           <div class="tabs-mesg" :class="{'is-tabs':tabsList.totals < 20}">
             <el-tabs v-model="activeName" @tab-click="tabClick">
-              <el-tab-pane v-for="(item, index) in counts" :key="index" :name="imgSrcs[item.type].type">
+              <el-tab-pane v-for="(item, index) in counts" :key="index" :name="'' + item.msg_type">
                 <div class="msg-label" slot="label">
-                  <img :src='imgSrcs[item.type].url'>
-                  <i class="b-item" v-show="item.count">{item.count > 99 ? '99+' : item.count}</i>
-                  <p class="words">{imgSrcs[item.type].title}</p>
+                  <img :src='item.img'>
+                  <i class="b-item" v-show="item.unreadMessages">{item.unreadMessages > 99 ? '99+' : item.unreadMessages}</i>
+                  <p class="words">{item.name}</p>
                 </div>
                 <div v-loading="loading">
                 <div
                   class="tips tab-tips"
-                  v-for="(ite, indx) in tabsList.lists"
-                  @click="linked(ite.id, ite.link, ite.isRead,2,ite.msg_type,ite.msgLogId)"
+                  v-for="(temp, indx) in tabsList.lists"
+                  :key="'message_' + indx"
+                  @click="linked(temp)"
                   v-if="tabsList.lists"
                 >
                   <div class="imgs">
-                    <img :src='imgSrcs[ite.msg_type].url'>
-                    <i class="dots" v-show="!ite.isRead"></i>
+                    <img :src='imgSrcs[temp.msg_type].url'>
+                    <i class="dots" v-show="!temp.isRead"></i>
                   </div>
                   <div class="r-lis">
                       <div class="title">
-                          <span>{ite.title}</span>
-                          <span>{dateMatter(ite.createtime)}</span>
+                          <span>{temp.title}</span>
+                          <span>{dateMatter(temp.createtime)}</span>
                       </div>
-                      <p>{ite.content}</p>
+                      <p>{temp.content}</p>
                   </div>
                 </div>
               </div>
@@ -90,13 +90,13 @@
                   ></el-pagination>
                 </div>
               </el-tab-pane>
-              <el-tab-pane v-if="shunted">
-                <div class="msg-label" slot="label" @click="kfHref">
-                  <img src='{{Msg "seo" "cdn"}}/frontRouter/pc/mesgCenter/image/sixin@2x.png?v={{Msg "seo" "version"}}'>
-                  <i class="b-item" v-show="kfCount">{kfCount > 99 ? '99+' : kfCount}</i>
-                  <p class="words">私信</p>
-                </div>
-              </el-tab-pane>
+<!--              <el-tab-pane v-if="shunted">-->
+<!--                <div class="msg-label" slot="label" @click="kfHref">-->
+<!--                  <img src='{{Msg "seo" "cdn"}}/frontRouter/pc/mesgCenter/image/sixin@2x.png?v={{Msg "seo" "version"}}'>-->
+<!--                  <i class="b-item" v-show="kfCount">{kfCount > 99 ? '99+' : kfCount}</i>-->
+<!--                  <p class="words">私信</p>-->
+<!--                </div>-->
+<!--              </el-tab-pane>-->
             </el-tabs>
           </div>
         </div>