添加微信小程序
@ -556,6 +556,7 @@ CONFIG_PKG_SHT3X_VER="latest"
|
||||
# CONFIG_PKG_USING_LEDBLINK is not set
|
||||
# CONFIG_PKG_USING_LITTLED is not set
|
||||
# CONFIG_PKG_USING_LKDGUI is not set
|
||||
# CONFIG_PKG_USING_NRF5X_SDK is not set
|
||||
# CONFIG_PKG_USING_WM_LIBRARIES is not set
|
||||
# CONFIG_PKG_USING_KENDRYTE_SDK is not set
|
||||
# CONFIG_PKG_USING_INFRARED is not set
|
||||
@ -581,6 +582,7 @@ CONFIG_PKG_GT9147_VER="latest"
|
||||
# CONFIG_PKG_USING_RC522 is not set
|
||||
# CONFIG_PKG_USING_EMBARC_BSP is not set
|
||||
# CONFIG_PKG_USING_EXTERN_RTC_DRIVERS is not set
|
||||
# CONFIG_PKG_USING_MULTI_RTIMER is not set
|
||||
# CONFIG_PKG_USING_MAX7219 is not set
|
||||
# CONFIG_PKG_USING_BEEP is not set
|
||||
# CONFIG_PKG_USING_EASYBLINK is not set
|
||||
|
@ -22,8 +22,8 @@
|
||||
#define MQTT_MAN_INFO_STRING "DiyMultiMeter"
|
||||
|
||||
/* <20>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ */
|
||||
#define ALI_SERVICE_RGB_CTRL_SUB "Topic-ServiceRGBCtrlSub"
|
||||
#define ALI_SERVICE_RGB_CTRL_REPLY_PUB "Topic-ServiceRGBCtrlReplyPub"
|
||||
#define ALI_SERVICE_RGB_CTRL_SUB "Topic-ServiceSwitchSub"
|
||||
#define ALI_SERVICE_RGB_CTRL_REPLY_PUB "Topic-ServiceSwitchReplyPub"
|
||||
/* <20>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD>ϱ<EFBFBD><CFB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ */
|
||||
#define ALI_PROPERTY_POST_PUB "Topic-PropertyPostPub"
|
||||
#define ALI_PROPERTY_POST_REPLY_SUB "Topic-PropertyPostReplySub"
|
||||
@ -95,9 +95,9 @@ static char * mqtt_check_load_topic(void)
|
||||
for (topic_idx = 0; topic_idx < sub_items; topic_idx++)
|
||||
{
|
||||
if (!rt_strcmp(mqtt_sub_item[topic_idx].topic_filter, ALI_SERVICE_RGB_CTRL_SUB))
|
||||
rt_snprintf(&topic[topic_idx * 128], MQTT_TOPIC_MAX_SIZE, "/sys/%s/%s/thing/service/rgb_ctrl", product_key, device_name);
|
||||
rt_snprintf(&topic[topic_idx * 128], MQTT_TOPIC_MAX_SIZE, "/sys/%s/%s/thing/service/switch", product_key, device_name);
|
||||
else if (!rt_strcmp(mqtt_sub_item[topic_idx].topic_filter, ALI_SERVICE_RGB_CTRL_REPLY_PUB))
|
||||
rt_snprintf(&topic[topic_idx * 128], MQTT_TOPIC_MAX_SIZE, "/sys/%s/%s/thing/service/rgb_ctrl_reply", product_key, device_name);
|
||||
rt_snprintf(&topic[topic_idx * 128], MQTT_TOPIC_MAX_SIZE, "/sys/%s/%s/thing/service/switch_reply", product_key, device_name);
|
||||
else if (!rt_strcmp(mqtt_sub_item[topic_idx].topic_filter, ALI_PROPERTY_POST_PUB))
|
||||
rt_snprintf(&topic[topic_idx * 128], MQTT_TOPIC_MAX_SIZE, "/sys/%s/%s/thing/event/property/post", product_key, device_name);
|
||||
else if (!rt_strcmp(mqtt_sub_item[topic_idx].topic_filter, ALI_PROPERTY_POST_REPLY_SUB))
|
||||
@ -157,7 +157,7 @@ static void ali_mqtt_rgb_ctrl_msg_arrive (void *pcontext, void *handle, iotx_mqt
|
||||
LOG_D("cJSON get object[rgb_blue] failed.");
|
||||
goto __door_ctrl_exit;
|
||||
}
|
||||
LOG_D("id=%.*s;rgb_red=%d;rgb_green=%d;rgb_blue=%d", rt_strlen(id->valuestring), id->valuestring,
|
||||
LOG_D("rgb_red=%d;rgb_green=%d;rgb_blue=%d",
|
||||
rgb_red->valueint,rgb_green->valueint,rgb_blue->valueint );
|
||||
|
||||
__door_ctrl_exit:
|
||||
@ -257,8 +257,8 @@ static void mqtt_period_task()
|
||||
|
||||
cJSON_AddStringToObject(root, "version", "1.0");
|
||||
cJSON_AddItemToObject(root, "params", js_params);
|
||||
cJSON_AddNumberToObject(js_params, "CurrentHumidity", sht30_device->humidity);
|
||||
cJSON_AddNumberToObject(js_params, "CurrentTemperature", sht30_device->temperature);
|
||||
cJSON_AddNumberToObject(js_params, "humidity", sht30_device->humidity);
|
||||
cJSON_AddNumberToObject(js_params, "temperature", sht30_device->temperature);
|
||||
cJSON_AddStringToObject(root, "method", "thing.event.property.post");
|
||||
char *msg_pub = cJSON_PrintUnformatted(root);
|
||||
if (msg_pub)
|
||||
|
@ -120,7 +120,7 @@
|
||||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
<Key>ST-LINKIII-KEIL_SWO</Key>
|
||||
<Name>-U54FF75066578555551530367 -O206 -SF10000 -C0 -A0 -I0 -HNlocalhost -HP7184 -P1 -N00("ARM CoreSight SW-DP (ARM Core") -D00(5BA02477) -L00(0) -TO131090 -TC10000000 -TT10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO11 -FD20000000 -FC6000 -FN2 -FF0STM32F7x_1024.FLM -FS08000000 -FL0100000 -FP0($$Device:STM32F767IGTx$CMSIS\Flash\STM32F7x_1024.FLM) -FF1STM32F767_W25QXX -FS190000000 -FL11000000</Name>
|
||||
<Name>-U52FF6B066570555010461587 -O206 -SF10000 -C0 -A0 -I0 -HNlocalhost -HP7184 -P1 -N00("ARM CoreSight SW-DP (ARM Core") -D00(1BA01477) -L00(0) -TO131090 -TC10000000 -TT10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO11 -FD20000000 -FC6000 -FN2 -FF0STM32F7x_1024.FLM -FS08000000 -FL0100000 -FP0($$Device:STM32F767IGTx$CMSIS\Flash\STM32F7x_1024.FLM) -FF1STM32F767_W25QXX -FS190000000 -FL11000000</Name>
|
||||
</SetRegEntry>
|
||||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
@ -177,7 +177,7 @@
|
||||
<pSingCmdsp></pSingCmdsp>
|
||||
<pMultCmdsp></pMultCmdsp>
|
||||
<DebugDescription>
|
||||
<Enable>1</Enable>
|
||||
<Enable>0</Enable>
|
||||
<EnableFlashSeq>0</EnableFlashSeq>
|
||||
<EnableLog>0</EnableLog>
|
||||
<Protocol>2</Protocol>
|
||||
@ -560,7 +560,7 @@
|
||||
|
||||
<Group>
|
||||
<GroupName>TouchGFX_app</GroupName>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
|
36
demo/4_微信小程序/不适用云服务/wechat_ali_esp8266/app.js
Normal file
@ -0,0 +1,36 @@
|
||||
//app.js
|
||||
App({
|
||||
onLaunch: function () {
|
||||
var that = this;
|
||||
// 展示本地存储能力
|
||||
var logs = wx.getStorageSync('logs') || []
|
||||
logs.unshift(Date.now())
|
||||
wx.setStorageSync('logs', logs)
|
||||
|
||||
wx.request({
|
||||
url: "https://api.heclouds.com/devices",
|
||||
header: {
|
||||
"api-key": that.globalData.masterAPIkey
|
||||
},
|
||||
success(res) {
|
||||
var devices = [];
|
||||
if (res.data.errno == 0) {
|
||||
for (var i = 0; i < res.data.data.total_count; i++) {
|
||||
devices.push(res.data.data.devices[i]);
|
||||
}
|
||||
}
|
||||
that.globalData.devices = devices
|
||||
console.log('devices数据', that.globalData.devices)
|
||||
},
|
||||
fail(res) {
|
||||
console.log("请求失败")
|
||||
}
|
||||
})
|
||||
},
|
||||
globalData: {
|
||||
userInfo: null,
|
||||
devices: [],
|
||||
respcmd: "",
|
||||
masterAPIkey: "NMatXOb7WuttCYVkzxZek9mHKmk="
|
||||
},
|
||||
})
|
47
demo/4_微信小程序/不适用云服务/wechat_ali_esp8266/app.json
Normal file
@ -0,0 +1,47 @@
|
||||
{
|
||||
"pages": [
|
||||
"pages/start/start",
|
||||
"pages/home/home",
|
||||
"pages/home/list/list",
|
||||
"pages/find/find",
|
||||
"pages/find/detail/detail",
|
||||
"pages/my/my",
|
||||
"pages/my/set/set",
|
||||
"pages/my/map/map",
|
||||
"pages/device/device"
|
||||
],
|
||||
"window": {
|
||||
"backgroundTextStyle": "light",
|
||||
"navigationBarBackgroundColor": "#0b737a",
|
||||
"navigationBarTitleText": "DEMO",
|
||||
"navigationBarTextStyle": "white",
|
||||
"backgroundColor": "#fbf9fe"
|
||||
},
|
||||
"tabBar": {
|
||||
"color": "#929292",
|
||||
"backgroundColor": "#ffffff",
|
||||
"selectedColor": "#69C3AA",
|
||||
"borderStyle": "white",
|
||||
"list": [
|
||||
{
|
||||
"pagePath": "pages/home/home",
|
||||
"text": "首页",
|
||||
"iconPath": "image/shouye1.png",
|
||||
"selectedIconPath": "image/shouye.png"
|
||||
},
|
||||
{
|
||||
"pagePath": "pages/find/find",
|
||||
"text": "发现",
|
||||
"iconPath": "image/huodong1.png",
|
||||
"selectedIconPath": "image/huodong.png"
|
||||
},
|
||||
{
|
||||
"pagePath": "pages/my/my",
|
||||
"text": "我的",
|
||||
"iconPath": "image/wode1.png",
|
||||
"selectedIconPath": "image/wode.png"
|
||||
}
|
||||
]
|
||||
},
|
||||
"sitemapLocation": "sitemap.json"
|
||||
}
|
11
demo/4_微信小程序/不适用云服务/wechat_ali_esp8266/app.wxss
Normal file
@ -0,0 +1,11 @@
|
||||
/**app.wxss**/
|
||||
@import 'style/weui.wxss';
|
||||
.container {
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 200rpx 0;
|
||||
box-sizing: border-box;
|
||||
}
|
BIN
demo/4_微信小程序/不适用云服务/wechat_ali_esp8266/image/.DS_Store
vendored
Normal file
BIN
demo/4_微信小程序/不适用云服务/wechat_ali_esp8266/image/brand.png
Normal file
After Width: | Height: | Size: 3.4 KiB |
BIN
demo/4_微信小程序/不适用云服务/wechat_ali_esp8266/image/car.png
Normal file
After Width: | Height: | Size: 731 B |
BIN
demo/4_微信小程序/不适用云服务/wechat_ali_esp8266/image/car1.png
Normal file
After Width: | Height: | Size: 688 B |
BIN
demo/4_微信小程序/不适用云服务/wechat_ali_esp8266/image/faxian.png
Normal file
After Width: | Height: | Size: 1.0 KiB |
BIN
demo/4_微信小程序/不适用云服务/wechat_ali_esp8266/image/faxian1.png
Normal file
After Width: | Height: | Size: 980 B |
BIN
demo/4_微信小程序/不适用云服务/wechat_ali_esp8266/image/huaju.jpeg
Normal file
After Width: | Height: | Size: 99 KiB |
BIN
demo/4_微信小程序/不适用云服务/wechat_ali_esp8266/image/huodong.png
Normal file
After Width: | Height: | Size: 832 B |
BIN
demo/4_微信小程序/不适用云服务/wechat_ali_esp8266/image/huodong1.png
Normal file
After Width: | Height: | Size: 771 B |
BIN
demo/4_微信小程序/不适用云服务/wechat_ali_esp8266/image/icon-aixin.png
Normal file
After Width: | Height: | Size: 558 B |
BIN
demo/4_微信小程序/不适用云服务/wechat_ali_esp8266/image/icon-aixin1.png
Normal file
After Width: | Height: | Size: 764 B |
BIN
demo/4_微信小程序/不适用云服务/wechat_ali_esp8266/image/icon-arrow.png
Normal file
After Width: | Height: | Size: 440 B |
BIN
demo/4_微信小程序/不适用云服务/wechat_ali_esp8266/image/icon-dw.png
Normal file
After Width: | Height: | Size: 742 B |
BIN
demo/4_微信小程序/不适用云服务/wechat_ali_esp8266/image/icon-fujin.png
Normal file
After Width: | Height: | Size: 7.3 KiB |
BIN
demo/4_微信小程序/不适用云服务/wechat_ali_esp8266/image/icon-fuli.png
Normal file
After Width: | Height: | Size: 6.1 KiB |
BIN
demo/4_微信小程序/不适用云服务/wechat_ali_esp8266/image/icon-muma.png
Normal file
After Width: | Height: | Size: 6.8 KiB |
BIN
demo/4_微信小程序/不适用云服务/wechat_ali_esp8266/image/icon-qiandao.png
Normal file
After Width: | Height: | Size: 6.1 KiB |
BIN
demo/4_微信小程序/不适用云服务/wechat_ali_esp8266/image/icon-qinzi.png
Normal file
After Width: | Height: | Size: 6.4 KiB |
BIN
demo/4_微信小程序/不适用云服务/wechat_ali_esp8266/image/icon-tiyu.png
Normal file
After Width: | Height: | Size: 7.5 KiB |
BIN
demo/4_微信小程序/不适用云服务/wechat_ali_esp8266/image/icon-xingxing.png
Normal file
After Width: | Height: | Size: 6.0 KiB |
BIN
demo/4_微信小程序/不适用云服务/wechat_ali_esp8266/image/icon-zhanhui.png
Normal file
After Width: | Height: | Size: 7.1 KiB |
BIN
demo/4_微信小程序/不适用云服务/wechat_ali_esp8266/image/led/led.jpg
Normal file
After Width: | Height: | Size: 2.1 KiB |
BIN
demo/4_微信小程序/不适用云服务/wechat_ali_esp8266/image/onenet.jpg
Normal file
After Width: | Height: | Size: 77 KiB |
BIN
demo/4_微信小程序/不适用云服务/wechat_ali_esp8266/image/rtt.jpg
Normal file
After Width: | Height: | Size: 33 KiB |
BIN
demo/4_微信小程序/不适用云服务/wechat_ali_esp8266/image/shanchu.png
Normal file
After Width: | Height: | Size: 653 B |
BIN
demo/4_微信小程序/不适用云服务/wechat_ali_esp8266/image/shouye.png
Normal file
After Width: | Height: | Size: 829 B |
BIN
demo/4_微信小程序/不适用云服务/wechat_ali_esp8266/image/shouye1.png
Normal file
After Width: | Height: | Size: 768 B |
BIN
demo/4_微信小程序/不适用云服务/wechat_ali_esp8266/image/start/start.png
Normal file
After Width: | Height: | Size: 337 KiB |
BIN
demo/4_微信小程序/不适用云服务/wechat_ali_esp8266/image/swiper1.jpg
Normal file
After Width: | Height: | Size: 25 KiB |
BIN
demo/4_微信小程序/不适用云服务/wechat_ali_esp8266/image/tecent.jpg
Normal file
After Width: | Height: | Size: 29 KiB |
BIN
demo/4_微信小程序/不适用云服务/wechat_ali_esp8266/image/wode.png
Normal file
After Width: | Height: | Size: 868 B |
BIN
demo/4_微信小程序/不适用云服务/wechat_ali_esp8266/image/wode1.png
Normal file
After Width: | Height: | Size: 801 B |
BIN
demo/4_微信小程序/不适用云服务/wechat_ali_esp8266/image/zhutu.jpg
Normal file
After Width: | Height: | Size: 70 KiB |
97
demo/4_微信小程序/不适用云服务/wechat_ali_esp8266/onenet/onenet.js
Normal file
@ -0,0 +1,97 @@
|
||||
var app = getApp();
|
||||
|
||||
function getDeviceStatus(device_id) {
|
||||
var deviceConnected
|
||||
var devices_origin = ''
|
||||
devices_origin = app.globalData.devices
|
||||
//查看设备连接状态
|
||||
wx.request({
|
||||
url: "https://api.heclouds.com/devices/" + device_id,
|
||||
header: {
|
||||
'content-type': 'application/x-www-form-urlencoded',
|
||||
"api-key": app.globalData.masterAPIkey
|
||||
},
|
||||
data: {
|
||||
|
||||
},
|
||||
success(res) {
|
||||
console.log(res)
|
||||
if (res.data.data.online == true) {
|
||||
console.log("设备已经连接")
|
||||
deviceConnected = true
|
||||
for (var i = 0; i < devices_origin.length; i++) {
|
||||
if (devices_origin[i].id == device_id){
|
||||
devices_origin[i].online = true
|
||||
console.log(devices_origin[i])
|
||||
}
|
||||
}
|
||||
return true
|
||||
} else {
|
||||
console.log("设备还未连接")
|
||||
deviceConnected = false
|
||||
for (var i = 0; i < devices_origin.length; i++) {
|
||||
if (devices_origin[i].id == device_id) {
|
||||
devices_origin[i].online = false
|
||||
console.log(devices_origin[i])
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
},
|
||||
fail(res) {
|
||||
console.log("请求失败")
|
||||
deviceConnected = false
|
||||
return false
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function sendCmd(id, data) {
|
||||
var deviceConnected
|
||||
//查看设备连接状态,并刷新按钮状态
|
||||
wx.request({
|
||||
url: ("https://api.heclouds.com/cmds?device_id=" + id),
|
||||
header: {
|
||||
'content-type': 'application/json',
|
||||
"api-key": app.globalData.masterAPIkey
|
||||
},
|
||||
data: data,
|
||||
method: 'POST',
|
||||
success(res) {
|
||||
console.log(res)
|
||||
if (res.data.errno == 0) {
|
||||
deviceConnected = true
|
||||
} else {
|
||||
deviceConnected = false
|
||||
}
|
||||
},
|
||||
fail(res) {
|
||||
console.log("请求失败")
|
||||
deviceConnected = false
|
||||
},
|
||||
complete() {
|
||||
if (deviceConnected) {
|
||||
console.log("complete ok")
|
||||
wx.showToast({
|
||||
title: "操作成功",
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
})
|
||||
return true
|
||||
} else {
|
||||
console.log("complete error")
|
||||
wx.showToast({
|
||||
title: "操作失败 ",
|
||||
icon: 'none',
|
||||
duration: 3000
|
||||
})
|
||||
return false
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
module.exports = {
|
||||
sendCmd,
|
||||
getDeviceStatus,
|
||||
}
|
162
demo/4_微信小程序/不适用云服务/wechat_ali_esp8266/onenet/sdk.js
Normal file
@ -0,0 +1,162 @@
|
||||
/**
|
||||
* Created with JetBrains PhpStorm.
|
||||
* Desc: OneNet JS SDK 使用高风险,仅限实验用
|
||||
* Author: limengjun
|
||||
* Date: 16-2-26
|
||||
* Time: 下午2:27
|
||||
* Version: 1.0.0
|
||||
* Copyright (c) 2016 中国移动物联网有限公司
|
||||
* Under MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
*/
|
||||
|
||||
(function(){
|
||||
var count = 1;
|
||||
var API_HOST = 'http://open.iot.10086.cn';
|
||||
function noop(){}
|
||||
function jsonp(url, opts, fn){
|
||||
if ('function' == typeof opts) {
|
||||
fn = opts;
|
||||
opts = {};
|
||||
}
|
||||
if (!opts) opts = {};
|
||||
|
||||
var prefix = opts.prefix || 'callback';
|
||||
|
||||
// use the callback name that was passed if one was provided.
|
||||
// otherwise generate a unique name by incrementing our counter.
|
||||
var id = opts.name || (prefix + (count++));
|
||||
|
||||
var param = opts.param || 'callback';
|
||||
var timeout = null != opts.timeout ? opts.timeout : 60000;
|
||||
var enc = encodeURIComponent;
|
||||
var target = document.getElementsByTagName('script')[0] || document.head;
|
||||
var script;
|
||||
var timer;
|
||||
|
||||
|
||||
if (timeout) {
|
||||
timer = setTimeout(function(){
|
||||
cleanup();
|
||||
if (fn) fn(new Error('Timeout'));
|
||||
}, timeout);
|
||||
}
|
||||
|
||||
function cleanup(){
|
||||
if (script.parentNode) script.parentNode.removeChild(script);
|
||||
window[id] = noop;
|
||||
if (timer) clearTimeout(timer);
|
||||
}
|
||||
|
||||
function cancel(){
|
||||
if (window[id]) {
|
||||
cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
window[id] = function(data){
|
||||
cleanup();
|
||||
if (fn) fn(null, data);
|
||||
};
|
||||
|
||||
// add qs component
|
||||
url += (~url.indexOf('?') ? '&' : '?') + param + '=' + enc(id) + '&_=' + (new Date()).getTime();
|
||||
url = url.replace('?&', '?');
|
||||
|
||||
// create script
|
||||
script = document.createElement('script');
|
||||
script.src = url;
|
||||
target.parentNode.insertBefore(script, target);
|
||||
|
||||
return cancel;
|
||||
}
|
||||
|
||||
function OneNetApi(apiKey){
|
||||
if(!apiKey){
|
||||
alert('初始化OneNetApi时必须传入apiKey!');
|
||||
}
|
||||
this._apiKey = encodeURIComponent(apiKey);
|
||||
}
|
||||
|
||||
OneNetApi.prototype = {
|
||||
/**
|
||||
* 读取设备多个数据流
|
||||
* */
|
||||
getDataStreams: function(deviceId){
|
||||
var doneCallBack;
|
||||
jsonp(API_HOST + '/api/jsonpresend?key='+this._apiKey+'&method=GET&uri=devices/'+deviceId+'/datastreams', function(error, res){
|
||||
if(error || !res.hasOwnProperty('data')){
|
||||
res = {
|
||||
errno: 100,
|
||||
error: 'timeout'
|
||||
};
|
||||
}
|
||||
|
||||
doneCallBack && doneCallBack(res);
|
||||
});
|
||||
return {
|
||||
done: function(func){
|
||||
doneCallBack = func;
|
||||
}
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 获取数据点 cmds
|
||||
* */
|
||||
getDataPoints: function(deviceId, parameter){
|
||||
var doneCallBack;
|
||||
var uri = 'devices/'+deviceId+'/datapoints';
|
||||
var uriComponent = '';
|
||||
if(parameter){
|
||||
for(var i in parameter){
|
||||
if(uriComponent){
|
||||
uriComponent += encodeURIComponent('&');
|
||||
}
|
||||
uriComponent += i + '=' + encodeURIComponent(parameter[i]);
|
||||
}
|
||||
uri += encodeURIComponent('?') + uriComponent;
|
||||
}
|
||||
jsonp(API_HOST + '/api/jsonpresend?key=' + this._apiKey + '&method=GET&uri=' + uri, function(error, res){
|
||||
if(error || !res.hasOwnProperty('data')){
|
||||
res = {
|
||||
errno: 100,
|
||||
error: 'timeout'
|
||||
};
|
||||
}
|
||||
|
||||
doneCallBack && doneCallBack(res);
|
||||
});
|
||||
return {
|
||||
done: function(func){
|
||||
doneCallBack = func;
|
||||
}
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 发送命令 /api/jsonpresend?callback=callback1&_=1&uri=cmds&method=cmds&key={APIkey}&device_id={设备ID}&sms={要发的指令
|
||||
* */
|
||||
sendCommand: function(deviceId, command){
|
||||
var doneCallBack;
|
||||
jsonp(API_HOST + '/api/jsonpresend?key=' + this._apiKey + '&method=cmds&uri=cmds&device_id=' + deviceId + '&sms=' + encodeURIComponent(command), function(error, res){
|
||||
if(error || !res.hasOwnProperty('errno')){
|
||||
res = {
|
||||
errno: 100,
|
||||
error: 'timeout'
|
||||
};
|
||||
}
|
||||
|
||||
doneCallBack && doneCallBack(res);
|
||||
});
|
||||
return {
|
||||
done: function(func){
|
||||
doneCallBack = func;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
this.OneNetApi = OneNetApi;
|
||||
|
||||
})();
|
||||
|
||||
|
||||
|
175
demo/4_微信小程序/不适用云服务/wechat_ali_esp8266/pages/device/device.js
Normal file
@ -0,0 +1,175 @@
|
||||
// pages/device/device.js
|
||||
var app = getApp();
|
||||
const onenet = require('../../onenet/onenet.js')
|
||||
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
client: null,
|
||||
deviceData: {},
|
||||
detail: {
|
||||
id: "",
|
||||
name: "",
|
||||
status:"",
|
||||
},
|
||||
items: [
|
||||
{ name: '红色', value: 0, color: "red" },
|
||||
{ name: '绿色', value: 1, color: "green" },
|
||||
{ name: '蓝色', value: 2, color: "blue" },
|
||||
]
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad: function (options) {
|
||||
var that = this;
|
||||
console.log(options)
|
||||
that.setData({
|
||||
detail: options,
|
||||
}
|
||||
)
|
||||
this.queryDeviceData()
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady: function () {
|
||||
|
||||
},
|
||||
/**
|
||||
* 查询设备数据流
|
||||
*/
|
||||
queryDeviceData() {
|
||||
let that = this
|
||||
var deviceConnected
|
||||
let detail = { status: ""}
|
||||
let deviceData = {"temperature":0}
|
||||
//查看设备连接状态,并刷新按钮状态
|
||||
onenet.getDeviceStatus(that.data.detail.id)
|
||||
wx.request({
|
||||
url: "https://api.heclouds.com/devices/" + this.data.detail.id + "/datapoints?datastream_id=temperature",
|
||||
header: {
|
||||
'content-type': 'application/x-www-form-urlencoded',
|
||||
"api-key": app.globalData.masterAPIkey
|
||||
},
|
||||
|
||||
success(res) {
|
||||
console.log(res)
|
||||
deviceData.temperature = res.data.data.datastreams[0].datapoints[0].value
|
||||
deviceConnected = true
|
||||
},
|
||||
fail(res) {
|
||||
console.log("请求失败")
|
||||
deviceConnected = false
|
||||
},
|
||||
complete() {
|
||||
if (deviceConnected) {
|
||||
console.log("complete ok")
|
||||
that.setData({
|
||||
deviceData: deviceData
|
||||
})
|
||||
console.log('receive data:', deviceData)
|
||||
for (var i = 0; i < app.globalData.devices.length; i++) {
|
||||
if (app.globalData.devices[i].id == that.data.detail.id) {
|
||||
if (app.globalData.devices[i].online == false) {
|
||||
detail.status = "离线"
|
||||
} else {
|
||||
detail.status = "在线"
|
||||
}
|
||||
that.setData({
|
||||
detail : detail.status
|
||||
})
|
||||
}
|
||||
}
|
||||
console.log(that.data.detail.status)
|
||||
wx.showToast({
|
||||
title: "操作成功",
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
})
|
||||
return true
|
||||
} else {
|
||||
console.log("complete error")
|
||||
wx.showToast({
|
||||
title: "操作失败 ",
|
||||
icon: 'none',
|
||||
duration: 3000
|
||||
})
|
||||
return false
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
},
|
||||
/**
|
||||
* 控制设备数据
|
||||
*/
|
||||
controlDeviceData(e) {
|
||||
let that = this
|
||||
wx.showLoading()
|
||||
|
||||
let data = e.detail.value
|
||||
if (data.power_switch == true) {
|
||||
data.power_switch = 1
|
||||
} else {
|
||||
data.power_switch = 0
|
||||
}
|
||||
console.log('form data:', e.detail.value)
|
||||
if (that.data.detail.status == "在线"){
|
||||
onenet.sendCmd(that.data.detail.id, data)
|
||||
}else{
|
||||
wx.showToast({
|
||||
title: "操作失败 " + "设备不在线",
|
||||
icon: 'none',
|
||||
duration: 3000
|
||||
})
|
||||
}
|
||||
|
||||
},
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage: function () {
|
||||
|
||||
}
|
||||
})
|
@ -0,0 +1,3 @@
|
||||
{
|
||||
"usingComponents": {}
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
<!--pages/device/device.wxml-->
|
||||
<view class="body">
|
||||
<view style="font-weight: bold;">
|
||||
设备信息
|
||||
</view>
|
||||
<view class="box">
|
||||
<view class="cell">
|
||||
<view class="status-left">设备ID</view>
|
||||
<view class="status-right">{{detail.id}}</view>
|
||||
</view>
|
||||
<view class="cell">
|
||||
<view class="status-left">设备名称</view>
|
||||
<view class="status-right">{{detail.name}}</view>
|
||||
</view>
|
||||
<view class="cell">
|
||||
<view class="status-left">设备状态</view>
|
||||
<view class="status-right">{{detail.status}}</view>
|
||||
</view>
|
||||
<view class="cell">
|
||||
<view class="status-left">环境温度</view>
|
||||
<view class="status-right">{{deviceData.temperature}}℃</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<text>\n</text>
|
||||
|
||||
<form bindsubmit="controlDeviceData">
|
||||
<view style="display:flex; flex-direction:row; justify-content: space-between;">
|
||||
<view style="font-weight: bold;">
|
||||
IOT Demo
|
||||
</view>
|
||||
<view>
|
||||
<button type="primary" size="mini" bindtap="queryDeviceData">查询</button>
|
||||
<button style="margin-left:20rpx" type="primary" size="mini" form-type="submit">发送</button>
|
||||
</view>
|
||||
</view>
|
||||
<view class="box">
|
||||
<view class="cell">
|
||||
<view>开关</view>
|
||||
<view>
|
||||
<switch name="power_switch" checked="{{deviceData.power_switch}}" />
|
||||
</view>
|
||||
</view>
|
||||
<view class="cell">
|
||||
<view>颜色</view>
|
||||
<view>
|
||||
<radio-group name="color">
|
||||
<label style="color:{{item.color}}" class="radio" wx:for="{{items}}" wx:key="unique" wx:for-index="idx">
|
||||
<radio color="{{item.color}}" value="{{item.value}}" checked="{{idx == deviceData.color.Value}}" />{{item.name}}
|
||||
</label>
|
||||
</radio-group>
|
||||
</view>
|
||||
</view>
|
||||
<view class="cell">
|
||||
<view>亮度</view>
|
||||
<view style="width:80%">
|
||||
<slider name="brightness" min="0" max="100" value="{{deviceData.brightness.Value}}" show-value/>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</form>
|
||||
</view>
|
@ -0,0 +1,17 @@
|
||||
/* pages/device/device.wxss */
|
||||
.body {
|
||||
margin: 10rpx 20rpx;
|
||||
}
|
||||
|
||||
.box {
|
||||
padding: 0rpx 20rpx;
|
||||
border-top: 2px solid #000;
|
||||
}
|
||||
|
||||
.cell {
|
||||
margin-top: 10rpx;
|
||||
margin-bottom: 40rpx;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
// pages/find/detail/detail.js
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
detail: {
|
||||
name: "",
|
||||
img: "",
|
||||
desc: ""
|
||||
},
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad: function (options) {
|
||||
console.log(options)
|
||||
this.setData({
|
||||
detail: options,
|
||||
}
|
||||
)
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage: function () {
|
||||
|
||||
}
|
||||
})
|
@ -0,0 +1,3 @@
|
||||
{
|
||||
"usingComponents": {}
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
<!--pages/find/detail/detail.wxml-->
|
||||
<image mode="widthFix" src="{{detail.img}}" sytle="height:auto"></image>
|
||||
|
@ -0,0 +1 @@
|
||||
/* pages/find/detail/detail.wxss */
|
86
demo/4_微信小程序/不适用云服务/wechat_ali_esp8266/pages/find/find.js
Normal file
@ -0,0 +1,86 @@
|
||||
// pages/find/find.js
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
date: "",
|
||||
stories: [],
|
||||
top_stories: [],
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad: function (options) {
|
||||
let that = this
|
||||
wx.request({
|
||||
url: 'https://news-at.zhihu.com/api/4/news/latest',
|
||||
header: {
|
||||
'content-type': 'application/json'
|
||||
},
|
||||
success(res) {
|
||||
let date = res.data.date
|
||||
let stories = res.data.stories
|
||||
let top_stories = res.data.top_stories
|
||||
console.log('date数据', date)
|
||||
console.log('stories数据', stories)
|
||||
console.log('top_stories数据', top_stories)
|
||||
that.setData({
|
||||
date, stories, top_stories
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage: function () {
|
||||
|
||||
}
|
||||
})
|
@ -0,0 +1,3 @@
|
||||
{
|
||||
"navigationBarTitleText": "发现"
|
||||
}
|
14
demo/4_微信小程序/不适用云服务/wechat_ali_esp8266/pages/find/find.wxml
Normal file
@ -0,0 +1,14 @@
|
||||
<view class="page__bd">
|
||||
<view class="weui-panel weui-panel_access">
|
||||
<view class="weui-panel__bd" wx:for="{{stories}}" wx:for-item="stories" wx:key="*item">
|
||||
<navigator url="" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active">
|
||||
<view class="weui-media-box__hd weui-media-box__hd_in-appmsg">
|
||||
<image class="weui-media-box__thumb" mode="widthFix" src="{{stories.images[0]}}" sytle="height:auto"></image>
|
||||
</view>
|
||||
<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
|
||||
<view class="weui-media-box__title">{{stories.title}}</view>
|
||||
</view>
|
||||
</navigator>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
@ -0,0 +1,4 @@
|
||||
/* pages/find/find.wxss */
|
||||
.weui-media-box__hd_in-appmsg{
|
||||
height: auto;
|
||||
}
|
107
demo/4_微信小程序/不适用云服务/wechat_ali_esp8266/pages/home/home.js
Normal file
@ -0,0 +1,107 @@
|
||||
// pages/home/home.js
|
||||
var app = getApp();
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
devices: [],
|
||||
imgUrls: [
|
||||
'https://images.unsplash.com/photo-1551334787-21e6bd3ab135?w=640',
|
||||
'https://images.unsplash.com/photo-1551214012-84f95e060dee?w=640',
|
||||
'https://images.unsplash.com/photo-1551446591-142875a901a1?w=640'
|
||||
],
|
||||
interval: 5000,
|
||||
duration: 1000,
|
||||
indicatorDots: true,
|
||||
indicatorColor: "#ffffff",
|
||||
activecolor: "#2971f6",
|
||||
autoplay: true,
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad: function (options) {
|
||||
var that = this;
|
||||
var name = ''
|
||||
var devices_origin = ''
|
||||
|
||||
console.log("onloading......");
|
||||
// setTimeout(function () {
|
||||
// onenet.getAllDeviceStatus()
|
||||
// }, 3000);
|
||||
|
||||
// 从app页面的devicesList中获取设备列表
|
||||
devices_origin = app.globalData.devices
|
||||
|
||||
|
||||
for (var i = 0; i < devices_origin.length; i++) {
|
||||
name = 'room_name_' + devices_origin[i].id
|
||||
try {
|
||||
var value = wx.getStorageSync(name)
|
||||
if (value) {
|
||||
devices_origin[i].room_name = value;
|
||||
}
|
||||
} catch (e) {
|
||||
// Do something when catch error
|
||||
console.log("get stroage data error!")
|
||||
}
|
||||
}
|
||||
|
||||
that.setData({
|
||||
devices: devices_origin
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage: function () {
|
||||
|
||||
}
|
||||
})
|
@ -0,0 +1,3 @@
|
||||
{
|
||||
"navigationBarTitleText": "首页"
|
||||
}
|
41
demo/4_微信小程序/不适用云服务/wechat_ali_esp8266/pages/home/home.wxml
Normal file
@ -0,0 +1,41 @@
|
||||
<view class="home-top">
|
||||
<view class="home-swiper">
|
||||
<swiper indicator-dots="{{indicatorDots}}" autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}" indicator-color="{{indicatorColor}}" indicator-active-color="{{activecolor}}">
|
||||
<block wx:for="{{imgUrls}}" wx:key="*this" >
|
||||
<swiper-item>
|
||||
<image src="{{item}}" style="width:100%;height:200px" class="slide-image" mode="widthFix" />
|
||||
</swiper-item>
|
||||
</block>
|
||||
</swiper>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="commen_title">
|
||||
<text>设备列表</text>
|
||||
</view>
|
||||
<view>
|
||||
<view wx:for="{{devices}}" wx:key="id" wx:for-item="item" data-id="{{item.id}}" bindtap="toDetailsTap">
|
||||
<view class="device">
|
||||
<view class="single_image_wrap">
|
||||
<image src="../../image/led/led.jpg" class="device_image"></image>
|
||||
</view>
|
||||
<view class="device_info">
|
||||
<navigator url="../device/device?id={{item.id}}&name={{item.title}}&status={{item.online === true ? ' 在线' : '离线'}}">
|
||||
<view class="device_name">
|
||||
<text>{{item.title}}</text>
|
||||
</view>
|
||||
<view class="device_d">
|
||||
<view class="room">
|
||||
<text>{{item.room_name}}</text>
|
||||
</view>
|
||||
<view class="device_status">
|
||||
<text>{{item.online === true ? ' 在线' : '离线'}}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</navigator>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</view>
|
80
demo/4_微信小程序/不适用云服务/wechat_ali_esp8266/pages/home/home.wxss
Normal file
@ -0,0 +1,80 @@
|
||||
.event-list{
|
||||
background-color: #fafbfc;
|
||||
padding: 20px 0;
|
||||
}
|
||||
.event-link{
|
||||
margin: 10px;
|
||||
border-radius: 5px;
|
||||
background-color: #fff;
|
||||
box-shadow:5rpx 8rpx 10rpx rgba(53,178,225,0.26);
|
||||
overflow: hidden;
|
||||
}
|
||||
.event-img image{
|
||||
width: 100%;
|
||||
}
|
||||
.event-content{
|
||||
padding: 25rpx;
|
||||
}
|
||||
.event-title{
|
||||
line-height: 1.7em;
|
||||
}
|
||||
.event-desc{
|
||||
font-size: 14px;
|
||||
color: #666;
|
||||
line-height: 1.5em;
|
||||
font-weight: 200;
|
||||
}
|
||||
.event-box{
|
||||
margin-top: 15px;
|
||||
overflow: hidden;
|
||||
}
|
||||
.event-address,.event-time{
|
||||
float: left;
|
||||
color: #cecece;
|
||||
font-size: 12px;
|
||||
padding-right: 15px;
|
||||
}
|
||||
.commen_title {
|
||||
padding: 10px;
|
||||
background-color: #fff;
|
||||
font-size: 16px;
|
||||
border-bottom: 1px solid #E9E9E9;
|
||||
}
|
||||
.device {
|
||||
position: relative;
|
||||
height: 120rpx;
|
||||
background-color: #FFF;
|
||||
padding-left: 80rpx;
|
||||
border-bottom: 1rpx solid #E7E7EB;
|
||||
}
|
||||
.single_image_wrap {
|
||||
position: absolute;
|
||||
left: 10rpx;
|
||||
}
|
||||
.device_image {
|
||||
width: 100rpx;
|
||||
height: 100rpx;
|
||||
}
|
||||
.device_info {
|
||||
position: relative;
|
||||
height: 100rpx;
|
||||
margin-left: 40rpx;
|
||||
}
|
||||
.device_name {
|
||||
font-size: 14px;
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
.device_d{
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-between
|
||||
}
|
||||
.room {
|
||||
color: #929292;
|
||||
font-size: 12px;
|
||||
}
|
||||
.device_status {
|
||||
font-size: 14px;
|
||||
color: #FF1493;
|
||||
margin-right: 40rpx;
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
// pages/home/list/list.js
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad: function (options) {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage: function () {
|
||||
|
||||
}
|
||||
})
|
@ -0,0 +1,3 @@
|
||||
{
|
||||
"usingComponents": {}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
<view class="page__bd">
|
||||
<view class="weui-article">
|
||||
<view class="weui-article__h1">HackWork技术工坊</view>
|
||||
<view class="weui-article__section">
|
||||
<view class="weui-article__p">HackWork技术工坊是技术普及的活动,致力于以有趣的形式让参与者学到有用的技术。任务式实战、系统指导以及社区学习能有效提高技术小白学习技术的效率以及热情。
|
||||
</view>
|
||||
<view class="weui-article__section">
|
||||
<view class="weui-article__h3">任务式实战</view>
|
||||
<view class="weui-article__p">
|
||||
每节都会有非常明确的学习任务,会引导你循序渐进地通过实战来掌握各个知识点。只有动手做过的技术才属于自己。
|
||||
</view>
|
||||
<view class="weui-article__p">
|
||||
<image class="weui-article__img" src="https://hackweek.oss-cn-shanghai.aliyuncs.com/hw18/hackwork/weapp/img1.jpg" mode="aspectFit" style="height: 180px" />
|
||||
</view>
|
||||
<view class="weui-article__h3">系统指导</view>
|
||||
<view class="weui-article__p">
|
||||
针对所有学习问题我们都会耐心解答,我们会提供详细的学习文档,对大家的学习进行系统指导。
|
||||
</view>
|
||||
<view class="weui-article__p">
|
||||
<image class="weui-article__img" src="https://hackweek.oss-cn-shanghai.aliyuncs.com/hw18/hackwork/weapp/img2.jpg" mode="aspectFit" style="height: 180px" />
|
||||
</view>
|
||||
<view class="weui-article__h3">社区学习</view>
|
||||
<view class="weui-article__p">
|
||||
参与活动即加入了我们的技术社区,我们会长期提供教学指导,不必担心学不会,也不用担心没有一起学习的伙伴。
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
@ -0,0 +1,2 @@
|
||||
|
||||
|
15
demo/4_微信小程序/不适用云服务/wechat_ali_esp8266/pages/logs/logs.js
Normal file
@ -0,0 +1,15 @@
|
||||
//logs.js
|
||||
const util = require('../../utils/util.js')
|
||||
|
||||
Page({
|
||||
data: {
|
||||
logs: []
|
||||
},
|
||||
onLoad: function () {
|
||||
this.setData({
|
||||
logs: (wx.getStorageSync('logs') || []).map(log => {
|
||||
return util.formatTime(new Date(log))
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
@ -0,0 +1,4 @@
|
||||
{
|
||||
"navigationBarTitleText": "查看启动日志",
|
||||
"usingComponents": {}
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
<!--logs.wxml-->
|
||||
<view class="container log-list">
|
||||
<block wx:for="{{logs}}" wx:for-item="log">
|
||||
<text class="log-item">{{index + 1}}. {{log}}</text>
|
||||
</block>
|
||||
</view>
|
@ -0,0 +1,8 @@
|
||||
.log-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 40rpx;
|
||||
}
|
||||
.log-item {
|
||||
margin: 10rpx;
|
||||
}
|
93
demo/4_微信小程序/不适用云服务/wechat_ali_esp8266/pages/my/map/map.js
Normal file
@ -0,0 +1,93 @@
|
||||
// pages/my/map/map.js
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
latitude: 22.540503,
|
||||
longitude: 113.934528,
|
||||
markers: [
|
||||
{
|
||||
id: 1,
|
||||
latitude: 22.540503,
|
||||
longitude: 113.934528,
|
||||
title: '深圳腾讯大厦'
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
latitude: 22.540576,
|
||||
longitude: 113.933790,
|
||||
title: '万利达科技大厦'
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
latitude: 22.522807,
|
||||
longitude: 113.935338,
|
||||
title: '深圳腾讯滨海大厦'
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
latitude: 22.547400,
|
||||
longitude: 113.944370,
|
||||
title: '腾讯C2'
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad: function (options) {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage: function () {
|
||||
|
||||
}
|
||||
})
|
@ -0,0 +1,3 @@
|
||||
{
|
||||
"usingComponents": {}
|
||||
}
|
10
demo/4_微信小程序/不适用云服务/wechat_ali_esp8266/pages/my/map/map.wxml
Normal file
@ -0,0 +1,10 @@
|
||||
<!--pages/my/map/map.wxml-->
|
||||
<map
|
||||
id="myMap"
|
||||
style="width: 100%; height: 300px;"
|
||||
latitude="{{latitude}}"
|
||||
longitude="{{longitude}}"
|
||||
markers="{{markers}}"
|
||||
covers="{{covers}}"
|
||||
show-location
|
||||
></map>
|
@ -0,0 +1 @@
|
||||
/* pages/my/map/map.wxss */
|
118
demo/4_微信小程序/不适用云服务/wechat_ali_esp8266/pages/my/my.js
Normal file
@ -0,0 +1,118 @@
|
||||
// pages/my/my.js
|
||||
//获取应用实例
|
||||
const app = getApp()
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
userInfo: {},
|
||||
hasUserInfo: false,
|
||||
listicons: [{
|
||||
icon: "https://hackweek.oss-cn-shanghai.aliyuncs.com/hw18/hackwork/weapp/listicons1.png",
|
||||
title: "文件",
|
||||
desc: "",
|
||||
url: ""
|
||||
},
|
||||
{
|
||||
icon: "https://hackweek.oss-cn-shanghai.aliyuncs.com/hw18/hackwork/weapp/listicons2.png",
|
||||
title: "收藏",
|
||||
desc: "",
|
||||
url: ""
|
||||
},
|
||||
{
|
||||
icon: "https://hackweek.oss-cn-shanghai.aliyuncs.com/hw18/hackwork/weapp/listicons3.png",
|
||||
title: "设置",
|
||||
desc: "",
|
||||
url: "./../my/set/set"
|
||||
},
|
||||
{
|
||||
icon: "https://hackweek.oss-cn-shanghai.aliyuncs.com/hw18/hackwork/weapp/listicons3.png",
|
||||
title: "地图",
|
||||
desc: "",
|
||||
url:"./../my/map/map"
|
||||
}
|
||||
],
|
||||
},
|
||||
//事件处理函数
|
||||
bindViewTap: function () {
|
||||
wx.navigateTo({
|
||||
url: '../logs/logs'
|
||||
})
|
||||
},
|
||||
getUserInfo: function (e) {
|
||||
console.log(e)
|
||||
app.globalData.userInfo = e.detail.userInfo
|
||||
this.setData({
|
||||
userInfo: e.detail.userInfo,
|
||||
hasUserInfo: true
|
||||
})
|
||||
},
|
||||
//事件处理函数
|
||||
bindViewTap: function () {
|
||||
wx.navigateTo({
|
||||
url: '../logs/logs'
|
||||
})
|
||||
},
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad: function (options) {
|
||||
if (app.globalData.userInfo) {
|
||||
this.setData({
|
||||
userInfo: app.globalData.userInfo,
|
||||
hasUserInfo: true
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage: function () {
|
||||
|
||||
}
|
||||
})
|
3
demo/4_微信小程序/不适用云服务/wechat_ali_esp8266/pages/my/my.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"navigationBarTitleText": "我的"
|
||||
}
|
26
demo/4_微信小程序/不适用云服务/wechat_ali_esp8266/pages/my/my.wxml
Normal file
@ -0,0 +1,26 @@
|
||||
<view class="container">
|
||||
<view class="userinfo">
|
||||
<button wx:if="{{!hasUserInfo}}" open-type="getUserInfo" bindgetuserinfo="getUserInfo"> 获取头像昵称 </button>
|
||||
<block wx:else>
|
||||
<image bindtap="bindViewTap" class="userinfo-avatar" src="{{userInfo.avatarUrl}}" mode="cover"></image>
|
||||
<text class="userinfo-nickname">{{userInfo.nickName}}</text>
|
||||
</block>
|
||||
</view>
|
||||
</view>
|
||||
<view class="weui-cells weui-cells_after-title">
|
||||
<block wx:for="{{listicons}}" wx:for-item="listicons">
|
||||
<navigator url="{{listicons.url}}" class="weui-cell weui-cell_access" hover-class="weui-cell_active">
|
||||
<view class="weui-cell__hd">
|
||||
<image src="{{listicons.icon}}" style="margin-right: 5px;vertical-align: middle;width:20px; height: 20px;"></image>
|
||||
</view>
|
||||
<view class="weui-cell__bd">{{listicons.title}}</view>
|
||||
<view class="weui-cell__ft weui-cell__ft_in-access">{{listicons.desc}}</view>
|
||||
</navigator>
|
||||
</block>
|
||||
</view>
|
||||
<view>
|
||||
<button class="wode_help" open-type="contact" >客服</button>
|
||||
</view>
|
||||
|
||||
|
||||
|
28
demo/4_微信小程序/不适用云服务/wechat_ali_esp8266/pages/my/my.wxss
Normal file
@ -0,0 +1,28 @@
|
||||
/* pages/my/my.wxss */
|
||||
.userinfo {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
.container {
|
||||
padding: 20px 0;
|
||||
background-color: #FFF;
|
||||
}
|
||||
.userinfo-avatar {
|
||||
width: 128rpx;
|
||||
height: 128rpx;
|
||||
margin: 20rpx;
|
||||
border-radius: 50%;
|
||||
}
|
||||
.userinfo-nickname {
|
||||
color: #aaa;
|
||||
}
|
||||
.wode_help {
|
||||
height: 50px;
|
||||
line-height: 45px;
|
||||
text-align: center;
|
||||
background-color: #FFF;
|
||||
margin-top: 10px;
|
||||
border-bottom: 1px solid #E5E5E5;
|
||||
border-top: 1px solid #E5E5E5;
|
||||
}
|
82
demo/4_微信小程序/不适用云服务/wechat_ali_esp8266/pages/my/set/set.js
Normal file
@ -0,0 +1,82 @@
|
||||
// pages/my/set/set.js
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
userDevicesId: null,
|
||||
inputValue: '你还没输入内容呢'
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad: function (options) {
|
||||
|
||||
},
|
||||
formSubmit: function (e) {
|
||||
console.log('表单携带的数据为:', e.detail.value)
|
||||
const gamecheck = e.detail.value.gamecheck
|
||||
console.log('直接打印的gamecheck', gamecheck)
|
||||
console.log('拓展运算符打印的gamecheck', ...gamecheck)
|
||||
},
|
||||
formReset: function () {
|
||||
console.log('表单重置了')
|
||||
},
|
||||
bindKeyInput: function (e) {
|
||||
const inputValue = e.detail.value
|
||||
console.log('响应式渲染', e.detail)
|
||||
this.setData({
|
||||
inputValue
|
||||
})
|
||||
},
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage: function () {
|
||||
|
||||
}
|
||||
})
|
@ -0,0 +1,3 @@
|
||||
{
|
||||
"usingComponents": {}
|
||||
}
|
26
demo/4_微信小程序/不适用云服务/wechat_ali_esp8266/pages/my/set/set.wxml
Normal file
@ -0,0 +1,26 @@
|
||||
<!--pages/my/set/set.wxml-->
|
||||
<form bindsubmit="formSubmit" bindrest="formReset">
|
||||
<view>开关选择器按钮</view>
|
||||
<switch name="switch"/>
|
||||
<view>滑动选择器按钮slider</view>
|
||||
<slider name="process" show-value ></slider>
|
||||
<view>文本输入框</view>
|
||||
<input name="textinput" bindinput="bindKeyInput" placeholder="要输入的文本" />
|
||||
<view>单选按钮radio</view>
|
||||
<radio-group name="sex">
|
||||
<label><radio value="male"/>男</label>
|
||||
<label><radio value="female"/>女</label>
|
||||
</radio-group>
|
||||
<view>多选按钮checkbox</view>
|
||||
<checkbox-group name="gamecheck">
|
||||
<label><checkbox value="game1"/>王者荣耀</label>
|
||||
<label><checkbox value="game2"/>欢乐斗地主</label>
|
||||
<label><checkbox value="game3"/>连连看</label>
|
||||
<label><checkbox value="game4"/>刺激战场</label>
|
||||
<label><checkbox value="game5"/>穿越火线</label>
|
||||
<label><checkbox value="game6"/>天天酷跑</label>
|
||||
</checkbox-group>
|
||||
<button form-type="submit">提交</button>
|
||||
<button form-type="reset">重置</button>
|
||||
</form>
|
||||
<view>你输入的是:{{inputValue}}</view>
|
@ -0,0 +1 @@
|
||||
/* pages/my/set/set.wxss */
|
119
demo/4_微信小程序/不适用云服务/wechat_ali_esp8266/pages/start/start.js
Normal file
@ -0,0 +1,119 @@
|
||||
// pages/start/start.js
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
remind: '加载中',
|
||||
angle: 0,
|
||||
},
|
||||
goToIndex: function () {
|
||||
wx.switchTab({
|
||||
url: '/pages/home/home',
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad: function (options) {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady: function () {
|
||||
var that = this;
|
||||
setTimeout(function () {
|
||||
that.setData({
|
||||
remind: ''
|
||||
});
|
||||
}, 1000);
|
||||
wx.onAccelerometerChange(function (res) {
|
||||
var angle = -(res.x * 30).toFixed(1);
|
||||
if (angle > 14) { angle = 14; }
|
||||
else if (angle < -14) { angle = -14; }
|
||||
if (that.data.angle !== angle) {
|
||||
that.setData({
|
||||
angle: angle
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
bindGetUserInfo(res) {
|
||||
var that = this;
|
||||
let app = getApp()
|
||||
app.globalData.userInfo = res.detail.userInfo
|
||||
// 登录
|
||||
wx.login({
|
||||
success: res => {
|
||||
// 发送 res.code 到后台换取 openId, sessionKey, unionId
|
||||
}
|
||||
})
|
||||
// 获取用户信息
|
||||
wx.getSetting({
|
||||
success: res => {
|
||||
if (res.authSetting['scope.userInfo']) {
|
||||
// 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
|
||||
wx.getUserInfo({
|
||||
success(res) {
|
||||
console.log("授权成功");
|
||||
that.goToIndex();
|
||||
// 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
|
||||
// 所以此处加入 callback 以防止这种情况
|
||||
if (that.userInfoReadyCallback) {
|
||||
that.userInfoReadyCallback(res)
|
||||
}
|
||||
}
|
||||
})
|
||||
} else {
|
||||
that.goToIndex();
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
},
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage: function () {
|
||||
|
||||
}
|
||||
})
|
@ -0,0 +1,5 @@
|
||||
{
|
||||
"navigationBarTitleText": " ",
|
||||
"enablePullDownRefresh": false,
|
||||
"disableScroll": true
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
<view>
|
||||
<image src="/image/start/start.png" class='welcome-img'></image>
|
||||
<button class="welcome-btn" open-type="getUserInfo" bindgetuserinfo="bindGetUserInfo">授权登录</button>
|
||||
|
||||
</view>
|
@ -0,0 +1,25 @@
|
||||
image {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.welcome-img {
|
||||
position: absolute;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.welcome-btn {
|
||||
background-color: #27e4b5;
|
||||
color: white;
|
||||
font-size: 38rpx;
|
||||
width: 330rpx;
|
||||
height: 90rpx;
|
||||
text-align: center;
|
||||
line-height: 90rpx;
|
||||
border-radius: 10px;
|
||||
position: absolute;
|
||||
bottom: 120rpx;
|
||||
left: 20px;
|
||||
right:20px;
|
||||
z-index: 2;
|
||||
}
|
52
demo/4_微信小程序/不适用云服务/wechat_ali_esp8266/project.config.json
Normal file
@ -0,0 +1,52 @@
|
||||
{
|
||||
"description": "项目配置文件",
|
||||
"packOptions": {
|
||||
"ignore": []
|
||||
},
|
||||
"setting": {
|
||||
"urlCheck": true,
|
||||
"es6": true,
|
||||
"enhance": true,
|
||||
"postcss": true,
|
||||
"minified": true,
|
||||
"newFeature": true,
|
||||
"coverView": true,
|
||||
"autoAudits": false,
|
||||
"checkInvalidKey": true,
|
||||
"checkSiteMap": true,
|
||||
"uploadWithSourceMap": true,
|
||||
"babelSetting": {
|
||||
"ignore": [],
|
||||
"disablePlugins": [],
|
||||
"outputPath": ""
|
||||
}
|
||||
},
|
||||
"compileType": "miniprogram",
|
||||
"libVersion": "2.10.1",
|
||||
"appid": "wx5b7604de7dd065b4",
|
||||
"projectname": "wechat_onenet_esp8266",
|
||||
"debugOptions": {
|
||||
"hidedInDevtools": []
|
||||
},
|
||||
"isGameTourist": false,
|
||||
"simulatorType": "wechat",
|
||||
"simulatorPluginLibVersion": {},
|
||||
"condition": {
|
||||
"search": {
|
||||
"current": -1,
|
||||
"list": []
|
||||
},
|
||||
"conversation": {
|
||||
"current": -1,
|
||||
"list": []
|
||||
},
|
||||
"game": {
|
||||
"currentL": -1,
|
||||
"list": []
|
||||
},
|
||||
"miniprogram": {
|
||||
"current": -1,
|
||||
"list": []
|
||||
}
|
||||
}
|
||||
}
|
7
demo/4_微信小程序/不适用云服务/wechat_ali_esp8266/sitemap.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html",
|
||||
"rules": [{
|
||||
"action": "allow",
|
||||
"page": "*"
|
||||
}]
|
||||
}
|
6
demo/4_微信小程序/不适用云服务/wechat_ali_esp8266/style/weui.wxss
Normal file
19
demo/4_微信小程序/不适用云服务/wechat_ali_esp8266/utils/util.js
Normal file
@ -0,0 +1,19 @@
|
||||
const formatTime = date => {
|
||||
const year = date.getFullYear()
|
||||
const month = date.getMonth() + 1
|
||||
const day = date.getDate()
|
||||
const hour = date.getHours()
|
||||
const minute = date.getMinutes()
|
||||
const second = date.getSeconds()
|
||||
|
||||
return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
|
||||
}
|
||||
|
||||
const formatNumber = n => {
|
||||
n = n.toString()
|
||||
return n[1] ? n : '0' + n
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
formatTime: formatTime
|
||||
}
|