- 鸿蒙next系统5.1.0,微信1.0.9。canvas.createImage创建的图片为黑屏?
[图片] [图片] [图片] bindTakePhoto() { const cameraContext = wx.createCameraContext(); const photoProp = { quality: 'high' }; cameraContext.takePhoto(photoProp) .then((res) => { this.drawPhoto(res.tempImagePath); }) .catch((error) => { logger.error(error) // console.log(error) }) }, /** * 画照片 */ async drawPhoto(filePath) { const ctx = this.canvas.getContext('2d') const dpr = app.globalData.screenHeight / app.globalData.rpxScreenHeight; const canvasWidth = this.data.canvasWidth * dpr; const canvasHeight = this.data.canvasHeight * dpr; //画照片 await new Promise((resolve) => { const photoImage = this.canvas.createImage() photoImage.onload = () => { const photoWidth = canvasWidth; const photoHeight = canvasHeight; const x = 0; const y = 0; const direction = this.data.direction; if (direction == 'left') { ctx.translate(0, photoHeight); ctx.rotate(-Math.PI / 2); ctx.drawImage(photoImage, x, y, photoHeight, photoWidth); ctx.rotate(Math.PI / 2); ctx.translate(0, -photoHeight); } else if (direction == 'right') { ctx.translate(photoWidth, 0); ctx.rotate(Math.PI / 2); ctx.drawImage(photoImage, x, y, photoHeight, photoWidth); ctx.rotate(-Math.PI / 2); ctx.translate(-photoWidth, 0); } else { ctx.drawImage(photoImage, x, y, photoWidth, photoHeight); } // console.log('已画照片'); resolve('已画照片') } photoImage.onerror = () => { // console.log('照片加载失败'); resolve(); } photoImage.src = filePath; }) //画现场水印 if (this.data.liveWatermark && this.data.liveWatermarkValue && this.data.liveWatermarkValue != '') { await new Promise((resolve) => { const liveWatermarkImage = this.canvas.createImage() liveWatermarkImage.onload = () => { const liveWatermarkWidth = dpr * 360; const liveWatermarkHeight = dpr * 90; const x = canvasWidth / 2 - liveWatermarkWidth / 2; const y = canvasHeight / 2 - liveWatermarkHeight / 2; ctx.drawImage(liveWatermarkImage, x, y, liveWatermarkWidth, liveWatermarkHeight); // console.log('已画现场水印', this.data.liveWatermarkValue); resolve('已画现场水印'); } liveWatermarkImage.onerror = () => { // console.log('现场水印加载失败', this.data.liveWatermarkValue); resolve(); } liveWatermarkImage.src = this.data.liveWatermarkValue; }) } //画手写签名水印 if (this.data.handWriting && this.data.handWriting != '') { await new Promise((resolve) => { const handWritingImage = this.canvas.createImage() handWritingImage.onload = () => { const handWritingWidth = dpr * 150; const handWritingHeight = dpr * 150; const x = canvasWidth - handWritingWidth - 10; const y = canvasHeight - 10; ctx.translate(x, y); ctx.rotate(-Math.PI / 2); ctx.drawImage(handWritingImage, 0, 0, handWritingWidth, handWritingHeight); ctx.rotate(Math.PI / 2); ctx.translate(-x, -y); // console.log('已画手写签名水印'); resolve('已画手写签名水印'); } handWritingImage.onerror = () => { // console.log('手写签名水印加载失败'); resolve(); } handWritingImage.src = this.data.handWriting; }) } //画水印LOGO if (this.data.logoEnable && this.data.logo && this.data.logo != '') { // console.log('画水印LOGO'); await new Promise((resolve) => { const logoImage = this.canvas.createImage() logoImage.onload = () => { const logoWidth = dpr * 150; const logoHeight = dpr * 150; const x = canvasWidth - logoWidth - 10; const y = 10; //水印LOGO透明度 const alpha = 1 - app.globalData.logoTransparency * 5 / 100; ctx.globalAlpha = alpha; ctx.drawImage(logoImage, x, y, logoWidth, logoHeight); ctx.globalAlpha = 1; // console.log('已画水印LOGO'); resolve('已画水印LOGO'); } logoImage.onerror = () => { // console.log('水印LOGO加载失败'); resolve(); } logoImage.src = this.data.logo; }) } // console.log('画水印信息'); //设置画笔 ctx.font = '14px'; ctx.fillStyle = this.data.watermarkFontColor; //颜色 const watermarkX = 10; const watermarkY = canvasHeight - 14; const lineHeight = 18; let i = 0; //备注 const remarkArr = this.data.remarkArr; if (remarkArr && remarkArr.length > 0) { for (let index = remarkArr.length - 1; index >= 1; index--) { const element = remarkArr[index]; ctx.fillText(element, watermarkX + 42, watermarkY - (i++) * lineHeight); } const firstRemark = remarkArr[0]; ctx.fillText('备注:' + firstRemark, watermarkX, watermarkY - (i++) * lineHeight); } //天气 if (this.data.weather && this.data.weatherValue) { ctx.fillText('天气:' + this.data.weatherValue, watermarkX, watermarkY - (i++) * lineHeight); } //海拔 if (this.data.altitude && this.data.altitudeValue) { ctx.fillText('海拔:' + this.data.altitudeValue, watermarkX, watermarkY - (i++) * lineHeight); } //时间 if (this.data.currentTime) { ctx.fillText('时间:' + this.data.currentTime, watermarkX, watermarkY - (i++) * lineHeight); } //地址 if (this.data.address && this.data.addressValue) { ctx.fillText('地址:' + this.data.addressValue, watermarkX, watermarkY - (i++) * lineHeight); } //纬度 //经度 if (this.data.lonLat && this.data.latitudeValue && this.data.longitudeValue) { ctx.fillText('纬度:' + this.data.latitudeValue, watermarkX, watermarkY - (i++) * lineHeight); ctx.fillText('经度:' + this.data.longitudeValue, watermarkX, watermarkY - (i++) * lineHeight); } this.savaToTempFile(); }, /** * canvas到临时文件 */ savaToTempFile() { let that = this wx.canvasToTempFilePath({ canvas: this.canvas, fileType: 'jpg' }).then(res => { // console.log(res); const filePath = res.tempFilePath //照片路径 this.setData({ tempImagePath: res.tempFilePath }) wx.saveImageToPhotosAlbum({ filePath: res.tempFilePath, success: function () { }, }) wx.compressImage({ src: filePath, //图片路径 quality: 60, // 压缩质量 success: image => { this.setLastPageFlag(true); this.wmCamera.goFormPage(image.tempFilePath) }, fail: (err) => { this.setLastPageFlag(true); this.wmCamera.goFormPage(image.tempFilePath) } }) // this.saveToPhotosAlbum(res.tempFilePath); }).catch(error => { logger.error(error) // console.log(error); }) },
08-11 - 我们业务场景是在短信连接拉起h5,跳转至小程序收银台收费,但微信支付平台一直提示风险,如何处理?
我们业务场景是在短信连接拉起h5,跳转至小程序收银台收费,但微信支付平台一直提示风险,如何处理?[图片]
2024-08-15 - 有奖体验|5分钟快速上线,超多小程序模板等你来上线?!
热点话题说来就来,活动上线迫不及待,程序员根本忙不过来? 活动上线很频繁,数据管理很麻烦,人手不够去哪里凑? …… 面对更紧密的发布节奏、更复杂的管理系统,开发者们如何快速应对,满足业务需求? 不用担心!微信云开发最新上线 云模板 能力,解放开发者的生产力! 优势一:超多模板选择 已上线抽奖、投票、签到等多款常用模板,一键选择即可快速应用,实用性超强 [图片] 优势二:一键便捷操作 仅需一键操作即可轻松配置页面,同时支持直接导出源码进行自定义调整,实现灵活定制化 [图片] 优势三:全面管理后台 云模板直接打通登录态,自动获取登录信息;同时配备管理后台,一站式管理多种需求 [图片] 为了更好地满足用户需求,欢迎各位开发者在下方评论区分享你想要的模板和场景。官方团队将在 4 月 6 日前精选相关模板 idea 并给对应用户赠送超可爱的周边礼物 1 份!同时官方团队将优先上线热门模板,更好地满足你的开发需求。 [图片] 现在点击微信开发者工具,创建云开发项目目录,右键一下即可接入云模板👇 [图片] 想了解更多云模板的最佳实践,查看以下干货内容,更快上手,更快上线! 最佳实践 1:搭建活动页面可以有多快?带你来看小程序云模板最佳实践 2:解锁新的小程序邀请函页面搭建方式官方文档:云模板能力介绍
2024-03-19 - 公众号认证已交费,如何联系人工客服进行认证?
公众号认证费已交,现确定要更名,11.7日认证到期,如何联系人工客服进行认证。
2023-11-01 - 微信商户平台现金红包功能“单笔发放金额”如何调整大于200?
现金红包功能 已经合并成了 商家红包,原先现金红包可以发放超过200的红包。 现在申请了功能后,上限只支持200元。 从官方文档和客服的回复看都是可以支持超过200的,请问需要如何申请 [图片] [图片][图片]
2023-10-17 - 多端框架全新上线!支持快速构建移动应用,你有什么新想法?
Donut 多端框架 支持使用小程序原生语法与工具开发移动应用,实现多端共用一套代码开发,有效降低研发与维护成本,提升开发效率和体验。 [图片] 功能亮点轻松解锁: 更高的开发效率:支持小程序原生语法,一次开发,多端编译和运行,实现高效开发 更低的开发门槛:全流程的开发工具,简单易用,让你轻松上手 更优质的用户体验:为用户带来接近原生界面的流畅交互体验 更丰富的业务场景:满足小程序与移动多端应用联动需求,拓展更多渠道场景,助力业务发展 多端框架现已全新上线!可分钟内体验你的多端应用,详情可查看 快速体验多端应用。也欢迎各位开发者访问 官网 以及 官方文档 了解更多内容。 为更好地满足开发者需求,欢迎广大开发者积极分享对多端框架的需求和建议。即日起至 2023 年 7 月 29 日,在评论区分享对多端框架的需求以及建议,精选评论的用户将获得官方精美礼品一份。 [图片] * 获奖名单将在「微信开放社区」本话题评论区进行公示
2023-06-27 - 微信小程序内嵌webview,上传图片拍照后,点击“使用图片”就会刷新到首页?
微信小程序内嵌webview,上传图片拍照后,点击“使用图片”就会刷新到首页,h5使用的组件:van-uploader 微信版本:8.0.36 手机型号包括但不限于iphone8/14.2 、 iPhone12/ios16.1 、 Mi10/Android13等多个手机都出现问题 微信社区也有类似的问题: 1.https://developers.weixin.qq.com/community/develop/doc/000c663fbc8850ceb6ee81f9451c00 2.https://developers.weixin.qq.com/community/develop/doc/000044af2fc6f806ee3eb678256800?_at=1682411197232 3.https://developers.weixin.qq.com/community/develop/doc/0002c4b71942e0dfdb9e9a91d51000?_at=1682411197232 这种高频问题从19年到23年都没给个确切解决方案!
2023-04-25 - 在微信开放平台成为第三方平台型服务商如何获得小程序票据?
1.在创建的时候就同时选择了平台型和定制型,现在在设置界面中只显示了平台型,平台型是否不能获取定制性的小程序绑定票据? 2.现在代理商需要我们的提供票据,才能上架服务。如何才能获取小程序绑定票据?重新注册还是有其他方式?
2022-06-07 - 微信小程序人脸识别可以使用第三方开发吗?
小程序需要用户通过摄像头左右扭头之类的动作通过人脸识别上传照片,不涉及采集用户姓名和身份证等信息,可以审核通过吗
2021-07-30 - 你有使用过小商店增值服务市场吗?对于平台提供的服务和能力有什么需求或建议呢?
微信小商店增值服务市场是微信平台与第三方合作伙伴共建的一项第三方服务能力。 对于服务商来说,成为微信小商店增值服务商你可以创建基于小商店及小商店开放组件的增值服务并发布到服务市场。 对于商家来说,小商店增值服务市场可以提供便捷选购需要的服务并通过授权的方式使用的能力。 目前小商店增值服务市场已开放商品管理、订单物流管理、装修与营销、ERP等服务,未来也将陆续开放接入CRM、智能客服、营销等经营工具类服务。希望和第三方合作伙伴共同打造更好的小商店服务生态,助力商家经营成长。 作为服务商,你对目前的增值服务市场有什么问题与看法呢?希望平台提供哪些有力的支持呢? 作为商家,你认为哪些增值服务最实用?希望将来上架什么新的服务? 欢迎到下方评论区分享你的期待以及建议。 [图片] 了解更多入驻相关内容,可点击查看微信小商店增值服务商入驻指引。 参与本话题优秀回答者将获得微信正版周边礼品一份,快来参加吧! [图片] [图片] [图片] [图片] [图片] *图片仅供参考,实际奖品选择与发放将视官方周边更新与存货情况进行适当调整 *获奖情况将在后续「社区每周」公告中进行公示长
2020-12-08