123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361 |
- <template>
- <view class="my-v" v-if="loading">
- <view class="u-flex user-box u-p-l-20 u-p-r-10 u-p-b-20">
- <view class="u-m-r-10">
- <u-avatar size="127" @click='chooseAvatar' :src='avatarSrc'></u-avatar>
- </view>
- <view class="u-flex-1 f-right" @click="personalPage('/pages/my/personalData/index')">
- <view class="u-font-36 u-m-l-16">{{baseInfo.realName}}</view>
- <view class="u-m-l-10 u-p-10">
- <u-icon name="arrow-right" color="#969799" size="28"></u-icon>
- </view>
- </view>
- </view>
- <view class="u-m-t-20 my-group-box">
- <view class="my-group-box-inner">
- <u-cell-group :border="false" class="cell-group">
- <u-cell-item :title="$t('app.my.organization')"
- @click="openPage('/pages/my/business/index','Organize')" :title-style="titleStyle">
- <template #icon>
- <text class="icon-ym icon-ym-zuzhi u-m-r-16 u-font-32 my-list" />
- </template>
- </u-cell-item>
- <u-cell-item :title="$t('app.my.position')" @click="openPage('/pages/my/business/index','Position')"
- :title-style="titleStyle">
- <template #icon>
- <text class="icon-ym icon-ym-position1 u-m-r-16 u-font-32 my-list" />
- </template>
- </u-cell-item>
- <u-cell-item :title="$t('app.my.subordinates')" @click="openPage('/pages/my/subordinate/index')"
- :title-style="titleStyle">
- <template #icon>
- <text class="icon-ym icon-ym-generator-section u-m-r-16 u-font-32 my-list" />
- </template>
- </u-cell-item>
- <u-cell-item :title="$t('app.my.entrustedAgency')" @click="openPage('/pages/my/entrustAgent/index')"
- :title-style="titleStyle">
- <template #icon>
- <text class="icon-ym icon-ym-header-role-toggle u-m-r-16 u-font-32 my-list" />
- </template>
- </u-cell-item>
- <u-cell-item :title="$t('app.my.switchIdentity')" @click="selectShow = true"
- v-if="userInfo.standingList?.length > 1" :title-style="titleStyle">
- <template #icon>
- <text class="icon-ym icon-ym-header-role-toggle u-m-r-16 u-font-32 my-list" />
- </template>
- </u-cell-item>
- <!-- #ifndef H5 -->
- <u-cell-item :title="$t('app.my.scanCode')" @click="scanCode()" :title-style="titleStyle">
- <template #icon>
- <text class="icon-ym icon-ym-scanCode1 u-m-r-16 u-font-32 my-list" />
- </template>
- </u-cell-item>
- <!-- #endif -->
- <!-- #ifdef APP-PLUS -->
- <u-cell-item :title="$t('app.my.accountSecurity')"
- @click="openPage('/pages/my/accountSecurity/index')" :title-style="titleStyle">
- <template #icon>
- <text class="icon-ym icon-ym-zhanghao u-m-r-16 u-font-32 my-list" />
- </template>
- </u-cell-item>
- <!-- #endif -->
- <u-cell-item :title="$t('app.my.setting')" @click="openPage('/pages/my/settings/index')"
- :title-style="titleStyle" :border-bottom="false">
- <template #icon>
- <text class="icon-ym icon-ym-shezhi u-m-r-16 u-font-32 my-list" />
- </template>
- </u-cell-item>
- </u-cell-group>
- </view>
- </view>
- <view class="u-p-t-20">
- <view class="logout-cell" hover-class="u-cell-hover" @click="logout">{{$t('app.my.logOut')}}</view>
- </view>
- <u-select v-model="selectShow" :list="selectList" mode="single-column" value-name='id' label-name='name'
- :default-value="defaultValue" @confirm="confirm"></u-select>
- </view>
- </template>
- <script>
- import IndexMixin from './mixin.js'
- import {
- UpdateAvatar,
- UserSettingInfo,
- setMajor
- } from '@/api/common'
- import chat from '@/libs/chat.js'
- import {
- useUserStore
- } from '@/store/modules/user'
- import {
- useChatStore
- } from '@/store/modules/chat'
- export default {
- mixins: [IndexMixin],
- data() {
- return {
- defaultValue: [],
- selectList: [],
- selectShow: false,
- titleStyle: {
- color: '#606266'
- },
- userInfo: '',
- avatarSrc: '',
- baseInfo: {},
- loading: false,
- cellItemColor: ['#6071F5', '#F4A02F', '#2B7FF0', '#4CBF2A']
- }
- },
- computed: {
- baseURL() {
- return this.define.comUploadUrl
- },
- baseURL2() {
- return this.define.baseURL
- },
- token() {
- return uni.getStorageSync('token')
- },
- report() {
- return this.define.report
- }
- },
- onLoad() {
- const chatStore = useChatStore()
- if (!chatStore.getSocket) chat.initSocket()
- },
- onShow() {
- UserSettingInfo().then(res => {
- this.baseInfo = res.data || {}
- this.avatarSrc = this.baseURL2 + this.baseInfo.avatar
- this.loading = true
- })
- this.setStanding()
- },
- methods: {
- confirm(e) {
- if (e[0].index == this.defaultValue[0]) return
- let data = {
- majorId: e[0].value,
- majorType: "Standing",
- menuType: 1,
- }
- setMajor(data).then(res => {
- this.$u.toast(res.msg)
- this.getCurrentUser()
- })
- },
- setStanding() {
- this.selectShow = false
- this.userInfo = uni.getStorageSync('userInfo') || {}
- this.selectList = []
- this.selectList = JSON.parse(JSON.stringify(this.userInfo.standingList))
- this.selectList.forEach((o, i) => {
- o.id = Number(this.selectList[i].id)
- })
- this.defaultValue = [this.selectList.findIndex(o => o.currentStanding)];
- },
- getCurrentUser() {
- const userStore = useUserStore()
- userStore.getCurrentUser().then(() => {
- this.setStanding()
- })
- },
- chooseAvatar() {
- uni.chooseImage({
- count: 1,
- sizeType: ['original', 'compressed'],
- success: (res) => {
- // #ifdef H5
- let isAccept = new RegExp('image/*').test(res.tempFiles[0].type)
- if (!isAccept) return this.$u.toast(`请上传图片`)
- // #endif
- let tempFilePaths = res.tempFilePaths[0]
- uni.uploadFile({
- url: this.baseURL + 'userAvatar',
- filePath: tempFilePaths,
- name: 'file',
- header: {
- 'Authorization': this.token
- },
- success: (uploadFileRes) => {
- let data = JSON.parse(uploadFileRes.data)
- if (data.code === 200) {
- UpdateAvatar(data.data.name).then(res => {
- this.$u.toast('头像更换成功')
- this.avatarSrc = this.baseURL2 + data.data.url
- })
- } else {
- this.$u.toast(data.msg)
- }
- },
- fail: (err) => {
- this.$u.toast('头像更换失败')
- }
- });
- }
- });
- },
- openPage(path, type) {
- if (!path) return
- let url = !!type ? path + '?majorType=' + type : path
- uni.navigateTo({
- url: url
- })
- },
- personalPage(path) {
- if (!path) return
- uni.navigateTo({
- url: path + '?baseInfo=' + encodeURIComponent(JSON
- .stringify(this.baseInfo))
- })
- },
- isJSON(str) {
- try {
- var obj = JSON.parse(str);
- if (typeof obj == 'object' && obj) {
- return true;
- } else {
- return false;
- }
- } catch (e) {
- return false;
- }
- },
- logout() {
- uni.showModal({
- title: '提示',
- content: '确定退出当前账号吗?',
- success: res => {
- if (res.confirm) {
- const userStore = useUserStore()
- userStore.logout().then(() => {
- uni.closeSocket()
- uni.reLaunch({
- url: '/pages/login/index'
- })
- })
- this.removeAccount()
- }
- }
- })
- },
- removeAccount() {
- let model = uni.getStorageSync('rememberAccount')
- if (!model.remember) {
- model.account = ''
- model.password = ''
- model.remember = false
- uni.setStorageSync('rememberAccount', model)
- }
- },
- scanCode() {
- uni.scanCode({
- success: res => {
- let url = ""
- if (this.isJSON(res.result.trim())) {
- const result = JSON.parse(res.result.trim())
- if (result.t === 'ADP') {
- let config = {
- isPreview: 1,
- moduleId: result.id,
- previewType: result.previewType
- }
- url = '/pages/apply/dynamicModel/index?config=' + this.jnpf.base64.encode(JSON
- .stringify(config))
- }
- if (result.t === 'DFD') {
- url = '/pages/apply/dynamicModel/scanForm?config=' + JSON.stringify(result)
- }
- if (result.t === 'WFP') {
- url = '/pages/workFlow/scanForm/index?config=' + JSON.stringify(result)
- }
- if (result.t === 'report') {
- let url_ =
- `${this.report}/preview.html?id=${result.id}&token=${this.token}&page=1&from=menu`
- url = '/pages/apply/externalLink/index?url=' + encodeURIComponent(url_) +
- '&fullName= ' + result.fullName
- }
- if (result.t === 'portal') {
- url = '/pages/portal/scanPortal/index?id=' + result.id
- }
- if (result.t === 'login') {
- url = '/pages/login/scanLogin?id=' + result.id
- }
- } else {
- url = '/pages/my/scanResult/index?result=' + res.result
- }
- uni.navigateTo({
- url,
- fail: (err) => {
- this.$u.toast("暂无此页面")
- }
- })
- }
- });
- }
- }
- }
- </script>
- <style lang="scss">
- page {
- background-color: #f0f2f6;
- }
- .my-v {
- :deep(.u-cell) {
- height: 112rpx;
- padding: 0;
- }
- .my-group-box {
- .my-group-box-inner {
- background-color: #fff;
- .cell-group {
- padding: 0 20rpx;
- .icon-ym-zuzhi {
- color: #6071F5;
- }
- .icon-ym-position1 {
- color: #2B7FF0;
- }
- .icon-ym-generator-section {
- color: #F4A02F;
- }
- .icon-ym-shezhi {
- color: #4CBF2A;
- }
- }
- }
- }
- .user-box {
- background-color: #fff;
- }
- .logout-cell {
- text-align: center;
- font-size: 32rpx;
- height: 108rpx;
- background-color: #fff;
- color: #D82828;
- line-height: 98rpx;
- font-family: PingFang SC;
- }
- .f-right {
- display: flex;
- flex-direction: row;
- justify-content: space-between;
- align-items: center;
- text-align: center;
- }
- }
- </style>
|