| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201 | const _Http = getApp().globalData.http;let DataCarousel = null;Page({    /**     * 页面的初始数据     */    data: {        user: {},        annunciateList: [], //通告列表        gridList: [],        unreadNum: 0, //通告未读        notice: "",        msgCount: 1,        subassembly: [], //首页部件    },    /**     * 生命周期函数--监听页面加载     */    onLoad(options) {        if (wx.getStorageSync('userauth').length != 0) {            /* 首页宫格授权查询 */            let auth = getApp().globalData.queryPer.query(wx.getStorageSync('userauth'), ['营销工具'], ['通告', '推广素材', '商学院', '提报']),                gridList = [],                subassembly = [];            auth.forEach(v => {                switch (v.systemmodulename) {                    case "通告":                        gridList.push({                            name: "通告",                            path: "/pages/annunciate/index",                            icon: "icon-a-shouyejingangqutonggao",                            apps: v.apps                        });                        if (v.apps[0].meta.wedgits.some(value => value.wedgit == 'homenoticelist')) subassembly.push('homenoticelist');                        this.setData({                            annunciateAuthList: v.apps[0].meta.auth.map(v => v.optionname)                        });                        break;                    case "推广素材":                        gridList.push({                            name: "推广素材",                            path: "/pages/promotional/index",                            icon: "icon-a-shouyejingangqutuiguangsucai",                            apps: v.apps                        })                        break;                    case "商学院":                        gridList.push({                            name: "商学院",                            path: "/pages/college/index",                            icon: "icon-a-shangxueyuanxuexi",                            apps: v.apps                        })                        break;                    case "提报":                        gridList.push({                            name: "提报",                            path: "/pages/submission/index",                            icon: "icon-a-tibaoguanlitibao",                            apps: v.apps                        })                        break;                };            });            /* 假的线索入口 */            gridList.push({                name: "销售线索",                path: "/pages/threadedTree/index",                icon: "icon-xiaoshouxiansuo",                apps: {}            });            /* 首页小组件查询 */            let home = getApp().globalData.queryPer.query(wx.getStorageSync('userauth'), ['通用'], ['首页'])[0].apps[0].meta.wedgits;            console.log("首页", home)            if (home.some(v => v.wedgit == 'homedatadisplay')) subassembly.push('homedatadisplay');            this.setData({                gridList,                subassembly            })        }        this.refreshData(wx.getStorageSync('userMsg'))        this.setData({ //获取胶囊位置信息            capsule: wx.getMenuButtonBoundingClientRect()        })    },    /* 查看通告详情 */    toAnnunciateDetails(e) {        const {            item        } = e.currentTarget.dataset;        let authList = this.data.annunciateAuthList;        wx.navigateTo({            url: `/pages/annunciate/details?id=${item.sat_noticeid}&feedback=${authList.includes('反馈')}&auth=${authList}`,        })    },    /* 获取通告列表 */    queryNoticeList(i) {        if (i == 5) return;        _Http.basic({            "classname": "saletool.notice.notice",            "method": "queryNoticeList",            "content": {                "pageNumber": 1,                "pageSize": 3            }        }).then(res => {            console.log("通告列表", res)            if (res.msg != '成功') return this.queryNoticeList(i + 1);            this.setData({                annunciateList: res.data,                unreadNum: res.total - res.tips.readNum            })        })    },    /* 获取最新信息 */    queryMessage(i) {        if (i == 5) return;        _Http.basic({            "classname": "system.message.Message",            "method": "queryMessage",            content: {                nocache: true,                pageNumber: 1,                pageSize: 3,                pageTotal: 1,                type: "系统"            },        }).then(res => {            if (res.msg != '成功') return this.queryMessage(i + 1);            this.setData({                msgList: res.data,                notice: res.data[0]            })            this.startDataCarousel();        })    },    startDataCarousel() {        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)    },    /* 更新站点信息 */    refreshData(item) {        this.setData({            user: item        })        this.queryNoticeList(0); //获取通告列表        this.queryMessage(0)    },    /* 宫格区域应用程序 */    applications(e) {        const {            item        } = e.currentTarget.dataset;        wx.navigateTo({            url: `${item.path}?auth=${JSON.stringify(item.apps)}`,        });    },    /* 去消息详情 */    toMsg(e) {        const {            item        } = e.currentTarget.dataset;        wx.navigateTo({            url: '/pages/tabbar/message/details?id=' + item.objectid,        })    },    /* 去通告 */    toAnnunciate() {        this.applications({            currentTarget: {                dataset: {                    item: this.data.gridList.find(v => v.name == '通告')                }            }        })    },    /**     * 生命周期函数--监听页面显示     */    onShow() {        this.getTabBar().init();        this.startDataCarousel();    },    /**     * 生命周期函数--监听页面隐藏     */    onHide() {        clearInterval(DataCarousel);    },})
 |