Commit 01957995 by 高淑倩

轮播图授权

parent ddc0b8c2
......@@ -48,15 +48,13 @@ Component({
newRow.newPath = '/pages/productDetail/productDetail'
} else if (newRow.type == 9) {
newRow.newPath = '/subPackage/page/pages/categoryPro/categoryPro'
} else {
newRow.newPath = ''
}
}
item.row = newRow
}
})
// 当前匹配路径是否需要授权 true 需要 false 不需要
tabBar.images.forEach(item => {
currentTab.forEach(item => {
let checkUrl = ''
if (item.link) {
checkUrl = item.link.newPath ? item.link.newPath : item.link.url
......@@ -64,8 +62,8 @@ Component({
checkUrl = item.row.newPath ? item.row.newPath : item.row.url
}
wxService.NoLoginPage(checkUrl).then(res => {
item.needAuth = res.needAuth
this.setData({ tabBarList: tabBar.images })
if(checkUrl) item.needAuth = res.needAuth
this.setData({ tabBarList: currentTab })
})
})
},
......
......@@ -11,6 +11,10 @@ Component({
* 组件的属性列表
*/
properties: {
currentHasUserInfo: {
type: Boolean,
type: false
},
imageData: {
type: Array,
value: [],
......@@ -20,6 +24,47 @@ Component({
this.setData({
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({
padding: 0,
heights: [],
imageHeights: {}, // 记录所有图片的实际高度
imageList: []
},
observers: {
heights: function (heights) {
......@@ -59,6 +105,9 @@ Component({
* 组件的方法列表
*/
methods: {
_getUserInfo(res = {}) {
this.triggerEvent('getAuth', res);
},
imageLoad: function (e) {
// 图片加载完成回调
let heights = this.data.heights
......
<!--component/imageSwiper/imageSwiper.wxml-->
<wxs src="../../wxs/utils.wxs" module="utils" />
<swiper
class="image-swiper"
indicator-dots="{{indicatorDots}}"
......@@ -9,17 +10,54 @@
duration="{{duration}}"
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">
<view
wx:if="{{baseImgUrl}}"
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 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
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>
<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>
</swiper-item>
</block>
......
......@@ -47,8 +47,6 @@ Component({
newRow.newPath = '/pages/productDetail/productDetail'
} else if (newRow.type == 9) {
newRow.newPath = '/subPackage/page/pages/categoryPro/categoryPro'
} else {
newRow.newPath = ''
}
item.row = newRow
}
......@@ -63,7 +61,7 @@ Component({
checkUrl = item.row.newPath ? item.row.newPath : item.row.url
}
wxService.NoLoginPage(checkUrl).then(res=>{
item.needAuth = res.needAuth
if(checkUrl) item.needAuth = res.needAuth
this.setData({ newPicNav: picNav })
})
})
......
......@@ -3,7 +3,7 @@
<!-- 1 轮播 2 个人中心 3 图片导航 4 底部左划 5 底部 Tab 6 公告 7 分类 8 关注公众号 9 plus(9/5-权重高)-->
<block wx:for="{{pages}}" wx:key="{{index}}" wx:for-item="pItem">
<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 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}}"/>
......
......@@ -3,7 +3,7 @@
<!-- 1 轮播 2 个人中心 3 图片导航 4 底部左划 5 底部 Tab 6 公告 7 分类 8 关注公众号 9 plus(9/5-权重高)-->
<block wx:for="{{pages}}" wx:key="{{index}}" wx:for-item="pItem">
<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 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}}"/>
......@@ -21,13 +21,13 @@
<announcement notice="{{pItem.notice}}"/>
</view>
<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 class="" wx:if="{{pItem.type == 8}}">
<attention focus-wx="{{pItem.focusWx}}" />
</view>
<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>
</block>
</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