add
This commit is contained in:
parent
eafb575f09
commit
86ad3a1104
63
src/App.vue
63
src/App.vue
|
@ -6,31 +6,45 @@ import { globalEventBus } from '@/common/eventBus'
|
||||||
import { Push } from '@/common/push'
|
import { Push } from '@/common/push'
|
||||||
import { areaObj } from "@/store/index.js"
|
import { areaObj } from "@/store/index.js"
|
||||||
import { useRouter } from 'vue-router';
|
import { useRouter } from 'vue-router';
|
||||||
const router=useRouter()
|
const router = useRouter()
|
||||||
const userInfoStore=areaObj()
|
const userInfoStore = areaObj()
|
||||||
userInfoStore.changeUserInfoFn(510521)
|
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({
|
var connection = new Push({
|
||||||
url: 'wss://chat.lihaink.cn/tts', // websocket地址
|
url: 'wss://chat.lihaink.cn/tts', // websocket地址
|
||||||
app_key: 'aaea61749929eb53a4bd75a1474c1d27',
|
app_key: 'aaea61749929eb53a4bd75a1474c1d27',
|
||||||
});
|
});
|
||||||
// 假设用户uid为1
|
// 假设用户uid为1
|
||||||
// 浏览器监听user-2频道的消息,也就是用户uid为1的用户消息
|
// 浏览器监听user-2频道的消息,也就是用户uid为1的用户消息
|
||||||
var user_channel = connection.subscribe( uid==11?'user-' + uid:uid+'user-plant' );
|
var user_channel = connection.subscribe(uid == 11 ? 'user-' + uid : uid + 'user-plant');
|
||||||
// var user_channel = connection.subscribe('zhanguan'+'user-plant' );
|
// var user_channel = connection.subscribe('zhanguan'+'user-plant' );
|
||||||
|
|
||||||
|
|
||||||
// 当user-2频道有message事件的消息时
|
// 当user-2频道有message事件的消息时
|
||||||
user_channel.on('message', function (data) {
|
user_channel.on('message', function (data) {
|
||||||
console.log(data,'收到事件')
|
console.log(data, '收到事件')
|
||||||
globalEventBus.emit(data.content.event, data.content.data)
|
globalEventBus.emit(data.content.event, data.content.data)
|
||||||
});
|
});
|
||||||
// 断线事件
|
// 断线事件
|
||||||
user_channel.on('close', function () {
|
user_channel.on('close', function () {
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
globalEventBus.on('refresh', data => {
|
globalEventBus.on('refresh', data => {
|
||||||
|
@ -47,15 +61,18 @@ const searchParams = new URLSearchParams(queryString);
|
||||||
|
|
||||||
// 读取名为 id 的参数
|
// 读取名为 id 的参数
|
||||||
const id = searchParams.get('local') || '';
|
const id = searchParams.get('local') || '';
|
||||||
if (!JSON.parse(localStorage.getItem("TRADE_TYPE"))) {
|
|
||||||
if (id) {
|
|
||||||
openPush(id);
|
|
||||||
|
|
||||||
}
|
id ? openPush(id) : openPush()
|
||||||
else {
|
|
||||||
openPush();
|
// if (!JSON.parse(localStorage.getItem("TRADE_TYPE"))) {
|
||||||
}
|
// if (id) {
|
||||||
}
|
// openPush(id);
|
||||||
|
|
||||||
|
// }
|
||||||
|
// else {
|
||||||
|
// openPush();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
|
|
|
@ -316,9 +316,6 @@ const initAreaMap = async () => {
|
||||||
bg.setOption(option);
|
bg.setOption(option);
|
||||||
bg.on('click', function (params) {
|
bg.on('click', function (params) {
|
||||||
|
|
||||||
console.log(params, 'parmas')
|
|
||||||
|
|
||||||
|
|
||||||
if (isMainScreen) {
|
if (isMainScreen) {
|
||||||
sendFn('choseTown', { name: params?.name||params?.value })
|
sendFn('choseTown', { name: params?.name||params?.value })
|
||||||
} else {
|
} else {
|
||||||
|
@ -563,7 +560,6 @@ const initTownMap = async (name) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(() => areaStore.userInfo, (value, oldValue) => {
|
watch(() => areaStore.userInfo, (value, oldValue) => {
|
||||||
console.log("监听到了", value)
|
|
||||||
if (!value.streetCode) {
|
if (!value.streetCode) {
|
||||||
initGeoJson(value.areaCode)
|
initGeoJson(value.areaCode)
|
||||||
getFamrCenter().then(res => {
|
getFamrCenter().then(res => {
|
||||||
|
|
|
@ -11,10 +11,7 @@
|
||||||
import { useRoute } from "vue-router"
|
import { useRoute } from "vue-router"
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
import Header from "@/components/Header.vue"
|
import Header from "@/components/Header.vue"
|
||||||
if (route.query?.type) { localStorage.setItem("TRADE_TYPE", true) }
|
|
||||||
else {
|
|
||||||
localStorage.setItem("TRADE_TYPE", false)
|
|
||||||
}
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
|
|
Loading…
Reference in New Issue