Commit 4e0093ac by 高淑倩

tab

parent 8c08fb5f
...@@ -9,6 +9,10 @@ Component({ ...@@ -9,6 +9,10 @@ Component({
* 组件的属性列表 * 组件的属性列表
*/ */
properties: { properties: {
currentHasUserInfo:{
type: Boolean,
type: false
},
tabBar:{ tabBar:{
type: Object, type: Object,
value: null value: null
...@@ -18,9 +22,6 @@ Component({ ...@@ -18,9 +22,6 @@ Component({
value: '' value: ''
} }
}, },
attached () {
},
ready() { ready() {
this.setData({ this.setData({
currentRoute: `/${utils.getCurrentPageUrl()}` currentRoute: `/${utils.getCurrentPageUrl()}`
...@@ -38,30 +39,70 @@ Component({ ...@@ -38,30 +39,70 @@ Component({
* 组件的方法列表 * 组件的方法列表
*/ */
methods: { methods: {
_getUserInfo(res = {}) {
const userInfo = res.detail || {}
console.log('userInfo',userInfo)
// 先授权再领卡
if (res.detail.userInfo) {
utils.getUserInfoByBtn(userInfo).then( (data = {} ) => {
const {token} = data
wx.setStorageSync('_accreditUserInfo', userInfo)
wx.hideNavigationBarLoading()
if (token) {
wx.setStorageSync('token', token)
} else {
wx.setStorageSync('token', '')
}
wx.setStorageSync('_baseUserInfo', data) // 缓存用户信息
this.setUserInfo() // 判断有无开卡
}).catch(err=> {
if (err) {
wx.showToast({
title: `会员系统异常请稍后重试!`,
icon: 'none'
})
}
})
}
},
setUserInfo () {
const userInfo = wx.getStorageSync('_baseUserInfo')
// 新用户去激活领卡
if (userInfo && userInfo.member && !userInfo.member.mobile) {
console.log('去开')
wxService.openCard()
return false
}else {
console.log('已开')
}
// 跳转
const urls = getCurrentPages()
setTimeout(() => {
const item = urls[0].options
if (item.route) {
try {
const options = JSON.parse(item.options)
wxService.router(`/${item.route}`).search(options).replace()
} catch (e) {
wxService.router('/pages/userCenter/userCenter').replace()
}
} else {
wxService.router('/pages/userCenter/userCenter').replace()
}
}, 200)
},
handelToPage(event){ handelToPage(event){
const ev = event.currentTarget.dataset; const ev = event.currentTarget.dataset;
let curItemType = ev.item let curItemType = ev.item
const userInfo = wx.getStorageSync('_baseUserInfo') const userInfo = wx.getStorageSync('_baseUserInfo')
// link row // link row
if (curItemType.link) { if (curItemType.link) {
let currentClickType = app.globalData.commonFunc.getLink(curItemType.link.type, curItemType) let currentClickType = app.globalData.commonFunc.getLink(curItemType.link.type, curItemType)
if (curItemType.link.type == 1) { if (curItemType.link.type == 1) {
// 触发父组件更新页面 外部小程序 // 触发父组件更新页面 外部小程序
this.setData({
isAuthorization: false
})
return false
} else if (!userInfo) {
this.setData({
isAuthorization: true
})
return false
} else if (userInfo && userInfo.member && !userInfo.member.mobile) {
wxService.openCard()
return false
}
if (curItemType.link.type == 2) { } else if (curItemType.link.type == 2) {
// 触发父组件更新页面 // 触发父组件更新页面
wxService.nextTick(() => { wxService.nextTick(() => {
this.triggerEvent('updatePage', { pageId: currentClickType.url }) this.triggerEvent('updatePage', { pageId: currentClickType.url })
......
<!--component/bottomTabs/bottomTabs.wxml--> <!--component/bottomTabs/bottomTabs.wxml-->
{{currentHasUserInfo}}
<view class='bgc fixed-bottom0' style="background-color:#FFF;background-image:url({{tabBar.num == 4 ? '': '/assets/imgs/7_1_0/bg.png'}});{{tabBar.num == 4 ? 'height: 108rpx':'height: 144rpx'}}" wx:if="{{tabBar.num == 4}}"> <view class='bgc fixed-bottom0' style="background-color:#FFF;background-image:url({{tabBar.num == 4 ? '': '/assets/imgs/7_1_0/bg.png'}});{{tabBar.num == 4 ? 'height: 108rpx':'height: 144rpx'}}" wx:if="{{tabBar.num == 4}}">
<block wx:for="{{tabBar.images}}" wx:key="{{index}}" wx:for-item="tab"> <block wx:for="{{tabBar.images}}" wx:key="{{index}}" wx:for-item="tab">
<view <view class="tab" data-item="{{tab}}" bindtap="handelToPage">
class="tab" <!-- <view wx:if="{{tab.desc == '个人中心'}}">
data-item="{{tab}}" <view wx:if="{{!currentHasUserInfo}}">
bindtap="handelToPage" <button
bindgetuserinfo="_getUserInfo"
data-jflag="false"
open-type='getUserInfo'
class='btn btn-primary'
hover-class="btn-hover"
> >
<image class='tab-img' wx:if="{{currHomePageId == tab.redirectId}}" src='{{tab.activeImageUrl}}' /> <image class='tab-img' src='{{currHomePageId == tab.redirectId ? "{{tab.activeImageUrl}}": "{{tab.imageUrl}}"}}' />
<image class='tab-img' wx:else src='{{tab.imageUrl}}' /> </button>
</view>
<view wx:else>3</view>
</view>
<view wx:else>
22
</view>-->
<button wx:if="{{currHomePageId == tab.redirectId}}">
<image class='tab-img' src='{{tab.activeImageUrl}}' />
</button>
<button wx:else>
<image class='tab-img' src='{{tab.imageUrl}}' />
</button>
</view> </view>
</block> </block>
</view> </view>
<view class="bottom-tab fixed-bottom0" style="height: 108rpx;" wx:if="{{tabBar.num == 5}}"> <view class="bottom-tab fixed-bottom0" style="height: 108rpx;" wx:if="{{tabBar.num == 5}}">
<block wx:for="{{tabs}}" wx:key="{{index}}" wx:for-item="tab"> <block wx:for="{{tabs}}" wx:key="{{index}}" wx:for-item="tab">
<view class="tab" data-item="{{tab}}" bindtap="handelToPage"> <view class="tab" data-item="{{tab}}" bindtap="handelToPage">
<image class='tab-img' wx:if="{{currHomePageId == tab.redirectId}}" src='{{tab.activeImageUrl}}' /> <button wx:if="{{currHomePageId == tab.redirectId}}">
<image class='tab-img' wx:else src='{{tab.imageUrl}}' /> <image class='tab-img' src='{{tab.activeImageUrl}}' />
</button>
<button wx:else>
<image class='tab-img' src='{{tab.imageUrl}}' />
</button>
</view> </view>
</block> </block>
</view> </view>
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<bottom bottom="{{pItem.bottom}}" /> <bottom bottom="{{pItem.bottom}}" />
</view> </view>
<view class="" wx:if="{{pItem.type == 5}}"> <view class="" wx:if="{{pItem.type == 5}}">
<bottom-tabs tab-bar="{{pItem.tabBar}}" bind:updatePage="updatePage"/> <bottom-tabs currHomePageId="{{currHomePageId}}" currentHasUserInfo="{{currentHasUserInfo}}" tab-bar="{{pItem.tabBar}}" bind:updatePage="updatePage"/>
</view> </view>
<view class="" wx:if="{{pItem.type == 6}}"> <view class="" wx:if="{{pItem.type == 6}}">
<announcement notice="{{pItem.notice}}" /> <announcement notice="{{pItem.notice}}" />
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<bottom bottom="{{pItem.bottom}}" /> <bottom bottom="{{pItem.bottom}}" />
</view> </view>
<view class="" wx:if="{{pItem.type == 5}}"> <view class="" wx:if="{{pItem.type == 5}}">
<bottom-tabs tab-bar="{{pItem.tabBar}}" /> <bottom-tabs currHomePageId="{{currHomePageId}}" currentHasUserInfo="{{currentHasUserInfo}}" tab-bar="{{pItem.tabBar}}" bind:updatePage="updatePage"/>
</view> </view>
<view class="" wx:if="{{pItem.type == 6}}"> <view class="" wx:if="{{pItem.type == 6}}">
<announcement notice="{{pItem.notice}}" /> <announcement notice="{{pItem.notice}}" />
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
<attention focus-wx="{{pItem.focusWx}}" /> <attention focus-wx="{{pItem.focusWx}}" />
</view> </view>
<view class="" wx:if="{{pItem.type == 9}}"> <view class="" wx:if="{{pItem.type == 9}}">
<plus sku-list="{{pItem.plus}}" /> <plus sku-list="{{pItem.plus}}" plus-bgi="{{pItem.plus}}" currentHasUserInfo="{{currentHasUserInfo}}"/>
</view> </view>
</block> </block>
<!--goHome--> <!--goHome-->
......
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