payStatus.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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(1)
  38. } else if (this.status === '2') {
  39. // 重新支付
  40. uni.navigateBack(1)
  41. }
  42. },
  43. // 查看详情按钮回调
  44. handleGoDetail() {
  45. this.getMessage(2)
  46. },
  47. // 订阅消息 1 代表主页 2代表详情页
  48. getMessage(type) {
  49. uni.showLoading({
  50. title: '加载中',
  51. mask: true
  52. })
  53. uni.getSetting({
  54. withSubscriptions: true,
  55. success: (res) => {
  56. uni.hideLoading()
  57. // console.log(res)
  58. if (res.subscriptionsSetting[this.templateOrder] !== 'reject') {
  59. uni.requestSubscribeMessage({
  60. tmplIds: [this.templateOrder],
  61. success: (res) => {
  62. // console.log(res)
  63. if (res[this.templateOrder] !== 'reject') {
  64. // console.log('成功')
  65. } else {
  66. // console.log('拒绝2')
  67. }
  68. if (type == 1) {
  69. uni.switchTab({
  70. url: '/pages/home3/home3'
  71. })
  72. } else if (type == 2) {
  73. uni.navigateTo({
  74. url: `/pages/orderDetail/orderDetail?id=${this.id}`
  75. })
  76. }
  77. },
  78. fail(err) {
  79. console.log(err)
  80. // console.log('拒绝')
  81. }
  82. })
  83. } else {
  84. uni.showModal({
  85. content: '当前没有订阅,是否去设置打开?',
  86. confirmText: '确认',
  87. cancelText: '取消',
  88. success: (res) => {
  89. if (res.confirm) {
  90. uni.openSetting({
  91. success: (res) => {
  92. this.handleClickBtn()
  93. }
  94. })
  95. } else {
  96. // console.log('失败')
  97. setTimeout(() => {
  98. if (type == 1) {
  99. uni.switchTab({
  100. url: '/pages/home3/home3'
  101. })
  102. } else if (type == 2) {
  103. uni.navigateTo({
  104. url: `/pages/orderDetail/orderDetail?id=${this.id}`
  105. })
  106. }
  107. }, 1500)
  108. }
  109. }
  110. })
  111. }
  112. }
  113. })
  114. }
  115. }
  116. }
  117. </script>
  118. <style lang="scss" scoped>
  119. .container {
  120. display: flex;
  121. flex-direction: column;
  122. align-items: center;
  123. height: 100vh;
  124. background-color: #fff;
  125. .img {
  126. margin-top: 80rpx;
  127. width: 134rpx;
  128. height: 134rpx;
  129. text-align: center;
  130. }
  131. .status {
  132. margin-top: 40rpx;
  133. font-size: 32rpx;
  134. font-weight: bold;
  135. }
  136. .btns {
  137. position: absolute;
  138. bottom: 75rpx;
  139. display: flex;
  140. justify-content: space-evenly;
  141. width: 100%;
  142. height: 96rpx;
  143. font-size: 32rpx;
  144. .btn_1 {
  145. display: flex;
  146. justify-content: center;
  147. align-items: center;
  148. width: 300rpx;
  149. color: #fff;
  150. border-radius: 64rpx;
  151. background-color: #096562;
  152. }
  153. .btn_2 {
  154. display: flex;
  155. justify-content: center;
  156. align-items: center;
  157. width: 300rpx;
  158. color: #096562;
  159. border: 1rpx solid #096562;
  160. border-radius: 64rpx;
  161. background-color: #fff;
  162. }
  163. }
  164. }
  165. </style>