zhaoxiaoqiang
2022-11-11 a2a242b8cd3aaebbfea69ca153459b77b0c32c16
1
2
3
4
5
6
7
8
9
10
11
12
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<!--
 * @Author: 小明丶
 * @Date: 2020-06-19 15:59:27
 * @LastEditors: zxq
 * @LastEditTime: 2022-11-11 09:35:55
 * @Description: 支付结果页面
--> 
<template>
  <div class="pay-result-page">
    <v-navbar title="支付结果"></v-navbar>
    <div class="result-box">
      <img :src="url" alt />
      <!-- <img src="../../../static/img/faile.png" alt />
      <img src="../../../static/img/ing.png" alt /> -->
      <p>{{titleText}}</p>
      <p>{{tipText}}</p>
    </div>
    <div class="btn-box">
        <button @click="goBack" v-if="preSettleStatus == 2">返回</button>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      preSettleStatus:'',
      url: "./static/img/ing.png", //图片地址
      titleText: "支付中", //标题文字
      tipText: "正在进行支付,请稍后…", //提示文字
      timer: "" //定时器
    };
  },
  created() {
      this.init()
  },
  methods: {
    init() {
      //判断用户查询哪一个行为的支付结果
      if(this.$route.query.model == 1){
          this.$api.findRepayResult({ repayId: this.$route.query.repayId}).then(res => {
          this.preSettleStatus = res.body.repaySts
          if (res.body.repaySts == 2) {
            this.url = "./static/img/faile.png";
            this.titleText = "支付失败";
            this.tipText = res.body.failMsg;
          }
          if (res.body.repaySts == 1) {
            this.url = "./static/img/success.png";
            this.titleText = "支付成功";
            this.tipText = "支付成功,跳转中请稍后…";
            this.timer = setTimeout(()=>{
                this.goBack()
            },3000)
          }
          if (res.body.repaySts == 0) {
            this.url = "./static/img/ing.png";
            this.titleText = "支付中";
            this.tipText = "正在进行支付,请稍后…"; 
          }
        });
      }
      if(this.$route.query.model == 2){
          this.$api.preSettleStatus({ orderId: this.$route.query.orderId}).then(res => {
              this.preSettleStatus = res.body.status
              if (res.body.status == 2) {
                this.url = "./static/img/faile.png";
                this.titleText = "支付失败";
                this.tipText = res.body.msg;
              }
              if (res.body.status == 1) {
                this.url = "./static/img/success.png";
                this.titleText = "支付成功";
                this.tipText = "支付成功,跳转中请稍后…";
                this.timer = setTimeout(()=>{
                    this.goBack()
                },3000)
              }
              if (res.body.status == 0) {
                  this.url = "./static/img/ing.png";
                  this.titleText = "支付中";
                  this.tipText = "正在进行支付,请稍后…";
                  this.timer = setInterval(()=>{
                      this.init()
                  },3000)
              }
        });
      }
      
    },
    goBack(){
        this.$router.push({
            path:'/order/order-detail',
            query:{id:this.$route.query.orderId}
        })
    }
  },
  beforeDestroy(){
      clearInterval(this.timer)
      clearTimeout(this.timer)
  }
};
</script>
<style lang="less" scoped>
.pay-result-page {
  & {
    min-height: 100vh;
    background: @c-back;
  }
  .result-box {
    & {
      background: #fff;
      text-align: center;
      margin-top: 10px;
      padding: 31px 0 24px;
    }
    img {
      width: 83px;
      height: 81px;
    }
    p:nth-of-type(1) {
      font-size: 16px;
      font-family: PingFang SC;
      font-weight: 500;
      color: rgba(51, 51, 51, 1);
      margin-top: 20px;
    }
    p:nth-of-type(2) {
      font-size: 14px;
      font-family: PingFang SC;
      font-weight: 500;
      color: rgba(153, 153, 153, 1);
      margin-top: 12px;
    }
  }
  .btn-box{
      text-align: center;
      margin-top: 32px;
      button{
          width:320px;
          height:44px;
          background:rgba(81,148,254,1);
          border-radius:22px;
          border: 0;
          outline: none;
          color: #fff;
      }
  }
}
</style>