微信小程序之登录页实例 —— 微信小程序实战系列(5)

提供一个登录页的案例,供同学们使用



项目效果图:



目录结构:



图片资源:

name.png


key.png


loginLog.jpg




login.wxml

<view class="container">
  <view class="login-icon">
    <image class="login-img" src="../images/loginLog.jpg"></image>
  </view>
  <view class="login-from">

    <!--账号-->
    <view class="inputView">
      <image class="nameImage" src="../images/name.png"></image>
      <label class="loginLab">账号</label>
      <input class="inputText" placeholder="请输入账号" bindinput="phoneInput" />
    </view>
    <view class="line"></view>

    <!--密码-->
    <view class="inputView">
      <image class="keyImage" src="../images/key.png"></image>
      <label class="loginLab">密码</label>
      <input class="inputText" password="true" placeholder="请输入密码" bindinput="passwordInput" />
    </view>

    <!--按钮-->
    <view class="loginBtnView">
      <button class="loginBtn" type="primary" size="{{primarySize}}" loading="{{loading}}" plain="{{plain}}" disabled="{{disabled}}" bindtap="login">登录</button>
    </view>
  </view>
</view>


login.wxss

page{
  height: 100%;
}

.container {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 0;
  box-sizing: border-box;
  background-color: #f2f2f2
} 

/*登录图片*/
.login-icon{
  flex: none;
}
.login-img{
  width: 750rpx;
}

/*表单内容*/
.login-from {
  margin-top: 20px;
  flex: auto;
  height:100%;
}

.inputView {
  background-color: #fff;
  line-height: 44px;
}
/*输入框*/
.nameImage, .keyImage {
  margin-left: 22px;
  width: 14px;
  height: 14px
}

.loginLab {
  margin: 15px 15px 15px 10px;
  color: #545454;
  font-size: 14px
}
.inputText {
  flex: block;
  float: right;
  text-align: right;
  margin-right: 22px;
  margin-top: 11px;
  color: #cccccc;
  font-size: 14px
}

.line {
  width: 100%;
  height: 1px;
  background-color: #cccccc;
  margin-top: 1px;
}
/*按钮*/
.loginBtnView {
  width: 100%;
  height: auto;
  background-color: #f2f2f2;
  margin-top: 0px;
  margin-bottom: 0px;
  padding-bottom: 0px;
}

.loginBtn {
  width: 80%;
  margin-top: 35px;
}


login.js

Page({
  data: {
    phone: '',
    password:''
  },

// 获取输入账号
  phoneInput :function (e) {
    this.setData({
      phone:e.detail.value
    })
  },

// 获取输入密码
  passwordInput :function (e) {
    this.setData({
      password:e.detail.value
    })
  },

// 登录
  login: function () {
    if(this.data.phone.length == 0 || this.data.password.length == 0){
      wx.showToast({  
        title: '用户名和密码不能为空',  
        icon: 'loading',  
        duration: 2000  
      })  
}else {
  // 这里修改成跳转的页面
      wx.showToast({  
        title: '登录成功',  
        icon: 'success',  
        duration: 2000  
      })  
    }  
  }
})


运行结果



微信小程序教程系列

相关连接:http://blog.csdn.net/michael_ouyang/article/details/54700871


基础篇

------------------------------------------------------------

微信开发者工具的快捷键

微信小程序的文件结构 —— 微信小程序教程系列(1)

微信小程序的生命周期实例演示 —— 微信小程序教程系列(2)

微信小程序的动态修改视图层的数据 —— 微信小程序教程系列(3)

微信小程序的新建页面 —— 微信小程序教程系列(4)

微信小程序的如何使用全局属性 —— 微信小程序教程系列(5)

微信小程序的页面跳转 —— 微信小程序教程系列(6)

微信小程序标题栏和导航栏的设置 —— 微信小程序教程系列(7)

微信小程序的作用域和模块化 —— 微信小程序教程系列(8)

微信小程序视图层的数据绑定 —— 微信小程序教程系列(9)

微信小程序视图层的条件渲染 —— 微信小程序教程系列(10)

微信小程序视图层的列表渲染 —— 微信小程序教程系列(11)

微信小程序视图层的模板 —— 微信小程序教程系列(12)

微信小程序之wxss —— 微信小程序教程系列(13)

微信小程序的网络请求 —— 微信小程序教程系列(14)

微信小程序的百度地图获取地理位置 —— 微信小程序教程系列(15)

微信小程序使用百度api获取天气信息 —— 微信小程序教程系列(16)

微信小程序获取系统日期和时间 —— 微信小程序教程系列(17)

微信小程序之上拉加载和下拉刷新 —— 微信小程序教程系列(18)

微信小程序之组件 —— 微信小程序教程系列(19)

微信小程序之微信登陆 —— 微信小程序教程系列(20)


实战篇

------------------------------------------------------------

微信小程序之顶部导航栏实例 —— 微信小程序实战系列(1)

微信小程序之上拉加载(分页加载)实例 —— 微信小程序实战系列(2)

微信小程序之轮播图实例 —— 微信小程序实战系列(3)

微信小程序之仿android fragment之可滑动的底部导航栏实例 —— 微信小程序实战系列(4)

微信小程序之登录页实例 —— 微信小程序实战系列(5)

微信小程序之自定义toast实例 —— 微信小程序实战系列(6)

微信小程序之自定义抽屉菜单(从下拉出)实例 —— 微信小程序实战系列(7)

微信小程序之自定义模态弹窗(带动画)实例 —— 微信小程序实战系列(8)


电商篇

------------------------------------------------------------

微信小程序之侧栏分类 —— 微信小程序实战商城系列(1)

微信小程序之仿淘宝分类入口 —— 微信小程序实战商城系列(2)

微信小程序之购物数量加减 —— 微信小程序实战商城系列(3)

微信小程序之商品属性分类 —— 微信小程序实战商城系列(4)

微信小程序之购物车 —— 微信小程序实战商城系列(5)


未完待续。。。


更多小程序的教程:http://blog.csdn.net/column/details/14653.html

谢谢观看,不足之处,敬请指导


附:项目下载地址 http://download.csdn.net/detail/michael_ouyang/9773804

  • 18
    点赞
  • 164
    收藏
    觉得还不错? 一键收藏
  • 10
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 10
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值