当前位置:网站首页>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
}
边栏推荐
- MPM model and ab pressure test
- Mount NFS in kubesphere
- 论文阅读_中文NLP_ELECTRA
- The 19th Zhejiang I. barbecue
- Market status and development prospects of the global IOT active infrared sensor industry in 2022
- The simple problem of leetcode: dismantling bombs
- ZABBIX monitoring of lamp architecture (2): ZABBIX basic operation
- 2022 t elevator repair simulation examination question bank and t elevator repair simulation examination question bank
- 【PHP漏洞-弱类型】基础知识、php弱相等、报错绕过
- Ffmpeg mix
猜你喜欢

LVS load balancing cluster of efficient multi-purpose cluster (NAT mode)

Symbol of array element product of leetcode simple problem

Contents of welder (primary) examination and welder (primary) examination in 2022

Use Sqlalchemy module to obtain the table name and field name of the existing table in the database

Number of uniform strings of leetcode simple problem

Learning practice: comprehensive application of cycle and branch structure (I)

The simple problem of leetcode: dismantling bombs

Concurrent operation memory interaction

ZABBIX monitoring of lamp architecture (3): zabbix+mysql (to be continued)

Uipath practice (08) - selector
随机推荐
String matching: find a substring in a string
Leetcode simple question: the key with the longest key duration
STM32 reverse entry
RSRS index timing and large and small disc rotation
Sdl2 + OpenGL glsl practice (Continued)
Review the old and know the new: Notes on Data Science
[BMZCTF-pwn] 18-RCTF-2017-Recho
移动端——uniapp开发记录(公共请求request封装)
Crazy scientist
On typescript and grammar
Function introduction of member points mall system
Contents of welder (primary) examination and welder (primary) examination in 2022
Shuttle + Alluxio 加速内存Shuffle起飞
The current market situation and development prospect of the global gluten tolerance test kit industry in 2022
【PHP漏洞-弱类型】基础知识、php弱相等、报错绕过
Market status and development prospects of the global autonomous marine glider industry in 2022
Employee attendance management system based on SSM
Leetcode simple question: check whether the array is sorted and rotated
Market status and development prospect prediction of global fermentation acid industry in 2022
Learning practice: comprehensive application of cycle and branch structure (I)