my.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <template>
  2. <view class="ss-p-b-30">
  3. <view class="text-center" @tap="handleTap">
  4. <img :src="getUserAvatar(baseInfo?.avatar, baseInfo?.sex)" alt="" class="img-box">
  5. <view v-if="!useUserStore.isLogin" class="font-weight-bold font-size-20">点击登录</view>
  6. <view v-else class="font-weight-bold font-size-20">{{ baseInfo?.name || userInfo?.phone }}</view>
  7. </view>
  8. <view class="d-flex" style="margin-top: 80rpx;">
  9. <view v-for="(item, index) in itemList" :key="index" @tap="handleToLink(item)" class="parent">
  10. <view class="d-flex justify-space-between">
  11. <view>
  12. <view class="colors">
  13. <span>查看更多</span>
  14. <uni-icons color="#c8c5c4" type="right" size="15" class="ml"/>
  15. </view>
  16. <view class="size-16">{{ item.title }}</view>
  17. </view>
  18. <view>
  19. <uni-icons color="#00897B" :type="item.icon" size="45"/>
  20. </view>
  21. </view>
  22. </view>
  23. </view>
  24. <view style="height: 10rpx; background-color: #f8f8fa;"></view>
  25. <view class="card">
  26. <uni-list>
  27. <uni-list-item v-for="item in list" :clickable="true" :key="item.title" :title="item.title" showArrow :rightText="item.rightTex || ''" @click="handleToLink(item)"></uni-list-item>
  28. </uni-list>
  29. </view>
  30. <button v-if="useUserStore.isLogin" class="send-button" @tap="handleLogout">退出登录</button>
  31. <uni-popup ref="popup" type="dialog">
  32. <uni-popup-dialog type="warn" cancelText="取消" confirmText="确定" title="系统提示" content="确认退出账号?" @confirm="handleLogoutConfirm"
  33. @close="handleLogoutClose"></uni-popup-dialog>
  34. </uni-popup>
  35. </view>
  36. </template>
  37. <script setup>
  38. import { ref, computed } from 'vue'
  39. import { userStore } from '@/store/user'
  40. import { getUserAvatar } from '@/utils/avatar'
  41. import { getAccessToken } from '@/utils/request'
  42. const useUserStore = userStore()
  43. const baseInfo = computed(() => useUserStore?.baseInfo)
  44. const userInfo = computed(() => useUserStore?.userInfo)
  45. const popup = ref()
  46. const itemList = [
  47. { title: "面试管理", path: "/pagesA/interview/index", icon: "list" },
  48. { title:'谁看过我', path:'/pagesA/seenMe/index', icon:'staff' }
  49. ]
  50. const list = [
  51. { title: '附件简历', path: '/pagesA/resume/index' },
  52. { title: '我的收藏', path: '/pagesA/collect/index' },
  53. { title: '前往门墩儿甄选商城', appId: 'wx6decdf12f9e7a061' },
  54. { title: '切换为求职者', rightTex: '我要找工作' }
  55. ]
  56. // 列表跳转
  57. const handleToLink = (item) => {
  58. if (item.appId) {
  59. uni.navigateToMiniProgram({
  60. appId: item.appId,
  61. // extraData: {} // 要传递的数据
  62. })
  63. return
  64. }
  65. if (!item.path) return
  66. if (!getAccessToken()) {
  67. uni.showToast({
  68. title: '请先登录'
  69. })
  70. uni.navigateTo({
  71. url: '/pages/login/index'
  72. })
  73. return
  74. }
  75. uni.navigateTo({
  76. url: item.path
  77. })
  78. }
  79. // 登录
  80. const handleTap = () => {
  81. if (!useUserStore.isLogin) {
  82. uni.navigateTo({
  83. url: '/pages/login/index'
  84. })
  85. return
  86. }
  87. uni.navigateTo({
  88. url: '/pagesA/info/index'
  89. })
  90. }
  91. // 退出登录
  92. const handleLogout = () => {
  93. popup.value.open()
  94. }
  95. const handleLogoutClose = () => {
  96. popup.value.close()
  97. }
  98. const handleLogoutConfirm = () => {
  99. useUserStore.handleLogout()
  100. }
  101. </script>
  102. <style scoped lang="scss">
  103. .img-box {
  104. width: 150rpx;
  105. height: 150rpx;
  106. border: 2rpx solid #ccc;
  107. border-radius: 50%;
  108. }
  109. ::v-deep .uni-list-item{
  110. height: 140rpx !important;
  111. line-height: 140rpx !important;
  112. }
  113. ::v-deep .uni-list-item__content-title{
  114. font-size: 32rpx !important;
  115. font-weight: 500;
  116. }
  117. .colors{
  118. font-size: 24rpx;
  119. color: #606266;
  120. }
  121. .size-16{
  122. color: #3f424f;
  123. font-size: 32rpx;
  124. margin: 13rpx 0 5rpx 0;
  125. }
  126. .parent{
  127. width: 50%;
  128. border: 1px solid #f4f4f4;
  129. border-radius: 10rpx;
  130. margin: 0 30rpx 20rpx 30rpx;
  131. padding: 20rpx;
  132. }
  133. .parent:first-child{
  134. margin: 0 0 20rpx 30rpx;
  135. }
  136. </style>