|
@@ -50,8 +50,12 @@
|
|
|
wrongSyncVisible = false;
|
|
|
}
|
|
|
"
|
|
|
-
|
|
|
- :columns="['合并本机和云端错题', '备份本机收藏到错题', '恢复云端收藏到错题']"></van-picker>
|
|
|
+ @confirm="sendWrongSync"
|
|
|
+ :columns="[
|
|
|
+ { text: '合并本机和云端错题', value: 0 },
|
|
|
+ { text: '备份本机收藏到错题', value: 1 },
|
|
|
+ { text: '恢复云端收藏到错题', value: 2 },
|
|
|
+ ]"></van-picker>
|
|
|
</van-popup>
|
|
|
|
|
|
<van-popup position="bottom" v-model:show="collectSyncVisible">
|
|
@@ -61,7 +65,12 @@
|
|
|
collectSyncVisible = false;
|
|
|
}
|
|
|
"
|
|
|
- :columns="['合并本机和云端收藏', '备份本机收藏到云端', '恢复云端收藏到本机']"></van-picker>
|
|
|
+ @confirm="sendCollectSync"
|
|
|
+ :columns="[
|
|
|
+ { text: '合并本机和云端收藏', value: 0 },
|
|
|
+ { text: '备份本机收藏到云端', value: 1 },
|
|
|
+ { text: '恢复云端收藏到本机', value: 2 },
|
|
|
+ ]"></van-picker>
|
|
|
</van-popup>
|
|
|
<!-- <listCom type="wrong"></listCom> -->
|
|
|
<!-- <van-swipe ref="swiper" :show-indicators="false" :touchable="false">
|
|
@@ -86,27 +95,15 @@ 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[]>([]);
|
|
|
+const wrongList = ref<{ id: number; timestamp: number }[]>([]);
|
|
|
+const collectionList = ref<{ id: number; timestamp: number }[]>([]);
|
|
|
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;
|
|
|
- });
|
|
|
+ let localVuex = JSON.parse(window.localStorage.getItem("vuex") || "{}");
|
|
|
+ let subject = query.subject;
|
|
|
+ let userWrongKey = localVuex.userData.openid + "_用户错题id_" + subject;
|
|
|
+ let userCollectKey = localVuex.userData.openid + "_用户收藏id_" + subject;
|
|
|
+ wrongList.value = JSON.parse(window.localStorage.getItem(userWrongKey) || "[]");
|
|
|
+ collectionList.value = JSON.parse(window.localStorage.getItem(userCollectKey) || "[]");
|
|
|
});
|
|
|
const onClickLeft = () => {
|
|
|
router.back();
|
|
@@ -126,6 +123,113 @@ const gsMap: {
|
|
|
kc: "客车",
|
|
|
mtc: "摩托车",
|
|
|
};
|
|
|
+const sendWrongSync = (column: { text: string; value: number }) => {
|
|
|
+ let collectionModel = new CollectionAndWrong("wrong");
|
|
|
+ let km = Number(query.subject);
|
|
|
+ let localVuex = JSON.parse(window.localStorage.getItem("vuex") || "{}");
|
|
|
+ let subject = query.subject;
|
|
|
+ let userWrongKey = localVuex.userData.openid + "_用户错题id_" + subject;
|
|
|
+ switch (column.value) {
|
|
|
+ case 0:
|
|
|
+ collectionModel
|
|
|
+ .merge({
|
|
|
+ wrongs: wrongList.value,
|
|
|
+ km,
|
|
|
+ })
|
|
|
+ .then((res) => {
|
|
|
+ collectionModel
|
|
|
+ .getList({
|
|
|
+ km,
|
|
|
+ })
|
|
|
+ .then((res) => {
|
|
|
+ wrongList.value = res.data;
|
|
|
+ window.localStorage.setItem(userWrongKey, JSON.stringify(wrongList.value));
|
|
|
+ });
|
|
|
+ });
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ collectionModel
|
|
|
+ .backups({
|
|
|
+ wrongs: wrongList.value,
|
|
|
+ km,
|
|
|
+ })
|
|
|
+ .then((res) => {
|
|
|
+ collectionModel
|
|
|
+ .getList({
|
|
|
+ km,
|
|
|
+ })
|
|
|
+ .then((res) => {
|
|
|
+ wrongList.value = res.data;
|
|
|
+ });
|
|
|
+ });
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ collectionModel
|
|
|
+ .getList({
|
|
|
+ km,
|
|
|
+ })
|
|
|
+ .then((res) => {
|
|
|
+ wrongList.value = res.data;
|
|
|
+ window.localStorage.setItem(userWrongKey, JSON.stringify(wrongList.value));
|
|
|
+ });
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ wrongSyncVisible.value = false;
|
|
|
+};
|
|
|
+const sendCollectSync = (column: { text: string; value: number }) => {
|
|
|
+ let collectionModel = new CollectionAndWrong("collection");
|
|
|
+ let km = Number(query.subject);
|
|
|
+ let localVuex = JSON.parse(window.localStorage.getItem("vuex") || "{}");
|
|
|
+ let subject = query.subject;
|
|
|
+ let userCollectKey = localVuex.userData.openid + "_用户收藏id_" + subject;
|
|
|
+
|
|
|
+ switch (column.value) {
|
|
|
+ case 0:
|
|
|
+ collectionModel
|
|
|
+ .merge({
|
|
|
+ cols: collectionList.value,
|
|
|
+ km,
|
|
|
+ })
|
|
|
+ .then((res) => {
|
|
|
+ collectionModel
|
|
|
+ .getList({
|
|
|
+ km,
|
|
|
+ })
|
|
|
+ .then((res) => {
|
|
|
+ collectionList.value = res.data;
|
|
|
+ window.localStorage.setItem(userCollectKey, JSON.stringify(collectionList.value));
|
|
|
+ });
|
|
|
+ });
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ collectionModel
|
|
|
+ .backups({
|
|
|
+ cols: collectionList.value,
|
|
|
+ km,
|
|
|
+ })
|
|
|
+ .then((res) => {
|
|
|
+ collectionModel
|
|
|
+ .getList({
|
|
|
+ km,
|
|
|
+ })
|
|
|
+ .then((res) => {
|
|
|
+ collectionList.value = res.data;
|
|
|
+ });
|
|
|
+ });
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ collectionModel
|
|
|
+ .getList({
|
|
|
+ km,
|
|
|
+ })
|
|
|
+ .then((res) => {
|
|
|
+ collectionList.value = res.data;
|
|
|
+ window.localStorage.setItem(userCollectKey, JSON.stringify(collectionList.value));
|
|
|
+ });
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ collectSyncVisible.value = false;
|
|
|
+};
|
|
|
const clearTopicsCollection = (e: PointerEvent) => {
|
|
|
e.preventDefault();
|
|
|
e.stopPropagation();
|
|
@@ -138,19 +242,21 @@ const clearTopicsCollection = (e: PointerEvent) => {
|
|
|
// on confirm
|
|
|
collectionModel
|
|
|
.deleteAll({
|
|
|
- km: router.currentRoute.value.query.subject === "1" ? "科目一" : "科目四",
|
|
|
- carType: gsMap[router.currentRoute.value.query.gs] as CollectionAndWrongType.CarType,
|
|
|
+ km: Number(router.currentRoute.value.query.subject),
|
|
|
})
|
|
|
.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,
|
|
|
+ km: Number(router.currentRoute.value.query.subject),
|
|
|
})
|
|
|
.then((res) => {
|
|
|
- collectionList.value = res.rows;
|
|
|
+ let localVuex = JSON.parse(window.localStorage.getItem("vuex") || "{}");
|
|
|
+ let subject = query.subject;
|
|
|
+ let userCollectKey = localVuex.userData.openid + "_用户收藏id_" + subject;
|
|
|
+ window.localStorage.setItem(userCollectKey, "[]");
|
|
|
+ collectionList.value = [];
|
|
|
});
|
|
|
});
|
|
|
})
|
|
@@ -170,19 +276,22 @@ const clearTopicsWrong = (e: PointerEvent) => {
|
|
|
// on confirm
|
|
|
collectionModel
|
|
|
.deleteAll({
|
|
|
- km: router.currentRoute.value.query.subject === "1" ? "科目一" : "科目四",
|
|
|
- carType: router.currentRoute.value.query.vehicle as CollectionAndWrongType.CarType,
|
|
|
+ km: Number(router.currentRoute.value.query.subject),
|
|
|
})
|
|
|
.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,
|
|
|
+ km: Number(router.currentRoute.value.query.subject),
|
|
|
})
|
|
|
.then((res) => {
|
|
|
- wrongList.value = res.rows;
|
|
|
+ let localVuex = JSON.parse(window.localStorage.getItem("vuex") || "{}");
|
|
|
+ let subject = query.subject;
|
|
|
+ let userWrongKey = localVuex.userData.openid + "_用户错题id_" + subject;
|
|
|
+ window.localStorage.setItem(userWrongKey, "[]");
|
|
|
+ wrongList.value = [];
|
|
|
});
|
|
|
});
|
|
|
})
|