index.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <?php
  2. use common\helpers\ComponentHelper;
  3. ComponentHelper::loadComponentView('component/notice-item', __DIR__);
  4. ?>
  5. <div id="app" v-cloak>
  6. <el-card shadow="never" style="border:0">
  7. <div slot="header">
  8. <el-breadcrumb separator="/">
  9. <el-breadcrumb-item :to="{ path: 'mall/overview/index' }">首页</el-breadcrumb-item>
  10. <el-breadcrumb-item>消息列表</el-breadcrumb-item>
  11. </el-breadcrumb>
  12. </div>
  13. <!-- body -->
  14. <div class="body">
  15. <template v-if="list.length > 0" v-loading="listLoading">
  16. <div class="notice-list">
  17. <notice-item
  18. v-for="(item, index) in list" :key="index"
  19. :item="item"
  20. :index="index"
  21. :show="action === index"
  22. @reading="handerRead"
  23. ></notice-item>
  24. </div>
  25. <!-- 分页 -->
  26. <el-row type="flex" class="page" justify="end" style="margin-top: 15px">
  27. <el-pagination
  28. @current-change="pagination"
  29. background
  30. layout="prev, pager, next"
  31. :page-count="pageCount"
  32. v-if="list"
  33. ></el-pagination>
  34. </el-row>
  35. </template>
  36. <template v-else>
  37. <el-empty description="暂无消息"></el-empty>
  38. </template>
  39. </div>
  40. </el-card>
  41. </div>
  42. <script>
  43. const app = new Vue({
  44. el: '#app',
  45. data() {
  46. return {
  47. action: "",
  48. listLoading: false,
  49. page: 1,
  50. limit: 20,
  51. list: [],
  52. pageCount: 0,
  53. currentPage: null,
  54. }
  55. },
  56. created() {
  57. this.getList()
  58. },
  59. methods: {
  60. getList() {
  61. this.listLoading = true;
  62. let params = {
  63. r: 'mall/notice/index',
  64. page: this.page,
  65. limit: this.limit
  66. }
  67. params = Object.assign(params, this.searchData)
  68. request({
  69. params: params,
  70. method: 'get',
  71. }).then(e => {
  72. if (e.data.code === 0) {
  73. this.list = e.data.data.list
  74. this.pageCount = e.data.data.page_count
  75. this.currentPage = e.data.data.pagination.current_page
  76. } else {
  77. this.$message.error(e.data.msg)
  78. }
  79. this.listLoading = false
  80. }).catch(e => {
  81. this.listLoading = false
  82. })
  83. },
  84. pagination(currentPage) {
  85. this.page = currentPage
  86. this.action = ""
  87. this.getList()
  88. },
  89. handerRead(i) {
  90. this.action = i
  91. },
  92. }
  93. })
  94. </script>
  95. <style>
  96. </style>