123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- // index.js
- Page({
- data: {
- // 轮播图配置
- indicatorDots: true,
- autoplay: true,
- interval: 5000,
- duration: 1000,
- circular: true,
-
- // 轮播图数据
- swiperList: [
- {
- id: 1,
- imageUrl: '../../imgs/guicang/haiwaiwenwu.png',
- title: '唐代三彩骆驼骑俑',
- date: '2023-06-30',
- source: '珍藏馆'
- },
- {
- id: 2,
- imageUrl: '../../imgs/guicang/haiwaiwenwu.png',
- title: '明代青花瓷器',
- date: '2023-06-29',
- source: '国家博物馆'
- },
- {
- id: 3,
- imageUrl: '../../imgs/guicang/haiwaiwenwu.png',
- title: '清代玉器',
- date: '2023-06-28',
- source: '故宫博物院'
- },
- {
- id: 4,
- imageUrl: '../../imgs/guicang/haiwaiwenwu.png',
- title: '宋代瓷器',
- date: '2023-06-27',
- source: '上海博物馆'
- }
- ],
-
- // 最新上传数据
- latestUploads: [],
-
- // 分页数据
- currentPage: 1,
- pageSize: 9,
- hasMoreData: true,
- loading: false
- },
-
- onLoad: function(options) {
- // 初始化最新上传数据
- this.loadLatestUploads();
- },
-
- // 加载最新上传数据
- loadLatestUploads: function() {
- if (!this.data.hasMoreData) return;
-
- this.setData({ loading: true });
-
- // 模拟数据加载
- setTimeout(() => {
- const newItems = this.getMockData(this.data.currentPage, this.data.pageSize);
- const hasMore = this.data.currentPage < 3; // 模拟只有3页数据
-
- this.setData({
- latestUploads: [...this.data.latestUploads, ...newItems],
- currentPage: this.data.currentPage + 1,
- hasMoreData: hasMore,
- loading: false
- });
- }, 1000);
- },
-
- // 生成模拟数据
- getMockData: function(page, pageSize) {
- const result = [];
- const startIndex = (page - 1) * pageSize;
-
- for (let i = 0; i < pageSize; i++) {
- result.push({
- id: startIndex + i + 1,
- imageUrl: '../../imgs/guicang/haiwaiwenwu.png'
- });
- }
-
- return result;
- },
-
- // 跳转到详情页
- goToDetail: function(e) {
- const id = e.currentTarget.dataset.id;
- wx.navigateTo({
- url: '../guicangDetails/index?id=' + id
- });
- },
-
- // 下拉刷新
- onPullDownRefresh: function() {
- this.setData({
- latestUploads: [],
- currentPage: 1,
- hasMoreData: true
- });
-
- this.loadLatestUploads();
- wx.stopPullDownRefresh();
- },
-
- // 上拉加载更多
- onReachBottom: function() {
- if (!this.data.loading && this.data.hasMoreData) {
- this.loadLatestUploads();
- }
- },
-
- onReady: function() {
- // 页面初次渲染完成时执行的函数
- },
-
- onShow: function() {
- // 页面显示时执行的函数
- },
-
- onHide: function() {
- // 页面隐藏时执行的函数
- },
-
- onUnload: function() {
- // 页面卸载时执行的函数
- }
- })
|