my.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  1. <template>
  2. <layout-page>
  3. <view class="pb-150">
  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" @click.stop="handleToLink({path: '/pagesA/vip/index'})"></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" style="margin-bottom: 50px;" @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. <!-- 我的分享码 -->
  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. <uni-popup ref="inputDialog" type="dialog">
  57. <view class="shareQrCodePopupContent">
  58. <view>请前往网页版{{ dialogType ? '门墩儿招聘' : '门墩儿商城' }}</view>
  59. <uni-link class="ss-m-t-10" :href="dialogType ? 'https://www.menduner.com' : 'https://www.menduner.com/mall'" text="点击复制网页地址" color="#00897B" fontSize="16" copyTips="已复制,请在电脑端打开"></uni-link>
  60. </view>
  61. </uni-popup>
  62. </view>
  63. </layout-page>
  64. </template>
  65. <script setup>
  66. import { ref, computed, watch } from 'vue'
  67. import ResumeStatus from '@/components/ResumeStatus'
  68. import { userStore } from '@/store/user'
  69. import { getUserAvatar } from '@/utils/avatar'
  70. import { getAccessToken } from '@/utils/request'
  71. import layoutPage from '@/layout'
  72. import { showAuthModal } from '@/hooks/useModal'
  73. import { onShow, onLoad } from '@dcloudio/uni-app'
  74. import { getJobAdvertisedShareQrcode } from '@/api/user'
  75. // 设置自定义tabbar选中值
  76. onShow(() => {
  77. const currentPage = getCurrentPages()[0]; // 获取当前页面实例
  78. const currentTabBar = currentPage?.getTabBar?.();
  79. // 设置当前tab页的下标index
  80. currentTabBar?.setData({ selected: 4 });
  81. })
  82. const inputDialog = ref()
  83. const useUserStore = userStore()
  84. const baseInfo = computed(() => useUserStore?.baseInfo)
  85. const userInfo = computed(() => useUserStore?.userInfo)
  86. const vip = computed(() => new Date().getTime() < useUserStore?.userInfo?.vipExpireDate)
  87. const popup = ref()
  88. const shareQrCodePopup = ref()
  89. const itemList = [
  90. { title: "我的关注", path: "/pagesA/collect/index", icon: "list" },
  91. { title:'关注我的', path:'/pagesA/seenMe/index', icon:'staff' }
  92. ]
  93. const list = ref([
  94. { title: '我的分享码', path: 'shareQrCode' },
  95. { title: '新用户邀请记录', path: '/pagesB/inviteRecord/index' },
  96. { title: '在线简历', path: '/pagesA/resumeOnline/index' },
  97. { title: '附件简历', path: '/pagesA/resume/index' },
  98. { title: '面试管理', path: '/pagesA/interview/index' },
  99. { title: '门墩儿商城', appId: 'wx6decdf12f9e7a061' },
  100. { title: '我要招聘', key: 'recruit' },
  101. { title: '协议中心', path: '/pagesB/agreement/index', open: true }
  102. ])
  103. watch(
  104. () => vip.value,
  105. (newVal) => {
  106. if (newVal) list.value.splice(2, 0, { title: 'vip权益', key: 'vip', path: '/pagesA/vip/index' })
  107. else list.value = list.value.filter(e => !e.key || e.key !== 'vip')
  108. },
  109. { immediate: true },
  110. // { deep: true }
  111. )
  112. onLoad(() => {
  113. wx.showShareMenu({
  114. withShareTicket: true,
  115. menus: ['shareAppMessage', 'shareTimeline']
  116. })
  117. onShareAppMessage(() => {
  118. return {
  119. title: '门墩儿 专注顶尖招聘',
  120. path: '/pages/index/position'
  121. }
  122. })
  123. onShareTimeline(() => {
  124. return {
  125. title: '门墩儿 专注顶尖招聘',
  126. path: '/pages/index/position'
  127. }
  128. })
  129. })
  130. // 列表跳转
  131. const dialogType = ref('')
  132. const handleToLink = (item) => {
  133. if (item.open && item.path) return uni.navigateTo({ url: item.path })
  134. if (item.appId) {
  135. // uni.navigateToMiniProgram({
  136. // appId: item.appId,
  137. // })
  138. // return
  139. // uni.showToast({
  140. // title: '请前往网页版门墩儿商城',
  141. // icon: 'none'
  142. // })
  143. dialogType.value = 0
  144. inputDialog.value.open()
  145. }
  146. if (item.key === 'recruit') {
  147. // uni.showToast({
  148. // title: '请前往网页版门墩儿招聘',
  149. // icon: 'none'
  150. // })
  151. dialogType.value = 1
  152. inputDialog.value.open()
  153. }
  154. if (!item.path) return
  155. if (!getAccessToken()) {
  156. uni.showToast({
  157. title: '请先登录',
  158. icon: 'none'
  159. })
  160. showAuthModal()
  161. return
  162. }
  163. if (item.path === 'shareQrCode') {
  164. handleShareCode()
  165. return
  166. }
  167. uni.navigateTo({
  168. url: item.path
  169. })
  170. }
  171. const shareUrl = ref()
  172. // 生成分享二维码
  173. const handleShareCode = async () => {
  174. const userId = useUserStore?.accountInfo?.userId || ''
  175. if (!userId) {
  176. uni.showToast({
  177. title: '请先登录',
  178. icon: 'none'
  179. })
  180. showAuthModal()
  181. return
  182. }
  183. // if (!getAccessToken())
  184. const query = {
  185. scene: 'shareId=' + userId,
  186. path: 'pages/login/index',
  187. width: 200,
  188. autoColor: false,
  189. checkPath: true,
  190. hyaline: true
  191. }
  192. const res = await getJobAdvertisedShareQrcode(query)
  193. shareUrl.value = res?.data ? 'data:image/png;base64,' + res.data : ''
  194. shareQrCodePopup.value.open()
  195. }
  196. // 保存到本地
  197. // const handleSaveShareUrl = async () => {
  198. // const fsm = wx.getFileSystemManager()
  199. // const data = shareUrl.value
  200. // if (!data) return
  201. // fsm.writeFile({
  202. // filePath:wx.env.USER_DATA_PATH+'/MySharingCode.png',
  203. // data: data.slice(22),
  204. // encoding:'base64',
  205. // success: res => {
  206. // wx.saveImageToPhotosAlbum({
  207. // filePath: wx.env.USER_DATA_PATH + '/MySharingCode.png',
  208. // success: function (res) {
  209. // wx.showToast({
  210. // title: '保存成功',
  211. // })
  212. // },
  213. // fail: function (err) {
  214. // console.log(err)
  215. // }
  216. // })
  217. // }, fail: err => {
  218. // console.log(err)
  219. // }
  220. // })
  221. // }
  222. // 登录
  223. const handleTap = () => {
  224. if (!useUserStore.isLogin) {
  225. showAuthModal()
  226. return
  227. }
  228. uni.navigateTo({
  229. url: '/pagesA/resumeOnline/index'
  230. })
  231. }
  232. // 退出登录
  233. const handleLogout = () => {
  234. popup.value.open()
  235. }
  236. const handleLogoutClose = () => {
  237. popup.value.close()
  238. }
  239. const handleLogoutConfirm = () => {
  240. useUserStore.handleLogout()
  241. }
  242. </script>
  243. <style scoped lang="scss">
  244. .pb-150 {
  245. padding-bottom: 100px;
  246. }
  247. .img-box {
  248. width: 150rpx;
  249. height: 150rpx;
  250. border: 2rpx solid #ccc;
  251. border-radius: 50%;
  252. }
  253. .vipBox {
  254. color: #a18a0f;
  255. position: relative;
  256. .img-box {
  257. border: 1px solid gold;
  258. }
  259. .vipIcon {
  260. position: absolute;
  261. width: 45px;
  262. height: 24px;
  263. bottom: 34px;
  264. left: 50%;
  265. }
  266. }
  267. :deep(.uni-list-item) {
  268. height: 120rpx !important;
  269. line-height: 120rpx !important;
  270. }
  271. :deep(.uni-list-item__content-title) {
  272. font-size: 32rpx !important;
  273. font-weight: 500;
  274. }
  275. .colors{
  276. font-size: 24rpx;
  277. color: #606266;
  278. }
  279. .size-16{
  280. color: #3f424f;
  281. font-size: 32rpx;
  282. margin: 13rpx 0 5rpx 0;
  283. }
  284. .itemText {
  285. color: #3f424f;
  286. font-size: 36rpx;
  287. }
  288. .parent{
  289. width: 50%;
  290. border: 1px solid #f4f4f4;
  291. border-radius: 10rpx;
  292. margin: 0 30rpx 20rpx 30rpx;
  293. padding: 20rpx;
  294. }
  295. .parent:first-child{
  296. margin: 0 0 20rpx 30rpx;
  297. }
  298. .shareQrCodePopupContent {
  299. width: 75vw;
  300. padding: 40rpx;
  301. margin-bottom: 20rpx;
  302. text-align: center;
  303. background-color: #fff;
  304. .text {
  305. margin-bottom: 20px;
  306. }
  307. .qrCode {
  308. margin-left: 4px;
  309. }
  310. .saveImg {
  311. text-align: center;
  312. margin-top: 10px;
  313. color: #999;
  314. }
  315. }
  316. </style>