index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410
  1. <template>
  2. <layout-page>
  3. <scroll-view class="scrollBox" style="position:relative;">
  4. <view class="box">
  5. <view v-if="loading" class="vertical80-center">{{ loadingText }}</view>
  6. <view v-else>
  7. <!-- 职位名称 + 薪资 -->
  8. <view class="d-flex justify-space-between">
  9. <h2 class="JobName ellipsis">
  10. {{ info.name }}
  11. </h2>
  12. <span class="salary w-600">{{ info.payFrom }}-{{ info.payTo }}/{{ positionInfo.payName }}</span>
  13. </view>
  14. <!-- 职位地区 收藏职位 -->
  15. <view class="d-flex justify-space-between mt-5">
  16. <view class="bold" style="font-size: 14px;">
  17. <span>
  18. <span>{{positionInfo?.areaName }}</span>
  19. <span class="viewider-mx">|</span>
  20. <span>{{positionInfo?.eduName }}</span>
  21. <span class="viewider-mx">|</span>
  22. <span>{{positionInfo?.expName }}</span>
  23. </span>
  24. </view>
  25. <!-- 收藏职位 -->
  26. <view @click="handleCollection">
  27. <uni-icons
  28. :type="isCollection ? 'heart-filled' : 'heart'"
  29. color="#fc6d5e"
  30. class="mr"
  31. size="25"
  32. ></uni-icons>
  33. </view>
  34. </view>
  35. <!-- 标签 -->
  36. <view class="tagList mt">
  37. <view class="tag" v-for="(tag,i) in info?.tagList || []" :key="'tagList' + i">
  38. {{ tag }}
  39. </view>
  40. </view>
  41. <!-- 赏金 -->
  42. <view v-if="info.hire" class="topLine mt-5" style="display: flex; align-items: center;">
  43. <view class="iconfont icon-a-1_zhaopin" style="color: #e03506; font-size: 30px;"></view>
  44. <view class="hirePrice">{{ `赏金:${commissionCalculation(info.hirePrice, 1)}元` }}</view>
  45. </view>
  46. <!-- 岗位职责 -->
  47. <view class="topLine fs14 mt-5">
  48. <view class="fs15 w-600 my5">岗位职责</view>
  49. <view v-if="!info.content">暂无</view>
  50. <rich-text v-else class="htmlCss" :nodes="info.content"></rich-text>
  51. </view>
  52. <!-- 岗位要求 -->
  53. <view class="topLine mt-5">
  54. <view class="fs15 w-600 my5">岗位要求</view>
  55. <view v-if="!info.requirement">暂无</view>
  56. <rich-text v-else class="htmlCss" :nodes="info.requirement"></rich-text>
  57. </view>
  58. <!-- 企业信息 -->
  59. <view class="topLine mt-5 d-flex">
  60. <view class="avatarBox">
  61. <image class="avatar" :src="info.contact?.avatar || 'https://minio.citupro.com/dev/menduner/7.png'"></image>
  62. </view>
  63. <view >
  64. <view class="contact-name">{{ info.contact?.name }}</view>
  65. <view class="contact-info">{{ info.enterprise?.name }} · {{ info.contact?.postNameCn }}</view>
  66. </view>
  67. </view>
  68. <!-- 工作地址 -->
  69. <view class="topLine mt-5">
  70. <view class="fs15 w-600 my5">工作地址</view>
  71. <view class="my10">
  72. <uni-icons
  73. type="map-pin-ellipse"
  74. color="#00897B"
  75. class="mr"
  76. size="25"
  77. ></uni-icons>
  78. <span style="color: var(--color-666);font-size: 15px;line-height: 26px;">{{ info.address }}</span>
  79. </view>
  80. </view>
  81. </view>
  82. </view>
  83. </scroll-view>
  84. <!-- 分享 投递 -->
  85. <view class="bottom-sticky" v-if="!loading && jobId">
  86. <view style="display: flex;justify-content: space-evenly;align-items: center;width: 100%;margin: 20rpx 0;">
  87. <view @click="handleClickShare" style="display: flex;justify-content: center;flex-direction: column;align-items: center;">
  88. <uni-icons type="redo-filled" size="24" color="#00897B"/>
  89. <span style="color:#00897B;font-weight:bold;">分享</span>
  90. </view>
  91. <button v-if="delivery" :disabled="true" class="buttons disable">我已投递</button>
  92. <button v-else class="buttons" @click="handleDelivery">我要投递</button>
  93. </view>
  94. </view>
  95. <!-- 选择简历 -->
  96. <uni-popup ref="popup" background-color="#fff" :mask-click="false" >
  97. <view class="dialogBox" style="width: 86vw;">
  98. <view class="dialog-title">
  99. <view class="title">选择简历</view>
  100. <uni-icons type="close" color="grey" size="26" @click="popupClose" />
  101. </view>
  102. <view style="height: 1px; margin: 0 20rpx; background-color: #dedede;"></view>
  103. <scroll-view class="dialog-content" scroll-y="true" style="max-height: 50vh; width: auto;">
  104. <uni-card
  105. v-for="(item, index) in resumeList"
  106. :key="index"
  107. shadow="0px 0px 3px 1px rgba(0,0,0,0.1)"
  108. :is-shadow="true"
  109. :border='false'
  110. background-color="red"
  111. :class="{'selected': selectIndex === index}"
  112. @click="selectIndex = index"
  113. >
  114. <view class="d-flex align-center">
  115. <view style="flex: 1;">
  116. <view style="font-weight: bold;">
  117. <uni-icons v-if="selectIndex === index" color="green" type="checkmarkempty" size="18"></uni-icons>
  118. {{ item.title }}
  119. </view>
  120. <view>上传时间:{{ timesTampChange(item.createTime, 'Y-M-D') }}</view>
  121. </view>
  122. <view class="ss-m-l-30" style="width: 60rpx;">
  123. <uni-icons @click="preview(item.url)" type="eye" size="24"></uni-icons>
  124. </view>
  125. </view>
  126. </uni-card>
  127. <view class="selectOnline" @click="handleUpload">选取微信聊天文件</view>
  128. </scroll-view>
  129. <view class="dialog-bottom" @click="deliverySubmit()">确认投递</view>
  130. </view>
  131. </uni-popup>
  132. <!-- 上传简历 -->
  133. <uni-popup ref="uploadPopup" type="dialog">
  134. <uni-popup-dialog
  135. type="warn"
  136. cancelText="取消"
  137. confirmText="确定"
  138. title="系统提示"
  139. content="您还未上传过简历,是否选取微信聊天文件投递?"
  140. @confirm="handleUpload"
  141. @close="uploadPopup.close()"
  142. ></uni-popup-dialog>
  143. </uni-popup>
  144. <!-- 职位分享 -->
  145. <uni-popup ref="sharePopup" type="share">
  146. <uni-popup-share title="分享到">
  147. <view class="share-pop">
  148. <button class="f-straight" open-type="share">
  149. <view class="share-round share-round-1" >
  150. <uni-icons
  151. type="weixin"
  152. color="#FFF"
  153. size="30"
  154. />
  155. </view>
  156. <view style="font-size:12px;">微信好友</view>
  157. </button>
  158. <button class="f-straight" @click="createPoster">
  159. <view class="share-round share-round-2" >
  160. <uni-icons
  161. type="download-filled"
  162. color="#FFF"
  163. size="30"
  164. />
  165. </view>
  166. <view style="font-size:12px;">生成海报</view>
  167. </button>
  168. </view>
  169. </uni-popup-share>
  170. </uni-popup>
  171. </layout-page>
  172. </template>
  173. <script setup>
  174. import { commissionCalculation } from '@/utils/position'
  175. import { timesTampChange } from '@/utils/date'
  176. import { preview } from '@/utils/preview'
  177. import { uploadFile } from '@/api/file'
  178. import layoutPage from '@/layout'
  179. import { ref } from 'vue';
  180. import {
  181. jobCvRelSend,
  182. getPositionDetails,
  183. jobCvRelCheckSend,
  184. getPersonJobUnfavorite, // 取消收藏
  185. getPersonJobFavorite, // 收藏
  186. getJobFavoriteCheck,
  187. jobCvRelHireSend
  188. } from '@/api/position'
  189. import { getPersonResumeCv, saveResume } from '@/api/user'
  190. import { dealDictObjData } from '@/utils/position'
  191. import { getAccessToken } from '@/utils/request'
  192. import { onLoad,onShareAppMessage,onShareTimeline } from '@dcloudio/uni-app'
  193. const sharePopup = ref()
  194. const loading = ref(false)
  195. const loadingText = ref('加载中 . . . ')
  196. // 职位详情
  197. const info = ref({})
  198. const positionInfo = ref({})
  199. const isEmployment = ref(null)
  200. const getPositionDetail = async () => {
  201. try {
  202. loading.value = true
  203. const { data } = await getPositionDetails({ id: jobId })
  204. info.value = data
  205. positionInfo.value = { ...dealDictObjData({}, info.value), ...info.value }
  206. loading.value = false
  207. console.log('positionInfo', positionInfo.value)
  208. } finally {
  209. }
  210. }
  211. let jobId = ''
  212. onLoad((options) => {
  213. // 是否是众聘
  214. if (options.userId) {
  215. isEmployment.value = options.userId
  216. }
  217. jobId = options?.id || ''
  218. if (jobId) {
  219. loading.value = true
  220. loadingText.value = '加载中 . . . '
  221. deliveryCheck()
  222. getCollectionStatus()
  223. getPositionDetail()
  224. } else {
  225. loadingText.value = '加载失败 . . . '
  226. }
  227. })
  228. // 效验是否有投递过简历
  229. const delivery = ref(false) // 是否已投递简历
  230. const deliveryCheck = async () => {
  231. try {
  232. if (!getAccessToken()) return delivery.value = false
  233. const { data } = await jobCvRelCheckSend({ jobId })
  234. delivery.value = Boolean(data)
  235. } finally {
  236. }
  237. }
  238. import { showAuthModal } from '@/hooks/useModal'
  239. const popup = ref()
  240. const uploadPopup = ref()
  241. const resumeList = ref([])
  242. const selectIndex = ref(null)
  243. const handleDelivery = async () => {
  244. // 未登录
  245. if (!getAccessToken()) {
  246. uni.showToast({
  247. title:'请先登录',
  248. icon: 'none'
  249. })
  250. showAuthModal()
  251. return
  252. }
  253. // 已投递
  254. if (delivery.value) {
  255. uni.showToast({ title: '您已投递过该职位!', icon: 'none', duration: 2000, })
  256. return
  257. }
  258. const { data } = await getPersonResumeCv()
  259. resumeList.value = data
  260. // 未上传简历
  261. if (!resumeList.value?.length) {
  262. return uploadPopup.value.open()
  263. }
  264. popup.value.open()
  265. }
  266. const deliverySubmit = async (uploadFile) => {
  267. const resume = uploadFile ? uploadFile : resumeList.value[selectIndex.value]
  268. if (!resume) {
  269. selectIndex.value = null
  270. uni.showToast({ title: '请选择简历', icon: 'none', duration: 2000, })
  271. return
  272. }
  273. if (isEmployment.value) {
  274. await jobCvRelHireSend({
  275. jobId,
  276. url: resume.url,
  277. recommendUserId: isEmployment.value
  278. })
  279. } else {
  280. await jobCvRelSend({
  281. jobId,
  282. title: resume.title,
  283. url: resume.url,
  284. type: info.value.hire ? 1 : 0
  285. })
  286. }
  287. uni.showToast({ title: '投递成功', icon: 'none', duration: 2000, })
  288. deliveryCheck()
  289. popup.value.close()
  290. }
  291. const popupClose = () => {
  292. selectIndex.value = null
  293. popup.value.close()
  294. }
  295. // 效验求职者是否有收藏该职位
  296. const isCollection = ref(false)
  297. const getCollectionStatus = async () => {
  298. if (!getAccessToken()) return isCollection.value = false
  299. const { data } = await getJobFavoriteCheck({ jobId })
  300. isCollection.value = Boolean(data)
  301. }
  302. // 操作 收藏&取消收藏职位
  303. const handleCollection = async () => {
  304. const api = isCollection.value ? getPersonJobUnfavorite : getPersonJobFavorite
  305. await api(isCollection.value ? jobId : { jobId })
  306. await getCollectionStatus()
  307. }
  308. // 选取微信聊天文件
  309. // 上传附件
  310. const handleUpload = () => {
  311. wx.chooseMessageFile({
  312. count: 1,
  313. type: 'file',
  314. success (res) {
  315. const title = res.tempFiles[0].name
  316. const path = res.tempFiles[0].path
  317. //效验是否为支持的文件格式
  318. if(/\.(pdf|docx|doc)$/.test(title)){
  319. uploadFile(path).then(async (res) => {
  320. if (!res.data) {
  321. uni.showToast({
  322. title: '上传失败',
  323. icon: 'none'
  324. })
  325. return
  326. }
  327. await saveResume({ title, url: res.data })
  328. uni.showToast({
  329. title: '上传成功',
  330. icon: 'success'
  331. })
  332. deliverySubmit({ title, url: res.data })
  333. })
  334. }else{
  335. uni.showToast({
  336. icon: 'none',
  337. title: '请上传pdf、word类型的文件',
  338. duration: 2000
  339. })
  340. return
  341. }
  342. }
  343. })
  344. }
  345. // 分享
  346. const handleClickShare = () => {
  347. sharePopup.value.open()
  348. }
  349. //在点击open-type="share"按钮后会触发以下函数,可以在函数中写需要的逻辑,当然函数的返回值必须是一个对象,用于设置分享卡片的展示形式
  350. //发送给微信好友
  351. onShareAppMessage((res) => {
  352. let path = `/pagesB/positionDetail/index?id=${info.value.id}`
  353. if (info.value.hire) {
  354. path += `&userId=${info.value.userId}`
  355. }
  356. return {
  357. title: '我发现了一个好职位,快来看看吧', //分享的名称
  358. path
  359. }
  360. })
  361. </script>
  362. <style scoped lang="scss">
  363. @import '../../static/style/position/index.scss';
  364. .share-pop {
  365. width: 100%;
  366. // height:300rpx;
  367. display: flex;
  368. justify-content: center;
  369. .f-straight {
  370. margin: 40rpx;
  371. background: unset;
  372. &::after{
  373. border:none !important;
  374. }
  375. }
  376. .share-round {
  377. border-radius:50%;
  378. height:100rpx;
  379. width:100rpx;
  380. display: flex;
  381. align-items: center;
  382. justify-content: center;
  383. }
  384. .share-round-1 {
  385. background-color:#22a039;
  386. }
  387. .share-round-2 {
  388. background-color:#3693cd;
  389. }
  390. }
  391. </style>