index.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. <template>
  2. <div>
  3. <!-- 顶部广告图 -->
  4. <div v-if="topAdvertise?.img" class="banner" :style="{'background-image': 'url('+topAdvertise?.img+')'}" :class="{'cursor-pointer': topAdvertise?.link}" @click="handleAdvertise"></div>
  5. <div class="stickyBox py-5">
  6. <headSearch @handleSearch="handleSearch"></headSearch>
  7. </div>
  8. <hotJobs></hotJobs>
  9. <div v-if="leftAdvertise.length" class="advertiseBox">
  10. <div v-for="val in leftAdvertise" :key="val.mark" class="advertise" :style="{'width': '20px'}">
  11. <div v-if="!val.show" class=" advertise-box cursor-pointer" @mouseenter="val.show = true"></div>
  12. </div>
  13. </div>
  14. <div class="default-width mb-5" :style="`margin-top: ${leftAdvertise.length * (-372)}px;`">
  15. <div v-if="leftAdvertise.length" class="advertiseBox">
  16. <div v-for="val in leftAdvertise" :key="val.mark" class="advertise" :style="{'width':'180px'}">
  17. <div v-if="val.show">
  18. <div class="advertise-title d-inline-block">
  19. <span>广告</span>
  20. <v-icon class="float-right cursor-pointer pb-1" color="primary" size="28" @click="val.show = false">mdi-close</v-icon>
  21. </div>
  22. <img class="advertise-img cursor-pointer" :src="val.img" @click.stop="handleLeftClick(val)">
  23. </div>
  24. </div>
  25. </div>
  26. <div :style="`margin-top: ${leftAdvertise.length * (-372)}px;`">
  27. <homeJobTypeCard></homeJobTypeCard>
  28. <advertisementPage v-if="preferred.length" :list="preferred" :content="preferredContent" class="my-3"></advertisementPage>
  29. <hotPromotedPositions :class="!preferred.length ? 'mt-10' : ''"></hotPromotedPositions>
  30. <PopularEnterprises class="mt-10"></PopularEnterprises>
  31. </div>
  32. </div>
  33. </div>
  34. <!-- 快速填写简易人才信息-弹窗 -->
  35. <!-- <simplePage v-if="showSimplePage" :closeable="true" closeText="暂时跳过" @close="handleInfoClose" @simpleInfoReady="handleUpdateInfo"></simplePage> -->
  36. <!-- 广告弹窗 -->
  37. <v-dialog
  38. v-model="adDialog"
  39. max-width="900"
  40. :persistent="false"
  41. >
  42. <div style="cursor: pointer; margin: 0 auto; position: relative;">
  43. <v-img :src="dialogAdvertise.img" :width="adImgWidth" style="height: auto;border-radius: 4px;" @click="adClick"></v-img>
  44. <span style="color: #ddddddcc; font-size: 32px; position: absolute; right: 0px; top: 0px;" class="mdi mdi-close-circle-outline cursor-pointer px-3" @click="adDialog = false"></span>
  45. </div>
  46. </v-dialog>
  47. </template>
  48. <script setup>
  49. defineOptions({ name:'personal-index'})
  50. // import simplePage from './components/simple.vue'
  51. import headSearch from '@/components/headSearch'
  52. import hotJobs from './components/hotJobs.vue'
  53. import homeJobTypeCard from './components/homeJobTypeCard'
  54. import hotPromotedPositions from './components/hotPromotedPositions.vue'
  55. import PopularEnterprises from './components/popularEnterprises.vue'
  56. import advertisementPage from './components/advertisement/index.vue'
  57. import { useRouter } from 'vue-router'
  58. import { onMounted, ref } from 'vue'
  59. // import { useUserStore } from '@/store/user'
  60. import { getToken } from '@/utils/auth'
  61. import { getWebContent } from '@/api/common'
  62. import { getRewardEventList } from '@/utils/eventList'
  63. if (!getToken()) getRewardEventList()
  64. // 获取广告图
  65. const topAdvertise = ref({})
  66. const leftAdvertise = ref([])
  67. const dialogAdvertise = ref({})
  68. const preferred = ref([])
  69. const preferredContent = ref({})
  70. const getSystemWebContent = async () => {
  71. const data = await getWebContent()
  72. // 优选集团
  73. preferred.value = data.pcHomePreferred ? data.pcHomePreferred.sort((a, b) => {
  74. const sortA = a.sort || Infinity
  75. const sortB = b.sort || Infinity
  76. return sortA - sortB
  77. }) : []
  78. preferredContent.value = data.appPreferredGroup
  79. // 顶部广告
  80. topAdvertise.value = data.pcTop && data.pcTop.length ? data.pcTop[0] : {}
  81. // 弹窗广告
  82. dialogAdvertise.value = data.pcAdvertisement ? data.pcAdvertisement[0] : {}
  83. // 左侧广告
  84. if (data.pcLeft) leftAdvertise.value = data.pcLeft.map(e => {
  85. e.show = true
  86. return e
  87. })
  88. }
  89. // 弹窗广告跳转
  90. const adClick = () => {
  91. if (!getToken()) router.push(dialogAdvertise.value.link)
  92. }
  93. // 左侧广告跳转
  94. const handleLeftClick = (val) => {
  95. if (val.link === '/recruit/enterprise/position/add') {
  96. const url = getToken(1) ? val.link : '/login?entLogin=true'
  97. if (!getToken(1)) localStorage.setItem('enterpriseRedirect', '/recruit/enterprise/position/add')
  98. window.open(url)
  99. } else window.open(val.link)
  100. }
  101. // 顶部banner跳转
  102. const handleAdvertise = () => {
  103. if (!topAdvertise.value?.link) return
  104. window.open(topAdvertise.value.link)
  105. }
  106. const router = useRouter()
  107. const handleSearch = (val) => {
  108. val = val?.includes('&') ? encodeURIComponent(val) : val
  109. window.open(val ? `/recruit/personal/position?content=${val}` : `/recruit/personal/position`)
  110. }
  111. // const store = useUserStore()
  112. // const simple = ref(localStorage.getItem('simpleCompleteDialogHaveBeenShow'))
  113. // const showSimplePage = ref(false) // 只提示一次
  114. // if (!getToken()) showSimplePage.value = false
  115. // nextTick(() => {
  116. // if (getToken()) {
  117. // showSimplePage.value = simple.value && JSON.parse(simple.value) ? true : false
  118. // }
  119. // })
  120. // const handleInfoClose = () => {
  121. // localStorage.setItem('simpleCompleteDialogHaveBeenShow', false)
  122. // }
  123. // 更新用户基本信息
  124. // const handleUpdateInfo = async () => {
  125. // handleInfoClose()
  126. // await store.getUserBaseInfos(null)
  127. // }
  128. const adImgWidth = ref(document?.documentElement?.clientWidth ?
  129. Math.floor(document.documentElement.clientWidth/2.2) > 500 ?
  130. Math.floor(document.documentElement.clientWidth/2.2) : 500
  131. : 900
  132. )
  133. const adDialog = ref(false)
  134. onMounted(async () => {
  135. await getSystemWebContent()
  136. const lastTime = localStorage.getItem('adDialogTime')
  137. localStorage.setItem('adDialogTime', Date.now())
  138. if (!lastTime || (Date.now() - Number(lastTime) > 300000)) {
  139. // 无数据不弹窗
  140. adDialog.value = dialogAdvertise.value && Object.keys(dialogAdvertise.value).length ? true : false
  141. }
  142. })
  143. </script>
  144. <style lang="scss" scoped>
  145. .stickyBox {
  146. position: sticky;
  147. top: 48px;
  148. z-index: 998;
  149. background-color: var(--default-bgc);
  150. }
  151. .advertiseBox {
  152. position: sticky;
  153. top: 150px;
  154. left: 0;
  155. z-index: 998;
  156. width: 15px;
  157. max-width: 180px;
  158. margin-left: -200px;
  159. }
  160. .advertise {
  161. // position: sticky;
  162. // top: 128px;
  163. // z-index: 999;
  164. height: 372px;
  165. &-box {
  166. position: relative;
  167. // left: 0;
  168. width: 15px;
  169. height: 100%;
  170. background-color: #00897B;
  171. &::after {
  172. content: "";
  173. position: absolute;
  174. top: 50%;
  175. margin-left: 3px;
  176. transform: translateY(-50%);
  177. border-width: 10px; // 12px
  178. border-style: solid;
  179. border-color: transparent transparent transparent orange;
  180. }
  181. }
  182. &-title {
  183. width: 100%;
  184. color: #000;
  185. font-size: 14px;
  186. background-color: #d5d5d5;
  187. border-left: 3px solid #00897B;
  188. padding: 8px 5px 0 16px;
  189. border-radius: 4px 4px 0 0;
  190. }
  191. &-img {
  192. width: 100%;
  193. height: 100%;
  194. border-radius: 0 0 4px 4px;
  195. object-fit: cover;
  196. }
  197. }
  198. // .content-box {
  199. // margin-top: -372px - 372px;
  200. // }
  201. .banner {
  202. width: 100%;
  203. height: 110px;
  204. // background: url("@/assets/headerBg.jpg") no-repeat;
  205. background-position: no-repeat;
  206. background-size: contain;
  207. }
  208. .common-width {
  209. width: 1160px;
  210. max-width: 1160px;
  211. min-width: 1160px;
  212. margin: 0 auto;
  213. }
  214. </style>