Parcourir la source

Merge remote-tracking branch 'origin/master'

licailing il y a 5 ans
Parent
commit
9d61e23cf8

+ 18 - 0
src/main/map/package-lock.json

@@ -3598,6 +3598,14 @@
       "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=",
       "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=",
       "dev": true
       "dev": true
     },
     },
+    "cos-js-sdk-v5": {
+      "version": "0.5.27",
+      "resolved": "https://registry.npmjs.org/cos-js-sdk-v5/-/cos-js-sdk-v5-0.5.27.tgz",
+      "integrity": "sha512-kq5363l1TpU26AHRZTcWCibPfM5ykQ2zHsdpnP/Ax8SMuYQDNIP/BVWaA55Ks2r5JsELjqXLF516FeXQz3jEZw==",
+      "requires": {
+        "xmldom": "^0.1.27"
+      }
+    },
     "cosmiconfig": {
     "cosmiconfig": {
       "version": "5.2.1",
       "version": "5.2.1",
       "resolved": "https://registry.npm.taobao.org/cosmiconfig/download/cosmiconfig-5.2.1.tgz?cache=0&sync_timestamp=1572710769619&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fcosmiconfig%2Fdownload%2Fcosmiconfig-5.2.1.tgz",
       "resolved": "https://registry.npm.taobao.org/cosmiconfig/download/cosmiconfig-5.2.1.tgz?cache=0&sync_timestamp=1572710769619&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fcosmiconfig%2Fdownload%2Fcosmiconfig-5.2.1.tgz",
@@ -10901,6 +10909,11 @@
       "integrity": "sha1-Wrr3FKlAXbBQRzK7zNLO3Z75U30=",
       "integrity": "sha1-Wrr3FKlAXbBQRzK7zNLO3Z75U30=",
       "dev": true
       "dev": true
     },
     },
+    "tim-js-sdk": {
+      "version": "2.7.6",
+      "resolved": "https://registry.npmjs.org/tim-js-sdk/-/tim-js-sdk-2.7.6.tgz",
+      "integrity": "sha512-bpdWM9aIdAfUTjONjMFqx2H6UOs+SCx1AozIL54zqbaYBJhyQL3Hy32BQd/zrTkCpdkO38hotUWy8O5aEy6nvg=="
+    },
     "timers-browserify": {
     "timers-browserify": {
       "version": "2.0.11",
       "version": "2.0.11",
       "resolved": "https://registry.npm.taobao.org/timers-browserify/download/timers-browserify-2.0.11.tgz",
       "resolved": "https://registry.npm.taobao.org/timers-browserify/download/timers-browserify-2.0.11.tgz",
@@ -12235,6 +12248,11 @@
         "async-limiter": "~1.0.0"
         "async-limiter": "~1.0.0"
       }
       }
     },
     },
+    "xmldom": {
+      "version": "0.1.31",
+      "resolved": "https://registry.npmjs.org/xmldom/-/xmldom-0.1.31.tgz",
+      "integrity": "sha512-yS2uJflVQs6n+CyjHoaBmVSqIDevTAWrzMmjG1Gc7h1qQ7uVozNhEPJAwZXWyGQ/Gafo3fCwrcaokezLPupVyQ=="
+    },
     "xregexp": {
     "xregexp": {
       "version": "4.3.0",
       "version": "4.3.0",
       "resolved": "https://registry.npm.taobao.org/xregexp/download/xregexp-4.3.0.tgz",
       "resolved": "https://registry.npm.taobao.org/xregexp/download/xregexp-4.3.0.tgz",

+ 2 - 0
src/main/map/package.json

@@ -12,6 +12,8 @@
     "axios": "^0.19.2",
     "axios": "^0.19.2",
     "babel-plugin-import": "^1.13.0",
     "babel-plugin-import": "^1.13.0",
     "core-js": "^3.6.5",
     "core-js": "^3.6.5",
+    "cos-js-sdk-v5": "^0.5.27",
+    "tim-js-sdk": "^2.7.6",
     "vant": "^2.9.0",
     "vant": "^2.9.0",
     "vue": "^2.6.11",
     "vue": "^2.6.11",
     "vue-router": "^3.2.0",
     "vue-router": "^3.2.0",

+ 5 - 0
src/main/map/src/router/index.js

@@ -28,6 +28,11 @@ const routes = [
         name: 'polylineRoutePlan',
         name: 'polylineRoutePlan',
         component: () => import('../views/PolylineRoutePlan.vue'),
         component: () => import('../views/PolylineRoutePlan.vue'),
     },
     },
+    {
+        path: '/tim',
+        name: 'tim',
+        component: () => import('../views/Tim.vue'),
+    },
 ];
 ];
 const router = new VueRouter({
 const router = new VueRouter({
     mode: 'history',
     mode: 'history',

+ 31 - 65
src/main/map/src/views/Heat3D.vue

@@ -1,23 +1,19 @@
 <template>
 <template>
-    <div id="container">
-        <div @click="sendMessage">发送信息</div>
-    </div>
+    <div id="container"></div>
 </template>
 </template>
 <script>
 <script>
 import { mapState } from 'vuex';
 import { mapState } from 'vuex';
-import axios from 'axios';
-window.addEventListener(
-    'message',
-    event => {
-        alert(JSON.stringify(event));
-    },
-    false,
-);
 export default {
 export default {
-    name: '',
+    name: 'heat3D',
     data() {
     data() {
         return {
         return {
             heatData: [],
             heatData: [],
+            center: {
+                lat: '',
+                lng: '',
+            },
+            map: null,
+            heat: null,
         };
         };
     },
     },
     computed: {
     computed: {
@@ -25,78 +21,48 @@ export default {
     },
     },
     mounted() {
     mounted() {
         this.$nextTick(() => {
         this.$nextTick(() => {
-            // this.getData();
-            // this.initMap();
+            window.draw = this.draw;
         });
         });
     },
     },
     methods: {
     methods: {
-        getData() {
-            axios.get('http://dingdong.izouma.com/merchant/heatMap', {
-                longitude: '118.734661',
-                latitude: '31.981746',
-            });
+        draw(list, center) {
+            this.heatData = list;
+            if (center) {
+                this.center = JSON.parse(center);
+            }
+            if (!this.map) {
+                this.initMap();
+            } else {
+                this.heat.setData(this.heatData);
+            }
         },
         },
         initMap() {
         initMap() {
-            var heatAddBtn = document.getElementById('heatAddBtn');
-            var heatDecBtn = document.getElementById('heatDecBtn');
-            var setStyleBtn = document.getElementById('setStyleBtn');
-
             //初始化地图
             //初始化地图
-            var map = new TMap.Map('container', {
-                zoom: 12, //设置地图缩放级别
+            this.map = new TMap.Map('container', {
+                zoom: 16, //设置地图缩放级别
                 pitch: 45, // 设置地图俯仰角
                 pitch: 45, // 设置地图俯仰角
-                center: new TMap.LatLng(39.909897147274364, 116.39756310116866), //设置地图中心点坐标
+                center: new TMap.LatLng(this.center.lat, this.center.lng), //设置地图中心点坐标
                 mapStyleId: 'style1', //个性化样式
                 mapStyleId: 'style1', //个性化样式
             });
             });
             //初始化热力图并添加至map图层
             //初始化热力图并添加至map图层
-            var heat = new TMap.visualization.Heat({
-                max: 180, // 热力最强阈值
+            this.heat = new TMap.visualization.Heat({
+                max: 80, // 热力最强阈值
                 min: 0, // 热力最弱阈值
                 min: 0, // 热力最弱阈值
                 height: 40, // 峰值高度
                 height: 40, // 峰值高度
                 radius: 30, // 最大辐射半径
                 radius: 30, // 最大辐射半径
             })
             })
-                .addTo(map)
-                .setData(this.heatData); //设置数据
-
-            heatAddBtn.addEventListener(
-                'click',
-                () => {
-                    var radius = heat.getRadius() + 5;
-                    heat.setRadius(radius);
-                },
-                false,
-            );
-
-            heatDecBtn.addEventListener(
-                'click',
-                () => {
-                    var radius = heat.getRadius() - 5;
-                    if (radius > 0) {
-                        heat.setRadius(radius);
-                    }
-                },
-                false,
-            );
-
-            setStyleBtn.addEventListener('click', () => {
-                heat.setGradientColor({
-                    0.6: '#673198',
-                    0.8: '#e53390',
-                    0.9: '#ffc95a',
-                });
-            });
-        },
-        sendMessage() {
-            if (window.ReactNativeWebView) {
-                window.ReactNativeWebView.postMessage('信息为27');
-            }
+                .addTo(this.map)
+                .setData(this.heatData)
+                .setGradientColor({
+                    0.9: '#FFA01C',
+                }); //设置数据
         },
         },
     },
     },
 };
 };
 </script>
 </script>
-<style lang='less' scoped>
+<style lang="less" scoped>
 #container {
 #container {
     width: 100vw;
     width: 100vw;
     height: 100vh;
     height: 100vh;
 }
 }
-</style>
+</style>

+ 2 - 2
src/main/map/src/views/PolylineRoutePlan.vue

@@ -34,9 +34,9 @@ export default {
     },
     },
 };
 };
 </script>
 </script>
-<style lang='less' scoped>
+<style lang="less" scoped>
 #iframe {
 #iframe {
     width: 100vw;
     width: 100vw;
     height: 100vh;
     height: 100vh;
 }
 }
-</style>
+</style>

+ 164 - 0
src/main/map/src/views/Tim.vue

@@ -0,0 +1,164 @@
+<template>
+    <div></div>
+</template>
+<script>
+import { mapState } from 'vuex';
+
+import TIM from 'tim-js-sdk';
+import COS from 'cos-js-sdk-v5';
+export default {
+    name: '',
+    data() {
+        return {
+            SDKAppID: 1400401634,
+            userID: 2015,
+            userSig:
+                'eJwtzMsKwjAURdF-ybRSbp6SgpPiRIjgo0VwJja1l6gNMUpA-HdL2*FZB-aXVOaYf2wgBWE5kMW4sbHPiC1ODFTO-mrcxXtsSEEFgACquJgemzwGO7iUkgHApBEfo2klNWeMzRW8DVmknc7KoPbJmU11jedTysAtW9dtexN39Z0f1n1gb1fDivz*cZcwNQ__',
+        };
+    },
+    computed: {
+        ...mapState(['userInfo']),
+    },
+    mounted() {
+        window.chatLogin = this.chatLogin;
+    },
+    methods: {
+        chatLogin(userID, userSig) {
+            if (userID) {
+                this.userID = userID;
+            }
+            if (userSig) {
+                this.userSig = userSig;
+            }
+
+            this.init();
+        },
+        init() {
+            // 创建 SDK 实例,TIM.create() 方法对于同一个 SDKAppID 只会返回同一份实例
+            let options = {
+                SDKAppID: this.SDKAppID, // 接入时需要将0替换为您的即时通信应用的 SDKAppID
+            };
+            let tim = TIM.create(options); // SDK 实例通常用 tim 表示
+            // 设置 SDK 日志输出级别,详细分级请参见 setLogLevel 接口的说明
+            tim.setLogLevel(0); // 普通级别,日志量较多,接入时建议使用
+            // tim.setLogLevel(1); // release级别,SDK 输出关键信息,生产环境时建议使用
+
+            // 将腾讯云对象存储服务 SDK (以下简称 COS SDK)注册为插件,IM SDK 发送文件、图片等消息时,需要用到腾讯云的 COS 服务
+            // HTML5 环境,注册 COS SDK
+            tim.registerPlugin({ 'cos-js-sdk': COS });
+
+            // 监听事件,如:
+            // eslint-disable-next-line no-unused-vars
+            tim.on(TIM.EVENT.SDK_READY, function(event) {
+                // 收到离线消息和会话列表同步完毕通知,接入侧可以调用 sendMessage 等需要鉴权的接口
+                // event.name - TIM.EVENT.SDK_READY
+            });
+
+            tim.on(TIM.EVENT.MESSAGE_RECEIVED, function(event) {
+                console.log(event);
+                // 收到推送的单聊、群聊、群提示、群系统通知的新消息,可通过遍历 event.data 获取消息列表数据并渲染到页面
+                // event.name - TIM.EVENT.MESSAGE_RECEIVED
+                // event.data - 存储 Message 对象的数组 - [Message]
+                if (window.ReactNativeWebView) {
+                    window.ReactNativeWebView.postMessage(
+                        JSON.stringify(event.data),
+                    );
+                }
+            });
+
+            // eslint-disable-next-line no-unused-vars
+            tim.on(TIM.EVENT.MESSAGE_REVOKED, function(event) {
+                // 收到消息被撤回的通知。使用前需要将SDK版本升级至v2.4.0或以上。
+                // event.name - TIM.EVENT.MESSAGE_REVOKED
+                // event.data - 存储 Message 对象的数组 - [Message] - 每个 Message 对象的 isRevoked 属性值为 true
+            });
+
+            // eslint-disable-next-line no-unused-vars
+            tim.on(TIM.EVENT.MESSAGE_READ_BY_PEER, function(event) {
+                // SDK 收到对端已读消息的通知,即已读回执。使用前需要将SDK版本升级至v2.7.0或以上。仅支持单聊会话。
+                // event.name - TIM.EVENT.MESSAGE_READ_BY_PEER
+                // event.data - event.data - 存储 Message 对象的数组 - [Message] - 每个 Message 对象的 isPeerRead 属性值为 true
+            });
+
+            // eslint-disable-next-line no-unused-vars
+            tim.on(TIM.EVENT.CONVERSATION_LIST_UPDATED, function(event) {
+                // 收到会话列表更新通知,可通过遍历 event.data 获取会话列表数据并渲染到页面
+                // event.name - TIM.EVENT.CONVERSATION_LIST_UPDATED
+                // event.data - 存储 Conversation 对象的数组 - [Conversation]
+            });
+
+            tim.on(TIM.EVENT.GROUP_LIST_UPDATED, function(event) {
+                // 收到群组列表更新通知,可通过遍历 event.data 获取群组列表数据并渲染到页面
+                // event.name - TIM.EVENT.GROUP_LIST_UPDATED
+                // event.data - 存储 Group 对象的数组 - [Group]
+                if (window.ReactNativeWebView) {
+                    window.ReactNativeWebView.postMessage(
+                        JSON.stringify(event.data),
+                    );
+                }
+            });
+
+            // eslint-disable-next-line no-unused-vars
+            tim.on(TIM.EVENT.PROFILE_UPDATED, function(event) {
+                // 收到自己或好友的资料变更通知
+                // event.name - TIM.EVENT.PROFILE_UPDATED
+                // event.data - 存储 Profile 对象的数组 - [Profile]
+            });
+
+            // eslint-disable-next-line no-unused-vars
+            tim.on(TIM.EVENT.BLACKLIST_UPDATED, function(event) {
+                // 收到黑名单列表更新通知
+                // event.name - TIM.EVENT.BLACKLIST_UPDATED
+                // event.data - 存储 userID 的数组 - [userID]
+            });
+
+            // eslint-disable-next-line no-unused-vars
+            tim.on(TIM.EVENT.ERROR, function(event) {
+                // 收到 SDK 发生错误通知,可以获取错误码和错误信息
+                // event.name - TIM.EVENT.ERROR
+                // event.data.code - 错误码
+                // event.data.message - 错误信息
+            });
+
+            // eslint-disable-next-line no-unused-vars
+            tim.on(TIM.EVENT.SDK_NOT_READY, function(event) {
+                // 收到 SDK 进入 not ready 状态通知,此时 SDK 无法正常工作
+                // event.name - TIM.EVENT.SDK_NOT_READY
+            });
+
+            // eslint-disable-next-line no-unused-vars
+            tim.on(TIM.EVENT.KICKED_OUT, function(event) {
+                // 收到被踢下线通知
+                // event.name - TIM.EVENT.KICKED_OUT
+                // event.data.type - 被踢下线的原因,例如 :
+                //   - TIM.TYPES.KICKED_OUT_MULT_ACCOUNT 多实例登录被踢
+                //   - TIM.TYPES.KICKED_OUT_MULT_DEVICE 多终端登录被踢
+                //   - TIM.TYPES.KICKED_OUT_USERSIG_EXPIRED 签名过期被踢(v2.4.0起支持)。
+            });
+
+            // eslint-disable-next-line no-unused-vars
+            tim.on(TIM.EVENT.NET_STATE_CHANGE, function(event) {
+                // 网络状态发生改变(v2.5.0 起支持)。
+                // event.name - TIM.EVENT.NET_STATE_CHANGE
+                // event.data.state 当前网络状态,枚举值及说明如下:
+                //   - TIM.TYPES.NET_STATE_CONNECTED - 已接入网络
+                //   - TIM.TYPES.NET_STATE_CONNECTING - 连接中。很可能遇到网络抖动,SDK 在重试。接入侧可根据此状态提示“当前网络不稳定”或“连接中”
+                //   - TIM.TYPES.NET_STATE_DISCONNECTED - 未接入网络。接入侧可根据此状态提示“当前网络不可用”。SDK 仍会继续重试,若用户网络恢复,SDK 会自动同步消息
+            });
+
+            // 开始登录
+            tim.login({
+                userID: this.userID.toString(),
+                userSig: this.userSig,
+            });
+
+            if (window.ReactNativeWebView) {
+                window.ReactNativeWebView.postMessage(
+                    `用户${this.userID}登录成功`,
+                );
+            }
+        },
+    },
+};
+</script>
+<style lang="less" scoped></style>