index.vue 24 KB

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