index.js 6.97 KB
const util = new window.publicMethod() ;

const citys = {
  '南京市': ['玄武区', '秦淮区', '建邺区', '鼓楼区', '浦口区', '栖霞区', '雨花台区', '江宁区', '六合区', '溧水区', '高淳区'],
  '苏州市': ['姑苏区', '吴中区', '相城区', '虎丘区', '吴江区', '新区', '经开区', '昆山市', '常熟市', '张家港市', '太仓市', '苏州工业园区'],
  '扬州市': ['广陵区', '邗江区', '江都区', '宝应县', '高邮市', '仪征市'],
  '无锡市': ['梁溪区', '锡山区', '惠山区', '滨湖区', '新吴区', '江阴市', '宜兴市'],
  '徐州市': ['鼓楼区', '云龙区', '贾汪区', '泉山区', '铜山区', '丰县', '沛县', '睢宁县', '邳州市', '新沂市'],
  '常州市': ['天宁区', '钟楼区', '新北区', '武进区', '金坛区', '溧阳市'],
  '连云港市': ['海州区', '连云区', '赣榆区', '东海县', '灌云县', '灌南县'],
  '淮安市': ['清江浦区', '淮阴区', '淮安区', '洪泽区', '涟水县', '盱眙县', '金湖县'],
  '盐城市': ['亭湖区', '盐都区', '盐开区','大丰区', '响水县', '滨海县', '阜宁县', '射阳县', '建湖县','东台市'],
  '南通市': ['崇川区', '通州区', '海门区', '如东县', '启东市', '如皋市', '海安市'],
  '泰州市': ['海陵区', '高港区', '姜堰区', '兴化市', '靖江市', '泰兴市'],
  '宿迁市': ['宿城区', '宿豫区', '沭阳县', '泗阳县', '泗洪县'],
};

new Vue({
  el: '#pageDiv',
  data: {
    tarr: ['精准高效','智能检测','实时监控','全程录像'],
    orderFlag: false,

    appParam: {},
    detail: {},

    pickData: {
      isShow: false,

      title: '地区选择',
      arr:[
        {
          values: Object.keys(citys),
          className: 'column1',
          defaultIndex: 0
        },
        {
          values: citys['南京市'],
          className: 'column2',
          defaultIndex: 0
        }
      ],
      nCity: '',
      nArea: '',
      menpai: ''
    },

    fbData:{
      isShow: false,
      confirmFlag: false,

      explain: '',
    },
    reasonPickData: {
      isShow: false,

      title: '原因选择',
      orArr: [],
      arr:[],
      index: 0,
      reason: '个人原因'
    }, 

    noDataFlag: false
  },
  created(){
    this.getReason()

    if(sessionStorage.getItem('huaiAnAppParam')){
      this.appParam = JSON.parse(sessionStorage.getItem('huaiAnAppParam'))

      this.getDetail()
    }else{
      this.appParam = JSON.parse(sessionStorage.getItem('listInfoParam'))

      this.getDetail('init')
    }
  },
  methods: {
    goBack(){
      history.go(-1)
    },
    getReason(){
      util.httpRequest({
        url: '/listEnum',
        middleUrl: '/zhijian-trial/common',
        data: {
          type: 3
        },
      }).then(res=>{
        if(res.code == 200){
          this.reasonPickData.orArr = res.data
          this.reasonPickData.arr = res.data.map(item=>{
            return item.label
          })
        }
      })
    },
    saveFeedback(){
      if(!this.fbData.explain){
        util.toast('请填写具体情况')
        return
      }

      let status = ''
      let p =  this.reasonPickData
      p.orArr.forEach(item=>{
        if(item.label == p.reason){
          status = item.value
        }
      })

      util.httpRequest({
        data: {
          applyId: this.detail.id,
          checkStatus: status,
          failReason: this.fbData.explain
        },
        url: '/unCheck'
      }).then(res=>{
        if(res.code == 200){
          this.getDetail()
          this.fbData.isShow = false
          this.fbData.confirmFlag = false

          util.toast('保存成功')
        }else{
          util.toast(res.msg)
        }
      })
    },
    showCity(){
      let __this = this

      let cIndex = __this.pickData.nCity?Object.keys(citys).indexOf(__this.pickData.nCity):0
      let aIndex = __this.pickData.nArea?(citys[__this.pickData.nCity||'南京市'].indexOf(__this.pickData.nArea)):0

      this.pickData.arr = [
        {
          values: Object.keys(citys),
          className: 'column1',
          defaultIndex: cIndex
        },
        {
          values: citys[__this.pickData.nCity||'南京市'],
          className: 'column2',
          defaultIndex: aIndex
        }
      ]

      this.pickData.isShow = true
    },
    onChange(picker, values) {
      picker.setColumnValues(1, citys[values[0]]);
    },
    onConfirm(value, index) {
      this.pickData.nCity = value[0]
      this.pickData.nArea = value[1]

      this.pickData.isShow = false
    },
    onCancel(){
      this.pickData.isShow = false
    },
    showReason(){
      this.reasonPickData.isShow = true
    },
    reasonCancel(){
      this.reasonPickData.isShow = false
    },
    reasonConfirm(value, index){
      this.reasonPickData.reason = value
      this.reasonPickData.index = index

      this.reasonCancel()
    },
    release(applyId){
      if(!sessionStorage.getItem('haCallId')){
        return
      }
    
      util.httpRequest({
        url: '/releaseConn',
        data: {
          callId: sessionStorage.getItem('haCallId')||'',
          applyId: applyId
        }
      })
    },
    getDetail(source){
      let json = this.appParam
      json.cmcc = source=='init'?true:false
      json.phoneModel = navigator.userAgent.toLowerCase()

      util.httpRequest({
        data: json,
        url: '/getOrderInfo'
      }).then(res=>{
        document.getElementById('pageDiv').style.display = 'block'; // 显示内容
        document.getElementById('loading').style.display = 'none'; // 去掉加载框
        
        if(res.code == 200){
          this.detail = res.data

          let json = {...this.appParam,...{
            address: res.data.addressName,
            applyId: res.data.id,
            campaignId: res.data.campaignId
          }}
          sessionStorage.setItem('huaiAnAppParam',JSON.stringify(json))

          this.release(json.applyId)
        }else if(res.code == '5002'){
          this.noDataFlag = true
        }else{
          util.toast(res.msg)
        }
      })
    },
    orderError(){
      this.orderFlag = true
    },
    feedback(){
      this.fbData.explain = ''
      this.reasonPickData.reason = '个人原因'
      this.reasonPickData.index = 0

      this.fbData.isShow = true
    },
    closeAlert(){
      this.orderFlag = false
    },
    beginTest(){
      if(!this.detail.id){
        util.toast('暂未查询到质检信息,请向技术支持方反馈')
        return
      }

      window.location.href = 'demo.html?time='+ new Date().getTime()
    },
    addOrder(){
      this.orderFlag = false
      window.location.href = 'addOrder.html?time='+ new Date().getTime()
    },
    delOrder(index){
      util.httpRequest({
        data: {
          devicesId: this.detail.devicessList[index].id
        },
        url: '/delDevices'
      }).then(res=>{
        if(res.code == 200){
          util.toast('删除成功')
          this.getDetail()
        }else{
          util.toast(res.msg)
        }
      })
    }
  }
})