index.vue 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858
  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">{{ 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" @click="jumpToEnterpriseDetail(info.enterprise.id)">
  60. <view class="avatarBox">
  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>
  64. <view class="contact-name MiSans-Medium default-text-color">{{ info.contact?.name }}</view>
  65. <view class="contact-info MiSans-Normal color-666">
  66. {{ formatName(info.enterprise?.anotherName || info.enterprise?.name) }} {{ info.contact?.postNameCn ? '· ' + info.contact?.postNameCn : '' }}
  67. </view>
  68. </view>
  69. <view class="d-flex align-center">
  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 } 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(uni.getStorageSync('navbarHeight'))
  261. const useUserStore = userStore()
  262. const sharePopup = ref()
  263. const loading = ref(false)
  264. const loadingText = ref('加载中 . . . ')
  265. // 职位详情
  266. const info = ref({})
  267. const positionInfo = ref({})
  268. const isEmployment = ref(null)
  269. const imgSrc = ref('')
  270. const appInfo = ref({})
  271. const poster = ref()
  272. const beenLogin = ref(false)
  273. // const isStudent = ref(false) // 已测试,待开放上线
  274. const isStudent = computed(() => useUserStore?.baseInfo?.type && Boolean(Number(useUserStore.baseInfo.type) === 1))
  275. const areaName = ref('')
  276. const canvasToTempFilePath = ref('')
  277. // 监听登录状态
  278. watch(() => useUserStore.refreshToken, (newVal) => {
  279. beenLogin.value = Boolean(newVal)
  280. }, { immediate: true }, { deep: true })
  281. let jobId = ''
  282. let jobFairId = ''
  283. const isJobFair = ref(false) // 是否是通过招聘会进入的岗位
  284. let obj = {}
  285. onLoad(async (options) => {
  286. console.log(options, 'options')
  287. areaName.value = options?.area || ''
  288. // 网站二维码分享
  289. if (options.scene) {
  290. const scene = decodeURIComponent(options.scene)
  291. const str = scene.split('=')
  292. const res = await getShareDetail({ id: str[1] })
  293. obj = res.data
  294. }
  295. // 是否众聘
  296. isEmployment.value = options?.sharedById || obj?.sharedById
  297. jobId = options?.id || options?.jobId || obj?.jobId || ''
  298. jobFairId = options?.jobFairId !== 'undefined' && options.jobFairId !== 'null' && options.jobFairId || obj?.jobFairId || ''
  299. // console.log(`${jobFairId?'是':'不是'}招聘会职位`, ',jobFairId:', jobFairId)
  300. isJobFair.value = Boolean(jobFairId)
  301. deliveryCheck()
  302. if (jobId) {
  303. loading.value = true
  304. loadingText.value = '加载中 . . . '
  305. getCollectionStatus()
  306. getPositionDetail()
  307. } else {
  308. loadingText.value = '加载失败 . . . '
  309. }
  310. })
  311. // onShow(() => {
  312. // if (!jobId) {
  313. // return
  314. // }
  315. // })
  316. const getImageTempRatio = (url) => {
  317. return new Promise((req, rej)=>{
  318. wx.getImageInfo({
  319. src:url,
  320. success:(res) =>{
  321. req(res)
  322. }
  323. })
  324. })
  325. }
  326. /**
  327. ctx: 画布的上下文环境
  328. fontSize: 文字大小
  329. text: 绘制文本
  330. maxWidth: 一行文字最大宽度
  331. x:文本在x轴显示的位置
  332. y:文本在y轴显示的位置
  333. maxLine:最多绘制的行数
  334. **/
  335. //处理文字多出省略号显示
  336. const enterpriseNameLines = ref(0)
  337. const dealWords = (ctx, fontSize, text, maxWidth, x, y, maxLine, isEnterpriseName) => {
  338. ctx.setFontSize(fontSize);//设置字体大小
  339. var allRow = Math.ceil(ctx.measureText(text).width / maxWidth);//实际总共能分多少行
  340. enterpriseNameLines.value = allRow
  341. var count = allRow >= maxLine ? maxLine : allRow;//实际能分多少行与设置的最大显示行数比,谁小就用谁做循环次数
  342. var endPos = 0;//当前字符串的截断点
  343. for (var j = 0; j < count; j++) {
  344. var nowStr = text.slice(endPos);//当前剩余的字符串
  345. var rowWid = 0;//每一行当前宽度
  346. if (ctx.measureText(nowStr).width > maxWidth) {//如果当前的字符串宽度大于最大宽度,然后开始截取
  347. for (var m = 0; m < nowStr.length; m++) {
  348. rowWid += ctx.measureText(nowStr[m]).width;//当前字符串总宽度
  349. if (rowWid > maxWidth) {
  350. if (j === maxLine - 1) { //如果是最后一行
  351. ctx.fillText(nowStr.slice(0, m - 1) + '...', x, y + (j + 1) * 30); //(j+1)*18这是每一行的高度
  352. } else {
  353. ctx.fillText(nowStr.slice(0, m), x, y + (j + 1) * 30);
  354. }
  355. endPos += m;//下次截断点
  356. break;
  357. }
  358. }
  359. } else {
  360. //如果当前的字符串宽度小于最大宽度就直接输出
  361. ctx.fillText(nowStr.slice(0), x, (isEnterpriseName ? y + 2 : y) + (j + 1) * 30);
  362. }
  363. }
  364. }
  365. // 职位分享图片绘制
  366. const createPoster = async () => {
  367. var context = uni.createCanvasContext('shareCanvas')
  368. //清空画布
  369. context.clearRect(0, 0, 452, 362);
  370. //背景图片
  371. context.drawImage('../../static/img/share-cover-border.jpg', 0, 0, 452, 362);
  372. // 岗位名称
  373. context.setFillStyle('#333333')
  374. dealWords(context, 25, formatName(positionInfo.value?.name), 350, 40, 30, 2)
  375. // 工作地区、工作经验、学历要求
  376. context.setFillStyle('#6c6e7b')
  377. const area = areaName.value + ' | '
  378. const combinationText = area + (positionInfo.value.expName || '') + (positionInfo.value.eduName ? ' | ' + positionInfo.value.eduName : '')
  379. dealWords(context, 20, combinationText, 350, 40, 100, 1) // 上下文、字号、文本、最大宽度、x、y、行数
  380. // 薪资
  381. context.setFontSize(22)
  382. context.setFillStyle('#f67272')
  383. const { payFrom, payTo, payName } = positionInfo.value
  384. const salary = payFrom && payTo ? payFrom + '-' + payTo + (payName ? '元/'+ payName : '') : '面议'
  385. context.fillText(salary, 40, 170)
  386. // 间隔线
  387. context.setLineDash([2, 4], 1)
  388. context.beginPath()
  389. context.moveTo(40, 195)
  390. context.lineTo(412, 195)
  391. context.setStrokeStyle('#00B760')
  392. context.stroke()
  393. // 企业头像
  394. const { logoUrl, anotherName, industryName, scaleName, name } = positionInfo.value.enterprise
  395. const {path : headImg} = await getImageTempRatio(logoUrl ? logoUrl : 'https://minio.citupro.com/dev/menduner/company-avatar.png')
  396. context.drawImage(headImg, 40, 220, 90, 90)
  397. // 企业名称
  398. context.setFillStyle('#000000')
  399. dealWords(context, 25, formatName(anotherName || name), 250, 150, 210, 2, true)
  400. // 企业行业类型、规模
  401. context.setFontSize(20)
  402. let industry = industryName && industryName.length > 6 ? `${industryName.slice(0, 7)}...` : industryName
  403. context.setFillStyle('#6c6e7b')
  404. context.fillText(`${industry || ''}${scaleName ? ' | ' + scaleName : ''}`, 150, enterpriseNameLines.value === 1 ? 280 : 310)
  405. context.draw(false, () =>{
  406. wx.canvasToTempFilePath({
  407. canvasId: 'shareCanvas',
  408. success:(res)=>{
  409. canvasToTempFilePath.value = res.tempFilePath
  410. console.log('canvas-success', canvasToTempFilePath.value)
  411. },
  412. fail:(err)=>{
  413. console.log('canvasToTemp-fail', err)
  414. }
  415. })
  416. })
  417. }
  418. //在点击open-type="share"按钮后会触发以下函数,可以在函数中写需要的逻辑,当然函数的返回值必须是一个对象,用于设置分享卡片的展示形式
  419. //发送给微信好友
  420. onShareAppMessage((res) => {
  421. let path = `/pagesB/positionDetail/index?jobId=${info.value.id}`
  422. if (info.value.hire) {
  423. path += `&sharedById=${useUserStore.accountInfo.userId}`
  424. }
  425. if (jobFairId) {
  426. path += `&jobFairId=${jobFairId}`
  427. }
  428. if(!canvasToTempFilePath.value){
  429. setTimeout(() => {},1000)
  430. }
  431. return {
  432. title: '我发现了一个好职位,快来看看吧',
  433. path,
  434. imageUrl: canvasToTempFilePath.value
  435. }
  436. })
  437. // 富文本内容处理,去除多余的换行空格等
  438. const cleanedHtml = (text) => {
  439. const cleaned = text.replace(/\n/g, '<br>')
  440. .replace(/\s+/g, ' ')
  441. .replace(/(^|\s+)<\/p>(\s*<p>|$)/g, '</p><p>')
  442. .replace(/<p>\s*(<br>)\s*<\/p>/g, '')
  443. .replace(/<pre([^>]*)>/g, '<div$1>')
  444. .replace(/<\/pre>/g, '</div>')
  445. .replace(/<p>\s*(<\/br>)\s*<\/p>/g, '').trim()
  446. return cleaned
  447. }
  448. // 职位详情
  449. async function getPositionDetail () {
  450. try {
  451. loading.value = true
  452. const { data } = await getPositionDetails({ id: jobId })
  453. info.value = data
  454. positionInfo.value = { ...dealDictObjData({}, info.value), ...info.value, enterprise: dealDictObjData({}, data.enterprise) }
  455. loading.value = false
  456. areaName.value = positionInfo.value.area?.str ?? '全国'
  457. // 生成分享图片
  458. createPoster()
  459. } finally {
  460. }
  461. }
  462. // 效验是否有投递过简历
  463. const delivery = ref(false) // 是否已投递简历
  464. async function deliveryCheck () {
  465. try {
  466. if (!getAccessToken() || !jobId) return delivery.value = false
  467. const params = { jobId, ...(jobFairId && { jobFairId }) }
  468. const api = params.jobFairId ? jobFairCvRelCheckSend : jobCvRelCheckSend
  469. const { data } = await api(params)
  470. delivery.value = Boolean(data)
  471. } finally {
  472. }
  473. }
  474. import { showAuthModal } from '@/hooks/useModal'
  475. const popup = ref()
  476. const uploadPopup = ref()
  477. const resumeList = ref([])
  478. const selectIndex = ref(null)
  479. const practicePopupClose = () => {
  480. practicePopup.value.close()
  481. }
  482. const beforeHandleUpload = async () => {
  483. practicePopup.value.open()
  484. }
  485. const practicePopup = ref()
  486. let practiceData = null
  487. const beforeHandleUploadSubmit = async () => {
  488. practiceData = await studentDeliveryFormRef.value.getQueryParams()
  489. if (!practiceData) {
  490. return
  491. }
  492. practicePopupClose()
  493. handleOpen(true)
  494. }
  495. const handleOpen = async (retry) => {
  496. if (isStudent.value && !retry) {
  497. beforeHandleUpload()
  498. return
  499. }
  500. // 未上传简历
  501. if (!resumeList.value?.length) {
  502. return uploadPopup.value.open()
  503. }
  504. popup.value.open()
  505. }
  506. const handleDelivery = async () => {
  507. // 未登录
  508. if (!getAccessToken()) {
  509. uni.showToast({
  510. title:'请先登录',
  511. icon: 'none'
  512. })
  513. showAuthModal()
  514. return
  515. }
  516. if (showNecessaryInfoPopup()) {
  517. uni.showToast({
  518. title: '请先完善基本信息',
  519. icon: 'none'
  520. })
  521. showAuthModal('necessaryInfo')
  522. return
  523. }
  524. // 已投递
  525. if (delivery.value) {
  526. uni.showToast({ title: '您已投递过该职位!', icon: 'none', duration: 2000, })
  527. return
  528. }
  529. // 获取附件简历
  530. const { data } = await getPersonResumeCv()
  531. resumeList.value = data
  532. // 消息订阅
  533. const tmplIds = ['2KOkuFsB-2MrvnQa_45OvqMJ9ik37Xz43YXPApiQ9es', 'tUTwKQTdWnZsen7Nhtu0ksMQj0lkEuMt2nBzCrm_7vY']
  534. wx.requestSubscribeMessage({
  535. tmplIds,
  536. success:(res)=>{
  537. console.log(res, 'uni.requestSubscribeMessage-res')
  538. if (res[tmplIds[0]] === 'accept' || res[tmplIds[1]] === 'accept') {
  539. console.log('订阅成功', res)
  540. handleOpen()
  541. }
  542. },
  543. fail:(err)=>{
  544. console.log('订阅失败', err)
  545. handleOpen()
  546. }
  547. })
  548. }
  549. const studentDeliveryFormRef = ref()
  550. const deliverySubmit = async (uploadFile) => {
  551. const resume = uploadFile ? uploadFile : resumeList.value[selectIndex.value]
  552. if (!resume) {
  553. selectIndex.value = null
  554. uni.showToast({ title: '请选择简历', icon: 'none', duration: 2000, })
  555. return
  556. }
  557. let params = {
  558. jobId,
  559. url: resume.url,
  560. ...(jobFairId && { jobFairId })
  561. }
  562. if (isStudent.value) {
  563. if (!practiceData) {
  564. handleOpen()
  565. return
  566. }
  567. params = Object.assign(params, practiceData)
  568. }
  569. if (isEmployment.value) {
  570. params.recommendUserId = isEmployment.value
  571. await jobCvRelHireSend(params)
  572. } else {
  573. params.type = info.value.hire ? 1 : 0
  574. params.title = resume.title
  575. await jobCvRelSend(params)
  576. }
  577. uni.showToast({ title: '投递成功', icon: 'none', duration: 2000, })
  578. deliveryCheck()
  579. popup.value.close()
  580. }
  581. const popupClose = () => {
  582. selectIndex.value = null
  583. popup.value.close()
  584. }
  585. // 发起聊天
  586. async function handleSend () {
  587. if (!getAccessToken()) {
  588. showAuthModal()
  589. return
  590. }
  591. if (showNecessaryInfoPopup()) {
  592. uni.showToast({
  593. title: '请先完善基本信息',
  594. icon: 'none'
  595. })
  596. showAuthModal('necessaryInfo')
  597. return
  598. }
  599. const userId = info.value.contact.userId
  600. const enterpriseId = info.value.contact.enterpriseId
  601. const textObj = {
  602. text: defaultText,
  603. positionInfo: positionInfo.value,
  604. }
  605. const channel = await prologue({userId, enterpriseId, text: JSON.stringify(textObj)})
  606. // 跳转
  607. const query = {
  608. id: userId,
  609. isEmployment: isEmployment.value ? isEmployment.value : '-1',
  610. name: info.value?.contact?.name,
  611. postName: info.value?.contact?.postNameCn,
  612. enterpriseName: info.value?.enterprise?.anotherName,
  613. enterpriseId: info.value?.enterpriseId,
  614. channelID: channel.channelID,
  615. channelType: channel.channelType,
  616. avatar: info.value?.contact?.avatar,
  617. sex: info.value?.contact?.sex,
  618. // ...(jobFairId && { jobFairId }),
  619. }
  620. const queryStr = Object.keys(query).reduce((r, v) => {
  621. return r += `${v}=${encodeURIComponent(query[v])}&`
  622. }, '?')
  623. uni.navigateTo({
  624. url: `/pagesA/chart/index${queryStr.slice(0, -1)}`
  625. })
  626. }
  627. // 效验求职者是否有收藏该职位
  628. const isCollection = ref(false)
  629. const getCollectionStatus = async () => {
  630. if (!getAccessToken()) return isCollection.value = false
  631. const { data } = await getJobFavoriteCheck({ jobId })
  632. isCollection.value = Boolean(data)
  633. }
  634. // 操作 收藏&取消收藏职位
  635. const handleCollection = async () => {
  636. const api = isCollection.value ? getPersonJobUnfavorite : getPersonJobFavorite
  637. await api(isCollection.value ? jobId : { jobId })
  638. await getCollectionStatus()
  639. }
  640. // 选取微信聊天文件
  641. // 上传附件
  642. const handleUpload = () => {
  643. wx.chooseMessageFile({
  644. count: 1,
  645. type: 'file',
  646. success (res) {
  647. // 限制文件上传大小
  648. const size = res.tempFiles[0].size
  649. if (size / (1024*1024) > 20) {
  650. uni.showToast({ icon: 'none', title: '文件大小不能超过20M' })
  651. return
  652. }
  653. const title = res.tempFiles[0].name
  654. const path = res.tempFiles[0].path
  655. //效验是否为支持的文件格式
  656. if(/\.(pdf|docx|doc)$/.test(title)){
  657. uploadFile(path, 'attachment').then(async (res) => {
  658. if (!res.data) {
  659. uni.showToast({
  660. title: '上传失败',
  661. icon: 'none'
  662. })
  663. return
  664. }
  665. await saveResume({ title, url: res.data })
  666. uni.showToast({
  667. title: '上传成功',
  668. icon: 'success'
  669. })
  670. deliverySubmit({ title, url: res.data })
  671. })
  672. }else{
  673. uni.showToast({
  674. icon: 'none',
  675. title: '请上传pdf、doc、docx类型的文件',
  676. duration: 2000
  677. })
  678. return
  679. }
  680. }
  681. })
  682. }
  683. // 分享
  684. const loginPopup = ref()
  685. const handleClickShare = () => {
  686. // 如果当前职位是赏金职位且没有登录的状态,则弹窗询问是否需要登录;普通职位登录与不登录都可直接分享
  687. if (!getAccessToken() && info.value.hire) return loginPopup.value.open()
  688. sharePopup.value.open()
  689. }
  690. // 取消则直接弹窗分享
  691. const handleLoginClose = () => {
  692. sharePopup.value.open()
  693. }
  694. // 确认则弹窗登录
  695. const handleLoginConfirm = () => {
  696. showAuthModal()
  697. }
  698. </script>
  699. <style scoped lang="scss">
  700. @import '../../static/style/position/index.scss';
  701. .commonBackground {
  702. position: absolute;
  703. top: 0;
  704. left: 0;
  705. width: 100%;
  706. height: 160px;
  707. &::before {
  708. content: '';
  709. position: absolute;
  710. top: 0;
  711. left: 0;
  712. width: 100%;
  713. height: 100%;
  714. background: linear-gradient(180deg, #BCFEDE, #F7F8FA);
  715. }
  716. }
  717. .hideCanvasView{
  718. position: relative;
  719. }
  720. .shareCanvas {
  721. position: fixed;
  722. top: -99999upx;
  723. left: -99999upx;
  724. z-index: -99999;
  725. }
  726. .bottom-content {
  727. display: flex;
  728. justify-content: space-evenly;
  729. align-items: center;
  730. width: 100%;
  731. margin: 20rpx 0;
  732. .btnStyle {
  733. flex: 1;
  734. margin-right: 20rpx;
  735. }
  736. .bgButtons {
  737. border: 2rpx solid #00B760;
  738. color: #00B760;
  739. border-radius: 50rpx;
  740. }
  741. .shareButtonCss {
  742. font-size: 16px;
  743. background: unset;
  744. &::after{
  745. border:none !important;
  746. }
  747. }
  748. &-tool {
  749. width: 160rpx;
  750. display: flex;
  751. justify-content: center;
  752. flex-direction: column;
  753. align-items: center;
  754. }
  755. }
  756. .share-pop {
  757. width: 100%;
  758. // height:300rpx;
  759. display: flex;
  760. justify-content: center;
  761. .f-straight {
  762. margin: 40rpx;
  763. background: unset;
  764. &::after{
  765. border:none !important;
  766. }
  767. }
  768. .share-round {
  769. border-radius:50%;
  770. height:100rpx;
  771. width:100rpx;
  772. display: flex;
  773. align-items: center;
  774. justify-content: center;
  775. }
  776. .share-round-1 {
  777. background-color:#22a039;
  778. }
  779. .share-round-2 {
  780. background-color:#3693cd;
  781. }
  782. }
  783. .border-bottom {
  784. border-bottom: 1px solid #eee;
  785. }
  786. .d-bottom {
  787. border-radius: 0 0 8px 8px;
  788. background-color: #fff;
  789. color: #00B760;
  790. width: 100%;
  791. height: 44px;
  792. line-height: 44px;
  793. text-align: center;
  794. border-top: 1px solid #eee;
  795. }
  796. </style>