paySuccess.vue 2.68 KB
Newer Older
潘永坪's avatar
潘永坪 committed
1
<template>
2 3 4 5
		<view class="wrap">
			<text style="margin-right: 20rpx;">
				{{title}}
			</text>
潘永坪's avatar
潘永坪 committed
6
			<image src="../../../static/img/common/loading.gif" v-if="loadImg" style="width: 36rpx;height: 36rpx;">
7 8 9
				
			</image>
		</view>
潘永坪's avatar
潘永坪 committed
10 11 12
</template>

<script>
潘永坪's avatar
潘永坪 committed
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
export default {
  data() {
    return {
      title: '', //标题
      orderId: '', //订单Id
      status: '', //出票状态
      timer: '', //计时器
      loadImg: true, //控制加载图片显示隐藏
      afterBuyUrl:'',//页面跳转地址
      ifyukuaiCode: '' //是否是渝快码跳入,渝快码跳入需要在H5端另外走流程
    }
  },
  onLoad(option) {
    this.orderId = option.orderId||''
    this.afterBuyUrl = option.afterBuyUrl||''
    this.ifyukuaiCode=option.ifyukuaiCode||''
    this.ticketStatus()
    let  intFun=()=>{ //页面初始化
      this.timer = setTimeout(()=>{
        if (this.status == '2' || this.status == '4' || this.status == '5') {
          return
        }
        if (this.status == '3') {
          return
        }
        this.ticketStatus()
        intFun()
      }, 2000)
    }
    intFun()
  },
  onHide() {
    if (this.timer) {
      clearInterval(this.timer)
    }
  },
  onUnload() {
    if (this.timer) {
      clearInterval(this.timer)
    }
  },
  methods: {
    //---出票状态
    ticketStatus() { 
      let data = {
        orderId: this.orderId
      }
潘永坪's avatar
潘永坪 committed
60
      this.$request('order/userOrder/getStatusById', data).then((res) => {
潘永坪's avatar
潘永坪 committed
61
        if (res.code == '00') {
潘永坪's avatar
潘永坪 committed
62
          //如果是组合票,直接跳订单列表页面
潘永坪's avatar
潘永坪 committed
63
          let orderType=res.main.orderType
潘永坪's avatar
潘永坪 committed
64 65 66 67 68 69
          if(orderType=='10'){
            uni.reLaunch({
							 url:this.afterBuyUrl+'?orderId=' + this.orderId+'&ifyukuaiCode='+this.ifyukuaiCode
            })
            return
          }
潘永坪's avatar
潘永坪 committed
70
          this.status = res.main.orderStatus
潘永坪's avatar
潘永坪 committed
71 72 73 74
          if (this.status == '2' || this.status == '4' || this.status == '5') {
            //1.跳订单列表,2.订单详情,3.停留该页面显示支付成功(ourPayment页面跳入时,无afterBuyUrl,停留在该页面)
            this.title='支付成功!'
            this.loadImg=false
潘永坪's avatar
潘永坪 committed
75
            uni.reLaunch({
76
							 url:this.afterBuyUrl+'?orderId=' + this.orderId+'&ifyukuaiCode='+this.ifyukuaiCode
潘永坪's avatar
潘永坪 committed
77 78 79 80 81 82 83 84
            })
          }
          if (this.status == '3') {
            this.title = '失败...'
            this.loadImg = false
          }
        } else {
          uni.showToast({
85 86
						  title: res.message,
						  icon: 'none'
潘永坪's avatar
潘永坪 committed
87 88 89 90 91 92
          })
        }
      })
    }
  }
}
潘永坪's avatar
潘永坪 committed
93 94
</script>

95 96 97 98 99 100 101 102 103 104
<style scoped="scoped">
	.wrap {
		padding-top: 150rpx;
		text-align: center;
		font-size: 36rpx;
		color: #ffbc00;
		display: flex;
		align-items: center;
		justify-content: center;
	}
潘永坪's avatar
潘永坪 committed
105
</style>