|
@@ -17,7 +17,7 @@
|
|
|
<el-form-item label="广告名称" prop="name">
|
|
|
<el-input v-model="ruleForm.name" style="width: 50%" />
|
|
|
</el-form-item>
|
|
|
- <div style="display: flex; border: 1px solid #dddfe6; padding: 0 0 0 5px; margin-bottom: 20px">
|
|
|
+ <div style="display: flex; border: 1px solid #dddfe6; padding: 0 0 0 5px; margin-bottom: 20px" v-loading="createLoading">
|
|
|
<div style="width: 50%; padding-left: 5px; border-right: 1px solid #dddfe6">
|
|
|
<el-scrollbar height="700px">
|
|
|
<el-collapse v-model="activeNames" @change="handleChange" style="border-top: none; border-bottom: none">
|
|
@@ -27,7 +27,15 @@
|
|
|
<el-input v-model="ruleForm.brandName" placeholder="请输入品牌名称" style="padding: 0 0 5px 0"></el-input>
|
|
|
</el-form-item>
|
|
|
|
|
|
- <el-upload v-model:file-list="fileList" action="#" accept=".png, .jpg" :limit="1" list-type="picture-card" :auto-upload="false">
|
|
|
+ <el-upload
|
|
|
+ v-model:file-list="fileList"
|
|
|
+ :on-change="changeFile"
|
|
|
+ v-loading="upLoading"
|
|
|
+ action="#"
|
|
|
+ accept=".png, .jpg"
|
|
|
+ :limit="1"
|
|
|
+ list-type="picture-card"
|
|
|
+ :auto-upload="false">
|
|
|
<el-icon><Plus /></el-icon>
|
|
|
<template #file="{ file }">
|
|
|
<div>
|
|
@@ -46,7 +54,7 @@
|
|
|
<div style="margin-top: 10px">
|
|
|
<div style="display: flex; align-items: center; justify-content: space-between">
|
|
|
<span style="line-height: 17px; font-weight: 600; color: #1e2128">徽标规格</span>
|
|
|
- <el-button type="primary" :icon="Picture" @click="openDialog">从素材库中选择</el-button>
|
|
|
+ <el-button type="primary" :icon="Picture" @click="openDialog" disabled="true">从素材库中选择</el-button>
|
|
|
</div>
|
|
|
<div class="introduce-item">1、图片大小: 400x400 像素或更大</div>
|
|
|
<div class="introduce-item">2、文件大小: 1MB 或更小</div>
|
|
@@ -72,33 +80,78 @@
|
|
|
<img w-full :src="dialogImageUrl" alt="Preview Image" />
|
|
|
</el-dialog>
|
|
|
</el-collapse-item>
|
|
|
+
|
|
|
<el-collapse-item name="commodity" v-loading="commodityLoading" style="padding-right: 10px">
|
|
|
<template #title>编辑品牌旗舰店页面</template>
|
|
|
- <div v-for="(item, index) in flattenedCommodityCard" :key="index" style="margin: 0 0 5px 0">
|
|
|
- <el-card shadow="hover" body-style="padding: 10px; display: flex;">
|
|
|
- <div style="margin-right: 8px; line-height: normal">
|
|
|
- <el-image class="img-box" :src="item.image_link" />
|
|
|
- </div>
|
|
|
- <div style="position: relative">
|
|
|
- <el-tooltip class="box-item" effect="dark" :content="item.title" placement="top">
|
|
|
- <div class="double-line">{{ item.title }}</div>
|
|
|
- </el-tooltip>
|
|
|
- <span>
|
|
|
- <span style="color: #6d7784">ASIN: </span>
|
|
|
- <span class="data-color" style="margin-right: 8px">{{ item.asin }}</span>
|
|
|
- </span>
|
|
|
- <el-button
|
|
|
- type="primary"
|
|
|
- size="small"
|
|
|
- link
|
|
|
- @click="() => openCommodityDialog(index)"
|
|
|
- style="position: absolute; bottom: 2px; right: 0">
|
|
|
- 更换商品
|
|
|
- </el-button>
|
|
|
+ <div v-for="(storePage, index) in topStorePages" :key="index" style="margin-bottom: 10px; width: 85%">
|
|
|
+ <el-card shadow="hover" body-style="padding: 10px;">
|
|
|
+ <div style="margin-right: 8px; line-height: normal; display: flex; align-items: center">
|
|
|
+ <el-image class="img-box" :src="storePage.storePageLink" />
|
|
|
+ <div style="margin-left: 15px">
|
|
|
+ <span><span style="color: #6d7784">当前名称:</span>{{ storePage.storePageName }}</span>
|
|
|
+ <div style="margin-bottom: 5px"><span style="color: #6d7784">ASIN: </span>{{ storePage.asin }}</div>
|
|
|
+ <el-input v-model="storePage.inputName" style="width: 300px" placeholder="修改品牌页面名称"></el-input>
|
|
|
+ </div>
|
|
|
+ <div class="card-operation">
|
|
|
+ <el-button link type="primary" @click="changePicture(storePage.storePageUrl, index)" style="margin-bottom: 10px"
|
|
|
+ >更换图片</el-button
|
|
|
+ >
|
|
|
+ <el-button link type="primary" @click="changePage(storePage.storePageUrl, index)">更换页面</el-button>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</el-card>
|
|
|
</div>
|
|
|
</el-collapse-item>
|
|
|
+ <el-dialog v-model="commodityDialog" title="更换图片" width="50%">
|
|
|
+ <el-radio-group
|
|
|
+ v-loading="dialogLoading3"
|
|
|
+ v-model="selectedCommodity"
|
|
|
+ style="display: flex; flex-direction: column; align-content: flex-start; align-items: flex-start">
|
|
|
+ <div v-for="(item, index) in stock" :key="index">
|
|
|
+ <el-radio :label="item.asin" style="height: 80px; border-bottom: 1px solid #ccc">
|
|
|
+ <div style="padding: 10px; display: flex; align-items: center">
|
|
|
+ <div style="margin-right: 8px; line-height: normal">
|
|
|
+ <el-image class="img-box" :src="item.image_link" />
|
|
|
+ </div>
|
|
|
+ <div style="position: relative">
|
|
|
+ <el-tooltip class="box-item" effect="dark" :content="item.title" placement="top">
|
|
|
+ <div class="double-line">{{ item.title }}</div>
|
|
|
+ </el-tooltip>
|
|
|
+ <span>
|
|
|
+ <span style="color: #6d7784">ASIN: </span>
|
|
|
+ <span class="data-color" style="margin-right: 8px">{{ item.asin }}</span>
|
|
|
+ </span>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </el-radio>
|
|
|
+ </div>
|
|
|
+ </el-radio-group>
|
|
|
+ <div style="margin-top: 20px; display: flex; justify-content: center">
|
|
|
+ <el-button type="primary" :disabled="!selectedCommodity" @click="handleSelectedStore">确定</el-button>
|
|
|
+ </div>
|
|
|
+ </el-dialog>
|
|
|
+ <el-dialog v-model="pageDialog" title="更换页面" width="50%">
|
|
|
+ <el-radio-group v-loading="pageDialogLoading" v-model="selectedCommodity" @change="handlePageChange" class="radio-group-item">
|
|
|
+ <div v-for="(item, index) in storePageData.storePageInfo" :key="index" style="width: 100%">
|
|
|
+ <el-radio
|
|
|
+ :label="item.storePageId"
|
|
|
+ class="radio-item"
|
|
|
+ :disabled="topStorePages.some((storePage) => storePage.storePageName === item.storePageName)">
|
|
|
+ <div class="radio-item-content">
|
|
|
+ <div style="position: relative">
|
|
|
+ <el-tooltip class="box-item" effect="dark" :content="item.storePageName" placement="top">
|
|
|
+ <div class="double-line">{{ item.storePageName }}</div>
|
|
|
+ </el-tooltip>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </el-radio>
|
|
|
+ </div>
|
|
|
+ </el-radio-group>
|
|
|
+ <!-- <div style="margin-top: 20px; display: flex; justify-content: center">
|
|
|
+ <el-button type="primary" :disabled="!selectedCommodity">确定</el-button>
|
|
|
+ </div> -->
|
|
|
+ </el-dialog>
|
|
|
+
|
|
|
<el-collapse-item name="4" style="padding-right: 10px">
|
|
|
<template #title> <span style="color: #e47470; margin-right: 4px">*</span>标题</template>
|
|
|
<el-form-item prop="title">
|
|
@@ -109,7 +162,9 @@
|
|
|
</el-scrollbar>
|
|
|
</div>
|
|
|
<div style="width: 50%; padding: 0 10px; position: relative">
|
|
|
- <el-button type="primary" plain @click="clickSave" style="position: absolute; top: 92%; left: 46%">保存</el-button>
|
|
|
+ <el-button type="primary" plain @click="submitForm(ruleFormRef)" :disabled="!fileList.length" style="position: absolute; top: 92%; left: 46%"
|
|
|
+ >保存</el-button
|
|
|
+ >
|
|
|
</div>
|
|
|
</div>
|
|
|
</el-form>
|
|
@@ -149,7 +204,7 @@
|
|
|
</span>
|
|
|
</template>
|
|
|
</el-dialog>
|
|
|
- <el-dialog v-model="lifeStyleDialog" title="从素材库中选择" width="65%">
|
|
|
+ <!-- <el-dialog v-model="lifeStyleDialog" title="从素材库中选择" width="65%">
|
|
|
<el-input :prefix-icon="Search"></el-input>
|
|
|
<div class="grid-container">
|
|
|
<div
|
|
@@ -183,51 +238,36 @@
|
|
|
<el-button type="primary" @click="centerDialogVisible = false">确定</el-button>
|
|
|
</span>
|
|
|
</template>
|
|
|
- </el-dialog>
|
|
|
- <el-dialog v-model="commodityDialog" title="更换商品" width="50%">
|
|
|
- <el-radio-group
|
|
|
- v-loading="dialogLoading3"
|
|
|
- v-model="selectedCommodity"
|
|
|
- style="display: flex; flex-direction: column; align-content: flex-start; align-items: flex-start">
|
|
|
- <div v-for="(item, index) in flattenedReplaceableCommodity" :key="index">
|
|
|
- <el-radio :label="item.asin" style="height: 80px; border-bottom: 1px solid #ccc">
|
|
|
- <div style="padding: 10px; display: flex; align-items: center">
|
|
|
- <div style="margin-right: 8px; line-height: normal">
|
|
|
- <el-image class="img-box" :src="item.image_link" />
|
|
|
- </div>
|
|
|
- <div style="position: relative">
|
|
|
- <el-tooltip class="box-item" effect="dark" :content="item.title" placement="top">
|
|
|
- <div class="double-line">{{ item.title }}</div>
|
|
|
- </el-tooltip>
|
|
|
- <span>
|
|
|
- <span style="color: #6d7784">ASIN: </span>
|
|
|
- <span class="data-color" style="margin-right: 8px">{{ item.asin }}</span>
|
|
|
- </span>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </el-radio>
|
|
|
- </div>
|
|
|
- </el-radio-group>
|
|
|
- <div style="margin-top: 20px; display: flex; justify-content: center">
|
|
|
- <el-button type="primary" :disabled="!selectedCommodity" @click="handleSelectedCommodity">确定</el-button>
|
|
|
- </div>
|
|
|
- </el-dialog>
|
|
|
+ </el-dialog> -->
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
-import { reactive, ref, inject, Ref, watch, computed } from 'vue'
|
|
|
+import { reactive, ref, inject, Ref, watch, computed, onMounted } from 'vue'
|
|
|
import type { FormInstance, FormRules, UploadProps, UploadUserFile } from 'element-plus'
|
|
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
|
|
import { Plus, Picture, Search, Delete, Download, ZoomIn } from '@element-plus/icons-vue'
|
|
|
import type { UploadFile } from 'element-plus'
|
|
|
-import { getAssets, getLifeStyleAssets, getPageAsins, getCommodityCard } from '../api/index'
|
|
|
+import emitter from '/@/utils/emitter'
|
|
|
+import {
|
|
|
+ getAssets,
|
|
|
+ getLifeStyleAssets,
|
|
|
+ getPageAsins,
|
|
|
+ getCommodityCard,
|
|
|
+ getStoreurl,
|
|
|
+ getDefaultSpotlightAsin,
|
|
|
+ getSellerInStock,
|
|
|
+ postStoreSpotlight,
|
|
|
+ uploadFile,
|
|
|
+ checkAsset,
|
|
|
+} from '../api/index'
|
|
|
import { storeToRefs } from 'pinia'
|
|
|
import { useShopInfo } from '/@/stores/shopInfo'
|
|
|
|
|
|
const shopInfo = useShopInfo()
|
|
|
const { profile } = storeToRefs(shopInfo)
|
|
|
|
|
|
+const createLoading = ref(false)
|
|
|
const ruleFormRef = ref<FormInstance>()
|
|
|
|
|
|
interface RuleForm {
|
|
@@ -252,6 +292,7 @@ const submitForm = async (formEl: FormInstance | undefined) => {
|
|
|
await formEl.validate((valid, fields) => {
|
|
|
if (valid) {
|
|
|
console.log('submit!')
|
|
|
+ createStoreSpotlight()
|
|
|
} else {
|
|
|
console.log('error submit!', fields)
|
|
|
}
|
|
@@ -260,9 +301,9 @@ const submitForm = async (formEl: FormInstance | undefined) => {
|
|
|
|
|
|
const activeNames = ref(['1'])
|
|
|
const handleChange = (val: string[]) => {
|
|
|
- console.log(val)
|
|
|
+ // console.log(val)
|
|
|
if (val.includes('commodity')) {
|
|
|
- getCommodityCardData()
|
|
|
+ // getCommodityCardData()
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -296,15 +337,6 @@ const selectedImageUrl = ref('')
|
|
|
const centerDialogVisible = ref(false)
|
|
|
const cards = reactive([])
|
|
|
|
|
|
-function handleRemove(file: UploadFile) {
|
|
|
- fileList.value = []
|
|
|
-}
|
|
|
-
|
|
|
-function handlePictureCardPreview(file: UploadFile) {
|
|
|
- dialogImageUrl.value = file.url!
|
|
|
- dialogVisible.value = true
|
|
|
-}
|
|
|
-
|
|
|
function selectCard(item) {
|
|
|
if (isSelected(item.id)) {
|
|
|
selectedCards.value = selectedCards.value.filter((card) => card.id !== item.id)
|
|
@@ -404,82 +436,339 @@ async function getLifeStyleAssetsData() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-function openLifeStyleDialog() {
|
|
|
- lifeStyleDialog.value = true
|
|
|
- getLifeStyleAssetsData()
|
|
|
+// function openLifeStyleDialog() {
|
|
|
+// lifeStyleDialog.value = true
|
|
|
+// getLifeStyleAssetsData()
|
|
|
+// }
|
|
|
+
|
|
|
+// 获取商品数据
|
|
|
+const topStorePages = ref([])
|
|
|
+const commodityLoading = ref(false)
|
|
|
+const dialogLoading3 = ref(false)
|
|
|
+let subpageslist = []
|
|
|
+
|
|
|
+async function getDefaultCommodityData() {
|
|
|
+ try {
|
|
|
+ commodityLoading.value = true
|
|
|
+ const resp = await getDefaultSpotlightAsin({ profile_id: '3006125408623189' })
|
|
|
+ if (resp.code === 2000) {
|
|
|
+ topStorePages.value = resp.data.defaultlist.map((item) => ({
|
|
|
+ storePageName: item.storePageName,
|
|
|
+ storePageLink: item.image_link,
|
|
|
+ storePageUrl: item.storePageUrl,
|
|
|
+ asin: item.asin,
|
|
|
+ inputName: item.storePageName, // 新增字段用于存储输入值
|
|
|
+ }))
|
|
|
+ subpageslist = topStorePages.value.map((item) => ({
|
|
|
+ asin: item.asin,
|
|
|
+ pageTitle: item.inputName,
|
|
|
+ url: item.storePageUrl,
|
|
|
+ }))
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.error('Error in getDefaultCommodityData:', error)
|
|
|
+ } finally {
|
|
|
+ commodityLoading.value = false
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
-const pageOptionsValue = inject<Ref>('pageOptionsValue')
|
|
|
const asinList = ref([])
|
|
|
-const commodityLoading = ref(false)
|
|
|
+const stock = ref([])
|
|
|
+const currentEditingIndex = ref(null)
|
|
|
+const selectedCommodityData = ref(null)
|
|
|
|
|
|
-async function getCommodityCollapseData() {
|
|
|
- commodityLoading.value = true
|
|
|
+async function changePicture(pageUrl, index) {
|
|
|
+ commodityDialog.value = true
|
|
|
+ dialogLoading3.value = true
|
|
|
+
|
|
|
+ currentEditingIndex.value = index
|
|
|
try {
|
|
|
const query = {
|
|
|
profile_id: profile.value.profile_id,
|
|
|
- pageurl: pageOptionsValue.value,
|
|
|
+ pageurl: pageUrl,
|
|
|
}
|
|
|
const response = await getPageAsins(query)
|
|
|
asinList.value = response.data.asinList
|
|
|
- console.log('asinList', asinList.value)
|
|
|
+ getStock()
|
|
|
+ dialogLoading3.value = false
|
|
|
+ } catch (error) {
|
|
|
+ console.log('error:', error)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+async function getStock() {
|
|
|
+ try {
|
|
|
+ const obj = {
|
|
|
+ profile_id: profile.value.profile_id,
|
|
|
+ asinlist: asinList.value,
|
|
|
+ }
|
|
|
+ const response = await getSellerInStock(obj)
|
|
|
+ stock.value = response.data
|
|
|
+ } catch (error) {
|
|
|
+ console.error('Error in getStock:', error)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function handleSelectedStore() {
|
|
|
+ if (currentEditingIndex.value !== null) {
|
|
|
+ selectedCommodityData.value = stock.value.find((item) => item.asin === selectedCommodity.value)
|
|
|
+ if (selectedCommodityData.value) {
|
|
|
+ // 更新图片链接和ASIN
|
|
|
+ topStorePages.value[currentEditingIndex.value].storePageLink = selectedCommodityData.value.image_link
|
|
|
+ topStorePages.value[currentEditingIndex.value].asin = selectedCommodityData.value.asin
|
|
|
+ // 更新输入框的绑定值以便可以继续编辑名称
|
|
|
+ topStorePages.value[currentEditingIndex.value].inputName = topStorePages.value[currentEditingIndex.value].inputName
|
|
|
+ console.log(topStorePages.value)
|
|
|
+ }
|
|
|
+ // 重置当前编辑索引和选中的商品
|
|
|
+ currentEditingIndex.value = null
|
|
|
+ selectedCommodity.value = null
|
|
|
+ commodityDialog.value = false
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// 更换页面功能
|
|
|
+const pageDialog = ref(false)
|
|
|
+const storePageData = ref({ storePageInfo: [] })
|
|
|
+const pageDialogLoading = ref(false)
|
|
|
+const selectedPageUrl = ref('')
|
|
|
+const firstObj: any = ref({})
|
|
|
+const pageAsinList = ref([])
|
|
|
+const selectedPageName = ref('')
|
|
|
+
|
|
|
+async function changePage(pageUrl, index) {
|
|
|
+ pageDialog.value = true
|
|
|
+ pageDialogLoading.value = true
|
|
|
+ currentEditingIndex.value = index
|
|
|
+ try {
|
|
|
+ const response = await getStoreurl({ profile_id: profile.value.profile_id })
|
|
|
+ storePageData.value = response.data
|
|
|
} catch (error) {
|
|
|
console.log('error:', error)
|
|
|
} finally {
|
|
|
- commodityLoading.value = false
|
|
|
+ pageDialogLoading.value = false
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-function clickSave() {
|
|
|
- console.log(123, fileList.value)
|
|
|
+async function getAsinList(pageurl) {
|
|
|
+ try {
|
|
|
+ const query = {
|
|
|
+ profile_id: profile.value.profile_id,
|
|
|
+ pageurl: pageurl,
|
|
|
+ }
|
|
|
+ const resp = await getPageAsins(query)
|
|
|
+ pageAsinList.value = resp.data.asinList
|
|
|
+
|
|
|
+ changeCardData()
|
|
|
+ } catch (error) {
|
|
|
+ console.log('error:', error)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
-let lastQueriedAsins = []
|
|
|
-const commodityCard = ref([])
|
|
|
-async function getCommodityCardData() {
|
|
|
+async function handlePageChange(selectedPageId) {
|
|
|
+ const selectedPage = storePageData.value.storePageInfo.find((page) => page.storePageId === selectedPageId)
|
|
|
+ if (selectedPage) {
|
|
|
+ selectedPageUrl.value = selectedPage.storePageUrl
|
|
|
+ selectedPageName.value = selectedPage.storePageName
|
|
|
+ pageDialog.value = false
|
|
|
+ await getAsinList(selectedPageUrl.value)
|
|
|
+ } else {
|
|
|
+ console.error('Selected page not found in storePageData')
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+async function changeCardData() {
|
|
|
try {
|
|
|
- commodityLoading.value = true
|
|
|
- const topAsins = asinList.value.slice(0, 3)
|
|
|
+ const query = {
|
|
|
+ profile_id: profile.value.profile_id,
|
|
|
+ asinlist: pageAsinList.value,
|
|
|
+ }
|
|
|
+ const response = await getSellerInStock(query)
|
|
|
+ if (response && response.data.length > 0) {
|
|
|
+ // 将response的第一个元素赋值给firstObj
|
|
|
+ firstObj.value = response.data[0]
|
|
|
+
|
|
|
+ // 更新图片链接和ASIN
|
|
|
+ topStorePages.value[currentEditingIndex.value].storePageLink = firstObj.value.image_link
|
|
|
+ topStorePages.value[currentEditingIndex.value].asin = firstObj.value.asin
|
|
|
+ topStorePages.value[currentEditingIndex.value].storePageName = selectedPageName.value
|
|
|
+ topStorePages.value[currentEditingIndex.value].inputName = selectedPageName.value
|
|
|
+ currentEditingIndex.value = null
|
|
|
+ } else {
|
|
|
+ console.error('No data')
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.error('error:', error)
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
- const newAsins = topAsins.filter((asin) => !lastQueriedAsins.includes(asin))
|
|
|
- if (newAsins.length === 0) {
|
|
|
- commodityLoading.value = false
|
|
|
- return // 如果没有新的 ASIN,直接返回
|
|
|
+// 创建创意
|
|
|
+let brandName = ''
|
|
|
+let brandEntityId = ''
|
|
|
+const respAdGroupId = inject<Ref>('respAdGroupId')
|
|
|
+let brandLogoCrop = {}
|
|
|
+
|
|
|
+const upLoading = ref(false)
|
|
|
+let respAssetId = ''
|
|
|
+
|
|
|
+function handleRemove(file: UploadFile) {
|
|
|
+ fileList.value = []
|
|
|
+}
|
|
|
+
|
|
|
+function handlePictureCardPreview(file: UploadFile) {
|
|
|
+ dialogImageUrl.value = file.url!
|
|
|
+ dialogVisible.value = true
|
|
|
+}
|
|
|
+
|
|
|
+function changeFile(file: UploadFile) {
|
|
|
+ handleUpload(file)
|
|
|
+}
|
|
|
+
|
|
|
+async function handleUpload(file: UploadFile) {
|
|
|
+ const formData = new FormData()
|
|
|
+ formData.append('file', file.raw)
|
|
|
+ formData.append('profile_id', profile.value.profile_id)
|
|
|
+ formData.append('brandEntityId', brandEntityId)
|
|
|
+ formData.append('assetType', 'IMAGE')
|
|
|
+ formData.append('assetSubTypeList', JSON.stringify(['LOGO']))
|
|
|
+ upLoading.value = true
|
|
|
+ try {
|
|
|
+ const response = await uploadFile(formData)
|
|
|
+ const fileName = response.data.file_name
|
|
|
+ const obj = {
|
|
|
+ profile_id: profile.value.profile_id,
|
|
|
+ file_name: fileName,
|
|
|
+ }
|
|
|
+ const resp = await checkAsset(obj)
|
|
|
+ respAssetId = resp.data.assetId
|
|
|
+ const { width, height } = resp.data.fileMetadata
|
|
|
+ brandLogoCrop = {
|
|
|
+ width,
|
|
|
+ height,
|
|
|
+ top: 0,
|
|
|
+ left: 0,
|
|
|
}
|
|
|
|
|
|
- lastQueriedAsins = [...topAsins]
|
|
|
+ if (resp.data.checkresult == 'success') {
|
|
|
+ ElMessage({ message: '上传成功', type: 'success' })
|
|
|
+ } else {
|
|
|
+ ElMessage.error('上传失败')
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.error('上传失败:', error)
|
|
|
+ } finally {
|
|
|
+ upLoading.value = false
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
- // 清空commodityCard,为新数据做准备
|
|
|
- commodityCard.value = []
|
|
|
+async function createStoreSpotlight() {
|
|
|
+ createLoading.value = true
|
|
|
+ try {
|
|
|
+ const query = {
|
|
|
+ profile_id: profile.value.profile_id,
|
|
|
+ url: 'https://www.amazon.com/stores/page/1D1DD2FD-CF54-4FE5-B1A0-9E01F12F8144',
|
|
|
+ name: ruleForm.name,
|
|
|
+ state: 'PAUSED',
|
|
|
+ adGroupId: respAdGroupId.value,
|
|
|
+ brandName: brandName,
|
|
|
+ brandLogoAssetID: respAssetId,
|
|
|
+ brandLogoCrop: brandLogoCrop,
|
|
|
+ consentToTranslate: false,
|
|
|
+ subpageslist: subpageslist,
|
|
|
+ headline: ruleForm.title,
|
|
|
+ }
|
|
|
+ const response = await postStoreSpotlight(query)
|
|
|
+ if (response.data.creative_state == 'success') {
|
|
|
+ ElMessage({ message: '创建成功', type: 'success' })
|
|
|
+ } else {
|
|
|
+ ElMessage.error('上传失败')
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.error('error:', error)
|
|
|
+ } finally {
|
|
|
+ createLoading.value = false
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
- // 对每个新的 ASIN 发送请求
|
|
|
- for (const asin of newAsins) {
|
|
|
- const query = {
|
|
|
- profile_id: profile.value.profile_id,
|
|
|
- asin: asin,
|
|
|
- }
|
|
|
+watch(topStorePages, () => {
|
|
|
+ subpageslist = topStorePages.value.map((item) => ({
|
|
|
+ asin: item.asin,
|
|
|
+ pageTitle: item.inputName,
|
|
|
+ url: item.storePageUrl,
|
|
|
+ }))
|
|
|
+ console.log('subpageslist', subpageslist)
|
|
|
+},{deep: true})
|
|
|
|
|
|
- try {
|
|
|
- const response = await getCommodityCard(query)
|
|
|
- commodityCard.value.push(response.data)
|
|
|
- // console.log('Response for ASIN', asin, ':', response)
|
|
|
- } catch (error) {
|
|
|
- console.log('Error for ASIN', asin, ':', error)
|
|
|
- }
|
|
|
+onMounted(() => {
|
|
|
+ emitter.on('spotlight-shop', (newValue: any) => {
|
|
|
+ brandName = newValue.brandRegistryName
|
|
|
+ brandEntityId = newValue.brandEntityId
|
|
|
+ })
|
|
|
+})
|
|
|
+
|
|
|
+const focusShop = inject<Ref>('focusShop')
|
|
|
+
|
|
|
+async function getCommodityCollapseData() {
|
|
|
+ commodityLoading.value = true
|
|
|
+ try {
|
|
|
+ const query = {
|
|
|
+ profile_id: profile.value.profile_id,
|
|
|
+ pageurl: focusShop.value,
|
|
|
}
|
|
|
+ const response = await getPageAsins(query)
|
|
|
+ asinList.value = response.data.asinList
|
|
|
+ console.log('asinList', asinList.value)
|
|
|
} catch (error) {
|
|
|
- console.log('Outer error:', error)
|
|
|
+ console.log('error:', error)
|
|
|
} finally {
|
|
|
commodityLoading.value = false
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+// let lastQueriedAsins = []
|
|
|
+const commodityCard = ref([])
|
|
|
+// async function getCommodityCardData() {
|
|
|
+// try {
|
|
|
+// commodityLoading.value = true
|
|
|
+// const topAsins = asinList.value.slice(0, 3)
|
|
|
+
|
|
|
+// const newAsins = topAsins.filter((asin) => !lastQueriedAsins.includes(asin))
|
|
|
+// if (newAsins.length === 0) {
|
|
|
+// commodityLoading.value = false
|
|
|
+// return // 如果没有新的 ASIN,直接返回
|
|
|
+// }
|
|
|
+
|
|
|
+// lastQueriedAsins = [...topAsins]
|
|
|
+
|
|
|
+// // 清空commodityCard,为新数据做准备
|
|
|
+// commodityCard.value = []
|
|
|
+
|
|
|
+// // 对每个新的 ASIN 发送请求
|
|
|
+// for (const asin of newAsins) {
|
|
|
+// const query = {
|
|
|
+// profile_id: profile.value.profile_id,
|
|
|
+// asin: asin,
|
|
|
+// }
|
|
|
+
|
|
|
+// try {
|
|
|
+// const response = await getCommodityCard(query)
|
|
|
+// commodityCard.value.push(response.data)
|
|
|
+// // console.log('Response for ASIN', asin, ':', response)
|
|
|
+// } catch (error) {
|
|
|
+// console.log('Error for ASIN', asin, ':', error)
|
|
|
+// }
|
|
|
+// }
|
|
|
+// } catch (error) {
|
|
|
+// console.log('Outer error:', error)
|
|
|
+// } finally {
|
|
|
+// commodityLoading.value = false
|
|
|
+// }
|
|
|
+// }
|
|
|
+
|
|
|
// 更改商品功能
|
|
|
const commodityDialog = ref(false)
|
|
|
const selectedCommodity = ref()
|
|
|
const replaceableCommodity = ref([])
|
|
|
-const dialogLoading3 = ref(false)
|
|
|
-let currentEditingIndex = ref(null)
|
|
|
|
|
|
function openCommodityDialog(index) {
|
|
|
currentEditingIndex.value = index
|
|
@@ -518,28 +807,6 @@ async function getAdditionalCommodityData() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-function handleSelectedCommodity() {
|
|
|
- if (currentEditingIndex.value !== null && selectedCommodity.value) {
|
|
|
- const selectedCommodityData = flattenedReplaceableCommodity.value.find((item) => item.asin === selectedCommodity.value)
|
|
|
- if (selectedCommodityData) {
|
|
|
- commodityCard.value[currentEditingIndex.value] = selectedCommodityData
|
|
|
- }
|
|
|
- commodityDialog.value = false
|
|
|
- console.log('commodityCard', commodityCard.value)
|
|
|
- currentEditingIndex.value = null
|
|
|
- selectedCommodity.value = null
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-watch(
|
|
|
- () => pageOptionsValue.value,
|
|
|
- async () => {
|
|
|
- await getCommodityCollapseData()
|
|
|
- getCommodityCardData()
|
|
|
- getAdditionalCommodityData()
|
|
|
- }
|
|
|
-)
|
|
|
-
|
|
|
const flattenedCommodityCard = computed(() => {
|
|
|
return commodityCard.value.flat()
|
|
|
})
|
|
@@ -547,6 +814,19 @@ const flattenedCommodityCard = computed(() => {
|
|
|
const flattenedReplaceableCommodity = computed(() => {
|
|
|
return replaceableCommodity.value.flat()
|
|
|
})
|
|
|
+// watch(focusShop.value,
|
|
|
+// async () => {
|
|
|
+// await getCommodityCollapseData()
|
|
|
+// getCommodityCardData()
|
|
|
+// getAdditionalCommodityData()
|
|
|
+// }
|
|
|
+// )
|
|
|
+onMounted(async () => {
|
|
|
+ await getDefaultCommodityData()
|
|
|
+ // await getCommodityCollapseData()
|
|
|
+ // getCommodityCardData()
|
|
|
+ // getAdditionalCommodityData()
|
|
|
+})
|
|
|
</script>
|
|
|
|
|
|
<style scoped>
|
|
@@ -644,7 +924,6 @@ const flattenedReplaceableCommodity = computed(() => {
|
|
|
display: block;
|
|
|
margin-bottom: 10px; /* 或根据需要调整 */
|
|
|
}
|
|
|
-
|
|
|
.upload-content {
|
|
|
text-align: center;
|
|
|
padding: 20px;
|
|
@@ -660,7 +939,7 @@ const flattenedReplaceableCommodity = computed(() => {
|
|
|
background-color: #3569d6;
|
|
|
}
|
|
|
.img-box {
|
|
|
- width: 60px;
|
|
|
+ min-width: 60px;
|
|
|
height: 60px;
|
|
|
border: 1px solid rgb(194, 199, 207);
|
|
|
border-radius: 4px;
|
|
@@ -675,4 +954,27 @@ const flattenedReplaceableCommodity = computed(() => {
|
|
|
white-space: pre-wrap;
|
|
|
word-break: break-word;
|
|
|
}
|
|
|
+.card-operation {
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+ align-items: flex-end;
|
|
|
+ justify-content: center;
|
|
|
+ margin-left: 30px;
|
|
|
+}
|
|
|
+.radio-group-item {
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+ align-content: flex-start;
|
|
|
+ align-items: flex-start;
|
|
|
+}
|
|
|
+.radio-item {
|
|
|
+ height: 80px;
|
|
|
+ width: 100%;
|
|
|
+ border-bottom: 1px solid #ccc;
|
|
|
+}
|
|
|
+.radio-item-content {
|
|
|
+ padding: 10px;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+}
|
|
|
</style>
|