|
|
|
@ -97,11 +97,14 @@ |
|
|
|
|
|
|
|
|
|
<script> |
|
|
|
|
import { my, editProvinceCity } from '@/apis/modules/parner.js' |
|
|
|
|
import { queryProvince, queryCity, updateAvatars } from '@/apis/modules/user.js' |
|
|
|
|
import { queryProvince, queryCity, updateAvatars, getUserRolesPermissionMenu } from '@/apis/modules/user.js' |
|
|
|
|
import { getTeamsByAccountId } from '@/apis/modules/client.js' |
|
|
|
|
export default { |
|
|
|
|
data() { |
|
|
|
|
return { |
|
|
|
|
per: true, // 是否有权限 |
|
|
|
|
teamId: uni.getStorageSync('teamId') || '', |
|
|
|
|
teams: [], |
|
|
|
|
my: { |
|
|
|
|
info: { |
|
|
|
|
phone: '' |
|
|
|
@ -115,7 +118,7 @@ |
|
|
|
|
}, |
|
|
|
|
avatar: uni.getStorageSync('avatar') || '@/static/image/avatar.png', |
|
|
|
|
userName: uni.getStorageSync('userName'), |
|
|
|
|
hasOwnTeam: uni.getStorageSync('hasOwnTeam') == 1, // 有自己的团队 |
|
|
|
|
hasOwnTeam: 0, // 有自己的团队 |
|
|
|
|
disabled: true, |
|
|
|
|
provinces: [], |
|
|
|
|
cities: [], |
|
|
|
@ -137,8 +140,7 @@ |
|
|
|
|
}, |
|
|
|
|
onShow() { |
|
|
|
|
this.per = true |
|
|
|
|
this.initRole() |
|
|
|
|
this.disabled = uni.getStorageSync('team').isTeam == 0 // 成员不能改省份城市 |
|
|
|
|
this.getTeam() |
|
|
|
|
}, |
|
|
|
|
methods: { |
|
|
|
|
// 初始化权限 |
|
|
|
@ -149,6 +151,80 @@ |
|
|
|
|
this.getInfo() |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
// 查询当前角色权限 |
|
|
|
|
getAuth() { |
|
|
|
|
uni.showLoading({ |
|
|
|
|
title: '加载中' |
|
|
|
|
}) |
|
|
|
|
getUserRolesPermissionMenu({ |
|
|
|
|
teamId: this.teams.find(e => e.teamId == this.teamId).partnerClassificationId, |
|
|
|
|
platformId: 4 |
|
|
|
|
}).then(({ permissionMenu }) => { |
|
|
|
|
uni.hideLoading() |
|
|
|
|
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, '') |
|
|
|
|
uni.setStorageSync('auth', auth) |
|
|
|
|
this.initRole() |
|
|
|
|
}).catch(e => { |
|
|
|
|
uni.hideLoading() |
|
|
|
|
uni.setStorageSync('auth', []) |
|
|
|
|
this.initRole() |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
// 获取团队 |
|
|
|
|
getTeam() { |
|
|
|
|
uni.showLoading({ |
|
|
|
|
title: '加载中' |
|
|
|
|
}) |
|
|
|
|
getTeamsByAccountId().then(({ data }) => { |
|
|
|
|
let hasOwnTeam = 0 // 是否有自己的团队 |
|
|
|
|
data.map(e => { |
|
|
|
|
const n = e.partnerClassificationList |
|
|
|
|
e.id = n.id |
|
|
|
|
// parnerId是商务经理id,teamId则是下面这个,其他地方要用的话直接uni.getStorageSync('team').partnerId去使用 |
|
|
|
|
e.teamId = e.isTeam == 1 ? +e.partnerClassificationId : n.id |
|
|
|
|
e.partnerClassificationName = n.partnerClassificationName |
|
|
|
|
delete e.partnerClassificationList |
|
|
|
|
if (e.isTeam == 1) hasOwnTeam = 1 |
|
|
|
|
}) |
|
|
|
|
this.hasOwnTeam = hasOwnTeam |
|
|
|
|
const teamId = uni.getStorageSync('teamId') |
|
|
|
|
if (data.length) { |
|
|
|
|
/** |
|
|
|
|
* @description 如果是第一次进,则默认选中第一个团队,并把该团队的信息存入缓存 |
|
|
|
|
* 或者团队列表里没有该id,则说明超管已经被转让,也需要重新选中团队 |
|
|
|
|
*/ |
|
|
|
|
const curTeam = data.find(e => e.teamId == teamId) |
|
|
|
|
if (teamId && curTeam) { |
|
|
|
|
uni.setStorageSync('team', curTeam) |
|
|
|
|
} else if (!uni.getStorageSync('team') || !curTeam) { |
|
|
|
|
this.teamId = data[0].teamId |
|
|
|
|
uni.setStorageSync('teamId', data[0].teamId) |
|
|
|
|
uni.setStorageSync('team', data[0]) |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
// 如果没有团队,则退出登录 |
|
|
|
|
uni.hideLoading() |
|
|
|
|
uni.clearStorageSync() |
|
|
|
|
uni.navigateTo({ |
|
|
|
|
url: '../login/login' |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
this.disabled = uni.getStorageSync('team').isTeam == 0 // 成员不能改省份城市 |
|
|
|
|
this.teams = data |
|
|
|
|
this.getAuth() |
|
|
|
|
}).catch(e => { |
|
|
|
|
uni.hideLoading() |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
// 获取个人信息 |
|
|
|
|
getInfo() { |
|
|
|
|
const { partnerId, teamId } = uni.getStorageSync('team') |
|
|
|
@ -187,7 +263,7 @@ |
|
|
|
|
}, |
|
|
|
|
// 创建自己的团队 |
|
|
|
|
createTeam() { |
|
|
|
|
this.$util.to(`../reg/reg?openid=${uni.getStorageSync('openid')}&phone=${this.my.info.phone}`) |
|
|
|
|
this.$util.to(`../reg/reg?openid=${uni.getStorageSync('openid')}&phone=${this.my.info.phone}&my=1`) |
|
|
|
|
}, |
|
|
|
|
// 进入设置 |
|
|
|
|
toSet() { |
|
|
|
|