msgView.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <template>
  2. <view>
  3. <view class="item fx-r fx-bc" @tap="tapItem(item)" v-for="(item,index) in data">
  4. <image :src="item.img == '' ? '/static/chat/user-avatar.png' : item.img" mode="aspectFill"></image>
  5. <view class="info fx-h fx-ac">
  6. <view class="fx-r">
  7. <view class="nickname">{{item.name}}</view>
  8. <view class="fx-g1"></view>
  9. <view class="iitem-time">{{utils.date('Y-m-d H:i:s',item.time)}}</view>
  10. </view>
  11. <rich-text class="title" :nodes="item.data"></rich-text>
  12. </view>
  13. </view>
  14. <view class="loading fx-r fx-ac fx-bc" v-if="page.isFrite && !page.isFoot">
  15. <image src="/static/chat/xloading.png"></image>
  16. <text>正在载入更多...</text>
  17. </view>
  18. <view class="loading complete" :hidden="!page.isFoot">已加载全部</view>
  19. </view>
  20. </template>
  21. <style>
  22. .item{background: #fff;padding:0 10px;position: relative;}
  23. .item:active{background: #f1f1f1;}
  24. .item image{width: 40px;height: 40px;border-radius: 50%;}
  25. .item .info{width: calc(100% - 70px);padding: 10px 0;margin-left: 10px;font-size: 14px;color:#787878;border-bottom: 1px solid #f1f1f1;}
  26. .item .info .title{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;overflow:hidden;}
  27. .item .flg{background: #ff5857;width: 20px;height: 20px;border-radius: 50%;font-size: 10px;text-align: center;line-height: 20px;color: #fff;}
  28. .item:last-child .info{border-bottom: 0;}
  29. .iitem-time{font-size: 12px;}
  30. </style>
  31. <script>
  32. import {mapState,mapMutations } from 'vuex';
  33. export default {
  34. data() {
  35. return {
  36. usercode : "",
  37. groupId : "",
  38. data : [],
  39. page:{
  40. isFirst:false,
  41. isLoad:false,
  42. isFoot:false,
  43. page:1
  44. }
  45. }
  46. },
  47. onLoad(option){
  48. this.groupId = option.groupId || "";
  49. this.usercode = option.usercode || "";
  50. this.getData();
  51. },
  52. onReachBottom() {
  53. if(this.page.isFoot || this.page.isLoad) {
  54. return;
  55. }
  56. this.page.page ++;
  57. this.getData();
  58. },
  59. methods: {
  60. getData:function(isPull = false){
  61. if(this.page.isLoad) return;
  62. this.page.isLoad = true;
  63. if(isPull) {
  64. this.page.page = 1;
  65. this.page.isLoad = false;
  66. this.page.isFoot = false;
  67. }
  68. uni.showLoading({ title: '获取数据中..' });
  69. var post = {};
  70. post.page = this.page.page;
  71. post.usercode = this.usercode;
  72. post.groupId = this.groupId;
  73. this
  74. .request
  75. .post("chatGroupUserMsg",post)
  76. .then(res => {
  77. uni.hideLoading();
  78. this.page.isFirst = true;
  79. this.page.isLoad = false;
  80. if(isPull) {
  81. this.data = res.data.list;
  82. } else {
  83. this.data = this.data.concat(res.data.list);
  84. }
  85. //是否到底
  86. if(res.data.list.length != res.data.pageSize) {
  87. this.page.isFoot = true;
  88. }
  89. })
  90. .catch(res=>{
  91. console.log(res);
  92. uni.hideLoading();
  93. uni.showModal({title: '系统提示',content: '加载失败,返回在尝试',showCancel: false});
  94. });
  95. },
  96. tapItem:function(item){
  97. uni.navigateTo({
  98. url:"../../chatGroup?groupId=" + this.groupId + "&usercode=&msgId=" + item.msgId + "&nid=" + item.nid
  99. })
  100. }
  101. }
  102. }
  103. </script>
  104. <style>
  105. </style>