2 Комити c620f24dcf ... effe859dce

Аутор SHA1 Порука Датум
  HuangKai effe859dce 更新移动标识位置,添加毫秒属性 пре 1 недеља
  HuangKai 37b79d5986 通过App构造接收地址,初始化连接到地址 пре 1 недеља

+ 4 - 3
src/model/AccountAuth.js

@@ -5,9 +5,10 @@ import PubSub from 'pubsub-js';
 // const [fooEvents, setFooEvents] = useState([]);
 
 class AccountAuth {
-    constructor(){
-        const URL = '121.42.8.157:19702'
-        this._socket = io(URL, {
+    constructor(url){
+        // const URL = '121.42.8.157:19702'
+        // this._socket = io(URL, {
+        this._socket = io(url, {
             transports: ["websocket", "polling"],
             // path: '',
             autoConnect: true,

+ 16 - 1
src/view/App.js

@@ -8,6 +8,7 @@ import AccountAuth from '../model/AccountAuth';
 import PresetsManager from '../ctrl/PresetsManager';
 import PubSub from 'pubsub-js';
 import VectorDataManager from '../ctrl/VectorDataManager';
+import LocationCard from './common/LocationCard';
 // import request from 'request-promise-native';
 
 
@@ -19,6 +20,7 @@ export default class App {
 	constructor(params) {
 		this.el = params.el
 		this.id = params.id
+		this.url = params.url
 	}
 
 	init() {
@@ -110,7 +112,7 @@ export default class App {
 		// 	this.authWait = setInterval(this._checkAuth.bind(this), 100);
 		// }
 
-		window.editor_user_auth = new AccountAuth();
+		window.editor_user_auth = new AccountAuth(this.url);
 
 		/**
 		 * Event for logging in user
@@ -295,4 +297,17 @@ export default class App {
 			return {};
 		}
 	}
+
+
+	/** * 更新标记位置 * * 
+	 * @param {Object} data - 根据data.type类型,将不同的标记按照data.data移动 * 
+	*/
+	moveMarker(data) {
+	  if (data.type === "card") {
+		let cards = data.data.map(card => {
+			return new LocationCard(card.lat, card.lng, card.loc_time, card.milli_time, card.card_id, card.info, card.src);
+		});
+		PubSub.publish('body.data.update', cards);
+	  }
+	}
 }

+ 4 - 4
src/view/common/LocationCard.js

@@ -6,17 +6,17 @@ export default class LocationCard{
 /** * 定位卡
     * @param {Number} lat - 定位卡纬度 
     * @param {Number} lng - 定位卡经度 
-    * @param {Number} reader_id - 基站ID
+    * @param {String} milli_time - 定位时间戳(毫秒)
     * @param {String} locTime - 定位时间 
     * @param {Number} card_id - 定位卡ID 
     * @param {JSX} info - jsx详细信息 
     * @param {String} src - 标记图标路径
    */
-    constructor(lat, lng, reader_id, locTime, card_id, info, src){
+    constructor(lat, lng, loc_time, milli_time, card_id, info, src){
         this.lat = lat;
         this.lng = lng;
-        this.reader_id = reader_id;
-        this.locTime = locTime;
+        this.milli_time = milli_time;
+        this.loc_time = loc_time;
         this.card = card_id;
         this.src = src ? src : "img/move.png";
         this.info = info;

+ 1 - 1
src/view/common/MoveableMarker.js

@@ -23,7 +23,7 @@ class MoveableMarker extends Component{
                 iconUrl: window.EDITOR_URL + this.props.data.src,
                 iconSize: [20,20],
                 iconAnchor: [10,10]
-            })} name={`${this.props.data.reader_name}-${this.props.data.reader_id}`} key={this.props.key}>
+            })} name={`${this.props.data.card}`} key={this.props.key}>
                 {this.props.data.info &&
                     <Tooltip>
                         { this.createInfo(this.props.data.info) }

+ 0 - 19
src/view/utils/moveMarker.js

@@ -1,19 +0,0 @@
-import React from 'react';
-import PubSub from 'pubsub-js';
-import LocationCard from '../common/LocationCard';
-
-
-/** * 更新标记位置 * * 
- * @param {Object} data - 根据data.type类型,将不同的标记按照data.data移动 * 
-*/
-export default function updateMarkerPos(data) {
-  if (data.type === "card") {
-    // let cards = data.data.map(card => {
-    //   return new LocationCard(...card);
-    // });
-    let cards = data.data.map(card => {
-      return new LocationCard(card.lat, card.lng, card.render_id, card.locTime, card.card_id, card.info, card.src);
-    });
-    PubSub.publish('body.data.update', cards);
-  }
-}

+ 0 - 18
src/view/utils/uploadMapdata.js

@@ -1,18 +0,0 @@
-import PubSub from 'pubsub-js';
-
-/** * 加载地图文件 * * 
- * @param {String} url - 地图文件路径 * 
-*/
-export default function uploadMapData(url) {   
-    fetch("./map/map.json")
-        .then(res => res.text())
-        .then(data => {
-            // 处理获取的数据
-            let json = JSON.parse(data);
-            PubSub.publish("body.draw.loaded", json);
-        })
-        .catch(error => {
-            // 处理错误
-            console.error('There was a problem with the fetch operation:', error);
-        });
-}