1
This commit is contained in:
@@ -493,14 +493,61 @@ export default {
|
|||||||
const images = (parsedQuery && parsedQuery.images && Array.isArray(parsedQuery.images)) ? parsedQuery.images : [];
|
const images = (parsedQuery && parsedQuery.images && Array.isArray(parsedQuery.images)) ? parsedQuery.images : [];
|
||||||
// 记录当前线报项,便于发品成功后加入常用
|
// 记录当前线报项,便于发品成功后加入常用
|
||||||
this.currentXbMessageItem = child;
|
this.currentXbMessageItem = child;
|
||||||
this.publishInitialData = {
|
|
||||||
|
// 先尝试生成转链文案,成功后带文案打开发品弹窗
|
||||||
|
const materialUrl = this.getJsonValue(child.jsonQueryResult, 'materialUrl');
|
||||||
|
const skuName = child.skuName;
|
||||||
|
const inputContent = materialUrl || skuName || '';
|
||||||
|
|
||||||
|
// 预先设置基本信息,等待文案生成后补充
|
||||||
|
const baseInitialData = {
|
||||||
title: this.decodeUnicode(child.skuName) || '',
|
title: this.decodeUnicode(child.skuName) || '',
|
||||||
content: '',
|
content: '',
|
||||||
images: images,
|
images: images,
|
||||||
originalPrice: parsedQuery && parsedQuery.priceInfo ? Number(parsedQuery.priceInfo.price || parsedQuery.priceInfo.lowestCouponPrice || 0) : null,
|
originalPrice: parsedQuery && parsedQuery.priceInfo ? Number(parsedQuery.priceInfo.price || parsedQuery.priceInfo.lowestCouponPrice || 0) : null,
|
||||||
wenanOptions: []
|
wenanOptions: []
|
||||||
};
|
};
|
||||||
this.publishDialogVisible = true;
|
|
||||||
|
if (!inputContent) {
|
||||||
|
// 无法生成转链输入,直接打开(无文案)
|
||||||
|
this.publishInitialData = baseInitialData;
|
||||||
|
this.publishDialogVisible = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
this.$modal && this.$modal.loading('正在生成转链文案,请稍候…');
|
||||||
|
} catch(e) { /* 忽略 */ }
|
||||||
|
|
||||||
|
generatePromotionContent({ promotionContent: inputContent }).then(res => {
|
||||||
|
let result = res && (res.msg || res.data);
|
||||||
|
let arr = [];
|
||||||
|
try {
|
||||||
|
if (typeof result === 'string') {
|
||||||
|
arr = JSON.parse(result);
|
||||||
|
} else if (Array.isArray(result)) {
|
||||||
|
arr = result;
|
||||||
|
}
|
||||||
|
} catch (e) { arr = []; }
|
||||||
|
|
||||||
|
let wenanOptions = [];
|
||||||
|
if (Array.isArray(arr) && arr.length > 0) {
|
||||||
|
const first = arr[0] || {};
|
||||||
|
const wenanArr = Array.isArray(first.wenan) ? first.wenan : [];
|
||||||
|
wenanOptions = wenanArr.map((w, i) => ({ label: w.type || `版本${i+1}`, content: w.content || '' }));
|
||||||
|
}
|
||||||
|
|
||||||
|
this.publishInitialData = Object.assign({}, baseInitialData, {
|
||||||
|
content: (wenanOptions[0] && wenanOptions[0].content) || '',
|
||||||
|
wenanOptions
|
||||||
|
});
|
||||||
|
}).catch(() => {
|
||||||
|
// 忽略错误,仍然打开弹窗(无文案)
|
||||||
|
this.publishInitialData = baseInitialData;
|
||||||
|
}).finally(() => {
|
||||||
|
try { this.$modal && this.$modal.closeLoading(); } catch(e) { /* 忽略 */ }
|
||||||
|
this.publishDialogVisible = true;
|
||||||
|
});
|
||||||
},
|
},
|
||||||
/** 查询消息列表 */
|
/** 查询消息列表 */
|
||||||
getList() {
|
getList() {
|
||||||
|
|||||||
Reference in New Issue
Block a user