my.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  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="#00B760" :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="#00B760" 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, showNecessaryInfoPopup } from '@/utils/request'
  71. import layoutPage from '@/layout'
  72. import { showAuthModal } from '@/hooks/useModal'
  73. import { onShow, onLoad, onShareAppMessage, onShareTimeline } 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. // showAuthModal('selectUserType') //测试 selectUserType
  83. const inputDialog = ref()
  84. const useUserStore = userStore()
  85. const baseInfo = computed(() => useUserStore?.baseInfo)
  86. const userInfo = computed(() => useUserStore?.userInfo)
  87. const vip = computed(() => new Date().getTime() < useUserStore?.userInfo?.vipExpireDate)
  88. const popup = ref()
  89. const shareQrCodePopup = ref()
  90. const itemList = [
  91. { title: "我的关注", path: "/pagesA/collect/index", icon: "list" },
  92. { title:'关注我的', path:'/pagesA/seenMe/index', icon:'staff' }
  93. ]
  94. const defaultList = [
  95. { title: '在线简历', path: '/pagesA/resumeOnline/index' },
  96. { title: '附件简历', path: '/pagesA/resume/index' },
  97. { title: '学生专区', path: '/pagesA/student/index', key: 'student', hide: true },
  98. { title: '面试管理', path: '/pagesA/interview/index' },
  99. { title: '会员套餐', path: '/pagesA/vipPackage/index' },
  100. { title: '我的分享码', path: '/pagesB/sharePoster/index' },
  101. { title: '新用户邀请记录', path: '/pagesB/inviteRecord/index' },
  102. { title: '门墩儿商城', appId: 'wx6decdf12f9e7a061' },
  103. { title: '我要招聘', key: 'recruit' },
  104. { title: '联系我们', path: '/pagesB/contactUs/index' },
  105. { title: '协议中心', path: '/pagesB/agreement/index', open: true }
  106. ]
  107. const list = ref(defaultList.filter(e => !e.hide))
  108. watch(
  109. () => baseInfo.value,
  110. (newVal) => {
  111. if (newVal) {
  112. list.value = defaultList.map(e => {
  113. if (e?.key === 'student' && newVal.type === '1') e.hide = false // 学生信息管理。 type:0是求职者,1是学生
  114. return e.hide ? null : e
  115. }).filter(Boolean)
  116. }
  117. },
  118. { immediate: true },
  119. // { deep: true }
  120. )
  121. watch(
  122. () => vip.value,
  123. (newVal) => {
  124. if (newVal) list.value.splice(3, 0, { title: 'vip权益', key: 'vip', path: '/pagesA/vip/index' })
  125. else list.value = list.value.filter(e => !e.key || e.key !== 'vip')
  126. },
  127. { immediate: true },
  128. // { deep: true }
  129. )
  130. onLoad(() => {
  131. wx.showShareMenu({
  132. withShareTicket: true,
  133. menus: ['shareAppMessage', 'shareTimeline']
  134. })
  135. onShareAppMessage(() => {
  136. return {
  137. title: '门墩儿 专注顶尖招聘',
  138. path: '/pages/index/position',
  139. imageUrl: '../../static/img/share-poster.jpg'
  140. }
  141. })
  142. onShareTimeline(() => {
  143. return {
  144. title: '门墩儿 专注顶尖招聘',
  145. path: '/pages/index/position',
  146. imageUrl: '../../static/img/share-poster.jpg'
  147. }
  148. })
  149. })
  150. // 列表跳转
  151. const dialogType = ref('')
  152. const handleToLink = (item) => {
  153. if (item.open && item.path) return uni.navigateTo({ url: item.path })
  154. if (item.appId) {
  155. // uni.navigateToMiniProgram({
  156. // appId: item.appId,
  157. // })
  158. // return
  159. // uni.showToast({
  160. // title: '请前往网页版门墩儿商城',
  161. // icon: 'none'
  162. // })
  163. dialogType.value = 0
  164. inputDialog.value.open()
  165. }
  166. if (item.key === 'recruit') {
  167. // uni.showToast({
  168. // title: '请前往网页版门墩儿招聘',
  169. // icon: 'none'
  170. // })
  171. dialogType.value = 1
  172. inputDialog.value.open()
  173. }
  174. if (!item.path) return
  175. if (!getAccessToken()) {
  176. uni.showToast({
  177. title: '请先登录',
  178. icon: 'none'
  179. })
  180. showAuthModal()
  181. return
  182. }
  183. if (showNecessaryInfoPopup()) {
  184. uni.showToast({
  185. title: '请先完善基本信息',
  186. icon: 'none'
  187. })
  188. showAuthModal('necessaryInfo')
  189. return
  190. }
  191. if (item.path === 'shareQrCode') {
  192. handleShareCode()
  193. return
  194. }
  195. uni.navigateTo({
  196. url: item.path
  197. })
  198. }
  199. const shareUrl = ref()
  200. // 生成分享二维码
  201. const handleShareCode = async () => {
  202. const userId = useUserStore?.accountInfo?.userId || ''
  203. if (!userId) {
  204. uni.showToast({
  205. title: '请先登录',
  206. icon: 'none'
  207. })
  208. showAuthModal()
  209. return
  210. }
  211. if (showNecessaryInfoPopup()) {
  212. uni.showToast({
  213. title: '请先完善基本信息',
  214. icon: 'none'
  215. })
  216. showAuthModal('necessaryInfo')
  217. return
  218. }
  219. const query = {
  220. scene: 'shareId=' + userId,
  221. path: 'pages/login/index',
  222. width: 200,
  223. autoColor: false,
  224. checkPath: true,
  225. hyaline: true
  226. }
  227. const res = await getJobAdvertisedShareQrcode(query)
  228. shareUrl.value = res?.data ? 'data:image/png;base64,' + res.data : ''
  229. shareQrCodePopup.value.open()
  230. }
  231. // 保存到本地
  232. // const handleSaveShareUrl = async () => {
  233. // const fsm = wx.getFileSystemManager()
  234. // const data = shareUrl.value
  235. // if (!data) return
  236. // fsm.writeFile({
  237. // filePath:wx.env.USER_DATA_PATH+'/MySharingCode.png',
  238. // data: data.slice(22),
  239. // encoding:'base64',
  240. // success: res => {
  241. // wx.saveImageToPhotosAlbum({
  242. // filePath: wx.env.USER_DATA_PATH + '/MySharingCode.png',
  243. // success: function (res) {
  244. // wx.showToast({
  245. // title: '保存成功',
  246. // })
  247. // },
  248. // fail: function (err) {
  249. // console.log(err)
  250. // }
  251. // })
  252. // }, fail: err => {
  253. // console.log(err)
  254. // }
  255. // })
  256. // }
  257. // 登录
  258. const handleTap = () => {
  259. if (!useUserStore.isLogin) {
  260. showAuthModal()
  261. return
  262. }
  263. uni.navigateTo({
  264. url: '/pagesA/resumeOnline/index'
  265. })
  266. }
  267. // 退出登录
  268. const handleLogout = () => {
  269. popup.value.open()
  270. }
  271. const handleLogoutClose = () => {
  272. popup.value.close()
  273. }
  274. const handleLogoutConfirm = () => {
  275. useUserStore.handleLogout()
  276. }
  277. </script>
  278. <style scoped lang="scss">
  279. .pb-150 {
  280. padding-bottom: 100px;
  281. }
  282. .img-box {
  283. width: 150rpx;
  284. height: 150rpx;
  285. border: 2rpx solid #ccc;
  286. border-radius: 50%;
  287. }
  288. .vipBox {
  289. color: #a18a0f;
  290. position: relative;
  291. .img-box {
  292. border: 1px solid gold;
  293. }
  294. .vipIcon {
  295. position: absolute;
  296. width: 45px;
  297. height: 24px;
  298. bottom: 34px;
  299. left: 50%;
  300. }
  301. }
  302. :deep(.uni-list-item) {
  303. height: 120rpx !important;
  304. line-height: 120rpx !important;
  305. }
  306. :deep(.uni-list-item__content-title) {
  307. font-size: 32rpx !important;
  308. font-weight: 500;
  309. }
  310. .colors{
  311. font-size: 24rpx;
  312. color: #606266;
  313. }
  314. .size-16{
  315. color: #3f424f;
  316. font-size: 32rpx;
  317. margin: 13rpx 0 5rpx 0;
  318. }
  319. .itemText {
  320. color: #3f424f;
  321. font-size: 36rpx;
  322. }
  323. .parent{
  324. width: 50%;
  325. border: 1px solid #f4f4f4;
  326. border-radius: 10rpx;
  327. margin: 0 30rpx 20rpx 30rpx;
  328. padding: 20rpx;
  329. }
  330. .parent:first-child{
  331. margin: 0 0 20rpx 30rpx;
  332. }
  333. .shareQrCodePopupContent {
  334. width: 75vw;
  335. padding: 40rpx;
  336. margin-bottom: 20rpx;
  337. text-align: center;
  338. background-color: #fff;
  339. .text {
  340. margin-bottom: 20px;
  341. }
  342. .qrCode {
  343. margin-left: 4px;
  344. }
  345. .saveImg {
  346. text-align: center;
  347. margin-top: 10px;
  348. color: #999;
  349. }
  350. }
  351. </style>