ChatList.vue 3.6 KB

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