uniapp手机号认证注册的一个页面

news/2024/10/1 21:35:53

今天主要在uniapp设计了一个通过手机号认证注册的一个页面,但是今天只完成了前端页面的部分。并且能成功的连接上对应的后端地址。

复制代码
<template><view class="container"><view class="logo"><!-- 这里放置你的应用 logo --><image src="/static/logo.png" class="logo-img" mode="aspectFit" /></view><view class="form-group"><text class="label">手机号:</text><input type="tel" v-model="phoneNumber" placeholder="请输入手机号" /></view><view class="form-group"><text class="label">验证码:</text><input type="text" v-model="verificationCode" placeholder="请输入验证码" /><button @click="getVerificationCode" :disabled="countdown > 0||phoneNumber.length !== 11||!isPhoneNumberValid" :class="{ 'code-btn-active': countdown <= 0 }">{{ countdown > 0 ? '重新获取('+ countdown + ' s)' : '获取验证码' }}</button></view><button class="regis-btn" @click="regis" :disabled="phoneNumber.length !== 11 || verificationCode === ''|| !isPhoneNumberValid">注册</button></view>
</template><script>
export default {data() {return {phoneNumber: '',verificationCode: '',countdown: 0,mes:''};},computed: {isPhoneNumberValid() {return /^\d{11}$/.test(this.phoneNumber); // 使用正则表达式检验电话号码是否全是数字且长度为11位}},methods: {regis() {//注册},getVerificationCode() {var self=this// 模拟发送验证码// 模拟倒计时this.countdown = 60; // 倒计时时间(秒)const timer = setInterval(() => {if (this.countdown > 0) {this.countdown--;} else {clearInterval(timer);this.countdown = 0;}}, 1000);uni.hideKeyboard()  // setTimeout(()=>// {//      uni.showToast({//      title:'验证码已发送',// icon:'success'//  });// },1000);uni.request({url:this.$BASE_URL.BASE_URL+"/regis/getcode",data:{phone:self.phoneNumber},success:(res)=>{self.mes=res.data;console.log(res.data)uni.showToast({title:self.mes,});}})}}
};
</script><style>
html, body {height: 100%; /* 设置页面高度为100% */margin: 0; /* 去除页面的默认边距 */
}
.container {background: linear-gradient(to bottom, #FFFFE0 0%, #87CEEB 250%); /* 使用线性渐变背景 *padding: 20px; /* 设置内边距 */height: 100%;height: 100%; /* 让容器充满整个页面 */padding: 20px; /* 设置内边距 */border-radius: 10px; /* 设置圆角 */display: flex; /* 使用 Flex 布局 */flex-direction: column; /* 垂直布局 */justify-content: top; /* 内容垂直居中 */align-items: center; /* 内容水平居中 */
}.logo {margin-bottom: 30px;
}.logo-img {width: 100px;height: 100px;border-radius: 50%;
}.form-group {margin-bottom: 20px;display: flex;align-items: center;justify-content: center;
}.label {font-weight: bold;margin-right: 10px;
}input {flex: 1;padding: 10px;border-radius: 5px;font-size: 18px;background-color: rgba(255, 255, 255, 0.3); /* 设置背景为浅白色并透明 */
}.code-btn-active {display: flex; /* 使用 flex 布局 */align-items: center; /* 垂直居中 */justify-content: center; /* 水平居中 */padding: 10px 15px;background-color: #00aaff;color: #ffffff;border: none;border-radius: 5px;cursor: pointer;font-size: 14px;transition: background-color 0.3s;height: 45px ;
}
button{display: flex; /* 使用 flex 布局 */align-items: center; /* 垂直居中 */justify-content: center; /* 水平居中 */padding: 10px 15px;background-color: #00aaff;color: #ffffff;border: none;border-radius: 5px;cursor: pointer;font-size: 14px;transition: background-color 0.3s;
}
/* 禁用状态下的样式保持不变 */
.button:hover {background-color: #0056b3;
}
button:disabled {background-color: #ccc;cursor: not-allowed;
}
.regis-btn {width: 100%;
}
/* .countdown {font-size: 12px;color: #888;margin-top: 10px;
} */
.code-btn:hover,
.regis-btn:hover {background-color: rgba(255, 255, 255, 0.8); /* 鼠标悬停时的背景色,这里使用半透明白色 */
}
</style>
复制代码

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.ryyt.cn/news/44959.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈,一经查实,立即删除!

相关文章

增补博客 第二十九篇 计算机网络复习四

第五章 运输层 1.运输层的作用 运输层向它上面的应用层提供通信服务(提供端到端,进程到进程的可靠通信),为运行在不同host上的进程提供逻辑通信,向高层用户屏蔽通信子网的细节 2.UDP和TCP的特点,及使用它们的应用程序,熟知端口号 UDP和TCP的特点:UDP支持单播、多播、广…

LeetCode 633 Sum of Square Numbers All In One

LeetCode 633 Sum of Square Numbers All In One 633. Sum of Square Numbers Math.sqrt Math.trunc Math.powLeetCode 633 Sum of Square Numbers All In OneSum of Square NumberssolutionsMath.sqrt / 平方根function judgeSquareSum(c: number): boolean {let max = Math.t…

又跳槽!3年Java经验收割成都大厂的面试心得(干货满满文末有福利)

中厂->阿里->字节,成都->杭州->成都 系列文章目录和关于我 0.前言 笔者在不足两年经验的时候从成都一家金融科技中厂跳槽到杭州阿里淘天集团,又于今年5月份从杭州淘天跳槽到成都字节。自认为自己在面试这方面有一点心得,处于记录和分享的目的便有了此文,此文纯…

leetcode 206. 反转链表

题目描述 206. 反转链表给你单链表的头节点 head ,请你反转链表,并返回反转后的链表。示例 1:输入:head = [1,2,3,4,5] 输出:[5,4,3,2,1]示例 2:输入:head = [1,2] 输出:[2,1]示例 3: 输入:head = [] 输出:[] 提示:链表中节点的数目范围是 [0, 5000],-5000 <= …

AgileConfig-1.9.4 发布,支持 OpenTelemetry

Hello 大家好,最新版的 AgileConfig 1.9.4 发布了。现在它可以通过 OpenTelemetry 对外提供 logs,traces,metrics 三个维度的数据。用户可以自由选择支持 otlp 协议的工具来进行查询与分析。比如 Seq,loki,prometheus, grafana 等等。 本来 AgileConfig 的日志是通过 Nlog…

实验七

TASK1点击查看代码 // 将图书信息写入文本文件data1.txt // 再从文件中读取图书信息,打印输出到屏幕上,并显示行号#include <stdio.h>#define N 80 #define M 100typedef struct {char name[N]; // 书名 char author[N]; // 作者 } Book;// 函数声明 void func1(); …

LLM大模型: DPO原理和源码解析

1、前段时间国外某大学反向抄袭国内某团队的大模型闹得沸沸扬扬,国内被抄袭的大模型是MiniCPM,详细资料:https://github.com/OpenBMB/MiniCPM ; 能被国外同行抄袭,必定有过人之处,粗略看了一下https://github.com/OpenBMB/MiniCPM/blob/main/model/modeling_minicpm.py 模…