pay-success.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. <template>
  2. <view class="pay-result">
  3. <!-- 提示图标 -->
  4. <view class="tip-icon">
  5. <image class="icon" :src="staticUrl + 'icon-pay-success.png'"></image>
  6. <view class="tip">订单支付成功~~</view>
  7. </view>
  8. <!-- 支付金额 -->
  9. <view class="payAmount">
  10. <text class="label">支付金额:</text>
  11. <text class="price">¥{{ orderInfo.payableAmount | priceFormat }}</text>
  12. </view>
  13. <!-- 执行操作 -->
  14. <view class="control">
  15. <tui-button
  16. type="base"
  17. width="600rpx"
  18. height="90rpx"
  19. shape="circle"
  20. :size="28"
  21. @click="toBuy"
  22. v-if="!hasOtherSplitOrder"
  23. >
  24. 继续购买
  25. </tui-button>
  26. <tui-button type="base" width="600rpx" height="90rpx" shape="circle" :size="28" @click="toRePay" v-else>
  27. 继续支付
  28. </tui-button>
  29. <tui-button
  30. type="base"
  31. :plain="true"
  32. width="600rpx"
  33. height="90rpx"
  34. shape="circle"
  35. :size="28"
  36. @click="onSearch"
  37. >
  38. 查看订单
  39. </tui-button>
  40. <view class="share">
  41. <view v-if="canShare" @click="onShare"><text class="btn-tip">点击分享可获得优惠券领取资格</text></view>
  42. </view>
  43. </view>
  44. <!-- 分享 -->
  45. <cm-share-popup ref="sharePopup" :data="posterData" type="normal" @share="onAfterShare"></cm-share-popup>
  46. </view>
  47. </template>
  48. <script>
  49. import { fetchCouponDisplay } from '@/services/api/coupon.js'
  50. import { orderShare, fetchOrderDetail } from '@/services/api/order.js'
  51. import { queryStringify } from '@/common/utils.js'
  52. import { mapGetters } from 'vuex'
  53. export default {
  54. data() {
  55. return {
  56. orderInfo: {},
  57. mapStateArr: [11, 12, 13, 21, 22, 23, 111],
  58. orderDetail: {},
  59. couponTipStr: '',
  60. posterData: {}
  61. }
  62. },
  63. computed: {
  64. ...mapGetters(['userId']),
  65. hasOtherSplitOrder() {
  66. return this.mapStateArr.includes(parseInt(this.orderDetail.status))
  67. },
  68. canShare() {
  69. return this.orderInfo.shareFlag === 1 && this.couponTipStr.indexOf('3') > -1
  70. }
  71. },
  72. beforeDestroy() {
  73. uni.removeStorageSync('PAY_ORDER_INFO')
  74. },
  75. onLoad() {
  76. this.orderInfo = uni.getStorageSync('PAY_ORDER_INFO')
  77. this.getOrderDetail()
  78. this.fetchCouponDisplay()
  79. },
  80. onShareAppMessage() {
  81. // 加密
  82. const state_str = encodeURIComponent(this.$crypto.encrypt({ type: 0 }))
  83. return {
  84. title: '护肤上颜选,正品有好货~',
  85. path: `/pages/index/index?state_str=${state_str}`,
  86. imageUrl: this.staticUrl + 'icon-share.png'
  87. }
  88. },
  89. methods: {
  90. // 分享结束
  91. async onAfterShare() {
  92. try {
  93. await orderShare({ orderId: this.orderInfo.orderId, userId: this.userId })
  94. this.$toast('分享成功')
  95. } catch (e) {
  96. this.$toast('分享失败')
  97. }
  98. },
  99. // 分享
  100. onShare() {
  101. this.posterData = { query: queryStringify({ type: 0 }) }
  102. this.$refs.sharePopup.open()
  103. },
  104. // 获取可领取优惠券类型
  105. async fetchCouponDisplay() {
  106. try {
  107. const res = await fetchCouponDisplay({ userId: this.userId })
  108. this.couponTipStr = res.data
  109. } catch (e) {
  110. console.log('获取优惠券类型失败')
  111. }
  112. },
  113. // 继续购买
  114. toBuy() {
  115. this.$router.switchTab('home')
  116. },
  117. // 订单列表
  118. onSearch() {
  119. this.$router.redirectTo(`order/order-detail?orderId=${this.orderInfo.orderId}`)
  120. },
  121. // 继续支付
  122. toRePay() {
  123. this.$router.redirectTo(`order/order-pay?orderId=${this.orderInfo.orderId}`)
  124. },
  125. // 获取订单支付列表
  126. async getOrderDetail() {
  127. try {
  128. const { data } = await fetchOrderDetail({ orderId: this.orderInfo.orderId })
  129. this.orderDetail = data.order
  130. } catch (e) {
  131. console.log('获取订单信息失败')
  132. console.log(e)
  133. }
  134. }
  135. }
  136. }
  137. </script>
  138. <style lang="scss" scoped>
  139. .pay-result {
  140. height: 100vh;
  141. .tip-icon {
  142. @extend .cm-flex-center;
  143. flex-direction: column;
  144. background-color: #fff;
  145. height: 340rpx;
  146. .icon {
  147. width: 210rpx;
  148. height: 210rpx;
  149. }
  150. .tip {
  151. margin-top: 24rpx;
  152. font-size: 28rpx;
  153. font-weight: bold;
  154. color: #666;
  155. }
  156. }
  157. .payAmount {
  158. @extend .cm-flex-between;
  159. height: 90rpx;
  160. padding: 0 24rpx;
  161. margin-top: 24rpx;
  162. background-color: #fff;
  163. font-size: 28rpx;
  164. .label {
  165. color: #333333;
  166. }
  167. .price {
  168. color: #666666;
  169. }
  170. }
  171. .control {
  172. @extend .cm-flex-between;
  173. flex-direction: column;
  174. height: 310rpx;
  175. margin-top: 150rpx;
  176. .share {
  177. height: 90rpx;
  178. line-height: 90rpx;
  179. text-align: center;
  180. color: #ff457b;
  181. .btn-tip {
  182. font-size: 24rpx;
  183. }
  184. }
  185. }
  186. }
  187. </style>