index.vue 22 KB

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