|
@@ -1,402 +1,32 @@
|
|
|
-<!-- 个人中心 -->
|
|
|
<template>
|
|
|
- <div class=" h-full w-full">
|
|
|
- <div class="h-72 relative text-white bg">
|
|
|
- <img class=" absolute object-cover w-full h-full" v-if="userInfo.cover" :src="baseApi + userInfo.cover" alt="">
|
|
|
- <div class="flex absolute bottom-0 w-full px-28 justify-between items-end">
|
|
|
- <div class=" h-36 ">
|
|
|
- <div class="flex justify-center">
|
|
|
- <div class="w-24 h-24">
|
|
|
- <img class="w-full h-full rounded-full" :src="$store.state.user.avatar" alt="">
|
|
|
- </div>
|
|
|
- <div class="flex flex-col justify-center ml-3">
|
|
|
- <div class="font-medium text-2xl ">{{ userInfo.userName }}</div>
|
|
|
- <div class="text-base">账号:{{ userInfo.account }}</div>
|
|
|
- <div class=" text-base">UID:{{ userInfo.id }} <i class="el-icon-copy-document text-base"></i></div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- <div class="flex mt-3">
|
|
|
- <div class=" text-sm">
|
|
|
- 关注: 15
|
|
|
- </div>
|
|
|
- <div class=" text-sm ml-4">
|
|
|
- 粉丝: 6
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- <div class="flex items-center h-20">
|
|
|
- <div class=" w-10 h-10 rounded-full button flex justify-center items-center cursor-pointer mr-4">
|
|
|
- <i class="el-icon-share text-xl"></i>
|
|
|
- </div>
|
|
|
- <div class="w-32 h-10 flex justify-center items-center rounded-full button cursor-pointer"
|
|
|
- @click="$router.push({ name: 'user' })">
|
|
|
- <i class="el-icon-edit"></i>
|
|
|
- 编辑资料
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
-
|
|
|
- <div class="px-28 py-10">
|
|
|
- <div class="h-18 flex justify-between pb-4 border-b border-gray-200">
|
|
|
- <div class="flex justify-center">
|
|
|
- <div class="labelButton flex justify-center items-center rounded-full mr-4 w-28 h-10 cursor-pointer"
|
|
|
- :class="active == 0 && 'buttonBg1'" @click="tabChange(0)">
|
|
|
- 公开内容
|
|
|
- </div>
|
|
|
- <div class="labelButton flex justify-center items-center rounded-full w-28 h-10 cursor-pointer"
|
|
|
- :class="active == 1 && 'buttonBg1'" @click="tabChange(1)">
|
|
|
- <i class="el-icon-lock"></i>
|
|
|
- 非公开
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- <div class="flex justify-center">
|
|
|
- <div class="text-gray-800 cursor-pointer">
|
|
|
- <i class="el-icon-question"></i>
|
|
|
- 操作指南
|
|
|
- </div>
|
|
|
- <el-popover placement="bottom" width="160" v-model="popoverVisible">
|
|
|
- <div class="flex flex-col">
|
|
|
- <div class="submenu w-full text-gray-600 text-center py-2 rounded cursor-pointer" @click="() => {
|
|
|
- popoverVisible = false
|
|
|
- routeTo('/createScene')
|
|
|
- }">
|
|
|
- 创建场景
|
|
|
- </div>
|
|
|
- <div class="submenu w-full text-gray-600 text-center py-2 rounded cursor-pointer" @click="() => {
|
|
|
- popoverVisible = false
|
|
|
- routeTo('/create')
|
|
|
- }">
|
|
|
- 创建角色
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- <div slot="reference" class=" text-gray-800 cursor-pointer ml-4">
|
|
|
- <i class="el-icon-plus"></i>
|
|
|
- 创建
|
|
|
- </div>
|
|
|
- </el-popover>
|
|
|
-
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- <div class="list mt-4">
|
|
|
- <div v-for="(item, index) in characterList" :key="index"
|
|
|
- class="box2 relative rounded-lg overflow-hidden shadow-lg cursor-pointer" @click="toDetail(item)">
|
|
|
- <div class="w-full overflow-hidden h-3/5">
|
|
|
- <img class="w-full img h-full" :src="baseApi + item.picture" />
|
|
|
- </div>
|
|
|
- <div class="p-2">
|
|
|
- <h3 class="text-lg font-bold">
|
|
|
- <i v-if="item.scene == 1" class="el-icon-video-camera"></i>
|
|
|
- {{ item.name }}
|
|
|
- </h3>
|
|
|
- <p class="prologue text-sm">
|
|
|
- {{ item.description }}
|
|
|
- </p>
|
|
|
-
|
|
|
- <div class="labels flex my-1 flex-wrap">
|
|
|
- <div v-for="(item2, index2) in item.labelArr" :key="index2"
|
|
|
- class="m-0.5 tag px-2 py-1 rounded flex items-center text-xs text-gray-500">
|
|
|
- <!-- <i class="fas fa-smile text-yellow-400 mr-2"></i> -->
|
|
|
- {{ item2 }}
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- <div class="absolute w-full bottom-0 flex items-center justify-between mt-3 px-3 pb-3">
|
|
|
- <div class="flex items-center box1 text-red-500">
|
|
|
- <v-icon name="fire" scale="1" />
|
|
|
- <span class="ml-1">{{ item.hotCount || 0 }}</span>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- <el-dialog title="提示" :visible.sync="dialogVisible" width="500px">
|
|
|
- <div class="flex justify-between px-2 py-3 border-b border-gray-200" v-if="selectObj.scene == 1">
|
|
|
- <div>场景</div>
|
|
|
- <div>{{ selectObj.name }}</div>
|
|
|
- </div>
|
|
|
- <div class="flex justify-between px-2 py-3 border-b border-gray-200">
|
|
|
- <div>角色</div>
|
|
|
- <div>{{ selectObj.scene == 1 ? selectObj.characerName : selectObj.name }}</div>
|
|
|
- </div>
|
|
|
- <div class="flex justify-between px-2 py-3 border-b border-gray-200">
|
|
|
- <div>可见性</div>
|
|
|
- <el-radio-group v-model="selectObj.type" @input="typeChange">
|
|
|
- <el-radio :label="0">公开</el-radio>
|
|
|
- <el-radio :label="1">私密</el-radio>
|
|
|
- </el-radio-group>
|
|
|
- </div>
|
|
|
- <div class="flex justify-between px-2 py-3 border-b border-gray-200">
|
|
|
- <div></div>
|
|
|
- <el-button round type="danger" @click="deleteData">删 除</el-button>
|
|
|
- </div>
|
|
|
- <span slot="footer" class="dialog-footer flex justify-around">
|
|
|
- <el-button class="flex-1" round @click="toChat">聊 天</el-button>
|
|
|
- <el-button class="flex-1" round type="primary" @click="toCreate">编 辑</el-button>
|
|
|
- </span>
|
|
|
- </el-dialog>
|
|
|
-
|
|
|
+ <div class="app-pageContainer">
|
|
|
+ <ProfilePC v-if="!$store.state.app.isMobile" />
|
|
|
+ <ProfileH5 v-else />
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { getInfo } from '@/api/login'
|
|
|
-import { queryCharacterAndSceneApi } from "@/api/profile.js"
|
|
|
-import {
|
|
|
- deleteSceneApi,
|
|
|
- deleteCharacterApi,
|
|
|
- setCharacterShowApi,
|
|
|
- editSceneApi
|
|
|
-} from "@/api/create.js"
|
|
|
-import 'vue-awesome/icons/fire'
|
|
|
+import ProfilePC from "./profilePC.vue"
|
|
|
+import ProfileH5 from "./profileH5.vue"
|
|
|
+
|
|
|
export default {
|
|
|
+ name: "profile",
|
|
|
+ components: {
|
|
|
+ ProfilePC,
|
|
|
+ ProfileH5
|
|
|
+ },
|
|
|
data() {
|
|
|
return {
|
|
|
- userInfo: {},
|
|
|
- popoverVisible: false,
|
|
|
- dialogVisible: false,
|
|
|
- selectObj: {},
|
|
|
- active: 0,
|
|
|
- characterList: []
|
|
|
+
|
|
|
}
|
|
|
},
|
|
|
mounted() {
|
|
|
- this.getUserInfo()
|
|
|
- this.getCharacterList()
|
|
|
+
|
|
|
},
|
|
|
methods: {
|
|
|
- getUserInfo() {
|
|
|
- let params = {
|
|
|
- userId: this.$store.state.user.userId
|
|
|
- }
|
|
|
- getInfo(params).then(res => {
|
|
|
- console.log(res, 'resUserInfo')
|
|
|
- this.userInfo = res.data
|
|
|
- })
|
|
|
- },
|
|
|
- routeTo(url) {
|
|
|
- this.$router.push(url)
|
|
|
- },
|
|
|
-
|
|
|
- toDetail(item) {
|
|
|
- console.log(item, 'item');
|
|
|
- this.selectObj = item
|
|
|
- this.dialogVisible = true
|
|
|
- },
|
|
|
- // 前往编辑页面
|
|
|
- toCreate() {
|
|
|
- if (this.selectObj.scene == 0) {
|
|
|
- // 点击是角色
|
|
|
- this.$router.push({
|
|
|
- path: '/create',
|
|
|
- query: {
|
|
|
- id: this.selectObj.id
|
|
|
- }
|
|
|
- })
|
|
|
- } else if (this.selectObj.scene == 1) {
|
|
|
- // 点击是场景
|
|
|
- this.$router.push({
|
|
|
- path: '/createScene',
|
|
|
- query: {
|
|
|
- sceneId: this.selectObj.id,
|
|
|
- characterId: this.selectObj.characterId
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
|
|
|
- },
|
|
|
- // 前往聊天页面
|
|
|
- toChat() {
|
|
|
- let query = {}
|
|
|
- if (this.selectObj.scene == 0) {
|
|
|
- // 点击是角色
|
|
|
- query.characterId = this.selectObj.id
|
|
|
- } else if (this.selectObj.scene == 1) {
|
|
|
- // 点击是场景
|
|
|
- query.characterId = this.selectObj.characterId
|
|
|
- query.sceneId = this.selectObj.id
|
|
|
- }
|
|
|
- this.$router.push({
|
|
|
- path: '/chat',
|
|
|
- query: query
|
|
|
- })
|
|
|
- },
|
|
|
- // 修改公开私密状态
|
|
|
- typeChange() {
|
|
|
- console.log(this.selectObj, 'this.selectObj');
|
|
|
- if (this.selectObj.scene == 0) {
|
|
|
- // 点击是角色
|
|
|
- let params = {
|
|
|
- id: this.selectObj.id,
|
|
|
- type: this.selectObj.type
|
|
|
- }
|
|
|
- setCharacterShowApi(this.selectObj.id, this.selectObj.type).then(res => {
|
|
|
- this.$message({
|
|
|
- type: 'success',
|
|
|
- message: '修改成功!'
|
|
|
- });
|
|
|
- this.dialogVisible = false
|
|
|
- this.getCharacterList()
|
|
|
- })
|
|
|
- } else if (this.selectObj.scene == 1) {
|
|
|
- // 点击是场景
|
|
|
- let params = {
|
|
|
- sceneId: this.selectObj.id,
|
|
|
- type: this.selectObj.type
|
|
|
- }
|
|
|
- editSceneApi(params).then(res => {
|
|
|
- this.$message({
|
|
|
- type: 'success',
|
|
|
- message: '修改成功!'
|
|
|
- });
|
|
|
- this.dialogVisible = false
|
|
|
- this.getCharacterList()
|
|
|
- })
|
|
|
- }
|
|
|
- },
|
|
|
- // 删除
|
|
|
- deleteData() {
|
|
|
- if (this.selectObj.scene == 0) {
|
|
|
- // 删除角色
|
|
|
- this.$confirm('此操作将永久删除该角色及其所有聊天记录, 是否继续?', '提示', {
|
|
|
- confirmButtonText: '确定',
|
|
|
- cancelButtonText: '取消',
|
|
|
- type: 'warning'
|
|
|
- }).then(() => {
|
|
|
- deleteCharacterApi(this.selectObj.id).then(res => {
|
|
|
- this.$message({
|
|
|
- type: 'success',
|
|
|
- message: '删除成功!'
|
|
|
- });
|
|
|
- this.dialogVisible = false
|
|
|
- this.getCharacterList()
|
|
|
- })
|
|
|
- })
|
|
|
- } else if (this.selectObj.scene == 1) {
|
|
|
- // 删除场景
|
|
|
- this.$confirm('此操作将永久删除该场景及其所有聊天记录, 是否继续?', '提示', {
|
|
|
- confirmButtonText: '确定',
|
|
|
- cancelButtonText: '取消',
|
|
|
- type: 'warning'
|
|
|
- }).then(() => {
|
|
|
- deleteSceneApi(this.selectObj.id).then(res => {
|
|
|
- this.$message({
|
|
|
- type: 'success',
|
|
|
- message: '删除成功!'
|
|
|
- });
|
|
|
- this.dialogVisible = false
|
|
|
- this.getCharacterList()
|
|
|
- })
|
|
|
- })
|
|
|
-
|
|
|
- }
|
|
|
- },
|
|
|
- tabChange(index) {
|
|
|
- this.active = index
|
|
|
- this.getCharacterList()
|
|
|
- },
|
|
|
- getCharacterList(query) {
|
|
|
- let params = {
|
|
|
- pageSize: 20,
|
|
|
- pageNum: 1,
|
|
|
- type: this.active
|
|
|
- }
|
|
|
- if (query) {
|
|
|
- params = {
|
|
|
- ...params,
|
|
|
- ...query
|
|
|
- }
|
|
|
- }
|
|
|
- queryCharacterAndSceneApi(params).then(res => {
|
|
|
- console.log(res, '角色列表');
|
|
|
- // let characterList = res.data.characterList
|
|
|
- // characterList.map((item) => { item.mType = 1 })
|
|
|
- // let sceneList = res.data.sceneList
|
|
|
- // sceneList.map((item) => { item.mType = 2 })
|
|
|
- // let arr = [
|
|
|
- // ...res.data.characterList,
|
|
|
- // ...res.data.sceneList,
|
|
|
- // ]
|
|
|
- // arr.sort(this.sortByTime('createTime', -1))
|
|
|
- this.characterList = res.rows
|
|
|
- })
|
|
|
- },
|
|
|
- sortByTime(attr, rev) {
|
|
|
- //attr:根据该属性排序;rev:升序1或降序-1,不填则默认为1
|
|
|
- if (rev == undefined) { rev = 1 } else { (rev) ? 1 : -1; }
|
|
|
- return function (a, b) {
|
|
|
- a = new Date(a[attr]).getTime();
|
|
|
- b = new Date(b[attr]).getTime();
|
|
|
- if (a < b) { return rev * -1 }
|
|
|
- if (a > b) { return rev * 1 }
|
|
|
- return 0;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
+ },
|
|
|
+};
|
|
|
</script>
|
|
|
|
|
|
-<style lang="scss" scoped>
|
|
|
-.list {
|
|
|
- display: grid;
|
|
|
- grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
|
|
|
- grid-auto-rows: minmax(100px, auto);
|
|
|
- grid-gap: 20px;
|
|
|
-}
|
|
|
-
|
|
|
-.button {
|
|
|
- // background-color: #fff;
|
|
|
- color: #fff;
|
|
|
- border: 1px solid #fff;
|
|
|
-}
|
|
|
-
|
|
|
-.labelButton {
|
|
|
- // border: solid 1px #e6e6e6;
|
|
|
- background: var(--bg-color2);
|
|
|
- color: var(--color2);
|
|
|
-}
|
|
|
-
|
|
|
-.buttonBg1 {
|
|
|
- background: var(--bg-color1);
|
|
|
- color: #fff;
|
|
|
-}
|
|
|
-
|
|
|
-.box2 {
|
|
|
- background: #ffffff0f;
|
|
|
- border: 1px solid #ffffff2e;
|
|
|
- min-width: 200px;
|
|
|
- height: 35vw;
|
|
|
- min-height: 260px;
|
|
|
- max-height: 400px;
|
|
|
-}
|
|
|
-
|
|
|
-.box2:hover {
|
|
|
- border: solid 1px var(--bg-color1);
|
|
|
-}
|
|
|
-
|
|
|
-.img {
|
|
|
- // height: 230px;
|
|
|
- object-fit: cover;
|
|
|
- object-position: top;
|
|
|
- transition: transform .2s
|
|
|
-}
|
|
|
-
|
|
|
-.img:hover {
|
|
|
- transform: scale(1.1);
|
|
|
-}
|
|
|
-
|
|
|
-.bg {
|
|
|
- background-color: var(--bg-color1);
|
|
|
- background-image: url(https://cdn-az.rochat.tech/avatar/131__c9103616-e103-11ee-bef2-66a40ff97e79.png);
|
|
|
- background-repeat: no-repeat;
|
|
|
- background-size: 100% 100%;
|
|
|
-}
|
|
|
-
|
|
|
-.prologue {
|
|
|
- overflow: hidden;
|
|
|
- text-overflow: ellipsis;
|
|
|
- -webkit-line-clamp: 4;
|
|
|
- display: -webkit-box;
|
|
|
- -webkit-box-orient: vertical;
|
|
|
-}
|
|
|
-</style>
|
|
|
+<style scoped lang="scss"></style>
|