Commit f925711c by 高淑倩

add: 动态子页面

parent 14f7fff3
...@@ -81,7 +81,6 @@ Component({ ...@@ -81,7 +81,6 @@ Component({
} }
// 2019.06.14 // 2019.06.14
let currentClickType = app.globalData.commonFunc.getLink(item.link.type, item) let currentClickType = app.globalData.commonFunc.getLink(item.link.type, item)
if(link.type == 2) { if(link.type == 2) {
// 触发父组件更新页面 // 触发父组件更新页面
wxService.nextTick(() => { wxService.nextTick(() => {
...@@ -96,7 +95,6 @@ Component({ ...@@ -96,7 +95,6 @@ Component({
} else if(link.type == 4) { } else if(link.type == 4) {
wxService.router(`${currentClickType}`) wxService.router(`${currentClickType}`)
} }
} }
} }
}) })
...@@ -54,12 +54,14 @@ wxService.page({ ...@@ -54,12 +54,14 @@ wxService.page({
* */ * */
updatePage(ev) { updatePage(ev) {
const {pageId} = ev.detail const {pageId} = ev.detail
this.setData({ console.log('pageId', pageId)
pages: [], // this.setData({
pageId // pages: [],
},()=>{ // pageId
this.initPage(pageId) // },()=>{
}) // this.initPage(pageId)
// })
wxService.router(`/subPackage/page/pages/subPage/subPage`).search({pageId})
}, },
/** /**
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
......
...@@ -121,7 +121,7 @@ ...@@ -121,7 +121,7 @@
"id": 13, "id": 13,
"name": "subPage", "name": "subPage",
"pathName": "subPackage/page/pages/subPage/subPage", "pathName": "subPackage/page/pages/subPage/subPage",
"query": "" "query": "pageId=4"
} }
] ]
} }
......
// subPackage/page/pages/subPage/subPage.js // subPackage/page/pages/subPage/subPage.js
const app = getApp()
const wxService = require('../../../../utils/wxService') const wxService = require('../../../../utils/wxService')
const utils = require('../../../../utils/util') const utils = require('../../../../utils/util')
const envInfo = require('../../../../config/index').envInfo
let renderPage = null // 渲染页面数据对象(安全渲染)
let handlerDataOnPage = null
let config = require('../../../../configScreen/configScreen');
const logger = utils.logger
wxService.page({ wxService.page({
/** /**
* 页面的初始数据 * 页面的初始数据
*/ */
data: {}, data: {
pages:[],
render: null, // 渲染页面数据对象(安全渲染)
renderPageOver: false, // 渲染页面结束
integralNum: 0,
couponNum: 0,
// isAllScreen: fullSucreen.isAllScreen
isAllScreen: config.isAllScreen,
token:'',
isAuthorization: false,
pageId: 3
},
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad () {}, onLoad () {
this.setData(
{
pages: [],
groupLoadState: 'complete', // 活动分组加载标志
homeApiLoading: true,
render: null, // 渲染页面数据对象(安全渲染)
isLastPage: false, // 页面段落加载完成
renderPageOver: false, // 渲染页面结束
// isAuthorization: true
},
() => {
// this.loadMore()
}
)
handlerDataOnPage = new utils.HandlerDataOnPage()
renderPage = require('../../../../utils/renderPage').getRenderPage()
handlerDataOnPage.init(this, 'pages')
},
/**
* 监听子组件事件
* */
updatePage(ev) {
// const {pageId} = ev.detail
// this.setData({
// pages: [],
// pageId
// },()=>{
// this.initPage(pageId)
// })
},
/** /**
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow () {} onShow () {
console.log('this..sub.', this.options)
const { pageId } = this.options
this.setData({
token: wx.getStorageSync('token'),
pages: [], // 清空当前页
pageId,
},()=>{
let currentPageId = pageId? pageId : this.data.pageId
this.initPage(currentPageId)
})
if (wx.getStorageSync('_baseUserInfo')){
// 积分数量
this.getMemberPointInfo()
// 优惠券数量
this.getMemberCouponInfo()
}
},
// 查询积分信息
getMemberPointInfo(){
wx.showLoading({
title: '加载中'
})
wxService.get(`/member/memberPoint/getMyPointInfo`).then(res => {
if(res) {
const { result, data } = res.data
if (result == 0) {
wx.hideLoading()
this.setData({
integralNum: data && data.point || 0
})
}
}
})
},
// 查询优惠券数量
getMemberCouponInfo(){
wx.showLoading({
title: '加载中'
})
wxService.post(`/coupon/coupon/memberCouponCount`).then(res => {
if(res){
const { result, data } = res && res.data
if (result == 0) {
wx.hideLoading()
this.setData({
couponNum: data && data[1] || 0
})
}
} else {
wx.showToast({
title: '请求失败',
icon: 'none'
})
}
})
},
// page 信息
initPage(pageId){
this.setData({
products: []
})
wx.showLoading({
title: '加载中'
})
wxService.post(`/merchant/modelPage/getDetailById?pageId=${pageId}&brandId=${app.globalData.brandId}`).then(res => {
if(!res) return false
const {result,data} = res.data
if(result == 0){
// 动态设置title
wx.setNavigationBarTitle({
title: data.page.title
})
// 段落
const products = data.paragraphs
const filterResult = products.map((res,index)=>{
return {
...res,index
}
}).filter(item=> {
// wx.hideLoading()
})
const render = renderPage.initPaging(filterResult).initRenderData(products)
this.data.render = render
const renderData = render.next()
this.data.renderPageOver = renderData.done
this.renderPageFunc({ products: renderData.value })
}
}).finally(() => {
wx.hideLoading();
})
},
/**
* 渲染数据(合并之前的数据)
* @param products 数组数据
* @param isLastPage
* @param now
*/
renderPageFunc ({ products }) {
let productData = handlerDataOnPage.handlerArray(products)
logger.log('productData.keysNum', productData.keysNum(), productData)
this.setData({
...productData
},()=>{
wx.hideLoading()
})
}
}) })
\ No newline at end of file
{ {
"navigationBarTitleText": "广东7-Eleven会员专区", "navigationBarTitleText": "广东7-Eleven会员专区",
"usingComponents": {} "usingComponents": {
"image-swiper": "/component/imageSwiper/imageSwiper",
"person-center": "/component/personCenter/personCenter",
"pic-nav": "/component/picNav/picNav",
"bottom": "/component/bottom/bottom",
"authorization-modal": "/component/authorization-modal/authorization-modal"
}
} }
\ No newline at end of file
<!--subPackage/page/pages/subPage/subPage.wxml--> <!--subPackage/page/pages/subPage/subPage.wxml-->
subPackage <view class='user-center'>
<!-- 1 轮播 2 个人中心 3 图片导航 4 底部-->
<block wx:for="{{pages}}" wx:key="{{index}}" wx:for-item="pItem">
<!--{{pItem.type}}-->
<!-- 轮播 -->
<view class="pd1530" wx:if="{{pItem.type == 1}}">
<image-swiper bind:updatePage="updatePage" image-data="{{pItem.rotationchart.images}}" />
</view>
<!-- 个人中心 {{pItem.customer}}-->
<view class="pd1530" wx:if="{{pItem.type == 2}}">
<person-center person-data="{{pItem.customer}}" integral-num="{{integralNum}}" coupon-num="{{couponNum}}" token="{{token}}"/>
</view>
<!-- 图片导航 {{pItem.navigation.images}} pd1530-->
<view class="pd1530" wx:if="{{pItem.type == 3}}">
<pic-nav bind:updatePage="updatePage" pic-nav="{{pItem.navigation.images}}" />
</view>
<!-- 底部 -->
<view class="" wx:if="{{pItem.type == 4}}">
<bottom bind:updatePage="updatePage" bottom="{{pItem.bottom}}"/>
</view>
</block>
</view>
<authorization-modal isAuthorization='{{isAuthorization}}'/>
/* subPackage/page/pages/subPage/subPage.wxss */ /* subPackage/page/pages/subPage/subPage.wxss */
@import './../../../../base/base.wxss';
page {
background: #fff!important;
}
.user-center{
/* margin-bottom: 120rpx; */
background: #fff;
box-sizing:border-box;
padding-bottom:120rpx;
}
.main-content{
margin-top: 18rpx;
}
.top-content,.bottom-content{
display: flex;
flex-direction: row;
flex-wrap: nowrap;
justify-content: space-between;
}
.top-content image{
width: 337rpx;
}
.top-left-img image{
height: 337rpx;
}
.top-right-img image{
height: 160rpx;
}
.bottom-content image{
width: 337rpx;
height: 160rpx;
}
.arrow-left {
width: 32rpx;
height: 32rpx;
vertical-align: middle;
}
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