123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- const _Http = getApp().globalData.http;
- Component({
- lifetimes: {},
- data: {
- active: 'home',
- Permission: ['首页', '信息', '我的'], //可看模块
- tabbarList: [{
- icon: 'icon-a-biaoqianlanshouyexuanzhong',
- acicon: 'icon-a-biaoqianlanshouyexuanzhong',
- text: '首页',
- url: '/pages/tabbar/home/index',
- name: 'home'
- },
- {
- icon: 'icon-a-biaoqianlanxiaoxi',
- acicon: 'icon-a-biaoqianlanxiaoxixuanzhong',
- text: '信息',
- url: '/pages/tabbar/message/index',
- name: 'message'
- },
- {
- icon: 'icon-a-biaoqianlanwode',
- acicon: 'icon-a-biaoqianlanwodexuanzhong',
- text: '我的',
- url: '/pages/tabbar/mine/index',
- name: 'mine'
- }
- ]
- },
- methods: {
- onChange(event) {
- let active = event.detail,
- obj = this.data.tabbarList.find(v => v.name == active);
- wx.switchTab({
- url: obj.url
- });
- this.setData({
- active
- });
- },
- init() {
- const page = getCurrentPages().pop();
- let obj = this.data.tabbarList.find(item => item.url === `/${page.route}`);
- this.setData({
- active: obj.name
- });
- //socket
- if (!getApp().globalData.socketEstablish) getApp().initSocket();
- if (!getApp().globalData.socketCallback) getApp().globalData.socketCallback = this.unReadMessageCount.bind(this);
- this.setUnReadMessageCount(getApp().globalData.fcount);
- getApp().globalData.Language.getLanguagePackage(this, obj.text);
- },
- /* 设置未读数量 */
- setUnReadMessageCount(fcount) {
- let i = this.data.tabbarList.findIndex(v => v.name == 'message');
- this.setData({
- [`tabbarList[${i}].fcount`]: fcount
- })
- },
- /* 更新信息数量 */
- unReadMessageCount() {
- _Http.basic({
- "classname": "system.message.Message",
- "method": "unReadMessageCount",
- "content": {
- nocache: true
- }
- }, false).then(res => {
- console.log('信息数量', res)
- if (res.code != '1') return;
- let fcount = res.data.fcount > 99 ? '99+' : res.data.fcount;
- if (res.data.fcount == 0) fcount = "";
- getApp().globalData.fcount = fcount;
- this.setUnReadMessageCount(fcount);
- })
- }
- },
- })
|