提交 9dc28abb 编写于 作者: Q qiang

fix: 修复 app-v3 uni.canvasToTempFilePath fileType 参数不生效的问题

上级 549d450b
......@@ -63,9 +63,10 @@ export const canvasPutImageData = {
}
}
const fileType = {
const fileTypes = {
PNG: 'png',
JPG: 'jpeg'
JPG: 'jpg',
JPEG: 'jpg'
}
export const canvasToTempFilePath = {
......@@ -103,7 +104,7 @@ export const canvasToTempFilePath = {
type: String,
validator (value, params) {
value = (value || '').toUpperCase()
params.fileType = value in fileType ? fileType[value] : fileType.PNG
params.fileType = value in fileTypes ? fileTypes[value] : fileTypes.PNG
}
},
quality: {
......
<template>
<uni-canvas
:canvas-id="canvasId"
:disable-scroll="disableScroll"
<uni-canvas
:canvas-id="canvasId"
:disable-scroll="disableScroll"
v-on="_listeners">
<canvas
ref="canvas"
width="300"
<canvas
ref="canvas"
width="300"
height="150" />
<div style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; overflow: hidden;">
<slot />
</div>
<v-uni-resize-sensor
ref="sensor"
<v-uni-resize-sensor
ref="sensor"
@resize="_resize" />
</uni-canvas>
</template>
......@@ -121,15 +121,15 @@ export default {
method(data)
}
},
_resize () {
var canvas = this.$refs.canvas
if (canvas.width > 0 && canvas.height > 0) {
var context = canvas.getContext('2d')
_resize () {
var canvas = this.$refs.canvas
if (canvas.width > 0 && canvas.height > 0) {
var context = canvas.getContext('2d')
var imageData = context.getImageData(0, 0, canvas.width, canvas.height)
wrapper(this.$refs.canvas)
context.putImageData(imageData, 0, 0)
} else {
wrapper(this.$refs.canvas)
wrapper(this.$refs.canvas)
context.putImageData(imageData, 0, 0)
} else {
wrapper(this.$refs.canvas)
}
},
_touchmove (event) {
......@@ -549,7 +549,8 @@ export default {
const img = new Image()
img.onload = () => {
const canvas = getTempCanvas(destWidth, destHeight)
if (fileType === 'jpeg') {
if (fileType === 'jpeg' || fileType === 'jpg') {
fileType = 'jpeg'
c2d.fillStyle = '#fff'
c2d.fillRect(0, 0, destWidth, destHeight)
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册