فهرست منبع

隐藏百度地图调用功能

ellisran 7 ماه پیش
والد
کامیت
d5022ba833
3فایلهای تغییر یافته به همراه1489 افزوده شده و 1621 حذف شده
  1. 21 21
      app/controller/tender_controller.js
  2. 3 136
      app/view/tender/detail.ejs
  3. 1465 1464
      app/view/tender/detail_modal.ejs

+ 21 - 21
app/controller/tender_controller.js

@@ -557,26 +557,26 @@ module.exports = app => {
                 ];
                 // 地图
                 const tenderALLInfo = await ctx.service.tender.getDataById(tender.id);
-                const hadMap = tenderALLInfo.had_map === 0 ? 1 : tenderALLInfo.had_map;// 0为初始值,因为默认可能会变化,所以暂时把0都默认为1。共三种模式坐标模式1,图片模式2,无图模式3。
-                const tenderMapList = await ctx.service.tenderMap.getAllDataByCondition({ where: { tid: tender.id } });
+                const hadMap = tenderALLInfo.had_map === 0 ? 3 : tenderALLInfo.had_map;// 0为初始值,因为默认可能会变化,所以暂时把0都默认为1。共三种模式坐标模式1,图片模式2,无图模式3。
+                // const tenderMapList = await ctx.service.tenderMap.getAllDataByCondition({ where: { tid: tender.id } });
                 // 默认坐标,否则则取办事处坐标
-                const projectData = await ctx.service.project.getDataById(ctx.session.sessionProject.id);
-                let map_json = {
-                    province: mapConst.map[0].province,
-                    lng: mapConst.map[0].lng,
-                    lat: mapConst.map[0].lat,
-                    level: 15,
-                };
-                if (projectData.map_json) {
-                    map_json = JSON.parse(projectData.map_json);
-                } else {
-                    const mapInfo = ctx.helper._.find(mapConst.map, { office: projectData.manager_office });
-                    if (mapInfo) {
-                        map_json.province = mapInfo.province;
-                        map_json.lng = mapInfo.lng;
-                        map_json.lat = mapInfo.lat;
-                    }
-                }
+                // const projectData = await ctx.service.project.getDataById(ctx.session.sessionProject.id);
+                // let map_json = {
+                //     province: mapConst.map[0].province,
+                //     lng: mapConst.map[0].lng,
+                //     lat: mapConst.map[0].lat,
+                //     level: 15,
+                // };
+                // if (projectData.map_json) {
+                //     map_json = JSON.parse(projectData.map_json);
+                // } else {
+                //     const mapInfo = ctx.helper._.find(mapConst.map, { office: projectData.manager_office });
+                //     if (mapInfo) {
+                //         map_json.province = mapInfo.province;
+                //         map_json.lng = mapInfo.lng;
+                //         map_json.lat = mapInfo.lat;
+                //     }
+                // }
                 const canFinish = await this.ctx.service.tender.checkTenderCanFinish(tender);
 
                 const projectSpread = await ctx.service.projectSpread.getProjectSpreadType(tender.project_id);
@@ -605,8 +605,8 @@ module.exports = app => {
                     map_pic: tenderALLInfo.map_pic,
                     jsFiles: this.app.jsFiles.common.concat(this.app.jsFiles.tender.tenderInfo),
                     gclChapter,
-                    tenderMapList,
-                    map_json,
+                    // tenderMapList,
+                    // map_json,
                     fujianOssPath: ctx.app.config.fujianOssPath,
                     canFinish,
                     buildStatus: tenderConst.buildStatus,

+ 3 - 136
app/view/tender/detail.ejs

@@ -221,9 +221,7 @@
                             <!--章节计量情况图-->
                             <div class="col-6 pl-0">
                                 <div class="card mb-3 <% if (!ctx.tender.info.display.dayMode) { %>bg-dark text-white<% } %>">
-                                    <% if (hadMap === 1) { %>
-                                        <div class="card-body" id="map" style="height: 388px; width: 100%;"></div>
-                                    <% } else if (hadMap === 2) { %>
+                                    <% if (hadMap === 2) { %>
                                         <div style="position:relative;height: 388px; width: 100%;">
                                             <% if (map_pic) { %>
                                             <% if (!ctx.tender.info.display.dayMode) { %>
@@ -395,7 +393,7 @@
                             <!--期进度表-->
                             <div class="col-6">
                                 <div class="card mb-3 <% if (!ctx.tender.info.display.dayMode) { %>bg-dark text-white<% } %> bottom-height">
-                                    <% if (hadMap === 1 || hadMap === 2) { %>
+                                    <% if (hadMap === 2) { %>
                                         <div class="card-header"><h6 class="mb-0">章节计量情况表</h6></div>
                                         <div class="card-body">
                                             <div id="jlchart3" style="height: 300px; width: 100%;"></div>
@@ -411,7 +409,7 @@
                             <!--月进度表-->
                             <div class="col-6 pl-0">
                                 <div class="card mb-3 bottom-height <% if (!ctx.tender.info.display.dayMode) { %>bg-dark text-white<% } %>">
-                                    <% if (hadMap === 1 || hadMap === 2) { %>
+                                    <% if (hadMap === 2) { %>
                                         <div class="card-header">
                                             <ul class="nav nav-tabs card-header-tabs panel-card-tabs <% if (ctx.tender.info.display.dayMode) { %>nav-white-tabs<% } %>" id="change-echarts">
                                                 <li class="nav-item">
@@ -1501,134 +1499,3 @@
         };
     })
 </script>
-<% if (hadMap === 1 || ctx.session.sessionUser.is_admin) { %>
-    <script src="/public/js/map/turf.min.js"></script>
-    <script src="/public/js/map/gcoord.js"></script>
-    <script>
-        const tenderMapList = JSON.parse(unescape('<%- escape(JSON.stringify(tenderMapList)) %>'));
-    </script>
-<% } %>
-<% if (hadMap === 1) { %>
-    <!--<script src="//bj.bcebos.com/v1/mapopen/api-demos/js/mapStyle.js"></script>-->
-    <script type="text/javascript" src="https://api.map.baidu.com/api?v=1.0&type=webgl&ak=C3hLZAjuWTaCdwnwoYY83APrwlPEj4v7"></script>
-    <script type="text/javascript">
-        // 画线
-        $(function () {
-            const map = new BMapGL.Map("map");
-            // 创建地图实例
-
-            const polyLineList = [];
-            const centerPoint = { lng: <%- map_json.lng %>, lat: <%- map_json.lat %> };
-            let level = <%- map_json.level %>;
-            const pointList = [];
-            const centerList = [];
-            for (const tm of tenderMapList) {
-                if (tm.map_json) {
-                    const map_json = JSON.parse(unescape(escape(tm.map_json)));
-                    const lngLatList = [];
-                    for (const mj of map_json) {
-                        const result = gcoord.transform([mj.lng, mj.lat], gcoord.WGS84, gcoord.BD09);
-                        lngLatList.push(new BMapGL.Point(result[0], result[1]));
-                    }
-                    polyLineList.push({
-                        map: lngLatList,
-                        color: tm.color,
-                    });
-                    const center = JSON.parse(tm.center);
-                    pointList.push(turf.point([center.lng, center.lat]));
-                    if (tm.tips) {
-                        const centerResult = gcoord.transform([map_json[Math.floor(map_json.length/2)].lng, map_json[Math.floor(map_json.length/2)].lat], gcoord.WGS84, gcoord.BD09);
-                        centerList.push({ map: new BMapGL.Point(centerResult[0], centerResult[1]), color: tm.color, tips: tm.tips });
-                    }
-                }
-            }
-            if (pointList.length > 0) {
-                let maxDistance = 0;
-                // 中心点计算
-                const features = turf.featureCollection(pointList);
-                const center = turf.center(features);
-                if (center && center.geometry && center.geometry.coordinates && center.geometry.coordinates.length === 2) {
-                    centerPoint.lng = _.round(center.geometry.coordinates[0], 4);
-                    centerPoint.lat = _.round(center.geometry.coordinates[1], 4);
-                }
-                // 地图级别计算
-                if (pointList.length === 1) {
-                    // 只有一条路线
-                    const map_json = JSON.parse(unescape(escape(tenderMapList[0].map_json)));
-                    for (const mj of map_json) {
-                        const distance = turf.distance(turf.point([mj.lng, mj.lat]), turf.point([centerPoint.lng, centerPoint.lat]));
-                        if (distance > maxDistance) {
-                            maxDistance = distance;
-                        }
-                    }
-                } else {
-                    for (const c of pointList) {
-                        const distance = turf.distance(c, turf.point([centerPoint.lng, centerPoint.lat]));
-                        if (distance > maxDistance) {
-                            maxDistance = distance;
-                        }
-                    }
-                }
-                if (maxDistance === 0) {
-                    level = 15;
-                } else {
-                    // 级别区间
-                    // const range = [0.02, 0.05, 0.1, 0.2, 0.5, 1, 2, 5, 10, 20, 25, 50, 100, 200, 500, 1000, 2000, 5000, 10000];
-                    const range = [10000, 5000, 2000, 1000, 500, 200, 100, 50, 25, 20, 10, 5, 2, 1, 0.5, 0.2, 0.1, 0.05, 0.02];
-                    level = _.findIndex(range, function (item) {
-                        return item <= maxDistance;
-                    })
-                    level = level + 1;
-                }
-                const result = gcoord.transform([centerPoint.lng, centerPoint.lat], gcoord.WGS84, gcoord.BD09);
-                centerPoint.lng = result[0];
-                centerPoint.lat = result[1];
-
-            }
-            // 初始化地图,设置中心点坐标和地图级别
-            const point = new BMapGL.Point(centerPoint.lng, centerPoint.lat);
-            map.centerAndZoom(point, level);
-            // const LocationControl = new BMapGL.LocationControl();  // 添加比例尺控件
-            // map.addControl(LocationControl);
-            map.enableScrollWheelZoom(true);
-            <% if (!ctx.tender.info.display.dayMode) { %>
-            map.setMapStyleV2({styleId: '20d4aea41cf71387395f2dc835f1c4b6'});
-            <% } %>
-            if (polyLineList.length > 0) {
-                for (const pl of polyLineList) {
-                    const polyline = new BMapGL.Polyline(pl.map, {strokeColor: pl.color, strokeWeight:10, strokeOpacity:1});
-                    map.addOverlay(polyline);
-                }
-            }
-            if (centerList.length > 0) {
-                for (const cl of centerList) {
-                    const opts = {
-                        position : cl.map,    // 指定文本标注所在的地理位置
-                        offset   : new BMapGL.Size(5, 0)    //设置文本偏移量
-                    }
-                    const label = new BMapGL.Label(cl.tips, opts);  // 创建文本标注对象
-                    label.setStyle({
-                        height: '18px',
-                        lineHeight : '18px',
-                        color : cl.color,
-                        borderRadius: '5px',
-                        borderColor: cl.color,
-                        padding: '0px 5px',
-                        fontSize : '12px',
-                        // fontFamily: '微软雅黑',
-                    });
-                    map.addOverlay(label);
-                    // const opts = {
-                    //     width: 0,
-                    //     height: 0,
-                    //     maxwidth: 220,
-                    //     title: '路线标注:',
-                    // };
-                    // const infoWindow = new BMapGL.InfoWindow(cl.tips, opts);
-                    // map.openInfoWindow(infoWindow, cl.map);
-                }
-            }
-        })
-
-    </script>
-<% } %>

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 1465 - 1464
app/view/tender/detail_modal.ejs