乐于分享
好东西不私藏

万能的小程序登录注册页面,包含源码和效果图.拷贝可直接运行看效果

万能的小程序登录注册页面,包含源码和效果图.拷贝可直接运行看效果

前言
       在大多数微信小程序项目中,用户身份管理是系统的基础功能。登录和注册模块不仅负责用户身份验证,还为后续的个性化服务、数据权限控制以及用户体验提供支撑。设计一个安全、可复用的登录注册模块,对于小程序开发者来说具有重要意义。 这里给出完整的注册和登录页面的源码,让你可以快速集成到自己的项目中。同时,文末的最后给出六个常见系统的源码,已经开源到GitHub了。可以参考学习。
实现效果截图
登录页面样式

     用户通过账号密码或手机号验证码登录,登录成功后生成 token 并存储在本地,后续请求自动携带 token,实现接口权限管理,登录失败可提示用户具体原因(如账号不存在、密码错误)

<viewclass="login-container">    <viewclass="login-card">        <viewclass="form-group">            <textclass="form-label">账号</text>            <inputclass="form-input"type="text"model:value="{{userAccount}}"placeholder="请输入用户账号"placeholder-class="input-placeholder" />        </view>        <viewclass="form-group">            <textclass="form-label">密码</text>            <inputclass="form-input"type="password"model:value="{{password}}"placeholder="请输入登录密码"placeholder-class="input-placeholder" />        </view>        <viewclass="btn-group">            <buttonclass="primary-btn"bind:tap="login">立即登录</button>            <buttonclass="secondary-btn"bind:tap="zhuce">注册账号</button>        </view>    </view></view>
样式
/* pages/login_main/login_main.wxss */.login-container {    height100vh;    display: flex;    justify-content: center;    align-items: center;    backgroundlinear-gradient(135degrgba(2452472500.80%rgba(1952072260.8100%),        url('https://tse2.mm.bing.net/th/id/OIP.tcjwPdWiG7x8Oz8QKyAh_gHaLG') no-repeat center center;    background-size: cover;}.login-card {    background#fff;    width85vw;    padding40rpx;    border-radius24rpx;    box-shadow0 10rpx 30rpx rgba(0000.1);}.form-group {    margin-bottom48rpx;}.form-label {    display: block;    font-size32rpx;    color#2c3e50;    margin-bottom20rpx;    font-weight500;}.form-input {    width90%;    height96rpx;    background#f8f9fa;    border-radius12rpx;    padding0 24rpx;    font-size28rpx;    border2rpx solid #e9ecef;    transition: all 0.3s ease;}.form-input:focus {    border-color#4dabf7;    background#fff;    box-shadow0 0 8rpx rgba(771712470.2);}.input-placeholder {    color#adb5bd;    font-size28rpx;}.btn-group {    margin-top60rpx;    display: flex;    flex-direction: column;    gap30rpx;}.primary-btn {    background#4dabf7;    color: white;    border-radius50rpx;    height96rpx;    font-size32rpx;    text-align: center;    display: flex;    /* 增加:启用 Flex 布局 */    justify-content: center;    /* 增加:水平居中 */    align-items: center;    /* 增加:垂直居中 */    transition: all 0.3s ease;}.primary-btn:active {    background#339af0;    transformscale(0.98);}.secondary-btn {    background: transparent;    color#4dabf7;    border2rpx solid #4dabf7;    border-radius50rpx;    height96rpx;    font-size32rpx;    text-align: center;    display: flex;    /* 增加:启用 Flex 布局 */    justify-content: center;    /* 增加:水平居中 */    align-items: center;    /* 增加:垂直居中 */}.secondary-btn:active {    backgroundrgba(771712470.1);}
注册页面布局和样式

   用户通过手机号、邮箱或账号密码进行注册,支持基本表单校验(如手机号格式、密码长度、两次密码一致性),注册成功后可自动登录或引导用户登录。

<!-- pages/register/register.wxml --><viewclass="register-container">    <viewclass="register-card">        <viewclass="form-group">            <textclass="form-label">账号</text>            <inputclass="form-input"type="text"model:value="{{userAccount}}"placeholder="4-16位字母/数字"placeholder-class="input-placeholder" />        </view>        <viewclass="form-group">            <textclass="form-label">设置密码</text>            <inputclass="form-input"type="password"model:value="{{password}}"placeholder="至少包含大小写字母"placeholder-class="input-placeholder" />        </view>        <viewclass="form-group">            <textclass="form-label">确认密码</text>            <inputclass="form-input"type="password"model:value="{{passwordSure}}"placeholder="请再次输入密码"placeholder-class="input-placeholder" />        </view>        <viewclass="btn-group">            <buttonclass="secondary-btn"bind:tap="zhuce">注册账号</button>            <buttonclass="primary-btn"bind:tap="login">已有账号?去登录</button>        </view>    </view></view>
样式
/* pages/register/register.wxss */.register-container {    height100vh;    display: flex;    justify-content: center;    align-items: center;    backgroundlinear-gradient(135degrgba(2452472500.80%rgba(1952072260.8100%),        url('https://tse2.mm.bing.net/th/id/OIP.tcjwPdWiG7x8Oz8QKyAh_gHaLG') no-repeat center center;    background-size: cover;}.register-card {    background#fff;    width86vw;    padding40rpx;    border-radius24rpx;    box-shadow0 12rpx 40rpx rgba(281002420.08);}.form-group {    margin-bottom48rpx;    position: relative;}.form-label {    display: block;    font-size30rpx;    color#2c3e50;    margin-bottom20rpx;    font-weight500;    padding-left8rpx;}.form-input {    width90%;    height96rpx;    background#f8faff;    border-radius12rpx;    padding0 28rpx;    font-size28rpx;    border2rpx solid #e1ebff;    transition: all 0.3s ease;}.form-input:focus {    border-color#4d7cfe;    background#fff;    box-shadow0 0 12rpx rgba(771242540.15);}.avatar-group {    text-align: center;}.upload-btn {    width240rpx;    height72rpx;    line-height72rpx;    background#ecf2ff;    color#4d7cfe;    font-size26rpx;    border-radius40rpx;    margin20rpx auto;    transition: all 0.2s;}.btn-hover {    background#dbe5ff !important;}.avatar-preview {    width200rpx;    height200rpx;    border-radius50%;    background#f8faff;    margin20rpx auto;    overflow: hidden;    border4rpx solid #e1ebff;    box-shadow0 8rpx 20rpx rgba(771242540.1);}.avatar-preview image {    width100%;    height100%;    opacity0.6;    transition: all 0.3s;}.avatar-preview .uploaded {    opacity1;    filterdrop-shadow(0 4rpx 12rpx rgba(771242540.2));}/* 注册按钮 */.submit-btn {    width100%;    height96rpx;    backgroundlinear-gradient(45deg#4d7cfe#6a93ff);    color: white;    font-size32rpx;    border-radius50rpx;    margin-top40rpx;    transition: all 0.3s;}.submit-btn:active {    opacity0.9;    transformscale(0.98);}.input-placeholder {    color#b4c6f8;    font-size26rpx;}.btn-group {    margin-top60rpx;    display: flex;    flex-direction: column;    gap30rpx;}.primary-btn {    background#4dabf7;    color: white;    border-radius50rpx;    height96rpx;    font-size32rpx;    text-align: center;    display: flex;    justify-content: center;    align-items: center;    transition: all 0.3s ease;}.primary-btn:active {    background#339af0;    transformscale(0.98);}.secondary-btn {    background: transparent;    color#4dabf7;    border2rpx solid #4dabf7;    border-radius50rpx;    height96rpx;    font-size32rpx;    text-align: center;    display: flex;    justify-content: center;    align-items: center;}.secondary-btn:active {    backgroundrgba(771712470.1);}

分享几个开源的项目(在GitHub上)

🎯 项目一:美妆商城系统

技术栈:SpringBoot + Vue + mybatis + mysql

https://github.com/zhengyuzh/meizhuangshop

🚀 项目二:智能美妆商城系统

技术栈:SpringBoot + Vue + 协同过滤算法 + 敏感词过滤 + mybatis + mysql

https://github.com/zhengyuzh/mzshop

🛍️ 项目三:通用商城系统

技术栈:前后端分离 SpringBoot + Vue + mybatis + mysql 

https://github.com/zhengyuzh/mallsystem

💗 项目四:大学生心理健康管理系统

技术栈:SpringBoot + mybatis + mysql 等

https://github.com/zhengyuzh/Mental-health-management-system

📚 项目六:智能书籍借阅系统

技术栈:SpringBoot + Vue + Redis + Mybatis-plus + 微信小程序

https://github.com/zhengyuzh/Book-borrowing-system

公众号回复如下内容即可获取对应资料

数字 1、表示获取后端开发学习资料

数字 2、表示获取前端开发学习资料

数字 3、表示获取 软考中级设计师资料

数字 4、表示获取后端常用在线免费学习资料

数字 5、计算机毕业设计优秀论文模板

数字 6、前后端分离项目案例源码

数字 7、SSM项目案例源码

数字 8、视频轮播图全部案例源码

数字 9、SpringBoot + Vue 商城系统项目 前后端分离源码

数字10:SpringBoot + Vue 商城系统源码 前后端分离项目【毕业设计系统】

数字11:毕业论文答辩PPT模板案例

数字12:系统部署+论文指导+开题指导+开发指导

数字13:万字答辩问题汇总文档

数字14:前后端项目结构模块详细讲解说明(小白可懂)

数字15:协同过滤算法+敏感词过滤+SpringBoot+Vue 商城源码

数字16:微信小程序考勤打卡 系统源码

数字17:基于SpringBoot 精准扶贫系统源码 系统源码

更多。。。

本站文章均为手工撰写未经允许谢绝转载:夜雨聆风 » 万能的小程序登录注册页面,包含源码和效果图.拷贝可直接运行看效果

评论 抢沙发

4 + 9 =
  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
×
订阅图标按钮