index.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701
  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 fs14 mt-5">
  49. <view class="fs15 w-600 my5">岗位职责</view>
  50. <view v-if="!info.content">暂无</view>
  51. <rich-text v-else class="htmlCss" :nodes="info.content"></rich-text>
  52. </view>
  53. <!-- 岗位要求 -->
  54. <view class="topLine mt-5">
  55. <view class="fs15 w-600 my5">岗位要求</view>
  56. <view v-if="!info.requirement">暂无</view>
  57. <rich-text v-else class="htmlCss" :nodes="info.requirement"></rich-text>
  58. </view>
  59. <!-- 企业信息 -->
  60. <view class="topLine mt-5 d-flex">
  61. <view class="avatarBox">
  62. <image class="avatar" :src="info.contact?.avatar || 'https://minio.citupro.com/dev/menduner/7.png'"></image>
  63. </view>
  64. <view >
  65. <view class="contact-name">{{ info.contact?.name }}</view>
  66. <view class="contact-info">{{ info.enterprise?.name }} {{ info.contact?.postNameCn ? '· ' + info.contact?.postNameCn : '' }}</view>
  67. </view>
  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. } from '@/api/position'
  209. import { getPersonResumeCv, saveResume } from '@/api/user'
  210. import { dealDictObjData } from '@/utils/position'
  211. import { getAccessToken } from '@/utils/request'
  212. import { onLoad,onShareAppMessage,onShareTimeline } from '@dcloudio/uni-app'
  213. import { prologue, defaultText } from '@/hooks/useIM'
  214. const sharePopup = ref()
  215. const loading = ref(false)
  216. const loadingText = ref('加载中 . . . ')
  217. // 职位详情
  218. const info = ref({})
  219. const positionInfo = ref({})
  220. const isEmployment = ref(null)
  221. const imgSrc = ref('')
  222. const appInfo = ref({})
  223. const poster = ref()
  224. const getPositionDetail = async () => {
  225. try {
  226. loading.value = true
  227. const { data } = await getPositionDetails({ id: jobId })
  228. info.value = data
  229. positionInfo.value = { ...dealDictObjData({}, info.value), ...info.value }
  230. loading.value = false
  231. } finally {
  232. }
  233. }
  234. let jobId = ''
  235. onLoad((options) => {
  236. // 是否是众聘
  237. if (options.userId) {
  238. isEmployment.value = options.userId
  239. }
  240. jobId = options?.id || ''
  241. if (jobId) {
  242. loading.value = true
  243. loadingText.value = '加载中 . . . '
  244. deliveryCheck()
  245. getCollectionStatus()
  246. getPositionDetail()
  247. } else {
  248. loadingText.value = '加载失败 . . . '
  249. }
  250. })
  251. // 效验是否有投递过简历
  252. const delivery = ref(false) // 是否已投递简历
  253. const deliveryCheck = async () => {
  254. try {
  255. if (!getAccessToken()) return delivery.value = false
  256. const { data } = await jobCvRelCheckSend({ jobId })
  257. delivery.value = Boolean(data)
  258. } finally {
  259. }
  260. }
  261. import { showAuthModal } from '@/hooks/useModal'
  262. const popup = ref()
  263. const uploadPopup = ref()
  264. const resumeList = ref([])
  265. const selectIndex = ref(null)
  266. const handleDelivery = async () => {
  267. // 未登录
  268. if (!getAccessToken()) {
  269. uni.showToast({
  270. title:'请先登录',
  271. icon: 'none'
  272. })
  273. showAuthModal()
  274. return
  275. }
  276. // 已投递
  277. if (delivery.value) {
  278. uni.showToast({ title: '您已投递过该职位!', icon: 'none', duration: 2000, })
  279. return
  280. }
  281. const { data } = await getPersonResumeCv()
  282. resumeList.value = data
  283. // 未上传简历
  284. if (!resumeList.value?.length) {
  285. return uploadPopup.value.open()
  286. }
  287. popup.value.open()
  288. }
  289. const deliverySubmit = async (uploadFile) => {
  290. const resume = uploadFile ? uploadFile : resumeList.value[selectIndex.value]
  291. if (!resume) {
  292. selectIndex.value = null
  293. uni.showToast({ title: '请选择简历', icon: 'none', duration: 2000, })
  294. return
  295. }
  296. if (isEmployment.value) {
  297. await jobCvRelHireSend({
  298. jobId,
  299. url: resume.url,
  300. recommendUserId: isEmployment.value
  301. })
  302. } else {
  303. await jobCvRelSend({
  304. jobId,
  305. title: resume.title,
  306. url: resume.url,
  307. type: info.value.hire ? 1 : 0
  308. })
  309. }
  310. uni.showToast({ title: '投递成功', icon: 'none', duration: 2000, })
  311. deliveryCheck()
  312. popup.value.close()
  313. }
  314. const popupClose = () => {
  315. selectIndex.value = null
  316. popup.value.close()
  317. }
  318. // 发起聊天
  319. async function handleSend () {
  320. const userId = info.value.contact.userId
  321. const enterpriseId = info.value.contact.enterpriseId
  322. const textObj = {
  323. text: defaultText,
  324. positionInfo: positionInfo.value
  325. }
  326. const channel = await prologue({userId, enterpriseId, text: JSON.stringify(textObj)})
  327. console.log('channel', channel)
  328. // 跳转
  329. const query = {
  330. id: userId,
  331. name: info.value?.contact?.name,
  332. postName: info.value?.contact?.postNameCn,
  333. enterpriseName: info.value?.enterprise?.anotherName,
  334. enterpriseId: info.value?.enterpriseId,
  335. channelId: channel.channel_id,
  336. avatar: info.value?.contact?.avatar,
  337. sex: info.value?.contact?.sex,
  338. }
  339. console.log('query', query)
  340. const queryStr = Object.keys(query).reduce((r, v) => {
  341. return r += `${v}=${encodeURIComponent(query[v])}&`
  342. }, '?')
  343. uni.navigateTo({
  344. url: `/pagesA/chart/index${queryStr.slice(0, -1)}`
  345. })
  346. }
  347. // 效验求职者是否有收藏该职位
  348. const isCollection = ref(false)
  349. const getCollectionStatus = async () => {
  350. if (!getAccessToken()) return isCollection.value = false
  351. const { data } = await getJobFavoriteCheck({ jobId })
  352. isCollection.value = Boolean(data)
  353. }
  354. // 操作 收藏&取消收藏职位
  355. const handleCollection = async () => {
  356. const api = isCollection.value ? getPersonJobUnfavorite : getPersonJobFavorite
  357. await api(isCollection.value ? jobId : { jobId })
  358. await getCollectionStatus()
  359. }
  360. // 选取微信聊天文件
  361. // 上传附件
  362. const handleUpload = () => {
  363. wx.chooseMessageFile({
  364. count: 1,
  365. type: 'file',
  366. success (res) {
  367. const title = res.tempFiles[0].name
  368. const path = res.tempFiles[0].path
  369. //效验是否为支持的文件格式
  370. if(/\.(pdf|docx|doc)$/.test(title)){
  371. uploadFile(path).then(async (res) => {
  372. if (!res.data) {
  373. uni.showToast({
  374. title: '上传失败',
  375. icon: 'none'
  376. })
  377. return
  378. }
  379. await saveResume({ title, url: res.data })
  380. uni.showToast({
  381. title: '上传成功',
  382. icon: 'success'
  383. })
  384. deliverySubmit({ title, url: res.data })
  385. })
  386. }else{
  387. uni.showToast({
  388. icon: 'none',
  389. title: '请上传pdf、word类型的文件',
  390. duration: 2000
  391. })
  392. return
  393. }
  394. }
  395. })
  396. }
  397. // 分享
  398. const handleClickShare = () => {
  399. sharePopup.value.open()
  400. }
  401. //在点击open-type="share"按钮后会触发以下函数,可以在函数中写需要的逻辑,当然函数的返回值必须是一个对象,用于设置分享卡片的展示形式
  402. //发送给微信好友
  403. onShareAppMessage((res) => {
  404. let path = `/pagesB/positionDetail/index?id=${info.value.id}`
  405. if (info.value.hire) {
  406. path += `&userId=${info.value.userId}`
  407. }
  408. return {
  409. title: '我发现了一个好职位,快来看看吧', //分享的名称
  410. path
  411. }
  412. })
  413. // 获取设备信息
  414. function getSystemInfo(){
  415. return new Promise((resolve, reject) =>{
  416. uni.getSystemInfo({
  417. success: (result) => {
  418. console.log(result)
  419. resolve(result)
  420. },
  421. fail: (err) => {
  422. console.log(err)
  423. }
  424. })
  425. })
  426. }
  427. function roundedRect(ctx, x, y, width, height, radius, color) {
  428. ctx.beginPath();
  429. ctx.moveTo(x, y + radius);
  430. ctx.lineTo(x, y + height - radius);
  431. ctx.quadraticCurveTo(x, y + height, x + radius, y + height);
  432. ctx.lineTo(x + width - radius, y + height);
  433. ctx.quadraticCurveTo(x + width, y + height, x + width, y + height - radius);
  434. ctx.lineTo(x + width, y + radius);
  435. ctx.quadraticCurveTo(x + width, y, x + width - radius, y);
  436. ctx.lineTo(x + radius, y);
  437. ctx.quadraticCurveTo(x, y, x, y + radius);
  438. // ctx.fillStyle = "#f5f5f5";
  439. ctx.fillStyle = color;
  440. ctx.fill()
  441. ctx.strokeStyle = color
  442. ctx.stroke();
  443. }
  444. //微信获取图片信息
  445. function getImageTempRatio (url){
  446. return new Promise((resolve, reject)=>{
  447. wx.getImageInfo({
  448. src:url,
  449. success:(res) =>{
  450. resolve(res)
  451. }
  452. })
  453. })
  454. }
  455. /**
  456. *
  457. * @param text 文本
  458. * @param x 起始位置x
  459. * @param y 起始位置y
  460. * @param maxWidth 最大宽度
  461. * @param lineHeight 行高
  462. * @param ctx 画布上下文
  463. * @param type 类型 cut 截断+省略号 wrap 自动换行
  464. */
  465. function wrapText(text, x, y, maxWidth, lineHeight, ctx, type = 'cut') {
  466. const words = text.split(' '); // 按空格分割成单词
  467. let line = ''
  468. words.forEach((word) => {
  469. const testLine = line + word + ' '; // 测试当前行加上新单词
  470. const metrics = ctx.measureText(testLine); // 测量文本宽度
  471. // 检查是否超过最大宽度
  472. if (metrics.width > maxWidth && line) {
  473. if (type === 'wrap') {
  474. ctx.fillText(line, x, y); // 在当前 y 位置绘制当前行
  475. line = word + ' '; // 重置行并开始新的一行
  476. y += lineHeight; // 更新 y 位置
  477. }
  478. if (type === 'cut') {
  479. line = line.slice(0, -word.length - 2) + '...'; // 截断当前行并添加省略号
  480. }
  481. } else {
  482. line = testLine; // 如果没有超出宽度,更新当前行
  483. }
  484. })
  485. // 绘制剩余的文本
  486. ctx.fillText(line, x, y)
  487. }
  488. // 生成海报
  489. async function createPoster () {
  490. const top = 50
  491. const left = 30
  492. console.log(info.value)
  493. sharePopup.value.close()
  494. const res = await getSystemInfo()
  495. const { windowWidth, windowHeight } = res
  496. appInfo.value = {
  497. windowWidth, windowHeight
  498. }
  499. var context = uni.createCanvasContext('firstCanvas')
  500. //底色
  501. context.setFillStyle('#03877a')
  502. context.fillRect(0,0, windowWidth, windowHeight)
  503. // 职位信息
  504. // 名称
  505. context.setFillStyle('#FFF')
  506. context.font = 'normal bold 26px Microsoft YaHei'
  507. context.fillText(info.value.name, left, top)
  508. // 薪酬
  509. context.fillStyle = 'yellow';
  510. context.font = 'normal 22px Microsoft YaHei'
  511. const payText = `${info.value.payFrom}-${info.value.payTo} / ${positionInfo.value.payName}`
  512. const payWidth = context.measureText(payText).width;
  513. const rightX = windowWidth - payWidth - left;
  514. context.fillText(payText, rightX, top);
  515. // 地区|年限|学历
  516. const areaText = `${positionInfo.value?.areaName} | ${positionInfo.value?.eduName} | ${positionInfo.value?.expName}`
  517. context.setFillStyle('#FFF')
  518. context.font = 'normal 14px Microsoft YaHei'
  519. const subTitleH = top + 20
  520. context.fillText(areaText, left, subTitleH)
  521. // 企业信息卡片
  522. roundedRect(context, left, subTitleH + 20 , windowWidth - 2 * left , 50, 10, 'rgba(255, 255, 255, 0.45)')
  523. // 企业信息
  524. // const headerMsg = await getImageTempRatio(info.value.contact.avatar)
  525. // context.drawImage(
  526. // headerMsg.path,
  527. // left + 5,
  528. // subTitleH + 25,
  529. // 40,
  530. // 40
  531. // )
  532. // 企业信息
  533. context.setFillStyle('#FFF')
  534. context.font = 'normal 16px Microsoft YaHei'
  535. const emTextH = subTitleH + 50
  536. context.fillText(info.value.enterprise.anotherName, left + 20, emTextH)
  537. // 企业地点
  538. const _areaText = `${info.value.areaName}`
  539. const areaTextW = context.measureText(_areaText).width;
  540. const _rightX = windowWidth - areaTextW - left - 20;
  541. context.fillText(_areaText, _rightX, emTextH);
  542. // 福利
  543. // context.setFillStyle('#FFF')
  544. context.font = 'normal 14px Microsoft YaHei'
  545. const welfareH = emTextH + 40
  546. const welfareText = info.value.tagList && info.value.tagList.join(' ') || ''
  547. wrapText(welfareText, left, welfareH, windowWidth - 2 * left, 20, context)
  548. // 卡片
  549. const cardTop = welfareH + 20 // 卡片顶部距离
  550. const cardH = windowHeight - cardTop - 100 // 卡片高度
  551. roundedRect(context, 10, cardTop , windowWidth - 20 , cardH, 10,'#fff')
  552. // 岗位
  553. // context.setFillStyle('#000000')
  554. // context.setFontSize(20)
  555. // context.font = 'normal bold 20px Microsoft YaHei'
  556. // context.fillText('111',windowWidth/10, windowHeight * 0.2)
  557. // 地区频率时长薪资
  558. // context.setFillStyle('#6c6e7b')
  559. // context.setFontSize(15)
  560. // context.font = 'normal 15px Microsoft YaHei'
  561. // context.fillText(' | ',windowWidth/10, windowHeight * 0.2 + 30)
  562. // context.setFontSize(18)
  563. // context.font = 'normal 18px Microsoft YaHei'
  564. // context.setFillStyle('#f67272')
  565. // context.fillText('120/天', windowWidth/10, windowHeight * 0.2 + 60)
  566. // 小程序码/ 二维码
  567. // context.drawImage(
  568. // // image.path,
  569. // windowWidth *0.5 - windowWidth/8,
  570. // windowHeight * 0.60,
  571. // windowWidth/4,
  572. // windowWidth/4
  573. // )
  574. context.setFontSize(16)
  575. context.fillText('长按二维码查看岗位', windowWidth/3.2, windowHeight * 0.65 + windowWidth/4)
  576. context.draw(false, () =>{
  577. uni.showLoading({
  578. title: '加载中……',
  579. icon: 'none',
  580. })
  581. setTimeout(() => {
  582. wx.canvasToTempFilePath({
  583. canvasId: 'firstCanvas',
  584. x:0,
  585. y:0,
  586. success:(res)=>{
  587. console.log('成功', res)
  588. imgSrc.value = res.tempFilePath
  589. },
  590. fail:(err)=>{
  591. console.log('canvasToTemp-fail', err)
  592. },
  593. complete:()=>{
  594. uni.hideLoading();
  595. }
  596. })
  597. }, 3000)
  598. // canvas生成图片
  599. poster.value.open()
  600. })
  601. }
  602. </script>
  603. <style scoped lang="scss">
  604. @import '../../static/style/position/index.scss';
  605. .bottom-content {
  606. display: flex;
  607. justify-content: space-evenly;
  608. align-items: center;
  609. width: 100%;
  610. margin: 20rpx 0;
  611. .btnStyle {
  612. flex: 1;
  613. margin-right: 20rpx;
  614. }
  615. .bgButtons {
  616. border: 2rpx solid #00897b;
  617. color: #00897b;
  618. background: #FFF;
  619. border-radius: 50rpx;
  620. }
  621. &-tool {
  622. width: 160rpx;
  623. display: flex;
  624. justify-content: center;
  625. flex-direction: column;
  626. align-items: center;
  627. }
  628. }
  629. .share-pop {
  630. width: 100%;
  631. // height:300rpx;
  632. display: flex;
  633. justify-content: center;
  634. .f-straight {
  635. margin: 40rpx;
  636. background: unset;
  637. &::after{
  638. border:none !important;
  639. }
  640. }
  641. .share-round {
  642. border-radius:50%;
  643. height:100rpx;
  644. width:100rpx;
  645. display: flex;
  646. align-items: center;
  647. justify-content: center;
  648. }
  649. .share-round-1 {
  650. background-color:#22a039;
  651. }
  652. .share-round-2 {
  653. background-color:#3693cd;
  654. }
  655. }
  656. .preview {
  657. position: fixed;
  658. z-index: 9;
  659. height: 100vh;
  660. width: 100vw;
  661. left: 0;
  662. top: 0;
  663. .image {
  664. position: absolute;
  665. width: 80%;
  666. left: 10%;
  667. top: 100rpx;
  668. }
  669. }
  670. </style>