123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238 |
- const _Http = getApp().globalData.http;
- let DataCarousel = null;
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- bannerList: null, //banner列表
- user: {},
- annunciateList: [], //通告列表
- gridList: [],
- unreadNum: 0, //通告未读
- notice: "",
- msgCount: 1,
- subassembly: [], //首页部件
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
- //this.getTabBar().monitor();开启socket监听
- this.refreshData(wx.getStorageSync('userMsg')) //更新权限等信息
- this.setData({ //获取胶囊位置信息
- capsule: wx.getMenuButtonBoundingClientRect()
- })
- },
- /* 更新站点信息 */
- refreshData(item) {
- this.setData({
- user: item
- })
- /* 首页宫格授权查询 */
- 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;
- case "销售线索":
- gridList.push({
- name: "销售线索",
- path: "/pages/threadedTree/index",
- icon: "icon-xiaoshouxiansuo",
- apps: v.apps
- })
- //获取销售线索待办数量
- setTimeout(this.getCount, 100);
- break;
- };
- });
- /* 首页小组件查询 */
- let home = getApp().globalData.queryPer.query(wx.getStorageSync('userauth'), ['通用'], ['首页'])[0].apps[0].meta.wedgits;
- if (home.some(v => v.wedgit == 'homedatadisplay')) subassembly.push('homedatadisplay');
- this.setData({
- gridList,
- subassembly
- })
- }
- /* 获取banner */
- this.setData({
- bannerList: wx.getStorageSync('banner_list')[0].ads
- })
- this.queryNoticeList(0); //获取通告列表
- },
- /* 销售线索待办 */
- getCount() {
- const index = this.data.gridList.findIndex(v => v.name == '销售线索');
- if (!index) return;
- _Http.basic({
- "classname": "saletool.orderclue.web.orderclue",
- "method": "getCount",
- "content": {
- "nocache": true,
- "status": "待跟进"
- }
- }).then(res => {
- if (res.data.count == 0) return;
- if (res.data.count > 99) res.data.count = '99+';
- this.data.gridList[index].count = res.data.count;
- this.setData({
- gridList: this.data.gridList
- })
- })
- },
- /* 查看通告详情 */
- toAnnunciateDetails(e) {
- const {
- item
- } = e.currentTarget.dataset;
- let authList = this.data.annunciateAuthList;
- wx.navigateTo({
- url: `/pages/annunciate/details?id=${item.sat_noticeid}&auth=${authList}`,
- })
- },
- /* 获取通告列表 */
- queryNoticeList(i) {
- if (i == 5) return;
- _Http.basic({
- "classname": "saletool.notice.notice",
- "method": "queryNoticeList",
- "content": {
- "pageNumber": 1,
- "pageSize": 3
- }
- }, false).then(res => {
- if (res.msg != '成功') return this.queryNoticeList(i + 1);
- this.setData({
- annunciateList: res.data,
- unreadNum: res.total - res.tips.readNum
- })
- })
- },
- /* 获取最新信息 */
- queryMessage(i = 0) {
- _Http.basic({
- "classname": "system.message.Message",
- "method": "queryMessage",
- content: {
- nocache: true,
- pageNumber: 1,
- pageSize: 5,
- pageTotal: 1,
- type: "",
- where: {}
- },
- }).then(res => {
- if (res.msg != '成功') return (i <= 5) ? this.queryMessage(i + 1) : wx.showToast({
- title: res.msg,
- icon: "none"
- })
- 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)
- },
- /* 宫格区域应用程序 */
- 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.messageid,
- })
- },
- /* 去通告 */
- toAnnunciate() {
- this.applications({
- currentTarget: {
- dataset: {
- item: this.data.gridList.find(v => v.name == '通告')
- }
- }
- })
- },
- /* banner */
- bannerClick(e) {
- const hyperlink = e.currentTarget.dataset.hyperlink.split(":");
- if (hyperlink[0] == 'path') {
- wx.navigateTo({
- url: hyperlink[1]
- })
- }
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
- this.getTabBar().init();
- this.startDataCarousel();
- this.getCount(); //更新徽标数据
- this.queryMessage(0); //更新最新消息
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {
- clearInterval(DataCarousel);
- },
- })
|