Pull-up refresh and pull-up loading of WeChat applet list
###1.1 scroll-view component
Write picture description here
Note: When using vertical scrolling, you need to give a fixed height and set the height through WXSS. ###1.2 image component
Write picture description here
Note: mode has 12 modes, 3 of which are zoom modes and 9 are cropping modes. ###1.3 Icon component Write picture description here
iconType: [ 'success', 'info', 'warn', 'waiting', 'safe_success', 'safe_warn', 'success_circle', 'success_no_circle', 'waiting_circle', 'circle', 'download', 'info_circle' , 'cancel', 'search', 'clear' ]
2. Implementation of pull-up loading and pull-down refresh of list
##2.1 Let’s take a rendering first and write the picture description here ##2.2 The logic is very simple, just upload the code ###2.2.1 detail.wxml layout file
<loading hidden="{{hidden}}" bindchange="loadingChange">
Loading...
</loading>
<scroll-view scroll-y="true" style="height: 100%;" bindscrolltolower="loadMore" bindscrolltoupper="refesh">
<view wx:if="{{hasRefesh}}" style="display: flex;flex-direction: row;align-items: center;align-self: center;justify-content: center;">
<icon type="waiting" size="45"/><text>Refreshing...</text></view>
<view wx:else style="display:none" ><text></text></view>
<view class="llll" wx:for="{{list}}" wx:for-item="item" bindtap="bindViewTap"
data-title="{{item.title}}" >
<image style=" width: 50px;height: 50px;margin: 20rpx;" src="{{item.firstImg}}" ></image>
<view class="eee" >
<view style="margin:5px;font-size:8px"> title:{{item.title}}</view>
<view style="margin:5px;color:red;font-size:6px"> Source:{{item.source}}</view>
</view>
</view>
<view class="tips1">
<view wx:if="{{hasMore}}" style="display: flex;flex-direction: row;align-items: center;align-self: center;justify-content: center;">
<icon type="waiting" size="45"/><text>Deadly loading...</text></view>
<view wx:else><text>No more content</text></view>
</view>
</scroll-view>
###2.2.1 detail.js logic code file
var network_util = require('../../utils/network_util.js');
var json_util = require('../../utils/json_util.js');
Page({
data:{
// text:"This is a page"
list:[],
dd:'',
hidden:false,
Page: 1,
Size: 20,
hasMore:true,
HasRefesh:false
},
onLoad:function(options){
var that = this;
var url = 'http://v.juhe.cn/weixin/query?key=f16af393a63364b729fd81ed9fdd4b7d&pno=1&ps=10';
Network_util._get(url,
function(res){
That.setData({
List:res.data.result.list,
hidden: true,
});
},function(res){
console.log(res);
});
},
onReady:function(){
// Page rendering completed
},
onShow:function(){
// Page display
},
onHide:function(){
// Page hidden
},
onUnload:function(){
// Page close
},
//Click event processing
bindViewTap: function(e) {
console.log(e.currentTarget.dataset.title);
},
//Load more
loadMore: function(e) {
var that = this;
That.setData({
hasRefesh:true,});
if (!this.data.hasMore) return
var url = 'http://v.juhe.cn/weixin/query?key=f16af393a63364b729fd81ed9fdd4b7d&pno='+(++that.data.page)+'&ps=10';
Network_util._get(url,
function(res){
That.setData({
List: that.data.list.concat(res.data.result.list),
hidden: true,
hasRefesh:false,
});
},function(res){
console.log(res);
})
},
//Refresh processing
refesh: function(e) {
var that = this;
that.setData({
hasRefesh:true,
});
var url = 'http://v.juhe.cn/weixin/query?key=f16af393a63364b729fd81ed9fdd4b7d&pno=1&ps=10';
Network_util._get(url,
function(res){
That.setData({
List:res.data.result.list,
hidden: true,
Page:1,
hasRefesh:false,
});
},function(res){
console.log(res);
})
},
})
All resources on this site are contributed by netizens or reprinted by major download sites. Please check the integrity of the software yourself! All resources on this site are for learning reference only. Please do not use them for commercial purposes. Otherwise, you will be responsible for all consequences! If there is any infringement, please contact us to delete it. Contact information: admin@php.cn
Related Article
03 Jan 2025
VS Code Unable to Build C Program with Multiple .cpp Source FilesOne of the common challenges in using VS Code for C development is building...
26 Dec 2024
Creating Executable JAR Files for Java Swing ApplicationsQuestion:For a Java Swing program with multiple source files, how can I create an...
17 Jan 2025
Generating C# Source Code from a .NET EXEWhen the source code for a C# application is lost, generating the code from the EXE file can be crucial....
03 Jan 2025
Why is Apache Rendering PHP Source Code Instead of Executing It?Finding yourself confronted with Apache revealing the PHP source code instead of...
17 Jan 2025
Setting Image Source in WPF Code: Understanding Pack URIsIn WPF, setting an image's source in code is a common task. However, when dealing with...
17 Jan 2025
Recovering C# Source Code from a .NET EXE:The loss of source code for a deployed .NET application can be a frustrating predicament. To address...
17 Jan 2025
Retrieving C# Source Code from a Compiled .NET EXEMaintaining access to the original source code of a .NET executable (.EXE) can be crucial for...
17 Jan 2025
Setting WPF Image Source in Code Using Pack URIsIn WPF, setting an image's source in code is often done when the image is embedded as a resource...
28 Dec 2024
Multithreading Program Optimization WoesIn your code, you have a multithreaded program where a separate thread increments a counter while the main...
Hot Tools
WeChat mini program demo: imitation mall
WeChat mini program demo: imitating a mall, easy to get started, and has a good introduction to some basic functions of the mall
Takeaway: Implement anchor-like functionality
It is the similar anchor function that everyone needs. In addition, it also implements the typical ordering functions of some takeout apps. It is recommended to study and study;
WeChat mini program demo: Lezhu
WeChat mini program demo: Lezhu: similar to location-based; helpful application, somewhat similar to the spirit of Zhang Xiaolong’s mini program.
WeChat mini program game demo selects different color blocks
WeChat mini program game demo selects different color blocks
WeChat applet demo: carousel image transformation
Carousel chart style change, a simple carousel chart implemented with a small program, easy to write