Commit 01957995 by 高淑倩

轮播图授权

parent ddc0b8c2
...@@ -48,15 +48,13 @@ Component({ ...@@ -48,15 +48,13 @@ Component({
newRow.newPath = '/pages/productDetail/productDetail' newRow.newPath = '/pages/productDetail/productDetail'
} else if (newRow.type == 9) { } else if (newRow.type == 9) {
newRow.newPath = '/subPackage/page/pages/categoryPro/categoryPro' newRow.newPath = '/subPackage/page/pages/categoryPro/categoryPro'
} else {
newRow.newPath = ''
} }
item.row = newRow item.row = newRow
} }
}) })
// 当前匹配路径是否需要授权 true 需要 false 不需要 // 当前匹配路径是否需要授权 true 需要 false 不需要
tabBar.images.forEach(item => { currentTab.forEach(item => {
let checkUrl = '' let checkUrl = ''
if (item.link) { if (item.link) {
checkUrl = item.link.newPath ? item.link.newPath : item.link.url checkUrl = item.link.newPath ? item.link.newPath : item.link.url
...@@ -64,8 +62,8 @@ Component({ ...@@ -64,8 +62,8 @@ Component({
checkUrl = item.row.newPath ? item.row.newPath : item.row.url checkUrl = item.row.newPath ? item.row.newPath : item.row.url
} }
wxService.NoLoginPage(checkUrl).then(res => { wxService.NoLoginPage(checkUrl).then(res => {
item.needAuth = res.needAuth if(checkUrl) item.needAuth = res.needAuth
this.setData({ tabBarList: tabBar.images }) this.setData({ tabBarList: currentTab })
}) })
}) })
}, },
......
...@@ -11,6 +11,10 @@ Component({ ...@@ -11,6 +11,10 @@ Component({
* 组件的属性列表 * 组件的属性列表
*/ */
properties: { properties: {
currentHasUserInfo: {
type: Boolean,
type: false
},
imageData: { imageData: {
type: Array, type: Array,
value: [], value: [],
...@@ -20,6 +24,47 @@ Component({ ...@@ -20,6 +24,47 @@ Component({
this.setData({ this.setData({
baseImgUrl: app.globalData.imageUrl baseImgUrl: app.globalData.imageUrl
}) })
const { imageData } = this.data
console.log('imageData', imageData)
let currentTab = imageData
currentTab.forEach(item => {
// 存在 row 处理数据 8 商品 9 分类
let newRow = null
if (item.link) {
if (item.link.type == 2) {
// 父组件 更新
const urls = getCurrentPages()
const currentPath = urls[0]
const pageId = item.link.url
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'
}
item.row = newRow
}
})
// 当前匹配路径是否需要授权 true 需要 false 不需要
currentTab.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 => {
if(checkUrl) item.needAuth = res.needAuth
this.setData({ imageList: currentTab })
})
})
}, },
/** /**
* 组件的初始数据 * 组件的初始数据
...@@ -36,6 +81,7 @@ Component({ ...@@ -36,6 +81,7 @@ Component({
padding: 0, padding: 0,
heights: [], heights: [],
imageHeights: {}, // 记录所有图片的实际高度 imageHeights: {}, // 记录所有图片的实际高度
imageList: []
}, },
observers: { observers: {
heights: function (heights) { heights: function (heights) {
...@@ -59,6 +105,9 @@ Component({ ...@@ -59,6 +105,9 @@ Component({
* 组件的方法列表 * 组件的方法列表
*/ */
methods: { methods: {
_getUserInfo(res = {}) {
this.triggerEvent('getAuth', res);
},
imageLoad: function (e) { imageLoad: function (e) {
// 图片加载完成回调 // 图片加载完成回调
let heights = this.data.heights let heights = this.data.heights
......
<!--component/imageSwiper/imageSwiper.wxml--> <!--component/imageSwiper/imageSwiper.wxml-->
<wxs src="../../wxs/utils.wxs" module="utils" /> <wxs src="../../wxs/utils.wxs" module="utils" />
<swiper <swiper
class="image-swiper" class="image-swiper"
indicator-dots="{{indicatorDots}}" indicator-dots="{{indicatorDots}}"
...@@ -9,17 +10,54 @@ ...@@ -9,17 +10,54 @@
duration="{{duration}}" duration="{{duration}}"
style="height: {{maxHeight}}px;" style="height: {{maxHeight}}px;"
> >
<block wx:for="{{imageData}}" wx:key="{{index}}" wx:for-item="item">
<block wx:for="{{imageList}}" wx:key="{{index}}" wx:for-item="item">
<swiper-item class="swiper-item"> <swiper-item class="swiper-item">
<view wx:if="{{item.needAuth}}">
<view wx:if="{{!currentHasUserInfo}}">
<image
bindload="imageLoad"
src="{{utils.formateUrl(item.imageUrl,baseImgUrl)}}"
id="swiperImg{{index}}"
mode="widthFix"
class="slide-image"
/>
</view>
<view wx:else>
<view <view
wx:if="{{baseImgUrl}}"
data-appid="{{item.link.appid}}" data-appid="{{item.link.appid}}"
data-path="{{item.link.url}}" data-path="{{item.link.url}}"
data-link="{{item.link}}" data-link="{{item.link}}"
data-item="{{item}}" data-item="{{item}}"
bindtap='preview' bindtap='preview'
> >
<image bindload="imageLoad" src="{{utils.formateUrl(item.imageUrl,baseImgUrl)}}" id="swiperImg{{index}}" mode="widthFix" class="slide-image" /> <image
bindload="imageLoad"
src="{{utils.formateUrl(item.imageUrl,baseImgUrl)}}"
id="swiperImg{{index}}"
mode="widthFix"
class="slide-image"
/>
</view>
</view>
</view>
<view wx:else>
<view
data-appid="{{item.link.appid}}"
data-path="{{item.link.url}}"
data-link="{{item.link}}"
data-item="{{item}}"
bindtap='preview'
>
<image
bindload="imageLoad"
src="{{utils.formateUrl(item.imageUrl,baseImgUrl)}}"
id="swiperImg{{index}}"
mode="widthFix"
class="slide-image"
/>
</view>
</view> </view>
</swiper-item> </swiper-item>
</block> </block>
......
...@@ -47,8 +47,6 @@ Component({ ...@@ -47,8 +47,6 @@ Component({
newRow.newPath = '/pages/productDetail/productDetail' newRow.newPath = '/pages/productDetail/productDetail'
} else if (newRow.type == 9) { } else if (newRow.type == 9) {
newRow.newPath = '/subPackage/page/pages/categoryPro/categoryPro' newRow.newPath = '/subPackage/page/pages/categoryPro/categoryPro'
} else {
newRow.newPath = ''
} }
item.row = newRow item.row = newRow
} }
...@@ -63,7 +61,7 @@ Component({ ...@@ -63,7 +61,7 @@ Component({
checkUrl = item.row.newPath ? item.row.newPath : item.row.url checkUrl = item.row.newPath ? item.row.newPath : item.row.url
} }
wxService.NoLoginPage(checkUrl).then(res=>{ wxService.NoLoginPage(checkUrl).then(res=>{
item.needAuth = res.needAuth if(checkUrl) item.needAuth = res.needAuth
this.setData({ newPicNav: picNav }) this.setData({ newPicNav: picNav })
}) })
}) })
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<!-- 1 轮播 2 个人中心 3 图片导航 4 底部左划 5 底部 Tab 6 公告 7 分类 8 关注公众号 9 plus(9/5-权重高)--> <!-- 1 轮播 2 个人中心 3 图片导航 4 底部左划 5 底部 Tab 6 公告 7 分类 8 关注公众号 9 plus(9/5-权重高)-->
<block wx:for="{{pages}}" wx:key="{{index}}" wx:for-item="pItem"> <block wx:for="{{pages}}" wx:key="{{index}}" wx:for-item="pItem">
<view wx:if="{{pItem.type == 1}}"> <view wx:if="{{pItem.type == 1}}">
<image-swiper image-data="{{pItem.rotationchart.images}}" /> <image-swiper image-data="{{pItem.rotationchart.images}}" bind:getAuth="_getUserInfo" currentHasUserInfo="{{currentHasUserInfo}}"/>
</view> </view>
<view class="" wx:if="{{pItem.type == 2}}"> <view class="" wx:if="{{pItem.type == 2}}">
<person-center bind:getAuth="_getUserInfo" currentHasUserInfo="{{currentHasUserInfo}}" base-user-info="{{baseUserInfo}}" person-data="{{pItem.customer}}" integral-num="{{integralNum}}" coupon-num="{{couponNum}}" token="{{token}}"/> <person-center bind:getAuth="_getUserInfo" currentHasUserInfo="{{currentHasUserInfo}}" base-user-info="{{baseUserInfo}}" person-data="{{pItem.customer}}" integral-num="{{integralNum}}" coupon-num="{{couponNum}}" token="{{token}}"/>
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<!-- 1 轮播 2 个人中心 3 图片导航 4 底部左划 5 底部 Tab 6 公告 7 分类 8 关注公众号 9 plus(9/5-权重高)--> <!-- 1 轮播 2 个人中心 3 图片导航 4 底部左划 5 底部 Tab 6 公告 7 分类 8 关注公众号 9 plus(9/5-权重高)-->
<block wx:for="{{pages}}" wx:key="{{index}}" wx:for-item="pItem"> <block wx:for="{{pages}}" wx:key="{{index}}" wx:for-item="pItem">
<view wx:if="{{pItem.type == 1}}"> <view wx:if="{{pItem.type == 1}}">
<image-swiper image-data="{{pItem.rotationchart.images}}" /> <image-swiper image-data="{{pItem.rotationchart.images}}" bind:getAuth="_getUserInfo" currentHasUserInfo="{{currentHasUserInfo}}"/>
</view> </view>
<view class="" wx:if="{{pItem.type == 2}}"> <view class="" wx:if="{{pItem.type == 2}}">
<person-center bind:getAuth="_getUserInfo" currentHasUserInfo="{{currentHasUserInfo}}" base-user-info="{{baseUserInfo}}" person-data="{{pItem.customer}}" integral-num="{{integralNum}}" coupon-num="{{couponNum}}" token="{{token}}"/> <person-center bind:getAuth="_getUserInfo" currentHasUserInfo="{{currentHasUserInfo}}" base-user-info="{{baseUserInfo}}" person-data="{{pItem.customer}}" integral-num="{{integralNum}}" coupon-num="{{couponNum}}" token="{{token}}"/>
...@@ -21,13 +21,13 @@ ...@@ -21,13 +21,13 @@
<announcement notice="{{pItem.notice}}"/> <announcement notice="{{pItem.notice}}"/>
</view> </view>
<view class="" wx:if="{{pItem.type == 7}}"> <view class="" wx:if="{{pItem.type == 7}}">
<tab-sort category-type="{{pItem.categoryType}}" bind:getAuth="_getUserInfo" currentHasUserInfo="{{currentHasUserInfo}}" /> <tab-sort category-type="{{pItem.categoryType}}" bind:getAuth="_getUserInfo" currentHasUserInfo="{{currentHasUserInfo}}" bind:updatePage="updatePage"/>
</view> </view>
<view class="" wx:if="{{pItem.type == 8}}"> <view class="" wx:if="{{pItem.type == 8}}">
<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="{{skuVOList}}" plus-bgi="{{pItem.plus}}" currentHasUserInfo="{{currentHasUserInfo}}"/> <plus sku-list="{{skuVOList}}" plus-bgi="{{pItem.plus}}" currentHasUserInfo="{{currentHasUserInfo}}" bind:updatePage="updatePage"/>
</view> </view>
</block> </block>
</view> </view>
......
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