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
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
1445 additions
and
1048 deletions
+1445
-1048
app.js
+1
-0
pages/index/index.js
+662
-493
pages/index/index.wxml
+11
-0
pages/index/index.wxss
+18
-0
pages/sellcar/sellcar.js
+724
-555
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({
...
@@ -3,6 +3,7 @@ App({
globalData
:
{
globalData
:
{
app_id
:
'wx3722cae0d0b62fff'
,
app_id
:
'wx3722cae0d0b62fff'
,
url
:
'https://test-es.checheng.com/api/'
,
url
:
'https://test-es.checheng.com/api/'
,
urlSpecial
:
'https://test-es.checheng.com/api-weapp/'
,
name
:
'爱车估价助手'
,
name
:
'爱车估价助手'
,
width
:
0
,
width
:
0
,
height
:
0
,
height
:
0
,
...
...
pages/index/index.js
View file @
b1c88250
const
app
=
getApp
();
const
app
=
getApp
();
const
utils
=
require
(
'../../utils/util.js'
);
const
utils
=
require
(
'../../utils/util.js'
);
const
{
md5
}
=
require
(
'../../utils/md5.js'
);
const
{
md5
}
=
require
(
'../../utils/md5.js'
);
Page
({
Page
({
data
:
{
data
:
{
userForms
:
{
userForms
:
{
link
:
app
.
globalData
.
link
,
link
:
app
.
globalData
.
link
,
specification_id
:
''
,
specification_id
:
''
,
specification_name
:
''
,
specification_name
:
''
,
buy_time
:
''
,
buy_time
:
''
,
mileage
:
''
,
mileage
:
''
,
city_id
:
''
,
city_id
:
''
,
city_name
:
''
,
city_name
:
''
,
phone
:
''
phone
:
''
,
},
pre_phone
:
''
startTime
:
''
,
endTime
:
''
,
provinceList
:
[],
province
:
''
,
province_index
:
''
,
cityList
:
[],
city_index
:
''
,
showPhoneInput
:
false
,
valuation
:
{},
carInfo
:
{},
terminal_names
:
[]
},
},
onShow
:
function
()
{
inputSmsCode
:
''
,
let
_this
=
this
smsCode
:
''
,
this
.
setData
({
disabled
:
false
,
provinceList
:
app
.
globalData
.
provinceList
,
totalTime
:
120
,
province_index
:
wx
.
getStorageSync
(
'province_index'
),
timer
:
null
,
city_index
:
wx
.
getStorageSync
(
'city_index'
)
btnText
:
'获取验证码'
,
},
()
=>
{
if
(
_this
.
data
.
provinceList
.
length
===
0
)
{
startTime
:
''
,
_this
.
getProvinceList
()
endTime
:
''
,
}
else
{
provinceList
:
[],
let
index
=
wx
.
getStorageSync
(
'province_index'
)
province
:
''
,
let
id
=
wx
.
getStorageSync
(
'province_id'
)
province_index
:
''
,
if
(
index
)
{
cityList
:
[],
_this
.
setData
({
city_index
:
''
,
province
:
_this
.
data
.
provinceList
[
index
].
name
showPhoneInput
:
false
,
})
_this
.
getCityList
(
id
,
_this
)
valuation
:
{},
}
carInfo
:
{},
}
terminal_names
:
[]
})
},
let
years
=
wx
.
getStorageSync
(
'years'
)
let
startTime
,
endTime
onShow
:
function
()
{
if
(
years
.
length
>
4
)
{
let
_this
=
this
startTime
=
years
.
substr
(
0
,
4
)
if
(
this
.
timer
)
{
endTime
=
years
.
substr
(
-
4
,
4
)
clearInterval
(
this
.
timer
)
let
today
=
utils
.
formatDate
(
new
Date
())
}
if
(
today
.
indexOf
(
endTime
)
>
-
1
)
{
this
.
setData
({
endTime
=
today
provinceList
:
app
.
globalData
.
provinceList
,
}
else
{
province_index
:
wx
.
getStorageSync
(
'province_index'
),
endTime
=
endTime
+
'-12-31'
city_index
:
wx
.
getStorageSync
(
'city_index'
),
}
inputSmsCode
:
''
,
this
.
setData
({
smsCode
:
''
,
startTime
:
startTime
+
'-01-01'
,
disabled
:
false
,
endTime
:
endTime
totalTime
:
120
,
})
timer
:
null
,
btnText
:
'获取验证码'
},
()
=>
{
if
(
_this
.
data
.
provinceList
.
length
===
0
)
{
_this
.
getProvinceList
()
}
else
{
let
index
=
wx
.
getStorageSync
(
'province_index'
)
let
id
=
wx
.
getStorageSync
(
'province_id'
)
if
(
index
)
{
_this
.
setData
({
province
:
_this
.
data
.
provinceList
[
index
].
name
})
_this
.
getCityList
(
id
,
_this
)
}
}
}
})
let
years
=
wx
.
getStorageSync
(
'years'
)
let
startTime
,
endTime
if
(
years
.
length
>
4
)
{
startTime
=
years
.
substr
(
0
,
4
)
endTime
=
years
.
substr
(
-
4
,
4
)
let
today
=
utils
.
formatDate
(
new
Date
())
if
(
today
.
indexOf
(
endTime
)
>
-
1
)
{
endTime
=
today
}
else
{
endTime
=
endTime
+
'-12-31'
}
this
.
setData
({
startTime
:
startTime
+
'-01-01'
,
endTime
:
endTime
})
}
this
.
getItem
(
'specification_id'
)
this
.
getItem
(
'specification_id'
)
this
.
getItem
(
'specification_name'
)
this
.
getItem
(
'specification_name'
)
this
.
getItem
(
'city_id'
)
this
.
getItem
(
'city_id'
)
this
.
getItem
(
'city_name'
)
this
.
getItem
(
'city_name'
)
this
.
getItem
(
'buy_time'
)
this
.
getItem
(
'buy_time'
)
this
.
getItem
(
'mileage'
)
this
.
getItem
(
'mileage'
)
this
.
getItem
(
'phone'
)
this
.
getItem
(
'phone'
)
let
province
=
wx
.
getStorageSync
(
'province'
)
let
province
=
wx
.
getStorageSync
(
'province'
)
this
.
setData
({
this
.
setData
({
province
:
province
?
province
:
''
province
:
province
?
province
:
''
})
})
this
.
data
.
terminal_names
=
[]
this
.
data
.
terminal_names
=
[]
},
},
// 获取省份
// 获取省份
getProvinceList
:
function
()
{
getProvinceList
:
function
()
{
let
_this
=
this
;
let
_this
=
this
;
wx
.
request
({
wx
.
request
({
url
:
app
.
globalData
.
url
+
'assess/provinces'
,
url
:
app
.
globalData
.
url
+
'assess/provinces'
,
success
:
function
(
res
)
{
success
:
function
(
res
)
{
if
(
res
.
data
&&
res
.
data
.
length
>
0
)
{
if
(
res
.
data
&&
res
.
data
.
length
>
0
)
{
let
data
=
res
.
data
let
data
=
res
.
data
let
arr
=
[]
let
arr
=
[]
for
(
let
key
in
data
)
{
for
(
let
key
in
data
)
{
if
(
data
[
key
].
id
===
32
)
{
if
(
data
[
key
].
id
===
32
)
{
continue
continue
}
arr
.
push
(
data
[
key
])
}
_this
.
setData
({
provinceList
:
arr
})
}
}
})
},
// 城市列表
getCityList
:
function
(
parent_id
,
_this
)
{
wx
.
request
({
url
:
app
.
globalData
.
url
+
'assess/cities'
,
data
:
{
parent_id
},
success
:
function
(
res
)
{
if
(
res
.
data
&&
res
.
data
.
length
>
0
)
{
let
data
=
res
.
data
_this
.
setData
({
cityList
:
data
,
},
()
=>
{
let
index
=
wx
.
getStorageSync
(
'city_index'
)
||
'0'
_this
.
setData
({
[
'userForms.city_name'
]:
_this
.
data
.
cityList
[
index
].
name
})
let
city_id
=
_this
.
data
.
cityList
[
index
].
id
;
let
city_name
=
_this
.
data
.
cityList
[
index
].
name
;
_this
.
setData
({
[
'userForms.city_id'
]:
city_id
,
[
'userForms.city_name'
]:
city_name
,
})
wx
.
setStorageSync
(
'city_id'
,
city_id
)
wx
.
setStorageSync
(
'city_name'
,
city_name
)
})
}
}
})
},
// 选择省份
changeProvince
:
function
(
e
)
{
let
_this
=
this
let
index
=
e
.
detail
.
value
let
parent_id
=
this
.
data
.
provinceList
[
index
].
id
this
.
getCityList
(
parent_id
,
_this
)
let
province
=
this
.
data
.
provinceList
[
index
].
name
;
let
province_id
=
this
.
data
.
provinceList
[
index
].
id
;
wx
.
setStorageSync
(
'province'
,
province
)
wx
.
setStorageSync
(
'province_id'
,
province_id
)
wx
.
setStorageSync
(
'province_index'
,
index
)
this
.
setData
({
province
:
province
,
city_index
:
'0'
},
()
=>
{
wx
.
setStorageSync
(
'city_index'
,
'0'
)
})
},
// 选择城市
changeCity
:
function
(
e
)
{
let
index
=
e
.
detail
.
value
let
city_id
=
this
.
data
.
cityList
[
index
].
id
;
let
city_name
=
this
.
data
.
cityList
[
index
].
name
;
this
.
setData
({
[
'userForms.city_id'
]:
city_id
,
[
'userForms.city_name'
]:
city_name
,
})
wx
.
setStorageSync
(
'city_id'
,
city_id
)
wx
.
setStorageSync
(
'city_name'
,
city_name
)
wx
.
setStorageSync
(
'city_index'
,
index
)
},
// 选择品牌
selectBrand
:
function
()
{
app
.
globalData
.
enter
=
'index'
wx
.
navigateTo
({
url
:
'/pages/car-select/brand'
,
})
},
// 更新值
getItem
(
item
)
{
let
_this
=
this
;
let
data
=
wx
.
getStorageSync
(
item
)
this
.
setData
({
[
'userForms.'
+
item
]:
data
?
data
:
''
},
()
=>
{
if
(
item
===
'phone'
&&
data
)
{
_this
.
setData
({
showPhoneInput
:
true
})
}
}
arr
.
push
(
data
[
key
])
}
_this
.
setData
({
provinceList
:
arr
})
}
}
})
},
// 城市列表
getCityList
:
function
(
parent_id
,
_this
)
{
wx
.
request
({
url
:
app
.
globalData
.
url
+
'assess/cities'
,
data
:
{
parent_id
},
success
:
function
(
res
)
{
if
(
res
.
data
&&
res
.
data
.
length
>
0
)
{
let
data
=
res
.
data
_this
.
setData
({
cityList
:
data
,
},
()
=>
{
let
index
=
wx
.
getStorageSync
(
'city_index'
)
||
'0'
_this
.
setData
({
[
'userForms.city_name'
]:
_this
.
data
.
cityList
[
index
].
name
})
let
city_id
=
_this
.
data
.
cityList
[
index
].
id
;
let
city_name
=
_this
.
data
.
cityList
[
index
].
name
;
_this
.
setData
({
[
'userForms.city_id'
]:
city_id
,
[
'userForms.city_name'
]:
city_name
,
})
wx
.
setStorageSync
(
'city_id'
,
city_id
)
wx
.
setStorageSync
(
'city_name'
,
city_name
)
})
}
}
})
},
// 选择省份
changeProvince
:
function
(
e
)
{
let
_this
=
this
let
index
=
e
.
detail
.
value
let
parent_id
=
this
.
data
.
provinceList
[
index
].
id
this
.
getCityList
(
parent_id
,
_this
)
let
province
=
this
.
data
.
provinceList
[
index
].
name
;
let
province_id
=
this
.
data
.
provinceList
[
index
].
id
;
wx
.
setStorageSync
(
'province'
,
province
)
wx
.
setStorageSync
(
'province_id'
,
province_id
)
wx
.
setStorageSync
(
'province_index'
,
index
)
this
.
setData
({
province
:
province
,
city_index
:
'0'
},
()
=>
{
wx
.
setStorageSync
(
'city_index'
,
'0'
)
})
},
// 选择城市
changeCity
:
function
(
e
)
{
let
index
=
e
.
detail
.
value
let
city_id
=
this
.
data
.
cityList
[
index
].
id
;
let
city_name
=
this
.
data
.
cityList
[
index
].
name
;
this
.
setData
({
[
'userForms.city_id'
]:
city_id
,
[
'userForms.city_name'
]:
city_name
,
})
wx
.
setStorageSync
(
'city_id'
,
city_id
)
wx
.
setStorageSync
(
'city_name'
,
city_name
)
wx
.
setStorageSync
(
'city_index'
,
index
)
},
// 选择品牌
selectBrand
:
function
()
{
app
.
globalData
.
enter
=
'index'
wx
.
navigateTo
({
url
:
'/pages/car-select/brand'
,
})
},
// 更新值
getItem
(
item
)
{
let
_this
=
this
;
let
data
=
wx
.
getStorageSync
(
item
)
this
.
setData
({
[
'userForms.'
+
item
]:
data
?
data
:
''
},
()
=>
{
if
(
item
===
'phone'
&&
data
)
{
_this
.
setData
({
showPhoneInput
:
true
})
})
},
}
})
},
// 选择日期
changeDate
:
function
(
e
)
{
let
time
=
e
.
detail
.
value
;
this
.
setData
({
[
'userForms.buy_time'
]:
time
})
wx
.
setStorageSync
(
'buy_time'
,
time
)
},
// 输入行驶里程
mileageInput
:
function
(
e
)
{
let
mileage
=
e
.
detail
.
value
this
.
setData
({
[
'userForms.mileage'
]:
mileage
})
wx
.
setStorageSync
(
'mileage'
,
mileage
)
},
// 输入手机号
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
({
changeDate
:
function
(
e
)
{
[
'userForms.phone'
]:
phone
let
time
=
e
.
detail
.
value
;
})
this
.
setData
({
[
'userForms.buy_time'
]:
time
// 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
:
'重新获取'
})
})
wx
.
setStorageSync
(
'buy_time'
,
time
)
}
else
{
},
_this
.
setData
({
totalTime
:
_this
.
data
.
totalTime
,
// 输入行驶里程
btnText
:
_this
.
data
.
btnText
mileageInput
:
function
(
e
)
{
let
mileage
=
e
.
detail
.
value
this
.
setData
({
[
'userForms.mileage'
]:
mileage
})
})
wx
.
setStorageSync
(
'mileage'
,
mileage
)
}
},
},
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
:
'获取失败,请稍后重试!'
})
}
})
})
// 输入手机号
},
phoneInput
:
function
(
e
)
{
let
phone
=
e
.
detail
.
value
this
.
setData
({
[
'userForms.phone'
]:
phone
})
if
(
phone
.
length
===
11
)
{
// 获取手机号
wx
.
setStorageSync
(
'phone'
,
phone
)
getPhone
:
function
(
e
)
{
let
_this
=
this
let
errMsg
=
e
.
detail
.
errMsg
if
(
errMsg
===
'getPhoneNumber:ok'
)
{
if
(
app
.
globalData
.
session_key
)
{
let
data
=
{
session_key
:
app
.
globalData
.
session_key
,
encrypted_data
:
e
.
detail
.
encryptedData
,
iv
:
e
.
detail
.
iv
,
app_id
:
app
.
globalData
.
app_id
}
}
},
wx
.
request
({
url
:
app
.
globalData
.
url
+
'decode-phone'
,
// 获取手机号
data
:
data
,
getPhone
:
function
(
e
)
{
method
:
'POST'
,
let
_this
=
this
success
:
function
(
res
)
{
let
errMsg
=
e
.
detail
.
errMsg
if
(
res
.
data
.
message
!==
'解密失败'
)
{
if
(
errMsg
===
'getPhoneNumber:ok'
)
{
let
phone
=
res
.
data
.
purePhoneNumber
if
(
app
.
globalData
.
session_key
)
{
_this
.
setData
({
let
data
=
{
[
'userForms.phone'
]:
phone
,
session_key
:
app
.
globalData
.
session_key
,
[
'userForms.pre_phone'
]:
phone
,
encrypted_data
:
e
.
detail
.
encryptedData
,
})
iv
:
e
.
detail
.
iv
,
wx
.
setStorageSync
(
'phone'
,
phone
)
app_id
:
app
.
globalData
.
app_id
}
wx
.
request
({
url
:
app
.
globalData
.
url
+
'decode-phone'
,
data
:
data
,
method
:
'POST'
,
success
:
function
(
res
)
{
if
(
res
.
data
.
message
!==
'解密失败'
)
{
let
phone
=
res
.
data
.
purePhoneNumber
_this
.
setData
({
[
'userForms.phone'
]:
phone
,
showPhoneInput
:
true
})
wx
.
setStorageSync
(
'phone'
,
phone
)
}
else
{
wx
.
showToast
({
icon
:
'none'
,
title
:
'获取失败,请稍后重试!'
})
}
}
})
}
else
{
}
else
{
_this
.
login
(
e
)
wx
.
showToast
({
icon
:
'none'
,
title
:
'获取失败,请稍后重试!'
})
}
}
}
else
if
(
errMsg
===
'getPhoneNumber:fail user deny'
)
{
}
this
.
setData
({
})
[
'userForms.phone'
]:
''
,
}
else
{
showPhoneInput
:
true
_this
.
login
(
e
)
})
}
}
}
else
if
(
errMsg
===
'getPhoneNumber:fail user deny'
)
{
},
this
.
setData
({
[
'userForms.phone'
]:
''
,
// 重新获取code
[
'userForms.pre_phone'
]:
''
,
login
:
function
(
e
)
{
})
let
_this
=
this
}
wx
.
login
({
},
// 重新获取code
login
:
function
(
e
)
{
let
_this
=
this
wx
.
login
({
success
:
function
(
res
)
{
if
(
res
.
errMsg
===
'login:ok'
)
{
let
data
=
{
code
:
res
.
code
,
app_id
:
app
.
globalData
.
app_id
}
wx
.
request
({
url
:
app
.
globalData
.
url
+
'user-code'
,
data
:
data
,
success
:
function
(
res
)
{
success
:
function
(
res
)
{
if
(
res
.
errMsg
===
'login:ok'
)
{
let
data
=
{
let
data
=
{
session_key
:
res
.
data
.
session_key
,
code
:
res
.
code
,
encrypted_data
:
e
.
detail
.
encryptedData
,
app_id
:
app
.
globalData
.
app_id
iv
:
e
.
detail
.
iv
,
}
app_id
:
app
.
globalData
.
app_id
wx
.
request
({
}
url
:
app
.
globalData
.
url
+
'user-code'
,
wx
.
request
({
data
:
data
,
url
:
app
.
globalData
.
url
+
'decode-phone'
,
success
:
function
(
res
)
{
data
:
data
,
let
data
=
{
method
:
'POST'
,
session_key
:
res
.
data
.
session_key
,
success
:
function
(
res
)
{
encrypted_data
:
e
.
detail
.
encryptedData
,
if
(
res
.
data
.
message
!==
'解密失败'
)
{
iv
:
e
.
detail
.
iv
,
let
phone
=
res
.
data
.
purePhoneNumber
app_id
:
app
.
globalData
.
app_id
_this
.
setData
({
}
[
'userForms.phone'
]:
phone
,
wx
.
request
({
[
'userForms.pre_phone'
]:
phone
,
url
:
app
.
globalData
.
url
+
'decode-phone'
,
data
:
data
,
method
:
'POST'
,
success
:
function
(
res
)
{
if
(
res
.
data
.
message
!==
'解密失败'
)
{
let
phone
=
res
.
data
.
purePhoneNumber
_this
.
setData
({
[
'userForms.phone'
]:
phone
,
showPhoneInput
:
true
})
wx
.
setStorageSync
(
'phone'
,
phone
)
}
else
{
wx
.
showToast
({
icon
:
'none'
,
title
:
'获取失败,请稍后重试!'
})
}
}
})
}
})
})
wx
.
setStorageSync
(
'phone'
,
phone
)
}
else
{
wx
.
showToast
({
icon
:
'none'
,
title
:
'获取失败,请稍后重试!'
})
}
}
}
})
}
}
})
})
},
// 检测是否为空
checkValue
:
function
()
{
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
;
}
}
}
})
},
// 检测是否为空
checkValue
:
function
()
{
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
;
}
this
.
terminalAvailable
(
app
.
globalData
.
tiantianpaiche_cityList
,
'天天拍车'
);
if
(
!
this
.
data
.
inputSmsCode
)
{
wx
.
showToast
({
let
terminal_length
=
this
.
data
.
terminal_names
.
length
;
icon
:
'none'
,
let
kaixun_terminal_index
=
this
.
data
.
terminal_names
.
indexOf
(
'上海铠寻'
);
title
:
'请输入短信验证码!'
})
return
false
;
}
if
(
this
.
data
.
userForms
.
city_name
===
'上海'
&&
kaixun_terminal_index
<
0
)
{
if
((
this
.
data
.
inputSmsCode
!=
this
.
data
.
smsCode
))
{
this
.
data
.
terminal_names
[
terminal_length
]
=
'上海铠寻'
wx
.
showToast
({
}
else
if
(
this
.
data
.
userForms
.
city_name
!==
'上海'
&&
kaixun_terminal_index
>
0
)
{
icon
:
'none'
,
this
.
data
.
terminal_names
.
splice
(
kaixun_terminal_index
,
1
);
title
:
'短信验证码不正确!'
}
})
return
false
;
}
this
.
terminalAvailable
(
app
.
globalData
.
chezhibao_cityList
,
'车置宝
'
);
this
.
terminalAvailable
(
app
.
globalData
.
tiantianpaiche_cityList
,
'天天拍车
'
);
this
.
terminalAvailable
(
app
.
globalData
.
renrenche_cityList
,
'人人车'
);
let
terminal_length
=
this
.
data
.
terminal_names
.
length
;
let
kaixun_terminal_index
=
this
.
data
.
terminal_names
.
indexOf
(
'上海铠寻'
);
return
true
;
if
(
this
.
data
.
userForms
.
city_name
===
'上海'
&&
kaixun_terminal_index
<
0
)
{
},
this
.
data
.
terminal_names
[
terminal_length
]
=
'上海铠寻'
}
else
if
(
this
.
data
.
userForms
.
city_name
!==
'上海'
&&
kaixun_terminal_index
>
0
)
{
this
.
data
.
terminal_names
.
splice
(
kaixun_terminal_index
,
1
);
}
// 城市是否覆盖 是否选择推送
this
.
terminalAvailable
(
app
.
globalData
.
chezhibao_cityList
,
'车置宝'
);
terminalAvailable
:
function
(
cityList
,
name
)
{
let
terminal_length
=
this
.
data
.
terminal_names
.
length
;
let
index
=
cityList
.
indexOf
(
this
.
data
.
userForms
.
city_name
);
let
terminal_index
=
this
.
data
.
terminal_names
.
indexOf
(
name
);
if
(
index
<
0
&&
terminal_index
>
-
1
)
{
this
.
terminalAvailable
(
app
.
globalData
.
renrenche_cityList
,
'人人车'
);
this
.
data
.
terminal_names
.
splice
(
terminal_index
,
1
);
}
else
if
(
index
>
-
1
&&
terminal_index
<
0
)
{
this
.
data
.
terminal_names
[
terminal_length
]
=
name
}
},
// 估价
return
true
;
submit
:
function
()
{
},
let
_this
=
this
;
if
(
this
.
checkValue
())
{
wx
.
showLoading
({
title
:
'估价中'
,
mask
:
true
})
_this
.
data
.
terminal_names
.
push
(
'瓜子二手车'
,
'精真估'
)
_this
.
setData
({
terminal_names
:
_this
.
data
.
terminal_names
},
()
=>
{
_this
.
storeCar
();
})
}
},
// 存储车
// 城市是否覆盖 是否选择推送
storeCar
:
function
()
{
terminalAvailable
:
function
(
cityList
,
name
)
{
let
_this
=
this
;
let
terminal_length
=
this
.
data
.
terminal_names
.
length
;
wx
.
request
({
let
index
=
cityList
.
indexOf
(
this
.
data
.
userForms
.
city_name
);
url
:
app
.
globalData
.
url
+
'cars'
,
let
terminal_index
=
this
.
data
.
terminal_names
.
indexOf
(
name
);
method
:
'POST'
,
data
:
_this
.
data
.
userForms
,
success
:
function
(
res
)
{
let
data
=
res
.
data
;
if
(
data
.
message
===
'ok'
)
{
let
carInfo
=
data
.
data
;
wx
.
setStorageSync
(
'carInfo'
,
carInfo
)
let
created_at
=
new
Date
(
carInfo
.
created_at
).
getTime
()
if
(
Date
.
now
()
-
created_at
<
3000
)
{
// 新车
_this
.
sellCar
();
}
else
{
// 已存在
_this
.
evaluate
();
}
}
else
{
wx
.
showToast
({
icon
:
'none'
,
title
:
'请求错误,请稍后重试!'
})
}
},
fail
:
function
()
{
wx
.
showToast
({
icon
:
'none'
,
title
:
'请求错误,请稍后重试!'
})
},
complete
:
function
()
{}
})
},
// 卖车接口
if
(
index
<
0
&&
terminal_index
>
-
1
)
{
sellCar
:
function
()
{
this
.
data
.
terminal_names
.
splice
(
terminal_index
,
1
);
let
_this
=
this
;
}
else
if
(
index
>
-
1
&&
terminal_index
<
0
)
{
wx
.
request
({
this
.
data
.
terminal_names
[
terminal_length
]
=
name
url
:
app
.
globalData
.
url
+
'distributions/push-to-terminals'
,
}
data
:
{
},
car_id
:
wx
.
getStorageSync
(
'carInfo'
).
id
,
terminal_names
:
this
.
data
.
terminal_names
// 估价
},
submit
:
function
()
{
method
:
"POST"
,
let
_this
=
this
;
success
:
function
(
res
)
{
if
(
this
.
checkValue
())
{
if
(
res
.
data
.
message
===
'ok'
)
{
wx
.
showLoading
({
_this
.
evaluate
();
title
:
'估价中'
,
}
else
{
mask
:
true
wx
.
showToast
({
})
icon
:
'none'
,
_this
.
data
.
terminal_names
.
push
(
'瓜子二手车'
,
'精真估'
)
title
:
'请求错误,请稍后重试!'
_this
.
setData
({
})
terminal_names
:
_this
.
data
.
terminal_names
}
},
()
=>
{
},
_this
.
storeCar
();
fail
:
function
()
{
})
wx
.
showToast
({
}
icon
:
'none'
,
},
title
:
'请求错误,请稍后重试!'
})
// 存储车
},
storeCar
:
function
()
{
complete
:
function
()
{}
let
_this
=
this
;
wx
.
request
({
url
:
app
.
globalData
.
url
+
'cars'
,
method
:
'POST'
,
data
:
_this
.
data
.
userForms
,
success
:
function
(
res
)
{
let
data
=
res
.
data
;
if
(
data
.
message
===
'ok'
)
{
let
carInfo
=
data
.
data
;
wx
.
setStorageSync
(
'carInfo'
,
carInfo
)
let
created_at
=
new
Date
(
carInfo
.
created_at
).
getTime
()
if
(
Date
.
now
()
-
created_at
<
3000
)
{
// 新车
_this
.
sellCar
();
}
else
{
// 已存在
_this
.
evaluate
();
}
}
else
{
wx
.
showToast
({
icon
:
'none'
,
title
:
'请求错误,请稍后重试!'
})
}
},
fail
:
function
()
{
wx
.
showToast
({
icon
:
'none'
,
title
:
'请求错误,请稍后重试!'
})
})
},
},
complete
:
function
()
{}
// 估值接口
})
evaluate
:
function
()
{
},
let
_this
=
this
;
let
model_id
=
this
.
data
.
userForms
.
specification_id
;
// 卖车接口
let
city_id
=
this
.
data
.
userForms
.
city_id
;
sellCar
:
function
()
{
let
data
=
{
let
_this
=
this
;
model_id
,
wx
.
request
({
road_haul
:
this
.
data
.
userForms
.
mileage
*
10000
,
url
:
app
.
globalData
.
url
+
'distributions/push-to-terminals'
,
license_year
:
this
.
data
.
userForms
.
buy_time
.
substr
(
0
,
4
),
data
:
{
license_month
:
this
.
data
.
userForms
.
buy_time
.
substr
(
5
,
2
),
car_id
:
wx
.
getStorageSync
(
'carInfo'
).
id
,
city_id
,
terminal_names
:
this
.
data
.
terminal_names
key
:
'lc0710'
,
},
sign
:
md5
(
model_id
+
''
+
city_id
+
'aespol'
).
toLowerCase
()
method
:
"POST"
,
success
:
function
(
res
)
{
if
(
res
.
data
.
message
===
'ok'
)
{
_this
.
evaluate
();
}
else
{
wx
.
showToast
({
icon
:
'none'
,
title
:
'请求错误,请稍后重试!'
})
}
}
wx
.
request
({
},
url
:
app
.
globalData
.
url
+
'assess/assess'
,
fail
:
function
()
{
data
:
data
,
wx
.
showToast
({
success
:
function
(
res
)
{
icon
:
'none'
,
if
(
res
.
data
.
message
!==
'估值失败'
)
{
title
:
'请求错误,请稍后重试!'
let
data
=
res
.
data
;
wx
.
setStorageSync
(
'valuation'
,
data
)
app
.
globalData
.
result
=
'result'
wx
.
navigateTo
({
url
:
'/pages/result/result'
,
})
}
else
{
wx
.
showToast
({
icon
:
'none'
,
title
:
'未查询到结果!'
})
}
},
fail
:
function
()
{
wx
.
showToast
({
icon
:
'none'
,
title
:
'请求错误,请稍后重试!'
})
},
complete
:
function
()
{
}
})
})
},
},
complete
:
function
()
{}
// 分享
})
onShareAppMessage
:
function
()
{
},
return
{
title
:
"爱车估值"
,
// 估值接口
path
:
"/pages/index/index"
evaluate
:
function
()
{
};
let
_this
=
this
;
let
model_id
=
this
.
data
.
userForms
.
specification_id
;
let
city_id
=
this
.
data
.
userForms
.
city_id
;
let
data
=
{
model_id
,
road_haul
:
this
.
data
.
userForms
.
mileage
*
10000
,
license_year
:
this
.
data
.
userForms
.
buy_time
.
substr
(
0
,
4
),
license_month
:
this
.
data
.
userForms
.
buy_time
.
substr
(
5
,
2
),
city_id
,
key
:
'lc0710'
,
sign
:
md5
(
model_id
+
''
+
city_id
+
'aespol'
).
toLowerCase
()
}
}
wx
.
request
({
url
:
app
.
globalData
.
url
+
'assess/assess'
,
data
:
data
,
success
:
function
(
res
)
{
if
(
res
.
data
.
message
!==
'估值失败'
)
{
let
data
=
res
.
data
;
wx
.
setStorageSync
(
'valuation'
,
data
)
app
.
globalData
.
result
=
'result'
wx
.
navigateTo
({
url
:
'/pages/result/result'
,
})
}
else
{
wx
.
showToast
({
icon
:
'none'
,
title
:
'未查询到结果!'
})
}
},
fail
:
function
()
{
wx
.
showToast
({
icon
:
'none'
,
title
:
'请求错误,请稍后重试!'
})
},
complete
:
function
()
{
}
})
},
// 分享
onShareAppMessage
:
function
()
{
return
{
title
:
"爱车估值"
,
path
:
"/pages/index/index"
};
}
})
})
\ No newline at end of file
pages/index/index.wxml
View file @
b1c88250
...
@@ -68,6 +68,17 @@
...
@@ -68,6 +68,17 @@
<button bindgetphonenumber="getPhone" id="get-phone" openType="getPhoneNumber" size="mini" type="primary" wx:else>11位手机号</button> -->
<button bindgetphonenumber="getPhone" id="get-phone" openType="getPhoneNumber" size="mini" type="primary" wx:else>11位手机号</button> -->
</view>
</view>
</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>
</view>
<view class="weui-cell submit-section">
<view class="weui-cell submit-section">
...
...
pages/index/index.wxss
View file @
b1c88250
...
@@ -139,4 +139,21 @@ page {
...
@@ -139,4 +139,21 @@ page {
.weui-input {
.weui-input {
color: #39424D;
color: #39424D;
text-align: right;
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
...
@@ -3,593 +3,761 @@ const utils = require('../../utils/util.js')
...
@@ -3,593 +3,761 @@ const utils = require('../../utils/util.js')
Page
({
Page
({
data
:
{
data
:
{
userForms
:
{
userForms
:
{
link
:
app
.
globalData
.
link
,
link
:
app
.
globalData
.
link
,
specification_id
:
''
,
specification_id
:
''
,
specification_name
:
''
,
specification_name
:
''
,
buy_time
:
''
,
buy_time
:
''
,
mileage
:
''
,
mileage
:
''
,
city_id
:
''
,
city_id
:
''
,
city_name
:
''
,
city_name
:
''
,
phone
:
''
phone
:
''
,
},
pre_phone
:
''
startTime
:
''
,
endTime
:
''
,
provinceList
:
[],
province
:
''
,
province_index
:
''
,
cityList
:
[],
city_index
:
''
,
showPhoneInput
:
false
,
isShow
:
false
,
collapseText
:
'展开'
,
valuation
:
{},
carInfo
:
{},
terminal_names
:
[],
partner
:
[{
id
:
0
,
logo
:
'../../images/shop_tiantianpaiche.png'
,
name
:
'天天拍车'
,
selected
:
true
,
des
:
'全国性二手车竞拍平台,买家在线竞拍,覆盖全国50多个主要城市,免费上门检测,最快一天成交!'
},
{
id
:
1
,
logo
:
'../../images/shop_guazi.png'
,
name
:
'瓜子二手车'
,
selected
:
true
,
des
:
'提供保卖服务。专注个人二手车交易,个人卖主直接把车卖给个人买家!'
},
{
id
:
2
,
logo
:
'../../images/shop_chezhibao.png'
,
name
:
'车置宝'
,
selected
:
true
,
des
:
'一个专注收车的网站。通过全业务流程大数据驱动,可以提供免费上门检测服务。即日起在车置宝成功卖车,最高可享20000元卖车补贴。'
},
{
id
:
3
,
logo
:
'../../images/shop_renrenche.png'
,
name
:
'人人车'
,
selected
:
true
,
des
:
'全程免费帮卖,免费上门评估,边开边卖,代办过户!最高多卖20%!'
}
],
},
},
inputSmsCode
:
''
,
onShow
:
function
()
{
smsCode
:
''
,
let
_this
=
this
disabled
:
false
,
this
.
setData
({
totalTime
:
120
,
provinceList
:
app
.
globalData
.
provinceList
,
timer
:
null
,
province_index
:
wx
.
getStorageSync
(
'province_index'
),
btnText
:
'获取验证码'
,
city_index
:
wx
.
getStorageSync
(
'city_index'
)
},
()
=>
{
startTime
:
''
,
if
(
_this
.
data
.
provinceList
.
length
===
0
)
{
endTime
:
''
,
_this
.
getProvinceList
()
provinceList
:
[],
}
else
{
province
:
''
,
let
index
=
wx
.
getStorageSync
(
'province_index'
)
province_index
:
''
,
let
id
=
wx
.
getStorageSync
(
'province_id'
)
cityList
:
[],
if
(
index
)
{
city_index
:
''
,
_this
.
setData
({
showPhoneInput
:
false
,
province
:
_this
.
data
.
provinceList
[
index
].
name
})
isShow
:
false
,
_this
.
getCityList
(
id
,
_this
)
collapseText
:
'展开'
,
}
valuation
:
{},
}
carInfo
:
{},
})
terminal_names
:
[],
let
years
=
wx
.
getStorageSync
(
'years'
)
partner
:
[{
let
startTime
,
endTime
id
:
0
,
if
(
years
.
length
>
4
)
{
logo
:
'../../images/shop_tiantianpaiche.png'
,
startTime
=
years
.
substr
(
0
,
4
)
name
:
'天天拍车'
,
endTime
=
years
.
substr
(
-
4
,
4
)
selected
:
true
,
let
today
=
utils
.
formatDate
(
new
Date
())
des
:
'全国性二手车竞拍平台,买家在线竞拍,覆盖全国50多个主要城市,免费上门检测,最快一天成交!'
if
(
today
.
indexOf
(
endTime
)
>
-
1
)
{
},
endTime
=
today
{
}
else
{
id
:
1
,
endTime
=
endTime
+
'-12-31'
logo
:
'../../images/shop_guazi.png'
,
name
:
'瓜子二手车'
,
selected
:
true
,
des
:
'提供保卖服务。专注个人二手车交易,个人卖主直接把车卖给个人买家!'
},
{
id
:
2
,
logo
:
'../../images/shop_chezhibao.png'
,
name
:
'车置宝'
,
selected
:
true
,
des
:
'一个专注收车的网站。通过全业务流程大数据驱动,可以提供免费上门检测服务。即日起在车置宝成功卖车,最高可享20000元卖车补贴。'
},
{
id
:
3
,
logo
:
'../../images/shop_renrenche.png'
,
name
:
'人人车'
,
selected
:
true
,
des
:
'全程免费帮卖,免费上门评估,边开边卖,代办过户!最高多卖20%!'
}
],
},
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'
),
inputSmsCode
:
''
,
smsCode
:
''
,
disabled
:
false
,
totalTime
:
120
,
timer
:
null
,
btnText
:
'获取验证码'
},
()
=>
{
if
(
_this
.
data
.
provinceList
.
length
===
0
)
{
_this
.
getProvinceList
()
}
else
{
let
index
=
wx
.
getStorageSync
(
'province_index'
)
let
id
=
wx
.
getStorageSync
(
'province_id'
)
if
(
index
)
{
_this
.
setData
({
province
:
_this
.
data
.
provinceList
[
index
].
name
})
_this
.
getCityList
(
id
,
_this
)
}
}
})
let
years
=
wx
.
getStorageSync
(
'years'
)
let
startTime
,
endTime
if
(
years
.
length
>
4
)
{
startTime
=
years
.
substr
(
0
,
4
)
endTime
=
years
.
substr
(
-
4
,
4
)
let
today
=
utils
.
formatDate
(
new
Date
())
if
(
today
.
indexOf
(
endTime
)
>
-
1
)
{
endTime
=
today
}
else
{
endTime
=
endTime
+
'-12-31'
}
this
.
setData
({
startTime
:
startTime
+
'-01-01'
,
endTime
:
endTime
})
}
this
.
data
.
terminal_names
=
this
.
data
.
partner
.
map
(
item
=>
item
.
name
)
this
.
getItem
(
'specification_id'
)
this
.
getItem
(
'specification_name'
)
this
.
getItem
(
'city_id'
)
this
.
getItem
(
'city_name'
)
this
.
getItem
(
'buy_time'
)
this
.
getItem
(
'mileage'
)
this
.
getItem
(
'phone'
)
let
province
=
wx
.
getStorageSync
(
'province'
)
this
.
setData
({
province
:
province
?
province
:
''
})
},
// 获取省份
getProvinceList
:
function
()
{
let
_this
=
this
;
wx
.
request
({
url
:
app
.
globalData
.
url
+
'assess/provinces'
,
success
:
function
(
res
)
{
if
(
res
.
data
&&
res
.
data
.
length
>
0
)
{
let
data
=
res
.
data
let
arr
=
[]
for
(
let
key
in
data
)
{
if
(
data
[
key
].
id
===
32
)
{
continue
}
}
this
.
setData
({
arr
.
push
(
data
[
key
])
startTime
:
startTime
+
'-01-01'
,
}
endTime
:
endTime
_this
.
setData
({
provinceList
:
arr
})
}
}
})
},
// 城市列表
getCityList
:
function
(
parent_id
,
_this
)
{
wx
.
request
({
url
:
app
.
globalData
.
url
+
'assess/cities'
,
data
:
{
parent_id
},
success
:
function
(
res
)
{
if
(
res
.
errMsg
===
'request:ok'
)
{
let
data
=
res
.
data
_this
.
setData
({
cityList
:
data
,
},
()
=>
{
let
index
=
wx
.
getStorageSync
(
'city_index'
)
||
'0'
_this
.
setData
({
[
'userForms.city_name'
]:
_this
.
data
.
cityList
[
index
].
name
})
let
city_id
=
_this
.
data
.
cityList
[
index
].
id
;
let
city_name
=
_this
.
data
.
cityList
[
index
].
name
;
_this
.
setData
({
[
'userForms.city_id'
]:
city_id
,
[
'userForms.city_name'
]:
city_name
,
})
})
wx
.
setStorageSync
(
'city_id'
,
city_id
)
wx
.
setStorageSync
(
'city_name'
,
city_name
)
})
}
}
this
.
data
.
terminal_names
=
this
.
data
.
partner
.
map
(
item
=>
item
.
name
)
}
})
this
.
getItem
(
'specification_id'
)
},
this
.
getItem
(
'specification_name'
)
this
.
getItem
(
'city_id'
)
// 选择省份
this
.
getItem
(
'city_name'
)
changeProvince
:
function
(
e
)
{
this
.
getItem
(
'buy_time'
)
let
_this
=
this
this
.
getItem
(
'mileage'
)
let
index
=
e
.
detail
.
value
this
.
getItem
(
'phone'
)
let
parent_id
=
this
.
data
.
provinceList
[
index
].
id
this
.
getCityList
(
parent_id
,
_this
)
let
province
=
wx
.
getStorageSync
(
'province'
)
let
province
=
this
.
data
.
provinceList
[
index
].
name
;
this
.
setData
({
let
province_id
=
this
.
data
.
provinceList
[
index
].
id
;
province
:
province
?
province
:
''
wx
.
setStorageSync
(
'province'
,
province
)
wx
.
setStorageSync
(
'province_id'
,
province_id
)
wx
.
setStorageSync
(
'province_index'
,
index
)
this
.
setData
({
province
:
province
,
city_index
:
'0'
},
()
=>
{
wx
.
setStorageSync
(
'city_index'
,
'0'
)
})
},
// 选择城市
changeCity
:
function
(
e
)
{
let
index
=
e
.
detail
.
value
let
city_id
=
this
.
data
.
cityList
[
index
].
id
;
let
city_name
=
this
.
data
.
cityList
[
index
].
name
;
this
.
setData
({
[
'userForms.city_id'
]:
city_id
,
[
'userForms.city_name'
]:
city_name
,
})
wx
.
setStorageSync
(
'city_id'
,
city_id
)
wx
.
setStorageSync
(
'city_name'
,
city_name
)
wx
.
setStorageSync
(
'city_index'
,
index
)
},
// 选择品牌
selectBrand
:
function
()
{
app
.
globalData
.
enter
=
'sell-car'
wx
.
navigateTo
({
url
:
'/pages/car-select/brand'
,
})
},
// 更新值
getItem
(
item
)
{
let
_this
=
this
;
let
data
=
wx
.
getStorageSync
(
item
)
this
.
setData
({
[
'userForms.'
+
item
]:
data
?
data
:
''
},
()
=>
{
if
(
item
===
'phone'
&&
data
)
{
_this
.
setData
({
showPhoneInput
:
true
})
})
}
})
},
// 选择日期
changeDate
:
function
(
e
)
{
let
time
=
e
.
detail
.
value
;
this
.
setData
({
[
'userForms.buy_time'
]:
time
})
wx
.
setStorageSync
(
'buy_time'
,
time
)
},
// 输入行驶里程
mileageInput
:
function
(
e
)
{
let
mileage
=
e
.
detail
.
value
this
.
setData
({
[
'userForms.mileage'
]:
mileage
})
wx
.
setStorageSync
(
'mileage'
,
mileage
)
},
// 输入手机号
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
// 获取省份
})
getProvinceList
:
function
()
{
let
_this
=
this
;
// 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
)
{
let
_this
=
this
let
errMsg
=
e
.
detail
.
errMsg
if
(
errMsg
===
'getPhoneNumber:ok'
)
{
if
(
app
.
globalData
.
session_key
)
{
let
data
=
{
session_key
:
app
.
globalData
.
session_key
,
encrypted_data
:
e
.
detail
.
encryptedData
,
iv
:
e
.
detail
.
iv
,
app_id
:
app
.
globalData
.
app_id
}
wx
.
request
({
wx
.
request
({
url
:
app
.
globalData
.
url
+
'assess/provinces'
,
url
:
app
.
globalData
.
url
+
'decode-phone'
,
success
:
function
(
res
)
{
data
:
data
,
if
(
res
.
data
&&
res
.
data
.
length
>
0
)
{
method
:
'POST'
,
let
data
=
res
.
data
success
:
function
(
res
)
{
let
arr
=
[]
if
(
res
.
data
.
message
!==
'解密失败'
)
{
for
(
let
key
in
data
)
{
let
phone
=
res
.
data
.
purePhoneNumber
if
(
data
[
key
].
id
===
32
)
{
_this
.
setData
({
continue
[
'userForms.phone'
]:
phone
,
}
[
'userForms.pre_phone'
]:
phone
,
arr
.
push
(
data
[
key
])
})
}
wx
.
setStorageSync
(
'phone'
,
phone
)
_this
.
setData
({
}
else
{
provinceList
:
arr
wx
.
showToast
({
})
icon
:
'none'
,
}
title
:
'获取失败,请稍后重试!'
})
}
}
}
})
})
},
}
else
{
_this
.
login
(
e
)
// 城市列表
}
getCityList
:
function
(
parent_id
,
_this
)
{
}
else
if
(
errMsg
===
'getPhoneNumber:fail user deny'
)
{
wx
.
request
({
this
.
setData
({
url
:
app
.
globalData
.
url
+
'assess/cities'
,
[
'userForms.phone'
]:
''
,
data
:
{
[
'userForms.pre_phone'
]:
''
,
parent_id
})
},
}
success
:
function
(
res
)
{
},
if
(
res
.
errMsg
===
'request:ok'
)
{
let
data
=
res
.
data
// 重新获取code
login
:
function
(
e
)
{
let
_this
=
this
wx
.
login
({
success
:
function
(
res
)
{
if
(
res
.
errMsg
===
'login:ok'
)
{
let
data
=
{
code
:
res
.
code
,
app_id
:
app
.
globalData
.
app_id
}
wx
.
request
({
url
:
app
.
globalData
.
url
+
'user-code'
,
data
:
data
,
success
:
function
(
res
)
{
let
data
=
{
session_key
:
res
.
data
.
session_key
,
encrypted_data
:
e
.
detail
.
encryptedData
,
iv
:
e
.
detail
.
iv
,
app_id
:
app
.
globalData
.
app_id
}
wx
.
request
({
url
:
app
.
globalData
.
url
+
'decode-phone'
,
data
:
data
,
method
:
'POST'
,
success
:
function
(
res
)
{
if
(
res
.
data
.
message
!==
'解密失败'
)
{
let
phone
=
res
.
data
.
purePhoneNumber
_this
.
setData
({
_this
.
setData
({
cityList
:
data
,
[
'userForms.phone'
]:
phone
,
},
()
=>
{
[
'userForms.pre_phone'
]:
phone
,
let
index
=
wx
.
getStorageSync
(
'city_index'
)
||
'0'
_this
.
setData
({
[
'userForms.city_name'
]:
_this
.
data
.
cityList
[
index
].
name
})
let
city_id
=
_this
.
data
.
cityList
[
index
].
id
;
let
city_name
=
_this
.
data
.
cityList
[
index
].
name
;
_this
.
setData
({
[
'userForms.city_id'
]:
city_id
,
[
'userForms.city_name'
]:
city_name
,
})
wx
.
setStorageSync
(
'city_id'
,
city_id
)
wx
.
setStorageSync
(
'city_name'
,
city_name
)
})
})
wx
.
setStorageSync
(
'phone'
,
phone
)
}
else
{
wx
.
showToast
({
icon
:
'none'
,
title
:
'获取失败,请稍后重试!'
})
}
}
}
})
}
}
})
})
},
// 选择省份
changeProvince
:
function
(
e
)
{
let
_this
=
this
let
index
=
e
.
detail
.
value
let
parent_id
=
this
.
data
.
provinceList
[
index
].
id
this
.
getCityList
(
parent_id
,
_this
)
let
province
=
this
.
data
.
provinceList
[
index
].
name
;
let
province_id
=
this
.
data
.
provinceList
[
index
].
id
;
wx
.
setStorageSync
(
'province'
,
province
)
wx
.
setStorageSync
(
'province_id'
,
province_id
)
wx
.
setStorageSync
(
'province_index'
,
index
)
this
.
setData
({
province
:
province
,
city_index
:
'0'
},
()
=>
{
wx
.
setStorageSync
(
'city_index'
,
'0'
)
})
},
// 选择城市
changeCity
:
function
(
e
)
{
let
index
=
e
.
detail
.
value
let
city_id
=
this
.
data
.
cityList
[
index
].
id
;
let
city_name
=
this
.
data
.
cityList
[
index
].
name
;
this
.
setData
({
[
'userForms.city_id'
]:
city_id
,
[
'userForms.city_name'
]:
city_name
,
})
wx
.
setStorageSync
(
'city_id'
,
city_id
)
wx
.
setStorageSync
(
'city_name'
,
city_name
)
wx
.
setStorageSync
(
'city_index'
,
index
)
},
// 选择品牌
selectBrand
:
function
()
{
app
.
globalData
.
enter
=
'sell-car'
wx
.
navigateTo
({
url
:
'/pages/car-select/brand'
,
})
},
// 更新值
getItem
(
item
)
{
let
_this
=
this
;
let
data
=
wx
.
getStorageSync
(
item
)
this
.
setData
({
[
'userForms.'
+
item
]:
data
?
data
:
''
},
()
=>
{
if
(
item
===
'phone'
&&
data
)
{
_this
.
setData
({
showPhoneInput
:
true
})
}
})
},
// 选择日期
changeDate
:
function
(
e
)
{
let
time
=
e
.
detail
.
value
;
this
.
setData
({
[
'userForms.buy_time'
]:
time
})
wx
.
setStorageSync
(
'buy_time'
,
time
)
},
// 输入行驶里程
mileageInput
:
function
(
e
)
{
let
mileage
=
e
.
detail
.
value
this
.
setData
({
[
'userForms.mileage'
]:
mileage
})
wx
.
setStorageSync
(
'mileage'
,
mileage
)
},
// 输入手机号
phoneInput
:
function
(
e
)
{
let
phone
=
e
.
detail
.
value
this
.
setData
({
[
'userForms.phone'
]:
phone
})
if
(
phone
.
length
===
11
)
{
wx
.
setStorageSync
(
'phone'
,
phone
)
}
}
},
}
})
// 获取手机号
},
getPhone
:
function
(
e
)
{
let
_this
=
this
// 是否勾选
let
errMsg
=
e
.
detail
.
errMsg
handleSelect
:
function
(
e
)
{
if
(
errMsg
===
'getPhoneNumber:ok'
)
{
let
index
=
e
.
currentTarget
.
dataset
.
index
;
if
(
app
.
globalData
.
session_key
)
{
let
selected
=
e
.
currentTarget
.
dataset
.
selected
;
let
data
=
{
session_key
:
app
.
globalData
.
session_key
,
let
item
=
'partner['
+
index
+
'].selected'
;
encrypted_data
:
e
.
detail
.
encryptedData
,
this
.
setData
({
iv
:
e
.
detail
.
iv
,
[
item
]:
!
selected
app_id
:
app
.
globalData
.
app_id
},
()
=>
{
}
let
list
=
[]
wx
.
request
({
for
(
let
key
in
this
.
data
.
partner
)
{
url
:
app
.
globalData
.
url
+
'decode-phone'
,
let
item
=
this
.
data
.
partner
[
key
]
data
:
data
,
if
(
item
.
selected
)
{
method
:
'POST'
,
list
.
push
(
item
.
name
)
success
:
function
(
res
)
{
if
(
res
.
data
.
message
!==
'解密失败'
)
{
let
phone
=
res
.
data
.
purePhoneNumber
_this
.
setData
({
[
'userForms.phone'
]:
phone
,
})
wx
.
setStorageSync
(
'phone'
,
phone
)
}
else
{
wx
.
showToast
({
icon
:
'none'
,
title
:
'获取失败,请稍后重试!'
})
}
}
})
}
else
{
_this
.
login
(
e
)
}
}
else
if
(
errMsg
===
'getPhoneNumber:fail user deny'
)
{
this
.
setData
({
[
'userForms.phone'
]:
''
,
showPhoneInput
:
true
})
}
}
},
}
this
.
setData
({
// 重新获取code
terminal_names
:
list
login
:
function
(
e
)
{
})
let
_this
=
this
})
wx
.
login
({
},
success
:
function
(
res
)
{
if
(
res
.
errMsg
===
'login:ok'
)
{
// 是否展示
let
data
=
{
showCollapse
:
function
()
{
code
:
res
.
code
,
this
.
setData
({
app_id
:
app
.
globalData
.
app_id
isShow
:
!
this
.
data
.
isShow
}
},
()
=>
{
wx
.
request
({
if
(
this
.
data
.
isShow
)
{
url
:
app
.
globalData
.
url
+
'user-code'
,
data
:
data
,
success
:
function
(
res
)
{
let
data
=
{
session_key
:
res
.
data
.
session_key
,
encrypted_data
:
e
.
detail
.
encryptedData
,
iv
:
e
.
detail
.
iv
,
app_id
:
app
.
globalData
.
app_id
}
wx
.
request
({
url
:
app
.
globalData
.
url
+
'decode-phone'
,
data
:
data
,
method
:
'POST'
,
success
:
function
(
res
)
{
if
(
res
.
data
.
message
!==
'解密失败'
)
{
let
phone
=
res
.
data
.
purePhoneNumber
_this
.
setData
({
[
'userForms.phone'
]:
phone
,
})
wx
.
setStorageSync
(
'phone'
,
phone
)
}
else
{
wx
.
showToast
({
icon
:
'none'
,
title
:
'获取失败,请稍后重试!'
})
}
}
})
}
})
}
}
})
},
// 是否勾选
handleSelect
:
function
(
e
)
{
let
index
=
e
.
currentTarget
.
dataset
.
index
;
let
selected
=
e
.
currentTarget
.
dataset
.
selected
;
let
item
=
'partner['
+
index
+
'].selected'
;
this
.
setData
({
this
.
setData
({
[
item
]:
!
selected
collapseText
:
'收起'
},
()
=>
{
let
list
=
[]
for
(
let
key
in
this
.
data
.
partner
)
{
let
item
=
this
.
data
.
partner
[
key
]
if
(
item
.
selected
)
{
list
.
push
(
item
.
name
)
}
}
this
.
setData
({
terminal_names
:
list
})
})
})
},
}
else
{
// 是否展示
showCollapse
:
function
()
{
this
.
setData
({
this
.
setData
({
isShow
:
!
this
.
data
.
isShow
collapseText
:
'展开'
},
()
=>
{
if
(
this
.
data
.
isShow
)
{
this
.
setData
({
collapseText
:
'收起'
})
}
else
{
this
.
setData
({
collapseText
:
'展开'
})
}
})
})
},
}
})
},
// 检测是否为空
checkValue
:
function
()
{
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
;
}
// 检测是否为空
if
(
!
this
.
data
.
inputSmsCode
)
{
checkValue
:
function
()
{
wx
.
showToast
({
if
(
!
this
.
data
.
userForms
.
specification_name
)
{
icon
:
'none'
,
wx
.
showToast
({
title
:
'请输入短信验证码!'
icon
:
'none'
,
})
title
:
'请选择车型!'
return
false
;
})
}
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
;
}
if
(
this
.
data
.
terminal_names
.
length
===
0
)
{
if
((
this
.
data
.
inputSmsCode
!=
this
.
data
.
smsCode
)
)
{
wx
.
showToast
({
wx
.
showToast
({
icon
:
'none'
,
icon
:
'none'
,
title
:
'至少选择一个卖车平台
!'
title
:
'短信验证码不正确
!'
})
})
return
false
;
return
false
;
}
}
this
.
terminalAvailable
(
app
.
globalData
.
tiantianpaiche_cityList
,
'天天拍车'
);
if
(
this
.
data
.
terminal_names
.
length
===
0
)
{
wx
.
showToast
({
icon
:
'none'
,
title
:
'至少选择一个卖车平台!'
})
return
false
;
}
let
terminal_length
=
this
.
data
.
terminal_names
.
length
;
this
.
terminalAvailable
(
app
.
globalData
.
tiantianpaiche_cityList
,
'天天拍车'
);
let
kaixun_terminal_index
=
this
.
data
.
terminal_names
.
indexOf
(
'上海铠寻'
);
if
(
this
.
data
.
userForms
.
city_name
===
'上海'
&&
kaixun_terminal_index
<
0
)
{
let
terminal_length
=
this
.
data
.
terminal_names
.
length
;
this
.
data
.
terminal_names
[
terminal_length
]
=
'上海铠寻'
let
kaixun_terminal_index
=
this
.
data
.
terminal_names
.
indexOf
(
'上海铠寻'
);
}
else
if
(
this
.
data
.
userForms
.
city_name
!==
'上海'
&&
kaixun_terminal_index
>
0
)
{
this
.
data
.
terminal_names
.
splice
(
kaixun_terminal_index
,
1
);
}
this
.
terminalAvailable
(
app
.
globalData
.
chezhibao_cityList
,
'车置宝'
);
if
(
this
.
data
.
userForms
.
city_name
===
'上海'
&&
kaixun_terminal_index
<
0
)
{
this
.
data
.
terminal_names
[
terminal_length
]
=
'上海铠寻'
}
else
if
(
this
.
data
.
userForms
.
city_name
!==
'上海'
&&
kaixun_terminal_index
>
0
)
{
this
.
data
.
terminal_names
.
splice
(
kaixun_terminal_index
,
1
);
}
this
.
terminalAvailable
(
app
.
globalData
.
renrenche_cityList
,
'人人车
'
);
this
.
terminalAvailable
(
app
.
globalData
.
chezhibao_cityList
,
'车置宝
'
);
return
true
;
this
.
terminalAvailable
(
app
.
globalData
.
renrenche_cityList
,
'人人车'
);
},
// 城市是否覆盖 是否选择推送
return
true
;
terminalAvailable
:
function
(
cityList
,
name
)
{
},
let
terminal_length
=
this
.
data
.
terminal_names
.
length
;
let
index
=
cityList
.
indexOf
(
this
.
data
.
userForms
.
city_name
);
let
terminal_index
=
this
.
data
.
terminal_names
.
indexOf
(
name
);
if
(
index
<
0
&&
terminal_index
>
-
1
)
{
// 城市是否覆盖 是否选择推送
this
.
data
.
terminal_names
.
splice
(
terminal_index
,
1
);
terminalAvailable
:
function
(
cityList
,
name
)
{
}
else
if
(
index
>
-
1
&&
terminal_index
<
0
)
{
let
terminal_length
=
this
.
data
.
terminal_names
.
length
;
this
.
data
.
terminal_names
[
terminal_length
]
=
name
let
index
=
cityList
.
indexOf
(
this
.
data
.
userForms
.
city_name
);
}
let
terminal_index
=
this
.
data
.
terminal_names
.
indexOf
(
name
);
},
// 提交
if
(
index
<
0
&&
terminal_index
>
-
1
)
{
submit
:
function
()
{
this
.
data
.
terminal_names
.
splice
(
terminal_index
,
1
);
let
_this
=
this
;
}
else
if
(
index
>
-
1
&&
terminal_index
<
0
)
{
if
(
this
.
checkValue
())
{
this
.
data
.
terminal_names
[
terminal_length
]
=
name
wx
.
showLoading
({
}
title
:
'卖车中'
,
},
mask
:
true
})
// 提交
_this
.
data
.
terminal_names
.
push
(
'精真估'
)
submit
:
function
()
{
_this
.
setData
({
let
_this
=
this
;
terminal_names
:
_this
.
data
.
terminal_names
if
(
this
.
checkValue
())
{
},
()
=>
{
wx
.
showLoading
({
_this
.
storeCar
();
title
:
'卖车中'
,
})
mask
:
true
})
_this
.
data
.
terminal_names
.
push
(
'精真估'
)
_this
.
setData
({
terminal_names
:
_this
.
data
.
terminal_names
},
()
=>
{
_this
.
storeCar
();
})
}
},
// 存储车
storeCar
:
function
()
{
let
_this
=
this
;
wx
.
request
({
url
:
app
.
globalData
.
url
+
'cars'
,
method
:
'POST'
,
data
:
_this
.
data
.
userForms
,
success
:
function
(
res
)
{
let
data
=
res
.
data
;
if
(
data
.
message
===
'ok'
)
{
let
carInfo
=
data
.
data
;
wx
.
setStorageSync
(
'carInfo'
,
carInfo
)
let
created_at
=
new
Date
(
carInfo
.
created_at
).
getTime
()
if
(
Date
.
now
()
-
created_at
<
3000
)
{
// 新车
_this
.
sellCar
();
}
else
{
// 已存在
_this
.
updateStatus
();
}
}
else
{
wx
.
showToast
({
icon
:
'none'
,
title
:
'请求错误,请稍后重试!'
})
}
}
},
},
fail
:
function
()
{
// 存储车
wx
.
showToast
({
storeCar
:
function
()
{
icon
:
'none'
,
let
_this
=
this
;
title
:
'请求错误,请稍后重试!'
wx
.
request
({
url
:
app
.
globalData
.
url
+
'cars'
,
method
:
'POST'
,
data
:
_this
.
data
.
userForms
,
success
:
function
(
res
)
{
let
data
=
res
.
data
;
if
(
data
.
message
===
'ok'
)
{
let
carInfo
=
data
.
data
;
wx
.
setStorageSync
(
'carInfo'
,
carInfo
)
let
created_at
=
new
Date
(
carInfo
.
created_at
).
getTime
()
if
(
Date
.
now
()
-
created_at
<
3000
)
{
// 新车
_this
.
sellCar
();
}
else
{
// 已存在
_this
.
updateStatus
();
}
}
else
{
wx
.
showToast
({
icon
:
'none'
,
title
:
'请求错误,请稍后重试!'
})
}
},
fail
:
function
()
{
wx
.
showToast
({
icon
:
'none'
,
title
:
'请求错误,请稍后重试!'
})
},
complete
:
function
()
{}
})
})
},
},
complete
:
function
()
{}
// 卖车接口
})
sellCar
:
function
()
{
},
let
_this
=
this
wx
.
request
({
// 卖车接口
url
:
app
.
globalData
.
url
+
'distributions/push-to-terminals'
,
sellCar
:
function
()
{
data
:
{
let
_this
=
this
car_id
:
wx
.
getStorageSync
(
'carInfo'
).
id
,
wx
.
request
({
terminal_names
:
this
.
data
.
terminal_names
url
:
app
.
globalData
.
url
+
'distributions/push-to-terminals'
,
},
data
:
{
method
:
"POST"
,
car_id
:
wx
.
getStorageSync
(
'carInfo'
).
id
,
success
:
function
(
res
)
{
terminal_names
:
this
.
data
.
terminal_names
if
(
res
.
data
.
message
===
'ok'
)
{
},
_this
.
updateStatus
();
method
:
"POST"
,
}
else
{
success
:
function
(
res
)
{
wx
.
showToast
(
{
if
(
res
.
data
.
message
===
'ok'
)
{
icon
:
'none'
,
_this
.
updateStatus
();
title
:
'请求错误,请稍后重试!'
}
else
{
})
wx
.
showToast
({
}
icon
:
'none'
,
},
title
:
'请求错误,请稍后重试!'
fail
:
function
()
{
})
wx
.
showToast
({
}
icon
:
'none'
,
}
,
title
:
'请求错误,请稍后重试!'
fail
:
function
()
{
})
wx
.
showToast
({
}
,
icon
:
'none'
,
complete
:
function
()
{}
title
:
'请求错误,请稍后重试!'
})
})
},
},
complete
:
function
()
{}
// 更新卖车状态
})
updateStatus
:
function
()
{
},
let
_this
=
this
;
wx
.
request
({
// 更新卖车状态
url
:
app
.
globalData
.
url
+
'distributions/update-sale-type'
,
updateStatus
:
function
()
{
data
:
{
let
_this
=
this
;
sale_type
:
1
,
wx
.
request
({
car_id
:
wx
.
getStorageSync
(
'carInfo'
).
id
url
:
app
.
globalData
.
url
+
'distributions/update-sale-type'
,
},
data
:
{
method
:
"POST"
,
sale_type
:
1
,
success
:
function
(
res
)
{
car_id
:
wx
.
getStorageSync
(
'carInfo'
).
id
if
(
res
.
data
.
message
===
'ok'
)
{
},
app
.
globalData
.
enter
=
'sell-car'
method
:
"POST"
,
wx
.
navigateTo
(
{
success
:
function
(
res
)
{
url
:
'/pages/submit/submit'
,
if
(
res
.
data
.
message
===
'ok'
)
{
})
app
.
globalData
.
enter
=
'sell-car'
}
else
{
wx
.
navigateTo
(
{
wx
.
showToast
({
url
:
'/pages/submit/submit'
,
icon
:
'none'
,
})
title
:
'请求错误,请稍后重试!'
}
else
{
})
wx
.
showToast
({
}
icon
:
'none'
,
},
title
:
'请求错误,请稍后重试!'
fail
:
function
()
{
})
wx
.
showToast
({
}
icon
:
'none'
,
}
,
title
:
'请求错误,请稍后重试!'
fail
:
function
()
{
})
wx
.
showToast
({
}
,
icon
:
'none'
,
complete
:
function
()
{}
title
:
'请求错误,请稍后重试!'
})
})
},
},
complete
:
function
()
{}
// 分享
})
onShareAppMessage
:
function
()
{
},
return
{
title
:
"高价卖车"
,
// 分享
path
:
"/pages/sellcar/sellcar"
onShareAppMessage
:
function
()
{
};
return
{
}
title
:
"高价卖车"
,
path
:
"/pages/sellcar/sellcar"
};
}
})
})
\ No newline at end of file
pages/sellcar/sellcar.wxml
View file @
b1c88250
...
@@ -68,6 +68,17 @@
...
@@ -68,6 +68,17 @@
<button bindgetphonenumber="getPhone" id="get-phone" openType="getPhoneNumber" size="mini" type="primary" wx:else>11位手机号</button> -->
<button bindgetphonenumber="getPhone" id="get-phone" openType="getPhoneNumber" size="mini" type="primary" wx:else>11位手机号</button> -->
</view>
</view>
</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>
</view>
...
...
pages/sellcar/sellcar.wxss
View file @
b1c88250
...
@@ -238,3 +238,20 @@ page {
...
@@ -238,3 +238,20 @@ page {
width: 202rpx;
width: 202rpx;
height: 32rpx;
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