password.vue 3.3 KB

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