index.vue 24 KB

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