Commit 446d2267 by 王榕

修改固件可输入

parent 59719230
...@@ -64,6 +64,8 @@ Page({ ...@@ -64,6 +64,8 @@ Page({
inputDeviceId: '', inputDeviceId: '',
deviceListShow: false, deviceListShow: false,
discovery: false, discovery: false,
firmware:false,
firmwareNo:'',
hex: '', hex: '',
hexStr: '' hexStr: ''
}, },
...@@ -74,13 +76,19 @@ Page({ ...@@ -74,13 +76,19 @@ Page({
onLoad: function() { onLoad: function() {
// 初始化蓝牙 // 初始化蓝牙
this.initBlueTooth() this.initBlueTooth()
this.getUpdateStr() // this.getUpdateStr()
}, },
getUpdateStr() { getUpdateStr() {
Api.get('http://yadi-upgrade.zhuzhux.com/download/getFileHex?typeHex=3') let { firmwareNo } = this.data
if(!firmwareNo){
alertTip('请输入固件编号')
return
}
Api.get('http://yadi-upgrade.zhuzhux.com/download/getFileHex?typeHex=' + firmwareNo)
.then(res => { .then(res => {
this.setData({ this.setData({
hexStr: res hexStr: res,
firmware:true
}) })
}) })
.catch(err => { .catch(err => {
...@@ -280,6 +288,11 @@ Page({ ...@@ -280,6 +288,11 @@ Page({
hex: e.detail.value.toUpperCase() hex: e.detail.value.toUpperCase()
}) })
}, },
bindFirmwareNoInput: function(e) {
this.setData({
firmwareNo: e.detail.value
})
},
bindDeviceIdInput: function(e) { bindDeviceIdInput: function(e) {
this.setData({ this.setData({
inputDeviceId: e.detail.value inputDeviceId: e.detail.value
...@@ -443,7 +456,7 @@ Page({ ...@@ -443,7 +456,7 @@ Page({
}, },
hexFocus: function() { hexFocus: function() {
this.setData({ this.setData({
hex: '', firmwareNo: '',
}) })
}, },
connectByHand() { connectByHand() {
......
...@@ -3,6 +3,11 @@ ...@@ -3,6 +3,11 @@
<view class="panel-title">状态</view> <view class="panel-title">状态</view>
<view class="panel-body"> <view class="panel-body">
<view class="body-item"> <view class="body-item">
<text>固件:</text>
<text wx:if="{{firmware}}" style='color:green'>已下载(编号:{{firmwareNo}})</text>
<text wx:else style='color:red'>未下载</text>
</view>
<view class="body-item">
<text>手机蓝牙:</text> <text>手机蓝牙:</text>
<text wx:if="{{blueOpen}}" style='color:green'>已开启</text> <text wx:if="{{blueOpen}}" style='color:green'>已开启</text>
<text wx:else style='color:red'>已关闭</text> <text wx:else style='color:red'>已关闭</text>
...@@ -18,10 +23,10 @@ ...@@ -18,10 +23,10 @@
<view class="panel-title">操作</view> <view class="panel-title">操作</view>
<view class="panel-body"> <view class="panel-body">
<view wx:if="{{blueOpen}}"> <view wx:if="{{blueOpen}}">
<button bindtap='searchStart' type='primary' wx:if="{{!discovery}}">搜索蓝牙设备</button> <button bindtap='searchStart' type='primary' wx:if="{{!discovery&&firmware}}">搜索蓝牙设备</button>
<button bindtap='searchEnd' wx:else>停止搜索</button> <button bindtap='searchEnd' wx:else>停止搜索</button>
</view> </view>
<button bindtap='scanDevice' wx:if="{{blueOpen}}" type='primary'>扫码连接</button> <button bindtap='scanDevice' wx:if="{{blueOpen&&firmware}}" type='primary'>扫码连接</button>
<!-- <input bindinput="bindDeviceIdInput" value='{{inputDeviceId}}' wx:if="{{blueOpen}}" placeholder="请输入设备deviceId" /> <!-- <input bindinput="bindDeviceIdInput" value='{{inputDeviceId}}' wx:if="{{blueOpen}}" placeholder="请输入设备deviceId" />
<button bindtap='connectByHand' wx:if="{{blueOpen}}" type='primary'>直接连接</button> --> <button bindtap='connectByHand' wx:if="{{blueOpen}}" type='primary'>直接连接</button> -->
<view wx:if="{{blueConnect}}"> <view wx:if="{{blueConnect}}">
...@@ -29,7 +34,8 @@ ...@@ -29,7 +34,8 @@
</view> </view>
<button bindtap='closeBlueTooth' wx:if="{{blueOpen}}" type='warn'>关闭蓝牙</button> <button bindtap='closeBlueTooth' wx:if="{{blueOpen}}" type='warn'>关闭蓝牙</button>
<button bindtap='initBlueTooth' wx:else type='primary'>开启蓝牙</button> <button bindtap='initBlueTooth' wx:else type='primary'>开启蓝牙</button>
<button bindtap='getUpdateStr' type='info'>重新获取升级文件</button> <input class="firem-ware" bindinput="bindFirmwareNoInput" value='{{firmwareNo}}' placeholder="请输入固件编号" bindfocus="hexFocus" />
<button bindtap='getUpdateStr' type='info'>下载固件</button>
</view> </view>
</view> </view>
<view class="panel"> <view class="panel">
......
...@@ -77,3 +77,9 @@ button { ...@@ -77,3 +77,9 @@ button {
border: 1rpx solid #000; border: 1rpx solid #000;
border-radius: 3px; border-radius: 3px;
} }
.firem-ware{
border: 1rpx solid #e5e5e5;
border-radius: 5px;
margin: 10px 0;
padding: 20rpx;
}
\ 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