当前位置:网站首页>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
}
边栏推荐
- M1 Pro install redis
- Leetcode simple problem delete an element to strictly increment the array
- UiPath实战(08) - 选取器(Selector)
- 有道云笔记
- Two drawing interfaces - 1 Matlab style interface
- 联发科技2023届提前批IC笔试(题目)
- Leetcode simple question: check whether the string is an array prefix
- Introduction to message queuing (MQ)
- SSM based campus part-time platform for College Students
- LVS load balancing cluster of efficient multi-purpose cluster (NAT mode)
猜你喜欢

有道云笔记

STM32 reverse entry

Arthas watch grabs a field / attribute of the input parameter

Thesis reading_ Chinese NLP_ ELECTRA

MC Layer Target

Network security textual research recommendation

Php+mysql registration landing page development complete code

String matching: find a substring in a string

2022 a special equipment related management (elevator) analysis and a special equipment related management (elevator) simulation test

Thesis reading_ ICD code_ MSMN
随机推荐
Market status and development prospect forecast of global heat curing adhesive industry in 2022
Contents of welder (primary) examination and welder (primary) examination in 2022
[luatos sensor] 2 air pressure bmp180
Library management system based on SSM
Current market situation and development prospect prediction of global direct energy deposition 3D printer industry in 2022
Function introduction of member points mall system
Matplotlib -- save graph
2022 t elevator repair simulation examination question bank and t elevator repair simulation examination question bank
STM32 reverse entry
UiPath实战(08) - 选取器(Selector)
Shell script Basics - basic grammar knowledge
Reptile exercise 03
MC Layer Target
[BMZCTF-pwn] 20-secret_ file
Market status and development prospect prediction of the global autonomous hybrid underwater glider industry in 2022
Employee attendance management system based on SSM
How to choose cross-border e-commerce multi merchant system
First + only! Alibaba cloud's real-time computing version of Flink passed the stability test of big data products of the Institute of ICT
[set theory] relational representation (relational matrix | examples of relational matrix | properties of relational matrix | operations of relational matrix | relational graph | examples of relationa
[PHP vulnerability weak type] basic knowledge, PHP weak equality, error reporting and bypassing