feat 区分中国coach和coach outlet

This commit is contained in:
timerzz 2024-06-16 12:48:34 +08:00
parent 1bf55e3308
commit 4561319933
7 changed files with 140 additions and 17 deletions

View File

@ -0,0 +1,9 @@
import {mande} from "mande";
const cnCoachSpider = mande('/api/v1/spider/cn/coach')
export const GetCNCoachSpiderGlobalCalculate = ()=> cnCoachSpider.get("global/calculate")
export const DeleteCNCoachSpiderGlobalCalculate = (id)=> cnCoachSpider.delete(`global/calculate/u/${id}`)
export const SaveCNCoachSpiderGlobalCalculate = (data)=> cnCoachSpider.post("global/calculate",data)
export const DeleteCNCoachSpiderCalculate = (id)=> cnCoachSpider.delete(`calculate/u/${id}`)
export const SaveCNCoachSpiderCalculate = (data)=> cnCoachSpider.post("calculate",data)

View File

@ -1,7 +1,8 @@
export const WEBSITES = {
UNKNOWN: 0,
US_COACH_OUTLET: 1,
CN_COACH: 2
CN_COACH_OUTLET: 2,
CN_COACH: 3
}
export const WEBSITE_OPTIONS = [
@ -16,5 +17,9 @@ export const WEBSITE_OPTIONS = [
{
label: '中国coach',
value: WEBSITES.CN_COACH
},
{
label: '中国coach outlet',
value: WEBSITES.CN_COACH_OUTLET
}
]

View File

@ -20,6 +20,11 @@ const routes = [
name: 'cn-coach',
component: ()=>import('@/views/Product/CNCoachOutlet.vue')
},
{
path: '/cn-coach-outlet',
name: 'cn-coach-outlet',
component: ()=>import('@/views/Product/CNCoachOutlet.vue')
},
{
path: '/pusher',
name: 'pusher',

View File

@ -2,6 +2,7 @@
<div class="h-full m-4 bg-white rounded-2 shadow-lg p-8 flex flex-col justify-between space-y-4 overscroll-auto">
<div class="flex justify-between">
<div class="flex items-center space-x-16">
<a-button type="primary" @click="globalCalculateVisible=true">查看优惠设置</a-button>
</div>
<div class="flex space-x-4">
<a-input placeholder="请输入关键词" v-model:value="query.keyword" @pressEnter="search"></a-input>
@ -19,9 +20,9 @@
<template v-else-if="column.key === 'updatedAt'">
<span>{{moment(record.updatedAt).format('YYYY-MM-DD HH:mm:ss')}}</span>
</template>
<template v-else-if="column.key === 'cnyPrice'">
<template v-else-if="column.key === 'originalPrice'">
<div class="flex space items-center">
<span >{{record.cnyPrice}}</span>
<span >{{record.originalPrice}}</span>
<CaretUpOutlined class="text-red" v-if="record.priceStatus === PRICE_STATUS.UP"/>
<CaretDownOutlined class="text-green" v-if="record.priceStatus === PRICE_STATUS.DOWN"/>
</div>
@ -43,6 +44,14 @@
:src="record.image"
/>
</template>
<template v-else-if="column.key === 'cnyPrice'">
<a-popover >
<template #content>
<div class="whitespace-pre">{{record.calMark}}</div>
</template>
<span class="cursor-pointer">{{parseFloat(record.cnyPrice).toFixed(2)}}</span>
</a-popover>
</template>
<template v-else-if="column.key === 'orderable'">
<span :class="[record.orderable ? '':'text-red']">{{record.orderable?'是':'否'}}</span>
</template>
@ -54,8 +63,13 @@
<!-- <FormOutlined v-else class="cursor-pointer" @click="onEdit(record, 'dwPrice')"/>-->
</div>
</template>
<template v-else-if="column.key === 'link'">
<a :href="`https://www.coach.com.cn/products/${record.pid}`" target="_blank">跳转</a>
<template v-else-if="column.key === 'opt'">
<a-popover title="" placement="bottom">
<template #content>
<a-button type="text" block @click="showCalculateModal(record)">查看优惠</a-button>
</template>
<SettingOutlined class="cursor-pointer" />
</a-popover>
</template>
</template>
@ -65,7 +79,7 @@
<div class="text-xl">历史价格</div>
<div class="flex space-x-16 my-2 text-lg" v-for="h in record.historyPrices">
<div>{{moment(h.createdAt).format('YYYY-MM-DD HH:mm:ss')}}</div>
<div>{{h.usPrice}}</div>
<div>{{h.originalPrice}}</div>
</div>
<div class="text-xl mt-4">得物价格CNY</div>
<div v-if="record.dwHistoryPrices?.length>0" class="flex space-x-16 my-2 text-lg" v-for="h in record.dwHistoryPrices">
@ -81,19 +95,61 @@
</div>
<a-pagination :disabled="loading" class="text-right" v-model:current="query.page" v-model:page-size="query.size" :total="data.total" show-less-items @change="list"/>
</div>
<Calculate v-model:visible="globalCalculateVisible"
:getter="route.name === 'cn-coach' ? GetCNCoachSpiderGlobalCalculate:GetCNCoachOutletSpiderGlobalCalculate"
:add="()=>{return {Condition:'', Name:'',Pid: route.name === 'cn-coach'?'cn-coach':'cn-coach-outlet',Process:'' }}"
:del="route.name === 'cn-coach' ? DeleteCNCoachSpiderGlobalCalculate:DeleteCNCoachOutletSpiderGlobalCalculate"
:save="route.name === 'cn-coach' ? SaveCNCoachSpiderGlobalCalculate: SaveCNCoachOutletSpiderGlobalCalculate"
@ok="list"
></Calculate>
<Calculate v-model:visible="calculateModal.visible"
:getter="calculateModal.getter"
:add="calculateModal.add"
:del="calculateModal.del"
:save="calculateModal.save"
@ok="list"
></Calculate>
</template>
<script setup>
import {computed, h, onMounted, reactive, ref} from "vue";
import {computed, h, onMounted, reactive, ref, watch} from "vue";
import {GetProduct, ListProducts, UpdateProduct} from "@/api/product.js";
import moment from "moment/moment.js";
import { clone } from 'radash'
import {LoadingOutlined, SaveOutlined,CaretUpOutlined,CaretDownOutlined} from "@ant-design/icons-vue";
import {
LoadingOutlined,
SaveOutlined,
CaretUpOutlined,
CaretDownOutlined,
FormOutlined,
SettingOutlined
} from "@ant-design/icons-vue";
import {message} from "ant-design-vue";
import {WEBSITES} from "@/constants/website.js";
import {useRoute} from "vue-router";
import {
DeleteUSCoachOutletSpiderCalculate,
DeleteUSCoachOutletSpiderGlobalCalculate,
GetUSCoachOutletSpiderGlobalCalculate, SaveUSCoachOutletSpiderCalculate, SaveUSCoachOutletSpiderGlobalCalculate
} from "@/api/us-coach-outlet-spider.js";
import Calculate from "@/views/Product/Calculate.vue";
import {
DeleteCNCoachSpiderCalculate, DeleteCNCoachSpiderGlobalCalculate,
GetCNCoachSpiderGlobalCalculate,
SaveCNCoachSpiderCalculate, SaveCNCoachSpiderGlobalCalculate
} from "@/api/cn-coach-spider.js";
import {
DeleteCNCoachOutletSpiderCalculate, DeleteCNCoachOutletSpiderGlobalCalculate,
GetCNCoachOutletSpiderGlobalCalculate,
SaveCNCoachOutletSpiderCalculate, SaveCNCoachOutletSpiderGlobalCalculate
} from "@/api/cn-coach-outlet-spider.js";
const route = useRoute()
onMounted(()=>{
list()
watch(()=>route.name,loadShopType)
})
const query = reactive({
@ -106,6 +162,15 @@ const query = reactive({
website: WEBSITES.CN_COACH
})
const loadShopType = ()=>{
if (route.name === 'cn-coach'){
query.website = WEBSITES.CN_COACH
}else{
query.website = WEBSITES.CN_COACH_OUTLET
}
list()
}
const loading = ref(false)
@ -147,6 +212,11 @@ const columns = computed(()=>[
dataIndex: 'image',
key: 'image',
},
{
title: '价格(CNY)',
dataIndex: 'originalPrice',
key: 'originalPrice',
},
{
title: '成本(CNY)',
dataIndex: 'cnyPrice',
@ -200,9 +270,8 @@ const columns = computed(()=>[
key: 'remark',
},
{
title: 'coach链接',
dataIndex: 'link',
key: 'link',
title: '操作',
key: 'opt',
},
])
@ -288,6 +357,33 @@ const expand = (expanded, record)=>{
}
}
const globalCalculateVisible = ref(false)
const calculateModal = reactive({
visible : false,
getter: ()=>{},
add: ()=>{},
del: ()=>{},
save: ()=>{}
})
const showCalculateModal = (record)=>{
calculateModal.getter = ()=>{
return GetProduct(record.pid).then(res=>res.calculateProcess)
}
calculateModal.add = ()=>{
return {
Pid: record.pid,
website: route.name === 'cn-coach'?WEBSITES.CN_COACH:WEBSITES.CN_COACH_OUTLET,
Condition:'',
Name:'',
Process:''
}
}
calculateModal.del = route.name === 'cn-coach'? DeleteCNCoachSpiderCalculate:DeleteCNCoachOutletSpiderCalculate
calculateModal.save = route.name === 'cn-coach' ? SaveCNCoachSpiderCalculate: SaveCNCoachOutletSpiderCalculate
calculateModal.visible = true
}
</script>

View File

@ -52,7 +52,7 @@ const props = defineProps({
default: ()=>{}
}
})
const emit = defineEmits(['update:visible'])
const emit = defineEmits(['update:visible', 'ok'])
const open = computed({
get() {
if(props.visible){
@ -107,6 +107,7 @@ const save = ()=>{
props.save(modal.data.calculate).then(res=>{
open.value = false
message.success('保存成功')
emit('ok')
}).catch(err=>{
console.log(err)
message.error('保存失败')

View File

@ -139,14 +139,16 @@
<Calculate v-model:visible="globalCalculateVisible"
:getter="GetUSCoachOutletSpiderGlobalCalculate"
:add="()=>{return {Condition:'', Name:'',Pid:'us-coach-outlet',Process:'' }}"
:del="DeleteCnCoachOutletSpiderGlobalCalculate"
:del="DeleteUSCoachOutletSpiderGlobalCalculate"
:save="SaveUSCoachOutletSpiderGlobalCalculate"
@ok="list"
></Calculate>
<Calculate v-model:visible="calculateModal.visible"
:getter="calculateModal.getter"
:add="calculateModal.add"
:del="calculateModal.del"
:save="calculateModal.save"
@ok="list"
></Calculate>
</template>
<script setup>
@ -159,12 +161,12 @@ import {LoadingOutlined, SaveOutlined,SettingOutlined,CaretUpOutlined,CaretDownO
import {message, Modal} from "ant-design-vue";
import {CreateWatcher} from "@/api/watcher.js";
import {
DeleteCnCoachOutletSpiderCalculate,
DeleteCnCoachOutletSpiderGlobalCalculate,
DeleteUSCoachOutletSpiderCalculate,
DeleteUSCoachOutletSpiderGlobalCalculate,
GetUSCoachOutletSpiderCfg,
GetUSCoachOutletSpiderGlobalCalculate, SaveUSCoachOutletSpiderCalculate, SaveUSCoachOutletSpiderGlobalCalculate,
SetUSCoachOutletSpiderCfg
} from "@/api/cn-coach-outlet-spider.js";
} from "@/api/us-coach-outlet-spider.js";
import {WEBSITES} from "@/constants/website.js";
import Calculate from "@/views/Product/Calculate.vue";
@ -455,7 +457,7 @@ const showCalculateModal = (record)=>{
Process:''
}
}
calculateModal.del = DeleteCnCoachOutletSpiderCalculate
calculateModal.del = DeleteUSCoachOutletSpiderCalculate
calculateModal.save = SaveUSCoachOutletSpiderCalculate
calculateModal.visible = true
}

View File

@ -39,6 +39,11 @@ const items = [
label: '美国coach outlet',
title: '美国coach outlet',
},
{
key: 'cn-coach-outlet',
label: '中国coach outlet',
title: '中国coach outlet',
},
{
key: 'cn-coach',
label: '中国coach',