index.vue 15 KB

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