payStatus.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <template>
  2. <view class="container">
  3. <!-- 图标区域 -->
  4. <img class="img" :src="status === '1' ? '../../static/index/success.png' : '../../static/index/fail.png'" />
  5. <!-- 支付状态区域 -->
  6. <view class="status">{{ status === '1' ? '支付成功' : '支付失败' }}</view>
  7. <!-- 底部按钮区域 -->
  8. <view class="btn" @click="handleClickBtn">{{ status === '1' ? '返回主页' : '重新支付' }}</view>
  9. </view>
  10. </template>
  11. <script>
  12. export default {
  13. data() {
  14. return {
  15. // 支付状态
  16. status: '',
  17. // 订单进度模版id
  18. templateOrder: 'ERU1ZY9IqwNkDxWyFJvo5VSE7ua-wey3SqhZgjqLDtU'
  19. }
  20. },
  21. onLoad(options) {
  22. this.status = options.status
  23. console.log(this.status)
  24. },
  25. onUnload() {
  26. this.handleClickBtn()
  27. },
  28. methods: {
  29. // 点击底部按钮回调
  30. handleClickBtn() {
  31. if (this.status === '1') {
  32. // 返回主页
  33. this.getMessage()
  34. } else if (this.status === '2') {
  35. // 重新支付
  36. uni.navigateBack(1)
  37. }
  38. },
  39. // 订阅消息
  40. getMessage() {
  41. uni.requestSubscribeMessage({
  42. tmplIds: [this.templateOrder],
  43. success: (res) => {
  44. for (let key in res) {
  45. if (res[key] === 'accept') {
  46. uni.showToast({
  47. title: '订阅成功',
  48. icon: 'success',
  49. mask: true
  50. })
  51. }
  52. // else if (res[key] === 'reject') {
  53. // uni.showToast({
  54. // title: '订阅失败',
  55. // icon: 'none',
  56. // mask: true
  57. // })
  58. // }
  59. }
  60. setTimeout(() => {
  61. uni.reLaunch({
  62. url: '/pages/orderManage/orderManage'
  63. })
  64. }, 1500)
  65. },
  66. fail: (res) => {
  67. console.log(2)
  68. console.log(res)
  69. uni.switchTab({
  70. url: '/pages/home/home'
  71. })
  72. }
  73. })
  74. }
  75. }
  76. }
  77. </script>
  78. <style lang="scss" scoped>
  79. .container {
  80. display: flex;
  81. flex-direction: column;
  82. align-items: center;
  83. height: 100vh;
  84. background-color: #fff;
  85. .img {
  86. margin-top: 80rpx;
  87. width: 134rpx;
  88. height: 134rpx;
  89. text-align: center;
  90. }
  91. .status {
  92. margin-top: 40rpx;
  93. font-size: 32rpx;
  94. font-weight: bold;
  95. }
  96. .btn {
  97. position: absolute;
  98. bottom: 75rpx;
  99. display: flex;
  100. justify-content: center;
  101. align-items: center;
  102. width: 710rpx;
  103. height: 96rpx;
  104. font-size: 32rpx;
  105. color: #fff;
  106. border-radius: 64rpx;
  107. background-color: #096562;
  108. }
  109. }
  110. </style>