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.

activeUploadPhoto.js 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. // plugin/etc/pages/activeUploadPhoto/activeUploadPhoto.js
  2. import {
  3. configPluginData,
  4. } from "../../../config.js"
  5. import {
  6. uploadFile
  7. } from "../../../network/upload"
  8. const network = require('../../../network/index');
  9. import {
  10. API
  11. } from "../../../network/etcApi"
  12. Page({
  13. /**
  14. * 页面的初始数据
  15. */
  16. data: {
  17. orderNo: "",
  18. obu: "",
  19. card: "",
  20. imagePath: '',
  21. imagePathUrl: '',
  22. isHaveUpload: true
  23. },
  24. /**
  25. * 生命周期函数--监听页面加载
  26. */
  27. onLoad(options) {
  28. this.configData(options)
  29. this.testIsHaveUpload()
  30. },
  31. // 是否需要上传安装照片
  32. async testIsHaveUpload() {
  33. wx.showLoading({
  34. title: '查询中...',
  35. })
  36. var res = await network.etc.isHaveUploadInstallPhoto({
  37. orderNo: this.data.orderNo,
  38. })
  39. wx.hideLoading()
  40. if (res.data) {
  41. let data = res.data.upInFlag
  42. // 如果需要上传
  43. if (data) {
  44. this.setData({
  45. isHaveUpload: true
  46. })
  47. } else {
  48. this.configJumpToActive();
  49. }
  50. } else {
  51. wx.showToast({
  52. title: res.message,
  53. icon: 'none'
  54. })
  55. }
  56. },
  57. configJumpToActive() {
  58. wx.redirectTo({
  59. url: `plugin://issuer-plugin/activeDeviceStep?orderNo=${this.data.orderNo}&obu=${this.data.obu}&card=${this.data.card}`
  60. })
  61. },
  62. nextStep() {
  63. if (this.data.imagePath) {
  64. this.configUploadInstallPhoto();
  65. // this.configJumpToActive();
  66. } else {
  67. wx.showToast({
  68. title: "请上传安装照片",
  69. icon: "none",
  70. })
  71. }
  72. },
  73. // 配置默认参数
  74. configData(options) {
  75. configPluginData()
  76. const orderNo = options?.orderNo
  77. if (orderNo) {
  78. this.setData({
  79. orderNo
  80. })
  81. }
  82. if (options?.obu) {
  83. this.setData({
  84. obu: options.obu
  85. })
  86. }
  87. if (options?.card) {
  88. this.setData({
  89. card: options.card
  90. })
  91. }
  92. },
  93. chooseImage() {
  94. const that = this;
  95. wx.chooseMedia({
  96. count: 1, //默认9
  97. mediaType: ['image'],
  98. sizeType: ["compressed"], //可以指定是原图还是压缩图,默认二者都有
  99. success: (res) => {
  100. let path = res.tempFiles[0].tempFilePath
  101. wx.showLoading({
  102. title: '上传中...',
  103. })
  104. uploadFile(path).then(res => {
  105. console.log(res)
  106. let fileUrl = res.ossFilePath
  107. console.log(fileUrl)
  108. that.setData({
  109. imagePath: fileUrl,
  110. imagePathUrl: `https://qtzl.etcjz.cn/${fileUrl}`
  111. })
  112. console.log(`https://qtzl.etcjz.cn/${fileUrl}`)
  113. wx.hideLoading();
  114. })
  115. },
  116. fail: function (e) {
  117. wx.hideLoading();
  118. console.log(e)
  119. },
  120. })
  121. },
  122. async configUploadInstallPhoto() {
  123. let params = {
  124. orderNo: this.data.orderNo,
  125. url: this.data.imagePath
  126. }
  127. const res = await API.ETC.uploadInstallPhoto(params)
  128. wx.hideLoading();
  129. if (res.code == 0) {
  130. this.configJumpToActive();
  131. } else {
  132. wx.showToast({
  133. title: res.message || "上传失败,请稍后重试",
  134. icon: "none"
  135. })
  136. }
  137. }
  138. })