初步分析,程序一共有两个界面即:登录界面和注册界面。

但是注册的时候由于不同的注册方式应该有不同的界面支持,故在本程序中我们要写两个注册界面和一个登录界面,两个注册界面分别位手机注册界面和企业用户注册界面。 在微信小程序中,每一个界面的文件夹下有4个文件,如图:


login为登录界面各文件存储的文件夹,其下有四个文件,从其后缀名可以看出其与web开发中的各种类型文件的相似之处。

  • wxml文件主要表示界面上有那些东西;
  • wxss文件则对wxml中的文件的样式,颜色等进行修饰;
  • js文件则主要是负责一些业务逻辑的处理,(可以粗浅的理解为存储定义一些数据和函数);
  • json文件则是记录一些页面的设置。 了解了这些后,我们便可以开始着手代码的编写了。

首先,新建一个项目。项目整体结构如图:

在app.json中添加我们要完成的页面,删除我们不需要的页面。修改后的app.json如下:

{  "pages":[    "pages/login/login",    "pages/mobile/mobile",    "pages/company/company"  ],  "window":{    "backgroundTextStyle":"light",    "navigationBarBackgroundColor": "#fff",    "navigationBarTitleText": "Weixin",    "navigationBarTextStyle":"black"  },  "style": "v2",  "sitemapLocation": "sitemap.json"}

如上,pages中的内容即为最终成品中所含的页面。本小程序含有login,mobile和company三个页面,用来实现登录,手机注册和企业用户注册三个功能。编辑完成app.json文件后按ctrl+s保存后,会自动生成各个页面的文件夹及文件夹下各个文件如图:

接下来我们只需要逐个完成其中的功能和页面就好了。

  1. 登录界面 login.wxml
<view class="content">  <view class="account">    <view class="title">account</view>    <view class="number"><input bindinput="accountInput" placeholder="username/email/phone" placeholder-style="color:#999999;"/></view>  </view>  <view class="hr"></view>  <view class="account">    <view class="title">passwd</view>    <view class="number"><input bindiblur="pwdBlur" placeholder="please input password" password placeholder-style="color:#999999;"/></view>  </view>  <view class="hr"></view>  <button class="btn" disabled="{{disabled}}" type="{{btnstate}}" bindtap="login">login</button>  <view class="operate">      <view><navigator url="../mobile/mobile">手机快速注册</navigator></view>      <view><navigator url="../company/company">企业用户注册</navigator></view>      <view>找回密码</view>  </view></view>

login.wxss:

/* pages/login/login.wxss */.content{  margin-top: 40px;}.account{  display: flex;  flex-direction: row;  padding-left: 20px;  padding-top: 20px;  padding-bottom: 10px;  width:90%;}.title{  margin-right: 30px;  font-weight: bold;}.hr{  border:1px solid #cccccc;  opacity: 0.2;  width:90%;  margin:0 auto;}.btn{  width: 90%;  margin-top: 40px;  color:grey;}.operate{  display: flex;  flex-direction: row;}.operate view{  margin:0 auto;  margin-top: 40px;  font-size : 14px;  color:#333333;}

login.js

// pages/login/login.jsPage({

  /**   * 页面的初始数据   */  data: {    disabled:true,    btnstate:"default",    account:"",    password:""  },

  accountInput:function(e){    var content = e.detail.value;    if(content!=''){      this.setData({disabled:false,btnstate:"primary",account:content});    }else{      this.setData({disabled:true,btnstate:"default"});    }  },  pwdBlur:function(e){    var password= e.detail.value;    if(password!=''){      this.setData({password:passwd});    }  }})

最总,表现结果如图:

2.手机注册界面

mobile.wxml:

<view class="content">   <view class="hr"></view>   <view class="numbg">     <view>+86</view>     <view><input placeholder="please input phone number" maxlength="11" bindblur="mobileblur"/></view>   </view>   <view class="xieyi">     <icon type="success" color="red" size="18"></icon>     <text class="agree">同意</text>     <text class="option">xx用户注册协议</text>   </view></view>

mobile.wxss:

.content{  width: 100%;  height: 600px;  background-color: #f2f2f2;}.hr{  padding-top: 20px;}.numbg{  border:1px silid grey;  width:90%;  margin:0 auto;  background: white;  border-radius: 5px;  display: flex;  flex-direction: row;  height: 50px;}.numbg view{  margin-left: 20px;  margin-top: 14px;}.xieyi{  margin-top: 15px;  margin-left: 15px;}.agree{  font-size:13px;  margin-left: 5px;  color: #666666;}.option{  font-size: 13px;  color: #000000;  font-weight: bold;}.btn{  width: 90%;  margin-top: 30px;}

mobile.js

// pages/mobile/mobile.jsPage({

  /**   * 页面的初始数据   */  data: {    disabled:true,    btnstate:"default",    mobile:""  },  mobileblur:function(e){    var content = e.detail.value;    if(content!=''){      this.setData({        disabled:false,        btnstate:"primary",        mobile:content      });    }else{      this.setData({        disabled:true,        btnstate:"default",        mobile:""      });    }  }})

最终,表现结果如图:

3.企业用户注册界面

company.wxml

<form bindsubmit="formSubmit" bindreset="formReset">  <view class="content">    <view class="hr"></view>    <view class="item">      <input type="text" name="loginName" placeholder="请设置4-20位用户名" placeholder-class="holder" bindblur="accountblur"/>    </view>    <view class="item flex">      <input type="text" password name="password" placeholder="请设置6-20位登录密码" placeholder-class="holder"/>      <switch type="switch" name="switch"/>    </view>    <view class="item">      <input type = "text" name="company" placeholder="请填写工商局注册名称" placeholder-class="holder"/>    </view>    <view class="item">      <input type="text" name="userName" placeholder="联系人姓名" placeholder-class="holder"/>    </view>    <view class="mobileInfo">      <view class="mobile">        <input type="text" name="mobile" placeholder="请输入手机号" placeholder-class="holder"/>      </view>      <view class="code">发送验证码</view>    </view>    <view class="item">      <input type="text" name="code" placeholder="短信验证码" placeholder-class="holder"/>    </view>    <button class="btn" disabled="{{disabled}}" type="{{btnstate}}" form-type="submit">注册</button>    <view class="xieyi">      <text class="agree">注册则视为同意</text><text class="opinion">《xx用户注册协议》</text>    </view>  </view></form>

company.wxss

.content{  width: 100%;  height: 700px;  background-color: #f2f2f2;}.hr{  padding-top: 40px;}.item{  margin:0 auto;  border:1px solid #cccccc;  height:40px;  width:90%;  border-radius:3px;  background-color: #ffffff;  margin-bottom: 15px;}.item input{  height:40px;  line-height: 40px;  margin-left: 10px;}.holder{  font-size: 14px;  color:#999999;}.flex{  display:flex;  flex-direction: row;}.flex input{  width:300px;}.item switch{  margin-top: 5px;  margin-right: 5px;}.mobileInfo{  display:flex;  flex-direction: row;}.mobile{  margin:0 auto;  border:1px solid #cccccc;  height:40px;  width:50%;  border-radius: 3px;  background-color: #ffffff;  margin-bottom: 15px;  display: flex;  flex-direction: row;  margin-left: 5%;}.mobile input{  margin-top: 8px;  margin-left: 10px;}.code{  border: 1px solid #cccccc;  height: 40px;  width:35%;  background-color: #EFEEEC;  border-radius:3px;  text-align: center;  margin-left: 10px;  line-height: 40px;  color: #999999;  font-size: 15px;  margin-bottom: 15px;  margin-right: 5%;}.btn{  width: 90%;  color: #999999;  margin-top: 40px;}.xieyi{  margin-top: 15px;  margin-left:15px;  font-size: 13px;}.agree{  margin-left: 5px;  columns: #666666;}.opinion{  color:red;  font-weight: bold;  text-decoration: underline;}

company.js

// pages/company/company.jsPage({

  /**   * 页面的初始数据   */  data: {    disabled:true,    btnstate:"default"  },  accountblur:function(e){    var content = e.detail.value;    if(content!=""){      this.setData({disabled:false,btnstate:"primary"});    }else{      this.setData({disabled:true,btnstate:"default"});    }  },  formSubmit:function(e){    console.log(e);    var user = new Object();    user.account = e.detail.value.loginName;    user.password = e.detail.value.password;    user.company = e.detail.value.company;    user.userName = e.detail.value.userName;    usesr.code = e.detail.value.code;    user.mobile = e.detail.value.mobile;    user.switch = e.detail.value.switch;    wx.setStorageSync('user', user);    wx.showToast({      title: '注册成功',      inco:"success",      duration:1000,      success:function(){        wx.navigateTo({          url: '../login/login'        })      }    })  }})

最终,表现结果如图:


微信小程序之登录注册界面的实现相关推荐

  1. 微信小程序之———登录注册!

    好了,我觉得有必要对前一阶段的小程序开发过程中的一些经验写出来,总结一下,今天呢,就来总结一下小程序登录注册相关的流程和开发过程中需要注意的问题,好了,废话不多说,开始咯! 一:登录 思路: 当用户在 ...

  2. 微信小程序的登录界面实现

    微信小程序的登录界面实现 <view class="container"><view class="wrapper"><view ...

  3. 微信小程序授权登录界面

    微信小程序授权登录界面 原先用的 wx.getUserInfo(Object object) ,现已改革 现用的 wx.getUserProfile(Object object),获取用户信息.每次请 ...

  4. 微信小程序开发登录界面mysql_微信小程序 欢迎界面开发的实例详解

    微信小程序 欢迎界面 市面上大多数的app都会有一个欢迎界面,下面将演示如何通过微信小程序实现一个欢迎界面. 下面将会按照以下的顺序介绍: 布局的实现 逻辑的实现 样式的实现 1.布局的实现 整个布局 ...

  5. 零基础微信小程序开发心得----注册微信小程序

    因为项目需要用到小程序,自己想写个从零到有的微信小程序专题,记录学习心得. 目录 1.微信小程序简介 2.注册小程序 3.安装开发工具 4.小程序初始化目录介绍 1.微信小程序简介 微信小程序这个词可 ...

  6. webform窗体怎么实现session唯一标识_微信小程序用户登录和登录态维护的实现_javascript技巧...

    这篇文章主要介绍了微信小程序用户登录和登录态维护的实现,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧 让用户登录,标识用户和获取 ...

  7. 微信小程序api登录接口wx.login(OBJECT)

    有些小程序可以直接使用而无需登录,例如,古诗.美图欣赏.美文等,这些微信小程序往往没有登录要求,只需要打开使用就可以了.但是,很多的小程序则往往需要登录,例如,在微信小程序里面您要发表评论.您要购买产 ...

  8. 新版微信小程序授权登录流程及问题汇总(getUserProfile)

    问题来源:前不久去面试的时候有面试官问我你有自己的博客啥的吗?只能很尴尬的说没有.其实一直想有一个属于自己的博客啥的去记录自己在开发过程中遇到的问题,正好现在微信小程序比较流行,就花了两天自己搞了一个 ...

  9. SpringCloud 微信小程序授权登录 获取openId SessionKey【SpringCloud系列13】

    SpringCloud 大型系列课程正在制作中,欢迎大家关注与提意见. 自我提升方法推荐:神奇的早起 早上 5:00 -5:20 起床刷牙 5:30-6:00 晨练(跑步.跳绳.骑自行车.打球等等) ...

  10. 微信小程序授权登录全过程解析(附代码)

    今天小编对于微信小程序的登录功能比较感兴趣,也是由于工作需要,就大概研究了一下. 这里先附一张小程序的登陆整体流程图. 整体流程: 微信端点击登录按钮后会去调用 wx.login接口,如果接口调用成功 ...

最新文章

  1. 从前端界面开发谈微信小程序体验
  2. 数据库死锁的解决办法
  3. java byte num =1 3_java中把byte[]{1,2,3}通过怎样的转换,可以让其最终在TextView中显示为123...
  4. 2017.9.1 最小生成树 失败总结
  5. Golang实践录:命令行cobra库实例
  6. 玩转 SpringBoot 2.x 之 RedisTemplate 操作
  7. 如何选型音视频即时通讯产品
  8. 关于流程图的场景提炼,这一次终于说清楚业务流程图、功能流程图、页面流程图了
  9. linux怎么进入etc目录,Linux 系统的/etc目录
  10. 王者无限火力服务器,王者无限火力2
  11. 思维导图 基础篇(11)应用-文章分析-框架法
  12. 北大教授:学术会议,已沦为表演
  13. 文件管理器和FTP客户端:ForkLift for Mac
  14. yocto bsp-开发人员指南
  15. html网页公式编辑软件,如何在网页中插入MathType公式
  16. 码元速率、数据速率、信道带宽、信道容量、载波的概念
  17. 树莓派python蓝牙_用树莓派玩转蓝牙
  18. 【网络安全常用术语解读】CWE详解
  19. 如何利用Matlab制作色卡,手把手教你做一张属于自己的色卡,彩铅必备!
  20. 大华sdk对接php,大华网络摄像机SDK对接

热门文章

  1. Weighted Quick Union
  2. 一周技术学习笔记(第58期)-如何突破第四章障碍
  3. Apache POI 操作Excel表格使用详解 最全
  4. 如何用ABBYY FineReader提取图片中的文字
  5. 但行好事 莫问前程(九月)
  6. uniApp_canvas电子签字
  7. Ubuntu下安装LXDE+XRDP实现远程桌面访问(最轻量级桌面)
  8. 计算机与电气工程sci期刊,电气工程专业什么SCI期刊比较好
  9. Spring框架 编程式事务 事务的传播行为(一)
  10. Intel(R) 6 Series/C200 Series Chipset Family USB Enhanced Host Controller - 1C26出现感叹号,USB无法使用