Collection.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. <template>
  2. <div class="container">
  3. <div class="title" ref="anchor">{{ type === 'BLIND_BOX' ? '欢迎来到藏品盲盒市场' : '欢迎来到藏品市场' }}</div>
  4. <el-radio-group v-if="type !== 'BLIND_BOX'" class="menu" v-model="select" size="normal">
  5. <el-radio-button v-for="(item, index) in typeList" :key="index" :label="item.value">
  6. <div class="radio-item">
  7. <i class="font_family" :class="[item.icon]"></i>
  8. <span>{{ item.label }}</span>
  9. </div>
  10. </el-radio-button>
  11. </el-radio-group>
  12. <div class="border" v-if="type !== 'BLIND_BOX'" style="margin-top: 30px"></div>
  13. <div class="search-list">
  14. <el-input
  15. class="search"
  16. prefix-icon="el-icon-search"
  17. placeholder="请输入您想找到的作品名称…"
  18. v-model="search"
  19. clearable
  20. @change="onSearch"
  21. >
  22. </el-input>
  23. <el-select class="select" style="margin-top: 30px" v-model="sortStr" placeholder="请选择">
  24. <el-option v-for="item in sortList" :key="item.value" :label="item.label" :value="item.value">
  25. </el-option>
  26. </el-select>
  27. </div>
  28. <div class="list" v-loading="fetchingData">
  29. <collection-info v-for="(item, index) in list" :key="item.id" :info.sync="list[index]"></collection-info>
  30. <el-empty v-if="empty" description="还没有该类型的藏品哦~"></el-empty>
  31. </div>
  32. <div class="pagination-wrapper">
  33. <el-pagination
  34. @size-change="onSizeChange"
  35. @current-change="onCurrentChange"
  36. :current-page="page"
  37. :page-sizes="[10, 20, 30, 40, 50]"
  38. :page-size="pageSize"
  39. layout="total, prev, pager, next"
  40. :total="totalElements"
  41. >
  42. </el-pagination>
  43. </div>
  44. </div>
  45. </template>
  46. <script>
  47. import CollectionInfo from '../components/CollectionInfo.vue';
  48. import pageableTable from '../mixins/pageableTable';
  49. export default {
  50. components: { CollectionInfo },
  51. data() {
  52. return {
  53. typeList: [
  54. {
  55. label: '全部',
  56. icon: 'icon-icon-quanbu',
  57. value: '0'
  58. },
  59. {
  60. label: '新品',
  61. icon: 'icon-icon-zuixin',
  62. value: '1'
  63. },
  64. {
  65. label: '转让',
  66. icon: 'icon-icon-zhuanrang',
  67. value: '2'
  68. },
  69. {
  70. label: '拍卖',
  71. icon: 'icon-icon-paimai',
  72. value: '3'
  73. }
  74. ],
  75. sortList: [
  76. {
  77. label: '综合排序',
  78. value: 'createdAt,desc'
  79. },
  80. {
  81. label: '热门排序',
  82. value: 'likes,desc'
  83. },
  84. {
  85. label: '价格降序',
  86. value: 'price,desc'
  87. },
  88. {
  89. label: '价格升序',
  90. value: 'price,asc'
  91. }
  92. ],
  93. search: '',
  94. select: '0',
  95. url: '/collection/all',
  96. list: [],
  97. type: 'DEFAULT,AUCTION'
  98. };
  99. },
  100. mixins: [pageableTable],
  101. watch: {
  102. select() {
  103. if (this.type === 'BLIND_BOX') {
  104. return;
  105. }
  106. switch (this.select) {
  107. case '0':
  108. this.type = 'DEFAULT,AUCTION';
  109. this.canResale = '';
  110. break;
  111. case '1':
  112. this.type = 'DEFAULT';
  113. this.canResale = '';
  114. break;
  115. case '2':
  116. this.type = 'DEFAULT,AUCTION';
  117. this.canResale = true;
  118. break;
  119. case '3':
  120. this.type = 'AUCTION';
  121. this.canResale = '';
  122. break;
  123. }
  124. this.$router
  125. .replace({
  126. query: {
  127. ...this.$route.query,
  128. type: this.type,
  129. canResale: this.canResale
  130. }
  131. })
  132. .catch(() => {});
  133. this.page = 1;
  134. this.getData();
  135. },
  136. '$route.query.type'() {
  137. if (!this.$route.query.type || this.$route.query.type === 'BLIND_BOX') {
  138. this.init();
  139. }
  140. }
  141. },
  142. mounted() {
  143. this.$nextTick(() => {
  144. this.init();
  145. });
  146. },
  147. methods: {
  148. init() {
  149. this.type = 'DEFAULT,AUCTION';
  150. this.search = '';
  151. this.sortStr = 'createdAt,desc';
  152. this.page = 1;
  153. if (this.$route.query.sort) {
  154. this.sortStr = this.$route.query.sort;
  155. }
  156. if (this.$route.query.type) {
  157. this.type = this.$route.query.type;
  158. }
  159. this.select = '0';
  160. if (this.type === 'DEFAULT') {
  161. this.select = '1';
  162. }
  163. if (this.type === 'AUCTION') {
  164. this.select = '3';
  165. }
  166. if (this.$route.query.canResale) {
  167. this.canResale = true;
  168. this.select = '2';
  169. } else {
  170. this.canResale = '';
  171. }
  172. this.isFirst = true;
  173. this.getData();
  174. },
  175. beforeGetData() {
  176. if (this.canResale) {
  177. return {
  178. search: this.search,
  179. query: {
  180. type: this.type,
  181. canResale: this.canResale,
  182. onShelf: true
  183. }
  184. };
  185. } else {
  186. return {
  187. search: this.search,
  188. query: {
  189. type: this.type,
  190. onShelf: true
  191. }
  192. };
  193. }
  194. },
  195. setList(list) {
  196. this.list = list;
  197. }
  198. }
  199. };
  200. </script>
  201. <style lang="less" scoped>
  202. @import url('../styles/list.less');
  203. </style>