collect.vue 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <template>
  2. <div>
  3. <use-table ref="tbl"></use-table>
  4. <div class="container use-table">
  5. <el-table :height="tblHeight" :data="tableDatas" highlight-current-row>
  6. <el-table-column label="商品" align="center">
  7. <template slot-scope="scope">
  8. <div class="dflex_vertical_c">
  9. <el-image style="width: 100px;height: 80px;" :src="scope.row.goods.img" :preview-src-list="scope.row.imgs" fit="contain"></el-image>
  10. <div class="left_just">
  11. <div class="ellipsis">{{ scope.row.goods.name }}</div>
  12. <div class="ellipsis">{{ scope.row.goods.name_pw }}</div>
  13. </div>
  14. </div>
  15. </template>
  16. </el-table-column>
  17. <el-table-column label="价格" align="center">
  18. <template slot-scope="scope">
  19. <div class="price">{{ scope.row.goods.price / 100}}</div>
  20. <div class="m_price">{{ scope.row.goods.market_price / 100}}</div>
  21. </template>
  22. </el-table-column>
  23. <el-table-column property="create_time" label="收藏时间" align="center"></el-table-column>
  24. </el-table>
  25. <el-pagination
  26. :current-page="req.page"
  27. :page-sizes="[10, 20, 30, 50, 100]"
  28. :page-size="req.rows"
  29. layout="total, sizes, prev, pager, next, jumper"
  30. :total="tableTotal"
  31. @size-change="sizeChange"
  32. @current-change="currentChange"
  33. ></el-pagination>
  34. </div>
  35. </div>
  36. </template>
  37. <script>
  38. const __name = 'usemall-member-collect, usemall-goods';
  39. export default {
  40. data() {
  41. return {
  42. dataId: '',
  43. req: {
  44. page: 1,
  45. rows: 10,
  46. orderby: 'create_time desc'
  47. },
  48. tblHeight: 0,
  49. tableDatas: [],
  50. tableTotal: 0
  51. };
  52. },
  53. methods: {
  54. async loadData() {
  55. this.$db[__name]
  56. .where({ create_uid: this.dataId })
  57. .field('create_time, last_modify_time, goods.name, goods.name_pw, goods.img, goods.price, goods.market_price')
  58. .totable(this.req)
  59. .then(res => {
  60. if (res.code == 200) {
  61. res.datas.rows.forEach(x => {
  62. x.goods = x.goods[0] || {};
  63. x.imgs = [x.goods.img];
  64. x.create_time = new Date(x.create_time).format();
  65. });
  66. this.tableDatas = res.datas.rows;
  67. this.tableTotal = res.datas.total;
  68. }
  69. });
  70. },
  71. sizeChange(size) {
  72. this.req.rows = size;
  73. this.loadData();
  74. },
  75. currentChange(current) {
  76. this.req.page = current;
  77. this.loadData();
  78. }
  79. },
  80. created() {
  81. this.dataId = this.$route.query.id || '';
  82. this.tblHeight = 0;
  83. this.loadData();
  84. },
  85. updated() {
  86. if (!this.tblHeight) {
  87. this.tblHeight = this.$refs.tbl.tblHeight;
  88. }
  89. }
  90. };
  91. </script>
  92. <style></style>