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