<% if @access_token.present? && @overview_data.present? %>
  <div>
    数据来源百度统计，本周 <%= @overview_data['timeSpan'] %>
  </div>
  <table class="table table-hover text-center subject-list-table">
    <thead class="thead-light">
    <tr>
      <th width="20%">日期</th>
      <th width="15%">访问量</th>
      <th width="15%">访客数</th>
      <th width="15%">IP数</th>
    </tr>
    </thead>
    <tbody>
    <% pv_count = [] %>
    <% visitor_count = [] %>
    <% ip_count = [] %>
    <% @overview_data['items'][0].each_with_index do |date, index| %>
      <% pv = @overview_data['items'][1][index][0] %>
      <% visitor = @overview_data['items'][1][index][1] %>
      <% ip = @overview_data['items'][1][index][2] %>
      <tr class="">
        <td><%= date[0] %> </td>
        <td><%= pv %></td>
        <td><%= visitor %></td>
        <td><%= ip %></td>
        </td>
      </tr>
      <% pv_count.push(pv) %>
      <% visitor_count.push(visitor) %>
      <% ip_count.push(ip) %>
    <% end %>
    <tr class="">
      <td><span style="color: #ff8200">合计</span></td>
      <td><span style="color: #ff8200"><%= pv_count %></span></td>
      <td><span style="color: #ff8200"><%= visitor_count %></span></td>
      <td><span style="color: #ff8200"><%= ip_count %></span></td>
      </td>
    </tr>
    </tbody>
  </table>
  <table class="table table-hover text-center subject-list-table">
    <thead class="thead-light">
    <tr>
      <th width="15%">直接访问占比</th>
      <th width="15%">外部链接占比</th>
      <th width="15%">搜索引擎占比</th>
      <th width="20%">自定义</th>
    </tr>
    </thead>
    <tbody>
    <tr class="">
      <% @source_from_data['items'][1].each_with_index do |source, index| %>
        <td><%= ((source[0].to_f / @source_from_data['sum'][0][0].to_f) * 100).round(2).to_s %>%</td>
      <% end %>
    </tr>
    </tbody>
  </table>
<% else %>
  <div>
    <a href="/admins/baidu_tongji" target="_blank">1.百度统计需人工授权,点击去授权</a>
  </div>
  <div>
    <a href="/admins/baidu_tongji_auth" onclick="this.href = '/admins/baidu_tongji_auth?code=' + document.getElementById('auth_code').value">2.获取百度统计授权码</a>
    <input name="code" id="auth_code" style="width: 380px" placeholder="请输入1.百度统计返回的code后，点击2.获取百度统计Token"/>
  </div>
<% end %>