| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 |
- <template>
- <div class="collection">
- <div class="gap10 title">
- <div class="line_vertical"></div>
- <div class="">{{ $t('personalCenter.myCollection') }}</div>
- </div>
- <div class="collection-list">
- <div @click.prevent="toDetail(item)" class="flex-center-between li" v-for="(item, index) in list" :key="index">
- <img class="image" :src="item.coverImageUrl" alt="">
- <div class="collection-list-main">
- <div class="collection-list-main-left">
- <div class="titles">{{ item.courseTitle }}</div>
- <div class="gap10 tag">
- <el-button type="primary" size="large" plain>{{ item.skillTag }}</el-button>
- </div>
- <div class="">{{ item.courseIntro }}</div>
- </div>
- <div @click.stop.prevent="cancelCollect(item, index)" class="btn flex-center active">
- <img src="/src/assets/imgs/my/star@2x.png" alt="">
- <div class="">{{ $t('common.cancelCollect') }}</div>
- </div>
- </div>
- </div>
- </div>
- <template v-if="list.length">
- <Pagination :total="form.total" :page-size="form.pageSize" :current-page="form.pageNum"
- @page-change="handlePageChange" />
- </template>
- <el-empty v-else :description="$t('common.empty')" />
- </div>
- </template>
- <script setup lang="ts">
- import Pagination from '@/components/Pagination.vue'
- import { ref, onMounted } from 'vue'
- import { collectList } from '@/api/my.js'
- import { collect } from '@/api/course'
- import DGTMessage from '@/utils/message'
- import { useI18n } from 'vue-i18n'
- const { t } = useI18n()
- import { useRouter } from 'vue-router'
- const router = useRouter()
- const form = ref({
- pageNum: 1,
- pageSize: 10,
- total: 0,
- orderByColumn: 'create_time',
- isAsc: 'desc'
- })
- const list = ref([])
- // 取消收藏
- const cancelCollect = async (item, index) => {
- let res = await collect({ objectId: item.objectId });
- DGTMessage.success(`${t('common.unCollect')}${t('common.success')}`)
- getList()
- }
- const getList = async () => {
- let res = await collectList(form.value);
- form.value.total = res.total;
- list.value = res.rows
- }
- const handlePageChange = (page, pageSize) => {
- list.value = []
- form.value.pageNum = page;
- if(pageSize)form.value.pageSize = pageSize;
- getList()
- }
- // 跳转详情
- const toDetail = (item: any) => {
- router.push({
- path: `/learning-system/detail/${item.objectId}/course/${item.objectId}`,
- query: {
- courseId: item.objectId,
- metaTitle: item.courseTitle || '课程详情'
- }
- })
- }
- onMounted(() => {
- getList()
- })
- </script>
- <style scoped lang="scss">
- .collection {
- padding-bottom: 20px;
- .title {
- height: 60px;
- font-size: 20px;
- font-weight: bold;
- color: #333333;
- }
- .collection-list {
- .li {
- padding: 16px;
- margin-bottom: 16px;
- background: #F5F7FA;
- border-radius: 16px;
- &:last-child {
- margin-bottom: 0;
- }
- .image {
- width: 213px;
- height: 120px;
- object-fit: cover;
- border-radius: 8px;
- margin-right: 16px;
- }
- .collection-list-main {
- flex: 1;
- display: flex;
- align-items: center;
- justify-content: space-between;
- .collection-list-main-left {
- flex: 1;
- margin-right: 16px;
- .titles {
- font-size: 18px;
- font-weight: bold;
- color: #333333;
- }
- .tag {
- margin: 8px 0;
- }
- .content {
- color: #666666;
- font-size: 14px;
- line-height: 22px;
- }
- }
- .btn {
- width: 120px;
- height: 32px;
- color: #FFFFFF;
- font-size: 14px;
- cursor: pointer;
- background: linear-gradient(270deg, #0055FE 0%, #C832FA 100%);
- border-radius: 4px;
- &:hover {
- opacity: 0.7;
- }
- img {
- width: 14px;
- height: 14px;
- margin-right: 4px;
- }
- }
- .active {
- background: #FFFFFF;
- color: #2D71FF;
- }
- }
- }
- }
- }
- </style>
|