Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
施宇
/
icsalesProgram
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
47113b44
authored
Jul 25, 2019
by
梁建民
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
js
parent
6caf8244
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
419 additions
and
42 deletions
app.json
pages/person/login/index.js
pages/person/login/index.wxml
pages/person/register/index.js
pages/person/register/index.less
pages/person/register/index.wxml
pages/person/register/index.wxss
pages/person/verifycode/index.js
utils/api.js
utils/util.js
app.json
View file @
47113b44
{
"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"
,
...
...
pages/person/login/index.js
View file @
47113b44
...
...
@@ -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
({
...
...
pages/person/login/index.wxml
View file @
47113b44
...
...
@@ -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
View file @
47113b44
// pages/person/register/index.js
const
http
=
require
(
'../../../utils/util.js'
);
import
{
apis
}
from
'../../../utils/api.js'
;
Page
({
/**
* 页面的初始数据
*/
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
)
{
onLoad
:
function
(
options
)
{
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady
:
function
()
{
onReady
:
function
()
{
},
/**
* 生命周期函数--监听页面显示
*/
onShow
:
function
()
{
onShow
:
function
()
{
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide
:
function
()
{
onHide
:
function
()
{
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload
:
function
()
{
onUnload
:
function
()
{
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh
:
function
()
{
onPullDownRefresh
:
function
()
{
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom
:
function
()
{
onReachBottom
:
function
()
{
},
/**
* 用户点击右上角分享
*/
onShareAppMessage
:
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
;
}
if
(
!
code
)
{
this
.
setData
({
error
:
true
,
errorText
:
'验证码不能为空'
,
codeFlag
:
true
});
return
false
;
}
this
.
setData
({
error
:
false
,
errorText
:
''
,
codeFlag
:
false
,
mobileFlag
:
false
});
return
true
;
},
/**
*注册
*/
formSubmit
:
function
(
e
)
{
if
(
this
.
calcForm
(
e
.
detail
.
value
))
{
this
.
setData
({
disabledBtn
:
true
,
loading
:
true
});
http
.
postData
(
apis
.
authRegister
,
e
.
detail
.
value
,
(
res
)
=>
{
if
(
res
.
err_code
===
0
)
{
//注入token
wx
.
setStorage
({
key
:
"access_token"
,
data
:
res
.
data
.
access_token
});
wx
.
switchTab
({
url
:
'/pages/tab/home/home'
})
}
else
{
wx
.
showToast
({
title
:
res
.
err_msg
,
icon
:
'none'
,
duration
:
2000
});
}
this
.
setData
({
disabledBtn
:
false
,
loading
:
false
});
});
}
},
/**
* 密码是否可见
*/
toggleFn
:
function
(
e
)
{
if
(
this
.
data
[
'visiblePwd'
])
{
this
.
setData
({
visiblePwd
:
false
,
passwordType
:
true
});
}
else
{
this
.
setData
({
visiblePwd
:
true
,
passwordType
:
false
});
}
}
})
pages/person/register/index.less
View file @
47113b44
...
...
@@ -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;
}
}
}
pages/person/register/index.wxml
View file @
47113b44
...
...
@@ -6,10 +6,12 @@
<text class="t1">欢迎注册账户!</text>
</view>
<view class="inp-wrap row verCenter">
<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"
></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>
...
...
@@ -17,30 +19,48 @@
</view>
</view>
<view class="inp-wrap row verCenter
">
<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"></input>
<text class="icon iconfont iconiconxiantiaoshouji4 pwd-ico"></text>
<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">
<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"
></input>
<button class="vcode">发送验证码
</button>
<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">密码错误,请重新输入</text>
<text class="txt">{{errorText}}</text>
</block>
</view>
</view>
<button class="register-button">注册</button>
<button class="register-button" form-type="submit" disabled="{{disabledBtn}}" loading="{{loading}}">注册</button>
</form>
<view class="agreement">
<text class="t1">点击注册即默认同意</text>
...
...
pages/person/register/index.wxss
View file @
47113b44
...
...
@@ -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;
}
pages/person/verifycode/index.js
View file @
47113b44
...
...
@@ -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
});
...
...
utils/api.js
View file @
47113b44
...
...
@@ -34,7 +34,7 @@ const apis = {
/**
* 获取图形验证码接口
*/
captchaInfo
:
auth_url
+
'/captchaInfo'
,
captchaInfo
:
auth_url
+
'/captchaInfo
/wx
'
,
/**
* 注册获取短信验证码接口
*/
...
...
utils/util.js
View file @
47113b44
...
...
@@ -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
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment