選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 
 
 
 

477 行
14 KiB

  1. function GetFileName(filename) {
  2. var startPos = filename.lastIndexOf("/");
  3. var ext = filename.substr(startPos + 1);
  4. return ext;
  5. }
  6. function GenerateRandom() {
  7. var retstr = "";
  8. var date = new Date();
  9. retstr = date.getFullYear().toString() + "-" + date.getMonth().toString() + "-" + date.getDate().toString() + "-" + date.getUTCHours().toString() + "-" + date.getUTCMinutes() + "-" + date.getUTCSeconds().toString();
  10. var Num = "";
  11. for(var i = 0; i < 6; i++) {
  12. Num += Math.floor(Math.random() * 10);
  13. }
  14. return retstr + Num;
  15. }
  16. function ChangeCurrentTab(tabid) {
  17. var ucenterTab = document.getElementById(tabid);
  18. //模拟点击
  19. mui.trigger(ucenterTab, 'tap');
  20. //切换选项卡高亮
  21. var current = document.querySelector(".web-tool>.active");
  22. if(defaultTab !== current) {
  23. current.classList.remove('active');
  24. ucenterTab.classList.add('active');
  25. }
  26. }
  27. function ReloadAllTabs() {
  28. if(plus.webview.currentWebview().opener() != undefined && plus.webview.currentWebview().opener() != null) {
  29. plus.webview.currentWebview().opener().reload(true);
  30. if(plus.webview.currentWebview().opener().opener() != undefined && plus.webview.currentWebview().opener().opener() != null)
  31. plus.webview.currentWebview().opener().opener().reload(true);
  32. } else
  33. plus.webview.currentWebview().reload(true);
  34. var subpages = ['index.html', 'message.html', 'kcb.html', 'kq.html', 'ucenter.html'];
  35. for(var i = 0; i < 5; i++) {
  36. plus.webview.getWebviewById(subpages[i]).reload(true);
  37. }
  38. }
  39. Date.prototype.Format = function(fmt) { //author: meizz
  40. var o = {
  41. "M+": this.getMonth() + 1, //月份
  42. "d+": this.getDate(), //日
  43. "h+": this.getHours(), //小时
  44. "m+": this.getMinutes(), //分
  45. "s+": this.getSeconds(), //秒
  46. "q+": Math.floor((this.getMonth() + 3) / 3), //季度
  47. "S": this.getMilliseconds() //毫秒
  48. };
  49. if(/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
  50. for(var k in o)
  51. if(new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
  52. return fmt;
  53. }
  54. function formatDateTime(date) {
  55. var myyear = date.getFullYear();
  56. var mymonth = date.getMonth() + 1;
  57. var myweekday = date.getDate();
  58. var myHours = date.getHours();
  59. var myMinutes = date.getMinutes();
  60. var mySeconds = date.getSeconds();
  61. if(mymonth < 10) {
  62. mymonth = "0" + mymonth;
  63. }
  64. if(myweekday < 10) {
  65. myweekday = "0" + myweekday;
  66. }
  67. if(myHours < 10) {
  68. myHours = "0" + myHours;
  69. }
  70. if(myMinutes < 10) {
  71. myMinutes = "0" + myMinutes;
  72. }
  73. if(mySeconds < 10) {
  74. mySeconds = "0" + mySeconds;
  75. }
  76. //return(myyear + "-" + mymonth + "-" + myweekday + " " + myHours + ":" + myMinutes + ":" + mySeconds);
  77. return(myyear + "-" + mymonth + "-" + myweekday );
  78. }
  79. function formatDate(date) {
  80. var myyear = date.getFullYear();
  81. var mymonth = date.getMonth() + 1;
  82. var myweekday = date.getDate();
  83. var myHours = date.getHours();
  84. var myMinutes = date.getMinutes();
  85. var mySeconds = date.getSeconds();
  86. if(mymonth < 10) {
  87. mymonth = "0" + mymonth;
  88. }
  89. if(myweekday < 10) {
  90. myweekday = "0" + myweekday;
  91. }
  92. if(myHours < 10) {
  93. myHours = "0" + myHours;
  94. }
  95. if(myMinutes < 10) {
  96. myMinutes = "0" + myMinutes;
  97. }
  98. if(mySeconds < 10) {
  99. mySeconds = "0" + mySeconds;
  100. }
  101. return(myyear + "-" + mymonth + "-" + myweekday);
  102. }
  103. function jsonDateFormatDateTime(strDate) { //json日期格式转换为正常格式
  104. if(strDate != undefined && strDate != null) {
  105. var date = eval('new Date(' + strDate.replace(/\d+(?=-[^-]+$)/,
  106. function(a) {
  107. return parseInt(a, 10) - 1;
  108. }).match(/\d+/g) + ')');
  109. return formatDateTime(date);
  110. } else {
  111. return '';
  112. }
  113. }
  114. function jsonDateFormatDate(strDate) { //json日期格式转换为正常格式
  115. if(strDate != undefined && strDate != null) {
  116. var date = eval('new Date(' + strDate.replace(/\d+(?=-[^-]+$)/,
  117. function(a) {
  118. return parseInt(a, 10) - 1;
  119. }).match(/\d+/g) + ')');
  120. return formatDate(date);
  121. } else {
  122. return '';
  123. }
  124. }
  125. function getImage() {
  126. var c = plus.camera.getCamera();
  127. c.captureImage(function(e) {
  128. plus.io.resolveLocalFileSystemURL(e, function(entry) {
  129. var s = entry.toLocalURL();
  130. var bitmap = new plus.nativeObj.Bitmap("bighead");
  131. bitmap.load(s, function() {
  132. bitmap.save("_doc/" + GenerateRandom() + ".jpg", {
  133. overwrite: true,
  134. format: "jpg",
  135. quality: 100
  136. },
  137. function(event) {
  138. var target = event.target;
  139. var width = event.width; // 保存后图片的实际宽度,单位为px
  140. var height = event.height; // 保存后图片的实际高度,单位为px
  141. //裁剪
  142. mui.openWindow({
  143. url: '/User/SelectHead.html',
  144. id: 'SelectHead',
  145. extras: {
  146. headsrc: target,
  147. realwidth: width,
  148. realheight: height
  149. },
  150. show: {
  151. aniShow: 'pop-in'
  152. }
  153. });
  154. bitmap.clear();
  155. },
  156. function(exc) {
  157. console.log("save Bitmap error" + exc.message + " " + exc.code);
  158. });
  159. }, function(ex) {
  160. console.log("load Bitmap error" + ex.message);
  161. });
  162. }, function(e) {
  163. console.log("读取拍照文件错误:" + e.message);
  164. });
  165. }, function(s) {
  166. console.log("error" + s.message);
  167. }, {
  168. filename: "_doc/" + GenerateRandom() + ".jpg"
  169. });
  170. }
  171. function galleryImg() {
  172. plus.gallery.pick(function(a) {
  173. plus.io.resolveLocalFileSystemURL(a, function(entry) {
  174. var s = entry.toLocalURL();
  175. var bitmap = new plus.nativeObj.Bitmap("bighead");
  176. bitmap.load(s, function() {
  177. bitmap.save("_doc/" + GenerateRandom() + ".jpg", {
  178. overwrite: true,
  179. format: "jpg",
  180. quality: 100
  181. },
  182. function(event) {
  183. var target = event.target;
  184. var width = event.width; // 保存后图片的实际宽度,单位为px
  185. var height = event.height; // 保存后图片的实际高度,单位为px
  186. //裁剪
  187. mui.openWindow({
  188. url: '/User/SelectHead.html',
  189. id: 'SelectHead',
  190. extras: {
  191. headsrc: target,
  192. realwidth: width,
  193. realheight: height
  194. },
  195. show: {
  196. aniShow: 'pop-in'
  197. }
  198. });
  199. bitmap.clear();
  200. },
  201. function(exc) {
  202. console.log("save Bitmap error" + exc.message + " " + exc.code);
  203. });
  204. }, function(ex) {
  205. console.log("load Bitmap error" + ex.message);
  206. });
  207. }, function(e) {
  208. console.log("读取拍照文件错误:" + e.message);
  209. });
  210. }, function(a) {}, {
  211. filter: "image"
  212. })
  213. }
  214. function UpdateUserColumns(columns, where) {
  215. var xhr = new plus.net.XMLHttpRequest();
  216. xhr.responseType = "json";
  217. xhr.onreadystatechange = function() {
  218. switch(xhr.readyState) {
  219. case 4:
  220. if(xhr.status == 200) {
  221. if(xhr.response.Statu == 1) {
  222. plus.nativeUI.toast('修改成功。');
  223. plus.nativeUI.closeWaiting();
  224. plus.webview.currentWebview().reload();
  225. } else {
  226. plus.nativeUI.toast('出错了,请稍候再试。');
  227. plus.nativeUI.closeWaiting();
  228. }
  229. } else {
  230. plus.nativeUI.closeWaiting();
  231. plus.nativeUI.toast('您的网络不给力');
  232. }
  233. break;
  234. default:
  235. break;
  236. }
  237. }
  238. xhr.open("POST", serverdomain + "/Account/UpdateUserColumns");
  239. var data = "columns=" + columns + "&where=" + where + "";
  240. xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  241. xhr.send(data);
  242. plus.nativeUI.showWaiting("加载中...");
  243. }
  244. /**
  245. * 获取本地是否安装客户端
  246. **/
  247. function isAppInstalled(id) {
  248. if(id === 'qihoo' && mui.os.plus) {
  249. return true;
  250. }
  251. if(mui.os.android) {
  252. var main = plus.android.runtimeMainActivity();
  253. var packageManager = main.getPackageManager();
  254. var PackageManager = plus.android.importClass(packageManager)
  255. var packageName = {
  256. "qq": "com.tencent.mobileqq",
  257. "weixin": "com.tencent.mm",
  258. "sinaweibo": "com.sina.weibo"
  259. }
  260. try {
  261. return packageManager.getPackageInfo(packageName[id], PackageManager.GET_ACTIVITIES);
  262. } catch(e) {}
  263. } else {
  264. switch(id) {
  265. case "qq":
  266. var TencentOAuth = plus.ios.import("TencentOAuth");
  267. return TencentOAuth.iphoneQQInstalled();
  268. case "weixin":
  269. var WXApi = plus.ios.import("WXApi");
  270. return WXApi.isWXAppInstalled()
  271. case "sinaweibo":
  272. var SinaAPI = plus.ios.import("WeiboSDK");
  273. return SinaAPI.isWeiboAppInstalled()
  274. default:
  275. break;
  276. }
  277. }
  278. }
  279. /*获取指定字典的列表*/
  280. function GetDictionaryData(userPicker, dicttypecode) {
  281. mui.post(api+'/user/getdataitem',{data:dicttypecode},function(res){
  282. if(res.code=="200"){
  283. userPicker.setData(ChangeJsonObjectPropertyToValueText(res.data, "dict"))
  284. }
  285. })
  286. }
  287. function GetDictionaryDataBySource(userPicker, dicttypecode) {
  288. mui.post(api+'/user/getCultureInfo',{data:dicttypecode},function(res){//
  289. if(res.code=="200"){
  290. userPicker.setData(ChangeJsonObjectPropertyToValueText(res.data, "dict"))
  291. }
  292. },'json')
  293. }
  294. /*获取校区的列表*/
  295. function GetSchoolData(userPicker) {
  296. mui.get(api+'/user/getcompany',{},function(res){
  297. if(res.code=="200"){
  298. userPicker.setData(ChangeJsonObjectPropertyToValueText(res.data, "school"))
  299. }
  300. })
  301. }
  302. /*获取专业列表*/
  303. function GetDepartData(userPicker, schoolid, whcdid) {
  304. plus.nativeUI.showWaiting("加载中...");
  305. mui.post(api+'/user/getmajor',{data:schoolid},function(res){
  306. plus.nativeUI.closeWaiting()
  307. if(res.code=="200"){
  308. userPicker.setData(ChangeJsonObjectPropertyToValueText(res.data, "depart"));
  309. }else{
  310. plus.nativeUI.toast("该校区无专业。");
  311. userPicker.setData(null);
  312. }
  313. },'json');
  314. }
  315. /*返回字典数据重新组装*/
  316. function ChangeJsonObjectPropertyToValueText(oldjsonlist, typename) {
  317. var newlist = new Array();
  318. if(oldjsonlist.length > 0) {
  319. for(var iobj in oldjsonlist) {
  320. var newobj = {};
  321. if(typename == "dict") {
  322. newobj.value = oldjsonlist[iobj].dicentryid;
  323. newobj.text = oldjsonlist[iobj].name;
  324. }
  325. if(typename == "school") {
  326. newobj.value = oldjsonlist[iobj].schoolID;
  327. newobj.text = oldjsonlist[iobj].school;
  328. }
  329. if(typename == "depart") {
  330. newobj.value = oldjsonlist[iobj].departID;
  331. newobj.text = oldjsonlist[iobj].depart;
  332. }
  333. if(typename == "province") {
  334. newobj.value = oldjsonlist[iobj].ProID;
  335. newobj.text = oldjsonlist[iobj].name;
  336. }
  337. if(typename == "city") {
  338. newobj.value = oldjsonlist[iobj].CityID;
  339. newobj.text = oldjsonlist[iobj].name;
  340. }
  341. if(typename == "area") {
  342. newobj.value = oldjsonlist[iobj].Id;
  343. newobj.text = oldjsonlist[iobj].name;
  344. }
  345. newlist.push(newobj);
  346. }
  347. }
  348. return newlist;
  349. }
  350. function isIdCardNo(num) {
  351. num = num.toUpperCase(); //身份证号码为15位或者18位,15位时全为数字,18位前17位为数字,最后一位是校验位,可能为数字或字符X。
  352. if(!(/(^\d{15}$)|(^\d{17}([0-9]|X)$)/.test(num))) {
  353. //alert('输入的身份证号长度不对,或者号码不符合规定!\n15位号码应全为数字,18位号码末位可以为数字或X。');
  354. alert('身份证号长度不正确或不符合规定!');
  355. return false;
  356. }
  357. //验证前2位,城市符合
  358. var aCity = {
  359. 11: "北京",
  360. 12: "天津",
  361. 13: "河北",
  362. 14: "山西",
  363. 15: "内蒙古",
  364. 21: "辽宁",
  365. 22: "吉林",
  366. 23: "黑龙江 ",
  367. 31: "上海",
  368. 32: "江苏",
  369. 33: "浙江",
  370. 34: "安徽",
  371. 35: "福建",
  372. 36: "江西",
  373. 37: "山东",
  374. 41: "河南",
  375. 42: "湖北",
  376. 43: "湖南",
  377. 44: "广东",
  378. 45: "广西",
  379. 46: "海南",
  380. 50: "重庆",
  381. 51: "四川",
  382. 52: "贵州",
  383. 53: "云南",
  384. 54: "西藏",
  385. 61: "陕西",
  386. 62: "甘肃",
  387. 63: "青海",
  388. 64: "宁夏",
  389. 65: "新疆",
  390. 71: "台湾",
  391. 81: "香港",
  392. 82: "澳门",
  393. 91: "国外"
  394. };
  395. if(aCity[parseInt(num.substr(0, 2))] == null) {
  396. alert('身份证号不正确或不符合规定!');
  397. return false;
  398. }
  399. //alert('城市:'+aCity[parseInt(num.substr(0,2))]);
  400. //下面分别分析出生日期和校验位
  401. var len, re;
  402. len = num.length;
  403. if(len == 15) {
  404. re = new RegExp(/^(\d{6})(\d{2})(\d{2})(\d{2})(\d{3})$/);
  405. var arrSplit = num.match(re); //检查生日日期是否正确
  406. var dtmBirth = new Date('19' + arrSplit[2] + '/' + arrSplit[3] + '/' + arrSplit[4]);
  407. var bGoodDay;
  408. bGoodDay = (dtmBirth.getYear() == Number(arrSplit[2])) && ((dtmBirth.getMonth() + 1) == Number(arrSplit[3])) && (dtmBirth.getDate() == Number(arrSplit[4]));
  409. if(!bGoodDay) {
  410. alert('身份证号的出生日期不对!');
  411. return false;
  412. } else { //将15位身份证转成18位 //校验位按照ISO 7064:1983.MOD 11-2的规定生成,X可以认为是数字10。
  413. var arrInt = new Array(7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2);
  414. var arrCh = new Array('1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2');
  415. var nTemp = 0,
  416. i;
  417. num = num.substr(0, 6) + '19' + num.substr(6, num.length - 6);
  418. for(i = 0; i < 17; i++) {
  419. nTemp += num.substr(i, 1) * arrInt[i];
  420. }
  421. num += arrCh[nTemp % 11];
  422. return true;
  423. }
  424. }
  425. if(len == 18) {
  426. re = new RegExp(/^(\d{6})(\d{4})(\d{2})(\d{2})(\d{3})([0-9]|X)$/);
  427. var arrSplit = num.match(re); //检查生日日期是否正确
  428. var dtmBirth = new Date(arrSplit[2] + "/" + arrSplit[3] + "/" + arrSplit[4]);
  429. var bGoodDay;
  430. bGoodDay = (dtmBirth.getFullYear() == Number(arrSplit[2])) && ((dtmBirth.getMonth() + 1) == Number(arrSplit[3])) && (dtmBirth.getDate() == Number(arrSplit[4]));
  431. if(!bGoodDay) {
  432. //alert(dtmBirth.getYear());
  433. //alert(arrSplit[2]);
  434. alert('身份证号的出生日期不对!');
  435. return false;
  436. } else { //检验18位身份证的校验码是否正确。 //校验位按照ISO 7064:1983.MOD 11-2的规定生成,X可以认为是数字10。
  437. var valnum;
  438. var arrInt = new Array(7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2);
  439. var arrCh = new Array('1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2');
  440. var nTemp = 0,
  441. i;
  442. for(i = 0; i < 17; i++) {
  443. nTemp += num.substr(i, 1) * arrInt[i];
  444. }
  445. valnum = arrCh[nTemp % 11];
  446. if(valnum != num.substr(17, 1)) {
  447. //alert('18位身份证的校验码不正确!应该为:' + valnum);
  448. alert('18位身份证号的校验码不正确!');
  449. return false;
  450. }
  451. return true;
  452. }
  453. }
  454. return false;
  455. }