|
|
@@ -12,9 +12,11 @@
|
|
|
<el-row :gutter="20" style="margin: 10px" class="card-headers">
|
|
|
<el-col :span="6">
|
|
|
<span class="head-title">上架</span>
|
|
|
- <el-icon :size="15" class="refresh-icon" v-if="listLoading"><RefreshRight /></el-icon>
|
|
|
+ <el-icon :size="15" class="refresh-icon" :class="{ spin: listLoading }" @click="getList">
|
|
|
+ <RefreshRight />
|
|
|
+ </el-icon>
|
|
|
<div style="flex-grow: 1"></div>
|
|
|
- <el-select size="small" v-model="listSort">
|
|
|
+ <el-select size="small" v-model="listSort" @change="getList">
|
|
|
<el-option
|
|
|
v-for="item in sortOptions"
|
|
|
:key="item.value"
|
|
|
@@ -25,9 +27,11 @@
|
|
|
</el-col>
|
|
|
<el-col :span="6">
|
|
|
<span class="head-title">交易</span>
|
|
|
- <el-icon :size="15" class="refresh-icon" v-if="orderLoading"><RefreshRight /></el-icon>
|
|
|
+ <el-icon :size="15" class="refresh-icon" :class="{ spin: orderLoading }" @click="getOrder">
|
|
|
+ <RefreshRight />
|
|
|
+ </el-icon>
|
|
|
<div style="flex-grow: 1"></div>
|
|
|
- <el-select size="small" v-model="orderSort">
|
|
|
+ <el-select size="small" v-model="orderSort" @change="getOrder">
|
|
|
<el-option
|
|
|
v-for="item in sortOptions"
|
|
|
:key="item.value"
|
|
|
@@ -43,13 +47,27 @@
|
|
|
</el-row>
|
|
|
<el-row :gutter="20" style="margin: 10px">
|
|
|
<el-col :span="6" key="list" class="list-container">
|
|
|
- <list-item :info="item" v-for="item in list" :key="item.id"></list-item>
|
|
|
+ <list-item
|
|
|
+ :info="item"
|
|
|
+ v-for="item in list"
|
|
|
+ :key="item.id"
|
|
|
+ @refresh="getData"
|
|
|
+ showBuyBtn
|
|
|
+ ></list-item>
|
|
|
</el-col>
|
|
|
<el-col :span="6" key="order" class="list-container">
|
|
|
- <list-item :info="item" v-for="item in order" :key="item.id"></list-item>
|
|
|
+ <list-item :info="item" v-for="item in order" :key="item.id" @refresh="getOrder"></list-item>
|
|
|
</el-col>
|
|
|
- <el-col :span="12" class="list-container assets-container" ref="assetListEl">
|
|
|
- <AssetItem v-for="item in assets" :key="item.id" :info="item"></AssetItem>
|
|
|
+ <el-col :span="12" class="list-container" ref="assetListEl" style="padding: 0">
|
|
|
+ <div class="assets-container">
|
|
|
+ <AssetItem
|
|
|
+ v-for="item in assets"
|
|
|
+ :key="item.id"
|
|
|
+ :info="item"
|
|
|
+ :size="itemSize"
|
|
|
+ @refresh="getAssets"
|
|
|
+ ></AssetItem>
|
|
|
+ </div>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
</el-main>
|
|
|
@@ -59,16 +77,27 @@
|
|
|
<script setup>
|
|
|
import VueFeather from 'vue-feather'
|
|
|
import DarkMode from '@/components/DarkMode.vue'
|
|
|
-import Account from '@/domain/account'
|
|
|
-import { ref } from 'vue'
|
|
|
+import { ref, watchEffect } from 'vue'
|
|
|
import { onBeforeRouteLeave } from 'vue-router'
|
|
|
import { http } from '@/plugins/http'
|
|
|
import ListItem from '@/components/ListItem.vue'
|
|
|
import AssetItem from '@/components/AssetItem.vue'
|
|
|
-import { useStorage } from '@vueuse/core'
|
|
|
+import { useStorage, useElementSize, useCssVar } from '@vueuse/core'
|
|
|
import { useRouter } from 'vue-router'
|
|
|
import { store } from '@/stores/store'
|
|
|
|
|
|
+const assetListEl = ref(null)
|
|
|
+const { width: assetListWidth } = useElementSize(assetListEl)
|
|
|
+
|
|
|
+const itemSize = ref(0)
|
|
|
+const cssSize = useCssVar('--item-size', assetListEl, { initialValue: '0px' })
|
|
|
+watchEffect(() => {
|
|
|
+ console.log(assetListWidth.value)
|
|
|
+ itemSize.value = assetListWidth.value / Math.round(assetListWidth.value / 150)
|
|
|
+ console.log(itemSize.value)
|
|
|
+ cssSize.value = `${itemSize.value}px`
|
|
|
+})
|
|
|
+
|
|
|
const router = useRouter()
|
|
|
console.log(router)
|
|
|
const logout = () => {
|
|
|
@@ -79,7 +108,7 @@ const logout = () => {
|
|
|
}
|
|
|
|
|
|
const sortOptions = [
|
|
|
- { label: '日期', value: 'createdAt,desc' },
|
|
|
+ { label: '日期', value: 'id,desc' },
|
|
|
{ label: '价格', value: 'price' }
|
|
|
]
|
|
|
const tagId = useStorage('tagId', '')
|
|
|
@@ -89,17 +118,13 @@ http.post('/tag/all', { size: 10000 }, { body: 'json' }).then(res => {
|
|
|
tags.value = res.content
|
|
|
})
|
|
|
|
|
|
-// const account1 = new Account('15077886171', 'x1ongDrew')
|
|
|
-const account2 = new Account('17601545948', '123456')
|
|
|
-// account1.login()
|
|
|
-account2.login()
|
|
|
-
|
|
|
const list = ref([])
|
|
|
const listSort = ref(sortOptions[1].value)
|
|
|
const listLoading = ref(false)
|
|
|
const getList = () => {
|
|
|
+ if (listLoading.value) return
|
|
|
listLoading.value = true
|
|
|
- http.get('/collection/byTag', { tagId: tagId.value }).then(res => {
|
|
|
+ http.get('/collection/byTag', { size: 10000, sort: listSort.value, tagId: tagId.value }).then(res => {
|
|
|
listLoading.value = false
|
|
|
res.content.forEach(i => {
|
|
|
const m = /^(.*?)\s*(#\d+)$/.exec(i.name)
|
|
|
@@ -119,8 +144,9 @@ const order = ref([])
|
|
|
const orderSort = ref(sortOptions[0].value)
|
|
|
const orderLoading = ref(false)
|
|
|
const getOrder = () => {
|
|
|
+ if (orderLoading.value) return
|
|
|
orderLoading.value = true
|
|
|
- http.get('/order/byTag', { tagId: tagId.value }).then(res => {
|
|
|
+ http.get('/order/byTag', { size: 10000, sort: orderSort.value, tagId: tagId.value }).then(res => {
|
|
|
orderLoading.value = false
|
|
|
res.content.forEach(i => {
|
|
|
const m = /^(.*?)\s*(#\d+)$/.exec(i.name)
|
|
|
@@ -139,14 +165,12 @@ const getOrder = () => {
|
|
|
const assets = ref([])
|
|
|
const assetsLoading = ref(false)
|
|
|
const getAssets = () => {
|
|
|
- http.post('/asset/all', { size: 100, query: { status: 'NORMAL' }, sort: 'createdAt,desc' }, { body: 'json' }).then(
|
|
|
- res => {
|
|
|
- if (res.first) {
|
|
|
- assets.value = []
|
|
|
- }
|
|
|
- assets.value = [...assets.value, ...res.content]
|
|
|
+ http.get('/asset/byTag', { size: 10000, sort: 'id,desc', tagId: tagId.value }, { body: 'json' }).then(res => {
|
|
|
+ if (res.first) {
|
|
|
+ assets.value = []
|
|
|
}
|
|
|
- )
|
|
|
+ assets.value = [...assets.value, ...res.content]
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
const getData = () => {
|
|
|
@@ -191,8 +215,11 @@ onBeforeRouteLeave(() => {
|
|
|
}
|
|
|
.refresh-icon {
|
|
|
margin-left: 6px;
|
|
|
- animation: spin 1s linear infinite;
|
|
|
font-size: 14px;
|
|
|
+ cursor: pointer;
|
|
|
+ &.spin {
|
|
|
+ animation: spin 1s linear infinite;
|
|
|
+ }
|
|
|
}
|
|
|
.el-select {
|
|
|
width: 80px;
|
|
|
@@ -214,12 +241,10 @@ onBeforeRouteLeave(() => {
|
|
|
display: none;
|
|
|
opacity: 0;
|
|
|
}
|
|
|
- &.assets-container {
|
|
|
- display: flex;
|
|
|
- flex-wrap: wrap;
|
|
|
- align-items: center;
|
|
|
- justify-content: space-between;
|
|
|
- padding: 0px !important;
|
|
|
- }
|
|
|
+}
|
|
|
+.assets-container {
|
|
|
+ display: flex;
|
|
|
+ flex-wrap: wrap;
|
|
|
+ padding: 0px !important;
|
|
|
}
|
|
|
</style>
|