zhaoxiaohai 3 سال پیش
والد
کامیت
bfaff82d85
4فایلهای تغییر یافته به همراه319 افزوده شده و 0 حذف شده
  1. 228 0
      pages/tabbar/workbench/index.js
  2. 4 0
      pages/tabbar/workbench/index.json
  3. 58 0
      pages/tabbar/workbench/index.scss
  4. 29 0
      pages/tabbar/workbench/index.wxml

+ 228 - 0
pages/tabbar/workbench/index.js

@@ -0,0 +1,228 @@
+Page({
+    data: {
+
+    },
+    onLoad(options) {
+        this.refreshData() //更新权限等信息
+        this.setData({ //最近使用记录
+            recorded: wx.getStorageSync('recorded') || []
+        })
+    },
+    /* 更新站点信息 */
+    refreshData() {
+        if (wx.getStorageSync('userauth').length != 0) {
+            let authList = {},
+                entrance = [{
+                    label: "通用",
+                    icon: "icon-tabxiangmu",
+                    list: dye([{
+                        name: "签到",
+                        path: "/packageA/clockIn/index",
+                        icon: "icon-a-wodemendianxinxidizhi"
+                    }, {
+                        name: "任务",
+                        path: "/packageA/work/index",
+                        icon: "icon-xiaochengxu_xiaoshouyuce"
+                    }, {
+                        name: "通讯录",
+                        path: "/packageA/contacts/index",
+                        icon: "icon-xiaochengxutongxunlu"
+                    }])
+                }, {
+                    label: "营销工具",
+                    icon: "icon-tabxiangmu",
+                    list: gettool()
+                }, {
+                    label: "CRM",
+                    icon: "icon-tabxiangmu",
+                    list: getcrm()
+                }];
+            //营销工具
+            function gettool() {
+                const paths = [{
+                    name: "通告",
+                    path: "/pages/annunciate/index",
+                    icon: "icon-a-shouyejingangqutonggao"
+                }, {
+                    name: "营销物料",
+                    path: "/pages/tabbar/smartStore/index",
+                    icon: "icon-a-shouyejingangquyingxiaowuliao",
+                    openType: "switchTab"
+                }, {
+                    name: "推广素材",
+                    path: "/pages/promotional/index",
+                    icon: "icon-a-shouyejingangqutuiguangsucai"
+                }, {
+                    name: "商学院",
+                    path: "/pages/college/index",
+                    icon: "icon-a-shangxueyuanxuexi"
+                }, {
+                    name: "提报",
+                    path: "/pages/submission/index",
+                    icon: "icon-a-tibaoguanlitibao"
+                }];
+                let tool = getApp().globalData.queryPer.query(wx.getStorageSync('userauth'), ['营销工具'], paths.map(v => v.name)),
+                    list = [];
+                tool.forEach(v => {
+                    let auth = v.apps[0].meta.auth;
+                    if (!auth.some(r => r.option == 'read')) return;
+                    authList[v.apps[0].name] = {
+                        options: auth.map(a => a.option),
+                        optionnames: auth.map(a => a.optionname)
+                    };
+                    let item = paths.find(s => s.name == v.systemmodulename);
+                    item && list.push(item)
+                });
+
+                return dye(list)
+            };
+            //CRM
+            function getcrm() {
+                const paths = [{
+                    name: "市场活动",
+                    path: "/packageA/activity/index",
+                    icon: "icon-shichanghuodong",
+                }, {
+                    name: "公海线索",
+                    path: "/packageA/publicClue/index",
+                    icon: "icon-xiaochengxu_xiaoshoumubiao"
+                }, {
+                    name: "销售线索",
+                    path: "/packageA/saleClue/index",
+                    icon: "icon-xiaoshouxiansuo"
+                }, {
+                    name: "公海客户",
+                    path: "/packageA/publicCustomer/index",
+                    icon: "icon-xiaochengxutongxunlu"
+                }, {
+                    name: "客户",
+                    path: "/packageA/setclient/index",
+                    icon: "icon-kehu"
+                }, {
+                    name: "项目商机",
+                    path: "/packageA/project/index",
+                    icon: "icon-xiangmushangji"
+                }, {
+                    name: "报价单",
+                    path: "/packageA/offers/index",
+                    icon: "icon-xiangmubaojia"
+                }, {
+                    name: "竞争对手",
+                    path: "/packageA/opponent/index",
+                    icon: "icon-jingzhengduishou"
+                }, {
+                    name: "合同",
+                    path: "/packageA/contract/index",
+                    icon: "icon-hetong"
+                }, {
+                    name: "销售目标",
+                    path: "/packageA/target/index",
+                    icon: "icon-xiaochengxu_xiaoshoumubiao"
+                }, {
+                    name: "销售预测",
+                    path: "/packageA/salesForecasting/index",
+                    icon: "icon-xiaochengxu_xiaoshouyuce"
+                }];
+                let crm = getApp().globalData.queryPer.query(wx.getStorageSync('userauth'), ['CRM'], ['销售预测', '销售线索', '销售目标', '合同管理', '客户管理', '项目管理']),
+                    list = [];
+                crm.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")) {
+                            let i = paths.findIndex(k => k.name == s.meta.title);
+                            if (i != -1) {
+                                paths[i].index = i;
+                                list.push(paths[i])
+                            }
+                        }
+                    })
+                });
+                return dye(list.sort((a, b) => a.index - b.index))
+            };
+            //染色
+            function dye(list) {
+                let colorList = [{
+                    color: "#3874F6",
+                    bColor: "#F0F3FF",
+                }, {
+                    color: "#5AB73F",
+                    bColor: "#F4FAEF",
+                }, {
+                    color: "#F29C37",
+                    bColor: "#FCF6EF",
+                }, {
+                    color: "#EB4B5C",
+                    bColor: "#FDF1ED",
+                }, {
+                    color: "#3874F6",
+                    bColor: "#F0F3FF",
+                }, {
+                    color: "#F29C37",
+                    bColor: "#FCF6EF",
+                }, {
+                    color: "#EB4B5C",
+                    bColor: "#FDF1ED",
+                }, {
+                    color: "#3874F6",
+                    bColor: "#F0F3FF",
+                }, {
+                    color: "#5AB73F",
+                    bColor: "#F4FAEF",
+                }, {
+                    color: "#F29C37",
+                    bColor: "#FCF6EF",
+                }, {
+                    color: "#5AB73F",
+                    bColor: "#F4FAEF",
+                }, {
+                    color: "#3874F6",
+                    bColor: "#F0F3FF",
+                }, {
+                    color: "#F29C37",
+                    bColor: "#FCF6EF",
+                }, {
+                    color: "#EB4B5C",
+                    bColor: "#FDF1ED",
+                }, {
+                    color: "#5AB73F",
+                    bColor: "#F4FAEF",
+                }];
+                return list.map((v, i) => {
+                    return {
+                        ...v,
+                        ...colorList[i > colorList.length - 1 ? i - colorList.length : i]
+                    }
+                })
+            };
+            this.setData({
+                entrance
+            })
+            wx.setStorageSync('auth', authList)
+        } else {
+            setTimeout(this.refreshData, 10);
+            return;
+        }
+    },
+    /* 使用记录 */
+    openRecord(e) {
+        let {
+            item
+        } = e.currentTarget.dataset;
+        if (!item) return;
+        this.data.recorded.unshift(item);
+        let recorded = this.data.recorded.reduce((pre, cur) => {
+            if (!pre.some(v => v.name == cur.name)) pre.push(cur)
+            return pre
+        }, []);
+        this.setData({
+            recorded: recorded.slice(0, 5)
+        })
+        wx.setStorage('recorded', recorded.slice(0, 5))
+    },
+    onShow() {
+        this.getTabBar().init();
+    },
+})

+ 4 - 0
pages/tabbar/workbench/index.json

@@ -0,0 +1,4 @@
+{
+    "usingComponents": {},
+    "navigationBarTitleText": "工作台"
+}

+ 58 - 0
pages/tabbar/workbench/index.scss

@@ -0,0 +1,58 @@
+.box {
+    width: 100vw;
+    background-color: #fff;
+    box-sizing: border-box;
+    padding-top: 30rpx;
+
+    .group {
+        margin-bottom: 30rpx;
+
+        .label {
+            height: 36rpx;
+            font-size: 30rpx;
+            font-family: AppleSystemUIFont-Bold, AppleSystemUIFont;
+            font-weight: bold;
+            color: #333333;
+            margin-bottom: 10rpx;
+
+            text {
+                margin: 0 20rpx 0 30rpx;
+            }
+        }
+
+        .main {
+            display: flex;
+            flex-wrap: wrap;
+
+            .item {
+                display: flex;
+                flex-direction: column;
+                align-items: center;
+                padding: 20rpx 0;
+                width: 20%;
+                border-radius: 16rpx;
+
+                .icon-box {
+                    width: 80rpx;
+                    border-radius: 16rpx;
+                    line-height: 80rpx;
+                    text-align: center;
+
+                    text {
+                        font-size: 40rpx;
+                    }
+                }
+
+                .name {
+                    width: 80%;
+                    line-height: 30rpx;
+                    font-size: 24rpx;
+                    font-family: AppleSystemUIFont-Regular, AppleSystemUIFont;
+                    color: #333333;
+                    margin-top: 16rpx;
+                    text-align: center;
+                }
+            }
+        }
+    }
+}

+ 29 - 0
pages/tabbar/workbench/index.wxml

@@ -0,0 +1,29 @@
+<view wx:if="{{recorded.length}}" class="box">
+    <view class="group">
+        <view class="label"><text class="iconfont icon-tabgenjindongtai1" />最近使用</view>
+        <view class="main">
+            <navigator class="item" wx:for="{{recorded}}" wx:for-item="it" wx:for-index="i" url="{{it.path}}" open-type="{{it.openType||'navigate'}}" wx:key="name" data-item="{{it}}" bindtap="openRecord">
+                <view class="icon-box" style="background-color: {{it.bColor}};">
+                    <text class="iconfont {{it.icon}}" style="color: {{it.color}};" />
+                </view>
+                <view class="name line-1">{{it.name}}</view>
+            </navigator>
+        </view>
+    </view>
+</view>
+<view class="box">
+    <block wx:for="{{entrance}}" wx:key="index">
+        <view class="group" wx:if="{{item.list.length}}">
+            <view class="label"><text class="iconfont {{item.icon}}" />{{item.label}}</view>
+            <view class="main">
+                <navigator class="item" wx:for="{{item.list}}" wx:for-item="it" wx:for-index="i" url="{{it.path}}" open-type="{{it.openType||'navigate'}}" wx:key="name" data-item="{{it}}" bindtap="openRecord">
+                    <view class="icon-box" style="background-color: {{it.bColor}};">
+                        <text class="iconfont {{it.icon}}" style="color: {{it.color}};" />
+                    </view>
+                    <view class="name line-1">{{it.name}}</view>
+                </navigator>
+            </view>
+        </view>
+    </block>
+</view>
+<view style="height: 140rpx;" />