mobile_homepage_wev8.js 48.5 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650
if(typeof(Mobile_NS) == 'undefined'){
	Mobile_NS = {};
}

var _top = null;var _win = window;try{while((_win.parent) != _win){_win = _win.parent;if(_win._mobilemode_root_page == true){_top = _win;break;}}}catch(e){}if(_top == null){_top = _win;}

function refreshIScroll(){}
function isRunInEmobile(){
    var ua = navigator.userAgent.toLowerCase();
    if(ua.match(/e-mobile/i) == "e-mobile"){
        return true;
    }else{
        return false;
    }
}
function isRunInEmobile7(){
    return !!navigator.userAgent.match(/e-mobile(7|\/7)/i);//e-mobile\/7
}
var checkEmpRetryTimes = 0;
function checkEmpEnv(callback){
    if(_top && _top != this && _top.checkEmpEnv){
        _top.checkEmpEnv(callback);
    }else{
        if(window.em){callback && callback();return;}
        setTimeout(function(){
            if(window.em){callback && callback();}
            else{if(checkEmpRetryTimes < 20){checkEmpRetryTimes++;checkEmpEnv(callback);}else{callback && callback();}}
        }, 100);
    }
}
checkEmpEnv();

function isRunInEmpAndCheckJsApi(apiList, callback){
    if(_top && _top != this && _top.isRunInEmpAndCheckJsApi){
        _top.isRunInEmpAndCheckJsApi(apiList, callback);
    }else{
        checkEmpEnv(function(){
            var result = isRunInEmobile7() || (!isRunInEmobile() && window.em && typeof(em.checkJsApi) == "function");
            if(result && apiList){
                if(typeof(apiList) == "string"){
                    result = result && em.checkJsApi(apiList);
                }else if(typeof(apiList) == "object"){
                    apiList.forEach(function(ele) {
                        result = result && em.checkJsApi(ele);
                    });
                }else{
                    result = false;
                }
            }
            callback && callback(result);
        });
    }
}

function $p(name){
	var v = Mobile_NS.pageParams[name];
	if(v == null || typeof(v) == "undefined"){
		v = "";
	}
	return v;
}

function openDetail(url, ele, oParam){
	$u(url, ele, oParam);
}

function openUrlFindBeforeCreate(url, ele, oParam){
	Mobile_NS.openUrlFindBeforeCreate(url, ele, oParam);
}

Mobile_NS.addCustomParamToUrl = function(url){
	 var index = url.indexOf("?");
	 var ownParam = {};
	 if(index > 0){
		 var pStr = url.substring(index+1);
		 var pArr = pStr.split("&");
		 for(var i = 0; i < pArr.length; i++){
			 var index2 = pArr[i].indexOf("="); 
			 if(index2 > 0){
				 var name = pArr[i].substring(0, index2);
			     var value = pArr[i].substr(index2 + 1);
			     ownParam[name] = value;
			 }
		 }
	 }
	 for(var pKey in Mobile_NS.customParams){
		 if(pKey == "isOpenedOnTopfloor") continue;
		 if(!ownParam.hasOwnProperty(pKey)){
			 url += (url.indexOf("?") == -1 ? "?" : "&") + pKey + "=" + Mobile_NS.customParams[pKey];
		 }
	 }
	 return url;
};

function $u(url, ele, oParam){
	var timestamp = (new Date()).valueOf();	//时间戳,防止缓存
	url += (url.indexOf("?") == -1 ? "?" : "&") + "_t=" + timestamp;
	url = Mobile_NS.addCustomParamToUrl(url);
	Mobile_NS.openUrl(url, ele, oParam);
}

function $u_l_replace(url, ele){
	var timestamp = (new Date()).valueOf();	//时间戳,防止缓存
	url += (url.indexOf("?") == -1 ? "?" : "&") + "_t=" + timestamp;
	url = Mobile_NS.addCustomParamToUrl(url);
	
	if(ele){
		$(ele).addClass("link_active");
		setTimeout(function(){$(ele).removeClass("link_active");},300);
	}
	
	if(_top && typeof(_top.openUrlOnLeftAndReplace) == "function"){
		_top.openUrlOnLeftAndReplace(url);
	}else{
		location.href = url;
	}
}

function $u_r_replace(url, ele){
	var timestamp = (new Date()).valueOf();	//时间戳,防止缓存
	url += (url.indexOf("?") == -1 ? "?" : "&") + "_t=" + timestamp;
	url = Mobile_NS.addCustomParamToUrl(url);
	
	if(ele){
		$(ele).addClass("link_active");
		setTimeout(function(){$(ele).removeClass("link_active");},300);
	}
	
	if(_top && typeof(_top.openUrlOnLeftAndReplace) == "function"){
		_top.openUrlOnRightAndReplace(url);
	}else{
		location.href = url;
	}
}

function fixIFrameIOSHistoryBug(preLength){
	if(_top && typeof(_top.fixIOSHistoryBug) == "function"){
		_top.fixIOSHistoryBug(preLength, window);
	}
}

function jionActionUrl(invoker, queryStr){
	if(!queryStr){
		queryStr = "";
	}
	if(queryStr.indexOf("&") != 0){
		queryStr = "&" + queryStr;
	}
	var url = "/mobilemode/Action.jsp?invoker=" + invoker + queryStr;
	if(_top && typeof(_top.changeUrl) == "function"){
		url = _top.changeUrl(url);
	}
	return url;
}

Mobile_NS.isRunInMobile = function(){
	var _m = true;
	if(_top && typeof(_top.mobilecheck) == "function"){
		_m = _top.mobilecheck();
	}
	return _m;
};

Mobile_NS.windowOnload = function(fn){
	if(Mobile_NS.isRunInMobile()){
		$(document).ready(fn);
	}else{
		if(window.addEventListener){
			window.addEventListener('load', fn, false);
		}else if(window.attachEvent){
			window.attachEvent("onload", fn);
		}
	}
};

Mobile_NS.log = function(str){
	console.error("移动建模 >> " + str);
};

Mobile_NS.openUrl = function(url, ele, oParam){
	if(ele){
		$(ele).addClass("link_active");
		setTimeout(function(){$(ele).removeClass("link_active");},300);
	}
	
	if(isOpenedOnTopfloor){
		if(_top && typeof(_top.openUrlWithTopfloor) == "function"){
			_top.openUrlWithTopfloor(url, oParam);
		}else{
			location.href = url;
		}
	}else{
		if(_top && typeof(_top.openUrl) == "function"){
			_top.openUrl(url, oParam);
		}else{
			location.href = url;
		}
	}
};

Mobile_NS.openUrlFindBeforeCreate = function(url, ele, oParam){
	if(ele){
		$(ele).addClass("link_active");
		setTimeout(function(){$(ele).removeClass("link_active");},300);
	}
	
	if(_top && typeof(_top.openUrlFindBeforeCreate) == "function"){
		_top.openUrlFindBeforeCreate(url, oParam);
	}else{
		location.href = url;
	}
};

//执行SQL
Mobile_NS.SQL = function(sqlstr, datasource, callbackFn){
	if (arguments.length == 2 && typeof(datasource) == "function") {
		callbackFn = datasource;
		datasource = "";
	}
	var requestParam = {};
	if(sqlstr){
		var sqlparamArr = sqlstr.split(";");
		sqlstr = sqlparamArr[0];
		for(var i = 1; i < sqlparamArr.length; i++){
			var oneParam = sqlparamArr[i];
			var pIndex = oneParam.indexOf("=");
			if(pIndex != -1){
				var paramName = oneParam.substring(0, pIndex);
				var paramValue = oneParam.substring(pIndex + 1);
				requestParam[paramName] = paramValue;
			}
		}
	}
	
	if(!datasource){
		datasource = "";
	}
	var asyncFlag = false;
	if(typeof(callbackFn) == "function"){
		asyncFlag = true;
	}
	
	var result = "";
	var timestamp = (new Date()).valueOf();	//时间戳,防止缓存
	$.ajax({
	 	type: "GET",
	 	url: jionActionUrl("com.api.mobilemode.web.mobile.service.MobileCommonAction", "action=runSQL&content="+sqlstr+"&datasource="+(datasource || "")),
	 	data: requestParam,
	 	async: asyncFlag,
	 	success: function(responseText)
	 	{
	 		var res = $.parseJSON(responseText);
			var data = res["data"];
	 		var status = data["status"];
	 		if(status != "-1"){	//server端没有出现未知异常
	 			result = data["result"];
	 		}
	 		if(typeof(callbackFn) == "function"){
	 			callbackFn.call(this, result);
	 		}
	 	},
	    error: function(){
	    	//alert("error");
	    }
	});
	return result;
};

Mobile_NS.toMapPage = function(appHomepageId, addressKey, addressValue){
	console.error("函数 Mobile_NS.toMapPage 已被废弃,后面的版本可能会删除这个函数,请慎用。");
	openDetail("/mobilemode/appHomepageView.jsp?appHomepageId="+appHomepageId+"&"+addressKey+"="+encodeURI(addressValue));
};

Mobile_NS.openMap = function(destination, coordinateType){
	var url = "/mobilemode/map.jsp?destination=" + encodeURI(destination);
	if(typeof(coordinateType) != "undefined"){
		url += "&coordinateType=" + coordinateType;
	}
	$u(url);
};

Mobile_NS.progressBar = function(id, config){
	var $obj = $("#" + id);
	if($obj.length == 0){
		return;
	}
	var v = $obj.html();
	v = $.trim(v);
	
	if(v == ""){
		v = 0;
	}else if(isNaN(v)){
		return;
	}
	
	var $csProgressBar = $("<div class=\"csProgressBar\"></div>");
	$csProgressBar.html("<div style=\"width:"+v+"%;\"><span>"+v+"%</span></div>");
	
	var color = "";
	
	var defaultConfig = {"0-40":"#da532c", "41-70":"#e3a21a", "71-100":"#99b433"};
	if(config){
		defaultConfig = config;
	}
	
	v = parseInt(v);
	for(var key in defaultConfig){
		var keyArr = key.split("-");
		if(keyArr.length == 2 && !isNaN(keyArr[0]) && !isNaN(keyArr[1])){
			if(v >= keyArr[0] && v <= keyArr[1]){
				color = defaultConfig[key];
				break;
			}
		}
	}
	
	if(color != ""){
		$csProgressBar.children("div").css("background-color", color);	
	}
	
	$obj.html("");
	$obj.append($csProgressBar);
};

Mobile_NS.createTopfloorPage = function(pageIdOrUrl, param){
	_top.createTopfloorPage(pageIdOrUrl, param);
};

Mobile_NS.closeTopfloorPage = function(callbackFn){
	_top.closeTopfloorPage(callbackFn);
};

Mobile_NS.backTopfloorPage = function(){
	_top.backTopfloorPage();
};

Mobile_NS.refresh = function(pageId){
	if(typeof(pageId) == "undefined"){
		if(_top && typeof(_top.refreshCurrPage) == "function"){
			_top.refreshCurrPage();
		}else{
			location.reload();
		}
	}else{
		var $frame = _top.$("#mobileFrameContainer iframe.mobileFrame[id='appHomepageFrame_"+pageId+"']");
		if($frame.length > 0){
			var f = $frame[0];
			f.src = f.src;
		}else{
			Mobile_NS.log("未找到指定id的页面:" + pageId);
		}
	}
};

Mobile_NS.backToHomepage = function(){
	if(_top && typeof(_top.backToHomepage) == "function"){
		_top.backToHomepage();
	}
};

//web头部点击左边按钮返回前一页
Mobile_NS.backPage = function(){
	if(_top && typeof(_top.doHistoryBack) == "function"){
		_top.doHistoryBack();
	}
};

/*首页内置JS函数,方便在首页进行代码编写和规避一些复杂的代码处理*/
//显示加载器  
Mobile_NS.showLoader = function() {  
	_top.showLoading();
  /*$.mobile.loading('show', {  
      text: '加载中...', //加载器中显示的文字  
      textVisible: true, //是否显示文字  
      theme: 'a',        //加载器主题样式a-e  
      textonly: false,   //是否只显示文字  
      html: ""           //要显示的html内容,如图片等  
  });  */
};

//隐藏加载器
Mobile_NS.hideLoader = function()  
{  
	_top.hideLoading();
  /*$.mobile.loading('hide');*/  
};

Mobile_NS.dynamicRunFn = function(fnName){
	try{
		var beCallCode = fnName + "()";
		eval(beCallCode);
	}catch(e){
		
	}
};

Mobile_NS.dynamicRunCode = function(code){
	try{
		eval(code);
	}catch(e){
		console.log(e);
	}
};

Mobile_NS.dynamicRunCode2 = function(code){
	if(code && code != ""){
		code = decodeURIComponent(code);
		Mobile_NS.dynamicRunCode(code);
	}
};

Mobile_NS.ajax = function(url, paramData, callbackFn, type){
	var timestamp = (new Date()).valueOf();	//时间戳,防止缓存
	url += (url.indexOf("?") == -1 ? "?" : "&") + timestamp;
	return $.get(url, paramData, function(data){
		if(typeof(callbackFn) == "function"){
			callbackFn.call(this, data);
		}
	}, type);
};

Mobile_NS.triggerLazyLoad = function(mec_id, params, callbackFn){
	var $lazyLoadContainer = $("#abbr_" + mec_id);
	if($lazyLoadContainer.length == 0){
		return;
	}
	var loaded = $lazyLoadContainer.attr("loaded");
	if(loaded == "true"){
		return;
	}
	$lazyLoadContainer.attr("loaded", "true");
	
	if(Mobile_NS.DataSet && Mobile_NS.DataSet.dArray && Mobile_NS.DataSet.dArray.length > 0){
		var dataSetArray = Mobile_NS.DataSet.dArray;
		var jsonArr = [];
		for(var i=0;i<dataSetArray.length;i++){
			var jsonObj = {};
			jsonObj[dataSetArray[i].name]= dataSetArray[i].dataObj;
			jsonArr.push(jsonObj);
		}
		
		Mobile_NS.pageParams["_DataSet"] = encodeURIComponent(JSON.stringify(jsonArr));
	}
	
	Mobile_NS.triggerRefresh(mec_id, params, callbackFn);
};

Mobile_NS.triggerRefresh = function(mec_id, params, callbackFn){
	var $mecContainer = $("#abbr_" + mec_id);
	if($mecContainer.length == 0){
		return;
	}
	
	if(typeof(params) == "function" && typeof(callbackFn) == "undefined"){
		callbackFn = params;
	}else{
		if(params){
			for(var key in params){
				Mobile_NS.pageParams[key] = params[key];
			}
		}
	}
	
	$mecContainer.find("*").remove();
	
	//动态创建一个loading的div
	var $refreshLoading = $(
			"<div class=\"mec_refresh_loading\"><div class=\"spinner\">" +
				"<div class=\"bounce1\"></div>" +
				"<div class=\"bounce2\"></div>" +
				"<div class=\"bounce3\"></div>" +
			"</div></div>"
	);
	$mecContainer.append($refreshLoading);
	var url = "/mobilemode/MECAction.jsp?action=getMecHtml&mec_id="+mec_id;
	var timestamp = (new Date()).valueOf();	//时间戳,防止缓存
	url += "&" + timestamp;
	$.ajax({
	    url: url,
	    data: Mobile_NS.pageParams,
	    type: 'post',
	    success: function (data) {
	    	$refreshLoading.hide();
			$refreshLoading.remove();
			
			//还原页数(如果有),针对列表或者时间轴,以及其它后面会增加的插件,但是要求名称必须是pageNo + mec_id
			eval("if(typeof(pageNo" + mec_id + ") != 'undefined'){pageNo" + mec_id + " = 1}");
			
			$mecContainer.html(data);

			$mecContainer.trigger("create"); //触发jqm渲染

	        if(typeof(callbackFn) == "function"){
	            try{
	                callbackFn.call(this, mec_id);
	            }catch(e){}
	        }

			Mobile_NS.imgLazyload($mecContainer, "img.lazy", $mecContainer.find("div").eq(0));
			
			refreshIScroll();
			
			if(_top && typeof(_top.resetActiveFrame) == "function"){
				_top.resetActiveFrame();
			}
	    },
	    error: function(res){
	    	//alert("error");
	    }
	});
};

Mobile_NS.initTapEvent = function($Wrap, stopPropagation){
	if(!$Wrap){
		$Wrap = $(document.body);
	}
	var $tapEle = $("*[ontap]", $Wrap);
	$tapEle.each(function(){
		var tapCode = $(this).attr("ontap");
		$(this).on("click", function(e){
			eval(tapCode);
			if(stopPropagation){
				e.stopPropagation();
			}
		});
	});
	$tapEle.removeAttr("ontap");
};

Mobile_NS.onTap = function(selector, fn){
	
	var $target = null;
	if(typeof selector === "string"){
		$target = $(selector);
	}else if(selector instanceof $){
		$target = selector;
	}else{
		$target = $(selector);
	}
	
	$target.on("click", fn);
	
};

Mobile_NS.getCurrUser = function(){
	return E3005CF26D9F9AC78773E16572827297;
};

var scanQRCodeCallbackFn = null;
Mobile_NS.scanQRCode = function(fn){
	if(_top && typeof(_top.registMPCWindow) == "function"){
		_top.registMPCWindow(window);
	}
	scanQRCodeCallbackFn = fn;
	
	isRunInEmpAndCheckJsApi("scanQRCode", function(isEmp){
	    if(_top && _top.eb_Scan){
	        _top.eb_Scan("_p_scanQRCode");
	    }else if(typeof(eb_Scan) == "function"){
	        eb_Scan("_p_scanQRCode");
	    }else if(isEmp){
	        if(_top && _top.scanQRCode4EM7){
	            return _top.scanQRCode4EM7(fn);
	        }
	        scanQRCode4EM7(fn);
	    }else{
	        location = "emobile:QRCode:_p_scanQRCode";
	    }
	});
};

function _p_scanQRCode(result){
	if(scanQRCodeCallbackFn && typeof(scanQRCodeCallbackFn) == "function"){
		scanQRCodeCallbackFn.call(this, result);
	}
}

Mobile_NS.callWebService = function(wsParam){
	var url = jionActionUrl("com.weaver.formmodel.mobile.ws.WSAction", "action=callWS");
	Mobile_NS.ajax(url,{
		"endpoint" : wsParam["endpoint"] || "",
		"namespace" : wsParam["namespace"] || "",
		"operationName" : wsParam["operationName"] || "",
		"parameters" : JSON.stringify(wsParam["parameters"]) || "[]",
        "timeOut" : wsParam["timeOut"] || "",
    },wsParam["callbackFn"]);
};

Mobile_NS.addJs = function(jsPath, fn){
	var headEle = document.getElementsByTagName("head")[0]; 
	var scriptEle = document.createElement("script");
	scriptEle.setAttribute("type", "text/javascript"); 
	scriptEle.setAttribute("src", jsPath); 
	if(typeof(fn) == "function"){
		scriptEle.onload = fn;
	}
	headEle.appendChild(scriptEle);
}


Mobile_NS.getCurrentPosition = function(fn){

	function innerFn(){
		
		if(_top && typeof(_top.registMPCWindow) == "function"){
			_top.registMPCWindow(window);
		}
		lbsCallbackFnCache.push(fn);
		isRunInEmpAndCheckJsApi("getLocation", function(isEmp){
		    if(isEmp){
	            if(_top && _top.getLocation4EM7){
	                return _top.getLocation4EM7(_p_getLBSResult);
	            }
	            getLocation4EM7(_p_getLBSResult);
	        }else if(_top && typeof(_top.isRunInEmobile) == "function" && _top.isRunInEmobile()){
	            location = "emobile:gps:_p_getLBSResult";
	        }else if(_top && _top.eb_GetLocation){
	            _top.eb_GetLocation("_p_wx_getLBSResult");
	        }else if(typeof(eb_GetLocation) == "function"){
	            eb_GetLocation("_p_wx_getLBSResult");
	        }else{
	            navigator.geolocation.getCurrentPosition(function(position){
	                var timestamp = (new Date()).valueOf();  
	                var gpsstr = timestamp+","+position.coords.latitude+","+position.coords.longitude;
	                _p_getLBSResult(gpsstr, "gps");
	            },function(error){
	                var errMsg = "";
	                switch(error.code){
	                    case error.PERMISSION_DENIED:
	                      errMsg = "用户拒绝对获取地理位置的请求。";
	                      break;
	                    case error.POSITION_UNAVAILABLE:
	                      errMsg = "位置信息是不可用的。";
	                      break;
	                    case error.TIMEOUT:
	                      errMsg = "请求用户地理位置超时。";
	                      break;
	                    case error.UNKNOWN_ERROR:
	                      errMsg = "未知错误。";
	                      break;
	                }
	                
	                var result = {};
	                result["status"] = "0";
	                result["errMsg"] = errMsg;  //错误信息
	                result["lng"] = ""; //精度
	                result["lat"] = ""; //纬度
	                result["addr"] = "";    //中文地址
	                result["province"] = "";    //省份
	                result["city"] = "";    //城市
	                result["district"] = "";    //区
	                result["street"] = "";  //街道
	                result["streetNumber"] = "";    //街道号码
	                
	                fn.call(this, result);
	                
	            },{
	                enableHighAcuracy: true,
	                maximumAge: 3000
	            });
	        }
		});
	}


    if(typeof(AMap) == "undefined" || typeof(BMap) == "undefined"){
        Mobile_NS.addJs("https://webapi.amap.com/maps?v=1.4.10&key=0911a33b8532677fba40e891ba3e73a2&cache=0&plugin=AMap.Geocoder", function(){
            Mobile_NS.addJs("https://webapi.amap.com/maps/modules?v=1.4.10&key=0911a33b8532677fba40e891ba3e73a2&vrs=1543554886650&m=mouse,vectorlayer,overlay,wgl,AMap.Geocoder,sync", function(){
                Mobile_NS.addJs("/mobilemode/js/baidu/api_https_wev8.js?v=2018101001", function(){
                    innerFn();
                });
            });
        });
	}else{
		innerFn();
	}
};

function _p_wx_getLBSResult(longitude, latitude){

    var lnglat = [longitude,latitude];
    var geocoder = new AMap.Geocoder();
    geocoder.getAddress(lnglat, function(status, result) {
        if (status === 'complete'&&result.regeocode) {
            var addstr = result.regeocode.formattedAddress;
            var timestamp = (new Date()).valueOf();
            var gpsstr = timestamp+","+latitude+","+longitude+","+addstr;
            _p_getLBSResult(gpsstr, "google");
        }else{
            alert("error: _p_wx_getlbsresult is not complete.");
        }
    });
}

function _p_getLBSResult_error(result){
	var index = result.lastIndexOf(","); 
	var status = result.substring(index+1);
	var errmsg = "";
	var errnum = "2,3,4,5,6,11,13,14";
	if(errnum.indexOf(status)){
		errmsg = result.substring(0,index);
	}
	alert("定位失败,"+errmsg+",响应码:"+status);
}

var lbsCallbackFnCache = [];
function _p_getLBSResult(result, gpsType){
	
	function parseLongLat(addstr, longitude, latitude, type){
		
		function parseAddress(point){
			
			var geoc = new BMap.Geocoder();
			geoc.getLocation(point, function(rs){
				var addComp = rs.addressComponents;
				var addr = addComp.province + addComp.city + addComp.district + addComp.street + addComp.streetNumber;
				if(addstr) addr = addstr;
				var result = {};
				result["status"] = "1";
				result["errMsg"] = "";	//错误信息
				result["lng"] = point.lng;	//精度
				result["lat"] = point.lat;	//纬度
				result["addr"] = addr;	//中文地址
				result["province"] = addComp.province;	//省份
				result["city"] = addComp.city;	//城市
				result["district"] = addComp.district;	//区
				result["street"] = addComp.street;	//街道
				result["streetNumber"] = addComp.streetNumber;	//街道号码
				while(lbsCallbackFnCache.length){
                    var lbsCallbackFn = lbsCallbackFnCache.shift();
                    if(lbsCallbackFn && typeof(lbsCallbackFn) == "function"){
                        lbsCallbackFn.call(this, result);
                    }
                }
			});
		}
		
		var convertor = new BMap.Convertor();
		if(type == "google"){	//谷歌坐标
			
			var googlePoint = new BMap.Point(longitude, latitude);
			convertor.translate([googlePoint], 3, 5, function(data){
				var point = data.points[0];
				parseAddress(point);
			});	
			/*
			var googlePoint = new BMap.Point(longitude, latitude);
			BMap.Convertor.translate(googlePoint, 2, parseAddress);
			*/
		}else if(type == "baidu"){	//百度坐标
			var baiduPoint = new BMap.Point(longitude, latitude);
			parseAddress(baiduPoint);
		}else if(type == "gps"){	//原始坐标
			
			var gpsPoint = new BMap.Point(longitude, latitude);
			convertor.translate([gpsPoint], 1, 5, function(data){
				var point = data.points[0];
				parseAddress(point);
			});
			/*
			var gpsPoint = new BMap.Point(longitude, latitude);
			BMap.Convertor.translate(gpsPoint, 0, parseAddress);
			*/
		}
	}
	
	
	if(result){
		var resultArr = result.split(",");
		if(resultArr.length >= 3){
			if(!gpsType){
				gpsType = "google";	//emobile使用的是google坐标
			}
			parseLongLat(resultArr[3], resultArr[2], resultArr[1], gpsType);
		}
	}
}

Mobile_NS.openHrmBrowser = function(fieldId, fieldSpanId, isMuti){
	if(_top && typeof(_top.openHrmBrowser) == "function"){
		_top.openHrmBrowser(window, fieldId, fieldSpanId, isMuti);
	}
};

Mobile_NS.openTreeBrowser = function(fieldId, fieldSpanId, browserId, browserName, browserText,isMuti){
	if(_top && typeof(_top.openTreeBrowser) == "function"){
		_top.openTreeBrowser(window, fieldId, fieldSpanId, browserId, browserName, browserText,isMuti);
	}
};

Mobile_NS.openCommonBrowser = function(fieldId, fieldSpanId, browserId, browserName, browserText, params, dbfieldId){
	if(_top && typeof(_top.openCommonBrowser) == "function"){
		_top.openCommonBrowser(window, fieldId, fieldSpanId, browserId, browserName, browserText, params, dbfieldId);
	}
};

Mobile_NS.openBrowser = function(fieldId, fieldSpanId, browserId, browserName, browserText, dbfieldId){
	if(browserId == "1"){	//人力资源
		Mobile_NS.openHrmBrowser(fieldId, fieldSpanId, false);
	}else if(browserId == "17"){	//多人力资源
		Mobile_NS.openHrmBrowser(fieldId, fieldSpanId, true);
	}else if(browserId == "256"){	//多人力资源
		Mobile_NS.openTreeBrowser(fieldId, fieldSpanId, browserId, browserName, browserText, false);
	}else if(browserId == "257"){	//多人力资源
		Mobile_NS.openTreeBrowser(fieldId, fieldSpanId, browserId, browserName, browserText, true);
	}else{
		var params = {}; //浏览框联动参数 如:{"_nj":"23","_bj":"24"};
		if(fieldId.indexOf("_as_field") != -1){//列表高级搜索
			var $advancedSearch = $("#"+fieldId).parents(".as-container");
			$("[search='true']", $advancedSearch).each(function(){
				var $that = $(this);
				var fieldname = "fieldname_"+$that.attr("fieldname").toLowerCase();
				var fieldtype = $that.attr("fieldtype");
				if($that.attr("fieldtype") == "date" || $that.attr("fieldtype") == "time" || $that.attr("fieldtype") == "numb" || $that.attr("fieldtype") == "thousandnumb"){//单独处理日期或者时间,数字
					params[fieldname] = "";
				}else{
					var v = $.trim($that.val());
					if(fieldtype != "browser" && v.length > 30){
						v = "";
					}
					params[fieldname] = v;
				}
			});
		}else{
			var $mainform = $(".mobileform");
			var getFieldParams = function($form, _params, detailtablename){
				$("[name^='fieldname_']", $form).each(function(){
					var _fieldname = $(this).attr("name").toLowerCase(); // nj
					var fieldvalue = $(this).val(); //23
					if(detailtablename){
						_fieldname = "fieldname_"+detailtablename + "_" + _fieldname.replace("fieldname_", "");
					}
					var fieldhtmltype = $(this).attr("fieldhtmltype");
					if(fieldhtmltype != "3" && fieldvalue.length > 30){
						fieldvalue = "";
					}
					_params[_fieldname] = fieldvalue;
				});
				return _params;
			};
			//主表字段
			params = getFieldParams($mainform, params);
			//明细表字段
			$(".detailtableform").each(function(){
				var $detailform = $(this);
				var detailformmecid = $detailform.attr("name");
				var detailtablename = $("input[name='detailtablename_"+detailformmecid+"']").val();
				params = getFieldParams($detailform, params, detailtablename);
			});
		}
		Mobile_NS.openCommonBrowser(fieldId, fieldSpanId, browserId, browserName, browserText, params, dbfieldId);
	}
};

Mobile_NS.clearBrowser = function(fieldId, fieldSpanId){
	$("#" + fieldId).val("");
	$("#" + fieldSpanId).html("");
	$("#" + fieldSpanId+"_hidden").html("");
	$("#" + fieldSpanId).parent().removeClass("hasValue");
	$("#" + fieldId).trigger("change");
	$("#" + fieldId).trigger("input");
};

Mobile_NS.openBrowserView = function(fieldId, fieldSpanId, browserId){
    if(browserId == "16"){	//流程
        Mobile_NS.openBrowserLink(fieldId, fieldSpanId, "wflow", false);
    }else if(browserId == "9"){	//文档
        Mobile_NS.openBrowserLink(fieldId, fieldSpanId, "doc", false);
    }else if(browserId == "37"){	//多文档
        Mobile_NS.openBrowserLink(fieldId, fieldSpanId, "doc", true);
    }else if(browserId == "152" || browserId == "171"){	//多流程 ||  归档流程
        Mobile_NS.openBrowserLink(fieldId, fieldSpanId, "wflow", true);
    }else{
        return;
    }
};

Mobile_NS.openBrowserLink = function(fieldId, fieldSpanId, browserType, isMuti){
    var linkurl = "";
    if(browserType == "wflow"){
        linkurl = "/mobile/plugin/1/view.jsp?detailid=";
    }else if(browserType == "doc"){
        linkurl = "/mobile/plugin/2/view.jsp?detailid=";
        if(_top && ((typeof(_top.isRunInEmobile7) == "function" && _top.isRunInEmobile7()) ||
			(typeof(_top.isRunInEmobile) == "function" && !_top.isRunInEmobile() && window.em && typeof(em.checkJsApi) == "function"))){
        	linkurl = "/spa/document/static4mobile/index.html#/doc/";
        }
    }else{
        return;
    }
    var fieldVals = $("#" + fieldId).val();
    if(!fieldVals) return;

    fieldVals = fieldVals.split(",");
    if(isMuti){
        var fieldSpans = $("#" + fieldSpanId).html().split(",");
        var json = [];
        for(var i=0;i<fieldVals.length;i++){
            var jsonObj = {};
            jsonObj.id = fieldVals[i];
            jsonObj.menuText = "<div style='text-align: left;font-size: 16px;color: #017afd;text-overflow: ellipsis;overflow: hidden;white-space: nowrap;'>"+fieldSpans[i]+"</div>";
            jsonObj.callback = function(){
                var dataid = $(this).attr("data-id");
                Mobile_NS.openUrl(linkurl + dataid);
            };
            json.push(jsonObj);
        }
        _top.addDialogCover(json);
    }else{
        Mobile_NS.openUrl(linkurl + fieldVals[0]);
    }
};

var _viewOpenCount = 0;
var _viewCloseFnArr = new Array();
Mobile_NS.isViewOpen = function(){
	return _viewOpenCount > 0;
};

Mobile_NS.setViewOpen = function(viewCloseFn){
	_viewOpenCount ++;
	_viewCloseFnArr.push(viewCloseFn);
	if(_top && typeof(_top.refreshWebHead) == "function"){
		setTimeout(_top.refreshWebHead, 300);
	}
	if(_top && typeof(_top.pushHistoryState) == "function"){
		_top.pushHistoryState({viewOpen:1});
	}
};

Mobile_NS.setViewClose = function(){
	_viewOpenCount --;
	var viewCloseFn = _viewCloseFnArr[_viewOpenCount];
	_viewCloseFnArr.splice(_viewOpenCount, 1);
	viewCloseFn.call(this);
	if(_top && typeof(_top.refreshWebHead) == "function"){
		setTimeout(_top.refreshWebHead, 300);
	}
};

Mobile_NS.isHidden = function($obj){
	return $obj.css("display") == "none" || $obj.css("visibility") == "hidden";
};

Mobile_NS.getCurrentWindow = function(){
	return window;
};

/**
 * 打开定位页面
 * {
 * 	posType : "1",		//定位类型, 默认"1"。 1.只显示当前位置,不显示周围热点     2.显示当前位置同时显示周围热点     3.显示当前位置和周围热点,并允许改变当前位置及更新周围热点
 * 	btnText : "确定",	//按钮文字, 默认"确定"。
 * 	poiRadius : 500,	//poi半径,单位米,默认500。
 * 	numPois : 12,		//列举poi的数量,默认12。
 * 	success : callbackFn	//回调函数 无默认。function(gpsstr, address){	//gpsstr: "31.173211,121.475134"	//address: "上海市浦东新区耀华支路39弄9号"	}
 * }
 */
Mobile_NS.openLBSWin = function(paramObj){
	if(_top && typeof(_top.registLBSBackWindow) == "function"){
		
		_top.registLBSBackWindow(window);
		
		var queryStr = "";
		var callbackFn = null;
		if(typeof(paramObj) == "function"){
			callbackFn = paramObj;
		}else{
			callbackFn = paramObj.success;
			if(paramObj.posType){
				queryStr += "&posType=" + paramObj.posType;
			}
			if(paramObj.btnText){
				queryStr += "&btnText=" + paramObj.btnText;
			}
			if(paramObj.poiRadius){
				queryStr += "&poiRadius=" + paramObj.poiRadius;
			}
			if(paramObj.numPois){
				queryStr += "&numPois=" + paramObj.numPois;
			}
		}
		
		window._LBSLoaded = function(result){
			var r_arr = result.split(";;");
			callbackFn.call(this, r_arr[0], r_arr[1]);
		};
		
		if(queryStr != ""){
			queryStr = "?" + queryStr.substring(1);
		}
		
		$u("/mobilemode/lbs.jsp" + queryStr);
	}else{
		Mobile_NS.log("无法定位顶部页面 或者 顶部页面无registLBSBackWindow方法。");
	}
};

Mobile_NS.refreshPrevPageList = function(listId){
	var $activeFrame = _top.$("#mobileFrameContainer iframe.activeFrame");
	var $prevFrame = $activeFrame.prev("iframe.mobileFrame");
	if($prevFrame.length > 0){
		try{
			var frameWin = $prevFrame[0].contentWindow;
			var _M_NS = frameWin.Mobile_NS;
			if(typeof(_M_NS.refreshList) == "function"){
				_M_NS.refreshList(listId);
			}
			if(typeof(_M_NS.refreshTimelinr) == "function"){
				_M_NS.refreshTimelinr(listId);
			}
			if(_M_NS.GridTable && typeof(_M_NS.GridTable.refresh) == "function"){
				_M_NS.GridTable.refresh(listId);
			}
		}catch(e){
			Mobile_NS.log(e);
		}
	}
};

Mobile_NS.refreshSpecifiedList = function(appHomepageId, listId, listparams){

    function refreshSpecifiedListInner(id, listId, theWin, listparams){
		
		if(id.indexOf(".") != -1){
			var _id = id.substring(0, id.indexOf("."));
			var _id2 = id.substring(id.indexOf(".") + 1);
			
			var $frame = theWin.$("#appHomepageFrame_" + _id);
			if($frame.length == 0){
				$frame = theWin.$("iframe[pageid='appHomepageFrame_"+_id+"']");
			}
			if($frame.length > 0){
				var frameWin = $frame[0].contentWindow;
                refreshSpecifiedListInner(_id2, listId, frameWin, listparams);
			}
		}else{
			var $frame = theWin.$("#appHomepageFrame_" + id);
			if($frame.length == 0){
				$frame = theWin.$("iframe[pageid='appHomepageFrame_"+id+"']");
			}
			if($frame.length > 0){
				try{
					var frameWin = $frame[0].contentWindow;
					var _M_NS = frameWin.Mobile_NS;
					if(typeof(_M_NS.refreshList) == "function"){
                        _M_NS.refreshList(listId, listparams);
					}
					if(typeof(_M_NS.refreshTimelinr) == "function"){
                        _M_NS.refreshTimelinr(listId, listparams);
					}
					if(_M_NS.GridTable && typeof(_M_NS.GridTable.refresh) == "function"){
                        _M_NS.GridTable.refresh(listId, listparams);
					}
				}catch(e){
					Mobile_NS.log(e);
				}
			}
		}
	}

    refreshSpecifiedListInner(appHomepageId, listId, _top, listparams);
};

var listenPgChangeFn = new Array();
Mobile_NS.listenPageChange = function(fn){
	listenPgChangeFn.push(fn);
}

Mobile_NS.triggerPageChange = function(source){
	for(var i = 0; i < listenPgChangeFn.length; i++){
		var fn = listenPgChangeFn[i];
		if(typeof(fn) == "function"){
			fn.call(this, source);
		}
	}
}

Mobile_NS.groupViewImg = function(source){
	$("img[data-groupid]").each(function(){
		var that = this;
		var hasEvent = $(that).attr("data-groupev") == "true";
		if(!hasEvent){
			$(that).attr("data-groupev", "true");
			$(that).click(function(e){
				var groupid = $(this).attr("data-groupid");
				var currSrc = $(this).attr("src");
				
				var imgSrcs = "";
				$("img[data-groupid='"+groupid+"']").each(function(){
					var src = $(this).attr("src");
					//编辑布局点击图片时会进入空白页面问题处理
					if(src == "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAANSURBVBhXY3j37t1/AAliA8r60tGjAAAAAElFTkSuQmCC") return;
					imgSrcs += src + "|";
				});
				if(imgSrcs != ""){
					imgSrcs = imgSrcs.substring(0, imgSrcs.length - 1);
				}
				
				imgSrcs = encodeURIComponent(imgSrcs);
				currSrc = encodeURIComponent(currSrc);
				var url = "/mobilemode/displayPicOnMobile.jsp?imgSrc="+imgSrcs+"&imgSrcActive="+currSrc+"&1=1";
				$u(url);
				
				e.stopPropagation();
			});
		}
	});
};

Mobile_NS.pressImgForSave = function(){
	if(!(typeof(_top.isRunInEmobile) == "function" && _top.isRunInEmobile())){
		return;
	}
	$("img").each(function(){
		var $imgEle = $(this);
		var flag = $imgEle.attr("data-press-save-event");
		if(flag == "1"){
			return;
		}
		$imgEle.attr("data-press-save-event", "1");
		var mc = new Hammer($imgEle[0], {
			recognizers: [
	      		[Hammer.Press,{ time : 500 }]
	      	]
		});
	    
		mc.on('press', function(ev) {
			var imgSrc = $(ev.target).attr("src");
			if(imgSrc == null || imgSrc == ""){
				return;
			}
			_top.addDialogCover([
	      		{id : "a", menuText : "<div style='text-align: center;margin-left: -18px;font-size: 18px;color: #017afd;'>保存图片</div>", callback : function(){
					isRunInEmpAndCheckJsApi("downloadImage", function(isEmp){
						if(isEmp){
							top && top.downloadImage4EM7 && top.downloadImage4EM7(imgSrc);
						}else{
							if(imgSrc.indexOf("data:image") == 0){
								try {
									var baseArr=imgSrc.split(",");
									var basepic64=baseArr[1];
									_top.invokeEmApi("saveBase64Image", {
										base64Img: basepic64,
									});
								} catch (e){
									console.log(e.message);
								}
							} else {
								location = "emobile:saveImage:"+imgSrc+":111";
							}
						}
					});
	      		}},
	      		{id : "b", menuText : "<div style='text-align: center;margin-left: -18px;font-size: 18px;color: #017afd;'>查看</div>", callback : function(){
	      			var url = "/mobilemode/displayPicOnMobile.jsp?imgSrc="+imgSrc+"&imgSrcActive="+imgSrc+"&1=1";
					$u(url);
	      		}}
	      	]);
		});	
	});
};

Mobile_NS.encrypt = function(content, unEncodeWhenFirewallDisabled){
	if(typeof(unEncodeWhenFirewallDisabled) == "undefined"){
		unEncodeWhenFirewallDisabled = false;
	}
	var url = jionActionUrl("com.weaver.formmodel.mobile.security.EDAction", "action=encrypt");
	$.ajax({
	    url: url,
	    data: {"content":content, "unEncodeWhenFirewallDisabled":unEncodeWhenFirewallDisabled},
	    async: false,
	    dataType: 'json',
	    type: 'get',
	    success: function (res) {
	    	content = res["content"];
	    	if(!content){
	    		content = "";
	    		var msg = res["msg"];
	    		if(msg && msg != ""){
	    			alert(msg);
	    		}
	    	}
	    },
	    error: function(res){
	    	//alert("error");
	    }
	});
	return content;
}
	
function downloadattach(fileid,filename, empowStr){
	var suffix = "&_fromMobilemode=1" + (empowStr ? empowStr : "");
    isRunInEmpAndCheckJsApi("openLink", function(isEmp){
        if(isEmp){
            var url = "/weaver/weaver.file.FileDownload?fileid=" + fileid + suffix;
            if(_top && _top.downloadAttach4EM7){
                return _top.downloadAttach4EM7(url, filename);
            }
            downloadAttach4EM7(url, filename);
        }else if(_top && _top._sessionkey){
			top.location.href =  "/mobile/plugin/Download.jsp?sessionkey=" + _top._sessionkey + "&url=" + fileid + suffix;
		} else if(_top && typeof(_top.isRunInEmobile) == "function" && _top.isRunInEmobile()){
			top.location.href  = "/download.do?fileid=" + fileid + "&module=3&scope=11&filename=" + encodeURI(filename) + suffix;
		}else{
            top.location.href = "/weaver/weaver.file.FileDownload?fileid=" + fileid + suffix;
        }
        _top.hideLoading();
    });
}

function anonymousFiledownProcess(container){
	var sessionKey = _top && _top._sessionkey;
	if(!sessionKey) return;
	$(container).find('img.lazy').each(function(index,ele){
		var url = $(ele).attr('data-original');
		url = url.replace(/\/weaver\/weaver.file.FileDownload\?fileid=/g, "/mobile/plugin/Download.jsp?sessionkey=" + sessionKey+ "&url=");
		$(ele).attr('data-original',url);
	});
}

Mobile_NS.addFormmodeDataShare = function(modelid, billid, callbackFn){
	var url = jionActionUrl("com.weaver.formmodel.mobile.mec.servlet.MECAction", "action=addFormmodeDataShare");
	Mobile_NS.ajax(url, {"modelid":modelid, "billid":billid}, callbackFn);
};

Mobile_NS.doNavgationJs = function(code){
	try{
		code = decodeURIComponent(code);
		if(code.indexOf("javascript:") == 0){
			var script = code.substring("javascript:".length);
			eval(script);
		}
	}catch(e){
		console.log(e);
	}
};

Mobile_NS.Alert = function(msg, autoHide, callbackFn){
	if(_top && typeof(_top.Dialog) == "function"){
		var params = {msg:msg};
        if(autoHide === false){
			params["autoHide"] = false;
			params["global"] = false;
			params["theme"] = "light";
			params["model"] = true;
			var buttons = {};
			if(callbackFn instanceof Array){
				var buttonName = (callbackFn[0] == undefined ? "确定" : callbackFn[0]);
				buttons[buttonName] = function(){
					if(typeof(callbackFn[1]) == "function"){
						callbackFn[1].call(this);
					}
					$(this).parents("#dialog").hide();
				};
			}else{
				params["buttons"] = {"确定": function(){
					if(typeof(callbackFn) == "function"){
						callbackFn.call(this);
					}
					$(this).parents("#dialog").hide();
				}};
			}
            params["buttons"] = buttons;
        }
        if(autoHide === true || !isNaN(autoHide) || typeof(autoHide) == "function"){
            if(typeof(autoHide) == "function"){
                callbackFn = autoHide;
            }
            if(typeof(callbackFn) == "function"){
                params["autoHideCallBack"] = callbackFn;
            }
            if(parseInt(autoHide) > 0){
                params["expire"] = parseInt(autoHide) * 1000;
            }
        }
		_top.Dialog(params);
	}else{
		alert(msg);
	}
};

Mobile_NS.Confirm = function(msg, title, fn1, fn2){
	if(_top && typeof(_top.Dialog) == "function"){
		var params = {
				autoHide:false, 
				width: "", 
				height:"", 
				msg: msg, 
				buttons:{
					"确认":function(){
						if(typeof(fn1) == "function"){
							fn1.call(this);
						}
						$(this).parents("#dialog").hide();
					},
					"取消":function(){
						if(typeof(fn2) == "function"){
							fn2.call(this);
						}
						$(this).parents("#dialog").hide();
					}
				}, 
				title:title, 
				model:true,
				bgColor: "",
				_top:"40%",
				autoHideCallBack:function(){},
				theme:"light",
				global:false
			};
		var buttons = {};
		if(fn1 instanceof Array && fn2 instanceof Array){
			if(fn1.length == 2 && typeof(fn1[1]) == "function"){
				buttons[fn1[0]] = function(){
					fn1[1].call(this);
					$(this).parents("#dialog").hide();
				};
			}
			if(fn2.length == 2 && typeof(fn2[1]) == "function"){
				buttons[fn2[0]] = function(){
					fn2[1].call(this);
					$(this).parents("#dialog").hide();
				};
			}
			params.buttons = buttons;
		}else if(fn1 instanceof Array){
			if(fn1.length == 2 && typeof(fn1[1]) == "function"){
				buttons[fn1[0]] = function(){
					fn1[1].call(this);
					$(this).parents("#dialog").hide();
				};
			}
			buttons["取消"] = function(){
				$(this).parents("#dialog").hide();
			};
			params.buttons = buttons;
		}else if(fn1 instanceof Array){
			buttons["确认"] = function(){
				$(this).parents("#dialog").hide();
			};
			if(fn2.length == 2 && typeof(fn2[1]) == "function"){
				buttons[fn2[0]] = function(){
					fn2[1].call(this);
					$(this).parents("#dialog").hide();
				};
			}
			params.buttons = buttons;
		}
		_top.Dialog(params);
	}else{
		if(!confirm(msg)){
			if(typeof(fn1) == "function"){
				fn1.call(this);
			}else if(fn1 instanceof Array && typeof(fn1[1]) == "function"){
				fn1[1].call(this);
			}
		}else{
			if(typeof(fn2) == "function"){
				fn2.call(this);
			}else if(fn2 instanceof Array && typeof(fn2[1]) == "function"){
				fn2[1].call(this);
			}
		}
	}
};

Mobile_NS.imgLazyload = function($wrap, imgExpr, containerExpr){
	if(!imgExpr){
		imgExpr = "img.lazy";
	}
	if(!containerExpr){
		containerExpr = "#scroll_wrapper";
        $wrap.parents().each(function(){
            var c = $(this).css("overflow-y").toLowerCase();
            if(c == "scroll" || c == "auto"){
                containerExpr = this;
                return false;
            }
        });
	}
	anonymousFiledownProcess($wrap);
	var $img;
	if($wrap){
		$img = $(imgExpr, $wrap);
	}else{
		$img = $(imgExpr);
	}
	$img.lazyload({
        container : containerExpr,
        failurelimit : 10
	});
};

Mobile_NS.isOnline = function(callbackFn){
	if(typeof(callbackFn) == "function"){
		if(!window.onlinejs){
			Mobile_NS.addJs("/mobilemode/js/online/online.js", function(){
				callbackFn.call(this, window.onLine);
			});
		}else{
			callbackFn.call(this, window.onLine);
		}
		
	}
};

Mobile_NS.getLayoutUrl = function(modelid, uitype, billid){
	if(typeof(uitype) == "undefined") uitype = "0";
	var url = "/mobilemode/layout.jsp?appid=" + appid + "&modelid=" + modelid + "&uitype=" + uitype;
	if(typeof(billid) != "undefined") url += "&billid=" + billid;
	return url;
};

Mobile_NS.callMobile = function(tel, type){
	if(!tel){
		Mobile_NS.Alert('电话号码为空');
	}else if(_top && typeof(_top.addDialogCover) == "function" && type == undefined){
		var telFace = tel;
		if(tel.length == 11 && tel.indexOf("-") == -1){ //手机号
			telFace = tel.substring(0, 3) + "-" + tel.substring(3, 7) + "-" + tel.substring(7);
		}
		_top.addDialogCover([
      		{id : "a", menuText : "<div style='text-align: center;margin-left: -18px;font-size: 20px;color: #017afd;'>呼叫&nbsp;"+telFace+"</div>", callback : function(){
				_top.location.href = "tel:" + tel;
      		}},
      		{id : "b", menuText : "<div style='text-align: center;margin-left: -18px;font-size: 20px;color: #017afd;'>发送短信</div>", callback : function(){
				_top.location.href = "sms:" + tel;
      		}}
      	]);
	}else if(type == 'sms'){
		if(navigator.userAgent.toLowerCase().match(/iphone|ipad/i) != null){
			window.top.location.href = "sms:" + tel;
		}else{
			window.location.href = "sms:" + tel;
		}
	}else{
		if(navigator.userAgent.toLowerCase().match(/iphone|ipad/i) != null){
			window.top.location.href = "tel:" + tel;
		}else{
			window.location.href = "tel:" + tel;
		}
	}
};

Mobile_NS.doRefreshRemind = function(mecid){
	var mecidArr = [];
	if(mecid){
		mecidArr.push(mecid);
	}else{
		$(".MEC_NumberRemind").each(function(){
			var $abbr = $(this).closest("abbr");
			var id = $abbr.attr("id").substring("abbr_".length);
			if(mecidArr.toString().indexOf(id) == -1){
				mecidArr.push(id);
			}
		});
	}

	var url = jionActionUrl("com.weaver.formmodel.mobile.mec.servlet.MECAction", "action=getRemindNums&ids="+mecidArr.toString());
	Mobile_NS.ajax(url, Mobile_NS.pageParams, function(responseText){
		var result = $.parseJSON(responseText);
 		var status = result["status"];
 		if(status == "1"){	
 			var data = result["data"];
 			for(var id in data){
 				var valueArr = data[id];
 				var $abbr = $("#abbr_" + id);
 				$(".MEC_NumberRemind", $abbr).each(function(i){
 					var value = valueArr[i];
 					if(!isNaN(value) && Number(value) > 0){
 						var remindclass = "MEC_NumberRemind" + value.length;
 						$(this)[0].className = "MEC_NumberRemind";
 						$(this).addClass(remindclass).html(value).show();
 					}else{
 						$(this).hide();
 					}
 					
 				});
 			}
 		}else{
 			console.error("Mobile_NS.refreshRemind Error:" + result["errorMsg"]);
 		}
	});
	
};

Mobile_NS.refreshRemind = function(id, mecid){
	
	function refreshRemindInner(id, mecid, theWin){
		
		if(id.indexOf(".") != -1){
			var _id = id.substring(0, id.indexOf("."));
			var _id2 = id.substring(id.indexOf(".") + 1);
			
			var $frame = theWin.$("#appHomepageFrame_" + _id);
			if($frame.length == 0){
				$frame = theWin.$("iframe[pageid='appHomepageFrame_"+_id+"']");
			}
			if($frame.length > 0){
				var frameWin = $frame[0].contentWindow;
				refreshRemindInner(_id2, mecid, frameWin);
			}
		}else{
			var $frame = theWin.$("#appHomepageFrame_" + id);
			if($frame.length == 0){
				$frame = theWin.$("iframe[pageid='appHomepageFrame_"+id+"']");
			}
			if($frame.length > 0){
				try{
					var frameWin = $frame[0].contentWindow;
					frameWin.Mobile_NS.doRefreshRemind(mecid);
				}catch(e){
					Mobile_NS.log(e);
				}
			}
		}
	}
	
	if(typeof(id) == "undefined"){
		Mobile_NS.doRefreshRemind();
	}else if(id.length == 32){
		Mobile_NS.doRefreshRemind(id);
	}else{
		refreshRemindInner(id, mecid, _top);
	}
	
};

Mobile_NS.refreshList = function(mec_id, listparams, callbackFn){
	if(!mec_id || mec_id == ""){	//没有列表组件id,取页面第一个列表组件的id
		$("abbr[m_type]").each(function(){
			var t = $(this).attr("m_type");
			if(t == "List" || t == "UrlList" || t == "Timelinr" || t == "GridTable" || t == "UrlGridTable"){
				mec_id = $(this).attr("id").substring("abbr_".length);
				return false;
			}
		});
	}
	
	if(!mec_id || mec_id == ""){
		return;
	}
	var $abbr = $("#abbr_" + mec_id);
	var type = $abbr.attr("m_type");
	if(!(type == "List" || type == "UrlList" || type == "Timelinr" || type == "GridTable" || type == "UrlGridTable")){
		console.error("不支持的插件类型调用refreshList脚本:" + type);
		return;
	}
	
	if(type == "List" || type == "UrlList"){
		Mobile_NS.List.refreshList(mec_id, listparams, callbackFn);
		return;
	}
	if(type == "Timelinr"){
		Mobile_NS.refreshTimelinr(mec_id, listparams, callbackFn);
		return;
	}
	if(type == "GridTable"){
		Mobile_NS.GridTable.refresh(mec_id, listparams, callbackFn);
		return;
	}
	if(type == "UrlGridTable"){
		Mobile_NS.UrlGridTable.refresh(mec_id, listparams, callbackFn);
		return;
	}
};

Mobile_NS.dateDiff = function(startDate, endDate){
	var startTime = new Date(Date.parse(startDate.replace(/-/g,   "/"))).getTime();     
    var endTime = new Date(Date.parse(endDate.replace(/-/g,   "/"))).getTime();     
    var dates = (endTime - startTime)/(1000*60*60*24);     
    return dates;  
};

Mobile_NS.sendEmobileMsg = function(receivers, content, msgurl, msgtype, callbackFn){
	if(typeof(msgtype) == "function"){
		callbackFn = msgtype;
		msgtype = "";
	}
	Mobile_NS.sendMsg(1, receivers, content, msgurl, msgtype, "", callbackFn);
};

Mobile_NS.sendWechatMsg = function(receivers, content, msgurl, pushkey, callbackFn){
	Mobile_NS.sendMsg(2, receivers, content, msgurl, "", pushkey, callbackFn);
};

Mobile_NS.sendMsg = function(pushtype, receivers, content, msgurl, msgtype, pushkey, callbackFn){
	var url = jionActionUrl("com.weaver.formmodel.mobile.pushmsg.servlet.PushMsgAction", "action=pushmsg");
	var params = {pushtype:pushtype,receivers:receivers,content:content,msgurl:msgurl,wechatpushkey:pushkey};
	if(msgtype) params.msgtype = msgtype;
	Mobile_NS.ajax(url, params, function(responseText){
		var result = $.parseJSON(responseText);
 		var status = result["status"];
 		if(status == "1"){
 			if(typeof(callbackFn) == "function"){
 				callbackFn.call(this);
 			}else{
 				Mobile_NS.Alert("发送提醒成功");
 			}
 			
 		}else{
 			Mobile_NS.Alert("Mobile_NS.sendWechatMsg Error:" + result["errorMsg"], false);
 			console.error("Mobile_NS.sendWechatMsg Error:" + result["errorMsg"]);
 		}
	});
};

Mobile_NS.formatNumber = function(num, pattern) {
	if(!pattern){
	    return num;
	}
	var vprefix = "";
	var vsuffix = "";
	var m = /^\[(.*?)\]/.exec(pattern);
	if(m) {
		vprefix = m[1];
	}				
	m = /.*\[([^\]]*)\]$/.exec(pattern);
	if(m) {
		vsuffix = m[1];
	}
	if(vprefix.length > 0 && vprefix == vsuffix){
		var pstr = pattern.substring(1,pattern.length - 1);
		if(vsuffix == pstr) vprefix = "";
	}
	pattern = pattern.replace(/\[.*?\]/g,'');
    if (!isNaN(parseFloat(num)) && isFinite(num) && pattern.length > 0) {
		var comma = false;  
		if(pattern.indexOf("#,##") != -1) comma = true;  				
		var fmtarr = pattern ? pattern.split('.') : [''];
		var precision = -1;
		if(fmtarr.length > 1){
			if(fmtarr[1].length > 0 && fmtarr[1].match(/0/g)){
				precision = fmtarr[1].match(/0/g).length;
			}else{
				precision = 0;
			}
		}
		var parts;
        num = Number(num);
	    num = (precision !== -1 ? num.toFixed(precision) : num).toString(); 
        parts = num.split('.');
        if(comma){
	        parts[0] = parts[0].toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1' + (','));
        }
        num = parts.join('.');
    }
    return vprefix + num + vsuffix;
};