update mini program doc
This commit is contained in:
@@ -1,29 +1,3 @@
|
||||
### 智能灯小程序云开发DEMO
|
||||
1. 说明
|
||||
本示例小程序配合TencentOS_tiny智能灯数据模板示例使用:TencentOS_tiny/examples/tencent_cloud_sdk_data_template
|
||||
[腾讯云侧接入文档参见: 智能灯接入指引](https://cloud.tencent.com/document/product/1081/34744)
|
||||
|
||||
2. tencent_cloud_sdk_data_template 接入腾讯云explorer后,在 app.js 中修改以下字段即可使用
|
||||
````
|
||||
globalData: {
|
||||
// 腾讯云物联网开发平台explorer中获取 产品ID和设备名称
|
||||
productId: "U2LPAXBT2C", // 产品ID
|
||||
deviceName: "royye_light", // 设备名称
|
||||
// 腾讯云控制台-访问管理-访问密钥-API密钥管理中获取 SecretId, secretKey
|
||||
secretId: "AKIDxZ2LTTi84eaR3OfS8hnfxd4JHzQatFpF",
|
||||
secretKey: "UigMrA9rJXUCeoiBQP8dsJuJ6sYzmNjs",
|
||||
// 接口 Region 字段
|
||||
region: "ap-guangzhou",
|
||||
// 云开发的环境名称。此处需要替换为云开发创建的环境名称
|
||||
env: "tos-demo"
|
||||
},
|
||||
````
|
||||
|
||||
3. 测试通过后,如果需要发布小程序,则还需要在小程序管理后台进行服务器域名配置
|
||||
[微信小程序添加服务器端就接口域名](https://jingyan.baidu.com/article/ce09321bb6e9c12bff858f92.html)
|
||||
进入微信公众平台小程序后台 - 开发 - 开发设置 - 服务器域名 - 输入域名: iotexplorer.tencentcloudapi.com
|
||||
|
||||
### 云开发参考文档
|
||||
|
||||
- [云开发文档](https://developers.weixin.qq.com/miniprogram/dev/wxcloud/basis/getting-started.html)
|
||||
### 智能灯小程序DEMO-云开发方式(云函数)
|
||||
|
||||
[参见 doc/17.Mini_Program_Quick_Start.md#云开发方式(云函数)](https://github.com/Tencent/TencentOS-tiny/blob/master/doc/17.Mini_Program_Quick_Start.md#124-%E4%BA%91%E5%BC%80%E5%8F%91%E6%96%B9%E5%BC%8F%E4%BA%91%E5%87%BD%E6%95%B0)
|
||||
|
@@ -5,11 +5,11 @@ App({
|
||||
productId: "U2LPAXBT2C", // 产品ID
|
||||
deviceName: "royye_light", // 设备名称
|
||||
// 腾讯云控制台-访问管理-访问密钥-API密钥管理中获取 SecretId, secretKey
|
||||
secretId: "AKIDxZ2LTTi84eaR3OfS8hnfxd4JHzQatFpF",
|
||||
secretKey: "UigMrA9rJXUCeoiBQP8dsJuJ6sYzmNjs",
|
||||
// 接口 Region 字段
|
||||
secretId: "xxx",
|
||||
secretKey: "xxx",
|
||||
// 接口 Region 字段。一般不需要修改
|
||||
region: "ap-guangzhou",
|
||||
// 云开发的环境名称。此处需要替换为云开发创建的环境名称
|
||||
// 云开发的环境ID。此处需要替换为云开发创建的环境ID
|
||||
env: "tos-demo"
|
||||
},
|
||||
onLaunch: function () {
|
||||
|
@@ -60,18 +60,27 @@ Page({
|
||||
region: app.globalData.region,
|
||||
}
|
||||
console.log(queryData);
|
||||
// 调用云函数query
|
||||
wx.cloud.callFunction({
|
||||
name: 'query',
|
||||
data: queryData,
|
||||
success: res => {
|
||||
wx.showToast({
|
||||
title: '调用成功',
|
||||
})
|
||||
let deviceData = JSON.parse(res.result.Data)
|
||||
this.setData({
|
||||
deviceData: deviceData
|
||||
})
|
||||
console.log("result:", deviceData)
|
||||
try {
|
||||
let deviceData = JSON.parse(res.result.Data)
|
||||
this.setData({
|
||||
deviceData: deviceData
|
||||
})
|
||||
console.log("result:", deviceData)
|
||||
wx.showToast({
|
||||
title: '调用成功',
|
||||
})
|
||||
} catch (e) {
|
||||
wx.showToast({
|
||||
icon: 'none',
|
||||
title: '调用失败',
|
||||
})
|
||||
console.log(res.result.Data, e)
|
||||
}
|
||||
},
|
||||
fail: err => {
|
||||
wx.showToast({
|
||||
@@ -101,7 +110,7 @@ Page({
|
||||
data: JSON.stringify(data),
|
||||
}
|
||||
console.log(controlData);
|
||||
|
||||
// 调用云函数control
|
||||
wx.cloud.callFunction({
|
||||
name: 'control',
|
||||
data: controlData,
|
||||
|
@@ -7,7 +7,11 @@
|
||||
"postcss": true,
|
||||
"minified": true,
|
||||
"newFeature": true,
|
||||
"coverView": true,
|
||||
"nodeModules": true,
|
||||
"autoAudits": false,
|
||||
"showShadowRootInWxmlPanel": true,
|
||||
"scopeDataCheck": false,
|
||||
"checkInvalidKey": true,
|
||||
"checkSiteMap": true,
|
||||
"uploadWithSourceMap": true,
|
||||
@@ -15,8 +19,7 @@
|
||||
"ignore": [],
|
||||
"disablePlugins": [],
|
||||
"outputPath": ""
|
||||
},
|
||||
"nodeModules": true
|
||||
}
|
||||
},
|
||||
"appid": "wx394efa031612f9b5",
|
||||
"projectname": "iotexplorer_mp_cloudfunctions_demo",
|
||||
|
@@ -1,20 +1,3 @@
|
||||
### 智能灯小程序DEMO
|
||||
1. 说明
|
||||
本示例小程序配合TencentOS_tiny智能灯数据模板示例使用:TencentOS_tiny/examples/tencent_cloud_sdk_data_template
|
||||
[腾讯云侧接入文档参见: 智能灯接入指引](https://cloud.tencent.com/document/product/1081/34744)
|
||||
### 智能灯小程序DEMO-普通开发方式(SDK)
|
||||
|
||||
2. tencent_cloud_sdk_data_template 接入腾讯云explorer后,在 app.js 中修改以下字段即可使用
|
||||
````
|
||||
globalData: {
|
||||
// 腾讯云物联网开发平台explorer中获取 产品ID和设备名称
|
||||
productId: "XXXX", // 产品ID
|
||||
deviceName: "XXXX", // 设备名称
|
||||
// 腾讯云控制台-访问管理-访问密钥-API密钥管理中获取 SecretId, secretKey
|
||||
secretId: "XXXX",
|
||||
secretKey: "XXXX",
|
||||
},
|
||||
````
|
||||
|
||||
3. 测试通过后,如果需要发布小程序,则还需要在小程序管理后台进行服务器域名配置
|
||||
[微信小程序添加服务器端就接口域名](https://jingyan.baidu.com/article/ce09321bb6e9c12bff858f92.html)
|
||||
进入微信公众平台小程序后台 - 开发 - 开发设置 - 服务器域名 - 输入域名: iotexplorer.tencentcloudapi.com
|
||||
[参见 doc/17.Mini_Program_Quick_Start.md#普通开发方式(SDK)](https://github.com/Tencent/TencentOS-tiny/blob/master/doc/17.Mini_Program_Quick_Start.md#123-%E6%99%AE%E9%80%9A%E5%BC%80%E5%8F%91%E6%96%B9%E5%BC%8Fsdk)
|
||||
|
@@ -2,11 +2,11 @@
|
||||
App({
|
||||
globalData: {
|
||||
// 腾讯云物联网开发平台explorer中获取 产品ID和设备名称
|
||||
productId: "", // 产品ID
|
||||
deviceName: "", // 设备名称
|
||||
productId: "U2LPAXBT2C", // 产品ID
|
||||
deviceName: "royye_light", // 设备名称
|
||||
// 腾讯云控制台-访问管理-访问密钥-API密钥管理中获取 SecretId, secretKey
|
||||
secretId: "",
|
||||
secretKey: "",
|
||||
secretId: "xxx",
|
||||
secretKey: "xxx",
|
||||
},
|
||||
onLaunch: function(options) {
|
||||
console.log("onLaunch")
|
||||
|
@@ -11,6 +11,8 @@
|
||||
"newFeature": true,
|
||||
"coverView": true,
|
||||
"autoAudits": false,
|
||||
"showShadowRootInWxmlPanel": true,
|
||||
"scopeDataCheck": false,
|
||||
"checkInvalidKey": true,
|
||||
"checkSiteMap": true,
|
||||
"uploadWithSourceMap": true,
|
||||
@@ -22,7 +24,7 @@
|
||||
},
|
||||
"compileType": "miniprogram",
|
||||
"libVersion": "2.4.0",
|
||||
"appid": "wx7152cd841f66c30b",
|
||||
"appid": "wx394efa031612f9b5",
|
||||
"projectname": "iotexplorer_mp_demo",
|
||||
"debugOptions": {
|
||||
"hidedInDevtools": []
|
||||
|
Reference in New Issue
Block a user