123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260 |
- const _Http = getApp().globalData.http;
- let DataCarousel = null,
- funs = {};
- Page({
- data: {
- msgCount: 1,
- subassembly: [], //首页部件
- msgList: [], //消息列表
- capsule: wx.getMenuButtonBoundingClientRect(), //胶囊位置信息
- },
- onLoad(options) {
- this.refreshData() //更新权限等信息
- },
- /* 更新站点信息 */
- 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") {
- //更新销售线索徽标数据
- 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": "待跟进"
- }
- }, 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
- }
- }, 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)
- } else {
- setTimeout(this.refreshData, 10);
- }
- },
- /* 宫格区域应用程序 */
- applications(e) {
- const {
- item
- } = e.currentTarget.dataset,
- userType = wx.getStorageSync('userMsg').usertype,
- isLeader = userType == 21 || userType == 22;
- console.log("跳转", item)
- //应用是否开通,开通直接跳转
- if (!item.isneedpay) {
- wx.showModal({
- title: '提示',
- content: `当前模块未付费,是否付费使用?`,
- confirmText: "前往付费",
- cancelText: isLeader ? "取消" : "提醒付费",
- complete: (res) => {
- if (res.confirm) {
- _Http.basic({
- "classname": "system.payorder.payorder",
- "method": "createOrder",
- "content": {},
- }).then(res => {
- console.log("新建订单", res)
- if (res.msg != '成功') return wx.showToast({
- title: res.msg,
- icon: "none",
- mask: true
- });
- wx.navigateTo({
- url: '/pages/teams/addOrder?sys_payorderid=' + res.data.sys_payorderid
- })
- })
- }
- if (res.cancel) {
- if (!isLeader) _Http.basic({
- "classname": "system.payorder.payorder",
- "method": "sendMessage",
- "content": {
- "sys_payorderid": ""
- }
- }).then(s => {
- wx.showToast({
- title: '已发送消息到主体主账号',
- icon: "none"
- })
- })
- }
- }
- })
- } else {
- if (item.label == "营销物料") {
- wx.switchTab({
- url: item.path
- });
- } else {
- wx.navigateTo({
- url: item.path
- });
- }
- }
- },
- /* 去消息详情 */
- 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 {
- 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);
- },
- })
|