<
form
bindsubmit=
'formSubmit'>
<
view
>用户名:
<
input
type=
'text'
name=
"username"
value=
''
placeholder=
'请输入您的姓名'
/
>
</
view
>
<
view
>手机:
<
input
type=
'number'
name=
"tel"
value=
''
placeholder=
'请输入您的手机号'
/
>
</
view
>
<
view
>
身份证:
<
input
type=
'idcard'
name=
"idcard"
value=
''
placeholder=
'请输入您的身份证号码'
/
>
</
view
>
<
view
>级别:
<
radio-group
name=
"rank">
<
label
>
<
radio
value=
"chuji"
/
>初级
</
label
>
<
label
>
<
radio
value=
"zhongji"
checked=
'checked'
/
>中级
</
label
>
<
label
>
<
radio
value=
"gaoji"
/
>高级
</
label
>
</
radio-group
>
</
view
>
<
button
form-type=
'submit'>保存
</
button
>
</
form
>
let app = getApp();
Page({
data: {
inputValue:
''
},
onLoad:
function() {
},
formSubmit:
function(e) {
console.log(e.detail.value)
console.log(e.detail.value.username)
console.log(e.detail.value.tel)
console.log(e.detail.value.idcard)
console.log(e.detail.value.rank)
var that =
this;
var username = e.detail.value.username;
var tel = e.detail.value.tel;
var idcard = e.detail.value.idcard;
var rank = e.detail.value.rank;
if (!(idcard.length ===
15 || idcard.length ===
18)) {
wx.showToast({
title:
'请输入15或18位数身份证号码',
duration:
2000
})
}
else {
wx.request({
method:
"POST",
url:
"",
data: {
'username': username,
'tel': tel,
'idcard': idcard,
'rank': rank
},
header: {
'content-type':
'application/json'
},
success:
function(res) {
wx.showToast({
title:
'保存成功',
duration:
2000
})
}
})
}
}
})