password.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. <template>
  2. <view class="container">
  3. <view class="row b-b">
  4. <text class="tit">手机号</text>
  5. <input class="input" v-model="account" type="text" placeholder="请填写手机号" placeholder-class="placeholder" />
  6. </view>
  7. <view class="row b-b">
  8. <text class="tit">验证码</text>
  9. <input class="input" v-model="captcha" type="text" placeholder="请填写验证码" placeholder-class="placeholder" />
  10. <view class="code" @click="verification">{{ countDown == 0 ? '验证码' : countDown }}</view>
  11. </view>
  12. <view class="row b-b">
  13. <text class="tit">新密码</text>
  14. <input class="input" v-model="password" type="password" placeholder="请填写新密码" placeholder-class="placeholder" />
  15. </view>
  16. <button class="add-btn" :class="{'bg-gray':loding}" @click="loding?'':confirm()">提交</button>
  17. </view>
  18. </template>
  19. <script>
  20. import { verify } from '@/api/login.js';
  21. import { registerReset } from '@/api/set.js';
  22. export default {
  23. data() {
  24. return {
  25. time: '', //保存倒计时对象
  26. countDown: 0, //倒计时
  27. account: '', //手机号
  28. captcha: '', //验证码
  29. password: '' ,//新密码
  30. loding:false,//是否载入中
  31. };
  32. },
  33. watch: {
  34. // 监听倒计时
  35. countDown(i) {
  36. if (i == 0) {
  37. clearInterval(this.time);
  38. }
  39. }
  40. },
  41. methods: {
  42. //发送验证码
  43. verification() {
  44. let obj = this;
  45. if (this.account == '') {
  46. this.$api.msg('请输入电话号码');
  47. return;
  48. }
  49. if (!/(^1[3|4|5|7|8][0-9]{9}$)/.test(this.account)) {
  50. this.$api.msg('请输入正确的手机号');
  51. return;
  52. }
  53. // 判断是否在倒计时
  54. if (obj.countDown > 0) {
  55. return false;
  56. } else {
  57. obj.countDown = 60;
  58. obj.time = setInterval(() => {
  59. obj.countDown--;
  60. }, 1000);
  61. //调用验证码接口
  62. verify({
  63. phone: obj.account,
  64. type: ''
  65. })
  66. .then(({ data }) => {})
  67. .catch(err => {
  68. console.log(err);
  69. });
  70. }
  71. },
  72. confirm(e) {
  73. this.loding = true;
  74. registerReset({
  75. account: this.account,
  76. captcha: this.captcha,
  77. password: this.password,
  78. })
  79. .then(({ data }) => {
  80. this.loding = false;
  81. this.$api.msg('修改成功');
  82. })
  83. .catch(err => {
  84. this.loding = true;
  85. console.log(err);
  86. });
  87. }
  88. }
  89. };
  90. </script>
  91. <style lang="scss">
  92. page {
  93. background: $page-color-base;
  94. }
  95. .container {
  96. padding-top: 30rpx;
  97. }
  98. .row {
  99. display: flex;
  100. align-items: center;
  101. position: relative;
  102. padding: 0 30rpx;
  103. height: 110rpx;
  104. background: #fff;
  105. .tit {
  106. flex-shrink: 0;
  107. width: 120rpx;
  108. font-size: 30rpx;
  109. color: $font-color-dark;
  110. }
  111. .input {
  112. flex: 1;
  113. font-size: 30rpx;
  114. color: $font-color-dark;
  115. }
  116. .iconlocation {
  117. font-size: 36rpx;
  118. color: $font-color-light;
  119. }
  120. }
  121. .add-btn {
  122. display: flex;
  123. align-items: center;
  124. justify-content: center;
  125. width: 690rpx;
  126. height: 80rpx;
  127. margin: 60rpx auto;
  128. font-size: $font-lg;
  129. color: #fff;
  130. background-color: $base-color;
  131. border-radius: 10rpx;
  132. // box-shadow: 1px 2px 5px rgba(219, 63, 96, 0.4);
  133. }
  134. .bg-gray{
  135. background-color: $color-gray;
  136. }
  137. .code {
  138. color: #5dbc7c;
  139. font-size: 23rpx;
  140. border-left: 1px solid #eeeeee;
  141. width: 150rpx;
  142. flex-shrink: 0;
  143. text-align: center;
  144. }
  145. </style>