my.vue 7.0 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 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. console.log(1, 'userId', userId)
  133. if (!userId) {
  134. uni.showToast({
  135. title: '请先登录',
  136. icon: 'none'
  137. })
  138. showAuthModal()
  139. return
  140. }
  141. // if (!getAccessToken())
  142. const query = {
  143. scene: 'shareId=' + userId,
  144. path: 'pages/login/index',
  145. width: 200,
  146. autoColor: false,
  147. checkPath: true,
  148. hyaline: true
  149. }
  150. const res = await getJobAdvertisedShareQrcode(query)
  151. shareUrl.value = res?.data ? 'data:image/png;base64,' + res.data : ''
  152. shareQrCodePopup.value.open()
  153. }
  154. // 保存到本地
  155. // const handleSaveShareUrl = async () => {
  156. // const fsm = wx.getFileSystemManager()
  157. // const data = shareUrl.value
  158. // if (!data) return
  159. // fsm.writeFile({
  160. // filePath:wx.env.USER_DATA_PATH+'/MySharingCode.png',
  161. // data: data.slice(22),
  162. // encoding:'base64',
  163. // success: res => {
  164. // wx.saveImageToPhotosAlbum({
  165. // filePath: wx.env.USER_DATA_PATH + '/MySharingCode.png',
  166. // success: function (res) {
  167. // wx.showToast({
  168. // title: '保存成功',
  169. // })
  170. // },
  171. // fail: function (err) {
  172. // console.log(err)
  173. // }
  174. // })
  175. // }, fail: err => {
  176. // console.log(err)
  177. // }
  178. // })
  179. // }
  180. // 登录
  181. const handleTap = () => {
  182. if (!useUserStore.isLogin) {
  183. showAuthModal()
  184. return
  185. }
  186. uni.navigateTo({
  187. url: '/pagesA/resumeOnline/index'
  188. })
  189. }
  190. // 退出登录
  191. const handleLogout = () => {
  192. popup.value.open()
  193. }
  194. const handleLogoutClose = () => {
  195. popup.value.close()
  196. }
  197. const handleLogoutConfirm = () => {
  198. useUserStore.handleLogout()
  199. }
  200. </script>
  201. <style scoped lang="scss">
  202. .pb-120 {
  203. padding-bottom: 120rpx;
  204. }
  205. .img-box {
  206. width: 150rpx;
  207. height: 150rpx;
  208. border: 2rpx solid #ccc;
  209. border-radius: 50%;
  210. }
  211. .vipBox {
  212. color: #a18a0f;
  213. position: relative;
  214. .img-box {
  215. border: 1px solid gold;
  216. }
  217. .vipIcon {
  218. position: absolute;
  219. width: 45px;
  220. height: 45px;
  221. bottom: 24px;
  222. left: 50%;
  223. }
  224. }
  225. :deep(.uni-list-item) {
  226. height: 120rpx !important;
  227. line-height: 120rpx !important;
  228. }
  229. :deep(.uni-list-item__content-title) {
  230. font-size: 32rpx !important;
  231. font-weight: 500;
  232. }
  233. .colors{
  234. font-size: 24rpx;
  235. color: #606266;
  236. }
  237. .size-16{
  238. color: #3f424f;
  239. font-size: 32rpx;
  240. margin: 13rpx 0 5rpx 0;
  241. }
  242. .itemText {
  243. color: #3f424f;
  244. font-size: 36rpx;
  245. }
  246. .parent{
  247. width: 50%;
  248. border: 1px solid #f4f4f4;
  249. border-radius: 10rpx;
  250. margin: 0 30rpx 20rpx 30rpx;
  251. padding: 20rpx;
  252. }
  253. .parent:first-child{
  254. margin: 0 0 20rpx 30rpx;
  255. }
  256. .shareQrCodePopupContent {
  257. width: 80vw;
  258. padding: 30rpx;
  259. margin-bottom: 20rpx;
  260. text-align: center;
  261. background-color: #fff;
  262. .text {
  263. margin-bottom: 20px;
  264. }
  265. .qrCode {
  266. margin-left: 4px;
  267. }
  268. .saveImg {
  269. text-align: center;
  270. margin-top: 10px;
  271. color: #999;
  272. }
  273. }
  274. </style>