<?php
/**
 * 投资者接待区块模板
 * 
 * @package Nenghui_Energy_Theme
 */

// 防止直接访问
if (!defined('ABSPATH')) {
    exit;
}

// 获取区块属性（支持直接调用和短代码调用）
global $investor_reception_attributes;

// 优先使用全局变量（短代码调用），其次使用直接传入的属性
$current_attributes = !empty($investor_reception_attributes) ? $investor_reception_attributes : (isset($attributes) ? $attributes : array());

$block_id = isset($current_attributes['blockId']) ? $current_attributes['blockId'] : 'investor-reception-' . uniqid();
$theme = isset($current_attributes['theme']) ? $current_attributes['theme'] : 'default';
$title = isset($current_attributes['title']) ? $current_attributes['title'] : '投资者接待';
$subtitle = isset($current_attributes['subtitle']) ? $current_attributes['subtitle'] : '投资者交流平台';
$contact_person = isset($current_attributes['contactPerson']) ? $current_attributes['contactPerson'] : '董事会秘书 罗联明';
$contact_phone = isset($current_attributes['contactPhone']) ? $current_attributes['contactPhone'] : '021-50896255';
$contact_email = isset($current_attributes['contactEmail']) ? $current_attributes['contactEmail'] : 'nenghui@nhet.com.cn';

// 获取背景图片（如果传入的是旧的测试地址或为空，使用正式环境的默认图）
$background_image = isset($current_attributes['backgroundImage']) ? $current_attributes['backgroundImage'] : '';
if (empty($background_image) || strpos($background_image, 'matepress.cn') !== false) {
    $background_image = 'https://cn.nenghui.com/wp-content/uploads/2025/09/touzizhe-banner-1.webp';
}

// 加载样式和脚本
wp_enqueue_style('investor-reception-style', get_template_directory_uri() . '/assets/css/investor-reception.css', array(), '1.0.0');
wp_enqueue_script('investor-reception-script', get_template_directory_uri() . '/assets/js/investor-reception.js', array('jquery'), '1.0.0', true);

// 本地化脚本数据
wp_localize_script('investor-reception-script', 'investorReceptionAjax', array(
    'nonce' => wp_create_nonce('investor_reception_nonce')
));
?>

<div class="investor-reception-block theme-<?php echo esc_attr($theme); ?>" id="<?php echo esc_attr($block_id); ?>">
    <div class="investor-reception-container">
        <!-- 图片区域 -->
        <div class="image-section">
            <img src="<?php echo esc_url($background_image); ?>" alt="<?php echo esc_attr($title); ?>" class="reception-image">
        </div>
        
        <!-- 内容区域 -->
        <div class="content-section">
            <div class="content-container">
                <!-- 标题区域 -->
                <div class="title-section">
                    <p class="main-title"><?php echo esc_html($title); ?> | <?php echo esc_html($subtitle); ?></p>
                </div>
                
                <!-- 联系信息区域 -->
                <div class="contact-section">
                    <div class="contact-item">
                        <span class="contact-label">联系人：</span>
                        <span class="contact-value"><?php echo esc_html($contact_person); ?></span>
                    </div>
                    
                    <div class="contact-item">
                        <span class="contact-label">联系电话：</span>
                        <span class="contact-value">
                            <a href="tel:<?php echo esc_attr(str_replace(array(' ', '-'), '', $contact_phone)); ?>" class="phone-link">
                                <?php echo esc_html($contact_phone); ?>
                            </a>
                        </span>
                    </div>
                    
                    <div class="contact-item">
                        <span class="contact-label">邮箱：</span>
                        <span class="contact-value">
                            <a href="mailto:<?php echo esc_attr($contact_email); ?>" class="email-link">
                                <?php echo esc_html($contact_email); ?>
                            </a>
                        </span>
                    </div>
                    <div class="contact-item">
                        <a href="#" class="contact-btn">投资者交流平台</a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>