origin added + refactor
This commit is contained in:
parent
5639f8031c
commit
2e9d1d33b7
7 changed files with 86 additions and 87 deletions
|
|
@ -6,7 +6,7 @@ const message = useMessage()
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
text: {
|
text: {
|
||||||
type: String,
|
type: String,
|
||||||
required: true,
|
default: '',
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ export const BASE_URL = 'https://api.nqws.ru/api/v2'
|
||||||
// export const BASE_URL = 'http://localhost:9090/api/v2'
|
// export const BASE_URL = 'http://localhost:9090/api/v2'
|
||||||
|
|
||||||
export const BASE_MANDARAKE_LINK = 'https://order.mandarake.co.jp/order/listPage/list?soldOut=1&keyword='
|
export const BASE_MANDARAKE_LINK = 'https://order.mandarake.co.jp/order/listPage/list?soldOut=1&keyword='
|
||||||
|
export const BASE_AMIAMI_LINK = 'https://slist.amiami.jp/top/search/list?s_cate_tag=1&submit_btn=&s_st_list_preorder_available=1&s_st_list_backorder_available=1&s_st_list_newitem_available=1&s_st_condition_flg=1&pagemax=60&s_keywords='
|
||||||
// export const IMAGE_STORAGE_URL = 'http://localhost:9280'
|
// export const IMAGE_STORAGE_URL = 'http://localhost:9280'
|
||||||
export const IMAGE_STORAGE_URL = 'https://images.nqws.ru'
|
export const IMAGE_STORAGE_URL = 'https://images.nqws.ru'
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
export const originColors = {
|
export const originColors = {
|
||||||
surugaya: '#2d3081',
|
surugaya: '#2d3081',
|
||||||
mandarake: '#924646',
|
mandarake: '#924646',
|
||||||
|
amiami: '#F27024',
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ const fetchPrices = async (days = 7) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
fetchPrices(7)
|
fetchPrices()
|
||||||
})
|
})
|
||||||
|
|
||||||
function handleSelectDays(days) {
|
function handleSelectDays(days) {
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,9 @@ import router from '@/router/index.js'
|
||||||
import PeriodSelector from '@/components/PeriodSelector.vue'
|
import PeriodSelector from '@/components/PeriodSelector.vue'
|
||||||
import ChartBlock from '@/components/ChartBlock.vue'
|
import ChartBlock from '@/components/ChartBlock.vue'
|
||||||
import { useChartsApi } from '@/api/charts.js'
|
import { useChartsApi } from '@/api/charts.js'
|
||||||
import EditLink from '@/views/DetailsView/EditLink.vue'
|
|
||||||
import CopyToClipboard from '@/components/CopyToClipboard.vue'
|
|
||||||
import DetailsViewImages from '@/views/DetailsView/DetailsViewImages.vue'
|
import DetailsViewImages from '@/views/DetailsView/DetailsViewImages.vue'
|
||||||
import AttachLabel from '@/views/DetailsView/AttachLabel.vue'
|
import AttachLabel from '@/views/DetailsView/AttachLabel.vue'
|
||||||
|
import OriginBlock from '@/views/DetailsView/OriginBlock.vue'
|
||||||
|
|
||||||
const { getMerchDetails, deleteMerch } = useMerchApi()
|
const { getMerchDetails, deleteMerch } = useMerchApi()
|
||||||
const { getDistinctPrices } = useChartsApi()
|
const { getDistinctPrices } = useChartsApi()
|
||||||
|
|
@ -20,11 +19,6 @@ const props = defineProps({
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const editing = ref({
|
|
||||||
surugaya: false,
|
|
||||||
mandarake: false,
|
|
||||||
})
|
|
||||||
|
|
||||||
const merchDetails = ref(null)
|
const merchDetails = ref(null)
|
||||||
const loading = ref(true)
|
const loading = ref(true)
|
||||||
const error = ref(null)
|
const error = ref(null)
|
||||||
|
|
@ -35,7 +29,7 @@ const fetchMerch = async () => {
|
||||||
merchDetails.value = response.data
|
merchDetails.value = response.data
|
||||||
|
|
||||||
if (!response.status === 400) {
|
if (!response.status === 400) {
|
||||||
router.push({ name: 'collection' })
|
await router.push({ name: 'collection' })
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
error.value = err.message
|
error.value = err.message
|
||||||
|
|
@ -58,7 +52,7 @@ const confirmDelete = async () => {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
}
|
}
|
||||||
showModal.value = false
|
showModal.value = false
|
||||||
router.push({ name: 'collection' })
|
await router.push({ name: 'collection' })
|
||||||
}
|
}
|
||||||
|
|
||||||
const prices = ref(null)
|
const prices = ref(null)
|
||||||
|
|
@ -72,7 +66,7 @@ const fetchPrices = async (days = 7) => {
|
||||||
const response = await getDistinctPrices(props.merch_uuid, days)
|
const response = await getDistinctPrices(props.merch_uuid, days)
|
||||||
|
|
||||||
if (response.status === 400) {
|
if (response.status === 400) {
|
||||||
router.push({ name: 'collection' })
|
await router.push({ name: 'collection' })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -84,11 +78,6 @@ const fetchPrices = async (days = 7) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleLinkUpdate(origin, newLink) {
|
|
||||||
merchDetails.value[`origin_${origin}`].link = newLink
|
|
||||||
editing.value[origin] = false
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleSelectDays(days) {
|
function handleSelectDays(days) {
|
||||||
fetchPrices(days)
|
fetchPrices(days)
|
||||||
}
|
}
|
||||||
|
|
@ -120,75 +109,10 @@ onMounted(() => {
|
||||||
<ChartBlock :charts-data="prices" />
|
<ChartBlock :charts-data="prices" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Surugaya -->
|
<div v-for="item in merchDetails.origins" :key="item">
|
||||||
<CopyToClipboard :text="merchDetails.origin_surugaya?.link">
|
<OriginBlock :merch_details="merchDetails" :merch_data="item" />
|
||||||
<n-divider title-placement="left">Surugaya</n-divider>
|
|
||||||
</CopyToClipboard>
|
|
||||||
<div v-if="!editing.surugaya">
|
|
||||||
<template v-if="merchDetails.origin_surugaya?.link">
|
|
||||||
<a
|
|
||||||
:href="merchDetails.origin_surugaya.link"
|
|
||||||
target="_blank"
|
|
||||||
rel="noopener"
|
|
||||||
class="default-color"
|
|
||||||
>
|
|
||||||
{{ merchDetails.origin_surugaya.link }}
|
|
||||||
</a>
|
|
||||||
<n-button type="primary" style="margin-left: 8px" @click="editing.surugaya = true">
|
|
||||||
Edit link
|
|
||||||
</n-button>
|
|
||||||
</template>
|
|
||||||
<template v-else>
|
|
||||||
<span class="default-color underline link-like-text" @click="editing.surugaya = true"
|
|
||||||
>Add link</span
|
|
||||||
>
|
|
||||||
</template>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<EditLink
|
|
||||||
v-else
|
|
||||||
:merch-uuid="merch_uuid"
|
|
||||||
origin="surugaya"
|
|
||||||
:name="merchDetails.name"
|
|
||||||
:model-value="merchDetails.origin_surugaya?.link || ''"
|
|
||||||
@update:model-value="handleLinkUpdate('surugaya', $event)"
|
|
||||||
@cancel-edit="editing.surugaya = false"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<!-- Mandarake -->
|
|
||||||
<CopyToClipboard :text="merchDetails.origin_mandarake?.link">
|
|
||||||
<n-divider title-placement="left">Mandarake</n-divider>
|
|
||||||
</CopyToClipboard>
|
|
||||||
<div v-if="!editing.mandarake">
|
|
||||||
<template v-if="merchDetails.origin_mandarake?.link">
|
|
||||||
<a
|
|
||||||
:href="merchDetails.origin_mandarake.link"
|
|
||||||
target="_blank"
|
|
||||||
rel="noopener"
|
|
||||||
class="default-color"
|
|
||||||
>
|
|
||||||
{{ merchDetails.origin_mandarake.link }}
|
|
||||||
</a>
|
|
||||||
<n-button type="primary" style="margin-left: 8px" @click="editing.mandarake = true">
|
|
||||||
Edit link
|
|
||||||
</n-button>
|
|
||||||
</template>
|
|
||||||
<template v-else>
|
|
||||||
<span class="default-color underline link-like-text" @click="editing.mandarake = true"
|
|
||||||
>Add link</span
|
|
||||||
>
|
|
||||||
</template>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<EditLink
|
|
||||||
v-else
|
|
||||||
:merch-uuid="merch_uuid"
|
|
||||||
origin="mandarake"
|
|
||||||
:name="merchDetails.name"
|
|
||||||
:model-value="merchDetails.origin_mandarake?.link || ''"
|
|
||||||
@update:model-value="handleLinkUpdate('mandarake', $event)"
|
|
||||||
@cancel-edit="editing.mandarake = false"
|
|
||||||
/>
|
|
||||||
</n-card>
|
</n-card>
|
||||||
<div v-else>Not found</div>
|
<div v-else>Not found</div>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, nextTick } from 'vue'
|
import { ref, nextTick } from 'vue'
|
||||||
import { useMerchApi } from '@/api/merch.js'
|
import { useMerchApi } from '@/api/merch.js'
|
||||||
import { BASE_MANDARAKE_LINK } from '@/main.js'
|
import { BASE_AMIAMI_LINK, BASE_MANDARAKE_LINK } from '@/main.js'
|
||||||
|
|
||||||
const { updateMerch } = useMerchApi()
|
const { updateMerch } = useMerchApi()
|
||||||
|
|
||||||
|
|
@ -101,18 +101,29 @@ const cancel = () => {
|
||||||
emit('cancel-edit')
|
emit('cancel-edit')
|
||||||
}
|
}
|
||||||
|
|
||||||
const insertAutoCompletedLink = () => {
|
const insertMandarakeLink = () => {
|
||||||
tempValue.value = BASE_MANDARAKE_LINK+props.name
|
tempValue.value = BASE_MANDARAKE_LINK+props.name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const insertAmiamiLink = () => {
|
||||||
|
tempValue.value = BASE_AMIAMI_LINK+props.name
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div v-if="props.origin === 'mandarake'" class="button-container-center mb-10">
|
<div v-if="props.origin === 'mandarake'" class="button-container-center mb-10">
|
||||||
<n-button type="warning" class="center-button" @click="insertAutoCompletedLink"
|
<n-button type="warning" class="center-button" @click="insertMandarakeLink"
|
||||||
>Insert auto-completed link</n-button
|
>Insert auto-completed link</n-button
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div v-if="props.origin === 'amiami'" class="button-container-center mb-10">
|
||||||
|
<n-button type="warning" class="center-button" @click="insertAmiamiLink"
|
||||||
|
>Insert auto-completed link</n-button
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="editing-area">
|
<div class="editing-area">
|
||||||
<n-input
|
<n-input
|
||||||
v-model:value="tempValue"
|
v-model:value="tempValue"
|
||||||
|
|
|
||||||
62
src/views/DetailsView/OriginBlock.vue
Normal file
62
src/views/DetailsView/OriginBlock.vue
Normal file
|
|
@ -0,0 +1,62 @@
|
||||||
|
<script setup>
|
||||||
|
import { computed, ref } from 'vue'
|
||||||
|
import CopyToClipboard from '@/components/CopyToClipboard.vue'
|
||||||
|
import EditLink from '@/views/DetailsView/EditLink.vue'
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
merch_data: {
|
||||||
|
type: Object,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
merch_details: {
|
||||||
|
type: Object,
|
||||||
|
required: true,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const editing = ref(false)
|
||||||
|
|
||||||
|
const formattedName = computed(() => {
|
||||||
|
const name = props.merch_data?.name
|
||||||
|
if (!name) return ''
|
||||||
|
return name.charAt(0).toUpperCase() + name.slice(1)
|
||||||
|
})
|
||||||
|
|
||||||
|
function handleLinkUpdate(origin, newLink) {
|
||||||
|
props.merch_data.link = newLink
|
||||||
|
editing.value = false
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<CopyToClipboard :text="merch_data.link">
|
||||||
|
<n-divider title-placement="left">{{ formattedName }}</n-divider>
|
||||||
|
</CopyToClipboard>
|
||||||
|
<div v-if="!editing">
|
||||||
|
<template v-if="merch_data.link">
|
||||||
|
<a :href="merch_data.link" target="_blank" rel="noopener" class="default-color">
|
||||||
|
{{ merch_data.link }}
|
||||||
|
</a>
|
||||||
|
<n-button type="primary" style="margin-left: 8px" @click="editing = true">
|
||||||
|
Edit link
|
||||||
|
</n-button>
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
<span class="default-color underline link-like-text" @click="editing = true"> Add link </span>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<EditLink
|
||||||
|
v-else
|
||||||
|
:merch-uuid="merch_details.merch_uuid"
|
||||||
|
:origin="merch_data.name"
|
||||||
|
:name="merch_details.name"
|
||||||
|
:model-value="merch_data.link"
|
||||||
|
@update:model-value="handleLinkUpdate(merch_data.name, $event)"
|
||||||
|
@cancel-edit="editing=false"
|
||||||
|
/>
|
||||||
|
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped></style>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue