chenkainan 4 months ago
parent
commit
f368ffdd93
  1. 144
      components/CustomTabBar.vue
  2. 52
      pages.json
  3. 31
      pages/cart/cart.vue
  4. 31
      pages/coupon/coupon.vue
  5. 17
      pages/index/index.vue
  6. 31
      pages/map/map.vue
  7. 26
      pages/user/user.vue
  8. 8
      static/css/base.css
  9. BIN
      static/images/cart.png
  10. BIN
      static/images/coupon.png
  11. BIN
      static/images/home.png
  12. BIN
      static/images/map.png
  13. BIN
      static/images/mine.png
  14. BIN
      static/images/selectCart.png
  15. BIN
      static/images/selectCoupon.png
  16. BIN
      static/images/selectHome.png
  17. BIN
      static/images/selectMap.png
  18. BIN
      static/images/selectMine.png
  19. BIN
      static/images/tabBarBg.png
  20. 6
      store/modules/user.js
  21. 5
      subPackages/line/index.vue

144
components/CustomTabBar.vue

@ -0,0 +1,144 @@
<template>
<view class="custom-tab-bar">
<view class="tab-item" :class="{ 'active': currentTab === 0 }" @click="switchTab(0)">
<image :src="currentTab === 0 ? tabBar.list[0].selectedIconPath : tabBar.list[0].iconPath"></image>
<text>{{ tabBar.list[0].text }}</text>
</view>
<view class="tab-item" :class="{ 'active': currentTab === 1 }" @click="switchTab(1)">
<image :src="currentTab === 1 ? tabBar.list[1].selectedIconPath : tabBar.list[1].iconPath"></image>
<text>{{ tabBar.list[1].text }}</text>
</view>
<view class="tab-item home-item" :class="{ 'active': currentTab === 2 }" @click="switchTab(2)">
<image :src="tabBar.list[2].iconPath" v-if="currentTab !== 2"></image>
<view v-else class="home-item-box">
<image :src="tabBar.list[2].selectedIconPath"></image>
</view>
<text v-if="currentTab !== 2">{{ tabBar.list[2].text }}</text>
</view>
<view class="tab-item" :class="{ 'active': currentTab === 3 }" @click="switchTab(3)">
<image :src="currentTab === 3 ? tabBar.list[3].selectedIconPath : tabBar.list[3].iconPath"></image>
<text>{{ tabBar.list[3].text }}</text>
</view>
<view class="tab-item" :class="{ 'active': currentTab === 4 }" @click="switchTab(4)">
<image :src="currentTab === 4 ? tabBar.list[4].selectedIconPath : tabBar.list[4].iconPath"></image>
<text>{{ tabBar.list[4].text }}</text>
</view>
</view>
</template>
<script>
export default {
props: {
currentTab: {
type: Number,
default: 0
}
},
data() {
return {
tabBar: {
list: [
{
"pagePath": "pages/map/map",
"iconPath": "/static/images/map.png",
"selectedIconPath": "/static/images/selectMap.png",
"text": "特产地图"
},
{
"pagePath": "pages/coupon/coupon",
"iconPath": "/static/images/coupon.png",
"selectedIconPath": "/static/images/selectCoupon.png",
"text": "领券中心"
},
{
"pagePath": "pages/index/index",
"iconPath": "/static/images/home.png",
"selectedIconPath": "/static/images/selectHome.png",
"text": "首页"
},
{
"pagePath": "pages/cart/cart",
"iconPath": "/static/images/cart.png",
"selectedIconPath": "/static/images/selectCart.png",
"text": "购物车"
},
{
"pagePath": "pages/user/user",
"iconPath": "/static/images/mine.png",
"selectedIconPath": "/static/images/selectMine.png",
"text": "我的"
}
]
}
};
},
onLoad() {
this.getCurrentTab();
},
methods: {
getCurrentTab() {
const pages = getCurrentPages();
const currentPage = pages[pages.length - 1];
const currentPath = currentPage.route;
this.tabBar.list.forEach((item, index) => {
if (item.pagePath === currentPath) {
this.currentTab = index;
}
});
},
switchTab(index) {
if (this.currentTab === index) return;
uni.switchTab({
url: '/' + this.tabBar.list[index].pagePath
});
}
}
};
</script>
<style scoped>
.custom-tab-bar {
position: fixed;
bottom: 0;
left: 0;
right: 0;
display: flex;
justify-content: space-around;
align-items: center;
height: 150rpx;
background-image: url('/static/images/tabBarBg.png');
background-size: 100% 100%;
}
.tab-item {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 20%;
}
.tab-item image {
width: 53rpx;
height: 53rpx;
}
.tab-item text {
font-size: 24rpx;
color: #666666;
}
.tab-item.active text {
color: #6A8A2D;
}
.home-item-box {
width: 112rpx;
height: 112rpx;
background: #6A8A2D;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
}
</style>

52
pages.json

@ -3,7 +3,8 @@
{ {
"path": "pages/index/index", "path": "pages/index/index",
"style": { "style": {
"navigationBarTitleText": "uni-app" "navigationBarTitleText": "首页",
"navigationStyle": "custom"
} }
}, },
{ {
@ -11,6 +12,24 @@
"style": { "style": {
"navigationBarTitleText": "uni-app" "navigationBarTitleText": "uni-app"
} }
},
{
"path": "pages/map/map",
"style": {
"navigationBarTitleText": "uni-app"
}
},
{
"path": "pages/cart/cart",
"style": {
"navigationBarTitleText": "uni-app"
}
},
{
"path": "pages/coupon/coupon",
"style": {
"navigationBarTitleText": "uni-app"
}
} }
], ],
"subPackages": [{ "subPackages": [{
@ -27,23 +46,48 @@
"style" : { "style" : {
"navigationBarTitleText" : "视频" "navigationBarTitleText" : "视频"
} }
},
{
"path" : "line/index",
"style" : {
"navigationBarTitleText" : "精选线路"
}
} }
] ]
}], }],
"tabBar": { "tabBar": {
"color": "#999999", "custom": true,
"selectedColor": "#333333", "color": "#666666",
"selectedColor": " #6A8A2D",
"borderStyle": "black", "borderStyle": "black",
"backgroundColor": "#ffffff", "backgroundColor": "#ffffff",
"fontSize": "24rpx", "fontSize": "24rpx",
"height": "100rpx", "height": "100rpx",
"iconWidth": "40rpx", "iconWidth": "53rpx",
"list": [{ "list": [{
"pagePath": "pages/map/map",
"iconPath": "/static/images/map.png",
"selectedIconPath": "/static/images/selectMap.png",
"text": "特产地图"
},
{
"pagePath": "pages/coupon/coupon",
"iconPath": "/static/images/coupon.png",
"selectedIconPath": "/static/images/selectCoupon.png",
"text": "领券中心"
},
{
"pagePath": "pages/index/index", "pagePath": "pages/index/index",
"iconPath": "/static/images/home.png", "iconPath": "/static/images/home.png",
"selectedIconPath": "/static/images/selectHome.png", "selectedIconPath": "/static/images/selectHome.png",
"text": "首页" "text": "首页"
}, },
{
"pagePath": "pages/cart/cart",
"iconPath": "/static/images/cart.png",
"selectedIconPath": "/static/images/selectCart.png",
"text": "购物车"
},
{ {
"pagePath": "pages/user/user", "pagePath": "pages/user/user",
"iconPath": "/static/images/mine.png", "iconPath": "/static/images/mine.png",

31
pages/cart/cart.vue

@ -0,0 +1,31 @@
<template>
<view class="bg">
<CustomTabBar :currentTab="3" />
</view>
</template>
<script>
import CustomTabBar from '@/components/CustomTabBar.vue';
export default {
components: {
CustomTabBar
},
data() {
return {
}
},
onLoad() {
},
methods: {
}
}
</script>
<style>
.bg {
}
</style>

31
pages/coupon/coupon.vue

@ -0,0 +1,31 @@
<template>
<view class="bg">
<CustomTabBar :currentTab="1" />
</view>
</template>
<script>
import CustomTabBar from '@/components/CustomTabBar.vue';
export default {
components: {
CustomTabBar
},
data() {
return {
}
},
onLoad() {
},
methods: {
}
}
</script>
<style>
.bg {
}
</style>

17
pages/index/index.vue

@ -1,11 +1,15 @@
<template> <template>
<view class="content"> <view class="bg">
<CustomTabBar :currentTab="2" />
</view> </view>
</template> </template>
<script> <script>
import CustomTabBar from '@/components/CustomTabBar.vue';
export default { export default {
components: {
CustomTabBar
},
data() { data() {
return { return {
@ -21,10 +25,9 @@
</script> </script>
<style> <style>
.content { .bg {
display: flex; width: 100%;
flex-direction: column; min-height: 100vh;
align-items: center; background: #CDE29E;
justify-content: center;
} }
</style> </style>

31
pages/map/map.vue

@ -0,0 +1,31 @@
<template>
<view class="bg">
<CustomTabBar :currentTab="0" />
</view>
</template>
<script>
import CustomTabBar from '@/components/CustomTabBar.vue';
export default {
components: {
CustomTabBar
},
data() {
return {
}
},
onLoad() {
},
methods: {
}
}
</script>
<style>
.bg {
}
</style>

26
pages/user/user.vue

@ -1,8 +1,34 @@
<template> <template>
<view class="content">
<CustomTabBar :currentTab="4" />
</view>
</template> </template>
<script> <script>
import CustomTabBar from '@/components/CustomTabBar.vue';
export default {
components: {
CustomTabBar
},
data() {
return {
}
},
onLoad() {
},
methods: {
}
}
</script> </script>
<style> <style>
.content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
</style> </style>

8
static/css/base.css

@ -12,6 +12,14 @@ input {
border: none; border: none;
} }
view {
box-sizing: border-box;
}
.bg {
padding-bottom: 250rpx;
}
.flex-between { .flex-between {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;

BIN
static/images/cart.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB

BIN
static/images/coupon.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

BIN
static/images/home.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 8.8 KiB

BIN
static/images/map.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

BIN
static/images/mine.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 9.6 KiB

BIN
static/images/selectCart.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

BIN
static/images/selectCoupon.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

BIN
static/images/selectHome.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

BIN
static/images/selectMap.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
static/images/selectMine.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 10 KiB

BIN
static/images/tabBarBg.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

6
store/modules/user.js

@ -37,9 +37,15 @@ export default {
state.toPath = currentPage.$page.fullPath state.toPath = currentPage.$page.fullPath
if(state.toPath == '/pages/login/login') return; if(state.toPath == '/pages/login/login') return;
// 登录 // 登录
// #ifdef MP-WEIXIN
uni.navigateTo({ uni.navigateTo({
url: '/pages/login/login' url: '/pages/login/login'
}) })
// #endif
// #ifdef H5
// #endif
}, },
//订单数据 //订单数据
changeOrderInfo(state, data) { changeOrderInfo(state, data) {

5
subPackages/line/index.vue

@ -0,0 +1,5 @@
<template>
<view>
</view>
</template>
Loading…
Cancel
Save