talk_room.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. var RoomList = function(ajaxData,append_el,load_state_el,dropload){
  2. if(dropload){
  3. var _self = this;
  4. $(window).on('scroll',function(){
  5. clearTimeout(this.timer);
  6. this.timer = setTimeout(function(){
  7. var scrollTop = $(this).scrollTop();
  8. var scrollHeight = $(document).height();
  9. var windowHeight = $(this).height();
  10. if(scrollTop + windowHeight == scrollHeight){
  11. _self.getData();
  12. }
  13. },500);
  14. });
  15. }
  16. this.append_el = append_el;
  17. this.load_state_el = load_state_el;
  18. this.curpage = 1;
  19. this.hasmore = true;
  20. this.init = function () {
  21. this.getData();
  22. };
  23. this.droploadCallback = function(res){};
  24. this.getData = function(){
  25. var _self = this;
  26. if(!_self.hasmore) return;
  27. $.showLoading();
  28. $.get("/mobile/index.php", {
  29. act: ajaxData.act,
  30. op: ajaxData.op,
  31. room_id: getHrefArguments("talk_id"),
  32. client_type: "ajax",
  33. curpage: _self.curpage
  34. }, function (res) {
  35. $.hideLoading();
  36. _self.droploadCallback(res);
  37. });
  38. }
  39. };
  40. var RoomListHTML = function(datas){
  41. this.listDatas = datas;
  42. this.endHTML = function(id){
  43. var endHTML = "<div class=\"weui-loadmore weui-loadmore_line\">\n" +
  44. " <span class=\"weui-loadmore__tips\">我是有底线的</span>\n" +
  45. "</div>";
  46. $(id).empty().append(endHTML);
  47. };
  48. this.loadHTML = function(id){
  49. var loadHTML = "<div class=\"weui-loadmore\">\n" +
  50. " <i class=\"weui-loading\"></i>\n" +
  51. " <span class=\"weui-loadmore__tips\">正在加载</span>\n" +
  52. "</div>";
  53. $(id).empty().append(loadHTML);
  54. };
  55. };