设备列表,设备绑定,删除,修改设备名
This commit is contained in:
@ -15,8 +15,8 @@
|
||||
<text class="device-name">设备名:CLI</text>
|
||||
<text class="device-model1">ID:{{deviceId}}</text>
|
||||
</view>
|
||||
<view class="connecting-line" v-if="isConnecting && !isConnected">连接中...</view>
|
||||
<view class="connecting-success" v-if="isConnected">设备绑定成功</view>
|
||||
<view class="connecting-line" v-if="isConnectNo">连接中...</view>
|
||||
<view class="connecting-success" v-if="isSuccess">设备绑定成功</view>
|
||||
</view>
|
||||
<view class="btn-bottom">
|
||||
<button class="login-btn" @click="handleConnect">
|
||||
@ -27,18 +27,26 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {deviceBind} from "@/api/common/qrcode.js"
|
||||
import {
|
||||
deviceBind
|
||||
} from "@/api/common/qrcode.js"
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
deviceId: '',
|
||||
isConnecting: false, // 是否正在连接
|
||||
isConnected: false // 是否连接成功
|
||||
isConnected: false ,// 是否连接成功
|
||||
isConnectNo:false,
|
||||
isSuccess:false
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
async handleConnect() {
|
||||
if (this.isConnecting) {
|
||||
// 绑定成功,确认按钮跳转到首页
|
||||
uni.switchTab({
|
||||
url: '/pages/common/index/index'
|
||||
})
|
||||
} else {
|
||||
// 开始连接逻辑
|
||||
uni.showLoading({
|
||||
@ -46,27 +54,33 @@
|
||||
title: '加载中....'
|
||||
})
|
||||
this.isConnecting = true;
|
||||
this.isConnectNo=true
|
||||
try {
|
||||
// 调用绑定设备接口
|
||||
await deviceBind({
|
||||
//deviceImei: this.deviceId,
|
||||
deviceIMEI: 'FYS-YF-082-SB',
|
||||
|
||||
const res = await deviceBind({
|
||||
deviceImei: this.deviceId,
|
||||
deviceMac: '',
|
||||
communicationMode: '0', //0是4g,1是蓝牙
|
||||
})
|
||||
|
||||
} catch (error) {
|
||||
}
|
||||
console.log(this.deviceId,'deerer ere');
|
||||
if (res.code == 0) {
|
||||
this.isConnectNo=false
|
||||
this.isSuccess =true
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: res.data,
|
||||
icon: 'success'
|
||||
});
|
||||
this.isConnecting = true;
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
});
|
||||
}
|
||||
|
||||
} catch (error) {}
|
||||
}
|
||||
},
|
||||
connectSuccess() {
|
||||
uni.hideLoading()
|
||||
// 连接成功后的处理
|
||||
uni.showToast({
|
||||
title: '连接成功',
|
||||
icon: 'success'
|
||||
});
|
||||
|
||||
}
|
||||
},
|
||||
onLoad(options) {
|
||||
if (options.deviceId) {
|
||||
|
Reference in New Issue
Block a user