index.vue 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874
  1. <template>
  2. <view>
  3. <Navbar title="职位详情" :textLeft="false" />
  4. <layout-page>
  5. <view :style="{'padding-top': navbarHeight + 'px'}">
  6. <view class="defaultBgc">
  7. <scroll-view class="scrollBox">
  8. <view class="commonBackground"></view>
  9. <view class="box" style="position: relative; z-index: 1;">
  10. <view v-if="loading" class="vertical80-center">{{ loadingText }}</view>
  11. <view v-else>
  12. <view style="display: flex;">
  13. <!-- 赏金 -->
  14. <view v-if="info.hire && info.hirePrice" class="hirePrice ss-m-r-10 d-flex align-center">
  15. <view class="iconfont icon-a-1_zhaopin ss-m-r-10" style="color: #e03506; font-size: 20px;"></view>
  16. <view class="MiSans-Normal">{{ `赏金:${commissionCalculation(info.hirePrice / 100, 1)}元` }}</view>
  17. </view>
  18. <image v-if="isJobFair" src="/static/svg/jobFair.svg" class="ss-m-r-10" style="width: 30px; height: 30px;"></image>
  19. <!-- 职位名称 -->
  20. <h2 class="JobName MiSans-Semibold" style="flex: 1;">{{ formatName(info.name) }}</h2>
  21. </view>
  22. <!-- 职位地区 -->
  23. <view class="d-flex justify-space-between mt-5 align-center">
  24. <view class="color-666" style="font-size: 28rpx; flex: 1; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; margin-right: 30px;">
  25. <span>
  26. <span class="MiSans-Normal">{{positionInfo?.area?.str ?? '全国' }}</span>
  27. <span class="viewider-mx" v-if="positionInfo?.eduName">|</span>
  28. <span class="MiSans-Normal">{{positionInfo?.eduName }}</span>
  29. <span class="viewider-mx" v-if="positionInfo?.expName">|</span>
  30. <span class="MiSans-Normal">{{positionInfo?.expName }}</span>
  31. </span>
  32. </view>
  33. </view>
  34. <view class="d-flex justify-space-between mt-5 align-center">
  35. <!-- 收藏职位 -->
  36. <view @click="handleCollection" class="d-flex align-center">
  37. <uni-icons
  38. :type="isCollection ? 'heart-filled' : 'heart'"
  39. color="#00B760"
  40. class="ss-m-r-10"
  41. size="25"
  42. ></uni-icons>
  43. <span class="color-primary MiSans-Normal font-size-14">{{ isCollection ? '取消收藏' : '收藏' }}</span>
  44. </view>
  45. <!-- 薪资 -->
  46. <view>
  47. <span v-if="!info.payFrom && !info.payTo" class="salary MiSans-Medium">面议</span>
  48. <span v-else class="salary MiSans-Medium">{{ info.payFrom }}-{{ info.payTo }}/{{ positionInfo.payName }}</span>
  49. </view>
  50. </view>
  51. <view class="font-size-13 color-999 ss-m-t-10 MiSans-Normal" style="text-align: end;">更新时间:{{ timesTampChange(info?.refreshTime || info.updateTime, 'Y-M-D h:m') }}</view>
  52. <!-- 标签 -->
  53. <view class="tagList mt">
  54. <view class="tag MiSans-Normal" v-for="(tag,i) in info?.tagList || []" :key="'tagList' + i">
  55. {{ tag }}
  56. </view>
  57. </view>
  58. <!-- 企业信息 -->
  59. <view class="topLine mt-5 d-flex align-center" style="position: relative;" @click="jumpToEnterpriseDetail(info.enterprise.id)">
  60. <view class="avatarBox ss-m-t-5">
  61. <image class="default-border default-radius" style="width: 100rpx; height: 100rpx;" :src="info.enterprise?.logoUrl || 'https://minio.citupro.com/dev/menduner/company-avatar.png'"></image>
  62. </view>
  63. <view style="margin-right: 20px;">
  64. <view class="contact-name MiSans-Medium default-text-color">{{ info.contact?.name }}</view>
  65. <view class="contact-info MiSans-Normal color-666 font-size-13">
  66. {{ formatName(info.enterprise?.anotherName || info.enterprise?.name) }} {{ info.contact?.postNameCn ? '· ' + info.contact?.postNameCn : '' }}
  67. </view>
  68. </view>
  69. <view style="position: absolute; right: 0px;">
  70. <uni-icons type="right" size="20" color="#666"></uni-icons>
  71. </view>
  72. </view>
  73. <!-- 岗位职责 -->
  74. <view class="topLine fs14 mt-5">
  75. <view class="MiSans-Semibold my5 font-size-17 title-text">岗位职责</view>
  76. <view v-if="!info.content"></view>
  77. <rich-text v-else class="htmlCss" :nodes="cleanedHtml(info.content)"></rich-text>
  78. </view>
  79. <!-- 岗位要求 -->
  80. <view class="topLine mt-5">
  81. <view class="MiSans-Semibold my5 font-size-17 title-text">岗位要求</view>
  82. <view v-if="!info.requirement"></view>
  83. <rich-text v-else class="htmlCss" :nodes="cleanedHtml(info.requirement)"></rich-text>
  84. </view>
  85. <!-- 工作地址 -->
  86. <view class="topLine mt-5">
  87. <view class="fs15 MiSans-Semibold my5">工作地址</view>
  88. <view class="my10">
  89. <uni-icons
  90. type="map-pin-ellipse"
  91. color="#00B760"
  92. class="mr"
  93. size="25"
  94. ></uni-icons>
  95. <span class="MiSans-Normal" style="color: var(--color-666);font-size: 15px;line-height: 26px;">{{ info.address || '' }}</span>
  96. </view>
  97. </view>
  98. </view>
  99. </view>
  100. </scroll-view>
  101. </view>
  102. </view>
  103. <!-- 分享 投递 -->
  104. <view class="bottom-sticky" style="z-index: 2;" v-if="!loading && jobId">
  105. <view class="bottom-content">
  106. <!-- 已登录可以分享 -->
  107. <button v-if="beenLogin" class="bottom-content-tool shareButtonCss" open-type="share">
  108. <uni-icons type="redo" size="30" color="#00B760" style="line-height: 30px;"/>
  109. <span class="MiSans-Normal" style="color:#00B760;line-height: 22px;">分享</span>
  110. </button>
  111. <!-- 未登录点击分享拉起登录 -->
  112. <view v-else @click="handleClickShare" class="bottom-content-tool">
  113. <uni-icons type="redo" size="30" color="#00B760"/>
  114. <span class="MiSans-Normal" style="color:#00B760;">分享</span>
  115. </view>
  116. <button class="btnStyle bgButtons MiSans-Medium" type="primary" plain="true" @tap="handleSend">立即沟通</button>
  117. <button v-if="delivery" :disabled="true" class="buttons btnStyle disable MiSans-Medium">我已投递</button>
  118. <button v-else class="buttons btnStyle MiSans-Medium" type="primary" @click="handleDelivery">我要投递</button>
  119. </view>
  120. </view>
  121. <uni-popup
  122. ref="poster"
  123. type="center"
  124. class="f-straight"
  125. style="position: relative;"
  126. >
  127. <canvas
  128. :style="{
  129. width:`${appInfo.windowWidth}px;`,
  130. height:`${appInfo.windowHeight}px;margin-left:-9999px; margin-top:-99.5vh;`
  131. }" canvas-id="firstCanvas" id="firstCanvas"></canvas>
  132. <image
  133. :style="{ width:`${appInfo.windowWidth}px;`, height:`${appInfo.windowHeight*.9}px;`}"
  134. :src="imgSrc"
  135. mode="aspectFit"
  136. />
  137. </uni-popup>
  138. <!-- 选择简历 -->
  139. <uni-popup ref="popup" background-color="#fff" :mask-click="false" >
  140. <view class="dialogBox" style="width: 86vw;">
  141. <view class="dialog-title border-bottom">
  142. <view class="title MiSans-Normal">选择简历</view>
  143. <uni-icons type="close" color="grey" size="26" @click="popupClose" />
  144. </view>
  145. <!-- <view style="height: 1px; margin: 0 20rpx; background-color: #dedede;"></view> -->
  146. <scroll-view class="dialog-content" scroll-y="true" style="max-height: 50vh; width: auto;">
  147. <uni-card
  148. v-for="(item, index) in resumeList"
  149. :key="index"
  150. shadow="0px 0px 3px 1px rgba(0,0,0,0.1)"
  151. :is-shadow="true"
  152. :border='false'
  153. background-color="red"
  154. :class="{'selected': selectIndex === index}"
  155. @click="selectIndex = index"
  156. >
  157. <view class="d-flex align-center">
  158. <view style="flex: 1;">
  159. <view class="MiSans-Mediuml default-text-color">
  160. <uni-icons v-if="selectIndex === index" color="green" type="checkmarkempty" size="18"></uni-icons>
  161. {{ item.title }}
  162. </view>
  163. <view class="MiSans-Normal color-666">上传时间:{{ timesTampChange(item.createTime, 'Y-M-D') }}</view>
  164. </view>
  165. <view class="ss-m-l-30" style="width: 60rpx;">
  166. <uni-icons @click="preview(item.url)" type="eye" size="24"></uni-icons>
  167. </view>
  168. </view>
  169. </uni-card>
  170. <view class="selectOnline MiSans-Normal" @click="handleUpload">选取微信聊天文件</view>
  171. </scroll-view>
  172. <view class="dialog-bottom MiSans-Medium" @click="deliverySubmit()">确认投递</view>
  173. </view>
  174. </uni-popup>
  175. <!-- 实习到岗时间 -->
  176. <uni-popup ref="practicePopup" :mask-click="false" >
  177. <view class="dialogBox" style="width: 86vw; border-radius: 8px; background-color: #fff;">
  178. <view class="dialog-title border-bottom">
  179. <view class="title MiSans-Normal">实习到岗信息</view>
  180. <uni-icons type="close" color="grey" size="26" @click="practicePopupClose" />
  181. </view>
  182. <scroll-view class="dialog-content" scroll-y="true" style="max-height: 50vh;">
  183. <view class="ss-p-x-50">
  184. <studentDeliveryForm ref="studentDeliveryFormRef" />
  185. </view>
  186. </scroll-view>
  187. <view class="d-bottom MiSans-Medium" @click="beforeHandleUploadSubmit()">确 认</view>
  188. </view>
  189. </uni-popup>
  190. <!-- 上传简历 -->
  191. <uni-popup ref="uploadPopup" type="dialog">
  192. <uni-popup-dialog
  193. type="warn"
  194. cancelText="取消"
  195. confirmText="确定"
  196. title="系统提示"
  197. content="您还未上传过简历,是否选取微信聊天文件投递?"
  198. @confirm="handleUpload"
  199. @close="uploadPopup.close()"
  200. ></uni-popup-dialog>
  201. </uni-popup>
  202. <!-- 职位分享 -->
  203. <uni-popup ref="sharePopup" type="share">
  204. <uni-popup-share title="分享到">
  205. <view class="share-pop">
  206. <button class="f-straight" open-type="share">
  207. <view class="share-round share-round-1" >
  208. <uni-icons type="weixin" color="#FFF" size="30" />
  209. </view>
  210. <view style="font-size:12px;">微信</view>
  211. </button>
  212. </view>
  213. </uni-popup-share>
  214. </uni-popup>
  215. <!-- 当前是赏金职位时,询问是否登录,不登录则没有赏金 -->
  216. <uni-popup ref="loginPopup" type="dialog">
  217. <uni-popup-dialog
  218. type="warn"
  219. cancelText="取消"
  220. confirmText="登录"
  221. title="系统提示"
  222. content="当前为赏金职位,不登录进行分享将无法获得赏金,是否登录?"
  223. @confirm="handleLoginConfirm"
  224. @close="handleLoginClose" />
  225. </uni-popup>
  226. <view class="hideCanvasView">
  227. <canvas class="shareCanvas" canvas-id="shareCanvas" style="width: 452px; height: 362px;"></canvas>
  228. </view>
  229. </layout-page>
  230. </view>
  231. </template>
  232. <script setup>
  233. import { commissionCalculation, jumpToEnterpriseDetail } from '@/utils/position'
  234. import { timesTampChange } from '@/utils/date'
  235. import { preview } from '@/utils/preview'
  236. import { uploadFile } from '@/api/file'
  237. import layoutPage from '@/layout'
  238. import Navbar from '@/components/Navbar'
  239. import { ref, watch, computed, onMounted } from 'vue';
  240. import {
  241. jobCvRelSend,
  242. getPositionDetails,
  243. jobCvRelCheckSend,
  244. jobFairCvRelCheckSend,
  245. getPersonJobUnfavorite, // 取消收藏
  246. getPersonJobFavorite, // 收藏
  247. getJobFavoriteCheck,
  248. jobCvRelHireSend,
  249. getShareDetail
  250. } from '@/api/position'
  251. import { getPersonResumeCv, saveResume } from '@/api/user'
  252. import { dealDictObjData } from '@/utils/position'
  253. import { getAccessToken, showNecessaryInfoPopup } from '@/utils/request'
  254. import { onLoad, onShareAppMessage } from '@dcloudio/uni-app'
  255. import { prologue, defaultText } from '@/hooks/useIM'
  256. import { userStore } from '@/store/user'
  257. import { formatName } from '@/utils/getText'
  258. import studentDeliveryForm from '@/components/studentDeliveryForm'
  259. // import { getShareQueryById } from '@/api/jobFair.js'
  260. const navbarHeight = ref(0)
  261. onMounted(async () => {
  262. try {
  263. const res = await new Promise((resolve, reject) => {
  264. uni.getStorage({
  265. key: 'navbarHeight',
  266. success: (result) => resolve(result),
  267. fail: (err) => reject(err)
  268. })
  269. })
  270. navbarHeight.value = res.data
  271. console.log(navbarHeight.value, '职位详情-导航栏高度')
  272. } catch (error) {
  273. console.error('读取本地缓存出错:', error)
  274. }
  275. })
  276. const useUserStore = userStore()
  277. const sharePopup = ref()
  278. const loading = ref(false)
  279. const loadingText = ref('加载中 . . . ')
  280. // 职位详情
  281. const info = ref({})
  282. const positionInfo = ref({})
  283. const isEmployment = ref(null)
  284. const imgSrc = ref('')
  285. const appInfo = ref({})
  286. const poster = ref()
  287. const beenLogin = ref(false)
  288. // const isStudent = ref(false) // 已测试,待开放上线
  289. const isStudent = computed(() => useUserStore?.baseInfo?.type && Boolean(Number(useUserStore.baseInfo.type) === 1))
  290. const areaName = ref('')
  291. const canvasToTempFilePath = ref('')
  292. // 监听登录状态
  293. watch(() => useUserStore.refreshToken, (newVal) => {
  294. beenLogin.value = Boolean(newVal)
  295. }, { immediate: true }, { deep: true })
  296. let jobId = ''
  297. let jobFairId = ''
  298. const isJobFair = ref(false) // 是否是通过招聘会进入的岗位
  299. let obj = {}
  300. onLoad(async (options) => {
  301. console.log(options, 'options')
  302. areaName.value = options?.area || ''
  303. // 网站二维码分享
  304. if (options.scene) {
  305. const scene = decodeURIComponent(options.scene)
  306. const str = scene.split('=')
  307. const res = await getShareDetail({ id: str[1] })
  308. obj = res.data
  309. }
  310. // 是否众聘
  311. isEmployment.value = options?.sharedById || obj?.sharedById
  312. jobId = options?.id || options?.jobId || obj?.jobId || ''
  313. jobFairId = options?.jobFairId !== 'undefined' && options.jobFairId !== 'null' && options.jobFairId || obj?.jobFairId || ''
  314. // console.log(`${jobFairId?'是':'不是'}招聘会职位`, ',jobFairId:', jobFairId)
  315. isJobFair.value = Boolean(jobFairId)
  316. deliveryCheck()
  317. if (jobId) {
  318. loading.value = true
  319. loadingText.value = '加载中 . . . '
  320. getCollectionStatus()
  321. getPositionDetail()
  322. } else {
  323. loadingText.value = '加载失败 . . . '
  324. }
  325. })
  326. // onShow(() => {
  327. // if (!jobId) {
  328. // return
  329. // }
  330. // })
  331. const getImageTempRatio = (url) => {
  332. return new Promise((req, rej)=>{
  333. wx.getImageInfo({
  334. src:url,
  335. success:(res) =>{
  336. req(res)
  337. }
  338. })
  339. })
  340. }
  341. /**
  342. ctx: 画布的上下文环境
  343. fontSize: 文字大小
  344. text: 绘制文本
  345. maxWidth: 一行文字最大宽度
  346. x:文本在x轴显示的位置
  347. y:文本在y轴显示的位置
  348. maxLine:最多绘制的行数
  349. **/
  350. //处理文字多出省略号显示
  351. const enterpriseNameLines = ref(0)
  352. const dealWords = (ctx, fontSize, text, maxWidth, x, y, maxLine, isEnterpriseName) => {
  353. ctx.setFontSize(fontSize);//设置字体大小
  354. var allRow = Math.ceil(ctx.measureText(text).width / maxWidth);//实际总共能分多少行
  355. enterpriseNameLines.value = allRow
  356. var count = allRow >= maxLine ? maxLine : allRow;//实际能分多少行与设置的最大显示行数比,谁小就用谁做循环次数
  357. var endPos = 0;//当前字符串的截断点
  358. for (var j = 0; j < count; j++) {
  359. var nowStr = text.slice(endPos);//当前剩余的字符串
  360. var rowWid = 0;//每一行当前宽度
  361. if (ctx.measureText(nowStr).width > maxWidth) {//如果当前的字符串宽度大于最大宽度,然后开始截取
  362. for (var m = 0; m < nowStr.length; m++) {
  363. rowWid += ctx.measureText(nowStr[m]).width;//当前字符串总宽度
  364. if (rowWid > maxWidth) {
  365. if (j === maxLine - 1) { //如果是最后一行
  366. ctx.fillText(nowStr.slice(0, m - 1) + '...', x, y + (j + 1) * 30); //(j+1)*18这是每一行的高度
  367. } else {
  368. ctx.fillText(nowStr.slice(0, m), x, y + (j + 1) * 30);
  369. }
  370. endPos += m;//下次截断点
  371. break;
  372. }
  373. }
  374. } else {
  375. //如果当前的字符串宽度小于最大宽度就直接输出
  376. ctx.fillText(nowStr.slice(0), x, (isEnterpriseName ? y + 2 : y) + (j + 1) * 30);
  377. }
  378. }
  379. }
  380. // 职位分享图片绘制
  381. const createPoster = async () => {
  382. var context = uni.createCanvasContext('shareCanvas')
  383. //清空画布
  384. context.clearRect(0, 0, 452, 362);
  385. //背景图片
  386. context.drawImage('../../static/img/share-cover-border.jpg', 0, 0, 452, 362);
  387. // 岗位名称
  388. context.setFillStyle('#333333')
  389. dealWords(context, 25, formatName(positionInfo.value?.name), 350, 40, 30, 2)
  390. // 工作地区、工作经验、学历要求
  391. context.setFillStyle('#6c6e7b')
  392. const area = areaName.value + ' | '
  393. const combinationText = area + (positionInfo.value.expName || '') + (positionInfo.value.eduName ? ' | ' + positionInfo.value.eduName : '')
  394. dealWords(context, 20, combinationText, 350, 40, 100, 1) // 上下文、字号、文本、最大宽度、x、y、行数
  395. // 薪资
  396. context.setFontSize(22)
  397. context.setFillStyle('#f67272')
  398. const { payFrom, payTo, payName } = positionInfo.value
  399. const salary = payFrom && payTo ? payFrom + '-' + payTo + (payName ? '元/'+ payName : '') : '面议'
  400. context.fillText(salary, 40, 170)
  401. // 间隔线
  402. context.setLineDash([2, 4], 1)
  403. context.beginPath()
  404. context.moveTo(40, 195)
  405. context.lineTo(412, 195)
  406. context.setStrokeStyle('#00B760')
  407. context.stroke()
  408. // 企业头像
  409. const { logoUrl, anotherName, industryName, scaleName, name } = positionInfo.value.enterprise
  410. const {path : headImg} = await getImageTempRatio(logoUrl ? logoUrl : 'https://minio.citupro.com/dev/menduner/company-avatar.png')
  411. context.drawImage(headImg, 40, 220, 90, 90)
  412. // 企业名称
  413. context.setFillStyle('#000000')
  414. dealWords(context, 25, formatName(anotherName || name), 250, 150, 210, 2, true)
  415. // 企业行业类型、规模
  416. context.setFontSize(20)
  417. let industry = industryName && industryName.length > 6 ? `${industryName.slice(0, 7)}...` : industryName
  418. context.setFillStyle('#6c6e7b')
  419. context.fillText(`${industry || ''}${scaleName ? ' | ' + scaleName : ''}`, 150, enterpriseNameLines.value === 1 ? 280 : 310)
  420. context.draw(false, () =>{
  421. wx.canvasToTempFilePath({
  422. canvasId: 'shareCanvas',
  423. success:(res)=>{
  424. canvasToTempFilePath.value = res.tempFilePath
  425. console.log('canvas-success', canvasToTempFilePath.value)
  426. },
  427. fail:(err)=>{
  428. console.log('canvasToTemp-fail', err)
  429. }
  430. })
  431. })
  432. }
  433. //在点击open-type="share"按钮后会触发以下函数,可以在函数中写需要的逻辑,当然函数的返回值必须是一个对象,用于设置分享卡片的展示形式
  434. //发送给微信好友
  435. onShareAppMessage((res) => {
  436. let path = `/pagesB/positionDetail/index?jobId=${info.value.id}`
  437. if (info.value.hire) {
  438. path += `&sharedById=${useUserStore.accountInfo.userId}`
  439. }
  440. if (jobFairId) {
  441. path += `&jobFairId=${jobFairId}`
  442. }
  443. if(!canvasToTempFilePath.value){
  444. setTimeout(() => {},1000)
  445. }
  446. return {
  447. title: '我发现了一个好职位,快来看看吧',
  448. path,
  449. imageUrl: canvasToTempFilePath.value
  450. }
  451. })
  452. // 富文本内容处理,去除多余的换行空格等
  453. const cleanedHtml = (text) => {
  454. const cleaned = text.replace(/\n/g, '<br>')
  455. .replace(/\s+/g, ' ')
  456. .replace(/(^|\s+)<\/p>(\s*<p>|$)/g, '</p><p>')
  457. .replace(/<p>\s*(<br>)\s*<\/p>/g, '')
  458. .replace(/<pre([^>]*)>/g, '<div$1>')
  459. .replace(/<\/pre>/g, '</div>')
  460. .replace(/<p>\s*(<\/br>)\s*<\/p>/g, '').trim()
  461. return cleaned
  462. }
  463. // 职位详情
  464. async function getPositionDetail () {
  465. try {
  466. loading.value = true
  467. const { data } = await getPositionDetails({ id: jobId })
  468. info.value = data
  469. positionInfo.value = { ...dealDictObjData({}, info.value), ...info.value, enterprise: dealDictObjData({}, data.enterprise) }
  470. loading.value = false
  471. areaName.value = positionInfo.value.area?.str ?? '全国'
  472. // 生成分享图片
  473. createPoster()
  474. } finally {
  475. }
  476. }
  477. // 效验是否有投递过简历
  478. const delivery = ref(false) // 是否已投递简历
  479. async function deliveryCheck () {
  480. try {
  481. if (!getAccessToken() || !jobId) return delivery.value = false
  482. const params = { jobId, ...(jobFairId && { jobFairId }) }
  483. const api = params.jobFairId ? jobFairCvRelCheckSend : jobCvRelCheckSend
  484. const { data } = await api(params)
  485. delivery.value = Boolean(data)
  486. } finally {
  487. }
  488. }
  489. import { showAuthModal } from '@/hooks/useModal'
  490. const popup = ref()
  491. const uploadPopup = ref()
  492. const resumeList = ref([])
  493. const selectIndex = ref(null)
  494. const practicePopupClose = () => {
  495. practicePopup.value.close()
  496. }
  497. const beforeHandleUpload = async () => {
  498. practicePopup.value.open()
  499. }
  500. const practicePopup = ref()
  501. let practiceData = null
  502. const beforeHandleUploadSubmit = async () => {
  503. practiceData = await studentDeliveryFormRef.value.getQueryParams()
  504. if (!practiceData) {
  505. return
  506. }
  507. practicePopupClose()
  508. handleOpen(true)
  509. }
  510. const handleOpen = async (retry) => {
  511. if (isStudent.value && !retry) {
  512. beforeHandleUpload()
  513. return
  514. }
  515. // 未上传简历
  516. if (!resumeList.value?.length) {
  517. return uploadPopup.value.open()
  518. }
  519. popup.value.open()
  520. }
  521. const handleDelivery = async () => {
  522. // 未登录
  523. if (!getAccessToken()) {
  524. uni.showToast({
  525. title:'请先登录',
  526. icon: 'none'
  527. })
  528. showAuthModal()
  529. return
  530. }
  531. if (showNecessaryInfoPopup()) {
  532. uni.showToast({
  533. title: '请先完善基本信息',
  534. icon: 'none'
  535. })
  536. showAuthModal('necessaryInfo')
  537. return
  538. }
  539. // 已投递
  540. if (delivery.value) {
  541. uni.showToast({ title: '您已投递过该职位!', icon: 'none', duration: 2000, })
  542. return
  543. }
  544. // 获取附件简历
  545. const { data } = await getPersonResumeCv()
  546. resumeList.value = data
  547. // 消息订阅
  548. const tmplIds = ['2KOkuFsB-2MrvnQa_45OvqMJ9ik37Xz43YXPApiQ9es', 'tUTwKQTdWnZsen7Nhtu0ksMQj0lkEuMt2nBzCrm_7vY']
  549. wx.requestSubscribeMessage({
  550. tmplIds,
  551. success:(res)=>{
  552. console.log(res, 'uni.requestSubscribeMessage-res')
  553. if (res[tmplIds[0]] === 'accept' || res[tmplIds[1]] === 'accept') {
  554. console.log('订阅成功', res)
  555. handleOpen()
  556. }
  557. },
  558. fail:(err)=>{
  559. console.log('订阅失败', err)
  560. handleOpen()
  561. }
  562. })
  563. }
  564. const studentDeliveryFormRef = ref()
  565. const deliverySubmit = async (uploadFile) => {
  566. const resume = uploadFile ? uploadFile : resumeList.value[selectIndex.value]
  567. if (!resume) {
  568. selectIndex.value = null
  569. uni.showToast({ title: '请选择简历', icon: 'none', duration: 2000, })
  570. return
  571. }
  572. let params = {
  573. jobId,
  574. url: resume.url,
  575. ...(jobFairId && { jobFairId })
  576. }
  577. if (isStudent.value) {
  578. if (!practiceData) {
  579. handleOpen()
  580. return
  581. }
  582. params = Object.assign(params, practiceData)
  583. }
  584. if (isEmployment.value) {
  585. params.recommendUserId = isEmployment.value
  586. await jobCvRelHireSend(params)
  587. } else {
  588. params.type = info.value.hire ? 1 : 0
  589. params.title = resume.title
  590. await jobCvRelSend(params)
  591. }
  592. uni.showToast({ title: '投递成功', icon: 'none', duration: 2000, })
  593. deliveryCheck()
  594. popup.value.close()
  595. }
  596. const popupClose = () => {
  597. selectIndex.value = null
  598. popup.value.close()
  599. }
  600. // 发起聊天
  601. async function handleSend () {
  602. if (!getAccessToken()) {
  603. showAuthModal()
  604. return
  605. }
  606. if (showNecessaryInfoPopup()) {
  607. uni.showToast({
  608. title: '请先完善基本信息',
  609. icon: 'none'
  610. })
  611. showAuthModal('necessaryInfo')
  612. return
  613. }
  614. const userId = info.value.contact.userId
  615. const enterpriseId = info.value.contact.enterpriseId
  616. const textObj = {
  617. text: defaultText,
  618. positionInfo: positionInfo.value,
  619. }
  620. const channel = await prologue({userId, enterpriseId, text: JSON.stringify(textObj)})
  621. // 跳转
  622. const query = {
  623. id: userId,
  624. isEmployment: isEmployment.value ? isEmployment.value : '-1',
  625. name: info.value?.contact?.name,
  626. postName: info.value?.contact?.postNameCn,
  627. enterpriseName: info.value?.enterprise?.anotherName,
  628. enterpriseId: info.value?.enterpriseId,
  629. channelID: channel.channelID,
  630. channelType: channel.channelType,
  631. avatar: info.value?.contact?.avatar,
  632. sex: info.value?.contact?.sex,
  633. // ...(jobFairId && { jobFairId }),
  634. }
  635. const queryStr = Object.keys(query).reduce((r, v) => {
  636. return r += `${v}=${encodeURIComponent(query[v])}&`
  637. }, '?')
  638. uni.navigateTo({
  639. url: `/pagesA/chart/index${queryStr.slice(0, -1)}`
  640. })
  641. }
  642. // 效验求职者是否有收藏该职位
  643. const isCollection = ref(false)
  644. const getCollectionStatus = async () => {
  645. if (!getAccessToken()) return isCollection.value = false
  646. const { data } = await getJobFavoriteCheck({ jobId })
  647. isCollection.value = Boolean(data)
  648. }
  649. // 操作 收藏&取消收藏职位
  650. const handleCollection = async () => {
  651. const api = isCollection.value ? getPersonJobUnfavorite : getPersonJobFavorite
  652. await api(isCollection.value ? jobId : { jobId })
  653. await getCollectionStatus()
  654. }
  655. // 选取微信聊天文件
  656. // 上传附件
  657. const handleUpload = () => {
  658. wx.chooseMessageFile({
  659. count: 1,
  660. type: 'file',
  661. success (res) {
  662. // 限制文件上传大小
  663. const size = res.tempFiles[0].size
  664. if (size / (1024*1024) > 20) {
  665. uni.showToast({ icon: 'none', title: '文件大小不能超过20M' })
  666. return
  667. }
  668. const title = res.tempFiles[0].name
  669. const path = res.tempFiles[0].path
  670. //效验是否为支持的文件格式
  671. if(/\.(pdf|docx|doc)$/.test(title)){
  672. uploadFile(path, 'attachment').then(async (res) => {
  673. if (!res.data) {
  674. uni.showToast({
  675. title: '上传失败',
  676. icon: 'none'
  677. })
  678. return
  679. }
  680. await saveResume({ title, url: res.data })
  681. uni.showToast({
  682. title: '上传成功',
  683. icon: 'success'
  684. })
  685. deliverySubmit({ title, url: res.data })
  686. })
  687. }else{
  688. uni.showToast({
  689. icon: 'none',
  690. title: '请上传pdf、doc、docx类型的文件',
  691. duration: 2000
  692. })
  693. return
  694. }
  695. }
  696. })
  697. }
  698. // 分享
  699. const loginPopup = ref()
  700. const handleClickShare = () => {
  701. // 如果当前职位是赏金职位且没有登录的状态,则弹窗询问是否需要登录;普通职位登录与不登录都可直接分享
  702. if (!getAccessToken() && info.value.hire) return loginPopup.value.open()
  703. sharePopup.value.open()
  704. }
  705. // 取消则直接弹窗分享
  706. const handleLoginClose = () => {
  707. sharePopup.value.open()
  708. }
  709. // 确认则弹窗登录
  710. const handleLoginConfirm = () => {
  711. showAuthModal()
  712. }
  713. </script>
  714. <style scoped lang="scss">
  715. @import '../../static/style/position/index.scss';
  716. .commonBackground {
  717. position: absolute;
  718. top: 0;
  719. left: 0;
  720. width: 100%;
  721. height: 160px;
  722. &::before {
  723. content: '';
  724. position: absolute;
  725. top: 0;
  726. left: 0;
  727. width: 100%;
  728. height: 100%;
  729. background: linear-gradient(180deg, #BCFEDE, #F7F8FA);
  730. }
  731. }
  732. .hideCanvasView{
  733. position: relative;
  734. }
  735. .shareCanvas {
  736. position: fixed;
  737. top: -99999upx;
  738. left: -99999upx;
  739. z-index: -99999;
  740. }
  741. .bottom-content {
  742. display: flex;
  743. justify-content: space-evenly;
  744. align-items: center;
  745. width: 100%;
  746. margin: 20rpx 0;
  747. .btnStyle {
  748. flex: 1;
  749. margin-right: 20rpx;
  750. }
  751. .bgButtons {
  752. border: 2rpx solid #00B760;
  753. color: #00B760;
  754. border-radius: 50rpx;
  755. }
  756. .shareButtonCss {
  757. font-size: 16px;
  758. background: unset;
  759. &::after{
  760. border:none !important;
  761. }
  762. }
  763. &-tool {
  764. width: 160rpx;
  765. display: flex;
  766. justify-content: center;
  767. flex-direction: column;
  768. align-items: center;
  769. }
  770. }
  771. .share-pop {
  772. width: 100%;
  773. // height:300rpx;
  774. display: flex;
  775. justify-content: center;
  776. .f-straight {
  777. margin: 40rpx;
  778. background: unset;
  779. &::after{
  780. border:none !important;
  781. }
  782. }
  783. .share-round {
  784. border-radius:50%;
  785. height:100rpx;
  786. width:100rpx;
  787. display: flex;
  788. align-items: center;
  789. justify-content: center;
  790. }
  791. .share-round-1 {
  792. background-color:#22a039;
  793. }
  794. .share-round-2 {
  795. background-color:#3693cd;
  796. }
  797. }
  798. .border-bottom {
  799. border-bottom: 1px solid #eee;
  800. }
  801. .d-bottom {
  802. border-radius: 0 0 8px 8px;
  803. background-color: #fff;
  804. color: #00B760;
  805. width: 100%;
  806. height: 44px;
  807. line-height: 44px;
  808. text-align: center;
  809. border-top: 1px solid #eee;
  810. }
  811. </style>