权限控制

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. 55
      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> <script>
import { getUserRolesPermissionMenu } from '@/apis/modules/user.js'
export default { export default {
onLaunch: function() { 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() { onShow: function() {

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

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

@ -16,3 +16,7 @@ export const generateInvitationCode = accountId => {
export const treeList = (data) => { export const treeList = (data) => {
return post('nakadai/partnerClassification/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) 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` 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, { const header = Object.assign({}, config.headers, {
token: uni.getStorageSync('token') token: uni.getStorageSync('token')
}) })
const otherUrl = ['my', 'generateInvitationCode', 'weChatAppletCallback', 'userBinding', 'getUserRolesPermissionMenu']
return new Promise((resolve, reject)=>{ return new Promise((resolve, reject)=>{
const { url } = options const { url } = options
uni.request({ uni.request({
header, 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 method: options.method || 'GET', // 请求类型,默认为GET
data: options.data || {}, // 请求参数,默认空对象 data: options.data || {}, // 请求参数,默认空对象
success: ({ data }) => { success: ({ data }) => {
@ -33,6 +34,7 @@ const request = options => {
uni.removeStorageSync('avatar') uni.removeStorageSync('avatar')
uni.removeStorageSync('sessionKey') uni.removeStorageSync('sessionKey')
uni.removeStorageSync('team') uni.removeStorageSync('team')
uni.removeStorageSync('auth')
uni.showToast({ uni.showToast({
title: message, title: message,
icon: 'none' 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 Vue from 'vue'
import App from './App' import App from './App'
import util from '@/libs/util' import util from '@/libs/util'
import plugins from '@/directives'
Vue.config.productionTip = false Vue.config.productionTip = false
Vue.prototype.$util = util Vue.prototype.$util = util
Vue.use(plugins)
App.mpType = 'app' 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({ const app = new Vue({
...App ...App
}) })

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

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

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

@ -26,7 +26,7 @@
<view class="info"> <view class="info">
<view class="left"> <view class="left">
<view class="line"> <view class="line">
<text class="name">客户名称</text> <text class="name">订单名称</text>
<text class="val">{{ item.customerName }}</text> <text class="val">{{ item.customerName }}</text>
</view> </view>
<view class="line"> <view class="line">
@ -63,7 +63,7 @@
<script> <script>
import { queryCustomer } from '@/apis/modules/client.js' 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' import slFilter from '@/components/sl-filter/sl-filter.vue'
export default { export default {
data() { data() {
@ -167,21 +167,41 @@
try { try {
uni.removeStorageSync('courses') uni.removeStorageSync('courses')
} catch (e) {} } catch (e) {}
this.initList() this.initRole()
}, },
methods: { 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() { getList() {
const method = this.curTab ? all : list
const data = { const data = {
businessManagerId: this.$util.getBmId(), businessManagerId: this.$util.getBmId(),
teamId: uni.getStorageSync('team').teamId,
keywords: this.keyword, keywords: this.keyword,
pageNum: this.page, pageNum: this.page,
pageSize: this.pageSize, pageSize: this.pageSize,
sort: this.sort, sort: this.sort,
orderStatus: this.orderStatus orderStatus: this.orderStatus,
type: this.curTab
} }
if (this.curTab) data.businessManagerIds = uni.getStorageSync('team').businessManagerIds list(data).then(({ data }) => {
method(data).then(({ data }) => {
// list // list
const list = data.records const list = data.records
list.map(e => { list.map(e => {

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

@ -1,7 +1,7 @@
<template> <template>
<view> <view>
<view class="top"> <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> <uni-icons class="icon" custom-prefix="iconfont" type="icon-filter" size="18" color="#007eff"></uni-icons>
</view> </view>
@ -151,6 +151,9 @@
.search { .search {
flex: 1; flex: 1;
} }
/deep/.uni-searchbar__box {
height: 60rpx;
}
} }
.list { .list {
background-color: #fff; background-color: #fff;

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

@ -25,7 +25,8 @@
</template> </template>
<empty v-else></empty> <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> </view>
</template> </template>
@ -34,6 +35,7 @@
export default { export default {
data() { data() {
return { return {
per: true, //
reachBottom: 0, // 0->,1->,-1-> reachBottom: 0, // 0->,1->,-1->
status: 'more', // more|loading|noMore status: 'more', // more|loading|noMore
searchTimer: null, searchTimer: null,
@ -67,9 +69,19 @@
} }
}, },
onShow() { onShow() {
this.initList() this.initRole()
}, },
methods: { methods: {
//
initRole() {
const auth = uni.getStorageSync('auth')
if (!auth.includes('团队')) {
this.per = false
} else if (auth.includes('团队:团队列表')) {
this.initList()
}
},
//
getList() { getList() {
teamList({ teamList({
pageNum: this.page, pageNum: this.page,

@ -163,3 +163,17 @@ ul {
background-color: #007EFF; 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