gmsmile

html:{

<view class=\'tj\'>
<form bindsubmit="formSubmit">
<view class=\'title\'>丫丫上门服务</view>
<view class=\'box\'><label>姓名:</label> <input type=\'text\' name=\'xm\' value=\'\' /> <view class=\'clear\'></view></view>
<view class=\'box\'><label>联系方式:</label> <input type=\'text\' name=\'lxfs\' value=\'\' /> <view class=\'clear\'></view> </view>
<view class=\'box\'><label>需求:</label> <input type=\'text\' name=\'xq\' value=\'\' /> <view class=\'clear\'></view></view>
<view class=\'box\'><label>小区名字:</label> <input type=\'text\' name=\'xqmz\' value=\'\' /> <view class=\'clear\'></view></view>
<button formType="submit">提交</button>
</form>
</view>

}

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

分类:

技术点:

相关文章:

  • 2021-11-20
  • 2021-11-20
  • 2021-12-08
  • 2021-11-20
  • 2021-12-01
  • 2021-11-20
猜你喜欢
  • 2021-12-08
  • 2021-11-20
  • 2021-11-20
  • 2021-11-06
  • 2021-11-20
  • 2021-11-30
  • 2021-11-11
相关资源
相似解决方案