1
This commit is contained in:
@@ -200,7 +200,6 @@
|
|||||||
<el-button type="primary" @click="openQuickLink(currentChild)" v-if="currentChild.jsonQueryResult">一键转链</el-button>
|
<el-button type="primary" @click="openQuickLink(currentChild)" v-if="currentChild.jsonQueryResult">一键转链</el-button>
|
||||||
<el-button type="warning" @click="openGiftDialog(currentChild)" v-if="currentChild.jsonQueryResult">开礼金</el-button>
|
<el-button type="warning" @click="openGiftDialog(currentChild)" v-if="currentChild.jsonQueryResult">开礼金</el-button>
|
||||||
<el-button type="success" @click="addToFavorites(currentChild)" v-if="currentChild.jsonQueryResult">添加到常用</el-button>
|
<el-button type="success" @click="addToFavorites(currentChild)" v-if="currentChild.jsonQueryResult">添加到常用</el-button>
|
||||||
<el-button type="warning" @click="quickLinkAndAddToFavorites(currentChild)" v-if="currentChild.jsonQueryResult">转链并入常用</el-button>
|
|
||||||
</div>
|
</div>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
|
|
||||||
@@ -290,8 +289,46 @@
|
|||||||
</template>
|
</template>
|
||||||
</el-alert>
|
</el-alert>
|
||||||
</div>
|
</div>
|
||||||
<div style="margin: 10px 0;">
|
|
||||||
|
<!-- 顶部左右布局:左输入,右通用文案(可多输入框) -->
|
||||||
|
<div style="display:flex; gap:12px; align-items:flex-start; margin: 10px 0;">
|
||||||
|
<div style="flex:1; min-width: 360px;">
|
||||||
|
<div style="display:flex; justify-content:space-between; align-items:center; margin-bottom:6px;">
|
||||||
|
<span style="font-weight:600;">输入内容</span>
|
||||||
|
<div>
|
||||||
|
<el-button type="primary" size="mini" :loading="quickLinkLoading" @click="generateQuickLink">生成转链内容</el-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<el-input type="textarea" :rows="6" v-model="quickLinkInput" placeholder="示例 https://u.jd.com/... 或商品关键词" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div style="flex:1; min-width: 360px;">
|
||||||
|
<div style="display:flex; justify-content:space-between; align-items:center; margin-bottom:6px;">
|
||||||
|
<span style="font-weight:600;">通用文案</span>
|
||||||
|
<div style="display:flex; gap:6px; align-items:center;">
|
||||||
|
<el-button size="mini" type="primary" @click="generateWenanFromQuickLink">生成文案</el-button>
|
||||||
|
<span>礼金</span>
|
||||||
|
<el-input v-model.number="quickLinkGift.amount" size="mini" style="width:80px" type="number" min="1" max="50" step="0.01" />
|
||||||
|
<el-input v-model.number="quickLinkGift.quantity" size="mini" style="width:70px" type="number" min="1" max="100" />
|
||||||
|
<el-button size="mini" type="warning" :loading="quickLinkGift.loading" @click="generateWenanWithGift">开礼金并生成</el-button>
|
||||||
|
<el-button size="mini" @click="handleCopyText(quickLinkWenanText)" :disabled="!quickLinkWenanText">复制</el-button>
|
||||||
|
<el-button size="mini" icon="el-icon-plus" @click="addExtraWenanBox">添加输入框</el-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<el-input type="textarea" :rows="6" v-model="quickLinkWenanText" placeholder="点击上方按钮生成文案" />
|
||||||
|
<div v-for="(val, i) in quickLinkExtraTexts" :key="'extra-'+i" style="margin-top:8px;">
|
||||||
|
<div style="display:flex; justify-content:flex-end; gap:6px; margin-bottom:4px;">
|
||||||
|
<el-button size="mini" @click="handleCopyText(quickLinkExtraTexts[i])" :disabled="!quickLinkExtraTexts[i]">复制</el-button>
|
||||||
|
<el-button size="mini" type="danger" icon="el-icon-delete" @click="removeExtraWenanBox(i)"></el-button>
|
||||||
|
</div>
|
||||||
|
<el-input type="textarea" :rows="4" v-model="quickLinkExtraTexts[i]" placeholder="自定义文案输入" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div style="margin: 10px 0; display:flex; gap:10px; flex-wrap:wrap;">
|
||||||
<el-button type="primary" :loading="quickLinkLoading" @click="generateQuickLink">生成转链内容</el-button>
|
<el-button type="primary" :loading="quickLinkLoading" @click="generateQuickLink">生成转链内容</el-button>
|
||||||
|
<el-button type="success" :disabled="!Array.isArray(parsedQuickLinkResult) || !parsedQuickLinkResult.length" @click="addQuickLinkResultsToFavorites">全部加入常用</el-button>
|
||||||
<el-button @click="quickLinkVisible = false">关闭</el-button>
|
<el-button @click="quickLinkVisible = false">关闭</el-button>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="Array.isArray(parsedQuickLinkResult) && parsedQuickLinkResult.length">
|
<div v-if="Array.isArray(parsedQuickLinkResult) && parsedQuickLinkResult.length">
|
||||||
@@ -305,11 +342,27 @@
|
|||||||
<div style="margin-top:4px;"><strong>价格:</strong>{{ it.price ? `¥${it.price}` : '-' }} <span v-if="it.commissionShare" style="color:#67c23a;">/ 佣金比 {{ it.commissionShare }}%</span></div>
|
<div style="margin-top:4px;"><strong>价格:</strong>{{ it.price ? `¥${it.price}` : '-' }} <span v-if="it.commissionShare" style="color:#67c23a;">/ 佣金比 {{ it.commissionShare }}%</span></div>
|
||||||
<div style="margin-top:4px;"><strong>链接:</strong><el-link v-if="it.materialUrl || it.url" :href="it.materialUrl || it.url" target="_blank">查看</el-link><span v-else>-</span></div>
|
<div style="margin-top:4px;"><strong>链接:</strong><el-link v-if="it.materialUrl || it.url" :href="it.materialUrl || it.url" target="_blank">查看</el-link><span v-else>-</span></div>
|
||||||
</div>
|
</div>
|
||||||
<div style="flex:0 0 auto;">
|
<div style="flex:0 0 auto; display:flex; gap:8px;">
|
||||||
<el-button type="success" size="mini" @click="addQuickLinkItemToFavorites(it)">加入常用</el-button>
|
<el-button type="success" size="mini" @click="addQuickLinkItemToFavorites(it)">加入常用</el-button>
|
||||||
|
<el-button type="primary" size="mini" @click="openPublishFromQuickLink(it)">发品</el-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</el-card>
|
</el-card>
|
||||||
|
|
||||||
|
<!-- 文案输出区 -->
|
||||||
|
<el-divider>文案输出</el-divider>
|
||||||
|
<div style="display:flex; gap:10px; align-items:center; flex-wrap:wrap; margin-bottom:8px;">
|
||||||
|
<el-button size="mini" type="primary" @click="generateWenanFromQuickLink">生成文案</el-button>
|
||||||
|
<div style="display:flex; gap:6px; align-items:center;">
|
||||||
|
<span>礼金金额(元)</span>
|
||||||
|
<el-input v-model.number="quickLinkGift.amount" size="mini" style="width:90px" type="number" min="1" max="50" step="0.01" />
|
||||||
|
<span>数量</span>
|
||||||
|
<el-input v-model.number="quickLinkGift.quantity" size="mini" style="width:80px" type="number" min="1" max="100" />
|
||||||
|
<el-button size="mini" type="warning" :loading="quickLinkGift.loading" @click="generateWenanWithGift">开礼金并生成文案</el-button>
|
||||||
|
</div>
|
||||||
|
<el-button size="mini" @click="handleCopyText(quickLinkWenanText)" :disabled="!quickLinkWenanText">复制文案</el-button>
|
||||||
|
</div>
|
||||||
|
<el-input type="textarea" :rows="6" v-model="quickLinkWenanText" placeholder="点击上方按钮生成文案" />
|
||||||
</div>
|
</div>
|
||||||
<div slot="footer" class="dialog-footer">
|
<div slot="footer" class="dialog-footer">
|
||||||
<el-button @click="quickLinkVisible = false">关 闭</el-button>
|
<el-button @click="quickLinkVisible = false">关 闭</el-button>
|
||||||
@@ -388,6 +441,10 @@ export default {
|
|||||||
activeQuickLinkTab: 0,
|
activeQuickLinkTab: 0,
|
||||||
activeQuickLinkWenanTab: {},
|
activeQuickLinkWenanTab: {},
|
||||||
quickLinkLoading: false,
|
quickLinkLoading: false,
|
||||||
|
quickLinkInput: '',
|
||||||
|
quickLinkWenanText: '',
|
||||||
|
quickLinkGift: { amount: null, quantity: 10, loading: false },
|
||||||
|
quickLinkExtraTexts: [],
|
||||||
giftDialogVisible: false,
|
giftDialogVisible: false,
|
||||||
giftForm: { amount: null, quantity: 10 },
|
giftForm: { amount: null, quantity: 10 },
|
||||||
giftLoading: false,
|
giftLoading: false,
|
||||||
@@ -572,6 +629,8 @@ export default {
|
|||||||
this.publishDialogVisible = true;
|
this.publishDialogVisible = true;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
addExtraWenanBox() { this.quickLinkExtraTexts.push(''); },
|
||||||
|
removeExtraWenanBox(i) { this.quickLinkExtraTexts.splice(i, 1); },
|
||||||
// 兼容多种结构提取图片URL(线报查询结果/行数据)
|
// 兼容多种结构提取图片URL(线报查询结果/行数据)
|
||||||
extractImageUrlsFromQuery(queryObj, rowFallback) {
|
extractImageUrlsFromQuery(queryObj, rowFallback) {
|
||||||
try {
|
try {
|
||||||
@@ -983,6 +1042,106 @@ export default {
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
/** 由转链结果生成文案(不带礼金替换) */
|
||||||
|
generateWenanFromQuickLink() {
|
||||||
|
if (!Array.isArray(this.parsedQuickLinkResult) || !this.parsedQuickLinkResult.length) {
|
||||||
|
this.$modal.msgWarning('请先生成转链内容');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 拼接首条或全部的文案
|
||||||
|
const parts = [];
|
||||||
|
this.parsedQuickLinkResult.forEach((it) => {
|
||||||
|
const title = this.decodeUnicode(it.skuName || it.title || '');
|
||||||
|
const firstWenan = Array.isArray(it.wenan) && it.wenan.length ? it.wenan[0].content : '';
|
||||||
|
const link = it.materialUrl || it.url || '';
|
||||||
|
parts.push([title, firstWenan, link].filter(Boolean).join('\n'));
|
||||||
|
});
|
||||||
|
this.quickLinkWenanText = parts.join('\n\n');
|
||||||
|
this.$modal.msgSuccess('文案已生成');
|
||||||
|
},
|
||||||
|
/** 开礼金并生成替换后的文案(逐条创建礼金,替换每条链接) */
|
||||||
|
async generateWenanWithGift() {
|
||||||
|
if (!Array.isArray(this.parsedQuickLinkResult) || !this.parsedQuickLinkResult.length) {
|
||||||
|
this.$modal.msgWarning('请先生成转链内容');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!this.quickLinkGift.amount || !this.quickLinkGift.quantity) {
|
||||||
|
this.$modal.msgWarning('请输入礼金金额与数量');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.quickLinkGift.loading = true;
|
||||||
|
const parts = [];
|
||||||
|
for (const it of this.parsedQuickLinkResult) {
|
||||||
|
try {
|
||||||
|
const materialUrl = it.materialUrl || it.url;
|
||||||
|
const owner = it.owner || 'g';
|
||||||
|
const skuName = it.skuName || it.title || '';
|
||||||
|
if (!materialUrl) continue;
|
||||||
|
// 1) 开礼金
|
||||||
|
const cg = await createGiftCoupon({ amount: this.quickLinkGift.amount, quantity: this.quickLinkGift.quantity, materialUrl, owner, skuName });
|
||||||
|
const giftKey = cg && cg.data && (cg.data.giftCouponKey || cg.data.giftKey);
|
||||||
|
// 2) 转链(带礼金)
|
||||||
|
let shortUrl = materialUrl;
|
||||||
|
if (giftKey) {
|
||||||
|
const tf = await transferWithGift({ materialUrl, giftCouponKey: giftKey });
|
||||||
|
if (tf && tf.data) {
|
||||||
|
if (typeof tf.data === 'string') shortUrl = tf.data; else if (tf.data.shortURL) shortUrl = tf.data.shortURL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const title = this.decodeUnicode(it.skuName || it.title || '');
|
||||||
|
const firstWenan = Array.isArray(it.wenan) && it.wenan.length ? it.wenan[0].content : '';
|
||||||
|
parts.push([title, firstWenan, shortUrl].filter(Boolean).join('\n'));
|
||||||
|
} catch (e) {
|
||||||
|
// 单条失败不中断
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.quickLinkWenanText = parts.join('\n\n');
|
||||||
|
this.quickLinkGift.loading = false;
|
||||||
|
this.$modal.msgSuccess('礼金已开通并生成文案');
|
||||||
|
},
|
||||||
|
/** 将一键转链结果全部加入常用 */
|
||||||
|
async addQuickLinkResultsToFavorites() {
|
||||||
|
if (!Array.isArray(this.parsedQuickLinkResult) || !this.parsedQuickLinkResult.length) return;
|
||||||
|
let success = 0, skipped = 0, failed = 0;
|
||||||
|
for (const it of this.parsedQuickLinkResult) {
|
||||||
|
try {
|
||||||
|
const spuid = it.spuid || '';
|
||||||
|
if (!spuid) { skipped++; continue; }
|
||||||
|
const exist = await getBySkuid(spuid);
|
||||||
|
if (exist && exist.data) { skipped++; continue; }
|
||||||
|
const favoriteData = {
|
||||||
|
skuid: spuid,
|
||||||
|
productName: it.skuName || it.title || '',
|
||||||
|
shopName: it.shopName || '',
|
||||||
|
shopId: it.shopId || '',
|
||||||
|
productUrl: it.materialUrl || it.url || '',
|
||||||
|
productImage: Array.isArray(it.images) && it.images.length ? it.images[0] : '',
|
||||||
|
price: it.price || '',
|
||||||
|
commissionInfo: it.commissionShare ? `${it.commissionShare}%` : (it.commission || ''),
|
||||||
|
remark: '来自一键转链',
|
||||||
|
isTop: 0,
|
||||||
|
sortWeight: 0
|
||||||
|
};
|
||||||
|
const addRes = await addToFavorites(favoriteData);
|
||||||
|
if (addRes && addRes.code === 200) success++; else failed++;
|
||||||
|
} catch (e) { failed++; }
|
||||||
|
}
|
||||||
|
this.$modal.msgSuccess(`加入常用完成:成功${success},跳过${skipped},失败${failed}`);
|
||||||
|
if (success > 0) this.$store.dispatch('app/triggerFavoriteProductRefresh');
|
||||||
|
},
|
||||||
|
/** 从转链结果直接打开发品弹窗 */
|
||||||
|
openPublishFromQuickLink(it) {
|
||||||
|
const images = Array.isArray(it.images) ? it.images : [];
|
||||||
|
const wenanOptions = Array.isArray(it.wenan) ? it.wenan.map((w, i) => ({ label: w.type || `版本${i+1}`, content: w.content || '' })) : [];
|
||||||
|
this.publishInitialData = {
|
||||||
|
title: it.skuName || it.title || '',
|
||||||
|
content: (wenanOptions[0] && wenanOptions[0].content) || '',
|
||||||
|
images: images,
|
||||||
|
originalPrice: it.price ? Number(it.price) : undefined,
|
||||||
|
wenanOptions
|
||||||
|
};
|
||||||
|
this.publishDialogVisible = true;
|
||||||
|
},
|
||||||
/** 复制文本 */
|
/** 复制文本 */
|
||||||
handleCopyText(text) {
|
handleCopyText(text) {
|
||||||
this.$copyText(text).then(() => {
|
this.$copyText(text).then(() => {
|
||||||
@@ -1343,12 +1502,12 @@ export default {
|
|||||||
|
|
||||||
/** 生成转链内容 */
|
/** 生成转链内容 */
|
||||||
generateQuickLink() {
|
generateQuickLink() {
|
||||||
if (!this.quickLinkProduct) return;
|
if (!this.quickLinkProduct && !this.quickLinkInput) return;
|
||||||
|
|
||||||
this.quickLinkLoading = true;
|
this.quickLinkLoading = true;
|
||||||
// 从线报消息中提取商品链接或信息
|
// 从线报消息中提取商品链接或信息
|
||||||
const materialUrl = this.getJsonValue(this.quickLinkProduct.jsonQueryResult, 'materialUrl');
|
const materialUrl = this.quickLinkInput || this.getJsonValue(this.quickLinkProduct.jsonQueryResult, 'materialUrl');
|
||||||
const skuName = this.quickLinkProduct.skuName;
|
const skuName = this.quickLinkProduct ? this.quickLinkProduct.skuName : '';
|
||||||
|
|
||||||
let inputContent = '';
|
let inputContent = '';
|
||||||
if (materialUrl) {
|
if (materialUrl) {
|
||||||
|
|||||||
Reference in New Issue
Block a user