Store.vue 16 KB

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