index.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. <template>
  2. <div>
  3. <!-- 顶部广告图 -->
  4. <div v-if="topAdvertise" class="banner" :style="{'background-image': 'url('+topAdvertise+')'}"></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].img : ''
  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. const router = useRouter()
  102. const handleSearch = (val) => {
  103. val = val?.includes('&') ? encodeURIComponent(val) : val
  104. window.open(val ? `/recruit/personal/position?content=${val}` : `/recruit/personal/position`)
  105. }
  106. // const store = useUserStore()
  107. // const simple = ref(localStorage.getItem('simpleCompleteDialogHaveBeenShow'))
  108. // const showSimplePage = ref(false) // 只提示一次
  109. // if (!getToken()) showSimplePage.value = false
  110. // nextTick(() => {
  111. // if (getToken()) {
  112. // showSimplePage.value = simple.value && JSON.parse(simple.value) ? true : false
  113. // }
  114. // })
  115. // const handleInfoClose = () => {
  116. // localStorage.setItem('simpleCompleteDialogHaveBeenShow', false)
  117. // }
  118. // 更新用户基本信息
  119. // const handleUpdateInfo = async () => {
  120. // handleInfoClose()
  121. // await store.getUserBaseInfos(null)
  122. // }
  123. const adImgWidth = ref(document?.documentElement?.clientWidth ?
  124. Math.floor(document.documentElement.clientWidth/2.2) > 500 ?
  125. Math.floor(document.documentElement.clientWidth/2.2) : 500
  126. : 900
  127. )
  128. const adDialog = ref(false)
  129. onMounted(async () => {
  130. await getSystemWebContent()
  131. const lastTime = localStorage.getItem('adDialogTime')
  132. localStorage.setItem('adDialogTime', Date.now())
  133. if (!lastTime || (Date.now() - Number(lastTime) > 300000)) {
  134. // 无数据不弹窗
  135. adDialog.value = dialogAdvertise.value && Object.keys(dialogAdvertise.value).length ? true : false
  136. }
  137. })
  138. </script>
  139. <style lang="scss" scoped>
  140. .stickyBox {
  141. position: sticky;
  142. top: 48px;
  143. z-index: 998;
  144. background-color: var(--default-bgc);
  145. }
  146. .advertiseBox {
  147. position: sticky;
  148. top: 150px;
  149. left: 0;
  150. z-index: 998;
  151. width: 15px;
  152. max-width: 180px;
  153. margin-left: -200px;
  154. }
  155. .advertise {
  156. // position: sticky;
  157. // top: 128px;
  158. // z-index: 999;
  159. height: 372px;
  160. &-box {
  161. position: relative;
  162. // left: 0;
  163. width: 15px;
  164. height: 100%;
  165. background-color: #00897B;
  166. &::after {
  167. content: "";
  168. position: absolute;
  169. top: 50%;
  170. margin-left: 3px;
  171. transform: translateY(-50%);
  172. border-width: 10px; // 12px
  173. border-style: solid;
  174. border-color: transparent transparent transparent orange;
  175. }
  176. }
  177. &-title {
  178. width: 100%;
  179. color: #000;
  180. font-size: 14px;
  181. background-color: #d5d5d5;
  182. border-left: 3px solid #00897B;
  183. padding: 8px 5px 0 16px;
  184. border-radius: 4px 4px 0 0;
  185. }
  186. &-img {
  187. width: 100%;
  188. height: 100%;
  189. border-radius: 0 0 4px 4px;
  190. object-fit: cover;
  191. }
  192. }
  193. // .content-box {
  194. // margin-top: -372px - 372px;
  195. // }
  196. .banner {
  197. width: 100%;
  198. height: 110px;
  199. // background: url("@/assets/headerBg.jpg") no-repeat;
  200. background-position: no-repeat;
  201. background-size: contain;
  202. }
  203. .common-width {
  204. width: 1160px;
  205. max-width: 1160px;
  206. min-width: 1160px;
  207. margin: 0 auto;
  208. }
  209. </style>