123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- // plugin/etc/pages/activeDes/activeDes.js
-
-
- import {
- configPluginData,
- failPluginData
- } from "../../../config.js"
- import Api from "../../../api/index.js"
- import {
- requestFnc
- } from "../../../utils/request.js"
- import {
- uploadFile
- } from "../../../network/upload"
- import {
- API
- } from "../../../network/etcApi"
-
- const network = require('../../../network/index');
-
- Page({
-
- /**
- * 页面的初始数据
- */
- data: {
- orderNo: "",
- isLoading: false,
- imagePath: '',
- imagePathUrl: '',
- isHaveUpload: true
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
- this.configData(options)
- this.testIsHaveUpload()
- },
- onUnload() {
-
- },
-
- // 是否需要上传安装照片
- async testIsHaveUpload() {
- this.setData({
- isLoading: true
- })
- var res = await network.etc.isHaveUploadInstallPhoto({
- orderNo: this.data.orderNo,
- })
- this.setData({
- isLoading: false
- })
- if (res.data) {
- let data = res.data.upInFlag
- // 如果需要上传
- if (data) {
- this.setData({
- isHaveUpload: true
- })
- } else {
- wx.redirectTo({
- url: `plugin://issuer-plugin/activeDesIn?orderNo=${this.data.orderNo}`
- })
- }
- } else {
- wx.showToast({
- title: res.message,
- icon: 'none'
- })
- setTimeout(() => {
- wx.navigateBack()
- }, 1500)
- }
- },
-
- nextStep() {
- if (this.data.imagePath) {
- wx.redirectTo({
- url: `plugin://issuer-plugin/activeDesIn?orderNo=${this.data.orderNo}`
- })
- } else {
- wx.showToast({
- title: "请上传安装照片",
- icon: "none",
- })
- }
- },
-
- /// -------------- 工具类型 ---------------- ///
- // 配置默认参数
- configData(options) {
- configPluginData()
- const orderNo = options?.orderNo
- if (orderNo) {
- this.setData({
- orderNo
- })
- }
- },
-
- /// 配置导航栏标题
- configNavTitle(title = "设备搜索") {
- wx.setNavigationBarTitle({
- title: title,
- })
- },
-
- chooseImage() {
- wx.chooseMedia({
- count: 1, //默认9
- mediaType: ['image'],
- sizeType: ["compressed"], //可以指定是原图还是压缩图,默认二者都有
- success: (res) => {
- let path = res.tempFiles[0].tempFilePath
- uploadFile(path).then(res => {
- console.log(res)
- wx.showLoading({
- title: '上传中...',
- })
- let fileUrl = res.ossFilePath
- console.log(fileUrl)
- this.setData({
- imagePath: fileUrl,
- imagePathUrl: `https://qtzl.etcjz.cn/${fileUrl}`
- })
- console.log(`https://qtzl.etcjz.cn/${fileUrl}`)
- let params = {
- orderNo: this.data.orderNo,
- url: fileUrl
- }
- API.ETC.uploadInstallPhoto(params)
- wx.hideLoading();
- })
- },
- fail: function (e) {
- console.log(e)
- wx.hideLoading();
- },
- })
- }
- })
|