list.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <template>
  2. <view>
  3. <view class="chatlist">
  4. <view class="chatlist-item" v-for="(item, i) in dataList" :key="item.roleId" @click="handleDetail(item)">
  5. <image class="chatlist-head" :src="item.roleAvatar||'https://fs-1319721001.cos.ap-chongqing.myqcloud.com/fs/20240229/be32b8d2ae9f497297d10327656bb43c.png'" mode="aspectFill"></image>
  6. <view style="overflow: hidden;">
  7. <view class="chatlist-namebox">
  8. <view class="chatlist-tag" v-for="(tag,i) in getTag(item.roleTag)" :key="i">{{tag}}</view>
  9. <view class="chatlist-name textOne">{{item.roleName}}</view>
  10. </view>
  11. <view class="chatlist-msg textOne">{{item.lastContent || item.welcomeMessage}}</view>
  12. </view>
  13. </view>
  14. </view>
  15. </view>
  16. </template>
  17. <script>
  18. import { getAllRolesListByUserId} from "@/api/ai.js"
  19. export default {
  20. data() {
  21. return {
  22. dataList: []
  23. }
  24. },
  25. computed: {
  26. getTag(){
  27. return (tag)=>{
  28. if (tag) {
  29. return tag.split(',')
  30. } else {
  31. return []
  32. }
  33. }
  34. }
  35. },
  36. onShow() {
  37. if(this.$isLogin()) {
  38. const user = this.$getUserInfo()
  39. const userId = user.userId || ''
  40. this.getList(userId)
  41. } else {
  42. this.$showLoginPage()
  43. }
  44. },
  45. methods: {
  46. handleDetail(item) {
  47. const sessionId = item.sessionId ||''
  48. uni.navigateTo({
  49. url: '/pages/ai/chat?roleId='+item.roleId+'&roleName='+item.roleName+'&sessionId='+sessionId
  50. })
  51. },
  52. getList(userId) {
  53. getAllRolesListByUserId({userId:userId}).then(res=>{
  54. if(res.code == 200) {
  55. this.dataList = res.data
  56. }
  57. })
  58. }
  59. }
  60. }
  61. </script>
  62. <style scoped lang="scss">
  63. @mixin u-flex($flexD, $alignI, $justifyC) {
  64. display: flex;
  65. flex-direction: $flexD;
  66. align-items: $alignI;
  67. justify-content: $justifyC;
  68. }
  69. .search-cont{
  70. width: 100%;
  71. padding: 16rpx 30rpx;
  72. background-color: #FFFFFF;
  73. box-sizing: border-box;
  74. .inner{
  75. box-sizing: border-box;
  76. width: 100%;
  77. height: 72rpx;
  78. background: #F7F7F7;
  79. border-radius: 36rpx;
  80. display: flex;
  81. align-items: center;
  82. padding: 0 30rpx;
  83. .icon-search{
  84. width: 28rpx;
  85. height: 28rpx;
  86. margin-right: 20rpx;
  87. }
  88. input{
  89. height: 60rpx;
  90. line-height: 60rpx;
  91. flex: 1;
  92. }
  93. }
  94. }
  95. .chatlist {
  96. width: 100%;
  97. box-sizing: border-box;
  98. font-family: PingFang SC, PingFang SC;
  99. font-weight: 400;
  100. font-size: 28rpx;
  101. color: #999999;
  102. background-color: #fff;
  103. &-item {
  104. padding: 20rpx 32rpx;
  105. box-sizing: border-box;
  106. overflow: hidden;
  107. @include u-flex(row,center,flex-start);
  108. }
  109. &-head {
  110. flex-shrink: 0;
  111. width: 96rpx;
  112. height: 96rpx;
  113. margin-right: 24rpx;
  114. border-radius: 24rpx 24rpx 24rpx 24rpx;
  115. overflow: hidden;
  116. }
  117. &-namebox {
  118. margin-bottom: 8rpx;
  119. @include u-flex(row,center,flex-start);
  120. }
  121. &-name {
  122. flex: 1;
  123. overflow: hidden;
  124. margin-left: 12rpx;
  125. font-family: PingFang SC, PingFang SC;
  126. font-weight: 600;
  127. font-size: 32rpx;
  128. color: #222222;
  129. }
  130. &-msg {
  131. width: 100%;
  132. }
  133. &-tag {
  134. flex-shrink: 0;
  135. max-width: 120rpx;
  136. padding: 5rpx 12rpx;
  137. background: #DBE8F8;
  138. border-radius: 8rpx 8rpx 8rpx 8rpx;
  139. box-sizing: border-box;
  140. text-align: center;
  141. word-break: keep-all;
  142. font-family: PingFang SC, PingFang SC;
  143. font-weight: 400;
  144. font-size: 24rpx;
  145. color: #3B74E1;
  146. }
  147. }
  148. </style>