uniapp学习-登录/注册页面搭建

1.创建路由

2.页面搭建

点击登录/注册切换页面

效果:

代码:

<style lang="scss">
  .container {
    font-family: PingFangSC, PingFang SC;
  }

  .top {
    position: relative;
    left: 0;
    top: 0;

    .title {
      display: inline-block;
      width: 440rpx;
      padding: 3rpx;
      color: #ffffff;
      font-size: 44rpx;
      line-height: 62rpx;
      position: absolute;
      left: 50%;
      top: 50%;
      transform: translate(-50%, -50%);
    }
  }

  .box {
    width: 100%;
    display: flex;
    justify-content: center;

    .main {
      position: relative;
      width: 670rpx;
      height: 590rpx;
      background-color: #ffffff;
      box-shadow: 0px 0px 9px 0px rgba(10, 53, 74, 0.19);
      border-radius: 40rpx;
      margin-top: -150rpx;
    }
  }

  .box2 {
    width: 100%;
    padding: 39rpx;
    display: flex;
    align-items: center;

    view {
      margin-right: 50rpx;
      font-size: 28rpx;
      color: #999999;
      line-height: 40rpx;
      font-weight: 600;
    }

    .active {
      font-size: 46rpx;
      font-weight: 600;
      color: #333333;
      line-height: 65rpx;
    }

    .line {
      width: 100%;
      height: 6rpx;
      background: linear-gradient(122deg, #2AB1E7 0%, #51B1FF 100%);
      border-radius: 3rpx;
      position: relative;
      left: 0;
      top: 0;

      .y {
        width: 30rpx;
        height: 30rpx;
        background: rgba(0, 145, 255, 0.2);
        border-radius: 15rpx;
        position: absolute;
        right: -15rpx;
        top: -15rpx;
        margin-right: 0;
      }
    }
  }

  .box3 {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    .items {
      width: 550rpx;
      height: 92rpx;
      background: #F8F8F8;
      border-radius: 10rpx;
      display: flex;
      align-items: center;
      padd
### 如何在 UniApp 中实现登录功能 #### 微信授权登录 为了实现在 UniApp 应用程序中集成微信授权登录,需按照 OAuth 2.0 协议中的授权码模式进行设置。这涉及到几个关键步骤: - 配置 `manifest.json` 文件内的 APP 模块来指定应用的 AppID[^2]。 ```json { "mp-weixin": { "appid": "your_app_id" } } ``` - 在项目的源代码视图下定义 appsecret 值以便后续处理获取到的临时票据 code 并向微信服务器请求 access_token 和 openid。 通过上述配置可以完成基础准备工作,在实际开发过程中还需要编写前端页面用于触发用户同意授权流程以及后端接口用来交换 token 等操作。 #### 实现一键登录 对于希望提供更便捷用户体验的应用来说,还可以考虑加入一键登录特性。此过程首先要求开发者前往 DCloud 开发者中心注册账号并提交审核以获得相应权限;之后依照官方文档指引逐步完善技术方案直至成功部署上线[^3]。 一旦完成了服务端的相关设定,则可以在客户端利用 SDK 提供的方法快速构建起完整的认证机制,从而让用户能够享受到更加流畅自然的身份验证体验。 ```javascript // 示例:调用微信登录API uni.login({ provider: 'weixin', success(res) { console.log('Login succeeded:', res); // 处理返回的数据... }, fail(err) { console.error('Failed to login', err); } }); ``` 以上就是关于如何基于 UniApp 构建不同类型的登录系统的概述与实践指南。具体实施细节可能会依据项目需求有所调整,请参照最新版本的框架手册及插件说明进一步探索学习
评论 2
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值