indexH5.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. <template>
  2. <div class="detail bg-gray-900 w-full overflow-hidden relative">
  3. <img :src="baseApi + info.picture" @error="$AIPohotoError" class="bgImg absolute" />
  4. <div class="topTool">
  5. <div class="tm_button rounded-full text-white" @click="goBack">
  6. <i class="el-icon-arrow-left"></i>
  7. </div>
  8. <div class="tm_button rounded-full text-white">
  9. <i class="el-icon-more"></i>
  10. </div>
  11. </div>
  12. <div class="content">
  13. <div class="info w-full px-4 text-white" style="height: 30%; margin-top: 60px;">
  14. <div class="flex pt-4">
  15. <img class="w-16 h-16 rounded-full object-cover border-2 border-white mr-2" :src="baseApi + info.picture"
  16. @error="$AIPohotoError">
  17. <div class="flex flex-col text-white justify-center">
  18. <div class=" text-lg font-semibold">{{ info.characterName }}</div>
  19. <div class=" text-xs">Xchat No.{{ info.id }}</div>
  20. </div>
  21. </div>
  22. <div class="mt-2 mb-4 text-sm prologue">
  23. {{ info.prologue }}
  24. </div>
  25. <div class="text-sm mb-2">创作人 <span class="ml-4">{{ info.author }}</span></div>
  26. <div class="text-sm">创建时间 <span class="ml-4">{{ info.createTime }}</span></div>
  27. </div>
  28. <div class="bg-white mx-auto absolute infoBottom pt-4 px-4 w-full" style="height: calc(100vh - 60px);">
  29. <div class="scenarioList h-full">
  30. <div class=" text-base" style="height: 25px;">场景</div>
  31. <div v-if="info.sceneList && info.sceneList.length > 0" class="grid grid-cols-2 gap-2 mb-4 cursor-pointer">
  32. <template v-for="(item, index) in info.sceneList">
  33. <div v-if="item.isDelete == 0" class="flex flex-col justify-center" :key="index"
  34. @click="toChat(item.sceneId)">
  35. <img class=" rounded w-full h-24 object-cover" :src="baseApi + item.background" alt="">
  36. <div>{{ item.sceneName }}</div>
  37. <div class=" text-gray-400">{{ item.sceneDescription }}</div>
  38. </div>
  39. </template>
  40. </div>
  41. <el-empty v-else description="暂无场景"></el-empty>
  42. </div>
  43. </div>
  44. <div class="bottomButtons flex justify-around px-8">
  45. <div class="button b1" @click="toCreateScene">创建场景</div>
  46. <div class="button b2 bgColor1" @click="toChat()">开始对话</div>
  47. </div>
  48. </div>
  49. </div>
  50. </template>
  51. <script>
  52. import { detailApi } from "@/api/detail.js"
  53. // 引入需要的图标
  54. import 'vue-awesome/icons/heart'
  55. // import 'vue-awesome/icons/comment'
  56. import 'vue-awesome/icons/star'
  57. import 'vue-awesome/icons/brands/twitter'
  58. import 'vue-awesome/icons/brands/reddit'
  59. export default {
  60. components: {
  61. },
  62. data() {
  63. return {
  64. info: {}
  65. }
  66. },
  67. mounted() {
  68. console.log(this.$route.query.id);
  69. if (this.$route.query.id) {
  70. this.getDetail(this.$route.query.id)
  71. }
  72. },
  73. methods: {
  74. goBack() {
  75. this.$router.back()
  76. },
  77. toChat(sceneId) {
  78. let query = {
  79. characterId: this.info.id
  80. }
  81. if (sceneId) {
  82. query.sceneId = sceneId
  83. }
  84. console.log(query, 'query');
  85. this.$router.push({
  86. path: '/chatH5',
  87. query: query
  88. })
  89. },
  90. toCreateScene() {
  91. let query = {
  92. characterId: this.info.id
  93. }
  94. this.$router.push({
  95. path: '/createScene',
  96. query: query
  97. })
  98. },
  99. getDetail(id) {
  100. detailApi(id).then(res => {
  101. console.log(res, '角色详情');
  102. this.info = res.data
  103. })
  104. }
  105. }
  106. }
  107. </script>
  108. <style lang="scss" scoped>
  109. .detail {
  110. height: 100vh;
  111. }
  112. .labels {
  113. width: 100%;
  114. overflow-x: auto;
  115. }
  116. .photo {}
  117. .bgImg {
  118. object-fit: cover;
  119. object-position: top;
  120. height: 70%;
  121. width: 100%;
  122. }
  123. .infoBottom {
  124. overflow: hidden;
  125. border-radius: 10px;
  126. // top: 60%;
  127. }
  128. .content {
  129. width: 100%;
  130. height: 100vh;
  131. position: absolute;
  132. padding-top: 60px;
  133. background: rgba(58, 58, 58, 0.3);
  134. overflow-y: auto;
  135. .info {
  136. .prologue {
  137. overflow: hidden;
  138. text-overflow: ellipsis;
  139. display: -webkit-box;
  140. -webkit-line-clamp: 3;
  141. -webkit-box-orient: vertical;
  142. }
  143. }
  144. }
  145. .content::-webkit-scrollbar {
  146. display: none;
  147. /* Chrome Safari */
  148. }
  149. .content {
  150. scrollbar-width: none;
  151. /* firefox */
  152. -ms-overflow-style: none;
  153. /* IE 10+ */
  154. overflow-x: hidden;
  155. overflow-y: auto;
  156. }
  157. .topTool {
  158. position: absolute;
  159. width: 100%;
  160. height: 60px;
  161. display: flex;
  162. justify-content: space-between;
  163. align-items: center;
  164. padding: 0 20px;
  165. top: 0;
  166. z-index: 5;
  167. .tm_button {
  168. font-size: 16px;
  169. width: 30px;
  170. height: 30px;
  171. background: rgba(23, 23, 23, 0.4);
  172. display: flex;
  173. justify-content: center;
  174. align-items: center;
  175. cursor: pointer;
  176. }
  177. }
  178. .scenarioList {
  179. .list {
  180. display: grid;
  181. grid-template-columns: 1fr 1fr;
  182. grid-gap: 10px;
  183. }
  184. }
  185. .bottomButtons {
  186. position: fixed;
  187. bottom: 20px;
  188. width: 100%;
  189. .button {
  190. height: 30px;
  191. width: 100px;
  192. border-radius: 100px;
  193. text-align: center;
  194. line-height: 30px;
  195. font-size: 15px;
  196. box-shadow: 0px 0px 2px 1px rgba(117, 117, 117, 0.3);
  197. }
  198. .b1 {
  199. border: solid 1px #000;
  200. }
  201. .b2 {
  202. color: #fff;
  203. }
  204. }
  205. </style>