my.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. <template>
  2. <view>
  3. <Navbar title="我的" />
  4. <layout-page>
  5. <view :style="{'padding-top': navbarHeight + 'px'}">
  6. <view class="commonBackground"></view>
  7. <view class="defaultBgc" style="padding-bottom: 100px;">
  8. <view class="ss-p-x-30 d-flex justify-space-between align-center" @tap="handleTap">
  9. <view class="img-box" :class="vip ? 'vipBox' : ''">
  10. <img :src="getUserAvatar(baseInfo?.avatar, baseInfo?.sex)" alt="" class="img default-border">
  11. <image v-if="vip" src="/static/svg/vip.svg" class="vipIcon" @click.stop="handleToLink({path: '/pagesA/vip/index'})"></image>
  12. </view>
  13. <view style="z-index: 1 !important;">
  14. <view v-if="!useUserStore.isLogin" class="">
  15. <view class="MiSans-Medium default-text-color font-size-28rpx">点击登录/注册</view>
  16. <view class="MiSans-Normal color-666 ss-m-t-10" style="font-size: 24rpx;">Hi 欢迎登录门墩儿</view>
  17. </view>
  18. <view v-else class="MiSans-Medium font-size-20 default-text-color">{{ baseInfo?.name || userInfo?.phone }}</view>
  19. </view>
  20. </view>
  21. <resume-status />
  22. <view class="d-flex" style="margin: 30rpx; border-radius: 20rpx;">
  23. <view v-for="(item, index) in itemList" :key="index" @tap="handleToLink(item)" class="parent">
  24. <view class="d-flex align-center">
  25. <image :src="item.src" mode="" style="width: 70rpx; height: 60rpx;"></image>
  26. <text class="ss-m-l-30 default-text-color">{{ item.title }}</text>
  27. </view>
  28. </view>
  29. </view>
  30. <view class="list-card">
  31. <uni-list>
  32. <uni-list-item
  33. v-for="item in list"
  34. :clickable="true"
  35. :key="item.title"
  36. :title="item.title"
  37. showArrow
  38. :thumb="item.src"
  39. thumb-size="sm"
  40. :rightText="item.rightTex || ''"
  41. @click="handleToLink(item)"
  42. >
  43. </uni-list-item>
  44. </uni-list>
  45. </view>
  46. <button v-if="useUserStore.isLogin" class="send-button" style="margin-bottom: 100px;" @tap="handleLogout">退出登录</button>
  47. <uni-popup ref="popup" type="dialog">
  48. <uni-popup-dialog type="warn" cancelText="取消" confirmText="确定" title="系统提示" content="确认退出账号?" @confirm="handleLogoutConfirm"
  49. @close="handleLogoutClose"></uni-popup-dialog>
  50. </uni-popup>
  51. <uni-popup ref="inputDialog" type="dialog">
  52. <view class="shareQrCodePopupContent">
  53. <view class="ss-m-b-10 MiSans-Normal">请前往网页版{{ dialogType ? '门墩儿招聘' : '门墩儿商城' }}</view>
  54. <uni-link class="MiSans-Normal" :href="dialogType ? 'https://www.menduner.com' : 'https://www.menduner.com/mall'" text="点击复制网页地址" color="#00B760" fontSize="16" copyTips="已复制,请在电脑端打开"></uni-link>
  55. </view>
  56. </uni-popup>
  57. </view>
  58. </view>
  59. </layout-page>
  60. </view>
  61. </template>
  62. <script setup>
  63. import { ref, computed, watch } from 'vue'
  64. import ResumeStatus from '@/components/ResumeStatus'
  65. import { userStore } from '@/store/user'
  66. import { getUserAvatar } from '@/utils/avatar'
  67. import { getAccessToken, showNecessaryInfoPopup } from '@/utils/request'
  68. import layoutPage from '@/layout'
  69. import { showAuthModal } from '@/hooks/useModal'
  70. import { onShow, onLoad, onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app'
  71. import Navbar from '@/components/Navbar'
  72. const navbarHeight = ref(uni.getStorageSync('navbarHeight'))
  73. // 设置自定义tabbar选中值
  74. onShow(() => {
  75. const currentPage = getCurrentPages()[0]; // 获取当前页面实例
  76. const currentTabBar = currentPage?.getTabBar?.();
  77. // 设置当前tab页的下标index
  78. currentTabBar?.setData({ selected: 4 });
  79. })
  80. const inputDialog = ref()
  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 itemList = [
  87. { title: "我的关注", path: "/pagesA/collect/index", src: "https://minio.menduner.com/dev/0490f8bd7d4894d6eb3001ba6a6c9080bbc3623113bf0050342466cdb44ccec6.png" },
  88. { title:'关注我的', path:'/pagesA/seenMe/index', src:'https://minio.menduner.com/dev/f6079be237dd39aa0929db31b7b35835e109b448ba0e1f278df64fa9391e6634.png' }
  89. ]
  90. const defaultList = [
  91. { title: '在线简历', path: '/pagesA/resumeOnline/index', src: 'https://minio.menduner.com/dev/ec05228053a844dfa89d3bcb3750aaf2571bff4c8e04a5de6dbee2e68200e792.png' },
  92. { title: '附件简历', path: '/pagesA/resume/index', src: 'https://minio.menduner.com/dev/d2687a2081847b092fc839880dd12fd7f374c58afeb07d567ae7cdfe8d68ce54.png' },
  93. { title: '学生专区', path: '/pagesA/student/index', key: 'student', defaultHide: true, src: 'https://minio.menduner.com/dev/ec05228053a844dfa89d3bcb3750aaf2571bff4c8e04a5de6dbee2e68200e792.png' },
  94. { title: '面试管理', path: '/pagesA/interview/index', src: 'https://minio.menduner.com/dev/747122b480d8358096e5848d0039cce0c8b8cf2a52f0409d073cc733cf4c0224.png' },
  95. { title: '会员套餐', path: '/pagesA/vipPackage/index', src: 'https://minio.menduner.com/dev/4e9f86f6a48b78c1aca7a6a6b3c5971044275a7f890f73d7c3b981f125378a0f.png' },
  96. { title: '我的分享码', path: '/pagesB/sharePoster/index', src: 'https://minio.menduner.com/dev/32e78eca5e003bb0136d874a973b582581eb4f9d3c746fb11ed3cc7f41a9b0e9.png' },
  97. { title: '新用户邀请记录', path: '/pagesB/inviteRecord/index', src: 'https://minio.menduner.com/dev/53c36e2fb4cb3b7852bcb9ce7584d9f4c1daaed034a065c33fdb4acd2f4b89b8.png' },
  98. { title: '门墩儿商城', appId: 'wx6decdf12f9e7a061', src: 'https://minio.menduner.com/dev/1f83900522317f36618b4b8314c2b6263c30d43ff1c0e8738903f85996f165d3.png' },
  99. { title: '我要招聘', key: 'recruit', src:'https://minio.menduner.com/dev/c8e7d358858eaf9bfe197473751d04d1bc79598b9ce6ecf882ec61c79b0d3bae.png' },
  100. { title: '联系我们', path: '/pagesB/contactUs/index', src: 'https://minio.menduner.com/dev/747122b480d8358096e5848d0039cce0c8b8cf2a52f0409d073cc733cf4c0224.png' },
  101. { title: '协议中心', path: '/pagesB/agreement/index', open: true, src: 'https://minio.menduner.com/dev/58cc8847965aaa4e80064732a2024b690ff2285aa57cc4d133846a1e06a23478.png' }
  102. ]
  103. const list = ref(defaultList.filter(e => !e.defaultHide))
  104. watch(
  105. () => baseInfo.value,
  106. (newVal) => {
  107. if (newVal) {
  108. list.value = defaultList.map(e => { // 不改变原数组,退出登录需要重置菜单
  109. let hide = e.defaultHide
  110. if (e?.key === 'student' && newVal.type === '1') hide = false // 学生信息管理。 type:0是求职者,1是学生
  111. return hide ? null : e
  112. }).filter(Boolean)
  113. }
  114. },
  115. { immediate: true },
  116. // { deep: true }
  117. )
  118. watch(
  119. () => vip.value,
  120. (newVal) => {
  121. if (newVal) list.value.splice(3, 0, { title: 'vip权益', key: 'vip', path: '/pagesA/vip/index' })
  122. else list.value = list.value.filter(e => !e.key || e.key !== 'vip')
  123. },
  124. { immediate: true },
  125. // { deep: true }
  126. )
  127. onLoad(() => {
  128. wx.showShareMenu({
  129. withShareTicket: true,
  130. menus: ['shareAppMessage', 'shareTimeline']
  131. })
  132. onShareAppMessage(() => {
  133. return {
  134. title: '门墩儿 专注顶尖招聘',
  135. path: '/pages/index/position',
  136. imageUrl: '../../static/img/share-poster.jpg'
  137. }
  138. })
  139. onShareTimeline(() => {
  140. return {
  141. title: '门墩儿 专注顶尖招聘',
  142. path: '/pages/index/position',
  143. imageUrl: '../../static/img/share-poster.jpg'
  144. }
  145. })
  146. })
  147. const openSubscribe = (path) => {
  148. wx.requestSubscribeMessage({
  149. tmplIds: ['2dByiI4wf6D3ZmxDH1QywH264F3N-9ysnvsS7xQm4PE'],
  150. success:(res)=>{
  151. console.log(res, 'uni.requestSubscribeMessage-res')
  152. uni.navigateTo({
  153. url: path
  154. })
  155. },
  156. fail:(err)=>{
  157. console.log('订阅失败', err)
  158. uni.navigateTo({
  159. url: path
  160. })
  161. }
  162. })
  163. }
  164. // 列表跳转
  165. const dialogType = ref('')
  166. const handleToLink = (item) => {
  167. if (item.open && item.path) return uni.navigateTo({ url: item.path })
  168. if (item.appId) {
  169. // uni.navigateToMiniProgram({
  170. // appId: item.appId,
  171. // })
  172. // return
  173. // uni.showToast({
  174. // title: '请前往网页版门墩儿商城',
  175. // icon: 'none'
  176. // })
  177. dialogType.value = 0
  178. inputDialog.value.open()
  179. }
  180. if (item.key === 'recruit') {
  181. dialogType.value = 1
  182. inputDialog.value.open()
  183. }
  184. if (!item.path) return
  185. if (!getAccessToken()) {
  186. uni.showToast({
  187. title: '请先登录',
  188. icon: 'none'
  189. })
  190. showAuthModal()
  191. return
  192. }
  193. if (showNecessaryInfoPopup()) {
  194. uni.showToast({
  195. title: '请先完善基本信息',
  196. icon: 'none'
  197. })
  198. showAuthModal('necessaryInfo')
  199. return
  200. }
  201. // 点击在线简历需调起订阅消息
  202. if (item.title === '在线简历'){
  203. openSubscribe(item.path)
  204. return
  205. }
  206. uni.navigateTo({
  207. url: item.path
  208. })
  209. }
  210. // 登录
  211. const handleTap = () => {
  212. if (!useUserStore.isLogin) {
  213. showAuthModal()
  214. return
  215. }
  216. uni.navigateTo({
  217. url: '/pagesA/resumeOnline/index'
  218. })
  219. }
  220. // 退出登录
  221. const handleLogout = () => {
  222. popup.value.open()
  223. }
  224. const handleLogoutClose = () => {
  225. popup.value.close()
  226. }
  227. const handleLogoutConfirm = () => {
  228. list.value = defaultList.filter(e => !e.hide) // 重置菜单
  229. useUserStore.handleLogout()
  230. }
  231. </script>
  232. <style scoped lang="scss">
  233. .font-size-28rpx {
  234. font-size: 28rpx;
  235. }
  236. .list-card {
  237. background-color: #fff;
  238. border-radius: 20rpx;
  239. margin: 30rpx;
  240. overflow: hidden;
  241. }
  242. .img-box {
  243. position: relative;
  244. display: flex;
  245. justify-content: center;
  246. .img {
  247. width: 100rpx;
  248. height: 100rpx;
  249. border-radius: 50%;
  250. }
  251. }
  252. .vipBox {
  253. color: #a18a0f;
  254. .img {
  255. border: 1px solid gold;
  256. }
  257. .vipIcon {
  258. position: absolute;
  259. width: 45px;
  260. height: 24px;
  261. bottom: 1px;
  262. left: 50%;
  263. }
  264. }
  265. :deep(.uni-list-item) {
  266. height: 120rpx !important;
  267. line-height: 120rpx !important;
  268. &:first-child {
  269. border-radius: 20rpx 20rpx 0 0;
  270. }
  271. &:last-child {
  272. border-radius: 0 0 20rpx 20rpx;
  273. }
  274. }
  275. :deep(.uni-list-item__content-title) {
  276. font-size: 28rpx !important;
  277. font-family: MiSans-Medium;
  278. }
  279. :deep(.uniui-arrowright) {
  280. color: #0E100F !important;
  281. }
  282. .parent{
  283. width: 50%;
  284. border-radius: 20rpx;
  285. background-color: #fff;
  286. padding: 30rpx;
  287. z-index: 1;
  288. }
  289. .parent:first-child{
  290. margin-right: 20rpx;
  291. }
  292. .shareQrCodePopupContent {
  293. width: 75vw;
  294. padding: 40rpx;
  295. margin-bottom: 20rpx;
  296. text-align: center;
  297. background-color: #fff;
  298. border-radius: 20rpx;
  299. .text {
  300. margin-bottom: 20px;
  301. }
  302. .qrCode {
  303. margin-left: 4px;
  304. }
  305. .saveImg {
  306. text-align: center;
  307. margin-top: 10px;
  308. color: #999;
  309. }
  310. }
  311. </style>