index.vue 26 KB

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