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.

130 lines
4.9 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 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.DATA, 'OrgID', 'OrgName', true);
  13. $('#OrgID').html(sOptionHtml);
  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: "TG",
  58. //OrgID: $('#OrgID').val(),
  59. UserID: $('#txtUserId').val()
  60. }, function (res) {
  61. if (res.RESULT) {
  62. $('.newpwd').show();
  63. $('#btnSent').removeAttr('disabled');
  64. showMsg('驗證碼已成功寄送,請到郵箱收取', 'success');
  65. fnRefreshTime();
  66. }
  67. else {
  68. if (res.MSG === "1") {
  69. showMsg('沒有此會員帳號,請確認輸入是否正確。', 'error');
  70. }
  71. else if (res.MSG === "2") {
  72. showMsg('產生驗證碼失敗', 'error');
  73. }
  74. else {
  75. showMsg(res.MSG, 'error');
  76. }
  77. }
  78. });
  79. });
  80. $('#btnSent').click(function (e) {
  81. if (!$("#formforgetpassword").valid()) {
  82. $Validator.focusInvalid();
  83. return false;
  84. }
  85. g_api.ConnectLite(Service.auth, 'ReSetPassword', {
  86. url: g_gd.webapilonginurl,
  87. OrgID: "TG",
  88. //OrgID: $('#OrgID').val(),
  89. UserID: $('#txtUserId').val(),
  90. VerificationCode: $('#txtVerificationCode').val(),
  91. NewPsw: $('#txtNewPassword').val()
  92. }, function (res) {
  93. if (res.RESULT) {
  94. showMsg('新密碼更新成功', 'success');
  95. setTimeout(function () {
  96. window.location.href = '/Page/Login.html';
  97. }, 1500);
  98. }
  99. else {
  100. if (res.MSG === "0") {
  101. showMsg('驗證碼錯誤', 'error');
  102. }
  103. else if (res.MSG === "1") {
  104. showMsg('輸入的帳號有誤', 'error');
  105. }
  106. else if (res.MSG === "2") {
  107. showMsg('驗證碼已失效,請重新取得驗證碼', 'error');
  108. }
  109. else if (res.MSG === "3") {
  110. showMsg('新密碼更新失敗', 'error');
  111. }
  112. else if (res.MSG === "4") {
  113. showMsg('驗證碼錯誤或驗證碼已失效', 'error');
  114. }
  115. else {
  116. showMsg(res.MSG, 'error');
  117. }
  118. }
  119. }, function () {
  120. showMsg(i18next.t("message.Modify_Failed"), 'error');//╠message.Modify_Failed⇒修改失敗╣
  121. });
  122. });
  123. });
  124. });