This commit is contained in:
zmj 2024-02-28 22:47:53 +08:00
parent eafb575f09
commit 86ad3a1104
3 changed files with 45 additions and 35 deletions

View File

@ -6,31 +6,45 @@ import { globalEventBus } from '@/common/eventBus'
import { Push } from '@/common/push'
import { areaObj } from "@/store/index.js"
import { useRouter } from 'vue-router';
const router=useRouter()
const userInfoStore=areaObj()
const router = useRouter()
const userInfoStore = areaObj()
userInfoStore.changeUserInfoFn(510521)
const openPush=(uid=11)=>{
// URL
var queryString = window.location.hash.split("?")[1];
//
const searchParamsType = new URLSearchParams(queryString);
// id
const type = searchParamsType.get('type') || '';
if (type) { localStorage.setItem("TRADE_TYPE", true) }
else {
localStorage.setItem("TRADE_TYPE", false)
}
const isMainScreen = Boolean(type)
console.log(isMainScreen, 'isMainScreen')
const openPush = (uid = 11) => {
if (isMainScreen) return
var connection = new Push({
url: 'wss://chat.lihaink.cn/tts', // websocket
app_key: 'aaea61749929eb53a4bd75a1474c1d27',
});
// uid1
// user-2uid1
var user_channel = connection.subscribe( uid==11?'user-' + uid:uid+'user-plant' );
// var user_channel = connection.subscribe('zhanguan'+'user-plant' );
url: 'wss://chat.lihaink.cn/tts', // websocket
app_key: 'aaea61749929eb53a4bd75a1474c1d27',
});
// uid1
// user-2uid1
var user_channel = connection.subscribe(uid == 11 ? 'user-' + uid : uid + 'user-plant');
// var user_channel = connection.subscribe('zhanguan'+'user-plant' );
// user-2message
user_channel.on('message', function (data) {
console.log(data,'收到事件')
// user-2message
user_channel.on('message', function (data) {
console.log(data, '收到事件')
globalEventBus.emit(data.content.event, data.content.data)
});
// 线
user_channel.on('close', function () {
});
// 线
user_channel.on('close', function () {
});
});
}
globalEventBus.on('refresh', data => {
@ -47,19 +61,22 @@ const searchParams = new URLSearchParams(queryString);
// id
const id = searchParams.get('local') || '';
if (!JSON.parse(localStorage.getItem("TRADE_TYPE"))) {
if (id) {
openPush(id);
}
else {
openPush();
}
}
id ? openPush(id) : openPush()
// if (!JSON.parse(localStorage.getItem("TRADE_TYPE"))) {
// if (id) {
// openPush(id);
// }
// else {
// openPush();
// }
// }
</script>
<template>
<router-view></router-view>
<router-view></router-view>
<div>
</div>
</template>

View File

@ -316,9 +316,6 @@ const initAreaMap = async () => {
bg.setOption(option);
bg.on('click', function (params) {
console.log(params, 'parmas')
if (isMainScreen) {
sendFn('choseTown', { name: params?.name||params?.value })
} else {
@ -563,7 +560,6 @@ const initTownMap = async (name) => {
}
watch(() => areaStore.userInfo, (value, oldValue) => {
console.log("监听到了", value)
if (!value.streetCode) {
initGeoJson(value.areaCode)
getFamrCenter().then(res => {

View File

@ -11,10 +11,7 @@
import { useRoute } from "vue-router"
const route = useRoute()
import Header from "@/components/Header.vue"
if (route.query?.type) { localStorage.setItem("TRADE_TYPE", true) }
else {
localStorage.setItem("TRADE_TYPE", false)
}
</script>
<style lang="scss">