瀏覽代碼

'增加:跳绳demo'

master
txw 3 年之前
父節點
當前提交
d33cb54fd5

+ 31
- 0
rope_skipping_demo/.eslintrc.js 查看文件

@@ -0,0 +1,31 @@
/*
* Eslint config file
* Documentation: https://eslint.org/docs/user-guide/configuring/
* Install the Eslint extension before using this feature.
*/
module.exports = {
env: {
es6: true,
browser: true,
node: true,
},
ecmaFeatures: {
modules: true,
},
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
},
globals: {
wx: true,
App: true,
Page: true,
getCurrentPages: true,
getApp: true,
Component: true,
requirePlugin: true,
requireMiniProgram: true,
},
// extends: 'eslint:recommended',
rules: {},
}

+ 19
- 0
rope_skipping_demo/app.js 查看文件

@@ -0,0 +1,19 @@
// app.js
App({
onLaunch() {
// 展示本地存储能力
const logs = wx.getStorageSync('logs') || []
logs.unshift(Date.now())
wx.setStorageSync('logs', logs)

// 登录
wx.login({
success: res => {
// 发送 res.code 到后台换取 openId, sessionKey, unionId
}
})
},
globalData: {
userInfo: null
}
})

+ 21
- 0
rope_skipping_demo/app.json 查看文件

@@ -0,0 +1,21 @@
{
"pages":[
"pages/index/index"
],
"window": {
"navigationBarBackgroundColor": "#0082FE",
"navigationBarTextStyle": "white",
"navigationBarTitleText": "跳绳Demo",
"backgroundColor": "#eeeeee",
"backgroundTextStyle": "light"
},
"plugins": {
"sdkPlugin": {
"version": "2.1.0",
"provider": "wx17e93aad47cdae1a"
}
},
"style": "v2",
"sitemapLocation": "sitemap.json"
}


+ 1
- 0
rope_skipping_demo/app.wxss 查看文件

@@ -0,0 +1 @@
/**app.wxss**/

+ 614
- 0
rope_skipping_demo/pages/index/index.js 查看文件

@@ -0,0 +1,614 @@
const util = require("../../utils/util");

const plugin = requirePlugin("sdkPlugin").AiLink;


function inArray(arr, key, val) {
if (!arr || !arr.length || typeof arr != 'object' || !Array.isArray(arr)) {
return -1
}
for (let i = 0; i < arr.length; i++) {
if (!key) {
if (arr[i] == val) {
return i
}
} else if (arr[i][key] === val) {
return i
}
}
return -1;
}

// ArrayBuffer转16进度字符串示例
function ab2hex(buffer, split) {
var hexArr = Array.prototype.map.call(
new Uint8Array(buffer),
function (bit) {
return ('00' + bit.toString(16)).slice(-2)
}
)
return hexArr.join(split);
}

Page({
data: {
showWriteInput: false,
devices: [
// {
// deviceId: "02:03:04:05:06:07",
// name: "elink",
// localName: "elink",
// mac: "02:03:04:05:06:07",
// RSSI: -69,
// advertisServiceUUIDs:[
// "FFE0","FFC0"
// ],
// analyzeDataText:"0102003241123413"
// }
],
connected: false,
chs: [],
cmd: '',
name: '',
deviceId: null,
historyList: [],
state:'',
electricity:'',
model:'',
skipNumber:'',
skipTime:'',
cumulativeNumber:'',
finishArr:{},
stumbleRope:[
],
isStumbleRope:1,
historicalRecord:'',
isSupport:'',
record:'',
// isHistoricalRecord:false
},
onLoad: function () {
let historyList = []
historyList = wx.getStorageSync('historyList')
this.setData({
historyList,
})
},

// 初始化蓝牙模块
openBluetoothAdapter() {
wx.openBluetoothAdapter({
success: (res) => {
;
console.log('openBluetoothAdapter success', res)
this.startBluetoothDevicesDiscovery()
},
fail: (res) => {
;
if (res.errCode === 10001) {
wx.showToast({
title: '请打开蓝牙',
icon: "none"
})
wx.onBluetoothAdapterStateChange(function (res) {
console.log('onBluetoothAdapterStateChange', res)
if (res.available) {
this.startBluetoothDevicesDiscovery()
}
})
}
}
})
},
// 获取本机蓝牙适配器状态
getBluetoothAdapterState() {
wx.getBluetoothAdapterState({
success: (res) => {
;
console.log('getBluetoothAdapterState', res)
if (res.discovering) {
this.onBluetoothDeviceFound()
} else if (res.available) {
this.startBluetoothDevicesDiscovery()
}
}
})
},
// 开始搜寻附近的蓝牙外围设备
startBluetoothDevicesDiscovery() {
if (this._discoveryStarted) {
return
}
this._discoveryStarted = true
wx.startBluetoothDevicesDiscovery({
allowDuplicatesKey: true,
services: [
"FFE0",
// "F0A0", // BM30广播模块需加上,如使用连接模块可忽略
],
success: (res) => {
;
console.log('startBluetoothDevicesDiscovery success', res)
this.onBluetoothDeviceFound()
},
})
},
// 停止搜寻附近的蓝牙外围设备
stopBluetoothDevicesDiscovery() {
wx.stopBluetoothDevicesDiscovery()
},

// 监听寻找到新设备的事件
onBluetoothDeviceFound() {
wx.onBluetoothDeviceFound((res) => {
res.devices.forEach(device => {
;
if (!device.name && !device.localName) {
return
}
const foundDevices = this.data.devices
const idx = inArray(foundDevices, 'deviceId', device.deviceId)
const data = {}
// console.log(device)
// console.log(ab2hex(device.advertisData))
// 此处判断是否BM30广播模块,如使用连接模块请删除此 if ,只保留 else 内容
if (device.advertisServiceUUIDs[0].indexOf("F0A0") !== -1) {
let parseDataRes = plugin.parseBroadcastData(device.advertisData)
console.log(parseDataRes)
if (parseDataRes.status == 1) {
let analyzeData = plugin.analyzeBroadcastScaleData(parseDataRes)
console.log(analyzeData)
device.analyzeDataText = analyzeData.text
}
} else {
let buff = device.advertisData.slice(-6)
device.mac = new Uint8Array(buff) // 保存广播数据中的mac地址,这是由于iOS不直接返回mac地址
let tempMac = Array.from(device.mac)
tempMac.reverse()
device.macAddr = ab2hex(tempMac, ':').toUpperCase()
}
if (idx === -1) {
data[`devices[${foundDevices.length}]`] = device
} else {
data[`devices[${idx}]`] = device
}
this.setData(data)
})
})
},
// 连接低功耗蓝牙设备
createBLEConnection(e) {
this._connLoading = true
wx.showLoading({
title: '连接中',
})
setTimeout(() => {
;
if (this._connLoading) {
this._connLoading = false
wx.hideLoading()
}
}, 6000)
const ds = e.currentTarget.dataset
const index = ds.index
// 保存当前连接的设备,注意不能从wxml的dataset中直接返回该对象,因为ArrarBuffer类型的数据无法保留
this._device = this.data.devices[index]
console.log(this._device)
const deviceId = ds.deviceId
const name = ds.name
this.mac = ds.mac
wx.createBLEConnection({
deviceId,
success: (res) => {
;
this.setData({
connected: true,
name,
deviceId,
})
console.log("createBLEConnection:success")
wx.stopBluetoothDevicesDiscovery()
this.onBLEConnectionStateChange()
this.getBLEDeviceServices(deviceId)
},
fail: res => {
;
this._connLoading = false
wx.hideLoading()
wx.showToast({
title: '连接失败',
icon: 'none'
})
}
})
// 连接上设备就可以停止蓝牙搜索,减少功耗。
this.stopBluetoothDevicesDiscovery()
},

onBLEConnectionStateChange() {
wx.onBLEConnectionStateChange((res) => {
console.log('wx.onBLEConnectionStateChange() ', res.deviceId, res.connected, res.errorCode, res.errorMsg)
// 该方法回调中可以用于处理连接意外断开等异常情况
// console.log(`%c device ${res.deviceId} state has changed, connected: ${res.connected}`, 'color: #F26363')
if (!res.connected) {
;
wx.showToast({
title: '连接已断开',
icon: 'none'
})
this.setData({
connected: false,
showWriteInput: false,
})
}
})
},

// 断开与低功耗蓝牙设备的连接
closeBLEConnection() {
wx.closeBLEConnection({
deviceId: this._deviceId
})
this.setData({
connected: false,
chs: [],
showWriteInput: false,
})
},

// 获取蓝牙设备的 serviceId
getBLEDeviceServices(deviceId) {
wx.getBLEDeviceServices({
deviceId,
success: (res) => {
;
for (let i = 0; i < res.services.length; i++) {
if (res.services[i].isPrimary && res.services[i].uuid.indexOf('FFE0') > -1) {
this.getBLEDeviceCharacteristics(deviceId, res.services[i].uuid)
return
}
}
}
})
},

// 获取蓝牙设备某个服务中所有特征值(characteristic)
getBLEDeviceCharacteristics(deviceId, serviceId) {
this._deviceId = deviceId
this._serviceId = serviceId
this._device.serviceId = serviceId

wx.getBLEDeviceCharacteristics({
deviceId,
serviceId,
success: (res) => {
;
console.log('getBLEDeviceCharacteristics success', res.characteristics)

// 这部分功能在插件的 initPlugin 中已实现,如需用到其中的 uuid 也可取消注释
// // let uuid1, uuid2, uuid3;
for (let i = 0; i < res.characteristics.length; i++) {
let item = res.characteristics[i]
if (item.uuid.indexOf('0000FFE1') != -1) {
this.uuid1 = item.uuid //下发数据
} else if (item.uuid.indexOf('0000FFE2') != -1) {
this.uuid2 = item.uuid //监听数据
} else if (item.uuid.indexOf('0000FFE3') != -1) {
this.uuid3 = item.uuid //写入设置
}
}
// 打开监听
wx.notifyBLECharacteristicValueChange({
deviceId,
serviceId,
characteristicId: this.uuid2,
state: true,
})
wx.notifyBLECharacteristicValueChange({
deviceId,
serviceId,
characteristicId: this.uuid3,
state: true,
})

// 初始化插件
plugin.initPlugin(res.characteristics, this._device)

wx.onBLECharacteristicValueChange((characteristic) => {
// 解析特征值,返回解密后的数据
let bleData = plugin.parseBleData(characteristic.value)
console.log('蓝牙返回',bleData)
if (bleData.status == 0) {
console.log("握手成功")
this._connLoading = false
wx.hideLoading()
wx.showToast({
title: '连接成功',
})
this.setData({
showWriteInput : true
})
} else if (bleData.status == 1) {
let payload = bleData.data //对应协议中的payload数据,可以自行解析该数据
if (payload[0] === 0x10) {
this.setData({
isStumbleRope:1
})
let skipNumber = payload[4] * 256 + payload[3]
let skipTime = payload[6] * 256 + payload[5]
let cumulativeNumber = payload[8] * 256 + payload[7]
this.setData({
state:(payload[1]),//状态
model:(payload[2]),//模式
electricity:(payload[9]),//电量
skipNumber:skipNumber,//跳绳数量
skipTime:skipTime,//跳绳时间
cumulativeNumber:cumulativeNumber//累计个数
})
}else if(payload[0] === 0x20){
let str = payload[1].toString(16)
let laststring = str.substring(str.length-1)
if (laststring == 0) {
var timeStamp = payload[2]+payload[3]*256+payload[4]*65536+payload[5]*16777216//时间戳
var model = (payload[6]).toString(16)//模式
var skipNumber = payload[8] * 256 + payload[7]//跳绳数量
this.setData({
['finishArr.timeStamp']:timeStamp,
['finishArr.model']:model,
['finishArr.skipNumber']:skipNumber,
})
}else if(laststring == 1){
var skipTime = payload[3] * 256 + payload[2]//跳绳时间
var cumulativeNumber = payload[5] * 256 + payload[4]//累计个数
var averageVelocity = payload[7] * 256 + payload[6]//平均速度
var prestissimo = payload[9] * 256 + payload[8]//最快速度
this.setData({
['finishArr.skipTime']:skipTime,
['finishArr.cumulativeNumber']:cumulativeNumber,
['finishArr.averageVelocity']:averageVelocity,
['finishArr.prestissimo']:prestissimo,
})
}else{
if (payload[2] != 65535 && payload[4] != 65535) {
var stumbleRopeZeroTime = payload[3] * 256 + payload[2]
var stumbleRopeZeroNum = payload[5] * 256 + payload[4]
}
if (payload[6] != 65535 && payload[8] != 65535) {
var stumbleRopeOneTime = payload[7] * 256 + payload[6]
var stumbleRopeOneNum = payload[9] * 256 + payload[8]
}
if (payload[10] != 65535 && payload[12] != 65535) {
var stumbleRopeTwoTime = payload[11] * 256 + payload[10]
var stumbleRopeTwoNum = payload[13] * 256 + payload[12]
}
let stumbleRopeOjeckt = {
stumbleRopeZeroTime:stumbleRopeZeroTime,
stumbleRopeZeroNum:stumbleRopeZeroNum,
stumbleRopeOneTime:stumbleRopeOneTime,
stumbleRopeOneNum:stumbleRopeOneNum,
stumbleRopeTwoTime:stumbleRopeTwoTime,
stumbleRopeTwoNum:stumbleRopeTwoNum,
}
var temp = []
temp.push(stumbleRopeOjeckt)
this.setData({
stumbleRope:temp
})
}
this.setData({
isStumbleRope:2
})
}
}else if(bleData.status == 2){
let payload = bleData.data
if (payload[0].toString(16) == 'f1') {
let historicalRecord = payload[1]//请求历史记录标识
let isSupport = payload[2]//是否支持
let record = payload[4] * 256 + payload[3]
this.setData({
historicalRecord:historicalRecord,
isSupport:isSupport,
record:record,
isStumbleRope:3,
})
}
}
const idx = inArray(this.data.chs, 'uuid', characteristic.characteristicId)
const data = {}
if (idx === -1) {
data[`chs[${this.data.chs.length}]`] = {
uuid: characteristic.characteristicId,
value: ab2hex(bleData.completeData, ' ')
}
} else {
data[`chs[${idx}]`] = {
uuid: characteristic.characteristicId,
value: ab2hex(bleData.completeData, ' ')
}
}
this.setData(data)
})
},
fail(res) {
console.error('getBLEDeviceCharacteristics', res)
}
})
},
writeBLECharacteristicValue(buffer, uuid, deviceId, serviceId) {
// 向蓝牙设备发送一个二进制流数据
wx.writeBLECharacteristicValue({
deviceId,
serviceId,
characteristicId: uuid,
value: buffer,
success(res) {
;
console.log('writeBLECharacteristicValue success', res)
console.log('下发指令==> ' + ab2hex(buffer))
}
})
},
closeBluetoothAdapter() {
wx.closeBluetoothAdapter()
this._discoveryStarted = false
},
//发送指令给设备
SendInstructions(e){
let key = e.currentTarget.dataset.index
let cmd = ''
switch (key) {
case '1':
cmd = 'a7,00,2f,05,00,67,28,9f,61,c3,7a'
this.submitCmd(null,cmd)
break;
case '2':
cmd = 'a7,00,2f,02,01,01,33,7a'
this.submitCmd(null,cmd)
this.setData({
isStumbleRope:1
})
break;
case '3':
cmd = 'a7,00,2f,02,01,00,32,7a'
this.submitCmd(null,cmd)
break;
case '4':
cmd = 'a7,00,2f,02,02,01,34,7a'
this.submitCmd(null,cmd)
this.setData({
isStumbleRope:1
})
break;
case '5':
cmd = 'a7,00,2f,02,02,00,33,7a'
this.submitCmd(null,cmd)
break;
case '6':
cmd = 'a7,00,2f,02,03,01,35,7a'
this.submitCmd(null,cmd)
this.setData({
isStumbleRope:1
})
break;
case '7':
cmd = 'a7,00,2f,02,03,00,34,7a'
this.submitCmd(null,cmd)
break;
case '8':
cmd = 'a7,00,2f,03,04,78,00,ae,7a'
this.submitCmd(null,cmd)
break;
case '9':
cmd = 'a7,00,2f,03,05,32,00,69,7a'
this.submitCmd(null,cmd)
break;
case '10':
cmd = 'a6,02,f1,01,f4,6a'
this.submitCmd(null,cmd)
break;
case '11':
cmd = 'a7,00,2f,02,b0,01,e2,7a'
this.submitCmd(null,cmd)
break;
}
},
// 指令下发
submitCmd(e, cmd) {
let arr = []
let temp = []
if (!cmd) {
cmd = this.data.cmd
}
console.log(cmd)
if(!cmd || !this.data.connected){
return
}
if(cmd.indexOf(",") == -1){
temp = cmd.split(" ")
} else {
temp = cmd.split(",")
}
let tempCmd = temp.join(' ')
for(let i = 0; i < temp.length; i++){
arr[i] = parseInt(temp[i],16)
}
// let arr = [
// 0xA6,
// 0x01,
// 0x28,
// 0x29,
// 0x6A,
// //A6 01 28 29 6A
// ]
if(arr[0] == 0xA6){
let len = arr[1]
let payload = arr.slice(2, 2 + len)
plugin.sendDataOfA6(payload)
// let buff = new Uint8Array(arr).buffer
// this.writeBLECharacteristicValue(buff, this.uuid3, this._deviceId, this._serviceId)
} else if(arr[0] == 0xA7) {
let len = arr[3]
let payload = arr.slice(4, 4 + len)
plugin.sendDataOfA7(payload)
}
let historyList = wx.getStorageSync('historyList') || []
let idx = historyList.findIndex(item => item.cmd == tempCmd)
if (idx < 0) {
historyList.push({cmd: tempCmd})
}
this.setData({
historyList
})
wx.setStorage({
data: historyList,
key: 'historyList',
})
wx.showToast({
title: '已发送',
icon: 'none'
})
},
history_delete(e) {
;
let index = e.currentTarget.dataset.index
this.data.historyList.splice(index, 1)
this.setData({
historyList: this.data.historyList
})
wx.setStorage({
data: this.data.historyList,
key: 'historyList',
})
},
history_copy(e) {
;
let index = e.currentTarget.dataset.index
wx.setClipboardData({
data: this.data.historyList[index].cmd
})
},
history_send(e) {
let index = e.currentTarget.dataset.index
let cmd = this.data.historyList[index].cmd
this.submitCmd(null, cmd)
},
});

+ 3
- 0
rope_skipping_demo/pages/index/index.json 查看文件

@@ -0,0 +1,3 @@
{
"usingComponents": {}
}

+ 104
- 0
rope_skipping_demo/pages/index/index.wxml 查看文件

@@ -0,0 +1,104 @@
<wxs module="utils">
module.exports.max = function(n1, n2) {
return Math.max(n1, n2)
}
module.exports.len = function(arr) {
arr = arr || []
return arr.length
}
</wxs>

<view class="container">
<view class="header" wx:if="{{!showWriteInput}}">
<button bindtap="openBluetoothAdapter" style="font-size: 32rpx;line-height:100rpx;width: 100%;">开始扫描</button>
<button bindtap="stopBluetoothDevicesDiscovery" style="font-size: 32rpx;line-height:100rpx;width: 100%;">停止扫描</button>
<button bindtap="closeBluetoothAdapter" style="font-size: 32rpx;line-height:100rpx;width: 100%;">结束流程</button>
</view>
<view wx:if="{{!showWriteInput}}" class="devices_summary">已发现 {{devices.length}} 个外围设备:</view>
<scroll-view wx:if="{{!showWriteInput}}" class="device_list" scroll-y scroll-with-animation>
<view wx:for="{{devices}}" wx:key="index"
data-device-id="{{item.deviceId}}"
data-name="{{item.name || item.localName}}"
data-mac="{{item.mac}}"
data-index="{{index}}"
bindtap="createBLEConnection"
class="device_item"
hover-class="device_item_hover">
<view style="font-size: 32rpx;">
<text style="color:#000;font-weight:bold">{{item.name}}</text>
<text style="font-size:26rpx">(信号强度: {{item.RSSI}}dBm)</text>
</view>
<view style="font-size: 26rpx">mac地址: {{item.macAddr || item.deviceId}}</view>
<!-- <view style="font-size: 10px">Service数量: {{utils.len(item.advertisServiceUUIDs)}}</view> -->
<view style="font-size: 26rpx">广播数据:{{item.analyzeDataText}}</view>
</view>
</scroll-view>
<view class="connected_info" wx:if="{{connected}}">
<view>
<text>已连接到 {{name}}</text>
<view class="operation">
<button size="mini" bindtap="closeBLEConnection" style="line-height:54rpx; font-size:28rpx;padding:0 20rpx;">断开连接</button>
</view>
</view>
<view wx:for="{{chs}}" wx:key="index" style="font-size: 26rpx; margin-top: 20rpx;">
<view>特性值: {{item.value}}</view>
</view>
</view>
<view style="width: 100vw;display:flex;flex-wrap: wrap;" wx:if="{{showWriteInput}}">
<view class = 'operation' bindtap="SendInstructions" data-index="1">同步时间戳</view>
<view class = 'operation' bindtap="SendInstructions" data-index="2">启动自由跳</view>
<view class = 'operation' bindtap="SendInstructions" data-index="3">结束自由跳</view>
<view class = 'operation' bindtap="SendInstructions" data-index="4">启动倒计时</view>
<view class = 'operation' bindtap="SendInstructions" data-index="5">结束倒计时</view>
<view class = 'operation' bindtap="SendInstructions" data-index="6">启动倒计数</view>
<view class = 'operation' bindtap="SendInstructions" data-index="7">结束倒计数</view>
<view class = 'operation' bindtap="SendInstructions" data-index="8">修改成120秒倒计时</view>
<view class = 'operation' bindtap="SendInstructions" data-index="9">修改成50个倒计数</view>
<view class = 'operation'bindtap="SendInstructions" data-index="10">获取离线历史记录</view>
<view class = 'operation' bindtap="SendInstructions" data-index="11">绑定设备</view>
</view>


<view class="writeInputView" wx:if="{{showWriteInput}}">


<view wx:if="{{isStumbleRope === 1}}">
<view>实时数据上报</view>
<view>状态:{{state}}(0:跳绳准备阶段1:正在跳绳阶段2:跳绳完成阶段)</view>
<view>模式:{{model}}(1:自由跳绳2:倒计时跳绳3:倒计数跳绳)</view>
<view>模式默认值:{{skipNumber}}</view>
<view>{{skipTime}}当前跳绳累积时间(2字节、小端序)</view>
<view>{{cumulativeNumber}}当前跳绳累积个数(2字节、小端序)</view>
<view>电量:{{electricity}}</view>
</view>


<view wx:elif="{{isStumbleRope === 2}}">
<view>跳绳结束</view>
<view>时间:{{finishArr.timeStamp}}</view>
<view>跳绳模式:{{finishArr.model}}</view>
<view>模式默认值:{{finishArr.skipNumber}}</view>
<view>总个数{{finishArr.cumulativeNumber}}</view>
<view>总时间{{finishArr.skipTime}}</view>
<view>电量:{{electricity}}</view>
<view>最快频次:{{finishArr.prestissimo}}</view>
<view>平均频次:{{finishArr.averageVelocity}}</view>
<view wx:for="{{stumbleRope}}" wx:key="index">
<view>绊绳数量:{{item.stumbleRopeOneNum}}绊绳时间:{{item.stumbleRopeOneTime}}</view>
<view>绊绳数量:{{item.stumbleRopeTwoNum}}绊绳时间:{{item.stumbleRopeTwoTime}}</view>
<view>绊绳数量:{{item.stumbleRopeZeroNum}}绊绳时间:{{item.stumbleRopeZeroTime}}</view>
</view>
</view>


<view wx:else="{{isStumbleRope === 3}}">
<view>离线历史记录</view>
<view>历史记录:{{historicalRecord}}(0x01:请求获取离线记录0x02:清空离线记录)</view>
<view>是否成功:{{isSupport}}(0x00:成功0x01:失败0x02:不支持)</view>
<view>历史记录条数:{{record}}(当前离线历史记录条数(2字节、小端序))</view>
</view>


</view>
</view>

+ 169
- 0
rope_skipping_demo/pages/index/index.wxss 查看文件

@@ -0,0 +1,169 @@
page {
background: #f0f0f0;
color: #333;
--safe-bottom: env(safe-area-inset-bottom);
}
view,
cover-view,
scroll-view,
swiper,
swiper-item,
movable-area,
movable-view,
button,
input,
textarea,
label,
navigator
{
box-sizing: border-box;
}
.operation{
padding: 5px;
border: 1px solid #000;
}
.container{
position: relative;
display: flex;
flex-direction: column;
align-items: center;
width: 100vw;
height: 100vh;
padding-bottom: 200rpx;
}
.header{
width: 100%;
}
.container button{
padding-top: 0;
padding-bottom: 0;
border: 1px solid #ddd;
}
.devices_summary {
width: 100%;
line-height: 70rpx;
padding: 0 30rpx;
margin-top: 30rpx;
font-size: 32rpx;
}
.device_list {
flex: 1;
width: 100%;
height: calc(100vh - 600rpx);
margin-top: 0;
border: 1px solid #fff;
border-radius: 5px;
background: #fff;
}
.device_item {
line-height: 1.5;
padding: 10rpx 30rpx;
border-bottom: 1px solid #EEE;
}
.device_item_hover {
background-color: rgba(0, 0, 0, .1);
}
.connected_info {
position: fixed;
bottom: 0;
width: 100%;
height: 200rpx;
padding: 10px;
border-top: 1px solid #ddd;
background-color: #fff;
font-size: 14px;
box-shadow: 0px -4rpx 4rpx 0px rgba(0,0,0,.05);
}
.connected_info .operation {
position: absolute;
display: inline-block;
right: 30rpx;
}
.writeInputViewBg{
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 1000;
background-color: rgba(0,0,0,0.5);
}
.writeInputView{
position: fixed;
bottom: 200rpx;
left: 0;
z-index: 1001;
display: flex;
flex-direction: column;
align-items: center;
width: 100%;
height: calc(100vh - 500rpx);
background-color: #fff;
border-top: 1px solid #ddd;
}
.history{
position: relative;
flex: 1;
width: 690rpx;
padding-top: 60rpx;
border: 1px solid #ddd;
margin: 30rpx;
}
.history_title{
position: absolute;
top: 0;
left: 0;
padding: 0 30rpx;
line-height: 60rpx;
font-size: 30rpx;
}
.history_wrap{
width: 100%;
height: 100%;
}
.history_item{
display: flex;
align-items: center;
justify-content: space-between;
width: 100%;
height: 72rpx;
padding: 0 30rpx;
border-top: 1px solid #ddd;
}
.history_cmd{
flex: 1;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
font-size: 24rpx;
}
.history_btns{
height: 60rpx;
overflow: hidden;
}

.writeInput{
margin-top: 30rpx;
width: 690rpx;
height: 80rpx;
border: 1rpx solid #ccc;
}
.writeInput input{
width: 100%;
height: 100%;
padding: 10rpx;
font-size: 32rpx;
}
.hint{
padding-top: 10rpx;
font-size: 24rpx;
color: #999;
}
.btns{
display: flex;
align-items: center;
justify-content: space-between;
width: 60%;
padding-bottom: 30rpx;
margin-top: 30rpx;
}

+ 82
- 0
rope_skipping_demo/project.config.json 查看文件

@@ -0,0 +1,82 @@
{
"description": "项目配置文件",
"packOptions": {
"ignore": [
{
"type": "file",
"value": ".eslintrc.js"
}
]
},
"setting": {
"urlCheck": true,
"es6": true,
"enhance": true,
"postcss": true,
"preloadBackgroundData": false,
"minified": true,
"newFeature": false,
"coverView": true,
"nodeModules": false,
"autoAudits": false,
"showShadowRootInWxmlPanel": true,
"scopeDataCheck": false,
"uglifyFileName": false,
"checkInvalidKey": true,
"checkSiteMap": true,
"uploadWithSourceMap": true,
"compileHotReLoad": false,
"lazyloadPlaceholderEnable": false,
"useMultiFrameRuntime": true,
"useApiHook": true,
"useApiHostProcess": true,
"babelSetting": {
"ignore": [],
"disablePlugins": [],
"outputPath": ""
},
"enableEngineNative": false,
"useIsolateContext": true,
"userConfirmedBundleSwitch": false,
"packNpmManually": false,
"packNpmRelationList": [],
"minifyWXSS": true,
"disableUseStrict": false,
"minifyWXML": true,
"showES6CompileOption": false,
"useCompilerPlugins": false
},
"compileType": "miniprogram",
"libVersion": "2.19.4",
"appid": "wx17e93aad47cdae1a",
"projectname": "miniprogram-2",
"debugOptions": {
"hidedInDevtools": []
},
"scripts": {},
"staticServerOptions": {
"baseURL": "",
"servePath": ""
},
"isGameTourist": false,
"condition": {
"search": {
"list": []
},
"conversation": {
"list": []
},
"game": {
"list": []
},
"plugin": {
"list": []
},
"gamePlugin": {
"list": []
},
"miniprogram": {
"list": []
}
}
}

+ 7
- 0
rope_skipping_demo/sitemap.json 查看文件

@@ -0,0 +1,7 @@
{
"desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html",
"rules": [{
"action": "allow",
"page": "*"
}]
}

+ 19
- 0
rope_skipping_demo/utils/util.js 查看文件

@@ -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
}

Loading…
取消
儲存