| | |
| | | qrCode: string |
| | | } |
| | | |
| | | function wait(ms: number) { |
| | | return new Promise(resolve => setTimeout(resolve, ms)) |
| | | } |
| | | |
| | | definePage({ |
| | | name: 'visitorCode', |
| | | layout: 'default', |
| | |
| | | errorCorrectionLevel: 'M', |
| | | margin: 1, |
| | | }) |
| | | const size = 400 |
| | | const size = 448 |
| | | const moduleCount = qr.modules.size |
| | | const tileSize = size / moduleCount |
| | | const canvasId = 'sharedVisitorQrCanvas' |
| | |
| | | } |
| | | |
| | | context.draw(false, () => { |
| | | uni.canvasToTempFilePath({ |
| | | canvasId, |
| | | width: size, |
| | | height: size, |
| | | destWidth: size * 2, |
| | | destHeight: size * 2, |
| | | success: res => resolve(res.tempFilePath), |
| | | fail: reject, |
| | | void wait(500).then(() => { |
| | | uni.canvasToTempFilePath({ |
| | | canvasId, |
| | | width: size, |
| | | height: size, |
| | | destWidth: size * 2, |
| | | destHeight: size * 2, |
| | | success: res => resolve(res.tempFilePath), |
| | | fail: reject, |
| | | }) |
| | | }) |
| | | }) |
| | | }) |
| | |
| | | ]) |
| | | detail.value = detailData |
| | | order.value = codeData |
| | | qrCodes.value = await Promise.all((codeData.qrCodes || []).map(async ticket => ({ |
| | | ...ticket, |
| | | qrCode: await createQrImage(ticket.payload), |
| | | }))) |
| | | const hydratedCodes: VisitorCodeDisplayTicket[] = [] |
| | | for (const ticket of (codeData.qrCodes || [])) { |
| | | hydratedCodes.push({ |
| | | ...ticket, |
| | | qrCode: await createQrImage(ticket.payload), |
| | | }) |
| | | } |
| | | qrCodes.value = hydratedCodes |
| | | currentTicketIndex.value = 0 |
| | | } |
| | | catch (error) { |
| | |
| | | } |
| | | |
| | | function buildSharePath() { |
| | | return orderUuid.value ? `/pages/visitorCode/index?uuid=${encodeURIComponent(orderUuid.value)}` : '/pages/index/index' |
| | | const ticketUuid = currentTicket.value?.ticketUuid || '' |
| | | return ticketUuid |
| | | ? `/pages/visitorCodeShare/index?ticketUuid=${encodeURIComponent(ticketUuid)}` |
| | | : '/pages/index/index' |
| | | } |
| | | |
| | | onShareAppMessage(() => ({ |
| | | title: detail.value?.visitedUserDisplay ? `${detail.value.visitedUserDisplay}的访客码` : '访客码分享', |
| | | title: '访客码的分享', |
| | | path: buildSharePath(), |
| | | })) |
| | | |
| | |
| | | position: fixed; |
| | | left: -9999px; |
| | | top: -9999px; |
| | | width: 400px; |
| | | height: 400px; |
| | | width: 448px; |
| | | height: 448px; |
| | | opacity: 0; |
| | | pointer-events: none; |
| | | } |