|
|
@@ -260,6 +260,12 @@
|
|
|
</view>
|
|
|
</u-popup>
|
|
|
|
|
|
+ <u-popup :show="deviceInfo.status != 3" mode="center" >
|
|
|
+ <view style="
|
|
|
+ margin:2%;padding:10%;background-color: #f0f0f0; /* 背景色 */color: #000; padding: 10px; /* 内边距 */border-radius: 5px; /* 圆角 */font-size: 16px; /* 文字大小 */text-align: center; /* 文字居中 */ ">
|
|
|
+ 设备未在线,无法操作
|
|
|
+ </view>
|
|
|
+ </u-popup>
|
|
|
|
|
|
<u-popup :show="planPopDlg" @close="closePlanPop" mode="center" :closeable="true">
|
|
|
<view style="position: relative;width: 400rpx;background: none;padding:40rpx;">
|
|
|
@@ -460,7 +466,7 @@
|
|
|
<image :src="imgUrl+'/setting/upload.png'" style="width: 100%;height:100%;"/>
|
|
|
</view>
|
|
|
<view class="prop-item-left">在线升级</view>
|
|
|
- <view class="prop-item-right">
|
|
|
+ <view class="prop-item-right" @click="getUpdateInfo">
|
|
|
<uni-icons type="forward" size="16"></uni-icons>
|
|
|
</view>
|
|
|
</view>
|
|
|
@@ -521,11 +527,9 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { getDetail,getDeviceStatus,cacheJsonThingsModel,reportError ,getDeviceRunTime} from '@/api/device/device.js'
|
|
|
+import { getDetail,getDeviceStatus,cacheJsonThingsModel,reportError ,getDeviceRunTime,getLatestFirmware} from '@/api/device/device.js'
|
|
|
import config from '@/config'
|
|
|
-import UImage from "../../uni_modules/uview-ui/components/u--image/u--image";
|
|
|
export default {
|
|
|
- components: {UImage},
|
|
|
data(){
|
|
|
return {
|
|
|
modeList:[[
|
|
|
@@ -619,7 +623,7 @@ export default {
|
|
|
jiaozhunPopDlg:false,
|
|
|
step:0,
|
|
|
yuyueIngPop:false,
|
|
|
-
|
|
|
+ firmware:{},
|
|
|
}
|
|
|
},
|
|
|
onLoad: function(opt) {
|
|
|
@@ -636,6 +640,47 @@ export default {
|
|
|
clearTimeout(this.checkTimer);
|
|
|
},
|
|
|
methods:{
|
|
|
+ getUpdateInfo(){
|
|
|
+ let self = this;
|
|
|
+ getLatestFirmware(this.id).then(res=>{
|
|
|
+ self.firmware = res.data;
|
|
|
+ let curVersion = self.deviceInfo.firmwareVersion;
|
|
|
+ let onlineVersion = self.firmware.version
|
|
|
+ if(curVersion>=onlineVersion){
|
|
|
+ this.$modal.showToast('当前已经是最新版本')
|
|
|
+ }else{
|
|
|
+ uni.showModal({
|
|
|
+ title: '检测到新版本',
|
|
|
+ content: "当前版本:"+curVersion+",新版本:"+onlineVersion,
|
|
|
+ cancelText: '取消',
|
|
|
+ confirmText: '升级',
|
|
|
+ success: function(res) {
|
|
|
+ if (res.confirm) {
|
|
|
+ self.doUpdate();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ doUpdate(){
|
|
|
+ if(this.deviceInfo.status != 3){
|
|
|
+ this.notifyError("请等待设备上线后操作")
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ let device = this.deviceInfo;
|
|
|
+ let message = "";
|
|
|
+ let topic = "";
|
|
|
+ let title = "升级";
|
|
|
+ topic = "/" + device.productId + "/" + device.serialNumber + "/ota/get";
|
|
|
+ message = '{"version":"' + this.firmware.version + '","downloadUrl":"' + this.getDownloadUrl(this.firmware.filePath) + '"}';
|
|
|
+ this.$mqttTool.publish(topic, message,title).then(res => {
|
|
|
+ this.notifySuccess(res);
|
|
|
+ }).catch(res => {
|
|
|
+ this.notifyError(res);
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
getStatusText(){
|
|
|
if(this.baozhuangRunning()){
|
|
|
return "工作中";
|
|
|
@@ -1638,7 +1683,7 @@ export default {
|
|
|
if(self.summary.length>0){
|
|
|
this.oneToMul = true;
|
|
|
for (let i = 0; i < self.summary.length; i++) {
|
|
|
- self.summary[i].tabName = self.summary[i].id+"_"+self.summary[i].name
|
|
|
+ self.summary[i].tabName = self.summary[i].name
|
|
|
}
|
|
|
let childId = "";
|
|
|
if(this.oneToMul){
|
|
|
@@ -1910,6 +1955,9 @@ export default {
|
|
|
icon:"success"
|
|
|
})
|
|
|
},
|
|
|
+ getDownloadUrl(path){
|
|
|
+ return this.firmware.downUrl +"/iot/tool/download?fileName="+ path;
|
|
|
+ },
|
|
|
/**
|
|
|
* Mqtt发布消息
|
|
|
* @type 类型(1=属性,2=功能,3=OTA升级,4=实时监测)
|
|
|
@@ -2000,6 +2048,8 @@ export default {
|
|
|
title = "属性";
|
|
|
}else if(type == 2){
|
|
|
title = "功能";
|
|
|
+ }else if(type == 3){
|
|
|
+ title = "升级";
|
|
|
}
|
|
|
if (topic != "") {
|
|
|
// 发布
|