riku
2022-10-17 eb7366f400867d3f401fe60f06d848d6d1448457
pages/m_user/base_c/c_scene-info/c_scene-info.js
@@ -1,8 +1,9 @@
// pages/m_user/base_c/c_scene-info/c_scene-info.js
import sceneInfo from '../../../../data/sceneInfo'
import {sceneInfo, sceneLedger} from '../../../../data/sceneInfo'
import userservice from '../../../../service/userservice'
import deviceservice from '../../../../service/deviceservice'
import b_inputCheck from '../../behaviors/b_inputCheck'
import ledgerservice from "../../../../service/ledgerservice"
import b_inputCheck from '../../../../base/behaviors/b_inputCheck'
import b_uploadLedger from '../../../m_ledger/behaviors/b_uploadLedger'
import b_loadingToast from '../../../../base/behaviors/b_loadingToast'
@@ -31,29 +32,18 @@
    }
  },
  attached() {
  ready() {
    this.setData({
      loadingText: '上传中',
      loadCompleteText: '上传完成'
    })
  },
  pageLifetimes: {
    show: function () {
      // 页面被展示
      const info = sceneInfo()
      this.setData({
        msg: info.get(this.data.sceneType)
      })
      //获取场景信息
      this.getSceneInfo()
    },
    hide: function () {
      // 页面被隐藏
    },
    resize: function (size) {
      // 页面尺寸变化
    }
    const info = sceneInfo()
    this.setData({
      msg: info.get(this.data.sceneType),
      ledger: sceneLedger[this.data.sceneType]
    })
    //获取场景信息
    this.getSceneInfo()
  },
  /**
@@ -82,14 +72,12 @@
                msg[3].value = data.baseInfo.biAddress
                msg[10].value = data.baseInfo.biContact
                msg[11].value = data.baseInfo.biTelephone
                msg[12].value = data.baseInfo.biTownName == null ? [] :
                [
                  data.baseInfo.biProvinceName, data.baseInfo.biCityName, data.baseInfo.biDistrictName, data.baseInfo.biTownName,
                  data.baseInfo.biProvinceCode, data.baseInfo.biCityCode, data.baseInfo.biDistrictCode, data.baseInfo.biTownCode,
                msg[12].value = data.baseInfo.biTownName == null ? [] : [
                  data.baseInfo.biProvinceName, data.baseInfo.biCityName, data.baseInfo.biDistrictName, data.baseInfo.biTownName,
                  data.baseInfo.biProvinceCode, data.baseInfo.biCityCode, data.baseInfo.biDistrictCode, data.baseInfo.biTownCode,
                ]
                msg[12].displayValue = data.baseInfo.biTownName == null ? [] :
                [
                  data.baseInfo.biProvinceName, data.baseInfo.biCityName, data.baseInfo.biDistrictName, data.baseInfo.biTownName,
                msg[12].displayValue = data.baseInfo.biTownName == null ? [] : [
                  data.baseInfo.biProvinceName, data.baseInfo.biCityName, data.baseInfo.biDistrictName, data.baseInfo.biTownName,
                ]
              }
              if (data.specialInfo != null) {
@@ -103,7 +91,7 @@
                    if (v == o.name) {
                      o.checked = true
                      break
                    }else if (o.hasRemark) {
                    } else if (o.hasRemark) {
                      o.checked = true
                      o.remark += v
                    }
@@ -137,7 +125,7 @@
                    if (v == o.name) {
                      o.checked = true
                      break
                    }else if (o.hasRemark) {
                    } else if (o.hasRemark) {
                      o.checked = true
                      o.remark += v
                    }
@@ -166,6 +154,23 @@
                  }
                }
              })
              ledgerservice.getLedgerDetail(
                app.globalData.accessToken.userId, that.data.ledger.ledgerSubTypeId, that.data.ledger.sceneType, undefined, {
                  success(res) {
                    if (res.length > 0) {
                      let detail = res[0]
                      if (detail.upLoad) {
                        let imgFiles = [{
                          url: detail.path1[0],
                          loading: false
                        }]
                        that.setData({
                          imgFiles
                        })
                      }
                    }
                  }
                })
              break;
            case '2':
@@ -193,13 +198,15 @@
            msg
          })
        }
      })
      }, app.globalData.accessToken.openId)
    },
    //提交场景信息
    submit() {
    _submit() {
      var that = this
      this.setData({loading: true})
      this.setData({
        loading: true
      })
      //针对不同场景,数据结构会有不同的定制需求
      switch (this.data.sceneType) {
        case '1':
@@ -227,7 +234,34 @@
    //提交图片信息
    submintLedger() {
      this._uploadLedger()
      if (this.data.imgFiles.length == 0) {
        this.setData({
          loading: false
        })
        wx.navigateBack({
          delta: 1,
        })
        return
      }
      if (this.data.imgFiles[0].url.indexOf('http') != -1) {
        wx.downloadFile({
          url: this.data.imgFiles[0].url,
          success: (res) => {
            const imgPath = res.tempFilePath
            this.data.imgFiles[0].url = imgPath
            this._uploadLedger()
          }
        })
      } else {
        this._uploadLedger()
      }
    },
    //上传完成后,回退
    _success(res) {
      wx.navigateBack({
        delta: 1,
      })
    }
  }
})