list.vue 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <template>
  2. <view>
  3. <uni-nav-bar statusBar backgroundColor="transparent" fixed title="全部群聊" left-icon="left" @clickLeft="utils.navigateBack()" />
  4. <view class="lists">
  5. <view class="item fx-r fx-bc" v-for="item in data" @tap="tapOpen" :data-url="'/pages/chat/chatGroup?groupId=' + item.group_id">
  6. <view class="img">
  7. <image :src="utils.getAvatar(item.img,'group_chat')" mode="aspectFill"></image>
  8. </view>
  9. <view class="nickname">{{item.name}}</view>
  10. </view>
  11. </view>
  12. <view class="loading fx-r fx-ac fx-bc" v-if="page.isFrite && !page.isFoot">
  13. <image src="/static/img/xloading.png"></image>
  14. <text>正在载入更多...</text>
  15. </view>
  16. <view class="loading complete" :hidden="!page.isFoot">已加载全部</view>
  17. </view>
  18. </template>
  19. <style lang="scss">
  20. page{background:#F5F5F5}
  21. .lists{}
  22. .lists .item{background: #fff;margin-top: 10px;padding: 10px;}
  23. .lists .item image{width: 40px;height: 40px;border-radius: 6px;}
  24. .lists .item .nickname{margin-left: 10px;}
  25. </style>
  26. <script>
  27. import {mapState,mapMutations } from 'vuex';
  28. export default {
  29. computed: mapState(['user']),
  30. data() {
  31. return {
  32. data: [],
  33. page:{
  34. isFirst:false,
  35. isLoad:false,
  36. isFoot:false,
  37. page:1
  38. }
  39. }
  40. },
  41. onLoad(option) {
  42. //获取订单
  43. this.getData();
  44. },
  45. onReachBottom() {
  46. if(this.page.isFoot || this.page.isLoad) {
  47. return;
  48. }
  49. this.page.page ++;
  50. this.getData();
  51. },
  52. methods: {
  53. getData:function(isPull = false){
  54. if(this.page.isLoad) return;
  55. this.page.isLoad = true;
  56. if(isPull) {
  57. this.page.page = 1;
  58. this.page.isLoad = false;
  59. this.page.isFoot = false;
  60. }
  61. uni.showLoading({ title: '获取数据中..' });
  62. var post = {};
  63. post.page = this.page.page;
  64. this
  65. .request
  66. .post("GroupList",post)
  67. .then(res => {
  68. uni.hideLoading();
  69. this.page.isFirst = true;
  70. this.page.isLoad = false;
  71. if(isPull) {
  72. this.data = res.data.list;
  73. } else {
  74. this.data = this.data.concat(res.data.list);
  75. }
  76. //是否到底
  77. if(res.data.list.length != res.data.pageSize) {
  78. this.page.isFoot = true;
  79. }
  80. })
  81. .catch(res=>{
  82. uni.hideLoading();
  83. uni.showModal({title: '系统提示',content: '加载失败,返回在尝试',showCancel: false});
  84. });
  85. },
  86. /**
  87. * 打开Open
  88. * @param {Object} ev
  89. */
  90. tapOpen:function(ev){
  91. let url = ev.currentTarget.dataset.url;
  92. this.utils.navigateTo(url);
  93. }
  94. }
  95. }
  96. </script>