You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

403 lines
12 KiB

3 years ago
<template>
<view class="page">
3 years ago
<image class="bg" src="@/static/image/person-bg.png"></image>
<view class="wrap">
<view class="info">
2 years ago
<button class="avatar-btn" open-type="chooseAvatar" @chooseavatar="onChooseAvatar">
<image class="avatar" :src="avatar" mode=""></image>
</button>
<view class="text">
2 years ago
<view class="name">{{ my.info.userName }}</view>
2 years ago
<view class="phone">{{ my.info.phone }}</view>
</view>
1 year ago
<view v-if="!disabled" class="tag">团队负责人</view>
</view>
<view class="list">
2 years ago
<view v-if="auth('我的:我的团队')" class="item" @click="$util.to('/team/teams/teams')">
<view class="left">
<image class="icon" src="@/static/image/person4.png" mode=""></image>
1 year ago
<text class="name">{{ disabled ? '所属团队' : '我的团队' }}</text>
</view>
<uni-icons type="right" size="15" color="#ccc"></uni-icons>
</view>
1 year ago
<view v-if="!hasOwnTeam && auth('我的:我的团队')" class="item" @click="createTeam">
1 year ago
<view class="left">
<image class="icon" src="@/static/image/person4.png" mode=""></image>
<text class="name">创建自己的团队</text>
</view>
2 years ago
<uni-icons type="right" size="15" color="#ccc"></uni-icons>
</view>
2 years ago
<view v-if="auth('我的:团队收益')" class="item">
<view class="left">
3 years ago
<image class="icon" src="@/static/image/person2.png" mode=""></image>
<text class="name">团队收益</text>
</view>
2 years ago
<text class="val">{{ my.teamIncome }}</text>
</view>
2 years ago
<view v-if="auth('我的:我的项目收益')" class="item">
<view class="left">
<image class="icon" src="@/static/image/person1.png" mode=""></image>
<text class="name">我的项目收益</text>
</view>
2 years ago
<text class="val">{{ my.myIncome }}</text>
</view>
2 years ago
<!-- <view class="item">
<view class="left">
<image class="icon" src="@/static/image/person5.png" mode=""></image>
<text class="name">我的收藏</text>
</view>
2 years ago
</view> -->
2 years ago
2 years ago
<view v-if="auth('我的:市场服务费')" class="item">
<view class="left">
2 years ago
<image class="icon" src="@/static/image/person26.png" mode=""></image>
<text class="name">市场服务费</text>
</view>
2 years ago
<text class="val">{{ my.teamInfo.annualMarketingFee ? '项目抽成' + my.teamInfo.annualMarketingFee + '%' :'-' }}</text>
</view>
2 years ago
<view v-if="auth('我的:团队年费')" class="item">
<view class="left">
2 years ago
<image class="icon" src="@/static/image/person27.png" mode=""></image>
<text class="name">团队年费</text>
</view>
2 years ago
<text class="val">{{ my.teamInfo.annualTeamFee ? '固定年费' + my.teamInfo.annualTeamFee + 'w' : '-' }}</text>
2 years ago
</view>
<view v-if="auth('我的:业务省份')" class="item">
<view class="left">
<image class="icon" src="@/static/image/person8.png" mode=""></image>
<text class="name">业务省份</text>
</view>
<view class="val">
<text v-if="disabled" class="name">{{ provinceName }}</text>
<uni-data-picker v-else class="picker-input" :clear-icon="false" :readonly="disabled" placeholder="请选择省份" popup-title="请选择省份" preload :localdata="provinces" :map="{text: 'provinceName', value: 'provinceId'}" v-model="provinceId" @change="getCity"></uni-data-picker>
</view>
</view>
<view v-if="auth('我的:业务城市')" class="item">
<view class="left">
<image class="icon" src="@/static/image/person9.png" mode=""></image>
<text class="name">业务城市</text>
</view>
<view class="val">
<text v-if="disabled" class="name">{{ cityName }}</text>
<uni-data-picker v-else class="picker-input" :clear-icon="false" :readonly="disabled" placeholder="请选择城市" popup-title="请选择城市" preload :localdata="cities" :map="{text: 'cityName', value: 'cityId'}" v-model="cityId" @change="submit"></uni-data-picker>
</view>
</view>
2 years ago
<view v-if="auth('我的:设置')" class="item" @click="toSet">
<view class="left">
3 years ago
<image class="icon" src="@/static/image/person3.png" mode=""></image>
<text class="name">设置</text>
</view>
</view>
</view>
</view>
2 years ago
<view v-if="!per" class="per-mask">功能升级中敬请期待...</view>
3 years ago
</view>
</template>
<script>
2 years ago
import { my, editProvinceCity } from '@/apis/modules/parner.js'
1 year ago
import { queryProvince, queryCity, updateAvatars, getUserRolesPermissionMenu } from '@/apis/modules/user.js'
import { getTeamsByAccountId } from '@/apis/modules/client.js'
3 years ago
export default {
data() {
return {
2 years ago
per: true, // 是否有权限
1 year ago
teamId: uni.getStorageSync('teamId') || '',
teams: [],
2 years ago
my: {
info: {
phone: ''
},
2 years ago
teamInfo: {
annualMarketingFee: '',
annualTeamFee: '',
},
2 years ago
myIncome: 0,
teamIncome: 0
},
3 years ago
avatar: uni.getStorageSync('avatar') || '@/static/image/avatar.png',
2 years ago
userName: uni.getStorageSync('userName'),
1 year ago
hasOwnTeam: 0, // 有自己的团队
2 years ago
disabled: true,
provinces: [],
cities: [],
provinceIcon: {
color: '#007eff',
size: '22',
type: 'location'
},
cityIcon: {
color: '#007eff',
size: '22',
type: 'map-pin-ellipse'
},
provinceId: '',
cityId: '',
provinceName: '',
cityName: ''
3 years ago
}
},
2 years ago
onShow() {
2 years ago
this.per = true
1 year ago
this.getTeam()
2 years ago
},
3 years ago
methods: {
2 years ago
// 初始化权限
initRole() {
if (!uni.getStorageSync('auth').includes('我的')) {
this.per = false
} else {
this.getInfo()
}
},
1 year ago
// 查询当前角色权限
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()
})
},
2 years ago
// 获取个人信息
getInfo() {
const { partnerId, teamId } = uni.getStorageSync('team')
2 years ago
my({
partnerId,
teamId
2 years ago
}).then(({ my }) => {
this.my = my
1 year ago
const avatar = my.info.userAvatars || 'https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png'
this.avatar = avatar
uni.setStorageSync('avatar', avatar)
2 years ago
this.provinceId = my.teamInfo.provinceId
this.cityId = my.teamInfo.cityId
2 years ago
uni.setStorageSync('provinceId', this.provinceId)
uni.setStorageSync('cityId', this.cityId)
2 years ago
this.getProvince()
this.provinceId && this.getCity()
}).catch(e => {})
},
// 上传头像回调
onChooseAvatar(e) {
2 years ago
uni.uploadFile({
url: 'https://huorantech.cn/nakadai/nakadai/oss/fileUpload',
filePath: e.detail.avatarUrl,
name: 'file',
header: {
token: uni.getStorageSync('token'),
},
formData: {},
success: ({ data }) => {
updateAvatars(JSON.parse(data).filesResult.fileUrl).then(res => {
this.getInfo()
}).catch(e => {})
}
})
2 years ago
},
1 year ago
// 创建自己的团队
createTeam() {
1 year ago
this.$util.to(`../reg/reg?openid=${uni.getStorageSync('openid')}&phone=${this.my.info.phone}&my=1`)
1 year ago
},
2 years ago
// 进入设置
toSet() {
this.$util.to(`/team/setting/setting`)
},
// 获取省份
getProvince() {
queryProvince().then(({ list }) => {
if (this.disabled) {
const { provinceId } = this
this.provinceName = list.find(e => e.provinceId == provinceId).provinceName
} else {
this.provinces = list
}
}).catch(res => {})
},
// 获取城市
getCity(val) {
if (this.provinceId) {
queryCity({
provinceId: this.provinceId
}).then(({ list }) => {
if (this.disabled) {
const { cityId } = this
this.cityName = list.find(e => e.cityId == cityId).cityName
} else {
this.cities = list
}
}).catch(res => {})
} else {
this.cities = []
}
if (val) this.cityId = ''
},
// 更改意向城市
submit() {
const { partnerId, teamId } = uni.getStorageSync('team')
editProvinceCity({
provinceId: this.provinceId,
cityId: this.cityId,
classificationId: teamId,
partnerId
}).then(({ my }) => {
this.$util.sucMsg('修改成功')
2 years ago
}).catch(e => {})
2 years ago
},
3 years ago
}
}
</script>
<style scoped lang="scss">
.bg {
width: 100%;
height: 300rpx;
}
.wrap {
position: relative;
padding: 0 24rpx;
margin-top: -150rpx;
}
.info {
display: flex;
align-items: center;
padding: 26rpx 34rpx;
background-color: #fff;
border-radius: 16rpx;
2 years ago
.avatar-btn {
padding: 0;
margin: 0 28rpx 0 0;
line-height: 0;
border: 0 !important;
background-color: transparent;
outline: none;
border-radius: 50%;
}
.avatar {
width: 120rpx;
height: 120rpx;
2 years ago
border: 0;
}
.text {
margin-right: 20rpx;
}
.name {
margin-bottom: 10rpx;
font-size: 40rpx;
color: #333;
}
.phone {
font-size: 28rpx;
color: #333;
}
.tag {
1 year ago
padding: 8rpx 16rpx;
margin-top: -50rpx;
1 year ago
font-size: 24rpx;
color: #fff;
background-color: #2979ff;
border-radius: 20px;
}
}
.list {
margin-top: 16rpx;
.item {
display: flex;
justify-content: space-between;
align-items: center;
padding: 26rpx 28rpx;
margin-bottom: 16rpx;
background-color: #fff;
border-radius: 16rpx;
}
.left {
display: inline-flex;
align-items: center;
}
.icon {
1 year ago
width: 40rpx;
height: 40rpx;
margin-right: 16rpx;
}
text {
font-size: 28rpx;
color: #333;
}
}
2 years ago
.location {
margin-top: 30rpx;
}
.picker-wrap {
margin-top: 4px;
}
.name {
font-size: 24rpx;
}
3 years ago
</style>