tuangou.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. function tuangou_init(tt) {
  2. $('#tg_publish').on('click', function () {
  3. window.location.href = "/yeweihui/tgPublish.html?userId=" + $('#userId').val();
  4. });
  5. $.ajax({
  6. url: '/yeweihui/tuangou/list/query.json',
  7. type: 'post',
  8. data: {
  9. userId: $('#userId').val()
  10. },
  11. success: function (data) {
  12. if (data.success) {
  13. makeList(data.data);
  14. }
  15. else {
  16. $.alert("操作失败");
  17. }
  18. },
  19. error: function () {
  20. $.alert("网络异常");
  21. }
  22. });
  23. $.ajax({
  24. url: '/yeweihui/tuangou/mylist/query.json',
  25. type: 'post',
  26. data: {
  27. userId: $('#userId').val()
  28. },
  29. success: function (data) {
  30. if (data.success) {
  31. makeMyPublishList(data.data);
  32. }
  33. else {
  34. $.alert("操作失败");
  35. }
  36. },
  37. error: function () {
  38. $.alert("网络异常");
  39. }
  40. });
  41. };
  42. function makeList(list) {
  43. $('#tg_list1').empty();
  44. if (list == undefined || list.length <= 0) {
  45. $('#tg_list1').append('<div class="weui-loadmore weui-loadmore_line">\n' +
  46. ' <span class="weui-loadmore__tips">暂无数据</span>\n' +
  47. '</div>');
  48. return;
  49. }
  50. for (let i = 0; i < list.length; i++) {
  51. let item = list[i];
  52. let status = '';
  53. if (item.tgStatus == 1) {
  54. status = "在团";
  55. }
  56. else if (item.tgStatus == 2) {
  57. status = "发货";
  58. }
  59. else if (item.tgStatus == 3) {
  60. status = "完成";
  61. }
  62. else if (item.tgStatus == 4) {
  63. status = "取消";
  64. }
  65. $('#tg_list1').append($('<a href="javascript:tgItemSelect(' + "'" + item.jmId + "'" + ');" style="color: grey;">\n' +
  66. ' <div style="display: flex; flex-direction: row; text-align: center; font-size: small; line-height: 5vh;">\n' +
  67. ' <div style="width: 40%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">' + item.tgTitle + '</div>\n' +
  68. ' <div style="width: 15%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">' + item.currentNum + '/' + item.tgMinNum + '</div>\n' +
  69. ' <div style="width: 30%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">' + item.tgEndTime.toString() + '</div>\n' +
  70. ' <div style="width: 15%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">' + status + '</div>\n' +
  71. ' </div>\n' +
  72. ' </a>'));
  73. }
  74. }
  75. function makeMyPublishList(list) {
  76. $('#tg_list2').empty();
  77. if (list == undefined || list.length <= 0) {
  78. $('#tg_list2').append('<div class="weui-loadmore weui-loadmore_line">\n' +
  79. ' <span class="weui-loadmore__tips">暂无数据</span>\n' +
  80. '</div>');
  81. return;
  82. }
  83. for (let i = 0; i < list.length; i++) {
  84. let item = list[i];
  85. let status = '';
  86. if (item.tgStatus == 1) {
  87. status = "在团";
  88. }
  89. else if (item.tgStatus == 2) {
  90. status = "发货";
  91. }
  92. else if (item.tgStatus == 3) {
  93. status = "完成";
  94. }
  95. else if (item.tgStatus == 4) {
  96. status = "取消";
  97. }
  98. $('#tg_list2').append($('<a href="javascript:tgMyItemSelect(' + "'" + item.jmId + "'" + ');" style="color: grey;">\n' +
  99. ' <div style="display: flex; flex-direction: row; text-align: center; font-size: small; line-height: 5vh;">\n' +
  100. ' <div style="width: 40%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">' + item.tgTitle + '</div>\n' +
  101. ' <div style="width: 15%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">' + item.currentNum + '/' + item.tgMinNum + '</div>\n' +
  102. ' <div style="width: 30%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">' + item.tgEndTime.toString() + '</div>\n' +
  103. ' <div style="width: 15%; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">' + status + '</div>\n' +
  104. ' </div>\n' +
  105. ' </a>'));
  106. }
  107. }
  108. function tgItemSelect(jmId) {
  109. console.log(jmId);
  110. }
  111. function tgMyItemSelect(jmId) {
  112. console.log(jmId);
  113. }