Commit 79c1bc55 by 程默

底部栏逻辑重构

parent dcabe71f
...@@ -14,10 +14,10 @@ ...@@ -14,10 +14,10 @@
<script> <script>
import { import {
getUrlofLink, getUrlofLink,
getUrlofQuery,
noLoginListPath,
checkTabbarPage, checkTabbarPage,
} from "../utils/mayi.js"; } from "../utils/mayi.js";
import { serialize} from "@/utils/index";
export default { export default {
props: { props: {
index: { index: {
...@@ -48,8 +48,6 @@ export default { ...@@ -48,8 +48,6 @@ export default {
}, },
}, },
onLoad(options) { onLoad(options) {
console.log('onload')
let ss = wx.getStorageSync("sessionid"); let ss = wx.getStorageSync("sessionid");
this.ss = ss ? `&sessionid=${ss}` : ""; this.ss = ss ? `&sessionid=${ss}` : "";
if (!ss) { if (!ss) {
...@@ -62,19 +60,10 @@ export default { ...@@ -62,19 +60,10 @@ export default {
this.page = getUrlofLink( this.page = getUrlofLink(
this.mpApp.globalData.footerVal.componentData.list[this.index].link this.mpApp.globalData.footerVal.componentData.list[this.index].link
); );
// this.params+='&'+getUrlofQuery( this.mpApp.globalData.footerVal.componentData.list[this.index].link) let query=serialize(options)
this.params+=query?'&'+query:''
} }
}, },
onShow() {
console.log('onshow')
// 登录态更新
// let ss = wx.getStorageSync("sessionid");
// if (!this.ss && ss) {
// this.ss = `&sessionid=${ss}`;
// } else if (!ss) {
// this.params += this.params.includes("logOut") ? "" : "&logOut=true";
// }
},
methods: { methods: {
handleError(data) { handleError(data) {
wx.showLoading({ wx.showLoading({
......
...@@ -104,8 +104,8 @@ ...@@ -104,8 +104,8 @@
<div v-if="applySucessEntry"> <div v-if="applySucessEntry">
<apply-sucess-entry></apply-sucess-entry> <apply-sucess-entry></apply-sucess-entry>
</div> </div>
<!-- 底部栏 -->
<custom-tab-bar></custom-tab-bar> <custom-tab-bar class="custom-tab-bar" :selected="active"></custom-tab-bar>
</div> </div>
</template> </template>
...@@ -145,6 +145,7 @@ export default { ...@@ -145,6 +145,7 @@ export default {
showHomepage: false,//分销商首页入口 showHomepage: false,//分销商首页入口
applySucessEntry: false,//成为分销弹框 applySucessEntry: false,//成为分销弹框
getDistributorHomepageName: '',//小店入口名称 getDistributorHomepageName: '',//小店入口名称
active:-1
}; };
}, },
components:{ components:{
...@@ -163,11 +164,9 @@ export default { ...@@ -163,11 +164,9 @@ export default {
spellGroup spellGroup
}, },
onShareAppMessage(res) { onShareAppMessage(res) {
let shareVal={};
let {shopCode} = app.globalData.shopInfo; let {shopCode} = app.globalData.shopInfo;
if (res.from === "button") { if (res.from === "button") {
console.log(res.target,'-----------78');
return new Promise((resolve,reject)=>{ return new Promise((resolve,reject)=>{
shop.getShopInfo({ shopMixId: shopCode }).then(res=>{ shop.getShopInfo({ shopMixId: shopCode }).then(res=>{
if(res.data.code ==200){ if(res.data.code ==200){
...@@ -285,13 +284,7 @@ export default { ...@@ -285,13 +284,7 @@ export default {
}, },
onShow() { onShow() {
// let linkVal = '/personalCenter/spokesmanCenter/mine/spokesmanHomePage?from=_goodsInfo'
// app.$themeToLink({
// type: 1,
// link:linkVal,
// });
this.getCartNum(); this.getCartNum();
setTabBarActive.bind(this)(checkTabbarPage('/'));
this.$mp.page.onPageScroll= (el)=>{ this.$mp.page.onPageScroll= (el)=>{
throttle(this.scrolls(el),100) throttle(this.scrolls(el),100)
}; };
...@@ -299,8 +292,8 @@ export default { ...@@ -299,8 +292,8 @@ export default {
methods: { methods: {
init(pageList) { init(pageList) {
this.getCartNum() this.getCartNum();
setTabBarActive.bind(this)(checkTabbarPage('/')); this.active=checkTabbarPage('/');
this.pageInfo = pageList.filter((item) => item.pageCode == 1)[0]; this.pageInfo = pageList.filter((item) => item.pageCode == 1)[0];
this.pageData = JSON.parse(this.pageInfo.pageData); this.pageData = JSON.parse(this.pageInfo.pageData);
...@@ -344,7 +337,7 @@ export default { ...@@ -344,7 +337,7 @@ export default {
}) })
}, },
scrolls(el){ scrolls(el){
// this.setFooterShow(el); this.setFooterShow(el);
if (this.pageData) { if (this.pageData) {
for (let i = 0; i < this.pageData.length; i++) { for (let i = 0; i < this.pageData.length; i++) {
const element = this.pageData[i] const element = this.pageData[i]
...@@ -363,9 +356,7 @@ export default { ...@@ -363,9 +356,7 @@ export default {
} }
} }
// this.setFooterShow(el);
if(this.$mp.page && this.$mp.page.selectComponent(".getIndexHomePage")){ if(this.$mp.page && this.$mp.page.selectComponent(".getIndexHomePage")){
this.$mp.page.selectComponent(".getIndexHomePage").getScroll(el); this.$mp.page.selectComponent(".getIndexHomePage").getScroll(el);
} }
...@@ -377,7 +368,7 @@ export default { ...@@ -377,7 +368,7 @@ export default {
// return // return
let afterScrollTop = el.scrollTop; let afterScrollTop = el.scrollTop;
let delta = afterScrollTop - this.beforeScrollTop; let delta = afterScrollTop - this.beforeScrollTop;
let {showFlag} = this.$mp.page.getTabBar().data; let {showFlag} = this.$mp.page.selectComponent(".custom-tab-bar").data;
if( if(
delta === 0 || delta === 0 ||
afterScrollTop < 0 || afterScrollTop < 0 ||
...@@ -388,9 +379,8 @@ export default { ...@@ -388,9 +379,8 @@ export default {
this.beforeScrollTop = afterScrollTop; this.beforeScrollTop = afterScrollTop;
return; return;
} }
// this.$mp.page.getTabBar().animation({'showFlag':delta>0?'down':'up'}) this.$mp.page.selectComponent(".custom-tab-bar").setData({'showFlag':delta>0?'down':'up'})
// console.log(showFlag,'set296' ) console.log('---------383')
this.$mp.page.getTabBar().setData({'showFlag':delta>0?'down':'up'})
}, },
scrolltolower(){ scrolltolower(){
console.log("scrolltolower") console.log("scrolltolower")
...@@ -398,7 +388,7 @@ export default { ...@@ -398,7 +388,7 @@ export default {
getCartNum() { getCartNum() {
app.cartApi.my_cart_count().then(res => { app.cartApi.my_cart_count().then(res => {
if (res.data.code == 200) { if (res.data.code == 200) {
this.$mp.page.getTabBar().setData({"cartNum": Number(res.data.data)}); this.$mp.page.selectComponent(".custom-tab-bar").setData({"cartNum": Number(res.data.data)});
} }
}); });
} }
......
...@@ -10,7 +10,7 @@ export const noLoginListPath = noLoginList.map(item => { ...@@ -10,7 +10,7 @@ export const noLoginListPath = noLoginList.map(item => {
return item return item
}) })
// 有底部栏页面 // 有底部栏页面
export const containFooterPage=["/","/goods/commodityMenu","/shopCart/shoppingCart","/personalCenter"] export const containFooterPage = ["/", "/goods/commodityMenu", "/shopCart/shoppingCart", "/personalCenter"]
// 主题色 // 主题色
export let themeColor = { export let themeColor = {
"--main-color": "#ffffff", "--main-color": "#ffffff",
...@@ -28,14 +28,14 @@ export function getUrlofQuery(data) { ...@@ -28,14 +28,14 @@ export function getUrlofQuery(data) {
export function $themeToLink(data, option) { export function $themeToLink(data, option) {
let app = getApp(); let app = getApp();
let type = data.type; let type = data.type;
console.log('299999',data,noLoginListPath)
// 登录拦截和底部导航栏拦截(非功能项) // 登录拦截和底部导航栏拦截(非功能项)
if (type != 2) { if (type != 2) {
// 登录拦截 // 登录拦截
let parseLink = getUrlofLink(data); let parseLink = getUrlofLink(data);
let aa = noLoginListPath.includes(parseLink) || parseLink.substr(0, 7) == "/goods/" || parseLink.includes('/brandTopics'); let parseQuery = getUrlofQuery(data);
console.log(noLoginListPath.includes(parseLink),'3535',aa)
if (!aa && !wx.getStorageSync("sessionid")) { let noLogin = noLoginListPath.includes(parseLink) || parseLink.substr(0, 7) == "/goods/" || parseLink.includes('/brandTopics');
if (!noLogin && !wx.getStorageSync("sessionid")) {
let url = `/pages/login/main?back=${parseLink}`; let url = `/pages/login/main?back=${parseLink}`;
wx.navigateTo({ url }); wx.navigateTo({ url });
return return
...@@ -44,14 +44,14 @@ export function $themeToLink(data, option) { ...@@ -44,14 +44,14 @@ export function $themeToLink(data, option) {
let isTabbarIndex = checkTabbarPage(parseLink); let isTabbarIndex = checkTabbarPage(parseLink);
if (isTabbarIndex >= 0) { if (isTabbarIndex >= 0) {
// 无底部栏h5页面 // 无底部栏h5页面
if(!containFooterPage.includes(parseLink)){ if (!containFooterPage.includes(parseLink)) {
toPage(getUrlofLink(data),getUrlofQuery(data)) toPage(getUrlofLink(data), getUrlofQuery(data))
return return
} }
isTabbarIndex = isTabbarIndex == 0 ? checkTabbarPage('/') : isTabbarIndex isTabbarIndex = isTabbarIndex == 0 ? checkTabbarPage('/') : isTabbarIndex
let query=parseQuery?`?${parseQuery}`:''
wx.reLaunch({ wx.reLaunch({
url: parseLink == '/' ? '/pages/home/main' : `/pages/tabBar${isTabbarIndex}/main`, url: parseLink == '/' ? `/pages/home/main${query}` : `/pages/tabBar${isTabbarIndex}/main${query}`,
}) })
return return
} }
...@@ -61,7 +61,7 @@ export function $themeToLink(data, option) { ...@@ -61,7 +61,7 @@ export function $themeToLink(data, option) {
// 历史数据 // 历史数据
if (type == undefined || type == 'undefined') { if (type == undefined || type == 'undefined') {
if (data.length > 0) { if (data.length > 0) {
toPage(getUrlofLink(data),getUrlofQuery(data)) toPage(getUrlofLink(data), getUrlofQuery(data))
} }
return return
} }
...@@ -71,7 +71,7 @@ export function $themeToLink(data, option) { ...@@ -71,7 +71,7 @@ export function $themeToLink(data, option) {
} else if (type == 1) {//h5页面 } else if (type == 1) {//h5页面
//兼容 //兼容
if (data.link.substring(0, 1) == "/") { if (data.link.substring(0, 1) == "/") {
toPage(getUrlofLink(data),getUrlofQuery(data)) toPage(getUrlofLink(data), getUrlofQuery(data))
} else { } else {
if (data.link.startsWith('http') || data.link.startsWith('https')) { if (data.link.startsWith('http') || data.link.startsWith('https')) {
wx.navigateTo({ url: '/pages/wxArticle/main?link=' + encodeURIComponent(data.link) }); wx.navigateTo({ url: '/pages/wxArticle/main?link=' + encodeURIComponent(data.link) });
...@@ -87,7 +87,7 @@ export function $themeToLink(data, option) { ...@@ -87,7 +87,7 @@ export function $themeToLink(data, option) {
return return
} }
if (data.link.substring(0, 1) == "/") { if (data.link.substring(0, 1) == "/") {
toPage(getUrlofLink(data),getUrlofQuery(data)) toPage(getUrlofLink(data), getUrlofQuery(data))
} else { } else {
wx.navigateTo({ url: '/pages/wxArticle/main?link=' + encodeURIComponent(data.link) }); wx.navigateTo({ url: '/pages/wxArticle/main?link=' + encodeURIComponent(data.link) });
} }
...@@ -108,7 +108,7 @@ export function $themeToLink(data, option) { ...@@ -108,7 +108,7 @@ export function $themeToLink(data, option) {
} else { } else {
//向后兼容 //向后兼容
if (data.length > 0) { if (data.length > 0) {
toPage(getUrlofLink(data),getUrlofQuery(data)) toPage(getUrlofLink(data), getUrlofQuery(data))
} }
} }
} }
......
const app = getApp(); const app = getApp();
Component({ Component({
properties:{
selected:{
type:Number,
default:-1
}
},
data: { data: {
selected: 0,
color: "#7A7E83", color: "#7A7E83",
selectedColor: "#3cc51f", selectedColor: "#3cc51f",
list: [ list: [
{
pagePath: "/pages/home/main",
iconPath:
"https://cdn.mayi888.com/public/png/2d084453-2ca3-4d01-95f9-8bed8fc46dc6.png",
selectedIconPath:
"https://cdn.mayi888.com/public/png/2d084453-2ca3-4d01-95f9-8bed8fc46dc6.png",
text: "组件",
//--多主题
condition: "",
icon: "ant-daishouhuo",
iconType: 1, //0 iconfont 1 image
imgUrl:
"https://cdn.mayi888.com/public/png/2d084453-2ca3-4d01-95f9-8bed8fc46dc6.png",
selectImgUrl:
"https://cdn.mayi888.com/public/png/2d084453-2ca3-4d01-95f9-8bed8fc46dc6.png",
link: {
key: "1.1.1.7",
link: "/personalCenter/spokesmanCenter?distributionModel=1",
name: "分销商中心",
type: 1
},
show: true,
title: "分类页",
version: "1.0.0",
visible: 1
},
{
pagePath: "/pages/index/main",
iconPath: "/static/images/bofang.png",
selectedIconPath: "/static/images/bofang.png",
text: "接口",
//--多主题
condition: "",
icon: "ant-daishouhuo",
iconType: 0, //0 iconfont 1 image
imgUrl: "",
selectImgUrl: "",
link: {},
show: true,
title: "分类页",
version: "1.0.0",
visible: 1
}
], ],
mm: false, mm: false,
componentData: {}, componentData: {},
...@@ -73,7 +33,8 @@ Component({ ...@@ -73,7 +33,8 @@ Component({
}; };
} }
this.setData({ this.setData({
mmm: Math.ceil(app.globalData.footerVal.componentData.list.length / 2 - 1) mmm: Math.ceil(app.globalData.footerVal.componentData.list.length / 2 - 1),
selected:this.data.active
}); });
}, },
attached() { attached() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment