Commit 47113b44 by 梁建民

js

parent 6caf8244
{
"pages": [
"pages/person/auth/index",
"pages/person/register/index",
"pages/person/verifycode/index",
"pages/person/login/index",
"pages/person/getphone/index",
"pages/person/agreement/index",
"pages/person/successfully/index",
"pages/person/register/index",
"pages/tab/home/home",
"pages/form/good/index",
"pages/tab/good/good",
......
......@@ -99,7 +99,6 @@ Page({
mobileFlag: true
});
return false;
}
if (!reg_mobile.test(mobile)) {
......@@ -109,9 +108,7 @@ Page({
errorText: '请填写正确的手机号',
mobileFlag: true
});
return false;
}
......@@ -123,7 +120,6 @@ Page({
mobileFlag: false,
passwordFlag: true
});
return false;
}
......@@ -135,9 +131,7 @@ Page({
mobileFlag: false,
passwordFlag: true
});
return false;
}
this.setData({
......
......@@ -11,7 +11,7 @@
<view class="inp-wrap row verCenter {{mobileFlag ? 'inp-error':''}}">
<text class="icon iconfont iconiconxiantiaoshouji21"></text>
<view class="form-item-right row verCenter bothSide">
<input placeholder="请输入手机号" placeholder-class="placeholderClass" name="mobile" type="number" data-type="1" bindinput='bindinputFn' bindblur='bindblurFn'></input>
<input placeholder="请输入手机号" placeholder-class="placeholderClass" name="mobile" type="number" data-type="1" bindinput='bindinputFn'></input>
<view class="areacode" bindtap="switchPrice">
<text class="tel-value">中国 + 86</text>
<text class="icon iconfont iconbianzu1"></text>
......@@ -22,7 +22,7 @@
<view class="inp-wrap row verCenter {{passwordFlag ? 'inp-error':''}}">
<text class="icon iconfont iconiconxiantiaoshouji2"></text>
<view class="form-item-right row verCenter bothSide">
<input placeholder="请输入密码" placeholder-class="placeholderClass" class="pwd" name="password" data-type="2" password='{{passwordType}}' bindinput='bindinputFn' bindblur='bindblurFn'></input>
<input placeholder="请输入密码" placeholder-class="placeholderClass" class="pwd" name="password" data-type="2" password='{{passwordType}}' bindinput='bindinputFn'></input>
<block wx:if="{{visiblePwd}}">
<text class="icon iconfont iconiconxiantiaoshouji3 pwd-ico" bindtap="toggleFn"></text>
</block>
......
// pages/person/register/index.js
const http = require('../../../utils/util.js');
import {
apis
} from '../../../utils/api.js';
Page({
/**
* 页面的初始数据
*/
data: {
/**
* 页面的初始数据
*/
data: {
error: false,
errorText: '',
visiblePwd: false,
passwordType: true,
mobileFlag: false,
passwordFlag: false,
codeFlag: false,
disabled: false,
disabledBtn: false,
loading: false,
currentTime: 61,
vcode: false,
vcodeFlag: false,
timeText: '发送验证码',
captchaUrl: '',
captchaUuid: '',
captcha: '',
formData: {
mobile: '',
code: ''
}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function() {
},
/**
* 获取验证码
*/
getCode: function() {
let self = this;
let currentTime = this.data.currentTime;
let interval = setInterval(function() {
currentTime--;
self.setData({
timeText: currentTime + 's'
});
if (currentTime <= 0) {
clearInterval(interval);
self.setData({
timeText: '重新发送',
currentTime: 61,
disabled: false
});
}
}, 1000)
},
/**
* 发送验证码
*/
getVerificationCode: function(e) {
//验证必填手机号
if (this.data.formData.mobile) {
//验证是否发送了验证码
if (this.data.captchaUuid) {
//是否填写了验证码
if (this.data.captcha) {
http.getData(apis.getRegistCode, {
captchaUuid: this.data.captchaUuid,
captcha: this.data.captcha,
mobile: this.data.formData.mobile,
code_type: 1
}, (res) => {
if (res.err_code === 0) {
this.getCode();
this.setData({
disabled: true
});
} else if (res.err_code === 500) {
//图形验证码不正确的时候
this.refreshVerification();
wx.showToast({
title: res.err_msg,
icon: 'none',
duration: 2000
});
} else {
wx.showToast({
title: res.err_msg,
icon: 'none',
duration: 2000
});
}
}, true);
} else {
this.setData({
error: true,
errorText: '图形验证码不能为空',
vcodeFlag: true
});
}
} else {
this.refreshVerification();
}
} else {
this.setData({
error: true,
errorText: '手机号不能为空',
mobileFlag: true
});
}
},
/**
* 刷新图形验证码
*/
refreshVerification: function() {
this.setData({
vcode: true
});
http.getData(apis.captchaInfo, null, (res) => {
this.setData({
captchaUrl: res.captchaUrl,
captchaUuid: res.captchaUuid
});
});
},
/**
* 校验字段
*/
bindinputFn: function(e) {
let value = e.detail.value
let reg_mobile = /^(13[0-9]|14[579]|15[0-3,5-9]|16[6]|17[0135678]|18[0-9]|19[89])\d{8}$/;
let reg_pwd = /^[0-9A-Za-z]{6,}$/;
if (e.currentTarget.dataset.type == 1) {
this.setData({
'formData.mobile': value
});
if (value) {
this.setData({
error: true,
errorText: '请填写正确的手机号',
mobileFlag: true
});
if (reg_mobile.test(value)) {
this.setData({
error: false,
errorText: '',
mobileFlag: false
});
}
}
} else if (e.currentTarget.dataset.type == 2) {
if (value) {
this.setData({
error: false,
errorText: '',
codeFlag: false
});
}
} else if (e.currentTarget.dataset.type == 3) {
if (value) {
this.setData({
captcha: value
});
this.setData({
error: false,
errorText: '',
vcodeFlag: false
});
}
} else if (e.currentTarget.dataset.type == 4) {
if (value) {
this.setData({
error: true,
errorText: '密码由字母和数字组成,且不能少于6位',
passwordFlag: true
});
if (reg_pwd.test(value)) {
this.setData({
error: false,
errorText: '',
passwordFlag: false
});
}
}
}
},
/**
* 校验字段
*/
calcForm: function(val, type) {
let mobile = val.mobile;
let code = val.code;
let password = val.password;
let reg_mobile = /^(13[0-9]|14[579]|15[0-3,5-9]|16[6]|17[0135678]|18[0-9]|19[89])\d{8}$/;
let reg_pwd = /^[0-9A-Za-z]{6,}$/;
if (!mobile) {
this.setData({
error: true,
errorText: '手机号不能为空',
mobileFlag: true
});
return false;
}
if (!reg_mobile.test(mobile)) {
this.setData({
error: true,
errorText: '请填写正确的手机号',
mobileFlag: true
});
return false;
}
if (!password) {
this.setData({
error: true,
errorText: '密码不能为空',
mobileFlag: false,
passwordFlag: true
});
return false;
}
if (!reg_pwd.test(password)) {
},
this.setData({
error: true,
errorText: '密码由字母和数字组成,且不能少于6位',
mobileFlag: false,
passwordFlag: true
});
return false;
}
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
if (!code) {
},
this.setData({
error: true,
errorText: '验证码不能为空',
codeFlag: true
});
return false;
}
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
this.setData({
error: false,
errorText: '',
codeFlag: false,
mobileFlag: false
});
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
return true;
},
/**
*注册
*/
formSubmit: function(e) {
},
if (this.calcForm(e.detail.value)) {
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
this.setData({
disabledBtn: true,
loading: true
});
},
http.postData(apis.authRegister, e.detail.value, (res) => {
if (res.err_code === 0) {
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
//注入token
wx.setStorage({
key: "access_token",
data: res.data.access_token
});
},
wx.switchTab({
url: '/pages/tab/home/home'
})
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
} else {
wx.showToast({
title: res.err_msg,
icon: 'none',
duration: 2000
});
}
this.setData({
disabledBtn: false,
loading: false
});
});
}
},
/**
* 密码是否可见
*/
toggleFn: function(e) {
},
if (this.data['visiblePwd']) {
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
this.setData({
visiblePwd: false,
passwordType: true
});
},
} else {
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
this.setData({
visiblePwd: true,
passwordType: false
});
}
})
\ No newline at end of file
}
}
})
.person {
.person {
margin: 0 55rpx;
padding-top: 32rpx;
.tit {
......@@ -50,10 +50,10 @@
.register-button {
height: 98rpx;
line-height: 98rpx;
background: rgba(13, 132, 209, 1);
box-shadow: 0px 6rpx 10rpx 0rpx rgba(97, 160, 242, 0.3);
background: rgba(13, 132, 209, 1) !important;
box-shadow: 0px 6rpx 10rpx 0rpx rgba(97, 160, 242, 0.3) !important;
border-radius: 8rpx;
color: #fff;
color: #fff !important;
font-size: 32rpx;
margin-top: 40rpx;
}
......@@ -90,4 +90,13 @@
color: #adb6bf;
font-size: 32rpx;
}
.inp-error {
border-bottom: 1px solid #ea1717;
.icon {
color: #ea1717;
}
input {
color: #ea1717;
}
}
}
<!-- 注册 -->
<view class="person">
<view class="column tit">
<text class="t1">Hi,上午好</text>
<text class="t1">欢迎注册账户!</text>
</view>
<view class="inp-wrap row verCenter">
<text class="icon iconfont iconiconxiantiaoshouji21"></text>
<view class="form-item-right row verCenter bothSide">
<input placeholder="请输入手机号" placeholder-class="placeholderClass"></input>
<view class="areacode" bindtap="switchPrice">
<text class="tel-value">中国 + 86</text>
<text class="icon iconfont iconbianzu1"></text>
</view>
</view>
</view>
<view class="inp-wrap row verCenter">
<text class="icon iconfont iconiconxiantiaoshouji2"></text>
<view class="form-item-right row verCenter bothSide">
<input placeholder="请设置密码" placeholder-class="placeholderClass" class="pwd"></input>
<text class="icon iconfont iconiconxiantiaoshouji4 pwd-ico"></text>
</view>
</view>
<view class="inp-wrap row verCenter">
<text class="icon iconfont iconiconxiantiaoshouji"></text>
<view class="form-item-right row verCenter bothSide">
<input placeholder="请输入验证码" placeholder-class="placeholderClass"></input>
<button class="vcode">发送验证码</button>
</view>
</view>
<view class="error-wrap row bothSide verCenter">
<view class="error">
<text class="icon iconfont iconiconxiantiaoshouji1"></text>
<text class="txt">密码错误,请重新输入</text>
</view>
</view>
<button class="register-button">注册</button>
<view class="agreement">
<text class="t1">点击注册即默认同意</text>
<navigator url="/pages/person/agreement/index" class="t2">《IC业务助手用户协议》</navigator>
</view>
</view>
\ No newline at end of file
<view class="column tit">
<text class="t1">Hi,上午好</text>
<text class="t1">欢迎注册账户!</text>
</view>
<form bindsubmit="formSubmit">
<view class="inp-wrap row verCenter {{mobileFlag ? 'inp-error':''}}">
<text class="icon iconfont iconiconxiantiaoshouji21"></text>
<view class="form-item-right row verCenter bothSide">
<input placeholder="请输入手机号" placeholder-class="placeholderClass" name="mobile" type="number" data-type="1" bindinput='bindinputFn'></input>
<view class="areacode" bindtap="switchPrice">
<text class="tel-value">中国 + 86</text>
<text class="icon iconfont iconbianzu1"></text>
</view>
</view>
</view>
<view class="inp-wrap row verCenter {{passwordFlag ? 'inp-error':''}}">
<text class="icon iconfont iconiconxiantiaoshouji2"></text>
<view class="form-item-right row verCenter bothSide">
<input placeholder="请输入密码" placeholder-class="placeholderClass" class="pwd" name="password" data-type="4" password='{{passwordType}}'
bindinput='bindinputFn'></input>
<block wx:if="{{visiblePwd}}">
<text class="icon iconfont iconiconxiantiaoshouji3 pwd-ico" bindtap="toggleFn"></text>
</block>
<block wx:else>
<text class="icon iconfont iconiconxiantiaoshouji4 pwd-ico" bindtap="toggleFn"></text>
</block>
</view>
</view>
<view class="inp-wrap row verCenter {{vcodeFlag ? 'inp-error':''}}" wx:if="{{vcode}}">
<text class="icon iconfont iconiconxiantiaoshouji"></text>
<view class="form-item-right row verCenter bothSide">
<input placeholder="请输入图形验证码" placeholder-class="placeholderClass" name='captcha' data-type="3" bindinput='bindinputFn'></input>
<view class='code-img'>
<cover-image src="{{captchaUrl}}" class="img" bindtap='refreshVerification'></cover-image>
</view>
</view>
</view>
<view class="inp-wrap row verCenter {{codeFlag ? 'inp-error':''}}">
<text class="icon iconfont iconiconxiantiaoshouji"></text>
<view class="form-item-right row verCenter bothSide">
<input placeholder="请输入手机验证码" placeholder-class="placeholderClass" name='code' data-type="2" bindinput='bindinputFn'></input>
<button class="vcode {{disabled ? 'vcode-color':''}}" disabled="{{disabled}}" bindtap="getVerificationCode">{{timeText}}</button>
</view>
</view>
<view class="error-wrap row bothSide verCenter">
<view class="error">
<block wx:if="{{error}}">
<text class="icon iconfont iconiconxiantiaoshouji1"></text>
<text class="txt">{{errorText}}</text>
</block>
</view>
</view>
<button class="register-button" form-type="submit" disabled="{{disabledBtn}}" loading="{{loading}}">注册</button>
</form>
<view class="agreement">
<text class="t1">点击注册即默认同意</text>
<navigator url="/pages/person/agreement/index" class="t2">《IC业务助手用户协议》</navigator>
</view>
</view>
......@@ -51,10 +51,10 @@
.person .register-button {
height: 98rpx;
line-height: 98rpx;
background: #0d84d1;
box-shadow: 0px 6rpx 10rpx 0rpx rgba(97, 160, 242, 0.3);
background: #0d84d1 !important;
box-shadow: 0px 6rpx 10rpx 0rpx rgba(97, 160, 242, 0.3) !important;
border-radius: 8rpx;
color: #fff;
color: #fff !important;
font-size: 32rpx;
margin-top: 40rpx;
}
......@@ -89,3 +89,12 @@
color: #adb6bf;
font-size: 32rpx;
}
.person .inp-error {
border-bottom: 1px solid #ea1717;
}
.person .inp-error .icon {
color: #ea1717;
}
.person .inp-error input {
color: #ea1717;
}
......@@ -137,6 +137,14 @@ Page({
this.setData({
disabled: true
});
} else if (res.err_code === 500) {
//图形验证码不正确的时候
this.refreshVerification();
wx.showToast({
title: res.err_msg,
icon: 'none',
duration: 2000
});
} else {
wx.showToast({
title: res.err_msg,
......@@ -289,11 +297,9 @@ Page({
*/
formSubmit: function(e) {
var self = this;
if (this.calcForm(e.detail.value)) {
self.setData({
this.setData({
disabledBtn: true,
loading: true
});
......@@ -318,7 +324,7 @@ Page({
duration: 2000
});
}
self.setData({
this.setData({
disabledBtn: false,
loading: false
});
......
......@@ -34,7 +34,7 @@ const apis = {
/**
* 获取图形验证码接口
*/
captchaInfo: auth_url + '/captchaInfo',
captchaInfo: auth_url + '/captchaInfo/wx',
/**
* 注册获取短信验证码接口
*/
......
......@@ -2,7 +2,7 @@
const getData = (url, param, callBack,loading) => {
wx.showNavigationBarLoading();
var params = Object.assign({}, param, { pf: 1 });
var params = Object.assign({}, param, { source: 1 });
if(loading){
wx.showLoading();
......@@ -42,7 +42,7 @@ const postData = (url, param, callBack, loading) => {
wx.showNavigationBarLoading();
var params = Object.assign({}, param, { pf: 1 });
var params = Object.assign({}, param, { source: 1 });
if (loading) {
wx.showLoading();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment