Commit 59719230 by 王榕

Initial commit

parents
//app.js
App({
onLaunch: function () {
},
globalData: {
userInfo: null
}
})
\ No newline at end of file
{
"pages": [
"pages/index/index"
],
"window": {
"backgroundTextStyle": "light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "WeChat",
"navigationBarTextStyle": "black"
},
"sitemapLocation": "sitemap.json"
}
\ No newline at end of file
{
"usingComponents": {}
}
\ No newline at end of file
<!--index.wxml-->
<view class="panel">
<view class="panel-title">状态</view>
<view class="panel-body">
<view class="body-item">
<text>手机蓝牙:</text>
<text wx:if="{{blueOpen}}" style='color:green'>已开启</text>
<text wx:else style='color:red'>已关闭</text>
</view>
<view class="body-item">
<text>设备:</text>
<text wx:if="{{blueConnect}}" style='color:green'>已连接,设备编号{{linkDevice||deviceId}}</text>
<text wx:else style='color:red'>已断开</text>
</view>
</view>
</view>
<view class="panel">
<view class="panel-title">操作</view>
<view class="panel-body">
<view wx:if="{{blueOpen}}">
<button bindtap='searchStart' type='primary' wx:if="{{!discovery}}">搜索蓝牙设备</button>
<button bindtap='searchEnd' wx:else>停止搜索</button>
</view>
<button bindtap='scanDevice' wx:if="{{blueOpen}}" type='primary'>扫码连接</button>
<!-- <input bindinput="bindDeviceIdInput" value='{{inputDeviceId}}' wx:if="{{blueOpen}}" placeholder="请输入设备deviceId" />
<button bindtap='connectByHand' wx:if="{{blueOpen}}" type='primary'>直接连接</button> -->
<view wx:if="{{blueConnect}}">
<button bindtap='sendMsg2' type='primary'>重试升级</button>
</view>
<button bindtap='closeBlueTooth' wx:if="{{blueOpen}}" type='warn'>关闭蓝牙</button>
<button bindtap='initBlueTooth' wx:else type='primary'>开启蓝牙</button>
<button bindtap='getUpdateStr' type='info'>重新获取升级文件</button>
</view>
</view>
<view class="panel">
<view class="panel-title">设备列表</view>
<view class="panel-body">
<view class='device-list' wx:if='deviceList.length!=0'>
<view wx:for="{{deviceList}}" class="device-item" wx:key="{{index}}" data-item='{{item}}' bindtap='connectByList'>
<view class="device-name">
<text>{{item.name}}</text>
<text>{{item.deviceId}}</text>
</view>
<view class="btn" style='color:green;'>连接并升级</view>
</view>
</view>
</view>
</view>
<!-- <view wx:if="{{blueConnect}}">
<view class="section">
<view class="label">自定义发送的值:</view>
<view class='hex-input'>
<input bindinput="bindHexInput" value='{{hex}}' placeholder="请输入hex可以小写" bindfocus="hexFocus" />
<button bindtap='sendMsg' plain>发送</button>
</view>
</view>
<view class='btn'>
<button bindtap='openLock' type='primary'>开锁</button>
<button bindtap='closeLock' type='warn'>关锁</button>
</view>
<view class='btn'>
<button bindtap='sendMsg2' type='primary'>重试升级</button>
<button bindtap='closeLock' type='warn'>关锁</button>
</view>
</view> -->
\ No newline at end of file
page {
background: #e5e5e5;
min-height: 100vh;
}
.panel {
}
.panel .panel-title {
font-size: 16px;
font-weight: bolder;
padding: 20rpx 30rpx;
}
.panel-body {
background-color: #fff;
padding: 30rpx;
font-size: 14px;
}
.panel-body .body-item {
display: flex;
padding-bottom: 10rpx;
}
.panel-body .body-item:last-child {
padding-bottom: 0;
}
.panel-body .body-item text:nth-of-type(1) {
width: 200rpx;
}
.panel-body .body-item text:nth-of-type(2) {
flex: 1;
}
.hex-input {
display: flex;
align-items: center;
padding: 10px;
}
.hex-input input {
border: 1px solid #ccc;
flex: 1;
margin-right: 8px;
height: 100rpx;
}
button {
margin: 5px;
}
.device-list{
}
.device-item{
padding: 20rpx 16rpx;
border: 1rpx solid #e5e5e5;
border-radius:6rpx;
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 20rpx;
}
.device-item .device-name{
font-size: 12px;
display: flex;
flex-direction: column;
line-height: 18px;
width: 500rpx;
}
.device-item .btn{
padding: 10rpx 15rpx;
font-size: 12px;
border: 1rpx solid #000;
border-radius: 3px;
}
\ No newline at end of file
{
"description": "项目配置文件",
"packOptions": {
"ignore": []
},
"setting": {
"urlCheck": false,
"es6": 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.7.2",
"appid": "wx918b041f12491a2b",
"projectname": "%E8%93%9D%E7%89%99%E5%BC%80%E9%94%81%E5%B7%A5%E5%85%B7",
"debugOptions": {
"hidedInDevtools": []
},
"isGameTourist": false,
"simulatorType": "wechat",
"simulatorPluginLibVersion": {},
"condition": {
"search": {
"current": -1,
"list": []
},
"conversation": {
"current": -1,
"list": []
},
"game": {
"currentL": -1,
"list": []
},
"miniprogram": {
"current": -1,
"list": []
}
}
}
\ No newline at end of file
{
"desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html",
"rules": [{
"action": "allow",
"page": "*"
}]
}
\ No newline at end of file
/**
*create by wr
**/
"use strict";var _createClass=function(){function n(t,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(t,r,e){return r&&n(t.prototype,r),e&&n(t,e),t}}();function _classCallCheck(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}var jsbuffer=function(){function t(){return _classCallCheck(this,t),this.buffer=null,this.hex=null,this.uint8array=null,this}return _createClass(t,[{key:"from",value:function(t,r){var n=this;if(r&&"hex"==r)this.hex=t,this.buffer=new ArrayBuffer(t.length/2),this.uint8array=new Uint8Array(this.buffer),t.match(/.{2}/g).forEach(function(t,r){n.uint8array[r]=Number("0x"+t)});else{var e=t.split("");this.buffer=new ArrayBuffer(e.length),this.uint8array=new Uint8Array(this.buffer),this.hex="",e.forEach(function(t,r){var e=t.charCodeAt(0);e=1==e.toString(16).length?"0"+e.toString(16):e.toString(16),n.hex+=e,n.uint8array[r]=Number("0x"+e)})}return this}},{key:"read",value:function(t){return this.buffer=t,this.uint8array=new Uint8Array(this.buffer),this.setHex(),this}},{key:"set",value:function(t,r){return this.uint8array[t]=r,this.setHex(),this}},{key:"get",value:function(t,r){var e=this.uint8array[t];return r&&/hex/i.test(r)?1==e.toString(16).length?"0"+e.toString(16):e.toString(16):e}},{key:"setHex",value:function(){var r=this;this.hex="",this.uint8array.forEach(function(t){r.hex+=1==t.toString(16).length?"0"+t.toString(16):t.toString(16)})}}]),t}();module.exports=jsbuffer;
\ No newline at end of file
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
}
const Api = {
get: (url, query, notShowLoad) => {
if (!notShowLoad) {
wx.showLoading({
mask: true,
})
}
return new Promise((resolve, reject) => {
wx.request({
url: url,
// data: Object.assign({}, { userId: wx.getStorageSync('user') ? wx.getStorageSync('user').userId : '' }, query),
data: query,
method: 'GET',
success(res) {
console.log(res)
if (res.statusCode == 200) {
resolve(res.data)
return
} else {
reject(res.data, '请求失败')
}
},
fail(res) {
console.error('1', res)
reject(res.data, '请求失败')
},
complete() {
if (!notShowLoad) {
wx.hideLoading()
}
}
})
})
}
}
module.exports = {
formatTime: formatTime,
Api,
confirmTip: (msg, cb) => {
msg = msg ? msg.toString() : 'timeout'
wx.showModal({
title: '提示',
content: msg,
success(res) {
if (res.confirm) {
cb && cb()
}
}
})
},
alertTip: (msg, cb) => {
wx.showModal({
title: '提示',
content: msg,
showCancel: false,
success() {
cb && cb()
}
})
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment