7 changed files with 366 additions and 252 deletions
@ -0,0 +1,130 @@ |
|||
<template> |
|||
<view class="tab_bar"> |
|||
<view class="tabbarBox"> |
|||
<view class="handleBox" v-for="(item,index) in tabBarList" :key="index"> |
|||
<view class="menuBox" @click="goPages(item.pageIndex)"> |
|||
<view class="menuIcon"> |
|||
<image v-if="item.type!=selectIndex" class="img" :src="item.iconPath"></image> |
|||
<image v-else class="img" :src="item.selectIconPath"></image> |
|||
</view> |
|||
<view class="menuName"> |
|||
<text :class="item.type==selectIndex?'TextColor':'Text'" >{{item.tabbarName}}</text> |
|||
</view> |
|||
</view> |
|||
</view> |
|||
</view> |
|||
|
|||
</view> |
|||
</template> |
|||
|
|||
<script> |
|||
export default { |
|||
props: { |
|||
page: { |
|||
type: String, |
|||
default: "homeIndex" |
|||
} |
|||
}, |
|||
watch: { |
|||
page: { |
|||
handler(value) { |
|||
this.selectIndex = value; |
|||
}, |
|||
immediate: true, |
|||
deep: true |
|||
} |
|||
}, |
|||
data() { |
|||
return { |
|||
selectIndex: "", |
|||
tabBarList: [], |
|||
} |
|||
|
|||
}, |
|||
//uniapp子组件不支持应用生命周期,所以只能用vue生命周期 |
|||
created() { |
|||
|
|||
//tabbar数据,这儿也支持后台定义通过接口获取数据 |
|||
// this.tabBarList = [{ |
|||
// "tabbarName":"", //tababr名称 |
|||
// "iconPath":"", //tabbar icon |
|||
// "selectIconPath":"", //tabbar 选择icon |
|||
// "pageIndex":"" //页面路径 |
|||
// }] |
|||
this.listTabbar(); |
|||
},methods: { |
|||
listTabbar() { |
|||
this.$api.listTabbar({}) |
|||
.then(res => { |
|||
console.log(res) |
|||
for (var i = 0; i < res.data.length; i++) { |
|||
if (res.data[i].hide == 1) { |
|||
this.tabBarList.push({ |
|||
"tabbarName": res.data[i].title, |
|||
"iconPath": res.data[i].selectedIconPath, |
|||
"selectIconPath": res.data[i].selectedIconPath, |
|||
"pageIndex": res.data[i].pagePath, |
|||
"type": res.data[i].type |
|||
}); |
|||
} |
|||
} |
|||
}).catch((e) => console.log(e)); //捕获异常 |
|||
}, |
|||
//进入tabble页 |
|||
goPages(pageIndex) { |
|||
uni.switchTab({ |
|||
url:"/"+pageIndex |
|||
}) |
|||
}, |
|||
|
|||
}, |
|||
} |
|||
</script> |
|||
<style lang="scss"> |
|||
.tab_bar { |
|||
width: 100vw; |
|||
height: 120rpx; |
|||
position: fixed; |
|||
bottom: 30rpx; |
|||
/* 模糊大小就是靠的blur这个函数中的数值大小 */ |
|||
backdrop-filter: blur(10px); |
|||
border-radius: 60rpx; |
|||
|
|||
.tabbarBox { |
|||
display: flex; |
|||
margin-top: 10rpx; |
|||
justify-content: space-evenly; |
|||
|
|||
|
|||
.handleBox { |
|||
width: 20vw; |
|||
height: 110rpx; |
|||
|
|||
|
|||
.menuBox { |
|||
padding: 0rpx 20rpx; |
|||
width: 120rpx; |
|||
height: 98%; |
|||
text-align: center; |
|||
|
|||
.img { |
|||
width: 50rpx; |
|||
height: 50rpx; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
.Text { |
|||
font-size: 24rpx; |
|||
font-family: Cochin, serif; |
|||
font-weight: 900; |
|||
} |
|||
|
|||
.TextColor { |
|||
@extend .Text; |
|||
color: #d81e06; |
|||
} |
|||
|
|||
</style> |
|||
@ -1,208 +1,224 @@ |
|||
<template> |
|||
<view class="my-userinfo-container"> |
|||
<!-- 头像和昵称区域 --> |
|||
<view class="top-box"> |
|||
<image :src="avatarUrl" class="avatar"></image> |
|||
<view class="nickname">盛大鹏</view> |
|||
</view> |
|||
|
|||
<!-- 面板区域 --> |
|||
<view class="panel-list"> |
|||
<!-- 第1个面板 --> |
|||
<view class="panel"> |
|||
<view class="panel-body"> |
|||
<view class="panel-item"> |
|||
<text>0</text> |
|||
<text>勋章</text> |
|||
</view> |
|||
<view class="panel-item"> |
|||
<text>0</text> |
|||
<text>挑战历史</text> |
|||
</view> |
|||
</view> |
|||
</view> |
|||
|
|||
<!-- 第2个面板 --> |
|||
<view class="panel"> |
|||
<!-- 轮播图 --> |
|||
<swiper :indicator-dots="false" :autoplay="true" :interval="3000" :duration="1000" :circular="true"> |
|||
<swiper-item v-for="(item, i) in swiperList" :key="i"> |
|||
<navigator class="swiper-item"> |
|||
<image :src="item"></image> |
|||
</navigator> |
|||
</swiper-item> |
|||
</swiper> |
|||
</view> |
|||
|
|||
<!-- 第3个面板 --> |
|||
<view class="panel"> |
|||
<view class="function-list"> |
|||
<view class="panel-list-item" v-for="(item,i) in functionList" :key="i"> |
|||
<image class="function-img" :src="item.uploadPath"></image> |
|||
<text style="margin-right: 220px;">{{item.name}}</text> |
|||
<uni-icons type="arrowright" size="15"></uni-icons> |
|||
</view> |
|||
</view> |
|||
</view> |
|||
</view> |
|||
<!-- 头像和昵称区域 --> |
|||
<view class="top-box"> |
|||
<image :src="avatarUrl" class="avatar"></image> |
|||
<view class="nickname">盛大鹏</view> |
|||
</view> |
|||
|
|||
<!-- 面板区域 --> |
|||
<view class="panel-list"> |
|||
<!-- 第1个面板 --> |
|||
<view class="panel"> |
|||
<view class="panel-body"> |
|||
<view class="panel-item"> |
|||
<text>0</text> |
|||
<text>勋章</text> |
|||
</view> |
|||
<view class="panel-item"> |
|||
<text>0</text> |
|||
<text>挑战历史</text> |
|||
</view> |
|||
</view> |
|||
</view> |
|||
|
|||
<!-- 第2个面板 --> |
|||
<view class="panel"> |
|||
<!-- 轮播图 --> |
|||
<swiper :indicator-dots="false" :autoplay="true" :interval="3000" :duration="1000" :circular="true"> |
|||
<swiper-item v-for="(item, i) in swiperList" :key="i"> |
|||
<navigator class="swiper-item"> |
|||
<image :src="item"></image> |
|||
</navigator> |
|||
</swiper-item> |
|||
</swiper> |
|||
</view> |
|||
|
|||
<!-- 第3个面板 --> |
|||
<view class="panel"> |
|||
<view class="function-list"> |
|||
<view class="panel-list-item" v-for="(item,i) in functionList" :key="i"> |
|||
<image class="function-img" :src="item.uploadPath"></image> |
|||
<text style="margin-right: 220px;">{{item.name}}</text> |
|||
<uni-icons type="arrowright" size="15"></uni-icons> |
|||
</view> |
|||
</view> |
|||
</view> |
|||
</view> |
|||
|
|||
<tabbar :page="page"></tabbar> |
|||
</view> |
|||
</template> |
|||
|
|||
<script> |
|||
import { mapState, mapMutations } from 'vuex' |
|||
import tabbar from "@/components/tabbar/tabbar.vue"; |
|||
import { |
|||
mapState, |
|||
mapMutations |
|||
} from 'vuex' |
|||
export default { |
|||
data() { |
|||
return { |
|||
avatarUrl : uni.$http.baseUrl+"/profile//2024/01/18/6147d64a3b94d7b3d3cc35aaf8cbfe06.png", |
|||
page: "", |
|||
avatarUrl: uni.$http.baseUrl + "/profile//2024/01/18/6147d64a3b94d7b3d3cc35aaf8cbfe06.png", |
|||
//轮播图数据列表 |
|||
swiperList: [], |
|||
//主页功能列表 |
|||
functionList:[] |
|||
functionList: [] |
|||
}; |
|||
}, |
|||
onLoad() { |
|||
this.getSwiperList() |
|||
this.getFunctionList() |
|||
}, |
|||
onShow() { |
|||
this.page = "my" |
|||
}, |
|||
computed: { |
|||
...mapState('m_user', ['userinfo']) |
|||
...mapState('m_user', ['userinfo']) |
|||
}, |
|||
methods: { |
|||
...mapMutations('m_user', ['updateAddress', 'updateUserInfo', 'updateToken']), |
|||
async logout() { |
|||
const [err, succ] = await uni.showModal({ |
|||
title: '提示', |
|||
content: '确认退出登录吗?' |
|||
}).catch(err => err) |
|||
|
|||
if (succ && succ.confirm) { |
|||
this.updateAddress({}) |
|||
this.updateUserInfo({}) |
|||
this.updateToken('') |
|||
} |
|||
}, |
|||
async getSwiperList() { |
|||
|
|||
const { |
|||
data: res |
|||
} = await uni.$http.post('/small/customImage/listAll',{page:"my"}) |
|||
if (!res.success) return uni.$showMsg() |
|||
|
|||
res.data.forEach(item=>{ |
|||
item.uploadPath = uni.$http.baseUrl +item.uploadPath |
|||
this.swiperList.push(item.uploadPath) |
|||
}) |
|||
uni.$showMsg('数据请求成功!') |
|||
}, |
|||
async getFunctionList() { |
|||
|
|||
const { |
|||
data: res |
|||
} = await uni.$http.post('/small/project/home/listAll') |
|||
if (!res.success) return uni.$showMsg() |
|||
|
|||
res.data.forEach(item=>{ |
|||
item.uploadPath = uni.$http.baseUrl +item.uploadPath |
|||
}) |
|||
this.functionList = res.data; |
|||
uni.$showMsg('数据请求成功!') |
|||
} |
|||
...mapMutations('m_user', ['updateAddress', 'updateUserInfo', 'updateToken']), |
|||
async logout() { |
|||
const [err, succ] = await uni.showModal({ |
|||
title: '提示', |
|||
content: '确认退出登录吗?' |
|||
}).catch(err => err) |
|||
|
|||
if (succ && succ.confirm) { |
|||
this.updateAddress({}) |
|||
this.updateUserInfo({}) |
|||
this.updateToken('') |
|||
} |
|||
}, |
|||
async getSwiperList() { |
|||
|
|||
const { |
|||
data: res |
|||
} = await uni.$http.post('/small/customImage/listAll', { |
|||
page: "my" |
|||
}) |
|||
if (!res.success) return uni.$showMsg() |
|||
|
|||
res.data.forEach(item => { |
|||
item.uploadPath = uni.$http.baseUrl + item.uploadPath |
|||
this.swiperList.push(item.uploadPath) |
|||
}) |
|||
uni.$showMsg('数据请求成功!') |
|||
}, |
|||
async getFunctionList() { |
|||
|
|||
const { |
|||
data: res |
|||
} = await uni.$http.post('/small/project/home/listAll') |
|||
if (!res.success) return uni.$showMsg() |
|||
|
|||
res.data.forEach(item => { |
|||
item.uploadPath = uni.$http.baseUrl + item.uploadPath |
|||
}) |
|||
this.functionList = res.data; |
|||
uni.$showMsg('数据请求成功!') |
|||
} |
|||
}, |
|||
navClickHandler(item) { |
|||
|
|||
|
|||
}, |
|||
components: { |
|||
tabbar |
|||
} |
|||
} |
|||
</script> |
|||
|
|||
<style lang="scss"> |
|||
.my-userinfo-container { |
|||
height: 100%; |
|||
background-color: #F4F4F4; |
|||
|
|||
.top-box { |
|||
height: 400rpx; |
|||
background-color: #aba9d0; |
|||
display: flex; |
|||
justify-content: center; |
|||
align-items: center; |
|||
flex-direction: column; |
|||
|
|||
.avatar { |
|||
width: 90px; |
|||
height: 90px; |
|||
border-radius: 45px; |
|||
border: 2px solid #FFF; |
|||
box-shadow: 0 1px 5px black; |
|||
} |
|||
|
|||
.nickname { |
|||
font-size: 16px; |
|||
color: black; |
|||
font-family: Georgia, 'Times New Roman', Times, serif; |
|||
margin-top: 10px; |
|||
} |
|||
} |
|||
} |
|||
|
|||
.panel-list { |
|||
padding: 0 10px; |
|||
position: relative; |
|||
top: -10px; |
|||
|
|||
.panel { |
|||
background-color: white; |
|||
border-radius: 3px; |
|||
margin-bottom: 8px; |
|||
|
|||
.panel-title { |
|||
line-height: 45px; |
|||
padding-left: 10px; |
|||
font-size: 15px; |
|||
border-bottom: 1px solid #F4F4F4; |
|||
} |
|||
|
|||
.panel-body { |
|||
display: flex; |
|||
justify-content: space-around; |
|||
|
|||
.panel-item { |
|||
display: flex; |
|||
flex-direction: column; |
|||
align-items: center; |
|||
justify-content: space-around; |
|||
padding: 10px 0; |
|||
font-size: 13px; |
|||
|
|||
.icon { |
|||
width: 35px; |
|||
height: 35px; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
.function-img{ |
|||
width: 30px; |
|||
height: 30px; |
|||
} |
|||
|
|||
.panel-list-item { |
|||
display: flex; |
|||
justify-content: space-between; |
|||
align-items: center; |
|||
font-size: 15px; |
|||
padding: 0 10px; |
|||
line-height: 45px; |
|||
} |
|||
swiper { |
|||
height: 230rpx; |
|||
|
|||
.swiper-item, |
|||
image { |
|||
width: 100%; |
|||
height: 100%; |
|||
border-radius: 4px; |
|||
} |
|||
} |
|||
</style> |
|||
.my-userinfo-container { |
|||
height: 100%; |
|||
background-color: #F4F4F4; |
|||
|
|||
.top-box { |
|||
height: 400rpx; |
|||
background-color: #aba9d0; |
|||
display: flex; |
|||
justify-content: center; |
|||
align-items: center; |
|||
flex-direction: column; |
|||
|
|||
.avatar { |
|||
width: 90px; |
|||
height: 90px; |
|||
border-radius: 45px; |
|||
border: 2px solid #FFF; |
|||
box-shadow: 0 1px 5px black; |
|||
} |
|||
|
|||
.nickname { |
|||
font-size: 16px; |
|||
color: black; |
|||
font-family: Georgia, 'Times New Roman', Times, serif; |
|||
margin-top: 10px; |
|||
} |
|||
} |
|||
} |
|||
|
|||
.panel-list { |
|||
padding: 0 10px; |
|||
position: relative; |
|||
top: -10px; |
|||
|
|||
.panel { |
|||
background-color: white; |
|||
border-radius: 3px; |
|||
margin-bottom: 8px; |
|||
|
|||
.panel-title { |
|||
line-height: 45px; |
|||
padding-left: 10px; |
|||
font-size: 15px; |
|||
border-bottom: 1px solid #F4F4F4; |
|||
} |
|||
|
|||
.panel-body { |
|||
display: flex; |
|||
justify-content: space-around; |
|||
|
|||
.panel-item { |
|||
display: flex; |
|||
flex-direction: column; |
|||
align-items: center; |
|||
justify-content: space-around; |
|||
padding: 10px 0; |
|||
font-size: 13px; |
|||
|
|||
.icon { |
|||
width: 35px; |
|||
height: 35px; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
.function-img { |
|||
width: 30px; |
|||
height: 30px; |
|||
} |
|||
|
|||
.panel-list-item { |
|||
display: flex; |
|||
justify-content: space-between; |
|||
align-items: center; |
|||
font-size: 15px; |
|||
padding: 0 10px; |
|||
line-height: 45px; |
|||
} |
|||
|
|||
swiper { |
|||
height: 230rpx; |
|||
|
|||
.swiper-item, |
|||
image { |
|||
width: 100%; |
|||
height: 100%; |
|||
border-radius: 4px; |
|||
} |
|||
} |
|||
</style> |
|||
Loading…
Reference in new issue