ChatList.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <template><page-meta :root-font-size="fontSize+'px'"></page-meta>
  2. <member-base :show="false" ><view class="div container">
  3. <view class="div common-header-wrap">
  4. <view :style="'height:'+navHeight+'px'"></view>
  5. <view class="common-header-holder"></view>
  6. <view class="common-header-fixed">
  7. <title-header />
  8. <uni-nav-bar title="最近消息" class="common-header" left-icon="back" @clickLeft="goBack()">
  9. </uni-nav-bar>
  10. </view>
  11. </view>
  12. <view class="div">
  13. <view class="ul dstouch-message-list">
  14. <view class="li" v-for="(item,index) in list" :key="index">
  15. <view class="a" @click="goNavigate('/pages/member/chat/ChatInfo',{t_id:item.u_id,t_name:item.u_name})">
  16. <view class="div avatar">
  17. <image mode="aspectFit" class="img" :src="item.avatar+'?'+time">
  18. <sup v-if="item.r_state == 2"></sup>
  19. </view>
  20. <view class="dl">
  21. <view class="dt">{{item.u_name}}</view>
  22. <view class="dd">{{item.message}}</view>
  23. </view>
  24. <time>{{item.time}}</time>
  25. </view>
  26. </view>
  27. </view>
  28. </view>
  29. </view></member-base>
  30. </template>
  31. <script>
  32. import {getFontSize} from '@/util/common'
  33. import TitleHeader from '../../TitleHeader'
  34. import { urlencode } from '@/util/common'
  35. import MemberBase from '../MemberBase'
  36. import { getChatList } from '../../../api/memberInstantMessage'
  37. export default {
  38. mounted(){
  39. // #ifdef MP-WEIXIN
  40. this.navHeight = uni.getMenuButtonBoundingClientRect().top
  41. // #endif
  42. },
  43. computed:{
  44. fontSize(){
  45. return getFontSize()
  46. },
  47. },
  48. data(){
  49. return {
  50. navHeight: 0,
  51. time:'',
  52. list: false
  53. }
  54. },
  55. components:{
  56. TitleHeader,
  57. MemberBase,
  58. },
  59. created () {
  60. this.time = new Date().getTime();
  61. uni.showLoading({ title: '加载中' });
  62. getChatList().then(res => {
  63. this.list = res.result.list
  64. uni.hideLoading()
  65. }).catch(function (error) {
  66. uni.hideLoading()
  67. uni.showToast({icon:'none',title: error.message})
  68. })
  69. },
  70. watch: {
  71. },
  72. methods:{
  73. goNavigate(path,query=false){
  74. uni.navigateTo({url:path+(query?('?'+urlencode(query)):'')})
  75. },
  76. goBack(){uni.navigateBack({delta:1})},
  77. }
  78. }
  79. </script>
  80. <style scoped lang="scss">
  81. .dstouch-message-list { background-color: #FFF;}
  82. .dstouch-message-list .li { position: relative; z-index: 1; height: 3rem; border-bottom: solid 0.05rem #EEE; margin: 0 $pageSpace 0 3.2rem;}
  83. .dstouch-message-list .li .avatar { position: absolute; z-index: 1; top: 0.4rem; bottom: 0.4rem; left: -2.7rem; display: block; width: 2.2rem; height: 2.2rem; background-color: #EEE; border-radius: 100%;}
  84. .dstouch-message-list .li .avatar .img { width: 100%; height: 100%; border-radius: 100%;}
  85. .dstouch-message-list .li .avatar sup { position: absolute; z-index: 1; top: 0; right: 0; width: 0.4rem; height: 0.4rem; background-color: #f23030; border-radius: 100%;}
  86. .dstouch-message-list .li .dl { display: block; padding: 0.4rem 0;}
  87. .dstouch-message-list .li .dt { display: block; height: 1.2rem; font-size:$subFontSize; line-height: 1.2rem; color: #111;}
  88. .dstouch-message-list .li .dd { display: block; height: 1rem; font-size:$fontSize; line-height: 1rem; color: #666; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;}
  89. .dstouch-message-list .li time { position: absolute; z-index: 1; top: 0.4rem; right: 0; font-size:$h6; line-height: 0.9rem; color: #BBB;}
  90. </style>