payStatus.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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. }
  18. },
  19. onLoad(options) {
  20. this.status = options.status
  21. console.log(this.status)
  22. },
  23. onUnload() {
  24. this.handleClickBtn()
  25. },
  26. methods: {
  27. // 点击底部按钮回调
  28. handleClickBtn() {
  29. if (this.status === '1') {
  30. // 返回主页
  31. this.getMessage()
  32. } else if (this.status === '2') {
  33. // 重新支付
  34. uni.navigateBack(1)
  35. }
  36. },
  37. // 订阅消息
  38. getMessage() {
  39. uni.requestSubscribeMessage({
  40. tmplIds: [this.templateOrder],
  41. success: (res) => {
  42. for (let key in res) {
  43. if (res[key] === 'accept') {
  44. uni.showToast({
  45. title: '订阅成功',
  46. icon: 'success',
  47. mask: true
  48. })
  49. } else if (res[key] === 'reject') {
  50. uni.showToast({
  51. title: '订阅失败',
  52. icon: 'none',
  53. mask: true
  54. })
  55. }
  56. }
  57. setTimeout(() => {
  58. uni.switchTab({
  59. url: '/pages/home/home'
  60. })
  61. }, 1500)
  62. },
  63. fail: (res) => {
  64. console.log(2)
  65. console.log(res)
  66. uni.switchTab({
  67. url: '/pages/home/home'
  68. })
  69. }
  70. })
  71. }
  72. }
  73. }
  74. </script>
  75. <style lang="scss" scoped>
  76. .container {
  77. display: flex;
  78. flex-direction: column;
  79. align-items: center;
  80. height: 100vh;
  81. background-color: #fff;
  82. .img {
  83. margin-top: 80rpx;
  84. width: 134rpx;
  85. height: 134rpx;
  86. text-align: center;
  87. }
  88. .status {
  89. margin-top: 40rpx;
  90. font-size: 32rpx;
  91. font-weight: bold;
  92. }
  93. .btn {
  94. position: absolute;
  95. bottom: 75rpx;
  96. display: flex;
  97. justify-content: center;
  98. align-items: center;
  99. width: 710rpx;
  100. height: 96rpx;
  101. font-size: 32rpx;
  102. color: #fff;
  103. border-radius: 64rpx;
  104. background-color: #096562;
  105. }
  106. }
  107. </style>