diff --git a/src/api/system/jdorder.js b/src/api/system/jdorder.js
index 4cbd1b9..af42288 100644
--- a/src/api/system/jdorder.js
+++ b/src/api/system/jdorder.js
@@ -84,4 +84,22 @@ export function getProperties(params) {
method: 'get',
params
})
+}
+
+// 开礼金
+export function createGiftCoupon(data) {
+ return request({
+ url: '/jarvis/jdorder/createGiftCoupon',
+ method: 'post',
+ data
+ })
+}
+
+// 转链(支持礼金)
+export function transferWithGift(data) {
+ return request({
+ url: '/jarvis/jdorder/transfer',
+ method: 'post',
+ data
+ })
}
\ No newline at end of file
diff --git a/src/views/system/xbmessage/index.vue b/src/views/system/xbmessage/index.vue
index a13b06e..6171d29 100644
--- a/src/views/system/xbmessage/index.vue
+++ b/src/views/system/xbmessage/index.vue
@@ -198,6 +198,7 @@
@@ -317,6 +318,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
@@ -324,7 +340,7 @@
import { listXbmessage, delXbmessage, getGroupNameOptions } from "@/api/system/xbmessage";
import { parseTime } from "@/utils/ruoyi";
import PublishDialog from '@/components/PublishDialog.vue'
-import { generatePromotionContent, createProductByPromotion, getProvinces, getCities, getAreas, getCategories, getUsernames, getERPAccounts, getProperties } from "@/api/system/jdorder";
+import { generatePromotionContent, createProductByPromotion, getProvinces, getCities, getAreas, getCategories, getUsernames, getERPAccounts, getProperties, createGiftCoupon, transferWithGift } from "@/api/system/jdorder";
import { addToFavorites, getBySkuid } from "@/api/system/favoriteProduct";
export default {
@@ -372,6 +388,10 @@ export default {
activeQuickLinkTab: 0,
activeQuickLinkWenanTab: {},
quickLinkLoading: false,
+ giftDialogVisible: false,
+ giftForm: { amount: null, quantity: 10 },
+ giftLoading: false,
+ giftContext: { materialUrl: '', owner: 'g', skuName: '' },
// 发品相关
quickLinkPublishDialog: {
visible: false,
@@ -490,7 +510,7 @@ export default {
methods: {
openPublishFromXb(child) {
const parsedQuery = this.safeJsonParse(child.jsonQueryResult);
- const images = (parsedQuery && parsedQuery.images && Array.isArray(parsedQuery.images)) ? parsedQuery.images : [];
+ const images = this.extractImageUrlsFromQuery(parsedQuery, child);
// 记录当前线报项,便于发品成功后加入常用
this.currentXbMessageItem = child;
@@ -531,15 +551,18 @@ export default {
} catch (e) { arr = []; }
let wenanOptions = [];
+ let detailImages = [];
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 || '' }));
+ detailImages = this.extractImageUrlsFromGenerateResult(first);
}
this.publishInitialData = Object.assign({}, baseInitialData, {
content: (wenanOptions[0] && wenanOptions[0].content) || '',
- wenanOptions
+ wenanOptions,
+ images: (detailImages && detailImages.length) ? detailImages : baseInitialData.images
});
}).catch(() => {
// 忽略错误,仍然打开弹窗(无文案)
@@ -549,6 +572,68 @@ export default {
this.publishDialogVisible = true;
});
},
+ // 兼容多种结构提取图片URL(线报查询结果/行数据)
+ extractImageUrlsFromQuery(queryObj, rowFallback) {
+ try {
+ const urls = [];
+ const pushIfUrl = (v) => {
+ if (!v) return;
+ const s = String(v).trim();
+ if (/^https?:\/\//.test(s)) urls.push(s);
+ };
+
+ if (queryObj && Array.isArray(queryObj.images)) {
+ queryObj.images.forEach(it => {
+ if (typeof it === 'string') pushIfUrl(it);
+ else if (it && (it.url || it.imageUrl || it.imgUrl)) pushIfUrl(it.url || it.imageUrl || it.imgUrl);
+ });
+ }
+ if (queryObj && queryObj.imageInfo) {
+ const ii = queryObj.imageInfo;
+ pushIfUrl(ii.mainImage);
+ if (Array.isArray(ii.imageList)) {
+ ii.imageList.forEach(it => {
+ if (typeof it === 'string') pushIfUrl(it);
+ else if (it && (it.url || it.imageUrl || it.imgUrl)) pushIfUrl(it.url || it.imageUrl || it.imgUrl);
+ });
+ } else if (typeof ii.imageList === 'string') {
+ ii.imageList.split(/[\s,]+/).forEach(pushIfUrl);
+ }
+ }
+ // 兜底:从行数据尝试
+ if (urls.length === 0 && rowFallback) {
+ if (Array.isArray(rowFallback.images)) {
+ rowFallback.images.forEach(it => { if (typeof it === 'string') pushIfUrl(it); else if (it && it.url) pushIfUrl(it.url); });
+ }
+ pushIfUrl(rowFallback.productImage);
+ pushIfUrl(rowFallback.imageUrl);
+ pushIfUrl(rowFallback.image);
+ }
+ return Array.from(new Set(urls));
+ } catch (e) { return []; }
+ },
+ // 兼容 generatePromotionContent 返回结构提取图片
+ extractImageUrlsFromGenerateResult(obj) {
+ try {
+ const urls = [];
+ const pushIfUrl = (v) => {
+ if (!v) return;
+ const s = String(v).trim();
+ if (/^https?:\/\//.test(s)) urls.push(s);
+ };
+ if (Array.isArray(obj.images)) {
+ obj.images.forEach(it => {
+ if (typeof it === 'string') pushIfUrl(it);
+ else if (it && (it.url || it.imageUrl || it.imgUrl)) pushIfUrl(it.url || it.imageUrl || it.imgUrl);
+ });
+ }
+ if (obj.mainImage) pushIfUrl(obj.mainImage);
+ if (Array.isArray(obj.imageList)) obj.imageList.forEach(pushIfUrl);
+ if (Array.isArray(obj.pics)) obj.pics.forEach(pushIfUrl);
+ if (Array.isArray(obj.imgUrls)) obj.imgUrls.forEach(pushIfUrl);
+ return Array.from(new Set(urls));
+ } catch (e) { return []; }
+ },
/** 查询消息列表 */
getList() {
this.loading = true;
@@ -1218,6 +1303,43 @@ export default {
this.activeQuickLinkWenanTab = {};
this.quickLinkVisible = true;
},
+ openGiftDialog(child) {
+ const materialUrl = this.getJsonValue(child.jsonQueryResult, 'materialUrl') || this.getJsonValue(child.jsonQueryResult, 'url');
+ const owner = this.getJsonValue(child.jsonQueryResult, 'owner') || 'g';
+ const skuName = child.skuName || '';
+ if (!materialUrl) { this.$modal.msgError('无法获取商品链接'); return; }
+ this.giftContext = { materialUrl, owner, skuName };
+ this.giftForm = { amount: null, quantity: 10 };
+ this.giftDialogVisible = true;
+ },
+ async submitGift() {
+ if (!this.giftContext.materialUrl || !this.giftForm.amount || !this.giftForm.quantity) {
+ this.$modal.msgError('请完善礼金金额与数量'); return;
+ }
+ this.giftLoading = true;
+ try {
+ const cg = await createGiftCoupon({ materialUrl: this.giftContext.materialUrl, amount: this.giftForm.amount, quantity: this.giftForm.quantity, owner: this.giftContext.owner, skuName: this.giftContext.skuName });
+ if (!cg || cg.code !== 200) { this.$modal.msgError((cg && cg.msg) || '开礼金失败'); this.giftLoading = false; return; }
+ const giftKey = (cg.data && (cg.data.giftCouponKey || cg.data.giftKey)) || (typeof cg.data === 'string' ? cg.data : null);
+ const tf = await transferWithGift({ materialUrl: this.giftContext.materialUrl, giftCouponKey: giftKey });
+ let shortUrl = '';
+ if (tf && tf.code === 200) {
+ const d = tf.data; if (typeof d === 'string') shortUrl = d; else if (d && d.shortURL) shortUrl = d.shortURL;
+ }
+ if (shortUrl) {
+ if (this.publishInitialData && this.publishDialogVisible) {
+ this.publishInitialData = Object.assign({}, this.publishInitialData, { content: (this.publishInitialData.content ? (this.publishInitialData.content + '\n' + shortUrl) : shortUrl) });
+ }
+ this.$modal.msgSuccess('礼金短链已生成');
+ } else {
+ this.$modal.msgSuccess('礼金创建成功');
+ }
+ this.giftDialogVisible = false;
+ } catch (e) {
+ this.$modal.msgError('礼金处理失败');
+ }
+ this.giftLoading = false;
+ },
/** 生成转链内容 */
generateQuickLink() {