Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

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