index.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. <template>
  2. <!--我的-->
  3. <view class="my-container">
  4. <view class="user-info-header">
  5. <userAvatar></userAvatar>
  6. <view class="col">
  7. <text class="u-name">{{ userInfo.userName }}</text>
  8. <view class="u-office">
  9. <text class="department">{{ userInfo.company }}</text>
  10. <view class="position" v-show="userInfo.post">
  11. {{ userInfo.post }}
  12. </view>
  13. </view>
  14. </view>
  15. <view class="leave-box" v-if="userStatus">
  16. <view class="bg-box"></view>
  17. <view class="leave-txt">{{ userStatus }}</view>
  18. </view>
  19. <view>
  20. <image
  21. src="@/static/images/my/header-bg.png"
  22. class="right-icon"
  23. ></image>
  24. </view>
  25. </view>
  26. <view class="content-fun">
  27. <view
  28. class="cell"
  29. @click="handleClick(item)"
  30. :key="idx"
  31. v-for="(item, idx) in list"
  32. >
  33. <view class="left-title">
  34. <image
  35. class="cell-img"
  36. :src="require(`@/static/images/my/${item.iconName}.png`)"
  37. ></image>
  38. <text>{{ item.title }}</text>
  39. </view>
  40. <view class="right-box">
  41. <msgNum
  42. v-if="item.msgNum"
  43. size="12"
  44. :value="item.msgNum"
  45. ></msgNum>
  46. <text class="tel-text" v-if="item.tel">{{ newTel }}</text>
  47. <u-icon name="arrow-right"></u-icon>
  48. </view>
  49. </view>
  50. </view>
  51. <c-button
  52. type="primary"
  53. class="footer-btn"
  54. @click="handleConfirm"
  55. >
  56. 退出登录
  57. </c-button>
  58. <u-modal
  59. :show="isShow"
  60. showCancelButton
  61. @confirm="handleLogOut"
  62. closeOnClickOverlay
  63. @close="isShow = false"
  64. @cancel="isShow = false"
  65. >
  66. 确认退出登录吗?
  67. </u-modal>
  68. </view>
  69. </template>
  70. <script>
  71. import userAvatar from '@/pages/my/userAvatar.vue';
  72. import msgNum from '@/components/msgNum/index.vue';
  73. export default {
  74. name: 'my',
  75. components: {
  76. userAvatar,
  77. msgNum,
  78. },
  79. data() {
  80. return {
  81. isShow: false,
  82. list: [
  83. {
  84. iconName: 'my-msg',
  85. title: '我的消息',
  86. msgNum: 10,
  87. path: '/pages/com/msgNotification/index',
  88. },
  89. {
  90. iconName: 'personal-data',
  91. title: '个人资料',
  92. msgNum: 0,
  93. path: '/pages/my/personalData',
  94. },
  95. {
  96. iconName: 'update-pwd',
  97. title: '修改密码',
  98. msgNum: 0,
  99. path: '/pages/my/updatePwd',
  100. },
  101. {
  102. iconName: 'update-phoneNum',
  103. title: '修改手机号',
  104. tel: '',
  105. msgNum: 0,
  106. path: '/pages/my/checkCurrentTel',
  107. },
  108. ],
  109. userInfo: {},
  110. };
  111. },
  112. onShow() {
  113. this.getUserInfo();
  114. },
  115. computed: {
  116. userStatus() {
  117. // 0正常 1加班 2出差 3请假
  118. const types = {
  119. 1: '加班',
  120. 2: '出差',
  121. 3: '请假',
  122. };
  123. const status = this.userInfo?.status;
  124. return types[status];
  125. },
  126. newTel() {
  127. const { phonenumber } = this.userInfo;
  128. return this.$c.middleTel(phonenumber, true);
  129. },
  130. },
  131. methods: {
  132. async getUserInfo() {
  133. const { data } = await this.$store.dispatch('user/GetInfo');
  134. this.userInfo = data || {};
  135. },
  136. handleClick(item) {
  137. this.$u.route(item.path);
  138. },
  139. handleConfirm() {
  140. this.isShow = true;
  141. },
  142. async handleLogOut() {
  143. await this.$store.dispatch('user/LogOut');
  144. this.isShow = false;
  145. },
  146. },
  147. };
  148. </script>
  149. <style scoped lang="scss">
  150. .my-container {
  151. background-color: #f8f8f8;
  152. padding: 28rpx;
  153. height: 100%;
  154. .user-info-header {
  155. position: relative;
  156. display: flex;
  157. align-items: center;
  158. background-color: #fff;
  159. padding: 30rpx;
  160. border-radius: $bd-radius;
  161. height: 70px;
  162. margin-bottom: 28rpx;
  163. .col {
  164. display: flex;
  165. flex-direction: column;
  166. margin-left: 20rpx;
  167. .u-name {
  168. font-size: 13px;
  169. color: #000000;
  170. }
  171. .u-office {
  172. display: flex;
  173. align-items: center;
  174. margin-top: 20rpx;
  175. .department {
  176. font-size: 12px;
  177. color: #8c93a3;
  178. }
  179. .position {
  180. color: #ff9935;
  181. padding: 0px 6rpx;
  182. font-size: 13px;
  183. border: 1px solid #ff9935;
  184. border-radius: 10rpx;
  185. margin-left: 10rpx;
  186. background-color: rgba(239, 140, 39, 0.1);
  187. }
  188. }
  189. }
  190. .leave-box {
  191. .bg-box {
  192. position: absolute;
  193. right: 0;
  194. top: 0;
  195. z-index: 1;
  196. border-width: 20px;
  197. border-style: solid;
  198. border-color: #436ff6 #436ff6 transparent transparent;
  199. }
  200. .leave-txt {
  201. transform: rotateZ(45deg);
  202. position: absolute;
  203. top: 5px;
  204. right: 0;
  205. z-index: 2;
  206. font-size: 12px;
  207. color: #fff;
  208. }
  209. }
  210. .right-icon {
  211. position: absolute;
  212. top: 0;
  213. right: 0;
  214. width: 78px;
  215. height: 70px;
  216. }
  217. }
  218. .content-fun {
  219. background-color: #fff;
  220. border-radius: $bd-radius;
  221. .cell {
  222. display: flex;
  223. align-items: center;
  224. justify-content: space-between;
  225. border-bottom: 1px solid #edeeef;
  226. &:last-child {
  227. border-bottom: 0;
  228. }
  229. padding: 28rpx;
  230. .left-title {
  231. display: flex;
  232. align-items: center;
  233. }
  234. .right-box {
  235. display: flex;
  236. align-items: center;
  237. .tel-text {
  238. font-size: 13px;
  239. }
  240. }
  241. .cell-img {
  242. width: 34px;
  243. height: 34px;
  244. margin-right: 16rpx;
  245. }
  246. }
  247. }
  248. .footer-btn {
  249. margin-top: 100rpx;
  250. }
  251. }
  252. </style>