my.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. <template>
  2. <layout-page>
  3. <view class="pb-120">
  4. <view class="text-center" @tap="handleTap">
  5. <img :src="getUserAvatar(baseInfo?.avatar, baseInfo?.sex)" alt="" class="img-box">
  6. <view v-if="!useUserStore.isLogin" class="font-weight-bold font-size-20">点击登录</view>
  7. <view v-else class="font-weight-bold font-size-20">{{ baseInfo?.name || userInfo?.phone }}</view>
  8. </view>
  9. <view style="padding: 40rpx 0 0 0;">
  10. <resume-status></resume-status>
  11. </view>
  12. <view class="d-flex">
  13. <view v-for="(item, index) in itemList" :key="index" @tap="handleToLink(item)" class="parent">
  14. <view class="d-flex justify-space-around align-center">
  15. <uni-icons color="#00897B" :type="item.icon" size="30"/>
  16. <text class="itemText">{{ item.title }}</text>
  17. </view>
  18. </view>
  19. </view>
  20. <view style="height: 20rpx; background-color: #f8f8fa;"></view>
  21. <view class="card">
  22. <uni-list>
  23. <uni-list-item
  24. v-for="item in list"
  25. :clickable="true"
  26. :key="item.title"
  27. :title="item.title"
  28. showArrow
  29. :rightText="item.rightTex || ''"
  30. @click="handleToLink(item)"
  31. >
  32. </uni-list-item>
  33. </uni-list>
  34. </view>
  35. <button v-if="useUserStore.isLogin" class="send-button ss-m-b-30" @tap="handleLogout">退出登录</button>
  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="shareQrCodePopup" type="dialog">
  41. <view class="shareQrCodePopupContent">
  42. <view class="color-primary text">邀请用户注册领50积分</view>
  43. <view class="qrCode">
  44. <image :src="shareUrl" style="width: 200px;height: 200px;"></image>
  45. </view>
  46. <!-- <button v-if="shareUrl" class="send-button ss-m-b-30" @tap="handleSaveShareUrl">保存</button> -->
  47. </view>
  48. </uni-popup>
  49. </view>
  50. </layout-page>
  51. </template>
  52. <script setup>
  53. import { ref, computed } from 'vue'
  54. import ResumeStatus from '@/components/ResumeStatus'
  55. import { userStore } from '@/store/user'
  56. import { getUserAvatar } from '@/utils/avatar'
  57. import { getAccessToken } from '@/utils/request'
  58. import layoutPage from '@/layout'
  59. import { showAuthModal } from '@/hooks/useModal'
  60. import { onShow } from '@dcloudio/uni-app'
  61. import { getJobAdvertisedShareQrcode } from '@/api/user'
  62. // import { base64src } from '@/utils/base64src.js'
  63. // 设置自定义tabbar选中值
  64. onShow(() => {
  65. const currentPage = getCurrentPages()[0]; // 获取当前页面实例
  66. const currentTabBar = currentPage?.getTabBar?.();
  67. // 设置当前tab页的下标index
  68. currentTabBar?.setData({ selected: 4 });
  69. })
  70. const useUserStore = userStore()
  71. const baseInfo = computed(() => useUserStore?.baseInfo)
  72. const userInfo = computed(() => useUserStore?.userInfo)
  73. const popup = ref()
  74. const shareQrCodePopup = ref()
  75. const itemList = [
  76. { title: "我的关注", path: "/pagesA/collect/index", icon: "list" },
  77. { title:'关注我的', path:'/pagesA/seenMe/index', icon:'staff' }
  78. ]
  79. const list = [
  80. { title: '我的分享码', path: 'shareQrCode' },
  81. { title: '在线简历', path: '/pagesA/resumeOnline/index' },
  82. { title: '附件简历', path: '/pagesA/resume/index' },
  83. { title: '面试管理', path: '/pagesA/interview/index' },
  84. { title: '门墩儿商城', appId: 'wx6decdf12f9e7a061' },
  85. { title: '我要招聘', key: 'recruit' }
  86. ]
  87. // 列表跳转
  88. const handleToLink = (item) => {
  89. if (item.appId) {
  90. // uni.navigateToMiniProgram({
  91. // appId: item.appId,
  92. // })
  93. // return
  94. uni.showToast({
  95. title: '请前往网页版门墩儿商城',
  96. icon: 'none'
  97. })
  98. }
  99. if (item.key === 'recruit') {
  100. uni.showToast({
  101. title: '请前往网页版门墩儿招聘',
  102. icon: 'none'
  103. })
  104. }
  105. if (!item.path) return
  106. if (!getAccessToken()) {
  107. uni.showToast({
  108. title: '请先登录',
  109. icon: 'none'
  110. })
  111. showAuthModal()
  112. return
  113. }
  114. if (item.path === 'shareQrCode') {
  115. handleShareCode()
  116. return
  117. }
  118. uni.navigateTo({
  119. url: item.path
  120. })
  121. }
  122. const shareUrl = ref()
  123. // 生成分享二维码
  124. const handleShareCode = async () => {
  125. const userId = useUserStore?.accountInfo?.userId || ''
  126. if (!userId) {
  127. uni.showToast({
  128. title: '请先登录',
  129. icon: 'none'
  130. })
  131. }
  132. const query = {
  133. scene: 'shareId=' + userId,
  134. path: 'pages/login/index',
  135. width: 200,
  136. autoColor: false,
  137. checkPath: true,
  138. hyaline: true
  139. }
  140. const res = await getJobAdvertisedShareQrcode(query)
  141. shareUrl.value = res?.data ? 'data:image/png;base64,' + res.data : ''
  142. shareQrCodePopup.value.open()
  143. }
  144. // 保存到本地
  145. const handleSaveShareUrl = async () => {
  146. const convertData = await base64src(shareUrl.value, '我的分享码')
  147. }
  148. // 登录
  149. const handleTap = () => {
  150. if (!useUserStore.isLogin) {
  151. showAuthModal()
  152. return
  153. }
  154. uni.navigateTo({
  155. url: '/pagesA/resumeOnline/index'
  156. })
  157. }
  158. // 退出登录
  159. const handleLogout = () => {
  160. popup.value.open()
  161. }
  162. const handleLogoutClose = () => {
  163. popup.value.close()
  164. }
  165. const handleLogoutConfirm = () => {
  166. useUserStore.handleLogout()
  167. }
  168. </script>
  169. <style scoped lang="scss">
  170. .pb-120 {
  171. padding-bottom: 120rpx;
  172. }
  173. .img-box {
  174. width: 150rpx;
  175. height: 150rpx;
  176. border: 2rpx solid #ccc;
  177. border-radius: 50%;
  178. }
  179. :deep(.uni-list-item) {
  180. height: 120rpx !important;
  181. line-height: 120rpx !important;
  182. }
  183. :deep(.uni-list-item__content-title) {
  184. font-size: 32rpx !important;
  185. font-weight: 500;
  186. }
  187. .colors{
  188. font-size: 24rpx;
  189. color: #606266;
  190. }
  191. .size-16{
  192. color: #3f424f;
  193. font-size: 32rpx;
  194. margin: 13rpx 0 5rpx 0;
  195. }
  196. .itemText {
  197. color: #3f424f;
  198. font-size: 36rpx;
  199. }
  200. .parent{
  201. width: 50%;
  202. border: 1px solid #f4f4f4;
  203. border-radius: 10rpx;
  204. margin: 0 30rpx 20rpx 30rpx;
  205. padding: 20rpx;
  206. }
  207. .parent:first-child{
  208. margin: 0 0 20rpx 30rpx;
  209. }
  210. .shareQrCodePopupContent {
  211. // width: 80vw;
  212. // display: flex;
  213. // flex-direction: column;
  214. margin: 30rpx;
  215. padding: 50rpx;
  216. text-align: center;
  217. background-color: #fff;
  218. .text {
  219. margin-bottom: 20px;
  220. }
  221. .qrCode {
  222. margin-left: 4px;
  223. }
  224. }
  225. </style>