This commit is contained in:
2025-08-21 23:42:49 +08:00
parent c8fdaf9e35
commit eb1c66b3b6

View File

@@ -5,24 +5,45 @@
<span>一键转链</span>
</div>
<el-form :model="form" label-width="120px">
<el-form-item label="输入内容">
<el-input
v-model="form.inputContent"
type="textarea"
:rows="6"
placeholder="请输入需要转链的内容,如商品链接、商品名称等"
style="width: 100%"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="handleGenerate" :loading="loading">
生成转链内容
</el-button>
<el-button @click="handleClear">清空</el-button>
</el-form-item>
</el-form>
<el-row :gutter="20">
<el-col :span="12">
<el-form :model="form" label-width="120px" label-position="top">
<el-form-item label="输入内容">
<el-input
v-model="form.inputContent"
type="textarea"
:rows="10"
placeholder="请输入需要转链的内容,如商品链接、商品名称等"
style="width: 100%"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="handleGenerate" :loading="loading">
生成转链内容
</el-button>
<el-button @click="handleClear">清空</el-button>
</el-form-item>
</el-form>
</el-col>
<el-col :span="12">
<el-form label-position="top">
<el-form-item label="通用文案">
<el-input
:value="generalCopy"
type="textarea"
:rows="10"
readonly
placeholder="暂无通用文案"
style="width: 100%"
/>
</el-form-item>
<div style="margin-top: 10px;">
<el-button type="success" @click="handleCopyText(generalCopy)" :disabled="!generalCopy">复制通用文案</el-button>
</div>
</el-form>
</el-col>
</el-row>
<div v-if="result" style="margin-top: 20px;">
<h4>转链结果</h4>
@@ -139,7 +160,7 @@ export default {
data() {
return {
form: {
inputContent: "示例 https://u.jd.com/YDy2OHn"
inputContent: ""
},
loading: false,
result: "",
@@ -214,6 +235,28 @@ export default {
};
},
mounted() {},
computed: {
// 提取通用文案:优先取第一个商品中类型包含“通用”的文案;否则取第一个文案
generalCopy() {
const data = this.parsedResult;
try {
if (Array.isArray(data) && data.length) {
const productIndex = typeof this.activeProductTab === 'number' ? this.activeProductTab : 0;
const product = data[productIndex] || data[0];
const wenanList = Array.isArray(product && product.wenan) ? product.wenan : [];
if (wenanList.length) {
const found = wenanList.find(w => (w && (w.type || '').includes('通用')));
const chosen = found || wenanList[0];
return (chosen && chosen.content) ? chosen.content : '';
}
}
if (data && data.generalCopy) {
return String(data.generalCopy || '');
}
} catch (e) { /* 忽略提取异常 */ }
return '';
}
},
watch: {
'publishDialog.form.itemBizType'(val) {
// 冗余联动,防止@change未触发的情况