my.vue 7.1 KB

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