123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- const _Http = getApp().globalData.http;
- Component({
- lifetimes: {
- ready: function () {
- if (this.data.count == 1) return;
- if (wx.getStorageSync('userauth') != 0) {
- //判断页面 以免一直触发
- const pages = getCurrentPages(),
- prevPage = pages[pages.length - 1];
- if (prevPage.route == 'pages/login/selectSite' || prevPage.route.includes('pages/tabbar/')) {
- const auth = getApp().globalData.queryPer.query(wx.getStorageSync('userauth'), ['营销工具'], ['营销物料']);
- if (auth.length == 1) this.setData({
- Permission: ['首页', '信息', '营销物料', '我的']
- })
- }
- }
- },
- },
- 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-biaoqianlanzhiku',
- acicon: 'icon-xiaochengxu_yingxiaowuliaoxuanzhong',
- text: '营销物料',
- url: '/pages/tabbar/smartStore/index',
- name: 'smartStore'
- },
- {
- icon: 'icon-a-biaoqianlanwode',
- acicon: 'icon-a-biaoqianlanwodexuanzhong',
- text: '我的',
- url: '/pages/tabbar/mine/index',
- name: 'mine'
- }
- ],
- },
- methods: {
- onChange({
- detail
- }) {
- if (detail == "smartStore") {
- let item = wx.getStorageSync('gridList').find(v => v.label == '营销物料');
- if (!item) return wx.showToast({
- title: `暂无进入‘营销物料’应用权限`,
- icon: "none",
- mask: true
- })
- getApp().globalData.evidence(item)
- } else {
- const obj = this.data.tabbarList.find(v => v.name == detail);
- wx.switchTab({
- url: obj.url
- });
- this.setData({
- active: detail
- });
- }
- },
- 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();
- getApp().globalData.socket = {
- that: this,
- callback: this.unReadMessageCount
- }
- this.unReadMessageCount()
- },
- /* 更新信息数量 */
- unReadMessageCount() {
- _Http.basic({
- "classname": "system.message.Message",
- "method": "unReadMessageCount",
- "content": {
- nochace: true
- }
- }, false).then(res => {
- if (res.msg != '成功') return;
- let fcount = res.data.fcount > 99 ? '99+' : res.data.fcount;
- if (res.data.fcount == 0) fcount = "";
- getApp().globalData.socket.that.setData({
- 'tabbarList[1].fcount': fcount
- })
- })
- }
- },
- })
|