Browse Source

预览文件名调整

Xiao_123 2 months ago
parent
commit
5178054272
3 changed files with 9 additions and 6 deletions
  1. 1 1
      pages/index/position.vue
  2. 1 1
      pagesB/jobFair/jobFairEntShare.vue
  3. 7 4
      pagesB/jobFair/jobFairShare.vue

+ 1 - 1
pages/index/position.vue

@@ -35,7 +35,7 @@
             <view class="white-bgc px-10 stickFilter">
             <FilterList :list="filterList" idValue="label" @change="handleSearch"></FilterList>
           </view>
-          <PositionList :list="positionListData" :noMore="false" :showJobFairEntrance="false"></PositionList>
+          <PositionList :list="positionListData" :noMore="false" :showJobFairEntrance="true"></PositionList>
           <uni-load-more :status="more" />
         </view>
       </scroll-view>

+ 1 - 1
pagesB/jobFair/jobFairEntShare.vue

@@ -92,7 +92,7 @@ const getImageTempRatio = (url) => {
 
 const getToLocal = (base64data) => {
   const fsm = wx.getFileSystemManager()
-  const FILE_BASE_NAME = 'tmp_base64src'; //自定义文件名
+  const FILE_BASE_NAME = `tmp_${new Date().getTime()}` // 自定义文件名
   const [, format, bodyData] = /data:image\/(\w+);base64,(.*)/.exec(base64data) || []
   if (!format) {
     return (new Error('ERROR_BASE64SRC_PARSE'))

+ 7 - 4
pagesB/jobFair/jobFairShare.vue

@@ -94,7 +94,7 @@ const getImageTempRatio = (url) => {
 const getToLocal = (base64data) => {
   return new Promise((resolve, reject) => {
     const fsm = wx.getFileSystemManager()
-    const FILE_BASE_NAME = 'tmp_base64src' // 自定义文件名
+    const FILE_BASE_NAME = `tmp_${new Date().getTime()}` // 自定义文件名
     const [, format, bodyData] = /data:image\/(\w+);base64,(.*)/.exec(base64data) || []
     if (!format) {
       reject(new Error('ERROR_BASE64SRC_PARSE'))
@@ -107,7 +107,6 @@ const getToLocal = (base64data) => {
       data: buffer,
       encoding: 'binary',
       success(r) {
-        qrCode.value = filePath
         resolve(filePath) // 成功时返回 filePath
       },
       fail() {
@@ -122,21 +121,24 @@ const qrCode = ref()
 const handleShareCode = async () => {
   const result = await saveShareQuery({ jobFairId })
 	const query = {
-		scene: 'id=' + result.data,
+    scene: 'id=' + result.data,
     path: `pagesB/jobFair/${!isEnt ? 'enterprisesClassification' : 'positionClassification'}`,
 		width: 200,
 		autoColor: false,
 		checkPath: true,
 		hyaline: false // 二维码背景颜色为透明
 	}
+  console.log(result.data, query.scene, '=========================')
 	const res = await getJobAdvertisedShareQrcode(query, { noAuth: true })
 	const data = res?.data ? 'data:image/png;base64,' + res.data : ''
-  await getToLocal(data) // 等待 getToLocal 完成
+  const filePath = await getToLocal(data) // 等待 getToLocal 完成
+  qrCode.value = filePath
 }
 
 const createPoster = async () => {
   uni.showLoading({ title: '生成中...', mask: true })
   await handleShareCode() // 生产分享二维码
+
   var context = uni.createCanvasContext('posterCanvas')
 
   //清空画布
@@ -151,6 +153,7 @@ const createPoster = async () => {
   const qrCodeHeight = 127
   const qrCodeX = 188
   const qrCodeY = 585
+  console.log('dddd', qrCode.value)
   context.drawImage(qrCode.value, qrCodeX, qrCodeY, qrCodeWidth, qrCodeHeight)
   
   context.font = 'bold 16px Arial'