Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

uploadEnterprise.js 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. // plugin/components/enterpriseUpload/enterpriseUpload.js
  2. import Api from "../../api/index.js"
  3. import { requestFnc } from "../../utils/request.js"
  4. import { getStore, setStore } from "../../utils/index.js"
  5. Component({
  6. properties: {
  7. showOne: {
  8. type: Boolean,
  9. value: false,
  10. },
  11. },
  12. data: {
  13. isLoading: false,
  14. sides: "1",
  15. leftPath: "",
  16. rightPath: "",
  17. identity: {},
  18. },
  19. attached: function () {},
  20. methods: {
  21. //选择图片
  22. chooseImage(e) {
  23. console.log(e.currentTarget.dataset.side)
  24. this.setData({
  25. sides: e.currentTarget.dataset.side,
  26. })
  27. this.compressRef = this.selectComponent("#compress")
  28. this.compressRef._changImg()
  29. },
  30. ////图片压缩成功
  31. compressRes(file) {
  32. this.setData({
  33. isLoading: true,
  34. })
  35. let imgStr = file.detail[0].split(";")[1].split(",")[1]
  36. if (this.data.sides === "2") {
  37. //反面
  38. this.setData({
  39. rightPath: file.detail[0],
  40. isLoading: false,
  41. })
  42. let obj = {
  43. type: "2",
  44. imgStr: imgStr,
  45. }
  46. this.triggerEvent("enterpriseImage", obj)
  47. return
  48. }
  49. if (this.data.sides === "1") {
  50. //正面
  51. this.setData({
  52. leftPath: file.detail[0],
  53. })
  54. let obj = {
  55. type: "1",
  56. imgStr: imgStr,
  57. }
  58. this.triggerEvent("enterpriseImage", obj)
  59. let data = {
  60. filename: Api.ocrCorp.filename,
  61. data: {
  62. imageStr: imgStr,
  63. vehicleId: getStore("vehicleId"),
  64. },
  65. }
  66. requestFnc(
  67. Api.ocrCorp.url,
  68. data,
  69. (res) => {
  70. let corpInfoObj = JSON.parse(res.encryptedData)
  71. corpInfoObj.imageId = res.imageId
  72. for (let key in corpInfoObj) {
  73. this.data.identity[key] = corpInfoObj[key]
  74. }
  75. this.setData({
  76. isLoading: false,
  77. identity: this.data.identity,
  78. })
  79. this.triggerEvent(
  80. "enterpriseOcrInfo",
  81. this.data.identity
  82. )
  83. },
  84. (msg) => {
  85. this.setData({
  86. isLoading: false,
  87. })
  88. }
  89. )
  90. }
  91. },
  92. viewImage(e) {
  93. console.log(e)
  94. wx.previewImage({
  95. urls: [e.currentTarget.dataset.type],
  96. })
  97. },
  98. delImg(e) {
  99. let data = e.currentTarget.dataset.type
  100. wx.showModal({
  101. title: "提示",
  102. content: "确定要删除此照片吗?",
  103. success: (res) => {
  104. if (res.confirm) {
  105. if (data == "left") {
  106. this.setData({
  107. leftPath: "",
  108. })
  109. } else if (data == "right") {
  110. this.setData({
  111. rightPath: "",
  112. })
  113. }
  114. this.triggerEvent("delImg", data)
  115. }
  116. },
  117. })
  118. },
  119. },
  120. })