fenxiao_to_accounts_list.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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/unIncomeOrderCast2?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. console.log(dt);
  34. if(dt.status) {
  35. var chanpin_data = [];
  36. if(dt.data.list != null) {
  37. chanpin_data = dt.data.list
  38. }
  39. document.querySelector("#accounts").innerHTML = accDiv(dt.data.unIncomeMoney, 100);
  40. mui('#pullrefresh').pullRefresh().endPullupToRefresh(chanpin_data.length < pagesize);
  41. var table = document.body.querySelector('.my-tab-view-pull');
  42. mui(chanpin_data).each(function(index) {
  43. var li = document.createElement('li');
  44. if(this.roleName != "门店" && this.roleName != "母婴店") {
  45. li.setAttribute("href", base_path + "/drp/UnIncomeOrderList?openid=" + this.openid)
  46. }
  47. li.className = 'mui-table-view-cell ft-12';
  48. li.innerHTML = '<table class="my-dl-tb-order"><tr><td style="width:70px;"><img class="wh-50" src="' + this.img + '"></td><td>' + decodeURI(this.name) + '</td><td class="mui-text-left" style="color:blue">' + this.roleName + '</td><td>¥' + accDiv(this.amount, 100) + '元</td></tr></table>';
  49. table.appendChild(li);
  50. });
  51. mui('body').on('tap', '.my-tab-view-pull .mui-table-view-cell', function() {
  52. var ref = this.getAttribute("href");
  53. if(ref != null) {
  54. location.href = this.getAttribute("href")
  55. }
  56. })
  57. } else {
  58. mui.confirm(dt.message, '提示', btnArray, function(e) {
  59. if(e.index == 1) {}
  60. })
  61. }
  62. }
  63. },
  64. error: function(xhr, type, errorThrown) {
  65. errorfn(xhr)
  66. }
  67. })
  68. };
  69. mui.ready(function() {
  70. mui('#pullrefresh').pullRefresh().pullupLoading();
  71. getCartNum();
  72. document.querySelector('.loading-bg').style.display = 'none'
  73. });
  74. var addTimer = function() {
  75. var list = [],
  76. interval;
  77. return function(id, time) {
  78. if(!interval) {
  79. interval = setInterval(go, 1000)
  80. }
  81. list.push({
  82. ele: document.getElementById(id),
  83. time: time
  84. })
  85. };
  86. function go() {
  87. for(var i = 0; i < list.length; i += 1) {
  88. list[i].ele.innerHTML = getTimerString(list[i].time ? list[i].time -= 1 : 0);
  89. if(!list[i].time) {
  90. list.splice(i--, 1)
  91. }
  92. }
  93. }
  94. function getTimerString(time) {
  95. 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);
  96. if(time > 0) {
  97. return "剩余" + d + "天" + h + ":" + m + ":" + s
  98. } else {
  99. return "即将入账"
  100. }
  101. }
  102. }();