当前位置:网站首页>Wechat applet waterfall flow and pull up to the bottom
Wechat applet waterfall flow and pull up to the bottom
2022-07-03 04:49:00 【Xiafei997】
js:
data: {
// Page number
page:1,
data:[],
// Last page number
last_page:"",
},
click(evt){
// console.log(evt.currentTarget.dataset.id)
let id=evt.currentTarget.dataset.id
wx.navigateTo({
url: '/pages/detail/detail?id='+id,
})
},
/**
* Life cycle function -- Monitor page loading
*/
onLoad: function (options) {
// Fetch cache
let token=wx.getStorageSync('token')
let _this=this
wx.request({
url: 'http://www.day.com/index.php/listDatas',
method:"GET",
data:{
"pages":10
},
header:{
"token":token
},
success(res){
// console.log(res.data.data.data)
// The top ten data
let data=res.data.data.data
// Total page number
let last_page= res.data.data.last_page
// console.log(last_page)
// Render data
_this.setData({
data:data,
last_page:last_page
})
}
})
},
// Pull up and touch the bottom
onReachBottom:function(e){
let token=wx.getStorageSync('token')
let that=this
// Get the next page
let page=that.data.page+1;
// console.log(this.data.last_page)
wx.showLoading({
title: ' Loading control '+page+" page ",
})
if(page>this.data.last_page){
wx.showToast({
title: ' Whether the ',
icon:'error'
})
}
wx.request({
url: 'http://www.day.com/index.php/listDatas',
method:"GET",
data:{
"pages":10,
"page":page
},
header:{
"token":token
},
success(res){
// console.log(res.data.data.data)
// The stitched data
// Render data
that.setData({
page:that.data.page+1,
data:that.data.data.concat(res.data.data.data)
})
}
})
setTimeout(function(){
wx.hideLoading()
},2000)
}
front end :
<wxs src="../../utils/tools.wxs" module="tools"></wxs>
<block wx:for="{ {data}}" wx:key="index">
<l-card type="primary" image="{ {item.img}}" title="{ {tools.mysub(item.name,0,14)}}" bindtap="click" data-id="{ {item.id}}">
<view>{ {item.score}} branch |{ {item.num}} comments </view>
<view class="price">¥{ {item.price}} rise </view>
</l-card>
</block>
wxs:
function mysub(str,start,end){
// Start
var beagin=start||0;
var len=end||14;
if(str.length<len){
return str;
}else{
var strNew=str.substring(beagin,len);
return strNew+"..."
}
}
module.exports={
mysub:mysub
}
边栏推荐
- Factor stock selection scoring model
- C primre plus Chapter 10 question 6 inverted array
- Concurrent operation memory interaction
- data2vec! New milestone of unified mode
- 《牛客刷verilog》Part II Verilog进阶挑战
- Thesis reading_ ICD code_ MSMN
- What functions need to be set after the mall system is built
- Do you know UVs in modeling?
- Analysis of proxy usage of ES6 new feature
- Uipath practice (08) - selector
猜你喜欢
移动端——uniapp开发记录(公共请求request封装)
Function introduction of member points mall system
Introduction to JVM principle
带有注意力RPN和多关系检测器的小样本目标检测网络(提供源码和数据及下载)...
Pyqt control part (II)
2022 registration examination for safety production management personnel of hazardous chemical production units and examination skills for safety production management personnel of hazardous chemical
4 years of experience to interview test development, 10 minutes to end, ask too
Uipath practice (08) - selector
Analysis of proxy usage of ES6 new feature
Contents of welder (primary) examination and welder (primary) examination in 2022
随机推荐
@RequestMapping
7. Integrated learning
The reason why the entity class in the database is changed into hump naming
Current market situation and development prospect prediction of global direct energy deposition 3D printer industry in 2022
2022 a special equipment related management (elevator) analysis and a special equipment related management (elevator) simulation test
Hire cashier (differential constraint)
[XSS bypass - protection strategy] understand the protection strategy and better bypass
2022 chemical automation control instrument examination summary and chemical automation control instrument certificate examination
"Niuke brush Verilog" part II Verilog advanced challenge
stm32逆向入门
JVM原理简介
Market status and development prospect prediction of the global fire extinguisher industry in 2022
String matching: find a substring in a string
Day 51 - tree problem
[PHP vulnerability weak type] basic knowledge, PHP weak equality, error reporting and bypassing
2022 new examination questions for the main principals of hazardous chemical business units and examination skills for the main principals of hazardous chemical business units
Mount NFS in kubesphere
Shell script Basics - basic grammar knowledge
C language self-made Games: Sanzi (tic tac toe chess) intelligent chess supplement
Blog building tool recommendation (text book delivery)