首页优化

This commit is contained in:
张文涛 2024-10-25 17:20:58 +08:00
parent a4311e3f9e
commit 0cdad3e244
13 changed files with 362 additions and 170 deletions

View File

@ -4,7 +4,8 @@
{ //
"path": "pages/home/home",
"style": {
"navigationStyle": "custom" //
"navigationStyle": "custom", //
"navigationBarTextStyle": "white"
}
},
// #endif

View File

@ -1,62 +1,26 @@
<template>
<!-- 新鲜事页 -->
<view class="news">
<!-- 导航栏 -->
<!-- <u-navbar placeholder>
<view slot="left"></view>
<view slot="center" class="nav-center">
<view :class="{'active':tabIndex === index}" @click="changeTab(index)" v-for="(item,index) in tabList"
:key="index">
<view class="nav-title">{{item.name}}</view>
<view class="active-line"></view>
<view>
<u-sticky>
<u-swiper :list="topicList.swiper" keyName="image" circular height="470rpx" bgColor="#ffffff"></u-swiper>
<view class="search-input">
<u-search searchIconColor='#e6e6e6' placeholderColor='#e6e6e6' color='#FFFFFF' placeholder="搜索招聘/课程/技能"
v-model="keyword" :showAction="false"></u-search>
</view>
<view class="tabs-list">
<view class="left">
<view class="item" @click="btntabs(index)" v-for="(item,index) in tabsList" :key="index">
<image class="images" :src="currect==index?item.imgSelect:item.img" mode=""></image>
<text :style="{color:currect==index?'#006EEF':'#707070'}" class="text1">{{item.title}}</text>
</view>
</view>
<view class="right">
<image class="images1" src="../../static/img/demo/gengduo.png" mode=""></image>
</view>
</view>
</u-navbar> -->
<!-- #ifdef MP-WEIXIN -->
<u-navbar placeholder>
<view slot="left" @click="btn" class="iconfont iconqiandao" style="visibility: hidden;"></view>
<view slot="center" class="nav-center">
<u-search placeholder="搜索新鲜事" @click="goSearch()" :showAction="false" disabled></u-search>
</view>
<!-- <view slot="right" class="iconfont iconPensyumaobi" @click="handlePublish()"></view> -->
</u-navbar>
<!-- #endif -->
<!-- 信息列表 -->
<swiper class="bg-white px-20 py-20" :style="{height:swiperHeight + 'px'}" :current="tabIndex"
@change="changeSwiper">
<!-- <swiper-item>
<scroll-view scroll-y class="flow h-full" @scrolltolower="reachBottom">
<info-list v-for="(item,index) in followList.list" :key="index" :item="item">
</info-list>
<u-loadmore :status="followList.loadStatus"></u-loadmore>
</scroll-view>
</swiper-item> -->
<!-- 话题 -->
<swiper-item>
<scroll-view scroll-y class="topic h-full">
<!-- 搜索框 -->
<!-- <view class="search-input" @click="goSearch">
<u-input type="text" placeholder="请输入搜索内容"
placeholderClass="iconfont iconsousuo text-28" border="none" inputAlign="center" clearable
confirmType="search" disabled>
</u-input>
</view> -->
<!-- 轮播图 -->
<u-swiper :list="topicList.swiper" keyName="image" indicator indicatorMode="line" circular
height="320rpx" bgColor="#ffffff"></u-swiper>
<news-topic-nav title="招聘公告" url=""></news-topic-nav>
<view class="last-update">
<topic-list v-if='index<=2' :item="item" v-for="(item,index) in topicList.list"
:key="index"></topic-list>
</view>
<news-topic-nav title="技能培训" url=""></news-topic-nav>
<view class="last-update">
<topic-list v-if='index<=2' :item="item" v-for="(item,index) in topicList.list"
:key="index"></topic-list>
</view>
</scroll-view>
</swiper-item>
</swiper>
</u-sticky>
<view class="last-update">
<topic-list v-if='index<=5' :item="item" v-for="(item,index) in topicList.list" :key="index"></topic-list>
</view>
</view>
</template>
@ -76,6 +40,9 @@
},
data() {
return {
keyword: "",
currect: 0,
//
tabIndex: 1,
tabList: [{
@ -99,152 +66,122 @@
topicList: {
swiper: [ //
{
image: '/static/img/demo/winter.png',
title: '迷人的春天是令人欢欣鼓舞的。'
},
{
image: '/static/img/demo/winter.png',
title: '一道残阳铺水中,半江瑟瑟半江红。'
},
{
image: '/static/img/demo/winter.png',
title: '金秋的阳光温馨恬静,金秋的微风和煦轻柔。'
},
{
image: '/static/img/demo/winter.png',
title: '风吹过,寒气直侵入骨头。'
image: '/static/img/demo/winter1.jpeg',
}
],
list: topicList[1].list
}
},
tabsList: [{
img: '/static/img/demo/zhaopin.png',
imgSelect: '/static/img/demo/zhaopin-select.png',
title: '招聘',
},
{
img: '/static/img/demo/jineng.png',
imgSelect: '/static/img/demo/jineng-select.png',
title: '技能',
},
{
img: '/static/img/demo/kecheng.png',
imgSelect: '/static/img/demo/kecheng-select.png',
title: '课程',
}
]
}
},
onLoad() {
// swiperHeight
uni.getSystemInfo({
success: (res) => {
// screenHeight) = (statusBarHeight) + (44px) + 使(windowHeight)
// 使 = swiper +
this.swiperHeight = res.windowHeight - 44
}
})
},
methods: {
// tabbar
changeTab(index) {
this.tabIndex = index
},
// swiper
changeSwiper(e) {
this.tabIndex = e.detail.current
},
// scroll-view
reachBottom() {
//
if (this.followList.loadStatus !== 'loadmore') return;
//
this.followList.loadStatus = "loading"
setTimeout(() => {
this.getList()
}, 1000);
},
//
getList(idx) {
// 5
for (let i = 0; i < 5; i++) {
let index = this.$u.random(0, this.followList.list.length - 1)
let data = JSON.parse(JSON.stringify(this.followList.list[index]))
this.followList.list.push(data)
}
//
this.followList.loadStatus = "nomore"
},
//
goSearch() {
this.$u.route('/pages/home/search', {
type: 'topic'
})
btntabs(index) {
this.currect = index
}
}
}
</script>
<style lang="scss" scoped>
.news {
<style lang="scss">
page {
background-color: #f7f8ff;
}
//
/deep/ .u-navbar {
.search-input {
width: 90%;
margin: 0 auto;
position: relative;
bottom: 270rpx;
}
.iconfont {
font-size: 48rpx;
color: $uni-color-green;
}
.tabs-list {
// border: solid 1px red;
width: 95%;
margin: 0 auto;
display: flex;
align-items: center;
background-color: #FFFFFF;
border-radius: 20rpx;
position: relative;
bottom: 200rpx;
height: 180rpx;
.nav-center {
text-align: center;
.left {
width: 80%;
display: flex;
align-items: center;
// border: solid 1px red;
.item {
flex: 1;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
.nav-title {
width: 60rpx;
font-size: 30rpx;
padding: 0 15rpx;
font-weight: bold;
color: $uni-text-color-gray;
.images {
width: 65rpx;
height: 65rpx;
}
.active {
position: relative;
display: flex;
justify-content: center;
align-items: center;
.nav-title {
color: $uni-color-green;
}
.active-line {
border-bottom: 8rpx solid $uni-color-green;
border-radius: 20rpx;
width: 70rpx;
position: absolute;
bottom: -10rpx;
left: 50%;
margin-left: -35rpx;
}
.text1 {
font-size: 28rpx;
color: #000000;
margin-top: 10rpx;
}
}
.u-navbar__content {
padding-right: 180rpx !important; //
}
}
.topic {
.search-input {
margin-top: 20rpx;
margin-bottom: 20rpx;
height: 70rpx;
background-color: #F4F4F4;
border-radius: 10rpx;
.right {
width: 20%;
// border:solid 1px blue;
display: flex;
justify-content: center;
/deep/ .u-input {
height: 100%;
}
.images1 {
width: 60rpx;
height: 60rpx;
}
.last-update {
padding: 0 20rpx 20rpx;
.last-update-name {
font-size: 32rpx;
padding-bottom: 5rpx;
}
}
}
}
.last-update {
// border: solid 1px red;
position: relative;
bottom: 200rpx;
width: 95%;
margin: 0 auto;
}
/deep/.u-search__content {
background-color: rgba(255, 255, 255, 0.4) !important;
}
/deep/.u-search__content__input {
background-color: rgba(255, 255, 255, 0) !important;
}
</style>

250
pages/home/oldHome.vue Normal file
View File

@ -0,0 +1,250 @@
<template>
<!-- 新鲜事页 -->
<view class="news">
<!-- 导航栏 -->
<!-- <u-navbar placeholder>
<view slot="left"></view>
<view slot="center" class="nav-center">
<view :class="{'active':tabIndex === index}" @click="changeTab(index)" v-for="(item,index) in tabList"
:key="index">
<view class="nav-title">{{item.name}}</view>
<view class="active-line"></view>
</view>
</view>
</u-navbar> -->
<!-- #ifdef MP-WEIXIN -->
<u-navbar placeholder>
<view slot="left" @click="btn" class="iconfont iconqiandao" style="visibility: hidden;"></view>
<view slot="center" class="nav-center">
<u-search placeholder="搜索新鲜事" @click="goSearch()" :showAction="false" disabled></u-search>
</view>
<!-- <view slot="right" class="iconfont iconPensyumaobi" @click="handlePublish()"></view> -->
</u-navbar>
<!-- #endif -->
<!-- 信息列表 -->
<swiper class="bg-white px-20 py-20" :style="{height:swiperHeight + 'px'}" :current="tabIndex"
@change="changeSwiper">
<!-- <swiper-item>
<scroll-view scroll-y class="flow h-full" @scrolltolower="reachBottom">
<info-list v-for="(item,index) in followList.list" :key="index" :item="item">
</info-list>
<u-loadmore :status="followList.loadStatus"></u-loadmore>
</scroll-view>
</swiper-item> -->
<!-- 话题 -->
<swiper-item>
<scroll-view scroll-y class="topic h-full">
<!-- 搜索框 -->
<!-- <view class="search-input" @click="goSearch">
<u-input type="text" placeholder="请输入搜索内容"
placeholderClass="iconfont iconsousuo text-28" border="none" inputAlign="center" clearable
confirmType="search" disabled>
</u-input>
</view> -->
<!-- 轮播图 -->
<u-swiper :list="topicList.swiper" keyName="image" indicator indicatorMode="line" circular
height="320rpx" bgColor="#ffffff"></u-swiper>
<news-topic-nav title="招聘公告" url=""></news-topic-nav>
<view class="last-update">
<topic-list v-if='index<=2' :item="item" v-for="(item,index) in topicList.list"
:key="index"></topic-list>
</view>
<news-topic-nav title="技能培训" url=""></news-topic-nav>
<view class="last-update">
<topic-list v-if='index<=2' :item="item" v-for="(item,index) in topicList.list"
:key="index"></topic-list>
</view>
</scroll-view>
</swiper-item>
</swiper>
</view>
</template>
<script>
import {
newsList,
topicList
} from "@/utils/data/data.js"
import InfoList from "@/pages/home/cpns/info-list.vue"
import NewsTopicNav from "@/pages/news/cpns/news-topic-nav.vue"
import TopicList from "@/pages/news/cpns/topic-list.vue"
export default {
components: {
InfoList,
NewsTopicNav,
TopicList
},
data() {
return {
//
tabIndex: 1,
tabList: [{
name: "关注",
id: 'follow'
},
{
name: "话题",
id: 'topic'
}
],
swiperHeight: 0,
//
followList: {
//
loadStatus: 'loadmore',
//
list: newsList[0].list
},
//
topicList: {
swiper: [ //
{
image: '/static/img/demo/winter.png',
title: '迷人的春天是令人欢欣鼓舞的。'
},
{
image: '/static/img/demo/winter.png',
title: '一道残阳铺水中,半江瑟瑟半江红。'
},
{
image: '/static/img/demo/winter.png',
title: '金秋的阳光温馨恬静,金秋的微风和煦轻柔。'
},
{
image: '/static/img/demo/winter.png',
title: '风吹过,寒气直侵入骨头。'
}
],
list: topicList[1].list
}
}
},
onLoad() {
// swiperHeight
uni.getSystemInfo({
success: (res) => {
// screenHeight) = (statusBarHeight) + (44px) + 使(windowHeight)
// 使 = swiper +
this.swiperHeight = res.windowHeight - 44
}
})
},
methods: {
// tabbar
changeTab(index) {
this.tabIndex = index
},
// swiper
changeSwiper(e) {
this.tabIndex = e.detail.current
},
// scroll-view
reachBottom() {
//
if (this.followList.loadStatus !== 'loadmore') return;
//
this.followList.loadStatus = "loading"
setTimeout(() => {
this.getList()
}, 1000);
},
//
getList(idx) {
// 5
for (let i = 0; i < 5; i++) {
let index = this.$u.random(0, this.followList.list.length - 1)
let data = JSON.parse(JSON.stringify(this.followList.list[index]))
this.followList.list.push(data)
}
//
this.followList.loadStatus = "nomore"
},
//
goSearch() {
this.$u.route('/pages/home/search', {
type: 'topic'
})
}
}
}
</script>
<style lang="scss" scoped>
.news {
//
/deep/ .u-navbar {
.iconfont {
font-size: 48rpx;
color: $uni-color-green;
}
.nav-center {
text-align: center;
display: flex;
justify-content: center;
align-items: center;
.nav-title {
width: 60rpx;
font-size: 30rpx;
padding: 0 15rpx;
font-weight: bold;
color: $uni-text-color-gray;
}
.active {
position: relative;
display: flex;
justify-content: center;
align-items: center;
.nav-title {
color: $uni-color-green;
}
.active-line {
border-bottom: 8rpx solid $uni-color-green;
border-radius: 20rpx;
width: 70rpx;
position: absolute;
bottom: -10rpx;
left: 50%;
margin-left: -35rpx;
}
}
}
.u-navbar__content {
padding-right: 180rpx !important; //
}
}
.topic {
.search-input {
margin-top: 20rpx;
margin-bottom: 20rpx;
height: 70rpx;
background-color: #F4F4F4;
border-radius: 10rpx;
/deep/ .u-input {
height: 100%;
}
}
.last-update {
padding: 0 20rpx 20rpx;
.last-update-name {
font-size: 32rpx;
padding-bottom: 5rpx;
}
}
}
}
</style>

View File

@ -65,6 +65,10 @@
<style lang="scss" scoped>
.topic-list {
background-color: #FFFFFF;
margin-top: 20rpx;
border-radius: 10rpx;
padding:15rpx 10rpx;
image {
width: 150rpx;
height: 150rpx;

BIN
static/img/demo/gengduo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 578 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 975 B

BIN
static/img/demo/jineng.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 966 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 700 B

BIN
static/img/demo/kecheng.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 681 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
static/img/demo/zhaopin.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
static/img/jineng.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 861 B