123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175 |
- const _Http = getApp().globalData.http;
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- user: {},
- annunciateList: [], //通告列表
- gridList: [],
- showAnnunciate: false, //显示最新通告
- unreadNum: 0, //通告未读
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
- if (wx.getStorageSync('userauth').length != 0) {
- let auth = getApp().globalData.queryPer.query(wx.getStorageSync('userauth'), ['营销工具'], ['通告', '推广素材', '商学院', '提报']);
- let gridList = [];
- auth.forEach(v => {
- switch (v.systemmodulename) {
- case "通告":
- gridList.push({
- name: "通告",
- path: "/pages/annunciate/index",
- icon: "icon-a-shouyejingangqutonggao",
- apps: v.apps
- });
- let annunciateAuthList = v.apps[0].meta.auth.map(v => v.optionname);
- this.setData({
- showAnnunciate: true,
- annunciateAuthList
- });
- 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;
- };
- });
- this.setData({
- gridList
- })
- }
- 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
- })
- })
- },
- /* 更新站点信息 */
- refreshData(item) {
- this.setData({
- user: item
- })
- this.queryNoticeList(0); //获取通告列表
- },
- /* 宫格区域应用程序 */
- applications(e) {
- const {
- item
- } = e.currentTarget.dataset;
- wx.navigateTo({
- url: `${item.path}?auth=${JSON.stringify(item.apps)}`,
- });
- },
- /* 去通告 */
- toAnnunciate() {
- this.applications({
- currentTarget: {
- dataset: {
- item: this.data.gridList.find(v => v.name == '通告')
- }
- }
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
- this.getTabBar().init();
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {
- }
- })
|