首页 > 编程语言 >微信小程序实现简单登录界面和登录功能

微信小程序实现简单登录界面和登录功能

时间:2023-04-18 14:31:56浏览次数:31  
标签:flex 登录 index 程序实现 微信 margin display

微信小程序实现简单登录界面和登录功能

问题背景

客户端开发和学习过程中,登录功能是一个很常见的场景。本文将介绍,微信小程序开发过程中是如何实现登录界面和登录功能的。

问题分析

话不多说,直接上代码。 (1)index.js文件,代码如下:

Page({
  /**
   * 页面的初始数据
   */
  data:{
    code:"0",
    location:[],
    imageUrl: "https://profile-avatar.csdnimg.cn/default.jpg!0",
    userName:"",
    userPass:"",
  },

  /* 登录校验操作 */
  login: function () {
    if (this.data.userName === "baorant" && this.data.userPass === "123123") {
      wx.navigateTo({
        url: '/pages/index2/index',
        success: function(res) {
          console.log('router1 success');
        },
        fail: function(res) {
          console.log('router1 fail');
          console.log(res)
        }
      })
    } else {
      wx.showToast({
        title: '账号密码错误',
        icon: 'none'
      })
    }
  },
})

(2)index.wxml文件,代码如下:

<view class="container">
  <view class="title">登录页面测试</view>
  <view class="inputRow">
    <View>账号</View>
    <input type="text" model:value="{{userName}}" placeholder="请输入账号" class="phone_number"></input>
  </view>
  <!-- <view class="divLine"></view> -->
  <view class="inputRow1">
    <View>密码</View>
    <input type="text" model:value="{{userPass}}" placeholder="请输入密码" class="phone_number"></input>
  </view>
  <!-- <view class="divLine"></view> -->
  <button class="buttonStyle" type="primary" bindtap="login">登录</button>
</view>

(3)index.wxss文件,代码如下:

/* 设置swiper组件的宽高 */
.swiper{
  width: 100%;
  height: 600rpx;
}
/* 设置swiper组件里面图片的宽高 */
.image{
  width: 100%;
  height: 600rpx;
}

.container{
  height: 100%;
  display: flex;
  flex-direction: column;
  padding-top: 100rpx;
}

.title{
  display:flex;
  font-size: larger;
}

.inputRow{
  margin-top: 150rpx;
  display: flex;
  flex-direction: row;
  padding-bottom: 20rpx;
  border-bottom: .5px solid rgba(0, 0, 0, 0.1);
}

/*分割线样式*/
.divLine{
  background: #E0E3DA;
  width: 80%;
  height: 5rpx;
  margin: 10rpx 150rpx;
}

.inputRow1{
  margin-top: 50rpx;
  display: flex;
  flex-direction: row;
  padding-bottom: 20rpx;
  border-bottom: .5px solid rgba(0, 0, 0, 0.1);
}

.phone_number{
  margin-left:40rpx;
}

.content1{
  /* text-align: center; */
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  margin: 10rpx;
}

.buttonStyle{
  margin-top: 50rpx;
}

.place{
  font-style: italic;
}

运行结果如下: 1681798538631.gif

问题总结

本文介绍了微信小程序开发过程中模拟实现登录界面和登录功能,有兴趣的同学可以进一步深入研究。

标签:flex,登录,index,程序实现,微信,margin,display
From: https://blog.51cto.com/baorant24/6203280

相关文章

  • 如何修复树莓派在更换了一个 SD 系统卡后,无法使用 SSH 登录问题 All In One
    如何修复树莓派在更换了一个SD系统卡后,无法使用SSH登录问题AllInOneknownhostsRaspberryPi无法SSH登录,报错❌/Users/xgqfrms-mm/.ssh/[email protected]@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@WARNING:REMO......
  • 微信小程序开始实现骨架屏
    微信小程序开始实现骨架屏问题背景客户端开发和学习过程中,骨架屏是一种很常见的场景。应用打开时加载资源和复杂逻辑导致耗时较长,可能出现白屏等场景,此时增加骨架屏可以极大改善用户的体验。本文将介绍微信小程序中是如何实现骨架屏的。问题分析(1)微信开发者工具,可以很方便的给......
  • vue3微信公众号商城项目实战系列(6)用户登录
    1.一个商城要实现购物的功能,需要能识别用户的身份,这样才能完成加购物车,下单,付款等操作。但微信公众号商城和PC端商城有些不一样,区别在于微信公众号商城使用微信支付的时候需要一个openid的参数(以后再具体讲)这个参数必须访问微信公众号提供的接口才能获取到,基于这个原因,用户登录......
  • oracle登录
    oracle登录允许错误次数设置一般数据库默认是10次尝试失败后锁住用户1、查看FAILED_LOGIN_ATTEMPTS的值select*fromdba_profiles2、修改为30次alterprofiledefaultlimitFAILED_LOGIN_ATTEMPTS30;3、修改为无限次(为安全起见,不建议使用)alterprofi......
  • vue登录路由权限管理
    前言在开发Web应用程序时,常常需要进行登录验证和权限管理。Vue是一款流行的JavaScript框架,提供了一套灵活的路由管理工具,可以方便地实现登录路由权限管理。本篇博客将介绍如何使用Vue来实现这些功能。登录验证首先,我们需要在Vue应用程序中对用户进行登录验证。在Vue中,我们可以通......
  • 探究公众号接口漏洞:从后台登录口到旁站getshell
    探究公众号接口漏洞:从后台登录口到旁站getshell1、入口发现与利用公众号接口安全漏洞某120公众号提供了一处考核平台,通过浏览器处打开该网站。打开可以看到一处密码登录口,试了一下常用的手机号和密码,没有登录成功。这个时候扫个目录吧。扫到了一处管理员页面:/index.php?c=h......
  • selenium登录cnblogs、抽屉半自动点赞、xpath的使用、打码平台使用、scrapy介绍
    昨日回顾#1beautifulsoup4使用-xml解析库,用它来解析爬回来的html内容,从中找出我们需要的内容#2遍历文档树-.的使用soup.html.body.p.a-获取属性对象.attrs.get('href')-获取文本对象.textstringstrings-子节点,父节点,兄......
  • 直播小程序源码,小程序生成二维码 (兼容H5、微信小程序)
    直播小程序源码,小程序生成二维码(兼容H5、微信小程序)1、<canvastype="2d"style="width:127px;height:127px;position:fixed;top:-1000px;"id="myQrcode"></canvas>注意:不能再v-if内,否则会导致找不到该节点 2、importdrawQrcodefrom'@/common/qrcodeJs......
  • mysql数据库的登录脚本
    ######################## ku脚本:可以使用以下ku脚本,它可以根据提供的参数登录到MySQL数据库:#!/bin/bash#Checkforcorrectnumberofargumentsif[$#-lt1];thenecho"Usage:$0<ip>[<port>][<mysqloptions>]"exit1fi#SettheIPaddressand......
  • telnet(远程登录协议)
    1.telnet配置的三种方式none:表示下次使用该用户线登录时不需要进行用户名和密码认证,任何人都可以登录设备。password:表示下次使用该用户线登录时,需要输入密码。scheme:表示下次使用该用户线登录设备时需要进行用户名和密码认证。2.用户角色network-admin:具有最高权限,可操作系统所......