password.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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" disabled 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. this.show = false;
  52. }
  53. },
  54. watch: {
  55. // 监听倒计时
  56. countDown(i) {
  57. if (i == 0) {
  58. clearInterval(this.time);
  59. }
  60. }
  61. },
  62. methods: {
  63. //发送验证码
  64. verification() {
  65. let obj = this;
  66. if (this.account == '') {
  67. this.$api.msg(obj.$t("reg.a3"));
  68. return;
  69. }
  70. if (!/(^1[3|4|5|7|8][0-9]{9}$)/.test(this.account)) {
  71. this.$api.msg(obj.$t("safe.b8"));
  72. return;
  73. }
  74. // 判断是否在倒计时
  75. if (obj.countDown > 0) {
  76. return false;
  77. } else {
  78. obj.countDown = 60;
  79. obj.time = setInterval(() => {
  80. obj.countDown--;
  81. }, 1000);
  82. //调用验证码接口
  83. verify({
  84. phone: obj.account,
  85. type: ''
  86. })
  87. .then(({
  88. data
  89. }) => {})
  90. .catch(err => {
  91. console.log(err);
  92. });
  93. }
  94. },
  95. confirm(e) {
  96. this.loding = true;
  97. registerReset({
  98. account: this.account,
  99. captcha: this.captcha,
  100. password: this.password,
  101. })
  102. .then(({
  103. data
  104. }) => {
  105. this.loding = false;
  106. this.$api.msg(obj.$t("safe.d3"));
  107. })
  108. .catch(err => {
  109. this.loding = false;
  110. console.log(err);
  111. });
  112. }
  113. }
  114. };
  115. </script>
  116. <style lang="scss">
  117. page {
  118. background-color: #051137;
  119. }
  120. .row {
  121. padding: 20rpx;
  122. background: #fff;
  123. background-color: #1F2A4A;
  124. border-radius: 10rpx;
  125. margin: 0 30rpx 30rpx 30rpx;
  126. .tit {
  127. flex-shrink: 0;
  128. font-size: $font-base;
  129. color: #FFF;
  130. width: 4em;
  131. }
  132. .input {
  133. text-align: left;
  134. font-size: $font-base;
  135. color: $color-gray;
  136. flex-grow: 1;
  137. }
  138. .iconlocation {
  139. font-size: 36rpx;
  140. color: $font-color-light;
  141. }
  142. }
  143. .add-btn {
  144. background: linear-gradient(90deg, #0C5AFA, #1356FF);
  145. margin: 30rpx;
  146. color: #FFF;
  147. font-size: 30rpx;
  148. text-align: center;
  149. border-radius: 10rpx;
  150. }
  151. .bg-gray {
  152. background-color: $color-gray;
  153. }
  154. .code {
  155. color: #FFF;
  156. font-size: 23rpx;
  157. border-left: 1px solid #eeeeee;
  158. width: 150rpx;
  159. flex-shrink: 0;
  160. text-align: center;
  161. }
  162. </style>