index.vue 23 KB

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