password.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. <template>
  2. <view class="container">
  3. <view class="row flex">
  4. <text class="tit">{{$t('set.a3')}}</text>
  5. <input class="input" v-model="account" type="text" :placeholder="$t('reg.c3')"
  6. placeholder-class="placeholder" />
  7. </view>
  8. <view class="row flex">
  9. <text class="tit">{{$t('safe.b3')}}</text>
  10. <input class="input" v-model="password" type="password" :placeholder="$t('safe.b4')"
  11. placeholder-class="placeholder" />
  12. </view>
  13. <view class="row flex">
  14. <text class="tit">{{$t('safe.a7')}}</text>
  15. <input class="input" v-model="captcha" type="text" :placeholder="$t('safe.a6')"
  16. placeholder-class="placeholder" />
  17. <view class="code" @click="verification">{{ countDown == 0 ? '验证码' : countDown }}</view>
  18. </view>
  19. <button class="add-btn" :class="{'bg-gray':loding}" @click="loding?'':confirm()">{{$t('set.a5')}}</button>
  20. </view>
  21. </template>
  22. <script>
  23. import {
  24. verify
  25. } from '@/api/login.js';
  26. import {
  27. mapState
  28. } from 'vuex';
  29. import {
  30. registerReset
  31. } from '@/api/set.js';
  32. export default {
  33. data() {
  34. return {
  35. time: '', //保存倒计时对象
  36. countDown: 0, //倒计时
  37. account: '', //手机号
  38. captcha: '', //验证码
  39. password: '', //新密码
  40. loding: false, //是否载入中
  41. };
  42. },
  43. computed: {
  44. ...mapState("user", ['userInfo'])
  45. },
  46. onLoad() {
  47. if (this.userInfo.account == null) {
  48. this.account = '';
  49. } else {
  50. this.account = this.userInfo.account;
  51. }
  52. },
  53. watch: {
  54. // 监听倒计时
  55. countDown(i) {
  56. if (i == 0) {
  57. clearInterval(this.time);
  58. }
  59. }
  60. },
  61. methods: {
  62. //发送验证码
  63. verification() {
  64. let obj = this;
  65. if (this.account == '') {
  66. this.$api.msg(obj.$t("reg.a3"));
  67. return;
  68. }
  69. if (!/(^1[3|4|5|7|8][0-9]{9}$)/.test(this.account)) {
  70. this.$api.msg(obj.$t("safe.b8"));
  71. return;
  72. }
  73. // 判断是否在倒计时
  74. if (obj.countDown > 0) {
  75. return false;
  76. } else {
  77. obj.countDown = 60;
  78. obj.time = setInterval(() => {
  79. obj.countDown--;
  80. }, 1000);
  81. //调用验证码接口
  82. verify({
  83. phone: obj.account,
  84. type: ''
  85. })
  86. .then(({
  87. data
  88. }) => {})
  89. .catch(err => {
  90. console.log(err);
  91. });
  92. }
  93. },
  94. confirm(e) {
  95. this.loding = true;
  96. registerReset({
  97. account: this.account,
  98. captcha: this.captcha,
  99. password: this.password,
  100. })
  101. .then((
  102. data
  103. ) => {
  104. this.loding = false;
  105. this.$api.msg(data.msg);
  106. })
  107. .catch(err => {
  108. this.loding = false;
  109. console.log(err);
  110. });
  111. }
  112. }
  113. };
  114. </script>
  115. <style lang="scss">
  116. page {
  117. background-color: #051137;
  118. }
  119. .row {
  120. padding: 20rpx;
  121. background: #fff;
  122. background-color: #1F2A4A;
  123. border-radius: 10rpx;
  124. margin: 0 30rpx 30rpx 30rpx;
  125. .tit {
  126. flex-shrink: 0;
  127. font-size: $font-base;
  128. color: #FFF;
  129. width: 4em;
  130. }
  131. .input {
  132. text-align: left;
  133. font-size: $font-base;
  134. color: $color-gray;
  135. flex-grow: 1;
  136. }
  137. .iconlocation {
  138. font-size: 36rpx;
  139. color: $font-color-light;
  140. }
  141. }
  142. .add-btn {
  143. background: linear-gradient(90deg, #0C5AFA, #1356FF);
  144. margin: 30rpx;
  145. color: #FFF;
  146. font-size: 30rpx;
  147. text-align: center;
  148. border-radius: 10rpx;
  149. }
  150. .bg-gray {
  151. background-color: $color-gray;
  152. }
  153. .code {
  154. color: #FFF;
  155. font-size: 23rpx;
  156. border-left: 1px solid #eeeeee;
  157. width: 150rpx;
  158. flex-shrink: 0;
  159. text-align: center;
  160. }
  161. </style>