From 4428b1af3add51108e1fd012cbdb121a1c6a16da Mon Sep 17 00:00:00 2001 From: weipengfei <2187978347@qq.com> Date: Thu, 22 Feb 2024 18:14:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E8=BF=9C=E7=A8=8B=E6=8E=A7?= =?UTF-8?q?=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.vue | 2 +- src/components/headView.vue | 33 ++++++++++++++++++++++++++++++++- src/view/index/index.vue | 8 ++++---- 3 files changed, 37 insertions(+), 6 deletions(-) diff --git a/src/App.vue b/src/App.vue index 3721602..ad11222 100644 --- a/src/App.vue +++ b/src/App.vue @@ -50,12 +50,12 @@ const user_channel = connection.subscribe('user-breed-datav'); // 当user-2频道有message事件的消息时 user_channel.on('message', function (data) { + console.log("收到消息--",data); if(route.query.type=='main'&&data.content.event=='changMap') return; if(data.content.event=='refresh') refresh(); if(data.content.event=='back') back(); else mitt.emit(data.content.event, data.content.data); - console.log("收到消息--",data); }); // 断线事件 diff --git a/src/components/headView.vue b/src/components/headView.vue index 21497ea..1ab37e9 100644 --- a/src/components/headView.vue +++ b/src/components/headView.vue @@ -160,6 +160,38 @@ const changeTime = (e) => { console.log(e); } +mitt.on("choserArea", (data) => { + appStore.setAddress({ + areaCode: data.code, + streetCode: "", + }); + initList(); + router.push({ + path: '/', + query: { + areaCode: data.code, + } + }) +}); + +mitt.on("choseTown", (data) => { + let c = list.value.find(item=>item.name==data.name); + if(!c)return; + appStore.setAddress({ + areaCode: appStore.address.areaCode, + streetCode: c.code, + }); + initList(); + router.push({ + path: '/indexc', + query: { + areaCode: appStore.address.areaCode, + streetCode: c.code, + name: data.name + } + }) +}); + onMounted(() => { if (route.query.areaCode) { appStore.setAddress({ @@ -188,7 +220,6 @@ onMounted(() => { setInterval(updateClock, 1000); initWeather(); - mitt.on('changMap', (e)=>{ if(e.areaName==info.areaName){ diff --git a/src/view/index/index.vue b/src/view/index/index.vue index b08036c..025ae5b 100644 --- a/src/view/index/index.vue +++ b/src/view/index/index.vue @@ -13,15 +13,15 @@ const key = ref(Date.now());