浏览代码

小程序跳转逻辑

zhaoxiaohai 3 年之前
父节点
当前提交
6380e2c01d
共有 4 个文件被更改,包括 164 次插入38 次删除
  1. 37 1
      app.js
  2. 118 28
      pages/tabbar/workbench/index.js
  3. 1 1
      pages/tabbar/workbench/index.scss
  4. 8 8
      pages/tabbar/workbench/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({

+ 118 - 28
pages/tabbar/workbench/index.js

@@ -1,12 +1,12 @@
 Page({
     data: {
-
+        appid: "wx08b337e860e3ea58",
     },
     onLoad(options) {
         this.refreshData() //更新权限等信息
         this.setData({ //最近使用记录
             recorded: wx.getStorageSync('recorded') || []
-        })
+        });
     },
     /* 更新站点信息 */
     refreshData() {
@@ -14,52 +14,60 @@ Page({
             let authList = {},
                 entrance = [{
                     label: "通用",
-                    icon: "icon-tongyong",
+                    appid: "wx08b337e860e3ea58",
+                    icon: "work-tongyong",
                     list: dye([{
                         name: "签到",
                         path: "/packageA/clockIn/index",
-                        icon: "icon-a-wodemendianxinxidizhi"
+                        icon: "work-a-wodemendianxinxidizhi"
                     }, {
                         name: "任务",
                         path: "/packageA/work/index",
-                        icon: "icon-xiaochengxu_xiaoshouyuce"
+                        icon: "work-a-woderenwuzhongxin"
                     }, {
                         name: "通讯录",
                         path: "/packageA/contacts/index",
-                        icon: "icon-xiaochengxutongxunlu"
+                        icon: "work-xiaochengxutongxunlu"
                     }])
                 }, {
                     label: "营销工具",
-                    icon: "icon-E-dingdan",
+                    appid: "wx08b337e860e3ea58",
+                    icon: "work-E-dingdan",
                     list: gettool()
                 }, {
                     label: "CRM",
-                    icon: "icon-CRM",
+                    appid: "wx08b337e860e3ea58",
+                    icon: "work-CRM",
                     list: getcrm()
+                }, {
+                    label: "E-订单",
+                    appid: "wxc1b6ae925ac1d06a",
+                    icon: "work-E-dingdan",
+                    list: getedd()
                 }];
             //营销工具
             function gettool() {
                 const paths = [{
                     name: "通告",
                     path: "/pages/annunciate/index",
-                    icon: "icon-a-shouyejingangqutonggao"
+                    icon: "work-a-shouyejingangqutonggao"
                 }, {
                     name: "营销物料",
                     path: "/pages/tabbar/smartStore/index",
-                    icon: "icon-a-shouyejingangquyingxiaowuliao",
+                    icon: "work-a-shouyejingangquyingxiaowuliao",
                     openType: "switchTab"
                 }, {
                     name: "推广素材",
                     path: "/pages/promotional/index",
-                    icon: "icon-a-shouyejingangqutuiguangsucai"
+                    icon: "work-a-shouyejingangqutuiguangsucai"
                 }, {
                     name: "商学院",
                     path: "/pages/college/index",
-                    icon: "icon-a-shangxueyuanxuexi"
+                    icon: "work-a-shangxueyuanxuexi"
                 }, {
                     name: "提报",
                     path: "/pages/submission/index",
-                    icon: "icon-a-tibaoguanlitibao"
+                    icon: "work-a-tibaoguanlitibao"
                 }];
                 let tool = getApp().globalData.queryPer.query(wx.getStorageSync('userauth'), ['营销工具'], paths.map(v => v.name)),
                     list = [];
@@ -81,47 +89,47 @@ Page({
                 const paths = [{
                     name: "市场活动",
                     path: "/packageA/activity/index",
-                    icon: "icon-shichanghuodong",
+                    icon: "work-shichanghuodong",
                 }, {
                     name: "公海线索",
                     path: "/packageA/publicClue/index",
-                    icon: "icon-xiaochengxu_xiaoshoumubiao"
+                    icon: "work-xiaochengxu_xiaoshoumubiao"
                 }, {
                     name: "销售线索",
                     path: "/packageA/saleClue/index",
-                    icon: "icon-xiaoshouxiansuo"
+                    icon: "work-xiaoshouxiansuo"
                 }, {
                     name: "公海客户",
                     path: "/packageA/publicCustomer/index",
-                    icon: "icon-xiaochengxutongxunlu"
+                    icon: "work-gonghaikehu"
                 }, {
                     name: "客户",
                     path: "/packageA/setclient/index",
-                    icon: "icon-kehu"
+                    icon: "work-kehu"
                 }, {
                     name: "项目商机",
                     path: "/packageA/project/index",
-                    icon: "icon-xiangmushangji"
+                    icon: "work-xiangmushangji"
                 }, {
                     name: "报价单",
                     path: "/packageA/offers/index",
-                    icon: "icon-xiangmubaojia"
+                    icon: "work-xiangmubaojia"
                 }, {
                     name: "竞争对手",
                     path: "/packageA/opponent/index",
-                    icon: "icon-jingzhengduishou"
+                    icon: "work-jingzhengduishou"
                 }, {
                     name: "合同",
                     path: "/packageA/contract/index",
-                    icon: "icon-hetong"
+                    icon: "work-hetong"
                 }, {
                     name: "销售目标",
                     path: "/packageA/target/index",
-                    icon: "icon-xiaochengxu_xiaoshoumubiao"
+                    icon: "work-xiaochengxu_xiaoshoumubiao"
                 }, {
                     name: "销售预测",
                     path: "/packageA/salesForecasting/index",
-                    icon: "icon-xiaochengxu_xiaoshouyuce"
+                    icon: "work-xiaochengxu_xiaoshouyuce"
                 }];
                 let crm = getApp().globalData.queryPer.query(wx.getStorageSync('userauth'), ['CRM'], ['销售预测', '销售线索', '销售目标', '合同管理', '客户管理', '项目管理']),
                     list = [];
@@ -142,6 +150,84 @@ Page({
                 });
                 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 = [{
@@ -198,7 +284,9 @@ Page({
                 })
             };
             this.setData({
-                entrance
+                entrance,
+                auth: JSON.stringify(authList),
+                userMsg: JSON.stringify(wx.getStorageSync('userMsg'))
             })
             wx.setStorageSync('auth', authList)
         } else {
@@ -209,10 +297,12 @@ Page({
     /* 使用记录 */
     openRecord(e) {
         let {
-            item
+            item,
+            it
         } = e.currentTarget.dataset;
-        if (!item) return;
-        this.data.recorded.unshift(item);
+        if (!it) return;
+        if (item.appid) it.appid = item.appid;
+        this.data.recorded.unshift(it);
         let recorded = this.data.recorded.reduce((pre, cur) => {
             if (!pre.some(v => v.name == cur.name)) pre.push(cur)
             return pre

+ 1 - 1
pages/tabbar/workbench/index.scss

@@ -1,4 +1,4 @@
-.box {
+.grld {
     width: 100vw;
     background-color: #fff;
     box-sizing: border-box;

+ 8 - 8
pages/tabbar/workbench/index.wxml

@@ -1,24 +1,24 @@
-<view wx:if="{{recorded.length}}" class="box">
+<view wx:if="{{recorded.length}}" class="grld">
     <view class="group">
-        <view class="label"><text class="iconfont icon-zuijinshiyong" />最近使用</view>
+        <view class="label"><text class="work work-zuijinshiyong" />最近使用</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">
+            <navigator version='trial' class="item" target='{{it.appid!=appid?"miniProgram":"self"}}' app-id='{{it.appid}}' path="{{it.path+'?auth='+auth+'&userMsg='+userMsg}}" 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}}">
                 <view class="icon-box" style="background-color: {{it.bColor}};">
-                    <text class="iconfont {{it.icon}}" style="color: {{it.color}};" />
+                    <text class="work {{it.icon}}" style="color: {{it.color}};" />
                 </view>
                 <view class="name line-1">{{it.name}}</view>
             </navigator>
         </view>
     </view>
 </view>
-<view class="box">
+<view class="grld">
     <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="label"><text class="work {{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">
+                <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="iconfont {{it.icon}}" style="color: {{it.color}};" />
+                        <text class="work {{it.icon}}" style="color: {{it.color}};" />
                     </view>
                     <view class="name line-1">{{it.name}}</view>
                 </navigator>