小程序简单的登录界面

news/2024/10/21 7:50:57/

造轮子系列复制粘贴,不多说

<view class=""><view class="logo h400 flex jc-ai-center"><image src="../../assets/images/yh.png"></image></view><view class="ipt-wrap"><view class="flex jc-center"><view class="p-lr20  _w100 {{ isIptactive == 1 ? 'iptactive' : ' ' }}" ><view class="ipt-item flex h70 _w100 jc-sb ai-center"><text class="iconfont font22 icon-geren"></text><input type="text" data-ipt="1" placeholder="请输入手机号码" class="ipt flex1 {{isIptborder == 1 ? 'iptnoneborder' : 'iptborder'}}" maxlength="11" bindfocus="selectFoucs" bindinput="IptPhoneValue" bindblur="selectBlur"></input></view></view></view><view class="mt50 flex jc-center"><view class="p-lr20  _w100 {{ isIptactive == 3 ? 'iptactive' : ' ' }}" ><view class="ipt-item flex h70 _w100 jc-sb ai-center"><text class="iconfont font20 icon-mima"></text><input type="password" data-ipt="3" placeholder="请输入密码" class="ipt flex1 {{isIptborder == 3 ? 'iptnoneborder' : 'iptborder'}}" bindfocus="selectFoucs" maxlength="16" bindinput="IptPassValue" bindblur="selectBlur"></input></view></view></view></view><view class="r-wrap"><view class="loginbtn font16 _w100 mt20 color-fff" bindtap="loginGO">登录</view><view class="mt10 flex jc-center"><text class="color-767676">没有账号?</text><text class="color-279efd" data-url="../register/register" bindtap="goRedirect"> 快速注册 </text></view></view><view class="agreement flex ai-center f-column"><view class="mt50 color-767676">说明:注册、登录代表您阅读并已同意</view><view class="mt10 color-279efd" data-url="../agreement/agreement" bindtap="goNavigate">天图极客网用户协议</view>          </view>
</view>

如果不知道icon.css的可以看我的“小程序造轮子”小图标篇 

@import "../../assets/iconfont/icon.wxss";.logo>image{width: 250rpx;height: 208rpx;
}
.iptactive{box-shadow: 0 0rpx 10rpx #ccc;border-radius: 8rpx;
}
.iptnoneborder{border-bottom:1px solid transparent;
}
.iptborder{border-bottom:1px solid #e7f2ff;
}
.ipt-item{position: relative;
}
.ipt{margin-left: 20rpx;height: 60rpx;padding-top: 5rpx;padding-bottom: 5rpx;padding-left: 10rpx;
}
.loginbtn{text-align: center;height: 80rpx;line-height: 80rpx;margin: 80rpx auto 20rpx;border-radius: 10rpx;background: linear-gradient(to right, #66ded0, #229dfe);
}
.ipt-wrap, .r-wrap, .agreement{padding: 0 100rpx;
}
const common = require('../../utils/common');
const api = require('../../utils/api');
const app = getApp();Page({data: {isIptactive: 0,isIptborder: 0,phoneNum:0,userPass:0,// code:''},selectFoucs: function (e) {let ipt = e.target.dataset.ipt;this.setData({ isIptactive: ipt, isIptborder: ipt });},selectBlur: function () {this.setData({ isIptactive: 0, isIptborder: 0 });},IptPhoneValue: function (e) {this.setData({ phoneNum: e.detail.value });},IptPassValue: function (e) {this.setData({ userPass: e.detail.value });},goNavigate: function (e) {common.NAVIGATE(e.target.dataset.url);},goRedirect: function (e){common.REDIRECT(e.target.dataset.url);},  onLoad(){},loginGO: function () {var that = thisvar phoneNum = that.data.phoneNumvar userPass = that.data.userPassvar url = api.SINGLOGIN.singLoginconsole.log("userLogin:" + url)if (!common.ISPHONE(phoneNum)) {common.SHOWTIPS('请输入11位有效手机号码', 'none'); return;} else if (!common.ISPASS(userPass)) {common.SHOWTIPS('密码必须大于6位且小于16位,由数字和字母组合构成', 'none');      return;} else {common.LOADTIPS('正在登录', function () {wx.login({success(res) {that.setData({code: res.code})wx.request({url: url,method: 'post',data: {code:that.data.code,loginName: that.data.phoneNum,password: that.data.userPass,deviceType: 0,userType: 0,},success(res) {console.log(res.data)wx.hideLoading();if (res.data.head.statusCode == "USR_003") {common.MODALTIPS('该手机号码未注册', '是否前往注册', function (res) {if (res.confirm) {common.REDIRECT('../register/register');} else if (res.cancel) {return;}});} else if (res.data.head.status == 1) {common.SHOWTIPS('登录成功', 'success');app.globalData.loginName = res.data.data.loginName;app.globalData.imageUrl = res.data.data.imageUrl;app.globalData.token = res.data.data.token;app.globalData.inviteCode = res.data.data.inviteCode;app.globalData.phone = res.data.data.phone;app.globalData.userType = res.data.data.userType;app.globalData.isLogin = 1;app.globalData.loginWay = 'app';common.SETSTORAGE('userID', res.data.data.token);setTimeout(function () {common.SWITCHTAB('../personal/personal')}, 1500);} else if (res.data.head.statusCode == "USR_005") {common.SHOWTIPS(res.data.head.message, 'none');} else {common.SHOWTIPS('未知错误,请重试', 'none');}},})}})})}},onShareAppMessage: function () {common.share()}
})

 


http://www.ppmy.cn/news/342657.html

相关文章

vscode使用小技巧

vscode全网最详细使用教程&#xff08;让你编码快上10倍&#xff09; 一、快速编写HTML代码 初始化 HTML文档需要包含一些固定的标签&#xff0c;比如、、等&#xff0c;现在你只需要1秒钟就可以输入这些标签。比如输入“!”或“html:5”&#xff0c;然后按Tab键&#xff1a…

wordpress常用调用标签

调用头部&#xff1a;<?php get_header(); ?> 调用底部&#xff1a;<?php get_footer(); ?> 调用自定义模板文件&#xff1a;<?php get_template_part(list-head); ?> 路径&#xff1a;<?php bloginfo(template_url); ?> 缩略图&#xff1a;&l…

【html/css】前端入门案例:画盒子

一、环境准备 【vscode】前端环境配置 二、画盒子 输入英文的感叹号&#xff01;并回车&#xff0c;然后不断按Tab直到文本编辑光标在body标签内。输入.red.green.red并回车。html代码部分完毕。在head标签最后写入style标签。写入css样式代码 .red {w100h100bc:red; } .gr…

页面滚动table头部悬浮

页面滚动头部悬浮&#xff0c;一般都会首相想到监听滚动条离顶部高度然后给需要悬浮的部分position设置成fixed&#xff0c;在一般布局里面是可以的&#xff0c;不过在table布局里面&#xff0c;如果要fixed悬浮thead里面的th会发现宽度样式都乱了。只能想其他办法了&#xff0…

小程序云开发教程五: 图片上传及发表文字的实现

微信给了我们存储空间以及图片上传的功能&#xff0c;我们怎么可以轻易放过呢&#xff1f; 先看看界面&#xff1a; 二话不说&#xff0c; 先实现界面&#xff1a; <!--pages/pulish/pulish.wxml--> <view classflexDownC><view classflexDownC w100> <…

js的form.reder()函数渲染table表格中的下拉框数据

目录 问题描述 form.reder()函数 简单介绍一下form.reder() layui官网对于渲染页面的介绍 页面渲染 问题描述 在我的项目中遇到一个问题在table中添加输入框但是下拉输入框中没有我们的数据 如图: 看代码 : function add(data) {data.forEach((item, index) > {let …

【工控老马】欧姆龙PLC Socket发送Fins/TCP命令解析

欧姆龙Socket tool发送Fins/TCP命令 实验设备&#xff1a;CJ2M-CPU33(PLC) 实验目的&#xff1a;发送Fins/TCP命令读写CJ2M-CPU33的数据 实验步骤&#xff1a; 1、 系统概述&#xff0c;硬件搭建和接线&#xff1a; 图1.1 2、软件设置 ①首先在PLC里通过CX-Programmer设置CJ…

动量梯度下降法(gradient descent with momentum)

简介 动量梯度下降法是对梯度下降法的改良版本&#xff0c;通常来说优化效果好于梯度下降法。对梯度下降法不熟悉的可以参考梯度下降法&#xff0c;理解梯度下降法是理解动量梯度下降法的前提&#xff0c;除此之外要搞懂动量梯度下降法需要知道原始方法在实际应用中的不足之处…