优化代码

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 return arr
}, },
//过滤html
filterHtml(html) {
return html.replace(/<[^>]+>/g, "")
},
// 秒数转时分秒格式 // 秒数转时分秒格式
sec_to_time(s) { sec_to_time(s) {
var t; var t;

View File

@ -54,6 +54,18 @@
</view> </view>
</view> </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-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 class="tn-flex tn-flex-direction-column tn-flex-row-center tn-flex-col-center">
<view <view
@ -90,18 +102,7 @@
</view> </view>
</view> </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>
</view> </view>
@ -124,9 +125,7 @@
<image class="question-bank-image" :src="imgUrl + item.image" <image class="question-bank-image" :src="imgUrl + item.image"
mode="aspectFill"></image> mode="aspectFill"></image>
</view> </view>
<view class="question-bank-title"> <view v-html="item.text" class="question-bank-title"></view>
{{ item.text }}
</view>
</view> </view>
</view> </view>
</block> </block>
@ -1146,9 +1145,9 @@ export default {
.question-bank-title { .question-bank-title {
padding: 15rpx; padding: 15rpx;
font-size: 32rpx; font-size: 28rpx;
color: #333333; color: #333333;
display: flex; text-align: center;
} }
/* 题库卡片样式 end */ /* 题库卡片样式 end */

View File

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

View File

@ -1,136 +1,155 @@
<template> <template>
<view style="padding: 30rpx; background-color: #FAFAFA; min-height: 100vh;"> <view>
<view style="display: flex;align-items: center;"> <view style="padding: 30rpx; background-color: #FAFAFA; min-height: 100vh;">
<view @click="show = true" <view style="display: flex;align-items: center;">
style="display: flex;align-items: center; border: 2rpx solid #1A73E8; border-radius: 32rpx; padding: 8rpx 24rpx; color: #1A73E8; background: #fff; font-weight: 500; box-shadow: 0 2rpx 8rpx rgba(26,115,232,0.08); cursor: pointer; transition: background 0.2s;"> <view @click="show = true"
<view style="margin-right: 8rpx;">更多题库</view> style="display: flex;align-items: center; border: 2rpx solid #1A73E8; border-radius: 32rpx; padding: 8rpx 24rpx; color: #1A73E8; background: #fff; font-weight: 500; box-shadow: 0 2rpx 8rpx rgba(26,115,232,0.08); cursor: pointer; transition: background 0.2s;">
<view> <view style="margin-right: 8rpx;">更多题库</view>
<text class="tn-icon-down-triangle" <view>
style="font-size: 24rpx; color: #1A73E8; position: relative;"></text> <text class="tn-icon-down-triangle"
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;">
<text>{{ info.text }}</text>
</view> </view>
</view> </view>
<view style="display: inline-block; position: relative;padding-left: 30rpx;font-size: 32rpx;font-weight: bold;"> <view style="padding: 20rpx 0px;margin-top: 30rpx;">
<text>{{ info.text }}</text> <view v-for="item in info.children" style="margin-bottom: 40rpx;">
</view> <view @click="goTrain(item.value, item.text, item.type)"
</view> style="display: flex;justify-content: space-between;align-items: center; background: #fff; border-radius: 16rpx; box-shadow: 0 4rpx 16rpx rgba(26,115,232,0.06); padding: 30rpx;">
<view style="padding: 20rpx 0px;margin-top: 30rpx;"> <view style="display: flex;align-items: center;">
<view v-for="item in info.children" style="margin-bottom: 40rpx;"> <view
<view @click="goTrain(item.value, item.text, item.type)" style="height: 40rpx;width: 40rpx;background-color: #1A73E8;border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 24rpx; font-weight: bold;">
style="display: flex;justify-content: space-between;align-items: center; background: #fff; border-radius: 16rpx; box-shadow: 0 4rpx 16rpx rgba(26,115,232,0.06); padding: 30rpx;">
<view style="display: flex;align-items: center;"> </view>
<view <view style="padding-left: 32rpx;">
style="height: 40rpx;width: 40rpx;background-color: #1A73E8;border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 24rpx; font-weight: bold;"> <view style="font-size: 32rpx; font-weight: bold; color: #222;">{{ item.text }}</view>
<view style="color: #999999;font-size: 24rpx;padding-top: 8rpx;">题目数量{{ item.count }}
</view> </view>
<view style="padding-left: 32rpx;">
<view style="font-size: 32rpx; font-weight: bold; color: #222;">{{ item.text }}</view>
<view style="color: #999999;font-size: 24rpx;padding-top: 8rpx;">题目数量{{ item.count }}
</view> </view>
</view> </view>
<!-- 1会员 2不是会员 -->
<view v-if="item.type == 2"
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="width: 110rpx;background: #f39c12; color: #fff; border-radius: 24rpx; padding: 4rpx 28rpx; font-size: 26rpx; font-weight: 500; letter-spacing: 2rpx;">
会员</view>
</view> </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;">
免费</view>
<view v-else
style="background: #f39c12; color: #fff; border-radius: 24rpx; padding: 4rpx 28rpx; font-size: 26rpx; font-weight: 500; letter-spacing: 2rpx;">
会员</view>
</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>
</view>
</tn-popup>
</view> </view>
<tn-popup v-model="show" mode="left" width="550rpx" <view @click="openCtj()"
:style="'border-radius:32rpx 0 0 32rpx; box-shadow: 0 8rpx 32rpx rgba(26,115,232,0.12); overflow: hidden;'"> 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 style="padding: 30rpx;"> 本章错题集</view>
<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>
</view>
</tn-popup>
</view> </view>
</template> </template>
<script> <script>
import newsApi from "@/common/api/news.js" import newsApi from "@/common/api/news.js"
export default { export default {
data() { data() {
return { return {
show: false, show: false,
id: 0, id: 0,
cateList: [], cateList: [],
info: {}, info: {},
vip: 0, vip: 0,
} }
}, },
onLoad(op) { onLoad(op) {
console.log(op); console.log(op);
this.id = op.id; this.id = op.id;
this.getCate(); this.getCate();
this.getIsUser(); this.getIsUser();
}, },
methods: { methods: {
getTree(item) { openCtj(){
this.info = item; const values = this.info.children?.map(item => item.value).join(',') || '';
this.show = false; console.log(values);
}, uni.navigateTo({
getIsUser() { url:"/pages/wrong/index?cate_ids="+values
newsApi.ifUserMember(this, {}).then(res => { })
//0 },
console.log(res); getTree(item) {
this.vip = res.code; this.info = item;
}) this.show = false;
}, },
getCate() { getIsUser() {
this.http('cate/getThree', { newsApi.ifUserMember(this, {}).then(res => {
kind: 'QUESTION', //0
}).then(res => { console.log(res);
this.cateList = res.data; this.vip = res.code;
this.info = res.data.find(item => item.value == this.id); })
}) },
}, getCate() {
goTrain(id, name, type) { this.http('cate/getThree', {
if (type == 1 && this.vip == 0) { kind: 'QUESTION',
uni.showModal({ }).then(res => {
title: '提示', //text
content: '该题库仅限会员可用,请联系客服开通会员!', res.data.forEach(item => {
confirmText: '联系客服', item.text = item.text.replace(/<[^>]+>/g, "")
success: (res) => { })
if (res.confirm) { this.cateList = res.data;
uni.makePhoneCall({ this.info = res.data.find(item => item.value == this.id);
phoneNumber: '18903795988' // })
}); },
} goTrain(id, name, type) {
} if (type == 1 && this.vip == 0) {
}); uni.showModal({
return; title: '提示',
content: '该题库仅限会员可用,请联系客服开通会员!',
confirmText: '联系客服',
success: (res) => {
if (res.confirm) {
uni.makePhoneCall({
phoneNumber: '18903795988' //
});
}
}
});
return;
}
this.utils.goto('train?cateId=' + id + '&cateName=' + name + '&mode=normal')
} }
this.utils.goto('train?cateId=' + id + '&cateName=' + name + '&mode=normal')
} }
} }
}
</script> </script>
<style> <style>
page { page {
background-color: #FAFAFA; background-color: #FAFAFA;
} }
/* 统一字体和颜色 */ /* 统一字体和颜色 */
body, body,
view, view,
text { text {
font-family: 'PingFang SC', 'Microsoft YaHei', Arial, sans-serif; font-family: 'PingFang SC', 'Microsoft YaHei', Arial, sans-serif;
color: #222; color: #222;
} }
/* 主题色变量可用于后续扩展 */ /* 主题色变量可用于后续扩展 */
:root { :root {
--theme-color: #1A73E8; --theme-color: #1A73E8;
} }
/* 适当增加全局间距 */ /* 适当增加全局间距 */
view { view {
box-sizing: border-box; box-sizing: border-box;
} }
/* 注释:如需进一步美化可在此扩展 */ /* 注释:如需进一步美化可在此扩展 */
</style> </style>

View File

@ -29,19 +29,16 @@
@click="checkPay">{{btnText}}</tui-button> @click="checkPay">{{btnText}}</tui-button>
</view> --> </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"> <view class="tn-flex tn-flex-wrap tn-margin-sm">
<block v-for="(item, index) in cateList" :key="index"> <block v-for="(item, index) in cateList" :key="index">
<view style="width: 50%"> <view style="width: 50%">
<view class="question-bank-card tn-margin-xs" <view class="question-bank-card tn-margin-xs" @click="checkPay(item.value)">
@click="checkPay(item.value)">
<view class="question-bank-image-wrapper"> <view class="question-bank-image-wrapper">
<image class="question-bank-image" :src="imgUrl + item.image" mode="aspectFill"> <image class="question-bank-image" :src="imgUrl + item.image" mode="aspectFill">
</image> </image>
</view> </view>
<view class="question-bank-title"> <view v-html="item.text" class="question-bank-title"></view>
{{ item.text }}
</view>
</view> </view>
</view> </view>
</block> </block>
@ -221,7 +218,7 @@ export default {
if (res.code == 1) { if (res.code == 1) {
this.questionCount = res.data.total this.questionCount = res.data.total
if (this.questionCount) { if (this.questionCount) {
this.btnText = '开始练习' this.btnText = '开始练习'
} else { } else {
this.btnText = '当前分类无试题' this.btnText = '当前分类无试题'
} }
@ -267,7 +264,7 @@ export default {
if (res.data.status == 1) { if (res.data.status == 1) {
this.utils.goto('/pages/train/detail?id=' + cateId); this.utils.goto('/pages/train/detail?id=' + cateId);
return return
} }
// //
// if (res.data.status == 1) { // if (res.data.status == 1) {
// this.goTrain() // this.goTrain()
@ -299,41 +296,43 @@ export default {
<style> <style>
page { page {
background-color: #fff; background-color: #fff;
} }
.tn-radio__label { .tn-radio__label {
color: #333 !important; color: #333 !important;
font-size: 15px !important; font-size: 15px !important;
} }
/* 题库卡片样式 start */ /* 题库卡片样式 start */
.question-bank-card { .question-bank-card {
background-color: #ffffff; background-color: #ffffff;
border-radius: 15rpx; border-radius: 15rpx;
} }
.question-bank-card:active { .question-bank-card:active {
transform: scale(0.98); transform: scale(0.98);
} }
.question-bank-image-wrapper { .question-bank-image-wrapper {
width: 100%; width: 100%;
height: 200rpx; height: 200rpx;
overflow: hidden; overflow: hidden;
border-radius: 15rpx; border-radius: 15rpx;
} }
.question-bank-image { .question-bank-image {
width: 100%; width: 100%;
height: 100%; height: 100%;
object-fit: cover; object-fit: cover;
} }
.question-bank-title { .question-bank-title {
padding: 15rpx; padding: 15rpx;
font-size: 32rpx; font-size: 28rpx;
color: #333333; color: #333333;
display: flex; text-align: center;
} }
/* 题库卡片样式 end */
/* 题库卡片样式 end */
</style> </style>

View File

@ -20,15 +20,17 @@
over: 0, over: 0,
questionIds: [], questionIds: [],
showNodata: false, showNodata: false,
cate_ids:'',
} }
}, },
onLoad(e) { onLoad(e) {
this.cate_ids=e.cate_ids;
this.questionIds = e.question_ids this.questionIds = e.question_ids
this.ajax() this.ajax()
}, },
methods: { methods: {
ajax() { 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) { if (res.code == 0) {
this.utils.toast(res.msg) this.utils.toast(res.msg)
setTimeout(() => { setTimeout(() => {

View File

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