活动介绍

export default { onLaunch: function(options) { console.log('欢迎使用Whotalk即时通讯系统'); console.log('Whotalk官网:https://www.whotalk.com.cn/'); if(options.query){ let fromuid = options.query.fromuid; if(typeof(options.query.debug)!='undefined') core.debug = options.query.debug=='yes' ? true : false; if(options.query.q){ fromuid = core.urlParams(decodeURIComponent(options.query.q), 'fromuid'); } if(fromuid){ core.agentid = parseInt(options.query.fromuid); } } let userstate = typeof(options.query.state)=='undefined' ? '' : options.query.state; core.init(userstate); uni.getSystemInfo({ success: function(e) { let custom, CustomBar; // #ifndef MP Vue.prototype.StatusBar = e.statusBarHeight; if (e.osName == 'android') { CustomBar = e.statusBarHeight + 50; } else { CustomBar = e.statusBarHeight + 45; core.device = 'ios'; }; // #endif // #ifdef MP-WEIXIN custom = wx.getMenuButtonBoundingClientRect(); CustomBar = custom.bottom + custom.top - e.statusBarHeight; // #endif // #ifdef MP-TOUTIAO custom = tt.getMenuButtonBoundingClientRect(); CustomBar = custom.bottom + custom.top - e.statusBarHeight; // #endif // #ifdef MP-TOUTIAO || MP-WEIXIN Vue.prototype.StatusBar = e.statusBarHeight; Vue.prototype.Custom = custom; // #endif // #ifdef MP-ALIPAY CustomBar = e.statusBarHeight + e.titleBarHeight; // #endif Vue.prototype.CustomBar = e.CustomBar = CustomBar; core.Client = e; } }) // #ifdef APP-PLUS if(typeof(plus.push)!='undefined'){ const _handlePush = function(message) { // TODO let payload = message.payload; if(core.isJsonString(payload)){ payload = JSON.parse(payload); } if(typeof(payload.pagePath)!='undefined'){ let ws = plus.webview.currentWebview(); let weburl = ws.getURL(); let redt = weburl.indexOf('dialog/index')>-1 ?

时间: 2025-03-29 21:18:03 浏览: 45
### 处理推送消息并初始化应用 在 Vue 和 Uni-app 中,`plus.push` 是用于处理推送消息的核心模块之一。以下是详细的实现方法: #### 1. 使用 `plus.push` 处理推送消息 为了监听和响应推送消息,在应用程序启动时可以通过注册事件来捕获推送通知的内容。 ```javascript // 注册推送消息接收事件 plus.push.addEventListener("receive", function (msg) { console.log("收到一条新消息:" + msg.content); }, false); // 当用户点击通知时触发此事件 plus.push.addEventListener("click", function (msg) { alert("您点击了一条通知:" + msg.content); }, false); ``` 上述代码实现了两个功能:当设备接收到推送消息时会打印日志[^1];当用户点击通知时弹出提示框显示具体内容[^2]。 #### 2. 初始化应用并设置状态栏高度 由于不同平台的状态栏高度可能有所不同,因此需要动态调整以适配各端环境。 对于 Android 平台: - 可以直接调用 API 获取当前屏幕尺寸及状态栏大小; ```javascript if (uni.getSystemInfoSync().platform === 'android') { let statusBarHeight = plus.navigator.getStatusBarHeight(); document.getElementById('status-bar').style.height = `${statusBarHeight}px`; } ``` 针对 iOS 设备,则需特别注意是否存在刘海屏设计影响布局效果的情况: ```javascript else if (uni.getSystemInfoSync().platform === 'ios') { const systemInfo = uni.getSystemInfoSync(); // 假设顶部安全区域距离等于状态栏高 var safeAreaInsetsTop = parseFloat(systemInfo.safeAreaInsets.top || 0); document.getElementById('safe-area-top').style.paddingTop = `${safeAreaInsetsTop}px`; } ``` 以上脚本片段分别演示了如何依据操作系统差异设定合适的 UI 参数值[^3]。 #### 注意事项 开发期间务必确认已正确集成第三方服务(如极光推送 JPush 或小米推送 MiPush),因为这些 SDK 提供更全面的功能支持,比如离线消息缓存机制等特性[^4]。 --- ###
阅读全文

相关推荐

<template> <view> <view class="map" id="mapDiv" style="width: 100%;height: 80vh;z-index: 0;position: relative;" :prop="dataOption" :change:prop="Trenderjs.initTMap" :change:renderTrigger="Trenderjs.handleMessage" :renderTrigger="triggerCounter"> </view> </view> </template> <script> export default { data() { return { msg: '我是service层原来的msg', triggerCounter: 0, isProcessing: false, // 新增状态锁 message: null }; }, props: { dataOption: { type: String, default: '' }, }, methods: { renderjsData() { console.log('----------', this.triggerCounter); if (this.isProcessing) return; // 阻止重复触发 this.isProcessing = true; this.triggerCounter++ console.log('=============', this.triggerCounter); }, someMethodInVue(newVal) { console.log('位置', newVal); this.$emit('childEvent', newVal); this.message = newVal this.isProcessing = false; } } }; </script> <script module="Trenderjs" lang="renderjs"> var control; export default { data() { return { tk: '27657afc3318f8f2166fceba83427734', options: { lng: '104.397894', lat: '31.126855', }, iconType: "default", dataList: [], pointList: [], Tmap: null, gisDataObj: {}, gisData: {}, geocode: null, gisPointLngLat: {} } }, mounted() { if (!window.T) { console.log('00000', ); const script = document.createElement('script') script.src = 'http://api.tianditu.gov.cn/api?v=4.0&tk=' + this.tk // this.initChartsRender.bind() document.head.appendChild(script) script.onload = this.initChartsRender.bind() } else { console.log('++++', ); const { lng, lat } = this.options this.Tmap = null; console.log(this.Tmap); this.Tmap = new T.Map('mapDiv'); this.Tmap.centerAndZoom(new T.LngLat(lng, lat), 15); this.Tmap.setStyle("indigo"); //设置地图主体颜色indigo this.Tmap.disableDoubleClickZoom(); this.Tmap.disableScrollWheelZoom(); this.Tmap.disableInertia() this.Tmap.disableKeyboard() //创建对象 this.geocode = new T.Geocoder(); control = new T.Control.Zoom(); this.Tmap.addControl(control); var controlPosition = T_ANCHOR_BOTTOM_RIGHT; control.setPosition(controlPosition); // Tmap.enableDrag(); // this.setIcon(lng, lat, true, '') } }, created() { }, methods: { // 初始化地图 initTMap(newValue, oldValue) { let that = this; // 开启实时定位监听 that._watchId && plus.geolocation.clearWatch(that._watchId); // 先清除旧的监听 that._watchId = plus.geolocation.watchPosition(successCB => { let data = { lng: successCB.coords.longitude, lat: successCB.coords.latitude } console.log('实时定位:', data.lng, data.lat); that.Tmap.centerAndZoom(new T.LngLat(data.lng, data.lat), 20); var point = new T.LngLat(data.lng, data.lat); const marker = new T.Marker(point, { // icon }); that.Tmap.clearOverLays(); // 可选:每次清除旧的覆盖物 that.Tmap.addOverLay(marker); var label = new T.Label({ text: '实时定位:' + data.lng + ',' + data.lat, position: point, offset: new T.Point(-40, 10) }); //创建地图文本对象 that.Tmap.addOverLay(label); }, err => { console.log(err); }, { provider: 'system', enableHighAccuracy: true, }); // let that = this if (newValue) { setTimeout(function() { console.log(JSON.parse(newValue)); that.gisDataObj = JSON.parse(newValue) console.log(JSON.parse(that.gisDataObj.data)); that.gisData = JSON.parse(that.gisDataObj.data) // if (that.gisData.length > 0) { // that.options = { // lng: that.pointList[0].deviceDeploymentLocation.split(',')[1], // lat: that.pointList[0].deviceDeploymentLocation.split(',')[0] // } // } else { let gisPoint = JSON.parse(that.gisData.data) that.gisPointLngLat = JSON.parse(that.gisData.data) if (that.gisData.type == 'marker') { that.options = { lng: gisPoint.lng, lat: gisPoint.lat, } } else if (that.gisData.type == 'polyline' || that.gisData.type == 'polygon') { that.options = { lng: gisPoint[0].lng, lat: gisPoint[0].lat, } } else { that.options = { lng: '104.397894', lat: '31.126855', } } const { lng, lat } = that.options that.Tmap.centerAndZoom(new T.LngLat(lng, lat), 15); if (that.gisData.type == 'marker') { var point = new T.LngLat(gisPoint.lng, gisPoint.lat); console.log(point); const marker = new T.Marker(point, { // icon }); that.Tmap.addOverLay(marker); var label = new T.Label({ text: that.gisData.name, position: point, offset: new T.Point(-40, 10) }); //创建地图文本对象 that.Tmap.addOverLay(label); } else if (that.gisData.type == 'polyline') { let points = []; for (let i = 0; i < gisPoint.length; i++) { points.push(new T.LngLat(gisPoint[i].lng, gisPoint[i].lat)); } //创建线对象 var line = new T.Polyline(points, { color: that.gisDataObj.color, weight: 6, }); //向地图上添加线 that.Tmap.addOverLay(line); var label = new T.Label({ text: that.gisData.name, position: points[points.length - 1], offset: new T.Point(-40, 10) }); //创建地图文本对象 that.Tmap.addOverLay(label); } else if (that.gisData.type == 'polygon') { let points = []; for (let i = 0; i < gisPoint.length; i++) { points.push(new T.LngLat(gisPoint[i].lng, gisPoint[i].lat)); } //创建线对象 var polygon = new T.Polygon(points, { color: that.gisDataObj.color, weight: 6, }); //向地图上添加线 that.Tmap.addOverLay(polygon); var label = new T.Label({ text: that.gisData.name, position: points[points.length - 1], offset: new T.Point(-40, 10) }); //创建地图文本对象 that.Tmap.addOverLay(label); } }, 1000); } }, // 若没有加载地图方法 initChartsRender() { const { lng, lat } = this.options var that = this; this.Tmap = new T.Map('mapDiv'); this.Tmap.centerAndZoom(new T.LngLat(lng, lat), 15); this.Tmap.setStyle("indigo"); //设置地图主体颜色indigo this.Tmap.disableDoubleClickZoom(); this.Tmap.disableScrollWheelZoom(); this.Tmap.disableInertia() this.Tmap.disableKeyboard() control = new T.Control.Zoom(); this.Tmap.addControl(control); var controlPosition = T_ANCHOR_BOTTOM_RIGHT; control.setPosition(controlPosition); // Tmap.enableDrag(); // this.setIcon(lng, lat, true, '') }, // 地图图标Icon setIcon(lng, lat, isClear, markerActive) { if (isClear) { // if (this.iconType == 'searchIcon') { // this.Tmap.clearOverLays() // } else { this.Tmap.removeOverLay(markerActive) // } } console.log(this.gisData); let gisPoint = JSON.parse(this.gisData.data) }, // RenderJS事件处理器 handleMessage(newVal, oldVal) { console.log(newVal, oldVal); if (newVal !== oldVal) { const center = this.Tmap.getCenter(); var lo = new T.Geolocation(); let that = this // let gisPoint = JSON.parse(this.gisData.data) const fn = function(e) { let distance = that.getDistance(e.lnglat.lat, e.lnglat.lng, that.gisPointLngLat.lat, that .gisPointLngLat.lng) that.$ownerInstance.callMethod('someMethodInVue', { lng: e.lnglat.lng, lat: e.lnglat.lat, distance: distance * 1000 }); // // if (this.getStatus() == 0) { // that.Tmap.centerAndZoom(e.lnglat, 15) // console.log('e.lnglat000', e.lnglat.lat, e.lnglat.lng); // // var marker = new T.Marker(e.lnglat); // // that.Tmap.addOverLay(marker); // // } // // if (this.getStatus() == 1) { // console.log('e.lnglat111', e.lnglat.lat, e.lnglat.lng); // that.Tmap.centerAndZoom(e.lnglat, e.level) // // var marker = new T.Marker(e.lnglat); // // that.Tmap.addOverLay(marker); // // } } lo.getCurrentPosition(fn); } }, getDistance(lat1, lng1, lat2, lng2) { console.log(lat1, lng1, lat2, lng2); const radLat1 = (lat1 * Math.PI) / 180.0 const radLat2 = (lat2 * Math.PI) / 180.0 const a = radLat1 - radLat2 const b = (lng1 * Math.PI) / 180.0 - (lng2 * Math.PI) / 180.0 let s = 2 * Math.asin( Math.sqrt( Math.pow(Math.sin(a / 2), 2) + Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2) ) ) s *= 6378.137 // EARTH_RADIUS; s = Math.round(s * 100) / 100 console.log(s); return s // 调用 return的距离单位为km } }, } </script> 在此代码中进行更改,生成完整的代码

获取特勤线路详细信息失败 TypeError: _this6.$refs.mineMapRef.updateRealtimeRoute is not a function at _callee3$ (index.vue?./node_modules/babel-loader/lib/index.js!./node_modules/vue-loader/lib/index.js??vue-loader-options:701:39) at tryCatch (regeneratorRuntime.js:72:16) at Generator.eval (regeneratorRuntime.js:161:17) at Generator.eval [as next] (regeneratorRuntime.js:102:21) at asyncGeneratorStep (asyncToGenerator.js:9:24) at _next (asyncToGenerator.js:28:9)deviceArray: [__ob__: Observer] vue.js:4857 [Vue warn]: Error in v-on handler: "TypeError: Cannot read properties of undefined (reading 'realtime')" found in ---> <SpeLineList> at src/views/components/SpeLineDetail/index.vue <Index> at src/views/largeScreen/SpecialLine/index.vue <App> at src/views/App.vue <Root> warn$2 @ vue.js:4857 logError @ vue.js:3547 globalHandleError @ vue.js:3543 handleError @ vue.js:3511 invokeWithErrorHandling @ vue.js:3527 invoker @ vue.js:1461 invokeWithErrorHandling @ vue.js:3519 Vue.$emit @ vue.js:2638 _callee2$ @ index.vue?./node_modules/babel-loader/lib/index.js!./node_modules/vue-loader/lib/index.js??vue-loader-options:360 tryCatch @ regeneratorRuntime.js:72 eval @ regeneratorRuntime.js:161 eval @ regeneratorRuntime.js:102 asyncGeneratorStep @ asyncToGenerator.js:9 _next @ asyncToGenerator.js:28 Promise.then asyncGeneratorStep @ asyncToGenerator.js:18 _next @ asyncToGenerator.js:28 eval @ asyncToGenerator.js:33 Wrapper @ export.js:20 eval @ asyncToGenerator.js:25 submitForm @ index.vue?./node_modules/babel-loader/lib/index.js!./node_modules/vue-loader/lib/index.js??vue-loader-options:373 invokeWithErrorHandling @ vue.js:3519 invoker @ vue.js:1461 original_1._wrapper @ vue.js:7516 vue.js:3551 TypeError: Cannot read properties of undefined (reading 'realtime') at VueComponent.updateVehiclePosition (index.vue?./node_modules/babel-loader/lib/index.js!./node_modules/vue-loader/lib/index.js??vue-loader-options:475:19) at VueComponent.handlesHeadTq (index.vue?./node_modules/babel-loader/lib/index.js!./node_modules/vue-loader/lib/index.js??vue-loader-options:677:29) at VueComponent.handlestartTq (index.vue?./node_modules/babel-loader/lib/index.js!./node_modules/vue-loader/lib/index.js??vue-loader-options:668:12) at invokeWithErrorHandling (vue.js:3519:28) at VueComponent.invoker (vue.js:1461:16) at invokeWithErrorHandling (vue.js:3519:28) at Vue.$emit (vue.js:2638:11) at _callee2$ (index.vue?./node_modules/babel-loader/lib/index.js!./node_modules/vue-loader/lib/index.js??vue-loader-options:360:24) at tryCatch (regeneratorRu