pwd.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. <template>
  2. <view class="container">
  3. <view class="wrapper">
  4. <view class="input-content">
  5. <view class="cu-form-group" style="border: 2upx solid whitesmoke;margin-bottom: 20px;border-radius: 30px">
  6. <text class="title">旧密码</text>
  7. <input type="password" :value="oldPwd" placeholder="请输入旧密码" placeholder-class="input-empty" maxlength="20"
  8. minlength="6" data-key="oldpassword" @input="inputChange" @confirm="toLogin" />
  9. </view>
  10. <view class="cu-form-group" style="border: 2upx solid whitesmoke;margin-bottom: 20px;border-radius: 30px">
  11. <text class="title">新密码</text>
  12. <input type="password" :value="pwd" placeholder="请设置新密码" placeholder-class="input-empty" maxlength="20"
  13. minlength="6" data-key="password" @input="inputChange" @confirm="toLogin" />
  14. </view>
  15. </view>
  16. <button class="confirm-btn" @click="toLogin">修改密码</button>
  17. </view>
  18. </view>
  19. </template>
  20. <script>
  21. export default {
  22. data() {
  23. return {
  24. code: '',
  25. phone: '',
  26. password: '',
  27. oldpassword: '',
  28. sending: false,
  29. sendTime: '获取验证码',
  30. count: 60,
  31. logining: false,
  32. oldPwd: '',
  33. pwd: ''
  34. }
  35. },
  36. methods: {
  37. sendMsg() {
  38. const {
  39. phone
  40. } = this;
  41. if (!phone) {
  42. this.$queue.showToast("请输入手机号");
  43. } else if (phone.length !== 11) {
  44. this.$queue.showToast("请输入正确的手机号");
  45. } else {
  46. this.$queue.showLoading("正在发送验证码...");
  47. this.$Request.getT('/appLogin/sendMsg/' + mobile + '/forget').then(res => {
  48. if (res.code === 0) {
  49. this.sending = true;
  50. this.$queue.showToast('验证码发送成功请注意查收');
  51. this.countDown();
  52. uni.hideLoading();
  53. } else {
  54. uni.hideLoading();
  55. uni.showModal({
  56. showCancel: false,
  57. title: '短信发送失败',
  58. content: res.msg ? res.msg : '请一分钟后再获取验证码'
  59. });
  60. }
  61. });
  62. }
  63. },
  64. countDown() {
  65. const {
  66. count
  67. } = this;
  68. if (count === 1) {
  69. this.count = 60;
  70. this.sending = false;
  71. this.sendTime = '获取验证码'
  72. } else {
  73. this.count = count - 1;
  74. this.sending = true;
  75. this.sendTime = count - 1 + '秒后重新获取';
  76. setTimeout(this.countDown.bind(this), 1000);
  77. }
  78. },
  79. inputChange(e) {
  80. const key = e.currentTarget.dataset.key;
  81. this[key] = e.detail.value;
  82. },
  83. navBack() {
  84. uni.navigateBack();
  85. },
  86. toLogin() {
  87. const {
  88. password,
  89. oldpassword
  90. } = this;
  91. if (!oldpassword) {
  92. this.$queue.showToast("请输入旧密码");
  93. } else if (oldpassword.length < 6) {
  94. this.$queue.showToast("旧密码位数必须大于六位");
  95. } else if (!password) {
  96. this.$queue.showToast("请设置新密码");
  97. } else if (password.length < 6) {
  98. this.$queue.showToast("新密码位数必须大于六位");
  99. } else {
  100. this.logining = true;
  101. this.$queue.showLoading("正在修改密码中...");
  102. this.$Request.post("/app/user/updatePwd", {
  103. pwd : password,
  104. oldPwd : oldpassword,
  105. }).then(res => {
  106. uni.hideLoading();
  107. if (res.code === 0) {
  108. this.$queue.showToast('密码修改成功!下次请使用新密码登录!')
  109. setTimeout(function(){
  110. uni.navigateBack()
  111. },1000)
  112. } else {
  113. uni.showModal({
  114. showCancel: false,
  115. title: '密码修改失败',
  116. content: res.msg,
  117. });
  118. }
  119. });
  120. }
  121. },
  122. },
  123. }
  124. </script>
  125. <style lang='scss'>
  126. page {
  127. height: 100%;
  128. background: #F5F5F5 !important;
  129. }
  130. .container {
  131. padding-top: 32upx;
  132. position: relative;
  133. width: 100%;
  134. height: 100%;
  135. overflow: hidden;
  136. background: #F5F5F5 !important;
  137. }
  138. .wrapper {
  139. position: relative;
  140. z-index: 90;
  141. background: #ffffff;
  142. padding-bottom: 20px;
  143. }
  144. .input-content {
  145. padding: 32upx 80upx;
  146. }
  147. .confirm-btn {
  148. width: 600upx;
  149. height: 80upx;
  150. line-height: 80upx;
  151. border-radius: 60upx;
  152. margin-top: 32upx;
  153. background: #6696FF;
  154. color: #fff;
  155. font-size: 32upx;
  156. &:after {
  157. border-radius: 60px;
  158. }
  159. }
  160. </style>