微信小程序多张图片和表单一起上传,验证表单及进度条的实现完整代码
微信小程序开发交流qq群 173683895
承接微信小程序开发。扫码加微信。
正文:
效果图:
完整代码:
<!--pages/register/register.wxml-->
<view class='top'>
<view>注 册 须 知 : </view>
</view>
<view>
<view class='form'>
<view class='hint'>标☆号为必填项</view><form bindsubmit="formSubmit" bindreset="formReset">头 像 上 传 ☆ <image wx:if="{{tempFilePaths[0] ==='undefined'}}" class='headimage' bindtap='img_item' id='0' name='headimage'></image><image wx:else src="{{tempFilePaths[0]}}" class='headimage' bindtap='img_item' id='0' name='headimage'></image><view class='view1' ><view class='view'>姓 名 ☆ </view><input type='text' name="name"></input></view><view class='view1' ><view class='view'>性 别 ☆ </view><input type='text' name="sex"></input></view><view class='view1' ><view class='view'>登录账号 ☆ </view><input type='text' name="account"></input></view><view class='view1' ><view class='view'>登录密码 ☆ </view><input type='text' bindinput='psw_1' name="psw"></input></view><view class='view1' ><view class='view'>确认密码 ☆ </view><input type='text' bindinput='psw_2' name="psw"></input></view><view class='view1' ><view class='view'>身份证号 ☆ </view><input type='text' name="certificate_num"></input></view><view class='view1' ><view class='view'>车牌号码 ☆ </view><input type='text' name="car_num"></input></view><view class='view1' ><view class='view'>手机号码 ☆ </view><input type='text' name="linktel"></input></view><!-- <view class='view1' ><view class='view'>驾照代号 ☆ </view><input type='text' name=""></input></view> --><view class='view'>身份证正面 ☆ </view><image class='img' wx:if="{{!tempFilePaths[1]}}" bindtap='img_item' id='1' name='idcard_positive' src='../../../image/jia.png'></image><image class='img' wx:else bindtap='img_item' id='1' name='idcard_positive' src='{{tempFilePaths[1]}}'></image><view class='view'>身份证反面 ☆ </view><image class='img' wx:if="{{!tempFilePaths[2]}}" bindtap='img_item' id='2' name='idcars_reverse' src='../../../image/jia.png'></image><image class='img' wx:else bindtap='img_item' id='2' name='idcard_positive' src='{{tempFilePaths[2]}}'></image><view class='view'>行驶本 ☆ </view><image class='img' wx:if="{{!tempFilePaths[3]}}" bindtap='img_item' id='3' name='driver_license' src='../../../image/jia.png'></image><image class='img' wx:else bindtap='img_item' id='3' name='idcard_positive' src='{{tempFilePaths[3]}}'></image><view class='view'>驾驶证 ☆ </view><image class='img' wx:if="{{!tempFilePaths[4]}}" bindtap='img_item' id='4' name='driving_this' src='../../../image/jia.png'></image><image class='img' wx:else bindtap='img_item' id='4' name='idcard_positive' src='{{tempFilePaths[4]}}'></image><view class='xiahuaxian'></view><progress percent="{{percent}}" wx:if="{{in_percent}}" show-info /><button formType="submit">提交审核</button></form>
</view>
</view>
js
// pages/register/register3/register3.js
const app = getApp()
const util = require("../../../utils/util.js")
var i;
var image_belong;
var only_num;
var form_data;
var psw_vaule=[];
Page({data: {tempFilePaths: [],percent: 0,in_percent: false},img_item: function (e) {var that = this;wx.chooseImage({count: 1,sizeType: ['original', 'compressed'],sourceType: ['album', 'camera'],success: function (res) {that.setData({['tempFilePaths[' + e.target.id + ']']: res.tempFilePaths[0]})}})},//POSTformSubmit: function (e) {var that = this;form_data = e.detail.value;if (psw_vaule[0] === psw_vaule[1]) {if (e.detail.value.name != '' && e.detail.value.account != '' && e.detail.value.psw != '' && e.detail.value.linktel != '' && e.detail.value.car_num != '') {var num = 0;for (var a = 0; a < that.data.tempFilePaths.length; a++) {if (that.data.tempFilePaths[a] === null) {wx.showToast({title: '请填写完整···',})} else {num++if (num === 5) {that.btn_up()}}}} else {wx.showToast({title: '请填写完整···',})}} else {wx.showToast({title: '密码重复···',})}},btn_up: function (e) {var that = this;switch (i) {case 0:image_belong = 'headimage'break;case 1:image_belong = 'idcard_positive'break;case 2:image_belong = 'idcars_reverse'break;case 3:image_belong = 'driver_license'break;case 4:image_belong = 'driving_this'break;}var data = form_datadata.openid = app._openiddata.program_id = app.jtappiddata.state = 1data.only_num = only_numdata.image_belong = image_belongwx.uploadFile({url: '/register_1',filePath: that.data.tempFilePaths[i],name: 'image',formData: data,success: function (res) {console.log(image_belong)i++that.setData({percent: that.data.percent + 20,in_percent: true})if (i == that.data.tempFilePaths.length) {util.request('/temp_info', 'get', { 'only_num': only_num }, '正在加载数据', function (res) {console.log(2)if (res.data.state == 1) {wx.showModal({title: '提示',content: '提交成功!',success: function (res) {that.setData({in_percent: false})that.onLoad()wx.navigateBack({delta: 2})}})} else {wx.showModal({title: '提示',content: '提交失败,请重新提交!',})}})} else if (i < that.data.tempFilePaths.length) {//若图片还没有传完,则继续调用函数that.btn_up()}}})},onLoad: function (options) {},onShow: function () {only_num = 'jt' + Math.round(new Date() / 1000);i = 0},onReachBottom: function (e) {console.log(e)},onShareAppMessage: function () {},psw_1: function (e) {psw_vaule[0] = e.detail.value},psw_2: function (e) {psw_vaule[1] = e.detail.value}
})
css
/* pages/register/register3/register3.wxss */
page{font-size: 32rpx;
}
.headimage{margin:0 auto;height: 150rpx;width: 150rpx;display: block;margin-bottom: 50rpx;border-radius: 50%;background: red
}
.top{border-radius: 15rpx;background: #F7B45D;height: 200rpx;margin: 15rpx;color: white;padding: 20rpx;
}
.form{margin: 35rpx 15rpx;border:1px solid #F7B45D;border-radius: 15rpx;padding: 15rpx;color: #F7B45D;margin-bottom: 30rpx
}
.form .view{display: inline-block;width: 220rpx;position: relative;bottom: 10rpx
}
.view1{margin-bottom: 20rpx;
}
.hint{position: relative;left: 40rpx;top: -35rpx;background: white;width: 230rpx;
}
input{border:1px solid #F7B45D;height: 30rpx;padding-left: 20rpx;border-radius: 15rpx;display: inline-block;
}
.img{height: 220rpx;display: block;margin-left: 120rpx;width: 360rpx;
}
.xiahuaxian{width: 100%;height: 3px;background: #F7B45D;margin-top: 100rpx;
}
button{width: 320rpx;height: 60rpx;font-size: 25rpx;line-height: 60rpx;margin-top: 50rpx;margin-bottom: 80rpx;background: #F7B45D;color: white
}
相关文章:

Android, BaseAdapter 处理大数据量时的优化
Android优化 最常见的就是ListView, Gallery, GridView, ViewPager 的大数据优化 图片优化 访问网络的优化优化的原则: 数据延迟加载 分批加载 本地缓存数据优化 1).复用contentview 2).创建static class ViewHolder 3).分…

meetup_我在2017年举办Meetup中学到的知识以及为何对2018年充满期待。
meetupby Daniel Deutsch由Daniel Deutsch 我在2017年举办Meetup中学到的知识以及为何对2018年充满期待。 (What I’ve learned hosting Meetups in 2017 — and why I’m looking forward to 2018.) As 2017 comes to an end, it’s time to reflect on the non-profit work …

BASE64 编码和解码
依赖jar: import org.apache.commons.codec.binary.Base64; BASE64和其他相似的编码算法通常用于转换二进制数据为文本数据,其目的是为了简化存储或传输。更具体地说,BASE64算法主要用于转换二进 制数据为ASCII字符串格式。Java语言提供了一个非常好的BA…

Android开发常用属性
1、android string.xml 文字中间加入空格 android string.xml前后加空格的技巧 <string name"password">密 码</string>   这个就代表着空格 2、文字单行显示 android layout布局文件中TextView、EditView单行显示和输入 <TextView androi…

JS计算起点坐标到终点坐标的驾车距离和驾车时间
微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 正文: 先上计算距离的简单demo: <!DOCTYPE html> <html><head><meta http-equiv"Content-Type" content"text/html; charsetutf-8"&…

css flexbox模型_5分钟内学习CSS Flexbox-初学者教程
css flexbox模型快速介绍流行的布局模块 (A quick introduction to the popular layout module) In this post, you’ll learn the basics of CSS Flexbox, which has become a must-have skill for web developers and designers in the last couple of years.在本文中&#x…

「linux网络管理」OSI模型
学习linux网络管理,笔记整理,促进记忆。 OSI(开放系统互联模型)包含七层,由应用层向物理层递进,分别有不同的协议和数据处理方式。 应用层--> 表示层--> 会话层--> 传输层--> 网络层--> 数据…

微信小程序下拉刷新和上拉加载的实现
微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 正文: 一: 下拉刷新 下拉刷新两个步骤就能实现。 1.在要实现下拉刷新的页面的json配置文件里面加上 "enablePullDownRefresh": true, //开启下拉刷新"backgro…

Spring整合Hibernate的步骤
为什么要整合Hibernate?1、使用Spring的IOC功能管理SessionFactory对象 LocalSessionFactoryBean2、使用Spring管理Session对象 HibernateTemplate3、使用Spring的功能实现声明式的事务管理 整合Hibernate的步骤:1、配置SessionFactory(能够…

初创企业购买企业邮箱_支持#NetNeutrality =支持设计师及其创建的初创企业
初创企业购买企业邮箱by Lukasz Lysakowski卢卡斯吕萨科夫斯基(Lukasz Lysakowski) 支持#NetNeutrality 支持设计师及其创建的初创企业 (Supporting #NetNeutrality Supporting Designers and the Startups They Create) I believe in Net Neutrality, and I wrote a brief e…

【转】Android source build/envsetup.sh学习笔记
原文网址:http://blog.csdn.net/mliubing2532/article/details/7567164 如果你只需要修改某一个模块的内容,但是却每次都要执行make, 最后等待很长时间。使用模块编译,那只需要在你所在的模块的目录或者其子目录,执行mm࿰…

微信小程序之上传附件
微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 正文: 目前微信API开放上传图片,录音文件,视频文件,but 只能下载并打开附件,不能上传附件,以后会不会开放附件上传目前还不确定&…

微软在.NET官网上线.NET 架构指南频道
微软在Visual Studio 2017 正式发布的时候也上线了一个参考应用https://github.com/dotnet/eShopOnContainers , 最近微软给这个参考应用写了完善的文档,放在.NET官网的.NET架构频道https://www.microsoft.com/net/architecture。 整个.NET 架构按照4个部分展开&…

初学者css常见问题_5分钟内学习CSS Grid-初学者教程
初学者css常见问题Grid layouts are fundamental to the design of websites, and the CSS Grid module is the most powerful and easiest tool for creating it. I personally think it’s a lot better than for example Bootstrap (read why here).网格布局是网站设计的基础…

HBase保存的各个字段意义解释
// Author:xxx0624 HomePage:http://www.cnblogs.com/xxx0624/ // nutch2.2.1集成HBase0.94.25, 可以查询nutch的conf文件中的gora-hbase-mapping.xml查看原文件 <gora-orm><table name"webpage"><family name"p" ma…

AJAX基础篇
微信小程序开发交流qq群 581478349 承接微信小程序开发。扫码加微信。 正文: 整理一下AJAX相关的知识,帮助自己复习的同时希望还能够帮助到新加入前端阵营的小伙伴们。 1.AJAX是什么? AJAX 异步的JavaScript和XML 2.AJAX的作用&…

在运筹学中什么样的解决方案是最优的
问题: 1.在运筹学中什么样的解决方案是最优的 2.线性代数解决的是什么问题? 3.运筹学与线性代数的关系? 4.如何使用matlab 解决运筹学中的问题? 转载于:https://www.cnblogs.com/lwy1103/p/6676373.html

npm构建脚本_NPM脚本简介
npm构建脚本by Mohammed Ajmal Siddiqui由Mohammed Ajmal Siddiqui NPM脚本简介 (Introduction to NPM Scripts) NPM scripts are among my favorite features of NPM. They are simple. They reduce the need for tools. Hence they reduce the number of configuration file…

SQL 中循环、for循环、游标
我们使用SQL语句处理数据时,可能会碰到一些需要循环遍历某个表并对其进行相应的操作(添加、修改、删除),这时我们就需要用到咱们在编程中常常用的for或foreach,但是在SQL中写循环往往显得那么吃力,翻遍网上…

Unix Linux大学教程(三):过滤器、正则表达式、vi
第16章 过滤器:简介和基本操作 删除数据列用colrm:colrm [startcol [endcol]] 如果没有endcol则删除从startcol至行末尾所有的列。 第17章 过滤器:比较和抽取 比较任意两个文件:cmp file1 file2 显示不同字节数及所在行。 比…

微信小程序获取多选框选中值和选中值对应的id
微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 官方文档中只有获取多选框的值的方法,但是我需要获取选中的值同时还要获取选中值对应的id,但是又不能操作DOM获取,相信和我有同样需求的伙伴们都会为此发愁࿰…

调试代码遗留_陷入遗留代码地狱吗? 这里有一些想法可以帮助您处理情况
调试代码遗留by Felipe Lopes通过Felipe Lopes 陷入遗留代码地狱吗? 这里有一些想法可以帮助您处理情况 (Stuck in legacy code hell? Here are some few thoughts to help you manage the situation) I’m gonna tell you a little story about how I ended up i…

求二维数组最大子数组
结对队友:胡康臻、杨寒寒 1、设计思想: 首先定义产生二维数组,定义可输入二维数组行和列,各位数随机产生; 然后进行最大子数组的求和比较,从每行的第一个数为子数组的起点开始进行不同的子数组遍历比较&…

UVa 11021 (概率 递推) Tribles
Tribble是麻球? 因为事件都是互相独立的,所以只考虑一只麻球。 设f(i)表示一只麻球i天后它以及后代全部死亡的概率,根据全概率公式: f(i) P0 P1 * f(i-1) P2 * f(i-1)2 ... Pn * f(n)n 每个麻球死亡是独立的,所以…

积分页面布局记录
微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 正文: 、 // pages/user/my_integral/record/record.js var app getApp(); var util require("../../../utils/util.js") Page({data: {url_data: ,username: ,usertop: ,tab: 1…

uber_Uber是如何制成的
uberby Dmytro Brovkin由Dmytro Brovkin Uber是如何制成的 (How Uber was made) Uber has transformed the world. Indeed, its inconceivable to think of a world without the convenience of the innovative ride sharing service. Tracing its origins in a market which …

HTML 标签包含规范,规避脱标流,图片和文字垂直居中对齐,
1 标签包含规范 ◆div可以包含所有的标签。 ◆p标签不能包含div h1等标签。 ◆h1可以包含p,div等标签。 ◆行内元素尽量包含行内元素,行内元素不要包含块元素。 2 规避脱标流 ◆尽量使用标准流。 ◆标准流解决不了的使用浮动。 ◆浮动解决不了…

Java Socket发送与接收HTTP消息简单实现
在上次Java Socket现实简单的HTTP服务我 们实现了简单的HTTP服务,它可以用来模拟HTTP服务,用它可以截获HTTP请求的原始码流,让我们很清楚的了解到我们向服务发的HTTP消息的结 构,对HTTP请求消息有个清晰的认识。这一节我想写了一个…

微信小程序日期相减得出天数
微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 正文: // 日期结算 num_data: function (e) {var start_date new Date(this.data.start_date.replace(/-/g, "/"));var end_date new Date(this.data.end_date.replace(/-/g, &q…

es6 ... 添加属性_如何在10分钟内免费将HTTPS添加到您的网站,以及为什么您现在不止需要这样做......
es6 ... 添加属性by Ayo Isaiah通过Ayo Isaiah 如何在10分钟内免费将HTTPS添加到您的网站,以及为什么现在比以往更需要这样做 (How to add HTTPS to your website for free in 10 minutes, and why you need to do this now more than ever) Last week, Google ann…