index.vue 14 KB

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