paySuccess.vue 2.38 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 60 61 62 63 64 65 66 67
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
      }
      this.$request('order/order/getStatusById', data).then((res) => {
        if (res.code == '00') {
          this.status = res.data
          if (this.status == '2' || this.status == '4' || this.status == '5') {
            //1.跳订单列表,2.订单详情,3.停留该页面显示支付成功(ourPayment页面跳入时,无afterBuyUrl,停留在该页面)
            this.title='支付成功!'
            this.loadImg=false
            uni.redirectTo({
68
							 url:this.afterBuyUrl+'?orderId=' + this.orderId+'&ifyukuaiCode='+this.ifyukuaiCode
潘永坪's avatar
潘永坪 committed
69 70 71 72 73 74 75 76
            })
          }
          if (this.status == '3') {
            this.title = '失败...'
            this.loadImg = false
          }
        } else {
          uni.showToast({
77 78
						  title: res.message,
						  icon: 'none'
潘永坪's avatar
潘永坪 committed
79 80 81 82 83 84
          })
        }
      })
    }
  }
}
潘永坪's avatar
潘永坪 committed
85 86
</script>

87 88 89 90 91 92 93 94 95 96
<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
97
</style>