添加行情缓存,修复项目中心图片显示问题

master
huangxinlu 5 years ago
parent 0f194ad27b
commit 71bab8533e
  1. 145
      html/home/js/home.js
  2. 1
      lib/js/app.js
  3. 2
      mine/html/my/project_white_paper.html

@ -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&nbsp;' + 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&nbsp;' + 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 = '';

@ -693,7 +693,6 @@
val = compute.Mul(val, 1e2, 2);
val = compute.Div(val, 1e2, 2);
val = val.toFixed(2);
console.log(val);
}
return val;
}

@ -139,7 +139,7 @@
thumbs: '0', //判断用户是否点赞过
projectID: '', //项目id
userLocalStorage: app.getUserLocalStorage(),
base_file_url: app.paperUrl, //基础路
base_file_url: app.walletFileUrl, //基础路
search_value: '', //搜索框值
},
methods: {

Loading…
Cancel
Save