payStatus.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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="btns">
  9. <view class="btn_1" @click="handleClickBtn">{{ status === '1' ? '返回主页' : '重新支付' }}</view>
  10. <view class="btn_2" v-if="status === '1'" @click="handleGoDetail">查看详情</view>
  11. </view>
  12. </view>
  13. </template>
  14. <script>
  15. export default {
  16. data() {
  17. return {
  18. id: '',
  19. // 支付状态
  20. status: '',
  21. // 订单进度模版id
  22. templateOrder: 'c9whRYC3d8ebNI_RdyG2X_1BBDwy2625hHmRWlW5Z9U'
  23. }
  24. },
  25. onLoad(options) {
  26. this.id = options.id
  27. this.status = options.status
  28. },
  29. onUnload() {
  30. this.handleClickBtn()
  31. },
  32. methods: {
  33. // 点击底部按钮回调
  34. handleClickBtn() {
  35. if (this.status === '1') {
  36. // 返回主页
  37. this.getMessage()
  38. } else if (this.status === '2') {
  39. // 重新支付
  40. uni.navigateBack(1)
  41. }
  42. },
  43. handleGoDetail() {
  44. uni.navigateTo({
  45. url: `/pages/orderDetail/orderDetail?id=${this.id}`
  46. })
  47. },
  48. // 订阅消息
  49. getMessage() {
  50. uni.showLoading({
  51. title: '加载中',
  52. mask: true
  53. })
  54. uni.getSetting({
  55. withSubscriptions: true,
  56. success: (res) => {
  57. uni.hideLoading()
  58. // console.log(res)
  59. if (res.subscriptionsSetting[this.templateOrder] !== 'reject') {
  60. uni.requestSubscribeMessage({
  61. tmplIds: [this.templateOrder],
  62. success: (res) => {
  63. // console.log(res)
  64. if (res[this.templateOrder] !== 'reject') {
  65. // console.log('成功')
  66. } else {
  67. // console.log('拒绝2')
  68. }
  69. uni.switchTab({
  70. url: '/pages/home3/home3'
  71. })
  72. },
  73. fail(err) {
  74. console.log(err)
  75. // console.log('拒绝')
  76. }
  77. })
  78. } else {
  79. uni.showModal({
  80. content: '当前没有订阅,是否去设置打开?',
  81. confirmText: '确认',
  82. cancelText: '取消',
  83. success: (res) => {
  84. if (res.confirm) {
  85. uni.openSetting({
  86. success: (res) => {
  87. // this.handleClick()
  88. }
  89. })
  90. } else {
  91. // console.log('失败')
  92. setTimeout(() => {
  93. uni.switchTab({
  94. url: '/pages/home3/home3'
  95. })
  96. }, 1500)
  97. }
  98. }
  99. })
  100. }
  101. }
  102. })
  103. }
  104. }
  105. }
  106. </script>
  107. <style lang="scss" scoped>
  108. .container {
  109. display: flex;
  110. flex-direction: column;
  111. align-items: center;
  112. height: 100vh;
  113. background-color: #fff;
  114. .img {
  115. margin-top: 80rpx;
  116. width: 134rpx;
  117. height: 134rpx;
  118. text-align: center;
  119. }
  120. .status {
  121. margin-top: 40rpx;
  122. font-size: 32rpx;
  123. font-weight: bold;
  124. }
  125. .btns {
  126. position: absolute;
  127. bottom: 75rpx;
  128. display: flex;
  129. justify-content: space-evenly;
  130. width: 100%;
  131. height: 96rpx;
  132. font-size: 32rpx;
  133. .btn_1 {
  134. display: flex;
  135. justify-content: center;
  136. align-items: center;
  137. width: 300rpx;
  138. color: #fff;
  139. border-radius: 64rpx;
  140. background-color: #096562;
  141. }
  142. .btn_2 {
  143. display: flex;
  144. justify-content: center;
  145. align-items: center;
  146. width: 300rpx;
  147. color: #096562;
  148. border: 1rpx solid #096562;
  149. border-radius: 64rpx;
  150. background-color: #fff;
  151. }
  152. }
  153. }
  154. </style>