微信小程序 form表单提交

html:{

丫丫上门服务

}

index.js代码

Page({
formSubmit: function (e) {
// var info = e.detail.value
if (e.detail.value.xm.length == 0 || e.detail.value.xq.length == 0 || e.detail.value.lxfs.length == 0 || e.detail.value.xqmz.length == 0) {

wx.showModal({

title: '姓名或联系方式或需求或小区名字不得为空!',
content:'很棒棒哟',

})

} else if (e.detail.value.lxfs.length != 11){
wx.showToast({

title: '请输入11位手机号码!',

icon: 'loading',

duration: 1500

})

setTimeout(function () {

wx.hideToast()

}, 2000)


}else{
wx.request({
url: app.globalData.http + '/Wechat/apply', //仅为示例,并非真实的接口地址
header: {
'content-type': 'application/x-www-form-urlencoded' // 默认值
},
method:'POST',
data:{xm:e.detail.value.xm,lxfs:e.detail.value.lxfs,xq:e.detail.value.xq,xqmz:e.detail.value.xqmz},
success: function (res) {
if (res.data.status == 0) {

wx.showToast({

title: res.data.info,

icon: 'loading',

duration: 1500

})

} else {

wx.showToast({

title: res.data.info,//这里打印出登录成功

icon: 'success',

duration: 1000

})

}

}
})
}

},
如有不懂可查看原网站http://www.jb51.net/article/102875.htm

转载于:https://www.cnblogs.com/gmsmile/p/8361193.html

你可能感兴趣的:(微信小程序 form表单提交)