exportStatisticsHour导出的数据如何发送到其他app

小程序开发相关产品技术讨论,包括面板、智能小程序、React Native、Ray跨端框架、Panel SDK、微信小程序、小程序开发工具(IDE)及其他开发技术相关等话题


Post Reply
silverlight
Posts: 151

目前这个api只能导出到邮箱里,但是我发现有款小程序,可以将数据分享到其他app中,我想知道是怎么实现的

Attachments
导出3.png
导出2.png
导出1.png

Tags:
crisiron
Posts: 120

Re: exportStatisticsHour导出的数据如何发送到其他app

调用 share, 可调起 app的分享方法, https://developer.tuya.com/cn/miniapp/d ... iner/share

silverlight
Posts: 151

Re: exportStatisticsHour导出的数据如何发送到其他app

crisiron 2025年 Apr 1日 15:29

调用 share, 可调起 app的分享方法, https://developer.tuya.com/cn/miniapp/d ... iner/share

你好,share可以分享文件这些,但是数据统计exportStatisticsDay导出的文件好像只能发往邮箱。share分享文件需要文件地址,我想知道exportStatisticsDay导出的文件存放在哪里

crisiron
Posts: 120

Re: exportStatisticsHour导出的数据如何发送到其他app

使用https://developer.tuya.com/cn/miniapp/develop/ray/api/meature/getStatisticsRangDay 获取到数据后,传入 share

silverlight
Posts: 151

Re: exportStatisticsHour导出的数据如何发送到其他app

crisiron 2025年 Apr 2日 09:27

使用https://developer.tuya.com/cn/miniapp/develop/ray/api/meature/getStatisticsRangDay 获取到数据后,传入 share

你好,我代码如下,在数据成功获取的情况下,并没能打开分享界面。我看了share的示例,还是原生小程序写法,是还没有封装进ray嘛?

Code: Select all

  const handleGetAndShare = () => {
    getStatisticsRangDay({
      devId: devInfo.devId,
      dpId: 106,
      startDay: '20250401',
      endDay: '20250401',
      type: 'avg',
    })
      .then((response) => {
        console.log('导出的数据', response);
  
share({ type: 'WeChat', title: '分享统计数据', message: `统计数据: ${JSON.stringify(response)}`, contentType: 'text', success(info) { console.log('微信分享成功', info); }, fail(error) { console.error('微信分享失败', error); }, complete(info){ console.log('微信分享完成', info); } }); }) .catch((error) => { console.error('获取统计数据失败', error); }); };
crisiron
Posts: 120

Re: exportStatisticsHour导出的数据如何发送到其他app

提供下机型与系统版本以及 APP 版本, 可先看看 文档中提供的示例 https://developer.tuya.com/cn/miniapp/d ... hare#share

silverlight
Posts: 151

Re: exportStatisticsHour导出的数据如何发送到其他app

crisiron 2025年 Apr 2日 11:51

提供下机型与系统版本以及 APP 版本, 可先看看 文档中提供的示例 https://developer.tuya.com/cn/miniapp/d ... hare#share

机型为iphone13 ,系统为18.3.2,智能生活版本为6.4.0。
目前能正确触发打开分享界面,但是存在以下两个个问题。
1:contentType为text的时候,获取到的数据在我iPhone13无法转发到微信里,安卓端则是以文本形式转发出去了
2:getStatisticsRangDay无法将数据以excel文件形式传出,并让我share进行转发

ios分享到微信的界面

分享1.jpg

安卓成功分享出去

分享2.jpg
crisiron
Posts: 120

Re: exportStatisticsHour导出的数据如何发送到其他app

silverlight 2025年 Apr 2日 15:00
crisiron 2025年 Apr 2日 11:51

提供下机型与系统版本以及 APP 版本, 可先看看 文档中提供的示例 https://developer.tuya.com/cn/miniapp/d ... hare#share

机型为iphone13 ,系统为18.3.2,智能生活版本为6.4.0。
目前能正确触发打开分享界面,但是存在以下两个个问题。
1:contentType为text的时候,获取到的数据在我iPhone13无法转发到微信里,安卓端则是以文本形式转发出去了
2:getStatisticsRangDay无法将数据以excel文件形式传出,并让我share进行转发

ios分享到微信的界面
分享1.jpg
安卓成功分享出去
分享2.jpg

我们这边未复现,可以试试 More 类型,不使用 wechat 类型

silverlight
Posts: 151

Re: exportStatisticsHour导出的数据如何发送到其他app

crisiron 2025年 Apr 3日 15:17

我们这边未复现,可以试试 More 类型,不使用 wechat 类型

我修改type为more之后的表现,1:依然是无法将数据转发到微信,2:无法将数据以excel的形式进行转发,下方为我的代码以及实际表现。
这是实际表现,微信显示不支持分享该类型,点击转发到短信中,可以看到数据是文本的形式在进行转发。

导出的问题.gif

下方为代码

Code: Select all

  const handleGetAndShare = () => {
    getStatisticsRangDay({
      devId: devInfo.devId,
      dpId: 106,
      startDay: '20250401',
      endDay: '20250407',
      type: 'avg',
    })
      .then((response) => {
        console.log('导出的数据', response);
  
share({ type: 'More', title: '分享统计数据', message: `统计数据: ${JSON.stringify(response)}`, contentType: 'text', success(info) { console.log('分享成功', info); }, fail(error) { console.error('分享失败', error); }, complete(info){ console.log('分享完成', info); } }); }) .catch((error) => { console.error('获取统计数据失败', error); }); };
crisiron
Posts: 120

Re: exportStatisticsHour导出的数据如何发送到其他app

具体代码可以参考 https://github.com/Tuya-Community/tuya- ... x/index.js 这里; ray中与 小程序写法一致,将ty.去掉 , 注意分享时最后需要添加 "https://www.tuya.com/cn/" 涂鸦官网地址,具体参考示例;这个问题后续优化下,可先进行调试开发;图片等格式 示例中也有

Post Reply