[新增]新增自定义tabbar组件

This commit is contained in:
唐明明
2020-12-30 10:15:22 +08:00
parent 2361b0ad09
commit 90ebeb48f7
21 changed files with 151 additions and 148 deletions

5
app.js
View File

@@ -14,9 +14,9 @@ App({
wx.$qqMap = new QQMapWX({ wx.$qqMap = new QQMapWX({
key: "3TBBZ-O42LU-HXCVQ-2M66A-NCFTT-LMBHU" key: "3TBBZ-O42LU-HXCVQ-2M66A-NCFTT-LMBHU"
}) })
//挂载api方法 //挂载api方法
wx.$api = apis wx.$api = apis
}, },
globalData: { globalData: {
navAppInfo : { navAppInfo : {
@@ -24,6 +24,7 @@ App({
envVersion : "trial", envVersion : "trial",
goodUrl : "/pages/goods/show?goodsId=", goodUrl : "/pages/goods/show?goodsId=",
cardUrl : "/pages/card/index?cardid=" cardUrl : "/pages/card/index?cardid="
} },
id : 1
} }
}) })

View File

@@ -1,8 +1,7 @@
{ {
"pages": [ "pages": [
"pages/config/config",
"pages/welcome/index", "pages/welcome/index",
"pages/config/config",
"pages/company/index", "pages/company/index",
"pages/company/search/search", "pages/company/search/search",
"pages/shortVideo/index", "pages/shortVideo/index",
@@ -45,42 +44,14 @@
"pages/home/projectSuccess/projectSuccess", "pages/home/projectSuccess/projectSuccess",
"pages/home/activeSuccess/activeSuccess" "pages/home/activeSuccess/activeSuccess"
], ],
"tabBar": {
"list": [{
"pagePath": "pages/shortVideo/index",
"text": "视频",
"iconPath": "/static/tabbar/tabbar_icon_00.png",
"selectedIconPath": "/static/tabbar/tabbar_icon_show_00.png"
},
{
"pagePath": "pages/mall/index",
"text": "商城",
"iconPath": "/static/tabbar/tabbar_icon_01.png",
"selectedIconPath": "/static/tabbar/tabbar_icon_show_01.png"
},
{
"pagePath": "pages/ticket/index",
"text": "优惠",
"iconPath": "/static/tabbar/tabbar_icon_02.png",
"selectedIconPath": "/static/tabbar/tabbar_icon_show_02.png"
},
{
"pagePath": "pages/user/index",
"text": "我的",
"iconPath": "/static/tabbar/tabbar_icon_03.png",
"selectedIconPath": "/static/tabbar/tabbar_icon_show_03.png"
}
],
"selectedColor": "#0b0041",
"color": "#4e4f51",
"borderStyle": "white",
"custom": true
},
"window": { "window": {
"navigationBarBackgroundColor": "#fff", "navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "", "navigationBarTitleText": "",
"navigationBarTextStyle": "black" "navigationBarTextStyle": "black"
}, },
"usingComponents": {
"storeTabBar": "/components/storeTabBar/storeTabBar"
},
"plugins": { "plugins": {
"live-player-plugin": { "live-player-plugin": {
"version": "1.2.5", "version": "1.2.5",

View File

@@ -7,7 +7,7 @@
<view class="recommend-label" wx:for="{{pushList}}" wx:key="pushList" bindtap="push" <view class="recommend-label" wx:for="{{pushList}}" wx:key="pushList" bindtap="push"
data-id="{{item.goods_id}}"> data-id="{{item.goods_id}}">
<view class="recommend-img"> <view class="recommend-img">
<image src="{{item.cover}}" mode="aspectFill"></image> <image class="recommend-img-src" src="{{item.cover}}" mode="aspectFill"></image>
</view> </view>
<view class="recommend-cont"> <view class="recommend-cont">
<view class="nowrap recommend-name"> <view class="nowrap recommend-name">

View File

@@ -34,7 +34,7 @@
padding-top: 100%; padding-top: 100%;
} }
.recommend-img image { .recommend-img-src {
position: absolute; position: absolute;
width: 100%; width: 100%;
height: 100%; height: 100%;
@@ -65,7 +65,6 @@
.recommend-cost { .recommend-cost {
font-size: 24rpx; font-size: 24rpx;
color: #999; color: #999;
/* text-decoration:line-through; */
margin: 2rpx 0 0 20rpx; margin: 2rpx 0 0 20rpx;
} }

View File

@@ -4,7 +4,7 @@
<view class="videoTitle-name"> <view class="videoTitle-name">
<view class="videoTitle-name-color">商品直播间专区</view> <view class="videoTitle-name-color">商品直播间专区</view>
<view class="videoTitle-name-img"> <view class="videoTitle-name-img">
<image src="/static/mall_icon/liveIng_bf.png"></image>LIVE <image class="videoTitle-name-img-img" src="/static/mall_icon/liveIng_bf.png"></image>LIVE
</view> </view>
</view> </view>
<navigator hover-class="none" url="/pages/mall_video/mall_video" class="videoTitle-more"> <navigator hover-class="none" url="/pages/mall_video/mall_video" class="videoTitle-more">
@@ -16,7 +16,7 @@
<view class="videoList-img"> <view class="videoList-img">
<image class="videoList-cover" src="/static/images/goods_text.png" mode="aspectFill"></image> <image class="videoList-cover" src="/static/images/goods_text.png" mode="aspectFill"></image>
<view class="videoList-tips"> <view class="videoList-tips">
<image src="/static/mall_icon/liveIng_icon.png"></image>正在直播 <image class="videoList-tips-image" src="/static/mall_icon/liveIng_icon.png"></image>正在直播
</view> </view>
</view> </view>
<view class="videoList-cont"> <view class="videoList-cont">

View File

@@ -40,7 +40,7 @@
margin-top: 5rpx; margin-top: 5rpx;
} }
.videoTitle-name-img image { .videoTitle-name-img-img {
width: 34rpx; width: 34rpx;
height: 34rpx; height: 34rpx;
margin: 1rpx 6rpx 0 10rpx; margin: 1rpx 6rpx 0 10rpx;
@@ -73,7 +73,7 @@
padding-top: 80%; padding-top: 80%;
} }
.videoList-img .videoList-cover { .videoList-cover {
position: absolute; position: absolute;
top: 0; top: 0;
left: 0; left: 0;
@@ -96,7 +96,7 @@
box-shadow: 0 0 10rpx rgba(0, 0, 0, .05); box-shadow: 0 0 10rpx rgba(0, 0, 0, .05);
} }
.videoList-tips image { .videoList-tips-image {
width: 30rpx; width: 30rpx;
height: 30rpx; height: 30rpx;
margin: 8rpx 10rpx 6rpx 0; margin: 8rpx 10rpx 6rpx 0;

View File

@@ -0,0 +1,56 @@
/**
* Web唐明明
* 匆匆数载恍如梦,岁月迢迢华发增。
* 碌碌无为枉半生,一朝惊醒万事空。
*/
import { tabBar } from "../../lib/storeConfig"
Component({
/**
* 组件接收参数
*/
properties: {
// 显示组件页面的路径
pagesUrl : {
type : String,
value : ""
}
},
/**
* 组件的初始数据
*/
data: {
selected : 0,
color : "#4e4f51",
selectedColor : "#0b0041",
list : []
},
/**
* 生命周期函数
*/
pageLifetimes: {
show(){
let selectedIndex = tabBar.findIndex(val=> val.pagePath == '/' + this.data.pagesUrl)
this.setData({
list : tabBar,
selected: selectedIndex
})
}
},
/**
* 组件的方法列表
*/
methods: {
switchTab(e) {
const data = e.currentTarget.dataset
const url = data.path
wx.reLaunch({
url
})
}
}
})

View File

@@ -0,0 +1,4 @@
{
"component": true,
"usingComponents": {}
}

View File

@@ -1,9 +1,8 @@
<cover-view class="tab-bar"> <cover-view class="tab-bar">
<cover-view class="tab-bar-border"></cover-view> <cover-view class="tab-bar-border"></cover-view>
<cover-view wx:for="{{list}}" wx:key="index" class="tab-bar-item" data-path="{{item.pagePath}}" <cover-view wx:for="{{list}}" wx:key="index" class="tab-bar-item" data-path="{{item.pagePath}}"
data-index="{{index}}" bindtap="switchTab"> data-index="{{index}}" bindtap="switchTab">
<cover-image src="{{selected === index ? item.selectedIconPath : item.iconPath}}"></cover-image> <cover-image class="tab-bar-item-icon" src="{{selected === index ? item.selectedIconPath : item.iconPath}}"></cover-image>
<cover-view style="color: {{selected === index ? selectedColor : color}}">{{item.text}}</cover-view> <cover-view class="tab-bar-text" style="color: {{selected === index ? selectedColor : color}}">{{item.text}}</cover-view>
</cover-view> </cover-view>
</cover-view> </cover-view>

View File

@@ -5,7 +5,7 @@
* 碌碌无为枉半生,一朝惊醒万事空。 * 碌碌无为枉半生,一朝惊醒万事空。
*/ */
.tab-bar { .tab-bar {
position: fixed; position: fixed;
bottom: 0; bottom: 0;
left: 0; left: 0;
@@ -34,11 +34,11 @@
flex-direction: column; flex-direction: column;
} }
.tab-bar-item cover-image { .tab-bar-item-icon{
width: 24px; width: 24px;
height: 24px; height: 24px;
} }
.tab-bar-item cover-view { .tab-bar-text{
font-size: 10px; font-size: 10px;
} }

View File

@@ -1,52 +0,0 @@
/**
* Web唐明明
* 匆匆数载恍如梦,岁月迢迢华发增。
* 碌碌无为枉半生,一朝惊醒万事空。
*/
import { tabBar } from "../lib/storeConfig"
Component({
/**
* 组件的初始数据
*/
data: {
selected : 0,
color : "#4e4f51",
selectedColor: "#0b0041",
list : []
},
/**
* 生命周期函数
*/
attached(){
if(this.data.list.length <= 0 && tabBar.length > 0){
this.setData({
list: tabBar
})
}else{
wx.showToast({
title: "获取店铺模块信息失败",
icon : "none"
})
}
},
/**
* 组件的方法列表
*/
methods: {
switchTab(e) {
const data = e.currentTarget.dataset
const url = data.path
wx.switchTab({
url
})
this.setData({
selected: data.index
})
}
}
})

View File

@@ -1,3 +0,0 @@
{
"component": true
}

View File

@@ -67,14 +67,17 @@ Page({
// 存储浏览记录 // 存储浏览记录
wx.setStorageSync('companyRecord', record) wx.setStorageSync('companyRecord', record)
// 存储点击的企业id
wx.setStorageSync('compayId', company.company_id)
// 存储店铺ID // 存储店铺ID
wx.setStorage({ wx.setStorage({
data : company.store_id, data : company.store_id,
key : "storeId", key : "storeId",
success : res=>{ success : res=>{
if(res.errMsg == "setStorage:ok"){ if(res.errMsg == "setStorage:ok"){
wx.navigateTo({ wx.reLaunch({
url: "/pages/shortVideo/index", url: "/pages/config/config",
}) })
} }
} }

View File

@@ -18,30 +18,44 @@ Page({
}) })
return return
} }
wx.getStorage({
key : 'compayId',
success : res=>{
wx.$api.publics.storeConfig({ wx.$api.publics.storeConfig({
company_id: e.companyoid company_id: res.data
}).then(res => { }).then(res => {
let tabBarVal = res.concat({}) let tabBarVal = res.concat({})
tabBarVal.forEach(res => { tabBarVal.forEach(res => {
switch (res.slug) { switch (res.slug) {
case "video": case "video":
tabBar.push(video) tabBar.push(video)
break; break;
case "mall": case "mall":
tabBar.push(mall) tabBar.push(mall)
break; break;
case "ticket": case "ticket":
tabBar.push(ticket) tabBar.push(ticket)
break; break;
default : default :
tabBar.push(user) tabBar.push(user)
break; break;
} }
}) })
wx.switchTab({
url: tabBar[0].pagePath if(tabBarVal.length == tabBar.length){
}) wx.reLaunch({
url: tabBar[0].pagePath,
})
}
})
}
}) })
},
/**
* 生命周期函数
*/
onShow(){
wx.hideHomeButton()
} }
}) })

View File

@@ -28,6 +28,13 @@ Page({
this.pushInfo(); this.pushInfo();
}, },
/**
* 生命周期函数
*/
onShow(){
wx.hideHomeButton()
},
/** /**
* 商城首页数据 * 商城首页数据
*/ */

View File

@@ -39,3 +39,5 @@
</block> </block>
</view> </view>
</view> </view>
<storeTabBar pages-url="pages/mall/index"></storeTabBar>

View File

@@ -10,10 +10,10 @@ Page({
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
videoList: [], //获取短视频列表 videoList : [], //获取短视频列表
videoIndex: 0, //当前播放视频的下标 videoIndex : 0, //当前播放视频的下标
videoId: "", //当前播放的视频id videoId : "", //当前播放的视频id
playState: true, //视频播放状态 playState : true, //视频播放状态
}, },
/** /**

View File

@@ -1,15 +1,13 @@
<view>短视频</view>
<view>短视频</view>
<view>短视频</view>
<view>短视频</view>
<view>短视频</view>
<view>短视频</view>
<view>短视频</view>
<view>短视频</view>
<navigator url="plugin-private://wx2b03c6e691cd7370/pages/live-player-plugin?room_id=4">进入直播间</navigator> <navigator url="plugin-private://wx2b03c6e691cd7370/pages/live-player-plugin?room_id=4">进入直播间</navigator>
<view class="videos-content">
<view style="margin-top: 10vh">
<view bindtap="onId">改变全局id</view>
</view>
<view class="videos-content" wx:if="{{1 == 2}}">
<swiperViode <swiperViode
wx:if="{{videoList.length > 0}}" wx:if="{{videoList.length > 0}}"
class="swiper-viode" class="swiper-viode"
@@ -52,3 +50,5 @@
</view> </view>
</view> </view>
</view> </view>
<storeTabBar pages-url="pages/shortVideo/index"></storeTabBar>

View File

@@ -111,3 +111,5 @@
</view> </view>
</view> </view>
</view> </view>
<storeTabBar pages-url="pages/user/index"></storeTabBar>

View File

@@ -25,7 +25,7 @@ Page({
key : "storeId", key : "storeId",
success : ()=>{ success : ()=>{
wx.reLaunch({ wx.reLaunch({
url: "/pages/shortVideo/index", url: "/pages/config/config",
}) })
}, },
fail : ()=>{ fail : ()=>{

View File

@@ -86,9 +86,9 @@
"scene": null "scene": null
}, },
{ {
"name": "读取企业配置", "name": "分享进入",
"pathName": "pages/config/config", "pathName": "pages/config/config",
"query": "companyoid=17", "query": "",
"scene": null "scene": null
} }
] ]