Forget.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. <template>
  2. <div class="view-product" style="overflow-y: hidden;">
  3. <div>
  4. <div class="ibox-content" style="padding-top: 20px">
  5. <layui-form style="text-align: center;">
  6. <layui-item>
  7. <layui-inline-input
  8. label="OA账号"
  9. placeholder="OA账号"
  10. lay-verify="required"
  11. v-model="account"
  12. ></layui-inline-input>
  13. </layui-item>
  14. <div class="layui-form layui-form-pane">
  15. <div class="layui-form-item" style="padding-left: 112px;">
  16. <div class="layui-inline">
  17. <label title="验证码" class="layui-form-label layui-required">{{ enableSms ? '短信验证码' : '邮件验证码' }}</label>
  18. <div class="layui-input-block">
  19. <input
  20. v-model="code"
  21. lay-verify="required"
  22. autocomplete="off"
  23. placeholder="验证码"
  24. class="layui-input"
  25. style="width: 192px;margin-right: 8px;"
  26. >
  27. </div>
  28. </div>
  29. <button
  30. @click="getCode"
  31. class="layui-btn layui-btn-primary btn_yz"
  32. style="float: right;margin-right: 12px;display: block;width: 100px;"
  33. >{{ getMobileCodeText() }}</button>
  34. </div>
  35. </div>
  36. <layui-item class="autofill_color">
  37. <layui-inline-input
  38. label="新密码"
  39. placeholder="新密码"
  40. type="password"
  41. lay-verify="required"
  42. v-model="newPwd"
  43. ></layui-inline-input>
  44. </layui-item>
  45. <layui-item>
  46. <layui-inline-input
  47. label="确认新密码"
  48. type="password"
  49. placeholder="确认新密码"
  50. lay-verify="required"
  51. v-model="surePwd"
  52. ></layui-inline-input>
  53. </layui-item>
  54. <hr class="layui-bg-blue" style="margin-bottom: 8px">
  55. <div>
  56. <ul class="pwd-rule">
  57. <li style="font-weight: bold;">提示:</li>
  58. <li>1. 输入正确的账号,获取{{ enableSms ? '短信验证码' : '邮件验证码' }}操作才能正常进行({{ enableSms ? '短信验证码' : '邮件验证码' }}有效期为{{ enableSms ? '5' : '10' }}分钟);</li>
  59. <li>2. 密码长度:8-20位;</li>
  60. <li>3. 密码格式:必须包含大写字母、小写字母和数字,并且符合行内安全规定。</li>
  61. <li></li>
  62. </ul>
  63. <ul class="pwd-rule">
  64. <li style="font-weight: bold;color:red">注意:</li>
  65. <li>重置密码还可直接联系管理员:刘帅(63699949,13810474041)、王敏(63699613,18500063356)。</li>
  66. </ul>
  67. </div>
  68. <layui-inline :style="{width:'100%'}">
  69. <div style="text-align:center;padding: 4px 0px;">
  70. <button
  71. class="layui-btn layui-btn-lg layui-btn-blue"
  72. @click="resetPwd()"
  73. >
  74. <i class="fa fa-repeat"></i> 重置密码
  75. </button>
  76. <button
  77. class="layui-btn layui-btn-lg layui-btn-red"
  78. @click="closeUpdateFrame()"
  79. >
  80. <i class="fa fa-times"></i> 关闭
  81. </button>
  82. </div>
  83. </layui-inline>
  84. </layui-form>
  85. </div>
  86. </div>
  87. </div>
  88. </template>
  89. <script>
  90. import { getEmailCode, getSmsCode, resetPwd } from "@/api/user";
  91. import BaseModal from "@/views/base/BaseModal";
  92. const enableSms = window.enableSms || false;
  93. export default {
  94. extends: BaseModal,
  95. data() {
  96. return {
  97. account: this.username,
  98. newPwd: null,
  99. surePwd: null,
  100. code: null,
  101. wait_timer: false,
  102. enableSms: enableSms,
  103. };
  104. },
  105. props: {
  106. username: {
  107. type: String,
  108. default: ""
  109. }
  110. },
  111. mounted() {
  112. },
  113. methods: {
  114. closeUpdateFrame: function() {
  115. this.$layer.close(this.layerid);
  116. },
  117. resetPwd: function() {
  118. confirm("确定重置密码吗?", () => {
  119. //加载层-风格4
  120. var layId = layer.msg("重置密码中", {
  121. icon: 16,
  122. shade: 0.01
  123. });
  124. resetPwd(this.account, this.newPwd, this.surePwd, this.code).then(res => {
  125. layer.close(layId);
  126. alert(res.msg);
  127. this.closeUpdateFrame();
  128. }).catch(error => {
  129. layer.close(layId);
  130. });
  131. });
  132. },
  133. getCode: function() {
  134. // 加载层-风格4
  135. var layId = layer.msg("验证码获取中", {
  136. icon: 16,
  137. shade: 0.01,
  138. time: 0
  139. });
  140. if (!this.enableSms) {
  141. getEmailCode(this.account, '').then(res => {
  142. layer.close(layId);
  143. alert(res.msg);
  144. // 验证码倒计时
  145. var that = this;
  146. this.wait_timer = 120;
  147. var timer_interval = setInterval(function() {
  148. if (that.wait_timer > 0) {
  149. that.wait_timer--;
  150. } else {
  151. clearInterval(timer_interval);
  152. }
  153. }, 1000);
  154. }).catch(error => {
  155. // alert("获取验证码超时,获取失败。");
  156. layer.close(layId);
  157. });
  158. } else {
  159. getSmsCode(this.account, 'Tx').then(res => {
  160. layer.close(layId);
  161. alert(res.msg);
  162. // 验证码倒计时
  163. var that = this;
  164. this.wait_timer = 120;
  165. var timer_interval = setInterval(function() {
  166. if (that.wait_timer > 0) {
  167. that.wait_timer--;
  168. } else {
  169. clearInterval(timer_interval);
  170. }
  171. }, 1000);
  172. }).catch(error => {
  173. // alert("获取验证码超时,获取失败。");
  174. layer.close(layId);
  175. });
  176. }
  177. },
  178. // 验证码倒计时显示内容
  179. getMobileCodeText: function() {
  180. if (this.wait_timer > 0) {
  181. $('.btn_yz').addClass('layui-btn-disabled').attr('disabled',"true");
  182. return this.wait_timer + "s后获取";
  183. }
  184. if (this.wait_timer === 0) {
  185. $('.btn_yz').removeClass('layui-btn-disabled').removeAttr('disabled',"false");
  186. return "重新获取";
  187. }
  188. if (this.wait_timer === false) {
  189. return "获取验证码";
  190. }
  191. }
  192. }
  193. };
  194. </script>
  195. <style scoped>
  196. .pwd-rule {
  197. text-align: left;
  198. }
  199. .pwd-rule li {
  200. padding-bottom: 4px;
  201. }
  202. input:-webkit-autofill {
  203. -webkit-text-fill-color: #354e6a !important;
  204. transition: background-color 5000s ease-in-out 0s;
  205. }
  206. .autofill_color /deep/ .layui-input {
  207. -webkit-box-shadow: 0 0 0px 1000px white inset;
  208. }
  209. </style>