forget.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <template>
  2. <view class="forget">
  3. <view class="content">
  4. <!-- 主体 -->
  5. <view class="main">
  6. <view class="tips">若你忘记了密码,可在此重置新密码。</view>
  7. <wInput
  8. v-model="phoneData"
  9. type="text"
  10. maxlength="11"
  11. placeholder="请输入手机号码"
  12. ></wInput>
  13. <wInput
  14. v-model="passData"
  15. type="password"
  16. maxlength="11"
  17. placeholder="请输入新密码"
  18. isShowPass
  19. ></wInput>
  20. <wInput
  21. v-model="verCode"
  22. type="number"
  23. maxlength="4"
  24. placeholder="验证码"
  25. isShowCode
  26. codeText="获取重置码"
  27. setTime="30"
  28. ref="runCode"
  29. @setCode="getVerCode()"
  30. ></wInput>
  31. </view>
  32. <wButton
  33. class="wbutton"
  34. text="重置密码"
  35. :rotate="isRotate"
  36. @click.native="startRePass()"
  37. ></wButton>
  38. </view>
  39. </view>
  40. </template>
  41. <script>
  42. let _this;
  43. import wInput from '../../components/watch-login/watch-input.vue' //input
  44. import wButton from '../../components/watch-login/watch-button.vue' //button
  45. export default {
  46. data() {
  47. return {
  48. phoneData: "", //电话
  49. passData: "", //密码
  50. verCode:"", //验证码
  51. isRotate: false, //是否加载旋转
  52. }
  53. },
  54. components:{
  55. wInput,
  56. wButton
  57. },
  58. mounted() {
  59. _this= this;
  60. },
  61. methods: {
  62. getVerCode(){
  63. //获取验证码
  64. if (_this.phoneData.length != 11) {
  65. uni.showToast({
  66. icon: 'none',
  67. position: 'bottom',
  68. title: '手机号不正确'
  69. });
  70. return false;
  71. }
  72. console.log("获取验证码")
  73. this.$refs.runCode.$emit('runCode'); //触发倒计时(一般用于请求成功验证码后调用)
  74. uni.showToast({
  75. icon: 'none',
  76. position: 'bottom',
  77. title: '模拟倒计时触发'
  78. });
  79. setTimeout(function(){
  80. _this.$refs.runCode.$emit('runCode',0); //假装模拟下需要 终止倒计时
  81. uni.showToast({
  82. icon: 'none',
  83. position: 'bottom',
  84. title: '模拟倒计时终止'
  85. });
  86. },3000)
  87. },
  88. startRePass() {
  89. //重置密码
  90. if(this.isRotate){
  91. //判断是否加载中,避免重复点击请求
  92. return false;
  93. }
  94. if (this.phoneData.length != 11) {
  95. uni.showToast({
  96. icon: 'none',
  97. position: 'bottom',
  98. title: '手机号不正确'
  99. });
  100. return false;
  101. }
  102. if (this.passData.length < 6) {
  103. uni.showToast({
  104. icon: 'none',
  105. position: 'bottom',
  106. title: '密码不正确'
  107. });
  108. return false;
  109. }
  110. if (this.verCode.length != 4) {
  111. uni.showToast({
  112. icon: 'none',
  113. position: 'bottom',
  114. title: '验证码不正确'
  115. });
  116. return false;
  117. }
  118. console.log("重置密码成功")
  119. _this.isRotate=true
  120. setTimeout(function(){
  121. _this.isRotate=false
  122. },3000)
  123. }
  124. }
  125. }
  126. </script>
  127. <style>
  128. @import url("../../components/watch-login/css/icon.css");
  129. @import url("./css/main.css");
  130. </style>