优化代码

This commit is contained in:
王创世 2025-08-08 18:28:22 +08:00
parent af094e55b0
commit de61f9db80
7 changed files with 189 additions and 176 deletions

View File

@ -117,7 +117,10 @@ module.exports = {
}
return arr
},
//过滤html
filterHtml(html) {
return html.replace(/<[^>]+>/g, "")
},
// 秒数转时分秒格式
sec_to_time(s) {
var t;

View File

@ -54,6 +54,18 @@
</view>
</view>
</view>
<view class="tn-padding-sm tn-margin-xs" @click="goPage('/pages/wrong/index')">
<view class="tn-flex tn-flex-direction-column tn-flex-row-center tn-flex-col-center">
<view
class="icon15__item--image tn-flex tn-flex-row-center tn-flex-col-center tn-shadow-blur tn-color-white">
<image src="/static/img/3.png" style="width: 100%;height: 100%"></image>
</view>
<view class="tn-text-center">
<text class="tn-text-ellipsis" style="font-size: 28rpx">错题本</text>
</view>
</view>
</view>
<view class="tn-padding-sm tn-margin-xs" @click="goPage('/pages/index/news-detail?id=1')">
<view class="tn-flex tn-flex-direction-column tn-flex-row-center tn-flex-col-center">
<view
@ -90,18 +102,7 @@
</view>
</view>
</view> -->
<view class="tn-padding-sm tn-margin-xs" @click="goPage('/pages/wrong/index')">
<view class="tn-flex tn-flex-direction-column tn-flex-row-center tn-flex-col-center">
<view
class="icon15__item--image tn-flex tn-flex-row-center tn-flex-col-center tn-shadow-blur tn-color-white">
<image src="/static/img/3.png" style="width: 100%;height: 100%"></image>
</view>
<view class="tn-text-center">
<text class="tn-text-ellipsis" style="font-size: 28rpx">错题本</text>
</view>
</view>
</view>
</view>
</view>
@ -124,9 +125,7 @@
<image class="question-bank-image" :src="imgUrl + item.image"
mode="aspectFill"></image>
</view>
<view class="question-bank-title">
{{ item.text }}
</view>
<view v-html="item.text" class="question-bank-title"></view>
</view>
</view>
</block>
@ -1146,9 +1145,9 @@ export default {
.question-bank-title {
padding: 15rpx;
font-size: 32rpx;
font-size: 28rpx;
color: #333333;
display: flex;
text-align: center;
}
/* 题库卡片样式 end */

View File

@ -117,7 +117,6 @@ export default {
newsApi.getNewsDetail(this, {
id: id
}).then(res => {
s
if (res && res.data) {
this.newsData = res.data
}

View File

@ -1,4 +1,5 @@
<template>
<view>
<view style="padding: 30rpx; background-color: #FAFAFA; min-height: 100vh;">
<view style="display: flex;align-items: center;">
<view @click="show = true"
@ -9,7 +10,8 @@
style="font-size: 24rpx; color: #1A73E8; position: relative;"></text>
</view>
</view>
<view style="display: inline-block; position: relative;padding-left: 30rpx;font-size: 32rpx;font-weight: bold;">
<view
style="display: inline-block; position: relative;padding-left: 30rpx;font-size: 32rpx;font-weight: bold;">
<text>{{ info.text }}</text>
</view>
</view>
@ -30,23 +32,29 @@
</view>
<!-- 1会员 2不是会员 -->
<view v-if="item.type == 2"
style="background: #1A73E8; color: #fff; border-radius: 24rpx; padding: 4rpx 28rpx; font-size: 26rpx; font-weight: 500; letter-spacing: 2rpx;">
style="width: 110rpx;background: #1A73E8; color: #fff; border-radius: 24rpx; padding: 4rpx 28rpx; font-size: 26rpx; font-weight: 500; letter-spacing: 2rpx;">
免费</view>
<view v-else
style="background: #f39c12; color: #fff; border-radius: 24rpx; padding: 4rpx 28rpx; font-size: 26rpx; font-weight: 500; letter-spacing: 2rpx;">
style="width: 110rpx;background: #f39c12; color: #fff; border-radius: 24rpx; padding: 4rpx 28rpx; font-size: 26rpx; font-weight: 500; letter-spacing: 2rpx;">
会员</view>
</view>
</view>
</view>
<tn-popup v-model="show" mode="left" width="550rpx"
:style="'border-radius:32rpx 0 0 32rpx; box-shadow: 0 8rpx 32rpx rgba(26,115,232,0.12); overflow: hidden;'">
<view style="padding: 30rpx;">
<view v-for="item in cateList" @click="getTree(item)"
style="margin-bottom: 40rpx;padding:25rpx 20rpx;text-align: center;background-color: #F3F5F7;border-radius: 60rpx; font-size: 28rpx; color: #1A73E8;">
{{ item.text }}</view>
{{ item.text }}
</view>
</view>
</tn-popup>
</view>
<view @click="openCtj()"
style="position: fixed;left:0;right: 0;bottom: 5%;;background-color: #1A73E8;text-align: center;width: 90%;margin: 0 auto;height: 90rpx;line-height: 90rpx;color: #FFFFFF">
本章错题集</view>
</view>
</template>
<script>
@ -68,6 +76,13 @@ export default {
this.getIsUser();
},
methods: {
openCtj(){
const values = this.info.children?.map(item => item.value).join(',') || '';
console.log(values);
uni.navigateTo({
url:"/pages/wrong/index?cate_ids="+values
})
},
getTree(item) {
this.info = item;
this.show = false;
@ -83,6 +98,10 @@ export default {
this.http('cate/getThree', {
kind: 'QUESTION',
}).then(res => {
//text
res.data.forEach(item => {
item.text = item.text.replace(/<[^>]+>/g, "")
})
this.cateList = res.data;
this.info = res.data.find(item => item.value == this.id);
})

View File

@ -29,19 +29,16 @@
@click="checkPay">{{btnText}}</tui-button>
</view> -->
<view class="tn-margin-top-sm">
<view class="tn-margin-top-sm" style="padding-bottom: 230rpx;">
<view class="tn-flex tn-flex-wrap tn-margin-sm">
<block v-for="(item, index) in cateList" :key="index">
<view style="width: 50%">
<view class="question-bank-card tn-margin-xs"
@click="checkPay(item.value)">
<view class="question-bank-card tn-margin-xs" @click="checkPay(item.value)">
<view class="question-bank-image-wrapper">
<image class="question-bank-image" :src="imgUrl + item.image" mode="aspectFill">
</image>
</view>
<view class="question-bank-title">
{{ item.text }}
</view>
<view v-html="item.text" class="question-bank-title"></view>
</view>
</view>
</block>
@ -306,6 +303,7 @@ page {
color: #333 !important;
font-size: 15px !important;
}
/* 题库卡片样式 start */
.question-bank-card {
background-color: #ffffff;
@ -331,9 +329,10 @@ page {
.question-bank-title {
padding: 15rpx;
font-size: 32rpx;
font-size: 28rpx;
color: #333333;
display: flex;
text-align: center;
}
/* 题库卡片样式 end */
</style>

View File

@ -20,15 +20,17 @@
over: 0,
questionIds: [],
showNodata: false,
cate_ids:'',
}
},
onLoad(e) {
this.cate_ids=e.cate_ids;
this.questionIds = e.question_ids
this.ajax()
},
methods: {
ajax() {
this.http('question/wrongList', {page:this.page, question_ids: this.questionIds}, 'post').then(res => {
this.http('question/wrongList', {page:this.page, question_ids: this.questionIds,cate_ids:this.cate_ids}, 'post').then(res => {
if (res.code == 0) {
this.utils.toast(res.msg)
setTimeout(() => {

View File

@ -36,7 +36,7 @@
<!-- 联系电话 -->
<tn-form-item label="手机号码" prop="phone" class="form-item-vertical" required>
<tn-input v-model="form.phone" type="number" placeholder="请输入手机号码" :border="false"
:placeholderStyle="placeholderStyle" maxlength="11" @blur="validatePhone" />
:placeholderStyle="placeholderStyle" maxlength="11"/>
</tn-form-item>
<!-- 上传蓝底电子版照片 -->
@ -671,18 +671,10 @@ export default {
leijishijian: '', //
pxjd: '' //
}
//
this.agreementChecked = []
//
this.datePickerShow = false
uni.showToast({
title: '表单已重置',
icon: 'success',
duration: 1500
})
}
}
}