integrated_traffic_uniapp/pages/my/home.vue

185 lines
4.9 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<template name="my">
<view>
<cu-custom bgColor="bg-gradual-blueness">
<block slot="content">我的</block>
</cu-custom>
<view class="my-avatar">
<view class="cu-avatar xl round margin-left" :style="{'background-color':'#fff','background-image': 'url(' + userPhoto + ')',}"></view>
<view class="right">
<view class="f30 text-bold">{{loginUser.NAME}}</view>
<view class="mt10">
<text class="text-grey">帐号</text>
<text class="text-grey">{{loginUser.USERNAME}}</text>
</view>
</view>
</view>
<view class="cu-list menu margin-top">
<view v-if="loginCorpId" class="cu-item arrow">
<navigator v-if="isRest==='1'" class="content" hover-class="none" url="../" @click="showRest()">
<text class="text-semi">离岗</text>
</navigator>
<navigator class="content" v-else hover-class="none" url="/pages/my/offduty/index">
<text class="text-semi">离岗</text>
</navigator>
</view>
<view class="cu-item arrow">
<navigator class="content" hover-class="none" url="/pages/my/set/set">
<text class="text-semi">设置</text>
</navigator>
</view>
<view class="cu-item arrow">
<navigator class="content" hover-class="none" url="/pages/my/feedback/feedback">
<text class="text-semi">问题反馈</text>
</navigator>
</view>
<!-- <view class="cu-item arrow">-->
<!-- <navigator class="content" hover-class="none" url="/pages/my/promise/promise">-->
<!-- <text class="text-semi">安全承诺</text>-->
<!-- </navigator>-->
<!-- </view>-->
<view class="cu-item arrow">
<navigator class="content" hover-class="none" url="/pages/my/agreement/agreement">
<text class="text-semi">用户服务协议</text>
</navigator>
</view>
<view class="cu-item arrow">
<navigator class="content" hover-class="none" url="/pages/my/privacy/privacy">
<text class="text-semi">用户隐私协议</text>
</navigator>
</view>
<view class="cu-item arrow">
<navigator class="content" hover-class="none" url="/pages/my/help/help">
<text class="text-semi">帮助中心</text>
</navigator>
</view>
<view class="cu-item arrow">
<navigator class="content" hover-class="none" url="/pages/my/about/about">
<text class="text-semi"></text>
</navigator>
</view>
</view>
</view>
</template>
<script>
import {
basePath,loginUser,baseImgPath,isRest,corpinfoId,setIsRest
} from '@/common/tool.js';
export default {
data() {
return {
loginCorpId: '',
loginUser :'',
userPhoto :'/static/avatar.png',
isRest :''
};
},
mounted() {
this.loginUser = loginUser;
this.loginCorpId = loginUser.CORPINFO_ID
this.isRest = isRest;
if(this.loginCorpId && this.loginUser.USERNAME){
this.getData();
this.getUserInfo();
}
},
methods: {
showRest(){
uni.showToast({
icon: 'none',
title: "您已经处于离岗状态中",
duration: 2000
});
},
getData(){
var _this = this;
// 查看是否离岗
uni.request({
url: basePath+'/app/offduty/isRest',
method: 'POST',
dataType: 'json',
header:{
'Content-type':'application/x-www-form-urlencoded'
},
data: {
CORPINFO_ID:loginUser.CORPINFO_ID,
USER_ID:loginUser.USER_ID,
},
success: (res) => {
if (res.data.ISREST != null) {
setIsRest(res.data.ISREST);
_this.isRest = res.data.ISREST;
}
_this.$forceUpdate();
},
fail: (res) => {
uni.showToast({
icon: 'none',
title: "服务器正在升级,请稍后再试。",
duration: 2000
});
}
});
},
getUserInfo(){
var _this = this;
uni.request({
url: basePath+"/app/user/getUserPhoto", //提交接口
method: 'POST',
dataType:'json',
header:{
'Content-type':'application/x-www-form-urlencoded'
},
data: {
USERNAME:this.loginUser.USERNAME,
CORPINFO_ID:loginUser.CORPINFO_ID,
USER_ID:loginUser.USER_ID,
},
success: (res) => {
if('success' == res.data.result){
this.checkImgExists(basePath +"/"+ res.data.userPhoto).then(res => {
_this.userPhoto =basePath +"/"+ res.data.userPhoto;
});
}else{
uni.showToast({
title: res.data.message,
duration: 2000
});
}
}
});
},
// 图片是否可访问成功
checkImgExists(imgurl) {
return new Promise(function(resolve, reject) {
let ImgObj = new Image();
ImgObj.src = imgurl;
ImgObj.onload = function(res) {
resolve(res);
}
ImgObj.onerror = function(err) {
reject(err)
}
})
},
},
}
</script>
<style>
.my-avatar{
background-color: #fff;
padding: 40upx 20upx;
display: flex;
align-items: center;
}
.my-avatar .right{
margin-left: 30upx;
}
.cu-list.menu>.cu-item.arrow {
padding-right: 35px;
}
</style>