Refactor code structure and remove redundant changes
This commit is contained in:
114
pages/personal-Center/components/account-security.vue
Normal file
114
pages/personal-Center/components/account-security.vue
Normal file
@ -0,0 +1,114 @@
|
||||
<template>
|
||||
<div class="box-border w-913px border border-[#EEEEEE] rounded-6px border-solid bg-[#FFFFFF] px-30px py-21px">
|
||||
<el-tabs v-model="activeName" class="demo-tabs">
|
||||
<el-tab-pane label="修改密码" name="修改密码">
|
||||
<el-form ref="formRef" :model="form" label-width="120px" class="profile-form" autocomplete="off">
|
||||
<el-form-item
|
||||
label="手机号"
|
||||
prop="phone"
|
||||
class="mt-15px!"
|
||||
:rules="[
|
||||
{ required: true, message: '请输入手机号', trigger: ['blur', 'change'] },
|
||||
{
|
||||
pattern: /^1[3456789]\d{9}$/,
|
||||
message: '请输入正确的手机号',
|
||||
trigger: ['blur', 'change'],
|
||||
},
|
||||
]"
|
||||
>
|
||||
<el-input v-model="form.phone" type="text" placeholder="请输入手机号" class="h-37px" />
|
||||
</el-form-item>
|
||||
<el-form-item label="验证码" prop="code" class="mt-15px!" :rules="{ required: true, message: '请输入验证码', trigger: ['blur', 'change'] }">
|
||||
<div class="flex items-center gap10">
|
||||
<el-input v-model="form.code" type="text" placeholder="请输入验证码" class="h-37px" />
|
||||
<el-button
|
||||
type="primary"
|
||||
class="w-110px rd-4px bg-[#1A65FF] px-6px text-center color-#fff line-height-37px h-37px!"
|
||||
:disabled="counting > 0"
|
||||
@click="handleCode"
|
||||
>
|
||||
{{ counting > 0 ? `${counting}s后重新获取` : '获取验证码' }}</el-button
|
||||
>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="新密码" prop="password" class="mt-20px!" :rules="{ required: true, message: '请输入新密码', trigger: ['blur', 'change'] }">
|
||||
<el-input v-model="form.password" autocomplete="new-password" type="password" placeholder="请输入新密码" class="h-37px" />
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
label="确认密码"
|
||||
prop="passwordV2"
|
||||
class="mt-20px!"
|
||||
:rules="{ required: true, message: '请再次输入新密码', trigger: ['blur', 'change'] }"
|
||||
>
|
||||
<el-input v-model="form.passwordV2" autocomplete="new-password" type="passwordV2" placeholder="请再次输入新密码" class="h-37px" />
|
||||
</el-form-item>
|
||||
<el-form-item class="mt-20px!">
|
||||
<el-button type="primary" class="h-37px w-121px line-height-37px" @click="handleSave">保存</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-tab-pane>
|
||||
<!-- <el-tab-pane label="登录设备管理" name="登录设备管理"> </el-tab-pane> -->
|
||||
</el-tabs>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { reactive, ref } from 'vue'
|
||||
import { resetPassoword } from '@/api/login/index'
|
||||
import { sendSms } from '@/api/common/index'
|
||||
import useUserStore from '@/store/user'
|
||||
const userStore = useUserStore()
|
||||
|
||||
const activeName = ref('修改密码')
|
||||
|
||||
/** 请求入参 */
|
||||
const form = reactive({
|
||||
phone: '',
|
||||
password: '',
|
||||
passwordV2: '',
|
||||
code: '',
|
||||
})
|
||||
|
||||
/** 提交 */
|
||||
const formRef = ref()
|
||||
const handleSave = async () => {
|
||||
await formRef.value.validate()
|
||||
if (form.password !== form.passwordV2) return ElMessage.error('两次密码不一致')
|
||||
try {
|
||||
const res = await resetPassoword(form)
|
||||
const { code } = res
|
||||
if (code === 0) {
|
||||
ElMessage.success(`修改密码成功,请重新登录`)
|
||||
setTimeout(() => {
|
||||
userStore.logout()
|
||||
userStore.$reset()
|
||||
}, 500)
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
}
|
||||
|
||||
/** 获取验证码 */
|
||||
const counting = ref(0)
|
||||
const handleCode = async () => {
|
||||
await formRef.value.validateField('phone')
|
||||
try {
|
||||
const res = await sendSms({ mobile: form.phone, scene: 3 })
|
||||
const { code } = res
|
||||
if (code === 0) {
|
||||
ElMessage.success('验证码已发送')
|
||||
counting.value = 60
|
||||
const timer = setInterval(() => {
|
||||
counting.value--
|
||||
if (counting.value === 0) {
|
||||
clearInterval(timer)
|
||||
}
|
||||
}, 1000)
|
||||
}
|
||||
} catch (error) {
|
||||
counting.value = 0
|
||||
console.log(error)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
31
pages/personal-Center/components/components/browse-table.vue
Normal file
31
pages/personal-Center/components/components/browse-table.vue
Normal file
@ -0,0 +1,31 @@
|
||||
<template>
|
||||
<el-table :data="modelValue" style="width: 100%">
|
||||
<el-table-column prop="date" label="文件信息">
|
||||
<template #default="scope">
|
||||
<div class="flex items-center">
|
||||
<el-image :src="scope.row.url" alt="" fit="cover" srcset="" class="h-91px w-181px rd-4px" />
|
||||
<div class="ml-17px">
|
||||
<div class="text-16px text-[#333333] font-normal">{{ scope.row.title }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="type" label="文件类型" width="180">
|
||||
<template #default="scope">{{ scope.row.type === 1 ? '图纸' : scope.row.type === 2 ? '文本' : '模型' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="createTime" label="下载时间" width="180">
|
||||
<template #default="scope">{{ dayjs(scope.row.createTime).format('YYYY-MM-DD HH:mm:ss') }}</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ProjectHistoryResVO } from '@/api/personal-center/types'
|
||||
import dayjs from 'dayjs'
|
||||
|
||||
const modelValue = defineModel<ProjectHistoryResVO[]>('modelValue', {
|
||||
required: true,
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
@ -0,0 +1,46 @@
|
||||
<template>
|
||||
<el-table :data="modelValue" style="width: 100%">
|
||||
<el-table-column prop="date" label="文件信息">
|
||||
<template #default="scope">
|
||||
<div class="flex items-center">
|
||||
<el-image :src="scope.row.iconUrl" alt="" fit="cover" srcset="" class="h-91px w-181px rd-4px" />
|
||||
<div class="ml-17px">
|
||||
<div class="text-16px text-[#333333] font-normal">{{ scope.row.title }}</div>
|
||||
<div class="text-14px text-[#333333] font-normal my-10px!">by {{ scope.row?.ownedUserIdInfo?.nickName }}</div>
|
||||
<div class="flex items-center">
|
||||
<div class="flex items-center">
|
||||
<img src="@/assets/images/look.png" alt="" srcset="" class="h-17px" />
|
||||
<span class="ml-4px">{{ scope.row.previewPoint }}</span>
|
||||
</div>
|
||||
<div class="ml-13px flex items-center">
|
||||
<img src="@/assets/images/add.png" alt="" srcset="" class="h-23px" />
|
||||
<span class="ml-4px">{{ scope.row.hotPoint }}</span>
|
||||
</div>
|
||||
<div class="ml-13px flex items-center">
|
||||
<img src="@/assets/images/chat.png" alt="" srcset="" class="h-17px" />
|
||||
<span class="ml-4px">{{ scope.row.commentsPoint }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="name" label="文件类型" width="180">
|
||||
<template #default="scope">{{ scope.row.type === 1 ? '图纸' : scope.row.type === 2 ? '文本' : scope.row.type === 3 ? '模型' : '工具箱' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="createTime" label="下载时间" width="180">
|
||||
<template #default="scope">{{ dayjs(scope.row.createTime).format('YYYY-MM-DD HH:mm:ss') }}</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ProjectHistoryResVO } from '@/api/personal-center/types'
|
||||
import dayjs from 'dayjs'
|
||||
|
||||
const modelValue = defineModel<ProjectHistoryResVO[]>('modelValue', {
|
||||
required: true,
|
||||
}) // 双向绑定的value
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
@ -0,0 +1,96 @@
|
||||
<template>
|
||||
<KlTabBar v-model="type" :data="tabBar" @change="props.refresh()" />
|
||||
<el-table :data="modelValue" style="width: 100%" class="mt-14px">
|
||||
<el-table-column prop="date" label="文件信息">
|
||||
<template #default="scope">
|
||||
<div class="flex items-center">
|
||||
<el-image :src="scope.row.iconUrl" alt="" fit="cover" srcset="" class="h-91px w-181px rd-4px" />
|
||||
<div class="ml-17px">
|
||||
<div class="text-16px text-[#333333] font-normal">{{ scope.row.title }}</div>
|
||||
<div class="text-14px text-[#333333] font-normal my-10px!">{{ scope.row?.ownedUserIdInfo?.nickName }}</div>
|
||||
<div class="flex items-center">
|
||||
<div class="flex items-center">
|
||||
<img src="@/assets/images/look.png" alt="" srcset="" class="h-17px" />
|
||||
<span class="ml-4px">{{ scope.rowpreviewPoint || 0 }}</span>
|
||||
</div>
|
||||
<div class="ml-13px flex items-center">
|
||||
<img src="@/assets/images/add.png" alt="" srcset="" class="h-23px" />
|
||||
<span class="ml-4px">{{ scope.row.hotPoint || 0 }}</span>
|
||||
</div>
|
||||
<div class="ml-13px flex items-center">
|
||||
<img src="@/assets/images/chat.png" alt="" srcset="" class="h-17px" />
|
||||
<span class="ml-4px">{{ scope.row.commentsPoint || 0 }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="type" label="文件类型" width="100">
|
||||
<template #default="scope">{{ scope.row.type === 1 ? '图纸' : scope.row.type === 2 ? '文本' : scope.row.type === 3 ? '模型' : '工具箱' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="createTime" label="下载时间" width="180">
|
||||
<template #default="scope">{{ dayjs(scope.row.createTime).format('YYYY-MM-DD HH:mm:ss') }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="createTime" label="取消收藏" width="100" fixed="right">
|
||||
<template #default="scope">
|
||||
<el-link type="primary" :underline="false" @click="handleDelete(scope.row.id)">取消收藏</el-link>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue'
|
||||
import KlTabBar from '@/components/kl-tab-bar/v2/index.vue'
|
||||
import { PageResultProjectMemberFavoritesRespVO } from '@/api/personal-center/types'
|
||||
import { deleteProject } from '@/api/drawe-detail/index'
|
||||
import dayjs from 'dayjs'
|
||||
import { useMessage } from '@/utils/useMessage'
|
||||
const message = useMessage()
|
||||
|
||||
const type = defineModel<number | string>('type', {
|
||||
required: true,
|
||||
}) // 双向绑定的value
|
||||
const modelValue = defineModel<PageResultProjectMemberFavoritesRespVO['list']>('modelValue', {
|
||||
required: true,
|
||||
}) // 双向绑定的value
|
||||
|
||||
const props = defineProps({
|
||||
// 刷新
|
||||
refresh: {
|
||||
type: Function,
|
||||
default: () => Function,
|
||||
},
|
||||
})
|
||||
|
||||
const tabBar = ref([
|
||||
{
|
||||
label: '图纸',
|
||||
value: 1,
|
||||
},
|
||||
{
|
||||
label: '模型',
|
||||
value: 3,
|
||||
},
|
||||
{
|
||||
label: '文本',
|
||||
value: 2,
|
||||
},
|
||||
])
|
||||
|
||||
const handleDelete = async (id: number) => {
|
||||
const r = await message.confirm('确定取消收藏吗?')
|
||||
if (!r) return
|
||||
const res = await deleteProject({
|
||||
id,
|
||||
})
|
||||
const { code } = res
|
||||
if (code === 0) {
|
||||
ElMessage.success('取消收藏成功')
|
||||
props.refresh()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
836
pages/personal-Center/components/components/message.vue
Normal file
836
pages/personal-Center/components/components/message.vue
Normal file
@ -0,0 +1,836 @@
|
||||
<!-- 弄成一个聊天弹窗 仿照微信聊天弹窗 -->
|
||||
<template>
|
||||
<div class="chat-dialog">
|
||||
<el-dialog
|
||||
v-model="dialogVisible"
|
||||
lock-scroll
|
||||
draggable
|
||||
:show-close="true"
|
||||
:close-on-click-modal="false"
|
||||
:close-on-press-escape="false"
|
||||
width="1000px"
|
||||
@close="closeDialog"
|
||||
>
|
||||
<template #header>
|
||||
<div class="dialog-header">
|
||||
<div class="title">在线消息</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<div class="chat-layout">
|
||||
<!-- 左侧用户列表 -->
|
||||
<div class="user-list">
|
||||
<div class="search-box">
|
||||
<el-input v-model="searchText" placeholder="搜索" :prefix-icon="Search" clearable />
|
||||
</div>
|
||||
<div class="user-items">
|
||||
<div v-for="(user, k) in filteredUsers" :key="k" :class="['user-item', { active: currentUserId === user.sessionId }]" @click="switchUser(user)">
|
||||
<el-avatar :size="40" :src="userStore.userInfoRes.id === user.fromId ? user.toUser?.avatar : user.fromUser?.avatar" />
|
||||
<div class="user-info">
|
||||
<div class="user-name">{{ user.name }}</div>
|
||||
<div class="last-message">{{ user.lastMsg.content }}</div>
|
||||
</div>
|
||||
<div class="message-status">
|
||||
<div class="time">{{ handleCreateTime(user.updateTime) }}</div>
|
||||
<el-badge v-if="user.unreadCount" :value="user.unreadCount" class="unread-badge" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 右侧聊天区域 -->
|
||||
<div class="chat-container">
|
||||
<!-- 聊天头部 -->
|
||||
<div class="chat-header">
|
||||
<div class="header-left">
|
||||
<!-- <el-avatar :size="36" :src="currentUser?.avatar" /> -->
|
||||
<div class="title-info">
|
||||
<div class="title">{{ currentUser?.fromId === userStore.userInfoRes.id ? currentUser?.toTitle : currentUser?.fromTitle }}</div>
|
||||
<!-- <div class="subtitle">{{ currentUser?.status }}</div> -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 消息列表区域 -->
|
||||
<div ref="messageList" class="message-list" @scroll="handleScroll">
|
||||
<!-- 加载更多提示 -->
|
||||
<div v-if="chatMessageQuery.hasMore" class="load-more">
|
||||
<el-icon v-if="chatMessageQuery.loading"><Loading /></el-icon>
|
||||
<span v-else>上拉加载更多</span>
|
||||
</div>
|
||||
<div
|
||||
v-for="(msg, index) in chatMessages"
|
||||
:key="index"
|
||||
:class="['message-item', msg.fromId === userStore.userInfoRes.id ? 'message-sent' : 'message-received']"
|
||||
>
|
||||
<div class="avatar">
|
||||
<el-avatar :size="40" :src="msg.fromId === userStore.userInfoRes.id ? userStore.userInfoRes.avatar : userAvatar" />
|
||||
</div>
|
||||
<div class="message-content">
|
||||
<div v-if="msg.msgType === 0" class="message-bubble whitespace-pre-wrap">{{ msg.content }}</div>
|
||||
<div v-else-if="msg.msgType === 1" class="message-bubble max-w-50%">
|
||||
<img :src="msg.content" alt="图片" class="w-100%" />
|
||||
</div>
|
||||
<div v-else class="message-bubble max-w-50%">
|
||||
{{ msg.content.split('/').pop() }}
|
||||
</div>
|
||||
<div class="message-time">{{ dayjs(msg.createTime).format('YYYY-MM-DD HH:mm:ss') }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 输入区域 -->
|
||||
<div class="input-area">
|
||||
<div class="toolbar">
|
||||
<div class="tool-left">
|
||||
<el-tooltip content="发送图片" placement="top">
|
||||
<el-icon class="tool-icon" @click="triggerImageUpload"><Picture /></el-icon>
|
||||
</el-tooltip>
|
||||
<input ref="imageInputRef" type="file" style="display: none" @change="handleImageUpload" />
|
||||
<el-popover :visible="showEmoji" placement="top" :width="450" trigger="click">
|
||||
<template #reference>
|
||||
<el-icon class="tool-icon emoji-trigger" @click="showEmoji = !showEmoji"><Sunrise /></el-icon>
|
||||
</template>
|
||||
|
||||
<div class="emoji-list">
|
||||
<span v-for="emoji in emojiList" :key="emoji" class="emoji-item" @click="insertEmoji(emoji)">
|
||||
{{ emoji }}
|
||||
</span>
|
||||
</div>
|
||||
</el-popover>
|
||||
</div>
|
||||
</div>
|
||||
<div class="input-box">
|
||||
<el-input
|
||||
v-model="inputMessage"
|
||||
type="textarea"
|
||||
:rows="3"
|
||||
placeholder="请输入消息,Enter 发送"
|
||||
resize="none"
|
||||
maxlength="255"
|
||||
@keydown.enter.prevent="(e: any) => (e.shiftKey ? (inputMessage += '\n') : handleSend(0))"
|
||||
/>
|
||||
</div>
|
||||
<div class="send-btn">
|
||||
<el-button type="primary" :disabled="!inputMessage.trim() || userList.length === 0" @click="handleSend(0)">
|
||||
<el-icon class="send-icon"><Position /></el-icon>
|
||||
发送
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { throttle } from 'lodash'
|
||||
import { ref, computed, onMounted, nextTick } from 'vue'
|
||||
import { Picture, Position, Sunrise, Search, Loading } from '@element-plus/icons-vue'
|
||||
import { upload } from '@/api/common'
|
||||
import { sendSingleChat, conversationList, getChatDetail, clearUnreadMessage } from '@/api/channel/index'
|
||||
import { chatMessagesReq, msgType, PageResultSessionRespVO, PageResultMessageRespVO } from '@/api/channel/types'
|
||||
import useUserStore from '@/store/user'
|
||||
const userStore = useUserStore()
|
||||
import dayjs from 'dayjs'
|
||||
|
||||
const inputMessage = ref('')
|
||||
const messageList = ref()
|
||||
const searchText = ref('')
|
||||
const currentUserId = ref()
|
||||
|
||||
const dialogVisible = defineModel<boolean>('dialogVisible', { required: true })
|
||||
// 获取传过来的数据
|
||||
const props = defineProps({
|
||||
sessionType: {
|
||||
// 会话类型0:单聊 1:群聊,示例值(2)
|
||||
type: String,
|
||||
default: '1',
|
||||
},
|
||||
})
|
||||
console.log('会话类型', props.sessionType)
|
||||
|
||||
// 模拟数据
|
||||
const userAvatar = 'https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png'
|
||||
|
||||
const userList = ref<PageResultSessionRespVO[]>([])
|
||||
|
||||
// 获取会话列表
|
||||
const getConversationList = async (type?: string) => {
|
||||
const res = await conversationList()
|
||||
if (res.code === 0) {
|
||||
userList.value = res.data
|
||||
?.map((item) => {
|
||||
return {
|
||||
...item,
|
||||
name: userStore.userInfoRes.id === item.fromId ? item.toTitle : item.fromTitle,
|
||||
lastMsg: item.lastMsg ? JSON.parse(item.lastMsg) : { content: '' },
|
||||
}
|
||||
})
|
||||
.filter((user) => userStore.userInfoRes.nickname !== user.name) // 提出自己
|
||||
// 默认选中第一个
|
||||
if (type === 'init' && userList.value.length > 0) {
|
||||
switchUser(userList.value[0])
|
||||
}
|
||||
}
|
||||
}
|
||||
getConversationList('init')
|
||||
|
||||
// 聊天记录
|
||||
const chatMessages = ref<PageResultMessageRespVO['list']>([])
|
||||
|
||||
const filteredUsers = computed(() => {
|
||||
if (!searchText.value) return userList.value
|
||||
return userList.value.filter(
|
||||
(user) => user.name.toLowerCase().includes(searchText.value.toLowerCase()) || user.lastMsg.content.toLowerCase().includes(searchText.value.toLowerCase())
|
||||
)
|
||||
})
|
||||
|
||||
const currentUser = computed(() => {
|
||||
return userList.value.find((user) => user.sessionId === currentUserId.value)
|
||||
})
|
||||
|
||||
const handleCreateTime = (time: string) => {
|
||||
// 先判断是否是今天 今天取时分 不是今天取年月日
|
||||
const today = dayjs()
|
||||
const msgTime = dayjs(time)
|
||||
if (today.isSame(msgTime, 'day')) {
|
||||
return msgTime.format('HH:mm')
|
||||
} else {
|
||||
return msgTime.format('YYYY-MM-DD')
|
||||
}
|
||||
}
|
||||
|
||||
// 聊天消息查询
|
||||
const chatMessageQuery = ref({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
hasMore: true,
|
||||
loading: false,
|
||||
sessionId: 0,
|
||||
toId: 0,
|
||||
isPending: false,
|
||||
})
|
||||
const switchUser = async (user: PageResultSessionRespVO) => {
|
||||
// 切换用户
|
||||
chatMessageQuery.value.toId = user.fromId === userStore.userInfoRes.id ? user.toId : user.fromId
|
||||
chatMessageQuery.value.sessionId = currentUserId.value = user.sessionId
|
||||
user.unreadCount = 0 // 清除未读消息
|
||||
// 切换用户时,清空聊天记录
|
||||
chatMessageQuery.value.loading = true
|
||||
chatMessageQuery.value.pageNo = 1
|
||||
chatMessageQuery.value.hasMore = true
|
||||
chatMessages.value = []
|
||||
await getChatDetailList()
|
||||
nextTick(() => {
|
||||
scrollToBottom()
|
||||
})
|
||||
// 清空未读消息
|
||||
clearUnreadMessage({ id: user.sessionId })
|
||||
}
|
||||
|
||||
const getChatDetailList = async () => {
|
||||
const res = await getChatDetail({
|
||||
sessionId: chatMessageQuery.value.sessionId,
|
||||
pageNo: chatMessageQuery.value.pageNo,
|
||||
pageSize: chatMessageQuery.value.pageSize,
|
||||
})
|
||||
if (res.code === 0) {
|
||||
chatMessageQuery.value.isPending = false
|
||||
// 数据反过来
|
||||
if (res.data.list.length > 0) {
|
||||
// 保存当前滚动位置和内容高度
|
||||
const scrollElement = messageList.value
|
||||
const oldScrollHeight = scrollElement.scrollHeight
|
||||
const oldScrollTop = scrollElement.scrollTop
|
||||
chatMessages.value = [...res.data.list.reverse(), ...chatMessages.value]
|
||||
// 在下一个 tick 后调整滚动位置
|
||||
nextTick(() => {
|
||||
const newScrollHeight = scrollElement.scrollHeight
|
||||
const heightDiff = newScrollHeight - oldScrollHeight
|
||||
scrollElement.scrollTop = oldScrollTop + heightDiff
|
||||
})
|
||||
}
|
||||
chatMessageQuery.value.loading = false
|
||||
chatMessageQuery.value.pageNo++
|
||||
// 判断是否还有更多数据
|
||||
if (res.data.list.length < chatMessageQuery.value.pageSize) {
|
||||
chatMessageQuery.value.hasMore = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 滚动处理函数
|
||||
const handleScroll = async (e: Event) => {
|
||||
const target = e.target as HTMLElement
|
||||
// 当滚动到顶部附近时触发加载更多
|
||||
if (target.scrollTop < 50 && !chatMessageQuery.value.loading && chatMessageQuery.value.hasMore && !chatMessageQuery.value.isPending) {
|
||||
// await loadMoreMessages()
|
||||
chatMessageQuery.value.isPending = true
|
||||
await throttledGetChatList()
|
||||
}
|
||||
}
|
||||
|
||||
// 创建节流函数,设置 500ms 的间隔
|
||||
const throttledGetChatList = throttle(async () => {
|
||||
await getChatDetailList()
|
||||
}, 1500)
|
||||
|
||||
const handleSend = (msgType: msgType = 0) => {
|
||||
if (!inputMessage.value.trim()) return
|
||||
|
||||
const newMessage = {
|
||||
msgType: msgType,
|
||||
content: inputMessage.value,
|
||||
toId: chatMessageQuery.value.toId, // 对方userId
|
||||
userId: userStore.userInfoRes.id, // 当前用户id
|
||||
fromId: userStore.userInfoRes.id, // 当前用户id
|
||||
createTime: dayjs(new Date()).format('YYYY-MM-DD HH:mm:ss'), // 当前时间戳
|
||||
}
|
||||
|
||||
chatMessages.value.push(newMessage)
|
||||
userStore.mqttClient?.publish(`zbjk_message_single/${currentUserId.value}`, JSON.stringify(newMessage))
|
||||
|
||||
// 更新用户列表中的最后一条消息
|
||||
userLastMessage(newMessage)
|
||||
// 清空输入框
|
||||
inputMessage.value = ''
|
||||
// 滚动到底部
|
||||
scrollToBottom()
|
||||
// 发送单聊信息存储到服务器
|
||||
sendSingleChat(newMessage)
|
||||
}
|
||||
|
||||
const userLastMessage = (msg: chatMessagesReq) => {
|
||||
console.log('msg', msg)
|
||||
const user = userList.value.find((u) => u.sessionId === currentUserId.value)
|
||||
if (user) {
|
||||
user.lastMsg.content = msg.content
|
||||
user.updateTime = user.createTime = msg.createTime
|
||||
}
|
||||
}
|
||||
|
||||
const scrollToBottom = () => {
|
||||
if (messageList.value) {
|
||||
nextTick(() => {
|
||||
messageList.value.scrollTop = messageList.value.scrollHeight
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
userStore.mqttClient?.onMessage((topic: string, message: any) => {
|
||||
if (topic.indexOf(`zbjk_message_single`) === -1) return
|
||||
console.log('接收消息---------', topic, message)
|
||||
console.log('当前用户id', userStore.userInfoRes.id)
|
||||
console.log('当前聊天用户id', currentUserId.value)
|
||||
|
||||
// 将消息添加到聊天记录中
|
||||
const msg = JSON.parse(message)
|
||||
if (msg.sessionId === currentUserId.value) {
|
||||
msg.msgType = Number(msg.msgType)
|
||||
// 当前用户发送的消息
|
||||
chatMessages.value.push(msg)
|
||||
// 更新当前用户列表中的最后一条消息
|
||||
userLastMessage(msg)
|
||||
// 清空未读消息
|
||||
clearUnreadMessage({ id: msg.sessionId })
|
||||
if (msg.msgType === 1) {
|
||||
const img = new Image()
|
||||
img.src = msg.content
|
||||
img.onload = () => {
|
||||
// 滚动到底部
|
||||
scrollToBottom()
|
||||
}
|
||||
} else {
|
||||
// 滚动到底部
|
||||
scrollToBottom()
|
||||
}
|
||||
} else {
|
||||
// 添加未读消息
|
||||
const user = userList.value.find((u) => u.sessionId === msg.sessionId)
|
||||
if (user) {
|
||||
user.unreadCount++
|
||||
user.updateTime = user.createTime = msg.createTime
|
||||
user.lastMsg.content = msg.content
|
||||
// 正常会拉取后端聊天接口
|
||||
} else {
|
||||
getConversationList('refresh')
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
document.addEventListener('click', (event) => {
|
||||
const target = event.target as HTMLElement
|
||||
if (!target.closest('.emoji-popover') && !target.closest('.emoji-trigger')) {
|
||||
showEmoji.value = false
|
||||
}
|
||||
})
|
||||
})
|
||||
// 触发图片上传
|
||||
const imageInputRef = ref()
|
||||
const triggerImageUpload = (): void => {
|
||||
if (imageInputRef.value) {
|
||||
imageInputRef.value.click()
|
||||
}
|
||||
}
|
||||
|
||||
// 处理图片上传
|
||||
const handleImageUpload = async (event: Event) => {
|
||||
const target = event.target as HTMLInputElement
|
||||
const files = target.files
|
||||
|
||||
if (files && files.length > 0) {
|
||||
const file = files[0]
|
||||
|
||||
// 检查文件类型 0:文本 1:图片 2:视频 3:文件
|
||||
const msgType = file.type.startsWith('image/') ? 1 : file.type.startsWith('video/') ? 2 : 3
|
||||
const formData = new FormData()
|
||||
formData.append('fieldName', file?.name)
|
||||
formData.append('file', file as Blob)
|
||||
const res = await upload('/prod-api/app-api/infra/file/upload', formData)
|
||||
if (res.code === 0) {
|
||||
const imageUrl = res.data
|
||||
if (msgType === 1) {
|
||||
// 预加载图片
|
||||
const img = new Image()
|
||||
img.src = imageUrl
|
||||
img.onload = () => {
|
||||
inputMessage.value = imageUrl
|
||||
handleSend(msgType)
|
||||
}
|
||||
} else {
|
||||
inputMessage.value = imageUrl
|
||||
handleSend(msgType)
|
||||
}
|
||||
}
|
||||
|
||||
// 重置文件输入以允许重复选择同一文件
|
||||
if (imageInputRef.value) {
|
||||
imageInputRef.value.value = ''
|
||||
}
|
||||
}
|
||||
}
|
||||
const showEmoji = ref(false)
|
||||
const emojiList = [
|
||||
'😀',
|
||||
'😃',
|
||||
'😄',
|
||||
'😁',
|
||||
'😆',
|
||||
'😅',
|
||||
'😂',
|
||||
'🤣',
|
||||
'😊',
|
||||
'😇',
|
||||
'🙂',
|
||||
'🙃',
|
||||
'😉',
|
||||
'😌',
|
||||
'😍',
|
||||
'🥰',
|
||||
'😘',
|
||||
'😗',
|
||||
'😙',
|
||||
'😚',
|
||||
'😋',
|
||||
'😛',
|
||||
'😝',
|
||||
'😜',
|
||||
'🤪',
|
||||
'🤨',
|
||||
'🧐',
|
||||
'🤓',
|
||||
'😎',
|
||||
'🤩',
|
||||
'🥳',
|
||||
'😏',
|
||||
'😒',
|
||||
'😞',
|
||||
'😔',
|
||||
'😟',
|
||||
'😕',
|
||||
'🙁',
|
||||
'☹️',
|
||||
'😣',
|
||||
]
|
||||
|
||||
const insertEmoji = (emoji: string) => {
|
||||
inputMessage.value += emoji
|
||||
showEmoji.value = false
|
||||
}
|
||||
|
||||
const closeDialog = () => {
|
||||
dialogVisible.value = false
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.emoji-list {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(10, 1fr);
|
||||
gap: 8px;
|
||||
|
||||
.emoji-item {
|
||||
cursor: pointer;
|
||||
font-size: 20px;
|
||||
padding: 4px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
transition: all 0.2s;
|
||||
|
||||
&:hover {
|
||||
background: #f5f5f5;
|
||||
border-radius: 4px;
|
||||
transform: scale(1.2);
|
||||
}
|
||||
}
|
||||
}
|
||||
.chat-dialog {
|
||||
:deep(.el-dialog__header) {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border-radius: 8px 8px 0 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
:deep(.el-dialog__body) {
|
||||
padding: 0px !important;
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
:deep(.el-dialog) {
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 12px 32px 4px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
:deep(.el-dialog__headerbtn) {
|
||||
top: 24px;
|
||||
right: 12px;
|
||||
z-index: 10;
|
||||
|
||||
.el-dialog__close {
|
||||
font-size: 16px;
|
||||
transition: all 0.3s;
|
||||
|
||||
&:hover {
|
||||
opacity: 0.8;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.dialog-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 0 16px;
|
||||
// height: 40px;
|
||||
|
||||
.title {
|
||||
font-size: 14px;
|
||||
font-weight: normal;
|
||||
}
|
||||
}
|
||||
|
||||
.chat-layout {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.user-list {
|
||||
width: 280px;
|
||||
border-right: 1px solid #eee;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
background-color: #34353a;
|
||||
|
||||
.search-box {
|
||||
padding: 12px 12px 12px 12px;
|
||||
:deep(.el-input__wrapper) {
|
||||
background-color: #4f5054 !important;
|
||||
box-shadow: none !important;
|
||||
}
|
||||
:deep(.el-input__inner) {
|
||||
color: #fff;
|
||||
border-radius: 16px;
|
||||
border: none;
|
||||
|
||||
&:focus {
|
||||
box-shadow: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.user-items {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
|
||||
.user-item {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
padding: 12px;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s;
|
||||
|
||||
&:hover {
|
||||
// background-color: #f5f5f5;
|
||||
}
|
||||
|
||||
&.active {
|
||||
background-color: rgba(255, 255, 255, 0.12) !important;
|
||||
}
|
||||
|
||||
.user-info {
|
||||
flex: 1;
|
||||
margin: 0 12px;
|
||||
overflow: hidden;
|
||||
|
||||
.user-name {
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
margin-bottom: 4px;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.last-message {
|
||||
font-size: 14px;
|
||||
color: #999;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
}
|
||||
|
||||
.message-status {
|
||||
text-align: right;
|
||||
|
||||
.time {
|
||||
font-size: 12px;
|
||||
color: #999;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.unread-badge {
|
||||
:deep(.el-badge__content) {
|
||||
background-color: #c561f9;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.chat-container {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
.chat-header {
|
||||
padding: 16px 20px;
|
||||
background: #fff;
|
||||
border-bottom: 1px solid #eee;
|
||||
|
||||
.header-left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
|
||||
.title-info {
|
||||
.title {
|
||||
font-size: 16px;
|
||||
font-weight: 500;
|
||||
color: #333;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.subtitle {
|
||||
font-size: 12px;
|
||||
color: #999;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.message-list {
|
||||
flex: 1;
|
||||
padding: 24px;
|
||||
box-sizing: border-box;
|
||||
overflow-y: auto;
|
||||
background-color: #f7f8fa;
|
||||
min-height: 300px;
|
||||
.load-more {
|
||||
text-align: center;
|
||||
padding: 10px 0;
|
||||
color: #999;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.message-item {
|
||||
display: flex;
|
||||
margin-bottom: 24px;
|
||||
|
||||
&.message-sent {
|
||||
flex-direction: row-reverse;
|
||||
|
||||
.message-content {
|
||||
margin-right: 12px;
|
||||
margin-left: 80px;
|
||||
align-items: flex-end;
|
||||
|
||||
.message-bubble {
|
||||
background: #1a65ff;
|
||||
color: #fff;
|
||||
border-radius: 12px 2px 12px 12px;
|
||||
box-shadow: 0 4px 12px rgba(197, 97, 249, 0.2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&.message-received {
|
||||
.message-content {
|
||||
margin-left: 12px;
|
||||
margin-right: 80px;
|
||||
|
||||
.message-bubble {
|
||||
background-color: #fff;
|
||||
border-radius: 2px 12px 12px 12px;
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.message-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
.message-bubble {
|
||||
padding: 12px 16px;
|
||||
font-size: 14px;
|
||||
max-width: 400px;
|
||||
word-break: break-word;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.message-time {
|
||||
font-size: 12px;
|
||||
color: #999;
|
||||
margin-top: 6px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.input-area {
|
||||
background-color: #fff;
|
||||
border-top: 1px solid #eee;
|
||||
padding: 16px 24px;
|
||||
box-sizing: border-box;
|
||||
|
||||
.toolbar {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
padding: 0 0 12px;
|
||||
|
||||
.tool-left {
|
||||
display: flex;
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
.tool-icon {
|
||||
font-size: 20px;
|
||||
color: #666;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s;
|
||||
|
||||
&:hover {
|
||||
color: #c561f9;
|
||||
transform: scale(1.1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.input-box {
|
||||
margin-bottom: 12px;
|
||||
|
||||
:deep(.el-textarea__inner) {
|
||||
border: 1px solid #fff !important;
|
||||
border-radius: 8px;
|
||||
padding: 12px;
|
||||
font-size: 14px;
|
||||
transition: all 0.3s;
|
||||
outline: none !important;
|
||||
box-shadow: none !important;
|
||||
|
||||
&:focus {
|
||||
border-color: #c561f9;
|
||||
box-shadow: none !important;
|
||||
// box-shadow: 0 0 0 2px rgba(197, 97, 249, 0.1);
|
||||
}
|
||||
|
||||
&::placeholder {
|
||||
color: #999;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.send-btn {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
|
||||
.el-button {
|
||||
background: #1a65ff;
|
||||
border: none;
|
||||
padding: 10px 24px;
|
||||
font-size: 14px;
|
||||
border-radius: 8px;
|
||||
transition: all 0.3s;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
|
||||
.send-icon {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
transform: translateY(-1px);
|
||||
// box-shadow: 0 4px 12px rgba(197, 97, 249, 0.3);
|
||||
}
|
||||
|
||||
&:active {
|
||||
transform: translateY(0);
|
||||
}
|
||||
|
||||
&.is-disabled {
|
||||
background: #e0e0e0;
|
||||
opacity: 0.6;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 自定义滚动条样式
|
||||
.message-list {
|
||||
&::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
}
|
||||
|
||||
&::-webkit-scrollbar-thumb {
|
||||
background-color: rgba(0, 0, 0, 0.1);
|
||||
border-radius: 3px;
|
||||
|
||||
&:hover {
|
||||
background-color: rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
}
|
||||
|
||||
&::-webkit-scrollbar-track {
|
||||
background-color: transparent;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
61
pages/personal-Center/components/components/pay-records.vue
Normal file
61
pages/personal-Center/components/components/pay-records.vue
Normal file
@ -0,0 +1,61 @@
|
||||
<template>
|
||||
<!-- 交易记录表格 -->
|
||||
<el-table v-loading="result.loading" :data="result.data" style="width: 100%">
|
||||
<el-table-column prop="bizType" label="交易分类">
|
||||
<template #default="{ row }">
|
||||
{{ bizTypeMap[row.bizType as number] || '未知' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="price" label="交易金额"> </el-table-column>
|
||||
<el-table-column prop="title" label="标题" />
|
||||
<el-table-column prop="createTime" label="交易时间">
|
||||
<template #default="{ row }">
|
||||
{{ dayjs(row.createTime).format('YYYY-MM-DD HH:mm:ss') }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<!-- 分页 -->
|
||||
<div class="pagination mt-15px">
|
||||
<el-pagination v-model:current-page="query.pageNo" :page-size="10" :total="result.total" background layout="prev, pager, next, jumper" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { reactive } from 'vue'
|
||||
// import { accDiv } from '@/utils/utils'
|
||||
import dayjs from 'dayjs'
|
||||
import { bizTypeMap } from '@/enum/index'
|
||||
import { getWalletRechargeRecordPage } from '@/api/pay/index'
|
||||
import { AppPayWalletRechargeRespVO } from '@/api/pay/types'
|
||||
|
||||
const result = reactive({
|
||||
data: [] as AppPayWalletRechargeRespVO[],
|
||||
total: 0,
|
||||
loading: false,
|
||||
})
|
||||
const query = reactive({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
})
|
||||
|
||||
// 获取交易记录
|
||||
const getTradeRecords = async () => {
|
||||
try {
|
||||
result.loading = true
|
||||
const res = await getWalletRechargeRecordPage(query)
|
||||
result.data = res.data.list || []
|
||||
result.total = res.data.total || 0
|
||||
} finally {
|
||||
result.loading = false
|
||||
}
|
||||
}
|
||||
getTradeRecords()
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
:deep(.el-pagination) {
|
||||
.el-input__inner {
|
||||
text-align: center !important;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
237
pages/personal-Center/components/components/pay.vue
Normal file
237
pages/personal-Center/components/components/pay.vue
Normal file
@ -0,0 +1,237 @@
|
||||
<template>
|
||||
<el-dialog v-model="visible" width="800px" class="vip-dialog" align-center>
|
||||
<template #header>
|
||||
<div class="vip-modal-title">钱包充值</div>
|
||||
</template>
|
||||
<div v-loading="loading" class="vip-cards">
|
||||
<div v-for="item in viplist" :key="item.id" class="vip-card">
|
||||
<div class="relative w-100% flex flex-col items-center">
|
||||
<div class="vip-card-header basic">
|
||||
<div class="vip-card-title">{{ item.name }}</div>
|
||||
<!-- <div class="vip-card-subtitle">中小微企业</div> -->
|
||||
</div>
|
||||
<div class="vip-card-price">
|
||||
<span class="price">¥{{ accDiv(item.payPrice || 0, 100) }}</span>
|
||||
<!-- <span class="per">/1年</span> -->
|
||||
</div>
|
||||
<ul class="vip-card-features">
|
||||
<li
|
||||
>赠送<span class="color-red">¥{{ accDiv(item.bonusPrice || 0, 100) }}</span></li
|
||||
>
|
||||
<!-- <li>1. {{ item.profile }}</li>
|
||||
<li
|
||||
>2. 佣金比例<span class="color-red">{{ item.brokerageRate }}</span
|
||||
>%</li
|
||||
> -->
|
||||
</ul>
|
||||
<div v-if="item.qrCodeUrl" class="vip-card-qrcode">
|
||||
<el-icon class="absolute right--10px top-0px cursor-pointer" @click="item.qrCodeUrl = ''"><Close /></el-icon>
|
||||
<qrcode-vue :value="item.qrCodeUrl" :size="140" level="H" />
|
||||
<div>请使用微信扫二维码</div>
|
||||
</div>
|
||||
</div>
|
||||
<el-button class="vip-card-btn" :loading="item.btnloading" @click="pay(item)">立即充值</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, watch, onMounted } from 'vue'
|
||||
import { listWalletRechargePackage, submitPayOrder, getPayStatus } from '@/api/pay/index'
|
||||
import { accDiv } from '@/utils/utils'
|
||||
import { Close } from '@element-plus/icons-vue'
|
||||
import type { AppPayWalletPackageRespVO } from '@/api/pay/types'
|
||||
// @ts-ignore
|
||||
import QrcodeVue from 'qrcode.vue'
|
||||
import useUserStore from '@/store/user'
|
||||
const userStore = useUserStore()
|
||||
|
||||
const props = defineProps({
|
||||
modelValue: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
})
|
||||
const emit = defineEmits(['update:modelValue', 'refresh'])
|
||||
|
||||
const visible = ref(props.modelValue)
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
(val) => (visible.value = val)
|
||||
)
|
||||
watch(visible, (val) => emit('update:modelValue', val))
|
||||
|
||||
const viplist = ref<AppPayWalletPackageRespVO[]>([])
|
||||
const loading = ref(false)
|
||||
const init = async () => {
|
||||
try {
|
||||
loading.value = true
|
||||
const res = await listWalletRechargePackage()
|
||||
viplist.value = res.data
|
||||
} finally {
|
||||
loading.value = false
|
||||
console.log(viplist.value)
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
init()
|
||||
})
|
||||
|
||||
const orderId = ref(0)
|
||||
const pay = async (row: AppPayWalletPackageRespVO) => {
|
||||
if (row.qrCodeUrl) return ElMessage.error('支付二维码已生成,请勿重复生成')
|
||||
viplist.value.forEach((item) => {
|
||||
if (item.id !== row.id) {
|
||||
item.qrCodeUrl = ''
|
||||
}
|
||||
})
|
||||
try {
|
||||
row.btnloading = true
|
||||
const res = await submitPayOrder({
|
||||
id: row.id,
|
||||
memberId: userStore.userId, // 用户id
|
||||
channelCode: 'wx_native',
|
||||
})
|
||||
if (res.code === 0) {
|
||||
row.qrCodeUrl = res.data.displayContent
|
||||
orderId.value = res.data.orderId
|
||||
// 打开轮询任务
|
||||
createQueryInterval(row)
|
||||
}
|
||||
} finally {
|
||||
row.btnloading = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 轮询查询任务 */
|
||||
const interval = ref()
|
||||
const createQueryInterval = (row: AppPayWalletPackageRespVO) => {
|
||||
if (interval.value) {
|
||||
return
|
||||
}
|
||||
interval.value = setInterval(async () => {
|
||||
const data = await getPayStatus({ id: orderId.value })
|
||||
// 已支付
|
||||
if (data.data.status === 10) {
|
||||
clearQueryInterval(row)
|
||||
ElMessage.success('支付成功!')
|
||||
emit('refresh')
|
||||
}
|
||||
// 已取消
|
||||
if (data.data.status === 20) {
|
||||
clearQueryInterval(row)
|
||||
ElMessage.error('支付已关闭!')
|
||||
}
|
||||
}, 1000 * 2)
|
||||
}
|
||||
|
||||
/** 清空查询任务 */
|
||||
const clearQueryInterval = (row: AppPayWalletPackageRespVO) => {
|
||||
// 清空各种弹窗
|
||||
row.qrCodeUrl = ''
|
||||
// 清空任务
|
||||
clearInterval(interval.value)
|
||||
interval.value = undefined
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.vip-modal-title {
|
||||
text-align: center;
|
||||
font-size: 20px;
|
||||
font-weight: bold;
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
.vip-cards {
|
||||
display: flex;
|
||||
gap: 32px;
|
||||
justify-content: center;
|
||||
margin: 24px 0;
|
||||
}
|
||||
.vip-card {
|
||||
background: #fff;
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
|
||||
padding: 24px 32px;
|
||||
width: 260px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
padding-bottom: 70px;
|
||||
position: relative;
|
||||
}
|
||||
.vip-card-header {
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
padding-bottom: 12px;
|
||||
border-radius: 8px 8px 0 0;
|
||||
margin-bottom: 12px;
|
||||
padding: 10px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.vip-card-header.basic {
|
||||
background: linear-gradient(90deg, #f7b7a3, #e97c6a);
|
||||
}
|
||||
.vip-card-header.pro {
|
||||
background: linear-gradient(90deg, #f7b7a3, #e97c6a);
|
||||
}
|
||||
.vip-card-title {
|
||||
font-size: 20px;
|
||||
font-weight: bold;
|
||||
color: #fff;
|
||||
}
|
||||
.vip-card-subtitle {
|
||||
font-size: 14px;
|
||||
color: #fff;
|
||||
}
|
||||
.vip-card-price {
|
||||
margin: 12px 0;
|
||||
font-size: 28px;
|
||||
color: #e74c3c;
|
||||
font-weight: bold;
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 8px;
|
||||
}
|
||||
.vip-card-price .origin {
|
||||
font-size: 16px;
|
||||
color: #bbb;
|
||||
text-decoration: line-through;
|
||||
margin-left: 4px;
|
||||
}
|
||||
.vip-card-price .per {
|
||||
font-size: 16px;
|
||||
color: #888;
|
||||
margin-left: 4px;
|
||||
}
|
||||
.vip-card-features {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
margin: 0 0 16px 0;
|
||||
color: #444;
|
||||
font-size: 15px;
|
||||
}
|
||||
.vip-card-features li {
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
.vip-card-features .highlight {
|
||||
color: #e74c3c;
|
||||
font-weight: bold;
|
||||
}
|
||||
.vip-card-btn {
|
||||
width: 80%;
|
||||
margin-top: 8px;
|
||||
border-radius: 24px;
|
||||
position: absolute;
|
||||
bottom: 20px;
|
||||
}
|
||||
:deep(.vip-card-qrcode) {
|
||||
position: absolute !important;
|
||||
inset: 0 !important;
|
||||
z-index: 1;
|
||||
text-align: center;
|
||||
background-color: #fff;
|
||||
}
|
||||
</style>
|
||||
119
pages/personal-Center/components/components/upload-table.vue
Normal file
119
pages/personal-Center/components/components/upload-table.vue
Normal file
@ -0,0 +1,119 @@
|
||||
<template>
|
||||
<KlTabBar v-model="type" :data="tabBar" @change="props.refresh()" />
|
||||
<el-table :data="modelValue" style="width: 100%" class="mt-14px">
|
||||
<el-table-column prop="date" label="文件信息">
|
||||
<template #default="scope">
|
||||
<div class="flex items-center">
|
||||
<el-image :src="scope.row.iconUrl" fit="cover" alt="" srcset="" class="h-91px w-181px rd-4px" />
|
||||
<div class="ml-17px">
|
||||
<div class="text-16px text-[#333333] font-normal">{{ scope.row.title }}</div>
|
||||
<div class="text-14px text-[#333333] font-normal my-10px!">{{ dayjs(scope.row.createTime).format('YYYY-MM-DD HH:mm:ss') }}</div>
|
||||
<div class="flex items-center">
|
||||
<div class="flex items-center">
|
||||
<img src="@/assets/images/look.png" alt="" srcset="" class="h-17px" />
|
||||
<span class="ml-4px">{{ scope.row.previewPoint }}</span>
|
||||
</div>
|
||||
<div class="ml-13px flex items-center">
|
||||
<img src="@/assets/images/add.png" alt="" srcset="" class="h-23px" />
|
||||
<span class="ml-4px">{{ scope.row.hotPoint }}</span>
|
||||
</div>
|
||||
<div class="ml-13px flex items-center">
|
||||
<img src="@/assets/images/chat.png" alt="" srcset="" class="h-17px" />
|
||||
<span class="ml-4px">{{ scope.row.commentsPoint }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="status" label="上传状态" width="180">
|
||||
<template #default="scope">
|
||||
{{ handleStatus(scope.row.status) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="address" label="操作" width="100">
|
||||
<template #default="scope">
|
||||
<el-link v-if="scope.row.status === 4" type="primary" :underline="false" @click="handleXiaJia(scope.row)">下架</el-link>
|
||||
<el-link type="primary" :underline="false" @click="handleDelete(scope.row)">删除</el-link>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue'
|
||||
|
||||
import { offShelf, deleteResource } from '@/api/personal-center'
|
||||
|
||||
import KlTabBar from '@/components/kl-tab-bar/v2/index.vue'
|
||||
import dayjs from 'dayjs'
|
||||
import { useMessage } from '@/utils/useMessage'
|
||||
const message = useMessage()
|
||||
|
||||
const type = defineModel<number | string>('type', {
|
||||
required: true,
|
||||
}) // 双向绑定的value
|
||||
const modelValue = defineModel<any>('modelValue', {
|
||||
required: true,
|
||||
}) // 双向绑定的value
|
||||
|
||||
const props = defineProps({
|
||||
// 刷新
|
||||
refresh: {
|
||||
type: Function,
|
||||
default: () => Function,
|
||||
},
|
||||
})
|
||||
|
||||
const tabBar = ref([
|
||||
{
|
||||
label: '图纸',
|
||||
value: 1,
|
||||
},
|
||||
{
|
||||
label: '模型',
|
||||
value: 3,
|
||||
},
|
||||
{
|
||||
label: '文本',
|
||||
value: 2,
|
||||
},
|
||||
])
|
||||
|
||||
const handleStatus = (status: number) => {
|
||||
switch (status) {
|
||||
case 1:
|
||||
return '草稿'
|
||||
case 2:
|
||||
return '提交审核'
|
||||
case 3:
|
||||
return '审核成功'
|
||||
case 4:
|
||||
return '下架'
|
||||
default:
|
||||
return ''
|
||||
}
|
||||
}
|
||||
|
||||
const handleXiaJia = (row: any) => {
|
||||
offShelf(row.id).then((res: any) => {
|
||||
if (res.code === 0) {
|
||||
ElMessage.success('下架成功')
|
||||
props.refresh()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const handleDelete = async (row: any) => {
|
||||
const r = await message.confirm('是否删除该资源', '提示')
|
||||
if (!r) return
|
||||
deleteResource({ id: row.id }).then((res: any) => {
|
||||
if (res.code === 0) {
|
||||
ElMessage.success('删除成功')
|
||||
props.refresh()
|
||||
}
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
325
pages/personal-Center/components/info-echarts.vue
Normal file
325
pages/personal-Center/components/info-echarts.vue
Normal file
@ -0,0 +1,325 @@
|
||||
<template>
|
||||
<div class="dashboard">
|
||||
<div class="chart-row">
|
||||
<div class="chart-container">
|
||||
<div ref="incomeChartRef" class="chart"></div>
|
||||
</div>
|
||||
<div class="chart-container">
|
||||
<div ref="activeChartRef" class="chart"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="chart-container full-width">
|
||||
<div ref="downloadChartRef" class="chart"></div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref, onUnmounted } from 'vue'
|
||||
import * as echarts from 'echarts'
|
||||
import { getRecentIncomeAndActive, getResourceDistribution } from '@/api/personal-center/index'
|
||||
|
||||
const incomeChartRef = ref<HTMLElement>()
|
||||
const activeChartRef = ref<HTMLElement>()
|
||||
const downloadChartRef = ref<HTMLElement>()
|
||||
let incomeChart: echarts.ECharts | null = null
|
||||
let activeChart: echarts.ECharts | null = null
|
||||
let downloadChart: echarts.ECharts | null = null
|
||||
|
||||
// 收益图表配置
|
||||
const incomeOption = {
|
||||
title: {
|
||||
text: '近7天收益',
|
||||
top: 6,
|
||||
left: 10,
|
||||
// 添加样式属性
|
||||
textStyle: {
|
||||
fontSize: 16, // 字体大小
|
||||
color: '#333', // 字体颜色
|
||||
fontWeight: 400, // 字体粗细
|
||||
},
|
||||
},
|
||||
tooltip: {
|
||||
trigger: 'axis',
|
||||
},
|
||||
grid: {
|
||||
top: '20%',
|
||||
left: '4%',
|
||||
right: '6%',
|
||||
bottom: '3%',
|
||||
containLabel: true,
|
||||
},
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
boundaryGap: false,
|
||||
data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'],
|
||||
},
|
||||
yAxis: {
|
||||
type: 'value',
|
||||
min: 0,
|
||||
// max: 6000,
|
||||
},
|
||||
series: [
|
||||
{
|
||||
name: '收益',
|
||||
type: 'line',
|
||||
smooth: true,
|
||||
areaStyle: {
|
||||
opacity: 0.3,
|
||||
color: '#4B7BEC',
|
||||
},
|
||||
lineStyle: {
|
||||
color: '#4B7BEC',
|
||||
},
|
||||
data: [4000, 4500, 4200, 3800, 2800, 2600, 3200],
|
||||
markLine: {
|
||||
silent: true,
|
||||
lineStyle: {
|
||||
type: 'dashed',
|
||||
color: '#4B7BEC',
|
||||
},
|
||||
data: [
|
||||
{
|
||||
xAxis: 4,
|
||||
},
|
||||
],
|
||||
},
|
||||
markPoint: {
|
||||
data: [
|
||||
{
|
||||
coord: [4, 0.2],
|
||||
value: '今日收益\n3624',
|
||||
symbol: 'circle',
|
||||
symbolSize: 8,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
// 活跃度图表配置
|
||||
const activeOption = {
|
||||
title: {
|
||||
text: '近7天活跃度',
|
||||
top: 6,
|
||||
left: 10,
|
||||
// 添加样式属性
|
||||
textStyle: {
|
||||
fontSize: 16, // 字体大小
|
||||
color: '#333', // 字体颜色
|
||||
fontWeight: 400, // 字体粗细
|
||||
},
|
||||
},
|
||||
tooltip: {
|
||||
trigger: 'axis',
|
||||
},
|
||||
grid: {
|
||||
top: '20%',
|
||||
left: '4%',
|
||||
right: '7%',
|
||||
bottom: '3%',
|
||||
containLabel: true,
|
||||
},
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
boundaryGap: false,
|
||||
data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'],
|
||||
},
|
||||
yAxis: {
|
||||
type: 'value',
|
||||
min: 0,
|
||||
// max: 600,
|
||||
},
|
||||
series: [
|
||||
{
|
||||
name: '活跃度',
|
||||
type: 'line',
|
||||
smooth: true,
|
||||
areaStyle: {
|
||||
opacity: 0.3,
|
||||
color: '#4B7BEC',
|
||||
},
|
||||
lineStyle: {
|
||||
color: '#4B7BEC',
|
||||
},
|
||||
data: [400, 450, 420, 360, 280, 260, 320],
|
||||
markLine: {
|
||||
silent: true,
|
||||
lineStyle: {
|
||||
type: 'dashed',
|
||||
color: '#4B7BEC',
|
||||
},
|
||||
data: [
|
||||
{
|
||||
xAxis: 3,
|
||||
},
|
||||
],
|
||||
},
|
||||
markPoint: {
|
||||
data: [
|
||||
{
|
||||
coord: [3, 360],
|
||||
value: '今日活跃度\n360次',
|
||||
symbol: 'circle',
|
||||
symbolSize: 8,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
// 下载分布图表配置
|
||||
const downloadOption = {
|
||||
title: {
|
||||
text: '资源下载分布',
|
||||
top: 6,
|
||||
left: 10,
|
||||
// 添加样式属性
|
||||
textStyle: {
|
||||
fontSize: 16, // 字体大小
|
||||
color: '#333', // 字体颜色
|
||||
fontWeight: 400, // 字体粗细
|
||||
},
|
||||
},
|
||||
tooltip: {
|
||||
trigger: 'axis',
|
||||
},
|
||||
legend: {
|
||||
data: ['图纸', '文本', '模型'],
|
||||
right: 10,
|
||||
top: 10,
|
||||
},
|
||||
grid: {
|
||||
top: '20%',
|
||||
left: '2%',
|
||||
right: '4%',
|
||||
bottom: '3%',
|
||||
containLabel: true,
|
||||
},
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
data: ['1月1日', '1月2日', '1月3日', '1月4日', '1月5日', '1月6日', '1月7日', '1月8日', '1月9日', '1月10日'],
|
||||
},
|
||||
yAxis: {
|
||||
type: 'value',
|
||||
max: 600,
|
||||
},
|
||||
series: [
|
||||
{
|
||||
name: '图纸',
|
||||
type: 'bar',
|
||||
data: [220, 340, 220, 340, 220, 340, 220, 340, 220, 340],
|
||||
color: '#2ECC71',
|
||||
},
|
||||
{
|
||||
name: '文本',
|
||||
type: 'bar',
|
||||
data: [300, 430, 320, 430, 320, 430, 320, 430, 320, 430],
|
||||
color: '#4B7BEC',
|
||||
},
|
||||
{
|
||||
name: '模型',
|
||||
type: 'bar',
|
||||
data: [340, 280, 340, 280, 340, 280, 340, 280, 340, 280],
|
||||
color: '#FFA502',
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
// 初始化图表
|
||||
const initCharts = async () => {
|
||||
// 获取今天星期几
|
||||
// const today = new Date().getDay()
|
||||
|
||||
if (incomeChartRef.value) {
|
||||
const res = await getRecentIncomeAndActive({
|
||||
type: 1,
|
||||
limit: 7,
|
||||
})
|
||||
incomeOption.xAxis.data = res.data.xaxis
|
||||
incomeOption.series[0].data = res.data.data
|
||||
const index = res.data.xaxis.findIndex((item) => item === res.data.checkedXAxis)
|
||||
incomeOption.series[0].markLine.data[0].xAxis = index
|
||||
incomeOption.series[0].markPoint.data[0].coord = [index, res.data.data[index]]
|
||||
incomeOption.series[0].markPoint.data[0].value = `今日收益\n${res.data.data[index]}`
|
||||
incomeChart = echarts.init(incomeChartRef.value)
|
||||
incomeChart.setOption(incomeOption)
|
||||
}
|
||||
if (activeChartRef.value) {
|
||||
const res = await getRecentIncomeAndActive({
|
||||
type: 2,
|
||||
limit: 7,
|
||||
})
|
||||
activeOption.xAxis.data = res.data.xaxis
|
||||
activeOption.series[0].data = res.data.data
|
||||
const index = res.data.xaxis.findIndex((item) => item === res.data.checkedXAxis)
|
||||
activeOption.series[0].markLine.data[0].xAxis = index
|
||||
activeOption.series[0].markPoint.data[0].coord = [index, res.data.data[index]]
|
||||
activeOption.series[0].markPoint.data[0].value = `今日活跃度\n${res.data.data[index]}`
|
||||
activeChart = echarts.init(activeChartRef.value)
|
||||
activeChart.setOption(activeOption)
|
||||
}
|
||||
if (downloadChartRef.value) {
|
||||
const res = await getResourceDistribution({
|
||||
type: 3,
|
||||
limit: 10,
|
||||
})
|
||||
downloadOption.xAxis.data = res.data.xaxis
|
||||
downloadOption.series[0].data = res.data.series[0].data
|
||||
downloadOption.series[1].data = res.data.series[1].data
|
||||
downloadOption.series[2].data = res.data.series[2].data
|
||||
downloadChart = echarts.init(downloadChartRef.value)
|
||||
downloadChart.setOption(downloadOption)
|
||||
}
|
||||
}
|
||||
|
||||
// 监听窗口大小变化
|
||||
const handleResize = () => {
|
||||
incomeChart?.resize()
|
||||
activeChart?.resize()
|
||||
downloadChart?.resize()
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
initCharts()
|
||||
window.addEventListener('resize', handleResize)
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
incomeChart?.dispose()
|
||||
activeChart?.dispose()
|
||||
downloadChart?.dispose()
|
||||
window.removeEventListener('resize', handleResize)
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.dashboard {
|
||||
/* padding: 20px; */
|
||||
/* background-color: #f5f6fa; */
|
||||
margin-top: 24px;
|
||||
width: 913px;
|
||||
}
|
||||
|
||||
.chart-row {
|
||||
display: flex;
|
||||
gap: 20px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.chart-container {
|
||||
flex: 1;
|
||||
padding: 15px;
|
||||
/* box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05); */
|
||||
background: #ffffff;
|
||||
border-radius: 6px;
|
||||
border: 1px solid #eeeeee;
|
||||
}
|
||||
|
||||
.chart {
|
||||
width: 100%;
|
||||
height: 300px;
|
||||
}
|
||||
</style>
|
||||
192
pages/personal-Center/components/info.vue
Normal file
192
pages/personal-Center/components/info.vue
Normal file
@ -0,0 +1,192 @@
|
||||
<template>
|
||||
<div class="box-border w-913px border border-[#EEEEEE] rounded-6px border-solid bg-[#FFFFFF] px-30px py-18px">
|
||||
<div class="flex items-center">
|
||||
<img :src="userStore.userInfoRes.avatar" alt="" srcset="" class="h-105px w-105px rounded-full" />
|
||||
<div class="ml-29px">
|
||||
<div class="flex items-center">
|
||||
<span class="text-20px text-[#333333] font-normal">Hi,{{ userStore.userInfoRes.nickname }}</span>
|
||||
<img v-if="userStore.userInfoRes.vipLevel === 1" src="@/assets/svg/vip.svg" alt="" class="relative top-2px ml-5px" />
|
||||
<img v-if="userStore.userInfoRes.vipLevel === 2" src="@/assets/svg/svip.svg" alt="" class="relative top-2px ml-5px" />
|
||||
<div
|
||||
class="ml-18px h-30px w-80px cursor-pointer border border-[#1A65FF] rounded-15px border-solid text-center text-14px text-[#1A65FF] font-normal line-height-30px"
|
||||
@click="handleClick"
|
||||
>编辑资料</div
|
||||
>
|
||||
</div>
|
||||
<div class="mt-20px flex items-center text-14px text-[#333333] font-normal">
|
||||
<div class="flex items-center">
|
||||
<img src="@/assets/images/cad_0 (1).png" alt="" srcset="" />
|
||||
<span class="ml-4px">我的积分: {{ userStaticInfo?.pointCount || 0 }}</span>
|
||||
</div>
|
||||
<div class="ml-37px flex items-center">
|
||||
<img src="@/assets/images/cad_0 (2).png" alt="" srcset="" />
|
||||
<span class="ml-4px">我的收藏: {{ userStaticInfo?.followCount || 0 }}</span>
|
||||
</div>
|
||||
<div class="ml-37px flex items-center">
|
||||
<img src="@/assets/images/cad_0 (3).png" alt="" srcset="" />
|
||||
<span class="ml-4px">我的发布: {{ userStaticInfo?.projectCount || 0 }}</span>
|
||||
</div>
|
||||
<div class="ml-37px flex items-center">
|
||||
<img src="@/assets/images/cad_0 (4).png" alt="" srcset="" />
|
||||
<span class="ml-4px">我的下载: {{ userStaticInfo?.downloadCount || 0 }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-30px flex items-center justify-around">
|
||||
<div class="flex items-center">
|
||||
<div class="relative">
|
||||
<img src="@/assets/images/info_1 (3).png" alt="" srcset="" />
|
||||
<img src="@/assets/images/info_1 (4).png" alt="" srcset="" class="absolute left-18px top-18px" />
|
||||
</div>
|
||||
<div class="ml-18px">
|
||||
<div class="flex items-center">
|
||||
<span class="info_num text-[#17A86D]">{{ userStaticInfo?.currencyCount || 0 }}</span>
|
||||
<div class="info_pay cursor-pointer" @click="handlePay">充值</div>
|
||||
</div>
|
||||
<div class="font">金币余额</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-center">
|
||||
<div class="relative">
|
||||
<img src="@/assets/images/info_1 (5).png" alt="" srcset="" />
|
||||
<img src="@/assets/images/info_1 (6).png" alt="" srcset="" class="absolute left-18px top-22px" />
|
||||
</div>
|
||||
<div class="ml-18px">
|
||||
<div>
|
||||
<span class="info_num text-[#328CD7]">{{ userStaticInfo?.previewCount || 0 }}</span>
|
||||
</div>
|
||||
<div class="font">今日浏览量(次)</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-center">
|
||||
<div class="relative">
|
||||
<img src="@/assets/images/info_1 (1).png" alt="" srcset="" />
|
||||
<img src="@/assets/images/info_1 (2).png" alt="" srcset="" class="absolute left-20px top-18px" />
|
||||
</div>
|
||||
<div class="ml-18px">
|
||||
<div>
|
||||
<span class="info_num text-[#FFC415]">{{ userStaticInfo?.revenueCount || 0 }}</span>
|
||||
</div>
|
||||
<div class="font">今日收益(元)</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- -->
|
||||
<div class="mt-23px box-border h-183px w-913px border border-[#EEEEEE] rounded-6px border-solid bg-[#FFFFFF] px-30px py-21px">
|
||||
<div class="title">快捷入口</div>
|
||||
<div class="mt-20px flex items-center">
|
||||
<div class="info_item cursor-pointer" @click="handleClickPush('/upnew/drawe')">
|
||||
<img src="@/assets/images/fabu_2 (3).png" alt="" srcset="" />
|
||||
<div class="mt-10px">发布资源</div>
|
||||
</div>
|
||||
<div class="info_item ml-31px cursor-pointer" @click="handleClickPush('/communication/channel')">
|
||||
<img src="@/assets/images/fabu_2 (1).png" alt="" srcset="" />
|
||||
<div class="mt-10px">交流频道</div>
|
||||
</div>
|
||||
<div class="info_item ml-31px cursor-pointer" @click="handleService">
|
||||
<img src="@/assets/images/fabu_2 (2).png" alt="" srcset="" />
|
||||
<div class="mt-10px">消息</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- echarts -->
|
||||
<InfoEcharts></InfoEcharts>
|
||||
|
||||
<!-- 打开消息弹窗 弄成组件 -->
|
||||
<Message v-if="dialogVisible" v-model:dialog-visible="dialogVisible"></Message>
|
||||
<!-- 充值弹窗 -->
|
||||
<Pay v-if="payVisible" v-model="payVisible" @refresh="fetchUserStatistics"></Pay>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
import { getUserStatistics } from '@/api/personal-center/index'
|
||||
import { UserStatisticsCountRespVO } from '@/api/personal-center/types'
|
||||
import Message from './components/message.vue'
|
||||
import InfoEcharts from './info-echarts.vue'
|
||||
import Pay from './components/pay.vue'
|
||||
import useUserStore from '@/store/user'
|
||||
const userStore = useUserStore()
|
||||
|
||||
// 路由跳转
|
||||
import { useRouter } from 'vue-router'
|
||||
const router = useRouter()
|
||||
|
||||
// 获取用户统计信息
|
||||
const userStaticInfo = ref<UserStatisticsCountRespVO>()
|
||||
const fetchUserStatistics = async () => {
|
||||
const res = await getUserStatistics()
|
||||
userStaticInfo.value = res.data
|
||||
}
|
||||
fetchUserStatistics()
|
||||
|
||||
const handleClick = () => {
|
||||
router.push({ path: '/personal/profile' })
|
||||
}
|
||||
|
||||
const payVisible = ref(false)
|
||||
const handlePay = () => {
|
||||
payVisible.value = true
|
||||
// router.push({ path: '/personal/trading/center' })
|
||||
}
|
||||
|
||||
const handleClickPush = (path: string) => {
|
||||
if (!path) {
|
||||
return
|
||||
}
|
||||
window.open(path, '_blank')
|
||||
}
|
||||
|
||||
const dialogVisible = ref(false)
|
||||
const handleService = () => {
|
||||
dialogVisible.value = true
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.info_num {
|
||||
font-family: Microsoft YaHei;
|
||||
font-weight: 400;
|
||||
font-size: 24px;
|
||||
}
|
||||
.font {
|
||||
font-weight: 400;
|
||||
font-size: 14px;
|
||||
color: #999999;
|
||||
margin-top: 6px;
|
||||
}
|
||||
.info_pay {
|
||||
width: 60px;
|
||||
height: 24px;
|
||||
border-radius: 12px;
|
||||
border: 1px solid #1a65ff;
|
||||
font-weight: 400;
|
||||
font-size: 14px;
|
||||
color: #1a65ff;
|
||||
text-align: center;
|
||||
line-height: 24px;
|
||||
margin-left: 7px;
|
||||
}
|
||||
.title {
|
||||
padding-bottom: 16px;
|
||||
border-bottom: 1px solid #eeeeee;
|
||||
font-weight: 400;
|
||||
font-size: 16px;
|
||||
color: #333333;
|
||||
}
|
||||
.info_item {
|
||||
width: 121px;
|
||||
height: 81px;
|
||||
border-radius: 4px;
|
||||
border: 1px solid #1a65ff;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
font-weight: 400;
|
||||
font-size: 16px;
|
||||
color: #333333;
|
||||
}
|
||||
</style>
|
||||
154
pages/personal-Center/components/message-center.vue
Normal file
154
pages/personal-Center/components/message-center.vue
Normal file
@ -0,0 +1,154 @@
|
||||
<template>
|
||||
<div class="system-message">
|
||||
<!-- 顶部导航 -->
|
||||
<div class="nav-tabs">
|
||||
<el-tabs v-model="activeTab">
|
||||
<el-tab-pane label="系统消息" name="system"></el-tab-pane>
|
||||
<el-tab-pane label="交易消息" name="trade"></el-tab-pane>
|
||||
<el-tab-pane label="论坛社区互动" name="forum"></el-tab-pane>
|
||||
</el-tabs>
|
||||
<div class="read-all">
|
||||
<el-button type="primary" link>全部已读</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 消息列表 -->
|
||||
<div class="message-list">
|
||||
<div v-for="(message, index) in messages" :key="index" class="message-item">
|
||||
<div class="message-icon">
|
||||
<el-icon size="24">
|
||||
<Bell />
|
||||
</el-icon>
|
||||
</div>
|
||||
<div class="message-content">
|
||||
<div class="message-title">
|
||||
<span>{{ message.title }}</span>
|
||||
</div>
|
||||
<div class="message-desc">{{ message.description }}</div>
|
||||
</div>
|
||||
<div class="message-time">{{ message.time }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 查看更多 -->
|
||||
<div class="view-more">
|
||||
<el-button type="primary" link>查看更多 >></el-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
import { Bell } from '@element-plus/icons-vue'
|
||||
|
||||
const activeTab = ref('system')
|
||||
|
||||
interface Message {
|
||||
title: string
|
||||
description: string
|
||||
time: string
|
||||
}
|
||||
|
||||
const messages = ref<Message[]>([
|
||||
{
|
||||
title: '国庆夕金币充值优惠!',
|
||||
description: '国庆夕限时优惠,微信满500送50金币,充200送10金币',
|
||||
time: '2025-03-05 17:00:57',
|
||||
},
|
||||
{
|
||||
title: '国庆夕金币充值优惠!',
|
||||
description: '国庆夕限时优惠,微信满500送50金币,充200送10金币',
|
||||
time: '2025-03-05 17:00:57',
|
||||
},
|
||||
])
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.system-message {
|
||||
/* background-color: #f0f6ff; */
|
||||
width: 913px;
|
||||
padding: 20px 25px;
|
||||
box-sizing: border-box;
|
||||
background: #ffffff;
|
||||
border-radius: 6px;
|
||||
border: 1px solid #eeeeee;
|
||||
}
|
||||
|
||||
.nav-tabs {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
background: white;
|
||||
border-radius: 8px;
|
||||
margin-bottom: 20px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.read-all {
|
||||
padding-right: 20px;
|
||||
}
|
||||
|
||||
.message-list {
|
||||
background: white;
|
||||
border-radius: 8px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.message-item {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
padding: 15px 20px;
|
||||
border-bottom: 1px solid #eee;
|
||||
}
|
||||
|
||||
.message-item:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.message-icon {
|
||||
color: #409eff;
|
||||
margin-right: 15px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.message-content {
|
||||
flex: 1;
|
||||
min-width: 0; /* 防止文本溢出 */
|
||||
}
|
||||
|
||||
.message-title {
|
||||
font-weight: bold;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.message-desc {
|
||||
color: #666;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.message-time {
|
||||
color: #999;
|
||||
font-size: 12px;
|
||||
flex-shrink: 0;
|
||||
margin-left: 15px;
|
||||
}
|
||||
|
||||
.view-more {
|
||||
text-align: center;
|
||||
padding: 10px 0;
|
||||
color: #409eff;
|
||||
background: white;
|
||||
margin-top: 20px;
|
||||
border-radius: 8px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
:deep(.el-tabs__header) {
|
||||
margin-bottom: 0;
|
||||
padding-left: 20px;
|
||||
}
|
||||
|
||||
:deep(.el-tabs__nav-wrap) {
|
||||
padding-right: 20px;
|
||||
}
|
||||
</style>
|
||||
429
pages/personal-Center/components/personal-profile.vue
Normal file
429
pages/personal-Center/components/personal-profile.vue
Normal file
@ -0,0 +1,429 @@
|
||||
<template>
|
||||
<div class="box-border h-1082px w-913px border border-[#EEEEEE] rounded-6px border-solid bg-[#FFFFFF] px-30px py-21px">
|
||||
<div class="flex items-center justify-between border-b-1px border-b-[#eeeeee] border-b-solid pb-18px">
|
||||
<div class="text-16px text-[#333333] font-normal">个人资料</div>
|
||||
<div class="flex items-center">
|
||||
<!-- <img src="@/assets/images/fans.png" alt="" srcset="" /> -->
|
||||
<span class="ml-8px text-14px text-[#333333] font-normal"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="user-profile-container">
|
||||
<div class="avatar-section">
|
||||
<el-upload class="avatar-uploader" action="#" :show-file-list="false" :auto-upload="false" :on-change="handleAvatarChange">
|
||||
<div class="flex flex-col items-center">
|
||||
<el-avatar :size="100" :src="userForm.avatar" />
|
||||
<div class="mt-15px">
|
||||
<el-button type="primary" plain>更改头像</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-upload>
|
||||
</div>
|
||||
<el-form ref="userFormRef" :model="userForm" label-width="120px" class="profile-form" :rules="rules">
|
||||
<!-- User avatar section -->
|
||||
|
||||
<!-- User information section -->
|
||||
<el-form-item label="用户名:" prop="nickname">
|
||||
<div class="flex items-center">
|
||||
<el-input v-model="userForm.nickname" class="w-247px" />
|
||||
<el-button type="primary" class="verify-btn" @click="handleVerify">实名认证</el-button>
|
||||
</div>
|
||||
</el-form-item>
|
||||
|
||||
<!-- <el-form-item label="真实姓名:" prop="trueName">
|
||||
<div class="flex items-center">
|
||||
<el-input v-model="userForm.trueName" placeholder="请输入真实姓名" class="w-247px" />
|
||||
<el-button type="primary" class="verify-btn" @click="handleVerify">实名认证</el-button>
|
||||
</div>
|
||||
</el-form-item> -->
|
||||
|
||||
<el-form-item label="手机号:" prop="phone">
|
||||
<div class="flex items-center">
|
||||
<el-input v-model="userForm.phone" disabled class="w-247px" />
|
||||
<!-- <el-link type="primary" class="modify-link">修改</el-link> -->
|
||||
</div>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="电子邮箱:" prop="email">
|
||||
<div class="flex items-center">
|
||||
<el-input v-model="userForm.email" placeholder="请输入电子邮箱" class="w-247px" />
|
||||
<!-- <el-link type="primary" class="modify-link">绑定</el-link> -->
|
||||
</div>
|
||||
</el-form-item>
|
||||
|
||||
<div class="flex items-center">
|
||||
<el-form-item label="所在地区:" prop="isDomestic">
|
||||
<el-select v-model="userForm.isDomestic" placeholder="请选择" class="w-120px!" @change="handleCountryChange">
|
||||
<el-option label="国内" :value="1"></el-option>
|
||||
<el-option label="国外" :value="0"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label-width="6px" prop="province">
|
||||
<el-select v-model="userForm.province" placeholder="请选择省份" class="w-120px" @change="handleProvinceChange">
|
||||
<el-option v-for="item in provinceList" :key="item.id" :label="item.name" :value="item.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label-width="6px" prop="city">
|
||||
<el-select v-model="userForm.city" placeholder="请选择城市" class="w-120px" @change="handleCityChange">
|
||||
<el-option v-for="item in cityList" :key="item.id" :label="item.name" :value="item.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label-width="6px" prop="county">
|
||||
<el-select v-model="userForm.county" placeholder="请选择区县" class="w-120px">
|
||||
<el-option v-for="item in countyList" :key="item.id" :label="item.name" :value="item.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</div>
|
||||
|
||||
<el-form-item label="技能标签:" prop="labels">
|
||||
<el-select
|
||||
v-model="userForm.labels"
|
||||
:remote-method="remoteMethod"
|
||||
:loading="loading"
|
||||
multiple
|
||||
filterable
|
||||
remote
|
||||
placeholder="请输入搜索标签"
|
||||
class="w-498px!"
|
||||
>
|
||||
<el-option v-for="(item, index) in labelsList" :key="index" :label="item" :value="item" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="技能证书:" prop="files">
|
||||
<KlUploader
|
||||
v-model:file-list="userForm.files"
|
||||
list-type="picture-card"
|
||||
:limit="1000"
|
||||
:size="1"
|
||||
tips="上传图片支持jpg/gif/png格式、第一张为封面图片、每张图片大小不得超过1M"
|
||||
>
|
||||
<div class="h-77px w-161px flex items-center justify-center bg-[#fafafa]">
|
||||
<el-icon class="text-[#999999]"><Plus /></el-icon>
|
||||
<div class="ml-4px mt-2px text-14px text-[#999999] font-normal">上传图纸</div>
|
||||
</div>
|
||||
</KlUploader>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="个人简介:" prop="description">
|
||||
<el-input v-model="userForm.description" type="textarea" :rows="5" placeholder="请输入个人简介" class="full-width" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item>
|
||||
<el-button type="primary" class="w-120px !h-37px" @click="submitForm">提交</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
<div class="flex items-center justify-between border-b-1px border-b-[#eeeeee] border-b-solid pb-18px">
|
||||
<div class="text-16px text-[#333333] font-normal">社交帐号绑定</div>
|
||||
</div>
|
||||
<div class="flex flex-col justify-center text-14px text-[#333333] font-normal">
|
||||
<div class="mt-30px flex items-center">
|
||||
<img src="@/assets/images/qq-v2.png" alt="" srcset="" class="h-35px w-34px" />
|
||||
<div class="ml-19px">QQ</div>
|
||||
<div class="ml-100px flex items-center"><div class="w-90px">QQ昵称:</div><div class="w-180px">xxx</div></div>
|
||||
<div class="btn">绑定</div>
|
||||
</div>
|
||||
<div class="mt-30px flex items-center">
|
||||
<img src="@/assets/images/weixin-v2.png" alt="" srcset="" class="h-35px w-34px" />
|
||||
<div class="ml-19px">微信</div>
|
||||
<div class="ml-95px flex items-center"><div class="w-90px">微信昵称:</div><div class="w-180px">xxx</div></div>
|
||||
<div class="btn">绑定</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<verifyDialog ref="verifyDialogRef" />
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive } from 'vue'
|
||||
import { Plus } from '@element-plus/icons-vue'
|
||||
import { tree, upload } from '@/api/common/index'
|
||||
import { keywords } from '@/api/upnew/index'
|
||||
import { userExtend, getUserInfo, updateUserExtend } from '@/api/personal-center/index.ts'
|
||||
import { UserExtendSaveReqVO } from '@/api/personal-center/types'
|
||||
import verifyDialog from './verify-dialog.vue'
|
||||
const userFormRef = ref()
|
||||
|
||||
const userForm = reactive<UserExtendSaveReqVO>({
|
||||
id: undefined,
|
||||
phone: '',
|
||||
username: '',
|
||||
avatar: '',
|
||||
trueName: '',
|
||||
city: '',
|
||||
email: '',
|
||||
isDomestic: undefined,
|
||||
area: '',
|
||||
country: '',
|
||||
province: '',
|
||||
county: '',
|
||||
labels: [],
|
||||
description: '',
|
||||
authStatus: 0,
|
||||
files: [],
|
||||
nickname: '',
|
||||
})
|
||||
|
||||
const rules = {
|
||||
username: [{ required: true, message: '请输入昵称', trigger: 'blur' }],
|
||||
city: [{ required: true, message: '请选择城市', trigger: 'change' }],
|
||||
email: [
|
||||
{ required: false, message: '请输入电子邮箱', trigger: 'blur' },
|
||||
{ type: 'email' as const, message: '请输入正确的邮箱格式', trigger: 'blur' },
|
||||
],
|
||||
// 标签
|
||||
labels: [{ required: false, message: '请选择技能标签', trigger: 'change' }],
|
||||
// 技能证书
|
||||
files: [{ required: false, message: '请上传技能证书', trigger: 'change' }],
|
||||
// 所在地区
|
||||
isDomestic: [{ required: false, message: '请选择国家', trigger: 'change' }],
|
||||
province: [{ required: false, message: '请选择省份', trigger: 'change' }],
|
||||
county: [{ required: false, message: '请选择区县', trigger: 'change' }],
|
||||
}
|
||||
|
||||
const verifyDialogRef = ref()
|
||||
const handleVerify = () => {
|
||||
verifyDialogRef.value.open()
|
||||
}
|
||||
|
||||
// 省份地址
|
||||
const provinceList = ref()
|
||||
// 城市地址
|
||||
const cityList = ref()
|
||||
// 区县地址
|
||||
const countyList = ref()
|
||||
// 获取地址
|
||||
const getAdress = async (type: string, val?: any) => {
|
||||
const res = await tree({
|
||||
id: val,
|
||||
})
|
||||
if (res.code === 0) {
|
||||
if (type === 'province') {
|
||||
provinceList.value = res.data
|
||||
} else if (type === 'city') {
|
||||
cityList.value = res.data
|
||||
} else if (type === 'county') {
|
||||
countyList.value = res.data
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 切换国家
|
||||
const handleCountryChange = (value: any) => {
|
||||
userForm.province = ''
|
||||
userForm.city = ''
|
||||
userForm.county = ''
|
||||
provinceList.value = []
|
||||
cityList.value = []
|
||||
countyList.value = []
|
||||
getAdress('province', value)
|
||||
}
|
||||
// 监听省份变化
|
||||
const handleProvinceChange = (value: string) => {
|
||||
userForm.city = ''
|
||||
userForm.county = ''
|
||||
cityList.value = []
|
||||
countyList.value = []
|
||||
getAdress('city', value)
|
||||
}
|
||||
|
||||
// 监听城市变化
|
||||
const handleCityChange = (value: string) => {
|
||||
userForm.county = ''
|
||||
countyList.value = []
|
||||
getAdress('county', value)
|
||||
}
|
||||
|
||||
// 处理头像上传变化
|
||||
const handleAvatarChange = (file: any) => {
|
||||
// 这里可以添加文件类型和大小的验证
|
||||
if (file) {
|
||||
// 创建本地预览URL
|
||||
userForm.avatar = URL.createObjectURL(file.raw)
|
||||
// 这里可以添加实际的上传逻辑
|
||||
console.log('Avatar file:', file)
|
||||
// 上传文件到服务器
|
||||
const formData = new FormData()
|
||||
formData.append('fieldName', file?.name)
|
||||
formData.append('file', file.raw as Blob)
|
||||
|
||||
upload('/prod-api/app-api/infra/file/upload', formData)
|
||||
.then((response) => {
|
||||
if (response.code === 0) {
|
||||
userForm.avatar = response.data
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Error uploading avatar:', error)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const loading = ref(false)
|
||||
/** 获取标签 */
|
||||
const labelsList = ref<any>([])
|
||||
const remoteMethod = (query: string) => {
|
||||
if (query) {
|
||||
loading.value = true
|
||||
keywords({
|
||||
type: 1,
|
||||
keywords: query,
|
||||
})
|
||||
.then((res) => {
|
||||
labelsList.value = res.data
|
||||
})
|
||||
.finally(() => {
|
||||
loading.value = false
|
||||
})
|
||||
} else {
|
||||
labelsList.value = []
|
||||
}
|
||||
}
|
||||
|
||||
// 提交表单
|
||||
const submitForm = async () => {
|
||||
if (!userFormRef.value) return
|
||||
|
||||
try {
|
||||
await userFormRef.value.validate()
|
||||
const res = userForm.id ? await updateUserExtend(userForm) : await userExtend(userForm)
|
||||
if (res.code === 0) {
|
||||
ElMessage.success('个人信息提交成功')
|
||||
} else {
|
||||
ElMessage.error('个人信息提交失败')
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Validation failed:', error)
|
||||
ElMessage.error('表单验证失败,请检查输入')
|
||||
}
|
||||
}
|
||||
|
||||
// 初始回显
|
||||
const init = async () => {
|
||||
const res = await getUserInfo()
|
||||
if (res.code === 0) {
|
||||
userForm.id = res.data.id
|
||||
userForm.nickname = res.data.nickname
|
||||
userForm.phone = res.data.mobile
|
||||
userForm.email = res.data.email
|
||||
userForm.isDomestic = +res.data.isDomestic
|
||||
userForm.country = res.data.country
|
||||
await getAdress('province', userForm.isDomestic)
|
||||
// @ts-ignore
|
||||
userForm.province = +res.data.province
|
||||
await getAdress('city', userForm.province)
|
||||
// @ts-ignore
|
||||
userForm.city = +res.data.city
|
||||
await getAdress('county', userForm.city)
|
||||
// @ts-ignore
|
||||
userForm.county = +res.data.county
|
||||
userForm.labels = res.data.labels
|
||||
userForm.description = res.data.description
|
||||
userForm.avatar = res.data.avatar
|
||||
userForm.files = res.data.files.map((item: any) => {
|
||||
return {
|
||||
...item,
|
||||
url: item.url,
|
||||
name: item.title,
|
||||
uid: item.id,
|
||||
status: 'success',
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
init()
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.btn {
|
||||
width: 91px;
|
||||
height: 37px;
|
||||
background: #1a65ff;
|
||||
border-radius: 4px;
|
||||
border: 1px solid #1a65ff;
|
||||
text-align: center;
|
||||
line-height: 37px;
|
||||
font-weight: 400;
|
||||
font-size: 14px;
|
||||
color: #ffffff;
|
||||
margin-left: 30px;
|
||||
}
|
||||
.user-profile-container {
|
||||
margin: 0 auto;
|
||||
padding: 30px;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.profile-form {
|
||||
/* margin-top: 20px; */
|
||||
}
|
||||
|
||||
.avatar-section {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
.update-avatar-btn {
|
||||
margin-top: 15px;
|
||||
}
|
||||
|
||||
.verify-btn {
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
.modify-link {
|
||||
margin-left: 10px;
|
||||
min-width: fit-content;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.certificate-uploader {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.upload-area {
|
||||
width: 200px;
|
||||
height: 100px;
|
||||
border: 1px dashed #d9d9d9;
|
||||
border-radius: 6px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.upload-area:hover {
|
||||
border-color: #409eff;
|
||||
}
|
||||
|
||||
.full-width {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.flex {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.gap-2 {
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.w-120px {
|
||||
width: 120px;
|
||||
}
|
||||
|
||||
/* 响应式布局调整 */
|
||||
@media (max-width: 768px) {
|
||||
.user-profile-container {
|
||||
padding: 20px 10px;
|
||||
}
|
||||
|
||||
.verify-btn {
|
||||
margin-top: 10px;
|
||||
margin-left: 0;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
124
pages/personal-Center/components/resource-center.vue
Normal file
124
pages/personal-Center/components/resource-center.vue
Normal file
@ -0,0 +1,124 @@
|
||||
<template>
|
||||
<div class="box-border min-h-494px w-913px border border-[#EEEEEE] rounded-6px border-solid bg-[#FFFFFF] px-30px py-21px">
|
||||
<el-tabs v-model="activeName" class="demo-tabs" @tab-click="handleClick">
|
||||
<el-tab-pane label="我的上传" name="我的上传">
|
||||
<uploadTable v-model:type="pageReq.type" v-model="result.list" :refresh="handlerefresh" />
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="我的购买" name="我的购买">
|
||||
<downloadTable v-model="result.list" />
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="收藏夹" name="收藏夹">
|
||||
<favoriteTable v-model:type="pageReq.type" v-model="result.list" :refresh="handlerefresh" />
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="浏览记录" name="浏览记录">
|
||||
<browseTable v-model="result.list" />
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
|
||||
<!-- 分页 -->
|
||||
<div class="mt-10px flex justify-center">
|
||||
<el-pagination
|
||||
v-model:current-page="pageReq.pageNum"
|
||||
v-model:page-size="pageReq.pageSize"
|
||||
:page-sizes="[10, 20, 30]"
|
||||
:total="result.total"
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
@size-change="handleClickSize"
|
||||
@current-change="handeClickCurrent"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive } from 'vue'
|
||||
|
||||
import { getContentPage, getUserToolBoxPage, getUserFavoritePage, getOwnContentPage } from '@/api/personal-center/index'
|
||||
// import { ProjectHistoryResVO } from '@/api/personal-center/types'
|
||||
|
||||
import uploadTable from './components/upload-table.vue'
|
||||
import downloadTable from './components/download-table.vue'
|
||||
import favoriteTable from './components/favorite-table.vue'
|
||||
import browseTable from './components/browse-table.vue'
|
||||
import useUserStore from '@/store/user'
|
||||
const userStore = useUserStore()
|
||||
|
||||
const activeName = ref('我的上传')
|
||||
const pageReq = reactive({
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
type: 1, //类型 1 图纸 2 工具箱
|
||||
})
|
||||
const result = reactive({
|
||||
total: 0, //总条数
|
||||
list: [] as any[], //列表
|
||||
})
|
||||
|
||||
const handleClickSize = (val: number) => {
|
||||
pageReq.pageSize = val
|
||||
fetchData()
|
||||
}
|
||||
|
||||
const handeClickCurrent = (val: number) => {
|
||||
pageReq.pageNum = val
|
||||
fetchData()
|
||||
}
|
||||
|
||||
const fetchData = async () => {
|
||||
let res = {} as any
|
||||
switch (activeName.value) {
|
||||
case '我的上传':
|
||||
res = await getOwnContentPage({ ...pageReq, pageNo: pageReq.pageNum }) // 我的上传
|
||||
if (res.code === 0) {
|
||||
result.total = res.data.total || 0
|
||||
result.list = res.data.list || []
|
||||
}
|
||||
break
|
||||
case '我的购买':
|
||||
res = await getUserToolBoxPage({ ...pageReq, type: undefined }) // 我的下载
|
||||
if (res.code === 0) {
|
||||
result.total = res.data.total || 0
|
||||
result.list = res.data.list || []
|
||||
}
|
||||
break
|
||||
case '收藏夹':
|
||||
res = await getUserFavoritePage({ ...pageReq, pageNo: pageReq.pageNum, userId: userStore.userId }) // 收藏夹
|
||||
if (res.code === 0) {
|
||||
result.total = res.data.total || 0
|
||||
result.list = res.data.list || []
|
||||
}
|
||||
break
|
||||
case '浏览记录':
|
||||
res = await getContentPage(pageReq) // 浏览记录
|
||||
if (res.code === 0) {
|
||||
result.total = res.data.total || 0
|
||||
result.list = res.data.list || []
|
||||
}
|
||||
break
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
const handlerefresh = () => {
|
||||
pageReq.pageNum = 1
|
||||
fetchData()
|
||||
}
|
||||
|
||||
const handleClick = (tab: any) => {
|
||||
console.log(tab)
|
||||
activeName.value = tab.props.name
|
||||
pageReq.pageNum = 1
|
||||
result.list = []
|
||||
result.total = 0
|
||||
fetchData()
|
||||
}
|
||||
|
||||
fetchData()
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
:deep(.el-input__inner) {
|
||||
text-align: center !important;
|
||||
}
|
||||
</style>
|
||||
146
pages/personal-Center/components/trading-center.vue
Normal file
146
pages/personal-Center/components/trading-center.vue
Normal file
@ -0,0 +1,146 @@
|
||||
<template>
|
||||
<div class="account-balance">
|
||||
<!-- 余额展示区域 -->
|
||||
<div class="balance-section">
|
||||
<div class="balance-title">
|
||||
<span>我的金币(元)</span>
|
||||
<el-tag size="small" type="primary">资产和使用</el-tag>
|
||||
</div>
|
||||
<div class="balance-amount">{{ userStaticInfo?.currencyCount || 0 }}</div>
|
||||
<div class="balance-actions">
|
||||
<el-button type="primary" @click="handlePay">充值</el-button>
|
||||
<el-button>提现</el-button>
|
||||
</div>
|
||||
<div class="balance-tip">提示:最低提现金额:100 元,一元=10金币</div>
|
||||
</div>
|
||||
|
||||
<!-- 交易记录区域 -->
|
||||
<div class="transaction-section">
|
||||
<div class="transaction-tabs">
|
||||
<el-tabs v-model="activeTab">
|
||||
<el-tab-pane label="充值记录" name="purchase">
|
||||
<!-- 组件 -->
|
||||
<PayRecords></PayRecords>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="提现管理" name="withdraw"></el-tab-pane>
|
||||
</el-tabs>
|
||||
<!-- <div class="date-filter">
|
||||
<span>当前时期:</span>
|
||||
<el-date-picker v-model="currentMonth" type="month" format="YYYY.MM" value-format="YYYY.MM" placeholder="选择月份" />
|
||||
</div> -->
|
||||
</div>
|
||||
</div>
|
||||
<!-- 充值弹窗 -->
|
||||
<Pay v-if="payVisible" v-model="payVisible" @refresh="fetchUserStatistics"></Pay>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
import Pay from './components/pay.vue'
|
||||
import PayRecords from './components/pay-records.vue'
|
||||
import { getUserStatistics } from '@/api/personal-center/index'
|
||||
import { UserStatisticsCountRespVO } from '@/api/personal-center/types'
|
||||
|
||||
const activeTab = ref('purchase')
|
||||
// const currentMonth = ref('2025.03')
|
||||
|
||||
// 获取用户统计信息
|
||||
const userStaticInfo = ref<UserStatisticsCountRespVO>()
|
||||
const fetchUserStatistics = async () => {
|
||||
const res = await getUserStatistics()
|
||||
userStaticInfo.value = res.data
|
||||
}
|
||||
fetchUserStatistics()
|
||||
|
||||
const payVisible = ref(false)
|
||||
const handlePay = () => {
|
||||
payVisible.value = true
|
||||
// router.push({ path: '/personal/trading/center' })
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.account-balance {
|
||||
width: 913px;
|
||||
min-height: 100vh;
|
||||
background: #ffffff;
|
||||
}
|
||||
|
||||
.balance-section {
|
||||
background: white;
|
||||
padding: 20px 25px;
|
||||
border-radius: 8px;
|
||||
margin-bottom: 20px;
|
||||
border-radius: 6px;
|
||||
border: 1px solid #eeeeee;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.balance-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
margin-bottom: 10px;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.balance-amount {
|
||||
font-size: 32px;
|
||||
font-weight: bold;
|
||||
margin: 20px 0;
|
||||
}
|
||||
|
||||
.balance-actions {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.balance-tip {
|
||||
color: #999;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.transaction-section {
|
||||
background: white;
|
||||
padding: 20px 25px;
|
||||
border-radius: 8px;
|
||||
border-radius: 6px;
|
||||
border: 1px solid #eeeeee;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.transaction-tabs {
|
||||
/* display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 20px; */
|
||||
}
|
||||
|
||||
.date-filter {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.amount {
|
||||
color: #409eff;
|
||||
}
|
||||
|
||||
.pagination {
|
||||
margin-top: 20px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
:deep(.el-pagination .el-pager li.is-active) {
|
||||
background-color: #409eff;
|
||||
color: white;
|
||||
}
|
||||
|
||||
:deep(.el-input__wrapper) {
|
||||
background-color: transparent;
|
||||
}
|
||||
</style>
|
||||
153
pages/personal-Center/components/verify-dialog.vue
Normal file
153
pages/personal-Center/components/verify-dialog.vue
Normal file
@ -0,0 +1,153 @@
|
||||
<template>
|
||||
<el-dialog v-model="dialogVisible" title="实名认证" width="600px" :close-on-click-modal="false" :close-on-press-escape="false" :show-close="false">
|
||||
<el-form ref="formRef" :model="form" :rules="rules" label-width="110px" class="pa-20px">
|
||||
<el-form-item label="真实姓名" prop="trueName">
|
||||
<el-input v-model="form.trueName" placeholder="请输入真实姓名" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="身份证号" prop="idNo">
|
||||
<el-input v-model="form.idNo" placeholder="请输入身份证号" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="身份证照片" prop="files">
|
||||
<KlUploader
|
||||
v-model:file-list="form.files"
|
||||
list-type="picture-card"
|
||||
:limit="2"
|
||||
:size="1"
|
||||
tips="上传图片支持jpg/gif/png格式、正反两面、每张图片大小不得超过1M"
|
||||
>
|
||||
<div class="h-77px w-161px flex items-center justify-center border border-[#cdd0d6] rounded-1px border-dashed bg-[#fafafa]">
|
||||
<el-icon class="text-[#999999]"><Plus /></el-icon>
|
||||
<div class="ml-4px mt-2px text-14px text-[#999999] font-normal">上传照片</div>
|
||||
</div>
|
||||
</KlUploader>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<el-button @click="handleCancel">取消</el-button>
|
||||
<el-button type="primary" @click="handleSubmit">确认</el-button>
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive } from 'vue'
|
||||
import { Plus } from '@element-plus/icons-vue'
|
||||
import type { FormInstance, FormRules } from 'element-plus'
|
||||
import { getUserAuthInfo, createUserAuthInfo, updateUserAuthInfo } from '@/api/personal-center/index.ts'
|
||||
import { UserAuthInfoRespVO } from '@/api/personal-center/types'
|
||||
|
||||
const dialogVisible = ref(false)
|
||||
const formRef = ref<FormInstance>()
|
||||
|
||||
const form = reactive<UserAuthInfoRespVO>({
|
||||
id: undefined,
|
||||
trueName: '',
|
||||
idNo: '',
|
||||
files: [],
|
||||
})
|
||||
|
||||
const rules = reactive<FormRules>({
|
||||
trueName: [
|
||||
{ required: true, message: '请输入真实姓名', trigger: 'blur' },
|
||||
{ min: 2, max: 20, message: '长度在 2 到 20 个字符', trigger: 'blur' },
|
||||
],
|
||||
idNo: [{ required: true, message: '请输入身份证号', trigger: 'blur' }],
|
||||
files: [{ required: true, message: '请上传身份证正面反面照片', trigger: 'change' }],
|
||||
})
|
||||
|
||||
const handleSubmit = async () => {
|
||||
if (!formRef.value) return
|
||||
|
||||
try {
|
||||
await formRef.value.validate()
|
||||
// TODO: 这里添加提交逻辑
|
||||
const res = form.id ? await updateUserAuthInfo(form) : await createUserAuthInfo(form)
|
||||
if (res.code === 0) {
|
||||
ElMessage.success('认证信息提交成功')
|
||||
dialogVisible.value = false
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('表单验证失败:', error)
|
||||
}
|
||||
}
|
||||
|
||||
const handleCancel = () => {
|
||||
dialogVisible.value = false
|
||||
formRef.value?.resetFields()
|
||||
}
|
||||
|
||||
// 对外暴露方法
|
||||
const open = () => {
|
||||
dialogVisible.value = true
|
||||
getUserAuthInfo().then((res) => {
|
||||
form.id = res.data.id
|
||||
form.files = res.data.files.map((item: any) => {
|
||||
return {
|
||||
...item,
|
||||
url: item.url,
|
||||
name: item.title,
|
||||
uid: item.id,
|
||||
status: 'success',
|
||||
}
|
||||
})
|
||||
form.trueName = res.data.trueName
|
||||
form.idNo = res.data.idNo
|
||||
})
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
open,
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.id-card-uploader {
|
||||
border: 1px dashed #d9d9d9;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
width: 178px;
|
||||
height: 178px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.id-card-uploader:hover {
|
||||
border-color: #409eff;
|
||||
}
|
||||
|
||||
.id-card-uploader-icon {
|
||||
font-size: 28px;
|
||||
color: #8c939d;
|
||||
width: 178px;
|
||||
height: 178px;
|
||||
text-align: center;
|
||||
line-height: 178px;
|
||||
}
|
||||
|
||||
.id-card-image {
|
||||
width: 178px;
|
||||
height: 178px;
|
||||
display: block;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.upload-tip {
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
.dialog-footer {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 12px;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user