当前位置:网站首页>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
}
边栏推荐
- Web security - CSRF (token)
- [set theory] binary relationship (definition field | value field | inverse operation | inverse synthesis operation | restriction | image | single root | single value | nature of synthesis operation)
- Valentine's day limited withdrawal guide: for one in 200 million of you
- Function introduction of member points mall system
- Leetcode simple question: the key with the longest key duration
- 【XSS绕过-防护策略】理解防护策略,更好的绕过
- Thesis reading_ ICD code_ MSMN
- Do you know UVs in modeling?
- AWS VPC
- stm32逆向入门
猜你喜欢

Golang -- realize file transfer

Thesis reading_ Tsinghua Ernie

2022 registration of G2 utility boiler stoker examination and G2 utility boiler stoker reexamination examination

Preparation for school and professional cognition

Truncated sentences of leetcode simple questions

Valentine's day limited withdrawal guide: for one in 200 million of you

Php+mysql registration landing page development complete code

Career planning of counter attacking College Students

【XSS绕过-防护策略】理解防护策略,更好的绕过

Uipath practice (08) - selector
随机推荐
Current market situation and development prospect forecast of global UV sensitive resin 3D printer industry in 2022
论文阅读_清华ERNIE
Reptile exercise 03
Leetcode simple problem delete an element to strictly increment the array
LVS load balancing cluster of efficient multi-purpose cluster (NAT mode)
C language self-made Games: Sanzi (tic tac toe chess) intelligent chess supplement
GFS distributed file system (it's nice to meet it alone)
Leetcode simple question: check whether the array is sorted and rotated
MC Layer Target
【工具跑SQL盲注】
Market status and development prospect prediction of global fermentation acid industry in 2022
Writing skills of multi plate rotation strategy -- strategy writing learning materials
联发科技2023届提前批IC笔试(题目)
[luatos sensor] 1 light sensing bh1750
[set theory] binary relation (example of binary relation operation | example of inverse operation | example of composite operation | example of limiting operation | example of image operation)
M1 Pro install redis
2022 registration examination for safety production management personnel of hazardous chemical production units and examination skills for safety production management personnel of hazardous chemical
2022 tea master (intermediate) examination questions and tea master (intermediate) examination skills
Preparation for school and professional cognition
[XSS bypass - protection strategy] understand the protection strategy and better bypass