group_chat.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <template>
  2. <view class="page">
  3. <uni-list v-if="list.length">
  4. <!--<uni-list-item :title="value.show_name"-->
  5. <!--:show-arrow="false"-->
  6. <!--:note="msgHandle(value.last_msg + '')"-->
  7. <!--:show-badge="false"-->
  8. <!--:badge-type="'default'"-->
  9. <!--:thumb="staticPhoto + value.photo_path"-->
  10. <!--v-for="(value,key) in list"-->
  11. <!--:key="key"-->
  12. <!--@tap="goPath(value.list_id)"-->
  13. <!--v-if="value.type == 1"/>-->
  14. <view class="uni-media-list btm_border" v-for="(value,key) in list" v-if="value.type == 1"
  15. @tap="goPath(value.list_id)">
  16. <view class="uni-media-list-logo">
  17. <image :src="staticPhoto + value.photo_path" class="img-icon" @error="imageError"
  18. :data-index="key" />
  19. </view>
  20. <view>
  21. <view class="text-hidden">{{value.show_name}}</view>
  22. <view class=" content">{{msgHandle(value.last_msg + '')}}</view>
  23. </view>
  24. </view>
  25. </uni-list>
  26. </view>
  27. </template>
  28. <script>
  29. import uniList from '../../components/uni-ui/uni-list/uni-list.vue';
  30. import uniListItem from '../../components/uni-ui/uni-list-item/uni-list-item.vue';
  31. import _get from '../../common/_get';
  32. import _hook from '../../common/_hook';
  33. import _data from '../../common/_data';
  34. export default {
  35. components: {
  36. uniList,
  37. uniListItem,
  38. },
  39. data() {
  40. return {
  41. list: [],
  42. }
  43. },
  44. onShow() {
  45. _hook.routeSonHook();
  46. let _this = this;
  47. _get.getGroupChatList({
  48. type: 1
  49. }, function(ret) {
  50. console.log(ret)
  51. _this.list = ret
  52. });
  53. },
  54. onLoad() {
  55. },
  56. onUnload() {
  57. uni.$off('data_chat_list');
  58. },
  59. computed: {
  60. staticPhoto() {
  61. return _data.staticPhoto();
  62. },
  63. },
  64. methods: {
  65. goPath(list_id) {
  66. uni.navigateTo({
  67. url: '../chat/message?list_id=' + list_id,
  68. });
  69. },
  70. imageError(e) {
  71. console.log("图片加载失败!", e.detail);
  72. let index = e.currentTarget.dataset.index
  73. console.log(e.currentTarget.dataset.index)
  74. //替换index对应的图片
  75. console.log(this.list[index].photo_path)
  76. this.list[index].photo_path = '/default_photo_path.png';
  77. },
  78. msgHandle(msg) {
  79. return msg.replace(/&lt;/g, '<').substr(0, 20);
  80. },
  81. },
  82. watch: {
  83. },
  84. }
  85. </script>
  86. <style scoped>
  87. .text-hidden {
  88. width: 500rpx; //固定宽度
  89. overflow: hidden;
  90. text-overflow: ellipsis;
  91. white-space: nowrap;
  92. }
  93. .img-icon {
  94. width: 85upx;
  95. height: 85upx;
  96. border-radius: 10upx;
  97. }
  98. .uni-list-cell-navigate {
  99. padding: 0;
  100. }
  101. .content {
  102. color: #7D7D72;
  103. font-size: 28upx;
  104. }
  105. .badge-text {
  106. background-color: #EEEEEE;
  107. padding: 3upx 10upx 0 10upx;
  108. border-radius: 15upx;
  109. font-size: 22upx;
  110. }
  111. .btm_border {
  112. position: relative;
  113. display: flex;
  114. flex-direction: row;
  115. justify-content: flex-start;
  116. align-items: flex-start;
  117. }
  118. .btm_border::after {
  119. position: absolute;
  120. z-index: 3;
  121. right: 0;
  122. bottom: 0;
  123. left: 115upx;
  124. height: 1px;
  125. content: '';
  126. -webkit-transform: scaleY(.5);
  127. transform: scaleY(.5);
  128. background-color: #c8c7cc;
  129. }
  130. </style>