my.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  1. <template>
  2. <layout-page>
  3. <view class="pb-150">
  4. <view class="text-center" :class="vip ? 'vipBox' : 'avatarBox'" @tap="handleTap">
  5. <view class="img-box">
  6. <img :src="getUserAvatar(baseInfo?.avatar, baseInfo?.sex)" alt="" class="img">
  7. <image v-if="vip" src="/static/svg/vip.svg" class="vipIcon" @click.stop="handleToLink({path: '/pagesA/vip/index'})"></image>
  8. </view>
  9. <view v-if="!useUserStore.isLogin" class="font-weight-bold font-size-20">点击登录</view>
  10. <view v-else class="font-weight-bold font-size-20">{{ baseInfo?.name || userInfo?.phone }}</view>
  11. </view>
  12. <view style="padding: 40rpx 0 0 0;">
  13. <resume-status></resume-status>
  14. </view>
  15. <view class="d-flex">
  16. <view v-for="(item, index) in itemList" :key="index" @tap="handleToLink(item)" class="parent">
  17. <view class="d-flex justify-space-around align-center">
  18. <uni-icons color="#00B760" :type="item.icon" size="30"/>
  19. <text class="itemText">{{ item.title }}</text>
  20. </view>
  21. </view>
  22. </view>
  23. <view style="height: 20rpx; background-color: #f8f8fa;"></view>
  24. <view class="card">
  25. <uni-list>
  26. <uni-list-item
  27. v-for="item in list"
  28. :clickable="true"
  29. :key="item.title"
  30. :title="item.title"
  31. showArrow
  32. :rightText="item.rightTex || ''"
  33. @click="handleToLink(item)"
  34. >
  35. </uni-list-item>
  36. </uni-list>
  37. </view>
  38. <button v-if="useUserStore.isLogin" class="send-button" style="margin-bottom: 50px;" @tap="handleLogout">退出登录</button>
  39. <uni-popup ref="popup" type="dialog">
  40. <uni-popup-dialog type="warn" cancelText="取消" confirmText="确定" title="系统提示" content="确认退出账号?" @confirm="handleLogoutConfirm"
  41. @close="handleLogoutClose"></uni-popup-dialog>
  42. </uni-popup>
  43. <!-- 我的分享码 -->
  44. <uni-popup ref="shareQrCodePopup" type="dialog">
  45. <view class="shareQrCodePopupContent">
  46. <view class="color-primary text">邀请用户注册领50积分</view>
  47. <view class="qrCode">
  48. <image
  49. v-if="!!shareUrl"
  50. :src="shareUrl"
  51. :show-menu-by-longpress="true"
  52. style="width: 200px;height: 200px; padding: 20rpx;"
  53. ></image>
  54. </view>
  55. <view v-if="shareUrl" class="saveImg">长按二维码保存图片</view>
  56. </view>
  57. </uni-popup>
  58. <uni-popup ref="inputDialog" type="dialog">
  59. <view class="shareQrCodePopupContent">
  60. <view>请前往网页版{{ dialogType ? '门墩儿招聘' : '门墩儿商城' }}</view>
  61. <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>
  62. </view>
  63. </uni-popup>
  64. </view>
  65. </layout-page>
  66. </template>
  67. <script setup>
  68. import { ref, computed, watch } from 'vue'
  69. import ResumeStatus from '@/components/ResumeStatus'
  70. import { userStore } from '@/store/user'
  71. import { getUserAvatar } from '@/utils/avatar'
  72. import { getAccessToken, showNecessaryInfoPopup } from '@/utils/request'
  73. import layoutPage from '@/layout'
  74. import { showAuthModal } from '@/hooks/useModal'
  75. import { onShow, onLoad, onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app'
  76. import { getJobAdvertisedShareQrcode } from '@/api/user'
  77. // 设置自定义tabbar选中值
  78. onShow(() => {
  79. const currentPage = getCurrentPages()[0]; // 获取当前页面实例
  80. const currentTabBar = currentPage?.getTabBar?.();
  81. // 设置当前tab页的下标index
  82. currentTabBar?.setData({ selected: 4 });
  83. })
  84. // showAuthModal('') //测试 selectUserType
  85. const inputDialog = ref()
  86. const useUserStore = userStore()
  87. const baseInfo = computed(() => useUserStore?.baseInfo)
  88. const userInfo = computed(() => useUserStore?.userInfo)
  89. const vip = computed(() => new Date().getTime() < useUserStore?.userInfo?.vipExpireDate)
  90. const popup = ref()
  91. const shareQrCodePopup = ref()
  92. const itemList = [
  93. { title: "我的关注", path: "/pagesA/collect/index", icon: "list" },
  94. { title:'关注我的', path:'/pagesA/seenMe/index', icon:'staff' }
  95. ]
  96. const defaultList = [
  97. { title: '在线简历', path: '/pagesA/resumeOnline/index' },
  98. { title: '附件简历', path: '/pagesA/resume/index' },
  99. { title: '学生专区', path: '/pagesA/student/index', key: 'student', defaultHide: true },
  100. { title: '面试管理', path: '/pagesA/interview/index' },
  101. { title: '会员套餐', path: '/pagesA/vipPackage/index' },
  102. { title: '我的分享码', path: '/pagesB/sharePoster/index' },
  103. { title: '新用户邀请记录', path: '/pagesB/inviteRecord/index' },
  104. { title: '门墩儿商城', appId: 'wx6decdf12f9e7a061' },
  105. { title: '我要招聘', key: 'recruit' },
  106. { title: '联系我们', path: '/pagesB/contactUs/index' },
  107. { title: '协议中心', path: '/pagesB/agreement/index', open: true }
  108. ]
  109. const list = ref(defaultList.filter(e => !e.defaultHide))
  110. watch(
  111. () => baseInfo.value,
  112. (newVal) => {
  113. if (newVal) {
  114. list.value = defaultList.map(e => { // 不改变原数组,退出登录需要重置菜单
  115. let hide = e.defaultHide
  116. if (e?.key === 'student' && newVal.type === '1') hide = false // 学生信息管理。 type:0是求职者,1是学生
  117. return hide ? null : e
  118. }).filter(Boolean)
  119. }
  120. },
  121. { immediate: true },
  122. // { deep: true }
  123. )
  124. watch(
  125. () => vip.value,
  126. (newVal) => {
  127. if (newVal) list.value.splice(3, 0, { title: 'vip权益', key: 'vip', path: '/pagesA/vip/index' })
  128. else list.value = list.value.filter(e => !e.key || e.key !== 'vip')
  129. },
  130. { immediate: true },
  131. // { deep: true }
  132. )
  133. onLoad(() => {
  134. wx.showShareMenu({
  135. withShareTicket: true,
  136. menus: ['shareAppMessage', 'shareTimeline']
  137. })
  138. onShareAppMessage(() => {
  139. return {
  140. title: '门墩儿 专注顶尖招聘',
  141. path: '/pages/index/position',
  142. imageUrl: '../../static/img/share-poster.jpg'
  143. }
  144. })
  145. onShareTimeline(() => {
  146. return {
  147. title: '门墩儿 专注顶尖招聘',
  148. path: '/pages/index/position',
  149. imageUrl: '../../static/img/share-poster.jpg'
  150. }
  151. })
  152. })
  153. const openSubscribe = (path) => {
  154. wx.requestSubscribeMessage({
  155. tmplIds: ['2dByiI4wf6D3ZmxDH1QywH264F3N-9ysnvsS7xQm4PE'],
  156. success:(res)=>{
  157. console.log(res, 'uni.requestSubscribeMessage-res')
  158. uni.navigateTo({
  159. url: path
  160. })
  161. },
  162. fail:(err)=>{
  163. console.log('订阅失败', err)
  164. uni.navigateTo({
  165. url: path
  166. })
  167. }
  168. })
  169. }
  170. // 列表跳转
  171. const dialogType = ref('')
  172. const handleToLink = (item) => {
  173. if (item.open && item.path) return uni.navigateTo({ url: item.path })
  174. if (item.appId) {
  175. // uni.navigateToMiniProgram({
  176. // appId: item.appId,
  177. // })
  178. // return
  179. // uni.showToast({
  180. // title: '请前往网页版门墩儿商城',
  181. // icon: 'none'
  182. // })
  183. dialogType.value = 0
  184. inputDialog.value.open()
  185. }
  186. if (item.key === 'recruit') {
  187. dialogType.value = 1
  188. inputDialog.value.open()
  189. }
  190. if (!item.path) return
  191. if (!getAccessToken()) {
  192. uni.showToast({
  193. title: '请先登录',
  194. icon: 'none'
  195. })
  196. showAuthModal()
  197. return
  198. }
  199. if (showNecessaryInfoPopup()) {
  200. uni.showToast({
  201. title: '请先完善基本信息',
  202. icon: 'none'
  203. })
  204. showAuthModal('necessaryInfo')
  205. return
  206. }
  207. if (item.path === 'shareQrCode') {
  208. handleShareCode()
  209. return
  210. }
  211. // 点击在线简历需调起订阅消息
  212. if (item.title === '在线简历'){
  213. openSubscribe(item.path)
  214. return
  215. }
  216. uni.navigateTo({
  217. url: item.path
  218. })
  219. }
  220. const shareUrl = ref()
  221. // 生成分享二维码
  222. const handleShareCode = async () => {
  223. const userId = useUserStore?.accountInfo?.userId || ''
  224. if (!userId) {
  225. uni.showToast({
  226. title: '请先登录',
  227. icon: 'none'
  228. })
  229. showAuthModal()
  230. return
  231. }
  232. if (showNecessaryInfoPopup()) {
  233. uni.showToast({
  234. title: '请先完善基本信息',
  235. icon: 'none'
  236. })
  237. showAuthModal('necessaryInfo')
  238. return
  239. }
  240. const query = {
  241. scene: 'shareId=' + userId,
  242. path: 'pages/login/index',
  243. width: 200,
  244. autoColor: false,
  245. checkPath: true,
  246. hyaline: true
  247. }
  248. const res = await getJobAdvertisedShareQrcode(query)
  249. shareUrl.value = res?.data ? 'data:image/png;base64,' + res.data : ''
  250. shareQrCodePopup.value.open()
  251. }
  252. // 保存到本地
  253. // const handleSaveShareUrl = async () => {
  254. // const fsm = wx.getFileSystemManager()
  255. // const data = shareUrl.value
  256. // if (!data) return
  257. // fsm.writeFile({
  258. // filePath:wx.env.USER_DATA_PATH+'/MySharingCode.png',
  259. // data: data.slice(22),
  260. // encoding:'base64',
  261. // success: res => {
  262. // wx.saveImageToPhotosAlbum({
  263. // filePath: wx.env.USER_DATA_PATH + '/MySharingCode.png',
  264. // success: function (res) {
  265. // wx.showToast({
  266. // title: '保存成功',
  267. // })
  268. // },
  269. // fail: function (err) {
  270. // console.log(err)
  271. // }
  272. // })
  273. // }, fail: err => {
  274. // console.log(err)
  275. // }
  276. // })
  277. // }
  278. // 登录
  279. const handleTap = () => {
  280. if (!useUserStore.isLogin) {
  281. showAuthModal()
  282. return
  283. }
  284. uni.navigateTo({
  285. url: '/pagesA/resumeOnline/index'
  286. })
  287. }
  288. // 退出登录
  289. const handleLogout = () => {
  290. popup.value.open()
  291. }
  292. const handleLogoutClose = () => {
  293. popup.value.close()
  294. }
  295. const handleLogoutConfirm = () => {
  296. list.value = defaultList.filter(e => !e.hide) // 重置菜单
  297. useUserStore.handleLogout()
  298. }
  299. </script>
  300. <style scoped lang="scss">
  301. .pb-150 {
  302. padding-bottom: 100px;
  303. }
  304. .img-box {
  305. position: relative;
  306. display: flex;
  307. justify-content: center;
  308. .img {
  309. width: 150rpx;
  310. height: 150rpx;
  311. border: 2rpx solid #ccc;
  312. border-radius: 50%;
  313. }
  314. }
  315. .vipBox {
  316. color: #a18a0f;
  317. .img {
  318. border: 1px solid gold;
  319. }
  320. .vipIcon {
  321. position: absolute;
  322. width: 45px;
  323. height: 24px;
  324. bottom: 1px;
  325. left: 50%;
  326. }
  327. }
  328. :deep(.uni-list-item) {
  329. height: 120rpx !important;
  330. line-height: 120rpx !important;
  331. }
  332. :deep(.uni-list-item__content-title) {
  333. font-size: 32rpx !important;
  334. font-weight: 500;
  335. }
  336. .colors{
  337. font-size: 24rpx;
  338. color: #606266;
  339. }
  340. .size-16{
  341. color: #3f424f;
  342. font-size: 32rpx;
  343. margin: 13rpx 0 5rpx 0;
  344. }
  345. .itemText {
  346. color: #3f424f;
  347. font-size: 36rpx;
  348. }
  349. .parent{
  350. width: 50%;
  351. border: 1px solid #f4f4f4;
  352. border-radius: 10rpx;
  353. margin: 0 30rpx 20rpx 30rpx;
  354. padding: 20rpx;
  355. }
  356. .parent:first-child{
  357. margin: 0 0 20rpx 30rpx;
  358. }
  359. .shareQrCodePopupContent {
  360. width: 75vw;
  361. padding: 40rpx;
  362. margin-bottom: 20rpx;
  363. text-align: center;
  364. background-color: #fff;
  365. .text {
  366. margin-bottom: 20px;
  367. }
  368. .qrCode {
  369. margin-left: 4px;
  370. }
  371. .saveImg {
  372. text-align: center;
  373. margin-top: 10px;
  374. color: #999;
  375. }
  376. }
  377. </style>