| | |
| | | currentCollect == 'book' || currentCollect == 'textBooks' |
| | | ? 'bookCartContent cartContent' |
| | | : currentCollect == 'course' |
| | | ? 'courseCartContent cartContent' |
| | | : 'cartContent' |
| | | ? 'courseCartContent cartContent' |
| | | : 'cartContent' |
| | | " |
| | | > |
| | | <div |
| | | class="collectList flex jc-sb clear" |
| | | v-if="collectList.length > 0 && !pages.loading" |
| | | > |
| | | <div |
| | | v-for="(item, index) in collectList" |
| | | :key="index" |
| | | class="collectList-item fl" |
| | | > |
| | | <div v-for="(item, index) in collectList" :key="index" class="collectList-item fl"> |
| | | <div class="cover" @click="goBookDetails(item.id, item.name)"> |
| | | <img :src="item.icon" alt="" /> |
| | | </div> |
| | |
| | | <span>{{ item.name }}</span> |
| | | </div> |
| | | <div class="currentBtn hover" @click="setCoolect(item)"> |
| | | <img |
| | | src="@/assets/images/personalCenter/collect-click.png" |
| | | alt="star" |
| | | /> |
| | | <img src="@/assets/images/personalCenter/collect-click.png" alt="star" /> |
| | | </div> |
| | | </div> |
| | | </div> |
| | |
| | | </template> |
| | | |
| | | <script setup lang="ts"> |
| | | import { reactive, ref, onMounted, inject, watch } from "vue"; |
| | | import { ElMessage, ElMessageBox } from "element-plus"; |
| | | import { useBreadcrumbStore, useUserStore } from '@/store' |
| | | import { useRouter } from "vue-router"; |
| | | const crumbStore = useBreadcrumbStore() |
| | | import { reactive, ref, onMounted, inject, watch } from 'vue' |
| | | import { ElMessage, ElMessageBox } from 'element-plus' |
| | | import { useUserStore } from '@/store' |
| | | import { useRouter } from 'vue-router' |
| | | const userStore = useUserStore() |
| | | const router = useRouter(); |
| | | const MG: any = inject("MG"); |
| | | const config: any = inject("config"); |
| | | let currentCollect = ref("book"); |
| | | let collectList = ref([]); |
| | | const background = ref(false); |
| | | const disabled = ref(false); |
| | | const router = useRouter() |
| | | const MG: any = inject('MG') |
| | | const config: any = inject('config') |
| | | let currentCollect = ref('textBooks') |
| | | let collectList = ref([]) |
| | | const background = ref(false) |
| | | const disabled = ref(false) |
| | | let pages = reactive({ |
| | | page: 1, |
| | | pageSize: 10, |
| | | count: 0, |
| | | loading: false, |
| | | }); |
| | | let linkType = ref("FavoriteTextBooks"); |
| | | }) |
| | | let linkType = ref('FavoriteBookCity') |
| | | |
| | | const tabCart = (event: Event) => { |
| | | pages.page = 1; |
| | | pages.loading = true; |
| | | collectList.value = []; |
| | | currentCollect.value = event.props.name; |
| | | if (currentCollect.value == "textBooks") { |
| | | linkType.value = "FavoriteTextBooks"; |
| | | pages.page = 1 |
| | | pages.loading = true |
| | | collectList.value = [] |
| | | currentCollect.value = event.props.name |
| | | if (currentCollect.value == 'textBooks') { |
| | | linkType.value = 'FavoriteBookCity' |
| | | } |
| | | getDataList(); |
| | | }; |
| | | getDataList() |
| | | } |
| | | |
| | | function getDataList() { |
| | | pages.loading = true; |
| | | pages.loading = true |
| | | MG.store |
| | | .getProductList({ |
| | | handelEBooK: true, |
| | | queryType: "AppUserProductLink", |
| | | queryType: 'AppUserProductLink', |
| | | linkType: linkType.value, |
| | | paging: { |
| | | start: pages.pageSize * pages.page - pages.pageSize, |
| | |
| | | }, |
| | | }) |
| | | .then((res) => { |
| | | collectList.value = res.datas; |
| | | pages.count = res.total; |
| | | pages.loading = false; |
| | | collectList.value = res.datas |
| | | pages.count = res.total |
| | | pages.loading = false |
| | | }) |
| | | .catch(() => { |
| | | pages.loading = false; |
| | | }); |
| | | pages.loading = false |
| | | }) |
| | | } |
| | | onMounted(() => { |
| | | getDataList(); |
| | | }); |
| | | getDataList() |
| | | }) |
| | | |
| | | // watch( |
| | | // () => userStore.token, |
| | |
| | | // ) |
| | | |
| | | const handleCurrentChange = (val: number) => { |
| | | pages.page = val; |
| | | getDataList(); |
| | | }; |
| | | pages.page = val |
| | | getDataList() |
| | | } |
| | | |
| | | const setCoolect = (item) => { |
| | | ElMessageBox.confirm("确定要取消收藏吗?", { |
| | | confirmButtonText: "确定", |
| | | cancelButtonText: "取消", |
| | | ElMessageBox.confirm('确定要取消收藏吗?', { |
| | | confirmButtonText: '确定', |
| | | cancelButtonText: '取消', |
| | | autofocus: false, |
| | | type: "warning", |
| | | type: 'warning', |
| | | }) |
| | | .then(() => { |
| | | MG.store |
| | |
| | | }) |
| | | .then(() => { |
| | | ElMessage({ |
| | | message: "收藏已取消!", |
| | | type: "success", |
| | | }); |
| | | pages.page = 1; |
| | | getDataList(); |
| | | }); |
| | | message: '收藏已取消!', |
| | | type: 'success', |
| | | }) |
| | | pages.page = 1 |
| | | getDataList() |
| | | }) |
| | | }) |
| | | .catch(() => {}); |
| | | }; |
| | | .catch(() => {}) |
| | | } |
| | | // 跳转书本详情 |
| | | const goBookDetails = (id: number, name: string) => { |
| | | let crumbs = [ |
| | | { |
| | | name, |
| | | isCrumbs: true, |
| | | type: |
| | | currentCollect.value == "book" |
| | | ? "bookService" |
| | | : currentCollect.value == "textBooks" |
| | | ? "digitalTextbooks" |
| | | : "digitalCourses", |
| | | path: |
| | | currentCollect.value == "book" |
| | | ? "/bookService/details" |
| | | : "/digitalCoursesDetails", |
| | | router.push({ |
| | | path: '/bookdetail', |
| | | query: { |
| | | bookId: id, |
| | | }, |
| | | ]; |
| | | // 在全局数据中设置面包屑 |
| | | crumbStore.setCrumbs({ |
| | | type: |
| | | currentCollect.value == "book" |
| | | ? "bookService" |
| | | : currentCollect.value == "textBooks" |
| | | ? "digitalTextbooks" |
| | | : "digitalCourses", |
| | | data: crumbs, |
| | | callback: (key: any) => { |
| | | router.push({ |
| | | name: |
| | | currentCollect.value == "book" |
| | | ? "bookDetails" |
| | | : currentCollect.value == "textBooks" |
| | | ? "digitalTextbooksDetails" |
| | | : "digitalCoursesDetails", |
| | | query: { |
| | | crumbsKey: key, |
| | | bookId: id, |
| | | bookName: name, |
| | | type: |
| | | currentCollect.value == "book" |
| | | ? "bookService" |
| | | : currentCollect.value == "textBooks" |
| | | ? "digitalTextbooks" |
| | | : "digitalCourses", |
| | | }, |
| | | }); |
| | | }, |
| | | }); |
| | | }; |
| | | }) |
| | | } |
| | | </script> |
| | | <style lang="less" scoped> |
| | | .cartClass { |
| | |
| | | padding: 2px; |
| | | background-color: #fff; |
| | | position: absolute; |
| | | top: 10px; |
| | | right: 10px; |
| | | top: 5px; |
| | | right: 2px; |
| | | |
| | | img { |
| | | width: 16px; |
| | | height: 16px; |
| | | height: 20px; |
| | | } |
| | | } |
| | | |