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());