diff --git a/common/commonJS.js b/common/commonJS.js index a9725ada..0d7b9682 100644 --- a/common/commonJS.js +++ b/common/commonJS.js @@ -33,6 +33,18 @@ export default { } }) }, + refreshPrevPageData(reset) { + const pages = getCurrentPages(); // 当前页面栈 + if (pages.length > 1) { + const prevPage = pages[pages.length - 2]; // 上一页实例 + if (prevPage && typeof prevPage.refreshData === 'function') { + console.log('at line 514:', '调用刷新函数') + prevPage.refreshData(reset); // 调用刷新函数 + + } + } + uni.navigateBack({ delta: 1 }); + }, //复制内容 handleCopy(value, title) { uniCopy({ @@ -44,22 +56,22 @@ export default { }) }, error: (e) => { - + } }) }, //用户协议 - async getAgreement(id) { + async getAgreement(id) { console.log('id at line 56:', id) var data = { id: id } var result = { - title:'', - content:'' + title: '', + content: '' } - await $http + await $http .request({ url: "sys/agreement/getAgreement", method: "POST", @@ -111,8 +123,8 @@ export default { } }, }); - }, - // 注销账户 + }, + // 注销账户 logout() { let that = this; uni.showModal({ diff --git a/common/debounce.js b/common/debounce.js index ad3996bb..15d310af 100644 --- a/common/debounce.js +++ b/common/debounce.js @@ -25,5 +25,35 @@ function debounce(func, wait = 500, immediate = false) { }, wait) } } - -export default debounce +function throttle(fn, delay = 1000, immediate = false) { + console.log("进入节流对象") + let timer + let status = false // 是否为重复点击状态 + return function () { + let _this = this + let args = arguments + + if (immediate) { + console.log("立即执行参数 执行一次方法") + fn.apply(_this, args) + immediate = false + return + } + if (status) { + console.log("当前点击状态为正在重复点击,请稍等片刻后在点击执行") + return + } + console.log("执行节流:当前执行了一次点击方法") + fn.apply(_this, args) + status = true // 修改状态 + timer = setTimeout(() => { + console.log("规定时间到,重置状态,可以重新调用") + status = false + }, delay) + } + } + + export { + debounce, + throttle + } diff --git a/components/qizai-dynamic/Dynamic.vue b/components/qizai-dynamic/Dynamic.vue index 1cb9b8ef..24b93370 100644 --- a/components/qizai-dynamic/Dynamic.vue +++ b/components/qizai-dynamic/Dynamic.vue @@ -10,7 +10,8 @@ mode="aspectFill" class="user__header-image" > - {{ name }} - {{ - createTime + + createTime }} - - - - {{ title }} + + + {{ title }} - - - - - + font-size: 28rpx; + " + /> + + + + + - - - - + + + + + + {{ + likeList + .map((item) => + item.user.nickname ? item.user.nickname : "普通用户" + ) + .join(" , ") + }} + + + + {{ likeCount ? likeCount : "0" }} + + {{ commentCount ? commentCount : "0" }} - {{ likeList.map(item => item.user.nickname?item.user.nickname:'普通用户').join(' , ') }} - - - - - {{ likeCount ? likeCount : "0" }} - - {{ commentCount ? commentCount : "0" }} + + 分享 + + - - 分享 - - - - -