From 9184741a28db0c449999fd78cbacb6d54137f4a7 Mon Sep 17 00:00:00 2001 From: huanglingchen Date: Mon, 28 Jul 2025 14:32:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8E=A5=E6=94=B6=E5=90=8E?= =?UTF-8?q?=E5=8F=B0=E6=95=B0=E6=8D=AE=E4=B8=8D=E7=94=9F=E6=95=88=EF=BC=8C?= =?UTF-8?q?=E7=BB=99=E6=95=B0=E6=8D=AE=E6=B7=BB=E5=8A=A0=E5=8D=95=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/carPage/index.vue | 305 ++++++++++++++++++++++--------- components/controlPage/index.vue | 24 +-- pages/index/index.vue | 173 +++++++----------- static/image/errorToast.png | Bin 0 -> 1000 bytes static/image/successToast.png | Bin 0 -> 967 bytes utils/requset.js | 9 +- 6 files changed, 300 insertions(+), 211 deletions(-) create mode 100644 static/image/errorToast.png create mode 100644 static/image/successToast.png diff --git a/components/carPage/index.vue b/components/carPage/index.vue index 9ba2cab..aeeed3a 100644 --- a/components/carPage/index.vue +++ b/components/carPage/index.vue @@ -9,7 +9,7 @@ {{item.name}} {{item.val}} - {{index==7||index==11?'mm':index==9?'°':''}} + {{index>=9?'mm':index==8?'°':''}} @@ -21,7 +21,7 @@ {{item.name}} {{item.val}} - {{index==7||index==11?'mm':index==9?'°':''}} + {{index>=9?'mm':index==8?'°':''}} @@ -33,7 +33,7 @@ {{item.name}} {{item.val}} - {{index==7||index==11?'mm':index==9?'°':''}} + {{index>=9?'mm':index==8?'°':''}} @@ -44,103 +44,238 @@ diff --git a/components/controlPage/index.vue b/components/controlPage/index.vue index 516709c..80b8f71 100644 --- a/components/controlPage/index.vue +++ b/components/controlPage/index.vue @@ -234,8 +234,8 @@ ctrlFlag: 0,//控制模式:0-手动、1-自动 lightFlag: 1,//设备状态:0-正常、1-异常 }, - errorIcon:'/static/image/error.png', - normalIcon:'/static/image/normal.png' + errorIcon:'../../static/image/error.png', + normalIcon:'../../static/image/normal.png' } }, methods:{ @@ -245,18 +245,13 @@ url:`/zhxx/dt/horizonLoadIControl/${value}`, data:{} }).then((res)=>{ - if(res.code==200){ - uni.showToast({ - title: res.msg, - icon: "success", - duration: 1000 - }) - }else{ - uni.showToast({ - title: res.msg?res.msg:'请求失败', - icon: "error", - duration: 1000 - }) + console.log(res) + + if(res.data.code==200){ + this.$eventBus.emit('showToast',{title:res.data.msg,duration:1000,icon:'success'}) + }else { + console.log(22222) + this.$eventBus.emit('showToast',{title:res.data.msg?res.data.msg:'请求失败',duration:1000,icon:'error'}) } }).catch((Error)=>{ // console.log(Error) @@ -296,6 +291,7 @@ }, watch:{ Data:{ + immediate:true, handler(newVal,oldVal){ if(newVal){ this.deviceData=newVal diff --git a/pages/index/index.vue b/pages/index/index.vue index 528a745..06200e7 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -12,7 +12,12 @@ 退出 --> - + + + + + {{showToastTitle}} + @@ -20,6 +25,8 @@ import controlPage from '/components/controlPage/index.vue'; import carPage from '/components/carPage/index.vue'; import {httpPost} from '../../utils/requset.js'; + import error from '../../static/image/errorToast.png'; + import successImage from '@/static/image/successToast.png'; export default { components: { controlPage, @@ -28,66 +35,17 @@ data() { return { optionIndex:0, - dataInter:[ - { - name:'支架车在线状态:', - width:0, - val:'' - },{ - name:'左横移限位:', - width:1, - val:'' - },{ - name:'右横移限位:', - width:1, - val:'' - },{ - name:'上限位:', - width:1, - val:'' - },{ - name:'下限位:', - width:1, - val:'' - },{ - name:'左滚转限位:', - width:1, - val:'' - },{ - name:'右滚转限位:', - width:1, - val:'' - },{ - name:'行进位置:', - width:1, - val:'' - },{ - name:'横移位置:', - width:1, - val:'' - },{ - name:'滚转位置:', - width:1, - val:'' - },{ - name:'超重限位:', - width:1, - val:'' - },{ - name:'升降位置:', - width:0, - val:'' - } - ], - carData1:[], - carData2:[], - carData3:[], deviceData:{}, + showToastTitle:'', + showToastIcon:'', + showToastState:0, + errorIcon:error, + successIcon:successImage } }, methods: { cutOption(value){ - this.optionIndex=value + this.optionIndex=value; }, outLogin(){ uni.showModal({ @@ -117,59 +75,29 @@ url:'/zhxx/dt/horizonLoadInfo', data:{} }).then((res)=>{ - if(res.code==200){ - this.deviceData=res.data; - this.carData1=this.carEntsorgen(res.data,1); - this.carData2=this.carEntsorgen(res.data,2); - this.carData3=this.carEntsorgen(res.data,3); + if(res.data.code==200){ + this.deviceData=res.data.data[0]; + } + }).catch((err)=>{ + console.log(err) + if(err.errMsg.includes('Failed to connect')){ + this.showToat({ + title:'请确保成功连接网络', + icon:'error', + duration:1800 + }) } + }) }, - - carEntsorgen(value,type){ - let data=value; - let arrData=this.dataInter; - if(type==1){ - arrData[0].val=value.online==1?'在线':'离线'; - arrData[1].val=value.leftHorizontalLimit; - arrData[2].val=value.rightHorizontalLimit; - arrData[3].val=value.downLimit; - arrData[4].val=value.upLimit; - arrData[5].val=value.leftTurnLimit; - arrData[6].val=value.rightTurnLimit; - arrData[7].val=value.walkAxisPosition; - arrData[8].val=value.horizontalAxisPosition; - arrData[9].val=value.turnPosition; - arrData[10].val=value.overWeightLimit; - arrData[11].val=value.liftPosition; - }else if(type==2){ - arrData[0].val=value.onlineTwo==1?'在线':'离线'; - arrData[1].val=value.leftHorizontalLimitTwo; - arrData[2].val=value.rightHorizontalLimitTwo; - arrData[3].val=value.downLimitTwo; - arrData[4].val=value.upLimitTwo; - arrData[5].val=value.leftTurnLimitTwo; - arrData[6].val=value.rightTurnLimitTwo; - arrData[7].val=value.walkAxisPositionTwo; - arrData[8].val=value.horizontalAxisPositionTwo; - arrData[9].val=value.turnPositionTwo; - arrData[10].val=value.overWeightLimitTwo; - arrData[11].val=value.liftPositionTwo; - }else{ - arrData[0].val=value.onlineThree==1?'在线':'离线'; - arrData[1].val=value.leftHorizontalLimitThree; - arrData[2].val=value.rightHorizontalLimitThree; - arrData[3].val=value.downLimitThree; - arrData[4].val=value.upLimitThree; - arrData[5].val=value.leftTurnLimitThree; - arrData[6].val=value.rightTurnLimitThree; - arrData[7].val=value.walkAxisPositionThree; - arrData[8].val=value.horizontalAxisPositionThree; - arrData[9].val=value.turnPositionThree; - arrData[10].val=value.overWeightLimitThree; - arrData[11].val=value.liftPositionThree; - } - return arrData; + showToat(value){ + this.showToastState=1; + this.showToastTitle=value.title; + this.showToastIcon=value.icon; + + setTimeout(()=>{ + this.showToastState=0; + },value.duration) } }, @@ -191,6 +119,13 @@ setInterval(()=>{ this.deviceAjax(); },1000) + // ,{title:res.data.msg?res.data.msg:'请求失败',duration:1000,icon:'error'} + + this.$eventBus.on('showToast',(data)=>{ + console.log(3333333); + this.showToat(data); + + }) } } @@ -235,4 +170,30 @@ right: 2%; } + .showToast{ + position: absolute; + left: 50%; + transform: translateX(-50%); + padding: 16px 12px; + background-color: rgb(0,0,0,0.7); + z-index: 2000; + top: 40%; + border-radius: 10px; + display: flex; + flex-direction: column; + align-items: center; + justify-content: space-between; + } + + .showToast>image{ + width: 40px; + height: 40px; + margin-bottom: 20px; + } + + .showToast>span{ + color: #ffffff; + font-size: 18px; + } + \ No newline at end of file diff --git a/static/image/errorToast.png b/static/image/errorToast.png new file mode 100644 index 0000000000000000000000000000000000000000..468129a82ea1d569fcd2b49cd0e312ed128b9b92 GIT binary patch literal 1000 zcmV>P)Px&qDe$SRA@u(T03$SK@62bP656J8Ei<%1psG|kP)*^xd239@Eu557ZInxL?qln z?3+?=X?oPt-+?m4RJrV(8F%YRPilRZY0xDi_lW2r5#7}#@fkn3Zp`l=_{_|Q5nFT5 zA}aJ#6&%9XTmW@RMAtoFngFQaUyO!p1oz$rm1&(B97&gmT&=xNSE*sRz%(q(JK}F2{T{yf?(#ec#Q=BC)!kL-f;RY z5k1$>FPQmV4FFXFLawFpB{QGfb!GrW1eAgH!_~}r5$Oh?AaG{j>8;@fQ^z9jRF7( zn;)~lY=Tz;Y$E{ixv*mq8BU+AD5UG!V6z7R%d6&tE4IoO7I6Gv0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 HcmV?d00001 diff --git a/utils/requset.js b/utils/requset.js index 63f27c6..1179ac7 100644 --- a/utils/requset.js +++ b/utils/requset.js @@ -27,12 +27,9 @@ export function httpPost(option) { reject(err, 22222) }, complete(res) { - if (res.data.code == 401) { - // uni.reLaunch({ - // url: "/pages/login/LoginPage" - // }) - fetchUserName() - } + // console.log(res) + reject(res) + } }) })