2021-07-29

微信小程序云开发-登录功能(账号密码登录)

一、新建页面

新建页面loadByAccount

 二、代码实现

 1、loadByAccount.w

 1 <view>账号</view> 2 <input type="text" placeholder="请输入账号" bindinput="getAccount"></input> 3 <view>密码</view> 4 <input type="text" placeholder="请输入密码" bindinput="getPassword"></input> 5 <view class="btn"> 6 <button type="primary" bindtap="loadByAccount">登录</button> 7 </view> 8 <view class="tosign"> 9 <view bindtap="toSign" >注册</view>10 </view>

2、loadByAccount.wxss

 1 input{ 2  margin: 20rpx; 3  padding-left: 10rpx; 4  height: 80rpx; 5  border: 1rpx solid #c3c3c3; 6 } 7 view{ 8  margin: 20rpx; 9 }10 .btn{11  display: flex;12  margin-top: 50rpx;13 }14 .tosign{15  margin-top: 50rpx;16  text-align: center;17 }

3、loadByAccount.js

 1 //自定义变量,存储用户输入的账号 2 let account = '' 3 //自定义变量,存储用户输入的密码 4 let password = '' 5 Page({ 6  7 //点击跳转到注册页 8  toSign(){ 9  wx.navigateTo({10  url: '/pages/sign/sign',11  })12  },13 14 //获取用户输入的账号、密码15  getAccount(e){16  console.log("用户输入的账号",e.detail.value);17  account = e.detail.value18  },19  getPassword(e){20  console.log("用户输入的密码",e.detail.value);21  password = e.detail.value22  },23 24 //登录功能25  loadByAccount(){26  //校验账号27  if(account.length<4){28   wx.showToast({29   title: '账号至少4位',30   icon:"none"31   })32  return33  }34  //登录功能的实现35  wx.cloud.database().collection("users")36  .where({37   Account:account38  })39  .get({})40  .then(res=>{41  console.log("获取账号成功",res);42  //校验密码长度43  if(password.length<4){44   wx.showToast({45   title: '密码至少4位',46   icon:"none"47   })48   return49   }50  //校验密码是否等于数据库中的密码51  if(password==res.data[0].Password){52   console.log("登录成功",res);53   //显示登录成功提示54   wx.showToast({55   title: '登录成功',56   ......

原文转载:http://www.shaoqun.com/a/892309.html

跨境电商:https://www.ikjzd.com/

乐宝:https://www.ikjzd.com/w/2200

腾邦:https://www.ikjzd.com/w/1382

acca:https://www.ikjzd.com/w/1370


一、新建页面新建页面loadByAccount二、代码实现1、loadByAccount.w1<view>账号</view>2<inputtype="text"placeholder="请输入账号"bindinput="getAccount"></input>3<view>密码&
四川有个地方, 只能进不能出, 原因至今未解, 意大利的更是神奇:http://www.30bags.com/a/235328.html
四川有哪些好吃的面条?:http://www.30bags.com/a/418207.html
四川有这么一座小城,堪称"中国橘乡",日本人都看中了这块宝地:http://www.30bags.com/a/223546.html
四川有座桥,简陋至极却闻名世界,游客宁可哭着走完也不让它修缮_泸定:http://www.30bags.com/a/220262.html
一晚上要了小姑娘三次 被男同事伺候的爽了一夜:http://lady.shaoqun.com/a/248129.html
校花让我玩她的大白兔 手伸进她的乳罩里揉搓着:http://lady.shaoqun.com/a/247767.html
他把舌头伸进两腿之间 舌尖逗弄她颤抖的小核:http://lady.shaoqun.com/m/a/248221.html
三个男人和我玩4P 两个㖭上面一个㖭下面:http://www.30bags.com/m/a/249813.html
深圳宝安科技馆8月展览汇总(持续更新):http://www.30bags.com/a/517601.html
2021时尚深圳展蝶讯馆展览好看吗:http://www.30bags.com/a/517602.html
2021时尚深圳蝶讯馆观展攻略:http://www.30bags.com/a/517603.html
深圳欢乐谷夏浪音乐节有朱星杰吗:http://www.30bags.com/a/517604.html

No comments:

Post a Comment