6155前端功能完成
This commit is contained in:
@ -1,16 +1,11 @@
|
||||
<template>
|
||||
<view>
|
||||
|
||||
<canvas canvas-id="splashCanvas"
|
||||
style="width: 160px; height: 80px; z-index: 9999;position: fixed; visibility: visible;top: 0px;left:0px;"
|
||||
|
||||
</canvas>
|
||||
|
||||
<qf-image-cropper :src="src" :showAngle="false" :width="1600" :height="800" fileType="jpg"
|
||||
@crop="handleCrop" :gpu="true">
|
||||
</qf-image-cropper>
|
||||
|
||||
|
||||
<canvas id="splashCanvas" canvas-id="splashCanvas" style="width: 160px; height: 80px; z-index: 9999;position: fixed; visibility: hidden;"></canvas>
|
||||
|
||||
|
||||
<qf-image-cropper :src="src" :showAngle="false" :width="1600" :height="800" fileType="jpg"
|
||||
@crop="handleCrop" :gpu="true">
|
||||
</qf-image-cropper>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
@ -22,64 +17,58 @@
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
src:"",
|
||||
src: "",
|
||||
Statu: false
|
||||
|
||||
|
||||
}
|
||||
},
|
||||
onLoad:function(option){
|
||||
const eventChannel = this.getOpenerEventChannel();
|
||||
var these=this;
|
||||
eventChannel.on('checkImg', function(data) {
|
||||
console.log("我收到你的消息了,消息内容是:"+JSON.stringify(data));
|
||||
these.src=data.data;
|
||||
})
|
||||
onLoad: function(option) {
|
||||
const eventChannel = this.getOpenerEventChannel();
|
||||
var these = this;
|
||||
eventChannel.on('checkImg', function(data) {
|
||||
console.log("我收到你的消息了,消息内容是:" + JSON.stringify(data));
|
||||
these.src = data.data;
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
handleCrop(e) {
|
||||
var these=this;
|
||||
var these = this;
|
||||
this.Statu = true;
|
||||
console.log("裁剪完成");
|
||||
console.log(e.tempFilePath);
|
||||
|
||||
|
||||
const ctx = uni.createCanvasContext('splashCanvas', these);
|
||||
console.log("1111111");
|
||||
// 绘制图片到canvas
|
||||
ctx.drawImage(e.tempFilePath, 0, 0, 160, 80);
|
||||
console.log("22222");
|
||||
ctx.draw(false, () => {
|
||||
// 获取canvas像素数据
|
||||
console.log("444444");
|
||||
setTimeout(() => {
|
||||
uni.canvasGetImageData({
|
||||
canvasId: 'splashCanvas',
|
||||
x: 0,
|
||||
y: 0,
|
||||
width: 160,
|
||||
height: 80,
|
||||
success: (res) => {
|
||||
// 处理像素数据并发送
|
||||
console.log("res.data.length="+res.data.length);
|
||||
// this.processAndSendImageData(res.data).then(
|
||||
// resolve).catch(reject);
|
||||
const eventChannel = these.getOpenerEventChannel();
|
||||
eventChannel.emit('ImgCutOver',res.data);
|
||||
uni.navigateBack();
|
||||
},
|
||||
fail: (err) => {
|
||||
reject(`获取canvas数据失败: ${err.errMsg}`);
|
||||
}
|
||||
});
|
||||
}, 500); // 等待canvas绘制完成
|
||||
});
|
||||
|
||||
console.log("333333");
|
||||
|
||||
|
||||
|
||||
const ctx = uni.createCanvasContext('splashCanvas', this);
|
||||
ctx.drawImage(
|
||||
e.tempFilePath,
|
||||
0,0,160,80
|
||||
);
|
||||
setTimeout(() => {
|
||||
ctx.draw(false, ()=>{
|
||||
console.log("abcdefg")
|
||||
uni.canvasGetImageData({
|
||||
canvasId: 'splashCanvas',
|
||||
x: 0,
|
||||
y: 0,
|
||||
width: 160,
|
||||
height: 80,
|
||||
success: (res) => {
|
||||
// 处理像素数据并发送
|
||||
console.log("res.data.length="+res.data.length);
|
||||
// this.processAndSendImageData(res.data).then(
|
||||
// resolve).catch(reject);
|
||||
const eventChannel = these.getOpenerEventChannel();
|
||||
eventChannel.emit('ImgCutOver',res.data);
|
||||
uni.navigateBack();
|
||||
},
|
||||
fail: (err) => {
|
||||
reject(`获取canvas数据失败: ${err.errMsg}`);
|
||||
}
|
||||
});
|
||||
});
|
||||
}, 500);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
@ -503,9 +503,9 @@ import { deviceReName } from '../../api/common';
|
||||
|
||||
|
||||
//发送数据包
|
||||
sendDataNew(f.deviceId, f.writeServiceId, f.wirteCharactId, buffer)
|
||||
ble.sendDataNew(f.deviceId, f.writeServiceId, f.wirteCharactId, buffer)
|
||||
.then(() => {
|
||||
|
||||
console.log("发送一个包完成了");
|
||||
these.Status.Progress.curr = currentPacket;
|
||||
currentPacket++;
|
||||
|
||||
|
Reference in New Issue
Block a user