<template>
|
<view class="container">
|
<view class="uni-panel-userinfo">
|
<view class="uni-panel-h" @click="clickCamera">
|
<text class="uni-panel-text" style="text-align: left;">头像</text>
|
<image class="user-image" :src="imgUserData" mode="widthFix" @error="imageUserError"> </image>
|
<text class="uni-panel-icon fs-ArrowRight"></text>
|
</view>
|
<view class="uni-panel-h">
|
<text>姓名</text>
|
<view class="uni-panel-text">
|
<text>{{userData.name}}</text>
|
</view>
|
</view>
|
<view class="uni-panel-h">
|
<text>账号</text>
|
<view class="uni-panel-text">
|
<text>{{userData.login}}</text>
|
</view>
|
</view>
|
<view class="uni-panel-h">
|
<text>性别</text>
|
<view class="uni-panel-text">
|
<text>{{gender}}</text>
|
</view>
|
</view>
|
<view class="uni-panel-h">
|
<text>别名</text>
|
<view class="uni-panel-text">
|
<text>{{userData.alias}}</text>
|
</view>
|
</view>
|
<view class="uni-panel-h">
|
<text>手机</text>
|
<view class="uni-panel-text">
|
<text>{{mobile}}</text>
|
</view>
|
</view>
|
<view class="uni-panel-h">
|
<text>电话</text>
|
<view class="uni-panel-text">
|
<text>{{userData.tel}}</text>
|
</view>
|
</view>
|
<view class="uni-panel-h">
|
<text>微信号</text>
|
<view class="uni-panel-text">
|
<text>{{userData.wechat}}</text>
|
</view>
|
</view>
|
<view class="uni-panel-h">
|
<text>邮箱</text>
|
<view class="uni-panel-text">
|
<text>{{userData.email}}</text>
|
</view>
|
</view>
|
|
<view class="uni-panel-h">
|
<text>职务</text>
|
<view class="uni-panel-text">
|
<text>{{userData.title}}</text>
|
</view>
|
</view>
|
|
<view class="uni-panel-h">
|
<text>密级</text>
|
<view class="uni-panel-text">
|
<text>{{secret}}</text>
|
</view>
|
</view>
|
<view class="uni-panel-h">
|
<text>职称</text>
|
<view class="uni-panel-text">
|
<text>{{userData.prof_qualify}}</text>
|
</view>
|
</view>
|
<view class="uni-panel-h">
|
<text>入职日期</text>
|
<view class="uni-panel-text">
|
<text>{{userData.dtjoin}}</text>
|
</view>
|
</view>
|
<view class="uni-panel-h">
|
<text>部门</text>
|
<view class="uni-panel-text">
|
<text>{{userData.unidept}}</text>
|
</view>
|
</view>
|
<view class="uni-panel-h2">
|
<text class="uni-panel-cc">签名</text>
|
</view>
|
<view class="uni-panel-c">
|
<text>{{userData.sign}}</text>
|
</view>
|
</view>
|
<view class="uni-panel-safe-bottom" :style="{height:safeAreaBottom + 'px'}" />
|
</view>
|
</template>
|
|
<script>
|
import {
|
showModal,
|
showToast
|
} from "@/common/Page.js"
|
import Session from "@/common/utils.js"
|
import {
|
getUserInfo,
|
updateUser,
|
setPhoto
|
} from "@/api/org.js"
|
|
|
export default {
|
name: "pagesMyUserSetting",
|
components: {},
|
data() {
|
return {
|
safeAreaBottom: getApp().globalData.safeAreaBottom,
|
userData: {},
|
imgUserData: '',
|
isMobilePlatform: true,
|
|
}
|
},
|
computed: {
|
secret() {
|
if (this.userData.secret == 4) {
|
return "绝密"
|
} else if (this.userData.secret == 3) {
|
return "机密"
|
} else if (this.userData.secret == 2) {
|
return "秘密"
|
} else if (this.userData.secret == 1) {
|
return "社外密"
|
} else {
|
return "非密"
|
}
|
},
|
gender() {
|
|
if (this.userData.gender == 2) {
|
return "女"
|
} else if (this.userData.gender == 1) {
|
return "男"
|
} else {
|
return ""
|
}
|
},
|
mobile() {
|
|
if (this.userData.mobile) {
|
if (this.userData.mobile_cornet)
|
return `${this.userData.mobile}-${this.userData.mobile_cornet}`
|
else
|
return `${this.userData.mobile}`
|
} else {
|
return `${this.userData.mobile_cornet}`
|
}
|
}
|
},
|
methods: {
|
setData(obj) {
|
let that = this;
|
let keys = [];
|
let val, data;
|
|
Object.keys(obj).forEach(function(key) {
|
keys = key.split(".");
|
val = obj[key];
|
data = that.$data;
|
keys.forEach(function(key2, index) {
|
if (index + 1 == keys.length) {
|
that.$set(data, key2, val);
|
} else {
|
if (!data[key2]) {
|
that.$set(data, key2, {});
|
}
|
}
|
data = data[key2];
|
});
|
});
|
},
|
loadPlatform() {
|
this.isMobilePlatform = false
|
const app = getApp()
|
if (app.globalData.platform == "ios" || app.globalData.platform == "android") {
|
this.isMobilePlatform = true
|
}
|
|
},
|
imageUserError() {
|
this.imgUserData = getApp().globalData.defaultuserphoto
|
},
|
getDefaultData(data) {
|
const user = getApp().globalData.userdata
|
const {
|
login = "",
|
name = "",
|
alias = "",
|
dtJoin = "",
|
email = "",
|
mobile = "",
|
prof_qualify = "",
|
secret = "",
|
gender = "",
|
sign = "",
|
tel = "",
|
title = "",
|
wechat = "",
|
unidept = user.depart_full_path
|
} = data
|
return {
|
login,
|
name,
|
alias,
|
dtJoin,
|
email,
|
mobile,
|
prof_qualify,
|
secret,
|
gender,
|
sign,
|
tel,
|
title,
|
wechat,
|
unidept
|
}
|
},
|
clickCamera() {
|
var _this = this
|
uni.navigateTo({
|
url: '/pages/my/cropper-image' ,
|
events: {
|
imageCorpped: function(data) {
|
_this.updatePhoto(data)
|
|
|
}
|
}
|
})
|
return
|
var _this = this
|
let sizeType = ['original', 'compressed']
|
//#ifdef MP-DINGTALK
|
sizeType = ['compressed']
|
// #endif
|
uni.chooseImage({
|
count: 1,
|
sizeType: sizeType, //original 原图,compressed 压缩图,默认二者都有
|
sourceType: ['album', 'camera'], //album 从相册选图,camera 使用相机,默认二者都有。
|
success: (res) => {
|
if (res.tempFilePaths) {
|
uni.navigateTo({
|
url: '/pages/my/cropper-image?imageSrc=' + res.tempFilePaths[0],
|
events: {
|
imageCorpped: function(data) {
|
_this.updatePhoto(data)
|
|
|
}
|
}
|
})
|
}
|
|
|
},
|
fail: (err) => {
|
console.log('chooseImage fail', err)
|
if (this.isMobilePlatform && err.errMsg.indexOf('cancel') < 0 && err.errMsg.indexOf(
|
'取消') < 0) {
|
console.log('chooseImage 取消')
|
uni.getSetting({
|
success: (res) => {
|
let authStatus = res.authSetting['scope.album'];
|
if (!authStatus) {
|
showModal("需要从您的相册获取图片,请在设置界面打开相关权限", "授权失败").then((
|
res) => {
|
if (res) {
|
uni.openSetting()
|
}
|
})
|
}
|
}
|
})
|
}
|
}
|
})
|
},
|
updatePhoto(data) {
|
const _this = this
|
uni.getFileSystemManager().readFile({
|
filePath: data.path,
|
encoding: "base64",
|
success: function(res) {
|
const photoType = data.path.split('.').pop()
|
setPhoto(
|
res.data,
|
photoType
|
).then((res) => {
|
const app = getApp()
|
_this.imgUserData =
|
`${app.globalData.apiurl.org}/userphoto?login=${app.globalData.userdata.user_login}&t=${new Date().getTime()}`;
|
const eventChannel = _this.getOpenerEventChannel();
|
eventChannel.emit('updatePhoto', "");
|
}).catch(ex => {
|
console.error(ex)
|
this.showError(ex)
|
})
|
},
|
fail: function(res) {
|
console.error(res)
|
}
|
})
|
},
|
|
showError(ex) {
|
let tip = typeof ex == 'string' ? ex : typeof ex.err_msg == 'string' ? ex.err_msg : typeof ex
|
.errMsg ==
|
'string' ? ex.errMsg : ""
|
showModal(tip, "提示", false)
|
},
|
|
},
|
onLoad() {
|
var _this = this
|
// #ifdef MP-DINGTALK
|
|
my.setNavigationBar({
|
backgroundColor: "#007AFF",
|
frontColor: "#ffffff"
|
})
|
// #endif
|
const app = getApp()
|
_this.imgUserData = `${app.globalData.apiurl.org}/userphoto?login=${app.globalData.userdata.user_login}`;
|
this.loadPlatform()
|
|
getUserInfo(app.globalData.userdata.user_login).then((res) => {
|
// console.log("getUserInfo",res)
|
if (res) {
|
|
let data = _this.getDefaultData(res[0])
|
_this.setData({
|
userData: data
|
})
|
// app.globalData.userInfo = data
|
}
|
|
}).catch((rej) => {
|
this.showError(rej)
|
})
|
}
|
}
|
</script>
|
|
<style>
|
.container {
|
display: flex;
|
width: 750rpx;
|
height: 100%;
|
flex-direction: column;
|
overflow: auto;
|
}
|
|
.uni-panel-userinfo {
|
display: flex;
|
width: 98%;
|
padding: 5px 1%;
|
flex-direction: column;
|
}
|
|
.uni-panel-h {
|
display: flex;
|
background-color: #ffffff;
|
flex-direction: row !important;
|
align-items: center !important;
|
margin: 0px 4px;
|
padding: 12px 12px;
|
font-size: 14px;
|
border-bottom: 1px solid #f2e7e7;
|
}
|
|
.uni-panel-h2 {
|
display: flex;
|
background-color: #ffffff;
|
flex-direction: row !important;
|
align-items: center !important;
|
margin: 0px 4px;
|
padding: 12px 12px 2px;
|
font-size: 14px;
|
}
|
|
.uni-panel-c {
|
display: flex;
|
background-color: #ffffff;
|
align-items: center !important;
|
margin: 0px 4px;
|
padding: 4px 12px;
|
font-size: 12px;
|
border-bottom: 1px solid #f2e7e7;
|
|
}
|
|
.uni-panel-c text {
|
flex: 1;
|
max-height: 56;
|
word-break: break-all;
|
font-size: 14px;
|
}
|
|
.uni-panel-text {
|
flex: 1;
|
color: #000000;
|
font-weight: normal;
|
text-align: right;
|
}
|
|
.uni-panel-icon {
|
margin-left: 8px;
|
color: #999999;
|
font-weight: normal;
|
font-size: 16px;
|
}
|
|
.user-image {
|
height: 50px !important;
|
width: 50px;
|
border-radius: 50%;
|
margin-left: 8px;
|
}
|
</style>
|