fenxiao_to_transfer_accounts_list.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. mui.init({
  2. pullRefresh: {
  3. container: '#pullrefresh',
  4. down: {},
  5. up: {
  6. contentrefresh: '正在加载...',
  7. callback: pullupRefresh
  8. }
  9. }
  10. });
  11. var pageNumber = 0,
  12. pagesize = 10;
  13. function pullupRefresh() {
  14. pageNumber += 1;
  15. var btnArray = ['否', '是'];
  16. $.ajax(base_path + '/rebackStatic/unIncomeOrderCast?dates=' + new Date().getTime(), {
  17. data: {
  18. "pageSize": pagesize,
  19. "pageNumber": pageNumber
  20. },
  21. dataType: 'json',
  22. type: 'post',
  23. timeout: 15000,
  24. xhrFields: {
  25. withCredentials: true
  26. },
  27. crossDomain: true,
  28. success: function(dt) {
  29. if(dt.isRedirect) {
  30. location.href = dt.redirectURL;
  31. } else {
  32. if(dt.status) {
  33. var chanpin_data = [];
  34. if(dt.data.list != null) {
  35. chanpin_data = dt.data.list
  36. }
  37. document.querySelector("#accounts").innerHTML = accDiv(dt.data.unIncomeMoney, 100);
  38. mui('#pullrefresh').pullRefresh().endPullupToRefresh(chanpin_data.length < pagesize);
  39. var table = document.body.querySelector('.my-tab-view-pull');
  40. mui(chanpin_data).each(function(index) {
  41. var li = document.createElement('li');
  42. li.className = 'mui-table-view-cell ft-12';
  43. if(this.strDate == '未发货') {
  44. li.innerHTML = '<table class="my-dl-tb-order"><tr><td><img class="wh-50" src="' + this.img + '"></td><td class="mui-text-left">' + decodeURI(this.name) + ':¥' + accDiv(this.amount, 100) + '元</td><td><span>未发货</span></td></tr></table>';
  45. table.appendChild(li)
  46. } else {
  47. li.innerHTML = '<table class="my-dl-tb-order"><tr><td><img class="wh-50" src="' + this.img + '"></td><td class="mui-text-left">' + decodeURI(this.name) + ':¥' + accDiv(this.amount, 100) + '元</td><td><span id="timer' + ((pagesize * pageNumber) + index) + '"></span></td></tr></table>';
  48. table.appendChild(li);
  49. addTimer('timer' + ((pagesize * pageNumber) + index) + '', this.strDate / 1000)
  50. }
  51. })
  52. } else {
  53. mui.confirm(dt.message, '提示', btnArray, function(e) {
  54. if(e.index == 1) {}
  55. })
  56. }
  57. }
  58. },
  59. error: function(xhr, type, errorThrown) {
  60. console.log(xhr)
  61. }
  62. })
  63. };
  64. mui.ready(function() {
  65. mui('#pullrefresh').pullRefresh().pullupLoading();
  66. getCartNum();
  67. document.querySelector('.loading-bg').style.display = 'none'
  68. });
  69. var addTimer = function() {
  70. var list = [],
  71. interval;
  72. return function(id, time) {
  73. if(!interval) {
  74. interval = setInterval(go, 1000)
  75. }
  76. list.push({
  77. ele: document.getElementById(id),
  78. time: time
  79. })
  80. };
  81. function go() {
  82. for(var i = 0; i < list.length; i += 1) {
  83. list[i].ele.innerHTML = getTimerString(list[i].time ? list[i].time -= 1 : 0);
  84. if(!list[i].time) {
  85. list.splice(i--, 1)
  86. }
  87. }
  88. }
  89. function getTimerString(time) {
  90. d = Math.floor(time / 86400), h = Math.floor((time % 86400) / 3600), m = Math.floor(((time % 86400) % 3600) / 60), s = Math.floor(((time % 86400) % 3600) % 60);
  91. if(time > 0) {
  92. return "剩余" + d + "天" + h + ":" + m + ":" + s
  93. } else {
  94. return "即将入账"
  95. }
  96. }
  97. }();