转载自 https://blog.csdn.net/qq_35713752/article/details/78975877
  1. <view class='top'>
  2. <view>注 册 须 知 : </view>
  3. </view>
  4. <view>
  5. <view class='form'>
  6. <view class='hint'>标☆号为必填项 </view>
  7. <form bindsubmit="formSubmit" bindreset="formReset">
  8. 头 像 上 传 ☆ <image wx:if="{{tempFilePaths[0] ==='undefined'}}" class='headimage' bindtap='img_item' id='0' name='headimage'> </image>
  9. <image wx:else src="{{tempFilePaths[0]}}" class='headimage' bindtap='img_item' id='0' name='headimage'> </image>
  10. <view class='view1' > <view class='view'>姓 名 ☆ </view> <input type='text' name="name"> </input> </view>
  11. <view class='view1' > <view class='view'>性 别 ☆ </view> <input type='text' name="sex"> </input> </view>
  12. <view class='view1' > <view class='view'>登录账号 ☆ </view> <input type='text' name="account"> </input> </view>
  13. <view class='view1' > <view class='view'>登录密码 ☆ </view> <input type='text' bindinput='psw_1' name="psw"> </input> </view>
  14. <view class='view1' > <view class='view'>确认密码 ☆ </view> <input type='text' bindinput='psw_2' name="psw"> </input> </view>
  15. <view class='view1' > <view class='view'>身份证号 ☆ </view> <input type='text' name="certificate_num"> </input> </view>
  16. <view class='view1' > <view class='view'>车牌号码 ☆ </view> <input type='text' name="car_num"> </input> </view>
  17. <view class='view1' > <view class='view'>手机号码 ☆ </view> <input type='text' name="linktel"> </input> </view>
  18. <!-- <view class='view1' ><view class='view'>驾照代号 ☆ </view><input type='text' name=""></input></view> -->
  19. <view class='view'>身份证正面 ☆ </view>
  20. <image class='img' wx:if="{{!tempFilePaths[1]}}" bindtap='img_item' id='1' name='idcard_positive' src='../../../image/jia.png'> </image>
  21. <image class='img' wx:else bindtap='img_item' id='1' name='idcard_positive' src='{{tempFilePaths[1]}}'> </image>
  22. <view class='view'>身份证反面 ☆ </view>
  23. <image class='img' wx:if="{{!tempFilePaths[2]}}" bindtap='img_item' id='2' name='idcars_reverse' src='../../../image/jia.png'> </image>
  24. <image class='img' wx:else bindtap='img_item' id='2' name='idcard_positive' src='{{tempFilePaths[2]}}'> </image>
  25. <view class='view'>行驶本 ☆ </view>
  26. <image class='img' wx:if="{{!tempFilePaths[3]}}" bindtap='img_item' id='3' name='driver_license' src='../../../image/jia.png'> </image>
  27. <image class='img' wx:else bindtap='img_item' id='3' name='idcard_positive' src='{{tempFilePaths[3]}}'> </image>
  28. <view class='view'>驾驶证 ☆ </view>
  29. <image class='img' wx:if="{{!tempFilePaths[4]}}" bindtap='img_item' id='4' name='driving_this' src='../../../image/jia.png'> </image>
  30. <image class='img' wx:else bindtap='img_item' id='4' name='idcard_positive' src='{{tempFilePaths[4]}}'> </image>
  31. <view class='xiahuaxian'> </view>
  32. <progress percent="{{percent}}" wx:if="{{in_percent}}" show-info />
  33. <button formType="submit">提交审核 </button>
  34. </form>
  35. </view>
  36. </view>
js

  1. // pages/register/register3/register3.js
  2. const app = getApp()
  3. const util = require( "../../../utils/util.js")
  4. var i;
  5. var image_belong;
  6. var only_num;
  7. var form_data;
  8. var psw_vaule=[];
  9. Page({
  10. data: {
  11. tempFilePaths: [],
  12. percent: 0,
  13. in_percent: false
  14. },
  15. img_item: function (e) {
  16. var that = this;
  17. wx.chooseImage({
  18. count: 1,
  19. sizeType: [ 'original', 'compressed'],
  20. sourceType: [ 'album', 'camera'],
  21. success: function (res) {
  22. that.setData({
  23. [ 'tempFilePaths[' + e.target.id + ']']: res.tempFilePaths[ 0]
  24. })
  25. }
  26. })
  27. },
  28. //POST
  29. formSubmit: function (e) {
  30. var that = this;
  31. form_data = e.detail.value;
  32. if (psw_vaule[ 0] === psw_vaule[ 1]) {
  33. if (e.detail.value.name != '' && e.detail.value.account != '' && e.detail.value.psw != '' && e.detail.value.linktel != '' && e.detail.value.car_num != '') {
  34. var num = 0;
  35. for ( var a = 0; a < that.data.tempFilePaths.length; a++) {
  36. if (that.data.tempFilePaths[a] === null) {
  37. wx.showToast({
  38. title: '请填写完整···',
  39. })
  40. } else {
  41. num++
  42. if (num === 5) {
  43. that.btn_up()
  44. }
  45. }
  46. }
  47. } else {
  48. wx.showToast({
  49. title: '请填写完整···',
  50. })
  51. }
  52. } else {
  53. wx.showToast({
  54. title: '密码重复···',
  55. })
  56. }
  57. },
  58. btn_up: function (e) {
  59. var that = this;
  60. switch (i) {
  61. case 0:
  62. image_belong = 'headimage'
  63. break;
  64. case 1:
  65. image_belong = 'idcard_positive'
  66. break;
  67. case 2:
  68. image_belong = 'idcars_reverse'
  69. break;
  70. case 3:
  71. image_belong = 'driver_license'
  72. break;
  73. case 4:
  74. image_belong = 'driving_this'
  75. break;
  76. }
  77. var data = form_data
  78. data.openid = app._openid
  79. data.program_id = app.jtappid
  80. data.state = 1
  81. data.only_num = only_num
  82. data.image_belong = image_belong
  83. wx.uploadFile({
  84. url: '/register_1',
  85. filePath: that.data.tempFilePaths[i],
  86. name: 'image',
  87. formData: data,
  88. success: function (res) {
  89. console.log(image_belong)
  90. i++
  91. that.setData({
  92. percent: that.data.percent + 20,
  93. in_percent: true
  94. })
  95. if (i == that.data.tempFilePaths.length) {
  96. util.request( '/temp_info', 'get', { 'only_num': only_num }, '正在加载数据', function (res) {
  97. console.log( 2)
  98. if (res.data.state == 1) {
  99. wx.showModal({
  100. title: '提示',
  101. content: '提交成功!',
  102. success: function (res) {
  103. that.setData({
  104. in_percent: false
  105. })
  106. that.onLoad()
  107. wx.navigateBack({
  108. delta: 2
  109. })
  110. }
  111. })
  112. } else {
  113. wx.showModal({
  114. title: '提示',
  115. content: '提交失败,请重新提交!',
  116. })
  117. }
  118. })
  119. } else if (i < that.data.tempFilePaths.length) { //若图片还没有传完,则继续调用函数
  120. that.btn_up()
  121. }
  122. }
  123. })
  124. },
  125. onLoad: function (options) {
  126. },
  127. onShow: function () {
  128. only_num = 'jt' + Math.round( new Date() / 1000);
  129. i = 0
  130. },
  131. onReachBottom: function (e) {
  132. console.log(e)
  133. },
  134. onShareAppMessage: function () {
  135. },
  136. psw_1: function (e) {
  137. psw_vaule[ 0] = e.detail.value
  138. },
  139. psw_2: function (e) {
  140. psw_vaule[ 1] = e.detail.value
  141. }
  142. })
css

  1. /* pages/register/register3/register3.wxss */
  2. page{
  3. font-size: 32rpx;
  4. }
  5. .headimage{
  6. margin: 0 auto;
  7. height: 150rpx;
  8. width: 150rpx;
  9. display: block;
  10. margin-bottom: 50rpx;
  11. border-radius: 50%;
  12. background: red
  13. }
  14. .top{
  15. border-radius: 15rpx;
  16. background: #F7B45D;
  17. height: 200rpx;
  18. margin: 15rpx;
  19. color: white;
  20. padding: 20rpx;
  21. }
  22. .form{
  23. margin: 35rpx 15rpx;
  24. border: 1px solid #F7B45D;
  25. border-radius: 15rpx;
  26. padding: 15rpx;
  27. color: #F7B45D;
  28. margin-bottom: 30rpx
  29. }
  30. .form .view{
  31. display: inline-block;
  32. width: 220rpx;
  33. position: relative;
  34. bottom: 10rpx
  35. }
  36. .view1{
  37. margin-bottom: 20rpx;
  38. }
  39. .hint{
  40. position: relative;
  41. left: 40rpx;
  42. top: - 35rpx;
  43. background: white;
  44. width: 230rpx;
  45. }
  46. input{
  47. border: 1px solid #F7B45D;
  48. height: 30rpx;
  49. padding-left: 20rpx;
  50. border-radius: 15rpx;
  51. display: inline-block;
  52. }
  53. .img{
  54. height: 220rpx;
  55. display: block;
  56. margin-left: 120rpx;
  57. width: 360rpx;
  58. }
  59. .xiahuaxian{
  60. width: 100%;
  61. height: 3px;
  62. background: #F7B45D;
  63. margin-top: 100rpx;
  64. }
  65. button{
  66. width: 320rpx;
  67. height: 60rpx;
  68. font-size: 25rpx;
  69. line-height: 60rpx;
  70. margin-top: 50rpx;
  71. margin-bottom: 80rpx;
  72. background: #F7B45D;
  73. color: white
  74. }