index.vue 27 KB

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