From 689436759f546267af327c99709c63ad7ee6fcc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=B2=E4=B9=88=E4=BA=86?= Date: Mon, 24 Jul 2023 08:47:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=AF=B9=E6=8E=A5=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.vue | 8 +- common/api/device.js | 37 +- common/api/user.js | 1 + common/css/base.scss | 28 +- common/js/config.js | 4 +- common/js/drawMixin.js | 71 +++ common/js/mqtt.js | 6 +- common/js/sm2.js | 6 + common/js/util.js | 17 +- components/Cn-htmlToImg/Cn-htmlToImg.vue | 6 +- main.js | 1 + manifest.json | 6 +- package.json | 3 +- pages.json | 9 +- pages/device/APF/comp/basic.vue | 156 ++++--- pages/device/APF/comp/power.vue | 118 +++-- pages/device/APF/detail.vue | 437 +++++++++++------- pages/device/list.vue | 2 +- pages/device/new.vue | 70 +-- pages/engineering/detail.vue | 34 +- pages/engineering/list.vue | 8 +- pages/engineering/new.vue | 58 ++- pages/index/comp/device.vue | 12 +- pages/index/mine.vue | 2 +- pages/project/detail.vue | 40 +- pages/project/list.vue | 9 +- pages/project/new.vue | 227 +++++++-- pages/user/changePwd.vue | 2 +- pages/user/login.vue | 28 +- pnpm-lock.yaml | 36 ++ .../uni-file-picker/upload-image.vue | 76 +-- 31 files changed, 1070 insertions(+), 448 deletions(-) create mode 100644 common/js/drawMixin.js diff --git a/App.vue b/App.vue index ce98a4e..bf52ac9 100644 --- a/App.vue +++ b/App.vue @@ -3,6 +3,7 @@ import { queryDictDataCache } from './common/api/dictionary.js' import encrypt from './common/js/aes.js' export default { onLaunch: function () { + console.log(window); // this.connect() console.log('App Launch') let devCode = uni.getStorageSync('devCode') @@ -13,13 +14,12 @@ export default { }, }) } - - queryDictDataCache().then((res) => { - uni.setStorageSync(this.$cacheKey.dictData, res.data) - }) }, onShow: function () { console.log('App Show') + queryDictDataCache().then((res) => { + uni.setStorageSync(this.$cacheKey.dictData, res.data) + }) }, onHide: function () { console.log('App Hide') diff --git a/common/api/device.js b/common/api/device.js index a73d9d4..b4e13fa 100644 --- a/common/api/device.js +++ b/common/api/device.js @@ -30,12 +30,11 @@ export function getModel(nDid) { url: '/access-boot/device/model', method: 'post', data: { - nDid + nDid, }, }) } - // 直连设备接入 export function addDevice(params) { return request({ @@ -54,7 +53,37 @@ export function registerDevice(nDid) { url: '/access-boot/device/register', method: 'post', data: { - nDid + nDid, }, }) -} \ No newline at end of file +} + +// 查询拓扑图模板 +export const getTopoTemplate = () => { + return request({ + url: '/cs-device-boot/topologyTemplate/queryImage', + method: 'POST', + }) +} + +// 查询拓扑图模板监测点 +export const queryByTopoId = (id) => { + return request({ + url: '/cs-device-boot/lineTemplate/queryByTopoId', + method: 'POST', + data: { + topoId:id, + }, + }) +} +// 查询装置拓扑图 +export const queryTopologyDiagram = (devId) => { + return request({ + url: '/cs-device-boot/lineTopologyDiagram/queryTopologyDiagram', + method: 'POST', + data: { + devId, + }, + }) +} + diff --git a/common/api/user.js b/common/api/user.js index d716bb2..c822122 100644 --- a/common/api/user.js +++ b/common/api/user.js @@ -168,6 +168,7 @@ export function apiPwdLogin(params) { //登录获取公钥 export function gongkey(data) { + console.log(data); return request({ url: '/user-boot/user/generateSm2Key', method: 'get', diff --git a/common/css/base.scss b/common/css/base.scss index a55d842..8616a78 100644 --- a/common/css/base.scss +++ b/common/css/base.scss @@ -97,6 +97,7 @@ page { .grid-card-content-4, .grid-card-content-2, + .grid-card-content-1, .grid-card-content-3, .grid-card-content-5, .grid-card-content-6 { @@ -114,15 +115,19 @@ page { text-align: center; border-bottom: 2rpx solid #ccc; border-right: 2rpx solid #ccc; - min-height: 100rpx; + padding: 4rpx; background: $uni-theme-white; } .item-title { background: unset; + padding: 8rpx 4rpx; } } + .grid-card-content-1 { + grid-template-columns: 1fr; + } .grid-card-content-2 { grid-template-columns: 1fr 2fr; } @@ -253,4 +258,25 @@ page { border-radius: 50%; background: red; overflow: hidden; +} + + +.popup-header { + display: flex; + align-items: center; + justify-content: space-between; + padding: 0 20rpx; + height: 80rpx; + background: #fff; + border-radius: 20rpx 20rpx 0 0; + overflow: hidden; + border-bottom: 1px solid #eee; + .popup-header-title { + font-size: 32rpx; + color: #333; + } + .popup-header-close { + font-size: 32rpx; + color: #666; + } } \ No newline at end of file diff --git a/common/js/config.js b/common/js/config.js index 67e9d47..6ddf744 100644 --- a/common/js/config.js +++ b/common/js/config.js @@ -1,13 +1,13 @@ const debug = true // true 是连地服务端本地,false 是连接线上 const development = { - domain: 'http://192.168.1.114:10210', + domain: 'http://192.168.1.139:10215', devCode: "2aaecd0b124df819eda75e639a1f91fd", key: "f81804778c89c779" } const production = { - domain: 'http://192.168.1.60:8094', + domain: 'http://192.168.1.13:10215', } const config = debug ? development : production diff --git a/common/js/drawMixin.js b/common/js/drawMixin.js new file mode 100644 index 0000000..b255460 --- /dev/null +++ b/common/js/drawMixin.js @@ -0,0 +1,71 @@ +// 屏幕适配 mixin 函数 + +// * 默认缩放值 +const scale = { + width: '1', + height: '1', +}; + +// * 设计稿尺寸(px) +const baseWidth = 375; +const baseHeight = 667; + +// * 需保持的比例(默认1.77778) +const baseProportion = parseFloat((baseWidth / baseHeight).toFixed(5)); + +export default { + data() { + return { + // * 定时函数 + drawTiming: null, + }; + }, + mounted() { + this.calcRate(); + window.addEventListener('resize', this.resize); + }, + beforeDestroy() { + window.removeEventListener('resize', this.resize); + }, + methods: { + calcRate() { + const appRef = this.$refs['appRef']; + const fatherRef = this.$refs['fatherRef']; + if (!appRef) return; + // 当前宽高比 + const currentRate = parseFloat( + (fatherRef.offsetWidth / fatherRef.offsetHeight).toFixed(5) + ); + if (appRef) { + if (currentRate > baseProportion) { + // 表示更宽 + scale.width = ( + (fatherRef.offsetHeight * baseProportion) / + baseWidth + ).toFixed(5); + scale.height = ( + fatherRef.offsetHeight / baseHeight + ).toFixed(5); + appRef.style.transform = `scale(${scale.width}, ${scale.height}) translate(-50%, -50%)`; + } else { + // 表示更高 + scale.height = ( + fatherRef.offsetWidth / + baseProportion / + baseHeight + ).toFixed(5); + scale.width = (fatherRef.offsetWidth / baseWidth).toFixed( + 5 + ); + appRef.style.transform = `scale(${scale.width}, ${scale.height}) translate(-50%, -50%)`; + } + } + }, + resize() { + clearTimeout(this.drawTiming); + this.drawTiming = setTimeout(() => { + this.calcRate(); + }, 200); + }, + }, +}; diff --git a/common/js/mqtt.js b/common/js/mqtt.js index 6b89b62..8b4b5e8 100644 --- a/common/js/mqtt.js +++ b/common/js/mqtt.js @@ -1,6 +1,6 @@ -export const MQTT_IP = '60.204.148.71:9001'//mqtt地址端口, 使用emqx时一定要加mqtt -const MQTT_USERNAME = 'test'//mqtt用户名 -const MQTT_PASSWORD = 'test'//密码 +export const MQTT_IP = '192.168.1.18:8083/mqtt'//mqtt地址端口, 使用emqx时一定要加mqtt +const MQTT_USERNAME = 't_user'//mqtt用户名 +const MQTT_PASSWORD = 'njcnpqs'//密码 export const MQTT_OPTIONS = { connectTimeout: 5000, diff --git a/common/js/sm2.js b/common/js/sm2.js index bbb516a..fb11399 100644 --- a/common/js/sm2.js +++ b/common/js/sm2.js @@ -1,4 +1,10 @@ import CryptoJS from 'crypto-js' +if(typeof navigator === 'undefined') { + var navigator = { + appName: 'Netscape', + }; + var window = {}; +} function SM2Cipher(a) { this.ct = 1; this.sm3c3 = this.sm3keybase = this.p2 = null; diff --git a/common/js/util.js b/common/js/util.js index 7b5fc2f..9e24fbc 100644 --- a/common/js/util.js +++ b/common/js/util.js @@ -1,5 +1,7 @@ import request from './request' import cache from './cacheKey.js' +import { queryDictDataCache } from '../api/dictionary.js' +import cacheKey from './cacheKey.js' const toast = (title, duration = 1500, call, mask = false, icon = 'none') => { if (Boolean(title) === false) { return @@ -198,14 +200,23 @@ const prePage = () => { } const loginSuccess = (data) => { + console.log(data); uni.setStorageSync('access_token', data.token_type + ' ' + data.access_token) uni.setStorageSync('refresh_token', data.refresh_token) let strings = data.access_token.split('.') //截取token,获取载体 - var userInfo = JSON.parse(decodeURIComponent(escape(window.atob(strings[1].replace(/-/g, '+').replace(/_/g, '/'))))) + console.log(escape,atob); + var userInfo = JSON.parse(decodeURIComponent(escape(atob(strings[1].replace(/-/g, '+').replace(/_/g, '/'))))) userInfo.authorities = userInfo.authorities[0] uni.setStorageSync('userInfo', userInfo) - uni.reLaunch({ - url: '/pages/index/index', + console.log('reLaunch'); + queryDictDataCache().then((res) => { + uni.setStorageSync(cacheKey.dictData, res.data) + uni.reLaunch({ + url: '/pages/index/index', + fail: (err) => { + console.log(err); + } + }) }) } diff --git a/components/Cn-htmlToImg/Cn-htmlToImg.vue b/components/Cn-htmlToImg/Cn-htmlToImg.vue index fb29024..2458c58 100644 --- a/components/Cn-htmlToImg/Cn-htmlToImg.vue +++ b/components/Cn-htmlToImg/Cn-htmlToImg.vue @@ -29,13 +29,15 @@ export default { methods: { // 生成图片需要调用的方法 generateImage(domId) { - console.log(123); // 获取设备dpi setTimeout(() => { let dom = document.getElementById(domId); + console.log(dom.offsetWidth, dom.offsetHeight); html2canvas(dom, { scale: 8, useCORS: true, + width: dom.offsetWidth, + height: dom.offsetHeight, }).then((canvas) => { // this.$refs.header.appendChild(canvas); const posterImg = canvas.toDataURL() @@ -45,7 +47,7 @@ export default { }).catch((err) => { console.log(err) }) - }, 300); + }, 200); } } } diff --git a/main.js b/main.js index d660026..8d4c685 100644 --- a/main.js +++ b/main.js @@ -6,6 +6,7 @@ import config from './common/js/config' import cacheKey from './common/js/cacheKey' import Vue from 'vue' import share from "@/common/js/share.js"; + Vue.config.productionTip = false Vue.prototype.$request = request Vue.prototype.$util = util diff --git a/manifest.json b/manifest.json index 38f4496..a7fe63a 100644 --- a/manifest.json +++ b/manifest.json @@ -2,8 +2,8 @@ "name" : "灿能物联", "appid" : "__UNI__88BC25B", "description" : "", - "versionName" : "1.0.2", - "versionCode" : 101, + "versionName" : "1.0.3", + "versionCode" : 102, "transformPx" : false, /* 5+App特有相关 */ "app-plus" : { @@ -132,7 +132,7 @@ "/api" : { "https" : true, // "target" : "https://china.indpecker.com", - "target" : "http://192.168.1.139:10215", + "target" : "http://192.168.1.115:10215", "changOrigin" : true, "pathRewrite" : { "/api" : "" diff --git a/package.json b/package.json index 2ec6bce..194ebd9 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,8 @@ "html2canvas": "^1.4.1", "mqtt": "3.0.0", "pinyin-pro": "^3.13.2", - "qs": "^6.11.2" + "qs": "^6.11.2", + "vconsole": "^3.15.1" }, "devDependencies": { "@types/html5plus": "^1.0.2", diff --git a/pages.json b/pages.json index fce8a80..231c05f 100644 --- a/pages.json +++ b/pages.json @@ -306,7 +306,8 @@ { "path": "pages/engineering/list", "style": { - "navigationBarTitleText": "工程列表" + "navigationBarTitleText": "工程列表", + "navigationStyle": "custom" } }, { @@ -437,11 +438,7 @@ //模式配置,仅开发期间生效 "current": 0, //当前激活的模式(list 的索引项) "list": [ - { - "name": "login", //模式名称 - "path": "pages/project/new", //启动页面,必选 - "query": "" //启动参数,在页面的onLoad函数里面得到。 - } + ] } } \ No newline at end of file diff --git a/pages/device/APF/comp/basic.vue b/pages/device/APF/comp/basic.vue index 75582cb..1163783 100644 --- a/pages/device/APF/comp/basic.vue +++ b/pages/device/APF/comp/basic.vue @@ -1,5 +1,5 @@ - \ No newline at end of file + diff --git a/pages/device/APF/comp/power.vue b/pages/device/APF/comp/power.vue index c28fe73..b916f6a 100644 --- a/pages/device/APF/comp/power.vue +++ b/pages/device/APF/comp/power.vue @@ -1,5 +1,5 @@ - \ No newline at end of file + diff --git a/pages/device/APF/detail.vue b/pages/device/APF/detail.vue index dfb4203..c256657 100644 --- a/pages/device/APF/detail.vue +++ b/pages/device/APF/detail.vue @@ -1,44 +1,22 @@ - \ No newline at end of file + diff --git a/pages/device/list.vue b/pages/device/list.vue index f844e27..8794528 100644 --- a/pages/device/list.vue +++ b/pages/device/list.vue @@ -32,7 +32,7 @@ export default { }, jump () { uni.navigateTo({ - url: '/pages/device/APF/detail' + url: '/pages/device/APF/detail?id=' + item.id }) }, trigger (e) { diff --git a/pages/device/new.vue b/pages/device/new.vue index ad7cd4c..02664ad 100644 --- a/pages/device/new.vue +++ b/pages/device/new.vue @@ -56,12 +56,9 @@ - + + + 选择拓扑图 - + 提交 @@ -113,7 +102,8 @@ :key="key" /> - 确定 + 取消 + 确定 @@ -161,7 +151,7 @@ diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7084bd3..448ac96 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,6 +8,7 @@ specifiers: mqtt: 3.0.0 pinyin-pro: ^3.13.2 qs: ^6.11.2 + vconsole: ^3.15.1 dependencies: crypto-js: 4.1.1 @@ -15,6 +16,7 @@ dependencies: mqtt: 3.0.0 pinyin-pro: 3.13.2 qs: 6.11.2 + vconsole: 3.15.1 devDependencies: '@types/html5plus': 1.0.2 @@ -40,6 +42,13 @@ packages: '@babel/types': 7.22.5 dev: true + /@babel/runtime/7.22.6: + resolution: {integrity: sha512-wDb5pWm4WDdF6LFUde3Jl8WzPA+3ZbxYqkC6xAXuD3irdEHN1k0NfTRrJD8ZD378SJ61miMLCqIOXYhd8x+AJQ==} + engines: {node: '>=6.9.0'} + dependencies: + regenerator-runtime: 0.13.11 + dev: false + /@babel/types/7.22.5: resolution: {integrity: sha512-zo3MIHGOkPOfoRXitsgHLjEXmlDaD/5KU1Uzuc9GNiZPhSqVxVRtxuPaSBZDsYZ9qV88AjtMtWW7ww98loJ9KA==} engines: {node: '>=6.9.0'} @@ -145,6 +154,16 @@ packages: typedarray: 0.0.6 dev: false + /copy-text-to-clipboard/3.2.0: + resolution: {integrity: sha512-RnJFp1XR/LOBDckxTib5Qjr/PMfkatD0MUCQgdpqS8MdKiNUzBjAQBEN6oUy+jW7LI93BBG3DtMB2KOOKpGs2Q==} + engines: {node: '>=12'} + dev: false + + /core-js/3.31.1: + resolution: {integrity: sha512-2sKLtfq1eFST7l7v62zaqXacPc7uG8ZAya8ogijLhTtaKNcpzpB4TMoTw2Si+8GYKRwFPMMtUT0263QFWFfqyQ==} + requiresBuild: true + dev: false + /core-util-is/1.0.3: resolution: {integrity: sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==} dev: false @@ -479,6 +498,10 @@ packages: resolution: {integrity: sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==} dev: false + /mutation-observer/1.0.3: + resolution: {integrity: sha512-M/O/4rF2h776hV7qGMZUH3utZLO/jK7p8rnNgGkjKUw8zCGjRQPxB8z6+5l8+VjRUQ3dNYu4vjqXYLr+U8ZVNA==} + dev: false + /nanoid/3.3.6: resolution: {integrity: sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA==} engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} @@ -585,6 +608,10 @@ packages: util-deprecate: 1.0.2 dev: false + /regenerator-runtime/0.13.11: + resolution: {integrity: sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==} + dev: false + /reinterval/1.1.0: resolution: {integrity: sha512-QIRet3SYrGp0HUHO88jVskiG6seqUGC5iAG7AwI/BV4ypGcuqk9Du6YQBUOUqm9c8pw1eyLoIaONifRua1lsEQ==} dev: false @@ -712,6 +739,15 @@ packages: base64-arraybuffer: 1.0.2 dev: false + /vconsole/3.15.1: + resolution: {integrity: sha512-KH8XLdrq9T5YHJO/ixrjivHfmF2PC2CdVoK6RWZB4yftMykYIaXY1mxZYAic70vADM54kpMQF+dYmvl5NRNy1g==} + dependencies: + '@babel/runtime': 7.22.6 + copy-text-to-clipboard: 3.2.0 + core-js: 3.31.1 + mutation-observer: 1.0.3 + dev: false + /vue/2.7.14: resolution: {integrity: sha512-b2qkFyOM0kwqWFuQmgd4o+uHGU7T+2z3T+WQp8UBjADfEv2n4FEMffzBmCKNP0IGzOEEfYjvtcC62xaSKeQDrQ==} dependencies: diff --git a/uni_modules/uni-file-picker/components/uni-file-picker/upload-image.vue b/uni_modules/uni-file-picker/components/uni-file-picker/upload-image.vue index 51ace0b..0c1abe8 100644 --- a/uni_modules/uni-file-picker/components/uni-file-picker/upload-image.vue +++ b/uni_modules/uni-file-picker/components/uni-file-picker/upload-image.vue @@ -1,7 +1,7 @@