Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
saas_plus
/
business-assistant
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit a1c2eb1a
authored
Oct 26, 2022
by
luyt
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
feat:滚动添加
1 parent
67c85b30
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
152 additions
and
30 deletions
pages/checkProduct/checkProduct.js
pages/checkProduct/checkProduct.scss
pages/checkProduct/checkProduct.wxml
pages/tab/index/components/product/product.js
pages/tab/index/components/product/product.scss
pages/tab/index/components/product/product.wxml
pages/tab/index/index.js
pages/checkProduct/checkProduct.js
View file @
a1c2eb1
...
@@ -425,6 +425,7 @@ Page({
...
@@ -425,6 +425,7 @@ Page({
this.setData({
this.setData({
hasUserInfo: true,
hasUserInfo: true,
});
});
let _this = this;
// 推荐使用 wx.getUserProfile 获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认
// 推荐使用 wx.getUserProfile 获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认
// 开发者妥善保管用户快速填写的头像昵称,避免重复弹窗
// 开发者妥善保管用户快速填写的头像昵称,避免重复弹窗
wx.getUserProfile({
wx.getUserProfile({
...
@@ -444,10 +445,23 @@ Page({
...
@@ -444,10 +445,23 @@ Page({
};
};
// console.log('obj',obj)
// console.log('obj',obj)
wx.$storage.set("wx_user_info", obj);
wx.$storage.set("wx_user_info", obj);
// this.onLoad(null);
_this.onLoad(null);
},
},
});
});
},
},
onPageScroll: (function () {
let timer = null;
return function (e) {
// console.log("在滚动");
// 监听页面的滚动开始和结束
clearTimeout(timer);
timer = setTimeout(() => {
// console.log("滚动结束");
wx.$eventbus.emit('evt_page_scroll',{scrollTop:e.scrollTop})
}, 500);
};
})(),
/**
/**
* 生命周期函数--监听页面初次渲染完成
* 生命周期函数--监听页面初次渲染完成
...
...
pages/checkProduct/checkProduct.scss
View file @
a1c2eb1
...
@@ -115,6 +115,7 @@
...
@@ -115,6 +115,7 @@
width
:
100%
;
width
:
100%
;
height
:
120rpx
;
height
:
120rpx
;
background
:
#ffffff
;
background
:
#ffffff
;
z-index
:
1
;
// border-radius: 8px 8px 0 0;
// border-radius: 8px 8px 0 0;
.top
{
.top
{
display
:
flex
;
display
:
flex
;
...
@@ -177,6 +178,6 @@
...
@@ -177,6 +178,6 @@
left
:
0
;
left
:
0
;
right
:
0
;
right
:
0
;
bottom
:
0
;
bottom
:
0
;
z-index
:
2
;
z-index
:
3
;
background-color
:
transparent
;
background-color
:
transparent
;
}
}
pages/checkProduct/checkProduct.wxml
View file @
a1c2eb1
...
@@ -37,7 +37,7 @@
...
@@ -37,7 +37,7 @@
</view> -->
</view> -->
<!-- 用于图片加载事件 -->
<!-- 用于图片加载事件 -->
<image class="img" src="{{IMG_URL}}index/longpic{{actNum+1}}.png" bindload="onloadFn" />
<image class="img" src="{{IMG_URL}}index/longpic{{actNum+1}}.png" bindload="onloadFn" />
<view class="btns-wrap">
<view class="btns-wrap"
wx:if="{{isShow}}"
>
<view class="top">
<view class="top">
<view class="btn" wx:for="{{btnList}}" wx:key="name" bindtap="handleClick" data-index="{{index}}">
<view class="btn" wx:for="{{btnList}}" wx:key="name" bindtap="handleClick" data-index="{{index}}">
<block wx:if="{{index == 1}}">
<block wx:if="{{index == 1}}">
...
...
pages/tab/index/components/product/product.js
View file @
a1c2eb1
...
@@ -49,12 +49,48 @@ Component({
...
@@ -49,12 +49,48 @@ Component({
IMGURL
:
`
${
IMG_URL
}
index/`
,
IMGURL
:
`
${
IMG_URL
}
index/`
,
videoBaseUrl
,
videoBaseUrl
,
getMoreBtn
:
false
,
getMoreBtn
:
false
,
showVideo
:
true
//显示视频列表
showVideo
:
true
,
//显示视频列表
imgTopArr
:[]
},
},
lifetimes
:
{
lifetimes
:
{
ready
:
function
()
{
ready
:
function
()
{
if
(
!
this
.
data
.
outshowVideo
){
//获取当前路径
let
currentUrl
=
this
.
getCurrentPageUrl
()
// console.log('currentUrl: ', currentUrl);
if
(
currentUrl
==
'/pages/tab/index/index'
){
this
.
setData
({
currentUrl
:
false
})
}
//监听页面滚动的距离
wx
.
$eventbus
.
on
(
'evt_page_scroll'
,
async
(
e
)
=>
{
console
.
log
(
e
)
// let heightTop = this.data.stickyTop// 90 场景高度,8 场景margin-bottom
// let prodArr = await this.getHeight('.prod-wrap')
// // console.log('prodArr: ', prodArr);
// heightTop += prodArr[0].height
// let imgArr = await this.getHeight('.img-item')
// // console.log('imgArr: ', imgArr);
// let imgHeightArr = []
// imgArr.reduce((pre,cur,index)=>{
// imgHeightArr.push(pre+cur.height)
// return pre+cur.height
// },heightTop)
let
imgTopArr
=
this
.
data
.
imgTopArr
if
(
imgTopArr
.
length
==
0
)
return
wx
.
nextTick
(()
=>
{
let
idx
=
imgTopArr
.
findIndex
(
item
=>
item
>
e
.
scrollTop
)
if
(
idx
>-
1
){
this
.
setData
({
curTabIdx
:
idx
})
}
})
})
if
(
!
this
.
data
.
outshowVideo
){
this
.
setData
({
this
.
setData
({
showVideo
:
false
showVideo
:
false
})
})
...
@@ -68,6 +104,7 @@ Component({
...
@@ -68,6 +104,7 @@ Component({
this
.
getMoreFn
();
this
.
getMoreFn
();
}
}
},
},
},
},
observers
:
{
observers
:
{
actNum
:
function
(
newval
,
oldval
)
{
actNum
:
function
(
newval
,
oldval
)
{
...
@@ -127,6 +164,12 @@ Component({
...
@@ -127,6 +164,12 @@ Component({
* 组件的方法列表
* 组件的方法列表
*/
*/
methods
:
{
methods
:
{
getCurrentPageUrl
()
{
const
pages
=
getCurrentPages
()
const
currentPage
=
pages
[
pages
.
length
-
1
]
const
url
=
`/
${
currentPage
.
route
}
`
return
url
},
async
init
()
{
async
init
()
{
try
{
try
{
const
{
data
,
code
,
message
}
=
await
USERAPI
.
wxCodeLogin
();
const
{
data
,
code
,
message
}
=
await
USERAPI
.
wxCodeLogin
();
...
@@ -175,43 +218,93 @@ Component({
...
@@ -175,43 +218,93 @@ Component({
saleTextChange
(
e
)
{},
saleTextChange
(
e
)
{},
changeTab
(
e
)
{
changeTab
(
e
)
{
let
idx
=
e
.
detail
;
let
idx
=
e
.
detail
;
this
.
setData
({
let
{
imgTopArr
,
stickyTop
}
=
this
.
data
intoViewId
:
`to-
${
idx
}
`
,
console
.
log
(
'idx: '
,
imgTopArr
[
idx
]);
});
// this.setData({
// intoViewId: `to-${idx}`,
// });
// wx.$eventbus.emit('evt_page_index',idx)
wx
.
pageScrollTo
({
scrollTop
:
imgTopArr
[
idx
]
-
stickyTop
+
88
+
34
})
},
// async changeTab(e){
// let idx = e.detail
// this.setData({
// intoViewId: `to-${idx}`
// })
// let heightTop = this.data.headerHeight + 90 - 16 - 46 // 90 场景高度,16 可能是误差 , 46 tab高度
// let prodArr = await this.getHeight('.prod-wrap')
// heightTop += prodArr[0].height
// let imgArr = await this.getHeight('.img-item')
// for(let i=0;i<idx;i++){
// heightTop += imgArr[i].height
// }
// wx.pageScrollTo({
// scrollTop: heightTop,
// duration: 0
// })
// },
getHeight
(
cla
){
return
new
Promise
((
resolve
,
reject
)
=>
{
let
query
=
wx
.
createSelectorQuery
().
in
(
this
)
query
.
selectAll
(
cla
).
boundingClientRect
((
rect
)
=>
{
resolve
(
rect
)
}).
exec
()
})
},
},
changeNav
(
event
)
{
changeNav
(
event
)
{
this
.
setData
({
this
.
setData
({
activeNavIdx
:
event
.
target
.
dataset
.
index
,
activeNavIdx
:
event
.
target
.
dataset
.
index
,
});
});
},
},
scrolltoupper
(
event
)
{
//
scrolltoupper(event) {
console
.
log
(
event
.
detail
.
scrollHeight
,
event
.
detail
.
scrollTop
)
//
console.log(event.detail.scrollHeight,event.detail.scrollTop)
const
idx
=
this
.
data
.
heightArr
.
findIndex
(
//
const idx = this.data.heightArr.findIndex(
(
item
)
=>
item
>
event
.
detail
.
scrollHeight
//
(item) => item > event.detail.scrollHeight
);
//
);
console
.
log
(
'idx'
,
idx
)
//
console.log('idx',idx)
this
.
setData
({
//
this.setData({
curTabIdx
:
idx
,
//
curTabIdx: idx,
});
//
});
// console.log(this.data.curTabIdx1)
//
// console.log(this.data.curTabIdx1)
},
//
},
getImgHeight
()
{
getImgHeight
()
{
let
query
=
wx
.
createSelectorQuery
().
in
(
this
);
let
query
=
wx
.
createSelectorQuery
().
in
(
this
);
let
heightArr
=
[];
let
heightArr
=
[];
let
imgTopArr
=
[]
let
s
=
0
;
let
s
=
0
;
let
top
query
query
.
selectAll
(
".img-item"
)
.
selectAll
(
".img-item"
)
.
boundingClientRect
((
react
)
=>
{
.
boundingClientRect
((
react
)
=>
{
react
.
forEach
((
item
)
=>
{
react
.
forEach
((
item
,
index
)
=>
{
s
+=
item
.
height
;
heightArr
.
push
(
s
);
// if(index == 0){
// console.log('item top: ', item);
// top = item.top
// }
// s = s +item.height;
s
=
item
.
top
// heightArr.push(s);
imgTopArr
.
push
(
s
)
});
});
this
.
data
.
heightArr
=
heightArr
;
console
.
log
(
'没有处理过的heightArr'
,
heightArr
)
// console.log(heightArr[heightArr.length-1])
this
.
data
.
allHeight
=
heightArr
[
heightArr
.
length
-
1
];
// heightArr = heightArr.map((item)=>{
// item += top
// return item
// })
// this.data.heightArr = heightArr;
// // console.log(heightArr[heightArr.length-1])
// this.data.allHeight = heightArr[heightArr.length - 1];
})
})
.
exec
();
.
exec
();
this
.
setData
({
imgTopArr
// heightArr,
// allHeight:heightArr[heightArr.length - 1]
})
// let query = wx.createSelectorQuery().in(this);
// let query = wx.createSelectorQuery().in(this);
// let heightArr = [];
// let heightArr = [];
// let s = 0;
// let s = 0;
...
...
pages/tab/index/components/product/product.scss
View file @
a1c2eb1
...
@@ -348,9 +348,12 @@
...
@@ -348,9 +348,12 @@
.video-list
{
.video-list
{
display
:
flex
;
display
:
flex
;
flex-wrap
:
wrap
;
flex-wrap
:
wrap
;
padding
:
0
32rpx
;
padding
:
0
rpx
32rpx
;
font-size
:
0
;
font-size
:
0
;
}
}
.check-prod
.video-list
{
padding-bottom
:
140rpx
;
}
.video-item
{
.video-item
{
position
:
relative
;
position
:
relative
;
width
:
calc
(
50%
-
12rpx
);
width
:
calc
(
50%
-
12rpx
);
...
...
pages/tab/index/components/product/product.wxml
View file @
a1c2eb1
<!-- 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">特色产品</view>
<view class="big-title">特色产品
{{origin}}
</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>
...
@@ -28,7 +28,7 @@
...
@@ -28,7 +28,7 @@
</view>
</view>
</view>
</view>
</view>
</view>
<view class="project-wrap">
<view class="project-wrap
{{currentUrl == ''? '':'check-prod'}}
">
<!-- -->
<!-- -->
<view class="stickyTab" style="top:{{isShare ? stickyTop+88 : stickyTop}}rpx">
<view class="stickyTab" style="top:{{isShare ? stickyTop+88 : stickyTop}}rpx">
<tab
<tab
...
...
pages/tab/index/index.js
View file @
a1c2eb1
...
@@ -635,7 +635,18 @@ Page({
...
@@ -635,7 +635,18 @@ Page({
// console.log('this.data.tabBarStyle',this.data.tabBarStyle,this.data.headerHeight)
// console.log('this.data.tabBarStyle',this.data.tabBarStyle,this.data.headerHeight)
// })
// })
},
},
onPageScroll
:
(
function
()
{
let
timer
=
null
;
return
function
(
e
)
{
// console.log("在滚动");
// 监听页面的滚动开始和结束
clearTimeout
(
timer
);
timer
=
setTimeout
(()
=>
{
// console.log("滚动结束");
wx
.
$eventbus
.
emit
(
'evt_page_scroll'
,{
scrollTop
:
e
.
scrollTop
})
},
500
);
};
})(),
/**
/**
* 生命周期函数--监听页面隐藏
* 生命周期函数--监听页面隐藏
*/
*/
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment