/**
 * [OElove] (C)2010-2099 oelove.com Inc. biz
 * Email: service@phpcoo.com ,phpcoo@qq.com
 * This is NOT a freeware, use is subject to license terms
 *  Last update 2019/04/24 by OE 
*/
$(function(){
    function Map() {
		this.search();
		this.save();
	}
	Map.prototype = {
		//搜索位置
		search: function () {
			$(document).on("click", "[f='but_search_map_location']", function(){
				_searchMap();
			});
		},
		//保存地图位置
		save: function () {
			var _this = this;
			$(document).on("click", "[f='but_save_setmap']", function(){
				var obj_id = $(this).attr("id");

				var _maplng = $("#maplng").val();
				var _maplat = $("#maplat").val();
				if (_maplng.length == 0) {
					OEUI.message.msg({text: "请先设置地图坐标"});
					return false;
				}
				if (_maplat.length == 0) {
					OEUI.message.msg({text: "请先设置地图坐标"});
					return false;
				}

				$("#"+obj_id).attr("f", "");

				$.ajax({
					type: "POST",
					url: _ROOT_PATH+"index.php?m=user&c=map",
					cache: false,
					data: {
						a:"saveset", maplng:_maplng, maplat:_maplat, datatype:"json", r:get_rndnum(8)
					},
					dataType: "json",
					success: function(data) {
						var json = eval(data);
						var response = json.response;
						var result = json.result;
						if (response == "1") {
							OEUI.message.msg({text: "保存成功"});
							setTimeout(function(){
								window.parent.mapdialog.remove();
								window.parent.location.reload(); //9.04.24
							}, 500);

						}
						else {
							if (result.length > 0) {
								OEUI.message.msg({text: result});
							}
							else {
								OEUI.message.msg({text: "保存失败"});
							}
						}
					},
					error: function() {
						OEUI.message.msg({text: "系统繁忙，请稍后再试"});
					}
				});
			});
		}
	};
    new Map();

	//弹出地图窗口
	/*$(document).on("click", "[f='pop_open_map']", function(){
		if (_LOGIN_STATUS == 0) {
			_jdLogin();
			return false;
		}
		_url = _ROOT_PATH+"index.php?m=user&c=map&r="+get_rndnum(8);
		if ($("#setmap_tips_box").length > 0) {
			$("#setmap_tips_box").hide();
		}
		oeShadeBox("pop_map", "ajax", _url, 800, 510, function(){
			_initOEmap();//回调初始化地图
		});
	});*/

	//关闭地图提示
	$(document).on("click", "[f='but_close_maptips']", function(){
		$(this).parent().fadeOut(200);
	});

	
});