Commit 1ce55c68 authored by 刘小敏's avatar 刘小敏

管理后台3D试戴优化

parent dc00f927
...@@ -112,8 +112,18 @@ class AiTryon extends Common ...@@ -112,8 +112,18 @@ class AiTryon extends Common
// 查询商品信息,获取 image 字段 // 查询商品信息,获取 image 字段
$goods = Goods::where('id', $params['goods_id'])->find(); $goods = Goods::where('id', $params['goods_id'])->find();
if (!$goods) {
$this->error('商品不存在');
}
// 校验 image_3d 字段值
if (empty($goods['image_3d'])) {
custom_log('[AI生成图片接口] 商品缺少3D图 user_id:'.$user->id.' goods_id:'.$params['goods_id'],$user->id, 'gen_ai');
$this->error('商品缺少3D图,无法试戴');
}
$config = get_addon_config('hwobs'); $config = get_addon_config('hwobs');
$goodsImage = $goods ? $config['cdnurl'].$goods->image : ''; $goodsImage = $config['cdnurl'].$goods->image;
// 我的试戴 // 我的试戴
$tryonModel = new AiTryOnModel(); $tryonModel = new AiTryOnModel();
...@@ -210,8 +220,18 @@ class AiTryon extends Common ...@@ -210,8 +220,18 @@ class AiTryon extends Common
// 查询商品信息,获取 image 字段 // 查询商品信息,获取 image 字段
$goods = Goods::where('id', $params['goods_id'])->find(); $goods = Goods::where('id', $params['goods_id'])->find();
if (!$goods) {
$this->error('商品不存在');
}
// 校验 image_3d 字段值
if (empty($goods['image_3d'])) {
custom_log('[AI生成视频接口] 商品缺少3D图 user_id:'.$user->id.' goods_id:'.$params['goods_id'],$user->id, 'gen_ai');
$this->error('商品缺少3D图,无法试戴');
}
$config = get_addon_config('hwobs'); $config = get_addon_config('hwobs');
$goodsImage = $goods ? $config['cdnurl'].$goods->image : ''; $goodsImage = $config['cdnurl'].$goods->image;
// 保存一条 我的试戴 // 保存一条 我的试戴
$tryonModel = new AiTryOnModel(); $tryonModel = new AiTryOnModel();
......
...@@ -21,9 +21,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'bootstrap-daterangep ...@@ -21,9 +21,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'bootstrap-daterangep
return '<span class="text-muted">-</span>'; return '<span class="text-muted">-</span>';
} }
return '<a href="' + value + '" target="_blank">' + return '<img src="' + value + '" data-url="' + value + '" class="img-preview" style="width:48px;height:48px;object-fit:cover;border-radius:6px;border:1px solid #eee;cursor:pointer;" title="点击查看原图">';
'<img src="' + value + '" style="width:48px;height:48px;object-fit:cover;border-radius:6px;border:1px solid #eee;">' +
'</a>';
} }
function renderResultMedia(value, row) { function renderResultMedia(value, row) {
...@@ -42,7 +40,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'bootstrap-daterangep ...@@ -42,7 +40,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'bootstrap-daterangep
'</div>'; '</div>';
} }
return renderImage(value); // AI结果图片:点击弹窗显示原图
return '<img src="' + value + '" data-url="' + value + '" class="img-preview" style="width:48px;height:48px;object-fit:cover;border-radius:6px;border:1px solid #eee;cursor:pointer;" title="点击查看原图">';
} }
function renderStatus(value, row) { function renderStatus(value, row) {
...@@ -117,7 +116,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'bootstrap-daterangep ...@@ -117,7 +116,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'bootstrap-daterangep
formatter: function (value) { formatter: function (value) {
if (value && value.nickname) { if (value && value.nickname) {
return '<div class="text-left">' + return '<div class="text-left">' +
(value.avatar ? '<img src="' + value.avatar + '" style="width:30px;height:30px;border-radius:50%;vertical-align:middle;margin-right:5px;">' : '') + (value.avatar ? '<img src="' + Fast.api.cdnurl(value.avatar) + '" style="width:30px;height:30px;border-radius:50%;vertical-align:middle;margin-right:5px;">' : '') +
'<span style="vertical-align:middle;">' + value.nickname + (value.mobile ? ' (' + value.mobile + ')' : '') + '</span>' + '<span style="vertical-align:middle;">' + value.nickname + (value.mobile ? ' (' + value.mobile + ')' : '') + '</span>' +
'</div>'; '</div>';
} }
...@@ -229,6 +228,21 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'bootstrap-daterangep ...@@ -229,6 +228,21 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'bootstrap-daterangep
table.bootstrapTable(tableOptions); table.bootstrapTable(tableOptions);
Table.api.bindevent(table); Table.api.bindevent(table);
// 点击图片弹窗显示大图
$(document).on('click', '.img-preview', function () {
var url = $(this).data('url');
if (url) {
Layer.open({
type: 1,
title: false,
closeBtn: 1,
shadeClose: true,
area: ['auto', 'auto'],
content: '<img src="' + url + '" style="max-width:90vw;max-height:90vh;display:block;" />'
});
}
});
// 时间范围选择器 // 时间范围选择器
if ($.fn.daterangepicker) { if ($.fn.daterangepicker) {
$('#createtime_range').daterangepicker({ $('#createtime_range').daterangepicker({
...@@ -324,7 +338,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'bootstrap-daterangep ...@@ -324,7 +338,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'bootstrap-daterangep
if (data.user_info) { if (data.user_info) {
html += '<tr><th>用户</th><td>'; html += '<tr><th>用户</th><td>';
if (data.user_info.avatar) { if (data.user_info.avatar) {
html += '<img src="' + data.user_info.avatar + '" style="width:40px;height:40px;border-radius:50%;vertical-align:middle;margin-right:10px;">'; html += '<img src="' + Fast.api.cdnurl(data.user_info.avatar) + '" style="width:40px;height:40px;border-radius:50%;vertical-align:middle;margin-right:10px;">';
} }
html += '<span style="vertical-align:middle;">' + (data.user_info.nickname || '未知') + '</span>'; html += '<span style="vertical-align:middle;">' + (data.user_info.nickname || '未知') + '</span>';
if (data.user_info.mobile) { if (data.user_info.mobile) {
...@@ -339,14 +353,16 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'bootstrap-daterangep ...@@ -339,14 +353,16 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'bootstrap-daterangep
// 图片信息 // 图片信息
if (data.ai_type == 0) { if (data.ai_type == 0) {
html += '<tr><th>人物图片</th><td><a href="' + data.person_image + '" target="_blank"><img src="' + data.person_image + '" style="max-width:300px;max-height:300px;"></a></td></tr>'; html += '<tr><th>人物图片</th><td><img src="' + data.person_image + '" data-url="' + data.person_image + '" class="img-preview" style="max-width:300px;max-height:300px;cursor:pointer;" title="点击查看原图"></td></tr>';
html += '<tr><th>商品图片</th><td><a href="' + data.goods_image + '" target="_blank"><img src="' + data.goods_image + '" style="max-width:300px;max-height:300px;"></a></td></tr>'; html += '<tr><th>商品图片</th><td><img src="' + data.goods_image + '" data-url="' + data.goods_image + '" class="img-preview" style="max-width:300px;max-height:300px;cursor:pointer;" title="点击查看原图"></td></tr>';
html += '<tr><th>3D图片</th><td><img src="' + data.image_3d + '" data-url="' + data.image_3d + '" class="img-preview" style="max-width:300px;max-height:300px;cursor:pointer;" title="点击查看原图"></td></tr>';
if (data.ai_url) { if (data.ai_url) {
html += '<tr><th>AI 生成结果</th><td><a href="' + data.ai_url + '" target="_blank"><img src="' + data.ai_url + '" style="max-width:300px;max-height:300px;"></a></td></tr>'; html += '<tr><th>AI 生成结果</th><td><img src="' + data.ai_url + '" data-url="' + data.ai_url + '" class="img-preview" style="max-width:300px;max-height:300px;cursor:pointer;" title="点击查看原图"></td></tr>';
} }
} else { } else {
html += '<tr><th>人物图片</th><td><a href="' + data.person_image + '" target="_blank"><img src="' + data.person_image + '" style="max-width:300px;max-height:300px;"></a></td></tr>'; html += '<tr><th>人物图片</th><td><img src="' + data.person_image + '" data-url="' + data.person_image + '" class="img-preview" style="max-width:300px;max-height:300px;cursor:pointer;" title="点击查看原图"></td></tr>';
html += '<tr><th>商品图片</th><td><a href="' + data.goods_image + '" target="_blank"><img src="' + data.goods_image + '" style="max-width:300px;max-height:300px;"></a></td></tr>'; html += '<tr><th>商品图片</th><td><img src="' + data.goods_image + '" data-url="' + data.goods_image + '" class="img-preview" style="max-width:300px;max-height:300px;cursor:pointer;" title="点击查看原图"></td></tr>';
html += '<tr><th>3D图片</th><td><img src="' + data.image_3d + '" data-url="' + data.image_3d + '" class="img-preview" style="max-width:300px;max-height:300px;cursor:pointer;" title="点击查看原图"></td></tr>';
if (data.ai_url) { if (data.ai_url) {
html += '<tr><th>AI 生成视频</th><td><div style="position:relative;max-width:600px;max-height:400px;border-radius:6px;overflow:hidden;background:#000;">' + html += '<tr><th>AI 生成视频</th><td><div style="position:relative;max-width:600px;max-height:400px;border-radius:6px;overflow:hidden;background:#000;">' +
'<video src="' + data.ai_url + '" controls preload="none" style="width:100%;height:100%;" onclick="this.play()">' + '<video src="' + data.ai_url + '" controls preload="none" style="width:100%;height:100%;" onclick="this.play()">' +
...@@ -379,6 +395,21 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'bootstrap-daterangep ...@@ -379,6 +395,21 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'bootstrap-daterangep
html += '</div>'; html += '</div>';
$('.panel-body').html(html); $('.panel-body').html(html);
// 详情页点击图片弹窗显示大图
$(document).on('click', '.img-preview', function () {
var url = $(this).data('url');
if (url) {
Layer.open({
type: 1,
title: false,
closeBtn: 1,
shadeClose: true,
area: ['auto', 'auto'],
content: '<img src="' + url + '" style="max-width:90vw;max-height:90vh;display:block;" />'
});
}
});
} }
return false; return false;
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment