Commit 25b4f037 by 高淑倩

tabBar 授权

parent 29bfb064
...@@ -26,40 +26,48 @@ Component({ ...@@ -26,40 +26,48 @@ Component({
this.setData({ this.setData({
baseImgUrl: app.globalData.imageUrl baseImgUrl: app.globalData.imageUrl
}) })
const { tabBar } = this.data const { tabBar } = this.data
let currentTab = tabBar.images let currentTab = tabBar.images
currentTab.forEach(item => { currentTab.forEach(item => {
// 存在 row 处理数据 8 商品 9 分类 // 存在 row 处理数据 8 商品 9 分类
let newRow = null let newRow = null
if (item.link) { if (item.link) {
if(item.link.type == 2){ if(item.link.type == 2){
// 父组件 更新 // 父组件 更新
const urls = getCurrentPages() const urls = getCurrentPages()
const currentPath = urls[0] const currentPath = urls[0]
const pageId = item.link.url const pageId = item.link.url
console.log('currentPath', currentPath.route,item.link.url) item.link.newPath = `/${currentPath.route}`
item.link.newPath = `/${currentPath.route}`
}
return
} else if (item.row) {
newRow = JSON.parse(item.row)
if (newRow.type == 8) {
newRow.newPath = '/pages/productDetail/productDetail'
} else if (newRow.type == 9) {
newRow.newPath = '/subPackage/page/pages/categoryPro/categoryPro'
} else {
newRow.newPath = ''
} }
// item.row = JSON.stringify(newRow) return
item.row = newRow } else if (item.row) {
} newRow = JSON.parse(item.row)
}) if (newRow.type == 8) {
newRow.newPath = '/pages/productDetail/productDetail'
} else if (newRow.type == 9) {
newRow.newPath = '/subPackage/page/pages/categoryPro/categoryPro'
} else {
newRow.newPath = ''
}
item.row = newRow
}
})
this.setData({ tabBar }, () => { // 当前匹配路径是否需要授权 true 需要 false 不需要
tabBar.images.forEach(item => {
}) let checkUrl = ''
}, if(item.link) {
checkUrl = item.link.newPath ? item.link.newPath : item.link.url
} else if(item.row) {
checkUrl = item.row.newPath ? item.row.newPath : item.row.url
}
wxService.NoLoginPage(checkUrl).then(res=>{
item.needAuth = res.needAuth
this.setData({ tabBarList : tabBar.images })
})
})
},
ready() { ready() {
this.setData({ this.setData({
currentRoute: `/${utils.getCurrentPageUrl()}` currentRoute: `/${utils.getCurrentPageUrl()}`
...@@ -70,9 +78,9 @@ Component({ ...@@ -70,9 +78,9 @@ Component({
*/ */
data: { data: {
currentRoute: '', currentRoute: '',
tabs: [],
type: 1, type: 1,
baseImgUrl: '' baseImgUrl: '',
tabBarList:[]
}, },
/** /**
* 组件的方法列表 * 组件的方法列表
......
...@@ -2,11 +2,10 @@ ...@@ -2,11 +2,10 @@
<wxs src="../../wxs/utils.wxs" module="utils" /> <wxs src="../../wxs/utils.wxs" module="utils" />
<!--<wxs src="./handlerData.wxs" module="tools" />--> <!--<wxs src="./handlerData.wxs" module="tools" />-->
<view class='bgc fixed-bottom0' style="background-image:url({{tabBar.num == 4 ? '': '/assets/imgs/7_1_0/bg.png'}});" wx:if="{{tabBar.num == 4}}"> <view class='bgc fixed-bottom0' style="background-image:url({{tabBar.num == 4 ? '': '/assets/imgs/7_1_0/bg.png'}});" wx:if="{{tabBar.num == 4}}">
<block wx:for="{{tabBar.images}}" wx:key="{{index}}" wx:for-item="tab"> <block wx:for="{{tabBarList}}" wx:key="{{index}}" wx:for-item="tab">
<view class="tab"> <view class="tab">
<!--当前页面需要授权 且未授权--> <!--当前页面需要授权 且未授权-->
<!--<view wx:if="{{utils.hanlerLinkNeedAuth(tab.link.url)}}" class="btn-tab">--> <view wx:if="{{tab.needAuth}}" class="btn-tab">
<view wx:if="{{tab.link ? utils.hanlerLinkNeedAuth(typeOf(tab.link.newPath) != undefined ? tab.link.newPath : tab.link.url) : utils.hanlerLinkNeedAuth(tab.row.newPath ? tab.row.newPath : tab.row.url)}}" class="btn-tab">
<view wx:if="{{!currentHasUserInfo}}" class="btn-tab"> <view wx:if="{{!currentHasUserInfo}}" class="btn-tab">
<button <button
bindgetuserinfo="_getUserInfo" bindgetuserinfo="_getUserInfo"
...@@ -44,7 +43,7 @@ ...@@ -44,7 +43,7 @@
</block> </block>
</view> </view>
<view class="bottom-tab fixed-bottom0" wx:if="{{tabBar.num == 5}}"> <view class="bottom-tab fixed-bottom0" wx:if="{{tabBar.num == 5}}">
<block wx:for="{{tabs}}" wx:key="{{index}}" wx:for-item="tab"> <block wx:for="{{tabBarList}}" wx:key="{{index}}" wx:for-item="tab">
<view class="tab" data-item="{{tab}}" bindtap="handelToPage"> <view class="tab" data-item="{{tab}}" bindtap="handelToPage">
<!--当前页面需要授权 且未授权--> <!--当前页面需要授权 且未授权-->
<view wx:if="{{utils.hanlerLinkNeedAuth(tab.link.url)}}" class="btn-tab"> <view wx:if="{{utils.hanlerLinkNeedAuth(tab.link.url)}}" class="btn-tab">
......
...@@ -49,7 +49,6 @@ Component({ ...@@ -49,7 +49,6 @@ Component({
} else { } else {
newRow.newPath = '' newRow.newPath = ''
} }
// item.row = JSON.stringify(newRow)
item.row = newRow item.row = newRow
} }
}) })
......
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