From cb56e36bf38da3da600c871416e8b55314620463 Mon Sep 17 00:00:00 2001 From: 26947 <12@1> Date: Wed, 5 Jun 2024 19:52:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B4=BB=E5=8A=A8=E5=88=97=E8=A1=A8=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E7=AE=80=E5=8D=95=E8=81=94=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/activityInfo/info.js | 2 +- main.js | 1 + pages/activity/index.vue | 203 +++++++++++++++++++++------------------ pages/activity/info.vue | 53 ++++++++-- 4 files changed, 158 insertions(+), 101 deletions(-) diff --git a/api/activityInfo/info.js b/api/activityInfo/info.js index d1e0d7e..4657952 100644 --- a/api/activityInfo/info.js +++ b/api/activityInfo/info.js @@ -12,7 +12,7 @@ export function listInfo(query) { // 查询活动详情详细 export function getInfo(id) { return request({ - url: '/activityInfo/info/' + id, + url: '/activityInfo/info/app/' + id, method: 'get' }) } diff --git a/main.js b/main.js index fcae548..08620ce 100644 --- a/main.js +++ b/main.js @@ -4,6 +4,7 @@ import store from './store' // store import { install } from './plugins' // plugins import './permission.js' // permission import iconConfig from './utils/icon/icon.js' + // main.js import uviewPlus from 'uview-plus' import { parseTime, resetForm, addDateRange, handleTree, selectDictLabel, selectDictLabels } from '@/utils/ruoyi' diff --git a/pages/activity/index.vue b/pages/activity/index.vue index 038c2fd..ab202f3 100644 --- a/pages/activity/index.vue +++ b/pages/activity/index.vue @@ -40,10 +40,10 @@ - + - + @@ -52,7 +52,7 @@ import { listInfo, getInfo, delInfo, addInfo, updateInfo } from "@/api/activityI import ActiInfoList from '../common/activityList/index.vue' import { onShow, onLoad } from '@dcloudio/uni-app' import { getDicts } from "@/api/system/dict/data" -import { ref, reactive, getCurrentInstance,toRefs } from 'vue' +import { ref, reactive, getCurrentInstance, toRefs } from 'vue' import { useStore } from 'vuex'; const { proxy } = getCurrentInstance(); const iconConfig = proxy.iconConfig; @@ -75,92 +75,94 @@ const list4 = reactive([ ]); const actiInfoList = ref([]); const data = reactive({ - form: {}, - queryParams: { - pageNum: 1, - pageSize: 5, - launchUserId: null, - accendCondition: null, - acName: null, - acTitle: null, - acContent: null, - startTime: null, - endTime: null, - state: null, - addres: null, - longitude: null, - latitude: null, - file: null, - elroll: null, - acQrcode: null, - tab: null, - readCount: null, - transmitCount: null, - likeCount: null, - commentCount: null, - favoriteCount: null, - postTop: null, - type: null, - anonymity: null, - auditor: null, - auditStatus: null, - auditTime: null, - auditAdvice: null, - cut: null, - }, - rules: { - auditStatus: [ - { required: true, message: "状态0正常1待脱敏 2待审核 3脱敏未通过 4 审核未通过 5草稿不能为空", trigger: "change" } - ], - } + form: {}, + queryParams: { + pageNum: 1, + pageSize: 5, + launchUserId: null, + accendCondition: null, + acName: null, + acTitle: null, + acContent: null, + startTime: null, + endTime: null, + state: null, + addres: null, + longitude: null, + latitude: null, + file: null, + elroll: null, + acQrcode: null, + tab: null, + readCount: null, + transmitCount: null, + likeCount: null, + commentCount: null, + favoriteCount: null, + postTop: null, + type: null, + anonymity: null, + auditor: null, + auditStatus: null, + auditTime: null, + auditAdvice: null, + cut: null, + }, + rules: { + auditStatus: [ + { required: true, message: "状态0正常1待脱敏 2待审核 3脱敏未通过 4 审核未通过 5草稿不能为空", trigger: "change" } + ], + } }); const { queryParams, form, rules } = toRefs(data); // 表单重置 function reset() { - form.value = { - id: null, - launchUserId: null, - accendCondition: null, - acName: null, - acTitle: null, - acContent: null, - startTime: null, - endTime: null, - state: null, - addres: null, - longitude: null, - latitude: null, - file: null, - elroll: null, - acQrcode: null, - tab: null, - readCount: null, - transmitCount: null, - likeCount: null, - commentCount: null, - favoriteCount: null, - postTop: null, - type: null, - anonymity: null, - createTime: null, - auditor: null, - auditStatus: null, - auditTime: null, - auditAdvice: null, - cut: null, - delFlag: null - }; - proxy.resetForm("infoRef"); + form.value = { + id: null, + launchUserId: null, + accendCondition: null, + acName: null, + acTitle: null, + acContent: null, + startTime: null, + endTime: null, + state: null, + addres: null, + longitude: null, + latitude: null, + file: null, + elroll: null, + acQrcode: null, + tab: null, + readCount: null, + transmitCount: null, + likeCount: null, + commentCount: null, + favoriteCount: null, + postTop: null, + type: null, + anonymity: null, + createTime: null, + auditor: null, + auditStatus: null, + auditTime: null, + auditAdvice: null, + cut: null, + delFlag: null + }; + proxy.resetForm("infoRef"); } /** 查询活动详情列表 */ function getList() { - queryParams.value.params = {}; + queryParams.value.params = {}; - listInfo(queryParams.value).then(response => { - console.log(response); - actiInfoList.value = response.rows; - total.value = response.total; - }); + listInfo(queryParams.value).then(response => { + actiInfoList.value = response.rows; + response.rows.forEach(item => { + actiInfoList.value.push(item) + }) + total.value = response.total; + }); } onLoad((options) => { getList(); @@ -170,15 +172,31 @@ onShow(() => { console.log('Page onShow') }) -const scrolltolower = () => { - console.log("scrolltolower"); - actiInfoList.value.push({ - title: '怎么评论爱德华·艾尔加这位音乐家及其他的作品,欢迎大家发表自己的看法?', - startTime: '2023-05-01 15:00', - endTime: '2023-05-01 16:00', - state: '2', - addrs: '天津电子信息职业技术学院操场东面' - }) +// 在data中添加isLoading标志 +const isLoading = ref(false); + +const scrolltolower = async () => { + // 检查是否还有更多数据可以加载 + if (queryParams.value.pageNum * queryParams.value.pageSize < total.value) { + // 防止在数据加载时重复触发 + if (isLoading.value) return; + isLoading.value = true; + + queryParams.value.pageNum += 1; + try { + const response = await listInfo(queryParams.value); + // 使用Array.prototype.push.apply将新数据追加到actiInfoList中 + Array.prototype.push.apply(actiInfoList.value, response.rows); + console.log(actiInfoList.value); + } catch (error) { + console.error("加载更多数据时发生错误:", error); + } finally { + isLoading.value = false; + } + } else { + // 可以在这里处理没有更多数据的情况,例如显示提示信息 + console.log("没有更多数据了"); + } }; @@ -190,10 +208,7 @@ function toESearch() {