123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894 |
- /**
- * [ONEMAP.M.mod]
- * @return {[object]}
- */
- define([
- 'html!templates/user/userSideBar',
- 'css!styles/user/userSideBar',
- 'modDir/picture',
- ],
- function (tplLayout) {
- /**
- * 模块数据 用于数据存储和外部调用
- * @type {Object}
- * 数据存放
- */
- var modValue = {
- subModName: null,
- getHeatmapTime: 'all',
- getTileHeatmapTime: 'all',
- cfg: {
- "radius": 2,
- "maxOpacity": 0.8,
- "scaleRadius": true,
- "useLocalExtrema": true,
- latField: 'lat',
- lngField: 'lng',
- valueField: 'count'
- },
- heatData: null,
- userInfoStatu: 1,
- userHeatmapMarkerGroup: null,
- appendToMyLayer: null,
- heatmapMarkerOpacity: 1,
- heatmapType: 0,
- IDCardPicture1: "",
- IDCardPicture2: "",
- _uploadTempDir: "",
- }
- /**
- * 模块界面样式 例如:宽,高
- * @type {Object}
- */
- var styles = {}
- /**
- * 模块状态,用于存储模块的状态 例如:收起,关闭
- * @type {Object}
- */
- var status = {
- initialized: false
- }
- /**
- * 初始化并订阅事件
- * @return {[type]} [description]
- */
- function init(modName) {
- //未初始化,初始化布局
- if (!status.initialized) {
- //设置容器布局
- setLayout();
- bindEvent();
- //订阅推送
- subscribe();
- status.initialized = true;
- } else {
- $('#userSideBar').show();
- }
- //设置zIndex 为最高
- var zIndex = ONEMAP.M.sideBar.getZIndex();
- $('#userSideBar').css({
- zIndex: 111111
- });
- }
- /**
- * 初始化布局
- */
- function setLayout() {
- $(tplLayout).appendTo($("#wrapper"));
- uinfoInit()
- //$("#userSideBar .username").html("用户名称:" + ONEMAP.D.user.name);
- $("#userSideBar .lgtime").html("登录时间:" + ONEMAP.D.user.current_login_at);
- $("#userSideBar .usdLeft li").removeClass("active");
- $("#userSideBar .usdLeft li.uInfo").addClass("active");
- $("#userSideBar .usdTab li").removeClass("active");
- $("#userSideBar .usdTab li.uInfo").addClass("active");
- //用户分类
- $("#userSideBar .usdLeft li.mng").hide();
- if (!ONEMAP.D.user.name) {
- ONEMAP.D.user.name = $("#userContent .username").text();
- }
- //用户中心显隐
- var role_list = ONEMAP.D.user.roles;
- $.each(role_list, function (i, t) {
- switch (t) {
- case "gcms chief editor":
- case "gcms adv editor":
- case "gcms editor":
- $("#userSideBar .usdLeft").show();//gcms
- break;
- case "admin":
- $("#userSideBar .usdLeft li.mng.tjUser").show();//数字战场访问统计系统
- $("#userSideBar .usdLeft li.mng.registeredheatmap").show();//热力图
- $("#userSideBar .usdLeft li.mng.qxUser").show();//全息地图数据管理系统
- $("#userSideBar .usdLeft li.mng.tyUser").show();//用户管理系统
- break;
- case "hmdms admin":
- $("#userSideBar .usdLeft li.mng.qxUser").show();//全息地图数据管理系统
- break;
- case "sys admin":
- case "security admin":
- $("#userSideBar .usdLeft li.mng.tyUser").show();//用户管理系统
- break;
- }
- })
- if (ONEMAP.D.user.roles.indexOf('developer') == -1) {
- $("#userSideBar .usdLeft li.mng.developerAuthentication").show();
- resetDeveloperAuthentication()
- } else {
- $("#userSideBar .usdLeft li.mng.developerAuthentication").hide();
- }
- //拖拽
- $("#userSideBar .popup-ct").dragmove($('#userSideBar'));
- };
- /**
- * 窗口布局重置
- * @type {Function}
- */
- function layoutResize() {
- };
- //获取authorization及用户列表
- function getAuthorization() {
- $.ajax({
- url: onemapUrlConfig.oauthServiceUrl + '/v1.0/account/auth',
- type: 'POST',
- dataType: 'json',
- data: JSON.stringify({
- email: ONEMAP.D.user.email,
- password: modValue.password
- }),
- headers: {
- "Accept": "application/json",
- "Content-type": "application/json"
- }
- })
- .done(function (data) {
- // console.log(data);
- modValue.Authorization = data.access_token;
- modValue.azType = data.token_type;
- // $.ajax({
- // url: onemapUrlConfig.oauthServiceUrl + '/v1.0/user/list',
- // type: 'GET',
- // dataType: 'json',
- // headers: {
- // "Authorization": modValue.azType + " " + modValue.Authorization
- // }
- // })
- // .done(function (data) {
- // modValue.listdata = data.data;
- // })
- })
- }
- //修改用户信息
- function putUserInfo(putdata) {
- $.ajax({
- url: onemapUrlConfig.oauthServiceUrl + '/v1.0/user?id=' + ONEMAP.D.user.id,
- type: 'PUT',
- dataType: 'json',
- data: putdata,
- headers: {
- "Authorization": modValue.azType + " " + modValue.Authorization
- }
- })
- .done(function (data) {
- if (data.status == 0) {
- ONEMAP.C.publisher.publish({
- type: 'success',
- message: '修改成功'
- }, 'noteBar::add');
- }
- uinfoInit(modValue.userInfoStatu);
- if (status.refresh) {
- alert("修改用户名/邮箱成功!即将刷新");
- ONEMAP.C.logout();
- window.location.reload();
- }
- })
- .fail(function (data) {
- console.log(data);
- data = JSON.parse(data.responseText);
- var alertInfos = "";
- $.each(data.errors, function (i, t) {
- alertInfos = alertInfos + i + ":";
- $.each(t, function (index, item) {
- alertInfos = alertInfos + item + ";"
- })
- })
- ONEMAP.C.publisher.publish({
- type: 'error',
- message: alertInfos
- }, 'noteBar::add');
- })
- }
- //属性赋值
- function shuxingfuzhi(a, b) {
- if (b == "" || b == null) {
- a.val("")
- } else {
- a.attr("value", b);
- a.val(b)
- }
- }
- //用户信息初始化
- function uinfoInit(uStatu) {
- $.ajax({
- url: onemapUrlConfig.oauthServiceUrl + '/v1.0/user?id=' + ONEMAP.D.user.id,
- type: 'GET',
- dataType: 'json'
- })
- .done(function (data) {
- _.merge(ONEMAP.D.user, data.data);
- // var name = data.data.nickname ? data.data.nickname : data.data.username
- shuxingfuzhi($("#userSideBar .baseInfList li.username input"), data.data.username)
- shuxingfuzhi($("#userSideBar .baseInfList li.nickname input"), data.data.nickname)
- shuxingfuzhi($("#userSideBar .baseInfList li.email input"), ONEMAP.D.user.email);
- shuxingfuzhi($("#userSideBar .baseInfList li.real_name input"), ONEMAP.D.user.real_name);
- shuxingfuzhi($("#userSideBar .baseInfList li.address input"), ONEMAP.D.user.address);
- shuxingfuzhi($("#userSideBar .baseInfList li.mobile input"), ONEMAP.D.user.mobile);
- $("#userContent .lgtop .username").html(data.data.nickname || data.data.username)
- if (ONEMAP.D.user.roles.indexOf('developer') == -1) {
- $("#userSideBar .baseInfList li.developer b").text("否");
- } else {
- $("#userSideBar .baseInfList li.developer b").text("是");
- }
- // //获取用户密码
- // $.ajax({
- // url: onemapUrlConfig.oauthServiceUrl + '/v1.0/user/resource_sharing_api?id=' + ONEMAP.D.user.id,
- // type: 'GET',
- // dataType: 'json'
- // })
- // .done(function (data) {
- // modValue.password = data.data.password;
- // getAuthorization()
- // })
- })
- $("#userSideBar .baseInfList li.org_name b").text(ONEMAP.D.user.org_name);
- $("#userSideBar .baseInfList li input").removeClass('edit');
- $("#userSideBar .usdTab .tipInfo").removeClass('active');
- $("#userSideBar .baseInfList li input").attr('readonly', 'readonly');
- $("#userSideBar .passchange li input").attr("value", "");
- $("#userSideBar .passchange li input").val("")
- if (uStatu == 1) {
- $("#userSideBar .usdTab .editInf").removeClass('hd');
- $("#userSideBar .usdTab .btns").removeClass('active');
- }
- }
- function compareData(putData, count, msg) {
- var ld = modValue.listdata;
- var a = 0,
- b = 0;
- var cd = "ok";
- for (var i = 0; i < ld.length; i++) {
- if (putData.username == ld[i].username) {
- a++;
- } else if (putData.email == ld[i].email) {
- b++;
- }
- if ((a + b) > (2 - count)) {
- if (a > 0 && msg == "username") cd = "用户名重复";
- if (b > 0 && msg == "email") cd = "邮箱重复";
- if (a > 0 && b > 0 && msg == "all") cd = "用户名、邮箱重复";
- break;
- }
- }
- return cd;
- }
- /**
- * 界面事件绑定
- * @return {[type]} [description]
- */
- function bindEvent() {
- //编辑用户信息
- $("#userSideBar .usdTab h1.tab span").off("click").on("click", function () {
- $("#userSideBar .usdTab h1.tab span").removeClass('active')
- $("#userSideBar .usdTab li.uInfo ul,#userSideBar .usdTab .editInf").removeClass('hd');
- $(this).addClass('active')
- if (!$(this).hasClass('baseInf')) {
- $("#userSideBar .baseInfList,#userSideBar .usdTab .editInf").addClass('hd')
- $("#userSideBar .usdTab .btns").addClass('active');
- modValue.userInfoStatu = 2;
- } else {
- $("#userSideBar .passchange").addClass('hd')
- $("#userSideBar .usdTab .btns").removeClass('active');
- modValue.userInfoStatu = 1;
- }
- uinfoInit();
- })
- $("#userSideBar .usdTab .editInf").off("click").on("click", function () {
- $(this).addClass('hd');
- $("#userSideBar .usdTab .btns").addClass('active');
- $("#userSideBar .baseInfList li input").addClass('edit');
- $("#userSideBar .baseInfList li input").removeAttr('readonly');
- $("#userSideBar .baseInfList li.username input").attr('readonly', 'readonly');
- $("#userSideBar .baseInfList li.username input").removeClass('edit');
- $("#userSideBar .baseInfList li.mobile input").attr('readonly', 'readonly');
- $("#userSideBar .baseInfList li.mobile input").removeClass('edit');
- $("#userSideBar .baseInfList li.developer").hide()
- })
- $("#userSideBar .usdTab .btns button.cancel").off("click").on("click", function () {
- uinfoInit(modValue.userInfoStatu);
- $("#userSideBar .baseInfList li.developer").show()
- })
- $("#userSideBar .baseInfList li input").on("focus", function () {
- $("#userSideBar .usdTab .tipInfo").removeClass('active');
- $("#userSideBar .usdTab .tipInfo span").text("")
- })
- $("#userSideBar .usdTab .btns button.submit").off("click").on("click", function () {
- if (modValue.userInfoStatu == 1) {
- var putData = {}
- //putData.username = $("#userSideBar .baseInfList li.username input").val();
- putData.username = ONEMAP.D.user.username;
- putData.nickname = $("#userSideBar .baseInfList li.nickname input").val();;
- putData.email = $("#userSideBar .baseInfList li.email input").val();
- putData.real_name = $("#userSideBar .baseInfList li.real_name input").val();
- putData.address = $("#userSideBar .baseInfList li.address input").val();
- putData.mobile = $("#userSideBar .baseInfList li.mobile input").val();
- var count = 0,
- msg = "";
- if (putData.username != ONEMAP.D.user.username || putData.email != ONEMAP.D.user.email) {
- if (putData.username != ONEMAP.D.user.username) {
- count++;
- msg = "username";
- }
- if (putData.email != ONEMAP.D.user.email) {
- count++;
- msg = "email";
- }
- if ((putData.email != ONEMAP.D.user.email) && (putData.username != ONEMAP.D.user.username)) {
- count++;
- msg = "all";
- }
- //var yz = compareData(putData, count, msg);
- var yz = "ok";
- if (yz == "ok") {
- putUserInfo(putData);
- status.refresh = true;
- } else {
- $("#userSideBar .usdTab .tipInfo").addClass('active');
- $("#userSideBar .usdTab .tipInfo span").text(yz)
- }
- } else {
- putUserInfo(putData);
- }
- } else {
- var oldPass = $("#userSideBar .passchange li input.oldPass").val();
- var newPass1 = $("#userSideBar .passchange li input.newPass1").val();
- var newPass2 = $("#userSideBar .passchange li input.newPass2").val();
- if (oldPass != modValue.password) {
- if (!$(".tipInfo").hasClass('active')) {
- $(".tipInfo").addClass('active');
- }
- $(".tipInfo span").text("原密码认证失败");
- } else if (newPass1 == "" || newPass2 == "") {
- if (!$(".tipInfo").hasClass('active')) {
- $(".tipInfo").addClass('active');
- }
- $(".tipInfo span").text("请输入新密码");
- } else if (newPass2 != newPass1) {
- if (!$(".tipInfo").hasClass('active')) {
- $(".tipInfo").addClass('active');
- }
- $(".tipInfo span").text("您输入的新密码不一致");
- } else {
- $(".tipInfo").removeClass('active');
- var pdata = {};
- pdata.password = newPass1;
- putUserInfo(pdata)
- }
- }
- })
- $("#userSideBar .passchange li input").on("change", function () {
- $(".tipInfo").removeClass('active');
- })
- //用户中心列表点击
- $("#userSideBar .usdLeft li").bind("click", function () {
- $("#userSideBar .usdLeft li").removeClass("active");
- $(this).addClass("active");
- $("#userSideBar .usdTab li").removeClass("active");
- var mid = $(this).attr("mid");
- if (mid == "uInfo") {
- $("#userSideBar .usdTab li.uInfo").addClass("active");
- } else if (mid == "uFavo") {
- $("#userSideBar .usdTab li.uFavo").addClass("active");
- } else if (mid == "uSet") {
- $("#userSideBar .usdTab li.uSet").addClass("active");
- require(['modDir/user/userSetting'], function (userSetting) {
- userSetting.init();
- });
- } else if (mid == "szzcUser") {
- $("#userSideBar .usdTab li.szzcUser").addClass("active");
- window.open(onemapUrlConfig.szzcUser);
- } else if (mid == "tyUser") {
- $("#userSideBar .usdTab li.tyUser").addClass("active");
- window.open(onemapUrlConfig.tyUser);
- } else if (mid == "qxUser") {
- $("#userSideBar .usdTab li.qxUser").addClass("active");
- window.open(onemapUrlConfig.qxUser);
- } else if (mid == "rzUser") {
- // $("#userSideBar .usdTab li.rzUser").addClass("active");
- // window.open(onemapUrlConfig.rzUser);
- } else if (mid == "tjUser") {
- $("#userSideBar .usdTab li.tjUser").addClass("active");
- window.open(onemapUrlConfig.tjUser);
- } else if (mid == "registeredheatmap") {
- $("#userSideBar .usdTab li.usigup").addClass("active");
- //getHeatmapData();
- } else if (mid == "developerAuthentication") {
- $("#userSideBar .usdTab li.uDeveloperAuth").addClass("active");
- resetDeveloperAuthentication()
- }
- })
- $("#uSigup .time_content input").bind('click', function () {
- var mid = $(this).attr('mid');
- var cid = $(this).attr('cid');
- $("#uSigup .time_content .active").removeClass('active');
- $(this).addClass('active');
- modValue.getHeatmapTime = mid;
- if (cid == 'tile') {
- getTileHeatmapData();
- } else {
- getHeatmapData();
- }
- })
- //在用户中心中展示我的收藏
- $("#userSideBar .usdLeft .uFavo").bind("click", function () {
- var options = {
- // modName: 'userFav',
- modName: 'userRoute',
- appdDom: 'userSideBar'
- }
- require(['modDir/user/userCenter'], function (userCenter) {
- userCenter.init(options);
- });
- ONEMAP.C.publisher.publish(options, 'showCenter');
- })
- //关闭用户中心
- $("#userSideBar .close").bind("click", function () {
- $("#userSideBar").hide();
- })
- //开发者用户认证
- $('.uDeveloperAuth .attestation').bind('click', function () {
- $('.authStep .step2').addClass('nowStep')
- $('.authStepContent>div').removeClass('nowStep')
- $('.authStepContent .step2').addClass('nowStep')
- if ($(this).hasClass('person')) {
- //个人 进入第二步
- $('.authStepContent .step2 .person').show();
- $('.authStepContent .step2 .enterprise').hide();
- } else {
- //企业 进入第二步
- $('.authStepContent .step2 .person').hide();
- $('.authStepContent .step2 .enterprise').show();
- }
- })
- $('.authStepContent .step2 .prev').bind("click", function () {
- resetDeveloperAuthentication()
- })
- $('.authStepContent .step2 .next').bind("click", function () {
- var ajaxData = {
- gcms_title: ONEMAP.D.user.username,
- name: $('.developerName').val(),
- IDCard: $('.IDNumber').val(),
- portrait: modValue.IDCardPicture1.getValue(),
- emblem: modValue.IDCardPicture2.getValue()
- }
- if (ajaxData.name.replace(/ /g, "") == "") {
- ONEMAP.C.publisher.publish({
- type: 'error',
- message: '姓名不能为空!'
- }, 'noteBar::add');
- return
- }
- if (ajaxData.IDCard.replace(/ /g, "") == "") {
- ONEMAP.C.publisher.publish({
- type: 'error',
- message: '身份证号不能为空!'
- }, 'noteBar::add');
- return
- }
- if (ajaxData.portrait == "") {
- ONEMAP.C.publisher.publish({
- type: 'error',
- message: '身份证人像面未上传!'
- }, 'noteBar::add');
- return
- }
- if (ajaxData.emblem == "") {
- ONEMAP.C.publisher.publish({
- type: 'error',
- message: '身份证国徽面未上传!'
- }, 'noteBar::add');
- return
- }
- var ajaxUrl = onemapUrlConfigNetwork.gcmsServiceUrl + '/content/developer_renzhen?uploadpath=' + modValue._uploadTempDir;
- $.ajax({
- url: ajaxUrl,
- type: 'POST',
- dataType: 'json',
- data: ajaxData
- })
- .done(function (data) {
- if (data.code == 4) {
- ONEMAP.C.noPermission('addArticle', '无权限添加内容');
- }
- if (data.code == 3) {
- ONEMAP.C.logout('addArticle');
- }
- if (data.code == 0) {
- ONEMAP.C.publisher.publish({ type: 'success', message: '上传认证成功!' }, 'noteBar::add');
- $('.authStep .step3').addClass('nowStep')
- $('.authStepContent>div').removeClass('nowStep')
- $('.authStepContent .step3').addClass('nowStep')
- $('.uploadBackMessage').html('上传认证成功,等待人工审核。5s后自动返回')
- setTimeout(function () {
- if ($('.authStep .step3').hasClass('nowStep')) {
- resetDeveloperAuthentication()
- }
- }, 5000);
- } else {
- ONEMAP.C.publisher.publish({ type: 'error', message: data['message'] }, 'noteBar::add');
- $('.uploadBackMessage').html('上传认证失败,返回重新填写。5s后自动返回')
- setTimeout(function () {
- if ($('.authStep .step3').hasClass('nowStep')) {
- resetDeveloperAuthentication()
- }
- }, 5000);
- }
- })
- .fail(function () {
- ONEMAP.C.publisher.publish({ type: 'error', message: '上传认证失败!' }, 'noteBar::add');
- $('.uploadBackMessage').html('上传认证失败,返回重新填写。5s后自动返回')
- setTimeout(function () {
- if ($('.authStep .step3').hasClass('nowStep')) {
- resetDeveloperAuthentication()
- }
- }, 5000);
- });
- })
- $('.authStepContent .step3 .back').bind("click", function () {
- resetDeveloperAuthentication()
- })
- }
- /**
- * [getTileHeatmapData description]
- * 获取用户访问瓦片统计热力图数据
- * @return {[type]} [description]
- */
- function getTileHeatmapData() {
- ONEMAP.V.loading.load();
- $.ajax({
- type: "get",
- dataType: 'json',
- url: onemapUrlConfig.getTileHeatmapUrl + "/api/heatmap/" + modValue.getHeatmapTime,
- success: function (data) {
- if ($("#layerControlMenu .myLayers span[title='瓦片访问热力图']").length != 0)
- $($("#layerControlMenu .myLayers span[title='瓦片访问热力图']").siblings(".close")[0]).click()
- if ($("#layerControlMenu .myLayers span[title='用户独立访问热力图']").length != 0)
- $($("#layerControlMenu .myLayers span[title='用户独立访问热力图']").siblings(".close")[0]).click()
- addHeatmapTip('瓦片访问热力图');
- modValue.heatmapType = 2;
- data = eval("(" + data.data + ")").aggregations.level8bucket.buckets;
- var newHeatData = [];
- $.each(data, function (i, t) {
- var latlng = t.hits.hits.hits[0]._source;
- newHeatData.push({
- lat: latlng.lat,
- lng: latlng.lng,
- count: t.doc_count
- })
- })
- modValue.heatData = {
- max: 8,
- data: newHeatData
- }
- if (modValue.appendToMyLayer == null) {
- var options = {
- action: "add",
- mod: 'userheatmap',
- DOM: {
- name: '瓦片访问热力图',
- type: "group",
- guid: 'userheatmap'
- }
- }
- modValue.appendToMyLayer = ONEMAP.M.myLayers.myLayerControl(options);
- ONEMAP.C.publisher.subscribe(controlMyLayer, modValue.appendToMyLayer);
- }
- modValue.cfg["gradient"] = {
- 0.25: "rgb(0,0,255)",
- 0.55: "rgb(0,255,0)",
- 0.85: "rgb(255,255,0)",
- 1.0: "rgb(255,0,0)"
- }
- modValue.hotLayer = new HeatmapOverlay(modValue.cfg);
- modValue.hotLayer.addTo(map2DViewer.map);
- modValue.hotLayer.setData(modValue.heatData);
- map23DControl.setView({
- center: {
- lat: 39,
- lng: 116
- },
- zoom: 4
- })
- },
- error: function (errorData) {
- ONEMAP.V.loading.loaded();
- }
- });
- }
- /**
- * [getHeatmapData description]
- * 获取热力图数据
- * @return {[type]} [description]
- */
- function getHeatmapData() {
- ONEMAP.V.loading.load();
- $.ajax({
- type: "get",
- dataType: 'json',
- url: onemapUrlConfig.getUserHeatmapUrl + "/heatmap/" + modValue.getHeatmapTime,
- success: function (data) {
- if ($("#layerControlMenu .myLayers span[title='瓦片访问热力图']").length != 0)
- $($("#layerControlMenu .myLayers span[title='瓦片访问热力图']").siblings(".close")[0]).click()
- if ($("#layerControlMenu .myLayers span[title='用户独立访问热力图']").length != 0)
- $($("#layerControlMenu .myLayers span[title='用户独立访问热力图']").siblings(".close")[0]).click()
- addHeatmapTip('用户独立访问热力图');
- modValue.heatmapType = 1;
- if (modValue.appendToMyLayer == null) {
- var options = {
- action: "add",
- mod: 'userheatmap',
- DOM: {
- name: '用户独立访问热力图',
- type: "group",
- guid: 'userheatmap'
- }
- }
- modValue.appendToMyLayer = ONEMAP.M.myLayers.myLayerControl(options);
- ONEMAP.C.publisher.subscribe(controlMyLayer, modValue.appendToMyLayer);
- }
- var newHeatData = [];
- modValue.GroupLayerGuid = map23DControl.group({
- action: 'add',
- clustering: false //关键 开启聚合
- })
- $.each(data, function (i, t) {
- for (var k = 0; k < t.count; k++) {
- newHeatData.push({
- lat: t.lat,
- lng: t.lon,
- })
- }
- var markerOp = {
- action: "add",
- groupId: modValue.GroupLayerGuid,
- geojson: {
- "type": "Feature",
- "properties": {
- iconUrl: '../../../images/layout/marker/roadsign_icon_1_b.png',
- iconSize: [60, 39],
- iconAnchor: [30, 39],
- popupAnchor: [0, -39],
- popupContent: creatPopupHtml(t.count)
- },
- "geometry": {
- "type": "Point",
- "coordinates": [t.lon, t.lat]
- }
- }
- }
- map23DControl.marker(markerOp);
- })
- map2DViewer.map.setZoom(4)
- modValue.hotLayer = L.heatLayer(newHeatData, {
- maxZoom: 7,
- radius: 40,
- blur: 30,
- shadowBlur: 25,
- min: 1,
- max: 25,
- gradient: {
- 0.25: "rgb(0,0,255)",
- 0.55: "rgb(0,255,0)",
- 0.85: "rgb(255,255,0)",
- 1.0: "rgb(255,0,0)"
- }
- });
- modValue.hotLayer.addTo(map2DViewer.map);
- userHeatlayerMarker(map2DViewer.map.getZoom())
- },
- error: function (errorData) {
- ONEMAP.V.loading.loaded();
- }
- });
- }
- function creatPopupHtml(options) {
- var popupHtml = '<div class="popup_html mini">' +
- ' <div class="popup-lt"></div>' +
- ' <div class="popup-lb"></div>' +
- ' <div class="popup-rt"></div>' +
- ' <div class="popup-rb"></div>' +
- ' <div class="popup-ct" style="text-indent:15px;line-height:48px">' +
- ' </div>' +
- ' <div class="popup-cb" style="padding-bottom:20px;color:#666666 !important"><div class="visitCount">访问次数:' + options + '</div></div>' +
- '</div>'
- return popupHtml;
- }
- function userHeatlayerMarker(zoom) {
- if (zoom >= 6) {
- modValue.markerOpacity = 1
- map2DViewer.group({
- action: 'show',
- guid: modValue.GroupLayerGuid
- })
- } else {
- modValue.markerOpacity = 0
- map2DViewer.group({
- action: 'hide',
- guid: modValue.GroupLayerGuid
- })
- }
- if (modValue.heatmapType == 1) {
- var option = {};
- if (zoom <= 5) {
- option.max = 10;
- } else if (zoom > 5 && zoom <= 7) {
- option.max = 50;
- } else if (zoom > 7) {
- option.max = 80;
- }
- modValue.hotLayer.setOptions(option);
- }
- }
- function controlMyLayer(options) {
- switch (options.action) {
- case 'remove':
- remove();
- break;
- case 'opacity':
- setGropOpacity(options);
- break;
- }
- }
- function setGropOpacity(options) {
- options = options.options;
- if (options.opacity == 1) {
- $(".leaflet-heatmap-layer, .heatmap-canvas").show();
- if (modValue.GroupLayerGuid)
- map2DViewer.group({
- action: 'show',
- guid: modValue.GroupLayerGuid
- })
- } else if (options.opacity == 0) {
- $(".leaflet-heatmap-layer, .heatmap-canvas").hide();
- if (modValue.GroupLayerGuid)
- map2DViewer.group({
- action: 'hide',
- guid: modValue.GroupLayerGuid
- })
- }
- }
- function remove() {
- if (modValue.hotLayer) {
- modValue.hotLayer.onRemove(map2DViewer.map);
- }
- if (modValue.GroupLayerGuid) {
- map2DViewer.group({
- action: 'remove',
- guid: modValue.GroupLayerGuid
- })
- }
- if ($('#heatmapTip').length > 0)
- $('#heatmapTip').remove();
- $(".registeredheatmap").removeClass('active');
- $("#uSigup .time_content .active").removeClass('active');
- modValue.GroupLayerGuid = null
- modValue.appendToMyLayer = null;
- modValue.hotLayer = null;
- //取消订阅
- unSubscribe();
- }
- function addHeatmapTip(text) {
- var html = '<div id="heatmapTip">' +
- ' <div class="heatmapTipClose">×</div>' + text + '</div>'
- $('body').append(html);
- $('#heatmapTip .heatmapTipClose').unbind('click').bind("click", function () {
- $(this).parent().remove();
- })
- }
- function resetDeveloperAuthentication() {
- $('.developAuthContent .nowStep').removeClass('nowStep')
- $('.developAuthContent .step1').addClass('nowStep')
- $('.developAuthContent input').val('');
- $('#portrait').empty()
- $('#emblem').empty()
- modValue._uploadTempDir = generateMixed(20);
- var op1 = {
- containId: '#portrait',
- id: "portrait",
- label: "",
- tips: '支持jpg,png,gif格式',
- uploadPath: onemapUrlConfigNetwork.gcmsServiceUrl + '/file/upload/tmp?path=' + modValue._uploadTempDir,
- verifyEmpty: 0
- }
- var op2 = {
- containId: '#emblem',
- id: "emblem",
- label: "",
- tips: '支持jpg,png,gif格式',
- uploadPath: onemapUrlConfigNetwork.gcmsServiceUrl + '/file/upload/tmp?path=' + modValue._uploadTempDir,
- verifyEmpty: 0
- }
- //图片地址
- op1['value'] = ""
- op2['value'] = ""
- modValue.IDCardPicture1 = new ONEMAP.M.field_picture(op1)
- modValue.IDCardPicture2 = new ONEMAP.M.field_picture(op2)
- }
- /** * 获取随机字符串 */
- function generateMixed(n) {
- var chars = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
- var res = '';
- for (var i = 0; i < n; i++) {
- var id = Math.ceil(Math.random() * 35);
- res += chars[id];
- }
- return res;
- }
- /**
- * 注册订阅
- * @type {Function}
- * 推送:ONEMAP.C.publisher.publish(options,'moduleName::type');
- * 订阅:ONEMAP.C.publisher.subscribe(layoutResize,'sideBarLayoutChange');
- */
- function subscribe() {
- ONEMAP.C.publisher.subscribe(userHeatlayerMarker, 'userHeatlayerMarker');
- ONEMAP.C.publisher.subscribe(remove, 'cleanMap');
- }
- /**
- * 取消订阅
- * @type {Function}
- * 取消订阅:ONEMAP.C.publisher.unSubscribe(layoutResize,'sideBarLayoutChange');
- */
- function unSubscribe() {
- //ONEMAP.C.publisher.unSubscribe(remove, 'cleanMap');
- ONEMAP.C.publisher.unSubscribe(controlMyLayer, modValue.appendToMyLayer)
- }
- return ONEMAP.M.userSideBar = {
- init: init,
- layoutResize: layoutResize
- }
- });
|