my.vue 6.6 KB

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