当前位置:网站首页>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
}
边栏推荐
- What functions need to be set after the mall system is built
- Factor stock selection scoring model
- @RequestMapping
- Thesis reading_ ICD code_ MSMN
- General undergraduate college life pit avoidance Guide
- The reason why the entity class in the database is changed into hump naming
- Learning practice: comprehensive application of cycle and branch structure (I)
- First + only! Alibaba cloud's real-time computing version of Flink passed the stability test of big data products of the Institute of ICT
- [BMZCTF-pwn] 20-secret_ file
- FISCO bcos zero knowledge proof Fiat Shamir instance source code
猜你喜欢

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

The programmer went to bed at 12 o'clock in the middle of the night, and the leader angrily scolded: go to bed so early, you are very good at keeping fit

Preparation for school and professional cognition

2022 P cylinder filling test content and P cylinder filling simulation test questions

Triangular rasterization

并发操作-内存交互操作

《牛客刷verilog》Part II Verilog进阶挑战

Learn to use the idea breakpoint debugging tool

Thesis reading_ ICD code_ MSMN

GFS distributed file system (it's nice to meet it alone)
随机推荐
Youdao cloud notes
MC Layer Target
Php+mysql registration landing page development complete code
2.14 summary
Number of uniform strings of leetcode simple problem
2022 P cylinder filling test content and P cylinder filling simulation test questions
Leetcode simple question: check whether two string arrays are equal
Day 51 - tree problem
After job hopping at the end of the year, I interviewed more than 30 companies in two weeks and finally landed
Learn to use the idea breakpoint debugging tool
[set theory] binary relation (example of binary relation on a | binary relation on a)
The least operation of leetcode simple problem makes the array increment
论文阅读_清华ERNIE
[SQL injection] joint query (the simplest injection method)
I've seen a piece of code in the past. I don't know what I'm doing. I can review it when I have time
《牛客刷verilog》Part II Verilog进阶挑战
雇佣收银员(差分约束)
JS multidimensional array to one-dimensional array
【工具跑SQL盲注】
Leetcode simple question: check whether the string is an array prefix