Index.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <template><page-meta :root-font-size="fontSize+'px'"></page-meta>
  2. <home-base :show="!special || !special['index/index'] || special['index/index']['editablePage']['editable_page_theme_config']['if_show_footer']==1"><view class="div">
  3. <special-index v-show="special && special['index/index']" :page-path="'index/index'" :item-id="''"></special-index>
  4. <view class="div container" v-show="!special || !special['index/index']">
  5. <home-common-search :from='"home"'></home-common-search>
  6. <index-banner v-if="banners && banners.length > 0" :items="banners"></index-banner>
  7. <index-menu :items="navs"></index-menu>
  8. <index-promotion-list :items="xianshiProducts" title="秒杀" v-if="xianshiProducts && xianshiProducts.length > 0"></index-promotion-list>
  9. <index-article :items="articles"></index-article>
  10. <index-three-ads :items="promotionAds"></index-three-ads>
  11. <index-floor-ads v-if="floorAds" :ad="floorAds[0]"></index-floor-ads>
  12. <index-product-list
  13. :items="goodProducts"
  14. title="热门推荐"
  15. :type="popular"
  16. v-if="goodProducts && goodProducts.length > 0"
  17. ></index-product-list>
  18. <index-floor-ads v-if="floorAds" :ad="floorAds[1]"></index-floor-ads>
  19. <index-product-list
  20. :items="hotProducts"
  21. title="销量排行"
  22. :type="sale"
  23. v-if="hotProducts && hotProducts.length > 0"
  24. ></index-product-list>
  25. <index-floor-ads v-if="floorAds" :ad="floorAds[2]"></index-floor-ads>
  26. <index-product-list
  27. :items="recentlyProducts"
  28. title="新品上架"
  29. :type="recently"
  30. v-if="recentlyProducts && recentlyProducts.length > 0"
  31. ></index-product-list>
  32. <!-- 版权信息 -->
  33. <view class="div copyright" v-if="config">
  34. <view class="div"><text class="a link" href="http://www.beian.gov.cn/portal/registerSystemInfo" target="_blank">{{config.wab_number}}</text></view>
  35. <view class="div"><text class="a link" href="https://beian.miit.gov.cn" target="_blank">{{config.icp_number}}</text></view>
  36. <view class="div">{{config.flow_static_code}}</view>
  37. </view>
  38. </view>
  39. </view></home-base>
  40. </template>
  41. <script>
  42. import {getFontSize} from '@/util/common'
  43. import HomeBase from '../HomeBase'
  44. import { mapState, mapActions } from 'vuex'
  45. import SpecialIndex from '../special/Index'
  46. import IndexProductList from './IndexProductList'
  47. import IndexPromotionList from './IndexPromotionList'
  48. import HomeCommonSearch from '../common/HomeCommonSearch'
  49. import IndexBanner from './IndexBanner'
  50. import IndexMenu from './IndexMenu'
  51. import IndexFloorAds from './IndexFloorAds'
  52. import IndexThreeAds from './IndexThreeAds'
  53. import IndexArticle from './IndexArticle'
  54. export default {
  55. name:'HomeIndex',
  56. data () {
  57. return {
  58. isshowBacktop: true,
  59. popular: '',
  60. sale: 'goods_salenum',
  61. recently: 'goods_addtime'
  62. }
  63. },
  64. components:{
  65. HomeBase,
  66. SpecialIndex,
  67. IndexProductList,
  68. IndexPromotionList,
  69. HomeCommonSearch,
  70. IndexBanner,
  71. IndexMenu,
  72. IndexFloorAds,
  73. IndexThreeAds,
  74. IndexArticle
  75. },
  76. mounted () {
  77. },
  78. onShareAppMessage(res) {
  79. return {
  80. title: this.config.site_name,
  81. path: "/pages/home/index/Index"
  82. }
  83. },
  84. onShareTimeline(res) {
  85. return {
  86. title: this.config.site_name,
  87. path: "/pages/home/index/Index"
  88. }
  89. },
  90. created: function () {
  91. this.fetchHomeAd({}).then(
  92. response => {
  93. },
  94. error => {
  95. uni.showToast({icon:'none',title: error.message})
  96. }
  97. )
  98. this.fetchHomeArticle({}).then(
  99. response => {
  100. },
  101. error => {
  102. uni.showToast({icon:'none',title: error.message})
  103. }
  104. )
  105. this.fetchHomeProduct({}).then(
  106. response => {
  107. },
  108. error => {
  109. uni.showToast({icon:'none',title: error.message})
  110. }
  111. )
  112. this.fetchConfig({}).then(
  113. response => {
  114. uni.setNavigationBarTitle({
  115. title: this.config.site_name
  116. })
  117. },
  118. error => {
  119. uni.showToast({icon:'none',title: error.message})
  120. }
  121. )
  122. },
  123. computed:{
  124. fontSize(){
  125. return getFontSize()
  126. },
  127. ...mapState({
  128. special: state => state.home.special,
  129. config: state => state.config.config,
  130. banners: state => state.home.banners,
  131. navs: state => state.home.navs,
  132. floorAds: state => state.home.floorAds,
  133. promotionAds: state => state.home.promotionAds,
  134. articles: state => state.home.articles,
  135. hotProducts: state => state.home.hotProducts,
  136. recentlyProducts: state => state.home.recentlyProducts,
  137. goodProducts: state => state.home.goodProducts,
  138. xianshiProducts: state => state.home.xianshiProducts
  139. })
  140. },
  141. methods: {
  142. ...mapActions({
  143. fetchHomeAd: 'fetchHomeAd',
  144. fetchHomeArticle: 'fetchHomeArticle',
  145. fetchHomeProduct: 'fetchHomeProduct',
  146. fetchConfig: 'fetchConfig'
  147. })
  148. }
  149. }
  150. </script>
  151. <style scoped lang="scss">
  152. .copyright{font-size:$fontSize;color:#c5c5c5;text-align: center;padding:.8rem 0;
  153. .link{color:#c5c5c5}
  154. }
  155. </style>