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.

126 lines
4.8 KiB

3 years ago
  1. $(function () {
  2. 'use strict';
  3. var $Validator = null,
  4. iValidatTime = 60,
  5. /**
  6. * 設置組織下拉單
  7. * @return {Object} Ajax 物件
  8. */
  9. fnSetOrgIDDrop = function () {
  10. return CallAjax(ComFn.W_Web, 'GetOrgs', {}, function (res) {
  11. var saList = $.parseJSON(res.d);
  12. var sOptionHtml = createOptions(saList, 'OrgID', 'OrgName', true);
  13. $('#OrgID').html(sOptionHtml).find('option:first').remove();
  14. });
  15. },
  16. fnRefreshTime = function () {
  17. var testTime = function () {
  18. };
  19. if (iValidatTime > 0) {
  20. setTimeout(function () {
  21. fnRefreshTime();
  22. }, 1000);
  23. iValidatTime--;
  24. $('#basic-addon2').attr('disabled', true).text(iValidatTime + 'S后失效').css('color', 'black');
  25. }
  26. else {
  27. iValidatTime = 60;
  28. $('#basic-addon2').removeAttr('disabled').text('重新產生驗證碼');
  29. }
  30. };
  31. fnSetOrgIDDrop().done(function () {
  32. //表單欄位驗證
  33. $Validator = $("#formforgetpassword").validate({
  34. rules: {
  35. txtUserId: { required: true },
  36. txtVerificationCode: { required: true },
  37. txtNewPassword: { required: true },
  38. txtCheckPassword: { required: true, equalTo: "#txtNewPassword" }
  39. },
  40. messages: {
  41. txtUserId: { required: '請輸入帳號/郵箱' },
  42. txtVerificationCode: { required: '請輸入驗證碼' },
  43. txtNewPassword: { required: '請輸入新密碼' },
  44. txtCheckPassword: { required: '請輸入確認新密碼', equalTo: "兩次密碼輸入不相符" }
  45. }
  46. });
  47. $('[name="btnVerificationCode"]').click(function (e) {
  48. if ($(this).attr('disabled')) {
  49. return;
  50. }
  51. if (!$("#txtUserId").valid()) {
  52. $Validator.focusInvalid();
  53. return false;
  54. }
  55. g_api.ConnectLite(Service.auth, 'CheckMember', {
  56. url: g_gd.webapilonginurl,
  57. OrgID: $('#OrgID').val(),
  58. UserID: $('#txtUserId').val()
  59. }, function (res) {
  60. if (res.RESULT) {
  61. $('.newpwd').show();
  62. $('#btnSent').removeAttr('disabled');
  63. showMsg('驗證碼已成功寄送,請到郵箱收取', 'success');
  64. fnRefreshTime();
  65. }
  66. else {
  67. if (res.MSG === "1") {
  68. showMsg('沒有此會員帳號,請確認輸入是否正確。', 'error');
  69. }
  70. else if (res.MSG === "2") {
  71. showMsg('產生驗證碼失敗', 'error');
  72. }
  73. else {
  74. showMsg(res.MSG, 'error');
  75. }
  76. }
  77. });
  78. });
  79. $('#btnSent').click(function (e) {
  80. if (!$("#formforgetpassword").valid()) {
  81. $Validator.focusInvalid();
  82. return false;
  83. }
  84. g_api.ConnectLite(Service.auth, 'ReSetPassword', {
  85. url: g_gd.webapilonginurl,
  86. OrgID: $('#OrgID').val(),
  87. UserID: $('#txtUserId').val(),
  88. VerificationCode: $('#txtVerificationCode').val(),
  89. NewPsw: $('#txtNewPassword').val()
  90. }, function (res) {
  91. if (res.RESULT) {
  92. showMsg('新密碼更新成功', 'success');
  93. setTimeout(function () {
  94. window.location.href = '/Page/Login.html';
  95. }, 1500);
  96. }
  97. else {
  98. if (res.MSG === "0") {
  99. showMsg('驗證碼錯誤', 'error');
  100. }
  101. else if (res.MSG === "1") {
  102. showMsg('輸入的帳號有誤', 'error');
  103. }
  104. else if (res.MSG === "2") {
  105. showMsg('驗證碼已失效,請重新取得驗證碼', 'error');
  106. }
  107. else if (res.MSG === "3") {
  108. showMsg('新密碼更新失敗', 'error');
  109. }
  110. else if (res.MSG === "4") {
  111. showMsg('驗證碼錯誤或驗證碼已失效', 'error');
  112. }
  113. else {
  114. showMsg(res.MSG, 'error');
  115. }
  116. }
  117. }, function () {
  118. showMsg(i18next.t("message.Modify_Failed"), 'error');//╠message.Modify_Failed⇒修改失敗╣
  119. });
  120. });
  121. });
  122. });