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> |
<template> |
||||
<view class="my-userinfo-container"> |
<view class="my-userinfo-container"> |
||||
<!-- 头像和昵称区域 --> |
<!-- 头像和昵称区域 --> |
||||
<view class="top-box"> |
<view class="top-box"> |
||||
<image :src="avatarUrl" class="avatar"></image> |
<image :src="avatarUrl" class="avatar"></image> |
||||
<view class="nickname">盛大鹏</view> |
<view class="nickname">盛大鹏</view> |
||||
</view> |
</view> |
||||
|
|
||||
<!-- 面板区域 --> |
<!-- 面板区域 --> |
||||
<view class="panel-list"> |
<view class="panel-list"> |
||||
<!-- 第1个面板 --> |
<!-- 第1个面板 --> |
||||
<view class="panel"> |
<view class="panel"> |
||||
<view class="panel-body"> |
<view class="panel-body"> |
||||
<view class="panel-item"> |
<view class="panel-item"> |
||||
<text>0</text> |
<text>0</text> |
||||
<text>勋章</text> |
<text>勋章</text> |
||||
</view> |
</view> |
||||
<view class="panel-item"> |
<view class="panel-item"> |
||||
<text>0</text> |
<text>0</text> |
||||
<text>挑战历史</text> |
<text>挑战历史</text> |
||||
</view> |
</view> |
||||
</view> |
</view> |
||||
</view> |
</view> |
||||
|
|
||||
<!-- 第2个面板 --> |
<!-- 第2个面板 --> |
||||
<view class="panel"> |
<view class="panel"> |
||||
<!-- 轮播图 --> |
<!-- 轮播图 --> |
||||
<swiper :indicator-dots="false" :autoplay="true" :interval="3000" :duration="1000" :circular="true"> |
<swiper :indicator-dots="false" :autoplay="true" :interval="3000" :duration="1000" :circular="true"> |
||||
<swiper-item v-for="(item, i) in swiperList" :key="i"> |
<swiper-item v-for="(item, i) in swiperList" :key="i"> |
||||
<navigator class="swiper-item"> |
<navigator class="swiper-item"> |
||||
<image :src="item"></image> |
<image :src="item"></image> |
||||
</navigator> |
</navigator> |
||||
</swiper-item> |
</swiper-item> |
||||
</swiper> |
</swiper> |
||||
</view> |
</view> |
||||
|
|
||||
<!-- 第3个面板 --> |
<!-- 第3个面板 --> |
||||
<view class="panel"> |
<view class="panel"> |
||||
<view class="function-list"> |
<view class="function-list"> |
||||
<view class="panel-list-item" v-for="(item,i) in functionList" :key="i"> |
<view class="panel-list-item" v-for="(item,i) in functionList" :key="i"> |
||||
<image class="function-img" :src="item.uploadPath"></image> |
<image class="function-img" :src="item.uploadPath"></image> |
||||
<text style="margin-right: 220px;">{{item.name}}</text> |
<text style="margin-right: 220px;">{{item.name}}</text> |
||||
<uni-icons type="arrowright" size="15"></uni-icons> |
<uni-icons type="arrowright" size="15"></uni-icons> |
||||
</view> |
</view> |
||||
</view> |
</view> |
||||
</view> |
</view> |
||||
</view> |
</view> |
||||
|
|
||||
|
<tabbar :page="page"></tabbar> |
||||
</view> |
</view> |
||||
</template> |
</template> |
||||
|
|
||||
<script> |
<script> |
||||
import { mapState, mapMutations } from 'vuex' |
import tabbar from "@/components/tabbar/tabbar.vue"; |
||||
|
import { |
||||
|
mapState, |
||||
|
mapMutations |
||||
|
} from 'vuex' |
||||
export default { |
export default { |
||||
data() { |
data() { |
||||
return { |
return { |
||||
avatarUrl : uni.$http.baseUrl+"/profile//2024/01/18/6147d64a3b94d7b3d3cc35aaf8cbfe06.png", |
page: "", |
||||
|
avatarUrl: uni.$http.baseUrl + "/profile//2024/01/18/6147d64a3b94d7b3d3cc35aaf8cbfe06.png", |
||||
//轮播图数据列表 |
//轮播图数据列表 |
||||
swiperList: [], |
swiperList: [], |
||||
//主页功能列表 |
//主页功能列表 |
||||
functionList:[] |
functionList: [] |
||||
}; |
}; |
||||
}, |
}, |
||||
onLoad() { |
onLoad() { |
||||
this.getSwiperList() |
this.getSwiperList() |
||||
this.getFunctionList() |
this.getFunctionList() |
||||
}, |
}, |
||||
|
onShow() { |
||||
|
this.page = "my" |
||||
|
}, |
||||
computed: { |
computed: { |
||||
...mapState('m_user', ['userinfo']) |
...mapState('m_user', ['userinfo']) |
||||
}, |
}, |
||||
methods: { |
methods: { |
||||
...mapMutations('m_user', ['updateAddress', 'updateUserInfo', 'updateToken']), |
...mapMutations('m_user', ['updateAddress', 'updateUserInfo', 'updateToken']), |
||||
async logout() { |
async logout() { |
||||
const [err, succ] = await uni.showModal({ |
const [err, succ] = await uni.showModal({ |
||||
title: '提示', |
title: '提示', |
||||
content: '确认退出登录吗?' |
content: '确认退出登录吗?' |
||||
}).catch(err => err) |
}).catch(err => err) |
||||
|
|
||||
if (succ && succ.confirm) { |
if (succ && succ.confirm) { |
||||
this.updateAddress({}) |
this.updateAddress({}) |
||||
this.updateUserInfo({}) |
this.updateUserInfo({}) |
||||
this.updateToken('') |
this.updateToken('') |
||||
} |
} |
||||
}, |
}, |
||||
async getSwiperList() { |
async getSwiperList() { |
||||
|
|
||||
const { |
const { |
||||
data: res |
data: res |
||||
} = await uni.$http.post('/small/customImage/listAll',{page:"my"}) |
} = await uni.$http.post('/small/customImage/listAll', { |
||||
if (!res.success) return uni.$showMsg() |
page: "my" |
||||
|
}) |
||||
res.data.forEach(item=>{ |
if (!res.success) return uni.$showMsg() |
||||
item.uploadPath = uni.$http.baseUrl +item.uploadPath |
|
||||
this.swiperList.push(item.uploadPath) |
res.data.forEach(item => { |
||||
}) |
item.uploadPath = uni.$http.baseUrl + item.uploadPath |
||||
uni.$showMsg('数据请求成功!') |
this.swiperList.push(item.uploadPath) |
||||
}, |
}) |
||||
async getFunctionList() { |
uni.$showMsg('数据请求成功!') |
||||
|
}, |
||||
const { |
async getFunctionList() { |
||||
data: res |
|
||||
} = await uni.$http.post('/small/project/home/listAll') |
const { |
||||
if (!res.success) return uni.$showMsg() |
data: res |
||||
|
} = await uni.$http.post('/small/project/home/listAll') |
||||
res.data.forEach(item=>{ |
if (!res.success) return uni.$showMsg() |
||||
item.uploadPath = uni.$http.baseUrl +item.uploadPath |
|
||||
}) |
res.data.forEach(item => { |
||||
this.functionList = res.data; |
item.uploadPath = uni.$http.baseUrl + item.uploadPath |
||||
uni.$showMsg('数据请求成功!') |
}) |
||||
} |
this.functionList = res.data; |
||||
|
uni.$showMsg('数据请求成功!') |
||||
|
} |
||||
}, |
}, |
||||
navClickHandler(item) { |
navClickHandler(item) { |
||||
|
|
||||
}, |
}, |
||||
|
components: { |
||||
|
tabbar |
||||
|
} |
||||
} |
} |
||||
</script> |
</script> |
||||
|
|
||||
<style lang="scss"> |
<style lang="scss"> |
||||
.my-userinfo-container { |
.my-userinfo-container { |
||||
height: 100%; |
height: 100%; |
||||
background-color: #F4F4F4; |
background-color: #F4F4F4; |
||||
|
|
||||
.top-box { |
.top-box { |
||||
height: 400rpx; |
height: 400rpx; |
||||
background-color: #aba9d0; |
background-color: #aba9d0; |
||||
display: flex; |
display: flex; |
||||
justify-content: center; |
justify-content: center; |
||||
align-items: center; |
align-items: center; |
||||
flex-direction: column; |
flex-direction: column; |
||||
|
|
||||
.avatar { |
.avatar { |
||||
width: 90px; |
width: 90px; |
||||
height: 90px; |
height: 90px; |
||||
border-radius: 45px; |
border-radius: 45px; |
||||
border: 2px solid #FFF; |
border: 2px solid #FFF; |
||||
box-shadow: 0 1px 5px black; |
box-shadow: 0 1px 5px black; |
||||
} |
} |
||||
|
|
||||
.nickname { |
.nickname { |
||||
font-size: 16px; |
font-size: 16px; |
||||
color: black; |
color: black; |
||||
font-family: Georgia, 'Times New Roman', Times, serif; |
font-family: Georgia, 'Times New Roman', Times, serif; |
||||
margin-top: 10px; |
margin-top: 10px; |
||||
} |
} |
||||
} |
} |
||||
} |
} |
||||
|
|
||||
.panel-list { |
.panel-list { |
||||
padding: 0 10px; |
padding: 0 10px; |
||||
position: relative; |
position: relative; |
||||
top: -10px; |
top: -10px; |
||||
|
|
||||
.panel { |
.panel { |
||||
background-color: white; |
background-color: white; |
||||
border-radius: 3px; |
border-radius: 3px; |
||||
margin-bottom: 8px; |
margin-bottom: 8px; |
||||
|
|
||||
.panel-title { |
.panel-title { |
||||
line-height: 45px; |
line-height: 45px; |
||||
padding-left: 10px; |
padding-left: 10px; |
||||
font-size: 15px; |
font-size: 15px; |
||||
border-bottom: 1px solid #F4F4F4; |
border-bottom: 1px solid #F4F4F4; |
||||
} |
} |
||||
|
|
||||
.panel-body { |
.panel-body { |
||||
display: flex; |
display: flex; |
||||
justify-content: space-around; |
justify-content: space-around; |
||||
|
|
||||
.panel-item { |
.panel-item { |
||||
display: flex; |
display: flex; |
||||
flex-direction: column; |
flex-direction: column; |
||||
align-items: center; |
align-items: center; |
||||
justify-content: space-around; |
justify-content: space-around; |
||||
padding: 10px 0; |
padding: 10px 0; |
||||
font-size: 13px; |
font-size: 13px; |
||||
|
|
||||
.icon { |
.icon { |
||||
width: 35px; |
width: 35px; |
||||
height: 35px; |
height: 35px; |
||||
} |
} |
||||
} |
} |
||||
} |
} |
||||
} |
} |
||||
} |
} |
||||
.function-img{ |
|
||||
width: 30px; |
.function-img { |
||||
height: 30px; |
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> |
|
||||
|
|
||||
|
.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