my.vue 6.3 KB

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