diff --git a/page_components/eletj.vue b/page_components/eletj.vue index dbe2aa0..22d31d3 100644 --- a/page_components/eletj.vue +++ b/page_components/eletj.vue @@ -73,15 +73,12 @@ chartday: [], loging: true, deviceId: '', - userType: '' + userType: '', + dateday:'', + monthdui:'' } }, onLoad(e) { - // setTimeout(() => { - - // this.initChart() - // }, 300); - // this.initChart() setTimeout(() => { // console.log(this.$refs) this.$refs.canvas.init(this.initChart) @@ -91,6 +88,8 @@ const now = new Date(); this.yeartime.year = now.getFullYear() this.yeartime.month = now.getMonth() + 1 + this.monthdui = this.yeartime.month + this.dateday = String(now.getDate()).padStart(2, '0') this.gettimes() }, methods: { @@ -114,12 +113,23 @@ this.$u.get('/app/device/electric/count', data).then((res) => { if (res.code == 200) { this.timelist = res.data - this.chartData = this.timelist.map(item => item.usedElectriQuantity); - this.chartday = this.timelist.map(item => item.createDay + '日'); + // this.chartData = this.timelist.map(item => item.usedElectriQuantity); + // this.chartday = this.timelist.map(item => item.createDay + '日'); - // console.log('用电', this.chartData, '时间', this.chartday); + if(this.monthdui != this.yeartime.month){ + this.timelist = this.timelist + this.totalRecharge = res.totalRecharge + this.chartData = this.timelist.map(item => item.usedElectriQuantity); + this.chartday = this.timelist.map(item => item.createDay + '日'); + }else{ + this.timelist = this.timelist.slice(0, 14) + this.timelist.reverse() + this.totalRecharge = res.totalRecharge + this.chartData = this.timelist.slice(0, this.dateday).map(item => item.usedElectriQuantity) + this.chartday = this.timelist.slice(0, this.dateday).map(item => item.createDay + '日'); + } + this.loging=true - // 求用电总度数 this.quantity = 0 for (let i = 0; i < this.timelist.length; i++) { this.quantity += this.timelist[i].usedElectriQuantity @@ -138,103 +148,6 @@ } return data; }, - // async initChart() { - // console.log('111111'); - // let that =this - // // let _this = this - // const option = { - // grid: { - // left: 60, - // right: 10, - // top: 10, - // bottom: 30, - // }, - // xAxis: { - // type: 'category', - // boundaryGap: false, - // axisLine: { - // show: false, - // }, - // axisTick: { - // show: false, - // }, - // axisLabel: { - // show: true, - // color: '#fff', - // fontSize: 11, - // rotate: 0, - // }, - // splitLine: { - // show: false, - // }, - // data:that.chartday, - // }, - // yAxis: { - // show: true, - // axisLine: { - // show: false, - // }, - // axisTick: { - // show: false, - // }, - // axisLabel: { - // show: true, - // color: '#fff', - // fontSize: 11, - // formatter: function(value) { - // // 保留两位小数,没有小数时显示00 - // return value + '度' - // }, - // }, - // splitLine: { - // show: false, - // }, - // }, - // visualMap: { - // type: 'piecewise', - // show: false, - // dimension: 0, - // seriesIndex: 0, - // pieces: [{ - // gt: 1, - // lt: 3, - // color: 'rgba(0, 0, 180, 0.4)', - // }, - // { - // gt: 5, - // lt: 7, - // color: 'rgba(0, 0, 180, 0.4)', - // }, - // ], - // }, - // series: [{ - // type: 'line', - // smooth: 0.6, - // symbol: 'none', - // lineStyle: { - // color: '#E0DBFF', - // width: 4, - // }, - // areaStyle: { - // normal: { - // color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{ - // offset: 0, - // color: '#B4B0F7' - // }, ]), - // }, - // }, - // data:that.chartData, - // }], - // }; - // const chart = await that.$refs.chart.init(echarts) - // console.log(option,'111'); - // // 给折线图赋值 - // // option.series[0].data = that.chartData - // option.xAxis.data = that.chartday - // chart.setOption(option) - // return chart - // }, - // }, initChart(canvas, width, height, canvasDpr) { let that = this console.log(canvas, width, height, canvasDpr) diff --git a/page_components/fuwu/index.vue b/page_components/fuwu/index.vue index 1586d07..d4989df 100644 --- a/page_components/fuwu/index.vue +++ b/page_components/fuwu/index.vue @@ -5,7 +5,7 @@ {{deviceobj.deviceName}} - 该设备还剩余时长:{{expireTimeStr + 1}}分钟 + 该设备还剩余时长:{{expireTimeStr}}分钟 联系客服:{{deviceobj.userMobile}} @@ -228,14 +228,23 @@ this.deviceobj = res.data; this.indexactive = res.data.suitList[0].suitId; this.zfobj = res.data.suitList[0] - let targetDateStr = this.deviceobj.expireTime - let targetParts = targetDateStr.split(/[- :]/); - let targetDate = new Date(targetParts[0], targetParts[1] - 1, targetParts[2], targetParts[ - 3], targetParts[4], targetParts[5]); - let now = new Date(); - let differenceInMs = targetDate - now; - let differenceInMinutes = Math.floor(differenceInMs / (1000 * 60)); - this.expireTimeStr = parseInt(differenceInMinutes) <= 0 ? '0' : differenceInMinutes + // let targetDateStr = this.deviceobj.expireTime + // let targetParts = targetDateStr.split(/[- :]/); + // let targetDate = new Date(targetParts[0], targetParts[1] - 1, targetParts[2], targetParts[3], targetParts[4], targetParts[5]); + // let now = new Date(); + // let differenceInMs = targetDate - now; + // let differenceInMinutes = Math.floor(differenceInMs / (1000 * 60)); + // this.expireTimeStr = parseInt(differenceInMinutes) <= 0 ? '0' : differenceInMinutes + let targetDateStr = this.deviceobj.expireTime; + let targetParts = targetDateStr.split(/[- :]/); + let targetDate = new Date(targetParts[0], targetParts[1] - 1, targetParts[2], targetParts[3], targetParts[4], targetParts[5]); + let now = new Date(); + let differenceInMs = targetDate - now; + if (differenceInMs <= 0) { + this.expireTimeStr = '0'; + } else { + this.expireTimeStr = '1' + } } }) }, diff --git a/page_fenbao/statulist/myshop/shopdetail/index.vue b/page_fenbao/statulist/myshop/shopdetail/index.vue index 4b8b15c..a466ccf 100644 --- a/page_fenbao/statulist/myshop/shopdetail/index.vue +++ b/page_fenbao/statulist/myshop/shopdetail/index.vue @@ -184,7 +184,6 @@ let id = getQueryParam(decodedValue, 's') this.$u.get(`/app/device/${id}/bySn`).then((res) => { if (res.code == 200) { - console.log(res,'resres'); this.macs = res.data.mac this.qrResult = 'CTKG-' + res.data.mac xBlufi.initXBlufi(1); diff --git a/page_fenbao/statulist/nearby/index.vue b/page_fenbao/statulist/nearby/index.vue index da5aafa..582fe10 100644 --- a/page_fenbao/statulist/nearby/index.vue +++ b/page_fenbao/statulist/nearby/index.vue @@ -8,7 +8,7 @@ - @@ -35,6 +35,10 @@ {{String(item.distance).split('.')[0]}}m + + + 该区域暂无店铺... + @@ -95,36 +99,42 @@ }, addMarkersWithoutLabels() { this.listmap.forEach((item) => { - const shopCover = { - id: parseFloat(item.storeId), - latitude: item.lat, - longitude: item.lng, - width: 25, - height: 30, - iconPath: 'https://api.ccttiot.com/smartmeter/img/static/uZXgsJE6hXbRSwbKILB4', - }; - this.covers.push(shopCover); - }); + if (item.deviceCount !== null && item.deviceCount > 0) { + const shopCover = { + id: parseFloat(item.storeId), + latitude: item.lat, + longitude: item.lng, + width: 25, + height: 30, + iconPath: 'https://api.ccttiot.com/smartmeter/img/static/uZXgsJE6hXbRSwbKILB4', + } + this.covers.push(shopCover); + } + + }) }, addMarkersWithLabels() { this.listmap.forEach((item) => { - const shopCover = { - id: parseFloat(item.storeId), - latitude: item.lat, - longitude: item.lng, - width: 25, - height: 30, - iconPath: 'https://api.ccttiot.com/smartmeter/img/static/uZXgsJE6hXbRSwbKILB4', - label: { - content: item.name, - anchorX: this.calculateAnchorX(item.name), - fontWeight: 700, - color: '#8883F0', - textShadow: '2px 2px 0px white, -2px -2px 0px white, 2px -2px 0px white, -2px 2px 0px white', + if (item.deviceCount !== null && item.deviceCount > 0) { + const shopCover = { + id: parseFloat(item.storeId), + latitude: item.lat, + longitude: item.lng, + width: 25, + height: 30, + iconPath: 'https://api.ccttiot.com/smartmeter/img/static/uZXgsJE6hXbRSwbKILB4', + label: { + content: item.name, + anchorX: this.calculateAnchorX(item.name), + fontWeight: 700, + color: '#8883F0', + textShadow: '2px 2px 0px white, -2px -2px 0px white, 2px -2px 0px white, -2px 2px 0px white', + } } + this.covers.push(shopCover); } - this.covers.push(shopCover); - }); + + }) }, calculateAnchorX(name) { let chineseLength = 0 @@ -142,7 +152,7 @@ const totalLength = chineseLength + englishLength * 2; // 总长度(以中文字符为单位) return -totalLength * 6.5 // 假设每个中文字符对应的 anchorX 偏移是 -6.5 }, - + onControltap(control) { this.setMapScale() }, @@ -199,51 +209,61 @@ response => { if (response.code == 200) { this.listmap = response.data - this.gxlist = response.data; - this.gxlist.forEach(item => { - // 计算距离 - const distance = this.getDistance(this.latitude, this.longitude, item.lat, item.lng); - // 将距离添加到店铺对象中 - item.distance = distance; - // 创建店铺覆盖物对象 - const shopCover = { - id: parseFloat(item.storeId), - latitude: item.lat, - longitude: item.lng, - width: 25, - height: 30, - iconPath: 'https://api.ccttiot.com/smartmeter/img/static/uZXgsJE6hXbRSwbKILB4', - distance: distance, // 可以在这里也添加距离到覆盖物对象中,但通常只需要在店铺对象中 - label: { - content: item.name, - anchorX: (() => { - if (item.name.length <= 2) { - return -12 - } else if (item.name.length <= 3) { - return -20 - } else if (item.name.length <= 4) { - return -25 - } else if (item.name.length <= 5) { - return -30 - } else if (item.name.length <= 6) { - return -35 - } else if (item.name.length <= 8) { - return -40 - } else if (item.name.length <= - 10) { - return -45 - } else { - return -item.name.length * 5 - } - })(), - fontWeight: 700, - color: '#8883F0', - textShadow: '2px 2px 0px white, -2px -2px 0px white, 2px -2px 0px white, -2px 2px 0px white', + let gxlist = response.data; + gxlist.forEach(item => { + if (item.deviceCount !== null && item.deviceCount > 0) { + // 计算距离 + const distance = this.getDistance(this.latitude, this + .longitude, item.lat, item.lng); + // 将距离添加到店铺对象中 + item.distance = distance; + // 创建店铺覆盖物对象 + const shopCover = { + id: parseFloat(item.storeId), + latitude: item.lat, + longitude: item.lng, + width: 25, + height: 30, + iconPath: 'https://api.ccttiot.com/smartmeter/img/static/uZXgsJE6hXbRSwbKILB4', + distance: distance, // 可以在这里也添加距离到覆盖物对象中,但通常只需要在店铺对象中 + label: { + content: item.name, + anchorX: (() => { + if (item.name.length <= 2) { + return -12 + } else if (item.name.length <= + 3) { + return -20 + } else if (item.name.length <= + 4) { + return -25 + } else if (item.name.length <= + 5) { + return -30 + } else if (item.name.length <= + 6) { + return -35 + } else if (item.name.length <= + 8) { + return -40 + } else if (item.name.length <= + 10) { + return -45 + } else { + return -item.name.length * + 5 + } + })(), + fontWeight: 700, + color: '#8883F0', + textShadow: '2px 2px 0px white, -2px -2px 0px white, 2px -2px 0px white, -2px 2px 0px white', + } } - }; - // console.log(this.gxlist) - this.covers.push(shopCover) // 将店铺覆盖物添加到数组中 - }); + this.covers.push(shopCover) + this.gxlist.push(item) + } + + }) } }).catch(error => { console.error('请求店铺列表失败:', error) @@ -254,14 +274,15 @@ } }); }, - // 计算距离函数 + // 计算距离函数 getDistance(lat1, lon1, lat2, lon2) { const R = 6371000 // 地球半径,单位:米 const phi1 = lat1 * Math.PI / 180 // 纬度转为弧度 const phi2 = lat2 * Math.PI / 180 const deltaPhi = (lat2 - lat1) * Math.PI / 180 const deltaLambda = (lon2 - lon1) * Math.PI / 180 - const a = Math.sin(deltaPhi / 2) * Math.sin(deltaPhi / 2) + Math.cos(phi1) * Math.cos(phi2) * Math.sin(deltaLambda / 2) * Math.sin(deltaLambda / 2) + const a = Math.sin(deltaPhi / 2) * Math.sin(deltaPhi / 2) + Math.cos(phi1) * Math.cos(phi2) * Math.sin( + deltaLambda / 2) * Math.sin(deltaLambda / 2) const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)) const distance = R * c return distance @@ -358,7 +379,7 @@ image { width: 230rpx; - height: 80rpx !important; + // height: 80rpx !important; } .img { diff --git a/page_user/mapditu/index.vue b/page_user/mapditu/index.vue index 811256a..9494a28 100644 --- a/page_user/mapditu/index.vue +++ b/page_user/mapditu/index.vue @@ -124,7 +124,8 @@ }, addMarkersWithoutLabels() { this.listmap.forEach((item) => { - const shopCover = { + if (item.deviceCount !== null && item.deviceCount > 0){ + const shopCover = { id: parseFloat(item.storeId), latitude: item.lat, longitude: item.lng, @@ -133,11 +134,13 @@ iconPath: 'https://api.ccttiot.com/smartmeter/img/static/uZXgsJE6hXbRSwbKILB4', }; this.covers.push(shopCover); + } }); }, addMarkersWithLabels() { this.listmap.forEach((item) => { - const shopCover = { + if (item.deviceCount !== null && item.deviceCount > 0){ + const shopCover = { id: parseFloat(item.storeId), latitude: item.lat, longitude: item.lng, @@ -153,6 +156,8 @@ } } this.covers.push(shopCover); + } + }); }, calculateAnchorX(name) { @@ -227,13 +232,13 @@ mapFun() { uni.openLocation({ - latitude: this.listobj.lat,//纬度 - 目的地/坐标点 - longitude: this.listobj.lng,//经度 - 目的地/坐标点 + latitude: this.listobj.lat, //纬度 - 目的地/坐标点 + longitude: this.listobj.lng, //经度 - 目的地/坐标点 name: this.mapname, //地点名称 address: this.mapaddress //详细地点名称 }); }, - + // 地图回正 async setMapScale(e, val) { let mapContext = uni.createMapContext('map', this); @@ -273,41 +278,50 @@ this.listmap = res.data // 假设返回的店铺数据在res.rows中,并且每个店铺有latitude和longitude字段 res.data.forEach(item => { - const shopCover = { - id: parseFloat(item.storeId), - latitude: item.lat, - longitude: item.lng, - width: 25, - height: 30, - iconPath: 'https://api.ccttiot.com/smartmeter/img/static/uZXgsJE6hXbRSwbKILB4', - label: { - content: item.name, - anchorX: (() => { - if (item.name.length <= 2) { - return -12 - } else if (item.name.length <= 3) { - return -20 - } else if (item.name.length <= 4) { - return -25 - } else if (item.name.length <= 5) { - return -30 - } else if (item.name.length <= 6) { - return -35 - } else if (item.name.length <= 8) { - return -40 - } else if (item.name.length <= - 10) { - return -45 - } else { - return -item.name.length * 5 - } - })(), - fontWeight: 700, - color: '#8883F0', - textShadow: '2px 2px 0px white, -2px -2px 0px white, 2px -2px 0px white, -2px 2px 0px white', - } - }; - this.covers.push(shopCover); + if (item.deviceCount !== null && item.deviceCount > 0) { + const shopCover = { + id: parseFloat(item.storeId), + latitude: item.lat, + longitude: item.lng, + width: 25, + height: 30, + iconPath: 'https://api.ccttiot.com/smartmeter/img/static/uZXgsJE6hXbRSwbKILB4', + label: { + content: item.name, + anchorX: (() => { + if (item.name.length <= 2) { + return -12 + } else if (item.name.length <= + 3) { + return -20 + } else if (item.name.length <= + 4) { + return -25 + } else if (item.name.length <= + 5) { + return -30 + } else if (item.name.length <= + 6) { + return -35 + } else if (item.name.length <= + 8) { + return -40 + } else if (item.name.length <= + 10) { + return -45 + } else { + return -item.name.length * + 5 + } + })(), + fontWeight: 700, + color: '#8883F0', + textShadow: '2px 2px 0px white, -2px -2px 0px white, 2px -2px 0px white, -2px 2px 0px white', + } + }; + this.covers.push(shopCover); + } + }); } }); @@ -436,6 +450,7 @@ width: 150rpx; height: 150rpx; border-radius: 20rpx; + image { width: 150rpx; height: 150rpx; diff --git a/page_user/sbdetail.vue b/page_user/sbdetail.vue index 501b765..1b6afcf 100644 --- a/page_user/sbdetail.vue +++ b/page_user/sbdetail.vue @@ -28,7 +28,7 @@ {{ deviceInfo.deviceName == null ? '' : deviceInfo.deviceName }} - 更新时间:{{deviceInfo.lastPullTime}} + 更新时间:{{deviceInfo.lastPullTime == null ? '--' : deviceInfo.lastPullTime}} @@ -149,16 +149,23 @@ 异常 - + + + + + + + 电量充值 - + @@ -172,20 +179,14 @@ 设置 - + 配网 - - - - - - 充值 - + diff --git a/page_user/setting.vue b/page_user/setting.vue index 148be81..45ae1e4 100644 --- a/page_user/setting.vue +++ b/page_user/setting.vue @@ -31,7 +31,7 @@ - {{listobj.storeName}} + {{listobj.storeName == null ? '' : listobj.storeName}} @@ -63,7 +63,7 @@ - {{listobj.wifi}} + {{listobj.wifi == null ? '' : listobj.wifi}} diff --git a/pages/my.vue b/pages/my.vue index 6a8c072..c4360c7 100644 --- a/pages/my.vue +++ b/pages/my.vue @@ -13,7 +13,7 @@ {{userinfo.nickName == null ? '' : userinfo.nickName}} - 共{{userinfo.storeCount == null ? '' : userinfo.storeCount}}间店铺 + 共{{userinfo.storeCount == null ? 0 : userinfo.storeCount}}间店铺 @@ -26,7 +26,7 @@ - {{userinfo.balance == null ? '' : userinfo.balance}} + {{userinfo.balance == null ? 0 : userinfo.balance}} 钱包余额 @@ -51,10 +51,14 @@ - + 我的店铺 + + + 提交申请后可创建店铺 + 订单记录 @@ -149,6 +153,10 @@ uni.navigateTo({ url:'/page_user/yetx' }) + }else if(num == 9){ + uni.navigateTo({ + url:'/page_fenbao/statulist/merchant/index' + }) } }, topages(num){ diff --git a/pages/shouye/index.vue b/pages/shouye/index.vue index b9d3ed7..1570922 100644 --- a/pages/shouye/index.vue +++ b/pages/shouye/index.vue @@ -122,19 +122,20 @@ } that.$u.put("/app/device/bind", data).then(res => { if (res.code == 200) { - uni.showModal({ - title: '提示', - content: '绑定成功,需前去设置吗?', - success: function(res) { - if (res.confirm) { - uni.navigateTo({ - url: '/page_user/sbdetail?id=' +that.deviceobj.deviceId - }) - } else if (res.cancel) { - - } - } + uni.navigateTo({ + url: '/page_user/sbdetail?id=' +that.deviceobj.deviceId }) + // uni.showModal({ + // title: '提示', + // content: '绑定成功,需前去设置吗?', + // success: function(res) { + // if (res.confirm) { + + // } else if (res.cancel) { + + // } + // } + // }) } else { uni.showToast({ title: res.msg, @@ -202,7 +203,8 @@ }, addMarkersWithoutLabels() { this.listmap.forEach((item) => { - const shopCover = { + if (item.deviceCount !== null && item.deviceCount > 0){ + const shopCover = { id: parseFloat(item.storeId), latitude: item.lat, longitude: item.lng, @@ -211,11 +213,14 @@ iconPath: 'https://api.ccttiot.com/smartmeter/img/static/uZXgsJE6hXbRSwbKILB4', }; this.covers.push(shopCover) + } + }); }, addMarkersWithLabels() { this.listmap.forEach((item) => { - const shopCover = { + if (item.deviceCount !== null && item.deviceCount > 0){ + const shopCover = { id: parseFloat(item.storeId), latitude: item.lat, longitude: item.lng, @@ -232,6 +237,8 @@ } } this.covers.push(shopCover) + } + }); }, calculateAnchorX(name) { @@ -361,52 +368,53 @@ this.longitude = Number(res.longitude.toFixed(5)) + 0.005 this.setMapScale() // 请求附近的店铺 - this.$u.get("/app/store/listNearBy?center=" + this.jinweidu + '&radius=' + 1000).then( - res => { + this.$u.get("/app/store/listNearBy?center=" + this.jinweidu + '&radius=' + 1000).then(res => { if (res.code == 200) { this.listmap = res.data res.data.forEach(item => { - const shopCover = { - id: parseFloat(item.storeId), - latitude: item.lat, - longitude: item.lng, - width: 25, - height: 30, - iconPath: 'https://api.ccttiot.com/smartmeter/img/static/uZXgsJE6hXbRSwbKILB4', - label: { - content: item.name, - anchorX: (() => { - if (item.name.length <= 2) { - return -12 - } else if (item.name.length <= 3) { - return -20 - } else if (item.name.length <= 4) { - return -25 - } else if (item.name.length <= 5) { - return -30 - } else if (item.name.length <= 6) { - return -35 - } else if (item.name.length <= 8) { - return -40 - } else if (item.name.length <= - 10) { - return -45 - } else { - return -item.name.length * 6 - } - })(), - fontWeight: 700, - color: '#8883F0', - textShadow: '2px 2px 0px white, -2px -2px 0px white, 2px -2px 0px white, -2px 2px 0px white', - style: { - - }, + if (item.deviceCount !== null && item.deviceCount > 0){ + const shopCover = { + id: parseFloat(item.storeId), + latitude: item.lat, + longitude: item.lng, + width: 25, + height: 30, + iconPath: 'https://api.ccttiot.com/smartmeter/img/static/uZXgsJE6hXbRSwbKILB4', + label: { + content: item.name, + anchorX: (() => { + if (item.name.length <= 2) { + return -12 + } else if (item.name.length <= 3) { + return -20 + } else if (item.name.length <= 4) { + return -25 + } else if (item.name.length <= 5) { + return -30 + } else if (item.name.length <= 6) { + return -35 + } else if (item.name.length <= 8) { + return -40 + } else if (item.name.length <= + 10) { + return -45 + } else { + return -item.name.length * 6 + } + })(), + fontWeight: 700, + color: '#8883F0', + textShadow: '2px 2px 0px white, -2px -2px 0px white, 2px -2px 0px white, -2px 2px 0px white', + style: { + + }, + } } - }; - this.covers.push(shopCover) - }); + this.covers.push(shopCover) + } + }) } - }); + }) }, fail: (err) => { console.error('获取位置失败:', err);