index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. <!-- 分享职位 -->
  2. <template>
  3. <div style="background-color: #f0f0f0;" :style="{'padding': isMobile ? '0' : '10px'}">
  4. <v-card
  5. class="py-3 px-5"
  6. style="min-height: calc(100vh - 20px); box-sizing: border-box; margin: 0 auto;"
  7. :style="{'width': isMobile ? '100%' : '750px'}"
  8. >
  9. <div v-if="!Object.keys(info).length">加载失败</div>
  10. <div v-else>
  11. <div class="d-flex justify-space-between">
  12. <h2 class="JobName ellipsis">{{ info.name }}</h2>
  13. <span v-if="!info.payFrom && !info.payTo" class="salary">面议</span>
  14. <span v-else class="salary">{{ info.payFrom ? info.payFrom + '-' : '' }}{{ info.payTo }}{{ positionInfo.payName ? '/' + positionInfo.payName : '' }}</span>
  15. </div>
  16. <div class="d-flex justify-space-between mt-4">
  17. <div class="banner-tags">
  18. <div v-for="k in desc" :key="k.mdi" class="mr-3">
  19. <v-icon color="var(--color-666)" size="20">{{ k.mdi }}</v-icon>
  20. <span class="f-w-600 ml-1">{{ positionInfo[k.value] }}</span>
  21. </div>
  22. </div>
  23. <div class="mt-4" v-if="info?.tagList">
  24. <v-chip size="small" class="mr-1 mb-1" color="primary" label v-for="(k, i) in info.tagList" :key="i">{{ k }}</v-chip>
  25. </div>
  26. </div>
  27. <div class="text-end d-flex align-center justify-space-between mt-3">
  28. <v-btn
  29. class="button-item radius"
  30. color="warning"
  31. variant="outlined"
  32. :prepend-icon="isCollection ? 'mdi-heart' : 'mdi-heart-outline'"
  33. @click="handleCollection"
  34. >{{ isCollection ? $t('position.cancelFavorite') : $t('position.collection') }}</v-btn>
  35. <svg-icon v-if="info.hire" name="pin" size="50"></svg-icon>
  36. </div>
  37. <div v-if="info.hire" class="mt-3">
  38. <v-chip v-if="info.hirePrice" label color="primary">赏金:{{ commissionCalculation(info.hirePrice, 1) }}元</v-chip>
  39. <v-chip v-if="info.hirePoint" label color="primary">积分:{{ commissionCalculation(info.hirePoint, 1) }}点</v-chip>
  40. </div>
  41. <v-divider class="mt-3"></v-divider>
  42. <div class="mt-3 mb-1 f-w-600">{{ $t('position.jobResponsibilities') }}</div>
  43. <div v-if="info.content" class="requirement" v-html="info.content?.replace(/\n/g, '</br>')"></div>
  44. <div v-else>暂无</div>
  45. <div class="mt-3 mb-1 f-w-600">{{ $t('position.jobRequirements') }}</div>
  46. <div v-if="info.requirement" class="requirement" v-html="info.requirement?.replace(/\n/g, '</br>')"></div>
  47. <div v-else>暂无</div>
  48. <v-divider class="my-3"></v-divider>
  49. <div class="contact">
  50. <div class="float-left d-flex align-center">
  51. <v-img :src="info.contact?.avatar || 'https://minio.citupro.com/dev/menduner/7.png'" :width="45" style="height: 45px;"></v-img>
  52. <div class="ml-2">
  53. <div class="contact-name">{{ info.contact?.name }}</div>
  54. <div class="contact-info">{{ info.enterprise?.name }} · {{ info.contact?.postNameCn }}</div>
  55. </div>
  56. </div>
  57. </div>
  58. <v-divider class="my-3"></v-divider>
  59. <div>
  60. <h4>{{ $t('position.address') }}</h4>
  61. <div class="mt-1">
  62. <v-icon size="25" color="primary">mdi-map-marker</v-icon>
  63. <span style="color: var(--color-666);font-size: 15px;">{{ info.address }}</span>
  64. </div>
  65. </div>
  66. <div class="text-center my-10">
  67. <v-btn v-if="!isMobile" class="mr-2 radius button-item" color="success" variant="outlined" target="_blank" to="/recruit/personal/position">{{ $t('position.moreBtn') }}</v-btn>
  68. <v-btn class="radius button-item" color="primary" :disabled="delivery" @click="sendResumeProcessVerify">{{ delivery ? $t('position.delivered') : $t('position.submitResume') }}</v-btn>
  69. <span v-if="showSwitchAccount" class="ml-2 cursor-pointer" style="font-size: 14px; color: #666; text-decoration: underline;" @click="handleSwitchAccount">切换账号</span>
  70. </div>
  71. </div>
  72. </v-card>
  73. <!-- 快速登录/注册 -->
  74. <loginPage
  75. v-if="sendResume.showLogin"
  76. :jobId="jobId"
  77. :hasLogout="hasLogout"
  78. @loginSuccess="loginSuccess"
  79. @close="handleClose('showLogin')"
  80. ></loginPage>
  81. <!-- 快速填写简易人才信息 -->
  82. <simplePage
  83. v-if="sendResume.showSimpleInfo"
  84. @simpleInfoReady="simpleInfoReadyFun"
  85. @close="handleClose('showSimpleInfo')"
  86. ></simplePage>
  87. <!-- 选择简历 -->
  88. <selectPage
  89. v-if="sendResume.showSelect"
  90. :hire="info?.hire"
  91. :jobId="jobId"
  92. :userId="sharedById"
  93. @refresh="handleCheckJobDelivery"
  94. @close="handleClose('showSelect')"
  95. ref="selectRef"
  96. ></selectPage>
  97. </div>
  98. </template>
  99. <script setup>
  100. import { commissionCalculation } from '@/utils/position'
  101. defineOptions({name: 'recruit-personal-shareJob-index'})
  102. import loginPage from '@/views/common/loginDialog.vue'
  103. import simplePage from './sendResume/simple.vue'
  104. import selectPage from './sendResume/select.vue'
  105. import { onMounted, reactive, ref } from 'vue';
  106. import { getPositionDetails, jobCvRelCheckSend, getPersonJobUnfavorite, getPersonJobFavorite, getJobFavoriteCheck } from '@/api/position'
  107. import { dealDictObjData } from '@/utils/position'
  108. import { getToken } from '@/utils/auth'
  109. import Snackbar from '@/plugins/snackbar'
  110. import { useI18n } from '@/hooks/web/useI18n'; const { t } = useI18n()
  111. // 组件挂载后添加事件监听器
  112. const isMobile = ref(false)
  113. onMounted(() => {
  114. const userAgent = navigator.userAgent
  115. isMobile.value = /(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i.test(userAgent)
  116. })
  117. // 获取路由参数
  118. const queryParams = new URLSearchParams(window.location.search)
  119. const jobId = queryParams.get('jobId') || ''
  120. const sharedById = queryParams.get('sharedById') || ''
  121. // 职位详情
  122. const info = ref({})
  123. const positionInfo = ref({})
  124. const getPositionDetail = async () => {
  125. const data = await getPositionDetails({ id: jobId })
  126. info.value = data
  127. positionInfo.value = { ...dealDictObjData({}, info.value), ...info.value }
  128. }
  129. // 效验是否已投递
  130. const delivery = ref(false)
  131. const handleCheckJobDelivery = async () => {
  132. delivery.value = await jobCvRelCheckSend({ jobId })
  133. return delivery.value
  134. }
  135. // 效验求职者是否有收藏该职位
  136. const actions = ref(false)
  137. const isCollection = ref(false)
  138. const getCollectionStatus = async () => {
  139. if (!jobId) return
  140. const data = await getJobFavoriteCheck({ jobId })
  141. isCollection.value = data
  142. }
  143. // 收藏&取消收藏职位
  144. const handleCollection = async () => {
  145. // 效验登录状态
  146. if (!getToken()) {
  147. actions.value = true
  148. sendResume.showLogin = true
  149. return
  150. }
  151. if (!jobId) return
  152. const api = isCollection.value ? getPersonJobUnfavorite : getPersonJobFavorite
  153. await api(isCollection.value ? jobId : { jobId })
  154. await getCollectionStatus()
  155. }
  156. // 判断有没有jobId跟sharedById,没有的话关闭当前窗口
  157. if (!jobId) { // !sharedById
  158. Snackbar.warning('当前打开的链接无效')
  159. setTimeout(() => {
  160. window.close()
  161. }, 2000)
  162. } else {
  163. getPositionDetail()
  164. if (getToken()) {
  165. handleCheckJobDelivery()
  166. getCollectionStatus()
  167. }
  168. }
  169. const desc = [
  170. { mdi: 'mdi-map-marker-outline', value: 'areaName' },
  171. { mdi: 'mdi-school-outline', value: 'eduName' },
  172. { mdi: 'mdi-clock-time-ten-outline', value: 'expName' }
  173. ]
  174. // 快速登录成功
  175. const loginSuccess = async () => {
  176. simpleInfoReady.value = false
  177. sendResume.showLogin = false // 关闭快速登录弹窗
  178. showSwitchAccountFun(true)
  179. // actions为true则是收藏时的登录,不需要弹窗选择简历
  180. if (actions.value) {
  181. actions.value = false
  182. Snackbar.success('登录成功')
  183. await handleCollection()
  184. return
  185. }
  186. const bool = await handleCheckJobDelivery()
  187. if (bool) return Snackbar.warning(t('resume.alreadyResume'))
  188. sendResumeProcessVerify()
  189. }
  190. // 简易人才信息
  191. const simpleInfoReady = ref(false)
  192. const simpleInfoReadyFun = () => {
  193. sendResume.showSimpleInfo = false
  194. simpleInfoReady.value = true
  195. sendResumeProcessVerify()
  196. }
  197. const sendResume = reactive({
  198. showLogin: false,
  199. showSimpleInfo: false,
  200. showSelect: false,
  201. })
  202. // 流程校准
  203. const sendResumeProcessVerify = async () => {
  204. try { // 1.登录 2.具备人才信息 3.有无附件简历,无则上传
  205. // 未登录
  206. if (!getToken()) {
  207. sendResume.showLogin = true
  208. return
  209. }
  210. // 已登录
  211. // * 必填人才信息不完全 -> 不符合快速投递,进入完善人才信息流程
  212. if (!simpleInfoReady.value) {
  213. sendResume.showSimpleInfo = true
  214. return
  215. }
  216. // * 简历列表
  217. sendResume.showSelect = hasLogout.value ? false : true
  218. hasLogout.value = false
  219. } catch (error) {
  220. console.error('error', error)
  221. }
  222. }
  223. const handleClose = (key) => {
  224. sendResume[key] = false // 弹窗关闭,重置绑定数据
  225. hasLogout.value = false
  226. }
  227. const showSwitchAccount = ref(false)
  228. const showSwitchAccountFun = (bool) => {
  229. showSwitchAccount.value = bool
  230. }
  231. onMounted(() => {
  232. showSwitchAccountFun(getToken()) // (isMobile.value && getToken())
  233. })
  234. // 切换账号
  235. const hasLogout = ref(false)
  236. const handleSwitchAccount = async () => {
  237. hasLogout.value = true
  238. sendResume.showLogin = true
  239. }
  240. </script>
  241. <style lang="scss" scoped>
  242. .f-w-600 { font-weight: 600; }
  243. .radius { border-radius: 8px; }
  244. .salary {
  245. color: var(--v-error-base);
  246. line-height: 41px;
  247. font-weight: 600;
  248. height: auto;
  249. display: inline-block;
  250. vertical-align: sub;
  251. }
  252. .JobName {
  253. color: #37576c;
  254. font-size: 28px;
  255. margin-right: 30px;
  256. margin-top: 1px;
  257. // max-width: 45%;
  258. vertical-align: middle;
  259. flex: 1;
  260. }
  261. .banner-tags { display: flex; flex-wrap: wrap; }
  262. .requirement {
  263. white-space: pre-wrap;
  264. word-break: break-all;
  265. line-height: 28px;
  266. color: var(--color-333);
  267. font-size: 15px;
  268. text-align: justify;
  269. letter-spacing: 0;
  270. }
  271. .contact {
  272. height: 60px;
  273. line-height: 60px;
  274. padding: 0 10px;
  275. }
  276. .contact-name {
  277. font-size: 20px;
  278. font-weight: 500;
  279. color: var(--color-222);
  280. line-height: 28px;
  281. }
  282. .contact-info {
  283. font-size: 15px;
  284. color: var(--color-666);
  285. line-height: 21px;
  286. margin-top: 8px;
  287. }
  288. .button-item {
  289. min-width: 110px;
  290. height: 36px
  291. }
  292. </style>