index.vue 6.6 KB

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