小程序笔记四:表单提交form
index.wxml代码
<form bindsubmit="formSubmit" bindreset="formReset">
<view class='box address-mode'>
<view class='item clearfix'>
<view class="float-li t1">收货人:</view>
<view class="float-li t2"><input name="name" maxlength="6" placeholder="请输入收货人" /></view>
</view>
<view class='item clearfix'>
<view class="float-li t1">手机:</view>
<view class="float-li t2"><input name="mobile" type="number" maxlength="11" placeholder="请输入手机" /></view>
</view> <view class='item clearfix' style='height: 50rpx;'>
<view class="float-li t1">省市地区:</view>
<view class="float-li t2" bindtap='pikerScenes'>{{region[0]['regname']}},{{region[1]['regname']}},{{region[2]['regname']}}</view>
</view> <view class='item clearfix' style='height: 100rpx;'>
<view class="float-li t1">详细地址:</view>
<view class="float-li t2"><textarea name="address" maxlength="-1" style='height: 80rpx'/></view> </view>
</view>
<view class="blank"></view>
<!--按钮-->
<view class="address-button"><button class='btn' formType="submit" bindtap='clickAdr'>保存地址</button></view>
</form>
index.js代码
formSubmit: function (e) {
var that = this
var regionInfo = that.data.regionInfo
var token = wx.getStorageSync('token')
var name = e.detail.value.name
var mobile = e.detail.value.mobile
var address = e.detail.value.address
//var province = 6 // 广东
//var city = 77 // 深圳
//var district = 708 // 西乡
var province = regionInfo[]['regid'] // 省
var city = regionInfo[]['regid'] // 市
var district = regionInfo[]['regid'] // 区
wx.request({
url: app.api.saveAddress,
data: { consignee: name, mobile: mobile, address: address, token: token.token, email: '', province: province, city: city, district: district},
success:function(e){
// 重新刷新地址列表
that.requestAddressList()
if(e.data.code ==){
var ttl='提交成功'
}else{
var ttl='提交失败'
}
wx.showModal({
content: ttl,
showCancel: false,
success: function (res) {
if (res.confirm) {
console.log('用户点击确定')
} else if (res.cancel) {
console.log('用户点击取消')
}
}
})
}
})
},
参考手册:
https://mp.weixin.qq.com/debug/wxadoc/dev/component/form.html
https://mp.weixin.qq.com/debug/wxadoc/dev/component/input.html
小程序笔记四:表单提交form的更多相关文章
- 微信小程序基础之表单Form的使用
表单Form的应用很广泛,我们可以利用form设计登录注册,也可以设计一种答题问卷的形式,今天主要讲一下form的使用 form表单,将组件内输入的"switch","i ...
- [学习笔记]--Jfinal 表单提交附件
近期.项目里面用到了Jfinal 里面的上传附件. Jfinal 的Controller 里面提供了一个 getFile系列方法提供文件上传. 我这里呢,是文件上传和表单參数一起提交. 页面类似下图: ...
- 20151223jquery学习笔记--Ajax表单提交
传统的表单提交, 需要多次跳转页面, 极大的消耗资源也缺乏良好的用户体验. 而这款form.js 表单的 Ajax 提交插件将解决这个问题.一. 核心方法官方网站: http://malsup.com ...
- 表单提交---前端页面模拟表单提交(form)
有些时候我们的前端页面总没有<form></form>表单,但是具体的业务时,我们又必须用表单提交才能达到我们想要的结果,LZ最近做了一些关于导出的一些功能,需要调用浏览器默认 ...
- 微信小程序——仿jqueryValidate表单验证插件WxValidate的二次封装(一)
在做web开发时,表单验证插件我们前端用的是jqueryValidate,由于个人主要精力是在后台JAVA开发上,为了让插件与后台更好的结合和使用,通过JAVA的自定义组件将表单全部重新写了一边,同时 ...
- 微信小程序实战:表单与选择控件的结合
先上代码. login.wxml <mp-toptips msg="{{error}}" type="error" show="{{error} ...
- SpringMVC学习笔记:表单提交 参数的接收
SpringMVC可以接收原生form表单和json格式数据 有一个名为Book的model,其中的属性如下: 字符串类型的name,数字类型的price,数组类型的cover,集合类型的author ...
- 微信小程序笔记<四>page.js —— 页面注册
小程序的每个页面都是独立的,每个页面都必须有 page.js 和 page.wxhl 文件,page.json 和 page.wxss 文件非必要文件,注意如果创建 page.json 则至少保证有一 ...
- 新开窗口不被拦截的方法-window.open和表单提交form
$("#btn").click(function() { var w = window.open(); setTimeout(function() { w.location = & ...
随机推荐
- fastjson使用TypeReference示例
package junit.test; import java.util.ArrayList; import java.util.HashMap; import java.util.List; imp ...
- 解决maven项目 maven install失败 错误 Failed to execute goal org.apache.maven.plugins
1.Maven构建失败 Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin: 2.3.4 :compile ( ...
- 开发错误处理记录(无法激活服务,因为它不支持 ASP.NET 兼容性)
错误提示:无法激活服务,因为它不支持 ASP.NET 兼容性.已为此应用程序启用了 ASP.NET 兼容性.请在 web.config 中关闭 ASP.NET 兼容性模式或将 AspNetCompat ...
- One-hot 编码/TF-IDF 值来提取特征,LAD/梯度下降法(Gradient Descent),Sigmoid
1. 多值无序类数据的特征提取: 多值无序类问题(One-hot 编码)把“耐克”编码为[0,1,0],其中“1”代表了“耐克”的中 间位置,而且是唯一标识.同理我们可以把“中国”标识为[1,0],把 ...
- systemd管理网络应用
采用systemd-networkd管理网卡 主网卡eth0的配置文件/etc/systemd/network/20-eth0.network,静态配置时内容示例如下: [Match] Name=et ...
- Vagrant (3) —— 复制/备份Vagrant Box
Vagrant (3) -- 复制/备份Vagrant Box 摘要 介绍复制/备份Vagrant Box基本方法 版本 Vagrant版本: 1.8.1 内容 复制vagrant box并压缩 关闭 ...
- openCV—Python(5)—— 图像几何变换
一.函数简单介绍 1.warpAffine-图像放射变换(平移.旋转.缩放) 函数原型:warpAffine(src, M, dsize, dst=None, flags=None, borderMo ...
- linq操作符:转换操作符
这些转换操作符将集合转换成数组:IEnumerable.IList.IDictionary等.转换操作符是用来实现将输入对象的类型转变为序列的功能.名称以"As"开头的转换方法可更 ...
- Spring配置文件<context:property-placeholder>标签使用漫谈
<context:property-placeholder>标签提供了一种优雅的外在化参数配置的方式,不过该标签在Spring配置文件中只能存在一份!!! 众所周知,Spring容器是采用 ...
- bootstrap底部消息提示插件
http://www.bootcss.com/p/messenger/ 具体效果下载插件查看