vehicle.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  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. let dt_url = 'my/images/tempimages';
  68. let dt_filePath = res.tempFilePaths[0];
  69. app.Multigraph(dt_url, dt_filePath, function (res) {
  70. if (res.code == 201) {
  71. console.log(res.data.img_name);
  72. _this.setData({
  73. xszzyImages: dt_filePath,
  74. xszzyImagesNum: true,
  75. // scsfzimg: false,
  76. positive: res.data.img_name, //手持身份证
  77. loadingHidden: true //加载中
  78. });
  79. }
  80. });
  81. }
  82. })
  83. },
  84. // 拍摄行驶证副页
  85. xszfyclick: function (e) {
  86. var _this = this;
  87. wx.chooseImage({
  88. count: 1,
  89. sizeType: ['original', 'compressed'],
  90. sourceType: ['album', 'camera'],
  91. success(res) {
  92. let tempFilesSize = res.tempFiles[0].size;
  93. if (tempFilesSize > 1024 * 1024 * 3) {
  94. wx.showModal({
  95. title: '提示',
  96. content: '图片不得超过3MB',
  97. showCancel: false,
  98. })
  99. return;
  100. }
  101. _this.setData({
  102. loadingHidden: false
  103. });
  104. let dt_url = 'my/images/tempimages';
  105. let dt_filePath = res.tempFilePaths[0];
  106. app.Multigraph(dt_url, dt_filePath, function (res) {
  107. if (res.code == 201) {
  108. console.log(res.data.img_name);
  109. _this.setData({
  110. xszfyImages: dt_filePath,
  111. xszfyImagesNum: true,
  112. // scsfzimg: false,
  113. opposite: res.data.img_name, //手持身份证
  114. loadingHidden: true //加载中
  115. });
  116. }
  117. });
  118. }
  119. })
  120. },
  121. //最后提交认证
  122. Submission: function (e) {
  123. console.log(this.data.opposite)
  124. console.log(this.data.positive)
  125. var _this =this;
  126. if (this.data.positive == '') {
  127. var _opposite = '请上传行驶证主页'
  128. Tips(_opposite)
  129. } else if (this.data.opposite == '') {
  130. var _positive = '请上传行驶证副页'
  131. Tips(_positive)
  132. }else{
  133. let income_url = 'my/authentication/vehicle';
  134. let income_data = {
  135. positive: this.data.positive, //正面
  136. opposite: this.data.opposite, //副面
  137. };
  138. app.postRequest(income_url, income_data, function (res) {
  139. console.log(res)
  140. if (res.code == 201) {
  141. wx.showToast({
  142. title: '提交成功',
  143. icon: 'success',
  144. duration: 2000
  145. })
  146. _this.onLoad();
  147. return
  148. }
  149. var _qrcode = res.msg;
  150. getApp().Tips(_qrcode);
  151. })
  152. }
  153. },
  154. })
  155. // 提示框
  156. function Tips(text) {
  157. wx.showToast({
  158. title: text,
  159. icon: 'none', // 不显示图标
  160. duration: 2500
  161. })
  162. }