123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285 |
- <template>
- <view class="uni-app">
- <view class="status-bar" />
- <view class="main-container">
- <wk-nav-bar />
- <view v-if="userInfo" class="container">
- <view class="main linear-gradient">
- <view class="content" @click="handleToUpdate">
- <view class="avatar-box">
- <wk-avatar
- :name="userInfo.realname"
- :avatar="userInfo.img"
- :size="18"
- :preview="false"
- class="avatar" />
- </view>
- <view class="info">
- <view class="realname">
- {{ userInfo.realname }}
- </view>
- <view class="dept">
- {{ userDesc }}
- </view>
- </view>
- <image v-if="!id" :src="$static('images/icon/edit_white.png')" class="edit-icon" />
- </view>
-
- <view class="company">
- <text class="wk wk-customer" />
- {{ companyInfo.companyName || appName }}
- </view>
- </view>
-
- <view class="base-info">
- <view class="cell">
- <view class="cell-title">
- 姓名
- </view>
- <view class="cell-body">
- {{ userInfo.realname || '' }}
- </view>
- </view>
-
- <view class="cell">
- <view class="cell-title">
- 性别
- </view>
- <view class="cell-body">
- {{ getSex(userInfo.sex) }}
- </view>
- </view>
-
- <view class="cell">
- <view class="cell-title">
- 手机
- </view>
- <view class="cell-body">
- {{ userInfo.mobile || '' }}
- </view>
- <image
- :src="$static('images/icon/call_voice.png')"
- class="call-icon"
- @click="ringUp(userInfo.mobile)" />
- </view>
-
- <view class="cell">
- <view class="cell-title">
- 邮箱
- </view>
- <view class="cell-body">
- {{ userInfo.email || '' }}
- </view>
- </view>
-
- <view class="cell">
- <view class="cell-title">
- 部门
- </view>
- <view class="cell-body">
- {{ userInfo.deptName || '' }}
- </view>
- </view>
-
- <view class="cell">
- <view class="cell-title">
- 岗位
- </view>
- <view class="cell-body">
- {{ userInfo.post || '' }}
- </view>
- </view>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- import {
- AdminQueryLoginUser,
- AdminQueryUserInfo,
- QueryCompanyConfig
- } from 'API/admin.js'
-
- import { appName } from '@/config.js'
- import { mapMutations } from 'vuex'
-
- export default {
- name: 'UserInfo',
- data() {
- return {
- id: null,
- userInfo: null,
- companyInfo: {},
-
- refreshPage: false
- }
- },
- computed: {
- userDesc() {
- if (!this.userInfo) return ''
- let str = ''
- str = `${this.userInfo.deptName || ''}-${this.userInfo.post || ''}`
- if (
- str.startsWith('-') ||
- str.endsWith('-')
- ) {
- return str.replace(/-/g, '')
- }
- return str
- },
- appName() {
- return appName
- }
- },
- onLoad(opt) {
- this.id = opt.id || null
- this.getUserInfo()
- this.getCompanyConfig()
- },
- onShow() {
- if (this.refreshPage) {
- this.$nextTick(() => {
- this.refreshPage = false
- this.getUserInfo()
- })
- }
- },
- methods: {
- ...mapMutations({
- setUserInfo: 'user/SET_USER_INFO'
- }),
-
- getUserInfo() {
- if (this.id) {
- AdminQueryUserInfo({
- userId: this.id
- }).then(res => {
- this.userInfo = res
- }).catch(() => {})
- } else {
- AdminQueryLoginUser().then(res => {
- this.userInfo = res
- this.setUserInfo(res)
- }).catch(() => {})
- }
- },
-
- getCompanyConfig() {
- QueryCompanyConfig().then(res => {
- this.companyInfo = res || {}
- }).catch()
- },
-
- getSex(sex) {
- if (isNaN(Number(sex))) return sex
- if (Number(sex) === 1) return '男'
- else if (Number(sex) === 2) return '女'
- return ''
- },
-
- ringUp(tel) {
- if (!tel) {
- this.$toast('暂无电话')
- return
- }
- uni.makePhoneCall({
- phoneNumber: tel
- })
- },
-
- handleToUpdate() {
- if (this.id) return
- this.$Router.navigateTo('/pages_personal/updateUser')
- }
- }
- }
- </script>
- <style scoped lang="scss">
- .main-container {
- .container {
- flex: 1;
- width: 100%;
- display: flex;
- flex-direction: column;
- .main {
- width: 100%;
- padding: 0 38rpx;
- .content {
- padding-top: 50rpx;
- @include left;
- .avatar-box {
- width: 136rpx;
- height: 136rpx;
- border: 5rpx solid white;
- border-radius: 50%;
- margin-right: 32rpx;
- .avatar {
- width: 100%;
- height: 100%;
- }
- }
- .info {
- flex: 1;
- color: white;
- .realname {
- font-size: 46rpx;
- margin-bottom: 15rpx;
- }
- .dept {
- font-size: $wk-font-base;
- }
- }
- .edit-icon {
- width: 45rpx;
- height: 45rpx;
- }
- }
- .company {
- width: 100%;
- font-size: $wk-font-base;
- color: white;
- padding: 45rpx 0 24rpx;
- @include left;
- .wk-customer {
- margin-right: 24rpx;
- }
- }
- }
-
- .base-info {
- flex: 1;
- overflow: auto;
- background-color: white;
- padding: 0 32rpx;
-
- .cell {
- position: relative;
- padding: 15rpx 0;
- border-bottom: 1rpx solid $border-color;
- .cell-title {
- color: $light;
- font-size: $wk-font-sm;
- }
- .cell-body {
- min-height: 45rpx;
- color: $dark;
- font-size: $wk-font-medium;
- margin-top: 10rpx;
- }
- .call-icon {
- position: absolute;
- top: 50%;
- right: 20rpx;
- transform: translateY(-50%);
- width: 56rpx;
- height: 56rpx;
- }
- }
- }
- }
- }
- </style>
|