Brak opisu

new.js 3.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /**
  2. * Created by TT on 2017/8/4.
  3. */
  4. ;
  5. spa_define(function () {
  6. return $.use(["spa", "util", "form"], function (spa, util, fb) {
  7. return {
  8. modal: function (data) {
  9. var root = spa.findInModal(".sys_professornew_new");
  10. var form = fb.build(root.find(".newForm"));
  11. var trim = function (str) { //删除左右两端的空格   
  12. return str.replace(/(^\s*)|(\s*$)/g, "");
  13. };
  14. var saveBtn = root.find(".opt-save"),
  15. save = function () {
  16. if (form.val().mobile) {
  17. var mobile = trim(form.val().mobile);
  18. var hunPhone = /^1[3|4|5|7|8]\d{9}$/;
  19. if (!hunPhone.test(mobile)) {
  20. util.alert("注册电话格式有误,请检查后重新填写");
  21. return;
  22. }
  23. }
  24. if (form.val().email) {
  25. var email = trim(form.val().email);
  26. var gunf = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
  27. if (!gunf.test(email)) {
  28. util.alert("注册邮箱格式有误,请检查后重新填写");
  29. return;
  30. }
  31. }
  32. if (form.val().name) {
  33. var name = trim(form.val().name);
  34. if (name.length > 10) {
  35. util.alert("姓名最长为10个字");
  36. return;
  37. }
  38. }else {
  39. util.alert("请填写用户名称");
  40. return;
  41. }
  42. if (form.val().mobile || form.val().email) {
  43. util.get("../ajax/sys/professor/createCheck", {
  44. mobile: form.val().mobile,
  45. email: form.val().email
  46. },function (success) {
  47. if (success){
  48. form.doPost("../ajax/sys/professor/createAccount", function () {
  49. spa.closeModal();
  50. if (data) {
  51. data();
  52. }
  53. }, {});
  54. }else {
  55. util.alert("该账号已存在");
  56. }
  57. });
  58. } else {
  59. util.alert("手机或邮箱至少输入一项");
  60. }
  61. };
  62. root.find(".modal-ctrl .icon-times").on("click", function () {
  63. spa.closeModal();
  64. });
  65. saveBtn.on("click", save);
  66. }
  67. }
  68. });
  69. });