forgetPwd.vue 4.3 KB

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