index.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <template>
  2. <section class="container">
  3. <!-- banner -->
  4. <div id="common-banner">
  5. <div class="common-banner-container">
  6. <div class="common-banner-img">
  7. <img src="~/assets/images/prod-view/banner.jpg">
  8. </div>
  9. </div>
  10. </div>
  11. <div class="new_products_wrap">
  12. <div class="new_products_box">
  13. <!-- products-show start -->
  14. <div id="products-show">
  15. <prodListShow :prodList="newProdList.list" :showNewMore="false" :typeId="97"></prodListShow>
  16. </div>
  17. <!-- products-show end -->
  18. <!-- products-pagination start-->
  19. <div id="products-pagination">
  20. <div class="products-pagination-box">
  21. <pagination
  22. :total="total"
  23. :display="display"
  24. :current-page="current"
  25. @pagechange="pagechange"
  26. ></pagination>
  27. </div>
  28. </div>
  29. <!-- products-pagination end-->
  30. </div>
  31. </div>
  32. </section>
  33. </template>
  34. <script>
  35. import axios from "axios";
  36. import prodListShow from "~/components/common/prodListShow";
  37. import pagination from "~/components/common/pagination.vue";
  38. export default {
  39. data() {
  40. return {
  41. //产品分页
  42. display: 12, // 每页显示条数
  43. current: 1, // 当前的页数
  44. };
  45. },
  46. head() {
  47. return {
  48. title: this.metaData.navigationTitle,
  49. meta: [
  50. {
  51. name: "keywords",
  52. hid: "keywords",
  53. content: `${this.metaData.navigationKeyword}`,
  54. },
  55. {
  56. name: "description",
  57. hid: "description",
  58. content: `${this.metaData.navigationDescription}`,
  59. },
  60. ],
  61. };
  62. },
  63. async asyncData({ params, store }) {
  64. //head信息
  65. let metaData = await axios(
  66. `${store.state.wordpressAPI}/NavigationMeta/get/4`
  67. );
  68. //新品数据
  69. let newProdList = await axios.post(
  70. `${store.state.wordpressAPI}/product/selectByNew/1/12`
  71. );
  72. return {
  73. metaData: metaData.data,
  74. newProdList: newProdList.data,
  75. total: newProdList.data.total,
  76. };
  77. },
  78. components: {
  79. prodListShow,
  80. pagination,
  81. },
  82. methods: {
  83. pagechange(currentPage) {
  84. // ajax请求, 向后台发送 currentPage, 来获取对应的数据
  85. axios
  86. .post(
  87. `${
  88. this.$store.state.wordpressAPI
  89. }/product/selectByNew/${currentPage}/12`
  90. )
  91. .then((response) => {
  92. this.newProdList = response.data;
  93. this.total = response.data.total;
  94. })
  95. .catch(function(error) {
  96. console.log(error);
  97. });
  98. },
  99. },
  100. };
  101. </script>
  102. <style type="text/css" scoped>
  103. div#common-banner {
  104. height: 394px;
  105. }
  106. .new_products_wrap {
  107. width: 100%;
  108. }
  109. .new_products_box {
  110. width: 1200px;
  111. margin: 0 auto;
  112. }
  113. div#products-show {
  114. width: 100%;
  115. padding: 105px 0 78px;
  116. border-bottom: 2px solid #d5d5d8;
  117. }
  118. div#products-pagination {
  119. width: 100%;
  120. height: auto;
  121. }
  122. .products-pagination-box {
  123. overflow: hidden;
  124. width: 1200px;
  125. height: auto;
  126. margin: 0 auto;
  127. padding: 60px 0 170px;
  128. text-align: center;
  129. }
  130. </style>