Browse Source

跳转小程序逻辑

zhaoxiaohai 2 years ago
parent
commit
c1c6876cc1
4 changed files with 331 additions and 176 deletions
  1. 37 1
      app.js
  2. 239 118
      pages/tabbar/home/index.js
  3. 40 38
      pages/tabbar/home/index.scss
  4. 15 19
      pages/tabbar/home/index.wxml

+ 37 - 1
app.js

@@ -3,7 +3,43 @@ import {
 } from './utils/Api';
 
 App({
-    onLaunch() {},
+    onLaunch(options) {
+        //小程序跳转进入
+        if (options.query.userMsg) {
+            wx.setStorageSync('userMsg', JSON.parse(options.query.userMsg))
+            wx.setStorageSync('auth', JSON.parse(options.query.auth))
+            //获取用户权限 
+            this.globalData.http.basic({
+                "classname": "sysmanage.develop.userauth.userauth",
+                "method": "query_userauth",
+                content: {
+                    nocache: true
+                }
+            }).then(res => {
+                console.log("跳转进入查询权限", res)
+                if (res.msg != '成功') return wx.showToast({
+                    title: '权限查询失败,请稍后再试',
+                    icon: "none"
+                })
+                wx.setStorageSync('userauth', res.data);
+            });
+            // 查询站点数据
+            this.globalData.http.basic({
+                "classname": "webmanage.site.site",
+                "method": "querySite_Parameter",
+                "content": {}
+            }).then(res => {
+                console.log("跳转进入查询站点数据", res)
+                if (res.msg != '成功') return wx.showToast({
+                    title: res.msg,
+                    icon: "none"
+                });
+                wx.setStorageSync('siteP', res.data);
+            });
+            console.log('跳转进入', wx.getStorageSync('userMsg'))
+            console.log('跳转进入', wx.getStorageSync('auth'))
+        }
+    },
     initSocket() {
         let that = this;
         this.globalData.SocketTask = wx.connectSocket({

+ 239 - 118
pages/tabbar/home/index.js

@@ -2,6 +2,7 @@ let _Http = getApp().globalData.http,
     DataCarousel = null;
 Page({
     data: {
+        appid: "wxc1b6ae925ac1d06a",
         bannerList: [], //banner列表
         gridList: [],
         notice: "",
@@ -9,6 +10,7 @@ Page({
         msgList: [], //消息列表
     },
     onLoad(options) {
+        console.log(options)
         this.setData({ //获取胶囊位置信息
             capsule: wx.getMenuButtonBoundingClientRect()
         })
@@ -77,17 +79,233 @@ Page({
         routeList[i].index = i
         return routeList[i]
     },
+
     /* 更新站点信息 */
     refreshData() {
         this.setData({
             user: wx.getStorageSync('userMsg')
         })
-        /* 首页宫格授权查询 */
         if (wx.getStorageSync('userauth').length != 0) {
-            let auth = getApp().globalData.queryPer.query(wx.getStorageSync('userauth'), ["E-订单"], ["商品档案", "销售管理", "财务管理", "售后管理", "发货与库存", "业绩查询"]),
-                gridList = [],
-                authList = [],
-                colorList = [{
+            let authList = {},
+                entrance = [{
+                    label: "E-订单",
+                    appid: "wxc1b6ae925ac1d06a",
+                    icon: "work-E-dingdan",
+                    list: getedd()
+                }, {
+                    label: "通用",
+                    icon: "work-tongyong",
+                    appid: "wx08b337e860e3ea58",
+                    list: dye([{
+                        name: "签到",
+                        path: "/packageA/clockIn/index",
+                        icon: "work-a-wodemendianxinxidizhi"
+                    }, {
+                        name: "任务",
+                        path: "/packageA/work/index",
+                        icon: "work-a-woderenwuzhongxin"
+                    }, {
+                        name: "通讯录",
+                        path: "/packageA/contacts/index",
+                        icon: "work-xiaochengxutongxunlu"
+                    }])
+                }, {
+                    label: "营销工具",
+                    icon: "work-E-dingdan",
+                    appid: "wx08b337e860e3ea58",
+                    list: gettool()
+                }, {
+                    label: "CRM",
+                    appid: "wx08b337e860e3ea58",
+                    icon: "work-CRM",
+                    list: getcrm()
+                }];
+            //营销工具
+            function gettool() {
+                const paths = [{
+                    name: "通告",
+                    path: "/pages/annunciate/index",
+                    icon: "work-a-shouyejingangqutonggao"
+                }, {
+                    name: "营销物料",
+                    path: "/pages/tabbar/smartStore/index",
+                    icon: "work-a-shouyejingangquyingxiaowuliao",
+                    openType: "switchTab"
+                }, {
+                    name: "推广素材",
+                    path: "/pages/promotional/index",
+                    icon: "work-a-shouyejingangqutuiguangsucai"
+                }, {
+                    name: "商学院",
+                    path: "/pages/college/index",
+                    icon: "work-a-shangxueyuanxuexi"
+                }, {
+                    name: "提报",
+                    path: "/pages/submission/index",
+                    icon: "work-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: "work-shichanghuodong",
+                }, {
+                    name: "公海线索",
+                    path: "/packageA/publicClue/index",
+                    icon: "work-xiaochengxu_xiaoshoumubiao"
+                }, {
+                    name: "销售线索",
+                    path: "/packageA/saleClue/index",
+                    icon: "work-xiaoshouxiansuo"
+                }, {
+                    name: "公海客户",
+                    path: "/packageA/publicCustomer/index",
+                    icon: "work-gonghaikehu"
+                }, {
+                    name: "客户",
+                    path: "/packageA/setclient/index",
+                    icon: "work-kehu"
+                }, {
+                    name: "项目商机",
+                    path: "/packageA/project/index",
+                    icon: "work-xiangmushangji"
+                }, {
+                    name: "报价单",
+                    path: "/packageA/offers/index",
+                    icon: "work-xiangmubaojia"
+                }, {
+                    name: "竞争对手",
+                    path: "/packageA/opponent/index",
+                    icon: "work-jingzhengduishou"
+                }, {
+                    name: "合同",
+                    path: "/packageA/contract/index",
+                    icon: "work-hetong"
+                }, {
+                    name: "销售目标",
+                    path: "/packageA/target/index",
+                    icon: "work-xiaochengxu_xiaoshoumubiao"
+                }, {
+                    name: "销售预测",
+                    path: "/packageA/salesForecasting/index",
+                    icon: "work-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))
+            };
+            //E订单
+            function getedd() {
+                let paths = [{
+                    name: "商城",
+                    path: "/packageA/market/index",
+                    icon: "work-shangcheng"
+                }, {
+                    name: "销售订单",
+                    path: "/packageA/orderForm/index",
+                    icon: "work-dingdan"
+                }, {
+                    name: "收货",
+                    path: "/packageA/shipment/index",
+                    icon: "work-shouhuo"
+                }, {
+                    name: "业绩目标",
+                    path: "/packageA/target/index",
+                    icon: "work-yejimubiao"
+                }, {
+                    name: "账户",
+                    path: "/packageA/account/index",
+                    icon: "work-zhanghu"
+                }, {
+                    name: "促销活动",
+                    path: "/packageA/activity/index",
+                    icon: "work-cuxiaohuodong"
+                }, {
+                    name: "工具查询",
+                    path: "/packageA/tool/index",
+                    icon: "work-gongjuchaxun"
+                }, {
+                    name: "购物车",
+                    path: "/packageA/shopping/index",
+                    icon: "work-gouwuche"
+                }, {
+                    name: "开票",
+                    path: "/packageA/invoice/index",
+                    icon: "work-kaipiao"
+                }, {
+                    name: "打款凭证",
+                    path: "/packageA/remitVoucher/index",
+                    icon: "work-shujuchaxun"
+                }, {
+                    name: "工具借用",
+                    path: "/packageA/borrow/index",
+                    icon: "work-shujuchaxun"
+                }, {
+                    name: "工具归还",
+                    path: "/packageA/toolBill/index",
+                    icon: "work-shujuchaxun"
+                }, {
+                    name: "居间费结算",
+                    path: "/packageA/betweenFee/index",
+                    icon: "work-shujuchaxun"
+                }, {
+                    name: "数据查询",
+                    path: "#",
+                    icon: "work-shujuchaxun"
+                }];
+                let edd = getApp().globalData.queryPer.query(wx.getStorageSync('userauth'), ["E-订单"], ["商品档案", "销售管理", "财务管理", "售后管理", "发货与库存", "业绩查询"]),
+                    list = [];
+                edd.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",
                 }, {
@@ -133,130 +351,33 @@ Page({
                     color: "#5AB73F",
                     bColor: "#F4FAEF",
                 }];
-            auth.forEach(v => {
-                switch (v.systemmodulename) {
-                    case "商品档案":
-                        console.log(v)
-                        v.apps.forEach(value => {
-                            authList[value.name] = {
-                                options: value.meta.auth.map(a => a.option),
-                                optionnames: value.meta.auth.map(a => a.optionname),
-                            }
-                            switch (value.name) {
-                                case "wmarket":
-                                    if (value.meta.auth.some(r => r.option == 'read')) gridList.push(this.queryApp("商城"))
-                                    break;
-                                case "wtool":
-                                    if (value.meta.auth.some(r => r.option == 'read')) gridList.push(this.queryApp("工具查询"))
-                                    break;
-                                case "wshoppingtrolley":
-                                    if (value.meta.auth.some(r => r.option == 'read')) gridList.push(this.queryApp("购物车"))
-                                    break;
-                            };
-                        });
-                        break;
-                    case "销售管理":
-                        v.apps.forEach(value => {
-                            authList[value.name] = {
-                                options: value.meta.auth.map(a => a.option),
-                                optionnames: value.meta.auth.map(a => a.optionname),
-                            }
-                            switch (value.name) {
-                                case "worderform":
-                                    if (value.meta.auth.some(r => r.option == 'read')) gridList.push(this.queryApp("销售订单"))
-                                    break;
-                                case "wborrow":
-                                    if (value.meta.auth.some(r => r.option == 'read')) gridList.push(this.queryApp("工具借用"))
-                                    break;
-                                case "wdiscounts":
-                                    if (value.meta.auth.some(r => r.option == 'read')) gridList.push(this.queryApp("促销活动"))
-                                    break;
-                            };
-                        });
-                        break;
-                    case "财务管理":
-                        v.apps.forEach(value => {
-                            authList[value.name] = {
-                                options: value.meta.auth.map(a => a.option),
-                                optionnames: value.meta.auth.map(a => a.optionname),
-                            }
-                            switch (value.name) {
-                                case "wmakeoutaninvoice":
-                                    if (value.meta.auth.some(r => r.option == 'read')) gridList.push(this.queryApp("开票"))
-                                    break;
-                                case "wpaymentdocument":
-                                    if (value.meta.auth.some(r => r.option == 'read')) gridList.push(this.queryApp("打款凭证"))
-                                    break;
-                                case "waccount":
-                                    if (value.meta.auth.some(r => r.option == 'read')) gridList.push(this.queryApp("账户"))
-                                    break;
-                                case "wbrokerage":
-                                    if (value.meta.auth.some(r => r.option == 'read')) gridList.push(this.queryApp("居间费结算"))
-                                    break;
-                            };
-                        });
-                        break;
-                    case "售后管理":
-                        v.apps.forEach(value => {
-                            authList[value.name] = {
-                                options: value.meta.auth.map(a => a.option),
-                                optionnames: value.meta.auth.map(a => a.optionname),
-                            }
-                            switch (value.name) {
-                                case "whandback":
-                                    if (value.meta.auth.some(r => r.option == 'read')) gridList.push(this.queryApp("工具归还"))
-                                    break;
-                            };
-                        });
-                        break;
-                    case "发货与库存":
-                        v.apps.forEach(value => {
-                            authList[value.name] = {
-                                options: value.meta.auth.map(a => a.option),
-                                optionnames: value.meta.auth.map(a => a.optionname),
-                            }
-                            switch (value.name) {
-                                case "wlogistcs":
-                                    if (value.meta.auth.some(r => r.option == 'read')) gridList.push(this.queryApp("收货"))
-                                    break;
-                            };
-                        });
-                        break;
-                    case "业绩查询":
-                        v.apps.forEach(value => {
-                            authList[value.name] = {
-                                options: value.meta.auth.map(a => a.option),
-                                optionnames: value.meta.auth.map(a => a.optionname),
-                            }
-                            switch (value.name) {
-                                case "wtarget":
-                                    if (value.meta.auth.some(r => r.option == 'read')) gridList.push(this.queryApp("业绩目标"))
-                                    break;
-                            };
-                        });
-                        break;
-                };
-            });
-            wx.setStorageSync('auth', authList)
-            gridList = gridList.sort((a, b) => a.index - b.index);
-            this.setData({
-                gridList: gridList.map((v, i) => {
+                return list.map((v, i) => {
                     return {
                         ...v,
                         ...colorList[i > colorList.length - 1 ? i - colorList.length : i]
                     }
                 })
+            };
+
+            this.setData({
+                entrance,
+                auth: JSON.stringify(authList),
+                userMsg: JSON.stringify(wx.getStorageSync('userMsg'))
             })
+
+            /* 获取首页banner */
+            let banner = wx.getStorageSync('banner_list').find(v => v.location == "index_top");
+            if (banner) this.setData({
+                bannerList: banner.ads
+            })
+
+            wx.setStorageSync('auth', authList)
+
         } else {
             setTimeout(this.refreshData, 10);
             return;
         }
 
-        /* 获取首页banner */
-        let banner = wx.getStorageSync('banner_list').find(v => v.location == "index_top");
-        if (banner) this.setData({
-            bannerList: banner.ads
-        })
     },
     /* 获取最新信息 */
     queryMessage(i = 0) {

+ 40 - 38
pages/tabbar/home/index.scss

@@ -15,6 +15,7 @@
         margin: 0 8rpx 0 24rpx;
     }
 }
+
 /* 滚动播放 */
 .notice-bar {
     font-size: 28rpx;
@@ -25,6 +26,7 @@
         margin-right: 20rpx;
     }
 }
+
 /* 轮播图区域 */
 .banner {
     height: 240rpx !important;
@@ -39,61 +41,61 @@
         }
     }
 }
-/* 宫格 */
+
 .grld {
     width: 100vw;
     background-color: #fff;
+    box-sizing: border-box;
+    padding-top: 30rpx;
 
-    &-title {
-        height: 36rpx;
-        line-height: 36rpx;
-        padding: 40rpx 30rpx 20rpx;
+    .group {
+        margin-bottom: 30rpx;
 
-
-        .content {
+        .label {
+            height: 36rpx;
             font-size: 30rpx;
             font-family: AppleSystemUIFont-Bold, AppleSystemUIFont;
             font-weight: bold;
             color: #333333;
-        }
+            margin-bottom: 10rpx;
 
-        .iconfont {
-            font-size: 28rpx;
-            margin-right: 15rpx;
+            text {
+                margin: 0 20rpx 0 30rpx;
+            }
         }
-    }
-
-    .main {
-        display: flex;
-        flex-wrap: wrap;
 
-        .item {
-            width: 25%;
+        .main {
             display: flex;
-            flex-direction: column;
-            align-items: center;
-            padding: 20rpx 0;
-            border-radius: 16rpx;
+            flex-wrap: wrap;
 
-            .icon-box {
-                width: 100rpx;
-                height: 100rpx;
-                text-align: center;
-                line-height: 100rpx;
+            .item {
+                display: flex;
+                flex-direction: column;
+                align-items: center;
+                padding: 20rpx 0;
+                width: 20%;
                 border-radius: 16rpx;
-                .iconfont{
-                    font-size: 38rpx;
+
+                .icon-box {
+                    width: 80rpx;
+                    border-radius: 16rpx;
+                    line-height: 80rpx;
+                    text-align: center;
+
+                    text {
+                        font-size: 40rpx;
+                    }
                 }
-            }
 
-            .name {
-                width: 80%;
-                text-align: center;
-                height: 30rpx;
-                font-size: 24rpx;
-                font-family: AppleSystemUIFont-Regular, AppleSystemUIFont;
-                color: #333333;
-                margin-top: 12rpx;
+                .name {
+                    width: 80%;
+                    line-height: 30rpx;
+                    font-size: 24rpx;
+                    font-family: AppleSystemUIFont-Regular, AppleSystemUIFont;
+                    color: #333333;
+                    margin-top: 16rpx;
+                    text-align: center;
+                }
             }
         }
     }

+ 15 - 19
pages/tabbar/home/index.wxml

@@ -15,28 +15,24 @@
     <text slot="left-icon" data-item="{{notice}}" class="iconfont icon-xiaoxigundong" />
 </van-notice-bar>
 <!-- 轮播区域 -->
-<swiper class='banner' autoplay circular>
+<swiper class='banner' wx:if="{{bannerList.length}}" autoplay circular>
     <swiper-item wx:for="{{bannerList}}" wx:key="index">
         <image src="{{item.attinfos[0].url}}" mode="aspectFill" data-item="{{item}}" catchtap="bannerClick" />
     </swiper-item>
 </swiper>
-
-<!-- 宫格区域 -->
 <view class="grld">
-    <view class="grld-title">
-        <text class="iconfont icon-E-dingdanxitong" /> <text class="content">E-订单</text>
-    </view>
-    <Yl_ListBox id='ListBox' pullDown='{{false}}'>
-        <view class="main">
-            <navigator url="{{item.path}}" class="item" wx:for="{{gridList}}" wx:key="name">
-                <view class="icon-box" style="background-color: {{item.bColor}};">
-                    <text class="iconfont {{item.icon}}" style="color: {{item.color}};" />
-                </view>
-                <view class="name line-1">
-                    {{item.name}}
-                </view>
-            </navigator>
+    <block wx:for="{{entrance}}" wx:key="index">
+        <view class="group" wx:if="{{item.list.length}}">
+            <view class="label"><text class="work {{item.icon}}" />{{item.label}}</view>
+            <view class="main">
+                <navigator version='trial' class="item" wx:for="{{item.list}}" wx:for-item="it" wx:for-index="i" target='{{item.appid!=appid?"miniProgram":"self"}}' app-id='{{item.appid}}' path="{{it.path+'?auth='+auth+'&userMsg='+userMsg}}" url="{{it.path}}" open-type="{{it.openType||'navigate'}}" wx:key="name" data-it="{{it}}" data-item="{{item}}" bindtap="openRecord">
+                    <view class="icon-box" style="background-color: {{it.bColor}};">
+                        <text class="work {{it.icon}}" style="color: {{it.color}};" />
+                    </view>
+                    <view class="name line-1">{{it.name}}</view>
+                </navigator>
+            </view>
         </view>
-        <view style="height: 140rpx;" />
-    </Yl_ListBox>
-</view>
+    </block>
+</view>
+<view style="height: 160rpx;" />