Store.vue 15 KB

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