forget.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <template>
  2. <view>
  3. <view class="content">
  4. <!-- 主体 -->
  5. <view class="main">
  6. <view class="tips">若你忘记了密码,可在此重置为:123456。</view>
  7. <wInput v-model="phoneData" type="text" maxlength="11" placeholder="请输入手机号码"></wInput>
  8. <wInput v-model="userName" type="text" maxlength="11" placeholder="请输入姓名" isShowPass></wInput>
  9. </view>
  10. <wButton bgColor="linear-gradient(to bottom right, rgb(55,186,189), #94e2c4)" class="wbutton" text="重置密码"
  11. :rotate="isRotate" @click.native="startReset()"></wButton>
  12. </view>
  13. </view>
  14. </template>
  15. <script>
  16. let _this;
  17. import wInput from '../watch-login/watch-input.vue' //input
  18. import wButton from '../watch-login/watch-button.vue' //button
  19. export default {
  20. data() {
  21. return {
  22. phoneData: "", //电话
  23. userName: "", //姓名
  24. verCode: "", //验证码
  25. isRotate: false, //是否加载旋转
  26. }
  27. },
  28. components: {
  29. wInput,
  30. wButton
  31. },
  32. mounted() {
  33. _this = this;
  34. },
  35. methods: {
  36. async startReset(e) {
  37. //登录
  38. if (this.isRotate) {
  39. //判断是否加载中,避免重复点击请求
  40. return false;
  41. }
  42. if (this.phoneData.length == "") {
  43. uni.showToast({
  44. icon: 'none',
  45. position: 'bottom',
  46. title: '手机号不能为空'
  47. });
  48. return;
  49. }
  50. if (!/^1[3|4|5|6|7|8|9][0-9]\d{4,8}$/.test(this.phoneData)) {
  51. uni.showToast({
  52. icon: 'none',
  53. position: 'bottom',
  54. title: '手机号不正确'
  55. });
  56. return
  57. }
  58. if (this.userName.length == "") {
  59. uni.showToast({
  60. icon: 'none',
  61. position: 'bottom',
  62. title: '姓名不能为空'
  63. });
  64. return;
  65. }
  66. _this.isRotate = true
  67. // 发送请求
  68. const {
  69. data: res
  70. } = await this.$httpRequest({
  71. url: '/api/resetPwd?un=' + this.userName + "&phone=" + this.phoneData,
  72. method: 'get',
  73. urlType: 1,
  74. isNotToken: true
  75. })
  76. _this.isRotate = false;
  77. if (res.code == 200) {
  78. _this.isRotate = false
  79. uni.showToast({
  80. icon: 'ok',
  81. position: 'bottom',
  82. title: '已重置为默认密码'
  83. });
  84. this.$goto('login');
  85. } else {
  86. uni.showToast({
  87. icon: 'error',
  88. position: 'bottom',
  89. title: '手机号与姓名不匹配'
  90. });
  91. }
  92. _this.isRotate = false;
  93. },
  94. getVerCode() {
  95. //获取验证码
  96. if (_this.phoneData.length != 11) {
  97. uni.showToast({
  98. icon: 'none',
  99. position: 'bottom',
  100. title: '手机号不正确'
  101. });
  102. return false;
  103. }
  104. console.log("获取验证码")
  105. this.$refs.runCode.$emit('runCode'); //触发倒计时(一般用于请求成功验证码后调用)
  106. uni.showToast({
  107. icon: 'none',
  108. position: 'bottom',
  109. title: '模拟倒计时触发'
  110. });
  111. setTimeout(function() {
  112. _this.$refs.runCode.$emit('runCode', 0); //假装模拟下需要 终止倒计时
  113. uni.showToast({
  114. icon: 'none',
  115. position: 'bottom',
  116. title: '模拟倒计时终止'
  117. });
  118. }, 3000)
  119. },
  120. startRePass() {
  121. //重置密码
  122. if (this.isRotate) {
  123. //判断是否加载中,避免重复点击请求
  124. return false;
  125. }
  126. if (this.phoneData.length != 11) {
  127. uni.showToast({
  128. icon: 'none',
  129. position: 'bottom',
  130. title: '手机号不正确'
  131. });
  132. return false;
  133. }
  134. if (this.passData.length < 6) {
  135. uni.showToast({
  136. icon: 'none',
  137. position: 'bottom',
  138. title: '密码不正确'
  139. });
  140. return false;
  141. }
  142. if (this.verCode.length != 4) {
  143. uni.showToast({
  144. icon: 'none',
  145. position: 'bottom',
  146. title: '验证码不正确'
  147. });
  148. return false;
  149. }
  150. console.log("重置密码成功")
  151. _this.isRotate = true
  152. setTimeout(function() {
  153. _this.isRotate = false
  154. }, 3000)
  155. }
  156. }
  157. }
  158. </script>
  159. <style>
  160. @import url("../watch-login/css/icon.css");
  161. @import url("./css/main.css");
  162. </style>