优化修改密码部分

master
lemon橪 2021-08-26 09:48:32 +08:00
parent 25fb26b7d0
commit 9a91e58f2c
3 changed files with 12 additions and 13 deletions

View File

@ -18,9 +18,9 @@ export function resetByMobile(params) {
* 发送验证码 * 发送验证码
* @param mobile * @param mobile
*/ */
export function sendMobile(mobile) { export function sendMobile(mobile,type='LOGIN') {
return http.request({ return http.request({
url: `${api.common}/sms/LOGIN/${mobile}`, url: `${api.common}/sms/${type}/${mobile}`,
method: "GET", method: "GET",
}); });
} }

View File

@ -9,17 +9,17 @@
<u-form :model="codeForm" class="form" ref="validateCodeForm"> <u-form :model="codeForm" class="form" ref="validateCodeForm">
<view v-if="!validateFlage"> <view v-if="!validateFlage">
<u-form-item label-width="120" label="手机号" prop="mobile"> <u-form-item label-width="120" label="手机号" prop="mobile">
<u-input v-model="codeForm.mobile" placeholder="请输入您的手机号" /> <u-input maxlength="11" v-model="codeForm.mobile" placeholder="请输入您的手机号" />
</u-form-item> </u-form-item>
<u-form-item class="sendCode" label-width="120" prop="code" label="验证码"> <u-form-item class="sendCode" label-width="120" prop="code" label="验证码">
<u-input v-model="codeForm.code" placeholder="请输入验证码" /> <u-input v-model="codeForm.code" placeholder="请输入验证码" />
<u-verification-code unique-key="page-edit" :seconds="seconds" @end="end" @start="start" ref="uCode" @change="codeChange"></u-verification-code> <u-verification-code unique-key="page-edit" :seconds="seconds" @end="end" @start="start" ref="uCode" @change="codeChange"></u-verification-code>
<view @tap="getCode" class="text-tips">{{ tips }}</view> <view @tap="getCode" class="text-tips">{{ tips }}</view>
</u-form-item> </u-form-item>
<view class="submit" @click="validatePhone"></view> <view class="submit" @click="validatePhone"></view>
<myVerification keep-running @send="verification" class="verification" ref="verification" business="LOGIN" /> <myVerification keep-running @send="verification" class="verification" ref="verification" business="FIND_USER" />
</view> </view>
<view v-if="validateFlage"> <view v-if="validateFlage">
<u-form-item label-width="120" label="旧密码"> <u-form-item label-width="120" label="旧密码">
@ -40,7 +40,7 @@
<script> <script>
import { sendMobile, resetByMobile, modifyPass } from "@/api/login"; import { sendMobile, resetByMobile, modifyPass } from "@/api/login";
import storage from "@/utils/storage.js";
import { md5 } from "@/utils/md5.js"; // md5 import { md5 } from "@/utils/md5.js"; // md5
import myVerification from "@/components/verification/verification.vue"; // import myVerification from "@/components/verification/verification.vue"; //
import uuid from "@/utils/uuid.modified.js"; import uuid from "@/utils/uuid.modified.js";
@ -108,7 +108,7 @@ export default {
uni.showLoading({ uni.showLoading({
title: "正在获取验证码", title: "正在获取验证码",
}); });
sendMobile(this.codeForm.mobile).then((res) => { sendMobile(this.codeForm.mobile, "FIND_USER").then((res) => {
uni.hideLoading(); uni.hideLoading();
// this.start() // this.start()
if (res.data.code == 200) { if (res.data.code == 200) {
@ -161,8 +161,7 @@ export default {
if (valid) { if (valid) {
resetByMobile(this.codeForm).then((res) => { resetByMobile(this.codeForm).then((res) => {
if (res.data.success) { if (res.data.success) {
storage.setAccessToken(res.data.result.accessToken); this.validateFlage = !this.validateFlage;
storage.setRefreshToken(res.data.result.refreshToken);
// //
uni.showToast({ uni.showToast({
title: "验证成功!", title: "验证成功!",
@ -238,6 +237,9 @@ page {
padding: 80rpx 0; padding: 80rpx 0;
border-radius: 20rpx; border-radius: 20rpx;
} }
.submit {
background: $light-color;
}
.box-tips { .box-tips {
margin: 0 72rpx; margin: 0 72rpx;
} }

View File

@ -17,13 +17,10 @@ export default {
methods: { methods: {
navigateTo(url) { navigateTo(url) {
uni.navigateTo({ uni.navigateTo({
url: url + `?mobile=${this.mobile}`, url: url,
}); });
}, },
}, },
onLoad(option) {
this.mobile = option.mobile;
},
}; };
</script> </script>