123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174 |
- <template>
- <view class="container">
- <view class="row flex">
- <text class="tit">{{$t('set.a3')}}</text>
- <input class="input" v-model="account" type="text" :placeholder="$t('reg.c3')"
- placeholder-class="placeholder" />
- </view>
- <view class="row flex">
- <text class="tit">{{$t('safe.b3')}}</text>
- <input class="input" v-model="password" type="password" :placeholder="$t('safe.b4')"
- placeholder-class="placeholder" />
- </view>
- <view class="row flex">
- <text class="tit">{{$t('safe.a7')}}</text>
- <input class="input" v-model="captcha" type="text" :placeholder="$t('safe.a6')"
- placeholder-class="placeholder" />
- <view class="code" @click="verification">{{ countDown == 0 ? '验证码' : countDown }}</view>
- </view>
- <button class="add-btn" :class="{'bg-gray':loding}" @click="loding?'':confirm()">{{$t('set.a5')}}</button>
- </view>
- </template>
- <script>
- import {
- verify
- } from '@/api/login.js';
- import {
- mapState
- } from 'vuex';
- import {
- registerReset
- } from '@/api/set.js';
- export default {
- data() {
- return {
- time: '', //保存倒计时对象
- countDown: 0, //倒计时
- account: '', //手机号
- captcha: '', //验证码
- password: '', //新密码
- loding: false, //是否载入中
- };
- },
- computed: {
- ...mapState("user", ['userInfo'])
- },
- onLoad() {
- if (this.userInfo.account == null) {
- this.account = '';
- } else {
- this.account = this.userInfo.account;
- }
- },
- watch: {
- // 监听倒计时
- countDown(i) {
- if (i == 0) {
- clearInterval(this.time);
- }
- }
- },
- methods: {
- //发送验证码
- verification() {
- let obj = this;
- if (this.account == '') {
- this.$api.msg(obj.$t("reg.a3"));
- return;
- }
- if (!/(^1[3|4|5|7|8][0-9]{9}$)/.test(this.account)) {
- this.$api.msg(obj.$t("safe.b8"));
- return;
- }
- // 判断是否在倒计时
- if (obj.countDown > 0) {
- return false;
- } else {
- obj.countDown = 60;
- obj.time = setInterval(() => {
- obj.countDown--;
- }, 1000);
- //调用验证码接口
- verify({
- phone: obj.account,
- type: ''
- })
- .then(({
- data
- }) => {})
- .catch(err => {
- console.log(err);
- });
- }
- },
- confirm(e) {
- this.loding = true;
- registerReset({
- account: this.account,
- captcha: this.captcha,
- password: this.password,
- })
- .then((
- data
- ) => {
- this.loding = false;
- this.$api.msg(data.msg);
- })
- .catch(err => {
- this.loding = false;
- console.log(err);
- });
- }
- }
- };
- </script>
- <style lang="scss">
- page {
- background-color: #051137;
- }
- .row {
- padding: 20rpx;
- background: #fff;
- background-color: #1F2A4A;
- border-radius: 10rpx;
- margin: 0 30rpx 30rpx 30rpx;
- .tit {
- flex-shrink: 0;
- font-size: $font-base;
- color: #FFF;
- width: 4em;
- }
- .input {
- text-align: left;
- font-size: $font-base;
- color: $color-gray;
- flex-grow: 1;
- }
- .iconlocation {
- font-size: 36rpx;
- color: $font-color-light;
- }
- }
- .add-btn {
- background: linear-gradient(90deg, #0C5AFA, #1356FF);
- margin: 30rpx;
- color: #FFF;
- font-size: 30rpx;
- text-align: center;
- border-radius: 10rpx;
- }
- .bg-gray {
- background-color: $color-gray;
- }
- .code {
- color: #FFF;
- font-size: 23rpx;
- border-left: 1px solid #eeeeee;
- width: 150rpx;
- flex-shrink: 0;
- text-align: center;
- }
- </style>
|