payStatus.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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.getSetting({
  42. withSubscriptions: true,
  43. success: (res) => {
  44. if (res.subscriptionsSetting[this.templateOrder] !== 'reject') {
  45. uni.requestSubscribeMessage({
  46. tmplIds: [this.templateOrder],
  47. success: (res) => {
  48. if (res[this.templateOrder] !== 'reject') {
  49. console.log('成功')
  50. } else {
  51. console.log('拒绝2')
  52. }
  53. uni.switchTab({
  54. url: '/pages/home/home'
  55. })
  56. },
  57. fail(err) {
  58. console.log('拒绝')
  59. }
  60. })
  61. } else {
  62. uni.showModal({
  63. content: '当前没有订阅,是否去设置打开?',
  64. confirmText: '确认',
  65. cancelText: '取消',
  66. success: (res) => {
  67. if (res.confirm) {
  68. uni.openSetting({
  69. success: (res) => {
  70. this.handleClick()
  71. }
  72. })
  73. } else {
  74. console.log('失败')
  75. setTimeout(() => {
  76. uni.switchTab({
  77. url: '/pages/home/home'
  78. })
  79. }, 1500)
  80. }
  81. }
  82. })
  83. }
  84. }
  85. })
  86. }
  87. }
  88. }
  89. </script>
  90. <style lang="scss" scoped>
  91. .container {
  92. display: flex;
  93. flex-direction: column;
  94. align-items: center;
  95. height: 100vh;
  96. background-color: #fff;
  97. .img {
  98. margin-top: 80rpx;
  99. width: 134rpx;
  100. height: 134rpx;
  101. text-align: center;
  102. }
  103. .status {
  104. margin-top: 40rpx;
  105. font-size: 32rpx;
  106. font-weight: bold;
  107. }
  108. .btn {
  109. position: absolute;
  110. bottom: 75rpx;
  111. display: flex;
  112. justify-content: center;
  113. align-items: center;
  114. width: 710rpx;
  115. height: 96rpx;
  116. font-size: 32rpx;
  117. color: #fff;
  118. border-radius: 64rpx;
  119. background-color: #096562;
  120. }
  121. }
  122. </style>