CreateOrderLayout.vue 3.9 KB

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