vehicle.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. const app = getApp();
  2. Page({
  3. data: {
  4. xszzyImages:'/image/vehicle1.png',
  5. xszzyImagesNum: false, //上传图标 显示
  6. // xszzyimg: true, //上传图片 隐藏
  7. xszfyImages: '/image/vehicle2.png',
  8. xszfyImagesNum: false, //上传图标 显示
  9. // xszzyimg: true, //上传图片 隐藏
  10. loadingHidden: true, //加载中
  11. positive: '', //行驶证主页
  12. opposite: '', //行驶证副页
  13. SubmissionHidden: true, //提交隐藏显示
  14. },
  15. /**
  16. * 生命周期函数--监听页面加载
  17. */
  18. onLoad: function (options) {
  19. var that = this;
  20. // 获取信息
  21. let initial_url = 'my/authentication/vehiclechange';
  22. let initial_data = {
  23. };
  24. app.postRequest(initial_url, initial_data, function (res) {
  25. if (res.code == 201) {
  26. // console.log(res.data.hold);
  27. that.setData({
  28. initial: res.data, // 初始数据
  29. initialcode: res, //获取未上传状态
  30. })
  31. }
  32. if (res.data.status == 2) { //如果审核通过 隐藏掉提交按钮
  33. that.setData({
  34. SubmissionHidden: false
  35. })
  36. } else if (res.code != 201) {
  37. that.setData({
  38. SubmissionHidden: false
  39. })
  40. } else {
  41. that.setData({
  42. SubmissionHidden: true
  43. })
  44. }
  45. })
  46. },
  47. // 拍摄行驶证主页
  48. xszzyclick: function (e) {
  49. var _this = this;
  50. wx.chooseImage({
  51. count: 1,
  52. sizeType: ['original', 'compressed'],
  53. sourceType: ['album', 'camera'],
  54. success(res) {
  55. let tempFilesSize = res.tempFiles[0].size;
  56. if (tempFilesSize > 1024 * 1024 * 3) {
  57. wx.showModal({
  58. title: '提示',
  59. content: '图片不得超过3MB',
  60. showCancel: false,
  61. })
  62. return;
  63. }
  64. // _this.setData({
  65. // loadingHidden: false
  66. // });
  67. wx.showToast({
  68. title: '上传中...',
  69. icon: 'loading'
  70. });
  71. let dt_url = 'my/images/tempimages';
  72. let dt_filePath = res.tempFilePaths[0];
  73. app.Multigraph(dt_url, dt_filePath, function (res) {
  74. if (res.code == 201) {
  75. // console.log(res.data.img_name);
  76. _this.setData({
  77. xszzyImages: dt_filePath,
  78. xszzyImagesNum: true,
  79. // scsfzimg: false,
  80. positive: res.data.img_name, //手持身份证
  81. });
  82. wx.showToast({
  83. title: '上传成功',
  84. icon: 'none', // 不显示图标
  85. duration: 2000
  86. })
  87. return;
  88. }
  89. app.Tips(res.msg);
  90. });
  91. }
  92. })
  93. },
  94. // 拍摄行驶证副页
  95. xszfyclick: function (e) {
  96. var _this = this;
  97. wx.chooseImage({
  98. count: 1,
  99. sizeType: ['original', 'compressed'],
  100. sourceType: ['album', 'camera'],
  101. success(res) {
  102. let tempFilesSize = res.tempFiles[0].size;
  103. if (tempFilesSize > 1024 * 1024 * 3) {
  104. wx.showModal({
  105. title: '提示',
  106. content: '图片不得超过3MB',
  107. showCancel: false,
  108. })
  109. return;
  110. }
  111. wx.showToast({
  112. title: '上传中...',
  113. icon: 'loading'
  114. });
  115. let dt_url = 'my/images/tempimages';
  116. let dt_filePath = res.tempFilePaths[0];
  117. app.Multigraph(dt_url, dt_filePath, function (res) {
  118. if (res.code == 201) {
  119. // console.log(res.data.img_name);
  120. _this.setData({
  121. xszfyImages: dt_filePath,
  122. xszfyImagesNum: true,
  123. // scsfzimg: false,
  124. opposite: res.data.img_name, //手持身份证
  125. loadingHidden: true //加载中
  126. });
  127. wx.showToast({
  128. title: '上传成功',
  129. icon: 'none', // 不显示图标
  130. duration: 2000
  131. })
  132. return;
  133. }
  134. app.Tips(res.msg);
  135. });
  136. }
  137. })
  138. },
  139. //最后提交认证
  140. Submission: function (e) {
  141. console.log(this.data.opposite)
  142. console.log(this.data.positive)
  143. var _this =this;
  144. if (this.data.positive == '') {
  145. var _opposite = '请上传行驶证主页'
  146. Tips(_opposite)
  147. } else if (this.data.opposite == '') {
  148. var _positive = '请上传行驶证副页'
  149. Tips(_positive)
  150. }else{
  151. let income_url = 'my/authentication/vehicle';
  152. let income_data = {
  153. positive: this.data.positive, //正面
  154. opposite: this.data.opposite, //副面
  155. };
  156. app.postRequest(income_url, income_data, function (res) {
  157. console.log(res)
  158. if (res.code == 201) {
  159. wx.showToast({
  160. title: '提交成功',
  161. icon: 'success',
  162. duration: 2000
  163. })
  164. _this.onLoad();
  165. return
  166. }
  167. var _qrcode = res.msg;
  168. getApp().Tips(_qrcode);
  169. })
  170. }
  171. },
  172. })
  173. // 提示框
  174. function Tips(text) {
  175. wx.showToast({
  176. title: text,
  177. icon: 'none', // 不显示图标
  178. duration: 2500
  179. })
  180. }