diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..da969d2 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 Tuya + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..8e13484 --- /dev/null +++ b/README.md @@ -0,0 +1,5 @@ +# Tuya_Wechat_Devtools +This project is developed using Tuya SDK, which enables you to quickly develop branded apps connecting and controlling smart scenarios of many devices.For more information, please check Tuya Developer Website. + +![智能插座open.png](https://github.com/1115332213/tuya_project/raw/main/image/open.png) +![智能插座close.png](https://github.com/1115332213/tuya_project/raw/main/image/close.png) \ No newline at end of file diff --git a/README.zh.md b/README.zh.md new file mode 100644 index 0000000..2865fb0 --- /dev/null +++ b/README.zh.md @@ -0,0 +1,80 @@ + +## 注意:当前仓库继承自即将被废弃的涂鸦Github仓库:xxxxxx,请使用当前 Github 仓库进行涂鸦 SDK相关开发。更换远程Github仓库URL的教程,可以参考:https://github.com/TuyaInc/tuya-weapp-demo + +## 概述 + +这个一个简易版快速接入[涂鸦的小程序 SDK](https://developer.tuya.com/cn/docs/iot/app-development/mini-programs/overview/applet-ecology?id=K9ptacgp94o5d),[配网插件](https://developer.tuya.com/cn/docs/iot/app-development/mini-programs/tuya-applet-with-web-plugin/distribution-network-plugin?id=K9lq218xn0wn8) 和 MQTT 的连接的Demo,目前趋于稳定。后续还会有新功能的更新。 + +## 体验 + +如果需要在自己的小程序中嵌入小程序配网的功能,可以通过接入小程序 SDK,获取自己的票据信息,然后调用小程序插件,完成配网,配网成功后重新调用获取设备信息的接口即可。 + +如果需要在自己的小程序中开发设备控制,场景联动、自动化等功能,可以通过小程序 SDK 调用相应的接口即可。 + +如果需要涂鸦公版小程序来支持您的设备,可以联系我们。公版小程序的您可以扫码下面的二维码体验: + +
+ +
+ +如果在设备列表中显示没有设备,可以点击 “添加设备”,选择“扫码配网”,扫描下面的二维码,即可体验设备。 ++ +
香薰机
+ + ++ +
空气净化器
+ + ++ +
空调
+ + ++ +
窗帘电机
+ + ++ +
智能灯
+ + +## Demo 目录 + +``` +├── cloudfunctions // 云函数目录 +│ ├── ty-service // SDK +├── miniprogram // 小程序主目录 +│ ├── image // 图片库 +│ ├── libs // 第三方库 +│ ├── pages // 具体页面的目录 +│ ├── app.js // 小程序入口 +│ ├── app.json // 配置文件 +├── project.config.json // 项目配置文件 +└── README.md // 说明文件 +``` + +## Demo 说明 + +- 设备配网: + + 直接点击按钮进行配网:目前支持 AP 配网、扫码配网、蓝牙配网、zigbee 配网 + +- 体验设备功能: + + 添加设备完成后,可以点击设备开启开关进行设备 MQTT 消息推送调试,建议先使用 api.js 文件中的 getDeviceSpecifications 函数获取指令集,防止出现 dp 点字段名称可能不一致的情况。正常下发指令后页面上会显示出推送消息的内容 + +- 完整版Demo + 目前支持设备控制,消息推送,添加设备(配网), 家庭模块 + +## 技术支持 + ++ +
+ + 文档看了这么多,还是有很多疑问?需要有技术支持?对我们的小程序有建议?有吐槽?有需求?可以添加上面的微信为好友,随时答疑解惑(验证消息中写明:技术交流,不然没法通过)。 \ No newline at end of file diff --git a/app.js b/app.js new file mode 100644 index 0000000..a1f012c --- /dev/null +++ b/app.js @@ -0,0 +1,23 @@ +//app.js +import wxMqtt from './utils/mqtt/wxMqtt' +import { Provider } from './libs/wechat-weapp-redux.min'; +import { configStore } from './utils/store/store'; + +const store = configStore(); + +App(Provider(store)({ + onLaunch: async function() { + // wx.cloud.init() + // wxMqtt.connectMqtt() + + wxMqtt.on('close', (errorMsg) => { + wxMqtt.connectMqtt() + console.log('errorMsg: mqttClose', errorMsg); + }) + + wxMqtt.on('error', (errorMsg) => { + wxMqtt.connectMqtt() + console.log('errorMsg: mqttError', errorMsg); + }) + } +})) \ No newline at end of file diff --git a/app.json b/app.json new file mode 100644 index 0000000..10a7981 --- /dev/null +++ b/app.json @@ -0,0 +1,25 @@ +{ + "pages": [ + "pages/guide/index", + "pages/home_center/device_list/index", + "pages/home_center/common_panel/index", + "pages/home_center/device_manage/index", + "pages/cloud_check/index", + "pages/function_center/device_connect/index", + "pages/web_view/index", + "pages/base_function/index" + ], + "window": { + "backgroundTextStyle": "light", + "navigationBarBackgroundColor": "#fff", + "navigationBarTitleText": "WeChat", + "navigationBarTextStyle": "black" + }, + "plugins": { + "tuya-ap-plugin": { + "version": "3.3.9", + "provider": "wxd2aa51ffacc3ff86" + } + }, + "sitemapLocation": "sitemap.json" +} \ No newline at end of file diff --git a/app.wxss b/app.wxss new file mode 100644 index 0000000..97362b8 --- /dev/null +++ b/app.wxss @@ -0,0 +1,9 @@ +/**app.wxss**/ +page { + background-color: #f6f6f6; + display: flex; + flex-direction: column; + justify-content: flex-start; + overflow: scroll; +} + diff --git a/components/t_navbar/index.js b/components/t_navbar/index.js new file mode 100644 index 0000000..e084b08 --- /dev/null +++ b/components/t_navbar/index.js @@ -0,0 +1,41 @@ +// components/t_navbar/index.js +Component({ + /** + * 组件的属性列表 + */ + properties: { + device_name: String, + device_id: String + }, + + /** + * 组件的初始数据 + */ + data: { + device_name: '未获取到名称', + marginTop: '20px', + height: 'auto', + }, + + lifetimes: { + attached: function () { + const { statusBarHeight, system } = wx.getSystemInfoSync(); + const height = system.indexOf('iOS') > -1 ? '44px' : '48px' + this.setData({ height, marginTop: `${statusBarHeight}px` }) + } + }, + + /** + * 组件的方法列表 + */ + methods: { + backPage: function () { + wx.navigateBack({ + delta: 1, + }) + }, + jumpEditPage: function() { + this.triggerEvent('jumpTodeviceEditPage',{}) + } + } +}) diff --git a/components/t_navbar/index.json b/components/t_navbar/index.json new file mode 100644 index 0000000..6f50345 --- /dev/null +++ b/components/t_navbar/index.json @@ -0,0 +1,6 @@ +{ + "component": true, + "usingComponents": { + "van-icon": "@vant/weapp/icon/index" + } +} \ No newline at end of file diff --git a/components/t_navbar/index.wxml b/components/t_navbar/index.wxml new file mode 100644 index 0000000..52b4533 --- /dev/null +++ b/components/t_navbar/index.wxml @@ -0,0 +1,8 @@ + +