|
@@ -137,9 +137,9 @@
|
|
|
"
|
|
|
@confirm="syncWrongQuestion"
|
|
|
:columns="[
|
|
|
- { text: '合并本机和云端收藏', type: 'wrong', value: 0 },
|
|
|
- { text: '备份本机收藏到云端', type: 'wrong', value: 1 },
|
|
|
- { text: '恢复云端收藏到本机', type: 'wrong', value: 2 },
|
|
|
+ { text: '合并本机和云端错题', type: 'wrong', value: 0 },
|
|
|
+ { text: '备份本机错题到云端', type: 'wrong', value: 1 },
|
|
|
+ { text: '恢复云端错题到本机', type: 'wrong', value: 2 },
|
|
|
]"
|
|
|
show-toolbar
|
|
|
title="同步错题"
|
|
@@ -213,19 +213,31 @@ export default {
|
|
|
wrongSyncShow: false,
|
|
|
collectSyncShow: false,
|
|
|
wrongList: [],
|
|
|
- wrongListCount: uni.getStorageSync("userWrongIds")
|
|
|
- ? uni.getStorageSync("userWrongIds").length
|
|
|
- : 0,
|
|
|
+ wrongListCount: 0,
|
|
|
|
|
|
collectionList: [],
|
|
|
- collectionListCount: uni.getStorageSync("userCollectionIds")
|
|
|
- ? uni.getStorageSync("userCollectionIds").length
|
|
|
- : 0,
|
|
|
+ collectionListCount: 0,
|
|
|
};
|
|
|
},
|
|
|
onLoad(query) {
|
|
|
this.query = query;
|
|
|
this.user;
|
|
|
+ let storageName1 =
|
|
|
+ uni.getStorageSync("userInfo").xcxOpenid +
|
|
|
+ "_userWrongIds_" +
|
|
|
+ this.query.subject;
|
|
|
+
|
|
|
+ let storageName2 =
|
|
|
+ uni.getStorageSync("userInfo").xcxOpenid +
|
|
|
+ "_userCollectionIds_" +
|
|
|
+ this.query.subject;
|
|
|
+
|
|
|
+ this.wrongListCount = uni.getStorageSync(storageName1)
|
|
|
+ ? uni.getStorageSync(storageName1).length
|
|
|
+ : 0;
|
|
|
+ this.collectionListCount = uni.getStorageSync(storageName2)
|
|
|
+ ? uni.getStorageSync(storageName2).length
|
|
|
+ : 0;
|
|
|
|
|
|
// api.exam
|
|
|
// .studentQuestionWrongWrongCountByUser({
|
|
@@ -241,51 +253,75 @@ export default {
|
|
|
methods: {
|
|
|
syncCollectQuestion(e) {
|
|
|
let select = e.detail.value;
|
|
|
+ let storageName =
|
|
|
+ uni.getStorageSync("userInfo").xcxOpenid +
|
|
|
+ "_userCollectionIds_" +
|
|
|
+ this.query.subject;
|
|
|
+ uni.getStorageSync(storageName)
|
|
|
+ ? ""
|
|
|
+ : uni.setStorageSync(storageName, []);
|
|
|
switch (select.value) {
|
|
|
- case 0:
|
|
|
+ case 0:
|
|
|
api.exam
|
|
|
- .studentQuestionCollectionBakCollections({
|
|
|
+ .studentQuestionCollectionCollections({
|
|
|
km: Number(this.query.subject),
|
|
|
- questionIds: uni
|
|
|
- .getStorageSync("userCollectionIds")
|
|
|
- .map((item) => item),
|
|
|
+ questionIds: uni.getStorageSync(storageName).map((item) => item),
|
|
|
})
|
|
|
.then((res) => {
|
|
|
- api.exam.studentQuestionCollectionCollectionByUser().then((result) => {
|
|
|
- let userCollectionIds = result.data.map((item) => {
|
|
|
- return item.id;
|
|
|
+ uni.showToast({
|
|
|
+ title:"合并成功"
|
|
|
+ })
|
|
|
+ api.exam
|
|
|
+ .studentQuestionCollectionCollectionByUser({
|
|
|
+ km: Number(this.query.subject),
|
|
|
+ })
|
|
|
+ .then((result) => {
|
|
|
+ let userCollectionIds = result.data.map((item) => {
|
|
|
+ return item.id;
|
|
|
+ });
|
|
|
+ uni.setStorageSync(storageName, userCollectionIds);
|
|
|
+ this.collectionListCount = userCollectionIds.length;
|
|
|
});
|
|
|
- uni.setStorageSync("userCollectionIds", userCollectionIds);
|
|
|
- this.collectionListCount = userCollectionIds.length;
|
|
|
- });
|
|
|
});
|
|
|
break;
|
|
|
case 1:
|
|
|
api.exam
|
|
|
- .studentQuestionWrongBakWrongs({
|
|
|
+ .studentQuestionCollectionBakCollections({
|
|
|
km: Number(this.query.subject),
|
|
|
- questionIds: uni
|
|
|
- .getStorageSync("userCollectionIds")
|
|
|
- .map((item) => item),
|
|
|
+ questionIds: uni.getStorageSync(storageName).map((item) => item),
|
|
|
})
|
|
|
.then((res) => {
|
|
|
- api.exam.studentQuestionWrongWrongByUser().then((result) => {
|
|
|
- let userCollectionIds = result.data.map((item) => {
|
|
|
- return item.id;
|
|
|
+ uni.showToast({
|
|
|
+ title:"备份成功"
|
|
|
+ })
|
|
|
+ api.exam
|
|
|
+ .studentQuestionCollectionCollectionByUser({
|
|
|
+ km: Number(this.query.subject),
|
|
|
+ })
|
|
|
+ .then((result) => {
|
|
|
+ let userCollectionIds = result.data.map((item) => {
|
|
|
+ return item.id;
|
|
|
+ });
|
|
|
+ uni.setStorageSync(storageName, userCollectionIds);
|
|
|
+ this.collectionListCount = userCollectionIds.length;
|
|
|
});
|
|
|
- uni.setStorageSync("userCollectionIds", userCollectionIds);
|
|
|
- this.collectionListCount = userCollectionIds.length;
|
|
|
- });
|
|
|
});
|
|
|
break;
|
|
|
case 2:
|
|
|
- api.exam.studentQuestionWrongWrongByUser().then((result) => {
|
|
|
- let userCollectionIds = result.data.map((item) => {
|
|
|
- return item.id;
|
|
|
+ api.exam
|
|
|
+ .studentQuestionCollectionCollectionByUser({
|
|
|
+ km: Number(this.query.subject),
|
|
|
+ })
|
|
|
+ .then((result) => {
|
|
|
+ uni.showToast({
|
|
|
+ title:"恢复成功"
|
|
|
+ })
|
|
|
+ let userCollectionIds = result.data.map((item) => {
|
|
|
+ return item.id;
|
|
|
+ });
|
|
|
+ uni.setStorageSync(storageName, userCollectionIds);
|
|
|
+ this.collectionListCount = userCollectionIds.length;
|
|
|
});
|
|
|
- uni.setStorageSync("userCollectionIds", userCollectionIds);
|
|
|
- this.collectionListCount = userCollectionIds.length;
|
|
|
- });
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
@@ -294,52 +330,77 @@ export default {
|
|
|
},
|
|
|
syncWrongQuestion(e) {
|
|
|
let select = e.detail.value;
|
|
|
+ let storageName =
|
|
|
+ uni.getStorageSync("userInfo").xcxOpenid +
|
|
|
+ "_userWrongIds_" +
|
|
|
+ this.query.subject;
|
|
|
+ uni.getStorageSync(storageName)
|
|
|
+ ? ""
|
|
|
+ : uni.setStorageSync(storageName, []);
|
|
|
+
|
|
|
console.log(e);
|
|
|
switch (select.value) {
|
|
|
case 0:
|
|
|
api.exam
|
|
|
.studentQuestionWrongWrongs({
|
|
|
km: Number(this.query.subject),
|
|
|
- questionIds: uni
|
|
|
- .getStorageSync("userWrongIds")
|
|
|
- .map((item) => item),
|
|
|
+ questionIds: uni.getStorageSync(storageName).map((item) => item),
|
|
|
})
|
|
|
.then((res) => {
|
|
|
- api.exam.studentQuestionWrongWrongByUser().then((result) => {
|
|
|
- let userWrongIds = result.data.map((item) => {
|
|
|
- return item.id;
|
|
|
+ uni.showToast({
|
|
|
+ title:'合并成功'
|
|
|
+ })
|
|
|
+ api.exam
|
|
|
+ .studentQuestionWrongWrongByUser({
|
|
|
+ km: Number(this.query.subject),
|
|
|
+ })
|
|
|
+ .then((result) => {
|
|
|
+ let userWrongIds = result.data.map((item) => {
|
|
|
+ return item.id;
|
|
|
+ });
|
|
|
+ uni.setStorageSync(storageName, userWrongIds);
|
|
|
+ this.wrongListCount = userWrongIds.length;
|
|
|
});
|
|
|
- uni.setStorageSync("userWrongIds", userWrongIds);
|
|
|
- this.wrongListCount = userWrongIds.length;
|
|
|
- });
|
|
|
});
|
|
|
break;
|
|
|
case 1:
|
|
|
api.exam
|
|
|
.studentQuestionWrongBakWrongs({
|
|
|
km: Number(this.query.subject),
|
|
|
- questionIds: uni
|
|
|
- .getStorageSync("userWrongIds")
|
|
|
- .map((item) => item),
|
|
|
+ questionIds: uni.getStorageSync(storageName).map((item) => item),
|
|
|
})
|
|
|
.then((res) => {
|
|
|
- api.exam.studentQuestionWrongWrongByUser().then((result) => {
|
|
|
- let userWrongIds = result.data.map((item) => {
|
|
|
- return item.id;
|
|
|
+ uni.showToast({
|
|
|
+ title:'备份成功'
|
|
|
+ })
|
|
|
+ api.exam
|
|
|
+ .studentQuestionWrongWrongByUser({
|
|
|
+ km: Number(this.query.subject),
|
|
|
+ })
|
|
|
+ .then((result) => {
|
|
|
+ let userWrongIds = result.data.map((item) => {
|
|
|
+ return item.id;
|
|
|
+ });
|
|
|
+ uni.setStorageSync(storageName, userWrongIds);
|
|
|
+ this.wrongListCount = userWrongIds.length;
|
|
|
});
|
|
|
- uni.setStorageSync("userWrongIds", userWrongIds);
|
|
|
- this.wrongListCount = userWrongIds.length;
|
|
|
- });
|
|
|
});
|
|
|
break;
|
|
|
case 2:
|
|
|
- api.exam.studentQuestionWrongWrongByUser().then((result) => {
|
|
|
- let userWrongIds = result.data.map((item) => {
|
|
|
- return item.id;
|
|
|
+ api.exam
|
|
|
+ .studentQuestionWrongWrongByUser({
|
|
|
+ km: Number(this.query.subject),
|
|
|
+ })
|
|
|
+ .then((result) => {
|
|
|
+ uni.showToast({
|
|
|
+ title:'恢复成功'
|
|
|
+ })
|
|
|
+ let userWrongIds = result.data.map((item) => {
|
|
|
+ return item.id;
|
|
|
+ });
|
|
|
+ uni.setStorageSync(storageName, userWrongIds);
|
|
|
+ this.wrongListCount = userWrongIds.length;
|
|
|
});
|
|
|
- uni.setStorageSync("userWrongIds", userWrongIds);
|
|
|
- this.wrongListCount = userWrongIds.length;
|
|
|
- });
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
@@ -377,22 +438,26 @@ export default {
|
|
|
},
|
|
|
clearTopics(type) {
|
|
|
let that = this;
|
|
|
+ let storageName = "";
|
|
|
if (type === "wrong") {
|
|
|
- uni.showModal({
|
|
|
+ storageName = uni.showModal({
|
|
|
title: "是否清空错题",
|
|
|
success(res) {
|
|
|
+ let storageName =
|
|
|
+ uni.getStorageSync("userInfo").xcxOpenid +
|
|
|
+ "_userWrongIds_" +
|
|
|
+ that.query.subject;
|
|
|
if (res.confirm) {
|
|
|
api.exam
|
|
|
.studentQuestionWrongCancelAll({
|
|
|
carType: that.gsMap[that.query.gs],
|
|
|
- km: that.query.subject === "1" ? "科目一" : "科目四",
|
|
|
+ km: Number(that.query.subject),
|
|
|
})
|
|
|
.then((res) => {
|
|
|
- uni.setStorageSync("userWrongIds", []);
|
|
|
+ uni.setStorageSync(storageName, []);
|
|
|
api.exam
|
|
|
.studentQuestionWrongWrongCountByUser({
|
|
|
- carType: that.gsMap[that.query.gs],
|
|
|
- km: that.query.subject === "1" ? "科目一" : "科目四",
|
|
|
+ km: Number(that.query.subject),
|
|
|
pageNum: 1,
|
|
|
pageSize: 10000,
|
|
|
})
|
|
@@ -407,18 +472,21 @@ export default {
|
|
|
uni.showModal({
|
|
|
title: "是否清空收藏题",
|
|
|
success(res) {
|
|
|
+ let storageName =
|
|
|
+ uni.getStorageSync("userInfo").xcxOpenid +
|
|
|
+ "_userCollectionIds_" +
|
|
|
+ that.query.subject;
|
|
|
if (res.confirm) {
|
|
|
api.exam
|
|
|
.studentQuestionCollectionCancelAll({
|
|
|
- carType: that.gsMap[that.query.gs],
|
|
|
- km: that.query.subject === "1" ? "科目一" : "科目四",
|
|
|
+ km: Number(that.query.subject),
|
|
|
})
|
|
|
.then((res) => {
|
|
|
- uni.setStorageSync("userCollectionIds", []);
|
|
|
+ uni.setStorageSync(storageName, []);
|
|
|
api.exam
|
|
|
.studentQuestionCollectionCollectionCountByUser({
|
|
|
carType: that.gsMap[that.query.gs],
|
|
|
- km: that.query.subject === "1" ? "科目一" : "科目四",
|
|
|
+ km: Number(that.query.subject),
|
|
|
pageNum: 1,
|
|
|
pageSize: 10000,
|
|
|
})
|