myCenter.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. <template>
  2. <view class="profile">
  3. <view class="banner">
  4. <template>
  5. <image :src="user.accountAvatar" class="avatar" @error="avatarError" v-if="user.userAvata"></image>
  6. <image :src="defAvatar" class="avatar" v-else></image>
  7. </template>
  8. <view class="user-info">
  9. <view class="name">
  10. <text>{{user.userName}}</text>
  11. <text v-if="user.positionName">({{user.positionName}})</text>
  12. </view>
  13. <view v-if="phone&&phone.phoneNumber" >{{phone.phoneNumber}}</view>
  14. <view v-else>
  15. {{user.accountPhone?user.accountPhone:'--'}}
  16. </view>
  17. </view>
  18. </view>
  19. <view class="statistics" v-if="isAccount===1">
  20. <view class="card task" @click="linkTo('task')">
  21. <view class="name">待办任务</view>
  22. <view class="number">{{statistics.myTaskHandlingCount}}</view>
  23. </view>
  24. <view class="card danger" @click="linkTo('danger')">
  25. <view class="name">待处理隐患</view>
  26. <view class="number">{{statistics.myDangerHandlingCount}}</view>
  27. </view>
  28. </view>
  29. <div class="hand-list">
  30. <view class="hand-item" v-if="isAccount===1">
  31. <view class="hand-lf" @click="linkTo(1)">
  32. <image class="icon" src="/static/center/location.png"></image>
  33. <view class="name">操作记录</view>
  34. </view>
  35. <view class="hand-rt"></view>
  36. </view>
  37. <view class="hand-item" v-if="isAccount===1">
  38. <view class="hand-lf" @click="linkTo(2)">
  39. <image class="icon" src="/static/center/user-group.png"></image>
  40. <view class="name">个人信息</view>
  41. </view>
  42. <view class="hand-rt"></view>
  43. </view>
  44. <view class="hand-item" @click="linkTo(3)">
  45. <view class="hand-lf">
  46. <image class="icon" src="/static/center/unlock.png"></image>
  47. <view class="name">关于</view>
  48. </view>
  49. <view class="hand-rt"></view>
  50. </view>
  51. </div>
  52. <!-- <button type="primary" @click="logoutSubmit" class="submit-BT">退出登录</button> -->
  53. </view>
  54. </template>
  55. <script>
  56. import {logout} from '@/api/system/user.js'
  57. import {waitHandleStatistics} from '@/api/aqpt/task.js'
  58. import defAvatar from '@/static/avatar.png'
  59. import { getUserInfo} from '@/api/system/user.js'
  60. export default {
  61. data() {
  62. return {
  63. defAvatar,
  64. isAccount:undefined,
  65. phone:{},
  66. user:{
  67. userAvatar:"",
  68. userName:"--",
  69. userIntro:"",
  70. userPhone:"--"
  71. },
  72. statistics:{
  73. myDangerHandlingCount:0,
  74. myTaskHandlingCount: 0
  75. }
  76. }
  77. },
  78. onLoad() {
  79. this.init()
  80. },
  81. methods: {
  82. init(){
  83. this.initUser()
  84. this.getwaitHandleStatistics()
  85. },
  86. getwaitHandleStatistics(){
  87. waitHandleStatistics().then((res)=>{
  88. this.statistics=res.data
  89. })
  90. },
  91. initUser(){
  92. this.isAccount =uni.getStorageSync('isAccount')
  93. this.phone=uni.getStorageSync('phone-info')
  94. this.user.userName=uni.getStorageSync('wxName')
  95. if(this.isAccount===1){
  96. getUserInfo().then((res)=>{
  97. this.user={...this.user,...res.data}
  98. uni.setStorageSync('accountInfo',res.data)
  99. })
  100. }
  101. },
  102. linkTo(index){
  103. if(index===1){uni.switchTab({url:'/pages/history/history'})}
  104. if(index===2){uni.navigateTo({url:'/pages/myCenter/profile/profile'})}
  105. if(index===3){uni.navigateTo({url:'/pages/service_agreement/service_agreement'})}
  106. if(index==='task'){
  107. uni.navigateTo({url:'/pages/task/task'})
  108. }
  109. if(index==='danger'){
  110. uni.navigateTo({url:'/pages/danger/danger'})
  111. }
  112. },
  113. logoutSubmit(){
  114. uni.clearStorageSync();
  115. logout().then(()=>{
  116. uni.navigateTo({
  117. url:'/pages/login/index'
  118. })
  119. })
  120. },
  121. avatarError(){
  122. this.user.userAvatar=this.defAvatar
  123. }
  124. }
  125. ,onPullDownRefresh() {
  126. this.init()
  127. uni.stopPullDownRefresh()
  128. }
  129. }
  130. </script>
  131. <style lang="scss" scoped>
  132. .profile{
  133. .banner{
  134. height: 236rpx;
  135. padding-left:30rpx;
  136. display: flex;
  137. align-items: center;
  138. .avatar{
  139. display: block;
  140. width: 112rpx;
  141. height: 112rpx;
  142. border-radius: 50%;
  143. }
  144. .user-info{
  145. padding-left: 30rpx;
  146. .name{
  147. color: #35364F;
  148. font-size: 38rpx;
  149. font-weight: 700;
  150. line-height: 54rpx;
  151. }
  152. .phone{
  153. color: #35364F;
  154. font-size: 28rpx;
  155. line-height: 44rpx;
  156. }
  157. }
  158. }
  159. .statistics{
  160. display: flex;
  161. justify-content: space-between;
  162. padding: 32rpx;
  163. .card{
  164. width: 328rpx;
  165. height: 168rpx;
  166. display: flex;
  167. justify-content: center;
  168. align-items: center;
  169. flex-direction: column;
  170. background-position: bottom right;
  171. background-repeat: no-repeat;
  172. background-size: 102rpx 102rpx;
  173. border-radius: 16rpx;
  174. &.task{
  175. background-color: #FFFDED;
  176. margin-right: 15rpx;
  177. background-image: url('/static/center/task.png');
  178. }
  179. &.danger{
  180. background-color: #F4F5FE;
  181. margin-left: 15rpx;
  182. background-image: url('/static/center/danger.png');
  183. }
  184. .name{
  185. font-size: 28rpx;
  186. line-height: 48rpx;
  187. color: #35364F;
  188. }
  189. .number{
  190. font-size: 40rpx;
  191. line-height: 48rpx;
  192. color: #35364F;
  193. font-weight: 700;
  194. }
  195. }
  196. }
  197. .hand-list{
  198. margin-top: 24rpx;
  199. padding: 0 24rpx;
  200. .hand-item{
  201. height: 120rpx;
  202. display: flex;
  203. align-items: center;
  204. background-image: url('/static/arrow.png');
  205. background-position:center right 36rpx;
  206. background-repeat: no-repeat;
  207. background-size: 44rpx 44rpx;
  208. .hand-lf{
  209. flex: 1;
  210. display: flex;
  211. align-items: center;
  212. .icon{
  213. display: block;
  214. width: 48rpx;
  215. height: 48rpx;
  216. }
  217. .name{
  218. font-size: 32rpx;
  219. line-height: 48rpx;
  220. padding-left: 8rpx;
  221. color: #35364F;
  222. }
  223. }
  224. }
  225. }
  226. .submit-BT {
  227. width: 600rpx;
  228. height: 72rpx;
  229. line-height: 72rpx;
  230. box-sizing: border-box;
  231. border-radius: 16upx;
  232. margin-top: 50upx;
  233. background-color:#3384FF;
  234. font-size: 32rpx;
  235. }
  236. }
  237. </style>