fenxiao_to_accounts_list2.js 2.6 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/unIncomeOrderCast3?dates=' + new Date().getTime(), {
  17. data: {
  18. "pageSize": pagesize,
  19. "pageNumber": pageNumber,
  20. "openid": getParam("openid")
  21. },
  22. dataType: 'json',
  23. type: 'post',
  24. timeout: 15000,
  25. xhrFields: {
  26. withCredentials: true
  27. },
  28. crossDomain: true,
  29. success: function(dt) {
  30. if(dt.isRedirect) {
  31. location.href = dt.redirectURL;
  32. } else {
  33. if(dt.status) {
  34. var chanpin_data = [];
  35. if(dt.data.list != null) {
  36. chanpin_data = dt.data.list
  37. }
  38. document.querySelector("#accounts").innerHTML = dt.data.salesNumber;
  39. mui('#pullrefresh').pullRefresh().endPullupToRefresh(chanpin_data.length < pagesize);
  40. var table = document.body.querySelector('.my-tab-view-pull');
  41. mui(chanpin_data).each(function(index) {
  42. var li = document.createElement('li');
  43. li.className = 'mui-table-view-cell ft-12';
  44. /*li.innerHTML = '<table class="my-dl-tb-order"><tr><td class="mui-text-left">' + this.strDate.substr(0, this.strDate.length - 2) + '</td><td>' + this.num + '台</td></tr></table>';*/
  45. li.innerHTML = '<table class="my-dl-tb-order"><tr><td class="mui-text-left">' + decodeURI(this.name) + '</td><td>' + this.num + '台</td></tr></table>';
  46. table.appendChild(li)
  47. })
  48. } else {
  49. mui.confirm(dt.message, '提示', btnArray,
  50. function(e) {
  51. if(e.index == 1) {}
  52. })
  53. }
  54. }
  55. },
  56. error: function(xhr, type, errorThrown) {
  57. console.log(xhr)
  58. }
  59. })
  60. };
  61. mui.ready(function() {
  62. mui('#pullrefresh').pullRefresh().pullupLoading();
  63. getCartNum();
  64. document.querySelector('.loading-bg').style.display = 'none'
  65. });
  66. var addTimer = function() {
  67. var list = [],
  68. interval;
  69. return function(id, time) {
  70. if(!interval) {
  71. interval = setInterval(go, 1000)
  72. }
  73. list.push({
  74. ele: document.getElementById(id),
  75. time: time
  76. })
  77. };
  78. function go() {
  79. for(var i = 0; i < list.length; i += 1) {
  80. list[i].ele.innerHTML = getTimerString(list[i].time ? list[i].time -= 1 : 0);
  81. if(!list[i].time) {
  82. list.splice(i--, 1)
  83. }
  84. }
  85. }
  86. function getTimerString(time) {
  87. d = Math.floor(time / 86400),
  88. h = Math.floor((time % 86400) / 3600),
  89. m = Math.floor(((time % 86400) % 3600) / 60),
  90. s = Math.floor(((time % 86400) % 3600) % 60);
  91. if(time > 0) {
  92. return "剩余" + d + "天" + h + ":" + m + ":" + s
  93. } else {
  94. return "即将入账"
  95. }
  96. }
  97. }();