share-buy-success.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <template>
  2. <view class="share-buy-success">
  3. <!-- 拼单信息 && 拼单成功 -->
  4. <view class="message">恭喜您拼单成功!</view>
  5. <share-buy-member-info
  6. :hasShopInfo="false"
  7. :memberNum="collageData.memberNum"
  8. :existNum="collageData.existNum"
  9. :shopInfo="collageData"
  10. ></share-buy-member-info>
  11. <view class="control">
  12. <tui-button type="base" width="600rpx" height="90rpx" shape="circle" :size="30" @click="handleToHome">
  13. <text>去首页逛逛</text>
  14. </tui-button>
  15. <view class="line"></view>
  16. <tui-button
  17. type="base"
  18. width="600rpx"
  19. height="90rpx"
  20. shape="circle"
  21. :plain="true"
  22. :size="30"
  23. @click="handleToOrderDetail"
  24. >
  25. <text>查看订单详情</text>
  26. </tui-button>
  27. <view class="share">
  28. <view v-if="canShare" @click="onShare"><text class="btn-tip">点击分享可获得优惠券领取资格</text></view>
  29. </view>
  30. </view>
  31. <!-- 分享 -->
  32. <cm-share-popup ref="sharePopup" :data="posterData" type="normal" @share="onAfterShare"></cm-share-popup>
  33. </view>
  34. </template>
  35. <script>
  36. import { orderShare } from '@/services/api/order.js'
  37. import { fetchCouponDisplay } from '@/services/api/coupon.js'
  38. import { mapGetters } from 'vuex'
  39. export default {
  40. data() {
  41. return {
  42. collageData: {},
  43. posterData: {},
  44. couponTipStr: ''
  45. }
  46. },
  47. computed: {
  48. ...mapGetters(['userId']),
  49. canShare() {
  50. return this.collageData.shareFlag === 1 && this.couponTipStr.indexOf('3') > -1
  51. }
  52. },
  53. onLoad() {
  54. this.collageData = uni.getStorageSync('SHARE_BUY_COLLAGE_DATA')
  55. this.fetchCouponDisplay()
  56. },
  57. beforeDestroy() {
  58. uni.removeStorageSync('SHARE_BUY_COLLAGE_DATA')
  59. },
  60. methods: {
  61. // 去首页
  62. handleToHome() {
  63. this.$router.switchTab('home')
  64. },
  65. // 查看订单详情
  66. handleToOrderDetail() {
  67. this.$router.navigateTo('order/order-detail?orderId=' + this.collageData.orderId)
  68. },
  69. // 获取可领取优惠券类型
  70. async fetchCouponDisplay() {
  71. try {
  72. const res = await fetchCouponDisplay({ userId: this.userId })
  73. this.couponTipStr = res.data
  74. } catch (e) {
  75. console.log('获取优惠券类型失败')
  76. }
  77. },
  78. // 分享结束
  79. async onAfterShare() {
  80. try {
  81. await orderShare({ orderId: this.collageData.orderId, userId: this.userId })
  82. this.$toast('分享成功')
  83. } catch (e) {
  84. this.$toast('分享失败')
  85. }
  86. }
  87. }
  88. }
  89. </script>
  90. <style lang="scss" scoped>
  91. .share-buy-success {
  92. background-color: #fff;
  93. padding: 32rpx 0;
  94. .message {
  95. font-size: 34rpx;
  96. color: #ff457b;
  97. font-weight: bold;
  98. text-align: center;
  99. }
  100. .control {
  101. @extend .cm-flex-center;
  102. flex-direction: column;
  103. .line {
  104. height: 24rpx;
  105. }
  106. .share {
  107. height: 90rpx;
  108. line-height: 90rpx;
  109. text-align: center;
  110. color: #ff457b;
  111. .btn-tip {
  112. font-size: 24rpx;
  113. }
  114. }
  115. }
  116. }
  117. </style>