profileH5.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. <template>
  2. <div class="profileH5 bg-white" style="min-height: 100vh;">
  3. <div class="title">
  4. <div>我的</div>
  5. </div>
  6. <el-tabs v-model="query.type" @tab-click="tabChange" class="tabs w-full">
  7. <el-tab-pane label="公开" :name="0"></el-tab-pane>
  8. <el-tab-pane label="非公开" :name="1"></el-tab-pane>
  9. </el-tabs>
  10. <div class="lietRom flex-1 overflow-auto" v-infinite-scroll="load" infinite-scroll-disabled="disabled">
  11. <div class="list mt-4">
  12. <div v-for="(item, index) in characterList" :key="index"
  13. class="box2 relative rounded-lg overflow-hidden shadow-lg cursor-pointer" @click="toDetail(item)">
  14. <div class="w-full overflow-hidden">
  15. <img :src="baseApi + item.picture" class="w-full img" />
  16. </div>
  17. <div class="p-2">
  18. <h3 class="text-lg font-bold flex items-center">
  19. <div style="max-width: calc(100% - 18px);">{{ item.name }}</div>
  20. <i v-if="item.scene == 1" class="el-icon-video-camera-solid"></i>
  21. <i v-if="item.scene == 0" class="el-icon-user-solid"></i>
  22. </h3>
  23. <p class="prologue text-sm">
  24. {{ item.description }}
  25. </p>
  26. <div class="labels flex my-1 flex-wrap">
  27. <div v-for="(item2, index2) in item.labelArr" :key="index2"
  28. class="m-0.5 tag px-2 py-1 rounded flex items-center text-xs text-gray-500">
  29. <!-- <i class="fas fa-smile text-yellow-400 mr-2"></i> -->
  30. {{ item2 }}
  31. </div>
  32. </div>
  33. </div>
  34. <div class="absolute w-full bottom-0 flex items-center justify-between mt-3 px-2 pb-2">
  35. <div></div>
  36. <div class="flex items-center box1 text-red-500">
  37. <v-icon name="fire" scale="1" />
  38. <span class="ml-1">{{ item.hotCount || 0 }}</span>
  39. </div>
  40. </div>
  41. </div>
  42. </div>
  43. <p class="w-full py-4 text-gray-400 text-center" v-if="loading">加载中...</p>
  44. <p class="w-full py-4 text-gray-400 text-center" v-if="noMore">没有更多了</p>
  45. </div>
  46. </div>
  47. </template>
  48. <script>
  49. import { queryCharacterAndSceneApi } from "@/api/profile.js"
  50. export default {
  51. data() {
  52. return {
  53. query: {
  54. pageSize: 10,
  55. pageNum: 2,
  56. type: 0
  57. },
  58. total: 0,
  59. loading: false,
  60. noMore: false,
  61. characterList: []
  62. }
  63. },
  64. computed: {
  65. disabled() {
  66. return this.loading || this.noMore
  67. }
  68. },
  69. mounted() {
  70. this.getCharacterList()
  71. },
  72. methods: {
  73. tabChange() {
  74. this.query.pageNum = 1
  75. this.characterList = []
  76. this.getCharacterList()
  77. },
  78. load() {
  79. this.query.pageNum += 1
  80. this.getCharacterList()
  81. },
  82. getCharacterList(query) {
  83. this.loading = true
  84. let params = this.query
  85. if (query) {
  86. params = {
  87. ...params,
  88. ...query,
  89. }
  90. }
  91. queryCharacterAndSceneApi(params).then(res => {
  92. console.log(res, '角色列表');
  93. if (res.rows.length == 0) {
  94. this.noMore = true
  95. }
  96. // this.characterList = res.rows
  97. this.characterList = [...this.characterList, ...res.rows]
  98. if (this.characterList.length >= res.total) {
  99. this.noMore = true
  100. }
  101. this.total = res.total
  102. this.loading = false
  103. })
  104. },
  105. toDetail(item) {
  106. console.log(item, 'item');
  107. this.selectObj = item
  108. this.toChat()
  109. // this.dialogVisible = true
  110. },
  111. // 前往聊天页面
  112. toChat() {
  113. let query = {}
  114. if (this.selectObj.scene == 0) {
  115. // 点击是角色
  116. query.characterId = this.selectObj.id
  117. this.$router.push({
  118. path: '/chatH5',
  119. query: query
  120. })
  121. } else if (this.selectObj.scene == 1) {
  122. // 点击是场景
  123. query.characterId = this.selectObj.characterId
  124. query.sceneId = this.selectObj.id
  125. this.$router.push({
  126. path: '/chat',
  127. query: query
  128. })
  129. }
  130. },
  131. }
  132. }
  133. </script>
  134. <style lang="scss" scoped>
  135. .profileH5 {
  136. .title {
  137. height: 40px;
  138. line-height: 40px;
  139. font-size: 16px;
  140. // font-weight: 600;
  141. text-align: center;
  142. }
  143. .tabs {}
  144. }
  145. .lietRom {
  146. padding: 5px;
  147. padding-bottom: 60px;
  148. }
  149. .lietRom::-webkit-scrollbar {
  150. display: none;
  151. }
  152. .textButton {
  153. // color: #eee;
  154. margin-left: 5px;
  155. }
  156. .textButton:hover {
  157. color: #9333ea;
  158. }
  159. .labelButton {
  160. border: solid 1px #e6e6e6;
  161. background: var(--bg-color2);
  162. }
  163. .buttonBg1 {
  164. background: var(--bg-color1);
  165. color: #fff;
  166. }
  167. .topActive {
  168. background: var(--bg-color1);
  169. }
  170. .tag {
  171. background: var(--bg-color2);
  172. }
  173. .box1 {
  174. border: 1px solid #ffffff4d;
  175. height: 30px;
  176. padding: 0 10px;
  177. border-radius: 18px;
  178. // width: 68px;
  179. font-size: 14px;
  180. }
  181. .box2 {
  182. background: #ffffff0f;
  183. border: 1px solid #ffffff2e;
  184. height: 380px;
  185. }
  186. .box2:hover {
  187. border: solid 1px var(--bg-color1);
  188. }
  189. .img {
  190. height: 200px;
  191. object-fit: cover;
  192. object-position: top;
  193. transition: transform .2s
  194. }
  195. .img:hover {
  196. transform: scale(1.1);
  197. }
  198. .labels {
  199. max-height: 56px;
  200. overflow-y: auto;
  201. }
  202. .prologue {
  203. overflow: hidden;
  204. text-overflow: ellipsis;
  205. -webkit-line-clamp: 2;
  206. display: -webkit-box;
  207. -webkit-box-orient: vertical;
  208. }
  209. </style>
  210. <style scoped>
  211. .list {
  212. display: grid;
  213. grid-template-columns: 1fr 1fr;
  214. /* grid-auto-rows: minmax(280px, 280px); */
  215. grid-gap: 10px;
  216. }
  217. .tabs>>>.el-tabs__nav {
  218. width: 100%;
  219. }
  220. .tabs>>>.el-tabs__item {
  221. width: 50%;
  222. padding: 0;
  223. text-align: center;
  224. }
  225. </style>