liangjin
2021-04-04 6ab8cacad8580c7d297609d6583b46b89310ff6f
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
<!--
 * @Author: 小明丶
 * @Date: 2020-11-27 09:14:20
 * @LastEditors: 小明丶
 * @LastEditTime: 2020-12-10 09:36:40
 * @Description: 商户收款支付结果页面
-->
<template>
  <div class="payResult-page">
    <van-nav-bar
      title="支付结果"
      left-text="返回"
      left-arrow
      @click-left="onClickLeft"
      style="line-height: 43px"
    >
      <i
        class="iconfont iconzuojiantou"
        slot="left"
        style="font-size: 25px"
      ></i>
    </van-nav-bar>
    <div class="result">
      <img
        src="../../../../assets/img/支付成功.png"
        alt=""
        v-show="status == 1"
      />
      <img
        src="../../../../assets/img/支付中.png"
        alt=""
        v-show="status == 0"
      />
      <img src="../../../../assets/img/超时.png" alt="" v-show="status == 2" />
      <p>{{ text }}</p>
    </div>
    <div class="btn-box" v-show="status != 0">
      <button
      class="getQrCode"
      @click="goback"
      :style="{ background: $store.state.backColor, color: '#fff' }"
    >
      返回
    </button>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      timeId:'',
      status: 0,
      text: "用户支付中,请稍后",
    };
  },
  created() {
    if(this.$route.query.needSearch == 1){
      this.timeId = setInterval(() => {
        this.search()
      }, 2000);
    }else{
      this.search_status()
    }
    
  },
  methods: {
    // 轮询 支付状态
    search_status() {
      let status = this.$route.query.orderStatus
      this.status = status
      console.log(this.status,status)
        if(status==0){
          this.text = '用户支付中,请稍后'
        }else if(status==1){
          this.text = '用户支付成功'
        }else{
          this.text = '用户支付失败,请重试'
        }
    },
    search(){
      this.$api.facepay_getStatus(
       this.$route.query.orderId
      ).then((res) => {
        let orderStatus = res.body.orderStatus;
        this.status = orderStatus
        if(orderStatus == 0){
          this.text = '用户支付中,请稍后'
        }else if(orderStatus == 1){
          this.text = '用户支付成功'
          clearInterval(this.timeId);
        }else{
          this.text = '用户支付失败,请重试'
          clearInterval(this.timeId);
        }
      });
    },
    goback(){
      this.$router.push('/main/product')
    }
  },
  beforeRouteLeave(to, from, next) {
    clearInterval(this.timeId);
    next();
  },
};
</script>
<style lang="less" scoped>
.payResult-page {
  & {
    min-height: 100vh;
    background: #f5f5f5;
  }
  .result {
    & {
      width: 359px;
      height: 190px;
      background: #ffffff;
      border-radius: 3px;
      margin: auto;
      margin-top: 10px;
      text-align: center;
      box-sizing: border-box;
      padding: 32px 0;
    }
    img {
      width: 95px;
      height: 95px;
      margin-bottom: 16px;
    }
  }
  .btn-box{
    text-align: center;
  }
  .getQrCode {
    width: 320px;
    height: 44px;
    outline: none;
    border-radius: 22px;
    border: 0;
    margin-top: 42px;
  }
}
</style>