Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
张身仁
/
mp-car-evaluate
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
b1c88250
authored
Sep 20, 2019
by
zhangshengren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加验证码
parent
c8c8bb17
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
418 additions
and
23 deletions
+418
-23
app.js
+1
-0
pages/index/index.js
+179
-11
pages/index/index.wxml
+11
-0
pages/index/index.wxss
+18
-0
pages/sellcar/sellcar.js
+180
-12
pages/sellcar/sellcar.wxml
+11
-0
pages/sellcar/sellcar.wxss
+18
-0
No files found.
app.js
View file @
b1c88250
...
...
@@ -3,6 +3,7 @@ App({
globalData
:
{
app_id
:
'wx3722cae0d0b62fff'
,
url
:
'https://test-es.checheng.com/api/'
,
urlSpecial
:
'https://test-es.checheng.com/api-weapp/'
,
name
:
'爱车估价助手'
,
width
:
0
,
height
:
0
,
...
...
pages/index/index.js
View file @
b1c88250
const
app
=
getApp
();
const
utils
=
require
(
'../../utils/util.js'
);
const
{
md5
}
=
require
(
'../../utils/md5.js'
);
const
{
md5
}
=
require
(
'../../utils/md5.js'
);
Page
({
...
...
@@ -13,8 +15,17 @@ Page({
mileage
:
''
,
city_id
:
''
,
city_name
:
''
,
phone
:
''
phone
:
''
,
pre_phone
:
''
},
inputSmsCode
:
''
,
smsCode
:
''
,
disabled
:
false
,
totalTime
:
120
,
timer
:
null
,
btnText
:
'获取验证码'
,
startTime
:
''
,
endTime
:
''
,
provinceList
:
[],
...
...
@@ -31,10 +42,19 @@ Page({
onShow
:
function
()
{
let
_this
=
this
if
(
this
.
timer
)
{
clearInterval
(
this
.
timer
)
}
this
.
setData
({
provinceList
:
app
.
globalData
.
provinceList
,
province_index
:
wx
.
getStorageSync
(
'province_index'
),
city_index
:
wx
.
getStorageSync
(
'city_index'
)
city_index
:
wx
.
getStorageSync
(
'city_index'
),
inputSmsCode
:
''
,
smsCode
:
''
,
disabled
:
false
,
totalTime
:
120
,
timer
:
null
,
btnText
:
'获取验证码'
},
()
=>
{
if
(
_this
.
data
.
provinceList
.
length
===
0
)
{
_this
.
getProvinceList
()
...
...
@@ -83,11 +103,11 @@ Page({
},
// 获取省份
getProvinceList
:
function
()
{
getProvinceList
:
function
()
{
let
_this
=
this
;
wx
.
request
({
url
:
app
.
globalData
.
url
+
'assess/provinces'
,
success
:
function
(
res
)
{
success
:
function
(
res
)
{
if
(
res
.
data
&&
res
.
data
.
length
>
0
)
{
let
data
=
res
.
data
let
arr
=
[]
...
...
@@ -212,14 +232,146 @@ Page({
// 输入手机号
phoneInput
:
function
(
e
)
{
let
pre_phone
=
this
.
data
.
userForms
.
pre_phone
let
phone
=
e
.
detail
.
value
if
(
pre_phone
!=
phone
)
{
this
.
setData
({
showSmsCode
:
true
})
}
else
if
(
pre_phone
==
phone
)
{
this
.
setData
({
showSmsCode
:
false
})
wx
.
setStorageSync
(
'phone'
,
phone
)
}
this
.
setData
({
[
'userForms.phone'
]:
phone
})
if
(
phone
.
length
===
11
)
{
wx
.
setStorageSync
(
'phone'
,
phone
)
// if (phone.length === 11) {
// wx.setStorageSync('phone', phone)
// }
},
// 输入验证码
smsCodeInput
:
function
(
e
)
{
let
code
=
e
.
detail
.
value
this
.
setData
({
inputSmsCode
:
code
})
},
// 倒计时
countDown
:
function
()
{
let
_this
=
this
;
_this
.
timer
=
setInterval
(
function
()
{
_this
.
data
.
totalTime
--
;
_this
.
data
.
btnText
=
_this
.
data
.
totalTime
+
'秒'
;
if
(
_this
.
data
.
totalTime
<
0
)
{
clearInterval
(
_this
.
timer
)
_this
.
setData
({
totalTime
:
120
,
btnText
:
'重新获取'
})
}
else
{
_this
.
setData
({
totalTime
:
_this
.
data
.
totalTime
,
btnText
:
_this
.
data
.
btnText
})
}
},
1000
)
},
// 发送短信验证码
sendSmsCode
:
function
(
e
)
{
let
_this
=
this
if
(
!
this
.
data
.
userForms
.
specification_name
)
{
wx
.
showToast
({
icon
:
'none'
,
title
:
'请选择车型!'
})
return
false
;
}
if
(
!
this
.
data
.
userForms
.
buy_time
)
{
wx
.
showToast
({
icon
:
'none'
,
title
:
'请选择上牌时间!'
})
return
false
;
}
if
(
!
this
.
data
.
userForms
.
city_name
)
{
wx
.
showToast
({
icon
:
'none'
,
title
:
'请选择城市!'
})
return
false
;
}
if
(
!
this
.
data
.
userForms
.
mileage
)
{
wx
.
showToast
({
icon
:
'none'
,
title
:
'请输入行驶里程!'
})
return
false
;
}
if
(
Number
(
this
.
data
.
userForms
.
mileage
)
>
100
)
{
wx
.
showToast
({
icon
:
'none'
,
title
:
'行驶里程不能超过100万公里!'
})
return
false
;
}
if
(
!
this
.
data
.
userForms
.
phone
)
{
wx
.
showToast
({
icon
:
'none'
,
title
:
'请输入手机号码!'
})
return
false
;
}
let
reg
=
/^1
(
3|4|5|7|8|9
)\d{9}
$/
;
if
(
!
reg
.
test
(
this
.
data
.
userForms
.
phone
))
{
wx
.
showToast
({
icon
:
'none'
,
title
:
'手机号码格式不正确!'
})
return
false
;
}
let
data
=
{
phone
:
this
.
data
.
userForms
.
phone
}
_this
.
setData
({
disabled
:
true
},
()
=>
{
wx
.
request
({
url
:
app
.
globalData
.
urlSpecial
+
'main-customers/get-new-sms'
,
data
:
data
,
success
:
function
(
res
)
{
res
=
res
.
data
if
(
res
.
message
===
'ok'
&&
res
.
data
&&
res
.
data
.
code
)
{
_this
.
setData
({
smsCode
:
res
.
data
.
code
,
},
()
=>
{
_this
.
countDown
();
})
}
else
if
(
res
.
message
===
'ok'
&&
res
.
data
&&
res
.
data
.
error
===
1
)
{
wx
.
showToast
({
icon
:
'none'
,
title
:
res
.
data
.
msg
})
_this
.
setData
({
disabled
:
false
},
()
=>
{})
}
},
fail
:
function
(
res
)
{
wx
.
showToast
({
icon
:
'none'
,
title
:
'获取失败,请稍后重试!'
})
}
})
})
},
// 获取手机号
...
...
@@ -243,7 +395,7 @@ Page({
let
phone
=
res
.
data
.
purePhoneNumber
_this
.
setData
({
[
'userForms.phone'
]:
phone
,
showPhoneInput
:
true
[
'userForms.pre_phone'
]:
phone
,
})
wx
.
setStorageSync
(
'phone'
,
phone
)
}
else
{
...
...
@@ -260,7 +412,7 @@ Page({
}
else
if
(
errMsg
===
'getPhoneNumber:fail user deny'
)
{
this
.
setData
({
[
'userForms.phone'
]:
''
,
showPhoneInput
:
true
[
'userForms.pre_phone'
]:
''
,
})
}
},
...
...
@@ -289,12 +441,12 @@ Page({
url
:
app
.
globalData
.
url
+
'decode-phone'
,
data
:
data
,
method
:
'POST'
,
success
:
function
(
res
)
{
success
:
function
(
res
)
{
if
(
res
.
data
.
message
!==
'解密失败'
)
{
let
phone
=
res
.
data
.
purePhoneNumber
_this
.
setData
({
[
'userForms.phone'
]:
phone
,
showPhoneInput
:
true
[
'userForms.pre_phone'
]:
phone
,
})
wx
.
setStorageSync
(
'phone'
,
phone
)
}
else
{
...
...
@@ -365,6 +517,22 @@ Page({
return
false
;
}
if
(
!
this
.
data
.
inputSmsCode
)
{
wx
.
showToast
({
icon
:
'none'
,
title
:
'请输入短信验证码!'
})
return
false
;
}
if
((
this
.
data
.
inputSmsCode
!=
this
.
data
.
smsCode
))
{
wx
.
showToast
({
icon
:
'none'
,
title
:
'短信验证码不正确!'
})
return
false
;
}
this
.
terminalAvailable
(
app
.
globalData
.
tiantianpaiche_cityList
,
'天天拍车'
);
let
terminal_length
=
this
.
data
.
terminal_names
.
length
;
...
...
pages/index/index.wxml
View file @
b1c88250
...
...
@@ -68,6 +68,17 @@
<button bindgetphonenumber="getPhone" id="get-phone" openType="getPhoneNumber" size="mini" type="primary" wx:else>11位手机号</button> -->
</view>
</view>
<view class="weui-cell weui-cell_input form-input-item">
<view class="weui-cell__hd">
<view class="weui-label">验 证 码</view>
</view>
<view class="weui-cell__bd">
<input bindinput="smsCodeInput" maxlength="6" class="weui-input text-right" placeholder="请输入短信验证码" type="digit" value="{{inputSmsCode}}"></input>
</view>
<view class="weui-cell__ft">
<button bindtap="sendSmsCode" id="get-smsCode" class="{{disabled ? 'disabled': ''}}" size="mini" type="primary" disabled="{{disabled}}">{{btnText}}</button>
</view>
</view>
</view>
</view>
<view class="weui-cell submit-section">
...
...
pages/index/index.wxss
View file @
b1c88250
...
...
@@ -140,3 +140,20 @@ page {
color: #39424D;
text-align: right;
}
#get-smsCode {
display: block;
padding: 3px 5px;
margin-left: 30rpx;
width: 180rpx;
line-height: 2;
background: #fe560e;
color:#fff;
border-color: white;
font-size: 26rpx;
text-align: center;
}
button.disabled {
background: #cec5c0 !important;
}
\ No newline at end of file
pages/sellcar/sellcar.js
View file @
b1c88250
...
...
@@ -12,8 +12,16 @@ Page({
mileage
:
''
,
city_id
:
''
,
city_name
:
''
,
phone
:
''
phone
:
''
,
pre_phone
:
''
},
inputSmsCode
:
''
,
smsCode
:
''
,
disabled
:
false
,
totalTime
:
120
,
timer
:
null
,
btnText
:
'获取验证码'
,
startTime
:
''
,
endTime
:
''
,
provinceList
:
[],
...
...
@@ -61,10 +69,19 @@ Page({
onShow
:
function
()
{
let
_this
=
this
if
(
this
.
timer
)
{
clearInterval
(
this
.
timer
)
}
this
.
setData
({
provinceList
:
app
.
globalData
.
provinceList
,
province_index
:
wx
.
getStorageSync
(
'province_index'
),
city_index
:
wx
.
getStorageSync
(
'city_index'
)
city_index
:
wx
.
getStorageSync
(
'city_index'
),
inputSmsCode
:
''
,
smsCode
:
''
,
disabled
:
false
,
totalTime
:
120
,
timer
:
null
,
btnText
:
'获取验证码'
},
()
=>
{
if
(
_this
.
data
.
provinceList
.
length
===
0
)
{
_this
.
getProvinceList
()
...
...
@@ -241,19 +258,151 @@ Page({
},
// 输入手机号
phoneInput
:
function
(
e
)
{
phoneInput
:
function
(
e
)
{
let
pre_phone
=
this
.
data
.
userForms
.
pre_phone
let
phone
=
e
.
detail
.
value
if
(
pre_phone
!=
phone
)
{
this
.
setData
({
showSmsCode
:
true
})
}
else
if
(
pre_phone
==
phone
)
{
this
.
setData
({
showSmsCode
:
false
})
wx
.
setStorageSync
(
'phone'
,
phone
)
}
this
.
setData
({
[
'userForms.phone'
]:
phone
})
if
(
phone
.
length
===
11
)
{
wx
.
setStorageSync
(
'phone'
,
phone
)
// if (phone.length === 11) {
// wx.setStorageSync('phone', phone)
// }
},
// 输入验证码
smsCodeInput
:
function
(
e
)
{
let
code
=
e
.
detail
.
value
this
.
setData
({
inputSmsCode
:
code
})
},
// 倒计时
countDown
:
function
()
{
let
_this
=
this
;
_this
.
timer
=
setInterval
(
function
()
{
_this
.
data
.
totalTime
--
;
_this
.
data
.
btnText
=
_this
.
data
.
totalTime
+
'秒'
;
if
(
_this
.
data
.
totalTime
<
0
)
{
clearInterval
(
_this
.
timer
)
_this
.
setData
({
totalTime
:
120
,
btnText
:
'重新获取'
})
}
else
{
_this
.
setData
({
totalTime
:
_this
.
data
.
totalTime
,
btnText
:
_this
.
data
.
btnText
})
}
},
1000
)
},
// 发送短信验证码
sendSmsCode
:
function
(
e
)
{
let
_this
=
this
if
(
!
this
.
data
.
userForms
.
specification_name
)
{
wx
.
showToast
({
icon
:
'none'
,
title
:
'请选择车型!'
})
return
false
;
}
if
(
!
this
.
data
.
userForms
.
buy_time
)
{
wx
.
showToast
({
icon
:
'none'
,
title
:
'请选择上牌时间!'
})
return
false
;
}
if
(
!
this
.
data
.
userForms
.
city_name
)
{
wx
.
showToast
({
icon
:
'none'
,
title
:
'请选择城市!'
})
return
false
;
}
if
(
!
this
.
data
.
userForms
.
mileage
)
{
wx
.
showToast
({
icon
:
'none'
,
title
:
'请输入行驶里程!'
})
return
false
;
}
if
(
Number
(
this
.
data
.
userForms
.
mileage
)
>
100
)
{
wx
.
showToast
({
icon
:
'none'
,
title
:
'行驶里程不能超过100万公里!'
})
return
false
;
}
if
(
!
this
.
data
.
userForms
.
phone
)
{
wx
.
showToast
({
icon
:
'none'
,
title
:
'请输入手机号码!'
})
return
false
;
}
let
reg
=
/^1
(
3|4|5|7|8|9
)\d{9}
$/
;
if
(
!
reg
.
test
(
this
.
data
.
userForms
.
phone
))
{
wx
.
showToast
({
icon
:
'none'
,
title
:
'手机号码格式不正确!'
})
return
false
;
}
let
data
=
{
phone
:
this
.
data
.
userForms
.
phone
}
_this
.
setData
({
disabled
:
true
},
()
=>
{
wx
.
request
({
url
:
app
.
globalData
.
urlSpecial
+
'main-customers/get-new-sms'
,
data
:
data
,
success
:
function
(
res
)
{
res
=
res
.
data
if
(
res
.
message
===
'ok'
&&
res
.
data
&&
res
.
data
.
code
)
{
_this
.
setData
({
smsCode
:
res
.
data
.
code
,
},
()
=>
{
_this
.
countDown
();
})
}
else
if
(
res
.
message
===
'ok'
&&
res
.
data
&&
res
.
data
.
error
===
1
)
{
wx
.
showToast
({
icon
:
'none'
,
title
:
res
.
data
.
msg
})
_this
.
setData
({
disabled
:
false
},
()
=>
{
})
}
},
fail
:
function
(
res
)
{
wx
.
showToast
({
icon
:
'none'
,
title
:
'获取失败,请稍后重试!'
})
}
})
})
},
// 获取手机号
getPhone
:
function
(
e
)
{
getPhone
:
function
(
e
)
{
let
_this
=
this
let
errMsg
=
e
.
detail
.
errMsg
if
(
errMsg
===
'getPhoneNumber:ok'
)
{
...
...
@@ -268,11 +417,12 @@ Page({
url
:
app
.
globalData
.
url
+
'decode-phone'
,
data
:
data
,
method
:
'POST'
,
success
:
function
(
res
)
{
success
:
function
(
res
)
{
if
(
res
.
data
.
message
!==
'解密失败'
)
{
let
phone
=
res
.
data
.
purePhoneNumber
_this
.
setData
({
[
'userForms.phone'
]:
phone
,
[
'userForms.pre_phone'
]:
phone
,
})
wx
.
setStorageSync
(
'phone'
,
phone
)
}
else
{
...
...
@@ -289,16 +439,16 @@ Page({
}
else
if
(
errMsg
===
'getPhoneNumber:fail user deny'
)
{
this
.
setData
({
[
'userForms.phone'
]:
''
,
showPhoneInput
:
true
[
'userForms.pre_phone'
]:
''
,
})
}
},
// 重新获取code
login
:
function
(
e
)
{
login
:
function
(
e
)
{
let
_this
=
this
wx
.
login
({
success
:
function
(
res
)
{
success
:
function
(
res
)
{
if
(
res
.
errMsg
===
'login:ok'
)
{
let
data
=
{
code
:
res
.
code
,
...
...
@@ -307,7 +457,7 @@ Page({
wx
.
request
({
url
:
app
.
globalData
.
url
+
'user-code'
,
data
:
data
,
success
:
function
(
res
)
{
success
:
function
(
res
)
{
let
data
=
{
session_key
:
res
.
data
.
session_key
,
encrypted_data
:
e
.
detail
.
encryptedData
,
...
...
@@ -318,11 +468,12 @@ Page({
url
:
app
.
globalData
.
url
+
'decode-phone'
,
data
:
data
,
method
:
'POST'
,
success
:
function
(
res
)
{
success
:
function
(
res
)
{
if
(
res
.
data
.
message
!==
'解密失败'
)
{
let
phone
=
res
.
data
.
purePhoneNumber
_this
.
setData
({
[
'userForms.phone'
]:
phone
,
[
'userForms.pre_phone'
]:
phone
,
})
wx
.
setStorageSync
(
'phone'
,
phone
)
}
else
{
...
...
@@ -339,6 +490,7 @@ Page({
}
})
},
// 是否勾选
handleSelect
:
function
(
e
)
{
let
index
=
e
.
currentTarget
.
dataset
.
index
;
...
...
@@ -431,6 +583,22 @@ Page({
return
false
;
}
if
(
!
this
.
data
.
inputSmsCode
)
{
wx
.
showToast
({
icon
:
'none'
,
title
:
'请输入短信验证码!'
})
return
false
;
}
if
((
this
.
data
.
inputSmsCode
!=
this
.
data
.
smsCode
))
{
wx
.
showToast
({
icon
:
'none'
,
title
:
'短信验证码不正确!'
})
return
false
;
}
if
(
this
.
data
.
terminal_names
.
length
===
0
)
{
wx
.
showToast
({
icon
:
'none'
,
...
...
pages/sellcar/sellcar.wxml
View file @
b1c88250
...
...
@@ -68,6 +68,17 @@
<button bindgetphonenumber="getPhone" id="get-phone" openType="getPhoneNumber" size="mini" type="primary" wx:else>11位手机号</button> -->
</view>
</view>
<view class="weui-cell weui-cell_input form-input-item">
<view class="weui-cell__hd">
<view class="weui-label">验 证 码</view>
</view>
<view class="weui-cell__bd">
<input bindinput="smsCodeInput" maxlength="6" class="weui-input text-right" placeholder="请输入短信验证码" type="digit" value="{{inputSmsCode}}"></input>
</view>
<view class="weui-cell__ft">
<button bindtap="sendSmsCode" id="get-smsCode" class="{{disabled ? 'disabled': ''}}" size="mini" type="primary" disabled="{{disabled}}">{{btnText}}</button>
</view>
</view>
</view>
</view>
...
...
pages/sellcar/sellcar.wxss
View file @
b1c88250
...
...
@@ -238,3 +238,20 @@ page {
width: 202rpx;
height: 32rpx;
}
#get-smsCode {
display: block;
padding: 3px 5px;
margin-left: 30rpx;
width: 180rpx;
line-height: 2;
background: #fe560e;
color:#fff;
border-color: white;
font-size: 26rpx;
text-align: center;
}
button.disabled {
background: #cec5c0 !important;
}
\ No newline at end of file
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