idCard.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. const app = require('../../utils/util.js');
  2. var util = require('../../utils/md5.js')
  3. Page({
  4. data: {
  5. imgPath: '',
  6. isTrue: true,
  7. },
  8. goShenFen() {
  9. if (!this.data.isTrue) {
  10. wx.request({
  11. url: app.globalData.publicUrl + '/applet/suppleUserInfo',
  12. method: "POST",
  13. header: {
  14. appletsId: wx.getStorageSync('openId')
  15. },
  16. data: {
  17. headPicPath: this.data.imgPath
  18. },
  19. success: (res) => {
  20. console.log(res, "000");
  21. }
  22. })
  23. wx.redirectTo({
  24. url: '/pages/idCardDetail/idCardDetail',
  25. })
  26. } else {
  27. wx.showToast({
  28. title: "请上传照片",
  29. icon: 'none',
  30. duration: 2000,
  31. })
  32. }
  33. // wx.request({
  34. // url: app.globalData.publicUrl + '/applet/suppleUserInfo',
  35. // method: "POST",
  36. // header: {
  37. // appletsId: wx.getStorageSync('openId')
  38. // },
  39. // data: {
  40. // headPicPath: this.data.imgPath
  41. // },
  42. // success: (res) => {
  43. // console.log(res, "000");
  44. // }
  45. // })
  46. // wx.redirectTo({
  47. // url: '/pages/idCardDetail/idCardDetail',
  48. // })
  49. },
  50. goPhoto() {
  51. var that = this;
  52. wx.chooseImage({
  53. count: 1,
  54. sizeType: ['compressed'],
  55. sourceType: ['camera'],
  56. success: function (res) {
  57. var tempFilePaths = res.tempFilePaths
  58. wx.uploadFile({
  59. url: app.globalData.publicUrl + '/sys/user/upload',
  60. filePath: tempFilePaths[0],
  61. name: 'uploadFile',
  62. formData: {
  63. "user": "test",
  64. },
  65. header: {
  66. appletsId: wx.getStorageSync('openId'),
  67. },
  68. success: function (res) {
  69. console.log(JSON.parse(res.data), "45454545");
  70. let datas = JSON.parse(res.data)
  71. if (datas.code == 0) {
  72. that.setData({
  73. imgPath: datas.data,
  74. isTrue: false
  75. })
  76. }
  77. }
  78. })
  79. }
  80. })
  81. },
  82. closeImage(e) {
  83. this.setData({
  84. isTrue: true,
  85. imgPath: '',
  86. })
  87. },
  88. onLoad: function () {},
  89. })