| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213 | const _Http = getApp().globalData.http;import {    vIndate} from "../../../utils/pay"let DataCarousel = null,    funs = {};Page({    data: {        msgCount: 1,        subassembly: [], //首页部件        msgList: [], //消息列表        capsule: wx.getMenuButtonBoundingClientRect(), //胶囊位置信息    },    onLoad(options) {        this.refreshData() //更新权限等信息        getApp().globalData.http.refreshData = this.refreshData.bind(this);        vIndate();    },    /* 更新站点信息 */    refreshData() {        this.setData({            user: wx.getStorageSync('userMsg')        })        if (wx.getStorageSync('userauth').length != 0) {            let authList = {},                gridList = [];            const apps = getApp().globalData.queryPer.query(wx.getStorageSync('userauth'), ['营销工具'], ['通告', '推广素材', '商学院', '提报', '销售线索', '营销物料']),                paths = [{                    label: "通告",                    name: "wnotice",                    path: "/pages/annunciate/index",                    icon: "icon-a-shouyejingangqutonggao"                }, {                    label: "商学院",                    name: "warchives_sc",                    path: "/pages/classroom/index",                    icon: "icon-a-shangxueyuanxuexi"                }, {                    label: "营销物料",                    name: "warchives",                    path: "/pages/tabbar/smartStore/index",                    icon: "icon-a-shouyejingangquyingxiaowuliao"                }, {                    label: "销售线索",                    name: "worderclue",                    path: "/pages/threadedTree/index",                    icon: "icon-xiaoshouxiansuo"                }, {                    label: "推广素材",                    name: "wpopularize",                    path: "/pages/promotional/index",                    icon: "icon-a-shouyejingangqutuiguangsucai"                }, {                    label: "提报",                    name: "wsubmitedit",                    path: "/pages/submission/index",                    icon: "icon-a-tibaoguanlitibao"                }];            apps.forEach(v => {                v.apps.forEach(s => {                    authList[s.name] = {                        options: s.meta.auth.map(a => a.option),                        optionnames: s.meta.auth.map(a => a.optionname),                    }                    if (authList[s.name].options.some(s => s == "read")) {                        if (s.name == "worderclue") {                            console.log(s.name)                            //更新销售线索徽标数据                            funs.getCount = () => {                                const index = this.data.gridList.findIndex(v => v.label == '销售线索');                                if (index == -1) return;                                _Http.basic({                                    "classname": "saletool.orderclue.web.orderclue",                                    "method": "getCount",                                    "content": {                                        "nocache": true,                                        "status": "待跟进",                                        content: Date.now()                                    }                                }, false).then(res => {                                    if (res.data.count == 0) res.data.count = '';                                    if (res.data.count > 99) res.data.count = '99+';                                    try {                                        this.data.gridList[index].count = res.data.count;                                    } catch (e) {}                                    this.setData({                                        gridList: this.data.gridList                                    })                                })                            };                        } else if (s.name == "wnotice" && s.meta.wedgits.find(a => a.wedgit == 'homenoticelist')) {                            //更新通告数据                            funs.queryNoticeList = () => {                                _Http.basic({                                    "classname": "saletool.notice.notice",                                    "method": "queryNoticeList",                                    "content": {                                        "nocache": true,                                        "pageNumber": 1,                                        "pageSize": 3,                                        content: Date.now()                                    }                                }, false).then(res => {                                    if (res.msg != '成功') return;                                    this.setData({                                        annunciateList: res.data,                                        unreadNum: res.total - res.tips.readNum                                    })                                });                            };                        }                        let data = paths.find(k => {                            return k.name == s.name                        });                        if (data) {                            data.isneedpay = s.isneedpay;                            gridList.push(data)                        }                    }                })            });            this.setData({                gridList            });            for (const key in funs) {                funs[key]()            };            /* 获取首页banner */            let banner = wx.getStorageSync('banner_list').find(v => v.location == "index_top");            if (banner) this.setData({                bannerList: banner.ads            });            wx.setStorageSync('authList', authList)            wx.setStorageSync('gridList', gridList)            return gridList        } else {            setTimeout(this.refreshData, 10);        }    },    /* 宫格区域应用程序 */    applications(e) {        getApp().globalData.evidence(e.currentTarget.dataset.item)    },    /* 去消息详情 */    toMsg(e) {        const {            item        } = e.currentTarget.dataset;        wx.navigateTo({            url: '/pages/tabbar/message/details?id=' + item.messageid,        })    },    /* 去通告 */    toAnnunciate() {        this.applications({            currentTarget: {                dataset: {                    item: this.data.gridList.find(v => v.label == '通告')                }            }        })    },    /* banner */    bannerClick(e) {        const {            item        } = e.currentTarget.dataset,            hyperlink = item.hyperlink.split(":");        if (hyperlink[0] == 'path') wx.navigateTo({            url: hyperlink[1]        })    },    onShow() {        this.getTabBar().init();        for (const key in funs) {            funs[key]()        }        /* 获取最新信息 */        _Http.basic({            "classname": "system.message.Message",            "method": "queryMessage",            content: {                nocache: true,                pageSize: 5,                type: "",                where: {}            },        }, false).then(res => {            if (res.msg != '成功') return wx.showToast({                title: res.msg,                icon: "none"            })            this.setData({                msgList: res.data,                notice: res.data[0]            })            if (this.data.msgList.length > 2) {                clearInterval(DataCarousel);                DataCarousel = setInterval(() => {                    let count = this.data.msgCount < this.data.msgList.length ? this.data.msgCount : 0;                    this.setData({                        msgCount: count + 1,                        notice: this.data.msgList[count]                    })                }, 5000)            }        });    },    onHide() {        clearInterval(DataCarousel);    },})
 |