index.vue 25 KB

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