微信小程序,加载更多
html
<!-- 头部 -->
<view class='tab'>
<view class="tab-new {{selected_new?'active':'default'}}" bindtap="selectedNew">最新理财</view>
<view class="tab-old {{selected_old?'active':'default'}}" bindtap="selectedOld">往期理财</view>
</view>
<!-- 列表 -->
<view class='list'>
<block wx:if="{{render_list.length == 0}}">
<view class="list-empty">
暂无理财产品数据
</view>
</block>
<block wx:else>
<block wx:for="{{render_list}}">
<view class='list-item' bindtap='gotoDetail' data-id="{{item.id}}">
<view class='list-item-left'>
<view class="left-yield">{{item.yield}}</view>
<view class="left-yield-name">预计年化收益率</view>
<view class="left-property">产品性质:{{item.property}}</view>
</view>
<view class='list-item-right'>
<view class='right-name'>{{item.name}}</view>
<view>起购金额:
<span class='right-font-black'>{{item.purchase_money}}</span>
</view>
<view>理财期限:
<span class='right-font-black'>{{item.time_limit}}</span>
</view>
<view>开始时间:{{item.start_time}}</view>
<view>结束时间:{{item.end_time}}</view>
</view>
<view class="list-item-top {{item.is_rec==1?'top-rec':''}}">
荐
</view>
<view class="list-item-top {{item.is_new==1?'top-new':''}} {{item.is_new==1 && item.is_rec==1?'top-margin-right':''}}">
新
</view>
<image class="list-item-arrow" src="/img/common/right.png"></image>
</view>
</block>
</block>
</view>
css
/* 先外后里,由上而下,由左而右 大小要计算 */
.tab {
display: flex;
height: 70rpx;
line-height: 70rpx;
margin-top: 45rpx;
}
.tab .tab-new {
width: 50%;
text-align: center;
}
.tab .tab-old {
width: 50%;
text-align: center;
}
.tab .active {
font-size: 34rpx;
font-weight: bold;
color: #222;
position: relative;
}
.tab .active::after {
content: "";
width: 150rpx;
height: 6rpx;
background: rgba(2, 101, 255, 1);
position: absolute;
bottom: 0rpx;
left: 50%;
transform: translateX(-50%);
}
.tab .default {
font-size: 28rpx;
font-weight: 500;
color: #666;
}
.list {
padding: 40rpx 20rpx;
width: 100%;
height: 100%;
}
.list-empty {
width: 100%;
height: auto;
text-align: center;
color:rgba(102, 102, 102, 1);
font-size: 30rpx;
position: fixed;
top: 40%;
left:50%;
transform: translate(-50%, -60%);
}
.list .list-item {
margin-bottom: 30rpx;
padding-top: 15rpx;
width: 100%;
height: 244rpx;
display: flex;
position: relative;
}
.list .list-item .list-item-left {
width: 320rpx;
padding-left: 23rpx;
}
.list-item-left .left-yield {
line-height: 70rpx;
font-size: 50rpx;
color: rgba(255, 0, 0, 1);
padding-top:25rpx;
}
.list-item-left .left-yield-name {
font-size:26rpx;
color:rgba(102,102,102,1);
line-height:30rpx;
}
.list-item-left .left-property {
width: auto;
font-size:26rpx;
color:rgba(255,98,4,1);
line-height:30rpx;
border:1rpx solid rgba(255,98,4,1);
border-radius:4rpx;
margin-top:10rpx;
float:left;
}
.list .list-item .list-item-right {
width: 390rpx;
font-size: 24rpx;
color: rgba(102, 102, 102, 1);
line-height: 38rpx;
}
.list-item-right .right-name {
font-size: 30rpx;
color: rgba(34, 34, 34, 1);
line-height: 48rpx;
}
.list-item-right .right-font-black {
font-size:26rpx;
color:#333333;
}
.list .list-item .list-item-top {
position: absolute;
top: 0rpx;
right: 23rpx;
display: none;
font-weight: 400;
font-size: 30rpx;
color: #fff;
padding: 8rpx;
border-bottom-left-radius: 10rpx;
border-bottom-right-radius: 10rpx;
}
.list .list-item .top-margin-right {
right: 75rpx;
}
.list .list-item .top-rec {
display: block;
background-color: #ff404a;
}
.list .list-item .top-new {
display: block;
background-color: #0265ff;
}
.list .list-item .list-item-arrow {
position: absolute;
top: 50%;
transform: translateY(-50%);
width: 16rpx;
height: 28rpx;
right: 38rpx;
}
js
const util = require('../../../utils/getData.js');
Page({
/**
* 页面的初始数据
*/
data: {
'selected_new': true,
'selected_old': false,
'type': 1,
'page': 1,
'page_size':4,
'render_list': []
},
initData: function() {
let that = this;
let page = that.data.page;
wx.showNavigationBarLoading(); //在标题栏中显示加载
util.getData('getFinanceList', {
page: page,
page_size:that.data.page_size,
type: that.data.type,
method: 'POST'
}, function(data) {
wx.hideNavigationBarLoading();
let data_list = data.data.data_list;
if (page != 1 && data_list.length == 0) {
wx.showToast({
title: "已经到底啦",
icon: "none",
duration: 1000,
mask: false,
});
return;
}
let render_list = [];
if (page != 1) {
render_list = that.data.render_list;
}
let new_render_list = render_list.concat(data_list);
page++;
that.data.page = page;
that.setData({
render_list: new_render_list
});
})
},
selectedNew: function() {
let that = this;
if (!that.data.selected_new) {
that.setData({
selected_new: true,
selected_old: false,
page:1,
type:1,
render_list:[]
});
that.initData();
}
},
selectedOld: function() {
let that = this;
if (!that.data.selected_old) {
that.setData({
selected_new: false,
selected_old: true,
page:1,
type: 2,
render_list: []
});
}
},
gotoDetail:function(e) {
let finance_id = e.currentTarget.dataset.id;
wx.navigateTo({
url: '/pages/finance/detail/index?id=' + finance_id
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
let that = this;
that.initData();
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function() {
let that = this;
that.initData();
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function() {
}
})
微信小程序,加载更多的更多相关文章
- 微信小程序 加载图片时,先拉长,再恢复正常
今天在写小程序,发现小程序的图片image如过mode设置为widthFix的话, 加载图片会被先拉伸,后恢复正常 我的处理方法是,给他一个初始的height值,或者就直接 height:auto
- 微信小程序 加载 HTML 标签
肯定有小伙伴遇到过这个问题:加载的数据是一堆HTML 标签这就尴尬了,因为小程序没有提供 webview 来加载这些 HTML.但是不用慌,小程序不提供我们可以自己造个新轮子,自己造不出新轮子咱们找到 ...
- 微信小程序加载本地图片方法
目录结构如下,只要图片按正确的方式放入小程序的开发工具的项目中,即可在wxml文件中用内联样式或者image标签都可以引用本地的图片. 步骤一:微信开发工具 打开项目 步骤二:新建个文件夹(放项目的一 ...
- 利用机器学习实现微信小程序-加减大师自动答题
之前有看到微信小程序<跳一跳>别人用python实现自动运行,后来看到别人用hash码实现<加减大师>的自动答题领取娃娃,最近一直在研究深度学习,为啥不用机器学习实现呢?不就是 ...
- [Cocos Creator]安卓上微信小游戏加载到100%就进不去了
最近用Cocos Creator 开发微信小游戏,构建发布到微信上,用安卓手机预览打开后加载到100%就不动了,开始以为微信开发工具版本的问题,后来用苹果的手机测试了一下,发现也有同样的问题. 仔细分 ...
- mpvue 小程序加载不了图片 Error: Failed to load local image resource /images/xx.png the server responded with a status of 404 (HTTP/1.1 404 Not Found)
mpvue开发小程序时候,要添加静态本地图片 <img src="../../images/bg.png" alt=""> 会报错: VM14878 ...
- mpvue小程序加载不出图片 Failed to load local image resource /images/xx.png
解决方法: 直接写 /static/img/xx.png(一定要从 "/static" 开始,不要写成 "../../static" ,当然static里面也可 ...
- 小程序加载大图片 使用widthFix时,图片先拉伸然后才显示完全
<image src="http://www.ll.com/sss.jpg" mode="widthFix" style="width:180r ...
- mpvue小程序加载不出图片 Failed to load local image resource
我的GitHub博客,很多内容可以看,喜欢的给星星哦 https://github.com/liangfengbo/frontend 第一道:图片引入本地静态文件失效? mpvue开发小程序时候,要添 ...
- 微信小程序------加导航
效果图如下 这个其实很简单 在app.json上面加点代码 "window":{ "backgroundTextStyle":"light" ...
随机推荐
- POJ 2248 - Addition Chains - [迭代加深DFS]
题目链接:http://bailian.openjudge.cn/practice/2248 题解: 迭代加深DFS. DFS思路:从目前 $x[1 \sim p]$ 中选取两个,作为一个新的值尝试放 ...
- Codeforces 607A - Chain Reaction - [DP+二分]
题目链接:https://codeforces.com/problemset/problem/607/A 题意: 有 $n$ 个塔排成一行,第 $i$ 个激光塔的位置为 $a_i$,伤害范围是 $b_ ...
- sqlserver开启远程访问
1.通过本地连接数据库,选择数据库——右键——属性 2.在连接选项勾选“允许远程连接到此服务器” 3.打开sqlserver配置管理器 4.到sqlserver网络配置——XXX的协议——TCP/IP ...
- xss脚本绕过限制的方法
第一关:第一关比较简单,直接写入标签就可以,这里不多说了,payload如下: http://sqler.win/xss/level1.php?name=test%3Csvg/onload=alert ...
- 并行开发-Task
Task 对于多线程,经常使用的是Thread.在了解Task之前,如果要使用多核的功能可能就会自己来开线程,然而这种线程模型在.net 4.0之后被一种称为基于“任务的编程模型”所冲击,这就是Tas ...
- python 发送无附件邮件
import smtplibimport tracebackfrom email.mime.text import MIMETextfrom config.config import * ...
- STL库学习笔记(待补充QAQ
几百年前就说要学STL了然后现在还没动呢QAQ总算还是克服了懒癌决定学下QAQ 首先港下有哪几个vector listset map stack queue,大概就这些? 然后因为有几个基本操作每个都 ...
- androidj基础:从网上下载图片
一.布局文件 设置界面,添加一个ImageView,和两个Button按钮,设置其属性及id <ImageView android:id="@+id/ImageView" a ...
- 列表 & 元组& join & range
一:列表(增删改查,列表的嵌套,列表的循环) 1)增加 append (在列表的尾部增加) insert (插入) insert(插入的位置,插入的内容) extend ...
- 关于什么是SpringMVC,和SpringMVC基于xml配置、注解配置、纯注解配置
首先我们先要了解一下,什么是SpringMVC? SpringMVC是Spring框架内置的MVC的实现.SpringMVC就是一个Spring内置的MVC子框架,也就是说SpringMVC的相关包都 ...