communicate.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <template>
  2. <layout-page class="ss-m-x-15">
  3. <view class="box" v-for="item in items" :key="item.id" @tap="handleTo(item)">
  4. <view class="box-header">
  5. <image
  6. class="enterAvatar"
  7. :src="item.headers"
  8. ></image>
  9. </view>
  10. <view class="box-content">
  11. <view class="box-content-names">
  12. <view class="name">{{ item.name }}</view>
  13. <view class="time">{{ item.updateTime }}</view>
  14. </view>
  15. <view class="box-content-text">{{ item.history }}</view>
  16. </view>
  17. </view>
  18. <image
  19. v-if=" items.length===0 "
  20. src="https://minio.citupro.com/dev/static/nodata.png"
  21. mode="widthFix"
  22. style="width: 100vw;height: 100vh;">
  23. </image>
  24. </layout-page>
  25. </template>
  26. <script setup>
  27. import { ref, watch } from 'vue'
  28. import layoutPage from '@/layout'
  29. import { getAccessToken } from '@/utils/request'
  30. import { showAuthModal } from '@/hooks/useModal'
  31. import { getConversationSync } from '@/api/common'
  32. import { onShow } from '@dcloudio/uni-app'
  33. import { userStore } from '@/store/user'
  34. const useUserStore = userStore()
  35. const items = ref([])
  36. watch(() => useUserStore.isLogin, (newVal, oldVal) => {
  37. if (useUserStore.isLogin) {
  38. // 监听登录状态
  39. console.log('重新登录了')
  40. init()
  41. }
  42. })
  43. onShow(() => {
  44. init()
  45. })
  46. const handleTo = (item) => {
  47. uni.navigateTo({
  48. url: `/pagesA/chart/index?id=${item.id}&name=${item.name}`
  49. })
  50. }
  51. // if (!getAccessToken()) {
  52. // uni.showToast({
  53. // title: '请先登录',
  54. // icon: 'none'
  55. // })
  56. // showAuthModal()
  57. // return
  58. // }
  59. async function init () {
  60. try {
  61. const resp = await getConversationSync({ msg_count: 1 })
  62. if (!resp) {
  63. return
  64. }
  65. console.log(resp)
  66. } catch (error) {
  67. }
  68. }
  69. </script>
  70. <style scoped lang="scss">
  71. .box {
  72. height: 130rpx;
  73. padding: 20rpx;
  74. box-sizing: border-box;
  75. display: flex;
  76. border-bottom: 2rpx solid #eee;
  77. &-header {
  78. width: 120rpx;
  79. height: 100%;
  80. }
  81. &-content {
  82. flex: 1;
  83. width: 0;
  84. display: flex;
  85. flex-direction: column;
  86. justify-content: space-between;
  87. &-names {
  88. display: flex;
  89. justify-content: space-between;
  90. .name {
  91. flex: 1;
  92. overflow: hidden;
  93. white-space: nowrap;
  94. text-overflow: ellipsis;
  95. }
  96. .time {
  97. color: #999;
  98. font-size: .85em;
  99. }
  100. }
  101. &-text {
  102. color: #999;
  103. font-size: .85em;
  104. overflow: hidden;
  105. white-space: nowrap;
  106. text-overflow: ellipsis;
  107. }
  108. }
  109. }
  110. .enterAvatar{
  111. width: 80rpx;
  112. height: 80rpx;
  113. border-radius: 50%;
  114. margin: 0 auto;
  115. }
  116. </style>