Business logic :
1, Implement login , register , Forget password function 
2, When requesting background , Passed parameter encryption 
3, cell-phone number , When the password is sent to the backend , Encryption processing 
  More codes , Post a login page 
<template> <view> <!-- 1 logo --> <view class="logo"> <image 
src="../../static/image/wx.png"></image> </view> <!-- 2  login information  --> <form 
@submit="doLogin"> <view class="login-info"> <view class="item"> <image 
src="../../static/image/login_tel.png"></image> <input name="mobile" 
type="number" placeholder=" Please enter your mobile number " maxlength="11"></input> </view> <view 
class="item"> <image src="../../static/image/login_pwd.png"></image> <input 
name="password" password placeholder=" Please input a password (6~15 position )" maxlength="15"></input> 
</view> <view class="item"> <text class="font-gray"> Login means you have agreed </text> <navigator 
class="color-green" url="/pages/agreement/agreement">《 User service agreement 》</navigator> 
</view> </view> <!-- 3  Login button  --> <button formType="submit" class="big-btn" 
lang="zh_CN"> Sign in </button> </form> <!-- 4  Auxiliary operation  --> <view class="login-opts 
font-gray"> <navigator url="/pages/register/register?type=0"> Quick registration </navigator> 
<navigator url="/pages/register/register?type=1"> Forgot password ?</navigator> </view> 
</view> </template> <script> import sha from '../../common/sha256.js'; export 
default { data() { return { mobile: '', password: '', navUrl:'' } }, 
onLoad:function(options){ let navUrl = options.navUrl; if (navUrl != null && 
navUrl != undefined && navUrl != '') {// Transfer from other interfaces url this.navUrl=navUrl }else{ 
this.navUrl='' } }, methods: { //  validate logon  doLogin: function(e) { let param = 
e.detail.value // Get user name when submitting , password  this._mysubmit(param) }, //  Verify my submission {mobile: "", 
password: ""} _mysubmit: function(param) { let mobile = param.mobile.trim() let 
password = param.password.trim() let flag = this._checkMobile(mobile) && 
this._checkPassword(password)// check  if (flag) { this._checkUserInfo(param); } }, 
//  Verify user name  _checkMobile: function (param) { let regFlag = 
this.$util.checkMobile(param) let telLens = param.length if (telLens === 0) { 
this.$request.setErrorMessage(' Mobile number cannot be empty ') } else if (telLens < 11) { 
this.$request.setErrorMessage(' Mobile number length error ') } else if (!regFlag) { 
this.$request.setErrorMessage(' Mobile number format error ') } else { return true } }, //  Verify password  
_checkPassword: function (param) { let pwdLens = param.length; if (pwdLens === 
0) { this.$request.setErrorMessage(' Password cannot be empty ') } else if (pwdLens < 6) { 
this.$request.setErrorMessage(' Password length cannot be less than 6 position ') }else{ return true } }, //  Check user information  
param={mobile: "", password: ""} _checkUserInfo: function(param) { let password 
= sha.sha256(param.password.trim()) param.password = password 
this.gotoLogin(param); }, gotoLogin(param){ this.$request.setRequest('/login', 
param) .then(res => { if (res.data.status == 1) {// success  let userInfo = 
res.data.data this.$common.setGlobalUserInfo(userInfo)//goto It should be the user information returned by the backend {} // 
 Log login success timestamp  let timestamp = new Date().getTime(); 
this.$common.setLogintimeInfo(timestamp); 
this.$request.setErrorMessage(res.data.msg) //  Jump to login interface  let navUrl = 
this.navUrl; if (navUrl != null && navUrl != undefined && navUrl != '') 
{// Transfer from other interfaces url uni.switchTab({ url: '/pages/' + navUrl, }) } else { 
uni.switchTab({ url: '/pages/mine/mine' // Parameter can only be in string form , Cannot be json object  }) } } else if 
(res.data.status <1){ this.$request.setErrorMessage(res.data.msg) }else{ 
this.$request.setErrorMessage() } }) }, } } </script> <style> @import 
'login.css'; </style> 
 
Technology