This commit is contained in:
qsh
2025-06-11 17:16:12 +08:00
parent d70a0141cc
commit 7442289a87
4 changed files with 148 additions and 227 deletions

View File

@@ -6,6 +6,7 @@ VITE_APP_ENV = 'development'
# 金武联驾校/开发环境 # 金武联驾校/开发环境
VITE_APP_BASE_API = 'https://jwl.ahduima.com/' VITE_APP_BASE_API = 'https://jwl.ahduima.com/'
# VITE_APP_BASE_API = 'http://tk-api.ahfkbg.com/'
# #
VITE_WEB_BASE_URL = 'https://jwl.ahduima.com' VITE_WEB_BASE_URL = 'https://jwl.ahduima.com'
# 资源地址 # 资源地址

View File

@@ -1,238 +1,158 @@
import { import { defineStore } from 'pinia';
defineStore
} from 'pinia';
import http from '@/jtools/request/index'; import http from '@/jtools/request/index';
import { import { queryQuestion, getVersion, querySysConfig } from '@/jtools/api/question';
queryQuestion,
getVersion,
querySysConfig
} from '@/jtools/api/question';
import storage from '@/jtools/storage'; import storage from '@/jtools/storage';
let JSON_SPLIT_LENGTH = 10;
const question = defineStore({ const question = defineStore({
id: 'question', id: 'question',
state: () => ({ state: () => ({
currentCartype: storage.get('carType') || '1001', currentCartype: storage.get('carType') || '1001',
currentCarName: storage.get('carName') || '小车C1/C2/C3', currentCarName: storage.get('carName') || '小车C1/C2/C3',
orderQuestion_subject1: storage.get('question_subject1') || [], //科目一顺序做题 orderQuestion_subject1: storage.get('question_subject1') || [], //科目一顺序做题
orderQuestion_subject4: storage.get('question_subject4') || [], //科目四顺序做题 orderQuestion_subject4: storage.get('question_subject4') || [], //科目四顺序做题
currentIndex_subject1: 0, //科目一索引 顺序做题 currentIndex_subject1: 0, //科目一索引 顺序做题
currentIndex_subject4: 0, //科目四索引 顺序做题 currentIndex_subject4: 0, //科目四索引 顺序做题
curSubject: storage.get('curSubject') || '1', curSubject: storage.get('curSubject') || '1',
loading_subject1: false, loading_subject1: false,
loading_subject4: false, loading_subject4: false,
version: storage.get('version') || '' version: storage.get('version') || ''
}), }),
actions: { actions: {
resetStorage(){ resetStorage() {
this.currentIndex_subject1=0 this.currentIndex_subject1 = 0;
this.currentIndex_subject4=0 this.currentIndex_subject4 = 0;
this.curSubject=0 this.curSubject = 0;
storage.remove('curSubject') storage.remove('curSubject');
storage.remove('wrongList_subject1') storage.remove('wrongList_subject1');
storage.remove('wrongList_subject4') storage.remove('wrongList_subject4');
storage.remove('rightList_subject1') storage.remove('rightList_subject1');
storage.remove('rightList_subject4') storage.remove('rightList_subject4');
this.getAllQuestion() // this.getAllQuestion()
}, },
getAllQuestion() { getAllQuestion() {
this.currentCartype = storage.get('carType') || '1001' this.currentCartype = storage.get('carType') || '1001';
getVersion(this.currentCartype).then(resp => { getVersion(this.currentCartype).then(resp => {
if (resp.code === '0000') { if (resp.code === '0000') {
querySysConfig(this.currentCartype, 'QuestionBank').then(res => { querySysConfig(this.currentCartype, 'QuestionBank').then(res => {
const urlList = JSON.parse(res.data.configJson) const urlList = JSON.parse(res.data.configJson);
const urlOne = urlList.find(item => item.subject == '1').url const urlOne = urlList.find(item => item.subject == '1').url;
const urlFour = urlList.find(item => item.subject == '4').url const urlFour = urlList.find(item => item.subject == '4').url;
if (this.version != resp.data) { if (this.version != resp.data) {
this.version = resp.data this.version = resp.data;
storage.set('version', resp.data) storage.set('version', resp.data);
this.getOrderQuestion_sub1(true, urlOne) this.getOrderQuestion_sub1(true, urlOne);
this.getOrderQuestion_sub4(true, urlFour) this.getOrderQuestion_sub4(true, urlFour);
} else { } else {
this.getOrderQuestion_sub1(false, urlOne) this.getOrderQuestion_sub1(false, urlOne);
this.getOrderQuestion_sub4(false, urlOne) this.getOrderQuestion_sub4(false, urlOne);
} }
}) });
}
});
},
divideArray(array, numChunks) {
var chunkSize = Math.ceil(array.length / numChunks);
var dividedArray = [];
for (var i = 0; i < array.length; i += chunkSize) {
dividedArray.push(array.slice(i, i + chunkSize));
}
return dividedArray;
},
} //改变当前科目
}) changeSubject(val) {
}, this.curSubject = val;
divideArray(array, numChunks) { storage.set('curSubject', val);
var chunkSize = Math.ceil(array.length / numChunks); },
var dividedArray = []; // 获取顺序做题科目1
for (var i = 0; i < array.length; i += chunkSize) { getOrderQuestion_sub1(isUpdate, url) {
dividedArray.push(array.slice(i, i + chunkSize)); if (isUpdate) {
} this.loading_subject1 = true;
return dividedArray; this.loadAllQuestion(url, 1);
}, } else {
this.orderQuestion_subject4 = [];
//改变当前科目 for (let i = 0; i < JSON_SPLIT_LENGTH; i++) {
changeSubject(val) { const arr = uni.getStorageSync(`question4Sub${i + 1}`) || [];
this.curSubject = val this.orderQuestion_subject4 = [...this.orderQuestion_subject4, ...arr];
storage.set('curSubject', val) }
}, if (this.orderQuestion_subject1 && this.orderQuestion_subject1.length) {
// 获取顺序做题科目1 } else {
getOrderQuestion_sub1(isUpdate, url) { this.loading_subject1 = true;
if (isUpdate) { this.loadAllQuestion(url, 1);
this.loading_subject1 = true }
const that = this }
uni.request({ },
url: url, // 获取顺序做题科目4
success(resp) { getOrderQuestion_sub4(isUpdate, url) {
if (resp.data) { if (isUpdate) {
that.orderQuestion_subject1 = resp.data.data this.loading_subject4 = true;
const diveList = that.divideArray(that.orderQuestion_subject1, 5) this.loadAllQuestion(url, 4);
that.loading_subject1 = false } else {
uni.setStorageSync('questionOneSub1', diveList[0]) this.orderQuestion_subject4 = [];
uni.setStorageSync('questionOneSub2', diveList[1]) for (let i = 0; i < JSON_SPLIT_LENGTH; i++) {
uni.setStorageSync('questionOneSub3', diveList[2]) const arr = uni.getStorageSync(`question1Sub${i + 1}`) || [];
uni.setStorageSync('questionOneSub4', diveList[3]) this.orderQuestion_subject4 = [...this.orderQuestion_subject4, ...arr];
uni.setStorageSync('questionOneSub5', diveList[4]) }
const falseList = storage.get('wrongList_subject1') || [] if (this.orderQuestion_subject4 && this.orderQuestion_subject4.length) {
const trueList = storage.get('rightList_subject1') || [] } else {
const falseArr = [] this.loading_subject4 = true;
const rightArr = [] this.loadAllQuestion(url, 4);
that.orderQuestion_subject1.forEach(item => { }
}
},
// 加载线上题目
loadAllQuestion(url, course) {
const that = this;
uni.request({
url: url,
success(resp) {
if (resp?.data) {
try {
for (let i = 0; i < JSON_SPLIT_LENGTH; i++) {
storage.remove(`question${course}Sub${i + 1}`);
}
that[`orderQuestion_subject${course}`] = resp.data?.data || [];
const diveList = that.divideArray(that.orderQuestion_subject4, JSON_SPLIT_LENGTH);
that[`loading_subject${course}`] = false;
for (let i = 0; i < JSON_SPLIT_LENGTH; i++) {
uni.setStorageSync(`question${course}Sub${i + 1}`, diveList[i]);
}
const falseList = storage.get(`wrongList_subject${course}`) || [];
const trueList = storage.get(`rightList_subject${course}`) || [];
const falseArr = [];
const rightArr = [];
that[`orderQuestion_subject${course}`].forEach(item => {
if (falseList.includes(item.questionId)) { if (falseList.includes(item.questionId)) {
falseArr.push(item.questionId) falseArr.push(item.questionId);
} }
if (trueList.includes(item.questionId)) { if (trueList.includes(item.questionId)) {
rightArr.push(item.questionId) rightArr.push(item.questionId);
} }
}) });
storage.set('wrongList_subject1', falseArr) storage.set(`wrongList_subject${course}`, falseArr);
storage.set('rightList_subject1', rightArr) storage.set(`rightList_subject${course}`, rightArr);
} catch () {
uni.showToast({
title: '题库下载异常,请稍后再试',
icon: 'none'
});
} }
} } else {
}) uni.showToast({
} else { title: '加载题目失败,请稍后再试',
const list1 = uni.getStorageSync('questionOneSub1') || [] icon: 'none'
const list2 = uni.getStorageSync('questionOneSub2') || [] });
const list3 = uni.getStorageSync('questionOneSub3') || [] }
const list4 = uni.getStorageSync('questionOneSub4') || [] }
const list5 = uni.getStorageSync('questionOneSub5') || [] });
this.orderQuestion_subject1 = [...list1, ...list2, ...list3, ...list4, ...list5] },
if (this.orderQuestion_subject1 && this.orderQuestion_subject1.length) { //获取索引
getCurrentIndex(index, val) {
} else { this[`currentIndex_subject${val}`] = index;
this.loading_subject1 = true }
const that = this }
uni.request({
url: url,
success(resp) {
if (resp.data) {
that.orderQuestion_subject1 = resp.data.data
const diveList = that.divideArray(that.orderQuestion_subject1, 5)
that.loading_subject1 = false
uni.setStorageSync('questionOneSub1', diveList[0])
uni.setStorageSync('questionOneSub2', diveList[1])
uni.setStorageSync('questionOneSub3', diveList[2])
uni.setStorageSync('questionOneSub4', diveList[3])
uni.setStorageSync('questionOneSub5', diveList[4])
const falseList = storage.get('wrongList_subject1') || []
const trueList = storage.get('rightList_subject1') || []
const falseArr = []
const rightArr = []
that.orderQuestion_subject1.forEach(item => {
if (falseList.includes(item.questionId)) {
falseArr.push(item.questionId)
}
if (trueList.includes(item.questionId)) {
rightArr.push(item.questionId)
}
})
storage.set('wrongList_subject1', falseArr)
storage.set('rightList_subject1', rightArr)
}
}
})
}
}
},
// 获取顺序做题科目4
getOrderQuestion_sub4(isUpdate, url) {
if (isUpdate) {
this.loading_subject4 = true
const that = this
uni.request({
url: url,
success(resp) {
if (resp.data) {
that.orderQuestion_subject4 = resp.data.data
const diveList = that.divideArray(that.orderQuestion_subject4, 5)
that.loading_subject4 = false
uni.setStorageSync('questionFourSub1', diveList[0])
uni.setStorageSync('questionFourSub2', diveList[1])
uni.setStorageSync('questionFourSub3', diveList[2])
uni.setStorageSync('questionFourSub4', diveList[3])
uni.setStorageSync('questionFourSub5', diveList[4])
const falseList = storage.get('wrongList_subject4') || []
const trueList = storage.get('rightList_subject4') || []
const falseArr = []
const rightArr = []
that.orderQuestion_subject4.forEach(item => {
if (falseList.includes(item.questionId)) {
falseArr.push(item.questionId)
}
if (trueList.includes(item.questionId)) {
rightArr.push(item.questionId)
}
})
storage.set('wrongList_subject4', falseArr)
storage.set('rightList_subject4', rightArr)
}
}
})
} else {
const list1 = uni.getStorageSync('questionFourSub1') || []
const list2 = uni.getStorageSync('questionFourSub2') || []
const list3 = uni.getStorageSync('questionFourSub3') || []
const list4 = uni.getStorageSync('questionFourSub4') || []
const list5 = uni.getStorageSync('questionFourSub5') || []
this.orderQuestion_subject4 = [...list1, ...list2, ...list3, ...list4, ...list5]
if (this.orderQuestion_subject4 && this.orderQuestion_subject4.length) {
} else {
this.loading_subject4 = true
const that = this
uni.request({
url: url,
success(resp) {
if (resp.data) {
that.orderQuestion_subject4 = resp.data.data
const diveList = that.divideArray(that.orderQuestion_subject4, 5)
that.loading_subject4 = false
uni.setStorageSync('questionFourSub1', diveList[0])
uni.setStorageSync('questionFourSub2', diveList[1])
uni.setStorageSync('questionFourSub3', diveList[2])
uni.setStorageSync('questionFourSub4', diveList[3])
uni.setStorageSync('questionFourSub5', diveList[4])
const falseList = storage.get('wrongList_subject4') || []
const trueList = storage.get('rightList_subject4') || []
const falseArr = []
const rightArr = []
that.orderQuestion_subject4.forEach(item => {
if (falseList.includes(item.questionId)) {
falseArr.push(item.questionId)
}
if (trueList.includes(item.questionId)) {
rightArr.push(item.questionId)
}
})
storage.set('wrongList_subject4', falseArr)
storage.set('rightList_subject4', rightArr)
}
}
})
}
}
},
//获取索引
getCurrentIndex(index, val) {
this[`currentIndex_subject${val}`] = index
}
}
}); });
export default question; export default question;

View File

@@ -42,7 +42,7 @@
<view class="absolute flex ai-c jc-c" style="left: 0;top: 40px;right: 0;bottom: 0;"> <view class="absolute flex ai-c jc-c" style="left: 0;top: 40px;right: 0;bottom: 0;">
<view v-if="!isLogin || !vipOn.length" class="text-center"> <view v-if="!isLogin || !vipOn.length" class="text-center">
<view class="fs18 fwb" style="color: #7E4012FF;">开通VIP尊享以下权益</view> <view class="fs18 fwb" style="color: #7E4012FF;">开通VIP尊享以下权益</view>
<view class="fs15" style="color: #7E4012FF;">精选500题 / 模考 / 考前密卷</view> <view class="fs15" style="color: #7E4012FF;">精选500题 / 模考 / 考前密卷</view>
<view class="study fs16 text-center" style="margin: 25px auto 0;color: #F6E99FFF;">{{ isIOS ? 'iOS暂不可用' : '立即开通' }}</view> <view class="study fs16 text-center" style="margin: 25px auto 0;color: #F6E99FFF;">{{ isIOS ? 'iOS暂不可用' : '立即开通' }}</view>
</view> </view>
<view v-else-if="vipOn.length" class="text-center"> <view v-else-if="vipOn.length" class="text-center">

View File

@@ -9,7 +9,7 @@
</view> </view>
<swiper class="swiper mt20" :current="swiperIndex" :duration="duration" :autoplay="false" @change="onChange" <swiper class="swiper mt20" :current="swiperIndex" :duration="duration" :autoplay="false" @change="onChange"
@animationfinish="onAnimationfinish" @touchend="touchEnd"> @animationfinish="onAnimationfinish" @touchend="touchEnd">
<swiper-item v-for="(quesItem,quesIndex) in swiperList" :key="quesIndex.questionId"> <swiper-item v-for="(quesItem,quesIndex) in swiperList" :key="quesItem.questionId">
<scroll-view scroll-y="true" class="swiper-scroll"> <scroll-view scroll-y="true" class="swiper-scroll">
<view> <view>
<view class="m14lr"> <view class="m14lr">