|
|
@@ -16,12 +16,32 @@
|
|
|
</view>
|
|
|
<u-modal :show="showPwd" :confirmText="i18('确认')" :cancelText="i18('取消')" @confirm="inputPwd" @cancel="cancel" :showCancelButton="true" :title="$t('buletooth.pwdinput')" >
|
|
|
<view class="slot-content">
|
|
|
- <u--input
|
|
|
- type="number"
|
|
|
- :placeholder="$t('buletooth.pwdtip')"
|
|
|
- border="surround"
|
|
|
- v-model="pwd"
|
|
|
- ></u--input>
|
|
|
+ <view>
|
|
|
+ <u--input
|
|
|
+ type="number"
|
|
|
+ :placeholder="$t('buletooth.pwdtip')"
|
|
|
+ border="surround"
|
|
|
+ v-model="pwd"
|
|
|
+ ></u--input>
|
|
|
+ </view>
|
|
|
+
|
|
|
+ <view style="margin:10px;text-decoration: underline;margin-bottom: 0px" @click="forgetPwd">
|
|
|
+ {{i18('忘记密码')}}?
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ </u-modal>
|
|
|
+
|
|
|
+ <u-modal :show="showDeviceNo" :confirmText="i18('确认')" :cancelText="i18('取消')" @confirm="resetPwd" @cancel="cancel" :showCancelButton="true" :title="i18('重置密码')" >
|
|
|
+ <view class="slot-content">
|
|
|
+ <view>
|
|
|
+ <u--input
|
|
|
+ type="number"
|
|
|
+ :placeholder="i18('请输入序列号')"
|
|
|
+ border="surround"
|
|
|
+ v-model="inputDeviceNo"
|
|
|
+ ></u--input>
|
|
|
+ </view>
|
|
|
+
|
|
|
</view>
|
|
|
</u-modal>
|
|
|
<view v-if="deviceListDataShow.length==0" class="notice"> - {{ $t('buletooth.nodevice') }} -</view>
|
|
|
@@ -32,7 +52,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import {getPwd,setPwd,parsePwd,sendPortDetailCmd} from "@/utils/weitiandi/device/device.js";
|
|
|
+import {getPwd,setPwd,parsePwd,sendPortDetailCmd,getUUID,parseDataObj} from "@/utils/weitiandi/device/device.js";
|
|
|
// #ifdef APP
|
|
|
import ecUI from '@/utils/ecUI.js'
|
|
|
import ecBLE from '@/utils/ecBLE/ecBLE.js'
|
|
|
@@ -54,6 +74,10 @@ import i18 from '@/utils/i18.js'
|
|
|
buleid:"",
|
|
|
deviceListDataShow: [],
|
|
|
showTimer:null,
|
|
|
+ connected:false,
|
|
|
+ uuid:"",
|
|
|
+ showDeviceNo:false,
|
|
|
+ inputDeviceNo:""
|
|
|
}
|
|
|
},
|
|
|
onLoad() {
|
|
|
@@ -88,6 +112,29 @@ import i18 from '@/utils/i18.js'
|
|
|
uni.navigateBack({
|
|
|
});
|
|
|
},
|
|
|
+ resetPwd(){
|
|
|
+ let self = this;
|
|
|
+ if(!this.inputDeviceNo){
|
|
|
+ self.$modal.showToast("请输入序列号");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if(this.uuid != this.inputDeviceNo){
|
|
|
+ self.$modal.showToast("序列号有误");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if(this.uuid == this.inputDeviceNo){
|
|
|
+ this.$modal.confirm("密码将被重置为123456").then(res=>{
|
|
|
+ setPwd("123456")
|
|
|
+ self.$modal.showToast("密码修改成功");
|
|
|
+ this.rightPwd = "123456";
|
|
|
+ self.loginSuccess();
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ goBack(){
|
|
|
+ uni.navigateBack({
|
|
|
+ });
|
|
|
+ },
|
|
|
inputPwd(){
|
|
|
if(!this.pwd ){
|
|
|
this.$modal.showToast(this.$t('buletooth.nopwd'));
|
|
|
@@ -102,6 +149,7 @@ import i18 from '@/utils/i18.js'
|
|
|
},
|
|
|
loginSuccess(){
|
|
|
this.showPwd = false;
|
|
|
+ this.showDeviceNo = false;
|
|
|
uni.setStorageSync("pwd",this.rightPwd);
|
|
|
uni.setStorageSync('blueid', this.buleid);
|
|
|
this.pwd = "";
|
|
|
@@ -120,6 +168,7 @@ import i18 from '@/utils/i18.js'
|
|
|
ecBLE.onBLEConnectionStateChange(res => {
|
|
|
console.log(res);
|
|
|
if (res.ok) {
|
|
|
+ self.connected = true;
|
|
|
setTimeout(function(){
|
|
|
ecUI.hideLoading()
|
|
|
getPwd();
|
|
|
@@ -143,33 +192,63 @@ import i18 from '@/utils/i18.js'
|
|
|
let isCheckRevHex = true;
|
|
|
let data =
|
|
|
(isCheckRevHex ? strHex.replace(/[0-9a-fA-F]{2}/g, ' $&') : str)
|
|
|
- // console.log(data)
|
|
|
+ console.log(data)
|
|
|
self.$modal.closeLoading();
|
|
|
- console.log("settting:"+data);
|
|
|
- //AA 67 0D 05 00 00 00 00 00 00 00 00 00 25 E2 00 80
|
|
|
- let pwd = parsePwd(data);
|
|
|
- let localPwd = self.getLocalPwd()
|
|
|
- console.log("pwd:"+pwd);
|
|
|
- console.log("localPwd:"+localPwd)
|
|
|
- self.rightPwd = pwd;
|
|
|
- if(pwd != localPwd){
|
|
|
- self.showInputPwd();
|
|
|
+ data = parseDataObj(data);
|
|
|
+ console.log(data);
|
|
|
+ let type = data.type;
|
|
|
+ if(type == 253){
|
|
|
+ self.messageCallback(data)
|
|
|
}else{
|
|
|
- self.loginSuccess();
|
|
|
+ let pwd = data.real_data;
|
|
|
+ let localPwd = self.getLocalPwd()
|
|
|
+ console.log("pwd:"+pwd);
|
|
|
+ console.log("localPwd:"+localPwd)
|
|
|
+ self.rightPwd = pwd;
|
|
|
+ if(pwd != localPwd){
|
|
|
+ self.showInputPwd();
|
|
|
+ }else{
|
|
|
+ self.loginSuccess();
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
})
|
|
|
- ecBLE.createBLEConnection(id)
|
|
|
+ self.connected = false;
|
|
|
+ ecBLE.createBLEConnection(id);
|
|
|
+ setTimeout(function (){
|
|
|
+ if(!self.connected){
|
|
|
+ self.$modal.showToast(i18('连接失败'));
|
|
|
+ self.startBluetoothDevicesDiscovery()
|
|
|
+ }
|
|
|
+ },10000);
|
|
|
},
|
|
|
showInputPwd(){
|
|
|
this.showPwd = true;
|
|
|
+ },
|
|
|
+ messageCallback(data){
|
|
|
+ let self = this;
|
|
|
+ console.log(data);
|
|
|
+ let type = data.type;
|
|
|
+ let real_data = data.real_data;
|
|
|
+ if(type == 253){
|
|
|
+ self.$modal.closeLoading();
|
|
|
+ self.uuid = real_data.substr(0,6);
|
|
|
+ }
|
|
|
+ self.$forceUpdate();
|
|
|
+ console.log('收到服务器内容:' + JSON.stringify(data));
|
|
|
+ },
|
|
|
+ forgetPwd(){
|
|
|
+ this.$modal.loading("正在读取设备ID");
|
|
|
+ getUUID()
|
|
|
+ this.showDeviceNo = true;
|
|
|
},
|
|
|
openBluetoothAdapter() {
|
|
|
let self = this;
|
|
|
ecBLE.onBluetoothAdapterStateChange(res => {
|
|
|
ecUI.hideLoading()
|
|
|
if (res.ok) {
|
|
|
- console.log('Bluetooth adapter ok')
|
|
|
let blueid = uni.getStorageSync('blueid');
|
|
|
+ console.log('Bluetooth adapter ok,blueid:'+blueid)
|
|
|
if(blueid){
|
|
|
self.listViewTap(blueid);
|
|
|
}else{
|