登录界面和注册界面修改密码界面完成前后端对接

master
Gary 3 months ago
parent 6a7d31e1c0
commit 5a1e37bc96

@ -1,7 +1,7 @@
{ {
"pages": [ "pages": [
/*-----------------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------------*/
/* { {
"path": "pages/transition/page1/page1", "path": "pages/transition/page1/page1",
"style": { "style": {
"navigationStyle": "custom" "navigationStyle": "custom"
@ -42,11 +42,11 @@
"style": { "style": {
"navigationStyle": "custom" "navigationStyle": "custom"
} }
},*/ },
/*------------------------------------------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------------------------------------------------*/
/* { {
"path": "pages/login/account_login/account_login", "path": "pages/login/account_login/account_login",
"style": { "style": {
"navigationStyle": "custom" "navigationStyle": "custom"
@ -69,18 +69,18 @@
"style": { "style": {
"navigationStyle": "custom" "navigationStyle": "custom"
} }
},*/ },
/*------------------------------------------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------------------------------------------------*/
/* { {
"path": "pages/information/sex/sex", "path": "pages/information/sex/sex",
"style": { "style": {
"navigationStyle": "custom" "navigationStyle": "custom"
} }
},*/ },
/*------------------------------------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------------------------------*/
/* { {
"path": "pages/information/boy_weight_start/boy_weight_start", "path": "pages/information/boy_weight_start/boy_weight_start",
"style": { "style": {
"navigationStyle": "custom" "navigationStyle": "custom"
@ -97,10 +97,10 @@
"style": { "style": {
"navigationStyle": "custom" "navigationStyle": "custom"
} }
},*/ },
/*------------------------------------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------------------------------------*/
/* { {
"path": "pages/information/boy_height_start/boy_height_start", "path": "pages/information/boy_height_start/boy_height_start",
"style": { "style": {
"navigationStyle": "custom" "navigationStyle": "custom"
@ -117,10 +117,10 @@
"style": { "style": {
"navigationStyle": "custom" "navigationStyle": "custom"
} }
},*/ },
/*-----------------------------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------------------------------------*/
/* { {
"path": "pages/information/girl_height_start/girl_height_start", "path": "pages/information/girl_height_start/girl_height_start",
"style": { "style": {
"navigationStyle": "custom" "navigationStyle": "custom"
@ -137,10 +137,10 @@
"style": { "style": {
"navigationStyle": "custom" "navigationStyle": "custom"
} }
},*/ },
/*------------------------------------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------------------------------------------------------------------*/
/* { {
"path": "pages/information/girl_weight_start/girl_weight_start", "path": "pages/information/girl_weight_start/girl_weight_start",
"style": { "style": {
"navigationStyle": "custom" "navigationStyle": "custom"
@ -157,23 +157,23 @@
"style": { "style": {
"navigationStyle": "custom" "navigationStyle": "custom"
} }
},*/ },
/*--------------------------------------------------------------------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------------------------------------------------------------------*/
/*----------------------------------------------------------使--------------------------------------------------*/ /*----------------------------------------------------------使--------------------------------------------------*/
/* { {
"path": "pages/information/purpose/purpose", "path": "pages/information/purpose/purpose",
"style": { "style": {
"navigationStyle": "custom" "navigationStyle": "custom"
} }
},*/ },
/*------------------------------------------------使-----------------------------------------------------------*/ /*------------------------------------------------使-----------------------------------------------------------*/
/*-------------------------------------------------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------------------------------------------------*/
/*{ {
"path": "pages/transition/page8/page8", "path": "pages/transition/page8/page8",
"style": { "style": {
"navigationStyle": "custom" "navigationStyle": "custom"
} }
},*/ },
/*--------------------------------------------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------------------------------------------*/
{ {

@ -26,22 +26,26 @@
<!-- 账号输入框 --> <!-- 账号输入框 -->
<view class="account_box login_form_item"> <view class="account_box login_form_item">
<view class="form_input_box"> <view class="form_input_box">
<input class="account" name="account" type="text" placeholder="请输入你的电话号码"/> <input class="account" v-model="phone_number" type="text" placeholder="请输入你的电话号码"/>
</view> </view>
<view class="error_tip" v-if="isPhoneError">*</view> <view class="error_tip" v-if="isPhoneError">*</view>
</view> </view>
<!-- 密码输入框 --> <!-- 密码输入框 -->
<view class="passage_box login_form_item" v-if="isPassagePage"> <view class="passage_box login_form_item" v-if="isPassagePage">
<view class="form_input_box passage_input_box"> <view class="form_input_box passage_input_box">
<input class="passage" name="passage" :password="isOpened" type="text" placeholder="请输入你的密码"/> <input class="passage" v-model="password" :password="isOpened" type="text" placeholder="请输入你的密码"/>
<image @click="openEyesEvent" class="eyes" :src="eyesStateIcon"></image> <image @click="openEyesEvent" class="eyes" :src="eyesStateIcon"></image>
</view> </view>
<view class="error_tip" v-if="isPassageError">*</view> <view class="error_tip" v-if="isPassageError">*</view>
</view> </view>
<!-- 验证码输入框 --> <!-- 验证码输入框 -->
<view class="captcha_box login_form_item" v-else> <view class="captcha_box login_form_item" v-else>
<view class="form_input_box captcha_input_box"> <view class="form_input_box captcha_input_box">
<input class="captcha" name="captcha" type="text" placeholder="请输入你的验证码"/> <input class="captcha" v-model="code" name="captcha" type="text" placeholder="请输入你的验证码"/>
<button class="captcha_button" @click="sendCaptchaEvent" <button class="captcha_button" @click="sendCaptchaEvent"
:style="{color:captchaButtonColor, backgroundColor:captchaButtonBackgroundColor}"> :style="{color:captchaButtonColor, backgroundColor:captchaButtonBackgroundColor}">
{{captchaButtonText}} {{captchaButtonText}}
@ -65,13 +69,13 @@
<image class="goto_register" src="../../../static/login/account_login/register.png"></image> <image class="goto_register" src="../../../static/login/account_login/register.png"></image>
</navigator> </navigator>
<!-- 其他登录部分 --> <!-- 其他登录部分 -->
<view class="otherways_part"> <!-- <view class="otherways_part">
<image class="otherways_tips" src="../../../static/login/account_login/other_ways.png"></image> <image class="otherways_tips" src="../../../static/login/account_login/other_ways.png"></image>
<view class="two_ways"> <view class="two_ways">
<image class="qq_icon" src="../../../static/login/account_login/qq_icon.png"></image> <image class="qq_icon" src="../../../static/login/account_login/qq_icon.png"></image>
<image class="weixin_icon" src="../../../static/login/account_login/weixin_icon.png"></image> <image class="weixin_icon" src="../../../static/login/account_login/weixin_icon.png"></image>
</view> </view>
</view> </view>-->
</view> </view>
</template> </template>
@ -84,6 +88,17 @@ var codeTime = ref(0); //验证码的倒计时
const captchaButtonBackgroundColor = computed(() => isSendCaptcha.value ? "#ABCBFF" : "#ffffff"); // const captchaButtonBackgroundColor = computed(() => isSendCaptcha.value ? "#ABCBFF" : "#ffffff"); //
const captchaButtonColor = computed(() => isSendCaptcha.value ? "#ffffff" : "#000364");// const captchaButtonColor = computed(() => isSendCaptcha.value ? "#ffffff" : "#000364");//
const captchaButtonText = computed(() => isSendCaptcha.value ? (codeTime.value+"s后重新发送"):"发送验证码") const captchaButtonText = computed(() => isSendCaptcha.value ? (codeTime.value+"s后重新发送"):"发送验证码")
const phone_number=ref("");
const password=ref("");
const code=ref("");//
const which_way_to_login = ref("0"); // 使0 使1
const access_token = ref("0"); //token
const isPassagePage = ref(true); // const isPassagePage = ref(true); //
const passageWordsBottomBorder = computed(() => isPassagePage.value? "0.1rem solid #094ABC":"none"); // const passageWordsBottomBorder = computed(() => isPassagePage.value? "0.1rem solid #094ABC":"none"); //
@ -99,11 +114,24 @@ const isCaptchaError = ref(false);
// //
function toCaptchaEvent(){ function toCaptchaEvent(){
isPassagePage.value = false; isPassagePage.value = false;
which_way_to_login.value=1;//
} }
//
function sendCaptchaEvent(){ function sendCaptchaEvent(){
console.log("send captcha"); //
if (codeTime.value>0){ // const isChinaPhone = /^1[3-9]\d{9}$/.test(phone_number.value);
if (!isChinaPhone) {
uni.showToast({
title: '请输入有效的中国大陆手机号',
icon: "none"
});
return; //
}
if (codeTime.value>0){ //
uni.showToast({ // uni.showToast({ //
title: '不能重复获取', title: '不能重复获取',
icon:"none" icon:"none"
@ -119,41 +147,184 @@ function sendCaptchaEvent(){
codeTime.value = 0; codeTime.value = 0;
} }
},1000) },1000)
}; }
} //
function login(){ const app = getApp();
//
//
const serverAddress = app.globalData.fit_journey_login_address + '/phone_code_register/getPhoneCode';
console.log(String(phoneNumber.value));
//
uni.request({ uni.request({
url: serverAddress, url: app.globalData.fit_journey_login_address + '/phone_code_register/getPhoneCode',
method: 'POST', method: 'POST',
header: { header: {
'Content-Type': 'application/x-www-form-urlencoded', 'content-type': 'application/x-www-form-urlencoded',
}, },
data: { data: {
phone: phoneNumber.value phone:String(phone_number.value)
}, },
success: (res) => { success: (res) => {
console.log(res.data); uni.showToast({
title: '发送验证码成功,请注意查收~',
icon: "none"
});
}, },
fail: (err) => { error: (res) => {
console.log("请求失败", err); console.log("请求失败!请求数据是", res);
} }
}); });
}
function login() {
console.log(which_way_to_login.value);
if (which_way_to_login.value === 0) { //
console.log("这里开始运行了");
//
const serverAddress = app.globalData.fit_journey_login_address + '/AccountLogin/PhonePasswordLogin';
console.log("后端服务器的地址是" + serverAddress);
console.log("发送的账号是" + String(phone_number.value));
console.log("发送的密码是" + String(password.value));
if(phone_number.value==null||code.value==null){
uni.showToast({
title: '手机号和密码不能为空',
icon: "none"
});
}
//
uni.request({
url: serverAddress,
method: 'POST',
header: {
'content-type': 'application/x-www-form-urlencoded',
},
data: {
phone: String(phone_number.value),
password: String(password.value)
},
success: (res) => {
if (res.statusCode === 500) {
uni.showToast({
title: '账号或密码错误',
icon: "none"
});
} else {
uni.showToast({
title: '登录成功',
icon: "none"
});
access_token.value = res.data.data.token;
console.log("登录成功!从后端收集的token是", access_token.value);
// token
uni.setStorage({
key: 'access_token', //
data: access_token.value, //
success: () => {
console.log("Token 已存储到本地!");
},
fail: () => {
console.error("Token 存储失败!");
}
});
console.log(access_token.value);
console.log("登录成功!从后端收集的token是", uni.getStorageSync('access_token'));
uni.navigateTo({
url: '/pages/information/sex/sex'//
})
}
},
error: (res) => {
console.log("请求失败!请求数据是", res);
uni.showToast({
title: '登录失败,服务器错误',
icon: "none"
});
}
});
} else if (which_way_to_login.value === 1) { //
console.log("验证码登录部分开始运行了");
//
const serverAddress = app.globalData.fit_journey_login_address + '/PhoneLogin/phoneLogin';
console.log("后端服务器的地址是" + serverAddress);
console.log("发送的账号是" + String(phone_number.value));
console.log("发送的code是" + String(code.value));
if(phone_number.value==null||code.value==null){
uni.showToast({
title: '手机号和验证码不能为空',
icon: "none"
});
}
//
uni.request({
url: serverAddress,
method: 'POST',
header: {
'content-type': 'application/x-www-form-urlencoded',
},
data: {
phone: String(phone_number.value),
code: String(code.value)
},
success: (res) => {
console.log(res);
if (res.statusCode === 500) {
uni.showToast({
title: '账号或密码错误,或账号没有进行注册',
icon: "none"
});
} else {
uni.showToast({
title: '登录成功',
icon: "none"
});
access_token.value = res.data.data.token;
console.log("登录成功!从后端收集的token是", access_token.value);
// token
uni.setStorage({
key: 'access_token', //
data: access_token.value, //
success: () => {
console.log("Token 已存储到本地!");
},
fail: () => {
console.error("Token 存储失败!");
}
});
console.log(access_token.value);
console.log("登录成功!从后端收集的token是", uni.getStorageSync('access_token'));
//
uni.navigateTo({
url: '/pages/information/sex/sex'//
})
}
},
error: (res) => {
console.log("请求失败!请求数据是", res);
uni.showToast({
title: '登录失败,服务器错误',
icon: "none"
})
}
})
}
}
/*
//TODO: //TODO:
console.log("login"); console.log("login");
uni.navigateTo({ uni.navigateTo({
url: '/pages/information/sex/sex'// url: '/pages/information/sex/sex'//
}) })*/
}
// //
function toPassageEvent(){ function toPassageEvent(){
isPassagePage.value = true; isPassagePage.value = true;
which_way_to_login.value=0;
} }
// //
function openEyesEvent() function openEyesEvent()

@ -11,7 +11,7 @@
<!-- 密码输入 --> <!-- 密码输入 -->
<view class="passage_box change_password_form_item"> <view class="passage_box change_password_form_item">
<view class="form_input_box passage_input_box"> <view class="form_input_box passage_input_box">
<input type="text" class="passage" :password="isOpened_1" placeholder="请输入你的密码"/> <input type="text" v-model="first_input_password" class="passage" :password="isOpened_1" placeholder="请输入你的密码"/>
<image @click="openEyesEvent_1" class="eyes" :src="eyesStateIcon_1"></image> <image @click="openEyesEvent_1" class="eyes" :src="eyesStateIcon_1"></image>
</view> </view>
<!-- <view class="error_tip" v-if="isPassageError">*</view> --> <!-- <view class="error_tip" v-if="isPassageError">*</view> -->
@ -19,7 +19,7 @@
<!-- 确认密码输入 --> <!-- 确认密码输入 -->
<view class="passage_box change_password_form_item"> <view class="passage_box change_password_form_item">
<view class="form_input_box passage_input_box"> <view class="form_input_box passage_input_box">
<input type="text" class="passage" :password="isOpened_2" placeholder="请再次确认密码"/> <input type="text" v-model="second_input_password" class="passage" :password="isOpened_2" placeholder="请再次确认密码"/>
<image @click="openEyesEvent_2" class="eyes" :src="eyesStateIcon_2"></image> <image @click="openEyesEvent_2" class="eyes" :src="eyesStateIcon_2"></image>
</view> </view>
<view class="error_tip" v-if="isPassageSameError">*</view> <view class="error_tip" v-if="isPassageSameError">*</view>
@ -42,10 +42,17 @@
</template> </template>
<script setup> <script setup>
import { ref, computed } from 'vue'; import { ref, onMounted } from 'vue';
const isPassageSameError = ref(false); const isPassageSameError = ref(false);
const first_input_password = ref(''); //
const second_input_password= ref(''); //
const phone_number = ref(''); //
const code= ref(''); //
const title = '成功'; // const title = '成功'; //
const content = '密码修改成功'; // const content = '密码修改成功'; //
const isOpenPopUp = ref(false);// const isOpenPopUp = ref(false);//
@ -54,7 +61,14 @@ const isOpened_1 = ref(true); //输入框是否密码显示的标志
const eyesStateIcon_1 = ref("../../../static/login/change_password/pictures/closedeyes.png"); const eyesStateIcon_1 = ref("../../../static/login/change_password/pictures/closedeyes.png");
const isOpened_2 = ref(true); // const isOpened_2 = ref(true); //
const eyesStateIcon_2 = ref("../../../static/login/change_password/pictures/closedeyes.png"); const eyesStateIcon_2 = ref("../../../static/login/change_password/pictures/closedeyes.png");
// 使 onLoad
onMounted(() => {
const options = getCurrentPages()[getCurrentPages().length - 1].options;
phone_number.value = options.phone_number || '';
code.value = options.code || '';
console.log('接收到的手机号是:', phone_number.value);
console.log('接收到的验证码是:', code.value);
});
// //
function openEyesEvent_1(){ function openEyesEvent_1(){
if (isOpened_1.value) if (isOpened_1.value)
@ -84,8 +98,68 @@ function openEyesEvent_2(){
// //
function ensureClickEvent(){ function ensureClickEvent(){
console.log('密码确认修改'); console.log(phone_number.value);
isOpenPopUp.value = true; // console.log(first_input_password.value);
console.log(second_input_password.value);
console.log(code.value);
if(first_input_password.value !== second_input_password.value){
uni.showToast({
title: '两次密码不相同',
icon: "none"
});
isPassageSameError.value = true;
}
if(first_input_password.value.length<6||first_input_password.value.length>10){
uni.showToast({
title: '密码必须在6-10位之间',
icon: "none"
});
}
//
//
const app = getApp();
//
uni.request({
url: app.globalData.fit_journey_login_address + '/ForgetPassword/FindPassword',
method: 'POST',
header: {
'content-type': 'application/x-www-form-urlencoded',
},
data: {
phone:String(phone_number.value),
code:String (code.value),
newPassword:String(first_input_password.value)
},
success: (res) => {
if(res.data.code===200){
uni.showToast({
title: '修改密码成功!',
icon: "none"
});
}else if(res.data.code===400){
uni.showToast({
title: '修改密码失败!',
icon: "none"
});
}
uni.navigateTo({
url: '/pages/login/account_login/account_login',
animationType: 'pop-in',
animationDuration: 200
});
},
error: (res) => {
console.log("请求失败!请求数据是", res);
uni.showToast({
title: '发送验证码成功,请注意查收~',
icon: "none"
});
}
});
/*console.log('');
isOpenPopUp.value = true; //*/
} }
function onOpenUpClick(){ function onOpenUpClick(){
//TODO: //TODO:
@ -103,101 +177,5 @@ function onClosePopUPClick(){
</script> </script>
<style lang="scss"> <style lang="scss">
.change_password_box{ @import "@/static/login/change_password/css/change_password.scss";
background-image: url("../../../static/login/change_password/pictures/background.png");
background-size: cover;
background-position: center;
height: 100vh;
width: auto;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
position: relative;
object-fit: contain;
//
.return_image{
position: absolute;
left: 16.5%;
right: 80.1%;
top: 8.62%;
bottom: 89.09%;
width: 0.8rem;
height: auto;
object-fit: contain;
}
//
.change_passage_words{
position: absolute;
left: 12.4%;
top: 30.8%;
font-family: 'PingFang SC';
font-size: 1.4rem;
color: #000364;
}
//
.change_password_form{
position: absolute;
width: 74.5%;
height: 33.6%;
top: 40%;
//
.change_password_form_item{
height: auto;
margin-bottom: 5%;
.form_input_box{
padding-left: 3%;
padding-right: 3%;
background-color: #D5E9FF;
border-radius: 12px;
}
.error_tip{
margin-top: 0.6vh;
padding-left: 3%;
font-size: 0.8rem;
color: #FF1E1E;
}
}
//
.passage_box{
display: flex;
flex-direction: column;
.passage_input_box{
display: flex;
align-items: center;
background-color: #D5E9FF;
border-radius: 12px;
position: relative;
.passage{
height: 5.5vh;
padding-left: 11%;
background-image: url("../../../static/login/change_password/pictures/lock_icon.png");
background-repeat: no-repeat;
background-size: 0.8rem;
background-position: 4.7% 50%;
font-size: 0.8rem;
}
.eyes{
width: 1rem;
height: 1rem;
position: absolute;
right: 13%;
}
}
}
//
.ensure_button{
display: flex;
align-items: center;
justify-content: center;
margin-top: 8%;
height: 5.5vh;
border-radius: 12px;
background-color: #4A69F7;
color: #FFFCFC;
text-align: center;
font-size: 1.2rem;
}
}
}
</style> </style>

@ -11,14 +11,14 @@
<!-- 手机号输入 --> <!-- 手机号输入 -->
<view class="phone_number_box forget_passage_form_item"> <view class="phone_number_box forget_passage_form_item">
<view class="form_input_box"> <view class="form_input_box">
<input type="text" class="phone_number" placeholder="请输入你的电话号码"/> <input type="text" v-model="phone_number" class="phone_number" placeholder="请输入你的电话号码"/>
</view> </view>
<view class="error_tip" v-if="isPhoneError">*</view> <view class="error_tip" v-if="isPhoneError">*</view>
</view> </view>
<!-- 验证码输入 --> <!-- 验证码输入 -->
<view class="captcha_box forget_passage_form_item"> <view class="captcha_box forget_passage_form_item">
<view class="form_input_box captcha_input_box"> <view class="form_input_box captcha_input_box">
<input type="text" class="captcha" placeholder="请输入你的验证码"/> <input type="text" v-model="code" class="captcha" placeholder="请输入你的验证码"/>
<button class="captcha_button" @click="sendCaptchaEvent" <button class="captcha_button" @click="sendCaptchaEvent"
:style="{color:captchaButtonColor, backgroundColor:captchaButtonBackgroundColor}"> :style="{color:captchaButtonColor, backgroundColor:captchaButtonBackgroundColor}">
{{captchaButtonText}} {{captchaButtonText}}
@ -36,45 +36,90 @@
<script setup> <script setup>
import { ref, computed } from 'vue'; import { ref, computed } from 'vue';
const code = ref("");
const isPhoneError = ref(false); const isPhoneError = ref(false);
const isCaptchaError = ref(false); const isCaptchaError = ref(false);
const phone_number =ref("");
const isSendCaptcha = ref(false); // const isSendCaptcha = ref(false); //
var codeTime = ref(0); // var codeTime = ref(0); //
const captchaButtonBackgroundColor = computed(() => isSendCaptcha.value ? "#ABCBFF" : "#ffffff"); // const captchaButtonBackgroundColor = computed(() => isSendCaptcha.value ? "#ABCBFF" : "#ffffff"); //
const captchaButtonColor = computed(() => isSendCaptcha.value ? "#ffffff" : "#000364");// const captchaButtonColor = computed(() => isSendCaptcha.value ? "#ffffff" : "#000364");//
const captchaButtonText = computed(() => isSendCaptcha.value ? (codeTime.value+"s后重新发送"):"发送验证码"); const captchaButtonText = computed(() => isSendCaptcha.value ? (codeTime.value+"s后重新发送"):"发送验证码");
//
function sendCaptchaEvent(){ function sendCaptchaEvent(){
console.log("send captcha"); //
if (codeTime.value>0){ // const isChinaPhone = /^1[3-9]\d{9}$/.test(phone_number.value);
uni.showToast({ // if (!isChinaPhone) {
title: '不能重复获取', uni.showToast({
icon:"none" title: '请输入有效的中国大陆手机号',
}); icon: "none"
} else{ // });
codeTime.value = 60; return; //
isSendCaptcha.value = true; }
var timer = setInterval(()=>{ if (codeTime.value>0){ //
codeTime.value--; uni.showToast({ //
if(codeTime.value<1){ title: '不能重复获取',
clearInterval(timer); icon:"none"
isSendCaptcha.value = false; });
codeTime.value = 0; } else{ //
} codeTime.value = 60;
},1000) isSendCaptcha.value = true;
}; var timer = setInterval(()=>{
} codeTime.value--;
if(codeTime.value<1){
clearInterval(timer);
isSendCaptcha.value = false;
codeTime.value = 0;
}
},1000)
}
//
const app = getApp();
//
uni.request({
url: app.globalData.fit_journey_login_address + '/phone_code_register/getPhoneCode',
method: 'POST',
header: {
'content-type': 'application/x-www-form-urlencoded',
},
data: {
phone:String(phone_number.value)
},
success: (res) => {
uni.showToast({
title: '发送验证码成功,请注意查收~',
icon: "none"
});
},
error: (res) => {
console.log("请求失败!请求数据是", res);
}
});
}
// //
function nextClickEvent(){ function nextClickEvent() {
uni.navigateTo({
url:'/pages/login/change_password/change_password',
animationType: 'pop-in',
animationDuration: 200 const isChinaPhone = /^1[3-9]\d{9}$/.test(phone_number.value);
}) if (!isChinaPhone) {
uni.showToast({
title: '请输入有效的中国大陆手机号',
icon: "none"
});
return; //
}
// 使 encodeURIComponent
const encodedPhoneNumber = encodeURIComponent(phone_number.value);
const encodedCode = encodeURIComponent(code.value);
console.log("携带参数跳转",phone_number.value,code.value);
uni.navigateTo({
url: `/pages/login/change_password/change_password?phone_number=${encodedPhoneNumber}&code=${encodedCode}`,
animationType: 'pop-in',
animationDuration: 200
});
} }
</script> </script>

@ -13,14 +13,14 @@
<!-- 手机号输入 --> <!-- 手机号输入 -->
<view class="phone_number_box register_form_item"> <view class="phone_number_box register_form_item">
<view class="form_input_box"> <view class="form_input_box">
<input v-model="phonenum" type="text" class="phone_number" placeholder="请输入你的电话号码"/> <input v-model="phone_number" type="text" class="phone_number" placeholder="请输入你的电话号码"/>
</view> </view>
<view class="error_tip" v-if="isPhoneError">*</view> <view class="error_tip" v-if="isPhoneError">*</view>
</view> </view>
<!-- 验证码输入 --> <!-- 验证码输入 -->
<view class="captcha_box register_form_item"> <view class="captcha_box register_form_item">
<view class="form_input_box captcha_input_box"> <view class="form_input_box captcha_input_box">
<input v-model="captchanum" class="captcha" name="captcha" type="text" placeholder="请输入你的验证码"/> <input v-model="code" class="captcha" name="captcha" type="text" placeholder="请输入你的验证码"/>
<button class="captcha_button" @click="sendCaptchaEvent" <button class="captcha_button" @click="sendCaptchaEvent"
:style="{color:captchaButtonColor, backgroundColor:captchaButtonBackgroundColor}"> :style="{color:captchaButtonColor, backgroundColor:captchaButtonBackgroundColor}">
{{captchaButtonText}} {{captchaButtonText}}
@ -71,11 +71,10 @@ import { ref, computed } from 'vue';
const app = getApp(); const app = getApp();
/*手机号框相关变量*/ /*手机号框相关变量*/
const phonenum = ref(); // const phone_number = ref(""); //
const isPhoneError = ref(false);// const isPhoneError = ref(false);//
const code=ref("");
/*验证码框相关变量*/ /*验证码框相关变量*/
const captchanum = ref(); //
const isCaptchaError = ref(false); // const isCaptchaError = ref(false); //
const isSendCaptcha = ref(false); // const isSendCaptcha = ref(false); //
var codeTime = ref(0); // var codeTime = ref(0); //
@ -110,13 +109,13 @@ const pMatch = /^1(3[0-9]|4[01456879]|5[0-35-9]|6[2567]|7[0-8]|8[0-9]|9[0-35-9])
function checkPhone(){ function checkPhone(){
var flag=true var flag=true
// //
if (phonenum.value==undefined){ if (phone_number.value===undefined){
flag = false flag = false
uni.showToast({ // uni.showToast({ //
title: '手机号不能为空', title: '手机号不能为空',
icon:"error", icon:"error",
}); });
}else if (!pMatch.test(phonenum.value)){ }else if (!pMatch.test(phone_number.value)){
flag = false flag = false
// isPhoneError.value = true // isPhoneError.value = true
uni.showToast({ // uni.showToast({ //
@ -129,49 +128,57 @@ function checkPhone(){
return flag return flag
} }
function sendCaptchaEvent(){ function sendCaptchaEvent(){
//TODO: //
console.log("点击发送验证码按钮"); const isChinaPhone = /^1[3-9]\d{9}$/.test(phone_number.value);
// if (!isChinaPhone) {
if (checkPhone()){ uni.showToast({
// title: '请输入有效的中国大陆手机号',
if (codeTime.value>0){ // icon: "none"
uni.showToast({ // });
title: '不能重复获取', return; //
icon:"none" }
}); if (codeTime.value>0){ //
} else{ // uni.showToast({ //
codeTime.value = 60; title: '不能重复获取',
isSendCaptcha.value = true; icon:"none"
var timer = setInterval(()=>{ });
codeTime.value--; } else{ //
if(codeTime.value<1){ codeTime.value = 60;
clearInterval(timer); isSendCaptcha.value = true;
isSendCaptcha.value = false; var timer = setInterval(()=>{
codeTime.value = 0; codeTime.value--;
} if(codeTime.value<1){
},1000) clearInterval(timer);
}; isSendCaptcha.value = false;
// codeTime.value = 0;
uni.request({ }
// url:app.globalData.fit_journey_login_address+'/phone_code_register/getPhoneCode', },1000)
url:'http://47.122.61.54:8084/phone_code_register/getPhoneCode', }
method:'POST', //
header:{ const app = getApp();
'Content-Type':'application/x-www-form-urlencoded', //
}, uni.request({
data:{ url: app.globalData.fit_journey_login_address + '/phone_code_register/getPhoneCode',
phone:phonenum.value method: 'POST',
}, header: {
success:(res)=>{ 'content-type': 'application/x-www-form-urlencoded',
console.log('发送验证码请求成功:'+res.data) },
}, data: {
fail:(err)=>{ phone:String(phone_number.value)
console.log('发送验证码请求失败') },
console.log(err) success: (res) => {
} uni.showToast({
}) title: '发送验证码成功,请注意查收~',
} icon: "none"
});
},
error: (res) => {
console.log("请求失败!请求数据是", res);
}
});
} }
/*-----密码码相关函数-----*/ /*-----密码码相关函数-----*/
@ -206,17 +213,15 @@ function openEyesEvent_2(){
/*-----注册按钮相关函数-----*/ /*-----注册按钮相关函数-----*/
function checkSubmit(){ function checkSubmit(){
//TODO:
var flag = true var flag = true
// //
if (phonenum.value==undefined){ if (phone_number.value===undefined){
flag = false flag = false
uni.showToast({ // uni.showToast({ //
title: '手机号不能为空', title: '手机号不能为空',
icon:"error", icon:"error",
}); });
}else if (!pMatch.test(phonenum.value)){ }else if (!pMatch.test(phone_number.value)){
flag = false flag = false
// isPhoneError.value = true // isPhoneError.value = true
uni.showToast({ // uni.showToast({ //
@ -226,22 +231,27 @@ function checkSubmit(){
} else { } else {
isPhoneError.value = false isPhoneError.value = false
} }
// //
if (passagenum.value==undefined){ if (passagenum.value===undefined){
flag = false flag = false
uni.showToast({ // uni.showToast({ //
title: '密码不能为空', title: '密码不能为空',
icon:"error", icon:"error",
}); });
}else if (passagesamenum.value==undefined){ }else if (passagesamenum.value===undefined){
// //
flag = false flag = false
uni.showToast({ // uni.showToast({ //
title: '请再输入密码', title: '请再输入密码',
icon:"error", icon:"error",
}); });
}else if (passagenum.value!=passagesamenum.value){ }else if(passagenum.value.length < 6 || passagenum.value.length > 10) {
flag = false;
uni.showToast({
title: '密码长度必须为6到10位',
icon: "error",
});
} else if (passagenum.value!==passagesamenum.value){
// //
flag = false flag = false
// isPassageSameError.value = true // isPassageSameError.value = true
@ -252,9 +262,8 @@ function checkSubmit(){
} else{ } else{
isPassageSameError.value = false isPassageSameError.value = false
} }
// //
if (captchanum.value==undefined){ if (code.value===undefined){
flag = false flag = false
// isCaptchaError.value = true // isCaptchaError.value = true
uni.showToast({ // uni.showToast({ //
@ -264,48 +273,70 @@ function checkSubmit(){
} else{ } else{
isCaptchaError.value = false isCaptchaError.value = false
} }
return flag return flag
} }
function registerEvent(){ function registerEvent(){
//TODO: console.log(code.value);
// console.log(phone_number.value);
console.log(passagenum.value);
if (checkSubmit()){ if (checkSubmit()){
// //
console.log("服务器地址是:"+app.globalData.fit_journey_login_address);
uni.request({ uni.request({
// url:app.globalData.fit_journey_login_address+'/phone_code_register/registerByPhone', url:app.globalData.fit_journey_login_address+'/phone_code_register/registerByPhone',
url:'http://47.122.61.54:8084/phone_code_register/registerByPhone', header: {
'content-type': 'application/x-www-form-urlencoded',
},
method:'POST', method:'POST',
data:{ data:{
code:captchanum.value, code:code.value,
phone:phonenum.value phone:phone_number.value,
password:passagenum.value
}, },
success:(res)=>{ success:(res)=>{
console.log('注册成功:'+res.data) if(res.data.code === 200) {
isRegisterSuccess.value = true isRegisterSuccess.value = true
isOpenPopUp.value = true // isOpenPopUp.value = true
}, }else if(res.data.code===400) {
fail:(err)=>{ uni.showToast({
console.log('注册失败'+err) title: '手机号已经被注册了~',
isRegisterSuccess.value = false icon: "error",
isOpenPopUp.value = true // });
} }else if(res.data.code===401) {
}) uni.showToast({
} title: '验证码错误~',
icon: "error",
});
}else if(res.data.code===500) {
uni.showToast({
title: '验证码过期~',
icon: "error",
});
}
},
fail:(err)=>{
isRegisterSuccess.value = false
isOpenPopUp.value = true //
}
})
}
} }
/*-----弹窗相关函数-----*/ /*-----弹窗相关函数-----*/
function onOpenUpClick(){ function onOpenUpClick(){
//TODO:
uni.navigateTo({ uni.navigateTo({
url: '/pages/login/account_login/account_login', url: '/pages/login/account_login/account_login',
animationType: 'pop-in', // animationType: 'pop-in',
animationDuration: 200 animationDuration: 200
}); });
} }
function onClosePopUPClick(){ function onClosePopUPClick(){
//TODO:
isOpenPopUp.value = false; isOpenPopUp.value = false;
} }

@ -0,0 +1,97 @@
.change_password_box{
background-image: url("@/static/login/change_password/pictures/background.png");
background-size: cover;
background-position: center;
height: 100vh;
width: auto;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
position: relative;
object-fit: contain;
//
.return_image{
position: absolute;
left: 16.5%;
right: 80.1%;
top: 8.62%;
bottom: 89.09%;
width: 0.8rem;
height: auto;
object-fit: contain;
}
//
.change_passage_words{
position: absolute;
left: 12.4%;
top: 30.8%;
font-family: 'PingFang SC';
font-size: 1.4rem;
color: #000364;
}
//
.change_password_form{
position: absolute;
width: 74.5%;
height: 33.6%;
top: 40%;
//
.change_password_form_item{
height: auto;
margin-bottom: 5%;
.form_input_box{
padding-left: 3%;
padding-right: 3%;
background-color: #D5E9FF;
border-radius: 12px;
}
.error_tip{
margin-top: 0.6vh;
padding-left: 3%;
font-size: 0.8rem;
color: #FF1E1E;
}
}
//
.passage_box{
display: flex;
flex-direction: column;
.passage_input_box{
display: flex;
align-items: center;
background-color: #D5E9FF;
border-radius: 12px;
position: relative;
.passage{
height: 5.5vh;
padding-left: 11%;
background-image: url("@/static/login/change_password/pictures/lock_icon.png");
background-repeat: no-repeat;
background-size: 0.8rem;
background-position: 4.7% 50%;
font-size: 0.8rem;
}
.eyes{
width: 1rem;
height: 1rem;
position: absolute;
right: 13%;
}
}
}
//
.ensure_button{
display: flex;
align-items: center;
justify-content: center;
margin-top: 8%;
height: 5.5vh;
border-radius: 12px;
background-color: #4A69F7;
color: #FFFCFC;
text-align: center;
font-size: 1.2rem;
}
}
}
Loading…
Cancel
Save