myCenter.vue 5.6 KB

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