附件远程地址被替换修复,附件地址统一处理

This commit is contained in:
gongfuxiang 2019-01-14 00:03:29 +08:00
parent cc854c0681
commit 495e3920a0
32 changed files with 89 additions and 99 deletions

View File

@ -137,7 +137,7 @@ class Common extends Controller
$this->assign('admin', $this->admin);
// 图片host地址
$this->assign('images_host', config('shopxo.images_host'));
$this->assign('attachment_host', config('shopxo.attachment_host'));
}
/**

View File

@ -58,7 +58,7 @@
<ul class="plug-file-upload-view slide-images_url-images-view" data-form-name="images_url" data-max-number="1" data-delete="0" data-dialog-type="images">
<li>
<input type="text" name="images_url" value="{{if !empty($data['images_url'])}}{{$data.images_url}}{{/if}}" data-validation-message="请上传图片" required />
<img src="{{if !empty($data['images_url'])}}{{$data.images_url}}{{else /}}{{$images_host}}/static/admin/default/images/default-images.png{{/if}}" />
<img src="{{if !empty($data['images_url'])}}{{$data.images_url}}{{else /}}{{$attachment_host}}/static/admin/default/images/default-images.png{{/if}}" />
</li>
</ul>
<div class="plug-file-upload-submit" data-view-tag="ul.slide-images_url-images-view">+上传图片</div>
@ -67,7 +67,7 @@
<label>背景色</label>
<input type="hidden" name="bg_color" value="{{if !empty($data)}}{{$data.bg_color}}{{/if}}" />
<button class="am-btn am-btn-default colorpicker-submit bg-color-tag am-btn-block bk-cr-white t-r" type="button" data-input-tag="button.bg-color-tag" data-color-tag="input[name='bg_color']" data-color-style="background-color" {{if !empty($data)}} style="background-color:{{$data.bg_color}};"{{/if}}>
<img src="{{$images_host}}/static/common/images/colorpicker.png" />
<img src="{{$attachment_host}}/static/common/images/colorpicker.png" />
</button>
</div>
<div class="am-form-group">

View File

@ -22,7 +22,7 @@
<input type="text" name="title" placeholder="标题" minlength="2" maxlength="60" data-validation-message="标题长度 2~60 个字符" class="am-form-field am-radius" {{if !empty($data)}} value="{{$data.title}}" {{/if}} {{if !empty($data['title_color'])}} style="color:{{$data.title_color}};" {{/if}} required />
<span class="am-input-group-btn">
<button class="am-btn am-btn-default colorpicker-submit" type="button" data-input-tag="input[name='title']" data-color-tag="input[name='title_color']">
<img src="{{$images_host}}/static/common/images/colorpicker.png" />
<img src="{{$attachment_host}}/static/common/images/colorpicker.png" />
</button>
</span>
</div>

View File

@ -42,7 +42,7 @@
<!-- list start -->
<div id="tree" class="m-t-15">
<div class="m-t-30 t-c">
<img src="{{$images_host}}/static/common/images/loading.gif" />
<img src="{{$attachment_host}}/static/common/images/loading.gif" />
<p>处理中...</p>
</div>
</div>

View File

@ -42,7 +42,7 @@
<!-- list start -->
<div id="tree" class="m-t-15">
<div class="m-t-30 t-c">
<img src="{{$images_host}}/static/common/images/loading.gif" />
<img src="{{$attachment_host}}/static/common/images/loading.gif" />
<p>处理中...</p>
</div>
</div>

View File

@ -24,7 +24,7 @@
<ul class="plug-file-upload-view express-icon-images-view" data-form-name="icon" data-max-number="1" data-dialog-type="images">
<li>
<input type="hidden" name="icon" value="" />
<img src="{{$images_host}}/static/admin/default/images/default-images.png" />
<img src="{{$attachment_host}}/static/admin/default/images/default-images.png" />
<i>×</i>
</li>
</ul>
@ -51,9 +51,9 @@
<!-- save win end -->
<!-- list start -->
<div id="tree" class="m-t-15" data-additional='[{"field":"icon", "value":"", "type":"input"}, {"field":"icon_url", "value":"{{$images_host}}/static/admin/default/images/default-images.png", "type":"attr", "tag":"ul.express-icon-images-view li img", "style":"src"}]'>
<div id="tree" class="m-t-15" data-additional='[{"field":"icon", "value":"", "type":"input"}, {"field":"icon_url", "value":"{{$attachment_host}}/static/admin/default/images/default-images.png", "type":"attr", "tag":"ul.express-icon-images-view li img", "style":"src"}]'>
<div class="m-t-30 t-c">
<img src="{{$images_host}}/static/common/images/loading.gif" />
<img src="{{$attachment_host}}/static/common/images/loading.gif" />
<p>处理中...</p>
</div>
</div>

View File

@ -50,7 +50,7 @@
<input type="text" name="title" placeholder="标题名称" minlength="2" maxlength="60" data-validation-message="标题名称格式 2~60 个字符" class="am-form-field am-radius" {{if !empty($data)}} value="{{$data.title}}" {{/if}} {{if !empty($data['title_color'])}} style="color:{{$data.title_color}};" {{/if}} required />
<span class="am-input-group-btn">
<button class="am-btn am-btn-default colorpicker-submit" type="button" data-input-tag="input[name='title']" data-color-tag="input[name='title_color']">
<img src="{{$images_host}}/static/common/images/colorpicker.png" />
<img src="{{$attachment_host}}/static/common/images/colorpicker.png" />
</button>
</span>
</div>

View File

@ -24,7 +24,7 @@
<ul class="plug-file-upload-view goods-category-icon-images-view" data-form-name="icon" data-max-number="1" data-dialog-type="images">
<li>
<input type="hidden" name="icon" value="" />
<img src="{{$images_host}}/static/admin/default/images/default-images.png" />
<img src="{{$attachment_host}}/static/admin/default/images/default-images.png" />
<i>×</i>
</li>
</ul>
@ -35,7 +35,7 @@
<ul class="plug-file-upload-view goods-category-big_images-images-view" data-form-name="big_images" data-max-number="1" data-dialog-type="images">
<li>
<input type="hidden" name="big_images" value="" />
<img src="{{$images_host}}/static/admin/default/images/default-images.png" />
<img src="{{$attachment_host}}/static/admin/default/images/default-images.png" />
<i>×</i>
</li>
</ul>
@ -45,7 +45,7 @@
<label>背景色</label>
<input type="hidden" name="bg_color" value="" />
<button class="am-btn am-btn-default colorpicker-submit bg-color-tag am-btn-block bk-cr-white t-r" type="button" data-input-tag="button.bg-color-tag" data-color-tag="input[name='bg_color']" data-color-style="background-color">
<img src="{{$images_host}}/static/common/images/colorpicker.png" />
<img src="{{$attachment_host}}/static/common/images/colorpicker.png" />
</button>
</div>
<div class="am-form-group">
@ -88,9 +88,9 @@
<!-- save win end -->
<!-- list start -->
<div id="tree" class="m-t-15" data-rank="3" data-additional='[{"field":"bg_color", "value":"", "type":"input"}, {"field":"bg_color", "value":"", "type":"css", "tag":"button.colorpicker-submit", "style":"background-color"}, {"field":"icon", "value":"", "type":"input"}, {"field":"icon_url", "value":"{{$images_host}}/static/admin/default/images/default-images.png", "type":"attr", "tag":"ul.goods-category-icon-images-view li img", "style":"src"}, {"field":"big_images", "value":"", "type":"input"}, {"field":"big_images_url", "value":"{{$images_host}}/static/admin/default/images/default-images.png", "type":"attr", "tag":"ul.goods-category-big_images-images-view li img", "style":"src"}, {"field":"vice_name", "value":"", "type":"input"}, {"field":"describe", "value":"", "type":"textarea"}, {"field":"is_home_recommended", "value":"0", "type":"input"}]'>
<div id="tree" class="m-t-15" data-rank="3" data-additional='[{"field":"bg_color", "value":"", "type":"input"}, {"field":"bg_color", "value":"", "type":"css", "tag":"button.colorpicker-submit", "style":"background-color"}, {"field":"icon", "value":"", "type":"input"}, {"field":"icon_url", "value":"{{$attachment_host}}/static/admin/default/images/default-images.png", "type":"attr", "tag":"ul.goods-category-icon-images-view li img", "style":"src"}, {"field":"big_images", "value":"", "type":"input"}, {"field":"big_images_url", "value":"{{$attachment_host}}/static/admin/default/images/default-images.png", "type":"attr", "tag":"ul.goods-category-big_images-images-view li img", "style":"src"}, {"field":"vice_name", "value":"", "type":"input"}, {"field":"describe", "value":"", "type":"textarea"}, {"field":"is_home_recommended", "value":"0", "type":"input"}]'>
<div class="m-t-30 t-c">
<img src="{{$images_host}}/static/common/images/loading.gif" />
<img src="{{$attachment_host}}/static/common/images/loading.gif" />
<p>处理中...</p>
</div>
</div>

View File

@ -17,6 +17,6 @@
{{/if}}
</head>
<script type="text/javascript">
var __images_host__ = '{{$images_host}}';
var __attachment_host__ = '{{$attachment_host}}';
</script>
<body>

View File

@ -43,7 +43,7 @@
<!-- list start -->
<div id="tree" class="m-t-15">
<div class="m-t-30 t-c">
<img src="{{$images_host}}/static/common/images/loading.gif" />
<img src="{{$attachment_host}}/static/common/images/loading.gif" />
<p>处理中...</p>
</div>
</div>

View File

@ -51,7 +51,7 @@
<!-- list start -->
<div id="tree" class="m-t-15" data-additional='[{"field":"min_price", "value":"0", "type":"input"}, {"field":"max_price", "value":"0", "type":"input"}]'>
<div class="m-t-30 t-c">
<img src="{{$images_host}}/static/common/images/loading.gif" />
<img src="{{$attachment_host}}/static/common/images/loading.gif" />
<p>处理中...</p>
</div>
</div>

View File

@ -54,7 +54,7 @@
<ul class="plug-file-upload-view slide-images_url-images-view" data-form-name="images_url" data-max-number="1" data-delete="0" data-dialog-type="images">
<li>
<input type="text" name="images_url" value="{{if !empty($data['images_url'])}}{{$data.images_url}}{{/if}}" data-validation-message="请上传图片" required />
<img src="{{if !empty($data['images_url'])}}{{$data.images_url}}{{else /}}{{$images_host}}/static/admin/default/images/default-images.png{{/if}}" />
<img src="{{if !empty($data['images_url'])}}{{$data.images_url}}{{else /}}{{$attachment_host}}/static/admin/default/images/default-images.png{{/if}}" />
</li>
</ul>
<div class="plug-file-upload-submit" data-view-tag="ul.slide-images_url-images-view">+上传图片</div>
@ -63,7 +63,7 @@
<label>背景色</label>
<input type="hidden" name="bg_color" value="{{if !empty($data)}}{{$data.bg_color}}{{/if}}" />
<button class="am-btn am-btn-default colorpicker-submit bg-color-tag am-btn-block bk-cr-white t-r" type="button" data-input-tag="button.bg-color-tag" data-color-tag="input[name='bg_color']" data-color-style="background-color" {{if !empty($data)}} style="background-color:{{$data.bg_color}};"{{/if}}>
<img src="{{$images_host}}/static/common/images/colorpicker.png" />
<img src="{{$attachment_host}}/static/common/images/colorpicker.png" />
</button>
</div>

View File

@ -163,7 +163,7 @@ class Common extends Controller
$this->assign('is_footer', 1);
// 图片host地址
$this->assign('images_host', config('shopxo.images_host'));
$this->assign('attachment_host', config('shopxo.attachment_host'));
// 标题
$this->assign('home_seo_site_title', MyC('home_seo_site_title'));

View File

@ -26,7 +26,7 @@
<div class="am-u-sm-3">
<a href="{{:MyUrl('index/category/index')}}">
<div class="nav-icon mini-nav-goods-category">
<img src="{{$images_host}}/static/{{$module_name}}/{{$default_theme}}/images/home-mini-nav-category-icon.png" />
<img src="{{$attachment_host}}/static/{{$module_name}}/{{$default_theme}}/images/home-mini-nav-category-icon.png" />
</div>
<div class="mini-nav-title">分类</div>
</a>
@ -34,7 +34,7 @@
<div class="am-u-sm-3">
<a {{if empty($user)}}href="javascript:;" class="login-event"{{else /}} href="{{:MyUrl('index/Cart/index')}}"{{/if}}>
<div class="nav-icon mini-nav-cart">
<img src="{{$images_host}}/static/{{$module_name}}/{{$default_theme}}/images/home-mini-nav-cart-icon.png" />
<img src="{{$attachment_host}}/static/{{$module_name}}/{{$default_theme}}/images/home-mini-nav-cart-icon.png" />
</div>
<div class="mini-nav-title">购物车</div>
</a>
@ -42,7 +42,7 @@
<div class="am-u-sm-3">
<a {{if empty($user)}}href="javascript:;" class="login-event"{{else /}} href="{{:MyUrl('index/order/index')}}"{{/if}}>
<div class="nav-icon mini-nav-order">
<img src="{{$images_host}}/static/{{$module_name}}/{{$default_theme}}/images/home-mini-nav-order-icon.png" />
<img src="{{$attachment_host}}/static/{{$module_name}}/{{$default_theme}}/images/home-mini-nav-order-icon.png" />
</div>
<div class="mini-nav-title">订单</div>
</a>
@ -50,7 +50,7 @@
<div class="am-u-sm-3">
<a {{if empty($user)}}href="javascript:;" class="login-event"{{else /}} href="{{:MyUrl('index/user/index')}}"{{/if}}>
<div class="nav-icon mini-nav-user">
<img src="{{$images_host}}/static/{{$module_name}}/{{$default_theme}}/images/home-mini-nav-user-icon.png" />
<img src="{{$attachment_host}}/static/{{$module_name}}/{{$default_theme}}/images/home-mini-nav-user-icon.png" />
</div>
<div class="mini-nav-title">我的</div>
</a>
@ -62,7 +62,7 @@
<div class="mod-vip">
<div class="m-baseinfo">
<a href="{{if !empty($user)}}{{:MyUrl('index/user/index')}}{{else /}}javascript:;{{/if}}" target="_blank">
<img src="{{if !empty($user['avatar'])}}{{$user.avatar}}{{else /}}{{$images_host}}/static/{{$module_name}}/{{$default_theme}}/images/default-user-avatar.jpg{{/if}}" class="user-avatar" />
<img src="{{if !empty($user['avatar'])}}{{$user.avatar}}{{else /}}{{$attachment_host}}/static/{{$module_name}}/{{$default_theme}}/images/default-user-avatar.jpg{{/if}}" class="user-avatar" />
</a>
<em>
<span class="s-name">

View File

@ -14,8 +14,8 @@
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-title" content="{{:MyC('home_site_name')}}">
<link rel="apple-touch-icon" href="{{$images_host}}{{:MyC('home_site_desktop_icon')}}">
<link rel="apple-touch-icon-precomposed" href="{{$images_host}}{{:MyC('home_site_desktop_icon')}}">
<link rel="apple-touch-icon" href="{{$attachment_host}}{{:MyC('home_site_desktop_icon')}}">
<link rel="apple-touch-icon-precomposed" href="{{$attachment_host}}{{:MyC('home_site_desktop_icon')}}">
<link rel="stylesheet" type="text/css" href="{{$Think.__MY_ROOT_PUBLIC__}}static/common/lib/assets/css/amazeui.css?v={{:MyC('home_static_cache_version')}}" />
<link rel="stylesheet" type="text/css" href="{{$Think.__MY_ROOT_PUBLIC__}}static/common/lib/amazeui-switch/amazeui.switch.css?v={{:MyC('home_static_cache_version')}}" />
@ -33,7 +33,7 @@
var __public__ = '{{$Think.__MY_ROOT_PUBLIC__}}';
var __default_theme__ = '{{$default_theme}}';
var __modal_login_url__ = '{{:Url("index/user/modallogininfo")}}';
var __images_host__ = '{{$images_host}}';
var __attachment_host__ = '{{$attachment_host}}';
var __user_id__ = {{if empty($user['id'])}}0{{else /}}{{$user.id}}{{/if}};
</script>
</head>

View File

@ -13,7 +13,7 @@
</ul>
<div class="nav-extra {{if empty($user)}}login-event{{/if}}">
<a href="{{if empty($user)}}javascript:;{{else /}}{{:MyUrl('index/user/index')}}{{/if}}">
<img src="{{if !empty($user['avatar'])}}{{$user.avatar}}{{else /}}{{$images_host}}/static/{{$module_name}}/{{$default_theme}}/images/default-user-avatar.jpg{{/if}}" class="nav-user" />
<img src="{{if !empty($user['avatar'])}}{{$user.avatar}}{{else /}}{{$attachment_host}}/static/{{$module_name}}/{{$default_theme}}/images/default-user-avatar.jpg{{/if}}" class="nav-user" />
<b></b>
<span>我的商城</span>
<i class="am-icon-angle-right"></i>

View File

@ -2,12 +2,12 @@
<div class="nav-search white">
<div class="logo">
<a href="{{$Think.__MY_URL__}}">
<img src="{{$images_host}}{{:MyC('home_site_logo_wap')}}" alt="{{:MyC('home_seo_site_title')}}" />
<img src="{{$attachment_host}}{{:MyC('home_site_logo_wap')}}" alt="{{:MyC('home_seo_site_title')}}" />
</a>
</div>
<div class="logo-big">
<a href="{{$Think.__MY_URL__}}">
<img src="{{$images_host}}{{:MyC('home_site_logo')}}" alt="{{:MyC('home_seo_site_title')}}" />
<img src="{{$attachment_host}}{{:MyC('home_site_logo')}}" alt="{{:MyC('home_seo_site_title')}}" />
</a>
</div>

View File

@ -43,7 +43,7 @@
<input type="hidden" name="max_file_size" value="{{:MyC('home_max_limit_image', 2048000)}}" />
<div class="cropper-images-view">
<div class="img-container am-fl user-avatar-img-container">
<img src="{{$images_host}}/static/{{$module_name}}/{{$default_theme}}/images/default-user-avatar.jpg" alt="Picture" />
<img src="{{$attachment_host}}/static/{{$module_name}}/{{$default_theme}}/images/default-user-avatar.jpg" alt="Picture" />
</div>
<div class="img-preview preview-lg am-fl am-radius user-avatar-img-preview am-hide-sm-only"></div>
<div class="img-preview preview-md am-fl am-radius user-avatar-img-preview "></div>

View File

@ -46,7 +46,6 @@ class AppNavService
$common_platform_type = lang('common_platform_type');
$common_is_enable_tips = lang('common_is_enable_tips');
$common_app_event_type = lang('common_app_event_type');
$images_host = config('shopxo.images_host');
foreach($data as &$v)
{
// 是否启用
@ -71,7 +70,7 @@ class AppNavService
if(isset($v['images_url']))
{
$v['images_url_old'] = $v['images_url'];
$v['images_url'] = empty($v['images_url']) ? '' : $images_host.$v['images_url'];
$v['images_url'] = ResourcesService::AttachmentPathViewHandle($v['images_url']);
}
// 时间
@ -328,11 +327,10 @@ class AppNavService
$data = Db::name('AppHomeNav')->field('id,name,images_url,event_value,event_type,bg_color')->where(['platform'=>APPLICATION_CLIENT_TYPE, 'is_enable'=>1])->order('sort asc')->select();
if(!empty($data))
{
$images_host = config('shopxo.images_host');
foreach($data as &$v)
{
$v['images_url_old'] = $v['images_url'];
$v['images_url'] = $images_host.$v['images_url'];
$v['images_url'] = ResourcesService::AttachmentPathViewHandle($v['images_url']);
$v['event_value'] = empty($v['event_value']) ? null : $v['event_value'];
}
}

View File

@ -11,6 +11,7 @@
namespace app\service;
use think\Db;
use app\service\ResourcesService;
/**
* 轮播服务层
@ -35,11 +36,10 @@ class BannerService
$banner = Db::name('Slide')->field('name,images_url,event_value,event_type,bg_color')->where(['platform'=>APPLICATION_CLIENT_TYPE, 'is_enable'=>1])->order('sort asc')->select();
if(!empty($banner))
{
$images_host = config('shopxo.images_host');
foreach($banner as &$v)
{
$v['images_url_old'] = $v['images_url'];
$v['images_url'] = $images_host.$v['images_url'];
$v['images_url'] = ResourcesService::AttachmentPathViewHandle($v['images_url']);
$v['event_value'] = empty($v['event_value']) ? null : $v['event_value'];
}
}

View File

@ -45,7 +45,6 @@ class BrandService
if(!empty($data))
{
$common_is_enable_tips = lang('common_is_enable_tips');
$images_host = config('shopxo.images_host');
foreach($data as &$v)
{
// 是否启用
@ -64,7 +63,7 @@ class BrandService
if(isset($v['logo']))
{
$v['logo_old'] = $v['logo'];
$v['logo'] = empty($v['logo']) ? '' : $images_host.$v['logo'];
$v['logo'] = ResourcesService::AttachmentPathViewHandle($v['logo']);
}
// 时间
@ -185,11 +184,10 @@ class BrandService
$brand = Db::name('Brand')->where($brand_where)->field('id,name,logo,website_url')->select();
if(!empty($brand))
{
$images_host = config('shopxo.images_host');
foreach($brand as &$v)
{
$v['logo_old'] = $v['logo'];
$v['logo'] = empty($v['logo']) ? null : $images_host.$v['logo'];
$v['logo'] = ResourcesService::AttachmentPathViewHandle($v['logo']);
$v['website_url'] = empty($v['website_url']) ? null : $v['website_url'];
}
}

View File

@ -13,6 +13,7 @@ namespace app\service;
use think\Db;
use app\service\GoodsService;
use app\service\UserService;
use app\service\ResourcesService;
/**
* 购买服务层
@ -173,7 +174,6 @@ class BuyService
// 数据处理
if(!empty($data))
{
$images_host = config('shopxo.images_host');
foreach($data as &$v)
{
// 规格
@ -193,7 +193,7 @@ class BuyService
// 基础信息
$v['goods_url'] = MyUrl('index/goods/index', ['id'=>$v['goods_id']]);
$v['images_old'] = $v['images'];
$v['images'] = empty($v['images']) ? null : $images_host.$v['images'];
$v['images'] = ResourcesService::AttachmentPathViewHandle($v['images']);
$v['total_price'] = $v['stock']*$v['price'];
$v['buy_max_number'] = ($v['buy_max_number'] <= 0) ? $v['inventory']: $v['buy_max_number'];
}

View File

@ -55,11 +55,10 @@ class ExpressService
$data = Db::name('Express')->where($where)->field('id,icon,name,sort,is_enable')->order('sort asc')->select();
if(!empty($data) && is_array($data))
{
$images_host = config('shopxo.images_host');
foreach($data as &$v)
{
$v['icon_old'] = $v['icon'];
$v['icon'] = empty($v['icon']) ? null : $images_host.$v['icon'];
$v['icon'] = ResourcesService::AttachmentPathViewHandle($v['icon']);
}
}
return $data;
@ -83,13 +82,12 @@ class ExpressService
$data = Db::name('Express')->field($field)->where(['pid'=>$id])->order('sort asc')->select();
if(!empty($data))
{
$images_host = config('shopxo.images_host');
foreach($data as &$v)
{
$v['is_son'] = (Db::name('Express')->where(['pid'=>$v['id']])->count() > 0) ? 'ok' : 'no';
$v['ajax_url'] = MyUrl('admin/express/getnodeson', array('id'=>$v['id']));
$v['delete_url'] = MyUrl('admin/express/delete');
$v['icon_url'] = empty($v['icon']) ? '' : $images_host.$v['icon'];
$v['icon_url'] = ResourcesService::AttachmentPathViewHandle($v['icon']);
$v['json'] = json_encode($v);
}
return DataReturn('操作成功', 0, $data);

View File

@ -115,19 +115,18 @@ class GoodsService
{
if(!empty($data) && is_array($data))
{
$images_host = config('shopxo.images_host');
foreach($data as &$v)
{
if(is_array($v))
{
if(isset($v['icon']))
{
$v['icon'] = empty($v['icon']) ? null : $images_host.$v['icon'];
$v['icon'] = ResourcesService::AttachmentPathViewHandle($v['icon']);
}
if(isset($v['big_images']))
{
$v['big_images_old'] = $v['big_images'];
$v['big_images'] = empty($v['big_images']) ? null : $images_host.$v['big_images'];
$v['big_images'] = ResourcesService::AttachmentPathViewHandle($v['big_images']);
}
}
}
@ -245,7 +244,6 @@ class GoodsService
$is_category = (isset($params['is_category']) && $params['is_category'] == true) ? true : false;
// 开始处理数据
$images_host = config('shopxo.images_host');
foreach($data as &$v)
{
// 商品url地址
@ -258,21 +256,21 @@ class GoodsService
if(isset($v['images']))
{
$v['images_old'] = $v['images'];
$v['images'] = empty($v['images']) ? null : $images_host.$v['images'];
$v['images'] = ResourcesService::AttachmentPathViewHandle($v['images']);
}
// 视频
if(isset($v['video']))
{
$v['video_old'] = $v['video'];
$v['video'] = empty($v['video']) ? null : $images_host.$v['video'];
$v['video'] = ResourcesService::AttachmentPathViewHandle($v['video']);
}
// 商品首页推荐图片,不存在则使用商品封面图片
if(isset($v['home_recommended_images']))
{
$v['home_recommended_images_old'] = $v['home_recommended_images'];
$v['home_recommended_images'] = empty($v['home_recommended_images']) ? (empty($v['images']) ? null : $v['images']) : $images_host.$v['home_recommended_images'];
$v['home_recommended_images'] = ResourcesService::AttachmentPathViewHandle($v['home_recommended_images']);
}
// PC内容处理
@ -314,7 +312,7 @@ class GoodsService
foreach($v['photo'] as &$vs)
{
$vs['images_old'] = $vs['images'];
$vs['images'] = $images_host.$vs['images'];
$vs['images'] = ResourcesService::AttachmentPathViewHandle($vs['images']);
}
}
}
@ -350,11 +348,10 @@ class GoodsService
$data = Db::name('GoodsContentApp')->where(['goods_id'=>$params['goods_id']])->field('id,images,content')->order('sort asc')->select();
if(!empty($data))
{
$images_host = config('shopxo.images_host');
foreach($data as &$v)
{
$v['images_old'] = $v['images'];
$v['images'] = empty($v['images']) ? null : $images_host.$v['images'];
$v['images'] = ResourcesService::AttachmentPathViewHandle($v['images']);
$v['content_old'] = $v['content'];
$v['content'] = empty($v['content']) ? null : explode("\n", $v['content']);
}
@ -381,13 +378,12 @@ class GoodsService
if(!empty($choose))
{
// 数据处理
$images_host = config('shopxo.images_host');
foreach($choose as &$temp_type)
{
$temp_type_value = json_decode($temp_type['value'], true);
foreach($temp_type_value as &$vs)
{
$vs['images'] = empty($vs['images']) ? '' : $images_host.$vs['images'];
$vs['images'] = ResourcesService::AttachmentPathViewHandle($vs['images']);
}
$temp_type['value'] = $temp_type_value;
$temp_type['add_time'] = date('Y-m-d H:i:s');
@ -582,12 +578,11 @@ class GoodsService
$data = Db::name('GoodsFavor')->alias('f')->join(['__GOODS__'=>'g'], 'g.id=f.goods_id')->field($field)->where($where)->limit($m, $n)->order($order_by)->select();
if(!empty($data))
{
$images_host = config('shopxo.images_host');
foreach($data as &$v)
{
// 图片
$v['images_old'] = $v['images'];
$v['images'] = empty($v['images']) ? null : $images_host.$v['images'];
$v['images'] = ResourcesService::AttachmentPathViewHandle($v['images']);
$v['goods_url'] = MyUrl('index/goods/index', ['id'=>$v['goods_id']]);
}
@ -729,11 +724,10 @@ class GoodsService
$data = Db::name('GoodsBrowse')->alias('b')->join(['__GOODS__'=>'g'], 'g.id=b.goods_id')->field($field)->where($where)->limit($m, $n)->order($order_by)->select();
if(!empty($data))
{
$images_host = config('shopxo.images_host');
foreach($data as &$v)
{
$v['images_old'] = $v['images'];
$v['images'] = empty($v['images']) ? null : $images_host.$v['images'];
$v['images'] = ResourcesService::AttachmentPathViewHandle($v['images']);
$v['goods_url'] = MyUrl('index/goods/index', ['id'=>$v['goods_id']]);
}
}
@ -1602,14 +1596,13 @@ class GoodsService
if(!empty($type))
{
// 数据处理
$images_host = config('shopxo.images_host');
foreach($type as &$temp_type)
{
$temp_type_value = json_decode($temp_type['value'], true);
foreach($temp_type_value as &$vs)
{
$vs['images_old'] = $vs['images'];
$vs['images'] = empty($vs['images']) ? '' : $images_host.$vs['images'];
$vs['images'] = ResourcesService::AttachmentPathViewHandle($vs['images']);
}
$temp_type['value'] = $temp_type_value;
}
@ -1874,14 +1867,13 @@ class GoodsService
$data = Db::name('GoodsCategory')->field($field)->where(['pid'=>$id])->order('sort asc')->select();
if(!empty($data))
{
$images_host = config('shopxo.images_host');
foreach($data as &$v)
{
$v['is_son'] = (Db::name('GoodsCategory')->where(['pid'=>$v['id']])->count() > 0) ? 'ok' : 'no';
$v['ajax_url'] = MyUrl('admin/goodscategory/getnodeson', array('id'=>$v['id']));
$v['delete_url'] = MyUrl('admin/goodscategory/delete');
$v['icon_url'] = empty($v['icon']) ? '' : $images_host.$v['icon'];
$v['big_images_url'] = empty($v['big_images']) ? '' : $images_host.$v['big_images'];
$v['icon_url'] = ResourcesService::AttachmentPathViewHandle($v['icon']);
$v['big_images_url'] = ResourcesService::AttachmentPathViewHandle($v['big_images']);
$v['json'] = json_encode($v);
}
return DataReturn('操作成功', 0, $data);

View File

@ -17,6 +17,7 @@ use app\service\BuyService;
use app\service\IntegralService;
use app\service\RegionService;
use app\service\ExpressService;
use app\service\ResourcesService;
/**
* 订单服务层
@ -574,7 +575,6 @@ class OrderService
if(!empty($data))
{
$detail_field = 'id,goods_id,title,images,original_price,price,spec,buy_number';
$images_host = config('shopxo.images_host');
$order_status_list = lang('common_order_user_status');
$order_pay_status = lang('common_order_pay_status');
foreach($data as &$v)
@ -643,7 +643,7 @@ class OrderService
{
foreach($items as &$vs)
{
$vs['images'] = empty($vs['images']) ? null : $images_host.$vs['images'];
$vs['images'] = ResourcesService::AttachmentPathViewHandle($vs['images']);
$vs['spec'] = empty($vs['spec']) ? null : json_decode($vs['spec'], true);
$vs['goods_url'] = MyUrl('index/goods/index', ['id'=>$vs['goods_id']]);
$vs['total_price'] = $vs['buy_number']*$vs['price'];

View File

@ -190,11 +190,10 @@ class PaymentService
$data = Db::name('Payment')->where($where)->field('id,logo,name,sort,payment,config,apply_terminal,apply_terminal,element,is_enable,is_open_user')->order('sort asc')->select();
if(!empty($data) && is_array($data))
{
$images_host = config('shopxo.images_host');
foreach($data as &$v)
{
$v['logo_old'] = $v['logo'];
$v['logo'] = empty($v['logo']) ? null : $images_host.$v['logo'];
$v['logo'] = ResourcesService::AttachmentPathViewHandle($v['logo']);
$v['element'] = empty($v['element']) ? '' : json_decode($v['element'], true);
$v['config'] = empty($v['config']) ? '' : json_decode($v['config'], true);
$v['apply_terminal'] = empty($v['apply_terminal']) ? '' : json_decode($v['apply_terminal'], true);

View File

@ -37,12 +37,12 @@ class ResourcesService
{
// 读取内容
case 'get':
return str_replace('/static/', __MY_PUBLIC_URL__.'static/', $content);
return str_replace('src="/static/', 'src="'.__MY_PUBLIC_URL__.'static/', $content);
break;
// 内容写入
case 'add':
return str_replace(array(__MY_PUBLIC_URL__.'static/', __MY_ROOT_PUBLIC__.'static/'), '/static/', $content);
return str_replace(array('src="'.__MY_PUBLIC_URL__.'static/', 'src="'.__MY_ROOT_PUBLIC__.'static/'), 'src="/static/', $content);
}
return $content;
}
@ -84,5 +84,26 @@ class ResourcesService
return DataReturn('success', 0, $result);
}
/**
* 附件展示地址处理
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @datetime 2019-01-13T15:13:30+0800
* @param [type] $value [description]
*/
public static function AttachmentPathViewHandle($value)
{
if(!empty($value))
{
if(substr($value, 0, 4) != 'http')
{
return config('shopxo.attachment_host').$value;
}
return $value;
}
return '';
}
}
?>

View File

@ -40,7 +40,6 @@ class ScreeningPriceService
$data = Db::name('ScreeningPrice')->field($field)->where(['pid'=>$id])->order('sort asc')->select();
if(!empty($data))
{
$images_host = config('shopxo.images_host');
foreach($data as &$v)
{
$v['is_son'] = (Db::name('ScreeningPrice')->where(['pid'=>$v['id']])->count() > 0) ? 'ok' : 'no';
@ -78,14 +77,6 @@ class ScreeningPriceService
return DataReturn($ret, -1);
}
// 其它附件
$data_fields = ['icon', 'big_images'];
$attachment = ResourcesService::AttachmentParams($params, $data_fields);
if($attachment['code'] != 0)
{
return $attachment;
}
// 数据
$data = [
'name' => $params['name'],

View File

@ -44,7 +44,6 @@ class SlideService
$common_platform_type = lang('common_platform_type');
$common_is_enable_tips = lang('common_is_enable_tips');
$common_app_event_type = lang('common_app_event_type');
$images_host = config('shopxo.images_host');
foreach($data as &$v)
{
// 是否启用
@ -69,7 +68,7 @@ class SlideService
if(isset($v['images_url']))
{
$v['images_url_old'] = $v['images_url'];
$v['images_url'] = empty($v['images_url']) ? '' : $images_host.$v['images_url'];
$v['images_url'] = ResourcesService::AttachmentPathViewHandle($v['images_url']);
}
// 时间

View File

@ -52,12 +52,9 @@ class UserService
// 头像
if(!empty($v['avatar']))
{
if(substr($v['avatar'], 0, 4) != 'http')
{
$v['avatar'] = config('shopxo.images_host').$v['avatar'];
}
$v['avatar'] = ResourcesService::AttachmentPathViewHandle($v['avatar']);
} else {
$v['avatar'] = config('shopxo.images_host').'/static/index/'.strtolower(MyC('common_default_theme', 'default', true)).'/images/default-user-avatar.jpg';
$v['avatar'] = config('shopxo.attachment_host').'/static/index/'.strtolower(MyC('common_default_theme', 'default', true)).'/images/default-user-avatar.jpg';
}
// 注册时间
@ -656,12 +653,9 @@ class UserService
// 头像
if(!empty($user['avatar']))
{
if(substr($user['avatar'], 0, 4) != 'http')
{
$user['avatar'] = config('shopxo.images_host').$user['avatar'];
}
$user['avatar'] = ResourcesService::AttachmentPathViewHandle($user['avatar']);
} else {
$user['avatar'] = config('shopxo.images_host').'/static/index/'.strtolower(config('DEFAULT_THEME', 'default')).'/images/default-user-avatar.jpg';
$user['avatar'] = config('shopxo.attachment_host').'/static/index/'.strtolower(config('DEFAULT_THEME', 'default')).'/images/default-user-avatar.jpg';
}
if($is_app == true)

View File

@ -28,7 +28,7 @@ return [
'cache_common_home_nav_footer_key' => 'cache_common_home_nav_footer_data',
// 图片host, 数据库图片地址以/Public/...开头
'images_host' => defined('__MY_PUBLIC_URL__') ? substr(__MY_PUBLIC_URL__, 0, -1) : '',
'attachment_host' => defined('__MY_PUBLIC_URL__') ? substr(__MY_PUBLIC_URL__, 0, -1) : '',
// 开启U带域名
'url_domain_deploy' => true,

View File

@ -110,7 +110,7 @@ $(function()
html += '<ul class="plug-file-upload-view spec-images-view-'+index+'" data-form-name="spec_images['+index+']" data-max-number="1" data-dialog-type="images">';
html += '<li>';
html += '<input type="text" name="spec_images['+index+']" data-validation-message="请上传规格图片" required />';
html += '<img src="'+__images_host__+'/static/admin/default/images/default-images.png" />';
html += '<img src="'+__attachment_host__+'/static/admin/default/images/default-images.png" />';
html += '<i>×</i>';
html += '</li>';
html += '</ul>';