优化代码

This commit is contained in:
王创世 2025-08-06 09:22:24 +08:00
parent 72633579e0
commit ed01d833b9
9 changed files with 1352 additions and 1240 deletions

View File

@ -18,7 +18,8 @@
</view> -->
<view>
<tn-swiper :list="banners" :radius="0" :height="400" :effect3d="false" mode="dot" @click="clickSwiper"></tn-swiper>
<tn-swiper :list="banners" :radius="0" :height="400" :effect3d="false" mode="dot"
@click="clickSwiper"></tn-swiper>
</view>
<!-- 公告 -->
@ -40,26 +41,66 @@
<!-- 功能列表 start -->
<view class="about-shadow tn-padding-top-sm tn-padding-bottom-sm">
<view style="display: flex;justify-content: center;align-items: center;gap: 12px;">
<block v-for="(item, index) in moduleList" :key="index">
<view class="tn-padding-sm tn-margin-xs" @click="goPage(item.path)">
<view v-if="classes_show == 1" class="tn-padding-sm tn-margin-xs" @click="goPage('/pagesSubject/video/index')">
<view class="tn-flex tn-flex-direction-column tn-flex-row-center tn-flex-col-center">
<view v-if="item.type == 'icon'"
class="icon15__item--icon tn-flex tn-flex-row-center tn-flex-col-center tn-shadow-blur tn-color-white"
:class="[item.color]">
<view :class="[item.icon]"></view>
</view>
<view v-else-if="item.type == 'image'"
<view
class="icon15__item--image tn-flex tn-flex-row-center tn-flex-col-center tn-shadow-blur tn-color-white">
<image :src="item.image" style="width: 100%;height: 100%"></image>
<image src="/static/img/1.png" style="width: 100%;height: 100%"></image>
</view>
<view class="tn-text-center">
<text class="tn-text-ellipsis" style="font-size: 28rpx">{{ item.name }}</text>
<text class="tn-text-ellipsis" style="font-size: 28rpx">课程中心</text>
</view>
</view>
</view>
<view v-if="classes_show == 1" class="tn-padding-sm tn-margin-xs" @click="goPage('/pages/index/news-list')">
<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/1.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/train/index?page=train')">
<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/2.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/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/collect/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/4.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>
</block>
</view>
</view>
<!-- 功能列表 end -->
@ -269,6 +310,10 @@ export default {
type: String,
default: "",
},
classes_show: {
type: String,
default: "",
}
},
watch: {
/**
@ -313,6 +358,7 @@ export default {
// },
},
mounted() {
console.log(this.modules);
let diyIndexButton = uni.getStorageSync("diyIndexButton");
if (diyIndexButton) {
this.moduleList = diyIndexButton;
@ -837,7 +883,7 @@ export default {
}
.nav-name {
font-size: 28upx;
font-size: 30rpx;
text-transform: Capitalize;
margin-top: 20upx;
position: relative;
@ -897,6 +943,7 @@ export default {
}
.bg-index3 {
font-size: 30rpx;
background-color: #5177ee;
color: #fff;
}

View File

@ -2000,7 +2000,7 @@
flex-wrap: wrap;
flex: 1;
height: 100%;
font-p: 32rpx;
font-size: 30rpx;
.image {
width: 50%;
@ -2463,7 +2463,7 @@
}
.text-right-answer-val {
font-size: 28rpx;
font-size: 30rpx;
color: #1A73E8;
padding: 8rpx 0rpx;
border-radius: 15rpx 15rpx 15rpx 0;

View File

@ -110,15 +110,15 @@
path: '/pages/index/index'
},
{
name: '模拟考试',
name: '平台题库',
icon: 'tn-icon-edit-form',
path: '/pages/paper/index',
},
{
name: '关于我们',
icon: 'tn-icon-inventory',
path: '/pages/index/news-list',
path: '/pages/train/index',
},
// {
// name: '',
// icon: 'tn-icon-inventory',
// path: '/pages/index/news-list',
// },
{
name: '考试公示',
icon: 'tn-icon-menu-list',

View File

@ -111,7 +111,7 @@
//tabs
size: {
type: Number,
default: 28
default: 30
},
//tabs
color: {
@ -180,7 +180,7 @@
//item text
textSize: {
type: Number,
default: 28
default: 30
},
//text
nowrap: {
@ -195,7 +195,7 @@
//item subText
subTextSize: {
type: Number,
default: 24
default: 30
},
// item padding
padding: {
@ -546,6 +546,7 @@
.tui-cell-title {
word-break: break-all;
font-size: 30rpx;
}
.tui-flex-shrink {

View File

@ -1,12 +1,8 @@
<template>
<view>
<!-- 骨架屏 -->
<kz-skeleton
v-if="showSkeleton"
:showSkeleton="showSkeleton"
backgroundColor="#fafafa"
borderRadius="10rpx"
></kz-skeleton>
<kz-skeleton v-if="showSkeleton" :showSkeleton="showSkeleton" backgroundColor="#fafafa"
borderRadius="10rpx"></kz-skeleton>
<!-- 添加小程序提示组件 -->
<!-- #ifdef MP-WEIXIN -->
@ -14,45 +10,19 @@
<!-- #endif -->
<!-- 首页多彩列表风格组件1 -->
<kz-page-index-color-1
:title="title"
:banners="banners"
:slides="slides"
:papers="papers"
:rooms="rooms"
:news="news"
:notices="notices"
:modules="diyIndexButton"
:subjectId="subjectId"
:subjectName="subjectName"
v-if="pageStyle == 'color'"
></kz-page-index-color-1>
<kz-page-index-color-1 :classes_show="classes_show" :title="title" :banners="banners" :slides="slides" :papers="papers" :rooms="rooms"
:news="news" :notices="notices" :modules="diyIndexButton" :subjectId="subjectId" :subjectName="subjectName"
v-if="pageStyle == 'color'"></kz-page-index-color-1>
<!-- 首页多彩列表风格组件2 -->
<kz-page-index-color-2
:title="title"
:banners="banners"
:slides="slides"
:papers="papers"
:rooms="rooms"
:news="news"
:notices="notices"
:modules="diyIndexButton"
:subjectId="subjectId"
:subjectName="subjectName"
v-else-if="pageStyle == 'color2'"
></kz-page-index-color-2>
<kz-page-index-color-2 :title="title" :banners="banners" :slides="slides" :papers="papers" :rooms="rooms"
:news="news" :notices="notices" :modules="diyIndexButton" :subjectId="subjectId" :subjectName="subjectName"
v-else-if="pageStyle == 'color2'"></kz-page-index-color-2>
<!-- 首页简约风格组件 -->
<kz-page-index-simple-1
:title="title"
:notices="notices"
:subjectName="subjectName"
:userInfo="userInfo"
:diyIndexButton="diyIndexButton"
v-else-if="pageStyle == 'simple'"
@clickUserInfo="clickUserInfo"
></kz-page-index-simple-1>
<kz-page-index-simple-1 :title="title" :notices="notices" :subjectName="subjectName" :userInfo="userInfo"
:diyIndexButton="diyIndexButton" v-else-if="pageStyle == 'simple'"
@clickUserInfo="clickUserInfo"></kz-page-index-simple-1>
<!-- <kz-page-index-simple :banners="banners" v-if="pageStyle == 'simple'"></kz-page-index-simple> -->
<!-- 悬浮组件 -->
@ -123,6 +93,7 @@ export default {
},
data() {
return {
classes_show:'',
loadText: {
loadmore: '灵睿网络',
loading: '灵睿网络',
@ -201,7 +172,9 @@ export default {
},
getSetting() {
this.http("common/index", { subject_id: this.subjectId }, "get").then(
this.http("common/index", {
subject_id: this.subjectId
}, "get").then(
(res) => {
if (!res.code) {
uni.showToast({
@ -210,7 +183,7 @@ export default {
});
return;
}
this.classes_show=res.data.classes_show;
//
let point = res.data.point;
// if (point?.get_point) {
@ -292,14 +265,14 @@ export default {
}
//
this.pageStyle = page.page_index_style
? page.page_index_style
: "color";
this.pageStyle = page.page_index_style ?
page.page_index_style :
"color";
// this.pageStyle = 'color'
//
this.tabbarStyle = page.page_tabbar_style
? page.page_tabbar_style
: "glass";
this.tabbarStyle = page.page_tabbar_style ?
page.page_tabbar_style :
"glass";
//
this.showAdBtn = parseInt(page.page_index_ad_btn) == 1;
this.showShareBtn = parseInt(page.page_index_share_btn) == 1;
@ -352,7 +325,9 @@ export default {
let user_subject = uni.getStorageSync("user_subject");
if (user_subject && user_subject.subject2 && user_subject.subject2.id) {
subjectApi
.getSubjectDetail(this, { subject_id: user_subject.subject2.id })
.getSubjectDetail(this, {
subject_id: user_subject.subject2.id
})
.then((res) => {
console.log("res", res);
if (res && res.code == 1) {

View File

@ -2,19 +2,30 @@
<template>
<view class="container">
<view>
<view style="background-color: #FFFFFF;padding: 30rpx 30rpx 30rpx 30rpx;">
<view class="titleBox text-xl text-black text-bold">{{ newsData.name }}</view>
<view class="flex justify-between text-df text-gray margin-top-sm margin-bottom-sm">
<text>{{ newsData.create_time_text }}</text>
<!-- <text>{{newsData.type | typeF}}</text> -->
</view>
<!-- <image mode="widthFix" :src="newsData.cover_image" @click="previewImage(0)"></image> -->
<!-- 中间文章区域 -->
<view class="contentBox text-lg text-black margin-top-sm margin-tb-lg">
<view style="background-color: #FFFFFF;padding: 30rpx 30rpx 80rpx 30rpx;">
<view class="contentBox text-lg text-black">
<mp-html :tag-style="tagStyle" :scroll-table="true" :content="newsData.contents" />
</view>
<!-- 地图区域 -->
<view class="mapSection margin-top-lg">
<view class="mapTitle text-xl text-black text-bold margin-bottom-sm">
<text class="cuIcon-locationfill text-blue margin-right-xs"></text>
我们的位置
</view>
<view class="mapContainer">
<map
:latitude="mapData.latitude"
:longitude="mapData.longitude"
:markers="mapData.markers"
:scale="mapData.scale"
:show-location="true"
@markertap="handleMarkerTap"
@callouttap="handleCalloutTap"
class="map"
></map>
</view>
</view>
</view>
<!-- <view class="cu-bar justify-left bg-white margin-top-sm">
@ -68,6 +79,29 @@
table: 'border: 1px solid gray;border-collapse:collapse',
th: 'border: 1px solid gray;',
td: 'border: 1px solid gray;'
},
//
mapData: {
latitude: 34.621881, //
longitude: 112.436631, //
scale: 17, //
markers: [{
id: 1,
latitude: 34.621881,
longitude: 112.436631,
title: '名扬体育学院',
width:15,
height:20,
callout: {
content: '名扬体育学院',
color: '#000000',
fontSize: 14,
borderRadius: 8,
bgColor: '#ffffff',
padding: 8,
display: 'ALWAYS'
}
}]
}
}
},
@ -88,6 +122,36 @@
}
})
},
//
openNavigation() {
uni.openLocation({
latitude: this.mapData.latitude,
longitude: this.mapData.longitude,
name: '名扬体育学院',
address: '名扬体育学院',
scale: 18,
success: () => {
console.log('成功打开地图导航');
},
fail: (err) => {
console.error('打开地图导航失败', err);
uni.showToast({
title: '打开地图失败',
icon: 'none'
});
}
});
},
//
handleMarkerTap(e) {
console.log('标记点被点击', e);
this.openNavigation();
},
// callout
handleCalloutTap(e) {
console.log('callout被点击', e);
this.openNavigation();
},
handleBack() {
this.utils.goto('news-list')
},
@ -121,8 +185,6 @@
.container {
background-color: #f2f2f2;
width: 750rpx;
}
.solid {
@ -140,4 +202,30 @@
left: 0;
bottom: 0rpx;
}
/* 地图相关样式 */
.mapSection {
background-color: #FFFFFF;
margin-top: 20rpx;
border-radius: 16rpx;
}
.mapTitle {
display: flex;
align-items: center;
margin-bottom: 20rpx;
}
.mapContainer {
width: 100%;
height: 400rpx;
border-radius: 12rpx;
overflow: hidden;
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1);
}
.map {
width: 100%;
height: 100%;
}
</style>

View File

@ -42,7 +42,7 @@
<view class="tn-tabbar-height"></view>
<!-- 底部导航栏组件 -->
<tabbar :theme="tabbarStyle"></tabbar>
<!-- <tabbar :theme="tabbarStyle"></tabbar> -->
</view>
</template>

View File

@ -37,6 +37,7 @@
:confirmCateContent="confirmCateContent" v-on:paySuccess="goTrain()" v-on:codeSuccess="goTrain()"
v-on:cancel="closeDialog">
</kz-cate-pay>
<tabbar :theme="tabbarStyle"></tabbar>
</view>
</template>

View File

@ -33,7 +33,7 @@ const store = new Vuex.Store({
state: {
// 如果上面从本地获取的lifeData对象下有对应的属性就赋值给state中对应的变量
// 加上vuex_前缀是防止变量名冲突也让人一目了然
vuex_user: lifeData.vuex_user ? lifeData.vuex_user : {name: '图鸟'},
vuex_user: lifeData.vuex_user ? lifeData.vuex_user : {name: '灵睿'},
// 如果vuex_version无需保存到本地永久存储无需lifeData.vuex_version方式
// app版本