ViolationQuery.js 3.7 KB
import {
  request
} from "../../request/index.js"
const a = getApp()
Page({
  data: {
    baseUrl: a.globalData.baseUrl,
    statusTop: a.globalData.statusHeight,
    imagesUrl: a.globalData.imagesUrl,
    four: 4,
    msg: '',
    it_cloose: false,
    showMycar:false,
    myCarList:'',
    isMycar:'',
    isMyplate:'',
    isMyFnum:'',
    isMyenum:'',
    showCarType:false,
    typeid:'',
    myCarType:'',
    Type:[
      {
        name:'小型车',
        id:'02'
      },
      {
        name:'大型车',
        id:'01'
      },
      {
        name:'新能源小型车',
        id:'52'
      },
      {
        name:'新能源大型车',
        id:'51'
      },
    ]
  },
  onLoad: function (options) {
    let that = this
    //  console.log(options);
    that.setData({
      // order_id: options.order_id,
    })
    that.myCar()
  },
  onShow: function () {},
  goback() {
    wx.navigateBack()
  },
  gobackhome() {
    wx.switchTab({
      url: '/pages/home/home'
    })
  },
  async myCar() {
    let that = this
    try {
      const {
        data: {
          data
        }
      } = await request({
        url: '/api/Traffic/getMyCarList',
        method:'POST'
      })
      that.setData({
        myCarList:data
      })
    } catch (err) {
       console.log(err);
    }
  },
  showCar(){
    this.setData({
      showMycar:true
    })
  },
  closeCar(){
    this.setData({
      showMycar:false
    })
  },
  // 选中我的车辆
  chooseMycar(e){
    console.log(e.currentTarget.dataset.idx,'选中的车辆')
    let idx = e.currentTarget.dataset.idx
    this.setData({
      isMycar:this.data.myCarList[idx].name,
      isMyplate:this.data.myCarList[idx].pai_name
    })
    this.closeCar()
  },
  // 选择车型
  showType(){
    this.setData({
      showCarType:true
    })
  },
  closeType(){
    this.setData({
      showCarType:false
    })
  },
  chooseType(e){
    let idx = e.currentTarget.dataset.idx
    this.setData({
      myCarType:this.data.Type[idx].name,
      typeid:this.data.Type[idx].id
    })
    this.closeType()
  },
  getFnum(e){
    
    this.setData({
      isMyFnum:e.detail.value
    })
  },
  getenum(e){
    this.setData({
      isMyenum:e.detail.value
    })
  },
  popTest(msg) {
    wx.showToast({
      title: msg,
      icon: 'none', //如果要纯文本,不要icon,将值设为'none'
      duration: 1300
    })
  },
  goLogin() {
    wx.showModal({
      title: '提示',
      content: '您尚未登录,前往登录',
      success: function (res) {
        if (res.confirm) {
          wx.navigateTo({
            // url: '/pages/authorization/authorization'
          })

        } else {
          wx.switchTab({
            url: '/pages/home/home'
          })
        }
      }
    })
  },
  popSuccessTest() {
    wx.showToast({
      title: this.data.msg,
      icon: '', //默认值是success,就算没有icon这个值,就算有其他值最终也显示success
      duration: 1300, //停留时间
    })
  },
  // 前往查询结果
  goRes(){
    let params = {
      hphm:this.data.isMyplate,
      hpzl:this.data.typeid,
      engineno:this.data.isMyenum,
      classno:this.data.isMyFnum
    }
    for(let arr in params){
      if(params[arr] == ''){
        this.popTest('请填写完整参数')
        return false
      }
    }
    this.Search(params)
    // wx.navigateTo({
    //   url: '/pages/ViolationRes/ViolationRes',
    // })
  },
  async Search(p){
    try {
      const {
        data
      } = await request({
        url: '/api/Traffic/select',
        method:'POST',
        data:p
      })
      console.log(data,'查询结果')
    } catch (err) {
      a.popTest(err.msg)
      console.log(err,'报错信息')
    }
  }
})