my.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. <template>
  2. <layout-page>
  3. <view class="pb-150">
  4. <view class="text-center ss-p-b-30" :class="vip ? 'vipBox' : 'avatarBox'" @tap="handleLogin">
  5. <img :src="getUserAvatar(userInfo?.avatar, userInfo?.sex)" alt="" class="img-box">
  6. <image v-if="vip" src="/static/svg/vip.svg" class="vipIcon"></image>
  7. <view v-if="!useUserStore.isLogin" class="font-weight-bold font-size-20">点击登录</view>
  8. <view v-else>
  9. <view>
  10. <span class="font-weight-bold font-size-20">{{ userInfo?.name || userInfo?.phone }}</span>
  11. <uni-icons @tap="handleEdit('/pagesB/staffInfoEdit/index')" class="ss-m-l-10" type="compose" :size="22"></uni-icons>
  12. </view>
  13. <view style="color: #0E100F" class="ss-m-t-20">
  14. <span>{{ formatName(userInfo?.enterpriseAnotherName || userInfo?.enterpriseName) }}</span>
  15. <uni-icons @tap="handleEdit('/pagesB/companyInfoEdit/index')" class="ss-m-l-10" type="compose" :size="22"></uni-icons>
  16. </view>
  17. </view>
  18. </view>
  19. <view class="defaultBgc ss-p-t-30">
  20. <view class="list-card">
  21. <uni-list>
  22. <uni-list-item
  23. v-for="item in list"
  24. :clickable="true"
  25. :key="item.title"
  26. :title="item.title"
  27. showArrow
  28. :rightText="item.rightTex || ''"
  29. @click="handleToLink(item)"
  30. >
  31. </uni-list-item>
  32. </uni-list>
  33. </view>
  34. <button v-if="useUserStore.isLogin" class="send-button" style="margin-bottom: 50px;" @tap="handleLogout">退出登录</button>
  35. </view>
  36. <uni-popup ref="popup" type="dialog">
  37. <uni-popup-dialog type="warn" cancelText="取消" confirmText="确定" title="系统提示" content="确认退出账号?" @confirm="handleLogoutConfirm"
  38. @close="handleLogoutClose"></uni-popup-dialog>
  39. </uni-popup>
  40. <uni-popup ref="inputDialog" type="dialog">
  41. <view class="shareQrCodePopupContent">
  42. <view>请前往网页版{{ dialogType ? '门墩儿招聘' : '门墩儿商城' }}</view>
  43. <uni-link class="ss-m-t-10" :href="dialogType ? 'https://www.menduner.com' : 'https://www.menduner.com/mall'" text="点击复制网页地址" color="#00B760" fontSize="16" copyTips="已复制,请在电脑端打开"></uni-link>
  44. </view>
  45. </uni-popup>
  46. </view>
  47. </layout-page>
  48. </template>
  49. <script setup>
  50. import { ref, computed, watch } from 'vue'
  51. import { userStore } from '@/store/user'
  52. import { getUserAvatar } from '@/utils/avatar'
  53. import { getAccessToken } from '@/utils/request'
  54. import layoutPage from '@/layout'
  55. import { formatName } from '@/utils/getText'
  56. import { showAuthModal } from '@/hooks/useModal'
  57. import { onShow, onLoad, onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app'
  58. // 设置自定义tabbar选中值
  59. onShow(() => {
  60. const currentPage = getCurrentPages()[0]; // 获取当前页面实例
  61. const currentTabBar = currentPage?.getTabBar?.();
  62. // 设置当前tab页的下标index
  63. currentTabBar?.setData({ selected: 4 });
  64. })
  65. const inputDialog = ref()
  66. const useUserStore = userStore()
  67. const userInfo = computed(() => useUserStore?.userInfo)
  68. const vip = computed(() => new Date().getTime() < useUserStore?.userInfo?.vipExpireDate)
  69. const popup = ref()
  70. const defaultList = [
  71. { title: '简历管理', path: '/pagesA/resume/index' },
  72. { title: '面试管理', path: '/pagesA/interview/index' },
  73. { title: '修改密码', path: '/pagesA/editPassword/index' },
  74. { title: '联系我们', path: '/pagesB/contactUs/index' },
  75. { title: '协议中心', path: '/pagesB/agreement/index', open: true },
  76. { title: '我要求职', appId: 'wx5dd538ccc752b03a' },
  77. ]
  78. const list = ref(defaultList.filter(e => !e.defaultHide))
  79. onLoad(() => {
  80. wx.showShareMenu({
  81. withShareTicket: true,
  82. menus: ['shareAppMessage', 'shareTimeline']
  83. })
  84. onShareAppMessage(() => {
  85. return {
  86. title: '门墩儿 专注顶尖招聘',
  87. path: '/pages/index/position',
  88. imageUrl: '../../static/img/share-poster.jpg'
  89. }
  90. })
  91. onShareTimeline(() => {
  92. return {
  93. title: '门墩儿 专注顶尖招聘',
  94. path: '/pages/index/position',
  95. imageUrl: '../../static/img/share-poster.jpg'
  96. }
  97. })
  98. })
  99. // 列表跳转
  100. const dialogType = ref('')
  101. const handleToLink = (item) => {
  102. if (item.open && item.path) return uni.navigateTo({ url: item.path })
  103. if (item.appId) {
  104. uni.navigateToMiniProgram({
  105. appId: item.appId,
  106. })
  107. return
  108. }
  109. if (item?.showDialog) {
  110. dialogType.value = 0
  111. inputDialog.value.open()
  112. return
  113. }
  114. if (!item.path) return
  115. if (!getAccessToken()) {
  116. uni.showToast({
  117. title: '请先登录',
  118. icon: 'none'
  119. })
  120. showAuthModal()
  121. return
  122. }
  123. uni.navigateTo({
  124. url: item.path
  125. })
  126. }
  127. const handleEdit = (url) => {
  128. if (!useUserStore.isLogin) {
  129. showAuthModal()
  130. return
  131. }
  132. if (!url) return
  133. uni.navigateTo({
  134. url
  135. })
  136. }
  137. // 退出登录
  138. const handleLogout = () => {
  139. popup.value.open()
  140. }
  141. const handleLogoutClose = () => {
  142. popup.value.close()
  143. }
  144. const handleLogoutConfirm = () => {
  145. // list.value = defaultList.filter(e => !e.hide) // 重置菜单
  146. useUserStore.handleLogout()
  147. }
  148. const handleLogin = () => {
  149. if (!getAccessToken()) {
  150. showAuthModal()
  151. }
  152. }
  153. </script>
  154. <style scoped lang="scss">
  155. .list-card {
  156. margin: 0 30rpx 30rpx 30rpx;
  157. border-radius: 20rpx;
  158. overflow: hidden;
  159. }
  160. .pb-150 {
  161. padding-bottom: 100px;
  162. }
  163. .img-box {
  164. width: 150rpx;
  165. height: 150rpx;
  166. border: 2rpx solid #ccc;
  167. border-radius: 50%;
  168. }
  169. .vipBox {
  170. color: #a18a0f;
  171. position: relative;
  172. .img-box {
  173. border: 1px solid gold;
  174. }
  175. .vipIcon {
  176. position: absolute;
  177. width: 45px;
  178. height: 24px;
  179. top: 60px;
  180. left: 50%;
  181. }
  182. }
  183. :deep(.uni-list-item) {
  184. height: 120rpx !important;
  185. line-height: 120rpx !important;
  186. }
  187. :deep(.uni-list-item__content-title) {
  188. font-size: 28rpx !important;
  189. }
  190. :deep(.uniui-arrowright) {
  191. color: #0E100F !important;
  192. }
  193. .shareQrCodePopupContent {
  194. width: 75vw;
  195. padding: 40rpx;
  196. margin-bottom: 20rpx;
  197. text-align: center;
  198. background-color: #fff;
  199. .text {
  200. margin-bottom: 20px;
  201. }
  202. .qrCode {
  203. margin-left: 4px;
  204. }
  205. .saveImg {
  206. text-align: center;
  207. margin-top: 10px;
  208. color: #999;
  209. }
  210. }
  211. </style>