my.vue 6.9 KB

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