trade_status和trade_status2在ios的差别
1.使用document绑定滑动页面不会很流畅,他会带有浏览器滚动的效果2.使用元素绑定scroll,滑动非常流畅,应该是调用了原生的效果trade_status.js
/** * Created by huyaozong on 2016-8-1. */var PORTFOLIO_ID;//窗口高度,下拉计数,判断有无数据var winH = 0, myPage = 1, gData = 1;var isScroll = true, $myBox = $('#myBox'), $pullUp = $myBox.find('.pullUp');$(document).ready(function () { winH = $(window).height(); $myBox.height(winH); // PORTFOLIO_ID = $.getUrlParameter('portfolioId'); Trading(1, false);});//是否订阅function IsSubscribe() { function CallBack(resp) { var mydata = resp.data; //1普通产品,//2安盈尊享 if (mydata.portfolioType === 2) { //已经订阅 if (mydata.isSub === 1 && gData > 0) { $('#showTip').hide(); } else if (mydata.isSub === 0 && gData > 0) { //订阅提示 LoginType(function (status, resp) { if (status) { var arr = []; if (resp.portfolioid != null) { arr.push(resp.portfolioid); } if (resp.productlist != null) { arr.push(resp.productlist.split(',')); arr = arr.concat.apply([], arr); } //默认显示 $('#showTip').show(); $.each(arr, function (i, val) { //如果是用户自己则隐藏 if (val == PORTFOLIO_ID) { $('#showTip').hide(); } }); } else { $('#showTip').show(); $('#showTip i').on('click', function () { $(this).parents('.showTip').hide(); }); } }); } } else if (mydata.portfolioType === 1) { $('#showTip').hide(); } PopupDestroy(); }}//交易动态function Trading(num, boolean) { var datas = { afterPosition:0, beforePosition:0.0121, costPrice:10.36, delayFlag:1, earnFare:"0.04", oprDate:"2016-06-23", oprId:null, oprResult:"清仓", oprTime:"09:57:26", oprType:1, reason:"1、该股股价快速上涨有调整需求,建议逢高出局,仅供参考。(止盈) 2、该股股价短期走弱,建议出局,仅供参考。(止损)", stockCode:"600356", stockName:"恒丰纸业" }; var sHtml = ''; for (var i = 0, len = 10; i < len; i++) { sHtml += ''; sHtml += ''; } $('#trade-list').append(sHtml); //当数据小于10代表下次没数据了 if (datas.length < 10) { gData = 0; $pullUp.html('没有更多数据了'); $myBox.off('scroll'); } else { if ($('#trade-list').height() > winH - 51) { PullUpAction(); } $pullUp.html(' '); } isScroll = true; if (boolean) { IsSubscribe(); } else { // PopupDestroy(); }}//上拉加载function PullUpAction() { $myBox.off('scroll').on('scroll', function () { if ($pullUp.offset().top <= $myBox.height()) { console.log('111'); if (isScroll) { isScroll = false; myPage++; Trading(myPage); } } });}//小数保留两位function DecimaltoFixed(num) { return (parseFloat(num) * 100).toFixed(2);}'; sHtml += '
'; sHtml += ' '; sHtml += '- '; sHtml += '
'; sHtml += ''; sHtml += '' + datas.stockName + '
' + datas.stockCode + '
'; sHtml += '' + datas.oprResult + '
' + datas.oprTime.substring(0, datas.oprTime.lastIndexOf(':')) + '
'; //只有清仓才判断盈利还是亏损 if (datas.earnFare !== '' && Number(datas.earnFare) > 0) { sHtml += '' + datas.costPrice + '
' + datas.oprDate + '
'; } else if (datas.earnFare !== '' && Number(datas.earnFare) < 0) { sHtml += '' + DecimaltoFixed(datas.beforePosition) + '' + DecimaltoFixed(datas.afterPosition) + '
'; sHtml += '盈利' + DecimaltoFixed(datas.earnFare) + '%
'; } else { sHtml += '' + DecimaltoFixed(datas.beforePosition) + '' + DecimaltoFixed(datas.afterPosition) + '
'; sHtml += '亏损' + DecimaltoFixed(datas.earnFare) + '%
' + DecimaltoFixed(datas.beforePosition) + '' + DecimaltoFixed(datas.afterPosition) + '
'; } sHtml += ''; sHtml += ''; sHtml += ''; sHtml += ''; sHtml += '操作理由
'; if (datas.reason !== null) { sHtml += '' + datas.reason + '
'; } else { sHtml += '无
'; } sHtml += '
trade_status2.js
/** * Created by huyaozong on 2016-8-1. */var PORTFOLIO_ID;//窗口高度,下拉计数,判断有无数据var winH = 0, myPage = 1, gData = 1;var isScroll = true, $myBox = $('#myBox'), $pullUp = $myBox.find('.pullUp');$(document).ready(function () { // winH = $(window).height(); // $myBox.height(winH); // PORTFOLIO_ID = $.getUrlParameter('portfolioId'); Trading(1, false);});//是否订阅function IsSubscribe() { function CallBack(resp) { var mydata = resp.data; //1普通产品,//2安盈尊享 if (mydata.portfolioType === 2) { //已经订阅 if (mydata.isSub === 1 && gData > 0) { $('#showTip').hide(); } else if (mydata.isSub === 0 && gData > 0) { //订阅提示 LoginType(function (status, resp) { if (status) { var arr = []; if (resp.portfolioid != null) { arr.push(resp.portfolioid); } if (resp.productlist != null) { arr.push(resp.productlist.split(',')); arr = arr.concat.apply([], arr); } //默认显示 $('#showTip').show(); $.each(arr, function (i, val) { //如果是用户自己则隐藏 if (val == PORTFOLIO_ID) { $('#showTip').hide(); } }); } else { $('#showTip').show(); $('#showTip i').on('click', function () { $(this).parents('.showTip').hide(); }); } }); } } else if (mydata.portfolioType === 1) { $('#showTip').hide(); } PopupDestroy(); }}//交易动态function Trading(num, boolean) { var datas = { afterPosition:0, beforePosition:0.0121, costPrice:10.36, delayFlag:1, earnFare:"0.04", oprDate:"2016-06-23", oprId:null, oprResult:"清仓", oprTime:"09:57:26", oprType:1, reason:"1、该股股价快速上涨有调整需求,建议逢高出局,仅供参考。(止盈) 2、该股股价短期走弱,建议出局,仅供参考。(止损)", stockCode:"600356", stockName:"恒丰纸业" }; var sHtml = ''; for (var i = 0, len = 10; i < len; i++) { sHtml += ''; sHtml += ''; } $('#trade-list').append(sHtml); //当数据小于10代表下次没数据了 if (datas.length < 10) { gData = 0; $pullUp.html('没有更多数据了'); $myBox.off('scroll'); } else { if ($('#trade-list').height() > winH - 51) { PullUpAction(); } $pullUp.html(' '); } isScroll = true; if (boolean) { IsSubscribe(); } else { // PopupDestroy(); }}//上拉加载function PullUpAction() { $(document).off("scroll").on("scroll", function () { var $docm = $(document); var actionH = $docm.scrollTop() + $(window).height(); if (actionH === $docm.height()) { myPage++; Trading(myPage); } });}//小数保留两位function DecimaltoFixed(num) { return (parseFloat(num) * 100).toFixed(2);}'; sHtml += '
'; sHtml += ' '; sHtml += '- '; sHtml += '
'; sHtml += ''; sHtml += '' + datas.stockName + '
' + datas.stockCode + '
'; sHtml += '' + datas.oprResult + '
' + datas.oprTime.substring(0, datas.oprTime.lastIndexOf(':')) + '
'; //只有清仓才判断盈利还是亏损 if (datas.earnFare !== '' && Number(datas.earnFare) > 0) { sHtml += '' + datas.costPrice + '
' + datas.oprDate + '
'; } else if (datas.earnFare !== '' && Number(datas.earnFare) < 0) { sHtml += '' + DecimaltoFixed(datas.beforePosition) + '' + DecimaltoFixed(datas.afterPosition) + '
'; sHtml += '盈利' + DecimaltoFixed(datas.earnFare) + '%
'; } else { sHtml += '' + DecimaltoFixed(datas.beforePosition) + '' + DecimaltoFixed(datas.afterPosition) + '
'; sHtml += '亏损' + DecimaltoFixed(datas.earnFare) + '%
' + DecimaltoFixed(datas.beforePosition) + '' + DecimaltoFixed(datas.afterPosition) + '
'; } sHtml += ''; sHtml += ''; sHtml += ''; sHtml += ''; sHtml += '操作理由
'; if (datas.reason !== null) { sHtml += '' + datas.reason + '
'; } else { sHtml += '无
'; } sHtml += '
html
最新调仓