Store.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443
  1. <template>
  2. <div class="explore_content" :class="collections.length < 5 ? 'shop_list_one' : ''">
  3. <van-pull-refresh
  4. class="load_refresh"
  5. success-text="加载成功"
  6. success-duration="1000"
  7. v-model="isLoading"
  8. @refresh="onRefresh"
  9. >
  10. <!-- 搜素 -->
  11. <van-sticky :offset-top="0" class="explore_content_con">
  12. <div class="explore_content_top">
  13. <div class="explore_content_top_one">
  14. <div class="collection_switching">
  15. <div class="collection_switching_con" :class="{ active: active === 0 }" @click="active = 0">
  16. 持有藏品
  17. </div>
  18. <div
  19. class="collection_switching_con"
  20. :class="{ active: active === 1 }"
  21. @click="getCollection"
  22. >
  23. 收藏藏品
  24. </div>
  25. </div>
  26. <img
  27. src="@assets/sousuo@3x.png"
  28. alt=""
  29. class="search_img"
  30. @click="$router.push('/productSearch')"
  31. />
  32. </div>
  33. <!-- 标签页展示切换 -->
  34. <van-tabs
  35. v-model:active="sort"
  36. line-width="32"
  37. line-height="2"
  38. @click-tab="changeTab"
  39. v-if="active === 0"
  40. >
  41. <van-tab
  42. :title="item.label"
  43. :name="item.value"
  44. :key="index"
  45. v-for="(item, index) in selectOptions"
  46. >
  47. </van-tab>
  48. </van-tabs>
  49. <!-- <div class="label_tabs">
  50. <div
  51. :class="tabLabel == 'whole' ? 'label_selected' : 'label_not_selected'"
  52. @click="tabLabelName('whole')"
  53. class="label_tab"
  54. >
  55. 全部
  56. </div>
  57. <div
  58. :class="tabLabel == 'onSale' ? 'label_selected' : 'label_not_selected'"
  59. @click="tabLabelName('onSale')"
  60. class="label_tab"
  61. >
  62. 出售中
  63. </div>
  64. <div
  65. :class="tabLabel == 'showOnly' ? 'label_selected' : 'label_not_selected'"
  66. @click="tabLabelName('showOnly')"
  67. class="label_tab"
  68. >
  69. 仅展示
  70. </div>
  71. <div
  72. :class="tabLabel == 'notShown' ? 'label_selected' : 'label_not_selected'"
  73. @click="tabLabelName('notShown')"
  74. class="label_tab"
  75. >
  76. 未展示
  77. </div>
  78. </div> -->
  79. </div>
  80. </van-sticky>
  81. <div class="data_display" v-if="active === 0">
  82. <!-- 藏品展示 -->
  83. <van-list v-model:loading="loading" :finished="finished" @load="getAllCollections">
  84. <div class="data_display_fanter">
  85. <template v-for="(item, index) in collections" :key="index">
  86. <asset-info :info="item"></asset-info>
  87. </template>
  88. </div>
  89. <van-empty
  90. v-if="collections.length === 0 && !loading"
  91. :image="require(`@assets/empty-collection.png`)"
  92. :image-size="`172`"
  93. >
  94. <div class="h44_tip_one">你还没有相关藏品</div>
  95. <div class="h44_tip">这里将展示你在拉索持有的数字藏品</div>
  96. </van-empty>
  97. <!-- </van-empty> -->
  98. </van-list>
  99. </div>
  100. <div class="data_display_one" v-else>
  101. <div class="current_recommendation">
  102. <template v-for="(item, index) in showList" :key="index">
  103. <CollectionList v-model:info="list[item.index]" @update:info="init"></CollectionList>
  104. </template>
  105. </div>
  106. <van-empty
  107. v-if="showList.length === 0"
  108. :image="require(`@assets/empty-collection.png`)"
  109. :image-size="`172`"
  110. >
  111. <div class="h44_tip_one">你还没有收藏的藏品</div>
  112. <div class="h44_tip">这里将展示你在拉索持有的数字藏品</div>
  113. </van-empty>
  114. </div>
  115. </van-pull-refresh>
  116. </div>
  117. </template>
  118. <script>
  119. import AssetInfo from '../components/asset/assetInfo.vue';
  120. import CollectionList from '../components/CollectionList.vue';
  121. import product from '../mixins/product';
  122. export default {
  123. mixins: [product],
  124. components: {
  125. AssetInfo,
  126. CollectionList
  127. },
  128. data() {
  129. return {
  130. tabLabel: 'whole',
  131. page: 0,
  132. empty: false,
  133. list: [],
  134. loading: false,
  135. finished: false,
  136. // 藏品列表
  137. collections: [],
  138. isLoading: true,
  139. active: 0,
  140. selectOptions: [
  141. {
  142. label: '全部',
  143. value: 'whole'
  144. },
  145. {
  146. label: '挂售中',
  147. value: 'onSale'
  148. },
  149. {
  150. label: '仅展示',
  151. value: 'showOnly'
  152. },
  153. {
  154. label: '未展示',
  155. value: 'notShown'
  156. }
  157. ]
  158. };
  159. },
  160. computed: {
  161. status() {
  162. return 'NORMAL,TRADING,GIFTING,MINTING';
  163. },
  164. showList() {
  165. return [...this.list].map((item, index) => {
  166. return {
  167. ...item,
  168. index
  169. };
  170. });
  171. }
  172. },
  173. mounted() {
  174. // this.getAllCollections();
  175. },
  176. methods: {
  177. // 获取收藏藏品
  178. getCollection() {
  179. this.active = 1;
  180. this.init();
  181. },
  182. init() {
  183. if (!this.isLogin) {
  184. this.empty = true;
  185. this.loading = false;
  186. return Promise.resolve();
  187. }
  188. this.$toast.loading({
  189. message: '加载中...',
  190. forbidClick: true
  191. });
  192. this.empty = false;
  193. this.$http.get('/collection/myLikes').then(res => {
  194. this.list = res;
  195. this.empty = res.length === 0;
  196. this.$toast.clear();
  197. });
  198. },
  199. change() {
  200. this.$root.$el.scrollTop = 0;
  201. },
  202. // 获取全部库存藏品
  203. getAllCollections() {
  204. if (!this.isLogin) {
  205. this.empty = true;
  206. this.loading = false;
  207. return Promise.resolve();
  208. }
  209. if (this.page === 0) {
  210. this.collections = [];
  211. }
  212. this.finished = false;
  213. this.empty = false;
  214. let form = {
  215. page: this.page,
  216. size: 20,
  217. sort: 'createdAt,desc',
  218. query: {
  219. userId: this.$store.state.userInfo.id,
  220. ...this.beforeQuery()
  221. }
  222. };
  223. this.$toast.loading({
  224. message: '加载中...',
  225. forbidClick: true
  226. });
  227. return this.$http.post('/asset/all', form, { body: 'json' }).then(res => {
  228. if (res.first) {
  229. this.collections = [];
  230. }
  231. this.collections = [...this.collections, ...res.content];
  232. this.empty = res.empty;
  233. this.loading = false;
  234. this.finished = res.last;
  235. if (!this.finished) {
  236. this.page = this.page + 1;
  237. }
  238. this.$toast.clear();
  239. });
  240. },
  241. // 顶部数据类型切换
  242. changeTab(info) {
  243. this.tabLabel = info.name;
  244. this.page = 0;
  245. this.loading = true;
  246. this.getAllCollections();
  247. },
  248. beforeQuery() {
  249. let form = {};
  250. if (this.tabLabel == 'onSale') {
  251. form = {
  252. ...form,
  253. publicShow: true,
  254. consignment: true
  255. };
  256. } else if (this.tabLabel == 'showOnly') {
  257. form = {
  258. ...form,
  259. publicShow: true,
  260. consignment: false
  261. };
  262. } else if (this.tabLabel == 'notShown') {
  263. form = {
  264. ...form,
  265. publicShow: false,
  266. consignment: false
  267. };
  268. } else {
  269. form = {
  270. status: this.status
  271. };
  272. }
  273. return form;
  274. },
  275. onRefresh() {
  276. if (this.active === 0) {
  277. this.page = 0;
  278. this.getAllCollections().then(() => {
  279. this.isLoading = false;
  280. });
  281. } else {
  282. Promise.all([this.init()]).then(res => {
  283. this.isLoading = false;
  284. });
  285. }
  286. }
  287. }
  288. };
  289. </script>
  290. <style lang="less" scoped>
  291. .load_refresh {
  292. background: #191d27;
  293. }
  294. /deep/ .van-button {
  295. width: 280px;
  296. height: 38px;
  297. }
  298. .explore_content {
  299. width: 100%;
  300. // margin-top: 44px;
  301. box-sizing: border-box;
  302. background: #191d27;
  303. .explore_content_top {
  304. padding: 0px 15px 15px;
  305. box-sizing: border-box;
  306. background: #191d27;
  307. .explore_content_top_one {
  308. height: 44px;
  309. padding: 6px 0px;
  310. box-sizing: border-box;
  311. display: flex;
  312. justify-content: space-between;
  313. .collection_switching {
  314. display: flex;
  315. font-family: PingFangSC-Semibold, PingFang SC;
  316. .collection_switching_con {
  317. padding-top: 5px;
  318. box-sizing: border-box;
  319. margin-right: 18px;
  320. font-size: 16px;
  321. font-weight: 500;
  322. color: #ffffff;
  323. line-height: 22px;
  324. }
  325. .active {
  326. padding-top: 2px;
  327. box-sizing: border-box;
  328. font-size: 20px;
  329. font-weight: 600;
  330. color: #f2d5b2;
  331. line-height: 28px;
  332. }
  333. }
  334. .search_img {
  335. width: 32px;
  336. height: 32px;
  337. }
  338. }
  339. /deep/ .van-tabs__wrap {
  340. height: 36px;
  341. .van-tabs__nav--line {
  342. padding-left: 0 !important;
  343. border-top: none;
  344. background: #191d27;
  345. padding-bottom: 0px;
  346. }
  347. .van-tab {
  348. flex: 1 !important;
  349. margin-right: 0px !important;
  350. }
  351. .van-tabs__line {
  352. bottom: 0;
  353. background: #d8d8d8;
  354. }
  355. .van-tab--active {
  356. font-size: 16px;
  357. font-weight: 500;
  358. color: #ffffff !important;
  359. }
  360. }
  361. }
  362. .label_tabs {
  363. width: 100%;
  364. display: flex;
  365. height: 36px;
  366. .label_tab {
  367. // width: 80px;
  368. flex: 1;
  369. height: 24px;
  370. // background: #29293f;
  371. // border-radius: 4px;
  372. margin-right: 16px;
  373. text-align: center;
  374. line-height: 24px;
  375. font-size: 14px;
  376. font-family: PingFangSC-Medium, PingFang SC;
  377. }
  378. .label_tab:last-child {
  379. margin-right: 0;
  380. }
  381. .label_selected {
  382. font-weight: 500;
  383. color: #ffffff;
  384. border-bottom: 2px solid #d8d8d8;
  385. }
  386. .label_not_selected {
  387. font-weight: 400;
  388. color: #5f646f;
  389. }
  390. }
  391. .data_display {
  392. padding: 0px 16px 16px;
  393. box-sizing: border-box;
  394. // background: #0F0F27;
  395. .data_display_fanter {
  396. width: 100%;
  397. display: flex;
  398. justify-content: space-between;
  399. flex-wrap: wrap;
  400. margin-bottom: 50px;
  401. }
  402. }
  403. .data_display_one {
  404. // padding: 0px 16px 16px;
  405. // box-sizing: border-box;
  406. .current_recommendation {
  407. width: 100%;
  408. display: flex;
  409. justify-content: space-between;
  410. flex-wrap: wrap;
  411. padding: 16px;
  412. box-sizing: border-box;
  413. }
  414. }
  415. }
  416. .shop_list_one {
  417. height: 100%;
  418. position: absolute;
  419. }
  420. .explore_content_con {
  421. position: relative;
  422. z-index: 10;
  423. }
  424. .h44_tip_one {
  425. font-size: 16px;
  426. font-family: PingFangSC-Regular, PingFang SC;
  427. font-weight: 400;
  428. color: #ffffff;
  429. line-height: 22px;
  430. text-align: center;
  431. margin-bottom: 8px;
  432. }
  433. .h44_tip {
  434. height: 20px;
  435. font-size: 14px;
  436. font-family: PingFangSC-Regular, PingFang SC;
  437. font-weight: 400;
  438. color: #ffffff;
  439. line-height: 20px;
  440. opacity: 0.3;
  441. }
  442. </style>