Commit 836c791f by 姜雷

添加权限控制

parent f6780eff
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var app = getApp();
var tabList = [
{
pagePath: '/pages/home/home',
iconPath: '/images/tab_shuju_nor@2x.png',
selectedIconPath: '/images/tab_shuju_pre@2x.png',
text: '数据首页',
code: '9001',
},
{
pagePath: '/pages/report/report',
iconPath: '/images/tab_baobiao_nor@2x.png',
selectedIconPath: '/images/tab_baobiao_pre@2x.png',
text: '运营管理',
code: '9002',
},
];
Page({ Page({
onLoad: function () {
var userRoles = app.globalData.userRoles;
var list = userRoles
.map(function (item) { return tabList.find(function (menu) { return menu.code === item.menuCode; }); })
.filter(function (menu) { return (menu ? true : false); });
this.setData({
selected: list.length ? list[0].code : '',
list: list,
});
},
onShow: function () { onShow: function () {
if (wx.hideHomeButton) { if (wx.hideHomeButton) {
wx.hideHomeButton(); wx.hideHomeButton();
} }
}, },
data: { data: {
selected: 0, selected: '',
list: [ list: [],
{
pagePath: '/pages/home/home',
iconPath: '/images/tab_shuju_nor@2x.png',
selectedIconPath: '/images/tab_shuju_pre@2x.png',
text: '数据首页',
},
{
pagePath: '/pages/report/report',
iconPath: '/images/tab_baobiao_nor@2x.png',
selectedIconPath: '/images/tab_baobiao_pre@2x.png',
text: '运营管理',
},
],
}, },
clickHandle: function (e) { clickHandle: function (e) {
console.log('in click', e); console.log('in click', e);
...@@ -30,4 +45,4 @@ Page({ ...@@ -30,4 +45,4 @@ Page({
}); });
}, },
}); });
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaG9tZUFuZFJlcG9ydC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbImhvbWVBbmRSZXBvcnQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLElBQUksQ0FBQztJQUNILE1BQU07UUFDSixFQUFFLENBQUMsQ0FBQyxFQUFFLENBQUMsY0FBYyxDQUFDLENBQUMsQ0FBQztZQ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SWNvblBhdGg6ICcvaW1hZ2VzL3RhYl9iYW9iaWFvX3ByZUAyeC5wbmcnLFxuICAgIHRleHQ6ICfov5DokKXnrqHnkIYnLFxuICAgIGNvZGU6ICc5MDAyJyxcbiAgfSxcbl07XG5cblBhZ2Uoe1xuICBvbkxvYWQoKSB7XG4gICAgbGV0IHVzZXJSb2xlcyA9IGFwcC5nbG9iYWxEYXRhLnVzZXJSb2xlcztcbiAgICBsZXQgbGlzdCA9IHVzZXJSb2xlc1xuICAgICAgLm1hcChpdGVtID0+IHRhYkxpc3QuZmluZChtZW51ID0+IG1lbnUuY29kZSA9PT0gaXRlbS5tZW51Q29kZSkpXG4gICAgICAuZmlsdGVyKG1lbnUgPT4gKG1lbnUgPyB0cnVlIDogZmFsc2UpKTtcbiAgICB0aGlzLnNldERhdGEhKHtcbiAgICAgIHNlbGVjdGVkOiBsaXN0Lmxlbmd0aCA/IGxpc3RbMF0uY29kZSA6ICcnLFxuICAgICAgbGlzdCxcbiAgICB9KTtcbiAgfSxcbiAgb25TaG93KCkge1xuICAgIGlmICh3eC5oaWRlSG9tZUJ1dHRvbikge1xuICAgICAgd3guaGlkZUhvbWVCdXR0b24oKTtcbiAgICB9XG4gIH0sXG4gIGRhdGE6IHtcbiAgICBzZWxlY3RlZDogJycsXG4gICAgbGlzdDogW10sXG4gIH0sXG4gIGNsaWNrSGFuZGxlKGUpIHtcbiAgICBjb25zb2xlLmxvZygnaW4gY2xpY2snLCBlKTtcbiAgICBsZXQgeyBwYXRoLCBpbmRleCB9ID0gZS5kZXRhaWw7XG4gICAgLy8gY29uc29sZS5sb2cocGF0aCwgaW5kZXgpO1xuICAgIC8vIHd4LnN3aXRjaFRhYih7IHVybDogcGF0aCB9KTtcbiAgICB0aGlzLnNldERhdGEhKHtcbiAgICAgIHNlbGVjdGVkOiBpbmRleCxcbiAgICB9KTtcbiAgfSxcbn0pO1xuIl19
\ No newline at end of file \ No newline at end of file
import { IMyApp } from '../../app';
type Menu = {
pagePath: string;
iconPath: string;
selectedIconPath: string;
text: string;
code: string;
};
const app = getApp<IMyApp>();
const tabList: Menu[] = [
{
pagePath: '/pages/home/home',
iconPath: '/images/tab_shuju_nor@2x.png',
selectedIconPath: '/images/tab_shuju_pre@2x.png',
text: '数据首页',
code: '9001',
},
{
pagePath: '/pages/report/report',
iconPath: '/images/tab_baobiao_nor@2x.png',
selectedIconPath: '/images/tab_baobiao_pre@2x.png',
text: '运营管理',
code: '9002',
},
];
Page({ Page({
onLoad() {
let userRoles = app.globalData.userRoles;
let list = userRoles
.map(item => tabList.find(menu => menu.code === item.menuCode))
.filter(menu => (menu ? true : false));
this.setData!({
selected: list.length ? list[0].code : '',
list,
});
},
onShow() { onShow() {
if (wx.hideHomeButton) { if (wx.hideHomeButton) {
wx.hideHomeButton(); wx.hideHomeButton();
} }
}, },
data: { data: {
selected: 0, selected: '',
list: [ list: [],
{
pagePath: '/pages/home/home',
iconPath: '/images/tab_shuju_nor@2x.png',
selectedIconPath: '/images/tab_shuju_pre@2x.png',
text: '数据首页',
},
{
pagePath: '/pages/report/report',
iconPath: '/images/tab_baobiao_nor@2x.png',
selectedIconPath: '/images/tab_baobiao_pre@2x.png',
text: '运营管理',
},
],
}, },
clickHandle(e) { clickHandle(e) {
console.log('in click', e); console.log('in click', e);
let { path, index } = e.detail; let { path, index } = e.detail;
// console.log(path, index); // console.log(path, index);
// wx.switchTab({ url: path }); // wx.switchTab({ url: path });
this.setData({ this.setData!({
selected: index, selected: index,
}); });
}, },
......
<!-- miniprogram/pages/homeAndReport/homeAndReport.wxml --> <!-- miniprogram/pages/homeAndReport/homeAndReport.wxml -->
<view class="container"> <view class="container">
<home wx:if="{{selected === 0}}" /> <home wx:if="{{selected === '9001'}}" />
<report wx:elif="{{selected === 1}}" class="report-wrap" /> <report wx:elif="{{selected === '9002'}}" class="report-wrap" />
<tab-bar checked="{{selected}}" listData="{{list}}" bindcustomevent="clickHandle"></tab-bar> <tab-bar checked="{{selected}}" listData="{{list}}" bindcustomevent="clickHandle"></tab-bar>
</view> </view>
\ No newline at end of file
...@@ -106,7 +106,7 @@ Page({ ...@@ -106,7 +106,7 @@ Page({
const { account, pwd } = this.data; const { account, pwd } = this.data;
console.log(account, pwd); console.log(account, pwd);
wx.requestSubscribeMessage({ wx.requestSubscribeMessage({
tmplIds: ['WU2yMHKM_yNPLGHRsstggsDYnZhKoHIg4heM2fZkD5I'], tmplIds: ['WU2yMHKM_yNPLGHRsstggnnGIgcRgDEIaJQiWWNJ9ss'],
success(res) { success(res) {
console.log('in success', res); console.log('in success', res);
}, },
......
import { IMyApp } from '../../app'; import { IMyApp } from '../../app';
import { operatorFetch } from '../../api/fetch'; import { operatorFetch } from '../../api/fetch';
const navList = [
{
name: '月度运营分析',
icon: '../../../images/btn_yuedu@2x.png',
url: '/pages/monthOperator/monthOperator',
code: '9102',
reLaunch: false,
},
// {
// name: '用户增长分析',
// icon: '../../../images/btn_yonghu@2x.png',
// url: '/pages/userGrowth/userGrowth',
// code:'9103',
// reLaunch: false,
// },
{
name: '会员反馈',
icon: '../../../images/btn_fsnkui@2x.png',
url: '/pages/feedback/feedback',
code: '9104',
reLaunch: false,
},
{
name: '服务费明细',
icon: '../../../images/btn_jiaona@2x.png',
url: '/pages/platformFee/platformFee',
code: '9105',
reLaunch: false,
},
// {
// name: '账户提现',
// icon: '../../../images/btn_tixian@2x.png',
// url: '',
// reLaunch: false,
// },
{
name: '退出登录',
icon: '../../../images/btn_Sign_out@2x.png',
url: '/pages/index/index?logout=true',
reLaunch: true,
},
];
// miniprogram/pages/report/report.js // miniprogram/pages/report/report.js
const app = getApp<IMyApp>(); const app = getApp<IMyApp>();
Component({ Component({
lifetimes: { lifetimes: {
attached() { attached() {
console.log(app.globalData.userInfo); console.log(app.globalData.userInfo);
let itemList = [];
let showBalance = false;
let pageItem = app.globalData.userRoles.find(
menu => menu.menuCode === '9002',
);
if (pageItem) {
itemList = pageItem.childs
.map(item => navList.find(menu => menu.code === item.menuCode))
.filter(menu => (menu ? true : false));
if (pageItem.childs.find(item => item.menuCode === '9101'))
showBalance = true;
}
itemList.push(navList[navList.length - 1]);
while (itemList.length % 3) {
itemList.push({});
}
this.setData!({ this.setData!({
userInfo: app.globalData.userInfo, userInfo: app.globalData.userInfo,
itemList,
showBalance,
}); });
this.fetchPlatformFee(); this.fetchPlatformFee();
}, },
...@@ -18,46 +79,8 @@ Component({ ...@@ -18,46 +79,8 @@ Component({
*/ */
data: { data: {
userInfo: app.globalData.userInfo, userInfo: app.globalData.userInfo,
itemList: [ itemList: [],
{ showBalance: false,
name: '月度运营分析',
icon: '../../../images/btn_yuedu@2x.png',
url: '/pages/monthOperator/monthOperator',
reLaunch: false,
},
// {
// name: '用户增长分析',
// icon: '../../../images/btn_yonghu@2x.png',
// url: '/pages/userGrowth/userGrowth',
// reLaunch: false,
// },
{
name: '会员反馈',
icon: '../../../images/btn_fsnkui@2x.png',
url: '/pages/feedback/feedback',
reLaunch: false,
},
{
name: '服务费明细',
icon: '../../../images/btn_jiaona@2x.png',
url: '/pages/platformFee/platformFee',
reLaunch: false,
},
// {
// name: '账户提现',
// icon: '../../../images/btn_tixian@2x.png',
// url: '',
// reLaunch: false,
// },
{
name: '退出登录',
icon: '../../../images/btn_Sign_out@2x.png',
url: '/pages/index/index?logout=true',
reLaunch: true,
},
{},
{},
],
account: 0, account: 0,
platformFee: '0.00', platformFee: '0.00',
}, },
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
<view class="report-header-accountItemValue">10000</view> <view class="report-header-accountItemValue">10000</view>
</view> </view>
</view> --> </view> -->
<view class="report-header-platform"> <view class="report-header-platform" wx:if="{{showBalance}}">
<view class="report-header-platform-info"> <view class="report-header-platform-info">
待缴纳服务费 待缴纳服务费
<text class="report-header-platform-fee" selectable="false" space="false" decode="false"> <text class="report-header-platform-fee" selectable="false" space="false" decode="false">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment