# 外贸易调用文档

📅 2025-06-08

💡 外贸易各版本调取代码。

demo演示网址: 外贸易demo (opens new window)

# 配置文件 .env

## 香港
OSS_ACCESSKEY_ID=LTAIULE9uCu25ea5
OSS_ACCESSKEY_SECRET=ITr4cFZeNIaJL4p00CKEUwqB0X3PD6
OSS_ENDPOINT=oss-cn-hongkong.aliyuncs.com
OSS_BUCKET=xypt-hk
OSS_PATH=waimao

## 美国/俄罗斯
OSS_ACCESSKEY_ID=LTAIULE9uCu25ea5
OSS_ACCESSKEY_SECRET=ITr4cFZeNIaJL4p00CKEUwqB0X3PD6
OSS_ENDPOINT=oss-us-west-1.aliyuncs.com
OSS_BUCKET=xypt
OSS_PATH=waimao

\config\services.php       'cdn' => env('WEB_CDN', 'wm-hk.cdn.cn86.cn'),    (香港服务器)

\config\services.php       'cdn' => env('WEB_CDN', 'wm.cdn.cn86.cn'),    (美国服务器)
OSS_ENDPOINT=oss-us-west-1.aliyuncs.com

# 外贸易不论几种语言 ,先开启SSL, 再添加下面代码

set $is_https 0;
if ($request_uri !~ ^/api) {
  set $is_https "${is_https}1";
}
if ($server_port !~ 443){
set $is_https "${is_https}1";
}
if ($is_https = "011") {
  rewrite ^(/.*)$ https://$host$1 permanent;
}

# 说明页

{{ inject('visual')->url('block', 'about') }}
// 获取说明页标题
{!! inject('block')->block('about', 'title') !!}
// 获取说明页摘要
{!! inject('block')->block('about', 'extend') !!}
// 获取说明页内容
{!! inject('block')->block('about', 'content') !!}
{!! inject('block')->block('about', 'imgs', 0) !!}

示例:

// 获取说明页所有字段信息
{{ inject('block')->block('about') }}

// 返回值
return [
    'name': '',         // 名称
    'slug': '',         // 别名
    'description': [
        'title': '',    // 标题
        'imgs': '',     // 多图
        'extend': '',   // 摘要
        'content': ''   // 内容
    ],
    'created_at': '',   // 创建时间
    'updated_at': ''    // 更新时间
];

# 导航

<ul class="x-menu d-none d-xl-flex" {{ inject('visual')->url('nav') }}>
    @foreach (inject('nav')->nav() as $key => $value)
    <li data-id="{{ $key }}">
        <a href="{{ $value->linkurl }}">
            {{ $value->description->cname or $value->cname }} @if(!$value->children->isEmpty() || $value->content_model)<i class="fa fa-angle-down"></i>@endif
        </a>
        @if(!$value->children->isEmpty())
        <ul class="x-sub-menu">
            @foreach ($value->children as $val)
            <li><a href="{{ $val->linkurl }}">{{ $val->description->cname  }}</a></li>
            @endforeach
        </ul>
        @endif

        @if($value->content_model && !inject('category')->cate($value->content_model, $value->content_model_id)->isEmpty())
        <ul class="x-sub-menu">
            @foreach (inject('category')->cate($value->content_model, $value->content_model_id) as $val)
            <li><a href="{{ $val->present()->url($value->content_model) }}">{{ $val->description->cname }}</a></li>
            @endforeach
        </ul>
        @endif
        
    </li>
    @endforeach
</ul>

# 单页分类

<div class="three_item">
    <div class="nax-item">
        <h2>产品中心</h2>
        <ul class="dropdown-subsection">
            @foreach (inject('category')->cate('product') as $key=> $value)
            @if($value->flag)
            <li><a href="{{ $value->present()->url }}">{{ $value->description->present()->cname }}</a></li>
            @endif
            @endforeach
        </ul>
    </div>
    
    <div class="nax-item">
        <h2>关于我们</h2>
        <ul class="dropdown-subsection">
            @foreach (inject('list')->page(6) as $value)
            <li><a href="{{ $value->present()->url('page') }}">{{ $value->description->title }}</a></li>
            @endforeach
        </ul>
    </div>
</div>

# 产品列表(推荐)

 <ul class="h-product-list">
    @foreach (inject('list')->lists('product', 0, 6, 0, 'recom-1') as $value)
    <li>
        <a href="{{ $value->present()->url }}" title="{{ $value->description->title or '' }}">
            <div class="img">
                <img src="{{ $value->description->present()->image('420*450') }}" alt="{{ $value->description->title or '' }}">
            </div>
            <div class="text">
                <h3 class="clamp1">{{ $value->description->title or '' }}</h3>
            </div>
        </a>
    </li>
    @endforeach
</ul>

// 第二张图片
<img src="{{ $value->description->present()->image('300*300', '', 1) }}">

# 新闻列表(推荐)

<div class="home-news">
    <div class="max1600 clearfix">
        <div class="ha-title2 text-center mb40">
            <h3 class="mb10">{!! inject('block')->block('home-blog', 'title') !!}</h3>
            <p>{!! inject('block')->block('home-blog', 'extend') !!}</p>
        </div>

        <div class="hnews-wap">
            <ul class="hnews_list1 flex2 wrap">
                @foreach (inject('list')->lists('news', 0, 4, 0, 'recom-1') as $value)
                <li>
                    <a href="{{ $value->present()->url('news') }}" title="{{ $value->description->title or '' }}">
                        <div class="img com-img">
                            <img src="{{ $value->description->present()->image('420*450') }}" alt="{{ $value->description->title or '' }}">
                        </div>
                        <div class="al-txt">
                            <span>{{ $value->created_at->format('Y-m-d') }}</span>
                            <h3 class="clamp2">{{ $value->description->title or '' }}</h3>
                            <div class="read"><i></i>{{ inject('setting')->langs('web', 'see_more') }}</div>
                        </div>
                    </a>
                </li>
                 @endforeach
            </ul>
        </div>
        
    </div>
</div>

# banner广告图

<div class="h-home-banner">
    <div class="swiper-container banner_swiper" {{ inject('visual')->url('ad', 1) }} data-position-top="80px">
        <div class="swiper-wrapper">
            @foreach (inject('ad')->ad(1) as $key => $value)
            <div class="swiper-slide">
                <a href="{{ $value['url'] }}"><img src="{{ $value->img }}" alt="{!! $value['title'] !!}"></a>
                    
                <div class="v_cover">
                    <div class="v_con">
                        <div class="v_tit_aa">
                            {!! $value['title'] !!}
                        </div>
                        <div class="v_tit_bb">
                            {!! $value['summary'] !!}
                        </div>
                        <div class="v_tit_dd"><a href="{{ $value['url'] }}">Learn more</a></div>
                    </div>
                </div>

            </div>
            @endforeach
        </div>
        <div class="swiper-pagination"></div>
    </div>
</div>

# 图文列表

<ul class="h-photo-list" {{ inject('visual')->url('photo-group') }}>
    @foreach (inject('photoGroup')->list(1) as $key => $value)
    <li>
        <a href="{{ $value->url }}" title="{{ $value->description->title }}">
            <div class="text">
                <h3 class="clamp2">
                    {{ $value->description->title }}
                </h3>
                <div class="clamp2">
                    {{ $value->description->f_title or '' }}
                </div>
                <div class="clamp2">
                    {{ $value->description->text1 or '' }}
                </div>
                <div class="clamp2">
                    {!! $value->description->summary !!}
                </div>
            </div>
            <div class="img com-img2">
                <img src="{{ $value->description->present()->images(0) }}" alt="{{ $value->description->title }}">
            </div>
        </a>
    </li>
    @endforeach
</ul>

# 产品分类

<ul class="h-product-sort">
    @foreach (inject('category')->cate('product') as $key => $value)
    <li>
        <a href="{{ $value->present()->url }}" title="{{ $value->description->cname }}">
            <span><img src="{{ $value->description->img }}" alt="{{ $value->description->cname }}">{{ $value->description->cname }}</span>
        </a>
    </li>
    @endforeach
</ul>

# 单页分类

<div class="nax-item">
    <ul class="dropdown-subsection">
        @foreach (inject('list')->page(6) as $value)
        <li><a href="{{ $value->present()->url('page') }}">{{ $value->description->title }}</a></li>
        @endforeach
    </ul>
</div>

# 友情链接

 <div class="links hidden-xs hidden-sm">
    <span>LINKS:</span>
    @foreach (inject('list')->link(1) as $value)
    <a href="{{ $value->url }}">{{ $value->title }}</a>
    @endforeach
</div>

# 产品分类tab切换

<div class="mob-home-product">
    <div class="max1600 clearfix">
        <div class="home-pro-top flex2 j-space-between wrap">
            <div class="h-ptitle">
                <h3>{!! inject('block')->block('home-cptitle', 'title') !!}</h3>
                <p>{!! inject('block')->block('home-cptitle', 'extend') !!}</p>
            </div>
            <ul class="pfirst_sort mob_pfirst_sort hd">
                @foreach (inject('category')->cate() as $value)
                <li>
                    <a href="javascript:;">
                        <span><img src="{{ $value->description->img }}" alt="{{ $value->description->cname }}">{{ $value->description->cname }}</span>
                    </a>
                </li>
                @endforeach
            </ul>
        </div>

        <div class="pro_con bd">
            @foreach (inject('category')->cate() as $value)
            <div class="pro_main">
                <ul class="last_listt2">
                    @foreach (inject('list')->lists('product', $value->id, 12, 0) as $val)
                    <li>
                        <a href="{{ $val->present()->url }}" title="{{ $val->description->title }}" class="img">
                            <div class="img com-img">
                                <img src="{{ $val->description->present()->image('294*220') }}" alt="{{ $val->description->title }}">
                            </div>
                            <h3>{{ $val->description->title }}</h3>
                        </a>
                    </li>
                     @endforeach
                </ul>
            </div>
            @endforeach
        </div>
    
    </div>
</div>

# 产品分类多级tab切换

<ul class="pfirst_sort tab-li hd">
    @foreach (inject('category')->cate() as $key => $value)
    @if($key < 4)
    <li>
        <a href="{{ $value->present()->url }}">
            <span><img src="{{ $value->description->img }}" alt="{{ $value->description->cname }}">{{ $value->description->cname }}</span>
        </a>
    </li>
    @endif
    @endforeach
</ul>

<div class="bd tab-con">
    @foreach (inject('category')->cate() as $key => $value)
    @if($key < 4)
    <div class="tab-main h-product-middle pro_nav_item pro_nav_item_a1">
        @if(!$value->children->isEmpty())
        <div class="sub_nav flex2 wrap">
            <dl class="sub1-item">
                @foreach ($value->children as $key2=> $val)
                <dd>
                    <a href="{{ $val->present()->url }}" data-key="{{ $key2 }}" class="title-nav @if($key2==0) on @endif ">
                        @if($val->description->img)
                        <span class="item-title__icon"><img src="{{ $val->description->img }}" alt="{{ $val->description->cname }}"></span>
                        @endif
                        <span class="item-title__name">{{ $val->description->cname }}</span>
                        <span class="item-title__ico"></span>
                    </a>
                </dd>
                @endforeach
            </dl>
        
            @foreach ($value->children as $key=> $val)
            <div class="pro-status">
                <div class="i1">
                    <div class="name">
                        @if(!$val->children->isEmpty())
                        <div class="list">
                            @foreach ($val->children as $key21=> $val2)
                            <a href="{{ $val2->present()->url }}" data-id="{{ $val2->cid }}" data-key="{{ $key21 }}" @if($key21==0) class="on" @endif>{{ $val2->description->cname }}</a>
                            @endforeach
                        </div>
                        @endif
                    </div>
                </div>
        
                <div class="i2">
                    @foreach ($val->children as $key3=> $val2)
                    <div class="name items2 @if($key3==0) on @endif" data-id="{{ $val->cid }}" data-key="{{ $key3 }}">
                        <div class="last_listt on">
                            @foreach (inject('list')->lists('product', $val2->id, 12, 0) as $val3)
                            <a href="{{ $val3->present()->url }}">
                                <div class="com-img"><img src="{{ $val3->description->present()->image('294*220') }}" alt="{{ $val3->description->title }}" width="100%"></div>
                                <h3>{{ $val3->number or '' }}</h3>
                            </a>
                            @endforeach
                        </div>
                    </div>
                    @endforeach
                </div>
            </div>
            @endforeach
        </div>

        @else

        <div class="last_listt2">
            @foreach (inject('list')->lists('product', $value->id, 12, 0) as $val)
            <li>
                <a href="{{ $val->present()->url }}">
                    <div class="com-img"><img src="{{ $val->description->present()->image('294*220') }}" alt="{{ $val->description->title }}" width="100%"></div>
                    <h3>{{ $val->number }}</h3>
                </a>
            </li>
            @endforeach
        </div>
        
        @endif

    </div>
    @endif
    @endforeach
</div>

# 产品列表中调取产品分类

<ul class="list">
    @foreach (inject('list')->lists('product', 0, 3, 0, 'recom-1') as $key => $value)
    <li class="wow fadeInUp" data-wow-delay="{{$key*2}}00ms">
        <a href="{{ $value->present()->url() }}">
            <div class="txt">
                <h1>
                    {{ $value->cates->present()->url('product') }}
                </h1>
                <h2>
                    {{ $value->cates->description->cname or '' }}
                </h2>
            </div>
            <ul class="img">
                @foreach ($value->description->present()->images as $key=> $val)
                <img src="{{ $val }}" alt="{{ $val }}" data-id="{{ $key }}">
                @endforeach
            </ul>
        </a>
    </li>
    @endforeach
</ul>

# 视频判断

// 首页视频判断
<ul class="h-product-list">
    @foreach (inject('list')->lists('product', 0, 6, 0) as $value)
    <li>
        @if(isVideo($value->description->present()->image))
         <video muted controls id="video" width="100%" height="253" loop="loop">
            <source src="{{ videoUrl($value->description->present()->image) }}" type="video/mp4">
        </video>
        @else
        <a href="{{ $value->present()->url }}" title="{{ $value->description->title or '' }}">
             <div class="img">
                <img src="{{ $value->description->present()->image('420*450') }}" alt="{{ $value->description->title or '' }}">
            </div>
        </a>
        @endif
    </li>
    @endforeach
</ul>

// 产品详情页视频判断
@if(count($product->description->imgs) > 1)
    <div class="pp_lk clearfix">
        @foreach($product->description->present()->images as $img)
        <li>
            @if(isVideo($img))
            <video muted controls id="video" width="100%" height="253" loop="loop">
                <source src="{{ videoUrl($img) }}" type="video/mp4">
            </video>
            @else
            <a class="img com-img" href="{{ $img }}"  data-lightbox="roadtrip"/ title="{{ $product->description->title or '' }}" alt="{{ $product->description->title or '' }}">
                <img src="{{ $img }}" alt="{{ $product->description->title or '' }}">
            </a>
            @endif
        </li>
        @endforeach
    </div>
@endif

# sitemap

<a href="/sitemap.xml" target="_blank">{{ inject('setting')->langs('system', 'sitemap') }}</a>

# 内页产品分类多级高亮

<?php $activeIds = $cate->getAncestorsAndSelf(['id'])->pluck('id')->toArray(); ?>

<div class="slideBarLeft hidden-xs hidden-sm">
    <h3 class="left-title">
        {{ inject('setting')->langs('web', 'product') }}
        <i class="visible-xs iconfont icon-zhankai"></i>
    </h3>

    <div class="moreLink mb-20">
        <ul {{ inject('visual')->url('product-cate') }}>
            @foreach (inject('category')->cate('product', $rootId) as $value)
            <li class="mb-20" data-id="{{ $value->id }}">
                <a class="one font-20 font-bold flex2 flex-jb flex-ac {{ in_array($value->id, $activeIds) ? 'active' : '' }}"
                   href="{{ $value->present()->url }}" title="{{ $value->description->cname }}">{{ $value->description->cname }}
                    @if(!$value->children->isEmpty())
                    <i class="iconfont2 iconfont-xiajiantou1"></i>
                    @endif
                </a>

                @if(!$value->children->isEmpty())
                <ul>
                    @foreach ($value->children as $val)
                    <li data-id="{{ $val->id }}">
                        <a href="{{ $val->present()->url }}" class="two font-16 font-bold flex2 flex-jb flex-ac {{ in_array($val->id, $activeIds) ? 'active' : '' }}">
                            {{ $val->description->cname }}
                            @if(!$val->children->isEmpty())
                            <i class="iconfont2 iconfont-xiajiantou1"></i>
                            @endif
                        </a>

                        @if(!$val->children->isEmpty())
                        <ul>
                            @foreach ($val->children as $val2)
                            <li data-id="{{ $val2->id }}">
                                <a href="{{ $val2->present()->url }}" class="two font-16 font-bold flex2 flex-jb flex-ac {{ in_array($val2->id, $activeIds) ? 'active' : '' }}">
                                    {{ $val2->description->cname }}
                                </a>
                            </li>
                            @endforeach
                        </ul>
                        @endif
                    </li>
                    @endforeach
                </ul>
                @endif
            </li>
            @endforeach
        </ul>
    </div>
</div>

<style>
@font-face{font-family:iconfont2;src:url('../fonts/font_378823_8nbt6xgrwa8.eot?t=1747619866917');src:url('../fonts/font_378823_8nbt6xgrwa8.eot?t=1747619866917') format('embedded-opentype'),url('../fonts/font_378823_8nbt6xgrwa8.woff2?t=1747619866917') format('woff2'),url('../fonts/font_378823_8nbt6xgrwa8.woff?t=1747619866917') format('woff'),url('../fonts/font_378823_8nbt6xgrwa8.ttf?t=1747619866917') format('truetype'),url('../fonts/font_378823_8nbt6xgrwa8.svg?t=1747619866917') format('svg');font-display:swap}
.iconfont2{font-family:iconfont2!important;font-size:16px;font-style:normal;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}
.iconfont-shangjiantou:before{content:"\e767"}
.iconfont-xiajiantou1:before{content:"\e768"}
i.iconfont2{font-size:inherit}
a{font:inherit;color:inherit}
.flex-ac{-webkit-box-align:center;-webkit-align-items:center;-moz-box-align:center;-ms-flex-align:center;align-items:center}
.flex-jb{-webkit-box-pack:justify;-webkit-justify-content:space-between;-moz-box-pack:justify;-ms-flex-pack:justify;justify-content:space-between}
.font-16{font-size:16px}
.font-20{font-size:20px}
.font-bold{font-weight:700}
.slideBarLeft{color:#000}
.slideBarLeft .moreLink{background-color:#f7f7f7;padding:10%}
.slideBarLeft .moreLink ul ul{position:relative;margin:.5em 0;padding-left:10%;display:none}
.slideBarLeft .moreLink ul ul:before{content:'';left:5px;top:1%;width:1px;height:98%;background-color:#d1d1d1;position:absolute}
.slideBarLeft .moreLink ul ul a{padding:.2em .5em;position:relative}
.slideBarLeft .moreLink ul ul a:before{content:'';width:.4em;height:.4em;border-radius:100%;background-color:var(--main-theme-color);position:absolute;top:50%;margin-top:-.2em;left:-10.5%;opacity:0;transform:translateY(-50%)}
.slideBarLeft .moreLink ul ul a.active:before,.slideBarLeft .moreLink ul ul a.on:before{opacity:1}
.slideBarLeft .moreLink ul ul ul.noborder{padding-left:4%}
.slideBarLeft .moreLink ul ul ul.noborder:before{display:none}
.slideBarLeft .moreLink ul ul ul.noborder>li>a:before{display:none}
.slideBarLeft .moreLink ul ul ul ul a:before{width:.7em;height:.7em;border:1px solid #d1d1d1;background-color:#f7f7f7;opacity:1}
.slideBarLeft .moreLink ul ul a.active,.slideBarLeft .moreLink ul ul a.on{background-color:#fff;color:var(--main-theme-color)}
.slideBarLeft .moreLink ul ul ul ul a.active,.slideBarLeft .moreLink ul ul ul ul a.on{background-color:transparent}
.slideBarLeft .moreLink ul ul ul ul a.active:before,.slideBarLeft .moreLink ul ul ul ul a.on:before{border-color:var(--main-theme-color)}
.slideBarLeft .moreLink ul ul a.on i.iconfont-plus{transform:rotate(45deg)}
.slideBarLeft .moreLink ul a{transition:.5s}
.slideBarLeft .moreLink ul a.active+ul{display:block}
.slideBarLeft .moreLink ul a:hover{color:var(--main-theme-color)}
</style>

<script>
    $(function () {
      $('.moreLink>ul').on('click', 'a > i', function (e) {
          e.preventDefault();
          e.stopPropagation();

          var a = $(this).parent();

          a.toggleClass('active');

          if (a.hasClass('active')) {
              a.parents('li').children('a').addClass('active');
          }
      });
  });
  </script>

# 视频banner自适应

@foreach (inject('ad')->ad(1) as $key => $value)
    <div class="swiper-slide">

          @if(trim((string) $value->summary) !== '')
          <div class="h100 img relative">
              <img src="{{ $value->img }}" alt="{!! $value['title'] !!}">
              <div class="video-all2">
                  <video autoplay muted loop playsinline preload="metadata" poster="{{ $value->img }}" src="{{ $value->summary }}"></video>
              </div>
          </div>
          @else
          <a href="{{ $value['url'] }}" class="img relative">
            <img src="{{ $value->img }}" alt="{!! $value['title'] !!}">
          </a>
          @endif
            
    </div>
@endforeach

*css*
.h100{height:100%}
.h100.img>img{display:block;width:100%}
.video-all2{position:absolute;height:100%;width:100%;left:0;top:0;z-index:9}
.video-all2 video{position:absolute;left:0;top:0;height:100%;width:100%;object-fit:cover}

# 外贸易判断语言

@if (config('lang') == 'en' ||  config('lang') == 'ja')

@endif

# 产品后台加扩展字段


 @foreach([
    'extend' => '扩展字段1',
    'extend1' => '扩展字段2',
    'extend2' => '扩展字段3',
    'extend3' => '扩展字段4'
] as $extendField => $extendLabel)
<div class="form-group">
    <label class="col-sm-2 control-label label-width">{{ $extendLabel }}:</label>
    <div class="col-sm-5">
        {!! Form::textarea("description[{$managerLang}][{$extendField}]", '', ['class'=>'form-control', 'rows'=>3]) !!}
    </div>
</div>
@endforeach


 @foreach([
    'extend' => '扩展字段1',
    'extend1' => '扩展字段2',
    'extend2' => '扩展字段3',
    'extend3' => '扩展字段4'
] as $extendField => $extendLabel)
<div class="form-group">
    <label class="col-sm-2 control-label label-width">{{ $extendLabel }}:</label>

    <div class="col-sm-5">
        {!! Form::textarea(
            "description[{$managerLang}][{$extendField}]",
            isset($descriptions[$managerLang])
                ? $descriptions[$managerLang][0]->{$extendField}
                : '',
            ['class'=>'form-control', 'rows'=>3]
        ) !!}
    </div>
</div>
@endforeach

# 可视化标签


{{ inject('visual')->url('block', 'about') }}  // 说明页

{{ inject('visual')->url('ad', 2) }} data-position-top="80px"   // 广告位

{{ inject('visual')->url('photo-group') }} data-position-top="80px"  // 图文

{{ inject('visual')->url('case-cate') }}   {{ inject('visual')->url('case') }}   // 案例

{{ inject('visual')->url('news-cate') }}  {{ inject('visual')->url('news') }}   // 新闻

{{ inject('visual')->url('product-cate') }}  {{ inject('visual')->url('product') }}  // 产品

{{ inject('setting')->langs('web', 'see_more') }}  // 模版语言包

{{ inject('setting')->langs('system', 'see_more') }}  // 系统语言包

{{ inject('visual')->url('view-lang') }}  // 模版语言包-可视化标签