123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324 |
- <template>
- <div class="collection-box">
- <van-nav-bar title="错题收藏" left-arrow @click-left="onClickLeft" placeholder> </van-nav-bar>
- <div>
- <img class="collectionHeader" :src="collectionHeader" />
- </div>
- <div class="choose">
- <div @click="goExercise('wrong')" class="choose-img">
- <span class="choose-text1"> 做错题 </span>
- <span class="choose-text2"> 共 {{ wrongList.length }} 题 </span>
- <img class="" :src="wrongBg" />
- <img class="goArrow" :src="goArrow" />
- <button @click="clearTopicsWrong" style="color: #498ef5" class="clear">清空错题</button>
- <button
- @click.stop="
- () => {
- wrongSyncVisible = true;
- }
- "
- style="color: #498ef5; left: 60vw"
- class="clear">
- 同步错题
- </button>
- </div>
- <div @click="goExercise('collection')" class="choose-img">
- <span class="choose-text1">收藏题</span>
- <span class="choose-text2"> 共 {{ collectionList.length }} 题 </span>
- <img class="" :src="collectionBg" />
- <img class="goArrow" :src="goArrow" />
- <button @click="clearTopicsCollection" style="color: #01c18d" class="clear">清空收藏</button>
- <button
- @click.stop="
- () => {
- collectSyncVisible = true;
- }
- "
- style="color: #01c18d; left: 60vw"
- class="clear">
- 同步收藏
- </button>
- </div>
- </div>
- <div class="bottom">
- <img :src="collectionBottomBg" />
- </div>
- <van-popup position="bottom" v-model:show="wrongSyncVisible">
- <van-picker
- @cancel="
- () => {
- wrongSyncVisible = false;
- }
- "
-
- :columns="['合并本机和云端错题', '备份本机收藏到错题', '恢复云端收藏到错题']"></van-picker>
- </van-popup>
- <van-popup position="bottom" v-model:show="collectSyncVisible">
- <van-picker
- @cancel="
- () => {
- collectSyncVisible = false;
- }
- "
- :columns="['合并本机和云端收藏', '备份本机收藏到云端', '恢复云端收藏到本机']"></van-picker>
- </van-popup>
- <!-- <listCom type="wrong"></listCom> -->
- <!-- <van-swipe ref="swiper" :show-indicators="false" :touchable="false">
- <van-swipe-item> <listCom type="wrong" /> </van-swipe-item>
- <van-swipe-item> <listCom type="collection" /> </van-swipe-item>
- </van-swipe> -->
- </div>
- </template>
- <script setup lang="ts">
- import { ref, onMounted } from "vue";
- import { useRouter, useRoute } from "vue-router";
- import listCom from "./components/list.vue";
- import collectionHeader from "@/assets/img/collectionHeader.png";
- import collectionBg from "@/assets/img/collectionBg.png";
- import wrongBg from "@/assets/img/wrongBg.png";
- import collectionBottomBg from "@/assets/img/collectionBottomBg.png";
- import goArrow from "@/assets/img/goArrow.png";
- import { CollectionModel } from "@/model/collection";
- import { CollectionAndWrong } from "@/api/index";
- import { Dialog } from "vant";
- import { RouterBus } from "@/hooks";
- const router = useRouter();
- const query = useRoute().query;
- const wrongList = ref<CollectionAndWrongType.Question[]>([]);
- const collectionList = ref<CollectionAndWrongType.Question[]>([]);
- onMounted(() => {
- let wrongModel = new CollectionAndWrong("wrong");
- wrongModel
- .getList({
- km: router.currentRoute.value.query.subject === "1" ? "科目一" : "科目四",
- carType: router.currentRoute.value.query.vehicle as CollectionAndWrongType.CarType,
- })
- .then((res) => {
- wrongList.value = res.rows;
- });
- let collectionModel = new CollectionAndWrong("collection");
- collectionModel
- .getList({
- km: router.currentRoute.value.query.subject === "1" ? "科目一" : "科目四",
- carType: router.currentRoute.value.query.vehicle as CollectionAndWrongType.CarType,
- })
- .then((res) => {
- collectionList.value = res.rows;
- });
- });
- const onClickLeft = () => {
- router.back();
- };
- const {
- router: { push },
- } = new RouterBus();
- const gsMap: {
- xc: string;
- hc: string;
- kc: string;
- mtc: string;
- } = {
- xc: "小车",
- hc: "货车",
- kc: "客车",
- mtc: "摩托车",
- };
- const clearTopicsCollection = (e: PointerEvent) => {
- e.preventDefault();
- e.stopPropagation();
- let collectionModel = new CollectionModel("collection");
- Dialog.confirm({
- title: "清除收藏",
- message: "是否清除收藏",
- })
- .then(() => {
- // on confirm
- collectionModel
- .deleteAll({
- km: router.currentRoute.value.query.subject === "1" ? "科目一" : "科目四",
- carType: gsMap[router.currentRoute.value.query.gs] as CollectionAndWrongType.CarType,
- })
- .then((res) => {
- Dialog.alert({ message: "清除成功" });
- let collectionModel = new CollectionAndWrong("collection");
- collectionModel
- .getList({
- km: router.currentRoute.value.query.subject === "1" ? "科目一" : "科目四",
- carType: router.currentRoute.value.query.vehicle as CollectionAndWrongType.CarType,
- })
- .then((res) => {
- collectionList.value = res.rows;
- });
- });
- })
- .catch(() => {
- // on cancel
- });
- };
- const clearTopicsWrong = (e: PointerEvent) => {
- e.preventDefault();
- e.stopPropagation();
- let collectionModel = new CollectionModel("wrong");
- Dialog.confirm({
- title: "清除错题",
- message: "是否清除错题",
- })
- .then(() => {
- // on confirm
- collectionModel
- .deleteAll({
- km: router.currentRoute.value.query.subject === "1" ? "科目一" : "科目四",
- carType: router.currentRoute.value.query.vehicle as CollectionAndWrongType.CarType,
- })
- .then((res) => {
- Dialog.alert({ message: "清除成功" });
- let wrongModel = new CollectionAndWrong("wrong");
- wrongModel
- .getList({
- km: router.currentRoute.value.query.subject === "1" ? "科目一" : "科目四",
- carType: router.currentRoute.value.query.vehicle as CollectionAndWrongType.CarType,
- })
- .then((res) => {
- wrongList.value = res.rows;
- });
- });
- })
- .catch(() => {
- // on cancel
- });
- };
- const goExercise = (type: string) => {
- switch (type) {
- case "wrong":
- if (wrongList.value.length == 0) {
- Dialog.alert({ title: "没有题目" });
- return;
- }
- push({
- name: "wrongExercise",
- query: {
- ...query,
- title: "错题",
- },
- });
- break;
- case "collection":
- if (collectionList.value.length == 0) {
- Dialog.alert({ title: "没有题目" });
- return;
- }
- push({
- name: "collectionExercise",
- query: {
- ...query,
- title: "收藏",
- },
- });
- break;
- default:
- break;
- }
- };
- const isType = ref(0); //0错题 1收藏
- const swiper = ref();
- const wrongSyncVisible = ref(false);
- const collectSyncVisible = ref(false);
- </script>
- <style lang="scss" scoped>
- .bottom {
- bottom: 0;
- img {
- width: 100%;
- }
- }
- .choose {
- width: 100%;
- display: flex;
- justify-content: center;
- flex-wrap: wrap;
- transform: translate(0%, -8%);
- .choose-img {
- width: 92%;
- position: relative;
- .clear {
- background: #fff;
- border-radius: 15px;
- position: absolute;
- bottom: 20px;
- width: 100px;
- height: 30px;
- left: 20px;
- bottom: 20px;
- border: 0;
- font-size: 13px;
- }
- .goArrow {
- position: absolute;
- top: 32px;
- right: 20px;
- width: 73px;
- }
- .choose-text1 {
- position: absolute;
- font-size: 25px;
- color: #fff;
- left: 20px;
- top: 20px;
- }
- .choose-text2 {
- position: absolute;
- top: 56px;
- left: 22px;
- font-size: 25px;
- color: #fff;
- }
- img {
- width: 100%;
- }
- }
- }
- .collectionHeader {
- width: 100%;
- }
- .collection-box {
- height: 100vh;
- display: flex;
- flex-direction: column;
- }
- .title {
- display: flex;
- width: 130px;
- justify-content: space-between;
- align-items: center;
- span {
- font-size: 15px;
- font-family: PingFang SC;
- font-weight: 400;
- line-height: 13px;
- color: #0a1a33;
- position: relative;
- padding: 8px;
- }
- .active {
- &:after {
- position: absolute;
- content: "";
- width: 20px;
- height: 4px;
- border-radius: 3px;
- background-color: #498ef5;
- bottom: 0;
- left: 50%;
- transform: translateX(-50%);
- z-index: 100;
- }
- }
- }
- </style>
|