| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316 | <template>	<view class="ezy-cuoti-page">		<view class="icon-title-navBar-box">			<view @click="handleBack" class="nav-bar-icon"></view>			<text class="nav-bar-title">我的错题</text>		</view>		<view class="cuoti-border-box">			<uni-segmented-control :current="data.current" :values="data.items" active-color="#3A7FE9"				@clickItem="onChangeTab" class="cuo-tab-box" />			<view class="cuoti-content-box">				<view v-if="data.current === 0">					<scroll-view scroll-y="true" refresher-enabled="true"						:refresher-triggered="data.shuxue.loading" :refresher-threshold="50"						refresher-background="transparent" @refresherrefresh="onRefresh" class="cuoti-scroll-view">						<!--数学-->						<uni-list>							<uni-list-item v-for="item in data.shuxue.list" class="list-item-box">								<template v-slot:body>									<!-- 时间 -->									<view class="item-date-row">										<icon class="data-icon"></icon>										<text>{{ item.cdate }}</text>									</view>									<!-- 数量 -->									<view class="item-cuoti-row">											<icon class="cuoti-icon"></icon>											<view class="cuoti-content">错题数:<text class="cuoti-text">{{ item.count }}</text>题</view>									</view>									<view @click="getCuotiData(item)" class="cuoti-btn">查看错题</view>								</template>							</uni-list-item>							<uni-load-more :status="data.shuxue.state" @click="getMore(0)"								:contentText="data.shuxue.contentText"></uni-load-more>						</uni-list>					</scroll-view>				</view>				<view v-if="data.current === 1">					<scroll-view scroll-y="true" refresher-enabled="true"						:refresher-triggered="data.yingyu.loading" :refresher-threshold="50"						refresher-background="transparent" @refresherrefresh="onRefresh" class="cuoti-scroll-view">						<!--英语-->						<uni-list>							<uni-list-item v-for="item in data.yingyu.list">                <template v-slot:body>                  <!-- 时间 -->                  <view class="item-date-row">                    <icon class="data-icon"></icon>                    <text>{{ item.cdate }}</text>                  </view>                  <!-- 数量 -->                  <view class="item-cuoti-row">                    <icon class="cuoti-icon"></icon>                    <view class="cuoti-content">错题数:<text class="cuoti-text">{{ item.count }}</text>题</view>                  </view>                  <view @click="getCuotiData(item)" class="cuoti-btn">查看错题</view>                </template>              </uni-list-item>							<uni-load-more :status="data.yingyu.state" @click="getMore(1)"								:contentText="data.yingyu.contentText"></uni-load-more>						</uni-list>					</scroll-view>				</view>			</view>		</view>		<cuoti ref="wrongRef" :list="data.wrongList" @back="handleBackFromCuoti"></cuoti>		<CustomTabBar :cardId="cardId" :nianji="nianji" :zhangId="zhangId"></CustomTabBar>	</view></template><script setup>	import {		reactive,		ref	} from "vue";	import {		getWrongData	} from "@/api/wrong";	import {		onLoad	} from "@dcloudio/uni-app";	import cuoti from "@/components/chengji/chengji.vue";	import {		getWrongInfo	} from "@/api/wrong";	import CustomTabBar from '@/components/custom-tabbar/custom-tabbar.vue';		const zhangId = ref(null);	const nianji = ref(null);	const cardId = ref(null);		const wrongRef = ref(null);	const data = reactive({		items: ['数学', '英语'],		current: 0,		shuxue: {			page: 0,			list: [],			loading: false,			state: 'more',      contentText: {        contentdown: '查看更多',        contentrefresh: '加载中',        contentnomore: '没有更多'      }		},		yingyu: {			page: 0,			list: [],			loading: false,			state: 'more',      contentText: {        contentdown: '查看更多',        contentrefresh: '加载中',        contentnomore: '没有更多'      }		},		wrongList: [],	})	function handleBack() {		uni.redirectTo({			url: '/pages/my/index'		})	}	function handleBackFromCuoti() {		wrongRef.value.closePopup();	}	function onChangeTab(e) {		if (data.current !== e.currentIndex) {			data.current = e.currentIndex;			if (data.current == 0) {				data.shuxue.page = 0			} else if (data.current == 1) {				data.yingyu.page = 0			}			refreshData(data.current);		}	}	function refreshData(code) {		const opt = {			page: 1,			size: 10, // 固定查询10条			cardId: data.current + 1 // 前台索引加1为学科cardId		}		if (code == 0) {			data.shuxue.list = [];			// 数学			data.shuxue.state = 'loading';			data.shuxue.page++;			opt.page = data.shuxue.page;		} else if (code == 1) {			data.yingyu.list = [];			// 英语			data.yingyu.state = 'loading';			data.yingyu.page++;			opt.page = data.yingyu.page;		}		getWrongData(opt).then(res => {			if (code == 0) {				data.shuxue.list = data.shuxue.list.concat(res.data.data);				data.shuxue.loading = false;			} else if (code == 1) {				data.yingyu.list = data.yingyu.list.concat(res.data.data);				data.yingyu.loading = false;			}			if (code == 0) {				if (res.data.total >= data.shuxue.list.length) {					// 数学					data.shuxue.state = 'no-more';					data.shuxue.loading = false;				} else {					// 数学					data.shuxue.state = 'more';					data.shuxue.loading = false;				}			} else if (code == 1) {				if (res.data.total >= data.yingyu.list.length) {					// 英语					data.yingyu.state = 'no-more';					data.yingyu.loading = false;				} else {					// 英语					data.yingyu.state = 'more';					data.yingyu.loading = false;				}			}		}).catch(err => {			if (code == 0) {				// 数学				data.shuxue.state = 'more';				data.shuxue.loading = false;			} else if (code == 1) {				// 英语				data.yingyu.state = 'more';				data.yingyu.loading = false;			}		})	}	function getMore(code) {		const opt = {			page: 1,			size: 10, // 固定查询10条			cardId: data.current + 1 // 前台索引加1为学科cardId		}		if (code == 0) {			if (data.shuxue.state == 'no-more') return;			// 数学			data.shuxue.state = 'loading';			data.shuxue.page++;			opt.page = data.shuxue.page;		} else if (code == 1) {			// 英语			if (data.yingyu.state == 'no-more') return;			data.yingyu.state = 'loading';			data.yingyu.page++;			opt.page = data.yingyu.page;		}		getWrongData(opt).then(res => {			if (code == 0) {				data.shuxue.list = data.shuxue.list.concat(res.data.data);				data.shuxue.loading = false;			} else if (code == 1) {				data.yingyu.list = data.yingyu.list.concat(res.data.data);				data.yingyu.loading = false;			}			if (code == 0) {				if (res.data.total >= data.shuxue.list.length) {					// 数学					data.shuxue.state = 'no-more';					data.shuxue.state_text = '没有更多啦';					data.shuxue.loading = false;				} else {					// 数学					data.shuxue.state = 'more';					data.shuxue.state_text = '加载更多';					data.shuxue.loading = false;				}			} else if (code == 1) {				if (res.data.total >= data.yingyu.list.length) {					// 英语					data.yingyu.state = 'no-more';					data.yingyu.state_text = '没有更多啦';					data.yingyu.loading = false;				} else {					// 英语					data.yingyu.state = 'more';					data.yingyu.state_text = '加载更多';					data.yingyu.loading = false;				}			}		}).catch(err => {			if (code == 0) {				// 数学				data.shuxue.state = 'more';				data.shuxue.state_text = '加载更多';				data.shuxue.loading = false;			} else if (code == 1) {				// 英语				data.yingyu.state = 'more';				data.yingyu.state_text = '加载更多';				data.yingyu.loading = false;			}		})	}	function formatListToUse(list) {		list.forEach((item, index) => {			item.mta_show = false;			if (item.type == 3) {				item.result = JSON.parse(item.result);				item.placeholders = item.result.map((item, cindex) => `[bank${cindex+1}]`)				item.reply = item.reply ? JSON.parse(item.reply) : item.result.map(() => '');			}		})	}	function getCuotiData(item) {		getWrongInfo({			cardId: data.current + 1,			cdate: item.cdate		}).then(res => {			formatListToUse(res.data)			data.wrongList = res.data;			wrongRef.value.showPopup();		})	}	function onRefresh() {		if (data.current == 0) {			data.shuxue.page = 0;			data.shuxue.list = [];			data.shuxue.loading = true;		} else if (data.current == 1) {			data.yingyu.page = 0;			data.yingyu.list = [];			data.yingyu.loading = true;		}		refreshData(data.current);	}	onLoad(() => {		getMore(data.current);	})</script><style></style>
 |