加入iccid

This commit is contained in:
home孙 2025-06-10 17:32:16 +08:00
parent 102f062f97
commit 190da084da
3 changed files with 136 additions and 42 deletions

View File

@ -15,8 +15,8 @@ const variable = {
name: "", //应用名字 name: "", //应用名字
whatType: type, //判断当前是哪端 whatType: type, //判断当前是哪端
// baseUrl: "http://hy.ecbeauty.cn", //线上测试接口的基础路径 baseUrl: "http://jiaxingtest.a1.luyouxia.net:25762", //本地测试接口的基础路径
baseUrl: "https://api.lihe-control.com", //线上接口的基础路径 // baseUrl: "https://api.lihe-control.com", //线上接口的基础路径
mapKey: "", //jsapi mapKey: "", //jsapi

View File

@ -16,6 +16,10 @@ let api = {
getFs_rtdata: "/getFs/rtdata", //主页查看施肥机实时数据 getFs_rtdata: "/getFs/rtdata", //主页查看施肥机实时数据
selFs_time: "/selFs/time", //主页查看施肥机历史数据 selFs_time: "/selFs/time", //主页查看施肥机历史数据
sel_eqbyid: "/sel/eqbyid/", //根据用户id查询对应的设备数据 sel_eqbyid: "/sel/eqbyid/", //根据用户id查询对应的设备数据
sel_userbyid: "/sel/userbyid/", //根据用户id查询对应的设备数据
qibenGeticcid: "/qiben/geticcid", //获取物联网卡号
popupwindow: "/qiben/popupwindow", //获取物联网卡号是否弹窗
chart_fsdata: "/chart/fsdata", //实时数据折线图 chart_fsdata: "/chart/fsdata", //实时数据折线图
user_update_pwd: "/user/update/pwd", //用户修改密码 user_update_pwd: "/user/update/pwd", //用户修改密码

View File

@ -28,8 +28,8 @@
<template v-for="item0 in weatherList"> <template v-for="item0 in weatherList">
<view class="waterAndFertilizerParams" :key="item0.id"> <view class="waterAndFertilizerParams" :key="item0.id">
<view class="nav"> <view class="nav">
<image src="../../static/PH.png" mode=""></image> <view class="name"><image src="../../static/PH.png" mode=""></image>
<text>{{item0.deviceName}}</text> <text>{{item0.deviceName}}</text></view>
</view> </view>
<view class="detail"> <view class="detail">
<view class="item" v-for="item,index in item0.weatherListChild" :key="index" <view class="item" v-for="item,index in item0.weatherListChild" :key="index"
@ -58,8 +58,10 @@
<template v-for="item0 in equipmentName30List"> <template v-for="item0 in equipmentName30List">
<view class="waterAndFertilizerParams" :key="item0.id"> <view class="waterAndFertilizerParams" :key="item0.id">
<view class="nav"> <view class="nav">
<image src="../../static/PH.png" mode=""></image> <view class="name">
<text>{{item0.deviceTypeName}}</text> <image src="../../static/PH.png" mode=""></image>
<text>{{item0.deviceTypeName}}</text>
</view>
</view> </view>
<view class="detail"> <view class="detail">
<view class="item" v-for="item,index in item0.equipmentName30ListChild" :key="index" <view class="item" v-for="item,index in item0.equipmentName30ListChild" :key="index"
@ -86,9 +88,13 @@
<!-- 智能灌溉 --> <!-- 智能灌溉 -->
<template v-for="item0 in equipmentName20List"> <template v-for="item0 in equipmentName20List">
<view class="waterAndFertilizerParams" :key="item0.id"> <view class="waterAndFertilizerParams" :key="item0.id">
<view class="nav"> <view class="nav iccid-nav">
<image src="../../static/PH.png" mode=""></image> <view class="name">
<text>{{item0.deviceTypeName}}</text> <image src="../../static/PH.png" mode=""></image>
<text>{{item0.deviceTypeName}}</text>
</view>
<view class="iccid">卡号:{{item0.iccidcode}}<br>
到期时间:<text :class="getPackageTimeColor(item0.iccidcode)?'color-red':''">{{getPackageTime(item0.iccidcode)}}<text v-if="getPackageTimeColor(item0.iccidcode)">(即将到期)</text></text></view>
</view> </view>
<view class="detail"> <view class="detail">
<view class="item" v-for="item,index in item0.equipmentName20ListChild" :key="index" <view class="item" v-for="item,index in item0.equipmentName20ListChild" :key="index"
@ -114,9 +120,13 @@
</template> </template>
<view class="waterAndFertilizerParams" v-for="(item1,index1) in waterAndFertilizerParamsList" :key="index1"> <view class="waterAndFertilizerParams" v-for="(item1,index1) in waterAndFertilizerParamsList" :key="index1">
<view class="nav"> <view class="nav iccid-nav">
<image src="../../static/PH.png" mode=""></image> <view class="name">
<text>{{ item1.deviceTypeName }}</text> <image src="../../static/PH.png" mode=""></image>
<text>{{ item1.deviceTypeName }}</text>
</view>
<view class="iccid">卡号:{{item1.iccidcode}}<br>
到期时间:<text :class="getPackageTimeColor(item1.iccidcode)?'color-red':''">{{getPackageTime(item1.iccidcode)}}<text v-if="getPackageTimeColor(item1.iccidcode)">(即将到期)</text></text></view>
</view> </view>
<view class="detail"> <view class="detail">
<view class="item" v-for="(item2,index2) in item1.childList_mubiao" :key="index2" <view class="item" v-for="(item2,index2) in item1.childList_mubiao" :key="index2"
@ -368,9 +378,13 @@
<!-- 数据采集器 --> <!-- 数据采集器 -->
<template v-for="item0 in equipmentName40List"> <template v-for="item0 in equipmentName40List">
<view class="waterAndFertilizerParams" :key="item0.id"> <view class="waterAndFertilizerParams" :key="item0.id">
<view class="nav"> <view class="nav iccid-nav">
<image src="../../static/PH.png" mode=""></image> <view class="name">
<text>{{item0.deviceTypeName}}</text> <image src="../../static/PH.png" mode=""></image>
<text>{{item0.deviceTypeName}}</text>
</view>
<view class="iccid">卡号:{{item0.iccidcode}}<br>
到期时间:<text :class="getPackageTimeColor(item0.iccidcode)?'color-red':''">{{getPackageTime(item0.iccidcode)}}<text v-if="getPackageTimeColor(item0.iccidcode)">(即将到期)</text></text></view>
</view> </view>
<view class="detail"> <view class="detail">
<view class="item" v-for="item,index in item0.equipmentName40ListChild" :key="index" <view class="item" v-for="item,index in item0.equipmentName40ListChild" :key="index"
@ -394,7 +408,7 @@
</view> </view>
</view> </view>
</template> </template>
<u-toast ref="uToast" />
</view> </view>
</view> </view>
</template> </template>
@ -403,6 +417,8 @@
export default { export default {
data() { data() {
return { return {
// iccid
iccidList:[],
// //
background: { background: {
backgroundColor: 'transparent', backgroundColor: 'transparent',
@ -545,7 +561,7 @@
uni.getStorage({ uni.getStorage({
key: 'token', key: 'token',
success: function(res) { success: function(res) {
that.getEquipmentInfo(uni.getStorageSync('userid')); that.getEquipmentInfo(uni.getStorageSync('userid'),true);
that.getcontrol_geteqetdata(uni.getStorageSync('userid')) that.getcontrol_geteqetdata(uni.getStorageSync('userid'))
}, },
fail: function(err) { fail: function(err) {
@ -563,7 +579,7 @@
uni.getStorage({ uni.getStorage({
key: 'token', key: 'token',
success: function(res) { success: function(res) {
that.getEquipmentInfo(uni.getStorageSync('userid')) that.getEquipmentInfo(uni.getStorageSync('userid'),false)
that.getcontrol_geteqetdata(uni.getStorageSync('userid')) that.getcontrol_geteqetdata(uni.getStorageSync('userid'))
}, },
}) })
@ -581,7 +597,7 @@
uni.getStorage({ uni.getStorage({
key: 'token', key: 'token',
success: function(res) { success: function(res) {
that.getEquipmentInfo(uni.getStorageSync('userid')) that.getEquipmentInfo(uni.getStorageSync('userid'),true)
that.getcontrol_geteqetdata(uni.getStorageSync('userid')) that.getcontrol_geteqetdata(uni.getStorageSync('userid'))
}, },
}) })
@ -607,30 +623,34 @@
}, },
methods: { methods: {
// id // id
getEquipmentInfo(userid) { getEquipmentInfo(userid,selTrue) {
let that = this let that = this
// uni.showLoading({ // uni.showLoading({
// title: '...' // title: '...'
// }); // });
this.$http({ this.$http({
url: this.api.sel_eqbyid + userid, url: this.api.sel_userbyid + userid,
// url: this.api.sel_eqbyid + '1730755572975824896', // url: this.api.sel_eqbyid + '1730755572975824896',
method: 'GET' method: 'GET'
}).then(res => { }).then(res1 => {
// console.log(res, 'id'); // console.log(res, 'id');
if (res.code == 200) { if (res1.code == 200) {
this.equipmentName30List = []; this.equipmentName30List = [];
this.equipmentName20List = []; this.equipmentName20List = [];
res.data.forEach(el => { // id
if(selTrue){
this.getQibenGeticcid(res1.data.devices)
}
res1.data.devices.forEach(el => {
// //
if (el.equipmentName == 30) { if (el.deviceName == 30) {
this.equipmentName30List.push(el) this.equipmentName30List.push(el)
} }
if (el.equipmentName == 20) { if (el.deviceName == 20) {
this.equipmentName20List.push(el) this.equipmentName20List.push(el)
} }
// //
if (el.equipmentName == 40) { if (el.deviceName == 40) {
this.equipmentName40List.push(el) this.equipmentName40List.push(el)
} }
}) })
@ -645,7 +665,7 @@
if (this.equipmentName20List.length != 0) { if (this.equipmentName20List.length != 0) {
this.getFi_rtdata() this.getFi_rtdata()
} }
this.waterAndFertilizerParamsList = res.data.map((item, index) => { this.waterAndFertilizerParamsList = res1.data.devices.map((item, index) => {
return { return {
...item, ...item,
childList: [], childList: [],
@ -757,22 +777,71 @@
}) })
// equipmentName==1 // equipmentName==1
let waterAndFertilizerParamsList_1 = this.waterAndFertilizerParamsList.filter(e => e let waterAndFertilizerParamsList_1 = this.waterAndFertilizerParamsList.filter(e => e
.equipmentName == 1).sort((a, b) => a.equipmentStatu - b.equipmentStatu) .deviceName == 1).sort((a, b) => a.equipmentStatu - b.equipmentStatu)
// equipmentName==10 // equipmentName==10
let waterAndFertilizerParamsList_10 = this.waterAndFertilizerParamsList.filter(e => e let waterAndFertilizerParamsList_10 = this.waterAndFertilizerParamsList.filter(e => e
.equipmentName == 10).sort((a, b) => a.equipmentStatu - b.equipmentStatu); .deviceName == 10).sort((a, b) => a.equipmentStatu - b.equipmentStatu);
// console.log(waterAndFertilizerParamsList_1,waterAndFertilizerParamsList_10,'00000000000'); // console.log(waterAndFertilizerParamsList_1,waterAndFertilizerParamsList_10,'00000000000');
this.waterAndFertilizerParamsList = [...waterAndFertilizerParamsList_1, ... this.waterAndFertilizerParamsList = [...waterAndFertilizerParamsList_1, ...
waterAndFertilizerParamsList_10 waterAndFertilizerParamsList_10
]; ];
// console.log(this.waterAndFertilizerParamsList, 'this.waterAndFertilizerParamsList'); // console.log(this.waterAndFertilizerParamsList, 'this.waterAndFertilizerParamsList');
} }
}) })
}, },
getQibenGeticcid(devicesList){
var data=devicesList.map(device => ({
deviceId: device.deviceId,
iccid: device.iccidcode,
deviceName: device.deviceTypeName
}));
var iccidList=[]
this.$http({
url: this.api.popupwindow,
data: {userId:uni.getStorageSync('userid')},
method: 'GET'
}).then(res1=>{
data.forEach((el,index)=>{
this.$http({
url: this.api.qibenGeticcid ,
data: el,
method: 'POST'
}).then(res=>{
if(res.code==200){
iccidList.push(res.data)
this.iccidList=iccidList
if(res1.data&&res.data.expired){
setTimeout(() => {
this.$refs.uToast.show({
title: `${res.data.deviceName}卡号为${res.data.iccid},物联网卡即将到期,剩余时间${res.data.daysDifference}天,请联系管理员。`,
type: 'default',
duration:10000
})
}, 10);
}
}
})
})
})
},
getPackageTime(iccidcode){
var item= this.iccidList.find(item=>item.iccid==iccidcode)
return item? item.packageTime:'无数据'
},
getPackageTimeColor(iccidcode){
var item= this.iccidList.find(item=>item.iccid==iccidcode)
return item? item.expired:false
},
// 线 // 线
toTarget_water_fertilizer_PH(id, data, name, equipmentNumber, targetValue, unit, equipmentName, flag) { toTarget_water_fertilizer_PH(id, data, name, equipmentNumber, targetValue, unit, equipmentName, flag) {
uni.navigateTo({ uni.navigateTo({
@ -1006,6 +1075,9 @@
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.color-red{
color: red!important;
}
.timeEnvironment { .timeEnvironment {
width: 100%; width: 100%;
min-height: 100vh; min-height: 100vh;
@ -1088,18 +1160,36 @@
display: flex; display: flex;
align-items: center; align-items: center;
border-bottom: 1rpx solid #DDDDDD; border-bottom: 1rpx solid #DDDDDD;
&.iccid-nav{
>image { display: flex;
width: 50rpx; align-items: center;
height: 50rpx; justify-content: space-between;
margin-right: 16rpx;
} }
.name{
>text { image {
font-size: 30rpx; width: 50rpx;
font-family: PingFang SC; height: 50rpx;
font-weight: bold; margin-right: 16rpx;
color: #333333; }
text {
font-size: 26rpx;
font-family: PingFang SC;
font-weight: bold;
color: #333333;
white-space: nowrap;
}
display: flex;
align-items: center;
}
.iccid{
display: block;
font-size: 24rpx;
text{
font-weight: normal;
}
} }
} }