
{if $TplName != 'clientarea'}
{else/}
<script>
  $(function () {
var credit = '{$ClientArea.index.client.credit}' // 余额
var unpaid = '{$ClientArea.index.invoice_unpaid}' // 未支付
var creditNum = parseFloat(credit.replace('{$Lang.element}', ''))
var unpaidNum = parseFloat(unpaid.replace('{$Lang.element}', ''))

var percentage = parseFloat(creditNum / (creditNum + unpaidNum)).toFixed(2)

if (creditNum === 0 || (creditNum === 0 && unpaidNum === 0)) {
  percentage = 0
}
var myChart = echarts.init(document.getElementById("balanceCharts"));
// 资源列表
getSourceList()
  })

  function getSourceList() {
$('#sourceListBox').html(`<div class="h-100 d-flex align-items-center justify-content-center">{$Lang.data_loading}......</div>`)
$.ajax({
  type: "get",
  url: '{$Setting.web_url}' + '/clientarea',
  data: {
action: 'list'
  },
  success: function (data) {
$('#sourceListBox').html(data)
  }
});
  }
$(function () {
// 状态筛选
var parmas = []
var urlParams = '{:implode(',', $Think.get.domain_status)}';
var statusSelected = urlParams.split(',')
if(!statusSelected[0]){
  statusSelected=['Pending','Active','Suspended']
}

$('#statusSel').selectpicker('val', statusSelected)
$('#statusSel').on('change', function () {

statusSelected = $('#statusSel').val()
statusSelected.forEach(item => {
parmas += '&domain_status[]=' + item
})

location.href = 'service?groupid={$Think.get.groupid}' + parmas
});
// 关键字搜索
$('#searchInp').val('{$Think.get.keywords}')

$('#searchInp').on('keydown', function (e) {
if (e.keyCode == 13) {
location.href = 'service?groupid={$Think.get.groupid}&keywords=' + $('#searchInp').val() +
'&sort={$Think.get.sort}&orderby={$Think.get.orderby}&page={$Think.get.page}&limit={$Think.get.limit}'
}
})
$('#searchIcon').on('click', function () {
location.href = 'service?groupid={$Think.get.groupid}&keywords=' + $('#searchInp').val() +
'&sort={$Think.get.sort}&orderby={$Think.get.orderby}&page={$Think.get.page}&limit={$Think.get.limit}'
});

// 排序
$('.bg-light th:not(.checkbox)').on('click', function () {
var sort = '{$Think.get.sort}'
location.href = 'service?groupid={$Think.get.groupid}&keywords={$Think.get.keywords}&sort=' + (sort ==
'desc' ? 'asc' : 'desc') + '&orderby=' + $(this).attr('prop') +
'&page={$Think.get.page}&limit={$Think.get.limit}'
})
})


$(function () {

// 关键字搜索
$('#searchInp2').val('{$Think.get.keywords}')

$('#searchInp2').on('keydown', function (e) {
if (e.keyCode == 13) {
location.href = 'service?groupid={$Think.get.groupid}&keywords=' + $('#searchInp2').val() +
'&sort={$Think.get.sort}&orderby={$Think.get.orderby}&page={$Think.get.page}&limit={$Think.get.limit}'
}
})
$('#searchIcon2').on('click', function () {
location.href = 'service?groupid={$Think.get.groupid}&keywords=' + $('#searchInp2').val() +
'&sort={$Think.get.sort}&orderby={$Think.get.orderby}&page={$Think.get.page}&limit={$Think.get.limit}'
});
})
</script>
{/if}