开发者社区> 问答> 正文

宜搭如何接收base64字符串?

求大神解答,现在钉钉的哪个接口可接收图片base64字符串? 或者有没有什么办法能把base64字符串转化为符合钉钉接口的传输格式。

展开
收起
游客6pqh5skenwlyg 2022-12-14 10:31:09 319 0
1 条回答
写回答
取消 提交回答
  • 十分耕耘,一定会有一分收获!

    楼主你好,看一下这个方法可以不: // pages Page({ data: { width: null, height: null, }, // 拍照 tap(e) { const that = this; dd.chooseImage({ /** 调取相册*/ // sourceType: ['camera', 'album'], sourceType: ['camera'], count: 1, success: (res1) => { console.log('res1', res1); dd.showLoading({ content: '转码中...' }); dd.compressImage({ filePaths: res1.filePaths, compressLevel: 1, success: (res2) => { console.log(res2) // 获取图片信息 dd.getImageInfo({ src: res2.filePaths[0], success: (res) => { console.log(res.width, 'res') const { width, height, path } = res; that.setData({ width, height }); const ctx = dd.createCanvasContext('canvas'); ctx.drawImage(path, 0, 0, width, height); ctx.draw(true, () => { // 获取画布指定区域的 data URL 数据 ctx.toDataURL({ x: 0, y: 0, width: width, height: height, destWidth: width, destHeight: height, }).then(dataURL => { console.log(dataURL) // 获取base64数据 return dataURL }).then(res => { dd.hideLoading(); // that.imageToWordCode(res); // 将base64数据传给后台的方法 }) }) } }) } }); }, fail: (e) => { console.log('fail---') } }) }, });

    2022-12-14 11:19:16
    赞同 1 展开评论 打赏
问答分类:
问答标签:
问答地址:
关联地址:
问答排行榜
最热
最新

相关电子书

更多
宜搭 - 企业智能化应用搭建平台 立即下载
《云市场-宜搭解决方案》 立即下载
《宜搭开发手册》 立即下载