权限控制

master
yujialong 2 years ago
parent 8813740799
commit 7e1d9fe995
  1. 18
      App.vue
  2. 2
      apis/modules/client.js
  3. 6
      apis/modules/order.js
  4. 4
      apis/modules/parner.js
  5. 4
      apis/modules/user.js
  6. 4
      apis/request.js
  7. 16
      directives/auth.js
  8. 12
      directives/index.js
  9. 11
      main.js
  10. 3
      pages.json
  11. 46
      pages/clients/clients.vue
  12. 61
      pages/index/index.vue
  13. 34
      pages/orders/orders.vue
  14. 48
      pages/person/person.vue
  15. 5
      pages/plans/plans.vue
  16. 11
      pages/setting/setting.vue
  17. 16
      pages/teams/teams.vue
  18. 14
      styles/common.scss

@ -1,7 +1,23 @@
<script>
import { getUserRolesPermissionMenu } from '@/apis/modules/user.js'
export default {
onLaunch: function() {
//
uni.getStorageSync('token') && getUserRolesPermissionMenu({
platformId: 4
}).then(({ permissionMenu }) => {
const auth = []
const generateAuth = (list, parent) => {
list.map(e => {
const name = `${parent ? parent + ':' : ''}${e.name}`
auth.push(name)
generateAuth(e.children, name)
})
}
generateAuth(permissionMenu[0].children, '')
console.log(333, auth)
uni.setStorageSync('auth', auth)
}).catch(e => {})
},
onShow: function() {

@ -10,7 +10,7 @@ export const list = (data) => {
}
export const all = (data) => {
return post('nakadai/applets/customer/allClientsOfTheTeam', data)
return post('nakadai/applets/customer/customerList', data)
}
export const queryCustomerDetails = (data) => {

@ -22,11 +22,7 @@ export const renew = (data) => {
}
export const list = (data) => {
return post('nakadai/applets/order/getOrderBasedOnBusinessManagerId', data)
}
export const all = (data) => {
return post('nakadai/applets/order/allTeamOrders', data)
return post('nakadai/applets/order/orderList', data)
}
export const del = (data) => {

@ -16,3 +16,7 @@ export const generateInvitationCode = accountId => {
export const treeList = (data) => {
return post('nakadai/partnerClassification/treeList', data)
}
export const my = (data) => {
return get('nakadai/partner-team/my', data)
}

@ -13,4 +13,8 @@ export const examinePassword = (data) => {
return post('users/users/userAccount/examinePassword', data)
}
export const getUserRolesPermissionMenu = (data) => {
return get('users/user-role/getUserRolesPermissionMenu', data)
}
export const updateUserAvatars = `http://39.108.250.202:9000/users/users/userAccount/updateUserAvatars`

@ -14,11 +14,12 @@ const request = options => {
const header = Object.assign({}, config.headers, {
token: uni.getStorageSync('token')
})
const otherUrl = ['my', 'generateInvitationCode', 'weChatAppletCallback', 'userBinding', 'getUserRolesPermissionMenu']
return new Promise((resolve, reject)=>{
const { url } = options
uni.request({
header,
url: ((url.includes('getTeamsByAccountId') || url.includes('getTheBusinessManagerIdsUnderTheTeam') || url.includes('treeList')) ? 'http://192.168.31.151:9000/' : config.baseURL) + url,
url: (otherUrl.find(e => url.includes(e)) ? 'http://192.168.31.137:9000/' : config.baseURL) + url,
method: options.method || 'GET', // 请求类型,默认为GET
data: options.data || {}, // 请求参数,默认空对象
success: ({ data }) => {
@ -33,6 +34,7 @@ const request = options => {
uni.removeStorageSync('avatar')
uni.removeStorageSync('sessionKey')
uni.removeStorageSync('team')
uni.removeStorageSync('auth')
uni.showToast({
title: message,
icon: 'none'

@ -0,0 +1,16 @@
/**
* @description 鉴权指令
* 当传入的权限当前用户没有时会移除该组件
* 用例<Tag v-auth>text</Tag> <Tag v-auth="'user:'">text</Tag>
* */
export default {
inserted(el, binding, vnode) {
const btnText = el.innerText
const btnPermissions = uni.getStorageSync('auth')
if (btnText && btnPermissions && btnPermissions.length) {
const isPermission = btnPermissions.includes(btnText)
// 如果按钮集合里没有该权限,就把该按钮给去除
!isPermission && el.parentNode && el.parentNode.removeChild(el)
}
},
};

@ -0,0 +1,12 @@
/**
* 插件
* */
import auth from './auth'
export default {
async install(Vue, options) {
// 指令
Vue.directive('auth', auth)
}
};

@ -3,12 +3,23 @@
import Vue from 'vue'
import App from './App'
import util from '@/libs/util'
import plugins from '@/directives'
Vue.config.productionTip = false
Vue.prototype.$util = util
Vue.use(plugins)
App.mpType = 'app'
// 权限控制
Vue.prototype.auth = function(text){
const auth = uni.getStorageSync('auth')
if (text && auth && auth.length) {
const isPermission = auth.includes(text)
return auth.includes(text)
}
}
const app = new Vue({
...App
})

@ -191,7 +191,8 @@
"pagePath": "pages/teams/teams",
"iconPath": "static/image/tab2.png",
"selectedIconPath": "static/image/tab2-1.png",
"text": "团队"
"text": "团队",
"visible": false
}, {
"pagePath": "pages/person/person",
"iconPath": "static/image/tab3.png",

@ -27,11 +27,11 @@
</view>
<view class="line">
<text class="name">产品到期时间</text>
<text class="val">{{ item.expireDate.replace(' 00:00:00', '') }}</text>
<text class="val">{{ item.expireDate.split(' ')[0] }}</text>
</view>
<view class="line">
<text class="name">商务经理</text>
<text class="val">{{ item.account }}</text>
<text class="val">{{ item.businessManagerName }}</text>
</view>
</view>
<view class="type">
@ -81,16 +81,7 @@
}
],
curTab: 0,
tabs: [
{
name: '我的客户',
id: 0
},
{
name: '团队全部客户',
id: 1
}
],
tabs: [],
reachBottom: 0, // 0->,1->,-1->
status: 'more', // more|loading|noMore
searchTimer: null,
@ -128,20 +119,41 @@
}
},
onShow() {
this.initList()
this.initRole()
},
methods: {
//
initRole() {
this.tabs = []
const auth = uni.getStorageSync('auth')
auth.includes('首页:客户:我的客户') && this.tabs.push({
name: '我的客户',
id: 0
})
auth.includes('首页:客户:团队全部客户') && this.tabs.push({
name: '团队全部客户',
id: 1
})
const len = this.tabs.length
// tab
if (len === 1) {
this.curTab = this.tabs[0].id
this.tabs = []
}
this.initList()
},
//
getList() {
const method = this.curTab ? all : list
const data = {
businessManagerId: this.$util.getBmId(),
teamId: uni.getStorageSync('team').teamId,
customerType: this.customerType,
keywords: this.keyword,
pageNum: this.page,
pageSize: this.pageSize
pageSize: this.pageSize,
type: this.curTab // 团队:1 / 个人:0
}
if (this.curTab) data.businessManagerIds = uni.getStorageSync('team').businessManagerIds
method(data).then(({ data }) => {
all(data).then(({ data }) => {
// list
this.list = this.reachBottom > 0 ? [...this.list, ...data.records] : data.records
this.page++ // page+1

@ -14,19 +14,19 @@
</view>
<ul class="entry">
<li @click="$util.to('../clients/clients')">
<li v-if="auth('首页:客户')" @click="$util.to('../clients/clients')">
<image class="icon" src="@/static/image/index/index3.png" mode="widthFix"></image>
<view class="text">客户</view>
</li>
<li @click="$util.to('../plans/plans')">
<li v-if="auth('首页:方案')" @click="$util.to('../plans/plans')">
<image class="icon" src="@/static/image/index/index4.png" mode="widthFix"></image>
<view class="text">方案</view>
</li>
<li @click="$util.to('../orders/orders')">
<li v-if="auth('首页:订单')" @click="$util.to('../orders/orders')">
<image class="icon" src="@/static/image/index/index5.png" mode="widthFix"></image>
<view class="text">订单</view>
</li>
<li @click="$util.to('../products/products')">
<li v-if="auth('首页:产品')" @click="$util.to('../products/products')">
<image class="icon" src="@/static/image/index/index6.png" mode="widthFix"></image>
<view class="text">产品</view>
</li>
@ -98,6 +98,7 @@
</view>
</view>
</view>
<view v-if="!per" class="per-mask">功能升级中敬请期待...</view>
</view>
</template>
@ -107,6 +108,7 @@
export default {
data() {
return {
per: true, //
teamId: uni.getStorageSync('team').teamId || '',
list: [],
id: '',
@ -114,50 +116,39 @@
}
},
onShow() {
this.getInfo()
this.initRole()
},
methods: {
//
initRole() {
if (!uni.getStorageSync('auth').includes('首页')) {
this.per = false
} else {
this.getInfo()
}
},
//
getInfo() {
getTeamsByAccountId().then(({ data }) => {
if (data.length) {
//
treeList().then(({ treeList }) => {
this.teamList = treeList
this.getId(treeList, '', data[0].teamId)
// id()
this.id && getTheBusinessManagerIdsUnderTheTeam(this.id).then(res => {
data[0].businessManagerIds = res
//
this.teamId = data[0].teamId
uni.setStorageSync('team', data[0])
}).catch(e => {})
}).catch(e => {})
data.map(e => {
const n = e.partnerClassificationList
e.teamId = n.id
e.partnerClassificationName = n.partnerClassificationName
delete e.partnerClassificationList
})
//
if (data.length && !this.teamId) {
this.teamId = data[0].teamId
uni.setStorageSync('team', data[0])
}
this.list = data
}).catch(e => {})
},
// teamIdid
getId(list, parentId, id) {
list.map(e => {
if (e.id === id) {
this.id = e.isTeam ? id : parentId
} else {
this.getId(e.children, e.id, id)
}
})
},
//
teamChange() {
const { teamId } = this
const e = this.list.find(e => e.teamId == teamId)
if (e) {
this.getId(this.teamList, '', e.teamId)
this.id && getTheBusinessManagerIdsUnderTheTeam(this.id).then(res => {
e.businessManagerIds = res
uni.setStorageSync('team', e)
}).catch(e => {})
}
uni.setStorageSync('team', e)
},
//
toPanel(i) {

@ -26,7 +26,7 @@
<view class="info">
<view class="left">
<view class="line">
<text class="name">客户名称</text>
<text class="name">订单名称</text>
<text class="val">{{ item.customerName }}</text>
</view>
<view class="line">
@ -63,7 +63,7 @@
<script>
import { queryCustomer } from '@/apis/modules/client.js'
import { list, all, del } from '@/apis/modules/order.js'
import { list, del } from '@/apis/modules/order.js'
import slFilter from '@/components/sl-filter/sl-filter.vue'
export default {
data() {
@ -167,21 +167,41 @@
try {
uni.removeStorageSync('courses')
} catch (e) {}
this.initList()
this.initRole()
},
methods: {
//
initRole() {
this.tabs = []
const auth = uni.getStorageSync('auth')
auth.includes('首页:订单:我的订单') && this.tabs.push({
name: '我的订单',
id: 0
})
auth.includes('首页:订单:团队全部订单') && this.tabs.push({
name: '团队全部订单',
id: 1
})
const len = this.tabs.length
// tab
if (len === 1) {
this.curTab = this.tabs[0].id
this.tabs = []
}
this.initList()
},
getList() {
const method = this.curTab ? all : list
const data = {
businessManagerId: this.$util.getBmId(),
teamId: uni.getStorageSync('team').teamId,
keywords: this.keyword,
pageNum: this.page,
pageSize: this.pageSize,
sort: this.sort,
orderStatus: this.orderStatus
orderStatus: this.orderStatus,
type: this.curTab
}
if (this.curTab) data.businessManagerIds = uni.getStorageSync('team').businessManagerIds
method(data).then(({ data }) => {
list(data).then(({ data }) => {
// list
const list = data.records
list.map(e => {

@ -6,25 +6,25 @@
<image class="avatar" :src="avatar" mode=""></image>
<view class="text">
<view class="name">{{ userName }}</view>
<view class="phone">1356231564</view>
<view class="phone">{{ my.info.phone }}</view>
</view>
</view>
<view class="list">
<view class="item">
<view v-if="auth('我的:我的收益')" class="item">
<view class="left">
<image class="icon" src="@/static/image/person1.png" mode=""></image>
<text class="name">我的收益</text>
</view>
<text class="val">231323</text>
<text class="val">{{ my.myIncome}}</text>
</view>
<view class="item">
<view v-if="auth('我的:团队收益')" class="item">
<view class="left">
<image class="icon" src="@/static/image/person2.png" mode=""></image>
<text class="name">团队收益</text>
</view>
<text class="val">231323</text>
<text class="val">{{ my.teamIncome}}</text>
</view>
<view class="item" @click="$util.to('../setting/setting')">
<view v-if="auth('我的:设置')" class="item" @click="$util.to('../setting/setting')">
<view class="left">
<image class="icon" src="@/static/image/person3.png" mode=""></image>
<text class="name">设置</text>
@ -32,19 +32,50 @@
</view>
</view>
</view>
<view v-if="!per" class="per-mask">功能升级中敬请期待...</view>
</view>
</template>
<script>
import { my } from '@/apis/modules/parner.js'
export default {
data() {
return {
per: true, //
my: {
info: {
phone: ''
},
myIncome: 0,
teamIncome: 0
},
avatar: uni.getStorageSync('avatar') || '@/static/image/avatar.png',
userName: uni.getStorageSync('userName'),
userName: uni.getStorageSync('userName')
}
},
onShow() {
this.initRole()
},
methods: {
//
initRole() {
if (!uni.getStorageSync('auth').includes('我的')) {
this.per = false
} else {
this.getInfo()
}
},
//
getInfo() {
const team = uni.getStorageSync('team')
my({
partnerId: team.partnerId,
teamId: team.teamId
}).then(({ my }) => {
this.my = my
uni.setStorageSync('info', my.info)
}).catch(e => {})
}
}
}
</script>
@ -55,7 +86,6 @@
height: 300rpx;
}
.wrap {
z-index: 2;
position: relative;
padding: 0 24rpx;
margin-top: -150rpx;

@ -1,7 +1,7 @@
<template>
<view>
<view class="top">
<uni-search-bar class="search" radius="5" placeholder="请输入方案名称" clearButton="auto" cancelButton="none" @confirm="search" />
<uni-search-bar class="search" radius="100" placeholder="请输入方案名称" clearButton="auto" cancelButton="none" @confirm="search" />
<uni-icons class="icon" custom-prefix="iconfont" type="icon-filter" size="18" color="#007eff"></uni-icons>
</view>
@ -151,6 +151,9 @@
.search {
flex: 1;
}
/deep/.uni-searchbar__box {
height: 60rpx;
}
}
.list {
background-color: #fff;

@ -1,9 +1,9 @@
<template>
<view>
<uni-list>
<uni-list-item :show-extra-icon="true" showArrow :extra-icon="phoneIcon" title="手机号" rightText="135617623" />
<uni-list-item :show-extra-icon="true" showArrow :extra-icon="mailIcon" title="邮箱" rightText="135617623" />
<uni-list-item :show-extra-icon="true" showArrow :extra-icon="accountIcon" title="账号" rightText="135617623" />
<uni-list-item :show-extra-icon="true" showArrow :extra-icon="phoneIcon" title="手机号" :rightText="info.phone" />
<uni-list-item :show-extra-icon="true" showArrow :extra-icon="mailIcon" title="邮箱" :rightText="info.email" />
<uni-list-item :show-extra-icon="true" showArrow :extra-icon="accountIcon" title="账号" :rightText="info.account" />
<uni-list-item :show-extra-icon="true" showArrow :extra-icon="pwdIcon" title="密码" rightText="******" clickable @click="toPage('../password/password')" />
</uni-list>
</view>
@ -26,13 +26,14 @@
accountIcon: {
color: '#007eff',
size: '22',
type: 'account'
type: 'person'
},
pwdIcon: {
color: '#007eff',
size: '22',
type: 'locked'
}
},
info: uni.getStorageSync('info')
}
},
methods: {

@ -25,7 +25,8 @@
</template>
<empty v-else></empty>
<uni-icons class="plus" type="plus-filled" size="60" color="#007eff" @click="$util.to('../addStaff/addStaff')"></uni-icons>
<uni-icons v-if="auth('团队:邀请成员')" class="plus" type="plus-filled" size="60" color="#007eff" @click="$util.to('../addStaff/addStaff')"></uni-icons>
<view v-if="!per" class="per-mask">功能升级中敬请期待...</view>
</view>
</template>
@ -34,6 +35,7 @@
export default {
data() {
return {
per: true, //
reachBottom: 0, // 0->,1->,-1->
status: 'more', // more|loading|noMore
searchTimer: null,
@ -67,9 +69,19 @@
}
},
onShow() {
this.initList()
this.initRole()
},
methods: {
//
initRole() {
const auth = uni.getStorageSync('auth')
if (!auth.includes('团队')) {
this.per = false
} else if (auth.includes('团队:团队列表')) {
this.initList()
}
},
//
getList() {
teamList({
pageNum: this.page,

@ -163,3 +163,17 @@ ul {
background-color: #007EFF;
}
}
.per-mask {
z-index: 3;
position: fixed;
top: 0;
left: 0;
display: flex;
justify-content: center;
align-items: center;
width: 100%;
height: 100%;
font-size: 28rpx;
color: #333;
background-color: rgba(255, 255, 255, 0.95);
}
Loading…
Cancel
Save