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.

common.js 22 KiB

3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809
  1. var base_api = "http://127.0.0.1/ZZCX_HT_2.0/st-ht/HTcontrol.php";
  2. base_api = "http://temp.zhizhuchuxing.com/zz-jd/st-ht/HTcontrol.php";
  3. base_api = "../st-ht/HTcontrol.php";
  4. base_api = "/zz-jd/st-ht/HTcontrol.php";
  5. //错误码
  6. //code FX-100001 未登录
  7. //提示信息归整
  8. var infoApiError = "服务器开小差了,请联系技术部相关人员";
  9. var infoNotLogin = "您还没有登录,点击确定前往登录页面";
  10. //延迟函数 需要将延迟处理的函数放在delay的回调中
  11. //$('#id').keyup(function() {
  12. // delay(function() {
  13. // console.log('test');
  14. // }, 1000);
  15. // });
  16. var delay = (function() {
  17. var timer = 0;
  18. return function(callback, time) {
  19. clearTimeout(timer);
  20. timer = setTimeout(callback, time);
  21. };
  22. })();
  23. //得到随机的字符串
  24. function getRdStr(len) {
  25. //2-36封顶
  26. var rdmString = "";
  27. for(; rdmString.length < len; rdmString += Math.random().toString(36).substr(2));
  28. return rdmString.substr(0, len);
  29. }
  30. // 打印日志
  31. //function ZZLog(...type) {
  32. function ZZLog() {
  33. // var isLog = true; //是否打印
  34. // if(isLog) {
  35. // type.forEach(v => {
  36. // if(typeof(v) == 'object') {
  37. // console.log(v);
  38. // } else {
  39. // console.log('%c' + v, 'color:#666699');
  40. // }
  41. // })
  42. // }
  43. var isLog = true; //是否打印
  44. var isSign = false; //是否签名
  45. if (isLog) {
  46. if (isSign) {
  47. //如果要加前缀
  48. var args = Array.prototype.slice.call(arguments);
  49. args.unshift('[ZZCX:DeBug:Log]');
  50. console.log.apply(console, args);
  51. } else {
  52. console.log.apply(console, arguments);
  53. }
  54. }
  55. }
  56. function setCookie(name, value, time) {
  57. var strsec = getsec(time);
  58. var exp = new Date();
  59. exp.setTime(exp.getTime() + strsec * 1);
  60. document.cookie = name + "=" + escape(value) + ";expires=" + exp.toGMTString();
  61. function getsec(str) {
  62. var str1 = str.substring(1, str.length) * 1;
  63. var str2 = str.substring(0, 1);
  64. if(str2 == "s") {
  65. return str1 * 1000;
  66. } else if(str2 == "h") {
  67. return str1 * 60 * 60 * 1000;
  68. } else if(str2 == "d") {
  69. return str1 * 24 * 60 * 60 * 1000;
  70. }
  71. }
  72. }
  73. function delCookie(name) {
  74. var exp = new Date();
  75. exp.setTime(exp.getTime() - 1);
  76. var cval = getCookie(name);
  77. if(cval != null)
  78. document.cookie = name + "=" + cval + ";expires=" + exp.toGMTString();
  79. }
  80. function getCookie(name) {
  81. var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
  82. if(arr = document.cookie.match(reg))
  83. return unescape(arr[2]);
  84. else
  85. return null;
  86. }
  87. //设置字符串类型的本地缓存
  88. function setStorage(objName, objValue) {
  89. var sto = window.localStorage;
  90. if(sto)
  91. sto.setItem(objName, objValue);
  92. }
  93. //读取字符串类型的本地缓存
  94. function getStorage(objName) {
  95. var ret = '';
  96. var sto = window.localStorage;
  97. if(sto)
  98. ret = sto.getItem(objName);
  99. return ret;
  100. }
  101. //清除本地缓存,如没指定名称则为清空所有缓存
  102. function clearStorage(objName) {
  103. var sto = window.localStorage;
  104. if(sto) {
  105. if(objName)
  106. sto.removeItem(objName);
  107. else
  108. sto.clear();
  109. }
  110. }
  111. //设置Json类型的本地缓存
  112. function setStorJson(objName, json) {
  113. if(json)
  114. setStorage(objName, JSON.stringify(json));
  115. }
  116. //读取Json类型的本地缓存
  117. function getStorJson(objName) {
  118. var ret = null;
  119. var str = getStorage(objName);
  120. if(str)
  121. ret = JSON.parse(str);
  122. return ret;
  123. }
  124. //js判断一个日期是星期几 传入 年/月/日
  125. function getWeekDay(day) {
  126. var a = new Array("日", "一", "二", "三", "四", "五", "六");
  127. var week = new Date(day).getDay();
  128. var str = "星期" + a[week];
  129. return str;
  130. }
  131. //获取前一天日期 传入指定时间
  132. function before(d) {
  133. d = new Date(d);
  134. d = +d - 10006060 / 3 * 24;
  135. d = new Date(d);
  136. //格式化
  137. var year = ";" + d.getFullYear() + ";";
  138. var month = ";" + (d.getMonth() + 0 + 1) + ";";
  139. var day = ";" + d.getDate() + ";";
  140. if(year.length < 4) {
  141. year = "0" + year;
  142. }
  143. if(month.length < 4) {
  144. month = "0" + month;
  145. }
  146. if(day.length < 4) {
  147. day = "0" + day;
  148. }
  149. var datestr = year + "-" + month + "-" + day;
  150. datestr = datestr.replace(/;/g, "");
  151. return datestr;
  152. }
  153. // 获取指定日期的前后几天
  154. function getDateByDay(addDayCount, curDate) {
  155. var d = new Date(curDate);
  156. d.setDate(d.getDate() + addDayCount); //获取AddDayCount天后的日期
  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. }
  174. //获取后一天日期 传入指定时间
  175. function after(d) {
  176. d = new Date(d);
  177. d = +d + 10006060 / 3 * 24;
  178. d = new Date(d);
  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. // 从URL上获得参数
  197. function getPar(par) {
  198. //获取当前URL
  199. var local_url = document.location.href;
  200. local_url = decodeURI(local_url);
  201. //获取要取得的get参数位置
  202. var get = local_url.indexOf(par + "=");
  203. if(get == -1) {
  204. return "";
  205. }
  206. //截取字符串
  207. var get_par = local_url.slice(par.length + get + 1);
  208. //判断截取后的字符串是否还有其他get参数
  209. var nextPar = get_par.indexOf("&");
  210. if(nextPar != -1) {
  211. get_par = get_par.slice(0, nextPar);
  212. }
  213. return get_par;
  214. }
  215. //得到时间组合
  216. function getDateTime(nTypeFlag) {
  217. var tNowTime = new Date();
  218. var myYear = ';' + tNowTime.getFullYear() + ';';
  219. var myMonth = ';' + (tNowTime.getMonth() + 1 - 0) + ';';
  220. var myDay = ';' + tNowTime.getDate() + ';';
  221. var myHour = ';' + tNowTime.getHours() + ';';
  222. var myMinu = ';' + tNowTime.getMinutes() + ';';
  223. var mySecond = ';' + tNowTime.getSeconds() + ';';
  224. if(myMonth.length < 4) myMonth = '0' + myMonth;
  225. if(myDay.length < 4) myDay = '0' + myDay;
  226. if(myHour.length < 4) myHour = '0' + myHour;
  227. if(myMinu.length < 4) myMinu = '0' + myMinu;
  228. if(mySecond.length < 4) mySecond = '0' + mySecond;
  229. var cNewTimeStr;
  230. //alert(tNowTime);
  231. switch(nTypeFlag + 1 - 1) {
  232. case 0:
  233. cNewTimeStr = myYear + '-' + myMonth + '-' + myDay;
  234. break;
  235. case 1:
  236. cNewTimeStr = myYear + myMonth + myDay;
  237. break;
  238. case 2:
  239. cNewTimeStr = myHour + ':' + myMinu + ':' + mySecond;
  240. break;
  241. case 3:
  242. cNewTimeStr = myHour + myMinu + mySecond;
  243. break;
  244. case 4:
  245. cNewTimeStr = myYear + myMonth + myDay + myHour + myMinu + mySecond;
  246. break;
  247. case 5:
  248. cNewTimeStr = myYear + '年' + myMonth + '月' + myDay + '日';
  249. break;
  250. case 6:
  251. cNewTimeStr = myYear;
  252. break;
  253. case 7:
  254. cNewTimeStr = myYear + '-' + myMonth;
  255. break;
  256. case 8: //得到上一个月的今天
  257. var date = getDateTime(0);
  258. var arr = date.split('-');
  259. var year = arr[0]; //获取当前日期的年份
  260. var month = arr[1]; //获取当前日期的月份
  261. var day = arr[2]; //获取当前日期的日
  262. var days = new Date(year, month, 0);
  263. days = days.getDate(); //获取当前日期中月的天数
  264. var year2 = year;
  265. var month2 = parseInt(month) - 1;
  266. if(month2 == 0) {
  267. year2 = parseInt(year2) - 1;
  268. month2 = 12;
  269. }
  270. var day2 = day;
  271. var days2 = new Date(year2, month2, 0);
  272. days2 = days2.getDate();
  273. if(day2 > days2) {
  274. day2 = days2;
  275. }
  276. if(month2 < 10) {
  277. month2 = '0' + month2;
  278. }
  279. cNewTimeStr = year2 + '-' + month2 + '-' + day2;
  280. break;
  281. case 9: //得到下一个月的今天
  282. var date = getDateTime(0);
  283. var arr = date.split('-');
  284. var year = arr[0]; //获取当前日期的年份
  285. var month = arr[1]; //获取当前日期的月份
  286. var day = arr[2]; //获取当前日期的日
  287. var days = new Date(year, month, 0);
  288. days = days.getDate(); //获取当前日期中的月的天数
  289. var year2 = year;
  290. var month2 = parseInt(month) + 1;
  291. if(month2 == 13) {
  292. year2 = parseInt(year2) + 1;
  293. month2 = 1;
  294. }
  295. var day2 = day;
  296. var days2 = new Date(year2, month2, 0);
  297. days2 = days2.getDate();
  298. if(day2 > days2) {
  299. day2 = days2;
  300. }
  301. if(month2 < 10) {
  302. month2 = '0' + month2;
  303. }
  304. var t2 = year2 + '-' + month2 + '-' + day2;
  305. return t2;
  306. break;
  307. case 10: //昨日日期
  308. //获取前一天日期
  309. return before(getDateTime(0));
  310. function before(d) {
  311. d = new Date(d);
  312. d = +d - 10006060 / 3 * 24;
  313. d = new Date(d);
  314. //return d;
  315. //格式化
  316. var year = ";" + d.getFullYear() + ";";
  317. var month = ";" + (d.getMonth() + 0 + 1) + ";";
  318. var day = ";" + d.getDate() + ";";
  319. if(year.length < 4) {
  320. year = "0" + year;
  321. }
  322. if(month.length < 4) {
  323. month = "0" + month;
  324. }
  325. if(day.length < 4) {
  326. day = "0" + day;
  327. }
  328. var datestr = year + "-" + month + "-" + day;
  329. datestr = datestr.replace(/;/g, "");
  330. return datestr;
  331. // return d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate();
  332. }
  333. break;
  334. case 11: //明日日期
  335. //获取后一天日期
  336. return after(getDateTime(0));
  337. function after(d) {
  338. d = new Date(d);
  339. d = +d + 10006060 / 3 * 24;
  340. d = new Date(d);
  341. //return d;
  342. //格式化
  343. var year = ";" + d.getFullYear() + ";";
  344. var month = ";" + (d.getMonth() + 0 + 1) + ";";
  345. var day = ";" + d.getDate() + ";";
  346. if(year.length < 4) {
  347. year = "0" + year;
  348. }
  349. if(month.length < 4) {
  350. month = "0" + month;
  351. }
  352. if(day.length < 4) {
  353. day = "0" + day;
  354. }
  355. var datestr = year + "-" + month + "-" + day;
  356. datestr = datestr.replace(/;/g, "");
  357. return datestr;
  358. // return d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate();
  359. }
  360. break;
  361. case 12: //本周起始日期
  362. return getWeekStartDate()
  363. function getWeekStartDate() {
  364. var now = new Date(); //当前日期
  365. var nowDayOfWeek = now.getDay(); //今天本周的第几天
  366. var nowDay = now.getDate(); //当前日
  367. var nowMonth = now.getMonth(); //当前月
  368. var nowYear = now.getYear(); //当前年
  369. nowYear += (nowYear < 2000) ? 1900 : 0; //
  370. var lastMonthDate = new Date(); //上月日期
  371. lastMonthDate.setDate(1);
  372. lastMonthDate.setMonth(lastMonthDate.getMonth() - 1);
  373. var lastYear = lastMonthDate.getYear();
  374. var lastMonth = lastMonthDate.getMonth();
  375. var weekStartDate = new Date(nowYear, nowMonth, nowDay - nowDayOfWeek);
  376. return formatDate(weekStartDate);
  377. }
  378. break;
  379. case 13: //本周结束日期
  380. return getWeekEndDate()
  381. function getWeekEndDate() {
  382. var now = new Date(); //当前日期
  383. var nowDayOfWeek = now.getDay(); //今天本周的第几天
  384. var nowDay = now.getDate(); //当前日
  385. var nowMonth = now.getMonth(); //当前月
  386. var nowYear = now.getYear(); //当前年
  387. nowYear += (nowYear < 2000) ? 1900 : 0; //
  388. var lastMonthDate = new Date(); //上月日期
  389. lastMonthDate.setDate(1);
  390. lastMonthDate.setMonth(lastMonthDate.getMonth() - 1);
  391. var lastYear = lastMonthDate.getYear();
  392. var lastMonth = lastMonthDate.getMonth();
  393. var weekEndDate = new Date(nowYear, nowMonth, nowDay + (6 - nowDayOfWeek));
  394. return formatDate(weekEndDate);
  395. }
  396. break;
  397. case 14: //本月开始日期
  398. return getMonthStartDate()
  399. function getMonthStartDate() {
  400. var now = new Date(); //当前日期
  401. var nowDayOfWeek = now.getDay(); //今天本周的第几天
  402. var nowDay = now.getDate(); //当前日
  403. var nowMonth = now.getMonth(); //当前月
  404. var nowYear = now.getYear(); //当前年
  405. nowYear += (nowYear < 2000) ? 1900 : 0; //
  406. var lastMonthDate = new Date(); //上月日期
  407. lastMonthDate.setDate(1);
  408. lastMonthDate.setMonth(lastMonthDate.getMonth() - 1);
  409. var lastYear = lastMonthDate.getYear();
  410. var lastMonth = lastMonthDate.getMonth();
  411. var monthStartDate = new Date(nowYear, nowMonth, 1);
  412. return formatDate(monthStartDate);
  413. }
  414. break;
  415. case 15: //本月结束日期
  416. return getMonthEndDate();
  417. function getMonthEndDate() {
  418. var now = new Date(); //当前日期
  419. var nowDayOfWeek = now.getDay(); //今天本周的第几天
  420. var nowDay = now.getDate(); //当前日
  421. var nowMonth = now.getMonth(); //当前月
  422. var nowYear = now.getYear(); //当前年
  423. nowYear += (nowYear < 2000) ? 1900 : 0; //
  424. var lastMonthDate = new Date(); //上月日期
  425. lastMonthDate.setDate(1);
  426. lastMonthDate.setMonth(lastMonthDate.getMonth() - 1);
  427. var lastYear = lastMonthDate.getYear();
  428. var lastMonth = lastMonthDate.getMonth();
  429. //获得某月的天数
  430. function getMonthDays(myMonth) {
  431. var monthStartDate = new Date(nowYear, myMonth, 1);
  432. var monthEndDate = new Date(nowYear, myMonth + 1, 1);
  433. var days = (monthEndDate - monthStartDate) / (1000 * 60 * 60 * 24);
  434. return days;
  435. }
  436. var monthEndDate = new Date(nowYear, nowMonth, getMonthDays(nowMonth));
  437. return formatDate(monthEndDate);
  438. }
  439. break;
  440. default:
  441. cNewTimeStr = myYear + '-' + myMonth + '-' + myDay + ' ' + myHour + ':' + myMinu + ':' + mySecond;
  442. break;
  443. }
  444. cNewTimeStr = cNewTimeStr.replace(/;/g, "");
  445. return cNewTimeStr;
  446. }
  447. //case 12,13的规整函数
  448. function formatDate(date) {
  449. var myyear = date.getFullYear();
  450. var mymonth = date.getMonth() + 1;
  451. var myweekday = date.getDate();
  452. if(mymonth < 10) {
  453. mymonth = "0" + mymonth;
  454. }
  455. if(myweekday < 10) {
  456. myweekday = "0" + myweekday;
  457. }
  458. return(myyear + "-" + mymonth + "-" + myweekday);
  459. }
  460. //计算天数差的函数,通用
  461. function DateDiff(sDate1, sDate2){ //sDate1和sDate2是2002-12-18格式
  462. var aDate, oDate1, oDate2, iDays
  463. aDate = sDate1.split("-")
  464. oDate1 = new Date(aDate[1] + '-' + aDate[2] + '-' + aDate[0]) //转换为12-18-2002格式
  465. aDate = sDate2.split("-")
  466. oDate2 = new Date(aDate[1] + '-' + aDate[2] + '-' + aDate[0])
  467. iDays = parseInt(Math.abs(oDate1 - oDate2) / 1000 / 60 / 60 /24) //把相差的毫秒数转换为天数
  468. return iDays
  469. }
  470. //html存入json
  471. function setJsonHtml(data) {
  472. if(typeof(data) == "object") {
  473. var jsonArrayFinal = JSON.stringify(data);
  474. jsonArrayFinal = jsonArrayFinal.replace(/ /g, '');
  475. // jsonArrayFinal = jsonArrayFinal.replace(/"/g, '&quot;');
  476. return jsonArrayFinal;
  477. }
  478. }
  479. //取出html存入的json
  480. function getJsonHtml(data) {
  481. if(data) {
  482. var data_info = JSON.parse(data);
  483. return data_info;
  484. }
  485. }
  486. //解决冒泡
  487. function solveBubbing() {
  488. var e = getEvent();
  489. if(window.event) {
  490. e.cancelBubble = true; //阻止冒泡
  491. } else if(e.preventDefault) {
  492. e.stopPropagation(); //阻止冒泡
  493. }
  494. }
  495. //得到事件
  496. function getEvent() {
  497. if(window.event) {
  498. return window.event;
  499. }
  500. func = getEvent.caller;
  501. while(func != null) {
  502. var arg0 = func.arguments[0];
  503. if(arg0) {
  504. if((arg0.constructor == Event || arg0.constructor == MouseEvent ||
  505. arg0.constructor == KeyboardEvent) ||
  506. (typeof(arg0) == "object" && arg0.preventDefault &&
  507. arg0.stopPropagation)) {
  508. return arg0;
  509. }
  510. }
  511. func = func.caller;
  512. }
  513. return null;
  514. }
  515. //得到浏览器
  516. function myBrowser() {
  517. var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串
  518. var isOpera = userAgent.indexOf("Opera") > -1;
  519. //判断是否Opera浏览器
  520. if(isOpera) {
  521. return "Opera"
  522. };
  523. //判断是否Firefox浏览器
  524. if(userAgent.indexOf("Firefox") > -1) {
  525. return "Firefox";
  526. }
  527. //判断是否Chrome浏览器
  528. if(userAgent.indexOf("Chrome") > -1) {
  529. return "Chrome";
  530. }
  531. //判断是否Safari浏览器
  532. if(userAgent.indexOf("Safari") > -1) {
  533. return "Safari";
  534. }
  535. if(userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1 && !isOpera) {
  536. return "IE";
  537. }; //判断是否IE浏览器
  538. }
  539. //需要成功回调的弹出框
  540. function ZZAlertInfo(info, callok) {
  541. window.wxc.xcConfirm(info, window.wxc.xcConfirm.typeEnum.info, {
  542. onOk: function() {
  543. if(callok) {
  544. callok();
  545. }
  546. }
  547. });
  548. }
  549. //确认框(提示信息,成功回调,取消回调,关闭回调)
  550. function ZZConfirm(info, callok, callcancel, callclose) {
  551. window.wxc.xcConfirm(info, window.wxc.xcConfirm.typeEnum.confirm, {
  552. onOk: function() {
  553. if(callok) {
  554. callok();
  555. }
  556. },
  557. onCancel: function() {
  558. if(callcancel) {
  559. callcancel();
  560. }
  561. },
  562. onClose: function() {
  563. if(callclose) {
  564. callclose();
  565. }
  566. }
  567. })
  568. }
  569. //输入框(输入的信息,成功回调,关闭的回调)
  570. function ZZInput(info, callok, callclose) {
  571. window.wxc.xcConfirm(info, window.wxc.xcConfirm.typeEnum.input, {
  572. onOk: function(ok) {
  573. if(callok) {
  574. callok(ok);
  575. }
  576. },
  577. onClose: function(close) {
  578. if(callclose) {
  579. callclose(close);
  580. }
  581. }
  582. });
  583. }
  584. //原htComoon.js中的
  585. //修改订单需要记录修改详细内容,保存好原数据
  586. function initOldData(order_data) {
  587. // var _old_data = {
  588. // order_id: '',
  589. // org_id: '',
  590. // org_num: '',
  591. // room_list: '',
  592. // cus_list: '',
  593. // checkin_time: '',
  594. // if_cancel: '',
  595. // benefit: '',
  596. // total_commission: ''
  597. // };
  598. var order_p = order_data.hotel_order_detail[0],
  599. order_c = order_data.hotel_child_order_detail;
  600. var amount = 0;
  601. // var cus_list = "{" + order_p.customer_name + "," + order_p.customer_mobile + "," + order_p.customer_memo + "}";
  602. _old_data['contact'] = order_p.customer_name;
  603. _old_data['mobile'] = order_p.customer_mobile;
  604. _old_data['memo'] = order_p.customer_memo;
  605. _old_data['org_id'] = org_id;
  606. _old_data['org_num'] = order_p.outside_order_no;
  607. // _old_data['org_name'] = $("#org_id option[value='"+ org_id.toString()+ "']").html()
  608. _old_data['start_date'] = order_p.start_date;
  609. // _old_data['end_date'] = order_p.end_date;
  610. //间夜数
  611. var count = 0;
  612. $.each(order_c, function (key, order) {
  613. count += parseInt(order.total);
  614. amount += order['order_price'] * order['total'];
  615. })
  616. _old_data['total'] = count;
  617. _old_data['amount'] = amount;
  618. }
  619. //对比数据,返回需要记录的字段
  620. function compareOldData(new_order_data) {
  621. var list = [];
  622. $.each(_old_data, function (key, item) {
  623. if ( key != 'amount' && item != new_order_data[key]) { //备注去除
  624. if (key == 'org_id') {// 修改渠道商
  625. var b = $("#org_id option[value='" + new_order_data[key] + "']").html()
  626. var a = $("#org_id option[value='" + item + "']").html();
  627. list.push({'name': key, 'old_val': a, 'new_val': b});
  628. } else
  629. list.push({'name': key, 'old_val': item, 'new_val': new_order_data[key]});
  630. }
  631. })
  632. return list;
  633. }
  634. function removeNote(obj, flag) {
  635. if(flag){
  636. ZZConfirm('确认要删除备注?', function () {
  637. $(obj).closest('.note').remove();
  638. })
  639. }else{
  640. $(obj).closest('.note').remove();
  641. }
  642. }
  643. //日期获取上周
  644. function getLastWeek(){
  645. var today = new Date();
  646. var lastWeek = new Date(today.getFullYear(), today.getMonth(), today.getDate() - 7);
  647. return lastWeek ;
  648. }
  649. //权限控制
  650. function playPermission(){
  651. var urlapi = base_api;
  652. var _hotel_id = getPar('hotel_id'),
  653. user_id = getCookie('user_id');
  654. var param = {
  655. type: "hotel_HotelList",
  656. hotel_id: _hotel_id,
  657. op: "getDetail"
  658. };
  659. ZZLog(urlapi + JSON.stringify(param));
  660. $.ajax({
  661. url: urlapi,
  662. data: param,
  663. type: "post",
  664. dataType: "json",
  665. success: function (res_data) {
  666. ZZLog(res_data);
  667. if (res_data['code'] != "0") {
  668. alert(res_data['info']);
  669. } else {
  670. var tmp = [],
  671. temp;
  672. temp = res_data['rowset'][0]['PRINCIPAL'];
  673. if(typeof temp == 'string')
  674. tmp = temp.split(',');
  675. var principal = $.merge(_principal, tmp);
  676. if($.inArray(user_id, principal.toString().split(',')) < 0){
  677. // $(".permission-display").hide();
  678. // $(".permission td.bday").unbind('click');
  679. // $(".permission td.cday").unbind('click');
  680. // $(".permission td.change").unbind('click');
  681. // $(".permission td.change").attr('onclick','');
  682. // $(".permission td img").attr('onclick','');
  683. }
  684. }
  685. },
  686. error: function (error) {
  687. alert('system ajax http error');
  688. ZZLog(error);
  689. }
  690. })
  691. }
  692. function all_sum() {
  693. all_yongj = 0;
  694. all_jiesuan = 0;
  695. all_profit = 0;
  696. var all_yongj1= 0;
  697. var all_jiesuan1 = 0;
  698. var all_profit1 = 0;
  699. $('.yongj_sum').each(function () {
  700. all_yongj += parseFloat($(this).text())
  701. });
  702. if (isNaN(all_yongj)) {
  703. all_yongj = 0
  704. }
  705. $('.jiesuan_sum').each(function () {
  706. all_jiesuan += parseFloat($(this).text())
  707. });
  708. if (isNaN(all_jiesuan)) {
  709. all_jiesuan = 0
  710. }
  711. $('.benefit_sum').each(function () {
  712. all_profit += parseFloat($(this).text())
  713. });
  714. if (isNaN(all_profit)) {
  715. all_profit = 0
  716. }
  717. all_yongj1 = all_yongj.toFixed(2);
  718. all_jiesuan1 = all_jiesuan.toFixed(2);
  719. all_profit1 = all_profit.toFixed(2);
  720. $('#all_yongj').text(all_yongj1 + '元');
  721. $('#all_jiesuan').text(all_jiesuan1 + '元');
  722. $('#all_profit').text(all_profit1 + '元');
  723. }
  724. /**
  725. * 加载时尽量考虑什么时候关闭,否则15秒后自动关闭
  726. */
  727. function loading(time) {
  728. var newDiv = '<div id="screen-cover" class="loader-inner ball-beat" style="width: 100%; height: 100%; position: fixed; top: 0; left: 0; background-color: rgba(0,0,0,0.5); text-align: center; z-index: 9999;' +
  729. '"><div class="on" style="border-radius: 100%!important;"></div><div class="off" style="border-radius: 100%!important;"></div><div class="on" style="border-radius: 100%!important;"></div>' +
  730. '</div>';
  731. if(typeof $("#screen-cover") != 'undefined')
  732. $("#screen-cover").remove();
  733. $("<link>")
  734. .attr({ rel: "stylesheet",
  735. type: "text/css",
  736. href: "../css/loader.css"
  737. })
  738. .appendTo("head");
  739. $("html").append(newDiv);
  740. $("#screen-cover").css('padding-top', $(window).height() / 2 - 55);
  741. // if(typeof time == 'undefined')
  742. // time = 15000;
  743. // setTimeout('closeLoading()',time);
  744. }
  745. function closeLoading() {
  746. if($("#screen-cover").length > 0)
  747. $("#screen-cover").remove();
  748. }