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