From 39b5e3774b696b60da58db42ee7fe4439b338132 Mon Sep 17 00:00:00 2001 From: fhysy <1149505133@qq.com> Date: Fri, 25 Apr 2025 14:06:05 +0800 Subject: [PATCH] =?UTF-8?q?feat(network):=20=E9=A1=B9=E7=9B=AE=E5=88=9D?= =?UTF-8?q?=E5=A7=8B=E5=8C=96=E3=80=81=E8=AF=B7=E6=B1=82=E5=B0=81=E8=A3=85?= =?UTF-8?q?=EF=BC=8C=E4=B8=BB=E5=8C=85=E9=83=A8=E5=88=86=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E5=BC=80=E5=8F=91=E5=92=8C=E6=8E=A5=E5=8F=A3=E5=AF=B9=E6=8E=A5?= =?UTF-8?q?=E7=AD=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 完成登录、配置、统计、设备、我的、修改密码页开发 - 初始化项目tabbar图标、默认图片等 - 重构请求封装,项目配置等 --- App.vue | 6 +- manifest.json | 10 +- network/api/index.js | 37 +- network/api/iots/index.js | 54 ++- network/config.js | 4 +- network/request.js | 6 +- pages.json | 30 +- pages/my/reset-password.vue | 4 +- pages/tabbar/config.vue | 467 ++++++++++--------- pages/tabbar/dashboard.vue | 458 ++++++++++++++++++ pages/tabbar/device.vue | 405 ++++++++++++++++ pages/tabbar/login.vue | 194 +++++--- pages/tabbar/my.vue | 47 +- static/app-plus/image/device/device-card.png | Bin 0 -> 7357 bytes static/image/tabbar/app-scan.png | Bin 4251 -> 2788 bytes static/image/tabbar/dashboard-active.png | Bin 0 -> 521 bytes static/image/tabbar/dashboard.png | Bin 0 -> 474 bytes static/image/tabbar/iot-active.png | Bin 0 -> 783 bytes static/image/tabbar/iot.png | Bin 0 -> 705 bytes static/image/tabbar/my-active.png | Bin 1776 -> 534 bytes static/image/tabbar/my.png | Bin 2020 -> 494 bytes static/image/tabbar/new-active.png | Bin 1567 -> 527 bytes static/image/tabbar/new.png | Bin 1785 -> 493 bytes static/image/tabbar/scan-active.png | Bin 1856 -> 560 bytes static/image/tabbar/scan.png | Bin 1313 -> 510 bytes 25 files changed, 1404 insertions(+), 318 deletions(-) create mode 100644 pages/tabbar/dashboard.vue create mode 100644 pages/tabbar/device.vue create mode 100644 static/app-plus/image/device/device-card.png create mode 100644 static/image/tabbar/dashboard-active.png create mode 100644 static/image/tabbar/dashboard.png create mode 100644 static/image/tabbar/iot-active.png create mode 100644 static/image/tabbar/iot.png diff --git a/App.vue b/App.vue index 415eb00..ff6cd74 100644 --- a/App.vue +++ b/App.vue @@ -10,14 +10,14 @@ if(!configList || configList.length == 0){ let configList = [{ id:this.$u.guid(32), - protocol:'https://', - address:'cloud.iot-fast.com', + protocol:'http://', + address:'192.168.1.17:8848', }] // #ifdef APP-PLUS configList.push({ id:this.$u.guid(32), protocol:'http://', - address:'192.168.21.22', + address:'192.168.1.17:8848', }) // #endif uni.setStorageSync('configList',configList) diff --git a/manifest.json b/manifest.json index 8fa087c..6613ec4 100644 --- a/manifest.json +++ b/manifest.json @@ -1,9 +1,9 @@ { - "name" : "物联网可视化", - "appid" : "__UNI__604B8F1", + "name" : "德润物联网", + "appid" : "__UNI__B7FE99B", "description" : "", - "versionName" : "1.0.34", - "versionCode" : 1034, + "versionName" : "1.0.0", + "versionCode" : 100, "transformPx" : false, /* 5+App特有相关 */ "app-plus" : { @@ -135,7 +135,7 @@ "quickapp" : {}, /* 小程序特有相关 */ "mp-weixin" : { - "appid" : "wx27c271b0cb420015", + "appid" : "wxc1dd0068f0f85026", "setting" : { "urlCheck" : false, "postcss" : true, diff --git a/network/api/index.js b/network/api/index.js index a11a67c..4266822 100644 --- a/network/api/index.js +++ b/network/api/index.js @@ -14,7 +14,7 @@ export default { getAppConfig(data){ return new Promise((resolve, reject) => { request.customRequest({ - url: '/admin/admin/site/config', + url: '/system/config/front', method: 'GET', },data) .then((res) =>{ @@ -58,7 +58,7 @@ export default { passwordLogin(data){ return new Promise((resolve, reject) => { request.customRequest({ - url: '/user/admin/site/accountLogin', + url: '/authorize/login', method: 'POST', },data) .then((res) =>{ @@ -68,6 +68,20 @@ export default { }) }) }, + // 获取用户信息 + userLogout(data){ + return new Promise((resolve, reject) => { + request.TokenRequest({ + url: '/user-token/reset', + method: 'GET', + },data) + .then((res) =>{ + resolve(res); + }).catch(err =>{ + reject(err); + }) + }) + }, // 发送短信验证码 sendSms(data){ @@ -103,7 +117,7 @@ export default { getUserInfo(data){ return new Promise((resolve, reject) => { request.TokenRequest({ - url: '/user/admin/member/info', + url: '/user/detail', method: 'GET', },data) .then((res) =>{ @@ -134,7 +148,22 @@ export default { updatePwd(data){ return new Promise((resolve, reject) => { request.TokenRequest({ - url: '/user/admin/member/updatePwd', + url: '/user/passwd', + method: 'PUT', + },data) + .then((res) =>{ + resolve(res); + }).catch(err =>{ + reject(err); + }) + }) + }, + + // 看板统计查询 + getDashboardSelect(data){ + return new Promise((resolve, reject) => { + request.TokenRequest({ + url: '/dashboard/_multi', method: 'POST', },data) .then((res) =>{ diff --git a/network/api/iots/index.js b/network/api/iots/index.js index e93e05a..20e09b1 100644 --- a/network/api/iots/index.js +++ b/network/api/iots/index.js @@ -1,6 +1,21 @@ import request from "../../request.js" export default { + // 获取设备数 + getDeviceInstanceCount(data){ + return new Promise((resolve, reject) => { + request.TokenRequest({ + url: '/device/instance/_count', + method: 'GET', + },data) + .then((res) =>{ + resolve(res); + }).catch(err =>{ + reject(err); + }) + }) + }, + // 获取设备统计数量 getDeviceCount(data){ return new Promise((resolve, reject) => { @@ -20,8 +35,8 @@ export default { getProductList(data){ return new Promise((resolve, reject) => { request.TokenRequest({ - url: '/iot/admin/product/list', - method: 'GET', + url: '/device-product/_query/no-paging', + method: 'POST', },data) .then((res) =>{ resolve(res); @@ -35,7 +50,7 @@ export default { getDeviceList(data){ return new Promise((resolve, reject) => { request.TokenRequest({ - url: '/iot/admin/device/list', + url: '/device-instance/_query', method: 'POST', },data) .then((res) =>{ @@ -136,12 +151,25 @@ export default { }) }) }, - - // 告警级别列表 + // 获取告警记录列表 + getAlarmList(data){ + return new Promise((resolve, reject) => { + request.TokenRequest({ + url: '/alarm/record/_query', + method: 'POST', + },data) + .then((res) =>{ + resolve(res); + }).catch(err =>{ + reject(err); + }) + }) + }, + // 获取默认告警级别 getAlarmLevelList(data){ return new Promise((resolve, reject) => { request.TokenRequest({ - url: '/iot/admin/alarm/level/list', + url: '/alarm/config/default/level', method: 'GET', },data) .then((res) =>{ @@ -151,6 +179,20 @@ export default { }) }) }, + // // 告警级别列表 + // getAlarmLevelList(data){ + // return new Promise((resolve, reject) => { + // request.TokenRequest({ + // url: '/iot/admin/alarm/level/list', + // method: 'GET', + // },data) + // .then((res) =>{ + // resolve(res); + // }).catch(err =>{ + // reject(err); + // }) + // }) + // }, // 概览页统计(图表) getAlarmRecordStat(data){ diff --git a/network/config.js b/network/config.js index 95b9535..be6a0ec 100644 --- a/network/config.js +++ b/network/config.js @@ -14,8 +14,8 @@ if(process.env.NODE_ENV === 'development'){ // wsUrl = "ws://iotos-ui-dev.iotos.192.168.10.243.nip.io:32764" // configurationUrl = "http://192.168.18.139:8855" // configurationhtmlUrl = "http://hceditor-2d-dev.hceditor.192.168.10.243.nip.io:30405" - url = 'https://miot.gkiiot.com' - wsUrl = 'wss://miot.gkiiot.com' + url = 'http://192.168.1.17:8848' + wsUrl = 'ws://192.168.1.17:8848' configurationUrl = 'https://2d.gkiiot.com/prod-api' configurationhtmlUrl = 'https://2d.gkiiot.com' }else{ diff --git a/network/request.js b/network/request.js index 499d0d4..6ce21f6 100644 --- a/network/request.js +++ b/network/request.js @@ -94,7 +94,7 @@ const TokenRequest = (opts, data) => { data: data, method: opts.method, header: { - 'Authorization': tokenKey, + 'x-access-token': tokenKey, }, } let promise = new Promise(function(resolve, reject) { @@ -102,7 +102,7 @@ const TokenRequest = (opts, data) => { (res) => { // console.log("请求返回",res) // 令牌过期关闭所有页面跳转登录页 - if(res[1].data.code==61){ + if(res[1].data.status==401){ uni.showToast({ title: '登录已过期,请重新登录', icon: 'none', @@ -114,7 +114,7 @@ const TokenRequest = (opts, data) => { setTimeout(()=>{ uni.reLaunch({url:'/pages/tabbar/login'}); },1500) - }else if(res[1].data.code>0){ + }else if(res[1].data.status!=200){ uni.showToast({ title: res[1].data.message, icon: 'none', diff --git a/pages.json b/pages.json index cf199e8..fd1705a 100644 --- a/pages.json +++ b/pages.json @@ -29,6 +29,20 @@ // "navigationStyle":"custom" // } // }, + { + "path": "pages/tabbar/dashboard", + "style": { + "navigationBarTitleText": "统计看板", + "navigationBarBackgroundColor": "#FFFFFF" + } + }, + { + "path": "pages/tabbar/device", + "style": { + "navigationBarTitleText": "设备", + "navigationBarBackgroundColor": "#FFFFFF" + } + }, { "path": "pages/tabbar/new", "style": { @@ -343,15 +357,15 @@ }, // #endif "list": [{ - "pagePath": "pages/tabbar/home", - "iconPath": "static/image/tabbar/home.png", - "selectedIconPath": "static/image/tabbar/home-active.png", - "text": "首页" + "pagePath": "pages/tabbar/dashboard", + "iconPath": "static/image/tabbar/dashboard.png", + "selectedIconPath": "static/image/tabbar/dashboard-active.png", + "text": "统计" },{ - "pagePath": "pages/tabbar/workbench", - "iconPath": "static/image/tabbar/workbench.png", - "selectedIconPath": "static/image/tabbar/workbench-active.png", - "text": "工作台" + "pagePath": "pages/tabbar/device", + "iconPath": "static/image/tabbar/iot.png", + "selectedIconPath": "static/image/tabbar/iot-active.png", + "text": "设备" }, // #ifdef MP-WEIXIN { diff --git a/pages/my/reset-password.vue b/pages/my/reset-password.vue index a4feb49..3f66a84 100644 --- a/pages/my/reset-password.vue +++ b/pages/my/reset-password.vue @@ -56,13 +56,13 @@ submit(){ if(this.verification()){ let params={ - id:this.infoData.id, + // id:this.infoData.id, newPassword:this.newPassword, oldPassword:this.oldPassword, } this.$api.updatePwd(params).then(res => { console.log("submit",res); - if(res.code==0){ + if(res.status == 200){ this.$u.toast(res.message); this.$store.commit('setTokenKey', ''); uni.$u.toast('退出登录成功'); diff --git a/pages/tabbar/config.vue b/pages/tabbar/config.vue index 34016f9..e20b859 100644 --- a/pages/tabbar/config.vue +++ b/pages/tabbar/config.vue @@ -1,46 +1,91 @@ @@ -49,122 +94,122 @@ export default { data() { return { - configIndex:0, - configList:[], - form:{ - id:'', - protocol:'', - address:'', + configIndex: 0, + configList: [], + form: { + id: '', + protocol: '', + address: '', }, - protocolShow:false, - protocolList:[ - { - value: 'http://', - label: 'http://' - }, + protocolShow: false, + protocolList: [ { value: 'https://', - label: 'https://' + label: 'HTTPS' + }, + { + value: 'http://', + label: 'HTTP' } ], - show:false, + show: false, }; }, onLoad() { // 小程序只使用https // #ifdef MP-WEIXIN - this.protocolList = [ - { - value: 'https://', - label: 'https://' - } - ] + // this.protocolList = [ + // { + // value: 'https://', + // label: 'HTTPS' + // } + // ] // #endif this.getConfigList(); }, - methods:{ - getConfigList(){ + methods: { + getConfigList() { uni.getStorage({ - key:'configList', + key: 'configList', }).then(res => { // 如果返回数组为两位就是正确 - if(res.length==2){ + if (res.length == 2) { this.configList = res[1].data; } return uni.getStorage({ - key:'configIndex', + key: 'configIndex', }) }).then(res => { - console.log("configIndex",res) - if(res.length==2){ + console.log("configIndex", res) + if (res.length == 2) { this.configIndex = res[1].data; } }) }, - changeConfig(i){ - console.log("index",i) - if(i !== this.configIndex){ + changeConfig(i) { + console.log("index", i) + if (i !== this.configIndex) { this.configIndex = i; uni.setStorage({ - key:'configIndex', + key: 'configIndex', data: i, }).then(res => { console.log("修改索引") }) } }, - verification(){ - if(!this.form.protocol){ + verification() { + if (!this.form.protocol) { this.$refs.uToast.show({ title: '请先选择协议!', type: 'error' }) return false; - }else if(!this.form.address){ + } else if (!this.form.address) { this.$refs.uToast.show({ title: '请先输入地址', type: 'error', }) return false; - }else if(!this.$u.test.url(this.form.protocol+this.form.address)){ + } else if (!this.$u.test.url(this.form.protocol + this.form.address)) { this.$refs.uToast.show({ title: '请确认输入地址正确', type: 'error', }) return false; - }else{ + } else { return true; } }, - openAdd(){ - if(this.configList.length == 0){ + openAdd() { + if (this.configList.length == 0) { this.form = { - id:'', - protocol:'https://', - address:'cloud.iot-fast.com', + id: '', + protocol: 'http://', + address: '192.168.1.17:8848', } - }else{ + } else { this.form = { - id:'', - protocol:'', - address:'', + id: '', + protocol: '', + address: '', } } - + this.show = true; }, - addConfig(){ - console.log("添加页面",this.form) - if(this.verification()){ - if(this.form.id===''){ + addConfig() { + console.log("添加页面", this.form) + if (this.verification()) { + if (this.form.id === '') { // 新增 this.configList.push({ - id:this.$u.guid(32), - protocol:this.form.protocol, - address:this.form.address, + id: this.$u.guid(32), + protocol: this.form.protocol, + address: this.form.address, }) uni.setStorage({ - key:'configList', + key: 'configList', data: this.configList, }).then(res => { this.$refs.uToast.show({ @@ -172,9 +217,9 @@ type: 'success', }) }) - if(this.configList.length==1){ + if (this.configList.length == 1) { uni.setStorage({ - key:'configIndex', + key: 'configIndex', data: 0, }).then(res => { console.log("添加第一个域名索引为0") @@ -182,18 +227,18 @@ } this.show = false; this.getConfigList() - console.log("configList",this.configList) - }else{ + console.log("configList", this.configList) + } else { // 编辑 - this.configList.map(item=>{ - if(item.id == this.form.id){ - item.protocol=this.form.protocol; - item.address=this.form.address; + this.configList.map(item => { + if (item.id == this.form.id) { + item.protocol = this.form.protocol; + item.address = this.form.address; } return item; }) uni.setStorage({ - key:'configList', + key: 'configList', data: this.configList, }).then(res => { this.$refs.uToast.show({ @@ -204,28 +249,29 @@ this.show = false; this.getConfigList() } - }else{ + } else { this.$refs.uModal.clearLoading(); } }, - confirmProtocol(e){ + confirmProtocol(e) { this.form.protocol = e[0].value; }, - openEdit(index){ - this.form = this.configList[index]; + openEdit(index) { + console.log("编辑",index) + this.form = JSON.parse(JSON.stringify(this.configList[index])); this.show = true; }, - delConfig(index){ + delConfig(index) { uni.showModal({ title: '提示', content: '确认要删除域名吗?', - success: (res)=>{ + success: (res) => { if (res.confirm) { console.log('用户点击确定'); - + this.configList.splice(index, 1); uni.setStorage({ - key:'configList', + key: 'configList', data: this.configList, }).then(res => { this.$refs.uToast.show({ @@ -233,19 +279,19 @@ type: 'success', }) }) - if(this.configIndexindex){ + if (this.configIndex < index) { + } else { + if (this.configIndex > index) { this.configIndex = this.configIndex - 1; - }else if(this.configIndex==index){ - if(this.configList.length==0){ + } else if (this.configIndex == index) { + if (this.configList.length == 0) { this.configIndex = -1; - }else{ + } else { this.configIndex = 0; } } uni.setStorage({ - key:'configIndex', + key: 'configIndex', data: this.configIndex, }).then(res => { console.log("修改索引") @@ -261,129 +307,130 @@ } } - + + .add-button-wrapper { + padding: 30rpx 20rpx; + position: fixed; + bottom: 0; + left: 0; + right: 0; + background-color: #fff; + box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.05); + } + + .slot-content { + padding: 20rpx 30rpx; + } + + .form-item { + margin-bottom: 30rpx; + + .form-label { + font-size: 28rpx; + color: #666; + margin-bottom: 20rpx; + } + + .form-value { + background-color: #f5f5f5; + border-radius: 8rpx; + height: 80rpx; + display: flex; + align-items: center; + padding: 0 20rpx; + position: relative; + + input { + width: 100%; + height: 100%; + } + + .arrow-icon { + position: absolute; + right: 20rpx; + } + } + } + \ No newline at end of file diff --git a/pages/tabbar/dashboard.vue b/pages/tabbar/dashboard.vue new file mode 100644 index 0000000..bb68d60 --- /dev/null +++ b/pages/tabbar/dashboard.vue @@ -0,0 +1,458 @@ + + + + + \ No newline at end of file diff --git a/pages/tabbar/device.vue b/pages/tabbar/device.vue new file mode 100644 index 0000000..7c4bb7b --- /dev/null +++ b/pages/tabbar/device.vue @@ -0,0 +1,405 @@ + + + + + + + \ No newline at end of file diff --git a/pages/tabbar/login.vue b/pages/tabbar/login.vue index 2f6566d..12ac0c4 100644 --- a/pages/tabbar/login.vue +++ b/pages/tabbar/login.vue @@ -1,12 +1,15 @@