From feac3406f92cb76a22571552a433249aab4dbbb7 Mon Sep 17 00:00:00 2001 From: "978184212@qq.com" <978184212@qq.com> Date: Fri, 21 Aug 2026 17:28:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=9C=B0=E5=9B=BE=E4=B9=9F?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E7=99=BB=E5=BD=95=E8=B7=B3=E8=BD=AC=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packDetail/pages/Site/index.vue | 119 +++-- packDetail/pages/login/login.vue | 30 +- pages/maps/index.vue | 870 ++++++++++++++++++------------- 3 files changed, 596 insertions(+), 423 deletions(-) diff --git a/packDetail/pages/Site/index.vue b/packDetail/pages/Site/index.vue index 9cf7270..6afd9b9 100644 --- a/packDetail/pages/Site/index.vue +++ b/packDetail/pages/Site/index.vue @@ -87,6 +87,7 @@ pageNo:1, pageSize:4, isRefresher: false, //下拉刷新状态 + isLoading: false, // 添加加载状态锁 } }, onLoad() { @@ -111,62 +112,68 @@ refresherpullingFun() { this.isRefresher= true }, - getList(){ - let params = {} - params.pageNo = this.pageNo - params.pageSize = this.pageSize - uni.showLoading({ - title: '加载中' - }); - this.List = [] - this.$http.get('/applet/survStationInfo/page',{params:params}).then(res =>{ - if(res.data.code == 0){ - var data = res.data.data.records - this.List = this.List.concat(data) - for(var i=0;i= 10000 && this.List[i].deviceCount < 100000000){ - this.List[i].deviceCount = (this.List[i].deviceCount /10000).toFixed(1) + '万' - } - if(this.List[i].deviceCount >= 100000000){ - this.List[i].deviceCount = (this.List[i].deviceCount /100000000).toFixed(1) + '亿' - } - if(this.List[i].survObj.length >= 10000 && this.List[i].survObj.length < 100000000){ - this.List[i].survObj.length = (this.List[i].survObj.length /10000).toFixed(1) + '万' - } - if(this.List[i].survObj.length >= 100000000){ - this.List[i].survObj.length = (this.List[i].survObj.length /100000000).toFixed(1) + '亿' - } - if(this.List[i].survDataCount >= 10000 && this.List[i].survDataCount < 100000000){ - this.List[i].survDataCount = (this.List[i].survDataCount /10000).toFixed(1) + '万' - } - if(this.List[i].survDataCount >= 100000000){ - this.List[i].survDataCount = (this.List[i].survDataCount /100000000).toFixed(1) + '亿' - } - } - if(res.data.data.total != 0){ - this.allNum = Number(res.data.data.total)/Number(this.pageSize)+''; - if(this.allNum.indexOf('.') == -1) { - this.allNum = this.allNum; - } else { - this.allNum = parseInt(Number(this.allNum)+1); - } - if(this.pageNo == this.allNum) { - this.isLastpage = true; - this.loadStatus='nomore' - } else { - this.isLastpage = false; - // this.isLoadMore=true - this.loadStatus = 'more' - } - }else{ - this.isLastpage = true; - this.loadStatus='nomore' - } - } - uni.hideLoading(); - this.isRefresher= false - }) - }, + getList(isRefresh = false) { + // 防止重复请求 + if (this.isLoading) return + this.isLoading = true + + let params = { + pageNo: this.pageNo, + pageSize: this.pageSize + } + + // 只有首次加载才显示全局loading + if (this.pageNo === 1 && !isRefresh) { + uni.showLoading({ title: '加载中' }) + } + + // 首次加载清空列表,下拉刷新时不清空 + if (this.pageNo === 1 && !isRefresh) { + this.List = [] + } + + this.$http.get('/applet/survStationInfo/page', { params }).then(res => { + this.isLoading = false + uni.hideLoading() + this.isRefresher = false + + if (res.data.code === 0) { + let data = res.data.data.records || [] + if (this.pageNo === 1) { + this.List = data + } else { + this.List = this.List.concat(data) + } + + // 格式化数据 + this.formatData() + + // 更新分页状态 + this.updatePaginationStatus(res.data.data.total) + } + }).catch(err => { + this.isLoading = false + uni.hideLoading() + this.isRefresher = false + }) + }, + formatData() { + // 将数据格式化逻辑提取出来 + this.List.forEach(item => { + item.deviceCount = this.formatNumber(item.deviceCount) + item.survObj.length = this.formatNumber(item.survObj.length) + item.survDataCount = this.formatNumber(item.survDataCount) + }) + }, + + formatNumber(num) { + if (num >= 100000000) { + return (num / 100000000).toFixed(1) + '亿' + } else if (num >= 10000) { + return (num / 10000).toFixed(1) + '万' + } + return num || 0 + }, lower() { // 最后一页了,取消下拉功能 if (this.isLastpage) { diff --git a/packDetail/pages/login/login.vue b/packDetail/pages/login/login.vue index 2a6b8d1..9e578c4 100644 --- a/packDetail/pages/login/login.vue +++ b/packDetail/pages/login/login.vue @@ -97,24 +97,28 @@ export default { this.CustomTop = this.Custom.top }, onShow() { - var that = this + // 检查是否已登录 + const token = uni.getStorageSync('constant'); + if (token) { + // 已登录,直接跳转首页 + uni.reLaunch({ + url: '/pages/index/index' + }); + return; + } + + // 未登录才执行微信登录流程 + var that = this; uni.login({ success: function (res) { - that.code = res.code - let params = {} - params.jsCode = that.code + that.code = res.code; + let params = {}; + params.jsCode = that.code; api.wxlogin(params).then(res => { let userInfo = res.data.data; uni.setStorageSync('third_session', userInfo.thirdSession); - // api.loginCallback(res, ()=>{ - // that.login = false - // uni.reLaunch({ - // url: '/pages/index/index' - // }) - // }, ()=>{ - // that.login = true - // }); - }) + // 注意:这里不要自动跳转,只存储 session + }); } }); }, diff --git a/pages/maps/index.vue b/pages/maps/index.vue index 71a0967..cc596e7 100644 --- a/pages/maps/index.vue +++ b/pages/maps/index.vue @@ -50,369 +50,531 @@