<!-- 继承公共的 form -->
{{extend name="../../../module/view/form_table/detail" /}}

<!-- 重写数据模块 -->
{{block name="detail_data"}}
    {{:ModuleInclude('public/detail_nav_switch_tabs', [
        'nav_data' => [
            [
                'name' => MyLang('form_base_data_title'),
                'key'  => 'base',
            ],
            [
                'name' => MyLang('order.detail_goods_title'),
                'key'  => 'order-detail-goods',
            ],
            [
                'name'     => MyLang('common_service.order.delivery_express_info'),
                'key'      => 'order-detail-express',
                'is_show'  => $data['order_model'] == 0 ? 1 : 0,
            ],
            [
                'name'     => $data['order_model'] == 2 ? MyLang('order.detail_take_address_title') : MyLang('order.detail_user_address_title'),
                'key'      => 'order-detail-user-address',
                'is_show'  => in_array($data['order_model'], [0,1,2]) ? 1 : 0,
            ],
            [
                'name'     => MyLang('order.detail_service_title'),
                'key'      => 'order-detail-service',
                'is_show'  => $data['order_model'] == 1 ? 1 : 0,
            ],
            [
                'name'     => MyLang('order.detail_fictitious_title'),
                'key'      => 'order-detail-fictitious',
                'is_show'  => $data['order_model'] == 3 ? 1 : 0,
            ],
            [
                'name'     => MyLang('order.detail_trace_source_title'),
                'key'      => 'trace-source',
                'is_show'  => empty($data['items']) || empty($data['trace_source_data']) ? 0 : 1,
            ],
            [
                'name'     => empty($data['use_guide_data']) ? MyLang('use_guide_title') : $data['use_guide_data']['title'],
                'key'      => 'use-guide',
                'is_show'  => empty($data['use_guide_data']) ? 0 : 1,
            ],
            [
                'name' => MyLang('order.detail_log_nav_title'),
                'key'  => 'status-history',
            ],
        ]
    ])}}
    <div class="detail-content-switch-data-item">
        <!-- 父级内容 -->
        <div class="item am-active" data-key="base">
            {__block__}
        </div>

        <!-- 订单商品 -->
        <div class="item" data-key="order-detail-goods">
            <div class="am-padding-sm">
                {{if !empty($data['items'])}}
                    {{:ModuleInclude('order/module/goods', $data)}}
                {{else /}}
                    {{:ModuleInclude('public/not_data')}}
                {{/if}}
            </div>
        </div>

        <!-- 订单快递信息 -->
        <div class="item" data-key="order-detail-express">
            <div class="am-padding-sm">
                {{if !empty($data['express_data'])}}
                    <div class="am-scrollable-horizontal">
                        <table class="am-table am-text-left am-margin-bottom-0 am-text-nowrap">
                            <thead>
                                <tr>
                                    <th>{{:MyLang('order.form_table_express.name')}}</th>
                                    <th>{{:MyLang('order.form_table_express.number')}}</th>
                                    <th>{{:MyLang('order.form_table_express.note')}}</th>
                                    <th>{{:MyLang('order.form_table_express.time')}}</th>
                                </tr>
                            </thead>
                            <tbody>
                                {{foreach $data.express_data as $v}}
                                    <tr>
                                        <td>
                                            {{if empty($v['express_website_url'])}}
                                                {{if !empty($v['express_icon'])}}
                                                    <img src="{{$v.express_icon}}" class="am-img-thumbnail am-radius am-vertical-align-middle" width="20" height="20" alt="{{$v.express_name}}" />
                                                {{/if}}
                                                <span class="am-vertical-align-middle">{{$v.express_name}}</span>
                                            {{else /}}
                                                <a href="{{$v.express_website_url}}" target="_blank" rel="noopener noreferrer">
                                                    {{if !empty($v['express_icon'])}}
                                                        <img src="{{$v.express_icon}}" class="am-img-thumbnail am-radius am-vertical-align-middle" width="20" height="20" alt="{{$v.express_name}}" />
                                                    {{/if}}
                                                    <span class="am-vertical-align-middle">{{$v.express_name}}</span>
                                                </a>
                                            {{/if}}
                                        </td>
                                        <td>
                                            <span class="text-copy-submit">{{$v.express_number}}</span>
                                        </td>
                                        <td>{{$v.note}}</td>
                                        <td>{{$v.add_time}}</td>
                                    </tr>
                                {{/foreach}}
                            </tbody>
                        </table>
                    </div>
                {{else /}}
                    {{:ModuleInclude('public/not_data')}}
                {{/if}}
            </div>
        </div>

        <!-- 收货/自提地址 -->
        <div class="item" data-key="order-detail-user-address">
            <div class="am-padding-sm">
                {{if !empty($data['address_data'])}}
                    {{if $data['order_model'] eq 2}}
                        <!-- 取货地址 -->
                        <div class="am-alert">
                            <p>
                                <span>{{:MyLang('order.detail_take_address_contact')}}：</span>
                                <span class="text-copy-submit">{{$data.address_data.name}}</span>
                                <span> / </span>
                                <span class="text-copy-submit">{{$data.address_data.tel}}</span>
                            </p>
                            <p>
                                <span>{{:MyLang('order.detail_take_address_value')}}：</span>
                                <span class="text-copy-submit">{{$data.address_data.province_name}}{{$data.address_data.city_name}}{{$data.address_data.county_name}}{{$data.address_data.address}}</span>
                                {{if isset($data['address_data']['lng']) and isset($data['address_data']['lat']) and $data['address_data']['lng'] neq 0 and $data['address_data']['lat'] neq 0}}
                                    <a href="javascript:;" class="submit-map-popup am-color-blue am-margin-left-xs" data-lng="{{$data.address_data.lng}}" data-lat="{{$data.address_data.lat}}" data-title="{{:MyLang('map_title')}}" data-full-max="1" data-full-max-size="xs">
                                        <i class="iconfont icon-map-position"></i>
                                        <span>{{:MyLang('map_title')}}</span>
                                    </a>
                                {{/if}}
                            </p>
                            {{if !empty($data['address_data']['extraction_contact_name']) or !empty($data['address_data']['extraction_contact_tel']) or !empty($data['address_data']['appoint_time'])}}
                                <hr data-am-widget="divider" class="am-divider am-divider-dashed am-margin-vertical-xs">
                                {{if !empty($data['address_data']['extraction_contact_name']) or !empty($data['address_data']['extraction_contact_tel'])}}
                                    <p>
                                        <span>{{:MyLang('customer_info_title')}}：</span>
                                        {{if !empty($data['address_data']['extraction_contact_name'])}}
                                            <span class="text-copy-submit am-margin-right-sm">{{$data.address_data.extraction_contact_name}}</span>
                                        {{/if}}
                                        {{if !empty($data['address_data']['extraction_contact_tel'])}}
                                            <span class="text-copy-submit am-margin-right-sm">{{$data.address_data.extraction_contact_tel}}</span>
                                        {{/if}}
                                    </p>
                                {{/if}}
                                {{if !empty($data['address_data']['appoint_time'])}}
                                    <p>
                                        <span>{{:MyLang('appoint_time_title')}}：</span>
                                        <span class="text-copy-submit am-color-red">{{$data.address_data.appoint_time}}</span>
                                    </p>
                                {{/if}}
                            {{/if}}
                        </div>
                        <!-- 取货码 -->
                        {{if !empty($data['extraction_data'])}}
                            {{if !empty($data['extraction_data']['images'])}}
                                <p class="am-margin-bottom-xs">
                                    <img class="am-img-thumbnail am-radius am-block common-annex-view-event" src="{{$data.extraction_data.images}}" width="105" height="105" data-is-download="1" />
                                </p>
                            {{/if}}
                            <p>
                                <span>{{:MyLang('order.form_item_take')}}：</span>
                                {{if empty($data['extraction_data']['code'])}}
                                    <span class="am-text-danger">{{:MyLang('no_data')}}</span>
                                {{else /}}
                                    <span class="am-badge am-badge-success am-radius am-margin-0 text-copy-submit">{{$data.extraction_data.code}}</span>
                                {{/if}}
                            </p>
                        {{/if}}
                    {{else /}}
                        <!-- 收货地址 -->
                        <p>
                            <span>{{:MyLang('order.detail_user_address_name')}}：</span>
                            <span class="text-copy-submit">{{$data.address_data.name}}</span>
                        </p>
                        <p>
                            <span>{{:MyLang('order.detail_user_address_tel')}}：</span>
                            <span class="text-copy-submit">{{$data.address_data.tel}}</span>
                        </p>
                        <p>
                            <span>{{:MyLang('order.detail_user_address_value')}}：</span>
                            <span class="text-copy-submit">{{$data.address_data.province_name}}{{$data.address_data.city_name}}{{$data.address_data.county_name}}{{$data.address_data.address}}</span>
                            {{if !empty($data['address_data']['lng']) and !empty($data['address_data']['lat']) and $data['address_data']['lng'] neq 0 and $data['address_data']['lat'] neq 0}}
                                <a href="javascript:;" class="submit-map-popup am-color-blue am-margin-left-xs" data-lng="{{$data.address_data.lng}}" data-lat="{{$data.address_data.lat}}" data-title="{{:MyLang('map_title')}}" data-full-max="1" data-full-max-size="xs">
                                    <i class="iconfont icon-map-position"></i>
                                    <span>{{:MyLang('map_title')}}</span>
                                </a>
                            {{/if}}
                        </p>
                        {{if !empty($data['address_data']['extraction_contact_name']) or !empty($data['address_data']['extraction_contact_tel']) or !empty($data['address_data']['appoint_time'])}}
                            {{if !empty($data['address_data']['extraction_contact_name']) or !empty($data['address_data']['extraction_contact_tel'])}}
                                <hr data-am-widget="divider" class="am-divider am-divider-dashed am-margin-vertical-xs">
                                <p>
                                    <span>{{:MyLang('customer_info_title')}}：</span>
                                    {{if !empty($data['address_data']['extraction_contact_name'])}}
                                        <span class="text-copy-submit am-margin-right-sm">{{$data.address_data.extraction_contact_name}}</span>
                                    {{/if}}
                                    {{if !empty($data['address_data']['extraction_contact_tel'])}}
                                        <span class="text-copy-submit am-margin-right-sm">{{$data.address_data.extraction_contact_tel}}</span>
                                    {{/if}}
                                </p>
                            {{/if}}
                            {{if !empty($data['address_data']['appoint_time'])}}
                                <p>
                                    <span>{{:MyLang('appoint_time_title')}}：</span>
                                    <span class="text-copy-submit am-color-red">{{$data.address_data.appoint_time}}</span>
                                </p>
                            {{/if}}
                        {{/if}}
                        {{if !empty($data['address_data']['idcard_name']) or !empty($data['address_data']['idcard_number']) or !empty($data['address_data']['idcard_front']) or !empty($data['address_data']['idcard_back'])}}
                            <div class="am-alert am-alert-secondary">
                                <p class="am-margin-bottom-xs"><strong>{{:MyLang('order.detail_user_address_idcard')}}</strong></p>
                                <hr data-am-widget="divider" style="" class="am-divider am-divider-dashed am-margin-vertical-0" />
                                <div class="am-margin-top-xs">
                                    <p>
                                        <span>{{:MyLang('order.detail_user_address_idcard_name')}}：</span>
                                        <span class="text-copy-submit">{{$data.address_data.idcard_name}}</span>
                                    </p>
                                    <p>
                                        <span>{{:MyLang('order.detail_user_address_idcard_number')}}：</span>
                                        <span class="text-copy-submit">{{$data.address_data.idcard_number}}</span>
                                    </p>
                                    {{if !empty($data['address_data']['idcard_front']) or !empty($data['address_data']['idcard_back'])}}
                                        <p class="am-nbfc"><span class="am-fl">{{:MyLang('order.detail_user_address_idcard_pic')}}：</span>{{if !empty($data['address_data']['idcard_front'])}}<img width="50" height="68" src="{{$data.address_data.idcard_front}}" class="am-img-thumbnail am-radius am-fl am-margin-right-xs common-annex-view-event" data-is-download="1" />{{/if}} {{if !empty($data['address_data']['idcard_back'])}}<img width="50" height="68" src="{{$data.address_data.idcard_back}}" class="am-img-thumbnail am-radius am-fl common-annex-view-event" data-is-download="1" />{{/if}}</p>
                                    {{/if}}
                                </div>
                            </div>
                        {{/if}}
                    {{/if}}
                {{else /}}
                    {{:ModuleInclude('public/not_data')}}
                {{/if}}
            </div>
        </div>

        <!-- 同城订单 - 服务信息 -->
        <div class="item" data-key="order-detail-service">
            <div class="am-padding-sm">
                {{if $data['order_model'] eq 1 and !empty($data['service_data'])}}
                    <div class="am-scrollable-horizontal">
                        <table class="am-table am-text-left am-margin-bottom-0 am-text-nowrap">
                            <thead>
                                <tr>
                                    <th>{{:MyLang('order.form_item_service_name')}}</th>
                                    <th>{{:MyLang('order.form_item_service_mobile')}}</th>
                                    <th>{{:MyLang('order.form_item_service_time')}}</th>
                                    <th>{{:MyLang('order.form_item_note')}}</th>
                                </tr>
                            </thead>
                            <tbody>
                                {{foreach $data.service_data as $v}}
                                    <tr>
                                        <td>
                                            <span class="text-copy-submit">{{$v.service_name}}</span>
                                        </td>
                                        <td>
                                            <span class="text-copy-submit">{{$v.service_mobile}}</span>
                                        </td>
                                        <td>
                                            <span class="text-copy-submit">
                                                {{if !empty($v['service_duration_minute_text'])}}
                                                    <span class="am-fr"><i class="am-icon-history"></i> {{$v.service_duration_minute_text}}</span>
                                                {{/if}}
                                                {{if !empty($v['service_start_time'])}}
                                                    <p>{{$v.service_start_time}}</p>
                                                {{/if}}
                                                {{if !empty($v['service_end_time'])}}
                                                    <p>{{$v.service_end_time}}</p>
                                                {{/if}}
                                            </span>
                                        </td>
                                        <td>{{$v.note}}</td>
                                    </tr>
                                {{/foreach}}
                            </tbody>
                        </table>
                    </div>
                {{else /}}
                    {{:ModuleInclude('public/not_data')}}
                {{/if}}
            </div>
        </div>

        <!-- 虚拟订单 - 密钥信息 -->
        <div class="item" data-key="order-detail-fictitious">
            <div class="am-padding-sm">
                {{if $data['order_model'] eq 3 and !empty($data['items'])}}
                    <ul class="am-list am-list-static am-margin-bottom-0 fictitious-container">
                        {{foreach $data.items as $goods}}
                            <li class="am-g am-list-item-desced">
                                <div class="am-u-sm-2">
                                    <img src="{{$goods.images}}" alt="{{$goods.title}}" class="am-img-thumbnail am-radius" />
                                </div>
                                <div class="am-u-sm-10">
                                    {{if !empty($goods['spec_text'])}}
                                        <p>
                                            <strong>{{$goods.spec_text}}</strong>
                                        </p>
                                    {{/if}}
                                    {{if empty($goods['fictitious_goods_value'])}}
                                        <span class="am-text-grey am-text-xs">{{:MyLang('no_config_data_tips')}}</span>
                                    {{else /}}
                                        {{$goods.fictitious_goods_value|raw}}
                                    {{/if}}
                                </div>
                            </li>
                        {{/foreach}}
                    </ul>
                {{else /}}
                    {{:ModuleInclude('public/not_data')}}
                {{/if}}
            </div>
        </div>

        <!-- 追溯 -->
        {{if !empty($data['items']) and !empty($data['trace_source_data'])}}
            <div class="item" data-key="trace-source">
                <div class="am-padding-sm">
                    {{foreach $data.items as $k=>$v}}
                        <div class="am-flex am-gap-1">
                            <a href="{{$v.goods_url}}" target="_blank" rel="noopener noreferrer">
                                <img src="{{$v.images}}" class="am-radius am-border-grey" width="60" height="60" />
                            </a>
                            <div>
                                <a href="{{$v.goods_url}}" target="_blank" rel="noopener noreferrer" class="am-text-truncates">{{$v.title}}</a>
                                <p>{{$data.currency_data.currency_symbol}}{{$v.price}} x{{$v.buy_number}}</p>
                            </div>
                        </div>
                        <div class="am-margin-top-sm">
                            <table class="am-table am-table-bordered am-table-compact am-table-radius am-text-left am-margin-bottom-xl">
                                <thead>
                                    <tr>
                                        <th>{{:MyLang('number_title')}}</th>
                                        <th>{{:MyLang('common_service.order.form_item_trace_source_code')}}</th>
                                        <th>{{:MyLang('common_service.order.form_item_trace_source_batch_number')}}</th>
                                        <th>{{:MyLang('common_service.order.form_item_trace_source_batch_number_expire')}}</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    {{for start="1" end="$v.buy_number" comparison="elt"}}
                                        <tr>
                                            <td>
                                                {{:MyLang('number_title')}}{{$i}}
                                            </td>
                                            <td>
                                                {{if !empty($data['trace_source_data']) and !empty($data['trace_source_data'][$v['id']]) and !empty($data['trace_source_data'][$v['id']][$i]) and !empty($data['trace_source_data'][$v['id']][$i]['code'])}}
                                                    <span class="text-copy-submit">{{$data['trace_source_data'][$v['id']][$i]['code']}}</span>
                                                {{/if}}
                                            </td>
                                            <td>
                                                {{if !empty($data['trace_source_data']) and !empty($data['trace_source_data'][$v['id']]) and !empty($data['trace_source_data'][$v['id']][$i]) and !empty($data['trace_source_data'][$v['id']][$i]['batch_number'])}}
                                                    <span class="text-copy-submit">{{$data['trace_source_data'][$v['id']][$i]['batch_number']}}</span>
                                                {{/if}}
                                            </td>
                                            <td>
                                                {{if !empty($data['trace_source_data']) and !empty($data['trace_source_data'][$v['id']]) and !empty($data['trace_source_data'][$v['id']][$i]) and !empty($data['trace_source_data'][$v['id']][$i]['batch_number_expire'])}}
                                                    <span class="text-copy-submit">{{$data['trace_source_data'][$v['id']][$i]['batch_number_expire']}}</span>
                                                {{/if}}
                                            </td>
                                        </tr>
                                    {{/for}}
                                </tbody>
                            </table>
                        </div>
                    {{/foreach}}
                </div>
            </div>
        {{/if}}

        <!-- 使用指南 -->
        {{if !empty($data['use_guide_data'])}}
            <div class="item" data-key="use-guide">
                <div class="am-padding-sm">
                    {{if !empty($data['use_guide_data']['data'])}}
                        <section data-am-widget="accordion" class="am-accordion am-accordion-default am-margin-0" data-am-accordion='{ "multiple": true }'>
                            {{foreach $data.use_guide_data.data as $k=>$v}}
                                <dl class="am-accordion-item {{if $k eq 0}}am-active{{/if}}">
                                    <dt class="am-accordion-title">
                                        <img src="{{$v.images}}" class="am-radius am-border-grey am-vertical-align-middle" width="25" height="25" />
                                        <span class="am-vertical-align-middle">{{$v.title}}</span>
                                    </dt>
                                    <dd class="am-accordion-bd am-collapse {{if $k eq 0}}am-in{{/if}}">
                                        <div class="am-accordion-content">
                                            {{if empty($v['goods_use_guide'])}}
                                                <p class="am-color-grey">{{:MyLang('no_data')}}</p>
                                            {{else /}}
                                                <div class="richtext">{{$v.goods_use_guide|raw}}</div>
                                            {{/if}}
                                        </div>
                                    </dd>
                                </dl>
                            {{/foreach}}
                        </section>
                    {{else /}}
                        {{:ModuleInclude('public/not_data')}}
                    {{/if}}
                </div>
            </div>
        {{/if}}

        <!-- 订单状态日志 -->
        <div class="item" data-key="status-history">
            <div class="am-padding-sm">
                {{if !empty($data['status_history_data'])}}
                    <table class="am-table am-table-striped am-table-hover am-text-left">
                        <thead>
                            <tr>
                                <th>{{:MyLang('order.detail_log_creator_msg')}}</th>
                                <th>{{:MyLang('order.detail_log_creator_name')}}</th>
                                <th>{{:MyLang('order.detail_log_creator_time')}}</th>
                            </tr>
                        </thead>
                        <tbody>
                            {{foreach $data['status_history_data'] as $v}}
                                <tr>
                                    <td>{{$v.msg}}</td>
                                    <td>{{$v.creator_name}}</td>
                                    <td>{{$v.add_time}}</td>
                                </tr>
                            {{/foreach}}
                        </tbody>
                    </table>
                {{else /}}
                    {{:ModuleInclude('public/not_data')}}
                {{/if}}
            </div>
        </div>
    </div>
{{/block}}