优化设备列表请求太慢 订单时间不准确 绑定默认选中等

This commit is contained in:
3321822538@qq.com 2024-11-06 17:21:47 +08:00
parent 5f5562ebe1
commit 704efa6243
5 changed files with 127 additions and 81 deletions

View File

@ -19,8 +19,8 @@ const install = (Vue, vm) => {
// },
// });
Vue.prototype.$u.http.setConfig({
baseUrl: 'http://192.168.2.12:10002',
// baseUrl: 'https://kg.chuangtewl.com/prod-api',
// baseUrl: 'http://192.168.2.12:10002',
baseUrl: 'https://kg.chuangtewl.com/prod-api',
// loadingText: '加载中...',
// loadingTime: 1000,
// 设置自定义头部content-type

View File

@ -281,7 +281,6 @@
"全部",
"电表",
"水表",
],
czflag:false,
curtitidx: 0,
@ -321,7 +320,9 @@
channelId:'',
dingobj: '',
timerone:null,
hasCalledGetczly:false
hasCalledGetczly:false,
timerIds: null ,
formattedTime:''
}
},
onLoad(option) {
@ -341,29 +342,11 @@
},
computed: {
//
formattedTime() {
// console.log(this.timeday,'00000');
if (this.timeday.days > 0) {
//
return `${this.timeday.days}${this.timeday.hours}小时`
} else if (this.timeday.hours > 0) {
//
return `${this.timeday.hours}小时${this.timeday.minutes}分钟`
} else if (this.timeday.minutes > 0) {
//
return `${this.timeday.minutes}分钟${this.timeday.seconds}`
} else if(this.timeday.seconds == 0){
this.getDevice()
this.timeday.seconds = 0
} else {
// 00
return this.timeday.seconds > 0 ? `${this.timeday.seconds}` : '0'
}
}
},
onUnload: function() {
console.log("unload ");
this.stopTimer();
clearInterval(this.timerone);
this.timerone= null
xBlufi.listenDeviceMsgEvent(false, this.funListenDeviceMsgEvent);
@ -371,6 +354,10 @@
deviceId: this.deviceId,
})
},
mounted() {
//
},
//
onShareAppMessage: function() {
return {
@ -402,19 +389,71 @@
},
onHide() {
// this.stopTimer();
uni.navigateBack()
},
beforeDestroy() {
uni.navigateBack()
//
if (this.timerIds) {
clearInterval(this.timerIds);
}
if (this.timer) {
clearInterval(this.timer)
this.timer = null;
console.log('已销毁')
}
},
onUnload() {
this.stopTimer();
},
methods: {
start() {
this.timerIds = setInterval(() => {
//
if (this.timeday.seconds > 0) {
this.timeday.seconds--;
} else {
// 059
if (this.timeday.minutes > 0) {
this.timeday.seconds = 59;
this.timeday.minutes--;
} else {
// 059
if (this.timeday.hours > 0) {
this.timeday.minutes = 59;
this.timeday.seconds = 59;
this.timeday.hours--;
} else {
// 0
if (this.timeday.days > 0) {
this.timeday.hours = 23;
this.timeday.minutes = 59;
this.timeday.seconds = 59;
this.timeday.days--;
} else {
// 0
clearInterval(this.timerIds);
this.getDevice();
return; // return退setIntervalconsole.log
}
}
}
}
//
this.formattedTime = this.formatTime(this.timeday);
// console.log(formattedTime, 'idsidsids');
}, 1000); // 10001
},
formatTime(timeObj) {
//
if (timeObj.days > 0) {
return `${timeObj.days}${timeObj.hours.toString().padStart(2, '0')}小时 ${timeObj.minutes.toString().padStart(2, '0')}分钟 ${timeObj.seconds.toString().padStart(2, '0')}`;
} else if (timeObj.hours > 0) {
return `${timeObj.hours}小时 ${timeObj.minutes.toString().padStart(2, '0')}分钟 ${timeObj.seconds.toString().padStart(2, '0')}`;
} else if (timeObj.minutes > 0) {
return `${timeObj.minutes}分钟 ${timeObj.seconds.toString().padStart(2, '0')}`;
} else {
return `${timeObj.seconds}`;
}
},
startTimerone() {
//
clearInterval(this.timerone);
@ -1221,14 +1260,14 @@
let expireDate = new Date(expireDateParts[0], expireDateParts[1] - 1, expireDateParts[2], expireTimePartsTime[0], expireTimePartsTime[1], expireTimePartsTime[2])
let now = new Date()
let differenceInMs = expireDate - now
console.log(differenceInMs,expireDate,now,this.formatMilliseconds(differenceInMs),'101010');
// console.log(differenceInMs,expireDate,now,this.formatMilliseconds(differenceInMs),'101010');
this.timeday == ''
if (differenceInMs <= 0) {
this.timeday = 0
} else {
if (this.timeday == '') {
this.timeday = this.formatMilliseconds(differenceInMs)
this.startTimer()
this.start()
}
}
}
@ -1283,31 +1322,6 @@
}
return result
},
startTimer() {
this.timer = setInterval(() => {
if (this.timeday.seconds > 0) {
this.timeday.seconds--
} else if (this.timeday.minutes > 0) {
this.timeday.seconds = 59 // 59
this.timeday.minutes--
} else if (this.timeday.hours > 0) {
this.timeday.minutes = 59 // 59
this.timeday.hours--
this.timeday.seconds = 0 // 0
} else if (this.timeday.days > 0) {
this.timeday.hours = 23 // 23
this.timeday.minutes = 59 // 59
this.timeday.seconds = 0 // 0
this.timeday.days--
} else {
// 0
clearInterval(this.timer)
this.timer = null;
console.log('时间已到期')
}
}, 1000); //
},
//
formatMilliseconds(milliseconds) {
//
@ -1477,7 +1491,6 @@
//
return parsedData
},
}
}
</script>

View File

@ -304,9 +304,14 @@
}
}
})
}else if(this.userId != this.deviceobj.userId && this.deviceobj.suitList.length == 0){
uni.showToast({
title:'该设备暂无套餐,请联系商家添加套餐在使用',
icon: 'none',
duration:2000
})
}
},
getzfqd(){
this.$u.get(`/app/channel/recharge/enabledList`).then(res =>{
if(res.code == 200){

View File

@ -2,9 +2,6 @@
<view>
<u-navbar title="秘钥管理" :border-bottom="false" :background="bgc" title-color='#fff' back-icon-color="#fff"
title-size='36' height='42'></u-navbar>
<!-- 有秘钥 -->
<view class="wubox" v-if="flag">
<view class="youmy">
@ -20,7 +17,6 @@
重置秘钥
</view>
</view>
<view class="" v-else>
<view class="img">
<image src="https://api.ccttiot.com/smartmeter/img/static/uCvMUhBep204JORh00p4" mode=""></image>
@ -32,8 +28,6 @@
申请
</view>
</view>
<!-- 弹窗 -->
<view class="tanc" v-if="maskflag">
<image src="https://api.ccttiot.com/smartmeter/img/static/uNaia3ZQXsWB9nkprcaa" mode=""></image>
@ -58,7 +52,6 @@
</view>
<view class="mask" v-if="maskflag"></view>
<view v-if="btnmsk" style="width: 100%;height: 100vh;position: fixed;top: 0;left: 0;background-color: #000;opacity: .1;z-index: 999;"></view>
</view>
</template>
@ -230,19 +223,16 @@
color: #3D3D3D;
}
}
}
page {
background-color: #F7FAFE;
text-align: center;
}
.wubox {
margin: auto;
width: 646rpx;
margin-top: 48rpx;
text-align: left !important;
.youmy {
width: 646rpx;
height: 210rpx;
@ -251,21 +241,18 @@
border-radius: 20rpx 20rpx 20rpx 20rpx;
font-size: 36rpx;
color: #3D3D3D;
.key {
height: 106rpx;
line-height: 106rpx;
padding-left: 24rpx;
box-sizing: border-box;
}
.xian {
width: 606rpx;
height: 0rpx;
border: 2rpx solid #D8D8D8;
margin-left: 24rpx;
}
.mima {
height: 106rpx;
line-height: 106rpx;
@ -273,7 +260,6 @@
box-sizing: border-box;
}
}
.cz {
margin-top: 44rpx;
width: 646rpx;
@ -287,26 +273,22 @@
color: #8883F0;
}
}
.img {
width: 430rpx;
height: 430rpx;
margin: auto;
margin-top: 114rpx;
image {
width: 430rpx;
height: 430rpx;
}
}
.ts {
font-weight: 500;
font-size: 36rpx;
color: #3D3D3D;
margin-top: 94rpx;
}
.sq {
width: 370rpx;
height: 96rpx;

View File

@ -243,6 +243,7 @@
addflag: false,
sbflag: true,
show: false,
qingqiuflag:true,
list: [{
value: '1',
label: '扫码添加'
@ -265,7 +266,7 @@
storeId: '',
pagenum: 1,
wateringList: [],
pagesize: 999,
pagesize: 10,
isLoading: false,
noMoreData: false,
total: 0,
@ -791,11 +792,19 @@
} else if (Math.abs(deltaY) > 50 && Math.abs(deltaX) < Math.abs(deltaY)) {
if (deltaY < 100) {
console.log("上滑")
// let sum = this.total / this.pagesize
// console.log(this.wateringList.length,this.total);
// if (this.wateringList.length < this.total) {
// this.getlist()
// }
if(this.qingqiuflag == true){
let sum = this.total / this.pagesize
console.log(this.wateringList.length,this.total);
if (this.wateringList.length < this.total) {
console.log(this.groupLists[0].wateringList.length,this.total);
if (this.groupLists[0].wateringList.length < this.total) {
this.qingqiuflag = false
this.getlist()
}
}
} else {
console.log(deltaY)
if (deltaY > 250) {
@ -1056,8 +1065,10 @@
if (this.pagenum > 1) {
this.pagenum++
// this.wateringList = []
this.wateringList = this.wateringList.concat(res.rows)
// this.wateringList = this.wateringList.concat(res.rows)
this.wateringList = res.rows
this.shujuflag = false
this.qingqiuflag = true
// console.log(this.wateringList);
this.groupLists.forEach(groupItem => {
groupItem.wateringList
@ -1074,10 +1085,28 @@
}
})
})
// this.groupLists[0] = this.groupLists[0].map(group => {
// // 使 deviceId
// const seenDeviceIds = {};
// // 使 reduce wateringList deviceId
// const uniqueWateringList = group.wateringList.reduce((acc, item) => {
// if (!seenDeviceIds[item.deviceId]) {
// seenDeviceIds[item.deviceId] = true;
// acc.push(item);
// }
// return acc;
// }, []);
// //
// return {
// ...group,
// wateringList: uniqueWateringList
// };
// })
uni.hideLoading()
} else {
this.pagenum++
this.wateringList = res.rows
this.qingqiuflag = true
// console.log(this.wateringList,'000')
this.groupLists.forEach(groupItem => {
groupItem.wateringList = []
@ -1093,6 +1122,23 @@
})
})
// console.log(this.groupLists)
// this.groupLists[0] = this.groupLists[0].map(group => {
// // 使 deviceId
// const seenDeviceIds = {};
// // 使 reduce wateringList deviceId
// const uniqueWateringList = group.wateringList.reduce((acc, item) => {
// if (!seenDeviceIds[item.deviceId]) {
// seenDeviceIds[item.deviceId] = true;
// acc.push(item);
// }
// return acc;
// }, []);
// //
// return {
// ...group,
// wateringList: uniqueWateringList
// };
// })
uni.hideLoading()
}
this.isLoading = false