my.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  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, watch } 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 = ref([
  86. { title: '我的分享码', path: 'shareQrCode' },
  87. { title: '在线简历', path: '/pagesA/resumeOnline/index' },
  88. { title: '附件简历', path: '/pagesA/resume/index' },
  89. // { title: '简历模板', path: '/pagesA/resume/index' },
  90. // { title: '屏蔽企业', path: '/pagesA/resume/index' },
  91. { title: '面试管理', path: '/pagesA/interview/index' },
  92. { title: '门墩儿商城', appId: 'wx6decdf12f9e7a061' },
  93. { title: '我要招聘', key: 'recruit' }
  94. ])
  95. watch(
  96. () => vip.value,
  97. (newVal) => {
  98. if (newVal) list.value.splice(1, 0, { title: 'vip权益', key: 'vip', path: '/pagesA/vip/index' })
  99. else list.value = list.value.filter(e => !e.key || e.key !== 'vip')
  100. },
  101. { immediate: true },
  102. // { deep: true }
  103. )
  104. // 列表跳转
  105. const handleToLink = (item) => {
  106. if (item.appId) {
  107. // uni.navigateToMiniProgram({
  108. // appId: item.appId,
  109. // })
  110. // return
  111. uni.showToast({
  112. title: '请前往网页版门墩儿商城',
  113. icon: 'none'
  114. })
  115. }
  116. if (item.key === 'recruit') {
  117. uni.showToast({
  118. title: '请前往网页版门墩儿招聘',
  119. icon: 'none'
  120. })
  121. }
  122. if (!item.path) return
  123. if (!getAccessToken()) {
  124. uni.showToast({
  125. title: '请先登录',
  126. icon: 'none'
  127. })
  128. showAuthModal()
  129. return
  130. }
  131. if (item.path === 'shareQrCode') {
  132. handleShareCode()
  133. return
  134. }
  135. uni.navigateTo({
  136. url: item.path
  137. })
  138. }
  139. const shareUrl = ref()
  140. // 生成分享二维码
  141. const handleShareCode = async () => {
  142. const userId = useUserStore?.accountInfo?.userId || ''
  143. if (!userId) {
  144. uni.showToast({
  145. title: '请先登录',
  146. icon: 'none'
  147. })
  148. showAuthModal()
  149. return
  150. }
  151. // if (!getAccessToken())
  152. const query = {
  153. scene: 'shareId=' + userId,
  154. path: 'pages/login/index',
  155. width: 200,
  156. autoColor: false,
  157. checkPath: true,
  158. hyaline: true
  159. }
  160. const res = await getJobAdvertisedShareQrcode(query)
  161. shareUrl.value = res?.data ? 'data:image/png;base64,' + res.data : ''
  162. shareQrCodePopup.value.open()
  163. }
  164. // 保存到本地
  165. // const handleSaveShareUrl = async () => {
  166. // const fsm = wx.getFileSystemManager()
  167. // const data = shareUrl.value
  168. // if (!data) return
  169. // fsm.writeFile({
  170. // filePath:wx.env.USER_DATA_PATH+'/MySharingCode.png',
  171. // data: data.slice(22),
  172. // encoding:'base64',
  173. // success: res => {
  174. // wx.saveImageToPhotosAlbum({
  175. // filePath: wx.env.USER_DATA_PATH + '/MySharingCode.png',
  176. // success: function (res) {
  177. // wx.showToast({
  178. // title: '保存成功',
  179. // })
  180. // },
  181. // fail: function (err) {
  182. // console.log(err)
  183. // }
  184. // })
  185. // }, fail: err => {
  186. // console.log(err)
  187. // }
  188. // })
  189. // }
  190. // 登录
  191. const handleTap = () => {
  192. if (!useUserStore.isLogin) {
  193. showAuthModal()
  194. return
  195. }
  196. uni.navigateTo({
  197. url: '/pagesA/resumeOnline/index'
  198. })
  199. }
  200. // 退出登录
  201. const handleLogout = () => {
  202. popup.value.open()
  203. }
  204. const handleLogoutClose = () => {
  205. popup.value.close()
  206. }
  207. const handleLogoutConfirm = () => {
  208. useUserStore.handleLogout()
  209. }
  210. </script>
  211. <style scoped lang="scss">
  212. .pb-120 {
  213. padding-bottom: 120rpx;
  214. }
  215. .img-box {
  216. width: 150rpx;
  217. height: 150rpx;
  218. border: 2rpx solid #ccc;
  219. border-radius: 50%;
  220. }
  221. .vipBox {
  222. color: #a18a0f;
  223. position: relative;
  224. .img-box {
  225. border: 1px solid gold;
  226. }
  227. .vipIcon {
  228. position: absolute;
  229. width: 45px;
  230. height: 45px;
  231. bottom: 24px;
  232. left: 50%;
  233. }
  234. }
  235. :deep(.uni-list-item) {
  236. height: 120rpx !important;
  237. line-height: 120rpx !important;
  238. }
  239. :deep(.uni-list-item__content-title) {
  240. font-size: 32rpx !important;
  241. font-weight: 500;
  242. }
  243. .colors{
  244. font-size: 24rpx;
  245. color: #606266;
  246. }
  247. .size-16{
  248. color: #3f424f;
  249. font-size: 32rpx;
  250. margin: 13rpx 0 5rpx 0;
  251. }
  252. .itemText {
  253. color: #3f424f;
  254. font-size: 36rpx;
  255. }
  256. .parent{
  257. width: 50%;
  258. border: 1px solid #f4f4f4;
  259. border-radius: 10rpx;
  260. margin: 0 30rpx 20rpx 30rpx;
  261. padding: 20rpx;
  262. }
  263. .parent:first-child{
  264. margin: 0 0 20rpx 30rpx;
  265. }
  266. .shareQrCodePopupContent {
  267. width: 80vw;
  268. padding: 30rpx;
  269. margin-bottom: 20rpx;
  270. text-align: center;
  271. background-color: #fff;
  272. .text {
  273. margin-bottom: 20px;
  274. }
  275. .qrCode {
  276. margin-left: 4px;
  277. }
  278. .saveImg {
  279. text-align: center;
  280. margin-top: 10px;
  281. color: #999;
  282. }
  283. }
  284. </style>