CreateOrderLayout.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <template>
  2. <div class="create-order-layout j-container">
  3. <div class="j-header">
  4. <router-view
  5. name="header"
  6. class="create-order-header"
  7. v-if="pageLayout.header"
  8. ></router-view>
  9. </div>
  10. <div class="j-main create-order-content" @scroll="onScroll">
  11. <router-view name="default" class="create-order-default"></router-view>
  12. <router-view
  13. name="activity"
  14. v-if="pageLayout.activity"
  15. class="create-order-activity"
  16. ></router-view>
  17. <router-view name="form" class="create-order-form"></router-view>
  18. <router-view name="adsense" class="create-order-adsense"></router-view>
  19. <router-view name="desc" class="create-order-desc"></router-view>
  20. </div>
  21. <div class="j-footer">
  22. <router-view
  23. v-if="pageLayout.footerNotice"
  24. name="footerNotice"
  25. class="create-order-footer-notice"
  26. ></router-view>
  27. <!-- 使用key避免当前路由页面底部组件不刷新问题 -->
  28. <!-- 主要解决类似<超级订阅>跳转<省份订阅包>时,store的canNextMap重置而底部已读不重置问题。具体问题#32998 -->
  29. <router-view
  30. name="footer"
  31. class="create-order-footer"
  32. :key="productId"
  33. ></router-view>
  34. </div>
  35. <customer-corner v-show="showCustomer" :scroll-status="scrollTop < 60" bottom-position="18%"></customer-corner>
  36. </div>
  37. </template>
  38. <script>
  39. import { mapGetters, mapActions, mapMutations } from 'vuex'
  40. import { openAppOrWxPage } from '@/utils'
  41. import CustomerCorner from '@/components/customer/index'
  42. export default {
  43. name: 'CreateOrderLayout',
  44. components: {
  45. CustomerCorner
  46. },
  47. computed: {
  48. ...mapGetters('createOrder', ['productId', 'pageLayout', 'loadingStatus']),
  49. ...mapGetters('user', [
  50. 'isLogin'
  51. ]),
  52. showCustomer () {
  53. return this.$route.path.indexOf('dataexport') > -1 && this.isLogin
  54. }
  55. },
  56. data() {
  57. return {
  58. loading: null,
  59. scrollTop: 0
  60. }
  61. },
  62. watch: {
  63. '$route.path': {
  64. handler() {
  65. // 页面改变,重置store
  66. this.resetStore()
  67. }
  68. },
  69. loadingStatus: {
  70. deep: true,
  71. handler(n) {
  72. // 此处修复 order-activity-helper.js 中 showToast 不展示问题
  73. const { disabledLoading } = this.pageLayout
  74. if (disabledLoading) return
  75. const { some } = n
  76. if (some) {
  77. this.loading = this.$toast.loading({ duration: 0 })
  78. } else {
  79. this.$nextTick(() => {
  80. this.loading?.clear()
  81. })
  82. }
  83. }
  84. }
  85. },
  86. beforeRouteEnter(to, from, next) {
  87. next((vm) => {
  88. if (vm.$store.state.direction !== 'forward') {
  89. vm.checkRedirect()
  90. }
  91. })
  92. },
  93. methods: {
  94. ...mapMutations('createOrder', ['updateProductIndex']),
  95. ...mapActions('createOrder', ['resetStore']),
  96. // 检查sessionStorage中是否有值。当页面支付返回时进行路由重定向(重定向到指定url)
  97. checkRedirect() {
  98. const options = {
  99. storage: sessionStorage
  100. }
  101. const cacheKey = `${this.$route.path}-redirect`
  102. const { urls, query } = this.$storage.get(cacheKey, {}, options)
  103. this.$storage.rm(cacheKey, options)
  104. if (!urls || !query) return
  105. openAppOrWxPage(urls, {
  106. type: 'replace',
  107. query
  108. })
  109. },
  110. onScroll (e) {
  111. this.scrollTop = e.target.scrollTop
  112. }
  113. }
  114. }
  115. </script>
  116. <style lang="scss" scoped>
  117. .create-order-desc {
  118. padding: 2.133vw 4.267vw;
  119. color: #9b9ca3;
  120. line-height: 5.333vw;
  121. font-size: 3.2vw;
  122. text-align: justify;
  123. }
  124. </style>