|
|
|
@ -194,97 +194,119 @@ function initHomeMarket() { |
|
|
|
|
var url = app.currencyBaseUrl + "market/getHomeList"; |
|
|
|
|
mui.ajax(url, { |
|
|
|
|
type: "GET", |
|
|
|
|
timeout: 5000, |
|
|
|
|
dataType: "json", |
|
|
|
|
success: function(j) { |
|
|
|
|
if(j.code == 200) { |
|
|
|
|
var markets = j.data; |
|
|
|
|
for(var i in markets) { |
|
|
|
|
var percent = (markets[i].percent * 100).toFixed(2) + "%"; |
|
|
|
|
if(markets[i].percent < 0) { |
|
|
|
|
document.getElementById("currency-amount-" + i).classList.add('app-market-down'); |
|
|
|
|
document.getElementById("currency-percent-" + i).classList.add('app-market-down'); |
|
|
|
|
} else { |
|
|
|
|
percent = "+" + percent; |
|
|
|
|
document.getElementById("currency-amount-" + i).classList.add('app-market-up'); |
|
|
|
|
document.getElementById("currency-percent-" + i).classList.add('app-market-up'); |
|
|
|
|
} |
|
|
|
|
var currencys = markets[i].currencyPair.split("-"); |
|
|
|
|
homeMarketPairObj[markets[i].currencyPair] = i; |
|
|
|
|
document.getElementById("currency-pair-" + i).innerText = currencys[0] + '/' + currencys[1]; |
|
|
|
|
document.getElementById("currency-amount-" + i).innerText = app.formatValue(markets[i].amount); |
|
|
|
|
document.getElementById("currency-percent-" + i).innerText = percent; |
|
|
|
|
document.getElementById("currency-rate-" + i).innerText = app.formatValue(markets[i][app.getExchangeRateLocalStorage().toLowerCase() + 'Amount'] * markets[i].amount) + app.getExchangeRateLocalStorage(); |
|
|
|
|
var currencyObj = { |
|
|
|
|
'marketObj': markets[i], |
|
|
|
|
'title': currencys[0] + '/' + currencys[1], |
|
|
|
|
'basecoin': currencys[1], |
|
|
|
|
'coin': currencys[0] |
|
|
|
|
} |
|
|
|
|
liListener(document.getElementById("currency-market-" + i), markets[i].currencyPair) |
|
|
|
|
} |
|
|
|
|
} else {} |
|
|
|
|
app.setLocalStorage("market/getHomeList",markets); |
|
|
|
|
renderHomeMarket(markets); |
|
|
|
|
} else { |
|
|
|
|
var markets = app.getLocalStorage("market/getHomeList"); |
|
|
|
|
renderHomeMarket(markets); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
error: function(xhr, type, errorThrown) { |
|
|
|
|
console.log(type) |
|
|
|
|
console.log("===market/getHomeList=== error type:"+type) |
|
|
|
|
var markets = app.getLocalStorage("market/getHomeList"); |
|
|
|
|
renderHomeMarket(markets); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function renderHomeMarket(markets){ |
|
|
|
|
for(var i in markets) { |
|
|
|
|
var percent = (markets[i].percent * 100).toFixed(2) + "%"; |
|
|
|
|
if(markets[i].percent < 0) { |
|
|
|
|
document.getElementById("currency-amount-" + i).classList.add('app-market-down'); |
|
|
|
|
document.getElementById("currency-percent-" + i).classList.add('app-market-down'); |
|
|
|
|
} else { |
|
|
|
|
percent = "+" + percent; |
|
|
|
|
document.getElementById("currency-amount-" + i).classList.add('app-market-up'); |
|
|
|
|
document.getElementById("currency-percent-" + i).classList.add('app-market-up'); |
|
|
|
|
} |
|
|
|
|
var currencys = markets[i].currencyPair.split("-"); |
|
|
|
|
homeMarketPairObj[markets[i].currencyPair] = i; |
|
|
|
|
document.getElementById("currency-pair-" + i).innerText = currencys[0] + '/' + currencys[1]; |
|
|
|
|
document.getElementById("currency-amount-" + i).innerText = app.formatValue(markets[i].amount); |
|
|
|
|
document.getElementById("currency-percent-" + i).innerText = percent; |
|
|
|
|
document.getElementById("currency-rate-" + i).innerText = app.formatValue(markets[i][app.getExchangeRateLocalStorage().toLowerCase() + 'Amount'] * markets[i].amount) + app.getExchangeRateLocalStorage(); |
|
|
|
|
var currencyObj = { |
|
|
|
|
'marketObj': markets[i], |
|
|
|
|
'title': currencys[0] + '/' + currencys[1], |
|
|
|
|
'basecoin': currencys[1], |
|
|
|
|
'coin': currencys[0] |
|
|
|
|
} |
|
|
|
|
liListener(document.getElementById("currency-market-" + i), markets[i].currencyPair) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function initTopMarket() { |
|
|
|
|
var url = app.currencyBaseUrl + "market/getTopList"; |
|
|
|
|
mui.ajax(url, { |
|
|
|
|
type: "GET", |
|
|
|
|
timeout: 5000, |
|
|
|
|
dataType: "json", |
|
|
|
|
success: function(j) { |
|
|
|
|
if(j.code == 200) { |
|
|
|
|
var markets = j.data; |
|
|
|
|
var ul = document.getElementById('top-ul'); |
|
|
|
|
ul.innerHTML = ''; |
|
|
|
|
for(var i = 0; i < markets.length; i++) { |
|
|
|
|
var currencys = markets[i].currencyPair.split('-'); |
|
|
|
|
var percent = (markets[i].percent * 100).toFixed(2) + "%"; |
|
|
|
|
var percentClassName; |
|
|
|
|
if(markets[i].percent < 0) { |
|
|
|
|
percentClassName = 'app-coin-percent-down'; |
|
|
|
|
} else { |
|
|
|
|
percentClassName = 'app-coin-percent-up'; |
|
|
|
|
percent = '+' + percent; |
|
|
|
|
} |
|
|
|
|
var li = document.createElement("li"); |
|
|
|
|
li.className = "gain-item-list mui-table-view-cell"; |
|
|
|
|
li.innerHTML = '<div class="gain-item-list-ranking">' + (i + 1) + '</div>' + |
|
|
|
|
'<div class="gain-item-list-name">' + |
|
|
|
|
' <span class="name1"><span>' + currencys[0] + '</span><span class="dapp-market-currency">/' + currencys[1] + '</span></span>' + |
|
|
|
|
' <span id="top-total-' + markets[i].currencyPair + '" class="name2">24H ' + app.formatValue(markets[i].total) + '</span>' + |
|
|
|
|
'</div>' + |
|
|
|
|
'<div class="gain-item-list-price">' + |
|
|
|
|
' <span id="top-amount-' + markets[i].currencyPair + '" class="price1">' + app.formatValue(markets[i].amount) + '</span>' + |
|
|
|
|
' <span id="top-money-' + markets[i].currencyPair + '" class="price2">' + app.formatValue(markets[i][app.getExchangeRateLocalStorage().toLowerCase() + 'Amount'] * markets[i].amount) + ' ' + app.getExchangeRateLocalStorage() + '</span>' + |
|
|
|
|
'</div>' + |
|
|
|
|
'<div id="top-percent-' + markets[i].currencyPair + '" class="gain-item-list-info ' + percentClassName + '">' + percent + '</div>'; |
|
|
|
|
var currencyObj = { |
|
|
|
|
'marketObj': markets[i], |
|
|
|
|
'title': currencys[0] + '/' + currencys[1], |
|
|
|
|
'basecoin': currencys[1], |
|
|
|
|
'coin': currencys[0] |
|
|
|
|
} |
|
|
|
|
ul.appendChild(li); |
|
|
|
|
liListener(li, markets[i].currencyPair) |
|
|
|
|
} |
|
|
|
|
app.setLocalStorage("market/getTopList",markets); |
|
|
|
|
renderTopMarket(markets); |
|
|
|
|
// var sliderItem = document.createElement('li');
|
|
|
|
|
// sliderItem.className = "gain-item-list mui-table-view-cell";
|
|
|
|
|
// sliderItem.innerHTML = '<div class="gain-item-list-ranking">' + (markets.length + 1) + '</div>' +
|
|
|
|
|
// '<div class="gain-item-list-name"><span class="name1">HFH/USDT</span><span class="name2">24H 0.1500</span></div><div class="gain-item-list-price"><span class="price1">0.1500</span><span class="price2">0.1500 USD</span></div><div class="gain-item-list-info">+0.00%</div>';
|
|
|
|
|
// ul.appendChild(sliderItem);
|
|
|
|
|
|
|
|
|
|
} else {} |
|
|
|
|
} else { |
|
|
|
|
var markets = app.getLocalStorage("market/getTopList"); |
|
|
|
|
renderTopMarket(markets); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
error: function(xhr, type, errorThrown) { |
|
|
|
|
console.log(type) |
|
|
|
|
console.log("===market/getTopList=== error type:"+type); |
|
|
|
|
var markets = app.getLocalStorage("market/getTopList"); |
|
|
|
|
renderTopMarket(markets); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function renderTopMarket(markets){ |
|
|
|
|
var ul = document.getElementById('top-ul'); |
|
|
|
|
ul.innerHTML = ''; |
|
|
|
|
for(var i = 0; i < markets.length; i++) { |
|
|
|
|
var currencys = markets[i].currencyPair.split('-'); |
|
|
|
|
var percent = (markets[i].percent * 100).toFixed(2) + "%"; |
|
|
|
|
var percentClassName; |
|
|
|
|
if(markets[i].percent < 0) { |
|
|
|
|
percentClassName = 'app-coin-percent-down'; |
|
|
|
|
} else { |
|
|
|
|
percentClassName = 'app-coin-percent-up'; |
|
|
|
|
percent = '+' + percent; |
|
|
|
|
} |
|
|
|
|
var li = document.createElement("li"); |
|
|
|
|
li.className = "gain-item-list mui-table-view-cell"; |
|
|
|
|
li.innerHTML = '<div class="gain-item-list-ranking">' + (i + 1) + '</div>' + |
|
|
|
|
'<div class="gain-item-list-name">' + |
|
|
|
|
' <span class="name1"><span>' + currencys[0] + '</span><span class="dapp-market-currency">/' + currencys[1] + '</span></span>' + |
|
|
|
|
' <span id="top-total-' + markets[i].currencyPair + '" class="name2">24H ' + app.formatValue(markets[i].total) + '</span>' + |
|
|
|
|
'</div>' + |
|
|
|
|
'<div class="gain-item-list-price">' + |
|
|
|
|
' <span id="top-amount-' + markets[i].currencyPair + '" class="price1">' + app.formatValue(markets[i].amount) + '</span>' + |
|
|
|
|
' <span id="top-money-' + markets[i].currencyPair + '" class="price2">' + app.formatValue(markets[i][app.getExchangeRateLocalStorage().toLowerCase() + 'Amount'] * markets[i].amount) + ' ' + app.getExchangeRateLocalStorage() + '</span>' + |
|
|
|
|
'</div>' + |
|
|
|
|
'<div id="top-percent-' + markets[i].currencyPair + '" class="gain-item-list-info ' + percentClassName + '">' + percent + '</div>'; |
|
|
|
|
var currencyObj = { |
|
|
|
|
'marketObj': markets[i], |
|
|
|
|
'title': currencys[0] + '/' + currencys[1], |
|
|
|
|
'basecoin': currencys[1], |
|
|
|
|
'coin': currencys[0] |
|
|
|
|
} |
|
|
|
|
ul.appendChild(li); |
|
|
|
|
liListener(li, markets[i].currencyPair) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function liListener(li, currencyPair) { |
|
|
|
|
li.addEventListener('tap', function() { |
|
|
|
|
openMarketInfo(currencyPair); |
|
|
|
@ -373,7 +395,6 @@ function listAdSlider() { |
|
|
|
|
* @param {Object} _data |
|
|
|
|
*/ |
|
|
|
|
function fillAdSliderData(resultData) { |
|
|
|
|
// console.log("1111" + resultData[resultData.length - 1].fileUrl);
|
|
|
|
|
if(resultData.length > 0) { |
|
|
|
|
var sliderGroup = document.getElementById('mui-slider-group1'); |
|
|
|
|
sliderGroup.innerHTML = ''; |
|
|
|
|