|
|
@@ -1,5 +1,6 @@ |
|
|
|
// components/tabbar/tabbar.js |
|
|
|
const app = getApp() |
|
|
|
const $request = require('../../utils/request.js'); |
|
|
|
Component({ |
|
|
|
/** |
|
|
|
* 组件的属性列表 |
|
|
@@ -21,26 +22,26 @@ Component({ |
|
|
|
text: "首页", |
|
|
|
pagePath: "/pages/index/index", |
|
|
|
iconPath: "/images/tabbar/home-bar.png", |
|
|
|
selectedIconPath: "/images/tabbar/home-bar.png", |
|
|
|
selectedIconPath: "/images/tabbar/home-bar-selected.png", |
|
|
|
}, |
|
|
|
{ |
|
|
|
text: "发布需求", |
|
|
|
pagePath: "/pages/releaseModule/index", |
|
|
|
iconPath: "/images/tabbar/release-bar.png", |
|
|
|
selectedIconPath: "/images/tabbar/release-bar.png", |
|
|
|
selectedIconPath: "/images/tabbar/release-bar-selected.png", |
|
|
|
}, |
|
|
|
{ |
|
|
|
text: "消息", |
|
|
|
pagePath: "/pages/msgModule/index", |
|
|
|
iconPath: "/images/tabbar/msg-bar.png", |
|
|
|
selectedIconPath: "/images/tabbar/msg-bar.png", |
|
|
|
selectedIconPath: "/images/tabbar/msg-bar-selected.png", |
|
|
|
dot: false, |
|
|
|
}, |
|
|
|
{ |
|
|
|
text: "我的", |
|
|
|
pagePath: "/pages/myModule/index", |
|
|
|
iconPath: "/images/tabbar/my-bar.png", |
|
|
|
selectedIconPath: "/images/tabbar/my-bar.png", |
|
|
|
selectedIconPath: "/images/tabbar/my-bar-selected.png", |
|
|
|
}, |
|
|
|
] |
|
|
|
}, |
|
|
@@ -56,30 +57,41 @@ Component({ |
|
|
|
customerId: businessCommunicationCustomer.customerId |
|
|
|
}) |
|
|
|
} |
|
|
|
// 获取当前路由,如果是消息页的话要把消息的红点取消 |
|
|
|
this.getCurrentRouter(); |
|
|
|
|
|
|
|
// 如果 websocket 没有连接,连接 |
|
|
|
if (!app.globalData.isOnSocketOpen) { |
|
|
|
this.initWebSocket(); |
|
|
|
} |
|
|
|
|
|
|
|
// let _this = this; |
|
|
|
let tiems = setInterval(() => { |
|
|
|
// 如果此时openid已被赋值 |
|
|
|
if (!!app.globalData.openid) { |
|
|
|
this.getChatRecordTable(); |
|
|
|
clearInterval(tiems) |
|
|
|
} |
|
|
|
}, 500); |
|
|
|
}, |
|
|
|
/** |
|
|
|
* 组件的方法列表 |
|
|
|
*/ |
|
|
|
methods: { |
|
|
|
// 获取当前路由 |
|
|
|
getCurrentRouter() { |
|
|
|
let pages = getCurrentPages(); |
|
|
|
let currentPage = null; |
|
|
|
if (pages.length) { |
|
|
|
currentPage = pages[pages.length - 1]; |
|
|
|
} |
|
|
|
// 如果是消息页,置空红点 |
|
|
|
if (currentPage.route == "pages/msgModule/index") { |
|
|
|
this.setListDot(false); |
|
|
|
} |
|
|
|
getChatRecordTable() { |
|
|
|
this.setListDot(false); |
|
|
|
$request.get('/businessCommunicationDemand/getChatRecordTable.action').then(res => { |
|
|
|
// console.log(res,'res'); |
|
|
|
if(res.status == 0){ |
|
|
|
let chatRecordTable = res.data.chatRecordTable; |
|
|
|
let sum = 0; |
|
|
|
chatRecordTable.forEach(el=>{ |
|
|
|
sum += el.size; |
|
|
|
}) |
|
|
|
if(sum > 0){ |
|
|
|
this.setListDot(true); |
|
|
|
} |
|
|
|
} |
|
|
|
}).catch(err=>{ |
|
|
|
console.log(err); |
|
|
|
}) |
|
|
|
}, |
|
|
|
// init websocket |
|
|
|
initWebSocket() { |