surePay.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <template>
  2. <!-- 确认支付页面 -->
  3. <view class="sure-pay-home">
  4. <view class="image" v-if="payStatus==0">
  5. <image src="../../static/image/pay.png" mode=""></image>
  6. <view class="text">
  7. 正在支付请稍后
  8. </view>
  9. </view>
  10. <view class="image" v-if="payStatus==1">
  11. <image src="../../static/image/paysuccess.png" mode=""></image>
  12. <view class="text">
  13. 支付成功,即将跳转吸氧页面
  14. </view>
  15. <view class="num">
  16. {{count}}s
  17. </view>
  18. <view class="submit" @click="skipNew()">
  19. 立即跳转
  20. </view>
  21. </view>
  22. <view class="image" v-if="payStatus==2">
  23. <image src="../../static/image/payfail.png" mode=""></image>
  24. <view class="text">
  25. 支付失败
  26. </view>
  27. </view>
  28. </view>
  29. </template>
  30. <script>
  31. var app = getApp()
  32. export default {
  33. data() {
  34. return {
  35. payStatus: '',
  36. count: 5,
  37. order_no: '',
  38. downtime:''
  39. }
  40. },
  41. onLoad(options) {
  42. let that=this
  43. console.log(options)
  44. this.order_no = options.order_no
  45. let params = {
  46. order_no: options.order_no
  47. // order_no: 'O20210419161056350041'
  48. }
  49. this.surePay(params)
  50. },
  51. methods: {
  52. //立即跳转
  53. skipNew: function() {
  54. clearInterval(this.downtime)
  55. uni.reLaunch({
  56. url: './order?order_no=' + this.order_no
  57. })
  58. },
  59. surePay: function(params) {
  60. let that = this
  61. app.request('/order', params, 'get').then(res => {
  62. console.log(res, '确认您订单')
  63. this.payStatus = res.data.data.pay_status
  64. if (this.payStatus == 0) {
  65. console.log(this.payStatus, 'ppppp')
  66. setInterval(function() {
  67. console.log('0000')
  68. that.surePay()
  69. }, 5000);
  70. } else if (this.payStatus == 1) {
  71. this.downtime = setInterval(function() {
  72. that.count--
  73. console.log(that.count, '+++++++++++')
  74. if (that.count == 0) {
  75. clearInterval(that.downtime)
  76. uni.reLaunch({
  77. url: './order?order_no=' + that.order_no
  78. })
  79. }
  80. }, 1000);
  81. }
  82. })
  83. }
  84. }
  85. }
  86. </script>
  87. <style lang="scss" scoped>
  88. .sure-pay-home {
  89. height: 100vh;
  90. background-color: #FFFFFF;
  91. .image {
  92. text-align: center;
  93. image {
  94. margin-top: 40%;
  95. height: 150upx;
  96. width: 150upx;
  97. }
  98. .text {
  99. margin-top: 50upx;
  100. font-size: 30upx;
  101. }
  102. .num {
  103. font-size: 30upx;
  104. color: $mine-background-color;
  105. font-weight: 500;
  106. }
  107. .submit {
  108. background-color: $mine-background-color;
  109. width:400upx;
  110. color: #FFFFFF;
  111. margin: 0 auto;
  112. height: 80upx;
  113. line-height: 80upx;
  114. // padding: 20upx;
  115. font-size: 26upx;
  116. border-radius: 20upx;
  117. margin-top: 50upx;
  118. }
  119. }
  120. }
  121. </style>