password.vue 3.7 KB

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