You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

634 lines
17 KiB

  1. ////导入常用JS
  2. //writeJS('js/jquery-2.2.4.min.js');
  3. //writeJS('js/date-time/bootstrap-datepicker.min.js');
  4. //writeJS('js/date-time/bootstrap-timepicker.min.js');
  5. //writeJS('My97DatePicker/WdatePicker.js');
  6. //writeJS('js/master.js');
  7. //writeJS('js/jquery.page.js');
  8. //writeJS('js/jquery.cookie.js');
  9. //writeJS('js/xm.js'); //判断登录
  10. //导入CSS
  11. // 导入JS文件
  12. //function writeJS(jsStr) {
  13. // var cstr = '<script type="text/javascript" src="' + jsStr + '"></script>';
  14. // document.write(cstr);
  15. //}
  16. //// 导入CSS
  17. //function writeCSS(cssStr){
  18. // var cstr = '<link rel="stylesheet" type="text/css" href="./css/'+cssStr+'" />';
  19. // document.write(cstr);
  20. //}
  21. var base_api = "http://cs2.zhizhuchuxing.com/ZZCS/coding/application/"; //绝对路径
  22. base_api = "http://cs.zhizhuchuxing.com/application/";
  23. // base_api="../../application/"; //相对路径
  24. document.write("<link rel='stylesheet' href='../css/xcConfirm.css' />");
  25. document.write("<script type='text/javascript' src='../js/xcConfirm.js' ></script>");
  26. // 打印日志
  27. function ZZLog() {
  28. var isLog = true; //是否打印
  29. var isSign = false; //是否签名
  30. if(isLog) {
  31. if(isSign){
  32. //如果要加前缀
  33. var args = Array.prototype.slice.call(arguments);
  34. args.unshift('[ZZCX:DeBug:Log]');
  35. console.log.apply(console,args);
  36. }else{
  37. console.log.apply(console,arguments);
  38. }
  39. }
  40. }
  41. //需要成功回调的弹出框
  42. function ZZAlertInfo(info, callok,callcancel,callclose) {
  43. window.wxc.xcConfirm(info, window.wxc.xcConfirm.typeEnum.info, {
  44. onOk: function() {
  45. if(callok) {
  46. callok();
  47. }
  48. },
  49. onCancel: function() {
  50. if(callcancel) {
  51. callcancel();
  52. }
  53. },
  54. onClose: function() {
  55. if(callclose) {
  56. callclose();
  57. }
  58. }
  59. });
  60. }
  61. //确认框(提示信息,成功回调,取消回调,关闭回调)
  62. function ZZConfirm(info, callok, callcancel, callclose) {
  63. window.wxc.xcConfirm(info, window.wxc.xcConfirm.typeEnum.confirm, {
  64. onOk: function() {
  65. if(callok) {
  66. callok();
  67. }
  68. },
  69. onCancel: function() {
  70. if(callcancel) {
  71. callcancel();
  72. }
  73. },
  74. onClose: function() {
  75. if(callclose) {
  76. callclose();
  77. }
  78. }
  79. })
  80. }
  81. //输入框(输入的信息,成功回调,关闭的回调)
  82. function ZZInput(info, callok, callclose) {
  83. window.wxc.xcConfirm(info, window.wxc.xcConfirm.typeEnum.input, {
  84. onOk: function(ok) {
  85. callok(ok);
  86. },
  87. onClose: function(close) {
  88. callclose(close);
  89. }
  90. });
  91. }
  92. //处理angular POST请求跨域问题 在创建angular app后调用
  93. function setAngularJSApp(app) {
  94. app.config(function($httpProvider) {
  95. $httpProvider.defaults.transformRequest = function(obj) {
  96. var str = [];
  97. for(var p in obj) {
  98. str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
  99. }
  100. return str.join("&");
  101. };
  102. $httpProvider.defaults.headers.post = {
  103. 'Content-Type': 'application/x-www-form-urlencoded'
  104. }
  105. })
  106. }
  107. //设置字符串类型的本地缓存
  108. function setStorage(objName, objValue) {
  109. var sto = window.localStorage;
  110. if(sto)
  111. sto.setItem(objName, objValue);
  112. }
  113. //读取字符串类型的本地缓存
  114. function getStorage(objName) {
  115. var ret = '';
  116. var sto = window.localStorage;
  117. if(sto)
  118. ret = sto.getItem(objName);
  119. return ret;
  120. }
  121. //清除本地缓存,如没指定名称则为清空所有缓存
  122. function clearStorage(objName) {
  123. var sto = window.localStorage;
  124. if(sto) {
  125. if(objName)
  126. sto.removeItem(objName);
  127. else
  128. sto.clear();
  129. }
  130. }
  131. //设置Json类型的本地缓存
  132. function setStorJson(objName, json) {
  133. if(json)
  134. setStorage(objName, JSON.stringify(json));
  135. }
  136. //读取Json类型的本地缓存
  137. function getStorJson(objName) {
  138. var ret = null;
  139. var str = getStorage(objName);
  140. if(str)
  141. ret = JSON.parse(str);
  142. return ret;
  143. }
  144. //js判断一个日期是星期几 传入 年/月/日
  145. function getWeekDay(day) {
  146. var a = new Array("日", "一", "二", "三", "四", "五", "六");
  147. var week = new Date(day).getDay();
  148. var str = "星期" + a[week];
  149. return str;
  150. }
  151. //获取前一天日期
  152. function before(d) {
  153. d = new Date(d);
  154. d = +d - 10006060 / 3 * 24;
  155. d = new Date(d);
  156. //return d;
  157. //格式化
  158. var year = ";" + d.getFullYear() + ";";
  159. var month = ";" + (d.getMonth() + 0 + 1) + ";";
  160. var day = ";" + d.getDate() + ";";
  161. if(year.length < 4) {
  162. year = "0" + year;
  163. }
  164. if(month.length < 4) {
  165. month = "0" + month;
  166. }
  167. if(day.length < 4) {
  168. day = "0" + day;
  169. }
  170. var datestr = year + "-" + month + "-" + day;
  171. datestr = datestr.replace(/;/g, "");
  172. return datestr;
  173. // return d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate();
  174. }
  175. // 获取指定日期的前后几天
  176. function getDateByDay(addDayCount, curDate) {
  177. var d = new Date(curDate);
  178. d.setDate(d.getDate() + addDayCount); //获取AddDayCount天后的日期
  179. //格式化
  180. var year = ";" + d.getFullYear() + ";";
  181. var month = ";" + (d.getMonth() + 0 + 1) + ";";
  182. var day = ";" + d.getDate() + ";";
  183. if(year.length < 4) {
  184. year = "0" + year;
  185. }
  186. if(month.length < 4) {
  187. month = "0" + month;
  188. }
  189. if(day.length < 4) {
  190. day = "0" + day;
  191. }
  192. var datestr = year + "-" + month + "-" + day;
  193. datestr = datestr.replace(/;/g, "");
  194. return datestr;
  195. }
  196. //获取后一天日期
  197. function after(d) {
  198. d = new Date(d);
  199. d = +d + 10006060 / 3 * 24;
  200. d = new Date(d);
  201. //return d;
  202. //格式化
  203. var year = ";" + d.getFullYear() + ";";
  204. var month = ";" + (d.getMonth() + 0 + 1) + ";";
  205. var day = ";" + d.getDate() + ";";
  206. if(year.length < 4) {
  207. year = "0" + year;
  208. }
  209. if(month.length < 4) {
  210. month = "0" + month;
  211. }
  212. if(day.length < 4) {
  213. day = "0" + day;
  214. }
  215. var datestr = year + "-" + month + "-" + day;
  216. datestr = datestr.replace(/;/g, "");
  217. return datestr;
  218. // return d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate();
  219. }
  220. // 从URL上获得参数
  221. function getPar(par) {
  222. //获取当前URL
  223. var local_url = document.location.href;
  224. local_url = decodeURI(local_url);
  225. //获取要取得的get参数位置
  226. var get = local_url.indexOf(par + "=");
  227. if(get == -1) {
  228. return "";
  229. }
  230. //截取字符串
  231. var get_par = local_url.slice(par.length + get + 1);
  232. //判断截取后的字符串是否还有其他get参数
  233. var nextPar = get_par.indexOf("&");
  234. if(nextPar != -1) {
  235. get_par = get_par.slice(0, nextPar);
  236. }
  237. return get_par;
  238. }
  239. //得到时间组合
  240. function getDateTime(nTypeFlag) {
  241. var tNowTime = new Date();
  242. var myYear = ';' + tNowTime.getFullYear() + ';';
  243. var myMonth = ';' + (tNowTime.getMonth() + 1 - 0) + ';';
  244. var myDay = ';' + tNowTime.getDate() + ';';
  245. var myHour = ';' + tNowTime.getHours() + ';';
  246. var myMinu = ';' + tNowTime.getMinutes() + ';';
  247. var mySecond = ';' + tNowTime.getSeconds() + ';';
  248. if(myMonth.length < 4) myMonth = '0' + myMonth;
  249. if(myDay.length < 4) myDay = '0' + myDay;
  250. if(myHour.length < 4) myHour = '0' + myHour;
  251. if(myMinu.length < 4) myMinu = '0' + myMinu;
  252. if(mySecond.length < 4) mySecond = '0' + mySecond;
  253. var cNewTimeStr;
  254. //alert(tNowTime);
  255. switch(nTypeFlag + 1 - 1) {
  256. case 0:
  257. cNewTimeStr = myYear + '-' + myMonth + '-' + myDay;
  258. break;
  259. case 1:
  260. cNewTimeStr = myYear + myMonth + myDay;
  261. break;
  262. case 2:
  263. cNewTimeStr = myHour + ':' + myMinu + ':' + mySecond;
  264. break;
  265. case 3:
  266. cNewTimeStr = myHour + myMinu + mySecond;
  267. break;
  268. case 4:
  269. cNewTimeStr = myYear + myMonth + myDay + myHour + myMinu + mySecond;
  270. break;
  271. case 5:
  272. cNewTimeStr = myYear + '年' + myMonth + '月' + myDay + '日';
  273. break;
  274. case 6:
  275. cNewTimeStr = myYear;
  276. break;
  277. case 7:
  278. cNewTimeStr = myYear + '-' + myMonth;
  279. break;
  280. case 8: //得到上一个月的今天
  281. var date = getDateTime(0);
  282. var arr = date.split('-');
  283. var year = arr[0]; //获取当前日期的年份
  284. var month = arr[1]; //获取当前日期的月份
  285. var day = arr[2]; //获取当前日期的日
  286. var days = new Date(year, month, 0);
  287. days = days.getDate(); //获取当前日期中月的天数
  288. var year2 = year;
  289. var month2 = parseInt(month) - 1;
  290. if(month2 == 0) {
  291. year2 = parseInt(year2) - 1;
  292. month2 = 12;
  293. }
  294. var day2 = day;
  295. var days2 = new Date(year2, month2, 0);
  296. days2 = days2.getDate();
  297. if(day2 > days2) {
  298. day2 = days2;
  299. }
  300. if(month2 < 10) {
  301. month2 = '0' + month2;
  302. }
  303. cNewTimeStr = year2 + '-' + month2 + '-' + day2;
  304. break;
  305. case 9: //得到下一个月的今天
  306. var date = getDateTime(0);
  307. var arr = date.split('-');
  308. var year = arr[0]; //获取当前日期的年份
  309. var month = arr[1]; //获取当前日期的月份
  310. var day = arr[2]; //获取当前日期的日
  311. var days = new Date(year, month, 0);
  312. days = days.getDate(); //获取当前日期中的月的天数
  313. var year2 = year;
  314. var month2 = parseInt(month) + 1;
  315. if(month2 == 13) {
  316. year2 = parseInt(year2) + 1;
  317. month2 = 1;
  318. }
  319. var day2 = day;
  320. var days2 = new Date(year2, month2, 0);
  321. days2 = days2.getDate();
  322. if(day2 > days2) {
  323. day2 = days2;
  324. }
  325. if(month2 < 10) {
  326. month2 = '0' + month2;
  327. }
  328. var t2 = year2 + '-' + month2 + '-' + day2;
  329. return t2;
  330. break;
  331. case 10: //昨日日期
  332. //获取前一天日期
  333. return before(getDateTime(0));
  334. function before(d) {
  335. d = new Date(d);
  336. d = +d - 10006060 / 3 * 24;
  337. d = new Date(d);
  338. //return d;
  339. //格式化
  340. var year = ";" + d.getFullYear() + ";";
  341. var month = ";" + (d.getMonth() + 0 + 1) + ";";
  342. var day = ";" + d.getDate() + ";";
  343. if(year.length < 4) {
  344. year = "0" + year;
  345. }
  346. if(month.length < 4) {
  347. month = "0" + month;
  348. }
  349. if(day.length < 4) {
  350. day = "0" + day;
  351. }
  352. var datestr = year + "-" + month + "-" + day;
  353. datestr = datestr.replace(/;/g, "");
  354. return datestr;
  355. // return d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate();
  356. }
  357. break;
  358. case 11: //明日日期
  359. //获取后一天日期
  360. return after(getDateTime(0));
  361. function after(d) {
  362. d = new Date(d);
  363. d = +d + 10006060 / 3 * 24;
  364. d = new Date(d);
  365. //return d;
  366. //格式化
  367. var year = ";" + d.getFullYear() + ";";
  368. var month = ";" + (d.getMonth() + 0 + 1) + ";";
  369. var day = ";" + d.getDate() + ";";
  370. if(year.length < 4) {
  371. year = "0" + year;
  372. }
  373. if(month.length < 4) {
  374. month = "0" + month;
  375. }
  376. if(day.length < 4) {
  377. day = "0" + day;
  378. }
  379. var datestr = year + "-" + month + "-" + day;
  380. datestr = datestr.replace(/;/g, "");
  381. return datestr;
  382. // return d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate();
  383. }
  384. break;
  385. case 12: //本周起始日期
  386. return getWeekStartDate()
  387. function getWeekStartDate() {
  388. var now = new Date(); //当前日期
  389. var nowDayOfWeek = now.getDay(); //今天本周的第几天
  390. var nowDay = now.getDate(); //当前日
  391. var nowMonth = now.getMonth(); //当前月
  392. var nowYear = now.getYear(); //当前年
  393. nowYear += (nowYear < 2000) ? 1900 : 0; //
  394. var lastMonthDate = new Date(); //上月日期
  395. lastMonthDate.setDate(1);
  396. lastMonthDate.setMonth(lastMonthDate.getMonth() - 1);
  397. var lastYear = lastMonthDate.getYear();
  398. var lastMonth = lastMonthDate.getMonth();
  399. var weekStartDate = new Date(nowYear, nowMonth, nowDay - nowDayOfWeek);
  400. return formatDate(weekStartDate);
  401. }
  402. break;
  403. case 13: //本周结束日期
  404. return getWeekEndDate()
  405. function getWeekEndDate() {
  406. var now = new Date(); //当前日期
  407. var nowDayOfWeek = now.getDay(); //今天本周的第几天
  408. var nowDay = now.getDate(); //当前日
  409. var nowMonth = now.getMonth(); //当前月
  410. var nowYear = now.getYear(); //当前年
  411. nowYear += (nowYear < 2000) ? 1900 : 0; //
  412. var lastMonthDate = new Date(); //上月日期
  413. lastMonthDate.setDate(1);
  414. lastMonthDate.setMonth(lastMonthDate.getMonth() - 1);
  415. var lastYear = lastMonthDate.getYear();
  416. var lastMonth = lastMonthDate.getMonth();
  417. var weekEndDate = new Date(nowYear, nowMonth, nowDay + (6 - nowDayOfWeek));
  418. return formatDate(weekEndDate);
  419. }
  420. break;
  421. case 14: //本月开始日期
  422. return getMonthStartDate()
  423. function getMonthStartDate() {
  424. var now = new Date(); //当前日期
  425. var nowDayOfWeek = now.getDay(); //今天本周的第几天
  426. var nowDay = now.getDate(); //当前日
  427. var nowMonth = now.getMonth(); //当前月
  428. var nowYear = now.getYear(); //当前年
  429. nowYear += (nowYear < 2000) ? 1900 : 0; //
  430. var lastMonthDate = new Date(); //上月日期
  431. lastMonthDate.setDate(1);
  432. lastMonthDate.setMonth(lastMonthDate.getMonth() - 1);
  433. var lastYear = lastMonthDate.getYear();
  434. var lastMonth = lastMonthDate.getMonth();
  435. var monthStartDate = new Date(nowYear, nowMonth, 1);
  436. return formatDate(monthStartDate);
  437. }
  438. break;
  439. case 15: //本月结束日期
  440. return getMonthEndDate();
  441. function getMonthEndDate() {
  442. var now = new Date(); //当前日期
  443. var nowDayOfWeek = now.getDay(); //今天本周的第几天
  444. var nowDay = now.getDate(); //当前日
  445. var nowMonth = now.getMonth(); //当前月
  446. var nowYear = now.getYear(); //当前年
  447. nowYear += (nowYear < 2000) ? 1900 : 0; //
  448. var lastMonthDate = new Date(); //上月日期
  449. lastMonthDate.setDate(1);
  450. lastMonthDate.setMonth(lastMonthDate.getMonth() - 1);
  451. var lastYear = lastMonthDate.getYear();
  452. var lastMonth = lastMonthDate.getMonth();
  453. //获得某月的天数
  454. function getMonthDays(myMonth) {
  455. var monthStartDate = new Date(nowYear, myMonth, 1);
  456. var monthEndDate = new Date(nowYear, myMonth + 1, 1);
  457. var days = (monthEndDate - monthStartDate) / (1000 * 60 * 60 * 24);
  458. return days;
  459. }
  460. var monthEndDate = new Date(nowYear, nowMonth, getMonthDays(nowMonth));
  461. return formatDate(monthEndDate);
  462. }
  463. break;
  464. default:
  465. cNewTimeStr = myYear + '-' + myMonth + '-' + myDay + ' ' + myHour + ':' + myMinu + ':' + mySecond;
  466. break;
  467. }
  468. cNewTimeStr = cNewTimeStr.replace(/;/g, "");
  469. return cNewTimeStr;
  470. }
  471. //case 12,13的规整函数
  472. function formatDate(date) {
  473. var myyear = date.getFullYear();
  474. var mymonth = date.getMonth() + 1;
  475. var myweekday = date.getDate();
  476. if(mymonth < 10) {
  477. mymonth = "0" + mymonth;
  478. }
  479. if(myweekday < 10) {
  480. myweekday = "0" + myweekday;
  481. }
  482. return(myyear + "-" + mymonth + "-" + myweekday);
  483. }
  484. //html存入json
  485. function setJsonHtml(data) {
  486. if(typeof(data) == "object") {
  487. var jsonArrayFinal = JSON.stringify(data);
  488. jsonArrayFinal = jsonArrayFinal.replace(/ /g, '');
  489. jsonArrayFinal = jsonArrayFinal.replace(/"/g, '&quot;');
  490. return jsonArrayFinal;
  491. }
  492. }
  493. //取出html存入的json
  494. function getJsonHtml(data) {
  495. if(data) {
  496. var data_info = JSON.parse(data);
  497. return data_info;
  498. }
  499. }
  500. //解决冒泡
  501. function solveBubbing() {
  502. // if($.browser.mozilla)
  503. // {
  504. // var $E = function(){var c=$E.caller; while(c.caller)c=c.caller; return c.arguments[0]};
  505. // __defineGetter__("event", $E);
  506. // }
  507. // var e = window.event || event;
  508. // if(e.stopPropagation) { //如果提供了事件对象,则这是一个非IE浏览器
  509. // e.stopPropagation();
  510. // } else {
  511. // //兼容IE的方式来取消事件冒泡
  512. // window.event.cancelBubble = true;
  513. // }
  514. var e=getEvent();
  515. if(window.event){
  516. //e.returnValue=false;//阻止自身行为
  517. e.cancelBubble=true;//阻止冒泡
  518. }else if(e.preventDefault){
  519. //e.preventDefault();//阻止自身行为
  520. e.stopPropagation();//阻止冒泡
  521. }
  522. }
  523. //得到事件
  524. function getEvent(){
  525. if(window.event) {return window.event;}
  526. func=getEvent.caller;
  527. while(func!=null){
  528. var arg0=func.arguments[0];
  529. if(arg0){
  530. if((arg0.constructor==Event || arg0.constructor ==MouseEvent
  531. || arg0.constructor==KeyboardEvent)
  532. ||(typeof(arg0)=="object" && arg0.preventDefault
  533. && arg0.stopPropagation)){
  534. return arg0;
  535. }
  536. }
  537. func=func.caller;
  538. }
  539. return null;
  540. }
  541. //得到浏览器
  542. function myBrowser() {
  543. var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串
  544. var isOpera = userAgent.indexOf("Opera") > -1;
  545. //判断是否Opera浏览器
  546. if(isOpera) {
  547. return "Opera"
  548. };
  549. //判断是否Firefox浏览器
  550. if(userAgent.indexOf("Firefox") > -1) {
  551. return "Firefox";
  552. }
  553. //判断是否Chrome浏览器
  554. if(userAgent.indexOf("Chrome") > -1) {
  555. return "Chrome";
  556. }
  557. //判断是否Safari浏览器
  558. if(userAgent.indexOf("Safari") > -1) {
  559. return "Safari";
  560. }
  561. if(userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1 && !isOpera) {
  562. return "IE";
  563. }; //判断是否IE浏览器
  564. }
  565. /**
  566. * 加载时尽量考虑什么时候关闭,否则15秒后自动关闭
  567. */
  568. function loading(time) {
  569. var newDiv = '<div id="screen-cover" class="loader-inner ball-beat" style="width: 100%; height: 100%; position: absolute; top: 0; left: 0; background-color: rgba(0,0,0,0.5); text-align: center; z-index: 9999;' +
  570. '"><div class="on"></div><div class="off"></div><div class="on"></div>' +
  571. '</div>';
  572. if(typeof $("#screen-cover") != 'undefined')
  573. $("#screen-cover").remove();
  574. $("<link>")
  575. .attr({ rel: "stylesheet",
  576. type: "text/css",
  577. href: "/css/loader.css"
  578. })
  579. .appendTo("head");
  580. $("html").append(newDiv);
  581. $("#screen-cover").css('padding-top', $(window).height() / 2 - 55);
  582. // if(typeof time == 'undefined')
  583. // time = 15000;
  584. // setTimeout('closeLoading()',time);
  585. }
  586. function closeLoading() {
  587. if($("#screen-cover").length > 0)
  588. $("#screen-cover").remove();
  589. }