From 71bab8533ec57e370c9a22f6e095ee5bf935c42b Mon Sep 17 00:00:00 2001 From: huangxinlu Date: Wed, 13 Nov 2019 11:03:10 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=A1=8C=E6=83=85=E7=BC=93?= =?UTF-8?q?=E5=AD=98=EF=BC=8C=E4=BF=AE=E5=A4=8D=E9=A1=B9=E7=9B=AE=E4=B8=AD?= =?UTF-8?q?=E5=BF=83=E5=9B=BE=E7=89=87=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- html/home/js/home.js | 145 +++++++++++++++----------- lib/js/app.js | 1 - mine/html/my/project_white_paper.html | 2 +- 3 files changed, 84 insertions(+), 64 deletions(-) diff --git a/html/home/js/home.js b/html/home/js/home.js index 92154c8..0414080 100644 --- a/html/home/js/home.js +++ b/html/home/js/home.js @@ -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 = '
' + (i + 1) + '
' + - '
' + - ' ' + currencys[0] + '/' + currencys[1] + '' + - ' 24H ' + app.formatValue(markets[i].total) + '' + - '
' + - '
' + - ' ' + app.formatValue(markets[i].amount) + '' + - ' ' + app.formatValue(markets[i][app.getExchangeRateLocalStorage().toLowerCase() + 'Amount'] * markets[i].amount) + ' ' + app.getExchangeRateLocalStorage() + '' + - '
' + - '
' + percent + '
'; - 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 = '
' + (markets.length + 1) + '
' + // '
HFH/USDT24H 0.1500
0.15000.1500 USD
+0.00%
'; // 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 = '
' + (i + 1) + '
' + + '
' + + ' ' + currencys[0] + '/' + currencys[1] + '' + + ' 24H ' + app.formatValue(markets[i].total) + '' + + '
' + + '
' + + ' ' + app.formatValue(markets[i].amount) + '' + + ' ' + app.formatValue(markets[i][app.getExchangeRateLocalStorage().toLowerCase() + 'Amount'] * markets[i].amount) + ' ' + app.getExchangeRateLocalStorage() + '' + + '
' + + '
' + percent + '
'; + 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 = ''; diff --git a/lib/js/app.js b/lib/js/app.js index ffaf9af..bd016ce 100644 --- a/lib/js/app.js +++ b/lib/js/app.js @@ -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; } diff --git a/mine/html/my/project_white_paper.html b/mine/html/my/project_white_paper.html index dce3dc9..274f2ac 100644 --- a/mine/html/my/project_white_paper.html +++ b/mine/html/my/project_white_paper.html @@ -139,7 +139,7 @@ thumbs: '0', //判断用户是否点赞过 projectID: '', //项目id userLocalStorage: app.getUserLocalStorage(), - base_file_url: app.paperUrl, //基础路 + base_file_url: app.walletFileUrl, //基础路 search_value: '', //搜索框值 }, methods: {