- 画布保存为图片,仿真时保存正常,真机调试时图片几乎全黑,这是为什么?
[图片] [图片] 这是保存的图片,下边是调试时保存的,上边一个是真机调试,内容一样但保存不一样。下面是保存部分的代码。 that.data.ccp.draw(false, function () { console.log("downImg "); setTimeout(function () { console.log("that.data.ccp.draw "); let params = { x: 0, y: 0, width: 265, height: 130, destWidth: 212, destHeight: 104, canvasId: 'cardcanvas', fileType: 'jpg', } wxCanvasToTempFilePath(params).then(res => { console.log("wxCanvasToTempFilePath ", JSON.stringify(res)); let params = { tempFilePath: res.tempFilePath, } return wxSaveFile(params) }).then(res => { let temp_cardpath = res.savedFilePath console.log("wxSaveFile ", JSON.stringify(res)); that.setData({ cardpath: temp_cardpath }) } 哪位大神碰到过,走过路过的帮忙看看啦!谢谢各位
2019-08-19 - getBLEDeviceServices "errCode":10004
- 当前 Bug 的表现(可附上截图) 小米9 真机调试蓝牙 总出现10004 code ,不知道原因,偶尔不会出现 14:16:40.702 index.js:40 openBluetoothAdapter success {errMsg: "openBluetoothAdapter:ok"} 14:16:40.913 index.js:75 startBluetoothDevicesDiscovery success {errCode: 0, errMsg: "startBluetoothDevicesDiscovery:ok", isDiscovering: true} 14:16:43.572 index.js:115 createBLEConnection success {"errCode":0,"errMsg":"createBLEConnection:ok"} 14:16:44.005 index.js:152 getBLEDeviceServices 34:03:DE:58:7C:3D fail {"errCode":10004,"errMsg":"getBLEDeviceServices:fail:no service"} - 预期表现 - 复现路径 - 提供一个最简复现 Demo 官方蓝牙demo修改的 openBluetoothAdapter() { wx.openBluetoothAdapter({ success: (res) => { console.log('openBluetoothAdapter success', res) this.startBluetoothDevicesDiscovery() }, fail: (res) => { if (res.errCode === 10001) { wx.onBluetoothAdapterStateChange(function (res) { console.log('onBluetoothAdapterStateChange', res) if (res.available) { this.startBluetoothDevicesDiscovery() } }) } } }) }, getBluetoothAdapterState() { wx.getBluetoothAdapterState({ success: (res) => { console.log('getBluetoothAdapterState', res) if (res.discovering) { this.onBluetoothDeviceFound() } else if (res.available) { this.startBluetoothDevicesDiscovery() } } }) }, startBluetoothDevicesDiscovery() { if (this._discoveryStarted) { return } this._discoveryStarted = true wx.startBluetoothDevicesDiscovery({ allowDuplicatesKey: true, success: (res) => { console.log('startBluetoothDevicesDiscovery success', res) this.onBluetoothDeviceFound() }, }) }, stopBluetoothDevicesDiscovery() { wx.stopBluetoothDevicesDiscovery() }, onBluetoothDeviceFound() { wx.onBluetoothDeviceFound((res) => { res.devices.forEach(device => { if (!device.name && !device.localName) { return } const foundDevices = this.data.devices const idx = inArray(foundDevices, 'deviceId', device.deviceId) const data = {} if (idx === -1) { data[`devices[${foundDevices.length}]`] = device } else { data[`devices[${idx}]`] = device } this.setData(data) }) }) }, onBLEConnectionStateChange(){ wx.onBLEConnectionStateChange(function (res) { // 该方法回调中可以用于处理连接意外断开等异常情况 console.log(`device ${res.deviceId} state has changed, connected: ${res.connected}`) }) }, createBLEConnection(e) { var that = this const ds = e.currentTarget.dataset const deviceId = ds.deviceId const name = ds.name wx.createBLEConnection({ deviceId, success: (res) => { console.log('createBLEConnection success', JSON.stringify(res)) this.setData({ connected: true, name, deviceId, }) //this.getBLEDeviceServices(deviceId) setTimeout(function () { that.getBLEDeviceServices(deviceId) }, 300) setInterval(function () { that.onBLEConnectionStateChange()},5000) } }) this.stopBluetoothDevicesDiscovery() }, closeBLEConnection() { wx.closeBLEConnection({ deviceId: this.data.deviceId }) this.setData({ connected: false, chs: [], canWrite: false, }) }, getBLEDeviceServices(deviceId) { var that =this wx.getBLEDeviceServices({ deviceId, success: (res) => { console.log('getBLEDeviceServices ' + deviceId+ ' success', JSON.stringify(res)) for (let i = 0; i < res.services.length; i++) { if (res.services[i].isPrimary && res.services[i].uuid.indexOf("0000FFF0") != -1) { this.getBLEDeviceCharacteristics(deviceId, res.services[i].uuid) } } }, fail:(res)=>{ console.log('getBLEDeviceServices ' + deviceId + ' fail', JSON.stringify(res)) //setTimeout(function () { that.getBLEDeviceServices(deviceId)} , 3000 ) } }) }, getBLEDeviceCharacteristics(deviceId, serviceId) { wx.getBLEDeviceCharacteristics({ deviceId, serviceId, success: (res) => { console.log('getBLEDeviceCharacteristics2 success', JSON.stringify(res)) //console.log('getBLEDeviceCharacteristics1 success', res.characteristics) for (let i = 0; i < res.characteristics.length; i++) { let item = res.characteristics[i] if (item.properties.read) { wx.readBLECharacteristicValue({ deviceId, serviceId, characteristicId: item.uuid, }) } if (item.properties.write && item.uuid.indexOf("0000FFF2") != -1) { this.setData({ canWrite: true, ble_status:1, }) this._deviceId = deviceId this._serviceId = serviceId this._characteristicId = item.uuid this.writeBLECharacteristicValue() } if (item.properties.notify || item.properties.indicate) { wx.notifyBLECharacteristicValueChange({ deviceId, serviceId, characteristicId: item.uuid, state: true, }) } } }, fail(res) { console.error('getBLEDeviceCharacteristics', res) } }) // 操作之前先监听,保证第一时间获取数据 wx.onBLECharacteristicValueChange((characteristic) => { const idx = inArray(this.data.chs, 'uuid', characteristic.characteristicId) const data = {} if (idx === -1) { data[`chs[${this.data.chs.length}]`] = { uuid: characteristic.characteristicId, value: ab2hex(characteristic.value) } } else { data[`chs[${idx}]`] = { uuid: characteristic.characteristicId, value: ab2hex(characteristic.value) } } // data[`chs[${this.data.chs.length}]`] = { // uuid: characteristic.characteristicId, // value: ab2hex(characteristic.value) // } this.setData(data) }) }, writeBLECharacteristicValue() { // 向蓝牙设备发送一个0x00的16进制数据 console.log('开始写入数据') let buffer = new ArrayBuffer(20) let dataView = new DataView(buffer) // dataView.setUint8(0, Math.random() * 255 | 0) for (let i = 0; i < 20; i++) { dataView[i] = i } wx.writeBLECharacteristicValue({ deviceId: this._deviceId, serviceId: this._serviceId, characteristicId: this._characteristicId, value: buffer, success: (res) => { console.log('writeBLECharacteristicValue success', JSON.stringify(res)) this.writeBLECharacteristicValue() }, fail: (res) => { console.log('writeBLECharacteristicValue fail', JSON.stringify(res)) //writeBLECharacteristicValue() } }) }, closeBluetoothAdapter() { wx.closeBluetoothAdapter() this._discoveryStarted = false this.setData({ ble_status: 0, }) },
2019-07-16 - 小程序蓝牙下载如何提高速度
最近需要使用蓝牙分包下载图片信息到硬件中,但速度太过缓慢,2756字节数据需要数分钟才能完成,大家有没有遇到过类似的问题,如何提高下载速度啊?交流一下
2019-07-10 - 本地保存图片成功后,如何在下个界面显示???
有A,B,C三个界面,在B界面编辑画布并将图片路径保存在全局变量里,保存成功,请问如何在C界面显示啊? 保存的路径: [图片] 在C界面WXML中 <image class='CardImg' src="{{(jvCardNum>=2)?'ljvImgUrl2':'/img/carddemo.png'}}" 报错: [图片]
2019-03-19 - 大家有没有遇到过 cannot read property 'appId' of
[图片] - 当前 Bug 的表现(可附上截图) paused on exception typeError: cannot read property 'appId' of undefine - 预期表现 什么叫预期表现 - 复现路径 什么路径 - 提供一个最简复现 Demo 什么demo 就提个问题 这么多事儿
2018-12-11