coupon.vue 6.15 KB
<template>
  <div>
    <img :src="imgurl" alt="" style="margin: 10px auto;width: 64px;height: 64px;">
    <div style="padding: 10px 30px 50px">
      <p>尊敬的车主您好:{{ tipText }}</p>
    </div>
    <div style="padding: 0 20px">
      <mt-button size="large" type="primary" @click="toPay" style="margin-bottom: 20px;" v-show="payFlag">去支付停车费用
      </mt-button>
      <mt-button size="large" type="danger" @click="toBackPage">返回</mt-button>
    </div>

  </div>
</template>

<script>


import {
  scanCouponQR,
  queryParkingRecordPageByCarNumbers,
  appApplyParkOut,
  parkingQuery
} from '@/api/couponPay/couponPay.js'

export default {
  name: "coupon",
  data() {
    return {
      imgurl: '',
      successiconUrl: require('../../assets/images/successIcon.png'),
      loseiconUrl: require('../../assets/images/loseIcon.png'),
      carNum: '',
      carNumberColor: '',
      parkingData: [],
      carType: '',
      codeType: '',
      tipText: '',
      payFlag: true,
    }
  },
  created() {
    this.carNum = this.$route.query.carNumber
    this.carType = this.$route.query.carType
    this.codeType = this.$route.query.codeType
    this.cardRelParkNo = this.$route.query.cardRelParkNo
    // this.carNum = this.$route.query.carNumber  // 获取车牌号
    // this.carNumberColor = this.$route.query.carNumberColor  // 获取颜色   0:蓝牌;1:黄牌;2:白牌;3:黑牌;4:绿色
    // this.currentTabActive = this.$route.query.parkFlag ? this.$route.query.parkFlag : 0
    // console.log(this.currentTabActive)
    // console.log(this.carNumber)
    this.scanCouponQR()
  },
  methods: {
    scanCouponQR() {

      let url = process.env.VUE_APP_API;
      console.log(url)
      var salt = this.$utils.myCommonSalt(32);
      var jsondata = {
        app_id: this.$utils.myVarAppid,
        deviceInfo: this.$utils.myDeviceInfo,
        salt: salt,
        sign_type: "md5",
        carType: '2',
        codeType: this.codeType,
        cardRelParkNo: this.cardRelParkNo,
        key: this.$route.query.key,
        carNum: this.carNum,
        // carNumberColor: this.carNumberColor,
        orgId: this.$utils.myOrgId,
        terminalSource: '7',
        // token:'e2c1e43722dd43a5b7e268001b39e6f0'
      }
      jsondata.sign = this.$utils.signObject(jsondata)
      console.log(jsondata)
      scanCouponQR(url,jsondata).then(response => {
        console.log(response)

        if (response.code == 0) {
          this.payFlag = true
          this.imgurl = this.successiconUrl
          this.tipText = '领取优惠券成功'
        } else {
          this.payFlag = true
          this.imgurl = this.loseiconUrl
          this.tipText = response.message
        }
        // this.tipText =
      })
    },
    toPay() {
      this.parkRecordList()
      // this.$router.push({
      //   path: 'couponPay'
      // })
    },
    toBackPage() {
      this.$router.back()
    },
    parkRecordList() {  // 获取停车记录数据
      let url = process.env.VUE_APP_PAYAPI;
      var salt = this.$utils.myCommonSalt(32);
      var jsondata = {
        app_id: this.$utils.myVarAppid,
        deviceInfo: this.$utils.myDeviceInfo,
        salt: salt,
        sign_type: "md5",
        pageNum: '1',
        pageSize: '1000',
        parkState: '10',
        terminalSource: '3',
        // parkState:'10',
        carNumber: this.carNum,
        // carNumberColor: '1',
        orgId: this.$utils.myOrgId,

      }
      jsondata.sign = this.$utils.signObject(jsondata)


      // jsondata.sign = md5sign
      console.log('停车记录传参  ' + JSON.stringify(jsondata));
      queryParkingRecordPageByCarNumbers(url,jsondata).then(response => {
        console.log(response)
        // this.parkList = response.data.dataList

        this.parkingData = response.data.dataList.filter(item => {
          return item.parkState == '10'
        })
        console.log(this.parkingData)
        this.toPayCurrent(this.parkingData)

      })
    },
    toPayCurrent(i) { // 缴纳本次在停费用
      let url = process.env.VUE_APP_PAYAPI;
      var salt = this.$utils.myCommonSalt(32);
      var params = {
        app_id: this.$utils.myVarAppid,
        deviceInfo: this.$utils.myDeviceInfo,
        salt: salt,
        sign_type: "md5",
        orderId: i[0].orderId,
        payOrderType: '101',
        terminalSource: '3',
      }
      params.sign = this.$utils.signObject(params)
      appApplyParkOut(url,params).then(response => {
        console.log(response)

        if (response.code == '5005') {
          var salt = this.$utils.myCommonSalt(32);
          var jsondata = {
            app_id: this.$utils.myVarAppid,
            deviceInfo: this.$utils.myDeviceInfo,
            salt: salt,
            sign_type: "md5",
            payType: this.$utils.clientBrowsePayType(),
            appId: this.$utils.myVxAppId,
            orderId: i[0].orderId,
            terminalSource: '7',
            parkCode: i[0].parkCode,
            carNumber: this.carNum,
          }
          jsondata.sign = this.$utils.signObject(jsondata)
          parkingQuery(url,jsondata).then(result => {
            console.log(result)
            let res = result.data
            let _dis = res.discountFee
            let discountFee = _dis.slice(1, _dis.length - 1)
            sessionStorage.setItem('couponPark', JSON.stringify(result.data))
            this.$router.push(
              {
                path: 'couponPay',
                query: {
                  carColor: this.carColor,// 车牌颜色
                  arrearageTotalFee: res.orderTotalFee,// 应收
                  arrearageDiscFee: discountFee * 100,// 优惠
                  arrearageActFee: res.orderFee,// 实收
                  carNumber: this.carNumber, // 车牌
                  paySrcType: 101, //支付的类型   101 是本次   103是历史欠费
                  ordeID: i.orderId, //支付的订单号
                  appOrderTimeout: res.appOrderTimeout, // 超时描述
                }
              }
            )
          })

        } else {
          //$('.dialog-out').show()
          this.$msgbox('提示', '停车15分钟内无需缴费,申请成功。')
        }

      })

    },
  }
};
</script>

<style scoped>

</style>