var requests = require('../../requests/request.js');
var utils = require('../../utils/util.js');
//刷新动态球颜色
var iconColor = [
'#42BD56', '#31A040'
];
Page({
data: {
scrollHeight: 0, //scroll-view高度
pageIndex: 0, //页码
totalRecord: 0, //图书总数
isInit: true, //是否第一次进入应用
loadingMore: false, //是否正在加载更多
footerIconColor: iconColor[0], //下拉刷新球初始颜色
pageData: [], //图书数据
searchKey: null //搜索关键字
},
//页面显示获取设备屏幕高度,以适配scroll-view组件高度
onShow: function () {
wx.getSystemInfo({
success: (res) => {
console.log(res)
this.setData({
scrollHeight: res.windowHeight - (100 * res.windowWidth / 750) //80为顶部搜索框区域高度 rpx转px 屏幕宽度/750
});
}
})
},
//搜索输入框输入取值
searchInputEvent: function (e) {
this.setData({ searchKey: e.detail.value });
},
//搜索按钮点击事件
searchClickEvent: function (e) {
if (!this.data.searchKey) {
return;
}
this.setData({ pageIndex: 0, pageData: [] });
requestData.call(this);
},
//下拉请求数据
scrollLowerEvent: function (e) {
if (this.data.loadingMore)
return;
requestData.call(this);
},
//跳转到详细页面
toDetailPage: function (e) {
var bid = e.currentTarget.dataset.bid; //图书id [data-bid]
wx.navigateTo({
url: '../detail/detail?id=' + bid
});
}
});
/**
* 请求图书信息
*/
function requestData() {
var _this = this;
var q = this.data.searchKey;
var start = this.data.pageIndex;
this.setData({ loadingMore: true, isInit: false });
updateRefreshBall.call(this);
console.log(start)
requests.requestSearchBook({ q: q, start: start }, (data) => {
if (data.total == 0) {
//没有记录
_this.setData({ totalRecord: 0 });
} else {
_this.setData({
pageData: _this.data.pageData.concat(data.books),
pageIndex: start + 1,
totalRecord: data.total
});
}
}, () => {
_this.setData({ totalRecord: 0 });
}, () => {
_this.setData({ loadingMore: false });
});
}
/**
* 刷新下拉效果变色球
*/
function updateRefreshBall() {
var cIndex = 0;
var _this = this;
var timer = setInterval(function () {
if (!_this.data['loadingMore']) {
clearInterval(timer);
}
if (cIndex >= iconColor.length)
cIndex = 0;
_this.setData({ footerIconColor: iconColor[cIndex++] });
}, 100);
}
没有合适的资源?快使用搜索试试~ 我知道了~
小程序源码 豆瓣图书 (代码+截图)
共16个文件
js:6个
wxss:3个
jpg:3个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
5星 · 超过95%的资源 1 下载量 62 浏览量
2022-06-19
09:03:50
上传
评论
收藏 58KB RAR 举报
温馨提示
小程序源码 豆瓣图书 (代码+截图)小程序源码 豆瓣图书 (代码+截图)小程序源码 豆瓣图书 (代码+截图)小程序源码 豆瓣图书 (代码+截图)小程序源码 豆瓣图书 (代码+截图)小程序源码 豆瓣图书 (代码+截图)小程序源码 豆瓣图书 (代码+截图)小程序源码 豆瓣图书 (代码+截图)小程序源码 豆瓣图书 (代码+截图)小程序源码 豆瓣图书 (代码+截图)小程序源码 豆瓣图书 (代码+截图)小程序源码 豆瓣图书 (代码+截图)小程序源码 豆瓣图书 (代码+截图)小程序源码 豆瓣图书 (代码+截图)小程序源码 豆瓣图书 (代码+截图)小程序源码 豆瓣图书 (代码+截图)小程序源码 豆瓣图书 (代码+截图)小程序源码 豆瓣图书 (代码+截图)小程序源码 豆瓣图书 (代码+截图)小程序源码 豆瓣图书 (代码+截图)小程序源码 豆瓣图书 (代码+截图)小程序源码 豆瓣图书 (代码+截图)小程序源码 豆瓣图书 (代码+截图)小程序源码 豆瓣图书 (代码+截图)小程序源码 豆瓣图书 (代码+截图)小程序源码 豆瓣图书 (代码+截图)小程序源码 豆瓣图书 (代码+截图)小程序源码 豆瓣图书 (代码
资源推荐
资源详情
资源评论
收起资源包目录
小程序源码 豆瓣图书 (代码+截图).rar (16个子文件)
豆瓣图书
3.jpg 26KB
2.jpg 22KB
DouBanBookApp
utils
util.js 686B
app.wxss 876B
app.js 719B
pages
detail
detail.js 743B
detail.wxml 1KB
detail.wxss 1KB
index
index.wxml 2KB
index.js 3KB
index.wxss 759B
app.json 257B
images
book.png 2KB
requests
request.js 1KB
api.js 151B
1.jpg 8KB
共 16 条
- 1
资源评论
- 曦岄曦岄2024-02-22资源不错,很实用,内容全面,介绍详细,很好用,谢谢分享。
金枝玉叶9
- 粉丝: 123
- 资源: 7641
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功