| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185 |
- <template>
- <view class="content">
- <view class="logo">
- <image style="height:104rpx;width:104rpx" src="/static/czzn-img/login/logo.jpg" mode="aspectFit" />
- <view class="app-name">{{$t('login.e')}}</view>
- </view>
- <!-- 账号密码登录 -->
- <view class="inp_box">
- <input type="text" v-model="forgotForm.mobile" :placeholder="this.$t('login.phonePlaceholder')" />
- </view>
- <view class="inp_box">
- <input type="text" v-model="forgotForm.code" :placeholder="this.$t('login.verifyCodePlaceholder')" />
- <button :class="time!=0?'load-reget':''" @click="getCode" :disabled='time!=0'
- class="get-code-btn">{{isGetCode?$t("login.reGetCode"):$t("login.getCode")}}{{time?`(${time}s)`:''}}</button>
- </view>
- <view class="inp_box">
- <input type="password" v-model="forgotForm.password"
- :placeholder="this.$t('register.passwordDigitsPlaceholder')" />
- </view>
- <view class="inp_box">
- <input type="password" v-model="forgotForm.confirmPassword"
- :placeholder="this.$t('register.passwordAgain')" />
- </view>
- <view class="btn-wrap">
- <button class="bind-btn" @click="resetPassword">{{$t('login.reset')}}</button>
- </view>
- </view>
- </template>
- <script>
- import {
- resetPassword,
- getTelCode
- } from '../../api/login'
- export default {
- data() {
- return {
- forgotForm: {
- mobile: "",
- code: "",
- password: "",
- confirmPassword: "",
- },
- time: 0,
- timer: '',
- isGetCode: false,
- }
- },
- methods: {
- backLogin() {
- uni.redirectTo({
- url: '/pages/login/login'
- })
- },
- resetPassword() {
- let phone = /^1[3-9]\d{9}$/
- if (this.forgotForm.mobile == '') {
- uni.showToast({
- title: this.$t('login.phonePlaceholder'),
- icon: "none",
- duration: 2500,
- })
- } else if (!phone.test(this.forgotForm.mobile)) {
- uni.showToast({
- title: this.$t('base.smsCode.phoneErrTip'),
- icon: "none",
- duration: 2500,
- })
- } else if (this.forgotForm.code == '') {
- uni.showToast({
- title: this.$t('login.verifyCodePlaceholder'),
- icon: "none",
- duration: 2500,
- })
- } else if (this.forgotForm.password == '' || this.forgotForm.confirmPassword == '') {
- uni.showToast({
- title: this.$t('login.verifyCodePlaceholder'),
- icon: "none",
- duration: 2500,
- })
- } else if (this.forgotForm.password !== this.forgotForm.confirmPassword) {
- uni.showToast({
- title: this.$t('login.diffrent'),
- icon: "none",
- duration: 2500,
- })
- } else {
- let data = {
- phone: this.forgotForm.mobile,
- newpassword1: this.forgotForm.password,
- verificationCode: this.forgotForm.code
- }
- resetPassword(data).then(res => {
- if (res.statusCode === 200) {
- if (res.data.msg) {
- uni.showToast({
- title: res.data.msg,
- icon: "none",
- duration: 2500,
- })
- } else {
- uni.showToast({
- title: '重置成功',
- icon: "none",
- duration: 1000,
- })
- setTimeout(() => {
- this.backLogin()
- }, 1200)
- }
- } else {
- uni.showToast({
- title: res.data.msg,
- icon: "none",
- duration: 2500,
- })
- }
- })
- }
- },
- getCode() {
- let phone = /^1[3-9]\d{9}$/
- if (this.forgotForm.mobile == '') {
- uni.showToast({
- title: this.$t('login.phonePlaceholder'),
- icon: "none",
- duration: 2500,
- })
- } else if (!phone.test(this.forgotForm.mobile)) {
- uni.showToast({
- title: this.$t('base.smsCode.phoneErrTip'),
- icon: "none",
- duration: 2500,
- })
- } else {
- getTelCode(this.forgotForm.mobile).then(res => {
- if (res.statusCode === 200) {
- if (res.data.code == 0) {
- if (res.data.msg) {
- uni.showToast({
- title: res.data.msg,
- icon: "none",
- duration: 2500,
- })
- return;
- }
- this.isGetCode = true
- this.time = 60
- this.forgotForm.code = ""
- this.forgotForm.password = ""
- this.forgotForm.confirmPassword = ""
- this.timer = setInterval(() => {
- this.time--
- if (this.time == 0) {
- clearInterval(this.timer)
- }
- }, 1000)
- }
- }
- })
- }
- },
- }
- }
- </script>
- <style>
- /* #ifndef APP-NVUE */
- view {
- display: flex;
- box-sizing: border-box;
- flex-direction: column;
- }
- page {
- box-sizing: border-box;
- padding: 0 48rpx 80rpx;
- height: 100%;
- }
- /* #endif*/
- </style>
- <style lang="scss" scoped>
- @import '../../common/css/login.scss';
- </style>
|