std_reg.js 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585
  1. app.controller("StdRegCtrl", [
  2. "$rootScope",
  3. "$scope",
  4. "$http",
  5. "$timeout",
  6. "$state",
  7. "$stateParams",
  8. function ($rootScope, $scope, $http, $timeout, $state, $stateParams) {
  9. $scope.showLiveCheckLoading = false;
  10. $scope.curStep = "start";
  11. $scope.StdReg = {};
  12. $scope.YmStdCategoryArray = [];
  13. if (!$rootScope.loginSuccess) return;
  14. /****************************
  15. * 根据省份-查找该省份的文理区分
  16. */
  17. $scope.findProvinceArtScience = function () {
  18. $rootScope.ajaxRequest(
  19. {
  20. url: "../conf/std/reg/get/province.htm",
  21. data: { province_id: $scope.StdReg.std_province },
  22. },
  23. function (response) {
  24. if (response.entity) {
  25. $scope.artArr = [];
  26. $scope.artArr = response.entity.art_science_status.split(",");
  27. for (const art of $scope.artArr) {
  28. for (const st of $rootScope.StdCategoryArray) {
  29. if (art == st.dict_value) {
  30. $scope.YmStdCategoryArray.push(st);
  31. break;
  32. }
  33. }
  34. }
  35. if ($scope.YmStdCategoryArray.length === 1) {
  36. $scope.StdReg.std_param3 =
  37. $scope.YmStdCategoryArray[0].dict_value;
  38. }
  39. $scope.YmStdCategoryArray.unshift({
  40. dict_text: "请选择",
  41. dict_value: null,
  42. });
  43. }
  44. }
  45. );
  46. };
  47. if ($rootScope.ArtStdReg != undefined) {
  48. $scope.StdReg = angular.extend({}, $rootScope.ArtStdReg);
  49. if ($scope.StdReg.reg_status == "IdCard") {
  50. $scope.curStep = "NoCrownPhotoWarning";
  51. } else if ($scope.StdReg.reg_status == "NoCrownPhoto") {
  52. $scope.curStep = "StdExtendInfo";
  53. $scope.findProvinceArtScience();
  54. }
  55. }
  56. $scope.getCategory = function () {
  57. if ($scope.YmStdCategoryArray.length < 1) {
  58. $scope.findProvinceArtScience();
  59. }
  60. };
  61. //生源地
  62. $rootScope.ajaxRequest(
  63. {
  64. url: "../enrol/reg/province/list.htm",
  65. },
  66. function (response) {
  67. $scope.provinceArray = response.array;
  68. }
  69. );
  70. //邮寄省份
  71. /* $rootScope.ajaxRequest(
  72. {
  73. url: "../enrol/std/reg/province/list.htm",
  74. },
  75. function (response) {
  76. $scope.provArray = response.array;
  77. }
  78. );*/
  79. /*//邮寄城市初始列表
  80. $rootScope.ajaxRequest({
  81. url : '../enrol/std/reg/city/alllist.htm'
  82. }, function(response) {
  83. $scope.cityArray = response.array;
  84. }); */
  85. //过滤城市
  86. /* $scope.freshCity = function () {
  87. $rootScope.ajaxRequest(
  88. {
  89. url:
  90. "../enrol/std/reg/city/list.htm?province_id=" +
  91. $scope.StdReg.link_province,
  92. },
  93. function (response) {
  94. $scope.cityArray = response.array;
  95. }
  96. );
  97. };*/
  98. //选择考生类型
  99. $scope.chooseStdType = function (d) {
  100. $rootScope.ajaxRequest(
  101. {
  102. url: "../enrol/province/list/stdType.htm",
  103. data: { std_type: d.dict_value },
  104. },
  105. function (response) {
  106. $scope.provinceArray = response.array;
  107. $scope.curStep = "province";
  108. }
  109. );
  110. };
  111. /***************************************************************************
  112. * 选择生源地
  113. */
  114. $scope.chooseProvince = function (p) {
  115. if (p.reg_status == "InActive") {
  116. var msg = "未开放【" + p.province_name + "】考生注册!";
  117. if (p.reg_fetch_param != undefined) msg = p.reg_fetch_param;
  118. $.alert(msg);
  119. return;
  120. }
  121. $scope.currentProvince = p;
  122. $scope.StdReg.std_province = p.province_id;
  123. $scope.StdReg.province_name = p.province_name;
  124. if (p.province_id + "" == "90") {
  125. // 外国,护照
  126. $scope.curStep = "PassportWarning";
  127. $scope.StdReg.cert_type = "Passport";
  128. } else if (p.province_id + "" == "71") {
  129. // 台湾,台湾居民往来大陆通行证,澳门,香港 港澳居民来往内地通行证
  130. $scope.curStep = "IdCard71Warning";
  131. $scope.StdReg.cert_type = "TaiWanPass";
  132. } else if (
  133. p.province_id + "" == "80" ||
  134. p.province_id + "" == "81" ||
  135. p.province_id + "" == "82"
  136. ) {
  137. // 澳门,香港 港澳居民来往内地通行证
  138. $scope.curStep = "HongKongMacaoPass";
  139. $scope.StdReg.cert_type = "TaiWanPass";
  140. } else if (p.ksh_status == "Active") {
  141. // 必须有高考报名号
  142. $scope.curStep = "ExamIdWarning";
  143. } else {
  144. // 大陆,需要上传身份证
  145. $scope.curStep = "IdCardWarning";
  146. $scope.StdReg.cert_type = "IdCard";
  147. }
  148. $scope.findProvinceArtScience();
  149. };
  150. $scope.checkExamId = function () {
  151. $scope.StdReg.exam_id = $.trim($scope.StdReg.exam_id);
  152. if (
  153. $scope.StdReg.exam_id == undefined ||
  154. $scope.StdReg.exam_id.length === 0
  155. ) {
  156. $.alert("高考报名号必须填写!");
  157. return false;
  158. }
  159. $.showLoading("正在提交考生信息,请稍后...");
  160. $rootScope.ajaxRequest(
  161. {
  162. url: "../enrol/reg/province/check.htm",
  163. data: $scope.StdReg,
  164. },
  165. function (response) {
  166. $.hideLoading();
  167. // 大陆,需要上传身份证
  168. $scope.curStep = "IdCardWarning";
  169. $scope.StdReg.cert_type = "IdCard";
  170. }
  171. );
  172. };
  173. //非大陆考生通行证和证件号码判断
  174. $scope.isCert = function (str) {
  175. var pat = /^[a-zA-Z0-9()]+$/;
  176. return pat.test(str);
  177. };
  178. /***************************************************************************
  179. * 识别正确,保存用户信息
  180. */
  181. $scope.saveIdCard = function (flag) {
  182. $scope.StdReg.cert_id = $.trim($scope.StdReg.cert_id);
  183. $scope.StdReg.std_name = $.trim($scope.StdReg.std_name);
  184. $scope.StdReg.std_sex = $.trim($scope.StdReg.std_sex);
  185. $scope.StdReg.std_mobile = $.trim($scope.StdReg.std_mobile);
  186. $scope.StdReg.std_name_confirm = $.trim($scope.StdReg.std_name_confirm);
  187. if (
  188. $scope.StdReg.cert_id == undefined ||
  189. $scope.StdReg.cert_id.length === 0
  190. ) {
  191. $.alert("请输入证件号码!");
  192. return false;
  193. }
  194. if (flag === 2) {
  195. if (
  196. $scope.StdReg.std_param2 == undefined ||
  197. $scope.StdReg.std_param2.length === 0
  198. ) {
  199. $.alert("请输入身份证号码!");
  200. return false;
  201. }
  202. if (
  203. $scope.StdReg.cert_id.indexOf("(") !== -1 ||
  204. $scope.StdReg.cert_id.indexOf(")") !== -1
  205. ) {
  206. $.alert("证件号码请输入半角括号!");
  207. return false;
  208. }
  209. if (
  210. $scope.StdReg.std_param2.indexOf("(") !== -1 ||
  211. $scope.StdReg.std_param2.indexOf(")") !== -1
  212. ) {
  213. $.alert("身份证号码请输入半角括号!");
  214. return false;
  215. }
  216. if (!$scope.isCert($scope.StdReg.cert_id)) {
  217. if ($scope.StdReg.std_province == "90") {
  218. $.alert("护照号只能为数字、字母、半角括号!");
  219. return false;
  220. } else {
  221. $.alert("证件号码只能为数字、字母、半角括号!");
  222. return false;
  223. }
  224. }
  225. if (!$scope.isCert($scope.StdReg.std_param2)) {
  226. $.alert("居民身份证只能为数字、字母、半角括号!");
  227. return false;
  228. }
  229. }
  230. if (
  231. $scope.StdReg.std_name == undefined ||
  232. $scope.StdReg.std_name.length == 0
  233. ) {
  234. $.alert("请输入考生姓名!");
  235. return false;
  236. }
  237. if (
  238. $scope.StdReg.std_sex == undefined ||
  239. $scope.StdReg.std_sex.length == 0
  240. ) {
  241. $.alert("请选择考生性别!");
  242. return false;
  243. }
  244. if (
  245. $scope.StdReg.std_mobile == undefined ||
  246. $scope.StdReg.std_mobile.length !== 11
  247. ) {
  248. $.alert("请输入正确的手机号码!");
  249. return false;
  250. }
  251. // 识别姓名和自输入姓名不相等
  252. if ($scope.StdReg.std_name_confirm != $scope.StdReg.std_name) {
  253. $.alert("自动识别的姓名和考生确认的姓名不一致,请修改为正确的姓名!");
  254. return false;
  255. }
  256. $.showLoading("正在提交考生信息,请稍后...");
  257. $rootScope.ajaxRequest(
  258. {
  259. url: "../enrol/reg/save.htm",
  260. data: $scope.StdReg,
  261. },
  262. function (response) {
  263. $.hideLoading();
  264. $scope.StdReg = response.entity;
  265. $rootScope.ArtStdReg = $scope.StdReg;
  266. // 上传免冠证件照
  267. if ($scope.StdReg.std_image) {
  268. $scope.curStep = "StdExtendInfo";
  269. } else {
  270. // 上传免冠证件照
  271. $scope.curStep = "NoCrownPhotoWarning";
  272. }
  273. }
  274. );
  275. };
  276. //是否是中文
  277. $scope.isChinese = function (str) {
  278. var reg = /^[\u4e00-\u9fa5]+$/;
  279. return reg.test(str);
  280. };
  281. /***************************************************************************
  282. * 完善个人信息
  283. */
  284. $scope.saveExtendInfo = function () {
  285. // 考生
  286. if ($rootScope.getParamValue("SchoolCode") == "51065") {
  287. if (
  288. $scope.StdReg.std_type == undefined ||
  289. $scope.StdReg.std_type == ""
  290. ) {
  291. $.alert("请选择考生类型!");
  292. return false;
  293. }
  294. }
  295. if (
  296. $scope.StdReg.link_mobile &&
  297. $scope.StdReg.std_mobile == $scope.StdReg.link_mobile
  298. ) {
  299. $.alert("紧急联系人电话与本人手机号码不能相同!");
  300. return false;
  301. }
  302. //政治面貌
  303. if (
  304. $scope.StdReg.std_political == undefined ||
  305. $scope.StdReg.std_political == ""
  306. ) {
  307. $.alert("请选择政治面貌!");
  308. return false;
  309. }
  310. //科类
  311. if (
  312. $scope.StdReg.std_param3 == undefined ||
  313. $scope.StdReg.std_param3 == "" ||
  314. $scope.StdReg.std_param3.length === 0
  315. ) {
  316. $.alert("请选择科类!");
  317. return false;
  318. }
  319. //科类
  320. if (
  321. $scope.StdReg.std_param4 == undefined ||
  322. $scope.StdReg.std_param4 == "" ||
  323. $scope.StdReg.std_param4.length === 0
  324. ) {
  325. $.alert("请选择毕业类型!");
  326. return false;
  327. }
  328. //毕业学校
  329. if (
  330. $rootScope.getParamValue("EnrolReg_ShowStdSchool", "Active") ==
  331. "Active" &&
  332. ($scope.StdReg.std_school == undefined ||
  333. $scope.StdReg.std_school == "")
  334. ) {
  335. $.alert("请填写毕业学校!");
  336. return false;
  337. }
  338. //考生类别
  339. if (
  340. $scope.StdReg.std_param5 == undefined ||
  341. $scope.StdReg.std_param5 == ""
  342. ) {
  343. $.alert("请选择考生类别!");
  344. return false;
  345. }
  346. /**毕业时间**/
  347. if (
  348. $scope.StdReg.end_date == undefined ||
  349. $scope.StdReg.end_date == ""
  350. ) {
  351. $.alert("请填写毕业时间!");
  352. return false;
  353. }
  354. //紧急联系人
  355. if (
  356. $scope.StdReg.link_man == undefined ||
  357. $scope.StdReg.link_man == ""
  358. ) {
  359. $.alert("请填写紧急联系人!");
  360. return false;
  361. } else if (!$scope.isChinese($scope.StdReg.link_man)) {
  362. $.alert("紧急联系人必须是汉字!");
  363. return false;
  364. }
  365. //家长手机号
  366. if (
  367. $scope.StdReg.link_mobile == undefined ||
  368. $scope.StdReg.link_mobile == ""
  369. ) {
  370. $.alert("请填写联系人手机号!");
  371. return false;
  372. }
  373. //通信地址
  374. if (
  375. $rootScope.getParamValue("EnrolReg_LinkAddr", "Active") == "Active" &&
  376. ($scope.StdReg.link_addr == undefined ||
  377. $scope.StdReg.link_addr == "")
  378. ) {
  379. $.alert("请填写通讯地址!");
  380. return false;
  381. }
  382. //邮政编码
  383. if (
  384. $scope.StdReg.link_postal == undefined ||
  385. $scope.StdReg.link_postal == "" ||
  386. $scope.StdReg.link_postal.length === 0
  387. ) {
  388. $.alert("请填写邮政编码!");
  389. return false;
  390. }
  391. if (
  392. $scope.StdReg.link_postal.length !== 6 ||
  393. $scope.isChinese($scope.StdReg.link_postal)
  394. ) {
  395. $.alert("请输入6位的邮政编码!");
  396. return false;
  397. }
  398. //电子邮箱
  399. if ($rootScope.getParamValue("EnrolReg_email", "Active") == "Active") {
  400. if ($scope.StdReg.email == undefined || $scope.StdReg.email == "") {
  401. $.alert("请填写电子邮箱!");
  402. return false;
  403. }
  404. }
  405. $.showLoading("正在提交考生信息,请稍后...");
  406. $rootScope.ajaxRequest(
  407. {
  408. url: "../enrol/std/info/save.htm",
  409. data: $scope.StdReg,
  410. },
  411. function (response) {
  412. $.hideLoading();
  413. // 显示注册成功
  414. $scope.curStep = "RegSuccess";
  415. }
  416. );
  417. };
  418. /***************************************************************************
  419. * 上传免冠证件照
  420. */
  421. // $scope.uploadNoCrownPhoto = function () {
  422. // $rootScope.uploadStdMaterialPhoto("NoCrownPhoto", function () {
  423. // // $scope.curStep = 'StdExtendInfo';
  424. // if (
  425. // $rootScope.checkParamValue(
  426. // "EnrolVerifyStdIdentity",
  427. // "InActive",
  428. // "Active"
  429. // )
  430. // ) {
  431. // $scope.curStep = "VerifySuccess";
  432. // } else {
  433. // $scope.curStep = "StdExtendInfo";
  434. // }
  435. // });
  436. // };
  437. let bizToken = sessionStorage.getItem("biz_token");
  438. // 找不到取最新的bizToken
  439. if (!bizToken) {
  440. bizToken = $scope.StdReg.biz_token;
  441. }
  442. if (bizToken) {
  443. $scope.showLiveCheckLoading = true;
  444. $rootScope.ajaxRequest(
  445. {
  446. url: "../std/register/live/result.htm",
  447. data: {
  448. bizToken: bizToken,
  449. },
  450. },
  451. function (res) {
  452. $scope.showLiveCheckLoading = false;
  453. // location.reload();
  454. $.hideLoading();
  455. if (res && res.result == 1) {
  456. $scope.curStep = "StdExtendInfo";
  457. }
  458. }
  459. );
  460. sessionStorage.removeItem("biz_token");
  461. }
  462. $scope.uploadNoCrownPhoto = function () {
  463. $rootScope.ajaxRequest(
  464. {
  465. url: "../std/register/live/token.htm",
  466. data: {
  467. stdName: $scope.StdReg.std_name,
  468. certId: $scope.StdReg.cert_id,
  469. },
  470. },
  471. function (res) {
  472. $.hideLoading();
  473. if (res && res.url && res.bizToken) {
  474. sessionStorage.setItem("biz_token", res.bizToken);
  475. location.href = res.url;
  476. }
  477. }
  478. );
  479. };
  480. $scope.goStep = function (step) {
  481. $scope.curStep = step;
  482. };
  483. $scope.openIdCard = function () {
  484. wx.chooseImage({
  485. count: 1, // 默认9
  486. sizeType: ["compressed"], // 可以指定是原图还是压缩图,默认二者都有'original',
  487. sourceType: ["album", "camera"], // 可以指定来源是相册还是相机,默认二者都有
  488. success: function (res) {
  489. var localIds = res.localIds; // 返回选定照片的本地ID列表,localId可以作为img标签的src属性显示图片
  490. wx.uploadImage({
  491. localId: localIds[0], // 需要上传的图片的本地ID,由chooseImage接口获得
  492. isShowProgressTips: 1, // 默认为1,显示进度提示
  493. success: function (serverRes) {
  494. var serverId = serverRes.serverId; // 返回图片的服务器端ID
  495. $.showLoading("证件照片上传中,请稍后...");
  496. // 上传成功,去服务器取图片
  497. $rootScope.ajaxRequest(
  498. {
  499. url:
  500. "../enrol/wx/reg/idcard/" +
  501. ($scope.StdReg.std_province < "70" ? "" : "other/") +
  502. "upload.htm",
  503. data: {
  504. media_id: serverId,
  505. },
  506. },
  507. function (response) {
  508. $.hideLoading();
  509. if ($scope.StdReg.std_province < "70") {
  510. $scope.StdReg.cert_id = response.map.IdCardInfo.person_code;
  511. $scope.StdReg.std_name =
  512. response.map.IdCardInfo.person_name;
  513. $scope.StdReg.std_sex = response.map.IdCardInfo.person_sex;
  514. $scope.StdReg.std_nation =
  515. response.map.IdCardInfo.person_nation;
  516. $scope.StdReg.cert_addr =
  517. response.map.IdCardInfo.person_addr;
  518. $scope.curStep = "IdCardResult";
  519. } else {
  520. $scope.curStep = "IdCardOther";
  521. }
  522. $scope.StdReg.idcard_file_name = response.map.IdCardFileName;
  523. }
  524. );
  525. },
  526. fail: function (error) {
  527. $.hideLoading();
  528. $.alert("图片服务器暂时无法访问,请稍侯再试", "错误提示");
  529. },
  530. });
  531. },
  532. });
  533. };
  534. //选择毕业日期
  535. $scope.getGraduateDate = function () {
  536. weui.datePicker({
  537. start: 1990,
  538. end: new Date().getFullYear(),
  539. defaultValue: [
  540. new Date().getFullYear(),
  541. new Date().getMonth() + 1,
  542. new Date().getDate(),
  543. ],
  544. depth: 2,
  545. onChange: function (result) {
  546. //console.log(result);
  547. },
  548. onConfirm: function (result) {
  549. $scope.$apply(function () {
  550. $scope.StdReg.end_date = result[0].label + result[1].label;
  551. });
  552. },
  553. title: "日期选择",
  554. });
  555. };
  556. },
  557. ]);