Commit dc017aff by luyt

feat:滚动添加

1 parent 956b351a
...@@ -5,7 +5,8 @@ ...@@ -5,7 +5,8 @@
<!-- <view style="height:{{headerHeight}}px"> <!-- <view style="height:{{headerHeight}}px">
</view> --> </view> -->
<product stickyTop="{{headerHeight}}" class="productCon" style="padding-top:{{headerHeight}}px" isAuthphone="{{isAuthphone}}" actNum="{{actNum}}" wrapactiveNavIdx="{{activeNavIdx}}" senceData="{{senceData}}" outshowVideo="{{outshowVideo}}" isShare="{{isShare}}" bindauthorized="authorizedFn" /> <!-- style="padding-top:{{headerHeight}}px" -->
<product stickyTop="{{headerHeight}}" class="productCon" isAuthphone="{{isAuthphone}}" actNum="{{actNum}}" wrapactiveNavIdx="{{activeNavIdx}}" senceData="{{senceData}}" outshowVideo="{{outshowVideo}}" isShare="{{isShare}}" bindauthorized="authorizedFn" />
<!-- 分享弹框 --> <!-- 分享弹框 -->
<!-- <view class="share-wrap" wx:if="{{isShow}}"> <!-- <view class="share-wrap" wx:if="{{isShow}}">
<view class="img-wrap"> <view class="img-wrap">
......
...@@ -54,6 +54,9 @@ Component({ ...@@ -54,6 +54,9 @@ Component({
}, },
lifetimes: { lifetimes: {
ready: function () { ready: function () {
this.init();
this.getImgHeight();
console.log('ready')
//获取当前路径 //获取当前路径
let currentUrl = this.getCurrentPageUrl() let currentUrl = this.getCurrentPageUrl()
// console.log('currentUrl: ', currentUrl); // console.log('currentUrl: ', currentUrl);
...@@ -77,6 +80,7 @@ Component({ ...@@ -77,6 +80,7 @@ Component({
// return pre+cur.height // return pre+cur.height
// },heightTop) // },heightTop)
let imgTopArr = this.data.imgTopArr let imgTopArr = this.data.imgTopArr
console.log('imgTopArr: ', imgTopArr);
if(imgTopArr.length == 0)return if(imgTopArr.length == 0)return
wx.nextTick(()=>{ wx.nextTick(()=>{
...@@ -96,8 +100,6 @@ Component({ ...@@ -96,8 +100,6 @@ Component({
}) })
} }
this.init();
this.getImgHeight();
//如果不是分享,初始化的时候调用函数 //如果不是分享,初始化的时候调用函数
if (!this.data.isShare) { if (!this.data.isShare) {
// console.log(131546) // console.log(131546)
...@@ -149,7 +151,7 @@ Component({ ...@@ -149,7 +151,7 @@ Component({
activeNavIdx: 0, activeNavIdx: 0,
}); });
// 每次切换场景,重新获取流程图高度 // 每次切换场景,重新获取流程图高度
this.getImgHeight(); // this.getImgHeight();
this.getMoreFn(); this.getMoreFn();
// this // this
if(this.data.wrapactiveNavIdx){ if(this.data.wrapactiveNavIdx){
...@@ -159,7 +161,6 @@ Component({ ...@@ -159,7 +161,6 @@ Component({
} }
}, },
}, },
/** /**
* 组件的方法列表 * 组件的方法列表
*/ */
...@@ -219,12 +220,18 @@ Component({ ...@@ -219,12 +220,18 @@ Component({
changeTab(e) { changeTab(e) {
let idx = e.detail; let idx = e.detail;
let {imgTopArr,stickyTop} = this.data let {imgTopArr,stickyTop} = this.data
console.log('idx: ', imgTopArr[idx]); console.log('idx: ', imgTopArr[idx],stickyTop);
// this.setData({ // this.setData({
// intoViewId: `to-${idx}`, // intoViewId: `to-${idx}`,
// }); // });
// wx.$eventbus.emit('evt_page_index',idx) // wx.$eventbus.emit('evt_page_index',idx)
//判断当前路径
let currentUrl = this.getCurrentPageUrl()
if(currentUrl == '/pages/tab/index/index'){
wx.pageScrollTo({ scrollTop: imgTopArr[idx]-stickyTop+88+34}) wx.pageScrollTo({ scrollTop: imgTopArr[idx]-stickyTop+88+34})
}else{
wx.pageScrollTo({ scrollTop: (imgTopArr[idx]-stickyTop)})
}
}, },
// async changeTab(e){ // async changeTab(e){
// let idx = e.detail // let idx = e.detail
...@@ -274,10 +281,12 @@ Component({ ...@@ -274,10 +281,12 @@ Component({
let imgTopArr = [] let imgTopArr = []
let s = 0; let s = 0;
let top let top
let _this = this
query query
.selectAll(".img-item") .selectAll(".img-item")
.boundingClientRect((react) => { .boundingClientRect((react) => {
react.forEach((item,index) => { react.forEach((item,index) => {
console.log('item: ', item);
// if(index == 0){ // if(index == 0){
// console.log('item top: ', item); // console.log('item top: ', item);
...@@ -288,7 +297,6 @@ Component({ ...@@ -288,7 +297,6 @@ Component({
// heightArr.push(s); // heightArr.push(s);
imgTopArr.push(s) imgTopArr.push(s)
}); });
console.log('没有处理过的heightArr',heightArr)
// heightArr = heightArr.map((item)=>{ // heightArr = heightArr.map((item)=>{
// item += top // item += top
...@@ -297,29 +305,12 @@ Component({ ...@@ -297,29 +305,12 @@ Component({
// this.data.heightArr = heightArr; // this.data.heightArr = heightArr;
// // console.log(heightArr[heightArr.length-1]) // // console.log(heightArr[heightArr.length-1])
// this.data.allHeight = heightArr[heightArr.length - 1]; // this.data.allHeight = heightArr[heightArr.length - 1];
}) // console.log('imgTopArr',imgTopArr)
.exec(); _this.setData({
this.setData({
imgTopArr imgTopArr
// heightArr,
// allHeight:heightArr[heightArr.length - 1]
}) })
// let query = wx.createSelectorQuery().in(this); })
// let heightArr = []; .exec();
// let s = 0;
// query
// .selectAll(".img-item")
// .boundingClientRect((react) => {
// react.forEach((item) => {
// // s += item.height;
// heightArr.push(item.top);
// });
// this.data.heightArr = heightArr;
// // console.log(heightArr[heightArr.length-1])
// this.data.allHeight = heightArr[heightArr.length - 1];
// })
// .exec();
}, },
// 获取用户信息 // 获取用户信息
getUserInfo({ detail }) { getUserInfo({ detail }) {
......
<!-- pages/tab/discovery/components/product/product.wxml --> <!-- pages/tab/discovery/components/product/product.wxml -->
<view class="prod-wrap" > <view class="prod-wrap" >
<view class="big-title">特色产品 {{origin}}</view> <view class="big-title">特色产品</view>
<scroll-view class="nav-wrap" scroll-x="{{true}}" wx:if="{{!isShare && origin =='home'}}"> <scroll-view class="nav-wrap" scroll-x="{{true}}" wx:if="{{!isShare && origin =='home'}}">
<block wx:for="{{navList}}" wx:key="index"> <block wx:for="{{navList}}" wx:key="index">
<text class='nav {{activeNavIdx==index ? "active-nav": ""}}' bindtap="changeNav" data-index="{{index}}">{{item}}</text> <text class='nav {{activeNavIdx==index ? "active-nav": ""}}' bindtap="changeNav" data-index="{{index}}">{{item}}</text>
...@@ -40,12 +40,11 @@ ...@@ -40,12 +40,11 @@
productHeight productHeight
/> />
</view> </view>
<!-- style="{height:{{allHeight}}px}" -->
<!-- style="{height:{{allHeight}}px}" scroll-y="{{true}}" bindscroll="scrolltoupper"-->
<scroll-view <scroll-view
class="project-img" class="project-img"
scroll-into-view="{{intoViewId}}" scroll-into-view="{{intoViewId}}"
bindscroll="scrolltoupper"
scroll-y="{{true}}"
> >
<block wx:for="{{tab}}" wx:key="index"> <block wx:for="{{tab}}" wx:key="index">
<!-- wx:if="{{showVideo && index==5 && tab.length < 5}}" --> <!-- wx:if="{{showVideo && index==5 && tab.length < 5}}" -->
......
...@@ -311,17 +311,17 @@ Page({ ...@@ -311,17 +311,17 @@ Page({
visible: false visible: false
}) })
// this.showCase(); // this.showCase();
if (!this.data.isFirst) { // if (!this.data.isFirst) {
wx.showToast({ wx.showToast({
title: '测算结果已在页面内同步展示', title: '测算结果已在页面内同步展示',
icon: 'none', icon: 'none',
duration: 2000 duration: 2000
}) })
} else { // } else {
this.setData({ // this.setData({
isFirst: false // isFirst: false
}) // })
} // }
}, },
// // 获取场景下的产品类型 // // 获取场景下的产品类型
// getProductType(sceneIndex, tabIndex) { // getProductType(sceneIndex, tabIndex) {
......
...@@ -386,18 +386,18 @@ page { ...@@ -386,18 +386,18 @@ page {
position: fixed; position: fixed;
right: -4px; right: -4px;
top: 60%; top: 60%;
width: 60px; width: 64px;
height: 60px; height: 64px;
border-radius: 50%; border-radius: 50%;
z-index: 2; z-index: 2;
} }
.output-value { .output-value {
position: fixed; position: fixed;
right: 5px; right: -2px;
top: 70%; top: 70%;
width: 40px; width: 64px;
height: 50px; height: 64px;
// border-radius: 50%; // border-radius: 50%;
z-index: 1; z-index: 1;
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!