diff --git a/cloudfunctions/project.config.json b/cloudfunctions/project.config.json new file mode 100644 index 0000000..2b3119a --- /dev/null +++ b/cloudfunctions/project.config.json @@ -0,0 +1,28 @@ +{ + "appid": "wx2cef527a000f87c9", + "compileType": "miniprogram", + "libVersion": "2.27.3", + "packOptions": { + "ignore": [], + "include": [] + }, + "setting": { + "coverView": true, + "es6": true, + "postcss": true, + "minified": true, + "enhance": true, + "showShadowRootInWxmlPanel": true, + "packNpmRelationList": [], + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + } + }, + "condition": {}, + "editorSetting": { + "tabIndent": "insertSpaces", + "tabSize": 4 + } +} \ No newline at end of file diff --git a/cloudfunctions/project.config.json b/cloudfunctions/project.config.json new file mode 100644 index 0000000..2b3119a --- /dev/null +++ b/cloudfunctions/project.config.json @@ -0,0 +1,28 @@ +{ + "appid": "wx2cef527a000f87c9", + "compileType": "miniprogram", + "libVersion": "2.27.3", + "packOptions": { + "ignore": [], + "include": [] + }, + "setting": { + "coverView": true, + "es6": true, + "postcss": true, + "minified": true, + "enhance": true, + "showShadowRootInWxmlPanel": true, + "packNpmRelationList": [], + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + } + }, + "condition": {}, + "editorSetting": { + "tabIndent": "insertSpaces", + "tabSize": 4 + } +} \ No newline at end of file diff --git a/cloudfunctions/project.private.config.json b/cloudfunctions/project.private.config.json new file mode 100644 index 0000000..42ff49d --- /dev/null +++ b/cloudfunctions/project.private.config.json @@ -0,0 +1,7 @@ +{ + "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", + "projectname": "cloudfunctions", + "setting": { + "compileHotReLoad": true + } +} \ No newline at end of file diff --git a/cloudfunctions/project.config.json b/cloudfunctions/project.config.json new file mode 100644 index 0000000..2b3119a --- /dev/null +++ b/cloudfunctions/project.config.json @@ -0,0 +1,28 @@ +{ + "appid": "wx2cef527a000f87c9", + "compileType": "miniprogram", + "libVersion": "2.27.3", + "packOptions": { + "ignore": [], + "include": [] + }, + "setting": { + "coverView": true, + "es6": true, + "postcss": true, + "minified": true, + "enhance": true, + "showShadowRootInWxmlPanel": true, + "packNpmRelationList": [], + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + } + }, + "condition": {}, + "editorSetting": { + "tabIndent": "insertSpaces", + "tabSize": 4 + } +} \ No newline at end of file diff --git a/cloudfunctions/project.private.config.json b/cloudfunctions/project.private.config.json new file mode 100644 index 0000000..42ff49d --- /dev/null +++ b/cloudfunctions/project.private.config.json @@ -0,0 +1,7 @@ +{ + "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", + "projectname": "cloudfunctions", + "setting": { + "compileHotReLoad": true + } +} \ No newline at end of file diff --git a/miniprogram/app.js b/miniprogram/app.js index 51d56f3..50a8a54 100644 --- a/miniprogram/app.js +++ b/miniprogram/app.js @@ -18,13 +18,15 @@ // this.globalData = {} }, globalData: { - // url: "http://111.198.10.15:11604/", - httpsUrl: "https://logapi.smartlog.work/", - httpsTestUrl: "https://smartlog.work/prodapi4test/", - url: "http://139.198.18.188:8083/", + httpsUrl: "https://logapi.smartlog.work/", + // httpsUrl: "http://139.198.18.188:8083/", // url: "http://127.0.0.1:8083/", - // httpsUrl: "http://127.0.0.1:8083/", + //httpsUrl: "http://127.0.0.1:8083/", openid: null, - indexCount:1 - }, + indexCount:1, + nickName:"", + userName:"", + role:"", + devcode:"" + } }) diff --git a/cloudfunctions/project.config.json b/cloudfunctions/project.config.json new file mode 100644 index 0000000..2b3119a --- /dev/null +++ b/cloudfunctions/project.config.json @@ -0,0 +1,28 @@ +{ + "appid": "wx2cef527a000f87c9", + "compileType": "miniprogram", + "libVersion": "2.27.3", + "packOptions": { + "ignore": [], + "include": [] + }, + "setting": { + "coverView": true, + "es6": true, + "postcss": true, + "minified": true, + "enhance": true, + "showShadowRootInWxmlPanel": true, + "packNpmRelationList": [], + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + } + }, + "condition": {}, + "editorSetting": { + "tabIndent": "insertSpaces", + "tabSize": 4 + } +} \ No newline at end of file diff --git a/cloudfunctions/project.private.config.json b/cloudfunctions/project.private.config.json new file mode 100644 index 0000000..42ff49d --- /dev/null +++ b/cloudfunctions/project.private.config.json @@ -0,0 +1,7 @@ +{ + "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", + "projectname": "cloudfunctions", + "setting": { + "compileHotReLoad": true + } +} \ No newline at end of file diff --git a/miniprogram/app.js b/miniprogram/app.js index 51d56f3..50a8a54 100644 --- a/miniprogram/app.js +++ b/miniprogram/app.js @@ -18,13 +18,15 @@ // this.globalData = {} }, globalData: { - // url: "http://111.198.10.15:11604/", - httpsUrl: "https://logapi.smartlog.work/", - httpsTestUrl: "https://smartlog.work/prodapi4test/", - url: "http://139.198.18.188:8083/", + httpsUrl: "https://logapi.smartlog.work/", + // httpsUrl: "http://139.198.18.188:8083/", // url: "http://127.0.0.1:8083/", - // httpsUrl: "http://127.0.0.1:8083/", + //httpsUrl: "http://127.0.0.1:8083/", openid: null, - indexCount:1 - }, + indexCount:1, + nickName:"", + userName:"", + role:"", + devcode:"" + } }) diff --git a/miniprogram/app.json b/miniprogram/app.json index d23f798..2b6db76 100644 --- a/miniprogram/app.json +++ b/miniprogram/app.json @@ -1,15 +1,17 @@ { "cloud": true, "pages": [ + "pages/login/login", "pages/indexapp/indexapp", "pages/earth/earth", "pages/applog/applog", "pages/addDevice/addDevice", "pages/addDevicelog/addDeviceLog", - "pages/searchLog/searchLog" + "pages/searchLog/searchLog", + "pages/notice/notice" ], "window": { - "backgroundColor": "#F6F6F6", + "backgroundColor": "#E6D480", "backgroundTextStyle": "light", "navigationBarBackgroundColor": "#FFCF00", "navigationBarTitleText": "智慧施工", @@ -46,11 +48,11 @@ "desc": "你的位置信息将用于小程序位置接口的效果展示" } }, + "requiredPrivateInfos": ["getLocation", "chooseLocation"], "networkTimeout": { "request": 30000, "connectSocket": 30000, "uploadFile": 30000, "downloadFile": 30000 - }, - "style": "v2" + } } \ No newline at end of file diff --git a/cloudfunctions/project.config.json b/cloudfunctions/project.config.json new file mode 100644 index 0000000..2b3119a --- /dev/null +++ b/cloudfunctions/project.config.json @@ -0,0 +1,28 @@ +{ + "appid": "wx2cef527a000f87c9", + "compileType": "miniprogram", + "libVersion": "2.27.3", + "packOptions": { + "ignore": [], + "include": [] + }, + "setting": { + "coverView": true, + "es6": true, + "postcss": true, + "minified": true, + "enhance": true, + "showShadowRootInWxmlPanel": true, + "packNpmRelationList": [], + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + } + }, + "condition": {}, + "editorSetting": { + "tabIndent": "insertSpaces", + "tabSize": 4 + } +} \ No newline at end of file diff --git a/cloudfunctions/project.private.config.json b/cloudfunctions/project.private.config.json new file mode 100644 index 0000000..42ff49d --- /dev/null +++ b/cloudfunctions/project.private.config.json @@ -0,0 +1,7 @@ +{ + "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", + "projectname": "cloudfunctions", + "setting": { + "compileHotReLoad": true + } +} \ No newline at end of file diff --git a/miniprogram/app.js b/miniprogram/app.js index 51d56f3..50a8a54 100644 --- a/miniprogram/app.js +++ b/miniprogram/app.js @@ -18,13 +18,15 @@ // this.globalData = {} }, globalData: { - // url: "http://111.198.10.15:11604/", - httpsUrl: "https://logapi.smartlog.work/", - httpsTestUrl: "https://smartlog.work/prodapi4test/", - url: "http://139.198.18.188:8083/", + httpsUrl: "https://logapi.smartlog.work/", + // httpsUrl: "http://139.198.18.188:8083/", // url: "http://127.0.0.1:8083/", - // httpsUrl: "http://127.0.0.1:8083/", + //httpsUrl: "http://127.0.0.1:8083/", openid: null, - indexCount:1 - }, + indexCount:1, + nickName:"", + userName:"", + role:"", + devcode:"" + } }) diff --git a/miniprogram/app.json b/miniprogram/app.json index d23f798..2b6db76 100644 --- a/miniprogram/app.json +++ b/miniprogram/app.json @@ -1,15 +1,17 @@ { "cloud": true, "pages": [ + "pages/login/login", "pages/indexapp/indexapp", "pages/earth/earth", "pages/applog/applog", "pages/addDevice/addDevice", "pages/addDevicelog/addDeviceLog", - "pages/searchLog/searchLog" + "pages/searchLog/searchLog", + "pages/notice/notice" ], "window": { - "backgroundColor": "#F6F6F6", + "backgroundColor": "#E6D480", "backgroundTextStyle": "light", "navigationBarBackgroundColor": "#FFCF00", "navigationBarTitleText": "智慧施工", @@ -46,11 +48,11 @@ "desc": "你的位置信息将用于小程序位置接口的效果展示" } }, + "requiredPrivateInfos": ["getLocation", "chooseLocation"], "networkTimeout": { "request": 30000, "connectSocket": 30000, "uploadFile": 30000, "downloadFile": 30000 - }, - "style": "v2" + } } \ No newline at end of file diff --git a/miniprogram/images/applocat.png b/miniprogram/images/applocat.png new file mode 100644 index 0000000..fe49f54 --- /dev/null +++ b/miniprogram/images/applocat.png Binary files differ diff --git a/cloudfunctions/project.config.json b/cloudfunctions/project.config.json new file mode 100644 index 0000000..2b3119a --- /dev/null +++ b/cloudfunctions/project.config.json @@ -0,0 +1,28 @@ +{ + "appid": "wx2cef527a000f87c9", + "compileType": "miniprogram", + "libVersion": "2.27.3", + "packOptions": { + "ignore": [], + "include": [] + }, + "setting": { + "coverView": true, + "es6": true, + "postcss": true, + "minified": true, + "enhance": true, + "showShadowRootInWxmlPanel": true, + "packNpmRelationList": [], + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + } + }, + "condition": {}, + "editorSetting": { + "tabIndent": "insertSpaces", + "tabSize": 4 + } +} \ No newline at end of file diff --git a/cloudfunctions/project.private.config.json b/cloudfunctions/project.private.config.json new file mode 100644 index 0000000..42ff49d --- /dev/null +++ b/cloudfunctions/project.private.config.json @@ -0,0 +1,7 @@ +{ + "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", + "projectname": "cloudfunctions", + "setting": { + "compileHotReLoad": true + } +} \ No newline at end of file diff --git a/miniprogram/app.js b/miniprogram/app.js index 51d56f3..50a8a54 100644 --- a/miniprogram/app.js +++ b/miniprogram/app.js @@ -18,13 +18,15 @@ // this.globalData = {} }, globalData: { - // url: "http://111.198.10.15:11604/", - httpsUrl: "https://logapi.smartlog.work/", - httpsTestUrl: "https://smartlog.work/prodapi4test/", - url: "http://139.198.18.188:8083/", + httpsUrl: "https://logapi.smartlog.work/", + // httpsUrl: "http://139.198.18.188:8083/", // url: "http://127.0.0.1:8083/", - // httpsUrl: "http://127.0.0.1:8083/", + //httpsUrl: "http://127.0.0.1:8083/", openid: null, - indexCount:1 - }, + indexCount:1, + nickName:"", + userName:"", + role:"", + devcode:"" + } }) diff --git a/miniprogram/app.json b/miniprogram/app.json index d23f798..2b6db76 100644 --- a/miniprogram/app.json +++ b/miniprogram/app.json @@ -1,15 +1,17 @@ { "cloud": true, "pages": [ + "pages/login/login", "pages/indexapp/indexapp", "pages/earth/earth", "pages/applog/applog", "pages/addDevice/addDevice", "pages/addDevicelog/addDeviceLog", - "pages/searchLog/searchLog" + "pages/searchLog/searchLog", + "pages/notice/notice" ], "window": { - "backgroundColor": "#F6F6F6", + "backgroundColor": "#E6D480", "backgroundTextStyle": "light", "navigationBarBackgroundColor": "#FFCF00", "navigationBarTitleText": "智慧施工", @@ -46,11 +48,11 @@ "desc": "你的位置信息将用于小程序位置接口的效果展示" } }, + "requiredPrivateInfos": ["getLocation", "chooseLocation"], "networkTimeout": { "request": 30000, "connectSocket": 30000, "uploadFile": 30000, "downloadFile": 30000 - }, - "style": "v2" + } } \ No newline at end of file diff --git a/miniprogram/images/applocat.png b/miniprogram/images/applocat.png new file mode 100644 index 0000000..fe49f54 --- /dev/null +++ b/miniprogram/images/applocat.png Binary files differ diff --git a/miniprogram/images/back.png b/miniprogram/images/back.png new file mode 100644 index 0000000..32ac82d --- /dev/null +++ b/miniprogram/images/back.png Binary files differ diff --git a/cloudfunctions/project.config.json b/cloudfunctions/project.config.json new file mode 100644 index 0000000..2b3119a --- /dev/null +++ b/cloudfunctions/project.config.json @@ -0,0 +1,28 @@ +{ + "appid": "wx2cef527a000f87c9", + "compileType": "miniprogram", + "libVersion": "2.27.3", + "packOptions": { + "ignore": [], + "include": [] + }, + "setting": { + "coverView": true, + "es6": true, + "postcss": true, + "minified": true, + "enhance": true, + "showShadowRootInWxmlPanel": true, + "packNpmRelationList": [], + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + } + }, + "condition": {}, + "editorSetting": { + "tabIndent": "insertSpaces", + "tabSize": 4 + } +} \ No newline at end of file diff --git a/cloudfunctions/project.private.config.json b/cloudfunctions/project.private.config.json new file mode 100644 index 0000000..42ff49d --- /dev/null +++ b/cloudfunctions/project.private.config.json @@ -0,0 +1,7 @@ +{ + "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", + "projectname": "cloudfunctions", + "setting": { + "compileHotReLoad": true + } +} \ No newline at end of file diff --git a/miniprogram/app.js b/miniprogram/app.js index 51d56f3..50a8a54 100644 --- a/miniprogram/app.js +++ b/miniprogram/app.js @@ -18,13 +18,15 @@ // this.globalData = {} }, globalData: { - // url: "http://111.198.10.15:11604/", - httpsUrl: "https://logapi.smartlog.work/", - httpsTestUrl: "https://smartlog.work/prodapi4test/", - url: "http://139.198.18.188:8083/", + httpsUrl: "https://logapi.smartlog.work/", + // httpsUrl: "http://139.198.18.188:8083/", // url: "http://127.0.0.1:8083/", - // httpsUrl: "http://127.0.0.1:8083/", + //httpsUrl: "http://127.0.0.1:8083/", openid: null, - indexCount:1 - }, + indexCount:1, + nickName:"", + userName:"", + role:"", + devcode:"" + } }) diff --git a/miniprogram/app.json b/miniprogram/app.json index d23f798..2b6db76 100644 --- a/miniprogram/app.json +++ b/miniprogram/app.json @@ -1,15 +1,17 @@ { "cloud": true, "pages": [ + "pages/login/login", "pages/indexapp/indexapp", "pages/earth/earth", "pages/applog/applog", "pages/addDevice/addDevice", "pages/addDevicelog/addDeviceLog", - "pages/searchLog/searchLog" + "pages/searchLog/searchLog", + "pages/notice/notice" ], "window": { - "backgroundColor": "#F6F6F6", + "backgroundColor": "#E6D480", "backgroundTextStyle": "light", "navigationBarBackgroundColor": "#FFCF00", "navigationBarTitleText": "智慧施工", @@ -46,11 +48,11 @@ "desc": "你的位置信息将用于小程序位置接口的效果展示" } }, + "requiredPrivateInfos": ["getLocation", "chooseLocation"], "networkTimeout": { "request": 30000, "connectSocket": 30000, "uploadFile": 30000, "downloadFile": 30000 - }, - "style": "v2" + } } \ No newline at end of file diff --git a/miniprogram/images/applocat.png b/miniprogram/images/applocat.png new file mode 100644 index 0000000..fe49f54 --- /dev/null +++ b/miniprogram/images/applocat.png Binary files differ diff --git a/miniprogram/images/back.png b/miniprogram/images/back.png new file mode 100644 index 0000000..32ac82d --- /dev/null +++ b/miniprogram/images/back.png Binary files differ diff --git a/miniprogram/images/bottom.png b/miniprogram/images/bottom.png new file mode 100644 index 0000000..d910e98 --- /dev/null +++ b/miniprogram/images/bottom.png Binary files differ diff --git a/cloudfunctions/project.config.json b/cloudfunctions/project.config.json new file mode 100644 index 0000000..2b3119a --- /dev/null +++ b/cloudfunctions/project.config.json @@ -0,0 +1,28 @@ +{ + "appid": "wx2cef527a000f87c9", + "compileType": "miniprogram", + "libVersion": "2.27.3", + "packOptions": { + "ignore": [], + "include": [] + }, + "setting": { + "coverView": true, + "es6": true, + "postcss": true, + "minified": true, + "enhance": true, + "showShadowRootInWxmlPanel": true, + "packNpmRelationList": [], + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + } + }, + "condition": {}, + "editorSetting": { + "tabIndent": "insertSpaces", + "tabSize": 4 + } +} \ No newline at end of file diff --git a/cloudfunctions/project.private.config.json b/cloudfunctions/project.private.config.json new file mode 100644 index 0000000..42ff49d --- /dev/null +++ b/cloudfunctions/project.private.config.json @@ -0,0 +1,7 @@ +{ + "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", + "projectname": "cloudfunctions", + "setting": { + "compileHotReLoad": true + } +} \ No newline at end of file diff --git a/miniprogram/app.js b/miniprogram/app.js index 51d56f3..50a8a54 100644 --- a/miniprogram/app.js +++ b/miniprogram/app.js @@ -18,13 +18,15 @@ // this.globalData = {} }, globalData: { - // url: "http://111.198.10.15:11604/", - httpsUrl: "https://logapi.smartlog.work/", - httpsTestUrl: "https://smartlog.work/prodapi4test/", - url: "http://139.198.18.188:8083/", + httpsUrl: "https://logapi.smartlog.work/", + // httpsUrl: "http://139.198.18.188:8083/", // url: "http://127.0.0.1:8083/", - // httpsUrl: "http://127.0.0.1:8083/", + //httpsUrl: "http://127.0.0.1:8083/", openid: null, - indexCount:1 - }, + indexCount:1, + nickName:"", + userName:"", + role:"", + devcode:"" + } }) diff --git a/miniprogram/app.json b/miniprogram/app.json index d23f798..2b6db76 100644 --- a/miniprogram/app.json +++ b/miniprogram/app.json @@ -1,15 +1,17 @@ { "cloud": true, "pages": [ + "pages/login/login", "pages/indexapp/indexapp", "pages/earth/earth", "pages/applog/applog", "pages/addDevice/addDevice", "pages/addDevicelog/addDeviceLog", - "pages/searchLog/searchLog" + "pages/searchLog/searchLog", + "pages/notice/notice" ], "window": { - "backgroundColor": "#F6F6F6", + "backgroundColor": "#E6D480", "backgroundTextStyle": "light", "navigationBarBackgroundColor": "#FFCF00", "navigationBarTitleText": "智慧施工", @@ -46,11 +48,11 @@ "desc": "你的位置信息将用于小程序位置接口的效果展示" } }, + "requiredPrivateInfos": ["getLocation", "chooseLocation"], "networkTimeout": { "request": 30000, "connectSocket": 30000, "uploadFile": 30000, "downloadFile": 30000 - }, - "style": "v2" + } } \ No newline at end of file diff --git a/miniprogram/images/applocat.png b/miniprogram/images/applocat.png new file mode 100644 index 0000000..fe49f54 --- /dev/null +++ b/miniprogram/images/applocat.png Binary files differ diff --git a/miniprogram/images/back.png b/miniprogram/images/back.png new file mode 100644 index 0000000..32ac82d --- /dev/null +++ b/miniprogram/images/back.png Binary files differ diff --git a/miniprogram/images/bottom.png b/miniprogram/images/bottom.png new file mode 100644 index 0000000..d910e98 --- /dev/null +++ b/miniprogram/images/bottom.png Binary files differ diff --git a/miniprogram/images/header.png b/miniprogram/images/header.png new file mode 100644 index 0000000..6ea222e --- /dev/null +++ b/miniprogram/images/header.png Binary files differ diff --git a/cloudfunctions/project.config.json b/cloudfunctions/project.config.json new file mode 100644 index 0000000..2b3119a --- /dev/null +++ b/cloudfunctions/project.config.json @@ -0,0 +1,28 @@ +{ + "appid": "wx2cef527a000f87c9", + "compileType": "miniprogram", + "libVersion": "2.27.3", + "packOptions": { + "ignore": [], + "include": [] + }, + "setting": { + "coverView": true, + "es6": true, + "postcss": true, + "minified": true, + "enhance": true, + "showShadowRootInWxmlPanel": true, + "packNpmRelationList": [], + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + } + }, + "condition": {}, + "editorSetting": { + "tabIndent": "insertSpaces", + "tabSize": 4 + } +} \ No newline at end of file diff --git a/cloudfunctions/project.private.config.json b/cloudfunctions/project.private.config.json new file mode 100644 index 0000000..42ff49d --- /dev/null +++ b/cloudfunctions/project.private.config.json @@ -0,0 +1,7 @@ +{ + "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", + "projectname": "cloudfunctions", + "setting": { + "compileHotReLoad": true + } +} \ No newline at end of file diff --git a/miniprogram/app.js b/miniprogram/app.js index 51d56f3..50a8a54 100644 --- a/miniprogram/app.js +++ b/miniprogram/app.js @@ -18,13 +18,15 @@ // this.globalData = {} }, globalData: { - // url: "http://111.198.10.15:11604/", - httpsUrl: "https://logapi.smartlog.work/", - httpsTestUrl: "https://smartlog.work/prodapi4test/", - url: "http://139.198.18.188:8083/", + httpsUrl: "https://logapi.smartlog.work/", + // httpsUrl: "http://139.198.18.188:8083/", // url: "http://127.0.0.1:8083/", - // httpsUrl: "http://127.0.0.1:8083/", + //httpsUrl: "http://127.0.0.1:8083/", openid: null, - indexCount:1 - }, + indexCount:1, + nickName:"", + userName:"", + role:"", + devcode:"" + } }) diff --git a/miniprogram/app.json b/miniprogram/app.json index d23f798..2b6db76 100644 --- a/miniprogram/app.json +++ b/miniprogram/app.json @@ -1,15 +1,17 @@ { "cloud": true, "pages": [ + "pages/login/login", "pages/indexapp/indexapp", "pages/earth/earth", "pages/applog/applog", "pages/addDevice/addDevice", "pages/addDevicelog/addDeviceLog", - "pages/searchLog/searchLog" + "pages/searchLog/searchLog", + "pages/notice/notice" ], "window": { - "backgroundColor": "#F6F6F6", + "backgroundColor": "#E6D480", "backgroundTextStyle": "light", "navigationBarBackgroundColor": "#FFCF00", "navigationBarTitleText": "智慧施工", @@ -46,11 +48,11 @@ "desc": "你的位置信息将用于小程序位置接口的效果展示" } }, + "requiredPrivateInfos": ["getLocation", "chooseLocation"], "networkTimeout": { "request": 30000, "connectSocket": 30000, "uploadFile": 30000, "downloadFile": 30000 - }, - "style": "v2" + } } \ No newline at end of file diff --git a/miniprogram/images/applocat.png b/miniprogram/images/applocat.png new file mode 100644 index 0000000..fe49f54 --- /dev/null +++ b/miniprogram/images/applocat.png Binary files differ diff --git a/miniprogram/images/back.png b/miniprogram/images/back.png new file mode 100644 index 0000000..32ac82d --- /dev/null +++ b/miniprogram/images/back.png Binary files differ diff --git a/miniprogram/images/bottom.png b/miniprogram/images/bottom.png new file mode 100644 index 0000000..d910e98 --- /dev/null +++ b/miniprogram/images/bottom.png Binary files differ diff --git a/miniprogram/images/header.png b/miniprogram/images/header.png new file mode 100644 index 0000000..6ea222e --- /dev/null +++ b/miniprogram/images/header.png Binary files differ diff --git a/miniprogram/images/login.png b/miniprogram/images/login.png index 8b73cc0..6471c46 100644 --- a/miniprogram/images/login.png +++ b/miniprogram/images/login.png Binary files differ diff --git a/cloudfunctions/project.config.json b/cloudfunctions/project.config.json new file mode 100644 index 0000000..2b3119a --- /dev/null +++ b/cloudfunctions/project.config.json @@ -0,0 +1,28 @@ +{ + "appid": "wx2cef527a000f87c9", + "compileType": "miniprogram", + "libVersion": "2.27.3", + "packOptions": { + "ignore": [], + "include": [] + }, + "setting": { + "coverView": true, + "es6": true, + "postcss": true, + "minified": true, + "enhance": true, + "showShadowRootInWxmlPanel": true, + "packNpmRelationList": [], + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + } + }, + "condition": {}, + "editorSetting": { + "tabIndent": "insertSpaces", + "tabSize": 4 + } +} \ No newline at end of file diff --git a/cloudfunctions/project.private.config.json b/cloudfunctions/project.private.config.json new file mode 100644 index 0000000..42ff49d --- /dev/null +++ b/cloudfunctions/project.private.config.json @@ -0,0 +1,7 @@ +{ + "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", + "projectname": "cloudfunctions", + "setting": { + "compileHotReLoad": true + } +} \ No newline at end of file diff --git a/miniprogram/app.js b/miniprogram/app.js index 51d56f3..50a8a54 100644 --- a/miniprogram/app.js +++ b/miniprogram/app.js @@ -18,13 +18,15 @@ // this.globalData = {} }, globalData: { - // url: "http://111.198.10.15:11604/", - httpsUrl: "https://logapi.smartlog.work/", - httpsTestUrl: "https://smartlog.work/prodapi4test/", - url: "http://139.198.18.188:8083/", + httpsUrl: "https://logapi.smartlog.work/", + // httpsUrl: "http://139.198.18.188:8083/", // url: "http://127.0.0.1:8083/", - // httpsUrl: "http://127.0.0.1:8083/", + //httpsUrl: "http://127.0.0.1:8083/", openid: null, - indexCount:1 - }, + indexCount:1, + nickName:"", + userName:"", + role:"", + devcode:"" + } }) diff --git a/miniprogram/app.json b/miniprogram/app.json index d23f798..2b6db76 100644 --- a/miniprogram/app.json +++ b/miniprogram/app.json @@ -1,15 +1,17 @@ { "cloud": true, "pages": [ + "pages/login/login", "pages/indexapp/indexapp", "pages/earth/earth", "pages/applog/applog", "pages/addDevice/addDevice", "pages/addDevicelog/addDeviceLog", - "pages/searchLog/searchLog" + "pages/searchLog/searchLog", + "pages/notice/notice" ], "window": { - "backgroundColor": "#F6F6F6", + "backgroundColor": "#E6D480", "backgroundTextStyle": "light", "navigationBarBackgroundColor": "#FFCF00", "navigationBarTitleText": "智慧施工", @@ -46,11 +48,11 @@ "desc": "你的位置信息将用于小程序位置接口的效果展示" } }, + "requiredPrivateInfos": ["getLocation", "chooseLocation"], "networkTimeout": { "request": 30000, "connectSocket": 30000, "uploadFile": 30000, "downloadFile": 30000 - }, - "style": "v2" + } } \ No newline at end of file diff --git a/miniprogram/images/applocat.png b/miniprogram/images/applocat.png new file mode 100644 index 0000000..fe49f54 --- /dev/null +++ b/miniprogram/images/applocat.png Binary files differ diff --git a/miniprogram/images/back.png b/miniprogram/images/back.png new file mode 100644 index 0000000..32ac82d --- /dev/null +++ b/miniprogram/images/back.png Binary files differ diff --git a/miniprogram/images/bottom.png b/miniprogram/images/bottom.png new file mode 100644 index 0000000..d910e98 --- /dev/null +++ b/miniprogram/images/bottom.png Binary files differ diff --git a/miniprogram/images/header.png b/miniprogram/images/header.png new file mode 100644 index 0000000..6ea222e --- /dev/null +++ b/miniprogram/images/header.png Binary files differ diff --git a/miniprogram/images/login.png b/miniprogram/images/login.png index 8b73cc0..6471c46 100644 --- a/miniprogram/images/login.png +++ b/miniprogram/images/login.png Binary files differ diff --git a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss index 5a591fb..c9c35b5 100644 --- a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss +++ b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:100%;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:100%}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file +@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:650rpx;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:600rpx}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file diff --git a/cloudfunctions/project.config.json b/cloudfunctions/project.config.json new file mode 100644 index 0000000..2b3119a --- /dev/null +++ b/cloudfunctions/project.config.json @@ -0,0 +1,28 @@ +{ + "appid": "wx2cef527a000f87c9", + "compileType": "miniprogram", + "libVersion": "2.27.3", + "packOptions": { + "ignore": [], + "include": [] + }, + "setting": { + "coverView": true, + "es6": true, + "postcss": true, + "minified": true, + "enhance": true, + "showShadowRootInWxmlPanel": true, + "packNpmRelationList": [], + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + } + }, + "condition": {}, + "editorSetting": { + "tabIndent": "insertSpaces", + "tabSize": 4 + } +} \ No newline at end of file diff --git a/cloudfunctions/project.private.config.json b/cloudfunctions/project.private.config.json new file mode 100644 index 0000000..42ff49d --- /dev/null +++ b/cloudfunctions/project.private.config.json @@ -0,0 +1,7 @@ +{ + "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", + "projectname": "cloudfunctions", + "setting": { + "compileHotReLoad": true + } +} \ No newline at end of file diff --git a/miniprogram/app.js b/miniprogram/app.js index 51d56f3..50a8a54 100644 --- a/miniprogram/app.js +++ b/miniprogram/app.js @@ -18,13 +18,15 @@ // this.globalData = {} }, globalData: { - // url: "http://111.198.10.15:11604/", - httpsUrl: "https://logapi.smartlog.work/", - httpsTestUrl: "https://smartlog.work/prodapi4test/", - url: "http://139.198.18.188:8083/", + httpsUrl: "https://logapi.smartlog.work/", + // httpsUrl: "http://139.198.18.188:8083/", // url: "http://127.0.0.1:8083/", - // httpsUrl: "http://127.0.0.1:8083/", + //httpsUrl: "http://127.0.0.1:8083/", openid: null, - indexCount:1 - }, + indexCount:1, + nickName:"", + userName:"", + role:"", + devcode:"" + } }) diff --git a/miniprogram/app.json b/miniprogram/app.json index d23f798..2b6db76 100644 --- a/miniprogram/app.json +++ b/miniprogram/app.json @@ -1,15 +1,17 @@ { "cloud": true, "pages": [ + "pages/login/login", "pages/indexapp/indexapp", "pages/earth/earth", "pages/applog/applog", "pages/addDevice/addDevice", "pages/addDevicelog/addDeviceLog", - "pages/searchLog/searchLog" + "pages/searchLog/searchLog", + "pages/notice/notice" ], "window": { - "backgroundColor": "#F6F6F6", + "backgroundColor": "#E6D480", "backgroundTextStyle": "light", "navigationBarBackgroundColor": "#FFCF00", "navigationBarTitleText": "智慧施工", @@ -46,11 +48,11 @@ "desc": "你的位置信息将用于小程序位置接口的效果展示" } }, + "requiredPrivateInfos": ["getLocation", "chooseLocation"], "networkTimeout": { "request": 30000, "connectSocket": 30000, "uploadFile": 30000, "downloadFile": 30000 - }, - "style": "v2" + } } \ No newline at end of file diff --git a/miniprogram/images/applocat.png b/miniprogram/images/applocat.png new file mode 100644 index 0000000..fe49f54 --- /dev/null +++ b/miniprogram/images/applocat.png Binary files differ diff --git a/miniprogram/images/back.png b/miniprogram/images/back.png new file mode 100644 index 0000000..32ac82d --- /dev/null +++ b/miniprogram/images/back.png Binary files differ diff --git a/miniprogram/images/bottom.png b/miniprogram/images/bottom.png new file mode 100644 index 0000000..d910e98 --- /dev/null +++ b/miniprogram/images/bottom.png Binary files differ diff --git a/miniprogram/images/header.png b/miniprogram/images/header.png new file mode 100644 index 0000000..6ea222e --- /dev/null +++ b/miniprogram/images/header.png Binary files differ diff --git a/miniprogram/images/login.png b/miniprogram/images/login.png index 8b73cc0..6471c46 100644 --- a/miniprogram/images/login.png +++ b/miniprogram/images/login.png Binary files differ diff --git a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss index 5a591fb..c9c35b5 100644 --- a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss +++ b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:100%;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:100%}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file +@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:650rpx;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:600rpx}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file diff --git a/miniprogram/pages/addDevice/addDevice.js b/miniprogram/pages/addDevice/addDevice.js index 2783674..78f00b7 100644 --- a/miniprogram/pages/addDevice/addDevice.js +++ b/miniprogram/pages/addDevice/addDevice.js @@ -1,5 +1,7 @@ // miniprogram/pages/addDevice/addDevice.js // import WxValidate from '../../utils/WxValidate.js' +var QQMapWX = require('../../libs/qqmap-wx-jssdk.js'); +var qqmapsdk; var app = getApp() Page({ @@ -11,32 +13,10 @@ canvasWidth: '', longitude: '', latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], + option1: [], personoption1: [], projectoption: [], + devtypeList:[], show: false, form: { devcode: "", @@ -59,7 +39,10 @@ project: "", area: "", street: "", - wellname: "" + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '', }, fileList: [] }, @@ -117,12 +100,14 @@ var that = this; //初始化表单内容为上次填写值 var cacheForms = wx.getStorageSync('cacheList') - if (cacheForms) { + cacheForms.photopath1='' + cacheForms.photopath2='' + cacheForms.photopath3='' + that.data.fileList=[] that.setData({ form: cacheForms, devcode: cacheForms.devcode, - }) } var form = that.data.form @@ -155,55 +140,89 @@ } }) + +//获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + that.setData({ + option1: welltypeArr + }) + } + } +}) + + //获取人员下拉列表 - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/getUser", + data:{ + tips:'repair' }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data.code == 200) { + var users = res.data.data + var personArr = []; + for (var i = 0; i < users.length; i++) { + var person = { + text: users[i].name, + value: users[i].name + }; + personArr.push(person); + } + that.setData({ + personoption1: personArr + }) } - that.setData({ - personoption1: personArr - }) } - }).catch(err => { - console.error(err); - }) + }) + - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - that.setData({ - projectoption: projectArr - }) + success(res){ + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); + } + that.setData({ + projectoption: projectArr + }) + } } - }).catch(err => { - console.error(err); - }) + }) + var installtime = 'form.installtimeFmt'; var dateNow = this.formatDate(); this.setData({ @@ -211,8 +230,40 @@ installtimeFmt: dateNow, [installtime]: dateNow, }); + + + + /** + * 获取设备类型下拉列表 + */ + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/deviceType", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var TypeList = res.data.data + var typeArr = []; + for (var i = 0; i < TypeList.length; i++) { + var type = { + text: TypeList[i].productName, + value: TypeList[i].productName + }; + typeArr.push(type); + } + that.setData({ + devtypeList: typeArr + }) + } + } + }) }, + + + /** * 生命周期函数--监听页面初次渲染完成 */ @@ -280,29 +331,7 @@ }, - - //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 - drawText: function (ctx, str, leftWidth, initHeight, titleHeight, canvasWidth) { - var lineWidth = 0; - var lastSubStrIndex = 0; //每次开始截取的字符串的索引 - for (let i = 0; i < str.length; i++) { - lineWidth += ctx.measureText(str[i]).width; - if (lineWidth > canvasWidth) { - ctx.fillText(str.substring(lastSubStrIndex, i), leftWidth, initHeight); //绘制截取部分 - initHeight = initHeight + leftWidth * 2; //22为字体的高度 - lineWidth = 0; - lastSubStrIndex = i; - // titleHeight += 40; - } - if (i == str.length - 1) { //绘制剩余部分 - ctx.fillText(str.substring(lastSubStrIndex, i + 1), leftWidth, initHeight); - } - } - // // 标题border-bottom 线距顶部距离 - // titleHeight = titleHeight + 10; - // return titleHeight - }, - + //验证表单 formValidate() { if (this.data.form.devcode == "") { @@ -312,27 +341,20 @@ }) return false } - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } if (this.data.form.wellcode == "") { wx.showToast({ icon: 'none', @@ -348,22 +370,10 @@ }) return false } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null) { + + if (this.data.form.installperson == "") { wx.showToast({ icon: 'none', title: '安装人员不能为空!', @@ -408,56 +418,90 @@ } return true; }, + //提交表单 formSubmit: function (event) { + console.log(this.data.form) + //表单参数验证 if (!this.formValidate()) { return false; } var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDevice', + //验证设备编号长度 + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/getDevTypeLength", data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceAdd/add" + code: encodeURI(this.data.form.devicetype) }, - }).then(res => { - if (res.result.code == 500) { - wx.showToast({ - title: '设备编号已安装!', - }) - } else if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - //用于回显 - wx.setStorageSync('cacheList', that.data.form) - //提交成功后提示用户操作 - if (res.confirm) { - wx.switchTab({ - url: '../earth/earth' - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (""==res.data.data ||res.data.data == that.data.form.devcode.length) { + that.saveDevice() + } else { //编号位数不对提示 + wx.showToast({ + icon: 'none', + title: '设备编号位数不对!', + duration: 1000 + }) + return false + } } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "提交失败", - }) }) }, + + //保存设备基本信息 + saveDevice() { + var that = this; + //设置照片路径 + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopathForm = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopathForm]: fileList[i].url.split("static/")[1] + }) + } + //表单提交 + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 500) { + wx.showToast({ + title: '设备编号已安装!', + }) + } else if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + //用于回显 + wx.setStorageSync('cacheList', that.data.form) + //提交成功后提示用户操作 + if (res.confirm) { + wx.switchTab({ + url: '../earth/earth' + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } + }, + fail(err) { + wx.showToast({ + title: '提交失败!', + }) + } + }) + }, + + //input 输入框设置值 confirm(event) { var that = this; var formValue = event.detail.value; @@ -466,8 +510,30 @@ that.setData({ [fromN]: formValue }) + //若输入是设备编号,自动获取设备类型 + if('devcode'==formName){ + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", + data: { + devcode: formValue, + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + that.setData({ + [formDevicetype]: res.data + }); + } + } + }) + } }, + //扫描设备获取编号和设备类型 scan() { var _this = this; wx.scanCode({ @@ -477,23 +543,28 @@ _this.setData({ [formdevcode]: devcode }); - wx.cloud.callFunction({ - name: 'findModeCode', + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", data: { devcode: devcode, - url: app.globalData.url + "appDeviceAdd/findModeCodeByCode" }, - }).then(res => { - if (res.result) { - var formDevicetype = 'form.devicetype' - _this.setData({ - [formDevicetype]: res.result - }); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + _this.setData({ + [formDevicetype]: res.data + }); + } } }) } }) }, + //粘贴经纬度 paste() { var _this = this; wx.getClipboardData({ @@ -510,9 +581,11 @@ longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), }); + _this.showAddress(_this.data.form.longitude,_this.data.form.latitude,_this) } }) }, + //设置经类型 selectValue(value) { var that = this; @@ -521,6 +594,16 @@ [wellType]: value.detail }) }, + + //设置设备类型 + selectDevType(event) { + var that = this; + var devtype = 'form.devicetype'; + that.setData({ + [devtype]: event.detail + }) + }, + //设置运维人员 selectpersonValue(event) { var that = this; var installPerson = 'form.installperson'; @@ -528,6 +611,7 @@ [installPerson]: event.detail }) }, + //设置项目 selectprojectValue(event) { var that = this; var project = 'form.project'; @@ -535,8 +619,41 @@ [project]: event.detail }) }, + showAddress :function(longitude, latitude, self) { + // 实例化腾讯地图API核心类 + qqmapsdk = new QQMapWX({ + key: 'BGPBZ-C5O3P-ROUDR-LWC4J-63EKH-V5FRX'//此处使用你自己申请的key + }) + // 腾讯地图调用接口 + qqmapsdk.reverseGeocoder({ + location: { + latitude: latitude, + longitude: longitude + }, + success: function (res) { + self.setData({ + 'form.area':res.result.address.slice(0,res.result.address.indexOf('区')+1), + 'form.street':res.result.address.slice(res.result.address.indexOf('区')+1) + }) + }, + fail: function (res) { + console.log(res); + }, + complete: function (res) { + } + }); + }, + //上传照片 afterRead(event) { var _this = this; + if (_this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '请先填写设备编号!\r\n否则水印中无编号', + duration: 2000 + }) + return false + } const { file } = event.detail; @@ -576,78 +693,8 @@ }) } }) - // 压缩图片 - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // //获取图片尺寸 - // wx.getImageInfo({ - // src: convertpath, - // success(res) { - // _this.setData({ - // canvasHeight: res.height, - // canvasWidth: res.width - // }) - // var ctx = wx.createCanvasContext('firstCanvas') - - // //将图片src放到cancas内,宽高为图片大小 - // ctx.drawImage(convertpath, 0, 0, res.width, res.height) - // //将声明的时间放入canvas - // ctx.setFontSize(30 * (res.width / 750)) //注意:设置文字大小必须放在填充文字之前,否则不生效 - // ctx.setFillStyle('blue') - // var text = "编号:" + _this.data.form.devcode + "\n经度:" + _this.data.form.longitude + "\n纬度:" + _this.data.form.latitude - // // _this.drawText(ctx,text,20, 70, 5, res.width) - // _this.drawText(ctx, text, 15 * (res.width / 750), 70 * (res.width / 750), 5, res.width) - - // // ctx.fillText(text, 0, 40) - // // ctx.strokeText(_this.data.form.devcode, 0, 30) - // //生成水印图 - // ctx.draw(false, function () { - // wx.canvasToTempFilePath({ - // canvasId: 'firstCanvas', - // success: (res) => { - // wx.compressImage({ - // src: res.tempFilePath, - // quality: 25, - // success: function (res) { - // //上传照片至服务器 - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: res.tempFilePath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // } - // }) - // //// - // } - // }) - // }) - // } - // }) - // } - // }); }, + //删除照片 deletePhoto(event) { var image_index = event.detail.index var fileList_new = this.data.fileList; diff --git a/cloudfunctions/project.config.json b/cloudfunctions/project.config.json new file mode 100644 index 0000000..2b3119a --- /dev/null +++ b/cloudfunctions/project.config.json @@ -0,0 +1,28 @@ +{ + "appid": "wx2cef527a000f87c9", + "compileType": "miniprogram", + "libVersion": "2.27.3", + "packOptions": { + "ignore": [], + "include": [] + }, + "setting": { + "coverView": true, + "es6": true, + "postcss": true, + "minified": true, + "enhance": true, + "showShadowRootInWxmlPanel": true, + "packNpmRelationList": [], + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + } + }, + "condition": {}, + "editorSetting": { + "tabIndent": "insertSpaces", + "tabSize": 4 + } +} \ No newline at end of file diff --git a/cloudfunctions/project.private.config.json b/cloudfunctions/project.private.config.json new file mode 100644 index 0000000..42ff49d --- /dev/null +++ b/cloudfunctions/project.private.config.json @@ -0,0 +1,7 @@ +{ + "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", + "projectname": "cloudfunctions", + "setting": { + "compileHotReLoad": true + } +} \ No newline at end of file diff --git a/miniprogram/app.js b/miniprogram/app.js index 51d56f3..50a8a54 100644 --- a/miniprogram/app.js +++ b/miniprogram/app.js @@ -18,13 +18,15 @@ // this.globalData = {} }, globalData: { - // url: "http://111.198.10.15:11604/", - httpsUrl: "https://logapi.smartlog.work/", - httpsTestUrl: "https://smartlog.work/prodapi4test/", - url: "http://139.198.18.188:8083/", + httpsUrl: "https://logapi.smartlog.work/", + // httpsUrl: "http://139.198.18.188:8083/", // url: "http://127.0.0.1:8083/", - // httpsUrl: "http://127.0.0.1:8083/", + //httpsUrl: "http://127.0.0.1:8083/", openid: null, - indexCount:1 - }, + indexCount:1, + nickName:"", + userName:"", + role:"", + devcode:"" + } }) diff --git a/miniprogram/app.json b/miniprogram/app.json index d23f798..2b6db76 100644 --- a/miniprogram/app.json +++ b/miniprogram/app.json @@ -1,15 +1,17 @@ { "cloud": true, "pages": [ + "pages/login/login", "pages/indexapp/indexapp", "pages/earth/earth", "pages/applog/applog", "pages/addDevice/addDevice", "pages/addDevicelog/addDeviceLog", - "pages/searchLog/searchLog" + "pages/searchLog/searchLog", + "pages/notice/notice" ], "window": { - "backgroundColor": "#F6F6F6", + "backgroundColor": "#E6D480", "backgroundTextStyle": "light", "navigationBarBackgroundColor": "#FFCF00", "navigationBarTitleText": "智慧施工", @@ -46,11 +48,11 @@ "desc": "你的位置信息将用于小程序位置接口的效果展示" } }, + "requiredPrivateInfos": ["getLocation", "chooseLocation"], "networkTimeout": { "request": 30000, "connectSocket": 30000, "uploadFile": 30000, "downloadFile": 30000 - }, - "style": "v2" + } } \ No newline at end of file diff --git a/miniprogram/images/applocat.png b/miniprogram/images/applocat.png new file mode 100644 index 0000000..fe49f54 --- /dev/null +++ b/miniprogram/images/applocat.png Binary files differ diff --git a/miniprogram/images/back.png b/miniprogram/images/back.png new file mode 100644 index 0000000..32ac82d --- /dev/null +++ b/miniprogram/images/back.png Binary files differ diff --git a/miniprogram/images/bottom.png b/miniprogram/images/bottom.png new file mode 100644 index 0000000..d910e98 --- /dev/null +++ b/miniprogram/images/bottom.png Binary files differ diff --git a/miniprogram/images/header.png b/miniprogram/images/header.png new file mode 100644 index 0000000..6ea222e --- /dev/null +++ b/miniprogram/images/header.png Binary files differ diff --git a/miniprogram/images/login.png b/miniprogram/images/login.png index 8b73cc0..6471c46 100644 --- a/miniprogram/images/login.png +++ b/miniprogram/images/login.png Binary files differ diff --git a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss index 5a591fb..c9c35b5 100644 --- a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss +++ b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:100%;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:100%}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file +@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:650rpx;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:600rpx}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file diff --git a/miniprogram/pages/addDevice/addDevice.js b/miniprogram/pages/addDevice/addDevice.js index 2783674..78f00b7 100644 --- a/miniprogram/pages/addDevice/addDevice.js +++ b/miniprogram/pages/addDevice/addDevice.js @@ -1,5 +1,7 @@ // miniprogram/pages/addDevice/addDevice.js // import WxValidate from '../../utils/WxValidate.js' +var QQMapWX = require('../../libs/qqmap-wx-jssdk.js'); +var qqmapsdk; var app = getApp() Page({ @@ -11,32 +13,10 @@ canvasWidth: '', longitude: '', latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], + option1: [], personoption1: [], projectoption: [], + devtypeList:[], show: false, form: { devcode: "", @@ -59,7 +39,10 @@ project: "", area: "", street: "", - wellname: "" + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '', }, fileList: [] }, @@ -117,12 +100,14 @@ var that = this; //初始化表单内容为上次填写值 var cacheForms = wx.getStorageSync('cacheList') - if (cacheForms) { + cacheForms.photopath1='' + cacheForms.photopath2='' + cacheForms.photopath3='' + that.data.fileList=[] that.setData({ form: cacheForms, devcode: cacheForms.devcode, - }) } var form = that.data.form @@ -155,55 +140,89 @@ } }) + +//获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + that.setData({ + option1: welltypeArr + }) + } + } +}) + + //获取人员下拉列表 - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/getUser", + data:{ + tips:'repair' }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data.code == 200) { + var users = res.data.data + var personArr = []; + for (var i = 0; i < users.length; i++) { + var person = { + text: users[i].name, + value: users[i].name + }; + personArr.push(person); + } + that.setData({ + personoption1: personArr + }) } - that.setData({ - personoption1: personArr - }) } - }).catch(err => { - console.error(err); - }) + }) + - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - that.setData({ - projectoption: projectArr - }) + success(res){ + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); + } + that.setData({ + projectoption: projectArr + }) + } } - }).catch(err => { - console.error(err); - }) + }) + var installtime = 'form.installtimeFmt'; var dateNow = this.formatDate(); this.setData({ @@ -211,8 +230,40 @@ installtimeFmt: dateNow, [installtime]: dateNow, }); + + + + /** + * 获取设备类型下拉列表 + */ + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/deviceType", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var TypeList = res.data.data + var typeArr = []; + for (var i = 0; i < TypeList.length; i++) { + var type = { + text: TypeList[i].productName, + value: TypeList[i].productName + }; + typeArr.push(type); + } + that.setData({ + devtypeList: typeArr + }) + } + } + }) }, + + + /** * 生命周期函数--监听页面初次渲染完成 */ @@ -280,29 +331,7 @@ }, - - //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 - drawText: function (ctx, str, leftWidth, initHeight, titleHeight, canvasWidth) { - var lineWidth = 0; - var lastSubStrIndex = 0; //每次开始截取的字符串的索引 - for (let i = 0; i < str.length; i++) { - lineWidth += ctx.measureText(str[i]).width; - if (lineWidth > canvasWidth) { - ctx.fillText(str.substring(lastSubStrIndex, i), leftWidth, initHeight); //绘制截取部分 - initHeight = initHeight + leftWidth * 2; //22为字体的高度 - lineWidth = 0; - lastSubStrIndex = i; - // titleHeight += 40; - } - if (i == str.length - 1) { //绘制剩余部分 - ctx.fillText(str.substring(lastSubStrIndex, i + 1), leftWidth, initHeight); - } - } - // // 标题border-bottom 线距顶部距离 - // titleHeight = titleHeight + 10; - // return titleHeight - }, - + //验证表单 formValidate() { if (this.data.form.devcode == "") { @@ -312,27 +341,20 @@ }) return false } - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } if (this.data.form.wellcode == "") { wx.showToast({ icon: 'none', @@ -348,22 +370,10 @@ }) return false } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null) { + + if (this.data.form.installperson == "") { wx.showToast({ icon: 'none', title: '安装人员不能为空!', @@ -408,56 +418,90 @@ } return true; }, + //提交表单 formSubmit: function (event) { + console.log(this.data.form) + //表单参数验证 if (!this.formValidate()) { return false; } var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDevice', + //验证设备编号长度 + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/getDevTypeLength", data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceAdd/add" + code: encodeURI(this.data.form.devicetype) }, - }).then(res => { - if (res.result.code == 500) { - wx.showToast({ - title: '设备编号已安装!', - }) - } else if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - //用于回显 - wx.setStorageSync('cacheList', that.data.form) - //提交成功后提示用户操作 - if (res.confirm) { - wx.switchTab({ - url: '../earth/earth' - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (""==res.data.data ||res.data.data == that.data.form.devcode.length) { + that.saveDevice() + } else { //编号位数不对提示 + wx.showToast({ + icon: 'none', + title: '设备编号位数不对!', + duration: 1000 + }) + return false + } } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "提交失败", - }) }) }, + + //保存设备基本信息 + saveDevice() { + var that = this; + //设置照片路径 + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopathForm = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopathForm]: fileList[i].url.split("static/")[1] + }) + } + //表单提交 + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 500) { + wx.showToast({ + title: '设备编号已安装!', + }) + } else if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + //用于回显 + wx.setStorageSync('cacheList', that.data.form) + //提交成功后提示用户操作 + if (res.confirm) { + wx.switchTab({ + url: '../earth/earth' + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } + }, + fail(err) { + wx.showToast({ + title: '提交失败!', + }) + } + }) + }, + + //input 输入框设置值 confirm(event) { var that = this; var formValue = event.detail.value; @@ -466,8 +510,30 @@ that.setData({ [fromN]: formValue }) + //若输入是设备编号,自动获取设备类型 + if('devcode'==formName){ + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", + data: { + devcode: formValue, + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + that.setData({ + [formDevicetype]: res.data + }); + } + } + }) + } }, + //扫描设备获取编号和设备类型 scan() { var _this = this; wx.scanCode({ @@ -477,23 +543,28 @@ _this.setData({ [formdevcode]: devcode }); - wx.cloud.callFunction({ - name: 'findModeCode', + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", data: { devcode: devcode, - url: app.globalData.url + "appDeviceAdd/findModeCodeByCode" }, - }).then(res => { - if (res.result) { - var formDevicetype = 'form.devicetype' - _this.setData({ - [formDevicetype]: res.result - }); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + _this.setData({ + [formDevicetype]: res.data + }); + } } }) } }) }, + //粘贴经纬度 paste() { var _this = this; wx.getClipboardData({ @@ -510,9 +581,11 @@ longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), }); + _this.showAddress(_this.data.form.longitude,_this.data.form.latitude,_this) } }) }, + //设置经类型 selectValue(value) { var that = this; @@ -521,6 +594,16 @@ [wellType]: value.detail }) }, + + //设置设备类型 + selectDevType(event) { + var that = this; + var devtype = 'form.devicetype'; + that.setData({ + [devtype]: event.detail + }) + }, + //设置运维人员 selectpersonValue(event) { var that = this; var installPerson = 'form.installperson'; @@ -528,6 +611,7 @@ [installPerson]: event.detail }) }, + //设置项目 selectprojectValue(event) { var that = this; var project = 'form.project'; @@ -535,8 +619,41 @@ [project]: event.detail }) }, + showAddress :function(longitude, latitude, self) { + // 实例化腾讯地图API核心类 + qqmapsdk = new QQMapWX({ + key: 'BGPBZ-C5O3P-ROUDR-LWC4J-63EKH-V5FRX'//此处使用你自己申请的key + }) + // 腾讯地图调用接口 + qqmapsdk.reverseGeocoder({ + location: { + latitude: latitude, + longitude: longitude + }, + success: function (res) { + self.setData({ + 'form.area':res.result.address.slice(0,res.result.address.indexOf('区')+1), + 'form.street':res.result.address.slice(res.result.address.indexOf('区')+1) + }) + }, + fail: function (res) { + console.log(res); + }, + complete: function (res) { + } + }); + }, + //上传照片 afterRead(event) { var _this = this; + if (_this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '请先填写设备编号!\r\n否则水印中无编号', + duration: 2000 + }) + return false + } const { file } = event.detail; @@ -576,78 +693,8 @@ }) } }) - // 压缩图片 - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // //获取图片尺寸 - // wx.getImageInfo({ - // src: convertpath, - // success(res) { - // _this.setData({ - // canvasHeight: res.height, - // canvasWidth: res.width - // }) - // var ctx = wx.createCanvasContext('firstCanvas') - - // //将图片src放到cancas内,宽高为图片大小 - // ctx.drawImage(convertpath, 0, 0, res.width, res.height) - // //将声明的时间放入canvas - // ctx.setFontSize(30 * (res.width / 750)) //注意:设置文字大小必须放在填充文字之前,否则不生效 - // ctx.setFillStyle('blue') - // var text = "编号:" + _this.data.form.devcode + "\n经度:" + _this.data.form.longitude + "\n纬度:" + _this.data.form.latitude - // // _this.drawText(ctx,text,20, 70, 5, res.width) - // _this.drawText(ctx, text, 15 * (res.width / 750), 70 * (res.width / 750), 5, res.width) - - // // ctx.fillText(text, 0, 40) - // // ctx.strokeText(_this.data.form.devcode, 0, 30) - // //生成水印图 - // ctx.draw(false, function () { - // wx.canvasToTempFilePath({ - // canvasId: 'firstCanvas', - // success: (res) => { - // wx.compressImage({ - // src: res.tempFilePath, - // quality: 25, - // success: function (res) { - // //上传照片至服务器 - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: res.tempFilePath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // } - // }) - // //// - // } - // }) - // }) - // } - // }) - // } - // }); }, + //删除照片 deletePhoto(event) { var image_index = event.detail.index var fileList_new = this.data.fileList; diff --git a/miniprogram/pages/addDevice/addDevice.wxml b/miniprogram/pages/addDevice/addDevice.wxml index b0977e2..f12c254 100644 --- a/miniprogram/pages/addDevice/addDevice.wxml +++ b/miniprogram/pages/addDevice/addDevice.wxml @@ -5,18 +5,30 @@ - + + + + + + + + + + + + + - - + + - - - + + + @@ -29,13 +41,13 @@ - + - + - + - + @@ -54,8 +66,7 @@ - - + @@ -68,8 +79,8 @@ - - + + - 保存 + 保存 \ No newline at end of file diff --git a/cloudfunctions/project.config.json b/cloudfunctions/project.config.json new file mode 100644 index 0000000..2b3119a --- /dev/null +++ b/cloudfunctions/project.config.json @@ -0,0 +1,28 @@ +{ + "appid": "wx2cef527a000f87c9", + "compileType": "miniprogram", + "libVersion": "2.27.3", + "packOptions": { + "ignore": [], + "include": [] + }, + "setting": { + "coverView": true, + "es6": true, + "postcss": true, + "minified": true, + "enhance": true, + "showShadowRootInWxmlPanel": true, + "packNpmRelationList": [], + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + } + }, + "condition": {}, + "editorSetting": { + "tabIndent": "insertSpaces", + "tabSize": 4 + } +} \ No newline at end of file diff --git a/cloudfunctions/project.private.config.json b/cloudfunctions/project.private.config.json new file mode 100644 index 0000000..42ff49d --- /dev/null +++ b/cloudfunctions/project.private.config.json @@ -0,0 +1,7 @@ +{ + "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", + "projectname": "cloudfunctions", + "setting": { + "compileHotReLoad": true + } +} \ No newline at end of file diff --git a/miniprogram/app.js b/miniprogram/app.js index 51d56f3..50a8a54 100644 --- a/miniprogram/app.js +++ b/miniprogram/app.js @@ -18,13 +18,15 @@ // this.globalData = {} }, globalData: { - // url: "http://111.198.10.15:11604/", - httpsUrl: "https://logapi.smartlog.work/", - httpsTestUrl: "https://smartlog.work/prodapi4test/", - url: "http://139.198.18.188:8083/", + httpsUrl: "https://logapi.smartlog.work/", + // httpsUrl: "http://139.198.18.188:8083/", // url: "http://127.0.0.1:8083/", - // httpsUrl: "http://127.0.0.1:8083/", + //httpsUrl: "http://127.0.0.1:8083/", openid: null, - indexCount:1 - }, + indexCount:1, + nickName:"", + userName:"", + role:"", + devcode:"" + } }) diff --git a/miniprogram/app.json b/miniprogram/app.json index d23f798..2b6db76 100644 --- a/miniprogram/app.json +++ b/miniprogram/app.json @@ -1,15 +1,17 @@ { "cloud": true, "pages": [ + "pages/login/login", "pages/indexapp/indexapp", "pages/earth/earth", "pages/applog/applog", "pages/addDevice/addDevice", "pages/addDevicelog/addDeviceLog", - "pages/searchLog/searchLog" + "pages/searchLog/searchLog", + "pages/notice/notice" ], "window": { - "backgroundColor": "#F6F6F6", + "backgroundColor": "#E6D480", "backgroundTextStyle": "light", "navigationBarBackgroundColor": "#FFCF00", "navigationBarTitleText": "智慧施工", @@ -46,11 +48,11 @@ "desc": "你的位置信息将用于小程序位置接口的效果展示" } }, + "requiredPrivateInfos": ["getLocation", "chooseLocation"], "networkTimeout": { "request": 30000, "connectSocket": 30000, "uploadFile": 30000, "downloadFile": 30000 - }, - "style": "v2" + } } \ No newline at end of file diff --git a/miniprogram/images/applocat.png b/miniprogram/images/applocat.png new file mode 100644 index 0000000..fe49f54 --- /dev/null +++ b/miniprogram/images/applocat.png Binary files differ diff --git a/miniprogram/images/back.png b/miniprogram/images/back.png new file mode 100644 index 0000000..32ac82d --- /dev/null +++ b/miniprogram/images/back.png Binary files differ diff --git a/miniprogram/images/bottom.png b/miniprogram/images/bottom.png new file mode 100644 index 0000000..d910e98 --- /dev/null +++ b/miniprogram/images/bottom.png Binary files differ diff --git a/miniprogram/images/header.png b/miniprogram/images/header.png new file mode 100644 index 0000000..6ea222e --- /dev/null +++ b/miniprogram/images/header.png Binary files differ diff --git a/miniprogram/images/login.png b/miniprogram/images/login.png index 8b73cc0..6471c46 100644 --- a/miniprogram/images/login.png +++ b/miniprogram/images/login.png Binary files differ diff --git a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss index 5a591fb..c9c35b5 100644 --- a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss +++ b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:100%;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:100%}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file +@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:650rpx;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:600rpx}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file diff --git a/miniprogram/pages/addDevice/addDevice.js b/miniprogram/pages/addDevice/addDevice.js index 2783674..78f00b7 100644 --- a/miniprogram/pages/addDevice/addDevice.js +++ b/miniprogram/pages/addDevice/addDevice.js @@ -1,5 +1,7 @@ // miniprogram/pages/addDevice/addDevice.js // import WxValidate from '../../utils/WxValidate.js' +var QQMapWX = require('../../libs/qqmap-wx-jssdk.js'); +var qqmapsdk; var app = getApp() Page({ @@ -11,32 +13,10 @@ canvasWidth: '', longitude: '', latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], + option1: [], personoption1: [], projectoption: [], + devtypeList:[], show: false, form: { devcode: "", @@ -59,7 +39,10 @@ project: "", area: "", street: "", - wellname: "" + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '', }, fileList: [] }, @@ -117,12 +100,14 @@ var that = this; //初始化表单内容为上次填写值 var cacheForms = wx.getStorageSync('cacheList') - if (cacheForms) { + cacheForms.photopath1='' + cacheForms.photopath2='' + cacheForms.photopath3='' + that.data.fileList=[] that.setData({ form: cacheForms, devcode: cacheForms.devcode, - }) } var form = that.data.form @@ -155,55 +140,89 @@ } }) + +//获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + that.setData({ + option1: welltypeArr + }) + } + } +}) + + //获取人员下拉列表 - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/getUser", + data:{ + tips:'repair' }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data.code == 200) { + var users = res.data.data + var personArr = []; + for (var i = 0; i < users.length; i++) { + var person = { + text: users[i].name, + value: users[i].name + }; + personArr.push(person); + } + that.setData({ + personoption1: personArr + }) } - that.setData({ - personoption1: personArr - }) } - }).catch(err => { - console.error(err); - }) + }) + - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - that.setData({ - projectoption: projectArr - }) + success(res){ + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); + } + that.setData({ + projectoption: projectArr + }) + } } - }).catch(err => { - console.error(err); - }) + }) + var installtime = 'form.installtimeFmt'; var dateNow = this.formatDate(); this.setData({ @@ -211,8 +230,40 @@ installtimeFmt: dateNow, [installtime]: dateNow, }); + + + + /** + * 获取设备类型下拉列表 + */ + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/deviceType", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var TypeList = res.data.data + var typeArr = []; + for (var i = 0; i < TypeList.length; i++) { + var type = { + text: TypeList[i].productName, + value: TypeList[i].productName + }; + typeArr.push(type); + } + that.setData({ + devtypeList: typeArr + }) + } + } + }) }, + + + /** * 生命周期函数--监听页面初次渲染完成 */ @@ -280,29 +331,7 @@ }, - - //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 - drawText: function (ctx, str, leftWidth, initHeight, titleHeight, canvasWidth) { - var lineWidth = 0; - var lastSubStrIndex = 0; //每次开始截取的字符串的索引 - for (let i = 0; i < str.length; i++) { - lineWidth += ctx.measureText(str[i]).width; - if (lineWidth > canvasWidth) { - ctx.fillText(str.substring(lastSubStrIndex, i), leftWidth, initHeight); //绘制截取部分 - initHeight = initHeight + leftWidth * 2; //22为字体的高度 - lineWidth = 0; - lastSubStrIndex = i; - // titleHeight += 40; - } - if (i == str.length - 1) { //绘制剩余部分 - ctx.fillText(str.substring(lastSubStrIndex, i + 1), leftWidth, initHeight); - } - } - // // 标题border-bottom 线距顶部距离 - // titleHeight = titleHeight + 10; - // return titleHeight - }, - + //验证表单 formValidate() { if (this.data.form.devcode == "") { @@ -312,27 +341,20 @@ }) return false } - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } if (this.data.form.wellcode == "") { wx.showToast({ icon: 'none', @@ -348,22 +370,10 @@ }) return false } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null) { + + if (this.data.form.installperson == "") { wx.showToast({ icon: 'none', title: '安装人员不能为空!', @@ -408,56 +418,90 @@ } return true; }, + //提交表单 formSubmit: function (event) { + console.log(this.data.form) + //表单参数验证 if (!this.formValidate()) { return false; } var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDevice', + //验证设备编号长度 + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/getDevTypeLength", data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceAdd/add" + code: encodeURI(this.data.form.devicetype) }, - }).then(res => { - if (res.result.code == 500) { - wx.showToast({ - title: '设备编号已安装!', - }) - } else if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - //用于回显 - wx.setStorageSync('cacheList', that.data.form) - //提交成功后提示用户操作 - if (res.confirm) { - wx.switchTab({ - url: '../earth/earth' - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (""==res.data.data ||res.data.data == that.data.form.devcode.length) { + that.saveDevice() + } else { //编号位数不对提示 + wx.showToast({ + icon: 'none', + title: '设备编号位数不对!', + duration: 1000 + }) + return false + } } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "提交失败", - }) }) }, + + //保存设备基本信息 + saveDevice() { + var that = this; + //设置照片路径 + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopathForm = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopathForm]: fileList[i].url.split("static/")[1] + }) + } + //表单提交 + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 500) { + wx.showToast({ + title: '设备编号已安装!', + }) + } else if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + //用于回显 + wx.setStorageSync('cacheList', that.data.form) + //提交成功后提示用户操作 + if (res.confirm) { + wx.switchTab({ + url: '../earth/earth' + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } + }, + fail(err) { + wx.showToast({ + title: '提交失败!', + }) + } + }) + }, + + //input 输入框设置值 confirm(event) { var that = this; var formValue = event.detail.value; @@ -466,8 +510,30 @@ that.setData({ [fromN]: formValue }) + //若输入是设备编号,自动获取设备类型 + if('devcode'==formName){ + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", + data: { + devcode: formValue, + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + that.setData({ + [formDevicetype]: res.data + }); + } + } + }) + } }, + //扫描设备获取编号和设备类型 scan() { var _this = this; wx.scanCode({ @@ -477,23 +543,28 @@ _this.setData({ [formdevcode]: devcode }); - wx.cloud.callFunction({ - name: 'findModeCode', + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", data: { devcode: devcode, - url: app.globalData.url + "appDeviceAdd/findModeCodeByCode" }, - }).then(res => { - if (res.result) { - var formDevicetype = 'form.devicetype' - _this.setData({ - [formDevicetype]: res.result - }); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + _this.setData({ + [formDevicetype]: res.data + }); + } } }) } }) }, + //粘贴经纬度 paste() { var _this = this; wx.getClipboardData({ @@ -510,9 +581,11 @@ longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), }); + _this.showAddress(_this.data.form.longitude,_this.data.form.latitude,_this) } }) }, + //设置经类型 selectValue(value) { var that = this; @@ -521,6 +594,16 @@ [wellType]: value.detail }) }, + + //设置设备类型 + selectDevType(event) { + var that = this; + var devtype = 'form.devicetype'; + that.setData({ + [devtype]: event.detail + }) + }, + //设置运维人员 selectpersonValue(event) { var that = this; var installPerson = 'form.installperson'; @@ -528,6 +611,7 @@ [installPerson]: event.detail }) }, + //设置项目 selectprojectValue(event) { var that = this; var project = 'form.project'; @@ -535,8 +619,41 @@ [project]: event.detail }) }, + showAddress :function(longitude, latitude, self) { + // 实例化腾讯地图API核心类 + qqmapsdk = new QQMapWX({ + key: 'BGPBZ-C5O3P-ROUDR-LWC4J-63EKH-V5FRX'//此处使用你自己申请的key + }) + // 腾讯地图调用接口 + qqmapsdk.reverseGeocoder({ + location: { + latitude: latitude, + longitude: longitude + }, + success: function (res) { + self.setData({ + 'form.area':res.result.address.slice(0,res.result.address.indexOf('区')+1), + 'form.street':res.result.address.slice(res.result.address.indexOf('区')+1) + }) + }, + fail: function (res) { + console.log(res); + }, + complete: function (res) { + } + }); + }, + //上传照片 afterRead(event) { var _this = this; + if (_this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '请先填写设备编号!\r\n否则水印中无编号', + duration: 2000 + }) + return false + } const { file } = event.detail; @@ -576,78 +693,8 @@ }) } }) - // 压缩图片 - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // //获取图片尺寸 - // wx.getImageInfo({ - // src: convertpath, - // success(res) { - // _this.setData({ - // canvasHeight: res.height, - // canvasWidth: res.width - // }) - // var ctx = wx.createCanvasContext('firstCanvas') - - // //将图片src放到cancas内,宽高为图片大小 - // ctx.drawImage(convertpath, 0, 0, res.width, res.height) - // //将声明的时间放入canvas - // ctx.setFontSize(30 * (res.width / 750)) //注意:设置文字大小必须放在填充文字之前,否则不生效 - // ctx.setFillStyle('blue') - // var text = "编号:" + _this.data.form.devcode + "\n经度:" + _this.data.form.longitude + "\n纬度:" + _this.data.form.latitude - // // _this.drawText(ctx,text,20, 70, 5, res.width) - // _this.drawText(ctx, text, 15 * (res.width / 750), 70 * (res.width / 750), 5, res.width) - - // // ctx.fillText(text, 0, 40) - // // ctx.strokeText(_this.data.form.devcode, 0, 30) - // //生成水印图 - // ctx.draw(false, function () { - // wx.canvasToTempFilePath({ - // canvasId: 'firstCanvas', - // success: (res) => { - // wx.compressImage({ - // src: res.tempFilePath, - // quality: 25, - // success: function (res) { - // //上传照片至服务器 - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: res.tempFilePath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // } - // }) - // //// - // } - // }) - // }) - // } - // }) - // } - // }); }, + //删除照片 deletePhoto(event) { var image_index = event.detail.index var fileList_new = this.data.fileList; diff --git a/miniprogram/pages/addDevice/addDevice.wxml b/miniprogram/pages/addDevice/addDevice.wxml index b0977e2..f12c254 100644 --- a/miniprogram/pages/addDevice/addDevice.wxml +++ b/miniprogram/pages/addDevice/addDevice.wxml @@ -5,18 +5,30 @@ - + + + + + + + + + + + + + - - + + - - - + + + @@ -29,13 +41,13 @@ - + - + - + - + @@ -54,8 +66,7 @@ - - + @@ -68,8 +79,8 @@ - - + + - 保存 + 保存 \ No newline at end of file diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.js b/miniprogram/pages/addDevicelog/addDeviceLog.js index cdec71b..a0dc6da 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.js +++ b/miniprogram/pages/addDevicelog/addDeviceLog.js @@ -3,681 +3,665 @@ var app = getApp(); Page({ - /** - * 页面的初始数据 - */ - data: { - pageName: '', - showMask: false, - today: new Date().getTime(), - longitude: '', - latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], - personoption1: [], - projectoption: [], - devcode: "", - deviceMode: "", - installtimeFmt: '', - show: false, - form: { - devcode: "", - wellcode: "", - welltype: "", - welldepth: "", - installheigt: "", - installperson: "", - installtimeFmt: "", - photopath: "", - factory: "", - workmsg: "", - position: "", - description: "", - longitude: "", - latitude: "", - longitude84: "", - latitude84: "", - devicetype: "", - project: "", - area: "", - street: "", - wellname: "" - }, - fileList: [], - detail: "" - }, + /** + * 页面的初始数据 + */ + data: { + pageName: '', + showMask: false, + today: new Date().getTime(), + longitude: '', + latitude: '', + option1: [], + personoption1: [], + projectoption: [], + devcode: "", + deviceMode: "", + installtimeFmt: '', + show: false, + form: { + devcode: "", + wellcode: "", + welltype: "", + welldepth: "", + installheigt: "", + installperson: "", + installtimeFmt: "", + photopath: "", + factory: "", + workmsg: "", + position: "", + description: "", + longitude: "", + latitude: "", + longitude84: "", + latitude84: "", + devicetype: "", + project: "", + area: "", + street: "", + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '' + }, + fileList: [], + detail: "", + markers: [{ + id: 100, + // iconPath: "../../images/point.png", + latitude: '', + longitude: '', + // label:'1', + width: 25, + height: 35 + }], + }, - onDisplay() { - this.setData({ - show: true - }); - }, - onClose() { - this.setData({ - show: false - }); - }, - formatDate() { - var date = new Date(); - // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; - var seperator1 = "-"; - var month = date.getMonth() + 1; - var strDate = date.getDate(); - var hour = date.getHours() - var minute = date.getMinutes() - var second = date.getSeconds() - month = month > 9 ? month : "0" + month; - strDate = strDate > 9 ? strDate : "0" + strDate; - hour = hour > 9 ? hour : "0" + hour; - minute = minute > 9 ? minute : "0" + minute; - second = second > 9 ? second : "0" + second; - var currentdate = - date.getFullYear() + - seperator1 + - month + - seperator1 + - strDate + - " " + - hour + ":" + - minute + ":" + - second; - return currentdate; + onDisplay() { + this.setData({ + show: true + }); + }, + onClose() { + this.setData({ + show: false + }); + }, + formatDate() { + var date = new Date(); + // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; + var seperator1 = "-"; + var month = date.getMonth() + 1; + var strDate = date.getDate(); + var hour = date.getHours() + var minute = date.getMinutes() + var second = date.getSeconds() + month = month > 9 ? month : "0" + month; + strDate = strDate > 9 ? strDate : "0" + strDate; + hour = hour > 9 ? hour : "0" + hour; + minute = minute > 9 ? minute : "0" + minute; + second = second > 9 ? second : "0" + second; + var currentdate = + date.getFullYear() + + seperator1 + + month + + seperator1 + + strDate + + " " + + hour + ":" + + minute + ":" + + second; + return currentdate; - }, - onConfirm(event) { - var installtime = 'form.installtimeFmt'; - this.setData({ - show: false, - installtimeFmt: this.formatDate(event.detail), - [installtime]: this.formatDate(event.detail), - }); - }, + }, + onConfirm(event) { + var installtime = 'form.installtimeFmt'; + this.setData({ + show: false, + installtimeFmt: this.formatDate(event.detail), + [installtime]: this.formatDate(event.detail), + }); + }, - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - var _this = this; - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" - }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); - } - _this.setData({ - personoption1: personArr - }) + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + var _this = this; + _this.setData({ + 'markers[0].latitude': Number(wx.getStorageSync('resultObject').latitude) , + 'markers[0].longitude': Number(wx.getStorageSync('resultObject').longitude), + // 'markers[0].label':'10', + 'markers[0].width': 18, + 'markers[0].id':1, + 'markers[0].height': 30, + latitude:Number(wx.getStorageSync('resultObject').latitude), + longitude:Number(wx.getStorageSync('resultObject').longitude) + }) + //获取人员下拉列表 + // wx.request({ + // method: "POST", + // url: app.globalData.httpsUrl + "deviceType/getUser", + // data:{ + // tips:'repair' + // }, + // header: { + // 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + // }, + // success(res) { + // if (res.data.code == 200) { + // var users = res.data.data + // var personArr = []; + // for (var i = 0; i < users.length; i++) { + // var person = { + // text: users[i].name, + // value: users[i].name + // }; + // personArr.push(person); + // } + // _this.setData({ + // personoption1: personArr + // }) + // } + // } + // }) + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); } - }).catch(err => { - console.error(err); - }) - - - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" - }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - _this.setData({ - projectoption: projectArr - }) - } - }).catch(err => { - console.error(err); - }) - - if (options.pageName) { - this.setData({ - pageName: options.pageName - }) - } - - if (options.detail) { - - var formObject = JSON.parse(options.detail); _this.setData({ - form: formObject, - detail: options.detail + projectoption: projectArr }) - - _this.setData({ - ['form.installperson']: "", - ['form.installtimeFmt']: "", - ['form.workmsg']: "", - ['form.description']: "" - }) - - const { - fileList = [] - } = _this.data; - if (formObject.photopath1 != "") { - var file1 = { - url: app.globalData.url + "static/" + formObject.photopath1 - } - fileList.push(file1) - } - if (formObject.photopath2 != "") { - var file2 = { - url: app.globalData.url + "static/" + formObject.photopath2 - } - fileList.push(file2) - } - if (formObject.photopath3 != "") { - var file3 = { - url: app.globalData.url + "static/" + formObject.photopath3 - } - fileList.push(file3) - } - - _this.setData({ - fileList - }); } - var installtime = 'form.installtimeFmt'; - var dateNow = this.formatDate(); - this.setData({ - installtimeFmt: dateNow, - [installtime]: dateNow, - }); - }, + } + }) - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { + //获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + _this.setData({ + option1: welltypeArr + }) + } + } +}) - }, + //跳转时带入参数返回哪页 + if (options.pageName) { + this.setData({ + pageName: options.pageName + }) + } + //跳转时带入参数设备的安装信息 + if (wx.getStorageSync('resultObject')) { + var formObject = wx.getStorageSync('resultObject') + _this.setData({ + form: formObject, + detail: formObject + }) - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { + _this.setData({ + ['form.installperson']: app.globalData.userName, + ['form.installtimeFmt']: "", + ['form.workmsg']: "", + ['form.description']: "" + }) - }, + const { + fileList = [] + } = _this.data; + if (formObject.photopath1 != "") { + var file1 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath1 + } + fileList.push(file1) + } + if (formObject.photopath2 != "") { + var file2 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath2 + } + fileList.push(file2) + } + if (formObject.photopath3 != "") { + var file3 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath3 + } + fileList.push(file3) + } + _this.setData({ + fileList + }); + } + var installtime = 'form.installtimeFmt'; + var dateNow = this.formatDate(); + this.setData({ + installtimeFmt: dateNow, + [installtime]: dateNow, + }); + }, - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, - }, + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + wx.removeStorageSync('resultObject') + }, - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, - }, + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { + }, - }, + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { + }, - }, + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { + }, - }, + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + }, - /** - * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true - **/ + /** + * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true + **/ - isNumber: function (val) { + isNumber: function (val) { - var regPos = /^[0-9]*$/; //非负浮点数 - var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数 - if (regPos.test(val) || regNeg.test(val)) { - return false; - } else { - return true; - } + var regPos = /^[0-9]*$/; //非负浮点数 + var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数 + if (regPos.test(val) || regNeg.test(val)) { + return false; + } else { + return true; + } - }, + }, - formValidate() { + formValidate() { - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } - if (this.data.form.wellcode == "") { - wx.showToast({ - icon: 'none', - title: '井编号不能为空!', - }) - return false - } - if (this.data.form.devicetype == "") { - wx.showToast({ - icon: 'none', - title: '设备类型不能为空!', - }) - return false - } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + if (this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '设备编号不能为空!', + }) + return false + } + if (this.data.form.wellcode == "") { + wx.showToast({ + icon: 'none', + title: '井编号不能为空!', + }) + return false + } + if (this.data.form.devicetype == "") { + wx.showToast({ + icon: 'none', + title: '设备类型不能为空!', + }) + return false + } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null || - this.data.form.installperson == '') { - wx.showToast({ - icon: 'none', - title: '运维人员不能为空!', - }) - return false - } - if (this.data.form.project == "") { - wx.showToast({ - icon: 'none', - title: '所属项目不能为空!', - }) - return false - } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } + if (this.data.form.installperson == null || + this.data.form.installperson == '') { + wx.showToast({ + icon: 'none', + title: '运维人员不能为空!', + }) + return false + } + if (this.data.form.project == "") { + wx.showToast({ + icon: 'none', + title: '所属项目不能为空!', + }) + return false + } - if (this.data.form.welldepth != null) { - if (this.isNumber(this.data.form.welldepth)) { - wx.showToast({ - icon: 'none', - title: '井深必须为数值!', - }) - return false - } - } - if (this.data.form.installheigt != null) { - if (this.isNumber(this.data.form.installheigt)) { - wx.showToast({ - icon: 'none', - title: '到井口距离必须为数值!', - }) - return false - } - } - - return true; - }, - - changeMsg: function () { - var formNew = this.data.form; - var formOld = JSON.parse(this.data.detail); - var descpNew = ""; - if (formNew.devcode != formOld.devcode) { - descpNew += "修改设备编号,原编号:" + formOld.devcode + ",新编号:" + formNew.devcode + ";" - } - if (formNew.devicetype != formOld.devicetype) { - descpNew += "修改设备类型,原设备类型:" + formOld.devicetype + ",新设备类型:" + formNew.devicetype + ";" - } - if (formNew.area != formOld.area) { - descpNew += "修改区,原区:" + formOld.area + ",新区:" + formNew.area + ";" - } - if (formNew.street != formOld.street) { - descpNew += "修改街道,原街道:" + formOld.street + ",新街道:" + formNew.street + ";" - } - if (formNew.wellname != formOld.wellname) { - descpNew += "修改井名称,原井名称:" + formOld.wellname + ",新井名称:" + formNew.wellname + ";" - } - if (formNew.factory != formOld.factory) { - descpNew += "修改权属单位,原权属单位:" + formOld.factory + ",新权属单位:" + formNew.factory + ";" - } - if (formNew.installheigt != formOld.installheigt) { - descpNew += "修改井口距离,原井口距离:" + formOld.installheigt + ",新井口距离:" + formNew.installheigt + ";" - } - if (formNew.installperson != formOld.installperson) { - descpNew += "修改运维人员,原运维人员:" + formOld.installperson + ",新运维人员:" + formNew.installperson + ";" - } - if (formNew.latitude != formOld.latitude) { - descpNew += "修改纬度,原纬度:" + formOld.latitude + ",新纬度:" + formNew.latitude + ";" - } - if (formNew.longitude != formOld.longitude) { - descpNew += "修改经度,原经度:" + formOld.longitude + ",新经度:" + formNew.longitude + ";" - } - if (formNew.position != formOld.position) { - descpNew += "修改位置描述,原位置:" + formOld.position + ",新位置:" + formNew.position + ";" - } - if (formNew.wellcode != formOld.wellcode) { - descpNew += "修改井编号,原编号:" + formOld.wellcode + ",新编号:" + formNew.wellcode + ";" - } - if (formNew.welldepth != formOld.welldepth) { - descpNew += "修改井深,原井深:" + formOld.welldepth + ",新井深:" + formNew.welldepth + ";" - } - if (formNew.welltype != formOld.welltype) { - descpNew += "修改井类型,原井类型:" + formOld.welltype + ",新井类型:" + formNew.welltype + ";" - } - if (formNew.project != formOld.project) { - descpNew += "修改所属项目,原项目:" + formOld.project + ",新项目:" + formNew.project + ";" - } - if (this.data.photopath1 != formOld.photopath1 || - this.data.photopath2 != formOld.photopath2 || - this.data.photopath3 != formOld.photopath3) { - descpNew += "修改照片;" - } - if ("" != formNew.description) { - descpNew += formNew.description; - } - this.setData({ - ['form.description']: descpNew + if (this.data.form.welldepth != null) { + if (this.isNumber(this.data.form.welldepth)) { + wx.showToast({ + icon: 'none', + title: '井深必须为数值!', }) - }, + return false + } + } + if (this.data.form.installheigt != null) { + if (this.isNumber(this.data.form.installheigt)) { + wx.showToast({ + icon: 'none', + title: '到井口距离必须为数值!', + }) + return false + } + } - formSubmit: function (event) { + return true; + }, - if (!this.formValidate()) { - return false; - } - this.changeMsg(); - var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDeviceLog', - data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceLog/add" - }, - }).then(res => { - // var resultObj=JSON.parse(res.result); - if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - if (res.confirm) { - wx.switchTab({ - url: that.data.pageName - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) - } - }).catch(err => { - console.error(err) - wx.showToast({ - title: "提交失败", - }) - }) - }, - confirm(event) { - var that = this; - var formValue = event.detail.value; - var formName = event.target.dataset.id; - var fromN = 'form.' + [formName]; - that.setData({ - [fromN]: formValue - }) - }, + //获取与上次修改的信息 + changeMsg: function () { + var formNew = this.data.form; + console.log(this.data.detail) + var formOld = JSON.parse(this.data.detail); + var descpNew = ""; + if (formNew.devcode != formOld.devcode) { + descpNew += "修改设备编号,原值:" + formOld.devcode + ",新值:" + formNew.devcode + ";" + } + if (formNew.devicetype != formOld.devicetype) { + descpNew += "修改设备类型,原值:" + formOld.devicetype + ",新值:" + formNew.devicetype + ";" + } + if (formNew.area != formOld.area) { + descpNew += "修改区,原值:" + formOld.area + ",新值:" + formNew.area + ";" + } + if (formNew.street != formOld.street) { + descpNew += "修改街道,原值:" + formOld.street + ",新值:" + formNew.street + ";" + } + if (formNew.wellname != formOld.wellname) { + descpNew += "修改井名称,原值:" + formOld.wellname + ",新值:" + formNew.wellname + ";" + } + if (formNew.factory != formOld.factory) { + descpNew += "修改权属单位,原值:" + formOld.factory + ",新值:" + formNew.factory + ";" + } + if (formNew.installheigt != formOld.installheigt) { + descpNew += "修改井口距离,原值:" + formOld.installheigt + ",新值:" + formNew.installheigt + ";" + } + if (formNew.installperson != formOld.installperson) { + descpNew += "修改运维人员,原值:" + formOld.installperson + ",新值:" + formNew.installperson + ";" + } + if (formNew.latitude != formOld.latitude) { + descpNew += "修改纬度,原值:" + formOld.latitude + ",新值:" + formNew.latitude + ";" + } + if (formNew.longitude != formOld.longitude) { + descpNew += "修改经度,原值:" + formOld.longitude + ",新值:" + formNew.longitude + ";" + } + if (formNew.position != formOld.position) { + descpNew += "修改位置描述,原值:" + formOld.position + ",新值:" + formNew.position + ";" + } + if (formNew.wellcode != formOld.wellcode) { + descpNew += "修改井编号,原值:" + formOld.wellcode + ",新值:" + formNew.wellcode + ";" + } + if (formNew.welldepth != formOld.welldepth) { + descpNew += "修改井深,原值:" + formOld.welldepth + ",新值:" + formNew.welldepth + ";" + } + if (formNew.welltype != formOld.welltype) { + descpNew += "修改井类型,原值:" + formOld.welltype + ",新值:" + formNew.welltype + ";" + } + if (formNew.project != formOld.project) { + descpNew += "修改所属项目,原值:" + formOld.project + ",新值:" + formNew.project + ";" + } + if (this.data.form.photopath1 != formOld.photopath1 || + this.data.form.photopath2 != formOld.photopath2 || + this.data.form.photopath3 != formOld.photopath3) { + descpNew += "修改照片;" + } + if ("" != formNew.description) { + descpNew += formNew.description; + } + this.setData({ + ['form.description']: descpNew + }) + }, - scan() { + //提交表单 + formSubmit: function (event) { - wx.scanCode({ - success(res) { - console.log(res) - } - }) + //表单验证 + if (!this.formValidate()) { + return false; + } + //自动生成修改内容 + this.changeMsg(); + //提交权限限制(只有施工人员能修改) + if(app.globalData.role!='repair'){ + wx.showToast({ + icon: 'none', + title: '无权限修改', + duration:2000 + }) + return false + } + var that = this; + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopath = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopath]: fileList[i].url.split("static/")[1] + }) + } + delete that.data.form.installtime + delete that.data.form.createtime + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - paste() { - var _this = this; - wx.getClipboardData({ - success: function (res) { - var longitude = 'form.longitude'; - var latitude = 'form.latitude'; - var longitude84 = 'form.longitude84'; - var latitude84 = 'form.latitude84'; - _this.setData({ - [longitude]: parseFloat(res.data.split(",", 4)[1]).toFixed(6), - [latitude]: parseFloat(res.data.split(",", 4)[0]).toFixed(6), - [longitude84]: "" == (res.data.split(",", 4)[3]) ? "" : parseFloat(res.data.split(",", 4)[3]).toFixed(6), - [latitude84]: "" == (res.data.split(",", 4)[2]) ? "" : parseFloat(res.data.split(",", 4)[2]).toFixed(6), - longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), - latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), - }); - } - }) - }, - selectValue(value) { - var that = this; - var wellType = 'form.welltype'; - that.setData({ - [wellType]: value.detail - }) - }, - selectpersonValue(event) { - var that = this; - var installPerson = 'form.installperson'; - that.setData({ - [installPerson]: event.detail - }) - }, - selectprojectValue(event) { - var that = this; - var project = 'form.project'; - that.setData({ - [project]: event.detail, - showMask: true - }) - }, - open() { - this.setData({ - showMask: true - }) - }, - close() { - this.setData({ - showMask: false - }) - }, - afterRead(event) { - var _this = this; - const { - file - } = event.detail; - const { - fileList = [] - } = _this.data; - var convertpath = ""; - wx.compressImage({ - src: event.detail.file.path, - quality: 25, - success: function (res) { - convertpath = res.tempFilePath; - wx.uploadFile({ - url: app.globalData.httpsUrl + "appDeviceAdd/fileUploadMarker", - filePath:convertpath, - name: 'file', - formData: { - 'text': "编号:" + _this.data.form.devcode + "经度:" + _this.data.form.longitude + "纬度:" + _this.data.form.latitude - }, - header: { - "Content-Type": "multipart/form-data", - 'accept': 'application/json', - }, - success(res) { - if (res.data) { - var url = JSON.parse(res.data); - fileList.push({ - ...file, - url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - }); - _this.setData({ - fileList - }); - } - } + success(res) { + if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + if (res.confirm) { + wx.switchTab({ + url: that.data.pageName }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') } - }) - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // // var base64 = "data:image/png;base64," + wx.getFileSystemManager().readFileSync(convertpath, 'base64'); - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: convertpath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // // wx.cloud.callFunction({ - // // name: 'uploadFile', - // // data: { - // // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // // fileBase64: base64 - // // }, - // // success: function (res) { - // // if (res.result) { - // // fileList.push({ - // // ...file, - // // url: app.globalData.url + "static/" + res.result.data.replace(/\\/g, "/") - // // }); - // // _this.setData({ - // // fileList - // // }); - // // } - // // }, - // // complete: res => { - // // }, - // // }) - // } - // }); + } + }) + } + }, + fail(err) { + wx.showToast({ + title: "提交失败", + }) + } + }) + }, + //报存录入的input信息 + confirm(event) { + var that = this; + var formValue = event.detail.value; + var formName = event.target.dataset.id; + var fromN = 'form.' + [formName]; + that.setData({ + [fromN]: formValue + }) + }, + + //扫码 + scan() { + + wx.scanCode({ + success(res) { + console.log(res) + } + }) + }, + //粘贴经纬度 + paste() { + var _this = this; + wx.getClipboardData({ + success: function (res) { + var longitude = 'form.longitude'; + var latitude = 'form.latitude'; + var longitude84 = 'form.longitude84'; + var latitude84 = 'form.latitude84'; + _this.setData({ + [longitude]: parseFloat(res.data.split(",", 4)[1]).toFixed(6), + [latitude]: parseFloat(res.data.split(",", 4)[0]).toFixed(6), + [longitude84]: "" == (res.data.split(",", 4)[3]) ? "" : parseFloat(res.data.split(",", 4)[3]).toFixed(6), + [latitude84]: "" == (res.data.split(",", 4)[2]) ? "" : parseFloat(res.data.split(",", 4)[2]).toFixed(6), + longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), + latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), + }); + } + }) + }, + selectValue(value) { + var that = this; + var wellType = 'form.welltype'; + that.setData({ + [wellType]: value.detail + }) + }, + //运维人员默认为登录人 + // selectpersonValue(event) { + // var that = this; + // var installPerson = 'form.installperson'; + // that.setData({ + // [installPerson]: event.detail + // }) + // }, + selectprojectValue(event) { + var that = this; + var project = 'form.project'; + that.setData({ + [project]: event.detail, + showMask: true + }) + }, + + open() { + this.setData({ + showMask: true + }) + }, + //隐藏textarea,防止遮挡 + close() { + this.setData({ + showMask: false + }) + }, + //上传照片 + afterRead(event) { + var _this = this; + const { + file + } = event.detail; + const { + fileList = [] + } = _this.data; + var convertpath = ""; + wx.compressImage({ + src: event.detail.file.path, + quality: 25, + success: function (res) { + convertpath = res.tempFilePath; + wx.uploadFile({ + url: app.globalData.httpsUrl + "appDeviceAdd/fileUploadMarker", + filePath: convertpath, + name: 'file', + formData: { + 'text': "编号:" + _this.data.form.devcode + "经度:" + _this.data.form.longitude + "纬度:" + _this.data.form.latitude }, - deletePhoto(event) { - var that = this - var image_index = event.detail.index - var fileList_new = that.data.fileList; - wx.showModal({ - content: '确定删除照片?', - success: function (res) { - if (res.confirm) { - fileList_new.splice(image_index, 1); - that.setData({ - fileList: fileList_new - }) - wx.cloud.callFunction({ - name: 'deletePhoto', - data: { - url: app.globalData.url + "appDeviceLog/deletePhoto", - devcode: that.data.form.devcode, - pathIndex: image_index - }, - success: function (res) {}, - complete: res => {}, - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + "Content-Type": "multipart/form-data", + 'accept': 'application/json', }, - }) \ No newline at end of file + success(res) { + if (res.data) { + var url = JSON.parse(res.data); + fileList.push({ + ...file, + url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") + }); + _this.setData({ + fileList + }); + } + } + }) + } + }) + }, + //删除照片 + deletePhoto(event) { + var that = this + var image_index = event.detail.index + var fileList_new = that.data.fileList; + wx.showModal({ + content: '确定删除照片?', + success: function (res) { + if (res.confirm) { + fileList_new.splice(image_index, 1); + that.setData({ + fileList: fileList_new + }) + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deletePhoto", + data: { + devcode: that.data.form.devcode + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) {} + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } +}) \ No newline at end of file diff --git a/cloudfunctions/project.config.json b/cloudfunctions/project.config.json new file mode 100644 index 0000000..2b3119a --- /dev/null +++ b/cloudfunctions/project.config.json @@ -0,0 +1,28 @@ +{ + "appid": "wx2cef527a000f87c9", + "compileType": "miniprogram", + "libVersion": "2.27.3", + "packOptions": { + "ignore": [], + "include": [] + }, + "setting": { + "coverView": true, + "es6": true, + "postcss": true, + "minified": true, + "enhance": true, + "showShadowRootInWxmlPanel": true, + "packNpmRelationList": [], + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + } + }, + "condition": {}, + "editorSetting": { + "tabIndent": "insertSpaces", + "tabSize": 4 + } +} \ No newline at end of file diff --git a/cloudfunctions/project.private.config.json b/cloudfunctions/project.private.config.json new file mode 100644 index 0000000..42ff49d --- /dev/null +++ b/cloudfunctions/project.private.config.json @@ -0,0 +1,7 @@ +{ + "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", + "projectname": "cloudfunctions", + "setting": { + "compileHotReLoad": true + } +} \ No newline at end of file diff --git a/miniprogram/app.js b/miniprogram/app.js index 51d56f3..50a8a54 100644 --- a/miniprogram/app.js +++ b/miniprogram/app.js @@ -18,13 +18,15 @@ // this.globalData = {} }, globalData: { - // url: "http://111.198.10.15:11604/", - httpsUrl: "https://logapi.smartlog.work/", - httpsTestUrl: "https://smartlog.work/prodapi4test/", - url: "http://139.198.18.188:8083/", + httpsUrl: "https://logapi.smartlog.work/", + // httpsUrl: "http://139.198.18.188:8083/", // url: "http://127.0.0.1:8083/", - // httpsUrl: "http://127.0.0.1:8083/", + //httpsUrl: "http://127.0.0.1:8083/", openid: null, - indexCount:1 - }, + indexCount:1, + nickName:"", + userName:"", + role:"", + devcode:"" + } }) diff --git a/miniprogram/app.json b/miniprogram/app.json index d23f798..2b6db76 100644 --- a/miniprogram/app.json +++ b/miniprogram/app.json @@ -1,15 +1,17 @@ { "cloud": true, "pages": [ + "pages/login/login", "pages/indexapp/indexapp", "pages/earth/earth", "pages/applog/applog", "pages/addDevice/addDevice", "pages/addDevicelog/addDeviceLog", - "pages/searchLog/searchLog" + "pages/searchLog/searchLog", + "pages/notice/notice" ], "window": { - "backgroundColor": "#F6F6F6", + "backgroundColor": "#E6D480", "backgroundTextStyle": "light", "navigationBarBackgroundColor": "#FFCF00", "navigationBarTitleText": "智慧施工", @@ -46,11 +48,11 @@ "desc": "你的位置信息将用于小程序位置接口的效果展示" } }, + "requiredPrivateInfos": ["getLocation", "chooseLocation"], "networkTimeout": { "request": 30000, "connectSocket": 30000, "uploadFile": 30000, "downloadFile": 30000 - }, - "style": "v2" + } } \ No newline at end of file diff --git a/miniprogram/images/applocat.png b/miniprogram/images/applocat.png new file mode 100644 index 0000000..fe49f54 --- /dev/null +++ b/miniprogram/images/applocat.png Binary files differ diff --git a/miniprogram/images/back.png b/miniprogram/images/back.png new file mode 100644 index 0000000..32ac82d --- /dev/null +++ b/miniprogram/images/back.png Binary files differ diff --git a/miniprogram/images/bottom.png b/miniprogram/images/bottom.png new file mode 100644 index 0000000..d910e98 --- /dev/null +++ b/miniprogram/images/bottom.png Binary files differ diff --git a/miniprogram/images/header.png b/miniprogram/images/header.png new file mode 100644 index 0000000..6ea222e --- /dev/null +++ b/miniprogram/images/header.png Binary files differ diff --git a/miniprogram/images/login.png b/miniprogram/images/login.png index 8b73cc0..6471c46 100644 --- a/miniprogram/images/login.png +++ b/miniprogram/images/login.png Binary files differ diff --git a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss index 5a591fb..c9c35b5 100644 --- a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss +++ b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:100%;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:100%}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file +@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:650rpx;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:600rpx}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file diff --git a/miniprogram/pages/addDevice/addDevice.js b/miniprogram/pages/addDevice/addDevice.js index 2783674..78f00b7 100644 --- a/miniprogram/pages/addDevice/addDevice.js +++ b/miniprogram/pages/addDevice/addDevice.js @@ -1,5 +1,7 @@ // miniprogram/pages/addDevice/addDevice.js // import WxValidate from '../../utils/WxValidate.js' +var QQMapWX = require('../../libs/qqmap-wx-jssdk.js'); +var qqmapsdk; var app = getApp() Page({ @@ -11,32 +13,10 @@ canvasWidth: '', longitude: '', latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], + option1: [], personoption1: [], projectoption: [], + devtypeList:[], show: false, form: { devcode: "", @@ -59,7 +39,10 @@ project: "", area: "", street: "", - wellname: "" + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '', }, fileList: [] }, @@ -117,12 +100,14 @@ var that = this; //初始化表单内容为上次填写值 var cacheForms = wx.getStorageSync('cacheList') - if (cacheForms) { + cacheForms.photopath1='' + cacheForms.photopath2='' + cacheForms.photopath3='' + that.data.fileList=[] that.setData({ form: cacheForms, devcode: cacheForms.devcode, - }) } var form = that.data.form @@ -155,55 +140,89 @@ } }) + +//获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + that.setData({ + option1: welltypeArr + }) + } + } +}) + + //获取人员下拉列表 - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/getUser", + data:{ + tips:'repair' }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data.code == 200) { + var users = res.data.data + var personArr = []; + for (var i = 0; i < users.length; i++) { + var person = { + text: users[i].name, + value: users[i].name + }; + personArr.push(person); + } + that.setData({ + personoption1: personArr + }) } - that.setData({ - personoption1: personArr - }) } - }).catch(err => { - console.error(err); - }) + }) + - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - that.setData({ - projectoption: projectArr - }) + success(res){ + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); + } + that.setData({ + projectoption: projectArr + }) + } } - }).catch(err => { - console.error(err); - }) + }) + var installtime = 'form.installtimeFmt'; var dateNow = this.formatDate(); this.setData({ @@ -211,8 +230,40 @@ installtimeFmt: dateNow, [installtime]: dateNow, }); + + + + /** + * 获取设备类型下拉列表 + */ + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/deviceType", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var TypeList = res.data.data + var typeArr = []; + for (var i = 0; i < TypeList.length; i++) { + var type = { + text: TypeList[i].productName, + value: TypeList[i].productName + }; + typeArr.push(type); + } + that.setData({ + devtypeList: typeArr + }) + } + } + }) }, + + + /** * 生命周期函数--监听页面初次渲染完成 */ @@ -280,29 +331,7 @@ }, - - //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 - drawText: function (ctx, str, leftWidth, initHeight, titleHeight, canvasWidth) { - var lineWidth = 0; - var lastSubStrIndex = 0; //每次开始截取的字符串的索引 - for (let i = 0; i < str.length; i++) { - lineWidth += ctx.measureText(str[i]).width; - if (lineWidth > canvasWidth) { - ctx.fillText(str.substring(lastSubStrIndex, i), leftWidth, initHeight); //绘制截取部分 - initHeight = initHeight + leftWidth * 2; //22为字体的高度 - lineWidth = 0; - lastSubStrIndex = i; - // titleHeight += 40; - } - if (i == str.length - 1) { //绘制剩余部分 - ctx.fillText(str.substring(lastSubStrIndex, i + 1), leftWidth, initHeight); - } - } - // // 标题border-bottom 线距顶部距离 - // titleHeight = titleHeight + 10; - // return titleHeight - }, - + //验证表单 formValidate() { if (this.data.form.devcode == "") { @@ -312,27 +341,20 @@ }) return false } - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } if (this.data.form.wellcode == "") { wx.showToast({ icon: 'none', @@ -348,22 +370,10 @@ }) return false } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null) { + + if (this.data.form.installperson == "") { wx.showToast({ icon: 'none', title: '安装人员不能为空!', @@ -408,56 +418,90 @@ } return true; }, + //提交表单 formSubmit: function (event) { + console.log(this.data.form) + //表单参数验证 if (!this.formValidate()) { return false; } var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDevice', + //验证设备编号长度 + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/getDevTypeLength", data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceAdd/add" + code: encodeURI(this.data.form.devicetype) }, - }).then(res => { - if (res.result.code == 500) { - wx.showToast({ - title: '设备编号已安装!', - }) - } else if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - //用于回显 - wx.setStorageSync('cacheList', that.data.form) - //提交成功后提示用户操作 - if (res.confirm) { - wx.switchTab({ - url: '../earth/earth' - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (""==res.data.data ||res.data.data == that.data.form.devcode.length) { + that.saveDevice() + } else { //编号位数不对提示 + wx.showToast({ + icon: 'none', + title: '设备编号位数不对!', + duration: 1000 + }) + return false + } } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "提交失败", - }) }) }, + + //保存设备基本信息 + saveDevice() { + var that = this; + //设置照片路径 + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopathForm = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopathForm]: fileList[i].url.split("static/")[1] + }) + } + //表单提交 + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 500) { + wx.showToast({ + title: '设备编号已安装!', + }) + } else if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + //用于回显 + wx.setStorageSync('cacheList', that.data.form) + //提交成功后提示用户操作 + if (res.confirm) { + wx.switchTab({ + url: '../earth/earth' + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } + }, + fail(err) { + wx.showToast({ + title: '提交失败!', + }) + } + }) + }, + + //input 输入框设置值 confirm(event) { var that = this; var formValue = event.detail.value; @@ -466,8 +510,30 @@ that.setData({ [fromN]: formValue }) + //若输入是设备编号,自动获取设备类型 + if('devcode'==formName){ + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", + data: { + devcode: formValue, + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + that.setData({ + [formDevicetype]: res.data + }); + } + } + }) + } }, + //扫描设备获取编号和设备类型 scan() { var _this = this; wx.scanCode({ @@ -477,23 +543,28 @@ _this.setData({ [formdevcode]: devcode }); - wx.cloud.callFunction({ - name: 'findModeCode', + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", data: { devcode: devcode, - url: app.globalData.url + "appDeviceAdd/findModeCodeByCode" }, - }).then(res => { - if (res.result) { - var formDevicetype = 'form.devicetype' - _this.setData({ - [formDevicetype]: res.result - }); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + _this.setData({ + [formDevicetype]: res.data + }); + } } }) } }) }, + //粘贴经纬度 paste() { var _this = this; wx.getClipboardData({ @@ -510,9 +581,11 @@ longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), }); + _this.showAddress(_this.data.form.longitude,_this.data.form.latitude,_this) } }) }, + //设置经类型 selectValue(value) { var that = this; @@ -521,6 +594,16 @@ [wellType]: value.detail }) }, + + //设置设备类型 + selectDevType(event) { + var that = this; + var devtype = 'form.devicetype'; + that.setData({ + [devtype]: event.detail + }) + }, + //设置运维人员 selectpersonValue(event) { var that = this; var installPerson = 'form.installperson'; @@ -528,6 +611,7 @@ [installPerson]: event.detail }) }, + //设置项目 selectprojectValue(event) { var that = this; var project = 'form.project'; @@ -535,8 +619,41 @@ [project]: event.detail }) }, + showAddress :function(longitude, latitude, self) { + // 实例化腾讯地图API核心类 + qqmapsdk = new QQMapWX({ + key: 'BGPBZ-C5O3P-ROUDR-LWC4J-63EKH-V5FRX'//此处使用你自己申请的key + }) + // 腾讯地图调用接口 + qqmapsdk.reverseGeocoder({ + location: { + latitude: latitude, + longitude: longitude + }, + success: function (res) { + self.setData({ + 'form.area':res.result.address.slice(0,res.result.address.indexOf('区')+1), + 'form.street':res.result.address.slice(res.result.address.indexOf('区')+1) + }) + }, + fail: function (res) { + console.log(res); + }, + complete: function (res) { + } + }); + }, + //上传照片 afterRead(event) { var _this = this; + if (_this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '请先填写设备编号!\r\n否则水印中无编号', + duration: 2000 + }) + return false + } const { file } = event.detail; @@ -576,78 +693,8 @@ }) } }) - // 压缩图片 - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // //获取图片尺寸 - // wx.getImageInfo({ - // src: convertpath, - // success(res) { - // _this.setData({ - // canvasHeight: res.height, - // canvasWidth: res.width - // }) - // var ctx = wx.createCanvasContext('firstCanvas') - - // //将图片src放到cancas内,宽高为图片大小 - // ctx.drawImage(convertpath, 0, 0, res.width, res.height) - // //将声明的时间放入canvas - // ctx.setFontSize(30 * (res.width / 750)) //注意:设置文字大小必须放在填充文字之前,否则不生效 - // ctx.setFillStyle('blue') - // var text = "编号:" + _this.data.form.devcode + "\n经度:" + _this.data.form.longitude + "\n纬度:" + _this.data.form.latitude - // // _this.drawText(ctx,text,20, 70, 5, res.width) - // _this.drawText(ctx, text, 15 * (res.width / 750), 70 * (res.width / 750), 5, res.width) - - // // ctx.fillText(text, 0, 40) - // // ctx.strokeText(_this.data.form.devcode, 0, 30) - // //生成水印图 - // ctx.draw(false, function () { - // wx.canvasToTempFilePath({ - // canvasId: 'firstCanvas', - // success: (res) => { - // wx.compressImage({ - // src: res.tempFilePath, - // quality: 25, - // success: function (res) { - // //上传照片至服务器 - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: res.tempFilePath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // } - // }) - // //// - // } - // }) - // }) - // } - // }) - // } - // }); }, + //删除照片 deletePhoto(event) { var image_index = event.detail.index var fileList_new = this.data.fileList; diff --git a/miniprogram/pages/addDevice/addDevice.wxml b/miniprogram/pages/addDevice/addDevice.wxml index b0977e2..f12c254 100644 --- a/miniprogram/pages/addDevice/addDevice.wxml +++ b/miniprogram/pages/addDevice/addDevice.wxml @@ -5,18 +5,30 @@ - + + + + + + + + + + + + + - - + + - - - + + + @@ -29,13 +41,13 @@ - + - + - + - + @@ -54,8 +66,7 @@ - - + @@ -68,8 +79,8 @@ - - + + - 保存 + 保存 \ No newline at end of file diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.js b/miniprogram/pages/addDevicelog/addDeviceLog.js index cdec71b..a0dc6da 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.js +++ b/miniprogram/pages/addDevicelog/addDeviceLog.js @@ -3,681 +3,665 @@ var app = getApp(); Page({ - /** - * 页面的初始数据 - */ - data: { - pageName: '', - showMask: false, - today: new Date().getTime(), - longitude: '', - latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], - personoption1: [], - projectoption: [], - devcode: "", - deviceMode: "", - installtimeFmt: '', - show: false, - form: { - devcode: "", - wellcode: "", - welltype: "", - welldepth: "", - installheigt: "", - installperson: "", - installtimeFmt: "", - photopath: "", - factory: "", - workmsg: "", - position: "", - description: "", - longitude: "", - latitude: "", - longitude84: "", - latitude84: "", - devicetype: "", - project: "", - area: "", - street: "", - wellname: "" - }, - fileList: [], - detail: "" - }, + /** + * 页面的初始数据 + */ + data: { + pageName: '', + showMask: false, + today: new Date().getTime(), + longitude: '', + latitude: '', + option1: [], + personoption1: [], + projectoption: [], + devcode: "", + deviceMode: "", + installtimeFmt: '', + show: false, + form: { + devcode: "", + wellcode: "", + welltype: "", + welldepth: "", + installheigt: "", + installperson: "", + installtimeFmt: "", + photopath: "", + factory: "", + workmsg: "", + position: "", + description: "", + longitude: "", + latitude: "", + longitude84: "", + latitude84: "", + devicetype: "", + project: "", + area: "", + street: "", + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '' + }, + fileList: [], + detail: "", + markers: [{ + id: 100, + // iconPath: "../../images/point.png", + latitude: '', + longitude: '', + // label:'1', + width: 25, + height: 35 + }], + }, - onDisplay() { - this.setData({ - show: true - }); - }, - onClose() { - this.setData({ - show: false - }); - }, - formatDate() { - var date = new Date(); - // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; - var seperator1 = "-"; - var month = date.getMonth() + 1; - var strDate = date.getDate(); - var hour = date.getHours() - var minute = date.getMinutes() - var second = date.getSeconds() - month = month > 9 ? month : "0" + month; - strDate = strDate > 9 ? strDate : "0" + strDate; - hour = hour > 9 ? hour : "0" + hour; - minute = minute > 9 ? minute : "0" + minute; - second = second > 9 ? second : "0" + second; - var currentdate = - date.getFullYear() + - seperator1 + - month + - seperator1 + - strDate + - " " + - hour + ":" + - minute + ":" + - second; - return currentdate; + onDisplay() { + this.setData({ + show: true + }); + }, + onClose() { + this.setData({ + show: false + }); + }, + formatDate() { + var date = new Date(); + // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; + var seperator1 = "-"; + var month = date.getMonth() + 1; + var strDate = date.getDate(); + var hour = date.getHours() + var minute = date.getMinutes() + var second = date.getSeconds() + month = month > 9 ? month : "0" + month; + strDate = strDate > 9 ? strDate : "0" + strDate; + hour = hour > 9 ? hour : "0" + hour; + minute = minute > 9 ? minute : "0" + minute; + second = second > 9 ? second : "0" + second; + var currentdate = + date.getFullYear() + + seperator1 + + month + + seperator1 + + strDate + + " " + + hour + ":" + + minute + ":" + + second; + return currentdate; - }, - onConfirm(event) { - var installtime = 'form.installtimeFmt'; - this.setData({ - show: false, - installtimeFmt: this.formatDate(event.detail), - [installtime]: this.formatDate(event.detail), - }); - }, + }, + onConfirm(event) { + var installtime = 'form.installtimeFmt'; + this.setData({ + show: false, + installtimeFmt: this.formatDate(event.detail), + [installtime]: this.formatDate(event.detail), + }); + }, - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - var _this = this; - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" - }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); - } - _this.setData({ - personoption1: personArr - }) + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + var _this = this; + _this.setData({ + 'markers[0].latitude': Number(wx.getStorageSync('resultObject').latitude) , + 'markers[0].longitude': Number(wx.getStorageSync('resultObject').longitude), + // 'markers[0].label':'10', + 'markers[0].width': 18, + 'markers[0].id':1, + 'markers[0].height': 30, + latitude:Number(wx.getStorageSync('resultObject').latitude), + longitude:Number(wx.getStorageSync('resultObject').longitude) + }) + //获取人员下拉列表 + // wx.request({ + // method: "POST", + // url: app.globalData.httpsUrl + "deviceType/getUser", + // data:{ + // tips:'repair' + // }, + // header: { + // 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + // }, + // success(res) { + // if (res.data.code == 200) { + // var users = res.data.data + // var personArr = []; + // for (var i = 0; i < users.length; i++) { + // var person = { + // text: users[i].name, + // value: users[i].name + // }; + // personArr.push(person); + // } + // _this.setData({ + // personoption1: personArr + // }) + // } + // } + // }) + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); } - }).catch(err => { - console.error(err); - }) - - - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" - }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - _this.setData({ - projectoption: projectArr - }) - } - }).catch(err => { - console.error(err); - }) - - if (options.pageName) { - this.setData({ - pageName: options.pageName - }) - } - - if (options.detail) { - - var formObject = JSON.parse(options.detail); _this.setData({ - form: formObject, - detail: options.detail + projectoption: projectArr }) - - _this.setData({ - ['form.installperson']: "", - ['form.installtimeFmt']: "", - ['form.workmsg']: "", - ['form.description']: "" - }) - - const { - fileList = [] - } = _this.data; - if (formObject.photopath1 != "") { - var file1 = { - url: app.globalData.url + "static/" + formObject.photopath1 - } - fileList.push(file1) - } - if (formObject.photopath2 != "") { - var file2 = { - url: app.globalData.url + "static/" + formObject.photopath2 - } - fileList.push(file2) - } - if (formObject.photopath3 != "") { - var file3 = { - url: app.globalData.url + "static/" + formObject.photopath3 - } - fileList.push(file3) - } - - _this.setData({ - fileList - }); } - var installtime = 'form.installtimeFmt'; - var dateNow = this.formatDate(); - this.setData({ - installtimeFmt: dateNow, - [installtime]: dateNow, - }); - }, + } + }) - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { + //获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + _this.setData({ + option1: welltypeArr + }) + } + } +}) - }, + //跳转时带入参数返回哪页 + if (options.pageName) { + this.setData({ + pageName: options.pageName + }) + } + //跳转时带入参数设备的安装信息 + if (wx.getStorageSync('resultObject')) { + var formObject = wx.getStorageSync('resultObject') + _this.setData({ + form: formObject, + detail: formObject + }) - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { + _this.setData({ + ['form.installperson']: app.globalData.userName, + ['form.installtimeFmt']: "", + ['form.workmsg']: "", + ['form.description']: "" + }) - }, + const { + fileList = [] + } = _this.data; + if (formObject.photopath1 != "") { + var file1 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath1 + } + fileList.push(file1) + } + if (formObject.photopath2 != "") { + var file2 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath2 + } + fileList.push(file2) + } + if (formObject.photopath3 != "") { + var file3 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath3 + } + fileList.push(file3) + } + _this.setData({ + fileList + }); + } + var installtime = 'form.installtimeFmt'; + var dateNow = this.formatDate(); + this.setData({ + installtimeFmt: dateNow, + [installtime]: dateNow, + }); + }, - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, - }, + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + wx.removeStorageSync('resultObject') + }, - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, - }, + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { + }, - }, + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { + }, - }, + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { + }, - }, + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + }, - /** - * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true - **/ + /** + * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true + **/ - isNumber: function (val) { + isNumber: function (val) { - var regPos = /^[0-9]*$/; //非负浮点数 - var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数 - if (regPos.test(val) || regNeg.test(val)) { - return false; - } else { - return true; - } + var regPos = /^[0-9]*$/; //非负浮点数 + var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数 + if (regPos.test(val) || regNeg.test(val)) { + return false; + } else { + return true; + } - }, + }, - formValidate() { + formValidate() { - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } - if (this.data.form.wellcode == "") { - wx.showToast({ - icon: 'none', - title: '井编号不能为空!', - }) - return false - } - if (this.data.form.devicetype == "") { - wx.showToast({ - icon: 'none', - title: '设备类型不能为空!', - }) - return false - } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + if (this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '设备编号不能为空!', + }) + return false + } + if (this.data.form.wellcode == "") { + wx.showToast({ + icon: 'none', + title: '井编号不能为空!', + }) + return false + } + if (this.data.form.devicetype == "") { + wx.showToast({ + icon: 'none', + title: '设备类型不能为空!', + }) + return false + } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null || - this.data.form.installperson == '') { - wx.showToast({ - icon: 'none', - title: '运维人员不能为空!', - }) - return false - } - if (this.data.form.project == "") { - wx.showToast({ - icon: 'none', - title: '所属项目不能为空!', - }) - return false - } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } + if (this.data.form.installperson == null || + this.data.form.installperson == '') { + wx.showToast({ + icon: 'none', + title: '运维人员不能为空!', + }) + return false + } + if (this.data.form.project == "") { + wx.showToast({ + icon: 'none', + title: '所属项目不能为空!', + }) + return false + } - if (this.data.form.welldepth != null) { - if (this.isNumber(this.data.form.welldepth)) { - wx.showToast({ - icon: 'none', - title: '井深必须为数值!', - }) - return false - } - } - if (this.data.form.installheigt != null) { - if (this.isNumber(this.data.form.installheigt)) { - wx.showToast({ - icon: 'none', - title: '到井口距离必须为数值!', - }) - return false - } - } - - return true; - }, - - changeMsg: function () { - var formNew = this.data.form; - var formOld = JSON.parse(this.data.detail); - var descpNew = ""; - if (formNew.devcode != formOld.devcode) { - descpNew += "修改设备编号,原编号:" + formOld.devcode + ",新编号:" + formNew.devcode + ";" - } - if (formNew.devicetype != formOld.devicetype) { - descpNew += "修改设备类型,原设备类型:" + formOld.devicetype + ",新设备类型:" + formNew.devicetype + ";" - } - if (formNew.area != formOld.area) { - descpNew += "修改区,原区:" + formOld.area + ",新区:" + formNew.area + ";" - } - if (formNew.street != formOld.street) { - descpNew += "修改街道,原街道:" + formOld.street + ",新街道:" + formNew.street + ";" - } - if (formNew.wellname != formOld.wellname) { - descpNew += "修改井名称,原井名称:" + formOld.wellname + ",新井名称:" + formNew.wellname + ";" - } - if (formNew.factory != formOld.factory) { - descpNew += "修改权属单位,原权属单位:" + formOld.factory + ",新权属单位:" + formNew.factory + ";" - } - if (formNew.installheigt != formOld.installheigt) { - descpNew += "修改井口距离,原井口距离:" + formOld.installheigt + ",新井口距离:" + formNew.installheigt + ";" - } - if (formNew.installperson != formOld.installperson) { - descpNew += "修改运维人员,原运维人员:" + formOld.installperson + ",新运维人员:" + formNew.installperson + ";" - } - if (formNew.latitude != formOld.latitude) { - descpNew += "修改纬度,原纬度:" + formOld.latitude + ",新纬度:" + formNew.latitude + ";" - } - if (formNew.longitude != formOld.longitude) { - descpNew += "修改经度,原经度:" + formOld.longitude + ",新经度:" + formNew.longitude + ";" - } - if (formNew.position != formOld.position) { - descpNew += "修改位置描述,原位置:" + formOld.position + ",新位置:" + formNew.position + ";" - } - if (formNew.wellcode != formOld.wellcode) { - descpNew += "修改井编号,原编号:" + formOld.wellcode + ",新编号:" + formNew.wellcode + ";" - } - if (formNew.welldepth != formOld.welldepth) { - descpNew += "修改井深,原井深:" + formOld.welldepth + ",新井深:" + formNew.welldepth + ";" - } - if (formNew.welltype != formOld.welltype) { - descpNew += "修改井类型,原井类型:" + formOld.welltype + ",新井类型:" + formNew.welltype + ";" - } - if (formNew.project != formOld.project) { - descpNew += "修改所属项目,原项目:" + formOld.project + ",新项目:" + formNew.project + ";" - } - if (this.data.photopath1 != formOld.photopath1 || - this.data.photopath2 != formOld.photopath2 || - this.data.photopath3 != formOld.photopath3) { - descpNew += "修改照片;" - } - if ("" != formNew.description) { - descpNew += formNew.description; - } - this.setData({ - ['form.description']: descpNew + if (this.data.form.welldepth != null) { + if (this.isNumber(this.data.form.welldepth)) { + wx.showToast({ + icon: 'none', + title: '井深必须为数值!', }) - }, + return false + } + } + if (this.data.form.installheigt != null) { + if (this.isNumber(this.data.form.installheigt)) { + wx.showToast({ + icon: 'none', + title: '到井口距离必须为数值!', + }) + return false + } + } - formSubmit: function (event) { + return true; + }, - if (!this.formValidate()) { - return false; - } - this.changeMsg(); - var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDeviceLog', - data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceLog/add" - }, - }).then(res => { - // var resultObj=JSON.parse(res.result); - if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - if (res.confirm) { - wx.switchTab({ - url: that.data.pageName - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) - } - }).catch(err => { - console.error(err) - wx.showToast({ - title: "提交失败", - }) - }) - }, - confirm(event) { - var that = this; - var formValue = event.detail.value; - var formName = event.target.dataset.id; - var fromN = 'form.' + [formName]; - that.setData({ - [fromN]: formValue - }) - }, + //获取与上次修改的信息 + changeMsg: function () { + var formNew = this.data.form; + console.log(this.data.detail) + var formOld = JSON.parse(this.data.detail); + var descpNew = ""; + if (formNew.devcode != formOld.devcode) { + descpNew += "修改设备编号,原值:" + formOld.devcode + ",新值:" + formNew.devcode + ";" + } + if (formNew.devicetype != formOld.devicetype) { + descpNew += "修改设备类型,原值:" + formOld.devicetype + ",新值:" + formNew.devicetype + ";" + } + if (formNew.area != formOld.area) { + descpNew += "修改区,原值:" + formOld.area + ",新值:" + formNew.area + ";" + } + if (formNew.street != formOld.street) { + descpNew += "修改街道,原值:" + formOld.street + ",新值:" + formNew.street + ";" + } + if (formNew.wellname != formOld.wellname) { + descpNew += "修改井名称,原值:" + formOld.wellname + ",新值:" + formNew.wellname + ";" + } + if (formNew.factory != formOld.factory) { + descpNew += "修改权属单位,原值:" + formOld.factory + ",新值:" + formNew.factory + ";" + } + if (formNew.installheigt != formOld.installheigt) { + descpNew += "修改井口距离,原值:" + formOld.installheigt + ",新值:" + formNew.installheigt + ";" + } + if (formNew.installperson != formOld.installperson) { + descpNew += "修改运维人员,原值:" + formOld.installperson + ",新值:" + formNew.installperson + ";" + } + if (formNew.latitude != formOld.latitude) { + descpNew += "修改纬度,原值:" + formOld.latitude + ",新值:" + formNew.latitude + ";" + } + if (formNew.longitude != formOld.longitude) { + descpNew += "修改经度,原值:" + formOld.longitude + ",新值:" + formNew.longitude + ";" + } + if (formNew.position != formOld.position) { + descpNew += "修改位置描述,原值:" + formOld.position + ",新值:" + formNew.position + ";" + } + if (formNew.wellcode != formOld.wellcode) { + descpNew += "修改井编号,原值:" + formOld.wellcode + ",新值:" + formNew.wellcode + ";" + } + if (formNew.welldepth != formOld.welldepth) { + descpNew += "修改井深,原值:" + formOld.welldepth + ",新值:" + formNew.welldepth + ";" + } + if (formNew.welltype != formOld.welltype) { + descpNew += "修改井类型,原值:" + formOld.welltype + ",新值:" + formNew.welltype + ";" + } + if (formNew.project != formOld.project) { + descpNew += "修改所属项目,原值:" + formOld.project + ",新值:" + formNew.project + ";" + } + if (this.data.form.photopath1 != formOld.photopath1 || + this.data.form.photopath2 != formOld.photopath2 || + this.data.form.photopath3 != formOld.photopath3) { + descpNew += "修改照片;" + } + if ("" != formNew.description) { + descpNew += formNew.description; + } + this.setData({ + ['form.description']: descpNew + }) + }, - scan() { + //提交表单 + formSubmit: function (event) { - wx.scanCode({ - success(res) { - console.log(res) - } - }) + //表单验证 + if (!this.formValidate()) { + return false; + } + //自动生成修改内容 + this.changeMsg(); + //提交权限限制(只有施工人员能修改) + if(app.globalData.role!='repair'){ + wx.showToast({ + icon: 'none', + title: '无权限修改', + duration:2000 + }) + return false + } + var that = this; + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopath = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopath]: fileList[i].url.split("static/")[1] + }) + } + delete that.data.form.installtime + delete that.data.form.createtime + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - paste() { - var _this = this; - wx.getClipboardData({ - success: function (res) { - var longitude = 'form.longitude'; - var latitude = 'form.latitude'; - var longitude84 = 'form.longitude84'; - var latitude84 = 'form.latitude84'; - _this.setData({ - [longitude]: parseFloat(res.data.split(",", 4)[1]).toFixed(6), - [latitude]: parseFloat(res.data.split(",", 4)[0]).toFixed(6), - [longitude84]: "" == (res.data.split(",", 4)[3]) ? "" : parseFloat(res.data.split(",", 4)[3]).toFixed(6), - [latitude84]: "" == (res.data.split(",", 4)[2]) ? "" : parseFloat(res.data.split(",", 4)[2]).toFixed(6), - longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), - latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), - }); - } - }) - }, - selectValue(value) { - var that = this; - var wellType = 'form.welltype'; - that.setData({ - [wellType]: value.detail - }) - }, - selectpersonValue(event) { - var that = this; - var installPerson = 'form.installperson'; - that.setData({ - [installPerson]: event.detail - }) - }, - selectprojectValue(event) { - var that = this; - var project = 'form.project'; - that.setData({ - [project]: event.detail, - showMask: true - }) - }, - open() { - this.setData({ - showMask: true - }) - }, - close() { - this.setData({ - showMask: false - }) - }, - afterRead(event) { - var _this = this; - const { - file - } = event.detail; - const { - fileList = [] - } = _this.data; - var convertpath = ""; - wx.compressImage({ - src: event.detail.file.path, - quality: 25, - success: function (res) { - convertpath = res.tempFilePath; - wx.uploadFile({ - url: app.globalData.httpsUrl + "appDeviceAdd/fileUploadMarker", - filePath:convertpath, - name: 'file', - formData: { - 'text': "编号:" + _this.data.form.devcode + "经度:" + _this.data.form.longitude + "纬度:" + _this.data.form.latitude - }, - header: { - "Content-Type": "multipart/form-data", - 'accept': 'application/json', - }, - success(res) { - if (res.data) { - var url = JSON.parse(res.data); - fileList.push({ - ...file, - url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - }); - _this.setData({ - fileList - }); - } - } + success(res) { + if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + if (res.confirm) { + wx.switchTab({ + url: that.data.pageName }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') } - }) - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // // var base64 = "data:image/png;base64," + wx.getFileSystemManager().readFileSync(convertpath, 'base64'); - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: convertpath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // // wx.cloud.callFunction({ - // // name: 'uploadFile', - // // data: { - // // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // // fileBase64: base64 - // // }, - // // success: function (res) { - // // if (res.result) { - // // fileList.push({ - // // ...file, - // // url: app.globalData.url + "static/" + res.result.data.replace(/\\/g, "/") - // // }); - // // _this.setData({ - // // fileList - // // }); - // // } - // // }, - // // complete: res => { - // // }, - // // }) - // } - // }); + } + }) + } + }, + fail(err) { + wx.showToast({ + title: "提交失败", + }) + } + }) + }, + //报存录入的input信息 + confirm(event) { + var that = this; + var formValue = event.detail.value; + var formName = event.target.dataset.id; + var fromN = 'form.' + [formName]; + that.setData({ + [fromN]: formValue + }) + }, + + //扫码 + scan() { + + wx.scanCode({ + success(res) { + console.log(res) + } + }) + }, + //粘贴经纬度 + paste() { + var _this = this; + wx.getClipboardData({ + success: function (res) { + var longitude = 'form.longitude'; + var latitude = 'form.latitude'; + var longitude84 = 'form.longitude84'; + var latitude84 = 'form.latitude84'; + _this.setData({ + [longitude]: parseFloat(res.data.split(",", 4)[1]).toFixed(6), + [latitude]: parseFloat(res.data.split(",", 4)[0]).toFixed(6), + [longitude84]: "" == (res.data.split(",", 4)[3]) ? "" : parseFloat(res.data.split(",", 4)[3]).toFixed(6), + [latitude84]: "" == (res.data.split(",", 4)[2]) ? "" : parseFloat(res.data.split(",", 4)[2]).toFixed(6), + longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), + latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), + }); + } + }) + }, + selectValue(value) { + var that = this; + var wellType = 'form.welltype'; + that.setData({ + [wellType]: value.detail + }) + }, + //运维人员默认为登录人 + // selectpersonValue(event) { + // var that = this; + // var installPerson = 'form.installperson'; + // that.setData({ + // [installPerson]: event.detail + // }) + // }, + selectprojectValue(event) { + var that = this; + var project = 'form.project'; + that.setData({ + [project]: event.detail, + showMask: true + }) + }, + + open() { + this.setData({ + showMask: true + }) + }, + //隐藏textarea,防止遮挡 + close() { + this.setData({ + showMask: false + }) + }, + //上传照片 + afterRead(event) { + var _this = this; + const { + file + } = event.detail; + const { + fileList = [] + } = _this.data; + var convertpath = ""; + wx.compressImage({ + src: event.detail.file.path, + quality: 25, + success: function (res) { + convertpath = res.tempFilePath; + wx.uploadFile({ + url: app.globalData.httpsUrl + "appDeviceAdd/fileUploadMarker", + filePath: convertpath, + name: 'file', + formData: { + 'text': "编号:" + _this.data.form.devcode + "经度:" + _this.data.form.longitude + "纬度:" + _this.data.form.latitude }, - deletePhoto(event) { - var that = this - var image_index = event.detail.index - var fileList_new = that.data.fileList; - wx.showModal({ - content: '确定删除照片?', - success: function (res) { - if (res.confirm) { - fileList_new.splice(image_index, 1); - that.setData({ - fileList: fileList_new - }) - wx.cloud.callFunction({ - name: 'deletePhoto', - data: { - url: app.globalData.url + "appDeviceLog/deletePhoto", - devcode: that.data.form.devcode, - pathIndex: image_index - }, - success: function (res) {}, - complete: res => {}, - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + "Content-Type": "multipart/form-data", + 'accept': 'application/json', }, - }) \ No newline at end of file + success(res) { + if (res.data) { + var url = JSON.parse(res.data); + fileList.push({ + ...file, + url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") + }); + _this.setData({ + fileList + }); + } + } + }) + } + }) + }, + //删除照片 + deletePhoto(event) { + var that = this + var image_index = event.detail.index + var fileList_new = that.data.fileList; + wx.showModal({ + content: '确定删除照片?', + success: function (res) { + if (res.confirm) { + fileList_new.splice(image_index, 1); + that.setData({ + fileList: fileList_new + }) + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deletePhoto", + data: { + devcode: that.data.form.devcode + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) {} + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } +}) \ No newline at end of file diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.wxml b/miniprogram/pages/addDevicelog/addDeviceLog.wxml index 38620d4..b10cc7d 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.wxml +++ b/miniprogram/pages/addDevicelog/addDeviceLog.wxml @@ -1,15 +1,21 @@ - + + + + + - + - - + + - - + + - + @@ -39,24 +45,25 @@ - - - + + + - + - + + @@ -64,7 +71,7 @@ - + @@ -79,9 +86,9 @@ - + - 保存 + 保存 diff --git a/cloudfunctions/project.config.json b/cloudfunctions/project.config.json new file mode 100644 index 0000000..2b3119a --- /dev/null +++ b/cloudfunctions/project.config.json @@ -0,0 +1,28 @@ +{ + "appid": "wx2cef527a000f87c9", + "compileType": "miniprogram", + "libVersion": "2.27.3", + "packOptions": { + "ignore": [], + "include": [] + }, + "setting": { + "coverView": true, + "es6": true, + "postcss": true, + "minified": true, + "enhance": true, + "showShadowRootInWxmlPanel": true, + "packNpmRelationList": [], + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + } + }, + "condition": {}, + "editorSetting": { + "tabIndent": "insertSpaces", + "tabSize": 4 + } +} \ No newline at end of file diff --git a/cloudfunctions/project.private.config.json b/cloudfunctions/project.private.config.json new file mode 100644 index 0000000..42ff49d --- /dev/null +++ b/cloudfunctions/project.private.config.json @@ -0,0 +1,7 @@ +{ + "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", + "projectname": "cloudfunctions", + "setting": { + "compileHotReLoad": true + } +} \ No newline at end of file diff --git a/miniprogram/app.js b/miniprogram/app.js index 51d56f3..50a8a54 100644 --- a/miniprogram/app.js +++ b/miniprogram/app.js @@ -18,13 +18,15 @@ // this.globalData = {} }, globalData: { - // url: "http://111.198.10.15:11604/", - httpsUrl: "https://logapi.smartlog.work/", - httpsTestUrl: "https://smartlog.work/prodapi4test/", - url: "http://139.198.18.188:8083/", + httpsUrl: "https://logapi.smartlog.work/", + // httpsUrl: "http://139.198.18.188:8083/", // url: "http://127.0.0.1:8083/", - // httpsUrl: "http://127.0.0.1:8083/", + //httpsUrl: "http://127.0.0.1:8083/", openid: null, - indexCount:1 - }, + indexCount:1, + nickName:"", + userName:"", + role:"", + devcode:"" + } }) diff --git a/miniprogram/app.json b/miniprogram/app.json index d23f798..2b6db76 100644 --- a/miniprogram/app.json +++ b/miniprogram/app.json @@ -1,15 +1,17 @@ { "cloud": true, "pages": [ + "pages/login/login", "pages/indexapp/indexapp", "pages/earth/earth", "pages/applog/applog", "pages/addDevice/addDevice", "pages/addDevicelog/addDeviceLog", - "pages/searchLog/searchLog" + "pages/searchLog/searchLog", + "pages/notice/notice" ], "window": { - "backgroundColor": "#F6F6F6", + "backgroundColor": "#E6D480", "backgroundTextStyle": "light", "navigationBarBackgroundColor": "#FFCF00", "navigationBarTitleText": "智慧施工", @@ -46,11 +48,11 @@ "desc": "你的位置信息将用于小程序位置接口的效果展示" } }, + "requiredPrivateInfos": ["getLocation", "chooseLocation"], "networkTimeout": { "request": 30000, "connectSocket": 30000, "uploadFile": 30000, "downloadFile": 30000 - }, - "style": "v2" + } } \ No newline at end of file diff --git a/miniprogram/images/applocat.png b/miniprogram/images/applocat.png new file mode 100644 index 0000000..fe49f54 --- /dev/null +++ b/miniprogram/images/applocat.png Binary files differ diff --git a/miniprogram/images/back.png b/miniprogram/images/back.png new file mode 100644 index 0000000..32ac82d --- /dev/null +++ b/miniprogram/images/back.png Binary files differ diff --git a/miniprogram/images/bottom.png b/miniprogram/images/bottom.png new file mode 100644 index 0000000..d910e98 --- /dev/null +++ b/miniprogram/images/bottom.png Binary files differ diff --git a/miniprogram/images/header.png b/miniprogram/images/header.png new file mode 100644 index 0000000..6ea222e --- /dev/null +++ b/miniprogram/images/header.png Binary files differ diff --git a/miniprogram/images/login.png b/miniprogram/images/login.png index 8b73cc0..6471c46 100644 --- a/miniprogram/images/login.png +++ b/miniprogram/images/login.png Binary files differ diff --git a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss index 5a591fb..c9c35b5 100644 --- a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss +++ b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:100%;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:100%}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file +@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:650rpx;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:600rpx}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file diff --git a/miniprogram/pages/addDevice/addDevice.js b/miniprogram/pages/addDevice/addDevice.js index 2783674..78f00b7 100644 --- a/miniprogram/pages/addDevice/addDevice.js +++ b/miniprogram/pages/addDevice/addDevice.js @@ -1,5 +1,7 @@ // miniprogram/pages/addDevice/addDevice.js // import WxValidate from '../../utils/WxValidate.js' +var QQMapWX = require('../../libs/qqmap-wx-jssdk.js'); +var qqmapsdk; var app = getApp() Page({ @@ -11,32 +13,10 @@ canvasWidth: '', longitude: '', latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], + option1: [], personoption1: [], projectoption: [], + devtypeList:[], show: false, form: { devcode: "", @@ -59,7 +39,10 @@ project: "", area: "", street: "", - wellname: "" + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '', }, fileList: [] }, @@ -117,12 +100,14 @@ var that = this; //初始化表单内容为上次填写值 var cacheForms = wx.getStorageSync('cacheList') - if (cacheForms) { + cacheForms.photopath1='' + cacheForms.photopath2='' + cacheForms.photopath3='' + that.data.fileList=[] that.setData({ form: cacheForms, devcode: cacheForms.devcode, - }) } var form = that.data.form @@ -155,55 +140,89 @@ } }) + +//获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + that.setData({ + option1: welltypeArr + }) + } + } +}) + + //获取人员下拉列表 - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/getUser", + data:{ + tips:'repair' }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data.code == 200) { + var users = res.data.data + var personArr = []; + for (var i = 0; i < users.length; i++) { + var person = { + text: users[i].name, + value: users[i].name + }; + personArr.push(person); + } + that.setData({ + personoption1: personArr + }) } - that.setData({ - personoption1: personArr - }) } - }).catch(err => { - console.error(err); - }) + }) + - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - that.setData({ - projectoption: projectArr - }) + success(res){ + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); + } + that.setData({ + projectoption: projectArr + }) + } } - }).catch(err => { - console.error(err); - }) + }) + var installtime = 'form.installtimeFmt'; var dateNow = this.formatDate(); this.setData({ @@ -211,8 +230,40 @@ installtimeFmt: dateNow, [installtime]: dateNow, }); + + + + /** + * 获取设备类型下拉列表 + */ + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/deviceType", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var TypeList = res.data.data + var typeArr = []; + for (var i = 0; i < TypeList.length; i++) { + var type = { + text: TypeList[i].productName, + value: TypeList[i].productName + }; + typeArr.push(type); + } + that.setData({ + devtypeList: typeArr + }) + } + } + }) }, + + + /** * 生命周期函数--监听页面初次渲染完成 */ @@ -280,29 +331,7 @@ }, - - //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 - drawText: function (ctx, str, leftWidth, initHeight, titleHeight, canvasWidth) { - var lineWidth = 0; - var lastSubStrIndex = 0; //每次开始截取的字符串的索引 - for (let i = 0; i < str.length; i++) { - lineWidth += ctx.measureText(str[i]).width; - if (lineWidth > canvasWidth) { - ctx.fillText(str.substring(lastSubStrIndex, i), leftWidth, initHeight); //绘制截取部分 - initHeight = initHeight + leftWidth * 2; //22为字体的高度 - lineWidth = 0; - lastSubStrIndex = i; - // titleHeight += 40; - } - if (i == str.length - 1) { //绘制剩余部分 - ctx.fillText(str.substring(lastSubStrIndex, i + 1), leftWidth, initHeight); - } - } - // // 标题border-bottom 线距顶部距离 - // titleHeight = titleHeight + 10; - // return titleHeight - }, - + //验证表单 formValidate() { if (this.data.form.devcode == "") { @@ -312,27 +341,20 @@ }) return false } - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } if (this.data.form.wellcode == "") { wx.showToast({ icon: 'none', @@ -348,22 +370,10 @@ }) return false } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null) { + + if (this.data.form.installperson == "") { wx.showToast({ icon: 'none', title: '安装人员不能为空!', @@ -408,56 +418,90 @@ } return true; }, + //提交表单 formSubmit: function (event) { + console.log(this.data.form) + //表单参数验证 if (!this.formValidate()) { return false; } var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDevice', + //验证设备编号长度 + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/getDevTypeLength", data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceAdd/add" + code: encodeURI(this.data.form.devicetype) }, - }).then(res => { - if (res.result.code == 500) { - wx.showToast({ - title: '设备编号已安装!', - }) - } else if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - //用于回显 - wx.setStorageSync('cacheList', that.data.form) - //提交成功后提示用户操作 - if (res.confirm) { - wx.switchTab({ - url: '../earth/earth' - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (""==res.data.data ||res.data.data == that.data.form.devcode.length) { + that.saveDevice() + } else { //编号位数不对提示 + wx.showToast({ + icon: 'none', + title: '设备编号位数不对!', + duration: 1000 + }) + return false + } } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "提交失败", - }) }) }, + + //保存设备基本信息 + saveDevice() { + var that = this; + //设置照片路径 + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopathForm = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopathForm]: fileList[i].url.split("static/")[1] + }) + } + //表单提交 + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 500) { + wx.showToast({ + title: '设备编号已安装!', + }) + } else if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + //用于回显 + wx.setStorageSync('cacheList', that.data.form) + //提交成功后提示用户操作 + if (res.confirm) { + wx.switchTab({ + url: '../earth/earth' + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } + }, + fail(err) { + wx.showToast({ + title: '提交失败!', + }) + } + }) + }, + + //input 输入框设置值 confirm(event) { var that = this; var formValue = event.detail.value; @@ -466,8 +510,30 @@ that.setData({ [fromN]: formValue }) + //若输入是设备编号,自动获取设备类型 + if('devcode'==formName){ + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", + data: { + devcode: formValue, + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + that.setData({ + [formDevicetype]: res.data + }); + } + } + }) + } }, + //扫描设备获取编号和设备类型 scan() { var _this = this; wx.scanCode({ @@ -477,23 +543,28 @@ _this.setData({ [formdevcode]: devcode }); - wx.cloud.callFunction({ - name: 'findModeCode', + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", data: { devcode: devcode, - url: app.globalData.url + "appDeviceAdd/findModeCodeByCode" }, - }).then(res => { - if (res.result) { - var formDevicetype = 'form.devicetype' - _this.setData({ - [formDevicetype]: res.result - }); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + _this.setData({ + [formDevicetype]: res.data + }); + } } }) } }) }, + //粘贴经纬度 paste() { var _this = this; wx.getClipboardData({ @@ -510,9 +581,11 @@ longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), }); + _this.showAddress(_this.data.form.longitude,_this.data.form.latitude,_this) } }) }, + //设置经类型 selectValue(value) { var that = this; @@ -521,6 +594,16 @@ [wellType]: value.detail }) }, + + //设置设备类型 + selectDevType(event) { + var that = this; + var devtype = 'form.devicetype'; + that.setData({ + [devtype]: event.detail + }) + }, + //设置运维人员 selectpersonValue(event) { var that = this; var installPerson = 'form.installperson'; @@ -528,6 +611,7 @@ [installPerson]: event.detail }) }, + //设置项目 selectprojectValue(event) { var that = this; var project = 'form.project'; @@ -535,8 +619,41 @@ [project]: event.detail }) }, + showAddress :function(longitude, latitude, self) { + // 实例化腾讯地图API核心类 + qqmapsdk = new QQMapWX({ + key: 'BGPBZ-C5O3P-ROUDR-LWC4J-63EKH-V5FRX'//此处使用你自己申请的key + }) + // 腾讯地图调用接口 + qqmapsdk.reverseGeocoder({ + location: { + latitude: latitude, + longitude: longitude + }, + success: function (res) { + self.setData({ + 'form.area':res.result.address.slice(0,res.result.address.indexOf('区')+1), + 'form.street':res.result.address.slice(res.result.address.indexOf('区')+1) + }) + }, + fail: function (res) { + console.log(res); + }, + complete: function (res) { + } + }); + }, + //上传照片 afterRead(event) { var _this = this; + if (_this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '请先填写设备编号!\r\n否则水印中无编号', + duration: 2000 + }) + return false + } const { file } = event.detail; @@ -576,78 +693,8 @@ }) } }) - // 压缩图片 - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // //获取图片尺寸 - // wx.getImageInfo({ - // src: convertpath, - // success(res) { - // _this.setData({ - // canvasHeight: res.height, - // canvasWidth: res.width - // }) - // var ctx = wx.createCanvasContext('firstCanvas') - - // //将图片src放到cancas内,宽高为图片大小 - // ctx.drawImage(convertpath, 0, 0, res.width, res.height) - // //将声明的时间放入canvas - // ctx.setFontSize(30 * (res.width / 750)) //注意:设置文字大小必须放在填充文字之前,否则不生效 - // ctx.setFillStyle('blue') - // var text = "编号:" + _this.data.form.devcode + "\n经度:" + _this.data.form.longitude + "\n纬度:" + _this.data.form.latitude - // // _this.drawText(ctx,text,20, 70, 5, res.width) - // _this.drawText(ctx, text, 15 * (res.width / 750), 70 * (res.width / 750), 5, res.width) - - // // ctx.fillText(text, 0, 40) - // // ctx.strokeText(_this.data.form.devcode, 0, 30) - // //生成水印图 - // ctx.draw(false, function () { - // wx.canvasToTempFilePath({ - // canvasId: 'firstCanvas', - // success: (res) => { - // wx.compressImage({ - // src: res.tempFilePath, - // quality: 25, - // success: function (res) { - // //上传照片至服务器 - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: res.tempFilePath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // } - // }) - // //// - // } - // }) - // }) - // } - // }) - // } - // }); }, + //删除照片 deletePhoto(event) { var image_index = event.detail.index var fileList_new = this.data.fileList; diff --git a/miniprogram/pages/addDevice/addDevice.wxml b/miniprogram/pages/addDevice/addDevice.wxml index b0977e2..f12c254 100644 --- a/miniprogram/pages/addDevice/addDevice.wxml +++ b/miniprogram/pages/addDevice/addDevice.wxml @@ -5,18 +5,30 @@ - + + + + + + + + + + + + + - - + + - - - + + + @@ -29,13 +41,13 @@ - + - + - + - + @@ -54,8 +66,7 @@ - - + @@ -68,8 +79,8 @@ - - + + - 保存 + 保存 \ No newline at end of file diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.js b/miniprogram/pages/addDevicelog/addDeviceLog.js index cdec71b..a0dc6da 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.js +++ b/miniprogram/pages/addDevicelog/addDeviceLog.js @@ -3,681 +3,665 @@ var app = getApp(); Page({ - /** - * 页面的初始数据 - */ - data: { - pageName: '', - showMask: false, - today: new Date().getTime(), - longitude: '', - latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], - personoption1: [], - projectoption: [], - devcode: "", - deviceMode: "", - installtimeFmt: '', - show: false, - form: { - devcode: "", - wellcode: "", - welltype: "", - welldepth: "", - installheigt: "", - installperson: "", - installtimeFmt: "", - photopath: "", - factory: "", - workmsg: "", - position: "", - description: "", - longitude: "", - latitude: "", - longitude84: "", - latitude84: "", - devicetype: "", - project: "", - area: "", - street: "", - wellname: "" - }, - fileList: [], - detail: "" - }, + /** + * 页面的初始数据 + */ + data: { + pageName: '', + showMask: false, + today: new Date().getTime(), + longitude: '', + latitude: '', + option1: [], + personoption1: [], + projectoption: [], + devcode: "", + deviceMode: "", + installtimeFmt: '', + show: false, + form: { + devcode: "", + wellcode: "", + welltype: "", + welldepth: "", + installheigt: "", + installperson: "", + installtimeFmt: "", + photopath: "", + factory: "", + workmsg: "", + position: "", + description: "", + longitude: "", + latitude: "", + longitude84: "", + latitude84: "", + devicetype: "", + project: "", + area: "", + street: "", + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '' + }, + fileList: [], + detail: "", + markers: [{ + id: 100, + // iconPath: "../../images/point.png", + latitude: '', + longitude: '', + // label:'1', + width: 25, + height: 35 + }], + }, - onDisplay() { - this.setData({ - show: true - }); - }, - onClose() { - this.setData({ - show: false - }); - }, - formatDate() { - var date = new Date(); - // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; - var seperator1 = "-"; - var month = date.getMonth() + 1; - var strDate = date.getDate(); - var hour = date.getHours() - var minute = date.getMinutes() - var second = date.getSeconds() - month = month > 9 ? month : "0" + month; - strDate = strDate > 9 ? strDate : "0" + strDate; - hour = hour > 9 ? hour : "0" + hour; - minute = minute > 9 ? minute : "0" + minute; - second = second > 9 ? second : "0" + second; - var currentdate = - date.getFullYear() + - seperator1 + - month + - seperator1 + - strDate + - " " + - hour + ":" + - minute + ":" + - second; - return currentdate; + onDisplay() { + this.setData({ + show: true + }); + }, + onClose() { + this.setData({ + show: false + }); + }, + formatDate() { + var date = new Date(); + // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; + var seperator1 = "-"; + var month = date.getMonth() + 1; + var strDate = date.getDate(); + var hour = date.getHours() + var minute = date.getMinutes() + var second = date.getSeconds() + month = month > 9 ? month : "0" + month; + strDate = strDate > 9 ? strDate : "0" + strDate; + hour = hour > 9 ? hour : "0" + hour; + minute = minute > 9 ? minute : "0" + minute; + second = second > 9 ? second : "0" + second; + var currentdate = + date.getFullYear() + + seperator1 + + month + + seperator1 + + strDate + + " " + + hour + ":" + + minute + ":" + + second; + return currentdate; - }, - onConfirm(event) { - var installtime = 'form.installtimeFmt'; - this.setData({ - show: false, - installtimeFmt: this.formatDate(event.detail), - [installtime]: this.formatDate(event.detail), - }); - }, + }, + onConfirm(event) { + var installtime = 'form.installtimeFmt'; + this.setData({ + show: false, + installtimeFmt: this.formatDate(event.detail), + [installtime]: this.formatDate(event.detail), + }); + }, - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - var _this = this; - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" - }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); - } - _this.setData({ - personoption1: personArr - }) + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + var _this = this; + _this.setData({ + 'markers[0].latitude': Number(wx.getStorageSync('resultObject').latitude) , + 'markers[0].longitude': Number(wx.getStorageSync('resultObject').longitude), + // 'markers[0].label':'10', + 'markers[0].width': 18, + 'markers[0].id':1, + 'markers[0].height': 30, + latitude:Number(wx.getStorageSync('resultObject').latitude), + longitude:Number(wx.getStorageSync('resultObject').longitude) + }) + //获取人员下拉列表 + // wx.request({ + // method: "POST", + // url: app.globalData.httpsUrl + "deviceType/getUser", + // data:{ + // tips:'repair' + // }, + // header: { + // 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + // }, + // success(res) { + // if (res.data.code == 200) { + // var users = res.data.data + // var personArr = []; + // for (var i = 0; i < users.length; i++) { + // var person = { + // text: users[i].name, + // value: users[i].name + // }; + // personArr.push(person); + // } + // _this.setData({ + // personoption1: personArr + // }) + // } + // } + // }) + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); } - }).catch(err => { - console.error(err); - }) - - - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" - }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - _this.setData({ - projectoption: projectArr - }) - } - }).catch(err => { - console.error(err); - }) - - if (options.pageName) { - this.setData({ - pageName: options.pageName - }) - } - - if (options.detail) { - - var formObject = JSON.parse(options.detail); _this.setData({ - form: formObject, - detail: options.detail + projectoption: projectArr }) - - _this.setData({ - ['form.installperson']: "", - ['form.installtimeFmt']: "", - ['form.workmsg']: "", - ['form.description']: "" - }) - - const { - fileList = [] - } = _this.data; - if (formObject.photopath1 != "") { - var file1 = { - url: app.globalData.url + "static/" + formObject.photopath1 - } - fileList.push(file1) - } - if (formObject.photopath2 != "") { - var file2 = { - url: app.globalData.url + "static/" + formObject.photopath2 - } - fileList.push(file2) - } - if (formObject.photopath3 != "") { - var file3 = { - url: app.globalData.url + "static/" + formObject.photopath3 - } - fileList.push(file3) - } - - _this.setData({ - fileList - }); } - var installtime = 'form.installtimeFmt'; - var dateNow = this.formatDate(); - this.setData({ - installtimeFmt: dateNow, - [installtime]: dateNow, - }); - }, + } + }) - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { + //获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + _this.setData({ + option1: welltypeArr + }) + } + } +}) - }, + //跳转时带入参数返回哪页 + if (options.pageName) { + this.setData({ + pageName: options.pageName + }) + } + //跳转时带入参数设备的安装信息 + if (wx.getStorageSync('resultObject')) { + var formObject = wx.getStorageSync('resultObject') + _this.setData({ + form: formObject, + detail: formObject + }) - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { + _this.setData({ + ['form.installperson']: app.globalData.userName, + ['form.installtimeFmt']: "", + ['form.workmsg']: "", + ['form.description']: "" + }) - }, + const { + fileList = [] + } = _this.data; + if (formObject.photopath1 != "") { + var file1 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath1 + } + fileList.push(file1) + } + if (formObject.photopath2 != "") { + var file2 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath2 + } + fileList.push(file2) + } + if (formObject.photopath3 != "") { + var file3 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath3 + } + fileList.push(file3) + } + _this.setData({ + fileList + }); + } + var installtime = 'form.installtimeFmt'; + var dateNow = this.formatDate(); + this.setData({ + installtimeFmt: dateNow, + [installtime]: dateNow, + }); + }, - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, - }, + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + wx.removeStorageSync('resultObject') + }, - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, - }, + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { + }, - }, + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { + }, - }, + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { + }, - }, + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + }, - /** - * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true - **/ + /** + * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true + **/ - isNumber: function (val) { + isNumber: function (val) { - var regPos = /^[0-9]*$/; //非负浮点数 - var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数 - if (regPos.test(val) || regNeg.test(val)) { - return false; - } else { - return true; - } + var regPos = /^[0-9]*$/; //非负浮点数 + var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数 + if (regPos.test(val) || regNeg.test(val)) { + return false; + } else { + return true; + } - }, + }, - formValidate() { + formValidate() { - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } - if (this.data.form.wellcode == "") { - wx.showToast({ - icon: 'none', - title: '井编号不能为空!', - }) - return false - } - if (this.data.form.devicetype == "") { - wx.showToast({ - icon: 'none', - title: '设备类型不能为空!', - }) - return false - } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + if (this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '设备编号不能为空!', + }) + return false + } + if (this.data.form.wellcode == "") { + wx.showToast({ + icon: 'none', + title: '井编号不能为空!', + }) + return false + } + if (this.data.form.devicetype == "") { + wx.showToast({ + icon: 'none', + title: '设备类型不能为空!', + }) + return false + } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null || - this.data.form.installperson == '') { - wx.showToast({ - icon: 'none', - title: '运维人员不能为空!', - }) - return false - } - if (this.data.form.project == "") { - wx.showToast({ - icon: 'none', - title: '所属项目不能为空!', - }) - return false - } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } + if (this.data.form.installperson == null || + this.data.form.installperson == '') { + wx.showToast({ + icon: 'none', + title: '运维人员不能为空!', + }) + return false + } + if (this.data.form.project == "") { + wx.showToast({ + icon: 'none', + title: '所属项目不能为空!', + }) + return false + } - if (this.data.form.welldepth != null) { - if (this.isNumber(this.data.form.welldepth)) { - wx.showToast({ - icon: 'none', - title: '井深必须为数值!', - }) - return false - } - } - if (this.data.form.installheigt != null) { - if (this.isNumber(this.data.form.installheigt)) { - wx.showToast({ - icon: 'none', - title: '到井口距离必须为数值!', - }) - return false - } - } - - return true; - }, - - changeMsg: function () { - var formNew = this.data.form; - var formOld = JSON.parse(this.data.detail); - var descpNew = ""; - if (formNew.devcode != formOld.devcode) { - descpNew += "修改设备编号,原编号:" + formOld.devcode + ",新编号:" + formNew.devcode + ";" - } - if (formNew.devicetype != formOld.devicetype) { - descpNew += "修改设备类型,原设备类型:" + formOld.devicetype + ",新设备类型:" + formNew.devicetype + ";" - } - if (formNew.area != formOld.area) { - descpNew += "修改区,原区:" + formOld.area + ",新区:" + formNew.area + ";" - } - if (formNew.street != formOld.street) { - descpNew += "修改街道,原街道:" + formOld.street + ",新街道:" + formNew.street + ";" - } - if (formNew.wellname != formOld.wellname) { - descpNew += "修改井名称,原井名称:" + formOld.wellname + ",新井名称:" + formNew.wellname + ";" - } - if (formNew.factory != formOld.factory) { - descpNew += "修改权属单位,原权属单位:" + formOld.factory + ",新权属单位:" + formNew.factory + ";" - } - if (formNew.installheigt != formOld.installheigt) { - descpNew += "修改井口距离,原井口距离:" + formOld.installheigt + ",新井口距离:" + formNew.installheigt + ";" - } - if (formNew.installperson != formOld.installperson) { - descpNew += "修改运维人员,原运维人员:" + formOld.installperson + ",新运维人员:" + formNew.installperson + ";" - } - if (formNew.latitude != formOld.latitude) { - descpNew += "修改纬度,原纬度:" + formOld.latitude + ",新纬度:" + formNew.latitude + ";" - } - if (formNew.longitude != formOld.longitude) { - descpNew += "修改经度,原经度:" + formOld.longitude + ",新经度:" + formNew.longitude + ";" - } - if (formNew.position != formOld.position) { - descpNew += "修改位置描述,原位置:" + formOld.position + ",新位置:" + formNew.position + ";" - } - if (formNew.wellcode != formOld.wellcode) { - descpNew += "修改井编号,原编号:" + formOld.wellcode + ",新编号:" + formNew.wellcode + ";" - } - if (formNew.welldepth != formOld.welldepth) { - descpNew += "修改井深,原井深:" + formOld.welldepth + ",新井深:" + formNew.welldepth + ";" - } - if (formNew.welltype != formOld.welltype) { - descpNew += "修改井类型,原井类型:" + formOld.welltype + ",新井类型:" + formNew.welltype + ";" - } - if (formNew.project != formOld.project) { - descpNew += "修改所属项目,原项目:" + formOld.project + ",新项目:" + formNew.project + ";" - } - if (this.data.photopath1 != formOld.photopath1 || - this.data.photopath2 != formOld.photopath2 || - this.data.photopath3 != formOld.photopath3) { - descpNew += "修改照片;" - } - if ("" != formNew.description) { - descpNew += formNew.description; - } - this.setData({ - ['form.description']: descpNew + if (this.data.form.welldepth != null) { + if (this.isNumber(this.data.form.welldepth)) { + wx.showToast({ + icon: 'none', + title: '井深必须为数值!', }) - }, + return false + } + } + if (this.data.form.installheigt != null) { + if (this.isNumber(this.data.form.installheigt)) { + wx.showToast({ + icon: 'none', + title: '到井口距离必须为数值!', + }) + return false + } + } - formSubmit: function (event) { + return true; + }, - if (!this.formValidate()) { - return false; - } - this.changeMsg(); - var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDeviceLog', - data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceLog/add" - }, - }).then(res => { - // var resultObj=JSON.parse(res.result); - if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - if (res.confirm) { - wx.switchTab({ - url: that.data.pageName - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) - } - }).catch(err => { - console.error(err) - wx.showToast({ - title: "提交失败", - }) - }) - }, - confirm(event) { - var that = this; - var formValue = event.detail.value; - var formName = event.target.dataset.id; - var fromN = 'form.' + [formName]; - that.setData({ - [fromN]: formValue - }) - }, + //获取与上次修改的信息 + changeMsg: function () { + var formNew = this.data.form; + console.log(this.data.detail) + var formOld = JSON.parse(this.data.detail); + var descpNew = ""; + if (formNew.devcode != formOld.devcode) { + descpNew += "修改设备编号,原值:" + formOld.devcode + ",新值:" + formNew.devcode + ";" + } + if (formNew.devicetype != formOld.devicetype) { + descpNew += "修改设备类型,原值:" + formOld.devicetype + ",新值:" + formNew.devicetype + ";" + } + if (formNew.area != formOld.area) { + descpNew += "修改区,原值:" + formOld.area + ",新值:" + formNew.area + ";" + } + if (formNew.street != formOld.street) { + descpNew += "修改街道,原值:" + formOld.street + ",新值:" + formNew.street + ";" + } + if (formNew.wellname != formOld.wellname) { + descpNew += "修改井名称,原值:" + formOld.wellname + ",新值:" + formNew.wellname + ";" + } + if (formNew.factory != formOld.factory) { + descpNew += "修改权属单位,原值:" + formOld.factory + ",新值:" + formNew.factory + ";" + } + if (formNew.installheigt != formOld.installheigt) { + descpNew += "修改井口距离,原值:" + formOld.installheigt + ",新值:" + formNew.installheigt + ";" + } + if (formNew.installperson != formOld.installperson) { + descpNew += "修改运维人员,原值:" + formOld.installperson + ",新值:" + formNew.installperson + ";" + } + if (formNew.latitude != formOld.latitude) { + descpNew += "修改纬度,原值:" + formOld.latitude + ",新值:" + formNew.latitude + ";" + } + if (formNew.longitude != formOld.longitude) { + descpNew += "修改经度,原值:" + formOld.longitude + ",新值:" + formNew.longitude + ";" + } + if (formNew.position != formOld.position) { + descpNew += "修改位置描述,原值:" + formOld.position + ",新值:" + formNew.position + ";" + } + if (formNew.wellcode != formOld.wellcode) { + descpNew += "修改井编号,原值:" + formOld.wellcode + ",新值:" + formNew.wellcode + ";" + } + if (formNew.welldepth != formOld.welldepth) { + descpNew += "修改井深,原值:" + formOld.welldepth + ",新值:" + formNew.welldepth + ";" + } + if (formNew.welltype != formOld.welltype) { + descpNew += "修改井类型,原值:" + formOld.welltype + ",新值:" + formNew.welltype + ";" + } + if (formNew.project != formOld.project) { + descpNew += "修改所属项目,原值:" + formOld.project + ",新值:" + formNew.project + ";" + } + if (this.data.form.photopath1 != formOld.photopath1 || + this.data.form.photopath2 != formOld.photopath2 || + this.data.form.photopath3 != formOld.photopath3) { + descpNew += "修改照片;" + } + if ("" != formNew.description) { + descpNew += formNew.description; + } + this.setData({ + ['form.description']: descpNew + }) + }, - scan() { + //提交表单 + formSubmit: function (event) { - wx.scanCode({ - success(res) { - console.log(res) - } - }) + //表单验证 + if (!this.formValidate()) { + return false; + } + //自动生成修改内容 + this.changeMsg(); + //提交权限限制(只有施工人员能修改) + if(app.globalData.role!='repair'){ + wx.showToast({ + icon: 'none', + title: '无权限修改', + duration:2000 + }) + return false + } + var that = this; + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopath = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopath]: fileList[i].url.split("static/")[1] + }) + } + delete that.data.form.installtime + delete that.data.form.createtime + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - paste() { - var _this = this; - wx.getClipboardData({ - success: function (res) { - var longitude = 'form.longitude'; - var latitude = 'form.latitude'; - var longitude84 = 'form.longitude84'; - var latitude84 = 'form.latitude84'; - _this.setData({ - [longitude]: parseFloat(res.data.split(",", 4)[1]).toFixed(6), - [latitude]: parseFloat(res.data.split(",", 4)[0]).toFixed(6), - [longitude84]: "" == (res.data.split(",", 4)[3]) ? "" : parseFloat(res.data.split(",", 4)[3]).toFixed(6), - [latitude84]: "" == (res.data.split(",", 4)[2]) ? "" : parseFloat(res.data.split(",", 4)[2]).toFixed(6), - longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), - latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), - }); - } - }) - }, - selectValue(value) { - var that = this; - var wellType = 'form.welltype'; - that.setData({ - [wellType]: value.detail - }) - }, - selectpersonValue(event) { - var that = this; - var installPerson = 'form.installperson'; - that.setData({ - [installPerson]: event.detail - }) - }, - selectprojectValue(event) { - var that = this; - var project = 'form.project'; - that.setData({ - [project]: event.detail, - showMask: true - }) - }, - open() { - this.setData({ - showMask: true - }) - }, - close() { - this.setData({ - showMask: false - }) - }, - afterRead(event) { - var _this = this; - const { - file - } = event.detail; - const { - fileList = [] - } = _this.data; - var convertpath = ""; - wx.compressImage({ - src: event.detail.file.path, - quality: 25, - success: function (res) { - convertpath = res.tempFilePath; - wx.uploadFile({ - url: app.globalData.httpsUrl + "appDeviceAdd/fileUploadMarker", - filePath:convertpath, - name: 'file', - formData: { - 'text': "编号:" + _this.data.form.devcode + "经度:" + _this.data.form.longitude + "纬度:" + _this.data.form.latitude - }, - header: { - "Content-Type": "multipart/form-data", - 'accept': 'application/json', - }, - success(res) { - if (res.data) { - var url = JSON.parse(res.data); - fileList.push({ - ...file, - url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - }); - _this.setData({ - fileList - }); - } - } + success(res) { + if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + if (res.confirm) { + wx.switchTab({ + url: that.data.pageName }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') } - }) - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // // var base64 = "data:image/png;base64," + wx.getFileSystemManager().readFileSync(convertpath, 'base64'); - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: convertpath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // // wx.cloud.callFunction({ - // // name: 'uploadFile', - // // data: { - // // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // // fileBase64: base64 - // // }, - // // success: function (res) { - // // if (res.result) { - // // fileList.push({ - // // ...file, - // // url: app.globalData.url + "static/" + res.result.data.replace(/\\/g, "/") - // // }); - // // _this.setData({ - // // fileList - // // }); - // // } - // // }, - // // complete: res => { - // // }, - // // }) - // } - // }); + } + }) + } + }, + fail(err) { + wx.showToast({ + title: "提交失败", + }) + } + }) + }, + //报存录入的input信息 + confirm(event) { + var that = this; + var formValue = event.detail.value; + var formName = event.target.dataset.id; + var fromN = 'form.' + [formName]; + that.setData({ + [fromN]: formValue + }) + }, + + //扫码 + scan() { + + wx.scanCode({ + success(res) { + console.log(res) + } + }) + }, + //粘贴经纬度 + paste() { + var _this = this; + wx.getClipboardData({ + success: function (res) { + var longitude = 'form.longitude'; + var latitude = 'form.latitude'; + var longitude84 = 'form.longitude84'; + var latitude84 = 'form.latitude84'; + _this.setData({ + [longitude]: parseFloat(res.data.split(",", 4)[1]).toFixed(6), + [latitude]: parseFloat(res.data.split(",", 4)[0]).toFixed(6), + [longitude84]: "" == (res.data.split(",", 4)[3]) ? "" : parseFloat(res.data.split(",", 4)[3]).toFixed(6), + [latitude84]: "" == (res.data.split(",", 4)[2]) ? "" : parseFloat(res.data.split(",", 4)[2]).toFixed(6), + longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), + latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), + }); + } + }) + }, + selectValue(value) { + var that = this; + var wellType = 'form.welltype'; + that.setData({ + [wellType]: value.detail + }) + }, + //运维人员默认为登录人 + // selectpersonValue(event) { + // var that = this; + // var installPerson = 'form.installperson'; + // that.setData({ + // [installPerson]: event.detail + // }) + // }, + selectprojectValue(event) { + var that = this; + var project = 'form.project'; + that.setData({ + [project]: event.detail, + showMask: true + }) + }, + + open() { + this.setData({ + showMask: true + }) + }, + //隐藏textarea,防止遮挡 + close() { + this.setData({ + showMask: false + }) + }, + //上传照片 + afterRead(event) { + var _this = this; + const { + file + } = event.detail; + const { + fileList = [] + } = _this.data; + var convertpath = ""; + wx.compressImage({ + src: event.detail.file.path, + quality: 25, + success: function (res) { + convertpath = res.tempFilePath; + wx.uploadFile({ + url: app.globalData.httpsUrl + "appDeviceAdd/fileUploadMarker", + filePath: convertpath, + name: 'file', + formData: { + 'text': "编号:" + _this.data.form.devcode + "经度:" + _this.data.form.longitude + "纬度:" + _this.data.form.latitude }, - deletePhoto(event) { - var that = this - var image_index = event.detail.index - var fileList_new = that.data.fileList; - wx.showModal({ - content: '确定删除照片?', - success: function (res) { - if (res.confirm) { - fileList_new.splice(image_index, 1); - that.setData({ - fileList: fileList_new - }) - wx.cloud.callFunction({ - name: 'deletePhoto', - data: { - url: app.globalData.url + "appDeviceLog/deletePhoto", - devcode: that.data.form.devcode, - pathIndex: image_index - }, - success: function (res) {}, - complete: res => {}, - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + "Content-Type": "multipart/form-data", + 'accept': 'application/json', }, - }) \ No newline at end of file + success(res) { + if (res.data) { + var url = JSON.parse(res.data); + fileList.push({ + ...file, + url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") + }); + _this.setData({ + fileList + }); + } + } + }) + } + }) + }, + //删除照片 + deletePhoto(event) { + var that = this + var image_index = event.detail.index + var fileList_new = that.data.fileList; + wx.showModal({ + content: '确定删除照片?', + success: function (res) { + if (res.confirm) { + fileList_new.splice(image_index, 1); + that.setData({ + fileList: fileList_new + }) + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deletePhoto", + data: { + devcode: that.data.form.devcode + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) {} + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } +}) \ No newline at end of file diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.wxml b/miniprogram/pages/addDevicelog/addDeviceLog.wxml index 38620d4..b10cc7d 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.wxml +++ b/miniprogram/pages/addDevicelog/addDeviceLog.wxml @@ -1,15 +1,21 @@ - + + + + + - + - - + + - - + + - + @@ -39,24 +45,25 @@ - - - + + + - + - + + @@ -64,7 +71,7 @@ - + @@ -79,9 +86,9 @@ - + - 保存 + 保存 diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.wxss b/miniprogram/pages/addDevicelog/addDeviceLog.wxss index ee0b75c..08d5fd7 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.wxss +++ b/miniprogram/pages/addDevicelog/addDeviceLog.wxss @@ -24,6 +24,17 @@ display: flex; align-items: center; } +.map-view{ + width: 750rpx; + height: 485rpx; + position: fixed; + top: 0px; + left: 0px; + z-index: 999; +} +.content{ + margin-top: 495rpx; +} .left { width: 210rpx; diff --git a/cloudfunctions/project.config.json b/cloudfunctions/project.config.json new file mode 100644 index 0000000..2b3119a --- /dev/null +++ b/cloudfunctions/project.config.json @@ -0,0 +1,28 @@ +{ + "appid": "wx2cef527a000f87c9", + "compileType": "miniprogram", + "libVersion": "2.27.3", + "packOptions": { + "ignore": [], + "include": [] + }, + "setting": { + "coverView": true, + "es6": true, + "postcss": true, + "minified": true, + "enhance": true, + "showShadowRootInWxmlPanel": true, + "packNpmRelationList": [], + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + } + }, + "condition": {}, + "editorSetting": { + "tabIndent": "insertSpaces", + "tabSize": 4 + } +} \ No newline at end of file diff --git a/cloudfunctions/project.private.config.json b/cloudfunctions/project.private.config.json new file mode 100644 index 0000000..42ff49d --- /dev/null +++ b/cloudfunctions/project.private.config.json @@ -0,0 +1,7 @@ +{ + "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", + "projectname": "cloudfunctions", + "setting": { + "compileHotReLoad": true + } +} \ No newline at end of file diff --git a/miniprogram/app.js b/miniprogram/app.js index 51d56f3..50a8a54 100644 --- a/miniprogram/app.js +++ b/miniprogram/app.js @@ -18,13 +18,15 @@ // this.globalData = {} }, globalData: { - // url: "http://111.198.10.15:11604/", - httpsUrl: "https://logapi.smartlog.work/", - httpsTestUrl: "https://smartlog.work/prodapi4test/", - url: "http://139.198.18.188:8083/", + httpsUrl: "https://logapi.smartlog.work/", + // httpsUrl: "http://139.198.18.188:8083/", // url: "http://127.0.0.1:8083/", - // httpsUrl: "http://127.0.0.1:8083/", + //httpsUrl: "http://127.0.0.1:8083/", openid: null, - indexCount:1 - }, + indexCount:1, + nickName:"", + userName:"", + role:"", + devcode:"" + } }) diff --git a/miniprogram/app.json b/miniprogram/app.json index d23f798..2b6db76 100644 --- a/miniprogram/app.json +++ b/miniprogram/app.json @@ -1,15 +1,17 @@ { "cloud": true, "pages": [ + "pages/login/login", "pages/indexapp/indexapp", "pages/earth/earth", "pages/applog/applog", "pages/addDevice/addDevice", "pages/addDevicelog/addDeviceLog", - "pages/searchLog/searchLog" + "pages/searchLog/searchLog", + "pages/notice/notice" ], "window": { - "backgroundColor": "#F6F6F6", + "backgroundColor": "#E6D480", "backgroundTextStyle": "light", "navigationBarBackgroundColor": "#FFCF00", "navigationBarTitleText": "智慧施工", @@ -46,11 +48,11 @@ "desc": "你的位置信息将用于小程序位置接口的效果展示" } }, + "requiredPrivateInfos": ["getLocation", "chooseLocation"], "networkTimeout": { "request": 30000, "connectSocket": 30000, "uploadFile": 30000, "downloadFile": 30000 - }, - "style": "v2" + } } \ No newline at end of file diff --git a/miniprogram/images/applocat.png b/miniprogram/images/applocat.png new file mode 100644 index 0000000..fe49f54 --- /dev/null +++ b/miniprogram/images/applocat.png Binary files differ diff --git a/miniprogram/images/back.png b/miniprogram/images/back.png new file mode 100644 index 0000000..32ac82d --- /dev/null +++ b/miniprogram/images/back.png Binary files differ diff --git a/miniprogram/images/bottom.png b/miniprogram/images/bottom.png new file mode 100644 index 0000000..d910e98 --- /dev/null +++ b/miniprogram/images/bottom.png Binary files differ diff --git a/miniprogram/images/header.png b/miniprogram/images/header.png new file mode 100644 index 0000000..6ea222e --- /dev/null +++ b/miniprogram/images/header.png Binary files differ diff --git a/miniprogram/images/login.png b/miniprogram/images/login.png index 8b73cc0..6471c46 100644 --- a/miniprogram/images/login.png +++ b/miniprogram/images/login.png Binary files differ diff --git a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss index 5a591fb..c9c35b5 100644 --- a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss +++ b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:100%;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:100%}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file +@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:650rpx;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:600rpx}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file diff --git a/miniprogram/pages/addDevice/addDevice.js b/miniprogram/pages/addDevice/addDevice.js index 2783674..78f00b7 100644 --- a/miniprogram/pages/addDevice/addDevice.js +++ b/miniprogram/pages/addDevice/addDevice.js @@ -1,5 +1,7 @@ // miniprogram/pages/addDevice/addDevice.js // import WxValidate from '../../utils/WxValidate.js' +var QQMapWX = require('../../libs/qqmap-wx-jssdk.js'); +var qqmapsdk; var app = getApp() Page({ @@ -11,32 +13,10 @@ canvasWidth: '', longitude: '', latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], + option1: [], personoption1: [], projectoption: [], + devtypeList:[], show: false, form: { devcode: "", @@ -59,7 +39,10 @@ project: "", area: "", street: "", - wellname: "" + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '', }, fileList: [] }, @@ -117,12 +100,14 @@ var that = this; //初始化表单内容为上次填写值 var cacheForms = wx.getStorageSync('cacheList') - if (cacheForms) { + cacheForms.photopath1='' + cacheForms.photopath2='' + cacheForms.photopath3='' + that.data.fileList=[] that.setData({ form: cacheForms, devcode: cacheForms.devcode, - }) } var form = that.data.form @@ -155,55 +140,89 @@ } }) + +//获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + that.setData({ + option1: welltypeArr + }) + } + } +}) + + //获取人员下拉列表 - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/getUser", + data:{ + tips:'repair' }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data.code == 200) { + var users = res.data.data + var personArr = []; + for (var i = 0; i < users.length; i++) { + var person = { + text: users[i].name, + value: users[i].name + }; + personArr.push(person); + } + that.setData({ + personoption1: personArr + }) } - that.setData({ - personoption1: personArr - }) } - }).catch(err => { - console.error(err); - }) + }) + - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - that.setData({ - projectoption: projectArr - }) + success(res){ + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); + } + that.setData({ + projectoption: projectArr + }) + } } - }).catch(err => { - console.error(err); - }) + }) + var installtime = 'form.installtimeFmt'; var dateNow = this.formatDate(); this.setData({ @@ -211,8 +230,40 @@ installtimeFmt: dateNow, [installtime]: dateNow, }); + + + + /** + * 获取设备类型下拉列表 + */ + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/deviceType", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var TypeList = res.data.data + var typeArr = []; + for (var i = 0; i < TypeList.length; i++) { + var type = { + text: TypeList[i].productName, + value: TypeList[i].productName + }; + typeArr.push(type); + } + that.setData({ + devtypeList: typeArr + }) + } + } + }) }, + + + /** * 生命周期函数--监听页面初次渲染完成 */ @@ -280,29 +331,7 @@ }, - - //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 - drawText: function (ctx, str, leftWidth, initHeight, titleHeight, canvasWidth) { - var lineWidth = 0; - var lastSubStrIndex = 0; //每次开始截取的字符串的索引 - for (let i = 0; i < str.length; i++) { - lineWidth += ctx.measureText(str[i]).width; - if (lineWidth > canvasWidth) { - ctx.fillText(str.substring(lastSubStrIndex, i), leftWidth, initHeight); //绘制截取部分 - initHeight = initHeight + leftWidth * 2; //22为字体的高度 - lineWidth = 0; - lastSubStrIndex = i; - // titleHeight += 40; - } - if (i == str.length - 1) { //绘制剩余部分 - ctx.fillText(str.substring(lastSubStrIndex, i + 1), leftWidth, initHeight); - } - } - // // 标题border-bottom 线距顶部距离 - // titleHeight = titleHeight + 10; - // return titleHeight - }, - + //验证表单 formValidate() { if (this.data.form.devcode == "") { @@ -312,27 +341,20 @@ }) return false } - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } if (this.data.form.wellcode == "") { wx.showToast({ icon: 'none', @@ -348,22 +370,10 @@ }) return false } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null) { + + if (this.data.form.installperson == "") { wx.showToast({ icon: 'none', title: '安装人员不能为空!', @@ -408,56 +418,90 @@ } return true; }, + //提交表单 formSubmit: function (event) { + console.log(this.data.form) + //表单参数验证 if (!this.formValidate()) { return false; } var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDevice', + //验证设备编号长度 + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/getDevTypeLength", data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceAdd/add" + code: encodeURI(this.data.form.devicetype) }, - }).then(res => { - if (res.result.code == 500) { - wx.showToast({ - title: '设备编号已安装!', - }) - } else if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - //用于回显 - wx.setStorageSync('cacheList', that.data.form) - //提交成功后提示用户操作 - if (res.confirm) { - wx.switchTab({ - url: '../earth/earth' - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (""==res.data.data ||res.data.data == that.data.form.devcode.length) { + that.saveDevice() + } else { //编号位数不对提示 + wx.showToast({ + icon: 'none', + title: '设备编号位数不对!', + duration: 1000 + }) + return false + } } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "提交失败", - }) }) }, + + //保存设备基本信息 + saveDevice() { + var that = this; + //设置照片路径 + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopathForm = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopathForm]: fileList[i].url.split("static/")[1] + }) + } + //表单提交 + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 500) { + wx.showToast({ + title: '设备编号已安装!', + }) + } else if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + //用于回显 + wx.setStorageSync('cacheList', that.data.form) + //提交成功后提示用户操作 + if (res.confirm) { + wx.switchTab({ + url: '../earth/earth' + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } + }, + fail(err) { + wx.showToast({ + title: '提交失败!', + }) + } + }) + }, + + //input 输入框设置值 confirm(event) { var that = this; var formValue = event.detail.value; @@ -466,8 +510,30 @@ that.setData({ [fromN]: formValue }) + //若输入是设备编号,自动获取设备类型 + if('devcode'==formName){ + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", + data: { + devcode: formValue, + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + that.setData({ + [formDevicetype]: res.data + }); + } + } + }) + } }, + //扫描设备获取编号和设备类型 scan() { var _this = this; wx.scanCode({ @@ -477,23 +543,28 @@ _this.setData({ [formdevcode]: devcode }); - wx.cloud.callFunction({ - name: 'findModeCode', + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", data: { devcode: devcode, - url: app.globalData.url + "appDeviceAdd/findModeCodeByCode" }, - }).then(res => { - if (res.result) { - var formDevicetype = 'form.devicetype' - _this.setData({ - [formDevicetype]: res.result - }); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + _this.setData({ + [formDevicetype]: res.data + }); + } } }) } }) }, + //粘贴经纬度 paste() { var _this = this; wx.getClipboardData({ @@ -510,9 +581,11 @@ longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), }); + _this.showAddress(_this.data.form.longitude,_this.data.form.latitude,_this) } }) }, + //设置经类型 selectValue(value) { var that = this; @@ -521,6 +594,16 @@ [wellType]: value.detail }) }, + + //设置设备类型 + selectDevType(event) { + var that = this; + var devtype = 'form.devicetype'; + that.setData({ + [devtype]: event.detail + }) + }, + //设置运维人员 selectpersonValue(event) { var that = this; var installPerson = 'form.installperson'; @@ -528,6 +611,7 @@ [installPerson]: event.detail }) }, + //设置项目 selectprojectValue(event) { var that = this; var project = 'form.project'; @@ -535,8 +619,41 @@ [project]: event.detail }) }, + showAddress :function(longitude, latitude, self) { + // 实例化腾讯地图API核心类 + qqmapsdk = new QQMapWX({ + key: 'BGPBZ-C5O3P-ROUDR-LWC4J-63EKH-V5FRX'//此处使用你自己申请的key + }) + // 腾讯地图调用接口 + qqmapsdk.reverseGeocoder({ + location: { + latitude: latitude, + longitude: longitude + }, + success: function (res) { + self.setData({ + 'form.area':res.result.address.slice(0,res.result.address.indexOf('区')+1), + 'form.street':res.result.address.slice(res.result.address.indexOf('区')+1) + }) + }, + fail: function (res) { + console.log(res); + }, + complete: function (res) { + } + }); + }, + //上传照片 afterRead(event) { var _this = this; + if (_this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '请先填写设备编号!\r\n否则水印中无编号', + duration: 2000 + }) + return false + } const { file } = event.detail; @@ -576,78 +693,8 @@ }) } }) - // 压缩图片 - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // //获取图片尺寸 - // wx.getImageInfo({ - // src: convertpath, - // success(res) { - // _this.setData({ - // canvasHeight: res.height, - // canvasWidth: res.width - // }) - // var ctx = wx.createCanvasContext('firstCanvas') - - // //将图片src放到cancas内,宽高为图片大小 - // ctx.drawImage(convertpath, 0, 0, res.width, res.height) - // //将声明的时间放入canvas - // ctx.setFontSize(30 * (res.width / 750)) //注意:设置文字大小必须放在填充文字之前,否则不生效 - // ctx.setFillStyle('blue') - // var text = "编号:" + _this.data.form.devcode + "\n经度:" + _this.data.form.longitude + "\n纬度:" + _this.data.form.latitude - // // _this.drawText(ctx,text,20, 70, 5, res.width) - // _this.drawText(ctx, text, 15 * (res.width / 750), 70 * (res.width / 750), 5, res.width) - - // // ctx.fillText(text, 0, 40) - // // ctx.strokeText(_this.data.form.devcode, 0, 30) - // //生成水印图 - // ctx.draw(false, function () { - // wx.canvasToTempFilePath({ - // canvasId: 'firstCanvas', - // success: (res) => { - // wx.compressImage({ - // src: res.tempFilePath, - // quality: 25, - // success: function (res) { - // //上传照片至服务器 - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: res.tempFilePath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // } - // }) - // //// - // } - // }) - // }) - // } - // }) - // } - // }); }, + //删除照片 deletePhoto(event) { var image_index = event.detail.index var fileList_new = this.data.fileList; diff --git a/miniprogram/pages/addDevice/addDevice.wxml b/miniprogram/pages/addDevice/addDevice.wxml index b0977e2..f12c254 100644 --- a/miniprogram/pages/addDevice/addDevice.wxml +++ b/miniprogram/pages/addDevice/addDevice.wxml @@ -5,18 +5,30 @@ - + + + + + + + + + + + + + - - + + - - - + + + @@ -29,13 +41,13 @@ - + - + - + - + @@ -54,8 +66,7 @@ - - + @@ -68,8 +79,8 @@ - - + + - 保存 + 保存 \ No newline at end of file diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.js b/miniprogram/pages/addDevicelog/addDeviceLog.js index cdec71b..a0dc6da 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.js +++ b/miniprogram/pages/addDevicelog/addDeviceLog.js @@ -3,681 +3,665 @@ var app = getApp(); Page({ - /** - * 页面的初始数据 - */ - data: { - pageName: '', - showMask: false, - today: new Date().getTime(), - longitude: '', - latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], - personoption1: [], - projectoption: [], - devcode: "", - deviceMode: "", - installtimeFmt: '', - show: false, - form: { - devcode: "", - wellcode: "", - welltype: "", - welldepth: "", - installheigt: "", - installperson: "", - installtimeFmt: "", - photopath: "", - factory: "", - workmsg: "", - position: "", - description: "", - longitude: "", - latitude: "", - longitude84: "", - latitude84: "", - devicetype: "", - project: "", - area: "", - street: "", - wellname: "" - }, - fileList: [], - detail: "" - }, + /** + * 页面的初始数据 + */ + data: { + pageName: '', + showMask: false, + today: new Date().getTime(), + longitude: '', + latitude: '', + option1: [], + personoption1: [], + projectoption: [], + devcode: "", + deviceMode: "", + installtimeFmt: '', + show: false, + form: { + devcode: "", + wellcode: "", + welltype: "", + welldepth: "", + installheigt: "", + installperson: "", + installtimeFmt: "", + photopath: "", + factory: "", + workmsg: "", + position: "", + description: "", + longitude: "", + latitude: "", + longitude84: "", + latitude84: "", + devicetype: "", + project: "", + area: "", + street: "", + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '' + }, + fileList: [], + detail: "", + markers: [{ + id: 100, + // iconPath: "../../images/point.png", + latitude: '', + longitude: '', + // label:'1', + width: 25, + height: 35 + }], + }, - onDisplay() { - this.setData({ - show: true - }); - }, - onClose() { - this.setData({ - show: false - }); - }, - formatDate() { - var date = new Date(); - // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; - var seperator1 = "-"; - var month = date.getMonth() + 1; - var strDate = date.getDate(); - var hour = date.getHours() - var minute = date.getMinutes() - var second = date.getSeconds() - month = month > 9 ? month : "0" + month; - strDate = strDate > 9 ? strDate : "0" + strDate; - hour = hour > 9 ? hour : "0" + hour; - minute = minute > 9 ? minute : "0" + minute; - second = second > 9 ? second : "0" + second; - var currentdate = - date.getFullYear() + - seperator1 + - month + - seperator1 + - strDate + - " " + - hour + ":" + - minute + ":" + - second; - return currentdate; + onDisplay() { + this.setData({ + show: true + }); + }, + onClose() { + this.setData({ + show: false + }); + }, + formatDate() { + var date = new Date(); + // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; + var seperator1 = "-"; + var month = date.getMonth() + 1; + var strDate = date.getDate(); + var hour = date.getHours() + var minute = date.getMinutes() + var second = date.getSeconds() + month = month > 9 ? month : "0" + month; + strDate = strDate > 9 ? strDate : "0" + strDate; + hour = hour > 9 ? hour : "0" + hour; + minute = minute > 9 ? minute : "0" + minute; + second = second > 9 ? second : "0" + second; + var currentdate = + date.getFullYear() + + seperator1 + + month + + seperator1 + + strDate + + " " + + hour + ":" + + minute + ":" + + second; + return currentdate; - }, - onConfirm(event) { - var installtime = 'form.installtimeFmt'; - this.setData({ - show: false, - installtimeFmt: this.formatDate(event.detail), - [installtime]: this.formatDate(event.detail), - }); - }, + }, + onConfirm(event) { + var installtime = 'form.installtimeFmt'; + this.setData({ + show: false, + installtimeFmt: this.formatDate(event.detail), + [installtime]: this.formatDate(event.detail), + }); + }, - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - var _this = this; - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" - }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); - } - _this.setData({ - personoption1: personArr - }) + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + var _this = this; + _this.setData({ + 'markers[0].latitude': Number(wx.getStorageSync('resultObject').latitude) , + 'markers[0].longitude': Number(wx.getStorageSync('resultObject').longitude), + // 'markers[0].label':'10', + 'markers[0].width': 18, + 'markers[0].id':1, + 'markers[0].height': 30, + latitude:Number(wx.getStorageSync('resultObject').latitude), + longitude:Number(wx.getStorageSync('resultObject').longitude) + }) + //获取人员下拉列表 + // wx.request({ + // method: "POST", + // url: app.globalData.httpsUrl + "deviceType/getUser", + // data:{ + // tips:'repair' + // }, + // header: { + // 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + // }, + // success(res) { + // if (res.data.code == 200) { + // var users = res.data.data + // var personArr = []; + // for (var i = 0; i < users.length; i++) { + // var person = { + // text: users[i].name, + // value: users[i].name + // }; + // personArr.push(person); + // } + // _this.setData({ + // personoption1: personArr + // }) + // } + // } + // }) + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); } - }).catch(err => { - console.error(err); - }) - - - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" - }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - _this.setData({ - projectoption: projectArr - }) - } - }).catch(err => { - console.error(err); - }) - - if (options.pageName) { - this.setData({ - pageName: options.pageName - }) - } - - if (options.detail) { - - var formObject = JSON.parse(options.detail); _this.setData({ - form: formObject, - detail: options.detail + projectoption: projectArr }) - - _this.setData({ - ['form.installperson']: "", - ['form.installtimeFmt']: "", - ['form.workmsg']: "", - ['form.description']: "" - }) - - const { - fileList = [] - } = _this.data; - if (formObject.photopath1 != "") { - var file1 = { - url: app.globalData.url + "static/" + formObject.photopath1 - } - fileList.push(file1) - } - if (formObject.photopath2 != "") { - var file2 = { - url: app.globalData.url + "static/" + formObject.photopath2 - } - fileList.push(file2) - } - if (formObject.photopath3 != "") { - var file3 = { - url: app.globalData.url + "static/" + formObject.photopath3 - } - fileList.push(file3) - } - - _this.setData({ - fileList - }); } - var installtime = 'form.installtimeFmt'; - var dateNow = this.formatDate(); - this.setData({ - installtimeFmt: dateNow, - [installtime]: dateNow, - }); - }, + } + }) - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { + //获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + _this.setData({ + option1: welltypeArr + }) + } + } +}) - }, + //跳转时带入参数返回哪页 + if (options.pageName) { + this.setData({ + pageName: options.pageName + }) + } + //跳转时带入参数设备的安装信息 + if (wx.getStorageSync('resultObject')) { + var formObject = wx.getStorageSync('resultObject') + _this.setData({ + form: formObject, + detail: formObject + }) - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { + _this.setData({ + ['form.installperson']: app.globalData.userName, + ['form.installtimeFmt']: "", + ['form.workmsg']: "", + ['form.description']: "" + }) - }, + const { + fileList = [] + } = _this.data; + if (formObject.photopath1 != "") { + var file1 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath1 + } + fileList.push(file1) + } + if (formObject.photopath2 != "") { + var file2 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath2 + } + fileList.push(file2) + } + if (formObject.photopath3 != "") { + var file3 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath3 + } + fileList.push(file3) + } + _this.setData({ + fileList + }); + } + var installtime = 'form.installtimeFmt'; + var dateNow = this.formatDate(); + this.setData({ + installtimeFmt: dateNow, + [installtime]: dateNow, + }); + }, - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, - }, + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + wx.removeStorageSync('resultObject') + }, - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, - }, + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { + }, - }, + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { + }, - }, + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { + }, - }, + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + }, - /** - * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true - **/ + /** + * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true + **/ - isNumber: function (val) { + isNumber: function (val) { - var regPos = /^[0-9]*$/; //非负浮点数 - var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数 - if (regPos.test(val) || regNeg.test(val)) { - return false; - } else { - return true; - } + var regPos = /^[0-9]*$/; //非负浮点数 + var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数 + if (regPos.test(val) || regNeg.test(val)) { + return false; + } else { + return true; + } - }, + }, - formValidate() { + formValidate() { - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } - if (this.data.form.wellcode == "") { - wx.showToast({ - icon: 'none', - title: '井编号不能为空!', - }) - return false - } - if (this.data.form.devicetype == "") { - wx.showToast({ - icon: 'none', - title: '设备类型不能为空!', - }) - return false - } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + if (this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '设备编号不能为空!', + }) + return false + } + if (this.data.form.wellcode == "") { + wx.showToast({ + icon: 'none', + title: '井编号不能为空!', + }) + return false + } + if (this.data.form.devicetype == "") { + wx.showToast({ + icon: 'none', + title: '设备类型不能为空!', + }) + return false + } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null || - this.data.form.installperson == '') { - wx.showToast({ - icon: 'none', - title: '运维人员不能为空!', - }) - return false - } - if (this.data.form.project == "") { - wx.showToast({ - icon: 'none', - title: '所属项目不能为空!', - }) - return false - } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } + if (this.data.form.installperson == null || + this.data.form.installperson == '') { + wx.showToast({ + icon: 'none', + title: '运维人员不能为空!', + }) + return false + } + if (this.data.form.project == "") { + wx.showToast({ + icon: 'none', + title: '所属项目不能为空!', + }) + return false + } - if (this.data.form.welldepth != null) { - if (this.isNumber(this.data.form.welldepth)) { - wx.showToast({ - icon: 'none', - title: '井深必须为数值!', - }) - return false - } - } - if (this.data.form.installheigt != null) { - if (this.isNumber(this.data.form.installheigt)) { - wx.showToast({ - icon: 'none', - title: '到井口距离必须为数值!', - }) - return false - } - } - - return true; - }, - - changeMsg: function () { - var formNew = this.data.form; - var formOld = JSON.parse(this.data.detail); - var descpNew = ""; - if (formNew.devcode != formOld.devcode) { - descpNew += "修改设备编号,原编号:" + formOld.devcode + ",新编号:" + formNew.devcode + ";" - } - if (formNew.devicetype != formOld.devicetype) { - descpNew += "修改设备类型,原设备类型:" + formOld.devicetype + ",新设备类型:" + formNew.devicetype + ";" - } - if (formNew.area != formOld.area) { - descpNew += "修改区,原区:" + formOld.area + ",新区:" + formNew.area + ";" - } - if (formNew.street != formOld.street) { - descpNew += "修改街道,原街道:" + formOld.street + ",新街道:" + formNew.street + ";" - } - if (formNew.wellname != formOld.wellname) { - descpNew += "修改井名称,原井名称:" + formOld.wellname + ",新井名称:" + formNew.wellname + ";" - } - if (formNew.factory != formOld.factory) { - descpNew += "修改权属单位,原权属单位:" + formOld.factory + ",新权属单位:" + formNew.factory + ";" - } - if (formNew.installheigt != formOld.installheigt) { - descpNew += "修改井口距离,原井口距离:" + formOld.installheigt + ",新井口距离:" + formNew.installheigt + ";" - } - if (formNew.installperson != formOld.installperson) { - descpNew += "修改运维人员,原运维人员:" + formOld.installperson + ",新运维人员:" + formNew.installperson + ";" - } - if (formNew.latitude != formOld.latitude) { - descpNew += "修改纬度,原纬度:" + formOld.latitude + ",新纬度:" + formNew.latitude + ";" - } - if (formNew.longitude != formOld.longitude) { - descpNew += "修改经度,原经度:" + formOld.longitude + ",新经度:" + formNew.longitude + ";" - } - if (formNew.position != formOld.position) { - descpNew += "修改位置描述,原位置:" + formOld.position + ",新位置:" + formNew.position + ";" - } - if (formNew.wellcode != formOld.wellcode) { - descpNew += "修改井编号,原编号:" + formOld.wellcode + ",新编号:" + formNew.wellcode + ";" - } - if (formNew.welldepth != formOld.welldepth) { - descpNew += "修改井深,原井深:" + formOld.welldepth + ",新井深:" + formNew.welldepth + ";" - } - if (formNew.welltype != formOld.welltype) { - descpNew += "修改井类型,原井类型:" + formOld.welltype + ",新井类型:" + formNew.welltype + ";" - } - if (formNew.project != formOld.project) { - descpNew += "修改所属项目,原项目:" + formOld.project + ",新项目:" + formNew.project + ";" - } - if (this.data.photopath1 != formOld.photopath1 || - this.data.photopath2 != formOld.photopath2 || - this.data.photopath3 != formOld.photopath3) { - descpNew += "修改照片;" - } - if ("" != formNew.description) { - descpNew += formNew.description; - } - this.setData({ - ['form.description']: descpNew + if (this.data.form.welldepth != null) { + if (this.isNumber(this.data.form.welldepth)) { + wx.showToast({ + icon: 'none', + title: '井深必须为数值!', }) - }, + return false + } + } + if (this.data.form.installheigt != null) { + if (this.isNumber(this.data.form.installheigt)) { + wx.showToast({ + icon: 'none', + title: '到井口距离必须为数值!', + }) + return false + } + } - formSubmit: function (event) { + return true; + }, - if (!this.formValidate()) { - return false; - } - this.changeMsg(); - var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDeviceLog', - data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceLog/add" - }, - }).then(res => { - // var resultObj=JSON.parse(res.result); - if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - if (res.confirm) { - wx.switchTab({ - url: that.data.pageName - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) - } - }).catch(err => { - console.error(err) - wx.showToast({ - title: "提交失败", - }) - }) - }, - confirm(event) { - var that = this; - var formValue = event.detail.value; - var formName = event.target.dataset.id; - var fromN = 'form.' + [formName]; - that.setData({ - [fromN]: formValue - }) - }, + //获取与上次修改的信息 + changeMsg: function () { + var formNew = this.data.form; + console.log(this.data.detail) + var formOld = JSON.parse(this.data.detail); + var descpNew = ""; + if (formNew.devcode != formOld.devcode) { + descpNew += "修改设备编号,原值:" + formOld.devcode + ",新值:" + formNew.devcode + ";" + } + if (formNew.devicetype != formOld.devicetype) { + descpNew += "修改设备类型,原值:" + formOld.devicetype + ",新值:" + formNew.devicetype + ";" + } + if (formNew.area != formOld.area) { + descpNew += "修改区,原值:" + formOld.area + ",新值:" + formNew.area + ";" + } + if (formNew.street != formOld.street) { + descpNew += "修改街道,原值:" + formOld.street + ",新值:" + formNew.street + ";" + } + if (formNew.wellname != formOld.wellname) { + descpNew += "修改井名称,原值:" + formOld.wellname + ",新值:" + formNew.wellname + ";" + } + if (formNew.factory != formOld.factory) { + descpNew += "修改权属单位,原值:" + formOld.factory + ",新值:" + formNew.factory + ";" + } + if (formNew.installheigt != formOld.installheigt) { + descpNew += "修改井口距离,原值:" + formOld.installheigt + ",新值:" + formNew.installheigt + ";" + } + if (formNew.installperson != formOld.installperson) { + descpNew += "修改运维人员,原值:" + formOld.installperson + ",新值:" + formNew.installperson + ";" + } + if (formNew.latitude != formOld.latitude) { + descpNew += "修改纬度,原值:" + formOld.latitude + ",新值:" + formNew.latitude + ";" + } + if (formNew.longitude != formOld.longitude) { + descpNew += "修改经度,原值:" + formOld.longitude + ",新值:" + formNew.longitude + ";" + } + if (formNew.position != formOld.position) { + descpNew += "修改位置描述,原值:" + formOld.position + ",新值:" + formNew.position + ";" + } + if (formNew.wellcode != formOld.wellcode) { + descpNew += "修改井编号,原值:" + formOld.wellcode + ",新值:" + formNew.wellcode + ";" + } + if (formNew.welldepth != formOld.welldepth) { + descpNew += "修改井深,原值:" + formOld.welldepth + ",新值:" + formNew.welldepth + ";" + } + if (formNew.welltype != formOld.welltype) { + descpNew += "修改井类型,原值:" + formOld.welltype + ",新值:" + formNew.welltype + ";" + } + if (formNew.project != formOld.project) { + descpNew += "修改所属项目,原值:" + formOld.project + ",新值:" + formNew.project + ";" + } + if (this.data.form.photopath1 != formOld.photopath1 || + this.data.form.photopath2 != formOld.photopath2 || + this.data.form.photopath3 != formOld.photopath3) { + descpNew += "修改照片;" + } + if ("" != formNew.description) { + descpNew += formNew.description; + } + this.setData({ + ['form.description']: descpNew + }) + }, - scan() { + //提交表单 + formSubmit: function (event) { - wx.scanCode({ - success(res) { - console.log(res) - } - }) + //表单验证 + if (!this.formValidate()) { + return false; + } + //自动生成修改内容 + this.changeMsg(); + //提交权限限制(只有施工人员能修改) + if(app.globalData.role!='repair'){ + wx.showToast({ + icon: 'none', + title: '无权限修改', + duration:2000 + }) + return false + } + var that = this; + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopath = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopath]: fileList[i].url.split("static/")[1] + }) + } + delete that.data.form.installtime + delete that.data.form.createtime + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - paste() { - var _this = this; - wx.getClipboardData({ - success: function (res) { - var longitude = 'form.longitude'; - var latitude = 'form.latitude'; - var longitude84 = 'form.longitude84'; - var latitude84 = 'form.latitude84'; - _this.setData({ - [longitude]: parseFloat(res.data.split(",", 4)[1]).toFixed(6), - [latitude]: parseFloat(res.data.split(",", 4)[0]).toFixed(6), - [longitude84]: "" == (res.data.split(",", 4)[3]) ? "" : parseFloat(res.data.split(",", 4)[3]).toFixed(6), - [latitude84]: "" == (res.data.split(",", 4)[2]) ? "" : parseFloat(res.data.split(",", 4)[2]).toFixed(6), - longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), - latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), - }); - } - }) - }, - selectValue(value) { - var that = this; - var wellType = 'form.welltype'; - that.setData({ - [wellType]: value.detail - }) - }, - selectpersonValue(event) { - var that = this; - var installPerson = 'form.installperson'; - that.setData({ - [installPerson]: event.detail - }) - }, - selectprojectValue(event) { - var that = this; - var project = 'form.project'; - that.setData({ - [project]: event.detail, - showMask: true - }) - }, - open() { - this.setData({ - showMask: true - }) - }, - close() { - this.setData({ - showMask: false - }) - }, - afterRead(event) { - var _this = this; - const { - file - } = event.detail; - const { - fileList = [] - } = _this.data; - var convertpath = ""; - wx.compressImage({ - src: event.detail.file.path, - quality: 25, - success: function (res) { - convertpath = res.tempFilePath; - wx.uploadFile({ - url: app.globalData.httpsUrl + "appDeviceAdd/fileUploadMarker", - filePath:convertpath, - name: 'file', - formData: { - 'text': "编号:" + _this.data.form.devcode + "经度:" + _this.data.form.longitude + "纬度:" + _this.data.form.latitude - }, - header: { - "Content-Type": "multipart/form-data", - 'accept': 'application/json', - }, - success(res) { - if (res.data) { - var url = JSON.parse(res.data); - fileList.push({ - ...file, - url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - }); - _this.setData({ - fileList - }); - } - } + success(res) { + if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + if (res.confirm) { + wx.switchTab({ + url: that.data.pageName }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') } - }) - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // // var base64 = "data:image/png;base64," + wx.getFileSystemManager().readFileSync(convertpath, 'base64'); - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: convertpath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // // wx.cloud.callFunction({ - // // name: 'uploadFile', - // // data: { - // // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // // fileBase64: base64 - // // }, - // // success: function (res) { - // // if (res.result) { - // // fileList.push({ - // // ...file, - // // url: app.globalData.url + "static/" + res.result.data.replace(/\\/g, "/") - // // }); - // // _this.setData({ - // // fileList - // // }); - // // } - // // }, - // // complete: res => { - // // }, - // // }) - // } - // }); + } + }) + } + }, + fail(err) { + wx.showToast({ + title: "提交失败", + }) + } + }) + }, + //报存录入的input信息 + confirm(event) { + var that = this; + var formValue = event.detail.value; + var formName = event.target.dataset.id; + var fromN = 'form.' + [formName]; + that.setData({ + [fromN]: formValue + }) + }, + + //扫码 + scan() { + + wx.scanCode({ + success(res) { + console.log(res) + } + }) + }, + //粘贴经纬度 + paste() { + var _this = this; + wx.getClipboardData({ + success: function (res) { + var longitude = 'form.longitude'; + var latitude = 'form.latitude'; + var longitude84 = 'form.longitude84'; + var latitude84 = 'form.latitude84'; + _this.setData({ + [longitude]: parseFloat(res.data.split(",", 4)[1]).toFixed(6), + [latitude]: parseFloat(res.data.split(",", 4)[0]).toFixed(6), + [longitude84]: "" == (res.data.split(",", 4)[3]) ? "" : parseFloat(res.data.split(",", 4)[3]).toFixed(6), + [latitude84]: "" == (res.data.split(",", 4)[2]) ? "" : parseFloat(res.data.split(",", 4)[2]).toFixed(6), + longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), + latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), + }); + } + }) + }, + selectValue(value) { + var that = this; + var wellType = 'form.welltype'; + that.setData({ + [wellType]: value.detail + }) + }, + //运维人员默认为登录人 + // selectpersonValue(event) { + // var that = this; + // var installPerson = 'form.installperson'; + // that.setData({ + // [installPerson]: event.detail + // }) + // }, + selectprojectValue(event) { + var that = this; + var project = 'form.project'; + that.setData({ + [project]: event.detail, + showMask: true + }) + }, + + open() { + this.setData({ + showMask: true + }) + }, + //隐藏textarea,防止遮挡 + close() { + this.setData({ + showMask: false + }) + }, + //上传照片 + afterRead(event) { + var _this = this; + const { + file + } = event.detail; + const { + fileList = [] + } = _this.data; + var convertpath = ""; + wx.compressImage({ + src: event.detail.file.path, + quality: 25, + success: function (res) { + convertpath = res.tempFilePath; + wx.uploadFile({ + url: app.globalData.httpsUrl + "appDeviceAdd/fileUploadMarker", + filePath: convertpath, + name: 'file', + formData: { + 'text': "编号:" + _this.data.form.devcode + "经度:" + _this.data.form.longitude + "纬度:" + _this.data.form.latitude }, - deletePhoto(event) { - var that = this - var image_index = event.detail.index - var fileList_new = that.data.fileList; - wx.showModal({ - content: '确定删除照片?', - success: function (res) { - if (res.confirm) { - fileList_new.splice(image_index, 1); - that.setData({ - fileList: fileList_new - }) - wx.cloud.callFunction({ - name: 'deletePhoto', - data: { - url: app.globalData.url + "appDeviceLog/deletePhoto", - devcode: that.data.form.devcode, - pathIndex: image_index - }, - success: function (res) {}, - complete: res => {}, - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + "Content-Type": "multipart/form-data", + 'accept': 'application/json', }, - }) \ No newline at end of file + success(res) { + if (res.data) { + var url = JSON.parse(res.data); + fileList.push({ + ...file, + url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") + }); + _this.setData({ + fileList + }); + } + } + }) + } + }) + }, + //删除照片 + deletePhoto(event) { + var that = this + var image_index = event.detail.index + var fileList_new = that.data.fileList; + wx.showModal({ + content: '确定删除照片?', + success: function (res) { + if (res.confirm) { + fileList_new.splice(image_index, 1); + that.setData({ + fileList: fileList_new + }) + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deletePhoto", + data: { + devcode: that.data.form.devcode + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) {} + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } +}) \ No newline at end of file diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.wxml b/miniprogram/pages/addDevicelog/addDeviceLog.wxml index 38620d4..b10cc7d 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.wxml +++ b/miniprogram/pages/addDevicelog/addDeviceLog.wxml @@ -1,15 +1,21 @@ - + + + + + - + - - + + - - + + - + @@ -39,24 +45,25 @@ - - - + + + - + - + + @@ -64,7 +71,7 @@ - + @@ -79,9 +86,9 @@ - + - 保存 + 保存 diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.wxss b/miniprogram/pages/addDevicelog/addDeviceLog.wxss index ee0b75c..08d5fd7 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.wxss +++ b/miniprogram/pages/addDevicelog/addDeviceLog.wxss @@ -24,6 +24,17 @@ display: flex; align-items: center; } +.map-view{ + width: 750rpx; + height: 485rpx; + position: fixed; + top: 0px; + left: 0px; + z-index: 999; +} +.content{ + margin-top: 495rpx; +} .left { width: 210rpx; diff --git a/miniprogram/pages/addFunction/addFunction.js b/miniprogram/pages/addFunction/addFunction.js deleted file mode 100644 index 4966be3..0000000 --- a/miniprogram/pages/addFunction/addFunction.js +++ /dev/null @@ -1,60 +0,0 @@ -// pages/addFunction/addFunction.js - -const code = `// 云函数入口函数 -exports.main = (event, context) => { - console.log(event) - console.log(context) - return { - sum: event.a + event.b - } -}` - -Page({ - - data: { - result: '', - canIUseClipboard: wx.canIUse('setClipboardData'), - }, - - onLoad: function (options) { - - }, - - copyCode: function() { - wx.setClipboardData({ - data: code, - success: function () { - wx.showToast({ - title: '复制成功', - }) - } - }) - }, - - testFunction() { - wx.cloud.callFunction({ - name: 'sum', - data: { - a: 1, - b: 2 - }, - success: res => { - wx.showToast({ - title: '调用成功', - }) - this.setData({ - result: JSON.stringify(res.result) - }) - }, - fail: err => { - wx.showToast({ - icon: 'none', - title: '调用失败', - }) - console.error('[云函数] [sum] 调用失败:', err) - } - }) - }, - -}) - diff --git a/cloudfunctions/project.config.json b/cloudfunctions/project.config.json new file mode 100644 index 0000000..2b3119a --- /dev/null +++ b/cloudfunctions/project.config.json @@ -0,0 +1,28 @@ +{ + "appid": "wx2cef527a000f87c9", + "compileType": "miniprogram", + "libVersion": "2.27.3", + "packOptions": { + "ignore": [], + "include": [] + }, + "setting": { + "coverView": true, + "es6": true, + "postcss": true, + "minified": true, + "enhance": true, + "showShadowRootInWxmlPanel": true, + "packNpmRelationList": [], + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + } + }, + "condition": {}, + "editorSetting": { + "tabIndent": "insertSpaces", + "tabSize": 4 + } +} \ No newline at end of file diff --git a/cloudfunctions/project.private.config.json b/cloudfunctions/project.private.config.json new file mode 100644 index 0000000..42ff49d --- /dev/null +++ b/cloudfunctions/project.private.config.json @@ -0,0 +1,7 @@ +{ + "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", + "projectname": "cloudfunctions", + "setting": { + "compileHotReLoad": true + } +} \ No newline at end of file diff --git a/miniprogram/app.js b/miniprogram/app.js index 51d56f3..50a8a54 100644 --- a/miniprogram/app.js +++ b/miniprogram/app.js @@ -18,13 +18,15 @@ // this.globalData = {} }, globalData: { - // url: "http://111.198.10.15:11604/", - httpsUrl: "https://logapi.smartlog.work/", - httpsTestUrl: "https://smartlog.work/prodapi4test/", - url: "http://139.198.18.188:8083/", + httpsUrl: "https://logapi.smartlog.work/", + // httpsUrl: "http://139.198.18.188:8083/", // url: "http://127.0.0.1:8083/", - // httpsUrl: "http://127.0.0.1:8083/", + //httpsUrl: "http://127.0.0.1:8083/", openid: null, - indexCount:1 - }, + indexCount:1, + nickName:"", + userName:"", + role:"", + devcode:"" + } }) diff --git a/miniprogram/app.json b/miniprogram/app.json index d23f798..2b6db76 100644 --- a/miniprogram/app.json +++ b/miniprogram/app.json @@ -1,15 +1,17 @@ { "cloud": true, "pages": [ + "pages/login/login", "pages/indexapp/indexapp", "pages/earth/earth", "pages/applog/applog", "pages/addDevice/addDevice", "pages/addDevicelog/addDeviceLog", - "pages/searchLog/searchLog" + "pages/searchLog/searchLog", + "pages/notice/notice" ], "window": { - "backgroundColor": "#F6F6F6", + "backgroundColor": "#E6D480", "backgroundTextStyle": "light", "navigationBarBackgroundColor": "#FFCF00", "navigationBarTitleText": "智慧施工", @@ -46,11 +48,11 @@ "desc": "你的位置信息将用于小程序位置接口的效果展示" } }, + "requiredPrivateInfos": ["getLocation", "chooseLocation"], "networkTimeout": { "request": 30000, "connectSocket": 30000, "uploadFile": 30000, "downloadFile": 30000 - }, - "style": "v2" + } } \ No newline at end of file diff --git a/miniprogram/images/applocat.png b/miniprogram/images/applocat.png new file mode 100644 index 0000000..fe49f54 --- /dev/null +++ b/miniprogram/images/applocat.png Binary files differ diff --git a/miniprogram/images/back.png b/miniprogram/images/back.png new file mode 100644 index 0000000..32ac82d --- /dev/null +++ b/miniprogram/images/back.png Binary files differ diff --git a/miniprogram/images/bottom.png b/miniprogram/images/bottom.png new file mode 100644 index 0000000..d910e98 --- /dev/null +++ b/miniprogram/images/bottom.png Binary files differ diff --git a/miniprogram/images/header.png b/miniprogram/images/header.png new file mode 100644 index 0000000..6ea222e --- /dev/null +++ b/miniprogram/images/header.png Binary files differ diff --git a/miniprogram/images/login.png b/miniprogram/images/login.png index 8b73cc0..6471c46 100644 --- a/miniprogram/images/login.png +++ b/miniprogram/images/login.png Binary files differ diff --git a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss index 5a591fb..c9c35b5 100644 --- a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss +++ b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:100%;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:100%}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file +@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:650rpx;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:600rpx}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file diff --git a/miniprogram/pages/addDevice/addDevice.js b/miniprogram/pages/addDevice/addDevice.js index 2783674..78f00b7 100644 --- a/miniprogram/pages/addDevice/addDevice.js +++ b/miniprogram/pages/addDevice/addDevice.js @@ -1,5 +1,7 @@ // miniprogram/pages/addDevice/addDevice.js // import WxValidate from '../../utils/WxValidate.js' +var QQMapWX = require('../../libs/qqmap-wx-jssdk.js'); +var qqmapsdk; var app = getApp() Page({ @@ -11,32 +13,10 @@ canvasWidth: '', longitude: '', latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], + option1: [], personoption1: [], projectoption: [], + devtypeList:[], show: false, form: { devcode: "", @@ -59,7 +39,10 @@ project: "", area: "", street: "", - wellname: "" + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '', }, fileList: [] }, @@ -117,12 +100,14 @@ var that = this; //初始化表单内容为上次填写值 var cacheForms = wx.getStorageSync('cacheList') - if (cacheForms) { + cacheForms.photopath1='' + cacheForms.photopath2='' + cacheForms.photopath3='' + that.data.fileList=[] that.setData({ form: cacheForms, devcode: cacheForms.devcode, - }) } var form = that.data.form @@ -155,55 +140,89 @@ } }) + +//获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + that.setData({ + option1: welltypeArr + }) + } + } +}) + + //获取人员下拉列表 - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/getUser", + data:{ + tips:'repair' }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data.code == 200) { + var users = res.data.data + var personArr = []; + for (var i = 0; i < users.length; i++) { + var person = { + text: users[i].name, + value: users[i].name + }; + personArr.push(person); + } + that.setData({ + personoption1: personArr + }) } - that.setData({ - personoption1: personArr - }) } - }).catch(err => { - console.error(err); - }) + }) + - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - that.setData({ - projectoption: projectArr - }) + success(res){ + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); + } + that.setData({ + projectoption: projectArr + }) + } } - }).catch(err => { - console.error(err); - }) + }) + var installtime = 'form.installtimeFmt'; var dateNow = this.formatDate(); this.setData({ @@ -211,8 +230,40 @@ installtimeFmt: dateNow, [installtime]: dateNow, }); + + + + /** + * 获取设备类型下拉列表 + */ + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/deviceType", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var TypeList = res.data.data + var typeArr = []; + for (var i = 0; i < TypeList.length; i++) { + var type = { + text: TypeList[i].productName, + value: TypeList[i].productName + }; + typeArr.push(type); + } + that.setData({ + devtypeList: typeArr + }) + } + } + }) }, + + + /** * 生命周期函数--监听页面初次渲染完成 */ @@ -280,29 +331,7 @@ }, - - //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 - drawText: function (ctx, str, leftWidth, initHeight, titleHeight, canvasWidth) { - var lineWidth = 0; - var lastSubStrIndex = 0; //每次开始截取的字符串的索引 - for (let i = 0; i < str.length; i++) { - lineWidth += ctx.measureText(str[i]).width; - if (lineWidth > canvasWidth) { - ctx.fillText(str.substring(lastSubStrIndex, i), leftWidth, initHeight); //绘制截取部分 - initHeight = initHeight + leftWidth * 2; //22为字体的高度 - lineWidth = 0; - lastSubStrIndex = i; - // titleHeight += 40; - } - if (i == str.length - 1) { //绘制剩余部分 - ctx.fillText(str.substring(lastSubStrIndex, i + 1), leftWidth, initHeight); - } - } - // // 标题border-bottom 线距顶部距离 - // titleHeight = titleHeight + 10; - // return titleHeight - }, - + //验证表单 formValidate() { if (this.data.form.devcode == "") { @@ -312,27 +341,20 @@ }) return false } - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } if (this.data.form.wellcode == "") { wx.showToast({ icon: 'none', @@ -348,22 +370,10 @@ }) return false } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null) { + + if (this.data.form.installperson == "") { wx.showToast({ icon: 'none', title: '安装人员不能为空!', @@ -408,56 +418,90 @@ } return true; }, + //提交表单 formSubmit: function (event) { + console.log(this.data.form) + //表单参数验证 if (!this.formValidate()) { return false; } var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDevice', + //验证设备编号长度 + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/getDevTypeLength", data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceAdd/add" + code: encodeURI(this.data.form.devicetype) }, - }).then(res => { - if (res.result.code == 500) { - wx.showToast({ - title: '设备编号已安装!', - }) - } else if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - //用于回显 - wx.setStorageSync('cacheList', that.data.form) - //提交成功后提示用户操作 - if (res.confirm) { - wx.switchTab({ - url: '../earth/earth' - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (""==res.data.data ||res.data.data == that.data.form.devcode.length) { + that.saveDevice() + } else { //编号位数不对提示 + wx.showToast({ + icon: 'none', + title: '设备编号位数不对!', + duration: 1000 + }) + return false + } } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "提交失败", - }) }) }, + + //保存设备基本信息 + saveDevice() { + var that = this; + //设置照片路径 + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopathForm = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopathForm]: fileList[i].url.split("static/")[1] + }) + } + //表单提交 + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 500) { + wx.showToast({ + title: '设备编号已安装!', + }) + } else if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + //用于回显 + wx.setStorageSync('cacheList', that.data.form) + //提交成功后提示用户操作 + if (res.confirm) { + wx.switchTab({ + url: '../earth/earth' + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } + }, + fail(err) { + wx.showToast({ + title: '提交失败!', + }) + } + }) + }, + + //input 输入框设置值 confirm(event) { var that = this; var formValue = event.detail.value; @@ -466,8 +510,30 @@ that.setData({ [fromN]: formValue }) + //若输入是设备编号,自动获取设备类型 + if('devcode'==formName){ + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", + data: { + devcode: formValue, + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + that.setData({ + [formDevicetype]: res.data + }); + } + } + }) + } }, + //扫描设备获取编号和设备类型 scan() { var _this = this; wx.scanCode({ @@ -477,23 +543,28 @@ _this.setData({ [formdevcode]: devcode }); - wx.cloud.callFunction({ - name: 'findModeCode', + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", data: { devcode: devcode, - url: app.globalData.url + "appDeviceAdd/findModeCodeByCode" }, - }).then(res => { - if (res.result) { - var formDevicetype = 'form.devicetype' - _this.setData({ - [formDevicetype]: res.result - }); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + _this.setData({ + [formDevicetype]: res.data + }); + } } }) } }) }, + //粘贴经纬度 paste() { var _this = this; wx.getClipboardData({ @@ -510,9 +581,11 @@ longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), }); + _this.showAddress(_this.data.form.longitude,_this.data.form.latitude,_this) } }) }, + //设置经类型 selectValue(value) { var that = this; @@ -521,6 +594,16 @@ [wellType]: value.detail }) }, + + //设置设备类型 + selectDevType(event) { + var that = this; + var devtype = 'form.devicetype'; + that.setData({ + [devtype]: event.detail + }) + }, + //设置运维人员 selectpersonValue(event) { var that = this; var installPerson = 'form.installperson'; @@ -528,6 +611,7 @@ [installPerson]: event.detail }) }, + //设置项目 selectprojectValue(event) { var that = this; var project = 'form.project'; @@ -535,8 +619,41 @@ [project]: event.detail }) }, + showAddress :function(longitude, latitude, self) { + // 实例化腾讯地图API核心类 + qqmapsdk = new QQMapWX({ + key: 'BGPBZ-C5O3P-ROUDR-LWC4J-63EKH-V5FRX'//此处使用你自己申请的key + }) + // 腾讯地图调用接口 + qqmapsdk.reverseGeocoder({ + location: { + latitude: latitude, + longitude: longitude + }, + success: function (res) { + self.setData({ + 'form.area':res.result.address.slice(0,res.result.address.indexOf('区')+1), + 'form.street':res.result.address.slice(res.result.address.indexOf('区')+1) + }) + }, + fail: function (res) { + console.log(res); + }, + complete: function (res) { + } + }); + }, + //上传照片 afterRead(event) { var _this = this; + if (_this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '请先填写设备编号!\r\n否则水印中无编号', + duration: 2000 + }) + return false + } const { file } = event.detail; @@ -576,78 +693,8 @@ }) } }) - // 压缩图片 - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // //获取图片尺寸 - // wx.getImageInfo({ - // src: convertpath, - // success(res) { - // _this.setData({ - // canvasHeight: res.height, - // canvasWidth: res.width - // }) - // var ctx = wx.createCanvasContext('firstCanvas') - - // //将图片src放到cancas内,宽高为图片大小 - // ctx.drawImage(convertpath, 0, 0, res.width, res.height) - // //将声明的时间放入canvas - // ctx.setFontSize(30 * (res.width / 750)) //注意:设置文字大小必须放在填充文字之前,否则不生效 - // ctx.setFillStyle('blue') - // var text = "编号:" + _this.data.form.devcode + "\n经度:" + _this.data.form.longitude + "\n纬度:" + _this.data.form.latitude - // // _this.drawText(ctx,text,20, 70, 5, res.width) - // _this.drawText(ctx, text, 15 * (res.width / 750), 70 * (res.width / 750), 5, res.width) - - // // ctx.fillText(text, 0, 40) - // // ctx.strokeText(_this.data.form.devcode, 0, 30) - // //生成水印图 - // ctx.draw(false, function () { - // wx.canvasToTempFilePath({ - // canvasId: 'firstCanvas', - // success: (res) => { - // wx.compressImage({ - // src: res.tempFilePath, - // quality: 25, - // success: function (res) { - // //上传照片至服务器 - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: res.tempFilePath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // } - // }) - // //// - // } - // }) - // }) - // } - // }) - // } - // }); }, + //删除照片 deletePhoto(event) { var image_index = event.detail.index var fileList_new = this.data.fileList; diff --git a/miniprogram/pages/addDevice/addDevice.wxml b/miniprogram/pages/addDevice/addDevice.wxml index b0977e2..f12c254 100644 --- a/miniprogram/pages/addDevice/addDevice.wxml +++ b/miniprogram/pages/addDevice/addDevice.wxml @@ -5,18 +5,30 @@ - + + + + + + + + + + + + + - - + + - - - + + + @@ -29,13 +41,13 @@ - + - + - + - + @@ -54,8 +66,7 @@ - - + @@ -68,8 +79,8 @@ - - + + - 保存 + 保存 \ No newline at end of file diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.js b/miniprogram/pages/addDevicelog/addDeviceLog.js index cdec71b..a0dc6da 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.js +++ b/miniprogram/pages/addDevicelog/addDeviceLog.js @@ -3,681 +3,665 @@ var app = getApp(); Page({ - /** - * 页面的初始数据 - */ - data: { - pageName: '', - showMask: false, - today: new Date().getTime(), - longitude: '', - latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], - personoption1: [], - projectoption: [], - devcode: "", - deviceMode: "", - installtimeFmt: '', - show: false, - form: { - devcode: "", - wellcode: "", - welltype: "", - welldepth: "", - installheigt: "", - installperson: "", - installtimeFmt: "", - photopath: "", - factory: "", - workmsg: "", - position: "", - description: "", - longitude: "", - latitude: "", - longitude84: "", - latitude84: "", - devicetype: "", - project: "", - area: "", - street: "", - wellname: "" - }, - fileList: [], - detail: "" - }, + /** + * 页面的初始数据 + */ + data: { + pageName: '', + showMask: false, + today: new Date().getTime(), + longitude: '', + latitude: '', + option1: [], + personoption1: [], + projectoption: [], + devcode: "", + deviceMode: "", + installtimeFmt: '', + show: false, + form: { + devcode: "", + wellcode: "", + welltype: "", + welldepth: "", + installheigt: "", + installperson: "", + installtimeFmt: "", + photopath: "", + factory: "", + workmsg: "", + position: "", + description: "", + longitude: "", + latitude: "", + longitude84: "", + latitude84: "", + devicetype: "", + project: "", + area: "", + street: "", + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '' + }, + fileList: [], + detail: "", + markers: [{ + id: 100, + // iconPath: "../../images/point.png", + latitude: '', + longitude: '', + // label:'1', + width: 25, + height: 35 + }], + }, - onDisplay() { - this.setData({ - show: true - }); - }, - onClose() { - this.setData({ - show: false - }); - }, - formatDate() { - var date = new Date(); - // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; - var seperator1 = "-"; - var month = date.getMonth() + 1; - var strDate = date.getDate(); - var hour = date.getHours() - var minute = date.getMinutes() - var second = date.getSeconds() - month = month > 9 ? month : "0" + month; - strDate = strDate > 9 ? strDate : "0" + strDate; - hour = hour > 9 ? hour : "0" + hour; - minute = minute > 9 ? minute : "0" + minute; - second = second > 9 ? second : "0" + second; - var currentdate = - date.getFullYear() + - seperator1 + - month + - seperator1 + - strDate + - " " + - hour + ":" + - minute + ":" + - second; - return currentdate; + onDisplay() { + this.setData({ + show: true + }); + }, + onClose() { + this.setData({ + show: false + }); + }, + formatDate() { + var date = new Date(); + // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; + var seperator1 = "-"; + var month = date.getMonth() + 1; + var strDate = date.getDate(); + var hour = date.getHours() + var minute = date.getMinutes() + var second = date.getSeconds() + month = month > 9 ? month : "0" + month; + strDate = strDate > 9 ? strDate : "0" + strDate; + hour = hour > 9 ? hour : "0" + hour; + minute = minute > 9 ? minute : "0" + minute; + second = second > 9 ? second : "0" + second; + var currentdate = + date.getFullYear() + + seperator1 + + month + + seperator1 + + strDate + + " " + + hour + ":" + + minute + ":" + + second; + return currentdate; - }, - onConfirm(event) { - var installtime = 'form.installtimeFmt'; - this.setData({ - show: false, - installtimeFmt: this.formatDate(event.detail), - [installtime]: this.formatDate(event.detail), - }); - }, + }, + onConfirm(event) { + var installtime = 'form.installtimeFmt'; + this.setData({ + show: false, + installtimeFmt: this.formatDate(event.detail), + [installtime]: this.formatDate(event.detail), + }); + }, - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - var _this = this; - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" - }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); - } - _this.setData({ - personoption1: personArr - }) + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + var _this = this; + _this.setData({ + 'markers[0].latitude': Number(wx.getStorageSync('resultObject').latitude) , + 'markers[0].longitude': Number(wx.getStorageSync('resultObject').longitude), + // 'markers[0].label':'10', + 'markers[0].width': 18, + 'markers[0].id':1, + 'markers[0].height': 30, + latitude:Number(wx.getStorageSync('resultObject').latitude), + longitude:Number(wx.getStorageSync('resultObject').longitude) + }) + //获取人员下拉列表 + // wx.request({ + // method: "POST", + // url: app.globalData.httpsUrl + "deviceType/getUser", + // data:{ + // tips:'repair' + // }, + // header: { + // 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + // }, + // success(res) { + // if (res.data.code == 200) { + // var users = res.data.data + // var personArr = []; + // for (var i = 0; i < users.length; i++) { + // var person = { + // text: users[i].name, + // value: users[i].name + // }; + // personArr.push(person); + // } + // _this.setData({ + // personoption1: personArr + // }) + // } + // } + // }) + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); } - }).catch(err => { - console.error(err); - }) - - - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" - }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - _this.setData({ - projectoption: projectArr - }) - } - }).catch(err => { - console.error(err); - }) - - if (options.pageName) { - this.setData({ - pageName: options.pageName - }) - } - - if (options.detail) { - - var formObject = JSON.parse(options.detail); _this.setData({ - form: formObject, - detail: options.detail + projectoption: projectArr }) - - _this.setData({ - ['form.installperson']: "", - ['form.installtimeFmt']: "", - ['form.workmsg']: "", - ['form.description']: "" - }) - - const { - fileList = [] - } = _this.data; - if (formObject.photopath1 != "") { - var file1 = { - url: app.globalData.url + "static/" + formObject.photopath1 - } - fileList.push(file1) - } - if (formObject.photopath2 != "") { - var file2 = { - url: app.globalData.url + "static/" + formObject.photopath2 - } - fileList.push(file2) - } - if (formObject.photopath3 != "") { - var file3 = { - url: app.globalData.url + "static/" + formObject.photopath3 - } - fileList.push(file3) - } - - _this.setData({ - fileList - }); } - var installtime = 'form.installtimeFmt'; - var dateNow = this.formatDate(); - this.setData({ - installtimeFmt: dateNow, - [installtime]: dateNow, - }); - }, + } + }) - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { + //获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + _this.setData({ + option1: welltypeArr + }) + } + } +}) - }, + //跳转时带入参数返回哪页 + if (options.pageName) { + this.setData({ + pageName: options.pageName + }) + } + //跳转时带入参数设备的安装信息 + if (wx.getStorageSync('resultObject')) { + var formObject = wx.getStorageSync('resultObject') + _this.setData({ + form: formObject, + detail: formObject + }) - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { + _this.setData({ + ['form.installperson']: app.globalData.userName, + ['form.installtimeFmt']: "", + ['form.workmsg']: "", + ['form.description']: "" + }) - }, + const { + fileList = [] + } = _this.data; + if (formObject.photopath1 != "") { + var file1 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath1 + } + fileList.push(file1) + } + if (formObject.photopath2 != "") { + var file2 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath2 + } + fileList.push(file2) + } + if (formObject.photopath3 != "") { + var file3 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath3 + } + fileList.push(file3) + } + _this.setData({ + fileList + }); + } + var installtime = 'form.installtimeFmt'; + var dateNow = this.formatDate(); + this.setData({ + installtimeFmt: dateNow, + [installtime]: dateNow, + }); + }, - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, - }, + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + wx.removeStorageSync('resultObject') + }, - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, - }, + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { + }, - }, + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { + }, - }, + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { + }, - }, + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + }, - /** - * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true - **/ + /** + * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true + **/ - isNumber: function (val) { + isNumber: function (val) { - var regPos = /^[0-9]*$/; //非负浮点数 - var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数 - if (regPos.test(val) || regNeg.test(val)) { - return false; - } else { - return true; - } + var regPos = /^[0-9]*$/; //非负浮点数 + var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数 + if (regPos.test(val) || regNeg.test(val)) { + return false; + } else { + return true; + } - }, + }, - formValidate() { + formValidate() { - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } - if (this.data.form.wellcode == "") { - wx.showToast({ - icon: 'none', - title: '井编号不能为空!', - }) - return false - } - if (this.data.form.devicetype == "") { - wx.showToast({ - icon: 'none', - title: '设备类型不能为空!', - }) - return false - } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + if (this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '设备编号不能为空!', + }) + return false + } + if (this.data.form.wellcode == "") { + wx.showToast({ + icon: 'none', + title: '井编号不能为空!', + }) + return false + } + if (this.data.form.devicetype == "") { + wx.showToast({ + icon: 'none', + title: '设备类型不能为空!', + }) + return false + } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null || - this.data.form.installperson == '') { - wx.showToast({ - icon: 'none', - title: '运维人员不能为空!', - }) - return false - } - if (this.data.form.project == "") { - wx.showToast({ - icon: 'none', - title: '所属项目不能为空!', - }) - return false - } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } + if (this.data.form.installperson == null || + this.data.form.installperson == '') { + wx.showToast({ + icon: 'none', + title: '运维人员不能为空!', + }) + return false + } + if (this.data.form.project == "") { + wx.showToast({ + icon: 'none', + title: '所属项目不能为空!', + }) + return false + } - if (this.data.form.welldepth != null) { - if (this.isNumber(this.data.form.welldepth)) { - wx.showToast({ - icon: 'none', - title: '井深必须为数值!', - }) - return false - } - } - if (this.data.form.installheigt != null) { - if (this.isNumber(this.data.form.installheigt)) { - wx.showToast({ - icon: 'none', - title: '到井口距离必须为数值!', - }) - return false - } - } - - return true; - }, - - changeMsg: function () { - var formNew = this.data.form; - var formOld = JSON.parse(this.data.detail); - var descpNew = ""; - if (formNew.devcode != formOld.devcode) { - descpNew += "修改设备编号,原编号:" + formOld.devcode + ",新编号:" + formNew.devcode + ";" - } - if (formNew.devicetype != formOld.devicetype) { - descpNew += "修改设备类型,原设备类型:" + formOld.devicetype + ",新设备类型:" + formNew.devicetype + ";" - } - if (formNew.area != formOld.area) { - descpNew += "修改区,原区:" + formOld.area + ",新区:" + formNew.area + ";" - } - if (formNew.street != formOld.street) { - descpNew += "修改街道,原街道:" + formOld.street + ",新街道:" + formNew.street + ";" - } - if (formNew.wellname != formOld.wellname) { - descpNew += "修改井名称,原井名称:" + formOld.wellname + ",新井名称:" + formNew.wellname + ";" - } - if (formNew.factory != formOld.factory) { - descpNew += "修改权属单位,原权属单位:" + formOld.factory + ",新权属单位:" + formNew.factory + ";" - } - if (formNew.installheigt != formOld.installheigt) { - descpNew += "修改井口距离,原井口距离:" + formOld.installheigt + ",新井口距离:" + formNew.installheigt + ";" - } - if (formNew.installperson != formOld.installperson) { - descpNew += "修改运维人员,原运维人员:" + formOld.installperson + ",新运维人员:" + formNew.installperson + ";" - } - if (formNew.latitude != formOld.latitude) { - descpNew += "修改纬度,原纬度:" + formOld.latitude + ",新纬度:" + formNew.latitude + ";" - } - if (formNew.longitude != formOld.longitude) { - descpNew += "修改经度,原经度:" + formOld.longitude + ",新经度:" + formNew.longitude + ";" - } - if (formNew.position != formOld.position) { - descpNew += "修改位置描述,原位置:" + formOld.position + ",新位置:" + formNew.position + ";" - } - if (formNew.wellcode != formOld.wellcode) { - descpNew += "修改井编号,原编号:" + formOld.wellcode + ",新编号:" + formNew.wellcode + ";" - } - if (formNew.welldepth != formOld.welldepth) { - descpNew += "修改井深,原井深:" + formOld.welldepth + ",新井深:" + formNew.welldepth + ";" - } - if (formNew.welltype != formOld.welltype) { - descpNew += "修改井类型,原井类型:" + formOld.welltype + ",新井类型:" + formNew.welltype + ";" - } - if (formNew.project != formOld.project) { - descpNew += "修改所属项目,原项目:" + formOld.project + ",新项目:" + formNew.project + ";" - } - if (this.data.photopath1 != formOld.photopath1 || - this.data.photopath2 != formOld.photopath2 || - this.data.photopath3 != formOld.photopath3) { - descpNew += "修改照片;" - } - if ("" != formNew.description) { - descpNew += formNew.description; - } - this.setData({ - ['form.description']: descpNew + if (this.data.form.welldepth != null) { + if (this.isNumber(this.data.form.welldepth)) { + wx.showToast({ + icon: 'none', + title: '井深必须为数值!', }) - }, + return false + } + } + if (this.data.form.installheigt != null) { + if (this.isNumber(this.data.form.installheigt)) { + wx.showToast({ + icon: 'none', + title: '到井口距离必须为数值!', + }) + return false + } + } - formSubmit: function (event) { + return true; + }, - if (!this.formValidate()) { - return false; - } - this.changeMsg(); - var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDeviceLog', - data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceLog/add" - }, - }).then(res => { - // var resultObj=JSON.parse(res.result); - if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - if (res.confirm) { - wx.switchTab({ - url: that.data.pageName - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) - } - }).catch(err => { - console.error(err) - wx.showToast({ - title: "提交失败", - }) - }) - }, - confirm(event) { - var that = this; - var formValue = event.detail.value; - var formName = event.target.dataset.id; - var fromN = 'form.' + [formName]; - that.setData({ - [fromN]: formValue - }) - }, + //获取与上次修改的信息 + changeMsg: function () { + var formNew = this.data.form; + console.log(this.data.detail) + var formOld = JSON.parse(this.data.detail); + var descpNew = ""; + if (formNew.devcode != formOld.devcode) { + descpNew += "修改设备编号,原值:" + formOld.devcode + ",新值:" + formNew.devcode + ";" + } + if (formNew.devicetype != formOld.devicetype) { + descpNew += "修改设备类型,原值:" + formOld.devicetype + ",新值:" + formNew.devicetype + ";" + } + if (formNew.area != formOld.area) { + descpNew += "修改区,原值:" + formOld.area + ",新值:" + formNew.area + ";" + } + if (formNew.street != formOld.street) { + descpNew += "修改街道,原值:" + formOld.street + ",新值:" + formNew.street + ";" + } + if (formNew.wellname != formOld.wellname) { + descpNew += "修改井名称,原值:" + formOld.wellname + ",新值:" + formNew.wellname + ";" + } + if (formNew.factory != formOld.factory) { + descpNew += "修改权属单位,原值:" + formOld.factory + ",新值:" + formNew.factory + ";" + } + if (formNew.installheigt != formOld.installheigt) { + descpNew += "修改井口距离,原值:" + formOld.installheigt + ",新值:" + formNew.installheigt + ";" + } + if (formNew.installperson != formOld.installperson) { + descpNew += "修改运维人员,原值:" + formOld.installperson + ",新值:" + formNew.installperson + ";" + } + if (formNew.latitude != formOld.latitude) { + descpNew += "修改纬度,原值:" + formOld.latitude + ",新值:" + formNew.latitude + ";" + } + if (formNew.longitude != formOld.longitude) { + descpNew += "修改经度,原值:" + formOld.longitude + ",新值:" + formNew.longitude + ";" + } + if (formNew.position != formOld.position) { + descpNew += "修改位置描述,原值:" + formOld.position + ",新值:" + formNew.position + ";" + } + if (formNew.wellcode != formOld.wellcode) { + descpNew += "修改井编号,原值:" + formOld.wellcode + ",新值:" + formNew.wellcode + ";" + } + if (formNew.welldepth != formOld.welldepth) { + descpNew += "修改井深,原值:" + formOld.welldepth + ",新值:" + formNew.welldepth + ";" + } + if (formNew.welltype != formOld.welltype) { + descpNew += "修改井类型,原值:" + formOld.welltype + ",新值:" + formNew.welltype + ";" + } + if (formNew.project != formOld.project) { + descpNew += "修改所属项目,原值:" + formOld.project + ",新值:" + formNew.project + ";" + } + if (this.data.form.photopath1 != formOld.photopath1 || + this.data.form.photopath2 != formOld.photopath2 || + this.data.form.photopath3 != formOld.photopath3) { + descpNew += "修改照片;" + } + if ("" != formNew.description) { + descpNew += formNew.description; + } + this.setData({ + ['form.description']: descpNew + }) + }, - scan() { + //提交表单 + formSubmit: function (event) { - wx.scanCode({ - success(res) { - console.log(res) - } - }) + //表单验证 + if (!this.formValidate()) { + return false; + } + //自动生成修改内容 + this.changeMsg(); + //提交权限限制(只有施工人员能修改) + if(app.globalData.role!='repair'){ + wx.showToast({ + icon: 'none', + title: '无权限修改', + duration:2000 + }) + return false + } + var that = this; + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopath = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopath]: fileList[i].url.split("static/")[1] + }) + } + delete that.data.form.installtime + delete that.data.form.createtime + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - paste() { - var _this = this; - wx.getClipboardData({ - success: function (res) { - var longitude = 'form.longitude'; - var latitude = 'form.latitude'; - var longitude84 = 'form.longitude84'; - var latitude84 = 'form.latitude84'; - _this.setData({ - [longitude]: parseFloat(res.data.split(",", 4)[1]).toFixed(6), - [latitude]: parseFloat(res.data.split(",", 4)[0]).toFixed(6), - [longitude84]: "" == (res.data.split(",", 4)[3]) ? "" : parseFloat(res.data.split(",", 4)[3]).toFixed(6), - [latitude84]: "" == (res.data.split(",", 4)[2]) ? "" : parseFloat(res.data.split(",", 4)[2]).toFixed(6), - longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), - latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), - }); - } - }) - }, - selectValue(value) { - var that = this; - var wellType = 'form.welltype'; - that.setData({ - [wellType]: value.detail - }) - }, - selectpersonValue(event) { - var that = this; - var installPerson = 'form.installperson'; - that.setData({ - [installPerson]: event.detail - }) - }, - selectprojectValue(event) { - var that = this; - var project = 'form.project'; - that.setData({ - [project]: event.detail, - showMask: true - }) - }, - open() { - this.setData({ - showMask: true - }) - }, - close() { - this.setData({ - showMask: false - }) - }, - afterRead(event) { - var _this = this; - const { - file - } = event.detail; - const { - fileList = [] - } = _this.data; - var convertpath = ""; - wx.compressImage({ - src: event.detail.file.path, - quality: 25, - success: function (res) { - convertpath = res.tempFilePath; - wx.uploadFile({ - url: app.globalData.httpsUrl + "appDeviceAdd/fileUploadMarker", - filePath:convertpath, - name: 'file', - formData: { - 'text': "编号:" + _this.data.form.devcode + "经度:" + _this.data.form.longitude + "纬度:" + _this.data.form.latitude - }, - header: { - "Content-Type": "multipart/form-data", - 'accept': 'application/json', - }, - success(res) { - if (res.data) { - var url = JSON.parse(res.data); - fileList.push({ - ...file, - url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - }); - _this.setData({ - fileList - }); - } - } + success(res) { + if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + if (res.confirm) { + wx.switchTab({ + url: that.data.pageName }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') } - }) - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // // var base64 = "data:image/png;base64," + wx.getFileSystemManager().readFileSync(convertpath, 'base64'); - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: convertpath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // // wx.cloud.callFunction({ - // // name: 'uploadFile', - // // data: { - // // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // // fileBase64: base64 - // // }, - // // success: function (res) { - // // if (res.result) { - // // fileList.push({ - // // ...file, - // // url: app.globalData.url + "static/" + res.result.data.replace(/\\/g, "/") - // // }); - // // _this.setData({ - // // fileList - // // }); - // // } - // // }, - // // complete: res => { - // // }, - // // }) - // } - // }); + } + }) + } + }, + fail(err) { + wx.showToast({ + title: "提交失败", + }) + } + }) + }, + //报存录入的input信息 + confirm(event) { + var that = this; + var formValue = event.detail.value; + var formName = event.target.dataset.id; + var fromN = 'form.' + [formName]; + that.setData({ + [fromN]: formValue + }) + }, + + //扫码 + scan() { + + wx.scanCode({ + success(res) { + console.log(res) + } + }) + }, + //粘贴经纬度 + paste() { + var _this = this; + wx.getClipboardData({ + success: function (res) { + var longitude = 'form.longitude'; + var latitude = 'form.latitude'; + var longitude84 = 'form.longitude84'; + var latitude84 = 'form.latitude84'; + _this.setData({ + [longitude]: parseFloat(res.data.split(",", 4)[1]).toFixed(6), + [latitude]: parseFloat(res.data.split(",", 4)[0]).toFixed(6), + [longitude84]: "" == (res.data.split(",", 4)[3]) ? "" : parseFloat(res.data.split(",", 4)[3]).toFixed(6), + [latitude84]: "" == (res.data.split(",", 4)[2]) ? "" : parseFloat(res.data.split(",", 4)[2]).toFixed(6), + longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), + latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), + }); + } + }) + }, + selectValue(value) { + var that = this; + var wellType = 'form.welltype'; + that.setData({ + [wellType]: value.detail + }) + }, + //运维人员默认为登录人 + // selectpersonValue(event) { + // var that = this; + // var installPerson = 'form.installperson'; + // that.setData({ + // [installPerson]: event.detail + // }) + // }, + selectprojectValue(event) { + var that = this; + var project = 'form.project'; + that.setData({ + [project]: event.detail, + showMask: true + }) + }, + + open() { + this.setData({ + showMask: true + }) + }, + //隐藏textarea,防止遮挡 + close() { + this.setData({ + showMask: false + }) + }, + //上传照片 + afterRead(event) { + var _this = this; + const { + file + } = event.detail; + const { + fileList = [] + } = _this.data; + var convertpath = ""; + wx.compressImage({ + src: event.detail.file.path, + quality: 25, + success: function (res) { + convertpath = res.tempFilePath; + wx.uploadFile({ + url: app.globalData.httpsUrl + "appDeviceAdd/fileUploadMarker", + filePath: convertpath, + name: 'file', + formData: { + 'text': "编号:" + _this.data.form.devcode + "经度:" + _this.data.form.longitude + "纬度:" + _this.data.form.latitude }, - deletePhoto(event) { - var that = this - var image_index = event.detail.index - var fileList_new = that.data.fileList; - wx.showModal({ - content: '确定删除照片?', - success: function (res) { - if (res.confirm) { - fileList_new.splice(image_index, 1); - that.setData({ - fileList: fileList_new - }) - wx.cloud.callFunction({ - name: 'deletePhoto', - data: { - url: app.globalData.url + "appDeviceLog/deletePhoto", - devcode: that.data.form.devcode, - pathIndex: image_index - }, - success: function (res) {}, - complete: res => {}, - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + "Content-Type": "multipart/form-data", + 'accept': 'application/json', }, - }) \ No newline at end of file + success(res) { + if (res.data) { + var url = JSON.parse(res.data); + fileList.push({ + ...file, + url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") + }); + _this.setData({ + fileList + }); + } + } + }) + } + }) + }, + //删除照片 + deletePhoto(event) { + var that = this + var image_index = event.detail.index + var fileList_new = that.data.fileList; + wx.showModal({ + content: '确定删除照片?', + success: function (res) { + if (res.confirm) { + fileList_new.splice(image_index, 1); + that.setData({ + fileList: fileList_new + }) + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deletePhoto", + data: { + devcode: that.data.form.devcode + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) {} + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } +}) \ No newline at end of file diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.wxml b/miniprogram/pages/addDevicelog/addDeviceLog.wxml index 38620d4..b10cc7d 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.wxml +++ b/miniprogram/pages/addDevicelog/addDeviceLog.wxml @@ -1,15 +1,21 @@ - + + + + + - + - - + + - - + + - + @@ -39,24 +45,25 @@ - - - + + + - + - + + @@ -64,7 +71,7 @@ - + @@ -79,9 +86,9 @@ - + - 保存 + 保存 diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.wxss b/miniprogram/pages/addDevicelog/addDeviceLog.wxss index ee0b75c..08d5fd7 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.wxss +++ b/miniprogram/pages/addDevicelog/addDeviceLog.wxss @@ -24,6 +24,17 @@ display: flex; align-items: center; } +.map-view{ + width: 750rpx; + height: 485rpx; + position: fixed; + top: 0px; + left: 0px; + z-index: 999; +} +.content{ + margin-top: 495rpx; +} .left { width: 210rpx; diff --git a/miniprogram/pages/addFunction/addFunction.js b/miniprogram/pages/addFunction/addFunction.js deleted file mode 100644 index 4966be3..0000000 --- a/miniprogram/pages/addFunction/addFunction.js +++ /dev/null @@ -1,60 +0,0 @@ -// pages/addFunction/addFunction.js - -const code = `// 云函数入口函数 -exports.main = (event, context) => { - console.log(event) - console.log(context) - return { - sum: event.a + event.b - } -}` - -Page({ - - data: { - result: '', - canIUseClipboard: wx.canIUse('setClipboardData'), - }, - - onLoad: function (options) { - - }, - - copyCode: function() { - wx.setClipboardData({ - data: code, - success: function () { - wx.showToast({ - title: '复制成功', - }) - } - }) - }, - - testFunction() { - wx.cloud.callFunction({ - name: 'sum', - data: { - a: 1, - b: 2 - }, - success: res => { - wx.showToast({ - title: '调用成功', - }) - this.setData({ - result: JSON.stringify(res.result) - }) - }, - fail: err => { - wx.showToast({ - icon: 'none', - title: '调用失败', - }) - console.error('[云函数] [sum] 调用失败:', err) - } - }) - }, - -}) - diff --git a/miniprogram/pages/addFunction/addFunction.json b/miniprogram/pages/addFunction/addFunction.json deleted file mode 100644 index a9a50c5..0000000 --- a/miniprogram/pages/addFunction/addFunction.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "navigationBarTitleText": "云函数指引", - "usingComponents": {} -} \ No newline at end of file diff --git a/cloudfunctions/project.config.json b/cloudfunctions/project.config.json new file mode 100644 index 0000000..2b3119a --- /dev/null +++ b/cloudfunctions/project.config.json @@ -0,0 +1,28 @@ +{ + "appid": "wx2cef527a000f87c9", + "compileType": "miniprogram", + "libVersion": "2.27.3", + "packOptions": { + "ignore": [], + "include": [] + }, + "setting": { + "coverView": true, + "es6": true, + "postcss": true, + "minified": true, + "enhance": true, + "showShadowRootInWxmlPanel": true, + "packNpmRelationList": [], + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + } + }, + "condition": {}, + "editorSetting": { + "tabIndent": "insertSpaces", + "tabSize": 4 + } +} \ No newline at end of file diff --git a/cloudfunctions/project.private.config.json b/cloudfunctions/project.private.config.json new file mode 100644 index 0000000..42ff49d --- /dev/null +++ b/cloudfunctions/project.private.config.json @@ -0,0 +1,7 @@ +{ + "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", + "projectname": "cloudfunctions", + "setting": { + "compileHotReLoad": true + } +} \ No newline at end of file diff --git a/miniprogram/app.js b/miniprogram/app.js index 51d56f3..50a8a54 100644 --- a/miniprogram/app.js +++ b/miniprogram/app.js @@ -18,13 +18,15 @@ // this.globalData = {} }, globalData: { - // url: "http://111.198.10.15:11604/", - httpsUrl: "https://logapi.smartlog.work/", - httpsTestUrl: "https://smartlog.work/prodapi4test/", - url: "http://139.198.18.188:8083/", + httpsUrl: "https://logapi.smartlog.work/", + // httpsUrl: "http://139.198.18.188:8083/", // url: "http://127.0.0.1:8083/", - // httpsUrl: "http://127.0.0.1:8083/", + //httpsUrl: "http://127.0.0.1:8083/", openid: null, - indexCount:1 - }, + indexCount:1, + nickName:"", + userName:"", + role:"", + devcode:"" + } }) diff --git a/miniprogram/app.json b/miniprogram/app.json index d23f798..2b6db76 100644 --- a/miniprogram/app.json +++ b/miniprogram/app.json @@ -1,15 +1,17 @@ { "cloud": true, "pages": [ + "pages/login/login", "pages/indexapp/indexapp", "pages/earth/earth", "pages/applog/applog", "pages/addDevice/addDevice", "pages/addDevicelog/addDeviceLog", - "pages/searchLog/searchLog" + "pages/searchLog/searchLog", + "pages/notice/notice" ], "window": { - "backgroundColor": "#F6F6F6", + "backgroundColor": "#E6D480", "backgroundTextStyle": "light", "navigationBarBackgroundColor": "#FFCF00", "navigationBarTitleText": "智慧施工", @@ -46,11 +48,11 @@ "desc": "你的位置信息将用于小程序位置接口的效果展示" } }, + "requiredPrivateInfos": ["getLocation", "chooseLocation"], "networkTimeout": { "request": 30000, "connectSocket": 30000, "uploadFile": 30000, "downloadFile": 30000 - }, - "style": "v2" + } } \ No newline at end of file diff --git a/miniprogram/images/applocat.png b/miniprogram/images/applocat.png new file mode 100644 index 0000000..fe49f54 --- /dev/null +++ b/miniprogram/images/applocat.png Binary files differ diff --git a/miniprogram/images/back.png b/miniprogram/images/back.png new file mode 100644 index 0000000..32ac82d --- /dev/null +++ b/miniprogram/images/back.png Binary files differ diff --git a/miniprogram/images/bottom.png b/miniprogram/images/bottom.png new file mode 100644 index 0000000..d910e98 --- /dev/null +++ b/miniprogram/images/bottom.png Binary files differ diff --git a/miniprogram/images/header.png b/miniprogram/images/header.png new file mode 100644 index 0000000..6ea222e --- /dev/null +++ b/miniprogram/images/header.png Binary files differ diff --git a/miniprogram/images/login.png b/miniprogram/images/login.png index 8b73cc0..6471c46 100644 --- a/miniprogram/images/login.png +++ b/miniprogram/images/login.png Binary files differ diff --git a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss index 5a591fb..c9c35b5 100644 --- a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss +++ b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:100%;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:100%}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file +@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:650rpx;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:600rpx}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file diff --git a/miniprogram/pages/addDevice/addDevice.js b/miniprogram/pages/addDevice/addDevice.js index 2783674..78f00b7 100644 --- a/miniprogram/pages/addDevice/addDevice.js +++ b/miniprogram/pages/addDevice/addDevice.js @@ -1,5 +1,7 @@ // miniprogram/pages/addDevice/addDevice.js // import WxValidate from '../../utils/WxValidate.js' +var QQMapWX = require('../../libs/qqmap-wx-jssdk.js'); +var qqmapsdk; var app = getApp() Page({ @@ -11,32 +13,10 @@ canvasWidth: '', longitude: '', latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], + option1: [], personoption1: [], projectoption: [], + devtypeList:[], show: false, form: { devcode: "", @@ -59,7 +39,10 @@ project: "", area: "", street: "", - wellname: "" + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '', }, fileList: [] }, @@ -117,12 +100,14 @@ var that = this; //初始化表单内容为上次填写值 var cacheForms = wx.getStorageSync('cacheList') - if (cacheForms) { + cacheForms.photopath1='' + cacheForms.photopath2='' + cacheForms.photopath3='' + that.data.fileList=[] that.setData({ form: cacheForms, devcode: cacheForms.devcode, - }) } var form = that.data.form @@ -155,55 +140,89 @@ } }) + +//获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + that.setData({ + option1: welltypeArr + }) + } + } +}) + + //获取人员下拉列表 - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/getUser", + data:{ + tips:'repair' }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data.code == 200) { + var users = res.data.data + var personArr = []; + for (var i = 0; i < users.length; i++) { + var person = { + text: users[i].name, + value: users[i].name + }; + personArr.push(person); + } + that.setData({ + personoption1: personArr + }) } - that.setData({ - personoption1: personArr - }) } - }).catch(err => { - console.error(err); - }) + }) + - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - that.setData({ - projectoption: projectArr - }) + success(res){ + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); + } + that.setData({ + projectoption: projectArr + }) + } } - }).catch(err => { - console.error(err); - }) + }) + var installtime = 'form.installtimeFmt'; var dateNow = this.formatDate(); this.setData({ @@ -211,8 +230,40 @@ installtimeFmt: dateNow, [installtime]: dateNow, }); + + + + /** + * 获取设备类型下拉列表 + */ + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/deviceType", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var TypeList = res.data.data + var typeArr = []; + for (var i = 0; i < TypeList.length; i++) { + var type = { + text: TypeList[i].productName, + value: TypeList[i].productName + }; + typeArr.push(type); + } + that.setData({ + devtypeList: typeArr + }) + } + } + }) }, + + + /** * 生命周期函数--监听页面初次渲染完成 */ @@ -280,29 +331,7 @@ }, - - //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 - drawText: function (ctx, str, leftWidth, initHeight, titleHeight, canvasWidth) { - var lineWidth = 0; - var lastSubStrIndex = 0; //每次开始截取的字符串的索引 - for (let i = 0; i < str.length; i++) { - lineWidth += ctx.measureText(str[i]).width; - if (lineWidth > canvasWidth) { - ctx.fillText(str.substring(lastSubStrIndex, i), leftWidth, initHeight); //绘制截取部分 - initHeight = initHeight + leftWidth * 2; //22为字体的高度 - lineWidth = 0; - lastSubStrIndex = i; - // titleHeight += 40; - } - if (i == str.length - 1) { //绘制剩余部分 - ctx.fillText(str.substring(lastSubStrIndex, i + 1), leftWidth, initHeight); - } - } - // // 标题border-bottom 线距顶部距离 - // titleHeight = titleHeight + 10; - // return titleHeight - }, - + //验证表单 formValidate() { if (this.data.form.devcode == "") { @@ -312,27 +341,20 @@ }) return false } - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } if (this.data.form.wellcode == "") { wx.showToast({ icon: 'none', @@ -348,22 +370,10 @@ }) return false } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null) { + + if (this.data.form.installperson == "") { wx.showToast({ icon: 'none', title: '安装人员不能为空!', @@ -408,56 +418,90 @@ } return true; }, + //提交表单 formSubmit: function (event) { + console.log(this.data.form) + //表单参数验证 if (!this.formValidate()) { return false; } var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDevice', + //验证设备编号长度 + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/getDevTypeLength", data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceAdd/add" + code: encodeURI(this.data.form.devicetype) }, - }).then(res => { - if (res.result.code == 500) { - wx.showToast({ - title: '设备编号已安装!', - }) - } else if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - //用于回显 - wx.setStorageSync('cacheList', that.data.form) - //提交成功后提示用户操作 - if (res.confirm) { - wx.switchTab({ - url: '../earth/earth' - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (""==res.data.data ||res.data.data == that.data.form.devcode.length) { + that.saveDevice() + } else { //编号位数不对提示 + wx.showToast({ + icon: 'none', + title: '设备编号位数不对!', + duration: 1000 + }) + return false + } } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "提交失败", - }) }) }, + + //保存设备基本信息 + saveDevice() { + var that = this; + //设置照片路径 + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopathForm = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopathForm]: fileList[i].url.split("static/")[1] + }) + } + //表单提交 + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 500) { + wx.showToast({ + title: '设备编号已安装!', + }) + } else if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + //用于回显 + wx.setStorageSync('cacheList', that.data.form) + //提交成功后提示用户操作 + if (res.confirm) { + wx.switchTab({ + url: '../earth/earth' + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } + }, + fail(err) { + wx.showToast({ + title: '提交失败!', + }) + } + }) + }, + + //input 输入框设置值 confirm(event) { var that = this; var formValue = event.detail.value; @@ -466,8 +510,30 @@ that.setData({ [fromN]: formValue }) + //若输入是设备编号,自动获取设备类型 + if('devcode'==formName){ + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", + data: { + devcode: formValue, + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + that.setData({ + [formDevicetype]: res.data + }); + } + } + }) + } }, + //扫描设备获取编号和设备类型 scan() { var _this = this; wx.scanCode({ @@ -477,23 +543,28 @@ _this.setData({ [formdevcode]: devcode }); - wx.cloud.callFunction({ - name: 'findModeCode', + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", data: { devcode: devcode, - url: app.globalData.url + "appDeviceAdd/findModeCodeByCode" }, - }).then(res => { - if (res.result) { - var formDevicetype = 'form.devicetype' - _this.setData({ - [formDevicetype]: res.result - }); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + _this.setData({ + [formDevicetype]: res.data + }); + } } }) } }) }, + //粘贴经纬度 paste() { var _this = this; wx.getClipboardData({ @@ -510,9 +581,11 @@ longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), }); + _this.showAddress(_this.data.form.longitude,_this.data.form.latitude,_this) } }) }, + //设置经类型 selectValue(value) { var that = this; @@ -521,6 +594,16 @@ [wellType]: value.detail }) }, + + //设置设备类型 + selectDevType(event) { + var that = this; + var devtype = 'form.devicetype'; + that.setData({ + [devtype]: event.detail + }) + }, + //设置运维人员 selectpersonValue(event) { var that = this; var installPerson = 'form.installperson'; @@ -528,6 +611,7 @@ [installPerson]: event.detail }) }, + //设置项目 selectprojectValue(event) { var that = this; var project = 'form.project'; @@ -535,8 +619,41 @@ [project]: event.detail }) }, + showAddress :function(longitude, latitude, self) { + // 实例化腾讯地图API核心类 + qqmapsdk = new QQMapWX({ + key: 'BGPBZ-C5O3P-ROUDR-LWC4J-63EKH-V5FRX'//此处使用你自己申请的key + }) + // 腾讯地图调用接口 + qqmapsdk.reverseGeocoder({ + location: { + latitude: latitude, + longitude: longitude + }, + success: function (res) { + self.setData({ + 'form.area':res.result.address.slice(0,res.result.address.indexOf('区')+1), + 'form.street':res.result.address.slice(res.result.address.indexOf('区')+1) + }) + }, + fail: function (res) { + console.log(res); + }, + complete: function (res) { + } + }); + }, + //上传照片 afterRead(event) { var _this = this; + if (_this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '请先填写设备编号!\r\n否则水印中无编号', + duration: 2000 + }) + return false + } const { file } = event.detail; @@ -576,78 +693,8 @@ }) } }) - // 压缩图片 - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // //获取图片尺寸 - // wx.getImageInfo({ - // src: convertpath, - // success(res) { - // _this.setData({ - // canvasHeight: res.height, - // canvasWidth: res.width - // }) - // var ctx = wx.createCanvasContext('firstCanvas') - - // //将图片src放到cancas内,宽高为图片大小 - // ctx.drawImage(convertpath, 0, 0, res.width, res.height) - // //将声明的时间放入canvas - // ctx.setFontSize(30 * (res.width / 750)) //注意:设置文字大小必须放在填充文字之前,否则不生效 - // ctx.setFillStyle('blue') - // var text = "编号:" + _this.data.form.devcode + "\n经度:" + _this.data.form.longitude + "\n纬度:" + _this.data.form.latitude - // // _this.drawText(ctx,text,20, 70, 5, res.width) - // _this.drawText(ctx, text, 15 * (res.width / 750), 70 * (res.width / 750), 5, res.width) - - // // ctx.fillText(text, 0, 40) - // // ctx.strokeText(_this.data.form.devcode, 0, 30) - // //生成水印图 - // ctx.draw(false, function () { - // wx.canvasToTempFilePath({ - // canvasId: 'firstCanvas', - // success: (res) => { - // wx.compressImage({ - // src: res.tempFilePath, - // quality: 25, - // success: function (res) { - // //上传照片至服务器 - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: res.tempFilePath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // } - // }) - // //// - // } - // }) - // }) - // } - // }) - // } - // }); }, + //删除照片 deletePhoto(event) { var image_index = event.detail.index var fileList_new = this.data.fileList; diff --git a/miniprogram/pages/addDevice/addDevice.wxml b/miniprogram/pages/addDevice/addDevice.wxml index b0977e2..f12c254 100644 --- a/miniprogram/pages/addDevice/addDevice.wxml +++ b/miniprogram/pages/addDevice/addDevice.wxml @@ -5,18 +5,30 @@ - + + + + + + + + + + + + + - - + + - - - + + + @@ -29,13 +41,13 @@ - + - + - + - + @@ -54,8 +66,7 @@ - - + @@ -68,8 +79,8 @@ - - + + - 保存 + 保存 \ No newline at end of file diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.js b/miniprogram/pages/addDevicelog/addDeviceLog.js index cdec71b..a0dc6da 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.js +++ b/miniprogram/pages/addDevicelog/addDeviceLog.js @@ -3,681 +3,665 @@ var app = getApp(); Page({ - /** - * 页面的初始数据 - */ - data: { - pageName: '', - showMask: false, - today: new Date().getTime(), - longitude: '', - latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], - personoption1: [], - projectoption: [], - devcode: "", - deviceMode: "", - installtimeFmt: '', - show: false, - form: { - devcode: "", - wellcode: "", - welltype: "", - welldepth: "", - installheigt: "", - installperson: "", - installtimeFmt: "", - photopath: "", - factory: "", - workmsg: "", - position: "", - description: "", - longitude: "", - latitude: "", - longitude84: "", - latitude84: "", - devicetype: "", - project: "", - area: "", - street: "", - wellname: "" - }, - fileList: [], - detail: "" - }, + /** + * 页面的初始数据 + */ + data: { + pageName: '', + showMask: false, + today: new Date().getTime(), + longitude: '', + latitude: '', + option1: [], + personoption1: [], + projectoption: [], + devcode: "", + deviceMode: "", + installtimeFmt: '', + show: false, + form: { + devcode: "", + wellcode: "", + welltype: "", + welldepth: "", + installheigt: "", + installperson: "", + installtimeFmt: "", + photopath: "", + factory: "", + workmsg: "", + position: "", + description: "", + longitude: "", + latitude: "", + longitude84: "", + latitude84: "", + devicetype: "", + project: "", + area: "", + street: "", + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '' + }, + fileList: [], + detail: "", + markers: [{ + id: 100, + // iconPath: "../../images/point.png", + latitude: '', + longitude: '', + // label:'1', + width: 25, + height: 35 + }], + }, - onDisplay() { - this.setData({ - show: true - }); - }, - onClose() { - this.setData({ - show: false - }); - }, - formatDate() { - var date = new Date(); - // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; - var seperator1 = "-"; - var month = date.getMonth() + 1; - var strDate = date.getDate(); - var hour = date.getHours() - var minute = date.getMinutes() - var second = date.getSeconds() - month = month > 9 ? month : "0" + month; - strDate = strDate > 9 ? strDate : "0" + strDate; - hour = hour > 9 ? hour : "0" + hour; - minute = minute > 9 ? minute : "0" + minute; - second = second > 9 ? second : "0" + second; - var currentdate = - date.getFullYear() + - seperator1 + - month + - seperator1 + - strDate + - " " + - hour + ":" + - minute + ":" + - second; - return currentdate; + onDisplay() { + this.setData({ + show: true + }); + }, + onClose() { + this.setData({ + show: false + }); + }, + formatDate() { + var date = new Date(); + // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; + var seperator1 = "-"; + var month = date.getMonth() + 1; + var strDate = date.getDate(); + var hour = date.getHours() + var minute = date.getMinutes() + var second = date.getSeconds() + month = month > 9 ? month : "0" + month; + strDate = strDate > 9 ? strDate : "0" + strDate; + hour = hour > 9 ? hour : "0" + hour; + minute = minute > 9 ? minute : "0" + minute; + second = second > 9 ? second : "0" + second; + var currentdate = + date.getFullYear() + + seperator1 + + month + + seperator1 + + strDate + + " " + + hour + ":" + + minute + ":" + + second; + return currentdate; - }, - onConfirm(event) { - var installtime = 'form.installtimeFmt'; - this.setData({ - show: false, - installtimeFmt: this.formatDate(event.detail), - [installtime]: this.formatDate(event.detail), - }); - }, + }, + onConfirm(event) { + var installtime = 'form.installtimeFmt'; + this.setData({ + show: false, + installtimeFmt: this.formatDate(event.detail), + [installtime]: this.formatDate(event.detail), + }); + }, - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - var _this = this; - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" - }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); - } - _this.setData({ - personoption1: personArr - }) + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + var _this = this; + _this.setData({ + 'markers[0].latitude': Number(wx.getStorageSync('resultObject').latitude) , + 'markers[0].longitude': Number(wx.getStorageSync('resultObject').longitude), + // 'markers[0].label':'10', + 'markers[0].width': 18, + 'markers[0].id':1, + 'markers[0].height': 30, + latitude:Number(wx.getStorageSync('resultObject').latitude), + longitude:Number(wx.getStorageSync('resultObject').longitude) + }) + //获取人员下拉列表 + // wx.request({ + // method: "POST", + // url: app.globalData.httpsUrl + "deviceType/getUser", + // data:{ + // tips:'repair' + // }, + // header: { + // 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + // }, + // success(res) { + // if (res.data.code == 200) { + // var users = res.data.data + // var personArr = []; + // for (var i = 0; i < users.length; i++) { + // var person = { + // text: users[i].name, + // value: users[i].name + // }; + // personArr.push(person); + // } + // _this.setData({ + // personoption1: personArr + // }) + // } + // } + // }) + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); } - }).catch(err => { - console.error(err); - }) - - - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" - }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - _this.setData({ - projectoption: projectArr - }) - } - }).catch(err => { - console.error(err); - }) - - if (options.pageName) { - this.setData({ - pageName: options.pageName - }) - } - - if (options.detail) { - - var formObject = JSON.parse(options.detail); _this.setData({ - form: formObject, - detail: options.detail + projectoption: projectArr }) - - _this.setData({ - ['form.installperson']: "", - ['form.installtimeFmt']: "", - ['form.workmsg']: "", - ['form.description']: "" - }) - - const { - fileList = [] - } = _this.data; - if (formObject.photopath1 != "") { - var file1 = { - url: app.globalData.url + "static/" + formObject.photopath1 - } - fileList.push(file1) - } - if (formObject.photopath2 != "") { - var file2 = { - url: app.globalData.url + "static/" + formObject.photopath2 - } - fileList.push(file2) - } - if (formObject.photopath3 != "") { - var file3 = { - url: app.globalData.url + "static/" + formObject.photopath3 - } - fileList.push(file3) - } - - _this.setData({ - fileList - }); } - var installtime = 'form.installtimeFmt'; - var dateNow = this.formatDate(); - this.setData({ - installtimeFmt: dateNow, - [installtime]: dateNow, - }); - }, + } + }) - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { + //获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + _this.setData({ + option1: welltypeArr + }) + } + } +}) - }, + //跳转时带入参数返回哪页 + if (options.pageName) { + this.setData({ + pageName: options.pageName + }) + } + //跳转时带入参数设备的安装信息 + if (wx.getStorageSync('resultObject')) { + var formObject = wx.getStorageSync('resultObject') + _this.setData({ + form: formObject, + detail: formObject + }) - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { + _this.setData({ + ['form.installperson']: app.globalData.userName, + ['form.installtimeFmt']: "", + ['form.workmsg']: "", + ['form.description']: "" + }) - }, + const { + fileList = [] + } = _this.data; + if (formObject.photopath1 != "") { + var file1 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath1 + } + fileList.push(file1) + } + if (formObject.photopath2 != "") { + var file2 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath2 + } + fileList.push(file2) + } + if (formObject.photopath3 != "") { + var file3 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath3 + } + fileList.push(file3) + } + _this.setData({ + fileList + }); + } + var installtime = 'form.installtimeFmt'; + var dateNow = this.formatDate(); + this.setData({ + installtimeFmt: dateNow, + [installtime]: dateNow, + }); + }, - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, - }, + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + wx.removeStorageSync('resultObject') + }, - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, - }, + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { + }, - }, + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { + }, - }, + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { + }, - }, + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + }, - /** - * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true - **/ + /** + * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true + **/ - isNumber: function (val) { + isNumber: function (val) { - var regPos = /^[0-9]*$/; //非负浮点数 - var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数 - if (regPos.test(val) || regNeg.test(val)) { - return false; - } else { - return true; - } + var regPos = /^[0-9]*$/; //非负浮点数 + var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数 + if (regPos.test(val) || regNeg.test(val)) { + return false; + } else { + return true; + } - }, + }, - formValidate() { + formValidate() { - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } - if (this.data.form.wellcode == "") { - wx.showToast({ - icon: 'none', - title: '井编号不能为空!', - }) - return false - } - if (this.data.form.devicetype == "") { - wx.showToast({ - icon: 'none', - title: '设备类型不能为空!', - }) - return false - } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + if (this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '设备编号不能为空!', + }) + return false + } + if (this.data.form.wellcode == "") { + wx.showToast({ + icon: 'none', + title: '井编号不能为空!', + }) + return false + } + if (this.data.form.devicetype == "") { + wx.showToast({ + icon: 'none', + title: '设备类型不能为空!', + }) + return false + } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null || - this.data.form.installperson == '') { - wx.showToast({ - icon: 'none', - title: '运维人员不能为空!', - }) - return false - } - if (this.data.form.project == "") { - wx.showToast({ - icon: 'none', - title: '所属项目不能为空!', - }) - return false - } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } + if (this.data.form.installperson == null || + this.data.form.installperson == '') { + wx.showToast({ + icon: 'none', + title: '运维人员不能为空!', + }) + return false + } + if (this.data.form.project == "") { + wx.showToast({ + icon: 'none', + title: '所属项目不能为空!', + }) + return false + } - if (this.data.form.welldepth != null) { - if (this.isNumber(this.data.form.welldepth)) { - wx.showToast({ - icon: 'none', - title: '井深必须为数值!', - }) - return false - } - } - if (this.data.form.installheigt != null) { - if (this.isNumber(this.data.form.installheigt)) { - wx.showToast({ - icon: 'none', - title: '到井口距离必须为数值!', - }) - return false - } - } - - return true; - }, - - changeMsg: function () { - var formNew = this.data.form; - var formOld = JSON.parse(this.data.detail); - var descpNew = ""; - if (formNew.devcode != formOld.devcode) { - descpNew += "修改设备编号,原编号:" + formOld.devcode + ",新编号:" + formNew.devcode + ";" - } - if (formNew.devicetype != formOld.devicetype) { - descpNew += "修改设备类型,原设备类型:" + formOld.devicetype + ",新设备类型:" + formNew.devicetype + ";" - } - if (formNew.area != formOld.area) { - descpNew += "修改区,原区:" + formOld.area + ",新区:" + formNew.area + ";" - } - if (formNew.street != formOld.street) { - descpNew += "修改街道,原街道:" + formOld.street + ",新街道:" + formNew.street + ";" - } - if (formNew.wellname != formOld.wellname) { - descpNew += "修改井名称,原井名称:" + formOld.wellname + ",新井名称:" + formNew.wellname + ";" - } - if (formNew.factory != formOld.factory) { - descpNew += "修改权属单位,原权属单位:" + formOld.factory + ",新权属单位:" + formNew.factory + ";" - } - if (formNew.installheigt != formOld.installheigt) { - descpNew += "修改井口距离,原井口距离:" + formOld.installheigt + ",新井口距离:" + formNew.installheigt + ";" - } - if (formNew.installperson != formOld.installperson) { - descpNew += "修改运维人员,原运维人员:" + formOld.installperson + ",新运维人员:" + formNew.installperson + ";" - } - if (formNew.latitude != formOld.latitude) { - descpNew += "修改纬度,原纬度:" + formOld.latitude + ",新纬度:" + formNew.latitude + ";" - } - if (formNew.longitude != formOld.longitude) { - descpNew += "修改经度,原经度:" + formOld.longitude + ",新经度:" + formNew.longitude + ";" - } - if (formNew.position != formOld.position) { - descpNew += "修改位置描述,原位置:" + formOld.position + ",新位置:" + formNew.position + ";" - } - if (formNew.wellcode != formOld.wellcode) { - descpNew += "修改井编号,原编号:" + formOld.wellcode + ",新编号:" + formNew.wellcode + ";" - } - if (formNew.welldepth != formOld.welldepth) { - descpNew += "修改井深,原井深:" + formOld.welldepth + ",新井深:" + formNew.welldepth + ";" - } - if (formNew.welltype != formOld.welltype) { - descpNew += "修改井类型,原井类型:" + formOld.welltype + ",新井类型:" + formNew.welltype + ";" - } - if (formNew.project != formOld.project) { - descpNew += "修改所属项目,原项目:" + formOld.project + ",新项目:" + formNew.project + ";" - } - if (this.data.photopath1 != formOld.photopath1 || - this.data.photopath2 != formOld.photopath2 || - this.data.photopath3 != formOld.photopath3) { - descpNew += "修改照片;" - } - if ("" != formNew.description) { - descpNew += formNew.description; - } - this.setData({ - ['form.description']: descpNew + if (this.data.form.welldepth != null) { + if (this.isNumber(this.data.form.welldepth)) { + wx.showToast({ + icon: 'none', + title: '井深必须为数值!', }) - }, + return false + } + } + if (this.data.form.installheigt != null) { + if (this.isNumber(this.data.form.installheigt)) { + wx.showToast({ + icon: 'none', + title: '到井口距离必须为数值!', + }) + return false + } + } - formSubmit: function (event) { + return true; + }, - if (!this.formValidate()) { - return false; - } - this.changeMsg(); - var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDeviceLog', - data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceLog/add" - }, - }).then(res => { - // var resultObj=JSON.parse(res.result); - if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - if (res.confirm) { - wx.switchTab({ - url: that.data.pageName - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) - } - }).catch(err => { - console.error(err) - wx.showToast({ - title: "提交失败", - }) - }) - }, - confirm(event) { - var that = this; - var formValue = event.detail.value; - var formName = event.target.dataset.id; - var fromN = 'form.' + [formName]; - that.setData({ - [fromN]: formValue - }) - }, + //获取与上次修改的信息 + changeMsg: function () { + var formNew = this.data.form; + console.log(this.data.detail) + var formOld = JSON.parse(this.data.detail); + var descpNew = ""; + if (formNew.devcode != formOld.devcode) { + descpNew += "修改设备编号,原值:" + formOld.devcode + ",新值:" + formNew.devcode + ";" + } + if (formNew.devicetype != formOld.devicetype) { + descpNew += "修改设备类型,原值:" + formOld.devicetype + ",新值:" + formNew.devicetype + ";" + } + if (formNew.area != formOld.area) { + descpNew += "修改区,原值:" + formOld.area + ",新值:" + formNew.area + ";" + } + if (formNew.street != formOld.street) { + descpNew += "修改街道,原值:" + formOld.street + ",新值:" + formNew.street + ";" + } + if (formNew.wellname != formOld.wellname) { + descpNew += "修改井名称,原值:" + formOld.wellname + ",新值:" + formNew.wellname + ";" + } + if (formNew.factory != formOld.factory) { + descpNew += "修改权属单位,原值:" + formOld.factory + ",新值:" + formNew.factory + ";" + } + if (formNew.installheigt != formOld.installheigt) { + descpNew += "修改井口距离,原值:" + formOld.installheigt + ",新值:" + formNew.installheigt + ";" + } + if (formNew.installperson != formOld.installperson) { + descpNew += "修改运维人员,原值:" + formOld.installperson + ",新值:" + formNew.installperson + ";" + } + if (formNew.latitude != formOld.latitude) { + descpNew += "修改纬度,原值:" + formOld.latitude + ",新值:" + formNew.latitude + ";" + } + if (formNew.longitude != formOld.longitude) { + descpNew += "修改经度,原值:" + formOld.longitude + ",新值:" + formNew.longitude + ";" + } + if (formNew.position != formOld.position) { + descpNew += "修改位置描述,原值:" + formOld.position + ",新值:" + formNew.position + ";" + } + if (formNew.wellcode != formOld.wellcode) { + descpNew += "修改井编号,原值:" + formOld.wellcode + ",新值:" + formNew.wellcode + ";" + } + if (formNew.welldepth != formOld.welldepth) { + descpNew += "修改井深,原值:" + formOld.welldepth + ",新值:" + formNew.welldepth + ";" + } + if (formNew.welltype != formOld.welltype) { + descpNew += "修改井类型,原值:" + formOld.welltype + ",新值:" + formNew.welltype + ";" + } + if (formNew.project != formOld.project) { + descpNew += "修改所属项目,原值:" + formOld.project + ",新值:" + formNew.project + ";" + } + if (this.data.form.photopath1 != formOld.photopath1 || + this.data.form.photopath2 != formOld.photopath2 || + this.data.form.photopath3 != formOld.photopath3) { + descpNew += "修改照片;" + } + if ("" != formNew.description) { + descpNew += formNew.description; + } + this.setData({ + ['form.description']: descpNew + }) + }, - scan() { + //提交表单 + formSubmit: function (event) { - wx.scanCode({ - success(res) { - console.log(res) - } - }) + //表单验证 + if (!this.formValidate()) { + return false; + } + //自动生成修改内容 + this.changeMsg(); + //提交权限限制(只有施工人员能修改) + if(app.globalData.role!='repair'){ + wx.showToast({ + icon: 'none', + title: '无权限修改', + duration:2000 + }) + return false + } + var that = this; + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopath = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopath]: fileList[i].url.split("static/")[1] + }) + } + delete that.data.form.installtime + delete that.data.form.createtime + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - paste() { - var _this = this; - wx.getClipboardData({ - success: function (res) { - var longitude = 'form.longitude'; - var latitude = 'form.latitude'; - var longitude84 = 'form.longitude84'; - var latitude84 = 'form.latitude84'; - _this.setData({ - [longitude]: parseFloat(res.data.split(",", 4)[1]).toFixed(6), - [latitude]: parseFloat(res.data.split(",", 4)[0]).toFixed(6), - [longitude84]: "" == (res.data.split(",", 4)[3]) ? "" : parseFloat(res.data.split(",", 4)[3]).toFixed(6), - [latitude84]: "" == (res.data.split(",", 4)[2]) ? "" : parseFloat(res.data.split(",", 4)[2]).toFixed(6), - longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), - latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), - }); - } - }) - }, - selectValue(value) { - var that = this; - var wellType = 'form.welltype'; - that.setData({ - [wellType]: value.detail - }) - }, - selectpersonValue(event) { - var that = this; - var installPerson = 'form.installperson'; - that.setData({ - [installPerson]: event.detail - }) - }, - selectprojectValue(event) { - var that = this; - var project = 'form.project'; - that.setData({ - [project]: event.detail, - showMask: true - }) - }, - open() { - this.setData({ - showMask: true - }) - }, - close() { - this.setData({ - showMask: false - }) - }, - afterRead(event) { - var _this = this; - const { - file - } = event.detail; - const { - fileList = [] - } = _this.data; - var convertpath = ""; - wx.compressImage({ - src: event.detail.file.path, - quality: 25, - success: function (res) { - convertpath = res.tempFilePath; - wx.uploadFile({ - url: app.globalData.httpsUrl + "appDeviceAdd/fileUploadMarker", - filePath:convertpath, - name: 'file', - formData: { - 'text': "编号:" + _this.data.form.devcode + "经度:" + _this.data.form.longitude + "纬度:" + _this.data.form.latitude - }, - header: { - "Content-Type": "multipart/form-data", - 'accept': 'application/json', - }, - success(res) { - if (res.data) { - var url = JSON.parse(res.data); - fileList.push({ - ...file, - url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - }); - _this.setData({ - fileList - }); - } - } + success(res) { + if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + if (res.confirm) { + wx.switchTab({ + url: that.data.pageName }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') } - }) - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // // var base64 = "data:image/png;base64," + wx.getFileSystemManager().readFileSync(convertpath, 'base64'); - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: convertpath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // // wx.cloud.callFunction({ - // // name: 'uploadFile', - // // data: { - // // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // // fileBase64: base64 - // // }, - // // success: function (res) { - // // if (res.result) { - // // fileList.push({ - // // ...file, - // // url: app.globalData.url + "static/" + res.result.data.replace(/\\/g, "/") - // // }); - // // _this.setData({ - // // fileList - // // }); - // // } - // // }, - // // complete: res => { - // // }, - // // }) - // } - // }); + } + }) + } + }, + fail(err) { + wx.showToast({ + title: "提交失败", + }) + } + }) + }, + //报存录入的input信息 + confirm(event) { + var that = this; + var formValue = event.detail.value; + var formName = event.target.dataset.id; + var fromN = 'form.' + [formName]; + that.setData({ + [fromN]: formValue + }) + }, + + //扫码 + scan() { + + wx.scanCode({ + success(res) { + console.log(res) + } + }) + }, + //粘贴经纬度 + paste() { + var _this = this; + wx.getClipboardData({ + success: function (res) { + var longitude = 'form.longitude'; + var latitude = 'form.latitude'; + var longitude84 = 'form.longitude84'; + var latitude84 = 'form.latitude84'; + _this.setData({ + [longitude]: parseFloat(res.data.split(",", 4)[1]).toFixed(6), + [latitude]: parseFloat(res.data.split(",", 4)[0]).toFixed(6), + [longitude84]: "" == (res.data.split(",", 4)[3]) ? "" : parseFloat(res.data.split(",", 4)[3]).toFixed(6), + [latitude84]: "" == (res.data.split(",", 4)[2]) ? "" : parseFloat(res.data.split(",", 4)[2]).toFixed(6), + longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), + latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), + }); + } + }) + }, + selectValue(value) { + var that = this; + var wellType = 'form.welltype'; + that.setData({ + [wellType]: value.detail + }) + }, + //运维人员默认为登录人 + // selectpersonValue(event) { + // var that = this; + // var installPerson = 'form.installperson'; + // that.setData({ + // [installPerson]: event.detail + // }) + // }, + selectprojectValue(event) { + var that = this; + var project = 'form.project'; + that.setData({ + [project]: event.detail, + showMask: true + }) + }, + + open() { + this.setData({ + showMask: true + }) + }, + //隐藏textarea,防止遮挡 + close() { + this.setData({ + showMask: false + }) + }, + //上传照片 + afterRead(event) { + var _this = this; + const { + file + } = event.detail; + const { + fileList = [] + } = _this.data; + var convertpath = ""; + wx.compressImage({ + src: event.detail.file.path, + quality: 25, + success: function (res) { + convertpath = res.tempFilePath; + wx.uploadFile({ + url: app.globalData.httpsUrl + "appDeviceAdd/fileUploadMarker", + filePath: convertpath, + name: 'file', + formData: { + 'text': "编号:" + _this.data.form.devcode + "经度:" + _this.data.form.longitude + "纬度:" + _this.data.form.latitude }, - deletePhoto(event) { - var that = this - var image_index = event.detail.index - var fileList_new = that.data.fileList; - wx.showModal({ - content: '确定删除照片?', - success: function (res) { - if (res.confirm) { - fileList_new.splice(image_index, 1); - that.setData({ - fileList: fileList_new - }) - wx.cloud.callFunction({ - name: 'deletePhoto', - data: { - url: app.globalData.url + "appDeviceLog/deletePhoto", - devcode: that.data.form.devcode, - pathIndex: image_index - }, - success: function (res) {}, - complete: res => {}, - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + "Content-Type": "multipart/form-data", + 'accept': 'application/json', }, - }) \ No newline at end of file + success(res) { + if (res.data) { + var url = JSON.parse(res.data); + fileList.push({ + ...file, + url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") + }); + _this.setData({ + fileList + }); + } + } + }) + } + }) + }, + //删除照片 + deletePhoto(event) { + var that = this + var image_index = event.detail.index + var fileList_new = that.data.fileList; + wx.showModal({ + content: '确定删除照片?', + success: function (res) { + if (res.confirm) { + fileList_new.splice(image_index, 1); + that.setData({ + fileList: fileList_new + }) + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deletePhoto", + data: { + devcode: that.data.form.devcode + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) {} + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } +}) \ No newline at end of file diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.wxml b/miniprogram/pages/addDevicelog/addDeviceLog.wxml index 38620d4..b10cc7d 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.wxml +++ b/miniprogram/pages/addDevicelog/addDeviceLog.wxml @@ -1,15 +1,21 @@ - + + + + + - + - - + + - - + + - + @@ -39,24 +45,25 @@ - - - + + + - + - + + @@ -64,7 +71,7 @@ - + @@ -79,9 +86,9 @@ - + - 保存 + 保存 diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.wxss b/miniprogram/pages/addDevicelog/addDeviceLog.wxss index ee0b75c..08d5fd7 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.wxss +++ b/miniprogram/pages/addDevicelog/addDeviceLog.wxss @@ -24,6 +24,17 @@ display: flex; align-items: center; } +.map-view{ + width: 750rpx; + height: 485rpx; + position: fixed; + top: 0px; + left: 0px; + z-index: 999; +} +.content{ + margin-top: 495rpx; +} .left { width: 210rpx; diff --git a/miniprogram/pages/addFunction/addFunction.js b/miniprogram/pages/addFunction/addFunction.js deleted file mode 100644 index 4966be3..0000000 --- a/miniprogram/pages/addFunction/addFunction.js +++ /dev/null @@ -1,60 +0,0 @@ -// pages/addFunction/addFunction.js - -const code = `// 云函数入口函数 -exports.main = (event, context) => { - console.log(event) - console.log(context) - return { - sum: event.a + event.b - } -}` - -Page({ - - data: { - result: '', - canIUseClipboard: wx.canIUse('setClipboardData'), - }, - - onLoad: function (options) { - - }, - - copyCode: function() { - wx.setClipboardData({ - data: code, - success: function () { - wx.showToast({ - title: '复制成功', - }) - } - }) - }, - - testFunction() { - wx.cloud.callFunction({ - name: 'sum', - data: { - a: 1, - b: 2 - }, - success: res => { - wx.showToast({ - title: '调用成功', - }) - this.setData({ - result: JSON.stringify(res.result) - }) - }, - fail: err => { - wx.showToast({ - icon: 'none', - title: '调用失败', - }) - console.error('[云函数] [sum] 调用失败:', err) - } - }) - }, - -}) - diff --git a/miniprogram/pages/addFunction/addFunction.json b/miniprogram/pages/addFunction/addFunction.json deleted file mode 100644 index a9a50c5..0000000 --- a/miniprogram/pages/addFunction/addFunction.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "navigationBarTitleText": "云函数指引", - "usingComponents": {} -} \ No newline at end of file diff --git a/miniprogram/pages/addFunction/addFunction.wxml b/miniprogram/pages/addFunction/addFunction.wxml deleted file mode 100644 index 3a10626..0000000 --- a/miniprogram/pages/addFunction/addFunction.wxml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - 测试云函数 - - - 期望输出:{"sum":3} - - - 调用结果:{{result}} - - - - - 新增云函数 - 1. 在云函数根目录 cloudfunctions 上右键选择新建云函数,命名为 sum - 2. 在创建的 cloudfunctions/sum/index.js 文件中添加如下代码 - - - 3. 在 cloudfunctions/sum 目录上右键上传并部署 - 4. 点击测试云函数测试 - 5. 打开云开发云函数管理页,选择 sum 云函数 - 6. 查看 sum 的调用日志 - 进阶:可在云函数中使用 wx-server-sdk 操作数据库,文件存储和调用其他云函数,详见文档 - - - diff --git a/cloudfunctions/project.config.json b/cloudfunctions/project.config.json new file mode 100644 index 0000000..2b3119a --- /dev/null +++ b/cloudfunctions/project.config.json @@ -0,0 +1,28 @@ +{ + "appid": "wx2cef527a000f87c9", + "compileType": "miniprogram", + "libVersion": "2.27.3", + "packOptions": { + "ignore": [], + "include": [] + }, + "setting": { + "coverView": true, + "es6": true, + "postcss": true, + "minified": true, + "enhance": true, + "showShadowRootInWxmlPanel": true, + "packNpmRelationList": [], + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + } + }, + "condition": {}, + "editorSetting": { + "tabIndent": "insertSpaces", + "tabSize": 4 + } +} \ No newline at end of file diff --git a/cloudfunctions/project.private.config.json b/cloudfunctions/project.private.config.json new file mode 100644 index 0000000..42ff49d --- /dev/null +++ b/cloudfunctions/project.private.config.json @@ -0,0 +1,7 @@ +{ + "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", + "projectname": "cloudfunctions", + "setting": { + "compileHotReLoad": true + } +} \ No newline at end of file diff --git a/miniprogram/app.js b/miniprogram/app.js index 51d56f3..50a8a54 100644 --- a/miniprogram/app.js +++ b/miniprogram/app.js @@ -18,13 +18,15 @@ // this.globalData = {} }, globalData: { - // url: "http://111.198.10.15:11604/", - httpsUrl: "https://logapi.smartlog.work/", - httpsTestUrl: "https://smartlog.work/prodapi4test/", - url: "http://139.198.18.188:8083/", + httpsUrl: "https://logapi.smartlog.work/", + // httpsUrl: "http://139.198.18.188:8083/", // url: "http://127.0.0.1:8083/", - // httpsUrl: "http://127.0.0.1:8083/", + //httpsUrl: "http://127.0.0.1:8083/", openid: null, - indexCount:1 - }, + indexCount:1, + nickName:"", + userName:"", + role:"", + devcode:"" + } }) diff --git a/miniprogram/app.json b/miniprogram/app.json index d23f798..2b6db76 100644 --- a/miniprogram/app.json +++ b/miniprogram/app.json @@ -1,15 +1,17 @@ { "cloud": true, "pages": [ + "pages/login/login", "pages/indexapp/indexapp", "pages/earth/earth", "pages/applog/applog", "pages/addDevice/addDevice", "pages/addDevicelog/addDeviceLog", - "pages/searchLog/searchLog" + "pages/searchLog/searchLog", + "pages/notice/notice" ], "window": { - "backgroundColor": "#F6F6F6", + "backgroundColor": "#E6D480", "backgroundTextStyle": "light", "navigationBarBackgroundColor": "#FFCF00", "navigationBarTitleText": "智慧施工", @@ -46,11 +48,11 @@ "desc": "你的位置信息将用于小程序位置接口的效果展示" } }, + "requiredPrivateInfos": ["getLocation", "chooseLocation"], "networkTimeout": { "request": 30000, "connectSocket": 30000, "uploadFile": 30000, "downloadFile": 30000 - }, - "style": "v2" + } } \ No newline at end of file diff --git a/miniprogram/images/applocat.png b/miniprogram/images/applocat.png new file mode 100644 index 0000000..fe49f54 --- /dev/null +++ b/miniprogram/images/applocat.png Binary files differ diff --git a/miniprogram/images/back.png b/miniprogram/images/back.png new file mode 100644 index 0000000..32ac82d --- /dev/null +++ b/miniprogram/images/back.png Binary files differ diff --git a/miniprogram/images/bottom.png b/miniprogram/images/bottom.png new file mode 100644 index 0000000..d910e98 --- /dev/null +++ b/miniprogram/images/bottom.png Binary files differ diff --git a/miniprogram/images/header.png b/miniprogram/images/header.png new file mode 100644 index 0000000..6ea222e --- /dev/null +++ b/miniprogram/images/header.png Binary files differ diff --git a/miniprogram/images/login.png b/miniprogram/images/login.png index 8b73cc0..6471c46 100644 --- a/miniprogram/images/login.png +++ b/miniprogram/images/login.png Binary files differ diff --git a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss index 5a591fb..c9c35b5 100644 --- a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss +++ b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:100%;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:100%}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file +@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:650rpx;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:600rpx}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file diff --git a/miniprogram/pages/addDevice/addDevice.js b/miniprogram/pages/addDevice/addDevice.js index 2783674..78f00b7 100644 --- a/miniprogram/pages/addDevice/addDevice.js +++ b/miniprogram/pages/addDevice/addDevice.js @@ -1,5 +1,7 @@ // miniprogram/pages/addDevice/addDevice.js // import WxValidate from '../../utils/WxValidate.js' +var QQMapWX = require('../../libs/qqmap-wx-jssdk.js'); +var qqmapsdk; var app = getApp() Page({ @@ -11,32 +13,10 @@ canvasWidth: '', longitude: '', latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], + option1: [], personoption1: [], projectoption: [], + devtypeList:[], show: false, form: { devcode: "", @@ -59,7 +39,10 @@ project: "", area: "", street: "", - wellname: "" + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '', }, fileList: [] }, @@ -117,12 +100,14 @@ var that = this; //初始化表单内容为上次填写值 var cacheForms = wx.getStorageSync('cacheList') - if (cacheForms) { + cacheForms.photopath1='' + cacheForms.photopath2='' + cacheForms.photopath3='' + that.data.fileList=[] that.setData({ form: cacheForms, devcode: cacheForms.devcode, - }) } var form = that.data.form @@ -155,55 +140,89 @@ } }) + +//获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + that.setData({ + option1: welltypeArr + }) + } + } +}) + + //获取人员下拉列表 - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/getUser", + data:{ + tips:'repair' }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data.code == 200) { + var users = res.data.data + var personArr = []; + for (var i = 0; i < users.length; i++) { + var person = { + text: users[i].name, + value: users[i].name + }; + personArr.push(person); + } + that.setData({ + personoption1: personArr + }) } - that.setData({ - personoption1: personArr - }) } - }).catch(err => { - console.error(err); - }) + }) + - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - that.setData({ - projectoption: projectArr - }) + success(res){ + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); + } + that.setData({ + projectoption: projectArr + }) + } } - }).catch(err => { - console.error(err); - }) + }) + var installtime = 'form.installtimeFmt'; var dateNow = this.formatDate(); this.setData({ @@ -211,8 +230,40 @@ installtimeFmt: dateNow, [installtime]: dateNow, }); + + + + /** + * 获取设备类型下拉列表 + */ + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/deviceType", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var TypeList = res.data.data + var typeArr = []; + for (var i = 0; i < TypeList.length; i++) { + var type = { + text: TypeList[i].productName, + value: TypeList[i].productName + }; + typeArr.push(type); + } + that.setData({ + devtypeList: typeArr + }) + } + } + }) }, + + + /** * 生命周期函数--监听页面初次渲染完成 */ @@ -280,29 +331,7 @@ }, - - //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 - drawText: function (ctx, str, leftWidth, initHeight, titleHeight, canvasWidth) { - var lineWidth = 0; - var lastSubStrIndex = 0; //每次开始截取的字符串的索引 - for (let i = 0; i < str.length; i++) { - lineWidth += ctx.measureText(str[i]).width; - if (lineWidth > canvasWidth) { - ctx.fillText(str.substring(lastSubStrIndex, i), leftWidth, initHeight); //绘制截取部分 - initHeight = initHeight + leftWidth * 2; //22为字体的高度 - lineWidth = 0; - lastSubStrIndex = i; - // titleHeight += 40; - } - if (i == str.length - 1) { //绘制剩余部分 - ctx.fillText(str.substring(lastSubStrIndex, i + 1), leftWidth, initHeight); - } - } - // // 标题border-bottom 线距顶部距离 - // titleHeight = titleHeight + 10; - // return titleHeight - }, - + //验证表单 formValidate() { if (this.data.form.devcode == "") { @@ -312,27 +341,20 @@ }) return false } - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } if (this.data.form.wellcode == "") { wx.showToast({ icon: 'none', @@ -348,22 +370,10 @@ }) return false } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null) { + + if (this.data.form.installperson == "") { wx.showToast({ icon: 'none', title: '安装人员不能为空!', @@ -408,56 +418,90 @@ } return true; }, + //提交表单 formSubmit: function (event) { + console.log(this.data.form) + //表单参数验证 if (!this.formValidate()) { return false; } var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDevice', + //验证设备编号长度 + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/getDevTypeLength", data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceAdd/add" + code: encodeURI(this.data.form.devicetype) }, - }).then(res => { - if (res.result.code == 500) { - wx.showToast({ - title: '设备编号已安装!', - }) - } else if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - //用于回显 - wx.setStorageSync('cacheList', that.data.form) - //提交成功后提示用户操作 - if (res.confirm) { - wx.switchTab({ - url: '../earth/earth' - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (""==res.data.data ||res.data.data == that.data.form.devcode.length) { + that.saveDevice() + } else { //编号位数不对提示 + wx.showToast({ + icon: 'none', + title: '设备编号位数不对!', + duration: 1000 + }) + return false + } } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "提交失败", - }) }) }, + + //保存设备基本信息 + saveDevice() { + var that = this; + //设置照片路径 + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopathForm = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopathForm]: fileList[i].url.split("static/")[1] + }) + } + //表单提交 + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 500) { + wx.showToast({ + title: '设备编号已安装!', + }) + } else if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + //用于回显 + wx.setStorageSync('cacheList', that.data.form) + //提交成功后提示用户操作 + if (res.confirm) { + wx.switchTab({ + url: '../earth/earth' + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } + }, + fail(err) { + wx.showToast({ + title: '提交失败!', + }) + } + }) + }, + + //input 输入框设置值 confirm(event) { var that = this; var formValue = event.detail.value; @@ -466,8 +510,30 @@ that.setData({ [fromN]: formValue }) + //若输入是设备编号,自动获取设备类型 + if('devcode'==formName){ + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", + data: { + devcode: formValue, + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + that.setData({ + [formDevicetype]: res.data + }); + } + } + }) + } }, + //扫描设备获取编号和设备类型 scan() { var _this = this; wx.scanCode({ @@ -477,23 +543,28 @@ _this.setData({ [formdevcode]: devcode }); - wx.cloud.callFunction({ - name: 'findModeCode', + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", data: { devcode: devcode, - url: app.globalData.url + "appDeviceAdd/findModeCodeByCode" }, - }).then(res => { - if (res.result) { - var formDevicetype = 'form.devicetype' - _this.setData({ - [formDevicetype]: res.result - }); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + _this.setData({ + [formDevicetype]: res.data + }); + } } }) } }) }, + //粘贴经纬度 paste() { var _this = this; wx.getClipboardData({ @@ -510,9 +581,11 @@ longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), }); + _this.showAddress(_this.data.form.longitude,_this.data.form.latitude,_this) } }) }, + //设置经类型 selectValue(value) { var that = this; @@ -521,6 +594,16 @@ [wellType]: value.detail }) }, + + //设置设备类型 + selectDevType(event) { + var that = this; + var devtype = 'form.devicetype'; + that.setData({ + [devtype]: event.detail + }) + }, + //设置运维人员 selectpersonValue(event) { var that = this; var installPerson = 'form.installperson'; @@ -528,6 +611,7 @@ [installPerson]: event.detail }) }, + //设置项目 selectprojectValue(event) { var that = this; var project = 'form.project'; @@ -535,8 +619,41 @@ [project]: event.detail }) }, + showAddress :function(longitude, latitude, self) { + // 实例化腾讯地图API核心类 + qqmapsdk = new QQMapWX({ + key: 'BGPBZ-C5O3P-ROUDR-LWC4J-63EKH-V5FRX'//此处使用你自己申请的key + }) + // 腾讯地图调用接口 + qqmapsdk.reverseGeocoder({ + location: { + latitude: latitude, + longitude: longitude + }, + success: function (res) { + self.setData({ + 'form.area':res.result.address.slice(0,res.result.address.indexOf('区')+1), + 'form.street':res.result.address.slice(res.result.address.indexOf('区')+1) + }) + }, + fail: function (res) { + console.log(res); + }, + complete: function (res) { + } + }); + }, + //上传照片 afterRead(event) { var _this = this; + if (_this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '请先填写设备编号!\r\n否则水印中无编号', + duration: 2000 + }) + return false + } const { file } = event.detail; @@ -576,78 +693,8 @@ }) } }) - // 压缩图片 - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // //获取图片尺寸 - // wx.getImageInfo({ - // src: convertpath, - // success(res) { - // _this.setData({ - // canvasHeight: res.height, - // canvasWidth: res.width - // }) - // var ctx = wx.createCanvasContext('firstCanvas') - - // //将图片src放到cancas内,宽高为图片大小 - // ctx.drawImage(convertpath, 0, 0, res.width, res.height) - // //将声明的时间放入canvas - // ctx.setFontSize(30 * (res.width / 750)) //注意:设置文字大小必须放在填充文字之前,否则不生效 - // ctx.setFillStyle('blue') - // var text = "编号:" + _this.data.form.devcode + "\n经度:" + _this.data.form.longitude + "\n纬度:" + _this.data.form.latitude - // // _this.drawText(ctx,text,20, 70, 5, res.width) - // _this.drawText(ctx, text, 15 * (res.width / 750), 70 * (res.width / 750), 5, res.width) - - // // ctx.fillText(text, 0, 40) - // // ctx.strokeText(_this.data.form.devcode, 0, 30) - // //生成水印图 - // ctx.draw(false, function () { - // wx.canvasToTempFilePath({ - // canvasId: 'firstCanvas', - // success: (res) => { - // wx.compressImage({ - // src: res.tempFilePath, - // quality: 25, - // success: function (res) { - // //上传照片至服务器 - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: res.tempFilePath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // } - // }) - // //// - // } - // }) - // }) - // } - // }) - // } - // }); }, + //删除照片 deletePhoto(event) { var image_index = event.detail.index var fileList_new = this.data.fileList; diff --git a/miniprogram/pages/addDevice/addDevice.wxml b/miniprogram/pages/addDevice/addDevice.wxml index b0977e2..f12c254 100644 --- a/miniprogram/pages/addDevice/addDevice.wxml +++ b/miniprogram/pages/addDevice/addDevice.wxml @@ -5,18 +5,30 @@ - + + + + + + + + + + + + + - - + + - - - + + + @@ -29,13 +41,13 @@ - + - + - + - + @@ -54,8 +66,7 @@ - - + @@ -68,8 +79,8 @@ - - + + - 保存 + 保存 \ No newline at end of file diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.js b/miniprogram/pages/addDevicelog/addDeviceLog.js index cdec71b..a0dc6da 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.js +++ b/miniprogram/pages/addDevicelog/addDeviceLog.js @@ -3,681 +3,665 @@ var app = getApp(); Page({ - /** - * 页面的初始数据 - */ - data: { - pageName: '', - showMask: false, - today: new Date().getTime(), - longitude: '', - latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], - personoption1: [], - projectoption: [], - devcode: "", - deviceMode: "", - installtimeFmt: '', - show: false, - form: { - devcode: "", - wellcode: "", - welltype: "", - welldepth: "", - installheigt: "", - installperson: "", - installtimeFmt: "", - photopath: "", - factory: "", - workmsg: "", - position: "", - description: "", - longitude: "", - latitude: "", - longitude84: "", - latitude84: "", - devicetype: "", - project: "", - area: "", - street: "", - wellname: "" - }, - fileList: [], - detail: "" - }, + /** + * 页面的初始数据 + */ + data: { + pageName: '', + showMask: false, + today: new Date().getTime(), + longitude: '', + latitude: '', + option1: [], + personoption1: [], + projectoption: [], + devcode: "", + deviceMode: "", + installtimeFmt: '', + show: false, + form: { + devcode: "", + wellcode: "", + welltype: "", + welldepth: "", + installheigt: "", + installperson: "", + installtimeFmt: "", + photopath: "", + factory: "", + workmsg: "", + position: "", + description: "", + longitude: "", + latitude: "", + longitude84: "", + latitude84: "", + devicetype: "", + project: "", + area: "", + street: "", + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '' + }, + fileList: [], + detail: "", + markers: [{ + id: 100, + // iconPath: "../../images/point.png", + latitude: '', + longitude: '', + // label:'1', + width: 25, + height: 35 + }], + }, - onDisplay() { - this.setData({ - show: true - }); - }, - onClose() { - this.setData({ - show: false - }); - }, - formatDate() { - var date = new Date(); - // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; - var seperator1 = "-"; - var month = date.getMonth() + 1; - var strDate = date.getDate(); - var hour = date.getHours() - var minute = date.getMinutes() - var second = date.getSeconds() - month = month > 9 ? month : "0" + month; - strDate = strDate > 9 ? strDate : "0" + strDate; - hour = hour > 9 ? hour : "0" + hour; - minute = minute > 9 ? minute : "0" + minute; - second = second > 9 ? second : "0" + second; - var currentdate = - date.getFullYear() + - seperator1 + - month + - seperator1 + - strDate + - " " + - hour + ":" + - minute + ":" + - second; - return currentdate; + onDisplay() { + this.setData({ + show: true + }); + }, + onClose() { + this.setData({ + show: false + }); + }, + formatDate() { + var date = new Date(); + // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; + var seperator1 = "-"; + var month = date.getMonth() + 1; + var strDate = date.getDate(); + var hour = date.getHours() + var minute = date.getMinutes() + var second = date.getSeconds() + month = month > 9 ? month : "0" + month; + strDate = strDate > 9 ? strDate : "0" + strDate; + hour = hour > 9 ? hour : "0" + hour; + minute = minute > 9 ? minute : "0" + minute; + second = second > 9 ? second : "0" + second; + var currentdate = + date.getFullYear() + + seperator1 + + month + + seperator1 + + strDate + + " " + + hour + ":" + + minute + ":" + + second; + return currentdate; - }, - onConfirm(event) { - var installtime = 'form.installtimeFmt'; - this.setData({ - show: false, - installtimeFmt: this.formatDate(event.detail), - [installtime]: this.formatDate(event.detail), - }); - }, + }, + onConfirm(event) { + var installtime = 'form.installtimeFmt'; + this.setData({ + show: false, + installtimeFmt: this.formatDate(event.detail), + [installtime]: this.formatDate(event.detail), + }); + }, - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - var _this = this; - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" - }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); - } - _this.setData({ - personoption1: personArr - }) + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + var _this = this; + _this.setData({ + 'markers[0].latitude': Number(wx.getStorageSync('resultObject').latitude) , + 'markers[0].longitude': Number(wx.getStorageSync('resultObject').longitude), + // 'markers[0].label':'10', + 'markers[0].width': 18, + 'markers[0].id':1, + 'markers[0].height': 30, + latitude:Number(wx.getStorageSync('resultObject').latitude), + longitude:Number(wx.getStorageSync('resultObject').longitude) + }) + //获取人员下拉列表 + // wx.request({ + // method: "POST", + // url: app.globalData.httpsUrl + "deviceType/getUser", + // data:{ + // tips:'repair' + // }, + // header: { + // 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + // }, + // success(res) { + // if (res.data.code == 200) { + // var users = res.data.data + // var personArr = []; + // for (var i = 0; i < users.length; i++) { + // var person = { + // text: users[i].name, + // value: users[i].name + // }; + // personArr.push(person); + // } + // _this.setData({ + // personoption1: personArr + // }) + // } + // } + // }) + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); } - }).catch(err => { - console.error(err); - }) - - - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" - }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - _this.setData({ - projectoption: projectArr - }) - } - }).catch(err => { - console.error(err); - }) - - if (options.pageName) { - this.setData({ - pageName: options.pageName - }) - } - - if (options.detail) { - - var formObject = JSON.parse(options.detail); _this.setData({ - form: formObject, - detail: options.detail + projectoption: projectArr }) - - _this.setData({ - ['form.installperson']: "", - ['form.installtimeFmt']: "", - ['form.workmsg']: "", - ['form.description']: "" - }) - - const { - fileList = [] - } = _this.data; - if (formObject.photopath1 != "") { - var file1 = { - url: app.globalData.url + "static/" + formObject.photopath1 - } - fileList.push(file1) - } - if (formObject.photopath2 != "") { - var file2 = { - url: app.globalData.url + "static/" + formObject.photopath2 - } - fileList.push(file2) - } - if (formObject.photopath3 != "") { - var file3 = { - url: app.globalData.url + "static/" + formObject.photopath3 - } - fileList.push(file3) - } - - _this.setData({ - fileList - }); } - var installtime = 'form.installtimeFmt'; - var dateNow = this.formatDate(); - this.setData({ - installtimeFmt: dateNow, - [installtime]: dateNow, - }); - }, + } + }) - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { + //获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + _this.setData({ + option1: welltypeArr + }) + } + } +}) - }, + //跳转时带入参数返回哪页 + if (options.pageName) { + this.setData({ + pageName: options.pageName + }) + } + //跳转时带入参数设备的安装信息 + if (wx.getStorageSync('resultObject')) { + var formObject = wx.getStorageSync('resultObject') + _this.setData({ + form: formObject, + detail: formObject + }) - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { + _this.setData({ + ['form.installperson']: app.globalData.userName, + ['form.installtimeFmt']: "", + ['form.workmsg']: "", + ['form.description']: "" + }) - }, + const { + fileList = [] + } = _this.data; + if (formObject.photopath1 != "") { + var file1 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath1 + } + fileList.push(file1) + } + if (formObject.photopath2 != "") { + var file2 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath2 + } + fileList.push(file2) + } + if (formObject.photopath3 != "") { + var file3 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath3 + } + fileList.push(file3) + } + _this.setData({ + fileList + }); + } + var installtime = 'form.installtimeFmt'; + var dateNow = this.formatDate(); + this.setData({ + installtimeFmt: dateNow, + [installtime]: dateNow, + }); + }, - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, - }, + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + wx.removeStorageSync('resultObject') + }, - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, - }, + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { + }, - }, + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { + }, - }, + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { + }, - }, + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + }, - /** - * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true - **/ + /** + * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true + **/ - isNumber: function (val) { + isNumber: function (val) { - var regPos = /^[0-9]*$/; //非负浮点数 - var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数 - if (regPos.test(val) || regNeg.test(val)) { - return false; - } else { - return true; - } + var regPos = /^[0-9]*$/; //非负浮点数 + var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数 + if (regPos.test(val) || regNeg.test(val)) { + return false; + } else { + return true; + } - }, + }, - formValidate() { + formValidate() { - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } - if (this.data.form.wellcode == "") { - wx.showToast({ - icon: 'none', - title: '井编号不能为空!', - }) - return false - } - if (this.data.form.devicetype == "") { - wx.showToast({ - icon: 'none', - title: '设备类型不能为空!', - }) - return false - } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + if (this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '设备编号不能为空!', + }) + return false + } + if (this.data.form.wellcode == "") { + wx.showToast({ + icon: 'none', + title: '井编号不能为空!', + }) + return false + } + if (this.data.form.devicetype == "") { + wx.showToast({ + icon: 'none', + title: '设备类型不能为空!', + }) + return false + } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null || - this.data.form.installperson == '') { - wx.showToast({ - icon: 'none', - title: '运维人员不能为空!', - }) - return false - } - if (this.data.form.project == "") { - wx.showToast({ - icon: 'none', - title: '所属项目不能为空!', - }) - return false - } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } + if (this.data.form.installperson == null || + this.data.form.installperson == '') { + wx.showToast({ + icon: 'none', + title: '运维人员不能为空!', + }) + return false + } + if (this.data.form.project == "") { + wx.showToast({ + icon: 'none', + title: '所属项目不能为空!', + }) + return false + } - if (this.data.form.welldepth != null) { - if (this.isNumber(this.data.form.welldepth)) { - wx.showToast({ - icon: 'none', - title: '井深必须为数值!', - }) - return false - } - } - if (this.data.form.installheigt != null) { - if (this.isNumber(this.data.form.installheigt)) { - wx.showToast({ - icon: 'none', - title: '到井口距离必须为数值!', - }) - return false - } - } - - return true; - }, - - changeMsg: function () { - var formNew = this.data.form; - var formOld = JSON.parse(this.data.detail); - var descpNew = ""; - if (formNew.devcode != formOld.devcode) { - descpNew += "修改设备编号,原编号:" + formOld.devcode + ",新编号:" + formNew.devcode + ";" - } - if (formNew.devicetype != formOld.devicetype) { - descpNew += "修改设备类型,原设备类型:" + formOld.devicetype + ",新设备类型:" + formNew.devicetype + ";" - } - if (formNew.area != formOld.area) { - descpNew += "修改区,原区:" + formOld.area + ",新区:" + formNew.area + ";" - } - if (formNew.street != formOld.street) { - descpNew += "修改街道,原街道:" + formOld.street + ",新街道:" + formNew.street + ";" - } - if (formNew.wellname != formOld.wellname) { - descpNew += "修改井名称,原井名称:" + formOld.wellname + ",新井名称:" + formNew.wellname + ";" - } - if (formNew.factory != formOld.factory) { - descpNew += "修改权属单位,原权属单位:" + formOld.factory + ",新权属单位:" + formNew.factory + ";" - } - if (formNew.installheigt != formOld.installheigt) { - descpNew += "修改井口距离,原井口距离:" + formOld.installheigt + ",新井口距离:" + formNew.installheigt + ";" - } - if (formNew.installperson != formOld.installperson) { - descpNew += "修改运维人员,原运维人员:" + formOld.installperson + ",新运维人员:" + formNew.installperson + ";" - } - if (formNew.latitude != formOld.latitude) { - descpNew += "修改纬度,原纬度:" + formOld.latitude + ",新纬度:" + formNew.latitude + ";" - } - if (formNew.longitude != formOld.longitude) { - descpNew += "修改经度,原经度:" + formOld.longitude + ",新经度:" + formNew.longitude + ";" - } - if (formNew.position != formOld.position) { - descpNew += "修改位置描述,原位置:" + formOld.position + ",新位置:" + formNew.position + ";" - } - if (formNew.wellcode != formOld.wellcode) { - descpNew += "修改井编号,原编号:" + formOld.wellcode + ",新编号:" + formNew.wellcode + ";" - } - if (formNew.welldepth != formOld.welldepth) { - descpNew += "修改井深,原井深:" + formOld.welldepth + ",新井深:" + formNew.welldepth + ";" - } - if (formNew.welltype != formOld.welltype) { - descpNew += "修改井类型,原井类型:" + formOld.welltype + ",新井类型:" + formNew.welltype + ";" - } - if (formNew.project != formOld.project) { - descpNew += "修改所属项目,原项目:" + formOld.project + ",新项目:" + formNew.project + ";" - } - if (this.data.photopath1 != formOld.photopath1 || - this.data.photopath2 != formOld.photopath2 || - this.data.photopath3 != formOld.photopath3) { - descpNew += "修改照片;" - } - if ("" != formNew.description) { - descpNew += formNew.description; - } - this.setData({ - ['form.description']: descpNew + if (this.data.form.welldepth != null) { + if (this.isNumber(this.data.form.welldepth)) { + wx.showToast({ + icon: 'none', + title: '井深必须为数值!', }) - }, + return false + } + } + if (this.data.form.installheigt != null) { + if (this.isNumber(this.data.form.installheigt)) { + wx.showToast({ + icon: 'none', + title: '到井口距离必须为数值!', + }) + return false + } + } - formSubmit: function (event) { + return true; + }, - if (!this.formValidate()) { - return false; - } - this.changeMsg(); - var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDeviceLog', - data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceLog/add" - }, - }).then(res => { - // var resultObj=JSON.parse(res.result); - if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - if (res.confirm) { - wx.switchTab({ - url: that.data.pageName - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) - } - }).catch(err => { - console.error(err) - wx.showToast({ - title: "提交失败", - }) - }) - }, - confirm(event) { - var that = this; - var formValue = event.detail.value; - var formName = event.target.dataset.id; - var fromN = 'form.' + [formName]; - that.setData({ - [fromN]: formValue - }) - }, + //获取与上次修改的信息 + changeMsg: function () { + var formNew = this.data.form; + console.log(this.data.detail) + var formOld = JSON.parse(this.data.detail); + var descpNew = ""; + if (formNew.devcode != formOld.devcode) { + descpNew += "修改设备编号,原值:" + formOld.devcode + ",新值:" + formNew.devcode + ";" + } + if (formNew.devicetype != formOld.devicetype) { + descpNew += "修改设备类型,原值:" + formOld.devicetype + ",新值:" + formNew.devicetype + ";" + } + if (formNew.area != formOld.area) { + descpNew += "修改区,原值:" + formOld.area + ",新值:" + formNew.area + ";" + } + if (formNew.street != formOld.street) { + descpNew += "修改街道,原值:" + formOld.street + ",新值:" + formNew.street + ";" + } + if (formNew.wellname != formOld.wellname) { + descpNew += "修改井名称,原值:" + formOld.wellname + ",新值:" + formNew.wellname + ";" + } + if (formNew.factory != formOld.factory) { + descpNew += "修改权属单位,原值:" + formOld.factory + ",新值:" + formNew.factory + ";" + } + if (formNew.installheigt != formOld.installheigt) { + descpNew += "修改井口距离,原值:" + formOld.installheigt + ",新值:" + formNew.installheigt + ";" + } + if (formNew.installperson != formOld.installperson) { + descpNew += "修改运维人员,原值:" + formOld.installperson + ",新值:" + formNew.installperson + ";" + } + if (formNew.latitude != formOld.latitude) { + descpNew += "修改纬度,原值:" + formOld.latitude + ",新值:" + formNew.latitude + ";" + } + if (formNew.longitude != formOld.longitude) { + descpNew += "修改经度,原值:" + formOld.longitude + ",新值:" + formNew.longitude + ";" + } + if (formNew.position != formOld.position) { + descpNew += "修改位置描述,原值:" + formOld.position + ",新值:" + formNew.position + ";" + } + if (formNew.wellcode != formOld.wellcode) { + descpNew += "修改井编号,原值:" + formOld.wellcode + ",新值:" + formNew.wellcode + ";" + } + if (formNew.welldepth != formOld.welldepth) { + descpNew += "修改井深,原值:" + formOld.welldepth + ",新值:" + formNew.welldepth + ";" + } + if (formNew.welltype != formOld.welltype) { + descpNew += "修改井类型,原值:" + formOld.welltype + ",新值:" + formNew.welltype + ";" + } + if (formNew.project != formOld.project) { + descpNew += "修改所属项目,原值:" + formOld.project + ",新值:" + formNew.project + ";" + } + if (this.data.form.photopath1 != formOld.photopath1 || + this.data.form.photopath2 != formOld.photopath2 || + this.data.form.photopath3 != formOld.photopath3) { + descpNew += "修改照片;" + } + if ("" != formNew.description) { + descpNew += formNew.description; + } + this.setData({ + ['form.description']: descpNew + }) + }, - scan() { + //提交表单 + formSubmit: function (event) { - wx.scanCode({ - success(res) { - console.log(res) - } - }) + //表单验证 + if (!this.formValidate()) { + return false; + } + //自动生成修改内容 + this.changeMsg(); + //提交权限限制(只有施工人员能修改) + if(app.globalData.role!='repair'){ + wx.showToast({ + icon: 'none', + title: '无权限修改', + duration:2000 + }) + return false + } + var that = this; + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopath = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopath]: fileList[i].url.split("static/")[1] + }) + } + delete that.data.form.installtime + delete that.data.form.createtime + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - paste() { - var _this = this; - wx.getClipboardData({ - success: function (res) { - var longitude = 'form.longitude'; - var latitude = 'form.latitude'; - var longitude84 = 'form.longitude84'; - var latitude84 = 'form.latitude84'; - _this.setData({ - [longitude]: parseFloat(res.data.split(",", 4)[1]).toFixed(6), - [latitude]: parseFloat(res.data.split(",", 4)[0]).toFixed(6), - [longitude84]: "" == (res.data.split(",", 4)[3]) ? "" : parseFloat(res.data.split(",", 4)[3]).toFixed(6), - [latitude84]: "" == (res.data.split(",", 4)[2]) ? "" : parseFloat(res.data.split(",", 4)[2]).toFixed(6), - longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), - latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), - }); - } - }) - }, - selectValue(value) { - var that = this; - var wellType = 'form.welltype'; - that.setData({ - [wellType]: value.detail - }) - }, - selectpersonValue(event) { - var that = this; - var installPerson = 'form.installperson'; - that.setData({ - [installPerson]: event.detail - }) - }, - selectprojectValue(event) { - var that = this; - var project = 'form.project'; - that.setData({ - [project]: event.detail, - showMask: true - }) - }, - open() { - this.setData({ - showMask: true - }) - }, - close() { - this.setData({ - showMask: false - }) - }, - afterRead(event) { - var _this = this; - const { - file - } = event.detail; - const { - fileList = [] - } = _this.data; - var convertpath = ""; - wx.compressImage({ - src: event.detail.file.path, - quality: 25, - success: function (res) { - convertpath = res.tempFilePath; - wx.uploadFile({ - url: app.globalData.httpsUrl + "appDeviceAdd/fileUploadMarker", - filePath:convertpath, - name: 'file', - formData: { - 'text': "编号:" + _this.data.form.devcode + "经度:" + _this.data.form.longitude + "纬度:" + _this.data.form.latitude - }, - header: { - "Content-Type": "multipart/form-data", - 'accept': 'application/json', - }, - success(res) { - if (res.data) { - var url = JSON.parse(res.data); - fileList.push({ - ...file, - url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - }); - _this.setData({ - fileList - }); - } - } + success(res) { + if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + if (res.confirm) { + wx.switchTab({ + url: that.data.pageName }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') } - }) - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // // var base64 = "data:image/png;base64," + wx.getFileSystemManager().readFileSync(convertpath, 'base64'); - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: convertpath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // // wx.cloud.callFunction({ - // // name: 'uploadFile', - // // data: { - // // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // // fileBase64: base64 - // // }, - // // success: function (res) { - // // if (res.result) { - // // fileList.push({ - // // ...file, - // // url: app.globalData.url + "static/" + res.result.data.replace(/\\/g, "/") - // // }); - // // _this.setData({ - // // fileList - // // }); - // // } - // // }, - // // complete: res => { - // // }, - // // }) - // } - // }); + } + }) + } + }, + fail(err) { + wx.showToast({ + title: "提交失败", + }) + } + }) + }, + //报存录入的input信息 + confirm(event) { + var that = this; + var formValue = event.detail.value; + var formName = event.target.dataset.id; + var fromN = 'form.' + [formName]; + that.setData({ + [fromN]: formValue + }) + }, + + //扫码 + scan() { + + wx.scanCode({ + success(res) { + console.log(res) + } + }) + }, + //粘贴经纬度 + paste() { + var _this = this; + wx.getClipboardData({ + success: function (res) { + var longitude = 'form.longitude'; + var latitude = 'form.latitude'; + var longitude84 = 'form.longitude84'; + var latitude84 = 'form.latitude84'; + _this.setData({ + [longitude]: parseFloat(res.data.split(",", 4)[1]).toFixed(6), + [latitude]: parseFloat(res.data.split(",", 4)[0]).toFixed(6), + [longitude84]: "" == (res.data.split(",", 4)[3]) ? "" : parseFloat(res.data.split(",", 4)[3]).toFixed(6), + [latitude84]: "" == (res.data.split(",", 4)[2]) ? "" : parseFloat(res.data.split(",", 4)[2]).toFixed(6), + longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), + latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), + }); + } + }) + }, + selectValue(value) { + var that = this; + var wellType = 'form.welltype'; + that.setData({ + [wellType]: value.detail + }) + }, + //运维人员默认为登录人 + // selectpersonValue(event) { + // var that = this; + // var installPerson = 'form.installperson'; + // that.setData({ + // [installPerson]: event.detail + // }) + // }, + selectprojectValue(event) { + var that = this; + var project = 'form.project'; + that.setData({ + [project]: event.detail, + showMask: true + }) + }, + + open() { + this.setData({ + showMask: true + }) + }, + //隐藏textarea,防止遮挡 + close() { + this.setData({ + showMask: false + }) + }, + //上传照片 + afterRead(event) { + var _this = this; + const { + file + } = event.detail; + const { + fileList = [] + } = _this.data; + var convertpath = ""; + wx.compressImage({ + src: event.detail.file.path, + quality: 25, + success: function (res) { + convertpath = res.tempFilePath; + wx.uploadFile({ + url: app.globalData.httpsUrl + "appDeviceAdd/fileUploadMarker", + filePath: convertpath, + name: 'file', + formData: { + 'text': "编号:" + _this.data.form.devcode + "经度:" + _this.data.form.longitude + "纬度:" + _this.data.form.latitude }, - deletePhoto(event) { - var that = this - var image_index = event.detail.index - var fileList_new = that.data.fileList; - wx.showModal({ - content: '确定删除照片?', - success: function (res) { - if (res.confirm) { - fileList_new.splice(image_index, 1); - that.setData({ - fileList: fileList_new - }) - wx.cloud.callFunction({ - name: 'deletePhoto', - data: { - url: app.globalData.url + "appDeviceLog/deletePhoto", - devcode: that.data.form.devcode, - pathIndex: image_index - }, - success: function (res) {}, - complete: res => {}, - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + "Content-Type": "multipart/form-data", + 'accept': 'application/json', }, - }) \ No newline at end of file + success(res) { + if (res.data) { + var url = JSON.parse(res.data); + fileList.push({ + ...file, + url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") + }); + _this.setData({ + fileList + }); + } + } + }) + } + }) + }, + //删除照片 + deletePhoto(event) { + var that = this + var image_index = event.detail.index + var fileList_new = that.data.fileList; + wx.showModal({ + content: '确定删除照片?', + success: function (res) { + if (res.confirm) { + fileList_new.splice(image_index, 1); + that.setData({ + fileList: fileList_new + }) + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deletePhoto", + data: { + devcode: that.data.form.devcode + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) {} + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } +}) \ No newline at end of file diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.wxml b/miniprogram/pages/addDevicelog/addDeviceLog.wxml index 38620d4..b10cc7d 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.wxml +++ b/miniprogram/pages/addDevicelog/addDeviceLog.wxml @@ -1,15 +1,21 @@ - + + + + + - + - - + + - - + + - + @@ -39,24 +45,25 @@ - - - + + + - + - + + @@ -64,7 +71,7 @@ - + @@ -79,9 +86,9 @@ - + - 保存 + 保存 diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.wxss b/miniprogram/pages/addDevicelog/addDeviceLog.wxss index ee0b75c..08d5fd7 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.wxss +++ b/miniprogram/pages/addDevicelog/addDeviceLog.wxss @@ -24,6 +24,17 @@ display: flex; align-items: center; } +.map-view{ + width: 750rpx; + height: 485rpx; + position: fixed; + top: 0px; + left: 0px; + z-index: 999; +} +.content{ + margin-top: 495rpx; +} .left { width: 210rpx; diff --git a/miniprogram/pages/addFunction/addFunction.js b/miniprogram/pages/addFunction/addFunction.js deleted file mode 100644 index 4966be3..0000000 --- a/miniprogram/pages/addFunction/addFunction.js +++ /dev/null @@ -1,60 +0,0 @@ -// pages/addFunction/addFunction.js - -const code = `// 云函数入口函数 -exports.main = (event, context) => { - console.log(event) - console.log(context) - return { - sum: event.a + event.b - } -}` - -Page({ - - data: { - result: '', - canIUseClipboard: wx.canIUse('setClipboardData'), - }, - - onLoad: function (options) { - - }, - - copyCode: function() { - wx.setClipboardData({ - data: code, - success: function () { - wx.showToast({ - title: '复制成功', - }) - } - }) - }, - - testFunction() { - wx.cloud.callFunction({ - name: 'sum', - data: { - a: 1, - b: 2 - }, - success: res => { - wx.showToast({ - title: '调用成功', - }) - this.setData({ - result: JSON.stringify(res.result) - }) - }, - fail: err => { - wx.showToast({ - icon: 'none', - title: '调用失败', - }) - console.error('[云函数] [sum] 调用失败:', err) - } - }) - }, - -}) - diff --git a/miniprogram/pages/addFunction/addFunction.json b/miniprogram/pages/addFunction/addFunction.json deleted file mode 100644 index a9a50c5..0000000 --- a/miniprogram/pages/addFunction/addFunction.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "navigationBarTitleText": "云函数指引", - "usingComponents": {} -} \ No newline at end of file diff --git a/miniprogram/pages/addFunction/addFunction.wxml b/miniprogram/pages/addFunction/addFunction.wxml deleted file mode 100644 index 3a10626..0000000 --- a/miniprogram/pages/addFunction/addFunction.wxml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - 测试云函数 - - - 期望输出:{"sum":3} - - - 调用结果:{{result}} - - - - - 新增云函数 - 1. 在云函数根目录 cloudfunctions 上右键选择新建云函数,命名为 sum - 2. 在创建的 cloudfunctions/sum/index.js 文件中添加如下代码 - - - 3. 在 cloudfunctions/sum 目录上右键上传并部署 - 4. 点击测试云函数测试 - 5. 打开云开发云函数管理页,选择 sum 云函数 - 6. 查看 sum 的调用日志 - 进阶:可在云函数中使用 wx-server-sdk 操作数据库,文件存储和调用其他云函数,详见文档 - - - diff --git a/miniprogram/pages/addFunction/addFunction.wxss b/miniprogram/pages/addFunction/addFunction.wxss deleted file mode 100644 index 7ac8619..0000000 --- a/miniprogram/pages/addFunction/addFunction.wxss +++ /dev/null @@ -1,3 +0,0 @@ -/* pages/addFunction/addFunction.wxss */ - -@import "../../style/guide.wxss"; \ No newline at end of file diff --git a/cloudfunctions/project.config.json b/cloudfunctions/project.config.json new file mode 100644 index 0000000..2b3119a --- /dev/null +++ b/cloudfunctions/project.config.json @@ -0,0 +1,28 @@ +{ + "appid": "wx2cef527a000f87c9", + "compileType": "miniprogram", + "libVersion": "2.27.3", + "packOptions": { + "ignore": [], + "include": [] + }, + "setting": { + "coverView": true, + "es6": true, + "postcss": true, + "minified": true, + "enhance": true, + "showShadowRootInWxmlPanel": true, + "packNpmRelationList": [], + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + } + }, + "condition": {}, + "editorSetting": { + "tabIndent": "insertSpaces", + "tabSize": 4 + } +} \ No newline at end of file diff --git a/cloudfunctions/project.private.config.json b/cloudfunctions/project.private.config.json new file mode 100644 index 0000000..42ff49d --- /dev/null +++ b/cloudfunctions/project.private.config.json @@ -0,0 +1,7 @@ +{ + "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", + "projectname": "cloudfunctions", + "setting": { + "compileHotReLoad": true + } +} \ No newline at end of file diff --git a/miniprogram/app.js b/miniprogram/app.js index 51d56f3..50a8a54 100644 --- a/miniprogram/app.js +++ b/miniprogram/app.js @@ -18,13 +18,15 @@ // this.globalData = {} }, globalData: { - // url: "http://111.198.10.15:11604/", - httpsUrl: "https://logapi.smartlog.work/", - httpsTestUrl: "https://smartlog.work/prodapi4test/", - url: "http://139.198.18.188:8083/", + httpsUrl: "https://logapi.smartlog.work/", + // httpsUrl: "http://139.198.18.188:8083/", // url: "http://127.0.0.1:8083/", - // httpsUrl: "http://127.0.0.1:8083/", + //httpsUrl: "http://127.0.0.1:8083/", openid: null, - indexCount:1 - }, + indexCount:1, + nickName:"", + userName:"", + role:"", + devcode:"" + } }) diff --git a/miniprogram/app.json b/miniprogram/app.json index d23f798..2b6db76 100644 --- a/miniprogram/app.json +++ b/miniprogram/app.json @@ -1,15 +1,17 @@ { "cloud": true, "pages": [ + "pages/login/login", "pages/indexapp/indexapp", "pages/earth/earth", "pages/applog/applog", "pages/addDevice/addDevice", "pages/addDevicelog/addDeviceLog", - "pages/searchLog/searchLog" + "pages/searchLog/searchLog", + "pages/notice/notice" ], "window": { - "backgroundColor": "#F6F6F6", + "backgroundColor": "#E6D480", "backgroundTextStyle": "light", "navigationBarBackgroundColor": "#FFCF00", "navigationBarTitleText": "智慧施工", @@ -46,11 +48,11 @@ "desc": "你的位置信息将用于小程序位置接口的效果展示" } }, + "requiredPrivateInfos": ["getLocation", "chooseLocation"], "networkTimeout": { "request": 30000, "connectSocket": 30000, "uploadFile": 30000, "downloadFile": 30000 - }, - "style": "v2" + } } \ No newline at end of file diff --git a/miniprogram/images/applocat.png b/miniprogram/images/applocat.png new file mode 100644 index 0000000..fe49f54 --- /dev/null +++ b/miniprogram/images/applocat.png Binary files differ diff --git a/miniprogram/images/back.png b/miniprogram/images/back.png new file mode 100644 index 0000000..32ac82d --- /dev/null +++ b/miniprogram/images/back.png Binary files differ diff --git a/miniprogram/images/bottom.png b/miniprogram/images/bottom.png new file mode 100644 index 0000000..d910e98 --- /dev/null +++ b/miniprogram/images/bottom.png Binary files differ diff --git a/miniprogram/images/header.png b/miniprogram/images/header.png new file mode 100644 index 0000000..6ea222e --- /dev/null +++ b/miniprogram/images/header.png Binary files differ diff --git a/miniprogram/images/login.png b/miniprogram/images/login.png index 8b73cc0..6471c46 100644 --- a/miniprogram/images/login.png +++ b/miniprogram/images/login.png Binary files differ diff --git a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss index 5a591fb..c9c35b5 100644 --- a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss +++ b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:100%;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:100%}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file +@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:650rpx;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:600rpx}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file diff --git a/miniprogram/pages/addDevice/addDevice.js b/miniprogram/pages/addDevice/addDevice.js index 2783674..78f00b7 100644 --- a/miniprogram/pages/addDevice/addDevice.js +++ b/miniprogram/pages/addDevice/addDevice.js @@ -1,5 +1,7 @@ // miniprogram/pages/addDevice/addDevice.js // import WxValidate from '../../utils/WxValidate.js' +var QQMapWX = require('../../libs/qqmap-wx-jssdk.js'); +var qqmapsdk; var app = getApp() Page({ @@ -11,32 +13,10 @@ canvasWidth: '', longitude: '', latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], + option1: [], personoption1: [], projectoption: [], + devtypeList:[], show: false, form: { devcode: "", @@ -59,7 +39,10 @@ project: "", area: "", street: "", - wellname: "" + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '', }, fileList: [] }, @@ -117,12 +100,14 @@ var that = this; //初始化表单内容为上次填写值 var cacheForms = wx.getStorageSync('cacheList') - if (cacheForms) { + cacheForms.photopath1='' + cacheForms.photopath2='' + cacheForms.photopath3='' + that.data.fileList=[] that.setData({ form: cacheForms, devcode: cacheForms.devcode, - }) } var form = that.data.form @@ -155,55 +140,89 @@ } }) + +//获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + that.setData({ + option1: welltypeArr + }) + } + } +}) + + //获取人员下拉列表 - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/getUser", + data:{ + tips:'repair' }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data.code == 200) { + var users = res.data.data + var personArr = []; + for (var i = 0; i < users.length; i++) { + var person = { + text: users[i].name, + value: users[i].name + }; + personArr.push(person); + } + that.setData({ + personoption1: personArr + }) } - that.setData({ - personoption1: personArr - }) } - }).catch(err => { - console.error(err); - }) + }) + - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - that.setData({ - projectoption: projectArr - }) + success(res){ + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); + } + that.setData({ + projectoption: projectArr + }) + } } - }).catch(err => { - console.error(err); - }) + }) + var installtime = 'form.installtimeFmt'; var dateNow = this.formatDate(); this.setData({ @@ -211,8 +230,40 @@ installtimeFmt: dateNow, [installtime]: dateNow, }); + + + + /** + * 获取设备类型下拉列表 + */ + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/deviceType", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var TypeList = res.data.data + var typeArr = []; + for (var i = 0; i < TypeList.length; i++) { + var type = { + text: TypeList[i].productName, + value: TypeList[i].productName + }; + typeArr.push(type); + } + that.setData({ + devtypeList: typeArr + }) + } + } + }) }, + + + /** * 生命周期函数--监听页面初次渲染完成 */ @@ -280,29 +331,7 @@ }, - - //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 - drawText: function (ctx, str, leftWidth, initHeight, titleHeight, canvasWidth) { - var lineWidth = 0; - var lastSubStrIndex = 0; //每次开始截取的字符串的索引 - for (let i = 0; i < str.length; i++) { - lineWidth += ctx.measureText(str[i]).width; - if (lineWidth > canvasWidth) { - ctx.fillText(str.substring(lastSubStrIndex, i), leftWidth, initHeight); //绘制截取部分 - initHeight = initHeight + leftWidth * 2; //22为字体的高度 - lineWidth = 0; - lastSubStrIndex = i; - // titleHeight += 40; - } - if (i == str.length - 1) { //绘制剩余部分 - ctx.fillText(str.substring(lastSubStrIndex, i + 1), leftWidth, initHeight); - } - } - // // 标题border-bottom 线距顶部距离 - // titleHeight = titleHeight + 10; - // return titleHeight - }, - + //验证表单 formValidate() { if (this.data.form.devcode == "") { @@ -312,27 +341,20 @@ }) return false } - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } if (this.data.form.wellcode == "") { wx.showToast({ icon: 'none', @@ -348,22 +370,10 @@ }) return false } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null) { + + if (this.data.form.installperson == "") { wx.showToast({ icon: 'none', title: '安装人员不能为空!', @@ -408,56 +418,90 @@ } return true; }, + //提交表单 formSubmit: function (event) { + console.log(this.data.form) + //表单参数验证 if (!this.formValidate()) { return false; } var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDevice', + //验证设备编号长度 + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/getDevTypeLength", data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceAdd/add" + code: encodeURI(this.data.form.devicetype) }, - }).then(res => { - if (res.result.code == 500) { - wx.showToast({ - title: '设备编号已安装!', - }) - } else if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - //用于回显 - wx.setStorageSync('cacheList', that.data.form) - //提交成功后提示用户操作 - if (res.confirm) { - wx.switchTab({ - url: '../earth/earth' - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (""==res.data.data ||res.data.data == that.data.form.devcode.length) { + that.saveDevice() + } else { //编号位数不对提示 + wx.showToast({ + icon: 'none', + title: '设备编号位数不对!', + duration: 1000 + }) + return false + } } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "提交失败", - }) }) }, + + //保存设备基本信息 + saveDevice() { + var that = this; + //设置照片路径 + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopathForm = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopathForm]: fileList[i].url.split("static/")[1] + }) + } + //表单提交 + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 500) { + wx.showToast({ + title: '设备编号已安装!', + }) + } else if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + //用于回显 + wx.setStorageSync('cacheList', that.data.form) + //提交成功后提示用户操作 + if (res.confirm) { + wx.switchTab({ + url: '../earth/earth' + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } + }, + fail(err) { + wx.showToast({ + title: '提交失败!', + }) + } + }) + }, + + //input 输入框设置值 confirm(event) { var that = this; var formValue = event.detail.value; @@ -466,8 +510,30 @@ that.setData({ [fromN]: formValue }) + //若输入是设备编号,自动获取设备类型 + if('devcode'==formName){ + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", + data: { + devcode: formValue, + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + that.setData({ + [formDevicetype]: res.data + }); + } + } + }) + } }, + //扫描设备获取编号和设备类型 scan() { var _this = this; wx.scanCode({ @@ -477,23 +543,28 @@ _this.setData({ [formdevcode]: devcode }); - wx.cloud.callFunction({ - name: 'findModeCode', + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", data: { devcode: devcode, - url: app.globalData.url + "appDeviceAdd/findModeCodeByCode" }, - }).then(res => { - if (res.result) { - var formDevicetype = 'form.devicetype' - _this.setData({ - [formDevicetype]: res.result - }); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + _this.setData({ + [formDevicetype]: res.data + }); + } } }) } }) }, + //粘贴经纬度 paste() { var _this = this; wx.getClipboardData({ @@ -510,9 +581,11 @@ longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), }); + _this.showAddress(_this.data.form.longitude,_this.data.form.latitude,_this) } }) }, + //设置经类型 selectValue(value) { var that = this; @@ -521,6 +594,16 @@ [wellType]: value.detail }) }, + + //设置设备类型 + selectDevType(event) { + var that = this; + var devtype = 'form.devicetype'; + that.setData({ + [devtype]: event.detail + }) + }, + //设置运维人员 selectpersonValue(event) { var that = this; var installPerson = 'form.installperson'; @@ -528,6 +611,7 @@ [installPerson]: event.detail }) }, + //设置项目 selectprojectValue(event) { var that = this; var project = 'form.project'; @@ -535,8 +619,41 @@ [project]: event.detail }) }, + showAddress :function(longitude, latitude, self) { + // 实例化腾讯地图API核心类 + qqmapsdk = new QQMapWX({ + key: 'BGPBZ-C5O3P-ROUDR-LWC4J-63EKH-V5FRX'//此处使用你自己申请的key + }) + // 腾讯地图调用接口 + qqmapsdk.reverseGeocoder({ + location: { + latitude: latitude, + longitude: longitude + }, + success: function (res) { + self.setData({ + 'form.area':res.result.address.slice(0,res.result.address.indexOf('区')+1), + 'form.street':res.result.address.slice(res.result.address.indexOf('区')+1) + }) + }, + fail: function (res) { + console.log(res); + }, + complete: function (res) { + } + }); + }, + //上传照片 afterRead(event) { var _this = this; + if (_this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '请先填写设备编号!\r\n否则水印中无编号', + duration: 2000 + }) + return false + } const { file } = event.detail; @@ -576,78 +693,8 @@ }) } }) - // 压缩图片 - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // //获取图片尺寸 - // wx.getImageInfo({ - // src: convertpath, - // success(res) { - // _this.setData({ - // canvasHeight: res.height, - // canvasWidth: res.width - // }) - // var ctx = wx.createCanvasContext('firstCanvas') - - // //将图片src放到cancas内,宽高为图片大小 - // ctx.drawImage(convertpath, 0, 0, res.width, res.height) - // //将声明的时间放入canvas - // ctx.setFontSize(30 * (res.width / 750)) //注意:设置文字大小必须放在填充文字之前,否则不生效 - // ctx.setFillStyle('blue') - // var text = "编号:" + _this.data.form.devcode + "\n经度:" + _this.data.form.longitude + "\n纬度:" + _this.data.form.latitude - // // _this.drawText(ctx,text,20, 70, 5, res.width) - // _this.drawText(ctx, text, 15 * (res.width / 750), 70 * (res.width / 750), 5, res.width) - - // // ctx.fillText(text, 0, 40) - // // ctx.strokeText(_this.data.form.devcode, 0, 30) - // //生成水印图 - // ctx.draw(false, function () { - // wx.canvasToTempFilePath({ - // canvasId: 'firstCanvas', - // success: (res) => { - // wx.compressImage({ - // src: res.tempFilePath, - // quality: 25, - // success: function (res) { - // //上传照片至服务器 - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: res.tempFilePath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // } - // }) - // //// - // } - // }) - // }) - // } - // }) - // } - // }); }, + //删除照片 deletePhoto(event) { var image_index = event.detail.index var fileList_new = this.data.fileList; diff --git a/miniprogram/pages/addDevice/addDevice.wxml b/miniprogram/pages/addDevice/addDevice.wxml index b0977e2..f12c254 100644 --- a/miniprogram/pages/addDevice/addDevice.wxml +++ b/miniprogram/pages/addDevice/addDevice.wxml @@ -5,18 +5,30 @@ - + + + + + + + + + + + + + - - + + - - - + + + @@ -29,13 +41,13 @@ - + - + - + - + @@ -54,8 +66,7 @@ - - + @@ -68,8 +79,8 @@ - - + + - 保存 + 保存 \ No newline at end of file diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.js b/miniprogram/pages/addDevicelog/addDeviceLog.js index cdec71b..a0dc6da 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.js +++ b/miniprogram/pages/addDevicelog/addDeviceLog.js @@ -3,681 +3,665 @@ var app = getApp(); Page({ - /** - * 页面的初始数据 - */ - data: { - pageName: '', - showMask: false, - today: new Date().getTime(), - longitude: '', - latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], - personoption1: [], - projectoption: [], - devcode: "", - deviceMode: "", - installtimeFmt: '', - show: false, - form: { - devcode: "", - wellcode: "", - welltype: "", - welldepth: "", - installheigt: "", - installperson: "", - installtimeFmt: "", - photopath: "", - factory: "", - workmsg: "", - position: "", - description: "", - longitude: "", - latitude: "", - longitude84: "", - latitude84: "", - devicetype: "", - project: "", - area: "", - street: "", - wellname: "" - }, - fileList: [], - detail: "" - }, + /** + * 页面的初始数据 + */ + data: { + pageName: '', + showMask: false, + today: new Date().getTime(), + longitude: '', + latitude: '', + option1: [], + personoption1: [], + projectoption: [], + devcode: "", + deviceMode: "", + installtimeFmt: '', + show: false, + form: { + devcode: "", + wellcode: "", + welltype: "", + welldepth: "", + installheigt: "", + installperson: "", + installtimeFmt: "", + photopath: "", + factory: "", + workmsg: "", + position: "", + description: "", + longitude: "", + latitude: "", + longitude84: "", + latitude84: "", + devicetype: "", + project: "", + area: "", + street: "", + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '' + }, + fileList: [], + detail: "", + markers: [{ + id: 100, + // iconPath: "../../images/point.png", + latitude: '', + longitude: '', + // label:'1', + width: 25, + height: 35 + }], + }, - onDisplay() { - this.setData({ - show: true - }); - }, - onClose() { - this.setData({ - show: false - }); - }, - formatDate() { - var date = new Date(); - // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; - var seperator1 = "-"; - var month = date.getMonth() + 1; - var strDate = date.getDate(); - var hour = date.getHours() - var minute = date.getMinutes() - var second = date.getSeconds() - month = month > 9 ? month : "0" + month; - strDate = strDate > 9 ? strDate : "0" + strDate; - hour = hour > 9 ? hour : "0" + hour; - minute = minute > 9 ? minute : "0" + minute; - second = second > 9 ? second : "0" + second; - var currentdate = - date.getFullYear() + - seperator1 + - month + - seperator1 + - strDate + - " " + - hour + ":" + - minute + ":" + - second; - return currentdate; + onDisplay() { + this.setData({ + show: true + }); + }, + onClose() { + this.setData({ + show: false + }); + }, + formatDate() { + var date = new Date(); + // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; + var seperator1 = "-"; + var month = date.getMonth() + 1; + var strDate = date.getDate(); + var hour = date.getHours() + var minute = date.getMinutes() + var second = date.getSeconds() + month = month > 9 ? month : "0" + month; + strDate = strDate > 9 ? strDate : "0" + strDate; + hour = hour > 9 ? hour : "0" + hour; + minute = minute > 9 ? minute : "0" + minute; + second = second > 9 ? second : "0" + second; + var currentdate = + date.getFullYear() + + seperator1 + + month + + seperator1 + + strDate + + " " + + hour + ":" + + minute + ":" + + second; + return currentdate; - }, - onConfirm(event) { - var installtime = 'form.installtimeFmt'; - this.setData({ - show: false, - installtimeFmt: this.formatDate(event.detail), - [installtime]: this.formatDate(event.detail), - }); - }, + }, + onConfirm(event) { + var installtime = 'form.installtimeFmt'; + this.setData({ + show: false, + installtimeFmt: this.formatDate(event.detail), + [installtime]: this.formatDate(event.detail), + }); + }, - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - var _this = this; - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" - }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); - } - _this.setData({ - personoption1: personArr - }) + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + var _this = this; + _this.setData({ + 'markers[0].latitude': Number(wx.getStorageSync('resultObject').latitude) , + 'markers[0].longitude': Number(wx.getStorageSync('resultObject').longitude), + // 'markers[0].label':'10', + 'markers[0].width': 18, + 'markers[0].id':1, + 'markers[0].height': 30, + latitude:Number(wx.getStorageSync('resultObject').latitude), + longitude:Number(wx.getStorageSync('resultObject').longitude) + }) + //获取人员下拉列表 + // wx.request({ + // method: "POST", + // url: app.globalData.httpsUrl + "deviceType/getUser", + // data:{ + // tips:'repair' + // }, + // header: { + // 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + // }, + // success(res) { + // if (res.data.code == 200) { + // var users = res.data.data + // var personArr = []; + // for (var i = 0; i < users.length; i++) { + // var person = { + // text: users[i].name, + // value: users[i].name + // }; + // personArr.push(person); + // } + // _this.setData({ + // personoption1: personArr + // }) + // } + // } + // }) + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); } - }).catch(err => { - console.error(err); - }) - - - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" - }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - _this.setData({ - projectoption: projectArr - }) - } - }).catch(err => { - console.error(err); - }) - - if (options.pageName) { - this.setData({ - pageName: options.pageName - }) - } - - if (options.detail) { - - var formObject = JSON.parse(options.detail); _this.setData({ - form: formObject, - detail: options.detail + projectoption: projectArr }) - - _this.setData({ - ['form.installperson']: "", - ['form.installtimeFmt']: "", - ['form.workmsg']: "", - ['form.description']: "" - }) - - const { - fileList = [] - } = _this.data; - if (formObject.photopath1 != "") { - var file1 = { - url: app.globalData.url + "static/" + formObject.photopath1 - } - fileList.push(file1) - } - if (formObject.photopath2 != "") { - var file2 = { - url: app.globalData.url + "static/" + formObject.photopath2 - } - fileList.push(file2) - } - if (formObject.photopath3 != "") { - var file3 = { - url: app.globalData.url + "static/" + formObject.photopath3 - } - fileList.push(file3) - } - - _this.setData({ - fileList - }); } - var installtime = 'form.installtimeFmt'; - var dateNow = this.formatDate(); - this.setData({ - installtimeFmt: dateNow, - [installtime]: dateNow, - }); - }, + } + }) - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { + //获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + _this.setData({ + option1: welltypeArr + }) + } + } +}) - }, + //跳转时带入参数返回哪页 + if (options.pageName) { + this.setData({ + pageName: options.pageName + }) + } + //跳转时带入参数设备的安装信息 + if (wx.getStorageSync('resultObject')) { + var formObject = wx.getStorageSync('resultObject') + _this.setData({ + form: formObject, + detail: formObject + }) - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { + _this.setData({ + ['form.installperson']: app.globalData.userName, + ['form.installtimeFmt']: "", + ['form.workmsg']: "", + ['form.description']: "" + }) - }, + const { + fileList = [] + } = _this.data; + if (formObject.photopath1 != "") { + var file1 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath1 + } + fileList.push(file1) + } + if (formObject.photopath2 != "") { + var file2 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath2 + } + fileList.push(file2) + } + if (formObject.photopath3 != "") { + var file3 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath3 + } + fileList.push(file3) + } + _this.setData({ + fileList + }); + } + var installtime = 'form.installtimeFmt'; + var dateNow = this.formatDate(); + this.setData({ + installtimeFmt: dateNow, + [installtime]: dateNow, + }); + }, - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, - }, + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + wx.removeStorageSync('resultObject') + }, - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, - }, + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { + }, - }, + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { + }, - }, + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { + }, - }, + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + }, - /** - * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true - **/ + /** + * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true + **/ - isNumber: function (val) { + isNumber: function (val) { - var regPos = /^[0-9]*$/; //非负浮点数 - var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数 - if (regPos.test(val) || regNeg.test(val)) { - return false; - } else { - return true; - } + var regPos = /^[0-9]*$/; //非负浮点数 + var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数 + if (regPos.test(val) || regNeg.test(val)) { + return false; + } else { + return true; + } - }, + }, - formValidate() { + formValidate() { - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } - if (this.data.form.wellcode == "") { - wx.showToast({ - icon: 'none', - title: '井编号不能为空!', - }) - return false - } - if (this.data.form.devicetype == "") { - wx.showToast({ - icon: 'none', - title: '设备类型不能为空!', - }) - return false - } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + if (this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '设备编号不能为空!', + }) + return false + } + if (this.data.form.wellcode == "") { + wx.showToast({ + icon: 'none', + title: '井编号不能为空!', + }) + return false + } + if (this.data.form.devicetype == "") { + wx.showToast({ + icon: 'none', + title: '设备类型不能为空!', + }) + return false + } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null || - this.data.form.installperson == '') { - wx.showToast({ - icon: 'none', - title: '运维人员不能为空!', - }) - return false - } - if (this.data.form.project == "") { - wx.showToast({ - icon: 'none', - title: '所属项目不能为空!', - }) - return false - } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } + if (this.data.form.installperson == null || + this.data.form.installperson == '') { + wx.showToast({ + icon: 'none', + title: '运维人员不能为空!', + }) + return false + } + if (this.data.form.project == "") { + wx.showToast({ + icon: 'none', + title: '所属项目不能为空!', + }) + return false + } - if (this.data.form.welldepth != null) { - if (this.isNumber(this.data.form.welldepth)) { - wx.showToast({ - icon: 'none', - title: '井深必须为数值!', - }) - return false - } - } - if (this.data.form.installheigt != null) { - if (this.isNumber(this.data.form.installheigt)) { - wx.showToast({ - icon: 'none', - title: '到井口距离必须为数值!', - }) - return false - } - } - - return true; - }, - - changeMsg: function () { - var formNew = this.data.form; - var formOld = JSON.parse(this.data.detail); - var descpNew = ""; - if (formNew.devcode != formOld.devcode) { - descpNew += "修改设备编号,原编号:" + formOld.devcode + ",新编号:" + formNew.devcode + ";" - } - if (formNew.devicetype != formOld.devicetype) { - descpNew += "修改设备类型,原设备类型:" + formOld.devicetype + ",新设备类型:" + formNew.devicetype + ";" - } - if (formNew.area != formOld.area) { - descpNew += "修改区,原区:" + formOld.area + ",新区:" + formNew.area + ";" - } - if (formNew.street != formOld.street) { - descpNew += "修改街道,原街道:" + formOld.street + ",新街道:" + formNew.street + ";" - } - if (formNew.wellname != formOld.wellname) { - descpNew += "修改井名称,原井名称:" + formOld.wellname + ",新井名称:" + formNew.wellname + ";" - } - if (formNew.factory != formOld.factory) { - descpNew += "修改权属单位,原权属单位:" + formOld.factory + ",新权属单位:" + formNew.factory + ";" - } - if (formNew.installheigt != formOld.installheigt) { - descpNew += "修改井口距离,原井口距离:" + formOld.installheigt + ",新井口距离:" + formNew.installheigt + ";" - } - if (formNew.installperson != formOld.installperson) { - descpNew += "修改运维人员,原运维人员:" + formOld.installperson + ",新运维人员:" + formNew.installperson + ";" - } - if (formNew.latitude != formOld.latitude) { - descpNew += "修改纬度,原纬度:" + formOld.latitude + ",新纬度:" + formNew.latitude + ";" - } - if (formNew.longitude != formOld.longitude) { - descpNew += "修改经度,原经度:" + formOld.longitude + ",新经度:" + formNew.longitude + ";" - } - if (formNew.position != formOld.position) { - descpNew += "修改位置描述,原位置:" + formOld.position + ",新位置:" + formNew.position + ";" - } - if (formNew.wellcode != formOld.wellcode) { - descpNew += "修改井编号,原编号:" + formOld.wellcode + ",新编号:" + formNew.wellcode + ";" - } - if (formNew.welldepth != formOld.welldepth) { - descpNew += "修改井深,原井深:" + formOld.welldepth + ",新井深:" + formNew.welldepth + ";" - } - if (formNew.welltype != formOld.welltype) { - descpNew += "修改井类型,原井类型:" + formOld.welltype + ",新井类型:" + formNew.welltype + ";" - } - if (formNew.project != formOld.project) { - descpNew += "修改所属项目,原项目:" + formOld.project + ",新项目:" + formNew.project + ";" - } - if (this.data.photopath1 != formOld.photopath1 || - this.data.photopath2 != formOld.photopath2 || - this.data.photopath3 != formOld.photopath3) { - descpNew += "修改照片;" - } - if ("" != formNew.description) { - descpNew += formNew.description; - } - this.setData({ - ['form.description']: descpNew + if (this.data.form.welldepth != null) { + if (this.isNumber(this.data.form.welldepth)) { + wx.showToast({ + icon: 'none', + title: '井深必须为数值!', }) - }, + return false + } + } + if (this.data.form.installheigt != null) { + if (this.isNumber(this.data.form.installheigt)) { + wx.showToast({ + icon: 'none', + title: '到井口距离必须为数值!', + }) + return false + } + } - formSubmit: function (event) { + return true; + }, - if (!this.formValidate()) { - return false; - } - this.changeMsg(); - var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDeviceLog', - data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceLog/add" - }, - }).then(res => { - // var resultObj=JSON.parse(res.result); - if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - if (res.confirm) { - wx.switchTab({ - url: that.data.pageName - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) - } - }).catch(err => { - console.error(err) - wx.showToast({ - title: "提交失败", - }) - }) - }, - confirm(event) { - var that = this; - var formValue = event.detail.value; - var formName = event.target.dataset.id; - var fromN = 'form.' + [formName]; - that.setData({ - [fromN]: formValue - }) - }, + //获取与上次修改的信息 + changeMsg: function () { + var formNew = this.data.form; + console.log(this.data.detail) + var formOld = JSON.parse(this.data.detail); + var descpNew = ""; + if (formNew.devcode != formOld.devcode) { + descpNew += "修改设备编号,原值:" + formOld.devcode + ",新值:" + formNew.devcode + ";" + } + if (formNew.devicetype != formOld.devicetype) { + descpNew += "修改设备类型,原值:" + formOld.devicetype + ",新值:" + formNew.devicetype + ";" + } + if (formNew.area != formOld.area) { + descpNew += "修改区,原值:" + formOld.area + ",新值:" + formNew.area + ";" + } + if (formNew.street != formOld.street) { + descpNew += "修改街道,原值:" + formOld.street + ",新值:" + formNew.street + ";" + } + if (formNew.wellname != formOld.wellname) { + descpNew += "修改井名称,原值:" + formOld.wellname + ",新值:" + formNew.wellname + ";" + } + if (formNew.factory != formOld.factory) { + descpNew += "修改权属单位,原值:" + formOld.factory + ",新值:" + formNew.factory + ";" + } + if (formNew.installheigt != formOld.installheigt) { + descpNew += "修改井口距离,原值:" + formOld.installheigt + ",新值:" + formNew.installheigt + ";" + } + if (formNew.installperson != formOld.installperson) { + descpNew += "修改运维人员,原值:" + formOld.installperson + ",新值:" + formNew.installperson + ";" + } + if (formNew.latitude != formOld.latitude) { + descpNew += "修改纬度,原值:" + formOld.latitude + ",新值:" + formNew.latitude + ";" + } + if (formNew.longitude != formOld.longitude) { + descpNew += "修改经度,原值:" + formOld.longitude + ",新值:" + formNew.longitude + ";" + } + if (formNew.position != formOld.position) { + descpNew += "修改位置描述,原值:" + formOld.position + ",新值:" + formNew.position + ";" + } + if (formNew.wellcode != formOld.wellcode) { + descpNew += "修改井编号,原值:" + formOld.wellcode + ",新值:" + formNew.wellcode + ";" + } + if (formNew.welldepth != formOld.welldepth) { + descpNew += "修改井深,原值:" + formOld.welldepth + ",新值:" + formNew.welldepth + ";" + } + if (formNew.welltype != formOld.welltype) { + descpNew += "修改井类型,原值:" + formOld.welltype + ",新值:" + formNew.welltype + ";" + } + if (formNew.project != formOld.project) { + descpNew += "修改所属项目,原值:" + formOld.project + ",新值:" + formNew.project + ";" + } + if (this.data.form.photopath1 != formOld.photopath1 || + this.data.form.photopath2 != formOld.photopath2 || + this.data.form.photopath3 != formOld.photopath3) { + descpNew += "修改照片;" + } + if ("" != formNew.description) { + descpNew += formNew.description; + } + this.setData({ + ['form.description']: descpNew + }) + }, - scan() { + //提交表单 + formSubmit: function (event) { - wx.scanCode({ - success(res) { - console.log(res) - } - }) + //表单验证 + if (!this.formValidate()) { + return false; + } + //自动生成修改内容 + this.changeMsg(); + //提交权限限制(只有施工人员能修改) + if(app.globalData.role!='repair'){ + wx.showToast({ + icon: 'none', + title: '无权限修改', + duration:2000 + }) + return false + } + var that = this; + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopath = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopath]: fileList[i].url.split("static/")[1] + }) + } + delete that.data.form.installtime + delete that.data.form.createtime + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - paste() { - var _this = this; - wx.getClipboardData({ - success: function (res) { - var longitude = 'form.longitude'; - var latitude = 'form.latitude'; - var longitude84 = 'form.longitude84'; - var latitude84 = 'form.latitude84'; - _this.setData({ - [longitude]: parseFloat(res.data.split(",", 4)[1]).toFixed(6), - [latitude]: parseFloat(res.data.split(",", 4)[0]).toFixed(6), - [longitude84]: "" == (res.data.split(",", 4)[3]) ? "" : parseFloat(res.data.split(",", 4)[3]).toFixed(6), - [latitude84]: "" == (res.data.split(",", 4)[2]) ? "" : parseFloat(res.data.split(",", 4)[2]).toFixed(6), - longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), - latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), - }); - } - }) - }, - selectValue(value) { - var that = this; - var wellType = 'form.welltype'; - that.setData({ - [wellType]: value.detail - }) - }, - selectpersonValue(event) { - var that = this; - var installPerson = 'form.installperson'; - that.setData({ - [installPerson]: event.detail - }) - }, - selectprojectValue(event) { - var that = this; - var project = 'form.project'; - that.setData({ - [project]: event.detail, - showMask: true - }) - }, - open() { - this.setData({ - showMask: true - }) - }, - close() { - this.setData({ - showMask: false - }) - }, - afterRead(event) { - var _this = this; - const { - file - } = event.detail; - const { - fileList = [] - } = _this.data; - var convertpath = ""; - wx.compressImage({ - src: event.detail.file.path, - quality: 25, - success: function (res) { - convertpath = res.tempFilePath; - wx.uploadFile({ - url: app.globalData.httpsUrl + "appDeviceAdd/fileUploadMarker", - filePath:convertpath, - name: 'file', - formData: { - 'text': "编号:" + _this.data.form.devcode + "经度:" + _this.data.form.longitude + "纬度:" + _this.data.form.latitude - }, - header: { - "Content-Type": "multipart/form-data", - 'accept': 'application/json', - }, - success(res) { - if (res.data) { - var url = JSON.parse(res.data); - fileList.push({ - ...file, - url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - }); - _this.setData({ - fileList - }); - } - } + success(res) { + if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + if (res.confirm) { + wx.switchTab({ + url: that.data.pageName }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') } - }) - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // // var base64 = "data:image/png;base64," + wx.getFileSystemManager().readFileSync(convertpath, 'base64'); - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: convertpath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // // wx.cloud.callFunction({ - // // name: 'uploadFile', - // // data: { - // // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // // fileBase64: base64 - // // }, - // // success: function (res) { - // // if (res.result) { - // // fileList.push({ - // // ...file, - // // url: app.globalData.url + "static/" + res.result.data.replace(/\\/g, "/") - // // }); - // // _this.setData({ - // // fileList - // // }); - // // } - // // }, - // // complete: res => { - // // }, - // // }) - // } - // }); + } + }) + } + }, + fail(err) { + wx.showToast({ + title: "提交失败", + }) + } + }) + }, + //报存录入的input信息 + confirm(event) { + var that = this; + var formValue = event.detail.value; + var formName = event.target.dataset.id; + var fromN = 'form.' + [formName]; + that.setData({ + [fromN]: formValue + }) + }, + + //扫码 + scan() { + + wx.scanCode({ + success(res) { + console.log(res) + } + }) + }, + //粘贴经纬度 + paste() { + var _this = this; + wx.getClipboardData({ + success: function (res) { + var longitude = 'form.longitude'; + var latitude = 'form.latitude'; + var longitude84 = 'form.longitude84'; + var latitude84 = 'form.latitude84'; + _this.setData({ + [longitude]: parseFloat(res.data.split(",", 4)[1]).toFixed(6), + [latitude]: parseFloat(res.data.split(",", 4)[0]).toFixed(6), + [longitude84]: "" == (res.data.split(",", 4)[3]) ? "" : parseFloat(res.data.split(",", 4)[3]).toFixed(6), + [latitude84]: "" == (res.data.split(",", 4)[2]) ? "" : parseFloat(res.data.split(",", 4)[2]).toFixed(6), + longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), + latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), + }); + } + }) + }, + selectValue(value) { + var that = this; + var wellType = 'form.welltype'; + that.setData({ + [wellType]: value.detail + }) + }, + //运维人员默认为登录人 + // selectpersonValue(event) { + // var that = this; + // var installPerson = 'form.installperson'; + // that.setData({ + // [installPerson]: event.detail + // }) + // }, + selectprojectValue(event) { + var that = this; + var project = 'form.project'; + that.setData({ + [project]: event.detail, + showMask: true + }) + }, + + open() { + this.setData({ + showMask: true + }) + }, + //隐藏textarea,防止遮挡 + close() { + this.setData({ + showMask: false + }) + }, + //上传照片 + afterRead(event) { + var _this = this; + const { + file + } = event.detail; + const { + fileList = [] + } = _this.data; + var convertpath = ""; + wx.compressImage({ + src: event.detail.file.path, + quality: 25, + success: function (res) { + convertpath = res.tempFilePath; + wx.uploadFile({ + url: app.globalData.httpsUrl + "appDeviceAdd/fileUploadMarker", + filePath: convertpath, + name: 'file', + formData: { + 'text': "编号:" + _this.data.form.devcode + "经度:" + _this.data.form.longitude + "纬度:" + _this.data.form.latitude }, - deletePhoto(event) { - var that = this - var image_index = event.detail.index - var fileList_new = that.data.fileList; - wx.showModal({ - content: '确定删除照片?', - success: function (res) { - if (res.confirm) { - fileList_new.splice(image_index, 1); - that.setData({ - fileList: fileList_new - }) - wx.cloud.callFunction({ - name: 'deletePhoto', - data: { - url: app.globalData.url + "appDeviceLog/deletePhoto", - devcode: that.data.form.devcode, - pathIndex: image_index - }, - success: function (res) {}, - complete: res => {}, - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + "Content-Type": "multipart/form-data", + 'accept': 'application/json', }, - }) \ No newline at end of file + success(res) { + if (res.data) { + var url = JSON.parse(res.data); + fileList.push({ + ...file, + url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") + }); + _this.setData({ + fileList + }); + } + } + }) + } + }) + }, + //删除照片 + deletePhoto(event) { + var that = this + var image_index = event.detail.index + var fileList_new = that.data.fileList; + wx.showModal({ + content: '确定删除照片?', + success: function (res) { + if (res.confirm) { + fileList_new.splice(image_index, 1); + that.setData({ + fileList: fileList_new + }) + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deletePhoto", + data: { + devcode: that.data.form.devcode + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) {} + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } +}) \ No newline at end of file diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.wxml b/miniprogram/pages/addDevicelog/addDeviceLog.wxml index 38620d4..b10cc7d 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.wxml +++ b/miniprogram/pages/addDevicelog/addDeviceLog.wxml @@ -1,15 +1,21 @@ - + + + + + - + - - + + - - + + - + @@ -39,24 +45,25 @@ - - - + + + - + - + + @@ -64,7 +71,7 @@ - + @@ -79,9 +86,9 @@ - + - 保存 + 保存 diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.wxss b/miniprogram/pages/addDevicelog/addDeviceLog.wxss index ee0b75c..08d5fd7 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.wxss +++ b/miniprogram/pages/addDevicelog/addDeviceLog.wxss @@ -24,6 +24,17 @@ display: flex; align-items: center; } +.map-view{ + width: 750rpx; + height: 485rpx; + position: fixed; + top: 0px; + left: 0px; + z-index: 999; +} +.content{ + margin-top: 495rpx; +} .left { width: 210rpx; diff --git a/miniprogram/pages/addFunction/addFunction.js b/miniprogram/pages/addFunction/addFunction.js deleted file mode 100644 index 4966be3..0000000 --- a/miniprogram/pages/addFunction/addFunction.js +++ /dev/null @@ -1,60 +0,0 @@ -// pages/addFunction/addFunction.js - -const code = `// 云函数入口函数 -exports.main = (event, context) => { - console.log(event) - console.log(context) - return { - sum: event.a + event.b - } -}` - -Page({ - - data: { - result: '', - canIUseClipboard: wx.canIUse('setClipboardData'), - }, - - onLoad: function (options) { - - }, - - copyCode: function() { - wx.setClipboardData({ - data: code, - success: function () { - wx.showToast({ - title: '复制成功', - }) - } - }) - }, - - testFunction() { - wx.cloud.callFunction({ - name: 'sum', - data: { - a: 1, - b: 2 - }, - success: res => { - wx.showToast({ - title: '调用成功', - }) - this.setData({ - result: JSON.stringify(res.result) - }) - }, - fail: err => { - wx.showToast({ - icon: 'none', - title: '调用失败', - }) - console.error('[云函数] [sum] 调用失败:', err) - } - }) - }, - -}) - diff --git a/miniprogram/pages/addFunction/addFunction.json b/miniprogram/pages/addFunction/addFunction.json deleted file mode 100644 index a9a50c5..0000000 --- a/miniprogram/pages/addFunction/addFunction.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "navigationBarTitleText": "云函数指引", - "usingComponents": {} -} \ No newline at end of file diff --git a/miniprogram/pages/addFunction/addFunction.wxml b/miniprogram/pages/addFunction/addFunction.wxml deleted file mode 100644 index 3a10626..0000000 --- a/miniprogram/pages/addFunction/addFunction.wxml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - 测试云函数 - - - 期望输出:{"sum":3} - - - 调用结果:{{result}} - - - - - 新增云函数 - 1. 在云函数根目录 cloudfunctions 上右键选择新建云函数,命名为 sum - 2. 在创建的 cloudfunctions/sum/index.js 文件中添加如下代码 - - - 3. 在 cloudfunctions/sum 目录上右键上传并部署 - 4. 点击测试云函数测试 - 5. 打开云开发云函数管理页,选择 sum 云函数 - 6. 查看 sum 的调用日志 - 进阶:可在云函数中使用 wx-server-sdk 操作数据库,文件存储和调用其他云函数,详见文档 - - - diff --git a/miniprogram/pages/addFunction/addFunction.wxss b/miniprogram/pages/addFunction/addFunction.wxss deleted file mode 100644 index 7ac8619..0000000 --- a/miniprogram/pages/addFunction/addFunction.wxss +++ /dev/null @@ -1,3 +0,0 @@ -/* pages/addFunction/addFunction.wxss */ - -@import "../../style/guide.wxss"; \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.js b/miniprogram/pages/applog/applog.js index 0e8c185..189e61f 100644 --- a/miniprogram/pages/applog/applog.js +++ b/miniprogram/pages/applog/applog.js @@ -13,98 +13,25 @@ isSeach: "false", params: {}, total: 0, - show: false + show: false, + delBtnWidth: 100, //删除按钮宽度单位(rpx) + activeIndex: -1, + list_style: '' }, - - touchE: function (e) { - // console.log(e); - var that = this - if (e.changedTouches.length == 1) { - //手指移动结束后触摸点位置的X坐标 - var endX = e.changedTouches[0].clientX; - //触摸开始与结束,手指移动的距离 - var disX = that.data.startX - endX; - var delBtnWidth = that.data.delBtnWidth; - //如果距离小于删除按钮的1/2,不显示删除按钮 - var txtStyle = disX > delBtnWidth / 2 ? "left:-" + delBtnWidth + "rpx" : "left:0rpx"; - - //获取手指触摸的是哪一项 - var index = e.currentTarget.dataset.index; - var list = that.data.deviceloglist; - list[index].txtStyle = txtStyle; - //更新列表的状态 - that.setData({ - deviceloglist: list - }); - } - }, - //手指触摸动作开始 记录起点X坐标 - touchstart: function (e) { - //开始触摸时 重置所有删除 - this.data.deviceloglist.forEach(function (v, i) { - if (v.isTouchMove) //只操作为true的 - v.isTouchMove = false; - }) - this.setData({ - startX: e.changedTouches[0].clientX, - startY: e.changedTouches[0].clientY, - deviceloglist: this.data.deviceloglist - }) - }, - //滑动事件处理 - touchmove: function (e) { - var that = this, - index = e.currentTarget.dataset.index, //当前索引 - startX = that.data.startX, //开始X坐标 - startY = that.data.startY, //开始Y坐标 - touchMoveX = e.changedTouches[0].clientX, //滑动变化坐标 - touchMoveY = e.changedTouches[0].clientY, //滑动变化坐标 - //获取滑动角度 - angle = that.angle({ - X: startX, - Y: startY - }, { - X: touchMoveX, - Y: touchMoveY - }); - that.data.deviceloglist.forEach(function (v, i) { - v.isTouchMove = false - //滑动超过30度角 return - if (Math.abs(angle) > 30) return; - if (i == index) { - if (touchMoveX > startX) //右滑 - v.isTouchMove = false - else //左滑 - v.isTouchMove = true - } - }) - //更新数据 - that.setData({ - deviceloglist: that.data.deviceloglist - }) - }, - /** - * 计算滑动角度 - * @param {Object} start 起点坐标 - * @param {Object} end 终点坐标 - */ - angle: function (start, end) { - var _X = end.X - start.X, - _Y = end.Y - start.Y - //返回角度 /Math.atan()返回数字的反正切值 - return 360 * Math.atan(_Y / _X) / (2 * Math.PI); - }, - /** - * 生命周期函数--监听页面加载var_this=this; - */ onLoad: function (options) { - if (options.params) { this.setData({ params: JSON.parse(options.params), isSeach: "true" }) this.initPages() + }else{ + this.setData({ + show: false + }) + //清空参数,重新加载 + this.clearParams(); + this.initPages(); } }, @@ -116,20 +43,33 @@ }, + //点击tabBar事件 + onTabItemTap(item) { + //隐藏历史显示总记录条数 + this.setData({ + show: false + }) + //清空参数,重新加载 + this.clearParams(); + this.initPages(); + }, + + /** * 生命周期函数--监听页面显示 */ onShow: function (options) { - this.setData({ - show:false - }) - if (this.data.isSeach == "false") { - this.clearParams(); - this.initPages(); - } - this.setData({ - isSeach: "false" - }) + + // this.setData({ + // show: false + // }) + // if (this.data.isSeach == "false") { + // this.clearParams(); + // this.initPages(); + // } + // this.setData({ + // isSeach: "false" + // }) }, /** @@ -167,6 +107,119 @@ }, + + //手指触摸动作开始 记录起点X坐标 + touchstart: function (e) { + //开始触摸时 重置所有删除 + this.data.deviceloglist.forEach(function (v, i) { + if (v.isTouchMove) //只操作为true的 + v.isTouchMove = false; + }) + this.setData({ + startX: e.changedTouches[0].clientX, + startY: e.changedTouches[0].clientY, + deviceloglist: this.data.deviceloglist + }) + }, + + //滑动事件处理 + touchmove: function (e) { + var that = this, + index = e.currentTarget.dataset.index, //当前索引 + startX = that.data.startX, //开始X坐标 + startY = that.data.startY, //开始Y坐标 + touchMoveX = e.changedTouches[0].clientX, //滑动变化坐标 + touchMoveY = e.changedTouches[0].clientY, //滑动变化坐标 + //获取滑动角度 + angle = that.angle({ + X: startX, + Y: startY + }, { + X: touchMoveX, + Y: touchMoveY + }); + that.data.deviceloglist.forEach(function (v, i) { + // v.isTouchMove = false + //滑动超过30度角 return + if (Math.abs(angle) > 30) return; + if (i == index) { + if (touchMoveX > startX) //右滑 + v.isTouchMove = false + else //左滑 + v.isTouchMove = true + } + }) + //更新数据 + that.setData({ + deviceloglist: that.data.deviceloglist + }) + }, + + /** + * 计算滑动角度 + * @param {Object} start 起点坐标 + * @param {Object} end 终点坐标 + */ + angle: function (start, end) { + var _X = end.X - start.X, + _Y = end.Y - start.Y + //返回角度 /Math.atan()返回数字的反正切值 + return 360 * Math.atan(_Y / _X) / (2 * Math.PI); + }, + + //删除事件 + delItem: function (e) { + if(app.globalData.role!='repair'){ + wx.showToast({ + icon: 'none', + title: '无权限删除', + duration:2000 + }) + return false + } + var that = this + wx.showModal({ + content: '是否删除?', + success: function (res) { + if (res.confirm) { + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/delete", + data: { + appDeviceAddId: e.currentTarget.dataset.devid + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if(res.data.code=='200'){ + that.data.deviceloglist.splice(e.currentTarget.dataset.index, 1) + that.setData({ + deviceloglist: that.data.deviceloglist, + total: that.data.deviceloglist.length + }) + wx.showToast({ + title: '删除成功!', + icon: 'none', + duration: 1000 + }) + } + }, + fail(err) { + wx.showToast({ + title: '删除失败!', + icon: 'none', + duration: 2000 + }) + } + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + }, + showLoading: function (message) { if (wx.showLoading) { // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 @@ -199,95 +252,105 @@ deviceloglist: [] }) }, + //查询列表数据 initPages: function () { var that = this + that.setData({ + show: false + }) var offsetValue = that.data.deviceloglist.length % 15 > 0 ? parseInt(that.data.deviceloglist.length / 15) + 2 : parseInt(that.data.deviceloglist.length / 15) + 1 - wx.cloud.callFunction({ - name: 'devicelog', + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/listPage", data: { devcode: that.data.params.devcode, devtype: that.data.params.devtype, installtimeFmt: that.data.params.installtimeFmt, project: that.data.params.project, installPerson: that.data.params.installPerson, - url: app.globalData.url + "appDeviceLog/listPage", limit: 15, offset: offsetValue }, - }).then(res => { - if (res.result.data.rows.length > 0) { - var resultJson = res.result - that.setData({ - deviceloglist: that.data.deviceloglist.concat(resultJson.data.rows) - }) - } else if (that.data.deviceloglist.length > 0) { - that.setData({ - show: true, - total: that.data.deviceloglist.length - }) - wx.showToast({ - title: '数据已全部加载完', - icon: 'none', - duration: 2000 - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.data.rows.length > 0) { + var resultJson = res.data + var listArr = resultJson.data.rows + listArr.forEach(function (v, i) { + listArr[i]['isTouchMove'] = false + }) + that.setData({ + deviceloglist: that.data.deviceloglist.concat(listArr) + }) + } else if (that.data.deviceloglist.length > 0) { + that.setData({ + show: true, + total: that.data.deviceloglist.length + }) + wx.showToast({ + title: '数据已全部加载完', + icon: 'none', + duration: 2000 + }) + } + if (offsetValue == 1 && res.data.data.rows.length < 15) { + that.setData({ + show: true, + total: that.data.deviceloglist.length + }) + } } - if(offsetValue==1&&res.result.data.rows.length<15){ - that.setData({ - show: true, - total: that.data.deviceloglist.length - }) - } - // console.log(res); - }).catch(err => { - console.error(err); }) + }, addDetail: function (event) { - this.showLoading("数据请求中..."); - wx.cloud.callFunction({ - name: 'deviceDetail', + var that = this + that.showLoading("数据请求中..."); + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deviceDetail", data: { devcode: event.target.dataset.devcode, - url: app.globalData.url + "appDeviceLog/deviceDetail", }, - }).then(res => { - this.hideLoading(); - var resultObject = JSON.parse(res.result); - var pageName = '../applog/applog' - if (resultObject.code == 200) { - wx.navigateTo({ - url: '../addDevicelog/addDeviceLog?detail=' + - JSON.stringify(resultObject.data) + "&pageName=" + pageName - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + that.hideLoading(); + // var resultObject = JSON.parse(res.data); + var resultObject = res.data; + var pageName = '../applog/applog' + if (resultObject.code == 200) { + wx.setStorageSync('resultObject', resultObject.data) + wx.navigateTo({ + url: '../addDevicelog/addDeviceLog?detail=' + "&pageName=" + pageName + }) + } + }, + fail(err) { + that.hideLoading(); } - }).catch(err => { - this.hideLoading() }) + }, add: function (event) { - wx.reLaunch({ - url: '../earth/earth?devcode=' + event.target.dataset.devcode - // url: '../earth/earth' + app.globalData.devcode = event.target.dataset.devcode; + wx.switchTab({ + url: '../earth/earth' }) + // wx.reLaunch({ + // url: '../earth/earth?devcode=' + event.target.dataset.devcode + // // url: '../earth/earth' + // }) }, onSearch: function () { + var _this = this wx.navigateTo({ - url: '../searchLog/searchLog' + url: '../searchLog/searchLog?params=' + JSON.stringify(_this.data.params) }) - }, - // initPages: function () { - // wx.cloud.callFunction({ - // name: 'devicelog' - // }).then(res => { - // var that = this; - // var jsonList = JSON.parse(res.result) - // that.setData({ - // deviceloglist: jsonList.data.rows - // }) - // console.log(res); - // }).catch(err => { - // console.error(err); - // }) - // } + } }) \ No newline at end of file diff --git a/cloudfunctions/project.config.json b/cloudfunctions/project.config.json new file mode 100644 index 0000000..2b3119a --- /dev/null +++ b/cloudfunctions/project.config.json @@ -0,0 +1,28 @@ +{ + "appid": "wx2cef527a000f87c9", + "compileType": "miniprogram", + "libVersion": "2.27.3", + "packOptions": { + "ignore": [], + "include": [] + }, + "setting": { + "coverView": true, + "es6": true, + "postcss": true, + "minified": true, + "enhance": true, + "showShadowRootInWxmlPanel": true, + "packNpmRelationList": [], + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + } + }, + "condition": {}, + "editorSetting": { + "tabIndent": "insertSpaces", + "tabSize": 4 + } +} \ No newline at end of file diff --git a/cloudfunctions/project.private.config.json b/cloudfunctions/project.private.config.json new file mode 100644 index 0000000..42ff49d --- /dev/null +++ b/cloudfunctions/project.private.config.json @@ -0,0 +1,7 @@ +{ + "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", + "projectname": "cloudfunctions", + "setting": { + "compileHotReLoad": true + } +} \ No newline at end of file diff --git a/miniprogram/app.js b/miniprogram/app.js index 51d56f3..50a8a54 100644 --- a/miniprogram/app.js +++ b/miniprogram/app.js @@ -18,13 +18,15 @@ // this.globalData = {} }, globalData: { - // url: "http://111.198.10.15:11604/", - httpsUrl: "https://logapi.smartlog.work/", - httpsTestUrl: "https://smartlog.work/prodapi4test/", - url: "http://139.198.18.188:8083/", + httpsUrl: "https://logapi.smartlog.work/", + // httpsUrl: "http://139.198.18.188:8083/", // url: "http://127.0.0.1:8083/", - // httpsUrl: "http://127.0.0.1:8083/", + //httpsUrl: "http://127.0.0.1:8083/", openid: null, - indexCount:1 - }, + indexCount:1, + nickName:"", + userName:"", + role:"", + devcode:"" + } }) diff --git a/miniprogram/app.json b/miniprogram/app.json index d23f798..2b6db76 100644 --- a/miniprogram/app.json +++ b/miniprogram/app.json @@ -1,15 +1,17 @@ { "cloud": true, "pages": [ + "pages/login/login", "pages/indexapp/indexapp", "pages/earth/earth", "pages/applog/applog", "pages/addDevice/addDevice", "pages/addDevicelog/addDeviceLog", - "pages/searchLog/searchLog" + "pages/searchLog/searchLog", + "pages/notice/notice" ], "window": { - "backgroundColor": "#F6F6F6", + "backgroundColor": "#E6D480", "backgroundTextStyle": "light", "navigationBarBackgroundColor": "#FFCF00", "navigationBarTitleText": "智慧施工", @@ -46,11 +48,11 @@ "desc": "你的位置信息将用于小程序位置接口的效果展示" } }, + "requiredPrivateInfos": ["getLocation", "chooseLocation"], "networkTimeout": { "request": 30000, "connectSocket": 30000, "uploadFile": 30000, "downloadFile": 30000 - }, - "style": "v2" + } } \ No newline at end of file diff --git a/miniprogram/images/applocat.png b/miniprogram/images/applocat.png new file mode 100644 index 0000000..fe49f54 --- /dev/null +++ b/miniprogram/images/applocat.png Binary files differ diff --git a/miniprogram/images/back.png b/miniprogram/images/back.png new file mode 100644 index 0000000..32ac82d --- /dev/null +++ b/miniprogram/images/back.png Binary files differ diff --git a/miniprogram/images/bottom.png b/miniprogram/images/bottom.png new file mode 100644 index 0000000..d910e98 --- /dev/null +++ b/miniprogram/images/bottom.png Binary files differ diff --git a/miniprogram/images/header.png b/miniprogram/images/header.png new file mode 100644 index 0000000..6ea222e --- /dev/null +++ b/miniprogram/images/header.png Binary files differ diff --git a/miniprogram/images/login.png b/miniprogram/images/login.png index 8b73cc0..6471c46 100644 --- a/miniprogram/images/login.png +++ b/miniprogram/images/login.png Binary files differ diff --git a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss index 5a591fb..c9c35b5 100644 --- a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss +++ b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:100%;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:100%}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file +@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:650rpx;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:600rpx}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file diff --git a/miniprogram/pages/addDevice/addDevice.js b/miniprogram/pages/addDevice/addDevice.js index 2783674..78f00b7 100644 --- a/miniprogram/pages/addDevice/addDevice.js +++ b/miniprogram/pages/addDevice/addDevice.js @@ -1,5 +1,7 @@ // miniprogram/pages/addDevice/addDevice.js // import WxValidate from '../../utils/WxValidate.js' +var QQMapWX = require('../../libs/qqmap-wx-jssdk.js'); +var qqmapsdk; var app = getApp() Page({ @@ -11,32 +13,10 @@ canvasWidth: '', longitude: '', latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], + option1: [], personoption1: [], projectoption: [], + devtypeList:[], show: false, form: { devcode: "", @@ -59,7 +39,10 @@ project: "", area: "", street: "", - wellname: "" + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '', }, fileList: [] }, @@ -117,12 +100,14 @@ var that = this; //初始化表单内容为上次填写值 var cacheForms = wx.getStorageSync('cacheList') - if (cacheForms) { + cacheForms.photopath1='' + cacheForms.photopath2='' + cacheForms.photopath3='' + that.data.fileList=[] that.setData({ form: cacheForms, devcode: cacheForms.devcode, - }) } var form = that.data.form @@ -155,55 +140,89 @@ } }) + +//获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + that.setData({ + option1: welltypeArr + }) + } + } +}) + + //获取人员下拉列表 - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/getUser", + data:{ + tips:'repair' }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data.code == 200) { + var users = res.data.data + var personArr = []; + for (var i = 0; i < users.length; i++) { + var person = { + text: users[i].name, + value: users[i].name + }; + personArr.push(person); + } + that.setData({ + personoption1: personArr + }) } - that.setData({ - personoption1: personArr - }) } - }).catch(err => { - console.error(err); - }) + }) + - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - that.setData({ - projectoption: projectArr - }) + success(res){ + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); + } + that.setData({ + projectoption: projectArr + }) + } } - }).catch(err => { - console.error(err); - }) + }) + var installtime = 'form.installtimeFmt'; var dateNow = this.formatDate(); this.setData({ @@ -211,8 +230,40 @@ installtimeFmt: dateNow, [installtime]: dateNow, }); + + + + /** + * 获取设备类型下拉列表 + */ + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/deviceType", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var TypeList = res.data.data + var typeArr = []; + for (var i = 0; i < TypeList.length; i++) { + var type = { + text: TypeList[i].productName, + value: TypeList[i].productName + }; + typeArr.push(type); + } + that.setData({ + devtypeList: typeArr + }) + } + } + }) }, + + + /** * 生命周期函数--监听页面初次渲染完成 */ @@ -280,29 +331,7 @@ }, - - //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 - drawText: function (ctx, str, leftWidth, initHeight, titleHeight, canvasWidth) { - var lineWidth = 0; - var lastSubStrIndex = 0; //每次开始截取的字符串的索引 - for (let i = 0; i < str.length; i++) { - lineWidth += ctx.measureText(str[i]).width; - if (lineWidth > canvasWidth) { - ctx.fillText(str.substring(lastSubStrIndex, i), leftWidth, initHeight); //绘制截取部分 - initHeight = initHeight + leftWidth * 2; //22为字体的高度 - lineWidth = 0; - lastSubStrIndex = i; - // titleHeight += 40; - } - if (i == str.length - 1) { //绘制剩余部分 - ctx.fillText(str.substring(lastSubStrIndex, i + 1), leftWidth, initHeight); - } - } - // // 标题border-bottom 线距顶部距离 - // titleHeight = titleHeight + 10; - // return titleHeight - }, - + //验证表单 formValidate() { if (this.data.form.devcode == "") { @@ -312,27 +341,20 @@ }) return false } - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } if (this.data.form.wellcode == "") { wx.showToast({ icon: 'none', @@ -348,22 +370,10 @@ }) return false } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null) { + + if (this.data.form.installperson == "") { wx.showToast({ icon: 'none', title: '安装人员不能为空!', @@ -408,56 +418,90 @@ } return true; }, + //提交表单 formSubmit: function (event) { + console.log(this.data.form) + //表单参数验证 if (!this.formValidate()) { return false; } var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDevice', + //验证设备编号长度 + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/getDevTypeLength", data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceAdd/add" + code: encodeURI(this.data.form.devicetype) }, - }).then(res => { - if (res.result.code == 500) { - wx.showToast({ - title: '设备编号已安装!', - }) - } else if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - //用于回显 - wx.setStorageSync('cacheList', that.data.form) - //提交成功后提示用户操作 - if (res.confirm) { - wx.switchTab({ - url: '../earth/earth' - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (""==res.data.data ||res.data.data == that.data.form.devcode.length) { + that.saveDevice() + } else { //编号位数不对提示 + wx.showToast({ + icon: 'none', + title: '设备编号位数不对!', + duration: 1000 + }) + return false + } } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "提交失败", - }) }) }, + + //保存设备基本信息 + saveDevice() { + var that = this; + //设置照片路径 + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopathForm = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopathForm]: fileList[i].url.split("static/")[1] + }) + } + //表单提交 + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 500) { + wx.showToast({ + title: '设备编号已安装!', + }) + } else if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + //用于回显 + wx.setStorageSync('cacheList', that.data.form) + //提交成功后提示用户操作 + if (res.confirm) { + wx.switchTab({ + url: '../earth/earth' + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } + }, + fail(err) { + wx.showToast({ + title: '提交失败!', + }) + } + }) + }, + + //input 输入框设置值 confirm(event) { var that = this; var formValue = event.detail.value; @@ -466,8 +510,30 @@ that.setData({ [fromN]: formValue }) + //若输入是设备编号,自动获取设备类型 + if('devcode'==formName){ + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", + data: { + devcode: formValue, + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + that.setData({ + [formDevicetype]: res.data + }); + } + } + }) + } }, + //扫描设备获取编号和设备类型 scan() { var _this = this; wx.scanCode({ @@ -477,23 +543,28 @@ _this.setData({ [formdevcode]: devcode }); - wx.cloud.callFunction({ - name: 'findModeCode', + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", data: { devcode: devcode, - url: app.globalData.url + "appDeviceAdd/findModeCodeByCode" }, - }).then(res => { - if (res.result) { - var formDevicetype = 'form.devicetype' - _this.setData({ - [formDevicetype]: res.result - }); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + _this.setData({ + [formDevicetype]: res.data + }); + } } }) } }) }, + //粘贴经纬度 paste() { var _this = this; wx.getClipboardData({ @@ -510,9 +581,11 @@ longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), }); + _this.showAddress(_this.data.form.longitude,_this.data.form.latitude,_this) } }) }, + //设置经类型 selectValue(value) { var that = this; @@ -521,6 +594,16 @@ [wellType]: value.detail }) }, + + //设置设备类型 + selectDevType(event) { + var that = this; + var devtype = 'form.devicetype'; + that.setData({ + [devtype]: event.detail + }) + }, + //设置运维人员 selectpersonValue(event) { var that = this; var installPerson = 'form.installperson'; @@ -528,6 +611,7 @@ [installPerson]: event.detail }) }, + //设置项目 selectprojectValue(event) { var that = this; var project = 'form.project'; @@ -535,8 +619,41 @@ [project]: event.detail }) }, + showAddress :function(longitude, latitude, self) { + // 实例化腾讯地图API核心类 + qqmapsdk = new QQMapWX({ + key: 'BGPBZ-C5O3P-ROUDR-LWC4J-63EKH-V5FRX'//此处使用你自己申请的key + }) + // 腾讯地图调用接口 + qqmapsdk.reverseGeocoder({ + location: { + latitude: latitude, + longitude: longitude + }, + success: function (res) { + self.setData({ + 'form.area':res.result.address.slice(0,res.result.address.indexOf('区')+1), + 'form.street':res.result.address.slice(res.result.address.indexOf('区')+1) + }) + }, + fail: function (res) { + console.log(res); + }, + complete: function (res) { + } + }); + }, + //上传照片 afterRead(event) { var _this = this; + if (_this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '请先填写设备编号!\r\n否则水印中无编号', + duration: 2000 + }) + return false + } const { file } = event.detail; @@ -576,78 +693,8 @@ }) } }) - // 压缩图片 - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // //获取图片尺寸 - // wx.getImageInfo({ - // src: convertpath, - // success(res) { - // _this.setData({ - // canvasHeight: res.height, - // canvasWidth: res.width - // }) - // var ctx = wx.createCanvasContext('firstCanvas') - - // //将图片src放到cancas内,宽高为图片大小 - // ctx.drawImage(convertpath, 0, 0, res.width, res.height) - // //将声明的时间放入canvas - // ctx.setFontSize(30 * (res.width / 750)) //注意:设置文字大小必须放在填充文字之前,否则不生效 - // ctx.setFillStyle('blue') - // var text = "编号:" + _this.data.form.devcode + "\n经度:" + _this.data.form.longitude + "\n纬度:" + _this.data.form.latitude - // // _this.drawText(ctx,text,20, 70, 5, res.width) - // _this.drawText(ctx, text, 15 * (res.width / 750), 70 * (res.width / 750), 5, res.width) - - // // ctx.fillText(text, 0, 40) - // // ctx.strokeText(_this.data.form.devcode, 0, 30) - // //生成水印图 - // ctx.draw(false, function () { - // wx.canvasToTempFilePath({ - // canvasId: 'firstCanvas', - // success: (res) => { - // wx.compressImage({ - // src: res.tempFilePath, - // quality: 25, - // success: function (res) { - // //上传照片至服务器 - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: res.tempFilePath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // } - // }) - // //// - // } - // }) - // }) - // } - // }) - // } - // }); }, + //删除照片 deletePhoto(event) { var image_index = event.detail.index var fileList_new = this.data.fileList; diff --git a/miniprogram/pages/addDevice/addDevice.wxml b/miniprogram/pages/addDevice/addDevice.wxml index b0977e2..f12c254 100644 --- a/miniprogram/pages/addDevice/addDevice.wxml +++ b/miniprogram/pages/addDevice/addDevice.wxml @@ -5,18 +5,30 @@ - + + + + + + + + + + + + + - - + + - - - + + + @@ -29,13 +41,13 @@ - + - + - + - + @@ -54,8 +66,7 @@ - - + @@ -68,8 +79,8 @@ - - + + - 保存 + 保存 \ No newline at end of file diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.js b/miniprogram/pages/addDevicelog/addDeviceLog.js index cdec71b..a0dc6da 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.js +++ b/miniprogram/pages/addDevicelog/addDeviceLog.js @@ -3,681 +3,665 @@ var app = getApp(); Page({ - /** - * 页面的初始数据 - */ - data: { - pageName: '', - showMask: false, - today: new Date().getTime(), - longitude: '', - latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], - personoption1: [], - projectoption: [], - devcode: "", - deviceMode: "", - installtimeFmt: '', - show: false, - form: { - devcode: "", - wellcode: "", - welltype: "", - welldepth: "", - installheigt: "", - installperson: "", - installtimeFmt: "", - photopath: "", - factory: "", - workmsg: "", - position: "", - description: "", - longitude: "", - latitude: "", - longitude84: "", - latitude84: "", - devicetype: "", - project: "", - area: "", - street: "", - wellname: "" - }, - fileList: [], - detail: "" - }, + /** + * 页面的初始数据 + */ + data: { + pageName: '', + showMask: false, + today: new Date().getTime(), + longitude: '', + latitude: '', + option1: [], + personoption1: [], + projectoption: [], + devcode: "", + deviceMode: "", + installtimeFmt: '', + show: false, + form: { + devcode: "", + wellcode: "", + welltype: "", + welldepth: "", + installheigt: "", + installperson: "", + installtimeFmt: "", + photopath: "", + factory: "", + workmsg: "", + position: "", + description: "", + longitude: "", + latitude: "", + longitude84: "", + latitude84: "", + devicetype: "", + project: "", + area: "", + street: "", + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '' + }, + fileList: [], + detail: "", + markers: [{ + id: 100, + // iconPath: "../../images/point.png", + latitude: '', + longitude: '', + // label:'1', + width: 25, + height: 35 + }], + }, - onDisplay() { - this.setData({ - show: true - }); - }, - onClose() { - this.setData({ - show: false - }); - }, - formatDate() { - var date = new Date(); - // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; - var seperator1 = "-"; - var month = date.getMonth() + 1; - var strDate = date.getDate(); - var hour = date.getHours() - var minute = date.getMinutes() - var second = date.getSeconds() - month = month > 9 ? month : "0" + month; - strDate = strDate > 9 ? strDate : "0" + strDate; - hour = hour > 9 ? hour : "0" + hour; - minute = minute > 9 ? minute : "0" + minute; - second = second > 9 ? second : "0" + second; - var currentdate = - date.getFullYear() + - seperator1 + - month + - seperator1 + - strDate + - " " + - hour + ":" + - minute + ":" + - second; - return currentdate; + onDisplay() { + this.setData({ + show: true + }); + }, + onClose() { + this.setData({ + show: false + }); + }, + formatDate() { + var date = new Date(); + // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; + var seperator1 = "-"; + var month = date.getMonth() + 1; + var strDate = date.getDate(); + var hour = date.getHours() + var minute = date.getMinutes() + var second = date.getSeconds() + month = month > 9 ? month : "0" + month; + strDate = strDate > 9 ? strDate : "0" + strDate; + hour = hour > 9 ? hour : "0" + hour; + minute = minute > 9 ? minute : "0" + minute; + second = second > 9 ? second : "0" + second; + var currentdate = + date.getFullYear() + + seperator1 + + month + + seperator1 + + strDate + + " " + + hour + ":" + + minute + ":" + + second; + return currentdate; - }, - onConfirm(event) { - var installtime = 'form.installtimeFmt'; - this.setData({ - show: false, - installtimeFmt: this.formatDate(event.detail), - [installtime]: this.formatDate(event.detail), - }); - }, + }, + onConfirm(event) { + var installtime = 'form.installtimeFmt'; + this.setData({ + show: false, + installtimeFmt: this.formatDate(event.detail), + [installtime]: this.formatDate(event.detail), + }); + }, - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - var _this = this; - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" - }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); - } - _this.setData({ - personoption1: personArr - }) + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + var _this = this; + _this.setData({ + 'markers[0].latitude': Number(wx.getStorageSync('resultObject').latitude) , + 'markers[0].longitude': Number(wx.getStorageSync('resultObject').longitude), + // 'markers[0].label':'10', + 'markers[0].width': 18, + 'markers[0].id':1, + 'markers[0].height': 30, + latitude:Number(wx.getStorageSync('resultObject').latitude), + longitude:Number(wx.getStorageSync('resultObject').longitude) + }) + //获取人员下拉列表 + // wx.request({ + // method: "POST", + // url: app.globalData.httpsUrl + "deviceType/getUser", + // data:{ + // tips:'repair' + // }, + // header: { + // 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + // }, + // success(res) { + // if (res.data.code == 200) { + // var users = res.data.data + // var personArr = []; + // for (var i = 0; i < users.length; i++) { + // var person = { + // text: users[i].name, + // value: users[i].name + // }; + // personArr.push(person); + // } + // _this.setData({ + // personoption1: personArr + // }) + // } + // } + // }) + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); } - }).catch(err => { - console.error(err); - }) - - - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" - }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - _this.setData({ - projectoption: projectArr - }) - } - }).catch(err => { - console.error(err); - }) - - if (options.pageName) { - this.setData({ - pageName: options.pageName - }) - } - - if (options.detail) { - - var formObject = JSON.parse(options.detail); _this.setData({ - form: formObject, - detail: options.detail + projectoption: projectArr }) - - _this.setData({ - ['form.installperson']: "", - ['form.installtimeFmt']: "", - ['form.workmsg']: "", - ['form.description']: "" - }) - - const { - fileList = [] - } = _this.data; - if (formObject.photopath1 != "") { - var file1 = { - url: app.globalData.url + "static/" + formObject.photopath1 - } - fileList.push(file1) - } - if (formObject.photopath2 != "") { - var file2 = { - url: app.globalData.url + "static/" + formObject.photopath2 - } - fileList.push(file2) - } - if (formObject.photopath3 != "") { - var file3 = { - url: app.globalData.url + "static/" + formObject.photopath3 - } - fileList.push(file3) - } - - _this.setData({ - fileList - }); } - var installtime = 'form.installtimeFmt'; - var dateNow = this.formatDate(); - this.setData({ - installtimeFmt: dateNow, - [installtime]: dateNow, - }); - }, + } + }) - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { + //获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + _this.setData({ + option1: welltypeArr + }) + } + } +}) - }, + //跳转时带入参数返回哪页 + if (options.pageName) { + this.setData({ + pageName: options.pageName + }) + } + //跳转时带入参数设备的安装信息 + if (wx.getStorageSync('resultObject')) { + var formObject = wx.getStorageSync('resultObject') + _this.setData({ + form: formObject, + detail: formObject + }) - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { + _this.setData({ + ['form.installperson']: app.globalData.userName, + ['form.installtimeFmt']: "", + ['form.workmsg']: "", + ['form.description']: "" + }) - }, + const { + fileList = [] + } = _this.data; + if (formObject.photopath1 != "") { + var file1 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath1 + } + fileList.push(file1) + } + if (formObject.photopath2 != "") { + var file2 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath2 + } + fileList.push(file2) + } + if (formObject.photopath3 != "") { + var file3 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath3 + } + fileList.push(file3) + } + _this.setData({ + fileList + }); + } + var installtime = 'form.installtimeFmt'; + var dateNow = this.formatDate(); + this.setData({ + installtimeFmt: dateNow, + [installtime]: dateNow, + }); + }, - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, - }, + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + wx.removeStorageSync('resultObject') + }, - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, - }, + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { + }, - }, + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { + }, - }, + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { + }, - }, + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + }, - /** - * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true - **/ + /** + * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true + **/ - isNumber: function (val) { + isNumber: function (val) { - var regPos = /^[0-9]*$/; //非负浮点数 - var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数 - if (regPos.test(val) || regNeg.test(val)) { - return false; - } else { - return true; - } + var regPos = /^[0-9]*$/; //非负浮点数 + var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数 + if (regPos.test(val) || regNeg.test(val)) { + return false; + } else { + return true; + } - }, + }, - formValidate() { + formValidate() { - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } - if (this.data.form.wellcode == "") { - wx.showToast({ - icon: 'none', - title: '井编号不能为空!', - }) - return false - } - if (this.data.form.devicetype == "") { - wx.showToast({ - icon: 'none', - title: '设备类型不能为空!', - }) - return false - } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + if (this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '设备编号不能为空!', + }) + return false + } + if (this.data.form.wellcode == "") { + wx.showToast({ + icon: 'none', + title: '井编号不能为空!', + }) + return false + } + if (this.data.form.devicetype == "") { + wx.showToast({ + icon: 'none', + title: '设备类型不能为空!', + }) + return false + } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null || - this.data.form.installperson == '') { - wx.showToast({ - icon: 'none', - title: '运维人员不能为空!', - }) - return false - } - if (this.data.form.project == "") { - wx.showToast({ - icon: 'none', - title: '所属项目不能为空!', - }) - return false - } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } + if (this.data.form.installperson == null || + this.data.form.installperson == '') { + wx.showToast({ + icon: 'none', + title: '运维人员不能为空!', + }) + return false + } + if (this.data.form.project == "") { + wx.showToast({ + icon: 'none', + title: '所属项目不能为空!', + }) + return false + } - if (this.data.form.welldepth != null) { - if (this.isNumber(this.data.form.welldepth)) { - wx.showToast({ - icon: 'none', - title: '井深必须为数值!', - }) - return false - } - } - if (this.data.form.installheigt != null) { - if (this.isNumber(this.data.form.installheigt)) { - wx.showToast({ - icon: 'none', - title: '到井口距离必须为数值!', - }) - return false - } - } - - return true; - }, - - changeMsg: function () { - var formNew = this.data.form; - var formOld = JSON.parse(this.data.detail); - var descpNew = ""; - if (formNew.devcode != formOld.devcode) { - descpNew += "修改设备编号,原编号:" + formOld.devcode + ",新编号:" + formNew.devcode + ";" - } - if (formNew.devicetype != formOld.devicetype) { - descpNew += "修改设备类型,原设备类型:" + formOld.devicetype + ",新设备类型:" + formNew.devicetype + ";" - } - if (formNew.area != formOld.area) { - descpNew += "修改区,原区:" + formOld.area + ",新区:" + formNew.area + ";" - } - if (formNew.street != formOld.street) { - descpNew += "修改街道,原街道:" + formOld.street + ",新街道:" + formNew.street + ";" - } - if (formNew.wellname != formOld.wellname) { - descpNew += "修改井名称,原井名称:" + formOld.wellname + ",新井名称:" + formNew.wellname + ";" - } - if (formNew.factory != formOld.factory) { - descpNew += "修改权属单位,原权属单位:" + formOld.factory + ",新权属单位:" + formNew.factory + ";" - } - if (formNew.installheigt != formOld.installheigt) { - descpNew += "修改井口距离,原井口距离:" + formOld.installheigt + ",新井口距离:" + formNew.installheigt + ";" - } - if (formNew.installperson != formOld.installperson) { - descpNew += "修改运维人员,原运维人员:" + formOld.installperson + ",新运维人员:" + formNew.installperson + ";" - } - if (formNew.latitude != formOld.latitude) { - descpNew += "修改纬度,原纬度:" + formOld.latitude + ",新纬度:" + formNew.latitude + ";" - } - if (formNew.longitude != formOld.longitude) { - descpNew += "修改经度,原经度:" + formOld.longitude + ",新经度:" + formNew.longitude + ";" - } - if (formNew.position != formOld.position) { - descpNew += "修改位置描述,原位置:" + formOld.position + ",新位置:" + formNew.position + ";" - } - if (formNew.wellcode != formOld.wellcode) { - descpNew += "修改井编号,原编号:" + formOld.wellcode + ",新编号:" + formNew.wellcode + ";" - } - if (formNew.welldepth != formOld.welldepth) { - descpNew += "修改井深,原井深:" + formOld.welldepth + ",新井深:" + formNew.welldepth + ";" - } - if (formNew.welltype != formOld.welltype) { - descpNew += "修改井类型,原井类型:" + formOld.welltype + ",新井类型:" + formNew.welltype + ";" - } - if (formNew.project != formOld.project) { - descpNew += "修改所属项目,原项目:" + formOld.project + ",新项目:" + formNew.project + ";" - } - if (this.data.photopath1 != formOld.photopath1 || - this.data.photopath2 != formOld.photopath2 || - this.data.photopath3 != formOld.photopath3) { - descpNew += "修改照片;" - } - if ("" != formNew.description) { - descpNew += formNew.description; - } - this.setData({ - ['form.description']: descpNew + if (this.data.form.welldepth != null) { + if (this.isNumber(this.data.form.welldepth)) { + wx.showToast({ + icon: 'none', + title: '井深必须为数值!', }) - }, + return false + } + } + if (this.data.form.installheigt != null) { + if (this.isNumber(this.data.form.installheigt)) { + wx.showToast({ + icon: 'none', + title: '到井口距离必须为数值!', + }) + return false + } + } - formSubmit: function (event) { + return true; + }, - if (!this.formValidate()) { - return false; - } - this.changeMsg(); - var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDeviceLog', - data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceLog/add" - }, - }).then(res => { - // var resultObj=JSON.parse(res.result); - if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - if (res.confirm) { - wx.switchTab({ - url: that.data.pageName - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) - } - }).catch(err => { - console.error(err) - wx.showToast({ - title: "提交失败", - }) - }) - }, - confirm(event) { - var that = this; - var formValue = event.detail.value; - var formName = event.target.dataset.id; - var fromN = 'form.' + [formName]; - that.setData({ - [fromN]: formValue - }) - }, + //获取与上次修改的信息 + changeMsg: function () { + var formNew = this.data.form; + console.log(this.data.detail) + var formOld = JSON.parse(this.data.detail); + var descpNew = ""; + if (formNew.devcode != formOld.devcode) { + descpNew += "修改设备编号,原值:" + formOld.devcode + ",新值:" + formNew.devcode + ";" + } + if (formNew.devicetype != formOld.devicetype) { + descpNew += "修改设备类型,原值:" + formOld.devicetype + ",新值:" + formNew.devicetype + ";" + } + if (formNew.area != formOld.area) { + descpNew += "修改区,原值:" + formOld.area + ",新值:" + formNew.area + ";" + } + if (formNew.street != formOld.street) { + descpNew += "修改街道,原值:" + formOld.street + ",新值:" + formNew.street + ";" + } + if (formNew.wellname != formOld.wellname) { + descpNew += "修改井名称,原值:" + formOld.wellname + ",新值:" + formNew.wellname + ";" + } + if (formNew.factory != formOld.factory) { + descpNew += "修改权属单位,原值:" + formOld.factory + ",新值:" + formNew.factory + ";" + } + if (formNew.installheigt != formOld.installheigt) { + descpNew += "修改井口距离,原值:" + formOld.installheigt + ",新值:" + formNew.installheigt + ";" + } + if (formNew.installperson != formOld.installperson) { + descpNew += "修改运维人员,原值:" + formOld.installperson + ",新值:" + formNew.installperson + ";" + } + if (formNew.latitude != formOld.latitude) { + descpNew += "修改纬度,原值:" + formOld.latitude + ",新值:" + formNew.latitude + ";" + } + if (formNew.longitude != formOld.longitude) { + descpNew += "修改经度,原值:" + formOld.longitude + ",新值:" + formNew.longitude + ";" + } + if (formNew.position != formOld.position) { + descpNew += "修改位置描述,原值:" + formOld.position + ",新值:" + formNew.position + ";" + } + if (formNew.wellcode != formOld.wellcode) { + descpNew += "修改井编号,原值:" + formOld.wellcode + ",新值:" + formNew.wellcode + ";" + } + if (formNew.welldepth != formOld.welldepth) { + descpNew += "修改井深,原值:" + formOld.welldepth + ",新值:" + formNew.welldepth + ";" + } + if (formNew.welltype != formOld.welltype) { + descpNew += "修改井类型,原值:" + formOld.welltype + ",新值:" + formNew.welltype + ";" + } + if (formNew.project != formOld.project) { + descpNew += "修改所属项目,原值:" + formOld.project + ",新值:" + formNew.project + ";" + } + if (this.data.form.photopath1 != formOld.photopath1 || + this.data.form.photopath2 != formOld.photopath2 || + this.data.form.photopath3 != formOld.photopath3) { + descpNew += "修改照片;" + } + if ("" != formNew.description) { + descpNew += formNew.description; + } + this.setData({ + ['form.description']: descpNew + }) + }, - scan() { + //提交表单 + formSubmit: function (event) { - wx.scanCode({ - success(res) { - console.log(res) - } - }) + //表单验证 + if (!this.formValidate()) { + return false; + } + //自动生成修改内容 + this.changeMsg(); + //提交权限限制(只有施工人员能修改) + if(app.globalData.role!='repair'){ + wx.showToast({ + icon: 'none', + title: '无权限修改', + duration:2000 + }) + return false + } + var that = this; + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopath = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopath]: fileList[i].url.split("static/")[1] + }) + } + delete that.data.form.installtime + delete that.data.form.createtime + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - paste() { - var _this = this; - wx.getClipboardData({ - success: function (res) { - var longitude = 'form.longitude'; - var latitude = 'form.latitude'; - var longitude84 = 'form.longitude84'; - var latitude84 = 'form.latitude84'; - _this.setData({ - [longitude]: parseFloat(res.data.split(",", 4)[1]).toFixed(6), - [latitude]: parseFloat(res.data.split(",", 4)[0]).toFixed(6), - [longitude84]: "" == (res.data.split(",", 4)[3]) ? "" : parseFloat(res.data.split(",", 4)[3]).toFixed(6), - [latitude84]: "" == (res.data.split(",", 4)[2]) ? "" : parseFloat(res.data.split(",", 4)[2]).toFixed(6), - longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), - latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), - }); - } - }) - }, - selectValue(value) { - var that = this; - var wellType = 'form.welltype'; - that.setData({ - [wellType]: value.detail - }) - }, - selectpersonValue(event) { - var that = this; - var installPerson = 'form.installperson'; - that.setData({ - [installPerson]: event.detail - }) - }, - selectprojectValue(event) { - var that = this; - var project = 'form.project'; - that.setData({ - [project]: event.detail, - showMask: true - }) - }, - open() { - this.setData({ - showMask: true - }) - }, - close() { - this.setData({ - showMask: false - }) - }, - afterRead(event) { - var _this = this; - const { - file - } = event.detail; - const { - fileList = [] - } = _this.data; - var convertpath = ""; - wx.compressImage({ - src: event.detail.file.path, - quality: 25, - success: function (res) { - convertpath = res.tempFilePath; - wx.uploadFile({ - url: app.globalData.httpsUrl + "appDeviceAdd/fileUploadMarker", - filePath:convertpath, - name: 'file', - formData: { - 'text': "编号:" + _this.data.form.devcode + "经度:" + _this.data.form.longitude + "纬度:" + _this.data.form.latitude - }, - header: { - "Content-Type": "multipart/form-data", - 'accept': 'application/json', - }, - success(res) { - if (res.data) { - var url = JSON.parse(res.data); - fileList.push({ - ...file, - url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - }); - _this.setData({ - fileList - }); - } - } + success(res) { + if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + if (res.confirm) { + wx.switchTab({ + url: that.data.pageName }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') } - }) - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // // var base64 = "data:image/png;base64," + wx.getFileSystemManager().readFileSync(convertpath, 'base64'); - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: convertpath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // // wx.cloud.callFunction({ - // // name: 'uploadFile', - // // data: { - // // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // // fileBase64: base64 - // // }, - // // success: function (res) { - // // if (res.result) { - // // fileList.push({ - // // ...file, - // // url: app.globalData.url + "static/" + res.result.data.replace(/\\/g, "/") - // // }); - // // _this.setData({ - // // fileList - // // }); - // // } - // // }, - // // complete: res => { - // // }, - // // }) - // } - // }); + } + }) + } + }, + fail(err) { + wx.showToast({ + title: "提交失败", + }) + } + }) + }, + //报存录入的input信息 + confirm(event) { + var that = this; + var formValue = event.detail.value; + var formName = event.target.dataset.id; + var fromN = 'form.' + [formName]; + that.setData({ + [fromN]: formValue + }) + }, + + //扫码 + scan() { + + wx.scanCode({ + success(res) { + console.log(res) + } + }) + }, + //粘贴经纬度 + paste() { + var _this = this; + wx.getClipboardData({ + success: function (res) { + var longitude = 'form.longitude'; + var latitude = 'form.latitude'; + var longitude84 = 'form.longitude84'; + var latitude84 = 'form.latitude84'; + _this.setData({ + [longitude]: parseFloat(res.data.split(",", 4)[1]).toFixed(6), + [latitude]: parseFloat(res.data.split(",", 4)[0]).toFixed(6), + [longitude84]: "" == (res.data.split(",", 4)[3]) ? "" : parseFloat(res.data.split(",", 4)[3]).toFixed(6), + [latitude84]: "" == (res.data.split(",", 4)[2]) ? "" : parseFloat(res.data.split(",", 4)[2]).toFixed(6), + longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), + latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), + }); + } + }) + }, + selectValue(value) { + var that = this; + var wellType = 'form.welltype'; + that.setData({ + [wellType]: value.detail + }) + }, + //运维人员默认为登录人 + // selectpersonValue(event) { + // var that = this; + // var installPerson = 'form.installperson'; + // that.setData({ + // [installPerson]: event.detail + // }) + // }, + selectprojectValue(event) { + var that = this; + var project = 'form.project'; + that.setData({ + [project]: event.detail, + showMask: true + }) + }, + + open() { + this.setData({ + showMask: true + }) + }, + //隐藏textarea,防止遮挡 + close() { + this.setData({ + showMask: false + }) + }, + //上传照片 + afterRead(event) { + var _this = this; + const { + file + } = event.detail; + const { + fileList = [] + } = _this.data; + var convertpath = ""; + wx.compressImage({ + src: event.detail.file.path, + quality: 25, + success: function (res) { + convertpath = res.tempFilePath; + wx.uploadFile({ + url: app.globalData.httpsUrl + "appDeviceAdd/fileUploadMarker", + filePath: convertpath, + name: 'file', + formData: { + 'text': "编号:" + _this.data.form.devcode + "经度:" + _this.data.form.longitude + "纬度:" + _this.data.form.latitude }, - deletePhoto(event) { - var that = this - var image_index = event.detail.index - var fileList_new = that.data.fileList; - wx.showModal({ - content: '确定删除照片?', - success: function (res) { - if (res.confirm) { - fileList_new.splice(image_index, 1); - that.setData({ - fileList: fileList_new - }) - wx.cloud.callFunction({ - name: 'deletePhoto', - data: { - url: app.globalData.url + "appDeviceLog/deletePhoto", - devcode: that.data.form.devcode, - pathIndex: image_index - }, - success: function (res) {}, - complete: res => {}, - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + "Content-Type": "multipart/form-data", + 'accept': 'application/json', }, - }) \ No newline at end of file + success(res) { + if (res.data) { + var url = JSON.parse(res.data); + fileList.push({ + ...file, + url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") + }); + _this.setData({ + fileList + }); + } + } + }) + } + }) + }, + //删除照片 + deletePhoto(event) { + var that = this + var image_index = event.detail.index + var fileList_new = that.data.fileList; + wx.showModal({ + content: '确定删除照片?', + success: function (res) { + if (res.confirm) { + fileList_new.splice(image_index, 1); + that.setData({ + fileList: fileList_new + }) + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deletePhoto", + data: { + devcode: that.data.form.devcode + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) {} + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } +}) \ No newline at end of file diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.wxml b/miniprogram/pages/addDevicelog/addDeviceLog.wxml index 38620d4..b10cc7d 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.wxml +++ b/miniprogram/pages/addDevicelog/addDeviceLog.wxml @@ -1,15 +1,21 @@ - + + + + + - + - - + + - - + + - + @@ -39,24 +45,25 @@ - - - + + + - + - + + @@ -64,7 +71,7 @@ - + @@ -79,9 +86,9 @@ - + - 保存 + 保存 diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.wxss b/miniprogram/pages/addDevicelog/addDeviceLog.wxss index ee0b75c..08d5fd7 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.wxss +++ b/miniprogram/pages/addDevicelog/addDeviceLog.wxss @@ -24,6 +24,17 @@ display: flex; align-items: center; } +.map-view{ + width: 750rpx; + height: 485rpx; + position: fixed; + top: 0px; + left: 0px; + z-index: 999; +} +.content{ + margin-top: 495rpx; +} .left { width: 210rpx; diff --git a/miniprogram/pages/addFunction/addFunction.js b/miniprogram/pages/addFunction/addFunction.js deleted file mode 100644 index 4966be3..0000000 --- a/miniprogram/pages/addFunction/addFunction.js +++ /dev/null @@ -1,60 +0,0 @@ -// pages/addFunction/addFunction.js - -const code = `// 云函数入口函数 -exports.main = (event, context) => { - console.log(event) - console.log(context) - return { - sum: event.a + event.b - } -}` - -Page({ - - data: { - result: '', - canIUseClipboard: wx.canIUse('setClipboardData'), - }, - - onLoad: function (options) { - - }, - - copyCode: function() { - wx.setClipboardData({ - data: code, - success: function () { - wx.showToast({ - title: '复制成功', - }) - } - }) - }, - - testFunction() { - wx.cloud.callFunction({ - name: 'sum', - data: { - a: 1, - b: 2 - }, - success: res => { - wx.showToast({ - title: '调用成功', - }) - this.setData({ - result: JSON.stringify(res.result) - }) - }, - fail: err => { - wx.showToast({ - icon: 'none', - title: '调用失败', - }) - console.error('[云函数] [sum] 调用失败:', err) - } - }) - }, - -}) - diff --git a/miniprogram/pages/addFunction/addFunction.json b/miniprogram/pages/addFunction/addFunction.json deleted file mode 100644 index a9a50c5..0000000 --- a/miniprogram/pages/addFunction/addFunction.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "navigationBarTitleText": "云函数指引", - "usingComponents": {} -} \ No newline at end of file diff --git a/miniprogram/pages/addFunction/addFunction.wxml b/miniprogram/pages/addFunction/addFunction.wxml deleted file mode 100644 index 3a10626..0000000 --- a/miniprogram/pages/addFunction/addFunction.wxml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - 测试云函数 - - - 期望输出:{"sum":3} - - - 调用结果:{{result}} - - - - - 新增云函数 - 1. 在云函数根目录 cloudfunctions 上右键选择新建云函数,命名为 sum - 2. 在创建的 cloudfunctions/sum/index.js 文件中添加如下代码 - - - 3. 在 cloudfunctions/sum 目录上右键上传并部署 - 4. 点击测试云函数测试 - 5. 打开云开发云函数管理页,选择 sum 云函数 - 6. 查看 sum 的调用日志 - 进阶:可在云函数中使用 wx-server-sdk 操作数据库,文件存储和调用其他云函数,详见文档 - - - diff --git a/miniprogram/pages/addFunction/addFunction.wxss b/miniprogram/pages/addFunction/addFunction.wxss deleted file mode 100644 index 7ac8619..0000000 --- a/miniprogram/pages/addFunction/addFunction.wxss +++ /dev/null @@ -1,3 +0,0 @@ -/* pages/addFunction/addFunction.wxss */ - -@import "../../style/guide.wxss"; \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.js b/miniprogram/pages/applog/applog.js index 0e8c185..189e61f 100644 --- a/miniprogram/pages/applog/applog.js +++ b/miniprogram/pages/applog/applog.js @@ -13,98 +13,25 @@ isSeach: "false", params: {}, total: 0, - show: false + show: false, + delBtnWidth: 100, //删除按钮宽度单位(rpx) + activeIndex: -1, + list_style: '' }, - - touchE: function (e) { - // console.log(e); - var that = this - if (e.changedTouches.length == 1) { - //手指移动结束后触摸点位置的X坐标 - var endX = e.changedTouches[0].clientX; - //触摸开始与结束,手指移动的距离 - var disX = that.data.startX - endX; - var delBtnWidth = that.data.delBtnWidth; - //如果距离小于删除按钮的1/2,不显示删除按钮 - var txtStyle = disX > delBtnWidth / 2 ? "left:-" + delBtnWidth + "rpx" : "left:0rpx"; - - //获取手指触摸的是哪一项 - var index = e.currentTarget.dataset.index; - var list = that.data.deviceloglist; - list[index].txtStyle = txtStyle; - //更新列表的状态 - that.setData({ - deviceloglist: list - }); - } - }, - //手指触摸动作开始 记录起点X坐标 - touchstart: function (e) { - //开始触摸时 重置所有删除 - this.data.deviceloglist.forEach(function (v, i) { - if (v.isTouchMove) //只操作为true的 - v.isTouchMove = false; - }) - this.setData({ - startX: e.changedTouches[0].clientX, - startY: e.changedTouches[0].clientY, - deviceloglist: this.data.deviceloglist - }) - }, - //滑动事件处理 - touchmove: function (e) { - var that = this, - index = e.currentTarget.dataset.index, //当前索引 - startX = that.data.startX, //开始X坐标 - startY = that.data.startY, //开始Y坐标 - touchMoveX = e.changedTouches[0].clientX, //滑动变化坐标 - touchMoveY = e.changedTouches[0].clientY, //滑动变化坐标 - //获取滑动角度 - angle = that.angle({ - X: startX, - Y: startY - }, { - X: touchMoveX, - Y: touchMoveY - }); - that.data.deviceloglist.forEach(function (v, i) { - v.isTouchMove = false - //滑动超过30度角 return - if (Math.abs(angle) > 30) return; - if (i == index) { - if (touchMoveX > startX) //右滑 - v.isTouchMove = false - else //左滑 - v.isTouchMove = true - } - }) - //更新数据 - that.setData({ - deviceloglist: that.data.deviceloglist - }) - }, - /** - * 计算滑动角度 - * @param {Object} start 起点坐标 - * @param {Object} end 终点坐标 - */ - angle: function (start, end) { - var _X = end.X - start.X, - _Y = end.Y - start.Y - //返回角度 /Math.atan()返回数字的反正切值 - return 360 * Math.atan(_Y / _X) / (2 * Math.PI); - }, - /** - * 生命周期函数--监听页面加载var_this=this; - */ onLoad: function (options) { - if (options.params) { this.setData({ params: JSON.parse(options.params), isSeach: "true" }) this.initPages() + }else{ + this.setData({ + show: false + }) + //清空参数,重新加载 + this.clearParams(); + this.initPages(); } }, @@ -116,20 +43,33 @@ }, + //点击tabBar事件 + onTabItemTap(item) { + //隐藏历史显示总记录条数 + this.setData({ + show: false + }) + //清空参数,重新加载 + this.clearParams(); + this.initPages(); + }, + + /** * 生命周期函数--监听页面显示 */ onShow: function (options) { - this.setData({ - show:false - }) - if (this.data.isSeach == "false") { - this.clearParams(); - this.initPages(); - } - this.setData({ - isSeach: "false" - }) + + // this.setData({ + // show: false + // }) + // if (this.data.isSeach == "false") { + // this.clearParams(); + // this.initPages(); + // } + // this.setData({ + // isSeach: "false" + // }) }, /** @@ -167,6 +107,119 @@ }, + + //手指触摸动作开始 记录起点X坐标 + touchstart: function (e) { + //开始触摸时 重置所有删除 + this.data.deviceloglist.forEach(function (v, i) { + if (v.isTouchMove) //只操作为true的 + v.isTouchMove = false; + }) + this.setData({ + startX: e.changedTouches[0].clientX, + startY: e.changedTouches[0].clientY, + deviceloglist: this.data.deviceloglist + }) + }, + + //滑动事件处理 + touchmove: function (e) { + var that = this, + index = e.currentTarget.dataset.index, //当前索引 + startX = that.data.startX, //开始X坐标 + startY = that.data.startY, //开始Y坐标 + touchMoveX = e.changedTouches[0].clientX, //滑动变化坐标 + touchMoveY = e.changedTouches[0].clientY, //滑动变化坐标 + //获取滑动角度 + angle = that.angle({ + X: startX, + Y: startY + }, { + X: touchMoveX, + Y: touchMoveY + }); + that.data.deviceloglist.forEach(function (v, i) { + // v.isTouchMove = false + //滑动超过30度角 return + if (Math.abs(angle) > 30) return; + if (i == index) { + if (touchMoveX > startX) //右滑 + v.isTouchMove = false + else //左滑 + v.isTouchMove = true + } + }) + //更新数据 + that.setData({ + deviceloglist: that.data.deviceloglist + }) + }, + + /** + * 计算滑动角度 + * @param {Object} start 起点坐标 + * @param {Object} end 终点坐标 + */ + angle: function (start, end) { + var _X = end.X - start.X, + _Y = end.Y - start.Y + //返回角度 /Math.atan()返回数字的反正切值 + return 360 * Math.atan(_Y / _X) / (2 * Math.PI); + }, + + //删除事件 + delItem: function (e) { + if(app.globalData.role!='repair'){ + wx.showToast({ + icon: 'none', + title: '无权限删除', + duration:2000 + }) + return false + } + var that = this + wx.showModal({ + content: '是否删除?', + success: function (res) { + if (res.confirm) { + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/delete", + data: { + appDeviceAddId: e.currentTarget.dataset.devid + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if(res.data.code=='200'){ + that.data.deviceloglist.splice(e.currentTarget.dataset.index, 1) + that.setData({ + deviceloglist: that.data.deviceloglist, + total: that.data.deviceloglist.length + }) + wx.showToast({ + title: '删除成功!', + icon: 'none', + duration: 1000 + }) + } + }, + fail(err) { + wx.showToast({ + title: '删除失败!', + icon: 'none', + duration: 2000 + }) + } + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + }, + showLoading: function (message) { if (wx.showLoading) { // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 @@ -199,95 +252,105 @@ deviceloglist: [] }) }, + //查询列表数据 initPages: function () { var that = this + that.setData({ + show: false + }) var offsetValue = that.data.deviceloglist.length % 15 > 0 ? parseInt(that.data.deviceloglist.length / 15) + 2 : parseInt(that.data.deviceloglist.length / 15) + 1 - wx.cloud.callFunction({ - name: 'devicelog', + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/listPage", data: { devcode: that.data.params.devcode, devtype: that.data.params.devtype, installtimeFmt: that.data.params.installtimeFmt, project: that.data.params.project, installPerson: that.data.params.installPerson, - url: app.globalData.url + "appDeviceLog/listPage", limit: 15, offset: offsetValue }, - }).then(res => { - if (res.result.data.rows.length > 0) { - var resultJson = res.result - that.setData({ - deviceloglist: that.data.deviceloglist.concat(resultJson.data.rows) - }) - } else if (that.data.deviceloglist.length > 0) { - that.setData({ - show: true, - total: that.data.deviceloglist.length - }) - wx.showToast({ - title: '数据已全部加载完', - icon: 'none', - duration: 2000 - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.data.rows.length > 0) { + var resultJson = res.data + var listArr = resultJson.data.rows + listArr.forEach(function (v, i) { + listArr[i]['isTouchMove'] = false + }) + that.setData({ + deviceloglist: that.data.deviceloglist.concat(listArr) + }) + } else if (that.data.deviceloglist.length > 0) { + that.setData({ + show: true, + total: that.data.deviceloglist.length + }) + wx.showToast({ + title: '数据已全部加载完', + icon: 'none', + duration: 2000 + }) + } + if (offsetValue == 1 && res.data.data.rows.length < 15) { + that.setData({ + show: true, + total: that.data.deviceloglist.length + }) + } } - if(offsetValue==1&&res.result.data.rows.length<15){ - that.setData({ - show: true, - total: that.data.deviceloglist.length - }) - } - // console.log(res); - }).catch(err => { - console.error(err); }) + }, addDetail: function (event) { - this.showLoading("数据请求中..."); - wx.cloud.callFunction({ - name: 'deviceDetail', + var that = this + that.showLoading("数据请求中..."); + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deviceDetail", data: { devcode: event.target.dataset.devcode, - url: app.globalData.url + "appDeviceLog/deviceDetail", }, - }).then(res => { - this.hideLoading(); - var resultObject = JSON.parse(res.result); - var pageName = '../applog/applog' - if (resultObject.code == 200) { - wx.navigateTo({ - url: '../addDevicelog/addDeviceLog?detail=' + - JSON.stringify(resultObject.data) + "&pageName=" + pageName - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + that.hideLoading(); + // var resultObject = JSON.parse(res.data); + var resultObject = res.data; + var pageName = '../applog/applog' + if (resultObject.code == 200) { + wx.setStorageSync('resultObject', resultObject.data) + wx.navigateTo({ + url: '../addDevicelog/addDeviceLog?detail=' + "&pageName=" + pageName + }) + } + }, + fail(err) { + that.hideLoading(); } - }).catch(err => { - this.hideLoading() }) + }, add: function (event) { - wx.reLaunch({ - url: '../earth/earth?devcode=' + event.target.dataset.devcode - // url: '../earth/earth' + app.globalData.devcode = event.target.dataset.devcode; + wx.switchTab({ + url: '../earth/earth' }) + // wx.reLaunch({ + // url: '../earth/earth?devcode=' + event.target.dataset.devcode + // // url: '../earth/earth' + // }) }, onSearch: function () { + var _this = this wx.navigateTo({ - url: '../searchLog/searchLog' + url: '../searchLog/searchLog?params=' + JSON.stringify(_this.data.params) }) - }, - // initPages: function () { - // wx.cloud.callFunction({ - // name: 'devicelog' - // }).then(res => { - // var that = this; - // var jsonList = JSON.parse(res.result) - // that.setData({ - // deviceloglist: jsonList.data.rows - // }) - // console.log(res); - // }).catch(err => { - // console.error(err); - // }) - // } + } }) \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.wxml b/miniprogram/pages/applog/applog.wxml index e9a2352..2bfd041 100644 --- a/miniprogram/pages/applog/applog.wxml +++ b/miniprogram/pages/applog/applog.wxml @@ -1,54 +1,59 @@ - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {{item.devcode}} {{item.devicetype}} + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + {{item.devcode}} {{item.devicetype}} + + {{item.project}} {{item.installtime}}- {{item.installperson}} - - - - - + + + + + + 删除 - - - + + - 共计:{{total}}台 - + 共计:{{total}}台 + \ No newline at end of file diff --git a/cloudfunctions/project.config.json b/cloudfunctions/project.config.json new file mode 100644 index 0000000..2b3119a --- /dev/null +++ b/cloudfunctions/project.config.json @@ -0,0 +1,28 @@ +{ + "appid": "wx2cef527a000f87c9", + "compileType": "miniprogram", + "libVersion": "2.27.3", + "packOptions": { + "ignore": [], + "include": [] + }, + "setting": { + "coverView": true, + "es6": true, + "postcss": true, + "minified": true, + "enhance": true, + "showShadowRootInWxmlPanel": true, + "packNpmRelationList": [], + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + } + }, + "condition": {}, + "editorSetting": { + "tabIndent": "insertSpaces", + "tabSize": 4 + } +} \ No newline at end of file diff --git a/cloudfunctions/project.private.config.json b/cloudfunctions/project.private.config.json new file mode 100644 index 0000000..42ff49d --- /dev/null +++ b/cloudfunctions/project.private.config.json @@ -0,0 +1,7 @@ +{ + "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", + "projectname": "cloudfunctions", + "setting": { + "compileHotReLoad": true + } +} \ No newline at end of file diff --git a/miniprogram/app.js b/miniprogram/app.js index 51d56f3..50a8a54 100644 --- a/miniprogram/app.js +++ b/miniprogram/app.js @@ -18,13 +18,15 @@ // this.globalData = {} }, globalData: { - // url: "http://111.198.10.15:11604/", - httpsUrl: "https://logapi.smartlog.work/", - httpsTestUrl: "https://smartlog.work/prodapi4test/", - url: "http://139.198.18.188:8083/", + httpsUrl: "https://logapi.smartlog.work/", + // httpsUrl: "http://139.198.18.188:8083/", // url: "http://127.0.0.1:8083/", - // httpsUrl: "http://127.0.0.1:8083/", + //httpsUrl: "http://127.0.0.1:8083/", openid: null, - indexCount:1 - }, + indexCount:1, + nickName:"", + userName:"", + role:"", + devcode:"" + } }) diff --git a/miniprogram/app.json b/miniprogram/app.json index d23f798..2b6db76 100644 --- a/miniprogram/app.json +++ b/miniprogram/app.json @@ -1,15 +1,17 @@ { "cloud": true, "pages": [ + "pages/login/login", "pages/indexapp/indexapp", "pages/earth/earth", "pages/applog/applog", "pages/addDevice/addDevice", "pages/addDevicelog/addDeviceLog", - "pages/searchLog/searchLog" + "pages/searchLog/searchLog", + "pages/notice/notice" ], "window": { - "backgroundColor": "#F6F6F6", + "backgroundColor": "#E6D480", "backgroundTextStyle": "light", "navigationBarBackgroundColor": "#FFCF00", "navigationBarTitleText": "智慧施工", @@ -46,11 +48,11 @@ "desc": "你的位置信息将用于小程序位置接口的效果展示" } }, + "requiredPrivateInfos": ["getLocation", "chooseLocation"], "networkTimeout": { "request": 30000, "connectSocket": 30000, "uploadFile": 30000, "downloadFile": 30000 - }, - "style": "v2" + } } \ No newline at end of file diff --git a/miniprogram/images/applocat.png b/miniprogram/images/applocat.png new file mode 100644 index 0000000..fe49f54 --- /dev/null +++ b/miniprogram/images/applocat.png Binary files differ diff --git a/miniprogram/images/back.png b/miniprogram/images/back.png new file mode 100644 index 0000000..32ac82d --- /dev/null +++ b/miniprogram/images/back.png Binary files differ diff --git a/miniprogram/images/bottom.png b/miniprogram/images/bottom.png new file mode 100644 index 0000000..d910e98 --- /dev/null +++ b/miniprogram/images/bottom.png Binary files differ diff --git a/miniprogram/images/header.png b/miniprogram/images/header.png new file mode 100644 index 0000000..6ea222e --- /dev/null +++ b/miniprogram/images/header.png Binary files differ diff --git a/miniprogram/images/login.png b/miniprogram/images/login.png index 8b73cc0..6471c46 100644 --- a/miniprogram/images/login.png +++ b/miniprogram/images/login.png Binary files differ diff --git a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss index 5a591fb..c9c35b5 100644 --- a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss +++ b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:100%;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:100%}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file +@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:650rpx;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:600rpx}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file diff --git a/miniprogram/pages/addDevice/addDevice.js b/miniprogram/pages/addDevice/addDevice.js index 2783674..78f00b7 100644 --- a/miniprogram/pages/addDevice/addDevice.js +++ b/miniprogram/pages/addDevice/addDevice.js @@ -1,5 +1,7 @@ // miniprogram/pages/addDevice/addDevice.js // import WxValidate from '../../utils/WxValidate.js' +var QQMapWX = require('../../libs/qqmap-wx-jssdk.js'); +var qqmapsdk; var app = getApp() Page({ @@ -11,32 +13,10 @@ canvasWidth: '', longitude: '', latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], + option1: [], personoption1: [], projectoption: [], + devtypeList:[], show: false, form: { devcode: "", @@ -59,7 +39,10 @@ project: "", area: "", street: "", - wellname: "" + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '', }, fileList: [] }, @@ -117,12 +100,14 @@ var that = this; //初始化表单内容为上次填写值 var cacheForms = wx.getStorageSync('cacheList') - if (cacheForms) { + cacheForms.photopath1='' + cacheForms.photopath2='' + cacheForms.photopath3='' + that.data.fileList=[] that.setData({ form: cacheForms, devcode: cacheForms.devcode, - }) } var form = that.data.form @@ -155,55 +140,89 @@ } }) + +//获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + that.setData({ + option1: welltypeArr + }) + } + } +}) + + //获取人员下拉列表 - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/getUser", + data:{ + tips:'repair' }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data.code == 200) { + var users = res.data.data + var personArr = []; + for (var i = 0; i < users.length; i++) { + var person = { + text: users[i].name, + value: users[i].name + }; + personArr.push(person); + } + that.setData({ + personoption1: personArr + }) } - that.setData({ - personoption1: personArr - }) } - }).catch(err => { - console.error(err); - }) + }) + - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - that.setData({ - projectoption: projectArr - }) + success(res){ + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); + } + that.setData({ + projectoption: projectArr + }) + } } - }).catch(err => { - console.error(err); - }) + }) + var installtime = 'form.installtimeFmt'; var dateNow = this.formatDate(); this.setData({ @@ -211,8 +230,40 @@ installtimeFmt: dateNow, [installtime]: dateNow, }); + + + + /** + * 获取设备类型下拉列表 + */ + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/deviceType", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var TypeList = res.data.data + var typeArr = []; + for (var i = 0; i < TypeList.length; i++) { + var type = { + text: TypeList[i].productName, + value: TypeList[i].productName + }; + typeArr.push(type); + } + that.setData({ + devtypeList: typeArr + }) + } + } + }) }, + + + /** * 生命周期函数--监听页面初次渲染完成 */ @@ -280,29 +331,7 @@ }, - - //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 - drawText: function (ctx, str, leftWidth, initHeight, titleHeight, canvasWidth) { - var lineWidth = 0; - var lastSubStrIndex = 0; //每次开始截取的字符串的索引 - for (let i = 0; i < str.length; i++) { - lineWidth += ctx.measureText(str[i]).width; - if (lineWidth > canvasWidth) { - ctx.fillText(str.substring(lastSubStrIndex, i), leftWidth, initHeight); //绘制截取部分 - initHeight = initHeight + leftWidth * 2; //22为字体的高度 - lineWidth = 0; - lastSubStrIndex = i; - // titleHeight += 40; - } - if (i == str.length - 1) { //绘制剩余部分 - ctx.fillText(str.substring(lastSubStrIndex, i + 1), leftWidth, initHeight); - } - } - // // 标题border-bottom 线距顶部距离 - // titleHeight = titleHeight + 10; - // return titleHeight - }, - + //验证表单 formValidate() { if (this.data.form.devcode == "") { @@ -312,27 +341,20 @@ }) return false } - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } if (this.data.form.wellcode == "") { wx.showToast({ icon: 'none', @@ -348,22 +370,10 @@ }) return false } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null) { + + if (this.data.form.installperson == "") { wx.showToast({ icon: 'none', title: '安装人员不能为空!', @@ -408,56 +418,90 @@ } return true; }, + //提交表单 formSubmit: function (event) { + console.log(this.data.form) + //表单参数验证 if (!this.formValidate()) { return false; } var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDevice', + //验证设备编号长度 + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/getDevTypeLength", data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceAdd/add" + code: encodeURI(this.data.form.devicetype) }, - }).then(res => { - if (res.result.code == 500) { - wx.showToast({ - title: '设备编号已安装!', - }) - } else if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - //用于回显 - wx.setStorageSync('cacheList', that.data.form) - //提交成功后提示用户操作 - if (res.confirm) { - wx.switchTab({ - url: '../earth/earth' - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (""==res.data.data ||res.data.data == that.data.form.devcode.length) { + that.saveDevice() + } else { //编号位数不对提示 + wx.showToast({ + icon: 'none', + title: '设备编号位数不对!', + duration: 1000 + }) + return false + } } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "提交失败", - }) }) }, + + //保存设备基本信息 + saveDevice() { + var that = this; + //设置照片路径 + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopathForm = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopathForm]: fileList[i].url.split("static/")[1] + }) + } + //表单提交 + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 500) { + wx.showToast({ + title: '设备编号已安装!', + }) + } else if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + //用于回显 + wx.setStorageSync('cacheList', that.data.form) + //提交成功后提示用户操作 + if (res.confirm) { + wx.switchTab({ + url: '../earth/earth' + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } + }, + fail(err) { + wx.showToast({ + title: '提交失败!', + }) + } + }) + }, + + //input 输入框设置值 confirm(event) { var that = this; var formValue = event.detail.value; @@ -466,8 +510,30 @@ that.setData({ [fromN]: formValue }) + //若输入是设备编号,自动获取设备类型 + if('devcode'==formName){ + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", + data: { + devcode: formValue, + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + that.setData({ + [formDevicetype]: res.data + }); + } + } + }) + } }, + //扫描设备获取编号和设备类型 scan() { var _this = this; wx.scanCode({ @@ -477,23 +543,28 @@ _this.setData({ [formdevcode]: devcode }); - wx.cloud.callFunction({ - name: 'findModeCode', + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", data: { devcode: devcode, - url: app.globalData.url + "appDeviceAdd/findModeCodeByCode" }, - }).then(res => { - if (res.result) { - var formDevicetype = 'form.devicetype' - _this.setData({ - [formDevicetype]: res.result - }); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + _this.setData({ + [formDevicetype]: res.data + }); + } } }) } }) }, + //粘贴经纬度 paste() { var _this = this; wx.getClipboardData({ @@ -510,9 +581,11 @@ longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), }); + _this.showAddress(_this.data.form.longitude,_this.data.form.latitude,_this) } }) }, + //设置经类型 selectValue(value) { var that = this; @@ -521,6 +594,16 @@ [wellType]: value.detail }) }, + + //设置设备类型 + selectDevType(event) { + var that = this; + var devtype = 'form.devicetype'; + that.setData({ + [devtype]: event.detail + }) + }, + //设置运维人员 selectpersonValue(event) { var that = this; var installPerson = 'form.installperson'; @@ -528,6 +611,7 @@ [installPerson]: event.detail }) }, + //设置项目 selectprojectValue(event) { var that = this; var project = 'form.project'; @@ -535,8 +619,41 @@ [project]: event.detail }) }, + showAddress :function(longitude, latitude, self) { + // 实例化腾讯地图API核心类 + qqmapsdk = new QQMapWX({ + key: 'BGPBZ-C5O3P-ROUDR-LWC4J-63EKH-V5FRX'//此处使用你自己申请的key + }) + // 腾讯地图调用接口 + qqmapsdk.reverseGeocoder({ + location: { + latitude: latitude, + longitude: longitude + }, + success: function (res) { + self.setData({ + 'form.area':res.result.address.slice(0,res.result.address.indexOf('区')+1), + 'form.street':res.result.address.slice(res.result.address.indexOf('区')+1) + }) + }, + fail: function (res) { + console.log(res); + }, + complete: function (res) { + } + }); + }, + //上传照片 afterRead(event) { var _this = this; + if (_this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '请先填写设备编号!\r\n否则水印中无编号', + duration: 2000 + }) + return false + } const { file } = event.detail; @@ -576,78 +693,8 @@ }) } }) - // 压缩图片 - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // //获取图片尺寸 - // wx.getImageInfo({ - // src: convertpath, - // success(res) { - // _this.setData({ - // canvasHeight: res.height, - // canvasWidth: res.width - // }) - // var ctx = wx.createCanvasContext('firstCanvas') - - // //将图片src放到cancas内,宽高为图片大小 - // ctx.drawImage(convertpath, 0, 0, res.width, res.height) - // //将声明的时间放入canvas - // ctx.setFontSize(30 * (res.width / 750)) //注意:设置文字大小必须放在填充文字之前,否则不生效 - // ctx.setFillStyle('blue') - // var text = "编号:" + _this.data.form.devcode + "\n经度:" + _this.data.form.longitude + "\n纬度:" + _this.data.form.latitude - // // _this.drawText(ctx,text,20, 70, 5, res.width) - // _this.drawText(ctx, text, 15 * (res.width / 750), 70 * (res.width / 750), 5, res.width) - - // // ctx.fillText(text, 0, 40) - // // ctx.strokeText(_this.data.form.devcode, 0, 30) - // //生成水印图 - // ctx.draw(false, function () { - // wx.canvasToTempFilePath({ - // canvasId: 'firstCanvas', - // success: (res) => { - // wx.compressImage({ - // src: res.tempFilePath, - // quality: 25, - // success: function (res) { - // //上传照片至服务器 - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: res.tempFilePath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // } - // }) - // //// - // } - // }) - // }) - // } - // }) - // } - // }); }, + //删除照片 deletePhoto(event) { var image_index = event.detail.index var fileList_new = this.data.fileList; diff --git a/miniprogram/pages/addDevice/addDevice.wxml b/miniprogram/pages/addDevice/addDevice.wxml index b0977e2..f12c254 100644 --- a/miniprogram/pages/addDevice/addDevice.wxml +++ b/miniprogram/pages/addDevice/addDevice.wxml @@ -5,18 +5,30 @@ - + + + + + + + + + + + + + - - + + - - - + + + @@ -29,13 +41,13 @@ - + - + - + - + @@ -54,8 +66,7 @@ - - + @@ -68,8 +79,8 @@ - - + + - 保存 + 保存 \ No newline at end of file diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.js b/miniprogram/pages/addDevicelog/addDeviceLog.js index cdec71b..a0dc6da 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.js +++ b/miniprogram/pages/addDevicelog/addDeviceLog.js @@ -3,681 +3,665 @@ var app = getApp(); Page({ - /** - * 页面的初始数据 - */ - data: { - pageName: '', - showMask: false, - today: new Date().getTime(), - longitude: '', - latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], - personoption1: [], - projectoption: [], - devcode: "", - deviceMode: "", - installtimeFmt: '', - show: false, - form: { - devcode: "", - wellcode: "", - welltype: "", - welldepth: "", - installheigt: "", - installperson: "", - installtimeFmt: "", - photopath: "", - factory: "", - workmsg: "", - position: "", - description: "", - longitude: "", - latitude: "", - longitude84: "", - latitude84: "", - devicetype: "", - project: "", - area: "", - street: "", - wellname: "" - }, - fileList: [], - detail: "" - }, + /** + * 页面的初始数据 + */ + data: { + pageName: '', + showMask: false, + today: new Date().getTime(), + longitude: '', + latitude: '', + option1: [], + personoption1: [], + projectoption: [], + devcode: "", + deviceMode: "", + installtimeFmt: '', + show: false, + form: { + devcode: "", + wellcode: "", + welltype: "", + welldepth: "", + installheigt: "", + installperson: "", + installtimeFmt: "", + photopath: "", + factory: "", + workmsg: "", + position: "", + description: "", + longitude: "", + latitude: "", + longitude84: "", + latitude84: "", + devicetype: "", + project: "", + area: "", + street: "", + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '' + }, + fileList: [], + detail: "", + markers: [{ + id: 100, + // iconPath: "../../images/point.png", + latitude: '', + longitude: '', + // label:'1', + width: 25, + height: 35 + }], + }, - onDisplay() { - this.setData({ - show: true - }); - }, - onClose() { - this.setData({ - show: false - }); - }, - formatDate() { - var date = new Date(); - // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; - var seperator1 = "-"; - var month = date.getMonth() + 1; - var strDate = date.getDate(); - var hour = date.getHours() - var minute = date.getMinutes() - var second = date.getSeconds() - month = month > 9 ? month : "0" + month; - strDate = strDate > 9 ? strDate : "0" + strDate; - hour = hour > 9 ? hour : "0" + hour; - minute = minute > 9 ? minute : "0" + minute; - second = second > 9 ? second : "0" + second; - var currentdate = - date.getFullYear() + - seperator1 + - month + - seperator1 + - strDate + - " " + - hour + ":" + - minute + ":" + - second; - return currentdate; + onDisplay() { + this.setData({ + show: true + }); + }, + onClose() { + this.setData({ + show: false + }); + }, + formatDate() { + var date = new Date(); + // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; + var seperator1 = "-"; + var month = date.getMonth() + 1; + var strDate = date.getDate(); + var hour = date.getHours() + var minute = date.getMinutes() + var second = date.getSeconds() + month = month > 9 ? month : "0" + month; + strDate = strDate > 9 ? strDate : "0" + strDate; + hour = hour > 9 ? hour : "0" + hour; + minute = minute > 9 ? minute : "0" + minute; + second = second > 9 ? second : "0" + second; + var currentdate = + date.getFullYear() + + seperator1 + + month + + seperator1 + + strDate + + " " + + hour + ":" + + minute + ":" + + second; + return currentdate; - }, - onConfirm(event) { - var installtime = 'form.installtimeFmt'; - this.setData({ - show: false, - installtimeFmt: this.formatDate(event.detail), - [installtime]: this.formatDate(event.detail), - }); - }, + }, + onConfirm(event) { + var installtime = 'form.installtimeFmt'; + this.setData({ + show: false, + installtimeFmt: this.formatDate(event.detail), + [installtime]: this.formatDate(event.detail), + }); + }, - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - var _this = this; - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" - }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); - } - _this.setData({ - personoption1: personArr - }) + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + var _this = this; + _this.setData({ + 'markers[0].latitude': Number(wx.getStorageSync('resultObject').latitude) , + 'markers[0].longitude': Number(wx.getStorageSync('resultObject').longitude), + // 'markers[0].label':'10', + 'markers[0].width': 18, + 'markers[0].id':1, + 'markers[0].height': 30, + latitude:Number(wx.getStorageSync('resultObject').latitude), + longitude:Number(wx.getStorageSync('resultObject').longitude) + }) + //获取人员下拉列表 + // wx.request({ + // method: "POST", + // url: app.globalData.httpsUrl + "deviceType/getUser", + // data:{ + // tips:'repair' + // }, + // header: { + // 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + // }, + // success(res) { + // if (res.data.code == 200) { + // var users = res.data.data + // var personArr = []; + // for (var i = 0; i < users.length; i++) { + // var person = { + // text: users[i].name, + // value: users[i].name + // }; + // personArr.push(person); + // } + // _this.setData({ + // personoption1: personArr + // }) + // } + // } + // }) + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); } - }).catch(err => { - console.error(err); - }) - - - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" - }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - _this.setData({ - projectoption: projectArr - }) - } - }).catch(err => { - console.error(err); - }) - - if (options.pageName) { - this.setData({ - pageName: options.pageName - }) - } - - if (options.detail) { - - var formObject = JSON.parse(options.detail); _this.setData({ - form: formObject, - detail: options.detail + projectoption: projectArr }) - - _this.setData({ - ['form.installperson']: "", - ['form.installtimeFmt']: "", - ['form.workmsg']: "", - ['form.description']: "" - }) - - const { - fileList = [] - } = _this.data; - if (formObject.photopath1 != "") { - var file1 = { - url: app.globalData.url + "static/" + formObject.photopath1 - } - fileList.push(file1) - } - if (formObject.photopath2 != "") { - var file2 = { - url: app.globalData.url + "static/" + formObject.photopath2 - } - fileList.push(file2) - } - if (formObject.photopath3 != "") { - var file3 = { - url: app.globalData.url + "static/" + formObject.photopath3 - } - fileList.push(file3) - } - - _this.setData({ - fileList - }); } - var installtime = 'form.installtimeFmt'; - var dateNow = this.formatDate(); - this.setData({ - installtimeFmt: dateNow, - [installtime]: dateNow, - }); - }, + } + }) - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { + //获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + _this.setData({ + option1: welltypeArr + }) + } + } +}) - }, + //跳转时带入参数返回哪页 + if (options.pageName) { + this.setData({ + pageName: options.pageName + }) + } + //跳转时带入参数设备的安装信息 + if (wx.getStorageSync('resultObject')) { + var formObject = wx.getStorageSync('resultObject') + _this.setData({ + form: formObject, + detail: formObject + }) - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { + _this.setData({ + ['form.installperson']: app.globalData.userName, + ['form.installtimeFmt']: "", + ['form.workmsg']: "", + ['form.description']: "" + }) - }, + const { + fileList = [] + } = _this.data; + if (formObject.photopath1 != "") { + var file1 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath1 + } + fileList.push(file1) + } + if (formObject.photopath2 != "") { + var file2 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath2 + } + fileList.push(file2) + } + if (formObject.photopath3 != "") { + var file3 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath3 + } + fileList.push(file3) + } + _this.setData({ + fileList + }); + } + var installtime = 'form.installtimeFmt'; + var dateNow = this.formatDate(); + this.setData({ + installtimeFmt: dateNow, + [installtime]: dateNow, + }); + }, - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, - }, + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + wx.removeStorageSync('resultObject') + }, - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, - }, + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { + }, - }, + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { + }, - }, + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { + }, - }, + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + }, - /** - * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true - **/ + /** + * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true + **/ - isNumber: function (val) { + isNumber: function (val) { - var regPos = /^[0-9]*$/; //非负浮点数 - var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数 - if (regPos.test(val) || regNeg.test(val)) { - return false; - } else { - return true; - } + var regPos = /^[0-9]*$/; //非负浮点数 + var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数 + if (regPos.test(val) || regNeg.test(val)) { + return false; + } else { + return true; + } - }, + }, - formValidate() { + formValidate() { - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } - if (this.data.form.wellcode == "") { - wx.showToast({ - icon: 'none', - title: '井编号不能为空!', - }) - return false - } - if (this.data.form.devicetype == "") { - wx.showToast({ - icon: 'none', - title: '设备类型不能为空!', - }) - return false - } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + if (this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '设备编号不能为空!', + }) + return false + } + if (this.data.form.wellcode == "") { + wx.showToast({ + icon: 'none', + title: '井编号不能为空!', + }) + return false + } + if (this.data.form.devicetype == "") { + wx.showToast({ + icon: 'none', + title: '设备类型不能为空!', + }) + return false + } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null || - this.data.form.installperson == '') { - wx.showToast({ - icon: 'none', - title: '运维人员不能为空!', - }) - return false - } - if (this.data.form.project == "") { - wx.showToast({ - icon: 'none', - title: '所属项目不能为空!', - }) - return false - } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } + if (this.data.form.installperson == null || + this.data.form.installperson == '') { + wx.showToast({ + icon: 'none', + title: '运维人员不能为空!', + }) + return false + } + if (this.data.form.project == "") { + wx.showToast({ + icon: 'none', + title: '所属项目不能为空!', + }) + return false + } - if (this.data.form.welldepth != null) { - if (this.isNumber(this.data.form.welldepth)) { - wx.showToast({ - icon: 'none', - title: '井深必须为数值!', - }) - return false - } - } - if (this.data.form.installheigt != null) { - if (this.isNumber(this.data.form.installheigt)) { - wx.showToast({ - icon: 'none', - title: '到井口距离必须为数值!', - }) - return false - } - } - - return true; - }, - - changeMsg: function () { - var formNew = this.data.form; - var formOld = JSON.parse(this.data.detail); - var descpNew = ""; - if (formNew.devcode != formOld.devcode) { - descpNew += "修改设备编号,原编号:" + formOld.devcode + ",新编号:" + formNew.devcode + ";" - } - if (formNew.devicetype != formOld.devicetype) { - descpNew += "修改设备类型,原设备类型:" + formOld.devicetype + ",新设备类型:" + formNew.devicetype + ";" - } - if (formNew.area != formOld.area) { - descpNew += "修改区,原区:" + formOld.area + ",新区:" + formNew.area + ";" - } - if (formNew.street != formOld.street) { - descpNew += "修改街道,原街道:" + formOld.street + ",新街道:" + formNew.street + ";" - } - if (formNew.wellname != formOld.wellname) { - descpNew += "修改井名称,原井名称:" + formOld.wellname + ",新井名称:" + formNew.wellname + ";" - } - if (formNew.factory != formOld.factory) { - descpNew += "修改权属单位,原权属单位:" + formOld.factory + ",新权属单位:" + formNew.factory + ";" - } - if (formNew.installheigt != formOld.installheigt) { - descpNew += "修改井口距离,原井口距离:" + formOld.installheigt + ",新井口距离:" + formNew.installheigt + ";" - } - if (formNew.installperson != formOld.installperson) { - descpNew += "修改运维人员,原运维人员:" + formOld.installperson + ",新运维人员:" + formNew.installperson + ";" - } - if (formNew.latitude != formOld.latitude) { - descpNew += "修改纬度,原纬度:" + formOld.latitude + ",新纬度:" + formNew.latitude + ";" - } - if (formNew.longitude != formOld.longitude) { - descpNew += "修改经度,原经度:" + formOld.longitude + ",新经度:" + formNew.longitude + ";" - } - if (formNew.position != formOld.position) { - descpNew += "修改位置描述,原位置:" + formOld.position + ",新位置:" + formNew.position + ";" - } - if (formNew.wellcode != formOld.wellcode) { - descpNew += "修改井编号,原编号:" + formOld.wellcode + ",新编号:" + formNew.wellcode + ";" - } - if (formNew.welldepth != formOld.welldepth) { - descpNew += "修改井深,原井深:" + formOld.welldepth + ",新井深:" + formNew.welldepth + ";" - } - if (formNew.welltype != formOld.welltype) { - descpNew += "修改井类型,原井类型:" + formOld.welltype + ",新井类型:" + formNew.welltype + ";" - } - if (formNew.project != formOld.project) { - descpNew += "修改所属项目,原项目:" + formOld.project + ",新项目:" + formNew.project + ";" - } - if (this.data.photopath1 != formOld.photopath1 || - this.data.photopath2 != formOld.photopath2 || - this.data.photopath3 != formOld.photopath3) { - descpNew += "修改照片;" - } - if ("" != formNew.description) { - descpNew += formNew.description; - } - this.setData({ - ['form.description']: descpNew + if (this.data.form.welldepth != null) { + if (this.isNumber(this.data.form.welldepth)) { + wx.showToast({ + icon: 'none', + title: '井深必须为数值!', }) - }, + return false + } + } + if (this.data.form.installheigt != null) { + if (this.isNumber(this.data.form.installheigt)) { + wx.showToast({ + icon: 'none', + title: '到井口距离必须为数值!', + }) + return false + } + } - formSubmit: function (event) { + return true; + }, - if (!this.formValidate()) { - return false; - } - this.changeMsg(); - var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDeviceLog', - data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceLog/add" - }, - }).then(res => { - // var resultObj=JSON.parse(res.result); - if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - if (res.confirm) { - wx.switchTab({ - url: that.data.pageName - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) - } - }).catch(err => { - console.error(err) - wx.showToast({ - title: "提交失败", - }) - }) - }, - confirm(event) { - var that = this; - var formValue = event.detail.value; - var formName = event.target.dataset.id; - var fromN = 'form.' + [formName]; - that.setData({ - [fromN]: formValue - }) - }, + //获取与上次修改的信息 + changeMsg: function () { + var formNew = this.data.form; + console.log(this.data.detail) + var formOld = JSON.parse(this.data.detail); + var descpNew = ""; + if (formNew.devcode != formOld.devcode) { + descpNew += "修改设备编号,原值:" + formOld.devcode + ",新值:" + formNew.devcode + ";" + } + if (formNew.devicetype != formOld.devicetype) { + descpNew += "修改设备类型,原值:" + formOld.devicetype + ",新值:" + formNew.devicetype + ";" + } + if (formNew.area != formOld.area) { + descpNew += "修改区,原值:" + formOld.area + ",新值:" + formNew.area + ";" + } + if (formNew.street != formOld.street) { + descpNew += "修改街道,原值:" + formOld.street + ",新值:" + formNew.street + ";" + } + if (formNew.wellname != formOld.wellname) { + descpNew += "修改井名称,原值:" + formOld.wellname + ",新值:" + formNew.wellname + ";" + } + if (formNew.factory != formOld.factory) { + descpNew += "修改权属单位,原值:" + formOld.factory + ",新值:" + formNew.factory + ";" + } + if (formNew.installheigt != formOld.installheigt) { + descpNew += "修改井口距离,原值:" + formOld.installheigt + ",新值:" + formNew.installheigt + ";" + } + if (formNew.installperson != formOld.installperson) { + descpNew += "修改运维人员,原值:" + formOld.installperson + ",新值:" + formNew.installperson + ";" + } + if (formNew.latitude != formOld.latitude) { + descpNew += "修改纬度,原值:" + formOld.latitude + ",新值:" + formNew.latitude + ";" + } + if (formNew.longitude != formOld.longitude) { + descpNew += "修改经度,原值:" + formOld.longitude + ",新值:" + formNew.longitude + ";" + } + if (formNew.position != formOld.position) { + descpNew += "修改位置描述,原值:" + formOld.position + ",新值:" + formNew.position + ";" + } + if (formNew.wellcode != formOld.wellcode) { + descpNew += "修改井编号,原值:" + formOld.wellcode + ",新值:" + formNew.wellcode + ";" + } + if (formNew.welldepth != formOld.welldepth) { + descpNew += "修改井深,原值:" + formOld.welldepth + ",新值:" + formNew.welldepth + ";" + } + if (formNew.welltype != formOld.welltype) { + descpNew += "修改井类型,原值:" + formOld.welltype + ",新值:" + formNew.welltype + ";" + } + if (formNew.project != formOld.project) { + descpNew += "修改所属项目,原值:" + formOld.project + ",新值:" + formNew.project + ";" + } + if (this.data.form.photopath1 != formOld.photopath1 || + this.data.form.photopath2 != formOld.photopath2 || + this.data.form.photopath3 != formOld.photopath3) { + descpNew += "修改照片;" + } + if ("" != formNew.description) { + descpNew += formNew.description; + } + this.setData({ + ['form.description']: descpNew + }) + }, - scan() { + //提交表单 + formSubmit: function (event) { - wx.scanCode({ - success(res) { - console.log(res) - } - }) + //表单验证 + if (!this.formValidate()) { + return false; + } + //自动生成修改内容 + this.changeMsg(); + //提交权限限制(只有施工人员能修改) + if(app.globalData.role!='repair'){ + wx.showToast({ + icon: 'none', + title: '无权限修改', + duration:2000 + }) + return false + } + var that = this; + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopath = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopath]: fileList[i].url.split("static/")[1] + }) + } + delete that.data.form.installtime + delete that.data.form.createtime + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - paste() { - var _this = this; - wx.getClipboardData({ - success: function (res) { - var longitude = 'form.longitude'; - var latitude = 'form.latitude'; - var longitude84 = 'form.longitude84'; - var latitude84 = 'form.latitude84'; - _this.setData({ - [longitude]: parseFloat(res.data.split(",", 4)[1]).toFixed(6), - [latitude]: parseFloat(res.data.split(",", 4)[0]).toFixed(6), - [longitude84]: "" == (res.data.split(",", 4)[3]) ? "" : parseFloat(res.data.split(",", 4)[3]).toFixed(6), - [latitude84]: "" == (res.data.split(",", 4)[2]) ? "" : parseFloat(res.data.split(",", 4)[2]).toFixed(6), - longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), - latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), - }); - } - }) - }, - selectValue(value) { - var that = this; - var wellType = 'form.welltype'; - that.setData({ - [wellType]: value.detail - }) - }, - selectpersonValue(event) { - var that = this; - var installPerson = 'form.installperson'; - that.setData({ - [installPerson]: event.detail - }) - }, - selectprojectValue(event) { - var that = this; - var project = 'form.project'; - that.setData({ - [project]: event.detail, - showMask: true - }) - }, - open() { - this.setData({ - showMask: true - }) - }, - close() { - this.setData({ - showMask: false - }) - }, - afterRead(event) { - var _this = this; - const { - file - } = event.detail; - const { - fileList = [] - } = _this.data; - var convertpath = ""; - wx.compressImage({ - src: event.detail.file.path, - quality: 25, - success: function (res) { - convertpath = res.tempFilePath; - wx.uploadFile({ - url: app.globalData.httpsUrl + "appDeviceAdd/fileUploadMarker", - filePath:convertpath, - name: 'file', - formData: { - 'text': "编号:" + _this.data.form.devcode + "经度:" + _this.data.form.longitude + "纬度:" + _this.data.form.latitude - }, - header: { - "Content-Type": "multipart/form-data", - 'accept': 'application/json', - }, - success(res) { - if (res.data) { - var url = JSON.parse(res.data); - fileList.push({ - ...file, - url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - }); - _this.setData({ - fileList - }); - } - } + success(res) { + if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + if (res.confirm) { + wx.switchTab({ + url: that.data.pageName }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') } - }) - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // // var base64 = "data:image/png;base64," + wx.getFileSystemManager().readFileSync(convertpath, 'base64'); - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: convertpath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // // wx.cloud.callFunction({ - // // name: 'uploadFile', - // // data: { - // // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // // fileBase64: base64 - // // }, - // // success: function (res) { - // // if (res.result) { - // // fileList.push({ - // // ...file, - // // url: app.globalData.url + "static/" + res.result.data.replace(/\\/g, "/") - // // }); - // // _this.setData({ - // // fileList - // // }); - // // } - // // }, - // // complete: res => { - // // }, - // // }) - // } - // }); + } + }) + } + }, + fail(err) { + wx.showToast({ + title: "提交失败", + }) + } + }) + }, + //报存录入的input信息 + confirm(event) { + var that = this; + var formValue = event.detail.value; + var formName = event.target.dataset.id; + var fromN = 'form.' + [formName]; + that.setData({ + [fromN]: formValue + }) + }, + + //扫码 + scan() { + + wx.scanCode({ + success(res) { + console.log(res) + } + }) + }, + //粘贴经纬度 + paste() { + var _this = this; + wx.getClipboardData({ + success: function (res) { + var longitude = 'form.longitude'; + var latitude = 'form.latitude'; + var longitude84 = 'form.longitude84'; + var latitude84 = 'form.latitude84'; + _this.setData({ + [longitude]: parseFloat(res.data.split(",", 4)[1]).toFixed(6), + [latitude]: parseFloat(res.data.split(",", 4)[0]).toFixed(6), + [longitude84]: "" == (res.data.split(",", 4)[3]) ? "" : parseFloat(res.data.split(",", 4)[3]).toFixed(6), + [latitude84]: "" == (res.data.split(",", 4)[2]) ? "" : parseFloat(res.data.split(",", 4)[2]).toFixed(6), + longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), + latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), + }); + } + }) + }, + selectValue(value) { + var that = this; + var wellType = 'form.welltype'; + that.setData({ + [wellType]: value.detail + }) + }, + //运维人员默认为登录人 + // selectpersonValue(event) { + // var that = this; + // var installPerson = 'form.installperson'; + // that.setData({ + // [installPerson]: event.detail + // }) + // }, + selectprojectValue(event) { + var that = this; + var project = 'form.project'; + that.setData({ + [project]: event.detail, + showMask: true + }) + }, + + open() { + this.setData({ + showMask: true + }) + }, + //隐藏textarea,防止遮挡 + close() { + this.setData({ + showMask: false + }) + }, + //上传照片 + afterRead(event) { + var _this = this; + const { + file + } = event.detail; + const { + fileList = [] + } = _this.data; + var convertpath = ""; + wx.compressImage({ + src: event.detail.file.path, + quality: 25, + success: function (res) { + convertpath = res.tempFilePath; + wx.uploadFile({ + url: app.globalData.httpsUrl + "appDeviceAdd/fileUploadMarker", + filePath: convertpath, + name: 'file', + formData: { + 'text': "编号:" + _this.data.form.devcode + "经度:" + _this.data.form.longitude + "纬度:" + _this.data.form.latitude }, - deletePhoto(event) { - var that = this - var image_index = event.detail.index - var fileList_new = that.data.fileList; - wx.showModal({ - content: '确定删除照片?', - success: function (res) { - if (res.confirm) { - fileList_new.splice(image_index, 1); - that.setData({ - fileList: fileList_new - }) - wx.cloud.callFunction({ - name: 'deletePhoto', - data: { - url: app.globalData.url + "appDeviceLog/deletePhoto", - devcode: that.data.form.devcode, - pathIndex: image_index - }, - success: function (res) {}, - complete: res => {}, - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + "Content-Type": "multipart/form-data", + 'accept': 'application/json', }, - }) \ No newline at end of file + success(res) { + if (res.data) { + var url = JSON.parse(res.data); + fileList.push({ + ...file, + url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") + }); + _this.setData({ + fileList + }); + } + } + }) + } + }) + }, + //删除照片 + deletePhoto(event) { + var that = this + var image_index = event.detail.index + var fileList_new = that.data.fileList; + wx.showModal({ + content: '确定删除照片?', + success: function (res) { + if (res.confirm) { + fileList_new.splice(image_index, 1); + that.setData({ + fileList: fileList_new + }) + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deletePhoto", + data: { + devcode: that.data.form.devcode + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) {} + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } +}) \ No newline at end of file diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.wxml b/miniprogram/pages/addDevicelog/addDeviceLog.wxml index 38620d4..b10cc7d 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.wxml +++ b/miniprogram/pages/addDevicelog/addDeviceLog.wxml @@ -1,15 +1,21 @@ - + + + + + - + - - + + - - + + - + @@ -39,24 +45,25 @@ - - - + + + - + - + + @@ -64,7 +71,7 @@ - + @@ -79,9 +86,9 @@ - + - 保存 + 保存 diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.wxss b/miniprogram/pages/addDevicelog/addDeviceLog.wxss index ee0b75c..08d5fd7 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.wxss +++ b/miniprogram/pages/addDevicelog/addDeviceLog.wxss @@ -24,6 +24,17 @@ display: flex; align-items: center; } +.map-view{ + width: 750rpx; + height: 485rpx; + position: fixed; + top: 0px; + left: 0px; + z-index: 999; +} +.content{ + margin-top: 495rpx; +} .left { width: 210rpx; diff --git a/miniprogram/pages/addFunction/addFunction.js b/miniprogram/pages/addFunction/addFunction.js deleted file mode 100644 index 4966be3..0000000 --- a/miniprogram/pages/addFunction/addFunction.js +++ /dev/null @@ -1,60 +0,0 @@ -// pages/addFunction/addFunction.js - -const code = `// 云函数入口函数 -exports.main = (event, context) => { - console.log(event) - console.log(context) - return { - sum: event.a + event.b - } -}` - -Page({ - - data: { - result: '', - canIUseClipboard: wx.canIUse('setClipboardData'), - }, - - onLoad: function (options) { - - }, - - copyCode: function() { - wx.setClipboardData({ - data: code, - success: function () { - wx.showToast({ - title: '复制成功', - }) - } - }) - }, - - testFunction() { - wx.cloud.callFunction({ - name: 'sum', - data: { - a: 1, - b: 2 - }, - success: res => { - wx.showToast({ - title: '调用成功', - }) - this.setData({ - result: JSON.stringify(res.result) - }) - }, - fail: err => { - wx.showToast({ - icon: 'none', - title: '调用失败', - }) - console.error('[云函数] [sum] 调用失败:', err) - } - }) - }, - -}) - diff --git a/miniprogram/pages/addFunction/addFunction.json b/miniprogram/pages/addFunction/addFunction.json deleted file mode 100644 index a9a50c5..0000000 --- a/miniprogram/pages/addFunction/addFunction.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "navigationBarTitleText": "云函数指引", - "usingComponents": {} -} \ No newline at end of file diff --git a/miniprogram/pages/addFunction/addFunction.wxml b/miniprogram/pages/addFunction/addFunction.wxml deleted file mode 100644 index 3a10626..0000000 --- a/miniprogram/pages/addFunction/addFunction.wxml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - 测试云函数 - - - 期望输出:{"sum":3} - - - 调用结果:{{result}} - - - - - 新增云函数 - 1. 在云函数根目录 cloudfunctions 上右键选择新建云函数,命名为 sum - 2. 在创建的 cloudfunctions/sum/index.js 文件中添加如下代码 - - - 3. 在 cloudfunctions/sum 目录上右键上传并部署 - 4. 点击测试云函数测试 - 5. 打开云开发云函数管理页,选择 sum 云函数 - 6. 查看 sum 的调用日志 - 进阶:可在云函数中使用 wx-server-sdk 操作数据库,文件存储和调用其他云函数,详见文档 - - - diff --git a/miniprogram/pages/addFunction/addFunction.wxss b/miniprogram/pages/addFunction/addFunction.wxss deleted file mode 100644 index 7ac8619..0000000 --- a/miniprogram/pages/addFunction/addFunction.wxss +++ /dev/null @@ -1,3 +0,0 @@ -/* pages/addFunction/addFunction.wxss */ - -@import "../../style/guide.wxss"; \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.js b/miniprogram/pages/applog/applog.js index 0e8c185..189e61f 100644 --- a/miniprogram/pages/applog/applog.js +++ b/miniprogram/pages/applog/applog.js @@ -13,98 +13,25 @@ isSeach: "false", params: {}, total: 0, - show: false + show: false, + delBtnWidth: 100, //删除按钮宽度单位(rpx) + activeIndex: -1, + list_style: '' }, - - touchE: function (e) { - // console.log(e); - var that = this - if (e.changedTouches.length == 1) { - //手指移动结束后触摸点位置的X坐标 - var endX = e.changedTouches[0].clientX; - //触摸开始与结束,手指移动的距离 - var disX = that.data.startX - endX; - var delBtnWidth = that.data.delBtnWidth; - //如果距离小于删除按钮的1/2,不显示删除按钮 - var txtStyle = disX > delBtnWidth / 2 ? "left:-" + delBtnWidth + "rpx" : "left:0rpx"; - - //获取手指触摸的是哪一项 - var index = e.currentTarget.dataset.index; - var list = that.data.deviceloglist; - list[index].txtStyle = txtStyle; - //更新列表的状态 - that.setData({ - deviceloglist: list - }); - } - }, - //手指触摸动作开始 记录起点X坐标 - touchstart: function (e) { - //开始触摸时 重置所有删除 - this.data.deviceloglist.forEach(function (v, i) { - if (v.isTouchMove) //只操作为true的 - v.isTouchMove = false; - }) - this.setData({ - startX: e.changedTouches[0].clientX, - startY: e.changedTouches[0].clientY, - deviceloglist: this.data.deviceloglist - }) - }, - //滑动事件处理 - touchmove: function (e) { - var that = this, - index = e.currentTarget.dataset.index, //当前索引 - startX = that.data.startX, //开始X坐标 - startY = that.data.startY, //开始Y坐标 - touchMoveX = e.changedTouches[0].clientX, //滑动变化坐标 - touchMoveY = e.changedTouches[0].clientY, //滑动变化坐标 - //获取滑动角度 - angle = that.angle({ - X: startX, - Y: startY - }, { - X: touchMoveX, - Y: touchMoveY - }); - that.data.deviceloglist.forEach(function (v, i) { - v.isTouchMove = false - //滑动超过30度角 return - if (Math.abs(angle) > 30) return; - if (i == index) { - if (touchMoveX > startX) //右滑 - v.isTouchMove = false - else //左滑 - v.isTouchMove = true - } - }) - //更新数据 - that.setData({ - deviceloglist: that.data.deviceloglist - }) - }, - /** - * 计算滑动角度 - * @param {Object} start 起点坐标 - * @param {Object} end 终点坐标 - */ - angle: function (start, end) { - var _X = end.X - start.X, - _Y = end.Y - start.Y - //返回角度 /Math.atan()返回数字的反正切值 - return 360 * Math.atan(_Y / _X) / (2 * Math.PI); - }, - /** - * 生命周期函数--监听页面加载var_this=this; - */ onLoad: function (options) { - if (options.params) { this.setData({ params: JSON.parse(options.params), isSeach: "true" }) this.initPages() + }else{ + this.setData({ + show: false + }) + //清空参数,重新加载 + this.clearParams(); + this.initPages(); } }, @@ -116,20 +43,33 @@ }, + //点击tabBar事件 + onTabItemTap(item) { + //隐藏历史显示总记录条数 + this.setData({ + show: false + }) + //清空参数,重新加载 + this.clearParams(); + this.initPages(); + }, + + /** * 生命周期函数--监听页面显示 */ onShow: function (options) { - this.setData({ - show:false - }) - if (this.data.isSeach == "false") { - this.clearParams(); - this.initPages(); - } - this.setData({ - isSeach: "false" - }) + + // this.setData({ + // show: false + // }) + // if (this.data.isSeach == "false") { + // this.clearParams(); + // this.initPages(); + // } + // this.setData({ + // isSeach: "false" + // }) }, /** @@ -167,6 +107,119 @@ }, + + //手指触摸动作开始 记录起点X坐标 + touchstart: function (e) { + //开始触摸时 重置所有删除 + this.data.deviceloglist.forEach(function (v, i) { + if (v.isTouchMove) //只操作为true的 + v.isTouchMove = false; + }) + this.setData({ + startX: e.changedTouches[0].clientX, + startY: e.changedTouches[0].clientY, + deviceloglist: this.data.deviceloglist + }) + }, + + //滑动事件处理 + touchmove: function (e) { + var that = this, + index = e.currentTarget.dataset.index, //当前索引 + startX = that.data.startX, //开始X坐标 + startY = that.data.startY, //开始Y坐标 + touchMoveX = e.changedTouches[0].clientX, //滑动变化坐标 + touchMoveY = e.changedTouches[0].clientY, //滑动变化坐标 + //获取滑动角度 + angle = that.angle({ + X: startX, + Y: startY + }, { + X: touchMoveX, + Y: touchMoveY + }); + that.data.deviceloglist.forEach(function (v, i) { + // v.isTouchMove = false + //滑动超过30度角 return + if (Math.abs(angle) > 30) return; + if (i == index) { + if (touchMoveX > startX) //右滑 + v.isTouchMove = false + else //左滑 + v.isTouchMove = true + } + }) + //更新数据 + that.setData({ + deviceloglist: that.data.deviceloglist + }) + }, + + /** + * 计算滑动角度 + * @param {Object} start 起点坐标 + * @param {Object} end 终点坐标 + */ + angle: function (start, end) { + var _X = end.X - start.X, + _Y = end.Y - start.Y + //返回角度 /Math.atan()返回数字的反正切值 + return 360 * Math.atan(_Y / _X) / (2 * Math.PI); + }, + + //删除事件 + delItem: function (e) { + if(app.globalData.role!='repair'){ + wx.showToast({ + icon: 'none', + title: '无权限删除', + duration:2000 + }) + return false + } + var that = this + wx.showModal({ + content: '是否删除?', + success: function (res) { + if (res.confirm) { + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/delete", + data: { + appDeviceAddId: e.currentTarget.dataset.devid + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if(res.data.code=='200'){ + that.data.deviceloglist.splice(e.currentTarget.dataset.index, 1) + that.setData({ + deviceloglist: that.data.deviceloglist, + total: that.data.deviceloglist.length + }) + wx.showToast({ + title: '删除成功!', + icon: 'none', + duration: 1000 + }) + } + }, + fail(err) { + wx.showToast({ + title: '删除失败!', + icon: 'none', + duration: 2000 + }) + } + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + }, + showLoading: function (message) { if (wx.showLoading) { // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 @@ -199,95 +252,105 @@ deviceloglist: [] }) }, + //查询列表数据 initPages: function () { var that = this + that.setData({ + show: false + }) var offsetValue = that.data.deviceloglist.length % 15 > 0 ? parseInt(that.data.deviceloglist.length / 15) + 2 : parseInt(that.data.deviceloglist.length / 15) + 1 - wx.cloud.callFunction({ - name: 'devicelog', + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/listPage", data: { devcode: that.data.params.devcode, devtype: that.data.params.devtype, installtimeFmt: that.data.params.installtimeFmt, project: that.data.params.project, installPerson: that.data.params.installPerson, - url: app.globalData.url + "appDeviceLog/listPage", limit: 15, offset: offsetValue }, - }).then(res => { - if (res.result.data.rows.length > 0) { - var resultJson = res.result - that.setData({ - deviceloglist: that.data.deviceloglist.concat(resultJson.data.rows) - }) - } else if (that.data.deviceloglist.length > 0) { - that.setData({ - show: true, - total: that.data.deviceloglist.length - }) - wx.showToast({ - title: '数据已全部加载完', - icon: 'none', - duration: 2000 - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.data.rows.length > 0) { + var resultJson = res.data + var listArr = resultJson.data.rows + listArr.forEach(function (v, i) { + listArr[i]['isTouchMove'] = false + }) + that.setData({ + deviceloglist: that.data.deviceloglist.concat(listArr) + }) + } else if (that.data.deviceloglist.length > 0) { + that.setData({ + show: true, + total: that.data.deviceloglist.length + }) + wx.showToast({ + title: '数据已全部加载完', + icon: 'none', + duration: 2000 + }) + } + if (offsetValue == 1 && res.data.data.rows.length < 15) { + that.setData({ + show: true, + total: that.data.deviceloglist.length + }) + } } - if(offsetValue==1&&res.result.data.rows.length<15){ - that.setData({ - show: true, - total: that.data.deviceloglist.length - }) - } - // console.log(res); - }).catch(err => { - console.error(err); }) + }, addDetail: function (event) { - this.showLoading("数据请求中..."); - wx.cloud.callFunction({ - name: 'deviceDetail', + var that = this + that.showLoading("数据请求中..."); + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deviceDetail", data: { devcode: event.target.dataset.devcode, - url: app.globalData.url + "appDeviceLog/deviceDetail", }, - }).then(res => { - this.hideLoading(); - var resultObject = JSON.parse(res.result); - var pageName = '../applog/applog' - if (resultObject.code == 200) { - wx.navigateTo({ - url: '../addDevicelog/addDeviceLog?detail=' + - JSON.stringify(resultObject.data) + "&pageName=" + pageName - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + that.hideLoading(); + // var resultObject = JSON.parse(res.data); + var resultObject = res.data; + var pageName = '../applog/applog' + if (resultObject.code == 200) { + wx.setStorageSync('resultObject', resultObject.data) + wx.navigateTo({ + url: '../addDevicelog/addDeviceLog?detail=' + "&pageName=" + pageName + }) + } + }, + fail(err) { + that.hideLoading(); } - }).catch(err => { - this.hideLoading() }) + }, add: function (event) { - wx.reLaunch({ - url: '../earth/earth?devcode=' + event.target.dataset.devcode - // url: '../earth/earth' + app.globalData.devcode = event.target.dataset.devcode; + wx.switchTab({ + url: '../earth/earth' }) + // wx.reLaunch({ + // url: '../earth/earth?devcode=' + event.target.dataset.devcode + // // url: '../earth/earth' + // }) }, onSearch: function () { + var _this = this wx.navigateTo({ - url: '../searchLog/searchLog' + url: '../searchLog/searchLog?params=' + JSON.stringify(_this.data.params) }) - }, - // initPages: function () { - // wx.cloud.callFunction({ - // name: 'devicelog' - // }).then(res => { - // var that = this; - // var jsonList = JSON.parse(res.result) - // that.setData({ - // deviceloglist: jsonList.data.rows - // }) - // console.log(res); - // }).catch(err => { - // console.error(err); - // }) - // } + } }) \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.wxml b/miniprogram/pages/applog/applog.wxml index e9a2352..2bfd041 100644 --- a/miniprogram/pages/applog/applog.wxml +++ b/miniprogram/pages/applog/applog.wxml @@ -1,54 +1,59 @@ - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {{item.devcode}} {{item.devicetype}} + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + {{item.devcode}} {{item.devicetype}} + + {{item.project}} {{item.installtime}}- {{item.installperson}} - - - - - + + + + + + 删除 - - - + + - 共计:{{total}}台 - + 共计:{{total}}台 + \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.wxss b/miniprogram/pages/applog/applog.wxss index 6d3428b..e6e8983 100644 --- a/miniprogram/pages/applog/applog.wxss +++ b/miniprogram/pages/applog/applog.wxss @@ -22,16 +22,18 @@ position: fixed; width: 100%; top: 0rpx; + z-index: 9999; /* margin-bottom: 100rpx; */ } .log-list { /* height: 100rpx; */ - /* display: flex; */ - + display: flex; + width: 100%; padding: 2px; margin-top: 2px; border-bottom: 1px solid #e5e5e5; + overflow: hidden } @@ -53,23 +55,29 @@ left: 35%; margin: 20rpx } - .del { - width: 90px; + /* display: flex; */ + width: 100rpx; display: flex; flex-direction: column; align-items: center; justify-content: center; - color: #fff; - -webkit-transform: translateX(90px); - transform: translateX(90px); - -webkit-transition: all 0.4s; + /* -webkit-transform: translateX(100rpx); */ + transform: translateX(100rpx); + /* -webkit-transition: all 0.4s; */ transition: all 0.4s; - font-size: 35rpx; + color: #fff; + background-color: #fe3e2f; +} +.logrow{ + width: 100%; + transform: translateX(100rpx); + /* -webkit-transform: translateX(100px); */ + margin-left: -100rpx; } -.touch-move-active .content, +.touch-move-active .logrow, .touch-move-active .del { - -webkit-transform: translateX(0); - transform: translateX(0); +/* -webkit-transform: translateX(0); */ +transform: translateX(0); } \ No newline at end of file diff --git a/cloudfunctions/project.config.json b/cloudfunctions/project.config.json new file mode 100644 index 0000000..2b3119a --- /dev/null +++ b/cloudfunctions/project.config.json @@ -0,0 +1,28 @@ +{ + "appid": "wx2cef527a000f87c9", + "compileType": "miniprogram", + "libVersion": "2.27.3", + "packOptions": { + "ignore": [], + "include": [] + }, + "setting": { + "coverView": true, + "es6": true, + "postcss": true, + "minified": true, + "enhance": true, + "showShadowRootInWxmlPanel": true, + "packNpmRelationList": [], + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + } + }, + "condition": {}, + "editorSetting": { + "tabIndent": "insertSpaces", + "tabSize": 4 + } +} \ No newline at end of file diff --git a/cloudfunctions/project.private.config.json b/cloudfunctions/project.private.config.json new file mode 100644 index 0000000..42ff49d --- /dev/null +++ b/cloudfunctions/project.private.config.json @@ -0,0 +1,7 @@ +{ + "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", + "projectname": "cloudfunctions", + "setting": { + "compileHotReLoad": true + } +} \ No newline at end of file diff --git a/miniprogram/app.js b/miniprogram/app.js index 51d56f3..50a8a54 100644 --- a/miniprogram/app.js +++ b/miniprogram/app.js @@ -18,13 +18,15 @@ // this.globalData = {} }, globalData: { - // url: "http://111.198.10.15:11604/", - httpsUrl: "https://logapi.smartlog.work/", - httpsTestUrl: "https://smartlog.work/prodapi4test/", - url: "http://139.198.18.188:8083/", + httpsUrl: "https://logapi.smartlog.work/", + // httpsUrl: "http://139.198.18.188:8083/", // url: "http://127.0.0.1:8083/", - // httpsUrl: "http://127.0.0.1:8083/", + //httpsUrl: "http://127.0.0.1:8083/", openid: null, - indexCount:1 - }, + indexCount:1, + nickName:"", + userName:"", + role:"", + devcode:"" + } }) diff --git a/miniprogram/app.json b/miniprogram/app.json index d23f798..2b6db76 100644 --- a/miniprogram/app.json +++ b/miniprogram/app.json @@ -1,15 +1,17 @@ { "cloud": true, "pages": [ + "pages/login/login", "pages/indexapp/indexapp", "pages/earth/earth", "pages/applog/applog", "pages/addDevice/addDevice", "pages/addDevicelog/addDeviceLog", - "pages/searchLog/searchLog" + "pages/searchLog/searchLog", + "pages/notice/notice" ], "window": { - "backgroundColor": "#F6F6F6", + "backgroundColor": "#E6D480", "backgroundTextStyle": "light", "navigationBarBackgroundColor": "#FFCF00", "navigationBarTitleText": "智慧施工", @@ -46,11 +48,11 @@ "desc": "你的位置信息将用于小程序位置接口的效果展示" } }, + "requiredPrivateInfos": ["getLocation", "chooseLocation"], "networkTimeout": { "request": 30000, "connectSocket": 30000, "uploadFile": 30000, "downloadFile": 30000 - }, - "style": "v2" + } } \ No newline at end of file diff --git a/miniprogram/images/applocat.png b/miniprogram/images/applocat.png new file mode 100644 index 0000000..fe49f54 --- /dev/null +++ b/miniprogram/images/applocat.png Binary files differ diff --git a/miniprogram/images/back.png b/miniprogram/images/back.png new file mode 100644 index 0000000..32ac82d --- /dev/null +++ b/miniprogram/images/back.png Binary files differ diff --git a/miniprogram/images/bottom.png b/miniprogram/images/bottom.png new file mode 100644 index 0000000..d910e98 --- /dev/null +++ b/miniprogram/images/bottom.png Binary files differ diff --git a/miniprogram/images/header.png b/miniprogram/images/header.png new file mode 100644 index 0000000..6ea222e --- /dev/null +++ b/miniprogram/images/header.png Binary files differ diff --git a/miniprogram/images/login.png b/miniprogram/images/login.png index 8b73cc0..6471c46 100644 --- a/miniprogram/images/login.png +++ b/miniprogram/images/login.png Binary files differ diff --git a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss index 5a591fb..c9c35b5 100644 --- a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss +++ b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:100%;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:100%}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file +@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:650rpx;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:600rpx}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file diff --git a/miniprogram/pages/addDevice/addDevice.js b/miniprogram/pages/addDevice/addDevice.js index 2783674..78f00b7 100644 --- a/miniprogram/pages/addDevice/addDevice.js +++ b/miniprogram/pages/addDevice/addDevice.js @@ -1,5 +1,7 @@ // miniprogram/pages/addDevice/addDevice.js // import WxValidate from '../../utils/WxValidate.js' +var QQMapWX = require('../../libs/qqmap-wx-jssdk.js'); +var qqmapsdk; var app = getApp() Page({ @@ -11,32 +13,10 @@ canvasWidth: '', longitude: '', latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], + option1: [], personoption1: [], projectoption: [], + devtypeList:[], show: false, form: { devcode: "", @@ -59,7 +39,10 @@ project: "", area: "", street: "", - wellname: "" + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '', }, fileList: [] }, @@ -117,12 +100,14 @@ var that = this; //初始化表单内容为上次填写值 var cacheForms = wx.getStorageSync('cacheList') - if (cacheForms) { + cacheForms.photopath1='' + cacheForms.photopath2='' + cacheForms.photopath3='' + that.data.fileList=[] that.setData({ form: cacheForms, devcode: cacheForms.devcode, - }) } var form = that.data.form @@ -155,55 +140,89 @@ } }) + +//获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + that.setData({ + option1: welltypeArr + }) + } + } +}) + + //获取人员下拉列表 - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/getUser", + data:{ + tips:'repair' }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data.code == 200) { + var users = res.data.data + var personArr = []; + for (var i = 0; i < users.length; i++) { + var person = { + text: users[i].name, + value: users[i].name + }; + personArr.push(person); + } + that.setData({ + personoption1: personArr + }) } - that.setData({ - personoption1: personArr - }) } - }).catch(err => { - console.error(err); - }) + }) + - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - that.setData({ - projectoption: projectArr - }) + success(res){ + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); + } + that.setData({ + projectoption: projectArr + }) + } } - }).catch(err => { - console.error(err); - }) + }) + var installtime = 'form.installtimeFmt'; var dateNow = this.formatDate(); this.setData({ @@ -211,8 +230,40 @@ installtimeFmt: dateNow, [installtime]: dateNow, }); + + + + /** + * 获取设备类型下拉列表 + */ + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/deviceType", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var TypeList = res.data.data + var typeArr = []; + for (var i = 0; i < TypeList.length; i++) { + var type = { + text: TypeList[i].productName, + value: TypeList[i].productName + }; + typeArr.push(type); + } + that.setData({ + devtypeList: typeArr + }) + } + } + }) }, + + + /** * 生命周期函数--监听页面初次渲染完成 */ @@ -280,29 +331,7 @@ }, - - //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 - drawText: function (ctx, str, leftWidth, initHeight, titleHeight, canvasWidth) { - var lineWidth = 0; - var lastSubStrIndex = 0; //每次开始截取的字符串的索引 - for (let i = 0; i < str.length; i++) { - lineWidth += ctx.measureText(str[i]).width; - if (lineWidth > canvasWidth) { - ctx.fillText(str.substring(lastSubStrIndex, i), leftWidth, initHeight); //绘制截取部分 - initHeight = initHeight + leftWidth * 2; //22为字体的高度 - lineWidth = 0; - lastSubStrIndex = i; - // titleHeight += 40; - } - if (i == str.length - 1) { //绘制剩余部分 - ctx.fillText(str.substring(lastSubStrIndex, i + 1), leftWidth, initHeight); - } - } - // // 标题border-bottom 线距顶部距离 - // titleHeight = titleHeight + 10; - // return titleHeight - }, - + //验证表单 formValidate() { if (this.data.form.devcode == "") { @@ -312,27 +341,20 @@ }) return false } - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } if (this.data.form.wellcode == "") { wx.showToast({ icon: 'none', @@ -348,22 +370,10 @@ }) return false } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null) { + + if (this.data.form.installperson == "") { wx.showToast({ icon: 'none', title: '安装人员不能为空!', @@ -408,56 +418,90 @@ } return true; }, + //提交表单 formSubmit: function (event) { + console.log(this.data.form) + //表单参数验证 if (!this.formValidate()) { return false; } var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDevice', + //验证设备编号长度 + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/getDevTypeLength", data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceAdd/add" + code: encodeURI(this.data.form.devicetype) }, - }).then(res => { - if (res.result.code == 500) { - wx.showToast({ - title: '设备编号已安装!', - }) - } else if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - //用于回显 - wx.setStorageSync('cacheList', that.data.form) - //提交成功后提示用户操作 - if (res.confirm) { - wx.switchTab({ - url: '../earth/earth' - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (""==res.data.data ||res.data.data == that.data.form.devcode.length) { + that.saveDevice() + } else { //编号位数不对提示 + wx.showToast({ + icon: 'none', + title: '设备编号位数不对!', + duration: 1000 + }) + return false + } } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "提交失败", - }) }) }, + + //保存设备基本信息 + saveDevice() { + var that = this; + //设置照片路径 + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopathForm = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopathForm]: fileList[i].url.split("static/")[1] + }) + } + //表单提交 + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 500) { + wx.showToast({ + title: '设备编号已安装!', + }) + } else if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + //用于回显 + wx.setStorageSync('cacheList', that.data.form) + //提交成功后提示用户操作 + if (res.confirm) { + wx.switchTab({ + url: '../earth/earth' + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } + }, + fail(err) { + wx.showToast({ + title: '提交失败!', + }) + } + }) + }, + + //input 输入框设置值 confirm(event) { var that = this; var formValue = event.detail.value; @@ -466,8 +510,30 @@ that.setData({ [fromN]: formValue }) + //若输入是设备编号,自动获取设备类型 + if('devcode'==formName){ + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", + data: { + devcode: formValue, + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + that.setData({ + [formDevicetype]: res.data + }); + } + } + }) + } }, + //扫描设备获取编号和设备类型 scan() { var _this = this; wx.scanCode({ @@ -477,23 +543,28 @@ _this.setData({ [formdevcode]: devcode }); - wx.cloud.callFunction({ - name: 'findModeCode', + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", data: { devcode: devcode, - url: app.globalData.url + "appDeviceAdd/findModeCodeByCode" }, - }).then(res => { - if (res.result) { - var formDevicetype = 'form.devicetype' - _this.setData({ - [formDevicetype]: res.result - }); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + _this.setData({ + [formDevicetype]: res.data + }); + } } }) } }) }, + //粘贴经纬度 paste() { var _this = this; wx.getClipboardData({ @@ -510,9 +581,11 @@ longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), }); + _this.showAddress(_this.data.form.longitude,_this.data.form.latitude,_this) } }) }, + //设置经类型 selectValue(value) { var that = this; @@ -521,6 +594,16 @@ [wellType]: value.detail }) }, + + //设置设备类型 + selectDevType(event) { + var that = this; + var devtype = 'form.devicetype'; + that.setData({ + [devtype]: event.detail + }) + }, + //设置运维人员 selectpersonValue(event) { var that = this; var installPerson = 'form.installperson'; @@ -528,6 +611,7 @@ [installPerson]: event.detail }) }, + //设置项目 selectprojectValue(event) { var that = this; var project = 'form.project'; @@ -535,8 +619,41 @@ [project]: event.detail }) }, + showAddress :function(longitude, latitude, self) { + // 实例化腾讯地图API核心类 + qqmapsdk = new QQMapWX({ + key: 'BGPBZ-C5O3P-ROUDR-LWC4J-63EKH-V5FRX'//此处使用你自己申请的key + }) + // 腾讯地图调用接口 + qqmapsdk.reverseGeocoder({ + location: { + latitude: latitude, + longitude: longitude + }, + success: function (res) { + self.setData({ + 'form.area':res.result.address.slice(0,res.result.address.indexOf('区')+1), + 'form.street':res.result.address.slice(res.result.address.indexOf('区')+1) + }) + }, + fail: function (res) { + console.log(res); + }, + complete: function (res) { + } + }); + }, + //上传照片 afterRead(event) { var _this = this; + if (_this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '请先填写设备编号!\r\n否则水印中无编号', + duration: 2000 + }) + return false + } const { file } = event.detail; @@ -576,78 +693,8 @@ }) } }) - // 压缩图片 - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // //获取图片尺寸 - // wx.getImageInfo({ - // src: convertpath, - // success(res) { - // _this.setData({ - // canvasHeight: res.height, - // canvasWidth: res.width - // }) - // var ctx = wx.createCanvasContext('firstCanvas') - - // //将图片src放到cancas内,宽高为图片大小 - // ctx.drawImage(convertpath, 0, 0, res.width, res.height) - // //将声明的时间放入canvas - // ctx.setFontSize(30 * (res.width / 750)) //注意:设置文字大小必须放在填充文字之前,否则不生效 - // ctx.setFillStyle('blue') - // var text = "编号:" + _this.data.form.devcode + "\n经度:" + _this.data.form.longitude + "\n纬度:" + _this.data.form.latitude - // // _this.drawText(ctx,text,20, 70, 5, res.width) - // _this.drawText(ctx, text, 15 * (res.width / 750), 70 * (res.width / 750), 5, res.width) - - // // ctx.fillText(text, 0, 40) - // // ctx.strokeText(_this.data.form.devcode, 0, 30) - // //生成水印图 - // ctx.draw(false, function () { - // wx.canvasToTempFilePath({ - // canvasId: 'firstCanvas', - // success: (res) => { - // wx.compressImage({ - // src: res.tempFilePath, - // quality: 25, - // success: function (res) { - // //上传照片至服务器 - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: res.tempFilePath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // } - // }) - // //// - // } - // }) - // }) - // } - // }) - // } - // }); }, + //删除照片 deletePhoto(event) { var image_index = event.detail.index var fileList_new = this.data.fileList; diff --git a/miniprogram/pages/addDevice/addDevice.wxml b/miniprogram/pages/addDevice/addDevice.wxml index b0977e2..f12c254 100644 --- a/miniprogram/pages/addDevice/addDevice.wxml +++ b/miniprogram/pages/addDevice/addDevice.wxml @@ -5,18 +5,30 @@ - + + + + + + + + + + + + + - - + + - - - + + + @@ -29,13 +41,13 @@ - + - + - + - + @@ -54,8 +66,7 @@ - - + @@ -68,8 +79,8 @@ - - + + - 保存 + 保存 \ No newline at end of file diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.js b/miniprogram/pages/addDevicelog/addDeviceLog.js index cdec71b..a0dc6da 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.js +++ b/miniprogram/pages/addDevicelog/addDeviceLog.js @@ -3,681 +3,665 @@ var app = getApp(); Page({ - /** - * 页面的初始数据 - */ - data: { - pageName: '', - showMask: false, - today: new Date().getTime(), - longitude: '', - latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], - personoption1: [], - projectoption: [], - devcode: "", - deviceMode: "", - installtimeFmt: '', - show: false, - form: { - devcode: "", - wellcode: "", - welltype: "", - welldepth: "", - installheigt: "", - installperson: "", - installtimeFmt: "", - photopath: "", - factory: "", - workmsg: "", - position: "", - description: "", - longitude: "", - latitude: "", - longitude84: "", - latitude84: "", - devicetype: "", - project: "", - area: "", - street: "", - wellname: "" - }, - fileList: [], - detail: "" - }, + /** + * 页面的初始数据 + */ + data: { + pageName: '', + showMask: false, + today: new Date().getTime(), + longitude: '', + latitude: '', + option1: [], + personoption1: [], + projectoption: [], + devcode: "", + deviceMode: "", + installtimeFmt: '', + show: false, + form: { + devcode: "", + wellcode: "", + welltype: "", + welldepth: "", + installheigt: "", + installperson: "", + installtimeFmt: "", + photopath: "", + factory: "", + workmsg: "", + position: "", + description: "", + longitude: "", + latitude: "", + longitude84: "", + latitude84: "", + devicetype: "", + project: "", + area: "", + street: "", + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '' + }, + fileList: [], + detail: "", + markers: [{ + id: 100, + // iconPath: "../../images/point.png", + latitude: '', + longitude: '', + // label:'1', + width: 25, + height: 35 + }], + }, - onDisplay() { - this.setData({ - show: true - }); - }, - onClose() { - this.setData({ - show: false - }); - }, - formatDate() { - var date = new Date(); - // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; - var seperator1 = "-"; - var month = date.getMonth() + 1; - var strDate = date.getDate(); - var hour = date.getHours() - var minute = date.getMinutes() - var second = date.getSeconds() - month = month > 9 ? month : "0" + month; - strDate = strDate > 9 ? strDate : "0" + strDate; - hour = hour > 9 ? hour : "0" + hour; - minute = minute > 9 ? minute : "0" + minute; - second = second > 9 ? second : "0" + second; - var currentdate = - date.getFullYear() + - seperator1 + - month + - seperator1 + - strDate + - " " + - hour + ":" + - minute + ":" + - second; - return currentdate; + onDisplay() { + this.setData({ + show: true + }); + }, + onClose() { + this.setData({ + show: false + }); + }, + formatDate() { + var date = new Date(); + // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; + var seperator1 = "-"; + var month = date.getMonth() + 1; + var strDate = date.getDate(); + var hour = date.getHours() + var minute = date.getMinutes() + var second = date.getSeconds() + month = month > 9 ? month : "0" + month; + strDate = strDate > 9 ? strDate : "0" + strDate; + hour = hour > 9 ? hour : "0" + hour; + minute = minute > 9 ? minute : "0" + minute; + second = second > 9 ? second : "0" + second; + var currentdate = + date.getFullYear() + + seperator1 + + month + + seperator1 + + strDate + + " " + + hour + ":" + + minute + ":" + + second; + return currentdate; - }, - onConfirm(event) { - var installtime = 'form.installtimeFmt'; - this.setData({ - show: false, - installtimeFmt: this.formatDate(event.detail), - [installtime]: this.formatDate(event.detail), - }); - }, + }, + onConfirm(event) { + var installtime = 'form.installtimeFmt'; + this.setData({ + show: false, + installtimeFmt: this.formatDate(event.detail), + [installtime]: this.formatDate(event.detail), + }); + }, - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - var _this = this; - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" - }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); - } - _this.setData({ - personoption1: personArr - }) + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + var _this = this; + _this.setData({ + 'markers[0].latitude': Number(wx.getStorageSync('resultObject').latitude) , + 'markers[0].longitude': Number(wx.getStorageSync('resultObject').longitude), + // 'markers[0].label':'10', + 'markers[0].width': 18, + 'markers[0].id':1, + 'markers[0].height': 30, + latitude:Number(wx.getStorageSync('resultObject').latitude), + longitude:Number(wx.getStorageSync('resultObject').longitude) + }) + //获取人员下拉列表 + // wx.request({ + // method: "POST", + // url: app.globalData.httpsUrl + "deviceType/getUser", + // data:{ + // tips:'repair' + // }, + // header: { + // 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + // }, + // success(res) { + // if (res.data.code == 200) { + // var users = res.data.data + // var personArr = []; + // for (var i = 0; i < users.length; i++) { + // var person = { + // text: users[i].name, + // value: users[i].name + // }; + // personArr.push(person); + // } + // _this.setData({ + // personoption1: personArr + // }) + // } + // } + // }) + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); } - }).catch(err => { - console.error(err); - }) - - - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" - }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - _this.setData({ - projectoption: projectArr - }) - } - }).catch(err => { - console.error(err); - }) - - if (options.pageName) { - this.setData({ - pageName: options.pageName - }) - } - - if (options.detail) { - - var formObject = JSON.parse(options.detail); _this.setData({ - form: formObject, - detail: options.detail + projectoption: projectArr }) - - _this.setData({ - ['form.installperson']: "", - ['form.installtimeFmt']: "", - ['form.workmsg']: "", - ['form.description']: "" - }) - - const { - fileList = [] - } = _this.data; - if (formObject.photopath1 != "") { - var file1 = { - url: app.globalData.url + "static/" + formObject.photopath1 - } - fileList.push(file1) - } - if (formObject.photopath2 != "") { - var file2 = { - url: app.globalData.url + "static/" + formObject.photopath2 - } - fileList.push(file2) - } - if (formObject.photopath3 != "") { - var file3 = { - url: app.globalData.url + "static/" + formObject.photopath3 - } - fileList.push(file3) - } - - _this.setData({ - fileList - }); } - var installtime = 'form.installtimeFmt'; - var dateNow = this.formatDate(); - this.setData({ - installtimeFmt: dateNow, - [installtime]: dateNow, - }); - }, + } + }) - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { + //获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + _this.setData({ + option1: welltypeArr + }) + } + } +}) - }, + //跳转时带入参数返回哪页 + if (options.pageName) { + this.setData({ + pageName: options.pageName + }) + } + //跳转时带入参数设备的安装信息 + if (wx.getStorageSync('resultObject')) { + var formObject = wx.getStorageSync('resultObject') + _this.setData({ + form: formObject, + detail: formObject + }) - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { + _this.setData({ + ['form.installperson']: app.globalData.userName, + ['form.installtimeFmt']: "", + ['form.workmsg']: "", + ['form.description']: "" + }) - }, + const { + fileList = [] + } = _this.data; + if (formObject.photopath1 != "") { + var file1 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath1 + } + fileList.push(file1) + } + if (formObject.photopath2 != "") { + var file2 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath2 + } + fileList.push(file2) + } + if (formObject.photopath3 != "") { + var file3 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath3 + } + fileList.push(file3) + } + _this.setData({ + fileList + }); + } + var installtime = 'form.installtimeFmt'; + var dateNow = this.formatDate(); + this.setData({ + installtimeFmt: dateNow, + [installtime]: dateNow, + }); + }, - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, - }, + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + wx.removeStorageSync('resultObject') + }, - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, - }, + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { + }, - }, + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { + }, - }, + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { + }, - }, + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + }, - /** - * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true - **/ + /** + * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true + **/ - isNumber: function (val) { + isNumber: function (val) { - var regPos = /^[0-9]*$/; //非负浮点数 - var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数 - if (regPos.test(val) || regNeg.test(val)) { - return false; - } else { - return true; - } + var regPos = /^[0-9]*$/; //非负浮点数 + var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数 + if (regPos.test(val) || regNeg.test(val)) { + return false; + } else { + return true; + } - }, + }, - formValidate() { + formValidate() { - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } - if (this.data.form.wellcode == "") { - wx.showToast({ - icon: 'none', - title: '井编号不能为空!', - }) - return false - } - if (this.data.form.devicetype == "") { - wx.showToast({ - icon: 'none', - title: '设备类型不能为空!', - }) - return false - } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + if (this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '设备编号不能为空!', + }) + return false + } + if (this.data.form.wellcode == "") { + wx.showToast({ + icon: 'none', + title: '井编号不能为空!', + }) + return false + } + if (this.data.form.devicetype == "") { + wx.showToast({ + icon: 'none', + title: '设备类型不能为空!', + }) + return false + } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null || - this.data.form.installperson == '') { - wx.showToast({ - icon: 'none', - title: '运维人员不能为空!', - }) - return false - } - if (this.data.form.project == "") { - wx.showToast({ - icon: 'none', - title: '所属项目不能为空!', - }) - return false - } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } + if (this.data.form.installperson == null || + this.data.form.installperson == '') { + wx.showToast({ + icon: 'none', + title: '运维人员不能为空!', + }) + return false + } + if (this.data.form.project == "") { + wx.showToast({ + icon: 'none', + title: '所属项目不能为空!', + }) + return false + } - if (this.data.form.welldepth != null) { - if (this.isNumber(this.data.form.welldepth)) { - wx.showToast({ - icon: 'none', - title: '井深必须为数值!', - }) - return false - } - } - if (this.data.form.installheigt != null) { - if (this.isNumber(this.data.form.installheigt)) { - wx.showToast({ - icon: 'none', - title: '到井口距离必须为数值!', - }) - return false - } - } - - return true; - }, - - changeMsg: function () { - var formNew = this.data.form; - var formOld = JSON.parse(this.data.detail); - var descpNew = ""; - if (formNew.devcode != formOld.devcode) { - descpNew += "修改设备编号,原编号:" + formOld.devcode + ",新编号:" + formNew.devcode + ";" - } - if (formNew.devicetype != formOld.devicetype) { - descpNew += "修改设备类型,原设备类型:" + formOld.devicetype + ",新设备类型:" + formNew.devicetype + ";" - } - if (formNew.area != formOld.area) { - descpNew += "修改区,原区:" + formOld.area + ",新区:" + formNew.area + ";" - } - if (formNew.street != formOld.street) { - descpNew += "修改街道,原街道:" + formOld.street + ",新街道:" + formNew.street + ";" - } - if (formNew.wellname != formOld.wellname) { - descpNew += "修改井名称,原井名称:" + formOld.wellname + ",新井名称:" + formNew.wellname + ";" - } - if (formNew.factory != formOld.factory) { - descpNew += "修改权属单位,原权属单位:" + formOld.factory + ",新权属单位:" + formNew.factory + ";" - } - if (formNew.installheigt != formOld.installheigt) { - descpNew += "修改井口距离,原井口距离:" + formOld.installheigt + ",新井口距离:" + formNew.installheigt + ";" - } - if (formNew.installperson != formOld.installperson) { - descpNew += "修改运维人员,原运维人员:" + formOld.installperson + ",新运维人员:" + formNew.installperson + ";" - } - if (formNew.latitude != formOld.latitude) { - descpNew += "修改纬度,原纬度:" + formOld.latitude + ",新纬度:" + formNew.latitude + ";" - } - if (formNew.longitude != formOld.longitude) { - descpNew += "修改经度,原经度:" + formOld.longitude + ",新经度:" + formNew.longitude + ";" - } - if (formNew.position != formOld.position) { - descpNew += "修改位置描述,原位置:" + formOld.position + ",新位置:" + formNew.position + ";" - } - if (formNew.wellcode != formOld.wellcode) { - descpNew += "修改井编号,原编号:" + formOld.wellcode + ",新编号:" + formNew.wellcode + ";" - } - if (formNew.welldepth != formOld.welldepth) { - descpNew += "修改井深,原井深:" + formOld.welldepth + ",新井深:" + formNew.welldepth + ";" - } - if (formNew.welltype != formOld.welltype) { - descpNew += "修改井类型,原井类型:" + formOld.welltype + ",新井类型:" + formNew.welltype + ";" - } - if (formNew.project != formOld.project) { - descpNew += "修改所属项目,原项目:" + formOld.project + ",新项目:" + formNew.project + ";" - } - if (this.data.photopath1 != formOld.photopath1 || - this.data.photopath2 != formOld.photopath2 || - this.data.photopath3 != formOld.photopath3) { - descpNew += "修改照片;" - } - if ("" != formNew.description) { - descpNew += formNew.description; - } - this.setData({ - ['form.description']: descpNew + if (this.data.form.welldepth != null) { + if (this.isNumber(this.data.form.welldepth)) { + wx.showToast({ + icon: 'none', + title: '井深必须为数值!', }) - }, + return false + } + } + if (this.data.form.installheigt != null) { + if (this.isNumber(this.data.form.installheigt)) { + wx.showToast({ + icon: 'none', + title: '到井口距离必须为数值!', + }) + return false + } + } - formSubmit: function (event) { + return true; + }, - if (!this.formValidate()) { - return false; - } - this.changeMsg(); - var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDeviceLog', - data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceLog/add" - }, - }).then(res => { - // var resultObj=JSON.parse(res.result); - if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - if (res.confirm) { - wx.switchTab({ - url: that.data.pageName - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) - } - }).catch(err => { - console.error(err) - wx.showToast({ - title: "提交失败", - }) - }) - }, - confirm(event) { - var that = this; - var formValue = event.detail.value; - var formName = event.target.dataset.id; - var fromN = 'form.' + [formName]; - that.setData({ - [fromN]: formValue - }) - }, + //获取与上次修改的信息 + changeMsg: function () { + var formNew = this.data.form; + console.log(this.data.detail) + var formOld = JSON.parse(this.data.detail); + var descpNew = ""; + if (formNew.devcode != formOld.devcode) { + descpNew += "修改设备编号,原值:" + formOld.devcode + ",新值:" + formNew.devcode + ";" + } + if (formNew.devicetype != formOld.devicetype) { + descpNew += "修改设备类型,原值:" + formOld.devicetype + ",新值:" + formNew.devicetype + ";" + } + if (formNew.area != formOld.area) { + descpNew += "修改区,原值:" + formOld.area + ",新值:" + formNew.area + ";" + } + if (formNew.street != formOld.street) { + descpNew += "修改街道,原值:" + formOld.street + ",新值:" + formNew.street + ";" + } + if (formNew.wellname != formOld.wellname) { + descpNew += "修改井名称,原值:" + formOld.wellname + ",新值:" + formNew.wellname + ";" + } + if (formNew.factory != formOld.factory) { + descpNew += "修改权属单位,原值:" + formOld.factory + ",新值:" + formNew.factory + ";" + } + if (formNew.installheigt != formOld.installheigt) { + descpNew += "修改井口距离,原值:" + formOld.installheigt + ",新值:" + formNew.installheigt + ";" + } + if (formNew.installperson != formOld.installperson) { + descpNew += "修改运维人员,原值:" + formOld.installperson + ",新值:" + formNew.installperson + ";" + } + if (formNew.latitude != formOld.latitude) { + descpNew += "修改纬度,原值:" + formOld.latitude + ",新值:" + formNew.latitude + ";" + } + if (formNew.longitude != formOld.longitude) { + descpNew += "修改经度,原值:" + formOld.longitude + ",新值:" + formNew.longitude + ";" + } + if (formNew.position != formOld.position) { + descpNew += "修改位置描述,原值:" + formOld.position + ",新值:" + formNew.position + ";" + } + if (formNew.wellcode != formOld.wellcode) { + descpNew += "修改井编号,原值:" + formOld.wellcode + ",新值:" + formNew.wellcode + ";" + } + if (formNew.welldepth != formOld.welldepth) { + descpNew += "修改井深,原值:" + formOld.welldepth + ",新值:" + formNew.welldepth + ";" + } + if (formNew.welltype != formOld.welltype) { + descpNew += "修改井类型,原值:" + formOld.welltype + ",新值:" + formNew.welltype + ";" + } + if (formNew.project != formOld.project) { + descpNew += "修改所属项目,原值:" + formOld.project + ",新值:" + formNew.project + ";" + } + if (this.data.form.photopath1 != formOld.photopath1 || + this.data.form.photopath2 != formOld.photopath2 || + this.data.form.photopath3 != formOld.photopath3) { + descpNew += "修改照片;" + } + if ("" != formNew.description) { + descpNew += formNew.description; + } + this.setData({ + ['form.description']: descpNew + }) + }, - scan() { + //提交表单 + formSubmit: function (event) { - wx.scanCode({ - success(res) { - console.log(res) - } - }) + //表单验证 + if (!this.formValidate()) { + return false; + } + //自动生成修改内容 + this.changeMsg(); + //提交权限限制(只有施工人员能修改) + if(app.globalData.role!='repair'){ + wx.showToast({ + icon: 'none', + title: '无权限修改', + duration:2000 + }) + return false + } + var that = this; + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopath = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopath]: fileList[i].url.split("static/")[1] + }) + } + delete that.data.form.installtime + delete that.data.form.createtime + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - paste() { - var _this = this; - wx.getClipboardData({ - success: function (res) { - var longitude = 'form.longitude'; - var latitude = 'form.latitude'; - var longitude84 = 'form.longitude84'; - var latitude84 = 'form.latitude84'; - _this.setData({ - [longitude]: parseFloat(res.data.split(",", 4)[1]).toFixed(6), - [latitude]: parseFloat(res.data.split(",", 4)[0]).toFixed(6), - [longitude84]: "" == (res.data.split(",", 4)[3]) ? "" : parseFloat(res.data.split(",", 4)[3]).toFixed(6), - [latitude84]: "" == (res.data.split(",", 4)[2]) ? "" : parseFloat(res.data.split(",", 4)[2]).toFixed(6), - longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), - latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), - }); - } - }) - }, - selectValue(value) { - var that = this; - var wellType = 'form.welltype'; - that.setData({ - [wellType]: value.detail - }) - }, - selectpersonValue(event) { - var that = this; - var installPerson = 'form.installperson'; - that.setData({ - [installPerson]: event.detail - }) - }, - selectprojectValue(event) { - var that = this; - var project = 'form.project'; - that.setData({ - [project]: event.detail, - showMask: true - }) - }, - open() { - this.setData({ - showMask: true - }) - }, - close() { - this.setData({ - showMask: false - }) - }, - afterRead(event) { - var _this = this; - const { - file - } = event.detail; - const { - fileList = [] - } = _this.data; - var convertpath = ""; - wx.compressImage({ - src: event.detail.file.path, - quality: 25, - success: function (res) { - convertpath = res.tempFilePath; - wx.uploadFile({ - url: app.globalData.httpsUrl + "appDeviceAdd/fileUploadMarker", - filePath:convertpath, - name: 'file', - formData: { - 'text': "编号:" + _this.data.form.devcode + "经度:" + _this.data.form.longitude + "纬度:" + _this.data.form.latitude - }, - header: { - "Content-Type": "multipart/form-data", - 'accept': 'application/json', - }, - success(res) { - if (res.data) { - var url = JSON.parse(res.data); - fileList.push({ - ...file, - url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - }); - _this.setData({ - fileList - }); - } - } + success(res) { + if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + if (res.confirm) { + wx.switchTab({ + url: that.data.pageName }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') } - }) - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // // var base64 = "data:image/png;base64," + wx.getFileSystemManager().readFileSync(convertpath, 'base64'); - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: convertpath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // // wx.cloud.callFunction({ - // // name: 'uploadFile', - // // data: { - // // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // // fileBase64: base64 - // // }, - // // success: function (res) { - // // if (res.result) { - // // fileList.push({ - // // ...file, - // // url: app.globalData.url + "static/" + res.result.data.replace(/\\/g, "/") - // // }); - // // _this.setData({ - // // fileList - // // }); - // // } - // // }, - // // complete: res => { - // // }, - // // }) - // } - // }); + } + }) + } + }, + fail(err) { + wx.showToast({ + title: "提交失败", + }) + } + }) + }, + //报存录入的input信息 + confirm(event) { + var that = this; + var formValue = event.detail.value; + var formName = event.target.dataset.id; + var fromN = 'form.' + [formName]; + that.setData({ + [fromN]: formValue + }) + }, + + //扫码 + scan() { + + wx.scanCode({ + success(res) { + console.log(res) + } + }) + }, + //粘贴经纬度 + paste() { + var _this = this; + wx.getClipboardData({ + success: function (res) { + var longitude = 'form.longitude'; + var latitude = 'form.latitude'; + var longitude84 = 'form.longitude84'; + var latitude84 = 'form.latitude84'; + _this.setData({ + [longitude]: parseFloat(res.data.split(",", 4)[1]).toFixed(6), + [latitude]: parseFloat(res.data.split(",", 4)[0]).toFixed(6), + [longitude84]: "" == (res.data.split(",", 4)[3]) ? "" : parseFloat(res.data.split(",", 4)[3]).toFixed(6), + [latitude84]: "" == (res.data.split(",", 4)[2]) ? "" : parseFloat(res.data.split(",", 4)[2]).toFixed(6), + longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), + latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), + }); + } + }) + }, + selectValue(value) { + var that = this; + var wellType = 'form.welltype'; + that.setData({ + [wellType]: value.detail + }) + }, + //运维人员默认为登录人 + // selectpersonValue(event) { + // var that = this; + // var installPerson = 'form.installperson'; + // that.setData({ + // [installPerson]: event.detail + // }) + // }, + selectprojectValue(event) { + var that = this; + var project = 'form.project'; + that.setData({ + [project]: event.detail, + showMask: true + }) + }, + + open() { + this.setData({ + showMask: true + }) + }, + //隐藏textarea,防止遮挡 + close() { + this.setData({ + showMask: false + }) + }, + //上传照片 + afterRead(event) { + var _this = this; + const { + file + } = event.detail; + const { + fileList = [] + } = _this.data; + var convertpath = ""; + wx.compressImage({ + src: event.detail.file.path, + quality: 25, + success: function (res) { + convertpath = res.tempFilePath; + wx.uploadFile({ + url: app.globalData.httpsUrl + "appDeviceAdd/fileUploadMarker", + filePath: convertpath, + name: 'file', + formData: { + 'text': "编号:" + _this.data.form.devcode + "经度:" + _this.data.form.longitude + "纬度:" + _this.data.form.latitude }, - deletePhoto(event) { - var that = this - var image_index = event.detail.index - var fileList_new = that.data.fileList; - wx.showModal({ - content: '确定删除照片?', - success: function (res) { - if (res.confirm) { - fileList_new.splice(image_index, 1); - that.setData({ - fileList: fileList_new - }) - wx.cloud.callFunction({ - name: 'deletePhoto', - data: { - url: app.globalData.url + "appDeviceLog/deletePhoto", - devcode: that.data.form.devcode, - pathIndex: image_index - }, - success: function (res) {}, - complete: res => {}, - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + "Content-Type": "multipart/form-data", + 'accept': 'application/json', }, - }) \ No newline at end of file + success(res) { + if (res.data) { + var url = JSON.parse(res.data); + fileList.push({ + ...file, + url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") + }); + _this.setData({ + fileList + }); + } + } + }) + } + }) + }, + //删除照片 + deletePhoto(event) { + var that = this + var image_index = event.detail.index + var fileList_new = that.data.fileList; + wx.showModal({ + content: '确定删除照片?', + success: function (res) { + if (res.confirm) { + fileList_new.splice(image_index, 1); + that.setData({ + fileList: fileList_new + }) + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deletePhoto", + data: { + devcode: that.data.form.devcode + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) {} + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } +}) \ No newline at end of file diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.wxml b/miniprogram/pages/addDevicelog/addDeviceLog.wxml index 38620d4..b10cc7d 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.wxml +++ b/miniprogram/pages/addDevicelog/addDeviceLog.wxml @@ -1,15 +1,21 @@ - + + + + + - + - - + + - - + + - + @@ -39,24 +45,25 @@ - - - + + + - + - + + @@ -64,7 +71,7 @@ - + @@ -79,9 +86,9 @@ - + - 保存 + 保存 diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.wxss b/miniprogram/pages/addDevicelog/addDeviceLog.wxss index ee0b75c..08d5fd7 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.wxss +++ b/miniprogram/pages/addDevicelog/addDeviceLog.wxss @@ -24,6 +24,17 @@ display: flex; align-items: center; } +.map-view{ + width: 750rpx; + height: 485rpx; + position: fixed; + top: 0px; + left: 0px; + z-index: 999; +} +.content{ + margin-top: 495rpx; +} .left { width: 210rpx; diff --git a/miniprogram/pages/addFunction/addFunction.js b/miniprogram/pages/addFunction/addFunction.js deleted file mode 100644 index 4966be3..0000000 --- a/miniprogram/pages/addFunction/addFunction.js +++ /dev/null @@ -1,60 +0,0 @@ -// pages/addFunction/addFunction.js - -const code = `// 云函数入口函数 -exports.main = (event, context) => { - console.log(event) - console.log(context) - return { - sum: event.a + event.b - } -}` - -Page({ - - data: { - result: '', - canIUseClipboard: wx.canIUse('setClipboardData'), - }, - - onLoad: function (options) { - - }, - - copyCode: function() { - wx.setClipboardData({ - data: code, - success: function () { - wx.showToast({ - title: '复制成功', - }) - } - }) - }, - - testFunction() { - wx.cloud.callFunction({ - name: 'sum', - data: { - a: 1, - b: 2 - }, - success: res => { - wx.showToast({ - title: '调用成功', - }) - this.setData({ - result: JSON.stringify(res.result) - }) - }, - fail: err => { - wx.showToast({ - icon: 'none', - title: '调用失败', - }) - console.error('[云函数] [sum] 调用失败:', err) - } - }) - }, - -}) - diff --git a/miniprogram/pages/addFunction/addFunction.json b/miniprogram/pages/addFunction/addFunction.json deleted file mode 100644 index a9a50c5..0000000 --- a/miniprogram/pages/addFunction/addFunction.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "navigationBarTitleText": "云函数指引", - "usingComponents": {} -} \ No newline at end of file diff --git a/miniprogram/pages/addFunction/addFunction.wxml b/miniprogram/pages/addFunction/addFunction.wxml deleted file mode 100644 index 3a10626..0000000 --- a/miniprogram/pages/addFunction/addFunction.wxml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - 测试云函数 - - - 期望输出:{"sum":3} - - - 调用结果:{{result}} - - - - - 新增云函数 - 1. 在云函数根目录 cloudfunctions 上右键选择新建云函数,命名为 sum - 2. 在创建的 cloudfunctions/sum/index.js 文件中添加如下代码 - - - 3. 在 cloudfunctions/sum 目录上右键上传并部署 - 4. 点击测试云函数测试 - 5. 打开云开发云函数管理页,选择 sum 云函数 - 6. 查看 sum 的调用日志 - 进阶:可在云函数中使用 wx-server-sdk 操作数据库,文件存储和调用其他云函数,详见文档 - - - diff --git a/miniprogram/pages/addFunction/addFunction.wxss b/miniprogram/pages/addFunction/addFunction.wxss deleted file mode 100644 index 7ac8619..0000000 --- a/miniprogram/pages/addFunction/addFunction.wxss +++ /dev/null @@ -1,3 +0,0 @@ -/* pages/addFunction/addFunction.wxss */ - -@import "../../style/guide.wxss"; \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.js b/miniprogram/pages/applog/applog.js index 0e8c185..189e61f 100644 --- a/miniprogram/pages/applog/applog.js +++ b/miniprogram/pages/applog/applog.js @@ -13,98 +13,25 @@ isSeach: "false", params: {}, total: 0, - show: false + show: false, + delBtnWidth: 100, //删除按钮宽度单位(rpx) + activeIndex: -1, + list_style: '' }, - - touchE: function (e) { - // console.log(e); - var that = this - if (e.changedTouches.length == 1) { - //手指移动结束后触摸点位置的X坐标 - var endX = e.changedTouches[0].clientX; - //触摸开始与结束,手指移动的距离 - var disX = that.data.startX - endX; - var delBtnWidth = that.data.delBtnWidth; - //如果距离小于删除按钮的1/2,不显示删除按钮 - var txtStyle = disX > delBtnWidth / 2 ? "left:-" + delBtnWidth + "rpx" : "left:0rpx"; - - //获取手指触摸的是哪一项 - var index = e.currentTarget.dataset.index; - var list = that.data.deviceloglist; - list[index].txtStyle = txtStyle; - //更新列表的状态 - that.setData({ - deviceloglist: list - }); - } - }, - //手指触摸动作开始 记录起点X坐标 - touchstart: function (e) { - //开始触摸时 重置所有删除 - this.data.deviceloglist.forEach(function (v, i) { - if (v.isTouchMove) //只操作为true的 - v.isTouchMove = false; - }) - this.setData({ - startX: e.changedTouches[0].clientX, - startY: e.changedTouches[0].clientY, - deviceloglist: this.data.deviceloglist - }) - }, - //滑动事件处理 - touchmove: function (e) { - var that = this, - index = e.currentTarget.dataset.index, //当前索引 - startX = that.data.startX, //开始X坐标 - startY = that.data.startY, //开始Y坐标 - touchMoveX = e.changedTouches[0].clientX, //滑动变化坐标 - touchMoveY = e.changedTouches[0].clientY, //滑动变化坐标 - //获取滑动角度 - angle = that.angle({ - X: startX, - Y: startY - }, { - X: touchMoveX, - Y: touchMoveY - }); - that.data.deviceloglist.forEach(function (v, i) { - v.isTouchMove = false - //滑动超过30度角 return - if (Math.abs(angle) > 30) return; - if (i == index) { - if (touchMoveX > startX) //右滑 - v.isTouchMove = false - else //左滑 - v.isTouchMove = true - } - }) - //更新数据 - that.setData({ - deviceloglist: that.data.deviceloglist - }) - }, - /** - * 计算滑动角度 - * @param {Object} start 起点坐标 - * @param {Object} end 终点坐标 - */ - angle: function (start, end) { - var _X = end.X - start.X, - _Y = end.Y - start.Y - //返回角度 /Math.atan()返回数字的反正切值 - return 360 * Math.atan(_Y / _X) / (2 * Math.PI); - }, - /** - * 生命周期函数--监听页面加载var_this=this; - */ onLoad: function (options) { - if (options.params) { this.setData({ params: JSON.parse(options.params), isSeach: "true" }) this.initPages() + }else{ + this.setData({ + show: false + }) + //清空参数,重新加载 + this.clearParams(); + this.initPages(); } }, @@ -116,20 +43,33 @@ }, + //点击tabBar事件 + onTabItemTap(item) { + //隐藏历史显示总记录条数 + this.setData({ + show: false + }) + //清空参数,重新加载 + this.clearParams(); + this.initPages(); + }, + + /** * 生命周期函数--监听页面显示 */ onShow: function (options) { - this.setData({ - show:false - }) - if (this.data.isSeach == "false") { - this.clearParams(); - this.initPages(); - } - this.setData({ - isSeach: "false" - }) + + // this.setData({ + // show: false + // }) + // if (this.data.isSeach == "false") { + // this.clearParams(); + // this.initPages(); + // } + // this.setData({ + // isSeach: "false" + // }) }, /** @@ -167,6 +107,119 @@ }, + + //手指触摸动作开始 记录起点X坐标 + touchstart: function (e) { + //开始触摸时 重置所有删除 + this.data.deviceloglist.forEach(function (v, i) { + if (v.isTouchMove) //只操作为true的 + v.isTouchMove = false; + }) + this.setData({ + startX: e.changedTouches[0].clientX, + startY: e.changedTouches[0].clientY, + deviceloglist: this.data.deviceloglist + }) + }, + + //滑动事件处理 + touchmove: function (e) { + var that = this, + index = e.currentTarget.dataset.index, //当前索引 + startX = that.data.startX, //开始X坐标 + startY = that.data.startY, //开始Y坐标 + touchMoveX = e.changedTouches[0].clientX, //滑动变化坐标 + touchMoveY = e.changedTouches[0].clientY, //滑动变化坐标 + //获取滑动角度 + angle = that.angle({ + X: startX, + Y: startY + }, { + X: touchMoveX, + Y: touchMoveY + }); + that.data.deviceloglist.forEach(function (v, i) { + // v.isTouchMove = false + //滑动超过30度角 return + if (Math.abs(angle) > 30) return; + if (i == index) { + if (touchMoveX > startX) //右滑 + v.isTouchMove = false + else //左滑 + v.isTouchMove = true + } + }) + //更新数据 + that.setData({ + deviceloglist: that.data.deviceloglist + }) + }, + + /** + * 计算滑动角度 + * @param {Object} start 起点坐标 + * @param {Object} end 终点坐标 + */ + angle: function (start, end) { + var _X = end.X - start.X, + _Y = end.Y - start.Y + //返回角度 /Math.atan()返回数字的反正切值 + return 360 * Math.atan(_Y / _X) / (2 * Math.PI); + }, + + //删除事件 + delItem: function (e) { + if(app.globalData.role!='repair'){ + wx.showToast({ + icon: 'none', + title: '无权限删除', + duration:2000 + }) + return false + } + var that = this + wx.showModal({ + content: '是否删除?', + success: function (res) { + if (res.confirm) { + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/delete", + data: { + appDeviceAddId: e.currentTarget.dataset.devid + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if(res.data.code=='200'){ + that.data.deviceloglist.splice(e.currentTarget.dataset.index, 1) + that.setData({ + deviceloglist: that.data.deviceloglist, + total: that.data.deviceloglist.length + }) + wx.showToast({ + title: '删除成功!', + icon: 'none', + duration: 1000 + }) + } + }, + fail(err) { + wx.showToast({ + title: '删除失败!', + icon: 'none', + duration: 2000 + }) + } + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + }, + showLoading: function (message) { if (wx.showLoading) { // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 @@ -199,95 +252,105 @@ deviceloglist: [] }) }, + //查询列表数据 initPages: function () { var that = this + that.setData({ + show: false + }) var offsetValue = that.data.deviceloglist.length % 15 > 0 ? parseInt(that.data.deviceloglist.length / 15) + 2 : parseInt(that.data.deviceloglist.length / 15) + 1 - wx.cloud.callFunction({ - name: 'devicelog', + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/listPage", data: { devcode: that.data.params.devcode, devtype: that.data.params.devtype, installtimeFmt: that.data.params.installtimeFmt, project: that.data.params.project, installPerson: that.data.params.installPerson, - url: app.globalData.url + "appDeviceLog/listPage", limit: 15, offset: offsetValue }, - }).then(res => { - if (res.result.data.rows.length > 0) { - var resultJson = res.result - that.setData({ - deviceloglist: that.data.deviceloglist.concat(resultJson.data.rows) - }) - } else if (that.data.deviceloglist.length > 0) { - that.setData({ - show: true, - total: that.data.deviceloglist.length - }) - wx.showToast({ - title: '数据已全部加载完', - icon: 'none', - duration: 2000 - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.data.rows.length > 0) { + var resultJson = res.data + var listArr = resultJson.data.rows + listArr.forEach(function (v, i) { + listArr[i]['isTouchMove'] = false + }) + that.setData({ + deviceloglist: that.data.deviceloglist.concat(listArr) + }) + } else if (that.data.deviceloglist.length > 0) { + that.setData({ + show: true, + total: that.data.deviceloglist.length + }) + wx.showToast({ + title: '数据已全部加载完', + icon: 'none', + duration: 2000 + }) + } + if (offsetValue == 1 && res.data.data.rows.length < 15) { + that.setData({ + show: true, + total: that.data.deviceloglist.length + }) + } } - if(offsetValue==1&&res.result.data.rows.length<15){ - that.setData({ - show: true, - total: that.data.deviceloglist.length - }) - } - // console.log(res); - }).catch(err => { - console.error(err); }) + }, addDetail: function (event) { - this.showLoading("数据请求中..."); - wx.cloud.callFunction({ - name: 'deviceDetail', + var that = this + that.showLoading("数据请求中..."); + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deviceDetail", data: { devcode: event.target.dataset.devcode, - url: app.globalData.url + "appDeviceLog/deviceDetail", }, - }).then(res => { - this.hideLoading(); - var resultObject = JSON.parse(res.result); - var pageName = '../applog/applog' - if (resultObject.code == 200) { - wx.navigateTo({ - url: '../addDevicelog/addDeviceLog?detail=' + - JSON.stringify(resultObject.data) + "&pageName=" + pageName - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + that.hideLoading(); + // var resultObject = JSON.parse(res.data); + var resultObject = res.data; + var pageName = '../applog/applog' + if (resultObject.code == 200) { + wx.setStorageSync('resultObject', resultObject.data) + wx.navigateTo({ + url: '../addDevicelog/addDeviceLog?detail=' + "&pageName=" + pageName + }) + } + }, + fail(err) { + that.hideLoading(); } - }).catch(err => { - this.hideLoading() }) + }, add: function (event) { - wx.reLaunch({ - url: '../earth/earth?devcode=' + event.target.dataset.devcode - // url: '../earth/earth' + app.globalData.devcode = event.target.dataset.devcode; + wx.switchTab({ + url: '../earth/earth' }) + // wx.reLaunch({ + // url: '../earth/earth?devcode=' + event.target.dataset.devcode + // // url: '../earth/earth' + // }) }, onSearch: function () { + var _this = this wx.navigateTo({ - url: '../searchLog/searchLog' + url: '../searchLog/searchLog?params=' + JSON.stringify(_this.data.params) }) - }, - // initPages: function () { - // wx.cloud.callFunction({ - // name: 'devicelog' - // }).then(res => { - // var that = this; - // var jsonList = JSON.parse(res.result) - // that.setData({ - // deviceloglist: jsonList.data.rows - // }) - // console.log(res); - // }).catch(err => { - // console.error(err); - // }) - // } + } }) \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.wxml b/miniprogram/pages/applog/applog.wxml index e9a2352..2bfd041 100644 --- a/miniprogram/pages/applog/applog.wxml +++ b/miniprogram/pages/applog/applog.wxml @@ -1,54 +1,59 @@ - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {{item.devcode}} {{item.devicetype}} + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + {{item.devcode}} {{item.devicetype}} + + {{item.project}} {{item.installtime}}- {{item.installperson}} - - - - - + + + + + + 删除 - - - + + - 共计:{{total}}台 - + 共计:{{total}}台 + \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.wxss b/miniprogram/pages/applog/applog.wxss index 6d3428b..e6e8983 100644 --- a/miniprogram/pages/applog/applog.wxss +++ b/miniprogram/pages/applog/applog.wxss @@ -22,16 +22,18 @@ position: fixed; width: 100%; top: 0rpx; + z-index: 9999; /* margin-bottom: 100rpx; */ } .log-list { /* height: 100rpx; */ - /* display: flex; */ - + display: flex; + width: 100%; padding: 2px; margin-top: 2px; border-bottom: 1px solid #e5e5e5; + overflow: hidden } @@ -53,23 +55,29 @@ left: 35%; margin: 20rpx } - .del { - width: 90px; + /* display: flex; */ + width: 100rpx; display: flex; flex-direction: column; align-items: center; justify-content: center; - color: #fff; - -webkit-transform: translateX(90px); - transform: translateX(90px); - -webkit-transition: all 0.4s; + /* -webkit-transform: translateX(100rpx); */ + transform: translateX(100rpx); + /* -webkit-transition: all 0.4s; */ transition: all 0.4s; - font-size: 35rpx; + color: #fff; + background-color: #fe3e2f; +} +.logrow{ + width: 100%; + transform: translateX(100rpx); + /* -webkit-transform: translateX(100px); */ + margin-left: -100rpx; } -.touch-move-active .content, +.touch-move-active .logrow, .touch-move-active .del { - -webkit-transform: translateX(0); - transform: translateX(0); +/* -webkit-transform: translateX(0); */ +transform: translateX(0); } \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.js b/miniprogram/pages/deployFunctions/deployFunctions.js deleted file mode 100644 index a76b144..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.js +++ /dev/null @@ -1,66 +0,0 @@ -// pages/deployFunctions/deployFunctions.js -Page({ - - /** - * 页面的初始数据 - */ - data: { - - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - - }, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { - - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - - }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { - - }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { - - } -}) \ No newline at end of file diff --git a/cloudfunctions/project.config.json b/cloudfunctions/project.config.json new file mode 100644 index 0000000..2b3119a --- /dev/null +++ b/cloudfunctions/project.config.json @@ -0,0 +1,28 @@ +{ + "appid": "wx2cef527a000f87c9", + "compileType": "miniprogram", + "libVersion": "2.27.3", + "packOptions": { + "ignore": [], + "include": [] + }, + "setting": { + "coverView": true, + "es6": true, + "postcss": true, + "minified": true, + "enhance": true, + "showShadowRootInWxmlPanel": true, + "packNpmRelationList": [], + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + } + }, + "condition": {}, + "editorSetting": { + "tabIndent": "insertSpaces", + "tabSize": 4 + } +} \ No newline at end of file diff --git a/cloudfunctions/project.private.config.json b/cloudfunctions/project.private.config.json new file mode 100644 index 0000000..42ff49d --- /dev/null +++ b/cloudfunctions/project.private.config.json @@ -0,0 +1,7 @@ +{ + "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", + "projectname": "cloudfunctions", + "setting": { + "compileHotReLoad": true + } +} \ No newline at end of file diff --git a/miniprogram/app.js b/miniprogram/app.js index 51d56f3..50a8a54 100644 --- a/miniprogram/app.js +++ b/miniprogram/app.js @@ -18,13 +18,15 @@ // this.globalData = {} }, globalData: { - // url: "http://111.198.10.15:11604/", - httpsUrl: "https://logapi.smartlog.work/", - httpsTestUrl: "https://smartlog.work/prodapi4test/", - url: "http://139.198.18.188:8083/", + httpsUrl: "https://logapi.smartlog.work/", + // httpsUrl: "http://139.198.18.188:8083/", // url: "http://127.0.0.1:8083/", - // httpsUrl: "http://127.0.0.1:8083/", + //httpsUrl: "http://127.0.0.1:8083/", openid: null, - indexCount:1 - }, + indexCount:1, + nickName:"", + userName:"", + role:"", + devcode:"" + } }) diff --git a/miniprogram/app.json b/miniprogram/app.json index d23f798..2b6db76 100644 --- a/miniprogram/app.json +++ b/miniprogram/app.json @@ -1,15 +1,17 @@ { "cloud": true, "pages": [ + "pages/login/login", "pages/indexapp/indexapp", "pages/earth/earth", "pages/applog/applog", "pages/addDevice/addDevice", "pages/addDevicelog/addDeviceLog", - "pages/searchLog/searchLog" + "pages/searchLog/searchLog", + "pages/notice/notice" ], "window": { - "backgroundColor": "#F6F6F6", + "backgroundColor": "#E6D480", "backgroundTextStyle": "light", "navigationBarBackgroundColor": "#FFCF00", "navigationBarTitleText": "智慧施工", @@ -46,11 +48,11 @@ "desc": "你的位置信息将用于小程序位置接口的效果展示" } }, + "requiredPrivateInfos": ["getLocation", "chooseLocation"], "networkTimeout": { "request": 30000, "connectSocket": 30000, "uploadFile": 30000, "downloadFile": 30000 - }, - "style": "v2" + } } \ No newline at end of file diff --git a/miniprogram/images/applocat.png b/miniprogram/images/applocat.png new file mode 100644 index 0000000..fe49f54 --- /dev/null +++ b/miniprogram/images/applocat.png Binary files differ diff --git a/miniprogram/images/back.png b/miniprogram/images/back.png new file mode 100644 index 0000000..32ac82d --- /dev/null +++ b/miniprogram/images/back.png Binary files differ diff --git a/miniprogram/images/bottom.png b/miniprogram/images/bottom.png new file mode 100644 index 0000000..d910e98 --- /dev/null +++ b/miniprogram/images/bottom.png Binary files differ diff --git a/miniprogram/images/header.png b/miniprogram/images/header.png new file mode 100644 index 0000000..6ea222e --- /dev/null +++ b/miniprogram/images/header.png Binary files differ diff --git a/miniprogram/images/login.png b/miniprogram/images/login.png index 8b73cc0..6471c46 100644 --- a/miniprogram/images/login.png +++ b/miniprogram/images/login.png Binary files differ diff --git a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss index 5a591fb..c9c35b5 100644 --- a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss +++ b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:100%;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:100%}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file +@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:650rpx;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:600rpx}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file diff --git a/miniprogram/pages/addDevice/addDevice.js b/miniprogram/pages/addDevice/addDevice.js index 2783674..78f00b7 100644 --- a/miniprogram/pages/addDevice/addDevice.js +++ b/miniprogram/pages/addDevice/addDevice.js @@ -1,5 +1,7 @@ // miniprogram/pages/addDevice/addDevice.js // import WxValidate from '../../utils/WxValidate.js' +var QQMapWX = require('../../libs/qqmap-wx-jssdk.js'); +var qqmapsdk; var app = getApp() Page({ @@ -11,32 +13,10 @@ canvasWidth: '', longitude: '', latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], + option1: [], personoption1: [], projectoption: [], + devtypeList:[], show: false, form: { devcode: "", @@ -59,7 +39,10 @@ project: "", area: "", street: "", - wellname: "" + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '', }, fileList: [] }, @@ -117,12 +100,14 @@ var that = this; //初始化表单内容为上次填写值 var cacheForms = wx.getStorageSync('cacheList') - if (cacheForms) { + cacheForms.photopath1='' + cacheForms.photopath2='' + cacheForms.photopath3='' + that.data.fileList=[] that.setData({ form: cacheForms, devcode: cacheForms.devcode, - }) } var form = that.data.form @@ -155,55 +140,89 @@ } }) + +//获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + that.setData({ + option1: welltypeArr + }) + } + } +}) + + //获取人员下拉列表 - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/getUser", + data:{ + tips:'repair' }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data.code == 200) { + var users = res.data.data + var personArr = []; + for (var i = 0; i < users.length; i++) { + var person = { + text: users[i].name, + value: users[i].name + }; + personArr.push(person); + } + that.setData({ + personoption1: personArr + }) } - that.setData({ - personoption1: personArr - }) } - }).catch(err => { - console.error(err); - }) + }) + - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - that.setData({ - projectoption: projectArr - }) + success(res){ + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); + } + that.setData({ + projectoption: projectArr + }) + } } - }).catch(err => { - console.error(err); - }) + }) + var installtime = 'form.installtimeFmt'; var dateNow = this.formatDate(); this.setData({ @@ -211,8 +230,40 @@ installtimeFmt: dateNow, [installtime]: dateNow, }); + + + + /** + * 获取设备类型下拉列表 + */ + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/deviceType", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var TypeList = res.data.data + var typeArr = []; + for (var i = 0; i < TypeList.length; i++) { + var type = { + text: TypeList[i].productName, + value: TypeList[i].productName + }; + typeArr.push(type); + } + that.setData({ + devtypeList: typeArr + }) + } + } + }) }, + + + /** * 生命周期函数--监听页面初次渲染完成 */ @@ -280,29 +331,7 @@ }, - - //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 - drawText: function (ctx, str, leftWidth, initHeight, titleHeight, canvasWidth) { - var lineWidth = 0; - var lastSubStrIndex = 0; //每次开始截取的字符串的索引 - for (let i = 0; i < str.length; i++) { - lineWidth += ctx.measureText(str[i]).width; - if (lineWidth > canvasWidth) { - ctx.fillText(str.substring(lastSubStrIndex, i), leftWidth, initHeight); //绘制截取部分 - initHeight = initHeight + leftWidth * 2; //22为字体的高度 - lineWidth = 0; - lastSubStrIndex = i; - // titleHeight += 40; - } - if (i == str.length - 1) { //绘制剩余部分 - ctx.fillText(str.substring(lastSubStrIndex, i + 1), leftWidth, initHeight); - } - } - // // 标题border-bottom 线距顶部距离 - // titleHeight = titleHeight + 10; - // return titleHeight - }, - + //验证表单 formValidate() { if (this.data.form.devcode == "") { @@ -312,27 +341,20 @@ }) return false } - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } if (this.data.form.wellcode == "") { wx.showToast({ icon: 'none', @@ -348,22 +370,10 @@ }) return false } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null) { + + if (this.data.form.installperson == "") { wx.showToast({ icon: 'none', title: '安装人员不能为空!', @@ -408,56 +418,90 @@ } return true; }, + //提交表单 formSubmit: function (event) { + console.log(this.data.form) + //表单参数验证 if (!this.formValidate()) { return false; } var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDevice', + //验证设备编号长度 + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/getDevTypeLength", data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceAdd/add" + code: encodeURI(this.data.form.devicetype) }, - }).then(res => { - if (res.result.code == 500) { - wx.showToast({ - title: '设备编号已安装!', - }) - } else if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - //用于回显 - wx.setStorageSync('cacheList', that.data.form) - //提交成功后提示用户操作 - if (res.confirm) { - wx.switchTab({ - url: '../earth/earth' - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (""==res.data.data ||res.data.data == that.data.form.devcode.length) { + that.saveDevice() + } else { //编号位数不对提示 + wx.showToast({ + icon: 'none', + title: '设备编号位数不对!', + duration: 1000 + }) + return false + } } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "提交失败", - }) }) }, + + //保存设备基本信息 + saveDevice() { + var that = this; + //设置照片路径 + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopathForm = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopathForm]: fileList[i].url.split("static/")[1] + }) + } + //表单提交 + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 500) { + wx.showToast({ + title: '设备编号已安装!', + }) + } else if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + //用于回显 + wx.setStorageSync('cacheList', that.data.form) + //提交成功后提示用户操作 + if (res.confirm) { + wx.switchTab({ + url: '../earth/earth' + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } + }, + fail(err) { + wx.showToast({ + title: '提交失败!', + }) + } + }) + }, + + //input 输入框设置值 confirm(event) { var that = this; var formValue = event.detail.value; @@ -466,8 +510,30 @@ that.setData({ [fromN]: formValue }) + //若输入是设备编号,自动获取设备类型 + if('devcode'==formName){ + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", + data: { + devcode: formValue, + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + that.setData({ + [formDevicetype]: res.data + }); + } + } + }) + } }, + //扫描设备获取编号和设备类型 scan() { var _this = this; wx.scanCode({ @@ -477,23 +543,28 @@ _this.setData({ [formdevcode]: devcode }); - wx.cloud.callFunction({ - name: 'findModeCode', + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", data: { devcode: devcode, - url: app.globalData.url + "appDeviceAdd/findModeCodeByCode" }, - }).then(res => { - if (res.result) { - var formDevicetype = 'form.devicetype' - _this.setData({ - [formDevicetype]: res.result - }); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + _this.setData({ + [formDevicetype]: res.data + }); + } } }) } }) }, + //粘贴经纬度 paste() { var _this = this; wx.getClipboardData({ @@ -510,9 +581,11 @@ longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), }); + _this.showAddress(_this.data.form.longitude,_this.data.form.latitude,_this) } }) }, + //设置经类型 selectValue(value) { var that = this; @@ -521,6 +594,16 @@ [wellType]: value.detail }) }, + + //设置设备类型 + selectDevType(event) { + var that = this; + var devtype = 'form.devicetype'; + that.setData({ + [devtype]: event.detail + }) + }, + //设置运维人员 selectpersonValue(event) { var that = this; var installPerson = 'form.installperson'; @@ -528,6 +611,7 @@ [installPerson]: event.detail }) }, + //设置项目 selectprojectValue(event) { var that = this; var project = 'form.project'; @@ -535,8 +619,41 @@ [project]: event.detail }) }, + showAddress :function(longitude, latitude, self) { + // 实例化腾讯地图API核心类 + qqmapsdk = new QQMapWX({ + key: 'BGPBZ-C5O3P-ROUDR-LWC4J-63EKH-V5FRX'//此处使用你自己申请的key + }) + // 腾讯地图调用接口 + qqmapsdk.reverseGeocoder({ + location: { + latitude: latitude, + longitude: longitude + }, + success: function (res) { + self.setData({ + 'form.area':res.result.address.slice(0,res.result.address.indexOf('区')+1), + 'form.street':res.result.address.slice(res.result.address.indexOf('区')+1) + }) + }, + fail: function (res) { + console.log(res); + }, + complete: function (res) { + } + }); + }, + //上传照片 afterRead(event) { var _this = this; + if (_this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '请先填写设备编号!\r\n否则水印中无编号', + duration: 2000 + }) + return false + } const { file } = event.detail; @@ -576,78 +693,8 @@ }) } }) - // 压缩图片 - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // //获取图片尺寸 - // wx.getImageInfo({ - // src: convertpath, - // success(res) { - // _this.setData({ - // canvasHeight: res.height, - // canvasWidth: res.width - // }) - // var ctx = wx.createCanvasContext('firstCanvas') - - // //将图片src放到cancas内,宽高为图片大小 - // ctx.drawImage(convertpath, 0, 0, res.width, res.height) - // //将声明的时间放入canvas - // ctx.setFontSize(30 * (res.width / 750)) //注意:设置文字大小必须放在填充文字之前,否则不生效 - // ctx.setFillStyle('blue') - // var text = "编号:" + _this.data.form.devcode + "\n经度:" + _this.data.form.longitude + "\n纬度:" + _this.data.form.latitude - // // _this.drawText(ctx,text,20, 70, 5, res.width) - // _this.drawText(ctx, text, 15 * (res.width / 750), 70 * (res.width / 750), 5, res.width) - - // // ctx.fillText(text, 0, 40) - // // ctx.strokeText(_this.data.form.devcode, 0, 30) - // //生成水印图 - // ctx.draw(false, function () { - // wx.canvasToTempFilePath({ - // canvasId: 'firstCanvas', - // success: (res) => { - // wx.compressImage({ - // src: res.tempFilePath, - // quality: 25, - // success: function (res) { - // //上传照片至服务器 - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: res.tempFilePath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // } - // }) - // //// - // } - // }) - // }) - // } - // }) - // } - // }); }, + //删除照片 deletePhoto(event) { var image_index = event.detail.index var fileList_new = this.data.fileList; diff --git a/miniprogram/pages/addDevice/addDevice.wxml b/miniprogram/pages/addDevice/addDevice.wxml index b0977e2..f12c254 100644 --- a/miniprogram/pages/addDevice/addDevice.wxml +++ b/miniprogram/pages/addDevice/addDevice.wxml @@ -5,18 +5,30 @@ - + + + + + + + + + + + + + - - + + - - - + + + @@ -29,13 +41,13 @@ - + - + - + - + @@ -54,8 +66,7 @@ - - + @@ -68,8 +79,8 @@ - - + + - 保存 + 保存 \ No newline at end of file diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.js b/miniprogram/pages/addDevicelog/addDeviceLog.js index cdec71b..a0dc6da 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.js +++ b/miniprogram/pages/addDevicelog/addDeviceLog.js @@ -3,681 +3,665 @@ var app = getApp(); Page({ - /** - * 页面的初始数据 - */ - data: { - pageName: '', - showMask: false, - today: new Date().getTime(), - longitude: '', - latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], - personoption1: [], - projectoption: [], - devcode: "", - deviceMode: "", - installtimeFmt: '', - show: false, - form: { - devcode: "", - wellcode: "", - welltype: "", - welldepth: "", - installheigt: "", - installperson: "", - installtimeFmt: "", - photopath: "", - factory: "", - workmsg: "", - position: "", - description: "", - longitude: "", - latitude: "", - longitude84: "", - latitude84: "", - devicetype: "", - project: "", - area: "", - street: "", - wellname: "" - }, - fileList: [], - detail: "" - }, + /** + * 页面的初始数据 + */ + data: { + pageName: '', + showMask: false, + today: new Date().getTime(), + longitude: '', + latitude: '', + option1: [], + personoption1: [], + projectoption: [], + devcode: "", + deviceMode: "", + installtimeFmt: '', + show: false, + form: { + devcode: "", + wellcode: "", + welltype: "", + welldepth: "", + installheigt: "", + installperson: "", + installtimeFmt: "", + photopath: "", + factory: "", + workmsg: "", + position: "", + description: "", + longitude: "", + latitude: "", + longitude84: "", + latitude84: "", + devicetype: "", + project: "", + area: "", + street: "", + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '' + }, + fileList: [], + detail: "", + markers: [{ + id: 100, + // iconPath: "../../images/point.png", + latitude: '', + longitude: '', + // label:'1', + width: 25, + height: 35 + }], + }, - onDisplay() { - this.setData({ - show: true - }); - }, - onClose() { - this.setData({ - show: false - }); - }, - formatDate() { - var date = new Date(); - // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; - var seperator1 = "-"; - var month = date.getMonth() + 1; - var strDate = date.getDate(); - var hour = date.getHours() - var minute = date.getMinutes() - var second = date.getSeconds() - month = month > 9 ? month : "0" + month; - strDate = strDate > 9 ? strDate : "0" + strDate; - hour = hour > 9 ? hour : "0" + hour; - minute = minute > 9 ? minute : "0" + minute; - second = second > 9 ? second : "0" + second; - var currentdate = - date.getFullYear() + - seperator1 + - month + - seperator1 + - strDate + - " " + - hour + ":" + - minute + ":" + - second; - return currentdate; + onDisplay() { + this.setData({ + show: true + }); + }, + onClose() { + this.setData({ + show: false + }); + }, + formatDate() { + var date = new Date(); + // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; + var seperator1 = "-"; + var month = date.getMonth() + 1; + var strDate = date.getDate(); + var hour = date.getHours() + var minute = date.getMinutes() + var second = date.getSeconds() + month = month > 9 ? month : "0" + month; + strDate = strDate > 9 ? strDate : "0" + strDate; + hour = hour > 9 ? hour : "0" + hour; + minute = minute > 9 ? minute : "0" + minute; + second = second > 9 ? second : "0" + second; + var currentdate = + date.getFullYear() + + seperator1 + + month + + seperator1 + + strDate + + " " + + hour + ":" + + minute + ":" + + second; + return currentdate; - }, - onConfirm(event) { - var installtime = 'form.installtimeFmt'; - this.setData({ - show: false, - installtimeFmt: this.formatDate(event.detail), - [installtime]: this.formatDate(event.detail), - }); - }, + }, + onConfirm(event) { + var installtime = 'form.installtimeFmt'; + this.setData({ + show: false, + installtimeFmt: this.formatDate(event.detail), + [installtime]: this.formatDate(event.detail), + }); + }, - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - var _this = this; - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" - }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); - } - _this.setData({ - personoption1: personArr - }) + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + var _this = this; + _this.setData({ + 'markers[0].latitude': Number(wx.getStorageSync('resultObject').latitude) , + 'markers[0].longitude': Number(wx.getStorageSync('resultObject').longitude), + // 'markers[0].label':'10', + 'markers[0].width': 18, + 'markers[0].id':1, + 'markers[0].height': 30, + latitude:Number(wx.getStorageSync('resultObject').latitude), + longitude:Number(wx.getStorageSync('resultObject').longitude) + }) + //获取人员下拉列表 + // wx.request({ + // method: "POST", + // url: app.globalData.httpsUrl + "deviceType/getUser", + // data:{ + // tips:'repair' + // }, + // header: { + // 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + // }, + // success(res) { + // if (res.data.code == 200) { + // var users = res.data.data + // var personArr = []; + // for (var i = 0; i < users.length; i++) { + // var person = { + // text: users[i].name, + // value: users[i].name + // }; + // personArr.push(person); + // } + // _this.setData({ + // personoption1: personArr + // }) + // } + // } + // }) + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); } - }).catch(err => { - console.error(err); - }) - - - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" - }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - _this.setData({ - projectoption: projectArr - }) - } - }).catch(err => { - console.error(err); - }) - - if (options.pageName) { - this.setData({ - pageName: options.pageName - }) - } - - if (options.detail) { - - var formObject = JSON.parse(options.detail); _this.setData({ - form: formObject, - detail: options.detail + projectoption: projectArr }) - - _this.setData({ - ['form.installperson']: "", - ['form.installtimeFmt']: "", - ['form.workmsg']: "", - ['form.description']: "" - }) - - const { - fileList = [] - } = _this.data; - if (formObject.photopath1 != "") { - var file1 = { - url: app.globalData.url + "static/" + formObject.photopath1 - } - fileList.push(file1) - } - if (formObject.photopath2 != "") { - var file2 = { - url: app.globalData.url + "static/" + formObject.photopath2 - } - fileList.push(file2) - } - if (formObject.photopath3 != "") { - var file3 = { - url: app.globalData.url + "static/" + formObject.photopath3 - } - fileList.push(file3) - } - - _this.setData({ - fileList - }); } - var installtime = 'form.installtimeFmt'; - var dateNow = this.formatDate(); - this.setData({ - installtimeFmt: dateNow, - [installtime]: dateNow, - }); - }, + } + }) - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { + //获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + _this.setData({ + option1: welltypeArr + }) + } + } +}) - }, + //跳转时带入参数返回哪页 + if (options.pageName) { + this.setData({ + pageName: options.pageName + }) + } + //跳转时带入参数设备的安装信息 + if (wx.getStorageSync('resultObject')) { + var formObject = wx.getStorageSync('resultObject') + _this.setData({ + form: formObject, + detail: formObject + }) - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { + _this.setData({ + ['form.installperson']: app.globalData.userName, + ['form.installtimeFmt']: "", + ['form.workmsg']: "", + ['form.description']: "" + }) - }, + const { + fileList = [] + } = _this.data; + if (formObject.photopath1 != "") { + var file1 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath1 + } + fileList.push(file1) + } + if (formObject.photopath2 != "") { + var file2 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath2 + } + fileList.push(file2) + } + if (formObject.photopath3 != "") { + var file3 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath3 + } + fileList.push(file3) + } + _this.setData({ + fileList + }); + } + var installtime = 'form.installtimeFmt'; + var dateNow = this.formatDate(); + this.setData({ + installtimeFmt: dateNow, + [installtime]: dateNow, + }); + }, - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, - }, + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + wx.removeStorageSync('resultObject') + }, - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, - }, + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { + }, - }, + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { + }, - }, + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { + }, - }, + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + }, - /** - * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true - **/ + /** + * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true + **/ - isNumber: function (val) { + isNumber: function (val) { - var regPos = /^[0-9]*$/; //非负浮点数 - var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数 - if (regPos.test(val) || regNeg.test(val)) { - return false; - } else { - return true; - } + var regPos = /^[0-9]*$/; //非负浮点数 + var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数 + if (regPos.test(val) || regNeg.test(val)) { + return false; + } else { + return true; + } - }, + }, - formValidate() { + formValidate() { - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } - if (this.data.form.wellcode == "") { - wx.showToast({ - icon: 'none', - title: '井编号不能为空!', - }) - return false - } - if (this.data.form.devicetype == "") { - wx.showToast({ - icon: 'none', - title: '设备类型不能为空!', - }) - return false - } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + if (this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '设备编号不能为空!', + }) + return false + } + if (this.data.form.wellcode == "") { + wx.showToast({ + icon: 'none', + title: '井编号不能为空!', + }) + return false + } + if (this.data.form.devicetype == "") { + wx.showToast({ + icon: 'none', + title: '设备类型不能为空!', + }) + return false + } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null || - this.data.form.installperson == '') { - wx.showToast({ - icon: 'none', - title: '运维人员不能为空!', - }) - return false - } - if (this.data.form.project == "") { - wx.showToast({ - icon: 'none', - title: '所属项目不能为空!', - }) - return false - } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } + if (this.data.form.installperson == null || + this.data.form.installperson == '') { + wx.showToast({ + icon: 'none', + title: '运维人员不能为空!', + }) + return false + } + if (this.data.form.project == "") { + wx.showToast({ + icon: 'none', + title: '所属项目不能为空!', + }) + return false + } - if (this.data.form.welldepth != null) { - if (this.isNumber(this.data.form.welldepth)) { - wx.showToast({ - icon: 'none', - title: '井深必须为数值!', - }) - return false - } - } - if (this.data.form.installheigt != null) { - if (this.isNumber(this.data.form.installheigt)) { - wx.showToast({ - icon: 'none', - title: '到井口距离必须为数值!', - }) - return false - } - } - - return true; - }, - - changeMsg: function () { - var formNew = this.data.form; - var formOld = JSON.parse(this.data.detail); - var descpNew = ""; - if (formNew.devcode != formOld.devcode) { - descpNew += "修改设备编号,原编号:" + formOld.devcode + ",新编号:" + formNew.devcode + ";" - } - if (formNew.devicetype != formOld.devicetype) { - descpNew += "修改设备类型,原设备类型:" + formOld.devicetype + ",新设备类型:" + formNew.devicetype + ";" - } - if (formNew.area != formOld.area) { - descpNew += "修改区,原区:" + formOld.area + ",新区:" + formNew.area + ";" - } - if (formNew.street != formOld.street) { - descpNew += "修改街道,原街道:" + formOld.street + ",新街道:" + formNew.street + ";" - } - if (formNew.wellname != formOld.wellname) { - descpNew += "修改井名称,原井名称:" + formOld.wellname + ",新井名称:" + formNew.wellname + ";" - } - if (formNew.factory != formOld.factory) { - descpNew += "修改权属单位,原权属单位:" + formOld.factory + ",新权属单位:" + formNew.factory + ";" - } - if (formNew.installheigt != formOld.installheigt) { - descpNew += "修改井口距离,原井口距离:" + formOld.installheigt + ",新井口距离:" + formNew.installheigt + ";" - } - if (formNew.installperson != formOld.installperson) { - descpNew += "修改运维人员,原运维人员:" + formOld.installperson + ",新运维人员:" + formNew.installperson + ";" - } - if (formNew.latitude != formOld.latitude) { - descpNew += "修改纬度,原纬度:" + formOld.latitude + ",新纬度:" + formNew.latitude + ";" - } - if (formNew.longitude != formOld.longitude) { - descpNew += "修改经度,原经度:" + formOld.longitude + ",新经度:" + formNew.longitude + ";" - } - if (formNew.position != formOld.position) { - descpNew += "修改位置描述,原位置:" + formOld.position + ",新位置:" + formNew.position + ";" - } - if (formNew.wellcode != formOld.wellcode) { - descpNew += "修改井编号,原编号:" + formOld.wellcode + ",新编号:" + formNew.wellcode + ";" - } - if (formNew.welldepth != formOld.welldepth) { - descpNew += "修改井深,原井深:" + formOld.welldepth + ",新井深:" + formNew.welldepth + ";" - } - if (formNew.welltype != formOld.welltype) { - descpNew += "修改井类型,原井类型:" + formOld.welltype + ",新井类型:" + formNew.welltype + ";" - } - if (formNew.project != formOld.project) { - descpNew += "修改所属项目,原项目:" + formOld.project + ",新项目:" + formNew.project + ";" - } - if (this.data.photopath1 != formOld.photopath1 || - this.data.photopath2 != formOld.photopath2 || - this.data.photopath3 != formOld.photopath3) { - descpNew += "修改照片;" - } - if ("" != formNew.description) { - descpNew += formNew.description; - } - this.setData({ - ['form.description']: descpNew + if (this.data.form.welldepth != null) { + if (this.isNumber(this.data.form.welldepth)) { + wx.showToast({ + icon: 'none', + title: '井深必须为数值!', }) - }, + return false + } + } + if (this.data.form.installheigt != null) { + if (this.isNumber(this.data.form.installheigt)) { + wx.showToast({ + icon: 'none', + title: '到井口距离必须为数值!', + }) + return false + } + } - formSubmit: function (event) { + return true; + }, - if (!this.formValidate()) { - return false; - } - this.changeMsg(); - var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDeviceLog', - data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceLog/add" - }, - }).then(res => { - // var resultObj=JSON.parse(res.result); - if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - if (res.confirm) { - wx.switchTab({ - url: that.data.pageName - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) - } - }).catch(err => { - console.error(err) - wx.showToast({ - title: "提交失败", - }) - }) - }, - confirm(event) { - var that = this; - var formValue = event.detail.value; - var formName = event.target.dataset.id; - var fromN = 'form.' + [formName]; - that.setData({ - [fromN]: formValue - }) - }, + //获取与上次修改的信息 + changeMsg: function () { + var formNew = this.data.form; + console.log(this.data.detail) + var formOld = JSON.parse(this.data.detail); + var descpNew = ""; + if (formNew.devcode != formOld.devcode) { + descpNew += "修改设备编号,原值:" + formOld.devcode + ",新值:" + formNew.devcode + ";" + } + if (formNew.devicetype != formOld.devicetype) { + descpNew += "修改设备类型,原值:" + formOld.devicetype + ",新值:" + formNew.devicetype + ";" + } + if (formNew.area != formOld.area) { + descpNew += "修改区,原值:" + formOld.area + ",新值:" + formNew.area + ";" + } + if (formNew.street != formOld.street) { + descpNew += "修改街道,原值:" + formOld.street + ",新值:" + formNew.street + ";" + } + if (formNew.wellname != formOld.wellname) { + descpNew += "修改井名称,原值:" + formOld.wellname + ",新值:" + formNew.wellname + ";" + } + if (formNew.factory != formOld.factory) { + descpNew += "修改权属单位,原值:" + formOld.factory + ",新值:" + formNew.factory + ";" + } + if (formNew.installheigt != formOld.installheigt) { + descpNew += "修改井口距离,原值:" + formOld.installheigt + ",新值:" + formNew.installheigt + ";" + } + if (formNew.installperson != formOld.installperson) { + descpNew += "修改运维人员,原值:" + formOld.installperson + ",新值:" + formNew.installperson + ";" + } + if (formNew.latitude != formOld.latitude) { + descpNew += "修改纬度,原值:" + formOld.latitude + ",新值:" + formNew.latitude + ";" + } + if (formNew.longitude != formOld.longitude) { + descpNew += "修改经度,原值:" + formOld.longitude + ",新值:" + formNew.longitude + ";" + } + if (formNew.position != formOld.position) { + descpNew += "修改位置描述,原值:" + formOld.position + ",新值:" + formNew.position + ";" + } + if (formNew.wellcode != formOld.wellcode) { + descpNew += "修改井编号,原值:" + formOld.wellcode + ",新值:" + formNew.wellcode + ";" + } + if (formNew.welldepth != formOld.welldepth) { + descpNew += "修改井深,原值:" + formOld.welldepth + ",新值:" + formNew.welldepth + ";" + } + if (formNew.welltype != formOld.welltype) { + descpNew += "修改井类型,原值:" + formOld.welltype + ",新值:" + formNew.welltype + ";" + } + if (formNew.project != formOld.project) { + descpNew += "修改所属项目,原值:" + formOld.project + ",新值:" + formNew.project + ";" + } + if (this.data.form.photopath1 != formOld.photopath1 || + this.data.form.photopath2 != formOld.photopath2 || + this.data.form.photopath3 != formOld.photopath3) { + descpNew += "修改照片;" + } + if ("" != formNew.description) { + descpNew += formNew.description; + } + this.setData({ + ['form.description']: descpNew + }) + }, - scan() { + //提交表单 + formSubmit: function (event) { - wx.scanCode({ - success(res) { - console.log(res) - } - }) + //表单验证 + if (!this.formValidate()) { + return false; + } + //自动生成修改内容 + this.changeMsg(); + //提交权限限制(只有施工人员能修改) + if(app.globalData.role!='repair'){ + wx.showToast({ + icon: 'none', + title: '无权限修改', + duration:2000 + }) + return false + } + var that = this; + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopath = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopath]: fileList[i].url.split("static/")[1] + }) + } + delete that.data.form.installtime + delete that.data.form.createtime + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - paste() { - var _this = this; - wx.getClipboardData({ - success: function (res) { - var longitude = 'form.longitude'; - var latitude = 'form.latitude'; - var longitude84 = 'form.longitude84'; - var latitude84 = 'form.latitude84'; - _this.setData({ - [longitude]: parseFloat(res.data.split(",", 4)[1]).toFixed(6), - [latitude]: parseFloat(res.data.split(",", 4)[0]).toFixed(6), - [longitude84]: "" == (res.data.split(",", 4)[3]) ? "" : parseFloat(res.data.split(",", 4)[3]).toFixed(6), - [latitude84]: "" == (res.data.split(",", 4)[2]) ? "" : parseFloat(res.data.split(",", 4)[2]).toFixed(6), - longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), - latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), - }); - } - }) - }, - selectValue(value) { - var that = this; - var wellType = 'form.welltype'; - that.setData({ - [wellType]: value.detail - }) - }, - selectpersonValue(event) { - var that = this; - var installPerson = 'form.installperson'; - that.setData({ - [installPerson]: event.detail - }) - }, - selectprojectValue(event) { - var that = this; - var project = 'form.project'; - that.setData({ - [project]: event.detail, - showMask: true - }) - }, - open() { - this.setData({ - showMask: true - }) - }, - close() { - this.setData({ - showMask: false - }) - }, - afterRead(event) { - var _this = this; - const { - file - } = event.detail; - const { - fileList = [] - } = _this.data; - var convertpath = ""; - wx.compressImage({ - src: event.detail.file.path, - quality: 25, - success: function (res) { - convertpath = res.tempFilePath; - wx.uploadFile({ - url: app.globalData.httpsUrl + "appDeviceAdd/fileUploadMarker", - filePath:convertpath, - name: 'file', - formData: { - 'text': "编号:" + _this.data.form.devcode + "经度:" + _this.data.form.longitude + "纬度:" + _this.data.form.latitude - }, - header: { - "Content-Type": "multipart/form-data", - 'accept': 'application/json', - }, - success(res) { - if (res.data) { - var url = JSON.parse(res.data); - fileList.push({ - ...file, - url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - }); - _this.setData({ - fileList - }); - } - } + success(res) { + if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + if (res.confirm) { + wx.switchTab({ + url: that.data.pageName }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') } - }) - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // // var base64 = "data:image/png;base64," + wx.getFileSystemManager().readFileSync(convertpath, 'base64'); - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: convertpath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // // wx.cloud.callFunction({ - // // name: 'uploadFile', - // // data: { - // // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // // fileBase64: base64 - // // }, - // // success: function (res) { - // // if (res.result) { - // // fileList.push({ - // // ...file, - // // url: app.globalData.url + "static/" + res.result.data.replace(/\\/g, "/") - // // }); - // // _this.setData({ - // // fileList - // // }); - // // } - // // }, - // // complete: res => { - // // }, - // // }) - // } - // }); + } + }) + } + }, + fail(err) { + wx.showToast({ + title: "提交失败", + }) + } + }) + }, + //报存录入的input信息 + confirm(event) { + var that = this; + var formValue = event.detail.value; + var formName = event.target.dataset.id; + var fromN = 'form.' + [formName]; + that.setData({ + [fromN]: formValue + }) + }, + + //扫码 + scan() { + + wx.scanCode({ + success(res) { + console.log(res) + } + }) + }, + //粘贴经纬度 + paste() { + var _this = this; + wx.getClipboardData({ + success: function (res) { + var longitude = 'form.longitude'; + var latitude = 'form.latitude'; + var longitude84 = 'form.longitude84'; + var latitude84 = 'form.latitude84'; + _this.setData({ + [longitude]: parseFloat(res.data.split(",", 4)[1]).toFixed(6), + [latitude]: parseFloat(res.data.split(",", 4)[0]).toFixed(6), + [longitude84]: "" == (res.data.split(",", 4)[3]) ? "" : parseFloat(res.data.split(",", 4)[3]).toFixed(6), + [latitude84]: "" == (res.data.split(",", 4)[2]) ? "" : parseFloat(res.data.split(",", 4)[2]).toFixed(6), + longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), + latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), + }); + } + }) + }, + selectValue(value) { + var that = this; + var wellType = 'form.welltype'; + that.setData({ + [wellType]: value.detail + }) + }, + //运维人员默认为登录人 + // selectpersonValue(event) { + // var that = this; + // var installPerson = 'form.installperson'; + // that.setData({ + // [installPerson]: event.detail + // }) + // }, + selectprojectValue(event) { + var that = this; + var project = 'form.project'; + that.setData({ + [project]: event.detail, + showMask: true + }) + }, + + open() { + this.setData({ + showMask: true + }) + }, + //隐藏textarea,防止遮挡 + close() { + this.setData({ + showMask: false + }) + }, + //上传照片 + afterRead(event) { + var _this = this; + const { + file + } = event.detail; + const { + fileList = [] + } = _this.data; + var convertpath = ""; + wx.compressImage({ + src: event.detail.file.path, + quality: 25, + success: function (res) { + convertpath = res.tempFilePath; + wx.uploadFile({ + url: app.globalData.httpsUrl + "appDeviceAdd/fileUploadMarker", + filePath: convertpath, + name: 'file', + formData: { + 'text': "编号:" + _this.data.form.devcode + "经度:" + _this.data.form.longitude + "纬度:" + _this.data.form.latitude }, - deletePhoto(event) { - var that = this - var image_index = event.detail.index - var fileList_new = that.data.fileList; - wx.showModal({ - content: '确定删除照片?', - success: function (res) { - if (res.confirm) { - fileList_new.splice(image_index, 1); - that.setData({ - fileList: fileList_new - }) - wx.cloud.callFunction({ - name: 'deletePhoto', - data: { - url: app.globalData.url + "appDeviceLog/deletePhoto", - devcode: that.data.form.devcode, - pathIndex: image_index - }, - success: function (res) {}, - complete: res => {}, - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + "Content-Type": "multipart/form-data", + 'accept': 'application/json', }, - }) \ No newline at end of file + success(res) { + if (res.data) { + var url = JSON.parse(res.data); + fileList.push({ + ...file, + url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") + }); + _this.setData({ + fileList + }); + } + } + }) + } + }) + }, + //删除照片 + deletePhoto(event) { + var that = this + var image_index = event.detail.index + var fileList_new = that.data.fileList; + wx.showModal({ + content: '确定删除照片?', + success: function (res) { + if (res.confirm) { + fileList_new.splice(image_index, 1); + that.setData({ + fileList: fileList_new + }) + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deletePhoto", + data: { + devcode: that.data.form.devcode + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) {} + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } +}) \ No newline at end of file diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.wxml b/miniprogram/pages/addDevicelog/addDeviceLog.wxml index 38620d4..b10cc7d 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.wxml +++ b/miniprogram/pages/addDevicelog/addDeviceLog.wxml @@ -1,15 +1,21 @@ - + + + + + - + - - + + - - + + - + @@ -39,24 +45,25 @@ - - - + + + - + - + + @@ -64,7 +71,7 @@ - + @@ -79,9 +86,9 @@ - + - 保存 + 保存 diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.wxss b/miniprogram/pages/addDevicelog/addDeviceLog.wxss index ee0b75c..08d5fd7 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.wxss +++ b/miniprogram/pages/addDevicelog/addDeviceLog.wxss @@ -24,6 +24,17 @@ display: flex; align-items: center; } +.map-view{ + width: 750rpx; + height: 485rpx; + position: fixed; + top: 0px; + left: 0px; + z-index: 999; +} +.content{ + margin-top: 495rpx; +} .left { width: 210rpx; diff --git a/miniprogram/pages/addFunction/addFunction.js b/miniprogram/pages/addFunction/addFunction.js deleted file mode 100644 index 4966be3..0000000 --- a/miniprogram/pages/addFunction/addFunction.js +++ /dev/null @@ -1,60 +0,0 @@ -// pages/addFunction/addFunction.js - -const code = `// 云函数入口函数 -exports.main = (event, context) => { - console.log(event) - console.log(context) - return { - sum: event.a + event.b - } -}` - -Page({ - - data: { - result: '', - canIUseClipboard: wx.canIUse('setClipboardData'), - }, - - onLoad: function (options) { - - }, - - copyCode: function() { - wx.setClipboardData({ - data: code, - success: function () { - wx.showToast({ - title: '复制成功', - }) - } - }) - }, - - testFunction() { - wx.cloud.callFunction({ - name: 'sum', - data: { - a: 1, - b: 2 - }, - success: res => { - wx.showToast({ - title: '调用成功', - }) - this.setData({ - result: JSON.stringify(res.result) - }) - }, - fail: err => { - wx.showToast({ - icon: 'none', - title: '调用失败', - }) - console.error('[云函数] [sum] 调用失败:', err) - } - }) - }, - -}) - diff --git a/miniprogram/pages/addFunction/addFunction.json b/miniprogram/pages/addFunction/addFunction.json deleted file mode 100644 index a9a50c5..0000000 --- a/miniprogram/pages/addFunction/addFunction.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "navigationBarTitleText": "云函数指引", - "usingComponents": {} -} \ No newline at end of file diff --git a/miniprogram/pages/addFunction/addFunction.wxml b/miniprogram/pages/addFunction/addFunction.wxml deleted file mode 100644 index 3a10626..0000000 --- a/miniprogram/pages/addFunction/addFunction.wxml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - 测试云函数 - - - 期望输出:{"sum":3} - - - 调用结果:{{result}} - - - - - 新增云函数 - 1. 在云函数根目录 cloudfunctions 上右键选择新建云函数,命名为 sum - 2. 在创建的 cloudfunctions/sum/index.js 文件中添加如下代码 - - - 3. 在 cloudfunctions/sum 目录上右键上传并部署 - 4. 点击测试云函数测试 - 5. 打开云开发云函数管理页,选择 sum 云函数 - 6. 查看 sum 的调用日志 - 进阶:可在云函数中使用 wx-server-sdk 操作数据库,文件存储和调用其他云函数,详见文档 - - - diff --git a/miniprogram/pages/addFunction/addFunction.wxss b/miniprogram/pages/addFunction/addFunction.wxss deleted file mode 100644 index 7ac8619..0000000 --- a/miniprogram/pages/addFunction/addFunction.wxss +++ /dev/null @@ -1,3 +0,0 @@ -/* pages/addFunction/addFunction.wxss */ - -@import "../../style/guide.wxss"; \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.js b/miniprogram/pages/applog/applog.js index 0e8c185..189e61f 100644 --- a/miniprogram/pages/applog/applog.js +++ b/miniprogram/pages/applog/applog.js @@ -13,98 +13,25 @@ isSeach: "false", params: {}, total: 0, - show: false + show: false, + delBtnWidth: 100, //删除按钮宽度单位(rpx) + activeIndex: -1, + list_style: '' }, - - touchE: function (e) { - // console.log(e); - var that = this - if (e.changedTouches.length == 1) { - //手指移动结束后触摸点位置的X坐标 - var endX = e.changedTouches[0].clientX; - //触摸开始与结束,手指移动的距离 - var disX = that.data.startX - endX; - var delBtnWidth = that.data.delBtnWidth; - //如果距离小于删除按钮的1/2,不显示删除按钮 - var txtStyle = disX > delBtnWidth / 2 ? "left:-" + delBtnWidth + "rpx" : "left:0rpx"; - - //获取手指触摸的是哪一项 - var index = e.currentTarget.dataset.index; - var list = that.data.deviceloglist; - list[index].txtStyle = txtStyle; - //更新列表的状态 - that.setData({ - deviceloglist: list - }); - } - }, - //手指触摸动作开始 记录起点X坐标 - touchstart: function (e) { - //开始触摸时 重置所有删除 - this.data.deviceloglist.forEach(function (v, i) { - if (v.isTouchMove) //只操作为true的 - v.isTouchMove = false; - }) - this.setData({ - startX: e.changedTouches[0].clientX, - startY: e.changedTouches[0].clientY, - deviceloglist: this.data.deviceloglist - }) - }, - //滑动事件处理 - touchmove: function (e) { - var that = this, - index = e.currentTarget.dataset.index, //当前索引 - startX = that.data.startX, //开始X坐标 - startY = that.data.startY, //开始Y坐标 - touchMoveX = e.changedTouches[0].clientX, //滑动变化坐标 - touchMoveY = e.changedTouches[0].clientY, //滑动变化坐标 - //获取滑动角度 - angle = that.angle({ - X: startX, - Y: startY - }, { - X: touchMoveX, - Y: touchMoveY - }); - that.data.deviceloglist.forEach(function (v, i) { - v.isTouchMove = false - //滑动超过30度角 return - if (Math.abs(angle) > 30) return; - if (i == index) { - if (touchMoveX > startX) //右滑 - v.isTouchMove = false - else //左滑 - v.isTouchMove = true - } - }) - //更新数据 - that.setData({ - deviceloglist: that.data.deviceloglist - }) - }, - /** - * 计算滑动角度 - * @param {Object} start 起点坐标 - * @param {Object} end 终点坐标 - */ - angle: function (start, end) { - var _X = end.X - start.X, - _Y = end.Y - start.Y - //返回角度 /Math.atan()返回数字的反正切值 - return 360 * Math.atan(_Y / _X) / (2 * Math.PI); - }, - /** - * 生命周期函数--监听页面加载var_this=this; - */ onLoad: function (options) { - if (options.params) { this.setData({ params: JSON.parse(options.params), isSeach: "true" }) this.initPages() + }else{ + this.setData({ + show: false + }) + //清空参数,重新加载 + this.clearParams(); + this.initPages(); } }, @@ -116,20 +43,33 @@ }, + //点击tabBar事件 + onTabItemTap(item) { + //隐藏历史显示总记录条数 + this.setData({ + show: false + }) + //清空参数,重新加载 + this.clearParams(); + this.initPages(); + }, + + /** * 生命周期函数--监听页面显示 */ onShow: function (options) { - this.setData({ - show:false - }) - if (this.data.isSeach == "false") { - this.clearParams(); - this.initPages(); - } - this.setData({ - isSeach: "false" - }) + + // this.setData({ + // show: false + // }) + // if (this.data.isSeach == "false") { + // this.clearParams(); + // this.initPages(); + // } + // this.setData({ + // isSeach: "false" + // }) }, /** @@ -167,6 +107,119 @@ }, + + //手指触摸动作开始 记录起点X坐标 + touchstart: function (e) { + //开始触摸时 重置所有删除 + this.data.deviceloglist.forEach(function (v, i) { + if (v.isTouchMove) //只操作为true的 + v.isTouchMove = false; + }) + this.setData({ + startX: e.changedTouches[0].clientX, + startY: e.changedTouches[0].clientY, + deviceloglist: this.data.deviceloglist + }) + }, + + //滑动事件处理 + touchmove: function (e) { + var that = this, + index = e.currentTarget.dataset.index, //当前索引 + startX = that.data.startX, //开始X坐标 + startY = that.data.startY, //开始Y坐标 + touchMoveX = e.changedTouches[0].clientX, //滑动变化坐标 + touchMoveY = e.changedTouches[0].clientY, //滑动变化坐标 + //获取滑动角度 + angle = that.angle({ + X: startX, + Y: startY + }, { + X: touchMoveX, + Y: touchMoveY + }); + that.data.deviceloglist.forEach(function (v, i) { + // v.isTouchMove = false + //滑动超过30度角 return + if (Math.abs(angle) > 30) return; + if (i == index) { + if (touchMoveX > startX) //右滑 + v.isTouchMove = false + else //左滑 + v.isTouchMove = true + } + }) + //更新数据 + that.setData({ + deviceloglist: that.data.deviceloglist + }) + }, + + /** + * 计算滑动角度 + * @param {Object} start 起点坐标 + * @param {Object} end 终点坐标 + */ + angle: function (start, end) { + var _X = end.X - start.X, + _Y = end.Y - start.Y + //返回角度 /Math.atan()返回数字的反正切值 + return 360 * Math.atan(_Y / _X) / (2 * Math.PI); + }, + + //删除事件 + delItem: function (e) { + if(app.globalData.role!='repair'){ + wx.showToast({ + icon: 'none', + title: '无权限删除', + duration:2000 + }) + return false + } + var that = this + wx.showModal({ + content: '是否删除?', + success: function (res) { + if (res.confirm) { + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/delete", + data: { + appDeviceAddId: e.currentTarget.dataset.devid + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if(res.data.code=='200'){ + that.data.deviceloglist.splice(e.currentTarget.dataset.index, 1) + that.setData({ + deviceloglist: that.data.deviceloglist, + total: that.data.deviceloglist.length + }) + wx.showToast({ + title: '删除成功!', + icon: 'none', + duration: 1000 + }) + } + }, + fail(err) { + wx.showToast({ + title: '删除失败!', + icon: 'none', + duration: 2000 + }) + } + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + }, + showLoading: function (message) { if (wx.showLoading) { // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 @@ -199,95 +252,105 @@ deviceloglist: [] }) }, + //查询列表数据 initPages: function () { var that = this + that.setData({ + show: false + }) var offsetValue = that.data.deviceloglist.length % 15 > 0 ? parseInt(that.data.deviceloglist.length / 15) + 2 : parseInt(that.data.deviceloglist.length / 15) + 1 - wx.cloud.callFunction({ - name: 'devicelog', + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/listPage", data: { devcode: that.data.params.devcode, devtype: that.data.params.devtype, installtimeFmt: that.data.params.installtimeFmt, project: that.data.params.project, installPerson: that.data.params.installPerson, - url: app.globalData.url + "appDeviceLog/listPage", limit: 15, offset: offsetValue }, - }).then(res => { - if (res.result.data.rows.length > 0) { - var resultJson = res.result - that.setData({ - deviceloglist: that.data.deviceloglist.concat(resultJson.data.rows) - }) - } else if (that.data.deviceloglist.length > 0) { - that.setData({ - show: true, - total: that.data.deviceloglist.length - }) - wx.showToast({ - title: '数据已全部加载完', - icon: 'none', - duration: 2000 - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.data.rows.length > 0) { + var resultJson = res.data + var listArr = resultJson.data.rows + listArr.forEach(function (v, i) { + listArr[i]['isTouchMove'] = false + }) + that.setData({ + deviceloglist: that.data.deviceloglist.concat(listArr) + }) + } else if (that.data.deviceloglist.length > 0) { + that.setData({ + show: true, + total: that.data.deviceloglist.length + }) + wx.showToast({ + title: '数据已全部加载完', + icon: 'none', + duration: 2000 + }) + } + if (offsetValue == 1 && res.data.data.rows.length < 15) { + that.setData({ + show: true, + total: that.data.deviceloglist.length + }) + } } - if(offsetValue==1&&res.result.data.rows.length<15){ - that.setData({ - show: true, - total: that.data.deviceloglist.length - }) - } - // console.log(res); - }).catch(err => { - console.error(err); }) + }, addDetail: function (event) { - this.showLoading("数据请求中..."); - wx.cloud.callFunction({ - name: 'deviceDetail', + var that = this + that.showLoading("数据请求中..."); + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deviceDetail", data: { devcode: event.target.dataset.devcode, - url: app.globalData.url + "appDeviceLog/deviceDetail", }, - }).then(res => { - this.hideLoading(); - var resultObject = JSON.parse(res.result); - var pageName = '../applog/applog' - if (resultObject.code == 200) { - wx.navigateTo({ - url: '../addDevicelog/addDeviceLog?detail=' + - JSON.stringify(resultObject.data) + "&pageName=" + pageName - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + that.hideLoading(); + // var resultObject = JSON.parse(res.data); + var resultObject = res.data; + var pageName = '../applog/applog' + if (resultObject.code == 200) { + wx.setStorageSync('resultObject', resultObject.data) + wx.navigateTo({ + url: '../addDevicelog/addDeviceLog?detail=' + "&pageName=" + pageName + }) + } + }, + fail(err) { + that.hideLoading(); } - }).catch(err => { - this.hideLoading() }) + }, add: function (event) { - wx.reLaunch({ - url: '../earth/earth?devcode=' + event.target.dataset.devcode - // url: '../earth/earth' + app.globalData.devcode = event.target.dataset.devcode; + wx.switchTab({ + url: '../earth/earth' }) + // wx.reLaunch({ + // url: '../earth/earth?devcode=' + event.target.dataset.devcode + // // url: '../earth/earth' + // }) }, onSearch: function () { + var _this = this wx.navigateTo({ - url: '../searchLog/searchLog' + url: '../searchLog/searchLog?params=' + JSON.stringify(_this.data.params) }) - }, - // initPages: function () { - // wx.cloud.callFunction({ - // name: 'devicelog' - // }).then(res => { - // var that = this; - // var jsonList = JSON.parse(res.result) - // that.setData({ - // deviceloglist: jsonList.data.rows - // }) - // console.log(res); - // }).catch(err => { - // console.error(err); - // }) - // } + } }) \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.wxml b/miniprogram/pages/applog/applog.wxml index e9a2352..2bfd041 100644 --- a/miniprogram/pages/applog/applog.wxml +++ b/miniprogram/pages/applog/applog.wxml @@ -1,54 +1,59 @@ - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {{item.devcode}} {{item.devicetype}} + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + {{item.devcode}} {{item.devicetype}} + + {{item.project}} {{item.installtime}}- {{item.installperson}} - - - - - + + + + + + 删除 - - - + + - 共计:{{total}}台 - + 共计:{{total}}台 + \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.wxss b/miniprogram/pages/applog/applog.wxss index 6d3428b..e6e8983 100644 --- a/miniprogram/pages/applog/applog.wxss +++ b/miniprogram/pages/applog/applog.wxss @@ -22,16 +22,18 @@ position: fixed; width: 100%; top: 0rpx; + z-index: 9999; /* margin-bottom: 100rpx; */ } .log-list { /* height: 100rpx; */ - /* display: flex; */ - + display: flex; + width: 100%; padding: 2px; margin-top: 2px; border-bottom: 1px solid #e5e5e5; + overflow: hidden } @@ -53,23 +55,29 @@ left: 35%; margin: 20rpx } - .del { - width: 90px; + /* display: flex; */ + width: 100rpx; display: flex; flex-direction: column; align-items: center; justify-content: center; - color: #fff; - -webkit-transform: translateX(90px); - transform: translateX(90px); - -webkit-transition: all 0.4s; + /* -webkit-transform: translateX(100rpx); */ + transform: translateX(100rpx); + /* -webkit-transition: all 0.4s; */ transition: all 0.4s; - font-size: 35rpx; + color: #fff; + background-color: #fe3e2f; +} +.logrow{ + width: 100%; + transform: translateX(100rpx); + /* -webkit-transform: translateX(100px); */ + margin-left: -100rpx; } -.touch-move-active .content, +.touch-move-active .logrow, .touch-move-active .del { - -webkit-transform: translateX(0); - transform: translateX(0); +/* -webkit-transform: translateX(0); */ +transform: translateX(0); } \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.js b/miniprogram/pages/deployFunctions/deployFunctions.js deleted file mode 100644 index a76b144..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.js +++ /dev/null @@ -1,66 +0,0 @@ -// pages/deployFunctions/deployFunctions.js -Page({ - - /** - * 页面的初始数据 - */ - data: { - - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - - }, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { - - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - - }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { - - }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { - - } -}) \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.json b/miniprogram/pages/deployFunctions/deployFunctions.json deleted file mode 100644 index 7fbedab..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "navigationBarTitleText": "部署云函数", - "usingComponents": {} -} \ No newline at end of file diff --git a/cloudfunctions/project.config.json b/cloudfunctions/project.config.json new file mode 100644 index 0000000..2b3119a --- /dev/null +++ b/cloudfunctions/project.config.json @@ -0,0 +1,28 @@ +{ + "appid": "wx2cef527a000f87c9", + "compileType": "miniprogram", + "libVersion": "2.27.3", + "packOptions": { + "ignore": [], + "include": [] + }, + "setting": { + "coverView": true, + "es6": true, + "postcss": true, + "minified": true, + "enhance": true, + "showShadowRootInWxmlPanel": true, + "packNpmRelationList": [], + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + } + }, + "condition": {}, + "editorSetting": { + "tabIndent": "insertSpaces", + "tabSize": 4 + } +} \ No newline at end of file diff --git a/cloudfunctions/project.private.config.json b/cloudfunctions/project.private.config.json new file mode 100644 index 0000000..42ff49d --- /dev/null +++ b/cloudfunctions/project.private.config.json @@ -0,0 +1,7 @@ +{ + "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", + "projectname": "cloudfunctions", + "setting": { + "compileHotReLoad": true + } +} \ No newline at end of file diff --git a/miniprogram/app.js b/miniprogram/app.js index 51d56f3..50a8a54 100644 --- a/miniprogram/app.js +++ b/miniprogram/app.js @@ -18,13 +18,15 @@ // this.globalData = {} }, globalData: { - // url: "http://111.198.10.15:11604/", - httpsUrl: "https://logapi.smartlog.work/", - httpsTestUrl: "https://smartlog.work/prodapi4test/", - url: "http://139.198.18.188:8083/", + httpsUrl: "https://logapi.smartlog.work/", + // httpsUrl: "http://139.198.18.188:8083/", // url: "http://127.0.0.1:8083/", - // httpsUrl: "http://127.0.0.1:8083/", + //httpsUrl: "http://127.0.0.1:8083/", openid: null, - indexCount:1 - }, + indexCount:1, + nickName:"", + userName:"", + role:"", + devcode:"" + } }) diff --git a/miniprogram/app.json b/miniprogram/app.json index d23f798..2b6db76 100644 --- a/miniprogram/app.json +++ b/miniprogram/app.json @@ -1,15 +1,17 @@ { "cloud": true, "pages": [ + "pages/login/login", "pages/indexapp/indexapp", "pages/earth/earth", "pages/applog/applog", "pages/addDevice/addDevice", "pages/addDevicelog/addDeviceLog", - "pages/searchLog/searchLog" + "pages/searchLog/searchLog", + "pages/notice/notice" ], "window": { - "backgroundColor": "#F6F6F6", + "backgroundColor": "#E6D480", "backgroundTextStyle": "light", "navigationBarBackgroundColor": "#FFCF00", "navigationBarTitleText": "智慧施工", @@ -46,11 +48,11 @@ "desc": "你的位置信息将用于小程序位置接口的效果展示" } }, + "requiredPrivateInfos": ["getLocation", "chooseLocation"], "networkTimeout": { "request": 30000, "connectSocket": 30000, "uploadFile": 30000, "downloadFile": 30000 - }, - "style": "v2" + } } \ No newline at end of file diff --git a/miniprogram/images/applocat.png b/miniprogram/images/applocat.png new file mode 100644 index 0000000..fe49f54 --- /dev/null +++ b/miniprogram/images/applocat.png Binary files differ diff --git a/miniprogram/images/back.png b/miniprogram/images/back.png new file mode 100644 index 0000000..32ac82d --- /dev/null +++ b/miniprogram/images/back.png Binary files differ diff --git a/miniprogram/images/bottom.png b/miniprogram/images/bottom.png new file mode 100644 index 0000000..d910e98 --- /dev/null +++ b/miniprogram/images/bottom.png Binary files differ diff --git a/miniprogram/images/header.png b/miniprogram/images/header.png new file mode 100644 index 0000000..6ea222e --- /dev/null +++ b/miniprogram/images/header.png Binary files differ diff --git a/miniprogram/images/login.png b/miniprogram/images/login.png index 8b73cc0..6471c46 100644 --- a/miniprogram/images/login.png +++ b/miniprogram/images/login.png Binary files differ diff --git a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss index 5a591fb..c9c35b5 100644 --- a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss +++ b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:100%;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:100%}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file +@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:650rpx;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:600rpx}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file diff --git a/miniprogram/pages/addDevice/addDevice.js b/miniprogram/pages/addDevice/addDevice.js index 2783674..78f00b7 100644 --- a/miniprogram/pages/addDevice/addDevice.js +++ b/miniprogram/pages/addDevice/addDevice.js @@ -1,5 +1,7 @@ // miniprogram/pages/addDevice/addDevice.js // import WxValidate from '../../utils/WxValidate.js' +var QQMapWX = require('../../libs/qqmap-wx-jssdk.js'); +var qqmapsdk; var app = getApp() Page({ @@ -11,32 +13,10 @@ canvasWidth: '', longitude: '', latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], + option1: [], personoption1: [], projectoption: [], + devtypeList:[], show: false, form: { devcode: "", @@ -59,7 +39,10 @@ project: "", area: "", street: "", - wellname: "" + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '', }, fileList: [] }, @@ -117,12 +100,14 @@ var that = this; //初始化表单内容为上次填写值 var cacheForms = wx.getStorageSync('cacheList') - if (cacheForms) { + cacheForms.photopath1='' + cacheForms.photopath2='' + cacheForms.photopath3='' + that.data.fileList=[] that.setData({ form: cacheForms, devcode: cacheForms.devcode, - }) } var form = that.data.form @@ -155,55 +140,89 @@ } }) + +//获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + that.setData({ + option1: welltypeArr + }) + } + } +}) + + //获取人员下拉列表 - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/getUser", + data:{ + tips:'repair' }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data.code == 200) { + var users = res.data.data + var personArr = []; + for (var i = 0; i < users.length; i++) { + var person = { + text: users[i].name, + value: users[i].name + }; + personArr.push(person); + } + that.setData({ + personoption1: personArr + }) } - that.setData({ - personoption1: personArr - }) } - }).catch(err => { - console.error(err); - }) + }) + - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - that.setData({ - projectoption: projectArr - }) + success(res){ + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); + } + that.setData({ + projectoption: projectArr + }) + } } - }).catch(err => { - console.error(err); - }) + }) + var installtime = 'form.installtimeFmt'; var dateNow = this.formatDate(); this.setData({ @@ -211,8 +230,40 @@ installtimeFmt: dateNow, [installtime]: dateNow, }); + + + + /** + * 获取设备类型下拉列表 + */ + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/deviceType", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var TypeList = res.data.data + var typeArr = []; + for (var i = 0; i < TypeList.length; i++) { + var type = { + text: TypeList[i].productName, + value: TypeList[i].productName + }; + typeArr.push(type); + } + that.setData({ + devtypeList: typeArr + }) + } + } + }) }, + + + /** * 生命周期函数--监听页面初次渲染完成 */ @@ -280,29 +331,7 @@ }, - - //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 - drawText: function (ctx, str, leftWidth, initHeight, titleHeight, canvasWidth) { - var lineWidth = 0; - var lastSubStrIndex = 0; //每次开始截取的字符串的索引 - for (let i = 0; i < str.length; i++) { - lineWidth += ctx.measureText(str[i]).width; - if (lineWidth > canvasWidth) { - ctx.fillText(str.substring(lastSubStrIndex, i), leftWidth, initHeight); //绘制截取部分 - initHeight = initHeight + leftWidth * 2; //22为字体的高度 - lineWidth = 0; - lastSubStrIndex = i; - // titleHeight += 40; - } - if (i == str.length - 1) { //绘制剩余部分 - ctx.fillText(str.substring(lastSubStrIndex, i + 1), leftWidth, initHeight); - } - } - // // 标题border-bottom 线距顶部距离 - // titleHeight = titleHeight + 10; - // return titleHeight - }, - + //验证表单 formValidate() { if (this.data.form.devcode == "") { @@ -312,27 +341,20 @@ }) return false } - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } if (this.data.form.wellcode == "") { wx.showToast({ icon: 'none', @@ -348,22 +370,10 @@ }) return false } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null) { + + if (this.data.form.installperson == "") { wx.showToast({ icon: 'none', title: '安装人员不能为空!', @@ -408,56 +418,90 @@ } return true; }, + //提交表单 formSubmit: function (event) { + console.log(this.data.form) + //表单参数验证 if (!this.formValidate()) { return false; } var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDevice', + //验证设备编号长度 + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/getDevTypeLength", data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceAdd/add" + code: encodeURI(this.data.form.devicetype) }, - }).then(res => { - if (res.result.code == 500) { - wx.showToast({ - title: '设备编号已安装!', - }) - } else if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - //用于回显 - wx.setStorageSync('cacheList', that.data.form) - //提交成功后提示用户操作 - if (res.confirm) { - wx.switchTab({ - url: '../earth/earth' - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (""==res.data.data ||res.data.data == that.data.form.devcode.length) { + that.saveDevice() + } else { //编号位数不对提示 + wx.showToast({ + icon: 'none', + title: '设备编号位数不对!', + duration: 1000 + }) + return false + } } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "提交失败", - }) }) }, + + //保存设备基本信息 + saveDevice() { + var that = this; + //设置照片路径 + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopathForm = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopathForm]: fileList[i].url.split("static/")[1] + }) + } + //表单提交 + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 500) { + wx.showToast({ + title: '设备编号已安装!', + }) + } else if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + //用于回显 + wx.setStorageSync('cacheList', that.data.form) + //提交成功后提示用户操作 + if (res.confirm) { + wx.switchTab({ + url: '../earth/earth' + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } + }, + fail(err) { + wx.showToast({ + title: '提交失败!', + }) + } + }) + }, + + //input 输入框设置值 confirm(event) { var that = this; var formValue = event.detail.value; @@ -466,8 +510,30 @@ that.setData({ [fromN]: formValue }) + //若输入是设备编号,自动获取设备类型 + if('devcode'==formName){ + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", + data: { + devcode: formValue, + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + that.setData({ + [formDevicetype]: res.data + }); + } + } + }) + } }, + //扫描设备获取编号和设备类型 scan() { var _this = this; wx.scanCode({ @@ -477,23 +543,28 @@ _this.setData({ [formdevcode]: devcode }); - wx.cloud.callFunction({ - name: 'findModeCode', + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", data: { devcode: devcode, - url: app.globalData.url + "appDeviceAdd/findModeCodeByCode" }, - }).then(res => { - if (res.result) { - var formDevicetype = 'form.devicetype' - _this.setData({ - [formDevicetype]: res.result - }); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + _this.setData({ + [formDevicetype]: res.data + }); + } } }) } }) }, + //粘贴经纬度 paste() { var _this = this; wx.getClipboardData({ @@ -510,9 +581,11 @@ longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), }); + _this.showAddress(_this.data.form.longitude,_this.data.form.latitude,_this) } }) }, + //设置经类型 selectValue(value) { var that = this; @@ -521,6 +594,16 @@ [wellType]: value.detail }) }, + + //设置设备类型 + selectDevType(event) { + var that = this; + var devtype = 'form.devicetype'; + that.setData({ + [devtype]: event.detail + }) + }, + //设置运维人员 selectpersonValue(event) { var that = this; var installPerson = 'form.installperson'; @@ -528,6 +611,7 @@ [installPerson]: event.detail }) }, + //设置项目 selectprojectValue(event) { var that = this; var project = 'form.project'; @@ -535,8 +619,41 @@ [project]: event.detail }) }, + showAddress :function(longitude, latitude, self) { + // 实例化腾讯地图API核心类 + qqmapsdk = new QQMapWX({ + key: 'BGPBZ-C5O3P-ROUDR-LWC4J-63EKH-V5FRX'//此处使用你自己申请的key + }) + // 腾讯地图调用接口 + qqmapsdk.reverseGeocoder({ + location: { + latitude: latitude, + longitude: longitude + }, + success: function (res) { + self.setData({ + 'form.area':res.result.address.slice(0,res.result.address.indexOf('区')+1), + 'form.street':res.result.address.slice(res.result.address.indexOf('区')+1) + }) + }, + fail: function (res) { + console.log(res); + }, + complete: function (res) { + } + }); + }, + //上传照片 afterRead(event) { var _this = this; + if (_this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '请先填写设备编号!\r\n否则水印中无编号', + duration: 2000 + }) + return false + } const { file } = event.detail; @@ -576,78 +693,8 @@ }) } }) - // 压缩图片 - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // //获取图片尺寸 - // wx.getImageInfo({ - // src: convertpath, - // success(res) { - // _this.setData({ - // canvasHeight: res.height, - // canvasWidth: res.width - // }) - // var ctx = wx.createCanvasContext('firstCanvas') - - // //将图片src放到cancas内,宽高为图片大小 - // ctx.drawImage(convertpath, 0, 0, res.width, res.height) - // //将声明的时间放入canvas - // ctx.setFontSize(30 * (res.width / 750)) //注意:设置文字大小必须放在填充文字之前,否则不生效 - // ctx.setFillStyle('blue') - // var text = "编号:" + _this.data.form.devcode + "\n经度:" + _this.data.form.longitude + "\n纬度:" + _this.data.form.latitude - // // _this.drawText(ctx,text,20, 70, 5, res.width) - // _this.drawText(ctx, text, 15 * (res.width / 750), 70 * (res.width / 750), 5, res.width) - - // // ctx.fillText(text, 0, 40) - // // ctx.strokeText(_this.data.form.devcode, 0, 30) - // //生成水印图 - // ctx.draw(false, function () { - // wx.canvasToTempFilePath({ - // canvasId: 'firstCanvas', - // success: (res) => { - // wx.compressImage({ - // src: res.tempFilePath, - // quality: 25, - // success: function (res) { - // //上传照片至服务器 - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: res.tempFilePath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // } - // }) - // //// - // } - // }) - // }) - // } - // }) - // } - // }); }, + //删除照片 deletePhoto(event) { var image_index = event.detail.index var fileList_new = this.data.fileList; diff --git a/miniprogram/pages/addDevice/addDevice.wxml b/miniprogram/pages/addDevice/addDevice.wxml index b0977e2..f12c254 100644 --- a/miniprogram/pages/addDevice/addDevice.wxml +++ b/miniprogram/pages/addDevice/addDevice.wxml @@ -5,18 +5,30 @@ - + + + + + + + + + + + + + - - + + - - - + + + @@ -29,13 +41,13 @@ - + - + - + - + @@ -54,8 +66,7 @@ - - + @@ -68,8 +79,8 @@ - - + + - 保存 + 保存 \ No newline at end of file diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.js b/miniprogram/pages/addDevicelog/addDeviceLog.js index cdec71b..a0dc6da 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.js +++ b/miniprogram/pages/addDevicelog/addDeviceLog.js @@ -3,681 +3,665 @@ var app = getApp(); Page({ - /** - * 页面的初始数据 - */ - data: { - pageName: '', - showMask: false, - today: new Date().getTime(), - longitude: '', - latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], - personoption1: [], - projectoption: [], - devcode: "", - deviceMode: "", - installtimeFmt: '', - show: false, - form: { - devcode: "", - wellcode: "", - welltype: "", - welldepth: "", - installheigt: "", - installperson: "", - installtimeFmt: "", - photopath: "", - factory: "", - workmsg: "", - position: "", - description: "", - longitude: "", - latitude: "", - longitude84: "", - latitude84: "", - devicetype: "", - project: "", - area: "", - street: "", - wellname: "" - }, - fileList: [], - detail: "" - }, + /** + * 页面的初始数据 + */ + data: { + pageName: '', + showMask: false, + today: new Date().getTime(), + longitude: '', + latitude: '', + option1: [], + personoption1: [], + projectoption: [], + devcode: "", + deviceMode: "", + installtimeFmt: '', + show: false, + form: { + devcode: "", + wellcode: "", + welltype: "", + welldepth: "", + installheigt: "", + installperson: "", + installtimeFmt: "", + photopath: "", + factory: "", + workmsg: "", + position: "", + description: "", + longitude: "", + latitude: "", + longitude84: "", + latitude84: "", + devicetype: "", + project: "", + area: "", + street: "", + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '' + }, + fileList: [], + detail: "", + markers: [{ + id: 100, + // iconPath: "../../images/point.png", + latitude: '', + longitude: '', + // label:'1', + width: 25, + height: 35 + }], + }, - onDisplay() { - this.setData({ - show: true - }); - }, - onClose() { - this.setData({ - show: false - }); - }, - formatDate() { - var date = new Date(); - // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; - var seperator1 = "-"; - var month = date.getMonth() + 1; - var strDate = date.getDate(); - var hour = date.getHours() - var minute = date.getMinutes() - var second = date.getSeconds() - month = month > 9 ? month : "0" + month; - strDate = strDate > 9 ? strDate : "0" + strDate; - hour = hour > 9 ? hour : "0" + hour; - minute = minute > 9 ? minute : "0" + minute; - second = second > 9 ? second : "0" + second; - var currentdate = - date.getFullYear() + - seperator1 + - month + - seperator1 + - strDate + - " " + - hour + ":" + - minute + ":" + - second; - return currentdate; + onDisplay() { + this.setData({ + show: true + }); + }, + onClose() { + this.setData({ + show: false + }); + }, + formatDate() { + var date = new Date(); + // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; + var seperator1 = "-"; + var month = date.getMonth() + 1; + var strDate = date.getDate(); + var hour = date.getHours() + var minute = date.getMinutes() + var second = date.getSeconds() + month = month > 9 ? month : "0" + month; + strDate = strDate > 9 ? strDate : "0" + strDate; + hour = hour > 9 ? hour : "0" + hour; + minute = minute > 9 ? minute : "0" + minute; + second = second > 9 ? second : "0" + second; + var currentdate = + date.getFullYear() + + seperator1 + + month + + seperator1 + + strDate + + " " + + hour + ":" + + minute + ":" + + second; + return currentdate; - }, - onConfirm(event) { - var installtime = 'form.installtimeFmt'; - this.setData({ - show: false, - installtimeFmt: this.formatDate(event.detail), - [installtime]: this.formatDate(event.detail), - }); - }, + }, + onConfirm(event) { + var installtime = 'form.installtimeFmt'; + this.setData({ + show: false, + installtimeFmt: this.formatDate(event.detail), + [installtime]: this.formatDate(event.detail), + }); + }, - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - var _this = this; - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" - }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); - } - _this.setData({ - personoption1: personArr - }) + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + var _this = this; + _this.setData({ + 'markers[0].latitude': Number(wx.getStorageSync('resultObject').latitude) , + 'markers[0].longitude': Number(wx.getStorageSync('resultObject').longitude), + // 'markers[0].label':'10', + 'markers[0].width': 18, + 'markers[0].id':1, + 'markers[0].height': 30, + latitude:Number(wx.getStorageSync('resultObject').latitude), + longitude:Number(wx.getStorageSync('resultObject').longitude) + }) + //获取人员下拉列表 + // wx.request({ + // method: "POST", + // url: app.globalData.httpsUrl + "deviceType/getUser", + // data:{ + // tips:'repair' + // }, + // header: { + // 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + // }, + // success(res) { + // if (res.data.code == 200) { + // var users = res.data.data + // var personArr = []; + // for (var i = 0; i < users.length; i++) { + // var person = { + // text: users[i].name, + // value: users[i].name + // }; + // personArr.push(person); + // } + // _this.setData({ + // personoption1: personArr + // }) + // } + // } + // }) + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); } - }).catch(err => { - console.error(err); - }) - - - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" - }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - _this.setData({ - projectoption: projectArr - }) - } - }).catch(err => { - console.error(err); - }) - - if (options.pageName) { - this.setData({ - pageName: options.pageName - }) - } - - if (options.detail) { - - var formObject = JSON.parse(options.detail); _this.setData({ - form: formObject, - detail: options.detail + projectoption: projectArr }) - - _this.setData({ - ['form.installperson']: "", - ['form.installtimeFmt']: "", - ['form.workmsg']: "", - ['form.description']: "" - }) - - const { - fileList = [] - } = _this.data; - if (formObject.photopath1 != "") { - var file1 = { - url: app.globalData.url + "static/" + formObject.photopath1 - } - fileList.push(file1) - } - if (formObject.photopath2 != "") { - var file2 = { - url: app.globalData.url + "static/" + formObject.photopath2 - } - fileList.push(file2) - } - if (formObject.photopath3 != "") { - var file3 = { - url: app.globalData.url + "static/" + formObject.photopath3 - } - fileList.push(file3) - } - - _this.setData({ - fileList - }); } - var installtime = 'form.installtimeFmt'; - var dateNow = this.formatDate(); - this.setData({ - installtimeFmt: dateNow, - [installtime]: dateNow, - }); - }, + } + }) - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { + //获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + _this.setData({ + option1: welltypeArr + }) + } + } +}) - }, + //跳转时带入参数返回哪页 + if (options.pageName) { + this.setData({ + pageName: options.pageName + }) + } + //跳转时带入参数设备的安装信息 + if (wx.getStorageSync('resultObject')) { + var formObject = wx.getStorageSync('resultObject') + _this.setData({ + form: formObject, + detail: formObject + }) - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { + _this.setData({ + ['form.installperson']: app.globalData.userName, + ['form.installtimeFmt']: "", + ['form.workmsg']: "", + ['form.description']: "" + }) - }, + const { + fileList = [] + } = _this.data; + if (formObject.photopath1 != "") { + var file1 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath1 + } + fileList.push(file1) + } + if (formObject.photopath2 != "") { + var file2 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath2 + } + fileList.push(file2) + } + if (formObject.photopath3 != "") { + var file3 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath3 + } + fileList.push(file3) + } + _this.setData({ + fileList + }); + } + var installtime = 'form.installtimeFmt'; + var dateNow = this.formatDate(); + this.setData({ + installtimeFmt: dateNow, + [installtime]: dateNow, + }); + }, - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, - }, + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + wx.removeStorageSync('resultObject') + }, - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, - }, + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { + }, - }, + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { + }, - }, + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { + }, - }, + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + }, - /** - * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true - **/ + /** + * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true + **/ - isNumber: function (val) { + isNumber: function (val) { - var regPos = /^[0-9]*$/; //非负浮点数 - var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数 - if (regPos.test(val) || regNeg.test(val)) { - return false; - } else { - return true; - } + var regPos = /^[0-9]*$/; //非负浮点数 + var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数 + if (regPos.test(val) || regNeg.test(val)) { + return false; + } else { + return true; + } - }, + }, - formValidate() { + formValidate() { - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } - if (this.data.form.wellcode == "") { - wx.showToast({ - icon: 'none', - title: '井编号不能为空!', - }) - return false - } - if (this.data.form.devicetype == "") { - wx.showToast({ - icon: 'none', - title: '设备类型不能为空!', - }) - return false - } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + if (this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '设备编号不能为空!', + }) + return false + } + if (this.data.form.wellcode == "") { + wx.showToast({ + icon: 'none', + title: '井编号不能为空!', + }) + return false + } + if (this.data.form.devicetype == "") { + wx.showToast({ + icon: 'none', + title: '设备类型不能为空!', + }) + return false + } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null || - this.data.form.installperson == '') { - wx.showToast({ - icon: 'none', - title: '运维人员不能为空!', - }) - return false - } - if (this.data.form.project == "") { - wx.showToast({ - icon: 'none', - title: '所属项目不能为空!', - }) - return false - } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } + if (this.data.form.installperson == null || + this.data.form.installperson == '') { + wx.showToast({ + icon: 'none', + title: '运维人员不能为空!', + }) + return false + } + if (this.data.form.project == "") { + wx.showToast({ + icon: 'none', + title: '所属项目不能为空!', + }) + return false + } - if (this.data.form.welldepth != null) { - if (this.isNumber(this.data.form.welldepth)) { - wx.showToast({ - icon: 'none', - title: '井深必须为数值!', - }) - return false - } - } - if (this.data.form.installheigt != null) { - if (this.isNumber(this.data.form.installheigt)) { - wx.showToast({ - icon: 'none', - title: '到井口距离必须为数值!', - }) - return false - } - } - - return true; - }, - - changeMsg: function () { - var formNew = this.data.form; - var formOld = JSON.parse(this.data.detail); - var descpNew = ""; - if (formNew.devcode != formOld.devcode) { - descpNew += "修改设备编号,原编号:" + formOld.devcode + ",新编号:" + formNew.devcode + ";" - } - if (formNew.devicetype != formOld.devicetype) { - descpNew += "修改设备类型,原设备类型:" + formOld.devicetype + ",新设备类型:" + formNew.devicetype + ";" - } - if (formNew.area != formOld.area) { - descpNew += "修改区,原区:" + formOld.area + ",新区:" + formNew.area + ";" - } - if (formNew.street != formOld.street) { - descpNew += "修改街道,原街道:" + formOld.street + ",新街道:" + formNew.street + ";" - } - if (formNew.wellname != formOld.wellname) { - descpNew += "修改井名称,原井名称:" + formOld.wellname + ",新井名称:" + formNew.wellname + ";" - } - if (formNew.factory != formOld.factory) { - descpNew += "修改权属单位,原权属单位:" + formOld.factory + ",新权属单位:" + formNew.factory + ";" - } - if (formNew.installheigt != formOld.installheigt) { - descpNew += "修改井口距离,原井口距离:" + formOld.installheigt + ",新井口距离:" + formNew.installheigt + ";" - } - if (formNew.installperson != formOld.installperson) { - descpNew += "修改运维人员,原运维人员:" + formOld.installperson + ",新运维人员:" + formNew.installperson + ";" - } - if (formNew.latitude != formOld.latitude) { - descpNew += "修改纬度,原纬度:" + formOld.latitude + ",新纬度:" + formNew.latitude + ";" - } - if (formNew.longitude != formOld.longitude) { - descpNew += "修改经度,原经度:" + formOld.longitude + ",新经度:" + formNew.longitude + ";" - } - if (formNew.position != formOld.position) { - descpNew += "修改位置描述,原位置:" + formOld.position + ",新位置:" + formNew.position + ";" - } - if (formNew.wellcode != formOld.wellcode) { - descpNew += "修改井编号,原编号:" + formOld.wellcode + ",新编号:" + formNew.wellcode + ";" - } - if (formNew.welldepth != formOld.welldepth) { - descpNew += "修改井深,原井深:" + formOld.welldepth + ",新井深:" + formNew.welldepth + ";" - } - if (formNew.welltype != formOld.welltype) { - descpNew += "修改井类型,原井类型:" + formOld.welltype + ",新井类型:" + formNew.welltype + ";" - } - if (formNew.project != formOld.project) { - descpNew += "修改所属项目,原项目:" + formOld.project + ",新项目:" + formNew.project + ";" - } - if (this.data.photopath1 != formOld.photopath1 || - this.data.photopath2 != formOld.photopath2 || - this.data.photopath3 != formOld.photopath3) { - descpNew += "修改照片;" - } - if ("" != formNew.description) { - descpNew += formNew.description; - } - this.setData({ - ['form.description']: descpNew + if (this.data.form.welldepth != null) { + if (this.isNumber(this.data.form.welldepth)) { + wx.showToast({ + icon: 'none', + title: '井深必须为数值!', }) - }, + return false + } + } + if (this.data.form.installheigt != null) { + if (this.isNumber(this.data.form.installheigt)) { + wx.showToast({ + icon: 'none', + title: '到井口距离必须为数值!', + }) + return false + } + } - formSubmit: function (event) { + return true; + }, - if (!this.formValidate()) { - return false; - } - this.changeMsg(); - var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDeviceLog', - data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceLog/add" - }, - }).then(res => { - // var resultObj=JSON.parse(res.result); - if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - if (res.confirm) { - wx.switchTab({ - url: that.data.pageName - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) - } - }).catch(err => { - console.error(err) - wx.showToast({ - title: "提交失败", - }) - }) - }, - confirm(event) { - var that = this; - var formValue = event.detail.value; - var formName = event.target.dataset.id; - var fromN = 'form.' + [formName]; - that.setData({ - [fromN]: formValue - }) - }, + //获取与上次修改的信息 + changeMsg: function () { + var formNew = this.data.form; + console.log(this.data.detail) + var formOld = JSON.parse(this.data.detail); + var descpNew = ""; + if (formNew.devcode != formOld.devcode) { + descpNew += "修改设备编号,原值:" + formOld.devcode + ",新值:" + formNew.devcode + ";" + } + if (formNew.devicetype != formOld.devicetype) { + descpNew += "修改设备类型,原值:" + formOld.devicetype + ",新值:" + formNew.devicetype + ";" + } + if (formNew.area != formOld.area) { + descpNew += "修改区,原值:" + formOld.area + ",新值:" + formNew.area + ";" + } + if (formNew.street != formOld.street) { + descpNew += "修改街道,原值:" + formOld.street + ",新值:" + formNew.street + ";" + } + if (formNew.wellname != formOld.wellname) { + descpNew += "修改井名称,原值:" + formOld.wellname + ",新值:" + formNew.wellname + ";" + } + if (formNew.factory != formOld.factory) { + descpNew += "修改权属单位,原值:" + formOld.factory + ",新值:" + formNew.factory + ";" + } + if (formNew.installheigt != formOld.installheigt) { + descpNew += "修改井口距离,原值:" + formOld.installheigt + ",新值:" + formNew.installheigt + ";" + } + if (formNew.installperson != formOld.installperson) { + descpNew += "修改运维人员,原值:" + formOld.installperson + ",新值:" + formNew.installperson + ";" + } + if (formNew.latitude != formOld.latitude) { + descpNew += "修改纬度,原值:" + formOld.latitude + ",新值:" + formNew.latitude + ";" + } + if (formNew.longitude != formOld.longitude) { + descpNew += "修改经度,原值:" + formOld.longitude + ",新值:" + formNew.longitude + ";" + } + if (formNew.position != formOld.position) { + descpNew += "修改位置描述,原值:" + formOld.position + ",新值:" + formNew.position + ";" + } + if (formNew.wellcode != formOld.wellcode) { + descpNew += "修改井编号,原值:" + formOld.wellcode + ",新值:" + formNew.wellcode + ";" + } + if (formNew.welldepth != formOld.welldepth) { + descpNew += "修改井深,原值:" + formOld.welldepth + ",新值:" + formNew.welldepth + ";" + } + if (formNew.welltype != formOld.welltype) { + descpNew += "修改井类型,原值:" + formOld.welltype + ",新值:" + formNew.welltype + ";" + } + if (formNew.project != formOld.project) { + descpNew += "修改所属项目,原值:" + formOld.project + ",新值:" + formNew.project + ";" + } + if (this.data.form.photopath1 != formOld.photopath1 || + this.data.form.photopath2 != formOld.photopath2 || + this.data.form.photopath3 != formOld.photopath3) { + descpNew += "修改照片;" + } + if ("" != formNew.description) { + descpNew += formNew.description; + } + this.setData({ + ['form.description']: descpNew + }) + }, - scan() { + //提交表单 + formSubmit: function (event) { - wx.scanCode({ - success(res) { - console.log(res) - } - }) + //表单验证 + if (!this.formValidate()) { + return false; + } + //自动生成修改内容 + this.changeMsg(); + //提交权限限制(只有施工人员能修改) + if(app.globalData.role!='repair'){ + wx.showToast({ + icon: 'none', + title: '无权限修改', + duration:2000 + }) + return false + } + var that = this; + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopath = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopath]: fileList[i].url.split("static/")[1] + }) + } + delete that.data.form.installtime + delete that.data.form.createtime + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - paste() { - var _this = this; - wx.getClipboardData({ - success: function (res) { - var longitude = 'form.longitude'; - var latitude = 'form.latitude'; - var longitude84 = 'form.longitude84'; - var latitude84 = 'form.latitude84'; - _this.setData({ - [longitude]: parseFloat(res.data.split(",", 4)[1]).toFixed(6), - [latitude]: parseFloat(res.data.split(",", 4)[0]).toFixed(6), - [longitude84]: "" == (res.data.split(",", 4)[3]) ? "" : parseFloat(res.data.split(",", 4)[3]).toFixed(6), - [latitude84]: "" == (res.data.split(",", 4)[2]) ? "" : parseFloat(res.data.split(",", 4)[2]).toFixed(6), - longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), - latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), - }); - } - }) - }, - selectValue(value) { - var that = this; - var wellType = 'form.welltype'; - that.setData({ - [wellType]: value.detail - }) - }, - selectpersonValue(event) { - var that = this; - var installPerson = 'form.installperson'; - that.setData({ - [installPerson]: event.detail - }) - }, - selectprojectValue(event) { - var that = this; - var project = 'form.project'; - that.setData({ - [project]: event.detail, - showMask: true - }) - }, - open() { - this.setData({ - showMask: true - }) - }, - close() { - this.setData({ - showMask: false - }) - }, - afterRead(event) { - var _this = this; - const { - file - } = event.detail; - const { - fileList = [] - } = _this.data; - var convertpath = ""; - wx.compressImage({ - src: event.detail.file.path, - quality: 25, - success: function (res) { - convertpath = res.tempFilePath; - wx.uploadFile({ - url: app.globalData.httpsUrl + "appDeviceAdd/fileUploadMarker", - filePath:convertpath, - name: 'file', - formData: { - 'text': "编号:" + _this.data.form.devcode + "经度:" + _this.data.form.longitude + "纬度:" + _this.data.form.latitude - }, - header: { - "Content-Type": "multipart/form-data", - 'accept': 'application/json', - }, - success(res) { - if (res.data) { - var url = JSON.parse(res.data); - fileList.push({ - ...file, - url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - }); - _this.setData({ - fileList - }); - } - } + success(res) { + if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + if (res.confirm) { + wx.switchTab({ + url: that.data.pageName }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') } - }) - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // // var base64 = "data:image/png;base64," + wx.getFileSystemManager().readFileSync(convertpath, 'base64'); - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: convertpath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // // wx.cloud.callFunction({ - // // name: 'uploadFile', - // // data: { - // // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // // fileBase64: base64 - // // }, - // // success: function (res) { - // // if (res.result) { - // // fileList.push({ - // // ...file, - // // url: app.globalData.url + "static/" + res.result.data.replace(/\\/g, "/") - // // }); - // // _this.setData({ - // // fileList - // // }); - // // } - // // }, - // // complete: res => { - // // }, - // // }) - // } - // }); + } + }) + } + }, + fail(err) { + wx.showToast({ + title: "提交失败", + }) + } + }) + }, + //报存录入的input信息 + confirm(event) { + var that = this; + var formValue = event.detail.value; + var formName = event.target.dataset.id; + var fromN = 'form.' + [formName]; + that.setData({ + [fromN]: formValue + }) + }, + + //扫码 + scan() { + + wx.scanCode({ + success(res) { + console.log(res) + } + }) + }, + //粘贴经纬度 + paste() { + var _this = this; + wx.getClipboardData({ + success: function (res) { + var longitude = 'form.longitude'; + var latitude = 'form.latitude'; + var longitude84 = 'form.longitude84'; + var latitude84 = 'form.latitude84'; + _this.setData({ + [longitude]: parseFloat(res.data.split(",", 4)[1]).toFixed(6), + [latitude]: parseFloat(res.data.split(",", 4)[0]).toFixed(6), + [longitude84]: "" == (res.data.split(",", 4)[3]) ? "" : parseFloat(res.data.split(",", 4)[3]).toFixed(6), + [latitude84]: "" == (res.data.split(",", 4)[2]) ? "" : parseFloat(res.data.split(",", 4)[2]).toFixed(6), + longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), + latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), + }); + } + }) + }, + selectValue(value) { + var that = this; + var wellType = 'form.welltype'; + that.setData({ + [wellType]: value.detail + }) + }, + //运维人员默认为登录人 + // selectpersonValue(event) { + // var that = this; + // var installPerson = 'form.installperson'; + // that.setData({ + // [installPerson]: event.detail + // }) + // }, + selectprojectValue(event) { + var that = this; + var project = 'form.project'; + that.setData({ + [project]: event.detail, + showMask: true + }) + }, + + open() { + this.setData({ + showMask: true + }) + }, + //隐藏textarea,防止遮挡 + close() { + this.setData({ + showMask: false + }) + }, + //上传照片 + afterRead(event) { + var _this = this; + const { + file + } = event.detail; + const { + fileList = [] + } = _this.data; + var convertpath = ""; + wx.compressImage({ + src: event.detail.file.path, + quality: 25, + success: function (res) { + convertpath = res.tempFilePath; + wx.uploadFile({ + url: app.globalData.httpsUrl + "appDeviceAdd/fileUploadMarker", + filePath: convertpath, + name: 'file', + formData: { + 'text': "编号:" + _this.data.form.devcode + "经度:" + _this.data.form.longitude + "纬度:" + _this.data.form.latitude }, - deletePhoto(event) { - var that = this - var image_index = event.detail.index - var fileList_new = that.data.fileList; - wx.showModal({ - content: '确定删除照片?', - success: function (res) { - if (res.confirm) { - fileList_new.splice(image_index, 1); - that.setData({ - fileList: fileList_new - }) - wx.cloud.callFunction({ - name: 'deletePhoto', - data: { - url: app.globalData.url + "appDeviceLog/deletePhoto", - devcode: that.data.form.devcode, - pathIndex: image_index - }, - success: function (res) {}, - complete: res => {}, - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + "Content-Type": "multipart/form-data", + 'accept': 'application/json', }, - }) \ No newline at end of file + success(res) { + if (res.data) { + var url = JSON.parse(res.data); + fileList.push({ + ...file, + url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") + }); + _this.setData({ + fileList + }); + } + } + }) + } + }) + }, + //删除照片 + deletePhoto(event) { + var that = this + var image_index = event.detail.index + var fileList_new = that.data.fileList; + wx.showModal({ + content: '确定删除照片?', + success: function (res) { + if (res.confirm) { + fileList_new.splice(image_index, 1); + that.setData({ + fileList: fileList_new + }) + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deletePhoto", + data: { + devcode: that.data.form.devcode + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) {} + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } +}) \ No newline at end of file diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.wxml b/miniprogram/pages/addDevicelog/addDeviceLog.wxml index 38620d4..b10cc7d 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.wxml +++ b/miniprogram/pages/addDevicelog/addDeviceLog.wxml @@ -1,15 +1,21 @@ - + + + + + - + - - + + - - + + - + @@ -39,24 +45,25 @@ - - - + + + - + - + + @@ -64,7 +71,7 @@ - + @@ -79,9 +86,9 @@ - + - 保存 + 保存 diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.wxss b/miniprogram/pages/addDevicelog/addDeviceLog.wxss index ee0b75c..08d5fd7 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.wxss +++ b/miniprogram/pages/addDevicelog/addDeviceLog.wxss @@ -24,6 +24,17 @@ display: flex; align-items: center; } +.map-view{ + width: 750rpx; + height: 485rpx; + position: fixed; + top: 0px; + left: 0px; + z-index: 999; +} +.content{ + margin-top: 495rpx; +} .left { width: 210rpx; diff --git a/miniprogram/pages/addFunction/addFunction.js b/miniprogram/pages/addFunction/addFunction.js deleted file mode 100644 index 4966be3..0000000 --- a/miniprogram/pages/addFunction/addFunction.js +++ /dev/null @@ -1,60 +0,0 @@ -// pages/addFunction/addFunction.js - -const code = `// 云函数入口函数 -exports.main = (event, context) => { - console.log(event) - console.log(context) - return { - sum: event.a + event.b - } -}` - -Page({ - - data: { - result: '', - canIUseClipboard: wx.canIUse('setClipboardData'), - }, - - onLoad: function (options) { - - }, - - copyCode: function() { - wx.setClipboardData({ - data: code, - success: function () { - wx.showToast({ - title: '复制成功', - }) - } - }) - }, - - testFunction() { - wx.cloud.callFunction({ - name: 'sum', - data: { - a: 1, - b: 2 - }, - success: res => { - wx.showToast({ - title: '调用成功', - }) - this.setData({ - result: JSON.stringify(res.result) - }) - }, - fail: err => { - wx.showToast({ - icon: 'none', - title: '调用失败', - }) - console.error('[云函数] [sum] 调用失败:', err) - } - }) - }, - -}) - diff --git a/miniprogram/pages/addFunction/addFunction.json b/miniprogram/pages/addFunction/addFunction.json deleted file mode 100644 index a9a50c5..0000000 --- a/miniprogram/pages/addFunction/addFunction.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "navigationBarTitleText": "云函数指引", - "usingComponents": {} -} \ No newline at end of file diff --git a/miniprogram/pages/addFunction/addFunction.wxml b/miniprogram/pages/addFunction/addFunction.wxml deleted file mode 100644 index 3a10626..0000000 --- a/miniprogram/pages/addFunction/addFunction.wxml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - 测试云函数 - - - 期望输出:{"sum":3} - - - 调用结果:{{result}} - - - - - 新增云函数 - 1. 在云函数根目录 cloudfunctions 上右键选择新建云函数,命名为 sum - 2. 在创建的 cloudfunctions/sum/index.js 文件中添加如下代码 - - - 3. 在 cloudfunctions/sum 目录上右键上传并部署 - 4. 点击测试云函数测试 - 5. 打开云开发云函数管理页,选择 sum 云函数 - 6. 查看 sum 的调用日志 - 进阶:可在云函数中使用 wx-server-sdk 操作数据库,文件存储和调用其他云函数,详见文档 - - - diff --git a/miniprogram/pages/addFunction/addFunction.wxss b/miniprogram/pages/addFunction/addFunction.wxss deleted file mode 100644 index 7ac8619..0000000 --- a/miniprogram/pages/addFunction/addFunction.wxss +++ /dev/null @@ -1,3 +0,0 @@ -/* pages/addFunction/addFunction.wxss */ - -@import "../../style/guide.wxss"; \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.js b/miniprogram/pages/applog/applog.js index 0e8c185..189e61f 100644 --- a/miniprogram/pages/applog/applog.js +++ b/miniprogram/pages/applog/applog.js @@ -13,98 +13,25 @@ isSeach: "false", params: {}, total: 0, - show: false + show: false, + delBtnWidth: 100, //删除按钮宽度单位(rpx) + activeIndex: -1, + list_style: '' }, - - touchE: function (e) { - // console.log(e); - var that = this - if (e.changedTouches.length == 1) { - //手指移动结束后触摸点位置的X坐标 - var endX = e.changedTouches[0].clientX; - //触摸开始与结束,手指移动的距离 - var disX = that.data.startX - endX; - var delBtnWidth = that.data.delBtnWidth; - //如果距离小于删除按钮的1/2,不显示删除按钮 - var txtStyle = disX > delBtnWidth / 2 ? "left:-" + delBtnWidth + "rpx" : "left:0rpx"; - - //获取手指触摸的是哪一项 - var index = e.currentTarget.dataset.index; - var list = that.data.deviceloglist; - list[index].txtStyle = txtStyle; - //更新列表的状态 - that.setData({ - deviceloglist: list - }); - } - }, - //手指触摸动作开始 记录起点X坐标 - touchstart: function (e) { - //开始触摸时 重置所有删除 - this.data.deviceloglist.forEach(function (v, i) { - if (v.isTouchMove) //只操作为true的 - v.isTouchMove = false; - }) - this.setData({ - startX: e.changedTouches[0].clientX, - startY: e.changedTouches[0].clientY, - deviceloglist: this.data.deviceloglist - }) - }, - //滑动事件处理 - touchmove: function (e) { - var that = this, - index = e.currentTarget.dataset.index, //当前索引 - startX = that.data.startX, //开始X坐标 - startY = that.data.startY, //开始Y坐标 - touchMoveX = e.changedTouches[0].clientX, //滑动变化坐标 - touchMoveY = e.changedTouches[0].clientY, //滑动变化坐标 - //获取滑动角度 - angle = that.angle({ - X: startX, - Y: startY - }, { - X: touchMoveX, - Y: touchMoveY - }); - that.data.deviceloglist.forEach(function (v, i) { - v.isTouchMove = false - //滑动超过30度角 return - if (Math.abs(angle) > 30) return; - if (i == index) { - if (touchMoveX > startX) //右滑 - v.isTouchMove = false - else //左滑 - v.isTouchMove = true - } - }) - //更新数据 - that.setData({ - deviceloglist: that.data.deviceloglist - }) - }, - /** - * 计算滑动角度 - * @param {Object} start 起点坐标 - * @param {Object} end 终点坐标 - */ - angle: function (start, end) { - var _X = end.X - start.X, - _Y = end.Y - start.Y - //返回角度 /Math.atan()返回数字的反正切值 - return 360 * Math.atan(_Y / _X) / (2 * Math.PI); - }, - /** - * 生命周期函数--监听页面加载var_this=this; - */ onLoad: function (options) { - if (options.params) { this.setData({ params: JSON.parse(options.params), isSeach: "true" }) this.initPages() + }else{ + this.setData({ + show: false + }) + //清空参数,重新加载 + this.clearParams(); + this.initPages(); } }, @@ -116,20 +43,33 @@ }, + //点击tabBar事件 + onTabItemTap(item) { + //隐藏历史显示总记录条数 + this.setData({ + show: false + }) + //清空参数,重新加载 + this.clearParams(); + this.initPages(); + }, + + /** * 生命周期函数--监听页面显示 */ onShow: function (options) { - this.setData({ - show:false - }) - if (this.data.isSeach == "false") { - this.clearParams(); - this.initPages(); - } - this.setData({ - isSeach: "false" - }) + + // this.setData({ + // show: false + // }) + // if (this.data.isSeach == "false") { + // this.clearParams(); + // this.initPages(); + // } + // this.setData({ + // isSeach: "false" + // }) }, /** @@ -167,6 +107,119 @@ }, + + //手指触摸动作开始 记录起点X坐标 + touchstart: function (e) { + //开始触摸时 重置所有删除 + this.data.deviceloglist.forEach(function (v, i) { + if (v.isTouchMove) //只操作为true的 + v.isTouchMove = false; + }) + this.setData({ + startX: e.changedTouches[0].clientX, + startY: e.changedTouches[0].clientY, + deviceloglist: this.data.deviceloglist + }) + }, + + //滑动事件处理 + touchmove: function (e) { + var that = this, + index = e.currentTarget.dataset.index, //当前索引 + startX = that.data.startX, //开始X坐标 + startY = that.data.startY, //开始Y坐标 + touchMoveX = e.changedTouches[0].clientX, //滑动变化坐标 + touchMoveY = e.changedTouches[0].clientY, //滑动变化坐标 + //获取滑动角度 + angle = that.angle({ + X: startX, + Y: startY + }, { + X: touchMoveX, + Y: touchMoveY + }); + that.data.deviceloglist.forEach(function (v, i) { + // v.isTouchMove = false + //滑动超过30度角 return + if (Math.abs(angle) > 30) return; + if (i == index) { + if (touchMoveX > startX) //右滑 + v.isTouchMove = false + else //左滑 + v.isTouchMove = true + } + }) + //更新数据 + that.setData({ + deviceloglist: that.data.deviceloglist + }) + }, + + /** + * 计算滑动角度 + * @param {Object} start 起点坐标 + * @param {Object} end 终点坐标 + */ + angle: function (start, end) { + var _X = end.X - start.X, + _Y = end.Y - start.Y + //返回角度 /Math.atan()返回数字的反正切值 + return 360 * Math.atan(_Y / _X) / (2 * Math.PI); + }, + + //删除事件 + delItem: function (e) { + if(app.globalData.role!='repair'){ + wx.showToast({ + icon: 'none', + title: '无权限删除', + duration:2000 + }) + return false + } + var that = this + wx.showModal({ + content: '是否删除?', + success: function (res) { + if (res.confirm) { + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/delete", + data: { + appDeviceAddId: e.currentTarget.dataset.devid + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if(res.data.code=='200'){ + that.data.deviceloglist.splice(e.currentTarget.dataset.index, 1) + that.setData({ + deviceloglist: that.data.deviceloglist, + total: that.data.deviceloglist.length + }) + wx.showToast({ + title: '删除成功!', + icon: 'none', + duration: 1000 + }) + } + }, + fail(err) { + wx.showToast({ + title: '删除失败!', + icon: 'none', + duration: 2000 + }) + } + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + }, + showLoading: function (message) { if (wx.showLoading) { // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 @@ -199,95 +252,105 @@ deviceloglist: [] }) }, + //查询列表数据 initPages: function () { var that = this + that.setData({ + show: false + }) var offsetValue = that.data.deviceloglist.length % 15 > 0 ? parseInt(that.data.deviceloglist.length / 15) + 2 : parseInt(that.data.deviceloglist.length / 15) + 1 - wx.cloud.callFunction({ - name: 'devicelog', + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/listPage", data: { devcode: that.data.params.devcode, devtype: that.data.params.devtype, installtimeFmt: that.data.params.installtimeFmt, project: that.data.params.project, installPerson: that.data.params.installPerson, - url: app.globalData.url + "appDeviceLog/listPage", limit: 15, offset: offsetValue }, - }).then(res => { - if (res.result.data.rows.length > 0) { - var resultJson = res.result - that.setData({ - deviceloglist: that.data.deviceloglist.concat(resultJson.data.rows) - }) - } else if (that.data.deviceloglist.length > 0) { - that.setData({ - show: true, - total: that.data.deviceloglist.length - }) - wx.showToast({ - title: '数据已全部加载完', - icon: 'none', - duration: 2000 - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.data.rows.length > 0) { + var resultJson = res.data + var listArr = resultJson.data.rows + listArr.forEach(function (v, i) { + listArr[i]['isTouchMove'] = false + }) + that.setData({ + deviceloglist: that.data.deviceloglist.concat(listArr) + }) + } else if (that.data.deviceloglist.length > 0) { + that.setData({ + show: true, + total: that.data.deviceloglist.length + }) + wx.showToast({ + title: '数据已全部加载完', + icon: 'none', + duration: 2000 + }) + } + if (offsetValue == 1 && res.data.data.rows.length < 15) { + that.setData({ + show: true, + total: that.data.deviceloglist.length + }) + } } - if(offsetValue==1&&res.result.data.rows.length<15){ - that.setData({ - show: true, - total: that.data.deviceloglist.length - }) - } - // console.log(res); - }).catch(err => { - console.error(err); }) + }, addDetail: function (event) { - this.showLoading("数据请求中..."); - wx.cloud.callFunction({ - name: 'deviceDetail', + var that = this + that.showLoading("数据请求中..."); + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deviceDetail", data: { devcode: event.target.dataset.devcode, - url: app.globalData.url + "appDeviceLog/deviceDetail", }, - }).then(res => { - this.hideLoading(); - var resultObject = JSON.parse(res.result); - var pageName = '../applog/applog' - if (resultObject.code == 200) { - wx.navigateTo({ - url: '../addDevicelog/addDeviceLog?detail=' + - JSON.stringify(resultObject.data) + "&pageName=" + pageName - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + that.hideLoading(); + // var resultObject = JSON.parse(res.data); + var resultObject = res.data; + var pageName = '../applog/applog' + if (resultObject.code == 200) { + wx.setStorageSync('resultObject', resultObject.data) + wx.navigateTo({ + url: '../addDevicelog/addDeviceLog?detail=' + "&pageName=" + pageName + }) + } + }, + fail(err) { + that.hideLoading(); } - }).catch(err => { - this.hideLoading() }) + }, add: function (event) { - wx.reLaunch({ - url: '../earth/earth?devcode=' + event.target.dataset.devcode - // url: '../earth/earth' + app.globalData.devcode = event.target.dataset.devcode; + wx.switchTab({ + url: '../earth/earth' }) + // wx.reLaunch({ + // url: '../earth/earth?devcode=' + event.target.dataset.devcode + // // url: '../earth/earth' + // }) }, onSearch: function () { + var _this = this wx.navigateTo({ - url: '../searchLog/searchLog' + url: '../searchLog/searchLog?params=' + JSON.stringify(_this.data.params) }) - }, - // initPages: function () { - // wx.cloud.callFunction({ - // name: 'devicelog' - // }).then(res => { - // var that = this; - // var jsonList = JSON.parse(res.result) - // that.setData({ - // deviceloglist: jsonList.data.rows - // }) - // console.log(res); - // }).catch(err => { - // console.error(err); - // }) - // } + } }) \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.wxml b/miniprogram/pages/applog/applog.wxml index e9a2352..2bfd041 100644 --- a/miniprogram/pages/applog/applog.wxml +++ b/miniprogram/pages/applog/applog.wxml @@ -1,54 +1,59 @@ - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {{item.devcode}} {{item.devicetype}} + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + {{item.devcode}} {{item.devicetype}} + + {{item.project}} {{item.installtime}}- {{item.installperson}} - - - - - + + + + + + 删除 - - - + + - 共计:{{total}}台 - + 共计:{{total}}台 + \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.wxss b/miniprogram/pages/applog/applog.wxss index 6d3428b..e6e8983 100644 --- a/miniprogram/pages/applog/applog.wxss +++ b/miniprogram/pages/applog/applog.wxss @@ -22,16 +22,18 @@ position: fixed; width: 100%; top: 0rpx; + z-index: 9999; /* margin-bottom: 100rpx; */ } .log-list { /* height: 100rpx; */ - /* display: flex; */ - + display: flex; + width: 100%; padding: 2px; margin-top: 2px; border-bottom: 1px solid #e5e5e5; + overflow: hidden } @@ -53,23 +55,29 @@ left: 35%; margin: 20rpx } - .del { - width: 90px; + /* display: flex; */ + width: 100rpx; display: flex; flex-direction: column; align-items: center; justify-content: center; - color: #fff; - -webkit-transform: translateX(90px); - transform: translateX(90px); - -webkit-transition: all 0.4s; + /* -webkit-transform: translateX(100rpx); */ + transform: translateX(100rpx); + /* -webkit-transition: all 0.4s; */ transition: all 0.4s; - font-size: 35rpx; + color: #fff; + background-color: #fe3e2f; +} +.logrow{ + width: 100%; + transform: translateX(100rpx); + /* -webkit-transform: translateX(100px); */ + margin-left: -100rpx; } -.touch-move-active .content, +.touch-move-active .logrow, .touch-move-active .del { - -webkit-transform: translateX(0); - transform: translateX(0); +/* -webkit-transform: translateX(0); */ +transform: translateX(0); } \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.js b/miniprogram/pages/deployFunctions/deployFunctions.js deleted file mode 100644 index a76b144..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.js +++ /dev/null @@ -1,66 +0,0 @@ -// pages/deployFunctions/deployFunctions.js -Page({ - - /** - * 页面的初始数据 - */ - data: { - - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - - }, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { - - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - - }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { - - }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { - - } -}) \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.json b/miniprogram/pages/deployFunctions/deployFunctions.json deleted file mode 100644 index 7fbedab..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "navigationBarTitleText": "部署云函数", - "usingComponents": {} -} \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.wxml b/miniprogram/pages/deployFunctions/deployFunctions.wxml deleted file mode 100644 index 462b6b6..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.wxml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - 调用失败 - - - 请检查 login 云函数是否已部署 - - - - - 部署 login 云函数 - 1. 确保已通过工具栏云开发入口开通云开发 - 2. 在 cloudfunctions/login 目录上右键上传并部署 - 3. 回到首页,重新点击获取 openid - - - - diff --git a/cloudfunctions/project.config.json b/cloudfunctions/project.config.json new file mode 100644 index 0000000..2b3119a --- /dev/null +++ b/cloudfunctions/project.config.json @@ -0,0 +1,28 @@ +{ + "appid": "wx2cef527a000f87c9", + "compileType": "miniprogram", + "libVersion": "2.27.3", + "packOptions": { + "ignore": [], + "include": [] + }, + "setting": { + "coverView": true, + "es6": true, + "postcss": true, + "minified": true, + "enhance": true, + "showShadowRootInWxmlPanel": true, + "packNpmRelationList": [], + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + } + }, + "condition": {}, + "editorSetting": { + "tabIndent": "insertSpaces", + "tabSize": 4 + } +} \ No newline at end of file diff --git a/cloudfunctions/project.private.config.json b/cloudfunctions/project.private.config.json new file mode 100644 index 0000000..42ff49d --- /dev/null +++ b/cloudfunctions/project.private.config.json @@ -0,0 +1,7 @@ +{ + "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", + "projectname": "cloudfunctions", + "setting": { + "compileHotReLoad": true + } +} \ No newline at end of file diff --git a/miniprogram/app.js b/miniprogram/app.js index 51d56f3..50a8a54 100644 --- a/miniprogram/app.js +++ b/miniprogram/app.js @@ -18,13 +18,15 @@ // this.globalData = {} }, globalData: { - // url: "http://111.198.10.15:11604/", - httpsUrl: "https://logapi.smartlog.work/", - httpsTestUrl: "https://smartlog.work/prodapi4test/", - url: "http://139.198.18.188:8083/", + httpsUrl: "https://logapi.smartlog.work/", + // httpsUrl: "http://139.198.18.188:8083/", // url: "http://127.0.0.1:8083/", - // httpsUrl: "http://127.0.0.1:8083/", + //httpsUrl: "http://127.0.0.1:8083/", openid: null, - indexCount:1 - }, + indexCount:1, + nickName:"", + userName:"", + role:"", + devcode:"" + } }) diff --git a/miniprogram/app.json b/miniprogram/app.json index d23f798..2b6db76 100644 --- a/miniprogram/app.json +++ b/miniprogram/app.json @@ -1,15 +1,17 @@ { "cloud": true, "pages": [ + "pages/login/login", "pages/indexapp/indexapp", "pages/earth/earth", "pages/applog/applog", "pages/addDevice/addDevice", "pages/addDevicelog/addDeviceLog", - "pages/searchLog/searchLog" + "pages/searchLog/searchLog", + "pages/notice/notice" ], "window": { - "backgroundColor": "#F6F6F6", + "backgroundColor": "#E6D480", "backgroundTextStyle": "light", "navigationBarBackgroundColor": "#FFCF00", "navigationBarTitleText": "智慧施工", @@ -46,11 +48,11 @@ "desc": "你的位置信息将用于小程序位置接口的效果展示" } }, + "requiredPrivateInfos": ["getLocation", "chooseLocation"], "networkTimeout": { "request": 30000, "connectSocket": 30000, "uploadFile": 30000, "downloadFile": 30000 - }, - "style": "v2" + } } \ No newline at end of file diff --git a/miniprogram/images/applocat.png b/miniprogram/images/applocat.png new file mode 100644 index 0000000..fe49f54 --- /dev/null +++ b/miniprogram/images/applocat.png Binary files differ diff --git a/miniprogram/images/back.png b/miniprogram/images/back.png new file mode 100644 index 0000000..32ac82d --- /dev/null +++ b/miniprogram/images/back.png Binary files differ diff --git a/miniprogram/images/bottom.png b/miniprogram/images/bottom.png new file mode 100644 index 0000000..d910e98 --- /dev/null +++ b/miniprogram/images/bottom.png Binary files differ diff --git a/miniprogram/images/header.png b/miniprogram/images/header.png new file mode 100644 index 0000000..6ea222e --- /dev/null +++ b/miniprogram/images/header.png Binary files differ diff --git a/miniprogram/images/login.png b/miniprogram/images/login.png index 8b73cc0..6471c46 100644 --- a/miniprogram/images/login.png +++ b/miniprogram/images/login.png Binary files differ diff --git a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss index 5a591fb..c9c35b5 100644 --- a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss +++ b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:100%;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:100%}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file +@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:650rpx;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:600rpx}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file diff --git a/miniprogram/pages/addDevice/addDevice.js b/miniprogram/pages/addDevice/addDevice.js index 2783674..78f00b7 100644 --- a/miniprogram/pages/addDevice/addDevice.js +++ b/miniprogram/pages/addDevice/addDevice.js @@ -1,5 +1,7 @@ // miniprogram/pages/addDevice/addDevice.js // import WxValidate from '../../utils/WxValidate.js' +var QQMapWX = require('../../libs/qqmap-wx-jssdk.js'); +var qqmapsdk; var app = getApp() Page({ @@ -11,32 +13,10 @@ canvasWidth: '', longitude: '', latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], + option1: [], personoption1: [], projectoption: [], + devtypeList:[], show: false, form: { devcode: "", @@ -59,7 +39,10 @@ project: "", area: "", street: "", - wellname: "" + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '', }, fileList: [] }, @@ -117,12 +100,14 @@ var that = this; //初始化表单内容为上次填写值 var cacheForms = wx.getStorageSync('cacheList') - if (cacheForms) { + cacheForms.photopath1='' + cacheForms.photopath2='' + cacheForms.photopath3='' + that.data.fileList=[] that.setData({ form: cacheForms, devcode: cacheForms.devcode, - }) } var form = that.data.form @@ -155,55 +140,89 @@ } }) + +//获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + that.setData({ + option1: welltypeArr + }) + } + } +}) + + //获取人员下拉列表 - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/getUser", + data:{ + tips:'repair' }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data.code == 200) { + var users = res.data.data + var personArr = []; + for (var i = 0; i < users.length; i++) { + var person = { + text: users[i].name, + value: users[i].name + }; + personArr.push(person); + } + that.setData({ + personoption1: personArr + }) } - that.setData({ - personoption1: personArr - }) } - }).catch(err => { - console.error(err); - }) + }) + - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - that.setData({ - projectoption: projectArr - }) + success(res){ + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); + } + that.setData({ + projectoption: projectArr + }) + } } - }).catch(err => { - console.error(err); - }) + }) + var installtime = 'form.installtimeFmt'; var dateNow = this.formatDate(); this.setData({ @@ -211,8 +230,40 @@ installtimeFmt: dateNow, [installtime]: dateNow, }); + + + + /** + * 获取设备类型下拉列表 + */ + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/deviceType", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var TypeList = res.data.data + var typeArr = []; + for (var i = 0; i < TypeList.length; i++) { + var type = { + text: TypeList[i].productName, + value: TypeList[i].productName + }; + typeArr.push(type); + } + that.setData({ + devtypeList: typeArr + }) + } + } + }) }, + + + /** * 生命周期函数--监听页面初次渲染完成 */ @@ -280,29 +331,7 @@ }, - - //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 - drawText: function (ctx, str, leftWidth, initHeight, titleHeight, canvasWidth) { - var lineWidth = 0; - var lastSubStrIndex = 0; //每次开始截取的字符串的索引 - for (let i = 0; i < str.length; i++) { - lineWidth += ctx.measureText(str[i]).width; - if (lineWidth > canvasWidth) { - ctx.fillText(str.substring(lastSubStrIndex, i), leftWidth, initHeight); //绘制截取部分 - initHeight = initHeight + leftWidth * 2; //22为字体的高度 - lineWidth = 0; - lastSubStrIndex = i; - // titleHeight += 40; - } - if (i == str.length - 1) { //绘制剩余部分 - ctx.fillText(str.substring(lastSubStrIndex, i + 1), leftWidth, initHeight); - } - } - // // 标题border-bottom 线距顶部距离 - // titleHeight = titleHeight + 10; - // return titleHeight - }, - + //验证表单 formValidate() { if (this.data.form.devcode == "") { @@ -312,27 +341,20 @@ }) return false } - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } if (this.data.form.wellcode == "") { wx.showToast({ icon: 'none', @@ -348,22 +370,10 @@ }) return false } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null) { + + if (this.data.form.installperson == "") { wx.showToast({ icon: 'none', title: '安装人员不能为空!', @@ -408,56 +418,90 @@ } return true; }, + //提交表单 formSubmit: function (event) { + console.log(this.data.form) + //表单参数验证 if (!this.formValidate()) { return false; } var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDevice', + //验证设备编号长度 + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/getDevTypeLength", data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceAdd/add" + code: encodeURI(this.data.form.devicetype) }, - }).then(res => { - if (res.result.code == 500) { - wx.showToast({ - title: '设备编号已安装!', - }) - } else if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - //用于回显 - wx.setStorageSync('cacheList', that.data.form) - //提交成功后提示用户操作 - if (res.confirm) { - wx.switchTab({ - url: '../earth/earth' - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (""==res.data.data ||res.data.data == that.data.form.devcode.length) { + that.saveDevice() + } else { //编号位数不对提示 + wx.showToast({ + icon: 'none', + title: '设备编号位数不对!', + duration: 1000 + }) + return false + } } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "提交失败", - }) }) }, + + //保存设备基本信息 + saveDevice() { + var that = this; + //设置照片路径 + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopathForm = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopathForm]: fileList[i].url.split("static/")[1] + }) + } + //表单提交 + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 500) { + wx.showToast({ + title: '设备编号已安装!', + }) + } else if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + //用于回显 + wx.setStorageSync('cacheList', that.data.form) + //提交成功后提示用户操作 + if (res.confirm) { + wx.switchTab({ + url: '../earth/earth' + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } + }, + fail(err) { + wx.showToast({ + title: '提交失败!', + }) + } + }) + }, + + //input 输入框设置值 confirm(event) { var that = this; var formValue = event.detail.value; @@ -466,8 +510,30 @@ that.setData({ [fromN]: formValue }) + //若输入是设备编号,自动获取设备类型 + if('devcode'==formName){ + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", + data: { + devcode: formValue, + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + that.setData({ + [formDevicetype]: res.data + }); + } + } + }) + } }, + //扫描设备获取编号和设备类型 scan() { var _this = this; wx.scanCode({ @@ -477,23 +543,28 @@ _this.setData({ [formdevcode]: devcode }); - wx.cloud.callFunction({ - name: 'findModeCode', + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", data: { devcode: devcode, - url: app.globalData.url + "appDeviceAdd/findModeCodeByCode" }, - }).then(res => { - if (res.result) { - var formDevicetype = 'form.devicetype' - _this.setData({ - [formDevicetype]: res.result - }); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + _this.setData({ + [formDevicetype]: res.data + }); + } } }) } }) }, + //粘贴经纬度 paste() { var _this = this; wx.getClipboardData({ @@ -510,9 +581,11 @@ longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), }); + _this.showAddress(_this.data.form.longitude,_this.data.form.latitude,_this) } }) }, + //设置经类型 selectValue(value) { var that = this; @@ -521,6 +594,16 @@ [wellType]: value.detail }) }, + + //设置设备类型 + selectDevType(event) { + var that = this; + var devtype = 'form.devicetype'; + that.setData({ + [devtype]: event.detail + }) + }, + //设置运维人员 selectpersonValue(event) { var that = this; var installPerson = 'form.installperson'; @@ -528,6 +611,7 @@ [installPerson]: event.detail }) }, + //设置项目 selectprojectValue(event) { var that = this; var project = 'form.project'; @@ -535,8 +619,41 @@ [project]: event.detail }) }, + showAddress :function(longitude, latitude, self) { + // 实例化腾讯地图API核心类 + qqmapsdk = new QQMapWX({ + key: 'BGPBZ-C5O3P-ROUDR-LWC4J-63EKH-V5FRX'//此处使用你自己申请的key + }) + // 腾讯地图调用接口 + qqmapsdk.reverseGeocoder({ + location: { + latitude: latitude, + longitude: longitude + }, + success: function (res) { + self.setData({ + 'form.area':res.result.address.slice(0,res.result.address.indexOf('区')+1), + 'form.street':res.result.address.slice(res.result.address.indexOf('区')+1) + }) + }, + fail: function (res) { + console.log(res); + }, + complete: function (res) { + } + }); + }, + //上传照片 afterRead(event) { var _this = this; + if (_this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '请先填写设备编号!\r\n否则水印中无编号', + duration: 2000 + }) + return false + } const { file } = event.detail; @@ -576,78 +693,8 @@ }) } }) - // 压缩图片 - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // //获取图片尺寸 - // wx.getImageInfo({ - // src: convertpath, - // success(res) { - // _this.setData({ - // canvasHeight: res.height, - // canvasWidth: res.width - // }) - // var ctx = wx.createCanvasContext('firstCanvas') - - // //将图片src放到cancas内,宽高为图片大小 - // ctx.drawImage(convertpath, 0, 0, res.width, res.height) - // //将声明的时间放入canvas - // ctx.setFontSize(30 * (res.width / 750)) //注意:设置文字大小必须放在填充文字之前,否则不生效 - // ctx.setFillStyle('blue') - // var text = "编号:" + _this.data.form.devcode + "\n经度:" + _this.data.form.longitude + "\n纬度:" + _this.data.form.latitude - // // _this.drawText(ctx,text,20, 70, 5, res.width) - // _this.drawText(ctx, text, 15 * (res.width / 750), 70 * (res.width / 750), 5, res.width) - - // // ctx.fillText(text, 0, 40) - // // ctx.strokeText(_this.data.form.devcode, 0, 30) - // //生成水印图 - // ctx.draw(false, function () { - // wx.canvasToTempFilePath({ - // canvasId: 'firstCanvas', - // success: (res) => { - // wx.compressImage({ - // src: res.tempFilePath, - // quality: 25, - // success: function (res) { - // //上传照片至服务器 - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: res.tempFilePath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // } - // }) - // //// - // } - // }) - // }) - // } - // }) - // } - // }); }, + //删除照片 deletePhoto(event) { var image_index = event.detail.index var fileList_new = this.data.fileList; diff --git a/miniprogram/pages/addDevice/addDevice.wxml b/miniprogram/pages/addDevice/addDevice.wxml index b0977e2..f12c254 100644 --- a/miniprogram/pages/addDevice/addDevice.wxml +++ b/miniprogram/pages/addDevice/addDevice.wxml @@ -5,18 +5,30 @@ - + + + + + + + + + + + + + - - + + - - - + + + @@ -29,13 +41,13 @@ - + - + - + - + @@ -54,8 +66,7 @@ - - + @@ -68,8 +79,8 @@ - - + + - 保存 + 保存 \ No newline at end of file diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.js b/miniprogram/pages/addDevicelog/addDeviceLog.js index cdec71b..a0dc6da 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.js +++ b/miniprogram/pages/addDevicelog/addDeviceLog.js @@ -3,681 +3,665 @@ var app = getApp(); Page({ - /** - * 页面的初始数据 - */ - data: { - pageName: '', - showMask: false, - today: new Date().getTime(), - longitude: '', - latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], - personoption1: [], - projectoption: [], - devcode: "", - deviceMode: "", - installtimeFmt: '', - show: false, - form: { - devcode: "", - wellcode: "", - welltype: "", - welldepth: "", - installheigt: "", - installperson: "", - installtimeFmt: "", - photopath: "", - factory: "", - workmsg: "", - position: "", - description: "", - longitude: "", - latitude: "", - longitude84: "", - latitude84: "", - devicetype: "", - project: "", - area: "", - street: "", - wellname: "" - }, - fileList: [], - detail: "" - }, + /** + * 页面的初始数据 + */ + data: { + pageName: '', + showMask: false, + today: new Date().getTime(), + longitude: '', + latitude: '', + option1: [], + personoption1: [], + projectoption: [], + devcode: "", + deviceMode: "", + installtimeFmt: '', + show: false, + form: { + devcode: "", + wellcode: "", + welltype: "", + welldepth: "", + installheigt: "", + installperson: "", + installtimeFmt: "", + photopath: "", + factory: "", + workmsg: "", + position: "", + description: "", + longitude: "", + latitude: "", + longitude84: "", + latitude84: "", + devicetype: "", + project: "", + area: "", + street: "", + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '' + }, + fileList: [], + detail: "", + markers: [{ + id: 100, + // iconPath: "../../images/point.png", + latitude: '', + longitude: '', + // label:'1', + width: 25, + height: 35 + }], + }, - onDisplay() { - this.setData({ - show: true - }); - }, - onClose() { - this.setData({ - show: false - }); - }, - formatDate() { - var date = new Date(); - // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; - var seperator1 = "-"; - var month = date.getMonth() + 1; - var strDate = date.getDate(); - var hour = date.getHours() - var minute = date.getMinutes() - var second = date.getSeconds() - month = month > 9 ? month : "0" + month; - strDate = strDate > 9 ? strDate : "0" + strDate; - hour = hour > 9 ? hour : "0" + hour; - minute = minute > 9 ? minute : "0" + minute; - second = second > 9 ? second : "0" + second; - var currentdate = - date.getFullYear() + - seperator1 + - month + - seperator1 + - strDate + - " " + - hour + ":" + - minute + ":" + - second; - return currentdate; + onDisplay() { + this.setData({ + show: true + }); + }, + onClose() { + this.setData({ + show: false + }); + }, + formatDate() { + var date = new Date(); + // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; + var seperator1 = "-"; + var month = date.getMonth() + 1; + var strDate = date.getDate(); + var hour = date.getHours() + var minute = date.getMinutes() + var second = date.getSeconds() + month = month > 9 ? month : "0" + month; + strDate = strDate > 9 ? strDate : "0" + strDate; + hour = hour > 9 ? hour : "0" + hour; + minute = minute > 9 ? minute : "0" + minute; + second = second > 9 ? second : "0" + second; + var currentdate = + date.getFullYear() + + seperator1 + + month + + seperator1 + + strDate + + " " + + hour + ":" + + minute + ":" + + second; + return currentdate; - }, - onConfirm(event) { - var installtime = 'form.installtimeFmt'; - this.setData({ - show: false, - installtimeFmt: this.formatDate(event.detail), - [installtime]: this.formatDate(event.detail), - }); - }, + }, + onConfirm(event) { + var installtime = 'form.installtimeFmt'; + this.setData({ + show: false, + installtimeFmt: this.formatDate(event.detail), + [installtime]: this.formatDate(event.detail), + }); + }, - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - var _this = this; - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" - }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); - } - _this.setData({ - personoption1: personArr - }) + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + var _this = this; + _this.setData({ + 'markers[0].latitude': Number(wx.getStorageSync('resultObject').latitude) , + 'markers[0].longitude': Number(wx.getStorageSync('resultObject').longitude), + // 'markers[0].label':'10', + 'markers[0].width': 18, + 'markers[0].id':1, + 'markers[0].height': 30, + latitude:Number(wx.getStorageSync('resultObject').latitude), + longitude:Number(wx.getStorageSync('resultObject').longitude) + }) + //获取人员下拉列表 + // wx.request({ + // method: "POST", + // url: app.globalData.httpsUrl + "deviceType/getUser", + // data:{ + // tips:'repair' + // }, + // header: { + // 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + // }, + // success(res) { + // if (res.data.code == 200) { + // var users = res.data.data + // var personArr = []; + // for (var i = 0; i < users.length; i++) { + // var person = { + // text: users[i].name, + // value: users[i].name + // }; + // personArr.push(person); + // } + // _this.setData({ + // personoption1: personArr + // }) + // } + // } + // }) + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); } - }).catch(err => { - console.error(err); - }) - - - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" - }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - _this.setData({ - projectoption: projectArr - }) - } - }).catch(err => { - console.error(err); - }) - - if (options.pageName) { - this.setData({ - pageName: options.pageName - }) - } - - if (options.detail) { - - var formObject = JSON.parse(options.detail); _this.setData({ - form: formObject, - detail: options.detail + projectoption: projectArr }) - - _this.setData({ - ['form.installperson']: "", - ['form.installtimeFmt']: "", - ['form.workmsg']: "", - ['form.description']: "" - }) - - const { - fileList = [] - } = _this.data; - if (formObject.photopath1 != "") { - var file1 = { - url: app.globalData.url + "static/" + formObject.photopath1 - } - fileList.push(file1) - } - if (formObject.photopath2 != "") { - var file2 = { - url: app.globalData.url + "static/" + formObject.photopath2 - } - fileList.push(file2) - } - if (formObject.photopath3 != "") { - var file3 = { - url: app.globalData.url + "static/" + formObject.photopath3 - } - fileList.push(file3) - } - - _this.setData({ - fileList - }); } - var installtime = 'form.installtimeFmt'; - var dateNow = this.formatDate(); - this.setData({ - installtimeFmt: dateNow, - [installtime]: dateNow, - }); - }, + } + }) - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { + //获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + _this.setData({ + option1: welltypeArr + }) + } + } +}) - }, + //跳转时带入参数返回哪页 + if (options.pageName) { + this.setData({ + pageName: options.pageName + }) + } + //跳转时带入参数设备的安装信息 + if (wx.getStorageSync('resultObject')) { + var formObject = wx.getStorageSync('resultObject') + _this.setData({ + form: formObject, + detail: formObject + }) - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { + _this.setData({ + ['form.installperson']: app.globalData.userName, + ['form.installtimeFmt']: "", + ['form.workmsg']: "", + ['form.description']: "" + }) - }, + const { + fileList = [] + } = _this.data; + if (formObject.photopath1 != "") { + var file1 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath1 + } + fileList.push(file1) + } + if (formObject.photopath2 != "") { + var file2 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath2 + } + fileList.push(file2) + } + if (formObject.photopath3 != "") { + var file3 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath3 + } + fileList.push(file3) + } + _this.setData({ + fileList + }); + } + var installtime = 'form.installtimeFmt'; + var dateNow = this.formatDate(); + this.setData({ + installtimeFmt: dateNow, + [installtime]: dateNow, + }); + }, - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, - }, + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + wx.removeStorageSync('resultObject') + }, - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, - }, + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { + }, - }, + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { + }, - }, + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { + }, - }, + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + }, - /** - * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true - **/ + /** + * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true + **/ - isNumber: function (val) { + isNumber: function (val) { - var regPos = /^[0-9]*$/; //非负浮点数 - var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数 - if (regPos.test(val) || regNeg.test(val)) { - return false; - } else { - return true; - } + var regPos = /^[0-9]*$/; //非负浮点数 + var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数 + if (regPos.test(val) || regNeg.test(val)) { + return false; + } else { + return true; + } - }, + }, - formValidate() { + formValidate() { - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } - if (this.data.form.wellcode == "") { - wx.showToast({ - icon: 'none', - title: '井编号不能为空!', - }) - return false - } - if (this.data.form.devicetype == "") { - wx.showToast({ - icon: 'none', - title: '设备类型不能为空!', - }) - return false - } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + if (this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '设备编号不能为空!', + }) + return false + } + if (this.data.form.wellcode == "") { + wx.showToast({ + icon: 'none', + title: '井编号不能为空!', + }) + return false + } + if (this.data.form.devicetype == "") { + wx.showToast({ + icon: 'none', + title: '设备类型不能为空!', + }) + return false + } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null || - this.data.form.installperson == '') { - wx.showToast({ - icon: 'none', - title: '运维人员不能为空!', - }) - return false - } - if (this.data.form.project == "") { - wx.showToast({ - icon: 'none', - title: '所属项目不能为空!', - }) - return false - } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } + if (this.data.form.installperson == null || + this.data.form.installperson == '') { + wx.showToast({ + icon: 'none', + title: '运维人员不能为空!', + }) + return false + } + if (this.data.form.project == "") { + wx.showToast({ + icon: 'none', + title: '所属项目不能为空!', + }) + return false + } - if (this.data.form.welldepth != null) { - if (this.isNumber(this.data.form.welldepth)) { - wx.showToast({ - icon: 'none', - title: '井深必须为数值!', - }) - return false - } - } - if (this.data.form.installheigt != null) { - if (this.isNumber(this.data.form.installheigt)) { - wx.showToast({ - icon: 'none', - title: '到井口距离必须为数值!', - }) - return false - } - } - - return true; - }, - - changeMsg: function () { - var formNew = this.data.form; - var formOld = JSON.parse(this.data.detail); - var descpNew = ""; - if (formNew.devcode != formOld.devcode) { - descpNew += "修改设备编号,原编号:" + formOld.devcode + ",新编号:" + formNew.devcode + ";" - } - if (formNew.devicetype != formOld.devicetype) { - descpNew += "修改设备类型,原设备类型:" + formOld.devicetype + ",新设备类型:" + formNew.devicetype + ";" - } - if (formNew.area != formOld.area) { - descpNew += "修改区,原区:" + formOld.area + ",新区:" + formNew.area + ";" - } - if (formNew.street != formOld.street) { - descpNew += "修改街道,原街道:" + formOld.street + ",新街道:" + formNew.street + ";" - } - if (formNew.wellname != formOld.wellname) { - descpNew += "修改井名称,原井名称:" + formOld.wellname + ",新井名称:" + formNew.wellname + ";" - } - if (formNew.factory != formOld.factory) { - descpNew += "修改权属单位,原权属单位:" + formOld.factory + ",新权属单位:" + formNew.factory + ";" - } - if (formNew.installheigt != formOld.installheigt) { - descpNew += "修改井口距离,原井口距离:" + formOld.installheigt + ",新井口距离:" + formNew.installheigt + ";" - } - if (formNew.installperson != formOld.installperson) { - descpNew += "修改运维人员,原运维人员:" + formOld.installperson + ",新运维人员:" + formNew.installperson + ";" - } - if (formNew.latitude != formOld.latitude) { - descpNew += "修改纬度,原纬度:" + formOld.latitude + ",新纬度:" + formNew.latitude + ";" - } - if (formNew.longitude != formOld.longitude) { - descpNew += "修改经度,原经度:" + formOld.longitude + ",新经度:" + formNew.longitude + ";" - } - if (formNew.position != formOld.position) { - descpNew += "修改位置描述,原位置:" + formOld.position + ",新位置:" + formNew.position + ";" - } - if (formNew.wellcode != formOld.wellcode) { - descpNew += "修改井编号,原编号:" + formOld.wellcode + ",新编号:" + formNew.wellcode + ";" - } - if (formNew.welldepth != formOld.welldepth) { - descpNew += "修改井深,原井深:" + formOld.welldepth + ",新井深:" + formNew.welldepth + ";" - } - if (formNew.welltype != formOld.welltype) { - descpNew += "修改井类型,原井类型:" + formOld.welltype + ",新井类型:" + formNew.welltype + ";" - } - if (formNew.project != formOld.project) { - descpNew += "修改所属项目,原项目:" + formOld.project + ",新项目:" + formNew.project + ";" - } - if (this.data.photopath1 != formOld.photopath1 || - this.data.photopath2 != formOld.photopath2 || - this.data.photopath3 != formOld.photopath3) { - descpNew += "修改照片;" - } - if ("" != formNew.description) { - descpNew += formNew.description; - } - this.setData({ - ['form.description']: descpNew + if (this.data.form.welldepth != null) { + if (this.isNumber(this.data.form.welldepth)) { + wx.showToast({ + icon: 'none', + title: '井深必须为数值!', }) - }, + return false + } + } + if (this.data.form.installheigt != null) { + if (this.isNumber(this.data.form.installheigt)) { + wx.showToast({ + icon: 'none', + title: '到井口距离必须为数值!', + }) + return false + } + } - formSubmit: function (event) { + return true; + }, - if (!this.formValidate()) { - return false; - } - this.changeMsg(); - var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDeviceLog', - data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceLog/add" - }, - }).then(res => { - // var resultObj=JSON.parse(res.result); - if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - if (res.confirm) { - wx.switchTab({ - url: that.data.pageName - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) - } - }).catch(err => { - console.error(err) - wx.showToast({ - title: "提交失败", - }) - }) - }, - confirm(event) { - var that = this; - var formValue = event.detail.value; - var formName = event.target.dataset.id; - var fromN = 'form.' + [formName]; - that.setData({ - [fromN]: formValue - }) - }, + //获取与上次修改的信息 + changeMsg: function () { + var formNew = this.data.form; + console.log(this.data.detail) + var formOld = JSON.parse(this.data.detail); + var descpNew = ""; + if (formNew.devcode != formOld.devcode) { + descpNew += "修改设备编号,原值:" + formOld.devcode + ",新值:" + formNew.devcode + ";" + } + if (formNew.devicetype != formOld.devicetype) { + descpNew += "修改设备类型,原值:" + formOld.devicetype + ",新值:" + formNew.devicetype + ";" + } + if (formNew.area != formOld.area) { + descpNew += "修改区,原值:" + formOld.area + ",新值:" + formNew.area + ";" + } + if (formNew.street != formOld.street) { + descpNew += "修改街道,原值:" + formOld.street + ",新值:" + formNew.street + ";" + } + if (formNew.wellname != formOld.wellname) { + descpNew += "修改井名称,原值:" + formOld.wellname + ",新值:" + formNew.wellname + ";" + } + if (formNew.factory != formOld.factory) { + descpNew += "修改权属单位,原值:" + formOld.factory + ",新值:" + formNew.factory + ";" + } + if (formNew.installheigt != formOld.installheigt) { + descpNew += "修改井口距离,原值:" + formOld.installheigt + ",新值:" + formNew.installheigt + ";" + } + if (formNew.installperson != formOld.installperson) { + descpNew += "修改运维人员,原值:" + formOld.installperson + ",新值:" + formNew.installperson + ";" + } + if (formNew.latitude != formOld.latitude) { + descpNew += "修改纬度,原值:" + formOld.latitude + ",新值:" + formNew.latitude + ";" + } + if (formNew.longitude != formOld.longitude) { + descpNew += "修改经度,原值:" + formOld.longitude + ",新值:" + formNew.longitude + ";" + } + if (formNew.position != formOld.position) { + descpNew += "修改位置描述,原值:" + formOld.position + ",新值:" + formNew.position + ";" + } + if (formNew.wellcode != formOld.wellcode) { + descpNew += "修改井编号,原值:" + formOld.wellcode + ",新值:" + formNew.wellcode + ";" + } + if (formNew.welldepth != formOld.welldepth) { + descpNew += "修改井深,原值:" + formOld.welldepth + ",新值:" + formNew.welldepth + ";" + } + if (formNew.welltype != formOld.welltype) { + descpNew += "修改井类型,原值:" + formOld.welltype + ",新值:" + formNew.welltype + ";" + } + if (formNew.project != formOld.project) { + descpNew += "修改所属项目,原值:" + formOld.project + ",新值:" + formNew.project + ";" + } + if (this.data.form.photopath1 != formOld.photopath1 || + this.data.form.photopath2 != formOld.photopath2 || + this.data.form.photopath3 != formOld.photopath3) { + descpNew += "修改照片;" + } + if ("" != formNew.description) { + descpNew += formNew.description; + } + this.setData({ + ['form.description']: descpNew + }) + }, - scan() { + //提交表单 + formSubmit: function (event) { - wx.scanCode({ - success(res) { - console.log(res) - } - }) + //表单验证 + if (!this.formValidate()) { + return false; + } + //自动生成修改内容 + this.changeMsg(); + //提交权限限制(只有施工人员能修改) + if(app.globalData.role!='repair'){ + wx.showToast({ + icon: 'none', + title: '无权限修改', + duration:2000 + }) + return false + } + var that = this; + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopath = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopath]: fileList[i].url.split("static/")[1] + }) + } + delete that.data.form.installtime + delete that.data.form.createtime + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - paste() { - var _this = this; - wx.getClipboardData({ - success: function (res) { - var longitude = 'form.longitude'; - var latitude = 'form.latitude'; - var longitude84 = 'form.longitude84'; - var latitude84 = 'form.latitude84'; - _this.setData({ - [longitude]: parseFloat(res.data.split(",", 4)[1]).toFixed(6), - [latitude]: parseFloat(res.data.split(",", 4)[0]).toFixed(6), - [longitude84]: "" == (res.data.split(",", 4)[3]) ? "" : parseFloat(res.data.split(",", 4)[3]).toFixed(6), - [latitude84]: "" == (res.data.split(",", 4)[2]) ? "" : parseFloat(res.data.split(",", 4)[2]).toFixed(6), - longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), - latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), - }); - } - }) - }, - selectValue(value) { - var that = this; - var wellType = 'form.welltype'; - that.setData({ - [wellType]: value.detail - }) - }, - selectpersonValue(event) { - var that = this; - var installPerson = 'form.installperson'; - that.setData({ - [installPerson]: event.detail - }) - }, - selectprojectValue(event) { - var that = this; - var project = 'form.project'; - that.setData({ - [project]: event.detail, - showMask: true - }) - }, - open() { - this.setData({ - showMask: true - }) - }, - close() { - this.setData({ - showMask: false - }) - }, - afterRead(event) { - var _this = this; - const { - file - } = event.detail; - const { - fileList = [] - } = _this.data; - var convertpath = ""; - wx.compressImage({ - src: event.detail.file.path, - quality: 25, - success: function (res) { - convertpath = res.tempFilePath; - wx.uploadFile({ - url: app.globalData.httpsUrl + "appDeviceAdd/fileUploadMarker", - filePath:convertpath, - name: 'file', - formData: { - 'text': "编号:" + _this.data.form.devcode + "经度:" + _this.data.form.longitude + "纬度:" + _this.data.form.latitude - }, - header: { - "Content-Type": "multipart/form-data", - 'accept': 'application/json', - }, - success(res) { - if (res.data) { - var url = JSON.parse(res.data); - fileList.push({ - ...file, - url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - }); - _this.setData({ - fileList - }); - } - } + success(res) { + if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + if (res.confirm) { + wx.switchTab({ + url: that.data.pageName }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') } - }) - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // // var base64 = "data:image/png;base64," + wx.getFileSystemManager().readFileSync(convertpath, 'base64'); - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: convertpath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // // wx.cloud.callFunction({ - // // name: 'uploadFile', - // // data: { - // // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // // fileBase64: base64 - // // }, - // // success: function (res) { - // // if (res.result) { - // // fileList.push({ - // // ...file, - // // url: app.globalData.url + "static/" + res.result.data.replace(/\\/g, "/") - // // }); - // // _this.setData({ - // // fileList - // // }); - // // } - // // }, - // // complete: res => { - // // }, - // // }) - // } - // }); + } + }) + } + }, + fail(err) { + wx.showToast({ + title: "提交失败", + }) + } + }) + }, + //报存录入的input信息 + confirm(event) { + var that = this; + var formValue = event.detail.value; + var formName = event.target.dataset.id; + var fromN = 'form.' + [formName]; + that.setData({ + [fromN]: formValue + }) + }, + + //扫码 + scan() { + + wx.scanCode({ + success(res) { + console.log(res) + } + }) + }, + //粘贴经纬度 + paste() { + var _this = this; + wx.getClipboardData({ + success: function (res) { + var longitude = 'form.longitude'; + var latitude = 'form.latitude'; + var longitude84 = 'form.longitude84'; + var latitude84 = 'form.latitude84'; + _this.setData({ + [longitude]: parseFloat(res.data.split(",", 4)[1]).toFixed(6), + [latitude]: parseFloat(res.data.split(",", 4)[0]).toFixed(6), + [longitude84]: "" == (res.data.split(",", 4)[3]) ? "" : parseFloat(res.data.split(",", 4)[3]).toFixed(6), + [latitude84]: "" == (res.data.split(",", 4)[2]) ? "" : parseFloat(res.data.split(",", 4)[2]).toFixed(6), + longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), + latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), + }); + } + }) + }, + selectValue(value) { + var that = this; + var wellType = 'form.welltype'; + that.setData({ + [wellType]: value.detail + }) + }, + //运维人员默认为登录人 + // selectpersonValue(event) { + // var that = this; + // var installPerson = 'form.installperson'; + // that.setData({ + // [installPerson]: event.detail + // }) + // }, + selectprojectValue(event) { + var that = this; + var project = 'form.project'; + that.setData({ + [project]: event.detail, + showMask: true + }) + }, + + open() { + this.setData({ + showMask: true + }) + }, + //隐藏textarea,防止遮挡 + close() { + this.setData({ + showMask: false + }) + }, + //上传照片 + afterRead(event) { + var _this = this; + const { + file + } = event.detail; + const { + fileList = [] + } = _this.data; + var convertpath = ""; + wx.compressImage({ + src: event.detail.file.path, + quality: 25, + success: function (res) { + convertpath = res.tempFilePath; + wx.uploadFile({ + url: app.globalData.httpsUrl + "appDeviceAdd/fileUploadMarker", + filePath: convertpath, + name: 'file', + formData: { + 'text': "编号:" + _this.data.form.devcode + "经度:" + _this.data.form.longitude + "纬度:" + _this.data.form.latitude }, - deletePhoto(event) { - var that = this - var image_index = event.detail.index - var fileList_new = that.data.fileList; - wx.showModal({ - content: '确定删除照片?', - success: function (res) { - if (res.confirm) { - fileList_new.splice(image_index, 1); - that.setData({ - fileList: fileList_new - }) - wx.cloud.callFunction({ - name: 'deletePhoto', - data: { - url: app.globalData.url + "appDeviceLog/deletePhoto", - devcode: that.data.form.devcode, - pathIndex: image_index - }, - success: function (res) {}, - complete: res => {}, - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + "Content-Type": "multipart/form-data", + 'accept': 'application/json', }, - }) \ No newline at end of file + success(res) { + if (res.data) { + var url = JSON.parse(res.data); + fileList.push({ + ...file, + url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") + }); + _this.setData({ + fileList + }); + } + } + }) + } + }) + }, + //删除照片 + deletePhoto(event) { + var that = this + var image_index = event.detail.index + var fileList_new = that.data.fileList; + wx.showModal({ + content: '确定删除照片?', + success: function (res) { + if (res.confirm) { + fileList_new.splice(image_index, 1); + that.setData({ + fileList: fileList_new + }) + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deletePhoto", + data: { + devcode: that.data.form.devcode + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) {} + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } +}) \ No newline at end of file diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.wxml b/miniprogram/pages/addDevicelog/addDeviceLog.wxml index 38620d4..b10cc7d 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.wxml +++ b/miniprogram/pages/addDevicelog/addDeviceLog.wxml @@ -1,15 +1,21 @@ - + + + + + - + - - + + - - + + - + @@ -39,24 +45,25 @@ - - - + + + - + - + + @@ -64,7 +71,7 @@ - + @@ -79,9 +86,9 @@ - + - 保存 + 保存 diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.wxss b/miniprogram/pages/addDevicelog/addDeviceLog.wxss index ee0b75c..08d5fd7 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.wxss +++ b/miniprogram/pages/addDevicelog/addDeviceLog.wxss @@ -24,6 +24,17 @@ display: flex; align-items: center; } +.map-view{ + width: 750rpx; + height: 485rpx; + position: fixed; + top: 0px; + left: 0px; + z-index: 999; +} +.content{ + margin-top: 495rpx; +} .left { width: 210rpx; diff --git a/miniprogram/pages/addFunction/addFunction.js b/miniprogram/pages/addFunction/addFunction.js deleted file mode 100644 index 4966be3..0000000 --- a/miniprogram/pages/addFunction/addFunction.js +++ /dev/null @@ -1,60 +0,0 @@ -// pages/addFunction/addFunction.js - -const code = `// 云函数入口函数 -exports.main = (event, context) => { - console.log(event) - console.log(context) - return { - sum: event.a + event.b - } -}` - -Page({ - - data: { - result: '', - canIUseClipboard: wx.canIUse('setClipboardData'), - }, - - onLoad: function (options) { - - }, - - copyCode: function() { - wx.setClipboardData({ - data: code, - success: function () { - wx.showToast({ - title: '复制成功', - }) - } - }) - }, - - testFunction() { - wx.cloud.callFunction({ - name: 'sum', - data: { - a: 1, - b: 2 - }, - success: res => { - wx.showToast({ - title: '调用成功', - }) - this.setData({ - result: JSON.stringify(res.result) - }) - }, - fail: err => { - wx.showToast({ - icon: 'none', - title: '调用失败', - }) - console.error('[云函数] [sum] 调用失败:', err) - } - }) - }, - -}) - diff --git a/miniprogram/pages/addFunction/addFunction.json b/miniprogram/pages/addFunction/addFunction.json deleted file mode 100644 index a9a50c5..0000000 --- a/miniprogram/pages/addFunction/addFunction.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "navigationBarTitleText": "云函数指引", - "usingComponents": {} -} \ No newline at end of file diff --git a/miniprogram/pages/addFunction/addFunction.wxml b/miniprogram/pages/addFunction/addFunction.wxml deleted file mode 100644 index 3a10626..0000000 --- a/miniprogram/pages/addFunction/addFunction.wxml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - 测试云函数 - - - 期望输出:{"sum":3} - - - 调用结果:{{result}} - - - - - 新增云函数 - 1. 在云函数根目录 cloudfunctions 上右键选择新建云函数,命名为 sum - 2. 在创建的 cloudfunctions/sum/index.js 文件中添加如下代码 - - - 3. 在 cloudfunctions/sum 目录上右键上传并部署 - 4. 点击测试云函数测试 - 5. 打开云开发云函数管理页,选择 sum 云函数 - 6. 查看 sum 的调用日志 - 进阶:可在云函数中使用 wx-server-sdk 操作数据库,文件存储和调用其他云函数,详见文档 - - - diff --git a/miniprogram/pages/addFunction/addFunction.wxss b/miniprogram/pages/addFunction/addFunction.wxss deleted file mode 100644 index 7ac8619..0000000 --- a/miniprogram/pages/addFunction/addFunction.wxss +++ /dev/null @@ -1,3 +0,0 @@ -/* pages/addFunction/addFunction.wxss */ - -@import "../../style/guide.wxss"; \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.js b/miniprogram/pages/applog/applog.js index 0e8c185..189e61f 100644 --- a/miniprogram/pages/applog/applog.js +++ b/miniprogram/pages/applog/applog.js @@ -13,98 +13,25 @@ isSeach: "false", params: {}, total: 0, - show: false + show: false, + delBtnWidth: 100, //删除按钮宽度单位(rpx) + activeIndex: -1, + list_style: '' }, - - touchE: function (e) { - // console.log(e); - var that = this - if (e.changedTouches.length == 1) { - //手指移动结束后触摸点位置的X坐标 - var endX = e.changedTouches[0].clientX; - //触摸开始与结束,手指移动的距离 - var disX = that.data.startX - endX; - var delBtnWidth = that.data.delBtnWidth; - //如果距离小于删除按钮的1/2,不显示删除按钮 - var txtStyle = disX > delBtnWidth / 2 ? "left:-" + delBtnWidth + "rpx" : "left:0rpx"; - - //获取手指触摸的是哪一项 - var index = e.currentTarget.dataset.index; - var list = that.data.deviceloglist; - list[index].txtStyle = txtStyle; - //更新列表的状态 - that.setData({ - deviceloglist: list - }); - } - }, - //手指触摸动作开始 记录起点X坐标 - touchstart: function (e) { - //开始触摸时 重置所有删除 - this.data.deviceloglist.forEach(function (v, i) { - if (v.isTouchMove) //只操作为true的 - v.isTouchMove = false; - }) - this.setData({ - startX: e.changedTouches[0].clientX, - startY: e.changedTouches[0].clientY, - deviceloglist: this.data.deviceloglist - }) - }, - //滑动事件处理 - touchmove: function (e) { - var that = this, - index = e.currentTarget.dataset.index, //当前索引 - startX = that.data.startX, //开始X坐标 - startY = that.data.startY, //开始Y坐标 - touchMoveX = e.changedTouches[0].clientX, //滑动变化坐标 - touchMoveY = e.changedTouches[0].clientY, //滑动变化坐标 - //获取滑动角度 - angle = that.angle({ - X: startX, - Y: startY - }, { - X: touchMoveX, - Y: touchMoveY - }); - that.data.deviceloglist.forEach(function (v, i) { - v.isTouchMove = false - //滑动超过30度角 return - if (Math.abs(angle) > 30) return; - if (i == index) { - if (touchMoveX > startX) //右滑 - v.isTouchMove = false - else //左滑 - v.isTouchMove = true - } - }) - //更新数据 - that.setData({ - deviceloglist: that.data.deviceloglist - }) - }, - /** - * 计算滑动角度 - * @param {Object} start 起点坐标 - * @param {Object} end 终点坐标 - */ - angle: function (start, end) { - var _X = end.X - start.X, - _Y = end.Y - start.Y - //返回角度 /Math.atan()返回数字的反正切值 - return 360 * Math.atan(_Y / _X) / (2 * Math.PI); - }, - /** - * 生命周期函数--监听页面加载var_this=this; - */ onLoad: function (options) { - if (options.params) { this.setData({ params: JSON.parse(options.params), isSeach: "true" }) this.initPages() + }else{ + this.setData({ + show: false + }) + //清空参数,重新加载 + this.clearParams(); + this.initPages(); } }, @@ -116,20 +43,33 @@ }, + //点击tabBar事件 + onTabItemTap(item) { + //隐藏历史显示总记录条数 + this.setData({ + show: false + }) + //清空参数,重新加载 + this.clearParams(); + this.initPages(); + }, + + /** * 生命周期函数--监听页面显示 */ onShow: function (options) { - this.setData({ - show:false - }) - if (this.data.isSeach == "false") { - this.clearParams(); - this.initPages(); - } - this.setData({ - isSeach: "false" - }) + + // this.setData({ + // show: false + // }) + // if (this.data.isSeach == "false") { + // this.clearParams(); + // this.initPages(); + // } + // this.setData({ + // isSeach: "false" + // }) }, /** @@ -167,6 +107,119 @@ }, + + //手指触摸动作开始 记录起点X坐标 + touchstart: function (e) { + //开始触摸时 重置所有删除 + this.data.deviceloglist.forEach(function (v, i) { + if (v.isTouchMove) //只操作为true的 + v.isTouchMove = false; + }) + this.setData({ + startX: e.changedTouches[0].clientX, + startY: e.changedTouches[0].clientY, + deviceloglist: this.data.deviceloglist + }) + }, + + //滑动事件处理 + touchmove: function (e) { + var that = this, + index = e.currentTarget.dataset.index, //当前索引 + startX = that.data.startX, //开始X坐标 + startY = that.data.startY, //开始Y坐标 + touchMoveX = e.changedTouches[0].clientX, //滑动变化坐标 + touchMoveY = e.changedTouches[0].clientY, //滑动变化坐标 + //获取滑动角度 + angle = that.angle({ + X: startX, + Y: startY + }, { + X: touchMoveX, + Y: touchMoveY + }); + that.data.deviceloglist.forEach(function (v, i) { + // v.isTouchMove = false + //滑动超过30度角 return + if (Math.abs(angle) > 30) return; + if (i == index) { + if (touchMoveX > startX) //右滑 + v.isTouchMove = false + else //左滑 + v.isTouchMove = true + } + }) + //更新数据 + that.setData({ + deviceloglist: that.data.deviceloglist + }) + }, + + /** + * 计算滑动角度 + * @param {Object} start 起点坐标 + * @param {Object} end 终点坐标 + */ + angle: function (start, end) { + var _X = end.X - start.X, + _Y = end.Y - start.Y + //返回角度 /Math.atan()返回数字的反正切值 + return 360 * Math.atan(_Y / _X) / (2 * Math.PI); + }, + + //删除事件 + delItem: function (e) { + if(app.globalData.role!='repair'){ + wx.showToast({ + icon: 'none', + title: '无权限删除', + duration:2000 + }) + return false + } + var that = this + wx.showModal({ + content: '是否删除?', + success: function (res) { + if (res.confirm) { + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/delete", + data: { + appDeviceAddId: e.currentTarget.dataset.devid + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if(res.data.code=='200'){ + that.data.deviceloglist.splice(e.currentTarget.dataset.index, 1) + that.setData({ + deviceloglist: that.data.deviceloglist, + total: that.data.deviceloglist.length + }) + wx.showToast({ + title: '删除成功!', + icon: 'none', + duration: 1000 + }) + } + }, + fail(err) { + wx.showToast({ + title: '删除失败!', + icon: 'none', + duration: 2000 + }) + } + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + }, + showLoading: function (message) { if (wx.showLoading) { // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 @@ -199,95 +252,105 @@ deviceloglist: [] }) }, + //查询列表数据 initPages: function () { var that = this + that.setData({ + show: false + }) var offsetValue = that.data.deviceloglist.length % 15 > 0 ? parseInt(that.data.deviceloglist.length / 15) + 2 : parseInt(that.data.deviceloglist.length / 15) + 1 - wx.cloud.callFunction({ - name: 'devicelog', + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/listPage", data: { devcode: that.data.params.devcode, devtype: that.data.params.devtype, installtimeFmt: that.data.params.installtimeFmt, project: that.data.params.project, installPerson: that.data.params.installPerson, - url: app.globalData.url + "appDeviceLog/listPage", limit: 15, offset: offsetValue }, - }).then(res => { - if (res.result.data.rows.length > 0) { - var resultJson = res.result - that.setData({ - deviceloglist: that.data.deviceloglist.concat(resultJson.data.rows) - }) - } else if (that.data.deviceloglist.length > 0) { - that.setData({ - show: true, - total: that.data.deviceloglist.length - }) - wx.showToast({ - title: '数据已全部加载完', - icon: 'none', - duration: 2000 - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.data.rows.length > 0) { + var resultJson = res.data + var listArr = resultJson.data.rows + listArr.forEach(function (v, i) { + listArr[i]['isTouchMove'] = false + }) + that.setData({ + deviceloglist: that.data.deviceloglist.concat(listArr) + }) + } else if (that.data.deviceloglist.length > 0) { + that.setData({ + show: true, + total: that.data.deviceloglist.length + }) + wx.showToast({ + title: '数据已全部加载完', + icon: 'none', + duration: 2000 + }) + } + if (offsetValue == 1 && res.data.data.rows.length < 15) { + that.setData({ + show: true, + total: that.data.deviceloglist.length + }) + } } - if(offsetValue==1&&res.result.data.rows.length<15){ - that.setData({ - show: true, - total: that.data.deviceloglist.length - }) - } - // console.log(res); - }).catch(err => { - console.error(err); }) + }, addDetail: function (event) { - this.showLoading("数据请求中..."); - wx.cloud.callFunction({ - name: 'deviceDetail', + var that = this + that.showLoading("数据请求中..."); + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deviceDetail", data: { devcode: event.target.dataset.devcode, - url: app.globalData.url + "appDeviceLog/deviceDetail", }, - }).then(res => { - this.hideLoading(); - var resultObject = JSON.parse(res.result); - var pageName = '../applog/applog' - if (resultObject.code == 200) { - wx.navigateTo({ - url: '../addDevicelog/addDeviceLog?detail=' + - JSON.stringify(resultObject.data) + "&pageName=" + pageName - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + that.hideLoading(); + // var resultObject = JSON.parse(res.data); + var resultObject = res.data; + var pageName = '../applog/applog' + if (resultObject.code == 200) { + wx.setStorageSync('resultObject', resultObject.data) + wx.navigateTo({ + url: '../addDevicelog/addDeviceLog?detail=' + "&pageName=" + pageName + }) + } + }, + fail(err) { + that.hideLoading(); } - }).catch(err => { - this.hideLoading() }) + }, add: function (event) { - wx.reLaunch({ - url: '../earth/earth?devcode=' + event.target.dataset.devcode - // url: '../earth/earth' + app.globalData.devcode = event.target.dataset.devcode; + wx.switchTab({ + url: '../earth/earth' }) + // wx.reLaunch({ + // url: '../earth/earth?devcode=' + event.target.dataset.devcode + // // url: '../earth/earth' + // }) }, onSearch: function () { + var _this = this wx.navigateTo({ - url: '../searchLog/searchLog' + url: '../searchLog/searchLog?params=' + JSON.stringify(_this.data.params) }) - }, - // initPages: function () { - // wx.cloud.callFunction({ - // name: 'devicelog' - // }).then(res => { - // var that = this; - // var jsonList = JSON.parse(res.result) - // that.setData({ - // deviceloglist: jsonList.data.rows - // }) - // console.log(res); - // }).catch(err => { - // console.error(err); - // }) - // } + } }) \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.wxml b/miniprogram/pages/applog/applog.wxml index e9a2352..2bfd041 100644 --- a/miniprogram/pages/applog/applog.wxml +++ b/miniprogram/pages/applog/applog.wxml @@ -1,54 +1,59 @@ - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {{item.devcode}} {{item.devicetype}} + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + {{item.devcode}} {{item.devicetype}} + + {{item.project}} {{item.installtime}}- {{item.installperson}} - - - - - + + + + + + 删除 - - - + + - 共计:{{total}}台 - + 共计:{{total}}台 + \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.wxss b/miniprogram/pages/applog/applog.wxss index 6d3428b..e6e8983 100644 --- a/miniprogram/pages/applog/applog.wxss +++ b/miniprogram/pages/applog/applog.wxss @@ -22,16 +22,18 @@ position: fixed; width: 100%; top: 0rpx; + z-index: 9999; /* margin-bottom: 100rpx; */ } .log-list { /* height: 100rpx; */ - /* display: flex; */ - + display: flex; + width: 100%; padding: 2px; margin-top: 2px; border-bottom: 1px solid #e5e5e5; + overflow: hidden } @@ -53,23 +55,29 @@ left: 35%; margin: 20rpx } - .del { - width: 90px; + /* display: flex; */ + width: 100rpx; display: flex; flex-direction: column; align-items: center; justify-content: center; - color: #fff; - -webkit-transform: translateX(90px); - transform: translateX(90px); - -webkit-transition: all 0.4s; + /* -webkit-transform: translateX(100rpx); */ + transform: translateX(100rpx); + /* -webkit-transition: all 0.4s; */ transition: all 0.4s; - font-size: 35rpx; + color: #fff; + background-color: #fe3e2f; +} +.logrow{ + width: 100%; + transform: translateX(100rpx); + /* -webkit-transform: translateX(100px); */ + margin-left: -100rpx; } -.touch-move-active .content, +.touch-move-active .logrow, .touch-move-active .del { - -webkit-transform: translateX(0); - transform: translateX(0); +/* -webkit-transform: translateX(0); */ +transform: translateX(0); } \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.js b/miniprogram/pages/deployFunctions/deployFunctions.js deleted file mode 100644 index a76b144..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.js +++ /dev/null @@ -1,66 +0,0 @@ -// pages/deployFunctions/deployFunctions.js -Page({ - - /** - * 页面的初始数据 - */ - data: { - - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - - }, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { - - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - - }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { - - }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { - - } -}) \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.json b/miniprogram/pages/deployFunctions/deployFunctions.json deleted file mode 100644 index 7fbedab..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "navigationBarTitleText": "部署云函数", - "usingComponents": {} -} \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.wxml b/miniprogram/pages/deployFunctions/deployFunctions.wxml deleted file mode 100644 index 462b6b6..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.wxml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - 调用失败 - - - 请检查 login 云函数是否已部署 - - - - - 部署 login 云函数 - 1. 确保已通过工具栏云开发入口开通云开发 - 2. 在 cloudfunctions/login 目录上右键上传并部署 - 3. 回到首页,重新点击获取 openid - - - - diff --git a/miniprogram/pages/deployFunctions/deployFunctions.wxss b/miniprogram/pages/deployFunctions/deployFunctions.wxss deleted file mode 100644 index c8803e6..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.wxss +++ /dev/null @@ -1,7 +0,0 @@ -/* pages/deployFunctions/deployFunctions.wxss */ - -@import "../../style/guide.wxss"; - -.black { - color: black; -} \ No newline at end of file diff --git a/cloudfunctions/project.config.json b/cloudfunctions/project.config.json new file mode 100644 index 0000000..2b3119a --- /dev/null +++ b/cloudfunctions/project.config.json @@ -0,0 +1,28 @@ +{ + "appid": "wx2cef527a000f87c9", + "compileType": "miniprogram", + "libVersion": "2.27.3", + "packOptions": { + "ignore": [], + "include": [] + }, + "setting": { + "coverView": true, + "es6": true, + "postcss": true, + "minified": true, + "enhance": true, + "showShadowRootInWxmlPanel": true, + "packNpmRelationList": [], + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + } + }, + "condition": {}, + "editorSetting": { + "tabIndent": "insertSpaces", + "tabSize": 4 + } +} \ No newline at end of file diff --git a/cloudfunctions/project.private.config.json b/cloudfunctions/project.private.config.json new file mode 100644 index 0000000..42ff49d --- /dev/null +++ b/cloudfunctions/project.private.config.json @@ -0,0 +1,7 @@ +{ + "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", + "projectname": "cloudfunctions", + "setting": { + "compileHotReLoad": true + } +} \ No newline at end of file diff --git a/miniprogram/app.js b/miniprogram/app.js index 51d56f3..50a8a54 100644 --- a/miniprogram/app.js +++ b/miniprogram/app.js @@ -18,13 +18,15 @@ // this.globalData = {} }, globalData: { - // url: "http://111.198.10.15:11604/", - httpsUrl: "https://logapi.smartlog.work/", - httpsTestUrl: "https://smartlog.work/prodapi4test/", - url: "http://139.198.18.188:8083/", + httpsUrl: "https://logapi.smartlog.work/", + // httpsUrl: "http://139.198.18.188:8083/", // url: "http://127.0.0.1:8083/", - // httpsUrl: "http://127.0.0.1:8083/", + //httpsUrl: "http://127.0.0.1:8083/", openid: null, - indexCount:1 - }, + indexCount:1, + nickName:"", + userName:"", + role:"", + devcode:"" + } }) diff --git a/miniprogram/app.json b/miniprogram/app.json index d23f798..2b6db76 100644 --- a/miniprogram/app.json +++ b/miniprogram/app.json @@ -1,15 +1,17 @@ { "cloud": true, "pages": [ + "pages/login/login", "pages/indexapp/indexapp", "pages/earth/earth", "pages/applog/applog", "pages/addDevice/addDevice", "pages/addDevicelog/addDeviceLog", - "pages/searchLog/searchLog" + "pages/searchLog/searchLog", + "pages/notice/notice" ], "window": { - "backgroundColor": "#F6F6F6", + "backgroundColor": "#E6D480", "backgroundTextStyle": "light", "navigationBarBackgroundColor": "#FFCF00", "navigationBarTitleText": "智慧施工", @@ -46,11 +48,11 @@ "desc": "你的位置信息将用于小程序位置接口的效果展示" } }, + "requiredPrivateInfos": ["getLocation", "chooseLocation"], "networkTimeout": { "request": 30000, "connectSocket": 30000, "uploadFile": 30000, "downloadFile": 30000 - }, - "style": "v2" + } } \ No newline at end of file diff --git a/miniprogram/images/applocat.png b/miniprogram/images/applocat.png new file mode 100644 index 0000000..fe49f54 --- /dev/null +++ b/miniprogram/images/applocat.png Binary files differ diff --git a/miniprogram/images/back.png b/miniprogram/images/back.png new file mode 100644 index 0000000..32ac82d --- /dev/null +++ b/miniprogram/images/back.png Binary files differ diff --git a/miniprogram/images/bottom.png b/miniprogram/images/bottom.png new file mode 100644 index 0000000..d910e98 --- /dev/null +++ b/miniprogram/images/bottom.png Binary files differ diff --git a/miniprogram/images/header.png b/miniprogram/images/header.png new file mode 100644 index 0000000..6ea222e --- /dev/null +++ b/miniprogram/images/header.png Binary files differ diff --git a/miniprogram/images/login.png b/miniprogram/images/login.png index 8b73cc0..6471c46 100644 --- a/miniprogram/images/login.png +++ b/miniprogram/images/login.png Binary files differ diff --git a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss index 5a591fb..c9c35b5 100644 --- a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss +++ b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:100%;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:100%}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file +@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:650rpx;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:600rpx}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file diff --git a/miniprogram/pages/addDevice/addDevice.js b/miniprogram/pages/addDevice/addDevice.js index 2783674..78f00b7 100644 --- a/miniprogram/pages/addDevice/addDevice.js +++ b/miniprogram/pages/addDevice/addDevice.js @@ -1,5 +1,7 @@ // miniprogram/pages/addDevice/addDevice.js // import WxValidate from '../../utils/WxValidate.js' +var QQMapWX = require('../../libs/qqmap-wx-jssdk.js'); +var qqmapsdk; var app = getApp() Page({ @@ -11,32 +13,10 @@ canvasWidth: '', longitude: '', latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], + option1: [], personoption1: [], projectoption: [], + devtypeList:[], show: false, form: { devcode: "", @@ -59,7 +39,10 @@ project: "", area: "", street: "", - wellname: "" + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '', }, fileList: [] }, @@ -117,12 +100,14 @@ var that = this; //初始化表单内容为上次填写值 var cacheForms = wx.getStorageSync('cacheList') - if (cacheForms) { + cacheForms.photopath1='' + cacheForms.photopath2='' + cacheForms.photopath3='' + that.data.fileList=[] that.setData({ form: cacheForms, devcode: cacheForms.devcode, - }) } var form = that.data.form @@ -155,55 +140,89 @@ } }) + +//获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + that.setData({ + option1: welltypeArr + }) + } + } +}) + + //获取人员下拉列表 - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/getUser", + data:{ + tips:'repair' }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data.code == 200) { + var users = res.data.data + var personArr = []; + for (var i = 0; i < users.length; i++) { + var person = { + text: users[i].name, + value: users[i].name + }; + personArr.push(person); + } + that.setData({ + personoption1: personArr + }) } - that.setData({ - personoption1: personArr - }) } - }).catch(err => { - console.error(err); - }) + }) + - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - that.setData({ - projectoption: projectArr - }) + success(res){ + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); + } + that.setData({ + projectoption: projectArr + }) + } } - }).catch(err => { - console.error(err); - }) + }) + var installtime = 'form.installtimeFmt'; var dateNow = this.formatDate(); this.setData({ @@ -211,8 +230,40 @@ installtimeFmt: dateNow, [installtime]: dateNow, }); + + + + /** + * 获取设备类型下拉列表 + */ + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/deviceType", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var TypeList = res.data.data + var typeArr = []; + for (var i = 0; i < TypeList.length; i++) { + var type = { + text: TypeList[i].productName, + value: TypeList[i].productName + }; + typeArr.push(type); + } + that.setData({ + devtypeList: typeArr + }) + } + } + }) }, + + + /** * 生命周期函数--监听页面初次渲染完成 */ @@ -280,29 +331,7 @@ }, - - //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 - drawText: function (ctx, str, leftWidth, initHeight, titleHeight, canvasWidth) { - var lineWidth = 0; - var lastSubStrIndex = 0; //每次开始截取的字符串的索引 - for (let i = 0; i < str.length; i++) { - lineWidth += ctx.measureText(str[i]).width; - if (lineWidth > canvasWidth) { - ctx.fillText(str.substring(lastSubStrIndex, i), leftWidth, initHeight); //绘制截取部分 - initHeight = initHeight + leftWidth * 2; //22为字体的高度 - lineWidth = 0; - lastSubStrIndex = i; - // titleHeight += 40; - } - if (i == str.length - 1) { //绘制剩余部分 - ctx.fillText(str.substring(lastSubStrIndex, i + 1), leftWidth, initHeight); - } - } - // // 标题border-bottom 线距顶部距离 - // titleHeight = titleHeight + 10; - // return titleHeight - }, - + //验证表单 formValidate() { if (this.data.form.devcode == "") { @@ -312,27 +341,20 @@ }) return false } - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } if (this.data.form.wellcode == "") { wx.showToast({ icon: 'none', @@ -348,22 +370,10 @@ }) return false } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null) { + + if (this.data.form.installperson == "") { wx.showToast({ icon: 'none', title: '安装人员不能为空!', @@ -408,56 +418,90 @@ } return true; }, + //提交表单 formSubmit: function (event) { + console.log(this.data.form) + //表单参数验证 if (!this.formValidate()) { return false; } var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDevice', + //验证设备编号长度 + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/getDevTypeLength", data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceAdd/add" + code: encodeURI(this.data.form.devicetype) }, - }).then(res => { - if (res.result.code == 500) { - wx.showToast({ - title: '设备编号已安装!', - }) - } else if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - //用于回显 - wx.setStorageSync('cacheList', that.data.form) - //提交成功后提示用户操作 - if (res.confirm) { - wx.switchTab({ - url: '../earth/earth' - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (""==res.data.data ||res.data.data == that.data.form.devcode.length) { + that.saveDevice() + } else { //编号位数不对提示 + wx.showToast({ + icon: 'none', + title: '设备编号位数不对!', + duration: 1000 + }) + return false + } } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "提交失败", - }) }) }, + + //保存设备基本信息 + saveDevice() { + var that = this; + //设置照片路径 + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopathForm = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopathForm]: fileList[i].url.split("static/")[1] + }) + } + //表单提交 + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 500) { + wx.showToast({ + title: '设备编号已安装!', + }) + } else if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + //用于回显 + wx.setStorageSync('cacheList', that.data.form) + //提交成功后提示用户操作 + if (res.confirm) { + wx.switchTab({ + url: '../earth/earth' + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } + }, + fail(err) { + wx.showToast({ + title: '提交失败!', + }) + } + }) + }, + + //input 输入框设置值 confirm(event) { var that = this; var formValue = event.detail.value; @@ -466,8 +510,30 @@ that.setData({ [fromN]: formValue }) + //若输入是设备编号,自动获取设备类型 + if('devcode'==formName){ + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", + data: { + devcode: formValue, + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + that.setData({ + [formDevicetype]: res.data + }); + } + } + }) + } }, + //扫描设备获取编号和设备类型 scan() { var _this = this; wx.scanCode({ @@ -477,23 +543,28 @@ _this.setData({ [formdevcode]: devcode }); - wx.cloud.callFunction({ - name: 'findModeCode', + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", data: { devcode: devcode, - url: app.globalData.url + "appDeviceAdd/findModeCodeByCode" }, - }).then(res => { - if (res.result) { - var formDevicetype = 'form.devicetype' - _this.setData({ - [formDevicetype]: res.result - }); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + _this.setData({ + [formDevicetype]: res.data + }); + } } }) } }) }, + //粘贴经纬度 paste() { var _this = this; wx.getClipboardData({ @@ -510,9 +581,11 @@ longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), }); + _this.showAddress(_this.data.form.longitude,_this.data.form.latitude,_this) } }) }, + //设置经类型 selectValue(value) { var that = this; @@ -521,6 +594,16 @@ [wellType]: value.detail }) }, + + //设置设备类型 + selectDevType(event) { + var that = this; + var devtype = 'form.devicetype'; + that.setData({ + [devtype]: event.detail + }) + }, + //设置运维人员 selectpersonValue(event) { var that = this; var installPerson = 'form.installperson'; @@ -528,6 +611,7 @@ [installPerson]: event.detail }) }, + //设置项目 selectprojectValue(event) { var that = this; var project = 'form.project'; @@ -535,8 +619,41 @@ [project]: event.detail }) }, + showAddress :function(longitude, latitude, self) { + // 实例化腾讯地图API核心类 + qqmapsdk = new QQMapWX({ + key: 'BGPBZ-C5O3P-ROUDR-LWC4J-63EKH-V5FRX'//此处使用你自己申请的key + }) + // 腾讯地图调用接口 + qqmapsdk.reverseGeocoder({ + location: { + latitude: latitude, + longitude: longitude + }, + success: function (res) { + self.setData({ + 'form.area':res.result.address.slice(0,res.result.address.indexOf('区')+1), + 'form.street':res.result.address.slice(res.result.address.indexOf('区')+1) + }) + }, + fail: function (res) { + console.log(res); + }, + complete: function (res) { + } + }); + }, + //上传照片 afterRead(event) { var _this = this; + if (_this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '请先填写设备编号!\r\n否则水印中无编号', + duration: 2000 + }) + return false + } const { file } = event.detail; @@ -576,78 +693,8 @@ }) } }) - // 压缩图片 - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // //获取图片尺寸 - // wx.getImageInfo({ - // src: convertpath, - // success(res) { - // _this.setData({ - // canvasHeight: res.height, - // canvasWidth: res.width - // }) - // var ctx = wx.createCanvasContext('firstCanvas') - - // //将图片src放到cancas内,宽高为图片大小 - // ctx.drawImage(convertpath, 0, 0, res.width, res.height) - // //将声明的时间放入canvas - // ctx.setFontSize(30 * (res.width / 750)) //注意:设置文字大小必须放在填充文字之前,否则不生效 - // ctx.setFillStyle('blue') - // var text = "编号:" + _this.data.form.devcode + "\n经度:" + _this.data.form.longitude + "\n纬度:" + _this.data.form.latitude - // // _this.drawText(ctx,text,20, 70, 5, res.width) - // _this.drawText(ctx, text, 15 * (res.width / 750), 70 * (res.width / 750), 5, res.width) - - // // ctx.fillText(text, 0, 40) - // // ctx.strokeText(_this.data.form.devcode, 0, 30) - // //生成水印图 - // ctx.draw(false, function () { - // wx.canvasToTempFilePath({ - // canvasId: 'firstCanvas', - // success: (res) => { - // wx.compressImage({ - // src: res.tempFilePath, - // quality: 25, - // success: function (res) { - // //上传照片至服务器 - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: res.tempFilePath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // } - // }) - // //// - // } - // }) - // }) - // } - // }) - // } - // }); }, + //删除照片 deletePhoto(event) { var image_index = event.detail.index var fileList_new = this.data.fileList; diff --git a/miniprogram/pages/addDevice/addDevice.wxml b/miniprogram/pages/addDevice/addDevice.wxml index b0977e2..f12c254 100644 --- a/miniprogram/pages/addDevice/addDevice.wxml +++ b/miniprogram/pages/addDevice/addDevice.wxml @@ -5,18 +5,30 @@ - + + + + + + + + + + + + + - - + + - - - + + + @@ -29,13 +41,13 @@ - + - + - + - + @@ -54,8 +66,7 @@ - - + @@ -68,8 +79,8 @@ - - + + - 保存 + 保存 \ No newline at end of file diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.js b/miniprogram/pages/addDevicelog/addDeviceLog.js index cdec71b..a0dc6da 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.js +++ b/miniprogram/pages/addDevicelog/addDeviceLog.js @@ -3,681 +3,665 @@ var app = getApp(); Page({ - /** - * 页面的初始数据 - */ - data: { - pageName: '', - showMask: false, - today: new Date().getTime(), - longitude: '', - latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], - personoption1: [], - projectoption: [], - devcode: "", - deviceMode: "", - installtimeFmt: '', - show: false, - form: { - devcode: "", - wellcode: "", - welltype: "", - welldepth: "", - installheigt: "", - installperson: "", - installtimeFmt: "", - photopath: "", - factory: "", - workmsg: "", - position: "", - description: "", - longitude: "", - latitude: "", - longitude84: "", - latitude84: "", - devicetype: "", - project: "", - area: "", - street: "", - wellname: "" - }, - fileList: [], - detail: "" - }, + /** + * 页面的初始数据 + */ + data: { + pageName: '', + showMask: false, + today: new Date().getTime(), + longitude: '', + latitude: '', + option1: [], + personoption1: [], + projectoption: [], + devcode: "", + deviceMode: "", + installtimeFmt: '', + show: false, + form: { + devcode: "", + wellcode: "", + welltype: "", + welldepth: "", + installheigt: "", + installperson: "", + installtimeFmt: "", + photopath: "", + factory: "", + workmsg: "", + position: "", + description: "", + longitude: "", + latitude: "", + longitude84: "", + latitude84: "", + devicetype: "", + project: "", + area: "", + street: "", + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '' + }, + fileList: [], + detail: "", + markers: [{ + id: 100, + // iconPath: "../../images/point.png", + latitude: '', + longitude: '', + // label:'1', + width: 25, + height: 35 + }], + }, - onDisplay() { - this.setData({ - show: true - }); - }, - onClose() { - this.setData({ - show: false - }); - }, - formatDate() { - var date = new Date(); - // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; - var seperator1 = "-"; - var month = date.getMonth() + 1; - var strDate = date.getDate(); - var hour = date.getHours() - var minute = date.getMinutes() - var second = date.getSeconds() - month = month > 9 ? month : "0" + month; - strDate = strDate > 9 ? strDate : "0" + strDate; - hour = hour > 9 ? hour : "0" + hour; - minute = minute > 9 ? minute : "0" + minute; - second = second > 9 ? second : "0" + second; - var currentdate = - date.getFullYear() + - seperator1 + - month + - seperator1 + - strDate + - " " + - hour + ":" + - minute + ":" + - second; - return currentdate; + onDisplay() { + this.setData({ + show: true + }); + }, + onClose() { + this.setData({ + show: false + }); + }, + formatDate() { + var date = new Date(); + // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; + var seperator1 = "-"; + var month = date.getMonth() + 1; + var strDate = date.getDate(); + var hour = date.getHours() + var minute = date.getMinutes() + var second = date.getSeconds() + month = month > 9 ? month : "0" + month; + strDate = strDate > 9 ? strDate : "0" + strDate; + hour = hour > 9 ? hour : "0" + hour; + minute = minute > 9 ? minute : "0" + minute; + second = second > 9 ? second : "0" + second; + var currentdate = + date.getFullYear() + + seperator1 + + month + + seperator1 + + strDate + + " " + + hour + ":" + + minute + ":" + + second; + return currentdate; - }, - onConfirm(event) { - var installtime = 'form.installtimeFmt'; - this.setData({ - show: false, - installtimeFmt: this.formatDate(event.detail), - [installtime]: this.formatDate(event.detail), - }); - }, + }, + onConfirm(event) { + var installtime = 'form.installtimeFmt'; + this.setData({ + show: false, + installtimeFmt: this.formatDate(event.detail), + [installtime]: this.formatDate(event.detail), + }); + }, - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - var _this = this; - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" - }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); - } - _this.setData({ - personoption1: personArr - }) + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + var _this = this; + _this.setData({ + 'markers[0].latitude': Number(wx.getStorageSync('resultObject').latitude) , + 'markers[0].longitude': Number(wx.getStorageSync('resultObject').longitude), + // 'markers[0].label':'10', + 'markers[0].width': 18, + 'markers[0].id':1, + 'markers[0].height': 30, + latitude:Number(wx.getStorageSync('resultObject').latitude), + longitude:Number(wx.getStorageSync('resultObject').longitude) + }) + //获取人员下拉列表 + // wx.request({ + // method: "POST", + // url: app.globalData.httpsUrl + "deviceType/getUser", + // data:{ + // tips:'repair' + // }, + // header: { + // 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + // }, + // success(res) { + // if (res.data.code == 200) { + // var users = res.data.data + // var personArr = []; + // for (var i = 0; i < users.length; i++) { + // var person = { + // text: users[i].name, + // value: users[i].name + // }; + // personArr.push(person); + // } + // _this.setData({ + // personoption1: personArr + // }) + // } + // } + // }) + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); } - }).catch(err => { - console.error(err); - }) - - - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" - }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - _this.setData({ - projectoption: projectArr - }) - } - }).catch(err => { - console.error(err); - }) - - if (options.pageName) { - this.setData({ - pageName: options.pageName - }) - } - - if (options.detail) { - - var formObject = JSON.parse(options.detail); _this.setData({ - form: formObject, - detail: options.detail + projectoption: projectArr }) - - _this.setData({ - ['form.installperson']: "", - ['form.installtimeFmt']: "", - ['form.workmsg']: "", - ['form.description']: "" - }) - - const { - fileList = [] - } = _this.data; - if (formObject.photopath1 != "") { - var file1 = { - url: app.globalData.url + "static/" + formObject.photopath1 - } - fileList.push(file1) - } - if (formObject.photopath2 != "") { - var file2 = { - url: app.globalData.url + "static/" + formObject.photopath2 - } - fileList.push(file2) - } - if (formObject.photopath3 != "") { - var file3 = { - url: app.globalData.url + "static/" + formObject.photopath3 - } - fileList.push(file3) - } - - _this.setData({ - fileList - }); } - var installtime = 'form.installtimeFmt'; - var dateNow = this.formatDate(); - this.setData({ - installtimeFmt: dateNow, - [installtime]: dateNow, - }); - }, + } + }) - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { + //获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + _this.setData({ + option1: welltypeArr + }) + } + } +}) - }, + //跳转时带入参数返回哪页 + if (options.pageName) { + this.setData({ + pageName: options.pageName + }) + } + //跳转时带入参数设备的安装信息 + if (wx.getStorageSync('resultObject')) { + var formObject = wx.getStorageSync('resultObject') + _this.setData({ + form: formObject, + detail: formObject + }) - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { + _this.setData({ + ['form.installperson']: app.globalData.userName, + ['form.installtimeFmt']: "", + ['form.workmsg']: "", + ['form.description']: "" + }) - }, + const { + fileList = [] + } = _this.data; + if (formObject.photopath1 != "") { + var file1 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath1 + } + fileList.push(file1) + } + if (formObject.photopath2 != "") { + var file2 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath2 + } + fileList.push(file2) + } + if (formObject.photopath3 != "") { + var file3 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath3 + } + fileList.push(file3) + } + _this.setData({ + fileList + }); + } + var installtime = 'form.installtimeFmt'; + var dateNow = this.formatDate(); + this.setData({ + installtimeFmt: dateNow, + [installtime]: dateNow, + }); + }, - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, - }, + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + wx.removeStorageSync('resultObject') + }, - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, - }, + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { + }, - }, + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { + }, - }, + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { + }, - }, + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + }, - /** - * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true - **/ + /** + * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true + **/ - isNumber: function (val) { + isNumber: function (val) { - var regPos = /^[0-9]*$/; //非负浮点数 - var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数 - if (regPos.test(val) || regNeg.test(val)) { - return false; - } else { - return true; - } + var regPos = /^[0-9]*$/; //非负浮点数 + var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数 + if (regPos.test(val) || regNeg.test(val)) { + return false; + } else { + return true; + } - }, + }, - formValidate() { + formValidate() { - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } - if (this.data.form.wellcode == "") { - wx.showToast({ - icon: 'none', - title: '井编号不能为空!', - }) - return false - } - if (this.data.form.devicetype == "") { - wx.showToast({ - icon: 'none', - title: '设备类型不能为空!', - }) - return false - } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + if (this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '设备编号不能为空!', + }) + return false + } + if (this.data.form.wellcode == "") { + wx.showToast({ + icon: 'none', + title: '井编号不能为空!', + }) + return false + } + if (this.data.form.devicetype == "") { + wx.showToast({ + icon: 'none', + title: '设备类型不能为空!', + }) + return false + } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null || - this.data.form.installperson == '') { - wx.showToast({ - icon: 'none', - title: '运维人员不能为空!', - }) - return false - } - if (this.data.form.project == "") { - wx.showToast({ - icon: 'none', - title: '所属项目不能为空!', - }) - return false - } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } + if (this.data.form.installperson == null || + this.data.form.installperson == '') { + wx.showToast({ + icon: 'none', + title: '运维人员不能为空!', + }) + return false + } + if (this.data.form.project == "") { + wx.showToast({ + icon: 'none', + title: '所属项目不能为空!', + }) + return false + } - if (this.data.form.welldepth != null) { - if (this.isNumber(this.data.form.welldepth)) { - wx.showToast({ - icon: 'none', - title: '井深必须为数值!', - }) - return false - } - } - if (this.data.form.installheigt != null) { - if (this.isNumber(this.data.form.installheigt)) { - wx.showToast({ - icon: 'none', - title: '到井口距离必须为数值!', - }) - return false - } - } - - return true; - }, - - changeMsg: function () { - var formNew = this.data.form; - var formOld = JSON.parse(this.data.detail); - var descpNew = ""; - if (formNew.devcode != formOld.devcode) { - descpNew += "修改设备编号,原编号:" + formOld.devcode + ",新编号:" + formNew.devcode + ";" - } - if (formNew.devicetype != formOld.devicetype) { - descpNew += "修改设备类型,原设备类型:" + formOld.devicetype + ",新设备类型:" + formNew.devicetype + ";" - } - if (formNew.area != formOld.area) { - descpNew += "修改区,原区:" + formOld.area + ",新区:" + formNew.area + ";" - } - if (formNew.street != formOld.street) { - descpNew += "修改街道,原街道:" + formOld.street + ",新街道:" + formNew.street + ";" - } - if (formNew.wellname != formOld.wellname) { - descpNew += "修改井名称,原井名称:" + formOld.wellname + ",新井名称:" + formNew.wellname + ";" - } - if (formNew.factory != formOld.factory) { - descpNew += "修改权属单位,原权属单位:" + formOld.factory + ",新权属单位:" + formNew.factory + ";" - } - if (formNew.installheigt != formOld.installheigt) { - descpNew += "修改井口距离,原井口距离:" + formOld.installheigt + ",新井口距离:" + formNew.installheigt + ";" - } - if (formNew.installperson != formOld.installperson) { - descpNew += "修改运维人员,原运维人员:" + formOld.installperson + ",新运维人员:" + formNew.installperson + ";" - } - if (formNew.latitude != formOld.latitude) { - descpNew += "修改纬度,原纬度:" + formOld.latitude + ",新纬度:" + formNew.latitude + ";" - } - if (formNew.longitude != formOld.longitude) { - descpNew += "修改经度,原经度:" + formOld.longitude + ",新经度:" + formNew.longitude + ";" - } - if (formNew.position != formOld.position) { - descpNew += "修改位置描述,原位置:" + formOld.position + ",新位置:" + formNew.position + ";" - } - if (formNew.wellcode != formOld.wellcode) { - descpNew += "修改井编号,原编号:" + formOld.wellcode + ",新编号:" + formNew.wellcode + ";" - } - if (formNew.welldepth != formOld.welldepth) { - descpNew += "修改井深,原井深:" + formOld.welldepth + ",新井深:" + formNew.welldepth + ";" - } - if (formNew.welltype != formOld.welltype) { - descpNew += "修改井类型,原井类型:" + formOld.welltype + ",新井类型:" + formNew.welltype + ";" - } - if (formNew.project != formOld.project) { - descpNew += "修改所属项目,原项目:" + formOld.project + ",新项目:" + formNew.project + ";" - } - if (this.data.photopath1 != formOld.photopath1 || - this.data.photopath2 != formOld.photopath2 || - this.data.photopath3 != formOld.photopath3) { - descpNew += "修改照片;" - } - if ("" != formNew.description) { - descpNew += formNew.description; - } - this.setData({ - ['form.description']: descpNew + if (this.data.form.welldepth != null) { + if (this.isNumber(this.data.form.welldepth)) { + wx.showToast({ + icon: 'none', + title: '井深必须为数值!', }) - }, + return false + } + } + if (this.data.form.installheigt != null) { + if (this.isNumber(this.data.form.installheigt)) { + wx.showToast({ + icon: 'none', + title: '到井口距离必须为数值!', + }) + return false + } + } - formSubmit: function (event) { + return true; + }, - if (!this.formValidate()) { - return false; - } - this.changeMsg(); - var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDeviceLog', - data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceLog/add" - }, - }).then(res => { - // var resultObj=JSON.parse(res.result); - if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - if (res.confirm) { - wx.switchTab({ - url: that.data.pageName - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) - } - }).catch(err => { - console.error(err) - wx.showToast({ - title: "提交失败", - }) - }) - }, - confirm(event) { - var that = this; - var formValue = event.detail.value; - var formName = event.target.dataset.id; - var fromN = 'form.' + [formName]; - that.setData({ - [fromN]: formValue - }) - }, + //获取与上次修改的信息 + changeMsg: function () { + var formNew = this.data.form; + console.log(this.data.detail) + var formOld = JSON.parse(this.data.detail); + var descpNew = ""; + if (formNew.devcode != formOld.devcode) { + descpNew += "修改设备编号,原值:" + formOld.devcode + ",新值:" + formNew.devcode + ";" + } + if (formNew.devicetype != formOld.devicetype) { + descpNew += "修改设备类型,原值:" + formOld.devicetype + ",新值:" + formNew.devicetype + ";" + } + if (formNew.area != formOld.area) { + descpNew += "修改区,原值:" + formOld.area + ",新值:" + formNew.area + ";" + } + if (formNew.street != formOld.street) { + descpNew += "修改街道,原值:" + formOld.street + ",新值:" + formNew.street + ";" + } + if (formNew.wellname != formOld.wellname) { + descpNew += "修改井名称,原值:" + formOld.wellname + ",新值:" + formNew.wellname + ";" + } + if (formNew.factory != formOld.factory) { + descpNew += "修改权属单位,原值:" + formOld.factory + ",新值:" + formNew.factory + ";" + } + if (formNew.installheigt != formOld.installheigt) { + descpNew += "修改井口距离,原值:" + formOld.installheigt + ",新值:" + formNew.installheigt + ";" + } + if (formNew.installperson != formOld.installperson) { + descpNew += "修改运维人员,原值:" + formOld.installperson + ",新值:" + formNew.installperson + ";" + } + if (formNew.latitude != formOld.latitude) { + descpNew += "修改纬度,原值:" + formOld.latitude + ",新值:" + formNew.latitude + ";" + } + if (formNew.longitude != formOld.longitude) { + descpNew += "修改经度,原值:" + formOld.longitude + ",新值:" + formNew.longitude + ";" + } + if (formNew.position != formOld.position) { + descpNew += "修改位置描述,原值:" + formOld.position + ",新值:" + formNew.position + ";" + } + if (formNew.wellcode != formOld.wellcode) { + descpNew += "修改井编号,原值:" + formOld.wellcode + ",新值:" + formNew.wellcode + ";" + } + if (formNew.welldepth != formOld.welldepth) { + descpNew += "修改井深,原值:" + formOld.welldepth + ",新值:" + formNew.welldepth + ";" + } + if (formNew.welltype != formOld.welltype) { + descpNew += "修改井类型,原值:" + formOld.welltype + ",新值:" + formNew.welltype + ";" + } + if (formNew.project != formOld.project) { + descpNew += "修改所属项目,原值:" + formOld.project + ",新值:" + formNew.project + ";" + } + if (this.data.form.photopath1 != formOld.photopath1 || + this.data.form.photopath2 != formOld.photopath2 || + this.data.form.photopath3 != formOld.photopath3) { + descpNew += "修改照片;" + } + if ("" != formNew.description) { + descpNew += formNew.description; + } + this.setData({ + ['form.description']: descpNew + }) + }, - scan() { + //提交表单 + formSubmit: function (event) { - wx.scanCode({ - success(res) { - console.log(res) - } - }) + //表单验证 + if (!this.formValidate()) { + return false; + } + //自动生成修改内容 + this.changeMsg(); + //提交权限限制(只有施工人员能修改) + if(app.globalData.role!='repair'){ + wx.showToast({ + icon: 'none', + title: '无权限修改', + duration:2000 + }) + return false + } + var that = this; + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopath = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopath]: fileList[i].url.split("static/")[1] + }) + } + delete that.data.form.installtime + delete that.data.form.createtime + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - paste() { - var _this = this; - wx.getClipboardData({ - success: function (res) { - var longitude = 'form.longitude'; - var latitude = 'form.latitude'; - var longitude84 = 'form.longitude84'; - var latitude84 = 'form.latitude84'; - _this.setData({ - [longitude]: parseFloat(res.data.split(",", 4)[1]).toFixed(6), - [latitude]: parseFloat(res.data.split(",", 4)[0]).toFixed(6), - [longitude84]: "" == (res.data.split(",", 4)[3]) ? "" : parseFloat(res.data.split(",", 4)[3]).toFixed(6), - [latitude84]: "" == (res.data.split(",", 4)[2]) ? "" : parseFloat(res.data.split(",", 4)[2]).toFixed(6), - longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), - latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), - }); - } - }) - }, - selectValue(value) { - var that = this; - var wellType = 'form.welltype'; - that.setData({ - [wellType]: value.detail - }) - }, - selectpersonValue(event) { - var that = this; - var installPerson = 'form.installperson'; - that.setData({ - [installPerson]: event.detail - }) - }, - selectprojectValue(event) { - var that = this; - var project = 'form.project'; - that.setData({ - [project]: event.detail, - showMask: true - }) - }, - open() { - this.setData({ - showMask: true - }) - }, - close() { - this.setData({ - showMask: false - }) - }, - afterRead(event) { - var _this = this; - const { - file - } = event.detail; - const { - fileList = [] - } = _this.data; - var convertpath = ""; - wx.compressImage({ - src: event.detail.file.path, - quality: 25, - success: function (res) { - convertpath = res.tempFilePath; - wx.uploadFile({ - url: app.globalData.httpsUrl + "appDeviceAdd/fileUploadMarker", - filePath:convertpath, - name: 'file', - formData: { - 'text': "编号:" + _this.data.form.devcode + "经度:" + _this.data.form.longitude + "纬度:" + _this.data.form.latitude - }, - header: { - "Content-Type": "multipart/form-data", - 'accept': 'application/json', - }, - success(res) { - if (res.data) { - var url = JSON.parse(res.data); - fileList.push({ - ...file, - url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - }); - _this.setData({ - fileList - }); - } - } + success(res) { + if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + if (res.confirm) { + wx.switchTab({ + url: that.data.pageName }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') } - }) - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // // var base64 = "data:image/png;base64," + wx.getFileSystemManager().readFileSync(convertpath, 'base64'); - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: convertpath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // // wx.cloud.callFunction({ - // // name: 'uploadFile', - // // data: { - // // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // // fileBase64: base64 - // // }, - // // success: function (res) { - // // if (res.result) { - // // fileList.push({ - // // ...file, - // // url: app.globalData.url + "static/" + res.result.data.replace(/\\/g, "/") - // // }); - // // _this.setData({ - // // fileList - // // }); - // // } - // // }, - // // complete: res => { - // // }, - // // }) - // } - // }); + } + }) + } + }, + fail(err) { + wx.showToast({ + title: "提交失败", + }) + } + }) + }, + //报存录入的input信息 + confirm(event) { + var that = this; + var formValue = event.detail.value; + var formName = event.target.dataset.id; + var fromN = 'form.' + [formName]; + that.setData({ + [fromN]: formValue + }) + }, + + //扫码 + scan() { + + wx.scanCode({ + success(res) { + console.log(res) + } + }) + }, + //粘贴经纬度 + paste() { + var _this = this; + wx.getClipboardData({ + success: function (res) { + var longitude = 'form.longitude'; + var latitude = 'form.latitude'; + var longitude84 = 'form.longitude84'; + var latitude84 = 'form.latitude84'; + _this.setData({ + [longitude]: parseFloat(res.data.split(",", 4)[1]).toFixed(6), + [latitude]: parseFloat(res.data.split(",", 4)[0]).toFixed(6), + [longitude84]: "" == (res.data.split(",", 4)[3]) ? "" : parseFloat(res.data.split(",", 4)[3]).toFixed(6), + [latitude84]: "" == (res.data.split(",", 4)[2]) ? "" : parseFloat(res.data.split(",", 4)[2]).toFixed(6), + longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), + latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), + }); + } + }) + }, + selectValue(value) { + var that = this; + var wellType = 'form.welltype'; + that.setData({ + [wellType]: value.detail + }) + }, + //运维人员默认为登录人 + // selectpersonValue(event) { + // var that = this; + // var installPerson = 'form.installperson'; + // that.setData({ + // [installPerson]: event.detail + // }) + // }, + selectprojectValue(event) { + var that = this; + var project = 'form.project'; + that.setData({ + [project]: event.detail, + showMask: true + }) + }, + + open() { + this.setData({ + showMask: true + }) + }, + //隐藏textarea,防止遮挡 + close() { + this.setData({ + showMask: false + }) + }, + //上传照片 + afterRead(event) { + var _this = this; + const { + file + } = event.detail; + const { + fileList = [] + } = _this.data; + var convertpath = ""; + wx.compressImage({ + src: event.detail.file.path, + quality: 25, + success: function (res) { + convertpath = res.tempFilePath; + wx.uploadFile({ + url: app.globalData.httpsUrl + "appDeviceAdd/fileUploadMarker", + filePath: convertpath, + name: 'file', + formData: { + 'text': "编号:" + _this.data.form.devcode + "经度:" + _this.data.form.longitude + "纬度:" + _this.data.form.latitude }, - deletePhoto(event) { - var that = this - var image_index = event.detail.index - var fileList_new = that.data.fileList; - wx.showModal({ - content: '确定删除照片?', - success: function (res) { - if (res.confirm) { - fileList_new.splice(image_index, 1); - that.setData({ - fileList: fileList_new - }) - wx.cloud.callFunction({ - name: 'deletePhoto', - data: { - url: app.globalData.url + "appDeviceLog/deletePhoto", - devcode: that.data.form.devcode, - pathIndex: image_index - }, - success: function (res) {}, - complete: res => {}, - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + "Content-Type": "multipart/form-data", + 'accept': 'application/json', }, - }) \ No newline at end of file + success(res) { + if (res.data) { + var url = JSON.parse(res.data); + fileList.push({ + ...file, + url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") + }); + _this.setData({ + fileList + }); + } + } + }) + } + }) + }, + //删除照片 + deletePhoto(event) { + var that = this + var image_index = event.detail.index + var fileList_new = that.data.fileList; + wx.showModal({ + content: '确定删除照片?', + success: function (res) { + if (res.confirm) { + fileList_new.splice(image_index, 1); + that.setData({ + fileList: fileList_new + }) + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deletePhoto", + data: { + devcode: that.data.form.devcode + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) {} + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } +}) \ No newline at end of file diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.wxml b/miniprogram/pages/addDevicelog/addDeviceLog.wxml index 38620d4..b10cc7d 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.wxml +++ b/miniprogram/pages/addDevicelog/addDeviceLog.wxml @@ -1,15 +1,21 @@ - + + + + + - + - - + + - - + + - + @@ -39,24 +45,25 @@ - - - + + + - + - + + @@ -64,7 +71,7 @@ - + @@ -79,9 +86,9 @@ - + - 保存 + 保存 diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.wxss b/miniprogram/pages/addDevicelog/addDeviceLog.wxss index ee0b75c..08d5fd7 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.wxss +++ b/miniprogram/pages/addDevicelog/addDeviceLog.wxss @@ -24,6 +24,17 @@ display: flex; align-items: center; } +.map-view{ + width: 750rpx; + height: 485rpx; + position: fixed; + top: 0px; + left: 0px; + z-index: 999; +} +.content{ + margin-top: 495rpx; +} .left { width: 210rpx; diff --git a/miniprogram/pages/addFunction/addFunction.js b/miniprogram/pages/addFunction/addFunction.js deleted file mode 100644 index 4966be3..0000000 --- a/miniprogram/pages/addFunction/addFunction.js +++ /dev/null @@ -1,60 +0,0 @@ -// pages/addFunction/addFunction.js - -const code = `// 云函数入口函数 -exports.main = (event, context) => { - console.log(event) - console.log(context) - return { - sum: event.a + event.b - } -}` - -Page({ - - data: { - result: '', - canIUseClipboard: wx.canIUse('setClipboardData'), - }, - - onLoad: function (options) { - - }, - - copyCode: function() { - wx.setClipboardData({ - data: code, - success: function () { - wx.showToast({ - title: '复制成功', - }) - } - }) - }, - - testFunction() { - wx.cloud.callFunction({ - name: 'sum', - data: { - a: 1, - b: 2 - }, - success: res => { - wx.showToast({ - title: '调用成功', - }) - this.setData({ - result: JSON.stringify(res.result) - }) - }, - fail: err => { - wx.showToast({ - icon: 'none', - title: '调用失败', - }) - console.error('[云函数] [sum] 调用失败:', err) - } - }) - }, - -}) - diff --git a/miniprogram/pages/addFunction/addFunction.json b/miniprogram/pages/addFunction/addFunction.json deleted file mode 100644 index a9a50c5..0000000 --- a/miniprogram/pages/addFunction/addFunction.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "navigationBarTitleText": "云函数指引", - "usingComponents": {} -} \ No newline at end of file diff --git a/miniprogram/pages/addFunction/addFunction.wxml b/miniprogram/pages/addFunction/addFunction.wxml deleted file mode 100644 index 3a10626..0000000 --- a/miniprogram/pages/addFunction/addFunction.wxml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - 测试云函数 - - - 期望输出:{"sum":3} - - - 调用结果:{{result}} - - - - - 新增云函数 - 1. 在云函数根目录 cloudfunctions 上右键选择新建云函数,命名为 sum - 2. 在创建的 cloudfunctions/sum/index.js 文件中添加如下代码 - - - 3. 在 cloudfunctions/sum 目录上右键上传并部署 - 4. 点击测试云函数测试 - 5. 打开云开发云函数管理页,选择 sum 云函数 - 6. 查看 sum 的调用日志 - 进阶:可在云函数中使用 wx-server-sdk 操作数据库,文件存储和调用其他云函数,详见文档 - - - diff --git a/miniprogram/pages/addFunction/addFunction.wxss b/miniprogram/pages/addFunction/addFunction.wxss deleted file mode 100644 index 7ac8619..0000000 --- a/miniprogram/pages/addFunction/addFunction.wxss +++ /dev/null @@ -1,3 +0,0 @@ -/* pages/addFunction/addFunction.wxss */ - -@import "../../style/guide.wxss"; \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.js b/miniprogram/pages/applog/applog.js index 0e8c185..189e61f 100644 --- a/miniprogram/pages/applog/applog.js +++ b/miniprogram/pages/applog/applog.js @@ -13,98 +13,25 @@ isSeach: "false", params: {}, total: 0, - show: false + show: false, + delBtnWidth: 100, //删除按钮宽度单位(rpx) + activeIndex: -1, + list_style: '' }, - - touchE: function (e) { - // console.log(e); - var that = this - if (e.changedTouches.length == 1) { - //手指移动结束后触摸点位置的X坐标 - var endX = e.changedTouches[0].clientX; - //触摸开始与结束,手指移动的距离 - var disX = that.data.startX - endX; - var delBtnWidth = that.data.delBtnWidth; - //如果距离小于删除按钮的1/2,不显示删除按钮 - var txtStyle = disX > delBtnWidth / 2 ? "left:-" + delBtnWidth + "rpx" : "left:0rpx"; - - //获取手指触摸的是哪一项 - var index = e.currentTarget.dataset.index; - var list = that.data.deviceloglist; - list[index].txtStyle = txtStyle; - //更新列表的状态 - that.setData({ - deviceloglist: list - }); - } - }, - //手指触摸动作开始 记录起点X坐标 - touchstart: function (e) { - //开始触摸时 重置所有删除 - this.data.deviceloglist.forEach(function (v, i) { - if (v.isTouchMove) //只操作为true的 - v.isTouchMove = false; - }) - this.setData({ - startX: e.changedTouches[0].clientX, - startY: e.changedTouches[0].clientY, - deviceloglist: this.data.deviceloglist - }) - }, - //滑动事件处理 - touchmove: function (e) { - var that = this, - index = e.currentTarget.dataset.index, //当前索引 - startX = that.data.startX, //开始X坐标 - startY = that.data.startY, //开始Y坐标 - touchMoveX = e.changedTouches[0].clientX, //滑动变化坐标 - touchMoveY = e.changedTouches[0].clientY, //滑动变化坐标 - //获取滑动角度 - angle = that.angle({ - X: startX, - Y: startY - }, { - X: touchMoveX, - Y: touchMoveY - }); - that.data.deviceloglist.forEach(function (v, i) { - v.isTouchMove = false - //滑动超过30度角 return - if (Math.abs(angle) > 30) return; - if (i == index) { - if (touchMoveX > startX) //右滑 - v.isTouchMove = false - else //左滑 - v.isTouchMove = true - } - }) - //更新数据 - that.setData({ - deviceloglist: that.data.deviceloglist - }) - }, - /** - * 计算滑动角度 - * @param {Object} start 起点坐标 - * @param {Object} end 终点坐标 - */ - angle: function (start, end) { - var _X = end.X - start.X, - _Y = end.Y - start.Y - //返回角度 /Math.atan()返回数字的反正切值 - return 360 * Math.atan(_Y / _X) / (2 * Math.PI); - }, - /** - * 生命周期函数--监听页面加载var_this=this; - */ onLoad: function (options) { - if (options.params) { this.setData({ params: JSON.parse(options.params), isSeach: "true" }) this.initPages() + }else{ + this.setData({ + show: false + }) + //清空参数,重新加载 + this.clearParams(); + this.initPages(); } }, @@ -116,20 +43,33 @@ }, + //点击tabBar事件 + onTabItemTap(item) { + //隐藏历史显示总记录条数 + this.setData({ + show: false + }) + //清空参数,重新加载 + this.clearParams(); + this.initPages(); + }, + + /** * 生命周期函数--监听页面显示 */ onShow: function (options) { - this.setData({ - show:false - }) - if (this.data.isSeach == "false") { - this.clearParams(); - this.initPages(); - } - this.setData({ - isSeach: "false" - }) + + // this.setData({ + // show: false + // }) + // if (this.data.isSeach == "false") { + // this.clearParams(); + // this.initPages(); + // } + // this.setData({ + // isSeach: "false" + // }) }, /** @@ -167,6 +107,119 @@ }, + + //手指触摸动作开始 记录起点X坐标 + touchstart: function (e) { + //开始触摸时 重置所有删除 + this.data.deviceloglist.forEach(function (v, i) { + if (v.isTouchMove) //只操作为true的 + v.isTouchMove = false; + }) + this.setData({ + startX: e.changedTouches[0].clientX, + startY: e.changedTouches[0].clientY, + deviceloglist: this.data.deviceloglist + }) + }, + + //滑动事件处理 + touchmove: function (e) { + var that = this, + index = e.currentTarget.dataset.index, //当前索引 + startX = that.data.startX, //开始X坐标 + startY = that.data.startY, //开始Y坐标 + touchMoveX = e.changedTouches[0].clientX, //滑动变化坐标 + touchMoveY = e.changedTouches[0].clientY, //滑动变化坐标 + //获取滑动角度 + angle = that.angle({ + X: startX, + Y: startY + }, { + X: touchMoveX, + Y: touchMoveY + }); + that.data.deviceloglist.forEach(function (v, i) { + // v.isTouchMove = false + //滑动超过30度角 return + if (Math.abs(angle) > 30) return; + if (i == index) { + if (touchMoveX > startX) //右滑 + v.isTouchMove = false + else //左滑 + v.isTouchMove = true + } + }) + //更新数据 + that.setData({ + deviceloglist: that.data.deviceloglist + }) + }, + + /** + * 计算滑动角度 + * @param {Object} start 起点坐标 + * @param {Object} end 终点坐标 + */ + angle: function (start, end) { + var _X = end.X - start.X, + _Y = end.Y - start.Y + //返回角度 /Math.atan()返回数字的反正切值 + return 360 * Math.atan(_Y / _X) / (2 * Math.PI); + }, + + //删除事件 + delItem: function (e) { + if(app.globalData.role!='repair'){ + wx.showToast({ + icon: 'none', + title: '无权限删除', + duration:2000 + }) + return false + } + var that = this + wx.showModal({ + content: '是否删除?', + success: function (res) { + if (res.confirm) { + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/delete", + data: { + appDeviceAddId: e.currentTarget.dataset.devid + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if(res.data.code=='200'){ + that.data.deviceloglist.splice(e.currentTarget.dataset.index, 1) + that.setData({ + deviceloglist: that.data.deviceloglist, + total: that.data.deviceloglist.length + }) + wx.showToast({ + title: '删除成功!', + icon: 'none', + duration: 1000 + }) + } + }, + fail(err) { + wx.showToast({ + title: '删除失败!', + icon: 'none', + duration: 2000 + }) + } + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + }, + showLoading: function (message) { if (wx.showLoading) { // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 @@ -199,95 +252,105 @@ deviceloglist: [] }) }, + //查询列表数据 initPages: function () { var that = this + that.setData({ + show: false + }) var offsetValue = that.data.deviceloglist.length % 15 > 0 ? parseInt(that.data.deviceloglist.length / 15) + 2 : parseInt(that.data.deviceloglist.length / 15) + 1 - wx.cloud.callFunction({ - name: 'devicelog', + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/listPage", data: { devcode: that.data.params.devcode, devtype: that.data.params.devtype, installtimeFmt: that.data.params.installtimeFmt, project: that.data.params.project, installPerson: that.data.params.installPerson, - url: app.globalData.url + "appDeviceLog/listPage", limit: 15, offset: offsetValue }, - }).then(res => { - if (res.result.data.rows.length > 0) { - var resultJson = res.result - that.setData({ - deviceloglist: that.data.deviceloglist.concat(resultJson.data.rows) - }) - } else if (that.data.deviceloglist.length > 0) { - that.setData({ - show: true, - total: that.data.deviceloglist.length - }) - wx.showToast({ - title: '数据已全部加载完', - icon: 'none', - duration: 2000 - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.data.rows.length > 0) { + var resultJson = res.data + var listArr = resultJson.data.rows + listArr.forEach(function (v, i) { + listArr[i]['isTouchMove'] = false + }) + that.setData({ + deviceloglist: that.data.deviceloglist.concat(listArr) + }) + } else if (that.data.deviceloglist.length > 0) { + that.setData({ + show: true, + total: that.data.deviceloglist.length + }) + wx.showToast({ + title: '数据已全部加载完', + icon: 'none', + duration: 2000 + }) + } + if (offsetValue == 1 && res.data.data.rows.length < 15) { + that.setData({ + show: true, + total: that.data.deviceloglist.length + }) + } } - if(offsetValue==1&&res.result.data.rows.length<15){ - that.setData({ - show: true, - total: that.data.deviceloglist.length - }) - } - // console.log(res); - }).catch(err => { - console.error(err); }) + }, addDetail: function (event) { - this.showLoading("数据请求中..."); - wx.cloud.callFunction({ - name: 'deviceDetail', + var that = this + that.showLoading("数据请求中..."); + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deviceDetail", data: { devcode: event.target.dataset.devcode, - url: app.globalData.url + "appDeviceLog/deviceDetail", }, - }).then(res => { - this.hideLoading(); - var resultObject = JSON.parse(res.result); - var pageName = '../applog/applog' - if (resultObject.code == 200) { - wx.navigateTo({ - url: '../addDevicelog/addDeviceLog?detail=' + - JSON.stringify(resultObject.data) + "&pageName=" + pageName - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + that.hideLoading(); + // var resultObject = JSON.parse(res.data); + var resultObject = res.data; + var pageName = '../applog/applog' + if (resultObject.code == 200) { + wx.setStorageSync('resultObject', resultObject.data) + wx.navigateTo({ + url: '../addDevicelog/addDeviceLog?detail=' + "&pageName=" + pageName + }) + } + }, + fail(err) { + that.hideLoading(); } - }).catch(err => { - this.hideLoading() }) + }, add: function (event) { - wx.reLaunch({ - url: '../earth/earth?devcode=' + event.target.dataset.devcode - // url: '../earth/earth' + app.globalData.devcode = event.target.dataset.devcode; + wx.switchTab({ + url: '../earth/earth' }) + // wx.reLaunch({ + // url: '../earth/earth?devcode=' + event.target.dataset.devcode + // // url: '../earth/earth' + // }) }, onSearch: function () { + var _this = this wx.navigateTo({ - url: '../searchLog/searchLog' + url: '../searchLog/searchLog?params=' + JSON.stringify(_this.data.params) }) - }, - // initPages: function () { - // wx.cloud.callFunction({ - // name: 'devicelog' - // }).then(res => { - // var that = this; - // var jsonList = JSON.parse(res.result) - // that.setData({ - // deviceloglist: jsonList.data.rows - // }) - // console.log(res); - // }).catch(err => { - // console.error(err); - // }) - // } + } }) \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.wxml b/miniprogram/pages/applog/applog.wxml index e9a2352..2bfd041 100644 --- a/miniprogram/pages/applog/applog.wxml +++ b/miniprogram/pages/applog/applog.wxml @@ -1,54 +1,59 @@ - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {{item.devcode}} {{item.devicetype}} + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + {{item.devcode}} {{item.devicetype}} + + {{item.project}} {{item.installtime}}- {{item.installperson}} - - - - - + + + + + + 删除 - - - + + - 共计:{{total}}台 - + 共计:{{total}}台 + \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.wxss b/miniprogram/pages/applog/applog.wxss index 6d3428b..e6e8983 100644 --- a/miniprogram/pages/applog/applog.wxss +++ b/miniprogram/pages/applog/applog.wxss @@ -22,16 +22,18 @@ position: fixed; width: 100%; top: 0rpx; + z-index: 9999; /* margin-bottom: 100rpx; */ } .log-list { /* height: 100rpx; */ - /* display: flex; */ - + display: flex; + width: 100%; padding: 2px; margin-top: 2px; border-bottom: 1px solid #e5e5e5; + overflow: hidden } @@ -53,23 +55,29 @@ left: 35%; margin: 20rpx } - .del { - width: 90px; + /* display: flex; */ + width: 100rpx; display: flex; flex-direction: column; align-items: center; justify-content: center; - color: #fff; - -webkit-transform: translateX(90px); - transform: translateX(90px); - -webkit-transition: all 0.4s; + /* -webkit-transform: translateX(100rpx); */ + transform: translateX(100rpx); + /* -webkit-transition: all 0.4s; */ transition: all 0.4s; - font-size: 35rpx; + color: #fff; + background-color: #fe3e2f; +} +.logrow{ + width: 100%; + transform: translateX(100rpx); + /* -webkit-transform: translateX(100px); */ + margin-left: -100rpx; } -.touch-move-active .content, +.touch-move-active .logrow, .touch-move-active .del { - -webkit-transform: translateX(0); - transform: translateX(0); +/* -webkit-transform: translateX(0); */ +transform: translateX(0); } \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.js b/miniprogram/pages/deployFunctions/deployFunctions.js deleted file mode 100644 index a76b144..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.js +++ /dev/null @@ -1,66 +0,0 @@ -// pages/deployFunctions/deployFunctions.js -Page({ - - /** - * 页面的初始数据 - */ - data: { - - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - - }, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { - - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - - }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { - - }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { - - } -}) \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.json b/miniprogram/pages/deployFunctions/deployFunctions.json deleted file mode 100644 index 7fbedab..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "navigationBarTitleText": "部署云函数", - "usingComponents": {} -} \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.wxml b/miniprogram/pages/deployFunctions/deployFunctions.wxml deleted file mode 100644 index 462b6b6..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.wxml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - 调用失败 - - - 请检查 login 云函数是否已部署 - - - - - 部署 login 云函数 - 1. 确保已通过工具栏云开发入口开通云开发 - 2. 在 cloudfunctions/login 目录上右键上传并部署 - 3. 回到首页,重新点击获取 openid - - - - diff --git a/miniprogram/pages/deployFunctions/deployFunctions.wxss b/miniprogram/pages/deployFunctions/deployFunctions.wxss deleted file mode 100644 index c8803e6..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.wxss +++ /dev/null @@ -1,7 +0,0 @@ -/* pages/deployFunctions/deployFunctions.wxss */ - -@import "../../style/guide.wxss"; - -.black { - color: black; -} \ No newline at end of file diff --git a/miniprogram/pages/earth/earth.js b/miniprogram/pages/earth/earth.js index ae0d3f3..376a6e2 100644 --- a/miniprogram/pages/earth/earth.js +++ b/miniprogram/pages/earth/earth.js @@ -21,19 +21,12 @@ show: false, enableSsatellite: false, windowWidth: 0, - longitude: 113.324520, - latitude: 23.099994, - longitude84: 113.324520, - latitude84: 23.099994, - markers: [{ - id: 0, - iconPath: "../../images/locat.png", - latitude: 23.099994, - longitude: 113.324520, - width: 50, - height: 50 - }], - controls: [], + longitude: "116.627340", + latitude: "39.874390", + longitude84: "", + latitude84: "", + markers: [], + controls: [] }, /** @@ -41,39 +34,13 @@ */ onLoad: function (options) { var that = this; - //获取当前坐标(gcj02) - wx.getLocation({ - type: "gcj02", - altitude: true, - success: function (res) { - that.setData({ - latitude: parseFloat(res.latitude).toFixed(6), - longitude: parseFloat(res.longitude).toFixed(6), - // markers: [{ - // latitude: res.latitude, - // longitude: res.longitude, - // }] - }) - //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 - wx.getLocation({ - type: "wgs84", - altitude: true, - success: function (res) { - that.setData({ - latitude84: parseFloat(res.latitude).toFixed(6), - longitude84: parseFloat(res.longitude).toFixed(6) - }) - } - }) - } - }), - - //设置地图组件 - wx.getSystemInfo({ + //设置地图组件 + wx.getSystemInfo({ success(res) { var windowWidth = res.windowWidth var windowHeight = res.windowHeight var query = wx.createSelectorQuery() + var platform =res.platform query.select('#map').boundingClientRect() query.exec(function (res) { that.setData({ @@ -139,10 +106,20 @@ clickable: true }, { id: 7, - iconPath: '../../images/locat.png', + iconPath: '../../images/applocat.png', position: { - left: res[0].width/2, - top: res[0].height/2, + left: res[0].width / 2 - 20, + top: platform=="ios"?res[0].height / 2 - 80:res[0].height / 2 - 40, + width: 40, + height: 40 + }, + clickable: true + }, { + id: 8, + iconPath: '../../images/back.png', + position: { + left: windowWidth - 40, + top: windowHeight - 140, width: 30, height: 30 }, @@ -150,71 +127,15 @@ }] }) }) - + } - }), + }) + // 实例化API核心类 qqmapsdk = new QQMapWX({ key: 'BGPBZ-C5O3P-ROUDR-LWC4J-63EKH-V5FRX' }) - - if (options.devcode) { - var that = this - var devcode = options.devcode - wx.cloud.callFunction({ - name: 'findListByCodes', - data: { - devcodes: devcode, - url: app.globalData.url + "appDeviceAdd/findListByCodes" - }, - }).then(res => { - if (res.result.code == 200) { - var listResultData = res.result.data; - that.setData({ - listData: listResultData - }) - var markersArr = that.data.markers; - for (var i = 0; i < listResultData.length; i++) { - markersArr = markersArr.concat({ - iconPath: "../../images/locat.png", - id: listResultData[i].id, - callout: { - content: listResultData[i].devcode, - fontSize: '14', - // padding: true, - color: '#00000', - borderColor: '#F4EA2A', - bgColor: '#F4EA2A', - borderWidth: 5, - display: 'ALWAYS', - textAlign: 'center', - // borderRadius: 15 - }, - latitude: listResultData[i].latitude, - longitude: listResultData[i].longitude, - width: 40, - height: 40 - }); - } - this.setData({ - markers: markersArr, - latitude: listResultData[0].latitude, - longitude: listResultData[0].longitude, - marker_latitude: listResultData[0].latitude, - marker_longitude: listResultData[0].longitude, - title: listResultData[0].devcode - }) - } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "无法获取设备地理信息!", - icon: 'none', - duration: 2000 - }) - }) - } }, /** @@ -228,6 +149,97 @@ * 生命周期函数--监听页面显示 */ onShow: function () { + //输入设备编号获取marker位置信息 + var that = this; + if ( app.globalData.devcode!="") { + var devcode = app.globalData.devcode + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/findListByCodes", + data: { + devcodes: devcode, + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + app.globalData.devcode=""; + if (res.data.code == 200) { + var listResultData = res.data.data; + that.setData({ + listData: listResultData + }) + var markersArr = that.data.markers; + for (var i = 0; i < listResultData.length; i++) { + markersArr = markersArr.concat({ + iconPath: "../../images/locat.png", + id: Number(listResultData[i].id), + callout: { + content: "编号:"+listResultData[i].devcode+"\r\n位置:"+listResultData[i].position+"\r\n时间:"+listResultData[i].createtime, + fontSize: '14', + padding: true, + color: '#000000', + borderColor: '#F4EA2A', + bgColor: '#F4EA2A', + borderWidth: 5, + display: 'ALWAYS', + textAlign: 'left', + // borderRadius: 15 + }, + latitude: listResultData[i].latitude, + longitude: listResultData[i].longitude, + width: 40, + height: 40 + }); + } + that.setData({ + markers: markersArr, + latitude: listResultData[0].latitude, + longitude: listResultData[0].longitude, + marker_latitude: listResultData[0].latitude, + marker_longitude: listResultData[0].longitude, + title: listResultData[0].devcode + }) + } + }, + fail(err) { + app.globalData.devcode=""; + wx.showToast({ + title: "无法获取设备地理信息!", + icon: 'none', + duration: 2000 + }) + } + }) +} else { + //获取当前坐标(gcj02) + wx.getLocation({ + type: "gcj02", + altitude: true, + success: function (res) { + that.setData({ + latitude: parseFloat(res.latitude).toFixed(6), + longitude: parseFloat(res.longitude).toFixed(6), + // markers: [{ + // latitude: res.latitude, + // longitude: res.longitude, + // }] + }) + //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 + wx.getLocation({ + type: "wgs84", + altitude: true, + success: function (res) { + that.setData({ + latitude84: parseFloat(res.latitude).toFixed(6), + longitude84: parseFloat(res.longitude).toFixed(6) + }) + } + }) + } + }) +} + }, @@ -265,12 +277,46 @@ onShareAppMessage: function () { }, + + //定位出来 + + locationPosition: function () { + var that = this; + //获取当前坐标(gcj02) + wx.getLocation({ + type: "gcj02", + altitude: true, + success: function (res) { + that.setData({ + latitude: parseFloat(res.latitude).toFixed(6), + longitude: parseFloat(res.longitude).toFixed(6), + // markers: [{ + // latitude: res.latitude, + // longitude: res.longitude + // }] + }) + //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 + wx.getLocation({ + type: "wgs84", + altitude: true, + success: function (res) { + that.setData({ + latitude84: parseFloat(res.latitude).toFixed(6), + longitude84: parseFloat(res.longitude).toFixed(6) + }) + } + }) + } + }) + }, + + //加载地图组件 controltap: function (e) { // console.log(e.controlId); //进入添加设备页 if (1 == e.controlId) { wx.setClipboardData({ - data: this.data.latitude + "," + this.data.longitude+ "," + this.data.latitude84+ "," + this.data.longitude84, + data: this.data.latitude + "," + this.data.longitude + "," + this.data.latitude84 + "," + this.data.longitude84, success: function (res) { wx.getClipboardData({ success: function (res) { @@ -282,6 +328,17 @@ } }) } else if (3 == e.controlId) { + //先定位 + // this.locationPosition() + wx.setClipboardData({ + data: this.data.latitude + "," + this.data.longitude + "," + this.data.latitude84 + "," + this.data.longitude84, + success: function (res) { + wx.showToast({ + title: '坐标已获取', + duration: 1000 + }) + } + }) wx.navigateTo({ url: '../addDevice/addDevice' }) @@ -302,32 +359,15 @@ enableSsatellite: !flag }); } else if (6 == e.controlId) { - var that = this; - //获取当前坐标(gcj02) - wx.getLocation({ - type: "gcj02", - altitude: true, - success: function (res) { - that.setData({ - latitude: parseFloat(res.latitude).toFixed(6), - longitude:parseFloat(res.longitude).toFixed(6), - // markers: [{ - // latitude: res.latitude, - // longitude: res.longitude - // }] - }) - //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 - wx.getLocation({ - type: "wgs84", - altitude: true, - success: function (res) { - that.setData({ - latitude84: parseFloat(res.latitude).toFixed(6), - longitude84: parseFloat(res.longitude).toFixed(6) - }) - } - }) - } + //先清marker + this.setData({ + markers: [] + }) + this.locationPosition() + }else if (8 == e.controlId) { + //跳转日志缓存页 + wx.switchTab({ + url: '../applog/applog', }) } }, @@ -343,63 +383,68 @@ }); }, + //获取设备maker leave() { var that = this; if (that.data.devcodes == "") { return false; } - wx.cloud.callFunction({ - name: 'findListByCodes', + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/findListByCodes", data: { - devcodes: that.data.devcodes, - url: app.globalData.url + "appDeviceAdd/findListByCodes" + devcodes: that.data.devcodes }, - }).then(res => { - if (res.result.code == 200) { - var listResultData = res.result.data; - that.setData({ - listData: listResultData - }) - var markersArr = that.data.markers; - for (var i = 0; i < listResultData.length; i++) { - markersArr = markersArr.concat({ - iconPath: "../../images/locat.png", - id: listResultData[i].id, - callout: { - content: listResultData[i].devcode, - fontSize: '14', - // padding: true, - color: '', - borderColor: '#F4EA2A', - bgColor: '#F4EA2A', - borderWidth: 5, - display: 'ALWAYS', - textAlign: 'center', - // borderRadius: 15 - }, - latitude: listResultData[i].latitude, - longitude: listResultData[i].longitude, - width: 40, - height: 40 - }); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var listResultData = res.data.data; + that.setData({ + listData: listResultData + }) + var markersArr = that.data.markers; + for (var i = 0; i < listResultData.length; i++) { + markersArr = markersArr.concat({ + iconPath: "../../images/locat.png", + id: listResultData[i].id, + callout: { + content: "编号:"+listResultData[i].devcode+"\r\n位置:"+listResultData[i].position+"\r\n时间:"+listResultData[i].createtime, + fontSize: '14', + // padding: true, + color: '#212121', + borderColor: '#F4EA2A', + bgColor: '#F4EA2A', + borderWidth: 5, + display: 'ALWAYS', + textAlign: 'left', + // borderRadius: 15 + }, + latitude: listResultData[i].latitude, + longitude: listResultData[i].longitude, + width: 40, + height: 40 + }); + } + that.setData({ + markers: markersArr, + latitude: listResultData[0].latitude, + longitude: listResultData[0].longitude, + marker_latitude: listResultData[0].latitude, + marker_longitude: listResultData[0].longitude, + title: listResultData[0].devcode + }) } - this.setData({ - markers: markersArr, - latitude: listResultData[0].latitude, - longitude: listResultData[0].longitude, - marker_latitude: listResultData[0].latitude, - marker_longitude: listResultData[0].longitude, - title: listResultData[0].devcode + }, + fail(err) { + wx.showToast({ + title: "无法获取设备地理信息!", + icon: 'none', + duration: 2000 }) } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "无法获取设备地理信息!", - icon: 'none', - duration: 2000 - }) }) }, @@ -422,6 +467,8 @@ } }, + + bindregionchange: function (e) { var that = this if (e.causedBy == "drag") { @@ -445,8 +492,8 @@ that.setData({ latitude: parseFloat(latitude).toFixed(6), longitude: parseFloat(longitude).toFixed(6), - latitude84:"", - longitude84:"", + latitude84: "", + longitude84: "", // markers: markersArr }) // mapCtx.moveToLocation(); @@ -465,16 +512,19 @@ qqmapsdk.search({ keyword: this.data.value, success: function (res) { + console.log(res) if (res && res.data) { _this.setData({ isShow: true, tips: res.data }); } + }, + complete: function (res){ + console.log(res); } }) }, - bindSearch: function (e) { var location = e.target.dataset.location; this.setData({ diff --git a/cloudfunctions/project.config.json b/cloudfunctions/project.config.json new file mode 100644 index 0000000..2b3119a --- /dev/null +++ b/cloudfunctions/project.config.json @@ -0,0 +1,28 @@ +{ + "appid": "wx2cef527a000f87c9", + "compileType": "miniprogram", + "libVersion": "2.27.3", + "packOptions": { + "ignore": [], + "include": [] + }, + "setting": { + "coverView": true, + "es6": true, + "postcss": true, + "minified": true, + "enhance": true, + "showShadowRootInWxmlPanel": true, + "packNpmRelationList": [], + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + } + }, + "condition": {}, + "editorSetting": { + "tabIndent": "insertSpaces", + "tabSize": 4 + } +} \ No newline at end of file diff --git a/cloudfunctions/project.private.config.json b/cloudfunctions/project.private.config.json new file mode 100644 index 0000000..42ff49d --- /dev/null +++ b/cloudfunctions/project.private.config.json @@ -0,0 +1,7 @@ +{ + "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", + "projectname": "cloudfunctions", + "setting": { + "compileHotReLoad": true + } +} \ No newline at end of file diff --git a/miniprogram/app.js b/miniprogram/app.js index 51d56f3..50a8a54 100644 --- a/miniprogram/app.js +++ b/miniprogram/app.js @@ -18,13 +18,15 @@ // this.globalData = {} }, globalData: { - // url: "http://111.198.10.15:11604/", - httpsUrl: "https://logapi.smartlog.work/", - httpsTestUrl: "https://smartlog.work/prodapi4test/", - url: "http://139.198.18.188:8083/", + httpsUrl: "https://logapi.smartlog.work/", + // httpsUrl: "http://139.198.18.188:8083/", // url: "http://127.0.0.1:8083/", - // httpsUrl: "http://127.0.0.1:8083/", + //httpsUrl: "http://127.0.0.1:8083/", openid: null, - indexCount:1 - }, + indexCount:1, + nickName:"", + userName:"", + role:"", + devcode:"" + } }) diff --git a/miniprogram/app.json b/miniprogram/app.json index d23f798..2b6db76 100644 --- a/miniprogram/app.json +++ b/miniprogram/app.json @@ -1,15 +1,17 @@ { "cloud": true, "pages": [ + "pages/login/login", "pages/indexapp/indexapp", "pages/earth/earth", "pages/applog/applog", "pages/addDevice/addDevice", "pages/addDevicelog/addDeviceLog", - "pages/searchLog/searchLog" + "pages/searchLog/searchLog", + "pages/notice/notice" ], "window": { - "backgroundColor": "#F6F6F6", + "backgroundColor": "#E6D480", "backgroundTextStyle": "light", "navigationBarBackgroundColor": "#FFCF00", "navigationBarTitleText": "智慧施工", @@ -46,11 +48,11 @@ "desc": "你的位置信息将用于小程序位置接口的效果展示" } }, + "requiredPrivateInfos": ["getLocation", "chooseLocation"], "networkTimeout": { "request": 30000, "connectSocket": 30000, "uploadFile": 30000, "downloadFile": 30000 - }, - "style": "v2" + } } \ No newline at end of file diff --git a/miniprogram/images/applocat.png b/miniprogram/images/applocat.png new file mode 100644 index 0000000..fe49f54 --- /dev/null +++ b/miniprogram/images/applocat.png Binary files differ diff --git a/miniprogram/images/back.png b/miniprogram/images/back.png new file mode 100644 index 0000000..32ac82d --- /dev/null +++ b/miniprogram/images/back.png Binary files differ diff --git a/miniprogram/images/bottom.png b/miniprogram/images/bottom.png new file mode 100644 index 0000000..d910e98 --- /dev/null +++ b/miniprogram/images/bottom.png Binary files differ diff --git a/miniprogram/images/header.png b/miniprogram/images/header.png new file mode 100644 index 0000000..6ea222e --- /dev/null +++ b/miniprogram/images/header.png Binary files differ diff --git a/miniprogram/images/login.png b/miniprogram/images/login.png index 8b73cc0..6471c46 100644 --- a/miniprogram/images/login.png +++ b/miniprogram/images/login.png Binary files differ diff --git a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss index 5a591fb..c9c35b5 100644 --- a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss +++ b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:100%;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:100%}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file +@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:650rpx;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:600rpx}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file diff --git a/miniprogram/pages/addDevice/addDevice.js b/miniprogram/pages/addDevice/addDevice.js index 2783674..78f00b7 100644 --- a/miniprogram/pages/addDevice/addDevice.js +++ b/miniprogram/pages/addDevice/addDevice.js @@ -1,5 +1,7 @@ // miniprogram/pages/addDevice/addDevice.js // import WxValidate from '../../utils/WxValidate.js' +var QQMapWX = require('../../libs/qqmap-wx-jssdk.js'); +var qqmapsdk; var app = getApp() Page({ @@ -11,32 +13,10 @@ canvasWidth: '', longitude: '', latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], + option1: [], personoption1: [], projectoption: [], + devtypeList:[], show: false, form: { devcode: "", @@ -59,7 +39,10 @@ project: "", area: "", street: "", - wellname: "" + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '', }, fileList: [] }, @@ -117,12 +100,14 @@ var that = this; //初始化表单内容为上次填写值 var cacheForms = wx.getStorageSync('cacheList') - if (cacheForms) { + cacheForms.photopath1='' + cacheForms.photopath2='' + cacheForms.photopath3='' + that.data.fileList=[] that.setData({ form: cacheForms, devcode: cacheForms.devcode, - }) } var form = that.data.form @@ -155,55 +140,89 @@ } }) + +//获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + that.setData({ + option1: welltypeArr + }) + } + } +}) + + //获取人员下拉列表 - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/getUser", + data:{ + tips:'repair' }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data.code == 200) { + var users = res.data.data + var personArr = []; + for (var i = 0; i < users.length; i++) { + var person = { + text: users[i].name, + value: users[i].name + }; + personArr.push(person); + } + that.setData({ + personoption1: personArr + }) } - that.setData({ - personoption1: personArr - }) } - }).catch(err => { - console.error(err); - }) + }) + - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - that.setData({ - projectoption: projectArr - }) + success(res){ + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); + } + that.setData({ + projectoption: projectArr + }) + } } - }).catch(err => { - console.error(err); - }) + }) + var installtime = 'form.installtimeFmt'; var dateNow = this.formatDate(); this.setData({ @@ -211,8 +230,40 @@ installtimeFmt: dateNow, [installtime]: dateNow, }); + + + + /** + * 获取设备类型下拉列表 + */ + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/deviceType", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var TypeList = res.data.data + var typeArr = []; + for (var i = 0; i < TypeList.length; i++) { + var type = { + text: TypeList[i].productName, + value: TypeList[i].productName + }; + typeArr.push(type); + } + that.setData({ + devtypeList: typeArr + }) + } + } + }) }, + + + /** * 生命周期函数--监听页面初次渲染完成 */ @@ -280,29 +331,7 @@ }, - - //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 - drawText: function (ctx, str, leftWidth, initHeight, titleHeight, canvasWidth) { - var lineWidth = 0; - var lastSubStrIndex = 0; //每次开始截取的字符串的索引 - for (let i = 0; i < str.length; i++) { - lineWidth += ctx.measureText(str[i]).width; - if (lineWidth > canvasWidth) { - ctx.fillText(str.substring(lastSubStrIndex, i), leftWidth, initHeight); //绘制截取部分 - initHeight = initHeight + leftWidth * 2; //22为字体的高度 - lineWidth = 0; - lastSubStrIndex = i; - // titleHeight += 40; - } - if (i == str.length - 1) { //绘制剩余部分 - ctx.fillText(str.substring(lastSubStrIndex, i + 1), leftWidth, initHeight); - } - } - // // 标题border-bottom 线距顶部距离 - // titleHeight = titleHeight + 10; - // return titleHeight - }, - + //验证表单 formValidate() { if (this.data.form.devcode == "") { @@ -312,27 +341,20 @@ }) return false } - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } if (this.data.form.wellcode == "") { wx.showToast({ icon: 'none', @@ -348,22 +370,10 @@ }) return false } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null) { + + if (this.data.form.installperson == "") { wx.showToast({ icon: 'none', title: '安装人员不能为空!', @@ -408,56 +418,90 @@ } return true; }, + //提交表单 formSubmit: function (event) { + console.log(this.data.form) + //表单参数验证 if (!this.formValidate()) { return false; } var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDevice', + //验证设备编号长度 + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/getDevTypeLength", data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceAdd/add" + code: encodeURI(this.data.form.devicetype) }, - }).then(res => { - if (res.result.code == 500) { - wx.showToast({ - title: '设备编号已安装!', - }) - } else if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - //用于回显 - wx.setStorageSync('cacheList', that.data.form) - //提交成功后提示用户操作 - if (res.confirm) { - wx.switchTab({ - url: '../earth/earth' - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (""==res.data.data ||res.data.data == that.data.form.devcode.length) { + that.saveDevice() + } else { //编号位数不对提示 + wx.showToast({ + icon: 'none', + title: '设备编号位数不对!', + duration: 1000 + }) + return false + } } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "提交失败", - }) }) }, + + //保存设备基本信息 + saveDevice() { + var that = this; + //设置照片路径 + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopathForm = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopathForm]: fileList[i].url.split("static/")[1] + }) + } + //表单提交 + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 500) { + wx.showToast({ + title: '设备编号已安装!', + }) + } else if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + //用于回显 + wx.setStorageSync('cacheList', that.data.form) + //提交成功后提示用户操作 + if (res.confirm) { + wx.switchTab({ + url: '../earth/earth' + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } + }, + fail(err) { + wx.showToast({ + title: '提交失败!', + }) + } + }) + }, + + //input 输入框设置值 confirm(event) { var that = this; var formValue = event.detail.value; @@ -466,8 +510,30 @@ that.setData({ [fromN]: formValue }) + //若输入是设备编号,自动获取设备类型 + if('devcode'==formName){ + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", + data: { + devcode: formValue, + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + that.setData({ + [formDevicetype]: res.data + }); + } + } + }) + } }, + //扫描设备获取编号和设备类型 scan() { var _this = this; wx.scanCode({ @@ -477,23 +543,28 @@ _this.setData({ [formdevcode]: devcode }); - wx.cloud.callFunction({ - name: 'findModeCode', + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", data: { devcode: devcode, - url: app.globalData.url + "appDeviceAdd/findModeCodeByCode" }, - }).then(res => { - if (res.result) { - var formDevicetype = 'form.devicetype' - _this.setData({ - [formDevicetype]: res.result - }); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + _this.setData({ + [formDevicetype]: res.data + }); + } } }) } }) }, + //粘贴经纬度 paste() { var _this = this; wx.getClipboardData({ @@ -510,9 +581,11 @@ longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), }); + _this.showAddress(_this.data.form.longitude,_this.data.form.latitude,_this) } }) }, + //设置经类型 selectValue(value) { var that = this; @@ -521,6 +594,16 @@ [wellType]: value.detail }) }, + + //设置设备类型 + selectDevType(event) { + var that = this; + var devtype = 'form.devicetype'; + that.setData({ + [devtype]: event.detail + }) + }, + //设置运维人员 selectpersonValue(event) { var that = this; var installPerson = 'form.installperson'; @@ -528,6 +611,7 @@ [installPerson]: event.detail }) }, + //设置项目 selectprojectValue(event) { var that = this; var project = 'form.project'; @@ -535,8 +619,41 @@ [project]: event.detail }) }, + showAddress :function(longitude, latitude, self) { + // 实例化腾讯地图API核心类 + qqmapsdk = new QQMapWX({ + key: 'BGPBZ-C5O3P-ROUDR-LWC4J-63EKH-V5FRX'//此处使用你自己申请的key + }) + // 腾讯地图调用接口 + qqmapsdk.reverseGeocoder({ + location: { + latitude: latitude, + longitude: longitude + }, + success: function (res) { + self.setData({ + 'form.area':res.result.address.slice(0,res.result.address.indexOf('区')+1), + 'form.street':res.result.address.slice(res.result.address.indexOf('区')+1) + }) + }, + fail: function (res) { + console.log(res); + }, + complete: function (res) { + } + }); + }, + //上传照片 afterRead(event) { var _this = this; + if (_this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '请先填写设备编号!\r\n否则水印中无编号', + duration: 2000 + }) + return false + } const { file } = event.detail; @@ -576,78 +693,8 @@ }) } }) - // 压缩图片 - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // //获取图片尺寸 - // wx.getImageInfo({ - // src: convertpath, - // success(res) { - // _this.setData({ - // canvasHeight: res.height, - // canvasWidth: res.width - // }) - // var ctx = wx.createCanvasContext('firstCanvas') - - // //将图片src放到cancas内,宽高为图片大小 - // ctx.drawImage(convertpath, 0, 0, res.width, res.height) - // //将声明的时间放入canvas - // ctx.setFontSize(30 * (res.width / 750)) //注意:设置文字大小必须放在填充文字之前,否则不生效 - // ctx.setFillStyle('blue') - // var text = "编号:" + _this.data.form.devcode + "\n经度:" + _this.data.form.longitude + "\n纬度:" + _this.data.form.latitude - // // _this.drawText(ctx,text,20, 70, 5, res.width) - // _this.drawText(ctx, text, 15 * (res.width / 750), 70 * (res.width / 750), 5, res.width) - - // // ctx.fillText(text, 0, 40) - // // ctx.strokeText(_this.data.form.devcode, 0, 30) - // //生成水印图 - // ctx.draw(false, function () { - // wx.canvasToTempFilePath({ - // canvasId: 'firstCanvas', - // success: (res) => { - // wx.compressImage({ - // src: res.tempFilePath, - // quality: 25, - // success: function (res) { - // //上传照片至服务器 - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: res.tempFilePath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // } - // }) - // //// - // } - // }) - // }) - // } - // }) - // } - // }); }, + //删除照片 deletePhoto(event) { var image_index = event.detail.index var fileList_new = this.data.fileList; diff --git a/miniprogram/pages/addDevice/addDevice.wxml b/miniprogram/pages/addDevice/addDevice.wxml index b0977e2..f12c254 100644 --- a/miniprogram/pages/addDevice/addDevice.wxml +++ b/miniprogram/pages/addDevice/addDevice.wxml @@ -5,18 +5,30 @@ - + + + + + + + + + + + + + - - + + - - - + + + @@ -29,13 +41,13 @@ - + - + - + - + @@ -54,8 +66,7 @@ - - + @@ -68,8 +79,8 @@ - - + + - 保存 + 保存 \ No newline at end of file diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.js b/miniprogram/pages/addDevicelog/addDeviceLog.js index cdec71b..a0dc6da 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.js +++ b/miniprogram/pages/addDevicelog/addDeviceLog.js @@ -3,681 +3,665 @@ var app = getApp(); Page({ - /** - * 页面的初始数据 - */ - data: { - pageName: '', - showMask: false, - today: new Date().getTime(), - longitude: '', - latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], - personoption1: [], - projectoption: [], - devcode: "", - deviceMode: "", - installtimeFmt: '', - show: false, - form: { - devcode: "", - wellcode: "", - welltype: "", - welldepth: "", - installheigt: "", - installperson: "", - installtimeFmt: "", - photopath: "", - factory: "", - workmsg: "", - position: "", - description: "", - longitude: "", - latitude: "", - longitude84: "", - latitude84: "", - devicetype: "", - project: "", - area: "", - street: "", - wellname: "" - }, - fileList: [], - detail: "" - }, + /** + * 页面的初始数据 + */ + data: { + pageName: '', + showMask: false, + today: new Date().getTime(), + longitude: '', + latitude: '', + option1: [], + personoption1: [], + projectoption: [], + devcode: "", + deviceMode: "", + installtimeFmt: '', + show: false, + form: { + devcode: "", + wellcode: "", + welltype: "", + welldepth: "", + installheigt: "", + installperson: "", + installtimeFmt: "", + photopath: "", + factory: "", + workmsg: "", + position: "", + description: "", + longitude: "", + latitude: "", + longitude84: "", + latitude84: "", + devicetype: "", + project: "", + area: "", + street: "", + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '' + }, + fileList: [], + detail: "", + markers: [{ + id: 100, + // iconPath: "../../images/point.png", + latitude: '', + longitude: '', + // label:'1', + width: 25, + height: 35 + }], + }, - onDisplay() { - this.setData({ - show: true - }); - }, - onClose() { - this.setData({ - show: false - }); - }, - formatDate() { - var date = new Date(); - // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; - var seperator1 = "-"; - var month = date.getMonth() + 1; - var strDate = date.getDate(); - var hour = date.getHours() - var minute = date.getMinutes() - var second = date.getSeconds() - month = month > 9 ? month : "0" + month; - strDate = strDate > 9 ? strDate : "0" + strDate; - hour = hour > 9 ? hour : "0" + hour; - minute = minute > 9 ? minute : "0" + minute; - second = second > 9 ? second : "0" + second; - var currentdate = - date.getFullYear() + - seperator1 + - month + - seperator1 + - strDate + - " " + - hour + ":" + - minute + ":" + - second; - return currentdate; + onDisplay() { + this.setData({ + show: true + }); + }, + onClose() { + this.setData({ + show: false + }); + }, + formatDate() { + var date = new Date(); + // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; + var seperator1 = "-"; + var month = date.getMonth() + 1; + var strDate = date.getDate(); + var hour = date.getHours() + var minute = date.getMinutes() + var second = date.getSeconds() + month = month > 9 ? month : "0" + month; + strDate = strDate > 9 ? strDate : "0" + strDate; + hour = hour > 9 ? hour : "0" + hour; + minute = minute > 9 ? minute : "0" + minute; + second = second > 9 ? second : "0" + second; + var currentdate = + date.getFullYear() + + seperator1 + + month + + seperator1 + + strDate + + " " + + hour + ":" + + minute + ":" + + second; + return currentdate; - }, - onConfirm(event) { - var installtime = 'form.installtimeFmt'; - this.setData({ - show: false, - installtimeFmt: this.formatDate(event.detail), - [installtime]: this.formatDate(event.detail), - }); - }, + }, + onConfirm(event) { + var installtime = 'form.installtimeFmt'; + this.setData({ + show: false, + installtimeFmt: this.formatDate(event.detail), + [installtime]: this.formatDate(event.detail), + }); + }, - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - var _this = this; - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" - }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); - } - _this.setData({ - personoption1: personArr - }) + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + var _this = this; + _this.setData({ + 'markers[0].latitude': Number(wx.getStorageSync('resultObject').latitude) , + 'markers[0].longitude': Number(wx.getStorageSync('resultObject').longitude), + // 'markers[0].label':'10', + 'markers[0].width': 18, + 'markers[0].id':1, + 'markers[0].height': 30, + latitude:Number(wx.getStorageSync('resultObject').latitude), + longitude:Number(wx.getStorageSync('resultObject').longitude) + }) + //获取人员下拉列表 + // wx.request({ + // method: "POST", + // url: app.globalData.httpsUrl + "deviceType/getUser", + // data:{ + // tips:'repair' + // }, + // header: { + // 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + // }, + // success(res) { + // if (res.data.code == 200) { + // var users = res.data.data + // var personArr = []; + // for (var i = 0; i < users.length; i++) { + // var person = { + // text: users[i].name, + // value: users[i].name + // }; + // personArr.push(person); + // } + // _this.setData({ + // personoption1: personArr + // }) + // } + // } + // }) + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); } - }).catch(err => { - console.error(err); - }) - - - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" - }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - _this.setData({ - projectoption: projectArr - }) - } - }).catch(err => { - console.error(err); - }) - - if (options.pageName) { - this.setData({ - pageName: options.pageName - }) - } - - if (options.detail) { - - var formObject = JSON.parse(options.detail); _this.setData({ - form: formObject, - detail: options.detail + projectoption: projectArr }) - - _this.setData({ - ['form.installperson']: "", - ['form.installtimeFmt']: "", - ['form.workmsg']: "", - ['form.description']: "" - }) - - const { - fileList = [] - } = _this.data; - if (formObject.photopath1 != "") { - var file1 = { - url: app.globalData.url + "static/" + formObject.photopath1 - } - fileList.push(file1) - } - if (formObject.photopath2 != "") { - var file2 = { - url: app.globalData.url + "static/" + formObject.photopath2 - } - fileList.push(file2) - } - if (formObject.photopath3 != "") { - var file3 = { - url: app.globalData.url + "static/" + formObject.photopath3 - } - fileList.push(file3) - } - - _this.setData({ - fileList - }); } - var installtime = 'form.installtimeFmt'; - var dateNow = this.formatDate(); - this.setData({ - installtimeFmt: dateNow, - [installtime]: dateNow, - }); - }, + } + }) - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { + //获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + _this.setData({ + option1: welltypeArr + }) + } + } +}) - }, + //跳转时带入参数返回哪页 + if (options.pageName) { + this.setData({ + pageName: options.pageName + }) + } + //跳转时带入参数设备的安装信息 + if (wx.getStorageSync('resultObject')) { + var formObject = wx.getStorageSync('resultObject') + _this.setData({ + form: formObject, + detail: formObject + }) - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { + _this.setData({ + ['form.installperson']: app.globalData.userName, + ['form.installtimeFmt']: "", + ['form.workmsg']: "", + ['form.description']: "" + }) - }, + const { + fileList = [] + } = _this.data; + if (formObject.photopath1 != "") { + var file1 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath1 + } + fileList.push(file1) + } + if (formObject.photopath2 != "") { + var file2 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath2 + } + fileList.push(file2) + } + if (formObject.photopath3 != "") { + var file3 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath3 + } + fileList.push(file3) + } + _this.setData({ + fileList + }); + } + var installtime = 'form.installtimeFmt'; + var dateNow = this.formatDate(); + this.setData({ + installtimeFmt: dateNow, + [installtime]: dateNow, + }); + }, - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, - }, + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + wx.removeStorageSync('resultObject') + }, - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, - }, + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { + }, - }, + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { + }, - }, + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { + }, - }, + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + }, - /** - * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true - **/ + /** + * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true + **/ - isNumber: function (val) { + isNumber: function (val) { - var regPos = /^[0-9]*$/; //非负浮点数 - var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数 - if (regPos.test(val) || regNeg.test(val)) { - return false; - } else { - return true; - } + var regPos = /^[0-9]*$/; //非负浮点数 + var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数 + if (regPos.test(val) || regNeg.test(val)) { + return false; + } else { + return true; + } - }, + }, - formValidate() { + formValidate() { - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } - if (this.data.form.wellcode == "") { - wx.showToast({ - icon: 'none', - title: '井编号不能为空!', - }) - return false - } - if (this.data.form.devicetype == "") { - wx.showToast({ - icon: 'none', - title: '设备类型不能为空!', - }) - return false - } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + if (this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '设备编号不能为空!', + }) + return false + } + if (this.data.form.wellcode == "") { + wx.showToast({ + icon: 'none', + title: '井编号不能为空!', + }) + return false + } + if (this.data.form.devicetype == "") { + wx.showToast({ + icon: 'none', + title: '设备类型不能为空!', + }) + return false + } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null || - this.data.form.installperson == '') { - wx.showToast({ - icon: 'none', - title: '运维人员不能为空!', - }) - return false - } - if (this.data.form.project == "") { - wx.showToast({ - icon: 'none', - title: '所属项目不能为空!', - }) - return false - } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } + if (this.data.form.installperson == null || + this.data.form.installperson == '') { + wx.showToast({ + icon: 'none', + title: '运维人员不能为空!', + }) + return false + } + if (this.data.form.project == "") { + wx.showToast({ + icon: 'none', + title: '所属项目不能为空!', + }) + return false + } - if (this.data.form.welldepth != null) { - if (this.isNumber(this.data.form.welldepth)) { - wx.showToast({ - icon: 'none', - title: '井深必须为数值!', - }) - return false - } - } - if (this.data.form.installheigt != null) { - if (this.isNumber(this.data.form.installheigt)) { - wx.showToast({ - icon: 'none', - title: '到井口距离必须为数值!', - }) - return false - } - } - - return true; - }, - - changeMsg: function () { - var formNew = this.data.form; - var formOld = JSON.parse(this.data.detail); - var descpNew = ""; - if (formNew.devcode != formOld.devcode) { - descpNew += "修改设备编号,原编号:" + formOld.devcode + ",新编号:" + formNew.devcode + ";" - } - if (formNew.devicetype != formOld.devicetype) { - descpNew += "修改设备类型,原设备类型:" + formOld.devicetype + ",新设备类型:" + formNew.devicetype + ";" - } - if (formNew.area != formOld.area) { - descpNew += "修改区,原区:" + formOld.area + ",新区:" + formNew.area + ";" - } - if (formNew.street != formOld.street) { - descpNew += "修改街道,原街道:" + formOld.street + ",新街道:" + formNew.street + ";" - } - if (formNew.wellname != formOld.wellname) { - descpNew += "修改井名称,原井名称:" + formOld.wellname + ",新井名称:" + formNew.wellname + ";" - } - if (formNew.factory != formOld.factory) { - descpNew += "修改权属单位,原权属单位:" + formOld.factory + ",新权属单位:" + formNew.factory + ";" - } - if (formNew.installheigt != formOld.installheigt) { - descpNew += "修改井口距离,原井口距离:" + formOld.installheigt + ",新井口距离:" + formNew.installheigt + ";" - } - if (formNew.installperson != formOld.installperson) { - descpNew += "修改运维人员,原运维人员:" + formOld.installperson + ",新运维人员:" + formNew.installperson + ";" - } - if (formNew.latitude != formOld.latitude) { - descpNew += "修改纬度,原纬度:" + formOld.latitude + ",新纬度:" + formNew.latitude + ";" - } - if (formNew.longitude != formOld.longitude) { - descpNew += "修改经度,原经度:" + formOld.longitude + ",新经度:" + formNew.longitude + ";" - } - if (formNew.position != formOld.position) { - descpNew += "修改位置描述,原位置:" + formOld.position + ",新位置:" + formNew.position + ";" - } - if (formNew.wellcode != formOld.wellcode) { - descpNew += "修改井编号,原编号:" + formOld.wellcode + ",新编号:" + formNew.wellcode + ";" - } - if (formNew.welldepth != formOld.welldepth) { - descpNew += "修改井深,原井深:" + formOld.welldepth + ",新井深:" + formNew.welldepth + ";" - } - if (formNew.welltype != formOld.welltype) { - descpNew += "修改井类型,原井类型:" + formOld.welltype + ",新井类型:" + formNew.welltype + ";" - } - if (formNew.project != formOld.project) { - descpNew += "修改所属项目,原项目:" + formOld.project + ",新项目:" + formNew.project + ";" - } - if (this.data.photopath1 != formOld.photopath1 || - this.data.photopath2 != formOld.photopath2 || - this.data.photopath3 != formOld.photopath3) { - descpNew += "修改照片;" - } - if ("" != formNew.description) { - descpNew += formNew.description; - } - this.setData({ - ['form.description']: descpNew + if (this.data.form.welldepth != null) { + if (this.isNumber(this.data.form.welldepth)) { + wx.showToast({ + icon: 'none', + title: '井深必须为数值!', }) - }, + return false + } + } + if (this.data.form.installheigt != null) { + if (this.isNumber(this.data.form.installheigt)) { + wx.showToast({ + icon: 'none', + title: '到井口距离必须为数值!', + }) + return false + } + } - formSubmit: function (event) { + return true; + }, - if (!this.formValidate()) { - return false; - } - this.changeMsg(); - var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDeviceLog', - data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceLog/add" - }, - }).then(res => { - // var resultObj=JSON.parse(res.result); - if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - if (res.confirm) { - wx.switchTab({ - url: that.data.pageName - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) - } - }).catch(err => { - console.error(err) - wx.showToast({ - title: "提交失败", - }) - }) - }, - confirm(event) { - var that = this; - var formValue = event.detail.value; - var formName = event.target.dataset.id; - var fromN = 'form.' + [formName]; - that.setData({ - [fromN]: formValue - }) - }, + //获取与上次修改的信息 + changeMsg: function () { + var formNew = this.data.form; + console.log(this.data.detail) + var formOld = JSON.parse(this.data.detail); + var descpNew = ""; + if (formNew.devcode != formOld.devcode) { + descpNew += "修改设备编号,原值:" + formOld.devcode + ",新值:" + formNew.devcode + ";" + } + if (formNew.devicetype != formOld.devicetype) { + descpNew += "修改设备类型,原值:" + formOld.devicetype + ",新值:" + formNew.devicetype + ";" + } + if (formNew.area != formOld.area) { + descpNew += "修改区,原值:" + formOld.area + ",新值:" + formNew.area + ";" + } + if (formNew.street != formOld.street) { + descpNew += "修改街道,原值:" + formOld.street + ",新值:" + formNew.street + ";" + } + if (formNew.wellname != formOld.wellname) { + descpNew += "修改井名称,原值:" + formOld.wellname + ",新值:" + formNew.wellname + ";" + } + if (formNew.factory != formOld.factory) { + descpNew += "修改权属单位,原值:" + formOld.factory + ",新值:" + formNew.factory + ";" + } + if (formNew.installheigt != formOld.installheigt) { + descpNew += "修改井口距离,原值:" + formOld.installheigt + ",新值:" + formNew.installheigt + ";" + } + if (formNew.installperson != formOld.installperson) { + descpNew += "修改运维人员,原值:" + formOld.installperson + ",新值:" + formNew.installperson + ";" + } + if (formNew.latitude != formOld.latitude) { + descpNew += "修改纬度,原值:" + formOld.latitude + ",新值:" + formNew.latitude + ";" + } + if (formNew.longitude != formOld.longitude) { + descpNew += "修改经度,原值:" + formOld.longitude + ",新值:" + formNew.longitude + ";" + } + if (formNew.position != formOld.position) { + descpNew += "修改位置描述,原值:" + formOld.position + ",新值:" + formNew.position + ";" + } + if (formNew.wellcode != formOld.wellcode) { + descpNew += "修改井编号,原值:" + formOld.wellcode + ",新值:" + formNew.wellcode + ";" + } + if (formNew.welldepth != formOld.welldepth) { + descpNew += "修改井深,原值:" + formOld.welldepth + ",新值:" + formNew.welldepth + ";" + } + if (formNew.welltype != formOld.welltype) { + descpNew += "修改井类型,原值:" + formOld.welltype + ",新值:" + formNew.welltype + ";" + } + if (formNew.project != formOld.project) { + descpNew += "修改所属项目,原值:" + formOld.project + ",新值:" + formNew.project + ";" + } + if (this.data.form.photopath1 != formOld.photopath1 || + this.data.form.photopath2 != formOld.photopath2 || + this.data.form.photopath3 != formOld.photopath3) { + descpNew += "修改照片;" + } + if ("" != formNew.description) { + descpNew += formNew.description; + } + this.setData({ + ['form.description']: descpNew + }) + }, - scan() { + //提交表单 + formSubmit: function (event) { - wx.scanCode({ - success(res) { - console.log(res) - } - }) + //表单验证 + if (!this.formValidate()) { + return false; + } + //自动生成修改内容 + this.changeMsg(); + //提交权限限制(只有施工人员能修改) + if(app.globalData.role!='repair'){ + wx.showToast({ + icon: 'none', + title: '无权限修改', + duration:2000 + }) + return false + } + var that = this; + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopath = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopath]: fileList[i].url.split("static/")[1] + }) + } + delete that.data.form.installtime + delete that.data.form.createtime + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - paste() { - var _this = this; - wx.getClipboardData({ - success: function (res) { - var longitude = 'form.longitude'; - var latitude = 'form.latitude'; - var longitude84 = 'form.longitude84'; - var latitude84 = 'form.latitude84'; - _this.setData({ - [longitude]: parseFloat(res.data.split(",", 4)[1]).toFixed(6), - [latitude]: parseFloat(res.data.split(",", 4)[0]).toFixed(6), - [longitude84]: "" == (res.data.split(",", 4)[3]) ? "" : parseFloat(res.data.split(",", 4)[3]).toFixed(6), - [latitude84]: "" == (res.data.split(",", 4)[2]) ? "" : parseFloat(res.data.split(",", 4)[2]).toFixed(6), - longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), - latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), - }); - } - }) - }, - selectValue(value) { - var that = this; - var wellType = 'form.welltype'; - that.setData({ - [wellType]: value.detail - }) - }, - selectpersonValue(event) { - var that = this; - var installPerson = 'form.installperson'; - that.setData({ - [installPerson]: event.detail - }) - }, - selectprojectValue(event) { - var that = this; - var project = 'form.project'; - that.setData({ - [project]: event.detail, - showMask: true - }) - }, - open() { - this.setData({ - showMask: true - }) - }, - close() { - this.setData({ - showMask: false - }) - }, - afterRead(event) { - var _this = this; - const { - file - } = event.detail; - const { - fileList = [] - } = _this.data; - var convertpath = ""; - wx.compressImage({ - src: event.detail.file.path, - quality: 25, - success: function (res) { - convertpath = res.tempFilePath; - wx.uploadFile({ - url: app.globalData.httpsUrl + "appDeviceAdd/fileUploadMarker", - filePath:convertpath, - name: 'file', - formData: { - 'text': "编号:" + _this.data.form.devcode + "经度:" + _this.data.form.longitude + "纬度:" + _this.data.form.latitude - }, - header: { - "Content-Type": "multipart/form-data", - 'accept': 'application/json', - }, - success(res) { - if (res.data) { - var url = JSON.parse(res.data); - fileList.push({ - ...file, - url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - }); - _this.setData({ - fileList - }); - } - } + success(res) { + if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + if (res.confirm) { + wx.switchTab({ + url: that.data.pageName }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') } - }) - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // // var base64 = "data:image/png;base64," + wx.getFileSystemManager().readFileSync(convertpath, 'base64'); - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: convertpath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // // wx.cloud.callFunction({ - // // name: 'uploadFile', - // // data: { - // // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // // fileBase64: base64 - // // }, - // // success: function (res) { - // // if (res.result) { - // // fileList.push({ - // // ...file, - // // url: app.globalData.url + "static/" + res.result.data.replace(/\\/g, "/") - // // }); - // // _this.setData({ - // // fileList - // // }); - // // } - // // }, - // // complete: res => { - // // }, - // // }) - // } - // }); + } + }) + } + }, + fail(err) { + wx.showToast({ + title: "提交失败", + }) + } + }) + }, + //报存录入的input信息 + confirm(event) { + var that = this; + var formValue = event.detail.value; + var formName = event.target.dataset.id; + var fromN = 'form.' + [formName]; + that.setData({ + [fromN]: formValue + }) + }, + + //扫码 + scan() { + + wx.scanCode({ + success(res) { + console.log(res) + } + }) + }, + //粘贴经纬度 + paste() { + var _this = this; + wx.getClipboardData({ + success: function (res) { + var longitude = 'form.longitude'; + var latitude = 'form.latitude'; + var longitude84 = 'form.longitude84'; + var latitude84 = 'form.latitude84'; + _this.setData({ + [longitude]: parseFloat(res.data.split(",", 4)[1]).toFixed(6), + [latitude]: parseFloat(res.data.split(",", 4)[0]).toFixed(6), + [longitude84]: "" == (res.data.split(",", 4)[3]) ? "" : parseFloat(res.data.split(",", 4)[3]).toFixed(6), + [latitude84]: "" == (res.data.split(",", 4)[2]) ? "" : parseFloat(res.data.split(",", 4)[2]).toFixed(6), + longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), + latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), + }); + } + }) + }, + selectValue(value) { + var that = this; + var wellType = 'form.welltype'; + that.setData({ + [wellType]: value.detail + }) + }, + //运维人员默认为登录人 + // selectpersonValue(event) { + // var that = this; + // var installPerson = 'form.installperson'; + // that.setData({ + // [installPerson]: event.detail + // }) + // }, + selectprojectValue(event) { + var that = this; + var project = 'form.project'; + that.setData({ + [project]: event.detail, + showMask: true + }) + }, + + open() { + this.setData({ + showMask: true + }) + }, + //隐藏textarea,防止遮挡 + close() { + this.setData({ + showMask: false + }) + }, + //上传照片 + afterRead(event) { + var _this = this; + const { + file + } = event.detail; + const { + fileList = [] + } = _this.data; + var convertpath = ""; + wx.compressImage({ + src: event.detail.file.path, + quality: 25, + success: function (res) { + convertpath = res.tempFilePath; + wx.uploadFile({ + url: app.globalData.httpsUrl + "appDeviceAdd/fileUploadMarker", + filePath: convertpath, + name: 'file', + formData: { + 'text': "编号:" + _this.data.form.devcode + "经度:" + _this.data.form.longitude + "纬度:" + _this.data.form.latitude }, - deletePhoto(event) { - var that = this - var image_index = event.detail.index - var fileList_new = that.data.fileList; - wx.showModal({ - content: '确定删除照片?', - success: function (res) { - if (res.confirm) { - fileList_new.splice(image_index, 1); - that.setData({ - fileList: fileList_new - }) - wx.cloud.callFunction({ - name: 'deletePhoto', - data: { - url: app.globalData.url + "appDeviceLog/deletePhoto", - devcode: that.data.form.devcode, - pathIndex: image_index - }, - success: function (res) {}, - complete: res => {}, - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + "Content-Type": "multipart/form-data", + 'accept': 'application/json', }, - }) \ No newline at end of file + success(res) { + if (res.data) { + var url = JSON.parse(res.data); + fileList.push({ + ...file, + url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") + }); + _this.setData({ + fileList + }); + } + } + }) + } + }) + }, + //删除照片 + deletePhoto(event) { + var that = this + var image_index = event.detail.index + var fileList_new = that.data.fileList; + wx.showModal({ + content: '确定删除照片?', + success: function (res) { + if (res.confirm) { + fileList_new.splice(image_index, 1); + that.setData({ + fileList: fileList_new + }) + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deletePhoto", + data: { + devcode: that.data.form.devcode + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) {} + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } +}) \ No newline at end of file diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.wxml b/miniprogram/pages/addDevicelog/addDeviceLog.wxml index 38620d4..b10cc7d 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.wxml +++ b/miniprogram/pages/addDevicelog/addDeviceLog.wxml @@ -1,15 +1,21 @@ - + + + + + - + - - + + - - + + - + @@ -39,24 +45,25 @@ - - - + + + - + - + + @@ -64,7 +71,7 @@ - + @@ -79,9 +86,9 @@ - + - 保存 + 保存 diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.wxss b/miniprogram/pages/addDevicelog/addDeviceLog.wxss index ee0b75c..08d5fd7 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.wxss +++ b/miniprogram/pages/addDevicelog/addDeviceLog.wxss @@ -24,6 +24,17 @@ display: flex; align-items: center; } +.map-view{ + width: 750rpx; + height: 485rpx; + position: fixed; + top: 0px; + left: 0px; + z-index: 999; +} +.content{ + margin-top: 495rpx; +} .left { width: 210rpx; diff --git a/miniprogram/pages/addFunction/addFunction.js b/miniprogram/pages/addFunction/addFunction.js deleted file mode 100644 index 4966be3..0000000 --- a/miniprogram/pages/addFunction/addFunction.js +++ /dev/null @@ -1,60 +0,0 @@ -// pages/addFunction/addFunction.js - -const code = `// 云函数入口函数 -exports.main = (event, context) => { - console.log(event) - console.log(context) - return { - sum: event.a + event.b - } -}` - -Page({ - - data: { - result: '', - canIUseClipboard: wx.canIUse('setClipboardData'), - }, - - onLoad: function (options) { - - }, - - copyCode: function() { - wx.setClipboardData({ - data: code, - success: function () { - wx.showToast({ - title: '复制成功', - }) - } - }) - }, - - testFunction() { - wx.cloud.callFunction({ - name: 'sum', - data: { - a: 1, - b: 2 - }, - success: res => { - wx.showToast({ - title: '调用成功', - }) - this.setData({ - result: JSON.stringify(res.result) - }) - }, - fail: err => { - wx.showToast({ - icon: 'none', - title: '调用失败', - }) - console.error('[云函数] [sum] 调用失败:', err) - } - }) - }, - -}) - diff --git a/miniprogram/pages/addFunction/addFunction.json b/miniprogram/pages/addFunction/addFunction.json deleted file mode 100644 index a9a50c5..0000000 --- a/miniprogram/pages/addFunction/addFunction.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "navigationBarTitleText": "云函数指引", - "usingComponents": {} -} \ No newline at end of file diff --git a/miniprogram/pages/addFunction/addFunction.wxml b/miniprogram/pages/addFunction/addFunction.wxml deleted file mode 100644 index 3a10626..0000000 --- a/miniprogram/pages/addFunction/addFunction.wxml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - 测试云函数 - - - 期望输出:{"sum":3} - - - 调用结果:{{result}} - - - - - 新增云函数 - 1. 在云函数根目录 cloudfunctions 上右键选择新建云函数,命名为 sum - 2. 在创建的 cloudfunctions/sum/index.js 文件中添加如下代码 - - - 3. 在 cloudfunctions/sum 目录上右键上传并部署 - 4. 点击测试云函数测试 - 5. 打开云开发云函数管理页,选择 sum 云函数 - 6. 查看 sum 的调用日志 - 进阶:可在云函数中使用 wx-server-sdk 操作数据库,文件存储和调用其他云函数,详见文档 - - - diff --git a/miniprogram/pages/addFunction/addFunction.wxss b/miniprogram/pages/addFunction/addFunction.wxss deleted file mode 100644 index 7ac8619..0000000 --- a/miniprogram/pages/addFunction/addFunction.wxss +++ /dev/null @@ -1,3 +0,0 @@ -/* pages/addFunction/addFunction.wxss */ - -@import "../../style/guide.wxss"; \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.js b/miniprogram/pages/applog/applog.js index 0e8c185..189e61f 100644 --- a/miniprogram/pages/applog/applog.js +++ b/miniprogram/pages/applog/applog.js @@ -13,98 +13,25 @@ isSeach: "false", params: {}, total: 0, - show: false + show: false, + delBtnWidth: 100, //删除按钮宽度单位(rpx) + activeIndex: -1, + list_style: '' }, - - touchE: function (e) { - // console.log(e); - var that = this - if (e.changedTouches.length == 1) { - //手指移动结束后触摸点位置的X坐标 - var endX = e.changedTouches[0].clientX; - //触摸开始与结束,手指移动的距离 - var disX = that.data.startX - endX; - var delBtnWidth = that.data.delBtnWidth; - //如果距离小于删除按钮的1/2,不显示删除按钮 - var txtStyle = disX > delBtnWidth / 2 ? "left:-" + delBtnWidth + "rpx" : "left:0rpx"; - - //获取手指触摸的是哪一项 - var index = e.currentTarget.dataset.index; - var list = that.data.deviceloglist; - list[index].txtStyle = txtStyle; - //更新列表的状态 - that.setData({ - deviceloglist: list - }); - } - }, - //手指触摸动作开始 记录起点X坐标 - touchstart: function (e) { - //开始触摸时 重置所有删除 - this.data.deviceloglist.forEach(function (v, i) { - if (v.isTouchMove) //只操作为true的 - v.isTouchMove = false; - }) - this.setData({ - startX: e.changedTouches[0].clientX, - startY: e.changedTouches[0].clientY, - deviceloglist: this.data.deviceloglist - }) - }, - //滑动事件处理 - touchmove: function (e) { - var that = this, - index = e.currentTarget.dataset.index, //当前索引 - startX = that.data.startX, //开始X坐标 - startY = that.data.startY, //开始Y坐标 - touchMoveX = e.changedTouches[0].clientX, //滑动变化坐标 - touchMoveY = e.changedTouches[0].clientY, //滑动变化坐标 - //获取滑动角度 - angle = that.angle({ - X: startX, - Y: startY - }, { - X: touchMoveX, - Y: touchMoveY - }); - that.data.deviceloglist.forEach(function (v, i) { - v.isTouchMove = false - //滑动超过30度角 return - if (Math.abs(angle) > 30) return; - if (i == index) { - if (touchMoveX > startX) //右滑 - v.isTouchMove = false - else //左滑 - v.isTouchMove = true - } - }) - //更新数据 - that.setData({ - deviceloglist: that.data.deviceloglist - }) - }, - /** - * 计算滑动角度 - * @param {Object} start 起点坐标 - * @param {Object} end 终点坐标 - */ - angle: function (start, end) { - var _X = end.X - start.X, - _Y = end.Y - start.Y - //返回角度 /Math.atan()返回数字的反正切值 - return 360 * Math.atan(_Y / _X) / (2 * Math.PI); - }, - /** - * 生命周期函数--监听页面加载var_this=this; - */ onLoad: function (options) { - if (options.params) { this.setData({ params: JSON.parse(options.params), isSeach: "true" }) this.initPages() + }else{ + this.setData({ + show: false + }) + //清空参数,重新加载 + this.clearParams(); + this.initPages(); } }, @@ -116,20 +43,33 @@ }, + //点击tabBar事件 + onTabItemTap(item) { + //隐藏历史显示总记录条数 + this.setData({ + show: false + }) + //清空参数,重新加载 + this.clearParams(); + this.initPages(); + }, + + /** * 生命周期函数--监听页面显示 */ onShow: function (options) { - this.setData({ - show:false - }) - if (this.data.isSeach == "false") { - this.clearParams(); - this.initPages(); - } - this.setData({ - isSeach: "false" - }) + + // this.setData({ + // show: false + // }) + // if (this.data.isSeach == "false") { + // this.clearParams(); + // this.initPages(); + // } + // this.setData({ + // isSeach: "false" + // }) }, /** @@ -167,6 +107,119 @@ }, + + //手指触摸动作开始 记录起点X坐标 + touchstart: function (e) { + //开始触摸时 重置所有删除 + this.data.deviceloglist.forEach(function (v, i) { + if (v.isTouchMove) //只操作为true的 + v.isTouchMove = false; + }) + this.setData({ + startX: e.changedTouches[0].clientX, + startY: e.changedTouches[0].clientY, + deviceloglist: this.data.deviceloglist + }) + }, + + //滑动事件处理 + touchmove: function (e) { + var that = this, + index = e.currentTarget.dataset.index, //当前索引 + startX = that.data.startX, //开始X坐标 + startY = that.data.startY, //开始Y坐标 + touchMoveX = e.changedTouches[0].clientX, //滑动变化坐标 + touchMoveY = e.changedTouches[0].clientY, //滑动变化坐标 + //获取滑动角度 + angle = that.angle({ + X: startX, + Y: startY + }, { + X: touchMoveX, + Y: touchMoveY + }); + that.data.deviceloglist.forEach(function (v, i) { + // v.isTouchMove = false + //滑动超过30度角 return + if (Math.abs(angle) > 30) return; + if (i == index) { + if (touchMoveX > startX) //右滑 + v.isTouchMove = false + else //左滑 + v.isTouchMove = true + } + }) + //更新数据 + that.setData({ + deviceloglist: that.data.deviceloglist + }) + }, + + /** + * 计算滑动角度 + * @param {Object} start 起点坐标 + * @param {Object} end 终点坐标 + */ + angle: function (start, end) { + var _X = end.X - start.X, + _Y = end.Y - start.Y + //返回角度 /Math.atan()返回数字的反正切值 + return 360 * Math.atan(_Y / _X) / (2 * Math.PI); + }, + + //删除事件 + delItem: function (e) { + if(app.globalData.role!='repair'){ + wx.showToast({ + icon: 'none', + title: '无权限删除', + duration:2000 + }) + return false + } + var that = this + wx.showModal({ + content: '是否删除?', + success: function (res) { + if (res.confirm) { + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/delete", + data: { + appDeviceAddId: e.currentTarget.dataset.devid + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if(res.data.code=='200'){ + that.data.deviceloglist.splice(e.currentTarget.dataset.index, 1) + that.setData({ + deviceloglist: that.data.deviceloglist, + total: that.data.deviceloglist.length + }) + wx.showToast({ + title: '删除成功!', + icon: 'none', + duration: 1000 + }) + } + }, + fail(err) { + wx.showToast({ + title: '删除失败!', + icon: 'none', + duration: 2000 + }) + } + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + }, + showLoading: function (message) { if (wx.showLoading) { // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 @@ -199,95 +252,105 @@ deviceloglist: [] }) }, + //查询列表数据 initPages: function () { var that = this + that.setData({ + show: false + }) var offsetValue = that.data.deviceloglist.length % 15 > 0 ? parseInt(that.data.deviceloglist.length / 15) + 2 : parseInt(that.data.deviceloglist.length / 15) + 1 - wx.cloud.callFunction({ - name: 'devicelog', + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/listPage", data: { devcode: that.data.params.devcode, devtype: that.data.params.devtype, installtimeFmt: that.data.params.installtimeFmt, project: that.data.params.project, installPerson: that.data.params.installPerson, - url: app.globalData.url + "appDeviceLog/listPage", limit: 15, offset: offsetValue }, - }).then(res => { - if (res.result.data.rows.length > 0) { - var resultJson = res.result - that.setData({ - deviceloglist: that.data.deviceloglist.concat(resultJson.data.rows) - }) - } else if (that.data.deviceloglist.length > 0) { - that.setData({ - show: true, - total: that.data.deviceloglist.length - }) - wx.showToast({ - title: '数据已全部加载完', - icon: 'none', - duration: 2000 - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.data.rows.length > 0) { + var resultJson = res.data + var listArr = resultJson.data.rows + listArr.forEach(function (v, i) { + listArr[i]['isTouchMove'] = false + }) + that.setData({ + deviceloglist: that.data.deviceloglist.concat(listArr) + }) + } else if (that.data.deviceloglist.length > 0) { + that.setData({ + show: true, + total: that.data.deviceloglist.length + }) + wx.showToast({ + title: '数据已全部加载完', + icon: 'none', + duration: 2000 + }) + } + if (offsetValue == 1 && res.data.data.rows.length < 15) { + that.setData({ + show: true, + total: that.data.deviceloglist.length + }) + } } - if(offsetValue==1&&res.result.data.rows.length<15){ - that.setData({ - show: true, - total: that.data.deviceloglist.length - }) - } - // console.log(res); - }).catch(err => { - console.error(err); }) + }, addDetail: function (event) { - this.showLoading("数据请求中..."); - wx.cloud.callFunction({ - name: 'deviceDetail', + var that = this + that.showLoading("数据请求中..."); + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deviceDetail", data: { devcode: event.target.dataset.devcode, - url: app.globalData.url + "appDeviceLog/deviceDetail", }, - }).then(res => { - this.hideLoading(); - var resultObject = JSON.parse(res.result); - var pageName = '../applog/applog' - if (resultObject.code == 200) { - wx.navigateTo({ - url: '../addDevicelog/addDeviceLog?detail=' + - JSON.stringify(resultObject.data) + "&pageName=" + pageName - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + that.hideLoading(); + // var resultObject = JSON.parse(res.data); + var resultObject = res.data; + var pageName = '../applog/applog' + if (resultObject.code == 200) { + wx.setStorageSync('resultObject', resultObject.data) + wx.navigateTo({ + url: '../addDevicelog/addDeviceLog?detail=' + "&pageName=" + pageName + }) + } + }, + fail(err) { + that.hideLoading(); } - }).catch(err => { - this.hideLoading() }) + }, add: function (event) { - wx.reLaunch({ - url: '../earth/earth?devcode=' + event.target.dataset.devcode - // url: '../earth/earth' + app.globalData.devcode = event.target.dataset.devcode; + wx.switchTab({ + url: '../earth/earth' }) + // wx.reLaunch({ + // url: '../earth/earth?devcode=' + event.target.dataset.devcode + // // url: '../earth/earth' + // }) }, onSearch: function () { + var _this = this wx.navigateTo({ - url: '../searchLog/searchLog' + url: '../searchLog/searchLog?params=' + JSON.stringify(_this.data.params) }) - }, - // initPages: function () { - // wx.cloud.callFunction({ - // name: 'devicelog' - // }).then(res => { - // var that = this; - // var jsonList = JSON.parse(res.result) - // that.setData({ - // deviceloglist: jsonList.data.rows - // }) - // console.log(res); - // }).catch(err => { - // console.error(err); - // }) - // } + } }) \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.wxml b/miniprogram/pages/applog/applog.wxml index e9a2352..2bfd041 100644 --- a/miniprogram/pages/applog/applog.wxml +++ b/miniprogram/pages/applog/applog.wxml @@ -1,54 +1,59 @@ - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {{item.devcode}} {{item.devicetype}} + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + {{item.devcode}} {{item.devicetype}} + + {{item.project}} {{item.installtime}}- {{item.installperson}} - - - - - + + + + + + 删除 - - - + + - 共计:{{total}}台 - + 共计:{{total}}台 + \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.wxss b/miniprogram/pages/applog/applog.wxss index 6d3428b..e6e8983 100644 --- a/miniprogram/pages/applog/applog.wxss +++ b/miniprogram/pages/applog/applog.wxss @@ -22,16 +22,18 @@ position: fixed; width: 100%; top: 0rpx; + z-index: 9999; /* margin-bottom: 100rpx; */ } .log-list { /* height: 100rpx; */ - /* display: flex; */ - + display: flex; + width: 100%; padding: 2px; margin-top: 2px; border-bottom: 1px solid #e5e5e5; + overflow: hidden } @@ -53,23 +55,29 @@ left: 35%; margin: 20rpx } - .del { - width: 90px; + /* display: flex; */ + width: 100rpx; display: flex; flex-direction: column; align-items: center; justify-content: center; - color: #fff; - -webkit-transform: translateX(90px); - transform: translateX(90px); - -webkit-transition: all 0.4s; + /* -webkit-transform: translateX(100rpx); */ + transform: translateX(100rpx); + /* -webkit-transition: all 0.4s; */ transition: all 0.4s; - font-size: 35rpx; + color: #fff; + background-color: #fe3e2f; +} +.logrow{ + width: 100%; + transform: translateX(100rpx); + /* -webkit-transform: translateX(100px); */ + margin-left: -100rpx; } -.touch-move-active .content, +.touch-move-active .logrow, .touch-move-active .del { - -webkit-transform: translateX(0); - transform: translateX(0); +/* -webkit-transform: translateX(0); */ +transform: translateX(0); } \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.js b/miniprogram/pages/deployFunctions/deployFunctions.js deleted file mode 100644 index a76b144..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.js +++ /dev/null @@ -1,66 +0,0 @@ -// pages/deployFunctions/deployFunctions.js -Page({ - - /** - * 页面的初始数据 - */ - data: { - - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - - }, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { - - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - - }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { - - }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { - - } -}) \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.json b/miniprogram/pages/deployFunctions/deployFunctions.json deleted file mode 100644 index 7fbedab..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "navigationBarTitleText": "部署云函数", - "usingComponents": {} -} \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.wxml b/miniprogram/pages/deployFunctions/deployFunctions.wxml deleted file mode 100644 index 462b6b6..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.wxml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - 调用失败 - - - 请检查 login 云函数是否已部署 - - - - - 部署 login 云函数 - 1. 确保已通过工具栏云开发入口开通云开发 - 2. 在 cloudfunctions/login 目录上右键上传并部署 - 3. 回到首页,重新点击获取 openid - - - - diff --git a/miniprogram/pages/deployFunctions/deployFunctions.wxss b/miniprogram/pages/deployFunctions/deployFunctions.wxss deleted file mode 100644 index c8803e6..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.wxss +++ /dev/null @@ -1,7 +0,0 @@ -/* pages/deployFunctions/deployFunctions.wxss */ - -@import "../../style/guide.wxss"; - -.black { - color: black; -} \ No newline at end of file diff --git a/miniprogram/pages/earth/earth.js b/miniprogram/pages/earth/earth.js index ae0d3f3..376a6e2 100644 --- a/miniprogram/pages/earth/earth.js +++ b/miniprogram/pages/earth/earth.js @@ -21,19 +21,12 @@ show: false, enableSsatellite: false, windowWidth: 0, - longitude: 113.324520, - latitude: 23.099994, - longitude84: 113.324520, - latitude84: 23.099994, - markers: [{ - id: 0, - iconPath: "../../images/locat.png", - latitude: 23.099994, - longitude: 113.324520, - width: 50, - height: 50 - }], - controls: [], + longitude: "116.627340", + latitude: "39.874390", + longitude84: "", + latitude84: "", + markers: [], + controls: [] }, /** @@ -41,39 +34,13 @@ */ onLoad: function (options) { var that = this; - //获取当前坐标(gcj02) - wx.getLocation({ - type: "gcj02", - altitude: true, - success: function (res) { - that.setData({ - latitude: parseFloat(res.latitude).toFixed(6), - longitude: parseFloat(res.longitude).toFixed(6), - // markers: [{ - // latitude: res.latitude, - // longitude: res.longitude, - // }] - }) - //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 - wx.getLocation({ - type: "wgs84", - altitude: true, - success: function (res) { - that.setData({ - latitude84: parseFloat(res.latitude).toFixed(6), - longitude84: parseFloat(res.longitude).toFixed(6) - }) - } - }) - } - }), - - //设置地图组件 - wx.getSystemInfo({ + //设置地图组件 + wx.getSystemInfo({ success(res) { var windowWidth = res.windowWidth var windowHeight = res.windowHeight var query = wx.createSelectorQuery() + var platform =res.platform query.select('#map').boundingClientRect() query.exec(function (res) { that.setData({ @@ -139,10 +106,20 @@ clickable: true }, { id: 7, - iconPath: '../../images/locat.png', + iconPath: '../../images/applocat.png', position: { - left: res[0].width/2, - top: res[0].height/2, + left: res[0].width / 2 - 20, + top: platform=="ios"?res[0].height / 2 - 80:res[0].height / 2 - 40, + width: 40, + height: 40 + }, + clickable: true + }, { + id: 8, + iconPath: '../../images/back.png', + position: { + left: windowWidth - 40, + top: windowHeight - 140, width: 30, height: 30 }, @@ -150,71 +127,15 @@ }] }) }) - + } - }), + }) + // 实例化API核心类 qqmapsdk = new QQMapWX({ key: 'BGPBZ-C5O3P-ROUDR-LWC4J-63EKH-V5FRX' }) - - if (options.devcode) { - var that = this - var devcode = options.devcode - wx.cloud.callFunction({ - name: 'findListByCodes', - data: { - devcodes: devcode, - url: app.globalData.url + "appDeviceAdd/findListByCodes" - }, - }).then(res => { - if (res.result.code == 200) { - var listResultData = res.result.data; - that.setData({ - listData: listResultData - }) - var markersArr = that.data.markers; - for (var i = 0; i < listResultData.length; i++) { - markersArr = markersArr.concat({ - iconPath: "../../images/locat.png", - id: listResultData[i].id, - callout: { - content: listResultData[i].devcode, - fontSize: '14', - // padding: true, - color: '#00000', - borderColor: '#F4EA2A', - bgColor: '#F4EA2A', - borderWidth: 5, - display: 'ALWAYS', - textAlign: 'center', - // borderRadius: 15 - }, - latitude: listResultData[i].latitude, - longitude: listResultData[i].longitude, - width: 40, - height: 40 - }); - } - this.setData({ - markers: markersArr, - latitude: listResultData[0].latitude, - longitude: listResultData[0].longitude, - marker_latitude: listResultData[0].latitude, - marker_longitude: listResultData[0].longitude, - title: listResultData[0].devcode - }) - } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "无法获取设备地理信息!", - icon: 'none', - duration: 2000 - }) - }) - } }, /** @@ -228,6 +149,97 @@ * 生命周期函数--监听页面显示 */ onShow: function () { + //输入设备编号获取marker位置信息 + var that = this; + if ( app.globalData.devcode!="") { + var devcode = app.globalData.devcode + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/findListByCodes", + data: { + devcodes: devcode, + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + app.globalData.devcode=""; + if (res.data.code == 200) { + var listResultData = res.data.data; + that.setData({ + listData: listResultData + }) + var markersArr = that.data.markers; + for (var i = 0; i < listResultData.length; i++) { + markersArr = markersArr.concat({ + iconPath: "../../images/locat.png", + id: Number(listResultData[i].id), + callout: { + content: "编号:"+listResultData[i].devcode+"\r\n位置:"+listResultData[i].position+"\r\n时间:"+listResultData[i].createtime, + fontSize: '14', + padding: true, + color: '#000000', + borderColor: '#F4EA2A', + bgColor: '#F4EA2A', + borderWidth: 5, + display: 'ALWAYS', + textAlign: 'left', + // borderRadius: 15 + }, + latitude: listResultData[i].latitude, + longitude: listResultData[i].longitude, + width: 40, + height: 40 + }); + } + that.setData({ + markers: markersArr, + latitude: listResultData[0].latitude, + longitude: listResultData[0].longitude, + marker_latitude: listResultData[0].latitude, + marker_longitude: listResultData[0].longitude, + title: listResultData[0].devcode + }) + } + }, + fail(err) { + app.globalData.devcode=""; + wx.showToast({ + title: "无法获取设备地理信息!", + icon: 'none', + duration: 2000 + }) + } + }) +} else { + //获取当前坐标(gcj02) + wx.getLocation({ + type: "gcj02", + altitude: true, + success: function (res) { + that.setData({ + latitude: parseFloat(res.latitude).toFixed(6), + longitude: parseFloat(res.longitude).toFixed(6), + // markers: [{ + // latitude: res.latitude, + // longitude: res.longitude, + // }] + }) + //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 + wx.getLocation({ + type: "wgs84", + altitude: true, + success: function (res) { + that.setData({ + latitude84: parseFloat(res.latitude).toFixed(6), + longitude84: parseFloat(res.longitude).toFixed(6) + }) + } + }) + } + }) +} + }, @@ -265,12 +277,46 @@ onShareAppMessage: function () { }, + + //定位出来 + + locationPosition: function () { + var that = this; + //获取当前坐标(gcj02) + wx.getLocation({ + type: "gcj02", + altitude: true, + success: function (res) { + that.setData({ + latitude: parseFloat(res.latitude).toFixed(6), + longitude: parseFloat(res.longitude).toFixed(6), + // markers: [{ + // latitude: res.latitude, + // longitude: res.longitude + // }] + }) + //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 + wx.getLocation({ + type: "wgs84", + altitude: true, + success: function (res) { + that.setData({ + latitude84: parseFloat(res.latitude).toFixed(6), + longitude84: parseFloat(res.longitude).toFixed(6) + }) + } + }) + } + }) + }, + + //加载地图组件 controltap: function (e) { // console.log(e.controlId); //进入添加设备页 if (1 == e.controlId) { wx.setClipboardData({ - data: this.data.latitude + "," + this.data.longitude+ "," + this.data.latitude84+ "," + this.data.longitude84, + data: this.data.latitude + "," + this.data.longitude + "," + this.data.latitude84 + "," + this.data.longitude84, success: function (res) { wx.getClipboardData({ success: function (res) { @@ -282,6 +328,17 @@ } }) } else if (3 == e.controlId) { + //先定位 + // this.locationPosition() + wx.setClipboardData({ + data: this.data.latitude + "," + this.data.longitude + "," + this.data.latitude84 + "," + this.data.longitude84, + success: function (res) { + wx.showToast({ + title: '坐标已获取', + duration: 1000 + }) + } + }) wx.navigateTo({ url: '../addDevice/addDevice' }) @@ -302,32 +359,15 @@ enableSsatellite: !flag }); } else if (6 == e.controlId) { - var that = this; - //获取当前坐标(gcj02) - wx.getLocation({ - type: "gcj02", - altitude: true, - success: function (res) { - that.setData({ - latitude: parseFloat(res.latitude).toFixed(6), - longitude:parseFloat(res.longitude).toFixed(6), - // markers: [{ - // latitude: res.latitude, - // longitude: res.longitude - // }] - }) - //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 - wx.getLocation({ - type: "wgs84", - altitude: true, - success: function (res) { - that.setData({ - latitude84: parseFloat(res.latitude).toFixed(6), - longitude84: parseFloat(res.longitude).toFixed(6) - }) - } - }) - } + //先清marker + this.setData({ + markers: [] + }) + this.locationPosition() + }else if (8 == e.controlId) { + //跳转日志缓存页 + wx.switchTab({ + url: '../applog/applog', }) } }, @@ -343,63 +383,68 @@ }); }, + //获取设备maker leave() { var that = this; if (that.data.devcodes == "") { return false; } - wx.cloud.callFunction({ - name: 'findListByCodes', + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/findListByCodes", data: { - devcodes: that.data.devcodes, - url: app.globalData.url + "appDeviceAdd/findListByCodes" + devcodes: that.data.devcodes }, - }).then(res => { - if (res.result.code == 200) { - var listResultData = res.result.data; - that.setData({ - listData: listResultData - }) - var markersArr = that.data.markers; - for (var i = 0; i < listResultData.length; i++) { - markersArr = markersArr.concat({ - iconPath: "../../images/locat.png", - id: listResultData[i].id, - callout: { - content: listResultData[i].devcode, - fontSize: '14', - // padding: true, - color: '', - borderColor: '#F4EA2A', - bgColor: '#F4EA2A', - borderWidth: 5, - display: 'ALWAYS', - textAlign: 'center', - // borderRadius: 15 - }, - latitude: listResultData[i].latitude, - longitude: listResultData[i].longitude, - width: 40, - height: 40 - }); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var listResultData = res.data.data; + that.setData({ + listData: listResultData + }) + var markersArr = that.data.markers; + for (var i = 0; i < listResultData.length; i++) { + markersArr = markersArr.concat({ + iconPath: "../../images/locat.png", + id: listResultData[i].id, + callout: { + content: "编号:"+listResultData[i].devcode+"\r\n位置:"+listResultData[i].position+"\r\n时间:"+listResultData[i].createtime, + fontSize: '14', + // padding: true, + color: '#212121', + borderColor: '#F4EA2A', + bgColor: '#F4EA2A', + borderWidth: 5, + display: 'ALWAYS', + textAlign: 'left', + // borderRadius: 15 + }, + latitude: listResultData[i].latitude, + longitude: listResultData[i].longitude, + width: 40, + height: 40 + }); + } + that.setData({ + markers: markersArr, + latitude: listResultData[0].latitude, + longitude: listResultData[0].longitude, + marker_latitude: listResultData[0].latitude, + marker_longitude: listResultData[0].longitude, + title: listResultData[0].devcode + }) } - this.setData({ - markers: markersArr, - latitude: listResultData[0].latitude, - longitude: listResultData[0].longitude, - marker_latitude: listResultData[0].latitude, - marker_longitude: listResultData[0].longitude, - title: listResultData[0].devcode + }, + fail(err) { + wx.showToast({ + title: "无法获取设备地理信息!", + icon: 'none', + duration: 2000 }) } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "无法获取设备地理信息!", - icon: 'none', - duration: 2000 - }) }) }, @@ -422,6 +467,8 @@ } }, + + bindregionchange: function (e) { var that = this if (e.causedBy == "drag") { @@ -445,8 +492,8 @@ that.setData({ latitude: parseFloat(latitude).toFixed(6), longitude: parseFloat(longitude).toFixed(6), - latitude84:"", - longitude84:"", + latitude84: "", + longitude84: "", // markers: markersArr }) // mapCtx.moveToLocation(); @@ -465,16 +512,19 @@ qqmapsdk.search({ keyword: this.data.value, success: function (res) { + console.log(res) if (res && res.data) { _this.setData({ isShow: true, tips: res.data }); } + }, + complete: function (res){ + console.log(res); } }) }, - bindSearch: function (e) { var location = e.target.dataset.location; this.setData({ diff --git a/miniprogram/pages/earth/earth.wxml b/miniprogram/pages/earth/earth.wxml index a0db6ef..87474f8 100644 --- a/miniprogram/pages/earth/earth.wxml +++ b/miniprogram/pages/earth/earth.wxml @@ -1,9 +1,10 @@ + - + {{item.title}} {{item.address}} @@ -17,6 +18,6 @@ + placeholder="请输入定位设备编号用换行隔开" autosize border="{{ false }}" /> \ No newline at end of file diff --git a/cloudfunctions/project.config.json b/cloudfunctions/project.config.json new file mode 100644 index 0000000..2b3119a --- /dev/null +++ b/cloudfunctions/project.config.json @@ -0,0 +1,28 @@ +{ + "appid": "wx2cef527a000f87c9", + "compileType": "miniprogram", + "libVersion": "2.27.3", + "packOptions": { + "ignore": [], + "include": [] + }, + "setting": { + "coverView": true, + "es6": true, + "postcss": true, + "minified": true, + "enhance": true, + "showShadowRootInWxmlPanel": true, + "packNpmRelationList": [], + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + } + }, + "condition": {}, + "editorSetting": { + "tabIndent": "insertSpaces", + "tabSize": 4 + } +} \ No newline at end of file diff --git a/cloudfunctions/project.private.config.json b/cloudfunctions/project.private.config.json new file mode 100644 index 0000000..42ff49d --- /dev/null +++ b/cloudfunctions/project.private.config.json @@ -0,0 +1,7 @@ +{ + "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", + "projectname": "cloudfunctions", + "setting": { + "compileHotReLoad": true + } +} \ No newline at end of file diff --git a/miniprogram/app.js b/miniprogram/app.js index 51d56f3..50a8a54 100644 --- a/miniprogram/app.js +++ b/miniprogram/app.js @@ -18,13 +18,15 @@ // this.globalData = {} }, globalData: { - // url: "http://111.198.10.15:11604/", - httpsUrl: "https://logapi.smartlog.work/", - httpsTestUrl: "https://smartlog.work/prodapi4test/", - url: "http://139.198.18.188:8083/", + httpsUrl: "https://logapi.smartlog.work/", + // httpsUrl: "http://139.198.18.188:8083/", // url: "http://127.0.0.1:8083/", - // httpsUrl: "http://127.0.0.1:8083/", + //httpsUrl: "http://127.0.0.1:8083/", openid: null, - indexCount:1 - }, + indexCount:1, + nickName:"", + userName:"", + role:"", + devcode:"" + } }) diff --git a/miniprogram/app.json b/miniprogram/app.json index d23f798..2b6db76 100644 --- a/miniprogram/app.json +++ b/miniprogram/app.json @@ -1,15 +1,17 @@ { "cloud": true, "pages": [ + "pages/login/login", "pages/indexapp/indexapp", "pages/earth/earth", "pages/applog/applog", "pages/addDevice/addDevice", "pages/addDevicelog/addDeviceLog", - "pages/searchLog/searchLog" + "pages/searchLog/searchLog", + "pages/notice/notice" ], "window": { - "backgroundColor": "#F6F6F6", + "backgroundColor": "#E6D480", "backgroundTextStyle": "light", "navigationBarBackgroundColor": "#FFCF00", "navigationBarTitleText": "智慧施工", @@ -46,11 +48,11 @@ "desc": "你的位置信息将用于小程序位置接口的效果展示" } }, + "requiredPrivateInfos": ["getLocation", "chooseLocation"], "networkTimeout": { "request": 30000, "connectSocket": 30000, "uploadFile": 30000, "downloadFile": 30000 - }, - "style": "v2" + } } \ No newline at end of file diff --git a/miniprogram/images/applocat.png b/miniprogram/images/applocat.png new file mode 100644 index 0000000..fe49f54 --- /dev/null +++ b/miniprogram/images/applocat.png Binary files differ diff --git a/miniprogram/images/back.png b/miniprogram/images/back.png new file mode 100644 index 0000000..32ac82d --- /dev/null +++ b/miniprogram/images/back.png Binary files differ diff --git a/miniprogram/images/bottom.png b/miniprogram/images/bottom.png new file mode 100644 index 0000000..d910e98 --- /dev/null +++ b/miniprogram/images/bottom.png Binary files differ diff --git a/miniprogram/images/header.png b/miniprogram/images/header.png new file mode 100644 index 0000000..6ea222e --- /dev/null +++ b/miniprogram/images/header.png Binary files differ diff --git a/miniprogram/images/login.png b/miniprogram/images/login.png index 8b73cc0..6471c46 100644 --- a/miniprogram/images/login.png +++ b/miniprogram/images/login.png Binary files differ diff --git a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss index 5a591fb..c9c35b5 100644 --- a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss +++ b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:100%;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:100%}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file +@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:650rpx;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:600rpx}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file diff --git a/miniprogram/pages/addDevice/addDevice.js b/miniprogram/pages/addDevice/addDevice.js index 2783674..78f00b7 100644 --- a/miniprogram/pages/addDevice/addDevice.js +++ b/miniprogram/pages/addDevice/addDevice.js @@ -1,5 +1,7 @@ // miniprogram/pages/addDevice/addDevice.js // import WxValidate from '../../utils/WxValidate.js' +var QQMapWX = require('../../libs/qqmap-wx-jssdk.js'); +var qqmapsdk; var app = getApp() Page({ @@ -11,32 +13,10 @@ canvasWidth: '', longitude: '', latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], + option1: [], personoption1: [], projectoption: [], + devtypeList:[], show: false, form: { devcode: "", @@ -59,7 +39,10 @@ project: "", area: "", street: "", - wellname: "" + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '', }, fileList: [] }, @@ -117,12 +100,14 @@ var that = this; //初始化表单内容为上次填写值 var cacheForms = wx.getStorageSync('cacheList') - if (cacheForms) { + cacheForms.photopath1='' + cacheForms.photopath2='' + cacheForms.photopath3='' + that.data.fileList=[] that.setData({ form: cacheForms, devcode: cacheForms.devcode, - }) } var form = that.data.form @@ -155,55 +140,89 @@ } }) + +//获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + that.setData({ + option1: welltypeArr + }) + } + } +}) + + //获取人员下拉列表 - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/getUser", + data:{ + tips:'repair' }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data.code == 200) { + var users = res.data.data + var personArr = []; + for (var i = 0; i < users.length; i++) { + var person = { + text: users[i].name, + value: users[i].name + }; + personArr.push(person); + } + that.setData({ + personoption1: personArr + }) } - that.setData({ - personoption1: personArr - }) } - }).catch(err => { - console.error(err); - }) + }) + - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - that.setData({ - projectoption: projectArr - }) + success(res){ + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); + } + that.setData({ + projectoption: projectArr + }) + } } - }).catch(err => { - console.error(err); - }) + }) + var installtime = 'form.installtimeFmt'; var dateNow = this.formatDate(); this.setData({ @@ -211,8 +230,40 @@ installtimeFmt: dateNow, [installtime]: dateNow, }); + + + + /** + * 获取设备类型下拉列表 + */ + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/deviceType", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var TypeList = res.data.data + var typeArr = []; + for (var i = 0; i < TypeList.length; i++) { + var type = { + text: TypeList[i].productName, + value: TypeList[i].productName + }; + typeArr.push(type); + } + that.setData({ + devtypeList: typeArr + }) + } + } + }) }, + + + /** * 生命周期函数--监听页面初次渲染完成 */ @@ -280,29 +331,7 @@ }, - - //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 - drawText: function (ctx, str, leftWidth, initHeight, titleHeight, canvasWidth) { - var lineWidth = 0; - var lastSubStrIndex = 0; //每次开始截取的字符串的索引 - for (let i = 0; i < str.length; i++) { - lineWidth += ctx.measureText(str[i]).width; - if (lineWidth > canvasWidth) { - ctx.fillText(str.substring(lastSubStrIndex, i), leftWidth, initHeight); //绘制截取部分 - initHeight = initHeight + leftWidth * 2; //22为字体的高度 - lineWidth = 0; - lastSubStrIndex = i; - // titleHeight += 40; - } - if (i == str.length - 1) { //绘制剩余部分 - ctx.fillText(str.substring(lastSubStrIndex, i + 1), leftWidth, initHeight); - } - } - // // 标题border-bottom 线距顶部距离 - // titleHeight = titleHeight + 10; - // return titleHeight - }, - + //验证表单 formValidate() { if (this.data.form.devcode == "") { @@ -312,27 +341,20 @@ }) return false } - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } if (this.data.form.wellcode == "") { wx.showToast({ icon: 'none', @@ -348,22 +370,10 @@ }) return false } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null) { + + if (this.data.form.installperson == "") { wx.showToast({ icon: 'none', title: '安装人员不能为空!', @@ -408,56 +418,90 @@ } return true; }, + //提交表单 formSubmit: function (event) { + console.log(this.data.form) + //表单参数验证 if (!this.formValidate()) { return false; } var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDevice', + //验证设备编号长度 + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/getDevTypeLength", data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceAdd/add" + code: encodeURI(this.data.form.devicetype) }, - }).then(res => { - if (res.result.code == 500) { - wx.showToast({ - title: '设备编号已安装!', - }) - } else if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - //用于回显 - wx.setStorageSync('cacheList', that.data.form) - //提交成功后提示用户操作 - if (res.confirm) { - wx.switchTab({ - url: '../earth/earth' - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (""==res.data.data ||res.data.data == that.data.form.devcode.length) { + that.saveDevice() + } else { //编号位数不对提示 + wx.showToast({ + icon: 'none', + title: '设备编号位数不对!', + duration: 1000 + }) + return false + } } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "提交失败", - }) }) }, + + //保存设备基本信息 + saveDevice() { + var that = this; + //设置照片路径 + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopathForm = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopathForm]: fileList[i].url.split("static/")[1] + }) + } + //表单提交 + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 500) { + wx.showToast({ + title: '设备编号已安装!', + }) + } else if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + //用于回显 + wx.setStorageSync('cacheList', that.data.form) + //提交成功后提示用户操作 + if (res.confirm) { + wx.switchTab({ + url: '../earth/earth' + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } + }, + fail(err) { + wx.showToast({ + title: '提交失败!', + }) + } + }) + }, + + //input 输入框设置值 confirm(event) { var that = this; var formValue = event.detail.value; @@ -466,8 +510,30 @@ that.setData({ [fromN]: formValue }) + //若输入是设备编号,自动获取设备类型 + if('devcode'==formName){ + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", + data: { + devcode: formValue, + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + that.setData({ + [formDevicetype]: res.data + }); + } + } + }) + } }, + //扫描设备获取编号和设备类型 scan() { var _this = this; wx.scanCode({ @@ -477,23 +543,28 @@ _this.setData({ [formdevcode]: devcode }); - wx.cloud.callFunction({ - name: 'findModeCode', + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", data: { devcode: devcode, - url: app.globalData.url + "appDeviceAdd/findModeCodeByCode" }, - }).then(res => { - if (res.result) { - var formDevicetype = 'form.devicetype' - _this.setData({ - [formDevicetype]: res.result - }); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + _this.setData({ + [formDevicetype]: res.data + }); + } } }) } }) }, + //粘贴经纬度 paste() { var _this = this; wx.getClipboardData({ @@ -510,9 +581,11 @@ longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), }); + _this.showAddress(_this.data.form.longitude,_this.data.form.latitude,_this) } }) }, + //设置经类型 selectValue(value) { var that = this; @@ -521,6 +594,16 @@ [wellType]: value.detail }) }, + + //设置设备类型 + selectDevType(event) { + var that = this; + var devtype = 'form.devicetype'; + that.setData({ + [devtype]: event.detail + }) + }, + //设置运维人员 selectpersonValue(event) { var that = this; var installPerson = 'form.installperson'; @@ -528,6 +611,7 @@ [installPerson]: event.detail }) }, + //设置项目 selectprojectValue(event) { var that = this; var project = 'form.project'; @@ -535,8 +619,41 @@ [project]: event.detail }) }, + showAddress :function(longitude, latitude, self) { + // 实例化腾讯地图API核心类 + qqmapsdk = new QQMapWX({ + key: 'BGPBZ-C5O3P-ROUDR-LWC4J-63EKH-V5FRX'//此处使用你自己申请的key + }) + // 腾讯地图调用接口 + qqmapsdk.reverseGeocoder({ + location: { + latitude: latitude, + longitude: longitude + }, + success: function (res) { + self.setData({ + 'form.area':res.result.address.slice(0,res.result.address.indexOf('区')+1), + 'form.street':res.result.address.slice(res.result.address.indexOf('区')+1) + }) + }, + fail: function (res) { + console.log(res); + }, + complete: function (res) { + } + }); + }, + //上传照片 afterRead(event) { var _this = this; + if (_this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '请先填写设备编号!\r\n否则水印中无编号', + duration: 2000 + }) + return false + } const { file } = event.detail; @@ -576,78 +693,8 @@ }) } }) - // 压缩图片 - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // //获取图片尺寸 - // wx.getImageInfo({ - // src: convertpath, - // success(res) { - // _this.setData({ - // canvasHeight: res.height, - // canvasWidth: res.width - // }) - // var ctx = wx.createCanvasContext('firstCanvas') - - // //将图片src放到cancas内,宽高为图片大小 - // ctx.drawImage(convertpath, 0, 0, res.width, res.height) - // //将声明的时间放入canvas - // ctx.setFontSize(30 * (res.width / 750)) //注意:设置文字大小必须放在填充文字之前,否则不生效 - // ctx.setFillStyle('blue') - // var text = "编号:" + _this.data.form.devcode + "\n经度:" + _this.data.form.longitude + "\n纬度:" + _this.data.form.latitude - // // _this.drawText(ctx,text,20, 70, 5, res.width) - // _this.drawText(ctx, text, 15 * (res.width / 750), 70 * (res.width / 750), 5, res.width) - - // // ctx.fillText(text, 0, 40) - // // ctx.strokeText(_this.data.form.devcode, 0, 30) - // //生成水印图 - // ctx.draw(false, function () { - // wx.canvasToTempFilePath({ - // canvasId: 'firstCanvas', - // success: (res) => { - // wx.compressImage({ - // src: res.tempFilePath, - // quality: 25, - // success: function (res) { - // //上传照片至服务器 - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: res.tempFilePath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // } - // }) - // //// - // } - // }) - // }) - // } - // }) - // } - // }); }, + //删除照片 deletePhoto(event) { var image_index = event.detail.index var fileList_new = this.data.fileList; diff --git a/miniprogram/pages/addDevice/addDevice.wxml b/miniprogram/pages/addDevice/addDevice.wxml index b0977e2..f12c254 100644 --- a/miniprogram/pages/addDevice/addDevice.wxml +++ b/miniprogram/pages/addDevice/addDevice.wxml @@ -5,18 +5,30 @@ - + + + + + + + + + + + + + - - + + - - - + + + @@ -29,13 +41,13 @@ - + - + - + - + @@ -54,8 +66,7 @@ - - + @@ -68,8 +79,8 @@ - - + + - 保存 + 保存 \ No newline at end of file diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.js b/miniprogram/pages/addDevicelog/addDeviceLog.js index cdec71b..a0dc6da 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.js +++ b/miniprogram/pages/addDevicelog/addDeviceLog.js @@ -3,681 +3,665 @@ var app = getApp(); Page({ - /** - * 页面的初始数据 - */ - data: { - pageName: '', - showMask: false, - today: new Date().getTime(), - longitude: '', - latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], - personoption1: [], - projectoption: [], - devcode: "", - deviceMode: "", - installtimeFmt: '', - show: false, - form: { - devcode: "", - wellcode: "", - welltype: "", - welldepth: "", - installheigt: "", - installperson: "", - installtimeFmt: "", - photopath: "", - factory: "", - workmsg: "", - position: "", - description: "", - longitude: "", - latitude: "", - longitude84: "", - latitude84: "", - devicetype: "", - project: "", - area: "", - street: "", - wellname: "" - }, - fileList: [], - detail: "" - }, + /** + * 页面的初始数据 + */ + data: { + pageName: '', + showMask: false, + today: new Date().getTime(), + longitude: '', + latitude: '', + option1: [], + personoption1: [], + projectoption: [], + devcode: "", + deviceMode: "", + installtimeFmt: '', + show: false, + form: { + devcode: "", + wellcode: "", + welltype: "", + welldepth: "", + installheigt: "", + installperson: "", + installtimeFmt: "", + photopath: "", + factory: "", + workmsg: "", + position: "", + description: "", + longitude: "", + latitude: "", + longitude84: "", + latitude84: "", + devicetype: "", + project: "", + area: "", + street: "", + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '' + }, + fileList: [], + detail: "", + markers: [{ + id: 100, + // iconPath: "../../images/point.png", + latitude: '', + longitude: '', + // label:'1', + width: 25, + height: 35 + }], + }, - onDisplay() { - this.setData({ - show: true - }); - }, - onClose() { - this.setData({ - show: false - }); - }, - formatDate() { - var date = new Date(); - // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; - var seperator1 = "-"; - var month = date.getMonth() + 1; - var strDate = date.getDate(); - var hour = date.getHours() - var minute = date.getMinutes() - var second = date.getSeconds() - month = month > 9 ? month : "0" + month; - strDate = strDate > 9 ? strDate : "0" + strDate; - hour = hour > 9 ? hour : "0" + hour; - minute = minute > 9 ? minute : "0" + minute; - second = second > 9 ? second : "0" + second; - var currentdate = - date.getFullYear() + - seperator1 + - month + - seperator1 + - strDate + - " " + - hour + ":" + - minute + ":" + - second; - return currentdate; + onDisplay() { + this.setData({ + show: true + }); + }, + onClose() { + this.setData({ + show: false + }); + }, + formatDate() { + var date = new Date(); + // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; + var seperator1 = "-"; + var month = date.getMonth() + 1; + var strDate = date.getDate(); + var hour = date.getHours() + var minute = date.getMinutes() + var second = date.getSeconds() + month = month > 9 ? month : "0" + month; + strDate = strDate > 9 ? strDate : "0" + strDate; + hour = hour > 9 ? hour : "0" + hour; + minute = minute > 9 ? minute : "0" + minute; + second = second > 9 ? second : "0" + second; + var currentdate = + date.getFullYear() + + seperator1 + + month + + seperator1 + + strDate + + " " + + hour + ":" + + minute + ":" + + second; + return currentdate; - }, - onConfirm(event) { - var installtime = 'form.installtimeFmt'; - this.setData({ - show: false, - installtimeFmt: this.formatDate(event.detail), - [installtime]: this.formatDate(event.detail), - }); - }, + }, + onConfirm(event) { + var installtime = 'form.installtimeFmt'; + this.setData({ + show: false, + installtimeFmt: this.formatDate(event.detail), + [installtime]: this.formatDate(event.detail), + }); + }, - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - var _this = this; - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" - }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); - } - _this.setData({ - personoption1: personArr - }) + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + var _this = this; + _this.setData({ + 'markers[0].latitude': Number(wx.getStorageSync('resultObject').latitude) , + 'markers[0].longitude': Number(wx.getStorageSync('resultObject').longitude), + // 'markers[0].label':'10', + 'markers[0].width': 18, + 'markers[0].id':1, + 'markers[0].height': 30, + latitude:Number(wx.getStorageSync('resultObject').latitude), + longitude:Number(wx.getStorageSync('resultObject').longitude) + }) + //获取人员下拉列表 + // wx.request({ + // method: "POST", + // url: app.globalData.httpsUrl + "deviceType/getUser", + // data:{ + // tips:'repair' + // }, + // header: { + // 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + // }, + // success(res) { + // if (res.data.code == 200) { + // var users = res.data.data + // var personArr = []; + // for (var i = 0; i < users.length; i++) { + // var person = { + // text: users[i].name, + // value: users[i].name + // }; + // personArr.push(person); + // } + // _this.setData({ + // personoption1: personArr + // }) + // } + // } + // }) + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); } - }).catch(err => { - console.error(err); - }) - - - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" - }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - _this.setData({ - projectoption: projectArr - }) - } - }).catch(err => { - console.error(err); - }) - - if (options.pageName) { - this.setData({ - pageName: options.pageName - }) - } - - if (options.detail) { - - var formObject = JSON.parse(options.detail); _this.setData({ - form: formObject, - detail: options.detail + projectoption: projectArr }) - - _this.setData({ - ['form.installperson']: "", - ['form.installtimeFmt']: "", - ['form.workmsg']: "", - ['form.description']: "" - }) - - const { - fileList = [] - } = _this.data; - if (formObject.photopath1 != "") { - var file1 = { - url: app.globalData.url + "static/" + formObject.photopath1 - } - fileList.push(file1) - } - if (formObject.photopath2 != "") { - var file2 = { - url: app.globalData.url + "static/" + formObject.photopath2 - } - fileList.push(file2) - } - if (formObject.photopath3 != "") { - var file3 = { - url: app.globalData.url + "static/" + formObject.photopath3 - } - fileList.push(file3) - } - - _this.setData({ - fileList - }); } - var installtime = 'form.installtimeFmt'; - var dateNow = this.formatDate(); - this.setData({ - installtimeFmt: dateNow, - [installtime]: dateNow, - }); - }, + } + }) - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { + //获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + _this.setData({ + option1: welltypeArr + }) + } + } +}) - }, + //跳转时带入参数返回哪页 + if (options.pageName) { + this.setData({ + pageName: options.pageName + }) + } + //跳转时带入参数设备的安装信息 + if (wx.getStorageSync('resultObject')) { + var formObject = wx.getStorageSync('resultObject') + _this.setData({ + form: formObject, + detail: formObject + }) - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { + _this.setData({ + ['form.installperson']: app.globalData.userName, + ['form.installtimeFmt']: "", + ['form.workmsg']: "", + ['form.description']: "" + }) - }, + const { + fileList = [] + } = _this.data; + if (formObject.photopath1 != "") { + var file1 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath1 + } + fileList.push(file1) + } + if (formObject.photopath2 != "") { + var file2 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath2 + } + fileList.push(file2) + } + if (formObject.photopath3 != "") { + var file3 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath3 + } + fileList.push(file3) + } + _this.setData({ + fileList + }); + } + var installtime = 'form.installtimeFmt'; + var dateNow = this.formatDate(); + this.setData({ + installtimeFmt: dateNow, + [installtime]: dateNow, + }); + }, - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, - }, + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + wx.removeStorageSync('resultObject') + }, - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, - }, + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { + }, - }, + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { + }, - }, + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { + }, - }, + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + }, - /** - * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true - **/ + /** + * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true + **/ - isNumber: function (val) { + isNumber: function (val) { - var regPos = /^[0-9]*$/; //非负浮点数 - var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数 - if (regPos.test(val) || regNeg.test(val)) { - return false; - } else { - return true; - } + var regPos = /^[0-9]*$/; //非负浮点数 + var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数 + if (regPos.test(val) || regNeg.test(val)) { + return false; + } else { + return true; + } - }, + }, - formValidate() { + formValidate() { - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } - if (this.data.form.wellcode == "") { - wx.showToast({ - icon: 'none', - title: '井编号不能为空!', - }) - return false - } - if (this.data.form.devicetype == "") { - wx.showToast({ - icon: 'none', - title: '设备类型不能为空!', - }) - return false - } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + if (this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '设备编号不能为空!', + }) + return false + } + if (this.data.form.wellcode == "") { + wx.showToast({ + icon: 'none', + title: '井编号不能为空!', + }) + return false + } + if (this.data.form.devicetype == "") { + wx.showToast({ + icon: 'none', + title: '设备类型不能为空!', + }) + return false + } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null || - this.data.form.installperson == '') { - wx.showToast({ - icon: 'none', - title: '运维人员不能为空!', - }) - return false - } - if (this.data.form.project == "") { - wx.showToast({ - icon: 'none', - title: '所属项目不能为空!', - }) - return false - } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } + if (this.data.form.installperson == null || + this.data.form.installperson == '') { + wx.showToast({ + icon: 'none', + title: '运维人员不能为空!', + }) + return false + } + if (this.data.form.project == "") { + wx.showToast({ + icon: 'none', + title: '所属项目不能为空!', + }) + return false + } - if (this.data.form.welldepth != null) { - if (this.isNumber(this.data.form.welldepth)) { - wx.showToast({ - icon: 'none', - title: '井深必须为数值!', - }) - return false - } - } - if (this.data.form.installheigt != null) { - if (this.isNumber(this.data.form.installheigt)) { - wx.showToast({ - icon: 'none', - title: '到井口距离必须为数值!', - }) - return false - } - } - - return true; - }, - - changeMsg: function () { - var formNew = this.data.form; - var formOld = JSON.parse(this.data.detail); - var descpNew = ""; - if (formNew.devcode != formOld.devcode) { - descpNew += "修改设备编号,原编号:" + formOld.devcode + ",新编号:" + formNew.devcode + ";" - } - if (formNew.devicetype != formOld.devicetype) { - descpNew += "修改设备类型,原设备类型:" + formOld.devicetype + ",新设备类型:" + formNew.devicetype + ";" - } - if (formNew.area != formOld.area) { - descpNew += "修改区,原区:" + formOld.area + ",新区:" + formNew.area + ";" - } - if (formNew.street != formOld.street) { - descpNew += "修改街道,原街道:" + formOld.street + ",新街道:" + formNew.street + ";" - } - if (formNew.wellname != formOld.wellname) { - descpNew += "修改井名称,原井名称:" + formOld.wellname + ",新井名称:" + formNew.wellname + ";" - } - if (formNew.factory != formOld.factory) { - descpNew += "修改权属单位,原权属单位:" + formOld.factory + ",新权属单位:" + formNew.factory + ";" - } - if (formNew.installheigt != formOld.installheigt) { - descpNew += "修改井口距离,原井口距离:" + formOld.installheigt + ",新井口距离:" + formNew.installheigt + ";" - } - if (formNew.installperson != formOld.installperson) { - descpNew += "修改运维人员,原运维人员:" + formOld.installperson + ",新运维人员:" + formNew.installperson + ";" - } - if (formNew.latitude != formOld.latitude) { - descpNew += "修改纬度,原纬度:" + formOld.latitude + ",新纬度:" + formNew.latitude + ";" - } - if (formNew.longitude != formOld.longitude) { - descpNew += "修改经度,原经度:" + formOld.longitude + ",新经度:" + formNew.longitude + ";" - } - if (formNew.position != formOld.position) { - descpNew += "修改位置描述,原位置:" + formOld.position + ",新位置:" + formNew.position + ";" - } - if (formNew.wellcode != formOld.wellcode) { - descpNew += "修改井编号,原编号:" + formOld.wellcode + ",新编号:" + formNew.wellcode + ";" - } - if (formNew.welldepth != formOld.welldepth) { - descpNew += "修改井深,原井深:" + formOld.welldepth + ",新井深:" + formNew.welldepth + ";" - } - if (formNew.welltype != formOld.welltype) { - descpNew += "修改井类型,原井类型:" + formOld.welltype + ",新井类型:" + formNew.welltype + ";" - } - if (formNew.project != formOld.project) { - descpNew += "修改所属项目,原项目:" + formOld.project + ",新项目:" + formNew.project + ";" - } - if (this.data.photopath1 != formOld.photopath1 || - this.data.photopath2 != formOld.photopath2 || - this.data.photopath3 != formOld.photopath3) { - descpNew += "修改照片;" - } - if ("" != formNew.description) { - descpNew += formNew.description; - } - this.setData({ - ['form.description']: descpNew + if (this.data.form.welldepth != null) { + if (this.isNumber(this.data.form.welldepth)) { + wx.showToast({ + icon: 'none', + title: '井深必须为数值!', }) - }, + return false + } + } + if (this.data.form.installheigt != null) { + if (this.isNumber(this.data.form.installheigt)) { + wx.showToast({ + icon: 'none', + title: '到井口距离必须为数值!', + }) + return false + } + } - formSubmit: function (event) { + return true; + }, - if (!this.formValidate()) { - return false; - } - this.changeMsg(); - var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDeviceLog', - data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceLog/add" - }, - }).then(res => { - // var resultObj=JSON.parse(res.result); - if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - if (res.confirm) { - wx.switchTab({ - url: that.data.pageName - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) - } - }).catch(err => { - console.error(err) - wx.showToast({ - title: "提交失败", - }) - }) - }, - confirm(event) { - var that = this; - var formValue = event.detail.value; - var formName = event.target.dataset.id; - var fromN = 'form.' + [formName]; - that.setData({ - [fromN]: formValue - }) - }, + //获取与上次修改的信息 + changeMsg: function () { + var formNew = this.data.form; + console.log(this.data.detail) + var formOld = JSON.parse(this.data.detail); + var descpNew = ""; + if (formNew.devcode != formOld.devcode) { + descpNew += "修改设备编号,原值:" + formOld.devcode + ",新值:" + formNew.devcode + ";" + } + if (formNew.devicetype != formOld.devicetype) { + descpNew += "修改设备类型,原值:" + formOld.devicetype + ",新值:" + formNew.devicetype + ";" + } + if (formNew.area != formOld.area) { + descpNew += "修改区,原值:" + formOld.area + ",新值:" + formNew.area + ";" + } + if (formNew.street != formOld.street) { + descpNew += "修改街道,原值:" + formOld.street + ",新值:" + formNew.street + ";" + } + if (formNew.wellname != formOld.wellname) { + descpNew += "修改井名称,原值:" + formOld.wellname + ",新值:" + formNew.wellname + ";" + } + if (formNew.factory != formOld.factory) { + descpNew += "修改权属单位,原值:" + formOld.factory + ",新值:" + formNew.factory + ";" + } + if (formNew.installheigt != formOld.installheigt) { + descpNew += "修改井口距离,原值:" + formOld.installheigt + ",新值:" + formNew.installheigt + ";" + } + if (formNew.installperson != formOld.installperson) { + descpNew += "修改运维人员,原值:" + formOld.installperson + ",新值:" + formNew.installperson + ";" + } + if (formNew.latitude != formOld.latitude) { + descpNew += "修改纬度,原值:" + formOld.latitude + ",新值:" + formNew.latitude + ";" + } + if (formNew.longitude != formOld.longitude) { + descpNew += "修改经度,原值:" + formOld.longitude + ",新值:" + formNew.longitude + ";" + } + if (formNew.position != formOld.position) { + descpNew += "修改位置描述,原值:" + formOld.position + ",新值:" + formNew.position + ";" + } + if (formNew.wellcode != formOld.wellcode) { + descpNew += "修改井编号,原值:" + formOld.wellcode + ",新值:" + formNew.wellcode + ";" + } + if (formNew.welldepth != formOld.welldepth) { + descpNew += "修改井深,原值:" + formOld.welldepth + ",新值:" + formNew.welldepth + ";" + } + if (formNew.welltype != formOld.welltype) { + descpNew += "修改井类型,原值:" + formOld.welltype + ",新值:" + formNew.welltype + ";" + } + if (formNew.project != formOld.project) { + descpNew += "修改所属项目,原值:" + formOld.project + ",新值:" + formNew.project + ";" + } + if (this.data.form.photopath1 != formOld.photopath1 || + this.data.form.photopath2 != formOld.photopath2 || + this.data.form.photopath3 != formOld.photopath3) { + descpNew += "修改照片;" + } + if ("" != formNew.description) { + descpNew += formNew.description; + } + this.setData({ + ['form.description']: descpNew + }) + }, - scan() { + //提交表单 + formSubmit: function (event) { - wx.scanCode({ - success(res) { - console.log(res) - } - }) + //表单验证 + if (!this.formValidate()) { + return false; + } + //自动生成修改内容 + this.changeMsg(); + //提交权限限制(只有施工人员能修改) + if(app.globalData.role!='repair'){ + wx.showToast({ + icon: 'none', + title: '无权限修改', + duration:2000 + }) + return false + } + var that = this; + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopath = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopath]: fileList[i].url.split("static/")[1] + }) + } + delete that.data.form.installtime + delete that.data.form.createtime + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - paste() { - var _this = this; - wx.getClipboardData({ - success: function (res) { - var longitude = 'form.longitude'; - var latitude = 'form.latitude'; - var longitude84 = 'form.longitude84'; - var latitude84 = 'form.latitude84'; - _this.setData({ - [longitude]: parseFloat(res.data.split(",", 4)[1]).toFixed(6), - [latitude]: parseFloat(res.data.split(",", 4)[0]).toFixed(6), - [longitude84]: "" == (res.data.split(",", 4)[3]) ? "" : parseFloat(res.data.split(",", 4)[3]).toFixed(6), - [latitude84]: "" == (res.data.split(",", 4)[2]) ? "" : parseFloat(res.data.split(",", 4)[2]).toFixed(6), - longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), - latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), - }); - } - }) - }, - selectValue(value) { - var that = this; - var wellType = 'form.welltype'; - that.setData({ - [wellType]: value.detail - }) - }, - selectpersonValue(event) { - var that = this; - var installPerson = 'form.installperson'; - that.setData({ - [installPerson]: event.detail - }) - }, - selectprojectValue(event) { - var that = this; - var project = 'form.project'; - that.setData({ - [project]: event.detail, - showMask: true - }) - }, - open() { - this.setData({ - showMask: true - }) - }, - close() { - this.setData({ - showMask: false - }) - }, - afterRead(event) { - var _this = this; - const { - file - } = event.detail; - const { - fileList = [] - } = _this.data; - var convertpath = ""; - wx.compressImage({ - src: event.detail.file.path, - quality: 25, - success: function (res) { - convertpath = res.tempFilePath; - wx.uploadFile({ - url: app.globalData.httpsUrl + "appDeviceAdd/fileUploadMarker", - filePath:convertpath, - name: 'file', - formData: { - 'text': "编号:" + _this.data.form.devcode + "经度:" + _this.data.form.longitude + "纬度:" + _this.data.form.latitude - }, - header: { - "Content-Type": "multipart/form-data", - 'accept': 'application/json', - }, - success(res) { - if (res.data) { - var url = JSON.parse(res.data); - fileList.push({ - ...file, - url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - }); - _this.setData({ - fileList - }); - } - } + success(res) { + if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + if (res.confirm) { + wx.switchTab({ + url: that.data.pageName }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') } - }) - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // // var base64 = "data:image/png;base64," + wx.getFileSystemManager().readFileSync(convertpath, 'base64'); - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: convertpath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // // wx.cloud.callFunction({ - // // name: 'uploadFile', - // // data: { - // // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // // fileBase64: base64 - // // }, - // // success: function (res) { - // // if (res.result) { - // // fileList.push({ - // // ...file, - // // url: app.globalData.url + "static/" + res.result.data.replace(/\\/g, "/") - // // }); - // // _this.setData({ - // // fileList - // // }); - // // } - // // }, - // // complete: res => { - // // }, - // // }) - // } - // }); + } + }) + } + }, + fail(err) { + wx.showToast({ + title: "提交失败", + }) + } + }) + }, + //报存录入的input信息 + confirm(event) { + var that = this; + var formValue = event.detail.value; + var formName = event.target.dataset.id; + var fromN = 'form.' + [formName]; + that.setData({ + [fromN]: formValue + }) + }, + + //扫码 + scan() { + + wx.scanCode({ + success(res) { + console.log(res) + } + }) + }, + //粘贴经纬度 + paste() { + var _this = this; + wx.getClipboardData({ + success: function (res) { + var longitude = 'form.longitude'; + var latitude = 'form.latitude'; + var longitude84 = 'form.longitude84'; + var latitude84 = 'form.latitude84'; + _this.setData({ + [longitude]: parseFloat(res.data.split(",", 4)[1]).toFixed(6), + [latitude]: parseFloat(res.data.split(",", 4)[0]).toFixed(6), + [longitude84]: "" == (res.data.split(",", 4)[3]) ? "" : parseFloat(res.data.split(",", 4)[3]).toFixed(6), + [latitude84]: "" == (res.data.split(",", 4)[2]) ? "" : parseFloat(res.data.split(",", 4)[2]).toFixed(6), + longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), + latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), + }); + } + }) + }, + selectValue(value) { + var that = this; + var wellType = 'form.welltype'; + that.setData({ + [wellType]: value.detail + }) + }, + //运维人员默认为登录人 + // selectpersonValue(event) { + // var that = this; + // var installPerson = 'form.installperson'; + // that.setData({ + // [installPerson]: event.detail + // }) + // }, + selectprojectValue(event) { + var that = this; + var project = 'form.project'; + that.setData({ + [project]: event.detail, + showMask: true + }) + }, + + open() { + this.setData({ + showMask: true + }) + }, + //隐藏textarea,防止遮挡 + close() { + this.setData({ + showMask: false + }) + }, + //上传照片 + afterRead(event) { + var _this = this; + const { + file + } = event.detail; + const { + fileList = [] + } = _this.data; + var convertpath = ""; + wx.compressImage({ + src: event.detail.file.path, + quality: 25, + success: function (res) { + convertpath = res.tempFilePath; + wx.uploadFile({ + url: app.globalData.httpsUrl + "appDeviceAdd/fileUploadMarker", + filePath: convertpath, + name: 'file', + formData: { + 'text': "编号:" + _this.data.form.devcode + "经度:" + _this.data.form.longitude + "纬度:" + _this.data.form.latitude }, - deletePhoto(event) { - var that = this - var image_index = event.detail.index - var fileList_new = that.data.fileList; - wx.showModal({ - content: '确定删除照片?', - success: function (res) { - if (res.confirm) { - fileList_new.splice(image_index, 1); - that.setData({ - fileList: fileList_new - }) - wx.cloud.callFunction({ - name: 'deletePhoto', - data: { - url: app.globalData.url + "appDeviceLog/deletePhoto", - devcode: that.data.form.devcode, - pathIndex: image_index - }, - success: function (res) {}, - complete: res => {}, - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + "Content-Type": "multipart/form-data", + 'accept': 'application/json', }, - }) \ No newline at end of file + success(res) { + if (res.data) { + var url = JSON.parse(res.data); + fileList.push({ + ...file, + url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") + }); + _this.setData({ + fileList + }); + } + } + }) + } + }) + }, + //删除照片 + deletePhoto(event) { + var that = this + var image_index = event.detail.index + var fileList_new = that.data.fileList; + wx.showModal({ + content: '确定删除照片?', + success: function (res) { + if (res.confirm) { + fileList_new.splice(image_index, 1); + that.setData({ + fileList: fileList_new + }) + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deletePhoto", + data: { + devcode: that.data.form.devcode + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) {} + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } +}) \ No newline at end of file diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.wxml b/miniprogram/pages/addDevicelog/addDeviceLog.wxml index 38620d4..b10cc7d 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.wxml +++ b/miniprogram/pages/addDevicelog/addDeviceLog.wxml @@ -1,15 +1,21 @@ - + + + + + - + - - + + - - + + - + @@ -39,24 +45,25 @@ - - - + + + - + - + + @@ -64,7 +71,7 @@ - + @@ -79,9 +86,9 @@ - + - 保存 + 保存 diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.wxss b/miniprogram/pages/addDevicelog/addDeviceLog.wxss index ee0b75c..08d5fd7 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.wxss +++ b/miniprogram/pages/addDevicelog/addDeviceLog.wxss @@ -24,6 +24,17 @@ display: flex; align-items: center; } +.map-view{ + width: 750rpx; + height: 485rpx; + position: fixed; + top: 0px; + left: 0px; + z-index: 999; +} +.content{ + margin-top: 495rpx; +} .left { width: 210rpx; diff --git a/miniprogram/pages/addFunction/addFunction.js b/miniprogram/pages/addFunction/addFunction.js deleted file mode 100644 index 4966be3..0000000 --- a/miniprogram/pages/addFunction/addFunction.js +++ /dev/null @@ -1,60 +0,0 @@ -// pages/addFunction/addFunction.js - -const code = `// 云函数入口函数 -exports.main = (event, context) => { - console.log(event) - console.log(context) - return { - sum: event.a + event.b - } -}` - -Page({ - - data: { - result: '', - canIUseClipboard: wx.canIUse('setClipboardData'), - }, - - onLoad: function (options) { - - }, - - copyCode: function() { - wx.setClipboardData({ - data: code, - success: function () { - wx.showToast({ - title: '复制成功', - }) - } - }) - }, - - testFunction() { - wx.cloud.callFunction({ - name: 'sum', - data: { - a: 1, - b: 2 - }, - success: res => { - wx.showToast({ - title: '调用成功', - }) - this.setData({ - result: JSON.stringify(res.result) - }) - }, - fail: err => { - wx.showToast({ - icon: 'none', - title: '调用失败', - }) - console.error('[云函数] [sum] 调用失败:', err) - } - }) - }, - -}) - diff --git a/miniprogram/pages/addFunction/addFunction.json b/miniprogram/pages/addFunction/addFunction.json deleted file mode 100644 index a9a50c5..0000000 --- a/miniprogram/pages/addFunction/addFunction.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "navigationBarTitleText": "云函数指引", - "usingComponents": {} -} \ No newline at end of file diff --git a/miniprogram/pages/addFunction/addFunction.wxml b/miniprogram/pages/addFunction/addFunction.wxml deleted file mode 100644 index 3a10626..0000000 --- a/miniprogram/pages/addFunction/addFunction.wxml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - 测试云函数 - - - 期望输出:{"sum":3} - - - 调用结果:{{result}} - - - - - 新增云函数 - 1. 在云函数根目录 cloudfunctions 上右键选择新建云函数,命名为 sum - 2. 在创建的 cloudfunctions/sum/index.js 文件中添加如下代码 - - - 3. 在 cloudfunctions/sum 目录上右键上传并部署 - 4. 点击测试云函数测试 - 5. 打开云开发云函数管理页,选择 sum 云函数 - 6. 查看 sum 的调用日志 - 进阶:可在云函数中使用 wx-server-sdk 操作数据库,文件存储和调用其他云函数,详见文档 - - - diff --git a/miniprogram/pages/addFunction/addFunction.wxss b/miniprogram/pages/addFunction/addFunction.wxss deleted file mode 100644 index 7ac8619..0000000 --- a/miniprogram/pages/addFunction/addFunction.wxss +++ /dev/null @@ -1,3 +0,0 @@ -/* pages/addFunction/addFunction.wxss */ - -@import "../../style/guide.wxss"; \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.js b/miniprogram/pages/applog/applog.js index 0e8c185..189e61f 100644 --- a/miniprogram/pages/applog/applog.js +++ b/miniprogram/pages/applog/applog.js @@ -13,98 +13,25 @@ isSeach: "false", params: {}, total: 0, - show: false + show: false, + delBtnWidth: 100, //删除按钮宽度单位(rpx) + activeIndex: -1, + list_style: '' }, - - touchE: function (e) { - // console.log(e); - var that = this - if (e.changedTouches.length == 1) { - //手指移动结束后触摸点位置的X坐标 - var endX = e.changedTouches[0].clientX; - //触摸开始与结束,手指移动的距离 - var disX = that.data.startX - endX; - var delBtnWidth = that.data.delBtnWidth; - //如果距离小于删除按钮的1/2,不显示删除按钮 - var txtStyle = disX > delBtnWidth / 2 ? "left:-" + delBtnWidth + "rpx" : "left:0rpx"; - - //获取手指触摸的是哪一项 - var index = e.currentTarget.dataset.index; - var list = that.data.deviceloglist; - list[index].txtStyle = txtStyle; - //更新列表的状态 - that.setData({ - deviceloglist: list - }); - } - }, - //手指触摸动作开始 记录起点X坐标 - touchstart: function (e) { - //开始触摸时 重置所有删除 - this.data.deviceloglist.forEach(function (v, i) { - if (v.isTouchMove) //只操作为true的 - v.isTouchMove = false; - }) - this.setData({ - startX: e.changedTouches[0].clientX, - startY: e.changedTouches[0].clientY, - deviceloglist: this.data.deviceloglist - }) - }, - //滑动事件处理 - touchmove: function (e) { - var that = this, - index = e.currentTarget.dataset.index, //当前索引 - startX = that.data.startX, //开始X坐标 - startY = that.data.startY, //开始Y坐标 - touchMoveX = e.changedTouches[0].clientX, //滑动变化坐标 - touchMoveY = e.changedTouches[0].clientY, //滑动变化坐标 - //获取滑动角度 - angle = that.angle({ - X: startX, - Y: startY - }, { - X: touchMoveX, - Y: touchMoveY - }); - that.data.deviceloglist.forEach(function (v, i) { - v.isTouchMove = false - //滑动超过30度角 return - if (Math.abs(angle) > 30) return; - if (i == index) { - if (touchMoveX > startX) //右滑 - v.isTouchMove = false - else //左滑 - v.isTouchMove = true - } - }) - //更新数据 - that.setData({ - deviceloglist: that.data.deviceloglist - }) - }, - /** - * 计算滑动角度 - * @param {Object} start 起点坐标 - * @param {Object} end 终点坐标 - */ - angle: function (start, end) { - var _X = end.X - start.X, - _Y = end.Y - start.Y - //返回角度 /Math.atan()返回数字的反正切值 - return 360 * Math.atan(_Y / _X) / (2 * Math.PI); - }, - /** - * 生命周期函数--监听页面加载var_this=this; - */ onLoad: function (options) { - if (options.params) { this.setData({ params: JSON.parse(options.params), isSeach: "true" }) this.initPages() + }else{ + this.setData({ + show: false + }) + //清空参数,重新加载 + this.clearParams(); + this.initPages(); } }, @@ -116,20 +43,33 @@ }, + //点击tabBar事件 + onTabItemTap(item) { + //隐藏历史显示总记录条数 + this.setData({ + show: false + }) + //清空参数,重新加载 + this.clearParams(); + this.initPages(); + }, + + /** * 生命周期函数--监听页面显示 */ onShow: function (options) { - this.setData({ - show:false - }) - if (this.data.isSeach == "false") { - this.clearParams(); - this.initPages(); - } - this.setData({ - isSeach: "false" - }) + + // this.setData({ + // show: false + // }) + // if (this.data.isSeach == "false") { + // this.clearParams(); + // this.initPages(); + // } + // this.setData({ + // isSeach: "false" + // }) }, /** @@ -167,6 +107,119 @@ }, + + //手指触摸动作开始 记录起点X坐标 + touchstart: function (e) { + //开始触摸时 重置所有删除 + this.data.deviceloglist.forEach(function (v, i) { + if (v.isTouchMove) //只操作为true的 + v.isTouchMove = false; + }) + this.setData({ + startX: e.changedTouches[0].clientX, + startY: e.changedTouches[0].clientY, + deviceloglist: this.data.deviceloglist + }) + }, + + //滑动事件处理 + touchmove: function (e) { + var that = this, + index = e.currentTarget.dataset.index, //当前索引 + startX = that.data.startX, //开始X坐标 + startY = that.data.startY, //开始Y坐标 + touchMoveX = e.changedTouches[0].clientX, //滑动变化坐标 + touchMoveY = e.changedTouches[0].clientY, //滑动变化坐标 + //获取滑动角度 + angle = that.angle({ + X: startX, + Y: startY + }, { + X: touchMoveX, + Y: touchMoveY + }); + that.data.deviceloglist.forEach(function (v, i) { + // v.isTouchMove = false + //滑动超过30度角 return + if (Math.abs(angle) > 30) return; + if (i == index) { + if (touchMoveX > startX) //右滑 + v.isTouchMove = false + else //左滑 + v.isTouchMove = true + } + }) + //更新数据 + that.setData({ + deviceloglist: that.data.deviceloglist + }) + }, + + /** + * 计算滑动角度 + * @param {Object} start 起点坐标 + * @param {Object} end 终点坐标 + */ + angle: function (start, end) { + var _X = end.X - start.X, + _Y = end.Y - start.Y + //返回角度 /Math.atan()返回数字的反正切值 + return 360 * Math.atan(_Y / _X) / (2 * Math.PI); + }, + + //删除事件 + delItem: function (e) { + if(app.globalData.role!='repair'){ + wx.showToast({ + icon: 'none', + title: '无权限删除', + duration:2000 + }) + return false + } + var that = this + wx.showModal({ + content: '是否删除?', + success: function (res) { + if (res.confirm) { + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/delete", + data: { + appDeviceAddId: e.currentTarget.dataset.devid + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if(res.data.code=='200'){ + that.data.deviceloglist.splice(e.currentTarget.dataset.index, 1) + that.setData({ + deviceloglist: that.data.deviceloglist, + total: that.data.deviceloglist.length + }) + wx.showToast({ + title: '删除成功!', + icon: 'none', + duration: 1000 + }) + } + }, + fail(err) { + wx.showToast({ + title: '删除失败!', + icon: 'none', + duration: 2000 + }) + } + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + }, + showLoading: function (message) { if (wx.showLoading) { // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 @@ -199,95 +252,105 @@ deviceloglist: [] }) }, + //查询列表数据 initPages: function () { var that = this + that.setData({ + show: false + }) var offsetValue = that.data.deviceloglist.length % 15 > 0 ? parseInt(that.data.deviceloglist.length / 15) + 2 : parseInt(that.data.deviceloglist.length / 15) + 1 - wx.cloud.callFunction({ - name: 'devicelog', + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/listPage", data: { devcode: that.data.params.devcode, devtype: that.data.params.devtype, installtimeFmt: that.data.params.installtimeFmt, project: that.data.params.project, installPerson: that.data.params.installPerson, - url: app.globalData.url + "appDeviceLog/listPage", limit: 15, offset: offsetValue }, - }).then(res => { - if (res.result.data.rows.length > 0) { - var resultJson = res.result - that.setData({ - deviceloglist: that.data.deviceloglist.concat(resultJson.data.rows) - }) - } else if (that.data.deviceloglist.length > 0) { - that.setData({ - show: true, - total: that.data.deviceloglist.length - }) - wx.showToast({ - title: '数据已全部加载完', - icon: 'none', - duration: 2000 - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.data.rows.length > 0) { + var resultJson = res.data + var listArr = resultJson.data.rows + listArr.forEach(function (v, i) { + listArr[i]['isTouchMove'] = false + }) + that.setData({ + deviceloglist: that.data.deviceloglist.concat(listArr) + }) + } else if (that.data.deviceloglist.length > 0) { + that.setData({ + show: true, + total: that.data.deviceloglist.length + }) + wx.showToast({ + title: '数据已全部加载完', + icon: 'none', + duration: 2000 + }) + } + if (offsetValue == 1 && res.data.data.rows.length < 15) { + that.setData({ + show: true, + total: that.data.deviceloglist.length + }) + } } - if(offsetValue==1&&res.result.data.rows.length<15){ - that.setData({ - show: true, - total: that.data.deviceloglist.length - }) - } - // console.log(res); - }).catch(err => { - console.error(err); }) + }, addDetail: function (event) { - this.showLoading("数据请求中..."); - wx.cloud.callFunction({ - name: 'deviceDetail', + var that = this + that.showLoading("数据请求中..."); + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deviceDetail", data: { devcode: event.target.dataset.devcode, - url: app.globalData.url + "appDeviceLog/deviceDetail", }, - }).then(res => { - this.hideLoading(); - var resultObject = JSON.parse(res.result); - var pageName = '../applog/applog' - if (resultObject.code == 200) { - wx.navigateTo({ - url: '../addDevicelog/addDeviceLog?detail=' + - JSON.stringify(resultObject.data) + "&pageName=" + pageName - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + that.hideLoading(); + // var resultObject = JSON.parse(res.data); + var resultObject = res.data; + var pageName = '../applog/applog' + if (resultObject.code == 200) { + wx.setStorageSync('resultObject', resultObject.data) + wx.navigateTo({ + url: '../addDevicelog/addDeviceLog?detail=' + "&pageName=" + pageName + }) + } + }, + fail(err) { + that.hideLoading(); } - }).catch(err => { - this.hideLoading() }) + }, add: function (event) { - wx.reLaunch({ - url: '../earth/earth?devcode=' + event.target.dataset.devcode - // url: '../earth/earth' + app.globalData.devcode = event.target.dataset.devcode; + wx.switchTab({ + url: '../earth/earth' }) + // wx.reLaunch({ + // url: '../earth/earth?devcode=' + event.target.dataset.devcode + // // url: '../earth/earth' + // }) }, onSearch: function () { + var _this = this wx.navigateTo({ - url: '../searchLog/searchLog' + url: '../searchLog/searchLog?params=' + JSON.stringify(_this.data.params) }) - }, - // initPages: function () { - // wx.cloud.callFunction({ - // name: 'devicelog' - // }).then(res => { - // var that = this; - // var jsonList = JSON.parse(res.result) - // that.setData({ - // deviceloglist: jsonList.data.rows - // }) - // console.log(res); - // }).catch(err => { - // console.error(err); - // }) - // } + } }) \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.wxml b/miniprogram/pages/applog/applog.wxml index e9a2352..2bfd041 100644 --- a/miniprogram/pages/applog/applog.wxml +++ b/miniprogram/pages/applog/applog.wxml @@ -1,54 +1,59 @@ - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {{item.devcode}} {{item.devicetype}} + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + {{item.devcode}} {{item.devicetype}} + + {{item.project}} {{item.installtime}}- {{item.installperson}} - - - - - + + + + + + 删除 - - - + + - 共计:{{total}}台 - + 共计:{{total}}台 + \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.wxss b/miniprogram/pages/applog/applog.wxss index 6d3428b..e6e8983 100644 --- a/miniprogram/pages/applog/applog.wxss +++ b/miniprogram/pages/applog/applog.wxss @@ -22,16 +22,18 @@ position: fixed; width: 100%; top: 0rpx; + z-index: 9999; /* margin-bottom: 100rpx; */ } .log-list { /* height: 100rpx; */ - /* display: flex; */ - + display: flex; + width: 100%; padding: 2px; margin-top: 2px; border-bottom: 1px solid #e5e5e5; + overflow: hidden } @@ -53,23 +55,29 @@ left: 35%; margin: 20rpx } - .del { - width: 90px; + /* display: flex; */ + width: 100rpx; display: flex; flex-direction: column; align-items: center; justify-content: center; - color: #fff; - -webkit-transform: translateX(90px); - transform: translateX(90px); - -webkit-transition: all 0.4s; + /* -webkit-transform: translateX(100rpx); */ + transform: translateX(100rpx); + /* -webkit-transition: all 0.4s; */ transition: all 0.4s; - font-size: 35rpx; + color: #fff; + background-color: #fe3e2f; +} +.logrow{ + width: 100%; + transform: translateX(100rpx); + /* -webkit-transform: translateX(100px); */ + margin-left: -100rpx; } -.touch-move-active .content, +.touch-move-active .logrow, .touch-move-active .del { - -webkit-transform: translateX(0); - transform: translateX(0); +/* -webkit-transform: translateX(0); */ +transform: translateX(0); } \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.js b/miniprogram/pages/deployFunctions/deployFunctions.js deleted file mode 100644 index a76b144..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.js +++ /dev/null @@ -1,66 +0,0 @@ -// pages/deployFunctions/deployFunctions.js -Page({ - - /** - * 页面的初始数据 - */ - data: { - - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - - }, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { - - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - - }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { - - }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { - - } -}) \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.json b/miniprogram/pages/deployFunctions/deployFunctions.json deleted file mode 100644 index 7fbedab..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "navigationBarTitleText": "部署云函数", - "usingComponents": {} -} \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.wxml b/miniprogram/pages/deployFunctions/deployFunctions.wxml deleted file mode 100644 index 462b6b6..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.wxml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - 调用失败 - - - 请检查 login 云函数是否已部署 - - - - - 部署 login 云函数 - 1. 确保已通过工具栏云开发入口开通云开发 - 2. 在 cloudfunctions/login 目录上右键上传并部署 - 3. 回到首页,重新点击获取 openid - - - - diff --git a/miniprogram/pages/deployFunctions/deployFunctions.wxss b/miniprogram/pages/deployFunctions/deployFunctions.wxss deleted file mode 100644 index c8803e6..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.wxss +++ /dev/null @@ -1,7 +0,0 @@ -/* pages/deployFunctions/deployFunctions.wxss */ - -@import "../../style/guide.wxss"; - -.black { - color: black; -} \ No newline at end of file diff --git a/miniprogram/pages/earth/earth.js b/miniprogram/pages/earth/earth.js index ae0d3f3..376a6e2 100644 --- a/miniprogram/pages/earth/earth.js +++ b/miniprogram/pages/earth/earth.js @@ -21,19 +21,12 @@ show: false, enableSsatellite: false, windowWidth: 0, - longitude: 113.324520, - latitude: 23.099994, - longitude84: 113.324520, - latitude84: 23.099994, - markers: [{ - id: 0, - iconPath: "../../images/locat.png", - latitude: 23.099994, - longitude: 113.324520, - width: 50, - height: 50 - }], - controls: [], + longitude: "116.627340", + latitude: "39.874390", + longitude84: "", + latitude84: "", + markers: [], + controls: [] }, /** @@ -41,39 +34,13 @@ */ onLoad: function (options) { var that = this; - //获取当前坐标(gcj02) - wx.getLocation({ - type: "gcj02", - altitude: true, - success: function (res) { - that.setData({ - latitude: parseFloat(res.latitude).toFixed(6), - longitude: parseFloat(res.longitude).toFixed(6), - // markers: [{ - // latitude: res.latitude, - // longitude: res.longitude, - // }] - }) - //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 - wx.getLocation({ - type: "wgs84", - altitude: true, - success: function (res) { - that.setData({ - latitude84: parseFloat(res.latitude).toFixed(6), - longitude84: parseFloat(res.longitude).toFixed(6) - }) - } - }) - } - }), - - //设置地图组件 - wx.getSystemInfo({ + //设置地图组件 + wx.getSystemInfo({ success(res) { var windowWidth = res.windowWidth var windowHeight = res.windowHeight var query = wx.createSelectorQuery() + var platform =res.platform query.select('#map').boundingClientRect() query.exec(function (res) { that.setData({ @@ -139,10 +106,20 @@ clickable: true }, { id: 7, - iconPath: '../../images/locat.png', + iconPath: '../../images/applocat.png', position: { - left: res[0].width/2, - top: res[0].height/2, + left: res[0].width / 2 - 20, + top: platform=="ios"?res[0].height / 2 - 80:res[0].height / 2 - 40, + width: 40, + height: 40 + }, + clickable: true + }, { + id: 8, + iconPath: '../../images/back.png', + position: { + left: windowWidth - 40, + top: windowHeight - 140, width: 30, height: 30 }, @@ -150,71 +127,15 @@ }] }) }) - + } - }), + }) + // 实例化API核心类 qqmapsdk = new QQMapWX({ key: 'BGPBZ-C5O3P-ROUDR-LWC4J-63EKH-V5FRX' }) - - if (options.devcode) { - var that = this - var devcode = options.devcode - wx.cloud.callFunction({ - name: 'findListByCodes', - data: { - devcodes: devcode, - url: app.globalData.url + "appDeviceAdd/findListByCodes" - }, - }).then(res => { - if (res.result.code == 200) { - var listResultData = res.result.data; - that.setData({ - listData: listResultData - }) - var markersArr = that.data.markers; - for (var i = 0; i < listResultData.length; i++) { - markersArr = markersArr.concat({ - iconPath: "../../images/locat.png", - id: listResultData[i].id, - callout: { - content: listResultData[i].devcode, - fontSize: '14', - // padding: true, - color: '#00000', - borderColor: '#F4EA2A', - bgColor: '#F4EA2A', - borderWidth: 5, - display: 'ALWAYS', - textAlign: 'center', - // borderRadius: 15 - }, - latitude: listResultData[i].latitude, - longitude: listResultData[i].longitude, - width: 40, - height: 40 - }); - } - this.setData({ - markers: markersArr, - latitude: listResultData[0].latitude, - longitude: listResultData[0].longitude, - marker_latitude: listResultData[0].latitude, - marker_longitude: listResultData[0].longitude, - title: listResultData[0].devcode - }) - } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "无法获取设备地理信息!", - icon: 'none', - duration: 2000 - }) - }) - } }, /** @@ -228,6 +149,97 @@ * 生命周期函数--监听页面显示 */ onShow: function () { + //输入设备编号获取marker位置信息 + var that = this; + if ( app.globalData.devcode!="") { + var devcode = app.globalData.devcode + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/findListByCodes", + data: { + devcodes: devcode, + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + app.globalData.devcode=""; + if (res.data.code == 200) { + var listResultData = res.data.data; + that.setData({ + listData: listResultData + }) + var markersArr = that.data.markers; + for (var i = 0; i < listResultData.length; i++) { + markersArr = markersArr.concat({ + iconPath: "../../images/locat.png", + id: Number(listResultData[i].id), + callout: { + content: "编号:"+listResultData[i].devcode+"\r\n位置:"+listResultData[i].position+"\r\n时间:"+listResultData[i].createtime, + fontSize: '14', + padding: true, + color: '#000000', + borderColor: '#F4EA2A', + bgColor: '#F4EA2A', + borderWidth: 5, + display: 'ALWAYS', + textAlign: 'left', + // borderRadius: 15 + }, + latitude: listResultData[i].latitude, + longitude: listResultData[i].longitude, + width: 40, + height: 40 + }); + } + that.setData({ + markers: markersArr, + latitude: listResultData[0].latitude, + longitude: listResultData[0].longitude, + marker_latitude: listResultData[0].latitude, + marker_longitude: listResultData[0].longitude, + title: listResultData[0].devcode + }) + } + }, + fail(err) { + app.globalData.devcode=""; + wx.showToast({ + title: "无法获取设备地理信息!", + icon: 'none', + duration: 2000 + }) + } + }) +} else { + //获取当前坐标(gcj02) + wx.getLocation({ + type: "gcj02", + altitude: true, + success: function (res) { + that.setData({ + latitude: parseFloat(res.latitude).toFixed(6), + longitude: parseFloat(res.longitude).toFixed(6), + // markers: [{ + // latitude: res.latitude, + // longitude: res.longitude, + // }] + }) + //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 + wx.getLocation({ + type: "wgs84", + altitude: true, + success: function (res) { + that.setData({ + latitude84: parseFloat(res.latitude).toFixed(6), + longitude84: parseFloat(res.longitude).toFixed(6) + }) + } + }) + } + }) +} + }, @@ -265,12 +277,46 @@ onShareAppMessage: function () { }, + + //定位出来 + + locationPosition: function () { + var that = this; + //获取当前坐标(gcj02) + wx.getLocation({ + type: "gcj02", + altitude: true, + success: function (res) { + that.setData({ + latitude: parseFloat(res.latitude).toFixed(6), + longitude: parseFloat(res.longitude).toFixed(6), + // markers: [{ + // latitude: res.latitude, + // longitude: res.longitude + // }] + }) + //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 + wx.getLocation({ + type: "wgs84", + altitude: true, + success: function (res) { + that.setData({ + latitude84: parseFloat(res.latitude).toFixed(6), + longitude84: parseFloat(res.longitude).toFixed(6) + }) + } + }) + } + }) + }, + + //加载地图组件 controltap: function (e) { // console.log(e.controlId); //进入添加设备页 if (1 == e.controlId) { wx.setClipboardData({ - data: this.data.latitude + "," + this.data.longitude+ "," + this.data.latitude84+ "," + this.data.longitude84, + data: this.data.latitude + "," + this.data.longitude + "," + this.data.latitude84 + "," + this.data.longitude84, success: function (res) { wx.getClipboardData({ success: function (res) { @@ -282,6 +328,17 @@ } }) } else if (3 == e.controlId) { + //先定位 + // this.locationPosition() + wx.setClipboardData({ + data: this.data.latitude + "," + this.data.longitude + "," + this.data.latitude84 + "," + this.data.longitude84, + success: function (res) { + wx.showToast({ + title: '坐标已获取', + duration: 1000 + }) + } + }) wx.navigateTo({ url: '../addDevice/addDevice' }) @@ -302,32 +359,15 @@ enableSsatellite: !flag }); } else if (6 == e.controlId) { - var that = this; - //获取当前坐标(gcj02) - wx.getLocation({ - type: "gcj02", - altitude: true, - success: function (res) { - that.setData({ - latitude: parseFloat(res.latitude).toFixed(6), - longitude:parseFloat(res.longitude).toFixed(6), - // markers: [{ - // latitude: res.latitude, - // longitude: res.longitude - // }] - }) - //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 - wx.getLocation({ - type: "wgs84", - altitude: true, - success: function (res) { - that.setData({ - latitude84: parseFloat(res.latitude).toFixed(6), - longitude84: parseFloat(res.longitude).toFixed(6) - }) - } - }) - } + //先清marker + this.setData({ + markers: [] + }) + this.locationPosition() + }else if (8 == e.controlId) { + //跳转日志缓存页 + wx.switchTab({ + url: '../applog/applog', }) } }, @@ -343,63 +383,68 @@ }); }, + //获取设备maker leave() { var that = this; if (that.data.devcodes == "") { return false; } - wx.cloud.callFunction({ - name: 'findListByCodes', + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/findListByCodes", data: { - devcodes: that.data.devcodes, - url: app.globalData.url + "appDeviceAdd/findListByCodes" + devcodes: that.data.devcodes }, - }).then(res => { - if (res.result.code == 200) { - var listResultData = res.result.data; - that.setData({ - listData: listResultData - }) - var markersArr = that.data.markers; - for (var i = 0; i < listResultData.length; i++) { - markersArr = markersArr.concat({ - iconPath: "../../images/locat.png", - id: listResultData[i].id, - callout: { - content: listResultData[i].devcode, - fontSize: '14', - // padding: true, - color: '', - borderColor: '#F4EA2A', - bgColor: '#F4EA2A', - borderWidth: 5, - display: 'ALWAYS', - textAlign: 'center', - // borderRadius: 15 - }, - latitude: listResultData[i].latitude, - longitude: listResultData[i].longitude, - width: 40, - height: 40 - }); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var listResultData = res.data.data; + that.setData({ + listData: listResultData + }) + var markersArr = that.data.markers; + for (var i = 0; i < listResultData.length; i++) { + markersArr = markersArr.concat({ + iconPath: "../../images/locat.png", + id: listResultData[i].id, + callout: { + content: "编号:"+listResultData[i].devcode+"\r\n位置:"+listResultData[i].position+"\r\n时间:"+listResultData[i].createtime, + fontSize: '14', + // padding: true, + color: '#212121', + borderColor: '#F4EA2A', + bgColor: '#F4EA2A', + borderWidth: 5, + display: 'ALWAYS', + textAlign: 'left', + // borderRadius: 15 + }, + latitude: listResultData[i].latitude, + longitude: listResultData[i].longitude, + width: 40, + height: 40 + }); + } + that.setData({ + markers: markersArr, + latitude: listResultData[0].latitude, + longitude: listResultData[0].longitude, + marker_latitude: listResultData[0].latitude, + marker_longitude: listResultData[0].longitude, + title: listResultData[0].devcode + }) } - this.setData({ - markers: markersArr, - latitude: listResultData[0].latitude, - longitude: listResultData[0].longitude, - marker_latitude: listResultData[0].latitude, - marker_longitude: listResultData[0].longitude, - title: listResultData[0].devcode + }, + fail(err) { + wx.showToast({ + title: "无法获取设备地理信息!", + icon: 'none', + duration: 2000 }) } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "无法获取设备地理信息!", - icon: 'none', - duration: 2000 - }) }) }, @@ -422,6 +467,8 @@ } }, + + bindregionchange: function (e) { var that = this if (e.causedBy == "drag") { @@ -445,8 +492,8 @@ that.setData({ latitude: parseFloat(latitude).toFixed(6), longitude: parseFloat(longitude).toFixed(6), - latitude84:"", - longitude84:"", + latitude84: "", + longitude84: "", // markers: markersArr }) // mapCtx.moveToLocation(); @@ -465,16 +512,19 @@ qqmapsdk.search({ keyword: this.data.value, success: function (res) { + console.log(res) if (res && res.data) { _this.setData({ isShow: true, tips: res.data }); } + }, + complete: function (res){ + console.log(res); } }) }, - bindSearch: function (e) { var location = e.target.dataset.location; this.setData({ diff --git a/miniprogram/pages/earth/earth.wxml b/miniprogram/pages/earth/earth.wxml index a0db6ef..87474f8 100644 --- a/miniprogram/pages/earth/earth.wxml +++ b/miniprogram/pages/earth/earth.wxml @@ -1,9 +1,10 @@ + - + {{item.title}} {{item.address}} @@ -17,6 +18,6 @@ + placeholder="请输入定位设备编号用换行隔开" autosize border="{{ false }}" /> \ No newline at end of file diff --git a/miniprogram/pages/indexapp/indexapp.js b/miniprogram/pages/indexapp/indexapp.js index 5063372..849dbdb 100644 --- a/miniprogram/pages/indexapp/indexapp.js +++ b/miniprogram/pages/indexapp/indexapp.js @@ -7,9 +7,8 @@ */ data: { - count:1, - show: false, - onshow:true, + count: 1, + onshow: true, value: "", deviceloglist: [], devcode: "", @@ -21,6 +20,7 @@ // iconPath: "../../images/point.png", latitude: 23.099994, longitude: 113.324520, + label:'1', width: 50, height: 50 }], @@ -31,62 +31,26 @@ * 生命周期函数--监听页面加载 */ onLoad: function (options) { - + }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { - + }, /** * 生命周期函数--监听页面显示 */ onShow: function () { - // if( app.globalData.indexCount>1){ - // this.setData({ - // show:false - // }) - // }else{ - // this.showNotice() - // } - if(app.globalData.indexCount==1){ - this.setData({ - show:true - }) - this.showNotice() - } - app.globalData.indexCount+=1 - if(this.data.onshow){ + if (this.data.onshow) { this.initPages(); } }, - - showNotice: function() { - var that = this - var times = 0 - var i = setInterval(function() { - times++ - if (times >= 15) { - that.setData({ - show:false - }) - wx.showTabBar({ - animation: false, - }) - clearInterval(i) - } else { - wx.hideTabBar({ - animation: false, - }) - } - }, 1000) -}, - /** * 生命周期函数--监听页面隐藏 */ @@ -122,16 +86,27 @@ }, jump: function (event) { - var that = this; var latitude = event.target.dataset.pointLat; var longitude = event.target.dataset.pointLon; + let devcode = event.target.dataset.pointCode; that.setData({ latitude: latitude, longitude: longitude, markers: [{ latitude: latitude, - longitude: longitude + longitude: longitude, + callout: { + display:'ALWAYS',// 常显气泡 + content: devcode, //名称文本 + color: '#fff', //文本颜色 + borderRadius: 5, //边框圆角 + borderWidth: 1, //边框宽度 + borderColor: '#0060ff', //边框颜色 + bgColor: '#0060ff', //背景色 + padding: 5, //文本边缘留白 + textAlign: 'center' //文本对齐方式。有效值: left, right, center + } }] }) }, @@ -142,7 +117,7 @@ var devcode = res.result _this.setData({ devcode: devcode, - onshow:false + onshow: false }); _this.searchlogs(devcode) } @@ -151,40 +126,11 @@ onSearch: function (event) { this.setData({ - devcode:event.detail + devcode: event.detail }) this.searchlogs(event.detail) }, - - // bindregionchange: function (e) { - // var that = this - // if (e.causedBy == "drag") { - // var mapCtx = wx.createMapContext("map") - // mapCtx.getCenterLocation({ - // success: function (res) { - // var markersArr = that.data.markers - // for (var i = 0; i < markersArr.length; i++) { - // if (markersArr[i].iconPath == undefined) { - // markersArr.splice(i, 1) - // } - // } - // var latitude = res.latitude - // var longitude = res.longitude - // markersArr = markersArr.concat({ - // latitude: latitude, - // longitude: longitude - // }) - // that.setData({ - // latitude: latitude, - // longitude: longitude, - // markers: markersArr - // }) - // } - // }) - // } - // }, - showLoading: function (message) { if (wx.showLoading) { // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 @@ -211,81 +157,89 @@ } }, + //加载设备运维详细信息 toDetail: function (event) { - this.showLoading("数据加载中...") - wx.cloud.callFunction({ - name: 'deviceDetail', + var that = this + that.showLoading("数据加载中...") + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deviceDetail", data: { devcode: event.target.dataset.devcode, - url: app.globalData.url + "appDeviceLog/deviceDetail", }, - }).then(res => { - this.hideLoading(); - var resultObject = JSON.parse(res.result); - var pageName='../indexapp/indexapp' - if (resultObject.code == 200) { - wx.navigateTo({ - url: '../addDevicelog/addDeviceLog?detail=' + - JSON.stringify(resultObject.data)+'&pageName='+pageName - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + that.hideLoading(); + var resultObject = res.data; + var pageName = '../indexapp/indexapp' + if (resultObject.code == 200) { + wx.setStorageSync('resultObject', resultObject.data) + wx.navigateTo({ + url: '../addDevicelog/addDeviceLog?detail=' +'&pageName=' + pageName + }) + } + }, + fail(err){ + that.hideLoading(); } - }).catch(err => { - this.hideLoading(); }) }, + //加载列表 getlogs: function (devcode) { var that = this - wx.cloud.callFunction({ - name: 'devicelog', + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/listPage", data: { devcode: devcode, - url: app.globalData.url + "appDeviceLog/listPage", limit: 100, offset: that.data.deviceloglist.length % 100 > 0 ? parseInt(that.data.deviceloglist.length / 100) + 2 : parseInt(that.data.deviceloglist.length / 100) + 1 }, - }).then(res => { - if (res.result) { - // var resultJson = JSON.parse(res.result) - var resultJson = res.result - that.setData({ - deviceloglist: that.data.deviceloglist.concat(resultJson.data.rows) - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + // var resultJson = JSON.parse(res.result) + var resultJson = res.data + that.setData({ + deviceloglist: that.data.deviceloglist.concat(resultJson.data.rows) + }) + } } - console.log(res); - }).catch(err => { - console.error(err); }) }, + //查询列表 searchlogs: function (devcode) { var that = this - wx.cloud.callFunction({ - name: 'devicelog', + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/listPage", data: { devcode: devcode, - url: app.globalData.url + "appDeviceLog/listPage", limit: 100, offset: 1 }, - }).then(res => { - if (res.result) { - var resultJson = res.result - that.setData({ - deviceloglist: resultJson.data.rows, - onshow:true - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var resultJson = res.data + that.setData({ + deviceloglist: resultJson.data.rows, + onshow: true + }) + } } - console.log(res); - }).catch(err => { - console.error(err); }) }, initPages: function () { var that = this; - that.setData({ - devcode: "" - }); wx.getLocation({ type: "gcj02", success: function (res) { @@ -302,6 +256,6 @@ }) } }) - this.searchlogs() + this.data.devcode !== '' ? this.searchlogs(this.data.devcode) : this.searchlogs() }, }) \ No newline at end of file diff --git a/cloudfunctions/project.config.json b/cloudfunctions/project.config.json new file mode 100644 index 0000000..2b3119a --- /dev/null +++ b/cloudfunctions/project.config.json @@ -0,0 +1,28 @@ +{ + "appid": "wx2cef527a000f87c9", + "compileType": "miniprogram", + "libVersion": "2.27.3", + "packOptions": { + "ignore": [], + "include": [] + }, + "setting": { + "coverView": true, + "es6": true, + "postcss": true, + "minified": true, + "enhance": true, + "showShadowRootInWxmlPanel": true, + "packNpmRelationList": [], + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + } + }, + "condition": {}, + "editorSetting": { + "tabIndent": "insertSpaces", + "tabSize": 4 + } +} \ No newline at end of file diff --git a/cloudfunctions/project.private.config.json b/cloudfunctions/project.private.config.json new file mode 100644 index 0000000..42ff49d --- /dev/null +++ b/cloudfunctions/project.private.config.json @@ -0,0 +1,7 @@ +{ + "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", + "projectname": "cloudfunctions", + "setting": { + "compileHotReLoad": true + } +} \ No newline at end of file diff --git a/miniprogram/app.js b/miniprogram/app.js index 51d56f3..50a8a54 100644 --- a/miniprogram/app.js +++ b/miniprogram/app.js @@ -18,13 +18,15 @@ // this.globalData = {} }, globalData: { - // url: "http://111.198.10.15:11604/", - httpsUrl: "https://logapi.smartlog.work/", - httpsTestUrl: "https://smartlog.work/prodapi4test/", - url: "http://139.198.18.188:8083/", + httpsUrl: "https://logapi.smartlog.work/", + // httpsUrl: "http://139.198.18.188:8083/", // url: "http://127.0.0.1:8083/", - // httpsUrl: "http://127.0.0.1:8083/", + //httpsUrl: "http://127.0.0.1:8083/", openid: null, - indexCount:1 - }, + indexCount:1, + nickName:"", + userName:"", + role:"", + devcode:"" + } }) diff --git a/miniprogram/app.json b/miniprogram/app.json index d23f798..2b6db76 100644 --- a/miniprogram/app.json +++ b/miniprogram/app.json @@ -1,15 +1,17 @@ { "cloud": true, "pages": [ + "pages/login/login", "pages/indexapp/indexapp", "pages/earth/earth", "pages/applog/applog", "pages/addDevice/addDevice", "pages/addDevicelog/addDeviceLog", - "pages/searchLog/searchLog" + "pages/searchLog/searchLog", + "pages/notice/notice" ], "window": { - "backgroundColor": "#F6F6F6", + "backgroundColor": "#E6D480", "backgroundTextStyle": "light", "navigationBarBackgroundColor": "#FFCF00", "navigationBarTitleText": "智慧施工", @@ -46,11 +48,11 @@ "desc": "你的位置信息将用于小程序位置接口的效果展示" } }, + "requiredPrivateInfos": ["getLocation", "chooseLocation"], "networkTimeout": { "request": 30000, "connectSocket": 30000, "uploadFile": 30000, "downloadFile": 30000 - }, - "style": "v2" + } } \ No newline at end of file diff --git a/miniprogram/images/applocat.png b/miniprogram/images/applocat.png new file mode 100644 index 0000000..fe49f54 --- /dev/null +++ b/miniprogram/images/applocat.png Binary files differ diff --git a/miniprogram/images/back.png b/miniprogram/images/back.png new file mode 100644 index 0000000..32ac82d --- /dev/null +++ b/miniprogram/images/back.png Binary files differ diff --git a/miniprogram/images/bottom.png b/miniprogram/images/bottom.png new file mode 100644 index 0000000..d910e98 --- /dev/null +++ b/miniprogram/images/bottom.png Binary files differ diff --git a/miniprogram/images/header.png b/miniprogram/images/header.png new file mode 100644 index 0000000..6ea222e --- /dev/null +++ b/miniprogram/images/header.png Binary files differ diff --git a/miniprogram/images/login.png b/miniprogram/images/login.png index 8b73cc0..6471c46 100644 --- a/miniprogram/images/login.png +++ b/miniprogram/images/login.png Binary files differ diff --git a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss index 5a591fb..c9c35b5 100644 --- a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss +++ b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:100%;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:100%}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file +@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:650rpx;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:600rpx}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file diff --git a/miniprogram/pages/addDevice/addDevice.js b/miniprogram/pages/addDevice/addDevice.js index 2783674..78f00b7 100644 --- a/miniprogram/pages/addDevice/addDevice.js +++ b/miniprogram/pages/addDevice/addDevice.js @@ -1,5 +1,7 @@ // miniprogram/pages/addDevice/addDevice.js // import WxValidate from '../../utils/WxValidate.js' +var QQMapWX = require('../../libs/qqmap-wx-jssdk.js'); +var qqmapsdk; var app = getApp() Page({ @@ -11,32 +13,10 @@ canvasWidth: '', longitude: '', latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], + option1: [], personoption1: [], projectoption: [], + devtypeList:[], show: false, form: { devcode: "", @@ -59,7 +39,10 @@ project: "", area: "", street: "", - wellname: "" + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '', }, fileList: [] }, @@ -117,12 +100,14 @@ var that = this; //初始化表单内容为上次填写值 var cacheForms = wx.getStorageSync('cacheList') - if (cacheForms) { + cacheForms.photopath1='' + cacheForms.photopath2='' + cacheForms.photopath3='' + that.data.fileList=[] that.setData({ form: cacheForms, devcode: cacheForms.devcode, - }) } var form = that.data.form @@ -155,55 +140,89 @@ } }) + +//获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + that.setData({ + option1: welltypeArr + }) + } + } +}) + + //获取人员下拉列表 - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/getUser", + data:{ + tips:'repair' }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data.code == 200) { + var users = res.data.data + var personArr = []; + for (var i = 0; i < users.length; i++) { + var person = { + text: users[i].name, + value: users[i].name + }; + personArr.push(person); + } + that.setData({ + personoption1: personArr + }) } - that.setData({ - personoption1: personArr - }) } - }).catch(err => { - console.error(err); - }) + }) + - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - that.setData({ - projectoption: projectArr - }) + success(res){ + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); + } + that.setData({ + projectoption: projectArr + }) + } } - }).catch(err => { - console.error(err); - }) + }) + var installtime = 'form.installtimeFmt'; var dateNow = this.formatDate(); this.setData({ @@ -211,8 +230,40 @@ installtimeFmt: dateNow, [installtime]: dateNow, }); + + + + /** + * 获取设备类型下拉列表 + */ + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/deviceType", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var TypeList = res.data.data + var typeArr = []; + for (var i = 0; i < TypeList.length; i++) { + var type = { + text: TypeList[i].productName, + value: TypeList[i].productName + }; + typeArr.push(type); + } + that.setData({ + devtypeList: typeArr + }) + } + } + }) }, + + + /** * 生命周期函数--监听页面初次渲染完成 */ @@ -280,29 +331,7 @@ }, - - //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 - drawText: function (ctx, str, leftWidth, initHeight, titleHeight, canvasWidth) { - var lineWidth = 0; - var lastSubStrIndex = 0; //每次开始截取的字符串的索引 - for (let i = 0; i < str.length; i++) { - lineWidth += ctx.measureText(str[i]).width; - if (lineWidth > canvasWidth) { - ctx.fillText(str.substring(lastSubStrIndex, i), leftWidth, initHeight); //绘制截取部分 - initHeight = initHeight + leftWidth * 2; //22为字体的高度 - lineWidth = 0; - lastSubStrIndex = i; - // titleHeight += 40; - } - if (i == str.length - 1) { //绘制剩余部分 - ctx.fillText(str.substring(lastSubStrIndex, i + 1), leftWidth, initHeight); - } - } - // // 标题border-bottom 线距顶部距离 - // titleHeight = titleHeight + 10; - // return titleHeight - }, - + //验证表单 formValidate() { if (this.data.form.devcode == "") { @@ -312,27 +341,20 @@ }) return false } - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } if (this.data.form.wellcode == "") { wx.showToast({ icon: 'none', @@ -348,22 +370,10 @@ }) return false } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null) { + + if (this.data.form.installperson == "") { wx.showToast({ icon: 'none', title: '安装人员不能为空!', @@ -408,56 +418,90 @@ } return true; }, + //提交表单 formSubmit: function (event) { + console.log(this.data.form) + //表单参数验证 if (!this.formValidate()) { return false; } var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDevice', + //验证设备编号长度 + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/getDevTypeLength", data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceAdd/add" + code: encodeURI(this.data.form.devicetype) }, - }).then(res => { - if (res.result.code == 500) { - wx.showToast({ - title: '设备编号已安装!', - }) - } else if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - //用于回显 - wx.setStorageSync('cacheList', that.data.form) - //提交成功后提示用户操作 - if (res.confirm) { - wx.switchTab({ - url: '../earth/earth' - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (""==res.data.data ||res.data.data == that.data.form.devcode.length) { + that.saveDevice() + } else { //编号位数不对提示 + wx.showToast({ + icon: 'none', + title: '设备编号位数不对!', + duration: 1000 + }) + return false + } } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "提交失败", - }) }) }, + + //保存设备基本信息 + saveDevice() { + var that = this; + //设置照片路径 + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopathForm = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopathForm]: fileList[i].url.split("static/")[1] + }) + } + //表单提交 + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 500) { + wx.showToast({ + title: '设备编号已安装!', + }) + } else if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + //用于回显 + wx.setStorageSync('cacheList', that.data.form) + //提交成功后提示用户操作 + if (res.confirm) { + wx.switchTab({ + url: '../earth/earth' + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } + }, + fail(err) { + wx.showToast({ + title: '提交失败!', + }) + } + }) + }, + + //input 输入框设置值 confirm(event) { var that = this; var formValue = event.detail.value; @@ -466,8 +510,30 @@ that.setData({ [fromN]: formValue }) + //若输入是设备编号,自动获取设备类型 + if('devcode'==formName){ + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", + data: { + devcode: formValue, + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + that.setData({ + [formDevicetype]: res.data + }); + } + } + }) + } }, + //扫描设备获取编号和设备类型 scan() { var _this = this; wx.scanCode({ @@ -477,23 +543,28 @@ _this.setData({ [formdevcode]: devcode }); - wx.cloud.callFunction({ - name: 'findModeCode', + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", data: { devcode: devcode, - url: app.globalData.url + "appDeviceAdd/findModeCodeByCode" }, - }).then(res => { - if (res.result) { - var formDevicetype = 'form.devicetype' - _this.setData({ - [formDevicetype]: res.result - }); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + _this.setData({ + [formDevicetype]: res.data + }); + } } }) } }) }, + //粘贴经纬度 paste() { var _this = this; wx.getClipboardData({ @@ -510,9 +581,11 @@ longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), }); + _this.showAddress(_this.data.form.longitude,_this.data.form.latitude,_this) } }) }, + //设置经类型 selectValue(value) { var that = this; @@ -521,6 +594,16 @@ [wellType]: value.detail }) }, + + //设置设备类型 + selectDevType(event) { + var that = this; + var devtype = 'form.devicetype'; + that.setData({ + [devtype]: event.detail + }) + }, + //设置运维人员 selectpersonValue(event) { var that = this; var installPerson = 'form.installperson'; @@ -528,6 +611,7 @@ [installPerson]: event.detail }) }, + //设置项目 selectprojectValue(event) { var that = this; var project = 'form.project'; @@ -535,8 +619,41 @@ [project]: event.detail }) }, + showAddress :function(longitude, latitude, self) { + // 实例化腾讯地图API核心类 + qqmapsdk = new QQMapWX({ + key: 'BGPBZ-C5O3P-ROUDR-LWC4J-63EKH-V5FRX'//此处使用你自己申请的key + }) + // 腾讯地图调用接口 + qqmapsdk.reverseGeocoder({ + location: { + latitude: latitude, + longitude: longitude + }, + success: function (res) { + self.setData({ + 'form.area':res.result.address.slice(0,res.result.address.indexOf('区')+1), + 'form.street':res.result.address.slice(res.result.address.indexOf('区')+1) + }) + }, + fail: function (res) { + console.log(res); + }, + complete: function (res) { + } + }); + }, + //上传照片 afterRead(event) { var _this = this; + if (_this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '请先填写设备编号!\r\n否则水印中无编号', + duration: 2000 + }) + return false + } const { file } = event.detail; @@ -576,78 +693,8 @@ }) } }) - // 压缩图片 - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // //获取图片尺寸 - // wx.getImageInfo({ - // src: convertpath, - // success(res) { - // _this.setData({ - // canvasHeight: res.height, - // canvasWidth: res.width - // }) - // var ctx = wx.createCanvasContext('firstCanvas') - - // //将图片src放到cancas内,宽高为图片大小 - // ctx.drawImage(convertpath, 0, 0, res.width, res.height) - // //将声明的时间放入canvas - // ctx.setFontSize(30 * (res.width / 750)) //注意:设置文字大小必须放在填充文字之前,否则不生效 - // ctx.setFillStyle('blue') - // var text = "编号:" + _this.data.form.devcode + "\n经度:" + _this.data.form.longitude + "\n纬度:" + _this.data.form.latitude - // // _this.drawText(ctx,text,20, 70, 5, res.width) - // _this.drawText(ctx, text, 15 * (res.width / 750), 70 * (res.width / 750), 5, res.width) - - // // ctx.fillText(text, 0, 40) - // // ctx.strokeText(_this.data.form.devcode, 0, 30) - // //生成水印图 - // ctx.draw(false, function () { - // wx.canvasToTempFilePath({ - // canvasId: 'firstCanvas', - // success: (res) => { - // wx.compressImage({ - // src: res.tempFilePath, - // quality: 25, - // success: function (res) { - // //上传照片至服务器 - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: res.tempFilePath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // } - // }) - // //// - // } - // }) - // }) - // } - // }) - // } - // }); }, + //删除照片 deletePhoto(event) { var image_index = event.detail.index var fileList_new = this.data.fileList; diff --git a/miniprogram/pages/addDevice/addDevice.wxml b/miniprogram/pages/addDevice/addDevice.wxml index b0977e2..f12c254 100644 --- a/miniprogram/pages/addDevice/addDevice.wxml +++ b/miniprogram/pages/addDevice/addDevice.wxml @@ -5,18 +5,30 @@ - + + + + + + + + + + + + + - - + + - - - + + + @@ -29,13 +41,13 @@ - + - + - + - + @@ -54,8 +66,7 @@ - - + @@ -68,8 +79,8 @@ - - + + - 保存 + 保存 \ No newline at end of file diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.js b/miniprogram/pages/addDevicelog/addDeviceLog.js index cdec71b..a0dc6da 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.js +++ b/miniprogram/pages/addDevicelog/addDeviceLog.js @@ -3,681 +3,665 @@ var app = getApp(); Page({ - /** - * 页面的初始数据 - */ - data: { - pageName: '', - showMask: false, - today: new Date().getTime(), - longitude: '', - latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], - personoption1: [], - projectoption: [], - devcode: "", - deviceMode: "", - installtimeFmt: '', - show: false, - form: { - devcode: "", - wellcode: "", - welltype: "", - welldepth: "", - installheigt: "", - installperson: "", - installtimeFmt: "", - photopath: "", - factory: "", - workmsg: "", - position: "", - description: "", - longitude: "", - latitude: "", - longitude84: "", - latitude84: "", - devicetype: "", - project: "", - area: "", - street: "", - wellname: "" - }, - fileList: [], - detail: "" - }, + /** + * 页面的初始数据 + */ + data: { + pageName: '', + showMask: false, + today: new Date().getTime(), + longitude: '', + latitude: '', + option1: [], + personoption1: [], + projectoption: [], + devcode: "", + deviceMode: "", + installtimeFmt: '', + show: false, + form: { + devcode: "", + wellcode: "", + welltype: "", + welldepth: "", + installheigt: "", + installperson: "", + installtimeFmt: "", + photopath: "", + factory: "", + workmsg: "", + position: "", + description: "", + longitude: "", + latitude: "", + longitude84: "", + latitude84: "", + devicetype: "", + project: "", + area: "", + street: "", + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '' + }, + fileList: [], + detail: "", + markers: [{ + id: 100, + // iconPath: "../../images/point.png", + latitude: '', + longitude: '', + // label:'1', + width: 25, + height: 35 + }], + }, - onDisplay() { - this.setData({ - show: true - }); - }, - onClose() { - this.setData({ - show: false - }); - }, - formatDate() { - var date = new Date(); - // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; - var seperator1 = "-"; - var month = date.getMonth() + 1; - var strDate = date.getDate(); - var hour = date.getHours() - var minute = date.getMinutes() - var second = date.getSeconds() - month = month > 9 ? month : "0" + month; - strDate = strDate > 9 ? strDate : "0" + strDate; - hour = hour > 9 ? hour : "0" + hour; - minute = minute > 9 ? minute : "0" + minute; - second = second > 9 ? second : "0" + second; - var currentdate = - date.getFullYear() + - seperator1 + - month + - seperator1 + - strDate + - " " + - hour + ":" + - minute + ":" + - second; - return currentdate; + onDisplay() { + this.setData({ + show: true + }); + }, + onClose() { + this.setData({ + show: false + }); + }, + formatDate() { + var date = new Date(); + // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; + var seperator1 = "-"; + var month = date.getMonth() + 1; + var strDate = date.getDate(); + var hour = date.getHours() + var minute = date.getMinutes() + var second = date.getSeconds() + month = month > 9 ? month : "0" + month; + strDate = strDate > 9 ? strDate : "0" + strDate; + hour = hour > 9 ? hour : "0" + hour; + minute = minute > 9 ? minute : "0" + minute; + second = second > 9 ? second : "0" + second; + var currentdate = + date.getFullYear() + + seperator1 + + month + + seperator1 + + strDate + + " " + + hour + ":" + + minute + ":" + + second; + return currentdate; - }, - onConfirm(event) { - var installtime = 'form.installtimeFmt'; - this.setData({ - show: false, - installtimeFmt: this.formatDate(event.detail), - [installtime]: this.formatDate(event.detail), - }); - }, + }, + onConfirm(event) { + var installtime = 'form.installtimeFmt'; + this.setData({ + show: false, + installtimeFmt: this.formatDate(event.detail), + [installtime]: this.formatDate(event.detail), + }); + }, - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - var _this = this; - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" - }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); - } - _this.setData({ - personoption1: personArr - }) + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + var _this = this; + _this.setData({ + 'markers[0].latitude': Number(wx.getStorageSync('resultObject').latitude) , + 'markers[0].longitude': Number(wx.getStorageSync('resultObject').longitude), + // 'markers[0].label':'10', + 'markers[0].width': 18, + 'markers[0].id':1, + 'markers[0].height': 30, + latitude:Number(wx.getStorageSync('resultObject').latitude), + longitude:Number(wx.getStorageSync('resultObject').longitude) + }) + //获取人员下拉列表 + // wx.request({ + // method: "POST", + // url: app.globalData.httpsUrl + "deviceType/getUser", + // data:{ + // tips:'repair' + // }, + // header: { + // 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + // }, + // success(res) { + // if (res.data.code == 200) { + // var users = res.data.data + // var personArr = []; + // for (var i = 0; i < users.length; i++) { + // var person = { + // text: users[i].name, + // value: users[i].name + // }; + // personArr.push(person); + // } + // _this.setData({ + // personoption1: personArr + // }) + // } + // } + // }) + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); } - }).catch(err => { - console.error(err); - }) - - - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" - }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - _this.setData({ - projectoption: projectArr - }) - } - }).catch(err => { - console.error(err); - }) - - if (options.pageName) { - this.setData({ - pageName: options.pageName - }) - } - - if (options.detail) { - - var formObject = JSON.parse(options.detail); _this.setData({ - form: formObject, - detail: options.detail + projectoption: projectArr }) - - _this.setData({ - ['form.installperson']: "", - ['form.installtimeFmt']: "", - ['form.workmsg']: "", - ['form.description']: "" - }) - - const { - fileList = [] - } = _this.data; - if (formObject.photopath1 != "") { - var file1 = { - url: app.globalData.url + "static/" + formObject.photopath1 - } - fileList.push(file1) - } - if (formObject.photopath2 != "") { - var file2 = { - url: app.globalData.url + "static/" + formObject.photopath2 - } - fileList.push(file2) - } - if (formObject.photopath3 != "") { - var file3 = { - url: app.globalData.url + "static/" + formObject.photopath3 - } - fileList.push(file3) - } - - _this.setData({ - fileList - }); } - var installtime = 'form.installtimeFmt'; - var dateNow = this.formatDate(); - this.setData({ - installtimeFmt: dateNow, - [installtime]: dateNow, - }); - }, + } + }) - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { + //获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + _this.setData({ + option1: welltypeArr + }) + } + } +}) - }, + //跳转时带入参数返回哪页 + if (options.pageName) { + this.setData({ + pageName: options.pageName + }) + } + //跳转时带入参数设备的安装信息 + if (wx.getStorageSync('resultObject')) { + var formObject = wx.getStorageSync('resultObject') + _this.setData({ + form: formObject, + detail: formObject + }) - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { + _this.setData({ + ['form.installperson']: app.globalData.userName, + ['form.installtimeFmt']: "", + ['form.workmsg']: "", + ['form.description']: "" + }) - }, + const { + fileList = [] + } = _this.data; + if (formObject.photopath1 != "") { + var file1 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath1 + } + fileList.push(file1) + } + if (formObject.photopath2 != "") { + var file2 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath2 + } + fileList.push(file2) + } + if (formObject.photopath3 != "") { + var file3 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath3 + } + fileList.push(file3) + } + _this.setData({ + fileList + }); + } + var installtime = 'form.installtimeFmt'; + var dateNow = this.formatDate(); + this.setData({ + installtimeFmt: dateNow, + [installtime]: dateNow, + }); + }, - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, - }, + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + wx.removeStorageSync('resultObject') + }, - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, - }, + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { + }, - }, + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { + }, - }, + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { + }, - }, + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + }, - /** - * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true - **/ + /** + * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true + **/ - isNumber: function (val) { + isNumber: function (val) { - var regPos = /^[0-9]*$/; //非负浮点数 - var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数 - if (regPos.test(val) || regNeg.test(val)) { - return false; - } else { - return true; - } + var regPos = /^[0-9]*$/; //非负浮点数 + var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数 + if (regPos.test(val) || regNeg.test(val)) { + return false; + } else { + return true; + } - }, + }, - formValidate() { + formValidate() { - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } - if (this.data.form.wellcode == "") { - wx.showToast({ - icon: 'none', - title: '井编号不能为空!', - }) - return false - } - if (this.data.form.devicetype == "") { - wx.showToast({ - icon: 'none', - title: '设备类型不能为空!', - }) - return false - } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + if (this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '设备编号不能为空!', + }) + return false + } + if (this.data.form.wellcode == "") { + wx.showToast({ + icon: 'none', + title: '井编号不能为空!', + }) + return false + } + if (this.data.form.devicetype == "") { + wx.showToast({ + icon: 'none', + title: '设备类型不能为空!', + }) + return false + } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null || - this.data.form.installperson == '') { - wx.showToast({ - icon: 'none', - title: '运维人员不能为空!', - }) - return false - } - if (this.data.form.project == "") { - wx.showToast({ - icon: 'none', - title: '所属项目不能为空!', - }) - return false - } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } + if (this.data.form.installperson == null || + this.data.form.installperson == '') { + wx.showToast({ + icon: 'none', + title: '运维人员不能为空!', + }) + return false + } + if (this.data.form.project == "") { + wx.showToast({ + icon: 'none', + title: '所属项目不能为空!', + }) + return false + } - if (this.data.form.welldepth != null) { - if (this.isNumber(this.data.form.welldepth)) { - wx.showToast({ - icon: 'none', - title: '井深必须为数值!', - }) - return false - } - } - if (this.data.form.installheigt != null) { - if (this.isNumber(this.data.form.installheigt)) { - wx.showToast({ - icon: 'none', - title: '到井口距离必须为数值!', - }) - return false - } - } - - return true; - }, - - changeMsg: function () { - var formNew = this.data.form; - var formOld = JSON.parse(this.data.detail); - var descpNew = ""; - if (formNew.devcode != formOld.devcode) { - descpNew += "修改设备编号,原编号:" + formOld.devcode + ",新编号:" + formNew.devcode + ";" - } - if (formNew.devicetype != formOld.devicetype) { - descpNew += "修改设备类型,原设备类型:" + formOld.devicetype + ",新设备类型:" + formNew.devicetype + ";" - } - if (formNew.area != formOld.area) { - descpNew += "修改区,原区:" + formOld.area + ",新区:" + formNew.area + ";" - } - if (formNew.street != formOld.street) { - descpNew += "修改街道,原街道:" + formOld.street + ",新街道:" + formNew.street + ";" - } - if (formNew.wellname != formOld.wellname) { - descpNew += "修改井名称,原井名称:" + formOld.wellname + ",新井名称:" + formNew.wellname + ";" - } - if (formNew.factory != formOld.factory) { - descpNew += "修改权属单位,原权属单位:" + formOld.factory + ",新权属单位:" + formNew.factory + ";" - } - if (formNew.installheigt != formOld.installheigt) { - descpNew += "修改井口距离,原井口距离:" + formOld.installheigt + ",新井口距离:" + formNew.installheigt + ";" - } - if (formNew.installperson != formOld.installperson) { - descpNew += "修改运维人员,原运维人员:" + formOld.installperson + ",新运维人员:" + formNew.installperson + ";" - } - if (formNew.latitude != formOld.latitude) { - descpNew += "修改纬度,原纬度:" + formOld.latitude + ",新纬度:" + formNew.latitude + ";" - } - if (formNew.longitude != formOld.longitude) { - descpNew += "修改经度,原经度:" + formOld.longitude + ",新经度:" + formNew.longitude + ";" - } - if (formNew.position != formOld.position) { - descpNew += "修改位置描述,原位置:" + formOld.position + ",新位置:" + formNew.position + ";" - } - if (formNew.wellcode != formOld.wellcode) { - descpNew += "修改井编号,原编号:" + formOld.wellcode + ",新编号:" + formNew.wellcode + ";" - } - if (formNew.welldepth != formOld.welldepth) { - descpNew += "修改井深,原井深:" + formOld.welldepth + ",新井深:" + formNew.welldepth + ";" - } - if (formNew.welltype != formOld.welltype) { - descpNew += "修改井类型,原井类型:" + formOld.welltype + ",新井类型:" + formNew.welltype + ";" - } - if (formNew.project != formOld.project) { - descpNew += "修改所属项目,原项目:" + formOld.project + ",新项目:" + formNew.project + ";" - } - if (this.data.photopath1 != formOld.photopath1 || - this.data.photopath2 != formOld.photopath2 || - this.data.photopath3 != formOld.photopath3) { - descpNew += "修改照片;" - } - if ("" != formNew.description) { - descpNew += formNew.description; - } - this.setData({ - ['form.description']: descpNew + if (this.data.form.welldepth != null) { + if (this.isNumber(this.data.form.welldepth)) { + wx.showToast({ + icon: 'none', + title: '井深必须为数值!', }) - }, + return false + } + } + if (this.data.form.installheigt != null) { + if (this.isNumber(this.data.form.installheigt)) { + wx.showToast({ + icon: 'none', + title: '到井口距离必须为数值!', + }) + return false + } + } - formSubmit: function (event) { + return true; + }, - if (!this.formValidate()) { - return false; - } - this.changeMsg(); - var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDeviceLog', - data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceLog/add" - }, - }).then(res => { - // var resultObj=JSON.parse(res.result); - if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - if (res.confirm) { - wx.switchTab({ - url: that.data.pageName - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) - } - }).catch(err => { - console.error(err) - wx.showToast({ - title: "提交失败", - }) - }) - }, - confirm(event) { - var that = this; - var formValue = event.detail.value; - var formName = event.target.dataset.id; - var fromN = 'form.' + [formName]; - that.setData({ - [fromN]: formValue - }) - }, + //获取与上次修改的信息 + changeMsg: function () { + var formNew = this.data.form; + console.log(this.data.detail) + var formOld = JSON.parse(this.data.detail); + var descpNew = ""; + if (formNew.devcode != formOld.devcode) { + descpNew += "修改设备编号,原值:" + formOld.devcode + ",新值:" + formNew.devcode + ";" + } + if (formNew.devicetype != formOld.devicetype) { + descpNew += "修改设备类型,原值:" + formOld.devicetype + ",新值:" + formNew.devicetype + ";" + } + if (formNew.area != formOld.area) { + descpNew += "修改区,原值:" + formOld.area + ",新值:" + formNew.area + ";" + } + if (formNew.street != formOld.street) { + descpNew += "修改街道,原值:" + formOld.street + ",新值:" + formNew.street + ";" + } + if (formNew.wellname != formOld.wellname) { + descpNew += "修改井名称,原值:" + formOld.wellname + ",新值:" + formNew.wellname + ";" + } + if (formNew.factory != formOld.factory) { + descpNew += "修改权属单位,原值:" + formOld.factory + ",新值:" + formNew.factory + ";" + } + if (formNew.installheigt != formOld.installheigt) { + descpNew += "修改井口距离,原值:" + formOld.installheigt + ",新值:" + formNew.installheigt + ";" + } + if (formNew.installperson != formOld.installperson) { + descpNew += "修改运维人员,原值:" + formOld.installperson + ",新值:" + formNew.installperson + ";" + } + if (formNew.latitude != formOld.latitude) { + descpNew += "修改纬度,原值:" + formOld.latitude + ",新值:" + formNew.latitude + ";" + } + if (formNew.longitude != formOld.longitude) { + descpNew += "修改经度,原值:" + formOld.longitude + ",新值:" + formNew.longitude + ";" + } + if (formNew.position != formOld.position) { + descpNew += "修改位置描述,原值:" + formOld.position + ",新值:" + formNew.position + ";" + } + if (formNew.wellcode != formOld.wellcode) { + descpNew += "修改井编号,原值:" + formOld.wellcode + ",新值:" + formNew.wellcode + ";" + } + if (formNew.welldepth != formOld.welldepth) { + descpNew += "修改井深,原值:" + formOld.welldepth + ",新值:" + formNew.welldepth + ";" + } + if (formNew.welltype != formOld.welltype) { + descpNew += "修改井类型,原值:" + formOld.welltype + ",新值:" + formNew.welltype + ";" + } + if (formNew.project != formOld.project) { + descpNew += "修改所属项目,原值:" + formOld.project + ",新值:" + formNew.project + ";" + } + if (this.data.form.photopath1 != formOld.photopath1 || + this.data.form.photopath2 != formOld.photopath2 || + this.data.form.photopath3 != formOld.photopath3) { + descpNew += "修改照片;" + } + if ("" != formNew.description) { + descpNew += formNew.description; + } + this.setData({ + ['form.description']: descpNew + }) + }, - scan() { + //提交表单 + formSubmit: function (event) { - wx.scanCode({ - success(res) { - console.log(res) - } - }) + //表单验证 + if (!this.formValidate()) { + return false; + } + //自动生成修改内容 + this.changeMsg(); + //提交权限限制(只有施工人员能修改) + if(app.globalData.role!='repair'){ + wx.showToast({ + icon: 'none', + title: '无权限修改', + duration:2000 + }) + return false + } + var that = this; + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopath = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopath]: fileList[i].url.split("static/")[1] + }) + } + delete that.data.form.installtime + delete that.data.form.createtime + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - paste() { - var _this = this; - wx.getClipboardData({ - success: function (res) { - var longitude = 'form.longitude'; - var latitude = 'form.latitude'; - var longitude84 = 'form.longitude84'; - var latitude84 = 'form.latitude84'; - _this.setData({ - [longitude]: parseFloat(res.data.split(",", 4)[1]).toFixed(6), - [latitude]: parseFloat(res.data.split(",", 4)[0]).toFixed(6), - [longitude84]: "" == (res.data.split(",", 4)[3]) ? "" : parseFloat(res.data.split(",", 4)[3]).toFixed(6), - [latitude84]: "" == (res.data.split(",", 4)[2]) ? "" : parseFloat(res.data.split(",", 4)[2]).toFixed(6), - longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), - latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), - }); - } - }) - }, - selectValue(value) { - var that = this; - var wellType = 'form.welltype'; - that.setData({ - [wellType]: value.detail - }) - }, - selectpersonValue(event) { - var that = this; - var installPerson = 'form.installperson'; - that.setData({ - [installPerson]: event.detail - }) - }, - selectprojectValue(event) { - var that = this; - var project = 'form.project'; - that.setData({ - [project]: event.detail, - showMask: true - }) - }, - open() { - this.setData({ - showMask: true - }) - }, - close() { - this.setData({ - showMask: false - }) - }, - afterRead(event) { - var _this = this; - const { - file - } = event.detail; - const { - fileList = [] - } = _this.data; - var convertpath = ""; - wx.compressImage({ - src: event.detail.file.path, - quality: 25, - success: function (res) { - convertpath = res.tempFilePath; - wx.uploadFile({ - url: app.globalData.httpsUrl + "appDeviceAdd/fileUploadMarker", - filePath:convertpath, - name: 'file', - formData: { - 'text': "编号:" + _this.data.form.devcode + "经度:" + _this.data.form.longitude + "纬度:" + _this.data.form.latitude - }, - header: { - "Content-Type": "multipart/form-data", - 'accept': 'application/json', - }, - success(res) { - if (res.data) { - var url = JSON.parse(res.data); - fileList.push({ - ...file, - url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - }); - _this.setData({ - fileList - }); - } - } + success(res) { + if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + if (res.confirm) { + wx.switchTab({ + url: that.data.pageName }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') } - }) - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // // var base64 = "data:image/png;base64," + wx.getFileSystemManager().readFileSync(convertpath, 'base64'); - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: convertpath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // // wx.cloud.callFunction({ - // // name: 'uploadFile', - // // data: { - // // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // // fileBase64: base64 - // // }, - // // success: function (res) { - // // if (res.result) { - // // fileList.push({ - // // ...file, - // // url: app.globalData.url + "static/" + res.result.data.replace(/\\/g, "/") - // // }); - // // _this.setData({ - // // fileList - // // }); - // // } - // // }, - // // complete: res => { - // // }, - // // }) - // } - // }); + } + }) + } + }, + fail(err) { + wx.showToast({ + title: "提交失败", + }) + } + }) + }, + //报存录入的input信息 + confirm(event) { + var that = this; + var formValue = event.detail.value; + var formName = event.target.dataset.id; + var fromN = 'form.' + [formName]; + that.setData({ + [fromN]: formValue + }) + }, + + //扫码 + scan() { + + wx.scanCode({ + success(res) { + console.log(res) + } + }) + }, + //粘贴经纬度 + paste() { + var _this = this; + wx.getClipboardData({ + success: function (res) { + var longitude = 'form.longitude'; + var latitude = 'form.latitude'; + var longitude84 = 'form.longitude84'; + var latitude84 = 'form.latitude84'; + _this.setData({ + [longitude]: parseFloat(res.data.split(",", 4)[1]).toFixed(6), + [latitude]: parseFloat(res.data.split(",", 4)[0]).toFixed(6), + [longitude84]: "" == (res.data.split(",", 4)[3]) ? "" : parseFloat(res.data.split(",", 4)[3]).toFixed(6), + [latitude84]: "" == (res.data.split(",", 4)[2]) ? "" : parseFloat(res.data.split(",", 4)[2]).toFixed(6), + longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), + latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), + }); + } + }) + }, + selectValue(value) { + var that = this; + var wellType = 'form.welltype'; + that.setData({ + [wellType]: value.detail + }) + }, + //运维人员默认为登录人 + // selectpersonValue(event) { + // var that = this; + // var installPerson = 'form.installperson'; + // that.setData({ + // [installPerson]: event.detail + // }) + // }, + selectprojectValue(event) { + var that = this; + var project = 'form.project'; + that.setData({ + [project]: event.detail, + showMask: true + }) + }, + + open() { + this.setData({ + showMask: true + }) + }, + //隐藏textarea,防止遮挡 + close() { + this.setData({ + showMask: false + }) + }, + //上传照片 + afterRead(event) { + var _this = this; + const { + file + } = event.detail; + const { + fileList = [] + } = _this.data; + var convertpath = ""; + wx.compressImage({ + src: event.detail.file.path, + quality: 25, + success: function (res) { + convertpath = res.tempFilePath; + wx.uploadFile({ + url: app.globalData.httpsUrl + "appDeviceAdd/fileUploadMarker", + filePath: convertpath, + name: 'file', + formData: { + 'text': "编号:" + _this.data.form.devcode + "经度:" + _this.data.form.longitude + "纬度:" + _this.data.form.latitude }, - deletePhoto(event) { - var that = this - var image_index = event.detail.index - var fileList_new = that.data.fileList; - wx.showModal({ - content: '确定删除照片?', - success: function (res) { - if (res.confirm) { - fileList_new.splice(image_index, 1); - that.setData({ - fileList: fileList_new - }) - wx.cloud.callFunction({ - name: 'deletePhoto', - data: { - url: app.globalData.url + "appDeviceLog/deletePhoto", - devcode: that.data.form.devcode, - pathIndex: image_index - }, - success: function (res) {}, - complete: res => {}, - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + "Content-Type": "multipart/form-data", + 'accept': 'application/json', }, - }) \ No newline at end of file + success(res) { + if (res.data) { + var url = JSON.parse(res.data); + fileList.push({ + ...file, + url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") + }); + _this.setData({ + fileList + }); + } + } + }) + } + }) + }, + //删除照片 + deletePhoto(event) { + var that = this + var image_index = event.detail.index + var fileList_new = that.data.fileList; + wx.showModal({ + content: '确定删除照片?', + success: function (res) { + if (res.confirm) { + fileList_new.splice(image_index, 1); + that.setData({ + fileList: fileList_new + }) + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deletePhoto", + data: { + devcode: that.data.form.devcode + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) {} + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } +}) \ No newline at end of file diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.wxml b/miniprogram/pages/addDevicelog/addDeviceLog.wxml index 38620d4..b10cc7d 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.wxml +++ b/miniprogram/pages/addDevicelog/addDeviceLog.wxml @@ -1,15 +1,21 @@ - + + + + + - + - - + + - - + + - + @@ -39,24 +45,25 @@ - - - + + + - + - + + @@ -64,7 +71,7 @@ - + @@ -79,9 +86,9 @@ - + - 保存 + 保存 diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.wxss b/miniprogram/pages/addDevicelog/addDeviceLog.wxss index ee0b75c..08d5fd7 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.wxss +++ b/miniprogram/pages/addDevicelog/addDeviceLog.wxss @@ -24,6 +24,17 @@ display: flex; align-items: center; } +.map-view{ + width: 750rpx; + height: 485rpx; + position: fixed; + top: 0px; + left: 0px; + z-index: 999; +} +.content{ + margin-top: 495rpx; +} .left { width: 210rpx; diff --git a/miniprogram/pages/addFunction/addFunction.js b/miniprogram/pages/addFunction/addFunction.js deleted file mode 100644 index 4966be3..0000000 --- a/miniprogram/pages/addFunction/addFunction.js +++ /dev/null @@ -1,60 +0,0 @@ -// pages/addFunction/addFunction.js - -const code = `// 云函数入口函数 -exports.main = (event, context) => { - console.log(event) - console.log(context) - return { - sum: event.a + event.b - } -}` - -Page({ - - data: { - result: '', - canIUseClipboard: wx.canIUse('setClipboardData'), - }, - - onLoad: function (options) { - - }, - - copyCode: function() { - wx.setClipboardData({ - data: code, - success: function () { - wx.showToast({ - title: '复制成功', - }) - } - }) - }, - - testFunction() { - wx.cloud.callFunction({ - name: 'sum', - data: { - a: 1, - b: 2 - }, - success: res => { - wx.showToast({ - title: '调用成功', - }) - this.setData({ - result: JSON.stringify(res.result) - }) - }, - fail: err => { - wx.showToast({ - icon: 'none', - title: '调用失败', - }) - console.error('[云函数] [sum] 调用失败:', err) - } - }) - }, - -}) - diff --git a/miniprogram/pages/addFunction/addFunction.json b/miniprogram/pages/addFunction/addFunction.json deleted file mode 100644 index a9a50c5..0000000 --- a/miniprogram/pages/addFunction/addFunction.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "navigationBarTitleText": "云函数指引", - "usingComponents": {} -} \ No newline at end of file diff --git a/miniprogram/pages/addFunction/addFunction.wxml b/miniprogram/pages/addFunction/addFunction.wxml deleted file mode 100644 index 3a10626..0000000 --- a/miniprogram/pages/addFunction/addFunction.wxml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - 测试云函数 - - - 期望输出:{"sum":3} - - - 调用结果:{{result}} - - - - - 新增云函数 - 1. 在云函数根目录 cloudfunctions 上右键选择新建云函数,命名为 sum - 2. 在创建的 cloudfunctions/sum/index.js 文件中添加如下代码 - - - 3. 在 cloudfunctions/sum 目录上右键上传并部署 - 4. 点击测试云函数测试 - 5. 打开云开发云函数管理页,选择 sum 云函数 - 6. 查看 sum 的调用日志 - 进阶:可在云函数中使用 wx-server-sdk 操作数据库,文件存储和调用其他云函数,详见文档 - - - diff --git a/miniprogram/pages/addFunction/addFunction.wxss b/miniprogram/pages/addFunction/addFunction.wxss deleted file mode 100644 index 7ac8619..0000000 --- a/miniprogram/pages/addFunction/addFunction.wxss +++ /dev/null @@ -1,3 +0,0 @@ -/* pages/addFunction/addFunction.wxss */ - -@import "../../style/guide.wxss"; \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.js b/miniprogram/pages/applog/applog.js index 0e8c185..189e61f 100644 --- a/miniprogram/pages/applog/applog.js +++ b/miniprogram/pages/applog/applog.js @@ -13,98 +13,25 @@ isSeach: "false", params: {}, total: 0, - show: false + show: false, + delBtnWidth: 100, //删除按钮宽度单位(rpx) + activeIndex: -1, + list_style: '' }, - - touchE: function (e) { - // console.log(e); - var that = this - if (e.changedTouches.length == 1) { - //手指移动结束后触摸点位置的X坐标 - var endX = e.changedTouches[0].clientX; - //触摸开始与结束,手指移动的距离 - var disX = that.data.startX - endX; - var delBtnWidth = that.data.delBtnWidth; - //如果距离小于删除按钮的1/2,不显示删除按钮 - var txtStyle = disX > delBtnWidth / 2 ? "left:-" + delBtnWidth + "rpx" : "left:0rpx"; - - //获取手指触摸的是哪一项 - var index = e.currentTarget.dataset.index; - var list = that.data.deviceloglist; - list[index].txtStyle = txtStyle; - //更新列表的状态 - that.setData({ - deviceloglist: list - }); - } - }, - //手指触摸动作开始 记录起点X坐标 - touchstart: function (e) { - //开始触摸时 重置所有删除 - this.data.deviceloglist.forEach(function (v, i) { - if (v.isTouchMove) //只操作为true的 - v.isTouchMove = false; - }) - this.setData({ - startX: e.changedTouches[0].clientX, - startY: e.changedTouches[0].clientY, - deviceloglist: this.data.deviceloglist - }) - }, - //滑动事件处理 - touchmove: function (e) { - var that = this, - index = e.currentTarget.dataset.index, //当前索引 - startX = that.data.startX, //开始X坐标 - startY = that.data.startY, //开始Y坐标 - touchMoveX = e.changedTouches[0].clientX, //滑动变化坐标 - touchMoveY = e.changedTouches[0].clientY, //滑动变化坐标 - //获取滑动角度 - angle = that.angle({ - X: startX, - Y: startY - }, { - X: touchMoveX, - Y: touchMoveY - }); - that.data.deviceloglist.forEach(function (v, i) { - v.isTouchMove = false - //滑动超过30度角 return - if (Math.abs(angle) > 30) return; - if (i == index) { - if (touchMoveX > startX) //右滑 - v.isTouchMove = false - else //左滑 - v.isTouchMove = true - } - }) - //更新数据 - that.setData({ - deviceloglist: that.data.deviceloglist - }) - }, - /** - * 计算滑动角度 - * @param {Object} start 起点坐标 - * @param {Object} end 终点坐标 - */ - angle: function (start, end) { - var _X = end.X - start.X, - _Y = end.Y - start.Y - //返回角度 /Math.atan()返回数字的反正切值 - return 360 * Math.atan(_Y / _X) / (2 * Math.PI); - }, - /** - * 生命周期函数--监听页面加载var_this=this; - */ onLoad: function (options) { - if (options.params) { this.setData({ params: JSON.parse(options.params), isSeach: "true" }) this.initPages() + }else{ + this.setData({ + show: false + }) + //清空参数,重新加载 + this.clearParams(); + this.initPages(); } }, @@ -116,20 +43,33 @@ }, + //点击tabBar事件 + onTabItemTap(item) { + //隐藏历史显示总记录条数 + this.setData({ + show: false + }) + //清空参数,重新加载 + this.clearParams(); + this.initPages(); + }, + + /** * 生命周期函数--监听页面显示 */ onShow: function (options) { - this.setData({ - show:false - }) - if (this.data.isSeach == "false") { - this.clearParams(); - this.initPages(); - } - this.setData({ - isSeach: "false" - }) + + // this.setData({ + // show: false + // }) + // if (this.data.isSeach == "false") { + // this.clearParams(); + // this.initPages(); + // } + // this.setData({ + // isSeach: "false" + // }) }, /** @@ -167,6 +107,119 @@ }, + + //手指触摸动作开始 记录起点X坐标 + touchstart: function (e) { + //开始触摸时 重置所有删除 + this.data.deviceloglist.forEach(function (v, i) { + if (v.isTouchMove) //只操作为true的 + v.isTouchMove = false; + }) + this.setData({ + startX: e.changedTouches[0].clientX, + startY: e.changedTouches[0].clientY, + deviceloglist: this.data.deviceloglist + }) + }, + + //滑动事件处理 + touchmove: function (e) { + var that = this, + index = e.currentTarget.dataset.index, //当前索引 + startX = that.data.startX, //开始X坐标 + startY = that.data.startY, //开始Y坐标 + touchMoveX = e.changedTouches[0].clientX, //滑动变化坐标 + touchMoveY = e.changedTouches[0].clientY, //滑动变化坐标 + //获取滑动角度 + angle = that.angle({ + X: startX, + Y: startY + }, { + X: touchMoveX, + Y: touchMoveY + }); + that.data.deviceloglist.forEach(function (v, i) { + // v.isTouchMove = false + //滑动超过30度角 return + if (Math.abs(angle) > 30) return; + if (i == index) { + if (touchMoveX > startX) //右滑 + v.isTouchMove = false + else //左滑 + v.isTouchMove = true + } + }) + //更新数据 + that.setData({ + deviceloglist: that.data.deviceloglist + }) + }, + + /** + * 计算滑动角度 + * @param {Object} start 起点坐标 + * @param {Object} end 终点坐标 + */ + angle: function (start, end) { + var _X = end.X - start.X, + _Y = end.Y - start.Y + //返回角度 /Math.atan()返回数字的反正切值 + return 360 * Math.atan(_Y / _X) / (2 * Math.PI); + }, + + //删除事件 + delItem: function (e) { + if(app.globalData.role!='repair'){ + wx.showToast({ + icon: 'none', + title: '无权限删除', + duration:2000 + }) + return false + } + var that = this + wx.showModal({ + content: '是否删除?', + success: function (res) { + if (res.confirm) { + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/delete", + data: { + appDeviceAddId: e.currentTarget.dataset.devid + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if(res.data.code=='200'){ + that.data.deviceloglist.splice(e.currentTarget.dataset.index, 1) + that.setData({ + deviceloglist: that.data.deviceloglist, + total: that.data.deviceloglist.length + }) + wx.showToast({ + title: '删除成功!', + icon: 'none', + duration: 1000 + }) + } + }, + fail(err) { + wx.showToast({ + title: '删除失败!', + icon: 'none', + duration: 2000 + }) + } + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + }, + showLoading: function (message) { if (wx.showLoading) { // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 @@ -199,95 +252,105 @@ deviceloglist: [] }) }, + //查询列表数据 initPages: function () { var that = this + that.setData({ + show: false + }) var offsetValue = that.data.deviceloglist.length % 15 > 0 ? parseInt(that.data.deviceloglist.length / 15) + 2 : parseInt(that.data.deviceloglist.length / 15) + 1 - wx.cloud.callFunction({ - name: 'devicelog', + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/listPage", data: { devcode: that.data.params.devcode, devtype: that.data.params.devtype, installtimeFmt: that.data.params.installtimeFmt, project: that.data.params.project, installPerson: that.data.params.installPerson, - url: app.globalData.url + "appDeviceLog/listPage", limit: 15, offset: offsetValue }, - }).then(res => { - if (res.result.data.rows.length > 0) { - var resultJson = res.result - that.setData({ - deviceloglist: that.data.deviceloglist.concat(resultJson.data.rows) - }) - } else if (that.data.deviceloglist.length > 0) { - that.setData({ - show: true, - total: that.data.deviceloglist.length - }) - wx.showToast({ - title: '数据已全部加载完', - icon: 'none', - duration: 2000 - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.data.rows.length > 0) { + var resultJson = res.data + var listArr = resultJson.data.rows + listArr.forEach(function (v, i) { + listArr[i]['isTouchMove'] = false + }) + that.setData({ + deviceloglist: that.data.deviceloglist.concat(listArr) + }) + } else if (that.data.deviceloglist.length > 0) { + that.setData({ + show: true, + total: that.data.deviceloglist.length + }) + wx.showToast({ + title: '数据已全部加载完', + icon: 'none', + duration: 2000 + }) + } + if (offsetValue == 1 && res.data.data.rows.length < 15) { + that.setData({ + show: true, + total: that.data.deviceloglist.length + }) + } } - if(offsetValue==1&&res.result.data.rows.length<15){ - that.setData({ - show: true, - total: that.data.deviceloglist.length - }) - } - // console.log(res); - }).catch(err => { - console.error(err); }) + }, addDetail: function (event) { - this.showLoading("数据请求中..."); - wx.cloud.callFunction({ - name: 'deviceDetail', + var that = this + that.showLoading("数据请求中..."); + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deviceDetail", data: { devcode: event.target.dataset.devcode, - url: app.globalData.url + "appDeviceLog/deviceDetail", }, - }).then(res => { - this.hideLoading(); - var resultObject = JSON.parse(res.result); - var pageName = '../applog/applog' - if (resultObject.code == 200) { - wx.navigateTo({ - url: '../addDevicelog/addDeviceLog?detail=' + - JSON.stringify(resultObject.data) + "&pageName=" + pageName - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + that.hideLoading(); + // var resultObject = JSON.parse(res.data); + var resultObject = res.data; + var pageName = '../applog/applog' + if (resultObject.code == 200) { + wx.setStorageSync('resultObject', resultObject.data) + wx.navigateTo({ + url: '../addDevicelog/addDeviceLog?detail=' + "&pageName=" + pageName + }) + } + }, + fail(err) { + that.hideLoading(); } - }).catch(err => { - this.hideLoading() }) + }, add: function (event) { - wx.reLaunch({ - url: '../earth/earth?devcode=' + event.target.dataset.devcode - // url: '../earth/earth' + app.globalData.devcode = event.target.dataset.devcode; + wx.switchTab({ + url: '../earth/earth' }) + // wx.reLaunch({ + // url: '../earth/earth?devcode=' + event.target.dataset.devcode + // // url: '../earth/earth' + // }) }, onSearch: function () { + var _this = this wx.navigateTo({ - url: '../searchLog/searchLog' + url: '../searchLog/searchLog?params=' + JSON.stringify(_this.data.params) }) - }, - // initPages: function () { - // wx.cloud.callFunction({ - // name: 'devicelog' - // }).then(res => { - // var that = this; - // var jsonList = JSON.parse(res.result) - // that.setData({ - // deviceloglist: jsonList.data.rows - // }) - // console.log(res); - // }).catch(err => { - // console.error(err); - // }) - // } + } }) \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.wxml b/miniprogram/pages/applog/applog.wxml index e9a2352..2bfd041 100644 --- a/miniprogram/pages/applog/applog.wxml +++ b/miniprogram/pages/applog/applog.wxml @@ -1,54 +1,59 @@ - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {{item.devcode}} {{item.devicetype}} + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + {{item.devcode}} {{item.devicetype}} + + {{item.project}} {{item.installtime}}- {{item.installperson}} - - - - - + + + + + + 删除 - - - + + - 共计:{{total}}台 - + 共计:{{total}}台 + \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.wxss b/miniprogram/pages/applog/applog.wxss index 6d3428b..e6e8983 100644 --- a/miniprogram/pages/applog/applog.wxss +++ b/miniprogram/pages/applog/applog.wxss @@ -22,16 +22,18 @@ position: fixed; width: 100%; top: 0rpx; + z-index: 9999; /* margin-bottom: 100rpx; */ } .log-list { /* height: 100rpx; */ - /* display: flex; */ - + display: flex; + width: 100%; padding: 2px; margin-top: 2px; border-bottom: 1px solid #e5e5e5; + overflow: hidden } @@ -53,23 +55,29 @@ left: 35%; margin: 20rpx } - .del { - width: 90px; + /* display: flex; */ + width: 100rpx; display: flex; flex-direction: column; align-items: center; justify-content: center; - color: #fff; - -webkit-transform: translateX(90px); - transform: translateX(90px); - -webkit-transition: all 0.4s; + /* -webkit-transform: translateX(100rpx); */ + transform: translateX(100rpx); + /* -webkit-transition: all 0.4s; */ transition: all 0.4s; - font-size: 35rpx; + color: #fff; + background-color: #fe3e2f; +} +.logrow{ + width: 100%; + transform: translateX(100rpx); + /* -webkit-transform: translateX(100px); */ + margin-left: -100rpx; } -.touch-move-active .content, +.touch-move-active .logrow, .touch-move-active .del { - -webkit-transform: translateX(0); - transform: translateX(0); +/* -webkit-transform: translateX(0); */ +transform: translateX(0); } \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.js b/miniprogram/pages/deployFunctions/deployFunctions.js deleted file mode 100644 index a76b144..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.js +++ /dev/null @@ -1,66 +0,0 @@ -// pages/deployFunctions/deployFunctions.js -Page({ - - /** - * 页面的初始数据 - */ - data: { - - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - - }, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { - - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - - }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { - - }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { - - } -}) \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.json b/miniprogram/pages/deployFunctions/deployFunctions.json deleted file mode 100644 index 7fbedab..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "navigationBarTitleText": "部署云函数", - "usingComponents": {} -} \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.wxml b/miniprogram/pages/deployFunctions/deployFunctions.wxml deleted file mode 100644 index 462b6b6..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.wxml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - 调用失败 - - - 请检查 login 云函数是否已部署 - - - - - 部署 login 云函数 - 1. 确保已通过工具栏云开发入口开通云开发 - 2. 在 cloudfunctions/login 目录上右键上传并部署 - 3. 回到首页,重新点击获取 openid - - - - diff --git a/miniprogram/pages/deployFunctions/deployFunctions.wxss b/miniprogram/pages/deployFunctions/deployFunctions.wxss deleted file mode 100644 index c8803e6..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.wxss +++ /dev/null @@ -1,7 +0,0 @@ -/* pages/deployFunctions/deployFunctions.wxss */ - -@import "../../style/guide.wxss"; - -.black { - color: black; -} \ No newline at end of file diff --git a/miniprogram/pages/earth/earth.js b/miniprogram/pages/earth/earth.js index ae0d3f3..376a6e2 100644 --- a/miniprogram/pages/earth/earth.js +++ b/miniprogram/pages/earth/earth.js @@ -21,19 +21,12 @@ show: false, enableSsatellite: false, windowWidth: 0, - longitude: 113.324520, - latitude: 23.099994, - longitude84: 113.324520, - latitude84: 23.099994, - markers: [{ - id: 0, - iconPath: "../../images/locat.png", - latitude: 23.099994, - longitude: 113.324520, - width: 50, - height: 50 - }], - controls: [], + longitude: "116.627340", + latitude: "39.874390", + longitude84: "", + latitude84: "", + markers: [], + controls: [] }, /** @@ -41,39 +34,13 @@ */ onLoad: function (options) { var that = this; - //获取当前坐标(gcj02) - wx.getLocation({ - type: "gcj02", - altitude: true, - success: function (res) { - that.setData({ - latitude: parseFloat(res.latitude).toFixed(6), - longitude: parseFloat(res.longitude).toFixed(6), - // markers: [{ - // latitude: res.latitude, - // longitude: res.longitude, - // }] - }) - //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 - wx.getLocation({ - type: "wgs84", - altitude: true, - success: function (res) { - that.setData({ - latitude84: parseFloat(res.latitude).toFixed(6), - longitude84: parseFloat(res.longitude).toFixed(6) - }) - } - }) - } - }), - - //设置地图组件 - wx.getSystemInfo({ + //设置地图组件 + wx.getSystemInfo({ success(res) { var windowWidth = res.windowWidth var windowHeight = res.windowHeight var query = wx.createSelectorQuery() + var platform =res.platform query.select('#map').boundingClientRect() query.exec(function (res) { that.setData({ @@ -139,10 +106,20 @@ clickable: true }, { id: 7, - iconPath: '../../images/locat.png', + iconPath: '../../images/applocat.png', position: { - left: res[0].width/2, - top: res[0].height/2, + left: res[0].width / 2 - 20, + top: platform=="ios"?res[0].height / 2 - 80:res[0].height / 2 - 40, + width: 40, + height: 40 + }, + clickable: true + }, { + id: 8, + iconPath: '../../images/back.png', + position: { + left: windowWidth - 40, + top: windowHeight - 140, width: 30, height: 30 }, @@ -150,71 +127,15 @@ }] }) }) - + } - }), + }) + // 实例化API核心类 qqmapsdk = new QQMapWX({ key: 'BGPBZ-C5O3P-ROUDR-LWC4J-63EKH-V5FRX' }) - - if (options.devcode) { - var that = this - var devcode = options.devcode - wx.cloud.callFunction({ - name: 'findListByCodes', - data: { - devcodes: devcode, - url: app.globalData.url + "appDeviceAdd/findListByCodes" - }, - }).then(res => { - if (res.result.code == 200) { - var listResultData = res.result.data; - that.setData({ - listData: listResultData - }) - var markersArr = that.data.markers; - for (var i = 0; i < listResultData.length; i++) { - markersArr = markersArr.concat({ - iconPath: "../../images/locat.png", - id: listResultData[i].id, - callout: { - content: listResultData[i].devcode, - fontSize: '14', - // padding: true, - color: '#00000', - borderColor: '#F4EA2A', - bgColor: '#F4EA2A', - borderWidth: 5, - display: 'ALWAYS', - textAlign: 'center', - // borderRadius: 15 - }, - latitude: listResultData[i].latitude, - longitude: listResultData[i].longitude, - width: 40, - height: 40 - }); - } - this.setData({ - markers: markersArr, - latitude: listResultData[0].latitude, - longitude: listResultData[0].longitude, - marker_latitude: listResultData[0].latitude, - marker_longitude: listResultData[0].longitude, - title: listResultData[0].devcode - }) - } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "无法获取设备地理信息!", - icon: 'none', - duration: 2000 - }) - }) - } }, /** @@ -228,6 +149,97 @@ * 生命周期函数--监听页面显示 */ onShow: function () { + //输入设备编号获取marker位置信息 + var that = this; + if ( app.globalData.devcode!="") { + var devcode = app.globalData.devcode + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/findListByCodes", + data: { + devcodes: devcode, + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + app.globalData.devcode=""; + if (res.data.code == 200) { + var listResultData = res.data.data; + that.setData({ + listData: listResultData + }) + var markersArr = that.data.markers; + for (var i = 0; i < listResultData.length; i++) { + markersArr = markersArr.concat({ + iconPath: "../../images/locat.png", + id: Number(listResultData[i].id), + callout: { + content: "编号:"+listResultData[i].devcode+"\r\n位置:"+listResultData[i].position+"\r\n时间:"+listResultData[i].createtime, + fontSize: '14', + padding: true, + color: '#000000', + borderColor: '#F4EA2A', + bgColor: '#F4EA2A', + borderWidth: 5, + display: 'ALWAYS', + textAlign: 'left', + // borderRadius: 15 + }, + latitude: listResultData[i].latitude, + longitude: listResultData[i].longitude, + width: 40, + height: 40 + }); + } + that.setData({ + markers: markersArr, + latitude: listResultData[0].latitude, + longitude: listResultData[0].longitude, + marker_latitude: listResultData[0].latitude, + marker_longitude: listResultData[0].longitude, + title: listResultData[0].devcode + }) + } + }, + fail(err) { + app.globalData.devcode=""; + wx.showToast({ + title: "无法获取设备地理信息!", + icon: 'none', + duration: 2000 + }) + } + }) +} else { + //获取当前坐标(gcj02) + wx.getLocation({ + type: "gcj02", + altitude: true, + success: function (res) { + that.setData({ + latitude: parseFloat(res.latitude).toFixed(6), + longitude: parseFloat(res.longitude).toFixed(6), + // markers: [{ + // latitude: res.latitude, + // longitude: res.longitude, + // }] + }) + //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 + wx.getLocation({ + type: "wgs84", + altitude: true, + success: function (res) { + that.setData({ + latitude84: parseFloat(res.latitude).toFixed(6), + longitude84: parseFloat(res.longitude).toFixed(6) + }) + } + }) + } + }) +} + }, @@ -265,12 +277,46 @@ onShareAppMessage: function () { }, + + //定位出来 + + locationPosition: function () { + var that = this; + //获取当前坐标(gcj02) + wx.getLocation({ + type: "gcj02", + altitude: true, + success: function (res) { + that.setData({ + latitude: parseFloat(res.latitude).toFixed(6), + longitude: parseFloat(res.longitude).toFixed(6), + // markers: [{ + // latitude: res.latitude, + // longitude: res.longitude + // }] + }) + //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 + wx.getLocation({ + type: "wgs84", + altitude: true, + success: function (res) { + that.setData({ + latitude84: parseFloat(res.latitude).toFixed(6), + longitude84: parseFloat(res.longitude).toFixed(6) + }) + } + }) + } + }) + }, + + //加载地图组件 controltap: function (e) { // console.log(e.controlId); //进入添加设备页 if (1 == e.controlId) { wx.setClipboardData({ - data: this.data.latitude + "," + this.data.longitude+ "," + this.data.latitude84+ "," + this.data.longitude84, + data: this.data.latitude + "," + this.data.longitude + "," + this.data.latitude84 + "," + this.data.longitude84, success: function (res) { wx.getClipboardData({ success: function (res) { @@ -282,6 +328,17 @@ } }) } else if (3 == e.controlId) { + //先定位 + // this.locationPosition() + wx.setClipboardData({ + data: this.data.latitude + "," + this.data.longitude + "," + this.data.latitude84 + "," + this.data.longitude84, + success: function (res) { + wx.showToast({ + title: '坐标已获取', + duration: 1000 + }) + } + }) wx.navigateTo({ url: '../addDevice/addDevice' }) @@ -302,32 +359,15 @@ enableSsatellite: !flag }); } else if (6 == e.controlId) { - var that = this; - //获取当前坐标(gcj02) - wx.getLocation({ - type: "gcj02", - altitude: true, - success: function (res) { - that.setData({ - latitude: parseFloat(res.latitude).toFixed(6), - longitude:parseFloat(res.longitude).toFixed(6), - // markers: [{ - // latitude: res.latitude, - // longitude: res.longitude - // }] - }) - //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 - wx.getLocation({ - type: "wgs84", - altitude: true, - success: function (res) { - that.setData({ - latitude84: parseFloat(res.latitude).toFixed(6), - longitude84: parseFloat(res.longitude).toFixed(6) - }) - } - }) - } + //先清marker + this.setData({ + markers: [] + }) + this.locationPosition() + }else if (8 == e.controlId) { + //跳转日志缓存页 + wx.switchTab({ + url: '../applog/applog', }) } }, @@ -343,63 +383,68 @@ }); }, + //获取设备maker leave() { var that = this; if (that.data.devcodes == "") { return false; } - wx.cloud.callFunction({ - name: 'findListByCodes', + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/findListByCodes", data: { - devcodes: that.data.devcodes, - url: app.globalData.url + "appDeviceAdd/findListByCodes" + devcodes: that.data.devcodes }, - }).then(res => { - if (res.result.code == 200) { - var listResultData = res.result.data; - that.setData({ - listData: listResultData - }) - var markersArr = that.data.markers; - for (var i = 0; i < listResultData.length; i++) { - markersArr = markersArr.concat({ - iconPath: "../../images/locat.png", - id: listResultData[i].id, - callout: { - content: listResultData[i].devcode, - fontSize: '14', - // padding: true, - color: '', - borderColor: '#F4EA2A', - bgColor: '#F4EA2A', - borderWidth: 5, - display: 'ALWAYS', - textAlign: 'center', - // borderRadius: 15 - }, - latitude: listResultData[i].latitude, - longitude: listResultData[i].longitude, - width: 40, - height: 40 - }); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var listResultData = res.data.data; + that.setData({ + listData: listResultData + }) + var markersArr = that.data.markers; + for (var i = 0; i < listResultData.length; i++) { + markersArr = markersArr.concat({ + iconPath: "../../images/locat.png", + id: listResultData[i].id, + callout: { + content: "编号:"+listResultData[i].devcode+"\r\n位置:"+listResultData[i].position+"\r\n时间:"+listResultData[i].createtime, + fontSize: '14', + // padding: true, + color: '#212121', + borderColor: '#F4EA2A', + bgColor: '#F4EA2A', + borderWidth: 5, + display: 'ALWAYS', + textAlign: 'left', + // borderRadius: 15 + }, + latitude: listResultData[i].latitude, + longitude: listResultData[i].longitude, + width: 40, + height: 40 + }); + } + that.setData({ + markers: markersArr, + latitude: listResultData[0].latitude, + longitude: listResultData[0].longitude, + marker_latitude: listResultData[0].latitude, + marker_longitude: listResultData[0].longitude, + title: listResultData[0].devcode + }) } - this.setData({ - markers: markersArr, - latitude: listResultData[0].latitude, - longitude: listResultData[0].longitude, - marker_latitude: listResultData[0].latitude, - marker_longitude: listResultData[0].longitude, - title: listResultData[0].devcode + }, + fail(err) { + wx.showToast({ + title: "无法获取设备地理信息!", + icon: 'none', + duration: 2000 }) } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "无法获取设备地理信息!", - icon: 'none', - duration: 2000 - }) }) }, @@ -422,6 +467,8 @@ } }, + + bindregionchange: function (e) { var that = this if (e.causedBy == "drag") { @@ -445,8 +492,8 @@ that.setData({ latitude: parseFloat(latitude).toFixed(6), longitude: parseFloat(longitude).toFixed(6), - latitude84:"", - longitude84:"", + latitude84: "", + longitude84: "", // markers: markersArr }) // mapCtx.moveToLocation(); @@ -465,16 +512,19 @@ qqmapsdk.search({ keyword: this.data.value, success: function (res) { + console.log(res) if (res && res.data) { _this.setData({ isShow: true, tips: res.data }); } + }, + complete: function (res){ + console.log(res); } }) }, - bindSearch: function (e) { var location = e.target.dataset.location; this.setData({ diff --git a/miniprogram/pages/earth/earth.wxml b/miniprogram/pages/earth/earth.wxml index a0db6ef..87474f8 100644 --- a/miniprogram/pages/earth/earth.wxml +++ b/miniprogram/pages/earth/earth.wxml @@ -1,9 +1,10 @@ + - + {{item.title}} {{item.address}} @@ -17,6 +18,6 @@ + placeholder="请输入定位设备编号用换行隔开" autosize border="{{ false }}" /> \ No newline at end of file diff --git a/miniprogram/pages/indexapp/indexapp.js b/miniprogram/pages/indexapp/indexapp.js index 5063372..849dbdb 100644 --- a/miniprogram/pages/indexapp/indexapp.js +++ b/miniprogram/pages/indexapp/indexapp.js @@ -7,9 +7,8 @@ */ data: { - count:1, - show: false, - onshow:true, + count: 1, + onshow: true, value: "", deviceloglist: [], devcode: "", @@ -21,6 +20,7 @@ // iconPath: "../../images/point.png", latitude: 23.099994, longitude: 113.324520, + label:'1', width: 50, height: 50 }], @@ -31,62 +31,26 @@ * 生命周期函数--监听页面加载 */ onLoad: function (options) { - + }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { - + }, /** * 生命周期函数--监听页面显示 */ onShow: function () { - // if( app.globalData.indexCount>1){ - // this.setData({ - // show:false - // }) - // }else{ - // this.showNotice() - // } - if(app.globalData.indexCount==1){ - this.setData({ - show:true - }) - this.showNotice() - } - app.globalData.indexCount+=1 - if(this.data.onshow){ + if (this.data.onshow) { this.initPages(); } }, - - showNotice: function() { - var that = this - var times = 0 - var i = setInterval(function() { - times++ - if (times >= 15) { - that.setData({ - show:false - }) - wx.showTabBar({ - animation: false, - }) - clearInterval(i) - } else { - wx.hideTabBar({ - animation: false, - }) - } - }, 1000) -}, - /** * 生命周期函数--监听页面隐藏 */ @@ -122,16 +86,27 @@ }, jump: function (event) { - var that = this; var latitude = event.target.dataset.pointLat; var longitude = event.target.dataset.pointLon; + let devcode = event.target.dataset.pointCode; that.setData({ latitude: latitude, longitude: longitude, markers: [{ latitude: latitude, - longitude: longitude + longitude: longitude, + callout: { + display:'ALWAYS',// 常显气泡 + content: devcode, //名称文本 + color: '#fff', //文本颜色 + borderRadius: 5, //边框圆角 + borderWidth: 1, //边框宽度 + borderColor: '#0060ff', //边框颜色 + bgColor: '#0060ff', //背景色 + padding: 5, //文本边缘留白 + textAlign: 'center' //文本对齐方式。有效值: left, right, center + } }] }) }, @@ -142,7 +117,7 @@ var devcode = res.result _this.setData({ devcode: devcode, - onshow:false + onshow: false }); _this.searchlogs(devcode) } @@ -151,40 +126,11 @@ onSearch: function (event) { this.setData({ - devcode:event.detail + devcode: event.detail }) this.searchlogs(event.detail) }, - - // bindregionchange: function (e) { - // var that = this - // if (e.causedBy == "drag") { - // var mapCtx = wx.createMapContext("map") - // mapCtx.getCenterLocation({ - // success: function (res) { - // var markersArr = that.data.markers - // for (var i = 0; i < markersArr.length; i++) { - // if (markersArr[i].iconPath == undefined) { - // markersArr.splice(i, 1) - // } - // } - // var latitude = res.latitude - // var longitude = res.longitude - // markersArr = markersArr.concat({ - // latitude: latitude, - // longitude: longitude - // }) - // that.setData({ - // latitude: latitude, - // longitude: longitude, - // markers: markersArr - // }) - // } - // }) - // } - // }, - showLoading: function (message) { if (wx.showLoading) { // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 @@ -211,81 +157,89 @@ } }, + //加载设备运维详细信息 toDetail: function (event) { - this.showLoading("数据加载中...") - wx.cloud.callFunction({ - name: 'deviceDetail', + var that = this + that.showLoading("数据加载中...") + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deviceDetail", data: { devcode: event.target.dataset.devcode, - url: app.globalData.url + "appDeviceLog/deviceDetail", }, - }).then(res => { - this.hideLoading(); - var resultObject = JSON.parse(res.result); - var pageName='../indexapp/indexapp' - if (resultObject.code == 200) { - wx.navigateTo({ - url: '../addDevicelog/addDeviceLog?detail=' + - JSON.stringify(resultObject.data)+'&pageName='+pageName - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + that.hideLoading(); + var resultObject = res.data; + var pageName = '../indexapp/indexapp' + if (resultObject.code == 200) { + wx.setStorageSync('resultObject', resultObject.data) + wx.navigateTo({ + url: '../addDevicelog/addDeviceLog?detail=' +'&pageName=' + pageName + }) + } + }, + fail(err){ + that.hideLoading(); } - }).catch(err => { - this.hideLoading(); }) }, + //加载列表 getlogs: function (devcode) { var that = this - wx.cloud.callFunction({ - name: 'devicelog', + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/listPage", data: { devcode: devcode, - url: app.globalData.url + "appDeviceLog/listPage", limit: 100, offset: that.data.deviceloglist.length % 100 > 0 ? parseInt(that.data.deviceloglist.length / 100) + 2 : parseInt(that.data.deviceloglist.length / 100) + 1 }, - }).then(res => { - if (res.result) { - // var resultJson = JSON.parse(res.result) - var resultJson = res.result - that.setData({ - deviceloglist: that.data.deviceloglist.concat(resultJson.data.rows) - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + // var resultJson = JSON.parse(res.result) + var resultJson = res.data + that.setData({ + deviceloglist: that.data.deviceloglist.concat(resultJson.data.rows) + }) + } } - console.log(res); - }).catch(err => { - console.error(err); }) }, + //查询列表 searchlogs: function (devcode) { var that = this - wx.cloud.callFunction({ - name: 'devicelog', + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/listPage", data: { devcode: devcode, - url: app.globalData.url + "appDeviceLog/listPage", limit: 100, offset: 1 }, - }).then(res => { - if (res.result) { - var resultJson = res.result - that.setData({ - deviceloglist: resultJson.data.rows, - onshow:true - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var resultJson = res.data + that.setData({ + deviceloglist: resultJson.data.rows, + onshow: true + }) + } } - console.log(res); - }).catch(err => { - console.error(err); }) }, initPages: function () { var that = this; - that.setData({ - devcode: "" - }); wx.getLocation({ type: "gcj02", success: function (res) { @@ -302,6 +256,6 @@ }) } }) - this.searchlogs() + this.data.devcode !== '' ? this.searchlogs(this.data.devcode) : this.searchlogs() }, }) \ No newline at end of file diff --git a/miniprogram/pages/indexapp/indexapp.wxml b/miniprogram/pages/indexapp/indexapp.wxml index 69322a0..f65b082 100644 --- a/miniprogram/pages/indexapp/indexapp.wxml +++ b/miniprogram/pages/indexapp/indexapp.wxml @@ -1,8 +1,12 @@ + + + + - @@ -32,9 +36,15 @@ - + + + + + + + @@ -46,14 +56,14 @@ - + - - + diff --git a/cloudfunctions/project.config.json b/cloudfunctions/project.config.json new file mode 100644 index 0000000..2b3119a --- /dev/null +++ b/cloudfunctions/project.config.json @@ -0,0 +1,28 @@ +{ + "appid": "wx2cef527a000f87c9", + "compileType": "miniprogram", + "libVersion": "2.27.3", + "packOptions": { + "ignore": [], + "include": [] + }, + "setting": { + "coverView": true, + "es6": true, + "postcss": true, + "minified": true, + "enhance": true, + "showShadowRootInWxmlPanel": true, + "packNpmRelationList": [], + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + } + }, + "condition": {}, + "editorSetting": { + "tabIndent": "insertSpaces", + "tabSize": 4 + } +} \ No newline at end of file diff --git a/cloudfunctions/project.private.config.json b/cloudfunctions/project.private.config.json new file mode 100644 index 0000000..42ff49d --- /dev/null +++ b/cloudfunctions/project.private.config.json @@ -0,0 +1,7 @@ +{ + "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", + "projectname": "cloudfunctions", + "setting": { + "compileHotReLoad": true + } +} \ No newline at end of file diff --git a/miniprogram/app.js b/miniprogram/app.js index 51d56f3..50a8a54 100644 --- a/miniprogram/app.js +++ b/miniprogram/app.js @@ -18,13 +18,15 @@ // this.globalData = {} }, globalData: { - // url: "http://111.198.10.15:11604/", - httpsUrl: "https://logapi.smartlog.work/", - httpsTestUrl: "https://smartlog.work/prodapi4test/", - url: "http://139.198.18.188:8083/", + httpsUrl: "https://logapi.smartlog.work/", + // httpsUrl: "http://139.198.18.188:8083/", // url: "http://127.0.0.1:8083/", - // httpsUrl: "http://127.0.0.1:8083/", + //httpsUrl: "http://127.0.0.1:8083/", openid: null, - indexCount:1 - }, + indexCount:1, + nickName:"", + userName:"", + role:"", + devcode:"" + } }) diff --git a/miniprogram/app.json b/miniprogram/app.json index d23f798..2b6db76 100644 --- a/miniprogram/app.json +++ b/miniprogram/app.json @@ -1,15 +1,17 @@ { "cloud": true, "pages": [ + "pages/login/login", "pages/indexapp/indexapp", "pages/earth/earth", "pages/applog/applog", "pages/addDevice/addDevice", "pages/addDevicelog/addDeviceLog", - "pages/searchLog/searchLog" + "pages/searchLog/searchLog", + "pages/notice/notice" ], "window": { - "backgroundColor": "#F6F6F6", + "backgroundColor": "#E6D480", "backgroundTextStyle": "light", "navigationBarBackgroundColor": "#FFCF00", "navigationBarTitleText": "智慧施工", @@ -46,11 +48,11 @@ "desc": "你的位置信息将用于小程序位置接口的效果展示" } }, + "requiredPrivateInfos": ["getLocation", "chooseLocation"], "networkTimeout": { "request": 30000, "connectSocket": 30000, "uploadFile": 30000, "downloadFile": 30000 - }, - "style": "v2" + } } \ No newline at end of file diff --git a/miniprogram/images/applocat.png b/miniprogram/images/applocat.png new file mode 100644 index 0000000..fe49f54 --- /dev/null +++ b/miniprogram/images/applocat.png Binary files differ diff --git a/miniprogram/images/back.png b/miniprogram/images/back.png new file mode 100644 index 0000000..32ac82d --- /dev/null +++ b/miniprogram/images/back.png Binary files differ diff --git a/miniprogram/images/bottom.png b/miniprogram/images/bottom.png new file mode 100644 index 0000000..d910e98 --- /dev/null +++ b/miniprogram/images/bottom.png Binary files differ diff --git a/miniprogram/images/header.png b/miniprogram/images/header.png new file mode 100644 index 0000000..6ea222e --- /dev/null +++ b/miniprogram/images/header.png Binary files differ diff --git a/miniprogram/images/login.png b/miniprogram/images/login.png index 8b73cc0..6471c46 100644 --- a/miniprogram/images/login.png +++ b/miniprogram/images/login.png Binary files differ diff --git a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss index 5a591fb..c9c35b5 100644 --- a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss +++ b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:100%;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:100%}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file +@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:650rpx;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:600rpx}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file diff --git a/miniprogram/pages/addDevice/addDevice.js b/miniprogram/pages/addDevice/addDevice.js index 2783674..78f00b7 100644 --- a/miniprogram/pages/addDevice/addDevice.js +++ b/miniprogram/pages/addDevice/addDevice.js @@ -1,5 +1,7 @@ // miniprogram/pages/addDevice/addDevice.js // import WxValidate from '../../utils/WxValidate.js' +var QQMapWX = require('../../libs/qqmap-wx-jssdk.js'); +var qqmapsdk; var app = getApp() Page({ @@ -11,32 +13,10 @@ canvasWidth: '', longitude: '', latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], + option1: [], personoption1: [], projectoption: [], + devtypeList:[], show: false, form: { devcode: "", @@ -59,7 +39,10 @@ project: "", area: "", street: "", - wellname: "" + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '', }, fileList: [] }, @@ -117,12 +100,14 @@ var that = this; //初始化表单内容为上次填写值 var cacheForms = wx.getStorageSync('cacheList') - if (cacheForms) { + cacheForms.photopath1='' + cacheForms.photopath2='' + cacheForms.photopath3='' + that.data.fileList=[] that.setData({ form: cacheForms, devcode: cacheForms.devcode, - }) } var form = that.data.form @@ -155,55 +140,89 @@ } }) + +//获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + that.setData({ + option1: welltypeArr + }) + } + } +}) + + //获取人员下拉列表 - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/getUser", + data:{ + tips:'repair' }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data.code == 200) { + var users = res.data.data + var personArr = []; + for (var i = 0; i < users.length; i++) { + var person = { + text: users[i].name, + value: users[i].name + }; + personArr.push(person); + } + that.setData({ + personoption1: personArr + }) } - that.setData({ - personoption1: personArr - }) } - }).catch(err => { - console.error(err); - }) + }) + - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - that.setData({ - projectoption: projectArr - }) + success(res){ + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); + } + that.setData({ + projectoption: projectArr + }) + } } - }).catch(err => { - console.error(err); - }) + }) + var installtime = 'form.installtimeFmt'; var dateNow = this.formatDate(); this.setData({ @@ -211,8 +230,40 @@ installtimeFmt: dateNow, [installtime]: dateNow, }); + + + + /** + * 获取设备类型下拉列表 + */ + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/deviceType", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var TypeList = res.data.data + var typeArr = []; + for (var i = 0; i < TypeList.length; i++) { + var type = { + text: TypeList[i].productName, + value: TypeList[i].productName + }; + typeArr.push(type); + } + that.setData({ + devtypeList: typeArr + }) + } + } + }) }, + + + /** * 生命周期函数--监听页面初次渲染完成 */ @@ -280,29 +331,7 @@ }, - - //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 - drawText: function (ctx, str, leftWidth, initHeight, titleHeight, canvasWidth) { - var lineWidth = 0; - var lastSubStrIndex = 0; //每次开始截取的字符串的索引 - for (let i = 0; i < str.length; i++) { - lineWidth += ctx.measureText(str[i]).width; - if (lineWidth > canvasWidth) { - ctx.fillText(str.substring(lastSubStrIndex, i), leftWidth, initHeight); //绘制截取部分 - initHeight = initHeight + leftWidth * 2; //22为字体的高度 - lineWidth = 0; - lastSubStrIndex = i; - // titleHeight += 40; - } - if (i == str.length - 1) { //绘制剩余部分 - ctx.fillText(str.substring(lastSubStrIndex, i + 1), leftWidth, initHeight); - } - } - // // 标题border-bottom 线距顶部距离 - // titleHeight = titleHeight + 10; - // return titleHeight - }, - + //验证表单 formValidate() { if (this.data.form.devcode == "") { @@ -312,27 +341,20 @@ }) return false } - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } if (this.data.form.wellcode == "") { wx.showToast({ icon: 'none', @@ -348,22 +370,10 @@ }) return false } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null) { + + if (this.data.form.installperson == "") { wx.showToast({ icon: 'none', title: '安装人员不能为空!', @@ -408,56 +418,90 @@ } return true; }, + //提交表单 formSubmit: function (event) { + console.log(this.data.form) + //表单参数验证 if (!this.formValidate()) { return false; } var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDevice', + //验证设备编号长度 + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/getDevTypeLength", data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceAdd/add" + code: encodeURI(this.data.form.devicetype) }, - }).then(res => { - if (res.result.code == 500) { - wx.showToast({ - title: '设备编号已安装!', - }) - } else if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - //用于回显 - wx.setStorageSync('cacheList', that.data.form) - //提交成功后提示用户操作 - if (res.confirm) { - wx.switchTab({ - url: '../earth/earth' - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (""==res.data.data ||res.data.data == that.data.form.devcode.length) { + that.saveDevice() + } else { //编号位数不对提示 + wx.showToast({ + icon: 'none', + title: '设备编号位数不对!', + duration: 1000 + }) + return false + } } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "提交失败", - }) }) }, + + //保存设备基本信息 + saveDevice() { + var that = this; + //设置照片路径 + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopathForm = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopathForm]: fileList[i].url.split("static/")[1] + }) + } + //表单提交 + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 500) { + wx.showToast({ + title: '设备编号已安装!', + }) + } else if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + //用于回显 + wx.setStorageSync('cacheList', that.data.form) + //提交成功后提示用户操作 + if (res.confirm) { + wx.switchTab({ + url: '../earth/earth' + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } + }, + fail(err) { + wx.showToast({ + title: '提交失败!', + }) + } + }) + }, + + //input 输入框设置值 confirm(event) { var that = this; var formValue = event.detail.value; @@ -466,8 +510,30 @@ that.setData({ [fromN]: formValue }) + //若输入是设备编号,自动获取设备类型 + if('devcode'==formName){ + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", + data: { + devcode: formValue, + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + that.setData({ + [formDevicetype]: res.data + }); + } + } + }) + } }, + //扫描设备获取编号和设备类型 scan() { var _this = this; wx.scanCode({ @@ -477,23 +543,28 @@ _this.setData({ [formdevcode]: devcode }); - wx.cloud.callFunction({ - name: 'findModeCode', + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", data: { devcode: devcode, - url: app.globalData.url + "appDeviceAdd/findModeCodeByCode" }, - }).then(res => { - if (res.result) { - var formDevicetype = 'form.devicetype' - _this.setData({ - [formDevicetype]: res.result - }); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + _this.setData({ + [formDevicetype]: res.data + }); + } } }) } }) }, + //粘贴经纬度 paste() { var _this = this; wx.getClipboardData({ @@ -510,9 +581,11 @@ longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), }); + _this.showAddress(_this.data.form.longitude,_this.data.form.latitude,_this) } }) }, + //设置经类型 selectValue(value) { var that = this; @@ -521,6 +594,16 @@ [wellType]: value.detail }) }, + + //设置设备类型 + selectDevType(event) { + var that = this; + var devtype = 'form.devicetype'; + that.setData({ + [devtype]: event.detail + }) + }, + //设置运维人员 selectpersonValue(event) { var that = this; var installPerson = 'form.installperson'; @@ -528,6 +611,7 @@ [installPerson]: event.detail }) }, + //设置项目 selectprojectValue(event) { var that = this; var project = 'form.project'; @@ -535,8 +619,41 @@ [project]: event.detail }) }, + showAddress :function(longitude, latitude, self) { + // 实例化腾讯地图API核心类 + qqmapsdk = new QQMapWX({ + key: 'BGPBZ-C5O3P-ROUDR-LWC4J-63EKH-V5FRX'//此处使用你自己申请的key + }) + // 腾讯地图调用接口 + qqmapsdk.reverseGeocoder({ + location: { + latitude: latitude, + longitude: longitude + }, + success: function (res) { + self.setData({ + 'form.area':res.result.address.slice(0,res.result.address.indexOf('区')+1), + 'form.street':res.result.address.slice(res.result.address.indexOf('区')+1) + }) + }, + fail: function (res) { + console.log(res); + }, + complete: function (res) { + } + }); + }, + //上传照片 afterRead(event) { var _this = this; + if (_this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '请先填写设备编号!\r\n否则水印中无编号', + duration: 2000 + }) + return false + } const { file } = event.detail; @@ -576,78 +693,8 @@ }) } }) - // 压缩图片 - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // //获取图片尺寸 - // wx.getImageInfo({ - // src: convertpath, - // success(res) { - // _this.setData({ - // canvasHeight: res.height, - // canvasWidth: res.width - // }) - // var ctx = wx.createCanvasContext('firstCanvas') - - // //将图片src放到cancas内,宽高为图片大小 - // ctx.drawImage(convertpath, 0, 0, res.width, res.height) - // //将声明的时间放入canvas - // ctx.setFontSize(30 * (res.width / 750)) //注意:设置文字大小必须放在填充文字之前,否则不生效 - // ctx.setFillStyle('blue') - // var text = "编号:" + _this.data.form.devcode + "\n经度:" + _this.data.form.longitude + "\n纬度:" + _this.data.form.latitude - // // _this.drawText(ctx,text,20, 70, 5, res.width) - // _this.drawText(ctx, text, 15 * (res.width / 750), 70 * (res.width / 750), 5, res.width) - - // // ctx.fillText(text, 0, 40) - // // ctx.strokeText(_this.data.form.devcode, 0, 30) - // //生成水印图 - // ctx.draw(false, function () { - // wx.canvasToTempFilePath({ - // canvasId: 'firstCanvas', - // success: (res) => { - // wx.compressImage({ - // src: res.tempFilePath, - // quality: 25, - // success: function (res) { - // //上传照片至服务器 - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: res.tempFilePath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // } - // }) - // //// - // } - // }) - // }) - // } - // }) - // } - // }); }, + //删除照片 deletePhoto(event) { var image_index = event.detail.index var fileList_new = this.data.fileList; diff --git a/miniprogram/pages/addDevice/addDevice.wxml b/miniprogram/pages/addDevice/addDevice.wxml index b0977e2..f12c254 100644 --- a/miniprogram/pages/addDevice/addDevice.wxml +++ b/miniprogram/pages/addDevice/addDevice.wxml @@ -5,18 +5,30 @@ - + + + + + + + + + + + + + - - + + - - - + + + @@ -29,13 +41,13 @@ - + - + - + - + @@ -54,8 +66,7 @@ - - + @@ -68,8 +79,8 @@ - - + + - 保存 + 保存 \ No newline at end of file diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.js b/miniprogram/pages/addDevicelog/addDeviceLog.js index cdec71b..a0dc6da 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.js +++ b/miniprogram/pages/addDevicelog/addDeviceLog.js @@ -3,681 +3,665 @@ var app = getApp(); Page({ - /** - * 页面的初始数据 - */ - data: { - pageName: '', - showMask: false, - today: new Date().getTime(), - longitude: '', - latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], - personoption1: [], - projectoption: [], - devcode: "", - deviceMode: "", - installtimeFmt: '', - show: false, - form: { - devcode: "", - wellcode: "", - welltype: "", - welldepth: "", - installheigt: "", - installperson: "", - installtimeFmt: "", - photopath: "", - factory: "", - workmsg: "", - position: "", - description: "", - longitude: "", - latitude: "", - longitude84: "", - latitude84: "", - devicetype: "", - project: "", - area: "", - street: "", - wellname: "" - }, - fileList: [], - detail: "" - }, + /** + * 页面的初始数据 + */ + data: { + pageName: '', + showMask: false, + today: new Date().getTime(), + longitude: '', + latitude: '', + option1: [], + personoption1: [], + projectoption: [], + devcode: "", + deviceMode: "", + installtimeFmt: '', + show: false, + form: { + devcode: "", + wellcode: "", + welltype: "", + welldepth: "", + installheigt: "", + installperson: "", + installtimeFmt: "", + photopath: "", + factory: "", + workmsg: "", + position: "", + description: "", + longitude: "", + latitude: "", + longitude84: "", + latitude84: "", + devicetype: "", + project: "", + area: "", + street: "", + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '' + }, + fileList: [], + detail: "", + markers: [{ + id: 100, + // iconPath: "../../images/point.png", + latitude: '', + longitude: '', + // label:'1', + width: 25, + height: 35 + }], + }, - onDisplay() { - this.setData({ - show: true - }); - }, - onClose() { - this.setData({ - show: false - }); - }, - formatDate() { - var date = new Date(); - // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; - var seperator1 = "-"; - var month = date.getMonth() + 1; - var strDate = date.getDate(); - var hour = date.getHours() - var minute = date.getMinutes() - var second = date.getSeconds() - month = month > 9 ? month : "0" + month; - strDate = strDate > 9 ? strDate : "0" + strDate; - hour = hour > 9 ? hour : "0" + hour; - minute = minute > 9 ? minute : "0" + minute; - second = second > 9 ? second : "0" + second; - var currentdate = - date.getFullYear() + - seperator1 + - month + - seperator1 + - strDate + - " " + - hour + ":" + - minute + ":" + - second; - return currentdate; + onDisplay() { + this.setData({ + show: true + }); + }, + onClose() { + this.setData({ + show: false + }); + }, + formatDate() { + var date = new Date(); + // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; + var seperator1 = "-"; + var month = date.getMonth() + 1; + var strDate = date.getDate(); + var hour = date.getHours() + var minute = date.getMinutes() + var second = date.getSeconds() + month = month > 9 ? month : "0" + month; + strDate = strDate > 9 ? strDate : "0" + strDate; + hour = hour > 9 ? hour : "0" + hour; + minute = minute > 9 ? minute : "0" + minute; + second = second > 9 ? second : "0" + second; + var currentdate = + date.getFullYear() + + seperator1 + + month + + seperator1 + + strDate + + " " + + hour + ":" + + minute + ":" + + second; + return currentdate; - }, - onConfirm(event) { - var installtime = 'form.installtimeFmt'; - this.setData({ - show: false, - installtimeFmt: this.formatDate(event.detail), - [installtime]: this.formatDate(event.detail), - }); - }, + }, + onConfirm(event) { + var installtime = 'form.installtimeFmt'; + this.setData({ + show: false, + installtimeFmt: this.formatDate(event.detail), + [installtime]: this.formatDate(event.detail), + }); + }, - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - var _this = this; - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" - }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); - } - _this.setData({ - personoption1: personArr - }) + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + var _this = this; + _this.setData({ + 'markers[0].latitude': Number(wx.getStorageSync('resultObject').latitude) , + 'markers[0].longitude': Number(wx.getStorageSync('resultObject').longitude), + // 'markers[0].label':'10', + 'markers[0].width': 18, + 'markers[0].id':1, + 'markers[0].height': 30, + latitude:Number(wx.getStorageSync('resultObject').latitude), + longitude:Number(wx.getStorageSync('resultObject').longitude) + }) + //获取人员下拉列表 + // wx.request({ + // method: "POST", + // url: app.globalData.httpsUrl + "deviceType/getUser", + // data:{ + // tips:'repair' + // }, + // header: { + // 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + // }, + // success(res) { + // if (res.data.code == 200) { + // var users = res.data.data + // var personArr = []; + // for (var i = 0; i < users.length; i++) { + // var person = { + // text: users[i].name, + // value: users[i].name + // }; + // personArr.push(person); + // } + // _this.setData({ + // personoption1: personArr + // }) + // } + // } + // }) + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); } - }).catch(err => { - console.error(err); - }) - - - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" - }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - _this.setData({ - projectoption: projectArr - }) - } - }).catch(err => { - console.error(err); - }) - - if (options.pageName) { - this.setData({ - pageName: options.pageName - }) - } - - if (options.detail) { - - var formObject = JSON.parse(options.detail); _this.setData({ - form: formObject, - detail: options.detail + projectoption: projectArr }) - - _this.setData({ - ['form.installperson']: "", - ['form.installtimeFmt']: "", - ['form.workmsg']: "", - ['form.description']: "" - }) - - const { - fileList = [] - } = _this.data; - if (formObject.photopath1 != "") { - var file1 = { - url: app.globalData.url + "static/" + formObject.photopath1 - } - fileList.push(file1) - } - if (formObject.photopath2 != "") { - var file2 = { - url: app.globalData.url + "static/" + formObject.photopath2 - } - fileList.push(file2) - } - if (formObject.photopath3 != "") { - var file3 = { - url: app.globalData.url + "static/" + formObject.photopath3 - } - fileList.push(file3) - } - - _this.setData({ - fileList - }); } - var installtime = 'form.installtimeFmt'; - var dateNow = this.formatDate(); - this.setData({ - installtimeFmt: dateNow, - [installtime]: dateNow, - }); - }, + } + }) - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { + //获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + _this.setData({ + option1: welltypeArr + }) + } + } +}) - }, + //跳转时带入参数返回哪页 + if (options.pageName) { + this.setData({ + pageName: options.pageName + }) + } + //跳转时带入参数设备的安装信息 + if (wx.getStorageSync('resultObject')) { + var formObject = wx.getStorageSync('resultObject') + _this.setData({ + form: formObject, + detail: formObject + }) - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { + _this.setData({ + ['form.installperson']: app.globalData.userName, + ['form.installtimeFmt']: "", + ['form.workmsg']: "", + ['form.description']: "" + }) - }, + const { + fileList = [] + } = _this.data; + if (formObject.photopath1 != "") { + var file1 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath1 + } + fileList.push(file1) + } + if (formObject.photopath2 != "") { + var file2 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath2 + } + fileList.push(file2) + } + if (formObject.photopath3 != "") { + var file3 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath3 + } + fileList.push(file3) + } + _this.setData({ + fileList + }); + } + var installtime = 'form.installtimeFmt'; + var dateNow = this.formatDate(); + this.setData({ + installtimeFmt: dateNow, + [installtime]: dateNow, + }); + }, - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, - }, + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + wx.removeStorageSync('resultObject') + }, - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, - }, + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { + }, - }, + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { + }, - }, + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { + }, - }, + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + }, - /** - * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true - **/ + /** + * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true + **/ - isNumber: function (val) { + isNumber: function (val) { - var regPos = /^[0-9]*$/; //非负浮点数 - var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数 - if (regPos.test(val) || regNeg.test(val)) { - return false; - } else { - return true; - } + var regPos = /^[0-9]*$/; //非负浮点数 + var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数 + if (regPos.test(val) || regNeg.test(val)) { + return false; + } else { + return true; + } - }, + }, - formValidate() { + formValidate() { - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } - if (this.data.form.wellcode == "") { - wx.showToast({ - icon: 'none', - title: '井编号不能为空!', - }) - return false - } - if (this.data.form.devicetype == "") { - wx.showToast({ - icon: 'none', - title: '设备类型不能为空!', - }) - return false - } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + if (this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '设备编号不能为空!', + }) + return false + } + if (this.data.form.wellcode == "") { + wx.showToast({ + icon: 'none', + title: '井编号不能为空!', + }) + return false + } + if (this.data.form.devicetype == "") { + wx.showToast({ + icon: 'none', + title: '设备类型不能为空!', + }) + return false + } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null || - this.data.form.installperson == '') { - wx.showToast({ - icon: 'none', - title: '运维人员不能为空!', - }) - return false - } - if (this.data.form.project == "") { - wx.showToast({ - icon: 'none', - title: '所属项目不能为空!', - }) - return false - } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } + if (this.data.form.installperson == null || + this.data.form.installperson == '') { + wx.showToast({ + icon: 'none', + title: '运维人员不能为空!', + }) + return false + } + if (this.data.form.project == "") { + wx.showToast({ + icon: 'none', + title: '所属项目不能为空!', + }) + return false + } - if (this.data.form.welldepth != null) { - if (this.isNumber(this.data.form.welldepth)) { - wx.showToast({ - icon: 'none', - title: '井深必须为数值!', - }) - return false - } - } - if (this.data.form.installheigt != null) { - if (this.isNumber(this.data.form.installheigt)) { - wx.showToast({ - icon: 'none', - title: '到井口距离必须为数值!', - }) - return false - } - } - - return true; - }, - - changeMsg: function () { - var formNew = this.data.form; - var formOld = JSON.parse(this.data.detail); - var descpNew = ""; - if (formNew.devcode != formOld.devcode) { - descpNew += "修改设备编号,原编号:" + formOld.devcode + ",新编号:" + formNew.devcode + ";" - } - if (formNew.devicetype != formOld.devicetype) { - descpNew += "修改设备类型,原设备类型:" + formOld.devicetype + ",新设备类型:" + formNew.devicetype + ";" - } - if (formNew.area != formOld.area) { - descpNew += "修改区,原区:" + formOld.area + ",新区:" + formNew.area + ";" - } - if (formNew.street != formOld.street) { - descpNew += "修改街道,原街道:" + formOld.street + ",新街道:" + formNew.street + ";" - } - if (formNew.wellname != formOld.wellname) { - descpNew += "修改井名称,原井名称:" + formOld.wellname + ",新井名称:" + formNew.wellname + ";" - } - if (formNew.factory != formOld.factory) { - descpNew += "修改权属单位,原权属单位:" + formOld.factory + ",新权属单位:" + formNew.factory + ";" - } - if (formNew.installheigt != formOld.installheigt) { - descpNew += "修改井口距离,原井口距离:" + formOld.installheigt + ",新井口距离:" + formNew.installheigt + ";" - } - if (formNew.installperson != formOld.installperson) { - descpNew += "修改运维人员,原运维人员:" + formOld.installperson + ",新运维人员:" + formNew.installperson + ";" - } - if (formNew.latitude != formOld.latitude) { - descpNew += "修改纬度,原纬度:" + formOld.latitude + ",新纬度:" + formNew.latitude + ";" - } - if (formNew.longitude != formOld.longitude) { - descpNew += "修改经度,原经度:" + formOld.longitude + ",新经度:" + formNew.longitude + ";" - } - if (formNew.position != formOld.position) { - descpNew += "修改位置描述,原位置:" + formOld.position + ",新位置:" + formNew.position + ";" - } - if (formNew.wellcode != formOld.wellcode) { - descpNew += "修改井编号,原编号:" + formOld.wellcode + ",新编号:" + formNew.wellcode + ";" - } - if (formNew.welldepth != formOld.welldepth) { - descpNew += "修改井深,原井深:" + formOld.welldepth + ",新井深:" + formNew.welldepth + ";" - } - if (formNew.welltype != formOld.welltype) { - descpNew += "修改井类型,原井类型:" + formOld.welltype + ",新井类型:" + formNew.welltype + ";" - } - if (formNew.project != formOld.project) { - descpNew += "修改所属项目,原项目:" + formOld.project + ",新项目:" + formNew.project + ";" - } - if (this.data.photopath1 != formOld.photopath1 || - this.data.photopath2 != formOld.photopath2 || - this.data.photopath3 != formOld.photopath3) { - descpNew += "修改照片;" - } - if ("" != formNew.description) { - descpNew += formNew.description; - } - this.setData({ - ['form.description']: descpNew + if (this.data.form.welldepth != null) { + if (this.isNumber(this.data.form.welldepth)) { + wx.showToast({ + icon: 'none', + title: '井深必须为数值!', }) - }, + return false + } + } + if (this.data.form.installheigt != null) { + if (this.isNumber(this.data.form.installheigt)) { + wx.showToast({ + icon: 'none', + title: '到井口距离必须为数值!', + }) + return false + } + } - formSubmit: function (event) { + return true; + }, - if (!this.formValidate()) { - return false; - } - this.changeMsg(); - var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDeviceLog', - data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceLog/add" - }, - }).then(res => { - // var resultObj=JSON.parse(res.result); - if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - if (res.confirm) { - wx.switchTab({ - url: that.data.pageName - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) - } - }).catch(err => { - console.error(err) - wx.showToast({ - title: "提交失败", - }) - }) - }, - confirm(event) { - var that = this; - var formValue = event.detail.value; - var formName = event.target.dataset.id; - var fromN = 'form.' + [formName]; - that.setData({ - [fromN]: formValue - }) - }, + //获取与上次修改的信息 + changeMsg: function () { + var formNew = this.data.form; + console.log(this.data.detail) + var formOld = JSON.parse(this.data.detail); + var descpNew = ""; + if (formNew.devcode != formOld.devcode) { + descpNew += "修改设备编号,原值:" + formOld.devcode + ",新值:" + formNew.devcode + ";" + } + if (formNew.devicetype != formOld.devicetype) { + descpNew += "修改设备类型,原值:" + formOld.devicetype + ",新值:" + formNew.devicetype + ";" + } + if (formNew.area != formOld.area) { + descpNew += "修改区,原值:" + formOld.area + ",新值:" + formNew.area + ";" + } + if (formNew.street != formOld.street) { + descpNew += "修改街道,原值:" + formOld.street + ",新值:" + formNew.street + ";" + } + if (formNew.wellname != formOld.wellname) { + descpNew += "修改井名称,原值:" + formOld.wellname + ",新值:" + formNew.wellname + ";" + } + if (formNew.factory != formOld.factory) { + descpNew += "修改权属单位,原值:" + formOld.factory + ",新值:" + formNew.factory + ";" + } + if (formNew.installheigt != formOld.installheigt) { + descpNew += "修改井口距离,原值:" + formOld.installheigt + ",新值:" + formNew.installheigt + ";" + } + if (formNew.installperson != formOld.installperson) { + descpNew += "修改运维人员,原值:" + formOld.installperson + ",新值:" + formNew.installperson + ";" + } + if (formNew.latitude != formOld.latitude) { + descpNew += "修改纬度,原值:" + formOld.latitude + ",新值:" + formNew.latitude + ";" + } + if (formNew.longitude != formOld.longitude) { + descpNew += "修改经度,原值:" + formOld.longitude + ",新值:" + formNew.longitude + ";" + } + if (formNew.position != formOld.position) { + descpNew += "修改位置描述,原值:" + formOld.position + ",新值:" + formNew.position + ";" + } + if (formNew.wellcode != formOld.wellcode) { + descpNew += "修改井编号,原值:" + formOld.wellcode + ",新值:" + formNew.wellcode + ";" + } + if (formNew.welldepth != formOld.welldepth) { + descpNew += "修改井深,原值:" + formOld.welldepth + ",新值:" + formNew.welldepth + ";" + } + if (formNew.welltype != formOld.welltype) { + descpNew += "修改井类型,原值:" + formOld.welltype + ",新值:" + formNew.welltype + ";" + } + if (formNew.project != formOld.project) { + descpNew += "修改所属项目,原值:" + formOld.project + ",新值:" + formNew.project + ";" + } + if (this.data.form.photopath1 != formOld.photopath1 || + this.data.form.photopath2 != formOld.photopath2 || + this.data.form.photopath3 != formOld.photopath3) { + descpNew += "修改照片;" + } + if ("" != formNew.description) { + descpNew += formNew.description; + } + this.setData({ + ['form.description']: descpNew + }) + }, - scan() { + //提交表单 + formSubmit: function (event) { - wx.scanCode({ - success(res) { - console.log(res) - } - }) + //表单验证 + if (!this.formValidate()) { + return false; + } + //自动生成修改内容 + this.changeMsg(); + //提交权限限制(只有施工人员能修改) + if(app.globalData.role!='repair'){ + wx.showToast({ + icon: 'none', + title: '无权限修改', + duration:2000 + }) + return false + } + var that = this; + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopath = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopath]: fileList[i].url.split("static/")[1] + }) + } + delete that.data.form.installtime + delete that.data.form.createtime + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - paste() { - var _this = this; - wx.getClipboardData({ - success: function (res) { - var longitude = 'form.longitude'; - var latitude = 'form.latitude'; - var longitude84 = 'form.longitude84'; - var latitude84 = 'form.latitude84'; - _this.setData({ - [longitude]: parseFloat(res.data.split(",", 4)[1]).toFixed(6), - [latitude]: parseFloat(res.data.split(",", 4)[0]).toFixed(6), - [longitude84]: "" == (res.data.split(",", 4)[3]) ? "" : parseFloat(res.data.split(",", 4)[3]).toFixed(6), - [latitude84]: "" == (res.data.split(",", 4)[2]) ? "" : parseFloat(res.data.split(",", 4)[2]).toFixed(6), - longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), - latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), - }); - } - }) - }, - selectValue(value) { - var that = this; - var wellType = 'form.welltype'; - that.setData({ - [wellType]: value.detail - }) - }, - selectpersonValue(event) { - var that = this; - var installPerson = 'form.installperson'; - that.setData({ - [installPerson]: event.detail - }) - }, - selectprojectValue(event) { - var that = this; - var project = 'form.project'; - that.setData({ - [project]: event.detail, - showMask: true - }) - }, - open() { - this.setData({ - showMask: true - }) - }, - close() { - this.setData({ - showMask: false - }) - }, - afterRead(event) { - var _this = this; - const { - file - } = event.detail; - const { - fileList = [] - } = _this.data; - var convertpath = ""; - wx.compressImage({ - src: event.detail.file.path, - quality: 25, - success: function (res) { - convertpath = res.tempFilePath; - wx.uploadFile({ - url: app.globalData.httpsUrl + "appDeviceAdd/fileUploadMarker", - filePath:convertpath, - name: 'file', - formData: { - 'text': "编号:" + _this.data.form.devcode + "经度:" + _this.data.form.longitude + "纬度:" + _this.data.form.latitude - }, - header: { - "Content-Type": "multipart/form-data", - 'accept': 'application/json', - }, - success(res) { - if (res.data) { - var url = JSON.parse(res.data); - fileList.push({ - ...file, - url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - }); - _this.setData({ - fileList - }); - } - } + success(res) { + if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + if (res.confirm) { + wx.switchTab({ + url: that.data.pageName }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') } - }) - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // // var base64 = "data:image/png;base64," + wx.getFileSystemManager().readFileSync(convertpath, 'base64'); - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: convertpath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // // wx.cloud.callFunction({ - // // name: 'uploadFile', - // // data: { - // // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // // fileBase64: base64 - // // }, - // // success: function (res) { - // // if (res.result) { - // // fileList.push({ - // // ...file, - // // url: app.globalData.url + "static/" + res.result.data.replace(/\\/g, "/") - // // }); - // // _this.setData({ - // // fileList - // // }); - // // } - // // }, - // // complete: res => { - // // }, - // // }) - // } - // }); + } + }) + } + }, + fail(err) { + wx.showToast({ + title: "提交失败", + }) + } + }) + }, + //报存录入的input信息 + confirm(event) { + var that = this; + var formValue = event.detail.value; + var formName = event.target.dataset.id; + var fromN = 'form.' + [formName]; + that.setData({ + [fromN]: formValue + }) + }, + + //扫码 + scan() { + + wx.scanCode({ + success(res) { + console.log(res) + } + }) + }, + //粘贴经纬度 + paste() { + var _this = this; + wx.getClipboardData({ + success: function (res) { + var longitude = 'form.longitude'; + var latitude = 'form.latitude'; + var longitude84 = 'form.longitude84'; + var latitude84 = 'form.latitude84'; + _this.setData({ + [longitude]: parseFloat(res.data.split(",", 4)[1]).toFixed(6), + [latitude]: parseFloat(res.data.split(",", 4)[0]).toFixed(6), + [longitude84]: "" == (res.data.split(",", 4)[3]) ? "" : parseFloat(res.data.split(",", 4)[3]).toFixed(6), + [latitude84]: "" == (res.data.split(",", 4)[2]) ? "" : parseFloat(res.data.split(",", 4)[2]).toFixed(6), + longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), + latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), + }); + } + }) + }, + selectValue(value) { + var that = this; + var wellType = 'form.welltype'; + that.setData({ + [wellType]: value.detail + }) + }, + //运维人员默认为登录人 + // selectpersonValue(event) { + // var that = this; + // var installPerson = 'form.installperson'; + // that.setData({ + // [installPerson]: event.detail + // }) + // }, + selectprojectValue(event) { + var that = this; + var project = 'form.project'; + that.setData({ + [project]: event.detail, + showMask: true + }) + }, + + open() { + this.setData({ + showMask: true + }) + }, + //隐藏textarea,防止遮挡 + close() { + this.setData({ + showMask: false + }) + }, + //上传照片 + afterRead(event) { + var _this = this; + const { + file + } = event.detail; + const { + fileList = [] + } = _this.data; + var convertpath = ""; + wx.compressImage({ + src: event.detail.file.path, + quality: 25, + success: function (res) { + convertpath = res.tempFilePath; + wx.uploadFile({ + url: app.globalData.httpsUrl + "appDeviceAdd/fileUploadMarker", + filePath: convertpath, + name: 'file', + formData: { + 'text': "编号:" + _this.data.form.devcode + "经度:" + _this.data.form.longitude + "纬度:" + _this.data.form.latitude }, - deletePhoto(event) { - var that = this - var image_index = event.detail.index - var fileList_new = that.data.fileList; - wx.showModal({ - content: '确定删除照片?', - success: function (res) { - if (res.confirm) { - fileList_new.splice(image_index, 1); - that.setData({ - fileList: fileList_new - }) - wx.cloud.callFunction({ - name: 'deletePhoto', - data: { - url: app.globalData.url + "appDeviceLog/deletePhoto", - devcode: that.data.form.devcode, - pathIndex: image_index - }, - success: function (res) {}, - complete: res => {}, - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + "Content-Type": "multipart/form-data", + 'accept': 'application/json', }, - }) \ No newline at end of file + success(res) { + if (res.data) { + var url = JSON.parse(res.data); + fileList.push({ + ...file, + url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") + }); + _this.setData({ + fileList + }); + } + } + }) + } + }) + }, + //删除照片 + deletePhoto(event) { + var that = this + var image_index = event.detail.index + var fileList_new = that.data.fileList; + wx.showModal({ + content: '确定删除照片?', + success: function (res) { + if (res.confirm) { + fileList_new.splice(image_index, 1); + that.setData({ + fileList: fileList_new + }) + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deletePhoto", + data: { + devcode: that.data.form.devcode + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) {} + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } +}) \ No newline at end of file diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.wxml b/miniprogram/pages/addDevicelog/addDeviceLog.wxml index 38620d4..b10cc7d 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.wxml +++ b/miniprogram/pages/addDevicelog/addDeviceLog.wxml @@ -1,15 +1,21 @@ - + + + + + - + - - + + - - + + - + @@ -39,24 +45,25 @@ - - - + + + - + - + + @@ -64,7 +71,7 @@ - + @@ -79,9 +86,9 @@ - + - 保存 + 保存 diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.wxss b/miniprogram/pages/addDevicelog/addDeviceLog.wxss index ee0b75c..08d5fd7 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.wxss +++ b/miniprogram/pages/addDevicelog/addDeviceLog.wxss @@ -24,6 +24,17 @@ display: flex; align-items: center; } +.map-view{ + width: 750rpx; + height: 485rpx; + position: fixed; + top: 0px; + left: 0px; + z-index: 999; +} +.content{ + margin-top: 495rpx; +} .left { width: 210rpx; diff --git a/miniprogram/pages/addFunction/addFunction.js b/miniprogram/pages/addFunction/addFunction.js deleted file mode 100644 index 4966be3..0000000 --- a/miniprogram/pages/addFunction/addFunction.js +++ /dev/null @@ -1,60 +0,0 @@ -// pages/addFunction/addFunction.js - -const code = `// 云函数入口函数 -exports.main = (event, context) => { - console.log(event) - console.log(context) - return { - sum: event.a + event.b - } -}` - -Page({ - - data: { - result: '', - canIUseClipboard: wx.canIUse('setClipboardData'), - }, - - onLoad: function (options) { - - }, - - copyCode: function() { - wx.setClipboardData({ - data: code, - success: function () { - wx.showToast({ - title: '复制成功', - }) - } - }) - }, - - testFunction() { - wx.cloud.callFunction({ - name: 'sum', - data: { - a: 1, - b: 2 - }, - success: res => { - wx.showToast({ - title: '调用成功', - }) - this.setData({ - result: JSON.stringify(res.result) - }) - }, - fail: err => { - wx.showToast({ - icon: 'none', - title: '调用失败', - }) - console.error('[云函数] [sum] 调用失败:', err) - } - }) - }, - -}) - diff --git a/miniprogram/pages/addFunction/addFunction.json b/miniprogram/pages/addFunction/addFunction.json deleted file mode 100644 index a9a50c5..0000000 --- a/miniprogram/pages/addFunction/addFunction.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "navigationBarTitleText": "云函数指引", - "usingComponents": {} -} \ No newline at end of file diff --git a/miniprogram/pages/addFunction/addFunction.wxml b/miniprogram/pages/addFunction/addFunction.wxml deleted file mode 100644 index 3a10626..0000000 --- a/miniprogram/pages/addFunction/addFunction.wxml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - 测试云函数 - - - 期望输出:{"sum":3} - - - 调用结果:{{result}} - - - - - 新增云函数 - 1. 在云函数根目录 cloudfunctions 上右键选择新建云函数,命名为 sum - 2. 在创建的 cloudfunctions/sum/index.js 文件中添加如下代码 - - - 3. 在 cloudfunctions/sum 目录上右键上传并部署 - 4. 点击测试云函数测试 - 5. 打开云开发云函数管理页,选择 sum 云函数 - 6. 查看 sum 的调用日志 - 进阶:可在云函数中使用 wx-server-sdk 操作数据库,文件存储和调用其他云函数,详见文档 - - - diff --git a/miniprogram/pages/addFunction/addFunction.wxss b/miniprogram/pages/addFunction/addFunction.wxss deleted file mode 100644 index 7ac8619..0000000 --- a/miniprogram/pages/addFunction/addFunction.wxss +++ /dev/null @@ -1,3 +0,0 @@ -/* pages/addFunction/addFunction.wxss */ - -@import "../../style/guide.wxss"; \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.js b/miniprogram/pages/applog/applog.js index 0e8c185..189e61f 100644 --- a/miniprogram/pages/applog/applog.js +++ b/miniprogram/pages/applog/applog.js @@ -13,98 +13,25 @@ isSeach: "false", params: {}, total: 0, - show: false + show: false, + delBtnWidth: 100, //删除按钮宽度单位(rpx) + activeIndex: -1, + list_style: '' }, - - touchE: function (e) { - // console.log(e); - var that = this - if (e.changedTouches.length == 1) { - //手指移动结束后触摸点位置的X坐标 - var endX = e.changedTouches[0].clientX; - //触摸开始与结束,手指移动的距离 - var disX = that.data.startX - endX; - var delBtnWidth = that.data.delBtnWidth; - //如果距离小于删除按钮的1/2,不显示删除按钮 - var txtStyle = disX > delBtnWidth / 2 ? "left:-" + delBtnWidth + "rpx" : "left:0rpx"; - - //获取手指触摸的是哪一项 - var index = e.currentTarget.dataset.index; - var list = that.data.deviceloglist; - list[index].txtStyle = txtStyle; - //更新列表的状态 - that.setData({ - deviceloglist: list - }); - } - }, - //手指触摸动作开始 记录起点X坐标 - touchstart: function (e) { - //开始触摸时 重置所有删除 - this.data.deviceloglist.forEach(function (v, i) { - if (v.isTouchMove) //只操作为true的 - v.isTouchMove = false; - }) - this.setData({ - startX: e.changedTouches[0].clientX, - startY: e.changedTouches[0].clientY, - deviceloglist: this.data.deviceloglist - }) - }, - //滑动事件处理 - touchmove: function (e) { - var that = this, - index = e.currentTarget.dataset.index, //当前索引 - startX = that.data.startX, //开始X坐标 - startY = that.data.startY, //开始Y坐标 - touchMoveX = e.changedTouches[0].clientX, //滑动变化坐标 - touchMoveY = e.changedTouches[0].clientY, //滑动变化坐标 - //获取滑动角度 - angle = that.angle({ - X: startX, - Y: startY - }, { - X: touchMoveX, - Y: touchMoveY - }); - that.data.deviceloglist.forEach(function (v, i) { - v.isTouchMove = false - //滑动超过30度角 return - if (Math.abs(angle) > 30) return; - if (i == index) { - if (touchMoveX > startX) //右滑 - v.isTouchMove = false - else //左滑 - v.isTouchMove = true - } - }) - //更新数据 - that.setData({ - deviceloglist: that.data.deviceloglist - }) - }, - /** - * 计算滑动角度 - * @param {Object} start 起点坐标 - * @param {Object} end 终点坐标 - */ - angle: function (start, end) { - var _X = end.X - start.X, - _Y = end.Y - start.Y - //返回角度 /Math.atan()返回数字的反正切值 - return 360 * Math.atan(_Y / _X) / (2 * Math.PI); - }, - /** - * 生命周期函数--监听页面加载var_this=this; - */ onLoad: function (options) { - if (options.params) { this.setData({ params: JSON.parse(options.params), isSeach: "true" }) this.initPages() + }else{ + this.setData({ + show: false + }) + //清空参数,重新加载 + this.clearParams(); + this.initPages(); } }, @@ -116,20 +43,33 @@ }, + //点击tabBar事件 + onTabItemTap(item) { + //隐藏历史显示总记录条数 + this.setData({ + show: false + }) + //清空参数,重新加载 + this.clearParams(); + this.initPages(); + }, + + /** * 生命周期函数--监听页面显示 */ onShow: function (options) { - this.setData({ - show:false - }) - if (this.data.isSeach == "false") { - this.clearParams(); - this.initPages(); - } - this.setData({ - isSeach: "false" - }) + + // this.setData({ + // show: false + // }) + // if (this.data.isSeach == "false") { + // this.clearParams(); + // this.initPages(); + // } + // this.setData({ + // isSeach: "false" + // }) }, /** @@ -167,6 +107,119 @@ }, + + //手指触摸动作开始 记录起点X坐标 + touchstart: function (e) { + //开始触摸时 重置所有删除 + this.data.deviceloglist.forEach(function (v, i) { + if (v.isTouchMove) //只操作为true的 + v.isTouchMove = false; + }) + this.setData({ + startX: e.changedTouches[0].clientX, + startY: e.changedTouches[0].clientY, + deviceloglist: this.data.deviceloglist + }) + }, + + //滑动事件处理 + touchmove: function (e) { + var that = this, + index = e.currentTarget.dataset.index, //当前索引 + startX = that.data.startX, //开始X坐标 + startY = that.data.startY, //开始Y坐标 + touchMoveX = e.changedTouches[0].clientX, //滑动变化坐标 + touchMoveY = e.changedTouches[0].clientY, //滑动变化坐标 + //获取滑动角度 + angle = that.angle({ + X: startX, + Y: startY + }, { + X: touchMoveX, + Y: touchMoveY + }); + that.data.deviceloglist.forEach(function (v, i) { + // v.isTouchMove = false + //滑动超过30度角 return + if (Math.abs(angle) > 30) return; + if (i == index) { + if (touchMoveX > startX) //右滑 + v.isTouchMove = false + else //左滑 + v.isTouchMove = true + } + }) + //更新数据 + that.setData({ + deviceloglist: that.data.deviceloglist + }) + }, + + /** + * 计算滑动角度 + * @param {Object} start 起点坐标 + * @param {Object} end 终点坐标 + */ + angle: function (start, end) { + var _X = end.X - start.X, + _Y = end.Y - start.Y + //返回角度 /Math.atan()返回数字的反正切值 + return 360 * Math.atan(_Y / _X) / (2 * Math.PI); + }, + + //删除事件 + delItem: function (e) { + if(app.globalData.role!='repair'){ + wx.showToast({ + icon: 'none', + title: '无权限删除', + duration:2000 + }) + return false + } + var that = this + wx.showModal({ + content: '是否删除?', + success: function (res) { + if (res.confirm) { + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/delete", + data: { + appDeviceAddId: e.currentTarget.dataset.devid + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if(res.data.code=='200'){ + that.data.deviceloglist.splice(e.currentTarget.dataset.index, 1) + that.setData({ + deviceloglist: that.data.deviceloglist, + total: that.data.deviceloglist.length + }) + wx.showToast({ + title: '删除成功!', + icon: 'none', + duration: 1000 + }) + } + }, + fail(err) { + wx.showToast({ + title: '删除失败!', + icon: 'none', + duration: 2000 + }) + } + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + }, + showLoading: function (message) { if (wx.showLoading) { // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 @@ -199,95 +252,105 @@ deviceloglist: [] }) }, + //查询列表数据 initPages: function () { var that = this + that.setData({ + show: false + }) var offsetValue = that.data.deviceloglist.length % 15 > 0 ? parseInt(that.data.deviceloglist.length / 15) + 2 : parseInt(that.data.deviceloglist.length / 15) + 1 - wx.cloud.callFunction({ - name: 'devicelog', + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/listPage", data: { devcode: that.data.params.devcode, devtype: that.data.params.devtype, installtimeFmt: that.data.params.installtimeFmt, project: that.data.params.project, installPerson: that.data.params.installPerson, - url: app.globalData.url + "appDeviceLog/listPage", limit: 15, offset: offsetValue }, - }).then(res => { - if (res.result.data.rows.length > 0) { - var resultJson = res.result - that.setData({ - deviceloglist: that.data.deviceloglist.concat(resultJson.data.rows) - }) - } else if (that.data.deviceloglist.length > 0) { - that.setData({ - show: true, - total: that.data.deviceloglist.length - }) - wx.showToast({ - title: '数据已全部加载完', - icon: 'none', - duration: 2000 - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.data.rows.length > 0) { + var resultJson = res.data + var listArr = resultJson.data.rows + listArr.forEach(function (v, i) { + listArr[i]['isTouchMove'] = false + }) + that.setData({ + deviceloglist: that.data.deviceloglist.concat(listArr) + }) + } else if (that.data.deviceloglist.length > 0) { + that.setData({ + show: true, + total: that.data.deviceloglist.length + }) + wx.showToast({ + title: '数据已全部加载完', + icon: 'none', + duration: 2000 + }) + } + if (offsetValue == 1 && res.data.data.rows.length < 15) { + that.setData({ + show: true, + total: that.data.deviceloglist.length + }) + } } - if(offsetValue==1&&res.result.data.rows.length<15){ - that.setData({ - show: true, - total: that.data.deviceloglist.length - }) - } - // console.log(res); - }).catch(err => { - console.error(err); }) + }, addDetail: function (event) { - this.showLoading("数据请求中..."); - wx.cloud.callFunction({ - name: 'deviceDetail', + var that = this + that.showLoading("数据请求中..."); + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deviceDetail", data: { devcode: event.target.dataset.devcode, - url: app.globalData.url + "appDeviceLog/deviceDetail", }, - }).then(res => { - this.hideLoading(); - var resultObject = JSON.parse(res.result); - var pageName = '../applog/applog' - if (resultObject.code == 200) { - wx.navigateTo({ - url: '../addDevicelog/addDeviceLog?detail=' + - JSON.stringify(resultObject.data) + "&pageName=" + pageName - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + that.hideLoading(); + // var resultObject = JSON.parse(res.data); + var resultObject = res.data; + var pageName = '../applog/applog' + if (resultObject.code == 200) { + wx.setStorageSync('resultObject', resultObject.data) + wx.navigateTo({ + url: '../addDevicelog/addDeviceLog?detail=' + "&pageName=" + pageName + }) + } + }, + fail(err) { + that.hideLoading(); } - }).catch(err => { - this.hideLoading() }) + }, add: function (event) { - wx.reLaunch({ - url: '../earth/earth?devcode=' + event.target.dataset.devcode - // url: '../earth/earth' + app.globalData.devcode = event.target.dataset.devcode; + wx.switchTab({ + url: '../earth/earth' }) + // wx.reLaunch({ + // url: '../earth/earth?devcode=' + event.target.dataset.devcode + // // url: '../earth/earth' + // }) }, onSearch: function () { + var _this = this wx.navigateTo({ - url: '../searchLog/searchLog' + url: '../searchLog/searchLog?params=' + JSON.stringify(_this.data.params) }) - }, - // initPages: function () { - // wx.cloud.callFunction({ - // name: 'devicelog' - // }).then(res => { - // var that = this; - // var jsonList = JSON.parse(res.result) - // that.setData({ - // deviceloglist: jsonList.data.rows - // }) - // console.log(res); - // }).catch(err => { - // console.error(err); - // }) - // } + } }) \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.wxml b/miniprogram/pages/applog/applog.wxml index e9a2352..2bfd041 100644 --- a/miniprogram/pages/applog/applog.wxml +++ b/miniprogram/pages/applog/applog.wxml @@ -1,54 +1,59 @@ - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {{item.devcode}} {{item.devicetype}} + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + {{item.devcode}} {{item.devicetype}} + + {{item.project}} {{item.installtime}}- {{item.installperson}} - - - - - + + + + + + 删除 - - - + + - 共计:{{total}}台 - + 共计:{{total}}台 + \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.wxss b/miniprogram/pages/applog/applog.wxss index 6d3428b..e6e8983 100644 --- a/miniprogram/pages/applog/applog.wxss +++ b/miniprogram/pages/applog/applog.wxss @@ -22,16 +22,18 @@ position: fixed; width: 100%; top: 0rpx; + z-index: 9999; /* margin-bottom: 100rpx; */ } .log-list { /* height: 100rpx; */ - /* display: flex; */ - + display: flex; + width: 100%; padding: 2px; margin-top: 2px; border-bottom: 1px solid #e5e5e5; + overflow: hidden } @@ -53,23 +55,29 @@ left: 35%; margin: 20rpx } - .del { - width: 90px; + /* display: flex; */ + width: 100rpx; display: flex; flex-direction: column; align-items: center; justify-content: center; - color: #fff; - -webkit-transform: translateX(90px); - transform: translateX(90px); - -webkit-transition: all 0.4s; + /* -webkit-transform: translateX(100rpx); */ + transform: translateX(100rpx); + /* -webkit-transition: all 0.4s; */ transition: all 0.4s; - font-size: 35rpx; + color: #fff; + background-color: #fe3e2f; +} +.logrow{ + width: 100%; + transform: translateX(100rpx); + /* -webkit-transform: translateX(100px); */ + margin-left: -100rpx; } -.touch-move-active .content, +.touch-move-active .logrow, .touch-move-active .del { - -webkit-transform: translateX(0); - transform: translateX(0); +/* -webkit-transform: translateX(0); */ +transform: translateX(0); } \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.js b/miniprogram/pages/deployFunctions/deployFunctions.js deleted file mode 100644 index a76b144..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.js +++ /dev/null @@ -1,66 +0,0 @@ -// pages/deployFunctions/deployFunctions.js -Page({ - - /** - * 页面的初始数据 - */ - data: { - - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - - }, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { - - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - - }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { - - }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { - - } -}) \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.json b/miniprogram/pages/deployFunctions/deployFunctions.json deleted file mode 100644 index 7fbedab..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "navigationBarTitleText": "部署云函数", - "usingComponents": {} -} \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.wxml b/miniprogram/pages/deployFunctions/deployFunctions.wxml deleted file mode 100644 index 462b6b6..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.wxml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - 调用失败 - - - 请检查 login 云函数是否已部署 - - - - - 部署 login 云函数 - 1. 确保已通过工具栏云开发入口开通云开发 - 2. 在 cloudfunctions/login 目录上右键上传并部署 - 3. 回到首页,重新点击获取 openid - - - - diff --git a/miniprogram/pages/deployFunctions/deployFunctions.wxss b/miniprogram/pages/deployFunctions/deployFunctions.wxss deleted file mode 100644 index c8803e6..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.wxss +++ /dev/null @@ -1,7 +0,0 @@ -/* pages/deployFunctions/deployFunctions.wxss */ - -@import "../../style/guide.wxss"; - -.black { - color: black; -} \ No newline at end of file diff --git a/miniprogram/pages/earth/earth.js b/miniprogram/pages/earth/earth.js index ae0d3f3..376a6e2 100644 --- a/miniprogram/pages/earth/earth.js +++ b/miniprogram/pages/earth/earth.js @@ -21,19 +21,12 @@ show: false, enableSsatellite: false, windowWidth: 0, - longitude: 113.324520, - latitude: 23.099994, - longitude84: 113.324520, - latitude84: 23.099994, - markers: [{ - id: 0, - iconPath: "../../images/locat.png", - latitude: 23.099994, - longitude: 113.324520, - width: 50, - height: 50 - }], - controls: [], + longitude: "116.627340", + latitude: "39.874390", + longitude84: "", + latitude84: "", + markers: [], + controls: [] }, /** @@ -41,39 +34,13 @@ */ onLoad: function (options) { var that = this; - //获取当前坐标(gcj02) - wx.getLocation({ - type: "gcj02", - altitude: true, - success: function (res) { - that.setData({ - latitude: parseFloat(res.latitude).toFixed(6), - longitude: parseFloat(res.longitude).toFixed(6), - // markers: [{ - // latitude: res.latitude, - // longitude: res.longitude, - // }] - }) - //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 - wx.getLocation({ - type: "wgs84", - altitude: true, - success: function (res) { - that.setData({ - latitude84: parseFloat(res.latitude).toFixed(6), - longitude84: parseFloat(res.longitude).toFixed(6) - }) - } - }) - } - }), - - //设置地图组件 - wx.getSystemInfo({ + //设置地图组件 + wx.getSystemInfo({ success(res) { var windowWidth = res.windowWidth var windowHeight = res.windowHeight var query = wx.createSelectorQuery() + var platform =res.platform query.select('#map').boundingClientRect() query.exec(function (res) { that.setData({ @@ -139,10 +106,20 @@ clickable: true }, { id: 7, - iconPath: '../../images/locat.png', + iconPath: '../../images/applocat.png', position: { - left: res[0].width/2, - top: res[0].height/2, + left: res[0].width / 2 - 20, + top: platform=="ios"?res[0].height / 2 - 80:res[0].height / 2 - 40, + width: 40, + height: 40 + }, + clickable: true + }, { + id: 8, + iconPath: '../../images/back.png', + position: { + left: windowWidth - 40, + top: windowHeight - 140, width: 30, height: 30 }, @@ -150,71 +127,15 @@ }] }) }) - + } - }), + }) + // 实例化API核心类 qqmapsdk = new QQMapWX({ key: 'BGPBZ-C5O3P-ROUDR-LWC4J-63EKH-V5FRX' }) - - if (options.devcode) { - var that = this - var devcode = options.devcode - wx.cloud.callFunction({ - name: 'findListByCodes', - data: { - devcodes: devcode, - url: app.globalData.url + "appDeviceAdd/findListByCodes" - }, - }).then(res => { - if (res.result.code == 200) { - var listResultData = res.result.data; - that.setData({ - listData: listResultData - }) - var markersArr = that.data.markers; - for (var i = 0; i < listResultData.length; i++) { - markersArr = markersArr.concat({ - iconPath: "../../images/locat.png", - id: listResultData[i].id, - callout: { - content: listResultData[i].devcode, - fontSize: '14', - // padding: true, - color: '#00000', - borderColor: '#F4EA2A', - bgColor: '#F4EA2A', - borderWidth: 5, - display: 'ALWAYS', - textAlign: 'center', - // borderRadius: 15 - }, - latitude: listResultData[i].latitude, - longitude: listResultData[i].longitude, - width: 40, - height: 40 - }); - } - this.setData({ - markers: markersArr, - latitude: listResultData[0].latitude, - longitude: listResultData[0].longitude, - marker_latitude: listResultData[0].latitude, - marker_longitude: listResultData[0].longitude, - title: listResultData[0].devcode - }) - } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "无法获取设备地理信息!", - icon: 'none', - duration: 2000 - }) - }) - } }, /** @@ -228,6 +149,97 @@ * 生命周期函数--监听页面显示 */ onShow: function () { + //输入设备编号获取marker位置信息 + var that = this; + if ( app.globalData.devcode!="") { + var devcode = app.globalData.devcode + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/findListByCodes", + data: { + devcodes: devcode, + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + app.globalData.devcode=""; + if (res.data.code == 200) { + var listResultData = res.data.data; + that.setData({ + listData: listResultData + }) + var markersArr = that.data.markers; + for (var i = 0; i < listResultData.length; i++) { + markersArr = markersArr.concat({ + iconPath: "../../images/locat.png", + id: Number(listResultData[i].id), + callout: { + content: "编号:"+listResultData[i].devcode+"\r\n位置:"+listResultData[i].position+"\r\n时间:"+listResultData[i].createtime, + fontSize: '14', + padding: true, + color: '#000000', + borderColor: '#F4EA2A', + bgColor: '#F4EA2A', + borderWidth: 5, + display: 'ALWAYS', + textAlign: 'left', + // borderRadius: 15 + }, + latitude: listResultData[i].latitude, + longitude: listResultData[i].longitude, + width: 40, + height: 40 + }); + } + that.setData({ + markers: markersArr, + latitude: listResultData[0].latitude, + longitude: listResultData[0].longitude, + marker_latitude: listResultData[0].latitude, + marker_longitude: listResultData[0].longitude, + title: listResultData[0].devcode + }) + } + }, + fail(err) { + app.globalData.devcode=""; + wx.showToast({ + title: "无法获取设备地理信息!", + icon: 'none', + duration: 2000 + }) + } + }) +} else { + //获取当前坐标(gcj02) + wx.getLocation({ + type: "gcj02", + altitude: true, + success: function (res) { + that.setData({ + latitude: parseFloat(res.latitude).toFixed(6), + longitude: parseFloat(res.longitude).toFixed(6), + // markers: [{ + // latitude: res.latitude, + // longitude: res.longitude, + // }] + }) + //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 + wx.getLocation({ + type: "wgs84", + altitude: true, + success: function (res) { + that.setData({ + latitude84: parseFloat(res.latitude).toFixed(6), + longitude84: parseFloat(res.longitude).toFixed(6) + }) + } + }) + } + }) +} + }, @@ -265,12 +277,46 @@ onShareAppMessage: function () { }, + + //定位出来 + + locationPosition: function () { + var that = this; + //获取当前坐标(gcj02) + wx.getLocation({ + type: "gcj02", + altitude: true, + success: function (res) { + that.setData({ + latitude: parseFloat(res.latitude).toFixed(6), + longitude: parseFloat(res.longitude).toFixed(6), + // markers: [{ + // latitude: res.latitude, + // longitude: res.longitude + // }] + }) + //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 + wx.getLocation({ + type: "wgs84", + altitude: true, + success: function (res) { + that.setData({ + latitude84: parseFloat(res.latitude).toFixed(6), + longitude84: parseFloat(res.longitude).toFixed(6) + }) + } + }) + } + }) + }, + + //加载地图组件 controltap: function (e) { // console.log(e.controlId); //进入添加设备页 if (1 == e.controlId) { wx.setClipboardData({ - data: this.data.latitude + "," + this.data.longitude+ "," + this.data.latitude84+ "," + this.data.longitude84, + data: this.data.latitude + "," + this.data.longitude + "," + this.data.latitude84 + "," + this.data.longitude84, success: function (res) { wx.getClipboardData({ success: function (res) { @@ -282,6 +328,17 @@ } }) } else if (3 == e.controlId) { + //先定位 + // this.locationPosition() + wx.setClipboardData({ + data: this.data.latitude + "," + this.data.longitude + "," + this.data.latitude84 + "," + this.data.longitude84, + success: function (res) { + wx.showToast({ + title: '坐标已获取', + duration: 1000 + }) + } + }) wx.navigateTo({ url: '../addDevice/addDevice' }) @@ -302,32 +359,15 @@ enableSsatellite: !flag }); } else if (6 == e.controlId) { - var that = this; - //获取当前坐标(gcj02) - wx.getLocation({ - type: "gcj02", - altitude: true, - success: function (res) { - that.setData({ - latitude: parseFloat(res.latitude).toFixed(6), - longitude:parseFloat(res.longitude).toFixed(6), - // markers: [{ - // latitude: res.latitude, - // longitude: res.longitude - // }] - }) - //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 - wx.getLocation({ - type: "wgs84", - altitude: true, - success: function (res) { - that.setData({ - latitude84: parseFloat(res.latitude).toFixed(6), - longitude84: parseFloat(res.longitude).toFixed(6) - }) - } - }) - } + //先清marker + this.setData({ + markers: [] + }) + this.locationPosition() + }else if (8 == e.controlId) { + //跳转日志缓存页 + wx.switchTab({ + url: '../applog/applog', }) } }, @@ -343,63 +383,68 @@ }); }, + //获取设备maker leave() { var that = this; if (that.data.devcodes == "") { return false; } - wx.cloud.callFunction({ - name: 'findListByCodes', + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/findListByCodes", data: { - devcodes: that.data.devcodes, - url: app.globalData.url + "appDeviceAdd/findListByCodes" + devcodes: that.data.devcodes }, - }).then(res => { - if (res.result.code == 200) { - var listResultData = res.result.data; - that.setData({ - listData: listResultData - }) - var markersArr = that.data.markers; - for (var i = 0; i < listResultData.length; i++) { - markersArr = markersArr.concat({ - iconPath: "../../images/locat.png", - id: listResultData[i].id, - callout: { - content: listResultData[i].devcode, - fontSize: '14', - // padding: true, - color: '', - borderColor: '#F4EA2A', - bgColor: '#F4EA2A', - borderWidth: 5, - display: 'ALWAYS', - textAlign: 'center', - // borderRadius: 15 - }, - latitude: listResultData[i].latitude, - longitude: listResultData[i].longitude, - width: 40, - height: 40 - }); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var listResultData = res.data.data; + that.setData({ + listData: listResultData + }) + var markersArr = that.data.markers; + for (var i = 0; i < listResultData.length; i++) { + markersArr = markersArr.concat({ + iconPath: "../../images/locat.png", + id: listResultData[i].id, + callout: { + content: "编号:"+listResultData[i].devcode+"\r\n位置:"+listResultData[i].position+"\r\n时间:"+listResultData[i].createtime, + fontSize: '14', + // padding: true, + color: '#212121', + borderColor: '#F4EA2A', + bgColor: '#F4EA2A', + borderWidth: 5, + display: 'ALWAYS', + textAlign: 'left', + // borderRadius: 15 + }, + latitude: listResultData[i].latitude, + longitude: listResultData[i].longitude, + width: 40, + height: 40 + }); + } + that.setData({ + markers: markersArr, + latitude: listResultData[0].latitude, + longitude: listResultData[0].longitude, + marker_latitude: listResultData[0].latitude, + marker_longitude: listResultData[0].longitude, + title: listResultData[0].devcode + }) } - this.setData({ - markers: markersArr, - latitude: listResultData[0].latitude, - longitude: listResultData[0].longitude, - marker_latitude: listResultData[0].latitude, - marker_longitude: listResultData[0].longitude, - title: listResultData[0].devcode + }, + fail(err) { + wx.showToast({ + title: "无法获取设备地理信息!", + icon: 'none', + duration: 2000 }) } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "无法获取设备地理信息!", - icon: 'none', - duration: 2000 - }) }) }, @@ -422,6 +467,8 @@ } }, + + bindregionchange: function (e) { var that = this if (e.causedBy == "drag") { @@ -445,8 +492,8 @@ that.setData({ latitude: parseFloat(latitude).toFixed(6), longitude: parseFloat(longitude).toFixed(6), - latitude84:"", - longitude84:"", + latitude84: "", + longitude84: "", // markers: markersArr }) // mapCtx.moveToLocation(); @@ -465,16 +512,19 @@ qqmapsdk.search({ keyword: this.data.value, success: function (res) { + console.log(res) if (res && res.data) { _this.setData({ isShow: true, tips: res.data }); } + }, + complete: function (res){ + console.log(res); } }) }, - bindSearch: function (e) { var location = e.target.dataset.location; this.setData({ diff --git a/miniprogram/pages/earth/earth.wxml b/miniprogram/pages/earth/earth.wxml index a0db6ef..87474f8 100644 --- a/miniprogram/pages/earth/earth.wxml +++ b/miniprogram/pages/earth/earth.wxml @@ -1,9 +1,10 @@ + - + {{item.title}} {{item.address}} @@ -17,6 +18,6 @@ + placeholder="请输入定位设备编号用换行隔开" autosize border="{{ false }}" /> \ No newline at end of file diff --git a/miniprogram/pages/indexapp/indexapp.js b/miniprogram/pages/indexapp/indexapp.js index 5063372..849dbdb 100644 --- a/miniprogram/pages/indexapp/indexapp.js +++ b/miniprogram/pages/indexapp/indexapp.js @@ -7,9 +7,8 @@ */ data: { - count:1, - show: false, - onshow:true, + count: 1, + onshow: true, value: "", deviceloglist: [], devcode: "", @@ -21,6 +20,7 @@ // iconPath: "../../images/point.png", latitude: 23.099994, longitude: 113.324520, + label:'1', width: 50, height: 50 }], @@ -31,62 +31,26 @@ * 生命周期函数--监听页面加载 */ onLoad: function (options) { - + }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { - + }, /** * 生命周期函数--监听页面显示 */ onShow: function () { - // if( app.globalData.indexCount>1){ - // this.setData({ - // show:false - // }) - // }else{ - // this.showNotice() - // } - if(app.globalData.indexCount==1){ - this.setData({ - show:true - }) - this.showNotice() - } - app.globalData.indexCount+=1 - if(this.data.onshow){ + if (this.data.onshow) { this.initPages(); } }, - - showNotice: function() { - var that = this - var times = 0 - var i = setInterval(function() { - times++ - if (times >= 15) { - that.setData({ - show:false - }) - wx.showTabBar({ - animation: false, - }) - clearInterval(i) - } else { - wx.hideTabBar({ - animation: false, - }) - } - }, 1000) -}, - /** * 生命周期函数--监听页面隐藏 */ @@ -122,16 +86,27 @@ }, jump: function (event) { - var that = this; var latitude = event.target.dataset.pointLat; var longitude = event.target.dataset.pointLon; + let devcode = event.target.dataset.pointCode; that.setData({ latitude: latitude, longitude: longitude, markers: [{ latitude: latitude, - longitude: longitude + longitude: longitude, + callout: { + display:'ALWAYS',// 常显气泡 + content: devcode, //名称文本 + color: '#fff', //文本颜色 + borderRadius: 5, //边框圆角 + borderWidth: 1, //边框宽度 + borderColor: '#0060ff', //边框颜色 + bgColor: '#0060ff', //背景色 + padding: 5, //文本边缘留白 + textAlign: 'center' //文本对齐方式。有效值: left, right, center + } }] }) }, @@ -142,7 +117,7 @@ var devcode = res.result _this.setData({ devcode: devcode, - onshow:false + onshow: false }); _this.searchlogs(devcode) } @@ -151,40 +126,11 @@ onSearch: function (event) { this.setData({ - devcode:event.detail + devcode: event.detail }) this.searchlogs(event.detail) }, - - // bindregionchange: function (e) { - // var that = this - // if (e.causedBy == "drag") { - // var mapCtx = wx.createMapContext("map") - // mapCtx.getCenterLocation({ - // success: function (res) { - // var markersArr = that.data.markers - // for (var i = 0; i < markersArr.length; i++) { - // if (markersArr[i].iconPath == undefined) { - // markersArr.splice(i, 1) - // } - // } - // var latitude = res.latitude - // var longitude = res.longitude - // markersArr = markersArr.concat({ - // latitude: latitude, - // longitude: longitude - // }) - // that.setData({ - // latitude: latitude, - // longitude: longitude, - // markers: markersArr - // }) - // } - // }) - // } - // }, - showLoading: function (message) { if (wx.showLoading) { // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 @@ -211,81 +157,89 @@ } }, + //加载设备运维详细信息 toDetail: function (event) { - this.showLoading("数据加载中...") - wx.cloud.callFunction({ - name: 'deviceDetail', + var that = this + that.showLoading("数据加载中...") + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deviceDetail", data: { devcode: event.target.dataset.devcode, - url: app.globalData.url + "appDeviceLog/deviceDetail", }, - }).then(res => { - this.hideLoading(); - var resultObject = JSON.parse(res.result); - var pageName='../indexapp/indexapp' - if (resultObject.code == 200) { - wx.navigateTo({ - url: '../addDevicelog/addDeviceLog?detail=' + - JSON.stringify(resultObject.data)+'&pageName='+pageName - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + that.hideLoading(); + var resultObject = res.data; + var pageName = '../indexapp/indexapp' + if (resultObject.code == 200) { + wx.setStorageSync('resultObject', resultObject.data) + wx.navigateTo({ + url: '../addDevicelog/addDeviceLog?detail=' +'&pageName=' + pageName + }) + } + }, + fail(err){ + that.hideLoading(); } - }).catch(err => { - this.hideLoading(); }) }, + //加载列表 getlogs: function (devcode) { var that = this - wx.cloud.callFunction({ - name: 'devicelog', + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/listPage", data: { devcode: devcode, - url: app.globalData.url + "appDeviceLog/listPage", limit: 100, offset: that.data.deviceloglist.length % 100 > 0 ? parseInt(that.data.deviceloglist.length / 100) + 2 : parseInt(that.data.deviceloglist.length / 100) + 1 }, - }).then(res => { - if (res.result) { - // var resultJson = JSON.parse(res.result) - var resultJson = res.result - that.setData({ - deviceloglist: that.data.deviceloglist.concat(resultJson.data.rows) - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + // var resultJson = JSON.parse(res.result) + var resultJson = res.data + that.setData({ + deviceloglist: that.data.deviceloglist.concat(resultJson.data.rows) + }) + } } - console.log(res); - }).catch(err => { - console.error(err); }) }, + //查询列表 searchlogs: function (devcode) { var that = this - wx.cloud.callFunction({ - name: 'devicelog', + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/listPage", data: { devcode: devcode, - url: app.globalData.url + "appDeviceLog/listPage", limit: 100, offset: 1 }, - }).then(res => { - if (res.result) { - var resultJson = res.result - that.setData({ - deviceloglist: resultJson.data.rows, - onshow:true - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var resultJson = res.data + that.setData({ + deviceloglist: resultJson.data.rows, + onshow: true + }) + } } - console.log(res); - }).catch(err => { - console.error(err); }) }, initPages: function () { var that = this; - that.setData({ - devcode: "" - }); wx.getLocation({ type: "gcj02", success: function (res) { @@ -302,6 +256,6 @@ }) } }) - this.searchlogs() + this.data.devcode !== '' ? this.searchlogs(this.data.devcode) : this.searchlogs() }, }) \ No newline at end of file diff --git a/miniprogram/pages/indexapp/indexapp.wxml b/miniprogram/pages/indexapp/indexapp.wxml index 69322a0..f65b082 100644 --- a/miniprogram/pages/indexapp/indexapp.wxml +++ b/miniprogram/pages/indexapp/indexapp.wxml @@ -1,8 +1,12 @@ + + + + - @@ -32,9 +36,15 @@ - + + + + + + + @@ -46,14 +56,14 @@ - + - - + diff --git a/miniprogram/pages/indexapp/indexapp.wxss b/miniprogram/pages/indexapp/indexapp.wxss index b18706a..fc27fcb 100644 --- a/miniprogram/pages/indexapp/indexapp.wxss +++ b/miniprogram/pages/indexapp/indexapp.wxss @@ -128,6 +128,7 @@ .noticeClass{ height: 2300rpx; width: 750rpx; + overflow-y:hidden; } @@ -148,14 +149,14 @@ } +/* .vanstyle{ + button: not([size='mini']) { + user agent stylesheetmin-height: 40px; + width: 650rpx; + margin-left: 20rpx; + margin-right: auto; + + } + +} */ -/* .van-enter-active-class, -.van-leave-active-class { - transition-property: background-color, transform; -} - -.van-enter-class, -.van-leave-to-class { - background-color: red; - transform: rotate(-360deg) translate3d(-100%, -100%, 0); -} */ \ No newline at end of file diff --git a/cloudfunctions/project.config.json b/cloudfunctions/project.config.json new file mode 100644 index 0000000..2b3119a --- /dev/null +++ b/cloudfunctions/project.config.json @@ -0,0 +1,28 @@ +{ + "appid": "wx2cef527a000f87c9", + "compileType": "miniprogram", + "libVersion": "2.27.3", + "packOptions": { + "ignore": [], + "include": [] + }, + "setting": { + "coverView": true, + "es6": true, + "postcss": true, + "minified": true, + "enhance": true, + "showShadowRootInWxmlPanel": true, + "packNpmRelationList": [], + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + } + }, + "condition": {}, + "editorSetting": { + "tabIndent": "insertSpaces", + "tabSize": 4 + } +} \ No newline at end of file diff --git a/cloudfunctions/project.private.config.json b/cloudfunctions/project.private.config.json new file mode 100644 index 0000000..42ff49d --- /dev/null +++ b/cloudfunctions/project.private.config.json @@ -0,0 +1,7 @@ +{ + "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", + "projectname": "cloudfunctions", + "setting": { + "compileHotReLoad": true + } +} \ No newline at end of file diff --git a/miniprogram/app.js b/miniprogram/app.js index 51d56f3..50a8a54 100644 --- a/miniprogram/app.js +++ b/miniprogram/app.js @@ -18,13 +18,15 @@ // this.globalData = {} }, globalData: { - // url: "http://111.198.10.15:11604/", - httpsUrl: "https://logapi.smartlog.work/", - httpsTestUrl: "https://smartlog.work/prodapi4test/", - url: "http://139.198.18.188:8083/", + httpsUrl: "https://logapi.smartlog.work/", + // httpsUrl: "http://139.198.18.188:8083/", // url: "http://127.0.0.1:8083/", - // httpsUrl: "http://127.0.0.1:8083/", + //httpsUrl: "http://127.0.0.1:8083/", openid: null, - indexCount:1 - }, + indexCount:1, + nickName:"", + userName:"", + role:"", + devcode:"" + } }) diff --git a/miniprogram/app.json b/miniprogram/app.json index d23f798..2b6db76 100644 --- a/miniprogram/app.json +++ b/miniprogram/app.json @@ -1,15 +1,17 @@ { "cloud": true, "pages": [ + "pages/login/login", "pages/indexapp/indexapp", "pages/earth/earth", "pages/applog/applog", "pages/addDevice/addDevice", "pages/addDevicelog/addDeviceLog", - "pages/searchLog/searchLog" + "pages/searchLog/searchLog", + "pages/notice/notice" ], "window": { - "backgroundColor": "#F6F6F6", + "backgroundColor": "#E6D480", "backgroundTextStyle": "light", "navigationBarBackgroundColor": "#FFCF00", "navigationBarTitleText": "智慧施工", @@ -46,11 +48,11 @@ "desc": "你的位置信息将用于小程序位置接口的效果展示" } }, + "requiredPrivateInfos": ["getLocation", "chooseLocation"], "networkTimeout": { "request": 30000, "connectSocket": 30000, "uploadFile": 30000, "downloadFile": 30000 - }, - "style": "v2" + } } \ No newline at end of file diff --git a/miniprogram/images/applocat.png b/miniprogram/images/applocat.png new file mode 100644 index 0000000..fe49f54 --- /dev/null +++ b/miniprogram/images/applocat.png Binary files differ diff --git a/miniprogram/images/back.png b/miniprogram/images/back.png new file mode 100644 index 0000000..32ac82d --- /dev/null +++ b/miniprogram/images/back.png Binary files differ diff --git a/miniprogram/images/bottom.png b/miniprogram/images/bottom.png new file mode 100644 index 0000000..d910e98 --- /dev/null +++ b/miniprogram/images/bottom.png Binary files differ diff --git a/miniprogram/images/header.png b/miniprogram/images/header.png new file mode 100644 index 0000000..6ea222e --- /dev/null +++ b/miniprogram/images/header.png Binary files differ diff --git a/miniprogram/images/login.png b/miniprogram/images/login.png index 8b73cc0..6471c46 100644 --- a/miniprogram/images/login.png +++ b/miniprogram/images/login.png Binary files differ diff --git a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss index 5a591fb..c9c35b5 100644 --- a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss +++ b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:100%;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:100%}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file +@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:650rpx;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:600rpx}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file diff --git a/miniprogram/pages/addDevice/addDevice.js b/miniprogram/pages/addDevice/addDevice.js index 2783674..78f00b7 100644 --- a/miniprogram/pages/addDevice/addDevice.js +++ b/miniprogram/pages/addDevice/addDevice.js @@ -1,5 +1,7 @@ // miniprogram/pages/addDevice/addDevice.js // import WxValidate from '../../utils/WxValidate.js' +var QQMapWX = require('../../libs/qqmap-wx-jssdk.js'); +var qqmapsdk; var app = getApp() Page({ @@ -11,32 +13,10 @@ canvasWidth: '', longitude: '', latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], + option1: [], personoption1: [], projectoption: [], + devtypeList:[], show: false, form: { devcode: "", @@ -59,7 +39,10 @@ project: "", area: "", street: "", - wellname: "" + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '', }, fileList: [] }, @@ -117,12 +100,14 @@ var that = this; //初始化表单内容为上次填写值 var cacheForms = wx.getStorageSync('cacheList') - if (cacheForms) { + cacheForms.photopath1='' + cacheForms.photopath2='' + cacheForms.photopath3='' + that.data.fileList=[] that.setData({ form: cacheForms, devcode: cacheForms.devcode, - }) } var form = that.data.form @@ -155,55 +140,89 @@ } }) + +//获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + that.setData({ + option1: welltypeArr + }) + } + } +}) + + //获取人员下拉列表 - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/getUser", + data:{ + tips:'repair' }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data.code == 200) { + var users = res.data.data + var personArr = []; + for (var i = 0; i < users.length; i++) { + var person = { + text: users[i].name, + value: users[i].name + }; + personArr.push(person); + } + that.setData({ + personoption1: personArr + }) } - that.setData({ - personoption1: personArr - }) } - }).catch(err => { - console.error(err); - }) + }) + - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - that.setData({ - projectoption: projectArr - }) + success(res){ + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); + } + that.setData({ + projectoption: projectArr + }) + } } - }).catch(err => { - console.error(err); - }) + }) + var installtime = 'form.installtimeFmt'; var dateNow = this.formatDate(); this.setData({ @@ -211,8 +230,40 @@ installtimeFmt: dateNow, [installtime]: dateNow, }); + + + + /** + * 获取设备类型下拉列表 + */ + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/deviceType", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var TypeList = res.data.data + var typeArr = []; + for (var i = 0; i < TypeList.length; i++) { + var type = { + text: TypeList[i].productName, + value: TypeList[i].productName + }; + typeArr.push(type); + } + that.setData({ + devtypeList: typeArr + }) + } + } + }) }, + + + /** * 生命周期函数--监听页面初次渲染完成 */ @@ -280,29 +331,7 @@ }, - - //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 - drawText: function (ctx, str, leftWidth, initHeight, titleHeight, canvasWidth) { - var lineWidth = 0; - var lastSubStrIndex = 0; //每次开始截取的字符串的索引 - for (let i = 0; i < str.length; i++) { - lineWidth += ctx.measureText(str[i]).width; - if (lineWidth > canvasWidth) { - ctx.fillText(str.substring(lastSubStrIndex, i), leftWidth, initHeight); //绘制截取部分 - initHeight = initHeight + leftWidth * 2; //22为字体的高度 - lineWidth = 0; - lastSubStrIndex = i; - // titleHeight += 40; - } - if (i == str.length - 1) { //绘制剩余部分 - ctx.fillText(str.substring(lastSubStrIndex, i + 1), leftWidth, initHeight); - } - } - // // 标题border-bottom 线距顶部距离 - // titleHeight = titleHeight + 10; - // return titleHeight - }, - + //验证表单 formValidate() { if (this.data.form.devcode == "") { @@ -312,27 +341,20 @@ }) return false } - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } if (this.data.form.wellcode == "") { wx.showToast({ icon: 'none', @@ -348,22 +370,10 @@ }) return false } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null) { + + if (this.data.form.installperson == "") { wx.showToast({ icon: 'none', title: '安装人员不能为空!', @@ -408,56 +418,90 @@ } return true; }, + //提交表单 formSubmit: function (event) { + console.log(this.data.form) + //表单参数验证 if (!this.formValidate()) { return false; } var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDevice', + //验证设备编号长度 + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/getDevTypeLength", data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceAdd/add" + code: encodeURI(this.data.form.devicetype) }, - }).then(res => { - if (res.result.code == 500) { - wx.showToast({ - title: '设备编号已安装!', - }) - } else if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - //用于回显 - wx.setStorageSync('cacheList', that.data.form) - //提交成功后提示用户操作 - if (res.confirm) { - wx.switchTab({ - url: '../earth/earth' - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (""==res.data.data ||res.data.data == that.data.form.devcode.length) { + that.saveDevice() + } else { //编号位数不对提示 + wx.showToast({ + icon: 'none', + title: '设备编号位数不对!', + duration: 1000 + }) + return false + } } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "提交失败", - }) }) }, + + //保存设备基本信息 + saveDevice() { + var that = this; + //设置照片路径 + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopathForm = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopathForm]: fileList[i].url.split("static/")[1] + }) + } + //表单提交 + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 500) { + wx.showToast({ + title: '设备编号已安装!', + }) + } else if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + //用于回显 + wx.setStorageSync('cacheList', that.data.form) + //提交成功后提示用户操作 + if (res.confirm) { + wx.switchTab({ + url: '../earth/earth' + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } + }, + fail(err) { + wx.showToast({ + title: '提交失败!', + }) + } + }) + }, + + //input 输入框设置值 confirm(event) { var that = this; var formValue = event.detail.value; @@ -466,8 +510,30 @@ that.setData({ [fromN]: formValue }) + //若输入是设备编号,自动获取设备类型 + if('devcode'==formName){ + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", + data: { + devcode: formValue, + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + that.setData({ + [formDevicetype]: res.data + }); + } + } + }) + } }, + //扫描设备获取编号和设备类型 scan() { var _this = this; wx.scanCode({ @@ -477,23 +543,28 @@ _this.setData({ [formdevcode]: devcode }); - wx.cloud.callFunction({ - name: 'findModeCode', + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", data: { devcode: devcode, - url: app.globalData.url + "appDeviceAdd/findModeCodeByCode" }, - }).then(res => { - if (res.result) { - var formDevicetype = 'form.devicetype' - _this.setData({ - [formDevicetype]: res.result - }); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + _this.setData({ + [formDevicetype]: res.data + }); + } } }) } }) }, + //粘贴经纬度 paste() { var _this = this; wx.getClipboardData({ @@ -510,9 +581,11 @@ longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), }); + _this.showAddress(_this.data.form.longitude,_this.data.form.latitude,_this) } }) }, + //设置经类型 selectValue(value) { var that = this; @@ -521,6 +594,16 @@ [wellType]: value.detail }) }, + + //设置设备类型 + selectDevType(event) { + var that = this; + var devtype = 'form.devicetype'; + that.setData({ + [devtype]: event.detail + }) + }, + //设置运维人员 selectpersonValue(event) { var that = this; var installPerson = 'form.installperson'; @@ -528,6 +611,7 @@ [installPerson]: event.detail }) }, + //设置项目 selectprojectValue(event) { var that = this; var project = 'form.project'; @@ -535,8 +619,41 @@ [project]: event.detail }) }, + showAddress :function(longitude, latitude, self) { + // 实例化腾讯地图API核心类 + qqmapsdk = new QQMapWX({ + key: 'BGPBZ-C5O3P-ROUDR-LWC4J-63EKH-V5FRX'//此处使用你自己申请的key + }) + // 腾讯地图调用接口 + qqmapsdk.reverseGeocoder({ + location: { + latitude: latitude, + longitude: longitude + }, + success: function (res) { + self.setData({ + 'form.area':res.result.address.slice(0,res.result.address.indexOf('区')+1), + 'form.street':res.result.address.slice(res.result.address.indexOf('区')+1) + }) + }, + fail: function (res) { + console.log(res); + }, + complete: function (res) { + } + }); + }, + //上传照片 afterRead(event) { var _this = this; + if (_this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '请先填写设备编号!\r\n否则水印中无编号', + duration: 2000 + }) + return false + } const { file } = event.detail; @@ -576,78 +693,8 @@ }) } }) - // 压缩图片 - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // //获取图片尺寸 - // wx.getImageInfo({ - // src: convertpath, - // success(res) { - // _this.setData({ - // canvasHeight: res.height, - // canvasWidth: res.width - // }) - // var ctx = wx.createCanvasContext('firstCanvas') - - // //将图片src放到cancas内,宽高为图片大小 - // ctx.drawImage(convertpath, 0, 0, res.width, res.height) - // //将声明的时间放入canvas - // ctx.setFontSize(30 * (res.width / 750)) //注意:设置文字大小必须放在填充文字之前,否则不生效 - // ctx.setFillStyle('blue') - // var text = "编号:" + _this.data.form.devcode + "\n经度:" + _this.data.form.longitude + "\n纬度:" + _this.data.form.latitude - // // _this.drawText(ctx,text,20, 70, 5, res.width) - // _this.drawText(ctx, text, 15 * (res.width / 750), 70 * (res.width / 750), 5, res.width) - - // // ctx.fillText(text, 0, 40) - // // ctx.strokeText(_this.data.form.devcode, 0, 30) - // //生成水印图 - // ctx.draw(false, function () { - // wx.canvasToTempFilePath({ - // canvasId: 'firstCanvas', - // success: (res) => { - // wx.compressImage({ - // src: res.tempFilePath, - // quality: 25, - // success: function (res) { - // //上传照片至服务器 - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: res.tempFilePath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // } - // }) - // //// - // } - // }) - // }) - // } - // }) - // } - // }); }, + //删除照片 deletePhoto(event) { var image_index = event.detail.index var fileList_new = this.data.fileList; diff --git a/miniprogram/pages/addDevice/addDevice.wxml b/miniprogram/pages/addDevice/addDevice.wxml index b0977e2..f12c254 100644 --- a/miniprogram/pages/addDevice/addDevice.wxml +++ b/miniprogram/pages/addDevice/addDevice.wxml @@ -5,18 +5,30 @@ - + + + + + + + + + + + + + - - + + - - - + + + @@ -29,13 +41,13 @@ - + - + - + - + @@ -54,8 +66,7 @@ - - + @@ -68,8 +79,8 @@ - - + + - 保存 + 保存 \ No newline at end of file diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.js b/miniprogram/pages/addDevicelog/addDeviceLog.js index cdec71b..a0dc6da 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.js +++ b/miniprogram/pages/addDevicelog/addDeviceLog.js @@ -3,681 +3,665 @@ var app = getApp(); Page({ - /** - * 页面的初始数据 - */ - data: { - pageName: '', - showMask: false, - today: new Date().getTime(), - longitude: '', - latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], - personoption1: [], - projectoption: [], - devcode: "", - deviceMode: "", - installtimeFmt: '', - show: false, - form: { - devcode: "", - wellcode: "", - welltype: "", - welldepth: "", - installheigt: "", - installperson: "", - installtimeFmt: "", - photopath: "", - factory: "", - workmsg: "", - position: "", - description: "", - longitude: "", - latitude: "", - longitude84: "", - latitude84: "", - devicetype: "", - project: "", - area: "", - street: "", - wellname: "" - }, - fileList: [], - detail: "" - }, + /** + * 页面的初始数据 + */ + data: { + pageName: '', + showMask: false, + today: new Date().getTime(), + longitude: '', + latitude: '', + option1: [], + personoption1: [], + projectoption: [], + devcode: "", + deviceMode: "", + installtimeFmt: '', + show: false, + form: { + devcode: "", + wellcode: "", + welltype: "", + welldepth: "", + installheigt: "", + installperson: "", + installtimeFmt: "", + photopath: "", + factory: "", + workmsg: "", + position: "", + description: "", + longitude: "", + latitude: "", + longitude84: "", + latitude84: "", + devicetype: "", + project: "", + area: "", + street: "", + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '' + }, + fileList: [], + detail: "", + markers: [{ + id: 100, + // iconPath: "../../images/point.png", + latitude: '', + longitude: '', + // label:'1', + width: 25, + height: 35 + }], + }, - onDisplay() { - this.setData({ - show: true - }); - }, - onClose() { - this.setData({ - show: false - }); - }, - formatDate() { - var date = new Date(); - // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; - var seperator1 = "-"; - var month = date.getMonth() + 1; - var strDate = date.getDate(); - var hour = date.getHours() - var minute = date.getMinutes() - var second = date.getSeconds() - month = month > 9 ? month : "0" + month; - strDate = strDate > 9 ? strDate : "0" + strDate; - hour = hour > 9 ? hour : "0" + hour; - minute = minute > 9 ? minute : "0" + minute; - second = second > 9 ? second : "0" + second; - var currentdate = - date.getFullYear() + - seperator1 + - month + - seperator1 + - strDate + - " " + - hour + ":" + - minute + ":" + - second; - return currentdate; + onDisplay() { + this.setData({ + show: true + }); + }, + onClose() { + this.setData({ + show: false + }); + }, + formatDate() { + var date = new Date(); + // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; + var seperator1 = "-"; + var month = date.getMonth() + 1; + var strDate = date.getDate(); + var hour = date.getHours() + var minute = date.getMinutes() + var second = date.getSeconds() + month = month > 9 ? month : "0" + month; + strDate = strDate > 9 ? strDate : "0" + strDate; + hour = hour > 9 ? hour : "0" + hour; + minute = minute > 9 ? minute : "0" + minute; + second = second > 9 ? second : "0" + second; + var currentdate = + date.getFullYear() + + seperator1 + + month + + seperator1 + + strDate + + " " + + hour + ":" + + minute + ":" + + second; + return currentdate; - }, - onConfirm(event) { - var installtime = 'form.installtimeFmt'; - this.setData({ - show: false, - installtimeFmt: this.formatDate(event.detail), - [installtime]: this.formatDate(event.detail), - }); - }, + }, + onConfirm(event) { + var installtime = 'form.installtimeFmt'; + this.setData({ + show: false, + installtimeFmt: this.formatDate(event.detail), + [installtime]: this.formatDate(event.detail), + }); + }, - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - var _this = this; - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" - }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); - } - _this.setData({ - personoption1: personArr - }) + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + var _this = this; + _this.setData({ + 'markers[0].latitude': Number(wx.getStorageSync('resultObject').latitude) , + 'markers[0].longitude': Number(wx.getStorageSync('resultObject').longitude), + // 'markers[0].label':'10', + 'markers[0].width': 18, + 'markers[0].id':1, + 'markers[0].height': 30, + latitude:Number(wx.getStorageSync('resultObject').latitude), + longitude:Number(wx.getStorageSync('resultObject').longitude) + }) + //获取人员下拉列表 + // wx.request({ + // method: "POST", + // url: app.globalData.httpsUrl + "deviceType/getUser", + // data:{ + // tips:'repair' + // }, + // header: { + // 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + // }, + // success(res) { + // if (res.data.code == 200) { + // var users = res.data.data + // var personArr = []; + // for (var i = 0; i < users.length; i++) { + // var person = { + // text: users[i].name, + // value: users[i].name + // }; + // personArr.push(person); + // } + // _this.setData({ + // personoption1: personArr + // }) + // } + // } + // }) + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); } - }).catch(err => { - console.error(err); - }) - - - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" - }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - _this.setData({ - projectoption: projectArr - }) - } - }).catch(err => { - console.error(err); - }) - - if (options.pageName) { - this.setData({ - pageName: options.pageName - }) - } - - if (options.detail) { - - var formObject = JSON.parse(options.detail); _this.setData({ - form: formObject, - detail: options.detail + projectoption: projectArr }) - - _this.setData({ - ['form.installperson']: "", - ['form.installtimeFmt']: "", - ['form.workmsg']: "", - ['form.description']: "" - }) - - const { - fileList = [] - } = _this.data; - if (formObject.photopath1 != "") { - var file1 = { - url: app.globalData.url + "static/" + formObject.photopath1 - } - fileList.push(file1) - } - if (formObject.photopath2 != "") { - var file2 = { - url: app.globalData.url + "static/" + formObject.photopath2 - } - fileList.push(file2) - } - if (formObject.photopath3 != "") { - var file3 = { - url: app.globalData.url + "static/" + formObject.photopath3 - } - fileList.push(file3) - } - - _this.setData({ - fileList - }); } - var installtime = 'form.installtimeFmt'; - var dateNow = this.formatDate(); - this.setData({ - installtimeFmt: dateNow, - [installtime]: dateNow, - }); - }, + } + }) - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { + //获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + _this.setData({ + option1: welltypeArr + }) + } + } +}) - }, + //跳转时带入参数返回哪页 + if (options.pageName) { + this.setData({ + pageName: options.pageName + }) + } + //跳转时带入参数设备的安装信息 + if (wx.getStorageSync('resultObject')) { + var formObject = wx.getStorageSync('resultObject') + _this.setData({ + form: formObject, + detail: formObject + }) - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { + _this.setData({ + ['form.installperson']: app.globalData.userName, + ['form.installtimeFmt']: "", + ['form.workmsg']: "", + ['form.description']: "" + }) - }, + const { + fileList = [] + } = _this.data; + if (formObject.photopath1 != "") { + var file1 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath1 + } + fileList.push(file1) + } + if (formObject.photopath2 != "") { + var file2 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath2 + } + fileList.push(file2) + } + if (formObject.photopath3 != "") { + var file3 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath3 + } + fileList.push(file3) + } + _this.setData({ + fileList + }); + } + var installtime = 'form.installtimeFmt'; + var dateNow = this.formatDate(); + this.setData({ + installtimeFmt: dateNow, + [installtime]: dateNow, + }); + }, - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, - }, + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + wx.removeStorageSync('resultObject') + }, - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, - }, + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { + }, - }, + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { + }, - }, + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { + }, - }, + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + }, - /** - * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true - **/ + /** + * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true + **/ - isNumber: function (val) { + isNumber: function (val) { - var regPos = /^[0-9]*$/; //非负浮点数 - var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数 - if (regPos.test(val) || regNeg.test(val)) { - return false; - } else { - return true; - } + var regPos = /^[0-9]*$/; //非负浮点数 + var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数 + if (regPos.test(val) || regNeg.test(val)) { + return false; + } else { + return true; + } - }, + }, - formValidate() { + formValidate() { - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } - if (this.data.form.wellcode == "") { - wx.showToast({ - icon: 'none', - title: '井编号不能为空!', - }) - return false - } - if (this.data.form.devicetype == "") { - wx.showToast({ - icon: 'none', - title: '设备类型不能为空!', - }) - return false - } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + if (this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '设备编号不能为空!', + }) + return false + } + if (this.data.form.wellcode == "") { + wx.showToast({ + icon: 'none', + title: '井编号不能为空!', + }) + return false + } + if (this.data.form.devicetype == "") { + wx.showToast({ + icon: 'none', + title: '设备类型不能为空!', + }) + return false + } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null || - this.data.form.installperson == '') { - wx.showToast({ - icon: 'none', - title: '运维人员不能为空!', - }) - return false - } - if (this.data.form.project == "") { - wx.showToast({ - icon: 'none', - title: '所属项目不能为空!', - }) - return false - } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } + if (this.data.form.installperson == null || + this.data.form.installperson == '') { + wx.showToast({ + icon: 'none', + title: '运维人员不能为空!', + }) + return false + } + if (this.data.form.project == "") { + wx.showToast({ + icon: 'none', + title: '所属项目不能为空!', + }) + return false + } - if (this.data.form.welldepth != null) { - if (this.isNumber(this.data.form.welldepth)) { - wx.showToast({ - icon: 'none', - title: '井深必须为数值!', - }) - return false - } - } - if (this.data.form.installheigt != null) { - if (this.isNumber(this.data.form.installheigt)) { - wx.showToast({ - icon: 'none', - title: '到井口距离必须为数值!', - }) - return false - } - } - - return true; - }, - - changeMsg: function () { - var formNew = this.data.form; - var formOld = JSON.parse(this.data.detail); - var descpNew = ""; - if (formNew.devcode != formOld.devcode) { - descpNew += "修改设备编号,原编号:" + formOld.devcode + ",新编号:" + formNew.devcode + ";" - } - if (formNew.devicetype != formOld.devicetype) { - descpNew += "修改设备类型,原设备类型:" + formOld.devicetype + ",新设备类型:" + formNew.devicetype + ";" - } - if (formNew.area != formOld.area) { - descpNew += "修改区,原区:" + formOld.area + ",新区:" + formNew.area + ";" - } - if (formNew.street != formOld.street) { - descpNew += "修改街道,原街道:" + formOld.street + ",新街道:" + formNew.street + ";" - } - if (formNew.wellname != formOld.wellname) { - descpNew += "修改井名称,原井名称:" + formOld.wellname + ",新井名称:" + formNew.wellname + ";" - } - if (formNew.factory != formOld.factory) { - descpNew += "修改权属单位,原权属单位:" + formOld.factory + ",新权属单位:" + formNew.factory + ";" - } - if (formNew.installheigt != formOld.installheigt) { - descpNew += "修改井口距离,原井口距离:" + formOld.installheigt + ",新井口距离:" + formNew.installheigt + ";" - } - if (formNew.installperson != formOld.installperson) { - descpNew += "修改运维人员,原运维人员:" + formOld.installperson + ",新运维人员:" + formNew.installperson + ";" - } - if (formNew.latitude != formOld.latitude) { - descpNew += "修改纬度,原纬度:" + formOld.latitude + ",新纬度:" + formNew.latitude + ";" - } - if (formNew.longitude != formOld.longitude) { - descpNew += "修改经度,原经度:" + formOld.longitude + ",新经度:" + formNew.longitude + ";" - } - if (formNew.position != formOld.position) { - descpNew += "修改位置描述,原位置:" + formOld.position + ",新位置:" + formNew.position + ";" - } - if (formNew.wellcode != formOld.wellcode) { - descpNew += "修改井编号,原编号:" + formOld.wellcode + ",新编号:" + formNew.wellcode + ";" - } - if (formNew.welldepth != formOld.welldepth) { - descpNew += "修改井深,原井深:" + formOld.welldepth + ",新井深:" + formNew.welldepth + ";" - } - if (formNew.welltype != formOld.welltype) { - descpNew += "修改井类型,原井类型:" + formOld.welltype + ",新井类型:" + formNew.welltype + ";" - } - if (formNew.project != formOld.project) { - descpNew += "修改所属项目,原项目:" + formOld.project + ",新项目:" + formNew.project + ";" - } - if (this.data.photopath1 != formOld.photopath1 || - this.data.photopath2 != formOld.photopath2 || - this.data.photopath3 != formOld.photopath3) { - descpNew += "修改照片;" - } - if ("" != formNew.description) { - descpNew += formNew.description; - } - this.setData({ - ['form.description']: descpNew + if (this.data.form.welldepth != null) { + if (this.isNumber(this.data.form.welldepth)) { + wx.showToast({ + icon: 'none', + title: '井深必须为数值!', }) - }, + return false + } + } + if (this.data.form.installheigt != null) { + if (this.isNumber(this.data.form.installheigt)) { + wx.showToast({ + icon: 'none', + title: '到井口距离必须为数值!', + }) + return false + } + } - formSubmit: function (event) { + return true; + }, - if (!this.formValidate()) { - return false; - } - this.changeMsg(); - var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDeviceLog', - data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceLog/add" - }, - }).then(res => { - // var resultObj=JSON.parse(res.result); - if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - if (res.confirm) { - wx.switchTab({ - url: that.data.pageName - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) - } - }).catch(err => { - console.error(err) - wx.showToast({ - title: "提交失败", - }) - }) - }, - confirm(event) { - var that = this; - var formValue = event.detail.value; - var formName = event.target.dataset.id; - var fromN = 'form.' + [formName]; - that.setData({ - [fromN]: formValue - }) - }, + //获取与上次修改的信息 + changeMsg: function () { + var formNew = this.data.form; + console.log(this.data.detail) + var formOld = JSON.parse(this.data.detail); + var descpNew = ""; + if (formNew.devcode != formOld.devcode) { + descpNew += "修改设备编号,原值:" + formOld.devcode + ",新值:" + formNew.devcode + ";" + } + if (formNew.devicetype != formOld.devicetype) { + descpNew += "修改设备类型,原值:" + formOld.devicetype + ",新值:" + formNew.devicetype + ";" + } + if (formNew.area != formOld.area) { + descpNew += "修改区,原值:" + formOld.area + ",新值:" + formNew.area + ";" + } + if (formNew.street != formOld.street) { + descpNew += "修改街道,原值:" + formOld.street + ",新值:" + formNew.street + ";" + } + if (formNew.wellname != formOld.wellname) { + descpNew += "修改井名称,原值:" + formOld.wellname + ",新值:" + formNew.wellname + ";" + } + if (formNew.factory != formOld.factory) { + descpNew += "修改权属单位,原值:" + formOld.factory + ",新值:" + formNew.factory + ";" + } + if (formNew.installheigt != formOld.installheigt) { + descpNew += "修改井口距离,原值:" + formOld.installheigt + ",新值:" + formNew.installheigt + ";" + } + if (formNew.installperson != formOld.installperson) { + descpNew += "修改运维人员,原值:" + formOld.installperson + ",新值:" + formNew.installperson + ";" + } + if (formNew.latitude != formOld.latitude) { + descpNew += "修改纬度,原值:" + formOld.latitude + ",新值:" + formNew.latitude + ";" + } + if (formNew.longitude != formOld.longitude) { + descpNew += "修改经度,原值:" + formOld.longitude + ",新值:" + formNew.longitude + ";" + } + if (formNew.position != formOld.position) { + descpNew += "修改位置描述,原值:" + formOld.position + ",新值:" + formNew.position + ";" + } + if (formNew.wellcode != formOld.wellcode) { + descpNew += "修改井编号,原值:" + formOld.wellcode + ",新值:" + formNew.wellcode + ";" + } + if (formNew.welldepth != formOld.welldepth) { + descpNew += "修改井深,原值:" + formOld.welldepth + ",新值:" + formNew.welldepth + ";" + } + if (formNew.welltype != formOld.welltype) { + descpNew += "修改井类型,原值:" + formOld.welltype + ",新值:" + formNew.welltype + ";" + } + if (formNew.project != formOld.project) { + descpNew += "修改所属项目,原值:" + formOld.project + ",新值:" + formNew.project + ";" + } + if (this.data.form.photopath1 != formOld.photopath1 || + this.data.form.photopath2 != formOld.photopath2 || + this.data.form.photopath3 != formOld.photopath3) { + descpNew += "修改照片;" + } + if ("" != formNew.description) { + descpNew += formNew.description; + } + this.setData({ + ['form.description']: descpNew + }) + }, - scan() { + //提交表单 + formSubmit: function (event) { - wx.scanCode({ - success(res) { - console.log(res) - } - }) + //表单验证 + if (!this.formValidate()) { + return false; + } + //自动生成修改内容 + this.changeMsg(); + //提交权限限制(只有施工人员能修改) + if(app.globalData.role!='repair'){ + wx.showToast({ + icon: 'none', + title: '无权限修改', + duration:2000 + }) + return false + } + var that = this; + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopath = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopath]: fileList[i].url.split("static/")[1] + }) + } + delete that.data.form.installtime + delete that.data.form.createtime + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - paste() { - var _this = this; - wx.getClipboardData({ - success: function (res) { - var longitude = 'form.longitude'; - var latitude = 'form.latitude'; - var longitude84 = 'form.longitude84'; - var latitude84 = 'form.latitude84'; - _this.setData({ - [longitude]: parseFloat(res.data.split(",", 4)[1]).toFixed(6), - [latitude]: parseFloat(res.data.split(",", 4)[0]).toFixed(6), - [longitude84]: "" == (res.data.split(",", 4)[3]) ? "" : parseFloat(res.data.split(",", 4)[3]).toFixed(6), - [latitude84]: "" == (res.data.split(",", 4)[2]) ? "" : parseFloat(res.data.split(",", 4)[2]).toFixed(6), - longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), - latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), - }); - } - }) - }, - selectValue(value) { - var that = this; - var wellType = 'form.welltype'; - that.setData({ - [wellType]: value.detail - }) - }, - selectpersonValue(event) { - var that = this; - var installPerson = 'form.installperson'; - that.setData({ - [installPerson]: event.detail - }) - }, - selectprojectValue(event) { - var that = this; - var project = 'form.project'; - that.setData({ - [project]: event.detail, - showMask: true - }) - }, - open() { - this.setData({ - showMask: true - }) - }, - close() { - this.setData({ - showMask: false - }) - }, - afterRead(event) { - var _this = this; - const { - file - } = event.detail; - const { - fileList = [] - } = _this.data; - var convertpath = ""; - wx.compressImage({ - src: event.detail.file.path, - quality: 25, - success: function (res) { - convertpath = res.tempFilePath; - wx.uploadFile({ - url: app.globalData.httpsUrl + "appDeviceAdd/fileUploadMarker", - filePath:convertpath, - name: 'file', - formData: { - 'text': "编号:" + _this.data.form.devcode + "经度:" + _this.data.form.longitude + "纬度:" + _this.data.form.latitude - }, - header: { - "Content-Type": "multipart/form-data", - 'accept': 'application/json', - }, - success(res) { - if (res.data) { - var url = JSON.parse(res.data); - fileList.push({ - ...file, - url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - }); - _this.setData({ - fileList - }); - } - } + success(res) { + if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + if (res.confirm) { + wx.switchTab({ + url: that.data.pageName }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') } - }) - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // // var base64 = "data:image/png;base64," + wx.getFileSystemManager().readFileSync(convertpath, 'base64'); - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: convertpath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // // wx.cloud.callFunction({ - // // name: 'uploadFile', - // // data: { - // // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // // fileBase64: base64 - // // }, - // // success: function (res) { - // // if (res.result) { - // // fileList.push({ - // // ...file, - // // url: app.globalData.url + "static/" + res.result.data.replace(/\\/g, "/") - // // }); - // // _this.setData({ - // // fileList - // // }); - // // } - // // }, - // // complete: res => { - // // }, - // // }) - // } - // }); + } + }) + } + }, + fail(err) { + wx.showToast({ + title: "提交失败", + }) + } + }) + }, + //报存录入的input信息 + confirm(event) { + var that = this; + var formValue = event.detail.value; + var formName = event.target.dataset.id; + var fromN = 'form.' + [formName]; + that.setData({ + [fromN]: formValue + }) + }, + + //扫码 + scan() { + + wx.scanCode({ + success(res) { + console.log(res) + } + }) + }, + //粘贴经纬度 + paste() { + var _this = this; + wx.getClipboardData({ + success: function (res) { + var longitude = 'form.longitude'; + var latitude = 'form.latitude'; + var longitude84 = 'form.longitude84'; + var latitude84 = 'form.latitude84'; + _this.setData({ + [longitude]: parseFloat(res.data.split(",", 4)[1]).toFixed(6), + [latitude]: parseFloat(res.data.split(",", 4)[0]).toFixed(6), + [longitude84]: "" == (res.data.split(",", 4)[3]) ? "" : parseFloat(res.data.split(",", 4)[3]).toFixed(6), + [latitude84]: "" == (res.data.split(",", 4)[2]) ? "" : parseFloat(res.data.split(",", 4)[2]).toFixed(6), + longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), + latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), + }); + } + }) + }, + selectValue(value) { + var that = this; + var wellType = 'form.welltype'; + that.setData({ + [wellType]: value.detail + }) + }, + //运维人员默认为登录人 + // selectpersonValue(event) { + // var that = this; + // var installPerson = 'form.installperson'; + // that.setData({ + // [installPerson]: event.detail + // }) + // }, + selectprojectValue(event) { + var that = this; + var project = 'form.project'; + that.setData({ + [project]: event.detail, + showMask: true + }) + }, + + open() { + this.setData({ + showMask: true + }) + }, + //隐藏textarea,防止遮挡 + close() { + this.setData({ + showMask: false + }) + }, + //上传照片 + afterRead(event) { + var _this = this; + const { + file + } = event.detail; + const { + fileList = [] + } = _this.data; + var convertpath = ""; + wx.compressImage({ + src: event.detail.file.path, + quality: 25, + success: function (res) { + convertpath = res.tempFilePath; + wx.uploadFile({ + url: app.globalData.httpsUrl + "appDeviceAdd/fileUploadMarker", + filePath: convertpath, + name: 'file', + formData: { + 'text': "编号:" + _this.data.form.devcode + "经度:" + _this.data.form.longitude + "纬度:" + _this.data.form.latitude }, - deletePhoto(event) { - var that = this - var image_index = event.detail.index - var fileList_new = that.data.fileList; - wx.showModal({ - content: '确定删除照片?', - success: function (res) { - if (res.confirm) { - fileList_new.splice(image_index, 1); - that.setData({ - fileList: fileList_new - }) - wx.cloud.callFunction({ - name: 'deletePhoto', - data: { - url: app.globalData.url + "appDeviceLog/deletePhoto", - devcode: that.data.form.devcode, - pathIndex: image_index - }, - success: function (res) {}, - complete: res => {}, - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + "Content-Type": "multipart/form-data", + 'accept': 'application/json', }, - }) \ No newline at end of file + success(res) { + if (res.data) { + var url = JSON.parse(res.data); + fileList.push({ + ...file, + url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") + }); + _this.setData({ + fileList + }); + } + } + }) + } + }) + }, + //删除照片 + deletePhoto(event) { + var that = this + var image_index = event.detail.index + var fileList_new = that.data.fileList; + wx.showModal({ + content: '确定删除照片?', + success: function (res) { + if (res.confirm) { + fileList_new.splice(image_index, 1); + that.setData({ + fileList: fileList_new + }) + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deletePhoto", + data: { + devcode: that.data.form.devcode + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) {} + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } +}) \ No newline at end of file diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.wxml b/miniprogram/pages/addDevicelog/addDeviceLog.wxml index 38620d4..b10cc7d 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.wxml +++ b/miniprogram/pages/addDevicelog/addDeviceLog.wxml @@ -1,15 +1,21 @@ - + + + + + - + - - + + - - + + - + @@ -39,24 +45,25 @@ - - - + + + - + - + + @@ -64,7 +71,7 @@ - + @@ -79,9 +86,9 @@ - + - 保存 + 保存 diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.wxss b/miniprogram/pages/addDevicelog/addDeviceLog.wxss index ee0b75c..08d5fd7 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.wxss +++ b/miniprogram/pages/addDevicelog/addDeviceLog.wxss @@ -24,6 +24,17 @@ display: flex; align-items: center; } +.map-view{ + width: 750rpx; + height: 485rpx; + position: fixed; + top: 0px; + left: 0px; + z-index: 999; +} +.content{ + margin-top: 495rpx; +} .left { width: 210rpx; diff --git a/miniprogram/pages/addFunction/addFunction.js b/miniprogram/pages/addFunction/addFunction.js deleted file mode 100644 index 4966be3..0000000 --- a/miniprogram/pages/addFunction/addFunction.js +++ /dev/null @@ -1,60 +0,0 @@ -// pages/addFunction/addFunction.js - -const code = `// 云函数入口函数 -exports.main = (event, context) => { - console.log(event) - console.log(context) - return { - sum: event.a + event.b - } -}` - -Page({ - - data: { - result: '', - canIUseClipboard: wx.canIUse('setClipboardData'), - }, - - onLoad: function (options) { - - }, - - copyCode: function() { - wx.setClipboardData({ - data: code, - success: function () { - wx.showToast({ - title: '复制成功', - }) - } - }) - }, - - testFunction() { - wx.cloud.callFunction({ - name: 'sum', - data: { - a: 1, - b: 2 - }, - success: res => { - wx.showToast({ - title: '调用成功', - }) - this.setData({ - result: JSON.stringify(res.result) - }) - }, - fail: err => { - wx.showToast({ - icon: 'none', - title: '调用失败', - }) - console.error('[云函数] [sum] 调用失败:', err) - } - }) - }, - -}) - diff --git a/miniprogram/pages/addFunction/addFunction.json b/miniprogram/pages/addFunction/addFunction.json deleted file mode 100644 index a9a50c5..0000000 --- a/miniprogram/pages/addFunction/addFunction.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "navigationBarTitleText": "云函数指引", - "usingComponents": {} -} \ No newline at end of file diff --git a/miniprogram/pages/addFunction/addFunction.wxml b/miniprogram/pages/addFunction/addFunction.wxml deleted file mode 100644 index 3a10626..0000000 --- a/miniprogram/pages/addFunction/addFunction.wxml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - 测试云函数 - - - 期望输出:{"sum":3} - - - 调用结果:{{result}} - - - - - 新增云函数 - 1. 在云函数根目录 cloudfunctions 上右键选择新建云函数,命名为 sum - 2. 在创建的 cloudfunctions/sum/index.js 文件中添加如下代码 - - - 3. 在 cloudfunctions/sum 目录上右键上传并部署 - 4. 点击测试云函数测试 - 5. 打开云开发云函数管理页,选择 sum 云函数 - 6. 查看 sum 的调用日志 - 进阶:可在云函数中使用 wx-server-sdk 操作数据库,文件存储和调用其他云函数,详见文档 - - - diff --git a/miniprogram/pages/addFunction/addFunction.wxss b/miniprogram/pages/addFunction/addFunction.wxss deleted file mode 100644 index 7ac8619..0000000 --- a/miniprogram/pages/addFunction/addFunction.wxss +++ /dev/null @@ -1,3 +0,0 @@ -/* pages/addFunction/addFunction.wxss */ - -@import "../../style/guide.wxss"; \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.js b/miniprogram/pages/applog/applog.js index 0e8c185..189e61f 100644 --- a/miniprogram/pages/applog/applog.js +++ b/miniprogram/pages/applog/applog.js @@ -13,98 +13,25 @@ isSeach: "false", params: {}, total: 0, - show: false + show: false, + delBtnWidth: 100, //删除按钮宽度单位(rpx) + activeIndex: -1, + list_style: '' }, - - touchE: function (e) { - // console.log(e); - var that = this - if (e.changedTouches.length == 1) { - //手指移动结束后触摸点位置的X坐标 - var endX = e.changedTouches[0].clientX; - //触摸开始与结束,手指移动的距离 - var disX = that.data.startX - endX; - var delBtnWidth = that.data.delBtnWidth; - //如果距离小于删除按钮的1/2,不显示删除按钮 - var txtStyle = disX > delBtnWidth / 2 ? "left:-" + delBtnWidth + "rpx" : "left:0rpx"; - - //获取手指触摸的是哪一项 - var index = e.currentTarget.dataset.index; - var list = that.data.deviceloglist; - list[index].txtStyle = txtStyle; - //更新列表的状态 - that.setData({ - deviceloglist: list - }); - } - }, - //手指触摸动作开始 记录起点X坐标 - touchstart: function (e) { - //开始触摸时 重置所有删除 - this.data.deviceloglist.forEach(function (v, i) { - if (v.isTouchMove) //只操作为true的 - v.isTouchMove = false; - }) - this.setData({ - startX: e.changedTouches[0].clientX, - startY: e.changedTouches[0].clientY, - deviceloglist: this.data.deviceloglist - }) - }, - //滑动事件处理 - touchmove: function (e) { - var that = this, - index = e.currentTarget.dataset.index, //当前索引 - startX = that.data.startX, //开始X坐标 - startY = that.data.startY, //开始Y坐标 - touchMoveX = e.changedTouches[0].clientX, //滑动变化坐标 - touchMoveY = e.changedTouches[0].clientY, //滑动变化坐标 - //获取滑动角度 - angle = that.angle({ - X: startX, - Y: startY - }, { - X: touchMoveX, - Y: touchMoveY - }); - that.data.deviceloglist.forEach(function (v, i) { - v.isTouchMove = false - //滑动超过30度角 return - if (Math.abs(angle) > 30) return; - if (i == index) { - if (touchMoveX > startX) //右滑 - v.isTouchMove = false - else //左滑 - v.isTouchMove = true - } - }) - //更新数据 - that.setData({ - deviceloglist: that.data.deviceloglist - }) - }, - /** - * 计算滑动角度 - * @param {Object} start 起点坐标 - * @param {Object} end 终点坐标 - */ - angle: function (start, end) { - var _X = end.X - start.X, - _Y = end.Y - start.Y - //返回角度 /Math.atan()返回数字的反正切值 - return 360 * Math.atan(_Y / _X) / (2 * Math.PI); - }, - /** - * 生命周期函数--监听页面加载var_this=this; - */ onLoad: function (options) { - if (options.params) { this.setData({ params: JSON.parse(options.params), isSeach: "true" }) this.initPages() + }else{ + this.setData({ + show: false + }) + //清空参数,重新加载 + this.clearParams(); + this.initPages(); } }, @@ -116,20 +43,33 @@ }, + //点击tabBar事件 + onTabItemTap(item) { + //隐藏历史显示总记录条数 + this.setData({ + show: false + }) + //清空参数,重新加载 + this.clearParams(); + this.initPages(); + }, + + /** * 生命周期函数--监听页面显示 */ onShow: function (options) { - this.setData({ - show:false - }) - if (this.data.isSeach == "false") { - this.clearParams(); - this.initPages(); - } - this.setData({ - isSeach: "false" - }) + + // this.setData({ + // show: false + // }) + // if (this.data.isSeach == "false") { + // this.clearParams(); + // this.initPages(); + // } + // this.setData({ + // isSeach: "false" + // }) }, /** @@ -167,6 +107,119 @@ }, + + //手指触摸动作开始 记录起点X坐标 + touchstart: function (e) { + //开始触摸时 重置所有删除 + this.data.deviceloglist.forEach(function (v, i) { + if (v.isTouchMove) //只操作为true的 + v.isTouchMove = false; + }) + this.setData({ + startX: e.changedTouches[0].clientX, + startY: e.changedTouches[0].clientY, + deviceloglist: this.data.deviceloglist + }) + }, + + //滑动事件处理 + touchmove: function (e) { + var that = this, + index = e.currentTarget.dataset.index, //当前索引 + startX = that.data.startX, //开始X坐标 + startY = that.data.startY, //开始Y坐标 + touchMoveX = e.changedTouches[0].clientX, //滑动变化坐标 + touchMoveY = e.changedTouches[0].clientY, //滑动变化坐标 + //获取滑动角度 + angle = that.angle({ + X: startX, + Y: startY + }, { + X: touchMoveX, + Y: touchMoveY + }); + that.data.deviceloglist.forEach(function (v, i) { + // v.isTouchMove = false + //滑动超过30度角 return + if (Math.abs(angle) > 30) return; + if (i == index) { + if (touchMoveX > startX) //右滑 + v.isTouchMove = false + else //左滑 + v.isTouchMove = true + } + }) + //更新数据 + that.setData({ + deviceloglist: that.data.deviceloglist + }) + }, + + /** + * 计算滑动角度 + * @param {Object} start 起点坐标 + * @param {Object} end 终点坐标 + */ + angle: function (start, end) { + var _X = end.X - start.X, + _Y = end.Y - start.Y + //返回角度 /Math.atan()返回数字的反正切值 + return 360 * Math.atan(_Y / _X) / (2 * Math.PI); + }, + + //删除事件 + delItem: function (e) { + if(app.globalData.role!='repair'){ + wx.showToast({ + icon: 'none', + title: '无权限删除', + duration:2000 + }) + return false + } + var that = this + wx.showModal({ + content: '是否删除?', + success: function (res) { + if (res.confirm) { + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/delete", + data: { + appDeviceAddId: e.currentTarget.dataset.devid + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if(res.data.code=='200'){ + that.data.deviceloglist.splice(e.currentTarget.dataset.index, 1) + that.setData({ + deviceloglist: that.data.deviceloglist, + total: that.data.deviceloglist.length + }) + wx.showToast({ + title: '删除成功!', + icon: 'none', + duration: 1000 + }) + } + }, + fail(err) { + wx.showToast({ + title: '删除失败!', + icon: 'none', + duration: 2000 + }) + } + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + }, + showLoading: function (message) { if (wx.showLoading) { // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 @@ -199,95 +252,105 @@ deviceloglist: [] }) }, + //查询列表数据 initPages: function () { var that = this + that.setData({ + show: false + }) var offsetValue = that.data.deviceloglist.length % 15 > 0 ? parseInt(that.data.deviceloglist.length / 15) + 2 : parseInt(that.data.deviceloglist.length / 15) + 1 - wx.cloud.callFunction({ - name: 'devicelog', + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/listPage", data: { devcode: that.data.params.devcode, devtype: that.data.params.devtype, installtimeFmt: that.data.params.installtimeFmt, project: that.data.params.project, installPerson: that.data.params.installPerson, - url: app.globalData.url + "appDeviceLog/listPage", limit: 15, offset: offsetValue }, - }).then(res => { - if (res.result.data.rows.length > 0) { - var resultJson = res.result - that.setData({ - deviceloglist: that.data.deviceloglist.concat(resultJson.data.rows) - }) - } else if (that.data.deviceloglist.length > 0) { - that.setData({ - show: true, - total: that.data.deviceloglist.length - }) - wx.showToast({ - title: '数据已全部加载完', - icon: 'none', - duration: 2000 - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.data.rows.length > 0) { + var resultJson = res.data + var listArr = resultJson.data.rows + listArr.forEach(function (v, i) { + listArr[i]['isTouchMove'] = false + }) + that.setData({ + deviceloglist: that.data.deviceloglist.concat(listArr) + }) + } else if (that.data.deviceloglist.length > 0) { + that.setData({ + show: true, + total: that.data.deviceloglist.length + }) + wx.showToast({ + title: '数据已全部加载完', + icon: 'none', + duration: 2000 + }) + } + if (offsetValue == 1 && res.data.data.rows.length < 15) { + that.setData({ + show: true, + total: that.data.deviceloglist.length + }) + } } - if(offsetValue==1&&res.result.data.rows.length<15){ - that.setData({ - show: true, - total: that.data.deviceloglist.length - }) - } - // console.log(res); - }).catch(err => { - console.error(err); }) + }, addDetail: function (event) { - this.showLoading("数据请求中..."); - wx.cloud.callFunction({ - name: 'deviceDetail', + var that = this + that.showLoading("数据请求中..."); + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deviceDetail", data: { devcode: event.target.dataset.devcode, - url: app.globalData.url + "appDeviceLog/deviceDetail", }, - }).then(res => { - this.hideLoading(); - var resultObject = JSON.parse(res.result); - var pageName = '../applog/applog' - if (resultObject.code == 200) { - wx.navigateTo({ - url: '../addDevicelog/addDeviceLog?detail=' + - JSON.stringify(resultObject.data) + "&pageName=" + pageName - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + that.hideLoading(); + // var resultObject = JSON.parse(res.data); + var resultObject = res.data; + var pageName = '../applog/applog' + if (resultObject.code == 200) { + wx.setStorageSync('resultObject', resultObject.data) + wx.navigateTo({ + url: '../addDevicelog/addDeviceLog?detail=' + "&pageName=" + pageName + }) + } + }, + fail(err) { + that.hideLoading(); } - }).catch(err => { - this.hideLoading() }) + }, add: function (event) { - wx.reLaunch({ - url: '../earth/earth?devcode=' + event.target.dataset.devcode - // url: '../earth/earth' + app.globalData.devcode = event.target.dataset.devcode; + wx.switchTab({ + url: '../earth/earth' }) + // wx.reLaunch({ + // url: '../earth/earth?devcode=' + event.target.dataset.devcode + // // url: '../earth/earth' + // }) }, onSearch: function () { + var _this = this wx.navigateTo({ - url: '../searchLog/searchLog' + url: '../searchLog/searchLog?params=' + JSON.stringify(_this.data.params) }) - }, - // initPages: function () { - // wx.cloud.callFunction({ - // name: 'devicelog' - // }).then(res => { - // var that = this; - // var jsonList = JSON.parse(res.result) - // that.setData({ - // deviceloglist: jsonList.data.rows - // }) - // console.log(res); - // }).catch(err => { - // console.error(err); - // }) - // } + } }) \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.wxml b/miniprogram/pages/applog/applog.wxml index e9a2352..2bfd041 100644 --- a/miniprogram/pages/applog/applog.wxml +++ b/miniprogram/pages/applog/applog.wxml @@ -1,54 +1,59 @@ - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {{item.devcode}} {{item.devicetype}} + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + {{item.devcode}} {{item.devicetype}} + + {{item.project}} {{item.installtime}}- {{item.installperson}} - - - - - + + + + + + 删除 - - - + + - 共计:{{total}}台 - + 共计:{{total}}台 + \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.wxss b/miniprogram/pages/applog/applog.wxss index 6d3428b..e6e8983 100644 --- a/miniprogram/pages/applog/applog.wxss +++ b/miniprogram/pages/applog/applog.wxss @@ -22,16 +22,18 @@ position: fixed; width: 100%; top: 0rpx; + z-index: 9999; /* margin-bottom: 100rpx; */ } .log-list { /* height: 100rpx; */ - /* display: flex; */ - + display: flex; + width: 100%; padding: 2px; margin-top: 2px; border-bottom: 1px solid #e5e5e5; + overflow: hidden } @@ -53,23 +55,29 @@ left: 35%; margin: 20rpx } - .del { - width: 90px; + /* display: flex; */ + width: 100rpx; display: flex; flex-direction: column; align-items: center; justify-content: center; - color: #fff; - -webkit-transform: translateX(90px); - transform: translateX(90px); - -webkit-transition: all 0.4s; + /* -webkit-transform: translateX(100rpx); */ + transform: translateX(100rpx); + /* -webkit-transition: all 0.4s; */ transition: all 0.4s; - font-size: 35rpx; + color: #fff; + background-color: #fe3e2f; +} +.logrow{ + width: 100%; + transform: translateX(100rpx); + /* -webkit-transform: translateX(100px); */ + margin-left: -100rpx; } -.touch-move-active .content, +.touch-move-active .logrow, .touch-move-active .del { - -webkit-transform: translateX(0); - transform: translateX(0); +/* -webkit-transform: translateX(0); */ +transform: translateX(0); } \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.js b/miniprogram/pages/deployFunctions/deployFunctions.js deleted file mode 100644 index a76b144..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.js +++ /dev/null @@ -1,66 +0,0 @@ -// pages/deployFunctions/deployFunctions.js -Page({ - - /** - * 页面的初始数据 - */ - data: { - - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - - }, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { - - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - - }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { - - }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { - - } -}) \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.json b/miniprogram/pages/deployFunctions/deployFunctions.json deleted file mode 100644 index 7fbedab..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "navigationBarTitleText": "部署云函数", - "usingComponents": {} -} \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.wxml b/miniprogram/pages/deployFunctions/deployFunctions.wxml deleted file mode 100644 index 462b6b6..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.wxml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - 调用失败 - - - 请检查 login 云函数是否已部署 - - - - - 部署 login 云函数 - 1. 确保已通过工具栏云开发入口开通云开发 - 2. 在 cloudfunctions/login 目录上右键上传并部署 - 3. 回到首页,重新点击获取 openid - - - - diff --git a/miniprogram/pages/deployFunctions/deployFunctions.wxss b/miniprogram/pages/deployFunctions/deployFunctions.wxss deleted file mode 100644 index c8803e6..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.wxss +++ /dev/null @@ -1,7 +0,0 @@ -/* pages/deployFunctions/deployFunctions.wxss */ - -@import "../../style/guide.wxss"; - -.black { - color: black; -} \ No newline at end of file diff --git a/miniprogram/pages/earth/earth.js b/miniprogram/pages/earth/earth.js index ae0d3f3..376a6e2 100644 --- a/miniprogram/pages/earth/earth.js +++ b/miniprogram/pages/earth/earth.js @@ -21,19 +21,12 @@ show: false, enableSsatellite: false, windowWidth: 0, - longitude: 113.324520, - latitude: 23.099994, - longitude84: 113.324520, - latitude84: 23.099994, - markers: [{ - id: 0, - iconPath: "../../images/locat.png", - latitude: 23.099994, - longitude: 113.324520, - width: 50, - height: 50 - }], - controls: [], + longitude: "116.627340", + latitude: "39.874390", + longitude84: "", + latitude84: "", + markers: [], + controls: [] }, /** @@ -41,39 +34,13 @@ */ onLoad: function (options) { var that = this; - //获取当前坐标(gcj02) - wx.getLocation({ - type: "gcj02", - altitude: true, - success: function (res) { - that.setData({ - latitude: parseFloat(res.latitude).toFixed(6), - longitude: parseFloat(res.longitude).toFixed(6), - // markers: [{ - // latitude: res.latitude, - // longitude: res.longitude, - // }] - }) - //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 - wx.getLocation({ - type: "wgs84", - altitude: true, - success: function (res) { - that.setData({ - latitude84: parseFloat(res.latitude).toFixed(6), - longitude84: parseFloat(res.longitude).toFixed(6) - }) - } - }) - } - }), - - //设置地图组件 - wx.getSystemInfo({ + //设置地图组件 + wx.getSystemInfo({ success(res) { var windowWidth = res.windowWidth var windowHeight = res.windowHeight var query = wx.createSelectorQuery() + var platform =res.platform query.select('#map').boundingClientRect() query.exec(function (res) { that.setData({ @@ -139,10 +106,20 @@ clickable: true }, { id: 7, - iconPath: '../../images/locat.png', + iconPath: '../../images/applocat.png', position: { - left: res[0].width/2, - top: res[0].height/2, + left: res[0].width / 2 - 20, + top: platform=="ios"?res[0].height / 2 - 80:res[0].height / 2 - 40, + width: 40, + height: 40 + }, + clickable: true + }, { + id: 8, + iconPath: '../../images/back.png', + position: { + left: windowWidth - 40, + top: windowHeight - 140, width: 30, height: 30 }, @@ -150,71 +127,15 @@ }] }) }) - + } - }), + }) + // 实例化API核心类 qqmapsdk = new QQMapWX({ key: 'BGPBZ-C5O3P-ROUDR-LWC4J-63EKH-V5FRX' }) - - if (options.devcode) { - var that = this - var devcode = options.devcode - wx.cloud.callFunction({ - name: 'findListByCodes', - data: { - devcodes: devcode, - url: app.globalData.url + "appDeviceAdd/findListByCodes" - }, - }).then(res => { - if (res.result.code == 200) { - var listResultData = res.result.data; - that.setData({ - listData: listResultData - }) - var markersArr = that.data.markers; - for (var i = 0; i < listResultData.length; i++) { - markersArr = markersArr.concat({ - iconPath: "../../images/locat.png", - id: listResultData[i].id, - callout: { - content: listResultData[i].devcode, - fontSize: '14', - // padding: true, - color: '#00000', - borderColor: '#F4EA2A', - bgColor: '#F4EA2A', - borderWidth: 5, - display: 'ALWAYS', - textAlign: 'center', - // borderRadius: 15 - }, - latitude: listResultData[i].latitude, - longitude: listResultData[i].longitude, - width: 40, - height: 40 - }); - } - this.setData({ - markers: markersArr, - latitude: listResultData[0].latitude, - longitude: listResultData[0].longitude, - marker_latitude: listResultData[0].latitude, - marker_longitude: listResultData[0].longitude, - title: listResultData[0].devcode - }) - } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "无法获取设备地理信息!", - icon: 'none', - duration: 2000 - }) - }) - } }, /** @@ -228,6 +149,97 @@ * 生命周期函数--监听页面显示 */ onShow: function () { + //输入设备编号获取marker位置信息 + var that = this; + if ( app.globalData.devcode!="") { + var devcode = app.globalData.devcode + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/findListByCodes", + data: { + devcodes: devcode, + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + app.globalData.devcode=""; + if (res.data.code == 200) { + var listResultData = res.data.data; + that.setData({ + listData: listResultData + }) + var markersArr = that.data.markers; + for (var i = 0; i < listResultData.length; i++) { + markersArr = markersArr.concat({ + iconPath: "../../images/locat.png", + id: Number(listResultData[i].id), + callout: { + content: "编号:"+listResultData[i].devcode+"\r\n位置:"+listResultData[i].position+"\r\n时间:"+listResultData[i].createtime, + fontSize: '14', + padding: true, + color: '#000000', + borderColor: '#F4EA2A', + bgColor: '#F4EA2A', + borderWidth: 5, + display: 'ALWAYS', + textAlign: 'left', + // borderRadius: 15 + }, + latitude: listResultData[i].latitude, + longitude: listResultData[i].longitude, + width: 40, + height: 40 + }); + } + that.setData({ + markers: markersArr, + latitude: listResultData[0].latitude, + longitude: listResultData[0].longitude, + marker_latitude: listResultData[0].latitude, + marker_longitude: listResultData[0].longitude, + title: listResultData[0].devcode + }) + } + }, + fail(err) { + app.globalData.devcode=""; + wx.showToast({ + title: "无法获取设备地理信息!", + icon: 'none', + duration: 2000 + }) + } + }) +} else { + //获取当前坐标(gcj02) + wx.getLocation({ + type: "gcj02", + altitude: true, + success: function (res) { + that.setData({ + latitude: parseFloat(res.latitude).toFixed(6), + longitude: parseFloat(res.longitude).toFixed(6), + // markers: [{ + // latitude: res.latitude, + // longitude: res.longitude, + // }] + }) + //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 + wx.getLocation({ + type: "wgs84", + altitude: true, + success: function (res) { + that.setData({ + latitude84: parseFloat(res.latitude).toFixed(6), + longitude84: parseFloat(res.longitude).toFixed(6) + }) + } + }) + } + }) +} + }, @@ -265,12 +277,46 @@ onShareAppMessage: function () { }, + + //定位出来 + + locationPosition: function () { + var that = this; + //获取当前坐标(gcj02) + wx.getLocation({ + type: "gcj02", + altitude: true, + success: function (res) { + that.setData({ + latitude: parseFloat(res.latitude).toFixed(6), + longitude: parseFloat(res.longitude).toFixed(6), + // markers: [{ + // latitude: res.latitude, + // longitude: res.longitude + // }] + }) + //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 + wx.getLocation({ + type: "wgs84", + altitude: true, + success: function (res) { + that.setData({ + latitude84: parseFloat(res.latitude).toFixed(6), + longitude84: parseFloat(res.longitude).toFixed(6) + }) + } + }) + } + }) + }, + + //加载地图组件 controltap: function (e) { // console.log(e.controlId); //进入添加设备页 if (1 == e.controlId) { wx.setClipboardData({ - data: this.data.latitude + "," + this.data.longitude+ "," + this.data.latitude84+ "," + this.data.longitude84, + data: this.data.latitude + "," + this.data.longitude + "," + this.data.latitude84 + "," + this.data.longitude84, success: function (res) { wx.getClipboardData({ success: function (res) { @@ -282,6 +328,17 @@ } }) } else if (3 == e.controlId) { + //先定位 + // this.locationPosition() + wx.setClipboardData({ + data: this.data.latitude + "," + this.data.longitude + "," + this.data.latitude84 + "," + this.data.longitude84, + success: function (res) { + wx.showToast({ + title: '坐标已获取', + duration: 1000 + }) + } + }) wx.navigateTo({ url: '../addDevice/addDevice' }) @@ -302,32 +359,15 @@ enableSsatellite: !flag }); } else if (6 == e.controlId) { - var that = this; - //获取当前坐标(gcj02) - wx.getLocation({ - type: "gcj02", - altitude: true, - success: function (res) { - that.setData({ - latitude: parseFloat(res.latitude).toFixed(6), - longitude:parseFloat(res.longitude).toFixed(6), - // markers: [{ - // latitude: res.latitude, - // longitude: res.longitude - // }] - }) - //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 - wx.getLocation({ - type: "wgs84", - altitude: true, - success: function (res) { - that.setData({ - latitude84: parseFloat(res.latitude).toFixed(6), - longitude84: parseFloat(res.longitude).toFixed(6) - }) - } - }) - } + //先清marker + this.setData({ + markers: [] + }) + this.locationPosition() + }else if (8 == e.controlId) { + //跳转日志缓存页 + wx.switchTab({ + url: '../applog/applog', }) } }, @@ -343,63 +383,68 @@ }); }, + //获取设备maker leave() { var that = this; if (that.data.devcodes == "") { return false; } - wx.cloud.callFunction({ - name: 'findListByCodes', + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/findListByCodes", data: { - devcodes: that.data.devcodes, - url: app.globalData.url + "appDeviceAdd/findListByCodes" + devcodes: that.data.devcodes }, - }).then(res => { - if (res.result.code == 200) { - var listResultData = res.result.data; - that.setData({ - listData: listResultData - }) - var markersArr = that.data.markers; - for (var i = 0; i < listResultData.length; i++) { - markersArr = markersArr.concat({ - iconPath: "../../images/locat.png", - id: listResultData[i].id, - callout: { - content: listResultData[i].devcode, - fontSize: '14', - // padding: true, - color: '', - borderColor: '#F4EA2A', - bgColor: '#F4EA2A', - borderWidth: 5, - display: 'ALWAYS', - textAlign: 'center', - // borderRadius: 15 - }, - latitude: listResultData[i].latitude, - longitude: listResultData[i].longitude, - width: 40, - height: 40 - }); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var listResultData = res.data.data; + that.setData({ + listData: listResultData + }) + var markersArr = that.data.markers; + for (var i = 0; i < listResultData.length; i++) { + markersArr = markersArr.concat({ + iconPath: "../../images/locat.png", + id: listResultData[i].id, + callout: { + content: "编号:"+listResultData[i].devcode+"\r\n位置:"+listResultData[i].position+"\r\n时间:"+listResultData[i].createtime, + fontSize: '14', + // padding: true, + color: '#212121', + borderColor: '#F4EA2A', + bgColor: '#F4EA2A', + borderWidth: 5, + display: 'ALWAYS', + textAlign: 'left', + // borderRadius: 15 + }, + latitude: listResultData[i].latitude, + longitude: listResultData[i].longitude, + width: 40, + height: 40 + }); + } + that.setData({ + markers: markersArr, + latitude: listResultData[0].latitude, + longitude: listResultData[0].longitude, + marker_latitude: listResultData[0].latitude, + marker_longitude: listResultData[0].longitude, + title: listResultData[0].devcode + }) } - this.setData({ - markers: markersArr, - latitude: listResultData[0].latitude, - longitude: listResultData[0].longitude, - marker_latitude: listResultData[0].latitude, - marker_longitude: listResultData[0].longitude, - title: listResultData[0].devcode + }, + fail(err) { + wx.showToast({ + title: "无法获取设备地理信息!", + icon: 'none', + duration: 2000 }) } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "无法获取设备地理信息!", - icon: 'none', - duration: 2000 - }) }) }, @@ -422,6 +467,8 @@ } }, + + bindregionchange: function (e) { var that = this if (e.causedBy == "drag") { @@ -445,8 +492,8 @@ that.setData({ latitude: parseFloat(latitude).toFixed(6), longitude: parseFloat(longitude).toFixed(6), - latitude84:"", - longitude84:"", + latitude84: "", + longitude84: "", // markers: markersArr }) // mapCtx.moveToLocation(); @@ -465,16 +512,19 @@ qqmapsdk.search({ keyword: this.data.value, success: function (res) { + console.log(res) if (res && res.data) { _this.setData({ isShow: true, tips: res.data }); } + }, + complete: function (res){ + console.log(res); } }) }, - bindSearch: function (e) { var location = e.target.dataset.location; this.setData({ diff --git a/miniprogram/pages/earth/earth.wxml b/miniprogram/pages/earth/earth.wxml index a0db6ef..87474f8 100644 --- a/miniprogram/pages/earth/earth.wxml +++ b/miniprogram/pages/earth/earth.wxml @@ -1,9 +1,10 @@ + - + {{item.title}} {{item.address}} @@ -17,6 +18,6 @@ + placeholder="请输入定位设备编号用换行隔开" autosize border="{{ false }}" /> \ No newline at end of file diff --git a/miniprogram/pages/indexapp/indexapp.js b/miniprogram/pages/indexapp/indexapp.js index 5063372..849dbdb 100644 --- a/miniprogram/pages/indexapp/indexapp.js +++ b/miniprogram/pages/indexapp/indexapp.js @@ -7,9 +7,8 @@ */ data: { - count:1, - show: false, - onshow:true, + count: 1, + onshow: true, value: "", deviceloglist: [], devcode: "", @@ -21,6 +20,7 @@ // iconPath: "../../images/point.png", latitude: 23.099994, longitude: 113.324520, + label:'1', width: 50, height: 50 }], @@ -31,62 +31,26 @@ * 生命周期函数--监听页面加载 */ onLoad: function (options) { - + }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { - + }, /** * 生命周期函数--监听页面显示 */ onShow: function () { - // if( app.globalData.indexCount>1){ - // this.setData({ - // show:false - // }) - // }else{ - // this.showNotice() - // } - if(app.globalData.indexCount==1){ - this.setData({ - show:true - }) - this.showNotice() - } - app.globalData.indexCount+=1 - if(this.data.onshow){ + if (this.data.onshow) { this.initPages(); } }, - - showNotice: function() { - var that = this - var times = 0 - var i = setInterval(function() { - times++ - if (times >= 15) { - that.setData({ - show:false - }) - wx.showTabBar({ - animation: false, - }) - clearInterval(i) - } else { - wx.hideTabBar({ - animation: false, - }) - } - }, 1000) -}, - /** * 生命周期函数--监听页面隐藏 */ @@ -122,16 +86,27 @@ }, jump: function (event) { - var that = this; var latitude = event.target.dataset.pointLat; var longitude = event.target.dataset.pointLon; + let devcode = event.target.dataset.pointCode; that.setData({ latitude: latitude, longitude: longitude, markers: [{ latitude: latitude, - longitude: longitude + longitude: longitude, + callout: { + display:'ALWAYS',// 常显气泡 + content: devcode, //名称文本 + color: '#fff', //文本颜色 + borderRadius: 5, //边框圆角 + borderWidth: 1, //边框宽度 + borderColor: '#0060ff', //边框颜色 + bgColor: '#0060ff', //背景色 + padding: 5, //文本边缘留白 + textAlign: 'center' //文本对齐方式。有效值: left, right, center + } }] }) }, @@ -142,7 +117,7 @@ var devcode = res.result _this.setData({ devcode: devcode, - onshow:false + onshow: false }); _this.searchlogs(devcode) } @@ -151,40 +126,11 @@ onSearch: function (event) { this.setData({ - devcode:event.detail + devcode: event.detail }) this.searchlogs(event.detail) }, - - // bindregionchange: function (e) { - // var that = this - // if (e.causedBy == "drag") { - // var mapCtx = wx.createMapContext("map") - // mapCtx.getCenterLocation({ - // success: function (res) { - // var markersArr = that.data.markers - // for (var i = 0; i < markersArr.length; i++) { - // if (markersArr[i].iconPath == undefined) { - // markersArr.splice(i, 1) - // } - // } - // var latitude = res.latitude - // var longitude = res.longitude - // markersArr = markersArr.concat({ - // latitude: latitude, - // longitude: longitude - // }) - // that.setData({ - // latitude: latitude, - // longitude: longitude, - // markers: markersArr - // }) - // } - // }) - // } - // }, - showLoading: function (message) { if (wx.showLoading) { // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 @@ -211,81 +157,89 @@ } }, + //加载设备运维详细信息 toDetail: function (event) { - this.showLoading("数据加载中...") - wx.cloud.callFunction({ - name: 'deviceDetail', + var that = this + that.showLoading("数据加载中...") + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deviceDetail", data: { devcode: event.target.dataset.devcode, - url: app.globalData.url + "appDeviceLog/deviceDetail", }, - }).then(res => { - this.hideLoading(); - var resultObject = JSON.parse(res.result); - var pageName='../indexapp/indexapp' - if (resultObject.code == 200) { - wx.navigateTo({ - url: '../addDevicelog/addDeviceLog?detail=' + - JSON.stringify(resultObject.data)+'&pageName='+pageName - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + that.hideLoading(); + var resultObject = res.data; + var pageName = '../indexapp/indexapp' + if (resultObject.code == 200) { + wx.setStorageSync('resultObject', resultObject.data) + wx.navigateTo({ + url: '../addDevicelog/addDeviceLog?detail=' +'&pageName=' + pageName + }) + } + }, + fail(err){ + that.hideLoading(); } - }).catch(err => { - this.hideLoading(); }) }, + //加载列表 getlogs: function (devcode) { var that = this - wx.cloud.callFunction({ - name: 'devicelog', + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/listPage", data: { devcode: devcode, - url: app.globalData.url + "appDeviceLog/listPage", limit: 100, offset: that.data.deviceloglist.length % 100 > 0 ? parseInt(that.data.deviceloglist.length / 100) + 2 : parseInt(that.data.deviceloglist.length / 100) + 1 }, - }).then(res => { - if (res.result) { - // var resultJson = JSON.parse(res.result) - var resultJson = res.result - that.setData({ - deviceloglist: that.data.deviceloglist.concat(resultJson.data.rows) - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + // var resultJson = JSON.parse(res.result) + var resultJson = res.data + that.setData({ + deviceloglist: that.data.deviceloglist.concat(resultJson.data.rows) + }) + } } - console.log(res); - }).catch(err => { - console.error(err); }) }, + //查询列表 searchlogs: function (devcode) { var that = this - wx.cloud.callFunction({ - name: 'devicelog', + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/listPage", data: { devcode: devcode, - url: app.globalData.url + "appDeviceLog/listPage", limit: 100, offset: 1 }, - }).then(res => { - if (res.result) { - var resultJson = res.result - that.setData({ - deviceloglist: resultJson.data.rows, - onshow:true - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var resultJson = res.data + that.setData({ + deviceloglist: resultJson.data.rows, + onshow: true + }) + } } - console.log(res); - }).catch(err => { - console.error(err); }) }, initPages: function () { var that = this; - that.setData({ - devcode: "" - }); wx.getLocation({ type: "gcj02", success: function (res) { @@ -302,6 +256,6 @@ }) } }) - this.searchlogs() + this.data.devcode !== '' ? this.searchlogs(this.data.devcode) : this.searchlogs() }, }) \ No newline at end of file diff --git a/miniprogram/pages/indexapp/indexapp.wxml b/miniprogram/pages/indexapp/indexapp.wxml index 69322a0..f65b082 100644 --- a/miniprogram/pages/indexapp/indexapp.wxml +++ b/miniprogram/pages/indexapp/indexapp.wxml @@ -1,8 +1,12 @@ + + + + - @@ -32,9 +36,15 @@ - + + + + + + + @@ -46,14 +56,14 @@ - + - - + diff --git a/miniprogram/pages/indexapp/indexapp.wxss b/miniprogram/pages/indexapp/indexapp.wxss index b18706a..fc27fcb 100644 --- a/miniprogram/pages/indexapp/indexapp.wxss +++ b/miniprogram/pages/indexapp/indexapp.wxss @@ -128,6 +128,7 @@ .noticeClass{ height: 2300rpx; width: 750rpx; + overflow-y:hidden; } @@ -148,14 +149,14 @@ } +/* .vanstyle{ + button: not([size='mini']) { + user agent stylesheetmin-height: 40px; + width: 650rpx; + margin-left: 20rpx; + margin-right: auto; + + } + +} */ -/* .van-enter-active-class, -.van-leave-active-class { - transition-property: background-color, transform; -} - -.van-enter-class, -.van-leave-to-class { - background-color: red; - transform: rotate(-360deg) translate3d(-100%, -100%, 0); -} */ \ No newline at end of file diff --git a/miniprogram/pages/log/log.js b/miniprogram/pages/log/log.js deleted file mode 100644 index 83ba349..0000000 --- a/miniprogram/pages/log/log.js +++ /dev/null @@ -1,66 +0,0 @@ -// pages/log/log.js -Page({ - - /** - * 页面的初始数据 - */ - data: { - - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - - }, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { - - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - - }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { - - }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { - - } -}) \ No newline at end of file diff --git a/cloudfunctions/project.config.json b/cloudfunctions/project.config.json new file mode 100644 index 0000000..2b3119a --- /dev/null +++ b/cloudfunctions/project.config.json @@ -0,0 +1,28 @@ +{ + "appid": "wx2cef527a000f87c9", + "compileType": "miniprogram", + "libVersion": "2.27.3", + "packOptions": { + "ignore": [], + "include": [] + }, + "setting": { + "coverView": true, + "es6": true, + "postcss": true, + "minified": true, + "enhance": true, + "showShadowRootInWxmlPanel": true, + "packNpmRelationList": [], + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + } + }, + "condition": {}, + "editorSetting": { + "tabIndent": "insertSpaces", + "tabSize": 4 + } +} \ No newline at end of file diff --git a/cloudfunctions/project.private.config.json b/cloudfunctions/project.private.config.json new file mode 100644 index 0000000..42ff49d --- /dev/null +++ b/cloudfunctions/project.private.config.json @@ -0,0 +1,7 @@ +{ + "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", + "projectname": "cloudfunctions", + "setting": { + "compileHotReLoad": true + } +} \ No newline at end of file diff --git a/miniprogram/app.js b/miniprogram/app.js index 51d56f3..50a8a54 100644 --- a/miniprogram/app.js +++ b/miniprogram/app.js @@ -18,13 +18,15 @@ // this.globalData = {} }, globalData: { - // url: "http://111.198.10.15:11604/", - httpsUrl: "https://logapi.smartlog.work/", - httpsTestUrl: "https://smartlog.work/prodapi4test/", - url: "http://139.198.18.188:8083/", + httpsUrl: "https://logapi.smartlog.work/", + // httpsUrl: "http://139.198.18.188:8083/", // url: "http://127.0.0.1:8083/", - // httpsUrl: "http://127.0.0.1:8083/", + //httpsUrl: "http://127.0.0.1:8083/", openid: null, - indexCount:1 - }, + indexCount:1, + nickName:"", + userName:"", + role:"", + devcode:"" + } }) diff --git a/miniprogram/app.json b/miniprogram/app.json index d23f798..2b6db76 100644 --- a/miniprogram/app.json +++ b/miniprogram/app.json @@ -1,15 +1,17 @@ { "cloud": true, "pages": [ + "pages/login/login", "pages/indexapp/indexapp", "pages/earth/earth", "pages/applog/applog", "pages/addDevice/addDevice", "pages/addDevicelog/addDeviceLog", - "pages/searchLog/searchLog" + "pages/searchLog/searchLog", + "pages/notice/notice" ], "window": { - "backgroundColor": "#F6F6F6", + "backgroundColor": "#E6D480", "backgroundTextStyle": "light", "navigationBarBackgroundColor": "#FFCF00", "navigationBarTitleText": "智慧施工", @@ -46,11 +48,11 @@ "desc": "你的位置信息将用于小程序位置接口的效果展示" } }, + "requiredPrivateInfos": ["getLocation", "chooseLocation"], "networkTimeout": { "request": 30000, "connectSocket": 30000, "uploadFile": 30000, "downloadFile": 30000 - }, - "style": "v2" + } } \ No newline at end of file diff --git a/miniprogram/images/applocat.png b/miniprogram/images/applocat.png new file mode 100644 index 0000000..fe49f54 --- /dev/null +++ b/miniprogram/images/applocat.png Binary files differ diff --git a/miniprogram/images/back.png b/miniprogram/images/back.png new file mode 100644 index 0000000..32ac82d --- /dev/null +++ b/miniprogram/images/back.png Binary files differ diff --git a/miniprogram/images/bottom.png b/miniprogram/images/bottom.png new file mode 100644 index 0000000..d910e98 --- /dev/null +++ b/miniprogram/images/bottom.png Binary files differ diff --git a/miniprogram/images/header.png b/miniprogram/images/header.png new file mode 100644 index 0000000..6ea222e --- /dev/null +++ b/miniprogram/images/header.png Binary files differ diff --git a/miniprogram/images/login.png b/miniprogram/images/login.png index 8b73cc0..6471c46 100644 --- a/miniprogram/images/login.png +++ b/miniprogram/images/login.png Binary files differ diff --git a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss index 5a591fb..c9c35b5 100644 --- a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss +++ b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:100%;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:100%}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file +@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:650rpx;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:600rpx}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file diff --git a/miniprogram/pages/addDevice/addDevice.js b/miniprogram/pages/addDevice/addDevice.js index 2783674..78f00b7 100644 --- a/miniprogram/pages/addDevice/addDevice.js +++ b/miniprogram/pages/addDevice/addDevice.js @@ -1,5 +1,7 @@ // miniprogram/pages/addDevice/addDevice.js // import WxValidate from '../../utils/WxValidate.js' +var QQMapWX = require('../../libs/qqmap-wx-jssdk.js'); +var qqmapsdk; var app = getApp() Page({ @@ -11,32 +13,10 @@ canvasWidth: '', longitude: '', latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], + option1: [], personoption1: [], projectoption: [], + devtypeList:[], show: false, form: { devcode: "", @@ -59,7 +39,10 @@ project: "", area: "", street: "", - wellname: "" + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '', }, fileList: [] }, @@ -117,12 +100,14 @@ var that = this; //初始化表单内容为上次填写值 var cacheForms = wx.getStorageSync('cacheList') - if (cacheForms) { + cacheForms.photopath1='' + cacheForms.photopath2='' + cacheForms.photopath3='' + that.data.fileList=[] that.setData({ form: cacheForms, devcode: cacheForms.devcode, - }) } var form = that.data.form @@ -155,55 +140,89 @@ } }) + +//获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + that.setData({ + option1: welltypeArr + }) + } + } +}) + + //获取人员下拉列表 - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/getUser", + data:{ + tips:'repair' }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data.code == 200) { + var users = res.data.data + var personArr = []; + for (var i = 0; i < users.length; i++) { + var person = { + text: users[i].name, + value: users[i].name + }; + personArr.push(person); + } + that.setData({ + personoption1: personArr + }) } - that.setData({ - personoption1: personArr - }) } - }).catch(err => { - console.error(err); - }) + }) + - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - that.setData({ - projectoption: projectArr - }) + success(res){ + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); + } + that.setData({ + projectoption: projectArr + }) + } } - }).catch(err => { - console.error(err); - }) + }) + var installtime = 'form.installtimeFmt'; var dateNow = this.formatDate(); this.setData({ @@ -211,8 +230,40 @@ installtimeFmt: dateNow, [installtime]: dateNow, }); + + + + /** + * 获取设备类型下拉列表 + */ + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/deviceType", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var TypeList = res.data.data + var typeArr = []; + for (var i = 0; i < TypeList.length; i++) { + var type = { + text: TypeList[i].productName, + value: TypeList[i].productName + }; + typeArr.push(type); + } + that.setData({ + devtypeList: typeArr + }) + } + } + }) }, + + + /** * 生命周期函数--监听页面初次渲染完成 */ @@ -280,29 +331,7 @@ }, - - //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 - drawText: function (ctx, str, leftWidth, initHeight, titleHeight, canvasWidth) { - var lineWidth = 0; - var lastSubStrIndex = 0; //每次开始截取的字符串的索引 - for (let i = 0; i < str.length; i++) { - lineWidth += ctx.measureText(str[i]).width; - if (lineWidth > canvasWidth) { - ctx.fillText(str.substring(lastSubStrIndex, i), leftWidth, initHeight); //绘制截取部分 - initHeight = initHeight + leftWidth * 2; //22为字体的高度 - lineWidth = 0; - lastSubStrIndex = i; - // titleHeight += 40; - } - if (i == str.length - 1) { //绘制剩余部分 - ctx.fillText(str.substring(lastSubStrIndex, i + 1), leftWidth, initHeight); - } - } - // // 标题border-bottom 线距顶部距离 - // titleHeight = titleHeight + 10; - // return titleHeight - }, - + //验证表单 formValidate() { if (this.data.form.devcode == "") { @@ -312,27 +341,20 @@ }) return false } - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } if (this.data.form.wellcode == "") { wx.showToast({ icon: 'none', @@ -348,22 +370,10 @@ }) return false } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null) { + + if (this.data.form.installperson == "") { wx.showToast({ icon: 'none', title: '安装人员不能为空!', @@ -408,56 +418,90 @@ } return true; }, + //提交表单 formSubmit: function (event) { + console.log(this.data.form) + //表单参数验证 if (!this.formValidate()) { return false; } var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDevice', + //验证设备编号长度 + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/getDevTypeLength", data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceAdd/add" + code: encodeURI(this.data.form.devicetype) }, - }).then(res => { - if (res.result.code == 500) { - wx.showToast({ - title: '设备编号已安装!', - }) - } else if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - //用于回显 - wx.setStorageSync('cacheList', that.data.form) - //提交成功后提示用户操作 - if (res.confirm) { - wx.switchTab({ - url: '../earth/earth' - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (""==res.data.data ||res.data.data == that.data.form.devcode.length) { + that.saveDevice() + } else { //编号位数不对提示 + wx.showToast({ + icon: 'none', + title: '设备编号位数不对!', + duration: 1000 + }) + return false + } } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "提交失败", - }) }) }, + + //保存设备基本信息 + saveDevice() { + var that = this; + //设置照片路径 + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopathForm = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopathForm]: fileList[i].url.split("static/")[1] + }) + } + //表单提交 + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 500) { + wx.showToast({ + title: '设备编号已安装!', + }) + } else if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + //用于回显 + wx.setStorageSync('cacheList', that.data.form) + //提交成功后提示用户操作 + if (res.confirm) { + wx.switchTab({ + url: '../earth/earth' + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } + }, + fail(err) { + wx.showToast({ + title: '提交失败!', + }) + } + }) + }, + + //input 输入框设置值 confirm(event) { var that = this; var formValue = event.detail.value; @@ -466,8 +510,30 @@ that.setData({ [fromN]: formValue }) + //若输入是设备编号,自动获取设备类型 + if('devcode'==formName){ + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", + data: { + devcode: formValue, + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + that.setData({ + [formDevicetype]: res.data + }); + } + } + }) + } }, + //扫描设备获取编号和设备类型 scan() { var _this = this; wx.scanCode({ @@ -477,23 +543,28 @@ _this.setData({ [formdevcode]: devcode }); - wx.cloud.callFunction({ - name: 'findModeCode', + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", data: { devcode: devcode, - url: app.globalData.url + "appDeviceAdd/findModeCodeByCode" }, - }).then(res => { - if (res.result) { - var formDevicetype = 'form.devicetype' - _this.setData({ - [formDevicetype]: res.result - }); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + _this.setData({ + [formDevicetype]: res.data + }); + } } }) } }) }, + //粘贴经纬度 paste() { var _this = this; wx.getClipboardData({ @@ -510,9 +581,11 @@ longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), }); + _this.showAddress(_this.data.form.longitude,_this.data.form.latitude,_this) } }) }, + //设置经类型 selectValue(value) { var that = this; @@ -521,6 +594,16 @@ [wellType]: value.detail }) }, + + //设置设备类型 + selectDevType(event) { + var that = this; + var devtype = 'form.devicetype'; + that.setData({ + [devtype]: event.detail + }) + }, + //设置运维人员 selectpersonValue(event) { var that = this; var installPerson = 'form.installperson'; @@ -528,6 +611,7 @@ [installPerson]: event.detail }) }, + //设置项目 selectprojectValue(event) { var that = this; var project = 'form.project'; @@ -535,8 +619,41 @@ [project]: event.detail }) }, + showAddress :function(longitude, latitude, self) { + // 实例化腾讯地图API核心类 + qqmapsdk = new QQMapWX({ + key: 'BGPBZ-C5O3P-ROUDR-LWC4J-63EKH-V5FRX'//此处使用你自己申请的key + }) + // 腾讯地图调用接口 + qqmapsdk.reverseGeocoder({ + location: { + latitude: latitude, + longitude: longitude + }, + success: function (res) { + self.setData({ + 'form.area':res.result.address.slice(0,res.result.address.indexOf('区')+1), + 'form.street':res.result.address.slice(res.result.address.indexOf('区')+1) + }) + }, + fail: function (res) { + console.log(res); + }, + complete: function (res) { + } + }); + }, + //上传照片 afterRead(event) { var _this = this; + if (_this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '请先填写设备编号!\r\n否则水印中无编号', + duration: 2000 + }) + return false + } const { file } = event.detail; @@ -576,78 +693,8 @@ }) } }) - // 压缩图片 - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // //获取图片尺寸 - // wx.getImageInfo({ - // src: convertpath, - // success(res) { - // _this.setData({ - // canvasHeight: res.height, - // canvasWidth: res.width - // }) - // var ctx = wx.createCanvasContext('firstCanvas') - - // //将图片src放到cancas内,宽高为图片大小 - // ctx.drawImage(convertpath, 0, 0, res.width, res.height) - // //将声明的时间放入canvas - // ctx.setFontSize(30 * (res.width / 750)) //注意:设置文字大小必须放在填充文字之前,否则不生效 - // ctx.setFillStyle('blue') - // var text = "编号:" + _this.data.form.devcode + "\n经度:" + _this.data.form.longitude + "\n纬度:" + _this.data.form.latitude - // // _this.drawText(ctx,text,20, 70, 5, res.width) - // _this.drawText(ctx, text, 15 * (res.width / 750), 70 * (res.width / 750), 5, res.width) - - // // ctx.fillText(text, 0, 40) - // // ctx.strokeText(_this.data.form.devcode, 0, 30) - // //生成水印图 - // ctx.draw(false, function () { - // wx.canvasToTempFilePath({ - // canvasId: 'firstCanvas', - // success: (res) => { - // wx.compressImage({ - // src: res.tempFilePath, - // quality: 25, - // success: function (res) { - // //上传照片至服务器 - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: res.tempFilePath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // } - // }) - // //// - // } - // }) - // }) - // } - // }) - // } - // }); }, + //删除照片 deletePhoto(event) { var image_index = event.detail.index var fileList_new = this.data.fileList; diff --git a/miniprogram/pages/addDevice/addDevice.wxml b/miniprogram/pages/addDevice/addDevice.wxml index b0977e2..f12c254 100644 --- a/miniprogram/pages/addDevice/addDevice.wxml +++ b/miniprogram/pages/addDevice/addDevice.wxml @@ -5,18 +5,30 @@ - + + + + + + + + + + + + + - - + + - - - + + + @@ -29,13 +41,13 @@ - + - + - + - + @@ -54,8 +66,7 @@ - - + @@ -68,8 +79,8 @@ - - + + - 保存 + 保存 \ No newline at end of file diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.js b/miniprogram/pages/addDevicelog/addDeviceLog.js index cdec71b..a0dc6da 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.js +++ b/miniprogram/pages/addDevicelog/addDeviceLog.js @@ -3,681 +3,665 @@ var app = getApp(); Page({ - /** - * 页面的初始数据 - */ - data: { - pageName: '', - showMask: false, - today: new Date().getTime(), - longitude: '', - latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], - personoption1: [], - projectoption: [], - devcode: "", - deviceMode: "", - installtimeFmt: '', - show: false, - form: { - devcode: "", - wellcode: "", - welltype: "", - welldepth: "", - installheigt: "", - installperson: "", - installtimeFmt: "", - photopath: "", - factory: "", - workmsg: "", - position: "", - description: "", - longitude: "", - latitude: "", - longitude84: "", - latitude84: "", - devicetype: "", - project: "", - area: "", - street: "", - wellname: "" - }, - fileList: [], - detail: "" - }, + /** + * 页面的初始数据 + */ + data: { + pageName: '', + showMask: false, + today: new Date().getTime(), + longitude: '', + latitude: '', + option1: [], + personoption1: [], + projectoption: [], + devcode: "", + deviceMode: "", + installtimeFmt: '', + show: false, + form: { + devcode: "", + wellcode: "", + welltype: "", + welldepth: "", + installheigt: "", + installperson: "", + installtimeFmt: "", + photopath: "", + factory: "", + workmsg: "", + position: "", + description: "", + longitude: "", + latitude: "", + longitude84: "", + latitude84: "", + devicetype: "", + project: "", + area: "", + street: "", + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '' + }, + fileList: [], + detail: "", + markers: [{ + id: 100, + // iconPath: "../../images/point.png", + latitude: '', + longitude: '', + // label:'1', + width: 25, + height: 35 + }], + }, - onDisplay() { - this.setData({ - show: true - }); - }, - onClose() { - this.setData({ - show: false - }); - }, - formatDate() { - var date = new Date(); - // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; - var seperator1 = "-"; - var month = date.getMonth() + 1; - var strDate = date.getDate(); - var hour = date.getHours() - var minute = date.getMinutes() - var second = date.getSeconds() - month = month > 9 ? month : "0" + month; - strDate = strDate > 9 ? strDate : "0" + strDate; - hour = hour > 9 ? hour : "0" + hour; - minute = minute > 9 ? minute : "0" + minute; - second = second > 9 ? second : "0" + second; - var currentdate = - date.getFullYear() + - seperator1 + - month + - seperator1 + - strDate + - " " + - hour + ":" + - minute + ":" + - second; - return currentdate; + onDisplay() { + this.setData({ + show: true + }); + }, + onClose() { + this.setData({ + show: false + }); + }, + formatDate() { + var date = new Date(); + // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; + var seperator1 = "-"; + var month = date.getMonth() + 1; + var strDate = date.getDate(); + var hour = date.getHours() + var minute = date.getMinutes() + var second = date.getSeconds() + month = month > 9 ? month : "0" + month; + strDate = strDate > 9 ? strDate : "0" + strDate; + hour = hour > 9 ? hour : "0" + hour; + minute = minute > 9 ? minute : "0" + minute; + second = second > 9 ? second : "0" + second; + var currentdate = + date.getFullYear() + + seperator1 + + month + + seperator1 + + strDate + + " " + + hour + ":" + + minute + ":" + + second; + return currentdate; - }, - onConfirm(event) { - var installtime = 'form.installtimeFmt'; - this.setData({ - show: false, - installtimeFmt: this.formatDate(event.detail), - [installtime]: this.formatDate(event.detail), - }); - }, + }, + onConfirm(event) { + var installtime = 'form.installtimeFmt'; + this.setData({ + show: false, + installtimeFmt: this.formatDate(event.detail), + [installtime]: this.formatDate(event.detail), + }); + }, - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - var _this = this; - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" - }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); - } - _this.setData({ - personoption1: personArr - }) + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + var _this = this; + _this.setData({ + 'markers[0].latitude': Number(wx.getStorageSync('resultObject').latitude) , + 'markers[0].longitude': Number(wx.getStorageSync('resultObject').longitude), + // 'markers[0].label':'10', + 'markers[0].width': 18, + 'markers[0].id':1, + 'markers[0].height': 30, + latitude:Number(wx.getStorageSync('resultObject').latitude), + longitude:Number(wx.getStorageSync('resultObject').longitude) + }) + //获取人员下拉列表 + // wx.request({ + // method: "POST", + // url: app.globalData.httpsUrl + "deviceType/getUser", + // data:{ + // tips:'repair' + // }, + // header: { + // 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + // }, + // success(res) { + // if (res.data.code == 200) { + // var users = res.data.data + // var personArr = []; + // for (var i = 0; i < users.length; i++) { + // var person = { + // text: users[i].name, + // value: users[i].name + // }; + // personArr.push(person); + // } + // _this.setData({ + // personoption1: personArr + // }) + // } + // } + // }) + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); } - }).catch(err => { - console.error(err); - }) - - - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" - }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - _this.setData({ - projectoption: projectArr - }) - } - }).catch(err => { - console.error(err); - }) - - if (options.pageName) { - this.setData({ - pageName: options.pageName - }) - } - - if (options.detail) { - - var formObject = JSON.parse(options.detail); _this.setData({ - form: formObject, - detail: options.detail + projectoption: projectArr }) - - _this.setData({ - ['form.installperson']: "", - ['form.installtimeFmt']: "", - ['form.workmsg']: "", - ['form.description']: "" - }) - - const { - fileList = [] - } = _this.data; - if (formObject.photopath1 != "") { - var file1 = { - url: app.globalData.url + "static/" + formObject.photopath1 - } - fileList.push(file1) - } - if (formObject.photopath2 != "") { - var file2 = { - url: app.globalData.url + "static/" + formObject.photopath2 - } - fileList.push(file2) - } - if (formObject.photopath3 != "") { - var file3 = { - url: app.globalData.url + "static/" + formObject.photopath3 - } - fileList.push(file3) - } - - _this.setData({ - fileList - }); } - var installtime = 'form.installtimeFmt'; - var dateNow = this.formatDate(); - this.setData({ - installtimeFmt: dateNow, - [installtime]: dateNow, - }); - }, + } + }) - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { + //获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + _this.setData({ + option1: welltypeArr + }) + } + } +}) - }, + //跳转时带入参数返回哪页 + if (options.pageName) { + this.setData({ + pageName: options.pageName + }) + } + //跳转时带入参数设备的安装信息 + if (wx.getStorageSync('resultObject')) { + var formObject = wx.getStorageSync('resultObject') + _this.setData({ + form: formObject, + detail: formObject + }) - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { + _this.setData({ + ['form.installperson']: app.globalData.userName, + ['form.installtimeFmt']: "", + ['form.workmsg']: "", + ['form.description']: "" + }) - }, + const { + fileList = [] + } = _this.data; + if (formObject.photopath1 != "") { + var file1 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath1 + } + fileList.push(file1) + } + if (formObject.photopath2 != "") { + var file2 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath2 + } + fileList.push(file2) + } + if (formObject.photopath3 != "") { + var file3 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath3 + } + fileList.push(file3) + } + _this.setData({ + fileList + }); + } + var installtime = 'form.installtimeFmt'; + var dateNow = this.formatDate(); + this.setData({ + installtimeFmt: dateNow, + [installtime]: dateNow, + }); + }, - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, - }, + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + wx.removeStorageSync('resultObject') + }, - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, - }, + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { + }, - }, + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { + }, - }, + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { + }, - }, + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + }, - /** - * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true - **/ + /** + * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true + **/ - isNumber: function (val) { + isNumber: function (val) { - var regPos = /^[0-9]*$/; //非负浮点数 - var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数 - if (regPos.test(val) || regNeg.test(val)) { - return false; - } else { - return true; - } + var regPos = /^[0-9]*$/; //非负浮点数 + var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数 + if (regPos.test(val) || regNeg.test(val)) { + return false; + } else { + return true; + } - }, + }, - formValidate() { + formValidate() { - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } - if (this.data.form.wellcode == "") { - wx.showToast({ - icon: 'none', - title: '井编号不能为空!', - }) - return false - } - if (this.data.form.devicetype == "") { - wx.showToast({ - icon: 'none', - title: '设备类型不能为空!', - }) - return false - } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + if (this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '设备编号不能为空!', + }) + return false + } + if (this.data.form.wellcode == "") { + wx.showToast({ + icon: 'none', + title: '井编号不能为空!', + }) + return false + } + if (this.data.form.devicetype == "") { + wx.showToast({ + icon: 'none', + title: '设备类型不能为空!', + }) + return false + } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null || - this.data.form.installperson == '') { - wx.showToast({ - icon: 'none', - title: '运维人员不能为空!', - }) - return false - } - if (this.data.form.project == "") { - wx.showToast({ - icon: 'none', - title: '所属项目不能为空!', - }) - return false - } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } + if (this.data.form.installperson == null || + this.data.form.installperson == '') { + wx.showToast({ + icon: 'none', + title: '运维人员不能为空!', + }) + return false + } + if (this.data.form.project == "") { + wx.showToast({ + icon: 'none', + title: '所属项目不能为空!', + }) + return false + } - if (this.data.form.welldepth != null) { - if (this.isNumber(this.data.form.welldepth)) { - wx.showToast({ - icon: 'none', - title: '井深必须为数值!', - }) - return false - } - } - if (this.data.form.installheigt != null) { - if (this.isNumber(this.data.form.installheigt)) { - wx.showToast({ - icon: 'none', - title: '到井口距离必须为数值!', - }) - return false - } - } - - return true; - }, - - changeMsg: function () { - var formNew = this.data.form; - var formOld = JSON.parse(this.data.detail); - var descpNew = ""; - if (formNew.devcode != formOld.devcode) { - descpNew += "修改设备编号,原编号:" + formOld.devcode + ",新编号:" + formNew.devcode + ";" - } - if (formNew.devicetype != formOld.devicetype) { - descpNew += "修改设备类型,原设备类型:" + formOld.devicetype + ",新设备类型:" + formNew.devicetype + ";" - } - if (formNew.area != formOld.area) { - descpNew += "修改区,原区:" + formOld.area + ",新区:" + formNew.area + ";" - } - if (formNew.street != formOld.street) { - descpNew += "修改街道,原街道:" + formOld.street + ",新街道:" + formNew.street + ";" - } - if (formNew.wellname != formOld.wellname) { - descpNew += "修改井名称,原井名称:" + formOld.wellname + ",新井名称:" + formNew.wellname + ";" - } - if (formNew.factory != formOld.factory) { - descpNew += "修改权属单位,原权属单位:" + formOld.factory + ",新权属单位:" + formNew.factory + ";" - } - if (formNew.installheigt != formOld.installheigt) { - descpNew += "修改井口距离,原井口距离:" + formOld.installheigt + ",新井口距离:" + formNew.installheigt + ";" - } - if (formNew.installperson != formOld.installperson) { - descpNew += "修改运维人员,原运维人员:" + formOld.installperson + ",新运维人员:" + formNew.installperson + ";" - } - if (formNew.latitude != formOld.latitude) { - descpNew += "修改纬度,原纬度:" + formOld.latitude + ",新纬度:" + formNew.latitude + ";" - } - if (formNew.longitude != formOld.longitude) { - descpNew += "修改经度,原经度:" + formOld.longitude + ",新经度:" + formNew.longitude + ";" - } - if (formNew.position != formOld.position) { - descpNew += "修改位置描述,原位置:" + formOld.position + ",新位置:" + formNew.position + ";" - } - if (formNew.wellcode != formOld.wellcode) { - descpNew += "修改井编号,原编号:" + formOld.wellcode + ",新编号:" + formNew.wellcode + ";" - } - if (formNew.welldepth != formOld.welldepth) { - descpNew += "修改井深,原井深:" + formOld.welldepth + ",新井深:" + formNew.welldepth + ";" - } - if (formNew.welltype != formOld.welltype) { - descpNew += "修改井类型,原井类型:" + formOld.welltype + ",新井类型:" + formNew.welltype + ";" - } - if (formNew.project != formOld.project) { - descpNew += "修改所属项目,原项目:" + formOld.project + ",新项目:" + formNew.project + ";" - } - if (this.data.photopath1 != formOld.photopath1 || - this.data.photopath2 != formOld.photopath2 || - this.data.photopath3 != formOld.photopath3) { - descpNew += "修改照片;" - } - if ("" != formNew.description) { - descpNew += formNew.description; - } - this.setData({ - ['form.description']: descpNew + if (this.data.form.welldepth != null) { + if (this.isNumber(this.data.form.welldepth)) { + wx.showToast({ + icon: 'none', + title: '井深必须为数值!', }) - }, + return false + } + } + if (this.data.form.installheigt != null) { + if (this.isNumber(this.data.form.installheigt)) { + wx.showToast({ + icon: 'none', + title: '到井口距离必须为数值!', + }) + return false + } + } - formSubmit: function (event) { + return true; + }, - if (!this.formValidate()) { - return false; - } - this.changeMsg(); - var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDeviceLog', - data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceLog/add" - }, - }).then(res => { - // var resultObj=JSON.parse(res.result); - if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - if (res.confirm) { - wx.switchTab({ - url: that.data.pageName - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) - } - }).catch(err => { - console.error(err) - wx.showToast({ - title: "提交失败", - }) - }) - }, - confirm(event) { - var that = this; - var formValue = event.detail.value; - var formName = event.target.dataset.id; - var fromN = 'form.' + [formName]; - that.setData({ - [fromN]: formValue - }) - }, + //获取与上次修改的信息 + changeMsg: function () { + var formNew = this.data.form; + console.log(this.data.detail) + var formOld = JSON.parse(this.data.detail); + var descpNew = ""; + if (formNew.devcode != formOld.devcode) { + descpNew += "修改设备编号,原值:" + formOld.devcode + ",新值:" + formNew.devcode + ";" + } + if (formNew.devicetype != formOld.devicetype) { + descpNew += "修改设备类型,原值:" + formOld.devicetype + ",新值:" + formNew.devicetype + ";" + } + if (formNew.area != formOld.area) { + descpNew += "修改区,原值:" + formOld.area + ",新值:" + formNew.area + ";" + } + if (formNew.street != formOld.street) { + descpNew += "修改街道,原值:" + formOld.street + ",新值:" + formNew.street + ";" + } + if (formNew.wellname != formOld.wellname) { + descpNew += "修改井名称,原值:" + formOld.wellname + ",新值:" + formNew.wellname + ";" + } + if (formNew.factory != formOld.factory) { + descpNew += "修改权属单位,原值:" + formOld.factory + ",新值:" + formNew.factory + ";" + } + if (formNew.installheigt != formOld.installheigt) { + descpNew += "修改井口距离,原值:" + formOld.installheigt + ",新值:" + formNew.installheigt + ";" + } + if (formNew.installperson != formOld.installperson) { + descpNew += "修改运维人员,原值:" + formOld.installperson + ",新值:" + formNew.installperson + ";" + } + if (formNew.latitude != formOld.latitude) { + descpNew += "修改纬度,原值:" + formOld.latitude + ",新值:" + formNew.latitude + ";" + } + if (formNew.longitude != formOld.longitude) { + descpNew += "修改经度,原值:" + formOld.longitude + ",新值:" + formNew.longitude + ";" + } + if (formNew.position != formOld.position) { + descpNew += "修改位置描述,原值:" + formOld.position + ",新值:" + formNew.position + ";" + } + if (formNew.wellcode != formOld.wellcode) { + descpNew += "修改井编号,原值:" + formOld.wellcode + ",新值:" + formNew.wellcode + ";" + } + if (formNew.welldepth != formOld.welldepth) { + descpNew += "修改井深,原值:" + formOld.welldepth + ",新值:" + formNew.welldepth + ";" + } + if (formNew.welltype != formOld.welltype) { + descpNew += "修改井类型,原值:" + formOld.welltype + ",新值:" + formNew.welltype + ";" + } + if (formNew.project != formOld.project) { + descpNew += "修改所属项目,原值:" + formOld.project + ",新值:" + formNew.project + ";" + } + if (this.data.form.photopath1 != formOld.photopath1 || + this.data.form.photopath2 != formOld.photopath2 || + this.data.form.photopath3 != formOld.photopath3) { + descpNew += "修改照片;" + } + if ("" != formNew.description) { + descpNew += formNew.description; + } + this.setData({ + ['form.description']: descpNew + }) + }, - scan() { + //提交表单 + formSubmit: function (event) { - wx.scanCode({ - success(res) { - console.log(res) - } - }) + //表单验证 + if (!this.formValidate()) { + return false; + } + //自动生成修改内容 + this.changeMsg(); + //提交权限限制(只有施工人员能修改) + if(app.globalData.role!='repair'){ + wx.showToast({ + icon: 'none', + title: '无权限修改', + duration:2000 + }) + return false + } + var that = this; + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopath = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopath]: fileList[i].url.split("static/")[1] + }) + } + delete that.data.form.installtime + delete that.data.form.createtime + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - paste() { - var _this = this; - wx.getClipboardData({ - success: function (res) { - var longitude = 'form.longitude'; - var latitude = 'form.latitude'; - var longitude84 = 'form.longitude84'; - var latitude84 = 'form.latitude84'; - _this.setData({ - [longitude]: parseFloat(res.data.split(",", 4)[1]).toFixed(6), - [latitude]: parseFloat(res.data.split(",", 4)[0]).toFixed(6), - [longitude84]: "" == (res.data.split(",", 4)[3]) ? "" : parseFloat(res.data.split(",", 4)[3]).toFixed(6), - [latitude84]: "" == (res.data.split(",", 4)[2]) ? "" : parseFloat(res.data.split(",", 4)[2]).toFixed(6), - longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), - latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), - }); - } - }) - }, - selectValue(value) { - var that = this; - var wellType = 'form.welltype'; - that.setData({ - [wellType]: value.detail - }) - }, - selectpersonValue(event) { - var that = this; - var installPerson = 'form.installperson'; - that.setData({ - [installPerson]: event.detail - }) - }, - selectprojectValue(event) { - var that = this; - var project = 'form.project'; - that.setData({ - [project]: event.detail, - showMask: true - }) - }, - open() { - this.setData({ - showMask: true - }) - }, - close() { - this.setData({ - showMask: false - }) - }, - afterRead(event) { - var _this = this; - const { - file - } = event.detail; - const { - fileList = [] - } = _this.data; - var convertpath = ""; - wx.compressImage({ - src: event.detail.file.path, - quality: 25, - success: function (res) { - convertpath = res.tempFilePath; - wx.uploadFile({ - url: app.globalData.httpsUrl + "appDeviceAdd/fileUploadMarker", - filePath:convertpath, - name: 'file', - formData: { - 'text': "编号:" + _this.data.form.devcode + "经度:" + _this.data.form.longitude + "纬度:" + _this.data.form.latitude - }, - header: { - "Content-Type": "multipart/form-data", - 'accept': 'application/json', - }, - success(res) { - if (res.data) { - var url = JSON.parse(res.data); - fileList.push({ - ...file, - url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - }); - _this.setData({ - fileList - }); - } - } + success(res) { + if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + if (res.confirm) { + wx.switchTab({ + url: that.data.pageName }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') } - }) - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // // var base64 = "data:image/png;base64," + wx.getFileSystemManager().readFileSync(convertpath, 'base64'); - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: convertpath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // // wx.cloud.callFunction({ - // // name: 'uploadFile', - // // data: { - // // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // // fileBase64: base64 - // // }, - // // success: function (res) { - // // if (res.result) { - // // fileList.push({ - // // ...file, - // // url: app.globalData.url + "static/" + res.result.data.replace(/\\/g, "/") - // // }); - // // _this.setData({ - // // fileList - // // }); - // // } - // // }, - // // complete: res => { - // // }, - // // }) - // } - // }); + } + }) + } + }, + fail(err) { + wx.showToast({ + title: "提交失败", + }) + } + }) + }, + //报存录入的input信息 + confirm(event) { + var that = this; + var formValue = event.detail.value; + var formName = event.target.dataset.id; + var fromN = 'form.' + [formName]; + that.setData({ + [fromN]: formValue + }) + }, + + //扫码 + scan() { + + wx.scanCode({ + success(res) { + console.log(res) + } + }) + }, + //粘贴经纬度 + paste() { + var _this = this; + wx.getClipboardData({ + success: function (res) { + var longitude = 'form.longitude'; + var latitude = 'form.latitude'; + var longitude84 = 'form.longitude84'; + var latitude84 = 'form.latitude84'; + _this.setData({ + [longitude]: parseFloat(res.data.split(",", 4)[1]).toFixed(6), + [latitude]: parseFloat(res.data.split(",", 4)[0]).toFixed(6), + [longitude84]: "" == (res.data.split(",", 4)[3]) ? "" : parseFloat(res.data.split(",", 4)[3]).toFixed(6), + [latitude84]: "" == (res.data.split(",", 4)[2]) ? "" : parseFloat(res.data.split(",", 4)[2]).toFixed(6), + longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), + latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), + }); + } + }) + }, + selectValue(value) { + var that = this; + var wellType = 'form.welltype'; + that.setData({ + [wellType]: value.detail + }) + }, + //运维人员默认为登录人 + // selectpersonValue(event) { + // var that = this; + // var installPerson = 'form.installperson'; + // that.setData({ + // [installPerson]: event.detail + // }) + // }, + selectprojectValue(event) { + var that = this; + var project = 'form.project'; + that.setData({ + [project]: event.detail, + showMask: true + }) + }, + + open() { + this.setData({ + showMask: true + }) + }, + //隐藏textarea,防止遮挡 + close() { + this.setData({ + showMask: false + }) + }, + //上传照片 + afterRead(event) { + var _this = this; + const { + file + } = event.detail; + const { + fileList = [] + } = _this.data; + var convertpath = ""; + wx.compressImage({ + src: event.detail.file.path, + quality: 25, + success: function (res) { + convertpath = res.tempFilePath; + wx.uploadFile({ + url: app.globalData.httpsUrl + "appDeviceAdd/fileUploadMarker", + filePath: convertpath, + name: 'file', + formData: { + 'text': "编号:" + _this.data.form.devcode + "经度:" + _this.data.form.longitude + "纬度:" + _this.data.form.latitude }, - deletePhoto(event) { - var that = this - var image_index = event.detail.index - var fileList_new = that.data.fileList; - wx.showModal({ - content: '确定删除照片?', - success: function (res) { - if (res.confirm) { - fileList_new.splice(image_index, 1); - that.setData({ - fileList: fileList_new - }) - wx.cloud.callFunction({ - name: 'deletePhoto', - data: { - url: app.globalData.url + "appDeviceLog/deletePhoto", - devcode: that.data.form.devcode, - pathIndex: image_index - }, - success: function (res) {}, - complete: res => {}, - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + "Content-Type": "multipart/form-data", + 'accept': 'application/json', }, - }) \ No newline at end of file + success(res) { + if (res.data) { + var url = JSON.parse(res.data); + fileList.push({ + ...file, + url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") + }); + _this.setData({ + fileList + }); + } + } + }) + } + }) + }, + //删除照片 + deletePhoto(event) { + var that = this + var image_index = event.detail.index + var fileList_new = that.data.fileList; + wx.showModal({ + content: '确定删除照片?', + success: function (res) { + if (res.confirm) { + fileList_new.splice(image_index, 1); + that.setData({ + fileList: fileList_new + }) + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deletePhoto", + data: { + devcode: that.data.form.devcode + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) {} + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } +}) \ No newline at end of file diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.wxml b/miniprogram/pages/addDevicelog/addDeviceLog.wxml index 38620d4..b10cc7d 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.wxml +++ b/miniprogram/pages/addDevicelog/addDeviceLog.wxml @@ -1,15 +1,21 @@ - + + + + + - + - - + + - - + + - + @@ -39,24 +45,25 @@ - - - + + + - + - + + @@ -64,7 +71,7 @@ - + @@ -79,9 +86,9 @@ - + - 保存 + 保存 diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.wxss b/miniprogram/pages/addDevicelog/addDeviceLog.wxss index ee0b75c..08d5fd7 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.wxss +++ b/miniprogram/pages/addDevicelog/addDeviceLog.wxss @@ -24,6 +24,17 @@ display: flex; align-items: center; } +.map-view{ + width: 750rpx; + height: 485rpx; + position: fixed; + top: 0px; + left: 0px; + z-index: 999; +} +.content{ + margin-top: 495rpx; +} .left { width: 210rpx; diff --git a/miniprogram/pages/addFunction/addFunction.js b/miniprogram/pages/addFunction/addFunction.js deleted file mode 100644 index 4966be3..0000000 --- a/miniprogram/pages/addFunction/addFunction.js +++ /dev/null @@ -1,60 +0,0 @@ -// pages/addFunction/addFunction.js - -const code = `// 云函数入口函数 -exports.main = (event, context) => { - console.log(event) - console.log(context) - return { - sum: event.a + event.b - } -}` - -Page({ - - data: { - result: '', - canIUseClipboard: wx.canIUse('setClipboardData'), - }, - - onLoad: function (options) { - - }, - - copyCode: function() { - wx.setClipboardData({ - data: code, - success: function () { - wx.showToast({ - title: '复制成功', - }) - } - }) - }, - - testFunction() { - wx.cloud.callFunction({ - name: 'sum', - data: { - a: 1, - b: 2 - }, - success: res => { - wx.showToast({ - title: '调用成功', - }) - this.setData({ - result: JSON.stringify(res.result) - }) - }, - fail: err => { - wx.showToast({ - icon: 'none', - title: '调用失败', - }) - console.error('[云函数] [sum] 调用失败:', err) - } - }) - }, - -}) - diff --git a/miniprogram/pages/addFunction/addFunction.json b/miniprogram/pages/addFunction/addFunction.json deleted file mode 100644 index a9a50c5..0000000 --- a/miniprogram/pages/addFunction/addFunction.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "navigationBarTitleText": "云函数指引", - "usingComponents": {} -} \ No newline at end of file diff --git a/miniprogram/pages/addFunction/addFunction.wxml b/miniprogram/pages/addFunction/addFunction.wxml deleted file mode 100644 index 3a10626..0000000 --- a/miniprogram/pages/addFunction/addFunction.wxml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - 测试云函数 - - - 期望输出:{"sum":3} - - - 调用结果:{{result}} - - - - - 新增云函数 - 1. 在云函数根目录 cloudfunctions 上右键选择新建云函数,命名为 sum - 2. 在创建的 cloudfunctions/sum/index.js 文件中添加如下代码 - - - 3. 在 cloudfunctions/sum 目录上右键上传并部署 - 4. 点击测试云函数测试 - 5. 打开云开发云函数管理页,选择 sum 云函数 - 6. 查看 sum 的调用日志 - 进阶:可在云函数中使用 wx-server-sdk 操作数据库,文件存储和调用其他云函数,详见文档 - - - diff --git a/miniprogram/pages/addFunction/addFunction.wxss b/miniprogram/pages/addFunction/addFunction.wxss deleted file mode 100644 index 7ac8619..0000000 --- a/miniprogram/pages/addFunction/addFunction.wxss +++ /dev/null @@ -1,3 +0,0 @@ -/* pages/addFunction/addFunction.wxss */ - -@import "../../style/guide.wxss"; \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.js b/miniprogram/pages/applog/applog.js index 0e8c185..189e61f 100644 --- a/miniprogram/pages/applog/applog.js +++ b/miniprogram/pages/applog/applog.js @@ -13,98 +13,25 @@ isSeach: "false", params: {}, total: 0, - show: false + show: false, + delBtnWidth: 100, //删除按钮宽度单位(rpx) + activeIndex: -1, + list_style: '' }, - - touchE: function (e) { - // console.log(e); - var that = this - if (e.changedTouches.length == 1) { - //手指移动结束后触摸点位置的X坐标 - var endX = e.changedTouches[0].clientX; - //触摸开始与结束,手指移动的距离 - var disX = that.data.startX - endX; - var delBtnWidth = that.data.delBtnWidth; - //如果距离小于删除按钮的1/2,不显示删除按钮 - var txtStyle = disX > delBtnWidth / 2 ? "left:-" + delBtnWidth + "rpx" : "left:0rpx"; - - //获取手指触摸的是哪一项 - var index = e.currentTarget.dataset.index; - var list = that.data.deviceloglist; - list[index].txtStyle = txtStyle; - //更新列表的状态 - that.setData({ - deviceloglist: list - }); - } - }, - //手指触摸动作开始 记录起点X坐标 - touchstart: function (e) { - //开始触摸时 重置所有删除 - this.data.deviceloglist.forEach(function (v, i) { - if (v.isTouchMove) //只操作为true的 - v.isTouchMove = false; - }) - this.setData({ - startX: e.changedTouches[0].clientX, - startY: e.changedTouches[0].clientY, - deviceloglist: this.data.deviceloglist - }) - }, - //滑动事件处理 - touchmove: function (e) { - var that = this, - index = e.currentTarget.dataset.index, //当前索引 - startX = that.data.startX, //开始X坐标 - startY = that.data.startY, //开始Y坐标 - touchMoveX = e.changedTouches[0].clientX, //滑动变化坐标 - touchMoveY = e.changedTouches[0].clientY, //滑动变化坐标 - //获取滑动角度 - angle = that.angle({ - X: startX, - Y: startY - }, { - X: touchMoveX, - Y: touchMoveY - }); - that.data.deviceloglist.forEach(function (v, i) { - v.isTouchMove = false - //滑动超过30度角 return - if (Math.abs(angle) > 30) return; - if (i == index) { - if (touchMoveX > startX) //右滑 - v.isTouchMove = false - else //左滑 - v.isTouchMove = true - } - }) - //更新数据 - that.setData({ - deviceloglist: that.data.deviceloglist - }) - }, - /** - * 计算滑动角度 - * @param {Object} start 起点坐标 - * @param {Object} end 终点坐标 - */ - angle: function (start, end) { - var _X = end.X - start.X, - _Y = end.Y - start.Y - //返回角度 /Math.atan()返回数字的反正切值 - return 360 * Math.atan(_Y / _X) / (2 * Math.PI); - }, - /** - * 生命周期函数--监听页面加载var_this=this; - */ onLoad: function (options) { - if (options.params) { this.setData({ params: JSON.parse(options.params), isSeach: "true" }) this.initPages() + }else{ + this.setData({ + show: false + }) + //清空参数,重新加载 + this.clearParams(); + this.initPages(); } }, @@ -116,20 +43,33 @@ }, + //点击tabBar事件 + onTabItemTap(item) { + //隐藏历史显示总记录条数 + this.setData({ + show: false + }) + //清空参数,重新加载 + this.clearParams(); + this.initPages(); + }, + + /** * 生命周期函数--监听页面显示 */ onShow: function (options) { - this.setData({ - show:false - }) - if (this.data.isSeach == "false") { - this.clearParams(); - this.initPages(); - } - this.setData({ - isSeach: "false" - }) + + // this.setData({ + // show: false + // }) + // if (this.data.isSeach == "false") { + // this.clearParams(); + // this.initPages(); + // } + // this.setData({ + // isSeach: "false" + // }) }, /** @@ -167,6 +107,119 @@ }, + + //手指触摸动作开始 记录起点X坐标 + touchstart: function (e) { + //开始触摸时 重置所有删除 + this.data.deviceloglist.forEach(function (v, i) { + if (v.isTouchMove) //只操作为true的 + v.isTouchMove = false; + }) + this.setData({ + startX: e.changedTouches[0].clientX, + startY: e.changedTouches[0].clientY, + deviceloglist: this.data.deviceloglist + }) + }, + + //滑动事件处理 + touchmove: function (e) { + var that = this, + index = e.currentTarget.dataset.index, //当前索引 + startX = that.data.startX, //开始X坐标 + startY = that.data.startY, //开始Y坐标 + touchMoveX = e.changedTouches[0].clientX, //滑动变化坐标 + touchMoveY = e.changedTouches[0].clientY, //滑动变化坐标 + //获取滑动角度 + angle = that.angle({ + X: startX, + Y: startY + }, { + X: touchMoveX, + Y: touchMoveY + }); + that.data.deviceloglist.forEach(function (v, i) { + // v.isTouchMove = false + //滑动超过30度角 return + if (Math.abs(angle) > 30) return; + if (i == index) { + if (touchMoveX > startX) //右滑 + v.isTouchMove = false + else //左滑 + v.isTouchMove = true + } + }) + //更新数据 + that.setData({ + deviceloglist: that.data.deviceloglist + }) + }, + + /** + * 计算滑动角度 + * @param {Object} start 起点坐标 + * @param {Object} end 终点坐标 + */ + angle: function (start, end) { + var _X = end.X - start.X, + _Y = end.Y - start.Y + //返回角度 /Math.atan()返回数字的反正切值 + return 360 * Math.atan(_Y / _X) / (2 * Math.PI); + }, + + //删除事件 + delItem: function (e) { + if(app.globalData.role!='repair'){ + wx.showToast({ + icon: 'none', + title: '无权限删除', + duration:2000 + }) + return false + } + var that = this + wx.showModal({ + content: '是否删除?', + success: function (res) { + if (res.confirm) { + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/delete", + data: { + appDeviceAddId: e.currentTarget.dataset.devid + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if(res.data.code=='200'){ + that.data.deviceloglist.splice(e.currentTarget.dataset.index, 1) + that.setData({ + deviceloglist: that.data.deviceloglist, + total: that.data.deviceloglist.length + }) + wx.showToast({ + title: '删除成功!', + icon: 'none', + duration: 1000 + }) + } + }, + fail(err) { + wx.showToast({ + title: '删除失败!', + icon: 'none', + duration: 2000 + }) + } + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + }, + showLoading: function (message) { if (wx.showLoading) { // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 @@ -199,95 +252,105 @@ deviceloglist: [] }) }, + //查询列表数据 initPages: function () { var that = this + that.setData({ + show: false + }) var offsetValue = that.data.deviceloglist.length % 15 > 0 ? parseInt(that.data.deviceloglist.length / 15) + 2 : parseInt(that.data.deviceloglist.length / 15) + 1 - wx.cloud.callFunction({ - name: 'devicelog', + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/listPage", data: { devcode: that.data.params.devcode, devtype: that.data.params.devtype, installtimeFmt: that.data.params.installtimeFmt, project: that.data.params.project, installPerson: that.data.params.installPerson, - url: app.globalData.url + "appDeviceLog/listPage", limit: 15, offset: offsetValue }, - }).then(res => { - if (res.result.data.rows.length > 0) { - var resultJson = res.result - that.setData({ - deviceloglist: that.data.deviceloglist.concat(resultJson.data.rows) - }) - } else if (that.data.deviceloglist.length > 0) { - that.setData({ - show: true, - total: that.data.deviceloglist.length - }) - wx.showToast({ - title: '数据已全部加载完', - icon: 'none', - duration: 2000 - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.data.rows.length > 0) { + var resultJson = res.data + var listArr = resultJson.data.rows + listArr.forEach(function (v, i) { + listArr[i]['isTouchMove'] = false + }) + that.setData({ + deviceloglist: that.data.deviceloglist.concat(listArr) + }) + } else if (that.data.deviceloglist.length > 0) { + that.setData({ + show: true, + total: that.data.deviceloglist.length + }) + wx.showToast({ + title: '数据已全部加载完', + icon: 'none', + duration: 2000 + }) + } + if (offsetValue == 1 && res.data.data.rows.length < 15) { + that.setData({ + show: true, + total: that.data.deviceloglist.length + }) + } } - if(offsetValue==1&&res.result.data.rows.length<15){ - that.setData({ - show: true, - total: that.data.deviceloglist.length - }) - } - // console.log(res); - }).catch(err => { - console.error(err); }) + }, addDetail: function (event) { - this.showLoading("数据请求中..."); - wx.cloud.callFunction({ - name: 'deviceDetail', + var that = this + that.showLoading("数据请求中..."); + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deviceDetail", data: { devcode: event.target.dataset.devcode, - url: app.globalData.url + "appDeviceLog/deviceDetail", }, - }).then(res => { - this.hideLoading(); - var resultObject = JSON.parse(res.result); - var pageName = '../applog/applog' - if (resultObject.code == 200) { - wx.navigateTo({ - url: '../addDevicelog/addDeviceLog?detail=' + - JSON.stringify(resultObject.data) + "&pageName=" + pageName - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + that.hideLoading(); + // var resultObject = JSON.parse(res.data); + var resultObject = res.data; + var pageName = '../applog/applog' + if (resultObject.code == 200) { + wx.setStorageSync('resultObject', resultObject.data) + wx.navigateTo({ + url: '../addDevicelog/addDeviceLog?detail=' + "&pageName=" + pageName + }) + } + }, + fail(err) { + that.hideLoading(); } - }).catch(err => { - this.hideLoading() }) + }, add: function (event) { - wx.reLaunch({ - url: '../earth/earth?devcode=' + event.target.dataset.devcode - // url: '../earth/earth' + app.globalData.devcode = event.target.dataset.devcode; + wx.switchTab({ + url: '../earth/earth' }) + // wx.reLaunch({ + // url: '../earth/earth?devcode=' + event.target.dataset.devcode + // // url: '../earth/earth' + // }) }, onSearch: function () { + var _this = this wx.navigateTo({ - url: '../searchLog/searchLog' + url: '../searchLog/searchLog?params=' + JSON.stringify(_this.data.params) }) - }, - // initPages: function () { - // wx.cloud.callFunction({ - // name: 'devicelog' - // }).then(res => { - // var that = this; - // var jsonList = JSON.parse(res.result) - // that.setData({ - // deviceloglist: jsonList.data.rows - // }) - // console.log(res); - // }).catch(err => { - // console.error(err); - // }) - // } + } }) \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.wxml b/miniprogram/pages/applog/applog.wxml index e9a2352..2bfd041 100644 --- a/miniprogram/pages/applog/applog.wxml +++ b/miniprogram/pages/applog/applog.wxml @@ -1,54 +1,59 @@ - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {{item.devcode}} {{item.devicetype}} + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + {{item.devcode}} {{item.devicetype}} + + {{item.project}} {{item.installtime}}- {{item.installperson}} - - - - - + + + + + + 删除 - - - + + - 共计:{{total}}台 - + 共计:{{total}}台 + \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.wxss b/miniprogram/pages/applog/applog.wxss index 6d3428b..e6e8983 100644 --- a/miniprogram/pages/applog/applog.wxss +++ b/miniprogram/pages/applog/applog.wxss @@ -22,16 +22,18 @@ position: fixed; width: 100%; top: 0rpx; + z-index: 9999; /* margin-bottom: 100rpx; */ } .log-list { /* height: 100rpx; */ - /* display: flex; */ - + display: flex; + width: 100%; padding: 2px; margin-top: 2px; border-bottom: 1px solid #e5e5e5; + overflow: hidden } @@ -53,23 +55,29 @@ left: 35%; margin: 20rpx } - .del { - width: 90px; + /* display: flex; */ + width: 100rpx; display: flex; flex-direction: column; align-items: center; justify-content: center; - color: #fff; - -webkit-transform: translateX(90px); - transform: translateX(90px); - -webkit-transition: all 0.4s; + /* -webkit-transform: translateX(100rpx); */ + transform: translateX(100rpx); + /* -webkit-transition: all 0.4s; */ transition: all 0.4s; - font-size: 35rpx; + color: #fff; + background-color: #fe3e2f; +} +.logrow{ + width: 100%; + transform: translateX(100rpx); + /* -webkit-transform: translateX(100px); */ + margin-left: -100rpx; } -.touch-move-active .content, +.touch-move-active .logrow, .touch-move-active .del { - -webkit-transform: translateX(0); - transform: translateX(0); +/* -webkit-transform: translateX(0); */ +transform: translateX(0); } \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.js b/miniprogram/pages/deployFunctions/deployFunctions.js deleted file mode 100644 index a76b144..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.js +++ /dev/null @@ -1,66 +0,0 @@ -// pages/deployFunctions/deployFunctions.js -Page({ - - /** - * 页面的初始数据 - */ - data: { - - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - - }, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { - - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - - }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { - - }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { - - } -}) \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.json b/miniprogram/pages/deployFunctions/deployFunctions.json deleted file mode 100644 index 7fbedab..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "navigationBarTitleText": "部署云函数", - "usingComponents": {} -} \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.wxml b/miniprogram/pages/deployFunctions/deployFunctions.wxml deleted file mode 100644 index 462b6b6..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.wxml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - 调用失败 - - - 请检查 login 云函数是否已部署 - - - - - 部署 login 云函数 - 1. 确保已通过工具栏云开发入口开通云开发 - 2. 在 cloudfunctions/login 目录上右键上传并部署 - 3. 回到首页,重新点击获取 openid - - - - diff --git a/miniprogram/pages/deployFunctions/deployFunctions.wxss b/miniprogram/pages/deployFunctions/deployFunctions.wxss deleted file mode 100644 index c8803e6..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.wxss +++ /dev/null @@ -1,7 +0,0 @@ -/* pages/deployFunctions/deployFunctions.wxss */ - -@import "../../style/guide.wxss"; - -.black { - color: black; -} \ No newline at end of file diff --git a/miniprogram/pages/earth/earth.js b/miniprogram/pages/earth/earth.js index ae0d3f3..376a6e2 100644 --- a/miniprogram/pages/earth/earth.js +++ b/miniprogram/pages/earth/earth.js @@ -21,19 +21,12 @@ show: false, enableSsatellite: false, windowWidth: 0, - longitude: 113.324520, - latitude: 23.099994, - longitude84: 113.324520, - latitude84: 23.099994, - markers: [{ - id: 0, - iconPath: "../../images/locat.png", - latitude: 23.099994, - longitude: 113.324520, - width: 50, - height: 50 - }], - controls: [], + longitude: "116.627340", + latitude: "39.874390", + longitude84: "", + latitude84: "", + markers: [], + controls: [] }, /** @@ -41,39 +34,13 @@ */ onLoad: function (options) { var that = this; - //获取当前坐标(gcj02) - wx.getLocation({ - type: "gcj02", - altitude: true, - success: function (res) { - that.setData({ - latitude: parseFloat(res.latitude).toFixed(6), - longitude: parseFloat(res.longitude).toFixed(6), - // markers: [{ - // latitude: res.latitude, - // longitude: res.longitude, - // }] - }) - //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 - wx.getLocation({ - type: "wgs84", - altitude: true, - success: function (res) { - that.setData({ - latitude84: parseFloat(res.latitude).toFixed(6), - longitude84: parseFloat(res.longitude).toFixed(6) - }) - } - }) - } - }), - - //设置地图组件 - wx.getSystemInfo({ + //设置地图组件 + wx.getSystemInfo({ success(res) { var windowWidth = res.windowWidth var windowHeight = res.windowHeight var query = wx.createSelectorQuery() + var platform =res.platform query.select('#map').boundingClientRect() query.exec(function (res) { that.setData({ @@ -139,10 +106,20 @@ clickable: true }, { id: 7, - iconPath: '../../images/locat.png', + iconPath: '../../images/applocat.png', position: { - left: res[0].width/2, - top: res[0].height/2, + left: res[0].width / 2 - 20, + top: platform=="ios"?res[0].height / 2 - 80:res[0].height / 2 - 40, + width: 40, + height: 40 + }, + clickable: true + }, { + id: 8, + iconPath: '../../images/back.png', + position: { + left: windowWidth - 40, + top: windowHeight - 140, width: 30, height: 30 }, @@ -150,71 +127,15 @@ }] }) }) - + } - }), + }) + // 实例化API核心类 qqmapsdk = new QQMapWX({ key: 'BGPBZ-C5O3P-ROUDR-LWC4J-63EKH-V5FRX' }) - - if (options.devcode) { - var that = this - var devcode = options.devcode - wx.cloud.callFunction({ - name: 'findListByCodes', - data: { - devcodes: devcode, - url: app.globalData.url + "appDeviceAdd/findListByCodes" - }, - }).then(res => { - if (res.result.code == 200) { - var listResultData = res.result.data; - that.setData({ - listData: listResultData - }) - var markersArr = that.data.markers; - for (var i = 0; i < listResultData.length; i++) { - markersArr = markersArr.concat({ - iconPath: "../../images/locat.png", - id: listResultData[i].id, - callout: { - content: listResultData[i].devcode, - fontSize: '14', - // padding: true, - color: '#00000', - borderColor: '#F4EA2A', - bgColor: '#F4EA2A', - borderWidth: 5, - display: 'ALWAYS', - textAlign: 'center', - // borderRadius: 15 - }, - latitude: listResultData[i].latitude, - longitude: listResultData[i].longitude, - width: 40, - height: 40 - }); - } - this.setData({ - markers: markersArr, - latitude: listResultData[0].latitude, - longitude: listResultData[0].longitude, - marker_latitude: listResultData[0].latitude, - marker_longitude: listResultData[0].longitude, - title: listResultData[0].devcode - }) - } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "无法获取设备地理信息!", - icon: 'none', - duration: 2000 - }) - }) - } }, /** @@ -228,6 +149,97 @@ * 生命周期函数--监听页面显示 */ onShow: function () { + //输入设备编号获取marker位置信息 + var that = this; + if ( app.globalData.devcode!="") { + var devcode = app.globalData.devcode + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/findListByCodes", + data: { + devcodes: devcode, + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + app.globalData.devcode=""; + if (res.data.code == 200) { + var listResultData = res.data.data; + that.setData({ + listData: listResultData + }) + var markersArr = that.data.markers; + for (var i = 0; i < listResultData.length; i++) { + markersArr = markersArr.concat({ + iconPath: "../../images/locat.png", + id: Number(listResultData[i].id), + callout: { + content: "编号:"+listResultData[i].devcode+"\r\n位置:"+listResultData[i].position+"\r\n时间:"+listResultData[i].createtime, + fontSize: '14', + padding: true, + color: '#000000', + borderColor: '#F4EA2A', + bgColor: '#F4EA2A', + borderWidth: 5, + display: 'ALWAYS', + textAlign: 'left', + // borderRadius: 15 + }, + latitude: listResultData[i].latitude, + longitude: listResultData[i].longitude, + width: 40, + height: 40 + }); + } + that.setData({ + markers: markersArr, + latitude: listResultData[0].latitude, + longitude: listResultData[0].longitude, + marker_latitude: listResultData[0].latitude, + marker_longitude: listResultData[0].longitude, + title: listResultData[0].devcode + }) + } + }, + fail(err) { + app.globalData.devcode=""; + wx.showToast({ + title: "无法获取设备地理信息!", + icon: 'none', + duration: 2000 + }) + } + }) +} else { + //获取当前坐标(gcj02) + wx.getLocation({ + type: "gcj02", + altitude: true, + success: function (res) { + that.setData({ + latitude: parseFloat(res.latitude).toFixed(6), + longitude: parseFloat(res.longitude).toFixed(6), + // markers: [{ + // latitude: res.latitude, + // longitude: res.longitude, + // }] + }) + //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 + wx.getLocation({ + type: "wgs84", + altitude: true, + success: function (res) { + that.setData({ + latitude84: parseFloat(res.latitude).toFixed(6), + longitude84: parseFloat(res.longitude).toFixed(6) + }) + } + }) + } + }) +} + }, @@ -265,12 +277,46 @@ onShareAppMessage: function () { }, + + //定位出来 + + locationPosition: function () { + var that = this; + //获取当前坐标(gcj02) + wx.getLocation({ + type: "gcj02", + altitude: true, + success: function (res) { + that.setData({ + latitude: parseFloat(res.latitude).toFixed(6), + longitude: parseFloat(res.longitude).toFixed(6), + // markers: [{ + // latitude: res.latitude, + // longitude: res.longitude + // }] + }) + //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 + wx.getLocation({ + type: "wgs84", + altitude: true, + success: function (res) { + that.setData({ + latitude84: parseFloat(res.latitude).toFixed(6), + longitude84: parseFloat(res.longitude).toFixed(6) + }) + } + }) + } + }) + }, + + //加载地图组件 controltap: function (e) { // console.log(e.controlId); //进入添加设备页 if (1 == e.controlId) { wx.setClipboardData({ - data: this.data.latitude + "," + this.data.longitude+ "," + this.data.latitude84+ "," + this.data.longitude84, + data: this.data.latitude + "," + this.data.longitude + "," + this.data.latitude84 + "," + this.data.longitude84, success: function (res) { wx.getClipboardData({ success: function (res) { @@ -282,6 +328,17 @@ } }) } else if (3 == e.controlId) { + //先定位 + // this.locationPosition() + wx.setClipboardData({ + data: this.data.latitude + "," + this.data.longitude + "," + this.data.latitude84 + "," + this.data.longitude84, + success: function (res) { + wx.showToast({ + title: '坐标已获取', + duration: 1000 + }) + } + }) wx.navigateTo({ url: '../addDevice/addDevice' }) @@ -302,32 +359,15 @@ enableSsatellite: !flag }); } else if (6 == e.controlId) { - var that = this; - //获取当前坐标(gcj02) - wx.getLocation({ - type: "gcj02", - altitude: true, - success: function (res) { - that.setData({ - latitude: parseFloat(res.latitude).toFixed(6), - longitude:parseFloat(res.longitude).toFixed(6), - // markers: [{ - // latitude: res.latitude, - // longitude: res.longitude - // }] - }) - //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 - wx.getLocation({ - type: "wgs84", - altitude: true, - success: function (res) { - that.setData({ - latitude84: parseFloat(res.latitude).toFixed(6), - longitude84: parseFloat(res.longitude).toFixed(6) - }) - } - }) - } + //先清marker + this.setData({ + markers: [] + }) + this.locationPosition() + }else if (8 == e.controlId) { + //跳转日志缓存页 + wx.switchTab({ + url: '../applog/applog', }) } }, @@ -343,63 +383,68 @@ }); }, + //获取设备maker leave() { var that = this; if (that.data.devcodes == "") { return false; } - wx.cloud.callFunction({ - name: 'findListByCodes', + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/findListByCodes", data: { - devcodes: that.data.devcodes, - url: app.globalData.url + "appDeviceAdd/findListByCodes" + devcodes: that.data.devcodes }, - }).then(res => { - if (res.result.code == 200) { - var listResultData = res.result.data; - that.setData({ - listData: listResultData - }) - var markersArr = that.data.markers; - for (var i = 0; i < listResultData.length; i++) { - markersArr = markersArr.concat({ - iconPath: "../../images/locat.png", - id: listResultData[i].id, - callout: { - content: listResultData[i].devcode, - fontSize: '14', - // padding: true, - color: '', - borderColor: '#F4EA2A', - bgColor: '#F4EA2A', - borderWidth: 5, - display: 'ALWAYS', - textAlign: 'center', - // borderRadius: 15 - }, - latitude: listResultData[i].latitude, - longitude: listResultData[i].longitude, - width: 40, - height: 40 - }); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var listResultData = res.data.data; + that.setData({ + listData: listResultData + }) + var markersArr = that.data.markers; + for (var i = 0; i < listResultData.length; i++) { + markersArr = markersArr.concat({ + iconPath: "../../images/locat.png", + id: listResultData[i].id, + callout: { + content: "编号:"+listResultData[i].devcode+"\r\n位置:"+listResultData[i].position+"\r\n时间:"+listResultData[i].createtime, + fontSize: '14', + // padding: true, + color: '#212121', + borderColor: '#F4EA2A', + bgColor: '#F4EA2A', + borderWidth: 5, + display: 'ALWAYS', + textAlign: 'left', + // borderRadius: 15 + }, + latitude: listResultData[i].latitude, + longitude: listResultData[i].longitude, + width: 40, + height: 40 + }); + } + that.setData({ + markers: markersArr, + latitude: listResultData[0].latitude, + longitude: listResultData[0].longitude, + marker_latitude: listResultData[0].latitude, + marker_longitude: listResultData[0].longitude, + title: listResultData[0].devcode + }) } - this.setData({ - markers: markersArr, - latitude: listResultData[0].latitude, - longitude: listResultData[0].longitude, - marker_latitude: listResultData[0].latitude, - marker_longitude: listResultData[0].longitude, - title: listResultData[0].devcode + }, + fail(err) { + wx.showToast({ + title: "无法获取设备地理信息!", + icon: 'none', + duration: 2000 }) } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "无法获取设备地理信息!", - icon: 'none', - duration: 2000 - }) }) }, @@ -422,6 +467,8 @@ } }, + + bindregionchange: function (e) { var that = this if (e.causedBy == "drag") { @@ -445,8 +492,8 @@ that.setData({ latitude: parseFloat(latitude).toFixed(6), longitude: parseFloat(longitude).toFixed(6), - latitude84:"", - longitude84:"", + latitude84: "", + longitude84: "", // markers: markersArr }) // mapCtx.moveToLocation(); @@ -465,16 +512,19 @@ qqmapsdk.search({ keyword: this.data.value, success: function (res) { + console.log(res) if (res && res.data) { _this.setData({ isShow: true, tips: res.data }); } + }, + complete: function (res){ + console.log(res); } }) }, - bindSearch: function (e) { var location = e.target.dataset.location; this.setData({ diff --git a/miniprogram/pages/earth/earth.wxml b/miniprogram/pages/earth/earth.wxml index a0db6ef..87474f8 100644 --- a/miniprogram/pages/earth/earth.wxml +++ b/miniprogram/pages/earth/earth.wxml @@ -1,9 +1,10 @@ + - + {{item.title}} {{item.address}} @@ -17,6 +18,6 @@ + placeholder="请输入定位设备编号用换行隔开" autosize border="{{ false }}" /> \ No newline at end of file diff --git a/miniprogram/pages/indexapp/indexapp.js b/miniprogram/pages/indexapp/indexapp.js index 5063372..849dbdb 100644 --- a/miniprogram/pages/indexapp/indexapp.js +++ b/miniprogram/pages/indexapp/indexapp.js @@ -7,9 +7,8 @@ */ data: { - count:1, - show: false, - onshow:true, + count: 1, + onshow: true, value: "", deviceloglist: [], devcode: "", @@ -21,6 +20,7 @@ // iconPath: "../../images/point.png", latitude: 23.099994, longitude: 113.324520, + label:'1', width: 50, height: 50 }], @@ -31,62 +31,26 @@ * 生命周期函数--监听页面加载 */ onLoad: function (options) { - + }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { - + }, /** * 生命周期函数--监听页面显示 */ onShow: function () { - // if( app.globalData.indexCount>1){ - // this.setData({ - // show:false - // }) - // }else{ - // this.showNotice() - // } - if(app.globalData.indexCount==1){ - this.setData({ - show:true - }) - this.showNotice() - } - app.globalData.indexCount+=1 - if(this.data.onshow){ + if (this.data.onshow) { this.initPages(); } }, - - showNotice: function() { - var that = this - var times = 0 - var i = setInterval(function() { - times++ - if (times >= 15) { - that.setData({ - show:false - }) - wx.showTabBar({ - animation: false, - }) - clearInterval(i) - } else { - wx.hideTabBar({ - animation: false, - }) - } - }, 1000) -}, - /** * 生命周期函数--监听页面隐藏 */ @@ -122,16 +86,27 @@ }, jump: function (event) { - var that = this; var latitude = event.target.dataset.pointLat; var longitude = event.target.dataset.pointLon; + let devcode = event.target.dataset.pointCode; that.setData({ latitude: latitude, longitude: longitude, markers: [{ latitude: latitude, - longitude: longitude + longitude: longitude, + callout: { + display:'ALWAYS',// 常显气泡 + content: devcode, //名称文本 + color: '#fff', //文本颜色 + borderRadius: 5, //边框圆角 + borderWidth: 1, //边框宽度 + borderColor: '#0060ff', //边框颜色 + bgColor: '#0060ff', //背景色 + padding: 5, //文本边缘留白 + textAlign: 'center' //文本对齐方式。有效值: left, right, center + } }] }) }, @@ -142,7 +117,7 @@ var devcode = res.result _this.setData({ devcode: devcode, - onshow:false + onshow: false }); _this.searchlogs(devcode) } @@ -151,40 +126,11 @@ onSearch: function (event) { this.setData({ - devcode:event.detail + devcode: event.detail }) this.searchlogs(event.detail) }, - - // bindregionchange: function (e) { - // var that = this - // if (e.causedBy == "drag") { - // var mapCtx = wx.createMapContext("map") - // mapCtx.getCenterLocation({ - // success: function (res) { - // var markersArr = that.data.markers - // for (var i = 0; i < markersArr.length; i++) { - // if (markersArr[i].iconPath == undefined) { - // markersArr.splice(i, 1) - // } - // } - // var latitude = res.latitude - // var longitude = res.longitude - // markersArr = markersArr.concat({ - // latitude: latitude, - // longitude: longitude - // }) - // that.setData({ - // latitude: latitude, - // longitude: longitude, - // markers: markersArr - // }) - // } - // }) - // } - // }, - showLoading: function (message) { if (wx.showLoading) { // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 @@ -211,81 +157,89 @@ } }, + //加载设备运维详细信息 toDetail: function (event) { - this.showLoading("数据加载中...") - wx.cloud.callFunction({ - name: 'deviceDetail', + var that = this + that.showLoading("数据加载中...") + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deviceDetail", data: { devcode: event.target.dataset.devcode, - url: app.globalData.url + "appDeviceLog/deviceDetail", }, - }).then(res => { - this.hideLoading(); - var resultObject = JSON.parse(res.result); - var pageName='../indexapp/indexapp' - if (resultObject.code == 200) { - wx.navigateTo({ - url: '../addDevicelog/addDeviceLog?detail=' + - JSON.stringify(resultObject.data)+'&pageName='+pageName - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + that.hideLoading(); + var resultObject = res.data; + var pageName = '../indexapp/indexapp' + if (resultObject.code == 200) { + wx.setStorageSync('resultObject', resultObject.data) + wx.navigateTo({ + url: '../addDevicelog/addDeviceLog?detail=' +'&pageName=' + pageName + }) + } + }, + fail(err){ + that.hideLoading(); } - }).catch(err => { - this.hideLoading(); }) }, + //加载列表 getlogs: function (devcode) { var that = this - wx.cloud.callFunction({ - name: 'devicelog', + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/listPage", data: { devcode: devcode, - url: app.globalData.url + "appDeviceLog/listPage", limit: 100, offset: that.data.deviceloglist.length % 100 > 0 ? parseInt(that.data.deviceloglist.length / 100) + 2 : parseInt(that.data.deviceloglist.length / 100) + 1 }, - }).then(res => { - if (res.result) { - // var resultJson = JSON.parse(res.result) - var resultJson = res.result - that.setData({ - deviceloglist: that.data.deviceloglist.concat(resultJson.data.rows) - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + // var resultJson = JSON.parse(res.result) + var resultJson = res.data + that.setData({ + deviceloglist: that.data.deviceloglist.concat(resultJson.data.rows) + }) + } } - console.log(res); - }).catch(err => { - console.error(err); }) }, + //查询列表 searchlogs: function (devcode) { var that = this - wx.cloud.callFunction({ - name: 'devicelog', + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/listPage", data: { devcode: devcode, - url: app.globalData.url + "appDeviceLog/listPage", limit: 100, offset: 1 }, - }).then(res => { - if (res.result) { - var resultJson = res.result - that.setData({ - deviceloglist: resultJson.data.rows, - onshow:true - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var resultJson = res.data + that.setData({ + deviceloglist: resultJson.data.rows, + onshow: true + }) + } } - console.log(res); - }).catch(err => { - console.error(err); }) }, initPages: function () { var that = this; - that.setData({ - devcode: "" - }); wx.getLocation({ type: "gcj02", success: function (res) { @@ -302,6 +256,6 @@ }) } }) - this.searchlogs() + this.data.devcode !== '' ? this.searchlogs(this.data.devcode) : this.searchlogs() }, }) \ No newline at end of file diff --git a/miniprogram/pages/indexapp/indexapp.wxml b/miniprogram/pages/indexapp/indexapp.wxml index 69322a0..f65b082 100644 --- a/miniprogram/pages/indexapp/indexapp.wxml +++ b/miniprogram/pages/indexapp/indexapp.wxml @@ -1,8 +1,12 @@ + + + + - @@ -32,9 +36,15 @@ - + + + + + + + @@ -46,14 +56,14 @@ - + - - + diff --git a/miniprogram/pages/indexapp/indexapp.wxss b/miniprogram/pages/indexapp/indexapp.wxss index b18706a..fc27fcb 100644 --- a/miniprogram/pages/indexapp/indexapp.wxss +++ b/miniprogram/pages/indexapp/indexapp.wxss @@ -128,6 +128,7 @@ .noticeClass{ height: 2300rpx; width: 750rpx; + overflow-y:hidden; } @@ -148,14 +149,14 @@ } +/* .vanstyle{ + button: not([size='mini']) { + user agent stylesheetmin-height: 40px; + width: 650rpx; + margin-left: 20rpx; + margin-right: auto; + + } + +} */ -/* .van-enter-active-class, -.van-leave-active-class { - transition-property: background-color, transform; -} - -.van-enter-class, -.van-leave-to-class { - background-color: red; - transform: rotate(-360deg) translate3d(-100%, -100%, 0); -} */ \ No newline at end of file diff --git a/miniprogram/pages/log/log.js b/miniprogram/pages/log/log.js deleted file mode 100644 index 83ba349..0000000 --- a/miniprogram/pages/log/log.js +++ /dev/null @@ -1,66 +0,0 @@ -// pages/log/log.js -Page({ - - /** - * 页面的初始数据 - */ - data: { - - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - - }, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { - - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - - }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { - - }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { - - } -}) \ No newline at end of file diff --git a/miniprogram/pages/log/log.json b/miniprogram/pages/log/log.json deleted file mode 100644 index 8835af0..0000000 --- a/miniprogram/pages/log/log.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "usingComponents": {} -} \ No newline at end of file diff --git a/cloudfunctions/project.config.json b/cloudfunctions/project.config.json new file mode 100644 index 0000000..2b3119a --- /dev/null +++ b/cloudfunctions/project.config.json @@ -0,0 +1,28 @@ +{ + "appid": "wx2cef527a000f87c9", + "compileType": "miniprogram", + "libVersion": "2.27.3", + "packOptions": { + "ignore": [], + "include": [] + }, + "setting": { + "coverView": true, + "es6": true, + "postcss": true, + "minified": true, + "enhance": true, + "showShadowRootInWxmlPanel": true, + "packNpmRelationList": [], + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + } + }, + "condition": {}, + "editorSetting": { + "tabIndent": "insertSpaces", + "tabSize": 4 + } +} \ No newline at end of file diff --git a/cloudfunctions/project.private.config.json b/cloudfunctions/project.private.config.json new file mode 100644 index 0000000..42ff49d --- /dev/null +++ b/cloudfunctions/project.private.config.json @@ -0,0 +1,7 @@ +{ + "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", + "projectname": "cloudfunctions", + "setting": { + "compileHotReLoad": true + } +} \ No newline at end of file diff --git a/miniprogram/app.js b/miniprogram/app.js index 51d56f3..50a8a54 100644 --- a/miniprogram/app.js +++ b/miniprogram/app.js @@ -18,13 +18,15 @@ // this.globalData = {} }, globalData: { - // url: "http://111.198.10.15:11604/", - httpsUrl: "https://logapi.smartlog.work/", - httpsTestUrl: "https://smartlog.work/prodapi4test/", - url: "http://139.198.18.188:8083/", + httpsUrl: "https://logapi.smartlog.work/", + // httpsUrl: "http://139.198.18.188:8083/", // url: "http://127.0.0.1:8083/", - // httpsUrl: "http://127.0.0.1:8083/", + //httpsUrl: "http://127.0.0.1:8083/", openid: null, - indexCount:1 - }, + indexCount:1, + nickName:"", + userName:"", + role:"", + devcode:"" + } }) diff --git a/miniprogram/app.json b/miniprogram/app.json index d23f798..2b6db76 100644 --- a/miniprogram/app.json +++ b/miniprogram/app.json @@ -1,15 +1,17 @@ { "cloud": true, "pages": [ + "pages/login/login", "pages/indexapp/indexapp", "pages/earth/earth", "pages/applog/applog", "pages/addDevice/addDevice", "pages/addDevicelog/addDeviceLog", - "pages/searchLog/searchLog" + "pages/searchLog/searchLog", + "pages/notice/notice" ], "window": { - "backgroundColor": "#F6F6F6", + "backgroundColor": "#E6D480", "backgroundTextStyle": "light", "navigationBarBackgroundColor": "#FFCF00", "navigationBarTitleText": "智慧施工", @@ -46,11 +48,11 @@ "desc": "你的位置信息将用于小程序位置接口的效果展示" } }, + "requiredPrivateInfos": ["getLocation", "chooseLocation"], "networkTimeout": { "request": 30000, "connectSocket": 30000, "uploadFile": 30000, "downloadFile": 30000 - }, - "style": "v2" + } } \ No newline at end of file diff --git a/miniprogram/images/applocat.png b/miniprogram/images/applocat.png new file mode 100644 index 0000000..fe49f54 --- /dev/null +++ b/miniprogram/images/applocat.png Binary files differ diff --git a/miniprogram/images/back.png b/miniprogram/images/back.png new file mode 100644 index 0000000..32ac82d --- /dev/null +++ b/miniprogram/images/back.png Binary files differ diff --git a/miniprogram/images/bottom.png b/miniprogram/images/bottom.png new file mode 100644 index 0000000..d910e98 --- /dev/null +++ b/miniprogram/images/bottom.png Binary files differ diff --git a/miniprogram/images/header.png b/miniprogram/images/header.png new file mode 100644 index 0000000..6ea222e --- /dev/null +++ b/miniprogram/images/header.png Binary files differ diff --git a/miniprogram/images/login.png b/miniprogram/images/login.png index 8b73cc0..6471c46 100644 --- a/miniprogram/images/login.png +++ b/miniprogram/images/login.png Binary files differ diff --git a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss index 5a591fb..c9c35b5 100644 --- a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss +++ b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:100%;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:100%}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file +@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:650rpx;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:600rpx}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file diff --git a/miniprogram/pages/addDevice/addDevice.js b/miniprogram/pages/addDevice/addDevice.js index 2783674..78f00b7 100644 --- a/miniprogram/pages/addDevice/addDevice.js +++ b/miniprogram/pages/addDevice/addDevice.js @@ -1,5 +1,7 @@ // miniprogram/pages/addDevice/addDevice.js // import WxValidate from '../../utils/WxValidate.js' +var QQMapWX = require('../../libs/qqmap-wx-jssdk.js'); +var qqmapsdk; var app = getApp() Page({ @@ -11,32 +13,10 @@ canvasWidth: '', longitude: '', latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], + option1: [], personoption1: [], projectoption: [], + devtypeList:[], show: false, form: { devcode: "", @@ -59,7 +39,10 @@ project: "", area: "", street: "", - wellname: "" + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '', }, fileList: [] }, @@ -117,12 +100,14 @@ var that = this; //初始化表单内容为上次填写值 var cacheForms = wx.getStorageSync('cacheList') - if (cacheForms) { + cacheForms.photopath1='' + cacheForms.photopath2='' + cacheForms.photopath3='' + that.data.fileList=[] that.setData({ form: cacheForms, devcode: cacheForms.devcode, - }) } var form = that.data.form @@ -155,55 +140,89 @@ } }) + +//获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + that.setData({ + option1: welltypeArr + }) + } + } +}) + + //获取人员下拉列表 - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/getUser", + data:{ + tips:'repair' }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data.code == 200) { + var users = res.data.data + var personArr = []; + for (var i = 0; i < users.length; i++) { + var person = { + text: users[i].name, + value: users[i].name + }; + personArr.push(person); + } + that.setData({ + personoption1: personArr + }) } - that.setData({ - personoption1: personArr - }) } - }).catch(err => { - console.error(err); - }) + }) + - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - that.setData({ - projectoption: projectArr - }) + success(res){ + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); + } + that.setData({ + projectoption: projectArr + }) + } } - }).catch(err => { - console.error(err); - }) + }) + var installtime = 'form.installtimeFmt'; var dateNow = this.formatDate(); this.setData({ @@ -211,8 +230,40 @@ installtimeFmt: dateNow, [installtime]: dateNow, }); + + + + /** + * 获取设备类型下拉列表 + */ + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/deviceType", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var TypeList = res.data.data + var typeArr = []; + for (var i = 0; i < TypeList.length; i++) { + var type = { + text: TypeList[i].productName, + value: TypeList[i].productName + }; + typeArr.push(type); + } + that.setData({ + devtypeList: typeArr + }) + } + } + }) }, + + + /** * 生命周期函数--监听页面初次渲染完成 */ @@ -280,29 +331,7 @@ }, - - //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 - drawText: function (ctx, str, leftWidth, initHeight, titleHeight, canvasWidth) { - var lineWidth = 0; - var lastSubStrIndex = 0; //每次开始截取的字符串的索引 - for (let i = 0; i < str.length; i++) { - lineWidth += ctx.measureText(str[i]).width; - if (lineWidth > canvasWidth) { - ctx.fillText(str.substring(lastSubStrIndex, i), leftWidth, initHeight); //绘制截取部分 - initHeight = initHeight + leftWidth * 2; //22为字体的高度 - lineWidth = 0; - lastSubStrIndex = i; - // titleHeight += 40; - } - if (i == str.length - 1) { //绘制剩余部分 - ctx.fillText(str.substring(lastSubStrIndex, i + 1), leftWidth, initHeight); - } - } - // // 标题border-bottom 线距顶部距离 - // titleHeight = titleHeight + 10; - // return titleHeight - }, - + //验证表单 formValidate() { if (this.data.form.devcode == "") { @@ -312,27 +341,20 @@ }) return false } - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } if (this.data.form.wellcode == "") { wx.showToast({ icon: 'none', @@ -348,22 +370,10 @@ }) return false } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null) { + + if (this.data.form.installperson == "") { wx.showToast({ icon: 'none', title: '安装人员不能为空!', @@ -408,56 +418,90 @@ } return true; }, + //提交表单 formSubmit: function (event) { + console.log(this.data.form) + //表单参数验证 if (!this.formValidate()) { return false; } var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDevice', + //验证设备编号长度 + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/getDevTypeLength", data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceAdd/add" + code: encodeURI(this.data.form.devicetype) }, - }).then(res => { - if (res.result.code == 500) { - wx.showToast({ - title: '设备编号已安装!', - }) - } else if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - //用于回显 - wx.setStorageSync('cacheList', that.data.form) - //提交成功后提示用户操作 - if (res.confirm) { - wx.switchTab({ - url: '../earth/earth' - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (""==res.data.data ||res.data.data == that.data.form.devcode.length) { + that.saveDevice() + } else { //编号位数不对提示 + wx.showToast({ + icon: 'none', + title: '设备编号位数不对!', + duration: 1000 + }) + return false + } } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "提交失败", - }) }) }, + + //保存设备基本信息 + saveDevice() { + var that = this; + //设置照片路径 + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopathForm = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopathForm]: fileList[i].url.split("static/")[1] + }) + } + //表单提交 + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 500) { + wx.showToast({ + title: '设备编号已安装!', + }) + } else if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + //用于回显 + wx.setStorageSync('cacheList', that.data.form) + //提交成功后提示用户操作 + if (res.confirm) { + wx.switchTab({ + url: '../earth/earth' + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } + }, + fail(err) { + wx.showToast({ + title: '提交失败!', + }) + } + }) + }, + + //input 输入框设置值 confirm(event) { var that = this; var formValue = event.detail.value; @@ -466,8 +510,30 @@ that.setData({ [fromN]: formValue }) + //若输入是设备编号,自动获取设备类型 + if('devcode'==formName){ + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", + data: { + devcode: formValue, + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + that.setData({ + [formDevicetype]: res.data + }); + } + } + }) + } }, + //扫描设备获取编号和设备类型 scan() { var _this = this; wx.scanCode({ @@ -477,23 +543,28 @@ _this.setData({ [formdevcode]: devcode }); - wx.cloud.callFunction({ - name: 'findModeCode', + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", data: { devcode: devcode, - url: app.globalData.url + "appDeviceAdd/findModeCodeByCode" }, - }).then(res => { - if (res.result) { - var formDevicetype = 'form.devicetype' - _this.setData({ - [formDevicetype]: res.result - }); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + _this.setData({ + [formDevicetype]: res.data + }); + } } }) } }) }, + //粘贴经纬度 paste() { var _this = this; wx.getClipboardData({ @@ -510,9 +581,11 @@ longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), }); + _this.showAddress(_this.data.form.longitude,_this.data.form.latitude,_this) } }) }, + //设置经类型 selectValue(value) { var that = this; @@ -521,6 +594,16 @@ [wellType]: value.detail }) }, + + //设置设备类型 + selectDevType(event) { + var that = this; + var devtype = 'form.devicetype'; + that.setData({ + [devtype]: event.detail + }) + }, + //设置运维人员 selectpersonValue(event) { var that = this; var installPerson = 'form.installperson'; @@ -528,6 +611,7 @@ [installPerson]: event.detail }) }, + //设置项目 selectprojectValue(event) { var that = this; var project = 'form.project'; @@ -535,8 +619,41 @@ [project]: event.detail }) }, + showAddress :function(longitude, latitude, self) { + // 实例化腾讯地图API核心类 + qqmapsdk = new QQMapWX({ + key: 'BGPBZ-C5O3P-ROUDR-LWC4J-63EKH-V5FRX'//此处使用你自己申请的key + }) + // 腾讯地图调用接口 + qqmapsdk.reverseGeocoder({ + location: { + latitude: latitude, + longitude: longitude + }, + success: function (res) { + self.setData({ + 'form.area':res.result.address.slice(0,res.result.address.indexOf('区')+1), + 'form.street':res.result.address.slice(res.result.address.indexOf('区')+1) + }) + }, + fail: function (res) { + console.log(res); + }, + complete: function (res) { + } + }); + }, + //上传照片 afterRead(event) { var _this = this; + if (_this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '请先填写设备编号!\r\n否则水印中无编号', + duration: 2000 + }) + return false + } const { file } = event.detail; @@ -576,78 +693,8 @@ }) } }) - // 压缩图片 - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // //获取图片尺寸 - // wx.getImageInfo({ - // src: convertpath, - // success(res) { - // _this.setData({ - // canvasHeight: res.height, - // canvasWidth: res.width - // }) - // var ctx = wx.createCanvasContext('firstCanvas') - - // //将图片src放到cancas内,宽高为图片大小 - // ctx.drawImage(convertpath, 0, 0, res.width, res.height) - // //将声明的时间放入canvas - // ctx.setFontSize(30 * (res.width / 750)) //注意:设置文字大小必须放在填充文字之前,否则不生效 - // ctx.setFillStyle('blue') - // var text = "编号:" + _this.data.form.devcode + "\n经度:" + _this.data.form.longitude + "\n纬度:" + _this.data.form.latitude - // // _this.drawText(ctx,text,20, 70, 5, res.width) - // _this.drawText(ctx, text, 15 * (res.width / 750), 70 * (res.width / 750), 5, res.width) - - // // ctx.fillText(text, 0, 40) - // // ctx.strokeText(_this.data.form.devcode, 0, 30) - // //生成水印图 - // ctx.draw(false, function () { - // wx.canvasToTempFilePath({ - // canvasId: 'firstCanvas', - // success: (res) => { - // wx.compressImage({ - // src: res.tempFilePath, - // quality: 25, - // success: function (res) { - // //上传照片至服务器 - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: res.tempFilePath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // } - // }) - // //// - // } - // }) - // }) - // } - // }) - // } - // }); }, + //删除照片 deletePhoto(event) { var image_index = event.detail.index var fileList_new = this.data.fileList; diff --git a/miniprogram/pages/addDevice/addDevice.wxml b/miniprogram/pages/addDevice/addDevice.wxml index b0977e2..f12c254 100644 --- a/miniprogram/pages/addDevice/addDevice.wxml +++ b/miniprogram/pages/addDevice/addDevice.wxml @@ -5,18 +5,30 @@ - + + + + + + + + + + + + + - - + + - - - + + + @@ -29,13 +41,13 @@ - + - + - + - + @@ -54,8 +66,7 @@ - - + @@ -68,8 +79,8 @@ - - + + - 保存 + 保存 \ No newline at end of file diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.js b/miniprogram/pages/addDevicelog/addDeviceLog.js index cdec71b..a0dc6da 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.js +++ b/miniprogram/pages/addDevicelog/addDeviceLog.js @@ -3,681 +3,665 @@ var app = getApp(); Page({ - /** - * 页面的初始数据 - */ - data: { - pageName: '', - showMask: false, - today: new Date().getTime(), - longitude: '', - latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], - personoption1: [], - projectoption: [], - devcode: "", - deviceMode: "", - installtimeFmt: '', - show: false, - form: { - devcode: "", - wellcode: "", - welltype: "", - welldepth: "", - installheigt: "", - installperson: "", - installtimeFmt: "", - photopath: "", - factory: "", - workmsg: "", - position: "", - description: "", - longitude: "", - latitude: "", - longitude84: "", - latitude84: "", - devicetype: "", - project: "", - area: "", - street: "", - wellname: "" - }, - fileList: [], - detail: "" - }, + /** + * 页面的初始数据 + */ + data: { + pageName: '', + showMask: false, + today: new Date().getTime(), + longitude: '', + latitude: '', + option1: [], + personoption1: [], + projectoption: [], + devcode: "", + deviceMode: "", + installtimeFmt: '', + show: false, + form: { + devcode: "", + wellcode: "", + welltype: "", + welldepth: "", + installheigt: "", + installperson: "", + installtimeFmt: "", + photopath: "", + factory: "", + workmsg: "", + position: "", + description: "", + longitude: "", + latitude: "", + longitude84: "", + latitude84: "", + devicetype: "", + project: "", + area: "", + street: "", + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '' + }, + fileList: [], + detail: "", + markers: [{ + id: 100, + // iconPath: "../../images/point.png", + latitude: '', + longitude: '', + // label:'1', + width: 25, + height: 35 + }], + }, - onDisplay() { - this.setData({ - show: true - }); - }, - onClose() { - this.setData({ - show: false - }); - }, - formatDate() { - var date = new Date(); - // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; - var seperator1 = "-"; - var month = date.getMonth() + 1; - var strDate = date.getDate(); - var hour = date.getHours() - var minute = date.getMinutes() - var second = date.getSeconds() - month = month > 9 ? month : "0" + month; - strDate = strDate > 9 ? strDate : "0" + strDate; - hour = hour > 9 ? hour : "0" + hour; - minute = minute > 9 ? minute : "0" + minute; - second = second > 9 ? second : "0" + second; - var currentdate = - date.getFullYear() + - seperator1 + - month + - seperator1 + - strDate + - " " + - hour + ":" + - minute + ":" + - second; - return currentdate; + onDisplay() { + this.setData({ + show: true + }); + }, + onClose() { + this.setData({ + show: false + }); + }, + formatDate() { + var date = new Date(); + // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; + var seperator1 = "-"; + var month = date.getMonth() + 1; + var strDate = date.getDate(); + var hour = date.getHours() + var minute = date.getMinutes() + var second = date.getSeconds() + month = month > 9 ? month : "0" + month; + strDate = strDate > 9 ? strDate : "0" + strDate; + hour = hour > 9 ? hour : "0" + hour; + minute = minute > 9 ? minute : "0" + minute; + second = second > 9 ? second : "0" + second; + var currentdate = + date.getFullYear() + + seperator1 + + month + + seperator1 + + strDate + + " " + + hour + ":" + + minute + ":" + + second; + return currentdate; - }, - onConfirm(event) { - var installtime = 'form.installtimeFmt'; - this.setData({ - show: false, - installtimeFmt: this.formatDate(event.detail), - [installtime]: this.formatDate(event.detail), - }); - }, + }, + onConfirm(event) { + var installtime = 'form.installtimeFmt'; + this.setData({ + show: false, + installtimeFmt: this.formatDate(event.detail), + [installtime]: this.formatDate(event.detail), + }); + }, - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - var _this = this; - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" - }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); - } - _this.setData({ - personoption1: personArr - }) + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + var _this = this; + _this.setData({ + 'markers[0].latitude': Number(wx.getStorageSync('resultObject').latitude) , + 'markers[0].longitude': Number(wx.getStorageSync('resultObject').longitude), + // 'markers[0].label':'10', + 'markers[0].width': 18, + 'markers[0].id':1, + 'markers[0].height': 30, + latitude:Number(wx.getStorageSync('resultObject').latitude), + longitude:Number(wx.getStorageSync('resultObject').longitude) + }) + //获取人员下拉列表 + // wx.request({ + // method: "POST", + // url: app.globalData.httpsUrl + "deviceType/getUser", + // data:{ + // tips:'repair' + // }, + // header: { + // 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + // }, + // success(res) { + // if (res.data.code == 200) { + // var users = res.data.data + // var personArr = []; + // for (var i = 0; i < users.length; i++) { + // var person = { + // text: users[i].name, + // value: users[i].name + // }; + // personArr.push(person); + // } + // _this.setData({ + // personoption1: personArr + // }) + // } + // } + // }) + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); } - }).catch(err => { - console.error(err); - }) - - - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" - }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - _this.setData({ - projectoption: projectArr - }) - } - }).catch(err => { - console.error(err); - }) - - if (options.pageName) { - this.setData({ - pageName: options.pageName - }) - } - - if (options.detail) { - - var formObject = JSON.parse(options.detail); _this.setData({ - form: formObject, - detail: options.detail + projectoption: projectArr }) - - _this.setData({ - ['form.installperson']: "", - ['form.installtimeFmt']: "", - ['form.workmsg']: "", - ['form.description']: "" - }) - - const { - fileList = [] - } = _this.data; - if (formObject.photopath1 != "") { - var file1 = { - url: app.globalData.url + "static/" + formObject.photopath1 - } - fileList.push(file1) - } - if (formObject.photopath2 != "") { - var file2 = { - url: app.globalData.url + "static/" + formObject.photopath2 - } - fileList.push(file2) - } - if (formObject.photopath3 != "") { - var file3 = { - url: app.globalData.url + "static/" + formObject.photopath3 - } - fileList.push(file3) - } - - _this.setData({ - fileList - }); } - var installtime = 'form.installtimeFmt'; - var dateNow = this.formatDate(); - this.setData({ - installtimeFmt: dateNow, - [installtime]: dateNow, - }); - }, + } + }) - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { + //获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + _this.setData({ + option1: welltypeArr + }) + } + } +}) - }, + //跳转时带入参数返回哪页 + if (options.pageName) { + this.setData({ + pageName: options.pageName + }) + } + //跳转时带入参数设备的安装信息 + if (wx.getStorageSync('resultObject')) { + var formObject = wx.getStorageSync('resultObject') + _this.setData({ + form: formObject, + detail: formObject + }) - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { + _this.setData({ + ['form.installperson']: app.globalData.userName, + ['form.installtimeFmt']: "", + ['form.workmsg']: "", + ['form.description']: "" + }) - }, + const { + fileList = [] + } = _this.data; + if (formObject.photopath1 != "") { + var file1 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath1 + } + fileList.push(file1) + } + if (formObject.photopath2 != "") { + var file2 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath2 + } + fileList.push(file2) + } + if (formObject.photopath3 != "") { + var file3 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath3 + } + fileList.push(file3) + } + _this.setData({ + fileList + }); + } + var installtime = 'form.installtimeFmt'; + var dateNow = this.formatDate(); + this.setData({ + installtimeFmt: dateNow, + [installtime]: dateNow, + }); + }, - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, - }, + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + wx.removeStorageSync('resultObject') + }, - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, - }, + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { + }, - }, + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { + }, - }, + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { + }, - }, + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + }, - /** - * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true - **/ + /** + * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true + **/ - isNumber: function (val) { + isNumber: function (val) { - var regPos = /^[0-9]*$/; //非负浮点数 - var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数 - if (regPos.test(val) || regNeg.test(val)) { - return false; - } else { - return true; - } + var regPos = /^[0-9]*$/; //非负浮点数 + var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数 + if (regPos.test(val) || regNeg.test(val)) { + return false; + } else { + return true; + } - }, + }, - formValidate() { + formValidate() { - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } - if (this.data.form.wellcode == "") { - wx.showToast({ - icon: 'none', - title: '井编号不能为空!', - }) - return false - } - if (this.data.form.devicetype == "") { - wx.showToast({ - icon: 'none', - title: '设备类型不能为空!', - }) - return false - } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + if (this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '设备编号不能为空!', + }) + return false + } + if (this.data.form.wellcode == "") { + wx.showToast({ + icon: 'none', + title: '井编号不能为空!', + }) + return false + } + if (this.data.form.devicetype == "") { + wx.showToast({ + icon: 'none', + title: '设备类型不能为空!', + }) + return false + } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null || - this.data.form.installperson == '') { - wx.showToast({ - icon: 'none', - title: '运维人员不能为空!', - }) - return false - } - if (this.data.form.project == "") { - wx.showToast({ - icon: 'none', - title: '所属项目不能为空!', - }) - return false - } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } + if (this.data.form.installperson == null || + this.data.form.installperson == '') { + wx.showToast({ + icon: 'none', + title: '运维人员不能为空!', + }) + return false + } + if (this.data.form.project == "") { + wx.showToast({ + icon: 'none', + title: '所属项目不能为空!', + }) + return false + } - if (this.data.form.welldepth != null) { - if (this.isNumber(this.data.form.welldepth)) { - wx.showToast({ - icon: 'none', - title: '井深必须为数值!', - }) - return false - } - } - if (this.data.form.installheigt != null) { - if (this.isNumber(this.data.form.installheigt)) { - wx.showToast({ - icon: 'none', - title: '到井口距离必须为数值!', - }) - return false - } - } - - return true; - }, - - changeMsg: function () { - var formNew = this.data.form; - var formOld = JSON.parse(this.data.detail); - var descpNew = ""; - if (formNew.devcode != formOld.devcode) { - descpNew += "修改设备编号,原编号:" + formOld.devcode + ",新编号:" + formNew.devcode + ";" - } - if (formNew.devicetype != formOld.devicetype) { - descpNew += "修改设备类型,原设备类型:" + formOld.devicetype + ",新设备类型:" + formNew.devicetype + ";" - } - if (formNew.area != formOld.area) { - descpNew += "修改区,原区:" + formOld.area + ",新区:" + formNew.area + ";" - } - if (formNew.street != formOld.street) { - descpNew += "修改街道,原街道:" + formOld.street + ",新街道:" + formNew.street + ";" - } - if (formNew.wellname != formOld.wellname) { - descpNew += "修改井名称,原井名称:" + formOld.wellname + ",新井名称:" + formNew.wellname + ";" - } - if (formNew.factory != formOld.factory) { - descpNew += "修改权属单位,原权属单位:" + formOld.factory + ",新权属单位:" + formNew.factory + ";" - } - if (formNew.installheigt != formOld.installheigt) { - descpNew += "修改井口距离,原井口距离:" + formOld.installheigt + ",新井口距离:" + formNew.installheigt + ";" - } - if (formNew.installperson != formOld.installperson) { - descpNew += "修改运维人员,原运维人员:" + formOld.installperson + ",新运维人员:" + formNew.installperson + ";" - } - if (formNew.latitude != formOld.latitude) { - descpNew += "修改纬度,原纬度:" + formOld.latitude + ",新纬度:" + formNew.latitude + ";" - } - if (formNew.longitude != formOld.longitude) { - descpNew += "修改经度,原经度:" + formOld.longitude + ",新经度:" + formNew.longitude + ";" - } - if (formNew.position != formOld.position) { - descpNew += "修改位置描述,原位置:" + formOld.position + ",新位置:" + formNew.position + ";" - } - if (formNew.wellcode != formOld.wellcode) { - descpNew += "修改井编号,原编号:" + formOld.wellcode + ",新编号:" + formNew.wellcode + ";" - } - if (formNew.welldepth != formOld.welldepth) { - descpNew += "修改井深,原井深:" + formOld.welldepth + ",新井深:" + formNew.welldepth + ";" - } - if (formNew.welltype != formOld.welltype) { - descpNew += "修改井类型,原井类型:" + formOld.welltype + ",新井类型:" + formNew.welltype + ";" - } - if (formNew.project != formOld.project) { - descpNew += "修改所属项目,原项目:" + formOld.project + ",新项目:" + formNew.project + ";" - } - if (this.data.photopath1 != formOld.photopath1 || - this.data.photopath2 != formOld.photopath2 || - this.data.photopath3 != formOld.photopath3) { - descpNew += "修改照片;" - } - if ("" != formNew.description) { - descpNew += formNew.description; - } - this.setData({ - ['form.description']: descpNew + if (this.data.form.welldepth != null) { + if (this.isNumber(this.data.form.welldepth)) { + wx.showToast({ + icon: 'none', + title: '井深必须为数值!', }) - }, + return false + } + } + if (this.data.form.installheigt != null) { + if (this.isNumber(this.data.form.installheigt)) { + wx.showToast({ + icon: 'none', + title: '到井口距离必须为数值!', + }) + return false + } + } - formSubmit: function (event) { + return true; + }, - if (!this.formValidate()) { - return false; - } - this.changeMsg(); - var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDeviceLog', - data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceLog/add" - }, - }).then(res => { - // var resultObj=JSON.parse(res.result); - if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - if (res.confirm) { - wx.switchTab({ - url: that.data.pageName - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) - } - }).catch(err => { - console.error(err) - wx.showToast({ - title: "提交失败", - }) - }) - }, - confirm(event) { - var that = this; - var formValue = event.detail.value; - var formName = event.target.dataset.id; - var fromN = 'form.' + [formName]; - that.setData({ - [fromN]: formValue - }) - }, + //获取与上次修改的信息 + changeMsg: function () { + var formNew = this.data.form; + console.log(this.data.detail) + var formOld = JSON.parse(this.data.detail); + var descpNew = ""; + if (formNew.devcode != formOld.devcode) { + descpNew += "修改设备编号,原值:" + formOld.devcode + ",新值:" + formNew.devcode + ";" + } + if (formNew.devicetype != formOld.devicetype) { + descpNew += "修改设备类型,原值:" + formOld.devicetype + ",新值:" + formNew.devicetype + ";" + } + if (formNew.area != formOld.area) { + descpNew += "修改区,原值:" + formOld.area + ",新值:" + formNew.area + ";" + } + if (formNew.street != formOld.street) { + descpNew += "修改街道,原值:" + formOld.street + ",新值:" + formNew.street + ";" + } + if (formNew.wellname != formOld.wellname) { + descpNew += "修改井名称,原值:" + formOld.wellname + ",新值:" + formNew.wellname + ";" + } + if (formNew.factory != formOld.factory) { + descpNew += "修改权属单位,原值:" + formOld.factory + ",新值:" + formNew.factory + ";" + } + if (formNew.installheigt != formOld.installheigt) { + descpNew += "修改井口距离,原值:" + formOld.installheigt + ",新值:" + formNew.installheigt + ";" + } + if (formNew.installperson != formOld.installperson) { + descpNew += "修改运维人员,原值:" + formOld.installperson + ",新值:" + formNew.installperson + ";" + } + if (formNew.latitude != formOld.latitude) { + descpNew += "修改纬度,原值:" + formOld.latitude + ",新值:" + formNew.latitude + ";" + } + if (formNew.longitude != formOld.longitude) { + descpNew += "修改经度,原值:" + formOld.longitude + ",新值:" + formNew.longitude + ";" + } + if (formNew.position != formOld.position) { + descpNew += "修改位置描述,原值:" + formOld.position + ",新值:" + formNew.position + ";" + } + if (formNew.wellcode != formOld.wellcode) { + descpNew += "修改井编号,原值:" + formOld.wellcode + ",新值:" + formNew.wellcode + ";" + } + if (formNew.welldepth != formOld.welldepth) { + descpNew += "修改井深,原值:" + formOld.welldepth + ",新值:" + formNew.welldepth + ";" + } + if (formNew.welltype != formOld.welltype) { + descpNew += "修改井类型,原值:" + formOld.welltype + ",新值:" + formNew.welltype + ";" + } + if (formNew.project != formOld.project) { + descpNew += "修改所属项目,原值:" + formOld.project + ",新值:" + formNew.project + ";" + } + if (this.data.form.photopath1 != formOld.photopath1 || + this.data.form.photopath2 != formOld.photopath2 || + this.data.form.photopath3 != formOld.photopath3) { + descpNew += "修改照片;" + } + if ("" != formNew.description) { + descpNew += formNew.description; + } + this.setData({ + ['form.description']: descpNew + }) + }, - scan() { + //提交表单 + formSubmit: function (event) { - wx.scanCode({ - success(res) { - console.log(res) - } - }) + //表单验证 + if (!this.formValidate()) { + return false; + } + //自动生成修改内容 + this.changeMsg(); + //提交权限限制(只有施工人员能修改) + if(app.globalData.role!='repair'){ + wx.showToast({ + icon: 'none', + title: '无权限修改', + duration:2000 + }) + return false + } + var that = this; + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopath = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopath]: fileList[i].url.split("static/")[1] + }) + } + delete that.data.form.installtime + delete that.data.form.createtime + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - paste() { - var _this = this; - wx.getClipboardData({ - success: function (res) { - var longitude = 'form.longitude'; - var latitude = 'form.latitude'; - var longitude84 = 'form.longitude84'; - var latitude84 = 'form.latitude84'; - _this.setData({ - [longitude]: parseFloat(res.data.split(",", 4)[1]).toFixed(6), - [latitude]: parseFloat(res.data.split(",", 4)[0]).toFixed(6), - [longitude84]: "" == (res.data.split(",", 4)[3]) ? "" : parseFloat(res.data.split(",", 4)[3]).toFixed(6), - [latitude84]: "" == (res.data.split(",", 4)[2]) ? "" : parseFloat(res.data.split(",", 4)[2]).toFixed(6), - longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), - latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), - }); - } - }) - }, - selectValue(value) { - var that = this; - var wellType = 'form.welltype'; - that.setData({ - [wellType]: value.detail - }) - }, - selectpersonValue(event) { - var that = this; - var installPerson = 'form.installperson'; - that.setData({ - [installPerson]: event.detail - }) - }, - selectprojectValue(event) { - var that = this; - var project = 'form.project'; - that.setData({ - [project]: event.detail, - showMask: true - }) - }, - open() { - this.setData({ - showMask: true - }) - }, - close() { - this.setData({ - showMask: false - }) - }, - afterRead(event) { - var _this = this; - const { - file - } = event.detail; - const { - fileList = [] - } = _this.data; - var convertpath = ""; - wx.compressImage({ - src: event.detail.file.path, - quality: 25, - success: function (res) { - convertpath = res.tempFilePath; - wx.uploadFile({ - url: app.globalData.httpsUrl + "appDeviceAdd/fileUploadMarker", - filePath:convertpath, - name: 'file', - formData: { - 'text': "编号:" + _this.data.form.devcode + "经度:" + _this.data.form.longitude + "纬度:" + _this.data.form.latitude - }, - header: { - "Content-Type": "multipart/form-data", - 'accept': 'application/json', - }, - success(res) { - if (res.data) { - var url = JSON.parse(res.data); - fileList.push({ - ...file, - url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - }); - _this.setData({ - fileList - }); - } - } + success(res) { + if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + if (res.confirm) { + wx.switchTab({ + url: that.data.pageName }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') } - }) - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // // var base64 = "data:image/png;base64," + wx.getFileSystemManager().readFileSync(convertpath, 'base64'); - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: convertpath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // // wx.cloud.callFunction({ - // // name: 'uploadFile', - // // data: { - // // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // // fileBase64: base64 - // // }, - // // success: function (res) { - // // if (res.result) { - // // fileList.push({ - // // ...file, - // // url: app.globalData.url + "static/" + res.result.data.replace(/\\/g, "/") - // // }); - // // _this.setData({ - // // fileList - // // }); - // // } - // // }, - // // complete: res => { - // // }, - // // }) - // } - // }); + } + }) + } + }, + fail(err) { + wx.showToast({ + title: "提交失败", + }) + } + }) + }, + //报存录入的input信息 + confirm(event) { + var that = this; + var formValue = event.detail.value; + var formName = event.target.dataset.id; + var fromN = 'form.' + [formName]; + that.setData({ + [fromN]: formValue + }) + }, + + //扫码 + scan() { + + wx.scanCode({ + success(res) { + console.log(res) + } + }) + }, + //粘贴经纬度 + paste() { + var _this = this; + wx.getClipboardData({ + success: function (res) { + var longitude = 'form.longitude'; + var latitude = 'form.latitude'; + var longitude84 = 'form.longitude84'; + var latitude84 = 'form.latitude84'; + _this.setData({ + [longitude]: parseFloat(res.data.split(",", 4)[1]).toFixed(6), + [latitude]: parseFloat(res.data.split(",", 4)[0]).toFixed(6), + [longitude84]: "" == (res.data.split(",", 4)[3]) ? "" : parseFloat(res.data.split(",", 4)[3]).toFixed(6), + [latitude84]: "" == (res.data.split(",", 4)[2]) ? "" : parseFloat(res.data.split(",", 4)[2]).toFixed(6), + longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), + latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), + }); + } + }) + }, + selectValue(value) { + var that = this; + var wellType = 'form.welltype'; + that.setData({ + [wellType]: value.detail + }) + }, + //运维人员默认为登录人 + // selectpersonValue(event) { + // var that = this; + // var installPerson = 'form.installperson'; + // that.setData({ + // [installPerson]: event.detail + // }) + // }, + selectprojectValue(event) { + var that = this; + var project = 'form.project'; + that.setData({ + [project]: event.detail, + showMask: true + }) + }, + + open() { + this.setData({ + showMask: true + }) + }, + //隐藏textarea,防止遮挡 + close() { + this.setData({ + showMask: false + }) + }, + //上传照片 + afterRead(event) { + var _this = this; + const { + file + } = event.detail; + const { + fileList = [] + } = _this.data; + var convertpath = ""; + wx.compressImage({ + src: event.detail.file.path, + quality: 25, + success: function (res) { + convertpath = res.tempFilePath; + wx.uploadFile({ + url: app.globalData.httpsUrl + "appDeviceAdd/fileUploadMarker", + filePath: convertpath, + name: 'file', + formData: { + 'text': "编号:" + _this.data.form.devcode + "经度:" + _this.data.form.longitude + "纬度:" + _this.data.form.latitude }, - deletePhoto(event) { - var that = this - var image_index = event.detail.index - var fileList_new = that.data.fileList; - wx.showModal({ - content: '确定删除照片?', - success: function (res) { - if (res.confirm) { - fileList_new.splice(image_index, 1); - that.setData({ - fileList: fileList_new - }) - wx.cloud.callFunction({ - name: 'deletePhoto', - data: { - url: app.globalData.url + "appDeviceLog/deletePhoto", - devcode: that.data.form.devcode, - pathIndex: image_index - }, - success: function (res) {}, - complete: res => {}, - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + "Content-Type": "multipart/form-data", + 'accept': 'application/json', }, - }) \ No newline at end of file + success(res) { + if (res.data) { + var url = JSON.parse(res.data); + fileList.push({ + ...file, + url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") + }); + _this.setData({ + fileList + }); + } + } + }) + } + }) + }, + //删除照片 + deletePhoto(event) { + var that = this + var image_index = event.detail.index + var fileList_new = that.data.fileList; + wx.showModal({ + content: '确定删除照片?', + success: function (res) { + if (res.confirm) { + fileList_new.splice(image_index, 1); + that.setData({ + fileList: fileList_new + }) + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deletePhoto", + data: { + devcode: that.data.form.devcode + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) {} + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } +}) \ No newline at end of file diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.wxml b/miniprogram/pages/addDevicelog/addDeviceLog.wxml index 38620d4..b10cc7d 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.wxml +++ b/miniprogram/pages/addDevicelog/addDeviceLog.wxml @@ -1,15 +1,21 @@ - + + + + + - + - - + + - - + + - + @@ -39,24 +45,25 @@ - - - + + + - + - + + @@ -64,7 +71,7 @@ - + @@ -79,9 +86,9 @@ - + - 保存 + 保存 diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.wxss b/miniprogram/pages/addDevicelog/addDeviceLog.wxss index ee0b75c..08d5fd7 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.wxss +++ b/miniprogram/pages/addDevicelog/addDeviceLog.wxss @@ -24,6 +24,17 @@ display: flex; align-items: center; } +.map-view{ + width: 750rpx; + height: 485rpx; + position: fixed; + top: 0px; + left: 0px; + z-index: 999; +} +.content{ + margin-top: 495rpx; +} .left { width: 210rpx; diff --git a/miniprogram/pages/addFunction/addFunction.js b/miniprogram/pages/addFunction/addFunction.js deleted file mode 100644 index 4966be3..0000000 --- a/miniprogram/pages/addFunction/addFunction.js +++ /dev/null @@ -1,60 +0,0 @@ -// pages/addFunction/addFunction.js - -const code = `// 云函数入口函数 -exports.main = (event, context) => { - console.log(event) - console.log(context) - return { - sum: event.a + event.b - } -}` - -Page({ - - data: { - result: '', - canIUseClipboard: wx.canIUse('setClipboardData'), - }, - - onLoad: function (options) { - - }, - - copyCode: function() { - wx.setClipboardData({ - data: code, - success: function () { - wx.showToast({ - title: '复制成功', - }) - } - }) - }, - - testFunction() { - wx.cloud.callFunction({ - name: 'sum', - data: { - a: 1, - b: 2 - }, - success: res => { - wx.showToast({ - title: '调用成功', - }) - this.setData({ - result: JSON.stringify(res.result) - }) - }, - fail: err => { - wx.showToast({ - icon: 'none', - title: '调用失败', - }) - console.error('[云函数] [sum] 调用失败:', err) - } - }) - }, - -}) - diff --git a/miniprogram/pages/addFunction/addFunction.json b/miniprogram/pages/addFunction/addFunction.json deleted file mode 100644 index a9a50c5..0000000 --- a/miniprogram/pages/addFunction/addFunction.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "navigationBarTitleText": "云函数指引", - "usingComponents": {} -} \ No newline at end of file diff --git a/miniprogram/pages/addFunction/addFunction.wxml b/miniprogram/pages/addFunction/addFunction.wxml deleted file mode 100644 index 3a10626..0000000 --- a/miniprogram/pages/addFunction/addFunction.wxml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - 测试云函数 - - - 期望输出:{"sum":3} - - - 调用结果:{{result}} - - - - - 新增云函数 - 1. 在云函数根目录 cloudfunctions 上右键选择新建云函数,命名为 sum - 2. 在创建的 cloudfunctions/sum/index.js 文件中添加如下代码 - - - 3. 在 cloudfunctions/sum 目录上右键上传并部署 - 4. 点击测试云函数测试 - 5. 打开云开发云函数管理页,选择 sum 云函数 - 6. 查看 sum 的调用日志 - 进阶:可在云函数中使用 wx-server-sdk 操作数据库,文件存储和调用其他云函数,详见文档 - - - diff --git a/miniprogram/pages/addFunction/addFunction.wxss b/miniprogram/pages/addFunction/addFunction.wxss deleted file mode 100644 index 7ac8619..0000000 --- a/miniprogram/pages/addFunction/addFunction.wxss +++ /dev/null @@ -1,3 +0,0 @@ -/* pages/addFunction/addFunction.wxss */ - -@import "../../style/guide.wxss"; \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.js b/miniprogram/pages/applog/applog.js index 0e8c185..189e61f 100644 --- a/miniprogram/pages/applog/applog.js +++ b/miniprogram/pages/applog/applog.js @@ -13,98 +13,25 @@ isSeach: "false", params: {}, total: 0, - show: false + show: false, + delBtnWidth: 100, //删除按钮宽度单位(rpx) + activeIndex: -1, + list_style: '' }, - - touchE: function (e) { - // console.log(e); - var that = this - if (e.changedTouches.length == 1) { - //手指移动结束后触摸点位置的X坐标 - var endX = e.changedTouches[0].clientX; - //触摸开始与结束,手指移动的距离 - var disX = that.data.startX - endX; - var delBtnWidth = that.data.delBtnWidth; - //如果距离小于删除按钮的1/2,不显示删除按钮 - var txtStyle = disX > delBtnWidth / 2 ? "left:-" + delBtnWidth + "rpx" : "left:0rpx"; - - //获取手指触摸的是哪一项 - var index = e.currentTarget.dataset.index; - var list = that.data.deviceloglist; - list[index].txtStyle = txtStyle; - //更新列表的状态 - that.setData({ - deviceloglist: list - }); - } - }, - //手指触摸动作开始 记录起点X坐标 - touchstart: function (e) { - //开始触摸时 重置所有删除 - this.data.deviceloglist.forEach(function (v, i) { - if (v.isTouchMove) //只操作为true的 - v.isTouchMove = false; - }) - this.setData({ - startX: e.changedTouches[0].clientX, - startY: e.changedTouches[0].clientY, - deviceloglist: this.data.deviceloglist - }) - }, - //滑动事件处理 - touchmove: function (e) { - var that = this, - index = e.currentTarget.dataset.index, //当前索引 - startX = that.data.startX, //开始X坐标 - startY = that.data.startY, //开始Y坐标 - touchMoveX = e.changedTouches[0].clientX, //滑动变化坐标 - touchMoveY = e.changedTouches[0].clientY, //滑动变化坐标 - //获取滑动角度 - angle = that.angle({ - X: startX, - Y: startY - }, { - X: touchMoveX, - Y: touchMoveY - }); - that.data.deviceloglist.forEach(function (v, i) { - v.isTouchMove = false - //滑动超过30度角 return - if (Math.abs(angle) > 30) return; - if (i == index) { - if (touchMoveX > startX) //右滑 - v.isTouchMove = false - else //左滑 - v.isTouchMove = true - } - }) - //更新数据 - that.setData({ - deviceloglist: that.data.deviceloglist - }) - }, - /** - * 计算滑动角度 - * @param {Object} start 起点坐标 - * @param {Object} end 终点坐标 - */ - angle: function (start, end) { - var _X = end.X - start.X, - _Y = end.Y - start.Y - //返回角度 /Math.atan()返回数字的反正切值 - return 360 * Math.atan(_Y / _X) / (2 * Math.PI); - }, - /** - * 生命周期函数--监听页面加载var_this=this; - */ onLoad: function (options) { - if (options.params) { this.setData({ params: JSON.parse(options.params), isSeach: "true" }) this.initPages() + }else{ + this.setData({ + show: false + }) + //清空参数,重新加载 + this.clearParams(); + this.initPages(); } }, @@ -116,20 +43,33 @@ }, + //点击tabBar事件 + onTabItemTap(item) { + //隐藏历史显示总记录条数 + this.setData({ + show: false + }) + //清空参数,重新加载 + this.clearParams(); + this.initPages(); + }, + + /** * 生命周期函数--监听页面显示 */ onShow: function (options) { - this.setData({ - show:false - }) - if (this.data.isSeach == "false") { - this.clearParams(); - this.initPages(); - } - this.setData({ - isSeach: "false" - }) + + // this.setData({ + // show: false + // }) + // if (this.data.isSeach == "false") { + // this.clearParams(); + // this.initPages(); + // } + // this.setData({ + // isSeach: "false" + // }) }, /** @@ -167,6 +107,119 @@ }, + + //手指触摸动作开始 记录起点X坐标 + touchstart: function (e) { + //开始触摸时 重置所有删除 + this.data.deviceloglist.forEach(function (v, i) { + if (v.isTouchMove) //只操作为true的 + v.isTouchMove = false; + }) + this.setData({ + startX: e.changedTouches[0].clientX, + startY: e.changedTouches[0].clientY, + deviceloglist: this.data.deviceloglist + }) + }, + + //滑动事件处理 + touchmove: function (e) { + var that = this, + index = e.currentTarget.dataset.index, //当前索引 + startX = that.data.startX, //开始X坐标 + startY = that.data.startY, //开始Y坐标 + touchMoveX = e.changedTouches[0].clientX, //滑动变化坐标 + touchMoveY = e.changedTouches[0].clientY, //滑动变化坐标 + //获取滑动角度 + angle = that.angle({ + X: startX, + Y: startY + }, { + X: touchMoveX, + Y: touchMoveY + }); + that.data.deviceloglist.forEach(function (v, i) { + // v.isTouchMove = false + //滑动超过30度角 return + if (Math.abs(angle) > 30) return; + if (i == index) { + if (touchMoveX > startX) //右滑 + v.isTouchMove = false + else //左滑 + v.isTouchMove = true + } + }) + //更新数据 + that.setData({ + deviceloglist: that.data.deviceloglist + }) + }, + + /** + * 计算滑动角度 + * @param {Object} start 起点坐标 + * @param {Object} end 终点坐标 + */ + angle: function (start, end) { + var _X = end.X - start.X, + _Y = end.Y - start.Y + //返回角度 /Math.atan()返回数字的反正切值 + return 360 * Math.atan(_Y / _X) / (2 * Math.PI); + }, + + //删除事件 + delItem: function (e) { + if(app.globalData.role!='repair'){ + wx.showToast({ + icon: 'none', + title: '无权限删除', + duration:2000 + }) + return false + } + var that = this + wx.showModal({ + content: '是否删除?', + success: function (res) { + if (res.confirm) { + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/delete", + data: { + appDeviceAddId: e.currentTarget.dataset.devid + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if(res.data.code=='200'){ + that.data.deviceloglist.splice(e.currentTarget.dataset.index, 1) + that.setData({ + deviceloglist: that.data.deviceloglist, + total: that.data.deviceloglist.length + }) + wx.showToast({ + title: '删除成功!', + icon: 'none', + duration: 1000 + }) + } + }, + fail(err) { + wx.showToast({ + title: '删除失败!', + icon: 'none', + duration: 2000 + }) + } + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + }, + showLoading: function (message) { if (wx.showLoading) { // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 @@ -199,95 +252,105 @@ deviceloglist: [] }) }, + //查询列表数据 initPages: function () { var that = this + that.setData({ + show: false + }) var offsetValue = that.data.deviceloglist.length % 15 > 0 ? parseInt(that.data.deviceloglist.length / 15) + 2 : parseInt(that.data.deviceloglist.length / 15) + 1 - wx.cloud.callFunction({ - name: 'devicelog', + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/listPage", data: { devcode: that.data.params.devcode, devtype: that.data.params.devtype, installtimeFmt: that.data.params.installtimeFmt, project: that.data.params.project, installPerson: that.data.params.installPerson, - url: app.globalData.url + "appDeviceLog/listPage", limit: 15, offset: offsetValue }, - }).then(res => { - if (res.result.data.rows.length > 0) { - var resultJson = res.result - that.setData({ - deviceloglist: that.data.deviceloglist.concat(resultJson.data.rows) - }) - } else if (that.data.deviceloglist.length > 0) { - that.setData({ - show: true, - total: that.data.deviceloglist.length - }) - wx.showToast({ - title: '数据已全部加载完', - icon: 'none', - duration: 2000 - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.data.rows.length > 0) { + var resultJson = res.data + var listArr = resultJson.data.rows + listArr.forEach(function (v, i) { + listArr[i]['isTouchMove'] = false + }) + that.setData({ + deviceloglist: that.data.deviceloglist.concat(listArr) + }) + } else if (that.data.deviceloglist.length > 0) { + that.setData({ + show: true, + total: that.data.deviceloglist.length + }) + wx.showToast({ + title: '数据已全部加载完', + icon: 'none', + duration: 2000 + }) + } + if (offsetValue == 1 && res.data.data.rows.length < 15) { + that.setData({ + show: true, + total: that.data.deviceloglist.length + }) + } } - if(offsetValue==1&&res.result.data.rows.length<15){ - that.setData({ - show: true, - total: that.data.deviceloglist.length - }) - } - // console.log(res); - }).catch(err => { - console.error(err); }) + }, addDetail: function (event) { - this.showLoading("数据请求中..."); - wx.cloud.callFunction({ - name: 'deviceDetail', + var that = this + that.showLoading("数据请求中..."); + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deviceDetail", data: { devcode: event.target.dataset.devcode, - url: app.globalData.url + "appDeviceLog/deviceDetail", }, - }).then(res => { - this.hideLoading(); - var resultObject = JSON.parse(res.result); - var pageName = '../applog/applog' - if (resultObject.code == 200) { - wx.navigateTo({ - url: '../addDevicelog/addDeviceLog?detail=' + - JSON.stringify(resultObject.data) + "&pageName=" + pageName - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + that.hideLoading(); + // var resultObject = JSON.parse(res.data); + var resultObject = res.data; + var pageName = '../applog/applog' + if (resultObject.code == 200) { + wx.setStorageSync('resultObject', resultObject.data) + wx.navigateTo({ + url: '../addDevicelog/addDeviceLog?detail=' + "&pageName=" + pageName + }) + } + }, + fail(err) { + that.hideLoading(); } - }).catch(err => { - this.hideLoading() }) + }, add: function (event) { - wx.reLaunch({ - url: '../earth/earth?devcode=' + event.target.dataset.devcode - // url: '../earth/earth' + app.globalData.devcode = event.target.dataset.devcode; + wx.switchTab({ + url: '../earth/earth' }) + // wx.reLaunch({ + // url: '../earth/earth?devcode=' + event.target.dataset.devcode + // // url: '../earth/earth' + // }) }, onSearch: function () { + var _this = this wx.navigateTo({ - url: '../searchLog/searchLog' + url: '../searchLog/searchLog?params=' + JSON.stringify(_this.data.params) }) - }, - // initPages: function () { - // wx.cloud.callFunction({ - // name: 'devicelog' - // }).then(res => { - // var that = this; - // var jsonList = JSON.parse(res.result) - // that.setData({ - // deviceloglist: jsonList.data.rows - // }) - // console.log(res); - // }).catch(err => { - // console.error(err); - // }) - // } + } }) \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.wxml b/miniprogram/pages/applog/applog.wxml index e9a2352..2bfd041 100644 --- a/miniprogram/pages/applog/applog.wxml +++ b/miniprogram/pages/applog/applog.wxml @@ -1,54 +1,59 @@ - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {{item.devcode}} {{item.devicetype}} + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + {{item.devcode}} {{item.devicetype}} + + {{item.project}} {{item.installtime}}- {{item.installperson}} - - - - - + + + + + + 删除 - - - + + - 共计:{{total}}台 - + 共计:{{total}}台 + \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.wxss b/miniprogram/pages/applog/applog.wxss index 6d3428b..e6e8983 100644 --- a/miniprogram/pages/applog/applog.wxss +++ b/miniprogram/pages/applog/applog.wxss @@ -22,16 +22,18 @@ position: fixed; width: 100%; top: 0rpx; + z-index: 9999; /* margin-bottom: 100rpx; */ } .log-list { /* height: 100rpx; */ - /* display: flex; */ - + display: flex; + width: 100%; padding: 2px; margin-top: 2px; border-bottom: 1px solid #e5e5e5; + overflow: hidden } @@ -53,23 +55,29 @@ left: 35%; margin: 20rpx } - .del { - width: 90px; + /* display: flex; */ + width: 100rpx; display: flex; flex-direction: column; align-items: center; justify-content: center; - color: #fff; - -webkit-transform: translateX(90px); - transform: translateX(90px); - -webkit-transition: all 0.4s; + /* -webkit-transform: translateX(100rpx); */ + transform: translateX(100rpx); + /* -webkit-transition: all 0.4s; */ transition: all 0.4s; - font-size: 35rpx; + color: #fff; + background-color: #fe3e2f; +} +.logrow{ + width: 100%; + transform: translateX(100rpx); + /* -webkit-transform: translateX(100px); */ + margin-left: -100rpx; } -.touch-move-active .content, +.touch-move-active .logrow, .touch-move-active .del { - -webkit-transform: translateX(0); - transform: translateX(0); +/* -webkit-transform: translateX(0); */ +transform: translateX(0); } \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.js b/miniprogram/pages/deployFunctions/deployFunctions.js deleted file mode 100644 index a76b144..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.js +++ /dev/null @@ -1,66 +0,0 @@ -// pages/deployFunctions/deployFunctions.js -Page({ - - /** - * 页面的初始数据 - */ - data: { - - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - - }, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { - - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - - }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { - - }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { - - } -}) \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.json b/miniprogram/pages/deployFunctions/deployFunctions.json deleted file mode 100644 index 7fbedab..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "navigationBarTitleText": "部署云函数", - "usingComponents": {} -} \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.wxml b/miniprogram/pages/deployFunctions/deployFunctions.wxml deleted file mode 100644 index 462b6b6..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.wxml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - 调用失败 - - - 请检查 login 云函数是否已部署 - - - - - 部署 login 云函数 - 1. 确保已通过工具栏云开发入口开通云开发 - 2. 在 cloudfunctions/login 目录上右键上传并部署 - 3. 回到首页,重新点击获取 openid - - - - diff --git a/miniprogram/pages/deployFunctions/deployFunctions.wxss b/miniprogram/pages/deployFunctions/deployFunctions.wxss deleted file mode 100644 index c8803e6..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.wxss +++ /dev/null @@ -1,7 +0,0 @@ -/* pages/deployFunctions/deployFunctions.wxss */ - -@import "../../style/guide.wxss"; - -.black { - color: black; -} \ No newline at end of file diff --git a/miniprogram/pages/earth/earth.js b/miniprogram/pages/earth/earth.js index ae0d3f3..376a6e2 100644 --- a/miniprogram/pages/earth/earth.js +++ b/miniprogram/pages/earth/earth.js @@ -21,19 +21,12 @@ show: false, enableSsatellite: false, windowWidth: 0, - longitude: 113.324520, - latitude: 23.099994, - longitude84: 113.324520, - latitude84: 23.099994, - markers: [{ - id: 0, - iconPath: "../../images/locat.png", - latitude: 23.099994, - longitude: 113.324520, - width: 50, - height: 50 - }], - controls: [], + longitude: "116.627340", + latitude: "39.874390", + longitude84: "", + latitude84: "", + markers: [], + controls: [] }, /** @@ -41,39 +34,13 @@ */ onLoad: function (options) { var that = this; - //获取当前坐标(gcj02) - wx.getLocation({ - type: "gcj02", - altitude: true, - success: function (res) { - that.setData({ - latitude: parseFloat(res.latitude).toFixed(6), - longitude: parseFloat(res.longitude).toFixed(6), - // markers: [{ - // latitude: res.latitude, - // longitude: res.longitude, - // }] - }) - //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 - wx.getLocation({ - type: "wgs84", - altitude: true, - success: function (res) { - that.setData({ - latitude84: parseFloat(res.latitude).toFixed(6), - longitude84: parseFloat(res.longitude).toFixed(6) - }) - } - }) - } - }), - - //设置地图组件 - wx.getSystemInfo({ + //设置地图组件 + wx.getSystemInfo({ success(res) { var windowWidth = res.windowWidth var windowHeight = res.windowHeight var query = wx.createSelectorQuery() + var platform =res.platform query.select('#map').boundingClientRect() query.exec(function (res) { that.setData({ @@ -139,10 +106,20 @@ clickable: true }, { id: 7, - iconPath: '../../images/locat.png', + iconPath: '../../images/applocat.png', position: { - left: res[0].width/2, - top: res[0].height/2, + left: res[0].width / 2 - 20, + top: platform=="ios"?res[0].height / 2 - 80:res[0].height / 2 - 40, + width: 40, + height: 40 + }, + clickable: true + }, { + id: 8, + iconPath: '../../images/back.png', + position: { + left: windowWidth - 40, + top: windowHeight - 140, width: 30, height: 30 }, @@ -150,71 +127,15 @@ }] }) }) - + } - }), + }) + // 实例化API核心类 qqmapsdk = new QQMapWX({ key: 'BGPBZ-C5O3P-ROUDR-LWC4J-63EKH-V5FRX' }) - - if (options.devcode) { - var that = this - var devcode = options.devcode - wx.cloud.callFunction({ - name: 'findListByCodes', - data: { - devcodes: devcode, - url: app.globalData.url + "appDeviceAdd/findListByCodes" - }, - }).then(res => { - if (res.result.code == 200) { - var listResultData = res.result.data; - that.setData({ - listData: listResultData - }) - var markersArr = that.data.markers; - for (var i = 0; i < listResultData.length; i++) { - markersArr = markersArr.concat({ - iconPath: "../../images/locat.png", - id: listResultData[i].id, - callout: { - content: listResultData[i].devcode, - fontSize: '14', - // padding: true, - color: '#00000', - borderColor: '#F4EA2A', - bgColor: '#F4EA2A', - borderWidth: 5, - display: 'ALWAYS', - textAlign: 'center', - // borderRadius: 15 - }, - latitude: listResultData[i].latitude, - longitude: listResultData[i].longitude, - width: 40, - height: 40 - }); - } - this.setData({ - markers: markersArr, - latitude: listResultData[0].latitude, - longitude: listResultData[0].longitude, - marker_latitude: listResultData[0].latitude, - marker_longitude: listResultData[0].longitude, - title: listResultData[0].devcode - }) - } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "无法获取设备地理信息!", - icon: 'none', - duration: 2000 - }) - }) - } }, /** @@ -228,6 +149,97 @@ * 生命周期函数--监听页面显示 */ onShow: function () { + //输入设备编号获取marker位置信息 + var that = this; + if ( app.globalData.devcode!="") { + var devcode = app.globalData.devcode + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/findListByCodes", + data: { + devcodes: devcode, + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + app.globalData.devcode=""; + if (res.data.code == 200) { + var listResultData = res.data.data; + that.setData({ + listData: listResultData + }) + var markersArr = that.data.markers; + for (var i = 0; i < listResultData.length; i++) { + markersArr = markersArr.concat({ + iconPath: "../../images/locat.png", + id: Number(listResultData[i].id), + callout: { + content: "编号:"+listResultData[i].devcode+"\r\n位置:"+listResultData[i].position+"\r\n时间:"+listResultData[i].createtime, + fontSize: '14', + padding: true, + color: '#000000', + borderColor: '#F4EA2A', + bgColor: '#F4EA2A', + borderWidth: 5, + display: 'ALWAYS', + textAlign: 'left', + // borderRadius: 15 + }, + latitude: listResultData[i].latitude, + longitude: listResultData[i].longitude, + width: 40, + height: 40 + }); + } + that.setData({ + markers: markersArr, + latitude: listResultData[0].latitude, + longitude: listResultData[0].longitude, + marker_latitude: listResultData[0].latitude, + marker_longitude: listResultData[0].longitude, + title: listResultData[0].devcode + }) + } + }, + fail(err) { + app.globalData.devcode=""; + wx.showToast({ + title: "无法获取设备地理信息!", + icon: 'none', + duration: 2000 + }) + } + }) +} else { + //获取当前坐标(gcj02) + wx.getLocation({ + type: "gcj02", + altitude: true, + success: function (res) { + that.setData({ + latitude: parseFloat(res.latitude).toFixed(6), + longitude: parseFloat(res.longitude).toFixed(6), + // markers: [{ + // latitude: res.latitude, + // longitude: res.longitude, + // }] + }) + //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 + wx.getLocation({ + type: "wgs84", + altitude: true, + success: function (res) { + that.setData({ + latitude84: parseFloat(res.latitude).toFixed(6), + longitude84: parseFloat(res.longitude).toFixed(6) + }) + } + }) + } + }) +} + }, @@ -265,12 +277,46 @@ onShareAppMessage: function () { }, + + //定位出来 + + locationPosition: function () { + var that = this; + //获取当前坐标(gcj02) + wx.getLocation({ + type: "gcj02", + altitude: true, + success: function (res) { + that.setData({ + latitude: parseFloat(res.latitude).toFixed(6), + longitude: parseFloat(res.longitude).toFixed(6), + // markers: [{ + // latitude: res.latitude, + // longitude: res.longitude + // }] + }) + //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 + wx.getLocation({ + type: "wgs84", + altitude: true, + success: function (res) { + that.setData({ + latitude84: parseFloat(res.latitude).toFixed(6), + longitude84: parseFloat(res.longitude).toFixed(6) + }) + } + }) + } + }) + }, + + //加载地图组件 controltap: function (e) { // console.log(e.controlId); //进入添加设备页 if (1 == e.controlId) { wx.setClipboardData({ - data: this.data.latitude + "," + this.data.longitude+ "," + this.data.latitude84+ "," + this.data.longitude84, + data: this.data.latitude + "," + this.data.longitude + "," + this.data.latitude84 + "," + this.data.longitude84, success: function (res) { wx.getClipboardData({ success: function (res) { @@ -282,6 +328,17 @@ } }) } else if (3 == e.controlId) { + //先定位 + // this.locationPosition() + wx.setClipboardData({ + data: this.data.latitude + "," + this.data.longitude + "," + this.data.latitude84 + "," + this.data.longitude84, + success: function (res) { + wx.showToast({ + title: '坐标已获取', + duration: 1000 + }) + } + }) wx.navigateTo({ url: '../addDevice/addDevice' }) @@ -302,32 +359,15 @@ enableSsatellite: !flag }); } else if (6 == e.controlId) { - var that = this; - //获取当前坐标(gcj02) - wx.getLocation({ - type: "gcj02", - altitude: true, - success: function (res) { - that.setData({ - latitude: parseFloat(res.latitude).toFixed(6), - longitude:parseFloat(res.longitude).toFixed(6), - // markers: [{ - // latitude: res.latitude, - // longitude: res.longitude - // }] - }) - //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 - wx.getLocation({ - type: "wgs84", - altitude: true, - success: function (res) { - that.setData({ - latitude84: parseFloat(res.latitude).toFixed(6), - longitude84: parseFloat(res.longitude).toFixed(6) - }) - } - }) - } + //先清marker + this.setData({ + markers: [] + }) + this.locationPosition() + }else if (8 == e.controlId) { + //跳转日志缓存页 + wx.switchTab({ + url: '../applog/applog', }) } }, @@ -343,63 +383,68 @@ }); }, + //获取设备maker leave() { var that = this; if (that.data.devcodes == "") { return false; } - wx.cloud.callFunction({ - name: 'findListByCodes', + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/findListByCodes", data: { - devcodes: that.data.devcodes, - url: app.globalData.url + "appDeviceAdd/findListByCodes" + devcodes: that.data.devcodes }, - }).then(res => { - if (res.result.code == 200) { - var listResultData = res.result.data; - that.setData({ - listData: listResultData - }) - var markersArr = that.data.markers; - for (var i = 0; i < listResultData.length; i++) { - markersArr = markersArr.concat({ - iconPath: "../../images/locat.png", - id: listResultData[i].id, - callout: { - content: listResultData[i].devcode, - fontSize: '14', - // padding: true, - color: '', - borderColor: '#F4EA2A', - bgColor: '#F4EA2A', - borderWidth: 5, - display: 'ALWAYS', - textAlign: 'center', - // borderRadius: 15 - }, - latitude: listResultData[i].latitude, - longitude: listResultData[i].longitude, - width: 40, - height: 40 - }); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var listResultData = res.data.data; + that.setData({ + listData: listResultData + }) + var markersArr = that.data.markers; + for (var i = 0; i < listResultData.length; i++) { + markersArr = markersArr.concat({ + iconPath: "../../images/locat.png", + id: listResultData[i].id, + callout: { + content: "编号:"+listResultData[i].devcode+"\r\n位置:"+listResultData[i].position+"\r\n时间:"+listResultData[i].createtime, + fontSize: '14', + // padding: true, + color: '#212121', + borderColor: '#F4EA2A', + bgColor: '#F4EA2A', + borderWidth: 5, + display: 'ALWAYS', + textAlign: 'left', + // borderRadius: 15 + }, + latitude: listResultData[i].latitude, + longitude: listResultData[i].longitude, + width: 40, + height: 40 + }); + } + that.setData({ + markers: markersArr, + latitude: listResultData[0].latitude, + longitude: listResultData[0].longitude, + marker_latitude: listResultData[0].latitude, + marker_longitude: listResultData[0].longitude, + title: listResultData[0].devcode + }) } - this.setData({ - markers: markersArr, - latitude: listResultData[0].latitude, - longitude: listResultData[0].longitude, - marker_latitude: listResultData[0].latitude, - marker_longitude: listResultData[0].longitude, - title: listResultData[0].devcode + }, + fail(err) { + wx.showToast({ + title: "无法获取设备地理信息!", + icon: 'none', + duration: 2000 }) } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "无法获取设备地理信息!", - icon: 'none', - duration: 2000 - }) }) }, @@ -422,6 +467,8 @@ } }, + + bindregionchange: function (e) { var that = this if (e.causedBy == "drag") { @@ -445,8 +492,8 @@ that.setData({ latitude: parseFloat(latitude).toFixed(6), longitude: parseFloat(longitude).toFixed(6), - latitude84:"", - longitude84:"", + latitude84: "", + longitude84: "", // markers: markersArr }) // mapCtx.moveToLocation(); @@ -465,16 +512,19 @@ qqmapsdk.search({ keyword: this.data.value, success: function (res) { + console.log(res) if (res && res.data) { _this.setData({ isShow: true, tips: res.data }); } + }, + complete: function (res){ + console.log(res); } }) }, - bindSearch: function (e) { var location = e.target.dataset.location; this.setData({ diff --git a/miniprogram/pages/earth/earth.wxml b/miniprogram/pages/earth/earth.wxml index a0db6ef..87474f8 100644 --- a/miniprogram/pages/earth/earth.wxml +++ b/miniprogram/pages/earth/earth.wxml @@ -1,9 +1,10 @@ + - + {{item.title}} {{item.address}} @@ -17,6 +18,6 @@ + placeholder="请输入定位设备编号用换行隔开" autosize border="{{ false }}" /> \ No newline at end of file diff --git a/miniprogram/pages/indexapp/indexapp.js b/miniprogram/pages/indexapp/indexapp.js index 5063372..849dbdb 100644 --- a/miniprogram/pages/indexapp/indexapp.js +++ b/miniprogram/pages/indexapp/indexapp.js @@ -7,9 +7,8 @@ */ data: { - count:1, - show: false, - onshow:true, + count: 1, + onshow: true, value: "", deviceloglist: [], devcode: "", @@ -21,6 +20,7 @@ // iconPath: "../../images/point.png", latitude: 23.099994, longitude: 113.324520, + label:'1', width: 50, height: 50 }], @@ -31,62 +31,26 @@ * 生命周期函数--监听页面加载 */ onLoad: function (options) { - + }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { - + }, /** * 生命周期函数--监听页面显示 */ onShow: function () { - // if( app.globalData.indexCount>1){ - // this.setData({ - // show:false - // }) - // }else{ - // this.showNotice() - // } - if(app.globalData.indexCount==1){ - this.setData({ - show:true - }) - this.showNotice() - } - app.globalData.indexCount+=1 - if(this.data.onshow){ + if (this.data.onshow) { this.initPages(); } }, - - showNotice: function() { - var that = this - var times = 0 - var i = setInterval(function() { - times++ - if (times >= 15) { - that.setData({ - show:false - }) - wx.showTabBar({ - animation: false, - }) - clearInterval(i) - } else { - wx.hideTabBar({ - animation: false, - }) - } - }, 1000) -}, - /** * 生命周期函数--监听页面隐藏 */ @@ -122,16 +86,27 @@ }, jump: function (event) { - var that = this; var latitude = event.target.dataset.pointLat; var longitude = event.target.dataset.pointLon; + let devcode = event.target.dataset.pointCode; that.setData({ latitude: latitude, longitude: longitude, markers: [{ latitude: latitude, - longitude: longitude + longitude: longitude, + callout: { + display:'ALWAYS',// 常显气泡 + content: devcode, //名称文本 + color: '#fff', //文本颜色 + borderRadius: 5, //边框圆角 + borderWidth: 1, //边框宽度 + borderColor: '#0060ff', //边框颜色 + bgColor: '#0060ff', //背景色 + padding: 5, //文本边缘留白 + textAlign: 'center' //文本对齐方式。有效值: left, right, center + } }] }) }, @@ -142,7 +117,7 @@ var devcode = res.result _this.setData({ devcode: devcode, - onshow:false + onshow: false }); _this.searchlogs(devcode) } @@ -151,40 +126,11 @@ onSearch: function (event) { this.setData({ - devcode:event.detail + devcode: event.detail }) this.searchlogs(event.detail) }, - - // bindregionchange: function (e) { - // var that = this - // if (e.causedBy == "drag") { - // var mapCtx = wx.createMapContext("map") - // mapCtx.getCenterLocation({ - // success: function (res) { - // var markersArr = that.data.markers - // for (var i = 0; i < markersArr.length; i++) { - // if (markersArr[i].iconPath == undefined) { - // markersArr.splice(i, 1) - // } - // } - // var latitude = res.latitude - // var longitude = res.longitude - // markersArr = markersArr.concat({ - // latitude: latitude, - // longitude: longitude - // }) - // that.setData({ - // latitude: latitude, - // longitude: longitude, - // markers: markersArr - // }) - // } - // }) - // } - // }, - showLoading: function (message) { if (wx.showLoading) { // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 @@ -211,81 +157,89 @@ } }, + //加载设备运维详细信息 toDetail: function (event) { - this.showLoading("数据加载中...") - wx.cloud.callFunction({ - name: 'deviceDetail', + var that = this + that.showLoading("数据加载中...") + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deviceDetail", data: { devcode: event.target.dataset.devcode, - url: app.globalData.url + "appDeviceLog/deviceDetail", }, - }).then(res => { - this.hideLoading(); - var resultObject = JSON.parse(res.result); - var pageName='../indexapp/indexapp' - if (resultObject.code == 200) { - wx.navigateTo({ - url: '../addDevicelog/addDeviceLog?detail=' + - JSON.stringify(resultObject.data)+'&pageName='+pageName - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + that.hideLoading(); + var resultObject = res.data; + var pageName = '../indexapp/indexapp' + if (resultObject.code == 200) { + wx.setStorageSync('resultObject', resultObject.data) + wx.navigateTo({ + url: '../addDevicelog/addDeviceLog?detail=' +'&pageName=' + pageName + }) + } + }, + fail(err){ + that.hideLoading(); } - }).catch(err => { - this.hideLoading(); }) }, + //加载列表 getlogs: function (devcode) { var that = this - wx.cloud.callFunction({ - name: 'devicelog', + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/listPage", data: { devcode: devcode, - url: app.globalData.url + "appDeviceLog/listPage", limit: 100, offset: that.data.deviceloglist.length % 100 > 0 ? parseInt(that.data.deviceloglist.length / 100) + 2 : parseInt(that.data.deviceloglist.length / 100) + 1 }, - }).then(res => { - if (res.result) { - // var resultJson = JSON.parse(res.result) - var resultJson = res.result - that.setData({ - deviceloglist: that.data.deviceloglist.concat(resultJson.data.rows) - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + // var resultJson = JSON.parse(res.result) + var resultJson = res.data + that.setData({ + deviceloglist: that.data.deviceloglist.concat(resultJson.data.rows) + }) + } } - console.log(res); - }).catch(err => { - console.error(err); }) }, + //查询列表 searchlogs: function (devcode) { var that = this - wx.cloud.callFunction({ - name: 'devicelog', + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/listPage", data: { devcode: devcode, - url: app.globalData.url + "appDeviceLog/listPage", limit: 100, offset: 1 }, - }).then(res => { - if (res.result) { - var resultJson = res.result - that.setData({ - deviceloglist: resultJson.data.rows, - onshow:true - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var resultJson = res.data + that.setData({ + deviceloglist: resultJson.data.rows, + onshow: true + }) + } } - console.log(res); - }).catch(err => { - console.error(err); }) }, initPages: function () { var that = this; - that.setData({ - devcode: "" - }); wx.getLocation({ type: "gcj02", success: function (res) { @@ -302,6 +256,6 @@ }) } }) - this.searchlogs() + this.data.devcode !== '' ? this.searchlogs(this.data.devcode) : this.searchlogs() }, }) \ No newline at end of file diff --git a/miniprogram/pages/indexapp/indexapp.wxml b/miniprogram/pages/indexapp/indexapp.wxml index 69322a0..f65b082 100644 --- a/miniprogram/pages/indexapp/indexapp.wxml +++ b/miniprogram/pages/indexapp/indexapp.wxml @@ -1,8 +1,12 @@ + + + + - @@ -32,9 +36,15 @@ - + + + + + + + @@ -46,14 +56,14 @@ - + - - + diff --git a/miniprogram/pages/indexapp/indexapp.wxss b/miniprogram/pages/indexapp/indexapp.wxss index b18706a..fc27fcb 100644 --- a/miniprogram/pages/indexapp/indexapp.wxss +++ b/miniprogram/pages/indexapp/indexapp.wxss @@ -128,6 +128,7 @@ .noticeClass{ height: 2300rpx; width: 750rpx; + overflow-y:hidden; } @@ -148,14 +149,14 @@ } +/* .vanstyle{ + button: not([size='mini']) { + user agent stylesheetmin-height: 40px; + width: 650rpx; + margin-left: 20rpx; + margin-right: auto; + + } + +} */ -/* .van-enter-active-class, -.van-leave-active-class { - transition-property: background-color, transform; -} - -.van-enter-class, -.van-leave-to-class { - background-color: red; - transform: rotate(-360deg) translate3d(-100%, -100%, 0); -} */ \ No newline at end of file diff --git a/miniprogram/pages/log/log.js b/miniprogram/pages/log/log.js deleted file mode 100644 index 83ba349..0000000 --- a/miniprogram/pages/log/log.js +++ /dev/null @@ -1,66 +0,0 @@ -// pages/log/log.js -Page({ - - /** - * 页面的初始数据 - */ - data: { - - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - - }, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { - - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - - }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { - - }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { - - } -}) \ No newline at end of file diff --git a/miniprogram/pages/log/log.json b/miniprogram/pages/log/log.json deleted file mode 100644 index 8835af0..0000000 --- a/miniprogram/pages/log/log.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "usingComponents": {} -} \ No newline at end of file diff --git a/miniprogram/pages/log/log.wxml b/miniprogram/pages/log/log.wxml deleted file mode 100644 index a510ad6..0000000 --- a/miniprogram/pages/log/log.wxml +++ /dev/null @@ -1,2 +0,0 @@ - -pages/log/log.wxml diff --git a/cloudfunctions/project.config.json b/cloudfunctions/project.config.json new file mode 100644 index 0000000..2b3119a --- /dev/null +++ b/cloudfunctions/project.config.json @@ -0,0 +1,28 @@ +{ + "appid": "wx2cef527a000f87c9", + "compileType": "miniprogram", + "libVersion": "2.27.3", + "packOptions": { + "ignore": [], + "include": [] + }, + "setting": { + "coverView": true, + "es6": true, + "postcss": true, + "minified": true, + "enhance": true, + "showShadowRootInWxmlPanel": true, + "packNpmRelationList": [], + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + } + }, + "condition": {}, + "editorSetting": { + "tabIndent": "insertSpaces", + "tabSize": 4 + } +} \ No newline at end of file diff --git a/cloudfunctions/project.private.config.json b/cloudfunctions/project.private.config.json new file mode 100644 index 0000000..42ff49d --- /dev/null +++ b/cloudfunctions/project.private.config.json @@ -0,0 +1,7 @@ +{ + "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", + "projectname": "cloudfunctions", + "setting": { + "compileHotReLoad": true + } +} \ No newline at end of file diff --git a/miniprogram/app.js b/miniprogram/app.js index 51d56f3..50a8a54 100644 --- a/miniprogram/app.js +++ b/miniprogram/app.js @@ -18,13 +18,15 @@ // this.globalData = {} }, globalData: { - // url: "http://111.198.10.15:11604/", - httpsUrl: "https://logapi.smartlog.work/", - httpsTestUrl: "https://smartlog.work/prodapi4test/", - url: "http://139.198.18.188:8083/", + httpsUrl: "https://logapi.smartlog.work/", + // httpsUrl: "http://139.198.18.188:8083/", // url: "http://127.0.0.1:8083/", - // httpsUrl: "http://127.0.0.1:8083/", + //httpsUrl: "http://127.0.0.1:8083/", openid: null, - indexCount:1 - }, + indexCount:1, + nickName:"", + userName:"", + role:"", + devcode:"" + } }) diff --git a/miniprogram/app.json b/miniprogram/app.json index d23f798..2b6db76 100644 --- a/miniprogram/app.json +++ b/miniprogram/app.json @@ -1,15 +1,17 @@ { "cloud": true, "pages": [ + "pages/login/login", "pages/indexapp/indexapp", "pages/earth/earth", "pages/applog/applog", "pages/addDevice/addDevice", "pages/addDevicelog/addDeviceLog", - "pages/searchLog/searchLog" + "pages/searchLog/searchLog", + "pages/notice/notice" ], "window": { - "backgroundColor": "#F6F6F6", + "backgroundColor": "#E6D480", "backgroundTextStyle": "light", "navigationBarBackgroundColor": "#FFCF00", "navigationBarTitleText": "智慧施工", @@ -46,11 +48,11 @@ "desc": "你的位置信息将用于小程序位置接口的效果展示" } }, + "requiredPrivateInfos": ["getLocation", "chooseLocation"], "networkTimeout": { "request": 30000, "connectSocket": 30000, "uploadFile": 30000, "downloadFile": 30000 - }, - "style": "v2" + } } \ No newline at end of file diff --git a/miniprogram/images/applocat.png b/miniprogram/images/applocat.png new file mode 100644 index 0000000..fe49f54 --- /dev/null +++ b/miniprogram/images/applocat.png Binary files differ diff --git a/miniprogram/images/back.png b/miniprogram/images/back.png new file mode 100644 index 0000000..32ac82d --- /dev/null +++ b/miniprogram/images/back.png Binary files differ diff --git a/miniprogram/images/bottom.png b/miniprogram/images/bottom.png new file mode 100644 index 0000000..d910e98 --- /dev/null +++ b/miniprogram/images/bottom.png Binary files differ diff --git a/miniprogram/images/header.png b/miniprogram/images/header.png new file mode 100644 index 0000000..6ea222e --- /dev/null +++ b/miniprogram/images/header.png Binary files differ diff --git a/miniprogram/images/login.png b/miniprogram/images/login.png index 8b73cc0..6471c46 100644 --- a/miniprogram/images/login.png +++ b/miniprogram/images/login.png Binary files differ diff --git a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss index 5a591fb..c9c35b5 100644 --- a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss +++ b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:100%;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:100%}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file +@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:650rpx;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:600rpx}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file diff --git a/miniprogram/pages/addDevice/addDevice.js b/miniprogram/pages/addDevice/addDevice.js index 2783674..78f00b7 100644 --- a/miniprogram/pages/addDevice/addDevice.js +++ b/miniprogram/pages/addDevice/addDevice.js @@ -1,5 +1,7 @@ // miniprogram/pages/addDevice/addDevice.js // import WxValidate from '../../utils/WxValidate.js' +var QQMapWX = require('../../libs/qqmap-wx-jssdk.js'); +var qqmapsdk; var app = getApp() Page({ @@ -11,32 +13,10 @@ canvasWidth: '', longitude: '', latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], + option1: [], personoption1: [], projectoption: [], + devtypeList:[], show: false, form: { devcode: "", @@ -59,7 +39,10 @@ project: "", area: "", street: "", - wellname: "" + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '', }, fileList: [] }, @@ -117,12 +100,14 @@ var that = this; //初始化表单内容为上次填写值 var cacheForms = wx.getStorageSync('cacheList') - if (cacheForms) { + cacheForms.photopath1='' + cacheForms.photopath2='' + cacheForms.photopath3='' + that.data.fileList=[] that.setData({ form: cacheForms, devcode: cacheForms.devcode, - }) } var form = that.data.form @@ -155,55 +140,89 @@ } }) + +//获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + that.setData({ + option1: welltypeArr + }) + } + } +}) + + //获取人员下拉列表 - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/getUser", + data:{ + tips:'repair' }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data.code == 200) { + var users = res.data.data + var personArr = []; + for (var i = 0; i < users.length; i++) { + var person = { + text: users[i].name, + value: users[i].name + }; + personArr.push(person); + } + that.setData({ + personoption1: personArr + }) } - that.setData({ - personoption1: personArr - }) } - }).catch(err => { - console.error(err); - }) + }) + - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - that.setData({ - projectoption: projectArr - }) + success(res){ + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); + } + that.setData({ + projectoption: projectArr + }) + } } - }).catch(err => { - console.error(err); - }) + }) + var installtime = 'form.installtimeFmt'; var dateNow = this.formatDate(); this.setData({ @@ -211,8 +230,40 @@ installtimeFmt: dateNow, [installtime]: dateNow, }); + + + + /** + * 获取设备类型下拉列表 + */ + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/deviceType", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var TypeList = res.data.data + var typeArr = []; + for (var i = 0; i < TypeList.length; i++) { + var type = { + text: TypeList[i].productName, + value: TypeList[i].productName + }; + typeArr.push(type); + } + that.setData({ + devtypeList: typeArr + }) + } + } + }) }, + + + /** * 生命周期函数--监听页面初次渲染完成 */ @@ -280,29 +331,7 @@ }, - - //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 - drawText: function (ctx, str, leftWidth, initHeight, titleHeight, canvasWidth) { - var lineWidth = 0; - var lastSubStrIndex = 0; //每次开始截取的字符串的索引 - for (let i = 0; i < str.length; i++) { - lineWidth += ctx.measureText(str[i]).width; - if (lineWidth > canvasWidth) { - ctx.fillText(str.substring(lastSubStrIndex, i), leftWidth, initHeight); //绘制截取部分 - initHeight = initHeight + leftWidth * 2; //22为字体的高度 - lineWidth = 0; - lastSubStrIndex = i; - // titleHeight += 40; - } - if (i == str.length - 1) { //绘制剩余部分 - ctx.fillText(str.substring(lastSubStrIndex, i + 1), leftWidth, initHeight); - } - } - // // 标题border-bottom 线距顶部距离 - // titleHeight = titleHeight + 10; - // return titleHeight - }, - + //验证表单 formValidate() { if (this.data.form.devcode == "") { @@ -312,27 +341,20 @@ }) return false } - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } if (this.data.form.wellcode == "") { wx.showToast({ icon: 'none', @@ -348,22 +370,10 @@ }) return false } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null) { + + if (this.data.form.installperson == "") { wx.showToast({ icon: 'none', title: '安装人员不能为空!', @@ -408,56 +418,90 @@ } return true; }, + //提交表单 formSubmit: function (event) { + console.log(this.data.form) + //表单参数验证 if (!this.formValidate()) { return false; } var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDevice', + //验证设备编号长度 + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/getDevTypeLength", data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceAdd/add" + code: encodeURI(this.data.form.devicetype) }, - }).then(res => { - if (res.result.code == 500) { - wx.showToast({ - title: '设备编号已安装!', - }) - } else if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - //用于回显 - wx.setStorageSync('cacheList', that.data.form) - //提交成功后提示用户操作 - if (res.confirm) { - wx.switchTab({ - url: '../earth/earth' - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (""==res.data.data ||res.data.data == that.data.form.devcode.length) { + that.saveDevice() + } else { //编号位数不对提示 + wx.showToast({ + icon: 'none', + title: '设备编号位数不对!', + duration: 1000 + }) + return false + } } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "提交失败", - }) }) }, + + //保存设备基本信息 + saveDevice() { + var that = this; + //设置照片路径 + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopathForm = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopathForm]: fileList[i].url.split("static/")[1] + }) + } + //表单提交 + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 500) { + wx.showToast({ + title: '设备编号已安装!', + }) + } else if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + //用于回显 + wx.setStorageSync('cacheList', that.data.form) + //提交成功后提示用户操作 + if (res.confirm) { + wx.switchTab({ + url: '../earth/earth' + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } + }, + fail(err) { + wx.showToast({ + title: '提交失败!', + }) + } + }) + }, + + //input 输入框设置值 confirm(event) { var that = this; var formValue = event.detail.value; @@ -466,8 +510,30 @@ that.setData({ [fromN]: formValue }) + //若输入是设备编号,自动获取设备类型 + if('devcode'==formName){ + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", + data: { + devcode: formValue, + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + that.setData({ + [formDevicetype]: res.data + }); + } + } + }) + } }, + //扫描设备获取编号和设备类型 scan() { var _this = this; wx.scanCode({ @@ -477,23 +543,28 @@ _this.setData({ [formdevcode]: devcode }); - wx.cloud.callFunction({ - name: 'findModeCode', + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", data: { devcode: devcode, - url: app.globalData.url + "appDeviceAdd/findModeCodeByCode" }, - }).then(res => { - if (res.result) { - var formDevicetype = 'form.devicetype' - _this.setData({ - [formDevicetype]: res.result - }); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + _this.setData({ + [formDevicetype]: res.data + }); + } } }) } }) }, + //粘贴经纬度 paste() { var _this = this; wx.getClipboardData({ @@ -510,9 +581,11 @@ longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), }); + _this.showAddress(_this.data.form.longitude,_this.data.form.latitude,_this) } }) }, + //设置经类型 selectValue(value) { var that = this; @@ -521,6 +594,16 @@ [wellType]: value.detail }) }, + + //设置设备类型 + selectDevType(event) { + var that = this; + var devtype = 'form.devicetype'; + that.setData({ + [devtype]: event.detail + }) + }, + //设置运维人员 selectpersonValue(event) { var that = this; var installPerson = 'form.installperson'; @@ -528,6 +611,7 @@ [installPerson]: event.detail }) }, + //设置项目 selectprojectValue(event) { var that = this; var project = 'form.project'; @@ -535,8 +619,41 @@ [project]: event.detail }) }, + showAddress :function(longitude, latitude, self) { + // 实例化腾讯地图API核心类 + qqmapsdk = new QQMapWX({ + key: 'BGPBZ-C5O3P-ROUDR-LWC4J-63EKH-V5FRX'//此处使用你自己申请的key + }) + // 腾讯地图调用接口 + qqmapsdk.reverseGeocoder({ + location: { + latitude: latitude, + longitude: longitude + }, + success: function (res) { + self.setData({ + 'form.area':res.result.address.slice(0,res.result.address.indexOf('区')+1), + 'form.street':res.result.address.slice(res.result.address.indexOf('区')+1) + }) + }, + fail: function (res) { + console.log(res); + }, + complete: function (res) { + } + }); + }, + //上传照片 afterRead(event) { var _this = this; + if (_this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '请先填写设备编号!\r\n否则水印中无编号', + duration: 2000 + }) + return false + } const { file } = event.detail; @@ -576,78 +693,8 @@ }) } }) - // 压缩图片 - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // //获取图片尺寸 - // wx.getImageInfo({ - // src: convertpath, - // success(res) { - // _this.setData({ - // canvasHeight: res.height, - // canvasWidth: res.width - // }) - // var ctx = wx.createCanvasContext('firstCanvas') - - // //将图片src放到cancas内,宽高为图片大小 - // ctx.drawImage(convertpath, 0, 0, res.width, res.height) - // //将声明的时间放入canvas - // ctx.setFontSize(30 * (res.width / 750)) //注意:设置文字大小必须放在填充文字之前,否则不生效 - // ctx.setFillStyle('blue') - // var text = "编号:" + _this.data.form.devcode + "\n经度:" + _this.data.form.longitude + "\n纬度:" + _this.data.form.latitude - // // _this.drawText(ctx,text,20, 70, 5, res.width) - // _this.drawText(ctx, text, 15 * (res.width / 750), 70 * (res.width / 750), 5, res.width) - - // // ctx.fillText(text, 0, 40) - // // ctx.strokeText(_this.data.form.devcode, 0, 30) - // //生成水印图 - // ctx.draw(false, function () { - // wx.canvasToTempFilePath({ - // canvasId: 'firstCanvas', - // success: (res) => { - // wx.compressImage({ - // src: res.tempFilePath, - // quality: 25, - // success: function (res) { - // //上传照片至服务器 - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: res.tempFilePath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // } - // }) - // //// - // } - // }) - // }) - // } - // }) - // } - // }); }, + //删除照片 deletePhoto(event) { var image_index = event.detail.index var fileList_new = this.data.fileList; diff --git a/miniprogram/pages/addDevice/addDevice.wxml b/miniprogram/pages/addDevice/addDevice.wxml index b0977e2..f12c254 100644 --- a/miniprogram/pages/addDevice/addDevice.wxml +++ b/miniprogram/pages/addDevice/addDevice.wxml @@ -5,18 +5,30 @@ - + + + + + + + + + + + + + - - + + - - - + + + @@ -29,13 +41,13 @@ - + - + - + - + @@ -54,8 +66,7 @@ - - + @@ -68,8 +79,8 @@ - - + + - 保存 + 保存 \ No newline at end of file diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.js b/miniprogram/pages/addDevicelog/addDeviceLog.js index cdec71b..a0dc6da 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.js +++ b/miniprogram/pages/addDevicelog/addDeviceLog.js @@ -3,681 +3,665 @@ var app = getApp(); Page({ - /** - * 页面的初始数据 - */ - data: { - pageName: '', - showMask: false, - today: new Date().getTime(), - longitude: '', - latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], - personoption1: [], - projectoption: [], - devcode: "", - deviceMode: "", - installtimeFmt: '', - show: false, - form: { - devcode: "", - wellcode: "", - welltype: "", - welldepth: "", - installheigt: "", - installperson: "", - installtimeFmt: "", - photopath: "", - factory: "", - workmsg: "", - position: "", - description: "", - longitude: "", - latitude: "", - longitude84: "", - latitude84: "", - devicetype: "", - project: "", - area: "", - street: "", - wellname: "" - }, - fileList: [], - detail: "" - }, + /** + * 页面的初始数据 + */ + data: { + pageName: '', + showMask: false, + today: new Date().getTime(), + longitude: '', + latitude: '', + option1: [], + personoption1: [], + projectoption: [], + devcode: "", + deviceMode: "", + installtimeFmt: '', + show: false, + form: { + devcode: "", + wellcode: "", + welltype: "", + welldepth: "", + installheigt: "", + installperson: "", + installtimeFmt: "", + photopath: "", + factory: "", + workmsg: "", + position: "", + description: "", + longitude: "", + latitude: "", + longitude84: "", + latitude84: "", + devicetype: "", + project: "", + area: "", + street: "", + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '' + }, + fileList: [], + detail: "", + markers: [{ + id: 100, + // iconPath: "../../images/point.png", + latitude: '', + longitude: '', + // label:'1', + width: 25, + height: 35 + }], + }, - onDisplay() { - this.setData({ - show: true - }); - }, - onClose() { - this.setData({ - show: false - }); - }, - formatDate() { - var date = new Date(); - // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; - var seperator1 = "-"; - var month = date.getMonth() + 1; - var strDate = date.getDate(); - var hour = date.getHours() - var minute = date.getMinutes() - var second = date.getSeconds() - month = month > 9 ? month : "0" + month; - strDate = strDate > 9 ? strDate : "0" + strDate; - hour = hour > 9 ? hour : "0" + hour; - minute = minute > 9 ? minute : "0" + minute; - second = second > 9 ? second : "0" + second; - var currentdate = - date.getFullYear() + - seperator1 + - month + - seperator1 + - strDate + - " " + - hour + ":" + - minute + ":" + - second; - return currentdate; + onDisplay() { + this.setData({ + show: true + }); + }, + onClose() { + this.setData({ + show: false + }); + }, + formatDate() { + var date = new Date(); + // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; + var seperator1 = "-"; + var month = date.getMonth() + 1; + var strDate = date.getDate(); + var hour = date.getHours() + var minute = date.getMinutes() + var second = date.getSeconds() + month = month > 9 ? month : "0" + month; + strDate = strDate > 9 ? strDate : "0" + strDate; + hour = hour > 9 ? hour : "0" + hour; + minute = minute > 9 ? minute : "0" + minute; + second = second > 9 ? second : "0" + second; + var currentdate = + date.getFullYear() + + seperator1 + + month + + seperator1 + + strDate + + " " + + hour + ":" + + minute + ":" + + second; + return currentdate; - }, - onConfirm(event) { - var installtime = 'form.installtimeFmt'; - this.setData({ - show: false, - installtimeFmt: this.formatDate(event.detail), - [installtime]: this.formatDate(event.detail), - }); - }, + }, + onConfirm(event) { + var installtime = 'form.installtimeFmt'; + this.setData({ + show: false, + installtimeFmt: this.formatDate(event.detail), + [installtime]: this.formatDate(event.detail), + }); + }, - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - var _this = this; - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" - }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); - } - _this.setData({ - personoption1: personArr - }) + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + var _this = this; + _this.setData({ + 'markers[0].latitude': Number(wx.getStorageSync('resultObject').latitude) , + 'markers[0].longitude': Number(wx.getStorageSync('resultObject').longitude), + // 'markers[0].label':'10', + 'markers[0].width': 18, + 'markers[0].id':1, + 'markers[0].height': 30, + latitude:Number(wx.getStorageSync('resultObject').latitude), + longitude:Number(wx.getStorageSync('resultObject').longitude) + }) + //获取人员下拉列表 + // wx.request({ + // method: "POST", + // url: app.globalData.httpsUrl + "deviceType/getUser", + // data:{ + // tips:'repair' + // }, + // header: { + // 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + // }, + // success(res) { + // if (res.data.code == 200) { + // var users = res.data.data + // var personArr = []; + // for (var i = 0; i < users.length; i++) { + // var person = { + // text: users[i].name, + // value: users[i].name + // }; + // personArr.push(person); + // } + // _this.setData({ + // personoption1: personArr + // }) + // } + // } + // }) + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); } - }).catch(err => { - console.error(err); - }) - - - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" - }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - _this.setData({ - projectoption: projectArr - }) - } - }).catch(err => { - console.error(err); - }) - - if (options.pageName) { - this.setData({ - pageName: options.pageName - }) - } - - if (options.detail) { - - var formObject = JSON.parse(options.detail); _this.setData({ - form: formObject, - detail: options.detail + projectoption: projectArr }) - - _this.setData({ - ['form.installperson']: "", - ['form.installtimeFmt']: "", - ['form.workmsg']: "", - ['form.description']: "" - }) - - const { - fileList = [] - } = _this.data; - if (formObject.photopath1 != "") { - var file1 = { - url: app.globalData.url + "static/" + formObject.photopath1 - } - fileList.push(file1) - } - if (formObject.photopath2 != "") { - var file2 = { - url: app.globalData.url + "static/" + formObject.photopath2 - } - fileList.push(file2) - } - if (formObject.photopath3 != "") { - var file3 = { - url: app.globalData.url + "static/" + formObject.photopath3 - } - fileList.push(file3) - } - - _this.setData({ - fileList - }); } - var installtime = 'form.installtimeFmt'; - var dateNow = this.formatDate(); - this.setData({ - installtimeFmt: dateNow, - [installtime]: dateNow, - }); - }, + } + }) - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { + //获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + _this.setData({ + option1: welltypeArr + }) + } + } +}) - }, + //跳转时带入参数返回哪页 + if (options.pageName) { + this.setData({ + pageName: options.pageName + }) + } + //跳转时带入参数设备的安装信息 + if (wx.getStorageSync('resultObject')) { + var formObject = wx.getStorageSync('resultObject') + _this.setData({ + form: formObject, + detail: formObject + }) - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { + _this.setData({ + ['form.installperson']: app.globalData.userName, + ['form.installtimeFmt']: "", + ['form.workmsg']: "", + ['form.description']: "" + }) - }, + const { + fileList = [] + } = _this.data; + if (formObject.photopath1 != "") { + var file1 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath1 + } + fileList.push(file1) + } + if (formObject.photopath2 != "") { + var file2 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath2 + } + fileList.push(file2) + } + if (formObject.photopath3 != "") { + var file3 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath3 + } + fileList.push(file3) + } + _this.setData({ + fileList + }); + } + var installtime = 'form.installtimeFmt'; + var dateNow = this.formatDate(); + this.setData({ + installtimeFmt: dateNow, + [installtime]: dateNow, + }); + }, - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, - }, + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + wx.removeStorageSync('resultObject') + }, - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, - }, + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { + }, - }, + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { + }, - }, + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { + }, - }, + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + }, - /** - * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true - **/ + /** + * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true + **/ - isNumber: function (val) { + isNumber: function (val) { - var regPos = /^[0-9]*$/; //非负浮点数 - var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数 - if (regPos.test(val) || regNeg.test(val)) { - return false; - } else { - return true; - } + var regPos = /^[0-9]*$/; //非负浮点数 + var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数 + if (regPos.test(val) || regNeg.test(val)) { + return false; + } else { + return true; + } - }, + }, - formValidate() { + formValidate() { - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } - if (this.data.form.wellcode == "") { - wx.showToast({ - icon: 'none', - title: '井编号不能为空!', - }) - return false - } - if (this.data.form.devicetype == "") { - wx.showToast({ - icon: 'none', - title: '设备类型不能为空!', - }) - return false - } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + if (this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '设备编号不能为空!', + }) + return false + } + if (this.data.form.wellcode == "") { + wx.showToast({ + icon: 'none', + title: '井编号不能为空!', + }) + return false + } + if (this.data.form.devicetype == "") { + wx.showToast({ + icon: 'none', + title: '设备类型不能为空!', + }) + return false + } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null || - this.data.form.installperson == '') { - wx.showToast({ - icon: 'none', - title: '运维人员不能为空!', - }) - return false - } - if (this.data.form.project == "") { - wx.showToast({ - icon: 'none', - title: '所属项目不能为空!', - }) - return false - } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } + if (this.data.form.installperson == null || + this.data.form.installperson == '') { + wx.showToast({ + icon: 'none', + title: '运维人员不能为空!', + }) + return false + } + if (this.data.form.project == "") { + wx.showToast({ + icon: 'none', + title: '所属项目不能为空!', + }) + return false + } - if (this.data.form.welldepth != null) { - if (this.isNumber(this.data.form.welldepth)) { - wx.showToast({ - icon: 'none', - title: '井深必须为数值!', - }) - return false - } - } - if (this.data.form.installheigt != null) { - if (this.isNumber(this.data.form.installheigt)) { - wx.showToast({ - icon: 'none', - title: '到井口距离必须为数值!', - }) - return false - } - } - - return true; - }, - - changeMsg: function () { - var formNew = this.data.form; - var formOld = JSON.parse(this.data.detail); - var descpNew = ""; - if (formNew.devcode != formOld.devcode) { - descpNew += "修改设备编号,原编号:" + formOld.devcode + ",新编号:" + formNew.devcode + ";" - } - if (formNew.devicetype != formOld.devicetype) { - descpNew += "修改设备类型,原设备类型:" + formOld.devicetype + ",新设备类型:" + formNew.devicetype + ";" - } - if (formNew.area != formOld.area) { - descpNew += "修改区,原区:" + formOld.area + ",新区:" + formNew.area + ";" - } - if (formNew.street != formOld.street) { - descpNew += "修改街道,原街道:" + formOld.street + ",新街道:" + formNew.street + ";" - } - if (formNew.wellname != formOld.wellname) { - descpNew += "修改井名称,原井名称:" + formOld.wellname + ",新井名称:" + formNew.wellname + ";" - } - if (formNew.factory != formOld.factory) { - descpNew += "修改权属单位,原权属单位:" + formOld.factory + ",新权属单位:" + formNew.factory + ";" - } - if (formNew.installheigt != formOld.installheigt) { - descpNew += "修改井口距离,原井口距离:" + formOld.installheigt + ",新井口距离:" + formNew.installheigt + ";" - } - if (formNew.installperson != formOld.installperson) { - descpNew += "修改运维人员,原运维人员:" + formOld.installperson + ",新运维人员:" + formNew.installperson + ";" - } - if (formNew.latitude != formOld.latitude) { - descpNew += "修改纬度,原纬度:" + formOld.latitude + ",新纬度:" + formNew.latitude + ";" - } - if (formNew.longitude != formOld.longitude) { - descpNew += "修改经度,原经度:" + formOld.longitude + ",新经度:" + formNew.longitude + ";" - } - if (formNew.position != formOld.position) { - descpNew += "修改位置描述,原位置:" + formOld.position + ",新位置:" + formNew.position + ";" - } - if (formNew.wellcode != formOld.wellcode) { - descpNew += "修改井编号,原编号:" + formOld.wellcode + ",新编号:" + formNew.wellcode + ";" - } - if (formNew.welldepth != formOld.welldepth) { - descpNew += "修改井深,原井深:" + formOld.welldepth + ",新井深:" + formNew.welldepth + ";" - } - if (formNew.welltype != formOld.welltype) { - descpNew += "修改井类型,原井类型:" + formOld.welltype + ",新井类型:" + formNew.welltype + ";" - } - if (formNew.project != formOld.project) { - descpNew += "修改所属项目,原项目:" + formOld.project + ",新项目:" + formNew.project + ";" - } - if (this.data.photopath1 != formOld.photopath1 || - this.data.photopath2 != formOld.photopath2 || - this.data.photopath3 != formOld.photopath3) { - descpNew += "修改照片;" - } - if ("" != formNew.description) { - descpNew += formNew.description; - } - this.setData({ - ['form.description']: descpNew + if (this.data.form.welldepth != null) { + if (this.isNumber(this.data.form.welldepth)) { + wx.showToast({ + icon: 'none', + title: '井深必须为数值!', }) - }, + return false + } + } + if (this.data.form.installheigt != null) { + if (this.isNumber(this.data.form.installheigt)) { + wx.showToast({ + icon: 'none', + title: '到井口距离必须为数值!', + }) + return false + } + } - formSubmit: function (event) { + return true; + }, - if (!this.formValidate()) { - return false; - } - this.changeMsg(); - var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDeviceLog', - data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceLog/add" - }, - }).then(res => { - // var resultObj=JSON.parse(res.result); - if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - if (res.confirm) { - wx.switchTab({ - url: that.data.pageName - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) - } - }).catch(err => { - console.error(err) - wx.showToast({ - title: "提交失败", - }) - }) - }, - confirm(event) { - var that = this; - var formValue = event.detail.value; - var formName = event.target.dataset.id; - var fromN = 'form.' + [formName]; - that.setData({ - [fromN]: formValue - }) - }, + //获取与上次修改的信息 + changeMsg: function () { + var formNew = this.data.form; + console.log(this.data.detail) + var formOld = JSON.parse(this.data.detail); + var descpNew = ""; + if (formNew.devcode != formOld.devcode) { + descpNew += "修改设备编号,原值:" + formOld.devcode + ",新值:" + formNew.devcode + ";" + } + if (formNew.devicetype != formOld.devicetype) { + descpNew += "修改设备类型,原值:" + formOld.devicetype + ",新值:" + formNew.devicetype + ";" + } + if (formNew.area != formOld.area) { + descpNew += "修改区,原值:" + formOld.area + ",新值:" + formNew.area + ";" + } + if (formNew.street != formOld.street) { + descpNew += "修改街道,原值:" + formOld.street + ",新值:" + formNew.street + ";" + } + if (formNew.wellname != formOld.wellname) { + descpNew += "修改井名称,原值:" + formOld.wellname + ",新值:" + formNew.wellname + ";" + } + if (formNew.factory != formOld.factory) { + descpNew += "修改权属单位,原值:" + formOld.factory + ",新值:" + formNew.factory + ";" + } + if (formNew.installheigt != formOld.installheigt) { + descpNew += "修改井口距离,原值:" + formOld.installheigt + ",新值:" + formNew.installheigt + ";" + } + if (formNew.installperson != formOld.installperson) { + descpNew += "修改运维人员,原值:" + formOld.installperson + ",新值:" + formNew.installperson + ";" + } + if (formNew.latitude != formOld.latitude) { + descpNew += "修改纬度,原值:" + formOld.latitude + ",新值:" + formNew.latitude + ";" + } + if (formNew.longitude != formOld.longitude) { + descpNew += "修改经度,原值:" + formOld.longitude + ",新值:" + formNew.longitude + ";" + } + if (formNew.position != formOld.position) { + descpNew += "修改位置描述,原值:" + formOld.position + ",新值:" + formNew.position + ";" + } + if (formNew.wellcode != formOld.wellcode) { + descpNew += "修改井编号,原值:" + formOld.wellcode + ",新值:" + formNew.wellcode + ";" + } + if (formNew.welldepth != formOld.welldepth) { + descpNew += "修改井深,原值:" + formOld.welldepth + ",新值:" + formNew.welldepth + ";" + } + if (formNew.welltype != formOld.welltype) { + descpNew += "修改井类型,原值:" + formOld.welltype + ",新值:" + formNew.welltype + ";" + } + if (formNew.project != formOld.project) { + descpNew += "修改所属项目,原值:" + formOld.project + ",新值:" + formNew.project + ";" + } + if (this.data.form.photopath1 != formOld.photopath1 || + this.data.form.photopath2 != formOld.photopath2 || + this.data.form.photopath3 != formOld.photopath3) { + descpNew += "修改照片;" + } + if ("" != formNew.description) { + descpNew += formNew.description; + } + this.setData({ + ['form.description']: descpNew + }) + }, - scan() { + //提交表单 + formSubmit: function (event) { - wx.scanCode({ - success(res) { - console.log(res) - } - }) + //表单验证 + if (!this.formValidate()) { + return false; + } + //自动生成修改内容 + this.changeMsg(); + //提交权限限制(只有施工人员能修改) + if(app.globalData.role!='repair'){ + wx.showToast({ + icon: 'none', + title: '无权限修改', + duration:2000 + }) + return false + } + var that = this; + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopath = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopath]: fileList[i].url.split("static/")[1] + }) + } + delete that.data.form.installtime + delete that.data.form.createtime + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - paste() { - var _this = this; - wx.getClipboardData({ - success: function (res) { - var longitude = 'form.longitude'; - var latitude = 'form.latitude'; - var longitude84 = 'form.longitude84'; - var latitude84 = 'form.latitude84'; - _this.setData({ - [longitude]: parseFloat(res.data.split(",", 4)[1]).toFixed(6), - [latitude]: parseFloat(res.data.split(",", 4)[0]).toFixed(6), - [longitude84]: "" == (res.data.split(",", 4)[3]) ? "" : parseFloat(res.data.split(",", 4)[3]).toFixed(6), - [latitude84]: "" == (res.data.split(",", 4)[2]) ? "" : parseFloat(res.data.split(",", 4)[2]).toFixed(6), - longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), - latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), - }); - } - }) - }, - selectValue(value) { - var that = this; - var wellType = 'form.welltype'; - that.setData({ - [wellType]: value.detail - }) - }, - selectpersonValue(event) { - var that = this; - var installPerson = 'form.installperson'; - that.setData({ - [installPerson]: event.detail - }) - }, - selectprojectValue(event) { - var that = this; - var project = 'form.project'; - that.setData({ - [project]: event.detail, - showMask: true - }) - }, - open() { - this.setData({ - showMask: true - }) - }, - close() { - this.setData({ - showMask: false - }) - }, - afterRead(event) { - var _this = this; - const { - file - } = event.detail; - const { - fileList = [] - } = _this.data; - var convertpath = ""; - wx.compressImage({ - src: event.detail.file.path, - quality: 25, - success: function (res) { - convertpath = res.tempFilePath; - wx.uploadFile({ - url: app.globalData.httpsUrl + "appDeviceAdd/fileUploadMarker", - filePath:convertpath, - name: 'file', - formData: { - 'text': "编号:" + _this.data.form.devcode + "经度:" + _this.data.form.longitude + "纬度:" + _this.data.form.latitude - }, - header: { - "Content-Type": "multipart/form-data", - 'accept': 'application/json', - }, - success(res) { - if (res.data) { - var url = JSON.parse(res.data); - fileList.push({ - ...file, - url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - }); - _this.setData({ - fileList - }); - } - } + success(res) { + if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + if (res.confirm) { + wx.switchTab({ + url: that.data.pageName }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') } - }) - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // // var base64 = "data:image/png;base64," + wx.getFileSystemManager().readFileSync(convertpath, 'base64'); - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: convertpath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // // wx.cloud.callFunction({ - // // name: 'uploadFile', - // // data: { - // // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // // fileBase64: base64 - // // }, - // // success: function (res) { - // // if (res.result) { - // // fileList.push({ - // // ...file, - // // url: app.globalData.url + "static/" + res.result.data.replace(/\\/g, "/") - // // }); - // // _this.setData({ - // // fileList - // // }); - // // } - // // }, - // // complete: res => { - // // }, - // // }) - // } - // }); + } + }) + } + }, + fail(err) { + wx.showToast({ + title: "提交失败", + }) + } + }) + }, + //报存录入的input信息 + confirm(event) { + var that = this; + var formValue = event.detail.value; + var formName = event.target.dataset.id; + var fromN = 'form.' + [formName]; + that.setData({ + [fromN]: formValue + }) + }, + + //扫码 + scan() { + + wx.scanCode({ + success(res) { + console.log(res) + } + }) + }, + //粘贴经纬度 + paste() { + var _this = this; + wx.getClipboardData({ + success: function (res) { + var longitude = 'form.longitude'; + var latitude = 'form.latitude'; + var longitude84 = 'form.longitude84'; + var latitude84 = 'form.latitude84'; + _this.setData({ + [longitude]: parseFloat(res.data.split(",", 4)[1]).toFixed(6), + [latitude]: parseFloat(res.data.split(",", 4)[0]).toFixed(6), + [longitude84]: "" == (res.data.split(",", 4)[3]) ? "" : parseFloat(res.data.split(",", 4)[3]).toFixed(6), + [latitude84]: "" == (res.data.split(",", 4)[2]) ? "" : parseFloat(res.data.split(",", 4)[2]).toFixed(6), + longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), + latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), + }); + } + }) + }, + selectValue(value) { + var that = this; + var wellType = 'form.welltype'; + that.setData({ + [wellType]: value.detail + }) + }, + //运维人员默认为登录人 + // selectpersonValue(event) { + // var that = this; + // var installPerson = 'form.installperson'; + // that.setData({ + // [installPerson]: event.detail + // }) + // }, + selectprojectValue(event) { + var that = this; + var project = 'form.project'; + that.setData({ + [project]: event.detail, + showMask: true + }) + }, + + open() { + this.setData({ + showMask: true + }) + }, + //隐藏textarea,防止遮挡 + close() { + this.setData({ + showMask: false + }) + }, + //上传照片 + afterRead(event) { + var _this = this; + const { + file + } = event.detail; + const { + fileList = [] + } = _this.data; + var convertpath = ""; + wx.compressImage({ + src: event.detail.file.path, + quality: 25, + success: function (res) { + convertpath = res.tempFilePath; + wx.uploadFile({ + url: app.globalData.httpsUrl + "appDeviceAdd/fileUploadMarker", + filePath: convertpath, + name: 'file', + formData: { + 'text': "编号:" + _this.data.form.devcode + "经度:" + _this.data.form.longitude + "纬度:" + _this.data.form.latitude }, - deletePhoto(event) { - var that = this - var image_index = event.detail.index - var fileList_new = that.data.fileList; - wx.showModal({ - content: '确定删除照片?', - success: function (res) { - if (res.confirm) { - fileList_new.splice(image_index, 1); - that.setData({ - fileList: fileList_new - }) - wx.cloud.callFunction({ - name: 'deletePhoto', - data: { - url: app.globalData.url + "appDeviceLog/deletePhoto", - devcode: that.data.form.devcode, - pathIndex: image_index - }, - success: function (res) {}, - complete: res => {}, - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + "Content-Type": "multipart/form-data", + 'accept': 'application/json', }, - }) \ No newline at end of file + success(res) { + if (res.data) { + var url = JSON.parse(res.data); + fileList.push({ + ...file, + url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") + }); + _this.setData({ + fileList + }); + } + } + }) + } + }) + }, + //删除照片 + deletePhoto(event) { + var that = this + var image_index = event.detail.index + var fileList_new = that.data.fileList; + wx.showModal({ + content: '确定删除照片?', + success: function (res) { + if (res.confirm) { + fileList_new.splice(image_index, 1); + that.setData({ + fileList: fileList_new + }) + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deletePhoto", + data: { + devcode: that.data.form.devcode + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) {} + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } +}) \ No newline at end of file diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.wxml b/miniprogram/pages/addDevicelog/addDeviceLog.wxml index 38620d4..b10cc7d 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.wxml +++ b/miniprogram/pages/addDevicelog/addDeviceLog.wxml @@ -1,15 +1,21 @@ - + + + + + - + - - + + - - + + - + @@ -39,24 +45,25 @@ - - - + + + - + - + + @@ -64,7 +71,7 @@ - + @@ -79,9 +86,9 @@ - + - 保存 + 保存 diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.wxss b/miniprogram/pages/addDevicelog/addDeviceLog.wxss index ee0b75c..08d5fd7 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.wxss +++ b/miniprogram/pages/addDevicelog/addDeviceLog.wxss @@ -24,6 +24,17 @@ display: flex; align-items: center; } +.map-view{ + width: 750rpx; + height: 485rpx; + position: fixed; + top: 0px; + left: 0px; + z-index: 999; +} +.content{ + margin-top: 495rpx; +} .left { width: 210rpx; diff --git a/miniprogram/pages/addFunction/addFunction.js b/miniprogram/pages/addFunction/addFunction.js deleted file mode 100644 index 4966be3..0000000 --- a/miniprogram/pages/addFunction/addFunction.js +++ /dev/null @@ -1,60 +0,0 @@ -// pages/addFunction/addFunction.js - -const code = `// 云函数入口函数 -exports.main = (event, context) => { - console.log(event) - console.log(context) - return { - sum: event.a + event.b - } -}` - -Page({ - - data: { - result: '', - canIUseClipboard: wx.canIUse('setClipboardData'), - }, - - onLoad: function (options) { - - }, - - copyCode: function() { - wx.setClipboardData({ - data: code, - success: function () { - wx.showToast({ - title: '复制成功', - }) - } - }) - }, - - testFunction() { - wx.cloud.callFunction({ - name: 'sum', - data: { - a: 1, - b: 2 - }, - success: res => { - wx.showToast({ - title: '调用成功', - }) - this.setData({ - result: JSON.stringify(res.result) - }) - }, - fail: err => { - wx.showToast({ - icon: 'none', - title: '调用失败', - }) - console.error('[云函数] [sum] 调用失败:', err) - } - }) - }, - -}) - diff --git a/miniprogram/pages/addFunction/addFunction.json b/miniprogram/pages/addFunction/addFunction.json deleted file mode 100644 index a9a50c5..0000000 --- a/miniprogram/pages/addFunction/addFunction.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "navigationBarTitleText": "云函数指引", - "usingComponents": {} -} \ No newline at end of file diff --git a/miniprogram/pages/addFunction/addFunction.wxml b/miniprogram/pages/addFunction/addFunction.wxml deleted file mode 100644 index 3a10626..0000000 --- a/miniprogram/pages/addFunction/addFunction.wxml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - 测试云函数 - - - 期望输出:{"sum":3} - - - 调用结果:{{result}} - - - - - 新增云函数 - 1. 在云函数根目录 cloudfunctions 上右键选择新建云函数,命名为 sum - 2. 在创建的 cloudfunctions/sum/index.js 文件中添加如下代码 - - - 3. 在 cloudfunctions/sum 目录上右键上传并部署 - 4. 点击测试云函数测试 - 5. 打开云开发云函数管理页,选择 sum 云函数 - 6. 查看 sum 的调用日志 - 进阶:可在云函数中使用 wx-server-sdk 操作数据库,文件存储和调用其他云函数,详见文档 - - - diff --git a/miniprogram/pages/addFunction/addFunction.wxss b/miniprogram/pages/addFunction/addFunction.wxss deleted file mode 100644 index 7ac8619..0000000 --- a/miniprogram/pages/addFunction/addFunction.wxss +++ /dev/null @@ -1,3 +0,0 @@ -/* pages/addFunction/addFunction.wxss */ - -@import "../../style/guide.wxss"; \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.js b/miniprogram/pages/applog/applog.js index 0e8c185..189e61f 100644 --- a/miniprogram/pages/applog/applog.js +++ b/miniprogram/pages/applog/applog.js @@ -13,98 +13,25 @@ isSeach: "false", params: {}, total: 0, - show: false + show: false, + delBtnWidth: 100, //删除按钮宽度单位(rpx) + activeIndex: -1, + list_style: '' }, - - touchE: function (e) { - // console.log(e); - var that = this - if (e.changedTouches.length == 1) { - //手指移动结束后触摸点位置的X坐标 - var endX = e.changedTouches[0].clientX; - //触摸开始与结束,手指移动的距离 - var disX = that.data.startX - endX; - var delBtnWidth = that.data.delBtnWidth; - //如果距离小于删除按钮的1/2,不显示删除按钮 - var txtStyle = disX > delBtnWidth / 2 ? "left:-" + delBtnWidth + "rpx" : "left:0rpx"; - - //获取手指触摸的是哪一项 - var index = e.currentTarget.dataset.index; - var list = that.data.deviceloglist; - list[index].txtStyle = txtStyle; - //更新列表的状态 - that.setData({ - deviceloglist: list - }); - } - }, - //手指触摸动作开始 记录起点X坐标 - touchstart: function (e) { - //开始触摸时 重置所有删除 - this.data.deviceloglist.forEach(function (v, i) { - if (v.isTouchMove) //只操作为true的 - v.isTouchMove = false; - }) - this.setData({ - startX: e.changedTouches[0].clientX, - startY: e.changedTouches[0].clientY, - deviceloglist: this.data.deviceloglist - }) - }, - //滑动事件处理 - touchmove: function (e) { - var that = this, - index = e.currentTarget.dataset.index, //当前索引 - startX = that.data.startX, //开始X坐标 - startY = that.data.startY, //开始Y坐标 - touchMoveX = e.changedTouches[0].clientX, //滑动变化坐标 - touchMoveY = e.changedTouches[0].clientY, //滑动变化坐标 - //获取滑动角度 - angle = that.angle({ - X: startX, - Y: startY - }, { - X: touchMoveX, - Y: touchMoveY - }); - that.data.deviceloglist.forEach(function (v, i) { - v.isTouchMove = false - //滑动超过30度角 return - if (Math.abs(angle) > 30) return; - if (i == index) { - if (touchMoveX > startX) //右滑 - v.isTouchMove = false - else //左滑 - v.isTouchMove = true - } - }) - //更新数据 - that.setData({ - deviceloglist: that.data.deviceloglist - }) - }, - /** - * 计算滑动角度 - * @param {Object} start 起点坐标 - * @param {Object} end 终点坐标 - */ - angle: function (start, end) { - var _X = end.X - start.X, - _Y = end.Y - start.Y - //返回角度 /Math.atan()返回数字的反正切值 - return 360 * Math.atan(_Y / _X) / (2 * Math.PI); - }, - /** - * 生命周期函数--监听页面加载var_this=this; - */ onLoad: function (options) { - if (options.params) { this.setData({ params: JSON.parse(options.params), isSeach: "true" }) this.initPages() + }else{ + this.setData({ + show: false + }) + //清空参数,重新加载 + this.clearParams(); + this.initPages(); } }, @@ -116,20 +43,33 @@ }, + //点击tabBar事件 + onTabItemTap(item) { + //隐藏历史显示总记录条数 + this.setData({ + show: false + }) + //清空参数,重新加载 + this.clearParams(); + this.initPages(); + }, + + /** * 生命周期函数--监听页面显示 */ onShow: function (options) { - this.setData({ - show:false - }) - if (this.data.isSeach == "false") { - this.clearParams(); - this.initPages(); - } - this.setData({ - isSeach: "false" - }) + + // this.setData({ + // show: false + // }) + // if (this.data.isSeach == "false") { + // this.clearParams(); + // this.initPages(); + // } + // this.setData({ + // isSeach: "false" + // }) }, /** @@ -167,6 +107,119 @@ }, + + //手指触摸动作开始 记录起点X坐标 + touchstart: function (e) { + //开始触摸时 重置所有删除 + this.data.deviceloglist.forEach(function (v, i) { + if (v.isTouchMove) //只操作为true的 + v.isTouchMove = false; + }) + this.setData({ + startX: e.changedTouches[0].clientX, + startY: e.changedTouches[0].clientY, + deviceloglist: this.data.deviceloglist + }) + }, + + //滑动事件处理 + touchmove: function (e) { + var that = this, + index = e.currentTarget.dataset.index, //当前索引 + startX = that.data.startX, //开始X坐标 + startY = that.data.startY, //开始Y坐标 + touchMoveX = e.changedTouches[0].clientX, //滑动变化坐标 + touchMoveY = e.changedTouches[0].clientY, //滑动变化坐标 + //获取滑动角度 + angle = that.angle({ + X: startX, + Y: startY + }, { + X: touchMoveX, + Y: touchMoveY + }); + that.data.deviceloglist.forEach(function (v, i) { + // v.isTouchMove = false + //滑动超过30度角 return + if (Math.abs(angle) > 30) return; + if (i == index) { + if (touchMoveX > startX) //右滑 + v.isTouchMove = false + else //左滑 + v.isTouchMove = true + } + }) + //更新数据 + that.setData({ + deviceloglist: that.data.deviceloglist + }) + }, + + /** + * 计算滑动角度 + * @param {Object} start 起点坐标 + * @param {Object} end 终点坐标 + */ + angle: function (start, end) { + var _X = end.X - start.X, + _Y = end.Y - start.Y + //返回角度 /Math.atan()返回数字的反正切值 + return 360 * Math.atan(_Y / _X) / (2 * Math.PI); + }, + + //删除事件 + delItem: function (e) { + if(app.globalData.role!='repair'){ + wx.showToast({ + icon: 'none', + title: '无权限删除', + duration:2000 + }) + return false + } + var that = this + wx.showModal({ + content: '是否删除?', + success: function (res) { + if (res.confirm) { + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/delete", + data: { + appDeviceAddId: e.currentTarget.dataset.devid + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if(res.data.code=='200'){ + that.data.deviceloglist.splice(e.currentTarget.dataset.index, 1) + that.setData({ + deviceloglist: that.data.deviceloglist, + total: that.data.deviceloglist.length + }) + wx.showToast({ + title: '删除成功!', + icon: 'none', + duration: 1000 + }) + } + }, + fail(err) { + wx.showToast({ + title: '删除失败!', + icon: 'none', + duration: 2000 + }) + } + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + }, + showLoading: function (message) { if (wx.showLoading) { // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 @@ -199,95 +252,105 @@ deviceloglist: [] }) }, + //查询列表数据 initPages: function () { var that = this + that.setData({ + show: false + }) var offsetValue = that.data.deviceloglist.length % 15 > 0 ? parseInt(that.data.deviceloglist.length / 15) + 2 : parseInt(that.data.deviceloglist.length / 15) + 1 - wx.cloud.callFunction({ - name: 'devicelog', + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/listPage", data: { devcode: that.data.params.devcode, devtype: that.data.params.devtype, installtimeFmt: that.data.params.installtimeFmt, project: that.data.params.project, installPerson: that.data.params.installPerson, - url: app.globalData.url + "appDeviceLog/listPage", limit: 15, offset: offsetValue }, - }).then(res => { - if (res.result.data.rows.length > 0) { - var resultJson = res.result - that.setData({ - deviceloglist: that.data.deviceloglist.concat(resultJson.data.rows) - }) - } else if (that.data.deviceloglist.length > 0) { - that.setData({ - show: true, - total: that.data.deviceloglist.length - }) - wx.showToast({ - title: '数据已全部加载完', - icon: 'none', - duration: 2000 - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.data.rows.length > 0) { + var resultJson = res.data + var listArr = resultJson.data.rows + listArr.forEach(function (v, i) { + listArr[i]['isTouchMove'] = false + }) + that.setData({ + deviceloglist: that.data.deviceloglist.concat(listArr) + }) + } else if (that.data.deviceloglist.length > 0) { + that.setData({ + show: true, + total: that.data.deviceloglist.length + }) + wx.showToast({ + title: '数据已全部加载完', + icon: 'none', + duration: 2000 + }) + } + if (offsetValue == 1 && res.data.data.rows.length < 15) { + that.setData({ + show: true, + total: that.data.deviceloglist.length + }) + } } - if(offsetValue==1&&res.result.data.rows.length<15){ - that.setData({ - show: true, - total: that.data.deviceloglist.length - }) - } - // console.log(res); - }).catch(err => { - console.error(err); }) + }, addDetail: function (event) { - this.showLoading("数据请求中..."); - wx.cloud.callFunction({ - name: 'deviceDetail', + var that = this + that.showLoading("数据请求中..."); + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deviceDetail", data: { devcode: event.target.dataset.devcode, - url: app.globalData.url + "appDeviceLog/deviceDetail", }, - }).then(res => { - this.hideLoading(); - var resultObject = JSON.parse(res.result); - var pageName = '../applog/applog' - if (resultObject.code == 200) { - wx.navigateTo({ - url: '../addDevicelog/addDeviceLog?detail=' + - JSON.stringify(resultObject.data) + "&pageName=" + pageName - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + that.hideLoading(); + // var resultObject = JSON.parse(res.data); + var resultObject = res.data; + var pageName = '../applog/applog' + if (resultObject.code == 200) { + wx.setStorageSync('resultObject', resultObject.data) + wx.navigateTo({ + url: '../addDevicelog/addDeviceLog?detail=' + "&pageName=" + pageName + }) + } + }, + fail(err) { + that.hideLoading(); } - }).catch(err => { - this.hideLoading() }) + }, add: function (event) { - wx.reLaunch({ - url: '../earth/earth?devcode=' + event.target.dataset.devcode - // url: '../earth/earth' + app.globalData.devcode = event.target.dataset.devcode; + wx.switchTab({ + url: '../earth/earth' }) + // wx.reLaunch({ + // url: '../earth/earth?devcode=' + event.target.dataset.devcode + // // url: '../earth/earth' + // }) }, onSearch: function () { + var _this = this wx.navigateTo({ - url: '../searchLog/searchLog' + url: '../searchLog/searchLog?params=' + JSON.stringify(_this.data.params) }) - }, - // initPages: function () { - // wx.cloud.callFunction({ - // name: 'devicelog' - // }).then(res => { - // var that = this; - // var jsonList = JSON.parse(res.result) - // that.setData({ - // deviceloglist: jsonList.data.rows - // }) - // console.log(res); - // }).catch(err => { - // console.error(err); - // }) - // } + } }) \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.wxml b/miniprogram/pages/applog/applog.wxml index e9a2352..2bfd041 100644 --- a/miniprogram/pages/applog/applog.wxml +++ b/miniprogram/pages/applog/applog.wxml @@ -1,54 +1,59 @@ - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {{item.devcode}} {{item.devicetype}} + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + {{item.devcode}} {{item.devicetype}} + + {{item.project}} {{item.installtime}}- {{item.installperson}} - - - - - + + + + + + 删除 - - - + + - 共计:{{total}}台 - + 共计:{{total}}台 + \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.wxss b/miniprogram/pages/applog/applog.wxss index 6d3428b..e6e8983 100644 --- a/miniprogram/pages/applog/applog.wxss +++ b/miniprogram/pages/applog/applog.wxss @@ -22,16 +22,18 @@ position: fixed; width: 100%; top: 0rpx; + z-index: 9999; /* margin-bottom: 100rpx; */ } .log-list { /* height: 100rpx; */ - /* display: flex; */ - + display: flex; + width: 100%; padding: 2px; margin-top: 2px; border-bottom: 1px solid #e5e5e5; + overflow: hidden } @@ -53,23 +55,29 @@ left: 35%; margin: 20rpx } - .del { - width: 90px; + /* display: flex; */ + width: 100rpx; display: flex; flex-direction: column; align-items: center; justify-content: center; - color: #fff; - -webkit-transform: translateX(90px); - transform: translateX(90px); - -webkit-transition: all 0.4s; + /* -webkit-transform: translateX(100rpx); */ + transform: translateX(100rpx); + /* -webkit-transition: all 0.4s; */ transition: all 0.4s; - font-size: 35rpx; + color: #fff; + background-color: #fe3e2f; +} +.logrow{ + width: 100%; + transform: translateX(100rpx); + /* -webkit-transform: translateX(100px); */ + margin-left: -100rpx; } -.touch-move-active .content, +.touch-move-active .logrow, .touch-move-active .del { - -webkit-transform: translateX(0); - transform: translateX(0); +/* -webkit-transform: translateX(0); */ +transform: translateX(0); } \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.js b/miniprogram/pages/deployFunctions/deployFunctions.js deleted file mode 100644 index a76b144..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.js +++ /dev/null @@ -1,66 +0,0 @@ -// pages/deployFunctions/deployFunctions.js -Page({ - - /** - * 页面的初始数据 - */ - data: { - - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - - }, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { - - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - - }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { - - }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { - - } -}) \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.json b/miniprogram/pages/deployFunctions/deployFunctions.json deleted file mode 100644 index 7fbedab..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "navigationBarTitleText": "部署云函数", - "usingComponents": {} -} \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.wxml b/miniprogram/pages/deployFunctions/deployFunctions.wxml deleted file mode 100644 index 462b6b6..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.wxml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - 调用失败 - - - 请检查 login 云函数是否已部署 - - - - - 部署 login 云函数 - 1. 确保已通过工具栏云开发入口开通云开发 - 2. 在 cloudfunctions/login 目录上右键上传并部署 - 3. 回到首页,重新点击获取 openid - - - - diff --git a/miniprogram/pages/deployFunctions/deployFunctions.wxss b/miniprogram/pages/deployFunctions/deployFunctions.wxss deleted file mode 100644 index c8803e6..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.wxss +++ /dev/null @@ -1,7 +0,0 @@ -/* pages/deployFunctions/deployFunctions.wxss */ - -@import "../../style/guide.wxss"; - -.black { - color: black; -} \ No newline at end of file diff --git a/miniprogram/pages/earth/earth.js b/miniprogram/pages/earth/earth.js index ae0d3f3..376a6e2 100644 --- a/miniprogram/pages/earth/earth.js +++ b/miniprogram/pages/earth/earth.js @@ -21,19 +21,12 @@ show: false, enableSsatellite: false, windowWidth: 0, - longitude: 113.324520, - latitude: 23.099994, - longitude84: 113.324520, - latitude84: 23.099994, - markers: [{ - id: 0, - iconPath: "../../images/locat.png", - latitude: 23.099994, - longitude: 113.324520, - width: 50, - height: 50 - }], - controls: [], + longitude: "116.627340", + latitude: "39.874390", + longitude84: "", + latitude84: "", + markers: [], + controls: [] }, /** @@ -41,39 +34,13 @@ */ onLoad: function (options) { var that = this; - //获取当前坐标(gcj02) - wx.getLocation({ - type: "gcj02", - altitude: true, - success: function (res) { - that.setData({ - latitude: parseFloat(res.latitude).toFixed(6), - longitude: parseFloat(res.longitude).toFixed(6), - // markers: [{ - // latitude: res.latitude, - // longitude: res.longitude, - // }] - }) - //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 - wx.getLocation({ - type: "wgs84", - altitude: true, - success: function (res) { - that.setData({ - latitude84: parseFloat(res.latitude).toFixed(6), - longitude84: parseFloat(res.longitude).toFixed(6) - }) - } - }) - } - }), - - //设置地图组件 - wx.getSystemInfo({ + //设置地图组件 + wx.getSystemInfo({ success(res) { var windowWidth = res.windowWidth var windowHeight = res.windowHeight var query = wx.createSelectorQuery() + var platform =res.platform query.select('#map').boundingClientRect() query.exec(function (res) { that.setData({ @@ -139,10 +106,20 @@ clickable: true }, { id: 7, - iconPath: '../../images/locat.png', + iconPath: '../../images/applocat.png', position: { - left: res[0].width/2, - top: res[0].height/2, + left: res[0].width / 2 - 20, + top: platform=="ios"?res[0].height / 2 - 80:res[0].height / 2 - 40, + width: 40, + height: 40 + }, + clickable: true + }, { + id: 8, + iconPath: '../../images/back.png', + position: { + left: windowWidth - 40, + top: windowHeight - 140, width: 30, height: 30 }, @@ -150,71 +127,15 @@ }] }) }) - + } - }), + }) + // 实例化API核心类 qqmapsdk = new QQMapWX({ key: 'BGPBZ-C5O3P-ROUDR-LWC4J-63EKH-V5FRX' }) - - if (options.devcode) { - var that = this - var devcode = options.devcode - wx.cloud.callFunction({ - name: 'findListByCodes', - data: { - devcodes: devcode, - url: app.globalData.url + "appDeviceAdd/findListByCodes" - }, - }).then(res => { - if (res.result.code == 200) { - var listResultData = res.result.data; - that.setData({ - listData: listResultData - }) - var markersArr = that.data.markers; - for (var i = 0; i < listResultData.length; i++) { - markersArr = markersArr.concat({ - iconPath: "../../images/locat.png", - id: listResultData[i].id, - callout: { - content: listResultData[i].devcode, - fontSize: '14', - // padding: true, - color: '#00000', - borderColor: '#F4EA2A', - bgColor: '#F4EA2A', - borderWidth: 5, - display: 'ALWAYS', - textAlign: 'center', - // borderRadius: 15 - }, - latitude: listResultData[i].latitude, - longitude: listResultData[i].longitude, - width: 40, - height: 40 - }); - } - this.setData({ - markers: markersArr, - latitude: listResultData[0].latitude, - longitude: listResultData[0].longitude, - marker_latitude: listResultData[0].latitude, - marker_longitude: listResultData[0].longitude, - title: listResultData[0].devcode - }) - } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "无法获取设备地理信息!", - icon: 'none', - duration: 2000 - }) - }) - } }, /** @@ -228,6 +149,97 @@ * 生命周期函数--监听页面显示 */ onShow: function () { + //输入设备编号获取marker位置信息 + var that = this; + if ( app.globalData.devcode!="") { + var devcode = app.globalData.devcode + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/findListByCodes", + data: { + devcodes: devcode, + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + app.globalData.devcode=""; + if (res.data.code == 200) { + var listResultData = res.data.data; + that.setData({ + listData: listResultData + }) + var markersArr = that.data.markers; + for (var i = 0; i < listResultData.length; i++) { + markersArr = markersArr.concat({ + iconPath: "../../images/locat.png", + id: Number(listResultData[i].id), + callout: { + content: "编号:"+listResultData[i].devcode+"\r\n位置:"+listResultData[i].position+"\r\n时间:"+listResultData[i].createtime, + fontSize: '14', + padding: true, + color: '#000000', + borderColor: '#F4EA2A', + bgColor: '#F4EA2A', + borderWidth: 5, + display: 'ALWAYS', + textAlign: 'left', + // borderRadius: 15 + }, + latitude: listResultData[i].latitude, + longitude: listResultData[i].longitude, + width: 40, + height: 40 + }); + } + that.setData({ + markers: markersArr, + latitude: listResultData[0].latitude, + longitude: listResultData[0].longitude, + marker_latitude: listResultData[0].latitude, + marker_longitude: listResultData[0].longitude, + title: listResultData[0].devcode + }) + } + }, + fail(err) { + app.globalData.devcode=""; + wx.showToast({ + title: "无法获取设备地理信息!", + icon: 'none', + duration: 2000 + }) + } + }) +} else { + //获取当前坐标(gcj02) + wx.getLocation({ + type: "gcj02", + altitude: true, + success: function (res) { + that.setData({ + latitude: parseFloat(res.latitude).toFixed(6), + longitude: parseFloat(res.longitude).toFixed(6), + // markers: [{ + // latitude: res.latitude, + // longitude: res.longitude, + // }] + }) + //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 + wx.getLocation({ + type: "wgs84", + altitude: true, + success: function (res) { + that.setData({ + latitude84: parseFloat(res.latitude).toFixed(6), + longitude84: parseFloat(res.longitude).toFixed(6) + }) + } + }) + } + }) +} + }, @@ -265,12 +277,46 @@ onShareAppMessage: function () { }, + + //定位出来 + + locationPosition: function () { + var that = this; + //获取当前坐标(gcj02) + wx.getLocation({ + type: "gcj02", + altitude: true, + success: function (res) { + that.setData({ + latitude: parseFloat(res.latitude).toFixed(6), + longitude: parseFloat(res.longitude).toFixed(6), + // markers: [{ + // latitude: res.latitude, + // longitude: res.longitude + // }] + }) + //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 + wx.getLocation({ + type: "wgs84", + altitude: true, + success: function (res) { + that.setData({ + latitude84: parseFloat(res.latitude).toFixed(6), + longitude84: parseFloat(res.longitude).toFixed(6) + }) + } + }) + } + }) + }, + + //加载地图组件 controltap: function (e) { // console.log(e.controlId); //进入添加设备页 if (1 == e.controlId) { wx.setClipboardData({ - data: this.data.latitude + "," + this.data.longitude+ "," + this.data.latitude84+ "," + this.data.longitude84, + data: this.data.latitude + "," + this.data.longitude + "," + this.data.latitude84 + "," + this.data.longitude84, success: function (res) { wx.getClipboardData({ success: function (res) { @@ -282,6 +328,17 @@ } }) } else if (3 == e.controlId) { + //先定位 + // this.locationPosition() + wx.setClipboardData({ + data: this.data.latitude + "," + this.data.longitude + "," + this.data.latitude84 + "," + this.data.longitude84, + success: function (res) { + wx.showToast({ + title: '坐标已获取', + duration: 1000 + }) + } + }) wx.navigateTo({ url: '../addDevice/addDevice' }) @@ -302,32 +359,15 @@ enableSsatellite: !flag }); } else if (6 == e.controlId) { - var that = this; - //获取当前坐标(gcj02) - wx.getLocation({ - type: "gcj02", - altitude: true, - success: function (res) { - that.setData({ - latitude: parseFloat(res.latitude).toFixed(6), - longitude:parseFloat(res.longitude).toFixed(6), - // markers: [{ - // latitude: res.latitude, - // longitude: res.longitude - // }] - }) - //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 - wx.getLocation({ - type: "wgs84", - altitude: true, - success: function (res) { - that.setData({ - latitude84: parseFloat(res.latitude).toFixed(6), - longitude84: parseFloat(res.longitude).toFixed(6) - }) - } - }) - } + //先清marker + this.setData({ + markers: [] + }) + this.locationPosition() + }else if (8 == e.controlId) { + //跳转日志缓存页 + wx.switchTab({ + url: '../applog/applog', }) } }, @@ -343,63 +383,68 @@ }); }, + //获取设备maker leave() { var that = this; if (that.data.devcodes == "") { return false; } - wx.cloud.callFunction({ - name: 'findListByCodes', + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/findListByCodes", data: { - devcodes: that.data.devcodes, - url: app.globalData.url + "appDeviceAdd/findListByCodes" + devcodes: that.data.devcodes }, - }).then(res => { - if (res.result.code == 200) { - var listResultData = res.result.data; - that.setData({ - listData: listResultData - }) - var markersArr = that.data.markers; - for (var i = 0; i < listResultData.length; i++) { - markersArr = markersArr.concat({ - iconPath: "../../images/locat.png", - id: listResultData[i].id, - callout: { - content: listResultData[i].devcode, - fontSize: '14', - // padding: true, - color: '', - borderColor: '#F4EA2A', - bgColor: '#F4EA2A', - borderWidth: 5, - display: 'ALWAYS', - textAlign: 'center', - // borderRadius: 15 - }, - latitude: listResultData[i].latitude, - longitude: listResultData[i].longitude, - width: 40, - height: 40 - }); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var listResultData = res.data.data; + that.setData({ + listData: listResultData + }) + var markersArr = that.data.markers; + for (var i = 0; i < listResultData.length; i++) { + markersArr = markersArr.concat({ + iconPath: "../../images/locat.png", + id: listResultData[i].id, + callout: { + content: "编号:"+listResultData[i].devcode+"\r\n位置:"+listResultData[i].position+"\r\n时间:"+listResultData[i].createtime, + fontSize: '14', + // padding: true, + color: '#212121', + borderColor: '#F4EA2A', + bgColor: '#F4EA2A', + borderWidth: 5, + display: 'ALWAYS', + textAlign: 'left', + // borderRadius: 15 + }, + latitude: listResultData[i].latitude, + longitude: listResultData[i].longitude, + width: 40, + height: 40 + }); + } + that.setData({ + markers: markersArr, + latitude: listResultData[0].latitude, + longitude: listResultData[0].longitude, + marker_latitude: listResultData[0].latitude, + marker_longitude: listResultData[0].longitude, + title: listResultData[0].devcode + }) } - this.setData({ - markers: markersArr, - latitude: listResultData[0].latitude, - longitude: listResultData[0].longitude, - marker_latitude: listResultData[0].latitude, - marker_longitude: listResultData[0].longitude, - title: listResultData[0].devcode + }, + fail(err) { + wx.showToast({ + title: "无法获取设备地理信息!", + icon: 'none', + duration: 2000 }) } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "无法获取设备地理信息!", - icon: 'none', - duration: 2000 - }) }) }, @@ -422,6 +467,8 @@ } }, + + bindregionchange: function (e) { var that = this if (e.causedBy == "drag") { @@ -445,8 +492,8 @@ that.setData({ latitude: parseFloat(latitude).toFixed(6), longitude: parseFloat(longitude).toFixed(6), - latitude84:"", - longitude84:"", + latitude84: "", + longitude84: "", // markers: markersArr }) // mapCtx.moveToLocation(); @@ -465,16 +512,19 @@ qqmapsdk.search({ keyword: this.data.value, success: function (res) { + console.log(res) if (res && res.data) { _this.setData({ isShow: true, tips: res.data }); } + }, + complete: function (res){ + console.log(res); } }) }, - bindSearch: function (e) { var location = e.target.dataset.location; this.setData({ diff --git a/miniprogram/pages/earth/earth.wxml b/miniprogram/pages/earth/earth.wxml index a0db6ef..87474f8 100644 --- a/miniprogram/pages/earth/earth.wxml +++ b/miniprogram/pages/earth/earth.wxml @@ -1,9 +1,10 @@ + - + {{item.title}} {{item.address}} @@ -17,6 +18,6 @@ + placeholder="请输入定位设备编号用换行隔开" autosize border="{{ false }}" /> \ No newline at end of file diff --git a/miniprogram/pages/indexapp/indexapp.js b/miniprogram/pages/indexapp/indexapp.js index 5063372..849dbdb 100644 --- a/miniprogram/pages/indexapp/indexapp.js +++ b/miniprogram/pages/indexapp/indexapp.js @@ -7,9 +7,8 @@ */ data: { - count:1, - show: false, - onshow:true, + count: 1, + onshow: true, value: "", deviceloglist: [], devcode: "", @@ -21,6 +20,7 @@ // iconPath: "../../images/point.png", latitude: 23.099994, longitude: 113.324520, + label:'1', width: 50, height: 50 }], @@ -31,62 +31,26 @@ * 生命周期函数--监听页面加载 */ onLoad: function (options) { - + }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { - + }, /** * 生命周期函数--监听页面显示 */ onShow: function () { - // if( app.globalData.indexCount>1){ - // this.setData({ - // show:false - // }) - // }else{ - // this.showNotice() - // } - if(app.globalData.indexCount==1){ - this.setData({ - show:true - }) - this.showNotice() - } - app.globalData.indexCount+=1 - if(this.data.onshow){ + if (this.data.onshow) { this.initPages(); } }, - - showNotice: function() { - var that = this - var times = 0 - var i = setInterval(function() { - times++ - if (times >= 15) { - that.setData({ - show:false - }) - wx.showTabBar({ - animation: false, - }) - clearInterval(i) - } else { - wx.hideTabBar({ - animation: false, - }) - } - }, 1000) -}, - /** * 生命周期函数--监听页面隐藏 */ @@ -122,16 +86,27 @@ }, jump: function (event) { - var that = this; var latitude = event.target.dataset.pointLat; var longitude = event.target.dataset.pointLon; + let devcode = event.target.dataset.pointCode; that.setData({ latitude: latitude, longitude: longitude, markers: [{ latitude: latitude, - longitude: longitude + longitude: longitude, + callout: { + display:'ALWAYS',// 常显气泡 + content: devcode, //名称文本 + color: '#fff', //文本颜色 + borderRadius: 5, //边框圆角 + borderWidth: 1, //边框宽度 + borderColor: '#0060ff', //边框颜色 + bgColor: '#0060ff', //背景色 + padding: 5, //文本边缘留白 + textAlign: 'center' //文本对齐方式。有效值: left, right, center + } }] }) }, @@ -142,7 +117,7 @@ var devcode = res.result _this.setData({ devcode: devcode, - onshow:false + onshow: false }); _this.searchlogs(devcode) } @@ -151,40 +126,11 @@ onSearch: function (event) { this.setData({ - devcode:event.detail + devcode: event.detail }) this.searchlogs(event.detail) }, - - // bindregionchange: function (e) { - // var that = this - // if (e.causedBy == "drag") { - // var mapCtx = wx.createMapContext("map") - // mapCtx.getCenterLocation({ - // success: function (res) { - // var markersArr = that.data.markers - // for (var i = 0; i < markersArr.length; i++) { - // if (markersArr[i].iconPath == undefined) { - // markersArr.splice(i, 1) - // } - // } - // var latitude = res.latitude - // var longitude = res.longitude - // markersArr = markersArr.concat({ - // latitude: latitude, - // longitude: longitude - // }) - // that.setData({ - // latitude: latitude, - // longitude: longitude, - // markers: markersArr - // }) - // } - // }) - // } - // }, - showLoading: function (message) { if (wx.showLoading) { // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 @@ -211,81 +157,89 @@ } }, + //加载设备运维详细信息 toDetail: function (event) { - this.showLoading("数据加载中...") - wx.cloud.callFunction({ - name: 'deviceDetail', + var that = this + that.showLoading("数据加载中...") + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deviceDetail", data: { devcode: event.target.dataset.devcode, - url: app.globalData.url + "appDeviceLog/deviceDetail", }, - }).then(res => { - this.hideLoading(); - var resultObject = JSON.parse(res.result); - var pageName='../indexapp/indexapp' - if (resultObject.code == 200) { - wx.navigateTo({ - url: '../addDevicelog/addDeviceLog?detail=' + - JSON.stringify(resultObject.data)+'&pageName='+pageName - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + that.hideLoading(); + var resultObject = res.data; + var pageName = '../indexapp/indexapp' + if (resultObject.code == 200) { + wx.setStorageSync('resultObject', resultObject.data) + wx.navigateTo({ + url: '../addDevicelog/addDeviceLog?detail=' +'&pageName=' + pageName + }) + } + }, + fail(err){ + that.hideLoading(); } - }).catch(err => { - this.hideLoading(); }) }, + //加载列表 getlogs: function (devcode) { var that = this - wx.cloud.callFunction({ - name: 'devicelog', + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/listPage", data: { devcode: devcode, - url: app.globalData.url + "appDeviceLog/listPage", limit: 100, offset: that.data.deviceloglist.length % 100 > 0 ? parseInt(that.data.deviceloglist.length / 100) + 2 : parseInt(that.data.deviceloglist.length / 100) + 1 }, - }).then(res => { - if (res.result) { - // var resultJson = JSON.parse(res.result) - var resultJson = res.result - that.setData({ - deviceloglist: that.data.deviceloglist.concat(resultJson.data.rows) - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + // var resultJson = JSON.parse(res.result) + var resultJson = res.data + that.setData({ + deviceloglist: that.data.deviceloglist.concat(resultJson.data.rows) + }) + } } - console.log(res); - }).catch(err => { - console.error(err); }) }, + //查询列表 searchlogs: function (devcode) { var that = this - wx.cloud.callFunction({ - name: 'devicelog', + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/listPage", data: { devcode: devcode, - url: app.globalData.url + "appDeviceLog/listPage", limit: 100, offset: 1 }, - }).then(res => { - if (res.result) { - var resultJson = res.result - that.setData({ - deviceloglist: resultJson.data.rows, - onshow:true - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var resultJson = res.data + that.setData({ + deviceloglist: resultJson.data.rows, + onshow: true + }) + } } - console.log(res); - }).catch(err => { - console.error(err); }) }, initPages: function () { var that = this; - that.setData({ - devcode: "" - }); wx.getLocation({ type: "gcj02", success: function (res) { @@ -302,6 +256,6 @@ }) } }) - this.searchlogs() + this.data.devcode !== '' ? this.searchlogs(this.data.devcode) : this.searchlogs() }, }) \ No newline at end of file diff --git a/miniprogram/pages/indexapp/indexapp.wxml b/miniprogram/pages/indexapp/indexapp.wxml index 69322a0..f65b082 100644 --- a/miniprogram/pages/indexapp/indexapp.wxml +++ b/miniprogram/pages/indexapp/indexapp.wxml @@ -1,8 +1,12 @@ + + + + - @@ -32,9 +36,15 @@ - + + + + + + + @@ -46,14 +56,14 @@ - + - - + diff --git a/miniprogram/pages/indexapp/indexapp.wxss b/miniprogram/pages/indexapp/indexapp.wxss index b18706a..fc27fcb 100644 --- a/miniprogram/pages/indexapp/indexapp.wxss +++ b/miniprogram/pages/indexapp/indexapp.wxss @@ -128,6 +128,7 @@ .noticeClass{ height: 2300rpx; width: 750rpx; + overflow-y:hidden; } @@ -148,14 +149,14 @@ } +/* .vanstyle{ + button: not([size='mini']) { + user agent stylesheetmin-height: 40px; + width: 650rpx; + margin-left: 20rpx; + margin-right: auto; + + } + +} */ -/* .van-enter-active-class, -.van-leave-active-class { - transition-property: background-color, transform; -} - -.van-enter-class, -.van-leave-to-class { - background-color: red; - transform: rotate(-360deg) translate3d(-100%, -100%, 0); -} */ \ No newline at end of file diff --git a/miniprogram/pages/log/log.js b/miniprogram/pages/log/log.js deleted file mode 100644 index 83ba349..0000000 --- a/miniprogram/pages/log/log.js +++ /dev/null @@ -1,66 +0,0 @@ -// pages/log/log.js -Page({ - - /** - * 页面的初始数据 - */ - data: { - - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - - }, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { - - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - - }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { - - }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { - - } -}) \ No newline at end of file diff --git a/miniprogram/pages/log/log.json b/miniprogram/pages/log/log.json deleted file mode 100644 index 8835af0..0000000 --- a/miniprogram/pages/log/log.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "usingComponents": {} -} \ No newline at end of file diff --git a/miniprogram/pages/log/log.wxml b/miniprogram/pages/log/log.wxml deleted file mode 100644 index a510ad6..0000000 --- a/miniprogram/pages/log/log.wxml +++ /dev/null @@ -1,2 +0,0 @@ - -pages/log/log.wxml diff --git a/miniprogram/pages/log/log.wxss b/miniprogram/pages/log/log.wxss deleted file mode 100644 index 23db318..0000000 --- a/miniprogram/pages/log/log.wxss +++ /dev/null @@ -1 +0,0 @@ -/* pages/log/log.wxss */ \ No newline at end of file diff --git a/cloudfunctions/project.config.json b/cloudfunctions/project.config.json new file mode 100644 index 0000000..2b3119a --- /dev/null +++ b/cloudfunctions/project.config.json @@ -0,0 +1,28 @@ +{ + "appid": "wx2cef527a000f87c9", + "compileType": "miniprogram", + "libVersion": "2.27.3", + "packOptions": { + "ignore": [], + "include": [] + }, + "setting": { + "coverView": true, + "es6": true, + "postcss": true, + "minified": true, + "enhance": true, + "showShadowRootInWxmlPanel": true, + "packNpmRelationList": [], + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + } + }, + "condition": {}, + "editorSetting": { + "tabIndent": "insertSpaces", + "tabSize": 4 + } +} \ No newline at end of file diff --git a/cloudfunctions/project.private.config.json b/cloudfunctions/project.private.config.json new file mode 100644 index 0000000..42ff49d --- /dev/null +++ b/cloudfunctions/project.private.config.json @@ -0,0 +1,7 @@ +{ + "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", + "projectname": "cloudfunctions", + "setting": { + "compileHotReLoad": true + } +} \ No newline at end of file diff --git a/miniprogram/app.js b/miniprogram/app.js index 51d56f3..50a8a54 100644 --- a/miniprogram/app.js +++ b/miniprogram/app.js @@ -18,13 +18,15 @@ // this.globalData = {} }, globalData: { - // url: "http://111.198.10.15:11604/", - httpsUrl: "https://logapi.smartlog.work/", - httpsTestUrl: "https://smartlog.work/prodapi4test/", - url: "http://139.198.18.188:8083/", + httpsUrl: "https://logapi.smartlog.work/", + // httpsUrl: "http://139.198.18.188:8083/", // url: "http://127.0.0.1:8083/", - // httpsUrl: "http://127.0.0.1:8083/", + //httpsUrl: "http://127.0.0.1:8083/", openid: null, - indexCount:1 - }, + indexCount:1, + nickName:"", + userName:"", + role:"", + devcode:"" + } }) diff --git a/miniprogram/app.json b/miniprogram/app.json index d23f798..2b6db76 100644 --- a/miniprogram/app.json +++ b/miniprogram/app.json @@ -1,15 +1,17 @@ { "cloud": true, "pages": [ + "pages/login/login", "pages/indexapp/indexapp", "pages/earth/earth", "pages/applog/applog", "pages/addDevice/addDevice", "pages/addDevicelog/addDeviceLog", - "pages/searchLog/searchLog" + "pages/searchLog/searchLog", + "pages/notice/notice" ], "window": { - "backgroundColor": "#F6F6F6", + "backgroundColor": "#E6D480", "backgroundTextStyle": "light", "navigationBarBackgroundColor": "#FFCF00", "navigationBarTitleText": "智慧施工", @@ -46,11 +48,11 @@ "desc": "你的位置信息将用于小程序位置接口的效果展示" } }, + "requiredPrivateInfos": ["getLocation", "chooseLocation"], "networkTimeout": { "request": 30000, "connectSocket": 30000, "uploadFile": 30000, "downloadFile": 30000 - }, - "style": "v2" + } } \ No newline at end of file diff --git a/miniprogram/images/applocat.png b/miniprogram/images/applocat.png new file mode 100644 index 0000000..fe49f54 --- /dev/null +++ b/miniprogram/images/applocat.png Binary files differ diff --git a/miniprogram/images/back.png b/miniprogram/images/back.png new file mode 100644 index 0000000..32ac82d --- /dev/null +++ b/miniprogram/images/back.png Binary files differ diff --git a/miniprogram/images/bottom.png b/miniprogram/images/bottom.png new file mode 100644 index 0000000..d910e98 --- /dev/null +++ b/miniprogram/images/bottom.png Binary files differ diff --git a/miniprogram/images/header.png b/miniprogram/images/header.png new file mode 100644 index 0000000..6ea222e --- /dev/null +++ b/miniprogram/images/header.png Binary files differ diff --git a/miniprogram/images/login.png b/miniprogram/images/login.png index 8b73cc0..6471c46 100644 --- a/miniprogram/images/login.png +++ b/miniprogram/images/login.png Binary files differ diff --git a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss index 5a591fb..c9c35b5 100644 --- a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss +++ b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:100%;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:100%}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file +@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:650rpx;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:600rpx}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file diff --git a/miniprogram/pages/addDevice/addDevice.js b/miniprogram/pages/addDevice/addDevice.js index 2783674..78f00b7 100644 --- a/miniprogram/pages/addDevice/addDevice.js +++ b/miniprogram/pages/addDevice/addDevice.js @@ -1,5 +1,7 @@ // miniprogram/pages/addDevice/addDevice.js // import WxValidate from '../../utils/WxValidate.js' +var QQMapWX = require('../../libs/qqmap-wx-jssdk.js'); +var qqmapsdk; var app = getApp() Page({ @@ -11,32 +13,10 @@ canvasWidth: '', longitude: '', latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], + option1: [], personoption1: [], projectoption: [], + devtypeList:[], show: false, form: { devcode: "", @@ -59,7 +39,10 @@ project: "", area: "", street: "", - wellname: "" + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '', }, fileList: [] }, @@ -117,12 +100,14 @@ var that = this; //初始化表单内容为上次填写值 var cacheForms = wx.getStorageSync('cacheList') - if (cacheForms) { + cacheForms.photopath1='' + cacheForms.photopath2='' + cacheForms.photopath3='' + that.data.fileList=[] that.setData({ form: cacheForms, devcode: cacheForms.devcode, - }) } var form = that.data.form @@ -155,55 +140,89 @@ } }) + +//获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + that.setData({ + option1: welltypeArr + }) + } + } +}) + + //获取人员下拉列表 - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/getUser", + data:{ + tips:'repair' }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data.code == 200) { + var users = res.data.data + var personArr = []; + for (var i = 0; i < users.length; i++) { + var person = { + text: users[i].name, + value: users[i].name + }; + personArr.push(person); + } + that.setData({ + personoption1: personArr + }) } - that.setData({ - personoption1: personArr - }) } - }).catch(err => { - console.error(err); - }) + }) + - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - that.setData({ - projectoption: projectArr - }) + success(res){ + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); + } + that.setData({ + projectoption: projectArr + }) + } } - }).catch(err => { - console.error(err); - }) + }) + var installtime = 'form.installtimeFmt'; var dateNow = this.formatDate(); this.setData({ @@ -211,8 +230,40 @@ installtimeFmt: dateNow, [installtime]: dateNow, }); + + + + /** + * 获取设备类型下拉列表 + */ + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/deviceType", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var TypeList = res.data.data + var typeArr = []; + for (var i = 0; i < TypeList.length; i++) { + var type = { + text: TypeList[i].productName, + value: TypeList[i].productName + }; + typeArr.push(type); + } + that.setData({ + devtypeList: typeArr + }) + } + } + }) }, + + + /** * 生命周期函数--监听页面初次渲染完成 */ @@ -280,29 +331,7 @@ }, - - //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 - drawText: function (ctx, str, leftWidth, initHeight, titleHeight, canvasWidth) { - var lineWidth = 0; - var lastSubStrIndex = 0; //每次开始截取的字符串的索引 - for (let i = 0; i < str.length; i++) { - lineWidth += ctx.measureText(str[i]).width; - if (lineWidth > canvasWidth) { - ctx.fillText(str.substring(lastSubStrIndex, i), leftWidth, initHeight); //绘制截取部分 - initHeight = initHeight + leftWidth * 2; //22为字体的高度 - lineWidth = 0; - lastSubStrIndex = i; - // titleHeight += 40; - } - if (i == str.length - 1) { //绘制剩余部分 - ctx.fillText(str.substring(lastSubStrIndex, i + 1), leftWidth, initHeight); - } - } - // // 标题border-bottom 线距顶部距离 - // titleHeight = titleHeight + 10; - // return titleHeight - }, - + //验证表单 formValidate() { if (this.data.form.devcode == "") { @@ -312,27 +341,20 @@ }) return false } - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } if (this.data.form.wellcode == "") { wx.showToast({ icon: 'none', @@ -348,22 +370,10 @@ }) return false } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null) { + + if (this.data.form.installperson == "") { wx.showToast({ icon: 'none', title: '安装人员不能为空!', @@ -408,56 +418,90 @@ } return true; }, + //提交表单 formSubmit: function (event) { + console.log(this.data.form) + //表单参数验证 if (!this.formValidate()) { return false; } var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDevice', + //验证设备编号长度 + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/getDevTypeLength", data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceAdd/add" + code: encodeURI(this.data.form.devicetype) }, - }).then(res => { - if (res.result.code == 500) { - wx.showToast({ - title: '设备编号已安装!', - }) - } else if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - //用于回显 - wx.setStorageSync('cacheList', that.data.form) - //提交成功后提示用户操作 - if (res.confirm) { - wx.switchTab({ - url: '../earth/earth' - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (""==res.data.data ||res.data.data == that.data.form.devcode.length) { + that.saveDevice() + } else { //编号位数不对提示 + wx.showToast({ + icon: 'none', + title: '设备编号位数不对!', + duration: 1000 + }) + return false + } } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "提交失败", - }) }) }, + + //保存设备基本信息 + saveDevice() { + var that = this; + //设置照片路径 + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopathForm = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopathForm]: fileList[i].url.split("static/")[1] + }) + } + //表单提交 + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 500) { + wx.showToast({ + title: '设备编号已安装!', + }) + } else if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + //用于回显 + wx.setStorageSync('cacheList', that.data.form) + //提交成功后提示用户操作 + if (res.confirm) { + wx.switchTab({ + url: '../earth/earth' + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } + }, + fail(err) { + wx.showToast({ + title: '提交失败!', + }) + } + }) + }, + + //input 输入框设置值 confirm(event) { var that = this; var formValue = event.detail.value; @@ -466,8 +510,30 @@ that.setData({ [fromN]: formValue }) + //若输入是设备编号,自动获取设备类型 + if('devcode'==formName){ + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", + data: { + devcode: formValue, + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + that.setData({ + [formDevicetype]: res.data + }); + } + } + }) + } }, + //扫描设备获取编号和设备类型 scan() { var _this = this; wx.scanCode({ @@ -477,23 +543,28 @@ _this.setData({ [formdevcode]: devcode }); - wx.cloud.callFunction({ - name: 'findModeCode', + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", data: { devcode: devcode, - url: app.globalData.url + "appDeviceAdd/findModeCodeByCode" }, - }).then(res => { - if (res.result) { - var formDevicetype = 'form.devicetype' - _this.setData({ - [formDevicetype]: res.result - }); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + _this.setData({ + [formDevicetype]: res.data + }); + } } }) } }) }, + //粘贴经纬度 paste() { var _this = this; wx.getClipboardData({ @@ -510,9 +581,11 @@ longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), }); + _this.showAddress(_this.data.form.longitude,_this.data.form.latitude,_this) } }) }, + //设置经类型 selectValue(value) { var that = this; @@ -521,6 +594,16 @@ [wellType]: value.detail }) }, + + //设置设备类型 + selectDevType(event) { + var that = this; + var devtype = 'form.devicetype'; + that.setData({ + [devtype]: event.detail + }) + }, + //设置运维人员 selectpersonValue(event) { var that = this; var installPerson = 'form.installperson'; @@ -528,6 +611,7 @@ [installPerson]: event.detail }) }, + //设置项目 selectprojectValue(event) { var that = this; var project = 'form.project'; @@ -535,8 +619,41 @@ [project]: event.detail }) }, + showAddress :function(longitude, latitude, self) { + // 实例化腾讯地图API核心类 + qqmapsdk = new QQMapWX({ + key: 'BGPBZ-C5O3P-ROUDR-LWC4J-63EKH-V5FRX'//此处使用你自己申请的key + }) + // 腾讯地图调用接口 + qqmapsdk.reverseGeocoder({ + location: { + latitude: latitude, + longitude: longitude + }, + success: function (res) { + self.setData({ + 'form.area':res.result.address.slice(0,res.result.address.indexOf('区')+1), + 'form.street':res.result.address.slice(res.result.address.indexOf('区')+1) + }) + }, + fail: function (res) { + console.log(res); + }, + complete: function (res) { + } + }); + }, + //上传照片 afterRead(event) { var _this = this; + if (_this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '请先填写设备编号!\r\n否则水印中无编号', + duration: 2000 + }) + return false + } const { file } = event.detail; @@ -576,78 +693,8 @@ }) } }) - // 压缩图片 - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // //获取图片尺寸 - // wx.getImageInfo({ - // src: convertpath, - // success(res) { - // _this.setData({ - // canvasHeight: res.height, - // canvasWidth: res.width - // }) - // var ctx = wx.createCanvasContext('firstCanvas') - - // //将图片src放到cancas内,宽高为图片大小 - // ctx.drawImage(convertpath, 0, 0, res.width, res.height) - // //将声明的时间放入canvas - // ctx.setFontSize(30 * (res.width / 750)) //注意:设置文字大小必须放在填充文字之前,否则不生效 - // ctx.setFillStyle('blue') - // var text = "编号:" + _this.data.form.devcode + "\n经度:" + _this.data.form.longitude + "\n纬度:" + _this.data.form.latitude - // // _this.drawText(ctx,text,20, 70, 5, res.width) - // _this.drawText(ctx, text, 15 * (res.width / 750), 70 * (res.width / 750), 5, res.width) - - // // ctx.fillText(text, 0, 40) - // // ctx.strokeText(_this.data.form.devcode, 0, 30) - // //生成水印图 - // ctx.draw(false, function () { - // wx.canvasToTempFilePath({ - // canvasId: 'firstCanvas', - // success: (res) => { - // wx.compressImage({ - // src: res.tempFilePath, - // quality: 25, - // success: function (res) { - // //上传照片至服务器 - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: res.tempFilePath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // } - // }) - // //// - // } - // }) - // }) - // } - // }) - // } - // }); }, + //删除照片 deletePhoto(event) { var image_index = event.detail.index var fileList_new = this.data.fileList; diff --git a/miniprogram/pages/addDevice/addDevice.wxml b/miniprogram/pages/addDevice/addDevice.wxml index b0977e2..f12c254 100644 --- a/miniprogram/pages/addDevice/addDevice.wxml +++ b/miniprogram/pages/addDevice/addDevice.wxml @@ -5,18 +5,30 @@ - + + + + + + + + + + + + + - - + + - - - + + + @@ -29,13 +41,13 @@ - + - + - + - + @@ -54,8 +66,7 @@ - - + @@ -68,8 +79,8 @@ - - + + - 保存 + 保存 \ No newline at end of file diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.js b/miniprogram/pages/addDevicelog/addDeviceLog.js index cdec71b..a0dc6da 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.js +++ b/miniprogram/pages/addDevicelog/addDeviceLog.js @@ -3,681 +3,665 @@ var app = getApp(); Page({ - /** - * 页面的初始数据 - */ - data: { - pageName: '', - showMask: false, - today: new Date().getTime(), - longitude: '', - latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], - personoption1: [], - projectoption: [], - devcode: "", - deviceMode: "", - installtimeFmt: '', - show: false, - form: { - devcode: "", - wellcode: "", - welltype: "", - welldepth: "", - installheigt: "", - installperson: "", - installtimeFmt: "", - photopath: "", - factory: "", - workmsg: "", - position: "", - description: "", - longitude: "", - latitude: "", - longitude84: "", - latitude84: "", - devicetype: "", - project: "", - area: "", - street: "", - wellname: "" - }, - fileList: [], - detail: "" - }, + /** + * 页面的初始数据 + */ + data: { + pageName: '', + showMask: false, + today: new Date().getTime(), + longitude: '', + latitude: '', + option1: [], + personoption1: [], + projectoption: [], + devcode: "", + deviceMode: "", + installtimeFmt: '', + show: false, + form: { + devcode: "", + wellcode: "", + welltype: "", + welldepth: "", + installheigt: "", + installperson: "", + installtimeFmt: "", + photopath: "", + factory: "", + workmsg: "", + position: "", + description: "", + longitude: "", + latitude: "", + longitude84: "", + latitude84: "", + devicetype: "", + project: "", + area: "", + street: "", + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '' + }, + fileList: [], + detail: "", + markers: [{ + id: 100, + // iconPath: "../../images/point.png", + latitude: '', + longitude: '', + // label:'1', + width: 25, + height: 35 + }], + }, - onDisplay() { - this.setData({ - show: true - }); - }, - onClose() { - this.setData({ - show: false - }); - }, - formatDate() { - var date = new Date(); - // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; - var seperator1 = "-"; - var month = date.getMonth() + 1; - var strDate = date.getDate(); - var hour = date.getHours() - var minute = date.getMinutes() - var second = date.getSeconds() - month = month > 9 ? month : "0" + month; - strDate = strDate > 9 ? strDate : "0" + strDate; - hour = hour > 9 ? hour : "0" + hour; - minute = minute > 9 ? minute : "0" + minute; - second = second > 9 ? second : "0" + second; - var currentdate = - date.getFullYear() + - seperator1 + - month + - seperator1 + - strDate + - " " + - hour + ":" + - minute + ":" + - second; - return currentdate; + onDisplay() { + this.setData({ + show: true + }); + }, + onClose() { + this.setData({ + show: false + }); + }, + formatDate() { + var date = new Date(); + // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; + var seperator1 = "-"; + var month = date.getMonth() + 1; + var strDate = date.getDate(); + var hour = date.getHours() + var minute = date.getMinutes() + var second = date.getSeconds() + month = month > 9 ? month : "0" + month; + strDate = strDate > 9 ? strDate : "0" + strDate; + hour = hour > 9 ? hour : "0" + hour; + minute = minute > 9 ? minute : "0" + minute; + second = second > 9 ? second : "0" + second; + var currentdate = + date.getFullYear() + + seperator1 + + month + + seperator1 + + strDate + + " " + + hour + ":" + + minute + ":" + + second; + return currentdate; - }, - onConfirm(event) { - var installtime = 'form.installtimeFmt'; - this.setData({ - show: false, - installtimeFmt: this.formatDate(event.detail), - [installtime]: this.formatDate(event.detail), - }); - }, + }, + onConfirm(event) { + var installtime = 'form.installtimeFmt'; + this.setData({ + show: false, + installtimeFmt: this.formatDate(event.detail), + [installtime]: this.formatDate(event.detail), + }); + }, - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - var _this = this; - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" - }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); - } - _this.setData({ - personoption1: personArr - }) + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + var _this = this; + _this.setData({ + 'markers[0].latitude': Number(wx.getStorageSync('resultObject').latitude) , + 'markers[0].longitude': Number(wx.getStorageSync('resultObject').longitude), + // 'markers[0].label':'10', + 'markers[0].width': 18, + 'markers[0].id':1, + 'markers[0].height': 30, + latitude:Number(wx.getStorageSync('resultObject').latitude), + longitude:Number(wx.getStorageSync('resultObject').longitude) + }) + //获取人员下拉列表 + // wx.request({ + // method: "POST", + // url: app.globalData.httpsUrl + "deviceType/getUser", + // data:{ + // tips:'repair' + // }, + // header: { + // 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + // }, + // success(res) { + // if (res.data.code == 200) { + // var users = res.data.data + // var personArr = []; + // for (var i = 0; i < users.length; i++) { + // var person = { + // text: users[i].name, + // value: users[i].name + // }; + // personArr.push(person); + // } + // _this.setData({ + // personoption1: personArr + // }) + // } + // } + // }) + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); } - }).catch(err => { - console.error(err); - }) - - - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" - }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - _this.setData({ - projectoption: projectArr - }) - } - }).catch(err => { - console.error(err); - }) - - if (options.pageName) { - this.setData({ - pageName: options.pageName - }) - } - - if (options.detail) { - - var formObject = JSON.parse(options.detail); _this.setData({ - form: formObject, - detail: options.detail + projectoption: projectArr }) - - _this.setData({ - ['form.installperson']: "", - ['form.installtimeFmt']: "", - ['form.workmsg']: "", - ['form.description']: "" - }) - - const { - fileList = [] - } = _this.data; - if (formObject.photopath1 != "") { - var file1 = { - url: app.globalData.url + "static/" + formObject.photopath1 - } - fileList.push(file1) - } - if (formObject.photopath2 != "") { - var file2 = { - url: app.globalData.url + "static/" + formObject.photopath2 - } - fileList.push(file2) - } - if (formObject.photopath3 != "") { - var file3 = { - url: app.globalData.url + "static/" + formObject.photopath3 - } - fileList.push(file3) - } - - _this.setData({ - fileList - }); } - var installtime = 'form.installtimeFmt'; - var dateNow = this.formatDate(); - this.setData({ - installtimeFmt: dateNow, - [installtime]: dateNow, - }); - }, + } + }) - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { + //获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + _this.setData({ + option1: welltypeArr + }) + } + } +}) - }, + //跳转时带入参数返回哪页 + if (options.pageName) { + this.setData({ + pageName: options.pageName + }) + } + //跳转时带入参数设备的安装信息 + if (wx.getStorageSync('resultObject')) { + var formObject = wx.getStorageSync('resultObject') + _this.setData({ + form: formObject, + detail: formObject + }) - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { + _this.setData({ + ['form.installperson']: app.globalData.userName, + ['form.installtimeFmt']: "", + ['form.workmsg']: "", + ['form.description']: "" + }) - }, + const { + fileList = [] + } = _this.data; + if (formObject.photopath1 != "") { + var file1 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath1 + } + fileList.push(file1) + } + if (formObject.photopath2 != "") { + var file2 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath2 + } + fileList.push(file2) + } + if (formObject.photopath3 != "") { + var file3 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath3 + } + fileList.push(file3) + } + _this.setData({ + fileList + }); + } + var installtime = 'form.installtimeFmt'; + var dateNow = this.formatDate(); + this.setData({ + installtimeFmt: dateNow, + [installtime]: dateNow, + }); + }, - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, - }, + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + wx.removeStorageSync('resultObject') + }, - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, - }, + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { + }, - }, + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { + }, - }, + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { + }, - }, + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + }, - /** - * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true - **/ + /** + * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true + **/ - isNumber: function (val) { + isNumber: function (val) { - var regPos = /^[0-9]*$/; //非负浮点数 - var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数 - if (regPos.test(val) || regNeg.test(val)) { - return false; - } else { - return true; - } + var regPos = /^[0-9]*$/; //非负浮点数 + var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数 + if (regPos.test(val) || regNeg.test(val)) { + return false; + } else { + return true; + } - }, + }, - formValidate() { + formValidate() { - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } - if (this.data.form.wellcode == "") { - wx.showToast({ - icon: 'none', - title: '井编号不能为空!', - }) - return false - } - if (this.data.form.devicetype == "") { - wx.showToast({ - icon: 'none', - title: '设备类型不能为空!', - }) - return false - } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + if (this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '设备编号不能为空!', + }) + return false + } + if (this.data.form.wellcode == "") { + wx.showToast({ + icon: 'none', + title: '井编号不能为空!', + }) + return false + } + if (this.data.form.devicetype == "") { + wx.showToast({ + icon: 'none', + title: '设备类型不能为空!', + }) + return false + } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null || - this.data.form.installperson == '') { - wx.showToast({ - icon: 'none', - title: '运维人员不能为空!', - }) - return false - } - if (this.data.form.project == "") { - wx.showToast({ - icon: 'none', - title: '所属项目不能为空!', - }) - return false - } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } + if (this.data.form.installperson == null || + this.data.form.installperson == '') { + wx.showToast({ + icon: 'none', + title: '运维人员不能为空!', + }) + return false + } + if (this.data.form.project == "") { + wx.showToast({ + icon: 'none', + title: '所属项目不能为空!', + }) + return false + } - if (this.data.form.welldepth != null) { - if (this.isNumber(this.data.form.welldepth)) { - wx.showToast({ - icon: 'none', - title: '井深必须为数值!', - }) - return false - } - } - if (this.data.form.installheigt != null) { - if (this.isNumber(this.data.form.installheigt)) { - wx.showToast({ - icon: 'none', - title: '到井口距离必须为数值!', - }) - return false - } - } - - return true; - }, - - changeMsg: function () { - var formNew = this.data.form; - var formOld = JSON.parse(this.data.detail); - var descpNew = ""; - if (formNew.devcode != formOld.devcode) { - descpNew += "修改设备编号,原编号:" + formOld.devcode + ",新编号:" + formNew.devcode + ";" - } - if (formNew.devicetype != formOld.devicetype) { - descpNew += "修改设备类型,原设备类型:" + formOld.devicetype + ",新设备类型:" + formNew.devicetype + ";" - } - if (formNew.area != formOld.area) { - descpNew += "修改区,原区:" + formOld.area + ",新区:" + formNew.area + ";" - } - if (formNew.street != formOld.street) { - descpNew += "修改街道,原街道:" + formOld.street + ",新街道:" + formNew.street + ";" - } - if (formNew.wellname != formOld.wellname) { - descpNew += "修改井名称,原井名称:" + formOld.wellname + ",新井名称:" + formNew.wellname + ";" - } - if (formNew.factory != formOld.factory) { - descpNew += "修改权属单位,原权属单位:" + formOld.factory + ",新权属单位:" + formNew.factory + ";" - } - if (formNew.installheigt != formOld.installheigt) { - descpNew += "修改井口距离,原井口距离:" + formOld.installheigt + ",新井口距离:" + formNew.installheigt + ";" - } - if (formNew.installperson != formOld.installperson) { - descpNew += "修改运维人员,原运维人员:" + formOld.installperson + ",新运维人员:" + formNew.installperson + ";" - } - if (formNew.latitude != formOld.latitude) { - descpNew += "修改纬度,原纬度:" + formOld.latitude + ",新纬度:" + formNew.latitude + ";" - } - if (formNew.longitude != formOld.longitude) { - descpNew += "修改经度,原经度:" + formOld.longitude + ",新经度:" + formNew.longitude + ";" - } - if (formNew.position != formOld.position) { - descpNew += "修改位置描述,原位置:" + formOld.position + ",新位置:" + formNew.position + ";" - } - if (formNew.wellcode != formOld.wellcode) { - descpNew += "修改井编号,原编号:" + formOld.wellcode + ",新编号:" + formNew.wellcode + ";" - } - if (formNew.welldepth != formOld.welldepth) { - descpNew += "修改井深,原井深:" + formOld.welldepth + ",新井深:" + formNew.welldepth + ";" - } - if (formNew.welltype != formOld.welltype) { - descpNew += "修改井类型,原井类型:" + formOld.welltype + ",新井类型:" + formNew.welltype + ";" - } - if (formNew.project != formOld.project) { - descpNew += "修改所属项目,原项目:" + formOld.project + ",新项目:" + formNew.project + ";" - } - if (this.data.photopath1 != formOld.photopath1 || - this.data.photopath2 != formOld.photopath2 || - this.data.photopath3 != formOld.photopath3) { - descpNew += "修改照片;" - } - if ("" != formNew.description) { - descpNew += formNew.description; - } - this.setData({ - ['form.description']: descpNew + if (this.data.form.welldepth != null) { + if (this.isNumber(this.data.form.welldepth)) { + wx.showToast({ + icon: 'none', + title: '井深必须为数值!', }) - }, + return false + } + } + if (this.data.form.installheigt != null) { + if (this.isNumber(this.data.form.installheigt)) { + wx.showToast({ + icon: 'none', + title: '到井口距离必须为数值!', + }) + return false + } + } - formSubmit: function (event) { + return true; + }, - if (!this.formValidate()) { - return false; - } - this.changeMsg(); - var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDeviceLog', - data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceLog/add" - }, - }).then(res => { - // var resultObj=JSON.parse(res.result); - if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - if (res.confirm) { - wx.switchTab({ - url: that.data.pageName - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) - } - }).catch(err => { - console.error(err) - wx.showToast({ - title: "提交失败", - }) - }) - }, - confirm(event) { - var that = this; - var formValue = event.detail.value; - var formName = event.target.dataset.id; - var fromN = 'form.' + [formName]; - that.setData({ - [fromN]: formValue - }) - }, + //获取与上次修改的信息 + changeMsg: function () { + var formNew = this.data.form; + console.log(this.data.detail) + var formOld = JSON.parse(this.data.detail); + var descpNew = ""; + if (formNew.devcode != formOld.devcode) { + descpNew += "修改设备编号,原值:" + formOld.devcode + ",新值:" + formNew.devcode + ";" + } + if (formNew.devicetype != formOld.devicetype) { + descpNew += "修改设备类型,原值:" + formOld.devicetype + ",新值:" + formNew.devicetype + ";" + } + if (formNew.area != formOld.area) { + descpNew += "修改区,原值:" + formOld.area + ",新值:" + formNew.area + ";" + } + if (formNew.street != formOld.street) { + descpNew += "修改街道,原值:" + formOld.street + ",新值:" + formNew.street + ";" + } + if (formNew.wellname != formOld.wellname) { + descpNew += "修改井名称,原值:" + formOld.wellname + ",新值:" + formNew.wellname + ";" + } + if (formNew.factory != formOld.factory) { + descpNew += "修改权属单位,原值:" + formOld.factory + ",新值:" + formNew.factory + ";" + } + if (formNew.installheigt != formOld.installheigt) { + descpNew += "修改井口距离,原值:" + formOld.installheigt + ",新值:" + formNew.installheigt + ";" + } + if (formNew.installperson != formOld.installperson) { + descpNew += "修改运维人员,原值:" + formOld.installperson + ",新值:" + formNew.installperson + ";" + } + if (formNew.latitude != formOld.latitude) { + descpNew += "修改纬度,原值:" + formOld.latitude + ",新值:" + formNew.latitude + ";" + } + if (formNew.longitude != formOld.longitude) { + descpNew += "修改经度,原值:" + formOld.longitude + ",新值:" + formNew.longitude + ";" + } + if (formNew.position != formOld.position) { + descpNew += "修改位置描述,原值:" + formOld.position + ",新值:" + formNew.position + ";" + } + if (formNew.wellcode != formOld.wellcode) { + descpNew += "修改井编号,原值:" + formOld.wellcode + ",新值:" + formNew.wellcode + ";" + } + if (formNew.welldepth != formOld.welldepth) { + descpNew += "修改井深,原值:" + formOld.welldepth + ",新值:" + formNew.welldepth + ";" + } + if (formNew.welltype != formOld.welltype) { + descpNew += "修改井类型,原值:" + formOld.welltype + ",新值:" + formNew.welltype + ";" + } + if (formNew.project != formOld.project) { + descpNew += "修改所属项目,原值:" + formOld.project + ",新值:" + formNew.project + ";" + } + if (this.data.form.photopath1 != formOld.photopath1 || + this.data.form.photopath2 != formOld.photopath2 || + this.data.form.photopath3 != formOld.photopath3) { + descpNew += "修改照片;" + } + if ("" != formNew.description) { + descpNew += formNew.description; + } + this.setData({ + ['form.description']: descpNew + }) + }, - scan() { + //提交表单 + formSubmit: function (event) { - wx.scanCode({ - success(res) { - console.log(res) - } - }) + //表单验证 + if (!this.formValidate()) { + return false; + } + //自动生成修改内容 + this.changeMsg(); + //提交权限限制(只有施工人员能修改) + if(app.globalData.role!='repair'){ + wx.showToast({ + icon: 'none', + title: '无权限修改', + duration:2000 + }) + return false + } + var that = this; + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopath = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopath]: fileList[i].url.split("static/")[1] + }) + } + delete that.data.form.installtime + delete that.data.form.createtime + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - paste() { - var _this = this; - wx.getClipboardData({ - success: function (res) { - var longitude = 'form.longitude'; - var latitude = 'form.latitude'; - var longitude84 = 'form.longitude84'; - var latitude84 = 'form.latitude84'; - _this.setData({ - [longitude]: parseFloat(res.data.split(",", 4)[1]).toFixed(6), - [latitude]: parseFloat(res.data.split(",", 4)[0]).toFixed(6), - [longitude84]: "" == (res.data.split(",", 4)[3]) ? "" : parseFloat(res.data.split(",", 4)[3]).toFixed(6), - [latitude84]: "" == (res.data.split(",", 4)[2]) ? "" : parseFloat(res.data.split(",", 4)[2]).toFixed(6), - longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), - latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), - }); - } - }) - }, - selectValue(value) { - var that = this; - var wellType = 'form.welltype'; - that.setData({ - [wellType]: value.detail - }) - }, - selectpersonValue(event) { - var that = this; - var installPerson = 'form.installperson'; - that.setData({ - [installPerson]: event.detail - }) - }, - selectprojectValue(event) { - var that = this; - var project = 'form.project'; - that.setData({ - [project]: event.detail, - showMask: true - }) - }, - open() { - this.setData({ - showMask: true - }) - }, - close() { - this.setData({ - showMask: false - }) - }, - afterRead(event) { - var _this = this; - const { - file - } = event.detail; - const { - fileList = [] - } = _this.data; - var convertpath = ""; - wx.compressImage({ - src: event.detail.file.path, - quality: 25, - success: function (res) { - convertpath = res.tempFilePath; - wx.uploadFile({ - url: app.globalData.httpsUrl + "appDeviceAdd/fileUploadMarker", - filePath:convertpath, - name: 'file', - formData: { - 'text': "编号:" + _this.data.form.devcode + "经度:" + _this.data.form.longitude + "纬度:" + _this.data.form.latitude - }, - header: { - "Content-Type": "multipart/form-data", - 'accept': 'application/json', - }, - success(res) { - if (res.data) { - var url = JSON.parse(res.data); - fileList.push({ - ...file, - url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - }); - _this.setData({ - fileList - }); - } - } + success(res) { + if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + if (res.confirm) { + wx.switchTab({ + url: that.data.pageName }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') } - }) - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // // var base64 = "data:image/png;base64," + wx.getFileSystemManager().readFileSync(convertpath, 'base64'); - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: convertpath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // // wx.cloud.callFunction({ - // // name: 'uploadFile', - // // data: { - // // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // // fileBase64: base64 - // // }, - // // success: function (res) { - // // if (res.result) { - // // fileList.push({ - // // ...file, - // // url: app.globalData.url + "static/" + res.result.data.replace(/\\/g, "/") - // // }); - // // _this.setData({ - // // fileList - // // }); - // // } - // // }, - // // complete: res => { - // // }, - // // }) - // } - // }); + } + }) + } + }, + fail(err) { + wx.showToast({ + title: "提交失败", + }) + } + }) + }, + //报存录入的input信息 + confirm(event) { + var that = this; + var formValue = event.detail.value; + var formName = event.target.dataset.id; + var fromN = 'form.' + [formName]; + that.setData({ + [fromN]: formValue + }) + }, + + //扫码 + scan() { + + wx.scanCode({ + success(res) { + console.log(res) + } + }) + }, + //粘贴经纬度 + paste() { + var _this = this; + wx.getClipboardData({ + success: function (res) { + var longitude = 'form.longitude'; + var latitude = 'form.latitude'; + var longitude84 = 'form.longitude84'; + var latitude84 = 'form.latitude84'; + _this.setData({ + [longitude]: parseFloat(res.data.split(",", 4)[1]).toFixed(6), + [latitude]: parseFloat(res.data.split(",", 4)[0]).toFixed(6), + [longitude84]: "" == (res.data.split(",", 4)[3]) ? "" : parseFloat(res.data.split(",", 4)[3]).toFixed(6), + [latitude84]: "" == (res.data.split(",", 4)[2]) ? "" : parseFloat(res.data.split(",", 4)[2]).toFixed(6), + longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), + latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), + }); + } + }) + }, + selectValue(value) { + var that = this; + var wellType = 'form.welltype'; + that.setData({ + [wellType]: value.detail + }) + }, + //运维人员默认为登录人 + // selectpersonValue(event) { + // var that = this; + // var installPerson = 'form.installperson'; + // that.setData({ + // [installPerson]: event.detail + // }) + // }, + selectprojectValue(event) { + var that = this; + var project = 'form.project'; + that.setData({ + [project]: event.detail, + showMask: true + }) + }, + + open() { + this.setData({ + showMask: true + }) + }, + //隐藏textarea,防止遮挡 + close() { + this.setData({ + showMask: false + }) + }, + //上传照片 + afterRead(event) { + var _this = this; + const { + file + } = event.detail; + const { + fileList = [] + } = _this.data; + var convertpath = ""; + wx.compressImage({ + src: event.detail.file.path, + quality: 25, + success: function (res) { + convertpath = res.tempFilePath; + wx.uploadFile({ + url: app.globalData.httpsUrl + "appDeviceAdd/fileUploadMarker", + filePath: convertpath, + name: 'file', + formData: { + 'text': "编号:" + _this.data.form.devcode + "经度:" + _this.data.form.longitude + "纬度:" + _this.data.form.latitude }, - deletePhoto(event) { - var that = this - var image_index = event.detail.index - var fileList_new = that.data.fileList; - wx.showModal({ - content: '确定删除照片?', - success: function (res) { - if (res.confirm) { - fileList_new.splice(image_index, 1); - that.setData({ - fileList: fileList_new - }) - wx.cloud.callFunction({ - name: 'deletePhoto', - data: { - url: app.globalData.url + "appDeviceLog/deletePhoto", - devcode: that.data.form.devcode, - pathIndex: image_index - }, - success: function (res) {}, - complete: res => {}, - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + "Content-Type": "multipart/form-data", + 'accept': 'application/json', }, - }) \ No newline at end of file + success(res) { + if (res.data) { + var url = JSON.parse(res.data); + fileList.push({ + ...file, + url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") + }); + _this.setData({ + fileList + }); + } + } + }) + } + }) + }, + //删除照片 + deletePhoto(event) { + var that = this + var image_index = event.detail.index + var fileList_new = that.data.fileList; + wx.showModal({ + content: '确定删除照片?', + success: function (res) { + if (res.confirm) { + fileList_new.splice(image_index, 1); + that.setData({ + fileList: fileList_new + }) + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deletePhoto", + data: { + devcode: that.data.form.devcode + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) {} + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } +}) \ No newline at end of file diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.wxml b/miniprogram/pages/addDevicelog/addDeviceLog.wxml index 38620d4..b10cc7d 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.wxml +++ b/miniprogram/pages/addDevicelog/addDeviceLog.wxml @@ -1,15 +1,21 @@ - + + + + + - + - - + + - - + + - + @@ -39,24 +45,25 @@ - - - + + + - + - + + @@ -64,7 +71,7 @@ - + @@ -79,9 +86,9 @@ - + - 保存 + 保存 diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.wxss b/miniprogram/pages/addDevicelog/addDeviceLog.wxss index ee0b75c..08d5fd7 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.wxss +++ b/miniprogram/pages/addDevicelog/addDeviceLog.wxss @@ -24,6 +24,17 @@ display: flex; align-items: center; } +.map-view{ + width: 750rpx; + height: 485rpx; + position: fixed; + top: 0px; + left: 0px; + z-index: 999; +} +.content{ + margin-top: 495rpx; +} .left { width: 210rpx; diff --git a/miniprogram/pages/addFunction/addFunction.js b/miniprogram/pages/addFunction/addFunction.js deleted file mode 100644 index 4966be3..0000000 --- a/miniprogram/pages/addFunction/addFunction.js +++ /dev/null @@ -1,60 +0,0 @@ -// pages/addFunction/addFunction.js - -const code = `// 云函数入口函数 -exports.main = (event, context) => { - console.log(event) - console.log(context) - return { - sum: event.a + event.b - } -}` - -Page({ - - data: { - result: '', - canIUseClipboard: wx.canIUse('setClipboardData'), - }, - - onLoad: function (options) { - - }, - - copyCode: function() { - wx.setClipboardData({ - data: code, - success: function () { - wx.showToast({ - title: '复制成功', - }) - } - }) - }, - - testFunction() { - wx.cloud.callFunction({ - name: 'sum', - data: { - a: 1, - b: 2 - }, - success: res => { - wx.showToast({ - title: '调用成功', - }) - this.setData({ - result: JSON.stringify(res.result) - }) - }, - fail: err => { - wx.showToast({ - icon: 'none', - title: '调用失败', - }) - console.error('[云函数] [sum] 调用失败:', err) - } - }) - }, - -}) - diff --git a/miniprogram/pages/addFunction/addFunction.json b/miniprogram/pages/addFunction/addFunction.json deleted file mode 100644 index a9a50c5..0000000 --- a/miniprogram/pages/addFunction/addFunction.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "navigationBarTitleText": "云函数指引", - "usingComponents": {} -} \ No newline at end of file diff --git a/miniprogram/pages/addFunction/addFunction.wxml b/miniprogram/pages/addFunction/addFunction.wxml deleted file mode 100644 index 3a10626..0000000 --- a/miniprogram/pages/addFunction/addFunction.wxml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - 测试云函数 - - - 期望输出:{"sum":3} - - - 调用结果:{{result}} - - - - - 新增云函数 - 1. 在云函数根目录 cloudfunctions 上右键选择新建云函数,命名为 sum - 2. 在创建的 cloudfunctions/sum/index.js 文件中添加如下代码 - - - 3. 在 cloudfunctions/sum 目录上右键上传并部署 - 4. 点击测试云函数测试 - 5. 打开云开发云函数管理页,选择 sum 云函数 - 6. 查看 sum 的调用日志 - 进阶:可在云函数中使用 wx-server-sdk 操作数据库,文件存储和调用其他云函数,详见文档 - - - diff --git a/miniprogram/pages/addFunction/addFunction.wxss b/miniprogram/pages/addFunction/addFunction.wxss deleted file mode 100644 index 7ac8619..0000000 --- a/miniprogram/pages/addFunction/addFunction.wxss +++ /dev/null @@ -1,3 +0,0 @@ -/* pages/addFunction/addFunction.wxss */ - -@import "../../style/guide.wxss"; \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.js b/miniprogram/pages/applog/applog.js index 0e8c185..189e61f 100644 --- a/miniprogram/pages/applog/applog.js +++ b/miniprogram/pages/applog/applog.js @@ -13,98 +13,25 @@ isSeach: "false", params: {}, total: 0, - show: false + show: false, + delBtnWidth: 100, //删除按钮宽度单位(rpx) + activeIndex: -1, + list_style: '' }, - - touchE: function (e) { - // console.log(e); - var that = this - if (e.changedTouches.length == 1) { - //手指移动结束后触摸点位置的X坐标 - var endX = e.changedTouches[0].clientX; - //触摸开始与结束,手指移动的距离 - var disX = that.data.startX - endX; - var delBtnWidth = that.data.delBtnWidth; - //如果距离小于删除按钮的1/2,不显示删除按钮 - var txtStyle = disX > delBtnWidth / 2 ? "left:-" + delBtnWidth + "rpx" : "left:0rpx"; - - //获取手指触摸的是哪一项 - var index = e.currentTarget.dataset.index; - var list = that.data.deviceloglist; - list[index].txtStyle = txtStyle; - //更新列表的状态 - that.setData({ - deviceloglist: list - }); - } - }, - //手指触摸动作开始 记录起点X坐标 - touchstart: function (e) { - //开始触摸时 重置所有删除 - this.data.deviceloglist.forEach(function (v, i) { - if (v.isTouchMove) //只操作为true的 - v.isTouchMove = false; - }) - this.setData({ - startX: e.changedTouches[0].clientX, - startY: e.changedTouches[0].clientY, - deviceloglist: this.data.deviceloglist - }) - }, - //滑动事件处理 - touchmove: function (e) { - var that = this, - index = e.currentTarget.dataset.index, //当前索引 - startX = that.data.startX, //开始X坐标 - startY = that.data.startY, //开始Y坐标 - touchMoveX = e.changedTouches[0].clientX, //滑动变化坐标 - touchMoveY = e.changedTouches[0].clientY, //滑动变化坐标 - //获取滑动角度 - angle = that.angle({ - X: startX, - Y: startY - }, { - X: touchMoveX, - Y: touchMoveY - }); - that.data.deviceloglist.forEach(function (v, i) { - v.isTouchMove = false - //滑动超过30度角 return - if (Math.abs(angle) > 30) return; - if (i == index) { - if (touchMoveX > startX) //右滑 - v.isTouchMove = false - else //左滑 - v.isTouchMove = true - } - }) - //更新数据 - that.setData({ - deviceloglist: that.data.deviceloglist - }) - }, - /** - * 计算滑动角度 - * @param {Object} start 起点坐标 - * @param {Object} end 终点坐标 - */ - angle: function (start, end) { - var _X = end.X - start.X, - _Y = end.Y - start.Y - //返回角度 /Math.atan()返回数字的反正切值 - return 360 * Math.atan(_Y / _X) / (2 * Math.PI); - }, - /** - * 生命周期函数--监听页面加载var_this=this; - */ onLoad: function (options) { - if (options.params) { this.setData({ params: JSON.parse(options.params), isSeach: "true" }) this.initPages() + }else{ + this.setData({ + show: false + }) + //清空参数,重新加载 + this.clearParams(); + this.initPages(); } }, @@ -116,20 +43,33 @@ }, + //点击tabBar事件 + onTabItemTap(item) { + //隐藏历史显示总记录条数 + this.setData({ + show: false + }) + //清空参数,重新加载 + this.clearParams(); + this.initPages(); + }, + + /** * 生命周期函数--监听页面显示 */ onShow: function (options) { - this.setData({ - show:false - }) - if (this.data.isSeach == "false") { - this.clearParams(); - this.initPages(); - } - this.setData({ - isSeach: "false" - }) + + // this.setData({ + // show: false + // }) + // if (this.data.isSeach == "false") { + // this.clearParams(); + // this.initPages(); + // } + // this.setData({ + // isSeach: "false" + // }) }, /** @@ -167,6 +107,119 @@ }, + + //手指触摸动作开始 记录起点X坐标 + touchstart: function (e) { + //开始触摸时 重置所有删除 + this.data.deviceloglist.forEach(function (v, i) { + if (v.isTouchMove) //只操作为true的 + v.isTouchMove = false; + }) + this.setData({ + startX: e.changedTouches[0].clientX, + startY: e.changedTouches[0].clientY, + deviceloglist: this.data.deviceloglist + }) + }, + + //滑动事件处理 + touchmove: function (e) { + var that = this, + index = e.currentTarget.dataset.index, //当前索引 + startX = that.data.startX, //开始X坐标 + startY = that.data.startY, //开始Y坐标 + touchMoveX = e.changedTouches[0].clientX, //滑动变化坐标 + touchMoveY = e.changedTouches[0].clientY, //滑动变化坐标 + //获取滑动角度 + angle = that.angle({ + X: startX, + Y: startY + }, { + X: touchMoveX, + Y: touchMoveY + }); + that.data.deviceloglist.forEach(function (v, i) { + // v.isTouchMove = false + //滑动超过30度角 return + if (Math.abs(angle) > 30) return; + if (i == index) { + if (touchMoveX > startX) //右滑 + v.isTouchMove = false + else //左滑 + v.isTouchMove = true + } + }) + //更新数据 + that.setData({ + deviceloglist: that.data.deviceloglist + }) + }, + + /** + * 计算滑动角度 + * @param {Object} start 起点坐标 + * @param {Object} end 终点坐标 + */ + angle: function (start, end) { + var _X = end.X - start.X, + _Y = end.Y - start.Y + //返回角度 /Math.atan()返回数字的反正切值 + return 360 * Math.atan(_Y / _X) / (2 * Math.PI); + }, + + //删除事件 + delItem: function (e) { + if(app.globalData.role!='repair'){ + wx.showToast({ + icon: 'none', + title: '无权限删除', + duration:2000 + }) + return false + } + var that = this + wx.showModal({ + content: '是否删除?', + success: function (res) { + if (res.confirm) { + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/delete", + data: { + appDeviceAddId: e.currentTarget.dataset.devid + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if(res.data.code=='200'){ + that.data.deviceloglist.splice(e.currentTarget.dataset.index, 1) + that.setData({ + deviceloglist: that.data.deviceloglist, + total: that.data.deviceloglist.length + }) + wx.showToast({ + title: '删除成功!', + icon: 'none', + duration: 1000 + }) + } + }, + fail(err) { + wx.showToast({ + title: '删除失败!', + icon: 'none', + duration: 2000 + }) + } + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + }, + showLoading: function (message) { if (wx.showLoading) { // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 @@ -199,95 +252,105 @@ deviceloglist: [] }) }, + //查询列表数据 initPages: function () { var that = this + that.setData({ + show: false + }) var offsetValue = that.data.deviceloglist.length % 15 > 0 ? parseInt(that.data.deviceloglist.length / 15) + 2 : parseInt(that.data.deviceloglist.length / 15) + 1 - wx.cloud.callFunction({ - name: 'devicelog', + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/listPage", data: { devcode: that.data.params.devcode, devtype: that.data.params.devtype, installtimeFmt: that.data.params.installtimeFmt, project: that.data.params.project, installPerson: that.data.params.installPerson, - url: app.globalData.url + "appDeviceLog/listPage", limit: 15, offset: offsetValue }, - }).then(res => { - if (res.result.data.rows.length > 0) { - var resultJson = res.result - that.setData({ - deviceloglist: that.data.deviceloglist.concat(resultJson.data.rows) - }) - } else if (that.data.deviceloglist.length > 0) { - that.setData({ - show: true, - total: that.data.deviceloglist.length - }) - wx.showToast({ - title: '数据已全部加载完', - icon: 'none', - duration: 2000 - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.data.rows.length > 0) { + var resultJson = res.data + var listArr = resultJson.data.rows + listArr.forEach(function (v, i) { + listArr[i]['isTouchMove'] = false + }) + that.setData({ + deviceloglist: that.data.deviceloglist.concat(listArr) + }) + } else if (that.data.deviceloglist.length > 0) { + that.setData({ + show: true, + total: that.data.deviceloglist.length + }) + wx.showToast({ + title: '数据已全部加载完', + icon: 'none', + duration: 2000 + }) + } + if (offsetValue == 1 && res.data.data.rows.length < 15) { + that.setData({ + show: true, + total: that.data.deviceloglist.length + }) + } } - if(offsetValue==1&&res.result.data.rows.length<15){ - that.setData({ - show: true, - total: that.data.deviceloglist.length - }) - } - // console.log(res); - }).catch(err => { - console.error(err); }) + }, addDetail: function (event) { - this.showLoading("数据请求中..."); - wx.cloud.callFunction({ - name: 'deviceDetail', + var that = this + that.showLoading("数据请求中..."); + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deviceDetail", data: { devcode: event.target.dataset.devcode, - url: app.globalData.url + "appDeviceLog/deviceDetail", }, - }).then(res => { - this.hideLoading(); - var resultObject = JSON.parse(res.result); - var pageName = '../applog/applog' - if (resultObject.code == 200) { - wx.navigateTo({ - url: '../addDevicelog/addDeviceLog?detail=' + - JSON.stringify(resultObject.data) + "&pageName=" + pageName - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + that.hideLoading(); + // var resultObject = JSON.parse(res.data); + var resultObject = res.data; + var pageName = '../applog/applog' + if (resultObject.code == 200) { + wx.setStorageSync('resultObject', resultObject.data) + wx.navigateTo({ + url: '../addDevicelog/addDeviceLog?detail=' + "&pageName=" + pageName + }) + } + }, + fail(err) { + that.hideLoading(); } - }).catch(err => { - this.hideLoading() }) + }, add: function (event) { - wx.reLaunch({ - url: '../earth/earth?devcode=' + event.target.dataset.devcode - // url: '../earth/earth' + app.globalData.devcode = event.target.dataset.devcode; + wx.switchTab({ + url: '../earth/earth' }) + // wx.reLaunch({ + // url: '../earth/earth?devcode=' + event.target.dataset.devcode + // // url: '../earth/earth' + // }) }, onSearch: function () { + var _this = this wx.navigateTo({ - url: '../searchLog/searchLog' + url: '../searchLog/searchLog?params=' + JSON.stringify(_this.data.params) }) - }, - // initPages: function () { - // wx.cloud.callFunction({ - // name: 'devicelog' - // }).then(res => { - // var that = this; - // var jsonList = JSON.parse(res.result) - // that.setData({ - // deviceloglist: jsonList.data.rows - // }) - // console.log(res); - // }).catch(err => { - // console.error(err); - // }) - // } + } }) \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.wxml b/miniprogram/pages/applog/applog.wxml index e9a2352..2bfd041 100644 --- a/miniprogram/pages/applog/applog.wxml +++ b/miniprogram/pages/applog/applog.wxml @@ -1,54 +1,59 @@ - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {{item.devcode}} {{item.devicetype}} + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + {{item.devcode}} {{item.devicetype}} + + {{item.project}} {{item.installtime}}- {{item.installperson}} - - - - - + + + + + + 删除 - - - + + - 共计:{{total}}台 - + 共计:{{total}}台 + \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.wxss b/miniprogram/pages/applog/applog.wxss index 6d3428b..e6e8983 100644 --- a/miniprogram/pages/applog/applog.wxss +++ b/miniprogram/pages/applog/applog.wxss @@ -22,16 +22,18 @@ position: fixed; width: 100%; top: 0rpx; + z-index: 9999; /* margin-bottom: 100rpx; */ } .log-list { /* height: 100rpx; */ - /* display: flex; */ - + display: flex; + width: 100%; padding: 2px; margin-top: 2px; border-bottom: 1px solid #e5e5e5; + overflow: hidden } @@ -53,23 +55,29 @@ left: 35%; margin: 20rpx } - .del { - width: 90px; + /* display: flex; */ + width: 100rpx; display: flex; flex-direction: column; align-items: center; justify-content: center; - color: #fff; - -webkit-transform: translateX(90px); - transform: translateX(90px); - -webkit-transition: all 0.4s; + /* -webkit-transform: translateX(100rpx); */ + transform: translateX(100rpx); + /* -webkit-transition: all 0.4s; */ transition: all 0.4s; - font-size: 35rpx; + color: #fff; + background-color: #fe3e2f; +} +.logrow{ + width: 100%; + transform: translateX(100rpx); + /* -webkit-transform: translateX(100px); */ + margin-left: -100rpx; } -.touch-move-active .content, +.touch-move-active .logrow, .touch-move-active .del { - -webkit-transform: translateX(0); - transform: translateX(0); +/* -webkit-transform: translateX(0); */ +transform: translateX(0); } \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.js b/miniprogram/pages/deployFunctions/deployFunctions.js deleted file mode 100644 index a76b144..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.js +++ /dev/null @@ -1,66 +0,0 @@ -// pages/deployFunctions/deployFunctions.js -Page({ - - /** - * 页面的初始数据 - */ - data: { - - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - - }, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { - - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - - }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { - - }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { - - } -}) \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.json b/miniprogram/pages/deployFunctions/deployFunctions.json deleted file mode 100644 index 7fbedab..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "navigationBarTitleText": "部署云函数", - "usingComponents": {} -} \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.wxml b/miniprogram/pages/deployFunctions/deployFunctions.wxml deleted file mode 100644 index 462b6b6..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.wxml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - 调用失败 - - - 请检查 login 云函数是否已部署 - - - - - 部署 login 云函数 - 1. 确保已通过工具栏云开发入口开通云开发 - 2. 在 cloudfunctions/login 目录上右键上传并部署 - 3. 回到首页,重新点击获取 openid - - - - diff --git a/miniprogram/pages/deployFunctions/deployFunctions.wxss b/miniprogram/pages/deployFunctions/deployFunctions.wxss deleted file mode 100644 index c8803e6..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.wxss +++ /dev/null @@ -1,7 +0,0 @@ -/* pages/deployFunctions/deployFunctions.wxss */ - -@import "../../style/guide.wxss"; - -.black { - color: black; -} \ No newline at end of file diff --git a/miniprogram/pages/earth/earth.js b/miniprogram/pages/earth/earth.js index ae0d3f3..376a6e2 100644 --- a/miniprogram/pages/earth/earth.js +++ b/miniprogram/pages/earth/earth.js @@ -21,19 +21,12 @@ show: false, enableSsatellite: false, windowWidth: 0, - longitude: 113.324520, - latitude: 23.099994, - longitude84: 113.324520, - latitude84: 23.099994, - markers: [{ - id: 0, - iconPath: "../../images/locat.png", - latitude: 23.099994, - longitude: 113.324520, - width: 50, - height: 50 - }], - controls: [], + longitude: "116.627340", + latitude: "39.874390", + longitude84: "", + latitude84: "", + markers: [], + controls: [] }, /** @@ -41,39 +34,13 @@ */ onLoad: function (options) { var that = this; - //获取当前坐标(gcj02) - wx.getLocation({ - type: "gcj02", - altitude: true, - success: function (res) { - that.setData({ - latitude: parseFloat(res.latitude).toFixed(6), - longitude: parseFloat(res.longitude).toFixed(6), - // markers: [{ - // latitude: res.latitude, - // longitude: res.longitude, - // }] - }) - //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 - wx.getLocation({ - type: "wgs84", - altitude: true, - success: function (res) { - that.setData({ - latitude84: parseFloat(res.latitude).toFixed(6), - longitude84: parseFloat(res.longitude).toFixed(6) - }) - } - }) - } - }), - - //设置地图组件 - wx.getSystemInfo({ + //设置地图组件 + wx.getSystemInfo({ success(res) { var windowWidth = res.windowWidth var windowHeight = res.windowHeight var query = wx.createSelectorQuery() + var platform =res.platform query.select('#map').boundingClientRect() query.exec(function (res) { that.setData({ @@ -139,10 +106,20 @@ clickable: true }, { id: 7, - iconPath: '../../images/locat.png', + iconPath: '../../images/applocat.png', position: { - left: res[0].width/2, - top: res[0].height/2, + left: res[0].width / 2 - 20, + top: platform=="ios"?res[0].height / 2 - 80:res[0].height / 2 - 40, + width: 40, + height: 40 + }, + clickable: true + }, { + id: 8, + iconPath: '../../images/back.png', + position: { + left: windowWidth - 40, + top: windowHeight - 140, width: 30, height: 30 }, @@ -150,71 +127,15 @@ }] }) }) - + } - }), + }) + // 实例化API核心类 qqmapsdk = new QQMapWX({ key: 'BGPBZ-C5O3P-ROUDR-LWC4J-63EKH-V5FRX' }) - - if (options.devcode) { - var that = this - var devcode = options.devcode - wx.cloud.callFunction({ - name: 'findListByCodes', - data: { - devcodes: devcode, - url: app.globalData.url + "appDeviceAdd/findListByCodes" - }, - }).then(res => { - if (res.result.code == 200) { - var listResultData = res.result.data; - that.setData({ - listData: listResultData - }) - var markersArr = that.data.markers; - for (var i = 0; i < listResultData.length; i++) { - markersArr = markersArr.concat({ - iconPath: "../../images/locat.png", - id: listResultData[i].id, - callout: { - content: listResultData[i].devcode, - fontSize: '14', - // padding: true, - color: '#00000', - borderColor: '#F4EA2A', - bgColor: '#F4EA2A', - borderWidth: 5, - display: 'ALWAYS', - textAlign: 'center', - // borderRadius: 15 - }, - latitude: listResultData[i].latitude, - longitude: listResultData[i].longitude, - width: 40, - height: 40 - }); - } - this.setData({ - markers: markersArr, - latitude: listResultData[0].latitude, - longitude: listResultData[0].longitude, - marker_latitude: listResultData[0].latitude, - marker_longitude: listResultData[0].longitude, - title: listResultData[0].devcode - }) - } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "无法获取设备地理信息!", - icon: 'none', - duration: 2000 - }) - }) - } }, /** @@ -228,6 +149,97 @@ * 生命周期函数--监听页面显示 */ onShow: function () { + //输入设备编号获取marker位置信息 + var that = this; + if ( app.globalData.devcode!="") { + var devcode = app.globalData.devcode + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/findListByCodes", + data: { + devcodes: devcode, + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + app.globalData.devcode=""; + if (res.data.code == 200) { + var listResultData = res.data.data; + that.setData({ + listData: listResultData + }) + var markersArr = that.data.markers; + for (var i = 0; i < listResultData.length; i++) { + markersArr = markersArr.concat({ + iconPath: "../../images/locat.png", + id: Number(listResultData[i].id), + callout: { + content: "编号:"+listResultData[i].devcode+"\r\n位置:"+listResultData[i].position+"\r\n时间:"+listResultData[i].createtime, + fontSize: '14', + padding: true, + color: '#000000', + borderColor: '#F4EA2A', + bgColor: '#F4EA2A', + borderWidth: 5, + display: 'ALWAYS', + textAlign: 'left', + // borderRadius: 15 + }, + latitude: listResultData[i].latitude, + longitude: listResultData[i].longitude, + width: 40, + height: 40 + }); + } + that.setData({ + markers: markersArr, + latitude: listResultData[0].latitude, + longitude: listResultData[0].longitude, + marker_latitude: listResultData[0].latitude, + marker_longitude: listResultData[0].longitude, + title: listResultData[0].devcode + }) + } + }, + fail(err) { + app.globalData.devcode=""; + wx.showToast({ + title: "无法获取设备地理信息!", + icon: 'none', + duration: 2000 + }) + } + }) +} else { + //获取当前坐标(gcj02) + wx.getLocation({ + type: "gcj02", + altitude: true, + success: function (res) { + that.setData({ + latitude: parseFloat(res.latitude).toFixed(6), + longitude: parseFloat(res.longitude).toFixed(6), + // markers: [{ + // latitude: res.latitude, + // longitude: res.longitude, + // }] + }) + //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 + wx.getLocation({ + type: "wgs84", + altitude: true, + success: function (res) { + that.setData({ + latitude84: parseFloat(res.latitude).toFixed(6), + longitude84: parseFloat(res.longitude).toFixed(6) + }) + } + }) + } + }) +} + }, @@ -265,12 +277,46 @@ onShareAppMessage: function () { }, + + //定位出来 + + locationPosition: function () { + var that = this; + //获取当前坐标(gcj02) + wx.getLocation({ + type: "gcj02", + altitude: true, + success: function (res) { + that.setData({ + latitude: parseFloat(res.latitude).toFixed(6), + longitude: parseFloat(res.longitude).toFixed(6), + // markers: [{ + // latitude: res.latitude, + // longitude: res.longitude + // }] + }) + //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 + wx.getLocation({ + type: "wgs84", + altitude: true, + success: function (res) { + that.setData({ + latitude84: parseFloat(res.latitude).toFixed(6), + longitude84: parseFloat(res.longitude).toFixed(6) + }) + } + }) + } + }) + }, + + //加载地图组件 controltap: function (e) { // console.log(e.controlId); //进入添加设备页 if (1 == e.controlId) { wx.setClipboardData({ - data: this.data.latitude + "," + this.data.longitude+ "," + this.data.latitude84+ "," + this.data.longitude84, + data: this.data.latitude + "," + this.data.longitude + "," + this.data.latitude84 + "," + this.data.longitude84, success: function (res) { wx.getClipboardData({ success: function (res) { @@ -282,6 +328,17 @@ } }) } else if (3 == e.controlId) { + //先定位 + // this.locationPosition() + wx.setClipboardData({ + data: this.data.latitude + "," + this.data.longitude + "," + this.data.latitude84 + "," + this.data.longitude84, + success: function (res) { + wx.showToast({ + title: '坐标已获取', + duration: 1000 + }) + } + }) wx.navigateTo({ url: '../addDevice/addDevice' }) @@ -302,32 +359,15 @@ enableSsatellite: !flag }); } else if (6 == e.controlId) { - var that = this; - //获取当前坐标(gcj02) - wx.getLocation({ - type: "gcj02", - altitude: true, - success: function (res) { - that.setData({ - latitude: parseFloat(res.latitude).toFixed(6), - longitude:parseFloat(res.longitude).toFixed(6), - // markers: [{ - // latitude: res.latitude, - // longitude: res.longitude - // }] - }) - //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 - wx.getLocation({ - type: "wgs84", - altitude: true, - success: function (res) { - that.setData({ - latitude84: parseFloat(res.latitude).toFixed(6), - longitude84: parseFloat(res.longitude).toFixed(6) - }) - } - }) - } + //先清marker + this.setData({ + markers: [] + }) + this.locationPosition() + }else if (8 == e.controlId) { + //跳转日志缓存页 + wx.switchTab({ + url: '../applog/applog', }) } }, @@ -343,63 +383,68 @@ }); }, + //获取设备maker leave() { var that = this; if (that.data.devcodes == "") { return false; } - wx.cloud.callFunction({ - name: 'findListByCodes', + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/findListByCodes", data: { - devcodes: that.data.devcodes, - url: app.globalData.url + "appDeviceAdd/findListByCodes" + devcodes: that.data.devcodes }, - }).then(res => { - if (res.result.code == 200) { - var listResultData = res.result.data; - that.setData({ - listData: listResultData - }) - var markersArr = that.data.markers; - for (var i = 0; i < listResultData.length; i++) { - markersArr = markersArr.concat({ - iconPath: "../../images/locat.png", - id: listResultData[i].id, - callout: { - content: listResultData[i].devcode, - fontSize: '14', - // padding: true, - color: '', - borderColor: '#F4EA2A', - bgColor: '#F4EA2A', - borderWidth: 5, - display: 'ALWAYS', - textAlign: 'center', - // borderRadius: 15 - }, - latitude: listResultData[i].latitude, - longitude: listResultData[i].longitude, - width: 40, - height: 40 - }); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var listResultData = res.data.data; + that.setData({ + listData: listResultData + }) + var markersArr = that.data.markers; + for (var i = 0; i < listResultData.length; i++) { + markersArr = markersArr.concat({ + iconPath: "../../images/locat.png", + id: listResultData[i].id, + callout: { + content: "编号:"+listResultData[i].devcode+"\r\n位置:"+listResultData[i].position+"\r\n时间:"+listResultData[i].createtime, + fontSize: '14', + // padding: true, + color: '#212121', + borderColor: '#F4EA2A', + bgColor: '#F4EA2A', + borderWidth: 5, + display: 'ALWAYS', + textAlign: 'left', + // borderRadius: 15 + }, + latitude: listResultData[i].latitude, + longitude: listResultData[i].longitude, + width: 40, + height: 40 + }); + } + that.setData({ + markers: markersArr, + latitude: listResultData[0].latitude, + longitude: listResultData[0].longitude, + marker_latitude: listResultData[0].latitude, + marker_longitude: listResultData[0].longitude, + title: listResultData[0].devcode + }) } - this.setData({ - markers: markersArr, - latitude: listResultData[0].latitude, - longitude: listResultData[0].longitude, - marker_latitude: listResultData[0].latitude, - marker_longitude: listResultData[0].longitude, - title: listResultData[0].devcode + }, + fail(err) { + wx.showToast({ + title: "无法获取设备地理信息!", + icon: 'none', + duration: 2000 }) } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "无法获取设备地理信息!", - icon: 'none', - duration: 2000 - }) }) }, @@ -422,6 +467,8 @@ } }, + + bindregionchange: function (e) { var that = this if (e.causedBy == "drag") { @@ -445,8 +492,8 @@ that.setData({ latitude: parseFloat(latitude).toFixed(6), longitude: parseFloat(longitude).toFixed(6), - latitude84:"", - longitude84:"", + latitude84: "", + longitude84: "", // markers: markersArr }) // mapCtx.moveToLocation(); @@ -465,16 +512,19 @@ qqmapsdk.search({ keyword: this.data.value, success: function (res) { + console.log(res) if (res && res.data) { _this.setData({ isShow: true, tips: res.data }); } + }, + complete: function (res){ + console.log(res); } }) }, - bindSearch: function (e) { var location = e.target.dataset.location; this.setData({ diff --git a/miniprogram/pages/earth/earth.wxml b/miniprogram/pages/earth/earth.wxml index a0db6ef..87474f8 100644 --- a/miniprogram/pages/earth/earth.wxml +++ b/miniprogram/pages/earth/earth.wxml @@ -1,9 +1,10 @@ + - + {{item.title}} {{item.address}} @@ -17,6 +18,6 @@ + placeholder="请输入定位设备编号用换行隔开" autosize border="{{ false }}" /> \ No newline at end of file diff --git a/miniprogram/pages/indexapp/indexapp.js b/miniprogram/pages/indexapp/indexapp.js index 5063372..849dbdb 100644 --- a/miniprogram/pages/indexapp/indexapp.js +++ b/miniprogram/pages/indexapp/indexapp.js @@ -7,9 +7,8 @@ */ data: { - count:1, - show: false, - onshow:true, + count: 1, + onshow: true, value: "", deviceloglist: [], devcode: "", @@ -21,6 +20,7 @@ // iconPath: "../../images/point.png", latitude: 23.099994, longitude: 113.324520, + label:'1', width: 50, height: 50 }], @@ -31,62 +31,26 @@ * 生命周期函数--监听页面加载 */ onLoad: function (options) { - + }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { - + }, /** * 生命周期函数--监听页面显示 */ onShow: function () { - // if( app.globalData.indexCount>1){ - // this.setData({ - // show:false - // }) - // }else{ - // this.showNotice() - // } - if(app.globalData.indexCount==1){ - this.setData({ - show:true - }) - this.showNotice() - } - app.globalData.indexCount+=1 - if(this.data.onshow){ + if (this.data.onshow) { this.initPages(); } }, - - showNotice: function() { - var that = this - var times = 0 - var i = setInterval(function() { - times++ - if (times >= 15) { - that.setData({ - show:false - }) - wx.showTabBar({ - animation: false, - }) - clearInterval(i) - } else { - wx.hideTabBar({ - animation: false, - }) - } - }, 1000) -}, - /** * 生命周期函数--监听页面隐藏 */ @@ -122,16 +86,27 @@ }, jump: function (event) { - var that = this; var latitude = event.target.dataset.pointLat; var longitude = event.target.dataset.pointLon; + let devcode = event.target.dataset.pointCode; that.setData({ latitude: latitude, longitude: longitude, markers: [{ latitude: latitude, - longitude: longitude + longitude: longitude, + callout: { + display:'ALWAYS',// 常显气泡 + content: devcode, //名称文本 + color: '#fff', //文本颜色 + borderRadius: 5, //边框圆角 + borderWidth: 1, //边框宽度 + borderColor: '#0060ff', //边框颜色 + bgColor: '#0060ff', //背景色 + padding: 5, //文本边缘留白 + textAlign: 'center' //文本对齐方式。有效值: left, right, center + } }] }) }, @@ -142,7 +117,7 @@ var devcode = res.result _this.setData({ devcode: devcode, - onshow:false + onshow: false }); _this.searchlogs(devcode) } @@ -151,40 +126,11 @@ onSearch: function (event) { this.setData({ - devcode:event.detail + devcode: event.detail }) this.searchlogs(event.detail) }, - - // bindregionchange: function (e) { - // var that = this - // if (e.causedBy == "drag") { - // var mapCtx = wx.createMapContext("map") - // mapCtx.getCenterLocation({ - // success: function (res) { - // var markersArr = that.data.markers - // for (var i = 0; i < markersArr.length; i++) { - // if (markersArr[i].iconPath == undefined) { - // markersArr.splice(i, 1) - // } - // } - // var latitude = res.latitude - // var longitude = res.longitude - // markersArr = markersArr.concat({ - // latitude: latitude, - // longitude: longitude - // }) - // that.setData({ - // latitude: latitude, - // longitude: longitude, - // markers: markersArr - // }) - // } - // }) - // } - // }, - showLoading: function (message) { if (wx.showLoading) { // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 @@ -211,81 +157,89 @@ } }, + //加载设备运维详细信息 toDetail: function (event) { - this.showLoading("数据加载中...") - wx.cloud.callFunction({ - name: 'deviceDetail', + var that = this + that.showLoading("数据加载中...") + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deviceDetail", data: { devcode: event.target.dataset.devcode, - url: app.globalData.url + "appDeviceLog/deviceDetail", }, - }).then(res => { - this.hideLoading(); - var resultObject = JSON.parse(res.result); - var pageName='../indexapp/indexapp' - if (resultObject.code == 200) { - wx.navigateTo({ - url: '../addDevicelog/addDeviceLog?detail=' + - JSON.stringify(resultObject.data)+'&pageName='+pageName - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + that.hideLoading(); + var resultObject = res.data; + var pageName = '../indexapp/indexapp' + if (resultObject.code == 200) { + wx.setStorageSync('resultObject', resultObject.data) + wx.navigateTo({ + url: '../addDevicelog/addDeviceLog?detail=' +'&pageName=' + pageName + }) + } + }, + fail(err){ + that.hideLoading(); } - }).catch(err => { - this.hideLoading(); }) }, + //加载列表 getlogs: function (devcode) { var that = this - wx.cloud.callFunction({ - name: 'devicelog', + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/listPage", data: { devcode: devcode, - url: app.globalData.url + "appDeviceLog/listPage", limit: 100, offset: that.data.deviceloglist.length % 100 > 0 ? parseInt(that.data.deviceloglist.length / 100) + 2 : parseInt(that.data.deviceloglist.length / 100) + 1 }, - }).then(res => { - if (res.result) { - // var resultJson = JSON.parse(res.result) - var resultJson = res.result - that.setData({ - deviceloglist: that.data.deviceloglist.concat(resultJson.data.rows) - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + // var resultJson = JSON.parse(res.result) + var resultJson = res.data + that.setData({ + deviceloglist: that.data.deviceloglist.concat(resultJson.data.rows) + }) + } } - console.log(res); - }).catch(err => { - console.error(err); }) }, + //查询列表 searchlogs: function (devcode) { var that = this - wx.cloud.callFunction({ - name: 'devicelog', + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/listPage", data: { devcode: devcode, - url: app.globalData.url + "appDeviceLog/listPage", limit: 100, offset: 1 }, - }).then(res => { - if (res.result) { - var resultJson = res.result - that.setData({ - deviceloglist: resultJson.data.rows, - onshow:true - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var resultJson = res.data + that.setData({ + deviceloglist: resultJson.data.rows, + onshow: true + }) + } } - console.log(res); - }).catch(err => { - console.error(err); }) }, initPages: function () { var that = this; - that.setData({ - devcode: "" - }); wx.getLocation({ type: "gcj02", success: function (res) { @@ -302,6 +256,6 @@ }) } }) - this.searchlogs() + this.data.devcode !== '' ? this.searchlogs(this.data.devcode) : this.searchlogs() }, }) \ No newline at end of file diff --git a/miniprogram/pages/indexapp/indexapp.wxml b/miniprogram/pages/indexapp/indexapp.wxml index 69322a0..f65b082 100644 --- a/miniprogram/pages/indexapp/indexapp.wxml +++ b/miniprogram/pages/indexapp/indexapp.wxml @@ -1,8 +1,12 @@ + + + + - @@ -32,9 +36,15 @@ - + + + + + + + @@ -46,14 +56,14 @@ - + - - + diff --git a/miniprogram/pages/indexapp/indexapp.wxss b/miniprogram/pages/indexapp/indexapp.wxss index b18706a..fc27fcb 100644 --- a/miniprogram/pages/indexapp/indexapp.wxss +++ b/miniprogram/pages/indexapp/indexapp.wxss @@ -128,6 +128,7 @@ .noticeClass{ height: 2300rpx; width: 750rpx; + overflow-y:hidden; } @@ -148,14 +149,14 @@ } +/* .vanstyle{ + button: not([size='mini']) { + user agent stylesheetmin-height: 40px; + width: 650rpx; + margin-left: 20rpx; + margin-right: auto; + + } + +} */ -/* .van-enter-active-class, -.van-leave-active-class { - transition-property: background-color, transform; -} - -.van-enter-class, -.van-leave-to-class { - background-color: red; - transform: rotate(-360deg) translate3d(-100%, -100%, 0); -} */ \ No newline at end of file diff --git a/miniprogram/pages/log/log.js b/miniprogram/pages/log/log.js deleted file mode 100644 index 83ba349..0000000 --- a/miniprogram/pages/log/log.js +++ /dev/null @@ -1,66 +0,0 @@ -// pages/log/log.js -Page({ - - /** - * 页面的初始数据 - */ - data: { - - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - - }, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { - - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - - }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { - - }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { - - } -}) \ No newline at end of file diff --git a/miniprogram/pages/log/log.json b/miniprogram/pages/log/log.json deleted file mode 100644 index 8835af0..0000000 --- a/miniprogram/pages/log/log.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "usingComponents": {} -} \ No newline at end of file diff --git a/miniprogram/pages/log/log.wxml b/miniprogram/pages/log/log.wxml deleted file mode 100644 index a510ad6..0000000 --- a/miniprogram/pages/log/log.wxml +++ /dev/null @@ -1,2 +0,0 @@ - -pages/log/log.wxml diff --git a/miniprogram/pages/log/log.wxss b/miniprogram/pages/log/log.wxss deleted file mode 100644 index 23db318..0000000 --- a/miniprogram/pages/log/log.wxss +++ /dev/null @@ -1 +0,0 @@ -/* pages/log/log.wxss */ \ No newline at end of file diff --git a/miniprogram/pages/login/login.js b/miniprogram/pages/login/login.js index a4074e7..cb0542a 100644 --- a/miniprogram/pages/login/login.js +++ b/miniprogram/pages/login/login.js @@ -1,11 +1,14 @@ // miniprogram/pages/login/login.js +var app = getApp() Page({ /** * 页面的初始数据 */ data: { - windowWidth:"" + windowWidth: "", + time: 15 * 1000, + showTime: false }, /** @@ -20,9 +23,9 @@ */ onReady: function () { this.setData({ - windowWidth:wx.getSystemInfoSync().windowWidth + windowWidth: wx.getSystemInfoSync().windowWidth }) - + }, /** @@ -66,14 +69,158 @@ onShareAppMessage: function () { }, + + + showLoading: function (message) { + if (wx.showLoading) { + // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 + wx.showLoading({ + title: message, + mask: true + }); + } else { + // 低版本采用Toast兼容处理并将时间设为20秒以免自动消失 + wx.showToast({ + title: message, + icon: 'loading', + mask: true, + duration: 20000 + }); + } + }, + hideLoading: function () { + if (wx.hideLoading) { + // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 + wx.hideLoading(); + } else { + wx.hideToast(); + } + }, + + //注册 loginClick: function () { + var that = this + that.showLoading("授权中...") + wx.login({ + success: function (res) { + if (res.code) { + wx.request({ + url: app.globalData.httpsUrl + "appUserOpenid/login", + data: { + code: res.code + }, + success: function (res) { + app.globalData.openid = res.data.data + wx.getUserInfo({ + success: (res) => { + var nickname = res.userInfo.nickName; + app.globalData.nickName = nickname; + //openid绑定昵称存入后台 + wx.request({ + url: app.globalData.httpsUrl + "appUserOpenid/add", + data: { + attr: nickname, + openid: app.globalData.openid + }, + success: function (res) { + that.hideLoading(); + wx.showToast({ + title: res.data.data+",\r\n请从正式版入口登录!", + icon: 'none', + duration: 2000 + }) - wx.navigateTo({ - - url: '../farmermain/farmermain', - + // //授权成功后跳转 + // wx.switchTab({ + // url: '../indexapp/indexapp' + // }) + } + }) + }, + fail: function (err) { + that.hideLoading(); + } + }) + }, + fail: function (res) { + that.hideLoading(); + wx.showToast({ + title: '服务器异常', + }) + } + }) + } + }, + fail: function (res) { + that.hideLoading(); + } }) + }, + //登录验证 + loginValidate: function () { + var that = this + that.showLoading("登录中...") + wx.login({ + success: function (res) { + if (res.code) { + console.info(res); + wx.request({ + url: app.globalData.httpsUrl + "appUserOpenid/login", + data: { + code: res.code + }, + success: function (res) { + app.globalData.openid = res.data.data + wx.request({ + url: app.globalData.httpsUrl + "appUserOpenid/validate", + data: { + openid: app.globalData.openid + }, + success: function (res) { + that.hideLoading(); + if (res.data.data) { + app.globalData.userName = res.data.data.attr1 == '' ? res.data.data.attr : res.data.data.attr1 + app.globalData.nickName = res.data.data.attr + app.globalData.role = res.data.data.role + wx.navigateTo({ + url: '../notice/notice' + }) + } else { + wx.showToast({ + icon: 'none', + title: '请联系管理员授权', + duration: 2000 + }) + } + }, + fail: function (err) { + that.hideLoading(); + wx.showToast({ + title: '验证失败', + }) + } + }) + }, + fail: function (res) { + that.hideLoading(); + wx.showToast({ + title: '服务器异常', + }) + } + }) + } + }, + fail: function (res) { + that.hideLoading(); + } + }) + }, + + finished() { + this.setData({ + showTime: true + }) }, onClickSubmit: function () { diff --git a/cloudfunctions/project.config.json b/cloudfunctions/project.config.json new file mode 100644 index 0000000..2b3119a --- /dev/null +++ b/cloudfunctions/project.config.json @@ -0,0 +1,28 @@ +{ + "appid": "wx2cef527a000f87c9", + "compileType": "miniprogram", + "libVersion": "2.27.3", + "packOptions": { + "ignore": [], + "include": [] + }, + "setting": { + "coverView": true, + "es6": true, + "postcss": true, + "minified": true, + "enhance": true, + "showShadowRootInWxmlPanel": true, + "packNpmRelationList": [], + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + } + }, + "condition": {}, + "editorSetting": { + "tabIndent": "insertSpaces", + "tabSize": 4 + } +} \ No newline at end of file diff --git a/cloudfunctions/project.private.config.json b/cloudfunctions/project.private.config.json new file mode 100644 index 0000000..42ff49d --- /dev/null +++ b/cloudfunctions/project.private.config.json @@ -0,0 +1,7 @@ +{ + "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", + "projectname": "cloudfunctions", + "setting": { + "compileHotReLoad": true + } +} \ No newline at end of file diff --git a/miniprogram/app.js b/miniprogram/app.js index 51d56f3..50a8a54 100644 --- a/miniprogram/app.js +++ b/miniprogram/app.js @@ -18,13 +18,15 @@ // this.globalData = {} }, globalData: { - // url: "http://111.198.10.15:11604/", - httpsUrl: "https://logapi.smartlog.work/", - httpsTestUrl: "https://smartlog.work/prodapi4test/", - url: "http://139.198.18.188:8083/", + httpsUrl: "https://logapi.smartlog.work/", + // httpsUrl: "http://139.198.18.188:8083/", // url: "http://127.0.0.1:8083/", - // httpsUrl: "http://127.0.0.1:8083/", + //httpsUrl: "http://127.0.0.1:8083/", openid: null, - indexCount:1 - }, + indexCount:1, + nickName:"", + userName:"", + role:"", + devcode:"" + } }) diff --git a/miniprogram/app.json b/miniprogram/app.json index d23f798..2b6db76 100644 --- a/miniprogram/app.json +++ b/miniprogram/app.json @@ -1,15 +1,17 @@ { "cloud": true, "pages": [ + "pages/login/login", "pages/indexapp/indexapp", "pages/earth/earth", "pages/applog/applog", "pages/addDevice/addDevice", "pages/addDevicelog/addDeviceLog", - "pages/searchLog/searchLog" + "pages/searchLog/searchLog", + "pages/notice/notice" ], "window": { - "backgroundColor": "#F6F6F6", + "backgroundColor": "#E6D480", "backgroundTextStyle": "light", "navigationBarBackgroundColor": "#FFCF00", "navigationBarTitleText": "智慧施工", @@ -46,11 +48,11 @@ "desc": "你的位置信息将用于小程序位置接口的效果展示" } }, + "requiredPrivateInfos": ["getLocation", "chooseLocation"], "networkTimeout": { "request": 30000, "connectSocket": 30000, "uploadFile": 30000, "downloadFile": 30000 - }, - "style": "v2" + } } \ No newline at end of file diff --git a/miniprogram/images/applocat.png b/miniprogram/images/applocat.png new file mode 100644 index 0000000..fe49f54 --- /dev/null +++ b/miniprogram/images/applocat.png Binary files differ diff --git a/miniprogram/images/back.png b/miniprogram/images/back.png new file mode 100644 index 0000000..32ac82d --- /dev/null +++ b/miniprogram/images/back.png Binary files differ diff --git a/miniprogram/images/bottom.png b/miniprogram/images/bottom.png new file mode 100644 index 0000000..d910e98 --- /dev/null +++ b/miniprogram/images/bottom.png Binary files differ diff --git a/miniprogram/images/header.png b/miniprogram/images/header.png new file mode 100644 index 0000000..6ea222e --- /dev/null +++ b/miniprogram/images/header.png Binary files differ diff --git a/miniprogram/images/login.png b/miniprogram/images/login.png index 8b73cc0..6471c46 100644 --- a/miniprogram/images/login.png +++ b/miniprogram/images/login.png Binary files differ diff --git a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss index 5a591fb..c9c35b5 100644 --- a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss +++ b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:100%;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:100%}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file +@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:650rpx;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:600rpx}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file diff --git a/miniprogram/pages/addDevice/addDevice.js b/miniprogram/pages/addDevice/addDevice.js index 2783674..78f00b7 100644 --- a/miniprogram/pages/addDevice/addDevice.js +++ b/miniprogram/pages/addDevice/addDevice.js @@ -1,5 +1,7 @@ // miniprogram/pages/addDevice/addDevice.js // import WxValidate from '../../utils/WxValidate.js' +var QQMapWX = require('../../libs/qqmap-wx-jssdk.js'); +var qqmapsdk; var app = getApp() Page({ @@ -11,32 +13,10 @@ canvasWidth: '', longitude: '', latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], + option1: [], personoption1: [], projectoption: [], + devtypeList:[], show: false, form: { devcode: "", @@ -59,7 +39,10 @@ project: "", area: "", street: "", - wellname: "" + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '', }, fileList: [] }, @@ -117,12 +100,14 @@ var that = this; //初始化表单内容为上次填写值 var cacheForms = wx.getStorageSync('cacheList') - if (cacheForms) { + cacheForms.photopath1='' + cacheForms.photopath2='' + cacheForms.photopath3='' + that.data.fileList=[] that.setData({ form: cacheForms, devcode: cacheForms.devcode, - }) } var form = that.data.form @@ -155,55 +140,89 @@ } }) + +//获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + that.setData({ + option1: welltypeArr + }) + } + } +}) + + //获取人员下拉列表 - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/getUser", + data:{ + tips:'repair' }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data.code == 200) { + var users = res.data.data + var personArr = []; + for (var i = 0; i < users.length; i++) { + var person = { + text: users[i].name, + value: users[i].name + }; + personArr.push(person); + } + that.setData({ + personoption1: personArr + }) } - that.setData({ - personoption1: personArr - }) } - }).catch(err => { - console.error(err); - }) + }) + - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - that.setData({ - projectoption: projectArr - }) + success(res){ + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); + } + that.setData({ + projectoption: projectArr + }) + } } - }).catch(err => { - console.error(err); - }) + }) + var installtime = 'form.installtimeFmt'; var dateNow = this.formatDate(); this.setData({ @@ -211,8 +230,40 @@ installtimeFmt: dateNow, [installtime]: dateNow, }); + + + + /** + * 获取设备类型下拉列表 + */ + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/deviceType", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var TypeList = res.data.data + var typeArr = []; + for (var i = 0; i < TypeList.length; i++) { + var type = { + text: TypeList[i].productName, + value: TypeList[i].productName + }; + typeArr.push(type); + } + that.setData({ + devtypeList: typeArr + }) + } + } + }) }, + + + /** * 生命周期函数--监听页面初次渲染完成 */ @@ -280,29 +331,7 @@ }, - - //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 - drawText: function (ctx, str, leftWidth, initHeight, titleHeight, canvasWidth) { - var lineWidth = 0; - var lastSubStrIndex = 0; //每次开始截取的字符串的索引 - for (let i = 0; i < str.length; i++) { - lineWidth += ctx.measureText(str[i]).width; - if (lineWidth > canvasWidth) { - ctx.fillText(str.substring(lastSubStrIndex, i), leftWidth, initHeight); //绘制截取部分 - initHeight = initHeight + leftWidth * 2; //22为字体的高度 - lineWidth = 0; - lastSubStrIndex = i; - // titleHeight += 40; - } - if (i == str.length - 1) { //绘制剩余部分 - ctx.fillText(str.substring(lastSubStrIndex, i + 1), leftWidth, initHeight); - } - } - // // 标题border-bottom 线距顶部距离 - // titleHeight = titleHeight + 10; - // return titleHeight - }, - + //验证表单 formValidate() { if (this.data.form.devcode == "") { @@ -312,27 +341,20 @@ }) return false } - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } if (this.data.form.wellcode == "") { wx.showToast({ icon: 'none', @@ -348,22 +370,10 @@ }) return false } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null) { + + if (this.data.form.installperson == "") { wx.showToast({ icon: 'none', title: '安装人员不能为空!', @@ -408,56 +418,90 @@ } return true; }, + //提交表单 formSubmit: function (event) { + console.log(this.data.form) + //表单参数验证 if (!this.formValidate()) { return false; } var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDevice', + //验证设备编号长度 + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/getDevTypeLength", data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceAdd/add" + code: encodeURI(this.data.form.devicetype) }, - }).then(res => { - if (res.result.code == 500) { - wx.showToast({ - title: '设备编号已安装!', - }) - } else if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - //用于回显 - wx.setStorageSync('cacheList', that.data.form) - //提交成功后提示用户操作 - if (res.confirm) { - wx.switchTab({ - url: '../earth/earth' - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (""==res.data.data ||res.data.data == that.data.form.devcode.length) { + that.saveDevice() + } else { //编号位数不对提示 + wx.showToast({ + icon: 'none', + title: '设备编号位数不对!', + duration: 1000 + }) + return false + } } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "提交失败", - }) }) }, + + //保存设备基本信息 + saveDevice() { + var that = this; + //设置照片路径 + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopathForm = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopathForm]: fileList[i].url.split("static/")[1] + }) + } + //表单提交 + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 500) { + wx.showToast({ + title: '设备编号已安装!', + }) + } else if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + //用于回显 + wx.setStorageSync('cacheList', that.data.form) + //提交成功后提示用户操作 + if (res.confirm) { + wx.switchTab({ + url: '../earth/earth' + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } + }, + fail(err) { + wx.showToast({ + title: '提交失败!', + }) + } + }) + }, + + //input 输入框设置值 confirm(event) { var that = this; var formValue = event.detail.value; @@ -466,8 +510,30 @@ that.setData({ [fromN]: formValue }) + //若输入是设备编号,自动获取设备类型 + if('devcode'==formName){ + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", + data: { + devcode: formValue, + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + that.setData({ + [formDevicetype]: res.data + }); + } + } + }) + } }, + //扫描设备获取编号和设备类型 scan() { var _this = this; wx.scanCode({ @@ -477,23 +543,28 @@ _this.setData({ [formdevcode]: devcode }); - wx.cloud.callFunction({ - name: 'findModeCode', + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", data: { devcode: devcode, - url: app.globalData.url + "appDeviceAdd/findModeCodeByCode" }, - }).then(res => { - if (res.result) { - var formDevicetype = 'form.devicetype' - _this.setData({ - [formDevicetype]: res.result - }); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + _this.setData({ + [formDevicetype]: res.data + }); + } } }) } }) }, + //粘贴经纬度 paste() { var _this = this; wx.getClipboardData({ @@ -510,9 +581,11 @@ longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), }); + _this.showAddress(_this.data.form.longitude,_this.data.form.latitude,_this) } }) }, + //设置经类型 selectValue(value) { var that = this; @@ -521,6 +594,16 @@ [wellType]: value.detail }) }, + + //设置设备类型 + selectDevType(event) { + var that = this; + var devtype = 'form.devicetype'; + that.setData({ + [devtype]: event.detail + }) + }, + //设置运维人员 selectpersonValue(event) { var that = this; var installPerson = 'form.installperson'; @@ -528,6 +611,7 @@ [installPerson]: event.detail }) }, + //设置项目 selectprojectValue(event) { var that = this; var project = 'form.project'; @@ -535,8 +619,41 @@ [project]: event.detail }) }, + showAddress :function(longitude, latitude, self) { + // 实例化腾讯地图API核心类 + qqmapsdk = new QQMapWX({ + key: 'BGPBZ-C5O3P-ROUDR-LWC4J-63EKH-V5FRX'//此处使用你自己申请的key + }) + // 腾讯地图调用接口 + qqmapsdk.reverseGeocoder({ + location: { + latitude: latitude, + longitude: longitude + }, + success: function (res) { + self.setData({ + 'form.area':res.result.address.slice(0,res.result.address.indexOf('区')+1), + 'form.street':res.result.address.slice(res.result.address.indexOf('区')+1) + }) + }, + fail: function (res) { + console.log(res); + }, + complete: function (res) { + } + }); + }, + //上传照片 afterRead(event) { var _this = this; + if (_this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '请先填写设备编号!\r\n否则水印中无编号', + duration: 2000 + }) + return false + } const { file } = event.detail; @@ -576,78 +693,8 @@ }) } }) - // 压缩图片 - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // //获取图片尺寸 - // wx.getImageInfo({ - // src: convertpath, - // success(res) { - // _this.setData({ - // canvasHeight: res.height, - // canvasWidth: res.width - // }) - // var ctx = wx.createCanvasContext('firstCanvas') - - // //将图片src放到cancas内,宽高为图片大小 - // ctx.drawImage(convertpath, 0, 0, res.width, res.height) - // //将声明的时间放入canvas - // ctx.setFontSize(30 * (res.width / 750)) //注意:设置文字大小必须放在填充文字之前,否则不生效 - // ctx.setFillStyle('blue') - // var text = "编号:" + _this.data.form.devcode + "\n经度:" + _this.data.form.longitude + "\n纬度:" + _this.data.form.latitude - // // _this.drawText(ctx,text,20, 70, 5, res.width) - // _this.drawText(ctx, text, 15 * (res.width / 750), 70 * (res.width / 750), 5, res.width) - - // // ctx.fillText(text, 0, 40) - // // ctx.strokeText(_this.data.form.devcode, 0, 30) - // //生成水印图 - // ctx.draw(false, function () { - // wx.canvasToTempFilePath({ - // canvasId: 'firstCanvas', - // success: (res) => { - // wx.compressImage({ - // src: res.tempFilePath, - // quality: 25, - // success: function (res) { - // //上传照片至服务器 - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: res.tempFilePath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // } - // }) - // //// - // } - // }) - // }) - // } - // }) - // } - // }); }, + //删除照片 deletePhoto(event) { var image_index = event.detail.index var fileList_new = this.data.fileList; diff --git a/miniprogram/pages/addDevice/addDevice.wxml b/miniprogram/pages/addDevice/addDevice.wxml index b0977e2..f12c254 100644 --- a/miniprogram/pages/addDevice/addDevice.wxml +++ b/miniprogram/pages/addDevice/addDevice.wxml @@ -5,18 +5,30 @@ - + + + + + + + + + + + + + - - + + - - - + + + @@ -29,13 +41,13 @@ - + - + - + - + @@ -54,8 +66,7 @@ - - + @@ -68,8 +79,8 @@ - - + + - 保存 + 保存 \ No newline at end of file diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.js b/miniprogram/pages/addDevicelog/addDeviceLog.js index cdec71b..a0dc6da 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.js +++ b/miniprogram/pages/addDevicelog/addDeviceLog.js @@ -3,681 +3,665 @@ var app = getApp(); Page({ - /** - * 页面的初始数据 - */ - data: { - pageName: '', - showMask: false, - today: new Date().getTime(), - longitude: '', - latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], - personoption1: [], - projectoption: [], - devcode: "", - deviceMode: "", - installtimeFmt: '', - show: false, - form: { - devcode: "", - wellcode: "", - welltype: "", - welldepth: "", - installheigt: "", - installperson: "", - installtimeFmt: "", - photopath: "", - factory: "", - workmsg: "", - position: "", - description: "", - longitude: "", - latitude: "", - longitude84: "", - latitude84: "", - devicetype: "", - project: "", - area: "", - street: "", - wellname: "" - }, - fileList: [], - detail: "" - }, + /** + * 页面的初始数据 + */ + data: { + pageName: '', + showMask: false, + today: new Date().getTime(), + longitude: '', + latitude: '', + option1: [], + personoption1: [], + projectoption: [], + devcode: "", + deviceMode: "", + installtimeFmt: '', + show: false, + form: { + devcode: "", + wellcode: "", + welltype: "", + welldepth: "", + installheigt: "", + installperson: "", + installtimeFmt: "", + photopath: "", + factory: "", + workmsg: "", + position: "", + description: "", + longitude: "", + latitude: "", + longitude84: "", + latitude84: "", + devicetype: "", + project: "", + area: "", + street: "", + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '' + }, + fileList: [], + detail: "", + markers: [{ + id: 100, + // iconPath: "../../images/point.png", + latitude: '', + longitude: '', + // label:'1', + width: 25, + height: 35 + }], + }, - onDisplay() { - this.setData({ - show: true - }); - }, - onClose() { - this.setData({ - show: false - }); - }, - formatDate() { - var date = new Date(); - // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; - var seperator1 = "-"; - var month = date.getMonth() + 1; - var strDate = date.getDate(); - var hour = date.getHours() - var minute = date.getMinutes() - var second = date.getSeconds() - month = month > 9 ? month : "0" + month; - strDate = strDate > 9 ? strDate : "0" + strDate; - hour = hour > 9 ? hour : "0" + hour; - minute = minute > 9 ? minute : "0" + minute; - second = second > 9 ? second : "0" + second; - var currentdate = - date.getFullYear() + - seperator1 + - month + - seperator1 + - strDate + - " " + - hour + ":" + - minute + ":" + - second; - return currentdate; + onDisplay() { + this.setData({ + show: true + }); + }, + onClose() { + this.setData({ + show: false + }); + }, + formatDate() { + var date = new Date(); + // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; + var seperator1 = "-"; + var month = date.getMonth() + 1; + var strDate = date.getDate(); + var hour = date.getHours() + var minute = date.getMinutes() + var second = date.getSeconds() + month = month > 9 ? month : "0" + month; + strDate = strDate > 9 ? strDate : "0" + strDate; + hour = hour > 9 ? hour : "0" + hour; + minute = minute > 9 ? minute : "0" + minute; + second = second > 9 ? second : "0" + second; + var currentdate = + date.getFullYear() + + seperator1 + + month + + seperator1 + + strDate + + " " + + hour + ":" + + minute + ":" + + second; + return currentdate; - }, - onConfirm(event) { - var installtime = 'form.installtimeFmt'; - this.setData({ - show: false, - installtimeFmt: this.formatDate(event.detail), - [installtime]: this.formatDate(event.detail), - }); - }, + }, + onConfirm(event) { + var installtime = 'form.installtimeFmt'; + this.setData({ + show: false, + installtimeFmt: this.formatDate(event.detail), + [installtime]: this.formatDate(event.detail), + }); + }, - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - var _this = this; - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" - }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); - } - _this.setData({ - personoption1: personArr - }) + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + var _this = this; + _this.setData({ + 'markers[0].latitude': Number(wx.getStorageSync('resultObject').latitude) , + 'markers[0].longitude': Number(wx.getStorageSync('resultObject').longitude), + // 'markers[0].label':'10', + 'markers[0].width': 18, + 'markers[0].id':1, + 'markers[0].height': 30, + latitude:Number(wx.getStorageSync('resultObject').latitude), + longitude:Number(wx.getStorageSync('resultObject').longitude) + }) + //获取人员下拉列表 + // wx.request({ + // method: "POST", + // url: app.globalData.httpsUrl + "deviceType/getUser", + // data:{ + // tips:'repair' + // }, + // header: { + // 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + // }, + // success(res) { + // if (res.data.code == 200) { + // var users = res.data.data + // var personArr = []; + // for (var i = 0; i < users.length; i++) { + // var person = { + // text: users[i].name, + // value: users[i].name + // }; + // personArr.push(person); + // } + // _this.setData({ + // personoption1: personArr + // }) + // } + // } + // }) + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); } - }).catch(err => { - console.error(err); - }) - - - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" - }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - _this.setData({ - projectoption: projectArr - }) - } - }).catch(err => { - console.error(err); - }) - - if (options.pageName) { - this.setData({ - pageName: options.pageName - }) - } - - if (options.detail) { - - var formObject = JSON.parse(options.detail); _this.setData({ - form: formObject, - detail: options.detail + projectoption: projectArr }) - - _this.setData({ - ['form.installperson']: "", - ['form.installtimeFmt']: "", - ['form.workmsg']: "", - ['form.description']: "" - }) - - const { - fileList = [] - } = _this.data; - if (formObject.photopath1 != "") { - var file1 = { - url: app.globalData.url + "static/" + formObject.photopath1 - } - fileList.push(file1) - } - if (formObject.photopath2 != "") { - var file2 = { - url: app.globalData.url + "static/" + formObject.photopath2 - } - fileList.push(file2) - } - if (formObject.photopath3 != "") { - var file3 = { - url: app.globalData.url + "static/" + formObject.photopath3 - } - fileList.push(file3) - } - - _this.setData({ - fileList - }); } - var installtime = 'form.installtimeFmt'; - var dateNow = this.formatDate(); - this.setData({ - installtimeFmt: dateNow, - [installtime]: dateNow, - }); - }, + } + }) - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { + //获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + _this.setData({ + option1: welltypeArr + }) + } + } +}) - }, + //跳转时带入参数返回哪页 + if (options.pageName) { + this.setData({ + pageName: options.pageName + }) + } + //跳转时带入参数设备的安装信息 + if (wx.getStorageSync('resultObject')) { + var formObject = wx.getStorageSync('resultObject') + _this.setData({ + form: formObject, + detail: formObject + }) - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { + _this.setData({ + ['form.installperson']: app.globalData.userName, + ['form.installtimeFmt']: "", + ['form.workmsg']: "", + ['form.description']: "" + }) - }, + const { + fileList = [] + } = _this.data; + if (formObject.photopath1 != "") { + var file1 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath1 + } + fileList.push(file1) + } + if (formObject.photopath2 != "") { + var file2 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath2 + } + fileList.push(file2) + } + if (formObject.photopath3 != "") { + var file3 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath3 + } + fileList.push(file3) + } + _this.setData({ + fileList + }); + } + var installtime = 'form.installtimeFmt'; + var dateNow = this.formatDate(); + this.setData({ + installtimeFmt: dateNow, + [installtime]: dateNow, + }); + }, - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, - }, + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + wx.removeStorageSync('resultObject') + }, - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, - }, + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { + }, - }, + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { + }, - }, + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { + }, - }, + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + }, - /** - * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true - **/ + /** + * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true + **/ - isNumber: function (val) { + isNumber: function (val) { - var regPos = /^[0-9]*$/; //非负浮点数 - var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数 - if (regPos.test(val) || regNeg.test(val)) { - return false; - } else { - return true; - } + var regPos = /^[0-9]*$/; //非负浮点数 + var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数 + if (regPos.test(val) || regNeg.test(val)) { + return false; + } else { + return true; + } - }, + }, - formValidate() { + formValidate() { - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } - if (this.data.form.wellcode == "") { - wx.showToast({ - icon: 'none', - title: '井编号不能为空!', - }) - return false - } - if (this.data.form.devicetype == "") { - wx.showToast({ - icon: 'none', - title: '设备类型不能为空!', - }) - return false - } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + if (this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '设备编号不能为空!', + }) + return false + } + if (this.data.form.wellcode == "") { + wx.showToast({ + icon: 'none', + title: '井编号不能为空!', + }) + return false + } + if (this.data.form.devicetype == "") { + wx.showToast({ + icon: 'none', + title: '设备类型不能为空!', + }) + return false + } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null || - this.data.form.installperson == '') { - wx.showToast({ - icon: 'none', - title: '运维人员不能为空!', - }) - return false - } - if (this.data.form.project == "") { - wx.showToast({ - icon: 'none', - title: '所属项目不能为空!', - }) - return false - } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } + if (this.data.form.installperson == null || + this.data.form.installperson == '') { + wx.showToast({ + icon: 'none', + title: '运维人员不能为空!', + }) + return false + } + if (this.data.form.project == "") { + wx.showToast({ + icon: 'none', + title: '所属项目不能为空!', + }) + return false + } - if (this.data.form.welldepth != null) { - if (this.isNumber(this.data.form.welldepth)) { - wx.showToast({ - icon: 'none', - title: '井深必须为数值!', - }) - return false - } - } - if (this.data.form.installheigt != null) { - if (this.isNumber(this.data.form.installheigt)) { - wx.showToast({ - icon: 'none', - title: '到井口距离必须为数值!', - }) - return false - } - } - - return true; - }, - - changeMsg: function () { - var formNew = this.data.form; - var formOld = JSON.parse(this.data.detail); - var descpNew = ""; - if (formNew.devcode != formOld.devcode) { - descpNew += "修改设备编号,原编号:" + formOld.devcode + ",新编号:" + formNew.devcode + ";" - } - if (formNew.devicetype != formOld.devicetype) { - descpNew += "修改设备类型,原设备类型:" + formOld.devicetype + ",新设备类型:" + formNew.devicetype + ";" - } - if (formNew.area != formOld.area) { - descpNew += "修改区,原区:" + formOld.area + ",新区:" + formNew.area + ";" - } - if (formNew.street != formOld.street) { - descpNew += "修改街道,原街道:" + formOld.street + ",新街道:" + formNew.street + ";" - } - if (formNew.wellname != formOld.wellname) { - descpNew += "修改井名称,原井名称:" + formOld.wellname + ",新井名称:" + formNew.wellname + ";" - } - if (formNew.factory != formOld.factory) { - descpNew += "修改权属单位,原权属单位:" + formOld.factory + ",新权属单位:" + formNew.factory + ";" - } - if (formNew.installheigt != formOld.installheigt) { - descpNew += "修改井口距离,原井口距离:" + formOld.installheigt + ",新井口距离:" + formNew.installheigt + ";" - } - if (formNew.installperson != formOld.installperson) { - descpNew += "修改运维人员,原运维人员:" + formOld.installperson + ",新运维人员:" + formNew.installperson + ";" - } - if (formNew.latitude != formOld.latitude) { - descpNew += "修改纬度,原纬度:" + formOld.latitude + ",新纬度:" + formNew.latitude + ";" - } - if (formNew.longitude != formOld.longitude) { - descpNew += "修改经度,原经度:" + formOld.longitude + ",新经度:" + formNew.longitude + ";" - } - if (formNew.position != formOld.position) { - descpNew += "修改位置描述,原位置:" + formOld.position + ",新位置:" + formNew.position + ";" - } - if (formNew.wellcode != formOld.wellcode) { - descpNew += "修改井编号,原编号:" + formOld.wellcode + ",新编号:" + formNew.wellcode + ";" - } - if (formNew.welldepth != formOld.welldepth) { - descpNew += "修改井深,原井深:" + formOld.welldepth + ",新井深:" + formNew.welldepth + ";" - } - if (formNew.welltype != formOld.welltype) { - descpNew += "修改井类型,原井类型:" + formOld.welltype + ",新井类型:" + formNew.welltype + ";" - } - if (formNew.project != formOld.project) { - descpNew += "修改所属项目,原项目:" + formOld.project + ",新项目:" + formNew.project + ";" - } - if (this.data.photopath1 != formOld.photopath1 || - this.data.photopath2 != formOld.photopath2 || - this.data.photopath3 != formOld.photopath3) { - descpNew += "修改照片;" - } - if ("" != formNew.description) { - descpNew += formNew.description; - } - this.setData({ - ['form.description']: descpNew + if (this.data.form.welldepth != null) { + if (this.isNumber(this.data.form.welldepth)) { + wx.showToast({ + icon: 'none', + title: '井深必须为数值!', }) - }, + return false + } + } + if (this.data.form.installheigt != null) { + if (this.isNumber(this.data.form.installheigt)) { + wx.showToast({ + icon: 'none', + title: '到井口距离必须为数值!', + }) + return false + } + } - formSubmit: function (event) { + return true; + }, - if (!this.formValidate()) { - return false; - } - this.changeMsg(); - var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDeviceLog', - data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceLog/add" - }, - }).then(res => { - // var resultObj=JSON.parse(res.result); - if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - if (res.confirm) { - wx.switchTab({ - url: that.data.pageName - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) - } - }).catch(err => { - console.error(err) - wx.showToast({ - title: "提交失败", - }) - }) - }, - confirm(event) { - var that = this; - var formValue = event.detail.value; - var formName = event.target.dataset.id; - var fromN = 'form.' + [formName]; - that.setData({ - [fromN]: formValue - }) - }, + //获取与上次修改的信息 + changeMsg: function () { + var formNew = this.data.form; + console.log(this.data.detail) + var formOld = JSON.parse(this.data.detail); + var descpNew = ""; + if (formNew.devcode != formOld.devcode) { + descpNew += "修改设备编号,原值:" + formOld.devcode + ",新值:" + formNew.devcode + ";" + } + if (formNew.devicetype != formOld.devicetype) { + descpNew += "修改设备类型,原值:" + formOld.devicetype + ",新值:" + formNew.devicetype + ";" + } + if (formNew.area != formOld.area) { + descpNew += "修改区,原值:" + formOld.area + ",新值:" + formNew.area + ";" + } + if (formNew.street != formOld.street) { + descpNew += "修改街道,原值:" + formOld.street + ",新值:" + formNew.street + ";" + } + if (formNew.wellname != formOld.wellname) { + descpNew += "修改井名称,原值:" + formOld.wellname + ",新值:" + formNew.wellname + ";" + } + if (formNew.factory != formOld.factory) { + descpNew += "修改权属单位,原值:" + formOld.factory + ",新值:" + formNew.factory + ";" + } + if (formNew.installheigt != formOld.installheigt) { + descpNew += "修改井口距离,原值:" + formOld.installheigt + ",新值:" + formNew.installheigt + ";" + } + if (formNew.installperson != formOld.installperson) { + descpNew += "修改运维人员,原值:" + formOld.installperson + ",新值:" + formNew.installperson + ";" + } + if (formNew.latitude != formOld.latitude) { + descpNew += "修改纬度,原值:" + formOld.latitude + ",新值:" + formNew.latitude + ";" + } + if (formNew.longitude != formOld.longitude) { + descpNew += "修改经度,原值:" + formOld.longitude + ",新值:" + formNew.longitude + ";" + } + if (formNew.position != formOld.position) { + descpNew += "修改位置描述,原值:" + formOld.position + ",新值:" + formNew.position + ";" + } + if (formNew.wellcode != formOld.wellcode) { + descpNew += "修改井编号,原值:" + formOld.wellcode + ",新值:" + formNew.wellcode + ";" + } + if (formNew.welldepth != formOld.welldepth) { + descpNew += "修改井深,原值:" + formOld.welldepth + ",新值:" + formNew.welldepth + ";" + } + if (formNew.welltype != formOld.welltype) { + descpNew += "修改井类型,原值:" + formOld.welltype + ",新值:" + formNew.welltype + ";" + } + if (formNew.project != formOld.project) { + descpNew += "修改所属项目,原值:" + formOld.project + ",新值:" + formNew.project + ";" + } + if (this.data.form.photopath1 != formOld.photopath1 || + this.data.form.photopath2 != formOld.photopath2 || + this.data.form.photopath3 != formOld.photopath3) { + descpNew += "修改照片;" + } + if ("" != formNew.description) { + descpNew += formNew.description; + } + this.setData({ + ['form.description']: descpNew + }) + }, - scan() { + //提交表单 + formSubmit: function (event) { - wx.scanCode({ - success(res) { - console.log(res) - } - }) + //表单验证 + if (!this.formValidate()) { + return false; + } + //自动生成修改内容 + this.changeMsg(); + //提交权限限制(只有施工人员能修改) + if(app.globalData.role!='repair'){ + wx.showToast({ + icon: 'none', + title: '无权限修改', + duration:2000 + }) + return false + } + var that = this; + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopath = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopath]: fileList[i].url.split("static/")[1] + }) + } + delete that.data.form.installtime + delete that.data.form.createtime + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - paste() { - var _this = this; - wx.getClipboardData({ - success: function (res) { - var longitude = 'form.longitude'; - var latitude = 'form.latitude'; - var longitude84 = 'form.longitude84'; - var latitude84 = 'form.latitude84'; - _this.setData({ - [longitude]: parseFloat(res.data.split(",", 4)[1]).toFixed(6), - [latitude]: parseFloat(res.data.split(",", 4)[0]).toFixed(6), - [longitude84]: "" == (res.data.split(",", 4)[3]) ? "" : parseFloat(res.data.split(",", 4)[3]).toFixed(6), - [latitude84]: "" == (res.data.split(",", 4)[2]) ? "" : parseFloat(res.data.split(",", 4)[2]).toFixed(6), - longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), - latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), - }); - } - }) - }, - selectValue(value) { - var that = this; - var wellType = 'form.welltype'; - that.setData({ - [wellType]: value.detail - }) - }, - selectpersonValue(event) { - var that = this; - var installPerson = 'form.installperson'; - that.setData({ - [installPerson]: event.detail - }) - }, - selectprojectValue(event) { - var that = this; - var project = 'form.project'; - that.setData({ - [project]: event.detail, - showMask: true - }) - }, - open() { - this.setData({ - showMask: true - }) - }, - close() { - this.setData({ - showMask: false - }) - }, - afterRead(event) { - var _this = this; - const { - file - } = event.detail; - const { - fileList = [] - } = _this.data; - var convertpath = ""; - wx.compressImage({ - src: event.detail.file.path, - quality: 25, - success: function (res) { - convertpath = res.tempFilePath; - wx.uploadFile({ - url: app.globalData.httpsUrl + "appDeviceAdd/fileUploadMarker", - filePath:convertpath, - name: 'file', - formData: { - 'text': "编号:" + _this.data.form.devcode + "经度:" + _this.data.form.longitude + "纬度:" + _this.data.form.latitude - }, - header: { - "Content-Type": "multipart/form-data", - 'accept': 'application/json', - }, - success(res) { - if (res.data) { - var url = JSON.parse(res.data); - fileList.push({ - ...file, - url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - }); - _this.setData({ - fileList - }); - } - } + success(res) { + if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + if (res.confirm) { + wx.switchTab({ + url: that.data.pageName }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') } - }) - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // // var base64 = "data:image/png;base64," + wx.getFileSystemManager().readFileSync(convertpath, 'base64'); - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: convertpath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // // wx.cloud.callFunction({ - // // name: 'uploadFile', - // // data: { - // // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // // fileBase64: base64 - // // }, - // // success: function (res) { - // // if (res.result) { - // // fileList.push({ - // // ...file, - // // url: app.globalData.url + "static/" + res.result.data.replace(/\\/g, "/") - // // }); - // // _this.setData({ - // // fileList - // // }); - // // } - // // }, - // // complete: res => { - // // }, - // // }) - // } - // }); + } + }) + } + }, + fail(err) { + wx.showToast({ + title: "提交失败", + }) + } + }) + }, + //报存录入的input信息 + confirm(event) { + var that = this; + var formValue = event.detail.value; + var formName = event.target.dataset.id; + var fromN = 'form.' + [formName]; + that.setData({ + [fromN]: formValue + }) + }, + + //扫码 + scan() { + + wx.scanCode({ + success(res) { + console.log(res) + } + }) + }, + //粘贴经纬度 + paste() { + var _this = this; + wx.getClipboardData({ + success: function (res) { + var longitude = 'form.longitude'; + var latitude = 'form.latitude'; + var longitude84 = 'form.longitude84'; + var latitude84 = 'form.latitude84'; + _this.setData({ + [longitude]: parseFloat(res.data.split(",", 4)[1]).toFixed(6), + [latitude]: parseFloat(res.data.split(",", 4)[0]).toFixed(6), + [longitude84]: "" == (res.data.split(",", 4)[3]) ? "" : parseFloat(res.data.split(",", 4)[3]).toFixed(6), + [latitude84]: "" == (res.data.split(",", 4)[2]) ? "" : parseFloat(res.data.split(",", 4)[2]).toFixed(6), + longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), + latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), + }); + } + }) + }, + selectValue(value) { + var that = this; + var wellType = 'form.welltype'; + that.setData({ + [wellType]: value.detail + }) + }, + //运维人员默认为登录人 + // selectpersonValue(event) { + // var that = this; + // var installPerson = 'form.installperson'; + // that.setData({ + // [installPerson]: event.detail + // }) + // }, + selectprojectValue(event) { + var that = this; + var project = 'form.project'; + that.setData({ + [project]: event.detail, + showMask: true + }) + }, + + open() { + this.setData({ + showMask: true + }) + }, + //隐藏textarea,防止遮挡 + close() { + this.setData({ + showMask: false + }) + }, + //上传照片 + afterRead(event) { + var _this = this; + const { + file + } = event.detail; + const { + fileList = [] + } = _this.data; + var convertpath = ""; + wx.compressImage({ + src: event.detail.file.path, + quality: 25, + success: function (res) { + convertpath = res.tempFilePath; + wx.uploadFile({ + url: app.globalData.httpsUrl + "appDeviceAdd/fileUploadMarker", + filePath: convertpath, + name: 'file', + formData: { + 'text': "编号:" + _this.data.form.devcode + "经度:" + _this.data.form.longitude + "纬度:" + _this.data.form.latitude }, - deletePhoto(event) { - var that = this - var image_index = event.detail.index - var fileList_new = that.data.fileList; - wx.showModal({ - content: '确定删除照片?', - success: function (res) { - if (res.confirm) { - fileList_new.splice(image_index, 1); - that.setData({ - fileList: fileList_new - }) - wx.cloud.callFunction({ - name: 'deletePhoto', - data: { - url: app.globalData.url + "appDeviceLog/deletePhoto", - devcode: that.data.form.devcode, - pathIndex: image_index - }, - success: function (res) {}, - complete: res => {}, - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + "Content-Type": "multipart/form-data", + 'accept': 'application/json', }, - }) \ No newline at end of file + success(res) { + if (res.data) { + var url = JSON.parse(res.data); + fileList.push({ + ...file, + url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") + }); + _this.setData({ + fileList + }); + } + } + }) + } + }) + }, + //删除照片 + deletePhoto(event) { + var that = this + var image_index = event.detail.index + var fileList_new = that.data.fileList; + wx.showModal({ + content: '确定删除照片?', + success: function (res) { + if (res.confirm) { + fileList_new.splice(image_index, 1); + that.setData({ + fileList: fileList_new + }) + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deletePhoto", + data: { + devcode: that.data.form.devcode + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) {} + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } +}) \ No newline at end of file diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.wxml b/miniprogram/pages/addDevicelog/addDeviceLog.wxml index 38620d4..b10cc7d 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.wxml +++ b/miniprogram/pages/addDevicelog/addDeviceLog.wxml @@ -1,15 +1,21 @@ - + + + + + - + - - + + - - + + - + @@ -39,24 +45,25 @@ - - - + + + - + - + + @@ -64,7 +71,7 @@ - + @@ -79,9 +86,9 @@ - + - 保存 + 保存 diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.wxss b/miniprogram/pages/addDevicelog/addDeviceLog.wxss index ee0b75c..08d5fd7 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.wxss +++ b/miniprogram/pages/addDevicelog/addDeviceLog.wxss @@ -24,6 +24,17 @@ display: flex; align-items: center; } +.map-view{ + width: 750rpx; + height: 485rpx; + position: fixed; + top: 0px; + left: 0px; + z-index: 999; +} +.content{ + margin-top: 495rpx; +} .left { width: 210rpx; diff --git a/miniprogram/pages/addFunction/addFunction.js b/miniprogram/pages/addFunction/addFunction.js deleted file mode 100644 index 4966be3..0000000 --- a/miniprogram/pages/addFunction/addFunction.js +++ /dev/null @@ -1,60 +0,0 @@ -// pages/addFunction/addFunction.js - -const code = `// 云函数入口函数 -exports.main = (event, context) => { - console.log(event) - console.log(context) - return { - sum: event.a + event.b - } -}` - -Page({ - - data: { - result: '', - canIUseClipboard: wx.canIUse('setClipboardData'), - }, - - onLoad: function (options) { - - }, - - copyCode: function() { - wx.setClipboardData({ - data: code, - success: function () { - wx.showToast({ - title: '复制成功', - }) - } - }) - }, - - testFunction() { - wx.cloud.callFunction({ - name: 'sum', - data: { - a: 1, - b: 2 - }, - success: res => { - wx.showToast({ - title: '调用成功', - }) - this.setData({ - result: JSON.stringify(res.result) - }) - }, - fail: err => { - wx.showToast({ - icon: 'none', - title: '调用失败', - }) - console.error('[云函数] [sum] 调用失败:', err) - } - }) - }, - -}) - diff --git a/miniprogram/pages/addFunction/addFunction.json b/miniprogram/pages/addFunction/addFunction.json deleted file mode 100644 index a9a50c5..0000000 --- a/miniprogram/pages/addFunction/addFunction.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "navigationBarTitleText": "云函数指引", - "usingComponents": {} -} \ No newline at end of file diff --git a/miniprogram/pages/addFunction/addFunction.wxml b/miniprogram/pages/addFunction/addFunction.wxml deleted file mode 100644 index 3a10626..0000000 --- a/miniprogram/pages/addFunction/addFunction.wxml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - 测试云函数 - - - 期望输出:{"sum":3} - - - 调用结果:{{result}} - - - - - 新增云函数 - 1. 在云函数根目录 cloudfunctions 上右键选择新建云函数,命名为 sum - 2. 在创建的 cloudfunctions/sum/index.js 文件中添加如下代码 - - - 3. 在 cloudfunctions/sum 目录上右键上传并部署 - 4. 点击测试云函数测试 - 5. 打开云开发云函数管理页,选择 sum 云函数 - 6. 查看 sum 的调用日志 - 进阶:可在云函数中使用 wx-server-sdk 操作数据库,文件存储和调用其他云函数,详见文档 - - - diff --git a/miniprogram/pages/addFunction/addFunction.wxss b/miniprogram/pages/addFunction/addFunction.wxss deleted file mode 100644 index 7ac8619..0000000 --- a/miniprogram/pages/addFunction/addFunction.wxss +++ /dev/null @@ -1,3 +0,0 @@ -/* pages/addFunction/addFunction.wxss */ - -@import "../../style/guide.wxss"; \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.js b/miniprogram/pages/applog/applog.js index 0e8c185..189e61f 100644 --- a/miniprogram/pages/applog/applog.js +++ b/miniprogram/pages/applog/applog.js @@ -13,98 +13,25 @@ isSeach: "false", params: {}, total: 0, - show: false + show: false, + delBtnWidth: 100, //删除按钮宽度单位(rpx) + activeIndex: -1, + list_style: '' }, - - touchE: function (e) { - // console.log(e); - var that = this - if (e.changedTouches.length == 1) { - //手指移动结束后触摸点位置的X坐标 - var endX = e.changedTouches[0].clientX; - //触摸开始与结束,手指移动的距离 - var disX = that.data.startX - endX; - var delBtnWidth = that.data.delBtnWidth; - //如果距离小于删除按钮的1/2,不显示删除按钮 - var txtStyle = disX > delBtnWidth / 2 ? "left:-" + delBtnWidth + "rpx" : "left:0rpx"; - - //获取手指触摸的是哪一项 - var index = e.currentTarget.dataset.index; - var list = that.data.deviceloglist; - list[index].txtStyle = txtStyle; - //更新列表的状态 - that.setData({ - deviceloglist: list - }); - } - }, - //手指触摸动作开始 记录起点X坐标 - touchstart: function (e) { - //开始触摸时 重置所有删除 - this.data.deviceloglist.forEach(function (v, i) { - if (v.isTouchMove) //只操作为true的 - v.isTouchMove = false; - }) - this.setData({ - startX: e.changedTouches[0].clientX, - startY: e.changedTouches[0].clientY, - deviceloglist: this.data.deviceloglist - }) - }, - //滑动事件处理 - touchmove: function (e) { - var that = this, - index = e.currentTarget.dataset.index, //当前索引 - startX = that.data.startX, //开始X坐标 - startY = that.data.startY, //开始Y坐标 - touchMoveX = e.changedTouches[0].clientX, //滑动变化坐标 - touchMoveY = e.changedTouches[0].clientY, //滑动变化坐标 - //获取滑动角度 - angle = that.angle({ - X: startX, - Y: startY - }, { - X: touchMoveX, - Y: touchMoveY - }); - that.data.deviceloglist.forEach(function (v, i) { - v.isTouchMove = false - //滑动超过30度角 return - if (Math.abs(angle) > 30) return; - if (i == index) { - if (touchMoveX > startX) //右滑 - v.isTouchMove = false - else //左滑 - v.isTouchMove = true - } - }) - //更新数据 - that.setData({ - deviceloglist: that.data.deviceloglist - }) - }, - /** - * 计算滑动角度 - * @param {Object} start 起点坐标 - * @param {Object} end 终点坐标 - */ - angle: function (start, end) { - var _X = end.X - start.X, - _Y = end.Y - start.Y - //返回角度 /Math.atan()返回数字的反正切值 - return 360 * Math.atan(_Y / _X) / (2 * Math.PI); - }, - /** - * 生命周期函数--监听页面加载var_this=this; - */ onLoad: function (options) { - if (options.params) { this.setData({ params: JSON.parse(options.params), isSeach: "true" }) this.initPages() + }else{ + this.setData({ + show: false + }) + //清空参数,重新加载 + this.clearParams(); + this.initPages(); } }, @@ -116,20 +43,33 @@ }, + //点击tabBar事件 + onTabItemTap(item) { + //隐藏历史显示总记录条数 + this.setData({ + show: false + }) + //清空参数,重新加载 + this.clearParams(); + this.initPages(); + }, + + /** * 生命周期函数--监听页面显示 */ onShow: function (options) { - this.setData({ - show:false - }) - if (this.data.isSeach == "false") { - this.clearParams(); - this.initPages(); - } - this.setData({ - isSeach: "false" - }) + + // this.setData({ + // show: false + // }) + // if (this.data.isSeach == "false") { + // this.clearParams(); + // this.initPages(); + // } + // this.setData({ + // isSeach: "false" + // }) }, /** @@ -167,6 +107,119 @@ }, + + //手指触摸动作开始 记录起点X坐标 + touchstart: function (e) { + //开始触摸时 重置所有删除 + this.data.deviceloglist.forEach(function (v, i) { + if (v.isTouchMove) //只操作为true的 + v.isTouchMove = false; + }) + this.setData({ + startX: e.changedTouches[0].clientX, + startY: e.changedTouches[0].clientY, + deviceloglist: this.data.deviceloglist + }) + }, + + //滑动事件处理 + touchmove: function (e) { + var that = this, + index = e.currentTarget.dataset.index, //当前索引 + startX = that.data.startX, //开始X坐标 + startY = that.data.startY, //开始Y坐标 + touchMoveX = e.changedTouches[0].clientX, //滑动变化坐标 + touchMoveY = e.changedTouches[0].clientY, //滑动变化坐标 + //获取滑动角度 + angle = that.angle({ + X: startX, + Y: startY + }, { + X: touchMoveX, + Y: touchMoveY + }); + that.data.deviceloglist.forEach(function (v, i) { + // v.isTouchMove = false + //滑动超过30度角 return + if (Math.abs(angle) > 30) return; + if (i == index) { + if (touchMoveX > startX) //右滑 + v.isTouchMove = false + else //左滑 + v.isTouchMove = true + } + }) + //更新数据 + that.setData({ + deviceloglist: that.data.deviceloglist + }) + }, + + /** + * 计算滑动角度 + * @param {Object} start 起点坐标 + * @param {Object} end 终点坐标 + */ + angle: function (start, end) { + var _X = end.X - start.X, + _Y = end.Y - start.Y + //返回角度 /Math.atan()返回数字的反正切值 + return 360 * Math.atan(_Y / _X) / (2 * Math.PI); + }, + + //删除事件 + delItem: function (e) { + if(app.globalData.role!='repair'){ + wx.showToast({ + icon: 'none', + title: '无权限删除', + duration:2000 + }) + return false + } + var that = this + wx.showModal({ + content: '是否删除?', + success: function (res) { + if (res.confirm) { + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/delete", + data: { + appDeviceAddId: e.currentTarget.dataset.devid + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if(res.data.code=='200'){ + that.data.deviceloglist.splice(e.currentTarget.dataset.index, 1) + that.setData({ + deviceloglist: that.data.deviceloglist, + total: that.data.deviceloglist.length + }) + wx.showToast({ + title: '删除成功!', + icon: 'none', + duration: 1000 + }) + } + }, + fail(err) { + wx.showToast({ + title: '删除失败!', + icon: 'none', + duration: 2000 + }) + } + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + }, + showLoading: function (message) { if (wx.showLoading) { // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 @@ -199,95 +252,105 @@ deviceloglist: [] }) }, + //查询列表数据 initPages: function () { var that = this + that.setData({ + show: false + }) var offsetValue = that.data.deviceloglist.length % 15 > 0 ? parseInt(that.data.deviceloglist.length / 15) + 2 : parseInt(that.data.deviceloglist.length / 15) + 1 - wx.cloud.callFunction({ - name: 'devicelog', + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/listPage", data: { devcode: that.data.params.devcode, devtype: that.data.params.devtype, installtimeFmt: that.data.params.installtimeFmt, project: that.data.params.project, installPerson: that.data.params.installPerson, - url: app.globalData.url + "appDeviceLog/listPage", limit: 15, offset: offsetValue }, - }).then(res => { - if (res.result.data.rows.length > 0) { - var resultJson = res.result - that.setData({ - deviceloglist: that.data.deviceloglist.concat(resultJson.data.rows) - }) - } else if (that.data.deviceloglist.length > 0) { - that.setData({ - show: true, - total: that.data.deviceloglist.length - }) - wx.showToast({ - title: '数据已全部加载完', - icon: 'none', - duration: 2000 - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.data.rows.length > 0) { + var resultJson = res.data + var listArr = resultJson.data.rows + listArr.forEach(function (v, i) { + listArr[i]['isTouchMove'] = false + }) + that.setData({ + deviceloglist: that.data.deviceloglist.concat(listArr) + }) + } else if (that.data.deviceloglist.length > 0) { + that.setData({ + show: true, + total: that.data.deviceloglist.length + }) + wx.showToast({ + title: '数据已全部加载完', + icon: 'none', + duration: 2000 + }) + } + if (offsetValue == 1 && res.data.data.rows.length < 15) { + that.setData({ + show: true, + total: that.data.deviceloglist.length + }) + } } - if(offsetValue==1&&res.result.data.rows.length<15){ - that.setData({ - show: true, - total: that.data.deviceloglist.length - }) - } - // console.log(res); - }).catch(err => { - console.error(err); }) + }, addDetail: function (event) { - this.showLoading("数据请求中..."); - wx.cloud.callFunction({ - name: 'deviceDetail', + var that = this + that.showLoading("数据请求中..."); + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deviceDetail", data: { devcode: event.target.dataset.devcode, - url: app.globalData.url + "appDeviceLog/deviceDetail", }, - }).then(res => { - this.hideLoading(); - var resultObject = JSON.parse(res.result); - var pageName = '../applog/applog' - if (resultObject.code == 200) { - wx.navigateTo({ - url: '../addDevicelog/addDeviceLog?detail=' + - JSON.stringify(resultObject.data) + "&pageName=" + pageName - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + that.hideLoading(); + // var resultObject = JSON.parse(res.data); + var resultObject = res.data; + var pageName = '../applog/applog' + if (resultObject.code == 200) { + wx.setStorageSync('resultObject', resultObject.data) + wx.navigateTo({ + url: '../addDevicelog/addDeviceLog?detail=' + "&pageName=" + pageName + }) + } + }, + fail(err) { + that.hideLoading(); } - }).catch(err => { - this.hideLoading() }) + }, add: function (event) { - wx.reLaunch({ - url: '../earth/earth?devcode=' + event.target.dataset.devcode - // url: '../earth/earth' + app.globalData.devcode = event.target.dataset.devcode; + wx.switchTab({ + url: '../earth/earth' }) + // wx.reLaunch({ + // url: '../earth/earth?devcode=' + event.target.dataset.devcode + // // url: '../earth/earth' + // }) }, onSearch: function () { + var _this = this wx.navigateTo({ - url: '../searchLog/searchLog' + url: '../searchLog/searchLog?params=' + JSON.stringify(_this.data.params) }) - }, - // initPages: function () { - // wx.cloud.callFunction({ - // name: 'devicelog' - // }).then(res => { - // var that = this; - // var jsonList = JSON.parse(res.result) - // that.setData({ - // deviceloglist: jsonList.data.rows - // }) - // console.log(res); - // }).catch(err => { - // console.error(err); - // }) - // } + } }) \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.wxml b/miniprogram/pages/applog/applog.wxml index e9a2352..2bfd041 100644 --- a/miniprogram/pages/applog/applog.wxml +++ b/miniprogram/pages/applog/applog.wxml @@ -1,54 +1,59 @@ - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {{item.devcode}} {{item.devicetype}} + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + {{item.devcode}} {{item.devicetype}} + + {{item.project}} {{item.installtime}}- {{item.installperson}} - - - - - + + + + + + 删除 - - - + + - 共计:{{total}}台 - + 共计:{{total}}台 + \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.wxss b/miniprogram/pages/applog/applog.wxss index 6d3428b..e6e8983 100644 --- a/miniprogram/pages/applog/applog.wxss +++ b/miniprogram/pages/applog/applog.wxss @@ -22,16 +22,18 @@ position: fixed; width: 100%; top: 0rpx; + z-index: 9999; /* margin-bottom: 100rpx; */ } .log-list { /* height: 100rpx; */ - /* display: flex; */ - + display: flex; + width: 100%; padding: 2px; margin-top: 2px; border-bottom: 1px solid #e5e5e5; + overflow: hidden } @@ -53,23 +55,29 @@ left: 35%; margin: 20rpx } - .del { - width: 90px; + /* display: flex; */ + width: 100rpx; display: flex; flex-direction: column; align-items: center; justify-content: center; - color: #fff; - -webkit-transform: translateX(90px); - transform: translateX(90px); - -webkit-transition: all 0.4s; + /* -webkit-transform: translateX(100rpx); */ + transform: translateX(100rpx); + /* -webkit-transition: all 0.4s; */ transition: all 0.4s; - font-size: 35rpx; + color: #fff; + background-color: #fe3e2f; +} +.logrow{ + width: 100%; + transform: translateX(100rpx); + /* -webkit-transform: translateX(100px); */ + margin-left: -100rpx; } -.touch-move-active .content, +.touch-move-active .logrow, .touch-move-active .del { - -webkit-transform: translateX(0); - transform: translateX(0); +/* -webkit-transform: translateX(0); */ +transform: translateX(0); } \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.js b/miniprogram/pages/deployFunctions/deployFunctions.js deleted file mode 100644 index a76b144..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.js +++ /dev/null @@ -1,66 +0,0 @@ -// pages/deployFunctions/deployFunctions.js -Page({ - - /** - * 页面的初始数据 - */ - data: { - - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - - }, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { - - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - - }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { - - }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { - - } -}) \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.json b/miniprogram/pages/deployFunctions/deployFunctions.json deleted file mode 100644 index 7fbedab..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "navigationBarTitleText": "部署云函数", - "usingComponents": {} -} \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.wxml b/miniprogram/pages/deployFunctions/deployFunctions.wxml deleted file mode 100644 index 462b6b6..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.wxml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - 调用失败 - - - 请检查 login 云函数是否已部署 - - - - - 部署 login 云函数 - 1. 确保已通过工具栏云开发入口开通云开发 - 2. 在 cloudfunctions/login 目录上右键上传并部署 - 3. 回到首页,重新点击获取 openid - - - - diff --git a/miniprogram/pages/deployFunctions/deployFunctions.wxss b/miniprogram/pages/deployFunctions/deployFunctions.wxss deleted file mode 100644 index c8803e6..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.wxss +++ /dev/null @@ -1,7 +0,0 @@ -/* pages/deployFunctions/deployFunctions.wxss */ - -@import "../../style/guide.wxss"; - -.black { - color: black; -} \ No newline at end of file diff --git a/miniprogram/pages/earth/earth.js b/miniprogram/pages/earth/earth.js index ae0d3f3..376a6e2 100644 --- a/miniprogram/pages/earth/earth.js +++ b/miniprogram/pages/earth/earth.js @@ -21,19 +21,12 @@ show: false, enableSsatellite: false, windowWidth: 0, - longitude: 113.324520, - latitude: 23.099994, - longitude84: 113.324520, - latitude84: 23.099994, - markers: [{ - id: 0, - iconPath: "../../images/locat.png", - latitude: 23.099994, - longitude: 113.324520, - width: 50, - height: 50 - }], - controls: [], + longitude: "116.627340", + latitude: "39.874390", + longitude84: "", + latitude84: "", + markers: [], + controls: [] }, /** @@ -41,39 +34,13 @@ */ onLoad: function (options) { var that = this; - //获取当前坐标(gcj02) - wx.getLocation({ - type: "gcj02", - altitude: true, - success: function (res) { - that.setData({ - latitude: parseFloat(res.latitude).toFixed(6), - longitude: parseFloat(res.longitude).toFixed(6), - // markers: [{ - // latitude: res.latitude, - // longitude: res.longitude, - // }] - }) - //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 - wx.getLocation({ - type: "wgs84", - altitude: true, - success: function (res) { - that.setData({ - latitude84: parseFloat(res.latitude).toFixed(6), - longitude84: parseFloat(res.longitude).toFixed(6) - }) - } - }) - } - }), - - //设置地图组件 - wx.getSystemInfo({ + //设置地图组件 + wx.getSystemInfo({ success(res) { var windowWidth = res.windowWidth var windowHeight = res.windowHeight var query = wx.createSelectorQuery() + var platform =res.platform query.select('#map').boundingClientRect() query.exec(function (res) { that.setData({ @@ -139,10 +106,20 @@ clickable: true }, { id: 7, - iconPath: '../../images/locat.png', + iconPath: '../../images/applocat.png', position: { - left: res[0].width/2, - top: res[0].height/2, + left: res[0].width / 2 - 20, + top: platform=="ios"?res[0].height / 2 - 80:res[0].height / 2 - 40, + width: 40, + height: 40 + }, + clickable: true + }, { + id: 8, + iconPath: '../../images/back.png', + position: { + left: windowWidth - 40, + top: windowHeight - 140, width: 30, height: 30 }, @@ -150,71 +127,15 @@ }] }) }) - + } - }), + }) + // 实例化API核心类 qqmapsdk = new QQMapWX({ key: 'BGPBZ-C5O3P-ROUDR-LWC4J-63EKH-V5FRX' }) - - if (options.devcode) { - var that = this - var devcode = options.devcode - wx.cloud.callFunction({ - name: 'findListByCodes', - data: { - devcodes: devcode, - url: app.globalData.url + "appDeviceAdd/findListByCodes" - }, - }).then(res => { - if (res.result.code == 200) { - var listResultData = res.result.data; - that.setData({ - listData: listResultData - }) - var markersArr = that.data.markers; - for (var i = 0; i < listResultData.length; i++) { - markersArr = markersArr.concat({ - iconPath: "../../images/locat.png", - id: listResultData[i].id, - callout: { - content: listResultData[i].devcode, - fontSize: '14', - // padding: true, - color: '#00000', - borderColor: '#F4EA2A', - bgColor: '#F4EA2A', - borderWidth: 5, - display: 'ALWAYS', - textAlign: 'center', - // borderRadius: 15 - }, - latitude: listResultData[i].latitude, - longitude: listResultData[i].longitude, - width: 40, - height: 40 - }); - } - this.setData({ - markers: markersArr, - latitude: listResultData[0].latitude, - longitude: listResultData[0].longitude, - marker_latitude: listResultData[0].latitude, - marker_longitude: listResultData[0].longitude, - title: listResultData[0].devcode - }) - } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "无法获取设备地理信息!", - icon: 'none', - duration: 2000 - }) - }) - } }, /** @@ -228,6 +149,97 @@ * 生命周期函数--监听页面显示 */ onShow: function () { + //输入设备编号获取marker位置信息 + var that = this; + if ( app.globalData.devcode!="") { + var devcode = app.globalData.devcode + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/findListByCodes", + data: { + devcodes: devcode, + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + app.globalData.devcode=""; + if (res.data.code == 200) { + var listResultData = res.data.data; + that.setData({ + listData: listResultData + }) + var markersArr = that.data.markers; + for (var i = 0; i < listResultData.length; i++) { + markersArr = markersArr.concat({ + iconPath: "../../images/locat.png", + id: Number(listResultData[i].id), + callout: { + content: "编号:"+listResultData[i].devcode+"\r\n位置:"+listResultData[i].position+"\r\n时间:"+listResultData[i].createtime, + fontSize: '14', + padding: true, + color: '#000000', + borderColor: '#F4EA2A', + bgColor: '#F4EA2A', + borderWidth: 5, + display: 'ALWAYS', + textAlign: 'left', + // borderRadius: 15 + }, + latitude: listResultData[i].latitude, + longitude: listResultData[i].longitude, + width: 40, + height: 40 + }); + } + that.setData({ + markers: markersArr, + latitude: listResultData[0].latitude, + longitude: listResultData[0].longitude, + marker_latitude: listResultData[0].latitude, + marker_longitude: listResultData[0].longitude, + title: listResultData[0].devcode + }) + } + }, + fail(err) { + app.globalData.devcode=""; + wx.showToast({ + title: "无法获取设备地理信息!", + icon: 'none', + duration: 2000 + }) + } + }) +} else { + //获取当前坐标(gcj02) + wx.getLocation({ + type: "gcj02", + altitude: true, + success: function (res) { + that.setData({ + latitude: parseFloat(res.latitude).toFixed(6), + longitude: parseFloat(res.longitude).toFixed(6), + // markers: [{ + // latitude: res.latitude, + // longitude: res.longitude, + // }] + }) + //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 + wx.getLocation({ + type: "wgs84", + altitude: true, + success: function (res) { + that.setData({ + latitude84: parseFloat(res.latitude).toFixed(6), + longitude84: parseFloat(res.longitude).toFixed(6) + }) + } + }) + } + }) +} + }, @@ -265,12 +277,46 @@ onShareAppMessage: function () { }, + + //定位出来 + + locationPosition: function () { + var that = this; + //获取当前坐标(gcj02) + wx.getLocation({ + type: "gcj02", + altitude: true, + success: function (res) { + that.setData({ + latitude: parseFloat(res.latitude).toFixed(6), + longitude: parseFloat(res.longitude).toFixed(6), + // markers: [{ + // latitude: res.latitude, + // longitude: res.longitude + // }] + }) + //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 + wx.getLocation({ + type: "wgs84", + altitude: true, + success: function (res) { + that.setData({ + latitude84: parseFloat(res.latitude).toFixed(6), + longitude84: parseFloat(res.longitude).toFixed(6) + }) + } + }) + } + }) + }, + + //加载地图组件 controltap: function (e) { // console.log(e.controlId); //进入添加设备页 if (1 == e.controlId) { wx.setClipboardData({ - data: this.data.latitude + "," + this.data.longitude+ "," + this.data.latitude84+ "," + this.data.longitude84, + data: this.data.latitude + "," + this.data.longitude + "," + this.data.latitude84 + "," + this.data.longitude84, success: function (res) { wx.getClipboardData({ success: function (res) { @@ -282,6 +328,17 @@ } }) } else if (3 == e.controlId) { + //先定位 + // this.locationPosition() + wx.setClipboardData({ + data: this.data.latitude + "," + this.data.longitude + "," + this.data.latitude84 + "," + this.data.longitude84, + success: function (res) { + wx.showToast({ + title: '坐标已获取', + duration: 1000 + }) + } + }) wx.navigateTo({ url: '../addDevice/addDevice' }) @@ -302,32 +359,15 @@ enableSsatellite: !flag }); } else if (6 == e.controlId) { - var that = this; - //获取当前坐标(gcj02) - wx.getLocation({ - type: "gcj02", - altitude: true, - success: function (res) { - that.setData({ - latitude: parseFloat(res.latitude).toFixed(6), - longitude:parseFloat(res.longitude).toFixed(6), - // markers: [{ - // latitude: res.latitude, - // longitude: res.longitude - // }] - }) - //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 - wx.getLocation({ - type: "wgs84", - altitude: true, - success: function (res) { - that.setData({ - latitude84: parseFloat(res.latitude).toFixed(6), - longitude84: parseFloat(res.longitude).toFixed(6) - }) - } - }) - } + //先清marker + this.setData({ + markers: [] + }) + this.locationPosition() + }else if (8 == e.controlId) { + //跳转日志缓存页 + wx.switchTab({ + url: '../applog/applog', }) } }, @@ -343,63 +383,68 @@ }); }, + //获取设备maker leave() { var that = this; if (that.data.devcodes == "") { return false; } - wx.cloud.callFunction({ - name: 'findListByCodes', + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/findListByCodes", data: { - devcodes: that.data.devcodes, - url: app.globalData.url + "appDeviceAdd/findListByCodes" + devcodes: that.data.devcodes }, - }).then(res => { - if (res.result.code == 200) { - var listResultData = res.result.data; - that.setData({ - listData: listResultData - }) - var markersArr = that.data.markers; - for (var i = 0; i < listResultData.length; i++) { - markersArr = markersArr.concat({ - iconPath: "../../images/locat.png", - id: listResultData[i].id, - callout: { - content: listResultData[i].devcode, - fontSize: '14', - // padding: true, - color: '', - borderColor: '#F4EA2A', - bgColor: '#F4EA2A', - borderWidth: 5, - display: 'ALWAYS', - textAlign: 'center', - // borderRadius: 15 - }, - latitude: listResultData[i].latitude, - longitude: listResultData[i].longitude, - width: 40, - height: 40 - }); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var listResultData = res.data.data; + that.setData({ + listData: listResultData + }) + var markersArr = that.data.markers; + for (var i = 0; i < listResultData.length; i++) { + markersArr = markersArr.concat({ + iconPath: "../../images/locat.png", + id: listResultData[i].id, + callout: { + content: "编号:"+listResultData[i].devcode+"\r\n位置:"+listResultData[i].position+"\r\n时间:"+listResultData[i].createtime, + fontSize: '14', + // padding: true, + color: '#212121', + borderColor: '#F4EA2A', + bgColor: '#F4EA2A', + borderWidth: 5, + display: 'ALWAYS', + textAlign: 'left', + // borderRadius: 15 + }, + latitude: listResultData[i].latitude, + longitude: listResultData[i].longitude, + width: 40, + height: 40 + }); + } + that.setData({ + markers: markersArr, + latitude: listResultData[0].latitude, + longitude: listResultData[0].longitude, + marker_latitude: listResultData[0].latitude, + marker_longitude: listResultData[0].longitude, + title: listResultData[0].devcode + }) } - this.setData({ - markers: markersArr, - latitude: listResultData[0].latitude, - longitude: listResultData[0].longitude, - marker_latitude: listResultData[0].latitude, - marker_longitude: listResultData[0].longitude, - title: listResultData[0].devcode + }, + fail(err) { + wx.showToast({ + title: "无法获取设备地理信息!", + icon: 'none', + duration: 2000 }) } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "无法获取设备地理信息!", - icon: 'none', - duration: 2000 - }) }) }, @@ -422,6 +467,8 @@ } }, + + bindregionchange: function (e) { var that = this if (e.causedBy == "drag") { @@ -445,8 +492,8 @@ that.setData({ latitude: parseFloat(latitude).toFixed(6), longitude: parseFloat(longitude).toFixed(6), - latitude84:"", - longitude84:"", + latitude84: "", + longitude84: "", // markers: markersArr }) // mapCtx.moveToLocation(); @@ -465,16 +512,19 @@ qqmapsdk.search({ keyword: this.data.value, success: function (res) { + console.log(res) if (res && res.data) { _this.setData({ isShow: true, tips: res.data }); } + }, + complete: function (res){ + console.log(res); } }) }, - bindSearch: function (e) { var location = e.target.dataset.location; this.setData({ diff --git a/miniprogram/pages/earth/earth.wxml b/miniprogram/pages/earth/earth.wxml index a0db6ef..87474f8 100644 --- a/miniprogram/pages/earth/earth.wxml +++ b/miniprogram/pages/earth/earth.wxml @@ -1,9 +1,10 @@ + - + {{item.title}} {{item.address}} @@ -17,6 +18,6 @@ + placeholder="请输入定位设备编号用换行隔开" autosize border="{{ false }}" /> \ No newline at end of file diff --git a/miniprogram/pages/indexapp/indexapp.js b/miniprogram/pages/indexapp/indexapp.js index 5063372..849dbdb 100644 --- a/miniprogram/pages/indexapp/indexapp.js +++ b/miniprogram/pages/indexapp/indexapp.js @@ -7,9 +7,8 @@ */ data: { - count:1, - show: false, - onshow:true, + count: 1, + onshow: true, value: "", deviceloglist: [], devcode: "", @@ -21,6 +20,7 @@ // iconPath: "../../images/point.png", latitude: 23.099994, longitude: 113.324520, + label:'1', width: 50, height: 50 }], @@ -31,62 +31,26 @@ * 生命周期函数--监听页面加载 */ onLoad: function (options) { - + }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { - + }, /** * 生命周期函数--监听页面显示 */ onShow: function () { - // if( app.globalData.indexCount>1){ - // this.setData({ - // show:false - // }) - // }else{ - // this.showNotice() - // } - if(app.globalData.indexCount==1){ - this.setData({ - show:true - }) - this.showNotice() - } - app.globalData.indexCount+=1 - if(this.data.onshow){ + if (this.data.onshow) { this.initPages(); } }, - - showNotice: function() { - var that = this - var times = 0 - var i = setInterval(function() { - times++ - if (times >= 15) { - that.setData({ - show:false - }) - wx.showTabBar({ - animation: false, - }) - clearInterval(i) - } else { - wx.hideTabBar({ - animation: false, - }) - } - }, 1000) -}, - /** * 生命周期函数--监听页面隐藏 */ @@ -122,16 +86,27 @@ }, jump: function (event) { - var that = this; var latitude = event.target.dataset.pointLat; var longitude = event.target.dataset.pointLon; + let devcode = event.target.dataset.pointCode; that.setData({ latitude: latitude, longitude: longitude, markers: [{ latitude: latitude, - longitude: longitude + longitude: longitude, + callout: { + display:'ALWAYS',// 常显气泡 + content: devcode, //名称文本 + color: '#fff', //文本颜色 + borderRadius: 5, //边框圆角 + borderWidth: 1, //边框宽度 + borderColor: '#0060ff', //边框颜色 + bgColor: '#0060ff', //背景色 + padding: 5, //文本边缘留白 + textAlign: 'center' //文本对齐方式。有效值: left, right, center + } }] }) }, @@ -142,7 +117,7 @@ var devcode = res.result _this.setData({ devcode: devcode, - onshow:false + onshow: false }); _this.searchlogs(devcode) } @@ -151,40 +126,11 @@ onSearch: function (event) { this.setData({ - devcode:event.detail + devcode: event.detail }) this.searchlogs(event.detail) }, - - // bindregionchange: function (e) { - // var that = this - // if (e.causedBy == "drag") { - // var mapCtx = wx.createMapContext("map") - // mapCtx.getCenterLocation({ - // success: function (res) { - // var markersArr = that.data.markers - // for (var i = 0; i < markersArr.length; i++) { - // if (markersArr[i].iconPath == undefined) { - // markersArr.splice(i, 1) - // } - // } - // var latitude = res.latitude - // var longitude = res.longitude - // markersArr = markersArr.concat({ - // latitude: latitude, - // longitude: longitude - // }) - // that.setData({ - // latitude: latitude, - // longitude: longitude, - // markers: markersArr - // }) - // } - // }) - // } - // }, - showLoading: function (message) { if (wx.showLoading) { // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 @@ -211,81 +157,89 @@ } }, + //加载设备运维详细信息 toDetail: function (event) { - this.showLoading("数据加载中...") - wx.cloud.callFunction({ - name: 'deviceDetail', + var that = this + that.showLoading("数据加载中...") + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deviceDetail", data: { devcode: event.target.dataset.devcode, - url: app.globalData.url + "appDeviceLog/deviceDetail", }, - }).then(res => { - this.hideLoading(); - var resultObject = JSON.parse(res.result); - var pageName='../indexapp/indexapp' - if (resultObject.code == 200) { - wx.navigateTo({ - url: '../addDevicelog/addDeviceLog?detail=' + - JSON.stringify(resultObject.data)+'&pageName='+pageName - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + that.hideLoading(); + var resultObject = res.data; + var pageName = '../indexapp/indexapp' + if (resultObject.code == 200) { + wx.setStorageSync('resultObject', resultObject.data) + wx.navigateTo({ + url: '../addDevicelog/addDeviceLog?detail=' +'&pageName=' + pageName + }) + } + }, + fail(err){ + that.hideLoading(); } - }).catch(err => { - this.hideLoading(); }) }, + //加载列表 getlogs: function (devcode) { var that = this - wx.cloud.callFunction({ - name: 'devicelog', + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/listPage", data: { devcode: devcode, - url: app.globalData.url + "appDeviceLog/listPage", limit: 100, offset: that.data.deviceloglist.length % 100 > 0 ? parseInt(that.data.deviceloglist.length / 100) + 2 : parseInt(that.data.deviceloglist.length / 100) + 1 }, - }).then(res => { - if (res.result) { - // var resultJson = JSON.parse(res.result) - var resultJson = res.result - that.setData({ - deviceloglist: that.data.deviceloglist.concat(resultJson.data.rows) - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + // var resultJson = JSON.parse(res.result) + var resultJson = res.data + that.setData({ + deviceloglist: that.data.deviceloglist.concat(resultJson.data.rows) + }) + } } - console.log(res); - }).catch(err => { - console.error(err); }) }, + //查询列表 searchlogs: function (devcode) { var that = this - wx.cloud.callFunction({ - name: 'devicelog', + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/listPage", data: { devcode: devcode, - url: app.globalData.url + "appDeviceLog/listPage", limit: 100, offset: 1 }, - }).then(res => { - if (res.result) { - var resultJson = res.result - that.setData({ - deviceloglist: resultJson.data.rows, - onshow:true - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var resultJson = res.data + that.setData({ + deviceloglist: resultJson.data.rows, + onshow: true + }) + } } - console.log(res); - }).catch(err => { - console.error(err); }) }, initPages: function () { var that = this; - that.setData({ - devcode: "" - }); wx.getLocation({ type: "gcj02", success: function (res) { @@ -302,6 +256,6 @@ }) } }) - this.searchlogs() + this.data.devcode !== '' ? this.searchlogs(this.data.devcode) : this.searchlogs() }, }) \ No newline at end of file diff --git a/miniprogram/pages/indexapp/indexapp.wxml b/miniprogram/pages/indexapp/indexapp.wxml index 69322a0..f65b082 100644 --- a/miniprogram/pages/indexapp/indexapp.wxml +++ b/miniprogram/pages/indexapp/indexapp.wxml @@ -1,8 +1,12 @@ + + + + - @@ -32,9 +36,15 @@ - + + + + + + + @@ -46,14 +56,14 @@ - + - - + diff --git a/miniprogram/pages/indexapp/indexapp.wxss b/miniprogram/pages/indexapp/indexapp.wxss index b18706a..fc27fcb 100644 --- a/miniprogram/pages/indexapp/indexapp.wxss +++ b/miniprogram/pages/indexapp/indexapp.wxss @@ -128,6 +128,7 @@ .noticeClass{ height: 2300rpx; width: 750rpx; + overflow-y:hidden; } @@ -148,14 +149,14 @@ } +/* .vanstyle{ + button: not([size='mini']) { + user agent stylesheetmin-height: 40px; + width: 650rpx; + margin-left: 20rpx; + margin-right: auto; + + } + +} */ -/* .van-enter-active-class, -.van-leave-active-class { - transition-property: background-color, transform; -} - -.van-enter-class, -.van-leave-to-class { - background-color: red; - transform: rotate(-360deg) translate3d(-100%, -100%, 0); -} */ \ No newline at end of file diff --git a/miniprogram/pages/log/log.js b/miniprogram/pages/log/log.js deleted file mode 100644 index 83ba349..0000000 --- a/miniprogram/pages/log/log.js +++ /dev/null @@ -1,66 +0,0 @@ -// pages/log/log.js -Page({ - - /** - * 页面的初始数据 - */ - data: { - - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - - }, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { - - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - - }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { - - }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { - - } -}) \ No newline at end of file diff --git a/miniprogram/pages/log/log.json b/miniprogram/pages/log/log.json deleted file mode 100644 index 8835af0..0000000 --- a/miniprogram/pages/log/log.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "usingComponents": {} -} \ No newline at end of file diff --git a/miniprogram/pages/log/log.wxml b/miniprogram/pages/log/log.wxml deleted file mode 100644 index a510ad6..0000000 --- a/miniprogram/pages/log/log.wxml +++ /dev/null @@ -1,2 +0,0 @@ - -pages/log/log.wxml diff --git a/miniprogram/pages/log/log.wxss b/miniprogram/pages/log/log.wxss deleted file mode 100644 index 23db318..0000000 --- a/miniprogram/pages/log/log.wxss +++ /dev/null @@ -1 +0,0 @@ -/* pages/log/log.wxss */ \ No newline at end of file diff --git a/miniprogram/pages/login/login.js b/miniprogram/pages/login/login.js index a4074e7..cb0542a 100644 --- a/miniprogram/pages/login/login.js +++ b/miniprogram/pages/login/login.js @@ -1,11 +1,14 @@ // miniprogram/pages/login/login.js +var app = getApp() Page({ /** * 页面的初始数据 */ data: { - windowWidth:"" + windowWidth: "", + time: 15 * 1000, + showTime: false }, /** @@ -20,9 +23,9 @@ */ onReady: function () { this.setData({ - windowWidth:wx.getSystemInfoSync().windowWidth + windowWidth: wx.getSystemInfoSync().windowWidth }) - + }, /** @@ -66,14 +69,158 @@ onShareAppMessage: function () { }, + + + showLoading: function (message) { + if (wx.showLoading) { + // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 + wx.showLoading({ + title: message, + mask: true + }); + } else { + // 低版本采用Toast兼容处理并将时间设为20秒以免自动消失 + wx.showToast({ + title: message, + icon: 'loading', + mask: true, + duration: 20000 + }); + } + }, + hideLoading: function () { + if (wx.hideLoading) { + // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 + wx.hideLoading(); + } else { + wx.hideToast(); + } + }, + + //注册 loginClick: function () { + var that = this + that.showLoading("授权中...") + wx.login({ + success: function (res) { + if (res.code) { + wx.request({ + url: app.globalData.httpsUrl + "appUserOpenid/login", + data: { + code: res.code + }, + success: function (res) { + app.globalData.openid = res.data.data + wx.getUserInfo({ + success: (res) => { + var nickname = res.userInfo.nickName; + app.globalData.nickName = nickname; + //openid绑定昵称存入后台 + wx.request({ + url: app.globalData.httpsUrl + "appUserOpenid/add", + data: { + attr: nickname, + openid: app.globalData.openid + }, + success: function (res) { + that.hideLoading(); + wx.showToast({ + title: res.data.data+",\r\n请从正式版入口登录!", + icon: 'none', + duration: 2000 + }) - wx.navigateTo({ - - url: '../farmermain/farmermain', - + // //授权成功后跳转 + // wx.switchTab({ + // url: '../indexapp/indexapp' + // }) + } + }) + }, + fail: function (err) { + that.hideLoading(); + } + }) + }, + fail: function (res) { + that.hideLoading(); + wx.showToast({ + title: '服务器异常', + }) + } + }) + } + }, + fail: function (res) { + that.hideLoading(); + } }) + }, + //登录验证 + loginValidate: function () { + var that = this + that.showLoading("登录中...") + wx.login({ + success: function (res) { + if (res.code) { + console.info(res); + wx.request({ + url: app.globalData.httpsUrl + "appUserOpenid/login", + data: { + code: res.code + }, + success: function (res) { + app.globalData.openid = res.data.data + wx.request({ + url: app.globalData.httpsUrl + "appUserOpenid/validate", + data: { + openid: app.globalData.openid + }, + success: function (res) { + that.hideLoading(); + if (res.data.data) { + app.globalData.userName = res.data.data.attr1 == '' ? res.data.data.attr : res.data.data.attr1 + app.globalData.nickName = res.data.data.attr + app.globalData.role = res.data.data.role + wx.navigateTo({ + url: '../notice/notice' + }) + } else { + wx.showToast({ + icon: 'none', + title: '请联系管理员授权', + duration: 2000 + }) + } + }, + fail: function (err) { + that.hideLoading(); + wx.showToast({ + title: '验证失败', + }) + } + }) + }, + fail: function (res) { + that.hideLoading(); + wx.showToast({ + title: '服务器异常', + }) + } + }) + } + }, + fail: function (res) { + that.hideLoading(); + } + }) + }, + + finished() { + this.setData({ + showTime: true + }) }, onClickSubmit: function () { diff --git a/miniprogram/pages/login/login.json b/miniprogram/pages/login/login.json index 8835af0..f2043a3 100644 --- a/miniprogram/pages/login/login.json +++ b/miniprogram/pages/login/login.json @@ -1,3 +1,8 @@ { - "usingComponents": {} + "usingComponents": { + "van-count-down": "../../miniprogram_npm/@vant/weapp/count-down", + "van-button": "../../miniprogram_npm/@vant/weapp/button" + }, + "navigationBarBackgroundColor": "#E6D480", + "disableScroll":true } \ No newline at end of file diff --git a/cloudfunctions/project.config.json b/cloudfunctions/project.config.json new file mode 100644 index 0000000..2b3119a --- /dev/null +++ b/cloudfunctions/project.config.json @@ -0,0 +1,28 @@ +{ + "appid": "wx2cef527a000f87c9", + "compileType": "miniprogram", + "libVersion": "2.27.3", + "packOptions": { + "ignore": [], + "include": [] + }, + "setting": { + "coverView": true, + "es6": true, + "postcss": true, + "minified": true, + "enhance": true, + "showShadowRootInWxmlPanel": true, + "packNpmRelationList": [], + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + } + }, + "condition": {}, + "editorSetting": { + "tabIndent": "insertSpaces", + "tabSize": 4 + } +} \ No newline at end of file diff --git a/cloudfunctions/project.private.config.json b/cloudfunctions/project.private.config.json new file mode 100644 index 0000000..42ff49d --- /dev/null +++ b/cloudfunctions/project.private.config.json @@ -0,0 +1,7 @@ +{ + "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", + "projectname": "cloudfunctions", + "setting": { + "compileHotReLoad": true + } +} \ No newline at end of file diff --git a/miniprogram/app.js b/miniprogram/app.js index 51d56f3..50a8a54 100644 --- a/miniprogram/app.js +++ b/miniprogram/app.js @@ -18,13 +18,15 @@ // this.globalData = {} }, globalData: { - // url: "http://111.198.10.15:11604/", - httpsUrl: "https://logapi.smartlog.work/", - httpsTestUrl: "https://smartlog.work/prodapi4test/", - url: "http://139.198.18.188:8083/", + httpsUrl: "https://logapi.smartlog.work/", + // httpsUrl: "http://139.198.18.188:8083/", // url: "http://127.0.0.1:8083/", - // httpsUrl: "http://127.0.0.1:8083/", + //httpsUrl: "http://127.0.0.1:8083/", openid: null, - indexCount:1 - }, + indexCount:1, + nickName:"", + userName:"", + role:"", + devcode:"" + } }) diff --git a/miniprogram/app.json b/miniprogram/app.json index d23f798..2b6db76 100644 --- a/miniprogram/app.json +++ b/miniprogram/app.json @@ -1,15 +1,17 @@ { "cloud": true, "pages": [ + "pages/login/login", "pages/indexapp/indexapp", "pages/earth/earth", "pages/applog/applog", "pages/addDevice/addDevice", "pages/addDevicelog/addDeviceLog", - "pages/searchLog/searchLog" + "pages/searchLog/searchLog", + "pages/notice/notice" ], "window": { - "backgroundColor": "#F6F6F6", + "backgroundColor": "#E6D480", "backgroundTextStyle": "light", "navigationBarBackgroundColor": "#FFCF00", "navigationBarTitleText": "智慧施工", @@ -46,11 +48,11 @@ "desc": "你的位置信息将用于小程序位置接口的效果展示" } }, + "requiredPrivateInfos": ["getLocation", "chooseLocation"], "networkTimeout": { "request": 30000, "connectSocket": 30000, "uploadFile": 30000, "downloadFile": 30000 - }, - "style": "v2" + } } \ No newline at end of file diff --git a/miniprogram/images/applocat.png b/miniprogram/images/applocat.png new file mode 100644 index 0000000..fe49f54 --- /dev/null +++ b/miniprogram/images/applocat.png Binary files differ diff --git a/miniprogram/images/back.png b/miniprogram/images/back.png new file mode 100644 index 0000000..32ac82d --- /dev/null +++ b/miniprogram/images/back.png Binary files differ diff --git a/miniprogram/images/bottom.png b/miniprogram/images/bottom.png new file mode 100644 index 0000000..d910e98 --- /dev/null +++ b/miniprogram/images/bottom.png Binary files differ diff --git a/miniprogram/images/header.png b/miniprogram/images/header.png new file mode 100644 index 0000000..6ea222e --- /dev/null +++ b/miniprogram/images/header.png Binary files differ diff --git a/miniprogram/images/login.png b/miniprogram/images/login.png index 8b73cc0..6471c46 100644 --- a/miniprogram/images/login.png +++ b/miniprogram/images/login.png Binary files differ diff --git a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss index 5a591fb..c9c35b5 100644 --- a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss +++ b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:100%;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:100%}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file +@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:650rpx;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:600rpx}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file diff --git a/miniprogram/pages/addDevice/addDevice.js b/miniprogram/pages/addDevice/addDevice.js index 2783674..78f00b7 100644 --- a/miniprogram/pages/addDevice/addDevice.js +++ b/miniprogram/pages/addDevice/addDevice.js @@ -1,5 +1,7 @@ // miniprogram/pages/addDevice/addDevice.js // import WxValidate from '../../utils/WxValidate.js' +var QQMapWX = require('../../libs/qqmap-wx-jssdk.js'); +var qqmapsdk; var app = getApp() Page({ @@ -11,32 +13,10 @@ canvasWidth: '', longitude: '', latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], + option1: [], personoption1: [], projectoption: [], + devtypeList:[], show: false, form: { devcode: "", @@ -59,7 +39,10 @@ project: "", area: "", street: "", - wellname: "" + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '', }, fileList: [] }, @@ -117,12 +100,14 @@ var that = this; //初始化表单内容为上次填写值 var cacheForms = wx.getStorageSync('cacheList') - if (cacheForms) { + cacheForms.photopath1='' + cacheForms.photopath2='' + cacheForms.photopath3='' + that.data.fileList=[] that.setData({ form: cacheForms, devcode: cacheForms.devcode, - }) } var form = that.data.form @@ -155,55 +140,89 @@ } }) + +//获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + that.setData({ + option1: welltypeArr + }) + } + } +}) + + //获取人员下拉列表 - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/getUser", + data:{ + tips:'repair' }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data.code == 200) { + var users = res.data.data + var personArr = []; + for (var i = 0; i < users.length; i++) { + var person = { + text: users[i].name, + value: users[i].name + }; + personArr.push(person); + } + that.setData({ + personoption1: personArr + }) } - that.setData({ - personoption1: personArr - }) } - }).catch(err => { - console.error(err); - }) + }) + - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - that.setData({ - projectoption: projectArr - }) + success(res){ + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); + } + that.setData({ + projectoption: projectArr + }) + } } - }).catch(err => { - console.error(err); - }) + }) + var installtime = 'form.installtimeFmt'; var dateNow = this.formatDate(); this.setData({ @@ -211,8 +230,40 @@ installtimeFmt: dateNow, [installtime]: dateNow, }); + + + + /** + * 获取设备类型下拉列表 + */ + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/deviceType", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var TypeList = res.data.data + var typeArr = []; + for (var i = 0; i < TypeList.length; i++) { + var type = { + text: TypeList[i].productName, + value: TypeList[i].productName + }; + typeArr.push(type); + } + that.setData({ + devtypeList: typeArr + }) + } + } + }) }, + + + /** * 生命周期函数--监听页面初次渲染完成 */ @@ -280,29 +331,7 @@ }, - - //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 - drawText: function (ctx, str, leftWidth, initHeight, titleHeight, canvasWidth) { - var lineWidth = 0; - var lastSubStrIndex = 0; //每次开始截取的字符串的索引 - for (let i = 0; i < str.length; i++) { - lineWidth += ctx.measureText(str[i]).width; - if (lineWidth > canvasWidth) { - ctx.fillText(str.substring(lastSubStrIndex, i), leftWidth, initHeight); //绘制截取部分 - initHeight = initHeight + leftWidth * 2; //22为字体的高度 - lineWidth = 0; - lastSubStrIndex = i; - // titleHeight += 40; - } - if (i == str.length - 1) { //绘制剩余部分 - ctx.fillText(str.substring(lastSubStrIndex, i + 1), leftWidth, initHeight); - } - } - // // 标题border-bottom 线距顶部距离 - // titleHeight = titleHeight + 10; - // return titleHeight - }, - + //验证表单 formValidate() { if (this.data.form.devcode == "") { @@ -312,27 +341,20 @@ }) return false } - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } if (this.data.form.wellcode == "") { wx.showToast({ icon: 'none', @@ -348,22 +370,10 @@ }) return false } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null) { + + if (this.data.form.installperson == "") { wx.showToast({ icon: 'none', title: '安装人员不能为空!', @@ -408,56 +418,90 @@ } return true; }, + //提交表单 formSubmit: function (event) { + console.log(this.data.form) + //表单参数验证 if (!this.formValidate()) { return false; } var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDevice', + //验证设备编号长度 + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/getDevTypeLength", data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceAdd/add" + code: encodeURI(this.data.form.devicetype) }, - }).then(res => { - if (res.result.code == 500) { - wx.showToast({ - title: '设备编号已安装!', - }) - } else if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - //用于回显 - wx.setStorageSync('cacheList', that.data.form) - //提交成功后提示用户操作 - if (res.confirm) { - wx.switchTab({ - url: '../earth/earth' - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (""==res.data.data ||res.data.data == that.data.form.devcode.length) { + that.saveDevice() + } else { //编号位数不对提示 + wx.showToast({ + icon: 'none', + title: '设备编号位数不对!', + duration: 1000 + }) + return false + } } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "提交失败", - }) }) }, + + //保存设备基本信息 + saveDevice() { + var that = this; + //设置照片路径 + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopathForm = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopathForm]: fileList[i].url.split("static/")[1] + }) + } + //表单提交 + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 500) { + wx.showToast({ + title: '设备编号已安装!', + }) + } else if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + //用于回显 + wx.setStorageSync('cacheList', that.data.form) + //提交成功后提示用户操作 + if (res.confirm) { + wx.switchTab({ + url: '../earth/earth' + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } + }, + fail(err) { + wx.showToast({ + title: '提交失败!', + }) + } + }) + }, + + //input 输入框设置值 confirm(event) { var that = this; var formValue = event.detail.value; @@ -466,8 +510,30 @@ that.setData({ [fromN]: formValue }) + //若输入是设备编号,自动获取设备类型 + if('devcode'==formName){ + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", + data: { + devcode: formValue, + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + that.setData({ + [formDevicetype]: res.data + }); + } + } + }) + } }, + //扫描设备获取编号和设备类型 scan() { var _this = this; wx.scanCode({ @@ -477,23 +543,28 @@ _this.setData({ [formdevcode]: devcode }); - wx.cloud.callFunction({ - name: 'findModeCode', + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", data: { devcode: devcode, - url: app.globalData.url + "appDeviceAdd/findModeCodeByCode" }, - }).then(res => { - if (res.result) { - var formDevicetype = 'form.devicetype' - _this.setData({ - [formDevicetype]: res.result - }); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + _this.setData({ + [formDevicetype]: res.data + }); + } } }) } }) }, + //粘贴经纬度 paste() { var _this = this; wx.getClipboardData({ @@ -510,9 +581,11 @@ longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), }); + _this.showAddress(_this.data.form.longitude,_this.data.form.latitude,_this) } }) }, + //设置经类型 selectValue(value) { var that = this; @@ -521,6 +594,16 @@ [wellType]: value.detail }) }, + + //设置设备类型 + selectDevType(event) { + var that = this; + var devtype = 'form.devicetype'; + that.setData({ + [devtype]: event.detail + }) + }, + //设置运维人员 selectpersonValue(event) { var that = this; var installPerson = 'form.installperson'; @@ -528,6 +611,7 @@ [installPerson]: event.detail }) }, + //设置项目 selectprojectValue(event) { var that = this; var project = 'form.project'; @@ -535,8 +619,41 @@ [project]: event.detail }) }, + showAddress :function(longitude, latitude, self) { + // 实例化腾讯地图API核心类 + qqmapsdk = new QQMapWX({ + key: 'BGPBZ-C5O3P-ROUDR-LWC4J-63EKH-V5FRX'//此处使用你自己申请的key + }) + // 腾讯地图调用接口 + qqmapsdk.reverseGeocoder({ + location: { + latitude: latitude, + longitude: longitude + }, + success: function (res) { + self.setData({ + 'form.area':res.result.address.slice(0,res.result.address.indexOf('区')+1), + 'form.street':res.result.address.slice(res.result.address.indexOf('区')+1) + }) + }, + fail: function (res) { + console.log(res); + }, + complete: function (res) { + } + }); + }, + //上传照片 afterRead(event) { var _this = this; + if (_this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '请先填写设备编号!\r\n否则水印中无编号', + duration: 2000 + }) + return false + } const { file } = event.detail; @@ -576,78 +693,8 @@ }) } }) - // 压缩图片 - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // //获取图片尺寸 - // wx.getImageInfo({ - // src: convertpath, - // success(res) { - // _this.setData({ - // canvasHeight: res.height, - // canvasWidth: res.width - // }) - // var ctx = wx.createCanvasContext('firstCanvas') - - // //将图片src放到cancas内,宽高为图片大小 - // ctx.drawImage(convertpath, 0, 0, res.width, res.height) - // //将声明的时间放入canvas - // ctx.setFontSize(30 * (res.width / 750)) //注意:设置文字大小必须放在填充文字之前,否则不生效 - // ctx.setFillStyle('blue') - // var text = "编号:" + _this.data.form.devcode + "\n经度:" + _this.data.form.longitude + "\n纬度:" + _this.data.form.latitude - // // _this.drawText(ctx,text,20, 70, 5, res.width) - // _this.drawText(ctx, text, 15 * (res.width / 750), 70 * (res.width / 750), 5, res.width) - - // // ctx.fillText(text, 0, 40) - // // ctx.strokeText(_this.data.form.devcode, 0, 30) - // //生成水印图 - // ctx.draw(false, function () { - // wx.canvasToTempFilePath({ - // canvasId: 'firstCanvas', - // success: (res) => { - // wx.compressImage({ - // src: res.tempFilePath, - // quality: 25, - // success: function (res) { - // //上传照片至服务器 - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: res.tempFilePath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // } - // }) - // //// - // } - // }) - // }) - // } - // }) - // } - // }); }, + //删除照片 deletePhoto(event) { var image_index = event.detail.index var fileList_new = this.data.fileList; diff --git a/miniprogram/pages/addDevice/addDevice.wxml b/miniprogram/pages/addDevice/addDevice.wxml index b0977e2..f12c254 100644 --- a/miniprogram/pages/addDevice/addDevice.wxml +++ b/miniprogram/pages/addDevice/addDevice.wxml @@ -5,18 +5,30 @@ - + + + + + + + + + + + + + - - + + - - - + + + @@ -29,13 +41,13 @@ - + - + - + - + @@ -54,8 +66,7 @@ - - + @@ -68,8 +79,8 @@ - - + + - 保存 + 保存 \ No newline at end of file diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.js b/miniprogram/pages/addDevicelog/addDeviceLog.js index cdec71b..a0dc6da 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.js +++ b/miniprogram/pages/addDevicelog/addDeviceLog.js @@ -3,681 +3,665 @@ var app = getApp(); Page({ - /** - * 页面的初始数据 - */ - data: { - pageName: '', - showMask: false, - today: new Date().getTime(), - longitude: '', - latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], - personoption1: [], - projectoption: [], - devcode: "", - deviceMode: "", - installtimeFmt: '', - show: false, - form: { - devcode: "", - wellcode: "", - welltype: "", - welldepth: "", - installheigt: "", - installperson: "", - installtimeFmt: "", - photopath: "", - factory: "", - workmsg: "", - position: "", - description: "", - longitude: "", - latitude: "", - longitude84: "", - latitude84: "", - devicetype: "", - project: "", - area: "", - street: "", - wellname: "" - }, - fileList: [], - detail: "" - }, + /** + * 页面的初始数据 + */ + data: { + pageName: '', + showMask: false, + today: new Date().getTime(), + longitude: '', + latitude: '', + option1: [], + personoption1: [], + projectoption: [], + devcode: "", + deviceMode: "", + installtimeFmt: '', + show: false, + form: { + devcode: "", + wellcode: "", + welltype: "", + welldepth: "", + installheigt: "", + installperson: "", + installtimeFmt: "", + photopath: "", + factory: "", + workmsg: "", + position: "", + description: "", + longitude: "", + latitude: "", + longitude84: "", + latitude84: "", + devicetype: "", + project: "", + area: "", + street: "", + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '' + }, + fileList: [], + detail: "", + markers: [{ + id: 100, + // iconPath: "../../images/point.png", + latitude: '', + longitude: '', + // label:'1', + width: 25, + height: 35 + }], + }, - onDisplay() { - this.setData({ - show: true - }); - }, - onClose() { - this.setData({ - show: false - }); - }, - formatDate() { - var date = new Date(); - // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; - var seperator1 = "-"; - var month = date.getMonth() + 1; - var strDate = date.getDate(); - var hour = date.getHours() - var minute = date.getMinutes() - var second = date.getSeconds() - month = month > 9 ? month : "0" + month; - strDate = strDate > 9 ? strDate : "0" + strDate; - hour = hour > 9 ? hour : "0" + hour; - minute = minute > 9 ? minute : "0" + minute; - second = second > 9 ? second : "0" + second; - var currentdate = - date.getFullYear() + - seperator1 + - month + - seperator1 + - strDate + - " " + - hour + ":" + - minute + ":" + - second; - return currentdate; + onDisplay() { + this.setData({ + show: true + }); + }, + onClose() { + this.setData({ + show: false + }); + }, + formatDate() { + var date = new Date(); + // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; + var seperator1 = "-"; + var month = date.getMonth() + 1; + var strDate = date.getDate(); + var hour = date.getHours() + var minute = date.getMinutes() + var second = date.getSeconds() + month = month > 9 ? month : "0" + month; + strDate = strDate > 9 ? strDate : "0" + strDate; + hour = hour > 9 ? hour : "0" + hour; + minute = minute > 9 ? minute : "0" + minute; + second = second > 9 ? second : "0" + second; + var currentdate = + date.getFullYear() + + seperator1 + + month + + seperator1 + + strDate + + " " + + hour + ":" + + minute + ":" + + second; + return currentdate; - }, - onConfirm(event) { - var installtime = 'form.installtimeFmt'; - this.setData({ - show: false, - installtimeFmt: this.formatDate(event.detail), - [installtime]: this.formatDate(event.detail), - }); - }, + }, + onConfirm(event) { + var installtime = 'form.installtimeFmt'; + this.setData({ + show: false, + installtimeFmt: this.formatDate(event.detail), + [installtime]: this.formatDate(event.detail), + }); + }, - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - var _this = this; - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" - }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); - } - _this.setData({ - personoption1: personArr - }) + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + var _this = this; + _this.setData({ + 'markers[0].latitude': Number(wx.getStorageSync('resultObject').latitude) , + 'markers[0].longitude': Number(wx.getStorageSync('resultObject').longitude), + // 'markers[0].label':'10', + 'markers[0].width': 18, + 'markers[0].id':1, + 'markers[0].height': 30, + latitude:Number(wx.getStorageSync('resultObject').latitude), + longitude:Number(wx.getStorageSync('resultObject').longitude) + }) + //获取人员下拉列表 + // wx.request({ + // method: "POST", + // url: app.globalData.httpsUrl + "deviceType/getUser", + // data:{ + // tips:'repair' + // }, + // header: { + // 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + // }, + // success(res) { + // if (res.data.code == 200) { + // var users = res.data.data + // var personArr = []; + // for (var i = 0; i < users.length; i++) { + // var person = { + // text: users[i].name, + // value: users[i].name + // }; + // personArr.push(person); + // } + // _this.setData({ + // personoption1: personArr + // }) + // } + // } + // }) + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); } - }).catch(err => { - console.error(err); - }) - - - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" - }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - _this.setData({ - projectoption: projectArr - }) - } - }).catch(err => { - console.error(err); - }) - - if (options.pageName) { - this.setData({ - pageName: options.pageName - }) - } - - if (options.detail) { - - var formObject = JSON.parse(options.detail); _this.setData({ - form: formObject, - detail: options.detail + projectoption: projectArr }) - - _this.setData({ - ['form.installperson']: "", - ['form.installtimeFmt']: "", - ['form.workmsg']: "", - ['form.description']: "" - }) - - const { - fileList = [] - } = _this.data; - if (formObject.photopath1 != "") { - var file1 = { - url: app.globalData.url + "static/" + formObject.photopath1 - } - fileList.push(file1) - } - if (formObject.photopath2 != "") { - var file2 = { - url: app.globalData.url + "static/" + formObject.photopath2 - } - fileList.push(file2) - } - if (formObject.photopath3 != "") { - var file3 = { - url: app.globalData.url + "static/" + formObject.photopath3 - } - fileList.push(file3) - } - - _this.setData({ - fileList - }); } - var installtime = 'form.installtimeFmt'; - var dateNow = this.formatDate(); - this.setData({ - installtimeFmt: dateNow, - [installtime]: dateNow, - }); - }, + } + }) - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { + //获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + _this.setData({ + option1: welltypeArr + }) + } + } +}) - }, + //跳转时带入参数返回哪页 + if (options.pageName) { + this.setData({ + pageName: options.pageName + }) + } + //跳转时带入参数设备的安装信息 + if (wx.getStorageSync('resultObject')) { + var formObject = wx.getStorageSync('resultObject') + _this.setData({ + form: formObject, + detail: formObject + }) - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { + _this.setData({ + ['form.installperson']: app.globalData.userName, + ['form.installtimeFmt']: "", + ['form.workmsg']: "", + ['form.description']: "" + }) - }, + const { + fileList = [] + } = _this.data; + if (formObject.photopath1 != "") { + var file1 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath1 + } + fileList.push(file1) + } + if (formObject.photopath2 != "") { + var file2 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath2 + } + fileList.push(file2) + } + if (formObject.photopath3 != "") { + var file3 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath3 + } + fileList.push(file3) + } + _this.setData({ + fileList + }); + } + var installtime = 'form.installtimeFmt'; + var dateNow = this.formatDate(); + this.setData({ + installtimeFmt: dateNow, + [installtime]: dateNow, + }); + }, - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, - }, + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + wx.removeStorageSync('resultObject') + }, - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, - }, + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { + }, - }, + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { + }, - }, + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { + }, - }, + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + }, - /** - * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true - **/ + /** + * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true + **/ - isNumber: function (val) { + isNumber: function (val) { - var regPos = /^[0-9]*$/; //非负浮点数 - var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数 - if (regPos.test(val) || regNeg.test(val)) { - return false; - } else { - return true; - } + var regPos = /^[0-9]*$/; //非负浮点数 + var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数 + if (regPos.test(val) || regNeg.test(val)) { + return false; + } else { + return true; + } - }, + }, - formValidate() { + formValidate() { - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } - if (this.data.form.wellcode == "") { - wx.showToast({ - icon: 'none', - title: '井编号不能为空!', - }) - return false - } - if (this.data.form.devicetype == "") { - wx.showToast({ - icon: 'none', - title: '设备类型不能为空!', - }) - return false - } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + if (this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '设备编号不能为空!', + }) + return false + } + if (this.data.form.wellcode == "") { + wx.showToast({ + icon: 'none', + title: '井编号不能为空!', + }) + return false + } + if (this.data.form.devicetype == "") { + wx.showToast({ + icon: 'none', + title: '设备类型不能为空!', + }) + return false + } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null || - this.data.form.installperson == '') { - wx.showToast({ - icon: 'none', - title: '运维人员不能为空!', - }) - return false - } - if (this.data.form.project == "") { - wx.showToast({ - icon: 'none', - title: '所属项目不能为空!', - }) - return false - } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } + if (this.data.form.installperson == null || + this.data.form.installperson == '') { + wx.showToast({ + icon: 'none', + title: '运维人员不能为空!', + }) + return false + } + if (this.data.form.project == "") { + wx.showToast({ + icon: 'none', + title: '所属项目不能为空!', + }) + return false + } - if (this.data.form.welldepth != null) { - if (this.isNumber(this.data.form.welldepth)) { - wx.showToast({ - icon: 'none', - title: '井深必须为数值!', - }) - return false - } - } - if (this.data.form.installheigt != null) { - if (this.isNumber(this.data.form.installheigt)) { - wx.showToast({ - icon: 'none', - title: '到井口距离必须为数值!', - }) - return false - } - } - - return true; - }, - - changeMsg: function () { - var formNew = this.data.form; - var formOld = JSON.parse(this.data.detail); - var descpNew = ""; - if (formNew.devcode != formOld.devcode) { - descpNew += "修改设备编号,原编号:" + formOld.devcode + ",新编号:" + formNew.devcode + ";" - } - if (formNew.devicetype != formOld.devicetype) { - descpNew += "修改设备类型,原设备类型:" + formOld.devicetype + ",新设备类型:" + formNew.devicetype + ";" - } - if (formNew.area != formOld.area) { - descpNew += "修改区,原区:" + formOld.area + ",新区:" + formNew.area + ";" - } - if (formNew.street != formOld.street) { - descpNew += "修改街道,原街道:" + formOld.street + ",新街道:" + formNew.street + ";" - } - if (formNew.wellname != formOld.wellname) { - descpNew += "修改井名称,原井名称:" + formOld.wellname + ",新井名称:" + formNew.wellname + ";" - } - if (formNew.factory != formOld.factory) { - descpNew += "修改权属单位,原权属单位:" + formOld.factory + ",新权属单位:" + formNew.factory + ";" - } - if (formNew.installheigt != formOld.installheigt) { - descpNew += "修改井口距离,原井口距离:" + formOld.installheigt + ",新井口距离:" + formNew.installheigt + ";" - } - if (formNew.installperson != formOld.installperson) { - descpNew += "修改运维人员,原运维人员:" + formOld.installperson + ",新运维人员:" + formNew.installperson + ";" - } - if (formNew.latitude != formOld.latitude) { - descpNew += "修改纬度,原纬度:" + formOld.latitude + ",新纬度:" + formNew.latitude + ";" - } - if (formNew.longitude != formOld.longitude) { - descpNew += "修改经度,原经度:" + formOld.longitude + ",新经度:" + formNew.longitude + ";" - } - if (formNew.position != formOld.position) { - descpNew += "修改位置描述,原位置:" + formOld.position + ",新位置:" + formNew.position + ";" - } - if (formNew.wellcode != formOld.wellcode) { - descpNew += "修改井编号,原编号:" + formOld.wellcode + ",新编号:" + formNew.wellcode + ";" - } - if (formNew.welldepth != formOld.welldepth) { - descpNew += "修改井深,原井深:" + formOld.welldepth + ",新井深:" + formNew.welldepth + ";" - } - if (formNew.welltype != formOld.welltype) { - descpNew += "修改井类型,原井类型:" + formOld.welltype + ",新井类型:" + formNew.welltype + ";" - } - if (formNew.project != formOld.project) { - descpNew += "修改所属项目,原项目:" + formOld.project + ",新项目:" + formNew.project + ";" - } - if (this.data.photopath1 != formOld.photopath1 || - this.data.photopath2 != formOld.photopath2 || - this.data.photopath3 != formOld.photopath3) { - descpNew += "修改照片;" - } - if ("" != formNew.description) { - descpNew += formNew.description; - } - this.setData({ - ['form.description']: descpNew + if (this.data.form.welldepth != null) { + if (this.isNumber(this.data.form.welldepth)) { + wx.showToast({ + icon: 'none', + title: '井深必须为数值!', }) - }, + return false + } + } + if (this.data.form.installheigt != null) { + if (this.isNumber(this.data.form.installheigt)) { + wx.showToast({ + icon: 'none', + title: '到井口距离必须为数值!', + }) + return false + } + } - formSubmit: function (event) { + return true; + }, - if (!this.formValidate()) { - return false; - } - this.changeMsg(); - var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDeviceLog', - data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceLog/add" - }, - }).then(res => { - // var resultObj=JSON.parse(res.result); - if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - if (res.confirm) { - wx.switchTab({ - url: that.data.pageName - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) - } - }).catch(err => { - console.error(err) - wx.showToast({ - title: "提交失败", - }) - }) - }, - confirm(event) { - var that = this; - var formValue = event.detail.value; - var formName = event.target.dataset.id; - var fromN = 'form.' + [formName]; - that.setData({ - [fromN]: formValue - }) - }, + //获取与上次修改的信息 + changeMsg: function () { + var formNew = this.data.form; + console.log(this.data.detail) + var formOld = JSON.parse(this.data.detail); + var descpNew = ""; + if (formNew.devcode != formOld.devcode) { + descpNew += "修改设备编号,原值:" + formOld.devcode + ",新值:" + formNew.devcode + ";" + } + if (formNew.devicetype != formOld.devicetype) { + descpNew += "修改设备类型,原值:" + formOld.devicetype + ",新值:" + formNew.devicetype + ";" + } + if (formNew.area != formOld.area) { + descpNew += "修改区,原值:" + formOld.area + ",新值:" + formNew.area + ";" + } + if (formNew.street != formOld.street) { + descpNew += "修改街道,原值:" + formOld.street + ",新值:" + formNew.street + ";" + } + if (formNew.wellname != formOld.wellname) { + descpNew += "修改井名称,原值:" + formOld.wellname + ",新值:" + formNew.wellname + ";" + } + if (formNew.factory != formOld.factory) { + descpNew += "修改权属单位,原值:" + formOld.factory + ",新值:" + formNew.factory + ";" + } + if (formNew.installheigt != formOld.installheigt) { + descpNew += "修改井口距离,原值:" + formOld.installheigt + ",新值:" + formNew.installheigt + ";" + } + if (formNew.installperson != formOld.installperson) { + descpNew += "修改运维人员,原值:" + formOld.installperson + ",新值:" + formNew.installperson + ";" + } + if (formNew.latitude != formOld.latitude) { + descpNew += "修改纬度,原值:" + formOld.latitude + ",新值:" + formNew.latitude + ";" + } + if (formNew.longitude != formOld.longitude) { + descpNew += "修改经度,原值:" + formOld.longitude + ",新值:" + formNew.longitude + ";" + } + if (formNew.position != formOld.position) { + descpNew += "修改位置描述,原值:" + formOld.position + ",新值:" + formNew.position + ";" + } + if (formNew.wellcode != formOld.wellcode) { + descpNew += "修改井编号,原值:" + formOld.wellcode + ",新值:" + formNew.wellcode + ";" + } + if (formNew.welldepth != formOld.welldepth) { + descpNew += "修改井深,原值:" + formOld.welldepth + ",新值:" + formNew.welldepth + ";" + } + if (formNew.welltype != formOld.welltype) { + descpNew += "修改井类型,原值:" + formOld.welltype + ",新值:" + formNew.welltype + ";" + } + if (formNew.project != formOld.project) { + descpNew += "修改所属项目,原值:" + formOld.project + ",新值:" + formNew.project + ";" + } + if (this.data.form.photopath1 != formOld.photopath1 || + this.data.form.photopath2 != formOld.photopath2 || + this.data.form.photopath3 != formOld.photopath3) { + descpNew += "修改照片;" + } + if ("" != formNew.description) { + descpNew += formNew.description; + } + this.setData({ + ['form.description']: descpNew + }) + }, - scan() { + //提交表单 + formSubmit: function (event) { - wx.scanCode({ - success(res) { - console.log(res) - } - }) + //表单验证 + if (!this.formValidate()) { + return false; + } + //自动生成修改内容 + this.changeMsg(); + //提交权限限制(只有施工人员能修改) + if(app.globalData.role!='repair'){ + wx.showToast({ + icon: 'none', + title: '无权限修改', + duration:2000 + }) + return false + } + var that = this; + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopath = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopath]: fileList[i].url.split("static/")[1] + }) + } + delete that.data.form.installtime + delete that.data.form.createtime + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - paste() { - var _this = this; - wx.getClipboardData({ - success: function (res) { - var longitude = 'form.longitude'; - var latitude = 'form.latitude'; - var longitude84 = 'form.longitude84'; - var latitude84 = 'form.latitude84'; - _this.setData({ - [longitude]: parseFloat(res.data.split(",", 4)[1]).toFixed(6), - [latitude]: parseFloat(res.data.split(",", 4)[0]).toFixed(6), - [longitude84]: "" == (res.data.split(",", 4)[3]) ? "" : parseFloat(res.data.split(",", 4)[3]).toFixed(6), - [latitude84]: "" == (res.data.split(",", 4)[2]) ? "" : parseFloat(res.data.split(",", 4)[2]).toFixed(6), - longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), - latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), - }); - } - }) - }, - selectValue(value) { - var that = this; - var wellType = 'form.welltype'; - that.setData({ - [wellType]: value.detail - }) - }, - selectpersonValue(event) { - var that = this; - var installPerson = 'form.installperson'; - that.setData({ - [installPerson]: event.detail - }) - }, - selectprojectValue(event) { - var that = this; - var project = 'form.project'; - that.setData({ - [project]: event.detail, - showMask: true - }) - }, - open() { - this.setData({ - showMask: true - }) - }, - close() { - this.setData({ - showMask: false - }) - }, - afterRead(event) { - var _this = this; - const { - file - } = event.detail; - const { - fileList = [] - } = _this.data; - var convertpath = ""; - wx.compressImage({ - src: event.detail.file.path, - quality: 25, - success: function (res) { - convertpath = res.tempFilePath; - wx.uploadFile({ - url: app.globalData.httpsUrl + "appDeviceAdd/fileUploadMarker", - filePath:convertpath, - name: 'file', - formData: { - 'text': "编号:" + _this.data.form.devcode + "经度:" + _this.data.form.longitude + "纬度:" + _this.data.form.latitude - }, - header: { - "Content-Type": "multipart/form-data", - 'accept': 'application/json', - }, - success(res) { - if (res.data) { - var url = JSON.parse(res.data); - fileList.push({ - ...file, - url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - }); - _this.setData({ - fileList - }); - } - } + success(res) { + if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + if (res.confirm) { + wx.switchTab({ + url: that.data.pageName }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') } - }) - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // // var base64 = "data:image/png;base64," + wx.getFileSystemManager().readFileSync(convertpath, 'base64'); - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: convertpath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // // wx.cloud.callFunction({ - // // name: 'uploadFile', - // // data: { - // // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // // fileBase64: base64 - // // }, - // // success: function (res) { - // // if (res.result) { - // // fileList.push({ - // // ...file, - // // url: app.globalData.url + "static/" + res.result.data.replace(/\\/g, "/") - // // }); - // // _this.setData({ - // // fileList - // // }); - // // } - // // }, - // // complete: res => { - // // }, - // // }) - // } - // }); + } + }) + } + }, + fail(err) { + wx.showToast({ + title: "提交失败", + }) + } + }) + }, + //报存录入的input信息 + confirm(event) { + var that = this; + var formValue = event.detail.value; + var formName = event.target.dataset.id; + var fromN = 'form.' + [formName]; + that.setData({ + [fromN]: formValue + }) + }, + + //扫码 + scan() { + + wx.scanCode({ + success(res) { + console.log(res) + } + }) + }, + //粘贴经纬度 + paste() { + var _this = this; + wx.getClipboardData({ + success: function (res) { + var longitude = 'form.longitude'; + var latitude = 'form.latitude'; + var longitude84 = 'form.longitude84'; + var latitude84 = 'form.latitude84'; + _this.setData({ + [longitude]: parseFloat(res.data.split(",", 4)[1]).toFixed(6), + [latitude]: parseFloat(res.data.split(",", 4)[0]).toFixed(6), + [longitude84]: "" == (res.data.split(",", 4)[3]) ? "" : parseFloat(res.data.split(",", 4)[3]).toFixed(6), + [latitude84]: "" == (res.data.split(",", 4)[2]) ? "" : parseFloat(res.data.split(",", 4)[2]).toFixed(6), + longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), + latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), + }); + } + }) + }, + selectValue(value) { + var that = this; + var wellType = 'form.welltype'; + that.setData({ + [wellType]: value.detail + }) + }, + //运维人员默认为登录人 + // selectpersonValue(event) { + // var that = this; + // var installPerson = 'form.installperson'; + // that.setData({ + // [installPerson]: event.detail + // }) + // }, + selectprojectValue(event) { + var that = this; + var project = 'form.project'; + that.setData({ + [project]: event.detail, + showMask: true + }) + }, + + open() { + this.setData({ + showMask: true + }) + }, + //隐藏textarea,防止遮挡 + close() { + this.setData({ + showMask: false + }) + }, + //上传照片 + afterRead(event) { + var _this = this; + const { + file + } = event.detail; + const { + fileList = [] + } = _this.data; + var convertpath = ""; + wx.compressImage({ + src: event.detail.file.path, + quality: 25, + success: function (res) { + convertpath = res.tempFilePath; + wx.uploadFile({ + url: app.globalData.httpsUrl + "appDeviceAdd/fileUploadMarker", + filePath: convertpath, + name: 'file', + formData: { + 'text': "编号:" + _this.data.form.devcode + "经度:" + _this.data.form.longitude + "纬度:" + _this.data.form.latitude }, - deletePhoto(event) { - var that = this - var image_index = event.detail.index - var fileList_new = that.data.fileList; - wx.showModal({ - content: '确定删除照片?', - success: function (res) { - if (res.confirm) { - fileList_new.splice(image_index, 1); - that.setData({ - fileList: fileList_new - }) - wx.cloud.callFunction({ - name: 'deletePhoto', - data: { - url: app.globalData.url + "appDeviceLog/deletePhoto", - devcode: that.data.form.devcode, - pathIndex: image_index - }, - success: function (res) {}, - complete: res => {}, - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + "Content-Type": "multipart/form-data", + 'accept': 'application/json', }, - }) \ No newline at end of file + success(res) { + if (res.data) { + var url = JSON.parse(res.data); + fileList.push({ + ...file, + url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") + }); + _this.setData({ + fileList + }); + } + } + }) + } + }) + }, + //删除照片 + deletePhoto(event) { + var that = this + var image_index = event.detail.index + var fileList_new = that.data.fileList; + wx.showModal({ + content: '确定删除照片?', + success: function (res) { + if (res.confirm) { + fileList_new.splice(image_index, 1); + that.setData({ + fileList: fileList_new + }) + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deletePhoto", + data: { + devcode: that.data.form.devcode + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) {} + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } +}) \ No newline at end of file diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.wxml b/miniprogram/pages/addDevicelog/addDeviceLog.wxml index 38620d4..b10cc7d 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.wxml +++ b/miniprogram/pages/addDevicelog/addDeviceLog.wxml @@ -1,15 +1,21 @@ - + + + + + - + - - + + - - + + - + @@ -39,24 +45,25 @@ - - - + + + - + - + + @@ -64,7 +71,7 @@ - + @@ -79,9 +86,9 @@ - + - 保存 + 保存 diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.wxss b/miniprogram/pages/addDevicelog/addDeviceLog.wxss index ee0b75c..08d5fd7 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.wxss +++ b/miniprogram/pages/addDevicelog/addDeviceLog.wxss @@ -24,6 +24,17 @@ display: flex; align-items: center; } +.map-view{ + width: 750rpx; + height: 485rpx; + position: fixed; + top: 0px; + left: 0px; + z-index: 999; +} +.content{ + margin-top: 495rpx; +} .left { width: 210rpx; diff --git a/miniprogram/pages/addFunction/addFunction.js b/miniprogram/pages/addFunction/addFunction.js deleted file mode 100644 index 4966be3..0000000 --- a/miniprogram/pages/addFunction/addFunction.js +++ /dev/null @@ -1,60 +0,0 @@ -// pages/addFunction/addFunction.js - -const code = `// 云函数入口函数 -exports.main = (event, context) => { - console.log(event) - console.log(context) - return { - sum: event.a + event.b - } -}` - -Page({ - - data: { - result: '', - canIUseClipboard: wx.canIUse('setClipboardData'), - }, - - onLoad: function (options) { - - }, - - copyCode: function() { - wx.setClipboardData({ - data: code, - success: function () { - wx.showToast({ - title: '复制成功', - }) - } - }) - }, - - testFunction() { - wx.cloud.callFunction({ - name: 'sum', - data: { - a: 1, - b: 2 - }, - success: res => { - wx.showToast({ - title: '调用成功', - }) - this.setData({ - result: JSON.stringify(res.result) - }) - }, - fail: err => { - wx.showToast({ - icon: 'none', - title: '调用失败', - }) - console.error('[云函数] [sum] 调用失败:', err) - } - }) - }, - -}) - diff --git a/miniprogram/pages/addFunction/addFunction.json b/miniprogram/pages/addFunction/addFunction.json deleted file mode 100644 index a9a50c5..0000000 --- a/miniprogram/pages/addFunction/addFunction.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "navigationBarTitleText": "云函数指引", - "usingComponents": {} -} \ No newline at end of file diff --git a/miniprogram/pages/addFunction/addFunction.wxml b/miniprogram/pages/addFunction/addFunction.wxml deleted file mode 100644 index 3a10626..0000000 --- a/miniprogram/pages/addFunction/addFunction.wxml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - 测试云函数 - - - 期望输出:{"sum":3} - - - 调用结果:{{result}} - - - - - 新增云函数 - 1. 在云函数根目录 cloudfunctions 上右键选择新建云函数,命名为 sum - 2. 在创建的 cloudfunctions/sum/index.js 文件中添加如下代码 - - - 3. 在 cloudfunctions/sum 目录上右键上传并部署 - 4. 点击测试云函数测试 - 5. 打开云开发云函数管理页,选择 sum 云函数 - 6. 查看 sum 的调用日志 - 进阶:可在云函数中使用 wx-server-sdk 操作数据库,文件存储和调用其他云函数,详见文档 - - - diff --git a/miniprogram/pages/addFunction/addFunction.wxss b/miniprogram/pages/addFunction/addFunction.wxss deleted file mode 100644 index 7ac8619..0000000 --- a/miniprogram/pages/addFunction/addFunction.wxss +++ /dev/null @@ -1,3 +0,0 @@ -/* pages/addFunction/addFunction.wxss */ - -@import "../../style/guide.wxss"; \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.js b/miniprogram/pages/applog/applog.js index 0e8c185..189e61f 100644 --- a/miniprogram/pages/applog/applog.js +++ b/miniprogram/pages/applog/applog.js @@ -13,98 +13,25 @@ isSeach: "false", params: {}, total: 0, - show: false + show: false, + delBtnWidth: 100, //删除按钮宽度单位(rpx) + activeIndex: -1, + list_style: '' }, - - touchE: function (e) { - // console.log(e); - var that = this - if (e.changedTouches.length == 1) { - //手指移动结束后触摸点位置的X坐标 - var endX = e.changedTouches[0].clientX; - //触摸开始与结束,手指移动的距离 - var disX = that.data.startX - endX; - var delBtnWidth = that.data.delBtnWidth; - //如果距离小于删除按钮的1/2,不显示删除按钮 - var txtStyle = disX > delBtnWidth / 2 ? "left:-" + delBtnWidth + "rpx" : "left:0rpx"; - - //获取手指触摸的是哪一项 - var index = e.currentTarget.dataset.index; - var list = that.data.deviceloglist; - list[index].txtStyle = txtStyle; - //更新列表的状态 - that.setData({ - deviceloglist: list - }); - } - }, - //手指触摸动作开始 记录起点X坐标 - touchstart: function (e) { - //开始触摸时 重置所有删除 - this.data.deviceloglist.forEach(function (v, i) { - if (v.isTouchMove) //只操作为true的 - v.isTouchMove = false; - }) - this.setData({ - startX: e.changedTouches[0].clientX, - startY: e.changedTouches[0].clientY, - deviceloglist: this.data.deviceloglist - }) - }, - //滑动事件处理 - touchmove: function (e) { - var that = this, - index = e.currentTarget.dataset.index, //当前索引 - startX = that.data.startX, //开始X坐标 - startY = that.data.startY, //开始Y坐标 - touchMoveX = e.changedTouches[0].clientX, //滑动变化坐标 - touchMoveY = e.changedTouches[0].clientY, //滑动变化坐标 - //获取滑动角度 - angle = that.angle({ - X: startX, - Y: startY - }, { - X: touchMoveX, - Y: touchMoveY - }); - that.data.deviceloglist.forEach(function (v, i) { - v.isTouchMove = false - //滑动超过30度角 return - if (Math.abs(angle) > 30) return; - if (i == index) { - if (touchMoveX > startX) //右滑 - v.isTouchMove = false - else //左滑 - v.isTouchMove = true - } - }) - //更新数据 - that.setData({ - deviceloglist: that.data.deviceloglist - }) - }, - /** - * 计算滑动角度 - * @param {Object} start 起点坐标 - * @param {Object} end 终点坐标 - */ - angle: function (start, end) { - var _X = end.X - start.X, - _Y = end.Y - start.Y - //返回角度 /Math.atan()返回数字的反正切值 - return 360 * Math.atan(_Y / _X) / (2 * Math.PI); - }, - /** - * 生命周期函数--监听页面加载var_this=this; - */ onLoad: function (options) { - if (options.params) { this.setData({ params: JSON.parse(options.params), isSeach: "true" }) this.initPages() + }else{ + this.setData({ + show: false + }) + //清空参数,重新加载 + this.clearParams(); + this.initPages(); } }, @@ -116,20 +43,33 @@ }, + //点击tabBar事件 + onTabItemTap(item) { + //隐藏历史显示总记录条数 + this.setData({ + show: false + }) + //清空参数,重新加载 + this.clearParams(); + this.initPages(); + }, + + /** * 生命周期函数--监听页面显示 */ onShow: function (options) { - this.setData({ - show:false - }) - if (this.data.isSeach == "false") { - this.clearParams(); - this.initPages(); - } - this.setData({ - isSeach: "false" - }) + + // this.setData({ + // show: false + // }) + // if (this.data.isSeach == "false") { + // this.clearParams(); + // this.initPages(); + // } + // this.setData({ + // isSeach: "false" + // }) }, /** @@ -167,6 +107,119 @@ }, + + //手指触摸动作开始 记录起点X坐标 + touchstart: function (e) { + //开始触摸时 重置所有删除 + this.data.deviceloglist.forEach(function (v, i) { + if (v.isTouchMove) //只操作为true的 + v.isTouchMove = false; + }) + this.setData({ + startX: e.changedTouches[0].clientX, + startY: e.changedTouches[0].clientY, + deviceloglist: this.data.deviceloglist + }) + }, + + //滑动事件处理 + touchmove: function (e) { + var that = this, + index = e.currentTarget.dataset.index, //当前索引 + startX = that.data.startX, //开始X坐标 + startY = that.data.startY, //开始Y坐标 + touchMoveX = e.changedTouches[0].clientX, //滑动变化坐标 + touchMoveY = e.changedTouches[0].clientY, //滑动变化坐标 + //获取滑动角度 + angle = that.angle({ + X: startX, + Y: startY + }, { + X: touchMoveX, + Y: touchMoveY + }); + that.data.deviceloglist.forEach(function (v, i) { + // v.isTouchMove = false + //滑动超过30度角 return + if (Math.abs(angle) > 30) return; + if (i == index) { + if (touchMoveX > startX) //右滑 + v.isTouchMove = false + else //左滑 + v.isTouchMove = true + } + }) + //更新数据 + that.setData({ + deviceloglist: that.data.deviceloglist + }) + }, + + /** + * 计算滑动角度 + * @param {Object} start 起点坐标 + * @param {Object} end 终点坐标 + */ + angle: function (start, end) { + var _X = end.X - start.X, + _Y = end.Y - start.Y + //返回角度 /Math.atan()返回数字的反正切值 + return 360 * Math.atan(_Y / _X) / (2 * Math.PI); + }, + + //删除事件 + delItem: function (e) { + if(app.globalData.role!='repair'){ + wx.showToast({ + icon: 'none', + title: '无权限删除', + duration:2000 + }) + return false + } + var that = this + wx.showModal({ + content: '是否删除?', + success: function (res) { + if (res.confirm) { + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/delete", + data: { + appDeviceAddId: e.currentTarget.dataset.devid + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if(res.data.code=='200'){ + that.data.deviceloglist.splice(e.currentTarget.dataset.index, 1) + that.setData({ + deviceloglist: that.data.deviceloglist, + total: that.data.deviceloglist.length + }) + wx.showToast({ + title: '删除成功!', + icon: 'none', + duration: 1000 + }) + } + }, + fail(err) { + wx.showToast({ + title: '删除失败!', + icon: 'none', + duration: 2000 + }) + } + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + }, + showLoading: function (message) { if (wx.showLoading) { // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 @@ -199,95 +252,105 @@ deviceloglist: [] }) }, + //查询列表数据 initPages: function () { var that = this + that.setData({ + show: false + }) var offsetValue = that.data.deviceloglist.length % 15 > 0 ? parseInt(that.data.deviceloglist.length / 15) + 2 : parseInt(that.data.deviceloglist.length / 15) + 1 - wx.cloud.callFunction({ - name: 'devicelog', + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/listPage", data: { devcode: that.data.params.devcode, devtype: that.data.params.devtype, installtimeFmt: that.data.params.installtimeFmt, project: that.data.params.project, installPerson: that.data.params.installPerson, - url: app.globalData.url + "appDeviceLog/listPage", limit: 15, offset: offsetValue }, - }).then(res => { - if (res.result.data.rows.length > 0) { - var resultJson = res.result - that.setData({ - deviceloglist: that.data.deviceloglist.concat(resultJson.data.rows) - }) - } else if (that.data.deviceloglist.length > 0) { - that.setData({ - show: true, - total: that.data.deviceloglist.length - }) - wx.showToast({ - title: '数据已全部加载完', - icon: 'none', - duration: 2000 - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.data.rows.length > 0) { + var resultJson = res.data + var listArr = resultJson.data.rows + listArr.forEach(function (v, i) { + listArr[i]['isTouchMove'] = false + }) + that.setData({ + deviceloglist: that.data.deviceloglist.concat(listArr) + }) + } else if (that.data.deviceloglist.length > 0) { + that.setData({ + show: true, + total: that.data.deviceloglist.length + }) + wx.showToast({ + title: '数据已全部加载完', + icon: 'none', + duration: 2000 + }) + } + if (offsetValue == 1 && res.data.data.rows.length < 15) { + that.setData({ + show: true, + total: that.data.deviceloglist.length + }) + } } - if(offsetValue==1&&res.result.data.rows.length<15){ - that.setData({ - show: true, - total: that.data.deviceloglist.length - }) - } - // console.log(res); - }).catch(err => { - console.error(err); }) + }, addDetail: function (event) { - this.showLoading("数据请求中..."); - wx.cloud.callFunction({ - name: 'deviceDetail', + var that = this + that.showLoading("数据请求中..."); + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deviceDetail", data: { devcode: event.target.dataset.devcode, - url: app.globalData.url + "appDeviceLog/deviceDetail", }, - }).then(res => { - this.hideLoading(); - var resultObject = JSON.parse(res.result); - var pageName = '../applog/applog' - if (resultObject.code == 200) { - wx.navigateTo({ - url: '../addDevicelog/addDeviceLog?detail=' + - JSON.stringify(resultObject.data) + "&pageName=" + pageName - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + that.hideLoading(); + // var resultObject = JSON.parse(res.data); + var resultObject = res.data; + var pageName = '../applog/applog' + if (resultObject.code == 200) { + wx.setStorageSync('resultObject', resultObject.data) + wx.navigateTo({ + url: '../addDevicelog/addDeviceLog?detail=' + "&pageName=" + pageName + }) + } + }, + fail(err) { + that.hideLoading(); } - }).catch(err => { - this.hideLoading() }) + }, add: function (event) { - wx.reLaunch({ - url: '../earth/earth?devcode=' + event.target.dataset.devcode - // url: '../earth/earth' + app.globalData.devcode = event.target.dataset.devcode; + wx.switchTab({ + url: '../earth/earth' }) + // wx.reLaunch({ + // url: '../earth/earth?devcode=' + event.target.dataset.devcode + // // url: '../earth/earth' + // }) }, onSearch: function () { + var _this = this wx.navigateTo({ - url: '../searchLog/searchLog' + url: '../searchLog/searchLog?params=' + JSON.stringify(_this.data.params) }) - }, - // initPages: function () { - // wx.cloud.callFunction({ - // name: 'devicelog' - // }).then(res => { - // var that = this; - // var jsonList = JSON.parse(res.result) - // that.setData({ - // deviceloglist: jsonList.data.rows - // }) - // console.log(res); - // }).catch(err => { - // console.error(err); - // }) - // } + } }) \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.wxml b/miniprogram/pages/applog/applog.wxml index e9a2352..2bfd041 100644 --- a/miniprogram/pages/applog/applog.wxml +++ b/miniprogram/pages/applog/applog.wxml @@ -1,54 +1,59 @@ - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {{item.devcode}} {{item.devicetype}} + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + {{item.devcode}} {{item.devicetype}} + + {{item.project}} {{item.installtime}}- {{item.installperson}} - - - - - + + + + + + 删除 - - - + + - 共计:{{total}}台 - + 共计:{{total}}台 + \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.wxss b/miniprogram/pages/applog/applog.wxss index 6d3428b..e6e8983 100644 --- a/miniprogram/pages/applog/applog.wxss +++ b/miniprogram/pages/applog/applog.wxss @@ -22,16 +22,18 @@ position: fixed; width: 100%; top: 0rpx; + z-index: 9999; /* margin-bottom: 100rpx; */ } .log-list { /* height: 100rpx; */ - /* display: flex; */ - + display: flex; + width: 100%; padding: 2px; margin-top: 2px; border-bottom: 1px solid #e5e5e5; + overflow: hidden } @@ -53,23 +55,29 @@ left: 35%; margin: 20rpx } - .del { - width: 90px; + /* display: flex; */ + width: 100rpx; display: flex; flex-direction: column; align-items: center; justify-content: center; - color: #fff; - -webkit-transform: translateX(90px); - transform: translateX(90px); - -webkit-transition: all 0.4s; + /* -webkit-transform: translateX(100rpx); */ + transform: translateX(100rpx); + /* -webkit-transition: all 0.4s; */ transition: all 0.4s; - font-size: 35rpx; + color: #fff; + background-color: #fe3e2f; +} +.logrow{ + width: 100%; + transform: translateX(100rpx); + /* -webkit-transform: translateX(100px); */ + margin-left: -100rpx; } -.touch-move-active .content, +.touch-move-active .logrow, .touch-move-active .del { - -webkit-transform: translateX(0); - transform: translateX(0); +/* -webkit-transform: translateX(0); */ +transform: translateX(0); } \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.js b/miniprogram/pages/deployFunctions/deployFunctions.js deleted file mode 100644 index a76b144..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.js +++ /dev/null @@ -1,66 +0,0 @@ -// pages/deployFunctions/deployFunctions.js -Page({ - - /** - * 页面的初始数据 - */ - data: { - - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - - }, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { - - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - - }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { - - }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { - - } -}) \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.json b/miniprogram/pages/deployFunctions/deployFunctions.json deleted file mode 100644 index 7fbedab..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "navigationBarTitleText": "部署云函数", - "usingComponents": {} -} \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.wxml b/miniprogram/pages/deployFunctions/deployFunctions.wxml deleted file mode 100644 index 462b6b6..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.wxml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - 调用失败 - - - 请检查 login 云函数是否已部署 - - - - - 部署 login 云函数 - 1. 确保已通过工具栏云开发入口开通云开发 - 2. 在 cloudfunctions/login 目录上右键上传并部署 - 3. 回到首页,重新点击获取 openid - - - - diff --git a/miniprogram/pages/deployFunctions/deployFunctions.wxss b/miniprogram/pages/deployFunctions/deployFunctions.wxss deleted file mode 100644 index c8803e6..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.wxss +++ /dev/null @@ -1,7 +0,0 @@ -/* pages/deployFunctions/deployFunctions.wxss */ - -@import "../../style/guide.wxss"; - -.black { - color: black; -} \ No newline at end of file diff --git a/miniprogram/pages/earth/earth.js b/miniprogram/pages/earth/earth.js index ae0d3f3..376a6e2 100644 --- a/miniprogram/pages/earth/earth.js +++ b/miniprogram/pages/earth/earth.js @@ -21,19 +21,12 @@ show: false, enableSsatellite: false, windowWidth: 0, - longitude: 113.324520, - latitude: 23.099994, - longitude84: 113.324520, - latitude84: 23.099994, - markers: [{ - id: 0, - iconPath: "../../images/locat.png", - latitude: 23.099994, - longitude: 113.324520, - width: 50, - height: 50 - }], - controls: [], + longitude: "116.627340", + latitude: "39.874390", + longitude84: "", + latitude84: "", + markers: [], + controls: [] }, /** @@ -41,39 +34,13 @@ */ onLoad: function (options) { var that = this; - //获取当前坐标(gcj02) - wx.getLocation({ - type: "gcj02", - altitude: true, - success: function (res) { - that.setData({ - latitude: parseFloat(res.latitude).toFixed(6), - longitude: parseFloat(res.longitude).toFixed(6), - // markers: [{ - // latitude: res.latitude, - // longitude: res.longitude, - // }] - }) - //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 - wx.getLocation({ - type: "wgs84", - altitude: true, - success: function (res) { - that.setData({ - latitude84: parseFloat(res.latitude).toFixed(6), - longitude84: parseFloat(res.longitude).toFixed(6) - }) - } - }) - } - }), - - //设置地图组件 - wx.getSystemInfo({ + //设置地图组件 + wx.getSystemInfo({ success(res) { var windowWidth = res.windowWidth var windowHeight = res.windowHeight var query = wx.createSelectorQuery() + var platform =res.platform query.select('#map').boundingClientRect() query.exec(function (res) { that.setData({ @@ -139,10 +106,20 @@ clickable: true }, { id: 7, - iconPath: '../../images/locat.png', + iconPath: '../../images/applocat.png', position: { - left: res[0].width/2, - top: res[0].height/2, + left: res[0].width / 2 - 20, + top: platform=="ios"?res[0].height / 2 - 80:res[0].height / 2 - 40, + width: 40, + height: 40 + }, + clickable: true + }, { + id: 8, + iconPath: '../../images/back.png', + position: { + left: windowWidth - 40, + top: windowHeight - 140, width: 30, height: 30 }, @@ -150,71 +127,15 @@ }] }) }) - + } - }), + }) + // 实例化API核心类 qqmapsdk = new QQMapWX({ key: 'BGPBZ-C5O3P-ROUDR-LWC4J-63EKH-V5FRX' }) - - if (options.devcode) { - var that = this - var devcode = options.devcode - wx.cloud.callFunction({ - name: 'findListByCodes', - data: { - devcodes: devcode, - url: app.globalData.url + "appDeviceAdd/findListByCodes" - }, - }).then(res => { - if (res.result.code == 200) { - var listResultData = res.result.data; - that.setData({ - listData: listResultData - }) - var markersArr = that.data.markers; - for (var i = 0; i < listResultData.length; i++) { - markersArr = markersArr.concat({ - iconPath: "../../images/locat.png", - id: listResultData[i].id, - callout: { - content: listResultData[i].devcode, - fontSize: '14', - // padding: true, - color: '#00000', - borderColor: '#F4EA2A', - bgColor: '#F4EA2A', - borderWidth: 5, - display: 'ALWAYS', - textAlign: 'center', - // borderRadius: 15 - }, - latitude: listResultData[i].latitude, - longitude: listResultData[i].longitude, - width: 40, - height: 40 - }); - } - this.setData({ - markers: markersArr, - latitude: listResultData[0].latitude, - longitude: listResultData[0].longitude, - marker_latitude: listResultData[0].latitude, - marker_longitude: listResultData[0].longitude, - title: listResultData[0].devcode - }) - } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "无法获取设备地理信息!", - icon: 'none', - duration: 2000 - }) - }) - } }, /** @@ -228,6 +149,97 @@ * 生命周期函数--监听页面显示 */ onShow: function () { + //输入设备编号获取marker位置信息 + var that = this; + if ( app.globalData.devcode!="") { + var devcode = app.globalData.devcode + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/findListByCodes", + data: { + devcodes: devcode, + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + app.globalData.devcode=""; + if (res.data.code == 200) { + var listResultData = res.data.data; + that.setData({ + listData: listResultData + }) + var markersArr = that.data.markers; + for (var i = 0; i < listResultData.length; i++) { + markersArr = markersArr.concat({ + iconPath: "../../images/locat.png", + id: Number(listResultData[i].id), + callout: { + content: "编号:"+listResultData[i].devcode+"\r\n位置:"+listResultData[i].position+"\r\n时间:"+listResultData[i].createtime, + fontSize: '14', + padding: true, + color: '#000000', + borderColor: '#F4EA2A', + bgColor: '#F4EA2A', + borderWidth: 5, + display: 'ALWAYS', + textAlign: 'left', + // borderRadius: 15 + }, + latitude: listResultData[i].latitude, + longitude: listResultData[i].longitude, + width: 40, + height: 40 + }); + } + that.setData({ + markers: markersArr, + latitude: listResultData[0].latitude, + longitude: listResultData[0].longitude, + marker_latitude: listResultData[0].latitude, + marker_longitude: listResultData[0].longitude, + title: listResultData[0].devcode + }) + } + }, + fail(err) { + app.globalData.devcode=""; + wx.showToast({ + title: "无法获取设备地理信息!", + icon: 'none', + duration: 2000 + }) + } + }) +} else { + //获取当前坐标(gcj02) + wx.getLocation({ + type: "gcj02", + altitude: true, + success: function (res) { + that.setData({ + latitude: parseFloat(res.latitude).toFixed(6), + longitude: parseFloat(res.longitude).toFixed(6), + // markers: [{ + // latitude: res.latitude, + // longitude: res.longitude, + // }] + }) + //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 + wx.getLocation({ + type: "wgs84", + altitude: true, + success: function (res) { + that.setData({ + latitude84: parseFloat(res.latitude).toFixed(6), + longitude84: parseFloat(res.longitude).toFixed(6) + }) + } + }) + } + }) +} + }, @@ -265,12 +277,46 @@ onShareAppMessage: function () { }, + + //定位出来 + + locationPosition: function () { + var that = this; + //获取当前坐标(gcj02) + wx.getLocation({ + type: "gcj02", + altitude: true, + success: function (res) { + that.setData({ + latitude: parseFloat(res.latitude).toFixed(6), + longitude: parseFloat(res.longitude).toFixed(6), + // markers: [{ + // latitude: res.latitude, + // longitude: res.longitude + // }] + }) + //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 + wx.getLocation({ + type: "wgs84", + altitude: true, + success: function (res) { + that.setData({ + latitude84: parseFloat(res.latitude).toFixed(6), + longitude84: parseFloat(res.longitude).toFixed(6) + }) + } + }) + } + }) + }, + + //加载地图组件 controltap: function (e) { // console.log(e.controlId); //进入添加设备页 if (1 == e.controlId) { wx.setClipboardData({ - data: this.data.latitude + "," + this.data.longitude+ "," + this.data.latitude84+ "," + this.data.longitude84, + data: this.data.latitude + "," + this.data.longitude + "," + this.data.latitude84 + "," + this.data.longitude84, success: function (res) { wx.getClipboardData({ success: function (res) { @@ -282,6 +328,17 @@ } }) } else if (3 == e.controlId) { + //先定位 + // this.locationPosition() + wx.setClipboardData({ + data: this.data.latitude + "," + this.data.longitude + "," + this.data.latitude84 + "," + this.data.longitude84, + success: function (res) { + wx.showToast({ + title: '坐标已获取', + duration: 1000 + }) + } + }) wx.navigateTo({ url: '../addDevice/addDevice' }) @@ -302,32 +359,15 @@ enableSsatellite: !flag }); } else if (6 == e.controlId) { - var that = this; - //获取当前坐标(gcj02) - wx.getLocation({ - type: "gcj02", - altitude: true, - success: function (res) { - that.setData({ - latitude: parseFloat(res.latitude).toFixed(6), - longitude:parseFloat(res.longitude).toFixed(6), - // markers: [{ - // latitude: res.latitude, - // longitude: res.longitude - // }] - }) - //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 - wx.getLocation({ - type: "wgs84", - altitude: true, - success: function (res) { - that.setData({ - latitude84: parseFloat(res.latitude).toFixed(6), - longitude84: parseFloat(res.longitude).toFixed(6) - }) - } - }) - } + //先清marker + this.setData({ + markers: [] + }) + this.locationPosition() + }else if (8 == e.controlId) { + //跳转日志缓存页 + wx.switchTab({ + url: '../applog/applog', }) } }, @@ -343,63 +383,68 @@ }); }, + //获取设备maker leave() { var that = this; if (that.data.devcodes == "") { return false; } - wx.cloud.callFunction({ - name: 'findListByCodes', + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/findListByCodes", data: { - devcodes: that.data.devcodes, - url: app.globalData.url + "appDeviceAdd/findListByCodes" + devcodes: that.data.devcodes }, - }).then(res => { - if (res.result.code == 200) { - var listResultData = res.result.data; - that.setData({ - listData: listResultData - }) - var markersArr = that.data.markers; - for (var i = 0; i < listResultData.length; i++) { - markersArr = markersArr.concat({ - iconPath: "../../images/locat.png", - id: listResultData[i].id, - callout: { - content: listResultData[i].devcode, - fontSize: '14', - // padding: true, - color: '', - borderColor: '#F4EA2A', - bgColor: '#F4EA2A', - borderWidth: 5, - display: 'ALWAYS', - textAlign: 'center', - // borderRadius: 15 - }, - latitude: listResultData[i].latitude, - longitude: listResultData[i].longitude, - width: 40, - height: 40 - }); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var listResultData = res.data.data; + that.setData({ + listData: listResultData + }) + var markersArr = that.data.markers; + for (var i = 0; i < listResultData.length; i++) { + markersArr = markersArr.concat({ + iconPath: "../../images/locat.png", + id: listResultData[i].id, + callout: { + content: "编号:"+listResultData[i].devcode+"\r\n位置:"+listResultData[i].position+"\r\n时间:"+listResultData[i].createtime, + fontSize: '14', + // padding: true, + color: '#212121', + borderColor: '#F4EA2A', + bgColor: '#F4EA2A', + borderWidth: 5, + display: 'ALWAYS', + textAlign: 'left', + // borderRadius: 15 + }, + latitude: listResultData[i].latitude, + longitude: listResultData[i].longitude, + width: 40, + height: 40 + }); + } + that.setData({ + markers: markersArr, + latitude: listResultData[0].latitude, + longitude: listResultData[0].longitude, + marker_latitude: listResultData[0].latitude, + marker_longitude: listResultData[0].longitude, + title: listResultData[0].devcode + }) } - this.setData({ - markers: markersArr, - latitude: listResultData[0].latitude, - longitude: listResultData[0].longitude, - marker_latitude: listResultData[0].latitude, - marker_longitude: listResultData[0].longitude, - title: listResultData[0].devcode + }, + fail(err) { + wx.showToast({ + title: "无法获取设备地理信息!", + icon: 'none', + duration: 2000 }) } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "无法获取设备地理信息!", - icon: 'none', - duration: 2000 - }) }) }, @@ -422,6 +467,8 @@ } }, + + bindregionchange: function (e) { var that = this if (e.causedBy == "drag") { @@ -445,8 +492,8 @@ that.setData({ latitude: parseFloat(latitude).toFixed(6), longitude: parseFloat(longitude).toFixed(6), - latitude84:"", - longitude84:"", + latitude84: "", + longitude84: "", // markers: markersArr }) // mapCtx.moveToLocation(); @@ -465,16 +512,19 @@ qqmapsdk.search({ keyword: this.data.value, success: function (res) { + console.log(res) if (res && res.data) { _this.setData({ isShow: true, tips: res.data }); } + }, + complete: function (res){ + console.log(res); } }) }, - bindSearch: function (e) { var location = e.target.dataset.location; this.setData({ diff --git a/miniprogram/pages/earth/earth.wxml b/miniprogram/pages/earth/earth.wxml index a0db6ef..87474f8 100644 --- a/miniprogram/pages/earth/earth.wxml +++ b/miniprogram/pages/earth/earth.wxml @@ -1,9 +1,10 @@ + - + {{item.title}} {{item.address}} @@ -17,6 +18,6 @@ + placeholder="请输入定位设备编号用换行隔开" autosize border="{{ false }}" /> \ No newline at end of file diff --git a/miniprogram/pages/indexapp/indexapp.js b/miniprogram/pages/indexapp/indexapp.js index 5063372..849dbdb 100644 --- a/miniprogram/pages/indexapp/indexapp.js +++ b/miniprogram/pages/indexapp/indexapp.js @@ -7,9 +7,8 @@ */ data: { - count:1, - show: false, - onshow:true, + count: 1, + onshow: true, value: "", deviceloglist: [], devcode: "", @@ -21,6 +20,7 @@ // iconPath: "../../images/point.png", latitude: 23.099994, longitude: 113.324520, + label:'1', width: 50, height: 50 }], @@ -31,62 +31,26 @@ * 生命周期函数--监听页面加载 */ onLoad: function (options) { - + }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { - + }, /** * 生命周期函数--监听页面显示 */ onShow: function () { - // if( app.globalData.indexCount>1){ - // this.setData({ - // show:false - // }) - // }else{ - // this.showNotice() - // } - if(app.globalData.indexCount==1){ - this.setData({ - show:true - }) - this.showNotice() - } - app.globalData.indexCount+=1 - if(this.data.onshow){ + if (this.data.onshow) { this.initPages(); } }, - - showNotice: function() { - var that = this - var times = 0 - var i = setInterval(function() { - times++ - if (times >= 15) { - that.setData({ - show:false - }) - wx.showTabBar({ - animation: false, - }) - clearInterval(i) - } else { - wx.hideTabBar({ - animation: false, - }) - } - }, 1000) -}, - /** * 生命周期函数--监听页面隐藏 */ @@ -122,16 +86,27 @@ }, jump: function (event) { - var that = this; var latitude = event.target.dataset.pointLat; var longitude = event.target.dataset.pointLon; + let devcode = event.target.dataset.pointCode; that.setData({ latitude: latitude, longitude: longitude, markers: [{ latitude: latitude, - longitude: longitude + longitude: longitude, + callout: { + display:'ALWAYS',// 常显气泡 + content: devcode, //名称文本 + color: '#fff', //文本颜色 + borderRadius: 5, //边框圆角 + borderWidth: 1, //边框宽度 + borderColor: '#0060ff', //边框颜色 + bgColor: '#0060ff', //背景色 + padding: 5, //文本边缘留白 + textAlign: 'center' //文本对齐方式。有效值: left, right, center + } }] }) }, @@ -142,7 +117,7 @@ var devcode = res.result _this.setData({ devcode: devcode, - onshow:false + onshow: false }); _this.searchlogs(devcode) } @@ -151,40 +126,11 @@ onSearch: function (event) { this.setData({ - devcode:event.detail + devcode: event.detail }) this.searchlogs(event.detail) }, - - // bindregionchange: function (e) { - // var that = this - // if (e.causedBy == "drag") { - // var mapCtx = wx.createMapContext("map") - // mapCtx.getCenterLocation({ - // success: function (res) { - // var markersArr = that.data.markers - // for (var i = 0; i < markersArr.length; i++) { - // if (markersArr[i].iconPath == undefined) { - // markersArr.splice(i, 1) - // } - // } - // var latitude = res.latitude - // var longitude = res.longitude - // markersArr = markersArr.concat({ - // latitude: latitude, - // longitude: longitude - // }) - // that.setData({ - // latitude: latitude, - // longitude: longitude, - // markers: markersArr - // }) - // } - // }) - // } - // }, - showLoading: function (message) { if (wx.showLoading) { // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 @@ -211,81 +157,89 @@ } }, + //加载设备运维详细信息 toDetail: function (event) { - this.showLoading("数据加载中...") - wx.cloud.callFunction({ - name: 'deviceDetail', + var that = this + that.showLoading("数据加载中...") + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deviceDetail", data: { devcode: event.target.dataset.devcode, - url: app.globalData.url + "appDeviceLog/deviceDetail", }, - }).then(res => { - this.hideLoading(); - var resultObject = JSON.parse(res.result); - var pageName='../indexapp/indexapp' - if (resultObject.code == 200) { - wx.navigateTo({ - url: '../addDevicelog/addDeviceLog?detail=' + - JSON.stringify(resultObject.data)+'&pageName='+pageName - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + that.hideLoading(); + var resultObject = res.data; + var pageName = '../indexapp/indexapp' + if (resultObject.code == 200) { + wx.setStorageSync('resultObject', resultObject.data) + wx.navigateTo({ + url: '../addDevicelog/addDeviceLog?detail=' +'&pageName=' + pageName + }) + } + }, + fail(err){ + that.hideLoading(); } - }).catch(err => { - this.hideLoading(); }) }, + //加载列表 getlogs: function (devcode) { var that = this - wx.cloud.callFunction({ - name: 'devicelog', + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/listPage", data: { devcode: devcode, - url: app.globalData.url + "appDeviceLog/listPage", limit: 100, offset: that.data.deviceloglist.length % 100 > 0 ? parseInt(that.data.deviceloglist.length / 100) + 2 : parseInt(that.data.deviceloglist.length / 100) + 1 }, - }).then(res => { - if (res.result) { - // var resultJson = JSON.parse(res.result) - var resultJson = res.result - that.setData({ - deviceloglist: that.data.deviceloglist.concat(resultJson.data.rows) - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + // var resultJson = JSON.parse(res.result) + var resultJson = res.data + that.setData({ + deviceloglist: that.data.deviceloglist.concat(resultJson.data.rows) + }) + } } - console.log(res); - }).catch(err => { - console.error(err); }) }, + //查询列表 searchlogs: function (devcode) { var that = this - wx.cloud.callFunction({ - name: 'devicelog', + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/listPage", data: { devcode: devcode, - url: app.globalData.url + "appDeviceLog/listPage", limit: 100, offset: 1 }, - }).then(res => { - if (res.result) { - var resultJson = res.result - that.setData({ - deviceloglist: resultJson.data.rows, - onshow:true - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var resultJson = res.data + that.setData({ + deviceloglist: resultJson.data.rows, + onshow: true + }) + } } - console.log(res); - }).catch(err => { - console.error(err); }) }, initPages: function () { var that = this; - that.setData({ - devcode: "" - }); wx.getLocation({ type: "gcj02", success: function (res) { @@ -302,6 +256,6 @@ }) } }) - this.searchlogs() + this.data.devcode !== '' ? this.searchlogs(this.data.devcode) : this.searchlogs() }, }) \ No newline at end of file diff --git a/miniprogram/pages/indexapp/indexapp.wxml b/miniprogram/pages/indexapp/indexapp.wxml index 69322a0..f65b082 100644 --- a/miniprogram/pages/indexapp/indexapp.wxml +++ b/miniprogram/pages/indexapp/indexapp.wxml @@ -1,8 +1,12 @@ + + + + - @@ -32,9 +36,15 @@ - + + + + + + + @@ -46,14 +56,14 @@ - + - - + diff --git a/miniprogram/pages/indexapp/indexapp.wxss b/miniprogram/pages/indexapp/indexapp.wxss index b18706a..fc27fcb 100644 --- a/miniprogram/pages/indexapp/indexapp.wxss +++ b/miniprogram/pages/indexapp/indexapp.wxss @@ -128,6 +128,7 @@ .noticeClass{ height: 2300rpx; width: 750rpx; + overflow-y:hidden; } @@ -148,14 +149,14 @@ } +/* .vanstyle{ + button: not([size='mini']) { + user agent stylesheetmin-height: 40px; + width: 650rpx; + margin-left: 20rpx; + margin-right: auto; + + } + +} */ -/* .van-enter-active-class, -.van-leave-active-class { - transition-property: background-color, transform; -} - -.van-enter-class, -.van-leave-to-class { - background-color: red; - transform: rotate(-360deg) translate3d(-100%, -100%, 0); -} */ \ No newline at end of file diff --git a/miniprogram/pages/log/log.js b/miniprogram/pages/log/log.js deleted file mode 100644 index 83ba349..0000000 --- a/miniprogram/pages/log/log.js +++ /dev/null @@ -1,66 +0,0 @@ -// pages/log/log.js -Page({ - - /** - * 页面的初始数据 - */ - data: { - - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - - }, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { - - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - - }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { - - }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { - - } -}) \ No newline at end of file diff --git a/miniprogram/pages/log/log.json b/miniprogram/pages/log/log.json deleted file mode 100644 index 8835af0..0000000 --- a/miniprogram/pages/log/log.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "usingComponents": {} -} \ No newline at end of file diff --git a/miniprogram/pages/log/log.wxml b/miniprogram/pages/log/log.wxml deleted file mode 100644 index a510ad6..0000000 --- a/miniprogram/pages/log/log.wxml +++ /dev/null @@ -1,2 +0,0 @@ - -pages/log/log.wxml diff --git a/miniprogram/pages/log/log.wxss b/miniprogram/pages/log/log.wxss deleted file mode 100644 index 23db318..0000000 --- a/miniprogram/pages/log/log.wxss +++ /dev/null @@ -1 +0,0 @@ -/* pages/log/log.wxss */ \ No newline at end of file diff --git a/miniprogram/pages/login/login.js b/miniprogram/pages/login/login.js index a4074e7..cb0542a 100644 --- a/miniprogram/pages/login/login.js +++ b/miniprogram/pages/login/login.js @@ -1,11 +1,14 @@ // miniprogram/pages/login/login.js +var app = getApp() Page({ /** * 页面的初始数据 */ data: { - windowWidth:"" + windowWidth: "", + time: 15 * 1000, + showTime: false }, /** @@ -20,9 +23,9 @@ */ onReady: function () { this.setData({ - windowWidth:wx.getSystemInfoSync().windowWidth + windowWidth: wx.getSystemInfoSync().windowWidth }) - + }, /** @@ -66,14 +69,158 @@ onShareAppMessage: function () { }, + + + showLoading: function (message) { + if (wx.showLoading) { + // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 + wx.showLoading({ + title: message, + mask: true + }); + } else { + // 低版本采用Toast兼容处理并将时间设为20秒以免自动消失 + wx.showToast({ + title: message, + icon: 'loading', + mask: true, + duration: 20000 + }); + } + }, + hideLoading: function () { + if (wx.hideLoading) { + // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 + wx.hideLoading(); + } else { + wx.hideToast(); + } + }, + + //注册 loginClick: function () { + var that = this + that.showLoading("授权中...") + wx.login({ + success: function (res) { + if (res.code) { + wx.request({ + url: app.globalData.httpsUrl + "appUserOpenid/login", + data: { + code: res.code + }, + success: function (res) { + app.globalData.openid = res.data.data + wx.getUserInfo({ + success: (res) => { + var nickname = res.userInfo.nickName; + app.globalData.nickName = nickname; + //openid绑定昵称存入后台 + wx.request({ + url: app.globalData.httpsUrl + "appUserOpenid/add", + data: { + attr: nickname, + openid: app.globalData.openid + }, + success: function (res) { + that.hideLoading(); + wx.showToast({ + title: res.data.data+",\r\n请从正式版入口登录!", + icon: 'none', + duration: 2000 + }) - wx.navigateTo({ - - url: '../farmermain/farmermain', - + // //授权成功后跳转 + // wx.switchTab({ + // url: '../indexapp/indexapp' + // }) + } + }) + }, + fail: function (err) { + that.hideLoading(); + } + }) + }, + fail: function (res) { + that.hideLoading(); + wx.showToast({ + title: '服务器异常', + }) + } + }) + } + }, + fail: function (res) { + that.hideLoading(); + } }) + }, + //登录验证 + loginValidate: function () { + var that = this + that.showLoading("登录中...") + wx.login({ + success: function (res) { + if (res.code) { + console.info(res); + wx.request({ + url: app.globalData.httpsUrl + "appUserOpenid/login", + data: { + code: res.code + }, + success: function (res) { + app.globalData.openid = res.data.data + wx.request({ + url: app.globalData.httpsUrl + "appUserOpenid/validate", + data: { + openid: app.globalData.openid + }, + success: function (res) { + that.hideLoading(); + if (res.data.data) { + app.globalData.userName = res.data.data.attr1 == '' ? res.data.data.attr : res.data.data.attr1 + app.globalData.nickName = res.data.data.attr + app.globalData.role = res.data.data.role + wx.navigateTo({ + url: '../notice/notice' + }) + } else { + wx.showToast({ + icon: 'none', + title: '请联系管理员授权', + duration: 2000 + }) + } + }, + fail: function (err) { + that.hideLoading(); + wx.showToast({ + title: '验证失败', + }) + } + }) + }, + fail: function (res) { + that.hideLoading(); + wx.showToast({ + title: '服务器异常', + }) + } + }) + } + }, + fail: function (res) { + that.hideLoading(); + } + }) + }, + + finished() { + this.setData({ + showTime: true + }) }, onClickSubmit: function () { diff --git a/miniprogram/pages/login/login.json b/miniprogram/pages/login/login.json index 8835af0..f2043a3 100644 --- a/miniprogram/pages/login/login.json +++ b/miniprogram/pages/login/login.json @@ -1,3 +1,8 @@ { - "usingComponents": {} + "usingComponents": { + "van-count-down": "../../miniprogram_npm/@vant/weapp/count-down", + "van-button": "../../miniprogram_npm/@vant/weapp/button" + }, + "navigationBarBackgroundColor": "#E6D480", + "disableScroll":true } \ No newline at end of file diff --git a/miniprogram/pages/login/login.wxml b/miniprogram/pages/login/login.wxml index c69df42..cf2ec72 100644 --- a/miniprogram/pages/login/login.wxml +++ b/miniprogram/pages/login/login.wxml @@ -1,21 +1,46 @@ + - + + + - + + + +    本程序为施工日志管理小程序,为航天二院智慧市 +政技术研究室内部系统,不对外开放。出于对数据信 +息安全的考虑,在您首次使用小程序时,请先对小程 +序进行授权,授权后的用户可以正常对小程序进行编 +辑,谢谢您的配合! + + + + + + + + 授权/登录 + + + - + + + diff --git a/cloudfunctions/project.config.json b/cloudfunctions/project.config.json new file mode 100644 index 0000000..2b3119a --- /dev/null +++ b/cloudfunctions/project.config.json @@ -0,0 +1,28 @@ +{ + "appid": "wx2cef527a000f87c9", + "compileType": "miniprogram", + "libVersion": "2.27.3", + "packOptions": { + "ignore": [], + "include": [] + }, + "setting": { + "coverView": true, + "es6": true, + "postcss": true, + "minified": true, + "enhance": true, + "showShadowRootInWxmlPanel": true, + "packNpmRelationList": [], + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + } + }, + "condition": {}, + "editorSetting": { + "tabIndent": "insertSpaces", + "tabSize": 4 + } +} \ No newline at end of file diff --git a/cloudfunctions/project.private.config.json b/cloudfunctions/project.private.config.json new file mode 100644 index 0000000..42ff49d --- /dev/null +++ b/cloudfunctions/project.private.config.json @@ -0,0 +1,7 @@ +{ + "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", + "projectname": "cloudfunctions", + "setting": { + "compileHotReLoad": true + } +} \ No newline at end of file diff --git a/miniprogram/app.js b/miniprogram/app.js index 51d56f3..50a8a54 100644 --- a/miniprogram/app.js +++ b/miniprogram/app.js @@ -18,13 +18,15 @@ // this.globalData = {} }, globalData: { - // url: "http://111.198.10.15:11604/", - httpsUrl: "https://logapi.smartlog.work/", - httpsTestUrl: "https://smartlog.work/prodapi4test/", - url: "http://139.198.18.188:8083/", + httpsUrl: "https://logapi.smartlog.work/", + // httpsUrl: "http://139.198.18.188:8083/", // url: "http://127.0.0.1:8083/", - // httpsUrl: "http://127.0.0.1:8083/", + //httpsUrl: "http://127.0.0.1:8083/", openid: null, - indexCount:1 - }, + indexCount:1, + nickName:"", + userName:"", + role:"", + devcode:"" + } }) diff --git a/miniprogram/app.json b/miniprogram/app.json index d23f798..2b6db76 100644 --- a/miniprogram/app.json +++ b/miniprogram/app.json @@ -1,15 +1,17 @@ { "cloud": true, "pages": [ + "pages/login/login", "pages/indexapp/indexapp", "pages/earth/earth", "pages/applog/applog", "pages/addDevice/addDevice", "pages/addDevicelog/addDeviceLog", - "pages/searchLog/searchLog" + "pages/searchLog/searchLog", + "pages/notice/notice" ], "window": { - "backgroundColor": "#F6F6F6", + "backgroundColor": "#E6D480", "backgroundTextStyle": "light", "navigationBarBackgroundColor": "#FFCF00", "navigationBarTitleText": "智慧施工", @@ -46,11 +48,11 @@ "desc": "你的位置信息将用于小程序位置接口的效果展示" } }, + "requiredPrivateInfos": ["getLocation", "chooseLocation"], "networkTimeout": { "request": 30000, "connectSocket": 30000, "uploadFile": 30000, "downloadFile": 30000 - }, - "style": "v2" + } } \ No newline at end of file diff --git a/miniprogram/images/applocat.png b/miniprogram/images/applocat.png new file mode 100644 index 0000000..fe49f54 --- /dev/null +++ b/miniprogram/images/applocat.png Binary files differ diff --git a/miniprogram/images/back.png b/miniprogram/images/back.png new file mode 100644 index 0000000..32ac82d --- /dev/null +++ b/miniprogram/images/back.png Binary files differ diff --git a/miniprogram/images/bottom.png b/miniprogram/images/bottom.png new file mode 100644 index 0000000..d910e98 --- /dev/null +++ b/miniprogram/images/bottom.png Binary files differ diff --git a/miniprogram/images/header.png b/miniprogram/images/header.png new file mode 100644 index 0000000..6ea222e --- /dev/null +++ b/miniprogram/images/header.png Binary files differ diff --git a/miniprogram/images/login.png b/miniprogram/images/login.png index 8b73cc0..6471c46 100644 --- a/miniprogram/images/login.png +++ b/miniprogram/images/login.png Binary files differ diff --git a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss index 5a591fb..c9c35b5 100644 --- a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss +++ b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:100%;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:100%}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file +@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:650rpx;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:600rpx}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file diff --git a/miniprogram/pages/addDevice/addDevice.js b/miniprogram/pages/addDevice/addDevice.js index 2783674..78f00b7 100644 --- a/miniprogram/pages/addDevice/addDevice.js +++ b/miniprogram/pages/addDevice/addDevice.js @@ -1,5 +1,7 @@ // miniprogram/pages/addDevice/addDevice.js // import WxValidate from '../../utils/WxValidate.js' +var QQMapWX = require('../../libs/qqmap-wx-jssdk.js'); +var qqmapsdk; var app = getApp() Page({ @@ -11,32 +13,10 @@ canvasWidth: '', longitude: '', latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], + option1: [], personoption1: [], projectoption: [], + devtypeList:[], show: false, form: { devcode: "", @@ -59,7 +39,10 @@ project: "", area: "", street: "", - wellname: "" + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '', }, fileList: [] }, @@ -117,12 +100,14 @@ var that = this; //初始化表单内容为上次填写值 var cacheForms = wx.getStorageSync('cacheList') - if (cacheForms) { + cacheForms.photopath1='' + cacheForms.photopath2='' + cacheForms.photopath3='' + that.data.fileList=[] that.setData({ form: cacheForms, devcode: cacheForms.devcode, - }) } var form = that.data.form @@ -155,55 +140,89 @@ } }) + +//获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + that.setData({ + option1: welltypeArr + }) + } + } +}) + + //获取人员下拉列表 - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/getUser", + data:{ + tips:'repair' }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data.code == 200) { + var users = res.data.data + var personArr = []; + for (var i = 0; i < users.length; i++) { + var person = { + text: users[i].name, + value: users[i].name + }; + personArr.push(person); + } + that.setData({ + personoption1: personArr + }) } - that.setData({ - personoption1: personArr - }) } - }).catch(err => { - console.error(err); - }) + }) + - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - that.setData({ - projectoption: projectArr - }) + success(res){ + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); + } + that.setData({ + projectoption: projectArr + }) + } } - }).catch(err => { - console.error(err); - }) + }) + var installtime = 'form.installtimeFmt'; var dateNow = this.formatDate(); this.setData({ @@ -211,8 +230,40 @@ installtimeFmt: dateNow, [installtime]: dateNow, }); + + + + /** + * 获取设备类型下拉列表 + */ + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/deviceType", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var TypeList = res.data.data + var typeArr = []; + for (var i = 0; i < TypeList.length; i++) { + var type = { + text: TypeList[i].productName, + value: TypeList[i].productName + }; + typeArr.push(type); + } + that.setData({ + devtypeList: typeArr + }) + } + } + }) }, + + + /** * 生命周期函数--监听页面初次渲染完成 */ @@ -280,29 +331,7 @@ }, - - //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 - drawText: function (ctx, str, leftWidth, initHeight, titleHeight, canvasWidth) { - var lineWidth = 0; - var lastSubStrIndex = 0; //每次开始截取的字符串的索引 - for (let i = 0; i < str.length; i++) { - lineWidth += ctx.measureText(str[i]).width; - if (lineWidth > canvasWidth) { - ctx.fillText(str.substring(lastSubStrIndex, i), leftWidth, initHeight); //绘制截取部分 - initHeight = initHeight + leftWidth * 2; //22为字体的高度 - lineWidth = 0; - lastSubStrIndex = i; - // titleHeight += 40; - } - if (i == str.length - 1) { //绘制剩余部分 - ctx.fillText(str.substring(lastSubStrIndex, i + 1), leftWidth, initHeight); - } - } - // // 标题border-bottom 线距顶部距离 - // titleHeight = titleHeight + 10; - // return titleHeight - }, - + //验证表单 formValidate() { if (this.data.form.devcode == "") { @@ -312,27 +341,20 @@ }) return false } - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } if (this.data.form.wellcode == "") { wx.showToast({ icon: 'none', @@ -348,22 +370,10 @@ }) return false } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null) { + + if (this.data.form.installperson == "") { wx.showToast({ icon: 'none', title: '安装人员不能为空!', @@ -408,56 +418,90 @@ } return true; }, + //提交表单 formSubmit: function (event) { + console.log(this.data.form) + //表单参数验证 if (!this.formValidate()) { return false; } var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDevice', + //验证设备编号长度 + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/getDevTypeLength", data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceAdd/add" + code: encodeURI(this.data.form.devicetype) }, - }).then(res => { - if (res.result.code == 500) { - wx.showToast({ - title: '设备编号已安装!', - }) - } else if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - //用于回显 - wx.setStorageSync('cacheList', that.data.form) - //提交成功后提示用户操作 - if (res.confirm) { - wx.switchTab({ - url: '../earth/earth' - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (""==res.data.data ||res.data.data == that.data.form.devcode.length) { + that.saveDevice() + } else { //编号位数不对提示 + wx.showToast({ + icon: 'none', + title: '设备编号位数不对!', + duration: 1000 + }) + return false + } } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "提交失败", - }) }) }, + + //保存设备基本信息 + saveDevice() { + var that = this; + //设置照片路径 + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopathForm = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopathForm]: fileList[i].url.split("static/")[1] + }) + } + //表单提交 + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 500) { + wx.showToast({ + title: '设备编号已安装!', + }) + } else if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + //用于回显 + wx.setStorageSync('cacheList', that.data.form) + //提交成功后提示用户操作 + if (res.confirm) { + wx.switchTab({ + url: '../earth/earth' + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } + }, + fail(err) { + wx.showToast({ + title: '提交失败!', + }) + } + }) + }, + + //input 输入框设置值 confirm(event) { var that = this; var formValue = event.detail.value; @@ -466,8 +510,30 @@ that.setData({ [fromN]: formValue }) + //若输入是设备编号,自动获取设备类型 + if('devcode'==formName){ + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", + data: { + devcode: formValue, + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + that.setData({ + [formDevicetype]: res.data + }); + } + } + }) + } }, + //扫描设备获取编号和设备类型 scan() { var _this = this; wx.scanCode({ @@ -477,23 +543,28 @@ _this.setData({ [formdevcode]: devcode }); - wx.cloud.callFunction({ - name: 'findModeCode', + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", data: { devcode: devcode, - url: app.globalData.url + "appDeviceAdd/findModeCodeByCode" }, - }).then(res => { - if (res.result) { - var formDevicetype = 'form.devicetype' - _this.setData({ - [formDevicetype]: res.result - }); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + _this.setData({ + [formDevicetype]: res.data + }); + } } }) } }) }, + //粘贴经纬度 paste() { var _this = this; wx.getClipboardData({ @@ -510,9 +581,11 @@ longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), }); + _this.showAddress(_this.data.form.longitude,_this.data.form.latitude,_this) } }) }, + //设置经类型 selectValue(value) { var that = this; @@ -521,6 +594,16 @@ [wellType]: value.detail }) }, + + //设置设备类型 + selectDevType(event) { + var that = this; + var devtype = 'form.devicetype'; + that.setData({ + [devtype]: event.detail + }) + }, + //设置运维人员 selectpersonValue(event) { var that = this; var installPerson = 'form.installperson'; @@ -528,6 +611,7 @@ [installPerson]: event.detail }) }, + //设置项目 selectprojectValue(event) { var that = this; var project = 'form.project'; @@ -535,8 +619,41 @@ [project]: event.detail }) }, + showAddress :function(longitude, latitude, self) { + // 实例化腾讯地图API核心类 + qqmapsdk = new QQMapWX({ + key: 'BGPBZ-C5O3P-ROUDR-LWC4J-63EKH-V5FRX'//此处使用你自己申请的key + }) + // 腾讯地图调用接口 + qqmapsdk.reverseGeocoder({ + location: { + latitude: latitude, + longitude: longitude + }, + success: function (res) { + self.setData({ + 'form.area':res.result.address.slice(0,res.result.address.indexOf('区')+1), + 'form.street':res.result.address.slice(res.result.address.indexOf('区')+1) + }) + }, + fail: function (res) { + console.log(res); + }, + complete: function (res) { + } + }); + }, + //上传照片 afterRead(event) { var _this = this; + if (_this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '请先填写设备编号!\r\n否则水印中无编号', + duration: 2000 + }) + return false + } const { file } = event.detail; @@ -576,78 +693,8 @@ }) } }) - // 压缩图片 - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // //获取图片尺寸 - // wx.getImageInfo({ - // src: convertpath, - // success(res) { - // _this.setData({ - // canvasHeight: res.height, - // canvasWidth: res.width - // }) - // var ctx = wx.createCanvasContext('firstCanvas') - - // //将图片src放到cancas内,宽高为图片大小 - // ctx.drawImage(convertpath, 0, 0, res.width, res.height) - // //将声明的时间放入canvas - // ctx.setFontSize(30 * (res.width / 750)) //注意:设置文字大小必须放在填充文字之前,否则不生效 - // ctx.setFillStyle('blue') - // var text = "编号:" + _this.data.form.devcode + "\n经度:" + _this.data.form.longitude + "\n纬度:" + _this.data.form.latitude - // // _this.drawText(ctx,text,20, 70, 5, res.width) - // _this.drawText(ctx, text, 15 * (res.width / 750), 70 * (res.width / 750), 5, res.width) - - // // ctx.fillText(text, 0, 40) - // // ctx.strokeText(_this.data.form.devcode, 0, 30) - // //生成水印图 - // ctx.draw(false, function () { - // wx.canvasToTempFilePath({ - // canvasId: 'firstCanvas', - // success: (res) => { - // wx.compressImage({ - // src: res.tempFilePath, - // quality: 25, - // success: function (res) { - // //上传照片至服务器 - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: res.tempFilePath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // } - // }) - // //// - // } - // }) - // }) - // } - // }) - // } - // }); }, + //删除照片 deletePhoto(event) { var image_index = event.detail.index var fileList_new = this.data.fileList; diff --git a/miniprogram/pages/addDevice/addDevice.wxml b/miniprogram/pages/addDevice/addDevice.wxml index b0977e2..f12c254 100644 --- a/miniprogram/pages/addDevice/addDevice.wxml +++ b/miniprogram/pages/addDevice/addDevice.wxml @@ -5,18 +5,30 @@ - + + + + + + + + + + + + + - - + + - - - + + + @@ -29,13 +41,13 @@ - + - + - + - + @@ -54,8 +66,7 @@ - - + @@ -68,8 +79,8 @@ - - + + - 保存 + 保存 \ No newline at end of file diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.js b/miniprogram/pages/addDevicelog/addDeviceLog.js index cdec71b..a0dc6da 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.js +++ b/miniprogram/pages/addDevicelog/addDeviceLog.js @@ -3,681 +3,665 @@ var app = getApp(); Page({ - /** - * 页面的初始数据 - */ - data: { - pageName: '', - showMask: false, - today: new Date().getTime(), - longitude: '', - latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], - personoption1: [], - projectoption: [], - devcode: "", - deviceMode: "", - installtimeFmt: '', - show: false, - form: { - devcode: "", - wellcode: "", - welltype: "", - welldepth: "", - installheigt: "", - installperson: "", - installtimeFmt: "", - photopath: "", - factory: "", - workmsg: "", - position: "", - description: "", - longitude: "", - latitude: "", - longitude84: "", - latitude84: "", - devicetype: "", - project: "", - area: "", - street: "", - wellname: "" - }, - fileList: [], - detail: "" - }, + /** + * 页面的初始数据 + */ + data: { + pageName: '', + showMask: false, + today: new Date().getTime(), + longitude: '', + latitude: '', + option1: [], + personoption1: [], + projectoption: [], + devcode: "", + deviceMode: "", + installtimeFmt: '', + show: false, + form: { + devcode: "", + wellcode: "", + welltype: "", + welldepth: "", + installheigt: "", + installperson: "", + installtimeFmt: "", + photopath: "", + factory: "", + workmsg: "", + position: "", + description: "", + longitude: "", + latitude: "", + longitude84: "", + latitude84: "", + devicetype: "", + project: "", + area: "", + street: "", + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '' + }, + fileList: [], + detail: "", + markers: [{ + id: 100, + // iconPath: "../../images/point.png", + latitude: '', + longitude: '', + // label:'1', + width: 25, + height: 35 + }], + }, - onDisplay() { - this.setData({ - show: true - }); - }, - onClose() { - this.setData({ - show: false - }); - }, - formatDate() { - var date = new Date(); - // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; - var seperator1 = "-"; - var month = date.getMonth() + 1; - var strDate = date.getDate(); - var hour = date.getHours() - var minute = date.getMinutes() - var second = date.getSeconds() - month = month > 9 ? month : "0" + month; - strDate = strDate > 9 ? strDate : "0" + strDate; - hour = hour > 9 ? hour : "0" + hour; - minute = minute > 9 ? minute : "0" + minute; - second = second > 9 ? second : "0" + second; - var currentdate = - date.getFullYear() + - seperator1 + - month + - seperator1 + - strDate + - " " + - hour + ":" + - minute + ":" + - second; - return currentdate; + onDisplay() { + this.setData({ + show: true + }); + }, + onClose() { + this.setData({ + show: false + }); + }, + formatDate() { + var date = new Date(); + // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; + var seperator1 = "-"; + var month = date.getMonth() + 1; + var strDate = date.getDate(); + var hour = date.getHours() + var minute = date.getMinutes() + var second = date.getSeconds() + month = month > 9 ? month : "0" + month; + strDate = strDate > 9 ? strDate : "0" + strDate; + hour = hour > 9 ? hour : "0" + hour; + minute = minute > 9 ? minute : "0" + minute; + second = second > 9 ? second : "0" + second; + var currentdate = + date.getFullYear() + + seperator1 + + month + + seperator1 + + strDate + + " " + + hour + ":" + + minute + ":" + + second; + return currentdate; - }, - onConfirm(event) { - var installtime = 'form.installtimeFmt'; - this.setData({ - show: false, - installtimeFmt: this.formatDate(event.detail), - [installtime]: this.formatDate(event.detail), - }); - }, + }, + onConfirm(event) { + var installtime = 'form.installtimeFmt'; + this.setData({ + show: false, + installtimeFmt: this.formatDate(event.detail), + [installtime]: this.formatDate(event.detail), + }); + }, - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - var _this = this; - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" - }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); - } - _this.setData({ - personoption1: personArr - }) + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + var _this = this; + _this.setData({ + 'markers[0].latitude': Number(wx.getStorageSync('resultObject').latitude) , + 'markers[0].longitude': Number(wx.getStorageSync('resultObject').longitude), + // 'markers[0].label':'10', + 'markers[0].width': 18, + 'markers[0].id':1, + 'markers[0].height': 30, + latitude:Number(wx.getStorageSync('resultObject').latitude), + longitude:Number(wx.getStorageSync('resultObject').longitude) + }) + //获取人员下拉列表 + // wx.request({ + // method: "POST", + // url: app.globalData.httpsUrl + "deviceType/getUser", + // data:{ + // tips:'repair' + // }, + // header: { + // 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + // }, + // success(res) { + // if (res.data.code == 200) { + // var users = res.data.data + // var personArr = []; + // for (var i = 0; i < users.length; i++) { + // var person = { + // text: users[i].name, + // value: users[i].name + // }; + // personArr.push(person); + // } + // _this.setData({ + // personoption1: personArr + // }) + // } + // } + // }) + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); } - }).catch(err => { - console.error(err); - }) - - - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" - }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - _this.setData({ - projectoption: projectArr - }) - } - }).catch(err => { - console.error(err); - }) - - if (options.pageName) { - this.setData({ - pageName: options.pageName - }) - } - - if (options.detail) { - - var formObject = JSON.parse(options.detail); _this.setData({ - form: formObject, - detail: options.detail + projectoption: projectArr }) - - _this.setData({ - ['form.installperson']: "", - ['form.installtimeFmt']: "", - ['form.workmsg']: "", - ['form.description']: "" - }) - - const { - fileList = [] - } = _this.data; - if (formObject.photopath1 != "") { - var file1 = { - url: app.globalData.url + "static/" + formObject.photopath1 - } - fileList.push(file1) - } - if (formObject.photopath2 != "") { - var file2 = { - url: app.globalData.url + "static/" + formObject.photopath2 - } - fileList.push(file2) - } - if (formObject.photopath3 != "") { - var file3 = { - url: app.globalData.url + "static/" + formObject.photopath3 - } - fileList.push(file3) - } - - _this.setData({ - fileList - }); } - var installtime = 'form.installtimeFmt'; - var dateNow = this.formatDate(); - this.setData({ - installtimeFmt: dateNow, - [installtime]: dateNow, - }); - }, + } + }) - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { + //获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + _this.setData({ + option1: welltypeArr + }) + } + } +}) - }, + //跳转时带入参数返回哪页 + if (options.pageName) { + this.setData({ + pageName: options.pageName + }) + } + //跳转时带入参数设备的安装信息 + if (wx.getStorageSync('resultObject')) { + var formObject = wx.getStorageSync('resultObject') + _this.setData({ + form: formObject, + detail: formObject + }) - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { + _this.setData({ + ['form.installperson']: app.globalData.userName, + ['form.installtimeFmt']: "", + ['form.workmsg']: "", + ['form.description']: "" + }) - }, + const { + fileList = [] + } = _this.data; + if (formObject.photopath1 != "") { + var file1 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath1 + } + fileList.push(file1) + } + if (formObject.photopath2 != "") { + var file2 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath2 + } + fileList.push(file2) + } + if (formObject.photopath3 != "") { + var file3 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath3 + } + fileList.push(file3) + } + _this.setData({ + fileList + }); + } + var installtime = 'form.installtimeFmt'; + var dateNow = this.formatDate(); + this.setData({ + installtimeFmt: dateNow, + [installtime]: dateNow, + }); + }, - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, - }, + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + wx.removeStorageSync('resultObject') + }, - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, - }, + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { + }, - }, + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { + }, - }, + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { + }, - }, + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + }, - /** - * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true - **/ + /** + * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true + **/ - isNumber: function (val) { + isNumber: function (val) { - var regPos = /^[0-9]*$/; //非负浮点数 - var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数 - if (regPos.test(val) || regNeg.test(val)) { - return false; - } else { - return true; - } + var regPos = /^[0-9]*$/; //非负浮点数 + var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数 + if (regPos.test(val) || regNeg.test(val)) { + return false; + } else { + return true; + } - }, + }, - formValidate() { + formValidate() { - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } - if (this.data.form.wellcode == "") { - wx.showToast({ - icon: 'none', - title: '井编号不能为空!', - }) - return false - } - if (this.data.form.devicetype == "") { - wx.showToast({ - icon: 'none', - title: '设备类型不能为空!', - }) - return false - } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + if (this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '设备编号不能为空!', + }) + return false + } + if (this.data.form.wellcode == "") { + wx.showToast({ + icon: 'none', + title: '井编号不能为空!', + }) + return false + } + if (this.data.form.devicetype == "") { + wx.showToast({ + icon: 'none', + title: '设备类型不能为空!', + }) + return false + } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null || - this.data.form.installperson == '') { - wx.showToast({ - icon: 'none', - title: '运维人员不能为空!', - }) - return false - } - if (this.data.form.project == "") { - wx.showToast({ - icon: 'none', - title: '所属项目不能为空!', - }) - return false - } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } + if (this.data.form.installperson == null || + this.data.form.installperson == '') { + wx.showToast({ + icon: 'none', + title: '运维人员不能为空!', + }) + return false + } + if (this.data.form.project == "") { + wx.showToast({ + icon: 'none', + title: '所属项目不能为空!', + }) + return false + } - if (this.data.form.welldepth != null) { - if (this.isNumber(this.data.form.welldepth)) { - wx.showToast({ - icon: 'none', - title: '井深必须为数值!', - }) - return false - } - } - if (this.data.form.installheigt != null) { - if (this.isNumber(this.data.form.installheigt)) { - wx.showToast({ - icon: 'none', - title: '到井口距离必须为数值!', - }) - return false - } - } - - return true; - }, - - changeMsg: function () { - var formNew = this.data.form; - var formOld = JSON.parse(this.data.detail); - var descpNew = ""; - if (formNew.devcode != formOld.devcode) { - descpNew += "修改设备编号,原编号:" + formOld.devcode + ",新编号:" + formNew.devcode + ";" - } - if (formNew.devicetype != formOld.devicetype) { - descpNew += "修改设备类型,原设备类型:" + formOld.devicetype + ",新设备类型:" + formNew.devicetype + ";" - } - if (formNew.area != formOld.area) { - descpNew += "修改区,原区:" + formOld.area + ",新区:" + formNew.area + ";" - } - if (formNew.street != formOld.street) { - descpNew += "修改街道,原街道:" + formOld.street + ",新街道:" + formNew.street + ";" - } - if (formNew.wellname != formOld.wellname) { - descpNew += "修改井名称,原井名称:" + formOld.wellname + ",新井名称:" + formNew.wellname + ";" - } - if (formNew.factory != formOld.factory) { - descpNew += "修改权属单位,原权属单位:" + formOld.factory + ",新权属单位:" + formNew.factory + ";" - } - if (formNew.installheigt != formOld.installheigt) { - descpNew += "修改井口距离,原井口距离:" + formOld.installheigt + ",新井口距离:" + formNew.installheigt + ";" - } - if (formNew.installperson != formOld.installperson) { - descpNew += "修改运维人员,原运维人员:" + formOld.installperson + ",新运维人员:" + formNew.installperson + ";" - } - if (formNew.latitude != formOld.latitude) { - descpNew += "修改纬度,原纬度:" + formOld.latitude + ",新纬度:" + formNew.latitude + ";" - } - if (formNew.longitude != formOld.longitude) { - descpNew += "修改经度,原经度:" + formOld.longitude + ",新经度:" + formNew.longitude + ";" - } - if (formNew.position != formOld.position) { - descpNew += "修改位置描述,原位置:" + formOld.position + ",新位置:" + formNew.position + ";" - } - if (formNew.wellcode != formOld.wellcode) { - descpNew += "修改井编号,原编号:" + formOld.wellcode + ",新编号:" + formNew.wellcode + ";" - } - if (formNew.welldepth != formOld.welldepth) { - descpNew += "修改井深,原井深:" + formOld.welldepth + ",新井深:" + formNew.welldepth + ";" - } - if (formNew.welltype != formOld.welltype) { - descpNew += "修改井类型,原井类型:" + formOld.welltype + ",新井类型:" + formNew.welltype + ";" - } - if (formNew.project != formOld.project) { - descpNew += "修改所属项目,原项目:" + formOld.project + ",新项目:" + formNew.project + ";" - } - if (this.data.photopath1 != formOld.photopath1 || - this.data.photopath2 != formOld.photopath2 || - this.data.photopath3 != formOld.photopath3) { - descpNew += "修改照片;" - } - if ("" != formNew.description) { - descpNew += formNew.description; - } - this.setData({ - ['form.description']: descpNew + if (this.data.form.welldepth != null) { + if (this.isNumber(this.data.form.welldepth)) { + wx.showToast({ + icon: 'none', + title: '井深必须为数值!', }) - }, + return false + } + } + if (this.data.form.installheigt != null) { + if (this.isNumber(this.data.form.installheigt)) { + wx.showToast({ + icon: 'none', + title: '到井口距离必须为数值!', + }) + return false + } + } - formSubmit: function (event) { + return true; + }, - if (!this.formValidate()) { - return false; - } - this.changeMsg(); - var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDeviceLog', - data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceLog/add" - }, - }).then(res => { - // var resultObj=JSON.parse(res.result); - if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - if (res.confirm) { - wx.switchTab({ - url: that.data.pageName - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) - } - }).catch(err => { - console.error(err) - wx.showToast({ - title: "提交失败", - }) - }) - }, - confirm(event) { - var that = this; - var formValue = event.detail.value; - var formName = event.target.dataset.id; - var fromN = 'form.' + [formName]; - that.setData({ - [fromN]: formValue - }) - }, + //获取与上次修改的信息 + changeMsg: function () { + var formNew = this.data.form; + console.log(this.data.detail) + var formOld = JSON.parse(this.data.detail); + var descpNew = ""; + if (formNew.devcode != formOld.devcode) { + descpNew += "修改设备编号,原值:" + formOld.devcode + ",新值:" + formNew.devcode + ";" + } + if (formNew.devicetype != formOld.devicetype) { + descpNew += "修改设备类型,原值:" + formOld.devicetype + ",新值:" + formNew.devicetype + ";" + } + if (formNew.area != formOld.area) { + descpNew += "修改区,原值:" + formOld.area + ",新值:" + formNew.area + ";" + } + if (formNew.street != formOld.street) { + descpNew += "修改街道,原值:" + formOld.street + ",新值:" + formNew.street + ";" + } + if (formNew.wellname != formOld.wellname) { + descpNew += "修改井名称,原值:" + formOld.wellname + ",新值:" + formNew.wellname + ";" + } + if (formNew.factory != formOld.factory) { + descpNew += "修改权属单位,原值:" + formOld.factory + ",新值:" + formNew.factory + ";" + } + if (formNew.installheigt != formOld.installheigt) { + descpNew += "修改井口距离,原值:" + formOld.installheigt + ",新值:" + formNew.installheigt + ";" + } + if (formNew.installperson != formOld.installperson) { + descpNew += "修改运维人员,原值:" + formOld.installperson + ",新值:" + formNew.installperson + ";" + } + if (formNew.latitude != formOld.latitude) { + descpNew += "修改纬度,原值:" + formOld.latitude + ",新值:" + formNew.latitude + ";" + } + if (formNew.longitude != formOld.longitude) { + descpNew += "修改经度,原值:" + formOld.longitude + ",新值:" + formNew.longitude + ";" + } + if (formNew.position != formOld.position) { + descpNew += "修改位置描述,原值:" + formOld.position + ",新值:" + formNew.position + ";" + } + if (formNew.wellcode != formOld.wellcode) { + descpNew += "修改井编号,原值:" + formOld.wellcode + ",新值:" + formNew.wellcode + ";" + } + if (formNew.welldepth != formOld.welldepth) { + descpNew += "修改井深,原值:" + formOld.welldepth + ",新值:" + formNew.welldepth + ";" + } + if (formNew.welltype != formOld.welltype) { + descpNew += "修改井类型,原值:" + formOld.welltype + ",新值:" + formNew.welltype + ";" + } + if (formNew.project != formOld.project) { + descpNew += "修改所属项目,原值:" + formOld.project + ",新值:" + formNew.project + ";" + } + if (this.data.form.photopath1 != formOld.photopath1 || + this.data.form.photopath2 != formOld.photopath2 || + this.data.form.photopath3 != formOld.photopath3) { + descpNew += "修改照片;" + } + if ("" != formNew.description) { + descpNew += formNew.description; + } + this.setData({ + ['form.description']: descpNew + }) + }, - scan() { + //提交表单 + formSubmit: function (event) { - wx.scanCode({ - success(res) { - console.log(res) - } - }) + //表单验证 + if (!this.formValidate()) { + return false; + } + //自动生成修改内容 + this.changeMsg(); + //提交权限限制(只有施工人员能修改) + if(app.globalData.role!='repair'){ + wx.showToast({ + icon: 'none', + title: '无权限修改', + duration:2000 + }) + return false + } + var that = this; + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopath = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopath]: fileList[i].url.split("static/")[1] + }) + } + delete that.data.form.installtime + delete that.data.form.createtime + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - paste() { - var _this = this; - wx.getClipboardData({ - success: function (res) { - var longitude = 'form.longitude'; - var latitude = 'form.latitude'; - var longitude84 = 'form.longitude84'; - var latitude84 = 'form.latitude84'; - _this.setData({ - [longitude]: parseFloat(res.data.split(",", 4)[1]).toFixed(6), - [latitude]: parseFloat(res.data.split(",", 4)[0]).toFixed(6), - [longitude84]: "" == (res.data.split(",", 4)[3]) ? "" : parseFloat(res.data.split(",", 4)[3]).toFixed(6), - [latitude84]: "" == (res.data.split(",", 4)[2]) ? "" : parseFloat(res.data.split(",", 4)[2]).toFixed(6), - longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), - latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), - }); - } - }) - }, - selectValue(value) { - var that = this; - var wellType = 'form.welltype'; - that.setData({ - [wellType]: value.detail - }) - }, - selectpersonValue(event) { - var that = this; - var installPerson = 'form.installperson'; - that.setData({ - [installPerson]: event.detail - }) - }, - selectprojectValue(event) { - var that = this; - var project = 'form.project'; - that.setData({ - [project]: event.detail, - showMask: true - }) - }, - open() { - this.setData({ - showMask: true - }) - }, - close() { - this.setData({ - showMask: false - }) - }, - afterRead(event) { - var _this = this; - const { - file - } = event.detail; - const { - fileList = [] - } = _this.data; - var convertpath = ""; - wx.compressImage({ - src: event.detail.file.path, - quality: 25, - success: function (res) { - convertpath = res.tempFilePath; - wx.uploadFile({ - url: app.globalData.httpsUrl + "appDeviceAdd/fileUploadMarker", - filePath:convertpath, - name: 'file', - formData: { - 'text': "编号:" + _this.data.form.devcode + "经度:" + _this.data.form.longitude + "纬度:" + _this.data.form.latitude - }, - header: { - "Content-Type": "multipart/form-data", - 'accept': 'application/json', - }, - success(res) { - if (res.data) { - var url = JSON.parse(res.data); - fileList.push({ - ...file, - url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - }); - _this.setData({ - fileList - }); - } - } + success(res) { + if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + if (res.confirm) { + wx.switchTab({ + url: that.data.pageName }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') } - }) - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // // var base64 = "data:image/png;base64," + wx.getFileSystemManager().readFileSync(convertpath, 'base64'); - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: convertpath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // // wx.cloud.callFunction({ - // // name: 'uploadFile', - // // data: { - // // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // // fileBase64: base64 - // // }, - // // success: function (res) { - // // if (res.result) { - // // fileList.push({ - // // ...file, - // // url: app.globalData.url + "static/" + res.result.data.replace(/\\/g, "/") - // // }); - // // _this.setData({ - // // fileList - // // }); - // // } - // // }, - // // complete: res => { - // // }, - // // }) - // } - // }); + } + }) + } + }, + fail(err) { + wx.showToast({ + title: "提交失败", + }) + } + }) + }, + //报存录入的input信息 + confirm(event) { + var that = this; + var formValue = event.detail.value; + var formName = event.target.dataset.id; + var fromN = 'form.' + [formName]; + that.setData({ + [fromN]: formValue + }) + }, + + //扫码 + scan() { + + wx.scanCode({ + success(res) { + console.log(res) + } + }) + }, + //粘贴经纬度 + paste() { + var _this = this; + wx.getClipboardData({ + success: function (res) { + var longitude = 'form.longitude'; + var latitude = 'form.latitude'; + var longitude84 = 'form.longitude84'; + var latitude84 = 'form.latitude84'; + _this.setData({ + [longitude]: parseFloat(res.data.split(",", 4)[1]).toFixed(6), + [latitude]: parseFloat(res.data.split(",", 4)[0]).toFixed(6), + [longitude84]: "" == (res.data.split(",", 4)[3]) ? "" : parseFloat(res.data.split(",", 4)[3]).toFixed(6), + [latitude84]: "" == (res.data.split(",", 4)[2]) ? "" : parseFloat(res.data.split(",", 4)[2]).toFixed(6), + longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), + latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), + }); + } + }) + }, + selectValue(value) { + var that = this; + var wellType = 'form.welltype'; + that.setData({ + [wellType]: value.detail + }) + }, + //运维人员默认为登录人 + // selectpersonValue(event) { + // var that = this; + // var installPerson = 'form.installperson'; + // that.setData({ + // [installPerson]: event.detail + // }) + // }, + selectprojectValue(event) { + var that = this; + var project = 'form.project'; + that.setData({ + [project]: event.detail, + showMask: true + }) + }, + + open() { + this.setData({ + showMask: true + }) + }, + //隐藏textarea,防止遮挡 + close() { + this.setData({ + showMask: false + }) + }, + //上传照片 + afterRead(event) { + var _this = this; + const { + file + } = event.detail; + const { + fileList = [] + } = _this.data; + var convertpath = ""; + wx.compressImage({ + src: event.detail.file.path, + quality: 25, + success: function (res) { + convertpath = res.tempFilePath; + wx.uploadFile({ + url: app.globalData.httpsUrl + "appDeviceAdd/fileUploadMarker", + filePath: convertpath, + name: 'file', + formData: { + 'text': "编号:" + _this.data.form.devcode + "经度:" + _this.data.form.longitude + "纬度:" + _this.data.form.latitude }, - deletePhoto(event) { - var that = this - var image_index = event.detail.index - var fileList_new = that.data.fileList; - wx.showModal({ - content: '确定删除照片?', - success: function (res) { - if (res.confirm) { - fileList_new.splice(image_index, 1); - that.setData({ - fileList: fileList_new - }) - wx.cloud.callFunction({ - name: 'deletePhoto', - data: { - url: app.globalData.url + "appDeviceLog/deletePhoto", - devcode: that.data.form.devcode, - pathIndex: image_index - }, - success: function (res) {}, - complete: res => {}, - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + "Content-Type": "multipart/form-data", + 'accept': 'application/json', }, - }) \ No newline at end of file + success(res) { + if (res.data) { + var url = JSON.parse(res.data); + fileList.push({ + ...file, + url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") + }); + _this.setData({ + fileList + }); + } + } + }) + } + }) + }, + //删除照片 + deletePhoto(event) { + var that = this + var image_index = event.detail.index + var fileList_new = that.data.fileList; + wx.showModal({ + content: '确定删除照片?', + success: function (res) { + if (res.confirm) { + fileList_new.splice(image_index, 1); + that.setData({ + fileList: fileList_new + }) + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deletePhoto", + data: { + devcode: that.data.form.devcode + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) {} + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } +}) \ No newline at end of file diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.wxml b/miniprogram/pages/addDevicelog/addDeviceLog.wxml index 38620d4..b10cc7d 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.wxml +++ b/miniprogram/pages/addDevicelog/addDeviceLog.wxml @@ -1,15 +1,21 @@ - + + + + + - + - - + + - - + + - + @@ -39,24 +45,25 @@ - - - + + + - + - + + @@ -64,7 +71,7 @@ - + @@ -79,9 +86,9 @@ - + - 保存 + 保存 diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.wxss b/miniprogram/pages/addDevicelog/addDeviceLog.wxss index ee0b75c..08d5fd7 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.wxss +++ b/miniprogram/pages/addDevicelog/addDeviceLog.wxss @@ -24,6 +24,17 @@ display: flex; align-items: center; } +.map-view{ + width: 750rpx; + height: 485rpx; + position: fixed; + top: 0px; + left: 0px; + z-index: 999; +} +.content{ + margin-top: 495rpx; +} .left { width: 210rpx; diff --git a/miniprogram/pages/addFunction/addFunction.js b/miniprogram/pages/addFunction/addFunction.js deleted file mode 100644 index 4966be3..0000000 --- a/miniprogram/pages/addFunction/addFunction.js +++ /dev/null @@ -1,60 +0,0 @@ -// pages/addFunction/addFunction.js - -const code = `// 云函数入口函数 -exports.main = (event, context) => { - console.log(event) - console.log(context) - return { - sum: event.a + event.b - } -}` - -Page({ - - data: { - result: '', - canIUseClipboard: wx.canIUse('setClipboardData'), - }, - - onLoad: function (options) { - - }, - - copyCode: function() { - wx.setClipboardData({ - data: code, - success: function () { - wx.showToast({ - title: '复制成功', - }) - } - }) - }, - - testFunction() { - wx.cloud.callFunction({ - name: 'sum', - data: { - a: 1, - b: 2 - }, - success: res => { - wx.showToast({ - title: '调用成功', - }) - this.setData({ - result: JSON.stringify(res.result) - }) - }, - fail: err => { - wx.showToast({ - icon: 'none', - title: '调用失败', - }) - console.error('[云函数] [sum] 调用失败:', err) - } - }) - }, - -}) - diff --git a/miniprogram/pages/addFunction/addFunction.json b/miniprogram/pages/addFunction/addFunction.json deleted file mode 100644 index a9a50c5..0000000 --- a/miniprogram/pages/addFunction/addFunction.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "navigationBarTitleText": "云函数指引", - "usingComponents": {} -} \ No newline at end of file diff --git a/miniprogram/pages/addFunction/addFunction.wxml b/miniprogram/pages/addFunction/addFunction.wxml deleted file mode 100644 index 3a10626..0000000 --- a/miniprogram/pages/addFunction/addFunction.wxml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - 测试云函数 - - - 期望输出:{"sum":3} - - - 调用结果:{{result}} - - - - - 新增云函数 - 1. 在云函数根目录 cloudfunctions 上右键选择新建云函数,命名为 sum - 2. 在创建的 cloudfunctions/sum/index.js 文件中添加如下代码 - - - 3. 在 cloudfunctions/sum 目录上右键上传并部署 - 4. 点击测试云函数测试 - 5. 打开云开发云函数管理页,选择 sum 云函数 - 6. 查看 sum 的调用日志 - 进阶:可在云函数中使用 wx-server-sdk 操作数据库,文件存储和调用其他云函数,详见文档 - - - diff --git a/miniprogram/pages/addFunction/addFunction.wxss b/miniprogram/pages/addFunction/addFunction.wxss deleted file mode 100644 index 7ac8619..0000000 --- a/miniprogram/pages/addFunction/addFunction.wxss +++ /dev/null @@ -1,3 +0,0 @@ -/* pages/addFunction/addFunction.wxss */ - -@import "../../style/guide.wxss"; \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.js b/miniprogram/pages/applog/applog.js index 0e8c185..189e61f 100644 --- a/miniprogram/pages/applog/applog.js +++ b/miniprogram/pages/applog/applog.js @@ -13,98 +13,25 @@ isSeach: "false", params: {}, total: 0, - show: false + show: false, + delBtnWidth: 100, //删除按钮宽度单位(rpx) + activeIndex: -1, + list_style: '' }, - - touchE: function (e) { - // console.log(e); - var that = this - if (e.changedTouches.length == 1) { - //手指移动结束后触摸点位置的X坐标 - var endX = e.changedTouches[0].clientX; - //触摸开始与结束,手指移动的距离 - var disX = that.data.startX - endX; - var delBtnWidth = that.data.delBtnWidth; - //如果距离小于删除按钮的1/2,不显示删除按钮 - var txtStyle = disX > delBtnWidth / 2 ? "left:-" + delBtnWidth + "rpx" : "left:0rpx"; - - //获取手指触摸的是哪一项 - var index = e.currentTarget.dataset.index; - var list = that.data.deviceloglist; - list[index].txtStyle = txtStyle; - //更新列表的状态 - that.setData({ - deviceloglist: list - }); - } - }, - //手指触摸动作开始 记录起点X坐标 - touchstart: function (e) { - //开始触摸时 重置所有删除 - this.data.deviceloglist.forEach(function (v, i) { - if (v.isTouchMove) //只操作为true的 - v.isTouchMove = false; - }) - this.setData({ - startX: e.changedTouches[0].clientX, - startY: e.changedTouches[0].clientY, - deviceloglist: this.data.deviceloglist - }) - }, - //滑动事件处理 - touchmove: function (e) { - var that = this, - index = e.currentTarget.dataset.index, //当前索引 - startX = that.data.startX, //开始X坐标 - startY = that.data.startY, //开始Y坐标 - touchMoveX = e.changedTouches[0].clientX, //滑动变化坐标 - touchMoveY = e.changedTouches[0].clientY, //滑动变化坐标 - //获取滑动角度 - angle = that.angle({ - X: startX, - Y: startY - }, { - X: touchMoveX, - Y: touchMoveY - }); - that.data.deviceloglist.forEach(function (v, i) { - v.isTouchMove = false - //滑动超过30度角 return - if (Math.abs(angle) > 30) return; - if (i == index) { - if (touchMoveX > startX) //右滑 - v.isTouchMove = false - else //左滑 - v.isTouchMove = true - } - }) - //更新数据 - that.setData({ - deviceloglist: that.data.deviceloglist - }) - }, - /** - * 计算滑动角度 - * @param {Object} start 起点坐标 - * @param {Object} end 终点坐标 - */ - angle: function (start, end) { - var _X = end.X - start.X, - _Y = end.Y - start.Y - //返回角度 /Math.atan()返回数字的反正切值 - return 360 * Math.atan(_Y / _X) / (2 * Math.PI); - }, - /** - * 生命周期函数--监听页面加载var_this=this; - */ onLoad: function (options) { - if (options.params) { this.setData({ params: JSON.parse(options.params), isSeach: "true" }) this.initPages() + }else{ + this.setData({ + show: false + }) + //清空参数,重新加载 + this.clearParams(); + this.initPages(); } }, @@ -116,20 +43,33 @@ }, + //点击tabBar事件 + onTabItemTap(item) { + //隐藏历史显示总记录条数 + this.setData({ + show: false + }) + //清空参数,重新加载 + this.clearParams(); + this.initPages(); + }, + + /** * 生命周期函数--监听页面显示 */ onShow: function (options) { - this.setData({ - show:false - }) - if (this.data.isSeach == "false") { - this.clearParams(); - this.initPages(); - } - this.setData({ - isSeach: "false" - }) + + // this.setData({ + // show: false + // }) + // if (this.data.isSeach == "false") { + // this.clearParams(); + // this.initPages(); + // } + // this.setData({ + // isSeach: "false" + // }) }, /** @@ -167,6 +107,119 @@ }, + + //手指触摸动作开始 记录起点X坐标 + touchstart: function (e) { + //开始触摸时 重置所有删除 + this.data.deviceloglist.forEach(function (v, i) { + if (v.isTouchMove) //只操作为true的 + v.isTouchMove = false; + }) + this.setData({ + startX: e.changedTouches[0].clientX, + startY: e.changedTouches[0].clientY, + deviceloglist: this.data.deviceloglist + }) + }, + + //滑动事件处理 + touchmove: function (e) { + var that = this, + index = e.currentTarget.dataset.index, //当前索引 + startX = that.data.startX, //开始X坐标 + startY = that.data.startY, //开始Y坐标 + touchMoveX = e.changedTouches[0].clientX, //滑动变化坐标 + touchMoveY = e.changedTouches[0].clientY, //滑动变化坐标 + //获取滑动角度 + angle = that.angle({ + X: startX, + Y: startY + }, { + X: touchMoveX, + Y: touchMoveY + }); + that.data.deviceloglist.forEach(function (v, i) { + // v.isTouchMove = false + //滑动超过30度角 return + if (Math.abs(angle) > 30) return; + if (i == index) { + if (touchMoveX > startX) //右滑 + v.isTouchMove = false + else //左滑 + v.isTouchMove = true + } + }) + //更新数据 + that.setData({ + deviceloglist: that.data.deviceloglist + }) + }, + + /** + * 计算滑动角度 + * @param {Object} start 起点坐标 + * @param {Object} end 终点坐标 + */ + angle: function (start, end) { + var _X = end.X - start.X, + _Y = end.Y - start.Y + //返回角度 /Math.atan()返回数字的反正切值 + return 360 * Math.atan(_Y / _X) / (2 * Math.PI); + }, + + //删除事件 + delItem: function (e) { + if(app.globalData.role!='repair'){ + wx.showToast({ + icon: 'none', + title: '无权限删除', + duration:2000 + }) + return false + } + var that = this + wx.showModal({ + content: '是否删除?', + success: function (res) { + if (res.confirm) { + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/delete", + data: { + appDeviceAddId: e.currentTarget.dataset.devid + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if(res.data.code=='200'){ + that.data.deviceloglist.splice(e.currentTarget.dataset.index, 1) + that.setData({ + deviceloglist: that.data.deviceloglist, + total: that.data.deviceloglist.length + }) + wx.showToast({ + title: '删除成功!', + icon: 'none', + duration: 1000 + }) + } + }, + fail(err) { + wx.showToast({ + title: '删除失败!', + icon: 'none', + duration: 2000 + }) + } + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + }, + showLoading: function (message) { if (wx.showLoading) { // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 @@ -199,95 +252,105 @@ deviceloglist: [] }) }, + //查询列表数据 initPages: function () { var that = this + that.setData({ + show: false + }) var offsetValue = that.data.deviceloglist.length % 15 > 0 ? parseInt(that.data.deviceloglist.length / 15) + 2 : parseInt(that.data.deviceloglist.length / 15) + 1 - wx.cloud.callFunction({ - name: 'devicelog', + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/listPage", data: { devcode: that.data.params.devcode, devtype: that.data.params.devtype, installtimeFmt: that.data.params.installtimeFmt, project: that.data.params.project, installPerson: that.data.params.installPerson, - url: app.globalData.url + "appDeviceLog/listPage", limit: 15, offset: offsetValue }, - }).then(res => { - if (res.result.data.rows.length > 0) { - var resultJson = res.result - that.setData({ - deviceloglist: that.data.deviceloglist.concat(resultJson.data.rows) - }) - } else if (that.data.deviceloglist.length > 0) { - that.setData({ - show: true, - total: that.data.deviceloglist.length - }) - wx.showToast({ - title: '数据已全部加载完', - icon: 'none', - duration: 2000 - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.data.rows.length > 0) { + var resultJson = res.data + var listArr = resultJson.data.rows + listArr.forEach(function (v, i) { + listArr[i]['isTouchMove'] = false + }) + that.setData({ + deviceloglist: that.data.deviceloglist.concat(listArr) + }) + } else if (that.data.deviceloglist.length > 0) { + that.setData({ + show: true, + total: that.data.deviceloglist.length + }) + wx.showToast({ + title: '数据已全部加载完', + icon: 'none', + duration: 2000 + }) + } + if (offsetValue == 1 && res.data.data.rows.length < 15) { + that.setData({ + show: true, + total: that.data.deviceloglist.length + }) + } } - if(offsetValue==1&&res.result.data.rows.length<15){ - that.setData({ - show: true, - total: that.data.deviceloglist.length - }) - } - // console.log(res); - }).catch(err => { - console.error(err); }) + }, addDetail: function (event) { - this.showLoading("数据请求中..."); - wx.cloud.callFunction({ - name: 'deviceDetail', + var that = this + that.showLoading("数据请求中..."); + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deviceDetail", data: { devcode: event.target.dataset.devcode, - url: app.globalData.url + "appDeviceLog/deviceDetail", }, - }).then(res => { - this.hideLoading(); - var resultObject = JSON.parse(res.result); - var pageName = '../applog/applog' - if (resultObject.code == 200) { - wx.navigateTo({ - url: '../addDevicelog/addDeviceLog?detail=' + - JSON.stringify(resultObject.data) + "&pageName=" + pageName - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + that.hideLoading(); + // var resultObject = JSON.parse(res.data); + var resultObject = res.data; + var pageName = '../applog/applog' + if (resultObject.code == 200) { + wx.setStorageSync('resultObject', resultObject.data) + wx.navigateTo({ + url: '../addDevicelog/addDeviceLog?detail=' + "&pageName=" + pageName + }) + } + }, + fail(err) { + that.hideLoading(); } - }).catch(err => { - this.hideLoading() }) + }, add: function (event) { - wx.reLaunch({ - url: '../earth/earth?devcode=' + event.target.dataset.devcode - // url: '../earth/earth' + app.globalData.devcode = event.target.dataset.devcode; + wx.switchTab({ + url: '../earth/earth' }) + // wx.reLaunch({ + // url: '../earth/earth?devcode=' + event.target.dataset.devcode + // // url: '../earth/earth' + // }) }, onSearch: function () { + var _this = this wx.navigateTo({ - url: '../searchLog/searchLog' + url: '../searchLog/searchLog?params=' + JSON.stringify(_this.data.params) }) - }, - // initPages: function () { - // wx.cloud.callFunction({ - // name: 'devicelog' - // }).then(res => { - // var that = this; - // var jsonList = JSON.parse(res.result) - // that.setData({ - // deviceloglist: jsonList.data.rows - // }) - // console.log(res); - // }).catch(err => { - // console.error(err); - // }) - // } + } }) \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.wxml b/miniprogram/pages/applog/applog.wxml index e9a2352..2bfd041 100644 --- a/miniprogram/pages/applog/applog.wxml +++ b/miniprogram/pages/applog/applog.wxml @@ -1,54 +1,59 @@ - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {{item.devcode}} {{item.devicetype}} + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + {{item.devcode}} {{item.devicetype}} + + {{item.project}} {{item.installtime}}- {{item.installperson}} - - - - - + + + + + + 删除 - - - + + - 共计:{{total}}台 - + 共计:{{total}}台 + \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.wxss b/miniprogram/pages/applog/applog.wxss index 6d3428b..e6e8983 100644 --- a/miniprogram/pages/applog/applog.wxss +++ b/miniprogram/pages/applog/applog.wxss @@ -22,16 +22,18 @@ position: fixed; width: 100%; top: 0rpx; + z-index: 9999; /* margin-bottom: 100rpx; */ } .log-list { /* height: 100rpx; */ - /* display: flex; */ - + display: flex; + width: 100%; padding: 2px; margin-top: 2px; border-bottom: 1px solid #e5e5e5; + overflow: hidden } @@ -53,23 +55,29 @@ left: 35%; margin: 20rpx } - .del { - width: 90px; + /* display: flex; */ + width: 100rpx; display: flex; flex-direction: column; align-items: center; justify-content: center; - color: #fff; - -webkit-transform: translateX(90px); - transform: translateX(90px); - -webkit-transition: all 0.4s; + /* -webkit-transform: translateX(100rpx); */ + transform: translateX(100rpx); + /* -webkit-transition: all 0.4s; */ transition: all 0.4s; - font-size: 35rpx; + color: #fff; + background-color: #fe3e2f; +} +.logrow{ + width: 100%; + transform: translateX(100rpx); + /* -webkit-transform: translateX(100px); */ + margin-left: -100rpx; } -.touch-move-active .content, +.touch-move-active .logrow, .touch-move-active .del { - -webkit-transform: translateX(0); - transform: translateX(0); +/* -webkit-transform: translateX(0); */ +transform: translateX(0); } \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.js b/miniprogram/pages/deployFunctions/deployFunctions.js deleted file mode 100644 index a76b144..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.js +++ /dev/null @@ -1,66 +0,0 @@ -// pages/deployFunctions/deployFunctions.js -Page({ - - /** - * 页面的初始数据 - */ - data: { - - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - - }, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { - - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - - }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { - - }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { - - } -}) \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.json b/miniprogram/pages/deployFunctions/deployFunctions.json deleted file mode 100644 index 7fbedab..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "navigationBarTitleText": "部署云函数", - "usingComponents": {} -} \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.wxml b/miniprogram/pages/deployFunctions/deployFunctions.wxml deleted file mode 100644 index 462b6b6..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.wxml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - 调用失败 - - - 请检查 login 云函数是否已部署 - - - - - 部署 login 云函数 - 1. 确保已通过工具栏云开发入口开通云开发 - 2. 在 cloudfunctions/login 目录上右键上传并部署 - 3. 回到首页,重新点击获取 openid - - - - diff --git a/miniprogram/pages/deployFunctions/deployFunctions.wxss b/miniprogram/pages/deployFunctions/deployFunctions.wxss deleted file mode 100644 index c8803e6..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.wxss +++ /dev/null @@ -1,7 +0,0 @@ -/* pages/deployFunctions/deployFunctions.wxss */ - -@import "../../style/guide.wxss"; - -.black { - color: black; -} \ No newline at end of file diff --git a/miniprogram/pages/earth/earth.js b/miniprogram/pages/earth/earth.js index ae0d3f3..376a6e2 100644 --- a/miniprogram/pages/earth/earth.js +++ b/miniprogram/pages/earth/earth.js @@ -21,19 +21,12 @@ show: false, enableSsatellite: false, windowWidth: 0, - longitude: 113.324520, - latitude: 23.099994, - longitude84: 113.324520, - latitude84: 23.099994, - markers: [{ - id: 0, - iconPath: "../../images/locat.png", - latitude: 23.099994, - longitude: 113.324520, - width: 50, - height: 50 - }], - controls: [], + longitude: "116.627340", + latitude: "39.874390", + longitude84: "", + latitude84: "", + markers: [], + controls: [] }, /** @@ -41,39 +34,13 @@ */ onLoad: function (options) { var that = this; - //获取当前坐标(gcj02) - wx.getLocation({ - type: "gcj02", - altitude: true, - success: function (res) { - that.setData({ - latitude: parseFloat(res.latitude).toFixed(6), - longitude: parseFloat(res.longitude).toFixed(6), - // markers: [{ - // latitude: res.latitude, - // longitude: res.longitude, - // }] - }) - //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 - wx.getLocation({ - type: "wgs84", - altitude: true, - success: function (res) { - that.setData({ - latitude84: parseFloat(res.latitude).toFixed(6), - longitude84: parseFloat(res.longitude).toFixed(6) - }) - } - }) - } - }), - - //设置地图组件 - wx.getSystemInfo({ + //设置地图组件 + wx.getSystemInfo({ success(res) { var windowWidth = res.windowWidth var windowHeight = res.windowHeight var query = wx.createSelectorQuery() + var platform =res.platform query.select('#map').boundingClientRect() query.exec(function (res) { that.setData({ @@ -139,10 +106,20 @@ clickable: true }, { id: 7, - iconPath: '../../images/locat.png', + iconPath: '../../images/applocat.png', position: { - left: res[0].width/2, - top: res[0].height/2, + left: res[0].width / 2 - 20, + top: platform=="ios"?res[0].height / 2 - 80:res[0].height / 2 - 40, + width: 40, + height: 40 + }, + clickable: true + }, { + id: 8, + iconPath: '../../images/back.png', + position: { + left: windowWidth - 40, + top: windowHeight - 140, width: 30, height: 30 }, @@ -150,71 +127,15 @@ }] }) }) - + } - }), + }) + // 实例化API核心类 qqmapsdk = new QQMapWX({ key: 'BGPBZ-C5O3P-ROUDR-LWC4J-63EKH-V5FRX' }) - - if (options.devcode) { - var that = this - var devcode = options.devcode - wx.cloud.callFunction({ - name: 'findListByCodes', - data: { - devcodes: devcode, - url: app.globalData.url + "appDeviceAdd/findListByCodes" - }, - }).then(res => { - if (res.result.code == 200) { - var listResultData = res.result.data; - that.setData({ - listData: listResultData - }) - var markersArr = that.data.markers; - for (var i = 0; i < listResultData.length; i++) { - markersArr = markersArr.concat({ - iconPath: "../../images/locat.png", - id: listResultData[i].id, - callout: { - content: listResultData[i].devcode, - fontSize: '14', - // padding: true, - color: '#00000', - borderColor: '#F4EA2A', - bgColor: '#F4EA2A', - borderWidth: 5, - display: 'ALWAYS', - textAlign: 'center', - // borderRadius: 15 - }, - latitude: listResultData[i].latitude, - longitude: listResultData[i].longitude, - width: 40, - height: 40 - }); - } - this.setData({ - markers: markersArr, - latitude: listResultData[0].latitude, - longitude: listResultData[0].longitude, - marker_latitude: listResultData[0].latitude, - marker_longitude: listResultData[0].longitude, - title: listResultData[0].devcode - }) - } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "无法获取设备地理信息!", - icon: 'none', - duration: 2000 - }) - }) - } }, /** @@ -228,6 +149,97 @@ * 生命周期函数--监听页面显示 */ onShow: function () { + //输入设备编号获取marker位置信息 + var that = this; + if ( app.globalData.devcode!="") { + var devcode = app.globalData.devcode + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/findListByCodes", + data: { + devcodes: devcode, + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + app.globalData.devcode=""; + if (res.data.code == 200) { + var listResultData = res.data.data; + that.setData({ + listData: listResultData + }) + var markersArr = that.data.markers; + for (var i = 0; i < listResultData.length; i++) { + markersArr = markersArr.concat({ + iconPath: "../../images/locat.png", + id: Number(listResultData[i].id), + callout: { + content: "编号:"+listResultData[i].devcode+"\r\n位置:"+listResultData[i].position+"\r\n时间:"+listResultData[i].createtime, + fontSize: '14', + padding: true, + color: '#000000', + borderColor: '#F4EA2A', + bgColor: '#F4EA2A', + borderWidth: 5, + display: 'ALWAYS', + textAlign: 'left', + // borderRadius: 15 + }, + latitude: listResultData[i].latitude, + longitude: listResultData[i].longitude, + width: 40, + height: 40 + }); + } + that.setData({ + markers: markersArr, + latitude: listResultData[0].latitude, + longitude: listResultData[0].longitude, + marker_latitude: listResultData[0].latitude, + marker_longitude: listResultData[0].longitude, + title: listResultData[0].devcode + }) + } + }, + fail(err) { + app.globalData.devcode=""; + wx.showToast({ + title: "无法获取设备地理信息!", + icon: 'none', + duration: 2000 + }) + } + }) +} else { + //获取当前坐标(gcj02) + wx.getLocation({ + type: "gcj02", + altitude: true, + success: function (res) { + that.setData({ + latitude: parseFloat(res.latitude).toFixed(6), + longitude: parseFloat(res.longitude).toFixed(6), + // markers: [{ + // latitude: res.latitude, + // longitude: res.longitude, + // }] + }) + //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 + wx.getLocation({ + type: "wgs84", + altitude: true, + success: function (res) { + that.setData({ + latitude84: parseFloat(res.latitude).toFixed(6), + longitude84: parseFloat(res.longitude).toFixed(6) + }) + } + }) + } + }) +} + }, @@ -265,12 +277,46 @@ onShareAppMessage: function () { }, + + //定位出来 + + locationPosition: function () { + var that = this; + //获取当前坐标(gcj02) + wx.getLocation({ + type: "gcj02", + altitude: true, + success: function (res) { + that.setData({ + latitude: parseFloat(res.latitude).toFixed(6), + longitude: parseFloat(res.longitude).toFixed(6), + // markers: [{ + // latitude: res.latitude, + // longitude: res.longitude + // }] + }) + //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 + wx.getLocation({ + type: "wgs84", + altitude: true, + success: function (res) { + that.setData({ + latitude84: parseFloat(res.latitude).toFixed(6), + longitude84: parseFloat(res.longitude).toFixed(6) + }) + } + }) + } + }) + }, + + //加载地图组件 controltap: function (e) { // console.log(e.controlId); //进入添加设备页 if (1 == e.controlId) { wx.setClipboardData({ - data: this.data.latitude + "," + this.data.longitude+ "," + this.data.latitude84+ "," + this.data.longitude84, + data: this.data.latitude + "," + this.data.longitude + "," + this.data.latitude84 + "," + this.data.longitude84, success: function (res) { wx.getClipboardData({ success: function (res) { @@ -282,6 +328,17 @@ } }) } else if (3 == e.controlId) { + //先定位 + // this.locationPosition() + wx.setClipboardData({ + data: this.data.latitude + "," + this.data.longitude + "," + this.data.latitude84 + "," + this.data.longitude84, + success: function (res) { + wx.showToast({ + title: '坐标已获取', + duration: 1000 + }) + } + }) wx.navigateTo({ url: '../addDevice/addDevice' }) @@ -302,32 +359,15 @@ enableSsatellite: !flag }); } else if (6 == e.controlId) { - var that = this; - //获取当前坐标(gcj02) - wx.getLocation({ - type: "gcj02", - altitude: true, - success: function (res) { - that.setData({ - latitude: parseFloat(res.latitude).toFixed(6), - longitude:parseFloat(res.longitude).toFixed(6), - // markers: [{ - // latitude: res.latitude, - // longitude: res.longitude - // }] - }) - //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 - wx.getLocation({ - type: "wgs84", - altitude: true, - success: function (res) { - that.setData({ - latitude84: parseFloat(res.latitude).toFixed(6), - longitude84: parseFloat(res.longitude).toFixed(6) - }) - } - }) - } + //先清marker + this.setData({ + markers: [] + }) + this.locationPosition() + }else if (8 == e.controlId) { + //跳转日志缓存页 + wx.switchTab({ + url: '../applog/applog', }) } }, @@ -343,63 +383,68 @@ }); }, + //获取设备maker leave() { var that = this; if (that.data.devcodes == "") { return false; } - wx.cloud.callFunction({ - name: 'findListByCodes', + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/findListByCodes", data: { - devcodes: that.data.devcodes, - url: app.globalData.url + "appDeviceAdd/findListByCodes" + devcodes: that.data.devcodes }, - }).then(res => { - if (res.result.code == 200) { - var listResultData = res.result.data; - that.setData({ - listData: listResultData - }) - var markersArr = that.data.markers; - for (var i = 0; i < listResultData.length; i++) { - markersArr = markersArr.concat({ - iconPath: "../../images/locat.png", - id: listResultData[i].id, - callout: { - content: listResultData[i].devcode, - fontSize: '14', - // padding: true, - color: '', - borderColor: '#F4EA2A', - bgColor: '#F4EA2A', - borderWidth: 5, - display: 'ALWAYS', - textAlign: 'center', - // borderRadius: 15 - }, - latitude: listResultData[i].latitude, - longitude: listResultData[i].longitude, - width: 40, - height: 40 - }); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var listResultData = res.data.data; + that.setData({ + listData: listResultData + }) + var markersArr = that.data.markers; + for (var i = 0; i < listResultData.length; i++) { + markersArr = markersArr.concat({ + iconPath: "../../images/locat.png", + id: listResultData[i].id, + callout: { + content: "编号:"+listResultData[i].devcode+"\r\n位置:"+listResultData[i].position+"\r\n时间:"+listResultData[i].createtime, + fontSize: '14', + // padding: true, + color: '#212121', + borderColor: '#F4EA2A', + bgColor: '#F4EA2A', + borderWidth: 5, + display: 'ALWAYS', + textAlign: 'left', + // borderRadius: 15 + }, + latitude: listResultData[i].latitude, + longitude: listResultData[i].longitude, + width: 40, + height: 40 + }); + } + that.setData({ + markers: markersArr, + latitude: listResultData[0].latitude, + longitude: listResultData[0].longitude, + marker_latitude: listResultData[0].latitude, + marker_longitude: listResultData[0].longitude, + title: listResultData[0].devcode + }) } - this.setData({ - markers: markersArr, - latitude: listResultData[0].latitude, - longitude: listResultData[0].longitude, - marker_latitude: listResultData[0].latitude, - marker_longitude: listResultData[0].longitude, - title: listResultData[0].devcode + }, + fail(err) { + wx.showToast({ + title: "无法获取设备地理信息!", + icon: 'none', + duration: 2000 }) } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "无法获取设备地理信息!", - icon: 'none', - duration: 2000 - }) }) }, @@ -422,6 +467,8 @@ } }, + + bindregionchange: function (e) { var that = this if (e.causedBy == "drag") { @@ -445,8 +492,8 @@ that.setData({ latitude: parseFloat(latitude).toFixed(6), longitude: parseFloat(longitude).toFixed(6), - latitude84:"", - longitude84:"", + latitude84: "", + longitude84: "", // markers: markersArr }) // mapCtx.moveToLocation(); @@ -465,16 +512,19 @@ qqmapsdk.search({ keyword: this.data.value, success: function (res) { + console.log(res) if (res && res.data) { _this.setData({ isShow: true, tips: res.data }); } + }, + complete: function (res){ + console.log(res); } }) }, - bindSearch: function (e) { var location = e.target.dataset.location; this.setData({ diff --git a/miniprogram/pages/earth/earth.wxml b/miniprogram/pages/earth/earth.wxml index a0db6ef..87474f8 100644 --- a/miniprogram/pages/earth/earth.wxml +++ b/miniprogram/pages/earth/earth.wxml @@ -1,9 +1,10 @@ + - + {{item.title}} {{item.address}} @@ -17,6 +18,6 @@ + placeholder="请输入定位设备编号用换行隔开" autosize border="{{ false }}" /> \ No newline at end of file diff --git a/miniprogram/pages/indexapp/indexapp.js b/miniprogram/pages/indexapp/indexapp.js index 5063372..849dbdb 100644 --- a/miniprogram/pages/indexapp/indexapp.js +++ b/miniprogram/pages/indexapp/indexapp.js @@ -7,9 +7,8 @@ */ data: { - count:1, - show: false, - onshow:true, + count: 1, + onshow: true, value: "", deviceloglist: [], devcode: "", @@ -21,6 +20,7 @@ // iconPath: "../../images/point.png", latitude: 23.099994, longitude: 113.324520, + label:'1', width: 50, height: 50 }], @@ -31,62 +31,26 @@ * 生命周期函数--监听页面加载 */ onLoad: function (options) { - + }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { - + }, /** * 生命周期函数--监听页面显示 */ onShow: function () { - // if( app.globalData.indexCount>1){ - // this.setData({ - // show:false - // }) - // }else{ - // this.showNotice() - // } - if(app.globalData.indexCount==1){ - this.setData({ - show:true - }) - this.showNotice() - } - app.globalData.indexCount+=1 - if(this.data.onshow){ + if (this.data.onshow) { this.initPages(); } }, - - showNotice: function() { - var that = this - var times = 0 - var i = setInterval(function() { - times++ - if (times >= 15) { - that.setData({ - show:false - }) - wx.showTabBar({ - animation: false, - }) - clearInterval(i) - } else { - wx.hideTabBar({ - animation: false, - }) - } - }, 1000) -}, - /** * 生命周期函数--监听页面隐藏 */ @@ -122,16 +86,27 @@ }, jump: function (event) { - var that = this; var latitude = event.target.dataset.pointLat; var longitude = event.target.dataset.pointLon; + let devcode = event.target.dataset.pointCode; that.setData({ latitude: latitude, longitude: longitude, markers: [{ latitude: latitude, - longitude: longitude + longitude: longitude, + callout: { + display:'ALWAYS',// 常显气泡 + content: devcode, //名称文本 + color: '#fff', //文本颜色 + borderRadius: 5, //边框圆角 + borderWidth: 1, //边框宽度 + borderColor: '#0060ff', //边框颜色 + bgColor: '#0060ff', //背景色 + padding: 5, //文本边缘留白 + textAlign: 'center' //文本对齐方式。有效值: left, right, center + } }] }) }, @@ -142,7 +117,7 @@ var devcode = res.result _this.setData({ devcode: devcode, - onshow:false + onshow: false }); _this.searchlogs(devcode) } @@ -151,40 +126,11 @@ onSearch: function (event) { this.setData({ - devcode:event.detail + devcode: event.detail }) this.searchlogs(event.detail) }, - - // bindregionchange: function (e) { - // var that = this - // if (e.causedBy == "drag") { - // var mapCtx = wx.createMapContext("map") - // mapCtx.getCenterLocation({ - // success: function (res) { - // var markersArr = that.data.markers - // for (var i = 0; i < markersArr.length; i++) { - // if (markersArr[i].iconPath == undefined) { - // markersArr.splice(i, 1) - // } - // } - // var latitude = res.latitude - // var longitude = res.longitude - // markersArr = markersArr.concat({ - // latitude: latitude, - // longitude: longitude - // }) - // that.setData({ - // latitude: latitude, - // longitude: longitude, - // markers: markersArr - // }) - // } - // }) - // } - // }, - showLoading: function (message) { if (wx.showLoading) { // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 @@ -211,81 +157,89 @@ } }, + //加载设备运维详细信息 toDetail: function (event) { - this.showLoading("数据加载中...") - wx.cloud.callFunction({ - name: 'deviceDetail', + var that = this + that.showLoading("数据加载中...") + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deviceDetail", data: { devcode: event.target.dataset.devcode, - url: app.globalData.url + "appDeviceLog/deviceDetail", }, - }).then(res => { - this.hideLoading(); - var resultObject = JSON.parse(res.result); - var pageName='../indexapp/indexapp' - if (resultObject.code == 200) { - wx.navigateTo({ - url: '../addDevicelog/addDeviceLog?detail=' + - JSON.stringify(resultObject.data)+'&pageName='+pageName - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + that.hideLoading(); + var resultObject = res.data; + var pageName = '../indexapp/indexapp' + if (resultObject.code == 200) { + wx.setStorageSync('resultObject', resultObject.data) + wx.navigateTo({ + url: '../addDevicelog/addDeviceLog?detail=' +'&pageName=' + pageName + }) + } + }, + fail(err){ + that.hideLoading(); } - }).catch(err => { - this.hideLoading(); }) }, + //加载列表 getlogs: function (devcode) { var that = this - wx.cloud.callFunction({ - name: 'devicelog', + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/listPage", data: { devcode: devcode, - url: app.globalData.url + "appDeviceLog/listPage", limit: 100, offset: that.data.deviceloglist.length % 100 > 0 ? parseInt(that.data.deviceloglist.length / 100) + 2 : parseInt(that.data.deviceloglist.length / 100) + 1 }, - }).then(res => { - if (res.result) { - // var resultJson = JSON.parse(res.result) - var resultJson = res.result - that.setData({ - deviceloglist: that.data.deviceloglist.concat(resultJson.data.rows) - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + // var resultJson = JSON.parse(res.result) + var resultJson = res.data + that.setData({ + deviceloglist: that.data.deviceloglist.concat(resultJson.data.rows) + }) + } } - console.log(res); - }).catch(err => { - console.error(err); }) }, + //查询列表 searchlogs: function (devcode) { var that = this - wx.cloud.callFunction({ - name: 'devicelog', + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/listPage", data: { devcode: devcode, - url: app.globalData.url + "appDeviceLog/listPage", limit: 100, offset: 1 }, - }).then(res => { - if (res.result) { - var resultJson = res.result - that.setData({ - deviceloglist: resultJson.data.rows, - onshow:true - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var resultJson = res.data + that.setData({ + deviceloglist: resultJson.data.rows, + onshow: true + }) + } } - console.log(res); - }).catch(err => { - console.error(err); }) }, initPages: function () { var that = this; - that.setData({ - devcode: "" - }); wx.getLocation({ type: "gcj02", success: function (res) { @@ -302,6 +256,6 @@ }) } }) - this.searchlogs() + this.data.devcode !== '' ? this.searchlogs(this.data.devcode) : this.searchlogs() }, }) \ No newline at end of file diff --git a/miniprogram/pages/indexapp/indexapp.wxml b/miniprogram/pages/indexapp/indexapp.wxml index 69322a0..f65b082 100644 --- a/miniprogram/pages/indexapp/indexapp.wxml +++ b/miniprogram/pages/indexapp/indexapp.wxml @@ -1,8 +1,12 @@ + + + + - @@ -32,9 +36,15 @@ - + + + + + + + @@ -46,14 +56,14 @@ - + - - + diff --git a/miniprogram/pages/indexapp/indexapp.wxss b/miniprogram/pages/indexapp/indexapp.wxss index b18706a..fc27fcb 100644 --- a/miniprogram/pages/indexapp/indexapp.wxss +++ b/miniprogram/pages/indexapp/indexapp.wxss @@ -128,6 +128,7 @@ .noticeClass{ height: 2300rpx; width: 750rpx; + overflow-y:hidden; } @@ -148,14 +149,14 @@ } +/* .vanstyle{ + button: not([size='mini']) { + user agent stylesheetmin-height: 40px; + width: 650rpx; + margin-left: 20rpx; + margin-right: auto; + + } + +} */ -/* .van-enter-active-class, -.van-leave-active-class { - transition-property: background-color, transform; -} - -.van-enter-class, -.van-leave-to-class { - background-color: red; - transform: rotate(-360deg) translate3d(-100%, -100%, 0); -} */ \ No newline at end of file diff --git a/miniprogram/pages/log/log.js b/miniprogram/pages/log/log.js deleted file mode 100644 index 83ba349..0000000 --- a/miniprogram/pages/log/log.js +++ /dev/null @@ -1,66 +0,0 @@ -// pages/log/log.js -Page({ - - /** - * 页面的初始数据 - */ - data: { - - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - - }, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { - - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - - }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { - - }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { - - } -}) \ No newline at end of file diff --git a/miniprogram/pages/log/log.json b/miniprogram/pages/log/log.json deleted file mode 100644 index 8835af0..0000000 --- a/miniprogram/pages/log/log.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "usingComponents": {} -} \ No newline at end of file diff --git a/miniprogram/pages/log/log.wxml b/miniprogram/pages/log/log.wxml deleted file mode 100644 index a510ad6..0000000 --- a/miniprogram/pages/log/log.wxml +++ /dev/null @@ -1,2 +0,0 @@ - -pages/log/log.wxml diff --git a/miniprogram/pages/log/log.wxss b/miniprogram/pages/log/log.wxss deleted file mode 100644 index 23db318..0000000 --- a/miniprogram/pages/log/log.wxss +++ /dev/null @@ -1 +0,0 @@ -/* pages/log/log.wxss */ \ No newline at end of file diff --git a/miniprogram/pages/login/login.js b/miniprogram/pages/login/login.js index a4074e7..cb0542a 100644 --- a/miniprogram/pages/login/login.js +++ b/miniprogram/pages/login/login.js @@ -1,11 +1,14 @@ // miniprogram/pages/login/login.js +var app = getApp() Page({ /** * 页面的初始数据 */ data: { - windowWidth:"" + windowWidth: "", + time: 15 * 1000, + showTime: false }, /** @@ -20,9 +23,9 @@ */ onReady: function () { this.setData({ - windowWidth:wx.getSystemInfoSync().windowWidth + windowWidth: wx.getSystemInfoSync().windowWidth }) - + }, /** @@ -66,14 +69,158 @@ onShareAppMessage: function () { }, + + + showLoading: function (message) { + if (wx.showLoading) { + // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 + wx.showLoading({ + title: message, + mask: true + }); + } else { + // 低版本采用Toast兼容处理并将时间设为20秒以免自动消失 + wx.showToast({ + title: message, + icon: 'loading', + mask: true, + duration: 20000 + }); + } + }, + hideLoading: function () { + if (wx.hideLoading) { + // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 + wx.hideLoading(); + } else { + wx.hideToast(); + } + }, + + //注册 loginClick: function () { + var that = this + that.showLoading("授权中...") + wx.login({ + success: function (res) { + if (res.code) { + wx.request({ + url: app.globalData.httpsUrl + "appUserOpenid/login", + data: { + code: res.code + }, + success: function (res) { + app.globalData.openid = res.data.data + wx.getUserInfo({ + success: (res) => { + var nickname = res.userInfo.nickName; + app.globalData.nickName = nickname; + //openid绑定昵称存入后台 + wx.request({ + url: app.globalData.httpsUrl + "appUserOpenid/add", + data: { + attr: nickname, + openid: app.globalData.openid + }, + success: function (res) { + that.hideLoading(); + wx.showToast({ + title: res.data.data+",\r\n请从正式版入口登录!", + icon: 'none', + duration: 2000 + }) - wx.navigateTo({ - - url: '../farmermain/farmermain', - + // //授权成功后跳转 + // wx.switchTab({ + // url: '../indexapp/indexapp' + // }) + } + }) + }, + fail: function (err) { + that.hideLoading(); + } + }) + }, + fail: function (res) { + that.hideLoading(); + wx.showToast({ + title: '服务器异常', + }) + } + }) + } + }, + fail: function (res) { + that.hideLoading(); + } }) + }, + //登录验证 + loginValidate: function () { + var that = this + that.showLoading("登录中...") + wx.login({ + success: function (res) { + if (res.code) { + console.info(res); + wx.request({ + url: app.globalData.httpsUrl + "appUserOpenid/login", + data: { + code: res.code + }, + success: function (res) { + app.globalData.openid = res.data.data + wx.request({ + url: app.globalData.httpsUrl + "appUserOpenid/validate", + data: { + openid: app.globalData.openid + }, + success: function (res) { + that.hideLoading(); + if (res.data.data) { + app.globalData.userName = res.data.data.attr1 == '' ? res.data.data.attr : res.data.data.attr1 + app.globalData.nickName = res.data.data.attr + app.globalData.role = res.data.data.role + wx.navigateTo({ + url: '../notice/notice' + }) + } else { + wx.showToast({ + icon: 'none', + title: '请联系管理员授权', + duration: 2000 + }) + } + }, + fail: function (err) { + that.hideLoading(); + wx.showToast({ + title: '验证失败', + }) + } + }) + }, + fail: function (res) { + that.hideLoading(); + wx.showToast({ + title: '服务器异常', + }) + } + }) + } + }, + fail: function (res) { + that.hideLoading(); + } + }) + }, + + finished() { + this.setData({ + showTime: true + }) }, onClickSubmit: function () { diff --git a/miniprogram/pages/login/login.json b/miniprogram/pages/login/login.json index 8835af0..f2043a3 100644 --- a/miniprogram/pages/login/login.json +++ b/miniprogram/pages/login/login.json @@ -1,3 +1,8 @@ { - "usingComponents": {} + "usingComponents": { + "van-count-down": "../../miniprogram_npm/@vant/weapp/count-down", + "van-button": "../../miniprogram_npm/@vant/weapp/button" + }, + "navigationBarBackgroundColor": "#E6D480", + "disableScroll":true } \ No newline at end of file diff --git a/miniprogram/pages/login/login.wxml b/miniprogram/pages/login/login.wxml index c69df42..cf2ec72 100644 --- a/miniprogram/pages/login/login.wxml +++ b/miniprogram/pages/login/login.wxml @@ -1,21 +1,46 @@ + - + + + - + + + +    本程序为施工日志管理小程序,为航天二院智慧市 +政技术研究室内部系统,不对外开放。出于对数据信 +息安全的考虑,在您首次使用小程序时,请先对小程 +序进行授权,授权后的用户可以正常对小程序进行编 +辑,谢谢您的配合! + + + + + + + + 授权/登录 + + + - + + + diff --git a/miniprogram/pages/login/login.wxss b/miniprogram/pages/login/login.wxss index ca77568..b9fa569 100644 --- a/miniprogram/pages/login/login.wxss +++ b/miniprogram/pages/login/login.wxss @@ -54,7 +54,8 @@ } .form .submit { - margin-top: 80rpx; + + /* margin-top: 80rpx; */ color: #fff; border: 2rpx solid #FFB90F; background-color: #FFB90F; @@ -63,10 +64,30 @@ } .login_image { - width: 200rpx; - height: 200rpx; - padding-top: 100rpx; - padding-left: 250rpx; + width: 750rpx; + height: 360rpx; + /* height: 2300rpx; */ + /* padding-top: 100rpx + padding-left: 250rpx; */ +} +.bottom_image { + width: 750rpx; + height: 32%; + position: fixed; + bottom: 0px; + /* padding-top: 100rpx + padding-left: 250rpx; */ +} +.cover{ + position: fixed; + top: 0rpx; + margin-left: 290rpx; + text-align:center; + font-size: 50rpx; + color: #FFCF00; + width: 750rpx; + z-index:9999; + } -} \ No newline at end of file + \ No newline at end of file diff --git a/cloudfunctions/project.config.json b/cloudfunctions/project.config.json new file mode 100644 index 0000000..2b3119a --- /dev/null +++ b/cloudfunctions/project.config.json @@ -0,0 +1,28 @@ +{ + "appid": "wx2cef527a000f87c9", + "compileType": "miniprogram", + "libVersion": "2.27.3", + "packOptions": { + "ignore": [], + "include": [] + }, + "setting": { + "coverView": true, + "es6": true, + "postcss": true, + "minified": true, + "enhance": true, + "showShadowRootInWxmlPanel": true, + "packNpmRelationList": [], + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + } + }, + "condition": {}, + "editorSetting": { + "tabIndent": "insertSpaces", + "tabSize": 4 + } +} \ No newline at end of file diff --git a/cloudfunctions/project.private.config.json b/cloudfunctions/project.private.config.json new file mode 100644 index 0000000..42ff49d --- /dev/null +++ b/cloudfunctions/project.private.config.json @@ -0,0 +1,7 @@ +{ + "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", + "projectname": "cloudfunctions", + "setting": { + "compileHotReLoad": true + } +} \ No newline at end of file diff --git a/miniprogram/app.js b/miniprogram/app.js index 51d56f3..50a8a54 100644 --- a/miniprogram/app.js +++ b/miniprogram/app.js @@ -18,13 +18,15 @@ // this.globalData = {} }, globalData: { - // url: "http://111.198.10.15:11604/", - httpsUrl: "https://logapi.smartlog.work/", - httpsTestUrl: "https://smartlog.work/prodapi4test/", - url: "http://139.198.18.188:8083/", + httpsUrl: "https://logapi.smartlog.work/", + // httpsUrl: "http://139.198.18.188:8083/", // url: "http://127.0.0.1:8083/", - // httpsUrl: "http://127.0.0.1:8083/", + //httpsUrl: "http://127.0.0.1:8083/", openid: null, - indexCount:1 - }, + indexCount:1, + nickName:"", + userName:"", + role:"", + devcode:"" + } }) diff --git a/miniprogram/app.json b/miniprogram/app.json index d23f798..2b6db76 100644 --- a/miniprogram/app.json +++ b/miniprogram/app.json @@ -1,15 +1,17 @@ { "cloud": true, "pages": [ + "pages/login/login", "pages/indexapp/indexapp", "pages/earth/earth", "pages/applog/applog", "pages/addDevice/addDevice", "pages/addDevicelog/addDeviceLog", - "pages/searchLog/searchLog" + "pages/searchLog/searchLog", + "pages/notice/notice" ], "window": { - "backgroundColor": "#F6F6F6", + "backgroundColor": "#E6D480", "backgroundTextStyle": "light", "navigationBarBackgroundColor": "#FFCF00", "navigationBarTitleText": "智慧施工", @@ -46,11 +48,11 @@ "desc": "你的位置信息将用于小程序位置接口的效果展示" } }, + "requiredPrivateInfos": ["getLocation", "chooseLocation"], "networkTimeout": { "request": 30000, "connectSocket": 30000, "uploadFile": 30000, "downloadFile": 30000 - }, - "style": "v2" + } } \ No newline at end of file diff --git a/miniprogram/images/applocat.png b/miniprogram/images/applocat.png new file mode 100644 index 0000000..fe49f54 --- /dev/null +++ b/miniprogram/images/applocat.png Binary files differ diff --git a/miniprogram/images/back.png b/miniprogram/images/back.png new file mode 100644 index 0000000..32ac82d --- /dev/null +++ b/miniprogram/images/back.png Binary files differ diff --git a/miniprogram/images/bottom.png b/miniprogram/images/bottom.png new file mode 100644 index 0000000..d910e98 --- /dev/null +++ b/miniprogram/images/bottom.png Binary files differ diff --git a/miniprogram/images/header.png b/miniprogram/images/header.png new file mode 100644 index 0000000..6ea222e --- /dev/null +++ b/miniprogram/images/header.png Binary files differ diff --git a/miniprogram/images/login.png b/miniprogram/images/login.png index 8b73cc0..6471c46 100644 --- a/miniprogram/images/login.png +++ b/miniprogram/images/login.png Binary files differ diff --git a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss index 5a591fb..c9c35b5 100644 --- a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss +++ b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:100%;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:100%}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file +@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:650rpx;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:600rpx}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file diff --git a/miniprogram/pages/addDevice/addDevice.js b/miniprogram/pages/addDevice/addDevice.js index 2783674..78f00b7 100644 --- a/miniprogram/pages/addDevice/addDevice.js +++ b/miniprogram/pages/addDevice/addDevice.js @@ -1,5 +1,7 @@ // miniprogram/pages/addDevice/addDevice.js // import WxValidate from '../../utils/WxValidate.js' +var QQMapWX = require('../../libs/qqmap-wx-jssdk.js'); +var qqmapsdk; var app = getApp() Page({ @@ -11,32 +13,10 @@ canvasWidth: '', longitude: '', latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], + option1: [], personoption1: [], projectoption: [], + devtypeList:[], show: false, form: { devcode: "", @@ -59,7 +39,10 @@ project: "", area: "", street: "", - wellname: "" + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '', }, fileList: [] }, @@ -117,12 +100,14 @@ var that = this; //初始化表单内容为上次填写值 var cacheForms = wx.getStorageSync('cacheList') - if (cacheForms) { + cacheForms.photopath1='' + cacheForms.photopath2='' + cacheForms.photopath3='' + that.data.fileList=[] that.setData({ form: cacheForms, devcode: cacheForms.devcode, - }) } var form = that.data.form @@ -155,55 +140,89 @@ } }) + +//获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + that.setData({ + option1: welltypeArr + }) + } + } +}) + + //获取人员下拉列表 - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/getUser", + data:{ + tips:'repair' }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data.code == 200) { + var users = res.data.data + var personArr = []; + for (var i = 0; i < users.length; i++) { + var person = { + text: users[i].name, + value: users[i].name + }; + personArr.push(person); + } + that.setData({ + personoption1: personArr + }) } - that.setData({ - personoption1: personArr - }) } - }).catch(err => { - console.error(err); - }) + }) + - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - that.setData({ - projectoption: projectArr - }) + success(res){ + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); + } + that.setData({ + projectoption: projectArr + }) + } } - }).catch(err => { - console.error(err); - }) + }) + var installtime = 'form.installtimeFmt'; var dateNow = this.formatDate(); this.setData({ @@ -211,8 +230,40 @@ installtimeFmt: dateNow, [installtime]: dateNow, }); + + + + /** + * 获取设备类型下拉列表 + */ + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/deviceType", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var TypeList = res.data.data + var typeArr = []; + for (var i = 0; i < TypeList.length; i++) { + var type = { + text: TypeList[i].productName, + value: TypeList[i].productName + }; + typeArr.push(type); + } + that.setData({ + devtypeList: typeArr + }) + } + } + }) }, + + + /** * 生命周期函数--监听页面初次渲染完成 */ @@ -280,29 +331,7 @@ }, - - //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 - drawText: function (ctx, str, leftWidth, initHeight, titleHeight, canvasWidth) { - var lineWidth = 0; - var lastSubStrIndex = 0; //每次开始截取的字符串的索引 - for (let i = 0; i < str.length; i++) { - lineWidth += ctx.measureText(str[i]).width; - if (lineWidth > canvasWidth) { - ctx.fillText(str.substring(lastSubStrIndex, i), leftWidth, initHeight); //绘制截取部分 - initHeight = initHeight + leftWidth * 2; //22为字体的高度 - lineWidth = 0; - lastSubStrIndex = i; - // titleHeight += 40; - } - if (i == str.length - 1) { //绘制剩余部分 - ctx.fillText(str.substring(lastSubStrIndex, i + 1), leftWidth, initHeight); - } - } - // // 标题border-bottom 线距顶部距离 - // titleHeight = titleHeight + 10; - // return titleHeight - }, - + //验证表单 formValidate() { if (this.data.form.devcode == "") { @@ -312,27 +341,20 @@ }) return false } - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } if (this.data.form.wellcode == "") { wx.showToast({ icon: 'none', @@ -348,22 +370,10 @@ }) return false } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null) { + + if (this.data.form.installperson == "") { wx.showToast({ icon: 'none', title: '安装人员不能为空!', @@ -408,56 +418,90 @@ } return true; }, + //提交表单 formSubmit: function (event) { + console.log(this.data.form) + //表单参数验证 if (!this.formValidate()) { return false; } var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDevice', + //验证设备编号长度 + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/getDevTypeLength", data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceAdd/add" + code: encodeURI(this.data.form.devicetype) }, - }).then(res => { - if (res.result.code == 500) { - wx.showToast({ - title: '设备编号已安装!', - }) - } else if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - //用于回显 - wx.setStorageSync('cacheList', that.data.form) - //提交成功后提示用户操作 - if (res.confirm) { - wx.switchTab({ - url: '../earth/earth' - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (""==res.data.data ||res.data.data == that.data.form.devcode.length) { + that.saveDevice() + } else { //编号位数不对提示 + wx.showToast({ + icon: 'none', + title: '设备编号位数不对!', + duration: 1000 + }) + return false + } } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "提交失败", - }) }) }, + + //保存设备基本信息 + saveDevice() { + var that = this; + //设置照片路径 + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopathForm = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopathForm]: fileList[i].url.split("static/")[1] + }) + } + //表单提交 + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 500) { + wx.showToast({ + title: '设备编号已安装!', + }) + } else if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + //用于回显 + wx.setStorageSync('cacheList', that.data.form) + //提交成功后提示用户操作 + if (res.confirm) { + wx.switchTab({ + url: '../earth/earth' + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } + }, + fail(err) { + wx.showToast({ + title: '提交失败!', + }) + } + }) + }, + + //input 输入框设置值 confirm(event) { var that = this; var formValue = event.detail.value; @@ -466,8 +510,30 @@ that.setData({ [fromN]: formValue }) + //若输入是设备编号,自动获取设备类型 + if('devcode'==formName){ + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", + data: { + devcode: formValue, + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + that.setData({ + [formDevicetype]: res.data + }); + } + } + }) + } }, + //扫描设备获取编号和设备类型 scan() { var _this = this; wx.scanCode({ @@ -477,23 +543,28 @@ _this.setData({ [formdevcode]: devcode }); - wx.cloud.callFunction({ - name: 'findModeCode', + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", data: { devcode: devcode, - url: app.globalData.url + "appDeviceAdd/findModeCodeByCode" }, - }).then(res => { - if (res.result) { - var formDevicetype = 'form.devicetype' - _this.setData({ - [formDevicetype]: res.result - }); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + _this.setData({ + [formDevicetype]: res.data + }); + } } }) } }) }, + //粘贴经纬度 paste() { var _this = this; wx.getClipboardData({ @@ -510,9 +581,11 @@ longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), }); + _this.showAddress(_this.data.form.longitude,_this.data.form.latitude,_this) } }) }, + //设置经类型 selectValue(value) { var that = this; @@ -521,6 +594,16 @@ [wellType]: value.detail }) }, + + //设置设备类型 + selectDevType(event) { + var that = this; + var devtype = 'form.devicetype'; + that.setData({ + [devtype]: event.detail + }) + }, + //设置运维人员 selectpersonValue(event) { var that = this; var installPerson = 'form.installperson'; @@ -528,6 +611,7 @@ [installPerson]: event.detail }) }, + //设置项目 selectprojectValue(event) { var that = this; var project = 'form.project'; @@ -535,8 +619,41 @@ [project]: event.detail }) }, + showAddress :function(longitude, latitude, self) { + // 实例化腾讯地图API核心类 + qqmapsdk = new QQMapWX({ + key: 'BGPBZ-C5O3P-ROUDR-LWC4J-63EKH-V5FRX'//此处使用你自己申请的key + }) + // 腾讯地图调用接口 + qqmapsdk.reverseGeocoder({ + location: { + latitude: latitude, + longitude: longitude + }, + success: function (res) { + self.setData({ + 'form.area':res.result.address.slice(0,res.result.address.indexOf('区')+1), + 'form.street':res.result.address.slice(res.result.address.indexOf('区')+1) + }) + }, + fail: function (res) { + console.log(res); + }, + complete: function (res) { + } + }); + }, + //上传照片 afterRead(event) { var _this = this; + if (_this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '请先填写设备编号!\r\n否则水印中无编号', + duration: 2000 + }) + return false + } const { file } = event.detail; @@ -576,78 +693,8 @@ }) } }) - // 压缩图片 - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // //获取图片尺寸 - // wx.getImageInfo({ - // src: convertpath, - // success(res) { - // _this.setData({ - // canvasHeight: res.height, - // canvasWidth: res.width - // }) - // var ctx = wx.createCanvasContext('firstCanvas') - - // //将图片src放到cancas内,宽高为图片大小 - // ctx.drawImage(convertpath, 0, 0, res.width, res.height) - // //将声明的时间放入canvas - // ctx.setFontSize(30 * (res.width / 750)) //注意:设置文字大小必须放在填充文字之前,否则不生效 - // ctx.setFillStyle('blue') - // var text = "编号:" + _this.data.form.devcode + "\n经度:" + _this.data.form.longitude + "\n纬度:" + _this.data.form.latitude - // // _this.drawText(ctx,text,20, 70, 5, res.width) - // _this.drawText(ctx, text, 15 * (res.width / 750), 70 * (res.width / 750), 5, res.width) - - // // ctx.fillText(text, 0, 40) - // // ctx.strokeText(_this.data.form.devcode, 0, 30) - // //生成水印图 - // ctx.draw(false, function () { - // wx.canvasToTempFilePath({ - // canvasId: 'firstCanvas', - // success: (res) => { - // wx.compressImage({ - // src: res.tempFilePath, - // quality: 25, - // success: function (res) { - // //上传照片至服务器 - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: res.tempFilePath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // } - // }) - // //// - // } - // }) - // }) - // } - // }) - // } - // }); }, + //删除照片 deletePhoto(event) { var image_index = event.detail.index var fileList_new = this.data.fileList; diff --git a/miniprogram/pages/addDevice/addDevice.wxml b/miniprogram/pages/addDevice/addDevice.wxml index b0977e2..f12c254 100644 --- a/miniprogram/pages/addDevice/addDevice.wxml +++ b/miniprogram/pages/addDevice/addDevice.wxml @@ -5,18 +5,30 @@ - + + + + + + + + + + + + + - - + + - - - + + + @@ -29,13 +41,13 @@ - + - + - + - + @@ -54,8 +66,7 @@ - - + @@ -68,8 +79,8 @@ - - + + - 保存 + 保存 \ No newline at end of file diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.js b/miniprogram/pages/addDevicelog/addDeviceLog.js index cdec71b..a0dc6da 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.js +++ b/miniprogram/pages/addDevicelog/addDeviceLog.js @@ -3,681 +3,665 @@ var app = getApp(); Page({ - /** - * 页面的初始数据 - */ - data: { - pageName: '', - showMask: false, - today: new Date().getTime(), - longitude: '', - latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], - personoption1: [], - projectoption: [], - devcode: "", - deviceMode: "", - installtimeFmt: '', - show: false, - form: { - devcode: "", - wellcode: "", - welltype: "", - welldepth: "", - installheigt: "", - installperson: "", - installtimeFmt: "", - photopath: "", - factory: "", - workmsg: "", - position: "", - description: "", - longitude: "", - latitude: "", - longitude84: "", - latitude84: "", - devicetype: "", - project: "", - area: "", - street: "", - wellname: "" - }, - fileList: [], - detail: "" - }, + /** + * 页面的初始数据 + */ + data: { + pageName: '', + showMask: false, + today: new Date().getTime(), + longitude: '', + latitude: '', + option1: [], + personoption1: [], + projectoption: [], + devcode: "", + deviceMode: "", + installtimeFmt: '', + show: false, + form: { + devcode: "", + wellcode: "", + welltype: "", + welldepth: "", + installheigt: "", + installperson: "", + installtimeFmt: "", + photopath: "", + factory: "", + workmsg: "", + position: "", + description: "", + longitude: "", + latitude: "", + longitude84: "", + latitude84: "", + devicetype: "", + project: "", + area: "", + street: "", + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '' + }, + fileList: [], + detail: "", + markers: [{ + id: 100, + // iconPath: "../../images/point.png", + latitude: '', + longitude: '', + // label:'1', + width: 25, + height: 35 + }], + }, - onDisplay() { - this.setData({ - show: true - }); - }, - onClose() { - this.setData({ - show: false - }); - }, - formatDate() { - var date = new Date(); - // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; - var seperator1 = "-"; - var month = date.getMonth() + 1; - var strDate = date.getDate(); - var hour = date.getHours() - var minute = date.getMinutes() - var second = date.getSeconds() - month = month > 9 ? month : "0" + month; - strDate = strDate > 9 ? strDate : "0" + strDate; - hour = hour > 9 ? hour : "0" + hour; - minute = minute > 9 ? minute : "0" + minute; - second = second > 9 ? second : "0" + second; - var currentdate = - date.getFullYear() + - seperator1 + - month + - seperator1 + - strDate + - " " + - hour + ":" + - minute + ":" + - second; - return currentdate; + onDisplay() { + this.setData({ + show: true + }); + }, + onClose() { + this.setData({ + show: false + }); + }, + formatDate() { + var date = new Date(); + // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; + var seperator1 = "-"; + var month = date.getMonth() + 1; + var strDate = date.getDate(); + var hour = date.getHours() + var minute = date.getMinutes() + var second = date.getSeconds() + month = month > 9 ? month : "0" + month; + strDate = strDate > 9 ? strDate : "0" + strDate; + hour = hour > 9 ? hour : "0" + hour; + minute = minute > 9 ? minute : "0" + minute; + second = second > 9 ? second : "0" + second; + var currentdate = + date.getFullYear() + + seperator1 + + month + + seperator1 + + strDate + + " " + + hour + ":" + + minute + ":" + + second; + return currentdate; - }, - onConfirm(event) { - var installtime = 'form.installtimeFmt'; - this.setData({ - show: false, - installtimeFmt: this.formatDate(event.detail), - [installtime]: this.formatDate(event.detail), - }); - }, + }, + onConfirm(event) { + var installtime = 'form.installtimeFmt'; + this.setData({ + show: false, + installtimeFmt: this.formatDate(event.detail), + [installtime]: this.formatDate(event.detail), + }); + }, - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - var _this = this; - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" - }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); - } - _this.setData({ - personoption1: personArr - }) + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + var _this = this; + _this.setData({ + 'markers[0].latitude': Number(wx.getStorageSync('resultObject').latitude) , + 'markers[0].longitude': Number(wx.getStorageSync('resultObject').longitude), + // 'markers[0].label':'10', + 'markers[0].width': 18, + 'markers[0].id':1, + 'markers[0].height': 30, + latitude:Number(wx.getStorageSync('resultObject').latitude), + longitude:Number(wx.getStorageSync('resultObject').longitude) + }) + //获取人员下拉列表 + // wx.request({ + // method: "POST", + // url: app.globalData.httpsUrl + "deviceType/getUser", + // data:{ + // tips:'repair' + // }, + // header: { + // 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + // }, + // success(res) { + // if (res.data.code == 200) { + // var users = res.data.data + // var personArr = []; + // for (var i = 0; i < users.length; i++) { + // var person = { + // text: users[i].name, + // value: users[i].name + // }; + // personArr.push(person); + // } + // _this.setData({ + // personoption1: personArr + // }) + // } + // } + // }) + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); } - }).catch(err => { - console.error(err); - }) - - - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" - }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - _this.setData({ - projectoption: projectArr - }) - } - }).catch(err => { - console.error(err); - }) - - if (options.pageName) { - this.setData({ - pageName: options.pageName - }) - } - - if (options.detail) { - - var formObject = JSON.parse(options.detail); _this.setData({ - form: formObject, - detail: options.detail + projectoption: projectArr }) - - _this.setData({ - ['form.installperson']: "", - ['form.installtimeFmt']: "", - ['form.workmsg']: "", - ['form.description']: "" - }) - - const { - fileList = [] - } = _this.data; - if (formObject.photopath1 != "") { - var file1 = { - url: app.globalData.url + "static/" + formObject.photopath1 - } - fileList.push(file1) - } - if (formObject.photopath2 != "") { - var file2 = { - url: app.globalData.url + "static/" + formObject.photopath2 - } - fileList.push(file2) - } - if (formObject.photopath3 != "") { - var file3 = { - url: app.globalData.url + "static/" + formObject.photopath3 - } - fileList.push(file3) - } - - _this.setData({ - fileList - }); } - var installtime = 'form.installtimeFmt'; - var dateNow = this.formatDate(); - this.setData({ - installtimeFmt: dateNow, - [installtime]: dateNow, - }); - }, + } + }) - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { + //获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + _this.setData({ + option1: welltypeArr + }) + } + } +}) - }, + //跳转时带入参数返回哪页 + if (options.pageName) { + this.setData({ + pageName: options.pageName + }) + } + //跳转时带入参数设备的安装信息 + if (wx.getStorageSync('resultObject')) { + var formObject = wx.getStorageSync('resultObject') + _this.setData({ + form: formObject, + detail: formObject + }) - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { + _this.setData({ + ['form.installperson']: app.globalData.userName, + ['form.installtimeFmt']: "", + ['form.workmsg']: "", + ['form.description']: "" + }) - }, + const { + fileList = [] + } = _this.data; + if (formObject.photopath1 != "") { + var file1 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath1 + } + fileList.push(file1) + } + if (formObject.photopath2 != "") { + var file2 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath2 + } + fileList.push(file2) + } + if (formObject.photopath3 != "") { + var file3 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath3 + } + fileList.push(file3) + } + _this.setData({ + fileList + }); + } + var installtime = 'form.installtimeFmt'; + var dateNow = this.formatDate(); + this.setData({ + installtimeFmt: dateNow, + [installtime]: dateNow, + }); + }, - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, - }, + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + wx.removeStorageSync('resultObject') + }, - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, - }, + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { + }, - }, + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { + }, - }, + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { + }, - }, + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + }, - /** - * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true - **/ + /** + * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true + **/ - isNumber: function (val) { + isNumber: function (val) { - var regPos = /^[0-9]*$/; //非负浮点数 - var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数 - if (regPos.test(val) || regNeg.test(val)) { - return false; - } else { - return true; - } + var regPos = /^[0-9]*$/; //非负浮点数 + var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数 + if (regPos.test(val) || regNeg.test(val)) { + return false; + } else { + return true; + } - }, + }, - formValidate() { + formValidate() { - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } - if (this.data.form.wellcode == "") { - wx.showToast({ - icon: 'none', - title: '井编号不能为空!', - }) - return false - } - if (this.data.form.devicetype == "") { - wx.showToast({ - icon: 'none', - title: '设备类型不能为空!', - }) - return false - } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + if (this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '设备编号不能为空!', + }) + return false + } + if (this.data.form.wellcode == "") { + wx.showToast({ + icon: 'none', + title: '井编号不能为空!', + }) + return false + } + if (this.data.form.devicetype == "") { + wx.showToast({ + icon: 'none', + title: '设备类型不能为空!', + }) + return false + } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null || - this.data.form.installperson == '') { - wx.showToast({ - icon: 'none', - title: '运维人员不能为空!', - }) - return false - } - if (this.data.form.project == "") { - wx.showToast({ - icon: 'none', - title: '所属项目不能为空!', - }) - return false - } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } + if (this.data.form.installperson == null || + this.data.form.installperson == '') { + wx.showToast({ + icon: 'none', + title: '运维人员不能为空!', + }) + return false + } + if (this.data.form.project == "") { + wx.showToast({ + icon: 'none', + title: '所属项目不能为空!', + }) + return false + } - if (this.data.form.welldepth != null) { - if (this.isNumber(this.data.form.welldepth)) { - wx.showToast({ - icon: 'none', - title: '井深必须为数值!', - }) - return false - } - } - if (this.data.form.installheigt != null) { - if (this.isNumber(this.data.form.installheigt)) { - wx.showToast({ - icon: 'none', - title: '到井口距离必须为数值!', - }) - return false - } - } - - return true; - }, - - changeMsg: function () { - var formNew = this.data.form; - var formOld = JSON.parse(this.data.detail); - var descpNew = ""; - if (formNew.devcode != formOld.devcode) { - descpNew += "修改设备编号,原编号:" + formOld.devcode + ",新编号:" + formNew.devcode + ";" - } - if (formNew.devicetype != formOld.devicetype) { - descpNew += "修改设备类型,原设备类型:" + formOld.devicetype + ",新设备类型:" + formNew.devicetype + ";" - } - if (formNew.area != formOld.area) { - descpNew += "修改区,原区:" + formOld.area + ",新区:" + formNew.area + ";" - } - if (formNew.street != formOld.street) { - descpNew += "修改街道,原街道:" + formOld.street + ",新街道:" + formNew.street + ";" - } - if (formNew.wellname != formOld.wellname) { - descpNew += "修改井名称,原井名称:" + formOld.wellname + ",新井名称:" + formNew.wellname + ";" - } - if (formNew.factory != formOld.factory) { - descpNew += "修改权属单位,原权属单位:" + formOld.factory + ",新权属单位:" + formNew.factory + ";" - } - if (formNew.installheigt != formOld.installheigt) { - descpNew += "修改井口距离,原井口距离:" + formOld.installheigt + ",新井口距离:" + formNew.installheigt + ";" - } - if (formNew.installperson != formOld.installperson) { - descpNew += "修改运维人员,原运维人员:" + formOld.installperson + ",新运维人员:" + formNew.installperson + ";" - } - if (formNew.latitude != formOld.latitude) { - descpNew += "修改纬度,原纬度:" + formOld.latitude + ",新纬度:" + formNew.latitude + ";" - } - if (formNew.longitude != formOld.longitude) { - descpNew += "修改经度,原经度:" + formOld.longitude + ",新经度:" + formNew.longitude + ";" - } - if (formNew.position != formOld.position) { - descpNew += "修改位置描述,原位置:" + formOld.position + ",新位置:" + formNew.position + ";" - } - if (formNew.wellcode != formOld.wellcode) { - descpNew += "修改井编号,原编号:" + formOld.wellcode + ",新编号:" + formNew.wellcode + ";" - } - if (formNew.welldepth != formOld.welldepth) { - descpNew += "修改井深,原井深:" + formOld.welldepth + ",新井深:" + formNew.welldepth + ";" - } - if (formNew.welltype != formOld.welltype) { - descpNew += "修改井类型,原井类型:" + formOld.welltype + ",新井类型:" + formNew.welltype + ";" - } - if (formNew.project != formOld.project) { - descpNew += "修改所属项目,原项目:" + formOld.project + ",新项目:" + formNew.project + ";" - } - if (this.data.photopath1 != formOld.photopath1 || - this.data.photopath2 != formOld.photopath2 || - this.data.photopath3 != formOld.photopath3) { - descpNew += "修改照片;" - } - if ("" != formNew.description) { - descpNew += formNew.description; - } - this.setData({ - ['form.description']: descpNew + if (this.data.form.welldepth != null) { + if (this.isNumber(this.data.form.welldepth)) { + wx.showToast({ + icon: 'none', + title: '井深必须为数值!', }) - }, + return false + } + } + if (this.data.form.installheigt != null) { + if (this.isNumber(this.data.form.installheigt)) { + wx.showToast({ + icon: 'none', + title: '到井口距离必须为数值!', + }) + return false + } + } - formSubmit: function (event) { + return true; + }, - if (!this.formValidate()) { - return false; - } - this.changeMsg(); - var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDeviceLog', - data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceLog/add" - }, - }).then(res => { - // var resultObj=JSON.parse(res.result); - if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - if (res.confirm) { - wx.switchTab({ - url: that.data.pageName - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) - } - }).catch(err => { - console.error(err) - wx.showToast({ - title: "提交失败", - }) - }) - }, - confirm(event) { - var that = this; - var formValue = event.detail.value; - var formName = event.target.dataset.id; - var fromN = 'form.' + [formName]; - that.setData({ - [fromN]: formValue - }) - }, + //获取与上次修改的信息 + changeMsg: function () { + var formNew = this.data.form; + console.log(this.data.detail) + var formOld = JSON.parse(this.data.detail); + var descpNew = ""; + if (formNew.devcode != formOld.devcode) { + descpNew += "修改设备编号,原值:" + formOld.devcode + ",新值:" + formNew.devcode + ";" + } + if (formNew.devicetype != formOld.devicetype) { + descpNew += "修改设备类型,原值:" + formOld.devicetype + ",新值:" + formNew.devicetype + ";" + } + if (formNew.area != formOld.area) { + descpNew += "修改区,原值:" + formOld.area + ",新值:" + formNew.area + ";" + } + if (formNew.street != formOld.street) { + descpNew += "修改街道,原值:" + formOld.street + ",新值:" + formNew.street + ";" + } + if (formNew.wellname != formOld.wellname) { + descpNew += "修改井名称,原值:" + formOld.wellname + ",新值:" + formNew.wellname + ";" + } + if (formNew.factory != formOld.factory) { + descpNew += "修改权属单位,原值:" + formOld.factory + ",新值:" + formNew.factory + ";" + } + if (formNew.installheigt != formOld.installheigt) { + descpNew += "修改井口距离,原值:" + formOld.installheigt + ",新值:" + formNew.installheigt + ";" + } + if (formNew.installperson != formOld.installperson) { + descpNew += "修改运维人员,原值:" + formOld.installperson + ",新值:" + formNew.installperson + ";" + } + if (formNew.latitude != formOld.latitude) { + descpNew += "修改纬度,原值:" + formOld.latitude + ",新值:" + formNew.latitude + ";" + } + if (formNew.longitude != formOld.longitude) { + descpNew += "修改经度,原值:" + formOld.longitude + ",新值:" + formNew.longitude + ";" + } + if (formNew.position != formOld.position) { + descpNew += "修改位置描述,原值:" + formOld.position + ",新值:" + formNew.position + ";" + } + if (formNew.wellcode != formOld.wellcode) { + descpNew += "修改井编号,原值:" + formOld.wellcode + ",新值:" + formNew.wellcode + ";" + } + if (formNew.welldepth != formOld.welldepth) { + descpNew += "修改井深,原值:" + formOld.welldepth + ",新值:" + formNew.welldepth + ";" + } + if (formNew.welltype != formOld.welltype) { + descpNew += "修改井类型,原值:" + formOld.welltype + ",新值:" + formNew.welltype + ";" + } + if (formNew.project != formOld.project) { + descpNew += "修改所属项目,原值:" + formOld.project + ",新值:" + formNew.project + ";" + } + if (this.data.form.photopath1 != formOld.photopath1 || + this.data.form.photopath2 != formOld.photopath2 || + this.data.form.photopath3 != formOld.photopath3) { + descpNew += "修改照片;" + } + if ("" != formNew.description) { + descpNew += formNew.description; + } + this.setData({ + ['form.description']: descpNew + }) + }, - scan() { + //提交表单 + formSubmit: function (event) { - wx.scanCode({ - success(res) { - console.log(res) - } - }) + //表单验证 + if (!this.formValidate()) { + return false; + } + //自动生成修改内容 + this.changeMsg(); + //提交权限限制(只有施工人员能修改) + if(app.globalData.role!='repair'){ + wx.showToast({ + icon: 'none', + title: '无权限修改', + duration:2000 + }) + return false + } + var that = this; + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopath = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopath]: fileList[i].url.split("static/")[1] + }) + } + delete that.data.form.installtime + delete that.data.form.createtime + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - paste() { - var _this = this; - wx.getClipboardData({ - success: function (res) { - var longitude = 'form.longitude'; - var latitude = 'form.latitude'; - var longitude84 = 'form.longitude84'; - var latitude84 = 'form.latitude84'; - _this.setData({ - [longitude]: parseFloat(res.data.split(",", 4)[1]).toFixed(6), - [latitude]: parseFloat(res.data.split(",", 4)[0]).toFixed(6), - [longitude84]: "" == (res.data.split(",", 4)[3]) ? "" : parseFloat(res.data.split(",", 4)[3]).toFixed(6), - [latitude84]: "" == (res.data.split(",", 4)[2]) ? "" : parseFloat(res.data.split(",", 4)[2]).toFixed(6), - longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), - latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), - }); - } - }) - }, - selectValue(value) { - var that = this; - var wellType = 'form.welltype'; - that.setData({ - [wellType]: value.detail - }) - }, - selectpersonValue(event) { - var that = this; - var installPerson = 'form.installperson'; - that.setData({ - [installPerson]: event.detail - }) - }, - selectprojectValue(event) { - var that = this; - var project = 'form.project'; - that.setData({ - [project]: event.detail, - showMask: true - }) - }, - open() { - this.setData({ - showMask: true - }) - }, - close() { - this.setData({ - showMask: false - }) - }, - afterRead(event) { - var _this = this; - const { - file - } = event.detail; - const { - fileList = [] - } = _this.data; - var convertpath = ""; - wx.compressImage({ - src: event.detail.file.path, - quality: 25, - success: function (res) { - convertpath = res.tempFilePath; - wx.uploadFile({ - url: app.globalData.httpsUrl + "appDeviceAdd/fileUploadMarker", - filePath:convertpath, - name: 'file', - formData: { - 'text': "编号:" + _this.data.form.devcode + "经度:" + _this.data.form.longitude + "纬度:" + _this.data.form.latitude - }, - header: { - "Content-Type": "multipart/form-data", - 'accept': 'application/json', - }, - success(res) { - if (res.data) { - var url = JSON.parse(res.data); - fileList.push({ - ...file, - url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - }); - _this.setData({ - fileList - }); - } - } + success(res) { + if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + if (res.confirm) { + wx.switchTab({ + url: that.data.pageName }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') } - }) - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // // var base64 = "data:image/png;base64," + wx.getFileSystemManager().readFileSync(convertpath, 'base64'); - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: convertpath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // // wx.cloud.callFunction({ - // // name: 'uploadFile', - // // data: { - // // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // // fileBase64: base64 - // // }, - // // success: function (res) { - // // if (res.result) { - // // fileList.push({ - // // ...file, - // // url: app.globalData.url + "static/" + res.result.data.replace(/\\/g, "/") - // // }); - // // _this.setData({ - // // fileList - // // }); - // // } - // // }, - // // complete: res => { - // // }, - // // }) - // } - // }); + } + }) + } + }, + fail(err) { + wx.showToast({ + title: "提交失败", + }) + } + }) + }, + //报存录入的input信息 + confirm(event) { + var that = this; + var formValue = event.detail.value; + var formName = event.target.dataset.id; + var fromN = 'form.' + [formName]; + that.setData({ + [fromN]: formValue + }) + }, + + //扫码 + scan() { + + wx.scanCode({ + success(res) { + console.log(res) + } + }) + }, + //粘贴经纬度 + paste() { + var _this = this; + wx.getClipboardData({ + success: function (res) { + var longitude = 'form.longitude'; + var latitude = 'form.latitude'; + var longitude84 = 'form.longitude84'; + var latitude84 = 'form.latitude84'; + _this.setData({ + [longitude]: parseFloat(res.data.split(",", 4)[1]).toFixed(6), + [latitude]: parseFloat(res.data.split(",", 4)[0]).toFixed(6), + [longitude84]: "" == (res.data.split(",", 4)[3]) ? "" : parseFloat(res.data.split(",", 4)[3]).toFixed(6), + [latitude84]: "" == (res.data.split(",", 4)[2]) ? "" : parseFloat(res.data.split(",", 4)[2]).toFixed(6), + longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), + latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), + }); + } + }) + }, + selectValue(value) { + var that = this; + var wellType = 'form.welltype'; + that.setData({ + [wellType]: value.detail + }) + }, + //运维人员默认为登录人 + // selectpersonValue(event) { + // var that = this; + // var installPerson = 'form.installperson'; + // that.setData({ + // [installPerson]: event.detail + // }) + // }, + selectprojectValue(event) { + var that = this; + var project = 'form.project'; + that.setData({ + [project]: event.detail, + showMask: true + }) + }, + + open() { + this.setData({ + showMask: true + }) + }, + //隐藏textarea,防止遮挡 + close() { + this.setData({ + showMask: false + }) + }, + //上传照片 + afterRead(event) { + var _this = this; + const { + file + } = event.detail; + const { + fileList = [] + } = _this.data; + var convertpath = ""; + wx.compressImage({ + src: event.detail.file.path, + quality: 25, + success: function (res) { + convertpath = res.tempFilePath; + wx.uploadFile({ + url: app.globalData.httpsUrl + "appDeviceAdd/fileUploadMarker", + filePath: convertpath, + name: 'file', + formData: { + 'text': "编号:" + _this.data.form.devcode + "经度:" + _this.data.form.longitude + "纬度:" + _this.data.form.latitude }, - deletePhoto(event) { - var that = this - var image_index = event.detail.index - var fileList_new = that.data.fileList; - wx.showModal({ - content: '确定删除照片?', - success: function (res) { - if (res.confirm) { - fileList_new.splice(image_index, 1); - that.setData({ - fileList: fileList_new - }) - wx.cloud.callFunction({ - name: 'deletePhoto', - data: { - url: app.globalData.url + "appDeviceLog/deletePhoto", - devcode: that.data.form.devcode, - pathIndex: image_index - }, - success: function (res) {}, - complete: res => {}, - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + "Content-Type": "multipart/form-data", + 'accept': 'application/json', }, - }) \ No newline at end of file + success(res) { + if (res.data) { + var url = JSON.parse(res.data); + fileList.push({ + ...file, + url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") + }); + _this.setData({ + fileList + }); + } + } + }) + } + }) + }, + //删除照片 + deletePhoto(event) { + var that = this + var image_index = event.detail.index + var fileList_new = that.data.fileList; + wx.showModal({ + content: '确定删除照片?', + success: function (res) { + if (res.confirm) { + fileList_new.splice(image_index, 1); + that.setData({ + fileList: fileList_new + }) + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deletePhoto", + data: { + devcode: that.data.form.devcode + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) {} + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } +}) \ No newline at end of file diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.wxml b/miniprogram/pages/addDevicelog/addDeviceLog.wxml index 38620d4..b10cc7d 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.wxml +++ b/miniprogram/pages/addDevicelog/addDeviceLog.wxml @@ -1,15 +1,21 @@ - + + + + + - + - - + + - - + + - + @@ -39,24 +45,25 @@ - - - + + + - + - + + @@ -64,7 +71,7 @@ - + @@ -79,9 +86,9 @@ - + - 保存 + 保存 diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.wxss b/miniprogram/pages/addDevicelog/addDeviceLog.wxss index ee0b75c..08d5fd7 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.wxss +++ b/miniprogram/pages/addDevicelog/addDeviceLog.wxss @@ -24,6 +24,17 @@ display: flex; align-items: center; } +.map-view{ + width: 750rpx; + height: 485rpx; + position: fixed; + top: 0px; + left: 0px; + z-index: 999; +} +.content{ + margin-top: 495rpx; +} .left { width: 210rpx; diff --git a/miniprogram/pages/addFunction/addFunction.js b/miniprogram/pages/addFunction/addFunction.js deleted file mode 100644 index 4966be3..0000000 --- a/miniprogram/pages/addFunction/addFunction.js +++ /dev/null @@ -1,60 +0,0 @@ -// pages/addFunction/addFunction.js - -const code = `// 云函数入口函数 -exports.main = (event, context) => { - console.log(event) - console.log(context) - return { - sum: event.a + event.b - } -}` - -Page({ - - data: { - result: '', - canIUseClipboard: wx.canIUse('setClipboardData'), - }, - - onLoad: function (options) { - - }, - - copyCode: function() { - wx.setClipboardData({ - data: code, - success: function () { - wx.showToast({ - title: '复制成功', - }) - } - }) - }, - - testFunction() { - wx.cloud.callFunction({ - name: 'sum', - data: { - a: 1, - b: 2 - }, - success: res => { - wx.showToast({ - title: '调用成功', - }) - this.setData({ - result: JSON.stringify(res.result) - }) - }, - fail: err => { - wx.showToast({ - icon: 'none', - title: '调用失败', - }) - console.error('[云函数] [sum] 调用失败:', err) - } - }) - }, - -}) - diff --git a/miniprogram/pages/addFunction/addFunction.json b/miniprogram/pages/addFunction/addFunction.json deleted file mode 100644 index a9a50c5..0000000 --- a/miniprogram/pages/addFunction/addFunction.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "navigationBarTitleText": "云函数指引", - "usingComponents": {} -} \ No newline at end of file diff --git a/miniprogram/pages/addFunction/addFunction.wxml b/miniprogram/pages/addFunction/addFunction.wxml deleted file mode 100644 index 3a10626..0000000 --- a/miniprogram/pages/addFunction/addFunction.wxml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - 测试云函数 - - - 期望输出:{"sum":3} - - - 调用结果:{{result}} - - - - - 新增云函数 - 1. 在云函数根目录 cloudfunctions 上右键选择新建云函数,命名为 sum - 2. 在创建的 cloudfunctions/sum/index.js 文件中添加如下代码 - - - 3. 在 cloudfunctions/sum 目录上右键上传并部署 - 4. 点击测试云函数测试 - 5. 打开云开发云函数管理页,选择 sum 云函数 - 6. 查看 sum 的调用日志 - 进阶:可在云函数中使用 wx-server-sdk 操作数据库,文件存储和调用其他云函数,详见文档 - - - diff --git a/miniprogram/pages/addFunction/addFunction.wxss b/miniprogram/pages/addFunction/addFunction.wxss deleted file mode 100644 index 7ac8619..0000000 --- a/miniprogram/pages/addFunction/addFunction.wxss +++ /dev/null @@ -1,3 +0,0 @@ -/* pages/addFunction/addFunction.wxss */ - -@import "../../style/guide.wxss"; \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.js b/miniprogram/pages/applog/applog.js index 0e8c185..189e61f 100644 --- a/miniprogram/pages/applog/applog.js +++ b/miniprogram/pages/applog/applog.js @@ -13,98 +13,25 @@ isSeach: "false", params: {}, total: 0, - show: false + show: false, + delBtnWidth: 100, //删除按钮宽度单位(rpx) + activeIndex: -1, + list_style: '' }, - - touchE: function (e) { - // console.log(e); - var that = this - if (e.changedTouches.length == 1) { - //手指移动结束后触摸点位置的X坐标 - var endX = e.changedTouches[0].clientX; - //触摸开始与结束,手指移动的距离 - var disX = that.data.startX - endX; - var delBtnWidth = that.data.delBtnWidth; - //如果距离小于删除按钮的1/2,不显示删除按钮 - var txtStyle = disX > delBtnWidth / 2 ? "left:-" + delBtnWidth + "rpx" : "left:0rpx"; - - //获取手指触摸的是哪一项 - var index = e.currentTarget.dataset.index; - var list = that.data.deviceloglist; - list[index].txtStyle = txtStyle; - //更新列表的状态 - that.setData({ - deviceloglist: list - }); - } - }, - //手指触摸动作开始 记录起点X坐标 - touchstart: function (e) { - //开始触摸时 重置所有删除 - this.data.deviceloglist.forEach(function (v, i) { - if (v.isTouchMove) //只操作为true的 - v.isTouchMove = false; - }) - this.setData({ - startX: e.changedTouches[0].clientX, - startY: e.changedTouches[0].clientY, - deviceloglist: this.data.deviceloglist - }) - }, - //滑动事件处理 - touchmove: function (e) { - var that = this, - index = e.currentTarget.dataset.index, //当前索引 - startX = that.data.startX, //开始X坐标 - startY = that.data.startY, //开始Y坐标 - touchMoveX = e.changedTouches[0].clientX, //滑动变化坐标 - touchMoveY = e.changedTouches[0].clientY, //滑动变化坐标 - //获取滑动角度 - angle = that.angle({ - X: startX, - Y: startY - }, { - X: touchMoveX, - Y: touchMoveY - }); - that.data.deviceloglist.forEach(function (v, i) { - v.isTouchMove = false - //滑动超过30度角 return - if (Math.abs(angle) > 30) return; - if (i == index) { - if (touchMoveX > startX) //右滑 - v.isTouchMove = false - else //左滑 - v.isTouchMove = true - } - }) - //更新数据 - that.setData({ - deviceloglist: that.data.deviceloglist - }) - }, - /** - * 计算滑动角度 - * @param {Object} start 起点坐标 - * @param {Object} end 终点坐标 - */ - angle: function (start, end) { - var _X = end.X - start.X, - _Y = end.Y - start.Y - //返回角度 /Math.atan()返回数字的反正切值 - return 360 * Math.atan(_Y / _X) / (2 * Math.PI); - }, - /** - * 生命周期函数--监听页面加载var_this=this; - */ onLoad: function (options) { - if (options.params) { this.setData({ params: JSON.parse(options.params), isSeach: "true" }) this.initPages() + }else{ + this.setData({ + show: false + }) + //清空参数,重新加载 + this.clearParams(); + this.initPages(); } }, @@ -116,20 +43,33 @@ }, + //点击tabBar事件 + onTabItemTap(item) { + //隐藏历史显示总记录条数 + this.setData({ + show: false + }) + //清空参数,重新加载 + this.clearParams(); + this.initPages(); + }, + + /** * 生命周期函数--监听页面显示 */ onShow: function (options) { - this.setData({ - show:false - }) - if (this.data.isSeach == "false") { - this.clearParams(); - this.initPages(); - } - this.setData({ - isSeach: "false" - }) + + // this.setData({ + // show: false + // }) + // if (this.data.isSeach == "false") { + // this.clearParams(); + // this.initPages(); + // } + // this.setData({ + // isSeach: "false" + // }) }, /** @@ -167,6 +107,119 @@ }, + + //手指触摸动作开始 记录起点X坐标 + touchstart: function (e) { + //开始触摸时 重置所有删除 + this.data.deviceloglist.forEach(function (v, i) { + if (v.isTouchMove) //只操作为true的 + v.isTouchMove = false; + }) + this.setData({ + startX: e.changedTouches[0].clientX, + startY: e.changedTouches[0].clientY, + deviceloglist: this.data.deviceloglist + }) + }, + + //滑动事件处理 + touchmove: function (e) { + var that = this, + index = e.currentTarget.dataset.index, //当前索引 + startX = that.data.startX, //开始X坐标 + startY = that.data.startY, //开始Y坐标 + touchMoveX = e.changedTouches[0].clientX, //滑动变化坐标 + touchMoveY = e.changedTouches[0].clientY, //滑动变化坐标 + //获取滑动角度 + angle = that.angle({ + X: startX, + Y: startY + }, { + X: touchMoveX, + Y: touchMoveY + }); + that.data.deviceloglist.forEach(function (v, i) { + // v.isTouchMove = false + //滑动超过30度角 return + if (Math.abs(angle) > 30) return; + if (i == index) { + if (touchMoveX > startX) //右滑 + v.isTouchMove = false + else //左滑 + v.isTouchMove = true + } + }) + //更新数据 + that.setData({ + deviceloglist: that.data.deviceloglist + }) + }, + + /** + * 计算滑动角度 + * @param {Object} start 起点坐标 + * @param {Object} end 终点坐标 + */ + angle: function (start, end) { + var _X = end.X - start.X, + _Y = end.Y - start.Y + //返回角度 /Math.atan()返回数字的反正切值 + return 360 * Math.atan(_Y / _X) / (2 * Math.PI); + }, + + //删除事件 + delItem: function (e) { + if(app.globalData.role!='repair'){ + wx.showToast({ + icon: 'none', + title: '无权限删除', + duration:2000 + }) + return false + } + var that = this + wx.showModal({ + content: '是否删除?', + success: function (res) { + if (res.confirm) { + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/delete", + data: { + appDeviceAddId: e.currentTarget.dataset.devid + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if(res.data.code=='200'){ + that.data.deviceloglist.splice(e.currentTarget.dataset.index, 1) + that.setData({ + deviceloglist: that.data.deviceloglist, + total: that.data.deviceloglist.length + }) + wx.showToast({ + title: '删除成功!', + icon: 'none', + duration: 1000 + }) + } + }, + fail(err) { + wx.showToast({ + title: '删除失败!', + icon: 'none', + duration: 2000 + }) + } + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + }, + showLoading: function (message) { if (wx.showLoading) { // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 @@ -199,95 +252,105 @@ deviceloglist: [] }) }, + //查询列表数据 initPages: function () { var that = this + that.setData({ + show: false + }) var offsetValue = that.data.deviceloglist.length % 15 > 0 ? parseInt(that.data.deviceloglist.length / 15) + 2 : parseInt(that.data.deviceloglist.length / 15) + 1 - wx.cloud.callFunction({ - name: 'devicelog', + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/listPage", data: { devcode: that.data.params.devcode, devtype: that.data.params.devtype, installtimeFmt: that.data.params.installtimeFmt, project: that.data.params.project, installPerson: that.data.params.installPerson, - url: app.globalData.url + "appDeviceLog/listPage", limit: 15, offset: offsetValue }, - }).then(res => { - if (res.result.data.rows.length > 0) { - var resultJson = res.result - that.setData({ - deviceloglist: that.data.deviceloglist.concat(resultJson.data.rows) - }) - } else if (that.data.deviceloglist.length > 0) { - that.setData({ - show: true, - total: that.data.deviceloglist.length - }) - wx.showToast({ - title: '数据已全部加载完', - icon: 'none', - duration: 2000 - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.data.rows.length > 0) { + var resultJson = res.data + var listArr = resultJson.data.rows + listArr.forEach(function (v, i) { + listArr[i]['isTouchMove'] = false + }) + that.setData({ + deviceloglist: that.data.deviceloglist.concat(listArr) + }) + } else if (that.data.deviceloglist.length > 0) { + that.setData({ + show: true, + total: that.data.deviceloglist.length + }) + wx.showToast({ + title: '数据已全部加载完', + icon: 'none', + duration: 2000 + }) + } + if (offsetValue == 1 && res.data.data.rows.length < 15) { + that.setData({ + show: true, + total: that.data.deviceloglist.length + }) + } } - if(offsetValue==1&&res.result.data.rows.length<15){ - that.setData({ - show: true, - total: that.data.deviceloglist.length - }) - } - // console.log(res); - }).catch(err => { - console.error(err); }) + }, addDetail: function (event) { - this.showLoading("数据请求中..."); - wx.cloud.callFunction({ - name: 'deviceDetail', + var that = this + that.showLoading("数据请求中..."); + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deviceDetail", data: { devcode: event.target.dataset.devcode, - url: app.globalData.url + "appDeviceLog/deviceDetail", }, - }).then(res => { - this.hideLoading(); - var resultObject = JSON.parse(res.result); - var pageName = '../applog/applog' - if (resultObject.code == 200) { - wx.navigateTo({ - url: '../addDevicelog/addDeviceLog?detail=' + - JSON.stringify(resultObject.data) + "&pageName=" + pageName - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + that.hideLoading(); + // var resultObject = JSON.parse(res.data); + var resultObject = res.data; + var pageName = '../applog/applog' + if (resultObject.code == 200) { + wx.setStorageSync('resultObject', resultObject.data) + wx.navigateTo({ + url: '../addDevicelog/addDeviceLog?detail=' + "&pageName=" + pageName + }) + } + }, + fail(err) { + that.hideLoading(); } - }).catch(err => { - this.hideLoading() }) + }, add: function (event) { - wx.reLaunch({ - url: '../earth/earth?devcode=' + event.target.dataset.devcode - // url: '../earth/earth' + app.globalData.devcode = event.target.dataset.devcode; + wx.switchTab({ + url: '../earth/earth' }) + // wx.reLaunch({ + // url: '../earth/earth?devcode=' + event.target.dataset.devcode + // // url: '../earth/earth' + // }) }, onSearch: function () { + var _this = this wx.navigateTo({ - url: '../searchLog/searchLog' + url: '../searchLog/searchLog?params=' + JSON.stringify(_this.data.params) }) - }, - // initPages: function () { - // wx.cloud.callFunction({ - // name: 'devicelog' - // }).then(res => { - // var that = this; - // var jsonList = JSON.parse(res.result) - // that.setData({ - // deviceloglist: jsonList.data.rows - // }) - // console.log(res); - // }).catch(err => { - // console.error(err); - // }) - // } + } }) \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.wxml b/miniprogram/pages/applog/applog.wxml index e9a2352..2bfd041 100644 --- a/miniprogram/pages/applog/applog.wxml +++ b/miniprogram/pages/applog/applog.wxml @@ -1,54 +1,59 @@ - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {{item.devcode}} {{item.devicetype}} + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + {{item.devcode}} {{item.devicetype}} + + {{item.project}} {{item.installtime}}- {{item.installperson}} - - - - - + + + + + + 删除 - - - + + - 共计:{{total}}台 - + 共计:{{total}}台 + \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.wxss b/miniprogram/pages/applog/applog.wxss index 6d3428b..e6e8983 100644 --- a/miniprogram/pages/applog/applog.wxss +++ b/miniprogram/pages/applog/applog.wxss @@ -22,16 +22,18 @@ position: fixed; width: 100%; top: 0rpx; + z-index: 9999; /* margin-bottom: 100rpx; */ } .log-list { /* height: 100rpx; */ - /* display: flex; */ - + display: flex; + width: 100%; padding: 2px; margin-top: 2px; border-bottom: 1px solid #e5e5e5; + overflow: hidden } @@ -53,23 +55,29 @@ left: 35%; margin: 20rpx } - .del { - width: 90px; + /* display: flex; */ + width: 100rpx; display: flex; flex-direction: column; align-items: center; justify-content: center; - color: #fff; - -webkit-transform: translateX(90px); - transform: translateX(90px); - -webkit-transition: all 0.4s; + /* -webkit-transform: translateX(100rpx); */ + transform: translateX(100rpx); + /* -webkit-transition: all 0.4s; */ transition: all 0.4s; - font-size: 35rpx; + color: #fff; + background-color: #fe3e2f; +} +.logrow{ + width: 100%; + transform: translateX(100rpx); + /* -webkit-transform: translateX(100px); */ + margin-left: -100rpx; } -.touch-move-active .content, +.touch-move-active .logrow, .touch-move-active .del { - -webkit-transform: translateX(0); - transform: translateX(0); +/* -webkit-transform: translateX(0); */ +transform: translateX(0); } \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.js b/miniprogram/pages/deployFunctions/deployFunctions.js deleted file mode 100644 index a76b144..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.js +++ /dev/null @@ -1,66 +0,0 @@ -// pages/deployFunctions/deployFunctions.js -Page({ - - /** - * 页面的初始数据 - */ - data: { - - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - - }, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { - - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - - }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { - - }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { - - } -}) \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.json b/miniprogram/pages/deployFunctions/deployFunctions.json deleted file mode 100644 index 7fbedab..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "navigationBarTitleText": "部署云函数", - "usingComponents": {} -} \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.wxml b/miniprogram/pages/deployFunctions/deployFunctions.wxml deleted file mode 100644 index 462b6b6..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.wxml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - 调用失败 - - - 请检查 login 云函数是否已部署 - - - - - 部署 login 云函数 - 1. 确保已通过工具栏云开发入口开通云开发 - 2. 在 cloudfunctions/login 目录上右键上传并部署 - 3. 回到首页,重新点击获取 openid - - - - diff --git a/miniprogram/pages/deployFunctions/deployFunctions.wxss b/miniprogram/pages/deployFunctions/deployFunctions.wxss deleted file mode 100644 index c8803e6..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.wxss +++ /dev/null @@ -1,7 +0,0 @@ -/* pages/deployFunctions/deployFunctions.wxss */ - -@import "../../style/guide.wxss"; - -.black { - color: black; -} \ No newline at end of file diff --git a/miniprogram/pages/earth/earth.js b/miniprogram/pages/earth/earth.js index ae0d3f3..376a6e2 100644 --- a/miniprogram/pages/earth/earth.js +++ b/miniprogram/pages/earth/earth.js @@ -21,19 +21,12 @@ show: false, enableSsatellite: false, windowWidth: 0, - longitude: 113.324520, - latitude: 23.099994, - longitude84: 113.324520, - latitude84: 23.099994, - markers: [{ - id: 0, - iconPath: "../../images/locat.png", - latitude: 23.099994, - longitude: 113.324520, - width: 50, - height: 50 - }], - controls: [], + longitude: "116.627340", + latitude: "39.874390", + longitude84: "", + latitude84: "", + markers: [], + controls: [] }, /** @@ -41,39 +34,13 @@ */ onLoad: function (options) { var that = this; - //获取当前坐标(gcj02) - wx.getLocation({ - type: "gcj02", - altitude: true, - success: function (res) { - that.setData({ - latitude: parseFloat(res.latitude).toFixed(6), - longitude: parseFloat(res.longitude).toFixed(6), - // markers: [{ - // latitude: res.latitude, - // longitude: res.longitude, - // }] - }) - //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 - wx.getLocation({ - type: "wgs84", - altitude: true, - success: function (res) { - that.setData({ - latitude84: parseFloat(res.latitude).toFixed(6), - longitude84: parseFloat(res.longitude).toFixed(6) - }) - } - }) - } - }), - - //设置地图组件 - wx.getSystemInfo({ + //设置地图组件 + wx.getSystemInfo({ success(res) { var windowWidth = res.windowWidth var windowHeight = res.windowHeight var query = wx.createSelectorQuery() + var platform =res.platform query.select('#map').boundingClientRect() query.exec(function (res) { that.setData({ @@ -139,10 +106,20 @@ clickable: true }, { id: 7, - iconPath: '../../images/locat.png', + iconPath: '../../images/applocat.png', position: { - left: res[0].width/2, - top: res[0].height/2, + left: res[0].width / 2 - 20, + top: platform=="ios"?res[0].height / 2 - 80:res[0].height / 2 - 40, + width: 40, + height: 40 + }, + clickable: true + }, { + id: 8, + iconPath: '../../images/back.png', + position: { + left: windowWidth - 40, + top: windowHeight - 140, width: 30, height: 30 }, @@ -150,71 +127,15 @@ }] }) }) - + } - }), + }) + // 实例化API核心类 qqmapsdk = new QQMapWX({ key: 'BGPBZ-C5O3P-ROUDR-LWC4J-63EKH-V5FRX' }) - - if (options.devcode) { - var that = this - var devcode = options.devcode - wx.cloud.callFunction({ - name: 'findListByCodes', - data: { - devcodes: devcode, - url: app.globalData.url + "appDeviceAdd/findListByCodes" - }, - }).then(res => { - if (res.result.code == 200) { - var listResultData = res.result.data; - that.setData({ - listData: listResultData - }) - var markersArr = that.data.markers; - for (var i = 0; i < listResultData.length; i++) { - markersArr = markersArr.concat({ - iconPath: "../../images/locat.png", - id: listResultData[i].id, - callout: { - content: listResultData[i].devcode, - fontSize: '14', - // padding: true, - color: '#00000', - borderColor: '#F4EA2A', - bgColor: '#F4EA2A', - borderWidth: 5, - display: 'ALWAYS', - textAlign: 'center', - // borderRadius: 15 - }, - latitude: listResultData[i].latitude, - longitude: listResultData[i].longitude, - width: 40, - height: 40 - }); - } - this.setData({ - markers: markersArr, - latitude: listResultData[0].latitude, - longitude: listResultData[0].longitude, - marker_latitude: listResultData[0].latitude, - marker_longitude: listResultData[0].longitude, - title: listResultData[0].devcode - }) - } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "无法获取设备地理信息!", - icon: 'none', - duration: 2000 - }) - }) - } }, /** @@ -228,6 +149,97 @@ * 生命周期函数--监听页面显示 */ onShow: function () { + //输入设备编号获取marker位置信息 + var that = this; + if ( app.globalData.devcode!="") { + var devcode = app.globalData.devcode + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/findListByCodes", + data: { + devcodes: devcode, + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + app.globalData.devcode=""; + if (res.data.code == 200) { + var listResultData = res.data.data; + that.setData({ + listData: listResultData + }) + var markersArr = that.data.markers; + for (var i = 0; i < listResultData.length; i++) { + markersArr = markersArr.concat({ + iconPath: "../../images/locat.png", + id: Number(listResultData[i].id), + callout: { + content: "编号:"+listResultData[i].devcode+"\r\n位置:"+listResultData[i].position+"\r\n时间:"+listResultData[i].createtime, + fontSize: '14', + padding: true, + color: '#000000', + borderColor: '#F4EA2A', + bgColor: '#F4EA2A', + borderWidth: 5, + display: 'ALWAYS', + textAlign: 'left', + // borderRadius: 15 + }, + latitude: listResultData[i].latitude, + longitude: listResultData[i].longitude, + width: 40, + height: 40 + }); + } + that.setData({ + markers: markersArr, + latitude: listResultData[0].latitude, + longitude: listResultData[0].longitude, + marker_latitude: listResultData[0].latitude, + marker_longitude: listResultData[0].longitude, + title: listResultData[0].devcode + }) + } + }, + fail(err) { + app.globalData.devcode=""; + wx.showToast({ + title: "无法获取设备地理信息!", + icon: 'none', + duration: 2000 + }) + } + }) +} else { + //获取当前坐标(gcj02) + wx.getLocation({ + type: "gcj02", + altitude: true, + success: function (res) { + that.setData({ + latitude: parseFloat(res.latitude).toFixed(6), + longitude: parseFloat(res.longitude).toFixed(6), + // markers: [{ + // latitude: res.latitude, + // longitude: res.longitude, + // }] + }) + //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 + wx.getLocation({ + type: "wgs84", + altitude: true, + success: function (res) { + that.setData({ + latitude84: parseFloat(res.latitude).toFixed(6), + longitude84: parseFloat(res.longitude).toFixed(6) + }) + } + }) + } + }) +} + }, @@ -265,12 +277,46 @@ onShareAppMessage: function () { }, + + //定位出来 + + locationPosition: function () { + var that = this; + //获取当前坐标(gcj02) + wx.getLocation({ + type: "gcj02", + altitude: true, + success: function (res) { + that.setData({ + latitude: parseFloat(res.latitude).toFixed(6), + longitude: parseFloat(res.longitude).toFixed(6), + // markers: [{ + // latitude: res.latitude, + // longitude: res.longitude + // }] + }) + //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 + wx.getLocation({ + type: "wgs84", + altitude: true, + success: function (res) { + that.setData({ + latitude84: parseFloat(res.latitude).toFixed(6), + longitude84: parseFloat(res.longitude).toFixed(6) + }) + } + }) + } + }) + }, + + //加载地图组件 controltap: function (e) { // console.log(e.controlId); //进入添加设备页 if (1 == e.controlId) { wx.setClipboardData({ - data: this.data.latitude + "," + this.data.longitude+ "," + this.data.latitude84+ "," + this.data.longitude84, + data: this.data.latitude + "," + this.data.longitude + "," + this.data.latitude84 + "," + this.data.longitude84, success: function (res) { wx.getClipboardData({ success: function (res) { @@ -282,6 +328,17 @@ } }) } else if (3 == e.controlId) { + //先定位 + // this.locationPosition() + wx.setClipboardData({ + data: this.data.latitude + "," + this.data.longitude + "," + this.data.latitude84 + "," + this.data.longitude84, + success: function (res) { + wx.showToast({ + title: '坐标已获取', + duration: 1000 + }) + } + }) wx.navigateTo({ url: '../addDevice/addDevice' }) @@ -302,32 +359,15 @@ enableSsatellite: !flag }); } else if (6 == e.controlId) { - var that = this; - //获取当前坐标(gcj02) - wx.getLocation({ - type: "gcj02", - altitude: true, - success: function (res) { - that.setData({ - latitude: parseFloat(res.latitude).toFixed(6), - longitude:parseFloat(res.longitude).toFixed(6), - // markers: [{ - // latitude: res.latitude, - // longitude: res.longitude - // }] - }) - //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 - wx.getLocation({ - type: "wgs84", - altitude: true, - success: function (res) { - that.setData({ - latitude84: parseFloat(res.latitude).toFixed(6), - longitude84: parseFloat(res.longitude).toFixed(6) - }) - } - }) - } + //先清marker + this.setData({ + markers: [] + }) + this.locationPosition() + }else if (8 == e.controlId) { + //跳转日志缓存页 + wx.switchTab({ + url: '../applog/applog', }) } }, @@ -343,63 +383,68 @@ }); }, + //获取设备maker leave() { var that = this; if (that.data.devcodes == "") { return false; } - wx.cloud.callFunction({ - name: 'findListByCodes', + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/findListByCodes", data: { - devcodes: that.data.devcodes, - url: app.globalData.url + "appDeviceAdd/findListByCodes" + devcodes: that.data.devcodes }, - }).then(res => { - if (res.result.code == 200) { - var listResultData = res.result.data; - that.setData({ - listData: listResultData - }) - var markersArr = that.data.markers; - for (var i = 0; i < listResultData.length; i++) { - markersArr = markersArr.concat({ - iconPath: "../../images/locat.png", - id: listResultData[i].id, - callout: { - content: listResultData[i].devcode, - fontSize: '14', - // padding: true, - color: '', - borderColor: '#F4EA2A', - bgColor: '#F4EA2A', - borderWidth: 5, - display: 'ALWAYS', - textAlign: 'center', - // borderRadius: 15 - }, - latitude: listResultData[i].latitude, - longitude: listResultData[i].longitude, - width: 40, - height: 40 - }); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var listResultData = res.data.data; + that.setData({ + listData: listResultData + }) + var markersArr = that.data.markers; + for (var i = 0; i < listResultData.length; i++) { + markersArr = markersArr.concat({ + iconPath: "../../images/locat.png", + id: listResultData[i].id, + callout: { + content: "编号:"+listResultData[i].devcode+"\r\n位置:"+listResultData[i].position+"\r\n时间:"+listResultData[i].createtime, + fontSize: '14', + // padding: true, + color: '#212121', + borderColor: '#F4EA2A', + bgColor: '#F4EA2A', + borderWidth: 5, + display: 'ALWAYS', + textAlign: 'left', + // borderRadius: 15 + }, + latitude: listResultData[i].latitude, + longitude: listResultData[i].longitude, + width: 40, + height: 40 + }); + } + that.setData({ + markers: markersArr, + latitude: listResultData[0].latitude, + longitude: listResultData[0].longitude, + marker_latitude: listResultData[0].latitude, + marker_longitude: listResultData[0].longitude, + title: listResultData[0].devcode + }) } - this.setData({ - markers: markersArr, - latitude: listResultData[0].latitude, - longitude: listResultData[0].longitude, - marker_latitude: listResultData[0].latitude, - marker_longitude: listResultData[0].longitude, - title: listResultData[0].devcode + }, + fail(err) { + wx.showToast({ + title: "无法获取设备地理信息!", + icon: 'none', + duration: 2000 }) } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "无法获取设备地理信息!", - icon: 'none', - duration: 2000 - }) }) }, @@ -422,6 +467,8 @@ } }, + + bindregionchange: function (e) { var that = this if (e.causedBy == "drag") { @@ -445,8 +492,8 @@ that.setData({ latitude: parseFloat(latitude).toFixed(6), longitude: parseFloat(longitude).toFixed(6), - latitude84:"", - longitude84:"", + latitude84: "", + longitude84: "", // markers: markersArr }) // mapCtx.moveToLocation(); @@ -465,16 +512,19 @@ qqmapsdk.search({ keyword: this.data.value, success: function (res) { + console.log(res) if (res && res.data) { _this.setData({ isShow: true, tips: res.data }); } + }, + complete: function (res){ + console.log(res); } }) }, - bindSearch: function (e) { var location = e.target.dataset.location; this.setData({ diff --git a/miniprogram/pages/earth/earth.wxml b/miniprogram/pages/earth/earth.wxml index a0db6ef..87474f8 100644 --- a/miniprogram/pages/earth/earth.wxml +++ b/miniprogram/pages/earth/earth.wxml @@ -1,9 +1,10 @@ + - + {{item.title}} {{item.address}} @@ -17,6 +18,6 @@ + placeholder="请输入定位设备编号用换行隔开" autosize border="{{ false }}" /> \ No newline at end of file diff --git a/miniprogram/pages/indexapp/indexapp.js b/miniprogram/pages/indexapp/indexapp.js index 5063372..849dbdb 100644 --- a/miniprogram/pages/indexapp/indexapp.js +++ b/miniprogram/pages/indexapp/indexapp.js @@ -7,9 +7,8 @@ */ data: { - count:1, - show: false, - onshow:true, + count: 1, + onshow: true, value: "", deviceloglist: [], devcode: "", @@ -21,6 +20,7 @@ // iconPath: "../../images/point.png", latitude: 23.099994, longitude: 113.324520, + label:'1', width: 50, height: 50 }], @@ -31,62 +31,26 @@ * 生命周期函数--监听页面加载 */ onLoad: function (options) { - + }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { - + }, /** * 生命周期函数--监听页面显示 */ onShow: function () { - // if( app.globalData.indexCount>1){ - // this.setData({ - // show:false - // }) - // }else{ - // this.showNotice() - // } - if(app.globalData.indexCount==1){ - this.setData({ - show:true - }) - this.showNotice() - } - app.globalData.indexCount+=1 - if(this.data.onshow){ + if (this.data.onshow) { this.initPages(); } }, - - showNotice: function() { - var that = this - var times = 0 - var i = setInterval(function() { - times++ - if (times >= 15) { - that.setData({ - show:false - }) - wx.showTabBar({ - animation: false, - }) - clearInterval(i) - } else { - wx.hideTabBar({ - animation: false, - }) - } - }, 1000) -}, - /** * 生命周期函数--监听页面隐藏 */ @@ -122,16 +86,27 @@ }, jump: function (event) { - var that = this; var latitude = event.target.dataset.pointLat; var longitude = event.target.dataset.pointLon; + let devcode = event.target.dataset.pointCode; that.setData({ latitude: latitude, longitude: longitude, markers: [{ latitude: latitude, - longitude: longitude + longitude: longitude, + callout: { + display:'ALWAYS',// 常显气泡 + content: devcode, //名称文本 + color: '#fff', //文本颜色 + borderRadius: 5, //边框圆角 + borderWidth: 1, //边框宽度 + borderColor: '#0060ff', //边框颜色 + bgColor: '#0060ff', //背景色 + padding: 5, //文本边缘留白 + textAlign: 'center' //文本对齐方式。有效值: left, right, center + } }] }) }, @@ -142,7 +117,7 @@ var devcode = res.result _this.setData({ devcode: devcode, - onshow:false + onshow: false }); _this.searchlogs(devcode) } @@ -151,40 +126,11 @@ onSearch: function (event) { this.setData({ - devcode:event.detail + devcode: event.detail }) this.searchlogs(event.detail) }, - - // bindregionchange: function (e) { - // var that = this - // if (e.causedBy == "drag") { - // var mapCtx = wx.createMapContext("map") - // mapCtx.getCenterLocation({ - // success: function (res) { - // var markersArr = that.data.markers - // for (var i = 0; i < markersArr.length; i++) { - // if (markersArr[i].iconPath == undefined) { - // markersArr.splice(i, 1) - // } - // } - // var latitude = res.latitude - // var longitude = res.longitude - // markersArr = markersArr.concat({ - // latitude: latitude, - // longitude: longitude - // }) - // that.setData({ - // latitude: latitude, - // longitude: longitude, - // markers: markersArr - // }) - // } - // }) - // } - // }, - showLoading: function (message) { if (wx.showLoading) { // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 @@ -211,81 +157,89 @@ } }, + //加载设备运维详细信息 toDetail: function (event) { - this.showLoading("数据加载中...") - wx.cloud.callFunction({ - name: 'deviceDetail', + var that = this + that.showLoading("数据加载中...") + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deviceDetail", data: { devcode: event.target.dataset.devcode, - url: app.globalData.url + "appDeviceLog/deviceDetail", }, - }).then(res => { - this.hideLoading(); - var resultObject = JSON.parse(res.result); - var pageName='../indexapp/indexapp' - if (resultObject.code == 200) { - wx.navigateTo({ - url: '../addDevicelog/addDeviceLog?detail=' + - JSON.stringify(resultObject.data)+'&pageName='+pageName - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + that.hideLoading(); + var resultObject = res.data; + var pageName = '../indexapp/indexapp' + if (resultObject.code == 200) { + wx.setStorageSync('resultObject', resultObject.data) + wx.navigateTo({ + url: '../addDevicelog/addDeviceLog?detail=' +'&pageName=' + pageName + }) + } + }, + fail(err){ + that.hideLoading(); } - }).catch(err => { - this.hideLoading(); }) }, + //加载列表 getlogs: function (devcode) { var that = this - wx.cloud.callFunction({ - name: 'devicelog', + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/listPage", data: { devcode: devcode, - url: app.globalData.url + "appDeviceLog/listPage", limit: 100, offset: that.data.deviceloglist.length % 100 > 0 ? parseInt(that.data.deviceloglist.length / 100) + 2 : parseInt(that.data.deviceloglist.length / 100) + 1 }, - }).then(res => { - if (res.result) { - // var resultJson = JSON.parse(res.result) - var resultJson = res.result - that.setData({ - deviceloglist: that.data.deviceloglist.concat(resultJson.data.rows) - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + // var resultJson = JSON.parse(res.result) + var resultJson = res.data + that.setData({ + deviceloglist: that.data.deviceloglist.concat(resultJson.data.rows) + }) + } } - console.log(res); - }).catch(err => { - console.error(err); }) }, + //查询列表 searchlogs: function (devcode) { var that = this - wx.cloud.callFunction({ - name: 'devicelog', + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/listPage", data: { devcode: devcode, - url: app.globalData.url + "appDeviceLog/listPage", limit: 100, offset: 1 }, - }).then(res => { - if (res.result) { - var resultJson = res.result - that.setData({ - deviceloglist: resultJson.data.rows, - onshow:true - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var resultJson = res.data + that.setData({ + deviceloglist: resultJson.data.rows, + onshow: true + }) + } } - console.log(res); - }).catch(err => { - console.error(err); }) }, initPages: function () { var that = this; - that.setData({ - devcode: "" - }); wx.getLocation({ type: "gcj02", success: function (res) { @@ -302,6 +256,6 @@ }) } }) - this.searchlogs() + this.data.devcode !== '' ? this.searchlogs(this.data.devcode) : this.searchlogs() }, }) \ No newline at end of file diff --git a/miniprogram/pages/indexapp/indexapp.wxml b/miniprogram/pages/indexapp/indexapp.wxml index 69322a0..f65b082 100644 --- a/miniprogram/pages/indexapp/indexapp.wxml +++ b/miniprogram/pages/indexapp/indexapp.wxml @@ -1,8 +1,12 @@ + + + + - @@ -32,9 +36,15 @@ - + + + + + + + @@ -46,14 +56,14 @@ - + - - + diff --git a/miniprogram/pages/indexapp/indexapp.wxss b/miniprogram/pages/indexapp/indexapp.wxss index b18706a..fc27fcb 100644 --- a/miniprogram/pages/indexapp/indexapp.wxss +++ b/miniprogram/pages/indexapp/indexapp.wxss @@ -128,6 +128,7 @@ .noticeClass{ height: 2300rpx; width: 750rpx; + overflow-y:hidden; } @@ -148,14 +149,14 @@ } +/* .vanstyle{ + button: not([size='mini']) { + user agent stylesheetmin-height: 40px; + width: 650rpx; + margin-left: 20rpx; + margin-right: auto; + + } + +} */ -/* .van-enter-active-class, -.van-leave-active-class { - transition-property: background-color, transform; -} - -.van-enter-class, -.van-leave-to-class { - background-color: red; - transform: rotate(-360deg) translate3d(-100%, -100%, 0); -} */ \ No newline at end of file diff --git a/miniprogram/pages/log/log.js b/miniprogram/pages/log/log.js deleted file mode 100644 index 83ba349..0000000 --- a/miniprogram/pages/log/log.js +++ /dev/null @@ -1,66 +0,0 @@ -// pages/log/log.js -Page({ - - /** - * 页面的初始数据 - */ - data: { - - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - - }, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { - - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - - }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { - - }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { - - } -}) \ No newline at end of file diff --git a/miniprogram/pages/log/log.json b/miniprogram/pages/log/log.json deleted file mode 100644 index 8835af0..0000000 --- a/miniprogram/pages/log/log.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "usingComponents": {} -} \ No newline at end of file diff --git a/miniprogram/pages/log/log.wxml b/miniprogram/pages/log/log.wxml deleted file mode 100644 index a510ad6..0000000 --- a/miniprogram/pages/log/log.wxml +++ /dev/null @@ -1,2 +0,0 @@ - -pages/log/log.wxml diff --git a/miniprogram/pages/log/log.wxss b/miniprogram/pages/log/log.wxss deleted file mode 100644 index 23db318..0000000 --- a/miniprogram/pages/log/log.wxss +++ /dev/null @@ -1 +0,0 @@ -/* pages/log/log.wxss */ \ No newline at end of file diff --git a/miniprogram/pages/login/login.js b/miniprogram/pages/login/login.js index a4074e7..cb0542a 100644 --- a/miniprogram/pages/login/login.js +++ b/miniprogram/pages/login/login.js @@ -1,11 +1,14 @@ // miniprogram/pages/login/login.js +var app = getApp() Page({ /** * 页面的初始数据 */ data: { - windowWidth:"" + windowWidth: "", + time: 15 * 1000, + showTime: false }, /** @@ -20,9 +23,9 @@ */ onReady: function () { this.setData({ - windowWidth:wx.getSystemInfoSync().windowWidth + windowWidth: wx.getSystemInfoSync().windowWidth }) - + }, /** @@ -66,14 +69,158 @@ onShareAppMessage: function () { }, + + + showLoading: function (message) { + if (wx.showLoading) { + // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 + wx.showLoading({ + title: message, + mask: true + }); + } else { + // 低版本采用Toast兼容处理并将时间设为20秒以免自动消失 + wx.showToast({ + title: message, + icon: 'loading', + mask: true, + duration: 20000 + }); + } + }, + hideLoading: function () { + if (wx.hideLoading) { + // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 + wx.hideLoading(); + } else { + wx.hideToast(); + } + }, + + //注册 loginClick: function () { + var that = this + that.showLoading("授权中...") + wx.login({ + success: function (res) { + if (res.code) { + wx.request({ + url: app.globalData.httpsUrl + "appUserOpenid/login", + data: { + code: res.code + }, + success: function (res) { + app.globalData.openid = res.data.data + wx.getUserInfo({ + success: (res) => { + var nickname = res.userInfo.nickName; + app.globalData.nickName = nickname; + //openid绑定昵称存入后台 + wx.request({ + url: app.globalData.httpsUrl + "appUserOpenid/add", + data: { + attr: nickname, + openid: app.globalData.openid + }, + success: function (res) { + that.hideLoading(); + wx.showToast({ + title: res.data.data+",\r\n请从正式版入口登录!", + icon: 'none', + duration: 2000 + }) - wx.navigateTo({ - - url: '../farmermain/farmermain', - + // //授权成功后跳转 + // wx.switchTab({ + // url: '../indexapp/indexapp' + // }) + } + }) + }, + fail: function (err) { + that.hideLoading(); + } + }) + }, + fail: function (res) { + that.hideLoading(); + wx.showToast({ + title: '服务器异常', + }) + } + }) + } + }, + fail: function (res) { + that.hideLoading(); + } }) + }, + //登录验证 + loginValidate: function () { + var that = this + that.showLoading("登录中...") + wx.login({ + success: function (res) { + if (res.code) { + console.info(res); + wx.request({ + url: app.globalData.httpsUrl + "appUserOpenid/login", + data: { + code: res.code + }, + success: function (res) { + app.globalData.openid = res.data.data + wx.request({ + url: app.globalData.httpsUrl + "appUserOpenid/validate", + data: { + openid: app.globalData.openid + }, + success: function (res) { + that.hideLoading(); + if (res.data.data) { + app.globalData.userName = res.data.data.attr1 == '' ? res.data.data.attr : res.data.data.attr1 + app.globalData.nickName = res.data.data.attr + app.globalData.role = res.data.data.role + wx.navigateTo({ + url: '../notice/notice' + }) + } else { + wx.showToast({ + icon: 'none', + title: '请联系管理员授权', + duration: 2000 + }) + } + }, + fail: function (err) { + that.hideLoading(); + wx.showToast({ + title: '验证失败', + }) + } + }) + }, + fail: function (res) { + that.hideLoading(); + wx.showToast({ + title: '服务器异常', + }) + } + }) + } + }, + fail: function (res) { + that.hideLoading(); + } + }) + }, + + finished() { + this.setData({ + showTime: true + }) }, onClickSubmit: function () { diff --git a/miniprogram/pages/login/login.json b/miniprogram/pages/login/login.json index 8835af0..f2043a3 100644 --- a/miniprogram/pages/login/login.json +++ b/miniprogram/pages/login/login.json @@ -1,3 +1,8 @@ { - "usingComponents": {} + "usingComponents": { + "van-count-down": "../../miniprogram_npm/@vant/weapp/count-down", + "van-button": "../../miniprogram_npm/@vant/weapp/button" + }, + "navigationBarBackgroundColor": "#E6D480", + "disableScroll":true } \ No newline at end of file diff --git a/miniprogram/pages/login/login.wxml b/miniprogram/pages/login/login.wxml index c69df42..cf2ec72 100644 --- a/miniprogram/pages/login/login.wxml +++ b/miniprogram/pages/login/login.wxml @@ -1,21 +1,46 @@ + - + + + - + + + +    本程序为施工日志管理小程序,为航天二院智慧市 +政技术研究室内部系统,不对外开放。出于对数据信 +息安全的考虑,在您首次使用小程序时,请先对小程 +序进行授权,授权后的用户可以正常对小程序进行编 +辑,谢谢您的配合! + + + + + + + + 授权/登录 + + + - + + + diff --git a/miniprogram/pages/login/login.wxss b/miniprogram/pages/login/login.wxss index ca77568..b9fa569 100644 --- a/miniprogram/pages/login/login.wxss +++ b/miniprogram/pages/login/login.wxss @@ -54,7 +54,8 @@ } .form .submit { - margin-top: 80rpx; + + /* margin-top: 80rpx; */ color: #fff; border: 2rpx solid #FFB90F; background-color: #FFB90F; @@ -63,10 +64,30 @@ } .login_image { - width: 200rpx; - height: 200rpx; - padding-top: 100rpx; - padding-left: 250rpx; + width: 750rpx; + height: 360rpx; + /* height: 2300rpx; */ + /* padding-top: 100rpx + padding-left: 250rpx; */ +} +.bottom_image { + width: 750rpx; + height: 32%; + position: fixed; + bottom: 0px; + /* padding-top: 100rpx + padding-left: 250rpx; */ +} +.cover{ + position: fixed; + top: 0rpx; + margin-left: 290rpx; + text-align:center; + font-size: 50rpx; + color: #FFCF00; + width: 750rpx; + z-index:9999; + } -} \ No newline at end of file + \ No newline at end of file diff --git a/miniprogram/pages/notice/notice.js b/miniprogram/pages/notice/notice.js new file mode 100644 index 0000000..7aeafb9 --- /dev/null +++ b/miniprogram/pages/notice/notice.js @@ -0,0 +1,80 @@ +// miniprogram/pages/notice.js +Page({ + + /** + * 页面的初始数据 + */ + data: { + time: 15 * 1000, + showTime: false + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { + this.setData({ + showTime: true + }) + wx.switchTab({ + url: '../indexapp/indexapp' + }) + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + }, + finished() { + this.setData({ + showTime: true + }) + wx.switchTab({ + url: '../indexapp/indexapp' + }) + } +}) \ No newline at end of file diff --git a/cloudfunctions/project.config.json b/cloudfunctions/project.config.json new file mode 100644 index 0000000..2b3119a --- /dev/null +++ b/cloudfunctions/project.config.json @@ -0,0 +1,28 @@ +{ + "appid": "wx2cef527a000f87c9", + "compileType": "miniprogram", + "libVersion": "2.27.3", + "packOptions": { + "ignore": [], + "include": [] + }, + "setting": { + "coverView": true, + "es6": true, + "postcss": true, + "minified": true, + "enhance": true, + "showShadowRootInWxmlPanel": true, + "packNpmRelationList": [], + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + } + }, + "condition": {}, + "editorSetting": { + "tabIndent": "insertSpaces", + "tabSize": 4 + } +} \ No newline at end of file diff --git a/cloudfunctions/project.private.config.json b/cloudfunctions/project.private.config.json new file mode 100644 index 0000000..42ff49d --- /dev/null +++ b/cloudfunctions/project.private.config.json @@ -0,0 +1,7 @@ +{ + "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", + "projectname": "cloudfunctions", + "setting": { + "compileHotReLoad": true + } +} \ No newline at end of file diff --git a/miniprogram/app.js b/miniprogram/app.js index 51d56f3..50a8a54 100644 --- a/miniprogram/app.js +++ b/miniprogram/app.js @@ -18,13 +18,15 @@ // this.globalData = {} }, globalData: { - // url: "http://111.198.10.15:11604/", - httpsUrl: "https://logapi.smartlog.work/", - httpsTestUrl: "https://smartlog.work/prodapi4test/", - url: "http://139.198.18.188:8083/", + httpsUrl: "https://logapi.smartlog.work/", + // httpsUrl: "http://139.198.18.188:8083/", // url: "http://127.0.0.1:8083/", - // httpsUrl: "http://127.0.0.1:8083/", + //httpsUrl: "http://127.0.0.1:8083/", openid: null, - indexCount:1 - }, + indexCount:1, + nickName:"", + userName:"", + role:"", + devcode:"" + } }) diff --git a/miniprogram/app.json b/miniprogram/app.json index d23f798..2b6db76 100644 --- a/miniprogram/app.json +++ b/miniprogram/app.json @@ -1,15 +1,17 @@ { "cloud": true, "pages": [ + "pages/login/login", "pages/indexapp/indexapp", "pages/earth/earth", "pages/applog/applog", "pages/addDevice/addDevice", "pages/addDevicelog/addDeviceLog", - "pages/searchLog/searchLog" + "pages/searchLog/searchLog", + "pages/notice/notice" ], "window": { - "backgroundColor": "#F6F6F6", + "backgroundColor": "#E6D480", "backgroundTextStyle": "light", "navigationBarBackgroundColor": "#FFCF00", "navigationBarTitleText": "智慧施工", @@ -46,11 +48,11 @@ "desc": "你的位置信息将用于小程序位置接口的效果展示" } }, + "requiredPrivateInfos": ["getLocation", "chooseLocation"], "networkTimeout": { "request": 30000, "connectSocket": 30000, "uploadFile": 30000, "downloadFile": 30000 - }, - "style": "v2" + } } \ No newline at end of file diff --git a/miniprogram/images/applocat.png b/miniprogram/images/applocat.png new file mode 100644 index 0000000..fe49f54 --- /dev/null +++ b/miniprogram/images/applocat.png Binary files differ diff --git a/miniprogram/images/back.png b/miniprogram/images/back.png new file mode 100644 index 0000000..32ac82d --- /dev/null +++ b/miniprogram/images/back.png Binary files differ diff --git a/miniprogram/images/bottom.png b/miniprogram/images/bottom.png new file mode 100644 index 0000000..d910e98 --- /dev/null +++ b/miniprogram/images/bottom.png Binary files differ diff --git a/miniprogram/images/header.png b/miniprogram/images/header.png new file mode 100644 index 0000000..6ea222e --- /dev/null +++ b/miniprogram/images/header.png Binary files differ diff --git a/miniprogram/images/login.png b/miniprogram/images/login.png index 8b73cc0..6471c46 100644 --- a/miniprogram/images/login.png +++ b/miniprogram/images/login.png Binary files differ diff --git a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss index 5a591fb..c9c35b5 100644 --- a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss +++ b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:100%;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:100%}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file +@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:650rpx;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:600rpx}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file diff --git a/miniprogram/pages/addDevice/addDevice.js b/miniprogram/pages/addDevice/addDevice.js index 2783674..78f00b7 100644 --- a/miniprogram/pages/addDevice/addDevice.js +++ b/miniprogram/pages/addDevice/addDevice.js @@ -1,5 +1,7 @@ // miniprogram/pages/addDevice/addDevice.js // import WxValidate from '../../utils/WxValidate.js' +var QQMapWX = require('../../libs/qqmap-wx-jssdk.js'); +var qqmapsdk; var app = getApp() Page({ @@ -11,32 +13,10 @@ canvasWidth: '', longitude: '', latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], + option1: [], personoption1: [], projectoption: [], + devtypeList:[], show: false, form: { devcode: "", @@ -59,7 +39,10 @@ project: "", area: "", street: "", - wellname: "" + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '', }, fileList: [] }, @@ -117,12 +100,14 @@ var that = this; //初始化表单内容为上次填写值 var cacheForms = wx.getStorageSync('cacheList') - if (cacheForms) { + cacheForms.photopath1='' + cacheForms.photopath2='' + cacheForms.photopath3='' + that.data.fileList=[] that.setData({ form: cacheForms, devcode: cacheForms.devcode, - }) } var form = that.data.form @@ -155,55 +140,89 @@ } }) + +//获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + that.setData({ + option1: welltypeArr + }) + } + } +}) + + //获取人员下拉列表 - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/getUser", + data:{ + tips:'repair' }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data.code == 200) { + var users = res.data.data + var personArr = []; + for (var i = 0; i < users.length; i++) { + var person = { + text: users[i].name, + value: users[i].name + }; + personArr.push(person); + } + that.setData({ + personoption1: personArr + }) } - that.setData({ - personoption1: personArr - }) } - }).catch(err => { - console.error(err); - }) + }) + - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - that.setData({ - projectoption: projectArr - }) + success(res){ + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); + } + that.setData({ + projectoption: projectArr + }) + } } - }).catch(err => { - console.error(err); - }) + }) + var installtime = 'form.installtimeFmt'; var dateNow = this.formatDate(); this.setData({ @@ -211,8 +230,40 @@ installtimeFmt: dateNow, [installtime]: dateNow, }); + + + + /** + * 获取设备类型下拉列表 + */ + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/deviceType", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var TypeList = res.data.data + var typeArr = []; + for (var i = 0; i < TypeList.length; i++) { + var type = { + text: TypeList[i].productName, + value: TypeList[i].productName + }; + typeArr.push(type); + } + that.setData({ + devtypeList: typeArr + }) + } + } + }) }, + + + /** * 生命周期函数--监听页面初次渲染完成 */ @@ -280,29 +331,7 @@ }, - - //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 - drawText: function (ctx, str, leftWidth, initHeight, titleHeight, canvasWidth) { - var lineWidth = 0; - var lastSubStrIndex = 0; //每次开始截取的字符串的索引 - for (let i = 0; i < str.length; i++) { - lineWidth += ctx.measureText(str[i]).width; - if (lineWidth > canvasWidth) { - ctx.fillText(str.substring(lastSubStrIndex, i), leftWidth, initHeight); //绘制截取部分 - initHeight = initHeight + leftWidth * 2; //22为字体的高度 - lineWidth = 0; - lastSubStrIndex = i; - // titleHeight += 40; - } - if (i == str.length - 1) { //绘制剩余部分 - ctx.fillText(str.substring(lastSubStrIndex, i + 1), leftWidth, initHeight); - } - } - // // 标题border-bottom 线距顶部距离 - // titleHeight = titleHeight + 10; - // return titleHeight - }, - + //验证表单 formValidate() { if (this.data.form.devcode == "") { @@ -312,27 +341,20 @@ }) return false } - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } if (this.data.form.wellcode == "") { wx.showToast({ icon: 'none', @@ -348,22 +370,10 @@ }) return false } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null) { + + if (this.data.form.installperson == "") { wx.showToast({ icon: 'none', title: '安装人员不能为空!', @@ -408,56 +418,90 @@ } return true; }, + //提交表单 formSubmit: function (event) { + console.log(this.data.form) + //表单参数验证 if (!this.formValidate()) { return false; } var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDevice', + //验证设备编号长度 + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/getDevTypeLength", data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceAdd/add" + code: encodeURI(this.data.form.devicetype) }, - }).then(res => { - if (res.result.code == 500) { - wx.showToast({ - title: '设备编号已安装!', - }) - } else if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - //用于回显 - wx.setStorageSync('cacheList', that.data.form) - //提交成功后提示用户操作 - if (res.confirm) { - wx.switchTab({ - url: '../earth/earth' - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (""==res.data.data ||res.data.data == that.data.form.devcode.length) { + that.saveDevice() + } else { //编号位数不对提示 + wx.showToast({ + icon: 'none', + title: '设备编号位数不对!', + duration: 1000 + }) + return false + } } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "提交失败", - }) }) }, + + //保存设备基本信息 + saveDevice() { + var that = this; + //设置照片路径 + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopathForm = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopathForm]: fileList[i].url.split("static/")[1] + }) + } + //表单提交 + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 500) { + wx.showToast({ + title: '设备编号已安装!', + }) + } else if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + //用于回显 + wx.setStorageSync('cacheList', that.data.form) + //提交成功后提示用户操作 + if (res.confirm) { + wx.switchTab({ + url: '../earth/earth' + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } + }, + fail(err) { + wx.showToast({ + title: '提交失败!', + }) + } + }) + }, + + //input 输入框设置值 confirm(event) { var that = this; var formValue = event.detail.value; @@ -466,8 +510,30 @@ that.setData({ [fromN]: formValue }) + //若输入是设备编号,自动获取设备类型 + if('devcode'==formName){ + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", + data: { + devcode: formValue, + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + that.setData({ + [formDevicetype]: res.data + }); + } + } + }) + } }, + //扫描设备获取编号和设备类型 scan() { var _this = this; wx.scanCode({ @@ -477,23 +543,28 @@ _this.setData({ [formdevcode]: devcode }); - wx.cloud.callFunction({ - name: 'findModeCode', + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", data: { devcode: devcode, - url: app.globalData.url + "appDeviceAdd/findModeCodeByCode" }, - }).then(res => { - if (res.result) { - var formDevicetype = 'form.devicetype' - _this.setData({ - [formDevicetype]: res.result - }); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + _this.setData({ + [formDevicetype]: res.data + }); + } } }) } }) }, + //粘贴经纬度 paste() { var _this = this; wx.getClipboardData({ @@ -510,9 +581,11 @@ longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), }); + _this.showAddress(_this.data.form.longitude,_this.data.form.latitude,_this) } }) }, + //设置经类型 selectValue(value) { var that = this; @@ -521,6 +594,16 @@ [wellType]: value.detail }) }, + + //设置设备类型 + selectDevType(event) { + var that = this; + var devtype = 'form.devicetype'; + that.setData({ + [devtype]: event.detail + }) + }, + //设置运维人员 selectpersonValue(event) { var that = this; var installPerson = 'form.installperson'; @@ -528,6 +611,7 @@ [installPerson]: event.detail }) }, + //设置项目 selectprojectValue(event) { var that = this; var project = 'form.project'; @@ -535,8 +619,41 @@ [project]: event.detail }) }, + showAddress :function(longitude, latitude, self) { + // 实例化腾讯地图API核心类 + qqmapsdk = new QQMapWX({ + key: 'BGPBZ-C5O3P-ROUDR-LWC4J-63EKH-V5FRX'//此处使用你自己申请的key + }) + // 腾讯地图调用接口 + qqmapsdk.reverseGeocoder({ + location: { + latitude: latitude, + longitude: longitude + }, + success: function (res) { + self.setData({ + 'form.area':res.result.address.slice(0,res.result.address.indexOf('区')+1), + 'form.street':res.result.address.slice(res.result.address.indexOf('区')+1) + }) + }, + fail: function (res) { + console.log(res); + }, + complete: function (res) { + } + }); + }, + //上传照片 afterRead(event) { var _this = this; + if (_this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '请先填写设备编号!\r\n否则水印中无编号', + duration: 2000 + }) + return false + } const { file } = event.detail; @@ -576,78 +693,8 @@ }) } }) - // 压缩图片 - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // //获取图片尺寸 - // wx.getImageInfo({ - // src: convertpath, - // success(res) { - // _this.setData({ - // canvasHeight: res.height, - // canvasWidth: res.width - // }) - // var ctx = wx.createCanvasContext('firstCanvas') - - // //将图片src放到cancas内,宽高为图片大小 - // ctx.drawImage(convertpath, 0, 0, res.width, res.height) - // //将声明的时间放入canvas - // ctx.setFontSize(30 * (res.width / 750)) //注意:设置文字大小必须放在填充文字之前,否则不生效 - // ctx.setFillStyle('blue') - // var text = "编号:" + _this.data.form.devcode + "\n经度:" + _this.data.form.longitude + "\n纬度:" + _this.data.form.latitude - // // _this.drawText(ctx,text,20, 70, 5, res.width) - // _this.drawText(ctx, text, 15 * (res.width / 750), 70 * (res.width / 750), 5, res.width) - - // // ctx.fillText(text, 0, 40) - // // ctx.strokeText(_this.data.form.devcode, 0, 30) - // //生成水印图 - // ctx.draw(false, function () { - // wx.canvasToTempFilePath({ - // canvasId: 'firstCanvas', - // success: (res) => { - // wx.compressImage({ - // src: res.tempFilePath, - // quality: 25, - // success: function (res) { - // //上传照片至服务器 - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: res.tempFilePath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // } - // }) - // //// - // } - // }) - // }) - // } - // }) - // } - // }); }, + //删除照片 deletePhoto(event) { var image_index = event.detail.index var fileList_new = this.data.fileList; diff --git a/miniprogram/pages/addDevice/addDevice.wxml b/miniprogram/pages/addDevice/addDevice.wxml index b0977e2..f12c254 100644 --- a/miniprogram/pages/addDevice/addDevice.wxml +++ b/miniprogram/pages/addDevice/addDevice.wxml @@ -5,18 +5,30 @@ - + + + + + + + + + + + + + - - + + - - - + + + @@ -29,13 +41,13 @@ - + - + - + - + @@ -54,8 +66,7 @@ - - + @@ -68,8 +79,8 @@ - - + + - 保存 + 保存 \ No newline at end of file diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.js b/miniprogram/pages/addDevicelog/addDeviceLog.js index cdec71b..a0dc6da 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.js +++ b/miniprogram/pages/addDevicelog/addDeviceLog.js @@ -3,681 +3,665 @@ var app = getApp(); Page({ - /** - * 页面的初始数据 - */ - data: { - pageName: '', - showMask: false, - today: new Date().getTime(), - longitude: '', - latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], - personoption1: [], - projectoption: [], - devcode: "", - deviceMode: "", - installtimeFmt: '', - show: false, - form: { - devcode: "", - wellcode: "", - welltype: "", - welldepth: "", - installheigt: "", - installperson: "", - installtimeFmt: "", - photopath: "", - factory: "", - workmsg: "", - position: "", - description: "", - longitude: "", - latitude: "", - longitude84: "", - latitude84: "", - devicetype: "", - project: "", - area: "", - street: "", - wellname: "" - }, - fileList: [], - detail: "" - }, + /** + * 页面的初始数据 + */ + data: { + pageName: '', + showMask: false, + today: new Date().getTime(), + longitude: '', + latitude: '', + option1: [], + personoption1: [], + projectoption: [], + devcode: "", + deviceMode: "", + installtimeFmt: '', + show: false, + form: { + devcode: "", + wellcode: "", + welltype: "", + welldepth: "", + installheigt: "", + installperson: "", + installtimeFmt: "", + photopath: "", + factory: "", + workmsg: "", + position: "", + description: "", + longitude: "", + latitude: "", + longitude84: "", + latitude84: "", + devicetype: "", + project: "", + area: "", + street: "", + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '' + }, + fileList: [], + detail: "", + markers: [{ + id: 100, + // iconPath: "../../images/point.png", + latitude: '', + longitude: '', + // label:'1', + width: 25, + height: 35 + }], + }, - onDisplay() { - this.setData({ - show: true - }); - }, - onClose() { - this.setData({ - show: false - }); - }, - formatDate() { - var date = new Date(); - // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; - var seperator1 = "-"; - var month = date.getMonth() + 1; - var strDate = date.getDate(); - var hour = date.getHours() - var minute = date.getMinutes() - var second = date.getSeconds() - month = month > 9 ? month : "0" + month; - strDate = strDate > 9 ? strDate : "0" + strDate; - hour = hour > 9 ? hour : "0" + hour; - minute = minute > 9 ? minute : "0" + minute; - second = second > 9 ? second : "0" + second; - var currentdate = - date.getFullYear() + - seperator1 + - month + - seperator1 + - strDate + - " " + - hour + ":" + - minute + ":" + - second; - return currentdate; + onDisplay() { + this.setData({ + show: true + }); + }, + onClose() { + this.setData({ + show: false + }); + }, + formatDate() { + var date = new Date(); + // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; + var seperator1 = "-"; + var month = date.getMonth() + 1; + var strDate = date.getDate(); + var hour = date.getHours() + var minute = date.getMinutes() + var second = date.getSeconds() + month = month > 9 ? month : "0" + month; + strDate = strDate > 9 ? strDate : "0" + strDate; + hour = hour > 9 ? hour : "0" + hour; + minute = minute > 9 ? minute : "0" + minute; + second = second > 9 ? second : "0" + second; + var currentdate = + date.getFullYear() + + seperator1 + + month + + seperator1 + + strDate + + " " + + hour + ":" + + minute + ":" + + second; + return currentdate; - }, - onConfirm(event) { - var installtime = 'form.installtimeFmt'; - this.setData({ - show: false, - installtimeFmt: this.formatDate(event.detail), - [installtime]: this.formatDate(event.detail), - }); - }, + }, + onConfirm(event) { + var installtime = 'form.installtimeFmt'; + this.setData({ + show: false, + installtimeFmt: this.formatDate(event.detail), + [installtime]: this.formatDate(event.detail), + }); + }, - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - var _this = this; - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" - }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); - } - _this.setData({ - personoption1: personArr - }) + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + var _this = this; + _this.setData({ + 'markers[0].latitude': Number(wx.getStorageSync('resultObject').latitude) , + 'markers[0].longitude': Number(wx.getStorageSync('resultObject').longitude), + // 'markers[0].label':'10', + 'markers[0].width': 18, + 'markers[0].id':1, + 'markers[0].height': 30, + latitude:Number(wx.getStorageSync('resultObject').latitude), + longitude:Number(wx.getStorageSync('resultObject').longitude) + }) + //获取人员下拉列表 + // wx.request({ + // method: "POST", + // url: app.globalData.httpsUrl + "deviceType/getUser", + // data:{ + // tips:'repair' + // }, + // header: { + // 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + // }, + // success(res) { + // if (res.data.code == 200) { + // var users = res.data.data + // var personArr = []; + // for (var i = 0; i < users.length; i++) { + // var person = { + // text: users[i].name, + // value: users[i].name + // }; + // personArr.push(person); + // } + // _this.setData({ + // personoption1: personArr + // }) + // } + // } + // }) + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); } - }).catch(err => { - console.error(err); - }) - - - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" - }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - _this.setData({ - projectoption: projectArr - }) - } - }).catch(err => { - console.error(err); - }) - - if (options.pageName) { - this.setData({ - pageName: options.pageName - }) - } - - if (options.detail) { - - var formObject = JSON.parse(options.detail); _this.setData({ - form: formObject, - detail: options.detail + projectoption: projectArr }) - - _this.setData({ - ['form.installperson']: "", - ['form.installtimeFmt']: "", - ['form.workmsg']: "", - ['form.description']: "" - }) - - const { - fileList = [] - } = _this.data; - if (formObject.photopath1 != "") { - var file1 = { - url: app.globalData.url + "static/" + formObject.photopath1 - } - fileList.push(file1) - } - if (formObject.photopath2 != "") { - var file2 = { - url: app.globalData.url + "static/" + formObject.photopath2 - } - fileList.push(file2) - } - if (formObject.photopath3 != "") { - var file3 = { - url: app.globalData.url + "static/" + formObject.photopath3 - } - fileList.push(file3) - } - - _this.setData({ - fileList - }); } - var installtime = 'form.installtimeFmt'; - var dateNow = this.formatDate(); - this.setData({ - installtimeFmt: dateNow, - [installtime]: dateNow, - }); - }, + } + }) - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { + //获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + _this.setData({ + option1: welltypeArr + }) + } + } +}) - }, + //跳转时带入参数返回哪页 + if (options.pageName) { + this.setData({ + pageName: options.pageName + }) + } + //跳转时带入参数设备的安装信息 + if (wx.getStorageSync('resultObject')) { + var formObject = wx.getStorageSync('resultObject') + _this.setData({ + form: formObject, + detail: formObject + }) - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { + _this.setData({ + ['form.installperson']: app.globalData.userName, + ['form.installtimeFmt']: "", + ['form.workmsg']: "", + ['form.description']: "" + }) - }, + const { + fileList = [] + } = _this.data; + if (formObject.photopath1 != "") { + var file1 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath1 + } + fileList.push(file1) + } + if (formObject.photopath2 != "") { + var file2 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath2 + } + fileList.push(file2) + } + if (formObject.photopath3 != "") { + var file3 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath3 + } + fileList.push(file3) + } + _this.setData({ + fileList + }); + } + var installtime = 'form.installtimeFmt'; + var dateNow = this.formatDate(); + this.setData({ + installtimeFmt: dateNow, + [installtime]: dateNow, + }); + }, - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, - }, + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + wx.removeStorageSync('resultObject') + }, - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, - }, + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { + }, - }, + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { + }, - }, + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { + }, - }, + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + }, - /** - * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true - **/ + /** + * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true + **/ - isNumber: function (val) { + isNumber: function (val) { - var regPos = /^[0-9]*$/; //非负浮点数 - var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数 - if (regPos.test(val) || regNeg.test(val)) { - return false; - } else { - return true; - } + var regPos = /^[0-9]*$/; //非负浮点数 + var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数 + if (regPos.test(val) || regNeg.test(val)) { + return false; + } else { + return true; + } - }, + }, - formValidate() { + formValidate() { - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } - if (this.data.form.wellcode == "") { - wx.showToast({ - icon: 'none', - title: '井编号不能为空!', - }) - return false - } - if (this.data.form.devicetype == "") { - wx.showToast({ - icon: 'none', - title: '设备类型不能为空!', - }) - return false - } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + if (this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '设备编号不能为空!', + }) + return false + } + if (this.data.form.wellcode == "") { + wx.showToast({ + icon: 'none', + title: '井编号不能为空!', + }) + return false + } + if (this.data.form.devicetype == "") { + wx.showToast({ + icon: 'none', + title: '设备类型不能为空!', + }) + return false + } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null || - this.data.form.installperson == '') { - wx.showToast({ - icon: 'none', - title: '运维人员不能为空!', - }) - return false - } - if (this.data.form.project == "") { - wx.showToast({ - icon: 'none', - title: '所属项目不能为空!', - }) - return false - } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } + if (this.data.form.installperson == null || + this.data.form.installperson == '') { + wx.showToast({ + icon: 'none', + title: '运维人员不能为空!', + }) + return false + } + if (this.data.form.project == "") { + wx.showToast({ + icon: 'none', + title: '所属项目不能为空!', + }) + return false + } - if (this.data.form.welldepth != null) { - if (this.isNumber(this.data.form.welldepth)) { - wx.showToast({ - icon: 'none', - title: '井深必须为数值!', - }) - return false - } - } - if (this.data.form.installheigt != null) { - if (this.isNumber(this.data.form.installheigt)) { - wx.showToast({ - icon: 'none', - title: '到井口距离必须为数值!', - }) - return false - } - } - - return true; - }, - - changeMsg: function () { - var formNew = this.data.form; - var formOld = JSON.parse(this.data.detail); - var descpNew = ""; - if (formNew.devcode != formOld.devcode) { - descpNew += "修改设备编号,原编号:" + formOld.devcode + ",新编号:" + formNew.devcode + ";" - } - if (formNew.devicetype != formOld.devicetype) { - descpNew += "修改设备类型,原设备类型:" + formOld.devicetype + ",新设备类型:" + formNew.devicetype + ";" - } - if (formNew.area != formOld.area) { - descpNew += "修改区,原区:" + formOld.area + ",新区:" + formNew.area + ";" - } - if (formNew.street != formOld.street) { - descpNew += "修改街道,原街道:" + formOld.street + ",新街道:" + formNew.street + ";" - } - if (formNew.wellname != formOld.wellname) { - descpNew += "修改井名称,原井名称:" + formOld.wellname + ",新井名称:" + formNew.wellname + ";" - } - if (formNew.factory != formOld.factory) { - descpNew += "修改权属单位,原权属单位:" + formOld.factory + ",新权属单位:" + formNew.factory + ";" - } - if (formNew.installheigt != formOld.installheigt) { - descpNew += "修改井口距离,原井口距离:" + formOld.installheigt + ",新井口距离:" + formNew.installheigt + ";" - } - if (formNew.installperson != formOld.installperson) { - descpNew += "修改运维人员,原运维人员:" + formOld.installperson + ",新运维人员:" + formNew.installperson + ";" - } - if (formNew.latitude != formOld.latitude) { - descpNew += "修改纬度,原纬度:" + formOld.latitude + ",新纬度:" + formNew.latitude + ";" - } - if (formNew.longitude != formOld.longitude) { - descpNew += "修改经度,原经度:" + formOld.longitude + ",新经度:" + formNew.longitude + ";" - } - if (formNew.position != formOld.position) { - descpNew += "修改位置描述,原位置:" + formOld.position + ",新位置:" + formNew.position + ";" - } - if (formNew.wellcode != formOld.wellcode) { - descpNew += "修改井编号,原编号:" + formOld.wellcode + ",新编号:" + formNew.wellcode + ";" - } - if (formNew.welldepth != formOld.welldepth) { - descpNew += "修改井深,原井深:" + formOld.welldepth + ",新井深:" + formNew.welldepth + ";" - } - if (formNew.welltype != formOld.welltype) { - descpNew += "修改井类型,原井类型:" + formOld.welltype + ",新井类型:" + formNew.welltype + ";" - } - if (formNew.project != formOld.project) { - descpNew += "修改所属项目,原项目:" + formOld.project + ",新项目:" + formNew.project + ";" - } - if (this.data.photopath1 != formOld.photopath1 || - this.data.photopath2 != formOld.photopath2 || - this.data.photopath3 != formOld.photopath3) { - descpNew += "修改照片;" - } - if ("" != formNew.description) { - descpNew += formNew.description; - } - this.setData({ - ['form.description']: descpNew + if (this.data.form.welldepth != null) { + if (this.isNumber(this.data.form.welldepth)) { + wx.showToast({ + icon: 'none', + title: '井深必须为数值!', }) - }, + return false + } + } + if (this.data.form.installheigt != null) { + if (this.isNumber(this.data.form.installheigt)) { + wx.showToast({ + icon: 'none', + title: '到井口距离必须为数值!', + }) + return false + } + } - formSubmit: function (event) { + return true; + }, - if (!this.formValidate()) { - return false; - } - this.changeMsg(); - var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDeviceLog', - data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceLog/add" - }, - }).then(res => { - // var resultObj=JSON.parse(res.result); - if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - if (res.confirm) { - wx.switchTab({ - url: that.data.pageName - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) - } - }).catch(err => { - console.error(err) - wx.showToast({ - title: "提交失败", - }) - }) - }, - confirm(event) { - var that = this; - var formValue = event.detail.value; - var formName = event.target.dataset.id; - var fromN = 'form.' + [formName]; - that.setData({ - [fromN]: formValue - }) - }, + //获取与上次修改的信息 + changeMsg: function () { + var formNew = this.data.form; + console.log(this.data.detail) + var formOld = JSON.parse(this.data.detail); + var descpNew = ""; + if (formNew.devcode != formOld.devcode) { + descpNew += "修改设备编号,原值:" + formOld.devcode + ",新值:" + formNew.devcode + ";" + } + if (formNew.devicetype != formOld.devicetype) { + descpNew += "修改设备类型,原值:" + formOld.devicetype + ",新值:" + formNew.devicetype + ";" + } + if (formNew.area != formOld.area) { + descpNew += "修改区,原值:" + formOld.area + ",新值:" + formNew.area + ";" + } + if (formNew.street != formOld.street) { + descpNew += "修改街道,原值:" + formOld.street + ",新值:" + formNew.street + ";" + } + if (formNew.wellname != formOld.wellname) { + descpNew += "修改井名称,原值:" + formOld.wellname + ",新值:" + formNew.wellname + ";" + } + if (formNew.factory != formOld.factory) { + descpNew += "修改权属单位,原值:" + formOld.factory + ",新值:" + formNew.factory + ";" + } + if (formNew.installheigt != formOld.installheigt) { + descpNew += "修改井口距离,原值:" + formOld.installheigt + ",新值:" + formNew.installheigt + ";" + } + if (formNew.installperson != formOld.installperson) { + descpNew += "修改运维人员,原值:" + formOld.installperson + ",新值:" + formNew.installperson + ";" + } + if (formNew.latitude != formOld.latitude) { + descpNew += "修改纬度,原值:" + formOld.latitude + ",新值:" + formNew.latitude + ";" + } + if (formNew.longitude != formOld.longitude) { + descpNew += "修改经度,原值:" + formOld.longitude + ",新值:" + formNew.longitude + ";" + } + if (formNew.position != formOld.position) { + descpNew += "修改位置描述,原值:" + formOld.position + ",新值:" + formNew.position + ";" + } + if (formNew.wellcode != formOld.wellcode) { + descpNew += "修改井编号,原值:" + formOld.wellcode + ",新值:" + formNew.wellcode + ";" + } + if (formNew.welldepth != formOld.welldepth) { + descpNew += "修改井深,原值:" + formOld.welldepth + ",新值:" + formNew.welldepth + ";" + } + if (formNew.welltype != formOld.welltype) { + descpNew += "修改井类型,原值:" + formOld.welltype + ",新值:" + formNew.welltype + ";" + } + if (formNew.project != formOld.project) { + descpNew += "修改所属项目,原值:" + formOld.project + ",新值:" + formNew.project + ";" + } + if (this.data.form.photopath1 != formOld.photopath1 || + this.data.form.photopath2 != formOld.photopath2 || + this.data.form.photopath3 != formOld.photopath3) { + descpNew += "修改照片;" + } + if ("" != formNew.description) { + descpNew += formNew.description; + } + this.setData({ + ['form.description']: descpNew + }) + }, - scan() { + //提交表单 + formSubmit: function (event) { - wx.scanCode({ - success(res) { - console.log(res) - } - }) + //表单验证 + if (!this.formValidate()) { + return false; + } + //自动生成修改内容 + this.changeMsg(); + //提交权限限制(只有施工人员能修改) + if(app.globalData.role!='repair'){ + wx.showToast({ + icon: 'none', + title: '无权限修改', + duration:2000 + }) + return false + } + var that = this; + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopath = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopath]: fileList[i].url.split("static/")[1] + }) + } + delete that.data.form.installtime + delete that.data.form.createtime + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - paste() { - var _this = this; - wx.getClipboardData({ - success: function (res) { - var longitude = 'form.longitude'; - var latitude = 'form.latitude'; - var longitude84 = 'form.longitude84'; - var latitude84 = 'form.latitude84'; - _this.setData({ - [longitude]: parseFloat(res.data.split(",", 4)[1]).toFixed(6), - [latitude]: parseFloat(res.data.split(",", 4)[0]).toFixed(6), - [longitude84]: "" == (res.data.split(",", 4)[3]) ? "" : parseFloat(res.data.split(",", 4)[3]).toFixed(6), - [latitude84]: "" == (res.data.split(",", 4)[2]) ? "" : parseFloat(res.data.split(",", 4)[2]).toFixed(6), - longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), - latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), - }); - } - }) - }, - selectValue(value) { - var that = this; - var wellType = 'form.welltype'; - that.setData({ - [wellType]: value.detail - }) - }, - selectpersonValue(event) { - var that = this; - var installPerson = 'form.installperson'; - that.setData({ - [installPerson]: event.detail - }) - }, - selectprojectValue(event) { - var that = this; - var project = 'form.project'; - that.setData({ - [project]: event.detail, - showMask: true - }) - }, - open() { - this.setData({ - showMask: true - }) - }, - close() { - this.setData({ - showMask: false - }) - }, - afterRead(event) { - var _this = this; - const { - file - } = event.detail; - const { - fileList = [] - } = _this.data; - var convertpath = ""; - wx.compressImage({ - src: event.detail.file.path, - quality: 25, - success: function (res) { - convertpath = res.tempFilePath; - wx.uploadFile({ - url: app.globalData.httpsUrl + "appDeviceAdd/fileUploadMarker", - filePath:convertpath, - name: 'file', - formData: { - 'text': "编号:" + _this.data.form.devcode + "经度:" + _this.data.form.longitude + "纬度:" + _this.data.form.latitude - }, - header: { - "Content-Type": "multipart/form-data", - 'accept': 'application/json', - }, - success(res) { - if (res.data) { - var url = JSON.parse(res.data); - fileList.push({ - ...file, - url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - }); - _this.setData({ - fileList - }); - } - } + success(res) { + if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + if (res.confirm) { + wx.switchTab({ + url: that.data.pageName }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') } - }) - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // // var base64 = "data:image/png;base64," + wx.getFileSystemManager().readFileSync(convertpath, 'base64'); - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: convertpath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // // wx.cloud.callFunction({ - // // name: 'uploadFile', - // // data: { - // // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // // fileBase64: base64 - // // }, - // // success: function (res) { - // // if (res.result) { - // // fileList.push({ - // // ...file, - // // url: app.globalData.url + "static/" + res.result.data.replace(/\\/g, "/") - // // }); - // // _this.setData({ - // // fileList - // // }); - // // } - // // }, - // // complete: res => { - // // }, - // // }) - // } - // }); + } + }) + } + }, + fail(err) { + wx.showToast({ + title: "提交失败", + }) + } + }) + }, + //报存录入的input信息 + confirm(event) { + var that = this; + var formValue = event.detail.value; + var formName = event.target.dataset.id; + var fromN = 'form.' + [formName]; + that.setData({ + [fromN]: formValue + }) + }, + + //扫码 + scan() { + + wx.scanCode({ + success(res) { + console.log(res) + } + }) + }, + //粘贴经纬度 + paste() { + var _this = this; + wx.getClipboardData({ + success: function (res) { + var longitude = 'form.longitude'; + var latitude = 'form.latitude'; + var longitude84 = 'form.longitude84'; + var latitude84 = 'form.latitude84'; + _this.setData({ + [longitude]: parseFloat(res.data.split(",", 4)[1]).toFixed(6), + [latitude]: parseFloat(res.data.split(",", 4)[0]).toFixed(6), + [longitude84]: "" == (res.data.split(",", 4)[3]) ? "" : parseFloat(res.data.split(",", 4)[3]).toFixed(6), + [latitude84]: "" == (res.data.split(",", 4)[2]) ? "" : parseFloat(res.data.split(",", 4)[2]).toFixed(6), + longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), + latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), + }); + } + }) + }, + selectValue(value) { + var that = this; + var wellType = 'form.welltype'; + that.setData({ + [wellType]: value.detail + }) + }, + //运维人员默认为登录人 + // selectpersonValue(event) { + // var that = this; + // var installPerson = 'form.installperson'; + // that.setData({ + // [installPerson]: event.detail + // }) + // }, + selectprojectValue(event) { + var that = this; + var project = 'form.project'; + that.setData({ + [project]: event.detail, + showMask: true + }) + }, + + open() { + this.setData({ + showMask: true + }) + }, + //隐藏textarea,防止遮挡 + close() { + this.setData({ + showMask: false + }) + }, + //上传照片 + afterRead(event) { + var _this = this; + const { + file + } = event.detail; + const { + fileList = [] + } = _this.data; + var convertpath = ""; + wx.compressImage({ + src: event.detail.file.path, + quality: 25, + success: function (res) { + convertpath = res.tempFilePath; + wx.uploadFile({ + url: app.globalData.httpsUrl + "appDeviceAdd/fileUploadMarker", + filePath: convertpath, + name: 'file', + formData: { + 'text': "编号:" + _this.data.form.devcode + "经度:" + _this.data.form.longitude + "纬度:" + _this.data.form.latitude }, - deletePhoto(event) { - var that = this - var image_index = event.detail.index - var fileList_new = that.data.fileList; - wx.showModal({ - content: '确定删除照片?', - success: function (res) { - if (res.confirm) { - fileList_new.splice(image_index, 1); - that.setData({ - fileList: fileList_new - }) - wx.cloud.callFunction({ - name: 'deletePhoto', - data: { - url: app.globalData.url + "appDeviceLog/deletePhoto", - devcode: that.data.form.devcode, - pathIndex: image_index - }, - success: function (res) {}, - complete: res => {}, - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + "Content-Type": "multipart/form-data", + 'accept': 'application/json', }, - }) \ No newline at end of file + success(res) { + if (res.data) { + var url = JSON.parse(res.data); + fileList.push({ + ...file, + url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") + }); + _this.setData({ + fileList + }); + } + } + }) + } + }) + }, + //删除照片 + deletePhoto(event) { + var that = this + var image_index = event.detail.index + var fileList_new = that.data.fileList; + wx.showModal({ + content: '确定删除照片?', + success: function (res) { + if (res.confirm) { + fileList_new.splice(image_index, 1); + that.setData({ + fileList: fileList_new + }) + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deletePhoto", + data: { + devcode: that.data.form.devcode + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) {} + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } +}) \ No newline at end of file diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.wxml b/miniprogram/pages/addDevicelog/addDeviceLog.wxml index 38620d4..b10cc7d 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.wxml +++ b/miniprogram/pages/addDevicelog/addDeviceLog.wxml @@ -1,15 +1,21 @@ - + + + + + - + - - + + - - + + - + @@ -39,24 +45,25 @@ - - - + + + - + - + + @@ -64,7 +71,7 @@ - + @@ -79,9 +86,9 @@ - + - 保存 + 保存 diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.wxss b/miniprogram/pages/addDevicelog/addDeviceLog.wxss index ee0b75c..08d5fd7 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.wxss +++ b/miniprogram/pages/addDevicelog/addDeviceLog.wxss @@ -24,6 +24,17 @@ display: flex; align-items: center; } +.map-view{ + width: 750rpx; + height: 485rpx; + position: fixed; + top: 0px; + left: 0px; + z-index: 999; +} +.content{ + margin-top: 495rpx; +} .left { width: 210rpx; diff --git a/miniprogram/pages/addFunction/addFunction.js b/miniprogram/pages/addFunction/addFunction.js deleted file mode 100644 index 4966be3..0000000 --- a/miniprogram/pages/addFunction/addFunction.js +++ /dev/null @@ -1,60 +0,0 @@ -// pages/addFunction/addFunction.js - -const code = `// 云函数入口函数 -exports.main = (event, context) => { - console.log(event) - console.log(context) - return { - sum: event.a + event.b - } -}` - -Page({ - - data: { - result: '', - canIUseClipboard: wx.canIUse('setClipboardData'), - }, - - onLoad: function (options) { - - }, - - copyCode: function() { - wx.setClipboardData({ - data: code, - success: function () { - wx.showToast({ - title: '复制成功', - }) - } - }) - }, - - testFunction() { - wx.cloud.callFunction({ - name: 'sum', - data: { - a: 1, - b: 2 - }, - success: res => { - wx.showToast({ - title: '调用成功', - }) - this.setData({ - result: JSON.stringify(res.result) - }) - }, - fail: err => { - wx.showToast({ - icon: 'none', - title: '调用失败', - }) - console.error('[云函数] [sum] 调用失败:', err) - } - }) - }, - -}) - diff --git a/miniprogram/pages/addFunction/addFunction.json b/miniprogram/pages/addFunction/addFunction.json deleted file mode 100644 index a9a50c5..0000000 --- a/miniprogram/pages/addFunction/addFunction.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "navigationBarTitleText": "云函数指引", - "usingComponents": {} -} \ No newline at end of file diff --git a/miniprogram/pages/addFunction/addFunction.wxml b/miniprogram/pages/addFunction/addFunction.wxml deleted file mode 100644 index 3a10626..0000000 --- a/miniprogram/pages/addFunction/addFunction.wxml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - 测试云函数 - - - 期望输出:{"sum":3} - - - 调用结果:{{result}} - - - - - 新增云函数 - 1. 在云函数根目录 cloudfunctions 上右键选择新建云函数,命名为 sum - 2. 在创建的 cloudfunctions/sum/index.js 文件中添加如下代码 - - - 3. 在 cloudfunctions/sum 目录上右键上传并部署 - 4. 点击测试云函数测试 - 5. 打开云开发云函数管理页,选择 sum 云函数 - 6. 查看 sum 的调用日志 - 进阶:可在云函数中使用 wx-server-sdk 操作数据库,文件存储和调用其他云函数,详见文档 - - - diff --git a/miniprogram/pages/addFunction/addFunction.wxss b/miniprogram/pages/addFunction/addFunction.wxss deleted file mode 100644 index 7ac8619..0000000 --- a/miniprogram/pages/addFunction/addFunction.wxss +++ /dev/null @@ -1,3 +0,0 @@ -/* pages/addFunction/addFunction.wxss */ - -@import "../../style/guide.wxss"; \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.js b/miniprogram/pages/applog/applog.js index 0e8c185..189e61f 100644 --- a/miniprogram/pages/applog/applog.js +++ b/miniprogram/pages/applog/applog.js @@ -13,98 +13,25 @@ isSeach: "false", params: {}, total: 0, - show: false + show: false, + delBtnWidth: 100, //删除按钮宽度单位(rpx) + activeIndex: -1, + list_style: '' }, - - touchE: function (e) { - // console.log(e); - var that = this - if (e.changedTouches.length == 1) { - //手指移动结束后触摸点位置的X坐标 - var endX = e.changedTouches[0].clientX; - //触摸开始与结束,手指移动的距离 - var disX = that.data.startX - endX; - var delBtnWidth = that.data.delBtnWidth; - //如果距离小于删除按钮的1/2,不显示删除按钮 - var txtStyle = disX > delBtnWidth / 2 ? "left:-" + delBtnWidth + "rpx" : "left:0rpx"; - - //获取手指触摸的是哪一项 - var index = e.currentTarget.dataset.index; - var list = that.data.deviceloglist; - list[index].txtStyle = txtStyle; - //更新列表的状态 - that.setData({ - deviceloglist: list - }); - } - }, - //手指触摸动作开始 记录起点X坐标 - touchstart: function (e) { - //开始触摸时 重置所有删除 - this.data.deviceloglist.forEach(function (v, i) { - if (v.isTouchMove) //只操作为true的 - v.isTouchMove = false; - }) - this.setData({ - startX: e.changedTouches[0].clientX, - startY: e.changedTouches[0].clientY, - deviceloglist: this.data.deviceloglist - }) - }, - //滑动事件处理 - touchmove: function (e) { - var that = this, - index = e.currentTarget.dataset.index, //当前索引 - startX = that.data.startX, //开始X坐标 - startY = that.data.startY, //开始Y坐标 - touchMoveX = e.changedTouches[0].clientX, //滑动变化坐标 - touchMoveY = e.changedTouches[0].clientY, //滑动变化坐标 - //获取滑动角度 - angle = that.angle({ - X: startX, - Y: startY - }, { - X: touchMoveX, - Y: touchMoveY - }); - that.data.deviceloglist.forEach(function (v, i) { - v.isTouchMove = false - //滑动超过30度角 return - if (Math.abs(angle) > 30) return; - if (i == index) { - if (touchMoveX > startX) //右滑 - v.isTouchMove = false - else //左滑 - v.isTouchMove = true - } - }) - //更新数据 - that.setData({ - deviceloglist: that.data.deviceloglist - }) - }, - /** - * 计算滑动角度 - * @param {Object} start 起点坐标 - * @param {Object} end 终点坐标 - */ - angle: function (start, end) { - var _X = end.X - start.X, - _Y = end.Y - start.Y - //返回角度 /Math.atan()返回数字的反正切值 - return 360 * Math.atan(_Y / _X) / (2 * Math.PI); - }, - /** - * 生命周期函数--监听页面加载var_this=this; - */ onLoad: function (options) { - if (options.params) { this.setData({ params: JSON.parse(options.params), isSeach: "true" }) this.initPages() + }else{ + this.setData({ + show: false + }) + //清空参数,重新加载 + this.clearParams(); + this.initPages(); } }, @@ -116,20 +43,33 @@ }, + //点击tabBar事件 + onTabItemTap(item) { + //隐藏历史显示总记录条数 + this.setData({ + show: false + }) + //清空参数,重新加载 + this.clearParams(); + this.initPages(); + }, + + /** * 生命周期函数--监听页面显示 */ onShow: function (options) { - this.setData({ - show:false - }) - if (this.data.isSeach == "false") { - this.clearParams(); - this.initPages(); - } - this.setData({ - isSeach: "false" - }) + + // this.setData({ + // show: false + // }) + // if (this.data.isSeach == "false") { + // this.clearParams(); + // this.initPages(); + // } + // this.setData({ + // isSeach: "false" + // }) }, /** @@ -167,6 +107,119 @@ }, + + //手指触摸动作开始 记录起点X坐标 + touchstart: function (e) { + //开始触摸时 重置所有删除 + this.data.deviceloglist.forEach(function (v, i) { + if (v.isTouchMove) //只操作为true的 + v.isTouchMove = false; + }) + this.setData({ + startX: e.changedTouches[0].clientX, + startY: e.changedTouches[0].clientY, + deviceloglist: this.data.deviceloglist + }) + }, + + //滑动事件处理 + touchmove: function (e) { + var that = this, + index = e.currentTarget.dataset.index, //当前索引 + startX = that.data.startX, //开始X坐标 + startY = that.data.startY, //开始Y坐标 + touchMoveX = e.changedTouches[0].clientX, //滑动变化坐标 + touchMoveY = e.changedTouches[0].clientY, //滑动变化坐标 + //获取滑动角度 + angle = that.angle({ + X: startX, + Y: startY + }, { + X: touchMoveX, + Y: touchMoveY + }); + that.data.deviceloglist.forEach(function (v, i) { + // v.isTouchMove = false + //滑动超过30度角 return + if (Math.abs(angle) > 30) return; + if (i == index) { + if (touchMoveX > startX) //右滑 + v.isTouchMove = false + else //左滑 + v.isTouchMove = true + } + }) + //更新数据 + that.setData({ + deviceloglist: that.data.deviceloglist + }) + }, + + /** + * 计算滑动角度 + * @param {Object} start 起点坐标 + * @param {Object} end 终点坐标 + */ + angle: function (start, end) { + var _X = end.X - start.X, + _Y = end.Y - start.Y + //返回角度 /Math.atan()返回数字的反正切值 + return 360 * Math.atan(_Y / _X) / (2 * Math.PI); + }, + + //删除事件 + delItem: function (e) { + if(app.globalData.role!='repair'){ + wx.showToast({ + icon: 'none', + title: '无权限删除', + duration:2000 + }) + return false + } + var that = this + wx.showModal({ + content: '是否删除?', + success: function (res) { + if (res.confirm) { + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/delete", + data: { + appDeviceAddId: e.currentTarget.dataset.devid + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if(res.data.code=='200'){ + that.data.deviceloglist.splice(e.currentTarget.dataset.index, 1) + that.setData({ + deviceloglist: that.data.deviceloglist, + total: that.data.deviceloglist.length + }) + wx.showToast({ + title: '删除成功!', + icon: 'none', + duration: 1000 + }) + } + }, + fail(err) { + wx.showToast({ + title: '删除失败!', + icon: 'none', + duration: 2000 + }) + } + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + }, + showLoading: function (message) { if (wx.showLoading) { // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 @@ -199,95 +252,105 @@ deviceloglist: [] }) }, + //查询列表数据 initPages: function () { var that = this + that.setData({ + show: false + }) var offsetValue = that.data.deviceloglist.length % 15 > 0 ? parseInt(that.data.deviceloglist.length / 15) + 2 : parseInt(that.data.deviceloglist.length / 15) + 1 - wx.cloud.callFunction({ - name: 'devicelog', + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/listPage", data: { devcode: that.data.params.devcode, devtype: that.data.params.devtype, installtimeFmt: that.data.params.installtimeFmt, project: that.data.params.project, installPerson: that.data.params.installPerson, - url: app.globalData.url + "appDeviceLog/listPage", limit: 15, offset: offsetValue }, - }).then(res => { - if (res.result.data.rows.length > 0) { - var resultJson = res.result - that.setData({ - deviceloglist: that.data.deviceloglist.concat(resultJson.data.rows) - }) - } else if (that.data.deviceloglist.length > 0) { - that.setData({ - show: true, - total: that.data.deviceloglist.length - }) - wx.showToast({ - title: '数据已全部加载完', - icon: 'none', - duration: 2000 - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.data.rows.length > 0) { + var resultJson = res.data + var listArr = resultJson.data.rows + listArr.forEach(function (v, i) { + listArr[i]['isTouchMove'] = false + }) + that.setData({ + deviceloglist: that.data.deviceloglist.concat(listArr) + }) + } else if (that.data.deviceloglist.length > 0) { + that.setData({ + show: true, + total: that.data.deviceloglist.length + }) + wx.showToast({ + title: '数据已全部加载完', + icon: 'none', + duration: 2000 + }) + } + if (offsetValue == 1 && res.data.data.rows.length < 15) { + that.setData({ + show: true, + total: that.data.deviceloglist.length + }) + } } - if(offsetValue==1&&res.result.data.rows.length<15){ - that.setData({ - show: true, - total: that.data.deviceloglist.length - }) - } - // console.log(res); - }).catch(err => { - console.error(err); }) + }, addDetail: function (event) { - this.showLoading("数据请求中..."); - wx.cloud.callFunction({ - name: 'deviceDetail', + var that = this + that.showLoading("数据请求中..."); + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deviceDetail", data: { devcode: event.target.dataset.devcode, - url: app.globalData.url + "appDeviceLog/deviceDetail", }, - }).then(res => { - this.hideLoading(); - var resultObject = JSON.parse(res.result); - var pageName = '../applog/applog' - if (resultObject.code == 200) { - wx.navigateTo({ - url: '../addDevicelog/addDeviceLog?detail=' + - JSON.stringify(resultObject.data) + "&pageName=" + pageName - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + that.hideLoading(); + // var resultObject = JSON.parse(res.data); + var resultObject = res.data; + var pageName = '../applog/applog' + if (resultObject.code == 200) { + wx.setStorageSync('resultObject', resultObject.data) + wx.navigateTo({ + url: '../addDevicelog/addDeviceLog?detail=' + "&pageName=" + pageName + }) + } + }, + fail(err) { + that.hideLoading(); } - }).catch(err => { - this.hideLoading() }) + }, add: function (event) { - wx.reLaunch({ - url: '../earth/earth?devcode=' + event.target.dataset.devcode - // url: '../earth/earth' + app.globalData.devcode = event.target.dataset.devcode; + wx.switchTab({ + url: '../earth/earth' }) + // wx.reLaunch({ + // url: '../earth/earth?devcode=' + event.target.dataset.devcode + // // url: '../earth/earth' + // }) }, onSearch: function () { + var _this = this wx.navigateTo({ - url: '../searchLog/searchLog' + url: '../searchLog/searchLog?params=' + JSON.stringify(_this.data.params) }) - }, - // initPages: function () { - // wx.cloud.callFunction({ - // name: 'devicelog' - // }).then(res => { - // var that = this; - // var jsonList = JSON.parse(res.result) - // that.setData({ - // deviceloglist: jsonList.data.rows - // }) - // console.log(res); - // }).catch(err => { - // console.error(err); - // }) - // } + } }) \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.wxml b/miniprogram/pages/applog/applog.wxml index e9a2352..2bfd041 100644 --- a/miniprogram/pages/applog/applog.wxml +++ b/miniprogram/pages/applog/applog.wxml @@ -1,54 +1,59 @@ - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {{item.devcode}} {{item.devicetype}} + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + {{item.devcode}} {{item.devicetype}} + + {{item.project}} {{item.installtime}}- {{item.installperson}} - - - - - + + + + + + 删除 - - - + + - 共计:{{total}}台 - + 共计:{{total}}台 + \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.wxss b/miniprogram/pages/applog/applog.wxss index 6d3428b..e6e8983 100644 --- a/miniprogram/pages/applog/applog.wxss +++ b/miniprogram/pages/applog/applog.wxss @@ -22,16 +22,18 @@ position: fixed; width: 100%; top: 0rpx; + z-index: 9999; /* margin-bottom: 100rpx; */ } .log-list { /* height: 100rpx; */ - /* display: flex; */ - + display: flex; + width: 100%; padding: 2px; margin-top: 2px; border-bottom: 1px solid #e5e5e5; + overflow: hidden } @@ -53,23 +55,29 @@ left: 35%; margin: 20rpx } - .del { - width: 90px; + /* display: flex; */ + width: 100rpx; display: flex; flex-direction: column; align-items: center; justify-content: center; - color: #fff; - -webkit-transform: translateX(90px); - transform: translateX(90px); - -webkit-transition: all 0.4s; + /* -webkit-transform: translateX(100rpx); */ + transform: translateX(100rpx); + /* -webkit-transition: all 0.4s; */ transition: all 0.4s; - font-size: 35rpx; + color: #fff; + background-color: #fe3e2f; +} +.logrow{ + width: 100%; + transform: translateX(100rpx); + /* -webkit-transform: translateX(100px); */ + margin-left: -100rpx; } -.touch-move-active .content, +.touch-move-active .logrow, .touch-move-active .del { - -webkit-transform: translateX(0); - transform: translateX(0); +/* -webkit-transform: translateX(0); */ +transform: translateX(0); } \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.js b/miniprogram/pages/deployFunctions/deployFunctions.js deleted file mode 100644 index a76b144..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.js +++ /dev/null @@ -1,66 +0,0 @@ -// pages/deployFunctions/deployFunctions.js -Page({ - - /** - * 页面的初始数据 - */ - data: { - - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - - }, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { - - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - - }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { - - }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { - - } -}) \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.json b/miniprogram/pages/deployFunctions/deployFunctions.json deleted file mode 100644 index 7fbedab..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "navigationBarTitleText": "部署云函数", - "usingComponents": {} -} \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.wxml b/miniprogram/pages/deployFunctions/deployFunctions.wxml deleted file mode 100644 index 462b6b6..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.wxml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - 调用失败 - - - 请检查 login 云函数是否已部署 - - - - - 部署 login 云函数 - 1. 确保已通过工具栏云开发入口开通云开发 - 2. 在 cloudfunctions/login 目录上右键上传并部署 - 3. 回到首页,重新点击获取 openid - - - - diff --git a/miniprogram/pages/deployFunctions/deployFunctions.wxss b/miniprogram/pages/deployFunctions/deployFunctions.wxss deleted file mode 100644 index c8803e6..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.wxss +++ /dev/null @@ -1,7 +0,0 @@ -/* pages/deployFunctions/deployFunctions.wxss */ - -@import "../../style/guide.wxss"; - -.black { - color: black; -} \ No newline at end of file diff --git a/miniprogram/pages/earth/earth.js b/miniprogram/pages/earth/earth.js index ae0d3f3..376a6e2 100644 --- a/miniprogram/pages/earth/earth.js +++ b/miniprogram/pages/earth/earth.js @@ -21,19 +21,12 @@ show: false, enableSsatellite: false, windowWidth: 0, - longitude: 113.324520, - latitude: 23.099994, - longitude84: 113.324520, - latitude84: 23.099994, - markers: [{ - id: 0, - iconPath: "../../images/locat.png", - latitude: 23.099994, - longitude: 113.324520, - width: 50, - height: 50 - }], - controls: [], + longitude: "116.627340", + latitude: "39.874390", + longitude84: "", + latitude84: "", + markers: [], + controls: [] }, /** @@ -41,39 +34,13 @@ */ onLoad: function (options) { var that = this; - //获取当前坐标(gcj02) - wx.getLocation({ - type: "gcj02", - altitude: true, - success: function (res) { - that.setData({ - latitude: parseFloat(res.latitude).toFixed(6), - longitude: parseFloat(res.longitude).toFixed(6), - // markers: [{ - // latitude: res.latitude, - // longitude: res.longitude, - // }] - }) - //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 - wx.getLocation({ - type: "wgs84", - altitude: true, - success: function (res) { - that.setData({ - latitude84: parseFloat(res.latitude).toFixed(6), - longitude84: parseFloat(res.longitude).toFixed(6) - }) - } - }) - } - }), - - //设置地图组件 - wx.getSystemInfo({ + //设置地图组件 + wx.getSystemInfo({ success(res) { var windowWidth = res.windowWidth var windowHeight = res.windowHeight var query = wx.createSelectorQuery() + var platform =res.platform query.select('#map').boundingClientRect() query.exec(function (res) { that.setData({ @@ -139,10 +106,20 @@ clickable: true }, { id: 7, - iconPath: '../../images/locat.png', + iconPath: '../../images/applocat.png', position: { - left: res[0].width/2, - top: res[0].height/2, + left: res[0].width / 2 - 20, + top: platform=="ios"?res[0].height / 2 - 80:res[0].height / 2 - 40, + width: 40, + height: 40 + }, + clickable: true + }, { + id: 8, + iconPath: '../../images/back.png', + position: { + left: windowWidth - 40, + top: windowHeight - 140, width: 30, height: 30 }, @@ -150,71 +127,15 @@ }] }) }) - + } - }), + }) + // 实例化API核心类 qqmapsdk = new QQMapWX({ key: 'BGPBZ-C5O3P-ROUDR-LWC4J-63EKH-V5FRX' }) - - if (options.devcode) { - var that = this - var devcode = options.devcode - wx.cloud.callFunction({ - name: 'findListByCodes', - data: { - devcodes: devcode, - url: app.globalData.url + "appDeviceAdd/findListByCodes" - }, - }).then(res => { - if (res.result.code == 200) { - var listResultData = res.result.data; - that.setData({ - listData: listResultData - }) - var markersArr = that.data.markers; - for (var i = 0; i < listResultData.length; i++) { - markersArr = markersArr.concat({ - iconPath: "../../images/locat.png", - id: listResultData[i].id, - callout: { - content: listResultData[i].devcode, - fontSize: '14', - // padding: true, - color: '#00000', - borderColor: '#F4EA2A', - bgColor: '#F4EA2A', - borderWidth: 5, - display: 'ALWAYS', - textAlign: 'center', - // borderRadius: 15 - }, - latitude: listResultData[i].latitude, - longitude: listResultData[i].longitude, - width: 40, - height: 40 - }); - } - this.setData({ - markers: markersArr, - latitude: listResultData[0].latitude, - longitude: listResultData[0].longitude, - marker_latitude: listResultData[0].latitude, - marker_longitude: listResultData[0].longitude, - title: listResultData[0].devcode - }) - } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "无法获取设备地理信息!", - icon: 'none', - duration: 2000 - }) - }) - } }, /** @@ -228,6 +149,97 @@ * 生命周期函数--监听页面显示 */ onShow: function () { + //输入设备编号获取marker位置信息 + var that = this; + if ( app.globalData.devcode!="") { + var devcode = app.globalData.devcode + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/findListByCodes", + data: { + devcodes: devcode, + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + app.globalData.devcode=""; + if (res.data.code == 200) { + var listResultData = res.data.data; + that.setData({ + listData: listResultData + }) + var markersArr = that.data.markers; + for (var i = 0; i < listResultData.length; i++) { + markersArr = markersArr.concat({ + iconPath: "../../images/locat.png", + id: Number(listResultData[i].id), + callout: { + content: "编号:"+listResultData[i].devcode+"\r\n位置:"+listResultData[i].position+"\r\n时间:"+listResultData[i].createtime, + fontSize: '14', + padding: true, + color: '#000000', + borderColor: '#F4EA2A', + bgColor: '#F4EA2A', + borderWidth: 5, + display: 'ALWAYS', + textAlign: 'left', + // borderRadius: 15 + }, + latitude: listResultData[i].latitude, + longitude: listResultData[i].longitude, + width: 40, + height: 40 + }); + } + that.setData({ + markers: markersArr, + latitude: listResultData[0].latitude, + longitude: listResultData[0].longitude, + marker_latitude: listResultData[0].latitude, + marker_longitude: listResultData[0].longitude, + title: listResultData[0].devcode + }) + } + }, + fail(err) { + app.globalData.devcode=""; + wx.showToast({ + title: "无法获取设备地理信息!", + icon: 'none', + duration: 2000 + }) + } + }) +} else { + //获取当前坐标(gcj02) + wx.getLocation({ + type: "gcj02", + altitude: true, + success: function (res) { + that.setData({ + latitude: parseFloat(res.latitude).toFixed(6), + longitude: parseFloat(res.longitude).toFixed(6), + // markers: [{ + // latitude: res.latitude, + // longitude: res.longitude, + // }] + }) + //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 + wx.getLocation({ + type: "wgs84", + altitude: true, + success: function (res) { + that.setData({ + latitude84: parseFloat(res.latitude).toFixed(6), + longitude84: parseFloat(res.longitude).toFixed(6) + }) + } + }) + } + }) +} + }, @@ -265,12 +277,46 @@ onShareAppMessage: function () { }, + + //定位出来 + + locationPosition: function () { + var that = this; + //获取当前坐标(gcj02) + wx.getLocation({ + type: "gcj02", + altitude: true, + success: function (res) { + that.setData({ + latitude: parseFloat(res.latitude).toFixed(6), + longitude: parseFloat(res.longitude).toFixed(6), + // markers: [{ + // latitude: res.latitude, + // longitude: res.longitude + // }] + }) + //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 + wx.getLocation({ + type: "wgs84", + altitude: true, + success: function (res) { + that.setData({ + latitude84: parseFloat(res.latitude).toFixed(6), + longitude84: parseFloat(res.longitude).toFixed(6) + }) + } + }) + } + }) + }, + + //加载地图组件 controltap: function (e) { // console.log(e.controlId); //进入添加设备页 if (1 == e.controlId) { wx.setClipboardData({ - data: this.data.latitude + "," + this.data.longitude+ "," + this.data.latitude84+ "," + this.data.longitude84, + data: this.data.latitude + "," + this.data.longitude + "," + this.data.latitude84 + "," + this.data.longitude84, success: function (res) { wx.getClipboardData({ success: function (res) { @@ -282,6 +328,17 @@ } }) } else if (3 == e.controlId) { + //先定位 + // this.locationPosition() + wx.setClipboardData({ + data: this.data.latitude + "," + this.data.longitude + "," + this.data.latitude84 + "," + this.data.longitude84, + success: function (res) { + wx.showToast({ + title: '坐标已获取', + duration: 1000 + }) + } + }) wx.navigateTo({ url: '../addDevice/addDevice' }) @@ -302,32 +359,15 @@ enableSsatellite: !flag }); } else if (6 == e.controlId) { - var that = this; - //获取当前坐标(gcj02) - wx.getLocation({ - type: "gcj02", - altitude: true, - success: function (res) { - that.setData({ - latitude: parseFloat(res.latitude).toFixed(6), - longitude:parseFloat(res.longitude).toFixed(6), - // markers: [{ - // latitude: res.latitude, - // longitude: res.longitude - // }] - }) - //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 - wx.getLocation({ - type: "wgs84", - altitude: true, - success: function (res) { - that.setData({ - latitude84: parseFloat(res.latitude).toFixed(6), - longitude84: parseFloat(res.longitude).toFixed(6) - }) - } - }) - } + //先清marker + this.setData({ + markers: [] + }) + this.locationPosition() + }else if (8 == e.controlId) { + //跳转日志缓存页 + wx.switchTab({ + url: '../applog/applog', }) } }, @@ -343,63 +383,68 @@ }); }, + //获取设备maker leave() { var that = this; if (that.data.devcodes == "") { return false; } - wx.cloud.callFunction({ - name: 'findListByCodes', + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/findListByCodes", data: { - devcodes: that.data.devcodes, - url: app.globalData.url + "appDeviceAdd/findListByCodes" + devcodes: that.data.devcodes }, - }).then(res => { - if (res.result.code == 200) { - var listResultData = res.result.data; - that.setData({ - listData: listResultData - }) - var markersArr = that.data.markers; - for (var i = 0; i < listResultData.length; i++) { - markersArr = markersArr.concat({ - iconPath: "../../images/locat.png", - id: listResultData[i].id, - callout: { - content: listResultData[i].devcode, - fontSize: '14', - // padding: true, - color: '', - borderColor: '#F4EA2A', - bgColor: '#F4EA2A', - borderWidth: 5, - display: 'ALWAYS', - textAlign: 'center', - // borderRadius: 15 - }, - latitude: listResultData[i].latitude, - longitude: listResultData[i].longitude, - width: 40, - height: 40 - }); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var listResultData = res.data.data; + that.setData({ + listData: listResultData + }) + var markersArr = that.data.markers; + for (var i = 0; i < listResultData.length; i++) { + markersArr = markersArr.concat({ + iconPath: "../../images/locat.png", + id: listResultData[i].id, + callout: { + content: "编号:"+listResultData[i].devcode+"\r\n位置:"+listResultData[i].position+"\r\n时间:"+listResultData[i].createtime, + fontSize: '14', + // padding: true, + color: '#212121', + borderColor: '#F4EA2A', + bgColor: '#F4EA2A', + borderWidth: 5, + display: 'ALWAYS', + textAlign: 'left', + // borderRadius: 15 + }, + latitude: listResultData[i].latitude, + longitude: listResultData[i].longitude, + width: 40, + height: 40 + }); + } + that.setData({ + markers: markersArr, + latitude: listResultData[0].latitude, + longitude: listResultData[0].longitude, + marker_latitude: listResultData[0].latitude, + marker_longitude: listResultData[0].longitude, + title: listResultData[0].devcode + }) } - this.setData({ - markers: markersArr, - latitude: listResultData[0].latitude, - longitude: listResultData[0].longitude, - marker_latitude: listResultData[0].latitude, - marker_longitude: listResultData[0].longitude, - title: listResultData[0].devcode + }, + fail(err) { + wx.showToast({ + title: "无法获取设备地理信息!", + icon: 'none', + duration: 2000 }) } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "无法获取设备地理信息!", - icon: 'none', - duration: 2000 - }) }) }, @@ -422,6 +467,8 @@ } }, + + bindregionchange: function (e) { var that = this if (e.causedBy == "drag") { @@ -445,8 +492,8 @@ that.setData({ latitude: parseFloat(latitude).toFixed(6), longitude: parseFloat(longitude).toFixed(6), - latitude84:"", - longitude84:"", + latitude84: "", + longitude84: "", // markers: markersArr }) // mapCtx.moveToLocation(); @@ -465,16 +512,19 @@ qqmapsdk.search({ keyword: this.data.value, success: function (res) { + console.log(res) if (res && res.data) { _this.setData({ isShow: true, tips: res.data }); } + }, + complete: function (res){ + console.log(res); } }) }, - bindSearch: function (e) { var location = e.target.dataset.location; this.setData({ diff --git a/miniprogram/pages/earth/earth.wxml b/miniprogram/pages/earth/earth.wxml index a0db6ef..87474f8 100644 --- a/miniprogram/pages/earth/earth.wxml +++ b/miniprogram/pages/earth/earth.wxml @@ -1,9 +1,10 @@ + - + {{item.title}} {{item.address}} @@ -17,6 +18,6 @@ + placeholder="请输入定位设备编号用换行隔开" autosize border="{{ false }}" /> \ No newline at end of file diff --git a/miniprogram/pages/indexapp/indexapp.js b/miniprogram/pages/indexapp/indexapp.js index 5063372..849dbdb 100644 --- a/miniprogram/pages/indexapp/indexapp.js +++ b/miniprogram/pages/indexapp/indexapp.js @@ -7,9 +7,8 @@ */ data: { - count:1, - show: false, - onshow:true, + count: 1, + onshow: true, value: "", deviceloglist: [], devcode: "", @@ -21,6 +20,7 @@ // iconPath: "../../images/point.png", latitude: 23.099994, longitude: 113.324520, + label:'1', width: 50, height: 50 }], @@ -31,62 +31,26 @@ * 生命周期函数--监听页面加载 */ onLoad: function (options) { - + }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { - + }, /** * 生命周期函数--监听页面显示 */ onShow: function () { - // if( app.globalData.indexCount>1){ - // this.setData({ - // show:false - // }) - // }else{ - // this.showNotice() - // } - if(app.globalData.indexCount==1){ - this.setData({ - show:true - }) - this.showNotice() - } - app.globalData.indexCount+=1 - if(this.data.onshow){ + if (this.data.onshow) { this.initPages(); } }, - - showNotice: function() { - var that = this - var times = 0 - var i = setInterval(function() { - times++ - if (times >= 15) { - that.setData({ - show:false - }) - wx.showTabBar({ - animation: false, - }) - clearInterval(i) - } else { - wx.hideTabBar({ - animation: false, - }) - } - }, 1000) -}, - /** * 生命周期函数--监听页面隐藏 */ @@ -122,16 +86,27 @@ }, jump: function (event) { - var that = this; var latitude = event.target.dataset.pointLat; var longitude = event.target.dataset.pointLon; + let devcode = event.target.dataset.pointCode; that.setData({ latitude: latitude, longitude: longitude, markers: [{ latitude: latitude, - longitude: longitude + longitude: longitude, + callout: { + display:'ALWAYS',// 常显气泡 + content: devcode, //名称文本 + color: '#fff', //文本颜色 + borderRadius: 5, //边框圆角 + borderWidth: 1, //边框宽度 + borderColor: '#0060ff', //边框颜色 + bgColor: '#0060ff', //背景色 + padding: 5, //文本边缘留白 + textAlign: 'center' //文本对齐方式。有效值: left, right, center + } }] }) }, @@ -142,7 +117,7 @@ var devcode = res.result _this.setData({ devcode: devcode, - onshow:false + onshow: false }); _this.searchlogs(devcode) } @@ -151,40 +126,11 @@ onSearch: function (event) { this.setData({ - devcode:event.detail + devcode: event.detail }) this.searchlogs(event.detail) }, - - // bindregionchange: function (e) { - // var that = this - // if (e.causedBy == "drag") { - // var mapCtx = wx.createMapContext("map") - // mapCtx.getCenterLocation({ - // success: function (res) { - // var markersArr = that.data.markers - // for (var i = 0; i < markersArr.length; i++) { - // if (markersArr[i].iconPath == undefined) { - // markersArr.splice(i, 1) - // } - // } - // var latitude = res.latitude - // var longitude = res.longitude - // markersArr = markersArr.concat({ - // latitude: latitude, - // longitude: longitude - // }) - // that.setData({ - // latitude: latitude, - // longitude: longitude, - // markers: markersArr - // }) - // } - // }) - // } - // }, - showLoading: function (message) { if (wx.showLoading) { // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 @@ -211,81 +157,89 @@ } }, + //加载设备运维详细信息 toDetail: function (event) { - this.showLoading("数据加载中...") - wx.cloud.callFunction({ - name: 'deviceDetail', + var that = this + that.showLoading("数据加载中...") + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deviceDetail", data: { devcode: event.target.dataset.devcode, - url: app.globalData.url + "appDeviceLog/deviceDetail", }, - }).then(res => { - this.hideLoading(); - var resultObject = JSON.parse(res.result); - var pageName='../indexapp/indexapp' - if (resultObject.code == 200) { - wx.navigateTo({ - url: '../addDevicelog/addDeviceLog?detail=' + - JSON.stringify(resultObject.data)+'&pageName='+pageName - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + that.hideLoading(); + var resultObject = res.data; + var pageName = '../indexapp/indexapp' + if (resultObject.code == 200) { + wx.setStorageSync('resultObject', resultObject.data) + wx.navigateTo({ + url: '../addDevicelog/addDeviceLog?detail=' +'&pageName=' + pageName + }) + } + }, + fail(err){ + that.hideLoading(); } - }).catch(err => { - this.hideLoading(); }) }, + //加载列表 getlogs: function (devcode) { var that = this - wx.cloud.callFunction({ - name: 'devicelog', + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/listPage", data: { devcode: devcode, - url: app.globalData.url + "appDeviceLog/listPage", limit: 100, offset: that.data.deviceloglist.length % 100 > 0 ? parseInt(that.data.deviceloglist.length / 100) + 2 : parseInt(that.data.deviceloglist.length / 100) + 1 }, - }).then(res => { - if (res.result) { - // var resultJson = JSON.parse(res.result) - var resultJson = res.result - that.setData({ - deviceloglist: that.data.deviceloglist.concat(resultJson.data.rows) - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + // var resultJson = JSON.parse(res.result) + var resultJson = res.data + that.setData({ + deviceloglist: that.data.deviceloglist.concat(resultJson.data.rows) + }) + } } - console.log(res); - }).catch(err => { - console.error(err); }) }, + //查询列表 searchlogs: function (devcode) { var that = this - wx.cloud.callFunction({ - name: 'devicelog', + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/listPage", data: { devcode: devcode, - url: app.globalData.url + "appDeviceLog/listPage", limit: 100, offset: 1 }, - }).then(res => { - if (res.result) { - var resultJson = res.result - that.setData({ - deviceloglist: resultJson.data.rows, - onshow:true - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var resultJson = res.data + that.setData({ + deviceloglist: resultJson.data.rows, + onshow: true + }) + } } - console.log(res); - }).catch(err => { - console.error(err); }) }, initPages: function () { var that = this; - that.setData({ - devcode: "" - }); wx.getLocation({ type: "gcj02", success: function (res) { @@ -302,6 +256,6 @@ }) } }) - this.searchlogs() + this.data.devcode !== '' ? this.searchlogs(this.data.devcode) : this.searchlogs() }, }) \ No newline at end of file diff --git a/miniprogram/pages/indexapp/indexapp.wxml b/miniprogram/pages/indexapp/indexapp.wxml index 69322a0..f65b082 100644 --- a/miniprogram/pages/indexapp/indexapp.wxml +++ b/miniprogram/pages/indexapp/indexapp.wxml @@ -1,8 +1,12 @@ + + + + - @@ -32,9 +36,15 @@ - + + + + + + + @@ -46,14 +56,14 @@ - + - - + diff --git a/miniprogram/pages/indexapp/indexapp.wxss b/miniprogram/pages/indexapp/indexapp.wxss index b18706a..fc27fcb 100644 --- a/miniprogram/pages/indexapp/indexapp.wxss +++ b/miniprogram/pages/indexapp/indexapp.wxss @@ -128,6 +128,7 @@ .noticeClass{ height: 2300rpx; width: 750rpx; + overflow-y:hidden; } @@ -148,14 +149,14 @@ } +/* .vanstyle{ + button: not([size='mini']) { + user agent stylesheetmin-height: 40px; + width: 650rpx; + margin-left: 20rpx; + margin-right: auto; + + } + +} */ -/* .van-enter-active-class, -.van-leave-active-class { - transition-property: background-color, transform; -} - -.van-enter-class, -.van-leave-to-class { - background-color: red; - transform: rotate(-360deg) translate3d(-100%, -100%, 0); -} */ \ No newline at end of file diff --git a/miniprogram/pages/log/log.js b/miniprogram/pages/log/log.js deleted file mode 100644 index 83ba349..0000000 --- a/miniprogram/pages/log/log.js +++ /dev/null @@ -1,66 +0,0 @@ -// pages/log/log.js -Page({ - - /** - * 页面的初始数据 - */ - data: { - - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - - }, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { - - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - - }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { - - }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { - - } -}) \ No newline at end of file diff --git a/miniprogram/pages/log/log.json b/miniprogram/pages/log/log.json deleted file mode 100644 index 8835af0..0000000 --- a/miniprogram/pages/log/log.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "usingComponents": {} -} \ No newline at end of file diff --git a/miniprogram/pages/log/log.wxml b/miniprogram/pages/log/log.wxml deleted file mode 100644 index a510ad6..0000000 --- a/miniprogram/pages/log/log.wxml +++ /dev/null @@ -1,2 +0,0 @@ - -pages/log/log.wxml diff --git a/miniprogram/pages/log/log.wxss b/miniprogram/pages/log/log.wxss deleted file mode 100644 index 23db318..0000000 --- a/miniprogram/pages/log/log.wxss +++ /dev/null @@ -1 +0,0 @@ -/* pages/log/log.wxss */ \ No newline at end of file diff --git a/miniprogram/pages/login/login.js b/miniprogram/pages/login/login.js index a4074e7..cb0542a 100644 --- a/miniprogram/pages/login/login.js +++ b/miniprogram/pages/login/login.js @@ -1,11 +1,14 @@ // miniprogram/pages/login/login.js +var app = getApp() Page({ /** * 页面的初始数据 */ data: { - windowWidth:"" + windowWidth: "", + time: 15 * 1000, + showTime: false }, /** @@ -20,9 +23,9 @@ */ onReady: function () { this.setData({ - windowWidth:wx.getSystemInfoSync().windowWidth + windowWidth: wx.getSystemInfoSync().windowWidth }) - + }, /** @@ -66,14 +69,158 @@ onShareAppMessage: function () { }, + + + showLoading: function (message) { + if (wx.showLoading) { + // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 + wx.showLoading({ + title: message, + mask: true + }); + } else { + // 低版本采用Toast兼容处理并将时间设为20秒以免自动消失 + wx.showToast({ + title: message, + icon: 'loading', + mask: true, + duration: 20000 + }); + } + }, + hideLoading: function () { + if (wx.hideLoading) { + // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 + wx.hideLoading(); + } else { + wx.hideToast(); + } + }, + + //注册 loginClick: function () { + var that = this + that.showLoading("授权中...") + wx.login({ + success: function (res) { + if (res.code) { + wx.request({ + url: app.globalData.httpsUrl + "appUserOpenid/login", + data: { + code: res.code + }, + success: function (res) { + app.globalData.openid = res.data.data + wx.getUserInfo({ + success: (res) => { + var nickname = res.userInfo.nickName; + app.globalData.nickName = nickname; + //openid绑定昵称存入后台 + wx.request({ + url: app.globalData.httpsUrl + "appUserOpenid/add", + data: { + attr: nickname, + openid: app.globalData.openid + }, + success: function (res) { + that.hideLoading(); + wx.showToast({ + title: res.data.data+",\r\n请从正式版入口登录!", + icon: 'none', + duration: 2000 + }) - wx.navigateTo({ - - url: '../farmermain/farmermain', - + // //授权成功后跳转 + // wx.switchTab({ + // url: '../indexapp/indexapp' + // }) + } + }) + }, + fail: function (err) { + that.hideLoading(); + } + }) + }, + fail: function (res) { + that.hideLoading(); + wx.showToast({ + title: '服务器异常', + }) + } + }) + } + }, + fail: function (res) { + that.hideLoading(); + } }) + }, + //登录验证 + loginValidate: function () { + var that = this + that.showLoading("登录中...") + wx.login({ + success: function (res) { + if (res.code) { + console.info(res); + wx.request({ + url: app.globalData.httpsUrl + "appUserOpenid/login", + data: { + code: res.code + }, + success: function (res) { + app.globalData.openid = res.data.data + wx.request({ + url: app.globalData.httpsUrl + "appUserOpenid/validate", + data: { + openid: app.globalData.openid + }, + success: function (res) { + that.hideLoading(); + if (res.data.data) { + app.globalData.userName = res.data.data.attr1 == '' ? res.data.data.attr : res.data.data.attr1 + app.globalData.nickName = res.data.data.attr + app.globalData.role = res.data.data.role + wx.navigateTo({ + url: '../notice/notice' + }) + } else { + wx.showToast({ + icon: 'none', + title: '请联系管理员授权', + duration: 2000 + }) + } + }, + fail: function (err) { + that.hideLoading(); + wx.showToast({ + title: '验证失败', + }) + } + }) + }, + fail: function (res) { + that.hideLoading(); + wx.showToast({ + title: '服务器异常', + }) + } + }) + } + }, + fail: function (res) { + that.hideLoading(); + } + }) + }, + + finished() { + this.setData({ + showTime: true + }) }, onClickSubmit: function () { diff --git a/miniprogram/pages/login/login.json b/miniprogram/pages/login/login.json index 8835af0..f2043a3 100644 --- a/miniprogram/pages/login/login.json +++ b/miniprogram/pages/login/login.json @@ -1,3 +1,8 @@ { - "usingComponents": {} + "usingComponents": { + "van-count-down": "../../miniprogram_npm/@vant/weapp/count-down", + "van-button": "../../miniprogram_npm/@vant/weapp/button" + }, + "navigationBarBackgroundColor": "#E6D480", + "disableScroll":true } \ No newline at end of file diff --git a/miniprogram/pages/login/login.wxml b/miniprogram/pages/login/login.wxml index c69df42..cf2ec72 100644 --- a/miniprogram/pages/login/login.wxml +++ b/miniprogram/pages/login/login.wxml @@ -1,21 +1,46 @@ + - + + + - + + + +    本程序为施工日志管理小程序,为航天二院智慧市 +政技术研究室内部系统,不对外开放。出于对数据信 +息安全的考虑,在您首次使用小程序时,请先对小程 +序进行授权,授权后的用户可以正常对小程序进行编 +辑,谢谢您的配合! + + + + + + + + 授权/登录 + + + - + + + diff --git a/miniprogram/pages/login/login.wxss b/miniprogram/pages/login/login.wxss index ca77568..b9fa569 100644 --- a/miniprogram/pages/login/login.wxss +++ b/miniprogram/pages/login/login.wxss @@ -54,7 +54,8 @@ } .form .submit { - margin-top: 80rpx; + + /* margin-top: 80rpx; */ color: #fff; border: 2rpx solid #FFB90F; background-color: #FFB90F; @@ -63,10 +64,30 @@ } .login_image { - width: 200rpx; - height: 200rpx; - padding-top: 100rpx; - padding-left: 250rpx; + width: 750rpx; + height: 360rpx; + /* height: 2300rpx; */ + /* padding-top: 100rpx + padding-left: 250rpx; */ +} +.bottom_image { + width: 750rpx; + height: 32%; + position: fixed; + bottom: 0px; + /* padding-top: 100rpx + padding-left: 250rpx; */ +} +.cover{ + position: fixed; + top: 0rpx; + margin-left: 290rpx; + text-align:center; + font-size: 50rpx; + color: #FFCF00; + width: 750rpx; + z-index:9999; + } -} \ No newline at end of file + \ No newline at end of file diff --git a/miniprogram/pages/notice/notice.js b/miniprogram/pages/notice/notice.js new file mode 100644 index 0000000..7aeafb9 --- /dev/null +++ b/miniprogram/pages/notice/notice.js @@ -0,0 +1,80 @@ +// miniprogram/pages/notice.js +Page({ + + /** + * 页面的初始数据 + */ + data: { + time: 15 * 1000, + showTime: false + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { + this.setData({ + showTime: true + }) + wx.switchTab({ + url: '../indexapp/indexapp' + }) + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + }, + finished() { + this.setData({ + showTime: true + }) + wx.switchTab({ + url: '../indexapp/indexapp' + }) + } +}) \ No newline at end of file diff --git a/miniprogram/pages/notice/notice.json b/miniprogram/pages/notice/notice.json new file mode 100644 index 0000000..4c73264 --- /dev/null +++ b/miniprogram/pages/notice/notice.json @@ -0,0 +1,5 @@ +{ + "usingComponents": { + "van-count-down": "../../miniprogram_npm/@vant/weapp/count-down" + } +} \ No newline at end of file diff --git a/cloudfunctions/project.config.json b/cloudfunctions/project.config.json new file mode 100644 index 0000000..2b3119a --- /dev/null +++ b/cloudfunctions/project.config.json @@ -0,0 +1,28 @@ +{ + "appid": "wx2cef527a000f87c9", + "compileType": "miniprogram", + "libVersion": "2.27.3", + "packOptions": { + "ignore": [], + "include": [] + }, + "setting": { + "coverView": true, + "es6": true, + "postcss": true, + "minified": true, + "enhance": true, + "showShadowRootInWxmlPanel": true, + "packNpmRelationList": [], + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + } + }, + "condition": {}, + "editorSetting": { + "tabIndent": "insertSpaces", + "tabSize": 4 + } +} \ No newline at end of file diff --git a/cloudfunctions/project.private.config.json b/cloudfunctions/project.private.config.json new file mode 100644 index 0000000..42ff49d --- /dev/null +++ b/cloudfunctions/project.private.config.json @@ -0,0 +1,7 @@ +{ + "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", + "projectname": "cloudfunctions", + "setting": { + "compileHotReLoad": true + } +} \ No newline at end of file diff --git a/miniprogram/app.js b/miniprogram/app.js index 51d56f3..50a8a54 100644 --- a/miniprogram/app.js +++ b/miniprogram/app.js @@ -18,13 +18,15 @@ // this.globalData = {} }, globalData: { - // url: "http://111.198.10.15:11604/", - httpsUrl: "https://logapi.smartlog.work/", - httpsTestUrl: "https://smartlog.work/prodapi4test/", - url: "http://139.198.18.188:8083/", + httpsUrl: "https://logapi.smartlog.work/", + // httpsUrl: "http://139.198.18.188:8083/", // url: "http://127.0.0.1:8083/", - // httpsUrl: "http://127.0.0.1:8083/", + //httpsUrl: "http://127.0.0.1:8083/", openid: null, - indexCount:1 - }, + indexCount:1, + nickName:"", + userName:"", + role:"", + devcode:"" + } }) diff --git a/miniprogram/app.json b/miniprogram/app.json index d23f798..2b6db76 100644 --- a/miniprogram/app.json +++ b/miniprogram/app.json @@ -1,15 +1,17 @@ { "cloud": true, "pages": [ + "pages/login/login", "pages/indexapp/indexapp", "pages/earth/earth", "pages/applog/applog", "pages/addDevice/addDevice", "pages/addDevicelog/addDeviceLog", - "pages/searchLog/searchLog" + "pages/searchLog/searchLog", + "pages/notice/notice" ], "window": { - "backgroundColor": "#F6F6F6", + "backgroundColor": "#E6D480", "backgroundTextStyle": "light", "navigationBarBackgroundColor": "#FFCF00", "navigationBarTitleText": "智慧施工", @@ -46,11 +48,11 @@ "desc": "你的位置信息将用于小程序位置接口的效果展示" } }, + "requiredPrivateInfos": ["getLocation", "chooseLocation"], "networkTimeout": { "request": 30000, "connectSocket": 30000, "uploadFile": 30000, "downloadFile": 30000 - }, - "style": "v2" + } } \ No newline at end of file diff --git a/miniprogram/images/applocat.png b/miniprogram/images/applocat.png new file mode 100644 index 0000000..fe49f54 --- /dev/null +++ b/miniprogram/images/applocat.png Binary files differ diff --git a/miniprogram/images/back.png b/miniprogram/images/back.png new file mode 100644 index 0000000..32ac82d --- /dev/null +++ b/miniprogram/images/back.png Binary files differ diff --git a/miniprogram/images/bottom.png b/miniprogram/images/bottom.png new file mode 100644 index 0000000..d910e98 --- /dev/null +++ b/miniprogram/images/bottom.png Binary files differ diff --git a/miniprogram/images/header.png b/miniprogram/images/header.png new file mode 100644 index 0000000..6ea222e --- /dev/null +++ b/miniprogram/images/header.png Binary files differ diff --git a/miniprogram/images/login.png b/miniprogram/images/login.png index 8b73cc0..6471c46 100644 --- a/miniprogram/images/login.png +++ b/miniprogram/images/login.png Binary files differ diff --git a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss index 5a591fb..c9c35b5 100644 --- a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss +++ b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:100%;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:100%}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file +@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:650rpx;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:600rpx}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file diff --git a/miniprogram/pages/addDevice/addDevice.js b/miniprogram/pages/addDevice/addDevice.js index 2783674..78f00b7 100644 --- a/miniprogram/pages/addDevice/addDevice.js +++ b/miniprogram/pages/addDevice/addDevice.js @@ -1,5 +1,7 @@ // miniprogram/pages/addDevice/addDevice.js // import WxValidate from '../../utils/WxValidate.js' +var QQMapWX = require('../../libs/qqmap-wx-jssdk.js'); +var qqmapsdk; var app = getApp() Page({ @@ -11,32 +13,10 @@ canvasWidth: '', longitude: '', latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], + option1: [], personoption1: [], projectoption: [], + devtypeList:[], show: false, form: { devcode: "", @@ -59,7 +39,10 @@ project: "", area: "", street: "", - wellname: "" + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '', }, fileList: [] }, @@ -117,12 +100,14 @@ var that = this; //初始化表单内容为上次填写值 var cacheForms = wx.getStorageSync('cacheList') - if (cacheForms) { + cacheForms.photopath1='' + cacheForms.photopath2='' + cacheForms.photopath3='' + that.data.fileList=[] that.setData({ form: cacheForms, devcode: cacheForms.devcode, - }) } var form = that.data.form @@ -155,55 +140,89 @@ } }) + +//获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + that.setData({ + option1: welltypeArr + }) + } + } +}) + + //获取人员下拉列表 - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/getUser", + data:{ + tips:'repair' }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data.code == 200) { + var users = res.data.data + var personArr = []; + for (var i = 0; i < users.length; i++) { + var person = { + text: users[i].name, + value: users[i].name + }; + personArr.push(person); + } + that.setData({ + personoption1: personArr + }) } - that.setData({ - personoption1: personArr - }) } - }).catch(err => { - console.error(err); - }) + }) + - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - that.setData({ - projectoption: projectArr - }) + success(res){ + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); + } + that.setData({ + projectoption: projectArr + }) + } } - }).catch(err => { - console.error(err); - }) + }) + var installtime = 'form.installtimeFmt'; var dateNow = this.formatDate(); this.setData({ @@ -211,8 +230,40 @@ installtimeFmt: dateNow, [installtime]: dateNow, }); + + + + /** + * 获取设备类型下拉列表 + */ + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/deviceType", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var TypeList = res.data.data + var typeArr = []; + for (var i = 0; i < TypeList.length; i++) { + var type = { + text: TypeList[i].productName, + value: TypeList[i].productName + }; + typeArr.push(type); + } + that.setData({ + devtypeList: typeArr + }) + } + } + }) }, + + + /** * 生命周期函数--监听页面初次渲染完成 */ @@ -280,29 +331,7 @@ }, - - //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 - drawText: function (ctx, str, leftWidth, initHeight, titleHeight, canvasWidth) { - var lineWidth = 0; - var lastSubStrIndex = 0; //每次开始截取的字符串的索引 - for (let i = 0; i < str.length; i++) { - lineWidth += ctx.measureText(str[i]).width; - if (lineWidth > canvasWidth) { - ctx.fillText(str.substring(lastSubStrIndex, i), leftWidth, initHeight); //绘制截取部分 - initHeight = initHeight + leftWidth * 2; //22为字体的高度 - lineWidth = 0; - lastSubStrIndex = i; - // titleHeight += 40; - } - if (i == str.length - 1) { //绘制剩余部分 - ctx.fillText(str.substring(lastSubStrIndex, i + 1), leftWidth, initHeight); - } - } - // // 标题border-bottom 线距顶部距离 - // titleHeight = titleHeight + 10; - // return titleHeight - }, - + //验证表单 formValidate() { if (this.data.form.devcode == "") { @@ -312,27 +341,20 @@ }) return false } - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } if (this.data.form.wellcode == "") { wx.showToast({ icon: 'none', @@ -348,22 +370,10 @@ }) return false } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null) { + + if (this.data.form.installperson == "") { wx.showToast({ icon: 'none', title: '安装人员不能为空!', @@ -408,56 +418,90 @@ } return true; }, + //提交表单 formSubmit: function (event) { + console.log(this.data.form) + //表单参数验证 if (!this.formValidate()) { return false; } var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDevice', + //验证设备编号长度 + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/getDevTypeLength", data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceAdd/add" + code: encodeURI(this.data.form.devicetype) }, - }).then(res => { - if (res.result.code == 500) { - wx.showToast({ - title: '设备编号已安装!', - }) - } else if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - //用于回显 - wx.setStorageSync('cacheList', that.data.form) - //提交成功后提示用户操作 - if (res.confirm) { - wx.switchTab({ - url: '../earth/earth' - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (""==res.data.data ||res.data.data == that.data.form.devcode.length) { + that.saveDevice() + } else { //编号位数不对提示 + wx.showToast({ + icon: 'none', + title: '设备编号位数不对!', + duration: 1000 + }) + return false + } } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "提交失败", - }) }) }, + + //保存设备基本信息 + saveDevice() { + var that = this; + //设置照片路径 + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopathForm = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopathForm]: fileList[i].url.split("static/")[1] + }) + } + //表单提交 + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 500) { + wx.showToast({ + title: '设备编号已安装!', + }) + } else if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + //用于回显 + wx.setStorageSync('cacheList', that.data.form) + //提交成功后提示用户操作 + if (res.confirm) { + wx.switchTab({ + url: '../earth/earth' + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } + }, + fail(err) { + wx.showToast({ + title: '提交失败!', + }) + } + }) + }, + + //input 输入框设置值 confirm(event) { var that = this; var formValue = event.detail.value; @@ -466,8 +510,30 @@ that.setData({ [fromN]: formValue }) + //若输入是设备编号,自动获取设备类型 + if('devcode'==formName){ + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", + data: { + devcode: formValue, + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + that.setData({ + [formDevicetype]: res.data + }); + } + } + }) + } }, + //扫描设备获取编号和设备类型 scan() { var _this = this; wx.scanCode({ @@ -477,23 +543,28 @@ _this.setData({ [formdevcode]: devcode }); - wx.cloud.callFunction({ - name: 'findModeCode', + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", data: { devcode: devcode, - url: app.globalData.url + "appDeviceAdd/findModeCodeByCode" }, - }).then(res => { - if (res.result) { - var formDevicetype = 'form.devicetype' - _this.setData({ - [formDevicetype]: res.result - }); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + _this.setData({ + [formDevicetype]: res.data + }); + } } }) } }) }, + //粘贴经纬度 paste() { var _this = this; wx.getClipboardData({ @@ -510,9 +581,11 @@ longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), }); + _this.showAddress(_this.data.form.longitude,_this.data.form.latitude,_this) } }) }, + //设置经类型 selectValue(value) { var that = this; @@ -521,6 +594,16 @@ [wellType]: value.detail }) }, + + //设置设备类型 + selectDevType(event) { + var that = this; + var devtype = 'form.devicetype'; + that.setData({ + [devtype]: event.detail + }) + }, + //设置运维人员 selectpersonValue(event) { var that = this; var installPerson = 'form.installperson'; @@ -528,6 +611,7 @@ [installPerson]: event.detail }) }, + //设置项目 selectprojectValue(event) { var that = this; var project = 'form.project'; @@ -535,8 +619,41 @@ [project]: event.detail }) }, + showAddress :function(longitude, latitude, self) { + // 实例化腾讯地图API核心类 + qqmapsdk = new QQMapWX({ + key: 'BGPBZ-C5O3P-ROUDR-LWC4J-63EKH-V5FRX'//此处使用你自己申请的key + }) + // 腾讯地图调用接口 + qqmapsdk.reverseGeocoder({ + location: { + latitude: latitude, + longitude: longitude + }, + success: function (res) { + self.setData({ + 'form.area':res.result.address.slice(0,res.result.address.indexOf('区')+1), + 'form.street':res.result.address.slice(res.result.address.indexOf('区')+1) + }) + }, + fail: function (res) { + console.log(res); + }, + complete: function (res) { + } + }); + }, + //上传照片 afterRead(event) { var _this = this; + if (_this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '请先填写设备编号!\r\n否则水印中无编号', + duration: 2000 + }) + return false + } const { file } = event.detail; @@ -576,78 +693,8 @@ }) } }) - // 压缩图片 - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // //获取图片尺寸 - // wx.getImageInfo({ - // src: convertpath, - // success(res) { - // _this.setData({ - // canvasHeight: res.height, - // canvasWidth: res.width - // }) - // var ctx = wx.createCanvasContext('firstCanvas') - - // //将图片src放到cancas内,宽高为图片大小 - // ctx.drawImage(convertpath, 0, 0, res.width, res.height) - // //将声明的时间放入canvas - // ctx.setFontSize(30 * (res.width / 750)) //注意:设置文字大小必须放在填充文字之前,否则不生效 - // ctx.setFillStyle('blue') - // var text = "编号:" + _this.data.form.devcode + "\n经度:" + _this.data.form.longitude + "\n纬度:" + _this.data.form.latitude - // // _this.drawText(ctx,text,20, 70, 5, res.width) - // _this.drawText(ctx, text, 15 * (res.width / 750), 70 * (res.width / 750), 5, res.width) - - // // ctx.fillText(text, 0, 40) - // // ctx.strokeText(_this.data.form.devcode, 0, 30) - // //生成水印图 - // ctx.draw(false, function () { - // wx.canvasToTempFilePath({ - // canvasId: 'firstCanvas', - // success: (res) => { - // wx.compressImage({ - // src: res.tempFilePath, - // quality: 25, - // success: function (res) { - // //上传照片至服务器 - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: res.tempFilePath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // } - // }) - // //// - // } - // }) - // }) - // } - // }) - // } - // }); }, + //删除照片 deletePhoto(event) { var image_index = event.detail.index var fileList_new = this.data.fileList; diff --git a/miniprogram/pages/addDevice/addDevice.wxml b/miniprogram/pages/addDevice/addDevice.wxml index b0977e2..f12c254 100644 --- a/miniprogram/pages/addDevice/addDevice.wxml +++ b/miniprogram/pages/addDevice/addDevice.wxml @@ -5,18 +5,30 @@ - + + + + + + + + + + + + + - - + + - - - + + + @@ -29,13 +41,13 @@ - + - + - + - + @@ -54,8 +66,7 @@ - - + @@ -68,8 +79,8 @@ - - + + - 保存 + 保存 \ No newline at end of file diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.js b/miniprogram/pages/addDevicelog/addDeviceLog.js index cdec71b..a0dc6da 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.js +++ b/miniprogram/pages/addDevicelog/addDeviceLog.js @@ -3,681 +3,665 @@ var app = getApp(); Page({ - /** - * 页面的初始数据 - */ - data: { - pageName: '', - showMask: false, - today: new Date().getTime(), - longitude: '', - latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], - personoption1: [], - projectoption: [], - devcode: "", - deviceMode: "", - installtimeFmt: '', - show: false, - form: { - devcode: "", - wellcode: "", - welltype: "", - welldepth: "", - installheigt: "", - installperson: "", - installtimeFmt: "", - photopath: "", - factory: "", - workmsg: "", - position: "", - description: "", - longitude: "", - latitude: "", - longitude84: "", - latitude84: "", - devicetype: "", - project: "", - area: "", - street: "", - wellname: "" - }, - fileList: [], - detail: "" - }, + /** + * 页面的初始数据 + */ + data: { + pageName: '', + showMask: false, + today: new Date().getTime(), + longitude: '', + latitude: '', + option1: [], + personoption1: [], + projectoption: [], + devcode: "", + deviceMode: "", + installtimeFmt: '', + show: false, + form: { + devcode: "", + wellcode: "", + welltype: "", + welldepth: "", + installheigt: "", + installperson: "", + installtimeFmt: "", + photopath: "", + factory: "", + workmsg: "", + position: "", + description: "", + longitude: "", + latitude: "", + longitude84: "", + latitude84: "", + devicetype: "", + project: "", + area: "", + street: "", + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '' + }, + fileList: [], + detail: "", + markers: [{ + id: 100, + // iconPath: "../../images/point.png", + latitude: '', + longitude: '', + // label:'1', + width: 25, + height: 35 + }], + }, - onDisplay() { - this.setData({ - show: true - }); - }, - onClose() { - this.setData({ - show: false - }); - }, - formatDate() { - var date = new Date(); - // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; - var seperator1 = "-"; - var month = date.getMonth() + 1; - var strDate = date.getDate(); - var hour = date.getHours() - var minute = date.getMinutes() - var second = date.getSeconds() - month = month > 9 ? month : "0" + month; - strDate = strDate > 9 ? strDate : "0" + strDate; - hour = hour > 9 ? hour : "0" + hour; - minute = minute > 9 ? minute : "0" + minute; - second = second > 9 ? second : "0" + second; - var currentdate = - date.getFullYear() + - seperator1 + - month + - seperator1 + - strDate + - " " + - hour + ":" + - minute + ":" + - second; - return currentdate; + onDisplay() { + this.setData({ + show: true + }); + }, + onClose() { + this.setData({ + show: false + }); + }, + formatDate() { + var date = new Date(); + // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; + var seperator1 = "-"; + var month = date.getMonth() + 1; + var strDate = date.getDate(); + var hour = date.getHours() + var minute = date.getMinutes() + var second = date.getSeconds() + month = month > 9 ? month : "0" + month; + strDate = strDate > 9 ? strDate : "0" + strDate; + hour = hour > 9 ? hour : "0" + hour; + minute = minute > 9 ? minute : "0" + minute; + second = second > 9 ? second : "0" + second; + var currentdate = + date.getFullYear() + + seperator1 + + month + + seperator1 + + strDate + + " " + + hour + ":" + + minute + ":" + + second; + return currentdate; - }, - onConfirm(event) { - var installtime = 'form.installtimeFmt'; - this.setData({ - show: false, - installtimeFmt: this.formatDate(event.detail), - [installtime]: this.formatDate(event.detail), - }); - }, + }, + onConfirm(event) { + var installtime = 'form.installtimeFmt'; + this.setData({ + show: false, + installtimeFmt: this.formatDate(event.detail), + [installtime]: this.formatDate(event.detail), + }); + }, - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - var _this = this; - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" - }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); - } - _this.setData({ - personoption1: personArr - }) + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + var _this = this; + _this.setData({ + 'markers[0].latitude': Number(wx.getStorageSync('resultObject').latitude) , + 'markers[0].longitude': Number(wx.getStorageSync('resultObject').longitude), + // 'markers[0].label':'10', + 'markers[0].width': 18, + 'markers[0].id':1, + 'markers[0].height': 30, + latitude:Number(wx.getStorageSync('resultObject').latitude), + longitude:Number(wx.getStorageSync('resultObject').longitude) + }) + //获取人员下拉列表 + // wx.request({ + // method: "POST", + // url: app.globalData.httpsUrl + "deviceType/getUser", + // data:{ + // tips:'repair' + // }, + // header: { + // 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + // }, + // success(res) { + // if (res.data.code == 200) { + // var users = res.data.data + // var personArr = []; + // for (var i = 0; i < users.length; i++) { + // var person = { + // text: users[i].name, + // value: users[i].name + // }; + // personArr.push(person); + // } + // _this.setData({ + // personoption1: personArr + // }) + // } + // } + // }) + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); } - }).catch(err => { - console.error(err); - }) - - - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" - }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - _this.setData({ - projectoption: projectArr - }) - } - }).catch(err => { - console.error(err); - }) - - if (options.pageName) { - this.setData({ - pageName: options.pageName - }) - } - - if (options.detail) { - - var formObject = JSON.parse(options.detail); _this.setData({ - form: formObject, - detail: options.detail + projectoption: projectArr }) - - _this.setData({ - ['form.installperson']: "", - ['form.installtimeFmt']: "", - ['form.workmsg']: "", - ['form.description']: "" - }) - - const { - fileList = [] - } = _this.data; - if (formObject.photopath1 != "") { - var file1 = { - url: app.globalData.url + "static/" + formObject.photopath1 - } - fileList.push(file1) - } - if (formObject.photopath2 != "") { - var file2 = { - url: app.globalData.url + "static/" + formObject.photopath2 - } - fileList.push(file2) - } - if (formObject.photopath3 != "") { - var file3 = { - url: app.globalData.url + "static/" + formObject.photopath3 - } - fileList.push(file3) - } - - _this.setData({ - fileList - }); } - var installtime = 'form.installtimeFmt'; - var dateNow = this.formatDate(); - this.setData({ - installtimeFmt: dateNow, - [installtime]: dateNow, - }); - }, + } + }) - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { + //获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + _this.setData({ + option1: welltypeArr + }) + } + } +}) - }, + //跳转时带入参数返回哪页 + if (options.pageName) { + this.setData({ + pageName: options.pageName + }) + } + //跳转时带入参数设备的安装信息 + if (wx.getStorageSync('resultObject')) { + var formObject = wx.getStorageSync('resultObject') + _this.setData({ + form: formObject, + detail: formObject + }) - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { + _this.setData({ + ['form.installperson']: app.globalData.userName, + ['form.installtimeFmt']: "", + ['form.workmsg']: "", + ['form.description']: "" + }) - }, + const { + fileList = [] + } = _this.data; + if (formObject.photopath1 != "") { + var file1 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath1 + } + fileList.push(file1) + } + if (formObject.photopath2 != "") { + var file2 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath2 + } + fileList.push(file2) + } + if (formObject.photopath3 != "") { + var file3 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath3 + } + fileList.push(file3) + } + _this.setData({ + fileList + }); + } + var installtime = 'form.installtimeFmt'; + var dateNow = this.formatDate(); + this.setData({ + installtimeFmt: dateNow, + [installtime]: dateNow, + }); + }, - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, - }, + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + wx.removeStorageSync('resultObject') + }, - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, - }, + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { + }, - }, + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { + }, - }, + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { + }, - }, + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + }, - /** - * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true - **/ + /** + * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true + **/ - isNumber: function (val) { + isNumber: function (val) { - var regPos = /^[0-9]*$/; //非负浮点数 - var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数 - if (regPos.test(val) || regNeg.test(val)) { - return false; - } else { - return true; - } + var regPos = /^[0-9]*$/; //非负浮点数 + var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数 + if (regPos.test(val) || regNeg.test(val)) { + return false; + } else { + return true; + } - }, + }, - formValidate() { + formValidate() { - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } - if (this.data.form.wellcode == "") { - wx.showToast({ - icon: 'none', - title: '井编号不能为空!', - }) - return false - } - if (this.data.form.devicetype == "") { - wx.showToast({ - icon: 'none', - title: '设备类型不能为空!', - }) - return false - } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + if (this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '设备编号不能为空!', + }) + return false + } + if (this.data.form.wellcode == "") { + wx.showToast({ + icon: 'none', + title: '井编号不能为空!', + }) + return false + } + if (this.data.form.devicetype == "") { + wx.showToast({ + icon: 'none', + title: '设备类型不能为空!', + }) + return false + } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null || - this.data.form.installperson == '') { - wx.showToast({ - icon: 'none', - title: '运维人员不能为空!', - }) - return false - } - if (this.data.form.project == "") { - wx.showToast({ - icon: 'none', - title: '所属项目不能为空!', - }) - return false - } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } + if (this.data.form.installperson == null || + this.data.form.installperson == '') { + wx.showToast({ + icon: 'none', + title: '运维人员不能为空!', + }) + return false + } + if (this.data.form.project == "") { + wx.showToast({ + icon: 'none', + title: '所属项目不能为空!', + }) + return false + } - if (this.data.form.welldepth != null) { - if (this.isNumber(this.data.form.welldepth)) { - wx.showToast({ - icon: 'none', - title: '井深必须为数值!', - }) - return false - } - } - if (this.data.form.installheigt != null) { - if (this.isNumber(this.data.form.installheigt)) { - wx.showToast({ - icon: 'none', - title: '到井口距离必须为数值!', - }) - return false - } - } - - return true; - }, - - changeMsg: function () { - var formNew = this.data.form; - var formOld = JSON.parse(this.data.detail); - var descpNew = ""; - if (formNew.devcode != formOld.devcode) { - descpNew += "修改设备编号,原编号:" + formOld.devcode + ",新编号:" + formNew.devcode + ";" - } - if (formNew.devicetype != formOld.devicetype) { - descpNew += "修改设备类型,原设备类型:" + formOld.devicetype + ",新设备类型:" + formNew.devicetype + ";" - } - if (formNew.area != formOld.area) { - descpNew += "修改区,原区:" + formOld.area + ",新区:" + formNew.area + ";" - } - if (formNew.street != formOld.street) { - descpNew += "修改街道,原街道:" + formOld.street + ",新街道:" + formNew.street + ";" - } - if (formNew.wellname != formOld.wellname) { - descpNew += "修改井名称,原井名称:" + formOld.wellname + ",新井名称:" + formNew.wellname + ";" - } - if (formNew.factory != formOld.factory) { - descpNew += "修改权属单位,原权属单位:" + formOld.factory + ",新权属单位:" + formNew.factory + ";" - } - if (formNew.installheigt != formOld.installheigt) { - descpNew += "修改井口距离,原井口距离:" + formOld.installheigt + ",新井口距离:" + formNew.installheigt + ";" - } - if (formNew.installperson != formOld.installperson) { - descpNew += "修改运维人员,原运维人员:" + formOld.installperson + ",新运维人员:" + formNew.installperson + ";" - } - if (formNew.latitude != formOld.latitude) { - descpNew += "修改纬度,原纬度:" + formOld.latitude + ",新纬度:" + formNew.latitude + ";" - } - if (formNew.longitude != formOld.longitude) { - descpNew += "修改经度,原经度:" + formOld.longitude + ",新经度:" + formNew.longitude + ";" - } - if (formNew.position != formOld.position) { - descpNew += "修改位置描述,原位置:" + formOld.position + ",新位置:" + formNew.position + ";" - } - if (formNew.wellcode != formOld.wellcode) { - descpNew += "修改井编号,原编号:" + formOld.wellcode + ",新编号:" + formNew.wellcode + ";" - } - if (formNew.welldepth != formOld.welldepth) { - descpNew += "修改井深,原井深:" + formOld.welldepth + ",新井深:" + formNew.welldepth + ";" - } - if (formNew.welltype != formOld.welltype) { - descpNew += "修改井类型,原井类型:" + formOld.welltype + ",新井类型:" + formNew.welltype + ";" - } - if (formNew.project != formOld.project) { - descpNew += "修改所属项目,原项目:" + formOld.project + ",新项目:" + formNew.project + ";" - } - if (this.data.photopath1 != formOld.photopath1 || - this.data.photopath2 != formOld.photopath2 || - this.data.photopath3 != formOld.photopath3) { - descpNew += "修改照片;" - } - if ("" != formNew.description) { - descpNew += formNew.description; - } - this.setData({ - ['form.description']: descpNew + if (this.data.form.welldepth != null) { + if (this.isNumber(this.data.form.welldepth)) { + wx.showToast({ + icon: 'none', + title: '井深必须为数值!', }) - }, + return false + } + } + if (this.data.form.installheigt != null) { + if (this.isNumber(this.data.form.installheigt)) { + wx.showToast({ + icon: 'none', + title: '到井口距离必须为数值!', + }) + return false + } + } - formSubmit: function (event) { + return true; + }, - if (!this.formValidate()) { - return false; - } - this.changeMsg(); - var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDeviceLog', - data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceLog/add" - }, - }).then(res => { - // var resultObj=JSON.parse(res.result); - if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - if (res.confirm) { - wx.switchTab({ - url: that.data.pageName - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) - } - }).catch(err => { - console.error(err) - wx.showToast({ - title: "提交失败", - }) - }) - }, - confirm(event) { - var that = this; - var formValue = event.detail.value; - var formName = event.target.dataset.id; - var fromN = 'form.' + [formName]; - that.setData({ - [fromN]: formValue - }) - }, + //获取与上次修改的信息 + changeMsg: function () { + var formNew = this.data.form; + console.log(this.data.detail) + var formOld = JSON.parse(this.data.detail); + var descpNew = ""; + if (formNew.devcode != formOld.devcode) { + descpNew += "修改设备编号,原值:" + formOld.devcode + ",新值:" + formNew.devcode + ";" + } + if (formNew.devicetype != formOld.devicetype) { + descpNew += "修改设备类型,原值:" + formOld.devicetype + ",新值:" + formNew.devicetype + ";" + } + if (formNew.area != formOld.area) { + descpNew += "修改区,原值:" + formOld.area + ",新值:" + formNew.area + ";" + } + if (formNew.street != formOld.street) { + descpNew += "修改街道,原值:" + formOld.street + ",新值:" + formNew.street + ";" + } + if (formNew.wellname != formOld.wellname) { + descpNew += "修改井名称,原值:" + formOld.wellname + ",新值:" + formNew.wellname + ";" + } + if (formNew.factory != formOld.factory) { + descpNew += "修改权属单位,原值:" + formOld.factory + ",新值:" + formNew.factory + ";" + } + if (formNew.installheigt != formOld.installheigt) { + descpNew += "修改井口距离,原值:" + formOld.installheigt + ",新值:" + formNew.installheigt + ";" + } + if (formNew.installperson != formOld.installperson) { + descpNew += "修改运维人员,原值:" + formOld.installperson + ",新值:" + formNew.installperson + ";" + } + if (formNew.latitude != formOld.latitude) { + descpNew += "修改纬度,原值:" + formOld.latitude + ",新值:" + formNew.latitude + ";" + } + if (formNew.longitude != formOld.longitude) { + descpNew += "修改经度,原值:" + formOld.longitude + ",新值:" + formNew.longitude + ";" + } + if (formNew.position != formOld.position) { + descpNew += "修改位置描述,原值:" + formOld.position + ",新值:" + formNew.position + ";" + } + if (formNew.wellcode != formOld.wellcode) { + descpNew += "修改井编号,原值:" + formOld.wellcode + ",新值:" + formNew.wellcode + ";" + } + if (formNew.welldepth != formOld.welldepth) { + descpNew += "修改井深,原值:" + formOld.welldepth + ",新值:" + formNew.welldepth + ";" + } + if (formNew.welltype != formOld.welltype) { + descpNew += "修改井类型,原值:" + formOld.welltype + ",新值:" + formNew.welltype + ";" + } + if (formNew.project != formOld.project) { + descpNew += "修改所属项目,原值:" + formOld.project + ",新值:" + formNew.project + ";" + } + if (this.data.form.photopath1 != formOld.photopath1 || + this.data.form.photopath2 != formOld.photopath2 || + this.data.form.photopath3 != formOld.photopath3) { + descpNew += "修改照片;" + } + if ("" != formNew.description) { + descpNew += formNew.description; + } + this.setData({ + ['form.description']: descpNew + }) + }, - scan() { + //提交表单 + formSubmit: function (event) { - wx.scanCode({ - success(res) { - console.log(res) - } - }) + //表单验证 + if (!this.formValidate()) { + return false; + } + //自动生成修改内容 + this.changeMsg(); + //提交权限限制(只有施工人员能修改) + if(app.globalData.role!='repair'){ + wx.showToast({ + icon: 'none', + title: '无权限修改', + duration:2000 + }) + return false + } + var that = this; + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopath = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopath]: fileList[i].url.split("static/")[1] + }) + } + delete that.data.form.installtime + delete that.data.form.createtime + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - paste() { - var _this = this; - wx.getClipboardData({ - success: function (res) { - var longitude = 'form.longitude'; - var latitude = 'form.latitude'; - var longitude84 = 'form.longitude84'; - var latitude84 = 'form.latitude84'; - _this.setData({ - [longitude]: parseFloat(res.data.split(",", 4)[1]).toFixed(6), - [latitude]: parseFloat(res.data.split(",", 4)[0]).toFixed(6), - [longitude84]: "" == (res.data.split(",", 4)[3]) ? "" : parseFloat(res.data.split(",", 4)[3]).toFixed(6), - [latitude84]: "" == (res.data.split(",", 4)[2]) ? "" : parseFloat(res.data.split(",", 4)[2]).toFixed(6), - longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), - latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), - }); - } - }) - }, - selectValue(value) { - var that = this; - var wellType = 'form.welltype'; - that.setData({ - [wellType]: value.detail - }) - }, - selectpersonValue(event) { - var that = this; - var installPerson = 'form.installperson'; - that.setData({ - [installPerson]: event.detail - }) - }, - selectprojectValue(event) { - var that = this; - var project = 'form.project'; - that.setData({ - [project]: event.detail, - showMask: true - }) - }, - open() { - this.setData({ - showMask: true - }) - }, - close() { - this.setData({ - showMask: false - }) - }, - afterRead(event) { - var _this = this; - const { - file - } = event.detail; - const { - fileList = [] - } = _this.data; - var convertpath = ""; - wx.compressImage({ - src: event.detail.file.path, - quality: 25, - success: function (res) { - convertpath = res.tempFilePath; - wx.uploadFile({ - url: app.globalData.httpsUrl + "appDeviceAdd/fileUploadMarker", - filePath:convertpath, - name: 'file', - formData: { - 'text': "编号:" + _this.data.form.devcode + "经度:" + _this.data.form.longitude + "纬度:" + _this.data.form.latitude - }, - header: { - "Content-Type": "multipart/form-data", - 'accept': 'application/json', - }, - success(res) { - if (res.data) { - var url = JSON.parse(res.data); - fileList.push({ - ...file, - url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - }); - _this.setData({ - fileList - }); - } - } + success(res) { + if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + if (res.confirm) { + wx.switchTab({ + url: that.data.pageName }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') } - }) - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // // var base64 = "data:image/png;base64," + wx.getFileSystemManager().readFileSync(convertpath, 'base64'); - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: convertpath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // // wx.cloud.callFunction({ - // // name: 'uploadFile', - // // data: { - // // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // // fileBase64: base64 - // // }, - // // success: function (res) { - // // if (res.result) { - // // fileList.push({ - // // ...file, - // // url: app.globalData.url + "static/" + res.result.data.replace(/\\/g, "/") - // // }); - // // _this.setData({ - // // fileList - // // }); - // // } - // // }, - // // complete: res => { - // // }, - // // }) - // } - // }); + } + }) + } + }, + fail(err) { + wx.showToast({ + title: "提交失败", + }) + } + }) + }, + //报存录入的input信息 + confirm(event) { + var that = this; + var formValue = event.detail.value; + var formName = event.target.dataset.id; + var fromN = 'form.' + [formName]; + that.setData({ + [fromN]: formValue + }) + }, + + //扫码 + scan() { + + wx.scanCode({ + success(res) { + console.log(res) + } + }) + }, + //粘贴经纬度 + paste() { + var _this = this; + wx.getClipboardData({ + success: function (res) { + var longitude = 'form.longitude'; + var latitude = 'form.latitude'; + var longitude84 = 'form.longitude84'; + var latitude84 = 'form.latitude84'; + _this.setData({ + [longitude]: parseFloat(res.data.split(",", 4)[1]).toFixed(6), + [latitude]: parseFloat(res.data.split(",", 4)[0]).toFixed(6), + [longitude84]: "" == (res.data.split(",", 4)[3]) ? "" : parseFloat(res.data.split(",", 4)[3]).toFixed(6), + [latitude84]: "" == (res.data.split(",", 4)[2]) ? "" : parseFloat(res.data.split(",", 4)[2]).toFixed(6), + longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), + latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), + }); + } + }) + }, + selectValue(value) { + var that = this; + var wellType = 'form.welltype'; + that.setData({ + [wellType]: value.detail + }) + }, + //运维人员默认为登录人 + // selectpersonValue(event) { + // var that = this; + // var installPerson = 'form.installperson'; + // that.setData({ + // [installPerson]: event.detail + // }) + // }, + selectprojectValue(event) { + var that = this; + var project = 'form.project'; + that.setData({ + [project]: event.detail, + showMask: true + }) + }, + + open() { + this.setData({ + showMask: true + }) + }, + //隐藏textarea,防止遮挡 + close() { + this.setData({ + showMask: false + }) + }, + //上传照片 + afterRead(event) { + var _this = this; + const { + file + } = event.detail; + const { + fileList = [] + } = _this.data; + var convertpath = ""; + wx.compressImage({ + src: event.detail.file.path, + quality: 25, + success: function (res) { + convertpath = res.tempFilePath; + wx.uploadFile({ + url: app.globalData.httpsUrl + "appDeviceAdd/fileUploadMarker", + filePath: convertpath, + name: 'file', + formData: { + 'text': "编号:" + _this.data.form.devcode + "经度:" + _this.data.form.longitude + "纬度:" + _this.data.form.latitude }, - deletePhoto(event) { - var that = this - var image_index = event.detail.index - var fileList_new = that.data.fileList; - wx.showModal({ - content: '确定删除照片?', - success: function (res) { - if (res.confirm) { - fileList_new.splice(image_index, 1); - that.setData({ - fileList: fileList_new - }) - wx.cloud.callFunction({ - name: 'deletePhoto', - data: { - url: app.globalData.url + "appDeviceLog/deletePhoto", - devcode: that.data.form.devcode, - pathIndex: image_index - }, - success: function (res) {}, - complete: res => {}, - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + "Content-Type": "multipart/form-data", + 'accept': 'application/json', }, - }) \ No newline at end of file + success(res) { + if (res.data) { + var url = JSON.parse(res.data); + fileList.push({ + ...file, + url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") + }); + _this.setData({ + fileList + }); + } + } + }) + } + }) + }, + //删除照片 + deletePhoto(event) { + var that = this + var image_index = event.detail.index + var fileList_new = that.data.fileList; + wx.showModal({ + content: '确定删除照片?', + success: function (res) { + if (res.confirm) { + fileList_new.splice(image_index, 1); + that.setData({ + fileList: fileList_new + }) + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deletePhoto", + data: { + devcode: that.data.form.devcode + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) {} + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } +}) \ No newline at end of file diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.wxml b/miniprogram/pages/addDevicelog/addDeviceLog.wxml index 38620d4..b10cc7d 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.wxml +++ b/miniprogram/pages/addDevicelog/addDeviceLog.wxml @@ -1,15 +1,21 @@ - + + + + + - + - - + + - - + + - + @@ -39,24 +45,25 @@ - - - + + + - + - + + @@ -64,7 +71,7 @@ - + @@ -79,9 +86,9 @@ - + - 保存 + 保存 diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.wxss b/miniprogram/pages/addDevicelog/addDeviceLog.wxss index ee0b75c..08d5fd7 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.wxss +++ b/miniprogram/pages/addDevicelog/addDeviceLog.wxss @@ -24,6 +24,17 @@ display: flex; align-items: center; } +.map-view{ + width: 750rpx; + height: 485rpx; + position: fixed; + top: 0px; + left: 0px; + z-index: 999; +} +.content{ + margin-top: 495rpx; +} .left { width: 210rpx; diff --git a/miniprogram/pages/addFunction/addFunction.js b/miniprogram/pages/addFunction/addFunction.js deleted file mode 100644 index 4966be3..0000000 --- a/miniprogram/pages/addFunction/addFunction.js +++ /dev/null @@ -1,60 +0,0 @@ -// pages/addFunction/addFunction.js - -const code = `// 云函数入口函数 -exports.main = (event, context) => { - console.log(event) - console.log(context) - return { - sum: event.a + event.b - } -}` - -Page({ - - data: { - result: '', - canIUseClipboard: wx.canIUse('setClipboardData'), - }, - - onLoad: function (options) { - - }, - - copyCode: function() { - wx.setClipboardData({ - data: code, - success: function () { - wx.showToast({ - title: '复制成功', - }) - } - }) - }, - - testFunction() { - wx.cloud.callFunction({ - name: 'sum', - data: { - a: 1, - b: 2 - }, - success: res => { - wx.showToast({ - title: '调用成功', - }) - this.setData({ - result: JSON.stringify(res.result) - }) - }, - fail: err => { - wx.showToast({ - icon: 'none', - title: '调用失败', - }) - console.error('[云函数] [sum] 调用失败:', err) - } - }) - }, - -}) - diff --git a/miniprogram/pages/addFunction/addFunction.json b/miniprogram/pages/addFunction/addFunction.json deleted file mode 100644 index a9a50c5..0000000 --- a/miniprogram/pages/addFunction/addFunction.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "navigationBarTitleText": "云函数指引", - "usingComponents": {} -} \ No newline at end of file diff --git a/miniprogram/pages/addFunction/addFunction.wxml b/miniprogram/pages/addFunction/addFunction.wxml deleted file mode 100644 index 3a10626..0000000 --- a/miniprogram/pages/addFunction/addFunction.wxml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - 测试云函数 - - - 期望输出:{"sum":3} - - - 调用结果:{{result}} - - - - - 新增云函数 - 1. 在云函数根目录 cloudfunctions 上右键选择新建云函数,命名为 sum - 2. 在创建的 cloudfunctions/sum/index.js 文件中添加如下代码 - - - 3. 在 cloudfunctions/sum 目录上右键上传并部署 - 4. 点击测试云函数测试 - 5. 打开云开发云函数管理页,选择 sum 云函数 - 6. 查看 sum 的调用日志 - 进阶:可在云函数中使用 wx-server-sdk 操作数据库,文件存储和调用其他云函数,详见文档 - - - diff --git a/miniprogram/pages/addFunction/addFunction.wxss b/miniprogram/pages/addFunction/addFunction.wxss deleted file mode 100644 index 7ac8619..0000000 --- a/miniprogram/pages/addFunction/addFunction.wxss +++ /dev/null @@ -1,3 +0,0 @@ -/* pages/addFunction/addFunction.wxss */ - -@import "../../style/guide.wxss"; \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.js b/miniprogram/pages/applog/applog.js index 0e8c185..189e61f 100644 --- a/miniprogram/pages/applog/applog.js +++ b/miniprogram/pages/applog/applog.js @@ -13,98 +13,25 @@ isSeach: "false", params: {}, total: 0, - show: false + show: false, + delBtnWidth: 100, //删除按钮宽度单位(rpx) + activeIndex: -1, + list_style: '' }, - - touchE: function (e) { - // console.log(e); - var that = this - if (e.changedTouches.length == 1) { - //手指移动结束后触摸点位置的X坐标 - var endX = e.changedTouches[0].clientX; - //触摸开始与结束,手指移动的距离 - var disX = that.data.startX - endX; - var delBtnWidth = that.data.delBtnWidth; - //如果距离小于删除按钮的1/2,不显示删除按钮 - var txtStyle = disX > delBtnWidth / 2 ? "left:-" + delBtnWidth + "rpx" : "left:0rpx"; - - //获取手指触摸的是哪一项 - var index = e.currentTarget.dataset.index; - var list = that.data.deviceloglist; - list[index].txtStyle = txtStyle; - //更新列表的状态 - that.setData({ - deviceloglist: list - }); - } - }, - //手指触摸动作开始 记录起点X坐标 - touchstart: function (e) { - //开始触摸时 重置所有删除 - this.data.deviceloglist.forEach(function (v, i) { - if (v.isTouchMove) //只操作为true的 - v.isTouchMove = false; - }) - this.setData({ - startX: e.changedTouches[0].clientX, - startY: e.changedTouches[0].clientY, - deviceloglist: this.data.deviceloglist - }) - }, - //滑动事件处理 - touchmove: function (e) { - var that = this, - index = e.currentTarget.dataset.index, //当前索引 - startX = that.data.startX, //开始X坐标 - startY = that.data.startY, //开始Y坐标 - touchMoveX = e.changedTouches[0].clientX, //滑动变化坐标 - touchMoveY = e.changedTouches[0].clientY, //滑动变化坐标 - //获取滑动角度 - angle = that.angle({ - X: startX, - Y: startY - }, { - X: touchMoveX, - Y: touchMoveY - }); - that.data.deviceloglist.forEach(function (v, i) { - v.isTouchMove = false - //滑动超过30度角 return - if (Math.abs(angle) > 30) return; - if (i == index) { - if (touchMoveX > startX) //右滑 - v.isTouchMove = false - else //左滑 - v.isTouchMove = true - } - }) - //更新数据 - that.setData({ - deviceloglist: that.data.deviceloglist - }) - }, - /** - * 计算滑动角度 - * @param {Object} start 起点坐标 - * @param {Object} end 终点坐标 - */ - angle: function (start, end) { - var _X = end.X - start.X, - _Y = end.Y - start.Y - //返回角度 /Math.atan()返回数字的反正切值 - return 360 * Math.atan(_Y / _X) / (2 * Math.PI); - }, - /** - * 生命周期函数--监听页面加载var_this=this; - */ onLoad: function (options) { - if (options.params) { this.setData({ params: JSON.parse(options.params), isSeach: "true" }) this.initPages() + }else{ + this.setData({ + show: false + }) + //清空参数,重新加载 + this.clearParams(); + this.initPages(); } }, @@ -116,20 +43,33 @@ }, + //点击tabBar事件 + onTabItemTap(item) { + //隐藏历史显示总记录条数 + this.setData({ + show: false + }) + //清空参数,重新加载 + this.clearParams(); + this.initPages(); + }, + + /** * 生命周期函数--监听页面显示 */ onShow: function (options) { - this.setData({ - show:false - }) - if (this.data.isSeach == "false") { - this.clearParams(); - this.initPages(); - } - this.setData({ - isSeach: "false" - }) + + // this.setData({ + // show: false + // }) + // if (this.data.isSeach == "false") { + // this.clearParams(); + // this.initPages(); + // } + // this.setData({ + // isSeach: "false" + // }) }, /** @@ -167,6 +107,119 @@ }, + + //手指触摸动作开始 记录起点X坐标 + touchstart: function (e) { + //开始触摸时 重置所有删除 + this.data.deviceloglist.forEach(function (v, i) { + if (v.isTouchMove) //只操作为true的 + v.isTouchMove = false; + }) + this.setData({ + startX: e.changedTouches[0].clientX, + startY: e.changedTouches[0].clientY, + deviceloglist: this.data.deviceloglist + }) + }, + + //滑动事件处理 + touchmove: function (e) { + var that = this, + index = e.currentTarget.dataset.index, //当前索引 + startX = that.data.startX, //开始X坐标 + startY = that.data.startY, //开始Y坐标 + touchMoveX = e.changedTouches[0].clientX, //滑动变化坐标 + touchMoveY = e.changedTouches[0].clientY, //滑动变化坐标 + //获取滑动角度 + angle = that.angle({ + X: startX, + Y: startY + }, { + X: touchMoveX, + Y: touchMoveY + }); + that.data.deviceloglist.forEach(function (v, i) { + // v.isTouchMove = false + //滑动超过30度角 return + if (Math.abs(angle) > 30) return; + if (i == index) { + if (touchMoveX > startX) //右滑 + v.isTouchMove = false + else //左滑 + v.isTouchMove = true + } + }) + //更新数据 + that.setData({ + deviceloglist: that.data.deviceloglist + }) + }, + + /** + * 计算滑动角度 + * @param {Object} start 起点坐标 + * @param {Object} end 终点坐标 + */ + angle: function (start, end) { + var _X = end.X - start.X, + _Y = end.Y - start.Y + //返回角度 /Math.atan()返回数字的反正切值 + return 360 * Math.atan(_Y / _X) / (2 * Math.PI); + }, + + //删除事件 + delItem: function (e) { + if(app.globalData.role!='repair'){ + wx.showToast({ + icon: 'none', + title: '无权限删除', + duration:2000 + }) + return false + } + var that = this + wx.showModal({ + content: '是否删除?', + success: function (res) { + if (res.confirm) { + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/delete", + data: { + appDeviceAddId: e.currentTarget.dataset.devid + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if(res.data.code=='200'){ + that.data.deviceloglist.splice(e.currentTarget.dataset.index, 1) + that.setData({ + deviceloglist: that.data.deviceloglist, + total: that.data.deviceloglist.length + }) + wx.showToast({ + title: '删除成功!', + icon: 'none', + duration: 1000 + }) + } + }, + fail(err) { + wx.showToast({ + title: '删除失败!', + icon: 'none', + duration: 2000 + }) + } + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + }, + showLoading: function (message) { if (wx.showLoading) { // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 @@ -199,95 +252,105 @@ deviceloglist: [] }) }, + //查询列表数据 initPages: function () { var that = this + that.setData({ + show: false + }) var offsetValue = that.data.deviceloglist.length % 15 > 0 ? parseInt(that.data.deviceloglist.length / 15) + 2 : parseInt(that.data.deviceloglist.length / 15) + 1 - wx.cloud.callFunction({ - name: 'devicelog', + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/listPage", data: { devcode: that.data.params.devcode, devtype: that.data.params.devtype, installtimeFmt: that.data.params.installtimeFmt, project: that.data.params.project, installPerson: that.data.params.installPerson, - url: app.globalData.url + "appDeviceLog/listPage", limit: 15, offset: offsetValue }, - }).then(res => { - if (res.result.data.rows.length > 0) { - var resultJson = res.result - that.setData({ - deviceloglist: that.data.deviceloglist.concat(resultJson.data.rows) - }) - } else if (that.data.deviceloglist.length > 0) { - that.setData({ - show: true, - total: that.data.deviceloglist.length - }) - wx.showToast({ - title: '数据已全部加载完', - icon: 'none', - duration: 2000 - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.data.rows.length > 0) { + var resultJson = res.data + var listArr = resultJson.data.rows + listArr.forEach(function (v, i) { + listArr[i]['isTouchMove'] = false + }) + that.setData({ + deviceloglist: that.data.deviceloglist.concat(listArr) + }) + } else if (that.data.deviceloglist.length > 0) { + that.setData({ + show: true, + total: that.data.deviceloglist.length + }) + wx.showToast({ + title: '数据已全部加载完', + icon: 'none', + duration: 2000 + }) + } + if (offsetValue == 1 && res.data.data.rows.length < 15) { + that.setData({ + show: true, + total: that.data.deviceloglist.length + }) + } } - if(offsetValue==1&&res.result.data.rows.length<15){ - that.setData({ - show: true, - total: that.data.deviceloglist.length - }) - } - // console.log(res); - }).catch(err => { - console.error(err); }) + }, addDetail: function (event) { - this.showLoading("数据请求中..."); - wx.cloud.callFunction({ - name: 'deviceDetail', + var that = this + that.showLoading("数据请求中..."); + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deviceDetail", data: { devcode: event.target.dataset.devcode, - url: app.globalData.url + "appDeviceLog/deviceDetail", }, - }).then(res => { - this.hideLoading(); - var resultObject = JSON.parse(res.result); - var pageName = '../applog/applog' - if (resultObject.code == 200) { - wx.navigateTo({ - url: '../addDevicelog/addDeviceLog?detail=' + - JSON.stringify(resultObject.data) + "&pageName=" + pageName - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + that.hideLoading(); + // var resultObject = JSON.parse(res.data); + var resultObject = res.data; + var pageName = '../applog/applog' + if (resultObject.code == 200) { + wx.setStorageSync('resultObject', resultObject.data) + wx.navigateTo({ + url: '../addDevicelog/addDeviceLog?detail=' + "&pageName=" + pageName + }) + } + }, + fail(err) { + that.hideLoading(); } - }).catch(err => { - this.hideLoading() }) + }, add: function (event) { - wx.reLaunch({ - url: '../earth/earth?devcode=' + event.target.dataset.devcode - // url: '../earth/earth' + app.globalData.devcode = event.target.dataset.devcode; + wx.switchTab({ + url: '../earth/earth' }) + // wx.reLaunch({ + // url: '../earth/earth?devcode=' + event.target.dataset.devcode + // // url: '../earth/earth' + // }) }, onSearch: function () { + var _this = this wx.navigateTo({ - url: '../searchLog/searchLog' + url: '../searchLog/searchLog?params=' + JSON.stringify(_this.data.params) }) - }, - // initPages: function () { - // wx.cloud.callFunction({ - // name: 'devicelog' - // }).then(res => { - // var that = this; - // var jsonList = JSON.parse(res.result) - // that.setData({ - // deviceloglist: jsonList.data.rows - // }) - // console.log(res); - // }).catch(err => { - // console.error(err); - // }) - // } + } }) \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.wxml b/miniprogram/pages/applog/applog.wxml index e9a2352..2bfd041 100644 --- a/miniprogram/pages/applog/applog.wxml +++ b/miniprogram/pages/applog/applog.wxml @@ -1,54 +1,59 @@ - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {{item.devcode}} {{item.devicetype}} + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + {{item.devcode}} {{item.devicetype}} + + {{item.project}} {{item.installtime}}- {{item.installperson}} - - - - - + + + + + + 删除 - - - + + - 共计:{{total}}台 - + 共计:{{total}}台 + \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.wxss b/miniprogram/pages/applog/applog.wxss index 6d3428b..e6e8983 100644 --- a/miniprogram/pages/applog/applog.wxss +++ b/miniprogram/pages/applog/applog.wxss @@ -22,16 +22,18 @@ position: fixed; width: 100%; top: 0rpx; + z-index: 9999; /* margin-bottom: 100rpx; */ } .log-list { /* height: 100rpx; */ - /* display: flex; */ - + display: flex; + width: 100%; padding: 2px; margin-top: 2px; border-bottom: 1px solid #e5e5e5; + overflow: hidden } @@ -53,23 +55,29 @@ left: 35%; margin: 20rpx } - .del { - width: 90px; + /* display: flex; */ + width: 100rpx; display: flex; flex-direction: column; align-items: center; justify-content: center; - color: #fff; - -webkit-transform: translateX(90px); - transform: translateX(90px); - -webkit-transition: all 0.4s; + /* -webkit-transform: translateX(100rpx); */ + transform: translateX(100rpx); + /* -webkit-transition: all 0.4s; */ transition: all 0.4s; - font-size: 35rpx; + color: #fff; + background-color: #fe3e2f; +} +.logrow{ + width: 100%; + transform: translateX(100rpx); + /* -webkit-transform: translateX(100px); */ + margin-left: -100rpx; } -.touch-move-active .content, +.touch-move-active .logrow, .touch-move-active .del { - -webkit-transform: translateX(0); - transform: translateX(0); +/* -webkit-transform: translateX(0); */ +transform: translateX(0); } \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.js b/miniprogram/pages/deployFunctions/deployFunctions.js deleted file mode 100644 index a76b144..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.js +++ /dev/null @@ -1,66 +0,0 @@ -// pages/deployFunctions/deployFunctions.js -Page({ - - /** - * 页面的初始数据 - */ - data: { - - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - - }, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { - - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - - }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { - - }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { - - } -}) \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.json b/miniprogram/pages/deployFunctions/deployFunctions.json deleted file mode 100644 index 7fbedab..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "navigationBarTitleText": "部署云函数", - "usingComponents": {} -} \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.wxml b/miniprogram/pages/deployFunctions/deployFunctions.wxml deleted file mode 100644 index 462b6b6..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.wxml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - 调用失败 - - - 请检查 login 云函数是否已部署 - - - - - 部署 login 云函数 - 1. 确保已通过工具栏云开发入口开通云开发 - 2. 在 cloudfunctions/login 目录上右键上传并部署 - 3. 回到首页,重新点击获取 openid - - - - diff --git a/miniprogram/pages/deployFunctions/deployFunctions.wxss b/miniprogram/pages/deployFunctions/deployFunctions.wxss deleted file mode 100644 index c8803e6..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.wxss +++ /dev/null @@ -1,7 +0,0 @@ -/* pages/deployFunctions/deployFunctions.wxss */ - -@import "../../style/guide.wxss"; - -.black { - color: black; -} \ No newline at end of file diff --git a/miniprogram/pages/earth/earth.js b/miniprogram/pages/earth/earth.js index ae0d3f3..376a6e2 100644 --- a/miniprogram/pages/earth/earth.js +++ b/miniprogram/pages/earth/earth.js @@ -21,19 +21,12 @@ show: false, enableSsatellite: false, windowWidth: 0, - longitude: 113.324520, - latitude: 23.099994, - longitude84: 113.324520, - latitude84: 23.099994, - markers: [{ - id: 0, - iconPath: "../../images/locat.png", - latitude: 23.099994, - longitude: 113.324520, - width: 50, - height: 50 - }], - controls: [], + longitude: "116.627340", + latitude: "39.874390", + longitude84: "", + latitude84: "", + markers: [], + controls: [] }, /** @@ -41,39 +34,13 @@ */ onLoad: function (options) { var that = this; - //获取当前坐标(gcj02) - wx.getLocation({ - type: "gcj02", - altitude: true, - success: function (res) { - that.setData({ - latitude: parseFloat(res.latitude).toFixed(6), - longitude: parseFloat(res.longitude).toFixed(6), - // markers: [{ - // latitude: res.latitude, - // longitude: res.longitude, - // }] - }) - //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 - wx.getLocation({ - type: "wgs84", - altitude: true, - success: function (res) { - that.setData({ - latitude84: parseFloat(res.latitude).toFixed(6), - longitude84: parseFloat(res.longitude).toFixed(6) - }) - } - }) - } - }), - - //设置地图组件 - wx.getSystemInfo({ + //设置地图组件 + wx.getSystemInfo({ success(res) { var windowWidth = res.windowWidth var windowHeight = res.windowHeight var query = wx.createSelectorQuery() + var platform =res.platform query.select('#map').boundingClientRect() query.exec(function (res) { that.setData({ @@ -139,10 +106,20 @@ clickable: true }, { id: 7, - iconPath: '../../images/locat.png', + iconPath: '../../images/applocat.png', position: { - left: res[0].width/2, - top: res[0].height/2, + left: res[0].width / 2 - 20, + top: platform=="ios"?res[0].height / 2 - 80:res[0].height / 2 - 40, + width: 40, + height: 40 + }, + clickable: true + }, { + id: 8, + iconPath: '../../images/back.png', + position: { + left: windowWidth - 40, + top: windowHeight - 140, width: 30, height: 30 }, @@ -150,71 +127,15 @@ }] }) }) - + } - }), + }) + // 实例化API核心类 qqmapsdk = new QQMapWX({ key: 'BGPBZ-C5O3P-ROUDR-LWC4J-63EKH-V5FRX' }) - - if (options.devcode) { - var that = this - var devcode = options.devcode - wx.cloud.callFunction({ - name: 'findListByCodes', - data: { - devcodes: devcode, - url: app.globalData.url + "appDeviceAdd/findListByCodes" - }, - }).then(res => { - if (res.result.code == 200) { - var listResultData = res.result.data; - that.setData({ - listData: listResultData - }) - var markersArr = that.data.markers; - for (var i = 0; i < listResultData.length; i++) { - markersArr = markersArr.concat({ - iconPath: "../../images/locat.png", - id: listResultData[i].id, - callout: { - content: listResultData[i].devcode, - fontSize: '14', - // padding: true, - color: '#00000', - borderColor: '#F4EA2A', - bgColor: '#F4EA2A', - borderWidth: 5, - display: 'ALWAYS', - textAlign: 'center', - // borderRadius: 15 - }, - latitude: listResultData[i].latitude, - longitude: listResultData[i].longitude, - width: 40, - height: 40 - }); - } - this.setData({ - markers: markersArr, - latitude: listResultData[0].latitude, - longitude: listResultData[0].longitude, - marker_latitude: listResultData[0].latitude, - marker_longitude: listResultData[0].longitude, - title: listResultData[0].devcode - }) - } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "无法获取设备地理信息!", - icon: 'none', - duration: 2000 - }) - }) - } }, /** @@ -228,6 +149,97 @@ * 生命周期函数--监听页面显示 */ onShow: function () { + //输入设备编号获取marker位置信息 + var that = this; + if ( app.globalData.devcode!="") { + var devcode = app.globalData.devcode + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/findListByCodes", + data: { + devcodes: devcode, + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + app.globalData.devcode=""; + if (res.data.code == 200) { + var listResultData = res.data.data; + that.setData({ + listData: listResultData + }) + var markersArr = that.data.markers; + for (var i = 0; i < listResultData.length; i++) { + markersArr = markersArr.concat({ + iconPath: "../../images/locat.png", + id: Number(listResultData[i].id), + callout: { + content: "编号:"+listResultData[i].devcode+"\r\n位置:"+listResultData[i].position+"\r\n时间:"+listResultData[i].createtime, + fontSize: '14', + padding: true, + color: '#000000', + borderColor: '#F4EA2A', + bgColor: '#F4EA2A', + borderWidth: 5, + display: 'ALWAYS', + textAlign: 'left', + // borderRadius: 15 + }, + latitude: listResultData[i].latitude, + longitude: listResultData[i].longitude, + width: 40, + height: 40 + }); + } + that.setData({ + markers: markersArr, + latitude: listResultData[0].latitude, + longitude: listResultData[0].longitude, + marker_latitude: listResultData[0].latitude, + marker_longitude: listResultData[0].longitude, + title: listResultData[0].devcode + }) + } + }, + fail(err) { + app.globalData.devcode=""; + wx.showToast({ + title: "无法获取设备地理信息!", + icon: 'none', + duration: 2000 + }) + } + }) +} else { + //获取当前坐标(gcj02) + wx.getLocation({ + type: "gcj02", + altitude: true, + success: function (res) { + that.setData({ + latitude: parseFloat(res.latitude).toFixed(6), + longitude: parseFloat(res.longitude).toFixed(6), + // markers: [{ + // latitude: res.latitude, + // longitude: res.longitude, + // }] + }) + //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 + wx.getLocation({ + type: "wgs84", + altitude: true, + success: function (res) { + that.setData({ + latitude84: parseFloat(res.latitude).toFixed(6), + longitude84: parseFloat(res.longitude).toFixed(6) + }) + } + }) + } + }) +} + }, @@ -265,12 +277,46 @@ onShareAppMessage: function () { }, + + //定位出来 + + locationPosition: function () { + var that = this; + //获取当前坐标(gcj02) + wx.getLocation({ + type: "gcj02", + altitude: true, + success: function (res) { + that.setData({ + latitude: parseFloat(res.latitude).toFixed(6), + longitude: parseFloat(res.longitude).toFixed(6), + // markers: [{ + // latitude: res.latitude, + // longitude: res.longitude + // }] + }) + //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 + wx.getLocation({ + type: "wgs84", + altitude: true, + success: function (res) { + that.setData({ + latitude84: parseFloat(res.latitude).toFixed(6), + longitude84: parseFloat(res.longitude).toFixed(6) + }) + } + }) + } + }) + }, + + //加载地图组件 controltap: function (e) { // console.log(e.controlId); //进入添加设备页 if (1 == e.controlId) { wx.setClipboardData({ - data: this.data.latitude + "," + this.data.longitude+ "," + this.data.latitude84+ "," + this.data.longitude84, + data: this.data.latitude + "," + this.data.longitude + "," + this.data.latitude84 + "," + this.data.longitude84, success: function (res) { wx.getClipboardData({ success: function (res) { @@ -282,6 +328,17 @@ } }) } else if (3 == e.controlId) { + //先定位 + // this.locationPosition() + wx.setClipboardData({ + data: this.data.latitude + "," + this.data.longitude + "," + this.data.latitude84 + "," + this.data.longitude84, + success: function (res) { + wx.showToast({ + title: '坐标已获取', + duration: 1000 + }) + } + }) wx.navigateTo({ url: '../addDevice/addDevice' }) @@ -302,32 +359,15 @@ enableSsatellite: !flag }); } else if (6 == e.controlId) { - var that = this; - //获取当前坐标(gcj02) - wx.getLocation({ - type: "gcj02", - altitude: true, - success: function (res) { - that.setData({ - latitude: parseFloat(res.latitude).toFixed(6), - longitude:parseFloat(res.longitude).toFixed(6), - // markers: [{ - // latitude: res.latitude, - // longitude: res.longitude - // }] - }) - //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 - wx.getLocation({ - type: "wgs84", - altitude: true, - success: function (res) { - that.setData({ - latitude84: parseFloat(res.latitude).toFixed(6), - longitude84: parseFloat(res.longitude).toFixed(6) - }) - } - }) - } + //先清marker + this.setData({ + markers: [] + }) + this.locationPosition() + }else if (8 == e.controlId) { + //跳转日志缓存页 + wx.switchTab({ + url: '../applog/applog', }) } }, @@ -343,63 +383,68 @@ }); }, + //获取设备maker leave() { var that = this; if (that.data.devcodes == "") { return false; } - wx.cloud.callFunction({ - name: 'findListByCodes', + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/findListByCodes", data: { - devcodes: that.data.devcodes, - url: app.globalData.url + "appDeviceAdd/findListByCodes" + devcodes: that.data.devcodes }, - }).then(res => { - if (res.result.code == 200) { - var listResultData = res.result.data; - that.setData({ - listData: listResultData - }) - var markersArr = that.data.markers; - for (var i = 0; i < listResultData.length; i++) { - markersArr = markersArr.concat({ - iconPath: "../../images/locat.png", - id: listResultData[i].id, - callout: { - content: listResultData[i].devcode, - fontSize: '14', - // padding: true, - color: '', - borderColor: '#F4EA2A', - bgColor: '#F4EA2A', - borderWidth: 5, - display: 'ALWAYS', - textAlign: 'center', - // borderRadius: 15 - }, - latitude: listResultData[i].latitude, - longitude: listResultData[i].longitude, - width: 40, - height: 40 - }); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var listResultData = res.data.data; + that.setData({ + listData: listResultData + }) + var markersArr = that.data.markers; + for (var i = 0; i < listResultData.length; i++) { + markersArr = markersArr.concat({ + iconPath: "../../images/locat.png", + id: listResultData[i].id, + callout: { + content: "编号:"+listResultData[i].devcode+"\r\n位置:"+listResultData[i].position+"\r\n时间:"+listResultData[i].createtime, + fontSize: '14', + // padding: true, + color: '#212121', + borderColor: '#F4EA2A', + bgColor: '#F4EA2A', + borderWidth: 5, + display: 'ALWAYS', + textAlign: 'left', + // borderRadius: 15 + }, + latitude: listResultData[i].latitude, + longitude: listResultData[i].longitude, + width: 40, + height: 40 + }); + } + that.setData({ + markers: markersArr, + latitude: listResultData[0].latitude, + longitude: listResultData[0].longitude, + marker_latitude: listResultData[0].latitude, + marker_longitude: listResultData[0].longitude, + title: listResultData[0].devcode + }) } - this.setData({ - markers: markersArr, - latitude: listResultData[0].latitude, - longitude: listResultData[0].longitude, - marker_latitude: listResultData[0].latitude, - marker_longitude: listResultData[0].longitude, - title: listResultData[0].devcode + }, + fail(err) { + wx.showToast({ + title: "无法获取设备地理信息!", + icon: 'none', + duration: 2000 }) } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "无法获取设备地理信息!", - icon: 'none', - duration: 2000 - }) }) }, @@ -422,6 +467,8 @@ } }, + + bindregionchange: function (e) { var that = this if (e.causedBy == "drag") { @@ -445,8 +492,8 @@ that.setData({ latitude: parseFloat(latitude).toFixed(6), longitude: parseFloat(longitude).toFixed(6), - latitude84:"", - longitude84:"", + latitude84: "", + longitude84: "", // markers: markersArr }) // mapCtx.moveToLocation(); @@ -465,16 +512,19 @@ qqmapsdk.search({ keyword: this.data.value, success: function (res) { + console.log(res) if (res && res.data) { _this.setData({ isShow: true, tips: res.data }); } + }, + complete: function (res){ + console.log(res); } }) }, - bindSearch: function (e) { var location = e.target.dataset.location; this.setData({ diff --git a/miniprogram/pages/earth/earth.wxml b/miniprogram/pages/earth/earth.wxml index a0db6ef..87474f8 100644 --- a/miniprogram/pages/earth/earth.wxml +++ b/miniprogram/pages/earth/earth.wxml @@ -1,9 +1,10 @@ + - + {{item.title}} {{item.address}} @@ -17,6 +18,6 @@ + placeholder="请输入定位设备编号用换行隔开" autosize border="{{ false }}" /> \ No newline at end of file diff --git a/miniprogram/pages/indexapp/indexapp.js b/miniprogram/pages/indexapp/indexapp.js index 5063372..849dbdb 100644 --- a/miniprogram/pages/indexapp/indexapp.js +++ b/miniprogram/pages/indexapp/indexapp.js @@ -7,9 +7,8 @@ */ data: { - count:1, - show: false, - onshow:true, + count: 1, + onshow: true, value: "", deviceloglist: [], devcode: "", @@ -21,6 +20,7 @@ // iconPath: "../../images/point.png", latitude: 23.099994, longitude: 113.324520, + label:'1', width: 50, height: 50 }], @@ -31,62 +31,26 @@ * 生命周期函数--监听页面加载 */ onLoad: function (options) { - + }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { - + }, /** * 生命周期函数--监听页面显示 */ onShow: function () { - // if( app.globalData.indexCount>1){ - // this.setData({ - // show:false - // }) - // }else{ - // this.showNotice() - // } - if(app.globalData.indexCount==1){ - this.setData({ - show:true - }) - this.showNotice() - } - app.globalData.indexCount+=1 - if(this.data.onshow){ + if (this.data.onshow) { this.initPages(); } }, - - showNotice: function() { - var that = this - var times = 0 - var i = setInterval(function() { - times++ - if (times >= 15) { - that.setData({ - show:false - }) - wx.showTabBar({ - animation: false, - }) - clearInterval(i) - } else { - wx.hideTabBar({ - animation: false, - }) - } - }, 1000) -}, - /** * 生命周期函数--监听页面隐藏 */ @@ -122,16 +86,27 @@ }, jump: function (event) { - var that = this; var latitude = event.target.dataset.pointLat; var longitude = event.target.dataset.pointLon; + let devcode = event.target.dataset.pointCode; that.setData({ latitude: latitude, longitude: longitude, markers: [{ latitude: latitude, - longitude: longitude + longitude: longitude, + callout: { + display:'ALWAYS',// 常显气泡 + content: devcode, //名称文本 + color: '#fff', //文本颜色 + borderRadius: 5, //边框圆角 + borderWidth: 1, //边框宽度 + borderColor: '#0060ff', //边框颜色 + bgColor: '#0060ff', //背景色 + padding: 5, //文本边缘留白 + textAlign: 'center' //文本对齐方式。有效值: left, right, center + } }] }) }, @@ -142,7 +117,7 @@ var devcode = res.result _this.setData({ devcode: devcode, - onshow:false + onshow: false }); _this.searchlogs(devcode) } @@ -151,40 +126,11 @@ onSearch: function (event) { this.setData({ - devcode:event.detail + devcode: event.detail }) this.searchlogs(event.detail) }, - - // bindregionchange: function (e) { - // var that = this - // if (e.causedBy == "drag") { - // var mapCtx = wx.createMapContext("map") - // mapCtx.getCenterLocation({ - // success: function (res) { - // var markersArr = that.data.markers - // for (var i = 0; i < markersArr.length; i++) { - // if (markersArr[i].iconPath == undefined) { - // markersArr.splice(i, 1) - // } - // } - // var latitude = res.latitude - // var longitude = res.longitude - // markersArr = markersArr.concat({ - // latitude: latitude, - // longitude: longitude - // }) - // that.setData({ - // latitude: latitude, - // longitude: longitude, - // markers: markersArr - // }) - // } - // }) - // } - // }, - showLoading: function (message) { if (wx.showLoading) { // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 @@ -211,81 +157,89 @@ } }, + //加载设备运维详细信息 toDetail: function (event) { - this.showLoading("数据加载中...") - wx.cloud.callFunction({ - name: 'deviceDetail', + var that = this + that.showLoading("数据加载中...") + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deviceDetail", data: { devcode: event.target.dataset.devcode, - url: app.globalData.url + "appDeviceLog/deviceDetail", }, - }).then(res => { - this.hideLoading(); - var resultObject = JSON.parse(res.result); - var pageName='../indexapp/indexapp' - if (resultObject.code == 200) { - wx.navigateTo({ - url: '../addDevicelog/addDeviceLog?detail=' + - JSON.stringify(resultObject.data)+'&pageName='+pageName - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + that.hideLoading(); + var resultObject = res.data; + var pageName = '../indexapp/indexapp' + if (resultObject.code == 200) { + wx.setStorageSync('resultObject', resultObject.data) + wx.navigateTo({ + url: '../addDevicelog/addDeviceLog?detail=' +'&pageName=' + pageName + }) + } + }, + fail(err){ + that.hideLoading(); } - }).catch(err => { - this.hideLoading(); }) }, + //加载列表 getlogs: function (devcode) { var that = this - wx.cloud.callFunction({ - name: 'devicelog', + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/listPage", data: { devcode: devcode, - url: app.globalData.url + "appDeviceLog/listPage", limit: 100, offset: that.data.deviceloglist.length % 100 > 0 ? parseInt(that.data.deviceloglist.length / 100) + 2 : parseInt(that.data.deviceloglist.length / 100) + 1 }, - }).then(res => { - if (res.result) { - // var resultJson = JSON.parse(res.result) - var resultJson = res.result - that.setData({ - deviceloglist: that.data.deviceloglist.concat(resultJson.data.rows) - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + // var resultJson = JSON.parse(res.result) + var resultJson = res.data + that.setData({ + deviceloglist: that.data.deviceloglist.concat(resultJson.data.rows) + }) + } } - console.log(res); - }).catch(err => { - console.error(err); }) }, + //查询列表 searchlogs: function (devcode) { var that = this - wx.cloud.callFunction({ - name: 'devicelog', + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/listPage", data: { devcode: devcode, - url: app.globalData.url + "appDeviceLog/listPage", limit: 100, offset: 1 }, - }).then(res => { - if (res.result) { - var resultJson = res.result - that.setData({ - deviceloglist: resultJson.data.rows, - onshow:true - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var resultJson = res.data + that.setData({ + deviceloglist: resultJson.data.rows, + onshow: true + }) + } } - console.log(res); - }).catch(err => { - console.error(err); }) }, initPages: function () { var that = this; - that.setData({ - devcode: "" - }); wx.getLocation({ type: "gcj02", success: function (res) { @@ -302,6 +256,6 @@ }) } }) - this.searchlogs() + this.data.devcode !== '' ? this.searchlogs(this.data.devcode) : this.searchlogs() }, }) \ No newline at end of file diff --git a/miniprogram/pages/indexapp/indexapp.wxml b/miniprogram/pages/indexapp/indexapp.wxml index 69322a0..f65b082 100644 --- a/miniprogram/pages/indexapp/indexapp.wxml +++ b/miniprogram/pages/indexapp/indexapp.wxml @@ -1,8 +1,12 @@ + + + + - @@ -32,9 +36,15 @@ - + + + + + + + @@ -46,14 +56,14 @@ - + - - + diff --git a/miniprogram/pages/indexapp/indexapp.wxss b/miniprogram/pages/indexapp/indexapp.wxss index b18706a..fc27fcb 100644 --- a/miniprogram/pages/indexapp/indexapp.wxss +++ b/miniprogram/pages/indexapp/indexapp.wxss @@ -128,6 +128,7 @@ .noticeClass{ height: 2300rpx; width: 750rpx; + overflow-y:hidden; } @@ -148,14 +149,14 @@ } +/* .vanstyle{ + button: not([size='mini']) { + user agent stylesheetmin-height: 40px; + width: 650rpx; + margin-left: 20rpx; + margin-right: auto; + + } + +} */ -/* .van-enter-active-class, -.van-leave-active-class { - transition-property: background-color, transform; -} - -.van-enter-class, -.van-leave-to-class { - background-color: red; - transform: rotate(-360deg) translate3d(-100%, -100%, 0); -} */ \ No newline at end of file diff --git a/miniprogram/pages/log/log.js b/miniprogram/pages/log/log.js deleted file mode 100644 index 83ba349..0000000 --- a/miniprogram/pages/log/log.js +++ /dev/null @@ -1,66 +0,0 @@ -// pages/log/log.js -Page({ - - /** - * 页面的初始数据 - */ - data: { - - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - - }, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { - - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - - }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { - - }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { - - } -}) \ No newline at end of file diff --git a/miniprogram/pages/log/log.json b/miniprogram/pages/log/log.json deleted file mode 100644 index 8835af0..0000000 --- a/miniprogram/pages/log/log.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "usingComponents": {} -} \ No newline at end of file diff --git a/miniprogram/pages/log/log.wxml b/miniprogram/pages/log/log.wxml deleted file mode 100644 index a510ad6..0000000 --- a/miniprogram/pages/log/log.wxml +++ /dev/null @@ -1,2 +0,0 @@ - -pages/log/log.wxml diff --git a/miniprogram/pages/log/log.wxss b/miniprogram/pages/log/log.wxss deleted file mode 100644 index 23db318..0000000 --- a/miniprogram/pages/log/log.wxss +++ /dev/null @@ -1 +0,0 @@ -/* pages/log/log.wxss */ \ No newline at end of file diff --git a/miniprogram/pages/login/login.js b/miniprogram/pages/login/login.js index a4074e7..cb0542a 100644 --- a/miniprogram/pages/login/login.js +++ b/miniprogram/pages/login/login.js @@ -1,11 +1,14 @@ // miniprogram/pages/login/login.js +var app = getApp() Page({ /** * 页面的初始数据 */ data: { - windowWidth:"" + windowWidth: "", + time: 15 * 1000, + showTime: false }, /** @@ -20,9 +23,9 @@ */ onReady: function () { this.setData({ - windowWidth:wx.getSystemInfoSync().windowWidth + windowWidth: wx.getSystemInfoSync().windowWidth }) - + }, /** @@ -66,14 +69,158 @@ onShareAppMessage: function () { }, + + + showLoading: function (message) { + if (wx.showLoading) { + // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 + wx.showLoading({ + title: message, + mask: true + }); + } else { + // 低版本采用Toast兼容处理并将时间设为20秒以免自动消失 + wx.showToast({ + title: message, + icon: 'loading', + mask: true, + duration: 20000 + }); + } + }, + hideLoading: function () { + if (wx.hideLoading) { + // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 + wx.hideLoading(); + } else { + wx.hideToast(); + } + }, + + //注册 loginClick: function () { + var that = this + that.showLoading("授权中...") + wx.login({ + success: function (res) { + if (res.code) { + wx.request({ + url: app.globalData.httpsUrl + "appUserOpenid/login", + data: { + code: res.code + }, + success: function (res) { + app.globalData.openid = res.data.data + wx.getUserInfo({ + success: (res) => { + var nickname = res.userInfo.nickName; + app.globalData.nickName = nickname; + //openid绑定昵称存入后台 + wx.request({ + url: app.globalData.httpsUrl + "appUserOpenid/add", + data: { + attr: nickname, + openid: app.globalData.openid + }, + success: function (res) { + that.hideLoading(); + wx.showToast({ + title: res.data.data+",\r\n请从正式版入口登录!", + icon: 'none', + duration: 2000 + }) - wx.navigateTo({ - - url: '../farmermain/farmermain', - + // //授权成功后跳转 + // wx.switchTab({ + // url: '../indexapp/indexapp' + // }) + } + }) + }, + fail: function (err) { + that.hideLoading(); + } + }) + }, + fail: function (res) { + that.hideLoading(); + wx.showToast({ + title: '服务器异常', + }) + } + }) + } + }, + fail: function (res) { + that.hideLoading(); + } }) + }, + //登录验证 + loginValidate: function () { + var that = this + that.showLoading("登录中...") + wx.login({ + success: function (res) { + if (res.code) { + console.info(res); + wx.request({ + url: app.globalData.httpsUrl + "appUserOpenid/login", + data: { + code: res.code + }, + success: function (res) { + app.globalData.openid = res.data.data + wx.request({ + url: app.globalData.httpsUrl + "appUserOpenid/validate", + data: { + openid: app.globalData.openid + }, + success: function (res) { + that.hideLoading(); + if (res.data.data) { + app.globalData.userName = res.data.data.attr1 == '' ? res.data.data.attr : res.data.data.attr1 + app.globalData.nickName = res.data.data.attr + app.globalData.role = res.data.data.role + wx.navigateTo({ + url: '../notice/notice' + }) + } else { + wx.showToast({ + icon: 'none', + title: '请联系管理员授权', + duration: 2000 + }) + } + }, + fail: function (err) { + that.hideLoading(); + wx.showToast({ + title: '验证失败', + }) + } + }) + }, + fail: function (res) { + that.hideLoading(); + wx.showToast({ + title: '服务器异常', + }) + } + }) + } + }, + fail: function (res) { + that.hideLoading(); + } + }) + }, + + finished() { + this.setData({ + showTime: true + }) }, onClickSubmit: function () { diff --git a/miniprogram/pages/login/login.json b/miniprogram/pages/login/login.json index 8835af0..f2043a3 100644 --- a/miniprogram/pages/login/login.json +++ b/miniprogram/pages/login/login.json @@ -1,3 +1,8 @@ { - "usingComponents": {} + "usingComponents": { + "van-count-down": "../../miniprogram_npm/@vant/weapp/count-down", + "van-button": "../../miniprogram_npm/@vant/weapp/button" + }, + "navigationBarBackgroundColor": "#E6D480", + "disableScroll":true } \ No newline at end of file diff --git a/miniprogram/pages/login/login.wxml b/miniprogram/pages/login/login.wxml index c69df42..cf2ec72 100644 --- a/miniprogram/pages/login/login.wxml +++ b/miniprogram/pages/login/login.wxml @@ -1,21 +1,46 @@ + - + + + - + + + +    本程序为施工日志管理小程序,为航天二院智慧市 +政技术研究室内部系统,不对外开放。出于对数据信 +息安全的考虑,在您首次使用小程序时,请先对小程 +序进行授权,授权后的用户可以正常对小程序进行编 +辑,谢谢您的配合! + + + + + + + + 授权/登录 + + + - + + + diff --git a/miniprogram/pages/login/login.wxss b/miniprogram/pages/login/login.wxss index ca77568..b9fa569 100644 --- a/miniprogram/pages/login/login.wxss +++ b/miniprogram/pages/login/login.wxss @@ -54,7 +54,8 @@ } .form .submit { - margin-top: 80rpx; + + /* margin-top: 80rpx; */ color: #fff; border: 2rpx solid #FFB90F; background-color: #FFB90F; @@ -63,10 +64,30 @@ } .login_image { - width: 200rpx; - height: 200rpx; - padding-top: 100rpx; - padding-left: 250rpx; + width: 750rpx; + height: 360rpx; + /* height: 2300rpx; */ + /* padding-top: 100rpx + padding-left: 250rpx; */ +} +.bottom_image { + width: 750rpx; + height: 32%; + position: fixed; + bottom: 0px; + /* padding-top: 100rpx + padding-left: 250rpx; */ +} +.cover{ + position: fixed; + top: 0rpx; + margin-left: 290rpx; + text-align:center; + font-size: 50rpx; + color: #FFCF00; + width: 750rpx; + z-index:9999; + } -} \ No newline at end of file + \ No newline at end of file diff --git a/miniprogram/pages/notice/notice.js b/miniprogram/pages/notice/notice.js new file mode 100644 index 0000000..7aeafb9 --- /dev/null +++ b/miniprogram/pages/notice/notice.js @@ -0,0 +1,80 @@ +// miniprogram/pages/notice.js +Page({ + + /** + * 页面的初始数据 + */ + data: { + time: 15 * 1000, + showTime: false + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { + this.setData({ + showTime: true + }) + wx.switchTab({ + url: '../indexapp/indexapp' + }) + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + }, + finished() { + this.setData({ + showTime: true + }) + wx.switchTab({ + url: '../indexapp/indexapp' + }) + } +}) \ No newline at end of file diff --git a/miniprogram/pages/notice/notice.json b/miniprogram/pages/notice/notice.json new file mode 100644 index 0000000..4c73264 --- /dev/null +++ b/miniprogram/pages/notice/notice.json @@ -0,0 +1,5 @@ +{ + "usingComponents": { + "van-count-down": "../../miniprogram_npm/@vant/weapp/count-down" + } +} \ No newline at end of file diff --git a/miniprogram/pages/notice/notice.wxml b/miniprogram/pages/notice/notice.wxml new file mode 100644 index 0000000..975304a --- /dev/null +++ b/miniprogram/pages/notice/notice.wxml @@ -0,0 +1,10 @@ + + + + + + + + diff --git a/cloudfunctions/project.config.json b/cloudfunctions/project.config.json new file mode 100644 index 0000000..2b3119a --- /dev/null +++ b/cloudfunctions/project.config.json @@ -0,0 +1,28 @@ +{ + "appid": "wx2cef527a000f87c9", + "compileType": "miniprogram", + "libVersion": "2.27.3", + "packOptions": { + "ignore": [], + "include": [] + }, + "setting": { + "coverView": true, + "es6": true, + "postcss": true, + "minified": true, + "enhance": true, + "showShadowRootInWxmlPanel": true, + "packNpmRelationList": [], + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + } + }, + "condition": {}, + "editorSetting": { + "tabIndent": "insertSpaces", + "tabSize": 4 + } +} \ No newline at end of file diff --git a/cloudfunctions/project.private.config.json b/cloudfunctions/project.private.config.json new file mode 100644 index 0000000..42ff49d --- /dev/null +++ b/cloudfunctions/project.private.config.json @@ -0,0 +1,7 @@ +{ + "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", + "projectname": "cloudfunctions", + "setting": { + "compileHotReLoad": true + } +} \ No newline at end of file diff --git a/miniprogram/app.js b/miniprogram/app.js index 51d56f3..50a8a54 100644 --- a/miniprogram/app.js +++ b/miniprogram/app.js @@ -18,13 +18,15 @@ // this.globalData = {} }, globalData: { - // url: "http://111.198.10.15:11604/", - httpsUrl: "https://logapi.smartlog.work/", - httpsTestUrl: "https://smartlog.work/prodapi4test/", - url: "http://139.198.18.188:8083/", + httpsUrl: "https://logapi.smartlog.work/", + // httpsUrl: "http://139.198.18.188:8083/", // url: "http://127.0.0.1:8083/", - // httpsUrl: "http://127.0.0.1:8083/", + //httpsUrl: "http://127.0.0.1:8083/", openid: null, - indexCount:1 - }, + indexCount:1, + nickName:"", + userName:"", + role:"", + devcode:"" + } }) diff --git a/miniprogram/app.json b/miniprogram/app.json index d23f798..2b6db76 100644 --- a/miniprogram/app.json +++ b/miniprogram/app.json @@ -1,15 +1,17 @@ { "cloud": true, "pages": [ + "pages/login/login", "pages/indexapp/indexapp", "pages/earth/earth", "pages/applog/applog", "pages/addDevice/addDevice", "pages/addDevicelog/addDeviceLog", - "pages/searchLog/searchLog" + "pages/searchLog/searchLog", + "pages/notice/notice" ], "window": { - "backgroundColor": "#F6F6F6", + "backgroundColor": "#E6D480", "backgroundTextStyle": "light", "navigationBarBackgroundColor": "#FFCF00", "navigationBarTitleText": "智慧施工", @@ -46,11 +48,11 @@ "desc": "你的位置信息将用于小程序位置接口的效果展示" } }, + "requiredPrivateInfos": ["getLocation", "chooseLocation"], "networkTimeout": { "request": 30000, "connectSocket": 30000, "uploadFile": 30000, "downloadFile": 30000 - }, - "style": "v2" + } } \ No newline at end of file diff --git a/miniprogram/images/applocat.png b/miniprogram/images/applocat.png new file mode 100644 index 0000000..fe49f54 --- /dev/null +++ b/miniprogram/images/applocat.png Binary files differ diff --git a/miniprogram/images/back.png b/miniprogram/images/back.png new file mode 100644 index 0000000..32ac82d --- /dev/null +++ b/miniprogram/images/back.png Binary files differ diff --git a/miniprogram/images/bottom.png b/miniprogram/images/bottom.png new file mode 100644 index 0000000..d910e98 --- /dev/null +++ b/miniprogram/images/bottom.png Binary files differ diff --git a/miniprogram/images/header.png b/miniprogram/images/header.png new file mode 100644 index 0000000..6ea222e --- /dev/null +++ b/miniprogram/images/header.png Binary files differ diff --git a/miniprogram/images/login.png b/miniprogram/images/login.png index 8b73cc0..6471c46 100644 --- a/miniprogram/images/login.png +++ b/miniprogram/images/login.png Binary files differ diff --git a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss index 5a591fb..c9c35b5 100644 --- a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss +++ b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:100%;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:100%}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file +@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:650rpx;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:600rpx}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file diff --git a/miniprogram/pages/addDevice/addDevice.js b/miniprogram/pages/addDevice/addDevice.js index 2783674..78f00b7 100644 --- a/miniprogram/pages/addDevice/addDevice.js +++ b/miniprogram/pages/addDevice/addDevice.js @@ -1,5 +1,7 @@ // miniprogram/pages/addDevice/addDevice.js // import WxValidate from '../../utils/WxValidate.js' +var QQMapWX = require('../../libs/qqmap-wx-jssdk.js'); +var qqmapsdk; var app = getApp() Page({ @@ -11,32 +13,10 @@ canvasWidth: '', longitude: '', latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], + option1: [], personoption1: [], projectoption: [], + devtypeList:[], show: false, form: { devcode: "", @@ -59,7 +39,10 @@ project: "", area: "", street: "", - wellname: "" + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '', }, fileList: [] }, @@ -117,12 +100,14 @@ var that = this; //初始化表单内容为上次填写值 var cacheForms = wx.getStorageSync('cacheList') - if (cacheForms) { + cacheForms.photopath1='' + cacheForms.photopath2='' + cacheForms.photopath3='' + that.data.fileList=[] that.setData({ form: cacheForms, devcode: cacheForms.devcode, - }) } var form = that.data.form @@ -155,55 +140,89 @@ } }) + +//获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + that.setData({ + option1: welltypeArr + }) + } + } +}) + + //获取人员下拉列表 - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/getUser", + data:{ + tips:'repair' }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data.code == 200) { + var users = res.data.data + var personArr = []; + for (var i = 0; i < users.length; i++) { + var person = { + text: users[i].name, + value: users[i].name + }; + personArr.push(person); + } + that.setData({ + personoption1: personArr + }) } - that.setData({ - personoption1: personArr - }) } - }).catch(err => { - console.error(err); - }) + }) + - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - that.setData({ - projectoption: projectArr - }) + success(res){ + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); + } + that.setData({ + projectoption: projectArr + }) + } } - }).catch(err => { - console.error(err); - }) + }) + var installtime = 'form.installtimeFmt'; var dateNow = this.formatDate(); this.setData({ @@ -211,8 +230,40 @@ installtimeFmt: dateNow, [installtime]: dateNow, }); + + + + /** + * 获取设备类型下拉列表 + */ + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/deviceType", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var TypeList = res.data.data + var typeArr = []; + for (var i = 0; i < TypeList.length; i++) { + var type = { + text: TypeList[i].productName, + value: TypeList[i].productName + }; + typeArr.push(type); + } + that.setData({ + devtypeList: typeArr + }) + } + } + }) }, + + + /** * 生命周期函数--监听页面初次渲染完成 */ @@ -280,29 +331,7 @@ }, - - //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 - drawText: function (ctx, str, leftWidth, initHeight, titleHeight, canvasWidth) { - var lineWidth = 0; - var lastSubStrIndex = 0; //每次开始截取的字符串的索引 - for (let i = 0; i < str.length; i++) { - lineWidth += ctx.measureText(str[i]).width; - if (lineWidth > canvasWidth) { - ctx.fillText(str.substring(lastSubStrIndex, i), leftWidth, initHeight); //绘制截取部分 - initHeight = initHeight + leftWidth * 2; //22为字体的高度 - lineWidth = 0; - lastSubStrIndex = i; - // titleHeight += 40; - } - if (i == str.length - 1) { //绘制剩余部分 - ctx.fillText(str.substring(lastSubStrIndex, i + 1), leftWidth, initHeight); - } - } - // // 标题border-bottom 线距顶部距离 - // titleHeight = titleHeight + 10; - // return titleHeight - }, - + //验证表单 formValidate() { if (this.data.form.devcode == "") { @@ -312,27 +341,20 @@ }) return false } - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } if (this.data.form.wellcode == "") { wx.showToast({ icon: 'none', @@ -348,22 +370,10 @@ }) return false } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null) { + + if (this.data.form.installperson == "") { wx.showToast({ icon: 'none', title: '安装人员不能为空!', @@ -408,56 +418,90 @@ } return true; }, + //提交表单 formSubmit: function (event) { + console.log(this.data.form) + //表单参数验证 if (!this.formValidate()) { return false; } var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDevice', + //验证设备编号长度 + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/getDevTypeLength", data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceAdd/add" + code: encodeURI(this.data.form.devicetype) }, - }).then(res => { - if (res.result.code == 500) { - wx.showToast({ - title: '设备编号已安装!', - }) - } else if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - //用于回显 - wx.setStorageSync('cacheList', that.data.form) - //提交成功后提示用户操作 - if (res.confirm) { - wx.switchTab({ - url: '../earth/earth' - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (""==res.data.data ||res.data.data == that.data.form.devcode.length) { + that.saveDevice() + } else { //编号位数不对提示 + wx.showToast({ + icon: 'none', + title: '设备编号位数不对!', + duration: 1000 + }) + return false + } } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "提交失败", - }) }) }, + + //保存设备基本信息 + saveDevice() { + var that = this; + //设置照片路径 + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopathForm = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopathForm]: fileList[i].url.split("static/")[1] + }) + } + //表单提交 + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 500) { + wx.showToast({ + title: '设备编号已安装!', + }) + } else if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + //用于回显 + wx.setStorageSync('cacheList', that.data.form) + //提交成功后提示用户操作 + if (res.confirm) { + wx.switchTab({ + url: '../earth/earth' + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } + }, + fail(err) { + wx.showToast({ + title: '提交失败!', + }) + } + }) + }, + + //input 输入框设置值 confirm(event) { var that = this; var formValue = event.detail.value; @@ -466,8 +510,30 @@ that.setData({ [fromN]: formValue }) + //若输入是设备编号,自动获取设备类型 + if('devcode'==formName){ + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", + data: { + devcode: formValue, + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + that.setData({ + [formDevicetype]: res.data + }); + } + } + }) + } }, + //扫描设备获取编号和设备类型 scan() { var _this = this; wx.scanCode({ @@ -477,23 +543,28 @@ _this.setData({ [formdevcode]: devcode }); - wx.cloud.callFunction({ - name: 'findModeCode', + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", data: { devcode: devcode, - url: app.globalData.url + "appDeviceAdd/findModeCodeByCode" }, - }).then(res => { - if (res.result) { - var formDevicetype = 'form.devicetype' - _this.setData({ - [formDevicetype]: res.result - }); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + _this.setData({ + [formDevicetype]: res.data + }); + } } }) } }) }, + //粘贴经纬度 paste() { var _this = this; wx.getClipboardData({ @@ -510,9 +581,11 @@ longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), }); + _this.showAddress(_this.data.form.longitude,_this.data.form.latitude,_this) } }) }, + //设置经类型 selectValue(value) { var that = this; @@ -521,6 +594,16 @@ [wellType]: value.detail }) }, + + //设置设备类型 + selectDevType(event) { + var that = this; + var devtype = 'form.devicetype'; + that.setData({ + [devtype]: event.detail + }) + }, + //设置运维人员 selectpersonValue(event) { var that = this; var installPerson = 'form.installperson'; @@ -528,6 +611,7 @@ [installPerson]: event.detail }) }, + //设置项目 selectprojectValue(event) { var that = this; var project = 'form.project'; @@ -535,8 +619,41 @@ [project]: event.detail }) }, + showAddress :function(longitude, latitude, self) { + // 实例化腾讯地图API核心类 + qqmapsdk = new QQMapWX({ + key: 'BGPBZ-C5O3P-ROUDR-LWC4J-63EKH-V5FRX'//此处使用你自己申请的key + }) + // 腾讯地图调用接口 + qqmapsdk.reverseGeocoder({ + location: { + latitude: latitude, + longitude: longitude + }, + success: function (res) { + self.setData({ + 'form.area':res.result.address.slice(0,res.result.address.indexOf('区')+1), + 'form.street':res.result.address.slice(res.result.address.indexOf('区')+1) + }) + }, + fail: function (res) { + console.log(res); + }, + complete: function (res) { + } + }); + }, + //上传照片 afterRead(event) { var _this = this; + if (_this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '请先填写设备编号!\r\n否则水印中无编号', + duration: 2000 + }) + return false + } const { file } = event.detail; @@ -576,78 +693,8 @@ }) } }) - // 压缩图片 - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // //获取图片尺寸 - // wx.getImageInfo({ - // src: convertpath, - // success(res) { - // _this.setData({ - // canvasHeight: res.height, - // canvasWidth: res.width - // }) - // var ctx = wx.createCanvasContext('firstCanvas') - - // //将图片src放到cancas内,宽高为图片大小 - // ctx.drawImage(convertpath, 0, 0, res.width, res.height) - // //将声明的时间放入canvas - // ctx.setFontSize(30 * (res.width / 750)) //注意:设置文字大小必须放在填充文字之前,否则不生效 - // ctx.setFillStyle('blue') - // var text = "编号:" + _this.data.form.devcode + "\n经度:" + _this.data.form.longitude + "\n纬度:" + _this.data.form.latitude - // // _this.drawText(ctx,text,20, 70, 5, res.width) - // _this.drawText(ctx, text, 15 * (res.width / 750), 70 * (res.width / 750), 5, res.width) - - // // ctx.fillText(text, 0, 40) - // // ctx.strokeText(_this.data.form.devcode, 0, 30) - // //生成水印图 - // ctx.draw(false, function () { - // wx.canvasToTempFilePath({ - // canvasId: 'firstCanvas', - // success: (res) => { - // wx.compressImage({ - // src: res.tempFilePath, - // quality: 25, - // success: function (res) { - // //上传照片至服务器 - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: res.tempFilePath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // } - // }) - // //// - // } - // }) - // }) - // } - // }) - // } - // }); }, + //删除照片 deletePhoto(event) { var image_index = event.detail.index var fileList_new = this.data.fileList; diff --git a/miniprogram/pages/addDevice/addDevice.wxml b/miniprogram/pages/addDevice/addDevice.wxml index b0977e2..f12c254 100644 --- a/miniprogram/pages/addDevice/addDevice.wxml +++ b/miniprogram/pages/addDevice/addDevice.wxml @@ -5,18 +5,30 @@ - + + + + + + + + + + + + + - - + + - - - + + + @@ -29,13 +41,13 @@ - + - + - + - + @@ -54,8 +66,7 @@ - - + @@ -68,8 +79,8 @@ - - + + - 保存 + 保存 \ No newline at end of file diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.js b/miniprogram/pages/addDevicelog/addDeviceLog.js index cdec71b..a0dc6da 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.js +++ b/miniprogram/pages/addDevicelog/addDeviceLog.js @@ -3,681 +3,665 @@ var app = getApp(); Page({ - /** - * 页面的初始数据 - */ - data: { - pageName: '', - showMask: false, - today: new Date().getTime(), - longitude: '', - latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], - personoption1: [], - projectoption: [], - devcode: "", - deviceMode: "", - installtimeFmt: '', - show: false, - form: { - devcode: "", - wellcode: "", - welltype: "", - welldepth: "", - installheigt: "", - installperson: "", - installtimeFmt: "", - photopath: "", - factory: "", - workmsg: "", - position: "", - description: "", - longitude: "", - latitude: "", - longitude84: "", - latitude84: "", - devicetype: "", - project: "", - area: "", - street: "", - wellname: "" - }, - fileList: [], - detail: "" - }, + /** + * 页面的初始数据 + */ + data: { + pageName: '', + showMask: false, + today: new Date().getTime(), + longitude: '', + latitude: '', + option1: [], + personoption1: [], + projectoption: [], + devcode: "", + deviceMode: "", + installtimeFmt: '', + show: false, + form: { + devcode: "", + wellcode: "", + welltype: "", + welldepth: "", + installheigt: "", + installperson: "", + installtimeFmt: "", + photopath: "", + factory: "", + workmsg: "", + position: "", + description: "", + longitude: "", + latitude: "", + longitude84: "", + latitude84: "", + devicetype: "", + project: "", + area: "", + street: "", + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '' + }, + fileList: [], + detail: "", + markers: [{ + id: 100, + // iconPath: "../../images/point.png", + latitude: '', + longitude: '', + // label:'1', + width: 25, + height: 35 + }], + }, - onDisplay() { - this.setData({ - show: true - }); - }, - onClose() { - this.setData({ - show: false - }); - }, - formatDate() { - var date = new Date(); - // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; - var seperator1 = "-"; - var month = date.getMonth() + 1; - var strDate = date.getDate(); - var hour = date.getHours() - var minute = date.getMinutes() - var second = date.getSeconds() - month = month > 9 ? month : "0" + month; - strDate = strDate > 9 ? strDate : "0" + strDate; - hour = hour > 9 ? hour : "0" + hour; - minute = minute > 9 ? minute : "0" + minute; - second = second > 9 ? second : "0" + second; - var currentdate = - date.getFullYear() + - seperator1 + - month + - seperator1 + - strDate + - " " + - hour + ":" + - minute + ":" + - second; - return currentdate; + onDisplay() { + this.setData({ + show: true + }); + }, + onClose() { + this.setData({ + show: false + }); + }, + formatDate() { + var date = new Date(); + // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; + var seperator1 = "-"; + var month = date.getMonth() + 1; + var strDate = date.getDate(); + var hour = date.getHours() + var minute = date.getMinutes() + var second = date.getSeconds() + month = month > 9 ? month : "0" + month; + strDate = strDate > 9 ? strDate : "0" + strDate; + hour = hour > 9 ? hour : "0" + hour; + minute = minute > 9 ? minute : "0" + minute; + second = second > 9 ? second : "0" + second; + var currentdate = + date.getFullYear() + + seperator1 + + month + + seperator1 + + strDate + + " " + + hour + ":" + + minute + ":" + + second; + return currentdate; - }, - onConfirm(event) { - var installtime = 'form.installtimeFmt'; - this.setData({ - show: false, - installtimeFmt: this.formatDate(event.detail), - [installtime]: this.formatDate(event.detail), - }); - }, + }, + onConfirm(event) { + var installtime = 'form.installtimeFmt'; + this.setData({ + show: false, + installtimeFmt: this.formatDate(event.detail), + [installtime]: this.formatDate(event.detail), + }); + }, - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - var _this = this; - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" - }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); - } - _this.setData({ - personoption1: personArr - }) + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + var _this = this; + _this.setData({ + 'markers[0].latitude': Number(wx.getStorageSync('resultObject').latitude) , + 'markers[0].longitude': Number(wx.getStorageSync('resultObject').longitude), + // 'markers[0].label':'10', + 'markers[0].width': 18, + 'markers[0].id':1, + 'markers[0].height': 30, + latitude:Number(wx.getStorageSync('resultObject').latitude), + longitude:Number(wx.getStorageSync('resultObject').longitude) + }) + //获取人员下拉列表 + // wx.request({ + // method: "POST", + // url: app.globalData.httpsUrl + "deviceType/getUser", + // data:{ + // tips:'repair' + // }, + // header: { + // 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + // }, + // success(res) { + // if (res.data.code == 200) { + // var users = res.data.data + // var personArr = []; + // for (var i = 0; i < users.length; i++) { + // var person = { + // text: users[i].name, + // value: users[i].name + // }; + // personArr.push(person); + // } + // _this.setData({ + // personoption1: personArr + // }) + // } + // } + // }) + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); } - }).catch(err => { - console.error(err); - }) - - - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" - }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - _this.setData({ - projectoption: projectArr - }) - } - }).catch(err => { - console.error(err); - }) - - if (options.pageName) { - this.setData({ - pageName: options.pageName - }) - } - - if (options.detail) { - - var formObject = JSON.parse(options.detail); _this.setData({ - form: formObject, - detail: options.detail + projectoption: projectArr }) - - _this.setData({ - ['form.installperson']: "", - ['form.installtimeFmt']: "", - ['form.workmsg']: "", - ['form.description']: "" - }) - - const { - fileList = [] - } = _this.data; - if (formObject.photopath1 != "") { - var file1 = { - url: app.globalData.url + "static/" + formObject.photopath1 - } - fileList.push(file1) - } - if (formObject.photopath2 != "") { - var file2 = { - url: app.globalData.url + "static/" + formObject.photopath2 - } - fileList.push(file2) - } - if (formObject.photopath3 != "") { - var file3 = { - url: app.globalData.url + "static/" + formObject.photopath3 - } - fileList.push(file3) - } - - _this.setData({ - fileList - }); } - var installtime = 'form.installtimeFmt'; - var dateNow = this.formatDate(); - this.setData({ - installtimeFmt: dateNow, - [installtime]: dateNow, - }); - }, + } + }) - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { + //获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + _this.setData({ + option1: welltypeArr + }) + } + } +}) - }, + //跳转时带入参数返回哪页 + if (options.pageName) { + this.setData({ + pageName: options.pageName + }) + } + //跳转时带入参数设备的安装信息 + if (wx.getStorageSync('resultObject')) { + var formObject = wx.getStorageSync('resultObject') + _this.setData({ + form: formObject, + detail: formObject + }) - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { + _this.setData({ + ['form.installperson']: app.globalData.userName, + ['form.installtimeFmt']: "", + ['form.workmsg']: "", + ['form.description']: "" + }) - }, + const { + fileList = [] + } = _this.data; + if (formObject.photopath1 != "") { + var file1 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath1 + } + fileList.push(file1) + } + if (formObject.photopath2 != "") { + var file2 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath2 + } + fileList.push(file2) + } + if (formObject.photopath3 != "") { + var file3 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath3 + } + fileList.push(file3) + } + _this.setData({ + fileList + }); + } + var installtime = 'form.installtimeFmt'; + var dateNow = this.formatDate(); + this.setData({ + installtimeFmt: dateNow, + [installtime]: dateNow, + }); + }, - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, - }, + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + wx.removeStorageSync('resultObject') + }, - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, - }, + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { + }, - }, + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { + }, - }, + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { + }, - }, + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + }, - /** - * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true - **/ + /** + * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true + **/ - isNumber: function (val) { + isNumber: function (val) { - var regPos = /^[0-9]*$/; //非负浮点数 - var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数 - if (regPos.test(val) || regNeg.test(val)) { - return false; - } else { - return true; - } + var regPos = /^[0-9]*$/; //非负浮点数 + var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数 + if (regPos.test(val) || regNeg.test(val)) { + return false; + } else { + return true; + } - }, + }, - formValidate() { + formValidate() { - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } - if (this.data.form.wellcode == "") { - wx.showToast({ - icon: 'none', - title: '井编号不能为空!', - }) - return false - } - if (this.data.form.devicetype == "") { - wx.showToast({ - icon: 'none', - title: '设备类型不能为空!', - }) - return false - } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + if (this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '设备编号不能为空!', + }) + return false + } + if (this.data.form.wellcode == "") { + wx.showToast({ + icon: 'none', + title: '井编号不能为空!', + }) + return false + } + if (this.data.form.devicetype == "") { + wx.showToast({ + icon: 'none', + title: '设备类型不能为空!', + }) + return false + } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null || - this.data.form.installperson == '') { - wx.showToast({ - icon: 'none', - title: '运维人员不能为空!', - }) - return false - } - if (this.data.form.project == "") { - wx.showToast({ - icon: 'none', - title: '所属项目不能为空!', - }) - return false - } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } + if (this.data.form.installperson == null || + this.data.form.installperson == '') { + wx.showToast({ + icon: 'none', + title: '运维人员不能为空!', + }) + return false + } + if (this.data.form.project == "") { + wx.showToast({ + icon: 'none', + title: '所属项目不能为空!', + }) + return false + } - if (this.data.form.welldepth != null) { - if (this.isNumber(this.data.form.welldepth)) { - wx.showToast({ - icon: 'none', - title: '井深必须为数值!', - }) - return false - } - } - if (this.data.form.installheigt != null) { - if (this.isNumber(this.data.form.installheigt)) { - wx.showToast({ - icon: 'none', - title: '到井口距离必须为数值!', - }) - return false - } - } - - return true; - }, - - changeMsg: function () { - var formNew = this.data.form; - var formOld = JSON.parse(this.data.detail); - var descpNew = ""; - if (formNew.devcode != formOld.devcode) { - descpNew += "修改设备编号,原编号:" + formOld.devcode + ",新编号:" + formNew.devcode + ";" - } - if (formNew.devicetype != formOld.devicetype) { - descpNew += "修改设备类型,原设备类型:" + formOld.devicetype + ",新设备类型:" + formNew.devicetype + ";" - } - if (formNew.area != formOld.area) { - descpNew += "修改区,原区:" + formOld.area + ",新区:" + formNew.area + ";" - } - if (formNew.street != formOld.street) { - descpNew += "修改街道,原街道:" + formOld.street + ",新街道:" + formNew.street + ";" - } - if (formNew.wellname != formOld.wellname) { - descpNew += "修改井名称,原井名称:" + formOld.wellname + ",新井名称:" + formNew.wellname + ";" - } - if (formNew.factory != formOld.factory) { - descpNew += "修改权属单位,原权属单位:" + formOld.factory + ",新权属单位:" + formNew.factory + ";" - } - if (formNew.installheigt != formOld.installheigt) { - descpNew += "修改井口距离,原井口距离:" + formOld.installheigt + ",新井口距离:" + formNew.installheigt + ";" - } - if (formNew.installperson != formOld.installperson) { - descpNew += "修改运维人员,原运维人员:" + formOld.installperson + ",新运维人员:" + formNew.installperson + ";" - } - if (formNew.latitude != formOld.latitude) { - descpNew += "修改纬度,原纬度:" + formOld.latitude + ",新纬度:" + formNew.latitude + ";" - } - if (formNew.longitude != formOld.longitude) { - descpNew += "修改经度,原经度:" + formOld.longitude + ",新经度:" + formNew.longitude + ";" - } - if (formNew.position != formOld.position) { - descpNew += "修改位置描述,原位置:" + formOld.position + ",新位置:" + formNew.position + ";" - } - if (formNew.wellcode != formOld.wellcode) { - descpNew += "修改井编号,原编号:" + formOld.wellcode + ",新编号:" + formNew.wellcode + ";" - } - if (formNew.welldepth != formOld.welldepth) { - descpNew += "修改井深,原井深:" + formOld.welldepth + ",新井深:" + formNew.welldepth + ";" - } - if (formNew.welltype != formOld.welltype) { - descpNew += "修改井类型,原井类型:" + formOld.welltype + ",新井类型:" + formNew.welltype + ";" - } - if (formNew.project != formOld.project) { - descpNew += "修改所属项目,原项目:" + formOld.project + ",新项目:" + formNew.project + ";" - } - if (this.data.photopath1 != formOld.photopath1 || - this.data.photopath2 != formOld.photopath2 || - this.data.photopath3 != formOld.photopath3) { - descpNew += "修改照片;" - } - if ("" != formNew.description) { - descpNew += formNew.description; - } - this.setData({ - ['form.description']: descpNew + if (this.data.form.welldepth != null) { + if (this.isNumber(this.data.form.welldepth)) { + wx.showToast({ + icon: 'none', + title: '井深必须为数值!', }) - }, + return false + } + } + if (this.data.form.installheigt != null) { + if (this.isNumber(this.data.form.installheigt)) { + wx.showToast({ + icon: 'none', + title: '到井口距离必须为数值!', + }) + return false + } + } - formSubmit: function (event) { + return true; + }, - if (!this.formValidate()) { - return false; - } - this.changeMsg(); - var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDeviceLog', - data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceLog/add" - }, - }).then(res => { - // var resultObj=JSON.parse(res.result); - if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - if (res.confirm) { - wx.switchTab({ - url: that.data.pageName - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) - } - }).catch(err => { - console.error(err) - wx.showToast({ - title: "提交失败", - }) - }) - }, - confirm(event) { - var that = this; - var formValue = event.detail.value; - var formName = event.target.dataset.id; - var fromN = 'form.' + [formName]; - that.setData({ - [fromN]: formValue - }) - }, + //获取与上次修改的信息 + changeMsg: function () { + var formNew = this.data.form; + console.log(this.data.detail) + var formOld = JSON.parse(this.data.detail); + var descpNew = ""; + if (formNew.devcode != formOld.devcode) { + descpNew += "修改设备编号,原值:" + formOld.devcode + ",新值:" + formNew.devcode + ";" + } + if (formNew.devicetype != formOld.devicetype) { + descpNew += "修改设备类型,原值:" + formOld.devicetype + ",新值:" + formNew.devicetype + ";" + } + if (formNew.area != formOld.area) { + descpNew += "修改区,原值:" + formOld.area + ",新值:" + formNew.area + ";" + } + if (formNew.street != formOld.street) { + descpNew += "修改街道,原值:" + formOld.street + ",新值:" + formNew.street + ";" + } + if (formNew.wellname != formOld.wellname) { + descpNew += "修改井名称,原值:" + formOld.wellname + ",新值:" + formNew.wellname + ";" + } + if (formNew.factory != formOld.factory) { + descpNew += "修改权属单位,原值:" + formOld.factory + ",新值:" + formNew.factory + ";" + } + if (formNew.installheigt != formOld.installheigt) { + descpNew += "修改井口距离,原值:" + formOld.installheigt + ",新值:" + formNew.installheigt + ";" + } + if (formNew.installperson != formOld.installperson) { + descpNew += "修改运维人员,原值:" + formOld.installperson + ",新值:" + formNew.installperson + ";" + } + if (formNew.latitude != formOld.latitude) { + descpNew += "修改纬度,原值:" + formOld.latitude + ",新值:" + formNew.latitude + ";" + } + if (formNew.longitude != formOld.longitude) { + descpNew += "修改经度,原值:" + formOld.longitude + ",新值:" + formNew.longitude + ";" + } + if (formNew.position != formOld.position) { + descpNew += "修改位置描述,原值:" + formOld.position + ",新值:" + formNew.position + ";" + } + if (formNew.wellcode != formOld.wellcode) { + descpNew += "修改井编号,原值:" + formOld.wellcode + ",新值:" + formNew.wellcode + ";" + } + if (formNew.welldepth != formOld.welldepth) { + descpNew += "修改井深,原值:" + formOld.welldepth + ",新值:" + formNew.welldepth + ";" + } + if (formNew.welltype != formOld.welltype) { + descpNew += "修改井类型,原值:" + formOld.welltype + ",新值:" + formNew.welltype + ";" + } + if (formNew.project != formOld.project) { + descpNew += "修改所属项目,原值:" + formOld.project + ",新值:" + formNew.project + ";" + } + if (this.data.form.photopath1 != formOld.photopath1 || + this.data.form.photopath2 != formOld.photopath2 || + this.data.form.photopath3 != formOld.photopath3) { + descpNew += "修改照片;" + } + if ("" != formNew.description) { + descpNew += formNew.description; + } + this.setData({ + ['form.description']: descpNew + }) + }, - scan() { + //提交表单 + formSubmit: function (event) { - wx.scanCode({ - success(res) { - console.log(res) - } - }) + //表单验证 + if (!this.formValidate()) { + return false; + } + //自动生成修改内容 + this.changeMsg(); + //提交权限限制(只有施工人员能修改) + if(app.globalData.role!='repair'){ + wx.showToast({ + icon: 'none', + title: '无权限修改', + duration:2000 + }) + return false + } + var that = this; + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopath = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopath]: fileList[i].url.split("static/")[1] + }) + } + delete that.data.form.installtime + delete that.data.form.createtime + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - paste() { - var _this = this; - wx.getClipboardData({ - success: function (res) { - var longitude = 'form.longitude'; - var latitude = 'form.latitude'; - var longitude84 = 'form.longitude84'; - var latitude84 = 'form.latitude84'; - _this.setData({ - [longitude]: parseFloat(res.data.split(",", 4)[1]).toFixed(6), - [latitude]: parseFloat(res.data.split(",", 4)[0]).toFixed(6), - [longitude84]: "" == (res.data.split(",", 4)[3]) ? "" : parseFloat(res.data.split(",", 4)[3]).toFixed(6), - [latitude84]: "" == (res.data.split(",", 4)[2]) ? "" : parseFloat(res.data.split(",", 4)[2]).toFixed(6), - longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), - latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), - }); - } - }) - }, - selectValue(value) { - var that = this; - var wellType = 'form.welltype'; - that.setData({ - [wellType]: value.detail - }) - }, - selectpersonValue(event) { - var that = this; - var installPerson = 'form.installperson'; - that.setData({ - [installPerson]: event.detail - }) - }, - selectprojectValue(event) { - var that = this; - var project = 'form.project'; - that.setData({ - [project]: event.detail, - showMask: true - }) - }, - open() { - this.setData({ - showMask: true - }) - }, - close() { - this.setData({ - showMask: false - }) - }, - afterRead(event) { - var _this = this; - const { - file - } = event.detail; - const { - fileList = [] - } = _this.data; - var convertpath = ""; - wx.compressImage({ - src: event.detail.file.path, - quality: 25, - success: function (res) { - convertpath = res.tempFilePath; - wx.uploadFile({ - url: app.globalData.httpsUrl + "appDeviceAdd/fileUploadMarker", - filePath:convertpath, - name: 'file', - formData: { - 'text': "编号:" + _this.data.form.devcode + "经度:" + _this.data.form.longitude + "纬度:" + _this.data.form.latitude - }, - header: { - "Content-Type": "multipart/form-data", - 'accept': 'application/json', - }, - success(res) { - if (res.data) { - var url = JSON.parse(res.data); - fileList.push({ - ...file, - url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - }); - _this.setData({ - fileList - }); - } - } + success(res) { + if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + if (res.confirm) { + wx.switchTab({ + url: that.data.pageName }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') } - }) - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // // var base64 = "data:image/png;base64," + wx.getFileSystemManager().readFileSync(convertpath, 'base64'); - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: convertpath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // // wx.cloud.callFunction({ - // // name: 'uploadFile', - // // data: { - // // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // // fileBase64: base64 - // // }, - // // success: function (res) { - // // if (res.result) { - // // fileList.push({ - // // ...file, - // // url: app.globalData.url + "static/" + res.result.data.replace(/\\/g, "/") - // // }); - // // _this.setData({ - // // fileList - // // }); - // // } - // // }, - // // complete: res => { - // // }, - // // }) - // } - // }); + } + }) + } + }, + fail(err) { + wx.showToast({ + title: "提交失败", + }) + } + }) + }, + //报存录入的input信息 + confirm(event) { + var that = this; + var formValue = event.detail.value; + var formName = event.target.dataset.id; + var fromN = 'form.' + [formName]; + that.setData({ + [fromN]: formValue + }) + }, + + //扫码 + scan() { + + wx.scanCode({ + success(res) { + console.log(res) + } + }) + }, + //粘贴经纬度 + paste() { + var _this = this; + wx.getClipboardData({ + success: function (res) { + var longitude = 'form.longitude'; + var latitude = 'form.latitude'; + var longitude84 = 'form.longitude84'; + var latitude84 = 'form.latitude84'; + _this.setData({ + [longitude]: parseFloat(res.data.split(",", 4)[1]).toFixed(6), + [latitude]: parseFloat(res.data.split(",", 4)[0]).toFixed(6), + [longitude84]: "" == (res.data.split(",", 4)[3]) ? "" : parseFloat(res.data.split(",", 4)[3]).toFixed(6), + [latitude84]: "" == (res.data.split(",", 4)[2]) ? "" : parseFloat(res.data.split(",", 4)[2]).toFixed(6), + longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), + latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), + }); + } + }) + }, + selectValue(value) { + var that = this; + var wellType = 'form.welltype'; + that.setData({ + [wellType]: value.detail + }) + }, + //运维人员默认为登录人 + // selectpersonValue(event) { + // var that = this; + // var installPerson = 'form.installperson'; + // that.setData({ + // [installPerson]: event.detail + // }) + // }, + selectprojectValue(event) { + var that = this; + var project = 'form.project'; + that.setData({ + [project]: event.detail, + showMask: true + }) + }, + + open() { + this.setData({ + showMask: true + }) + }, + //隐藏textarea,防止遮挡 + close() { + this.setData({ + showMask: false + }) + }, + //上传照片 + afterRead(event) { + var _this = this; + const { + file + } = event.detail; + const { + fileList = [] + } = _this.data; + var convertpath = ""; + wx.compressImage({ + src: event.detail.file.path, + quality: 25, + success: function (res) { + convertpath = res.tempFilePath; + wx.uploadFile({ + url: app.globalData.httpsUrl + "appDeviceAdd/fileUploadMarker", + filePath: convertpath, + name: 'file', + formData: { + 'text': "编号:" + _this.data.form.devcode + "经度:" + _this.data.form.longitude + "纬度:" + _this.data.form.latitude }, - deletePhoto(event) { - var that = this - var image_index = event.detail.index - var fileList_new = that.data.fileList; - wx.showModal({ - content: '确定删除照片?', - success: function (res) { - if (res.confirm) { - fileList_new.splice(image_index, 1); - that.setData({ - fileList: fileList_new - }) - wx.cloud.callFunction({ - name: 'deletePhoto', - data: { - url: app.globalData.url + "appDeviceLog/deletePhoto", - devcode: that.data.form.devcode, - pathIndex: image_index - }, - success: function (res) {}, - complete: res => {}, - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + "Content-Type": "multipart/form-data", + 'accept': 'application/json', }, - }) \ No newline at end of file + success(res) { + if (res.data) { + var url = JSON.parse(res.data); + fileList.push({ + ...file, + url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") + }); + _this.setData({ + fileList + }); + } + } + }) + } + }) + }, + //删除照片 + deletePhoto(event) { + var that = this + var image_index = event.detail.index + var fileList_new = that.data.fileList; + wx.showModal({ + content: '确定删除照片?', + success: function (res) { + if (res.confirm) { + fileList_new.splice(image_index, 1); + that.setData({ + fileList: fileList_new + }) + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deletePhoto", + data: { + devcode: that.data.form.devcode + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) {} + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } +}) \ No newline at end of file diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.wxml b/miniprogram/pages/addDevicelog/addDeviceLog.wxml index 38620d4..b10cc7d 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.wxml +++ b/miniprogram/pages/addDevicelog/addDeviceLog.wxml @@ -1,15 +1,21 @@ - + + + + + - + - - + + - - + + - + @@ -39,24 +45,25 @@ - - - + + + - + - + + @@ -64,7 +71,7 @@ - + @@ -79,9 +86,9 @@ - + - 保存 + 保存 diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.wxss b/miniprogram/pages/addDevicelog/addDeviceLog.wxss index ee0b75c..08d5fd7 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.wxss +++ b/miniprogram/pages/addDevicelog/addDeviceLog.wxss @@ -24,6 +24,17 @@ display: flex; align-items: center; } +.map-view{ + width: 750rpx; + height: 485rpx; + position: fixed; + top: 0px; + left: 0px; + z-index: 999; +} +.content{ + margin-top: 495rpx; +} .left { width: 210rpx; diff --git a/miniprogram/pages/addFunction/addFunction.js b/miniprogram/pages/addFunction/addFunction.js deleted file mode 100644 index 4966be3..0000000 --- a/miniprogram/pages/addFunction/addFunction.js +++ /dev/null @@ -1,60 +0,0 @@ -// pages/addFunction/addFunction.js - -const code = `// 云函数入口函数 -exports.main = (event, context) => { - console.log(event) - console.log(context) - return { - sum: event.a + event.b - } -}` - -Page({ - - data: { - result: '', - canIUseClipboard: wx.canIUse('setClipboardData'), - }, - - onLoad: function (options) { - - }, - - copyCode: function() { - wx.setClipboardData({ - data: code, - success: function () { - wx.showToast({ - title: '复制成功', - }) - } - }) - }, - - testFunction() { - wx.cloud.callFunction({ - name: 'sum', - data: { - a: 1, - b: 2 - }, - success: res => { - wx.showToast({ - title: '调用成功', - }) - this.setData({ - result: JSON.stringify(res.result) - }) - }, - fail: err => { - wx.showToast({ - icon: 'none', - title: '调用失败', - }) - console.error('[云函数] [sum] 调用失败:', err) - } - }) - }, - -}) - diff --git a/miniprogram/pages/addFunction/addFunction.json b/miniprogram/pages/addFunction/addFunction.json deleted file mode 100644 index a9a50c5..0000000 --- a/miniprogram/pages/addFunction/addFunction.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "navigationBarTitleText": "云函数指引", - "usingComponents": {} -} \ No newline at end of file diff --git a/miniprogram/pages/addFunction/addFunction.wxml b/miniprogram/pages/addFunction/addFunction.wxml deleted file mode 100644 index 3a10626..0000000 --- a/miniprogram/pages/addFunction/addFunction.wxml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - 测试云函数 - - - 期望输出:{"sum":3} - - - 调用结果:{{result}} - - - - - 新增云函数 - 1. 在云函数根目录 cloudfunctions 上右键选择新建云函数,命名为 sum - 2. 在创建的 cloudfunctions/sum/index.js 文件中添加如下代码 - - - 3. 在 cloudfunctions/sum 目录上右键上传并部署 - 4. 点击测试云函数测试 - 5. 打开云开发云函数管理页,选择 sum 云函数 - 6. 查看 sum 的调用日志 - 进阶:可在云函数中使用 wx-server-sdk 操作数据库,文件存储和调用其他云函数,详见文档 - - - diff --git a/miniprogram/pages/addFunction/addFunction.wxss b/miniprogram/pages/addFunction/addFunction.wxss deleted file mode 100644 index 7ac8619..0000000 --- a/miniprogram/pages/addFunction/addFunction.wxss +++ /dev/null @@ -1,3 +0,0 @@ -/* pages/addFunction/addFunction.wxss */ - -@import "../../style/guide.wxss"; \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.js b/miniprogram/pages/applog/applog.js index 0e8c185..189e61f 100644 --- a/miniprogram/pages/applog/applog.js +++ b/miniprogram/pages/applog/applog.js @@ -13,98 +13,25 @@ isSeach: "false", params: {}, total: 0, - show: false + show: false, + delBtnWidth: 100, //删除按钮宽度单位(rpx) + activeIndex: -1, + list_style: '' }, - - touchE: function (e) { - // console.log(e); - var that = this - if (e.changedTouches.length == 1) { - //手指移动结束后触摸点位置的X坐标 - var endX = e.changedTouches[0].clientX; - //触摸开始与结束,手指移动的距离 - var disX = that.data.startX - endX; - var delBtnWidth = that.data.delBtnWidth; - //如果距离小于删除按钮的1/2,不显示删除按钮 - var txtStyle = disX > delBtnWidth / 2 ? "left:-" + delBtnWidth + "rpx" : "left:0rpx"; - - //获取手指触摸的是哪一项 - var index = e.currentTarget.dataset.index; - var list = that.data.deviceloglist; - list[index].txtStyle = txtStyle; - //更新列表的状态 - that.setData({ - deviceloglist: list - }); - } - }, - //手指触摸动作开始 记录起点X坐标 - touchstart: function (e) { - //开始触摸时 重置所有删除 - this.data.deviceloglist.forEach(function (v, i) { - if (v.isTouchMove) //只操作为true的 - v.isTouchMove = false; - }) - this.setData({ - startX: e.changedTouches[0].clientX, - startY: e.changedTouches[0].clientY, - deviceloglist: this.data.deviceloglist - }) - }, - //滑动事件处理 - touchmove: function (e) { - var that = this, - index = e.currentTarget.dataset.index, //当前索引 - startX = that.data.startX, //开始X坐标 - startY = that.data.startY, //开始Y坐标 - touchMoveX = e.changedTouches[0].clientX, //滑动变化坐标 - touchMoveY = e.changedTouches[0].clientY, //滑动变化坐标 - //获取滑动角度 - angle = that.angle({ - X: startX, - Y: startY - }, { - X: touchMoveX, - Y: touchMoveY - }); - that.data.deviceloglist.forEach(function (v, i) { - v.isTouchMove = false - //滑动超过30度角 return - if (Math.abs(angle) > 30) return; - if (i == index) { - if (touchMoveX > startX) //右滑 - v.isTouchMove = false - else //左滑 - v.isTouchMove = true - } - }) - //更新数据 - that.setData({ - deviceloglist: that.data.deviceloglist - }) - }, - /** - * 计算滑动角度 - * @param {Object} start 起点坐标 - * @param {Object} end 终点坐标 - */ - angle: function (start, end) { - var _X = end.X - start.X, - _Y = end.Y - start.Y - //返回角度 /Math.atan()返回数字的反正切值 - return 360 * Math.atan(_Y / _X) / (2 * Math.PI); - }, - /** - * 生命周期函数--监听页面加载var_this=this; - */ onLoad: function (options) { - if (options.params) { this.setData({ params: JSON.parse(options.params), isSeach: "true" }) this.initPages() + }else{ + this.setData({ + show: false + }) + //清空参数,重新加载 + this.clearParams(); + this.initPages(); } }, @@ -116,20 +43,33 @@ }, + //点击tabBar事件 + onTabItemTap(item) { + //隐藏历史显示总记录条数 + this.setData({ + show: false + }) + //清空参数,重新加载 + this.clearParams(); + this.initPages(); + }, + + /** * 生命周期函数--监听页面显示 */ onShow: function (options) { - this.setData({ - show:false - }) - if (this.data.isSeach == "false") { - this.clearParams(); - this.initPages(); - } - this.setData({ - isSeach: "false" - }) + + // this.setData({ + // show: false + // }) + // if (this.data.isSeach == "false") { + // this.clearParams(); + // this.initPages(); + // } + // this.setData({ + // isSeach: "false" + // }) }, /** @@ -167,6 +107,119 @@ }, + + //手指触摸动作开始 记录起点X坐标 + touchstart: function (e) { + //开始触摸时 重置所有删除 + this.data.deviceloglist.forEach(function (v, i) { + if (v.isTouchMove) //只操作为true的 + v.isTouchMove = false; + }) + this.setData({ + startX: e.changedTouches[0].clientX, + startY: e.changedTouches[0].clientY, + deviceloglist: this.data.deviceloglist + }) + }, + + //滑动事件处理 + touchmove: function (e) { + var that = this, + index = e.currentTarget.dataset.index, //当前索引 + startX = that.data.startX, //开始X坐标 + startY = that.data.startY, //开始Y坐标 + touchMoveX = e.changedTouches[0].clientX, //滑动变化坐标 + touchMoveY = e.changedTouches[0].clientY, //滑动变化坐标 + //获取滑动角度 + angle = that.angle({ + X: startX, + Y: startY + }, { + X: touchMoveX, + Y: touchMoveY + }); + that.data.deviceloglist.forEach(function (v, i) { + // v.isTouchMove = false + //滑动超过30度角 return + if (Math.abs(angle) > 30) return; + if (i == index) { + if (touchMoveX > startX) //右滑 + v.isTouchMove = false + else //左滑 + v.isTouchMove = true + } + }) + //更新数据 + that.setData({ + deviceloglist: that.data.deviceloglist + }) + }, + + /** + * 计算滑动角度 + * @param {Object} start 起点坐标 + * @param {Object} end 终点坐标 + */ + angle: function (start, end) { + var _X = end.X - start.X, + _Y = end.Y - start.Y + //返回角度 /Math.atan()返回数字的反正切值 + return 360 * Math.atan(_Y / _X) / (2 * Math.PI); + }, + + //删除事件 + delItem: function (e) { + if(app.globalData.role!='repair'){ + wx.showToast({ + icon: 'none', + title: '无权限删除', + duration:2000 + }) + return false + } + var that = this + wx.showModal({ + content: '是否删除?', + success: function (res) { + if (res.confirm) { + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/delete", + data: { + appDeviceAddId: e.currentTarget.dataset.devid + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if(res.data.code=='200'){ + that.data.deviceloglist.splice(e.currentTarget.dataset.index, 1) + that.setData({ + deviceloglist: that.data.deviceloglist, + total: that.data.deviceloglist.length + }) + wx.showToast({ + title: '删除成功!', + icon: 'none', + duration: 1000 + }) + } + }, + fail(err) { + wx.showToast({ + title: '删除失败!', + icon: 'none', + duration: 2000 + }) + } + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + }, + showLoading: function (message) { if (wx.showLoading) { // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 @@ -199,95 +252,105 @@ deviceloglist: [] }) }, + //查询列表数据 initPages: function () { var that = this + that.setData({ + show: false + }) var offsetValue = that.data.deviceloglist.length % 15 > 0 ? parseInt(that.data.deviceloglist.length / 15) + 2 : parseInt(that.data.deviceloglist.length / 15) + 1 - wx.cloud.callFunction({ - name: 'devicelog', + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/listPage", data: { devcode: that.data.params.devcode, devtype: that.data.params.devtype, installtimeFmt: that.data.params.installtimeFmt, project: that.data.params.project, installPerson: that.data.params.installPerson, - url: app.globalData.url + "appDeviceLog/listPage", limit: 15, offset: offsetValue }, - }).then(res => { - if (res.result.data.rows.length > 0) { - var resultJson = res.result - that.setData({ - deviceloglist: that.data.deviceloglist.concat(resultJson.data.rows) - }) - } else if (that.data.deviceloglist.length > 0) { - that.setData({ - show: true, - total: that.data.deviceloglist.length - }) - wx.showToast({ - title: '数据已全部加载完', - icon: 'none', - duration: 2000 - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.data.rows.length > 0) { + var resultJson = res.data + var listArr = resultJson.data.rows + listArr.forEach(function (v, i) { + listArr[i]['isTouchMove'] = false + }) + that.setData({ + deviceloglist: that.data.deviceloglist.concat(listArr) + }) + } else if (that.data.deviceloglist.length > 0) { + that.setData({ + show: true, + total: that.data.deviceloglist.length + }) + wx.showToast({ + title: '数据已全部加载完', + icon: 'none', + duration: 2000 + }) + } + if (offsetValue == 1 && res.data.data.rows.length < 15) { + that.setData({ + show: true, + total: that.data.deviceloglist.length + }) + } } - if(offsetValue==1&&res.result.data.rows.length<15){ - that.setData({ - show: true, - total: that.data.deviceloglist.length - }) - } - // console.log(res); - }).catch(err => { - console.error(err); }) + }, addDetail: function (event) { - this.showLoading("数据请求中..."); - wx.cloud.callFunction({ - name: 'deviceDetail', + var that = this + that.showLoading("数据请求中..."); + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deviceDetail", data: { devcode: event.target.dataset.devcode, - url: app.globalData.url + "appDeviceLog/deviceDetail", }, - }).then(res => { - this.hideLoading(); - var resultObject = JSON.parse(res.result); - var pageName = '../applog/applog' - if (resultObject.code == 200) { - wx.navigateTo({ - url: '../addDevicelog/addDeviceLog?detail=' + - JSON.stringify(resultObject.data) + "&pageName=" + pageName - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + that.hideLoading(); + // var resultObject = JSON.parse(res.data); + var resultObject = res.data; + var pageName = '../applog/applog' + if (resultObject.code == 200) { + wx.setStorageSync('resultObject', resultObject.data) + wx.navigateTo({ + url: '../addDevicelog/addDeviceLog?detail=' + "&pageName=" + pageName + }) + } + }, + fail(err) { + that.hideLoading(); } - }).catch(err => { - this.hideLoading() }) + }, add: function (event) { - wx.reLaunch({ - url: '../earth/earth?devcode=' + event.target.dataset.devcode - // url: '../earth/earth' + app.globalData.devcode = event.target.dataset.devcode; + wx.switchTab({ + url: '../earth/earth' }) + // wx.reLaunch({ + // url: '../earth/earth?devcode=' + event.target.dataset.devcode + // // url: '../earth/earth' + // }) }, onSearch: function () { + var _this = this wx.navigateTo({ - url: '../searchLog/searchLog' + url: '../searchLog/searchLog?params=' + JSON.stringify(_this.data.params) }) - }, - // initPages: function () { - // wx.cloud.callFunction({ - // name: 'devicelog' - // }).then(res => { - // var that = this; - // var jsonList = JSON.parse(res.result) - // that.setData({ - // deviceloglist: jsonList.data.rows - // }) - // console.log(res); - // }).catch(err => { - // console.error(err); - // }) - // } + } }) \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.wxml b/miniprogram/pages/applog/applog.wxml index e9a2352..2bfd041 100644 --- a/miniprogram/pages/applog/applog.wxml +++ b/miniprogram/pages/applog/applog.wxml @@ -1,54 +1,59 @@ - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {{item.devcode}} {{item.devicetype}} + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + {{item.devcode}} {{item.devicetype}} + + {{item.project}} {{item.installtime}}- {{item.installperson}} - - - - - + + + + + + 删除 - - - + + - 共计:{{total}}台 - + 共计:{{total}}台 + \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.wxss b/miniprogram/pages/applog/applog.wxss index 6d3428b..e6e8983 100644 --- a/miniprogram/pages/applog/applog.wxss +++ b/miniprogram/pages/applog/applog.wxss @@ -22,16 +22,18 @@ position: fixed; width: 100%; top: 0rpx; + z-index: 9999; /* margin-bottom: 100rpx; */ } .log-list { /* height: 100rpx; */ - /* display: flex; */ - + display: flex; + width: 100%; padding: 2px; margin-top: 2px; border-bottom: 1px solid #e5e5e5; + overflow: hidden } @@ -53,23 +55,29 @@ left: 35%; margin: 20rpx } - .del { - width: 90px; + /* display: flex; */ + width: 100rpx; display: flex; flex-direction: column; align-items: center; justify-content: center; - color: #fff; - -webkit-transform: translateX(90px); - transform: translateX(90px); - -webkit-transition: all 0.4s; + /* -webkit-transform: translateX(100rpx); */ + transform: translateX(100rpx); + /* -webkit-transition: all 0.4s; */ transition: all 0.4s; - font-size: 35rpx; + color: #fff; + background-color: #fe3e2f; +} +.logrow{ + width: 100%; + transform: translateX(100rpx); + /* -webkit-transform: translateX(100px); */ + margin-left: -100rpx; } -.touch-move-active .content, +.touch-move-active .logrow, .touch-move-active .del { - -webkit-transform: translateX(0); - transform: translateX(0); +/* -webkit-transform: translateX(0); */ +transform: translateX(0); } \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.js b/miniprogram/pages/deployFunctions/deployFunctions.js deleted file mode 100644 index a76b144..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.js +++ /dev/null @@ -1,66 +0,0 @@ -// pages/deployFunctions/deployFunctions.js -Page({ - - /** - * 页面的初始数据 - */ - data: { - - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - - }, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { - - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - - }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { - - }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { - - } -}) \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.json b/miniprogram/pages/deployFunctions/deployFunctions.json deleted file mode 100644 index 7fbedab..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "navigationBarTitleText": "部署云函数", - "usingComponents": {} -} \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.wxml b/miniprogram/pages/deployFunctions/deployFunctions.wxml deleted file mode 100644 index 462b6b6..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.wxml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - 调用失败 - - - 请检查 login 云函数是否已部署 - - - - - 部署 login 云函数 - 1. 确保已通过工具栏云开发入口开通云开发 - 2. 在 cloudfunctions/login 目录上右键上传并部署 - 3. 回到首页,重新点击获取 openid - - - - diff --git a/miniprogram/pages/deployFunctions/deployFunctions.wxss b/miniprogram/pages/deployFunctions/deployFunctions.wxss deleted file mode 100644 index c8803e6..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.wxss +++ /dev/null @@ -1,7 +0,0 @@ -/* pages/deployFunctions/deployFunctions.wxss */ - -@import "../../style/guide.wxss"; - -.black { - color: black; -} \ No newline at end of file diff --git a/miniprogram/pages/earth/earth.js b/miniprogram/pages/earth/earth.js index ae0d3f3..376a6e2 100644 --- a/miniprogram/pages/earth/earth.js +++ b/miniprogram/pages/earth/earth.js @@ -21,19 +21,12 @@ show: false, enableSsatellite: false, windowWidth: 0, - longitude: 113.324520, - latitude: 23.099994, - longitude84: 113.324520, - latitude84: 23.099994, - markers: [{ - id: 0, - iconPath: "../../images/locat.png", - latitude: 23.099994, - longitude: 113.324520, - width: 50, - height: 50 - }], - controls: [], + longitude: "116.627340", + latitude: "39.874390", + longitude84: "", + latitude84: "", + markers: [], + controls: [] }, /** @@ -41,39 +34,13 @@ */ onLoad: function (options) { var that = this; - //获取当前坐标(gcj02) - wx.getLocation({ - type: "gcj02", - altitude: true, - success: function (res) { - that.setData({ - latitude: parseFloat(res.latitude).toFixed(6), - longitude: parseFloat(res.longitude).toFixed(6), - // markers: [{ - // latitude: res.latitude, - // longitude: res.longitude, - // }] - }) - //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 - wx.getLocation({ - type: "wgs84", - altitude: true, - success: function (res) { - that.setData({ - latitude84: parseFloat(res.latitude).toFixed(6), - longitude84: parseFloat(res.longitude).toFixed(6) - }) - } - }) - } - }), - - //设置地图组件 - wx.getSystemInfo({ + //设置地图组件 + wx.getSystemInfo({ success(res) { var windowWidth = res.windowWidth var windowHeight = res.windowHeight var query = wx.createSelectorQuery() + var platform =res.platform query.select('#map').boundingClientRect() query.exec(function (res) { that.setData({ @@ -139,10 +106,20 @@ clickable: true }, { id: 7, - iconPath: '../../images/locat.png', + iconPath: '../../images/applocat.png', position: { - left: res[0].width/2, - top: res[0].height/2, + left: res[0].width / 2 - 20, + top: platform=="ios"?res[0].height / 2 - 80:res[0].height / 2 - 40, + width: 40, + height: 40 + }, + clickable: true + }, { + id: 8, + iconPath: '../../images/back.png', + position: { + left: windowWidth - 40, + top: windowHeight - 140, width: 30, height: 30 }, @@ -150,71 +127,15 @@ }] }) }) - + } - }), + }) + // 实例化API核心类 qqmapsdk = new QQMapWX({ key: 'BGPBZ-C5O3P-ROUDR-LWC4J-63EKH-V5FRX' }) - - if (options.devcode) { - var that = this - var devcode = options.devcode - wx.cloud.callFunction({ - name: 'findListByCodes', - data: { - devcodes: devcode, - url: app.globalData.url + "appDeviceAdd/findListByCodes" - }, - }).then(res => { - if (res.result.code == 200) { - var listResultData = res.result.data; - that.setData({ - listData: listResultData - }) - var markersArr = that.data.markers; - for (var i = 0; i < listResultData.length; i++) { - markersArr = markersArr.concat({ - iconPath: "../../images/locat.png", - id: listResultData[i].id, - callout: { - content: listResultData[i].devcode, - fontSize: '14', - // padding: true, - color: '#00000', - borderColor: '#F4EA2A', - bgColor: '#F4EA2A', - borderWidth: 5, - display: 'ALWAYS', - textAlign: 'center', - // borderRadius: 15 - }, - latitude: listResultData[i].latitude, - longitude: listResultData[i].longitude, - width: 40, - height: 40 - }); - } - this.setData({ - markers: markersArr, - latitude: listResultData[0].latitude, - longitude: listResultData[0].longitude, - marker_latitude: listResultData[0].latitude, - marker_longitude: listResultData[0].longitude, - title: listResultData[0].devcode - }) - } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "无法获取设备地理信息!", - icon: 'none', - duration: 2000 - }) - }) - } }, /** @@ -228,6 +149,97 @@ * 生命周期函数--监听页面显示 */ onShow: function () { + //输入设备编号获取marker位置信息 + var that = this; + if ( app.globalData.devcode!="") { + var devcode = app.globalData.devcode + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/findListByCodes", + data: { + devcodes: devcode, + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + app.globalData.devcode=""; + if (res.data.code == 200) { + var listResultData = res.data.data; + that.setData({ + listData: listResultData + }) + var markersArr = that.data.markers; + for (var i = 0; i < listResultData.length; i++) { + markersArr = markersArr.concat({ + iconPath: "../../images/locat.png", + id: Number(listResultData[i].id), + callout: { + content: "编号:"+listResultData[i].devcode+"\r\n位置:"+listResultData[i].position+"\r\n时间:"+listResultData[i].createtime, + fontSize: '14', + padding: true, + color: '#000000', + borderColor: '#F4EA2A', + bgColor: '#F4EA2A', + borderWidth: 5, + display: 'ALWAYS', + textAlign: 'left', + // borderRadius: 15 + }, + latitude: listResultData[i].latitude, + longitude: listResultData[i].longitude, + width: 40, + height: 40 + }); + } + that.setData({ + markers: markersArr, + latitude: listResultData[0].latitude, + longitude: listResultData[0].longitude, + marker_latitude: listResultData[0].latitude, + marker_longitude: listResultData[0].longitude, + title: listResultData[0].devcode + }) + } + }, + fail(err) { + app.globalData.devcode=""; + wx.showToast({ + title: "无法获取设备地理信息!", + icon: 'none', + duration: 2000 + }) + } + }) +} else { + //获取当前坐标(gcj02) + wx.getLocation({ + type: "gcj02", + altitude: true, + success: function (res) { + that.setData({ + latitude: parseFloat(res.latitude).toFixed(6), + longitude: parseFloat(res.longitude).toFixed(6), + // markers: [{ + // latitude: res.latitude, + // longitude: res.longitude, + // }] + }) + //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 + wx.getLocation({ + type: "wgs84", + altitude: true, + success: function (res) { + that.setData({ + latitude84: parseFloat(res.latitude).toFixed(6), + longitude84: parseFloat(res.longitude).toFixed(6) + }) + } + }) + } + }) +} + }, @@ -265,12 +277,46 @@ onShareAppMessage: function () { }, + + //定位出来 + + locationPosition: function () { + var that = this; + //获取当前坐标(gcj02) + wx.getLocation({ + type: "gcj02", + altitude: true, + success: function (res) { + that.setData({ + latitude: parseFloat(res.latitude).toFixed(6), + longitude: parseFloat(res.longitude).toFixed(6), + // markers: [{ + // latitude: res.latitude, + // longitude: res.longitude + // }] + }) + //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 + wx.getLocation({ + type: "wgs84", + altitude: true, + success: function (res) { + that.setData({ + latitude84: parseFloat(res.latitude).toFixed(6), + longitude84: parseFloat(res.longitude).toFixed(6) + }) + } + }) + } + }) + }, + + //加载地图组件 controltap: function (e) { // console.log(e.controlId); //进入添加设备页 if (1 == e.controlId) { wx.setClipboardData({ - data: this.data.latitude + "," + this.data.longitude+ "," + this.data.latitude84+ "," + this.data.longitude84, + data: this.data.latitude + "," + this.data.longitude + "," + this.data.latitude84 + "," + this.data.longitude84, success: function (res) { wx.getClipboardData({ success: function (res) { @@ -282,6 +328,17 @@ } }) } else if (3 == e.controlId) { + //先定位 + // this.locationPosition() + wx.setClipboardData({ + data: this.data.latitude + "," + this.data.longitude + "," + this.data.latitude84 + "," + this.data.longitude84, + success: function (res) { + wx.showToast({ + title: '坐标已获取', + duration: 1000 + }) + } + }) wx.navigateTo({ url: '../addDevice/addDevice' }) @@ -302,32 +359,15 @@ enableSsatellite: !flag }); } else if (6 == e.controlId) { - var that = this; - //获取当前坐标(gcj02) - wx.getLocation({ - type: "gcj02", - altitude: true, - success: function (res) { - that.setData({ - latitude: parseFloat(res.latitude).toFixed(6), - longitude:parseFloat(res.longitude).toFixed(6), - // markers: [{ - // latitude: res.latitude, - // longitude: res.longitude - // }] - }) - //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 - wx.getLocation({ - type: "wgs84", - altitude: true, - success: function (res) { - that.setData({ - latitude84: parseFloat(res.latitude).toFixed(6), - longitude84: parseFloat(res.longitude).toFixed(6) - }) - } - }) - } + //先清marker + this.setData({ + markers: [] + }) + this.locationPosition() + }else if (8 == e.controlId) { + //跳转日志缓存页 + wx.switchTab({ + url: '../applog/applog', }) } }, @@ -343,63 +383,68 @@ }); }, + //获取设备maker leave() { var that = this; if (that.data.devcodes == "") { return false; } - wx.cloud.callFunction({ - name: 'findListByCodes', + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/findListByCodes", data: { - devcodes: that.data.devcodes, - url: app.globalData.url + "appDeviceAdd/findListByCodes" + devcodes: that.data.devcodes }, - }).then(res => { - if (res.result.code == 200) { - var listResultData = res.result.data; - that.setData({ - listData: listResultData - }) - var markersArr = that.data.markers; - for (var i = 0; i < listResultData.length; i++) { - markersArr = markersArr.concat({ - iconPath: "../../images/locat.png", - id: listResultData[i].id, - callout: { - content: listResultData[i].devcode, - fontSize: '14', - // padding: true, - color: '', - borderColor: '#F4EA2A', - bgColor: '#F4EA2A', - borderWidth: 5, - display: 'ALWAYS', - textAlign: 'center', - // borderRadius: 15 - }, - latitude: listResultData[i].latitude, - longitude: listResultData[i].longitude, - width: 40, - height: 40 - }); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var listResultData = res.data.data; + that.setData({ + listData: listResultData + }) + var markersArr = that.data.markers; + for (var i = 0; i < listResultData.length; i++) { + markersArr = markersArr.concat({ + iconPath: "../../images/locat.png", + id: listResultData[i].id, + callout: { + content: "编号:"+listResultData[i].devcode+"\r\n位置:"+listResultData[i].position+"\r\n时间:"+listResultData[i].createtime, + fontSize: '14', + // padding: true, + color: '#212121', + borderColor: '#F4EA2A', + bgColor: '#F4EA2A', + borderWidth: 5, + display: 'ALWAYS', + textAlign: 'left', + // borderRadius: 15 + }, + latitude: listResultData[i].latitude, + longitude: listResultData[i].longitude, + width: 40, + height: 40 + }); + } + that.setData({ + markers: markersArr, + latitude: listResultData[0].latitude, + longitude: listResultData[0].longitude, + marker_latitude: listResultData[0].latitude, + marker_longitude: listResultData[0].longitude, + title: listResultData[0].devcode + }) } - this.setData({ - markers: markersArr, - latitude: listResultData[0].latitude, - longitude: listResultData[0].longitude, - marker_latitude: listResultData[0].latitude, - marker_longitude: listResultData[0].longitude, - title: listResultData[0].devcode + }, + fail(err) { + wx.showToast({ + title: "无法获取设备地理信息!", + icon: 'none', + duration: 2000 }) } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "无法获取设备地理信息!", - icon: 'none', - duration: 2000 - }) }) }, @@ -422,6 +467,8 @@ } }, + + bindregionchange: function (e) { var that = this if (e.causedBy == "drag") { @@ -445,8 +492,8 @@ that.setData({ latitude: parseFloat(latitude).toFixed(6), longitude: parseFloat(longitude).toFixed(6), - latitude84:"", - longitude84:"", + latitude84: "", + longitude84: "", // markers: markersArr }) // mapCtx.moveToLocation(); @@ -465,16 +512,19 @@ qqmapsdk.search({ keyword: this.data.value, success: function (res) { + console.log(res) if (res && res.data) { _this.setData({ isShow: true, tips: res.data }); } + }, + complete: function (res){ + console.log(res); } }) }, - bindSearch: function (e) { var location = e.target.dataset.location; this.setData({ diff --git a/miniprogram/pages/earth/earth.wxml b/miniprogram/pages/earth/earth.wxml index a0db6ef..87474f8 100644 --- a/miniprogram/pages/earth/earth.wxml +++ b/miniprogram/pages/earth/earth.wxml @@ -1,9 +1,10 @@ + - + {{item.title}} {{item.address}} @@ -17,6 +18,6 @@ + placeholder="请输入定位设备编号用换行隔开" autosize border="{{ false }}" /> \ No newline at end of file diff --git a/miniprogram/pages/indexapp/indexapp.js b/miniprogram/pages/indexapp/indexapp.js index 5063372..849dbdb 100644 --- a/miniprogram/pages/indexapp/indexapp.js +++ b/miniprogram/pages/indexapp/indexapp.js @@ -7,9 +7,8 @@ */ data: { - count:1, - show: false, - onshow:true, + count: 1, + onshow: true, value: "", deviceloglist: [], devcode: "", @@ -21,6 +20,7 @@ // iconPath: "../../images/point.png", latitude: 23.099994, longitude: 113.324520, + label:'1', width: 50, height: 50 }], @@ -31,62 +31,26 @@ * 生命周期函数--监听页面加载 */ onLoad: function (options) { - + }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { - + }, /** * 生命周期函数--监听页面显示 */ onShow: function () { - // if( app.globalData.indexCount>1){ - // this.setData({ - // show:false - // }) - // }else{ - // this.showNotice() - // } - if(app.globalData.indexCount==1){ - this.setData({ - show:true - }) - this.showNotice() - } - app.globalData.indexCount+=1 - if(this.data.onshow){ + if (this.data.onshow) { this.initPages(); } }, - - showNotice: function() { - var that = this - var times = 0 - var i = setInterval(function() { - times++ - if (times >= 15) { - that.setData({ - show:false - }) - wx.showTabBar({ - animation: false, - }) - clearInterval(i) - } else { - wx.hideTabBar({ - animation: false, - }) - } - }, 1000) -}, - /** * 生命周期函数--监听页面隐藏 */ @@ -122,16 +86,27 @@ }, jump: function (event) { - var that = this; var latitude = event.target.dataset.pointLat; var longitude = event.target.dataset.pointLon; + let devcode = event.target.dataset.pointCode; that.setData({ latitude: latitude, longitude: longitude, markers: [{ latitude: latitude, - longitude: longitude + longitude: longitude, + callout: { + display:'ALWAYS',// 常显气泡 + content: devcode, //名称文本 + color: '#fff', //文本颜色 + borderRadius: 5, //边框圆角 + borderWidth: 1, //边框宽度 + borderColor: '#0060ff', //边框颜色 + bgColor: '#0060ff', //背景色 + padding: 5, //文本边缘留白 + textAlign: 'center' //文本对齐方式。有效值: left, right, center + } }] }) }, @@ -142,7 +117,7 @@ var devcode = res.result _this.setData({ devcode: devcode, - onshow:false + onshow: false }); _this.searchlogs(devcode) } @@ -151,40 +126,11 @@ onSearch: function (event) { this.setData({ - devcode:event.detail + devcode: event.detail }) this.searchlogs(event.detail) }, - - // bindregionchange: function (e) { - // var that = this - // if (e.causedBy == "drag") { - // var mapCtx = wx.createMapContext("map") - // mapCtx.getCenterLocation({ - // success: function (res) { - // var markersArr = that.data.markers - // for (var i = 0; i < markersArr.length; i++) { - // if (markersArr[i].iconPath == undefined) { - // markersArr.splice(i, 1) - // } - // } - // var latitude = res.latitude - // var longitude = res.longitude - // markersArr = markersArr.concat({ - // latitude: latitude, - // longitude: longitude - // }) - // that.setData({ - // latitude: latitude, - // longitude: longitude, - // markers: markersArr - // }) - // } - // }) - // } - // }, - showLoading: function (message) { if (wx.showLoading) { // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 @@ -211,81 +157,89 @@ } }, + //加载设备运维详细信息 toDetail: function (event) { - this.showLoading("数据加载中...") - wx.cloud.callFunction({ - name: 'deviceDetail', + var that = this + that.showLoading("数据加载中...") + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deviceDetail", data: { devcode: event.target.dataset.devcode, - url: app.globalData.url + "appDeviceLog/deviceDetail", }, - }).then(res => { - this.hideLoading(); - var resultObject = JSON.parse(res.result); - var pageName='../indexapp/indexapp' - if (resultObject.code == 200) { - wx.navigateTo({ - url: '../addDevicelog/addDeviceLog?detail=' + - JSON.stringify(resultObject.data)+'&pageName='+pageName - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + that.hideLoading(); + var resultObject = res.data; + var pageName = '../indexapp/indexapp' + if (resultObject.code == 200) { + wx.setStorageSync('resultObject', resultObject.data) + wx.navigateTo({ + url: '../addDevicelog/addDeviceLog?detail=' +'&pageName=' + pageName + }) + } + }, + fail(err){ + that.hideLoading(); } - }).catch(err => { - this.hideLoading(); }) }, + //加载列表 getlogs: function (devcode) { var that = this - wx.cloud.callFunction({ - name: 'devicelog', + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/listPage", data: { devcode: devcode, - url: app.globalData.url + "appDeviceLog/listPage", limit: 100, offset: that.data.deviceloglist.length % 100 > 0 ? parseInt(that.data.deviceloglist.length / 100) + 2 : parseInt(that.data.deviceloglist.length / 100) + 1 }, - }).then(res => { - if (res.result) { - // var resultJson = JSON.parse(res.result) - var resultJson = res.result - that.setData({ - deviceloglist: that.data.deviceloglist.concat(resultJson.data.rows) - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + // var resultJson = JSON.parse(res.result) + var resultJson = res.data + that.setData({ + deviceloglist: that.data.deviceloglist.concat(resultJson.data.rows) + }) + } } - console.log(res); - }).catch(err => { - console.error(err); }) }, + //查询列表 searchlogs: function (devcode) { var that = this - wx.cloud.callFunction({ - name: 'devicelog', + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/listPage", data: { devcode: devcode, - url: app.globalData.url + "appDeviceLog/listPage", limit: 100, offset: 1 }, - }).then(res => { - if (res.result) { - var resultJson = res.result - that.setData({ - deviceloglist: resultJson.data.rows, - onshow:true - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var resultJson = res.data + that.setData({ + deviceloglist: resultJson.data.rows, + onshow: true + }) + } } - console.log(res); - }).catch(err => { - console.error(err); }) }, initPages: function () { var that = this; - that.setData({ - devcode: "" - }); wx.getLocation({ type: "gcj02", success: function (res) { @@ -302,6 +256,6 @@ }) } }) - this.searchlogs() + this.data.devcode !== '' ? this.searchlogs(this.data.devcode) : this.searchlogs() }, }) \ No newline at end of file diff --git a/miniprogram/pages/indexapp/indexapp.wxml b/miniprogram/pages/indexapp/indexapp.wxml index 69322a0..f65b082 100644 --- a/miniprogram/pages/indexapp/indexapp.wxml +++ b/miniprogram/pages/indexapp/indexapp.wxml @@ -1,8 +1,12 @@ + + + + - @@ -32,9 +36,15 @@ - + + + + + + + @@ -46,14 +56,14 @@ - + - - + diff --git a/miniprogram/pages/indexapp/indexapp.wxss b/miniprogram/pages/indexapp/indexapp.wxss index b18706a..fc27fcb 100644 --- a/miniprogram/pages/indexapp/indexapp.wxss +++ b/miniprogram/pages/indexapp/indexapp.wxss @@ -128,6 +128,7 @@ .noticeClass{ height: 2300rpx; width: 750rpx; + overflow-y:hidden; } @@ -148,14 +149,14 @@ } +/* .vanstyle{ + button: not([size='mini']) { + user agent stylesheetmin-height: 40px; + width: 650rpx; + margin-left: 20rpx; + margin-right: auto; + + } + +} */ -/* .van-enter-active-class, -.van-leave-active-class { - transition-property: background-color, transform; -} - -.van-enter-class, -.van-leave-to-class { - background-color: red; - transform: rotate(-360deg) translate3d(-100%, -100%, 0); -} */ \ No newline at end of file diff --git a/miniprogram/pages/log/log.js b/miniprogram/pages/log/log.js deleted file mode 100644 index 83ba349..0000000 --- a/miniprogram/pages/log/log.js +++ /dev/null @@ -1,66 +0,0 @@ -// pages/log/log.js -Page({ - - /** - * 页面的初始数据 - */ - data: { - - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - - }, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { - - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - - }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { - - }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { - - } -}) \ No newline at end of file diff --git a/miniprogram/pages/log/log.json b/miniprogram/pages/log/log.json deleted file mode 100644 index 8835af0..0000000 --- a/miniprogram/pages/log/log.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "usingComponents": {} -} \ No newline at end of file diff --git a/miniprogram/pages/log/log.wxml b/miniprogram/pages/log/log.wxml deleted file mode 100644 index a510ad6..0000000 --- a/miniprogram/pages/log/log.wxml +++ /dev/null @@ -1,2 +0,0 @@ - -pages/log/log.wxml diff --git a/miniprogram/pages/log/log.wxss b/miniprogram/pages/log/log.wxss deleted file mode 100644 index 23db318..0000000 --- a/miniprogram/pages/log/log.wxss +++ /dev/null @@ -1 +0,0 @@ -/* pages/log/log.wxss */ \ No newline at end of file diff --git a/miniprogram/pages/login/login.js b/miniprogram/pages/login/login.js index a4074e7..cb0542a 100644 --- a/miniprogram/pages/login/login.js +++ b/miniprogram/pages/login/login.js @@ -1,11 +1,14 @@ // miniprogram/pages/login/login.js +var app = getApp() Page({ /** * 页面的初始数据 */ data: { - windowWidth:"" + windowWidth: "", + time: 15 * 1000, + showTime: false }, /** @@ -20,9 +23,9 @@ */ onReady: function () { this.setData({ - windowWidth:wx.getSystemInfoSync().windowWidth + windowWidth: wx.getSystemInfoSync().windowWidth }) - + }, /** @@ -66,14 +69,158 @@ onShareAppMessage: function () { }, + + + showLoading: function (message) { + if (wx.showLoading) { + // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 + wx.showLoading({ + title: message, + mask: true + }); + } else { + // 低版本采用Toast兼容处理并将时间设为20秒以免自动消失 + wx.showToast({ + title: message, + icon: 'loading', + mask: true, + duration: 20000 + }); + } + }, + hideLoading: function () { + if (wx.hideLoading) { + // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 + wx.hideLoading(); + } else { + wx.hideToast(); + } + }, + + //注册 loginClick: function () { + var that = this + that.showLoading("授权中...") + wx.login({ + success: function (res) { + if (res.code) { + wx.request({ + url: app.globalData.httpsUrl + "appUserOpenid/login", + data: { + code: res.code + }, + success: function (res) { + app.globalData.openid = res.data.data + wx.getUserInfo({ + success: (res) => { + var nickname = res.userInfo.nickName; + app.globalData.nickName = nickname; + //openid绑定昵称存入后台 + wx.request({ + url: app.globalData.httpsUrl + "appUserOpenid/add", + data: { + attr: nickname, + openid: app.globalData.openid + }, + success: function (res) { + that.hideLoading(); + wx.showToast({ + title: res.data.data+",\r\n请从正式版入口登录!", + icon: 'none', + duration: 2000 + }) - wx.navigateTo({ - - url: '../farmermain/farmermain', - + // //授权成功后跳转 + // wx.switchTab({ + // url: '../indexapp/indexapp' + // }) + } + }) + }, + fail: function (err) { + that.hideLoading(); + } + }) + }, + fail: function (res) { + that.hideLoading(); + wx.showToast({ + title: '服务器异常', + }) + } + }) + } + }, + fail: function (res) { + that.hideLoading(); + } }) + }, + //登录验证 + loginValidate: function () { + var that = this + that.showLoading("登录中...") + wx.login({ + success: function (res) { + if (res.code) { + console.info(res); + wx.request({ + url: app.globalData.httpsUrl + "appUserOpenid/login", + data: { + code: res.code + }, + success: function (res) { + app.globalData.openid = res.data.data + wx.request({ + url: app.globalData.httpsUrl + "appUserOpenid/validate", + data: { + openid: app.globalData.openid + }, + success: function (res) { + that.hideLoading(); + if (res.data.data) { + app.globalData.userName = res.data.data.attr1 == '' ? res.data.data.attr : res.data.data.attr1 + app.globalData.nickName = res.data.data.attr + app.globalData.role = res.data.data.role + wx.navigateTo({ + url: '../notice/notice' + }) + } else { + wx.showToast({ + icon: 'none', + title: '请联系管理员授权', + duration: 2000 + }) + } + }, + fail: function (err) { + that.hideLoading(); + wx.showToast({ + title: '验证失败', + }) + } + }) + }, + fail: function (res) { + that.hideLoading(); + wx.showToast({ + title: '服务器异常', + }) + } + }) + } + }, + fail: function (res) { + that.hideLoading(); + } + }) + }, + + finished() { + this.setData({ + showTime: true + }) }, onClickSubmit: function () { diff --git a/miniprogram/pages/login/login.json b/miniprogram/pages/login/login.json index 8835af0..f2043a3 100644 --- a/miniprogram/pages/login/login.json +++ b/miniprogram/pages/login/login.json @@ -1,3 +1,8 @@ { - "usingComponents": {} + "usingComponents": { + "van-count-down": "../../miniprogram_npm/@vant/weapp/count-down", + "van-button": "../../miniprogram_npm/@vant/weapp/button" + }, + "navigationBarBackgroundColor": "#E6D480", + "disableScroll":true } \ No newline at end of file diff --git a/miniprogram/pages/login/login.wxml b/miniprogram/pages/login/login.wxml index c69df42..cf2ec72 100644 --- a/miniprogram/pages/login/login.wxml +++ b/miniprogram/pages/login/login.wxml @@ -1,21 +1,46 @@ + - + + + - + + + +    本程序为施工日志管理小程序,为航天二院智慧市 +政技术研究室内部系统,不对外开放。出于对数据信 +息安全的考虑,在您首次使用小程序时,请先对小程 +序进行授权,授权后的用户可以正常对小程序进行编 +辑,谢谢您的配合! + + + + + + + + 授权/登录 + + + - + + + diff --git a/miniprogram/pages/login/login.wxss b/miniprogram/pages/login/login.wxss index ca77568..b9fa569 100644 --- a/miniprogram/pages/login/login.wxss +++ b/miniprogram/pages/login/login.wxss @@ -54,7 +54,8 @@ } .form .submit { - margin-top: 80rpx; + + /* margin-top: 80rpx; */ color: #fff; border: 2rpx solid #FFB90F; background-color: #FFB90F; @@ -63,10 +64,30 @@ } .login_image { - width: 200rpx; - height: 200rpx; - padding-top: 100rpx; - padding-left: 250rpx; + width: 750rpx; + height: 360rpx; + /* height: 2300rpx; */ + /* padding-top: 100rpx + padding-left: 250rpx; */ +} +.bottom_image { + width: 750rpx; + height: 32%; + position: fixed; + bottom: 0px; + /* padding-top: 100rpx + padding-left: 250rpx; */ +} +.cover{ + position: fixed; + top: 0rpx; + margin-left: 290rpx; + text-align:center; + font-size: 50rpx; + color: #FFCF00; + width: 750rpx; + z-index:9999; + } -} \ No newline at end of file + \ No newline at end of file diff --git a/miniprogram/pages/notice/notice.js b/miniprogram/pages/notice/notice.js new file mode 100644 index 0000000..7aeafb9 --- /dev/null +++ b/miniprogram/pages/notice/notice.js @@ -0,0 +1,80 @@ +// miniprogram/pages/notice.js +Page({ + + /** + * 页面的初始数据 + */ + data: { + time: 15 * 1000, + showTime: false + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { + this.setData({ + showTime: true + }) + wx.switchTab({ + url: '../indexapp/indexapp' + }) + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + }, + finished() { + this.setData({ + showTime: true + }) + wx.switchTab({ + url: '../indexapp/indexapp' + }) + } +}) \ No newline at end of file diff --git a/miniprogram/pages/notice/notice.json b/miniprogram/pages/notice/notice.json new file mode 100644 index 0000000..4c73264 --- /dev/null +++ b/miniprogram/pages/notice/notice.json @@ -0,0 +1,5 @@ +{ + "usingComponents": { + "van-count-down": "../../miniprogram_npm/@vant/weapp/count-down" + } +} \ No newline at end of file diff --git a/miniprogram/pages/notice/notice.wxml b/miniprogram/pages/notice/notice.wxml new file mode 100644 index 0000000..975304a --- /dev/null +++ b/miniprogram/pages/notice/notice.wxml @@ -0,0 +1,10 @@ + + + + + + + + diff --git a/miniprogram/pages/notice/notice.wxss b/miniprogram/pages/notice/notice.wxss new file mode 100644 index 0000000..36d7542 --- /dev/null +++ b/miniprogram/pages/notice/notice.wxss @@ -0,0 +1,18 @@ +/* miniprogram/pages/notice.wxss */ + +.login_image { + width: 750rpx; + height: 2300rpx; + /* padding-top: 100rpx + padding-left: 250rpx; */ +} +.cover{ + position: fixed; + top: 0rpx; + margin-left: 290rpx; + text-align:center; + font-size: 50rpx; + color: #FFCF00; + width: 750rpx; + z-index:9999; + } \ No newline at end of file diff --git a/cloudfunctions/project.config.json b/cloudfunctions/project.config.json new file mode 100644 index 0000000..2b3119a --- /dev/null +++ b/cloudfunctions/project.config.json @@ -0,0 +1,28 @@ +{ + "appid": "wx2cef527a000f87c9", + "compileType": "miniprogram", + "libVersion": "2.27.3", + "packOptions": { + "ignore": [], + "include": [] + }, + "setting": { + "coverView": true, + "es6": true, + "postcss": true, + "minified": true, + "enhance": true, + "showShadowRootInWxmlPanel": true, + "packNpmRelationList": [], + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + } + }, + "condition": {}, + "editorSetting": { + "tabIndent": "insertSpaces", + "tabSize": 4 + } +} \ No newline at end of file diff --git a/cloudfunctions/project.private.config.json b/cloudfunctions/project.private.config.json new file mode 100644 index 0000000..42ff49d --- /dev/null +++ b/cloudfunctions/project.private.config.json @@ -0,0 +1,7 @@ +{ + "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", + "projectname": "cloudfunctions", + "setting": { + "compileHotReLoad": true + } +} \ No newline at end of file diff --git a/miniprogram/app.js b/miniprogram/app.js index 51d56f3..50a8a54 100644 --- a/miniprogram/app.js +++ b/miniprogram/app.js @@ -18,13 +18,15 @@ // this.globalData = {} }, globalData: { - // url: "http://111.198.10.15:11604/", - httpsUrl: "https://logapi.smartlog.work/", - httpsTestUrl: "https://smartlog.work/prodapi4test/", - url: "http://139.198.18.188:8083/", + httpsUrl: "https://logapi.smartlog.work/", + // httpsUrl: "http://139.198.18.188:8083/", // url: "http://127.0.0.1:8083/", - // httpsUrl: "http://127.0.0.1:8083/", + //httpsUrl: "http://127.0.0.1:8083/", openid: null, - indexCount:1 - }, + indexCount:1, + nickName:"", + userName:"", + role:"", + devcode:"" + } }) diff --git a/miniprogram/app.json b/miniprogram/app.json index d23f798..2b6db76 100644 --- a/miniprogram/app.json +++ b/miniprogram/app.json @@ -1,15 +1,17 @@ { "cloud": true, "pages": [ + "pages/login/login", "pages/indexapp/indexapp", "pages/earth/earth", "pages/applog/applog", "pages/addDevice/addDevice", "pages/addDevicelog/addDeviceLog", - "pages/searchLog/searchLog" + "pages/searchLog/searchLog", + "pages/notice/notice" ], "window": { - "backgroundColor": "#F6F6F6", + "backgroundColor": "#E6D480", "backgroundTextStyle": "light", "navigationBarBackgroundColor": "#FFCF00", "navigationBarTitleText": "智慧施工", @@ -46,11 +48,11 @@ "desc": "你的位置信息将用于小程序位置接口的效果展示" } }, + "requiredPrivateInfos": ["getLocation", "chooseLocation"], "networkTimeout": { "request": 30000, "connectSocket": 30000, "uploadFile": 30000, "downloadFile": 30000 - }, - "style": "v2" + } } \ No newline at end of file diff --git a/miniprogram/images/applocat.png b/miniprogram/images/applocat.png new file mode 100644 index 0000000..fe49f54 --- /dev/null +++ b/miniprogram/images/applocat.png Binary files differ diff --git a/miniprogram/images/back.png b/miniprogram/images/back.png new file mode 100644 index 0000000..32ac82d --- /dev/null +++ b/miniprogram/images/back.png Binary files differ diff --git a/miniprogram/images/bottom.png b/miniprogram/images/bottom.png new file mode 100644 index 0000000..d910e98 --- /dev/null +++ b/miniprogram/images/bottom.png Binary files differ diff --git a/miniprogram/images/header.png b/miniprogram/images/header.png new file mode 100644 index 0000000..6ea222e --- /dev/null +++ b/miniprogram/images/header.png Binary files differ diff --git a/miniprogram/images/login.png b/miniprogram/images/login.png index 8b73cc0..6471c46 100644 --- a/miniprogram/images/login.png +++ b/miniprogram/images/login.png Binary files differ diff --git a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss index 5a591fb..c9c35b5 100644 --- a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss +++ b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:100%;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:100%}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file +@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:650rpx;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:600rpx}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file diff --git a/miniprogram/pages/addDevice/addDevice.js b/miniprogram/pages/addDevice/addDevice.js index 2783674..78f00b7 100644 --- a/miniprogram/pages/addDevice/addDevice.js +++ b/miniprogram/pages/addDevice/addDevice.js @@ -1,5 +1,7 @@ // miniprogram/pages/addDevice/addDevice.js // import WxValidate from '../../utils/WxValidate.js' +var QQMapWX = require('../../libs/qqmap-wx-jssdk.js'); +var qqmapsdk; var app = getApp() Page({ @@ -11,32 +13,10 @@ canvasWidth: '', longitude: '', latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], + option1: [], personoption1: [], projectoption: [], + devtypeList:[], show: false, form: { devcode: "", @@ -59,7 +39,10 @@ project: "", area: "", street: "", - wellname: "" + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '', }, fileList: [] }, @@ -117,12 +100,14 @@ var that = this; //初始化表单内容为上次填写值 var cacheForms = wx.getStorageSync('cacheList') - if (cacheForms) { + cacheForms.photopath1='' + cacheForms.photopath2='' + cacheForms.photopath3='' + that.data.fileList=[] that.setData({ form: cacheForms, devcode: cacheForms.devcode, - }) } var form = that.data.form @@ -155,55 +140,89 @@ } }) + +//获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + that.setData({ + option1: welltypeArr + }) + } + } +}) + + //获取人员下拉列表 - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/getUser", + data:{ + tips:'repair' }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data.code == 200) { + var users = res.data.data + var personArr = []; + for (var i = 0; i < users.length; i++) { + var person = { + text: users[i].name, + value: users[i].name + }; + personArr.push(person); + } + that.setData({ + personoption1: personArr + }) } - that.setData({ - personoption1: personArr - }) } - }).catch(err => { - console.error(err); - }) + }) + - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - that.setData({ - projectoption: projectArr - }) + success(res){ + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); + } + that.setData({ + projectoption: projectArr + }) + } } - }).catch(err => { - console.error(err); - }) + }) + var installtime = 'form.installtimeFmt'; var dateNow = this.formatDate(); this.setData({ @@ -211,8 +230,40 @@ installtimeFmt: dateNow, [installtime]: dateNow, }); + + + + /** + * 获取设备类型下拉列表 + */ + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/deviceType", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var TypeList = res.data.data + var typeArr = []; + for (var i = 0; i < TypeList.length; i++) { + var type = { + text: TypeList[i].productName, + value: TypeList[i].productName + }; + typeArr.push(type); + } + that.setData({ + devtypeList: typeArr + }) + } + } + }) }, + + + /** * 生命周期函数--监听页面初次渲染完成 */ @@ -280,29 +331,7 @@ }, - - //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 - drawText: function (ctx, str, leftWidth, initHeight, titleHeight, canvasWidth) { - var lineWidth = 0; - var lastSubStrIndex = 0; //每次开始截取的字符串的索引 - for (let i = 0; i < str.length; i++) { - lineWidth += ctx.measureText(str[i]).width; - if (lineWidth > canvasWidth) { - ctx.fillText(str.substring(lastSubStrIndex, i), leftWidth, initHeight); //绘制截取部分 - initHeight = initHeight + leftWidth * 2; //22为字体的高度 - lineWidth = 0; - lastSubStrIndex = i; - // titleHeight += 40; - } - if (i == str.length - 1) { //绘制剩余部分 - ctx.fillText(str.substring(lastSubStrIndex, i + 1), leftWidth, initHeight); - } - } - // // 标题border-bottom 线距顶部距离 - // titleHeight = titleHeight + 10; - // return titleHeight - }, - + //验证表单 formValidate() { if (this.data.form.devcode == "") { @@ -312,27 +341,20 @@ }) return false } - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } if (this.data.form.wellcode == "") { wx.showToast({ icon: 'none', @@ -348,22 +370,10 @@ }) return false } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null) { + + if (this.data.form.installperson == "") { wx.showToast({ icon: 'none', title: '安装人员不能为空!', @@ -408,56 +418,90 @@ } return true; }, + //提交表单 formSubmit: function (event) { + console.log(this.data.form) + //表单参数验证 if (!this.formValidate()) { return false; } var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDevice', + //验证设备编号长度 + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/getDevTypeLength", data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceAdd/add" + code: encodeURI(this.data.form.devicetype) }, - }).then(res => { - if (res.result.code == 500) { - wx.showToast({ - title: '设备编号已安装!', - }) - } else if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - //用于回显 - wx.setStorageSync('cacheList', that.data.form) - //提交成功后提示用户操作 - if (res.confirm) { - wx.switchTab({ - url: '../earth/earth' - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (""==res.data.data ||res.data.data == that.data.form.devcode.length) { + that.saveDevice() + } else { //编号位数不对提示 + wx.showToast({ + icon: 'none', + title: '设备编号位数不对!', + duration: 1000 + }) + return false + } } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "提交失败", - }) }) }, + + //保存设备基本信息 + saveDevice() { + var that = this; + //设置照片路径 + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopathForm = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopathForm]: fileList[i].url.split("static/")[1] + }) + } + //表单提交 + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 500) { + wx.showToast({ + title: '设备编号已安装!', + }) + } else if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + //用于回显 + wx.setStorageSync('cacheList', that.data.form) + //提交成功后提示用户操作 + if (res.confirm) { + wx.switchTab({ + url: '../earth/earth' + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } + }, + fail(err) { + wx.showToast({ + title: '提交失败!', + }) + } + }) + }, + + //input 输入框设置值 confirm(event) { var that = this; var formValue = event.detail.value; @@ -466,8 +510,30 @@ that.setData({ [fromN]: formValue }) + //若输入是设备编号,自动获取设备类型 + if('devcode'==formName){ + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", + data: { + devcode: formValue, + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + that.setData({ + [formDevicetype]: res.data + }); + } + } + }) + } }, + //扫描设备获取编号和设备类型 scan() { var _this = this; wx.scanCode({ @@ -477,23 +543,28 @@ _this.setData({ [formdevcode]: devcode }); - wx.cloud.callFunction({ - name: 'findModeCode', + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", data: { devcode: devcode, - url: app.globalData.url + "appDeviceAdd/findModeCodeByCode" }, - }).then(res => { - if (res.result) { - var formDevicetype = 'form.devicetype' - _this.setData({ - [formDevicetype]: res.result - }); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + _this.setData({ + [formDevicetype]: res.data + }); + } } }) } }) }, + //粘贴经纬度 paste() { var _this = this; wx.getClipboardData({ @@ -510,9 +581,11 @@ longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), }); + _this.showAddress(_this.data.form.longitude,_this.data.form.latitude,_this) } }) }, + //设置经类型 selectValue(value) { var that = this; @@ -521,6 +594,16 @@ [wellType]: value.detail }) }, + + //设置设备类型 + selectDevType(event) { + var that = this; + var devtype = 'form.devicetype'; + that.setData({ + [devtype]: event.detail + }) + }, + //设置运维人员 selectpersonValue(event) { var that = this; var installPerson = 'form.installperson'; @@ -528,6 +611,7 @@ [installPerson]: event.detail }) }, + //设置项目 selectprojectValue(event) { var that = this; var project = 'form.project'; @@ -535,8 +619,41 @@ [project]: event.detail }) }, + showAddress :function(longitude, latitude, self) { + // 实例化腾讯地图API核心类 + qqmapsdk = new QQMapWX({ + key: 'BGPBZ-C5O3P-ROUDR-LWC4J-63EKH-V5FRX'//此处使用你自己申请的key + }) + // 腾讯地图调用接口 + qqmapsdk.reverseGeocoder({ + location: { + latitude: latitude, + longitude: longitude + }, + success: function (res) { + self.setData({ + 'form.area':res.result.address.slice(0,res.result.address.indexOf('区')+1), + 'form.street':res.result.address.slice(res.result.address.indexOf('区')+1) + }) + }, + fail: function (res) { + console.log(res); + }, + complete: function (res) { + } + }); + }, + //上传照片 afterRead(event) { var _this = this; + if (_this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '请先填写设备编号!\r\n否则水印中无编号', + duration: 2000 + }) + return false + } const { file } = event.detail; @@ -576,78 +693,8 @@ }) } }) - // 压缩图片 - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // //获取图片尺寸 - // wx.getImageInfo({ - // src: convertpath, - // success(res) { - // _this.setData({ - // canvasHeight: res.height, - // canvasWidth: res.width - // }) - // var ctx = wx.createCanvasContext('firstCanvas') - - // //将图片src放到cancas内,宽高为图片大小 - // ctx.drawImage(convertpath, 0, 0, res.width, res.height) - // //将声明的时间放入canvas - // ctx.setFontSize(30 * (res.width / 750)) //注意:设置文字大小必须放在填充文字之前,否则不生效 - // ctx.setFillStyle('blue') - // var text = "编号:" + _this.data.form.devcode + "\n经度:" + _this.data.form.longitude + "\n纬度:" + _this.data.form.latitude - // // _this.drawText(ctx,text,20, 70, 5, res.width) - // _this.drawText(ctx, text, 15 * (res.width / 750), 70 * (res.width / 750), 5, res.width) - - // // ctx.fillText(text, 0, 40) - // // ctx.strokeText(_this.data.form.devcode, 0, 30) - // //生成水印图 - // ctx.draw(false, function () { - // wx.canvasToTempFilePath({ - // canvasId: 'firstCanvas', - // success: (res) => { - // wx.compressImage({ - // src: res.tempFilePath, - // quality: 25, - // success: function (res) { - // //上传照片至服务器 - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: res.tempFilePath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // } - // }) - // //// - // } - // }) - // }) - // } - // }) - // } - // }); }, + //删除照片 deletePhoto(event) { var image_index = event.detail.index var fileList_new = this.data.fileList; diff --git a/miniprogram/pages/addDevice/addDevice.wxml b/miniprogram/pages/addDevice/addDevice.wxml index b0977e2..f12c254 100644 --- a/miniprogram/pages/addDevice/addDevice.wxml +++ b/miniprogram/pages/addDevice/addDevice.wxml @@ -5,18 +5,30 @@ - + + + + + + + + + + + + + - - + + - - - + + + @@ -29,13 +41,13 @@ - + - + - + - + @@ -54,8 +66,7 @@ - - + @@ -68,8 +79,8 @@ - - + + - 保存 + 保存 \ No newline at end of file diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.js b/miniprogram/pages/addDevicelog/addDeviceLog.js index cdec71b..a0dc6da 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.js +++ b/miniprogram/pages/addDevicelog/addDeviceLog.js @@ -3,681 +3,665 @@ var app = getApp(); Page({ - /** - * 页面的初始数据 - */ - data: { - pageName: '', - showMask: false, - today: new Date().getTime(), - longitude: '', - latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], - personoption1: [], - projectoption: [], - devcode: "", - deviceMode: "", - installtimeFmt: '', - show: false, - form: { - devcode: "", - wellcode: "", - welltype: "", - welldepth: "", - installheigt: "", - installperson: "", - installtimeFmt: "", - photopath: "", - factory: "", - workmsg: "", - position: "", - description: "", - longitude: "", - latitude: "", - longitude84: "", - latitude84: "", - devicetype: "", - project: "", - area: "", - street: "", - wellname: "" - }, - fileList: [], - detail: "" - }, + /** + * 页面的初始数据 + */ + data: { + pageName: '', + showMask: false, + today: new Date().getTime(), + longitude: '', + latitude: '', + option1: [], + personoption1: [], + projectoption: [], + devcode: "", + deviceMode: "", + installtimeFmt: '', + show: false, + form: { + devcode: "", + wellcode: "", + welltype: "", + welldepth: "", + installheigt: "", + installperson: "", + installtimeFmt: "", + photopath: "", + factory: "", + workmsg: "", + position: "", + description: "", + longitude: "", + latitude: "", + longitude84: "", + latitude84: "", + devicetype: "", + project: "", + area: "", + street: "", + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '' + }, + fileList: [], + detail: "", + markers: [{ + id: 100, + // iconPath: "../../images/point.png", + latitude: '', + longitude: '', + // label:'1', + width: 25, + height: 35 + }], + }, - onDisplay() { - this.setData({ - show: true - }); - }, - onClose() { - this.setData({ - show: false - }); - }, - formatDate() { - var date = new Date(); - // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; - var seperator1 = "-"; - var month = date.getMonth() + 1; - var strDate = date.getDate(); - var hour = date.getHours() - var minute = date.getMinutes() - var second = date.getSeconds() - month = month > 9 ? month : "0" + month; - strDate = strDate > 9 ? strDate : "0" + strDate; - hour = hour > 9 ? hour : "0" + hour; - minute = minute > 9 ? minute : "0" + minute; - second = second > 9 ? second : "0" + second; - var currentdate = - date.getFullYear() + - seperator1 + - month + - seperator1 + - strDate + - " " + - hour + ":" + - minute + ":" + - second; - return currentdate; + onDisplay() { + this.setData({ + show: true + }); + }, + onClose() { + this.setData({ + show: false + }); + }, + formatDate() { + var date = new Date(); + // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; + var seperator1 = "-"; + var month = date.getMonth() + 1; + var strDate = date.getDate(); + var hour = date.getHours() + var minute = date.getMinutes() + var second = date.getSeconds() + month = month > 9 ? month : "0" + month; + strDate = strDate > 9 ? strDate : "0" + strDate; + hour = hour > 9 ? hour : "0" + hour; + minute = minute > 9 ? minute : "0" + minute; + second = second > 9 ? second : "0" + second; + var currentdate = + date.getFullYear() + + seperator1 + + month + + seperator1 + + strDate + + " " + + hour + ":" + + minute + ":" + + second; + return currentdate; - }, - onConfirm(event) { - var installtime = 'form.installtimeFmt'; - this.setData({ - show: false, - installtimeFmt: this.formatDate(event.detail), - [installtime]: this.formatDate(event.detail), - }); - }, + }, + onConfirm(event) { + var installtime = 'form.installtimeFmt'; + this.setData({ + show: false, + installtimeFmt: this.formatDate(event.detail), + [installtime]: this.formatDate(event.detail), + }); + }, - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - var _this = this; - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" - }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); - } - _this.setData({ - personoption1: personArr - }) + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + var _this = this; + _this.setData({ + 'markers[0].latitude': Number(wx.getStorageSync('resultObject').latitude) , + 'markers[0].longitude': Number(wx.getStorageSync('resultObject').longitude), + // 'markers[0].label':'10', + 'markers[0].width': 18, + 'markers[0].id':1, + 'markers[0].height': 30, + latitude:Number(wx.getStorageSync('resultObject').latitude), + longitude:Number(wx.getStorageSync('resultObject').longitude) + }) + //获取人员下拉列表 + // wx.request({ + // method: "POST", + // url: app.globalData.httpsUrl + "deviceType/getUser", + // data:{ + // tips:'repair' + // }, + // header: { + // 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + // }, + // success(res) { + // if (res.data.code == 200) { + // var users = res.data.data + // var personArr = []; + // for (var i = 0; i < users.length; i++) { + // var person = { + // text: users[i].name, + // value: users[i].name + // }; + // personArr.push(person); + // } + // _this.setData({ + // personoption1: personArr + // }) + // } + // } + // }) + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); } - }).catch(err => { - console.error(err); - }) - - - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" - }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - _this.setData({ - projectoption: projectArr - }) - } - }).catch(err => { - console.error(err); - }) - - if (options.pageName) { - this.setData({ - pageName: options.pageName - }) - } - - if (options.detail) { - - var formObject = JSON.parse(options.detail); _this.setData({ - form: formObject, - detail: options.detail + projectoption: projectArr }) - - _this.setData({ - ['form.installperson']: "", - ['form.installtimeFmt']: "", - ['form.workmsg']: "", - ['form.description']: "" - }) - - const { - fileList = [] - } = _this.data; - if (formObject.photopath1 != "") { - var file1 = { - url: app.globalData.url + "static/" + formObject.photopath1 - } - fileList.push(file1) - } - if (formObject.photopath2 != "") { - var file2 = { - url: app.globalData.url + "static/" + formObject.photopath2 - } - fileList.push(file2) - } - if (formObject.photopath3 != "") { - var file3 = { - url: app.globalData.url + "static/" + formObject.photopath3 - } - fileList.push(file3) - } - - _this.setData({ - fileList - }); } - var installtime = 'form.installtimeFmt'; - var dateNow = this.formatDate(); - this.setData({ - installtimeFmt: dateNow, - [installtime]: dateNow, - }); - }, + } + }) - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { + //获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + _this.setData({ + option1: welltypeArr + }) + } + } +}) - }, + //跳转时带入参数返回哪页 + if (options.pageName) { + this.setData({ + pageName: options.pageName + }) + } + //跳转时带入参数设备的安装信息 + if (wx.getStorageSync('resultObject')) { + var formObject = wx.getStorageSync('resultObject') + _this.setData({ + form: formObject, + detail: formObject + }) - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { + _this.setData({ + ['form.installperson']: app.globalData.userName, + ['form.installtimeFmt']: "", + ['form.workmsg']: "", + ['form.description']: "" + }) - }, + const { + fileList = [] + } = _this.data; + if (formObject.photopath1 != "") { + var file1 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath1 + } + fileList.push(file1) + } + if (formObject.photopath2 != "") { + var file2 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath2 + } + fileList.push(file2) + } + if (formObject.photopath3 != "") { + var file3 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath3 + } + fileList.push(file3) + } + _this.setData({ + fileList + }); + } + var installtime = 'form.installtimeFmt'; + var dateNow = this.formatDate(); + this.setData({ + installtimeFmt: dateNow, + [installtime]: dateNow, + }); + }, - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, - }, + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + wx.removeStorageSync('resultObject') + }, - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, - }, + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { + }, - }, + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { + }, - }, + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { + }, - }, + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + }, - /** - * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true - **/ + /** + * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true + **/ - isNumber: function (val) { + isNumber: function (val) { - var regPos = /^[0-9]*$/; //非负浮点数 - var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数 - if (regPos.test(val) || regNeg.test(val)) { - return false; - } else { - return true; - } + var regPos = /^[0-9]*$/; //非负浮点数 + var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数 + if (regPos.test(val) || regNeg.test(val)) { + return false; + } else { + return true; + } - }, + }, - formValidate() { + formValidate() { - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } - if (this.data.form.wellcode == "") { - wx.showToast({ - icon: 'none', - title: '井编号不能为空!', - }) - return false - } - if (this.data.form.devicetype == "") { - wx.showToast({ - icon: 'none', - title: '设备类型不能为空!', - }) - return false - } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + if (this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '设备编号不能为空!', + }) + return false + } + if (this.data.form.wellcode == "") { + wx.showToast({ + icon: 'none', + title: '井编号不能为空!', + }) + return false + } + if (this.data.form.devicetype == "") { + wx.showToast({ + icon: 'none', + title: '设备类型不能为空!', + }) + return false + } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null || - this.data.form.installperson == '') { - wx.showToast({ - icon: 'none', - title: '运维人员不能为空!', - }) - return false - } - if (this.data.form.project == "") { - wx.showToast({ - icon: 'none', - title: '所属项目不能为空!', - }) - return false - } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } + if (this.data.form.installperson == null || + this.data.form.installperson == '') { + wx.showToast({ + icon: 'none', + title: '运维人员不能为空!', + }) + return false + } + if (this.data.form.project == "") { + wx.showToast({ + icon: 'none', + title: '所属项目不能为空!', + }) + return false + } - if (this.data.form.welldepth != null) { - if (this.isNumber(this.data.form.welldepth)) { - wx.showToast({ - icon: 'none', - title: '井深必须为数值!', - }) - return false - } - } - if (this.data.form.installheigt != null) { - if (this.isNumber(this.data.form.installheigt)) { - wx.showToast({ - icon: 'none', - title: '到井口距离必须为数值!', - }) - return false - } - } - - return true; - }, - - changeMsg: function () { - var formNew = this.data.form; - var formOld = JSON.parse(this.data.detail); - var descpNew = ""; - if (formNew.devcode != formOld.devcode) { - descpNew += "修改设备编号,原编号:" + formOld.devcode + ",新编号:" + formNew.devcode + ";" - } - if (formNew.devicetype != formOld.devicetype) { - descpNew += "修改设备类型,原设备类型:" + formOld.devicetype + ",新设备类型:" + formNew.devicetype + ";" - } - if (formNew.area != formOld.area) { - descpNew += "修改区,原区:" + formOld.area + ",新区:" + formNew.area + ";" - } - if (formNew.street != formOld.street) { - descpNew += "修改街道,原街道:" + formOld.street + ",新街道:" + formNew.street + ";" - } - if (formNew.wellname != formOld.wellname) { - descpNew += "修改井名称,原井名称:" + formOld.wellname + ",新井名称:" + formNew.wellname + ";" - } - if (formNew.factory != formOld.factory) { - descpNew += "修改权属单位,原权属单位:" + formOld.factory + ",新权属单位:" + formNew.factory + ";" - } - if (formNew.installheigt != formOld.installheigt) { - descpNew += "修改井口距离,原井口距离:" + formOld.installheigt + ",新井口距离:" + formNew.installheigt + ";" - } - if (formNew.installperson != formOld.installperson) { - descpNew += "修改运维人员,原运维人员:" + formOld.installperson + ",新运维人员:" + formNew.installperson + ";" - } - if (formNew.latitude != formOld.latitude) { - descpNew += "修改纬度,原纬度:" + formOld.latitude + ",新纬度:" + formNew.latitude + ";" - } - if (formNew.longitude != formOld.longitude) { - descpNew += "修改经度,原经度:" + formOld.longitude + ",新经度:" + formNew.longitude + ";" - } - if (formNew.position != formOld.position) { - descpNew += "修改位置描述,原位置:" + formOld.position + ",新位置:" + formNew.position + ";" - } - if (formNew.wellcode != formOld.wellcode) { - descpNew += "修改井编号,原编号:" + formOld.wellcode + ",新编号:" + formNew.wellcode + ";" - } - if (formNew.welldepth != formOld.welldepth) { - descpNew += "修改井深,原井深:" + formOld.welldepth + ",新井深:" + formNew.welldepth + ";" - } - if (formNew.welltype != formOld.welltype) { - descpNew += "修改井类型,原井类型:" + formOld.welltype + ",新井类型:" + formNew.welltype + ";" - } - if (formNew.project != formOld.project) { - descpNew += "修改所属项目,原项目:" + formOld.project + ",新项目:" + formNew.project + ";" - } - if (this.data.photopath1 != formOld.photopath1 || - this.data.photopath2 != formOld.photopath2 || - this.data.photopath3 != formOld.photopath3) { - descpNew += "修改照片;" - } - if ("" != formNew.description) { - descpNew += formNew.description; - } - this.setData({ - ['form.description']: descpNew + if (this.data.form.welldepth != null) { + if (this.isNumber(this.data.form.welldepth)) { + wx.showToast({ + icon: 'none', + title: '井深必须为数值!', }) - }, + return false + } + } + if (this.data.form.installheigt != null) { + if (this.isNumber(this.data.form.installheigt)) { + wx.showToast({ + icon: 'none', + title: '到井口距离必须为数值!', + }) + return false + } + } - formSubmit: function (event) { + return true; + }, - if (!this.formValidate()) { - return false; - } - this.changeMsg(); - var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDeviceLog', - data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceLog/add" - }, - }).then(res => { - // var resultObj=JSON.parse(res.result); - if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - if (res.confirm) { - wx.switchTab({ - url: that.data.pageName - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) - } - }).catch(err => { - console.error(err) - wx.showToast({ - title: "提交失败", - }) - }) - }, - confirm(event) { - var that = this; - var formValue = event.detail.value; - var formName = event.target.dataset.id; - var fromN = 'form.' + [formName]; - that.setData({ - [fromN]: formValue - }) - }, + //获取与上次修改的信息 + changeMsg: function () { + var formNew = this.data.form; + console.log(this.data.detail) + var formOld = JSON.parse(this.data.detail); + var descpNew = ""; + if (formNew.devcode != formOld.devcode) { + descpNew += "修改设备编号,原值:" + formOld.devcode + ",新值:" + formNew.devcode + ";" + } + if (formNew.devicetype != formOld.devicetype) { + descpNew += "修改设备类型,原值:" + formOld.devicetype + ",新值:" + formNew.devicetype + ";" + } + if (formNew.area != formOld.area) { + descpNew += "修改区,原值:" + formOld.area + ",新值:" + formNew.area + ";" + } + if (formNew.street != formOld.street) { + descpNew += "修改街道,原值:" + formOld.street + ",新值:" + formNew.street + ";" + } + if (formNew.wellname != formOld.wellname) { + descpNew += "修改井名称,原值:" + formOld.wellname + ",新值:" + formNew.wellname + ";" + } + if (formNew.factory != formOld.factory) { + descpNew += "修改权属单位,原值:" + formOld.factory + ",新值:" + formNew.factory + ";" + } + if (formNew.installheigt != formOld.installheigt) { + descpNew += "修改井口距离,原值:" + formOld.installheigt + ",新值:" + formNew.installheigt + ";" + } + if (formNew.installperson != formOld.installperson) { + descpNew += "修改运维人员,原值:" + formOld.installperson + ",新值:" + formNew.installperson + ";" + } + if (formNew.latitude != formOld.latitude) { + descpNew += "修改纬度,原值:" + formOld.latitude + ",新值:" + formNew.latitude + ";" + } + if (formNew.longitude != formOld.longitude) { + descpNew += "修改经度,原值:" + formOld.longitude + ",新值:" + formNew.longitude + ";" + } + if (formNew.position != formOld.position) { + descpNew += "修改位置描述,原值:" + formOld.position + ",新值:" + formNew.position + ";" + } + if (formNew.wellcode != formOld.wellcode) { + descpNew += "修改井编号,原值:" + formOld.wellcode + ",新值:" + formNew.wellcode + ";" + } + if (formNew.welldepth != formOld.welldepth) { + descpNew += "修改井深,原值:" + formOld.welldepth + ",新值:" + formNew.welldepth + ";" + } + if (formNew.welltype != formOld.welltype) { + descpNew += "修改井类型,原值:" + formOld.welltype + ",新值:" + formNew.welltype + ";" + } + if (formNew.project != formOld.project) { + descpNew += "修改所属项目,原值:" + formOld.project + ",新值:" + formNew.project + ";" + } + if (this.data.form.photopath1 != formOld.photopath1 || + this.data.form.photopath2 != formOld.photopath2 || + this.data.form.photopath3 != formOld.photopath3) { + descpNew += "修改照片;" + } + if ("" != formNew.description) { + descpNew += formNew.description; + } + this.setData({ + ['form.description']: descpNew + }) + }, - scan() { + //提交表单 + formSubmit: function (event) { - wx.scanCode({ - success(res) { - console.log(res) - } - }) + //表单验证 + if (!this.formValidate()) { + return false; + } + //自动生成修改内容 + this.changeMsg(); + //提交权限限制(只有施工人员能修改) + if(app.globalData.role!='repair'){ + wx.showToast({ + icon: 'none', + title: '无权限修改', + duration:2000 + }) + return false + } + var that = this; + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopath = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopath]: fileList[i].url.split("static/")[1] + }) + } + delete that.data.form.installtime + delete that.data.form.createtime + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - paste() { - var _this = this; - wx.getClipboardData({ - success: function (res) { - var longitude = 'form.longitude'; - var latitude = 'form.latitude'; - var longitude84 = 'form.longitude84'; - var latitude84 = 'form.latitude84'; - _this.setData({ - [longitude]: parseFloat(res.data.split(",", 4)[1]).toFixed(6), - [latitude]: parseFloat(res.data.split(",", 4)[0]).toFixed(6), - [longitude84]: "" == (res.data.split(",", 4)[3]) ? "" : parseFloat(res.data.split(",", 4)[3]).toFixed(6), - [latitude84]: "" == (res.data.split(",", 4)[2]) ? "" : parseFloat(res.data.split(",", 4)[2]).toFixed(6), - longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), - latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), - }); - } - }) - }, - selectValue(value) { - var that = this; - var wellType = 'form.welltype'; - that.setData({ - [wellType]: value.detail - }) - }, - selectpersonValue(event) { - var that = this; - var installPerson = 'form.installperson'; - that.setData({ - [installPerson]: event.detail - }) - }, - selectprojectValue(event) { - var that = this; - var project = 'form.project'; - that.setData({ - [project]: event.detail, - showMask: true - }) - }, - open() { - this.setData({ - showMask: true - }) - }, - close() { - this.setData({ - showMask: false - }) - }, - afterRead(event) { - var _this = this; - const { - file - } = event.detail; - const { - fileList = [] - } = _this.data; - var convertpath = ""; - wx.compressImage({ - src: event.detail.file.path, - quality: 25, - success: function (res) { - convertpath = res.tempFilePath; - wx.uploadFile({ - url: app.globalData.httpsUrl + "appDeviceAdd/fileUploadMarker", - filePath:convertpath, - name: 'file', - formData: { - 'text': "编号:" + _this.data.form.devcode + "经度:" + _this.data.form.longitude + "纬度:" + _this.data.form.latitude - }, - header: { - "Content-Type": "multipart/form-data", - 'accept': 'application/json', - }, - success(res) { - if (res.data) { - var url = JSON.parse(res.data); - fileList.push({ - ...file, - url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - }); - _this.setData({ - fileList - }); - } - } + success(res) { + if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + if (res.confirm) { + wx.switchTab({ + url: that.data.pageName }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') } - }) - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // // var base64 = "data:image/png;base64," + wx.getFileSystemManager().readFileSync(convertpath, 'base64'); - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: convertpath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // // wx.cloud.callFunction({ - // // name: 'uploadFile', - // // data: { - // // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // // fileBase64: base64 - // // }, - // // success: function (res) { - // // if (res.result) { - // // fileList.push({ - // // ...file, - // // url: app.globalData.url + "static/" + res.result.data.replace(/\\/g, "/") - // // }); - // // _this.setData({ - // // fileList - // // }); - // // } - // // }, - // // complete: res => { - // // }, - // // }) - // } - // }); + } + }) + } + }, + fail(err) { + wx.showToast({ + title: "提交失败", + }) + } + }) + }, + //报存录入的input信息 + confirm(event) { + var that = this; + var formValue = event.detail.value; + var formName = event.target.dataset.id; + var fromN = 'form.' + [formName]; + that.setData({ + [fromN]: formValue + }) + }, + + //扫码 + scan() { + + wx.scanCode({ + success(res) { + console.log(res) + } + }) + }, + //粘贴经纬度 + paste() { + var _this = this; + wx.getClipboardData({ + success: function (res) { + var longitude = 'form.longitude'; + var latitude = 'form.latitude'; + var longitude84 = 'form.longitude84'; + var latitude84 = 'form.latitude84'; + _this.setData({ + [longitude]: parseFloat(res.data.split(",", 4)[1]).toFixed(6), + [latitude]: parseFloat(res.data.split(",", 4)[0]).toFixed(6), + [longitude84]: "" == (res.data.split(",", 4)[3]) ? "" : parseFloat(res.data.split(",", 4)[3]).toFixed(6), + [latitude84]: "" == (res.data.split(",", 4)[2]) ? "" : parseFloat(res.data.split(",", 4)[2]).toFixed(6), + longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), + latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), + }); + } + }) + }, + selectValue(value) { + var that = this; + var wellType = 'form.welltype'; + that.setData({ + [wellType]: value.detail + }) + }, + //运维人员默认为登录人 + // selectpersonValue(event) { + // var that = this; + // var installPerson = 'form.installperson'; + // that.setData({ + // [installPerson]: event.detail + // }) + // }, + selectprojectValue(event) { + var that = this; + var project = 'form.project'; + that.setData({ + [project]: event.detail, + showMask: true + }) + }, + + open() { + this.setData({ + showMask: true + }) + }, + //隐藏textarea,防止遮挡 + close() { + this.setData({ + showMask: false + }) + }, + //上传照片 + afterRead(event) { + var _this = this; + const { + file + } = event.detail; + const { + fileList = [] + } = _this.data; + var convertpath = ""; + wx.compressImage({ + src: event.detail.file.path, + quality: 25, + success: function (res) { + convertpath = res.tempFilePath; + wx.uploadFile({ + url: app.globalData.httpsUrl + "appDeviceAdd/fileUploadMarker", + filePath: convertpath, + name: 'file', + formData: { + 'text': "编号:" + _this.data.form.devcode + "经度:" + _this.data.form.longitude + "纬度:" + _this.data.form.latitude }, - deletePhoto(event) { - var that = this - var image_index = event.detail.index - var fileList_new = that.data.fileList; - wx.showModal({ - content: '确定删除照片?', - success: function (res) { - if (res.confirm) { - fileList_new.splice(image_index, 1); - that.setData({ - fileList: fileList_new - }) - wx.cloud.callFunction({ - name: 'deletePhoto', - data: { - url: app.globalData.url + "appDeviceLog/deletePhoto", - devcode: that.data.form.devcode, - pathIndex: image_index - }, - success: function (res) {}, - complete: res => {}, - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + "Content-Type": "multipart/form-data", + 'accept': 'application/json', }, - }) \ No newline at end of file + success(res) { + if (res.data) { + var url = JSON.parse(res.data); + fileList.push({ + ...file, + url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") + }); + _this.setData({ + fileList + }); + } + } + }) + } + }) + }, + //删除照片 + deletePhoto(event) { + var that = this + var image_index = event.detail.index + var fileList_new = that.data.fileList; + wx.showModal({ + content: '确定删除照片?', + success: function (res) { + if (res.confirm) { + fileList_new.splice(image_index, 1); + that.setData({ + fileList: fileList_new + }) + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deletePhoto", + data: { + devcode: that.data.form.devcode + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) {} + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } +}) \ No newline at end of file diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.wxml b/miniprogram/pages/addDevicelog/addDeviceLog.wxml index 38620d4..b10cc7d 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.wxml +++ b/miniprogram/pages/addDevicelog/addDeviceLog.wxml @@ -1,15 +1,21 @@ - + + + + + - + - - + + - - + + - + @@ -39,24 +45,25 @@ - - - + + + - + - + + @@ -64,7 +71,7 @@ - + @@ -79,9 +86,9 @@ - + - 保存 + 保存 diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.wxss b/miniprogram/pages/addDevicelog/addDeviceLog.wxss index ee0b75c..08d5fd7 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.wxss +++ b/miniprogram/pages/addDevicelog/addDeviceLog.wxss @@ -24,6 +24,17 @@ display: flex; align-items: center; } +.map-view{ + width: 750rpx; + height: 485rpx; + position: fixed; + top: 0px; + left: 0px; + z-index: 999; +} +.content{ + margin-top: 495rpx; +} .left { width: 210rpx; diff --git a/miniprogram/pages/addFunction/addFunction.js b/miniprogram/pages/addFunction/addFunction.js deleted file mode 100644 index 4966be3..0000000 --- a/miniprogram/pages/addFunction/addFunction.js +++ /dev/null @@ -1,60 +0,0 @@ -// pages/addFunction/addFunction.js - -const code = `// 云函数入口函数 -exports.main = (event, context) => { - console.log(event) - console.log(context) - return { - sum: event.a + event.b - } -}` - -Page({ - - data: { - result: '', - canIUseClipboard: wx.canIUse('setClipboardData'), - }, - - onLoad: function (options) { - - }, - - copyCode: function() { - wx.setClipboardData({ - data: code, - success: function () { - wx.showToast({ - title: '复制成功', - }) - } - }) - }, - - testFunction() { - wx.cloud.callFunction({ - name: 'sum', - data: { - a: 1, - b: 2 - }, - success: res => { - wx.showToast({ - title: '调用成功', - }) - this.setData({ - result: JSON.stringify(res.result) - }) - }, - fail: err => { - wx.showToast({ - icon: 'none', - title: '调用失败', - }) - console.error('[云函数] [sum] 调用失败:', err) - } - }) - }, - -}) - diff --git a/miniprogram/pages/addFunction/addFunction.json b/miniprogram/pages/addFunction/addFunction.json deleted file mode 100644 index a9a50c5..0000000 --- a/miniprogram/pages/addFunction/addFunction.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "navigationBarTitleText": "云函数指引", - "usingComponents": {} -} \ No newline at end of file diff --git a/miniprogram/pages/addFunction/addFunction.wxml b/miniprogram/pages/addFunction/addFunction.wxml deleted file mode 100644 index 3a10626..0000000 --- a/miniprogram/pages/addFunction/addFunction.wxml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - 测试云函数 - - - 期望输出:{"sum":3} - - - 调用结果:{{result}} - - - - - 新增云函数 - 1. 在云函数根目录 cloudfunctions 上右键选择新建云函数,命名为 sum - 2. 在创建的 cloudfunctions/sum/index.js 文件中添加如下代码 - - - 3. 在 cloudfunctions/sum 目录上右键上传并部署 - 4. 点击测试云函数测试 - 5. 打开云开发云函数管理页,选择 sum 云函数 - 6. 查看 sum 的调用日志 - 进阶:可在云函数中使用 wx-server-sdk 操作数据库,文件存储和调用其他云函数,详见文档 - - - diff --git a/miniprogram/pages/addFunction/addFunction.wxss b/miniprogram/pages/addFunction/addFunction.wxss deleted file mode 100644 index 7ac8619..0000000 --- a/miniprogram/pages/addFunction/addFunction.wxss +++ /dev/null @@ -1,3 +0,0 @@ -/* pages/addFunction/addFunction.wxss */ - -@import "../../style/guide.wxss"; \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.js b/miniprogram/pages/applog/applog.js index 0e8c185..189e61f 100644 --- a/miniprogram/pages/applog/applog.js +++ b/miniprogram/pages/applog/applog.js @@ -13,98 +13,25 @@ isSeach: "false", params: {}, total: 0, - show: false + show: false, + delBtnWidth: 100, //删除按钮宽度单位(rpx) + activeIndex: -1, + list_style: '' }, - - touchE: function (e) { - // console.log(e); - var that = this - if (e.changedTouches.length == 1) { - //手指移动结束后触摸点位置的X坐标 - var endX = e.changedTouches[0].clientX; - //触摸开始与结束,手指移动的距离 - var disX = that.data.startX - endX; - var delBtnWidth = that.data.delBtnWidth; - //如果距离小于删除按钮的1/2,不显示删除按钮 - var txtStyle = disX > delBtnWidth / 2 ? "left:-" + delBtnWidth + "rpx" : "left:0rpx"; - - //获取手指触摸的是哪一项 - var index = e.currentTarget.dataset.index; - var list = that.data.deviceloglist; - list[index].txtStyle = txtStyle; - //更新列表的状态 - that.setData({ - deviceloglist: list - }); - } - }, - //手指触摸动作开始 记录起点X坐标 - touchstart: function (e) { - //开始触摸时 重置所有删除 - this.data.deviceloglist.forEach(function (v, i) { - if (v.isTouchMove) //只操作为true的 - v.isTouchMove = false; - }) - this.setData({ - startX: e.changedTouches[0].clientX, - startY: e.changedTouches[0].clientY, - deviceloglist: this.data.deviceloglist - }) - }, - //滑动事件处理 - touchmove: function (e) { - var that = this, - index = e.currentTarget.dataset.index, //当前索引 - startX = that.data.startX, //开始X坐标 - startY = that.data.startY, //开始Y坐标 - touchMoveX = e.changedTouches[0].clientX, //滑动变化坐标 - touchMoveY = e.changedTouches[0].clientY, //滑动变化坐标 - //获取滑动角度 - angle = that.angle({ - X: startX, - Y: startY - }, { - X: touchMoveX, - Y: touchMoveY - }); - that.data.deviceloglist.forEach(function (v, i) { - v.isTouchMove = false - //滑动超过30度角 return - if (Math.abs(angle) > 30) return; - if (i == index) { - if (touchMoveX > startX) //右滑 - v.isTouchMove = false - else //左滑 - v.isTouchMove = true - } - }) - //更新数据 - that.setData({ - deviceloglist: that.data.deviceloglist - }) - }, - /** - * 计算滑动角度 - * @param {Object} start 起点坐标 - * @param {Object} end 终点坐标 - */ - angle: function (start, end) { - var _X = end.X - start.X, - _Y = end.Y - start.Y - //返回角度 /Math.atan()返回数字的反正切值 - return 360 * Math.atan(_Y / _X) / (2 * Math.PI); - }, - /** - * 生命周期函数--监听页面加载var_this=this; - */ onLoad: function (options) { - if (options.params) { this.setData({ params: JSON.parse(options.params), isSeach: "true" }) this.initPages() + }else{ + this.setData({ + show: false + }) + //清空参数,重新加载 + this.clearParams(); + this.initPages(); } }, @@ -116,20 +43,33 @@ }, + //点击tabBar事件 + onTabItemTap(item) { + //隐藏历史显示总记录条数 + this.setData({ + show: false + }) + //清空参数,重新加载 + this.clearParams(); + this.initPages(); + }, + + /** * 生命周期函数--监听页面显示 */ onShow: function (options) { - this.setData({ - show:false - }) - if (this.data.isSeach == "false") { - this.clearParams(); - this.initPages(); - } - this.setData({ - isSeach: "false" - }) + + // this.setData({ + // show: false + // }) + // if (this.data.isSeach == "false") { + // this.clearParams(); + // this.initPages(); + // } + // this.setData({ + // isSeach: "false" + // }) }, /** @@ -167,6 +107,119 @@ }, + + //手指触摸动作开始 记录起点X坐标 + touchstart: function (e) { + //开始触摸时 重置所有删除 + this.data.deviceloglist.forEach(function (v, i) { + if (v.isTouchMove) //只操作为true的 + v.isTouchMove = false; + }) + this.setData({ + startX: e.changedTouches[0].clientX, + startY: e.changedTouches[0].clientY, + deviceloglist: this.data.deviceloglist + }) + }, + + //滑动事件处理 + touchmove: function (e) { + var that = this, + index = e.currentTarget.dataset.index, //当前索引 + startX = that.data.startX, //开始X坐标 + startY = that.data.startY, //开始Y坐标 + touchMoveX = e.changedTouches[0].clientX, //滑动变化坐标 + touchMoveY = e.changedTouches[0].clientY, //滑动变化坐标 + //获取滑动角度 + angle = that.angle({ + X: startX, + Y: startY + }, { + X: touchMoveX, + Y: touchMoveY + }); + that.data.deviceloglist.forEach(function (v, i) { + // v.isTouchMove = false + //滑动超过30度角 return + if (Math.abs(angle) > 30) return; + if (i == index) { + if (touchMoveX > startX) //右滑 + v.isTouchMove = false + else //左滑 + v.isTouchMove = true + } + }) + //更新数据 + that.setData({ + deviceloglist: that.data.deviceloglist + }) + }, + + /** + * 计算滑动角度 + * @param {Object} start 起点坐标 + * @param {Object} end 终点坐标 + */ + angle: function (start, end) { + var _X = end.X - start.X, + _Y = end.Y - start.Y + //返回角度 /Math.atan()返回数字的反正切值 + return 360 * Math.atan(_Y / _X) / (2 * Math.PI); + }, + + //删除事件 + delItem: function (e) { + if(app.globalData.role!='repair'){ + wx.showToast({ + icon: 'none', + title: '无权限删除', + duration:2000 + }) + return false + } + var that = this + wx.showModal({ + content: '是否删除?', + success: function (res) { + if (res.confirm) { + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/delete", + data: { + appDeviceAddId: e.currentTarget.dataset.devid + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if(res.data.code=='200'){ + that.data.deviceloglist.splice(e.currentTarget.dataset.index, 1) + that.setData({ + deviceloglist: that.data.deviceloglist, + total: that.data.deviceloglist.length + }) + wx.showToast({ + title: '删除成功!', + icon: 'none', + duration: 1000 + }) + } + }, + fail(err) { + wx.showToast({ + title: '删除失败!', + icon: 'none', + duration: 2000 + }) + } + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + }, + showLoading: function (message) { if (wx.showLoading) { // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 @@ -199,95 +252,105 @@ deviceloglist: [] }) }, + //查询列表数据 initPages: function () { var that = this + that.setData({ + show: false + }) var offsetValue = that.data.deviceloglist.length % 15 > 0 ? parseInt(that.data.deviceloglist.length / 15) + 2 : parseInt(that.data.deviceloglist.length / 15) + 1 - wx.cloud.callFunction({ - name: 'devicelog', + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/listPage", data: { devcode: that.data.params.devcode, devtype: that.data.params.devtype, installtimeFmt: that.data.params.installtimeFmt, project: that.data.params.project, installPerson: that.data.params.installPerson, - url: app.globalData.url + "appDeviceLog/listPage", limit: 15, offset: offsetValue }, - }).then(res => { - if (res.result.data.rows.length > 0) { - var resultJson = res.result - that.setData({ - deviceloglist: that.data.deviceloglist.concat(resultJson.data.rows) - }) - } else if (that.data.deviceloglist.length > 0) { - that.setData({ - show: true, - total: that.data.deviceloglist.length - }) - wx.showToast({ - title: '数据已全部加载完', - icon: 'none', - duration: 2000 - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.data.rows.length > 0) { + var resultJson = res.data + var listArr = resultJson.data.rows + listArr.forEach(function (v, i) { + listArr[i]['isTouchMove'] = false + }) + that.setData({ + deviceloglist: that.data.deviceloglist.concat(listArr) + }) + } else if (that.data.deviceloglist.length > 0) { + that.setData({ + show: true, + total: that.data.deviceloglist.length + }) + wx.showToast({ + title: '数据已全部加载完', + icon: 'none', + duration: 2000 + }) + } + if (offsetValue == 1 && res.data.data.rows.length < 15) { + that.setData({ + show: true, + total: that.data.deviceloglist.length + }) + } } - if(offsetValue==1&&res.result.data.rows.length<15){ - that.setData({ - show: true, - total: that.data.deviceloglist.length - }) - } - // console.log(res); - }).catch(err => { - console.error(err); }) + }, addDetail: function (event) { - this.showLoading("数据请求中..."); - wx.cloud.callFunction({ - name: 'deviceDetail', + var that = this + that.showLoading("数据请求中..."); + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deviceDetail", data: { devcode: event.target.dataset.devcode, - url: app.globalData.url + "appDeviceLog/deviceDetail", }, - }).then(res => { - this.hideLoading(); - var resultObject = JSON.parse(res.result); - var pageName = '../applog/applog' - if (resultObject.code == 200) { - wx.navigateTo({ - url: '../addDevicelog/addDeviceLog?detail=' + - JSON.stringify(resultObject.data) + "&pageName=" + pageName - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + that.hideLoading(); + // var resultObject = JSON.parse(res.data); + var resultObject = res.data; + var pageName = '../applog/applog' + if (resultObject.code == 200) { + wx.setStorageSync('resultObject', resultObject.data) + wx.navigateTo({ + url: '../addDevicelog/addDeviceLog?detail=' + "&pageName=" + pageName + }) + } + }, + fail(err) { + that.hideLoading(); } - }).catch(err => { - this.hideLoading() }) + }, add: function (event) { - wx.reLaunch({ - url: '../earth/earth?devcode=' + event.target.dataset.devcode - // url: '../earth/earth' + app.globalData.devcode = event.target.dataset.devcode; + wx.switchTab({ + url: '../earth/earth' }) + // wx.reLaunch({ + // url: '../earth/earth?devcode=' + event.target.dataset.devcode + // // url: '../earth/earth' + // }) }, onSearch: function () { + var _this = this wx.navigateTo({ - url: '../searchLog/searchLog' + url: '../searchLog/searchLog?params=' + JSON.stringify(_this.data.params) }) - }, - // initPages: function () { - // wx.cloud.callFunction({ - // name: 'devicelog' - // }).then(res => { - // var that = this; - // var jsonList = JSON.parse(res.result) - // that.setData({ - // deviceloglist: jsonList.data.rows - // }) - // console.log(res); - // }).catch(err => { - // console.error(err); - // }) - // } + } }) \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.wxml b/miniprogram/pages/applog/applog.wxml index e9a2352..2bfd041 100644 --- a/miniprogram/pages/applog/applog.wxml +++ b/miniprogram/pages/applog/applog.wxml @@ -1,54 +1,59 @@ - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {{item.devcode}} {{item.devicetype}} + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + {{item.devcode}} {{item.devicetype}} + + {{item.project}} {{item.installtime}}- {{item.installperson}} - - - - - + + + + + + 删除 - - - + + - 共计:{{total}}台 - + 共计:{{total}}台 + \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.wxss b/miniprogram/pages/applog/applog.wxss index 6d3428b..e6e8983 100644 --- a/miniprogram/pages/applog/applog.wxss +++ b/miniprogram/pages/applog/applog.wxss @@ -22,16 +22,18 @@ position: fixed; width: 100%; top: 0rpx; + z-index: 9999; /* margin-bottom: 100rpx; */ } .log-list { /* height: 100rpx; */ - /* display: flex; */ - + display: flex; + width: 100%; padding: 2px; margin-top: 2px; border-bottom: 1px solid #e5e5e5; + overflow: hidden } @@ -53,23 +55,29 @@ left: 35%; margin: 20rpx } - .del { - width: 90px; + /* display: flex; */ + width: 100rpx; display: flex; flex-direction: column; align-items: center; justify-content: center; - color: #fff; - -webkit-transform: translateX(90px); - transform: translateX(90px); - -webkit-transition: all 0.4s; + /* -webkit-transform: translateX(100rpx); */ + transform: translateX(100rpx); + /* -webkit-transition: all 0.4s; */ transition: all 0.4s; - font-size: 35rpx; + color: #fff; + background-color: #fe3e2f; +} +.logrow{ + width: 100%; + transform: translateX(100rpx); + /* -webkit-transform: translateX(100px); */ + margin-left: -100rpx; } -.touch-move-active .content, +.touch-move-active .logrow, .touch-move-active .del { - -webkit-transform: translateX(0); - transform: translateX(0); +/* -webkit-transform: translateX(0); */ +transform: translateX(0); } \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.js b/miniprogram/pages/deployFunctions/deployFunctions.js deleted file mode 100644 index a76b144..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.js +++ /dev/null @@ -1,66 +0,0 @@ -// pages/deployFunctions/deployFunctions.js -Page({ - - /** - * 页面的初始数据 - */ - data: { - - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - - }, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { - - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - - }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { - - }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { - - } -}) \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.json b/miniprogram/pages/deployFunctions/deployFunctions.json deleted file mode 100644 index 7fbedab..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "navigationBarTitleText": "部署云函数", - "usingComponents": {} -} \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.wxml b/miniprogram/pages/deployFunctions/deployFunctions.wxml deleted file mode 100644 index 462b6b6..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.wxml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - 调用失败 - - - 请检查 login 云函数是否已部署 - - - - - 部署 login 云函数 - 1. 确保已通过工具栏云开发入口开通云开发 - 2. 在 cloudfunctions/login 目录上右键上传并部署 - 3. 回到首页,重新点击获取 openid - - - - diff --git a/miniprogram/pages/deployFunctions/deployFunctions.wxss b/miniprogram/pages/deployFunctions/deployFunctions.wxss deleted file mode 100644 index c8803e6..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.wxss +++ /dev/null @@ -1,7 +0,0 @@ -/* pages/deployFunctions/deployFunctions.wxss */ - -@import "../../style/guide.wxss"; - -.black { - color: black; -} \ No newline at end of file diff --git a/miniprogram/pages/earth/earth.js b/miniprogram/pages/earth/earth.js index ae0d3f3..376a6e2 100644 --- a/miniprogram/pages/earth/earth.js +++ b/miniprogram/pages/earth/earth.js @@ -21,19 +21,12 @@ show: false, enableSsatellite: false, windowWidth: 0, - longitude: 113.324520, - latitude: 23.099994, - longitude84: 113.324520, - latitude84: 23.099994, - markers: [{ - id: 0, - iconPath: "../../images/locat.png", - latitude: 23.099994, - longitude: 113.324520, - width: 50, - height: 50 - }], - controls: [], + longitude: "116.627340", + latitude: "39.874390", + longitude84: "", + latitude84: "", + markers: [], + controls: [] }, /** @@ -41,39 +34,13 @@ */ onLoad: function (options) { var that = this; - //获取当前坐标(gcj02) - wx.getLocation({ - type: "gcj02", - altitude: true, - success: function (res) { - that.setData({ - latitude: parseFloat(res.latitude).toFixed(6), - longitude: parseFloat(res.longitude).toFixed(6), - // markers: [{ - // latitude: res.latitude, - // longitude: res.longitude, - // }] - }) - //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 - wx.getLocation({ - type: "wgs84", - altitude: true, - success: function (res) { - that.setData({ - latitude84: parseFloat(res.latitude).toFixed(6), - longitude84: parseFloat(res.longitude).toFixed(6) - }) - } - }) - } - }), - - //设置地图组件 - wx.getSystemInfo({ + //设置地图组件 + wx.getSystemInfo({ success(res) { var windowWidth = res.windowWidth var windowHeight = res.windowHeight var query = wx.createSelectorQuery() + var platform =res.platform query.select('#map').boundingClientRect() query.exec(function (res) { that.setData({ @@ -139,10 +106,20 @@ clickable: true }, { id: 7, - iconPath: '../../images/locat.png', + iconPath: '../../images/applocat.png', position: { - left: res[0].width/2, - top: res[0].height/2, + left: res[0].width / 2 - 20, + top: platform=="ios"?res[0].height / 2 - 80:res[0].height / 2 - 40, + width: 40, + height: 40 + }, + clickable: true + }, { + id: 8, + iconPath: '../../images/back.png', + position: { + left: windowWidth - 40, + top: windowHeight - 140, width: 30, height: 30 }, @@ -150,71 +127,15 @@ }] }) }) - + } - }), + }) + // 实例化API核心类 qqmapsdk = new QQMapWX({ key: 'BGPBZ-C5O3P-ROUDR-LWC4J-63EKH-V5FRX' }) - - if (options.devcode) { - var that = this - var devcode = options.devcode - wx.cloud.callFunction({ - name: 'findListByCodes', - data: { - devcodes: devcode, - url: app.globalData.url + "appDeviceAdd/findListByCodes" - }, - }).then(res => { - if (res.result.code == 200) { - var listResultData = res.result.data; - that.setData({ - listData: listResultData - }) - var markersArr = that.data.markers; - for (var i = 0; i < listResultData.length; i++) { - markersArr = markersArr.concat({ - iconPath: "../../images/locat.png", - id: listResultData[i].id, - callout: { - content: listResultData[i].devcode, - fontSize: '14', - // padding: true, - color: '#00000', - borderColor: '#F4EA2A', - bgColor: '#F4EA2A', - borderWidth: 5, - display: 'ALWAYS', - textAlign: 'center', - // borderRadius: 15 - }, - latitude: listResultData[i].latitude, - longitude: listResultData[i].longitude, - width: 40, - height: 40 - }); - } - this.setData({ - markers: markersArr, - latitude: listResultData[0].latitude, - longitude: listResultData[0].longitude, - marker_latitude: listResultData[0].latitude, - marker_longitude: listResultData[0].longitude, - title: listResultData[0].devcode - }) - } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "无法获取设备地理信息!", - icon: 'none', - duration: 2000 - }) - }) - } }, /** @@ -228,6 +149,97 @@ * 生命周期函数--监听页面显示 */ onShow: function () { + //输入设备编号获取marker位置信息 + var that = this; + if ( app.globalData.devcode!="") { + var devcode = app.globalData.devcode + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/findListByCodes", + data: { + devcodes: devcode, + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + app.globalData.devcode=""; + if (res.data.code == 200) { + var listResultData = res.data.data; + that.setData({ + listData: listResultData + }) + var markersArr = that.data.markers; + for (var i = 0; i < listResultData.length; i++) { + markersArr = markersArr.concat({ + iconPath: "../../images/locat.png", + id: Number(listResultData[i].id), + callout: { + content: "编号:"+listResultData[i].devcode+"\r\n位置:"+listResultData[i].position+"\r\n时间:"+listResultData[i].createtime, + fontSize: '14', + padding: true, + color: '#000000', + borderColor: '#F4EA2A', + bgColor: '#F4EA2A', + borderWidth: 5, + display: 'ALWAYS', + textAlign: 'left', + // borderRadius: 15 + }, + latitude: listResultData[i].latitude, + longitude: listResultData[i].longitude, + width: 40, + height: 40 + }); + } + that.setData({ + markers: markersArr, + latitude: listResultData[0].latitude, + longitude: listResultData[0].longitude, + marker_latitude: listResultData[0].latitude, + marker_longitude: listResultData[0].longitude, + title: listResultData[0].devcode + }) + } + }, + fail(err) { + app.globalData.devcode=""; + wx.showToast({ + title: "无法获取设备地理信息!", + icon: 'none', + duration: 2000 + }) + } + }) +} else { + //获取当前坐标(gcj02) + wx.getLocation({ + type: "gcj02", + altitude: true, + success: function (res) { + that.setData({ + latitude: parseFloat(res.latitude).toFixed(6), + longitude: parseFloat(res.longitude).toFixed(6), + // markers: [{ + // latitude: res.latitude, + // longitude: res.longitude, + // }] + }) + //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 + wx.getLocation({ + type: "wgs84", + altitude: true, + success: function (res) { + that.setData({ + latitude84: parseFloat(res.latitude).toFixed(6), + longitude84: parseFloat(res.longitude).toFixed(6) + }) + } + }) + } + }) +} + }, @@ -265,12 +277,46 @@ onShareAppMessage: function () { }, + + //定位出来 + + locationPosition: function () { + var that = this; + //获取当前坐标(gcj02) + wx.getLocation({ + type: "gcj02", + altitude: true, + success: function (res) { + that.setData({ + latitude: parseFloat(res.latitude).toFixed(6), + longitude: parseFloat(res.longitude).toFixed(6), + // markers: [{ + // latitude: res.latitude, + // longitude: res.longitude + // }] + }) + //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 + wx.getLocation({ + type: "wgs84", + altitude: true, + success: function (res) { + that.setData({ + latitude84: parseFloat(res.latitude).toFixed(6), + longitude84: parseFloat(res.longitude).toFixed(6) + }) + } + }) + } + }) + }, + + //加载地图组件 controltap: function (e) { // console.log(e.controlId); //进入添加设备页 if (1 == e.controlId) { wx.setClipboardData({ - data: this.data.latitude + "," + this.data.longitude+ "," + this.data.latitude84+ "," + this.data.longitude84, + data: this.data.latitude + "," + this.data.longitude + "," + this.data.latitude84 + "," + this.data.longitude84, success: function (res) { wx.getClipboardData({ success: function (res) { @@ -282,6 +328,17 @@ } }) } else if (3 == e.controlId) { + //先定位 + // this.locationPosition() + wx.setClipboardData({ + data: this.data.latitude + "," + this.data.longitude + "," + this.data.latitude84 + "," + this.data.longitude84, + success: function (res) { + wx.showToast({ + title: '坐标已获取', + duration: 1000 + }) + } + }) wx.navigateTo({ url: '../addDevice/addDevice' }) @@ -302,32 +359,15 @@ enableSsatellite: !flag }); } else if (6 == e.controlId) { - var that = this; - //获取当前坐标(gcj02) - wx.getLocation({ - type: "gcj02", - altitude: true, - success: function (res) { - that.setData({ - latitude: parseFloat(res.latitude).toFixed(6), - longitude:parseFloat(res.longitude).toFixed(6), - // markers: [{ - // latitude: res.latitude, - // longitude: res.longitude - // }] - }) - //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 - wx.getLocation({ - type: "wgs84", - altitude: true, - success: function (res) { - that.setData({ - latitude84: parseFloat(res.latitude).toFixed(6), - longitude84: parseFloat(res.longitude).toFixed(6) - }) - } - }) - } + //先清marker + this.setData({ + markers: [] + }) + this.locationPosition() + }else if (8 == e.controlId) { + //跳转日志缓存页 + wx.switchTab({ + url: '../applog/applog', }) } }, @@ -343,63 +383,68 @@ }); }, + //获取设备maker leave() { var that = this; if (that.data.devcodes == "") { return false; } - wx.cloud.callFunction({ - name: 'findListByCodes', + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/findListByCodes", data: { - devcodes: that.data.devcodes, - url: app.globalData.url + "appDeviceAdd/findListByCodes" + devcodes: that.data.devcodes }, - }).then(res => { - if (res.result.code == 200) { - var listResultData = res.result.data; - that.setData({ - listData: listResultData - }) - var markersArr = that.data.markers; - for (var i = 0; i < listResultData.length; i++) { - markersArr = markersArr.concat({ - iconPath: "../../images/locat.png", - id: listResultData[i].id, - callout: { - content: listResultData[i].devcode, - fontSize: '14', - // padding: true, - color: '', - borderColor: '#F4EA2A', - bgColor: '#F4EA2A', - borderWidth: 5, - display: 'ALWAYS', - textAlign: 'center', - // borderRadius: 15 - }, - latitude: listResultData[i].latitude, - longitude: listResultData[i].longitude, - width: 40, - height: 40 - }); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var listResultData = res.data.data; + that.setData({ + listData: listResultData + }) + var markersArr = that.data.markers; + for (var i = 0; i < listResultData.length; i++) { + markersArr = markersArr.concat({ + iconPath: "../../images/locat.png", + id: listResultData[i].id, + callout: { + content: "编号:"+listResultData[i].devcode+"\r\n位置:"+listResultData[i].position+"\r\n时间:"+listResultData[i].createtime, + fontSize: '14', + // padding: true, + color: '#212121', + borderColor: '#F4EA2A', + bgColor: '#F4EA2A', + borderWidth: 5, + display: 'ALWAYS', + textAlign: 'left', + // borderRadius: 15 + }, + latitude: listResultData[i].latitude, + longitude: listResultData[i].longitude, + width: 40, + height: 40 + }); + } + that.setData({ + markers: markersArr, + latitude: listResultData[0].latitude, + longitude: listResultData[0].longitude, + marker_latitude: listResultData[0].latitude, + marker_longitude: listResultData[0].longitude, + title: listResultData[0].devcode + }) } - this.setData({ - markers: markersArr, - latitude: listResultData[0].latitude, - longitude: listResultData[0].longitude, - marker_latitude: listResultData[0].latitude, - marker_longitude: listResultData[0].longitude, - title: listResultData[0].devcode + }, + fail(err) { + wx.showToast({ + title: "无法获取设备地理信息!", + icon: 'none', + duration: 2000 }) } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "无法获取设备地理信息!", - icon: 'none', - duration: 2000 - }) }) }, @@ -422,6 +467,8 @@ } }, + + bindregionchange: function (e) { var that = this if (e.causedBy == "drag") { @@ -445,8 +492,8 @@ that.setData({ latitude: parseFloat(latitude).toFixed(6), longitude: parseFloat(longitude).toFixed(6), - latitude84:"", - longitude84:"", + latitude84: "", + longitude84: "", // markers: markersArr }) // mapCtx.moveToLocation(); @@ -465,16 +512,19 @@ qqmapsdk.search({ keyword: this.data.value, success: function (res) { + console.log(res) if (res && res.data) { _this.setData({ isShow: true, tips: res.data }); } + }, + complete: function (res){ + console.log(res); } }) }, - bindSearch: function (e) { var location = e.target.dataset.location; this.setData({ diff --git a/miniprogram/pages/earth/earth.wxml b/miniprogram/pages/earth/earth.wxml index a0db6ef..87474f8 100644 --- a/miniprogram/pages/earth/earth.wxml +++ b/miniprogram/pages/earth/earth.wxml @@ -1,9 +1,10 @@ + - + {{item.title}} {{item.address}} @@ -17,6 +18,6 @@ + placeholder="请输入定位设备编号用换行隔开" autosize border="{{ false }}" /> \ No newline at end of file diff --git a/miniprogram/pages/indexapp/indexapp.js b/miniprogram/pages/indexapp/indexapp.js index 5063372..849dbdb 100644 --- a/miniprogram/pages/indexapp/indexapp.js +++ b/miniprogram/pages/indexapp/indexapp.js @@ -7,9 +7,8 @@ */ data: { - count:1, - show: false, - onshow:true, + count: 1, + onshow: true, value: "", deviceloglist: [], devcode: "", @@ -21,6 +20,7 @@ // iconPath: "../../images/point.png", latitude: 23.099994, longitude: 113.324520, + label:'1', width: 50, height: 50 }], @@ -31,62 +31,26 @@ * 生命周期函数--监听页面加载 */ onLoad: function (options) { - + }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { - + }, /** * 生命周期函数--监听页面显示 */ onShow: function () { - // if( app.globalData.indexCount>1){ - // this.setData({ - // show:false - // }) - // }else{ - // this.showNotice() - // } - if(app.globalData.indexCount==1){ - this.setData({ - show:true - }) - this.showNotice() - } - app.globalData.indexCount+=1 - if(this.data.onshow){ + if (this.data.onshow) { this.initPages(); } }, - - showNotice: function() { - var that = this - var times = 0 - var i = setInterval(function() { - times++ - if (times >= 15) { - that.setData({ - show:false - }) - wx.showTabBar({ - animation: false, - }) - clearInterval(i) - } else { - wx.hideTabBar({ - animation: false, - }) - } - }, 1000) -}, - /** * 生命周期函数--监听页面隐藏 */ @@ -122,16 +86,27 @@ }, jump: function (event) { - var that = this; var latitude = event.target.dataset.pointLat; var longitude = event.target.dataset.pointLon; + let devcode = event.target.dataset.pointCode; that.setData({ latitude: latitude, longitude: longitude, markers: [{ latitude: latitude, - longitude: longitude + longitude: longitude, + callout: { + display:'ALWAYS',// 常显气泡 + content: devcode, //名称文本 + color: '#fff', //文本颜色 + borderRadius: 5, //边框圆角 + borderWidth: 1, //边框宽度 + borderColor: '#0060ff', //边框颜色 + bgColor: '#0060ff', //背景色 + padding: 5, //文本边缘留白 + textAlign: 'center' //文本对齐方式。有效值: left, right, center + } }] }) }, @@ -142,7 +117,7 @@ var devcode = res.result _this.setData({ devcode: devcode, - onshow:false + onshow: false }); _this.searchlogs(devcode) } @@ -151,40 +126,11 @@ onSearch: function (event) { this.setData({ - devcode:event.detail + devcode: event.detail }) this.searchlogs(event.detail) }, - - // bindregionchange: function (e) { - // var that = this - // if (e.causedBy == "drag") { - // var mapCtx = wx.createMapContext("map") - // mapCtx.getCenterLocation({ - // success: function (res) { - // var markersArr = that.data.markers - // for (var i = 0; i < markersArr.length; i++) { - // if (markersArr[i].iconPath == undefined) { - // markersArr.splice(i, 1) - // } - // } - // var latitude = res.latitude - // var longitude = res.longitude - // markersArr = markersArr.concat({ - // latitude: latitude, - // longitude: longitude - // }) - // that.setData({ - // latitude: latitude, - // longitude: longitude, - // markers: markersArr - // }) - // } - // }) - // } - // }, - showLoading: function (message) { if (wx.showLoading) { // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 @@ -211,81 +157,89 @@ } }, + //加载设备运维详细信息 toDetail: function (event) { - this.showLoading("数据加载中...") - wx.cloud.callFunction({ - name: 'deviceDetail', + var that = this + that.showLoading("数据加载中...") + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deviceDetail", data: { devcode: event.target.dataset.devcode, - url: app.globalData.url + "appDeviceLog/deviceDetail", }, - }).then(res => { - this.hideLoading(); - var resultObject = JSON.parse(res.result); - var pageName='../indexapp/indexapp' - if (resultObject.code == 200) { - wx.navigateTo({ - url: '../addDevicelog/addDeviceLog?detail=' + - JSON.stringify(resultObject.data)+'&pageName='+pageName - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + that.hideLoading(); + var resultObject = res.data; + var pageName = '../indexapp/indexapp' + if (resultObject.code == 200) { + wx.setStorageSync('resultObject', resultObject.data) + wx.navigateTo({ + url: '../addDevicelog/addDeviceLog?detail=' +'&pageName=' + pageName + }) + } + }, + fail(err){ + that.hideLoading(); } - }).catch(err => { - this.hideLoading(); }) }, + //加载列表 getlogs: function (devcode) { var that = this - wx.cloud.callFunction({ - name: 'devicelog', + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/listPage", data: { devcode: devcode, - url: app.globalData.url + "appDeviceLog/listPage", limit: 100, offset: that.data.deviceloglist.length % 100 > 0 ? parseInt(that.data.deviceloglist.length / 100) + 2 : parseInt(that.data.deviceloglist.length / 100) + 1 }, - }).then(res => { - if (res.result) { - // var resultJson = JSON.parse(res.result) - var resultJson = res.result - that.setData({ - deviceloglist: that.data.deviceloglist.concat(resultJson.data.rows) - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + // var resultJson = JSON.parse(res.result) + var resultJson = res.data + that.setData({ + deviceloglist: that.data.deviceloglist.concat(resultJson.data.rows) + }) + } } - console.log(res); - }).catch(err => { - console.error(err); }) }, + //查询列表 searchlogs: function (devcode) { var that = this - wx.cloud.callFunction({ - name: 'devicelog', + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/listPage", data: { devcode: devcode, - url: app.globalData.url + "appDeviceLog/listPage", limit: 100, offset: 1 }, - }).then(res => { - if (res.result) { - var resultJson = res.result - that.setData({ - deviceloglist: resultJson.data.rows, - onshow:true - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var resultJson = res.data + that.setData({ + deviceloglist: resultJson.data.rows, + onshow: true + }) + } } - console.log(res); - }).catch(err => { - console.error(err); }) }, initPages: function () { var that = this; - that.setData({ - devcode: "" - }); wx.getLocation({ type: "gcj02", success: function (res) { @@ -302,6 +256,6 @@ }) } }) - this.searchlogs() + this.data.devcode !== '' ? this.searchlogs(this.data.devcode) : this.searchlogs() }, }) \ No newline at end of file diff --git a/miniprogram/pages/indexapp/indexapp.wxml b/miniprogram/pages/indexapp/indexapp.wxml index 69322a0..f65b082 100644 --- a/miniprogram/pages/indexapp/indexapp.wxml +++ b/miniprogram/pages/indexapp/indexapp.wxml @@ -1,8 +1,12 @@ + + + + - @@ -32,9 +36,15 @@ - + + + + + + + @@ -46,14 +56,14 @@ - + - - + diff --git a/miniprogram/pages/indexapp/indexapp.wxss b/miniprogram/pages/indexapp/indexapp.wxss index b18706a..fc27fcb 100644 --- a/miniprogram/pages/indexapp/indexapp.wxss +++ b/miniprogram/pages/indexapp/indexapp.wxss @@ -128,6 +128,7 @@ .noticeClass{ height: 2300rpx; width: 750rpx; + overflow-y:hidden; } @@ -148,14 +149,14 @@ } +/* .vanstyle{ + button: not([size='mini']) { + user agent stylesheetmin-height: 40px; + width: 650rpx; + margin-left: 20rpx; + margin-right: auto; + + } + +} */ -/* .van-enter-active-class, -.van-leave-active-class { - transition-property: background-color, transform; -} - -.van-enter-class, -.van-leave-to-class { - background-color: red; - transform: rotate(-360deg) translate3d(-100%, -100%, 0); -} */ \ No newline at end of file diff --git a/miniprogram/pages/log/log.js b/miniprogram/pages/log/log.js deleted file mode 100644 index 83ba349..0000000 --- a/miniprogram/pages/log/log.js +++ /dev/null @@ -1,66 +0,0 @@ -// pages/log/log.js -Page({ - - /** - * 页面的初始数据 - */ - data: { - - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - - }, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { - - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - - }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { - - }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { - - } -}) \ No newline at end of file diff --git a/miniprogram/pages/log/log.json b/miniprogram/pages/log/log.json deleted file mode 100644 index 8835af0..0000000 --- a/miniprogram/pages/log/log.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "usingComponents": {} -} \ No newline at end of file diff --git a/miniprogram/pages/log/log.wxml b/miniprogram/pages/log/log.wxml deleted file mode 100644 index a510ad6..0000000 --- a/miniprogram/pages/log/log.wxml +++ /dev/null @@ -1,2 +0,0 @@ - -pages/log/log.wxml diff --git a/miniprogram/pages/log/log.wxss b/miniprogram/pages/log/log.wxss deleted file mode 100644 index 23db318..0000000 --- a/miniprogram/pages/log/log.wxss +++ /dev/null @@ -1 +0,0 @@ -/* pages/log/log.wxss */ \ No newline at end of file diff --git a/miniprogram/pages/login/login.js b/miniprogram/pages/login/login.js index a4074e7..cb0542a 100644 --- a/miniprogram/pages/login/login.js +++ b/miniprogram/pages/login/login.js @@ -1,11 +1,14 @@ // miniprogram/pages/login/login.js +var app = getApp() Page({ /** * 页面的初始数据 */ data: { - windowWidth:"" + windowWidth: "", + time: 15 * 1000, + showTime: false }, /** @@ -20,9 +23,9 @@ */ onReady: function () { this.setData({ - windowWidth:wx.getSystemInfoSync().windowWidth + windowWidth: wx.getSystemInfoSync().windowWidth }) - + }, /** @@ -66,14 +69,158 @@ onShareAppMessage: function () { }, + + + showLoading: function (message) { + if (wx.showLoading) { + // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 + wx.showLoading({ + title: message, + mask: true + }); + } else { + // 低版本采用Toast兼容处理并将时间设为20秒以免自动消失 + wx.showToast({ + title: message, + icon: 'loading', + mask: true, + duration: 20000 + }); + } + }, + hideLoading: function () { + if (wx.hideLoading) { + // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 + wx.hideLoading(); + } else { + wx.hideToast(); + } + }, + + //注册 loginClick: function () { + var that = this + that.showLoading("授权中...") + wx.login({ + success: function (res) { + if (res.code) { + wx.request({ + url: app.globalData.httpsUrl + "appUserOpenid/login", + data: { + code: res.code + }, + success: function (res) { + app.globalData.openid = res.data.data + wx.getUserInfo({ + success: (res) => { + var nickname = res.userInfo.nickName; + app.globalData.nickName = nickname; + //openid绑定昵称存入后台 + wx.request({ + url: app.globalData.httpsUrl + "appUserOpenid/add", + data: { + attr: nickname, + openid: app.globalData.openid + }, + success: function (res) { + that.hideLoading(); + wx.showToast({ + title: res.data.data+",\r\n请从正式版入口登录!", + icon: 'none', + duration: 2000 + }) - wx.navigateTo({ - - url: '../farmermain/farmermain', - + // //授权成功后跳转 + // wx.switchTab({ + // url: '../indexapp/indexapp' + // }) + } + }) + }, + fail: function (err) { + that.hideLoading(); + } + }) + }, + fail: function (res) { + that.hideLoading(); + wx.showToast({ + title: '服务器异常', + }) + } + }) + } + }, + fail: function (res) { + that.hideLoading(); + } }) + }, + //登录验证 + loginValidate: function () { + var that = this + that.showLoading("登录中...") + wx.login({ + success: function (res) { + if (res.code) { + console.info(res); + wx.request({ + url: app.globalData.httpsUrl + "appUserOpenid/login", + data: { + code: res.code + }, + success: function (res) { + app.globalData.openid = res.data.data + wx.request({ + url: app.globalData.httpsUrl + "appUserOpenid/validate", + data: { + openid: app.globalData.openid + }, + success: function (res) { + that.hideLoading(); + if (res.data.data) { + app.globalData.userName = res.data.data.attr1 == '' ? res.data.data.attr : res.data.data.attr1 + app.globalData.nickName = res.data.data.attr + app.globalData.role = res.data.data.role + wx.navigateTo({ + url: '../notice/notice' + }) + } else { + wx.showToast({ + icon: 'none', + title: '请联系管理员授权', + duration: 2000 + }) + } + }, + fail: function (err) { + that.hideLoading(); + wx.showToast({ + title: '验证失败', + }) + } + }) + }, + fail: function (res) { + that.hideLoading(); + wx.showToast({ + title: '服务器异常', + }) + } + }) + } + }, + fail: function (res) { + that.hideLoading(); + } + }) + }, + + finished() { + this.setData({ + showTime: true + }) }, onClickSubmit: function () { diff --git a/miniprogram/pages/login/login.json b/miniprogram/pages/login/login.json index 8835af0..f2043a3 100644 --- a/miniprogram/pages/login/login.json +++ b/miniprogram/pages/login/login.json @@ -1,3 +1,8 @@ { - "usingComponents": {} + "usingComponents": { + "van-count-down": "../../miniprogram_npm/@vant/weapp/count-down", + "van-button": "../../miniprogram_npm/@vant/weapp/button" + }, + "navigationBarBackgroundColor": "#E6D480", + "disableScroll":true } \ No newline at end of file diff --git a/miniprogram/pages/login/login.wxml b/miniprogram/pages/login/login.wxml index c69df42..cf2ec72 100644 --- a/miniprogram/pages/login/login.wxml +++ b/miniprogram/pages/login/login.wxml @@ -1,21 +1,46 @@ + - + + + - + + + +    本程序为施工日志管理小程序,为航天二院智慧市 +政技术研究室内部系统,不对外开放。出于对数据信 +息安全的考虑,在您首次使用小程序时,请先对小程 +序进行授权,授权后的用户可以正常对小程序进行编 +辑,谢谢您的配合! + + + + + + + + 授权/登录 + + + - + + + diff --git a/miniprogram/pages/login/login.wxss b/miniprogram/pages/login/login.wxss index ca77568..b9fa569 100644 --- a/miniprogram/pages/login/login.wxss +++ b/miniprogram/pages/login/login.wxss @@ -54,7 +54,8 @@ } .form .submit { - margin-top: 80rpx; + + /* margin-top: 80rpx; */ color: #fff; border: 2rpx solid #FFB90F; background-color: #FFB90F; @@ -63,10 +64,30 @@ } .login_image { - width: 200rpx; - height: 200rpx; - padding-top: 100rpx; - padding-left: 250rpx; + width: 750rpx; + height: 360rpx; + /* height: 2300rpx; */ + /* padding-top: 100rpx + padding-left: 250rpx; */ +} +.bottom_image { + width: 750rpx; + height: 32%; + position: fixed; + bottom: 0px; + /* padding-top: 100rpx + padding-left: 250rpx; */ +} +.cover{ + position: fixed; + top: 0rpx; + margin-left: 290rpx; + text-align:center; + font-size: 50rpx; + color: #FFCF00; + width: 750rpx; + z-index:9999; + } -} \ No newline at end of file + \ No newline at end of file diff --git a/miniprogram/pages/notice/notice.js b/miniprogram/pages/notice/notice.js new file mode 100644 index 0000000..7aeafb9 --- /dev/null +++ b/miniprogram/pages/notice/notice.js @@ -0,0 +1,80 @@ +// miniprogram/pages/notice.js +Page({ + + /** + * 页面的初始数据 + */ + data: { + time: 15 * 1000, + showTime: false + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { + this.setData({ + showTime: true + }) + wx.switchTab({ + url: '../indexapp/indexapp' + }) + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + }, + finished() { + this.setData({ + showTime: true + }) + wx.switchTab({ + url: '../indexapp/indexapp' + }) + } +}) \ No newline at end of file diff --git a/miniprogram/pages/notice/notice.json b/miniprogram/pages/notice/notice.json new file mode 100644 index 0000000..4c73264 --- /dev/null +++ b/miniprogram/pages/notice/notice.json @@ -0,0 +1,5 @@ +{ + "usingComponents": { + "van-count-down": "../../miniprogram_npm/@vant/weapp/count-down" + } +} \ No newline at end of file diff --git a/miniprogram/pages/notice/notice.wxml b/miniprogram/pages/notice/notice.wxml new file mode 100644 index 0000000..975304a --- /dev/null +++ b/miniprogram/pages/notice/notice.wxml @@ -0,0 +1,10 @@ + + + + + + + + diff --git a/miniprogram/pages/notice/notice.wxss b/miniprogram/pages/notice/notice.wxss new file mode 100644 index 0000000..36d7542 --- /dev/null +++ b/miniprogram/pages/notice/notice.wxss @@ -0,0 +1,18 @@ +/* miniprogram/pages/notice.wxss */ + +.login_image { + width: 750rpx; + height: 2300rpx; + /* padding-top: 100rpx + padding-left: 250rpx; */ +} +.cover{ + position: fixed; + top: 0rpx; + margin-left: 290rpx; + text-align:center; + font-size: 50rpx; + color: #FFCF00; + width: 750rpx; + z-index:9999; + } \ No newline at end of file diff --git a/miniprogram/pages/searchLog/searchLog.js b/miniprogram/pages/searchLog/searchLog.js index a4f8c33..1f7069b 100644 --- a/miniprogram/pages/searchLog/searchLog.js +++ b/miniprogram/pages/searchLog/searchLog.js @@ -6,29 +6,35 @@ * 页面的初始数据 */ data: { - defaultDay:[ + defaultDay: [ new Date().getTime(), - new Date().getTime()+24*60*60*1000, + new Date().getTime() + 24 * 60 * 60 * 1000, ], projectoption: [], - devtypeList:[], + devtypeList: [], personoption: [], installtimeFmt: '', show: false, - minDate: new Date(2010, 0, 1).getTime(), devcode: '', + timeShow:false, project: '', devtype: '', - installPerson:'', + installPerson: '', + projectvalue:'', minDate: new Date(2018, 0, 1).getTime(), // maxDate: new Date(2018, 0, 31).getTime(), }, onDisplay() { - this.setData({ show: true }); + this.setData({ + show: true + }); }, onClose() { - this.setData({ show: false }); + this.setData({ + show: false + }); }, + //格式化时间 formatDate(date) { date = new Date(date); // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; @@ -50,6 +56,7 @@ return currentdate; }, + //查询时间区域设置 onConfirm(event) { // this.setData({ @@ -67,87 +74,102 @@ /** * 生命周期函数--监听页面加载 */ - onLoad: function (options) { - var _this=this + onLoad: async function (options) { + await this.setData({ + timeShow:true, + }) + const {devcode,devtype,installPerson,installtimeFmt,project} = JSON.parse(options.params) + this.setData({ + devcode:devcode || '', + devtype:devtype || '', + installPerson:installPerson || '', + installtimeFmt:installtimeFmt || '', + project:project || '', + projectvalue:project || '', + + }) + + var _this = this /** * 获取所属项目下拉列表 */ - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); + success(res) { + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); + } + _this.setData({ + projectoption: projectArr + }) } - _this.setData({ - projectoption: projectArr - }) } - }).catch(err => { - console.error(err); }) - - - /** + /** * 获取设备类型下拉列表 */ - wx.cloud.callFunction({ - name: 'getTypeList', - data: { - url: app.globalData.url + "deviceType/deviceType" + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/deviceType", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - }).then(res => { - if (res.result.code == 200) { - var TypeList = res.result.data - var typeArr = []; - for (var i = 0; i < TypeList.length; i++) { - var type = { - text: TypeList[i].productName, - value: TypeList[i].productName - }; - typeArr.push(type); + success(res) { + if (res.data.code == 200) { + var TypeList = res.data.data + var typeArr = []; + for (var i = 0; i < TypeList.length; i++) { + var type = { + text: TypeList[i].productName, + value: TypeList[i].productName + }; + typeArr.push(type); + } + _this.setData({ + devtypeList: typeArr + }) } - _this.setData({ - devtypeList: typeArr - }) } - }).catch(err => { - console.error(err); }) - //获取人员下拉列表 - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" + //获取人员下拉列表 + wx.request({ + method: "POST", + data:{ + tips:'repair' }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); + url: app.globalData.httpsUrl + "deviceType/getUser", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var users = res.data.data + var personArr = []; + for (var i = 0; i < users.length; i++) { + var person = { + text: users[i].name, + value: users[i].name + }; + personArr.push(person); + } + _this.setData({ + personoption: personArr + }) } - _this.setData({ - personoption: personArr - }) } - }).catch(err => { - console.error(err); }) }, @@ -202,13 +224,13 @@ }, scan() { - var _this=this; + var _this = this; wx.scanCode({ success(res) { - var devcode=res.result + var devcode = res.result _this.setData({ - devcode: devcode, - }); + devcode: devcode, + }); } }) }, @@ -221,6 +243,7 @@ [formName]: formValue }) }, + //设置项目 selectprojectValue(event) { var that = this; that.setData({ @@ -228,7 +251,7 @@ }) }, - + //设置设备类型 selectDevType(event) { var that = this; that.setData({ @@ -236,46 +259,24 @@ }) }, + //设置人员 selectpersonValue(event) { var that = this; that.setData({ installPerson: event.detail }) }, - + //查询 query: function (event) { - var data={ + var data = { devcode: this.data.devcode, installtimeFmt: this.data.installtimeFmt, project: this.data.project, devtype: this.data.devtype, - installPerson:this.data.installPerson + installPerson: this.data.installPerson } wx.reLaunch({ url: '../applog/applog?params=' + JSON.stringify(data) }) - // var that = this; - // wx.cloud.callFunction({ - // name: 'devicelog', - // data: { - // devcode: that.data.devcode, - // installtimeFmt: that.data.installtimeFmt, - // project: that.data.project, - // devtype: that.data.devtype, - // }, - // }).then(res => { - // // var resultObj=JSON.parse(res.result); - // var resultObj=res.result; - // if (resultObj.code == 200) { - // wx.reLaunch({ - // url: '../applog/applog?applogList=' + JSON.stringify(resultObj.data.rows) - // }) - // } - // }).catch(err => { - // console.error(err); - // wx.showToast({ - // title: "查询失败", - // }) - // }) }, }) \ No newline at end of file diff --git a/cloudfunctions/project.config.json b/cloudfunctions/project.config.json new file mode 100644 index 0000000..2b3119a --- /dev/null +++ b/cloudfunctions/project.config.json @@ -0,0 +1,28 @@ +{ + "appid": "wx2cef527a000f87c9", + "compileType": "miniprogram", + "libVersion": "2.27.3", + "packOptions": { + "ignore": [], + "include": [] + }, + "setting": { + "coverView": true, + "es6": true, + "postcss": true, + "minified": true, + "enhance": true, + "showShadowRootInWxmlPanel": true, + "packNpmRelationList": [], + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + } + }, + "condition": {}, + "editorSetting": { + "tabIndent": "insertSpaces", + "tabSize": 4 + } +} \ No newline at end of file diff --git a/cloudfunctions/project.private.config.json b/cloudfunctions/project.private.config.json new file mode 100644 index 0000000..42ff49d --- /dev/null +++ b/cloudfunctions/project.private.config.json @@ -0,0 +1,7 @@ +{ + "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", + "projectname": "cloudfunctions", + "setting": { + "compileHotReLoad": true + } +} \ No newline at end of file diff --git a/miniprogram/app.js b/miniprogram/app.js index 51d56f3..50a8a54 100644 --- a/miniprogram/app.js +++ b/miniprogram/app.js @@ -18,13 +18,15 @@ // this.globalData = {} }, globalData: { - // url: "http://111.198.10.15:11604/", - httpsUrl: "https://logapi.smartlog.work/", - httpsTestUrl: "https://smartlog.work/prodapi4test/", - url: "http://139.198.18.188:8083/", + httpsUrl: "https://logapi.smartlog.work/", + // httpsUrl: "http://139.198.18.188:8083/", // url: "http://127.0.0.1:8083/", - // httpsUrl: "http://127.0.0.1:8083/", + //httpsUrl: "http://127.0.0.1:8083/", openid: null, - indexCount:1 - }, + indexCount:1, + nickName:"", + userName:"", + role:"", + devcode:"" + } }) diff --git a/miniprogram/app.json b/miniprogram/app.json index d23f798..2b6db76 100644 --- a/miniprogram/app.json +++ b/miniprogram/app.json @@ -1,15 +1,17 @@ { "cloud": true, "pages": [ + "pages/login/login", "pages/indexapp/indexapp", "pages/earth/earth", "pages/applog/applog", "pages/addDevice/addDevice", "pages/addDevicelog/addDeviceLog", - "pages/searchLog/searchLog" + "pages/searchLog/searchLog", + "pages/notice/notice" ], "window": { - "backgroundColor": "#F6F6F6", + "backgroundColor": "#E6D480", "backgroundTextStyle": "light", "navigationBarBackgroundColor": "#FFCF00", "navigationBarTitleText": "智慧施工", @@ -46,11 +48,11 @@ "desc": "你的位置信息将用于小程序位置接口的效果展示" } }, + "requiredPrivateInfos": ["getLocation", "chooseLocation"], "networkTimeout": { "request": 30000, "connectSocket": 30000, "uploadFile": 30000, "downloadFile": 30000 - }, - "style": "v2" + } } \ No newline at end of file diff --git a/miniprogram/images/applocat.png b/miniprogram/images/applocat.png new file mode 100644 index 0000000..fe49f54 --- /dev/null +++ b/miniprogram/images/applocat.png Binary files differ diff --git a/miniprogram/images/back.png b/miniprogram/images/back.png new file mode 100644 index 0000000..32ac82d --- /dev/null +++ b/miniprogram/images/back.png Binary files differ diff --git a/miniprogram/images/bottom.png b/miniprogram/images/bottom.png new file mode 100644 index 0000000..d910e98 --- /dev/null +++ b/miniprogram/images/bottom.png Binary files differ diff --git a/miniprogram/images/header.png b/miniprogram/images/header.png new file mode 100644 index 0000000..6ea222e --- /dev/null +++ b/miniprogram/images/header.png Binary files differ diff --git a/miniprogram/images/login.png b/miniprogram/images/login.png index 8b73cc0..6471c46 100644 --- a/miniprogram/images/login.png +++ b/miniprogram/images/login.png Binary files differ diff --git a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss index 5a591fb..c9c35b5 100644 --- a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss +++ b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:100%;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:100%}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file +@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:650rpx;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:600rpx}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file diff --git a/miniprogram/pages/addDevice/addDevice.js b/miniprogram/pages/addDevice/addDevice.js index 2783674..78f00b7 100644 --- a/miniprogram/pages/addDevice/addDevice.js +++ b/miniprogram/pages/addDevice/addDevice.js @@ -1,5 +1,7 @@ // miniprogram/pages/addDevice/addDevice.js // import WxValidate from '../../utils/WxValidate.js' +var QQMapWX = require('../../libs/qqmap-wx-jssdk.js'); +var qqmapsdk; var app = getApp() Page({ @@ -11,32 +13,10 @@ canvasWidth: '', longitude: '', latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], + option1: [], personoption1: [], projectoption: [], + devtypeList:[], show: false, form: { devcode: "", @@ -59,7 +39,10 @@ project: "", area: "", street: "", - wellname: "" + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '', }, fileList: [] }, @@ -117,12 +100,14 @@ var that = this; //初始化表单内容为上次填写值 var cacheForms = wx.getStorageSync('cacheList') - if (cacheForms) { + cacheForms.photopath1='' + cacheForms.photopath2='' + cacheForms.photopath3='' + that.data.fileList=[] that.setData({ form: cacheForms, devcode: cacheForms.devcode, - }) } var form = that.data.form @@ -155,55 +140,89 @@ } }) + +//获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + that.setData({ + option1: welltypeArr + }) + } + } +}) + + //获取人员下拉列表 - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/getUser", + data:{ + tips:'repair' }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data.code == 200) { + var users = res.data.data + var personArr = []; + for (var i = 0; i < users.length; i++) { + var person = { + text: users[i].name, + value: users[i].name + }; + personArr.push(person); + } + that.setData({ + personoption1: personArr + }) } - that.setData({ - personoption1: personArr - }) } - }).catch(err => { - console.error(err); - }) + }) + - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - that.setData({ - projectoption: projectArr - }) + success(res){ + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); + } + that.setData({ + projectoption: projectArr + }) + } } - }).catch(err => { - console.error(err); - }) + }) + var installtime = 'form.installtimeFmt'; var dateNow = this.formatDate(); this.setData({ @@ -211,8 +230,40 @@ installtimeFmt: dateNow, [installtime]: dateNow, }); + + + + /** + * 获取设备类型下拉列表 + */ + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/deviceType", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var TypeList = res.data.data + var typeArr = []; + for (var i = 0; i < TypeList.length; i++) { + var type = { + text: TypeList[i].productName, + value: TypeList[i].productName + }; + typeArr.push(type); + } + that.setData({ + devtypeList: typeArr + }) + } + } + }) }, + + + /** * 生命周期函数--监听页面初次渲染完成 */ @@ -280,29 +331,7 @@ }, - - //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 - drawText: function (ctx, str, leftWidth, initHeight, titleHeight, canvasWidth) { - var lineWidth = 0; - var lastSubStrIndex = 0; //每次开始截取的字符串的索引 - for (let i = 0; i < str.length; i++) { - lineWidth += ctx.measureText(str[i]).width; - if (lineWidth > canvasWidth) { - ctx.fillText(str.substring(lastSubStrIndex, i), leftWidth, initHeight); //绘制截取部分 - initHeight = initHeight + leftWidth * 2; //22为字体的高度 - lineWidth = 0; - lastSubStrIndex = i; - // titleHeight += 40; - } - if (i == str.length - 1) { //绘制剩余部分 - ctx.fillText(str.substring(lastSubStrIndex, i + 1), leftWidth, initHeight); - } - } - // // 标题border-bottom 线距顶部距离 - // titleHeight = titleHeight + 10; - // return titleHeight - }, - + //验证表单 formValidate() { if (this.data.form.devcode == "") { @@ -312,27 +341,20 @@ }) return false } - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } if (this.data.form.wellcode == "") { wx.showToast({ icon: 'none', @@ -348,22 +370,10 @@ }) return false } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null) { + + if (this.data.form.installperson == "") { wx.showToast({ icon: 'none', title: '安装人员不能为空!', @@ -408,56 +418,90 @@ } return true; }, + //提交表单 formSubmit: function (event) { + console.log(this.data.form) + //表单参数验证 if (!this.formValidate()) { return false; } var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDevice', + //验证设备编号长度 + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/getDevTypeLength", data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceAdd/add" + code: encodeURI(this.data.form.devicetype) }, - }).then(res => { - if (res.result.code == 500) { - wx.showToast({ - title: '设备编号已安装!', - }) - } else if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - //用于回显 - wx.setStorageSync('cacheList', that.data.form) - //提交成功后提示用户操作 - if (res.confirm) { - wx.switchTab({ - url: '../earth/earth' - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (""==res.data.data ||res.data.data == that.data.form.devcode.length) { + that.saveDevice() + } else { //编号位数不对提示 + wx.showToast({ + icon: 'none', + title: '设备编号位数不对!', + duration: 1000 + }) + return false + } } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "提交失败", - }) }) }, + + //保存设备基本信息 + saveDevice() { + var that = this; + //设置照片路径 + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopathForm = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopathForm]: fileList[i].url.split("static/")[1] + }) + } + //表单提交 + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 500) { + wx.showToast({ + title: '设备编号已安装!', + }) + } else if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + //用于回显 + wx.setStorageSync('cacheList', that.data.form) + //提交成功后提示用户操作 + if (res.confirm) { + wx.switchTab({ + url: '../earth/earth' + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } + }, + fail(err) { + wx.showToast({ + title: '提交失败!', + }) + } + }) + }, + + //input 输入框设置值 confirm(event) { var that = this; var formValue = event.detail.value; @@ -466,8 +510,30 @@ that.setData({ [fromN]: formValue }) + //若输入是设备编号,自动获取设备类型 + if('devcode'==formName){ + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", + data: { + devcode: formValue, + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + that.setData({ + [formDevicetype]: res.data + }); + } + } + }) + } }, + //扫描设备获取编号和设备类型 scan() { var _this = this; wx.scanCode({ @@ -477,23 +543,28 @@ _this.setData({ [formdevcode]: devcode }); - wx.cloud.callFunction({ - name: 'findModeCode', + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", data: { devcode: devcode, - url: app.globalData.url + "appDeviceAdd/findModeCodeByCode" }, - }).then(res => { - if (res.result) { - var formDevicetype = 'form.devicetype' - _this.setData({ - [formDevicetype]: res.result - }); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + _this.setData({ + [formDevicetype]: res.data + }); + } } }) } }) }, + //粘贴经纬度 paste() { var _this = this; wx.getClipboardData({ @@ -510,9 +581,11 @@ longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), }); + _this.showAddress(_this.data.form.longitude,_this.data.form.latitude,_this) } }) }, + //设置经类型 selectValue(value) { var that = this; @@ -521,6 +594,16 @@ [wellType]: value.detail }) }, + + //设置设备类型 + selectDevType(event) { + var that = this; + var devtype = 'form.devicetype'; + that.setData({ + [devtype]: event.detail + }) + }, + //设置运维人员 selectpersonValue(event) { var that = this; var installPerson = 'form.installperson'; @@ -528,6 +611,7 @@ [installPerson]: event.detail }) }, + //设置项目 selectprojectValue(event) { var that = this; var project = 'form.project'; @@ -535,8 +619,41 @@ [project]: event.detail }) }, + showAddress :function(longitude, latitude, self) { + // 实例化腾讯地图API核心类 + qqmapsdk = new QQMapWX({ + key: 'BGPBZ-C5O3P-ROUDR-LWC4J-63EKH-V5FRX'//此处使用你自己申请的key + }) + // 腾讯地图调用接口 + qqmapsdk.reverseGeocoder({ + location: { + latitude: latitude, + longitude: longitude + }, + success: function (res) { + self.setData({ + 'form.area':res.result.address.slice(0,res.result.address.indexOf('区')+1), + 'form.street':res.result.address.slice(res.result.address.indexOf('区')+1) + }) + }, + fail: function (res) { + console.log(res); + }, + complete: function (res) { + } + }); + }, + //上传照片 afterRead(event) { var _this = this; + if (_this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '请先填写设备编号!\r\n否则水印中无编号', + duration: 2000 + }) + return false + } const { file } = event.detail; @@ -576,78 +693,8 @@ }) } }) - // 压缩图片 - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // //获取图片尺寸 - // wx.getImageInfo({ - // src: convertpath, - // success(res) { - // _this.setData({ - // canvasHeight: res.height, - // canvasWidth: res.width - // }) - // var ctx = wx.createCanvasContext('firstCanvas') - - // //将图片src放到cancas内,宽高为图片大小 - // ctx.drawImage(convertpath, 0, 0, res.width, res.height) - // //将声明的时间放入canvas - // ctx.setFontSize(30 * (res.width / 750)) //注意:设置文字大小必须放在填充文字之前,否则不生效 - // ctx.setFillStyle('blue') - // var text = "编号:" + _this.data.form.devcode + "\n经度:" + _this.data.form.longitude + "\n纬度:" + _this.data.form.latitude - // // _this.drawText(ctx,text,20, 70, 5, res.width) - // _this.drawText(ctx, text, 15 * (res.width / 750), 70 * (res.width / 750), 5, res.width) - - // // ctx.fillText(text, 0, 40) - // // ctx.strokeText(_this.data.form.devcode, 0, 30) - // //生成水印图 - // ctx.draw(false, function () { - // wx.canvasToTempFilePath({ - // canvasId: 'firstCanvas', - // success: (res) => { - // wx.compressImage({ - // src: res.tempFilePath, - // quality: 25, - // success: function (res) { - // //上传照片至服务器 - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: res.tempFilePath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // } - // }) - // //// - // } - // }) - // }) - // } - // }) - // } - // }); }, + //删除照片 deletePhoto(event) { var image_index = event.detail.index var fileList_new = this.data.fileList; diff --git a/miniprogram/pages/addDevice/addDevice.wxml b/miniprogram/pages/addDevice/addDevice.wxml index b0977e2..f12c254 100644 --- a/miniprogram/pages/addDevice/addDevice.wxml +++ b/miniprogram/pages/addDevice/addDevice.wxml @@ -5,18 +5,30 @@ - + + + + + + + + + + + + + - - + + - - - + + + @@ -29,13 +41,13 @@ - + - + - + - + @@ -54,8 +66,7 @@ - - + @@ -68,8 +79,8 @@ - - + + - 保存 + 保存 \ No newline at end of file diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.js b/miniprogram/pages/addDevicelog/addDeviceLog.js index cdec71b..a0dc6da 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.js +++ b/miniprogram/pages/addDevicelog/addDeviceLog.js @@ -3,681 +3,665 @@ var app = getApp(); Page({ - /** - * 页面的初始数据 - */ - data: { - pageName: '', - showMask: false, - today: new Date().getTime(), - longitude: '', - latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], - personoption1: [], - projectoption: [], - devcode: "", - deviceMode: "", - installtimeFmt: '', - show: false, - form: { - devcode: "", - wellcode: "", - welltype: "", - welldepth: "", - installheigt: "", - installperson: "", - installtimeFmt: "", - photopath: "", - factory: "", - workmsg: "", - position: "", - description: "", - longitude: "", - latitude: "", - longitude84: "", - latitude84: "", - devicetype: "", - project: "", - area: "", - street: "", - wellname: "" - }, - fileList: [], - detail: "" - }, + /** + * 页面的初始数据 + */ + data: { + pageName: '', + showMask: false, + today: new Date().getTime(), + longitude: '', + latitude: '', + option1: [], + personoption1: [], + projectoption: [], + devcode: "", + deviceMode: "", + installtimeFmt: '', + show: false, + form: { + devcode: "", + wellcode: "", + welltype: "", + welldepth: "", + installheigt: "", + installperson: "", + installtimeFmt: "", + photopath: "", + factory: "", + workmsg: "", + position: "", + description: "", + longitude: "", + latitude: "", + longitude84: "", + latitude84: "", + devicetype: "", + project: "", + area: "", + street: "", + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '' + }, + fileList: [], + detail: "", + markers: [{ + id: 100, + // iconPath: "../../images/point.png", + latitude: '', + longitude: '', + // label:'1', + width: 25, + height: 35 + }], + }, - onDisplay() { - this.setData({ - show: true - }); - }, - onClose() { - this.setData({ - show: false - }); - }, - formatDate() { - var date = new Date(); - // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; - var seperator1 = "-"; - var month = date.getMonth() + 1; - var strDate = date.getDate(); - var hour = date.getHours() - var minute = date.getMinutes() - var second = date.getSeconds() - month = month > 9 ? month : "0" + month; - strDate = strDate > 9 ? strDate : "0" + strDate; - hour = hour > 9 ? hour : "0" + hour; - minute = minute > 9 ? minute : "0" + minute; - second = second > 9 ? second : "0" + second; - var currentdate = - date.getFullYear() + - seperator1 + - month + - seperator1 + - strDate + - " " + - hour + ":" + - minute + ":" + - second; - return currentdate; + onDisplay() { + this.setData({ + show: true + }); + }, + onClose() { + this.setData({ + show: false + }); + }, + formatDate() { + var date = new Date(); + // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; + var seperator1 = "-"; + var month = date.getMonth() + 1; + var strDate = date.getDate(); + var hour = date.getHours() + var minute = date.getMinutes() + var second = date.getSeconds() + month = month > 9 ? month : "0" + month; + strDate = strDate > 9 ? strDate : "0" + strDate; + hour = hour > 9 ? hour : "0" + hour; + minute = minute > 9 ? minute : "0" + minute; + second = second > 9 ? second : "0" + second; + var currentdate = + date.getFullYear() + + seperator1 + + month + + seperator1 + + strDate + + " " + + hour + ":" + + minute + ":" + + second; + return currentdate; - }, - onConfirm(event) { - var installtime = 'form.installtimeFmt'; - this.setData({ - show: false, - installtimeFmt: this.formatDate(event.detail), - [installtime]: this.formatDate(event.detail), - }); - }, + }, + onConfirm(event) { + var installtime = 'form.installtimeFmt'; + this.setData({ + show: false, + installtimeFmt: this.formatDate(event.detail), + [installtime]: this.formatDate(event.detail), + }); + }, - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - var _this = this; - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" - }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); - } - _this.setData({ - personoption1: personArr - }) + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + var _this = this; + _this.setData({ + 'markers[0].latitude': Number(wx.getStorageSync('resultObject').latitude) , + 'markers[0].longitude': Number(wx.getStorageSync('resultObject').longitude), + // 'markers[0].label':'10', + 'markers[0].width': 18, + 'markers[0].id':1, + 'markers[0].height': 30, + latitude:Number(wx.getStorageSync('resultObject').latitude), + longitude:Number(wx.getStorageSync('resultObject').longitude) + }) + //获取人员下拉列表 + // wx.request({ + // method: "POST", + // url: app.globalData.httpsUrl + "deviceType/getUser", + // data:{ + // tips:'repair' + // }, + // header: { + // 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + // }, + // success(res) { + // if (res.data.code == 200) { + // var users = res.data.data + // var personArr = []; + // for (var i = 0; i < users.length; i++) { + // var person = { + // text: users[i].name, + // value: users[i].name + // }; + // personArr.push(person); + // } + // _this.setData({ + // personoption1: personArr + // }) + // } + // } + // }) + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); } - }).catch(err => { - console.error(err); - }) - - - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" - }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - _this.setData({ - projectoption: projectArr - }) - } - }).catch(err => { - console.error(err); - }) - - if (options.pageName) { - this.setData({ - pageName: options.pageName - }) - } - - if (options.detail) { - - var formObject = JSON.parse(options.detail); _this.setData({ - form: formObject, - detail: options.detail + projectoption: projectArr }) - - _this.setData({ - ['form.installperson']: "", - ['form.installtimeFmt']: "", - ['form.workmsg']: "", - ['form.description']: "" - }) - - const { - fileList = [] - } = _this.data; - if (formObject.photopath1 != "") { - var file1 = { - url: app.globalData.url + "static/" + formObject.photopath1 - } - fileList.push(file1) - } - if (formObject.photopath2 != "") { - var file2 = { - url: app.globalData.url + "static/" + formObject.photopath2 - } - fileList.push(file2) - } - if (formObject.photopath3 != "") { - var file3 = { - url: app.globalData.url + "static/" + formObject.photopath3 - } - fileList.push(file3) - } - - _this.setData({ - fileList - }); } - var installtime = 'form.installtimeFmt'; - var dateNow = this.formatDate(); - this.setData({ - installtimeFmt: dateNow, - [installtime]: dateNow, - }); - }, + } + }) - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { + //获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + _this.setData({ + option1: welltypeArr + }) + } + } +}) - }, + //跳转时带入参数返回哪页 + if (options.pageName) { + this.setData({ + pageName: options.pageName + }) + } + //跳转时带入参数设备的安装信息 + if (wx.getStorageSync('resultObject')) { + var formObject = wx.getStorageSync('resultObject') + _this.setData({ + form: formObject, + detail: formObject + }) - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { + _this.setData({ + ['form.installperson']: app.globalData.userName, + ['form.installtimeFmt']: "", + ['form.workmsg']: "", + ['form.description']: "" + }) - }, + const { + fileList = [] + } = _this.data; + if (formObject.photopath1 != "") { + var file1 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath1 + } + fileList.push(file1) + } + if (formObject.photopath2 != "") { + var file2 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath2 + } + fileList.push(file2) + } + if (formObject.photopath3 != "") { + var file3 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath3 + } + fileList.push(file3) + } + _this.setData({ + fileList + }); + } + var installtime = 'form.installtimeFmt'; + var dateNow = this.formatDate(); + this.setData({ + installtimeFmt: dateNow, + [installtime]: dateNow, + }); + }, - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, - }, + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + wx.removeStorageSync('resultObject') + }, - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, - }, + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { + }, - }, + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { + }, - }, + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { + }, - }, + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + }, - /** - * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true - **/ + /** + * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true + **/ - isNumber: function (val) { + isNumber: function (val) { - var regPos = /^[0-9]*$/; //非负浮点数 - var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数 - if (regPos.test(val) || regNeg.test(val)) { - return false; - } else { - return true; - } + var regPos = /^[0-9]*$/; //非负浮点数 + var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数 + if (regPos.test(val) || regNeg.test(val)) { + return false; + } else { + return true; + } - }, + }, - formValidate() { + formValidate() { - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } - if (this.data.form.wellcode == "") { - wx.showToast({ - icon: 'none', - title: '井编号不能为空!', - }) - return false - } - if (this.data.form.devicetype == "") { - wx.showToast({ - icon: 'none', - title: '设备类型不能为空!', - }) - return false - } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + if (this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '设备编号不能为空!', + }) + return false + } + if (this.data.form.wellcode == "") { + wx.showToast({ + icon: 'none', + title: '井编号不能为空!', + }) + return false + } + if (this.data.form.devicetype == "") { + wx.showToast({ + icon: 'none', + title: '设备类型不能为空!', + }) + return false + } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null || - this.data.form.installperson == '') { - wx.showToast({ - icon: 'none', - title: '运维人员不能为空!', - }) - return false - } - if (this.data.form.project == "") { - wx.showToast({ - icon: 'none', - title: '所属项目不能为空!', - }) - return false - } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } + if (this.data.form.installperson == null || + this.data.form.installperson == '') { + wx.showToast({ + icon: 'none', + title: '运维人员不能为空!', + }) + return false + } + if (this.data.form.project == "") { + wx.showToast({ + icon: 'none', + title: '所属项目不能为空!', + }) + return false + } - if (this.data.form.welldepth != null) { - if (this.isNumber(this.data.form.welldepth)) { - wx.showToast({ - icon: 'none', - title: '井深必须为数值!', - }) - return false - } - } - if (this.data.form.installheigt != null) { - if (this.isNumber(this.data.form.installheigt)) { - wx.showToast({ - icon: 'none', - title: '到井口距离必须为数值!', - }) - return false - } - } - - return true; - }, - - changeMsg: function () { - var formNew = this.data.form; - var formOld = JSON.parse(this.data.detail); - var descpNew = ""; - if (formNew.devcode != formOld.devcode) { - descpNew += "修改设备编号,原编号:" + formOld.devcode + ",新编号:" + formNew.devcode + ";" - } - if (formNew.devicetype != formOld.devicetype) { - descpNew += "修改设备类型,原设备类型:" + formOld.devicetype + ",新设备类型:" + formNew.devicetype + ";" - } - if (formNew.area != formOld.area) { - descpNew += "修改区,原区:" + formOld.area + ",新区:" + formNew.area + ";" - } - if (formNew.street != formOld.street) { - descpNew += "修改街道,原街道:" + formOld.street + ",新街道:" + formNew.street + ";" - } - if (formNew.wellname != formOld.wellname) { - descpNew += "修改井名称,原井名称:" + formOld.wellname + ",新井名称:" + formNew.wellname + ";" - } - if (formNew.factory != formOld.factory) { - descpNew += "修改权属单位,原权属单位:" + formOld.factory + ",新权属单位:" + formNew.factory + ";" - } - if (formNew.installheigt != formOld.installheigt) { - descpNew += "修改井口距离,原井口距离:" + formOld.installheigt + ",新井口距离:" + formNew.installheigt + ";" - } - if (formNew.installperson != formOld.installperson) { - descpNew += "修改运维人员,原运维人员:" + formOld.installperson + ",新运维人员:" + formNew.installperson + ";" - } - if (formNew.latitude != formOld.latitude) { - descpNew += "修改纬度,原纬度:" + formOld.latitude + ",新纬度:" + formNew.latitude + ";" - } - if (formNew.longitude != formOld.longitude) { - descpNew += "修改经度,原经度:" + formOld.longitude + ",新经度:" + formNew.longitude + ";" - } - if (formNew.position != formOld.position) { - descpNew += "修改位置描述,原位置:" + formOld.position + ",新位置:" + formNew.position + ";" - } - if (formNew.wellcode != formOld.wellcode) { - descpNew += "修改井编号,原编号:" + formOld.wellcode + ",新编号:" + formNew.wellcode + ";" - } - if (formNew.welldepth != formOld.welldepth) { - descpNew += "修改井深,原井深:" + formOld.welldepth + ",新井深:" + formNew.welldepth + ";" - } - if (formNew.welltype != formOld.welltype) { - descpNew += "修改井类型,原井类型:" + formOld.welltype + ",新井类型:" + formNew.welltype + ";" - } - if (formNew.project != formOld.project) { - descpNew += "修改所属项目,原项目:" + formOld.project + ",新项目:" + formNew.project + ";" - } - if (this.data.photopath1 != formOld.photopath1 || - this.data.photopath2 != formOld.photopath2 || - this.data.photopath3 != formOld.photopath3) { - descpNew += "修改照片;" - } - if ("" != formNew.description) { - descpNew += formNew.description; - } - this.setData({ - ['form.description']: descpNew + if (this.data.form.welldepth != null) { + if (this.isNumber(this.data.form.welldepth)) { + wx.showToast({ + icon: 'none', + title: '井深必须为数值!', }) - }, + return false + } + } + if (this.data.form.installheigt != null) { + if (this.isNumber(this.data.form.installheigt)) { + wx.showToast({ + icon: 'none', + title: '到井口距离必须为数值!', + }) + return false + } + } - formSubmit: function (event) { + return true; + }, - if (!this.formValidate()) { - return false; - } - this.changeMsg(); - var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDeviceLog', - data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceLog/add" - }, - }).then(res => { - // var resultObj=JSON.parse(res.result); - if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - if (res.confirm) { - wx.switchTab({ - url: that.data.pageName - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) - } - }).catch(err => { - console.error(err) - wx.showToast({ - title: "提交失败", - }) - }) - }, - confirm(event) { - var that = this; - var formValue = event.detail.value; - var formName = event.target.dataset.id; - var fromN = 'form.' + [formName]; - that.setData({ - [fromN]: formValue - }) - }, + //获取与上次修改的信息 + changeMsg: function () { + var formNew = this.data.form; + console.log(this.data.detail) + var formOld = JSON.parse(this.data.detail); + var descpNew = ""; + if (formNew.devcode != formOld.devcode) { + descpNew += "修改设备编号,原值:" + formOld.devcode + ",新值:" + formNew.devcode + ";" + } + if (formNew.devicetype != formOld.devicetype) { + descpNew += "修改设备类型,原值:" + formOld.devicetype + ",新值:" + formNew.devicetype + ";" + } + if (formNew.area != formOld.area) { + descpNew += "修改区,原值:" + formOld.area + ",新值:" + formNew.area + ";" + } + if (formNew.street != formOld.street) { + descpNew += "修改街道,原值:" + formOld.street + ",新值:" + formNew.street + ";" + } + if (formNew.wellname != formOld.wellname) { + descpNew += "修改井名称,原值:" + formOld.wellname + ",新值:" + formNew.wellname + ";" + } + if (formNew.factory != formOld.factory) { + descpNew += "修改权属单位,原值:" + formOld.factory + ",新值:" + formNew.factory + ";" + } + if (formNew.installheigt != formOld.installheigt) { + descpNew += "修改井口距离,原值:" + formOld.installheigt + ",新值:" + formNew.installheigt + ";" + } + if (formNew.installperson != formOld.installperson) { + descpNew += "修改运维人员,原值:" + formOld.installperson + ",新值:" + formNew.installperson + ";" + } + if (formNew.latitude != formOld.latitude) { + descpNew += "修改纬度,原值:" + formOld.latitude + ",新值:" + formNew.latitude + ";" + } + if (formNew.longitude != formOld.longitude) { + descpNew += "修改经度,原值:" + formOld.longitude + ",新值:" + formNew.longitude + ";" + } + if (formNew.position != formOld.position) { + descpNew += "修改位置描述,原值:" + formOld.position + ",新值:" + formNew.position + ";" + } + if (formNew.wellcode != formOld.wellcode) { + descpNew += "修改井编号,原值:" + formOld.wellcode + ",新值:" + formNew.wellcode + ";" + } + if (formNew.welldepth != formOld.welldepth) { + descpNew += "修改井深,原值:" + formOld.welldepth + ",新值:" + formNew.welldepth + ";" + } + if (formNew.welltype != formOld.welltype) { + descpNew += "修改井类型,原值:" + formOld.welltype + ",新值:" + formNew.welltype + ";" + } + if (formNew.project != formOld.project) { + descpNew += "修改所属项目,原值:" + formOld.project + ",新值:" + formNew.project + ";" + } + if (this.data.form.photopath1 != formOld.photopath1 || + this.data.form.photopath2 != formOld.photopath2 || + this.data.form.photopath3 != formOld.photopath3) { + descpNew += "修改照片;" + } + if ("" != formNew.description) { + descpNew += formNew.description; + } + this.setData({ + ['form.description']: descpNew + }) + }, - scan() { + //提交表单 + formSubmit: function (event) { - wx.scanCode({ - success(res) { - console.log(res) - } - }) + //表单验证 + if (!this.formValidate()) { + return false; + } + //自动生成修改内容 + this.changeMsg(); + //提交权限限制(只有施工人员能修改) + if(app.globalData.role!='repair'){ + wx.showToast({ + icon: 'none', + title: '无权限修改', + duration:2000 + }) + return false + } + var that = this; + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopath = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopath]: fileList[i].url.split("static/")[1] + }) + } + delete that.data.form.installtime + delete that.data.form.createtime + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - paste() { - var _this = this; - wx.getClipboardData({ - success: function (res) { - var longitude = 'form.longitude'; - var latitude = 'form.latitude'; - var longitude84 = 'form.longitude84'; - var latitude84 = 'form.latitude84'; - _this.setData({ - [longitude]: parseFloat(res.data.split(",", 4)[1]).toFixed(6), - [latitude]: parseFloat(res.data.split(",", 4)[0]).toFixed(6), - [longitude84]: "" == (res.data.split(",", 4)[3]) ? "" : parseFloat(res.data.split(",", 4)[3]).toFixed(6), - [latitude84]: "" == (res.data.split(",", 4)[2]) ? "" : parseFloat(res.data.split(",", 4)[2]).toFixed(6), - longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), - latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), - }); - } - }) - }, - selectValue(value) { - var that = this; - var wellType = 'form.welltype'; - that.setData({ - [wellType]: value.detail - }) - }, - selectpersonValue(event) { - var that = this; - var installPerson = 'form.installperson'; - that.setData({ - [installPerson]: event.detail - }) - }, - selectprojectValue(event) { - var that = this; - var project = 'form.project'; - that.setData({ - [project]: event.detail, - showMask: true - }) - }, - open() { - this.setData({ - showMask: true - }) - }, - close() { - this.setData({ - showMask: false - }) - }, - afterRead(event) { - var _this = this; - const { - file - } = event.detail; - const { - fileList = [] - } = _this.data; - var convertpath = ""; - wx.compressImage({ - src: event.detail.file.path, - quality: 25, - success: function (res) { - convertpath = res.tempFilePath; - wx.uploadFile({ - url: app.globalData.httpsUrl + "appDeviceAdd/fileUploadMarker", - filePath:convertpath, - name: 'file', - formData: { - 'text': "编号:" + _this.data.form.devcode + "经度:" + _this.data.form.longitude + "纬度:" + _this.data.form.latitude - }, - header: { - "Content-Type": "multipart/form-data", - 'accept': 'application/json', - }, - success(res) { - if (res.data) { - var url = JSON.parse(res.data); - fileList.push({ - ...file, - url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - }); - _this.setData({ - fileList - }); - } - } + success(res) { + if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + if (res.confirm) { + wx.switchTab({ + url: that.data.pageName }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') } - }) - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // // var base64 = "data:image/png;base64," + wx.getFileSystemManager().readFileSync(convertpath, 'base64'); - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: convertpath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // // wx.cloud.callFunction({ - // // name: 'uploadFile', - // // data: { - // // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // // fileBase64: base64 - // // }, - // // success: function (res) { - // // if (res.result) { - // // fileList.push({ - // // ...file, - // // url: app.globalData.url + "static/" + res.result.data.replace(/\\/g, "/") - // // }); - // // _this.setData({ - // // fileList - // // }); - // // } - // // }, - // // complete: res => { - // // }, - // // }) - // } - // }); + } + }) + } + }, + fail(err) { + wx.showToast({ + title: "提交失败", + }) + } + }) + }, + //报存录入的input信息 + confirm(event) { + var that = this; + var formValue = event.detail.value; + var formName = event.target.dataset.id; + var fromN = 'form.' + [formName]; + that.setData({ + [fromN]: formValue + }) + }, + + //扫码 + scan() { + + wx.scanCode({ + success(res) { + console.log(res) + } + }) + }, + //粘贴经纬度 + paste() { + var _this = this; + wx.getClipboardData({ + success: function (res) { + var longitude = 'form.longitude'; + var latitude = 'form.latitude'; + var longitude84 = 'form.longitude84'; + var latitude84 = 'form.latitude84'; + _this.setData({ + [longitude]: parseFloat(res.data.split(",", 4)[1]).toFixed(6), + [latitude]: parseFloat(res.data.split(",", 4)[0]).toFixed(6), + [longitude84]: "" == (res.data.split(",", 4)[3]) ? "" : parseFloat(res.data.split(",", 4)[3]).toFixed(6), + [latitude84]: "" == (res.data.split(",", 4)[2]) ? "" : parseFloat(res.data.split(",", 4)[2]).toFixed(6), + longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), + latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), + }); + } + }) + }, + selectValue(value) { + var that = this; + var wellType = 'form.welltype'; + that.setData({ + [wellType]: value.detail + }) + }, + //运维人员默认为登录人 + // selectpersonValue(event) { + // var that = this; + // var installPerson = 'form.installperson'; + // that.setData({ + // [installPerson]: event.detail + // }) + // }, + selectprojectValue(event) { + var that = this; + var project = 'form.project'; + that.setData({ + [project]: event.detail, + showMask: true + }) + }, + + open() { + this.setData({ + showMask: true + }) + }, + //隐藏textarea,防止遮挡 + close() { + this.setData({ + showMask: false + }) + }, + //上传照片 + afterRead(event) { + var _this = this; + const { + file + } = event.detail; + const { + fileList = [] + } = _this.data; + var convertpath = ""; + wx.compressImage({ + src: event.detail.file.path, + quality: 25, + success: function (res) { + convertpath = res.tempFilePath; + wx.uploadFile({ + url: app.globalData.httpsUrl + "appDeviceAdd/fileUploadMarker", + filePath: convertpath, + name: 'file', + formData: { + 'text': "编号:" + _this.data.form.devcode + "经度:" + _this.data.form.longitude + "纬度:" + _this.data.form.latitude }, - deletePhoto(event) { - var that = this - var image_index = event.detail.index - var fileList_new = that.data.fileList; - wx.showModal({ - content: '确定删除照片?', - success: function (res) { - if (res.confirm) { - fileList_new.splice(image_index, 1); - that.setData({ - fileList: fileList_new - }) - wx.cloud.callFunction({ - name: 'deletePhoto', - data: { - url: app.globalData.url + "appDeviceLog/deletePhoto", - devcode: that.data.form.devcode, - pathIndex: image_index - }, - success: function (res) {}, - complete: res => {}, - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + "Content-Type": "multipart/form-data", + 'accept': 'application/json', }, - }) \ No newline at end of file + success(res) { + if (res.data) { + var url = JSON.parse(res.data); + fileList.push({ + ...file, + url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") + }); + _this.setData({ + fileList + }); + } + } + }) + } + }) + }, + //删除照片 + deletePhoto(event) { + var that = this + var image_index = event.detail.index + var fileList_new = that.data.fileList; + wx.showModal({ + content: '确定删除照片?', + success: function (res) { + if (res.confirm) { + fileList_new.splice(image_index, 1); + that.setData({ + fileList: fileList_new + }) + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deletePhoto", + data: { + devcode: that.data.form.devcode + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) {} + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } +}) \ No newline at end of file diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.wxml b/miniprogram/pages/addDevicelog/addDeviceLog.wxml index 38620d4..b10cc7d 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.wxml +++ b/miniprogram/pages/addDevicelog/addDeviceLog.wxml @@ -1,15 +1,21 @@ - + + + + + - + - - + + - - + + - + @@ -39,24 +45,25 @@ - - - + + + - + - + + @@ -64,7 +71,7 @@ - + @@ -79,9 +86,9 @@ - + - 保存 + 保存 diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.wxss b/miniprogram/pages/addDevicelog/addDeviceLog.wxss index ee0b75c..08d5fd7 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.wxss +++ b/miniprogram/pages/addDevicelog/addDeviceLog.wxss @@ -24,6 +24,17 @@ display: flex; align-items: center; } +.map-view{ + width: 750rpx; + height: 485rpx; + position: fixed; + top: 0px; + left: 0px; + z-index: 999; +} +.content{ + margin-top: 495rpx; +} .left { width: 210rpx; diff --git a/miniprogram/pages/addFunction/addFunction.js b/miniprogram/pages/addFunction/addFunction.js deleted file mode 100644 index 4966be3..0000000 --- a/miniprogram/pages/addFunction/addFunction.js +++ /dev/null @@ -1,60 +0,0 @@ -// pages/addFunction/addFunction.js - -const code = `// 云函数入口函数 -exports.main = (event, context) => { - console.log(event) - console.log(context) - return { - sum: event.a + event.b - } -}` - -Page({ - - data: { - result: '', - canIUseClipboard: wx.canIUse('setClipboardData'), - }, - - onLoad: function (options) { - - }, - - copyCode: function() { - wx.setClipboardData({ - data: code, - success: function () { - wx.showToast({ - title: '复制成功', - }) - } - }) - }, - - testFunction() { - wx.cloud.callFunction({ - name: 'sum', - data: { - a: 1, - b: 2 - }, - success: res => { - wx.showToast({ - title: '调用成功', - }) - this.setData({ - result: JSON.stringify(res.result) - }) - }, - fail: err => { - wx.showToast({ - icon: 'none', - title: '调用失败', - }) - console.error('[云函数] [sum] 调用失败:', err) - } - }) - }, - -}) - diff --git a/miniprogram/pages/addFunction/addFunction.json b/miniprogram/pages/addFunction/addFunction.json deleted file mode 100644 index a9a50c5..0000000 --- a/miniprogram/pages/addFunction/addFunction.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "navigationBarTitleText": "云函数指引", - "usingComponents": {} -} \ No newline at end of file diff --git a/miniprogram/pages/addFunction/addFunction.wxml b/miniprogram/pages/addFunction/addFunction.wxml deleted file mode 100644 index 3a10626..0000000 --- a/miniprogram/pages/addFunction/addFunction.wxml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - 测试云函数 - - - 期望输出:{"sum":3} - - - 调用结果:{{result}} - - - - - 新增云函数 - 1. 在云函数根目录 cloudfunctions 上右键选择新建云函数,命名为 sum - 2. 在创建的 cloudfunctions/sum/index.js 文件中添加如下代码 - - - 3. 在 cloudfunctions/sum 目录上右键上传并部署 - 4. 点击测试云函数测试 - 5. 打开云开发云函数管理页,选择 sum 云函数 - 6. 查看 sum 的调用日志 - 进阶:可在云函数中使用 wx-server-sdk 操作数据库,文件存储和调用其他云函数,详见文档 - - - diff --git a/miniprogram/pages/addFunction/addFunction.wxss b/miniprogram/pages/addFunction/addFunction.wxss deleted file mode 100644 index 7ac8619..0000000 --- a/miniprogram/pages/addFunction/addFunction.wxss +++ /dev/null @@ -1,3 +0,0 @@ -/* pages/addFunction/addFunction.wxss */ - -@import "../../style/guide.wxss"; \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.js b/miniprogram/pages/applog/applog.js index 0e8c185..189e61f 100644 --- a/miniprogram/pages/applog/applog.js +++ b/miniprogram/pages/applog/applog.js @@ -13,98 +13,25 @@ isSeach: "false", params: {}, total: 0, - show: false + show: false, + delBtnWidth: 100, //删除按钮宽度单位(rpx) + activeIndex: -1, + list_style: '' }, - - touchE: function (e) { - // console.log(e); - var that = this - if (e.changedTouches.length == 1) { - //手指移动结束后触摸点位置的X坐标 - var endX = e.changedTouches[0].clientX; - //触摸开始与结束,手指移动的距离 - var disX = that.data.startX - endX; - var delBtnWidth = that.data.delBtnWidth; - //如果距离小于删除按钮的1/2,不显示删除按钮 - var txtStyle = disX > delBtnWidth / 2 ? "left:-" + delBtnWidth + "rpx" : "left:0rpx"; - - //获取手指触摸的是哪一项 - var index = e.currentTarget.dataset.index; - var list = that.data.deviceloglist; - list[index].txtStyle = txtStyle; - //更新列表的状态 - that.setData({ - deviceloglist: list - }); - } - }, - //手指触摸动作开始 记录起点X坐标 - touchstart: function (e) { - //开始触摸时 重置所有删除 - this.data.deviceloglist.forEach(function (v, i) { - if (v.isTouchMove) //只操作为true的 - v.isTouchMove = false; - }) - this.setData({ - startX: e.changedTouches[0].clientX, - startY: e.changedTouches[0].clientY, - deviceloglist: this.data.deviceloglist - }) - }, - //滑动事件处理 - touchmove: function (e) { - var that = this, - index = e.currentTarget.dataset.index, //当前索引 - startX = that.data.startX, //开始X坐标 - startY = that.data.startY, //开始Y坐标 - touchMoveX = e.changedTouches[0].clientX, //滑动变化坐标 - touchMoveY = e.changedTouches[0].clientY, //滑动变化坐标 - //获取滑动角度 - angle = that.angle({ - X: startX, - Y: startY - }, { - X: touchMoveX, - Y: touchMoveY - }); - that.data.deviceloglist.forEach(function (v, i) { - v.isTouchMove = false - //滑动超过30度角 return - if (Math.abs(angle) > 30) return; - if (i == index) { - if (touchMoveX > startX) //右滑 - v.isTouchMove = false - else //左滑 - v.isTouchMove = true - } - }) - //更新数据 - that.setData({ - deviceloglist: that.data.deviceloglist - }) - }, - /** - * 计算滑动角度 - * @param {Object} start 起点坐标 - * @param {Object} end 终点坐标 - */ - angle: function (start, end) { - var _X = end.X - start.X, - _Y = end.Y - start.Y - //返回角度 /Math.atan()返回数字的反正切值 - return 360 * Math.atan(_Y / _X) / (2 * Math.PI); - }, - /** - * 生命周期函数--监听页面加载var_this=this; - */ onLoad: function (options) { - if (options.params) { this.setData({ params: JSON.parse(options.params), isSeach: "true" }) this.initPages() + }else{ + this.setData({ + show: false + }) + //清空参数,重新加载 + this.clearParams(); + this.initPages(); } }, @@ -116,20 +43,33 @@ }, + //点击tabBar事件 + onTabItemTap(item) { + //隐藏历史显示总记录条数 + this.setData({ + show: false + }) + //清空参数,重新加载 + this.clearParams(); + this.initPages(); + }, + + /** * 生命周期函数--监听页面显示 */ onShow: function (options) { - this.setData({ - show:false - }) - if (this.data.isSeach == "false") { - this.clearParams(); - this.initPages(); - } - this.setData({ - isSeach: "false" - }) + + // this.setData({ + // show: false + // }) + // if (this.data.isSeach == "false") { + // this.clearParams(); + // this.initPages(); + // } + // this.setData({ + // isSeach: "false" + // }) }, /** @@ -167,6 +107,119 @@ }, + + //手指触摸动作开始 记录起点X坐标 + touchstart: function (e) { + //开始触摸时 重置所有删除 + this.data.deviceloglist.forEach(function (v, i) { + if (v.isTouchMove) //只操作为true的 + v.isTouchMove = false; + }) + this.setData({ + startX: e.changedTouches[0].clientX, + startY: e.changedTouches[0].clientY, + deviceloglist: this.data.deviceloglist + }) + }, + + //滑动事件处理 + touchmove: function (e) { + var that = this, + index = e.currentTarget.dataset.index, //当前索引 + startX = that.data.startX, //开始X坐标 + startY = that.data.startY, //开始Y坐标 + touchMoveX = e.changedTouches[0].clientX, //滑动变化坐标 + touchMoveY = e.changedTouches[0].clientY, //滑动变化坐标 + //获取滑动角度 + angle = that.angle({ + X: startX, + Y: startY + }, { + X: touchMoveX, + Y: touchMoveY + }); + that.data.deviceloglist.forEach(function (v, i) { + // v.isTouchMove = false + //滑动超过30度角 return + if (Math.abs(angle) > 30) return; + if (i == index) { + if (touchMoveX > startX) //右滑 + v.isTouchMove = false + else //左滑 + v.isTouchMove = true + } + }) + //更新数据 + that.setData({ + deviceloglist: that.data.deviceloglist + }) + }, + + /** + * 计算滑动角度 + * @param {Object} start 起点坐标 + * @param {Object} end 终点坐标 + */ + angle: function (start, end) { + var _X = end.X - start.X, + _Y = end.Y - start.Y + //返回角度 /Math.atan()返回数字的反正切值 + return 360 * Math.atan(_Y / _X) / (2 * Math.PI); + }, + + //删除事件 + delItem: function (e) { + if(app.globalData.role!='repair'){ + wx.showToast({ + icon: 'none', + title: '无权限删除', + duration:2000 + }) + return false + } + var that = this + wx.showModal({ + content: '是否删除?', + success: function (res) { + if (res.confirm) { + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/delete", + data: { + appDeviceAddId: e.currentTarget.dataset.devid + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if(res.data.code=='200'){ + that.data.deviceloglist.splice(e.currentTarget.dataset.index, 1) + that.setData({ + deviceloglist: that.data.deviceloglist, + total: that.data.deviceloglist.length + }) + wx.showToast({ + title: '删除成功!', + icon: 'none', + duration: 1000 + }) + } + }, + fail(err) { + wx.showToast({ + title: '删除失败!', + icon: 'none', + duration: 2000 + }) + } + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + }, + showLoading: function (message) { if (wx.showLoading) { // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 @@ -199,95 +252,105 @@ deviceloglist: [] }) }, + //查询列表数据 initPages: function () { var that = this + that.setData({ + show: false + }) var offsetValue = that.data.deviceloglist.length % 15 > 0 ? parseInt(that.data.deviceloglist.length / 15) + 2 : parseInt(that.data.deviceloglist.length / 15) + 1 - wx.cloud.callFunction({ - name: 'devicelog', + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/listPage", data: { devcode: that.data.params.devcode, devtype: that.data.params.devtype, installtimeFmt: that.data.params.installtimeFmt, project: that.data.params.project, installPerson: that.data.params.installPerson, - url: app.globalData.url + "appDeviceLog/listPage", limit: 15, offset: offsetValue }, - }).then(res => { - if (res.result.data.rows.length > 0) { - var resultJson = res.result - that.setData({ - deviceloglist: that.data.deviceloglist.concat(resultJson.data.rows) - }) - } else if (that.data.deviceloglist.length > 0) { - that.setData({ - show: true, - total: that.data.deviceloglist.length - }) - wx.showToast({ - title: '数据已全部加载完', - icon: 'none', - duration: 2000 - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.data.rows.length > 0) { + var resultJson = res.data + var listArr = resultJson.data.rows + listArr.forEach(function (v, i) { + listArr[i]['isTouchMove'] = false + }) + that.setData({ + deviceloglist: that.data.deviceloglist.concat(listArr) + }) + } else if (that.data.deviceloglist.length > 0) { + that.setData({ + show: true, + total: that.data.deviceloglist.length + }) + wx.showToast({ + title: '数据已全部加载完', + icon: 'none', + duration: 2000 + }) + } + if (offsetValue == 1 && res.data.data.rows.length < 15) { + that.setData({ + show: true, + total: that.data.deviceloglist.length + }) + } } - if(offsetValue==1&&res.result.data.rows.length<15){ - that.setData({ - show: true, - total: that.data.deviceloglist.length - }) - } - // console.log(res); - }).catch(err => { - console.error(err); }) + }, addDetail: function (event) { - this.showLoading("数据请求中..."); - wx.cloud.callFunction({ - name: 'deviceDetail', + var that = this + that.showLoading("数据请求中..."); + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deviceDetail", data: { devcode: event.target.dataset.devcode, - url: app.globalData.url + "appDeviceLog/deviceDetail", }, - }).then(res => { - this.hideLoading(); - var resultObject = JSON.parse(res.result); - var pageName = '../applog/applog' - if (resultObject.code == 200) { - wx.navigateTo({ - url: '../addDevicelog/addDeviceLog?detail=' + - JSON.stringify(resultObject.data) + "&pageName=" + pageName - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + that.hideLoading(); + // var resultObject = JSON.parse(res.data); + var resultObject = res.data; + var pageName = '../applog/applog' + if (resultObject.code == 200) { + wx.setStorageSync('resultObject', resultObject.data) + wx.navigateTo({ + url: '../addDevicelog/addDeviceLog?detail=' + "&pageName=" + pageName + }) + } + }, + fail(err) { + that.hideLoading(); } - }).catch(err => { - this.hideLoading() }) + }, add: function (event) { - wx.reLaunch({ - url: '../earth/earth?devcode=' + event.target.dataset.devcode - // url: '../earth/earth' + app.globalData.devcode = event.target.dataset.devcode; + wx.switchTab({ + url: '../earth/earth' }) + // wx.reLaunch({ + // url: '../earth/earth?devcode=' + event.target.dataset.devcode + // // url: '../earth/earth' + // }) }, onSearch: function () { + var _this = this wx.navigateTo({ - url: '../searchLog/searchLog' + url: '../searchLog/searchLog?params=' + JSON.stringify(_this.data.params) }) - }, - // initPages: function () { - // wx.cloud.callFunction({ - // name: 'devicelog' - // }).then(res => { - // var that = this; - // var jsonList = JSON.parse(res.result) - // that.setData({ - // deviceloglist: jsonList.data.rows - // }) - // console.log(res); - // }).catch(err => { - // console.error(err); - // }) - // } + } }) \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.wxml b/miniprogram/pages/applog/applog.wxml index e9a2352..2bfd041 100644 --- a/miniprogram/pages/applog/applog.wxml +++ b/miniprogram/pages/applog/applog.wxml @@ -1,54 +1,59 @@ - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {{item.devcode}} {{item.devicetype}} + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + {{item.devcode}} {{item.devicetype}} + + {{item.project}} {{item.installtime}}- {{item.installperson}} - - - - - + + + + + + 删除 - - - + + - 共计:{{total}}台 - + 共计:{{total}}台 + \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.wxss b/miniprogram/pages/applog/applog.wxss index 6d3428b..e6e8983 100644 --- a/miniprogram/pages/applog/applog.wxss +++ b/miniprogram/pages/applog/applog.wxss @@ -22,16 +22,18 @@ position: fixed; width: 100%; top: 0rpx; + z-index: 9999; /* margin-bottom: 100rpx; */ } .log-list { /* height: 100rpx; */ - /* display: flex; */ - + display: flex; + width: 100%; padding: 2px; margin-top: 2px; border-bottom: 1px solid #e5e5e5; + overflow: hidden } @@ -53,23 +55,29 @@ left: 35%; margin: 20rpx } - .del { - width: 90px; + /* display: flex; */ + width: 100rpx; display: flex; flex-direction: column; align-items: center; justify-content: center; - color: #fff; - -webkit-transform: translateX(90px); - transform: translateX(90px); - -webkit-transition: all 0.4s; + /* -webkit-transform: translateX(100rpx); */ + transform: translateX(100rpx); + /* -webkit-transition: all 0.4s; */ transition: all 0.4s; - font-size: 35rpx; + color: #fff; + background-color: #fe3e2f; +} +.logrow{ + width: 100%; + transform: translateX(100rpx); + /* -webkit-transform: translateX(100px); */ + margin-left: -100rpx; } -.touch-move-active .content, +.touch-move-active .logrow, .touch-move-active .del { - -webkit-transform: translateX(0); - transform: translateX(0); +/* -webkit-transform: translateX(0); */ +transform: translateX(0); } \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.js b/miniprogram/pages/deployFunctions/deployFunctions.js deleted file mode 100644 index a76b144..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.js +++ /dev/null @@ -1,66 +0,0 @@ -// pages/deployFunctions/deployFunctions.js -Page({ - - /** - * 页面的初始数据 - */ - data: { - - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - - }, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { - - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - - }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { - - }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { - - } -}) \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.json b/miniprogram/pages/deployFunctions/deployFunctions.json deleted file mode 100644 index 7fbedab..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "navigationBarTitleText": "部署云函数", - "usingComponents": {} -} \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.wxml b/miniprogram/pages/deployFunctions/deployFunctions.wxml deleted file mode 100644 index 462b6b6..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.wxml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - 调用失败 - - - 请检查 login 云函数是否已部署 - - - - - 部署 login 云函数 - 1. 确保已通过工具栏云开发入口开通云开发 - 2. 在 cloudfunctions/login 目录上右键上传并部署 - 3. 回到首页,重新点击获取 openid - - - - diff --git a/miniprogram/pages/deployFunctions/deployFunctions.wxss b/miniprogram/pages/deployFunctions/deployFunctions.wxss deleted file mode 100644 index c8803e6..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.wxss +++ /dev/null @@ -1,7 +0,0 @@ -/* pages/deployFunctions/deployFunctions.wxss */ - -@import "../../style/guide.wxss"; - -.black { - color: black; -} \ No newline at end of file diff --git a/miniprogram/pages/earth/earth.js b/miniprogram/pages/earth/earth.js index ae0d3f3..376a6e2 100644 --- a/miniprogram/pages/earth/earth.js +++ b/miniprogram/pages/earth/earth.js @@ -21,19 +21,12 @@ show: false, enableSsatellite: false, windowWidth: 0, - longitude: 113.324520, - latitude: 23.099994, - longitude84: 113.324520, - latitude84: 23.099994, - markers: [{ - id: 0, - iconPath: "../../images/locat.png", - latitude: 23.099994, - longitude: 113.324520, - width: 50, - height: 50 - }], - controls: [], + longitude: "116.627340", + latitude: "39.874390", + longitude84: "", + latitude84: "", + markers: [], + controls: [] }, /** @@ -41,39 +34,13 @@ */ onLoad: function (options) { var that = this; - //获取当前坐标(gcj02) - wx.getLocation({ - type: "gcj02", - altitude: true, - success: function (res) { - that.setData({ - latitude: parseFloat(res.latitude).toFixed(6), - longitude: parseFloat(res.longitude).toFixed(6), - // markers: [{ - // latitude: res.latitude, - // longitude: res.longitude, - // }] - }) - //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 - wx.getLocation({ - type: "wgs84", - altitude: true, - success: function (res) { - that.setData({ - latitude84: parseFloat(res.latitude).toFixed(6), - longitude84: parseFloat(res.longitude).toFixed(6) - }) - } - }) - } - }), - - //设置地图组件 - wx.getSystemInfo({ + //设置地图组件 + wx.getSystemInfo({ success(res) { var windowWidth = res.windowWidth var windowHeight = res.windowHeight var query = wx.createSelectorQuery() + var platform =res.platform query.select('#map').boundingClientRect() query.exec(function (res) { that.setData({ @@ -139,10 +106,20 @@ clickable: true }, { id: 7, - iconPath: '../../images/locat.png', + iconPath: '../../images/applocat.png', position: { - left: res[0].width/2, - top: res[0].height/2, + left: res[0].width / 2 - 20, + top: platform=="ios"?res[0].height / 2 - 80:res[0].height / 2 - 40, + width: 40, + height: 40 + }, + clickable: true + }, { + id: 8, + iconPath: '../../images/back.png', + position: { + left: windowWidth - 40, + top: windowHeight - 140, width: 30, height: 30 }, @@ -150,71 +127,15 @@ }] }) }) - + } - }), + }) + // 实例化API核心类 qqmapsdk = new QQMapWX({ key: 'BGPBZ-C5O3P-ROUDR-LWC4J-63EKH-V5FRX' }) - - if (options.devcode) { - var that = this - var devcode = options.devcode - wx.cloud.callFunction({ - name: 'findListByCodes', - data: { - devcodes: devcode, - url: app.globalData.url + "appDeviceAdd/findListByCodes" - }, - }).then(res => { - if (res.result.code == 200) { - var listResultData = res.result.data; - that.setData({ - listData: listResultData - }) - var markersArr = that.data.markers; - for (var i = 0; i < listResultData.length; i++) { - markersArr = markersArr.concat({ - iconPath: "../../images/locat.png", - id: listResultData[i].id, - callout: { - content: listResultData[i].devcode, - fontSize: '14', - // padding: true, - color: '#00000', - borderColor: '#F4EA2A', - bgColor: '#F4EA2A', - borderWidth: 5, - display: 'ALWAYS', - textAlign: 'center', - // borderRadius: 15 - }, - latitude: listResultData[i].latitude, - longitude: listResultData[i].longitude, - width: 40, - height: 40 - }); - } - this.setData({ - markers: markersArr, - latitude: listResultData[0].latitude, - longitude: listResultData[0].longitude, - marker_latitude: listResultData[0].latitude, - marker_longitude: listResultData[0].longitude, - title: listResultData[0].devcode - }) - } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "无法获取设备地理信息!", - icon: 'none', - duration: 2000 - }) - }) - } }, /** @@ -228,6 +149,97 @@ * 生命周期函数--监听页面显示 */ onShow: function () { + //输入设备编号获取marker位置信息 + var that = this; + if ( app.globalData.devcode!="") { + var devcode = app.globalData.devcode + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/findListByCodes", + data: { + devcodes: devcode, + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + app.globalData.devcode=""; + if (res.data.code == 200) { + var listResultData = res.data.data; + that.setData({ + listData: listResultData + }) + var markersArr = that.data.markers; + for (var i = 0; i < listResultData.length; i++) { + markersArr = markersArr.concat({ + iconPath: "../../images/locat.png", + id: Number(listResultData[i].id), + callout: { + content: "编号:"+listResultData[i].devcode+"\r\n位置:"+listResultData[i].position+"\r\n时间:"+listResultData[i].createtime, + fontSize: '14', + padding: true, + color: '#000000', + borderColor: '#F4EA2A', + bgColor: '#F4EA2A', + borderWidth: 5, + display: 'ALWAYS', + textAlign: 'left', + // borderRadius: 15 + }, + latitude: listResultData[i].latitude, + longitude: listResultData[i].longitude, + width: 40, + height: 40 + }); + } + that.setData({ + markers: markersArr, + latitude: listResultData[0].latitude, + longitude: listResultData[0].longitude, + marker_latitude: listResultData[0].latitude, + marker_longitude: listResultData[0].longitude, + title: listResultData[0].devcode + }) + } + }, + fail(err) { + app.globalData.devcode=""; + wx.showToast({ + title: "无法获取设备地理信息!", + icon: 'none', + duration: 2000 + }) + } + }) +} else { + //获取当前坐标(gcj02) + wx.getLocation({ + type: "gcj02", + altitude: true, + success: function (res) { + that.setData({ + latitude: parseFloat(res.latitude).toFixed(6), + longitude: parseFloat(res.longitude).toFixed(6), + // markers: [{ + // latitude: res.latitude, + // longitude: res.longitude, + // }] + }) + //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 + wx.getLocation({ + type: "wgs84", + altitude: true, + success: function (res) { + that.setData({ + latitude84: parseFloat(res.latitude).toFixed(6), + longitude84: parseFloat(res.longitude).toFixed(6) + }) + } + }) + } + }) +} + }, @@ -265,12 +277,46 @@ onShareAppMessage: function () { }, + + //定位出来 + + locationPosition: function () { + var that = this; + //获取当前坐标(gcj02) + wx.getLocation({ + type: "gcj02", + altitude: true, + success: function (res) { + that.setData({ + latitude: parseFloat(res.latitude).toFixed(6), + longitude: parseFloat(res.longitude).toFixed(6), + // markers: [{ + // latitude: res.latitude, + // longitude: res.longitude + // }] + }) + //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 + wx.getLocation({ + type: "wgs84", + altitude: true, + success: function (res) { + that.setData({ + latitude84: parseFloat(res.latitude).toFixed(6), + longitude84: parseFloat(res.longitude).toFixed(6) + }) + } + }) + } + }) + }, + + //加载地图组件 controltap: function (e) { // console.log(e.controlId); //进入添加设备页 if (1 == e.controlId) { wx.setClipboardData({ - data: this.data.latitude + "," + this.data.longitude+ "," + this.data.latitude84+ "," + this.data.longitude84, + data: this.data.latitude + "," + this.data.longitude + "," + this.data.latitude84 + "," + this.data.longitude84, success: function (res) { wx.getClipboardData({ success: function (res) { @@ -282,6 +328,17 @@ } }) } else if (3 == e.controlId) { + //先定位 + // this.locationPosition() + wx.setClipboardData({ + data: this.data.latitude + "," + this.data.longitude + "," + this.data.latitude84 + "," + this.data.longitude84, + success: function (res) { + wx.showToast({ + title: '坐标已获取', + duration: 1000 + }) + } + }) wx.navigateTo({ url: '../addDevice/addDevice' }) @@ -302,32 +359,15 @@ enableSsatellite: !flag }); } else if (6 == e.controlId) { - var that = this; - //获取当前坐标(gcj02) - wx.getLocation({ - type: "gcj02", - altitude: true, - success: function (res) { - that.setData({ - latitude: parseFloat(res.latitude).toFixed(6), - longitude:parseFloat(res.longitude).toFixed(6), - // markers: [{ - // latitude: res.latitude, - // longitude: res.longitude - // }] - }) - //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 - wx.getLocation({ - type: "wgs84", - altitude: true, - success: function (res) { - that.setData({ - latitude84: parseFloat(res.latitude).toFixed(6), - longitude84: parseFloat(res.longitude).toFixed(6) - }) - } - }) - } + //先清marker + this.setData({ + markers: [] + }) + this.locationPosition() + }else if (8 == e.controlId) { + //跳转日志缓存页 + wx.switchTab({ + url: '../applog/applog', }) } }, @@ -343,63 +383,68 @@ }); }, + //获取设备maker leave() { var that = this; if (that.data.devcodes == "") { return false; } - wx.cloud.callFunction({ - name: 'findListByCodes', + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/findListByCodes", data: { - devcodes: that.data.devcodes, - url: app.globalData.url + "appDeviceAdd/findListByCodes" + devcodes: that.data.devcodes }, - }).then(res => { - if (res.result.code == 200) { - var listResultData = res.result.data; - that.setData({ - listData: listResultData - }) - var markersArr = that.data.markers; - for (var i = 0; i < listResultData.length; i++) { - markersArr = markersArr.concat({ - iconPath: "../../images/locat.png", - id: listResultData[i].id, - callout: { - content: listResultData[i].devcode, - fontSize: '14', - // padding: true, - color: '', - borderColor: '#F4EA2A', - bgColor: '#F4EA2A', - borderWidth: 5, - display: 'ALWAYS', - textAlign: 'center', - // borderRadius: 15 - }, - latitude: listResultData[i].latitude, - longitude: listResultData[i].longitude, - width: 40, - height: 40 - }); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var listResultData = res.data.data; + that.setData({ + listData: listResultData + }) + var markersArr = that.data.markers; + for (var i = 0; i < listResultData.length; i++) { + markersArr = markersArr.concat({ + iconPath: "../../images/locat.png", + id: listResultData[i].id, + callout: { + content: "编号:"+listResultData[i].devcode+"\r\n位置:"+listResultData[i].position+"\r\n时间:"+listResultData[i].createtime, + fontSize: '14', + // padding: true, + color: '#212121', + borderColor: '#F4EA2A', + bgColor: '#F4EA2A', + borderWidth: 5, + display: 'ALWAYS', + textAlign: 'left', + // borderRadius: 15 + }, + latitude: listResultData[i].latitude, + longitude: listResultData[i].longitude, + width: 40, + height: 40 + }); + } + that.setData({ + markers: markersArr, + latitude: listResultData[0].latitude, + longitude: listResultData[0].longitude, + marker_latitude: listResultData[0].latitude, + marker_longitude: listResultData[0].longitude, + title: listResultData[0].devcode + }) } - this.setData({ - markers: markersArr, - latitude: listResultData[0].latitude, - longitude: listResultData[0].longitude, - marker_latitude: listResultData[0].latitude, - marker_longitude: listResultData[0].longitude, - title: listResultData[0].devcode + }, + fail(err) { + wx.showToast({ + title: "无法获取设备地理信息!", + icon: 'none', + duration: 2000 }) } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "无法获取设备地理信息!", - icon: 'none', - duration: 2000 - }) }) }, @@ -422,6 +467,8 @@ } }, + + bindregionchange: function (e) { var that = this if (e.causedBy == "drag") { @@ -445,8 +492,8 @@ that.setData({ latitude: parseFloat(latitude).toFixed(6), longitude: parseFloat(longitude).toFixed(6), - latitude84:"", - longitude84:"", + latitude84: "", + longitude84: "", // markers: markersArr }) // mapCtx.moveToLocation(); @@ -465,16 +512,19 @@ qqmapsdk.search({ keyword: this.data.value, success: function (res) { + console.log(res) if (res && res.data) { _this.setData({ isShow: true, tips: res.data }); } + }, + complete: function (res){ + console.log(res); } }) }, - bindSearch: function (e) { var location = e.target.dataset.location; this.setData({ diff --git a/miniprogram/pages/earth/earth.wxml b/miniprogram/pages/earth/earth.wxml index a0db6ef..87474f8 100644 --- a/miniprogram/pages/earth/earth.wxml +++ b/miniprogram/pages/earth/earth.wxml @@ -1,9 +1,10 @@ + - + {{item.title}} {{item.address}} @@ -17,6 +18,6 @@ + placeholder="请输入定位设备编号用换行隔开" autosize border="{{ false }}" /> \ No newline at end of file diff --git a/miniprogram/pages/indexapp/indexapp.js b/miniprogram/pages/indexapp/indexapp.js index 5063372..849dbdb 100644 --- a/miniprogram/pages/indexapp/indexapp.js +++ b/miniprogram/pages/indexapp/indexapp.js @@ -7,9 +7,8 @@ */ data: { - count:1, - show: false, - onshow:true, + count: 1, + onshow: true, value: "", deviceloglist: [], devcode: "", @@ -21,6 +20,7 @@ // iconPath: "../../images/point.png", latitude: 23.099994, longitude: 113.324520, + label:'1', width: 50, height: 50 }], @@ -31,62 +31,26 @@ * 生命周期函数--监听页面加载 */ onLoad: function (options) { - + }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { - + }, /** * 生命周期函数--监听页面显示 */ onShow: function () { - // if( app.globalData.indexCount>1){ - // this.setData({ - // show:false - // }) - // }else{ - // this.showNotice() - // } - if(app.globalData.indexCount==1){ - this.setData({ - show:true - }) - this.showNotice() - } - app.globalData.indexCount+=1 - if(this.data.onshow){ + if (this.data.onshow) { this.initPages(); } }, - - showNotice: function() { - var that = this - var times = 0 - var i = setInterval(function() { - times++ - if (times >= 15) { - that.setData({ - show:false - }) - wx.showTabBar({ - animation: false, - }) - clearInterval(i) - } else { - wx.hideTabBar({ - animation: false, - }) - } - }, 1000) -}, - /** * 生命周期函数--监听页面隐藏 */ @@ -122,16 +86,27 @@ }, jump: function (event) { - var that = this; var latitude = event.target.dataset.pointLat; var longitude = event.target.dataset.pointLon; + let devcode = event.target.dataset.pointCode; that.setData({ latitude: latitude, longitude: longitude, markers: [{ latitude: latitude, - longitude: longitude + longitude: longitude, + callout: { + display:'ALWAYS',// 常显气泡 + content: devcode, //名称文本 + color: '#fff', //文本颜色 + borderRadius: 5, //边框圆角 + borderWidth: 1, //边框宽度 + borderColor: '#0060ff', //边框颜色 + bgColor: '#0060ff', //背景色 + padding: 5, //文本边缘留白 + textAlign: 'center' //文本对齐方式。有效值: left, right, center + } }] }) }, @@ -142,7 +117,7 @@ var devcode = res.result _this.setData({ devcode: devcode, - onshow:false + onshow: false }); _this.searchlogs(devcode) } @@ -151,40 +126,11 @@ onSearch: function (event) { this.setData({ - devcode:event.detail + devcode: event.detail }) this.searchlogs(event.detail) }, - - // bindregionchange: function (e) { - // var that = this - // if (e.causedBy == "drag") { - // var mapCtx = wx.createMapContext("map") - // mapCtx.getCenterLocation({ - // success: function (res) { - // var markersArr = that.data.markers - // for (var i = 0; i < markersArr.length; i++) { - // if (markersArr[i].iconPath == undefined) { - // markersArr.splice(i, 1) - // } - // } - // var latitude = res.latitude - // var longitude = res.longitude - // markersArr = markersArr.concat({ - // latitude: latitude, - // longitude: longitude - // }) - // that.setData({ - // latitude: latitude, - // longitude: longitude, - // markers: markersArr - // }) - // } - // }) - // } - // }, - showLoading: function (message) { if (wx.showLoading) { // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 @@ -211,81 +157,89 @@ } }, + //加载设备运维详细信息 toDetail: function (event) { - this.showLoading("数据加载中...") - wx.cloud.callFunction({ - name: 'deviceDetail', + var that = this + that.showLoading("数据加载中...") + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deviceDetail", data: { devcode: event.target.dataset.devcode, - url: app.globalData.url + "appDeviceLog/deviceDetail", }, - }).then(res => { - this.hideLoading(); - var resultObject = JSON.parse(res.result); - var pageName='../indexapp/indexapp' - if (resultObject.code == 200) { - wx.navigateTo({ - url: '../addDevicelog/addDeviceLog?detail=' + - JSON.stringify(resultObject.data)+'&pageName='+pageName - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + that.hideLoading(); + var resultObject = res.data; + var pageName = '../indexapp/indexapp' + if (resultObject.code == 200) { + wx.setStorageSync('resultObject', resultObject.data) + wx.navigateTo({ + url: '../addDevicelog/addDeviceLog?detail=' +'&pageName=' + pageName + }) + } + }, + fail(err){ + that.hideLoading(); } - }).catch(err => { - this.hideLoading(); }) }, + //加载列表 getlogs: function (devcode) { var that = this - wx.cloud.callFunction({ - name: 'devicelog', + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/listPage", data: { devcode: devcode, - url: app.globalData.url + "appDeviceLog/listPage", limit: 100, offset: that.data.deviceloglist.length % 100 > 0 ? parseInt(that.data.deviceloglist.length / 100) + 2 : parseInt(that.data.deviceloglist.length / 100) + 1 }, - }).then(res => { - if (res.result) { - // var resultJson = JSON.parse(res.result) - var resultJson = res.result - that.setData({ - deviceloglist: that.data.deviceloglist.concat(resultJson.data.rows) - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + // var resultJson = JSON.parse(res.result) + var resultJson = res.data + that.setData({ + deviceloglist: that.data.deviceloglist.concat(resultJson.data.rows) + }) + } } - console.log(res); - }).catch(err => { - console.error(err); }) }, + //查询列表 searchlogs: function (devcode) { var that = this - wx.cloud.callFunction({ - name: 'devicelog', + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/listPage", data: { devcode: devcode, - url: app.globalData.url + "appDeviceLog/listPage", limit: 100, offset: 1 }, - }).then(res => { - if (res.result) { - var resultJson = res.result - that.setData({ - deviceloglist: resultJson.data.rows, - onshow:true - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var resultJson = res.data + that.setData({ + deviceloglist: resultJson.data.rows, + onshow: true + }) + } } - console.log(res); - }).catch(err => { - console.error(err); }) }, initPages: function () { var that = this; - that.setData({ - devcode: "" - }); wx.getLocation({ type: "gcj02", success: function (res) { @@ -302,6 +256,6 @@ }) } }) - this.searchlogs() + this.data.devcode !== '' ? this.searchlogs(this.data.devcode) : this.searchlogs() }, }) \ No newline at end of file diff --git a/miniprogram/pages/indexapp/indexapp.wxml b/miniprogram/pages/indexapp/indexapp.wxml index 69322a0..f65b082 100644 --- a/miniprogram/pages/indexapp/indexapp.wxml +++ b/miniprogram/pages/indexapp/indexapp.wxml @@ -1,8 +1,12 @@ + + + + - @@ -32,9 +36,15 @@ - + + + + + + + @@ -46,14 +56,14 @@ - + - - + diff --git a/miniprogram/pages/indexapp/indexapp.wxss b/miniprogram/pages/indexapp/indexapp.wxss index b18706a..fc27fcb 100644 --- a/miniprogram/pages/indexapp/indexapp.wxss +++ b/miniprogram/pages/indexapp/indexapp.wxss @@ -128,6 +128,7 @@ .noticeClass{ height: 2300rpx; width: 750rpx; + overflow-y:hidden; } @@ -148,14 +149,14 @@ } +/* .vanstyle{ + button: not([size='mini']) { + user agent stylesheetmin-height: 40px; + width: 650rpx; + margin-left: 20rpx; + margin-right: auto; + + } + +} */ -/* .van-enter-active-class, -.van-leave-active-class { - transition-property: background-color, transform; -} - -.van-enter-class, -.van-leave-to-class { - background-color: red; - transform: rotate(-360deg) translate3d(-100%, -100%, 0); -} */ \ No newline at end of file diff --git a/miniprogram/pages/log/log.js b/miniprogram/pages/log/log.js deleted file mode 100644 index 83ba349..0000000 --- a/miniprogram/pages/log/log.js +++ /dev/null @@ -1,66 +0,0 @@ -// pages/log/log.js -Page({ - - /** - * 页面的初始数据 - */ - data: { - - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - - }, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { - - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - - }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { - - }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { - - } -}) \ No newline at end of file diff --git a/miniprogram/pages/log/log.json b/miniprogram/pages/log/log.json deleted file mode 100644 index 8835af0..0000000 --- a/miniprogram/pages/log/log.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "usingComponents": {} -} \ No newline at end of file diff --git a/miniprogram/pages/log/log.wxml b/miniprogram/pages/log/log.wxml deleted file mode 100644 index a510ad6..0000000 --- a/miniprogram/pages/log/log.wxml +++ /dev/null @@ -1,2 +0,0 @@ - -pages/log/log.wxml diff --git a/miniprogram/pages/log/log.wxss b/miniprogram/pages/log/log.wxss deleted file mode 100644 index 23db318..0000000 --- a/miniprogram/pages/log/log.wxss +++ /dev/null @@ -1 +0,0 @@ -/* pages/log/log.wxss */ \ No newline at end of file diff --git a/miniprogram/pages/login/login.js b/miniprogram/pages/login/login.js index a4074e7..cb0542a 100644 --- a/miniprogram/pages/login/login.js +++ b/miniprogram/pages/login/login.js @@ -1,11 +1,14 @@ // miniprogram/pages/login/login.js +var app = getApp() Page({ /** * 页面的初始数据 */ data: { - windowWidth:"" + windowWidth: "", + time: 15 * 1000, + showTime: false }, /** @@ -20,9 +23,9 @@ */ onReady: function () { this.setData({ - windowWidth:wx.getSystemInfoSync().windowWidth + windowWidth: wx.getSystemInfoSync().windowWidth }) - + }, /** @@ -66,14 +69,158 @@ onShareAppMessage: function () { }, + + + showLoading: function (message) { + if (wx.showLoading) { + // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 + wx.showLoading({ + title: message, + mask: true + }); + } else { + // 低版本采用Toast兼容处理并将时间设为20秒以免自动消失 + wx.showToast({ + title: message, + icon: 'loading', + mask: true, + duration: 20000 + }); + } + }, + hideLoading: function () { + if (wx.hideLoading) { + // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 + wx.hideLoading(); + } else { + wx.hideToast(); + } + }, + + //注册 loginClick: function () { + var that = this + that.showLoading("授权中...") + wx.login({ + success: function (res) { + if (res.code) { + wx.request({ + url: app.globalData.httpsUrl + "appUserOpenid/login", + data: { + code: res.code + }, + success: function (res) { + app.globalData.openid = res.data.data + wx.getUserInfo({ + success: (res) => { + var nickname = res.userInfo.nickName; + app.globalData.nickName = nickname; + //openid绑定昵称存入后台 + wx.request({ + url: app.globalData.httpsUrl + "appUserOpenid/add", + data: { + attr: nickname, + openid: app.globalData.openid + }, + success: function (res) { + that.hideLoading(); + wx.showToast({ + title: res.data.data+",\r\n请从正式版入口登录!", + icon: 'none', + duration: 2000 + }) - wx.navigateTo({ - - url: '../farmermain/farmermain', - + // //授权成功后跳转 + // wx.switchTab({ + // url: '../indexapp/indexapp' + // }) + } + }) + }, + fail: function (err) { + that.hideLoading(); + } + }) + }, + fail: function (res) { + that.hideLoading(); + wx.showToast({ + title: '服务器异常', + }) + } + }) + } + }, + fail: function (res) { + that.hideLoading(); + } }) + }, + //登录验证 + loginValidate: function () { + var that = this + that.showLoading("登录中...") + wx.login({ + success: function (res) { + if (res.code) { + console.info(res); + wx.request({ + url: app.globalData.httpsUrl + "appUserOpenid/login", + data: { + code: res.code + }, + success: function (res) { + app.globalData.openid = res.data.data + wx.request({ + url: app.globalData.httpsUrl + "appUserOpenid/validate", + data: { + openid: app.globalData.openid + }, + success: function (res) { + that.hideLoading(); + if (res.data.data) { + app.globalData.userName = res.data.data.attr1 == '' ? res.data.data.attr : res.data.data.attr1 + app.globalData.nickName = res.data.data.attr + app.globalData.role = res.data.data.role + wx.navigateTo({ + url: '../notice/notice' + }) + } else { + wx.showToast({ + icon: 'none', + title: '请联系管理员授权', + duration: 2000 + }) + } + }, + fail: function (err) { + that.hideLoading(); + wx.showToast({ + title: '验证失败', + }) + } + }) + }, + fail: function (res) { + that.hideLoading(); + wx.showToast({ + title: '服务器异常', + }) + } + }) + } + }, + fail: function (res) { + that.hideLoading(); + } + }) + }, + + finished() { + this.setData({ + showTime: true + }) }, onClickSubmit: function () { diff --git a/miniprogram/pages/login/login.json b/miniprogram/pages/login/login.json index 8835af0..f2043a3 100644 --- a/miniprogram/pages/login/login.json +++ b/miniprogram/pages/login/login.json @@ -1,3 +1,8 @@ { - "usingComponents": {} + "usingComponents": { + "van-count-down": "../../miniprogram_npm/@vant/weapp/count-down", + "van-button": "../../miniprogram_npm/@vant/weapp/button" + }, + "navigationBarBackgroundColor": "#E6D480", + "disableScroll":true } \ No newline at end of file diff --git a/miniprogram/pages/login/login.wxml b/miniprogram/pages/login/login.wxml index c69df42..cf2ec72 100644 --- a/miniprogram/pages/login/login.wxml +++ b/miniprogram/pages/login/login.wxml @@ -1,21 +1,46 @@ + - + + + - + + + +    本程序为施工日志管理小程序,为航天二院智慧市 +政技术研究室内部系统,不对外开放。出于对数据信 +息安全的考虑,在您首次使用小程序时,请先对小程 +序进行授权,授权后的用户可以正常对小程序进行编 +辑,谢谢您的配合! + + + + + + + + 授权/登录 + + + - + + + diff --git a/miniprogram/pages/login/login.wxss b/miniprogram/pages/login/login.wxss index ca77568..b9fa569 100644 --- a/miniprogram/pages/login/login.wxss +++ b/miniprogram/pages/login/login.wxss @@ -54,7 +54,8 @@ } .form .submit { - margin-top: 80rpx; + + /* margin-top: 80rpx; */ color: #fff; border: 2rpx solid #FFB90F; background-color: #FFB90F; @@ -63,10 +64,30 @@ } .login_image { - width: 200rpx; - height: 200rpx; - padding-top: 100rpx; - padding-left: 250rpx; + width: 750rpx; + height: 360rpx; + /* height: 2300rpx; */ + /* padding-top: 100rpx + padding-left: 250rpx; */ +} +.bottom_image { + width: 750rpx; + height: 32%; + position: fixed; + bottom: 0px; + /* padding-top: 100rpx + padding-left: 250rpx; */ +} +.cover{ + position: fixed; + top: 0rpx; + margin-left: 290rpx; + text-align:center; + font-size: 50rpx; + color: #FFCF00; + width: 750rpx; + z-index:9999; + } -} \ No newline at end of file + \ No newline at end of file diff --git a/miniprogram/pages/notice/notice.js b/miniprogram/pages/notice/notice.js new file mode 100644 index 0000000..7aeafb9 --- /dev/null +++ b/miniprogram/pages/notice/notice.js @@ -0,0 +1,80 @@ +// miniprogram/pages/notice.js +Page({ + + /** + * 页面的初始数据 + */ + data: { + time: 15 * 1000, + showTime: false + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { + this.setData({ + showTime: true + }) + wx.switchTab({ + url: '../indexapp/indexapp' + }) + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + }, + finished() { + this.setData({ + showTime: true + }) + wx.switchTab({ + url: '../indexapp/indexapp' + }) + } +}) \ No newline at end of file diff --git a/miniprogram/pages/notice/notice.json b/miniprogram/pages/notice/notice.json new file mode 100644 index 0000000..4c73264 --- /dev/null +++ b/miniprogram/pages/notice/notice.json @@ -0,0 +1,5 @@ +{ + "usingComponents": { + "van-count-down": "../../miniprogram_npm/@vant/weapp/count-down" + } +} \ No newline at end of file diff --git a/miniprogram/pages/notice/notice.wxml b/miniprogram/pages/notice/notice.wxml new file mode 100644 index 0000000..975304a --- /dev/null +++ b/miniprogram/pages/notice/notice.wxml @@ -0,0 +1,10 @@ + + + + + + + + diff --git a/miniprogram/pages/notice/notice.wxss b/miniprogram/pages/notice/notice.wxss new file mode 100644 index 0000000..36d7542 --- /dev/null +++ b/miniprogram/pages/notice/notice.wxss @@ -0,0 +1,18 @@ +/* miniprogram/pages/notice.wxss */ + +.login_image { + width: 750rpx; + height: 2300rpx; + /* padding-top: 100rpx + padding-left: 250rpx; */ +} +.cover{ + position: fixed; + top: 0rpx; + margin-left: 290rpx; + text-align:center; + font-size: 50rpx; + color: #FFCF00; + width: 750rpx; + z-index:9999; + } \ No newline at end of file diff --git a/miniprogram/pages/searchLog/searchLog.js b/miniprogram/pages/searchLog/searchLog.js index a4f8c33..1f7069b 100644 --- a/miniprogram/pages/searchLog/searchLog.js +++ b/miniprogram/pages/searchLog/searchLog.js @@ -6,29 +6,35 @@ * 页面的初始数据 */ data: { - defaultDay:[ + defaultDay: [ new Date().getTime(), - new Date().getTime()+24*60*60*1000, + new Date().getTime() + 24 * 60 * 60 * 1000, ], projectoption: [], - devtypeList:[], + devtypeList: [], personoption: [], installtimeFmt: '', show: false, - minDate: new Date(2010, 0, 1).getTime(), devcode: '', + timeShow:false, project: '', devtype: '', - installPerson:'', + installPerson: '', + projectvalue:'', minDate: new Date(2018, 0, 1).getTime(), // maxDate: new Date(2018, 0, 31).getTime(), }, onDisplay() { - this.setData({ show: true }); + this.setData({ + show: true + }); }, onClose() { - this.setData({ show: false }); + this.setData({ + show: false + }); }, + //格式化时间 formatDate(date) { date = new Date(date); // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; @@ -50,6 +56,7 @@ return currentdate; }, + //查询时间区域设置 onConfirm(event) { // this.setData({ @@ -67,87 +74,102 @@ /** * 生命周期函数--监听页面加载 */ - onLoad: function (options) { - var _this=this + onLoad: async function (options) { + await this.setData({ + timeShow:true, + }) + const {devcode,devtype,installPerson,installtimeFmt,project} = JSON.parse(options.params) + this.setData({ + devcode:devcode || '', + devtype:devtype || '', + installPerson:installPerson || '', + installtimeFmt:installtimeFmt || '', + project:project || '', + projectvalue:project || '', + + }) + + var _this = this /** * 获取所属项目下拉列表 */ - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); + success(res) { + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); + } + _this.setData({ + projectoption: projectArr + }) } - _this.setData({ - projectoption: projectArr - }) } - }).catch(err => { - console.error(err); }) - - - /** + /** * 获取设备类型下拉列表 */ - wx.cloud.callFunction({ - name: 'getTypeList', - data: { - url: app.globalData.url + "deviceType/deviceType" + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/deviceType", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - }).then(res => { - if (res.result.code == 200) { - var TypeList = res.result.data - var typeArr = []; - for (var i = 0; i < TypeList.length; i++) { - var type = { - text: TypeList[i].productName, - value: TypeList[i].productName - }; - typeArr.push(type); + success(res) { + if (res.data.code == 200) { + var TypeList = res.data.data + var typeArr = []; + for (var i = 0; i < TypeList.length; i++) { + var type = { + text: TypeList[i].productName, + value: TypeList[i].productName + }; + typeArr.push(type); + } + _this.setData({ + devtypeList: typeArr + }) } - _this.setData({ - devtypeList: typeArr - }) } - }).catch(err => { - console.error(err); }) - //获取人员下拉列表 - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" + //获取人员下拉列表 + wx.request({ + method: "POST", + data:{ + tips:'repair' }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); + url: app.globalData.httpsUrl + "deviceType/getUser", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var users = res.data.data + var personArr = []; + for (var i = 0; i < users.length; i++) { + var person = { + text: users[i].name, + value: users[i].name + }; + personArr.push(person); + } + _this.setData({ + personoption: personArr + }) } - _this.setData({ - personoption: personArr - }) } - }).catch(err => { - console.error(err); }) }, @@ -202,13 +224,13 @@ }, scan() { - var _this=this; + var _this = this; wx.scanCode({ success(res) { - var devcode=res.result + var devcode = res.result _this.setData({ - devcode: devcode, - }); + devcode: devcode, + }); } }) }, @@ -221,6 +243,7 @@ [formName]: formValue }) }, + //设置项目 selectprojectValue(event) { var that = this; that.setData({ @@ -228,7 +251,7 @@ }) }, - + //设置设备类型 selectDevType(event) { var that = this; that.setData({ @@ -236,46 +259,24 @@ }) }, + //设置人员 selectpersonValue(event) { var that = this; that.setData({ installPerson: event.detail }) }, - + //查询 query: function (event) { - var data={ + var data = { devcode: this.data.devcode, installtimeFmt: this.data.installtimeFmt, project: this.data.project, devtype: this.data.devtype, - installPerson:this.data.installPerson + installPerson: this.data.installPerson } wx.reLaunch({ url: '../applog/applog?params=' + JSON.stringify(data) }) - // var that = this; - // wx.cloud.callFunction({ - // name: 'devicelog', - // data: { - // devcode: that.data.devcode, - // installtimeFmt: that.data.installtimeFmt, - // project: that.data.project, - // devtype: that.data.devtype, - // }, - // }).then(res => { - // // var resultObj=JSON.parse(res.result); - // var resultObj=res.result; - // if (resultObj.code == 200) { - // wx.reLaunch({ - // url: '../applog/applog?applogList=' + JSON.stringify(resultObj.data.rows) - // }) - // } - // }).catch(err => { - // console.error(err); - // wx.showToast({ - // title: "查询失败", - // }) - // }) }, }) \ No newline at end of file diff --git a/miniprogram/pages/searchLog/searchLog.wxml b/miniprogram/pages/searchLog/searchLog.wxml index dfbc788..daf06bc 100644 --- a/miniprogram/pages/searchLog/searchLog.wxml +++ b/miniprogram/pages/searchLog/searchLog.wxml @@ -21,14 +21,10 @@ - + - - @@ -39,7 +35,12 @@ - - 查询 + + + + + 查询 \ No newline at end of file diff --git a/cloudfunctions/project.config.json b/cloudfunctions/project.config.json new file mode 100644 index 0000000..2b3119a --- /dev/null +++ b/cloudfunctions/project.config.json @@ -0,0 +1,28 @@ +{ + "appid": "wx2cef527a000f87c9", + "compileType": "miniprogram", + "libVersion": "2.27.3", + "packOptions": { + "ignore": [], + "include": [] + }, + "setting": { + "coverView": true, + "es6": true, + "postcss": true, + "minified": true, + "enhance": true, + "showShadowRootInWxmlPanel": true, + "packNpmRelationList": [], + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + } + }, + "condition": {}, + "editorSetting": { + "tabIndent": "insertSpaces", + "tabSize": 4 + } +} \ No newline at end of file diff --git a/cloudfunctions/project.private.config.json b/cloudfunctions/project.private.config.json new file mode 100644 index 0000000..42ff49d --- /dev/null +++ b/cloudfunctions/project.private.config.json @@ -0,0 +1,7 @@ +{ + "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", + "projectname": "cloudfunctions", + "setting": { + "compileHotReLoad": true + } +} \ No newline at end of file diff --git a/miniprogram/app.js b/miniprogram/app.js index 51d56f3..50a8a54 100644 --- a/miniprogram/app.js +++ b/miniprogram/app.js @@ -18,13 +18,15 @@ // this.globalData = {} }, globalData: { - // url: "http://111.198.10.15:11604/", - httpsUrl: "https://logapi.smartlog.work/", - httpsTestUrl: "https://smartlog.work/prodapi4test/", - url: "http://139.198.18.188:8083/", + httpsUrl: "https://logapi.smartlog.work/", + // httpsUrl: "http://139.198.18.188:8083/", // url: "http://127.0.0.1:8083/", - // httpsUrl: "http://127.0.0.1:8083/", + //httpsUrl: "http://127.0.0.1:8083/", openid: null, - indexCount:1 - }, + indexCount:1, + nickName:"", + userName:"", + role:"", + devcode:"" + } }) diff --git a/miniprogram/app.json b/miniprogram/app.json index d23f798..2b6db76 100644 --- a/miniprogram/app.json +++ b/miniprogram/app.json @@ -1,15 +1,17 @@ { "cloud": true, "pages": [ + "pages/login/login", "pages/indexapp/indexapp", "pages/earth/earth", "pages/applog/applog", "pages/addDevice/addDevice", "pages/addDevicelog/addDeviceLog", - "pages/searchLog/searchLog" + "pages/searchLog/searchLog", + "pages/notice/notice" ], "window": { - "backgroundColor": "#F6F6F6", + "backgroundColor": "#E6D480", "backgroundTextStyle": "light", "navigationBarBackgroundColor": "#FFCF00", "navigationBarTitleText": "智慧施工", @@ -46,11 +48,11 @@ "desc": "你的位置信息将用于小程序位置接口的效果展示" } }, + "requiredPrivateInfos": ["getLocation", "chooseLocation"], "networkTimeout": { "request": 30000, "connectSocket": 30000, "uploadFile": 30000, "downloadFile": 30000 - }, - "style": "v2" + } } \ No newline at end of file diff --git a/miniprogram/images/applocat.png b/miniprogram/images/applocat.png new file mode 100644 index 0000000..fe49f54 --- /dev/null +++ b/miniprogram/images/applocat.png Binary files differ diff --git a/miniprogram/images/back.png b/miniprogram/images/back.png new file mode 100644 index 0000000..32ac82d --- /dev/null +++ b/miniprogram/images/back.png Binary files differ diff --git a/miniprogram/images/bottom.png b/miniprogram/images/bottom.png new file mode 100644 index 0000000..d910e98 --- /dev/null +++ b/miniprogram/images/bottom.png Binary files differ diff --git a/miniprogram/images/header.png b/miniprogram/images/header.png new file mode 100644 index 0000000..6ea222e --- /dev/null +++ b/miniprogram/images/header.png Binary files differ diff --git a/miniprogram/images/login.png b/miniprogram/images/login.png index 8b73cc0..6471c46 100644 --- a/miniprogram/images/login.png +++ b/miniprogram/images/login.png Binary files differ diff --git a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss index 5a591fb..c9c35b5 100644 --- a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss +++ b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:100%;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:100%}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file +@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:650rpx;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:600rpx}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file diff --git a/miniprogram/pages/addDevice/addDevice.js b/miniprogram/pages/addDevice/addDevice.js index 2783674..78f00b7 100644 --- a/miniprogram/pages/addDevice/addDevice.js +++ b/miniprogram/pages/addDevice/addDevice.js @@ -1,5 +1,7 @@ // miniprogram/pages/addDevice/addDevice.js // import WxValidate from '../../utils/WxValidate.js' +var QQMapWX = require('../../libs/qqmap-wx-jssdk.js'); +var qqmapsdk; var app = getApp() Page({ @@ -11,32 +13,10 @@ canvasWidth: '', longitude: '', latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], + option1: [], personoption1: [], projectoption: [], + devtypeList:[], show: false, form: { devcode: "", @@ -59,7 +39,10 @@ project: "", area: "", street: "", - wellname: "" + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '', }, fileList: [] }, @@ -117,12 +100,14 @@ var that = this; //初始化表单内容为上次填写值 var cacheForms = wx.getStorageSync('cacheList') - if (cacheForms) { + cacheForms.photopath1='' + cacheForms.photopath2='' + cacheForms.photopath3='' + that.data.fileList=[] that.setData({ form: cacheForms, devcode: cacheForms.devcode, - }) } var form = that.data.form @@ -155,55 +140,89 @@ } }) + +//获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + that.setData({ + option1: welltypeArr + }) + } + } +}) + + //获取人员下拉列表 - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/getUser", + data:{ + tips:'repair' }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data.code == 200) { + var users = res.data.data + var personArr = []; + for (var i = 0; i < users.length; i++) { + var person = { + text: users[i].name, + value: users[i].name + }; + personArr.push(person); + } + that.setData({ + personoption1: personArr + }) } - that.setData({ - personoption1: personArr - }) } - }).catch(err => { - console.error(err); - }) + }) + - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - that.setData({ - projectoption: projectArr - }) + success(res){ + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); + } + that.setData({ + projectoption: projectArr + }) + } } - }).catch(err => { - console.error(err); - }) + }) + var installtime = 'form.installtimeFmt'; var dateNow = this.formatDate(); this.setData({ @@ -211,8 +230,40 @@ installtimeFmt: dateNow, [installtime]: dateNow, }); + + + + /** + * 获取设备类型下拉列表 + */ + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/deviceType", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var TypeList = res.data.data + var typeArr = []; + for (var i = 0; i < TypeList.length; i++) { + var type = { + text: TypeList[i].productName, + value: TypeList[i].productName + }; + typeArr.push(type); + } + that.setData({ + devtypeList: typeArr + }) + } + } + }) }, + + + /** * 生命周期函数--监听页面初次渲染完成 */ @@ -280,29 +331,7 @@ }, - - //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 - drawText: function (ctx, str, leftWidth, initHeight, titleHeight, canvasWidth) { - var lineWidth = 0; - var lastSubStrIndex = 0; //每次开始截取的字符串的索引 - for (let i = 0; i < str.length; i++) { - lineWidth += ctx.measureText(str[i]).width; - if (lineWidth > canvasWidth) { - ctx.fillText(str.substring(lastSubStrIndex, i), leftWidth, initHeight); //绘制截取部分 - initHeight = initHeight + leftWidth * 2; //22为字体的高度 - lineWidth = 0; - lastSubStrIndex = i; - // titleHeight += 40; - } - if (i == str.length - 1) { //绘制剩余部分 - ctx.fillText(str.substring(lastSubStrIndex, i + 1), leftWidth, initHeight); - } - } - // // 标题border-bottom 线距顶部距离 - // titleHeight = titleHeight + 10; - // return titleHeight - }, - + //验证表单 formValidate() { if (this.data.form.devcode == "") { @@ -312,27 +341,20 @@ }) return false } - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } if (this.data.form.wellcode == "") { wx.showToast({ icon: 'none', @@ -348,22 +370,10 @@ }) return false } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null) { + + if (this.data.form.installperson == "") { wx.showToast({ icon: 'none', title: '安装人员不能为空!', @@ -408,56 +418,90 @@ } return true; }, + //提交表单 formSubmit: function (event) { + console.log(this.data.form) + //表单参数验证 if (!this.formValidate()) { return false; } var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDevice', + //验证设备编号长度 + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/getDevTypeLength", data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceAdd/add" + code: encodeURI(this.data.form.devicetype) }, - }).then(res => { - if (res.result.code == 500) { - wx.showToast({ - title: '设备编号已安装!', - }) - } else if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - //用于回显 - wx.setStorageSync('cacheList', that.data.form) - //提交成功后提示用户操作 - if (res.confirm) { - wx.switchTab({ - url: '../earth/earth' - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (""==res.data.data ||res.data.data == that.data.form.devcode.length) { + that.saveDevice() + } else { //编号位数不对提示 + wx.showToast({ + icon: 'none', + title: '设备编号位数不对!', + duration: 1000 + }) + return false + } } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "提交失败", - }) }) }, + + //保存设备基本信息 + saveDevice() { + var that = this; + //设置照片路径 + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopathForm = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopathForm]: fileList[i].url.split("static/")[1] + }) + } + //表单提交 + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 500) { + wx.showToast({ + title: '设备编号已安装!', + }) + } else if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + //用于回显 + wx.setStorageSync('cacheList', that.data.form) + //提交成功后提示用户操作 + if (res.confirm) { + wx.switchTab({ + url: '../earth/earth' + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } + }, + fail(err) { + wx.showToast({ + title: '提交失败!', + }) + } + }) + }, + + //input 输入框设置值 confirm(event) { var that = this; var formValue = event.detail.value; @@ -466,8 +510,30 @@ that.setData({ [fromN]: formValue }) + //若输入是设备编号,自动获取设备类型 + if('devcode'==formName){ + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", + data: { + devcode: formValue, + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + that.setData({ + [formDevicetype]: res.data + }); + } + } + }) + } }, + //扫描设备获取编号和设备类型 scan() { var _this = this; wx.scanCode({ @@ -477,23 +543,28 @@ _this.setData({ [formdevcode]: devcode }); - wx.cloud.callFunction({ - name: 'findModeCode', + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", data: { devcode: devcode, - url: app.globalData.url + "appDeviceAdd/findModeCodeByCode" }, - }).then(res => { - if (res.result) { - var formDevicetype = 'form.devicetype' - _this.setData({ - [formDevicetype]: res.result - }); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + _this.setData({ + [formDevicetype]: res.data + }); + } } }) } }) }, + //粘贴经纬度 paste() { var _this = this; wx.getClipboardData({ @@ -510,9 +581,11 @@ longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), }); + _this.showAddress(_this.data.form.longitude,_this.data.form.latitude,_this) } }) }, + //设置经类型 selectValue(value) { var that = this; @@ -521,6 +594,16 @@ [wellType]: value.detail }) }, + + //设置设备类型 + selectDevType(event) { + var that = this; + var devtype = 'form.devicetype'; + that.setData({ + [devtype]: event.detail + }) + }, + //设置运维人员 selectpersonValue(event) { var that = this; var installPerson = 'form.installperson'; @@ -528,6 +611,7 @@ [installPerson]: event.detail }) }, + //设置项目 selectprojectValue(event) { var that = this; var project = 'form.project'; @@ -535,8 +619,41 @@ [project]: event.detail }) }, + showAddress :function(longitude, latitude, self) { + // 实例化腾讯地图API核心类 + qqmapsdk = new QQMapWX({ + key: 'BGPBZ-C5O3P-ROUDR-LWC4J-63EKH-V5FRX'//此处使用你自己申请的key + }) + // 腾讯地图调用接口 + qqmapsdk.reverseGeocoder({ + location: { + latitude: latitude, + longitude: longitude + }, + success: function (res) { + self.setData({ + 'form.area':res.result.address.slice(0,res.result.address.indexOf('区')+1), + 'form.street':res.result.address.slice(res.result.address.indexOf('区')+1) + }) + }, + fail: function (res) { + console.log(res); + }, + complete: function (res) { + } + }); + }, + //上传照片 afterRead(event) { var _this = this; + if (_this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '请先填写设备编号!\r\n否则水印中无编号', + duration: 2000 + }) + return false + } const { file } = event.detail; @@ -576,78 +693,8 @@ }) } }) - // 压缩图片 - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // //获取图片尺寸 - // wx.getImageInfo({ - // src: convertpath, - // success(res) { - // _this.setData({ - // canvasHeight: res.height, - // canvasWidth: res.width - // }) - // var ctx = wx.createCanvasContext('firstCanvas') - - // //将图片src放到cancas内,宽高为图片大小 - // ctx.drawImage(convertpath, 0, 0, res.width, res.height) - // //将声明的时间放入canvas - // ctx.setFontSize(30 * (res.width / 750)) //注意:设置文字大小必须放在填充文字之前,否则不生效 - // ctx.setFillStyle('blue') - // var text = "编号:" + _this.data.form.devcode + "\n经度:" + _this.data.form.longitude + "\n纬度:" + _this.data.form.latitude - // // _this.drawText(ctx,text,20, 70, 5, res.width) - // _this.drawText(ctx, text, 15 * (res.width / 750), 70 * (res.width / 750), 5, res.width) - - // // ctx.fillText(text, 0, 40) - // // ctx.strokeText(_this.data.form.devcode, 0, 30) - // //生成水印图 - // ctx.draw(false, function () { - // wx.canvasToTempFilePath({ - // canvasId: 'firstCanvas', - // success: (res) => { - // wx.compressImage({ - // src: res.tempFilePath, - // quality: 25, - // success: function (res) { - // //上传照片至服务器 - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: res.tempFilePath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // } - // }) - // //// - // } - // }) - // }) - // } - // }) - // } - // }); }, + //删除照片 deletePhoto(event) { var image_index = event.detail.index var fileList_new = this.data.fileList; diff --git a/miniprogram/pages/addDevice/addDevice.wxml b/miniprogram/pages/addDevice/addDevice.wxml index b0977e2..f12c254 100644 --- a/miniprogram/pages/addDevice/addDevice.wxml +++ b/miniprogram/pages/addDevice/addDevice.wxml @@ -5,18 +5,30 @@ - + + + + + + + + + + + + + - - + + - - - + + + @@ -29,13 +41,13 @@ - + - + - + - + @@ -54,8 +66,7 @@ - - + @@ -68,8 +79,8 @@ - - + + - 保存 + 保存 \ No newline at end of file diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.js b/miniprogram/pages/addDevicelog/addDeviceLog.js index cdec71b..a0dc6da 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.js +++ b/miniprogram/pages/addDevicelog/addDeviceLog.js @@ -3,681 +3,665 @@ var app = getApp(); Page({ - /** - * 页面的初始数据 - */ - data: { - pageName: '', - showMask: false, - today: new Date().getTime(), - longitude: '', - latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], - personoption1: [], - projectoption: [], - devcode: "", - deviceMode: "", - installtimeFmt: '', - show: false, - form: { - devcode: "", - wellcode: "", - welltype: "", - welldepth: "", - installheigt: "", - installperson: "", - installtimeFmt: "", - photopath: "", - factory: "", - workmsg: "", - position: "", - description: "", - longitude: "", - latitude: "", - longitude84: "", - latitude84: "", - devicetype: "", - project: "", - area: "", - street: "", - wellname: "" - }, - fileList: [], - detail: "" - }, + /** + * 页面的初始数据 + */ + data: { + pageName: '', + showMask: false, + today: new Date().getTime(), + longitude: '', + latitude: '', + option1: [], + personoption1: [], + projectoption: [], + devcode: "", + deviceMode: "", + installtimeFmt: '', + show: false, + form: { + devcode: "", + wellcode: "", + welltype: "", + welldepth: "", + installheigt: "", + installperson: "", + installtimeFmt: "", + photopath: "", + factory: "", + workmsg: "", + position: "", + description: "", + longitude: "", + latitude: "", + longitude84: "", + latitude84: "", + devicetype: "", + project: "", + area: "", + street: "", + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '' + }, + fileList: [], + detail: "", + markers: [{ + id: 100, + // iconPath: "../../images/point.png", + latitude: '', + longitude: '', + // label:'1', + width: 25, + height: 35 + }], + }, - onDisplay() { - this.setData({ - show: true - }); - }, - onClose() { - this.setData({ - show: false - }); - }, - formatDate() { - var date = new Date(); - // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; - var seperator1 = "-"; - var month = date.getMonth() + 1; - var strDate = date.getDate(); - var hour = date.getHours() - var minute = date.getMinutes() - var second = date.getSeconds() - month = month > 9 ? month : "0" + month; - strDate = strDate > 9 ? strDate : "0" + strDate; - hour = hour > 9 ? hour : "0" + hour; - minute = minute > 9 ? minute : "0" + minute; - second = second > 9 ? second : "0" + second; - var currentdate = - date.getFullYear() + - seperator1 + - month + - seperator1 + - strDate + - " " + - hour + ":" + - minute + ":" + - second; - return currentdate; + onDisplay() { + this.setData({ + show: true + }); + }, + onClose() { + this.setData({ + show: false + }); + }, + formatDate() { + var date = new Date(); + // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; + var seperator1 = "-"; + var month = date.getMonth() + 1; + var strDate = date.getDate(); + var hour = date.getHours() + var minute = date.getMinutes() + var second = date.getSeconds() + month = month > 9 ? month : "0" + month; + strDate = strDate > 9 ? strDate : "0" + strDate; + hour = hour > 9 ? hour : "0" + hour; + minute = minute > 9 ? minute : "0" + minute; + second = second > 9 ? second : "0" + second; + var currentdate = + date.getFullYear() + + seperator1 + + month + + seperator1 + + strDate + + " " + + hour + ":" + + minute + ":" + + second; + return currentdate; - }, - onConfirm(event) { - var installtime = 'form.installtimeFmt'; - this.setData({ - show: false, - installtimeFmt: this.formatDate(event.detail), - [installtime]: this.formatDate(event.detail), - }); - }, + }, + onConfirm(event) { + var installtime = 'form.installtimeFmt'; + this.setData({ + show: false, + installtimeFmt: this.formatDate(event.detail), + [installtime]: this.formatDate(event.detail), + }); + }, - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - var _this = this; - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" - }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); - } - _this.setData({ - personoption1: personArr - }) + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + var _this = this; + _this.setData({ + 'markers[0].latitude': Number(wx.getStorageSync('resultObject').latitude) , + 'markers[0].longitude': Number(wx.getStorageSync('resultObject').longitude), + // 'markers[0].label':'10', + 'markers[0].width': 18, + 'markers[0].id':1, + 'markers[0].height': 30, + latitude:Number(wx.getStorageSync('resultObject').latitude), + longitude:Number(wx.getStorageSync('resultObject').longitude) + }) + //获取人员下拉列表 + // wx.request({ + // method: "POST", + // url: app.globalData.httpsUrl + "deviceType/getUser", + // data:{ + // tips:'repair' + // }, + // header: { + // 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + // }, + // success(res) { + // if (res.data.code == 200) { + // var users = res.data.data + // var personArr = []; + // for (var i = 0; i < users.length; i++) { + // var person = { + // text: users[i].name, + // value: users[i].name + // }; + // personArr.push(person); + // } + // _this.setData({ + // personoption1: personArr + // }) + // } + // } + // }) + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); } - }).catch(err => { - console.error(err); - }) - - - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" - }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - _this.setData({ - projectoption: projectArr - }) - } - }).catch(err => { - console.error(err); - }) - - if (options.pageName) { - this.setData({ - pageName: options.pageName - }) - } - - if (options.detail) { - - var formObject = JSON.parse(options.detail); _this.setData({ - form: formObject, - detail: options.detail + projectoption: projectArr }) - - _this.setData({ - ['form.installperson']: "", - ['form.installtimeFmt']: "", - ['form.workmsg']: "", - ['form.description']: "" - }) - - const { - fileList = [] - } = _this.data; - if (formObject.photopath1 != "") { - var file1 = { - url: app.globalData.url + "static/" + formObject.photopath1 - } - fileList.push(file1) - } - if (formObject.photopath2 != "") { - var file2 = { - url: app.globalData.url + "static/" + formObject.photopath2 - } - fileList.push(file2) - } - if (formObject.photopath3 != "") { - var file3 = { - url: app.globalData.url + "static/" + formObject.photopath3 - } - fileList.push(file3) - } - - _this.setData({ - fileList - }); } - var installtime = 'form.installtimeFmt'; - var dateNow = this.formatDate(); - this.setData({ - installtimeFmt: dateNow, - [installtime]: dateNow, - }); - }, + } + }) - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { + //获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + _this.setData({ + option1: welltypeArr + }) + } + } +}) - }, + //跳转时带入参数返回哪页 + if (options.pageName) { + this.setData({ + pageName: options.pageName + }) + } + //跳转时带入参数设备的安装信息 + if (wx.getStorageSync('resultObject')) { + var formObject = wx.getStorageSync('resultObject') + _this.setData({ + form: formObject, + detail: formObject + }) - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { + _this.setData({ + ['form.installperson']: app.globalData.userName, + ['form.installtimeFmt']: "", + ['form.workmsg']: "", + ['form.description']: "" + }) - }, + const { + fileList = [] + } = _this.data; + if (formObject.photopath1 != "") { + var file1 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath1 + } + fileList.push(file1) + } + if (formObject.photopath2 != "") { + var file2 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath2 + } + fileList.push(file2) + } + if (formObject.photopath3 != "") { + var file3 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath3 + } + fileList.push(file3) + } + _this.setData({ + fileList + }); + } + var installtime = 'form.installtimeFmt'; + var dateNow = this.formatDate(); + this.setData({ + installtimeFmt: dateNow, + [installtime]: dateNow, + }); + }, - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, - }, + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + wx.removeStorageSync('resultObject') + }, - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, - }, + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { + }, - }, + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { + }, - }, + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { + }, - }, + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + }, - /** - * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true - **/ + /** + * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true + **/ - isNumber: function (val) { + isNumber: function (val) { - var regPos = /^[0-9]*$/; //非负浮点数 - var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数 - if (regPos.test(val) || regNeg.test(val)) { - return false; - } else { - return true; - } + var regPos = /^[0-9]*$/; //非负浮点数 + var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数 + if (regPos.test(val) || regNeg.test(val)) { + return false; + } else { + return true; + } - }, + }, - formValidate() { + formValidate() { - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } - if (this.data.form.wellcode == "") { - wx.showToast({ - icon: 'none', - title: '井编号不能为空!', - }) - return false - } - if (this.data.form.devicetype == "") { - wx.showToast({ - icon: 'none', - title: '设备类型不能为空!', - }) - return false - } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + if (this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '设备编号不能为空!', + }) + return false + } + if (this.data.form.wellcode == "") { + wx.showToast({ + icon: 'none', + title: '井编号不能为空!', + }) + return false + } + if (this.data.form.devicetype == "") { + wx.showToast({ + icon: 'none', + title: '设备类型不能为空!', + }) + return false + } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null || - this.data.form.installperson == '') { - wx.showToast({ - icon: 'none', - title: '运维人员不能为空!', - }) - return false - } - if (this.data.form.project == "") { - wx.showToast({ - icon: 'none', - title: '所属项目不能为空!', - }) - return false - } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } + if (this.data.form.installperson == null || + this.data.form.installperson == '') { + wx.showToast({ + icon: 'none', + title: '运维人员不能为空!', + }) + return false + } + if (this.data.form.project == "") { + wx.showToast({ + icon: 'none', + title: '所属项目不能为空!', + }) + return false + } - if (this.data.form.welldepth != null) { - if (this.isNumber(this.data.form.welldepth)) { - wx.showToast({ - icon: 'none', - title: '井深必须为数值!', - }) - return false - } - } - if (this.data.form.installheigt != null) { - if (this.isNumber(this.data.form.installheigt)) { - wx.showToast({ - icon: 'none', - title: '到井口距离必须为数值!', - }) - return false - } - } - - return true; - }, - - changeMsg: function () { - var formNew = this.data.form; - var formOld = JSON.parse(this.data.detail); - var descpNew = ""; - if (formNew.devcode != formOld.devcode) { - descpNew += "修改设备编号,原编号:" + formOld.devcode + ",新编号:" + formNew.devcode + ";" - } - if (formNew.devicetype != formOld.devicetype) { - descpNew += "修改设备类型,原设备类型:" + formOld.devicetype + ",新设备类型:" + formNew.devicetype + ";" - } - if (formNew.area != formOld.area) { - descpNew += "修改区,原区:" + formOld.area + ",新区:" + formNew.area + ";" - } - if (formNew.street != formOld.street) { - descpNew += "修改街道,原街道:" + formOld.street + ",新街道:" + formNew.street + ";" - } - if (formNew.wellname != formOld.wellname) { - descpNew += "修改井名称,原井名称:" + formOld.wellname + ",新井名称:" + formNew.wellname + ";" - } - if (formNew.factory != formOld.factory) { - descpNew += "修改权属单位,原权属单位:" + formOld.factory + ",新权属单位:" + formNew.factory + ";" - } - if (formNew.installheigt != formOld.installheigt) { - descpNew += "修改井口距离,原井口距离:" + formOld.installheigt + ",新井口距离:" + formNew.installheigt + ";" - } - if (formNew.installperson != formOld.installperson) { - descpNew += "修改运维人员,原运维人员:" + formOld.installperson + ",新运维人员:" + formNew.installperson + ";" - } - if (formNew.latitude != formOld.latitude) { - descpNew += "修改纬度,原纬度:" + formOld.latitude + ",新纬度:" + formNew.latitude + ";" - } - if (formNew.longitude != formOld.longitude) { - descpNew += "修改经度,原经度:" + formOld.longitude + ",新经度:" + formNew.longitude + ";" - } - if (formNew.position != formOld.position) { - descpNew += "修改位置描述,原位置:" + formOld.position + ",新位置:" + formNew.position + ";" - } - if (formNew.wellcode != formOld.wellcode) { - descpNew += "修改井编号,原编号:" + formOld.wellcode + ",新编号:" + formNew.wellcode + ";" - } - if (formNew.welldepth != formOld.welldepth) { - descpNew += "修改井深,原井深:" + formOld.welldepth + ",新井深:" + formNew.welldepth + ";" - } - if (formNew.welltype != formOld.welltype) { - descpNew += "修改井类型,原井类型:" + formOld.welltype + ",新井类型:" + formNew.welltype + ";" - } - if (formNew.project != formOld.project) { - descpNew += "修改所属项目,原项目:" + formOld.project + ",新项目:" + formNew.project + ";" - } - if (this.data.photopath1 != formOld.photopath1 || - this.data.photopath2 != formOld.photopath2 || - this.data.photopath3 != formOld.photopath3) { - descpNew += "修改照片;" - } - if ("" != formNew.description) { - descpNew += formNew.description; - } - this.setData({ - ['form.description']: descpNew + if (this.data.form.welldepth != null) { + if (this.isNumber(this.data.form.welldepth)) { + wx.showToast({ + icon: 'none', + title: '井深必须为数值!', }) - }, + return false + } + } + if (this.data.form.installheigt != null) { + if (this.isNumber(this.data.form.installheigt)) { + wx.showToast({ + icon: 'none', + title: '到井口距离必须为数值!', + }) + return false + } + } - formSubmit: function (event) { + return true; + }, - if (!this.formValidate()) { - return false; - } - this.changeMsg(); - var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDeviceLog', - data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceLog/add" - }, - }).then(res => { - // var resultObj=JSON.parse(res.result); - if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - if (res.confirm) { - wx.switchTab({ - url: that.data.pageName - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) - } - }).catch(err => { - console.error(err) - wx.showToast({ - title: "提交失败", - }) - }) - }, - confirm(event) { - var that = this; - var formValue = event.detail.value; - var formName = event.target.dataset.id; - var fromN = 'form.' + [formName]; - that.setData({ - [fromN]: formValue - }) - }, + //获取与上次修改的信息 + changeMsg: function () { + var formNew = this.data.form; + console.log(this.data.detail) + var formOld = JSON.parse(this.data.detail); + var descpNew = ""; + if (formNew.devcode != formOld.devcode) { + descpNew += "修改设备编号,原值:" + formOld.devcode + ",新值:" + formNew.devcode + ";" + } + if (formNew.devicetype != formOld.devicetype) { + descpNew += "修改设备类型,原值:" + formOld.devicetype + ",新值:" + formNew.devicetype + ";" + } + if (formNew.area != formOld.area) { + descpNew += "修改区,原值:" + formOld.area + ",新值:" + formNew.area + ";" + } + if (formNew.street != formOld.street) { + descpNew += "修改街道,原值:" + formOld.street + ",新值:" + formNew.street + ";" + } + if (formNew.wellname != formOld.wellname) { + descpNew += "修改井名称,原值:" + formOld.wellname + ",新值:" + formNew.wellname + ";" + } + if (formNew.factory != formOld.factory) { + descpNew += "修改权属单位,原值:" + formOld.factory + ",新值:" + formNew.factory + ";" + } + if (formNew.installheigt != formOld.installheigt) { + descpNew += "修改井口距离,原值:" + formOld.installheigt + ",新值:" + formNew.installheigt + ";" + } + if (formNew.installperson != formOld.installperson) { + descpNew += "修改运维人员,原值:" + formOld.installperson + ",新值:" + formNew.installperson + ";" + } + if (formNew.latitude != formOld.latitude) { + descpNew += "修改纬度,原值:" + formOld.latitude + ",新值:" + formNew.latitude + ";" + } + if (formNew.longitude != formOld.longitude) { + descpNew += "修改经度,原值:" + formOld.longitude + ",新值:" + formNew.longitude + ";" + } + if (formNew.position != formOld.position) { + descpNew += "修改位置描述,原值:" + formOld.position + ",新值:" + formNew.position + ";" + } + if (formNew.wellcode != formOld.wellcode) { + descpNew += "修改井编号,原值:" + formOld.wellcode + ",新值:" + formNew.wellcode + ";" + } + if (formNew.welldepth != formOld.welldepth) { + descpNew += "修改井深,原值:" + formOld.welldepth + ",新值:" + formNew.welldepth + ";" + } + if (formNew.welltype != formOld.welltype) { + descpNew += "修改井类型,原值:" + formOld.welltype + ",新值:" + formNew.welltype + ";" + } + if (formNew.project != formOld.project) { + descpNew += "修改所属项目,原值:" + formOld.project + ",新值:" + formNew.project + ";" + } + if (this.data.form.photopath1 != formOld.photopath1 || + this.data.form.photopath2 != formOld.photopath2 || + this.data.form.photopath3 != formOld.photopath3) { + descpNew += "修改照片;" + } + if ("" != formNew.description) { + descpNew += formNew.description; + } + this.setData({ + ['form.description']: descpNew + }) + }, - scan() { + //提交表单 + formSubmit: function (event) { - wx.scanCode({ - success(res) { - console.log(res) - } - }) + //表单验证 + if (!this.formValidate()) { + return false; + } + //自动生成修改内容 + this.changeMsg(); + //提交权限限制(只有施工人员能修改) + if(app.globalData.role!='repair'){ + wx.showToast({ + icon: 'none', + title: '无权限修改', + duration:2000 + }) + return false + } + var that = this; + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopath = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopath]: fileList[i].url.split("static/")[1] + }) + } + delete that.data.form.installtime + delete that.data.form.createtime + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - paste() { - var _this = this; - wx.getClipboardData({ - success: function (res) { - var longitude = 'form.longitude'; - var latitude = 'form.latitude'; - var longitude84 = 'form.longitude84'; - var latitude84 = 'form.latitude84'; - _this.setData({ - [longitude]: parseFloat(res.data.split(",", 4)[1]).toFixed(6), - [latitude]: parseFloat(res.data.split(",", 4)[0]).toFixed(6), - [longitude84]: "" == (res.data.split(",", 4)[3]) ? "" : parseFloat(res.data.split(",", 4)[3]).toFixed(6), - [latitude84]: "" == (res.data.split(",", 4)[2]) ? "" : parseFloat(res.data.split(",", 4)[2]).toFixed(6), - longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), - latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), - }); - } - }) - }, - selectValue(value) { - var that = this; - var wellType = 'form.welltype'; - that.setData({ - [wellType]: value.detail - }) - }, - selectpersonValue(event) { - var that = this; - var installPerson = 'form.installperson'; - that.setData({ - [installPerson]: event.detail - }) - }, - selectprojectValue(event) { - var that = this; - var project = 'form.project'; - that.setData({ - [project]: event.detail, - showMask: true - }) - }, - open() { - this.setData({ - showMask: true - }) - }, - close() { - this.setData({ - showMask: false - }) - }, - afterRead(event) { - var _this = this; - const { - file - } = event.detail; - const { - fileList = [] - } = _this.data; - var convertpath = ""; - wx.compressImage({ - src: event.detail.file.path, - quality: 25, - success: function (res) { - convertpath = res.tempFilePath; - wx.uploadFile({ - url: app.globalData.httpsUrl + "appDeviceAdd/fileUploadMarker", - filePath:convertpath, - name: 'file', - formData: { - 'text': "编号:" + _this.data.form.devcode + "经度:" + _this.data.form.longitude + "纬度:" + _this.data.form.latitude - }, - header: { - "Content-Type": "multipart/form-data", - 'accept': 'application/json', - }, - success(res) { - if (res.data) { - var url = JSON.parse(res.data); - fileList.push({ - ...file, - url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - }); - _this.setData({ - fileList - }); - } - } + success(res) { + if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + if (res.confirm) { + wx.switchTab({ + url: that.data.pageName }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') } - }) - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // // var base64 = "data:image/png;base64," + wx.getFileSystemManager().readFileSync(convertpath, 'base64'); - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: convertpath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // // wx.cloud.callFunction({ - // // name: 'uploadFile', - // // data: { - // // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // // fileBase64: base64 - // // }, - // // success: function (res) { - // // if (res.result) { - // // fileList.push({ - // // ...file, - // // url: app.globalData.url + "static/" + res.result.data.replace(/\\/g, "/") - // // }); - // // _this.setData({ - // // fileList - // // }); - // // } - // // }, - // // complete: res => { - // // }, - // // }) - // } - // }); + } + }) + } + }, + fail(err) { + wx.showToast({ + title: "提交失败", + }) + } + }) + }, + //报存录入的input信息 + confirm(event) { + var that = this; + var formValue = event.detail.value; + var formName = event.target.dataset.id; + var fromN = 'form.' + [formName]; + that.setData({ + [fromN]: formValue + }) + }, + + //扫码 + scan() { + + wx.scanCode({ + success(res) { + console.log(res) + } + }) + }, + //粘贴经纬度 + paste() { + var _this = this; + wx.getClipboardData({ + success: function (res) { + var longitude = 'form.longitude'; + var latitude = 'form.latitude'; + var longitude84 = 'form.longitude84'; + var latitude84 = 'form.latitude84'; + _this.setData({ + [longitude]: parseFloat(res.data.split(",", 4)[1]).toFixed(6), + [latitude]: parseFloat(res.data.split(",", 4)[0]).toFixed(6), + [longitude84]: "" == (res.data.split(",", 4)[3]) ? "" : parseFloat(res.data.split(",", 4)[3]).toFixed(6), + [latitude84]: "" == (res.data.split(",", 4)[2]) ? "" : parseFloat(res.data.split(",", 4)[2]).toFixed(6), + longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), + latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), + }); + } + }) + }, + selectValue(value) { + var that = this; + var wellType = 'form.welltype'; + that.setData({ + [wellType]: value.detail + }) + }, + //运维人员默认为登录人 + // selectpersonValue(event) { + // var that = this; + // var installPerson = 'form.installperson'; + // that.setData({ + // [installPerson]: event.detail + // }) + // }, + selectprojectValue(event) { + var that = this; + var project = 'form.project'; + that.setData({ + [project]: event.detail, + showMask: true + }) + }, + + open() { + this.setData({ + showMask: true + }) + }, + //隐藏textarea,防止遮挡 + close() { + this.setData({ + showMask: false + }) + }, + //上传照片 + afterRead(event) { + var _this = this; + const { + file + } = event.detail; + const { + fileList = [] + } = _this.data; + var convertpath = ""; + wx.compressImage({ + src: event.detail.file.path, + quality: 25, + success: function (res) { + convertpath = res.tempFilePath; + wx.uploadFile({ + url: app.globalData.httpsUrl + "appDeviceAdd/fileUploadMarker", + filePath: convertpath, + name: 'file', + formData: { + 'text': "编号:" + _this.data.form.devcode + "经度:" + _this.data.form.longitude + "纬度:" + _this.data.form.latitude }, - deletePhoto(event) { - var that = this - var image_index = event.detail.index - var fileList_new = that.data.fileList; - wx.showModal({ - content: '确定删除照片?', - success: function (res) { - if (res.confirm) { - fileList_new.splice(image_index, 1); - that.setData({ - fileList: fileList_new - }) - wx.cloud.callFunction({ - name: 'deletePhoto', - data: { - url: app.globalData.url + "appDeviceLog/deletePhoto", - devcode: that.data.form.devcode, - pathIndex: image_index - }, - success: function (res) {}, - complete: res => {}, - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + "Content-Type": "multipart/form-data", + 'accept': 'application/json', }, - }) \ No newline at end of file + success(res) { + if (res.data) { + var url = JSON.parse(res.data); + fileList.push({ + ...file, + url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") + }); + _this.setData({ + fileList + }); + } + } + }) + } + }) + }, + //删除照片 + deletePhoto(event) { + var that = this + var image_index = event.detail.index + var fileList_new = that.data.fileList; + wx.showModal({ + content: '确定删除照片?', + success: function (res) { + if (res.confirm) { + fileList_new.splice(image_index, 1); + that.setData({ + fileList: fileList_new + }) + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deletePhoto", + data: { + devcode: that.data.form.devcode + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) {} + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } +}) \ No newline at end of file diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.wxml b/miniprogram/pages/addDevicelog/addDeviceLog.wxml index 38620d4..b10cc7d 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.wxml +++ b/miniprogram/pages/addDevicelog/addDeviceLog.wxml @@ -1,15 +1,21 @@ - + + + + + - + - - + + - - + + - + @@ -39,24 +45,25 @@ - - - + + + - + - + + @@ -64,7 +71,7 @@ - + @@ -79,9 +86,9 @@ - + - 保存 + 保存 diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.wxss b/miniprogram/pages/addDevicelog/addDeviceLog.wxss index ee0b75c..08d5fd7 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.wxss +++ b/miniprogram/pages/addDevicelog/addDeviceLog.wxss @@ -24,6 +24,17 @@ display: flex; align-items: center; } +.map-view{ + width: 750rpx; + height: 485rpx; + position: fixed; + top: 0px; + left: 0px; + z-index: 999; +} +.content{ + margin-top: 495rpx; +} .left { width: 210rpx; diff --git a/miniprogram/pages/addFunction/addFunction.js b/miniprogram/pages/addFunction/addFunction.js deleted file mode 100644 index 4966be3..0000000 --- a/miniprogram/pages/addFunction/addFunction.js +++ /dev/null @@ -1,60 +0,0 @@ -// pages/addFunction/addFunction.js - -const code = `// 云函数入口函数 -exports.main = (event, context) => { - console.log(event) - console.log(context) - return { - sum: event.a + event.b - } -}` - -Page({ - - data: { - result: '', - canIUseClipboard: wx.canIUse('setClipboardData'), - }, - - onLoad: function (options) { - - }, - - copyCode: function() { - wx.setClipboardData({ - data: code, - success: function () { - wx.showToast({ - title: '复制成功', - }) - } - }) - }, - - testFunction() { - wx.cloud.callFunction({ - name: 'sum', - data: { - a: 1, - b: 2 - }, - success: res => { - wx.showToast({ - title: '调用成功', - }) - this.setData({ - result: JSON.stringify(res.result) - }) - }, - fail: err => { - wx.showToast({ - icon: 'none', - title: '调用失败', - }) - console.error('[云函数] [sum] 调用失败:', err) - } - }) - }, - -}) - diff --git a/miniprogram/pages/addFunction/addFunction.json b/miniprogram/pages/addFunction/addFunction.json deleted file mode 100644 index a9a50c5..0000000 --- a/miniprogram/pages/addFunction/addFunction.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "navigationBarTitleText": "云函数指引", - "usingComponents": {} -} \ No newline at end of file diff --git a/miniprogram/pages/addFunction/addFunction.wxml b/miniprogram/pages/addFunction/addFunction.wxml deleted file mode 100644 index 3a10626..0000000 --- a/miniprogram/pages/addFunction/addFunction.wxml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - 测试云函数 - - - 期望输出:{"sum":3} - - - 调用结果:{{result}} - - - - - 新增云函数 - 1. 在云函数根目录 cloudfunctions 上右键选择新建云函数,命名为 sum - 2. 在创建的 cloudfunctions/sum/index.js 文件中添加如下代码 - - - 3. 在 cloudfunctions/sum 目录上右键上传并部署 - 4. 点击测试云函数测试 - 5. 打开云开发云函数管理页,选择 sum 云函数 - 6. 查看 sum 的调用日志 - 进阶:可在云函数中使用 wx-server-sdk 操作数据库,文件存储和调用其他云函数,详见文档 - - - diff --git a/miniprogram/pages/addFunction/addFunction.wxss b/miniprogram/pages/addFunction/addFunction.wxss deleted file mode 100644 index 7ac8619..0000000 --- a/miniprogram/pages/addFunction/addFunction.wxss +++ /dev/null @@ -1,3 +0,0 @@ -/* pages/addFunction/addFunction.wxss */ - -@import "../../style/guide.wxss"; \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.js b/miniprogram/pages/applog/applog.js index 0e8c185..189e61f 100644 --- a/miniprogram/pages/applog/applog.js +++ b/miniprogram/pages/applog/applog.js @@ -13,98 +13,25 @@ isSeach: "false", params: {}, total: 0, - show: false + show: false, + delBtnWidth: 100, //删除按钮宽度单位(rpx) + activeIndex: -1, + list_style: '' }, - - touchE: function (e) { - // console.log(e); - var that = this - if (e.changedTouches.length == 1) { - //手指移动结束后触摸点位置的X坐标 - var endX = e.changedTouches[0].clientX; - //触摸开始与结束,手指移动的距离 - var disX = that.data.startX - endX; - var delBtnWidth = that.data.delBtnWidth; - //如果距离小于删除按钮的1/2,不显示删除按钮 - var txtStyle = disX > delBtnWidth / 2 ? "left:-" + delBtnWidth + "rpx" : "left:0rpx"; - - //获取手指触摸的是哪一项 - var index = e.currentTarget.dataset.index; - var list = that.data.deviceloglist; - list[index].txtStyle = txtStyle; - //更新列表的状态 - that.setData({ - deviceloglist: list - }); - } - }, - //手指触摸动作开始 记录起点X坐标 - touchstart: function (e) { - //开始触摸时 重置所有删除 - this.data.deviceloglist.forEach(function (v, i) { - if (v.isTouchMove) //只操作为true的 - v.isTouchMove = false; - }) - this.setData({ - startX: e.changedTouches[0].clientX, - startY: e.changedTouches[0].clientY, - deviceloglist: this.data.deviceloglist - }) - }, - //滑动事件处理 - touchmove: function (e) { - var that = this, - index = e.currentTarget.dataset.index, //当前索引 - startX = that.data.startX, //开始X坐标 - startY = that.data.startY, //开始Y坐标 - touchMoveX = e.changedTouches[0].clientX, //滑动变化坐标 - touchMoveY = e.changedTouches[0].clientY, //滑动变化坐标 - //获取滑动角度 - angle = that.angle({ - X: startX, - Y: startY - }, { - X: touchMoveX, - Y: touchMoveY - }); - that.data.deviceloglist.forEach(function (v, i) { - v.isTouchMove = false - //滑动超过30度角 return - if (Math.abs(angle) > 30) return; - if (i == index) { - if (touchMoveX > startX) //右滑 - v.isTouchMove = false - else //左滑 - v.isTouchMove = true - } - }) - //更新数据 - that.setData({ - deviceloglist: that.data.deviceloglist - }) - }, - /** - * 计算滑动角度 - * @param {Object} start 起点坐标 - * @param {Object} end 终点坐标 - */ - angle: function (start, end) { - var _X = end.X - start.X, - _Y = end.Y - start.Y - //返回角度 /Math.atan()返回数字的反正切值 - return 360 * Math.atan(_Y / _X) / (2 * Math.PI); - }, - /** - * 生命周期函数--监听页面加载var_this=this; - */ onLoad: function (options) { - if (options.params) { this.setData({ params: JSON.parse(options.params), isSeach: "true" }) this.initPages() + }else{ + this.setData({ + show: false + }) + //清空参数,重新加载 + this.clearParams(); + this.initPages(); } }, @@ -116,20 +43,33 @@ }, + //点击tabBar事件 + onTabItemTap(item) { + //隐藏历史显示总记录条数 + this.setData({ + show: false + }) + //清空参数,重新加载 + this.clearParams(); + this.initPages(); + }, + + /** * 生命周期函数--监听页面显示 */ onShow: function (options) { - this.setData({ - show:false - }) - if (this.data.isSeach == "false") { - this.clearParams(); - this.initPages(); - } - this.setData({ - isSeach: "false" - }) + + // this.setData({ + // show: false + // }) + // if (this.data.isSeach == "false") { + // this.clearParams(); + // this.initPages(); + // } + // this.setData({ + // isSeach: "false" + // }) }, /** @@ -167,6 +107,119 @@ }, + + //手指触摸动作开始 记录起点X坐标 + touchstart: function (e) { + //开始触摸时 重置所有删除 + this.data.deviceloglist.forEach(function (v, i) { + if (v.isTouchMove) //只操作为true的 + v.isTouchMove = false; + }) + this.setData({ + startX: e.changedTouches[0].clientX, + startY: e.changedTouches[0].clientY, + deviceloglist: this.data.deviceloglist + }) + }, + + //滑动事件处理 + touchmove: function (e) { + var that = this, + index = e.currentTarget.dataset.index, //当前索引 + startX = that.data.startX, //开始X坐标 + startY = that.data.startY, //开始Y坐标 + touchMoveX = e.changedTouches[0].clientX, //滑动变化坐标 + touchMoveY = e.changedTouches[0].clientY, //滑动变化坐标 + //获取滑动角度 + angle = that.angle({ + X: startX, + Y: startY + }, { + X: touchMoveX, + Y: touchMoveY + }); + that.data.deviceloglist.forEach(function (v, i) { + // v.isTouchMove = false + //滑动超过30度角 return + if (Math.abs(angle) > 30) return; + if (i == index) { + if (touchMoveX > startX) //右滑 + v.isTouchMove = false + else //左滑 + v.isTouchMove = true + } + }) + //更新数据 + that.setData({ + deviceloglist: that.data.deviceloglist + }) + }, + + /** + * 计算滑动角度 + * @param {Object} start 起点坐标 + * @param {Object} end 终点坐标 + */ + angle: function (start, end) { + var _X = end.X - start.X, + _Y = end.Y - start.Y + //返回角度 /Math.atan()返回数字的反正切值 + return 360 * Math.atan(_Y / _X) / (2 * Math.PI); + }, + + //删除事件 + delItem: function (e) { + if(app.globalData.role!='repair'){ + wx.showToast({ + icon: 'none', + title: '无权限删除', + duration:2000 + }) + return false + } + var that = this + wx.showModal({ + content: '是否删除?', + success: function (res) { + if (res.confirm) { + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/delete", + data: { + appDeviceAddId: e.currentTarget.dataset.devid + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if(res.data.code=='200'){ + that.data.deviceloglist.splice(e.currentTarget.dataset.index, 1) + that.setData({ + deviceloglist: that.data.deviceloglist, + total: that.data.deviceloglist.length + }) + wx.showToast({ + title: '删除成功!', + icon: 'none', + duration: 1000 + }) + } + }, + fail(err) { + wx.showToast({ + title: '删除失败!', + icon: 'none', + duration: 2000 + }) + } + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + }, + showLoading: function (message) { if (wx.showLoading) { // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 @@ -199,95 +252,105 @@ deviceloglist: [] }) }, + //查询列表数据 initPages: function () { var that = this + that.setData({ + show: false + }) var offsetValue = that.data.deviceloglist.length % 15 > 0 ? parseInt(that.data.deviceloglist.length / 15) + 2 : parseInt(that.data.deviceloglist.length / 15) + 1 - wx.cloud.callFunction({ - name: 'devicelog', + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/listPage", data: { devcode: that.data.params.devcode, devtype: that.data.params.devtype, installtimeFmt: that.data.params.installtimeFmt, project: that.data.params.project, installPerson: that.data.params.installPerson, - url: app.globalData.url + "appDeviceLog/listPage", limit: 15, offset: offsetValue }, - }).then(res => { - if (res.result.data.rows.length > 0) { - var resultJson = res.result - that.setData({ - deviceloglist: that.data.deviceloglist.concat(resultJson.data.rows) - }) - } else if (that.data.deviceloglist.length > 0) { - that.setData({ - show: true, - total: that.data.deviceloglist.length - }) - wx.showToast({ - title: '数据已全部加载完', - icon: 'none', - duration: 2000 - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.data.rows.length > 0) { + var resultJson = res.data + var listArr = resultJson.data.rows + listArr.forEach(function (v, i) { + listArr[i]['isTouchMove'] = false + }) + that.setData({ + deviceloglist: that.data.deviceloglist.concat(listArr) + }) + } else if (that.data.deviceloglist.length > 0) { + that.setData({ + show: true, + total: that.data.deviceloglist.length + }) + wx.showToast({ + title: '数据已全部加载完', + icon: 'none', + duration: 2000 + }) + } + if (offsetValue == 1 && res.data.data.rows.length < 15) { + that.setData({ + show: true, + total: that.data.deviceloglist.length + }) + } } - if(offsetValue==1&&res.result.data.rows.length<15){ - that.setData({ - show: true, - total: that.data.deviceloglist.length - }) - } - // console.log(res); - }).catch(err => { - console.error(err); }) + }, addDetail: function (event) { - this.showLoading("数据请求中..."); - wx.cloud.callFunction({ - name: 'deviceDetail', + var that = this + that.showLoading("数据请求中..."); + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deviceDetail", data: { devcode: event.target.dataset.devcode, - url: app.globalData.url + "appDeviceLog/deviceDetail", }, - }).then(res => { - this.hideLoading(); - var resultObject = JSON.parse(res.result); - var pageName = '../applog/applog' - if (resultObject.code == 200) { - wx.navigateTo({ - url: '../addDevicelog/addDeviceLog?detail=' + - JSON.stringify(resultObject.data) + "&pageName=" + pageName - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + that.hideLoading(); + // var resultObject = JSON.parse(res.data); + var resultObject = res.data; + var pageName = '../applog/applog' + if (resultObject.code == 200) { + wx.setStorageSync('resultObject', resultObject.data) + wx.navigateTo({ + url: '../addDevicelog/addDeviceLog?detail=' + "&pageName=" + pageName + }) + } + }, + fail(err) { + that.hideLoading(); } - }).catch(err => { - this.hideLoading() }) + }, add: function (event) { - wx.reLaunch({ - url: '../earth/earth?devcode=' + event.target.dataset.devcode - // url: '../earth/earth' + app.globalData.devcode = event.target.dataset.devcode; + wx.switchTab({ + url: '../earth/earth' }) + // wx.reLaunch({ + // url: '../earth/earth?devcode=' + event.target.dataset.devcode + // // url: '../earth/earth' + // }) }, onSearch: function () { + var _this = this wx.navigateTo({ - url: '../searchLog/searchLog' + url: '../searchLog/searchLog?params=' + JSON.stringify(_this.data.params) }) - }, - // initPages: function () { - // wx.cloud.callFunction({ - // name: 'devicelog' - // }).then(res => { - // var that = this; - // var jsonList = JSON.parse(res.result) - // that.setData({ - // deviceloglist: jsonList.data.rows - // }) - // console.log(res); - // }).catch(err => { - // console.error(err); - // }) - // } + } }) \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.wxml b/miniprogram/pages/applog/applog.wxml index e9a2352..2bfd041 100644 --- a/miniprogram/pages/applog/applog.wxml +++ b/miniprogram/pages/applog/applog.wxml @@ -1,54 +1,59 @@ - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {{item.devcode}} {{item.devicetype}} + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + {{item.devcode}} {{item.devicetype}} + + {{item.project}} {{item.installtime}}- {{item.installperson}} - - - - - + + + + + + 删除 - - - + + - 共计:{{total}}台 - + 共计:{{total}}台 + \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.wxss b/miniprogram/pages/applog/applog.wxss index 6d3428b..e6e8983 100644 --- a/miniprogram/pages/applog/applog.wxss +++ b/miniprogram/pages/applog/applog.wxss @@ -22,16 +22,18 @@ position: fixed; width: 100%; top: 0rpx; + z-index: 9999; /* margin-bottom: 100rpx; */ } .log-list { /* height: 100rpx; */ - /* display: flex; */ - + display: flex; + width: 100%; padding: 2px; margin-top: 2px; border-bottom: 1px solid #e5e5e5; + overflow: hidden } @@ -53,23 +55,29 @@ left: 35%; margin: 20rpx } - .del { - width: 90px; + /* display: flex; */ + width: 100rpx; display: flex; flex-direction: column; align-items: center; justify-content: center; - color: #fff; - -webkit-transform: translateX(90px); - transform: translateX(90px); - -webkit-transition: all 0.4s; + /* -webkit-transform: translateX(100rpx); */ + transform: translateX(100rpx); + /* -webkit-transition: all 0.4s; */ transition: all 0.4s; - font-size: 35rpx; + color: #fff; + background-color: #fe3e2f; +} +.logrow{ + width: 100%; + transform: translateX(100rpx); + /* -webkit-transform: translateX(100px); */ + margin-left: -100rpx; } -.touch-move-active .content, +.touch-move-active .logrow, .touch-move-active .del { - -webkit-transform: translateX(0); - transform: translateX(0); +/* -webkit-transform: translateX(0); */ +transform: translateX(0); } \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.js b/miniprogram/pages/deployFunctions/deployFunctions.js deleted file mode 100644 index a76b144..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.js +++ /dev/null @@ -1,66 +0,0 @@ -// pages/deployFunctions/deployFunctions.js -Page({ - - /** - * 页面的初始数据 - */ - data: { - - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - - }, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { - - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - - }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { - - }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { - - } -}) \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.json b/miniprogram/pages/deployFunctions/deployFunctions.json deleted file mode 100644 index 7fbedab..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "navigationBarTitleText": "部署云函数", - "usingComponents": {} -} \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.wxml b/miniprogram/pages/deployFunctions/deployFunctions.wxml deleted file mode 100644 index 462b6b6..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.wxml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - 调用失败 - - - 请检查 login 云函数是否已部署 - - - - - 部署 login 云函数 - 1. 确保已通过工具栏云开发入口开通云开发 - 2. 在 cloudfunctions/login 目录上右键上传并部署 - 3. 回到首页,重新点击获取 openid - - - - diff --git a/miniprogram/pages/deployFunctions/deployFunctions.wxss b/miniprogram/pages/deployFunctions/deployFunctions.wxss deleted file mode 100644 index c8803e6..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.wxss +++ /dev/null @@ -1,7 +0,0 @@ -/* pages/deployFunctions/deployFunctions.wxss */ - -@import "../../style/guide.wxss"; - -.black { - color: black; -} \ No newline at end of file diff --git a/miniprogram/pages/earth/earth.js b/miniprogram/pages/earth/earth.js index ae0d3f3..376a6e2 100644 --- a/miniprogram/pages/earth/earth.js +++ b/miniprogram/pages/earth/earth.js @@ -21,19 +21,12 @@ show: false, enableSsatellite: false, windowWidth: 0, - longitude: 113.324520, - latitude: 23.099994, - longitude84: 113.324520, - latitude84: 23.099994, - markers: [{ - id: 0, - iconPath: "../../images/locat.png", - latitude: 23.099994, - longitude: 113.324520, - width: 50, - height: 50 - }], - controls: [], + longitude: "116.627340", + latitude: "39.874390", + longitude84: "", + latitude84: "", + markers: [], + controls: [] }, /** @@ -41,39 +34,13 @@ */ onLoad: function (options) { var that = this; - //获取当前坐标(gcj02) - wx.getLocation({ - type: "gcj02", - altitude: true, - success: function (res) { - that.setData({ - latitude: parseFloat(res.latitude).toFixed(6), - longitude: parseFloat(res.longitude).toFixed(6), - // markers: [{ - // latitude: res.latitude, - // longitude: res.longitude, - // }] - }) - //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 - wx.getLocation({ - type: "wgs84", - altitude: true, - success: function (res) { - that.setData({ - latitude84: parseFloat(res.latitude).toFixed(6), - longitude84: parseFloat(res.longitude).toFixed(6) - }) - } - }) - } - }), - - //设置地图组件 - wx.getSystemInfo({ + //设置地图组件 + wx.getSystemInfo({ success(res) { var windowWidth = res.windowWidth var windowHeight = res.windowHeight var query = wx.createSelectorQuery() + var platform =res.platform query.select('#map').boundingClientRect() query.exec(function (res) { that.setData({ @@ -139,10 +106,20 @@ clickable: true }, { id: 7, - iconPath: '../../images/locat.png', + iconPath: '../../images/applocat.png', position: { - left: res[0].width/2, - top: res[0].height/2, + left: res[0].width / 2 - 20, + top: platform=="ios"?res[0].height / 2 - 80:res[0].height / 2 - 40, + width: 40, + height: 40 + }, + clickable: true + }, { + id: 8, + iconPath: '../../images/back.png', + position: { + left: windowWidth - 40, + top: windowHeight - 140, width: 30, height: 30 }, @@ -150,71 +127,15 @@ }] }) }) - + } - }), + }) + // 实例化API核心类 qqmapsdk = new QQMapWX({ key: 'BGPBZ-C5O3P-ROUDR-LWC4J-63EKH-V5FRX' }) - - if (options.devcode) { - var that = this - var devcode = options.devcode - wx.cloud.callFunction({ - name: 'findListByCodes', - data: { - devcodes: devcode, - url: app.globalData.url + "appDeviceAdd/findListByCodes" - }, - }).then(res => { - if (res.result.code == 200) { - var listResultData = res.result.data; - that.setData({ - listData: listResultData - }) - var markersArr = that.data.markers; - for (var i = 0; i < listResultData.length; i++) { - markersArr = markersArr.concat({ - iconPath: "../../images/locat.png", - id: listResultData[i].id, - callout: { - content: listResultData[i].devcode, - fontSize: '14', - // padding: true, - color: '#00000', - borderColor: '#F4EA2A', - bgColor: '#F4EA2A', - borderWidth: 5, - display: 'ALWAYS', - textAlign: 'center', - // borderRadius: 15 - }, - latitude: listResultData[i].latitude, - longitude: listResultData[i].longitude, - width: 40, - height: 40 - }); - } - this.setData({ - markers: markersArr, - latitude: listResultData[0].latitude, - longitude: listResultData[0].longitude, - marker_latitude: listResultData[0].latitude, - marker_longitude: listResultData[0].longitude, - title: listResultData[0].devcode - }) - } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "无法获取设备地理信息!", - icon: 'none', - duration: 2000 - }) - }) - } }, /** @@ -228,6 +149,97 @@ * 生命周期函数--监听页面显示 */ onShow: function () { + //输入设备编号获取marker位置信息 + var that = this; + if ( app.globalData.devcode!="") { + var devcode = app.globalData.devcode + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/findListByCodes", + data: { + devcodes: devcode, + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + app.globalData.devcode=""; + if (res.data.code == 200) { + var listResultData = res.data.data; + that.setData({ + listData: listResultData + }) + var markersArr = that.data.markers; + for (var i = 0; i < listResultData.length; i++) { + markersArr = markersArr.concat({ + iconPath: "../../images/locat.png", + id: Number(listResultData[i].id), + callout: { + content: "编号:"+listResultData[i].devcode+"\r\n位置:"+listResultData[i].position+"\r\n时间:"+listResultData[i].createtime, + fontSize: '14', + padding: true, + color: '#000000', + borderColor: '#F4EA2A', + bgColor: '#F4EA2A', + borderWidth: 5, + display: 'ALWAYS', + textAlign: 'left', + // borderRadius: 15 + }, + latitude: listResultData[i].latitude, + longitude: listResultData[i].longitude, + width: 40, + height: 40 + }); + } + that.setData({ + markers: markersArr, + latitude: listResultData[0].latitude, + longitude: listResultData[0].longitude, + marker_latitude: listResultData[0].latitude, + marker_longitude: listResultData[0].longitude, + title: listResultData[0].devcode + }) + } + }, + fail(err) { + app.globalData.devcode=""; + wx.showToast({ + title: "无法获取设备地理信息!", + icon: 'none', + duration: 2000 + }) + } + }) +} else { + //获取当前坐标(gcj02) + wx.getLocation({ + type: "gcj02", + altitude: true, + success: function (res) { + that.setData({ + latitude: parseFloat(res.latitude).toFixed(6), + longitude: parseFloat(res.longitude).toFixed(6), + // markers: [{ + // latitude: res.latitude, + // longitude: res.longitude, + // }] + }) + //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 + wx.getLocation({ + type: "wgs84", + altitude: true, + success: function (res) { + that.setData({ + latitude84: parseFloat(res.latitude).toFixed(6), + longitude84: parseFloat(res.longitude).toFixed(6) + }) + } + }) + } + }) +} + }, @@ -265,12 +277,46 @@ onShareAppMessage: function () { }, + + //定位出来 + + locationPosition: function () { + var that = this; + //获取当前坐标(gcj02) + wx.getLocation({ + type: "gcj02", + altitude: true, + success: function (res) { + that.setData({ + latitude: parseFloat(res.latitude).toFixed(6), + longitude: parseFloat(res.longitude).toFixed(6), + // markers: [{ + // latitude: res.latitude, + // longitude: res.longitude + // }] + }) + //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 + wx.getLocation({ + type: "wgs84", + altitude: true, + success: function (res) { + that.setData({ + latitude84: parseFloat(res.latitude).toFixed(6), + longitude84: parseFloat(res.longitude).toFixed(6) + }) + } + }) + } + }) + }, + + //加载地图组件 controltap: function (e) { // console.log(e.controlId); //进入添加设备页 if (1 == e.controlId) { wx.setClipboardData({ - data: this.data.latitude + "," + this.data.longitude+ "," + this.data.latitude84+ "," + this.data.longitude84, + data: this.data.latitude + "," + this.data.longitude + "," + this.data.latitude84 + "," + this.data.longitude84, success: function (res) { wx.getClipboardData({ success: function (res) { @@ -282,6 +328,17 @@ } }) } else if (3 == e.controlId) { + //先定位 + // this.locationPosition() + wx.setClipboardData({ + data: this.data.latitude + "," + this.data.longitude + "," + this.data.latitude84 + "," + this.data.longitude84, + success: function (res) { + wx.showToast({ + title: '坐标已获取', + duration: 1000 + }) + } + }) wx.navigateTo({ url: '../addDevice/addDevice' }) @@ -302,32 +359,15 @@ enableSsatellite: !flag }); } else if (6 == e.controlId) { - var that = this; - //获取当前坐标(gcj02) - wx.getLocation({ - type: "gcj02", - altitude: true, - success: function (res) { - that.setData({ - latitude: parseFloat(res.latitude).toFixed(6), - longitude:parseFloat(res.longitude).toFixed(6), - // markers: [{ - // latitude: res.latitude, - // longitude: res.longitude - // }] - }) - //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 - wx.getLocation({ - type: "wgs84", - altitude: true, - success: function (res) { - that.setData({ - latitude84: parseFloat(res.latitude).toFixed(6), - longitude84: parseFloat(res.longitude).toFixed(6) - }) - } - }) - } + //先清marker + this.setData({ + markers: [] + }) + this.locationPosition() + }else if (8 == e.controlId) { + //跳转日志缓存页 + wx.switchTab({ + url: '../applog/applog', }) } }, @@ -343,63 +383,68 @@ }); }, + //获取设备maker leave() { var that = this; if (that.data.devcodes == "") { return false; } - wx.cloud.callFunction({ - name: 'findListByCodes', + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/findListByCodes", data: { - devcodes: that.data.devcodes, - url: app.globalData.url + "appDeviceAdd/findListByCodes" + devcodes: that.data.devcodes }, - }).then(res => { - if (res.result.code == 200) { - var listResultData = res.result.data; - that.setData({ - listData: listResultData - }) - var markersArr = that.data.markers; - for (var i = 0; i < listResultData.length; i++) { - markersArr = markersArr.concat({ - iconPath: "../../images/locat.png", - id: listResultData[i].id, - callout: { - content: listResultData[i].devcode, - fontSize: '14', - // padding: true, - color: '', - borderColor: '#F4EA2A', - bgColor: '#F4EA2A', - borderWidth: 5, - display: 'ALWAYS', - textAlign: 'center', - // borderRadius: 15 - }, - latitude: listResultData[i].latitude, - longitude: listResultData[i].longitude, - width: 40, - height: 40 - }); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var listResultData = res.data.data; + that.setData({ + listData: listResultData + }) + var markersArr = that.data.markers; + for (var i = 0; i < listResultData.length; i++) { + markersArr = markersArr.concat({ + iconPath: "../../images/locat.png", + id: listResultData[i].id, + callout: { + content: "编号:"+listResultData[i].devcode+"\r\n位置:"+listResultData[i].position+"\r\n时间:"+listResultData[i].createtime, + fontSize: '14', + // padding: true, + color: '#212121', + borderColor: '#F4EA2A', + bgColor: '#F4EA2A', + borderWidth: 5, + display: 'ALWAYS', + textAlign: 'left', + // borderRadius: 15 + }, + latitude: listResultData[i].latitude, + longitude: listResultData[i].longitude, + width: 40, + height: 40 + }); + } + that.setData({ + markers: markersArr, + latitude: listResultData[0].latitude, + longitude: listResultData[0].longitude, + marker_latitude: listResultData[0].latitude, + marker_longitude: listResultData[0].longitude, + title: listResultData[0].devcode + }) } - this.setData({ - markers: markersArr, - latitude: listResultData[0].latitude, - longitude: listResultData[0].longitude, - marker_latitude: listResultData[0].latitude, - marker_longitude: listResultData[0].longitude, - title: listResultData[0].devcode + }, + fail(err) { + wx.showToast({ + title: "无法获取设备地理信息!", + icon: 'none', + duration: 2000 }) } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "无法获取设备地理信息!", - icon: 'none', - duration: 2000 - }) }) }, @@ -422,6 +467,8 @@ } }, + + bindregionchange: function (e) { var that = this if (e.causedBy == "drag") { @@ -445,8 +492,8 @@ that.setData({ latitude: parseFloat(latitude).toFixed(6), longitude: parseFloat(longitude).toFixed(6), - latitude84:"", - longitude84:"", + latitude84: "", + longitude84: "", // markers: markersArr }) // mapCtx.moveToLocation(); @@ -465,16 +512,19 @@ qqmapsdk.search({ keyword: this.data.value, success: function (res) { + console.log(res) if (res && res.data) { _this.setData({ isShow: true, tips: res.data }); } + }, + complete: function (res){ + console.log(res); } }) }, - bindSearch: function (e) { var location = e.target.dataset.location; this.setData({ diff --git a/miniprogram/pages/earth/earth.wxml b/miniprogram/pages/earth/earth.wxml index a0db6ef..87474f8 100644 --- a/miniprogram/pages/earth/earth.wxml +++ b/miniprogram/pages/earth/earth.wxml @@ -1,9 +1,10 @@ + - + {{item.title}} {{item.address}} @@ -17,6 +18,6 @@ + placeholder="请输入定位设备编号用换行隔开" autosize border="{{ false }}" /> \ No newline at end of file diff --git a/miniprogram/pages/indexapp/indexapp.js b/miniprogram/pages/indexapp/indexapp.js index 5063372..849dbdb 100644 --- a/miniprogram/pages/indexapp/indexapp.js +++ b/miniprogram/pages/indexapp/indexapp.js @@ -7,9 +7,8 @@ */ data: { - count:1, - show: false, - onshow:true, + count: 1, + onshow: true, value: "", deviceloglist: [], devcode: "", @@ -21,6 +20,7 @@ // iconPath: "../../images/point.png", latitude: 23.099994, longitude: 113.324520, + label:'1', width: 50, height: 50 }], @@ -31,62 +31,26 @@ * 生命周期函数--监听页面加载 */ onLoad: function (options) { - + }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { - + }, /** * 生命周期函数--监听页面显示 */ onShow: function () { - // if( app.globalData.indexCount>1){ - // this.setData({ - // show:false - // }) - // }else{ - // this.showNotice() - // } - if(app.globalData.indexCount==1){ - this.setData({ - show:true - }) - this.showNotice() - } - app.globalData.indexCount+=1 - if(this.data.onshow){ + if (this.data.onshow) { this.initPages(); } }, - - showNotice: function() { - var that = this - var times = 0 - var i = setInterval(function() { - times++ - if (times >= 15) { - that.setData({ - show:false - }) - wx.showTabBar({ - animation: false, - }) - clearInterval(i) - } else { - wx.hideTabBar({ - animation: false, - }) - } - }, 1000) -}, - /** * 生命周期函数--监听页面隐藏 */ @@ -122,16 +86,27 @@ }, jump: function (event) { - var that = this; var latitude = event.target.dataset.pointLat; var longitude = event.target.dataset.pointLon; + let devcode = event.target.dataset.pointCode; that.setData({ latitude: latitude, longitude: longitude, markers: [{ latitude: latitude, - longitude: longitude + longitude: longitude, + callout: { + display:'ALWAYS',// 常显气泡 + content: devcode, //名称文本 + color: '#fff', //文本颜色 + borderRadius: 5, //边框圆角 + borderWidth: 1, //边框宽度 + borderColor: '#0060ff', //边框颜色 + bgColor: '#0060ff', //背景色 + padding: 5, //文本边缘留白 + textAlign: 'center' //文本对齐方式。有效值: left, right, center + } }] }) }, @@ -142,7 +117,7 @@ var devcode = res.result _this.setData({ devcode: devcode, - onshow:false + onshow: false }); _this.searchlogs(devcode) } @@ -151,40 +126,11 @@ onSearch: function (event) { this.setData({ - devcode:event.detail + devcode: event.detail }) this.searchlogs(event.detail) }, - - // bindregionchange: function (e) { - // var that = this - // if (e.causedBy == "drag") { - // var mapCtx = wx.createMapContext("map") - // mapCtx.getCenterLocation({ - // success: function (res) { - // var markersArr = that.data.markers - // for (var i = 0; i < markersArr.length; i++) { - // if (markersArr[i].iconPath == undefined) { - // markersArr.splice(i, 1) - // } - // } - // var latitude = res.latitude - // var longitude = res.longitude - // markersArr = markersArr.concat({ - // latitude: latitude, - // longitude: longitude - // }) - // that.setData({ - // latitude: latitude, - // longitude: longitude, - // markers: markersArr - // }) - // } - // }) - // } - // }, - showLoading: function (message) { if (wx.showLoading) { // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 @@ -211,81 +157,89 @@ } }, + //加载设备运维详细信息 toDetail: function (event) { - this.showLoading("数据加载中...") - wx.cloud.callFunction({ - name: 'deviceDetail', + var that = this + that.showLoading("数据加载中...") + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deviceDetail", data: { devcode: event.target.dataset.devcode, - url: app.globalData.url + "appDeviceLog/deviceDetail", }, - }).then(res => { - this.hideLoading(); - var resultObject = JSON.parse(res.result); - var pageName='../indexapp/indexapp' - if (resultObject.code == 200) { - wx.navigateTo({ - url: '../addDevicelog/addDeviceLog?detail=' + - JSON.stringify(resultObject.data)+'&pageName='+pageName - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + that.hideLoading(); + var resultObject = res.data; + var pageName = '../indexapp/indexapp' + if (resultObject.code == 200) { + wx.setStorageSync('resultObject', resultObject.data) + wx.navigateTo({ + url: '../addDevicelog/addDeviceLog?detail=' +'&pageName=' + pageName + }) + } + }, + fail(err){ + that.hideLoading(); } - }).catch(err => { - this.hideLoading(); }) }, + //加载列表 getlogs: function (devcode) { var that = this - wx.cloud.callFunction({ - name: 'devicelog', + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/listPage", data: { devcode: devcode, - url: app.globalData.url + "appDeviceLog/listPage", limit: 100, offset: that.data.deviceloglist.length % 100 > 0 ? parseInt(that.data.deviceloglist.length / 100) + 2 : parseInt(that.data.deviceloglist.length / 100) + 1 }, - }).then(res => { - if (res.result) { - // var resultJson = JSON.parse(res.result) - var resultJson = res.result - that.setData({ - deviceloglist: that.data.deviceloglist.concat(resultJson.data.rows) - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + // var resultJson = JSON.parse(res.result) + var resultJson = res.data + that.setData({ + deviceloglist: that.data.deviceloglist.concat(resultJson.data.rows) + }) + } } - console.log(res); - }).catch(err => { - console.error(err); }) }, + //查询列表 searchlogs: function (devcode) { var that = this - wx.cloud.callFunction({ - name: 'devicelog', + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/listPage", data: { devcode: devcode, - url: app.globalData.url + "appDeviceLog/listPage", limit: 100, offset: 1 }, - }).then(res => { - if (res.result) { - var resultJson = res.result - that.setData({ - deviceloglist: resultJson.data.rows, - onshow:true - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var resultJson = res.data + that.setData({ + deviceloglist: resultJson.data.rows, + onshow: true + }) + } } - console.log(res); - }).catch(err => { - console.error(err); }) }, initPages: function () { var that = this; - that.setData({ - devcode: "" - }); wx.getLocation({ type: "gcj02", success: function (res) { @@ -302,6 +256,6 @@ }) } }) - this.searchlogs() + this.data.devcode !== '' ? this.searchlogs(this.data.devcode) : this.searchlogs() }, }) \ No newline at end of file diff --git a/miniprogram/pages/indexapp/indexapp.wxml b/miniprogram/pages/indexapp/indexapp.wxml index 69322a0..f65b082 100644 --- a/miniprogram/pages/indexapp/indexapp.wxml +++ b/miniprogram/pages/indexapp/indexapp.wxml @@ -1,8 +1,12 @@ + + + + - @@ -32,9 +36,15 @@ - + + + + + + + @@ -46,14 +56,14 @@ - + - - + diff --git a/miniprogram/pages/indexapp/indexapp.wxss b/miniprogram/pages/indexapp/indexapp.wxss index b18706a..fc27fcb 100644 --- a/miniprogram/pages/indexapp/indexapp.wxss +++ b/miniprogram/pages/indexapp/indexapp.wxss @@ -128,6 +128,7 @@ .noticeClass{ height: 2300rpx; width: 750rpx; + overflow-y:hidden; } @@ -148,14 +149,14 @@ } +/* .vanstyle{ + button: not([size='mini']) { + user agent stylesheetmin-height: 40px; + width: 650rpx; + margin-left: 20rpx; + margin-right: auto; + + } + +} */ -/* .van-enter-active-class, -.van-leave-active-class { - transition-property: background-color, transform; -} - -.van-enter-class, -.van-leave-to-class { - background-color: red; - transform: rotate(-360deg) translate3d(-100%, -100%, 0); -} */ \ No newline at end of file diff --git a/miniprogram/pages/log/log.js b/miniprogram/pages/log/log.js deleted file mode 100644 index 83ba349..0000000 --- a/miniprogram/pages/log/log.js +++ /dev/null @@ -1,66 +0,0 @@ -// pages/log/log.js -Page({ - - /** - * 页面的初始数据 - */ - data: { - - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - - }, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { - - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - - }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { - - }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { - - } -}) \ No newline at end of file diff --git a/miniprogram/pages/log/log.json b/miniprogram/pages/log/log.json deleted file mode 100644 index 8835af0..0000000 --- a/miniprogram/pages/log/log.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "usingComponents": {} -} \ No newline at end of file diff --git a/miniprogram/pages/log/log.wxml b/miniprogram/pages/log/log.wxml deleted file mode 100644 index a510ad6..0000000 --- a/miniprogram/pages/log/log.wxml +++ /dev/null @@ -1,2 +0,0 @@ - -pages/log/log.wxml diff --git a/miniprogram/pages/log/log.wxss b/miniprogram/pages/log/log.wxss deleted file mode 100644 index 23db318..0000000 --- a/miniprogram/pages/log/log.wxss +++ /dev/null @@ -1 +0,0 @@ -/* pages/log/log.wxss */ \ No newline at end of file diff --git a/miniprogram/pages/login/login.js b/miniprogram/pages/login/login.js index a4074e7..cb0542a 100644 --- a/miniprogram/pages/login/login.js +++ b/miniprogram/pages/login/login.js @@ -1,11 +1,14 @@ // miniprogram/pages/login/login.js +var app = getApp() Page({ /** * 页面的初始数据 */ data: { - windowWidth:"" + windowWidth: "", + time: 15 * 1000, + showTime: false }, /** @@ -20,9 +23,9 @@ */ onReady: function () { this.setData({ - windowWidth:wx.getSystemInfoSync().windowWidth + windowWidth: wx.getSystemInfoSync().windowWidth }) - + }, /** @@ -66,14 +69,158 @@ onShareAppMessage: function () { }, + + + showLoading: function (message) { + if (wx.showLoading) { + // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 + wx.showLoading({ + title: message, + mask: true + }); + } else { + // 低版本采用Toast兼容处理并将时间设为20秒以免自动消失 + wx.showToast({ + title: message, + icon: 'loading', + mask: true, + duration: 20000 + }); + } + }, + hideLoading: function () { + if (wx.hideLoading) { + // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 + wx.hideLoading(); + } else { + wx.hideToast(); + } + }, + + //注册 loginClick: function () { + var that = this + that.showLoading("授权中...") + wx.login({ + success: function (res) { + if (res.code) { + wx.request({ + url: app.globalData.httpsUrl + "appUserOpenid/login", + data: { + code: res.code + }, + success: function (res) { + app.globalData.openid = res.data.data + wx.getUserInfo({ + success: (res) => { + var nickname = res.userInfo.nickName; + app.globalData.nickName = nickname; + //openid绑定昵称存入后台 + wx.request({ + url: app.globalData.httpsUrl + "appUserOpenid/add", + data: { + attr: nickname, + openid: app.globalData.openid + }, + success: function (res) { + that.hideLoading(); + wx.showToast({ + title: res.data.data+",\r\n请从正式版入口登录!", + icon: 'none', + duration: 2000 + }) - wx.navigateTo({ - - url: '../farmermain/farmermain', - + // //授权成功后跳转 + // wx.switchTab({ + // url: '../indexapp/indexapp' + // }) + } + }) + }, + fail: function (err) { + that.hideLoading(); + } + }) + }, + fail: function (res) { + that.hideLoading(); + wx.showToast({ + title: '服务器异常', + }) + } + }) + } + }, + fail: function (res) { + that.hideLoading(); + } }) + }, + //登录验证 + loginValidate: function () { + var that = this + that.showLoading("登录中...") + wx.login({ + success: function (res) { + if (res.code) { + console.info(res); + wx.request({ + url: app.globalData.httpsUrl + "appUserOpenid/login", + data: { + code: res.code + }, + success: function (res) { + app.globalData.openid = res.data.data + wx.request({ + url: app.globalData.httpsUrl + "appUserOpenid/validate", + data: { + openid: app.globalData.openid + }, + success: function (res) { + that.hideLoading(); + if (res.data.data) { + app.globalData.userName = res.data.data.attr1 == '' ? res.data.data.attr : res.data.data.attr1 + app.globalData.nickName = res.data.data.attr + app.globalData.role = res.data.data.role + wx.navigateTo({ + url: '../notice/notice' + }) + } else { + wx.showToast({ + icon: 'none', + title: '请联系管理员授权', + duration: 2000 + }) + } + }, + fail: function (err) { + that.hideLoading(); + wx.showToast({ + title: '验证失败', + }) + } + }) + }, + fail: function (res) { + that.hideLoading(); + wx.showToast({ + title: '服务器异常', + }) + } + }) + } + }, + fail: function (res) { + that.hideLoading(); + } + }) + }, + + finished() { + this.setData({ + showTime: true + }) }, onClickSubmit: function () { diff --git a/miniprogram/pages/login/login.json b/miniprogram/pages/login/login.json index 8835af0..f2043a3 100644 --- a/miniprogram/pages/login/login.json +++ b/miniprogram/pages/login/login.json @@ -1,3 +1,8 @@ { - "usingComponents": {} + "usingComponents": { + "van-count-down": "../../miniprogram_npm/@vant/weapp/count-down", + "van-button": "../../miniprogram_npm/@vant/weapp/button" + }, + "navigationBarBackgroundColor": "#E6D480", + "disableScroll":true } \ No newline at end of file diff --git a/miniprogram/pages/login/login.wxml b/miniprogram/pages/login/login.wxml index c69df42..cf2ec72 100644 --- a/miniprogram/pages/login/login.wxml +++ b/miniprogram/pages/login/login.wxml @@ -1,21 +1,46 @@ + - + + + - + + + +    本程序为施工日志管理小程序,为航天二院智慧市 +政技术研究室内部系统,不对外开放。出于对数据信 +息安全的考虑,在您首次使用小程序时,请先对小程 +序进行授权,授权后的用户可以正常对小程序进行编 +辑,谢谢您的配合! + + + + + + + + 授权/登录 + + + - + + + diff --git a/miniprogram/pages/login/login.wxss b/miniprogram/pages/login/login.wxss index ca77568..b9fa569 100644 --- a/miniprogram/pages/login/login.wxss +++ b/miniprogram/pages/login/login.wxss @@ -54,7 +54,8 @@ } .form .submit { - margin-top: 80rpx; + + /* margin-top: 80rpx; */ color: #fff; border: 2rpx solid #FFB90F; background-color: #FFB90F; @@ -63,10 +64,30 @@ } .login_image { - width: 200rpx; - height: 200rpx; - padding-top: 100rpx; - padding-left: 250rpx; + width: 750rpx; + height: 360rpx; + /* height: 2300rpx; */ + /* padding-top: 100rpx + padding-left: 250rpx; */ +} +.bottom_image { + width: 750rpx; + height: 32%; + position: fixed; + bottom: 0px; + /* padding-top: 100rpx + padding-left: 250rpx; */ +} +.cover{ + position: fixed; + top: 0rpx; + margin-left: 290rpx; + text-align:center; + font-size: 50rpx; + color: #FFCF00; + width: 750rpx; + z-index:9999; + } -} \ No newline at end of file + \ No newline at end of file diff --git a/miniprogram/pages/notice/notice.js b/miniprogram/pages/notice/notice.js new file mode 100644 index 0000000..7aeafb9 --- /dev/null +++ b/miniprogram/pages/notice/notice.js @@ -0,0 +1,80 @@ +// miniprogram/pages/notice.js +Page({ + + /** + * 页面的初始数据 + */ + data: { + time: 15 * 1000, + showTime: false + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { + this.setData({ + showTime: true + }) + wx.switchTab({ + url: '../indexapp/indexapp' + }) + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + }, + finished() { + this.setData({ + showTime: true + }) + wx.switchTab({ + url: '../indexapp/indexapp' + }) + } +}) \ No newline at end of file diff --git a/miniprogram/pages/notice/notice.json b/miniprogram/pages/notice/notice.json new file mode 100644 index 0000000..4c73264 --- /dev/null +++ b/miniprogram/pages/notice/notice.json @@ -0,0 +1,5 @@ +{ + "usingComponents": { + "van-count-down": "../../miniprogram_npm/@vant/weapp/count-down" + } +} \ No newline at end of file diff --git a/miniprogram/pages/notice/notice.wxml b/miniprogram/pages/notice/notice.wxml new file mode 100644 index 0000000..975304a --- /dev/null +++ b/miniprogram/pages/notice/notice.wxml @@ -0,0 +1,10 @@ + + + + + + + + diff --git a/miniprogram/pages/notice/notice.wxss b/miniprogram/pages/notice/notice.wxss new file mode 100644 index 0000000..36d7542 --- /dev/null +++ b/miniprogram/pages/notice/notice.wxss @@ -0,0 +1,18 @@ +/* miniprogram/pages/notice.wxss */ + +.login_image { + width: 750rpx; + height: 2300rpx; + /* padding-top: 100rpx + padding-left: 250rpx; */ +} +.cover{ + position: fixed; + top: 0rpx; + margin-left: 290rpx; + text-align:center; + font-size: 50rpx; + color: #FFCF00; + width: 750rpx; + z-index:9999; + } \ No newline at end of file diff --git a/miniprogram/pages/searchLog/searchLog.js b/miniprogram/pages/searchLog/searchLog.js index a4f8c33..1f7069b 100644 --- a/miniprogram/pages/searchLog/searchLog.js +++ b/miniprogram/pages/searchLog/searchLog.js @@ -6,29 +6,35 @@ * 页面的初始数据 */ data: { - defaultDay:[ + defaultDay: [ new Date().getTime(), - new Date().getTime()+24*60*60*1000, + new Date().getTime() + 24 * 60 * 60 * 1000, ], projectoption: [], - devtypeList:[], + devtypeList: [], personoption: [], installtimeFmt: '', show: false, - minDate: new Date(2010, 0, 1).getTime(), devcode: '', + timeShow:false, project: '', devtype: '', - installPerson:'', + installPerson: '', + projectvalue:'', minDate: new Date(2018, 0, 1).getTime(), // maxDate: new Date(2018, 0, 31).getTime(), }, onDisplay() { - this.setData({ show: true }); + this.setData({ + show: true + }); }, onClose() { - this.setData({ show: false }); + this.setData({ + show: false + }); }, + //格式化时间 formatDate(date) { date = new Date(date); // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; @@ -50,6 +56,7 @@ return currentdate; }, + //查询时间区域设置 onConfirm(event) { // this.setData({ @@ -67,87 +74,102 @@ /** * 生命周期函数--监听页面加载 */ - onLoad: function (options) { - var _this=this + onLoad: async function (options) { + await this.setData({ + timeShow:true, + }) + const {devcode,devtype,installPerson,installtimeFmt,project} = JSON.parse(options.params) + this.setData({ + devcode:devcode || '', + devtype:devtype || '', + installPerson:installPerson || '', + installtimeFmt:installtimeFmt || '', + project:project || '', + projectvalue:project || '', + + }) + + var _this = this /** * 获取所属项目下拉列表 */ - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); + success(res) { + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); + } + _this.setData({ + projectoption: projectArr + }) } - _this.setData({ - projectoption: projectArr - }) } - }).catch(err => { - console.error(err); }) - - - /** + /** * 获取设备类型下拉列表 */ - wx.cloud.callFunction({ - name: 'getTypeList', - data: { - url: app.globalData.url + "deviceType/deviceType" + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/deviceType", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - }).then(res => { - if (res.result.code == 200) { - var TypeList = res.result.data - var typeArr = []; - for (var i = 0; i < TypeList.length; i++) { - var type = { - text: TypeList[i].productName, - value: TypeList[i].productName - }; - typeArr.push(type); + success(res) { + if (res.data.code == 200) { + var TypeList = res.data.data + var typeArr = []; + for (var i = 0; i < TypeList.length; i++) { + var type = { + text: TypeList[i].productName, + value: TypeList[i].productName + }; + typeArr.push(type); + } + _this.setData({ + devtypeList: typeArr + }) } - _this.setData({ - devtypeList: typeArr - }) } - }).catch(err => { - console.error(err); }) - //获取人员下拉列表 - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" + //获取人员下拉列表 + wx.request({ + method: "POST", + data:{ + tips:'repair' }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); + url: app.globalData.httpsUrl + "deviceType/getUser", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var users = res.data.data + var personArr = []; + for (var i = 0; i < users.length; i++) { + var person = { + text: users[i].name, + value: users[i].name + }; + personArr.push(person); + } + _this.setData({ + personoption: personArr + }) } - _this.setData({ - personoption: personArr - }) } - }).catch(err => { - console.error(err); }) }, @@ -202,13 +224,13 @@ }, scan() { - var _this=this; + var _this = this; wx.scanCode({ success(res) { - var devcode=res.result + var devcode = res.result _this.setData({ - devcode: devcode, - }); + devcode: devcode, + }); } }) }, @@ -221,6 +243,7 @@ [formName]: formValue }) }, + //设置项目 selectprojectValue(event) { var that = this; that.setData({ @@ -228,7 +251,7 @@ }) }, - + //设置设备类型 selectDevType(event) { var that = this; that.setData({ @@ -236,46 +259,24 @@ }) }, + //设置人员 selectpersonValue(event) { var that = this; that.setData({ installPerson: event.detail }) }, - + //查询 query: function (event) { - var data={ + var data = { devcode: this.data.devcode, installtimeFmt: this.data.installtimeFmt, project: this.data.project, devtype: this.data.devtype, - installPerson:this.data.installPerson + installPerson: this.data.installPerson } wx.reLaunch({ url: '../applog/applog?params=' + JSON.stringify(data) }) - // var that = this; - // wx.cloud.callFunction({ - // name: 'devicelog', - // data: { - // devcode: that.data.devcode, - // installtimeFmt: that.data.installtimeFmt, - // project: that.data.project, - // devtype: that.data.devtype, - // }, - // }).then(res => { - // // var resultObj=JSON.parse(res.result); - // var resultObj=res.result; - // if (resultObj.code == 200) { - // wx.reLaunch({ - // url: '../applog/applog?applogList=' + JSON.stringify(resultObj.data.rows) - // }) - // } - // }).catch(err => { - // console.error(err); - // wx.showToast({ - // title: "查询失败", - // }) - // }) }, }) \ No newline at end of file diff --git a/miniprogram/pages/searchLog/searchLog.wxml b/miniprogram/pages/searchLog/searchLog.wxml index dfbc788..daf06bc 100644 --- a/miniprogram/pages/searchLog/searchLog.wxml +++ b/miniprogram/pages/searchLog/searchLog.wxml @@ -21,14 +21,10 @@ - + - - @@ -39,7 +35,12 @@ - - 查询 + + + + + 查询 \ No newline at end of file diff --git a/miniprogram/project.config.json b/miniprogram/project.config.json new file mode 100644 index 0000000..4a797a9 --- /dev/null +++ b/miniprogram/project.config.json @@ -0,0 +1,43 @@ +{ + "appid": "wx79419f886f8c77ef", + "compileType": "miniprogram", + "libVersion": "2.27.3", + "packOptions": { + "ignore": [], + "include": [] + }, + "setting": { + "urlCheck": true, + "coverView": true, + "es6": true, + "postcss": true, + "lazyloadPlaceholderEnable": false, + "preloadBackgroundData": false, + "minified": true, + "autoAudits": false, + "uglifyFileName": false, + "uploadWithSourceMap": true, + "enhance": true, + "showShadowRootInWxmlPanel": true, + "packNpmManually": false, + "packNpmRelationList": [], + "minifyWXSS": true, + "useStaticServer": true, + "showES6CompileOption": false, + "checkInvalidKey": true, + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + }, + "disableUseStrict": false, + "useCompilerPlugins": false, + "minifyWXML": true + }, + "condition": {}, + "editorSetting": { + "tabIndent": "insertSpaces", + "tabSize": 4 + }, + "description": "项目配置文件,详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html" +} \ No newline at end of file diff --git a/cloudfunctions/project.config.json b/cloudfunctions/project.config.json new file mode 100644 index 0000000..2b3119a --- /dev/null +++ b/cloudfunctions/project.config.json @@ -0,0 +1,28 @@ +{ + "appid": "wx2cef527a000f87c9", + "compileType": "miniprogram", + "libVersion": "2.27.3", + "packOptions": { + "ignore": [], + "include": [] + }, + "setting": { + "coverView": true, + "es6": true, + "postcss": true, + "minified": true, + "enhance": true, + "showShadowRootInWxmlPanel": true, + "packNpmRelationList": [], + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + } + }, + "condition": {}, + "editorSetting": { + "tabIndent": "insertSpaces", + "tabSize": 4 + } +} \ No newline at end of file diff --git a/cloudfunctions/project.private.config.json b/cloudfunctions/project.private.config.json new file mode 100644 index 0000000..42ff49d --- /dev/null +++ b/cloudfunctions/project.private.config.json @@ -0,0 +1,7 @@ +{ + "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", + "projectname": "cloudfunctions", + "setting": { + "compileHotReLoad": true + } +} \ No newline at end of file diff --git a/miniprogram/app.js b/miniprogram/app.js index 51d56f3..50a8a54 100644 --- a/miniprogram/app.js +++ b/miniprogram/app.js @@ -18,13 +18,15 @@ // this.globalData = {} }, globalData: { - // url: "http://111.198.10.15:11604/", - httpsUrl: "https://logapi.smartlog.work/", - httpsTestUrl: "https://smartlog.work/prodapi4test/", - url: "http://139.198.18.188:8083/", + httpsUrl: "https://logapi.smartlog.work/", + // httpsUrl: "http://139.198.18.188:8083/", // url: "http://127.0.0.1:8083/", - // httpsUrl: "http://127.0.0.1:8083/", + //httpsUrl: "http://127.0.0.1:8083/", openid: null, - indexCount:1 - }, + indexCount:1, + nickName:"", + userName:"", + role:"", + devcode:"" + } }) diff --git a/miniprogram/app.json b/miniprogram/app.json index d23f798..2b6db76 100644 --- a/miniprogram/app.json +++ b/miniprogram/app.json @@ -1,15 +1,17 @@ { "cloud": true, "pages": [ + "pages/login/login", "pages/indexapp/indexapp", "pages/earth/earth", "pages/applog/applog", "pages/addDevice/addDevice", "pages/addDevicelog/addDeviceLog", - "pages/searchLog/searchLog" + "pages/searchLog/searchLog", + "pages/notice/notice" ], "window": { - "backgroundColor": "#F6F6F6", + "backgroundColor": "#E6D480", "backgroundTextStyle": "light", "navigationBarBackgroundColor": "#FFCF00", "navigationBarTitleText": "智慧施工", @@ -46,11 +48,11 @@ "desc": "你的位置信息将用于小程序位置接口的效果展示" } }, + "requiredPrivateInfos": ["getLocation", "chooseLocation"], "networkTimeout": { "request": 30000, "connectSocket": 30000, "uploadFile": 30000, "downloadFile": 30000 - }, - "style": "v2" + } } \ No newline at end of file diff --git a/miniprogram/images/applocat.png b/miniprogram/images/applocat.png new file mode 100644 index 0000000..fe49f54 --- /dev/null +++ b/miniprogram/images/applocat.png Binary files differ diff --git a/miniprogram/images/back.png b/miniprogram/images/back.png new file mode 100644 index 0000000..32ac82d --- /dev/null +++ b/miniprogram/images/back.png Binary files differ diff --git a/miniprogram/images/bottom.png b/miniprogram/images/bottom.png new file mode 100644 index 0000000..d910e98 --- /dev/null +++ b/miniprogram/images/bottom.png Binary files differ diff --git a/miniprogram/images/header.png b/miniprogram/images/header.png new file mode 100644 index 0000000..6ea222e --- /dev/null +++ b/miniprogram/images/header.png Binary files differ diff --git a/miniprogram/images/login.png b/miniprogram/images/login.png index 8b73cc0..6471c46 100644 --- a/miniprogram/images/login.png +++ b/miniprogram/images/login.png Binary files differ diff --git a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss index 5a591fb..c9c35b5 100644 --- a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss +++ b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:100%;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:100%}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file +@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:650rpx;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:600rpx}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file diff --git a/miniprogram/pages/addDevice/addDevice.js b/miniprogram/pages/addDevice/addDevice.js index 2783674..78f00b7 100644 --- a/miniprogram/pages/addDevice/addDevice.js +++ b/miniprogram/pages/addDevice/addDevice.js @@ -1,5 +1,7 @@ // miniprogram/pages/addDevice/addDevice.js // import WxValidate from '../../utils/WxValidate.js' +var QQMapWX = require('../../libs/qqmap-wx-jssdk.js'); +var qqmapsdk; var app = getApp() Page({ @@ -11,32 +13,10 @@ canvasWidth: '', longitude: '', latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], + option1: [], personoption1: [], projectoption: [], + devtypeList:[], show: false, form: { devcode: "", @@ -59,7 +39,10 @@ project: "", area: "", street: "", - wellname: "" + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '', }, fileList: [] }, @@ -117,12 +100,14 @@ var that = this; //初始化表单内容为上次填写值 var cacheForms = wx.getStorageSync('cacheList') - if (cacheForms) { + cacheForms.photopath1='' + cacheForms.photopath2='' + cacheForms.photopath3='' + that.data.fileList=[] that.setData({ form: cacheForms, devcode: cacheForms.devcode, - }) } var form = that.data.form @@ -155,55 +140,89 @@ } }) + +//获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + that.setData({ + option1: welltypeArr + }) + } + } +}) + + //获取人员下拉列表 - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/getUser", + data:{ + tips:'repair' }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data.code == 200) { + var users = res.data.data + var personArr = []; + for (var i = 0; i < users.length; i++) { + var person = { + text: users[i].name, + value: users[i].name + }; + personArr.push(person); + } + that.setData({ + personoption1: personArr + }) } - that.setData({ - personoption1: personArr - }) } - }).catch(err => { - console.error(err); - }) + }) + - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - that.setData({ - projectoption: projectArr - }) + success(res){ + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); + } + that.setData({ + projectoption: projectArr + }) + } } - }).catch(err => { - console.error(err); - }) + }) + var installtime = 'form.installtimeFmt'; var dateNow = this.formatDate(); this.setData({ @@ -211,8 +230,40 @@ installtimeFmt: dateNow, [installtime]: dateNow, }); + + + + /** + * 获取设备类型下拉列表 + */ + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/deviceType", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var TypeList = res.data.data + var typeArr = []; + for (var i = 0; i < TypeList.length; i++) { + var type = { + text: TypeList[i].productName, + value: TypeList[i].productName + }; + typeArr.push(type); + } + that.setData({ + devtypeList: typeArr + }) + } + } + }) }, + + + /** * 生命周期函数--监听页面初次渲染完成 */ @@ -280,29 +331,7 @@ }, - - //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 - drawText: function (ctx, str, leftWidth, initHeight, titleHeight, canvasWidth) { - var lineWidth = 0; - var lastSubStrIndex = 0; //每次开始截取的字符串的索引 - for (let i = 0; i < str.length; i++) { - lineWidth += ctx.measureText(str[i]).width; - if (lineWidth > canvasWidth) { - ctx.fillText(str.substring(lastSubStrIndex, i), leftWidth, initHeight); //绘制截取部分 - initHeight = initHeight + leftWidth * 2; //22为字体的高度 - lineWidth = 0; - lastSubStrIndex = i; - // titleHeight += 40; - } - if (i == str.length - 1) { //绘制剩余部分 - ctx.fillText(str.substring(lastSubStrIndex, i + 1), leftWidth, initHeight); - } - } - // // 标题border-bottom 线距顶部距离 - // titleHeight = titleHeight + 10; - // return titleHeight - }, - + //验证表单 formValidate() { if (this.data.form.devcode == "") { @@ -312,27 +341,20 @@ }) return false } - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } if (this.data.form.wellcode == "") { wx.showToast({ icon: 'none', @@ -348,22 +370,10 @@ }) return false } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null) { + + if (this.data.form.installperson == "") { wx.showToast({ icon: 'none', title: '安装人员不能为空!', @@ -408,56 +418,90 @@ } return true; }, + //提交表单 formSubmit: function (event) { + console.log(this.data.form) + //表单参数验证 if (!this.formValidate()) { return false; } var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDevice', + //验证设备编号长度 + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/getDevTypeLength", data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceAdd/add" + code: encodeURI(this.data.form.devicetype) }, - }).then(res => { - if (res.result.code == 500) { - wx.showToast({ - title: '设备编号已安装!', - }) - } else if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - //用于回显 - wx.setStorageSync('cacheList', that.data.form) - //提交成功后提示用户操作 - if (res.confirm) { - wx.switchTab({ - url: '../earth/earth' - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (""==res.data.data ||res.data.data == that.data.form.devcode.length) { + that.saveDevice() + } else { //编号位数不对提示 + wx.showToast({ + icon: 'none', + title: '设备编号位数不对!', + duration: 1000 + }) + return false + } } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "提交失败", - }) }) }, + + //保存设备基本信息 + saveDevice() { + var that = this; + //设置照片路径 + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopathForm = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopathForm]: fileList[i].url.split("static/")[1] + }) + } + //表单提交 + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 500) { + wx.showToast({ + title: '设备编号已安装!', + }) + } else if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + //用于回显 + wx.setStorageSync('cacheList', that.data.form) + //提交成功后提示用户操作 + if (res.confirm) { + wx.switchTab({ + url: '../earth/earth' + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } + }, + fail(err) { + wx.showToast({ + title: '提交失败!', + }) + } + }) + }, + + //input 输入框设置值 confirm(event) { var that = this; var formValue = event.detail.value; @@ -466,8 +510,30 @@ that.setData({ [fromN]: formValue }) + //若输入是设备编号,自动获取设备类型 + if('devcode'==formName){ + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", + data: { + devcode: formValue, + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + that.setData({ + [formDevicetype]: res.data + }); + } + } + }) + } }, + //扫描设备获取编号和设备类型 scan() { var _this = this; wx.scanCode({ @@ -477,23 +543,28 @@ _this.setData({ [formdevcode]: devcode }); - wx.cloud.callFunction({ - name: 'findModeCode', + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", data: { devcode: devcode, - url: app.globalData.url + "appDeviceAdd/findModeCodeByCode" }, - }).then(res => { - if (res.result) { - var formDevicetype = 'form.devicetype' - _this.setData({ - [formDevicetype]: res.result - }); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + _this.setData({ + [formDevicetype]: res.data + }); + } } }) } }) }, + //粘贴经纬度 paste() { var _this = this; wx.getClipboardData({ @@ -510,9 +581,11 @@ longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), }); + _this.showAddress(_this.data.form.longitude,_this.data.form.latitude,_this) } }) }, + //设置经类型 selectValue(value) { var that = this; @@ -521,6 +594,16 @@ [wellType]: value.detail }) }, + + //设置设备类型 + selectDevType(event) { + var that = this; + var devtype = 'form.devicetype'; + that.setData({ + [devtype]: event.detail + }) + }, + //设置运维人员 selectpersonValue(event) { var that = this; var installPerson = 'form.installperson'; @@ -528,6 +611,7 @@ [installPerson]: event.detail }) }, + //设置项目 selectprojectValue(event) { var that = this; var project = 'form.project'; @@ -535,8 +619,41 @@ [project]: event.detail }) }, + showAddress :function(longitude, latitude, self) { + // 实例化腾讯地图API核心类 + qqmapsdk = new QQMapWX({ + key: 'BGPBZ-C5O3P-ROUDR-LWC4J-63EKH-V5FRX'//此处使用你自己申请的key + }) + // 腾讯地图调用接口 + qqmapsdk.reverseGeocoder({ + location: { + latitude: latitude, + longitude: longitude + }, + success: function (res) { + self.setData({ + 'form.area':res.result.address.slice(0,res.result.address.indexOf('区')+1), + 'form.street':res.result.address.slice(res.result.address.indexOf('区')+1) + }) + }, + fail: function (res) { + console.log(res); + }, + complete: function (res) { + } + }); + }, + //上传照片 afterRead(event) { var _this = this; + if (_this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '请先填写设备编号!\r\n否则水印中无编号', + duration: 2000 + }) + return false + } const { file } = event.detail; @@ -576,78 +693,8 @@ }) } }) - // 压缩图片 - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // //获取图片尺寸 - // wx.getImageInfo({ - // src: convertpath, - // success(res) { - // _this.setData({ - // canvasHeight: res.height, - // canvasWidth: res.width - // }) - // var ctx = wx.createCanvasContext('firstCanvas') - - // //将图片src放到cancas内,宽高为图片大小 - // ctx.drawImage(convertpath, 0, 0, res.width, res.height) - // //将声明的时间放入canvas - // ctx.setFontSize(30 * (res.width / 750)) //注意:设置文字大小必须放在填充文字之前,否则不生效 - // ctx.setFillStyle('blue') - // var text = "编号:" + _this.data.form.devcode + "\n经度:" + _this.data.form.longitude + "\n纬度:" + _this.data.form.latitude - // // _this.drawText(ctx,text,20, 70, 5, res.width) - // _this.drawText(ctx, text, 15 * (res.width / 750), 70 * (res.width / 750), 5, res.width) - - // // ctx.fillText(text, 0, 40) - // // ctx.strokeText(_this.data.form.devcode, 0, 30) - // //生成水印图 - // ctx.draw(false, function () { - // wx.canvasToTempFilePath({ - // canvasId: 'firstCanvas', - // success: (res) => { - // wx.compressImage({ - // src: res.tempFilePath, - // quality: 25, - // success: function (res) { - // //上传照片至服务器 - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: res.tempFilePath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // } - // }) - // //// - // } - // }) - // }) - // } - // }) - // } - // }); }, + //删除照片 deletePhoto(event) { var image_index = event.detail.index var fileList_new = this.data.fileList; diff --git a/miniprogram/pages/addDevice/addDevice.wxml b/miniprogram/pages/addDevice/addDevice.wxml index b0977e2..f12c254 100644 --- a/miniprogram/pages/addDevice/addDevice.wxml +++ b/miniprogram/pages/addDevice/addDevice.wxml @@ -5,18 +5,30 @@ - + + + + + + + + + + + + + - - + + - - - + + + @@ -29,13 +41,13 @@ - + - + - + - + @@ -54,8 +66,7 @@ - - + @@ -68,8 +79,8 @@ - - + + - 保存 + 保存 \ No newline at end of file diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.js b/miniprogram/pages/addDevicelog/addDeviceLog.js index cdec71b..a0dc6da 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.js +++ b/miniprogram/pages/addDevicelog/addDeviceLog.js @@ -3,681 +3,665 @@ var app = getApp(); Page({ - /** - * 页面的初始数据 - */ - data: { - pageName: '', - showMask: false, - today: new Date().getTime(), - longitude: '', - latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], - personoption1: [], - projectoption: [], - devcode: "", - deviceMode: "", - installtimeFmt: '', - show: false, - form: { - devcode: "", - wellcode: "", - welltype: "", - welldepth: "", - installheigt: "", - installperson: "", - installtimeFmt: "", - photopath: "", - factory: "", - workmsg: "", - position: "", - description: "", - longitude: "", - latitude: "", - longitude84: "", - latitude84: "", - devicetype: "", - project: "", - area: "", - street: "", - wellname: "" - }, - fileList: [], - detail: "" - }, + /** + * 页面的初始数据 + */ + data: { + pageName: '', + showMask: false, + today: new Date().getTime(), + longitude: '', + latitude: '', + option1: [], + personoption1: [], + projectoption: [], + devcode: "", + deviceMode: "", + installtimeFmt: '', + show: false, + form: { + devcode: "", + wellcode: "", + welltype: "", + welldepth: "", + installheigt: "", + installperson: "", + installtimeFmt: "", + photopath: "", + factory: "", + workmsg: "", + position: "", + description: "", + longitude: "", + latitude: "", + longitude84: "", + latitude84: "", + devicetype: "", + project: "", + area: "", + street: "", + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '' + }, + fileList: [], + detail: "", + markers: [{ + id: 100, + // iconPath: "../../images/point.png", + latitude: '', + longitude: '', + // label:'1', + width: 25, + height: 35 + }], + }, - onDisplay() { - this.setData({ - show: true - }); - }, - onClose() { - this.setData({ - show: false - }); - }, - formatDate() { - var date = new Date(); - // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; - var seperator1 = "-"; - var month = date.getMonth() + 1; - var strDate = date.getDate(); - var hour = date.getHours() - var minute = date.getMinutes() - var second = date.getSeconds() - month = month > 9 ? month : "0" + month; - strDate = strDate > 9 ? strDate : "0" + strDate; - hour = hour > 9 ? hour : "0" + hour; - minute = minute > 9 ? minute : "0" + minute; - second = second > 9 ? second : "0" + second; - var currentdate = - date.getFullYear() + - seperator1 + - month + - seperator1 + - strDate + - " " + - hour + ":" + - minute + ":" + - second; - return currentdate; + onDisplay() { + this.setData({ + show: true + }); + }, + onClose() { + this.setData({ + show: false + }); + }, + formatDate() { + var date = new Date(); + // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; + var seperator1 = "-"; + var month = date.getMonth() + 1; + var strDate = date.getDate(); + var hour = date.getHours() + var minute = date.getMinutes() + var second = date.getSeconds() + month = month > 9 ? month : "0" + month; + strDate = strDate > 9 ? strDate : "0" + strDate; + hour = hour > 9 ? hour : "0" + hour; + minute = minute > 9 ? minute : "0" + minute; + second = second > 9 ? second : "0" + second; + var currentdate = + date.getFullYear() + + seperator1 + + month + + seperator1 + + strDate + + " " + + hour + ":" + + minute + ":" + + second; + return currentdate; - }, - onConfirm(event) { - var installtime = 'form.installtimeFmt'; - this.setData({ - show: false, - installtimeFmt: this.formatDate(event.detail), - [installtime]: this.formatDate(event.detail), - }); - }, + }, + onConfirm(event) { + var installtime = 'form.installtimeFmt'; + this.setData({ + show: false, + installtimeFmt: this.formatDate(event.detail), + [installtime]: this.formatDate(event.detail), + }); + }, - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - var _this = this; - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" - }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); - } - _this.setData({ - personoption1: personArr - }) + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + var _this = this; + _this.setData({ + 'markers[0].latitude': Number(wx.getStorageSync('resultObject').latitude) , + 'markers[0].longitude': Number(wx.getStorageSync('resultObject').longitude), + // 'markers[0].label':'10', + 'markers[0].width': 18, + 'markers[0].id':1, + 'markers[0].height': 30, + latitude:Number(wx.getStorageSync('resultObject').latitude), + longitude:Number(wx.getStorageSync('resultObject').longitude) + }) + //获取人员下拉列表 + // wx.request({ + // method: "POST", + // url: app.globalData.httpsUrl + "deviceType/getUser", + // data:{ + // tips:'repair' + // }, + // header: { + // 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + // }, + // success(res) { + // if (res.data.code == 200) { + // var users = res.data.data + // var personArr = []; + // for (var i = 0; i < users.length; i++) { + // var person = { + // text: users[i].name, + // value: users[i].name + // }; + // personArr.push(person); + // } + // _this.setData({ + // personoption1: personArr + // }) + // } + // } + // }) + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); } - }).catch(err => { - console.error(err); - }) - - - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" - }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - _this.setData({ - projectoption: projectArr - }) - } - }).catch(err => { - console.error(err); - }) - - if (options.pageName) { - this.setData({ - pageName: options.pageName - }) - } - - if (options.detail) { - - var formObject = JSON.parse(options.detail); _this.setData({ - form: formObject, - detail: options.detail + projectoption: projectArr }) - - _this.setData({ - ['form.installperson']: "", - ['form.installtimeFmt']: "", - ['form.workmsg']: "", - ['form.description']: "" - }) - - const { - fileList = [] - } = _this.data; - if (formObject.photopath1 != "") { - var file1 = { - url: app.globalData.url + "static/" + formObject.photopath1 - } - fileList.push(file1) - } - if (formObject.photopath2 != "") { - var file2 = { - url: app.globalData.url + "static/" + formObject.photopath2 - } - fileList.push(file2) - } - if (formObject.photopath3 != "") { - var file3 = { - url: app.globalData.url + "static/" + formObject.photopath3 - } - fileList.push(file3) - } - - _this.setData({ - fileList - }); } - var installtime = 'form.installtimeFmt'; - var dateNow = this.formatDate(); - this.setData({ - installtimeFmt: dateNow, - [installtime]: dateNow, - }); - }, + } + }) - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { + //获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + _this.setData({ + option1: welltypeArr + }) + } + } +}) - }, + //跳转时带入参数返回哪页 + if (options.pageName) { + this.setData({ + pageName: options.pageName + }) + } + //跳转时带入参数设备的安装信息 + if (wx.getStorageSync('resultObject')) { + var formObject = wx.getStorageSync('resultObject') + _this.setData({ + form: formObject, + detail: formObject + }) - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { + _this.setData({ + ['form.installperson']: app.globalData.userName, + ['form.installtimeFmt']: "", + ['form.workmsg']: "", + ['form.description']: "" + }) - }, + const { + fileList = [] + } = _this.data; + if (formObject.photopath1 != "") { + var file1 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath1 + } + fileList.push(file1) + } + if (formObject.photopath2 != "") { + var file2 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath2 + } + fileList.push(file2) + } + if (formObject.photopath3 != "") { + var file3 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath3 + } + fileList.push(file3) + } + _this.setData({ + fileList + }); + } + var installtime = 'form.installtimeFmt'; + var dateNow = this.formatDate(); + this.setData({ + installtimeFmt: dateNow, + [installtime]: dateNow, + }); + }, - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, - }, + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + wx.removeStorageSync('resultObject') + }, - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, - }, + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { + }, - }, + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { + }, - }, + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { + }, - }, + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + }, - /** - * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true - **/ + /** + * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true + **/ - isNumber: function (val) { + isNumber: function (val) { - var regPos = /^[0-9]*$/; //非负浮点数 - var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数 - if (regPos.test(val) || regNeg.test(val)) { - return false; - } else { - return true; - } + var regPos = /^[0-9]*$/; //非负浮点数 + var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数 + if (regPos.test(val) || regNeg.test(val)) { + return false; + } else { + return true; + } - }, + }, - formValidate() { + formValidate() { - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } - if (this.data.form.wellcode == "") { - wx.showToast({ - icon: 'none', - title: '井编号不能为空!', - }) - return false - } - if (this.data.form.devicetype == "") { - wx.showToast({ - icon: 'none', - title: '设备类型不能为空!', - }) - return false - } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + if (this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '设备编号不能为空!', + }) + return false + } + if (this.data.form.wellcode == "") { + wx.showToast({ + icon: 'none', + title: '井编号不能为空!', + }) + return false + } + if (this.data.form.devicetype == "") { + wx.showToast({ + icon: 'none', + title: '设备类型不能为空!', + }) + return false + } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null || - this.data.form.installperson == '') { - wx.showToast({ - icon: 'none', - title: '运维人员不能为空!', - }) - return false - } - if (this.data.form.project == "") { - wx.showToast({ - icon: 'none', - title: '所属项目不能为空!', - }) - return false - } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } + if (this.data.form.installperson == null || + this.data.form.installperson == '') { + wx.showToast({ + icon: 'none', + title: '运维人员不能为空!', + }) + return false + } + if (this.data.form.project == "") { + wx.showToast({ + icon: 'none', + title: '所属项目不能为空!', + }) + return false + } - if (this.data.form.welldepth != null) { - if (this.isNumber(this.data.form.welldepth)) { - wx.showToast({ - icon: 'none', - title: '井深必须为数值!', - }) - return false - } - } - if (this.data.form.installheigt != null) { - if (this.isNumber(this.data.form.installheigt)) { - wx.showToast({ - icon: 'none', - title: '到井口距离必须为数值!', - }) - return false - } - } - - return true; - }, - - changeMsg: function () { - var formNew = this.data.form; - var formOld = JSON.parse(this.data.detail); - var descpNew = ""; - if (formNew.devcode != formOld.devcode) { - descpNew += "修改设备编号,原编号:" + formOld.devcode + ",新编号:" + formNew.devcode + ";" - } - if (formNew.devicetype != formOld.devicetype) { - descpNew += "修改设备类型,原设备类型:" + formOld.devicetype + ",新设备类型:" + formNew.devicetype + ";" - } - if (formNew.area != formOld.area) { - descpNew += "修改区,原区:" + formOld.area + ",新区:" + formNew.area + ";" - } - if (formNew.street != formOld.street) { - descpNew += "修改街道,原街道:" + formOld.street + ",新街道:" + formNew.street + ";" - } - if (formNew.wellname != formOld.wellname) { - descpNew += "修改井名称,原井名称:" + formOld.wellname + ",新井名称:" + formNew.wellname + ";" - } - if (formNew.factory != formOld.factory) { - descpNew += "修改权属单位,原权属单位:" + formOld.factory + ",新权属单位:" + formNew.factory + ";" - } - if (formNew.installheigt != formOld.installheigt) { - descpNew += "修改井口距离,原井口距离:" + formOld.installheigt + ",新井口距离:" + formNew.installheigt + ";" - } - if (formNew.installperson != formOld.installperson) { - descpNew += "修改运维人员,原运维人员:" + formOld.installperson + ",新运维人员:" + formNew.installperson + ";" - } - if (formNew.latitude != formOld.latitude) { - descpNew += "修改纬度,原纬度:" + formOld.latitude + ",新纬度:" + formNew.latitude + ";" - } - if (formNew.longitude != formOld.longitude) { - descpNew += "修改经度,原经度:" + formOld.longitude + ",新经度:" + formNew.longitude + ";" - } - if (formNew.position != formOld.position) { - descpNew += "修改位置描述,原位置:" + formOld.position + ",新位置:" + formNew.position + ";" - } - if (formNew.wellcode != formOld.wellcode) { - descpNew += "修改井编号,原编号:" + formOld.wellcode + ",新编号:" + formNew.wellcode + ";" - } - if (formNew.welldepth != formOld.welldepth) { - descpNew += "修改井深,原井深:" + formOld.welldepth + ",新井深:" + formNew.welldepth + ";" - } - if (formNew.welltype != formOld.welltype) { - descpNew += "修改井类型,原井类型:" + formOld.welltype + ",新井类型:" + formNew.welltype + ";" - } - if (formNew.project != formOld.project) { - descpNew += "修改所属项目,原项目:" + formOld.project + ",新项目:" + formNew.project + ";" - } - if (this.data.photopath1 != formOld.photopath1 || - this.data.photopath2 != formOld.photopath2 || - this.data.photopath3 != formOld.photopath3) { - descpNew += "修改照片;" - } - if ("" != formNew.description) { - descpNew += formNew.description; - } - this.setData({ - ['form.description']: descpNew + if (this.data.form.welldepth != null) { + if (this.isNumber(this.data.form.welldepth)) { + wx.showToast({ + icon: 'none', + title: '井深必须为数值!', }) - }, + return false + } + } + if (this.data.form.installheigt != null) { + if (this.isNumber(this.data.form.installheigt)) { + wx.showToast({ + icon: 'none', + title: '到井口距离必须为数值!', + }) + return false + } + } - formSubmit: function (event) { + return true; + }, - if (!this.formValidate()) { - return false; - } - this.changeMsg(); - var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDeviceLog', - data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceLog/add" - }, - }).then(res => { - // var resultObj=JSON.parse(res.result); - if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - if (res.confirm) { - wx.switchTab({ - url: that.data.pageName - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) - } - }).catch(err => { - console.error(err) - wx.showToast({ - title: "提交失败", - }) - }) - }, - confirm(event) { - var that = this; - var formValue = event.detail.value; - var formName = event.target.dataset.id; - var fromN = 'form.' + [formName]; - that.setData({ - [fromN]: formValue - }) - }, + //获取与上次修改的信息 + changeMsg: function () { + var formNew = this.data.form; + console.log(this.data.detail) + var formOld = JSON.parse(this.data.detail); + var descpNew = ""; + if (formNew.devcode != formOld.devcode) { + descpNew += "修改设备编号,原值:" + formOld.devcode + ",新值:" + formNew.devcode + ";" + } + if (formNew.devicetype != formOld.devicetype) { + descpNew += "修改设备类型,原值:" + formOld.devicetype + ",新值:" + formNew.devicetype + ";" + } + if (formNew.area != formOld.area) { + descpNew += "修改区,原值:" + formOld.area + ",新值:" + formNew.area + ";" + } + if (formNew.street != formOld.street) { + descpNew += "修改街道,原值:" + formOld.street + ",新值:" + formNew.street + ";" + } + if (formNew.wellname != formOld.wellname) { + descpNew += "修改井名称,原值:" + formOld.wellname + ",新值:" + formNew.wellname + ";" + } + if (formNew.factory != formOld.factory) { + descpNew += "修改权属单位,原值:" + formOld.factory + ",新值:" + formNew.factory + ";" + } + if (formNew.installheigt != formOld.installheigt) { + descpNew += "修改井口距离,原值:" + formOld.installheigt + ",新值:" + formNew.installheigt + ";" + } + if (formNew.installperson != formOld.installperson) { + descpNew += "修改运维人员,原值:" + formOld.installperson + ",新值:" + formNew.installperson + ";" + } + if (formNew.latitude != formOld.latitude) { + descpNew += "修改纬度,原值:" + formOld.latitude + ",新值:" + formNew.latitude + ";" + } + if (formNew.longitude != formOld.longitude) { + descpNew += "修改经度,原值:" + formOld.longitude + ",新值:" + formNew.longitude + ";" + } + if (formNew.position != formOld.position) { + descpNew += "修改位置描述,原值:" + formOld.position + ",新值:" + formNew.position + ";" + } + if (formNew.wellcode != formOld.wellcode) { + descpNew += "修改井编号,原值:" + formOld.wellcode + ",新值:" + formNew.wellcode + ";" + } + if (formNew.welldepth != formOld.welldepth) { + descpNew += "修改井深,原值:" + formOld.welldepth + ",新值:" + formNew.welldepth + ";" + } + if (formNew.welltype != formOld.welltype) { + descpNew += "修改井类型,原值:" + formOld.welltype + ",新值:" + formNew.welltype + ";" + } + if (formNew.project != formOld.project) { + descpNew += "修改所属项目,原值:" + formOld.project + ",新值:" + formNew.project + ";" + } + if (this.data.form.photopath1 != formOld.photopath1 || + this.data.form.photopath2 != formOld.photopath2 || + this.data.form.photopath3 != formOld.photopath3) { + descpNew += "修改照片;" + } + if ("" != formNew.description) { + descpNew += formNew.description; + } + this.setData({ + ['form.description']: descpNew + }) + }, - scan() { + //提交表单 + formSubmit: function (event) { - wx.scanCode({ - success(res) { - console.log(res) - } - }) + //表单验证 + if (!this.formValidate()) { + return false; + } + //自动生成修改内容 + this.changeMsg(); + //提交权限限制(只有施工人员能修改) + if(app.globalData.role!='repair'){ + wx.showToast({ + icon: 'none', + title: '无权限修改', + duration:2000 + }) + return false + } + var that = this; + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopath = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopath]: fileList[i].url.split("static/")[1] + }) + } + delete that.data.form.installtime + delete that.data.form.createtime + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - paste() { - var _this = this; - wx.getClipboardData({ - success: function (res) { - var longitude = 'form.longitude'; - var latitude = 'form.latitude'; - var longitude84 = 'form.longitude84'; - var latitude84 = 'form.latitude84'; - _this.setData({ - [longitude]: parseFloat(res.data.split(",", 4)[1]).toFixed(6), - [latitude]: parseFloat(res.data.split(",", 4)[0]).toFixed(6), - [longitude84]: "" == (res.data.split(",", 4)[3]) ? "" : parseFloat(res.data.split(",", 4)[3]).toFixed(6), - [latitude84]: "" == (res.data.split(",", 4)[2]) ? "" : parseFloat(res.data.split(",", 4)[2]).toFixed(6), - longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), - latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), - }); - } - }) - }, - selectValue(value) { - var that = this; - var wellType = 'form.welltype'; - that.setData({ - [wellType]: value.detail - }) - }, - selectpersonValue(event) { - var that = this; - var installPerson = 'form.installperson'; - that.setData({ - [installPerson]: event.detail - }) - }, - selectprojectValue(event) { - var that = this; - var project = 'form.project'; - that.setData({ - [project]: event.detail, - showMask: true - }) - }, - open() { - this.setData({ - showMask: true - }) - }, - close() { - this.setData({ - showMask: false - }) - }, - afterRead(event) { - var _this = this; - const { - file - } = event.detail; - const { - fileList = [] - } = _this.data; - var convertpath = ""; - wx.compressImage({ - src: event.detail.file.path, - quality: 25, - success: function (res) { - convertpath = res.tempFilePath; - wx.uploadFile({ - url: app.globalData.httpsUrl + "appDeviceAdd/fileUploadMarker", - filePath:convertpath, - name: 'file', - formData: { - 'text': "编号:" + _this.data.form.devcode + "经度:" + _this.data.form.longitude + "纬度:" + _this.data.form.latitude - }, - header: { - "Content-Type": "multipart/form-data", - 'accept': 'application/json', - }, - success(res) { - if (res.data) { - var url = JSON.parse(res.data); - fileList.push({ - ...file, - url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - }); - _this.setData({ - fileList - }); - } - } + success(res) { + if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + if (res.confirm) { + wx.switchTab({ + url: that.data.pageName }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') } - }) - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // // var base64 = "data:image/png;base64," + wx.getFileSystemManager().readFileSync(convertpath, 'base64'); - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: convertpath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // // wx.cloud.callFunction({ - // // name: 'uploadFile', - // // data: { - // // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // // fileBase64: base64 - // // }, - // // success: function (res) { - // // if (res.result) { - // // fileList.push({ - // // ...file, - // // url: app.globalData.url + "static/" + res.result.data.replace(/\\/g, "/") - // // }); - // // _this.setData({ - // // fileList - // // }); - // // } - // // }, - // // complete: res => { - // // }, - // // }) - // } - // }); + } + }) + } + }, + fail(err) { + wx.showToast({ + title: "提交失败", + }) + } + }) + }, + //报存录入的input信息 + confirm(event) { + var that = this; + var formValue = event.detail.value; + var formName = event.target.dataset.id; + var fromN = 'form.' + [formName]; + that.setData({ + [fromN]: formValue + }) + }, + + //扫码 + scan() { + + wx.scanCode({ + success(res) { + console.log(res) + } + }) + }, + //粘贴经纬度 + paste() { + var _this = this; + wx.getClipboardData({ + success: function (res) { + var longitude = 'form.longitude'; + var latitude = 'form.latitude'; + var longitude84 = 'form.longitude84'; + var latitude84 = 'form.latitude84'; + _this.setData({ + [longitude]: parseFloat(res.data.split(",", 4)[1]).toFixed(6), + [latitude]: parseFloat(res.data.split(",", 4)[0]).toFixed(6), + [longitude84]: "" == (res.data.split(",", 4)[3]) ? "" : parseFloat(res.data.split(",", 4)[3]).toFixed(6), + [latitude84]: "" == (res.data.split(",", 4)[2]) ? "" : parseFloat(res.data.split(",", 4)[2]).toFixed(6), + longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), + latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), + }); + } + }) + }, + selectValue(value) { + var that = this; + var wellType = 'form.welltype'; + that.setData({ + [wellType]: value.detail + }) + }, + //运维人员默认为登录人 + // selectpersonValue(event) { + // var that = this; + // var installPerson = 'form.installperson'; + // that.setData({ + // [installPerson]: event.detail + // }) + // }, + selectprojectValue(event) { + var that = this; + var project = 'form.project'; + that.setData({ + [project]: event.detail, + showMask: true + }) + }, + + open() { + this.setData({ + showMask: true + }) + }, + //隐藏textarea,防止遮挡 + close() { + this.setData({ + showMask: false + }) + }, + //上传照片 + afterRead(event) { + var _this = this; + const { + file + } = event.detail; + const { + fileList = [] + } = _this.data; + var convertpath = ""; + wx.compressImage({ + src: event.detail.file.path, + quality: 25, + success: function (res) { + convertpath = res.tempFilePath; + wx.uploadFile({ + url: app.globalData.httpsUrl + "appDeviceAdd/fileUploadMarker", + filePath: convertpath, + name: 'file', + formData: { + 'text': "编号:" + _this.data.form.devcode + "经度:" + _this.data.form.longitude + "纬度:" + _this.data.form.latitude }, - deletePhoto(event) { - var that = this - var image_index = event.detail.index - var fileList_new = that.data.fileList; - wx.showModal({ - content: '确定删除照片?', - success: function (res) { - if (res.confirm) { - fileList_new.splice(image_index, 1); - that.setData({ - fileList: fileList_new - }) - wx.cloud.callFunction({ - name: 'deletePhoto', - data: { - url: app.globalData.url + "appDeviceLog/deletePhoto", - devcode: that.data.form.devcode, - pathIndex: image_index - }, - success: function (res) {}, - complete: res => {}, - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + "Content-Type": "multipart/form-data", + 'accept': 'application/json', }, - }) \ No newline at end of file + success(res) { + if (res.data) { + var url = JSON.parse(res.data); + fileList.push({ + ...file, + url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") + }); + _this.setData({ + fileList + }); + } + } + }) + } + }) + }, + //删除照片 + deletePhoto(event) { + var that = this + var image_index = event.detail.index + var fileList_new = that.data.fileList; + wx.showModal({ + content: '确定删除照片?', + success: function (res) { + if (res.confirm) { + fileList_new.splice(image_index, 1); + that.setData({ + fileList: fileList_new + }) + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deletePhoto", + data: { + devcode: that.data.form.devcode + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) {} + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } +}) \ No newline at end of file diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.wxml b/miniprogram/pages/addDevicelog/addDeviceLog.wxml index 38620d4..b10cc7d 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.wxml +++ b/miniprogram/pages/addDevicelog/addDeviceLog.wxml @@ -1,15 +1,21 @@ - + + + + + - + - - + + - - + + - + @@ -39,24 +45,25 @@ - - - + + + - + - + + @@ -64,7 +71,7 @@ - + @@ -79,9 +86,9 @@ - + - 保存 + 保存 diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.wxss b/miniprogram/pages/addDevicelog/addDeviceLog.wxss index ee0b75c..08d5fd7 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.wxss +++ b/miniprogram/pages/addDevicelog/addDeviceLog.wxss @@ -24,6 +24,17 @@ display: flex; align-items: center; } +.map-view{ + width: 750rpx; + height: 485rpx; + position: fixed; + top: 0px; + left: 0px; + z-index: 999; +} +.content{ + margin-top: 495rpx; +} .left { width: 210rpx; diff --git a/miniprogram/pages/addFunction/addFunction.js b/miniprogram/pages/addFunction/addFunction.js deleted file mode 100644 index 4966be3..0000000 --- a/miniprogram/pages/addFunction/addFunction.js +++ /dev/null @@ -1,60 +0,0 @@ -// pages/addFunction/addFunction.js - -const code = `// 云函数入口函数 -exports.main = (event, context) => { - console.log(event) - console.log(context) - return { - sum: event.a + event.b - } -}` - -Page({ - - data: { - result: '', - canIUseClipboard: wx.canIUse('setClipboardData'), - }, - - onLoad: function (options) { - - }, - - copyCode: function() { - wx.setClipboardData({ - data: code, - success: function () { - wx.showToast({ - title: '复制成功', - }) - } - }) - }, - - testFunction() { - wx.cloud.callFunction({ - name: 'sum', - data: { - a: 1, - b: 2 - }, - success: res => { - wx.showToast({ - title: '调用成功', - }) - this.setData({ - result: JSON.stringify(res.result) - }) - }, - fail: err => { - wx.showToast({ - icon: 'none', - title: '调用失败', - }) - console.error('[云函数] [sum] 调用失败:', err) - } - }) - }, - -}) - diff --git a/miniprogram/pages/addFunction/addFunction.json b/miniprogram/pages/addFunction/addFunction.json deleted file mode 100644 index a9a50c5..0000000 --- a/miniprogram/pages/addFunction/addFunction.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "navigationBarTitleText": "云函数指引", - "usingComponents": {} -} \ No newline at end of file diff --git a/miniprogram/pages/addFunction/addFunction.wxml b/miniprogram/pages/addFunction/addFunction.wxml deleted file mode 100644 index 3a10626..0000000 --- a/miniprogram/pages/addFunction/addFunction.wxml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - 测试云函数 - - - 期望输出:{"sum":3} - - - 调用结果:{{result}} - - - - - 新增云函数 - 1. 在云函数根目录 cloudfunctions 上右键选择新建云函数,命名为 sum - 2. 在创建的 cloudfunctions/sum/index.js 文件中添加如下代码 - - - 3. 在 cloudfunctions/sum 目录上右键上传并部署 - 4. 点击测试云函数测试 - 5. 打开云开发云函数管理页,选择 sum 云函数 - 6. 查看 sum 的调用日志 - 进阶:可在云函数中使用 wx-server-sdk 操作数据库,文件存储和调用其他云函数,详见文档 - - - diff --git a/miniprogram/pages/addFunction/addFunction.wxss b/miniprogram/pages/addFunction/addFunction.wxss deleted file mode 100644 index 7ac8619..0000000 --- a/miniprogram/pages/addFunction/addFunction.wxss +++ /dev/null @@ -1,3 +0,0 @@ -/* pages/addFunction/addFunction.wxss */ - -@import "../../style/guide.wxss"; \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.js b/miniprogram/pages/applog/applog.js index 0e8c185..189e61f 100644 --- a/miniprogram/pages/applog/applog.js +++ b/miniprogram/pages/applog/applog.js @@ -13,98 +13,25 @@ isSeach: "false", params: {}, total: 0, - show: false + show: false, + delBtnWidth: 100, //删除按钮宽度单位(rpx) + activeIndex: -1, + list_style: '' }, - - touchE: function (e) { - // console.log(e); - var that = this - if (e.changedTouches.length == 1) { - //手指移动结束后触摸点位置的X坐标 - var endX = e.changedTouches[0].clientX; - //触摸开始与结束,手指移动的距离 - var disX = that.data.startX - endX; - var delBtnWidth = that.data.delBtnWidth; - //如果距离小于删除按钮的1/2,不显示删除按钮 - var txtStyle = disX > delBtnWidth / 2 ? "left:-" + delBtnWidth + "rpx" : "left:0rpx"; - - //获取手指触摸的是哪一项 - var index = e.currentTarget.dataset.index; - var list = that.data.deviceloglist; - list[index].txtStyle = txtStyle; - //更新列表的状态 - that.setData({ - deviceloglist: list - }); - } - }, - //手指触摸动作开始 记录起点X坐标 - touchstart: function (e) { - //开始触摸时 重置所有删除 - this.data.deviceloglist.forEach(function (v, i) { - if (v.isTouchMove) //只操作为true的 - v.isTouchMove = false; - }) - this.setData({ - startX: e.changedTouches[0].clientX, - startY: e.changedTouches[0].clientY, - deviceloglist: this.data.deviceloglist - }) - }, - //滑动事件处理 - touchmove: function (e) { - var that = this, - index = e.currentTarget.dataset.index, //当前索引 - startX = that.data.startX, //开始X坐标 - startY = that.data.startY, //开始Y坐标 - touchMoveX = e.changedTouches[0].clientX, //滑动变化坐标 - touchMoveY = e.changedTouches[0].clientY, //滑动变化坐标 - //获取滑动角度 - angle = that.angle({ - X: startX, - Y: startY - }, { - X: touchMoveX, - Y: touchMoveY - }); - that.data.deviceloglist.forEach(function (v, i) { - v.isTouchMove = false - //滑动超过30度角 return - if (Math.abs(angle) > 30) return; - if (i == index) { - if (touchMoveX > startX) //右滑 - v.isTouchMove = false - else //左滑 - v.isTouchMove = true - } - }) - //更新数据 - that.setData({ - deviceloglist: that.data.deviceloglist - }) - }, - /** - * 计算滑动角度 - * @param {Object} start 起点坐标 - * @param {Object} end 终点坐标 - */ - angle: function (start, end) { - var _X = end.X - start.X, - _Y = end.Y - start.Y - //返回角度 /Math.atan()返回数字的反正切值 - return 360 * Math.atan(_Y / _X) / (2 * Math.PI); - }, - /** - * 生命周期函数--监听页面加载var_this=this; - */ onLoad: function (options) { - if (options.params) { this.setData({ params: JSON.parse(options.params), isSeach: "true" }) this.initPages() + }else{ + this.setData({ + show: false + }) + //清空参数,重新加载 + this.clearParams(); + this.initPages(); } }, @@ -116,20 +43,33 @@ }, + //点击tabBar事件 + onTabItemTap(item) { + //隐藏历史显示总记录条数 + this.setData({ + show: false + }) + //清空参数,重新加载 + this.clearParams(); + this.initPages(); + }, + + /** * 生命周期函数--监听页面显示 */ onShow: function (options) { - this.setData({ - show:false - }) - if (this.data.isSeach == "false") { - this.clearParams(); - this.initPages(); - } - this.setData({ - isSeach: "false" - }) + + // this.setData({ + // show: false + // }) + // if (this.data.isSeach == "false") { + // this.clearParams(); + // this.initPages(); + // } + // this.setData({ + // isSeach: "false" + // }) }, /** @@ -167,6 +107,119 @@ }, + + //手指触摸动作开始 记录起点X坐标 + touchstart: function (e) { + //开始触摸时 重置所有删除 + this.data.deviceloglist.forEach(function (v, i) { + if (v.isTouchMove) //只操作为true的 + v.isTouchMove = false; + }) + this.setData({ + startX: e.changedTouches[0].clientX, + startY: e.changedTouches[0].clientY, + deviceloglist: this.data.deviceloglist + }) + }, + + //滑动事件处理 + touchmove: function (e) { + var that = this, + index = e.currentTarget.dataset.index, //当前索引 + startX = that.data.startX, //开始X坐标 + startY = that.data.startY, //开始Y坐标 + touchMoveX = e.changedTouches[0].clientX, //滑动变化坐标 + touchMoveY = e.changedTouches[0].clientY, //滑动变化坐标 + //获取滑动角度 + angle = that.angle({ + X: startX, + Y: startY + }, { + X: touchMoveX, + Y: touchMoveY + }); + that.data.deviceloglist.forEach(function (v, i) { + // v.isTouchMove = false + //滑动超过30度角 return + if (Math.abs(angle) > 30) return; + if (i == index) { + if (touchMoveX > startX) //右滑 + v.isTouchMove = false + else //左滑 + v.isTouchMove = true + } + }) + //更新数据 + that.setData({ + deviceloglist: that.data.deviceloglist + }) + }, + + /** + * 计算滑动角度 + * @param {Object} start 起点坐标 + * @param {Object} end 终点坐标 + */ + angle: function (start, end) { + var _X = end.X - start.X, + _Y = end.Y - start.Y + //返回角度 /Math.atan()返回数字的反正切值 + return 360 * Math.atan(_Y / _X) / (2 * Math.PI); + }, + + //删除事件 + delItem: function (e) { + if(app.globalData.role!='repair'){ + wx.showToast({ + icon: 'none', + title: '无权限删除', + duration:2000 + }) + return false + } + var that = this + wx.showModal({ + content: '是否删除?', + success: function (res) { + if (res.confirm) { + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/delete", + data: { + appDeviceAddId: e.currentTarget.dataset.devid + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if(res.data.code=='200'){ + that.data.deviceloglist.splice(e.currentTarget.dataset.index, 1) + that.setData({ + deviceloglist: that.data.deviceloglist, + total: that.data.deviceloglist.length + }) + wx.showToast({ + title: '删除成功!', + icon: 'none', + duration: 1000 + }) + } + }, + fail(err) { + wx.showToast({ + title: '删除失败!', + icon: 'none', + duration: 2000 + }) + } + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + }, + showLoading: function (message) { if (wx.showLoading) { // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 @@ -199,95 +252,105 @@ deviceloglist: [] }) }, + //查询列表数据 initPages: function () { var that = this + that.setData({ + show: false + }) var offsetValue = that.data.deviceloglist.length % 15 > 0 ? parseInt(that.data.deviceloglist.length / 15) + 2 : parseInt(that.data.deviceloglist.length / 15) + 1 - wx.cloud.callFunction({ - name: 'devicelog', + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/listPage", data: { devcode: that.data.params.devcode, devtype: that.data.params.devtype, installtimeFmt: that.data.params.installtimeFmt, project: that.data.params.project, installPerson: that.data.params.installPerson, - url: app.globalData.url + "appDeviceLog/listPage", limit: 15, offset: offsetValue }, - }).then(res => { - if (res.result.data.rows.length > 0) { - var resultJson = res.result - that.setData({ - deviceloglist: that.data.deviceloglist.concat(resultJson.data.rows) - }) - } else if (that.data.deviceloglist.length > 0) { - that.setData({ - show: true, - total: that.data.deviceloglist.length - }) - wx.showToast({ - title: '数据已全部加载完', - icon: 'none', - duration: 2000 - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.data.rows.length > 0) { + var resultJson = res.data + var listArr = resultJson.data.rows + listArr.forEach(function (v, i) { + listArr[i]['isTouchMove'] = false + }) + that.setData({ + deviceloglist: that.data.deviceloglist.concat(listArr) + }) + } else if (that.data.deviceloglist.length > 0) { + that.setData({ + show: true, + total: that.data.deviceloglist.length + }) + wx.showToast({ + title: '数据已全部加载完', + icon: 'none', + duration: 2000 + }) + } + if (offsetValue == 1 && res.data.data.rows.length < 15) { + that.setData({ + show: true, + total: that.data.deviceloglist.length + }) + } } - if(offsetValue==1&&res.result.data.rows.length<15){ - that.setData({ - show: true, - total: that.data.deviceloglist.length - }) - } - // console.log(res); - }).catch(err => { - console.error(err); }) + }, addDetail: function (event) { - this.showLoading("数据请求中..."); - wx.cloud.callFunction({ - name: 'deviceDetail', + var that = this + that.showLoading("数据请求中..."); + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deviceDetail", data: { devcode: event.target.dataset.devcode, - url: app.globalData.url + "appDeviceLog/deviceDetail", }, - }).then(res => { - this.hideLoading(); - var resultObject = JSON.parse(res.result); - var pageName = '../applog/applog' - if (resultObject.code == 200) { - wx.navigateTo({ - url: '../addDevicelog/addDeviceLog?detail=' + - JSON.stringify(resultObject.data) + "&pageName=" + pageName - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + that.hideLoading(); + // var resultObject = JSON.parse(res.data); + var resultObject = res.data; + var pageName = '../applog/applog' + if (resultObject.code == 200) { + wx.setStorageSync('resultObject', resultObject.data) + wx.navigateTo({ + url: '../addDevicelog/addDeviceLog?detail=' + "&pageName=" + pageName + }) + } + }, + fail(err) { + that.hideLoading(); } - }).catch(err => { - this.hideLoading() }) + }, add: function (event) { - wx.reLaunch({ - url: '../earth/earth?devcode=' + event.target.dataset.devcode - // url: '../earth/earth' + app.globalData.devcode = event.target.dataset.devcode; + wx.switchTab({ + url: '../earth/earth' }) + // wx.reLaunch({ + // url: '../earth/earth?devcode=' + event.target.dataset.devcode + // // url: '../earth/earth' + // }) }, onSearch: function () { + var _this = this wx.navigateTo({ - url: '../searchLog/searchLog' + url: '../searchLog/searchLog?params=' + JSON.stringify(_this.data.params) }) - }, - // initPages: function () { - // wx.cloud.callFunction({ - // name: 'devicelog' - // }).then(res => { - // var that = this; - // var jsonList = JSON.parse(res.result) - // that.setData({ - // deviceloglist: jsonList.data.rows - // }) - // console.log(res); - // }).catch(err => { - // console.error(err); - // }) - // } + } }) \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.wxml b/miniprogram/pages/applog/applog.wxml index e9a2352..2bfd041 100644 --- a/miniprogram/pages/applog/applog.wxml +++ b/miniprogram/pages/applog/applog.wxml @@ -1,54 +1,59 @@ - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {{item.devcode}} {{item.devicetype}} + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + {{item.devcode}} {{item.devicetype}} + + {{item.project}} {{item.installtime}}- {{item.installperson}} - - - - - + + + + + + 删除 - - - + + - 共计:{{total}}台 - + 共计:{{total}}台 + \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.wxss b/miniprogram/pages/applog/applog.wxss index 6d3428b..e6e8983 100644 --- a/miniprogram/pages/applog/applog.wxss +++ b/miniprogram/pages/applog/applog.wxss @@ -22,16 +22,18 @@ position: fixed; width: 100%; top: 0rpx; + z-index: 9999; /* margin-bottom: 100rpx; */ } .log-list { /* height: 100rpx; */ - /* display: flex; */ - + display: flex; + width: 100%; padding: 2px; margin-top: 2px; border-bottom: 1px solid #e5e5e5; + overflow: hidden } @@ -53,23 +55,29 @@ left: 35%; margin: 20rpx } - .del { - width: 90px; + /* display: flex; */ + width: 100rpx; display: flex; flex-direction: column; align-items: center; justify-content: center; - color: #fff; - -webkit-transform: translateX(90px); - transform: translateX(90px); - -webkit-transition: all 0.4s; + /* -webkit-transform: translateX(100rpx); */ + transform: translateX(100rpx); + /* -webkit-transition: all 0.4s; */ transition: all 0.4s; - font-size: 35rpx; + color: #fff; + background-color: #fe3e2f; +} +.logrow{ + width: 100%; + transform: translateX(100rpx); + /* -webkit-transform: translateX(100px); */ + margin-left: -100rpx; } -.touch-move-active .content, +.touch-move-active .logrow, .touch-move-active .del { - -webkit-transform: translateX(0); - transform: translateX(0); +/* -webkit-transform: translateX(0); */ +transform: translateX(0); } \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.js b/miniprogram/pages/deployFunctions/deployFunctions.js deleted file mode 100644 index a76b144..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.js +++ /dev/null @@ -1,66 +0,0 @@ -// pages/deployFunctions/deployFunctions.js -Page({ - - /** - * 页面的初始数据 - */ - data: { - - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - - }, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { - - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - - }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { - - }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { - - } -}) \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.json b/miniprogram/pages/deployFunctions/deployFunctions.json deleted file mode 100644 index 7fbedab..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "navigationBarTitleText": "部署云函数", - "usingComponents": {} -} \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.wxml b/miniprogram/pages/deployFunctions/deployFunctions.wxml deleted file mode 100644 index 462b6b6..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.wxml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - 调用失败 - - - 请检查 login 云函数是否已部署 - - - - - 部署 login 云函数 - 1. 确保已通过工具栏云开发入口开通云开发 - 2. 在 cloudfunctions/login 目录上右键上传并部署 - 3. 回到首页,重新点击获取 openid - - - - diff --git a/miniprogram/pages/deployFunctions/deployFunctions.wxss b/miniprogram/pages/deployFunctions/deployFunctions.wxss deleted file mode 100644 index c8803e6..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.wxss +++ /dev/null @@ -1,7 +0,0 @@ -/* pages/deployFunctions/deployFunctions.wxss */ - -@import "../../style/guide.wxss"; - -.black { - color: black; -} \ No newline at end of file diff --git a/miniprogram/pages/earth/earth.js b/miniprogram/pages/earth/earth.js index ae0d3f3..376a6e2 100644 --- a/miniprogram/pages/earth/earth.js +++ b/miniprogram/pages/earth/earth.js @@ -21,19 +21,12 @@ show: false, enableSsatellite: false, windowWidth: 0, - longitude: 113.324520, - latitude: 23.099994, - longitude84: 113.324520, - latitude84: 23.099994, - markers: [{ - id: 0, - iconPath: "../../images/locat.png", - latitude: 23.099994, - longitude: 113.324520, - width: 50, - height: 50 - }], - controls: [], + longitude: "116.627340", + latitude: "39.874390", + longitude84: "", + latitude84: "", + markers: [], + controls: [] }, /** @@ -41,39 +34,13 @@ */ onLoad: function (options) { var that = this; - //获取当前坐标(gcj02) - wx.getLocation({ - type: "gcj02", - altitude: true, - success: function (res) { - that.setData({ - latitude: parseFloat(res.latitude).toFixed(6), - longitude: parseFloat(res.longitude).toFixed(6), - // markers: [{ - // latitude: res.latitude, - // longitude: res.longitude, - // }] - }) - //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 - wx.getLocation({ - type: "wgs84", - altitude: true, - success: function (res) { - that.setData({ - latitude84: parseFloat(res.latitude).toFixed(6), - longitude84: parseFloat(res.longitude).toFixed(6) - }) - } - }) - } - }), - - //设置地图组件 - wx.getSystemInfo({ + //设置地图组件 + wx.getSystemInfo({ success(res) { var windowWidth = res.windowWidth var windowHeight = res.windowHeight var query = wx.createSelectorQuery() + var platform =res.platform query.select('#map').boundingClientRect() query.exec(function (res) { that.setData({ @@ -139,10 +106,20 @@ clickable: true }, { id: 7, - iconPath: '../../images/locat.png', + iconPath: '../../images/applocat.png', position: { - left: res[0].width/2, - top: res[0].height/2, + left: res[0].width / 2 - 20, + top: platform=="ios"?res[0].height / 2 - 80:res[0].height / 2 - 40, + width: 40, + height: 40 + }, + clickable: true + }, { + id: 8, + iconPath: '../../images/back.png', + position: { + left: windowWidth - 40, + top: windowHeight - 140, width: 30, height: 30 }, @@ -150,71 +127,15 @@ }] }) }) - + } - }), + }) + // 实例化API核心类 qqmapsdk = new QQMapWX({ key: 'BGPBZ-C5O3P-ROUDR-LWC4J-63EKH-V5FRX' }) - - if (options.devcode) { - var that = this - var devcode = options.devcode - wx.cloud.callFunction({ - name: 'findListByCodes', - data: { - devcodes: devcode, - url: app.globalData.url + "appDeviceAdd/findListByCodes" - }, - }).then(res => { - if (res.result.code == 200) { - var listResultData = res.result.data; - that.setData({ - listData: listResultData - }) - var markersArr = that.data.markers; - for (var i = 0; i < listResultData.length; i++) { - markersArr = markersArr.concat({ - iconPath: "../../images/locat.png", - id: listResultData[i].id, - callout: { - content: listResultData[i].devcode, - fontSize: '14', - // padding: true, - color: '#00000', - borderColor: '#F4EA2A', - bgColor: '#F4EA2A', - borderWidth: 5, - display: 'ALWAYS', - textAlign: 'center', - // borderRadius: 15 - }, - latitude: listResultData[i].latitude, - longitude: listResultData[i].longitude, - width: 40, - height: 40 - }); - } - this.setData({ - markers: markersArr, - latitude: listResultData[0].latitude, - longitude: listResultData[0].longitude, - marker_latitude: listResultData[0].latitude, - marker_longitude: listResultData[0].longitude, - title: listResultData[0].devcode - }) - } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "无法获取设备地理信息!", - icon: 'none', - duration: 2000 - }) - }) - } }, /** @@ -228,6 +149,97 @@ * 生命周期函数--监听页面显示 */ onShow: function () { + //输入设备编号获取marker位置信息 + var that = this; + if ( app.globalData.devcode!="") { + var devcode = app.globalData.devcode + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/findListByCodes", + data: { + devcodes: devcode, + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + app.globalData.devcode=""; + if (res.data.code == 200) { + var listResultData = res.data.data; + that.setData({ + listData: listResultData + }) + var markersArr = that.data.markers; + for (var i = 0; i < listResultData.length; i++) { + markersArr = markersArr.concat({ + iconPath: "../../images/locat.png", + id: Number(listResultData[i].id), + callout: { + content: "编号:"+listResultData[i].devcode+"\r\n位置:"+listResultData[i].position+"\r\n时间:"+listResultData[i].createtime, + fontSize: '14', + padding: true, + color: '#000000', + borderColor: '#F4EA2A', + bgColor: '#F4EA2A', + borderWidth: 5, + display: 'ALWAYS', + textAlign: 'left', + // borderRadius: 15 + }, + latitude: listResultData[i].latitude, + longitude: listResultData[i].longitude, + width: 40, + height: 40 + }); + } + that.setData({ + markers: markersArr, + latitude: listResultData[0].latitude, + longitude: listResultData[0].longitude, + marker_latitude: listResultData[0].latitude, + marker_longitude: listResultData[0].longitude, + title: listResultData[0].devcode + }) + } + }, + fail(err) { + app.globalData.devcode=""; + wx.showToast({ + title: "无法获取设备地理信息!", + icon: 'none', + duration: 2000 + }) + } + }) +} else { + //获取当前坐标(gcj02) + wx.getLocation({ + type: "gcj02", + altitude: true, + success: function (res) { + that.setData({ + latitude: parseFloat(res.latitude).toFixed(6), + longitude: parseFloat(res.longitude).toFixed(6), + // markers: [{ + // latitude: res.latitude, + // longitude: res.longitude, + // }] + }) + //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 + wx.getLocation({ + type: "wgs84", + altitude: true, + success: function (res) { + that.setData({ + latitude84: parseFloat(res.latitude).toFixed(6), + longitude84: parseFloat(res.longitude).toFixed(6) + }) + } + }) + } + }) +} + }, @@ -265,12 +277,46 @@ onShareAppMessage: function () { }, + + //定位出来 + + locationPosition: function () { + var that = this; + //获取当前坐标(gcj02) + wx.getLocation({ + type: "gcj02", + altitude: true, + success: function (res) { + that.setData({ + latitude: parseFloat(res.latitude).toFixed(6), + longitude: parseFloat(res.longitude).toFixed(6), + // markers: [{ + // latitude: res.latitude, + // longitude: res.longitude + // }] + }) + //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 + wx.getLocation({ + type: "wgs84", + altitude: true, + success: function (res) { + that.setData({ + latitude84: parseFloat(res.latitude).toFixed(6), + longitude84: parseFloat(res.longitude).toFixed(6) + }) + } + }) + } + }) + }, + + //加载地图组件 controltap: function (e) { // console.log(e.controlId); //进入添加设备页 if (1 == e.controlId) { wx.setClipboardData({ - data: this.data.latitude + "," + this.data.longitude+ "," + this.data.latitude84+ "," + this.data.longitude84, + data: this.data.latitude + "," + this.data.longitude + "," + this.data.latitude84 + "," + this.data.longitude84, success: function (res) { wx.getClipboardData({ success: function (res) { @@ -282,6 +328,17 @@ } }) } else if (3 == e.controlId) { + //先定位 + // this.locationPosition() + wx.setClipboardData({ + data: this.data.latitude + "," + this.data.longitude + "," + this.data.latitude84 + "," + this.data.longitude84, + success: function (res) { + wx.showToast({ + title: '坐标已获取', + duration: 1000 + }) + } + }) wx.navigateTo({ url: '../addDevice/addDevice' }) @@ -302,32 +359,15 @@ enableSsatellite: !flag }); } else if (6 == e.controlId) { - var that = this; - //获取当前坐标(gcj02) - wx.getLocation({ - type: "gcj02", - altitude: true, - success: function (res) { - that.setData({ - latitude: parseFloat(res.latitude).toFixed(6), - longitude:parseFloat(res.longitude).toFixed(6), - // markers: [{ - // latitude: res.latitude, - // longitude: res.longitude - // }] - }) - //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 - wx.getLocation({ - type: "wgs84", - altitude: true, - success: function (res) { - that.setData({ - latitude84: parseFloat(res.latitude).toFixed(6), - longitude84: parseFloat(res.longitude).toFixed(6) - }) - } - }) - } + //先清marker + this.setData({ + markers: [] + }) + this.locationPosition() + }else if (8 == e.controlId) { + //跳转日志缓存页 + wx.switchTab({ + url: '../applog/applog', }) } }, @@ -343,63 +383,68 @@ }); }, + //获取设备maker leave() { var that = this; if (that.data.devcodes == "") { return false; } - wx.cloud.callFunction({ - name: 'findListByCodes', + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/findListByCodes", data: { - devcodes: that.data.devcodes, - url: app.globalData.url + "appDeviceAdd/findListByCodes" + devcodes: that.data.devcodes }, - }).then(res => { - if (res.result.code == 200) { - var listResultData = res.result.data; - that.setData({ - listData: listResultData - }) - var markersArr = that.data.markers; - for (var i = 0; i < listResultData.length; i++) { - markersArr = markersArr.concat({ - iconPath: "../../images/locat.png", - id: listResultData[i].id, - callout: { - content: listResultData[i].devcode, - fontSize: '14', - // padding: true, - color: '', - borderColor: '#F4EA2A', - bgColor: '#F4EA2A', - borderWidth: 5, - display: 'ALWAYS', - textAlign: 'center', - // borderRadius: 15 - }, - latitude: listResultData[i].latitude, - longitude: listResultData[i].longitude, - width: 40, - height: 40 - }); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var listResultData = res.data.data; + that.setData({ + listData: listResultData + }) + var markersArr = that.data.markers; + for (var i = 0; i < listResultData.length; i++) { + markersArr = markersArr.concat({ + iconPath: "../../images/locat.png", + id: listResultData[i].id, + callout: { + content: "编号:"+listResultData[i].devcode+"\r\n位置:"+listResultData[i].position+"\r\n时间:"+listResultData[i].createtime, + fontSize: '14', + // padding: true, + color: '#212121', + borderColor: '#F4EA2A', + bgColor: '#F4EA2A', + borderWidth: 5, + display: 'ALWAYS', + textAlign: 'left', + // borderRadius: 15 + }, + latitude: listResultData[i].latitude, + longitude: listResultData[i].longitude, + width: 40, + height: 40 + }); + } + that.setData({ + markers: markersArr, + latitude: listResultData[0].latitude, + longitude: listResultData[0].longitude, + marker_latitude: listResultData[0].latitude, + marker_longitude: listResultData[0].longitude, + title: listResultData[0].devcode + }) } - this.setData({ - markers: markersArr, - latitude: listResultData[0].latitude, - longitude: listResultData[0].longitude, - marker_latitude: listResultData[0].latitude, - marker_longitude: listResultData[0].longitude, - title: listResultData[0].devcode + }, + fail(err) { + wx.showToast({ + title: "无法获取设备地理信息!", + icon: 'none', + duration: 2000 }) } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "无法获取设备地理信息!", - icon: 'none', - duration: 2000 - }) }) }, @@ -422,6 +467,8 @@ } }, + + bindregionchange: function (e) { var that = this if (e.causedBy == "drag") { @@ -445,8 +492,8 @@ that.setData({ latitude: parseFloat(latitude).toFixed(6), longitude: parseFloat(longitude).toFixed(6), - latitude84:"", - longitude84:"", + latitude84: "", + longitude84: "", // markers: markersArr }) // mapCtx.moveToLocation(); @@ -465,16 +512,19 @@ qqmapsdk.search({ keyword: this.data.value, success: function (res) { + console.log(res) if (res && res.data) { _this.setData({ isShow: true, tips: res.data }); } + }, + complete: function (res){ + console.log(res); } }) }, - bindSearch: function (e) { var location = e.target.dataset.location; this.setData({ diff --git a/miniprogram/pages/earth/earth.wxml b/miniprogram/pages/earth/earth.wxml index a0db6ef..87474f8 100644 --- a/miniprogram/pages/earth/earth.wxml +++ b/miniprogram/pages/earth/earth.wxml @@ -1,9 +1,10 @@ + - + {{item.title}} {{item.address}} @@ -17,6 +18,6 @@ + placeholder="请输入定位设备编号用换行隔开" autosize border="{{ false }}" /> \ No newline at end of file diff --git a/miniprogram/pages/indexapp/indexapp.js b/miniprogram/pages/indexapp/indexapp.js index 5063372..849dbdb 100644 --- a/miniprogram/pages/indexapp/indexapp.js +++ b/miniprogram/pages/indexapp/indexapp.js @@ -7,9 +7,8 @@ */ data: { - count:1, - show: false, - onshow:true, + count: 1, + onshow: true, value: "", deviceloglist: [], devcode: "", @@ -21,6 +20,7 @@ // iconPath: "../../images/point.png", latitude: 23.099994, longitude: 113.324520, + label:'1', width: 50, height: 50 }], @@ -31,62 +31,26 @@ * 生命周期函数--监听页面加载 */ onLoad: function (options) { - + }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { - + }, /** * 生命周期函数--监听页面显示 */ onShow: function () { - // if( app.globalData.indexCount>1){ - // this.setData({ - // show:false - // }) - // }else{ - // this.showNotice() - // } - if(app.globalData.indexCount==1){ - this.setData({ - show:true - }) - this.showNotice() - } - app.globalData.indexCount+=1 - if(this.data.onshow){ + if (this.data.onshow) { this.initPages(); } }, - - showNotice: function() { - var that = this - var times = 0 - var i = setInterval(function() { - times++ - if (times >= 15) { - that.setData({ - show:false - }) - wx.showTabBar({ - animation: false, - }) - clearInterval(i) - } else { - wx.hideTabBar({ - animation: false, - }) - } - }, 1000) -}, - /** * 生命周期函数--监听页面隐藏 */ @@ -122,16 +86,27 @@ }, jump: function (event) { - var that = this; var latitude = event.target.dataset.pointLat; var longitude = event.target.dataset.pointLon; + let devcode = event.target.dataset.pointCode; that.setData({ latitude: latitude, longitude: longitude, markers: [{ latitude: latitude, - longitude: longitude + longitude: longitude, + callout: { + display:'ALWAYS',// 常显气泡 + content: devcode, //名称文本 + color: '#fff', //文本颜色 + borderRadius: 5, //边框圆角 + borderWidth: 1, //边框宽度 + borderColor: '#0060ff', //边框颜色 + bgColor: '#0060ff', //背景色 + padding: 5, //文本边缘留白 + textAlign: 'center' //文本对齐方式。有效值: left, right, center + } }] }) }, @@ -142,7 +117,7 @@ var devcode = res.result _this.setData({ devcode: devcode, - onshow:false + onshow: false }); _this.searchlogs(devcode) } @@ -151,40 +126,11 @@ onSearch: function (event) { this.setData({ - devcode:event.detail + devcode: event.detail }) this.searchlogs(event.detail) }, - - // bindregionchange: function (e) { - // var that = this - // if (e.causedBy == "drag") { - // var mapCtx = wx.createMapContext("map") - // mapCtx.getCenterLocation({ - // success: function (res) { - // var markersArr = that.data.markers - // for (var i = 0; i < markersArr.length; i++) { - // if (markersArr[i].iconPath == undefined) { - // markersArr.splice(i, 1) - // } - // } - // var latitude = res.latitude - // var longitude = res.longitude - // markersArr = markersArr.concat({ - // latitude: latitude, - // longitude: longitude - // }) - // that.setData({ - // latitude: latitude, - // longitude: longitude, - // markers: markersArr - // }) - // } - // }) - // } - // }, - showLoading: function (message) { if (wx.showLoading) { // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 @@ -211,81 +157,89 @@ } }, + //加载设备运维详细信息 toDetail: function (event) { - this.showLoading("数据加载中...") - wx.cloud.callFunction({ - name: 'deviceDetail', + var that = this + that.showLoading("数据加载中...") + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deviceDetail", data: { devcode: event.target.dataset.devcode, - url: app.globalData.url + "appDeviceLog/deviceDetail", }, - }).then(res => { - this.hideLoading(); - var resultObject = JSON.parse(res.result); - var pageName='../indexapp/indexapp' - if (resultObject.code == 200) { - wx.navigateTo({ - url: '../addDevicelog/addDeviceLog?detail=' + - JSON.stringify(resultObject.data)+'&pageName='+pageName - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + that.hideLoading(); + var resultObject = res.data; + var pageName = '../indexapp/indexapp' + if (resultObject.code == 200) { + wx.setStorageSync('resultObject', resultObject.data) + wx.navigateTo({ + url: '../addDevicelog/addDeviceLog?detail=' +'&pageName=' + pageName + }) + } + }, + fail(err){ + that.hideLoading(); } - }).catch(err => { - this.hideLoading(); }) }, + //加载列表 getlogs: function (devcode) { var that = this - wx.cloud.callFunction({ - name: 'devicelog', + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/listPage", data: { devcode: devcode, - url: app.globalData.url + "appDeviceLog/listPage", limit: 100, offset: that.data.deviceloglist.length % 100 > 0 ? parseInt(that.data.deviceloglist.length / 100) + 2 : parseInt(that.data.deviceloglist.length / 100) + 1 }, - }).then(res => { - if (res.result) { - // var resultJson = JSON.parse(res.result) - var resultJson = res.result - that.setData({ - deviceloglist: that.data.deviceloglist.concat(resultJson.data.rows) - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + // var resultJson = JSON.parse(res.result) + var resultJson = res.data + that.setData({ + deviceloglist: that.data.deviceloglist.concat(resultJson.data.rows) + }) + } } - console.log(res); - }).catch(err => { - console.error(err); }) }, + //查询列表 searchlogs: function (devcode) { var that = this - wx.cloud.callFunction({ - name: 'devicelog', + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/listPage", data: { devcode: devcode, - url: app.globalData.url + "appDeviceLog/listPage", limit: 100, offset: 1 }, - }).then(res => { - if (res.result) { - var resultJson = res.result - that.setData({ - deviceloglist: resultJson.data.rows, - onshow:true - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var resultJson = res.data + that.setData({ + deviceloglist: resultJson.data.rows, + onshow: true + }) + } } - console.log(res); - }).catch(err => { - console.error(err); }) }, initPages: function () { var that = this; - that.setData({ - devcode: "" - }); wx.getLocation({ type: "gcj02", success: function (res) { @@ -302,6 +256,6 @@ }) } }) - this.searchlogs() + this.data.devcode !== '' ? this.searchlogs(this.data.devcode) : this.searchlogs() }, }) \ No newline at end of file diff --git a/miniprogram/pages/indexapp/indexapp.wxml b/miniprogram/pages/indexapp/indexapp.wxml index 69322a0..f65b082 100644 --- a/miniprogram/pages/indexapp/indexapp.wxml +++ b/miniprogram/pages/indexapp/indexapp.wxml @@ -1,8 +1,12 @@ + + + + - @@ -32,9 +36,15 @@ - + + + + + + + @@ -46,14 +56,14 @@ - + - - + diff --git a/miniprogram/pages/indexapp/indexapp.wxss b/miniprogram/pages/indexapp/indexapp.wxss index b18706a..fc27fcb 100644 --- a/miniprogram/pages/indexapp/indexapp.wxss +++ b/miniprogram/pages/indexapp/indexapp.wxss @@ -128,6 +128,7 @@ .noticeClass{ height: 2300rpx; width: 750rpx; + overflow-y:hidden; } @@ -148,14 +149,14 @@ } +/* .vanstyle{ + button: not([size='mini']) { + user agent stylesheetmin-height: 40px; + width: 650rpx; + margin-left: 20rpx; + margin-right: auto; + + } + +} */ -/* .van-enter-active-class, -.van-leave-active-class { - transition-property: background-color, transform; -} - -.van-enter-class, -.van-leave-to-class { - background-color: red; - transform: rotate(-360deg) translate3d(-100%, -100%, 0); -} */ \ No newline at end of file diff --git a/miniprogram/pages/log/log.js b/miniprogram/pages/log/log.js deleted file mode 100644 index 83ba349..0000000 --- a/miniprogram/pages/log/log.js +++ /dev/null @@ -1,66 +0,0 @@ -// pages/log/log.js -Page({ - - /** - * 页面的初始数据 - */ - data: { - - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - - }, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { - - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - - }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { - - }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { - - } -}) \ No newline at end of file diff --git a/miniprogram/pages/log/log.json b/miniprogram/pages/log/log.json deleted file mode 100644 index 8835af0..0000000 --- a/miniprogram/pages/log/log.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "usingComponents": {} -} \ No newline at end of file diff --git a/miniprogram/pages/log/log.wxml b/miniprogram/pages/log/log.wxml deleted file mode 100644 index a510ad6..0000000 --- a/miniprogram/pages/log/log.wxml +++ /dev/null @@ -1,2 +0,0 @@ - -pages/log/log.wxml diff --git a/miniprogram/pages/log/log.wxss b/miniprogram/pages/log/log.wxss deleted file mode 100644 index 23db318..0000000 --- a/miniprogram/pages/log/log.wxss +++ /dev/null @@ -1 +0,0 @@ -/* pages/log/log.wxss */ \ No newline at end of file diff --git a/miniprogram/pages/login/login.js b/miniprogram/pages/login/login.js index a4074e7..cb0542a 100644 --- a/miniprogram/pages/login/login.js +++ b/miniprogram/pages/login/login.js @@ -1,11 +1,14 @@ // miniprogram/pages/login/login.js +var app = getApp() Page({ /** * 页面的初始数据 */ data: { - windowWidth:"" + windowWidth: "", + time: 15 * 1000, + showTime: false }, /** @@ -20,9 +23,9 @@ */ onReady: function () { this.setData({ - windowWidth:wx.getSystemInfoSync().windowWidth + windowWidth: wx.getSystemInfoSync().windowWidth }) - + }, /** @@ -66,14 +69,158 @@ onShareAppMessage: function () { }, + + + showLoading: function (message) { + if (wx.showLoading) { + // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 + wx.showLoading({ + title: message, + mask: true + }); + } else { + // 低版本采用Toast兼容处理并将时间设为20秒以免自动消失 + wx.showToast({ + title: message, + icon: 'loading', + mask: true, + duration: 20000 + }); + } + }, + hideLoading: function () { + if (wx.hideLoading) { + // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 + wx.hideLoading(); + } else { + wx.hideToast(); + } + }, + + //注册 loginClick: function () { + var that = this + that.showLoading("授权中...") + wx.login({ + success: function (res) { + if (res.code) { + wx.request({ + url: app.globalData.httpsUrl + "appUserOpenid/login", + data: { + code: res.code + }, + success: function (res) { + app.globalData.openid = res.data.data + wx.getUserInfo({ + success: (res) => { + var nickname = res.userInfo.nickName; + app.globalData.nickName = nickname; + //openid绑定昵称存入后台 + wx.request({ + url: app.globalData.httpsUrl + "appUserOpenid/add", + data: { + attr: nickname, + openid: app.globalData.openid + }, + success: function (res) { + that.hideLoading(); + wx.showToast({ + title: res.data.data+",\r\n请从正式版入口登录!", + icon: 'none', + duration: 2000 + }) - wx.navigateTo({ - - url: '../farmermain/farmermain', - + // //授权成功后跳转 + // wx.switchTab({ + // url: '../indexapp/indexapp' + // }) + } + }) + }, + fail: function (err) { + that.hideLoading(); + } + }) + }, + fail: function (res) { + that.hideLoading(); + wx.showToast({ + title: '服务器异常', + }) + } + }) + } + }, + fail: function (res) { + that.hideLoading(); + } }) + }, + //登录验证 + loginValidate: function () { + var that = this + that.showLoading("登录中...") + wx.login({ + success: function (res) { + if (res.code) { + console.info(res); + wx.request({ + url: app.globalData.httpsUrl + "appUserOpenid/login", + data: { + code: res.code + }, + success: function (res) { + app.globalData.openid = res.data.data + wx.request({ + url: app.globalData.httpsUrl + "appUserOpenid/validate", + data: { + openid: app.globalData.openid + }, + success: function (res) { + that.hideLoading(); + if (res.data.data) { + app.globalData.userName = res.data.data.attr1 == '' ? res.data.data.attr : res.data.data.attr1 + app.globalData.nickName = res.data.data.attr + app.globalData.role = res.data.data.role + wx.navigateTo({ + url: '../notice/notice' + }) + } else { + wx.showToast({ + icon: 'none', + title: '请联系管理员授权', + duration: 2000 + }) + } + }, + fail: function (err) { + that.hideLoading(); + wx.showToast({ + title: '验证失败', + }) + } + }) + }, + fail: function (res) { + that.hideLoading(); + wx.showToast({ + title: '服务器异常', + }) + } + }) + } + }, + fail: function (res) { + that.hideLoading(); + } + }) + }, + + finished() { + this.setData({ + showTime: true + }) }, onClickSubmit: function () { diff --git a/miniprogram/pages/login/login.json b/miniprogram/pages/login/login.json index 8835af0..f2043a3 100644 --- a/miniprogram/pages/login/login.json +++ b/miniprogram/pages/login/login.json @@ -1,3 +1,8 @@ { - "usingComponents": {} + "usingComponents": { + "van-count-down": "../../miniprogram_npm/@vant/weapp/count-down", + "van-button": "../../miniprogram_npm/@vant/weapp/button" + }, + "navigationBarBackgroundColor": "#E6D480", + "disableScroll":true } \ No newline at end of file diff --git a/miniprogram/pages/login/login.wxml b/miniprogram/pages/login/login.wxml index c69df42..cf2ec72 100644 --- a/miniprogram/pages/login/login.wxml +++ b/miniprogram/pages/login/login.wxml @@ -1,21 +1,46 @@ + - + + + - + + + +    本程序为施工日志管理小程序,为航天二院智慧市 +政技术研究室内部系统,不对外开放。出于对数据信 +息安全的考虑,在您首次使用小程序时,请先对小程 +序进行授权,授权后的用户可以正常对小程序进行编 +辑,谢谢您的配合! + + + + + + + + 授权/登录 + + + - + + + diff --git a/miniprogram/pages/login/login.wxss b/miniprogram/pages/login/login.wxss index ca77568..b9fa569 100644 --- a/miniprogram/pages/login/login.wxss +++ b/miniprogram/pages/login/login.wxss @@ -54,7 +54,8 @@ } .form .submit { - margin-top: 80rpx; + + /* margin-top: 80rpx; */ color: #fff; border: 2rpx solid #FFB90F; background-color: #FFB90F; @@ -63,10 +64,30 @@ } .login_image { - width: 200rpx; - height: 200rpx; - padding-top: 100rpx; - padding-left: 250rpx; + width: 750rpx; + height: 360rpx; + /* height: 2300rpx; */ + /* padding-top: 100rpx + padding-left: 250rpx; */ +} +.bottom_image { + width: 750rpx; + height: 32%; + position: fixed; + bottom: 0px; + /* padding-top: 100rpx + padding-left: 250rpx; */ +} +.cover{ + position: fixed; + top: 0rpx; + margin-left: 290rpx; + text-align:center; + font-size: 50rpx; + color: #FFCF00; + width: 750rpx; + z-index:9999; + } -} \ No newline at end of file + \ No newline at end of file diff --git a/miniprogram/pages/notice/notice.js b/miniprogram/pages/notice/notice.js new file mode 100644 index 0000000..7aeafb9 --- /dev/null +++ b/miniprogram/pages/notice/notice.js @@ -0,0 +1,80 @@ +// miniprogram/pages/notice.js +Page({ + + /** + * 页面的初始数据 + */ + data: { + time: 15 * 1000, + showTime: false + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { + this.setData({ + showTime: true + }) + wx.switchTab({ + url: '../indexapp/indexapp' + }) + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + }, + finished() { + this.setData({ + showTime: true + }) + wx.switchTab({ + url: '../indexapp/indexapp' + }) + } +}) \ No newline at end of file diff --git a/miniprogram/pages/notice/notice.json b/miniprogram/pages/notice/notice.json new file mode 100644 index 0000000..4c73264 --- /dev/null +++ b/miniprogram/pages/notice/notice.json @@ -0,0 +1,5 @@ +{ + "usingComponents": { + "van-count-down": "../../miniprogram_npm/@vant/weapp/count-down" + } +} \ No newline at end of file diff --git a/miniprogram/pages/notice/notice.wxml b/miniprogram/pages/notice/notice.wxml new file mode 100644 index 0000000..975304a --- /dev/null +++ b/miniprogram/pages/notice/notice.wxml @@ -0,0 +1,10 @@ + + + + + + + + diff --git a/miniprogram/pages/notice/notice.wxss b/miniprogram/pages/notice/notice.wxss new file mode 100644 index 0000000..36d7542 --- /dev/null +++ b/miniprogram/pages/notice/notice.wxss @@ -0,0 +1,18 @@ +/* miniprogram/pages/notice.wxss */ + +.login_image { + width: 750rpx; + height: 2300rpx; + /* padding-top: 100rpx + padding-left: 250rpx; */ +} +.cover{ + position: fixed; + top: 0rpx; + margin-left: 290rpx; + text-align:center; + font-size: 50rpx; + color: #FFCF00; + width: 750rpx; + z-index:9999; + } \ No newline at end of file diff --git a/miniprogram/pages/searchLog/searchLog.js b/miniprogram/pages/searchLog/searchLog.js index a4f8c33..1f7069b 100644 --- a/miniprogram/pages/searchLog/searchLog.js +++ b/miniprogram/pages/searchLog/searchLog.js @@ -6,29 +6,35 @@ * 页面的初始数据 */ data: { - defaultDay:[ + defaultDay: [ new Date().getTime(), - new Date().getTime()+24*60*60*1000, + new Date().getTime() + 24 * 60 * 60 * 1000, ], projectoption: [], - devtypeList:[], + devtypeList: [], personoption: [], installtimeFmt: '', show: false, - minDate: new Date(2010, 0, 1).getTime(), devcode: '', + timeShow:false, project: '', devtype: '', - installPerson:'', + installPerson: '', + projectvalue:'', minDate: new Date(2018, 0, 1).getTime(), // maxDate: new Date(2018, 0, 31).getTime(), }, onDisplay() { - this.setData({ show: true }); + this.setData({ + show: true + }); }, onClose() { - this.setData({ show: false }); + this.setData({ + show: false + }); }, + //格式化时间 formatDate(date) { date = new Date(date); // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; @@ -50,6 +56,7 @@ return currentdate; }, + //查询时间区域设置 onConfirm(event) { // this.setData({ @@ -67,87 +74,102 @@ /** * 生命周期函数--监听页面加载 */ - onLoad: function (options) { - var _this=this + onLoad: async function (options) { + await this.setData({ + timeShow:true, + }) + const {devcode,devtype,installPerson,installtimeFmt,project} = JSON.parse(options.params) + this.setData({ + devcode:devcode || '', + devtype:devtype || '', + installPerson:installPerson || '', + installtimeFmt:installtimeFmt || '', + project:project || '', + projectvalue:project || '', + + }) + + var _this = this /** * 获取所属项目下拉列表 */ - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); + success(res) { + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); + } + _this.setData({ + projectoption: projectArr + }) } - _this.setData({ - projectoption: projectArr - }) } - }).catch(err => { - console.error(err); }) - - - /** + /** * 获取设备类型下拉列表 */ - wx.cloud.callFunction({ - name: 'getTypeList', - data: { - url: app.globalData.url + "deviceType/deviceType" + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/deviceType", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - }).then(res => { - if (res.result.code == 200) { - var TypeList = res.result.data - var typeArr = []; - for (var i = 0; i < TypeList.length; i++) { - var type = { - text: TypeList[i].productName, - value: TypeList[i].productName - }; - typeArr.push(type); + success(res) { + if (res.data.code == 200) { + var TypeList = res.data.data + var typeArr = []; + for (var i = 0; i < TypeList.length; i++) { + var type = { + text: TypeList[i].productName, + value: TypeList[i].productName + }; + typeArr.push(type); + } + _this.setData({ + devtypeList: typeArr + }) } - _this.setData({ - devtypeList: typeArr - }) } - }).catch(err => { - console.error(err); }) - //获取人员下拉列表 - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" + //获取人员下拉列表 + wx.request({ + method: "POST", + data:{ + tips:'repair' }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); + url: app.globalData.httpsUrl + "deviceType/getUser", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var users = res.data.data + var personArr = []; + for (var i = 0; i < users.length; i++) { + var person = { + text: users[i].name, + value: users[i].name + }; + personArr.push(person); + } + _this.setData({ + personoption: personArr + }) } - _this.setData({ - personoption: personArr - }) } - }).catch(err => { - console.error(err); }) }, @@ -202,13 +224,13 @@ }, scan() { - var _this=this; + var _this = this; wx.scanCode({ success(res) { - var devcode=res.result + var devcode = res.result _this.setData({ - devcode: devcode, - }); + devcode: devcode, + }); } }) }, @@ -221,6 +243,7 @@ [formName]: formValue }) }, + //设置项目 selectprojectValue(event) { var that = this; that.setData({ @@ -228,7 +251,7 @@ }) }, - + //设置设备类型 selectDevType(event) { var that = this; that.setData({ @@ -236,46 +259,24 @@ }) }, + //设置人员 selectpersonValue(event) { var that = this; that.setData({ installPerson: event.detail }) }, - + //查询 query: function (event) { - var data={ + var data = { devcode: this.data.devcode, installtimeFmt: this.data.installtimeFmt, project: this.data.project, devtype: this.data.devtype, - installPerson:this.data.installPerson + installPerson: this.data.installPerson } wx.reLaunch({ url: '../applog/applog?params=' + JSON.stringify(data) }) - // var that = this; - // wx.cloud.callFunction({ - // name: 'devicelog', - // data: { - // devcode: that.data.devcode, - // installtimeFmt: that.data.installtimeFmt, - // project: that.data.project, - // devtype: that.data.devtype, - // }, - // }).then(res => { - // // var resultObj=JSON.parse(res.result); - // var resultObj=res.result; - // if (resultObj.code == 200) { - // wx.reLaunch({ - // url: '../applog/applog?applogList=' + JSON.stringify(resultObj.data.rows) - // }) - // } - // }).catch(err => { - // console.error(err); - // wx.showToast({ - // title: "查询失败", - // }) - // }) }, }) \ No newline at end of file diff --git a/miniprogram/pages/searchLog/searchLog.wxml b/miniprogram/pages/searchLog/searchLog.wxml index dfbc788..daf06bc 100644 --- a/miniprogram/pages/searchLog/searchLog.wxml +++ b/miniprogram/pages/searchLog/searchLog.wxml @@ -21,14 +21,10 @@ - + - - @@ -39,7 +35,12 @@ - - 查询 + + + + + 查询 \ No newline at end of file diff --git a/miniprogram/project.config.json b/miniprogram/project.config.json new file mode 100644 index 0000000..4a797a9 --- /dev/null +++ b/miniprogram/project.config.json @@ -0,0 +1,43 @@ +{ + "appid": "wx79419f886f8c77ef", + "compileType": "miniprogram", + "libVersion": "2.27.3", + "packOptions": { + "ignore": [], + "include": [] + }, + "setting": { + "urlCheck": true, + "coverView": true, + "es6": true, + "postcss": true, + "lazyloadPlaceholderEnable": false, + "preloadBackgroundData": false, + "minified": true, + "autoAudits": false, + "uglifyFileName": false, + "uploadWithSourceMap": true, + "enhance": true, + "showShadowRootInWxmlPanel": true, + "packNpmManually": false, + "packNpmRelationList": [], + "minifyWXSS": true, + "useStaticServer": true, + "showES6CompileOption": false, + "checkInvalidKey": true, + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + }, + "disableUseStrict": false, + "useCompilerPlugins": false, + "minifyWXML": true + }, + "condition": {}, + "editorSetting": { + "tabIndent": "insertSpaces", + "tabSize": 4 + }, + "description": "项目配置文件,详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html" +} \ No newline at end of file diff --git a/miniprogram/project.private.config.json b/miniprogram/project.private.config.json new file mode 100644 index 0000000..7bbb91d --- /dev/null +++ b/miniprogram/project.private.config.json @@ -0,0 +1,56 @@ +{ + "projectname": "miniprogram", + "setting": { + "compileHotReLoad": true, + "urlCheck": true + }, + "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", + "condition": { + "miniprogram": { + "list": [ + { + "name": "", + "pathName": "pages/indexapp/indexapp", + "query": "", + "launchMode": "default", + "scene": null + }, + { + "name": "", + "pathName": "pages/addDevice/addDevice", + "query": "", + "launchMode": "default", + "scene": null + }, + { + "name": "", + "pathName": "pages/addDevicelog/addDeviceLog", + "query": "", + "launchMode": "default", + "scene": null + }, + { + "name": "", + "pathName": "pages/searchLog/searchLog", + "query": "", + "launchMode": "default", + "scene": null + }, + { + "name": "", + "pathName": "pages/applog/applog", + "query": "", + "launchMode": "default", + "scene": null + }, + { + "name": "", + "pathName": "pages/login/login", + "query": "", + "launchMode": "default", + "scene": null + } + ] + } + } +} \ No newline at end of file diff --git a/cloudfunctions/project.config.json b/cloudfunctions/project.config.json new file mode 100644 index 0000000..2b3119a --- /dev/null +++ b/cloudfunctions/project.config.json @@ -0,0 +1,28 @@ +{ + "appid": "wx2cef527a000f87c9", + "compileType": "miniprogram", + "libVersion": "2.27.3", + "packOptions": { + "ignore": [], + "include": [] + }, + "setting": { + "coverView": true, + "es6": true, + "postcss": true, + "minified": true, + "enhance": true, + "showShadowRootInWxmlPanel": true, + "packNpmRelationList": [], + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + } + }, + "condition": {}, + "editorSetting": { + "tabIndent": "insertSpaces", + "tabSize": 4 + } +} \ No newline at end of file diff --git a/cloudfunctions/project.private.config.json b/cloudfunctions/project.private.config.json new file mode 100644 index 0000000..42ff49d --- /dev/null +++ b/cloudfunctions/project.private.config.json @@ -0,0 +1,7 @@ +{ + "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", + "projectname": "cloudfunctions", + "setting": { + "compileHotReLoad": true + } +} \ No newline at end of file diff --git a/miniprogram/app.js b/miniprogram/app.js index 51d56f3..50a8a54 100644 --- a/miniprogram/app.js +++ b/miniprogram/app.js @@ -18,13 +18,15 @@ // this.globalData = {} }, globalData: { - // url: "http://111.198.10.15:11604/", - httpsUrl: "https://logapi.smartlog.work/", - httpsTestUrl: "https://smartlog.work/prodapi4test/", - url: "http://139.198.18.188:8083/", + httpsUrl: "https://logapi.smartlog.work/", + // httpsUrl: "http://139.198.18.188:8083/", // url: "http://127.0.0.1:8083/", - // httpsUrl: "http://127.0.0.1:8083/", + //httpsUrl: "http://127.0.0.1:8083/", openid: null, - indexCount:1 - }, + indexCount:1, + nickName:"", + userName:"", + role:"", + devcode:"" + } }) diff --git a/miniprogram/app.json b/miniprogram/app.json index d23f798..2b6db76 100644 --- a/miniprogram/app.json +++ b/miniprogram/app.json @@ -1,15 +1,17 @@ { "cloud": true, "pages": [ + "pages/login/login", "pages/indexapp/indexapp", "pages/earth/earth", "pages/applog/applog", "pages/addDevice/addDevice", "pages/addDevicelog/addDeviceLog", - "pages/searchLog/searchLog" + "pages/searchLog/searchLog", + "pages/notice/notice" ], "window": { - "backgroundColor": "#F6F6F6", + "backgroundColor": "#E6D480", "backgroundTextStyle": "light", "navigationBarBackgroundColor": "#FFCF00", "navigationBarTitleText": "智慧施工", @@ -46,11 +48,11 @@ "desc": "你的位置信息将用于小程序位置接口的效果展示" } }, + "requiredPrivateInfos": ["getLocation", "chooseLocation"], "networkTimeout": { "request": 30000, "connectSocket": 30000, "uploadFile": 30000, "downloadFile": 30000 - }, - "style": "v2" + } } \ No newline at end of file diff --git a/miniprogram/images/applocat.png b/miniprogram/images/applocat.png new file mode 100644 index 0000000..fe49f54 --- /dev/null +++ b/miniprogram/images/applocat.png Binary files differ diff --git a/miniprogram/images/back.png b/miniprogram/images/back.png new file mode 100644 index 0000000..32ac82d --- /dev/null +++ b/miniprogram/images/back.png Binary files differ diff --git a/miniprogram/images/bottom.png b/miniprogram/images/bottom.png new file mode 100644 index 0000000..d910e98 --- /dev/null +++ b/miniprogram/images/bottom.png Binary files differ diff --git a/miniprogram/images/header.png b/miniprogram/images/header.png new file mode 100644 index 0000000..6ea222e --- /dev/null +++ b/miniprogram/images/header.png Binary files differ diff --git a/miniprogram/images/login.png b/miniprogram/images/login.png index 8b73cc0..6471c46 100644 --- a/miniprogram/images/login.png +++ b/miniprogram/images/login.png Binary files differ diff --git a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss index 5a591fb..c9c35b5 100644 --- a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss +++ b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:100%;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:100%}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file +@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:650rpx;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:600rpx}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file diff --git a/miniprogram/pages/addDevice/addDevice.js b/miniprogram/pages/addDevice/addDevice.js index 2783674..78f00b7 100644 --- a/miniprogram/pages/addDevice/addDevice.js +++ b/miniprogram/pages/addDevice/addDevice.js @@ -1,5 +1,7 @@ // miniprogram/pages/addDevice/addDevice.js // import WxValidate from '../../utils/WxValidate.js' +var QQMapWX = require('../../libs/qqmap-wx-jssdk.js'); +var qqmapsdk; var app = getApp() Page({ @@ -11,32 +13,10 @@ canvasWidth: '', longitude: '', latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], + option1: [], personoption1: [], projectoption: [], + devtypeList:[], show: false, form: { devcode: "", @@ -59,7 +39,10 @@ project: "", area: "", street: "", - wellname: "" + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '', }, fileList: [] }, @@ -117,12 +100,14 @@ var that = this; //初始化表单内容为上次填写值 var cacheForms = wx.getStorageSync('cacheList') - if (cacheForms) { + cacheForms.photopath1='' + cacheForms.photopath2='' + cacheForms.photopath3='' + that.data.fileList=[] that.setData({ form: cacheForms, devcode: cacheForms.devcode, - }) } var form = that.data.form @@ -155,55 +140,89 @@ } }) + +//获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + that.setData({ + option1: welltypeArr + }) + } + } +}) + + //获取人员下拉列表 - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/getUser", + data:{ + tips:'repair' }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data.code == 200) { + var users = res.data.data + var personArr = []; + for (var i = 0; i < users.length; i++) { + var person = { + text: users[i].name, + value: users[i].name + }; + personArr.push(person); + } + that.setData({ + personoption1: personArr + }) } - that.setData({ - personoption1: personArr - }) } - }).catch(err => { - console.error(err); - }) + }) + - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - that.setData({ - projectoption: projectArr - }) + success(res){ + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); + } + that.setData({ + projectoption: projectArr + }) + } } - }).catch(err => { - console.error(err); - }) + }) + var installtime = 'form.installtimeFmt'; var dateNow = this.formatDate(); this.setData({ @@ -211,8 +230,40 @@ installtimeFmt: dateNow, [installtime]: dateNow, }); + + + + /** + * 获取设备类型下拉列表 + */ + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/deviceType", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var TypeList = res.data.data + var typeArr = []; + for (var i = 0; i < TypeList.length; i++) { + var type = { + text: TypeList[i].productName, + value: TypeList[i].productName + }; + typeArr.push(type); + } + that.setData({ + devtypeList: typeArr + }) + } + } + }) }, + + + /** * 生命周期函数--监听页面初次渲染完成 */ @@ -280,29 +331,7 @@ }, - - //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 - drawText: function (ctx, str, leftWidth, initHeight, titleHeight, canvasWidth) { - var lineWidth = 0; - var lastSubStrIndex = 0; //每次开始截取的字符串的索引 - for (let i = 0; i < str.length; i++) { - lineWidth += ctx.measureText(str[i]).width; - if (lineWidth > canvasWidth) { - ctx.fillText(str.substring(lastSubStrIndex, i), leftWidth, initHeight); //绘制截取部分 - initHeight = initHeight + leftWidth * 2; //22为字体的高度 - lineWidth = 0; - lastSubStrIndex = i; - // titleHeight += 40; - } - if (i == str.length - 1) { //绘制剩余部分 - ctx.fillText(str.substring(lastSubStrIndex, i + 1), leftWidth, initHeight); - } - } - // // 标题border-bottom 线距顶部距离 - // titleHeight = titleHeight + 10; - // return titleHeight - }, - + //验证表单 formValidate() { if (this.data.form.devcode == "") { @@ -312,27 +341,20 @@ }) return false } - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } if (this.data.form.wellcode == "") { wx.showToast({ icon: 'none', @@ -348,22 +370,10 @@ }) return false } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null) { + + if (this.data.form.installperson == "") { wx.showToast({ icon: 'none', title: '安装人员不能为空!', @@ -408,56 +418,90 @@ } return true; }, + //提交表单 formSubmit: function (event) { + console.log(this.data.form) + //表单参数验证 if (!this.formValidate()) { return false; } var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDevice', + //验证设备编号长度 + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/getDevTypeLength", data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceAdd/add" + code: encodeURI(this.data.form.devicetype) }, - }).then(res => { - if (res.result.code == 500) { - wx.showToast({ - title: '设备编号已安装!', - }) - } else if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - //用于回显 - wx.setStorageSync('cacheList', that.data.form) - //提交成功后提示用户操作 - if (res.confirm) { - wx.switchTab({ - url: '../earth/earth' - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (""==res.data.data ||res.data.data == that.data.form.devcode.length) { + that.saveDevice() + } else { //编号位数不对提示 + wx.showToast({ + icon: 'none', + title: '设备编号位数不对!', + duration: 1000 + }) + return false + } } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "提交失败", - }) }) }, + + //保存设备基本信息 + saveDevice() { + var that = this; + //设置照片路径 + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopathForm = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopathForm]: fileList[i].url.split("static/")[1] + }) + } + //表单提交 + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 500) { + wx.showToast({ + title: '设备编号已安装!', + }) + } else if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + //用于回显 + wx.setStorageSync('cacheList', that.data.form) + //提交成功后提示用户操作 + if (res.confirm) { + wx.switchTab({ + url: '../earth/earth' + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } + }, + fail(err) { + wx.showToast({ + title: '提交失败!', + }) + } + }) + }, + + //input 输入框设置值 confirm(event) { var that = this; var formValue = event.detail.value; @@ -466,8 +510,30 @@ that.setData({ [fromN]: formValue }) + //若输入是设备编号,自动获取设备类型 + if('devcode'==formName){ + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", + data: { + devcode: formValue, + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + that.setData({ + [formDevicetype]: res.data + }); + } + } + }) + } }, + //扫描设备获取编号和设备类型 scan() { var _this = this; wx.scanCode({ @@ -477,23 +543,28 @@ _this.setData({ [formdevcode]: devcode }); - wx.cloud.callFunction({ - name: 'findModeCode', + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", data: { devcode: devcode, - url: app.globalData.url + "appDeviceAdd/findModeCodeByCode" }, - }).then(res => { - if (res.result) { - var formDevicetype = 'form.devicetype' - _this.setData({ - [formDevicetype]: res.result - }); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + _this.setData({ + [formDevicetype]: res.data + }); + } } }) } }) }, + //粘贴经纬度 paste() { var _this = this; wx.getClipboardData({ @@ -510,9 +581,11 @@ longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), }); + _this.showAddress(_this.data.form.longitude,_this.data.form.latitude,_this) } }) }, + //设置经类型 selectValue(value) { var that = this; @@ -521,6 +594,16 @@ [wellType]: value.detail }) }, + + //设置设备类型 + selectDevType(event) { + var that = this; + var devtype = 'form.devicetype'; + that.setData({ + [devtype]: event.detail + }) + }, + //设置运维人员 selectpersonValue(event) { var that = this; var installPerson = 'form.installperson'; @@ -528,6 +611,7 @@ [installPerson]: event.detail }) }, + //设置项目 selectprojectValue(event) { var that = this; var project = 'form.project'; @@ -535,8 +619,41 @@ [project]: event.detail }) }, + showAddress :function(longitude, latitude, self) { + // 实例化腾讯地图API核心类 + qqmapsdk = new QQMapWX({ + key: 'BGPBZ-C5O3P-ROUDR-LWC4J-63EKH-V5FRX'//此处使用你自己申请的key + }) + // 腾讯地图调用接口 + qqmapsdk.reverseGeocoder({ + location: { + latitude: latitude, + longitude: longitude + }, + success: function (res) { + self.setData({ + 'form.area':res.result.address.slice(0,res.result.address.indexOf('区')+1), + 'form.street':res.result.address.slice(res.result.address.indexOf('区')+1) + }) + }, + fail: function (res) { + console.log(res); + }, + complete: function (res) { + } + }); + }, + //上传照片 afterRead(event) { var _this = this; + if (_this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '请先填写设备编号!\r\n否则水印中无编号', + duration: 2000 + }) + return false + } const { file } = event.detail; @@ -576,78 +693,8 @@ }) } }) - // 压缩图片 - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // //获取图片尺寸 - // wx.getImageInfo({ - // src: convertpath, - // success(res) { - // _this.setData({ - // canvasHeight: res.height, - // canvasWidth: res.width - // }) - // var ctx = wx.createCanvasContext('firstCanvas') - - // //将图片src放到cancas内,宽高为图片大小 - // ctx.drawImage(convertpath, 0, 0, res.width, res.height) - // //将声明的时间放入canvas - // ctx.setFontSize(30 * (res.width / 750)) //注意:设置文字大小必须放在填充文字之前,否则不生效 - // ctx.setFillStyle('blue') - // var text = "编号:" + _this.data.form.devcode + "\n经度:" + _this.data.form.longitude + "\n纬度:" + _this.data.form.latitude - // // _this.drawText(ctx,text,20, 70, 5, res.width) - // _this.drawText(ctx, text, 15 * (res.width / 750), 70 * (res.width / 750), 5, res.width) - - // // ctx.fillText(text, 0, 40) - // // ctx.strokeText(_this.data.form.devcode, 0, 30) - // //生成水印图 - // ctx.draw(false, function () { - // wx.canvasToTempFilePath({ - // canvasId: 'firstCanvas', - // success: (res) => { - // wx.compressImage({ - // src: res.tempFilePath, - // quality: 25, - // success: function (res) { - // //上传照片至服务器 - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: res.tempFilePath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // } - // }) - // //// - // } - // }) - // }) - // } - // }) - // } - // }); }, + //删除照片 deletePhoto(event) { var image_index = event.detail.index var fileList_new = this.data.fileList; diff --git a/miniprogram/pages/addDevice/addDevice.wxml b/miniprogram/pages/addDevice/addDevice.wxml index b0977e2..f12c254 100644 --- a/miniprogram/pages/addDevice/addDevice.wxml +++ b/miniprogram/pages/addDevice/addDevice.wxml @@ -5,18 +5,30 @@ - + + + + + + + + + + + + + - - + + - - - + + + @@ -29,13 +41,13 @@ - + - + - + - + @@ -54,8 +66,7 @@ - - + @@ -68,8 +79,8 @@ - - + + - 保存 + 保存 \ No newline at end of file diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.js b/miniprogram/pages/addDevicelog/addDeviceLog.js index cdec71b..a0dc6da 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.js +++ b/miniprogram/pages/addDevicelog/addDeviceLog.js @@ -3,681 +3,665 @@ var app = getApp(); Page({ - /** - * 页面的初始数据 - */ - data: { - pageName: '', - showMask: false, - today: new Date().getTime(), - longitude: '', - latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], - personoption1: [], - projectoption: [], - devcode: "", - deviceMode: "", - installtimeFmt: '', - show: false, - form: { - devcode: "", - wellcode: "", - welltype: "", - welldepth: "", - installheigt: "", - installperson: "", - installtimeFmt: "", - photopath: "", - factory: "", - workmsg: "", - position: "", - description: "", - longitude: "", - latitude: "", - longitude84: "", - latitude84: "", - devicetype: "", - project: "", - area: "", - street: "", - wellname: "" - }, - fileList: [], - detail: "" - }, + /** + * 页面的初始数据 + */ + data: { + pageName: '', + showMask: false, + today: new Date().getTime(), + longitude: '', + latitude: '', + option1: [], + personoption1: [], + projectoption: [], + devcode: "", + deviceMode: "", + installtimeFmt: '', + show: false, + form: { + devcode: "", + wellcode: "", + welltype: "", + welldepth: "", + installheigt: "", + installperson: "", + installtimeFmt: "", + photopath: "", + factory: "", + workmsg: "", + position: "", + description: "", + longitude: "", + latitude: "", + longitude84: "", + latitude84: "", + devicetype: "", + project: "", + area: "", + street: "", + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '' + }, + fileList: [], + detail: "", + markers: [{ + id: 100, + // iconPath: "../../images/point.png", + latitude: '', + longitude: '', + // label:'1', + width: 25, + height: 35 + }], + }, - onDisplay() { - this.setData({ - show: true - }); - }, - onClose() { - this.setData({ - show: false - }); - }, - formatDate() { - var date = new Date(); - // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; - var seperator1 = "-"; - var month = date.getMonth() + 1; - var strDate = date.getDate(); - var hour = date.getHours() - var minute = date.getMinutes() - var second = date.getSeconds() - month = month > 9 ? month : "0" + month; - strDate = strDate > 9 ? strDate : "0" + strDate; - hour = hour > 9 ? hour : "0" + hour; - minute = minute > 9 ? minute : "0" + minute; - second = second > 9 ? second : "0" + second; - var currentdate = - date.getFullYear() + - seperator1 + - month + - seperator1 + - strDate + - " " + - hour + ":" + - minute + ":" + - second; - return currentdate; + onDisplay() { + this.setData({ + show: true + }); + }, + onClose() { + this.setData({ + show: false + }); + }, + formatDate() { + var date = new Date(); + // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; + var seperator1 = "-"; + var month = date.getMonth() + 1; + var strDate = date.getDate(); + var hour = date.getHours() + var minute = date.getMinutes() + var second = date.getSeconds() + month = month > 9 ? month : "0" + month; + strDate = strDate > 9 ? strDate : "0" + strDate; + hour = hour > 9 ? hour : "0" + hour; + minute = minute > 9 ? minute : "0" + minute; + second = second > 9 ? second : "0" + second; + var currentdate = + date.getFullYear() + + seperator1 + + month + + seperator1 + + strDate + + " " + + hour + ":" + + minute + ":" + + second; + return currentdate; - }, - onConfirm(event) { - var installtime = 'form.installtimeFmt'; - this.setData({ - show: false, - installtimeFmt: this.formatDate(event.detail), - [installtime]: this.formatDate(event.detail), - }); - }, + }, + onConfirm(event) { + var installtime = 'form.installtimeFmt'; + this.setData({ + show: false, + installtimeFmt: this.formatDate(event.detail), + [installtime]: this.formatDate(event.detail), + }); + }, - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - var _this = this; - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" - }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); - } - _this.setData({ - personoption1: personArr - }) + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + var _this = this; + _this.setData({ + 'markers[0].latitude': Number(wx.getStorageSync('resultObject').latitude) , + 'markers[0].longitude': Number(wx.getStorageSync('resultObject').longitude), + // 'markers[0].label':'10', + 'markers[0].width': 18, + 'markers[0].id':1, + 'markers[0].height': 30, + latitude:Number(wx.getStorageSync('resultObject').latitude), + longitude:Number(wx.getStorageSync('resultObject').longitude) + }) + //获取人员下拉列表 + // wx.request({ + // method: "POST", + // url: app.globalData.httpsUrl + "deviceType/getUser", + // data:{ + // tips:'repair' + // }, + // header: { + // 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + // }, + // success(res) { + // if (res.data.code == 200) { + // var users = res.data.data + // var personArr = []; + // for (var i = 0; i < users.length; i++) { + // var person = { + // text: users[i].name, + // value: users[i].name + // }; + // personArr.push(person); + // } + // _this.setData({ + // personoption1: personArr + // }) + // } + // } + // }) + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); } - }).catch(err => { - console.error(err); - }) - - - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" - }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - _this.setData({ - projectoption: projectArr - }) - } - }).catch(err => { - console.error(err); - }) - - if (options.pageName) { - this.setData({ - pageName: options.pageName - }) - } - - if (options.detail) { - - var formObject = JSON.parse(options.detail); _this.setData({ - form: formObject, - detail: options.detail + projectoption: projectArr }) - - _this.setData({ - ['form.installperson']: "", - ['form.installtimeFmt']: "", - ['form.workmsg']: "", - ['form.description']: "" - }) - - const { - fileList = [] - } = _this.data; - if (formObject.photopath1 != "") { - var file1 = { - url: app.globalData.url + "static/" + formObject.photopath1 - } - fileList.push(file1) - } - if (formObject.photopath2 != "") { - var file2 = { - url: app.globalData.url + "static/" + formObject.photopath2 - } - fileList.push(file2) - } - if (formObject.photopath3 != "") { - var file3 = { - url: app.globalData.url + "static/" + formObject.photopath3 - } - fileList.push(file3) - } - - _this.setData({ - fileList - }); } - var installtime = 'form.installtimeFmt'; - var dateNow = this.formatDate(); - this.setData({ - installtimeFmt: dateNow, - [installtime]: dateNow, - }); - }, + } + }) - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { + //获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + _this.setData({ + option1: welltypeArr + }) + } + } +}) - }, + //跳转时带入参数返回哪页 + if (options.pageName) { + this.setData({ + pageName: options.pageName + }) + } + //跳转时带入参数设备的安装信息 + if (wx.getStorageSync('resultObject')) { + var formObject = wx.getStorageSync('resultObject') + _this.setData({ + form: formObject, + detail: formObject + }) - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { + _this.setData({ + ['form.installperson']: app.globalData.userName, + ['form.installtimeFmt']: "", + ['form.workmsg']: "", + ['form.description']: "" + }) - }, + const { + fileList = [] + } = _this.data; + if (formObject.photopath1 != "") { + var file1 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath1 + } + fileList.push(file1) + } + if (formObject.photopath2 != "") { + var file2 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath2 + } + fileList.push(file2) + } + if (formObject.photopath3 != "") { + var file3 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath3 + } + fileList.push(file3) + } + _this.setData({ + fileList + }); + } + var installtime = 'form.installtimeFmt'; + var dateNow = this.formatDate(); + this.setData({ + installtimeFmt: dateNow, + [installtime]: dateNow, + }); + }, - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, - }, + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + wx.removeStorageSync('resultObject') + }, - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, - }, + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { + }, - }, + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { + }, - }, + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { + }, - }, + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + }, - /** - * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true - **/ + /** + * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true + **/ - isNumber: function (val) { + isNumber: function (val) { - var regPos = /^[0-9]*$/; //非负浮点数 - var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数 - if (regPos.test(val) || regNeg.test(val)) { - return false; - } else { - return true; - } + var regPos = /^[0-9]*$/; //非负浮点数 + var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数 + if (regPos.test(val) || regNeg.test(val)) { + return false; + } else { + return true; + } - }, + }, - formValidate() { + formValidate() { - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } - if (this.data.form.wellcode == "") { - wx.showToast({ - icon: 'none', - title: '井编号不能为空!', - }) - return false - } - if (this.data.form.devicetype == "") { - wx.showToast({ - icon: 'none', - title: '设备类型不能为空!', - }) - return false - } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + if (this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '设备编号不能为空!', + }) + return false + } + if (this.data.form.wellcode == "") { + wx.showToast({ + icon: 'none', + title: '井编号不能为空!', + }) + return false + } + if (this.data.form.devicetype == "") { + wx.showToast({ + icon: 'none', + title: '设备类型不能为空!', + }) + return false + } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null || - this.data.form.installperson == '') { - wx.showToast({ - icon: 'none', - title: '运维人员不能为空!', - }) - return false - } - if (this.data.form.project == "") { - wx.showToast({ - icon: 'none', - title: '所属项目不能为空!', - }) - return false - } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } + if (this.data.form.installperson == null || + this.data.form.installperson == '') { + wx.showToast({ + icon: 'none', + title: '运维人员不能为空!', + }) + return false + } + if (this.data.form.project == "") { + wx.showToast({ + icon: 'none', + title: '所属项目不能为空!', + }) + return false + } - if (this.data.form.welldepth != null) { - if (this.isNumber(this.data.form.welldepth)) { - wx.showToast({ - icon: 'none', - title: '井深必须为数值!', - }) - return false - } - } - if (this.data.form.installheigt != null) { - if (this.isNumber(this.data.form.installheigt)) { - wx.showToast({ - icon: 'none', - title: '到井口距离必须为数值!', - }) - return false - } - } - - return true; - }, - - changeMsg: function () { - var formNew = this.data.form; - var formOld = JSON.parse(this.data.detail); - var descpNew = ""; - if (formNew.devcode != formOld.devcode) { - descpNew += "修改设备编号,原编号:" + formOld.devcode + ",新编号:" + formNew.devcode + ";" - } - if (formNew.devicetype != formOld.devicetype) { - descpNew += "修改设备类型,原设备类型:" + formOld.devicetype + ",新设备类型:" + formNew.devicetype + ";" - } - if (formNew.area != formOld.area) { - descpNew += "修改区,原区:" + formOld.area + ",新区:" + formNew.area + ";" - } - if (formNew.street != formOld.street) { - descpNew += "修改街道,原街道:" + formOld.street + ",新街道:" + formNew.street + ";" - } - if (formNew.wellname != formOld.wellname) { - descpNew += "修改井名称,原井名称:" + formOld.wellname + ",新井名称:" + formNew.wellname + ";" - } - if (formNew.factory != formOld.factory) { - descpNew += "修改权属单位,原权属单位:" + formOld.factory + ",新权属单位:" + formNew.factory + ";" - } - if (formNew.installheigt != formOld.installheigt) { - descpNew += "修改井口距离,原井口距离:" + formOld.installheigt + ",新井口距离:" + formNew.installheigt + ";" - } - if (formNew.installperson != formOld.installperson) { - descpNew += "修改运维人员,原运维人员:" + formOld.installperson + ",新运维人员:" + formNew.installperson + ";" - } - if (formNew.latitude != formOld.latitude) { - descpNew += "修改纬度,原纬度:" + formOld.latitude + ",新纬度:" + formNew.latitude + ";" - } - if (formNew.longitude != formOld.longitude) { - descpNew += "修改经度,原经度:" + formOld.longitude + ",新经度:" + formNew.longitude + ";" - } - if (formNew.position != formOld.position) { - descpNew += "修改位置描述,原位置:" + formOld.position + ",新位置:" + formNew.position + ";" - } - if (formNew.wellcode != formOld.wellcode) { - descpNew += "修改井编号,原编号:" + formOld.wellcode + ",新编号:" + formNew.wellcode + ";" - } - if (formNew.welldepth != formOld.welldepth) { - descpNew += "修改井深,原井深:" + formOld.welldepth + ",新井深:" + formNew.welldepth + ";" - } - if (formNew.welltype != formOld.welltype) { - descpNew += "修改井类型,原井类型:" + formOld.welltype + ",新井类型:" + formNew.welltype + ";" - } - if (formNew.project != formOld.project) { - descpNew += "修改所属项目,原项目:" + formOld.project + ",新项目:" + formNew.project + ";" - } - if (this.data.photopath1 != formOld.photopath1 || - this.data.photopath2 != formOld.photopath2 || - this.data.photopath3 != formOld.photopath3) { - descpNew += "修改照片;" - } - if ("" != formNew.description) { - descpNew += formNew.description; - } - this.setData({ - ['form.description']: descpNew + if (this.data.form.welldepth != null) { + if (this.isNumber(this.data.form.welldepth)) { + wx.showToast({ + icon: 'none', + title: '井深必须为数值!', }) - }, + return false + } + } + if (this.data.form.installheigt != null) { + if (this.isNumber(this.data.form.installheigt)) { + wx.showToast({ + icon: 'none', + title: '到井口距离必须为数值!', + }) + return false + } + } - formSubmit: function (event) { + return true; + }, - if (!this.formValidate()) { - return false; - } - this.changeMsg(); - var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDeviceLog', - data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceLog/add" - }, - }).then(res => { - // var resultObj=JSON.parse(res.result); - if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - if (res.confirm) { - wx.switchTab({ - url: that.data.pageName - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) - } - }).catch(err => { - console.error(err) - wx.showToast({ - title: "提交失败", - }) - }) - }, - confirm(event) { - var that = this; - var formValue = event.detail.value; - var formName = event.target.dataset.id; - var fromN = 'form.' + [formName]; - that.setData({ - [fromN]: formValue - }) - }, + //获取与上次修改的信息 + changeMsg: function () { + var formNew = this.data.form; + console.log(this.data.detail) + var formOld = JSON.parse(this.data.detail); + var descpNew = ""; + if (formNew.devcode != formOld.devcode) { + descpNew += "修改设备编号,原值:" + formOld.devcode + ",新值:" + formNew.devcode + ";" + } + if (formNew.devicetype != formOld.devicetype) { + descpNew += "修改设备类型,原值:" + formOld.devicetype + ",新值:" + formNew.devicetype + ";" + } + if (formNew.area != formOld.area) { + descpNew += "修改区,原值:" + formOld.area + ",新值:" + formNew.area + ";" + } + if (formNew.street != formOld.street) { + descpNew += "修改街道,原值:" + formOld.street + ",新值:" + formNew.street + ";" + } + if (formNew.wellname != formOld.wellname) { + descpNew += "修改井名称,原值:" + formOld.wellname + ",新值:" + formNew.wellname + ";" + } + if (formNew.factory != formOld.factory) { + descpNew += "修改权属单位,原值:" + formOld.factory + ",新值:" + formNew.factory + ";" + } + if (formNew.installheigt != formOld.installheigt) { + descpNew += "修改井口距离,原值:" + formOld.installheigt + ",新值:" + formNew.installheigt + ";" + } + if (formNew.installperson != formOld.installperson) { + descpNew += "修改运维人员,原值:" + formOld.installperson + ",新值:" + formNew.installperson + ";" + } + if (formNew.latitude != formOld.latitude) { + descpNew += "修改纬度,原值:" + formOld.latitude + ",新值:" + formNew.latitude + ";" + } + if (formNew.longitude != formOld.longitude) { + descpNew += "修改经度,原值:" + formOld.longitude + ",新值:" + formNew.longitude + ";" + } + if (formNew.position != formOld.position) { + descpNew += "修改位置描述,原值:" + formOld.position + ",新值:" + formNew.position + ";" + } + if (formNew.wellcode != formOld.wellcode) { + descpNew += "修改井编号,原值:" + formOld.wellcode + ",新值:" + formNew.wellcode + ";" + } + if (formNew.welldepth != formOld.welldepth) { + descpNew += "修改井深,原值:" + formOld.welldepth + ",新值:" + formNew.welldepth + ";" + } + if (formNew.welltype != formOld.welltype) { + descpNew += "修改井类型,原值:" + formOld.welltype + ",新值:" + formNew.welltype + ";" + } + if (formNew.project != formOld.project) { + descpNew += "修改所属项目,原值:" + formOld.project + ",新值:" + formNew.project + ";" + } + if (this.data.form.photopath1 != formOld.photopath1 || + this.data.form.photopath2 != formOld.photopath2 || + this.data.form.photopath3 != formOld.photopath3) { + descpNew += "修改照片;" + } + if ("" != formNew.description) { + descpNew += formNew.description; + } + this.setData({ + ['form.description']: descpNew + }) + }, - scan() { + //提交表单 + formSubmit: function (event) { - wx.scanCode({ - success(res) { - console.log(res) - } - }) + //表单验证 + if (!this.formValidate()) { + return false; + } + //自动生成修改内容 + this.changeMsg(); + //提交权限限制(只有施工人员能修改) + if(app.globalData.role!='repair'){ + wx.showToast({ + icon: 'none', + title: '无权限修改', + duration:2000 + }) + return false + } + var that = this; + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopath = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopath]: fileList[i].url.split("static/")[1] + }) + } + delete that.data.form.installtime + delete that.data.form.createtime + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - paste() { - var _this = this; - wx.getClipboardData({ - success: function (res) { - var longitude = 'form.longitude'; - var latitude = 'form.latitude'; - var longitude84 = 'form.longitude84'; - var latitude84 = 'form.latitude84'; - _this.setData({ - [longitude]: parseFloat(res.data.split(",", 4)[1]).toFixed(6), - [latitude]: parseFloat(res.data.split(",", 4)[0]).toFixed(6), - [longitude84]: "" == (res.data.split(",", 4)[3]) ? "" : parseFloat(res.data.split(",", 4)[3]).toFixed(6), - [latitude84]: "" == (res.data.split(",", 4)[2]) ? "" : parseFloat(res.data.split(",", 4)[2]).toFixed(6), - longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), - latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), - }); - } - }) - }, - selectValue(value) { - var that = this; - var wellType = 'form.welltype'; - that.setData({ - [wellType]: value.detail - }) - }, - selectpersonValue(event) { - var that = this; - var installPerson = 'form.installperson'; - that.setData({ - [installPerson]: event.detail - }) - }, - selectprojectValue(event) { - var that = this; - var project = 'form.project'; - that.setData({ - [project]: event.detail, - showMask: true - }) - }, - open() { - this.setData({ - showMask: true - }) - }, - close() { - this.setData({ - showMask: false - }) - }, - afterRead(event) { - var _this = this; - const { - file - } = event.detail; - const { - fileList = [] - } = _this.data; - var convertpath = ""; - wx.compressImage({ - src: event.detail.file.path, - quality: 25, - success: function (res) { - convertpath = res.tempFilePath; - wx.uploadFile({ - url: app.globalData.httpsUrl + "appDeviceAdd/fileUploadMarker", - filePath:convertpath, - name: 'file', - formData: { - 'text': "编号:" + _this.data.form.devcode + "经度:" + _this.data.form.longitude + "纬度:" + _this.data.form.latitude - }, - header: { - "Content-Type": "multipart/form-data", - 'accept': 'application/json', - }, - success(res) { - if (res.data) { - var url = JSON.parse(res.data); - fileList.push({ - ...file, - url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - }); - _this.setData({ - fileList - }); - } - } + success(res) { + if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + if (res.confirm) { + wx.switchTab({ + url: that.data.pageName }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') } - }) - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // // var base64 = "data:image/png;base64," + wx.getFileSystemManager().readFileSync(convertpath, 'base64'); - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: convertpath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // // wx.cloud.callFunction({ - // // name: 'uploadFile', - // // data: { - // // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // // fileBase64: base64 - // // }, - // // success: function (res) { - // // if (res.result) { - // // fileList.push({ - // // ...file, - // // url: app.globalData.url + "static/" + res.result.data.replace(/\\/g, "/") - // // }); - // // _this.setData({ - // // fileList - // // }); - // // } - // // }, - // // complete: res => { - // // }, - // // }) - // } - // }); + } + }) + } + }, + fail(err) { + wx.showToast({ + title: "提交失败", + }) + } + }) + }, + //报存录入的input信息 + confirm(event) { + var that = this; + var formValue = event.detail.value; + var formName = event.target.dataset.id; + var fromN = 'form.' + [formName]; + that.setData({ + [fromN]: formValue + }) + }, + + //扫码 + scan() { + + wx.scanCode({ + success(res) { + console.log(res) + } + }) + }, + //粘贴经纬度 + paste() { + var _this = this; + wx.getClipboardData({ + success: function (res) { + var longitude = 'form.longitude'; + var latitude = 'form.latitude'; + var longitude84 = 'form.longitude84'; + var latitude84 = 'form.latitude84'; + _this.setData({ + [longitude]: parseFloat(res.data.split(",", 4)[1]).toFixed(6), + [latitude]: parseFloat(res.data.split(",", 4)[0]).toFixed(6), + [longitude84]: "" == (res.data.split(",", 4)[3]) ? "" : parseFloat(res.data.split(",", 4)[3]).toFixed(6), + [latitude84]: "" == (res.data.split(",", 4)[2]) ? "" : parseFloat(res.data.split(",", 4)[2]).toFixed(6), + longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), + latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), + }); + } + }) + }, + selectValue(value) { + var that = this; + var wellType = 'form.welltype'; + that.setData({ + [wellType]: value.detail + }) + }, + //运维人员默认为登录人 + // selectpersonValue(event) { + // var that = this; + // var installPerson = 'form.installperson'; + // that.setData({ + // [installPerson]: event.detail + // }) + // }, + selectprojectValue(event) { + var that = this; + var project = 'form.project'; + that.setData({ + [project]: event.detail, + showMask: true + }) + }, + + open() { + this.setData({ + showMask: true + }) + }, + //隐藏textarea,防止遮挡 + close() { + this.setData({ + showMask: false + }) + }, + //上传照片 + afterRead(event) { + var _this = this; + const { + file + } = event.detail; + const { + fileList = [] + } = _this.data; + var convertpath = ""; + wx.compressImage({ + src: event.detail.file.path, + quality: 25, + success: function (res) { + convertpath = res.tempFilePath; + wx.uploadFile({ + url: app.globalData.httpsUrl + "appDeviceAdd/fileUploadMarker", + filePath: convertpath, + name: 'file', + formData: { + 'text': "编号:" + _this.data.form.devcode + "经度:" + _this.data.form.longitude + "纬度:" + _this.data.form.latitude }, - deletePhoto(event) { - var that = this - var image_index = event.detail.index - var fileList_new = that.data.fileList; - wx.showModal({ - content: '确定删除照片?', - success: function (res) { - if (res.confirm) { - fileList_new.splice(image_index, 1); - that.setData({ - fileList: fileList_new - }) - wx.cloud.callFunction({ - name: 'deletePhoto', - data: { - url: app.globalData.url + "appDeviceLog/deletePhoto", - devcode: that.data.form.devcode, - pathIndex: image_index - }, - success: function (res) {}, - complete: res => {}, - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + "Content-Type": "multipart/form-data", + 'accept': 'application/json', }, - }) \ No newline at end of file + success(res) { + if (res.data) { + var url = JSON.parse(res.data); + fileList.push({ + ...file, + url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") + }); + _this.setData({ + fileList + }); + } + } + }) + } + }) + }, + //删除照片 + deletePhoto(event) { + var that = this + var image_index = event.detail.index + var fileList_new = that.data.fileList; + wx.showModal({ + content: '确定删除照片?', + success: function (res) { + if (res.confirm) { + fileList_new.splice(image_index, 1); + that.setData({ + fileList: fileList_new + }) + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deletePhoto", + data: { + devcode: that.data.form.devcode + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) {} + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } +}) \ No newline at end of file diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.wxml b/miniprogram/pages/addDevicelog/addDeviceLog.wxml index 38620d4..b10cc7d 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.wxml +++ b/miniprogram/pages/addDevicelog/addDeviceLog.wxml @@ -1,15 +1,21 @@ - + + + + + - + - - + + - - + + - + @@ -39,24 +45,25 @@ - - - + + + - + - + + @@ -64,7 +71,7 @@ - + @@ -79,9 +86,9 @@ - + - 保存 + 保存 diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.wxss b/miniprogram/pages/addDevicelog/addDeviceLog.wxss index ee0b75c..08d5fd7 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.wxss +++ b/miniprogram/pages/addDevicelog/addDeviceLog.wxss @@ -24,6 +24,17 @@ display: flex; align-items: center; } +.map-view{ + width: 750rpx; + height: 485rpx; + position: fixed; + top: 0px; + left: 0px; + z-index: 999; +} +.content{ + margin-top: 495rpx; +} .left { width: 210rpx; diff --git a/miniprogram/pages/addFunction/addFunction.js b/miniprogram/pages/addFunction/addFunction.js deleted file mode 100644 index 4966be3..0000000 --- a/miniprogram/pages/addFunction/addFunction.js +++ /dev/null @@ -1,60 +0,0 @@ -// pages/addFunction/addFunction.js - -const code = `// 云函数入口函数 -exports.main = (event, context) => { - console.log(event) - console.log(context) - return { - sum: event.a + event.b - } -}` - -Page({ - - data: { - result: '', - canIUseClipboard: wx.canIUse('setClipboardData'), - }, - - onLoad: function (options) { - - }, - - copyCode: function() { - wx.setClipboardData({ - data: code, - success: function () { - wx.showToast({ - title: '复制成功', - }) - } - }) - }, - - testFunction() { - wx.cloud.callFunction({ - name: 'sum', - data: { - a: 1, - b: 2 - }, - success: res => { - wx.showToast({ - title: '调用成功', - }) - this.setData({ - result: JSON.stringify(res.result) - }) - }, - fail: err => { - wx.showToast({ - icon: 'none', - title: '调用失败', - }) - console.error('[云函数] [sum] 调用失败:', err) - } - }) - }, - -}) - diff --git a/miniprogram/pages/addFunction/addFunction.json b/miniprogram/pages/addFunction/addFunction.json deleted file mode 100644 index a9a50c5..0000000 --- a/miniprogram/pages/addFunction/addFunction.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "navigationBarTitleText": "云函数指引", - "usingComponents": {} -} \ No newline at end of file diff --git a/miniprogram/pages/addFunction/addFunction.wxml b/miniprogram/pages/addFunction/addFunction.wxml deleted file mode 100644 index 3a10626..0000000 --- a/miniprogram/pages/addFunction/addFunction.wxml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - 测试云函数 - - - 期望输出:{"sum":3} - - - 调用结果:{{result}} - - - - - 新增云函数 - 1. 在云函数根目录 cloudfunctions 上右键选择新建云函数,命名为 sum - 2. 在创建的 cloudfunctions/sum/index.js 文件中添加如下代码 - - - 3. 在 cloudfunctions/sum 目录上右键上传并部署 - 4. 点击测试云函数测试 - 5. 打开云开发云函数管理页,选择 sum 云函数 - 6. 查看 sum 的调用日志 - 进阶:可在云函数中使用 wx-server-sdk 操作数据库,文件存储和调用其他云函数,详见文档 - - - diff --git a/miniprogram/pages/addFunction/addFunction.wxss b/miniprogram/pages/addFunction/addFunction.wxss deleted file mode 100644 index 7ac8619..0000000 --- a/miniprogram/pages/addFunction/addFunction.wxss +++ /dev/null @@ -1,3 +0,0 @@ -/* pages/addFunction/addFunction.wxss */ - -@import "../../style/guide.wxss"; \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.js b/miniprogram/pages/applog/applog.js index 0e8c185..189e61f 100644 --- a/miniprogram/pages/applog/applog.js +++ b/miniprogram/pages/applog/applog.js @@ -13,98 +13,25 @@ isSeach: "false", params: {}, total: 0, - show: false + show: false, + delBtnWidth: 100, //删除按钮宽度单位(rpx) + activeIndex: -1, + list_style: '' }, - - touchE: function (e) { - // console.log(e); - var that = this - if (e.changedTouches.length == 1) { - //手指移动结束后触摸点位置的X坐标 - var endX = e.changedTouches[0].clientX; - //触摸开始与结束,手指移动的距离 - var disX = that.data.startX - endX; - var delBtnWidth = that.data.delBtnWidth; - //如果距离小于删除按钮的1/2,不显示删除按钮 - var txtStyle = disX > delBtnWidth / 2 ? "left:-" + delBtnWidth + "rpx" : "left:0rpx"; - - //获取手指触摸的是哪一项 - var index = e.currentTarget.dataset.index; - var list = that.data.deviceloglist; - list[index].txtStyle = txtStyle; - //更新列表的状态 - that.setData({ - deviceloglist: list - }); - } - }, - //手指触摸动作开始 记录起点X坐标 - touchstart: function (e) { - //开始触摸时 重置所有删除 - this.data.deviceloglist.forEach(function (v, i) { - if (v.isTouchMove) //只操作为true的 - v.isTouchMove = false; - }) - this.setData({ - startX: e.changedTouches[0].clientX, - startY: e.changedTouches[0].clientY, - deviceloglist: this.data.deviceloglist - }) - }, - //滑动事件处理 - touchmove: function (e) { - var that = this, - index = e.currentTarget.dataset.index, //当前索引 - startX = that.data.startX, //开始X坐标 - startY = that.data.startY, //开始Y坐标 - touchMoveX = e.changedTouches[0].clientX, //滑动变化坐标 - touchMoveY = e.changedTouches[0].clientY, //滑动变化坐标 - //获取滑动角度 - angle = that.angle({ - X: startX, - Y: startY - }, { - X: touchMoveX, - Y: touchMoveY - }); - that.data.deviceloglist.forEach(function (v, i) { - v.isTouchMove = false - //滑动超过30度角 return - if (Math.abs(angle) > 30) return; - if (i == index) { - if (touchMoveX > startX) //右滑 - v.isTouchMove = false - else //左滑 - v.isTouchMove = true - } - }) - //更新数据 - that.setData({ - deviceloglist: that.data.deviceloglist - }) - }, - /** - * 计算滑动角度 - * @param {Object} start 起点坐标 - * @param {Object} end 终点坐标 - */ - angle: function (start, end) { - var _X = end.X - start.X, - _Y = end.Y - start.Y - //返回角度 /Math.atan()返回数字的反正切值 - return 360 * Math.atan(_Y / _X) / (2 * Math.PI); - }, - /** - * 生命周期函数--监听页面加载var_this=this; - */ onLoad: function (options) { - if (options.params) { this.setData({ params: JSON.parse(options.params), isSeach: "true" }) this.initPages() + }else{ + this.setData({ + show: false + }) + //清空参数,重新加载 + this.clearParams(); + this.initPages(); } }, @@ -116,20 +43,33 @@ }, + //点击tabBar事件 + onTabItemTap(item) { + //隐藏历史显示总记录条数 + this.setData({ + show: false + }) + //清空参数,重新加载 + this.clearParams(); + this.initPages(); + }, + + /** * 生命周期函数--监听页面显示 */ onShow: function (options) { - this.setData({ - show:false - }) - if (this.data.isSeach == "false") { - this.clearParams(); - this.initPages(); - } - this.setData({ - isSeach: "false" - }) + + // this.setData({ + // show: false + // }) + // if (this.data.isSeach == "false") { + // this.clearParams(); + // this.initPages(); + // } + // this.setData({ + // isSeach: "false" + // }) }, /** @@ -167,6 +107,119 @@ }, + + //手指触摸动作开始 记录起点X坐标 + touchstart: function (e) { + //开始触摸时 重置所有删除 + this.data.deviceloglist.forEach(function (v, i) { + if (v.isTouchMove) //只操作为true的 + v.isTouchMove = false; + }) + this.setData({ + startX: e.changedTouches[0].clientX, + startY: e.changedTouches[0].clientY, + deviceloglist: this.data.deviceloglist + }) + }, + + //滑动事件处理 + touchmove: function (e) { + var that = this, + index = e.currentTarget.dataset.index, //当前索引 + startX = that.data.startX, //开始X坐标 + startY = that.data.startY, //开始Y坐标 + touchMoveX = e.changedTouches[0].clientX, //滑动变化坐标 + touchMoveY = e.changedTouches[0].clientY, //滑动变化坐标 + //获取滑动角度 + angle = that.angle({ + X: startX, + Y: startY + }, { + X: touchMoveX, + Y: touchMoveY + }); + that.data.deviceloglist.forEach(function (v, i) { + // v.isTouchMove = false + //滑动超过30度角 return + if (Math.abs(angle) > 30) return; + if (i == index) { + if (touchMoveX > startX) //右滑 + v.isTouchMove = false + else //左滑 + v.isTouchMove = true + } + }) + //更新数据 + that.setData({ + deviceloglist: that.data.deviceloglist + }) + }, + + /** + * 计算滑动角度 + * @param {Object} start 起点坐标 + * @param {Object} end 终点坐标 + */ + angle: function (start, end) { + var _X = end.X - start.X, + _Y = end.Y - start.Y + //返回角度 /Math.atan()返回数字的反正切值 + return 360 * Math.atan(_Y / _X) / (2 * Math.PI); + }, + + //删除事件 + delItem: function (e) { + if(app.globalData.role!='repair'){ + wx.showToast({ + icon: 'none', + title: '无权限删除', + duration:2000 + }) + return false + } + var that = this + wx.showModal({ + content: '是否删除?', + success: function (res) { + if (res.confirm) { + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/delete", + data: { + appDeviceAddId: e.currentTarget.dataset.devid + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if(res.data.code=='200'){ + that.data.deviceloglist.splice(e.currentTarget.dataset.index, 1) + that.setData({ + deviceloglist: that.data.deviceloglist, + total: that.data.deviceloglist.length + }) + wx.showToast({ + title: '删除成功!', + icon: 'none', + duration: 1000 + }) + } + }, + fail(err) { + wx.showToast({ + title: '删除失败!', + icon: 'none', + duration: 2000 + }) + } + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + }, + showLoading: function (message) { if (wx.showLoading) { // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 @@ -199,95 +252,105 @@ deviceloglist: [] }) }, + //查询列表数据 initPages: function () { var that = this + that.setData({ + show: false + }) var offsetValue = that.data.deviceloglist.length % 15 > 0 ? parseInt(that.data.deviceloglist.length / 15) + 2 : parseInt(that.data.deviceloglist.length / 15) + 1 - wx.cloud.callFunction({ - name: 'devicelog', + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/listPage", data: { devcode: that.data.params.devcode, devtype: that.data.params.devtype, installtimeFmt: that.data.params.installtimeFmt, project: that.data.params.project, installPerson: that.data.params.installPerson, - url: app.globalData.url + "appDeviceLog/listPage", limit: 15, offset: offsetValue }, - }).then(res => { - if (res.result.data.rows.length > 0) { - var resultJson = res.result - that.setData({ - deviceloglist: that.data.deviceloglist.concat(resultJson.data.rows) - }) - } else if (that.data.deviceloglist.length > 0) { - that.setData({ - show: true, - total: that.data.deviceloglist.length - }) - wx.showToast({ - title: '数据已全部加载完', - icon: 'none', - duration: 2000 - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.data.rows.length > 0) { + var resultJson = res.data + var listArr = resultJson.data.rows + listArr.forEach(function (v, i) { + listArr[i]['isTouchMove'] = false + }) + that.setData({ + deviceloglist: that.data.deviceloglist.concat(listArr) + }) + } else if (that.data.deviceloglist.length > 0) { + that.setData({ + show: true, + total: that.data.deviceloglist.length + }) + wx.showToast({ + title: '数据已全部加载完', + icon: 'none', + duration: 2000 + }) + } + if (offsetValue == 1 && res.data.data.rows.length < 15) { + that.setData({ + show: true, + total: that.data.deviceloglist.length + }) + } } - if(offsetValue==1&&res.result.data.rows.length<15){ - that.setData({ - show: true, - total: that.data.deviceloglist.length - }) - } - // console.log(res); - }).catch(err => { - console.error(err); }) + }, addDetail: function (event) { - this.showLoading("数据请求中..."); - wx.cloud.callFunction({ - name: 'deviceDetail', + var that = this + that.showLoading("数据请求中..."); + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deviceDetail", data: { devcode: event.target.dataset.devcode, - url: app.globalData.url + "appDeviceLog/deviceDetail", }, - }).then(res => { - this.hideLoading(); - var resultObject = JSON.parse(res.result); - var pageName = '../applog/applog' - if (resultObject.code == 200) { - wx.navigateTo({ - url: '../addDevicelog/addDeviceLog?detail=' + - JSON.stringify(resultObject.data) + "&pageName=" + pageName - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + that.hideLoading(); + // var resultObject = JSON.parse(res.data); + var resultObject = res.data; + var pageName = '../applog/applog' + if (resultObject.code == 200) { + wx.setStorageSync('resultObject', resultObject.data) + wx.navigateTo({ + url: '../addDevicelog/addDeviceLog?detail=' + "&pageName=" + pageName + }) + } + }, + fail(err) { + that.hideLoading(); } - }).catch(err => { - this.hideLoading() }) + }, add: function (event) { - wx.reLaunch({ - url: '../earth/earth?devcode=' + event.target.dataset.devcode - // url: '../earth/earth' + app.globalData.devcode = event.target.dataset.devcode; + wx.switchTab({ + url: '../earth/earth' }) + // wx.reLaunch({ + // url: '../earth/earth?devcode=' + event.target.dataset.devcode + // // url: '../earth/earth' + // }) }, onSearch: function () { + var _this = this wx.navigateTo({ - url: '../searchLog/searchLog' + url: '../searchLog/searchLog?params=' + JSON.stringify(_this.data.params) }) - }, - // initPages: function () { - // wx.cloud.callFunction({ - // name: 'devicelog' - // }).then(res => { - // var that = this; - // var jsonList = JSON.parse(res.result) - // that.setData({ - // deviceloglist: jsonList.data.rows - // }) - // console.log(res); - // }).catch(err => { - // console.error(err); - // }) - // } + } }) \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.wxml b/miniprogram/pages/applog/applog.wxml index e9a2352..2bfd041 100644 --- a/miniprogram/pages/applog/applog.wxml +++ b/miniprogram/pages/applog/applog.wxml @@ -1,54 +1,59 @@ - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {{item.devcode}} {{item.devicetype}} + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + {{item.devcode}} {{item.devicetype}} + + {{item.project}} {{item.installtime}}- {{item.installperson}} - - - - - + + + + + + 删除 - - - + + - 共计:{{total}}台 - + 共计:{{total}}台 + \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.wxss b/miniprogram/pages/applog/applog.wxss index 6d3428b..e6e8983 100644 --- a/miniprogram/pages/applog/applog.wxss +++ b/miniprogram/pages/applog/applog.wxss @@ -22,16 +22,18 @@ position: fixed; width: 100%; top: 0rpx; + z-index: 9999; /* margin-bottom: 100rpx; */ } .log-list { /* height: 100rpx; */ - /* display: flex; */ - + display: flex; + width: 100%; padding: 2px; margin-top: 2px; border-bottom: 1px solid #e5e5e5; + overflow: hidden } @@ -53,23 +55,29 @@ left: 35%; margin: 20rpx } - .del { - width: 90px; + /* display: flex; */ + width: 100rpx; display: flex; flex-direction: column; align-items: center; justify-content: center; - color: #fff; - -webkit-transform: translateX(90px); - transform: translateX(90px); - -webkit-transition: all 0.4s; + /* -webkit-transform: translateX(100rpx); */ + transform: translateX(100rpx); + /* -webkit-transition: all 0.4s; */ transition: all 0.4s; - font-size: 35rpx; + color: #fff; + background-color: #fe3e2f; +} +.logrow{ + width: 100%; + transform: translateX(100rpx); + /* -webkit-transform: translateX(100px); */ + margin-left: -100rpx; } -.touch-move-active .content, +.touch-move-active .logrow, .touch-move-active .del { - -webkit-transform: translateX(0); - transform: translateX(0); +/* -webkit-transform: translateX(0); */ +transform: translateX(0); } \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.js b/miniprogram/pages/deployFunctions/deployFunctions.js deleted file mode 100644 index a76b144..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.js +++ /dev/null @@ -1,66 +0,0 @@ -// pages/deployFunctions/deployFunctions.js -Page({ - - /** - * 页面的初始数据 - */ - data: { - - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - - }, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { - - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - - }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { - - }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { - - } -}) \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.json b/miniprogram/pages/deployFunctions/deployFunctions.json deleted file mode 100644 index 7fbedab..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "navigationBarTitleText": "部署云函数", - "usingComponents": {} -} \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.wxml b/miniprogram/pages/deployFunctions/deployFunctions.wxml deleted file mode 100644 index 462b6b6..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.wxml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - 调用失败 - - - 请检查 login 云函数是否已部署 - - - - - 部署 login 云函数 - 1. 确保已通过工具栏云开发入口开通云开发 - 2. 在 cloudfunctions/login 目录上右键上传并部署 - 3. 回到首页,重新点击获取 openid - - - - diff --git a/miniprogram/pages/deployFunctions/deployFunctions.wxss b/miniprogram/pages/deployFunctions/deployFunctions.wxss deleted file mode 100644 index c8803e6..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.wxss +++ /dev/null @@ -1,7 +0,0 @@ -/* pages/deployFunctions/deployFunctions.wxss */ - -@import "../../style/guide.wxss"; - -.black { - color: black; -} \ No newline at end of file diff --git a/miniprogram/pages/earth/earth.js b/miniprogram/pages/earth/earth.js index ae0d3f3..376a6e2 100644 --- a/miniprogram/pages/earth/earth.js +++ b/miniprogram/pages/earth/earth.js @@ -21,19 +21,12 @@ show: false, enableSsatellite: false, windowWidth: 0, - longitude: 113.324520, - latitude: 23.099994, - longitude84: 113.324520, - latitude84: 23.099994, - markers: [{ - id: 0, - iconPath: "../../images/locat.png", - latitude: 23.099994, - longitude: 113.324520, - width: 50, - height: 50 - }], - controls: [], + longitude: "116.627340", + latitude: "39.874390", + longitude84: "", + latitude84: "", + markers: [], + controls: [] }, /** @@ -41,39 +34,13 @@ */ onLoad: function (options) { var that = this; - //获取当前坐标(gcj02) - wx.getLocation({ - type: "gcj02", - altitude: true, - success: function (res) { - that.setData({ - latitude: parseFloat(res.latitude).toFixed(6), - longitude: parseFloat(res.longitude).toFixed(6), - // markers: [{ - // latitude: res.latitude, - // longitude: res.longitude, - // }] - }) - //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 - wx.getLocation({ - type: "wgs84", - altitude: true, - success: function (res) { - that.setData({ - latitude84: parseFloat(res.latitude).toFixed(6), - longitude84: parseFloat(res.longitude).toFixed(6) - }) - } - }) - } - }), - - //设置地图组件 - wx.getSystemInfo({ + //设置地图组件 + wx.getSystemInfo({ success(res) { var windowWidth = res.windowWidth var windowHeight = res.windowHeight var query = wx.createSelectorQuery() + var platform =res.platform query.select('#map').boundingClientRect() query.exec(function (res) { that.setData({ @@ -139,10 +106,20 @@ clickable: true }, { id: 7, - iconPath: '../../images/locat.png', + iconPath: '../../images/applocat.png', position: { - left: res[0].width/2, - top: res[0].height/2, + left: res[0].width / 2 - 20, + top: platform=="ios"?res[0].height / 2 - 80:res[0].height / 2 - 40, + width: 40, + height: 40 + }, + clickable: true + }, { + id: 8, + iconPath: '../../images/back.png', + position: { + left: windowWidth - 40, + top: windowHeight - 140, width: 30, height: 30 }, @@ -150,71 +127,15 @@ }] }) }) - + } - }), + }) + // 实例化API核心类 qqmapsdk = new QQMapWX({ key: 'BGPBZ-C5O3P-ROUDR-LWC4J-63EKH-V5FRX' }) - - if (options.devcode) { - var that = this - var devcode = options.devcode - wx.cloud.callFunction({ - name: 'findListByCodes', - data: { - devcodes: devcode, - url: app.globalData.url + "appDeviceAdd/findListByCodes" - }, - }).then(res => { - if (res.result.code == 200) { - var listResultData = res.result.data; - that.setData({ - listData: listResultData - }) - var markersArr = that.data.markers; - for (var i = 0; i < listResultData.length; i++) { - markersArr = markersArr.concat({ - iconPath: "../../images/locat.png", - id: listResultData[i].id, - callout: { - content: listResultData[i].devcode, - fontSize: '14', - // padding: true, - color: '#00000', - borderColor: '#F4EA2A', - bgColor: '#F4EA2A', - borderWidth: 5, - display: 'ALWAYS', - textAlign: 'center', - // borderRadius: 15 - }, - latitude: listResultData[i].latitude, - longitude: listResultData[i].longitude, - width: 40, - height: 40 - }); - } - this.setData({ - markers: markersArr, - latitude: listResultData[0].latitude, - longitude: listResultData[0].longitude, - marker_latitude: listResultData[0].latitude, - marker_longitude: listResultData[0].longitude, - title: listResultData[0].devcode - }) - } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "无法获取设备地理信息!", - icon: 'none', - duration: 2000 - }) - }) - } }, /** @@ -228,6 +149,97 @@ * 生命周期函数--监听页面显示 */ onShow: function () { + //输入设备编号获取marker位置信息 + var that = this; + if ( app.globalData.devcode!="") { + var devcode = app.globalData.devcode + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/findListByCodes", + data: { + devcodes: devcode, + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + app.globalData.devcode=""; + if (res.data.code == 200) { + var listResultData = res.data.data; + that.setData({ + listData: listResultData + }) + var markersArr = that.data.markers; + for (var i = 0; i < listResultData.length; i++) { + markersArr = markersArr.concat({ + iconPath: "../../images/locat.png", + id: Number(listResultData[i].id), + callout: { + content: "编号:"+listResultData[i].devcode+"\r\n位置:"+listResultData[i].position+"\r\n时间:"+listResultData[i].createtime, + fontSize: '14', + padding: true, + color: '#000000', + borderColor: '#F4EA2A', + bgColor: '#F4EA2A', + borderWidth: 5, + display: 'ALWAYS', + textAlign: 'left', + // borderRadius: 15 + }, + latitude: listResultData[i].latitude, + longitude: listResultData[i].longitude, + width: 40, + height: 40 + }); + } + that.setData({ + markers: markersArr, + latitude: listResultData[0].latitude, + longitude: listResultData[0].longitude, + marker_latitude: listResultData[0].latitude, + marker_longitude: listResultData[0].longitude, + title: listResultData[0].devcode + }) + } + }, + fail(err) { + app.globalData.devcode=""; + wx.showToast({ + title: "无法获取设备地理信息!", + icon: 'none', + duration: 2000 + }) + } + }) +} else { + //获取当前坐标(gcj02) + wx.getLocation({ + type: "gcj02", + altitude: true, + success: function (res) { + that.setData({ + latitude: parseFloat(res.latitude).toFixed(6), + longitude: parseFloat(res.longitude).toFixed(6), + // markers: [{ + // latitude: res.latitude, + // longitude: res.longitude, + // }] + }) + //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 + wx.getLocation({ + type: "wgs84", + altitude: true, + success: function (res) { + that.setData({ + latitude84: parseFloat(res.latitude).toFixed(6), + longitude84: parseFloat(res.longitude).toFixed(6) + }) + } + }) + } + }) +} + }, @@ -265,12 +277,46 @@ onShareAppMessage: function () { }, + + //定位出来 + + locationPosition: function () { + var that = this; + //获取当前坐标(gcj02) + wx.getLocation({ + type: "gcj02", + altitude: true, + success: function (res) { + that.setData({ + latitude: parseFloat(res.latitude).toFixed(6), + longitude: parseFloat(res.longitude).toFixed(6), + // markers: [{ + // latitude: res.latitude, + // longitude: res.longitude + // }] + }) + //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 + wx.getLocation({ + type: "wgs84", + altitude: true, + success: function (res) { + that.setData({ + latitude84: parseFloat(res.latitude).toFixed(6), + longitude84: parseFloat(res.longitude).toFixed(6) + }) + } + }) + } + }) + }, + + //加载地图组件 controltap: function (e) { // console.log(e.controlId); //进入添加设备页 if (1 == e.controlId) { wx.setClipboardData({ - data: this.data.latitude + "," + this.data.longitude+ "," + this.data.latitude84+ "," + this.data.longitude84, + data: this.data.latitude + "," + this.data.longitude + "," + this.data.latitude84 + "," + this.data.longitude84, success: function (res) { wx.getClipboardData({ success: function (res) { @@ -282,6 +328,17 @@ } }) } else if (3 == e.controlId) { + //先定位 + // this.locationPosition() + wx.setClipboardData({ + data: this.data.latitude + "," + this.data.longitude + "," + this.data.latitude84 + "," + this.data.longitude84, + success: function (res) { + wx.showToast({ + title: '坐标已获取', + duration: 1000 + }) + } + }) wx.navigateTo({ url: '../addDevice/addDevice' }) @@ -302,32 +359,15 @@ enableSsatellite: !flag }); } else if (6 == e.controlId) { - var that = this; - //获取当前坐标(gcj02) - wx.getLocation({ - type: "gcj02", - altitude: true, - success: function (res) { - that.setData({ - latitude: parseFloat(res.latitude).toFixed(6), - longitude:parseFloat(res.longitude).toFixed(6), - // markers: [{ - // latitude: res.latitude, - // longitude: res.longitude - // }] - }) - //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 - wx.getLocation({ - type: "wgs84", - altitude: true, - success: function (res) { - that.setData({ - latitude84: parseFloat(res.latitude).toFixed(6), - longitude84: parseFloat(res.longitude).toFixed(6) - }) - } - }) - } + //先清marker + this.setData({ + markers: [] + }) + this.locationPosition() + }else if (8 == e.controlId) { + //跳转日志缓存页 + wx.switchTab({ + url: '../applog/applog', }) } }, @@ -343,63 +383,68 @@ }); }, + //获取设备maker leave() { var that = this; if (that.data.devcodes == "") { return false; } - wx.cloud.callFunction({ - name: 'findListByCodes', + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/findListByCodes", data: { - devcodes: that.data.devcodes, - url: app.globalData.url + "appDeviceAdd/findListByCodes" + devcodes: that.data.devcodes }, - }).then(res => { - if (res.result.code == 200) { - var listResultData = res.result.data; - that.setData({ - listData: listResultData - }) - var markersArr = that.data.markers; - for (var i = 0; i < listResultData.length; i++) { - markersArr = markersArr.concat({ - iconPath: "../../images/locat.png", - id: listResultData[i].id, - callout: { - content: listResultData[i].devcode, - fontSize: '14', - // padding: true, - color: '', - borderColor: '#F4EA2A', - bgColor: '#F4EA2A', - borderWidth: 5, - display: 'ALWAYS', - textAlign: 'center', - // borderRadius: 15 - }, - latitude: listResultData[i].latitude, - longitude: listResultData[i].longitude, - width: 40, - height: 40 - }); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var listResultData = res.data.data; + that.setData({ + listData: listResultData + }) + var markersArr = that.data.markers; + for (var i = 0; i < listResultData.length; i++) { + markersArr = markersArr.concat({ + iconPath: "../../images/locat.png", + id: listResultData[i].id, + callout: { + content: "编号:"+listResultData[i].devcode+"\r\n位置:"+listResultData[i].position+"\r\n时间:"+listResultData[i].createtime, + fontSize: '14', + // padding: true, + color: '#212121', + borderColor: '#F4EA2A', + bgColor: '#F4EA2A', + borderWidth: 5, + display: 'ALWAYS', + textAlign: 'left', + // borderRadius: 15 + }, + latitude: listResultData[i].latitude, + longitude: listResultData[i].longitude, + width: 40, + height: 40 + }); + } + that.setData({ + markers: markersArr, + latitude: listResultData[0].latitude, + longitude: listResultData[0].longitude, + marker_latitude: listResultData[0].latitude, + marker_longitude: listResultData[0].longitude, + title: listResultData[0].devcode + }) } - this.setData({ - markers: markersArr, - latitude: listResultData[0].latitude, - longitude: listResultData[0].longitude, - marker_latitude: listResultData[0].latitude, - marker_longitude: listResultData[0].longitude, - title: listResultData[0].devcode + }, + fail(err) { + wx.showToast({ + title: "无法获取设备地理信息!", + icon: 'none', + duration: 2000 }) } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "无法获取设备地理信息!", - icon: 'none', - duration: 2000 - }) }) }, @@ -422,6 +467,8 @@ } }, + + bindregionchange: function (e) { var that = this if (e.causedBy == "drag") { @@ -445,8 +492,8 @@ that.setData({ latitude: parseFloat(latitude).toFixed(6), longitude: parseFloat(longitude).toFixed(6), - latitude84:"", - longitude84:"", + latitude84: "", + longitude84: "", // markers: markersArr }) // mapCtx.moveToLocation(); @@ -465,16 +512,19 @@ qqmapsdk.search({ keyword: this.data.value, success: function (res) { + console.log(res) if (res && res.data) { _this.setData({ isShow: true, tips: res.data }); } + }, + complete: function (res){ + console.log(res); } }) }, - bindSearch: function (e) { var location = e.target.dataset.location; this.setData({ diff --git a/miniprogram/pages/earth/earth.wxml b/miniprogram/pages/earth/earth.wxml index a0db6ef..87474f8 100644 --- a/miniprogram/pages/earth/earth.wxml +++ b/miniprogram/pages/earth/earth.wxml @@ -1,9 +1,10 @@ + - + {{item.title}} {{item.address}} @@ -17,6 +18,6 @@ + placeholder="请输入定位设备编号用换行隔开" autosize border="{{ false }}" /> \ No newline at end of file diff --git a/miniprogram/pages/indexapp/indexapp.js b/miniprogram/pages/indexapp/indexapp.js index 5063372..849dbdb 100644 --- a/miniprogram/pages/indexapp/indexapp.js +++ b/miniprogram/pages/indexapp/indexapp.js @@ -7,9 +7,8 @@ */ data: { - count:1, - show: false, - onshow:true, + count: 1, + onshow: true, value: "", deviceloglist: [], devcode: "", @@ -21,6 +20,7 @@ // iconPath: "../../images/point.png", latitude: 23.099994, longitude: 113.324520, + label:'1', width: 50, height: 50 }], @@ -31,62 +31,26 @@ * 生命周期函数--监听页面加载 */ onLoad: function (options) { - + }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { - + }, /** * 生命周期函数--监听页面显示 */ onShow: function () { - // if( app.globalData.indexCount>1){ - // this.setData({ - // show:false - // }) - // }else{ - // this.showNotice() - // } - if(app.globalData.indexCount==1){ - this.setData({ - show:true - }) - this.showNotice() - } - app.globalData.indexCount+=1 - if(this.data.onshow){ + if (this.data.onshow) { this.initPages(); } }, - - showNotice: function() { - var that = this - var times = 0 - var i = setInterval(function() { - times++ - if (times >= 15) { - that.setData({ - show:false - }) - wx.showTabBar({ - animation: false, - }) - clearInterval(i) - } else { - wx.hideTabBar({ - animation: false, - }) - } - }, 1000) -}, - /** * 生命周期函数--监听页面隐藏 */ @@ -122,16 +86,27 @@ }, jump: function (event) { - var that = this; var latitude = event.target.dataset.pointLat; var longitude = event.target.dataset.pointLon; + let devcode = event.target.dataset.pointCode; that.setData({ latitude: latitude, longitude: longitude, markers: [{ latitude: latitude, - longitude: longitude + longitude: longitude, + callout: { + display:'ALWAYS',// 常显气泡 + content: devcode, //名称文本 + color: '#fff', //文本颜色 + borderRadius: 5, //边框圆角 + borderWidth: 1, //边框宽度 + borderColor: '#0060ff', //边框颜色 + bgColor: '#0060ff', //背景色 + padding: 5, //文本边缘留白 + textAlign: 'center' //文本对齐方式。有效值: left, right, center + } }] }) }, @@ -142,7 +117,7 @@ var devcode = res.result _this.setData({ devcode: devcode, - onshow:false + onshow: false }); _this.searchlogs(devcode) } @@ -151,40 +126,11 @@ onSearch: function (event) { this.setData({ - devcode:event.detail + devcode: event.detail }) this.searchlogs(event.detail) }, - - // bindregionchange: function (e) { - // var that = this - // if (e.causedBy == "drag") { - // var mapCtx = wx.createMapContext("map") - // mapCtx.getCenterLocation({ - // success: function (res) { - // var markersArr = that.data.markers - // for (var i = 0; i < markersArr.length; i++) { - // if (markersArr[i].iconPath == undefined) { - // markersArr.splice(i, 1) - // } - // } - // var latitude = res.latitude - // var longitude = res.longitude - // markersArr = markersArr.concat({ - // latitude: latitude, - // longitude: longitude - // }) - // that.setData({ - // latitude: latitude, - // longitude: longitude, - // markers: markersArr - // }) - // } - // }) - // } - // }, - showLoading: function (message) { if (wx.showLoading) { // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 @@ -211,81 +157,89 @@ } }, + //加载设备运维详细信息 toDetail: function (event) { - this.showLoading("数据加载中...") - wx.cloud.callFunction({ - name: 'deviceDetail', + var that = this + that.showLoading("数据加载中...") + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deviceDetail", data: { devcode: event.target.dataset.devcode, - url: app.globalData.url + "appDeviceLog/deviceDetail", }, - }).then(res => { - this.hideLoading(); - var resultObject = JSON.parse(res.result); - var pageName='../indexapp/indexapp' - if (resultObject.code == 200) { - wx.navigateTo({ - url: '../addDevicelog/addDeviceLog?detail=' + - JSON.stringify(resultObject.data)+'&pageName='+pageName - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + that.hideLoading(); + var resultObject = res.data; + var pageName = '../indexapp/indexapp' + if (resultObject.code == 200) { + wx.setStorageSync('resultObject', resultObject.data) + wx.navigateTo({ + url: '../addDevicelog/addDeviceLog?detail=' +'&pageName=' + pageName + }) + } + }, + fail(err){ + that.hideLoading(); } - }).catch(err => { - this.hideLoading(); }) }, + //加载列表 getlogs: function (devcode) { var that = this - wx.cloud.callFunction({ - name: 'devicelog', + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/listPage", data: { devcode: devcode, - url: app.globalData.url + "appDeviceLog/listPage", limit: 100, offset: that.data.deviceloglist.length % 100 > 0 ? parseInt(that.data.deviceloglist.length / 100) + 2 : parseInt(that.data.deviceloglist.length / 100) + 1 }, - }).then(res => { - if (res.result) { - // var resultJson = JSON.parse(res.result) - var resultJson = res.result - that.setData({ - deviceloglist: that.data.deviceloglist.concat(resultJson.data.rows) - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + // var resultJson = JSON.parse(res.result) + var resultJson = res.data + that.setData({ + deviceloglist: that.data.deviceloglist.concat(resultJson.data.rows) + }) + } } - console.log(res); - }).catch(err => { - console.error(err); }) }, + //查询列表 searchlogs: function (devcode) { var that = this - wx.cloud.callFunction({ - name: 'devicelog', + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/listPage", data: { devcode: devcode, - url: app.globalData.url + "appDeviceLog/listPage", limit: 100, offset: 1 }, - }).then(res => { - if (res.result) { - var resultJson = res.result - that.setData({ - deviceloglist: resultJson.data.rows, - onshow:true - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var resultJson = res.data + that.setData({ + deviceloglist: resultJson.data.rows, + onshow: true + }) + } } - console.log(res); - }).catch(err => { - console.error(err); }) }, initPages: function () { var that = this; - that.setData({ - devcode: "" - }); wx.getLocation({ type: "gcj02", success: function (res) { @@ -302,6 +256,6 @@ }) } }) - this.searchlogs() + this.data.devcode !== '' ? this.searchlogs(this.data.devcode) : this.searchlogs() }, }) \ No newline at end of file diff --git a/miniprogram/pages/indexapp/indexapp.wxml b/miniprogram/pages/indexapp/indexapp.wxml index 69322a0..f65b082 100644 --- a/miniprogram/pages/indexapp/indexapp.wxml +++ b/miniprogram/pages/indexapp/indexapp.wxml @@ -1,8 +1,12 @@ + + + + - @@ -32,9 +36,15 @@ - + + + + + + + @@ -46,14 +56,14 @@ - + - - + diff --git a/miniprogram/pages/indexapp/indexapp.wxss b/miniprogram/pages/indexapp/indexapp.wxss index b18706a..fc27fcb 100644 --- a/miniprogram/pages/indexapp/indexapp.wxss +++ b/miniprogram/pages/indexapp/indexapp.wxss @@ -128,6 +128,7 @@ .noticeClass{ height: 2300rpx; width: 750rpx; + overflow-y:hidden; } @@ -148,14 +149,14 @@ } +/* .vanstyle{ + button: not([size='mini']) { + user agent stylesheetmin-height: 40px; + width: 650rpx; + margin-left: 20rpx; + margin-right: auto; + + } + +} */ -/* .van-enter-active-class, -.van-leave-active-class { - transition-property: background-color, transform; -} - -.van-enter-class, -.van-leave-to-class { - background-color: red; - transform: rotate(-360deg) translate3d(-100%, -100%, 0); -} */ \ No newline at end of file diff --git a/miniprogram/pages/log/log.js b/miniprogram/pages/log/log.js deleted file mode 100644 index 83ba349..0000000 --- a/miniprogram/pages/log/log.js +++ /dev/null @@ -1,66 +0,0 @@ -// pages/log/log.js -Page({ - - /** - * 页面的初始数据 - */ - data: { - - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - - }, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { - - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - - }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { - - }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { - - } -}) \ No newline at end of file diff --git a/miniprogram/pages/log/log.json b/miniprogram/pages/log/log.json deleted file mode 100644 index 8835af0..0000000 --- a/miniprogram/pages/log/log.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "usingComponents": {} -} \ No newline at end of file diff --git a/miniprogram/pages/log/log.wxml b/miniprogram/pages/log/log.wxml deleted file mode 100644 index a510ad6..0000000 --- a/miniprogram/pages/log/log.wxml +++ /dev/null @@ -1,2 +0,0 @@ - -pages/log/log.wxml diff --git a/miniprogram/pages/log/log.wxss b/miniprogram/pages/log/log.wxss deleted file mode 100644 index 23db318..0000000 --- a/miniprogram/pages/log/log.wxss +++ /dev/null @@ -1 +0,0 @@ -/* pages/log/log.wxss */ \ No newline at end of file diff --git a/miniprogram/pages/login/login.js b/miniprogram/pages/login/login.js index a4074e7..cb0542a 100644 --- a/miniprogram/pages/login/login.js +++ b/miniprogram/pages/login/login.js @@ -1,11 +1,14 @@ // miniprogram/pages/login/login.js +var app = getApp() Page({ /** * 页面的初始数据 */ data: { - windowWidth:"" + windowWidth: "", + time: 15 * 1000, + showTime: false }, /** @@ -20,9 +23,9 @@ */ onReady: function () { this.setData({ - windowWidth:wx.getSystemInfoSync().windowWidth + windowWidth: wx.getSystemInfoSync().windowWidth }) - + }, /** @@ -66,14 +69,158 @@ onShareAppMessage: function () { }, + + + showLoading: function (message) { + if (wx.showLoading) { + // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 + wx.showLoading({ + title: message, + mask: true + }); + } else { + // 低版本采用Toast兼容处理并将时间设为20秒以免自动消失 + wx.showToast({ + title: message, + icon: 'loading', + mask: true, + duration: 20000 + }); + } + }, + hideLoading: function () { + if (wx.hideLoading) { + // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 + wx.hideLoading(); + } else { + wx.hideToast(); + } + }, + + //注册 loginClick: function () { + var that = this + that.showLoading("授权中...") + wx.login({ + success: function (res) { + if (res.code) { + wx.request({ + url: app.globalData.httpsUrl + "appUserOpenid/login", + data: { + code: res.code + }, + success: function (res) { + app.globalData.openid = res.data.data + wx.getUserInfo({ + success: (res) => { + var nickname = res.userInfo.nickName; + app.globalData.nickName = nickname; + //openid绑定昵称存入后台 + wx.request({ + url: app.globalData.httpsUrl + "appUserOpenid/add", + data: { + attr: nickname, + openid: app.globalData.openid + }, + success: function (res) { + that.hideLoading(); + wx.showToast({ + title: res.data.data+",\r\n请从正式版入口登录!", + icon: 'none', + duration: 2000 + }) - wx.navigateTo({ - - url: '../farmermain/farmermain', - + // //授权成功后跳转 + // wx.switchTab({ + // url: '../indexapp/indexapp' + // }) + } + }) + }, + fail: function (err) { + that.hideLoading(); + } + }) + }, + fail: function (res) { + that.hideLoading(); + wx.showToast({ + title: '服务器异常', + }) + } + }) + } + }, + fail: function (res) { + that.hideLoading(); + } }) + }, + //登录验证 + loginValidate: function () { + var that = this + that.showLoading("登录中...") + wx.login({ + success: function (res) { + if (res.code) { + console.info(res); + wx.request({ + url: app.globalData.httpsUrl + "appUserOpenid/login", + data: { + code: res.code + }, + success: function (res) { + app.globalData.openid = res.data.data + wx.request({ + url: app.globalData.httpsUrl + "appUserOpenid/validate", + data: { + openid: app.globalData.openid + }, + success: function (res) { + that.hideLoading(); + if (res.data.data) { + app.globalData.userName = res.data.data.attr1 == '' ? res.data.data.attr : res.data.data.attr1 + app.globalData.nickName = res.data.data.attr + app.globalData.role = res.data.data.role + wx.navigateTo({ + url: '../notice/notice' + }) + } else { + wx.showToast({ + icon: 'none', + title: '请联系管理员授权', + duration: 2000 + }) + } + }, + fail: function (err) { + that.hideLoading(); + wx.showToast({ + title: '验证失败', + }) + } + }) + }, + fail: function (res) { + that.hideLoading(); + wx.showToast({ + title: '服务器异常', + }) + } + }) + } + }, + fail: function (res) { + that.hideLoading(); + } + }) + }, + + finished() { + this.setData({ + showTime: true + }) }, onClickSubmit: function () { diff --git a/miniprogram/pages/login/login.json b/miniprogram/pages/login/login.json index 8835af0..f2043a3 100644 --- a/miniprogram/pages/login/login.json +++ b/miniprogram/pages/login/login.json @@ -1,3 +1,8 @@ { - "usingComponents": {} + "usingComponents": { + "van-count-down": "../../miniprogram_npm/@vant/weapp/count-down", + "van-button": "../../miniprogram_npm/@vant/weapp/button" + }, + "navigationBarBackgroundColor": "#E6D480", + "disableScroll":true } \ No newline at end of file diff --git a/miniprogram/pages/login/login.wxml b/miniprogram/pages/login/login.wxml index c69df42..cf2ec72 100644 --- a/miniprogram/pages/login/login.wxml +++ b/miniprogram/pages/login/login.wxml @@ -1,21 +1,46 @@ + - + + + - + + + +    本程序为施工日志管理小程序,为航天二院智慧市 +政技术研究室内部系统,不对外开放。出于对数据信 +息安全的考虑,在您首次使用小程序时,请先对小程 +序进行授权,授权后的用户可以正常对小程序进行编 +辑,谢谢您的配合! + + + + + + + + 授权/登录 + + + - + + + diff --git a/miniprogram/pages/login/login.wxss b/miniprogram/pages/login/login.wxss index ca77568..b9fa569 100644 --- a/miniprogram/pages/login/login.wxss +++ b/miniprogram/pages/login/login.wxss @@ -54,7 +54,8 @@ } .form .submit { - margin-top: 80rpx; + + /* margin-top: 80rpx; */ color: #fff; border: 2rpx solid #FFB90F; background-color: #FFB90F; @@ -63,10 +64,30 @@ } .login_image { - width: 200rpx; - height: 200rpx; - padding-top: 100rpx; - padding-left: 250rpx; + width: 750rpx; + height: 360rpx; + /* height: 2300rpx; */ + /* padding-top: 100rpx + padding-left: 250rpx; */ +} +.bottom_image { + width: 750rpx; + height: 32%; + position: fixed; + bottom: 0px; + /* padding-top: 100rpx + padding-left: 250rpx; */ +} +.cover{ + position: fixed; + top: 0rpx; + margin-left: 290rpx; + text-align:center; + font-size: 50rpx; + color: #FFCF00; + width: 750rpx; + z-index:9999; + } -} \ No newline at end of file + \ No newline at end of file diff --git a/miniprogram/pages/notice/notice.js b/miniprogram/pages/notice/notice.js new file mode 100644 index 0000000..7aeafb9 --- /dev/null +++ b/miniprogram/pages/notice/notice.js @@ -0,0 +1,80 @@ +// miniprogram/pages/notice.js +Page({ + + /** + * 页面的初始数据 + */ + data: { + time: 15 * 1000, + showTime: false + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { + this.setData({ + showTime: true + }) + wx.switchTab({ + url: '../indexapp/indexapp' + }) + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + }, + finished() { + this.setData({ + showTime: true + }) + wx.switchTab({ + url: '../indexapp/indexapp' + }) + } +}) \ No newline at end of file diff --git a/miniprogram/pages/notice/notice.json b/miniprogram/pages/notice/notice.json new file mode 100644 index 0000000..4c73264 --- /dev/null +++ b/miniprogram/pages/notice/notice.json @@ -0,0 +1,5 @@ +{ + "usingComponents": { + "van-count-down": "../../miniprogram_npm/@vant/weapp/count-down" + } +} \ No newline at end of file diff --git a/miniprogram/pages/notice/notice.wxml b/miniprogram/pages/notice/notice.wxml new file mode 100644 index 0000000..975304a --- /dev/null +++ b/miniprogram/pages/notice/notice.wxml @@ -0,0 +1,10 @@ + + + + + + + + diff --git a/miniprogram/pages/notice/notice.wxss b/miniprogram/pages/notice/notice.wxss new file mode 100644 index 0000000..36d7542 --- /dev/null +++ b/miniprogram/pages/notice/notice.wxss @@ -0,0 +1,18 @@ +/* miniprogram/pages/notice.wxss */ + +.login_image { + width: 750rpx; + height: 2300rpx; + /* padding-top: 100rpx + padding-left: 250rpx; */ +} +.cover{ + position: fixed; + top: 0rpx; + margin-left: 290rpx; + text-align:center; + font-size: 50rpx; + color: #FFCF00; + width: 750rpx; + z-index:9999; + } \ No newline at end of file diff --git a/miniprogram/pages/searchLog/searchLog.js b/miniprogram/pages/searchLog/searchLog.js index a4f8c33..1f7069b 100644 --- a/miniprogram/pages/searchLog/searchLog.js +++ b/miniprogram/pages/searchLog/searchLog.js @@ -6,29 +6,35 @@ * 页面的初始数据 */ data: { - defaultDay:[ + defaultDay: [ new Date().getTime(), - new Date().getTime()+24*60*60*1000, + new Date().getTime() + 24 * 60 * 60 * 1000, ], projectoption: [], - devtypeList:[], + devtypeList: [], personoption: [], installtimeFmt: '', show: false, - minDate: new Date(2010, 0, 1).getTime(), devcode: '', + timeShow:false, project: '', devtype: '', - installPerson:'', + installPerson: '', + projectvalue:'', minDate: new Date(2018, 0, 1).getTime(), // maxDate: new Date(2018, 0, 31).getTime(), }, onDisplay() { - this.setData({ show: true }); + this.setData({ + show: true + }); }, onClose() { - this.setData({ show: false }); + this.setData({ + show: false + }); }, + //格式化时间 formatDate(date) { date = new Date(date); // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; @@ -50,6 +56,7 @@ return currentdate; }, + //查询时间区域设置 onConfirm(event) { // this.setData({ @@ -67,87 +74,102 @@ /** * 生命周期函数--监听页面加载 */ - onLoad: function (options) { - var _this=this + onLoad: async function (options) { + await this.setData({ + timeShow:true, + }) + const {devcode,devtype,installPerson,installtimeFmt,project} = JSON.parse(options.params) + this.setData({ + devcode:devcode || '', + devtype:devtype || '', + installPerson:installPerson || '', + installtimeFmt:installtimeFmt || '', + project:project || '', + projectvalue:project || '', + + }) + + var _this = this /** * 获取所属项目下拉列表 */ - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); + success(res) { + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); + } + _this.setData({ + projectoption: projectArr + }) } - _this.setData({ - projectoption: projectArr - }) } - }).catch(err => { - console.error(err); }) - - - /** + /** * 获取设备类型下拉列表 */ - wx.cloud.callFunction({ - name: 'getTypeList', - data: { - url: app.globalData.url + "deviceType/deviceType" + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/deviceType", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - }).then(res => { - if (res.result.code == 200) { - var TypeList = res.result.data - var typeArr = []; - for (var i = 0; i < TypeList.length; i++) { - var type = { - text: TypeList[i].productName, - value: TypeList[i].productName - }; - typeArr.push(type); + success(res) { + if (res.data.code == 200) { + var TypeList = res.data.data + var typeArr = []; + for (var i = 0; i < TypeList.length; i++) { + var type = { + text: TypeList[i].productName, + value: TypeList[i].productName + }; + typeArr.push(type); + } + _this.setData({ + devtypeList: typeArr + }) } - _this.setData({ - devtypeList: typeArr - }) } - }).catch(err => { - console.error(err); }) - //获取人员下拉列表 - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" + //获取人员下拉列表 + wx.request({ + method: "POST", + data:{ + tips:'repair' }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); + url: app.globalData.httpsUrl + "deviceType/getUser", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var users = res.data.data + var personArr = []; + for (var i = 0; i < users.length; i++) { + var person = { + text: users[i].name, + value: users[i].name + }; + personArr.push(person); + } + _this.setData({ + personoption: personArr + }) } - _this.setData({ - personoption: personArr - }) } - }).catch(err => { - console.error(err); }) }, @@ -202,13 +224,13 @@ }, scan() { - var _this=this; + var _this = this; wx.scanCode({ success(res) { - var devcode=res.result + var devcode = res.result _this.setData({ - devcode: devcode, - }); + devcode: devcode, + }); } }) }, @@ -221,6 +243,7 @@ [formName]: formValue }) }, + //设置项目 selectprojectValue(event) { var that = this; that.setData({ @@ -228,7 +251,7 @@ }) }, - + //设置设备类型 selectDevType(event) { var that = this; that.setData({ @@ -236,46 +259,24 @@ }) }, + //设置人员 selectpersonValue(event) { var that = this; that.setData({ installPerson: event.detail }) }, - + //查询 query: function (event) { - var data={ + var data = { devcode: this.data.devcode, installtimeFmt: this.data.installtimeFmt, project: this.data.project, devtype: this.data.devtype, - installPerson:this.data.installPerson + installPerson: this.data.installPerson } wx.reLaunch({ url: '../applog/applog?params=' + JSON.stringify(data) }) - // var that = this; - // wx.cloud.callFunction({ - // name: 'devicelog', - // data: { - // devcode: that.data.devcode, - // installtimeFmt: that.data.installtimeFmt, - // project: that.data.project, - // devtype: that.data.devtype, - // }, - // }).then(res => { - // // var resultObj=JSON.parse(res.result); - // var resultObj=res.result; - // if (resultObj.code == 200) { - // wx.reLaunch({ - // url: '../applog/applog?applogList=' + JSON.stringify(resultObj.data.rows) - // }) - // } - // }).catch(err => { - // console.error(err); - // wx.showToast({ - // title: "查询失败", - // }) - // }) }, }) \ No newline at end of file diff --git a/miniprogram/pages/searchLog/searchLog.wxml b/miniprogram/pages/searchLog/searchLog.wxml index dfbc788..daf06bc 100644 --- a/miniprogram/pages/searchLog/searchLog.wxml +++ b/miniprogram/pages/searchLog/searchLog.wxml @@ -21,14 +21,10 @@ - + - - @@ -39,7 +35,12 @@ - - 查询 + + + + + 查询 \ No newline at end of file diff --git a/miniprogram/project.config.json b/miniprogram/project.config.json new file mode 100644 index 0000000..4a797a9 --- /dev/null +++ b/miniprogram/project.config.json @@ -0,0 +1,43 @@ +{ + "appid": "wx79419f886f8c77ef", + "compileType": "miniprogram", + "libVersion": "2.27.3", + "packOptions": { + "ignore": [], + "include": [] + }, + "setting": { + "urlCheck": true, + "coverView": true, + "es6": true, + "postcss": true, + "lazyloadPlaceholderEnable": false, + "preloadBackgroundData": false, + "minified": true, + "autoAudits": false, + "uglifyFileName": false, + "uploadWithSourceMap": true, + "enhance": true, + "showShadowRootInWxmlPanel": true, + "packNpmManually": false, + "packNpmRelationList": [], + "minifyWXSS": true, + "useStaticServer": true, + "showES6CompileOption": false, + "checkInvalidKey": true, + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + }, + "disableUseStrict": false, + "useCompilerPlugins": false, + "minifyWXML": true + }, + "condition": {}, + "editorSetting": { + "tabIndent": "insertSpaces", + "tabSize": 4 + }, + "description": "项目配置文件,详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html" +} \ No newline at end of file diff --git a/miniprogram/project.private.config.json b/miniprogram/project.private.config.json new file mode 100644 index 0000000..7bbb91d --- /dev/null +++ b/miniprogram/project.private.config.json @@ -0,0 +1,56 @@ +{ + "projectname": "miniprogram", + "setting": { + "compileHotReLoad": true, + "urlCheck": true + }, + "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", + "condition": { + "miniprogram": { + "list": [ + { + "name": "", + "pathName": "pages/indexapp/indexapp", + "query": "", + "launchMode": "default", + "scene": null + }, + { + "name": "", + "pathName": "pages/addDevice/addDevice", + "query": "", + "launchMode": "default", + "scene": null + }, + { + "name": "", + "pathName": "pages/addDevicelog/addDeviceLog", + "query": "", + "launchMode": "default", + "scene": null + }, + { + "name": "", + "pathName": "pages/searchLog/searchLog", + "query": "", + "launchMode": "default", + "scene": null + }, + { + "name": "", + "pathName": "pages/applog/applog", + "query": "", + "launchMode": "default", + "scene": null + }, + { + "name": "", + "pathName": "pages/login/login", + "query": "", + "launchMode": "default", + "scene": null + } + ] + } + } +} \ No newline at end of file diff --git a/project.config.json b/project.config.json index c5f5337..c3a97f8 100644 --- a/project.config.json +++ b/project.config.json @@ -1,61 +1,55 @@ { - "miniprogramRoot": "miniprogram/", - "cloudfunctionRoot": "cloudfunctions/", - "setting": { - "urlCheck": false, - "es6": true, - "enhance": true, - "postcss": true, - "preloadBackgroundData": false, - "minified": true, - "newFeature": true, - "coverView": true, - "nodeModules": true, - "autoAudits": false, - "showShadowRootInWxmlPanel": true, - "scopeDataCheck": false, - "checkInvalidKey": true, - "checkSiteMap": true, - "uploadWithSourceMap": true, - "babelSetting": { - "ignore": [], - "disablePlugins": [], - "outputPath": "" - }, - "useCompilerModule": false, - "userConfirmedUseCompilerModuleSwitch": false - }, - "appid": "wx79419f886f8c77ef", - "projectname": "constructionApp", - "libVersion": "2.8.1", - "simulatorType": "wechat", - "simulatorPluginLibVersion": {}, - "cloudfunctionTemplateRoot": "cloudfunctionTemplate", - "condition": { - "search": { - "current": -1, - "list": [] - }, - "conversation": { - "current": -1, - "list": [] - }, - "plugin": { - "current": -1, - "list": [] - }, - "game": { - "list": [] - }, - "miniprogram": { - "current": 0, - "list": [ - { - "id": -1, - "name": "db guide", - "pathName": "pages/databaseGuide/databaseGuide" - } - ] - } - } + "miniprogramRoot": "miniprogram/", + "cloudfunctionRoot": "cloudfunctions/", + "setting": { + "urlCheck": false, + "es6": true, + "enhance": true, + "postcss": true, + "preloadBackgroundData": false, + "minified": true, + "newFeature": true, + "coverView": true, + "nodeModules": true, + "autoAudits": false, + "showShadowRootInWxmlPanel": true, + "scopeDataCheck": false, + "checkInvalidKey": true, + "checkSiteMap": true, + "uploadWithSourceMap": true, + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + }, + "useCompilerModule": false, + "userConfirmedUseCompilerModuleSwitch": false + }, + "appid": "wx2cef527a000f87c9", + "projectname": "constructionApp", + "libVersion": "2.8.1", + "simulatorType": "wechat", + "simulatorPluginLibVersion": {}, + "cloudfunctionTemplateRoot": "cloudfunctionTemplate/", + "compileType": "miniprogram", + "condition": { + "miniprogram": { + "list": [ + { + "name": "db guide", + "pathName": "pages/databaseGuide/databaseGuide", + "query": "" + } + ] + } + }, + "srcMiniprogramRoot": "miniprogram/", + "packOptions": { + "ignore": [], + "include": [] + }, + "editorSetting": { + "tabIndent": "insertSpaces", + "tabSize": 4 + } } \ No newline at end of file diff --git a/cloudfunctions/project.config.json b/cloudfunctions/project.config.json new file mode 100644 index 0000000..2b3119a --- /dev/null +++ b/cloudfunctions/project.config.json @@ -0,0 +1,28 @@ +{ + "appid": "wx2cef527a000f87c9", + "compileType": "miniprogram", + "libVersion": "2.27.3", + "packOptions": { + "ignore": [], + "include": [] + }, + "setting": { + "coverView": true, + "es6": true, + "postcss": true, + "minified": true, + "enhance": true, + "showShadowRootInWxmlPanel": true, + "packNpmRelationList": [], + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + } + }, + "condition": {}, + "editorSetting": { + "tabIndent": "insertSpaces", + "tabSize": 4 + } +} \ No newline at end of file diff --git a/cloudfunctions/project.private.config.json b/cloudfunctions/project.private.config.json new file mode 100644 index 0000000..42ff49d --- /dev/null +++ b/cloudfunctions/project.private.config.json @@ -0,0 +1,7 @@ +{ + "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", + "projectname": "cloudfunctions", + "setting": { + "compileHotReLoad": true + } +} \ No newline at end of file diff --git a/miniprogram/app.js b/miniprogram/app.js index 51d56f3..50a8a54 100644 --- a/miniprogram/app.js +++ b/miniprogram/app.js @@ -18,13 +18,15 @@ // this.globalData = {} }, globalData: { - // url: "http://111.198.10.15:11604/", - httpsUrl: "https://logapi.smartlog.work/", - httpsTestUrl: "https://smartlog.work/prodapi4test/", - url: "http://139.198.18.188:8083/", + httpsUrl: "https://logapi.smartlog.work/", + // httpsUrl: "http://139.198.18.188:8083/", // url: "http://127.0.0.1:8083/", - // httpsUrl: "http://127.0.0.1:8083/", + //httpsUrl: "http://127.0.0.1:8083/", openid: null, - indexCount:1 - }, + indexCount:1, + nickName:"", + userName:"", + role:"", + devcode:"" + } }) diff --git a/miniprogram/app.json b/miniprogram/app.json index d23f798..2b6db76 100644 --- a/miniprogram/app.json +++ b/miniprogram/app.json @@ -1,15 +1,17 @@ { "cloud": true, "pages": [ + "pages/login/login", "pages/indexapp/indexapp", "pages/earth/earth", "pages/applog/applog", "pages/addDevice/addDevice", "pages/addDevicelog/addDeviceLog", - "pages/searchLog/searchLog" + "pages/searchLog/searchLog", + "pages/notice/notice" ], "window": { - "backgroundColor": "#F6F6F6", + "backgroundColor": "#E6D480", "backgroundTextStyle": "light", "navigationBarBackgroundColor": "#FFCF00", "navigationBarTitleText": "智慧施工", @@ -46,11 +48,11 @@ "desc": "你的位置信息将用于小程序位置接口的效果展示" } }, + "requiredPrivateInfos": ["getLocation", "chooseLocation"], "networkTimeout": { "request": 30000, "connectSocket": 30000, "uploadFile": 30000, "downloadFile": 30000 - }, - "style": "v2" + } } \ No newline at end of file diff --git a/miniprogram/images/applocat.png b/miniprogram/images/applocat.png new file mode 100644 index 0000000..fe49f54 --- /dev/null +++ b/miniprogram/images/applocat.png Binary files differ diff --git a/miniprogram/images/back.png b/miniprogram/images/back.png new file mode 100644 index 0000000..32ac82d --- /dev/null +++ b/miniprogram/images/back.png Binary files differ diff --git a/miniprogram/images/bottom.png b/miniprogram/images/bottom.png new file mode 100644 index 0000000..d910e98 --- /dev/null +++ b/miniprogram/images/bottom.png Binary files differ diff --git a/miniprogram/images/header.png b/miniprogram/images/header.png new file mode 100644 index 0000000..6ea222e --- /dev/null +++ b/miniprogram/images/header.png Binary files differ diff --git a/miniprogram/images/login.png b/miniprogram/images/login.png index 8b73cc0..6471c46 100644 --- a/miniprogram/images/login.png +++ b/miniprogram/images/login.png Binary files differ diff --git a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss index 5a591fb..c9c35b5 100644 --- a/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss +++ b/miniprogram/miniprogram_npm/@vant/weapp/button/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:100%;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:100%}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file +@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:650rpx;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:600rpx}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file diff --git a/miniprogram/pages/addDevice/addDevice.js b/miniprogram/pages/addDevice/addDevice.js index 2783674..78f00b7 100644 --- a/miniprogram/pages/addDevice/addDevice.js +++ b/miniprogram/pages/addDevice/addDevice.js @@ -1,5 +1,7 @@ // miniprogram/pages/addDevice/addDevice.js // import WxValidate from '../../utils/WxValidate.js' +var QQMapWX = require('../../libs/qqmap-wx-jssdk.js'); +var qqmapsdk; var app = getApp() Page({ @@ -11,32 +13,10 @@ canvasWidth: '', longitude: '', latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], + option1: [], personoption1: [], projectoption: [], + devtypeList:[], show: false, form: { devcode: "", @@ -59,7 +39,10 @@ project: "", area: "", street: "", - wellname: "" + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '', }, fileList: [] }, @@ -117,12 +100,14 @@ var that = this; //初始化表单内容为上次填写值 var cacheForms = wx.getStorageSync('cacheList') - if (cacheForms) { + cacheForms.photopath1='' + cacheForms.photopath2='' + cacheForms.photopath3='' + that.data.fileList=[] that.setData({ form: cacheForms, devcode: cacheForms.devcode, - }) } var form = that.data.form @@ -155,55 +140,89 @@ } }) + +//获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + that.setData({ + option1: welltypeArr + }) + } + } +}) + + //获取人员下拉列表 - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/getUser", + data:{ + tips:'repair' }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data.code == 200) { + var users = res.data.data + var personArr = []; + for (var i = 0; i < users.length; i++) { + var person = { + text: users[i].name, + value: users[i].name + }; + personArr.push(person); + } + that.setData({ + personoption1: personArr + }) } - that.setData({ - personoption1: personArr - }) } - }).catch(err => { - console.error(err); - }) + }) + - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - that.setData({ - projectoption: projectArr - }) + success(res){ + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); + } + that.setData({ + projectoption: projectArr + }) + } } - }).catch(err => { - console.error(err); - }) + }) + var installtime = 'form.installtimeFmt'; var dateNow = this.formatDate(); this.setData({ @@ -211,8 +230,40 @@ installtimeFmt: dateNow, [installtime]: dateNow, }); + + + + /** + * 获取设备类型下拉列表 + */ + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/deviceType", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var TypeList = res.data.data + var typeArr = []; + for (var i = 0; i < TypeList.length; i++) { + var type = { + text: TypeList[i].productName, + value: TypeList[i].productName + }; + typeArr.push(type); + } + that.setData({ + devtypeList: typeArr + }) + } + } + }) }, + + + /** * 生命周期函数--监听页面初次渲染完成 */ @@ -280,29 +331,7 @@ }, - - //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 - drawText: function (ctx, str, leftWidth, initHeight, titleHeight, canvasWidth) { - var lineWidth = 0; - var lastSubStrIndex = 0; //每次开始截取的字符串的索引 - for (let i = 0; i < str.length; i++) { - lineWidth += ctx.measureText(str[i]).width; - if (lineWidth > canvasWidth) { - ctx.fillText(str.substring(lastSubStrIndex, i), leftWidth, initHeight); //绘制截取部分 - initHeight = initHeight + leftWidth * 2; //22为字体的高度 - lineWidth = 0; - lastSubStrIndex = i; - // titleHeight += 40; - } - if (i == str.length - 1) { //绘制剩余部分 - ctx.fillText(str.substring(lastSubStrIndex, i + 1), leftWidth, initHeight); - } - } - // // 标题border-bottom 线距顶部距离 - // titleHeight = titleHeight + 10; - // return titleHeight - }, - + //验证表单 formValidate() { if (this.data.form.devcode == "") { @@ -312,27 +341,20 @@ }) return false } - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } if (this.data.form.wellcode == "") { wx.showToast({ icon: 'none', @@ -348,22 +370,10 @@ }) return false } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null) { + + if (this.data.form.installperson == "") { wx.showToast({ icon: 'none', title: '安装人员不能为空!', @@ -408,56 +418,90 @@ } return true; }, + //提交表单 formSubmit: function (event) { + console.log(this.data.form) + //表单参数验证 if (!this.formValidate()) { return false; } var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDevice', + //验证设备编号长度 + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/getDevTypeLength", data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceAdd/add" + code: encodeURI(this.data.form.devicetype) }, - }).then(res => { - if (res.result.code == 500) { - wx.showToast({ - title: '设备编号已安装!', - }) - } else if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - //用于回显 - wx.setStorageSync('cacheList', that.data.form) - //提交成功后提示用户操作 - if (res.confirm) { - wx.switchTab({ - url: '../earth/earth' - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (""==res.data.data ||res.data.data == that.data.form.devcode.length) { + that.saveDevice() + } else { //编号位数不对提示 + wx.showToast({ + icon: 'none', + title: '设备编号位数不对!', + duration: 1000 + }) + return false + } } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "提交失败", - }) }) }, + + //保存设备基本信息 + saveDevice() { + var that = this; + //设置照片路径 + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopathForm = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopathForm]: fileList[i].url.split("static/")[1] + }) + } + //表单提交 + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 500) { + wx.showToast({ + title: '设备编号已安装!', + }) + } else if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + //用于回显 + wx.setStorageSync('cacheList', that.data.form) + //提交成功后提示用户操作 + if (res.confirm) { + wx.switchTab({ + url: '../earth/earth' + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } + }, + fail(err) { + wx.showToast({ + title: '提交失败!', + }) + } + }) + }, + + //input 输入框设置值 confirm(event) { var that = this; var formValue = event.detail.value; @@ -466,8 +510,30 @@ that.setData({ [fromN]: formValue }) + //若输入是设备编号,自动获取设备类型 + if('devcode'==formName){ + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", + data: { + devcode: formValue, + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + that.setData({ + [formDevicetype]: res.data + }); + } + } + }) + } }, + //扫描设备获取编号和设备类型 scan() { var _this = this; wx.scanCode({ @@ -477,23 +543,28 @@ _this.setData({ [formdevcode]: devcode }); - wx.cloud.callFunction({ - name: 'findModeCode', + wx.request({ + method: 'POST', + url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode", data: { devcode: devcode, - url: app.globalData.url + "appDeviceAdd/findModeCodeByCode" }, - }).then(res => { - if (res.result) { - var formDevicetype = 'form.devicetype' - _this.setData({ - [formDevicetype]: res.result - }); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var formDevicetype = 'form.devicetype' + _this.setData({ + [formDevicetype]: res.data + }); + } } }) } }) }, + //粘贴经纬度 paste() { var _this = this; wx.getClipboardData({ @@ -510,9 +581,11 @@ longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), }); + _this.showAddress(_this.data.form.longitude,_this.data.form.latitude,_this) } }) }, + //设置经类型 selectValue(value) { var that = this; @@ -521,6 +594,16 @@ [wellType]: value.detail }) }, + + //设置设备类型 + selectDevType(event) { + var that = this; + var devtype = 'form.devicetype'; + that.setData({ + [devtype]: event.detail + }) + }, + //设置运维人员 selectpersonValue(event) { var that = this; var installPerson = 'form.installperson'; @@ -528,6 +611,7 @@ [installPerson]: event.detail }) }, + //设置项目 selectprojectValue(event) { var that = this; var project = 'form.project'; @@ -535,8 +619,41 @@ [project]: event.detail }) }, + showAddress :function(longitude, latitude, self) { + // 实例化腾讯地图API核心类 + qqmapsdk = new QQMapWX({ + key: 'BGPBZ-C5O3P-ROUDR-LWC4J-63EKH-V5FRX'//此处使用你自己申请的key + }) + // 腾讯地图调用接口 + qqmapsdk.reverseGeocoder({ + location: { + latitude: latitude, + longitude: longitude + }, + success: function (res) { + self.setData({ + 'form.area':res.result.address.slice(0,res.result.address.indexOf('区')+1), + 'form.street':res.result.address.slice(res.result.address.indexOf('区')+1) + }) + }, + fail: function (res) { + console.log(res); + }, + complete: function (res) { + } + }); + }, + //上传照片 afterRead(event) { var _this = this; + if (_this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '请先填写设备编号!\r\n否则水印中无编号', + duration: 2000 + }) + return false + } const { file } = event.detail; @@ -576,78 +693,8 @@ }) } }) - // 压缩图片 - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // //获取图片尺寸 - // wx.getImageInfo({ - // src: convertpath, - // success(res) { - // _this.setData({ - // canvasHeight: res.height, - // canvasWidth: res.width - // }) - // var ctx = wx.createCanvasContext('firstCanvas') - - // //将图片src放到cancas内,宽高为图片大小 - // ctx.drawImage(convertpath, 0, 0, res.width, res.height) - // //将声明的时间放入canvas - // ctx.setFontSize(30 * (res.width / 750)) //注意:设置文字大小必须放在填充文字之前,否则不生效 - // ctx.setFillStyle('blue') - // var text = "编号:" + _this.data.form.devcode + "\n经度:" + _this.data.form.longitude + "\n纬度:" + _this.data.form.latitude - // // _this.drawText(ctx,text,20, 70, 5, res.width) - // _this.drawText(ctx, text, 15 * (res.width / 750), 70 * (res.width / 750), 5, res.width) - - // // ctx.fillText(text, 0, 40) - // // ctx.strokeText(_this.data.form.devcode, 0, 30) - // //生成水印图 - // ctx.draw(false, function () { - // wx.canvasToTempFilePath({ - // canvasId: 'firstCanvas', - // success: (res) => { - // wx.compressImage({ - // src: res.tempFilePath, - // quality: 25, - // success: function (res) { - // //上传照片至服务器 - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: res.tempFilePath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // } - // }) - // //// - // } - // }) - // }) - // } - // }) - // } - // }); }, + //删除照片 deletePhoto(event) { var image_index = event.detail.index var fileList_new = this.data.fileList; diff --git a/miniprogram/pages/addDevice/addDevice.wxml b/miniprogram/pages/addDevice/addDevice.wxml index b0977e2..f12c254 100644 --- a/miniprogram/pages/addDevice/addDevice.wxml +++ b/miniprogram/pages/addDevice/addDevice.wxml @@ -5,18 +5,30 @@ - + + + + + + + + + + + + + - - + + - - - + + + @@ -29,13 +41,13 @@ - + - + - + - + @@ -54,8 +66,7 @@ - - + @@ -68,8 +79,8 @@ - - + + - 保存 + 保存 \ No newline at end of file diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.js b/miniprogram/pages/addDevicelog/addDeviceLog.js index cdec71b..a0dc6da 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.js +++ b/miniprogram/pages/addDevicelog/addDeviceLog.js @@ -3,681 +3,665 @@ var app = getApp(); Page({ - /** - * 页面的初始数据 - */ - data: { - pageName: '', - showMask: false, - today: new Date().getTime(), - longitude: '', - latitude: '', - photopath1: '', - photopath2: '', - photopath3: '', - option1: [{ - text: '雨水井', - value: "1" - }, - { - text: '污水井', - value: "2" - }, - { - text: '燃气井', - value: "3" - }, - { - text: '热力井', - value: "4" - }, - { - text: '电力井', - value: "5" - }, - ], - personoption1: [], - projectoption: [], - devcode: "", - deviceMode: "", - installtimeFmt: '', - show: false, - form: { - devcode: "", - wellcode: "", - welltype: "", - welldepth: "", - installheigt: "", - installperson: "", - installtimeFmt: "", - photopath: "", - factory: "", - workmsg: "", - position: "", - description: "", - longitude: "", - latitude: "", - longitude84: "", - latitude84: "", - devicetype: "", - project: "", - area: "", - street: "", - wellname: "" - }, - fileList: [], - detail: "" - }, + /** + * 页面的初始数据 + */ + data: { + pageName: '', + showMask: false, + today: new Date().getTime(), + longitude: '', + latitude: '', + option1: [], + personoption1: [], + projectoption: [], + devcode: "", + deviceMode: "", + installtimeFmt: '', + show: false, + form: { + devcode: "", + wellcode: "", + welltype: "", + welldepth: "", + installheigt: "", + installperson: "", + installtimeFmt: "", + photopath: "", + factory: "", + workmsg: "", + position: "", + description: "", + longitude: "", + latitude: "", + longitude84: "", + latitude84: "", + devicetype: "", + project: "", + area: "", + street: "", + wellname: "", + photopath1: '', + photopath2: '', + photopath3: '' + }, + fileList: [], + detail: "", + markers: [{ + id: 100, + // iconPath: "../../images/point.png", + latitude: '', + longitude: '', + // label:'1', + width: 25, + height: 35 + }], + }, - onDisplay() { - this.setData({ - show: true - }); - }, - onClose() { - this.setData({ - show: false - }); - }, - formatDate() { - var date = new Date(); - // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; - var seperator1 = "-"; - var month = date.getMonth() + 1; - var strDate = date.getDate(); - var hour = date.getHours() - var minute = date.getMinutes() - var second = date.getSeconds() - month = month > 9 ? month : "0" + month; - strDate = strDate > 9 ? strDate : "0" + strDate; - hour = hour > 9 ? hour : "0" + hour; - minute = minute > 9 ? minute : "0" + minute; - second = second > 9 ? second : "0" + second; - var currentdate = - date.getFullYear() + - seperator1 + - month + - seperator1 + - strDate + - " " + - hour + ":" + - minute + ":" + - second; - return currentdate; + onDisplay() { + this.setData({ + show: true + }); + }, + onClose() { + this.setData({ + show: false + }); + }, + formatDate() { + var date = new Date(); + // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; + var seperator1 = "-"; + var month = date.getMonth() + 1; + var strDate = date.getDate(); + var hour = date.getHours() + var minute = date.getMinutes() + var second = date.getSeconds() + month = month > 9 ? month : "0" + month; + strDate = strDate > 9 ? strDate : "0" + strDate; + hour = hour > 9 ? hour : "0" + hour; + minute = minute > 9 ? minute : "0" + minute; + second = second > 9 ? second : "0" + second; + var currentdate = + date.getFullYear() + + seperator1 + + month + + seperator1 + + strDate + + " " + + hour + ":" + + minute + ":" + + second; + return currentdate; - }, - onConfirm(event) { - var installtime = 'form.installtimeFmt'; - this.setData({ - show: false, - installtimeFmt: this.formatDate(event.detail), - [installtime]: this.formatDate(event.detail), - }); - }, + }, + onConfirm(event) { + var installtime = 'form.installtimeFmt'; + this.setData({ + show: false, + installtimeFmt: this.formatDate(event.detail), + [installtime]: this.formatDate(event.detail), + }); + }, - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - var _this = this; - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" - }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); - } - _this.setData({ - personoption1: personArr - }) + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + var _this = this; + _this.setData({ + 'markers[0].latitude': Number(wx.getStorageSync('resultObject').latitude) , + 'markers[0].longitude': Number(wx.getStorageSync('resultObject').longitude), + // 'markers[0].label':'10', + 'markers[0].width': 18, + 'markers[0].id':1, + 'markers[0].height': 30, + latitude:Number(wx.getStorageSync('resultObject').latitude), + longitude:Number(wx.getStorageSync('resultObject').longitude) + }) + //获取人员下拉列表 + // wx.request({ + // method: "POST", + // url: app.globalData.httpsUrl + "deviceType/getUser", + // data:{ + // tips:'repair' + // }, + // header: { + // 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + // }, + // success(res) { + // if (res.data.code == 200) { + // var users = res.data.data + // var personArr = []; + // for (var i = 0; i < users.length; i++) { + // var person = { + // text: users[i].name, + // value: users[i].name + // }; + // personArr.push(person); + // } + // _this.setData({ + // personoption1: personArr + // }) + // } + // } + // }) + //获取项目下拉列表 + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); } - }).catch(err => { - console.error(err); - }) - - - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" - }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); - } - _this.setData({ - projectoption: projectArr - }) - } - }).catch(err => { - console.error(err); - }) - - if (options.pageName) { - this.setData({ - pageName: options.pageName - }) - } - - if (options.detail) { - - var formObject = JSON.parse(options.detail); _this.setData({ - form: formObject, - detail: options.detail + projectoption: projectArr }) - - _this.setData({ - ['form.installperson']: "", - ['form.installtimeFmt']: "", - ['form.workmsg']: "", - ['form.description']: "" - }) - - const { - fileList = [] - } = _this.data; - if (formObject.photopath1 != "") { - var file1 = { - url: app.globalData.url + "static/" + formObject.photopath1 - } - fileList.push(file1) - } - if (formObject.photopath2 != "") { - var file2 = { - url: app.globalData.url + "static/" + formObject.photopath2 - } - fileList.push(file2) - } - if (formObject.photopath3 != "") { - var file3 = { - url: app.globalData.url + "static/" + formObject.photopath3 - } - fileList.push(file3) - } - - _this.setData({ - fileList - }); } - var installtime = 'form.installtimeFmt'; - var dateNow = this.formatDate(); - this.setData({ - installtimeFmt: dateNow, - [installtime]: dateNow, - }); - }, + } + }) - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { + //获取井类型下拉列表 +wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/getWellTypeList", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res){ + if (res.data) { + var welltype = res.data + var welltypeArr = []; + for (var i = 0; i < welltype.length; i++) { + var type = { + text: welltype[i].text, + value: welltype[i].value + }; + welltypeArr.push(type); + } + _this.setData({ + option1: welltypeArr + }) + } + } +}) - }, + //跳转时带入参数返回哪页 + if (options.pageName) { + this.setData({ + pageName: options.pageName + }) + } + //跳转时带入参数设备的安装信息 + if (wx.getStorageSync('resultObject')) { + var formObject = wx.getStorageSync('resultObject') + _this.setData({ + form: formObject, + detail: formObject + }) - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { + _this.setData({ + ['form.installperson']: app.globalData.userName, + ['form.installtimeFmt']: "", + ['form.workmsg']: "", + ['form.description']: "" + }) - }, + const { + fileList = [] + } = _this.data; + if (formObject.photopath1 != "") { + var file1 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath1 + } + fileList.push(file1) + } + if (formObject.photopath2 != "") { + var file2 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath2 + } + fileList.push(file2) + } + if (formObject.photopath3 != "") { + var file3 = { + url: app.globalData.httpsUrl + "static/" + formObject.photopath3 + } + fileList.push(file3) + } + _this.setData({ + fileList + }); + } + var installtime = 'form.installtimeFmt'; + var dateNow = this.formatDate(); + this.setData({ + installtimeFmt: dateNow, + [installtime]: dateNow, + }); + }, - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, - }, + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + wx.removeStorageSync('resultObject') + }, - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, - }, + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { + }, - }, + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { + }, - }, + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { + }, - }, + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + }, - /** - * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true - **/ + /** + * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true + **/ - isNumber: function (val) { + isNumber: function (val) { - var regPos = /^[0-9]*$/; //非负浮点数 - var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数 - if (regPos.test(val) || regNeg.test(val)) { - return false; - } else { - return true; - } + var regPos = /^[0-9]*$/; //非负浮点数 + var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数 + if (regPos.test(val) || regNeg.test(val)) { + return false; + } else { + return true; + } - }, + }, - formValidate() { + formValidate() { - if (this.data.form.devcode == "") { - wx.showToast({ - icon: 'none', - title: '设备编号不能为空!', - }) - return false - } - if (this.data.form.area == "") { - wx.showToast({ - icon: 'none', - title: '区不能为空!', - }) - return false - } - if (this.data.form.street == "") { - wx.showToast({ - icon: 'none', - title: '街道不能为空!', - }) - return false - } - if (this.data.form.wellcode == "") { - wx.showToast({ - icon: 'none', - title: '井编号不能为空!', - }) - return false - } - if (this.data.form.devicetype == "") { - wx.showToast({ - icon: 'none', - title: '设备类型不能为空!', - }) - return false - } - if (this.data.form.longitude == "" || this.data.form.latitude == "") { - wx.showToast({ - icon: 'none', - title: '经纬度不能为空!', - }) - return false - } + if (this.data.form.devcode == "") { + wx.showToast({ + icon: 'none', + title: '设备编号不能为空!', + }) + return false + } + if (this.data.form.wellcode == "") { + wx.showToast({ + icon: 'none', + title: '井编号不能为空!', + }) + return false + } + if (this.data.form.devicetype == "") { + wx.showToast({ + icon: 'none', + title: '设备类型不能为空!', + }) + return false + } + if (this.data.form.longitude == "" || this.data.form.latitude == "") { + wx.showToast({ + icon: 'none', + title: '经纬度不能为空!', + }) + return false + } - if (this.data.form.position == "") { - wx.showToast({ - icon: 'none', - title: '位置描述不能为空!', - }) - return false - } - if (this.data.form.installperson == null || - this.data.form.installperson == '') { - wx.showToast({ - icon: 'none', - title: '运维人员不能为空!', - }) - return false - } - if (this.data.form.project == "") { - wx.showToast({ - icon: 'none', - title: '所属项目不能为空!', - }) - return false - } + if (this.data.form.position == "") { + wx.showToast({ + icon: 'none', + title: '位置描述不能为空!', + }) + return false + } + if (this.data.form.installperson == null || + this.data.form.installperson == '') { + wx.showToast({ + icon: 'none', + title: '运维人员不能为空!', + }) + return false + } + if (this.data.form.project == "") { + wx.showToast({ + icon: 'none', + title: '所属项目不能为空!', + }) + return false + } - if (this.data.form.welldepth != null) { - if (this.isNumber(this.data.form.welldepth)) { - wx.showToast({ - icon: 'none', - title: '井深必须为数值!', - }) - return false - } - } - if (this.data.form.installheigt != null) { - if (this.isNumber(this.data.form.installheigt)) { - wx.showToast({ - icon: 'none', - title: '到井口距离必须为数值!', - }) - return false - } - } - - return true; - }, - - changeMsg: function () { - var formNew = this.data.form; - var formOld = JSON.parse(this.data.detail); - var descpNew = ""; - if (formNew.devcode != formOld.devcode) { - descpNew += "修改设备编号,原编号:" + formOld.devcode + ",新编号:" + formNew.devcode + ";" - } - if (formNew.devicetype != formOld.devicetype) { - descpNew += "修改设备类型,原设备类型:" + formOld.devicetype + ",新设备类型:" + formNew.devicetype + ";" - } - if (formNew.area != formOld.area) { - descpNew += "修改区,原区:" + formOld.area + ",新区:" + formNew.area + ";" - } - if (formNew.street != formOld.street) { - descpNew += "修改街道,原街道:" + formOld.street + ",新街道:" + formNew.street + ";" - } - if (formNew.wellname != formOld.wellname) { - descpNew += "修改井名称,原井名称:" + formOld.wellname + ",新井名称:" + formNew.wellname + ";" - } - if (formNew.factory != formOld.factory) { - descpNew += "修改权属单位,原权属单位:" + formOld.factory + ",新权属单位:" + formNew.factory + ";" - } - if (formNew.installheigt != formOld.installheigt) { - descpNew += "修改井口距离,原井口距离:" + formOld.installheigt + ",新井口距离:" + formNew.installheigt + ";" - } - if (formNew.installperson != formOld.installperson) { - descpNew += "修改运维人员,原运维人员:" + formOld.installperson + ",新运维人员:" + formNew.installperson + ";" - } - if (formNew.latitude != formOld.latitude) { - descpNew += "修改纬度,原纬度:" + formOld.latitude + ",新纬度:" + formNew.latitude + ";" - } - if (formNew.longitude != formOld.longitude) { - descpNew += "修改经度,原经度:" + formOld.longitude + ",新经度:" + formNew.longitude + ";" - } - if (formNew.position != formOld.position) { - descpNew += "修改位置描述,原位置:" + formOld.position + ",新位置:" + formNew.position + ";" - } - if (formNew.wellcode != formOld.wellcode) { - descpNew += "修改井编号,原编号:" + formOld.wellcode + ",新编号:" + formNew.wellcode + ";" - } - if (formNew.welldepth != formOld.welldepth) { - descpNew += "修改井深,原井深:" + formOld.welldepth + ",新井深:" + formNew.welldepth + ";" - } - if (formNew.welltype != formOld.welltype) { - descpNew += "修改井类型,原井类型:" + formOld.welltype + ",新井类型:" + formNew.welltype + ";" - } - if (formNew.project != formOld.project) { - descpNew += "修改所属项目,原项目:" + formOld.project + ",新项目:" + formNew.project + ";" - } - if (this.data.photopath1 != formOld.photopath1 || - this.data.photopath2 != formOld.photopath2 || - this.data.photopath3 != formOld.photopath3) { - descpNew += "修改照片;" - } - if ("" != formNew.description) { - descpNew += formNew.description; - } - this.setData({ - ['form.description']: descpNew + if (this.data.form.welldepth != null) { + if (this.isNumber(this.data.form.welldepth)) { + wx.showToast({ + icon: 'none', + title: '井深必须为数值!', }) - }, + return false + } + } + if (this.data.form.installheigt != null) { + if (this.isNumber(this.data.form.installheigt)) { + wx.showToast({ + icon: 'none', + title: '到井口距离必须为数值!', + }) + return false + } + } - formSubmit: function (event) { + return true; + }, - if (!this.formValidate()) { - return false; - } - this.changeMsg(); - var that = this; - var fileList = that.data.fileList; - for (var i = 0; i < fileList.length; i++) { - var photopath = 'photopath' + [Number(i) + 1] - this.setData({ - [photopath]: fileList[i].url.split("static/")[1] - }) - } - wx.cloud.callFunction({ - name: 'addDeviceLog', - data: { - device: that.data.form, - photopath1: that.data.photopath1, - photopath2: that.data.photopath2, - photopath3: that.data.photopath3, - url: app.globalData.url + "appDeviceLog/add" - }, - }).then(res => { - // var resultObj=JSON.parse(res.result); - if (res.result.code == 200) { - wx.showModal({ - content: '提交成功,是否返回?', - success: function (res) { - if (res.confirm) { - wx.switchTab({ - url: that.data.pageName - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) - } - }).catch(err => { - console.error(err) - wx.showToast({ - title: "提交失败", - }) - }) - }, - confirm(event) { - var that = this; - var formValue = event.detail.value; - var formName = event.target.dataset.id; - var fromN = 'form.' + [formName]; - that.setData({ - [fromN]: formValue - }) - }, + //获取与上次修改的信息 + changeMsg: function () { + var formNew = this.data.form; + console.log(this.data.detail) + var formOld = JSON.parse(this.data.detail); + var descpNew = ""; + if (formNew.devcode != formOld.devcode) { + descpNew += "修改设备编号,原值:" + formOld.devcode + ",新值:" + formNew.devcode + ";" + } + if (formNew.devicetype != formOld.devicetype) { + descpNew += "修改设备类型,原值:" + formOld.devicetype + ",新值:" + formNew.devicetype + ";" + } + if (formNew.area != formOld.area) { + descpNew += "修改区,原值:" + formOld.area + ",新值:" + formNew.area + ";" + } + if (formNew.street != formOld.street) { + descpNew += "修改街道,原值:" + formOld.street + ",新值:" + formNew.street + ";" + } + if (formNew.wellname != formOld.wellname) { + descpNew += "修改井名称,原值:" + formOld.wellname + ",新值:" + formNew.wellname + ";" + } + if (formNew.factory != formOld.factory) { + descpNew += "修改权属单位,原值:" + formOld.factory + ",新值:" + formNew.factory + ";" + } + if (formNew.installheigt != formOld.installheigt) { + descpNew += "修改井口距离,原值:" + formOld.installheigt + ",新值:" + formNew.installheigt + ";" + } + if (formNew.installperson != formOld.installperson) { + descpNew += "修改运维人员,原值:" + formOld.installperson + ",新值:" + formNew.installperson + ";" + } + if (formNew.latitude != formOld.latitude) { + descpNew += "修改纬度,原值:" + formOld.latitude + ",新值:" + formNew.latitude + ";" + } + if (formNew.longitude != formOld.longitude) { + descpNew += "修改经度,原值:" + formOld.longitude + ",新值:" + formNew.longitude + ";" + } + if (formNew.position != formOld.position) { + descpNew += "修改位置描述,原值:" + formOld.position + ",新值:" + formNew.position + ";" + } + if (formNew.wellcode != formOld.wellcode) { + descpNew += "修改井编号,原值:" + formOld.wellcode + ",新值:" + formNew.wellcode + ";" + } + if (formNew.welldepth != formOld.welldepth) { + descpNew += "修改井深,原值:" + formOld.welldepth + ",新值:" + formNew.welldepth + ";" + } + if (formNew.welltype != formOld.welltype) { + descpNew += "修改井类型,原值:" + formOld.welltype + ",新值:" + formNew.welltype + ";" + } + if (formNew.project != formOld.project) { + descpNew += "修改所属项目,原值:" + formOld.project + ",新值:" + formNew.project + ";" + } + if (this.data.form.photopath1 != formOld.photopath1 || + this.data.form.photopath2 != formOld.photopath2 || + this.data.form.photopath3 != formOld.photopath3) { + descpNew += "修改照片;" + } + if ("" != formNew.description) { + descpNew += formNew.description; + } + this.setData({ + ['form.description']: descpNew + }) + }, - scan() { + //提交表单 + formSubmit: function (event) { - wx.scanCode({ - success(res) { - console.log(res) - } - }) + //表单验证 + if (!this.formValidate()) { + return false; + } + //自动生成修改内容 + this.changeMsg(); + //提交权限限制(只有施工人员能修改) + if(app.globalData.role!='repair'){ + wx.showToast({ + icon: 'none', + title: '无权限修改', + duration:2000 + }) + return false + } + var that = this; + var fileList = that.data.fileList; + for (var i = 0; i < fileList.length; i++) { + var photopath = 'form.photopath' + [Number(i) + 1] + this.setData({ + [photopath]: fileList[i].url.split("static/")[1] + }) + } + delete that.data.form.installtime + delete that.data.form.createtime + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/add", + data: that.data.form, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - paste() { - var _this = this; - wx.getClipboardData({ - success: function (res) { - var longitude = 'form.longitude'; - var latitude = 'form.latitude'; - var longitude84 = 'form.longitude84'; - var latitude84 = 'form.latitude84'; - _this.setData({ - [longitude]: parseFloat(res.data.split(",", 4)[1]).toFixed(6), - [latitude]: parseFloat(res.data.split(",", 4)[0]).toFixed(6), - [longitude84]: "" == (res.data.split(",", 4)[3]) ? "" : parseFloat(res.data.split(",", 4)[3]).toFixed(6), - [latitude84]: "" == (res.data.split(",", 4)[2]) ? "" : parseFloat(res.data.split(",", 4)[2]).toFixed(6), - longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), - latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), - }); - } - }) - }, - selectValue(value) { - var that = this; - var wellType = 'form.welltype'; - that.setData({ - [wellType]: value.detail - }) - }, - selectpersonValue(event) { - var that = this; - var installPerson = 'form.installperson'; - that.setData({ - [installPerson]: event.detail - }) - }, - selectprojectValue(event) { - var that = this; - var project = 'form.project'; - that.setData({ - [project]: event.detail, - showMask: true - }) - }, - open() { - this.setData({ - showMask: true - }) - }, - close() { - this.setData({ - showMask: false - }) - }, - afterRead(event) { - var _this = this; - const { - file - } = event.detail; - const { - fileList = [] - } = _this.data; - var convertpath = ""; - wx.compressImage({ - src: event.detail.file.path, - quality: 25, - success: function (res) { - convertpath = res.tempFilePath; - wx.uploadFile({ - url: app.globalData.httpsUrl + "appDeviceAdd/fileUploadMarker", - filePath:convertpath, - name: 'file', - formData: { - 'text': "编号:" + _this.data.form.devcode + "经度:" + _this.data.form.longitude + "纬度:" + _this.data.form.latitude - }, - header: { - "Content-Type": "multipart/form-data", - 'accept': 'application/json', - }, - success(res) { - if (res.data) { - var url = JSON.parse(res.data); - fileList.push({ - ...file, - url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - }); - _this.setData({ - fileList - }); - } - } + success(res) { + if (res.data.code == 200) { + wx.showModal({ + content: '提交成功,是否返回?', + success: function (res) { + if (res.confirm) { + wx.switchTab({ + url: that.data.pageName }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') } - }) - // wx.compressImage({ - // src: event.detail.file.path, - // quality: 25, - // success: function (res) { - // convertpath = res.tempFilePath; - // // var base64 = "data:image/png;base64," + wx.getFileSystemManager().readFileSync(convertpath, 'base64'); - // wx.uploadFile({ - // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // filePath: convertpath, - // name: 'file', - // // formData: { - // // 'devcode': '642019010001' - // // }, - // header: { - // "Content-Type": "multipart/form-data", - // 'accept': 'application/json', - // }, - // success(res) { - // if (res.data) { - // var url = JSON.parse(res.data); - // fileList.push({ - // ...file, - // url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") - // }); - // _this.setData({ - // fileList - // }); - // } - // } - // }) - // // wx.cloud.callFunction({ - // // name: 'uploadFile', - // // data: { - // // url: app.globalData.httpsUrl + "appDeviceAdd/fileUpload", - // // fileBase64: base64 - // // }, - // // success: function (res) { - // // if (res.result) { - // // fileList.push({ - // // ...file, - // // url: app.globalData.url + "static/" + res.result.data.replace(/\\/g, "/") - // // }); - // // _this.setData({ - // // fileList - // // }); - // // } - // // }, - // // complete: res => { - // // }, - // // }) - // } - // }); + } + }) + } + }, + fail(err) { + wx.showToast({ + title: "提交失败", + }) + } + }) + }, + //报存录入的input信息 + confirm(event) { + var that = this; + var formValue = event.detail.value; + var formName = event.target.dataset.id; + var fromN = 'form.' + [formName]; + that.setData({ + [fromN]: formValue + }) + }, + + //扫码 + scan() { + + wx.scanCode({ + success(res) { + console.log(res) + } + }) + }, + //粘贴经纬度 + paste() { + var _this = this; + wx.getClipboardData({ + success: function (res) { + var longitude = 'form.longitude'; + var latitude = 'form.latitude'; + var longitude84 = 'form.longitude84'; + var latitude84 = 'form.latitude84'; + _this.setData({ + [longitude]: parseFloat(res.data.split(",", 4)[1]).toFixed(6), + [latitude]: parseFloat(res.data.split(",", 4)[0]).toFixed(6), + [longitude84]: "" == (res.data.split(",", 4)[3]) ? "" : parseFloat(res.data.split(",", 4)[3]).toFixed(6), + [latitude84]: "" == (res.data.split(",", 4)[2]) ? "" : parseFloat(res.data.split(",", 4)[2]).toFixed(6), + longitude: parseFloat(res.data.split(",", 4)[1]).toFixed(6), + latitude: parseFloat(res.data.split(",", 4)[0]).toFixed(6), + }); + } + }) + }, + selectValue(value) { + var that = this; + var wellType = 'form.welltype'; + that.setData({ + [wellType]: value.detail + }) + }, + //运维人员默认为登录人 + // selectpersonValue(event) { + // var that = this; + // var installPerson = 'form.installperson'; + // that.setData({ + // [installPerson]: event.detail + // }) + // }, + selectprojectValue(event) { + var that = this; + var project = 'form.project'; + that.setData({ + [project]: event.detail, + showMask: true + }) + }, + + open() { + this.setData({ + showMask: true + }) + }, + //隐藏textarea,防止遮挡 + close() { + this.setData({ + showMask: false + }) + }, + //上传照片 + afterRead(event) { + var _this = this; + const { + file + } = event.detail; + const { + fileList = [] + } = _this.data; + var convertpath = ""; + wx.compressImage({ + src: event.detail.file.path, + quality: 25, + success: function (res) { + convertpath = res.tempFilePath; + wx.uploadFile({ + url: app.globalData.httpsUrl + "appDeviceAdd/fileUploadMarker", + filePath: convertpath, + name: 'file', + formData: { + 'text': "编号:" + _this.data.form.devcode + "经度:" + _this.data.form.longitude + "纬度:" + _this.data.form.latitude }, - deletePhoto(event) { - var that = this - var image_index = event.detail.index - var fileList_new = that.data.fileList; - wx.showModal({ - content: '确定删除照片?', - success: function (res) { - if (res.confirm) { - fileList_new.splice(image_index, 1); - that.setData({ - fileList: fileList_new - }) - wx.cloud.callFunction({ - name: 'deletePhoto', - data: { - url: app.globalData.url + "appDeviceLog/deletePhoto", - devcode: that.data.form.devcode, - pathIndex: image_index - }, - success: function (res) {}, - complete: res => {}, - }) - } else { //这里是点击了取消以后 - console.log('用户点击取消') - } - } - }) + header: { + "Content-Type": "multipart/form-data", + 'accept': 'application/json', }, - }) \ No newline at end of file + success(res) { + if (res.data) { + var url = JSON.parse(res.data); + fileList.push({ + ...file, + url: app.globalData.httpsUrl + "static/" + url.data.replace(/\\/g, "/") + }); + _this.setData({ + fileList + }); + } + } + }) + } + }) + }, + //删除照片 + deletePhoto(event) { + var that = this + var image_index = event.detail.index + var fileList_new = that.data.fileList; + wx.showModal({ + content: '确定删除照片?', + success: function (res) { + if (res.confirm) { + fileList_new.splice(image_index, 1); + that.setData({ + fileList: fileList_new + }) + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deletePhoto", + data: { + devcode: that.data.form.devcode + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) {} + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + } +}) \ No newline at end of file diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.wxml b/miniprogram/pages/addDevicelog/addDeviceLog.wxml index 38620d4..b10cc7d 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.wxml +++ b/miniprogram/pages/addDevicelog/addDeviceLog.wxml @@ -1,15 +1,21 @@ - + + + + + - + - - + + - - + + - + @@ -39,24 +45,25 @@ - - - + + + - + - + + @@ -64,7 +71,7 @@ - + @@ -79,9 +86,9 @@ - + - 保存 + 保存 diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.wxss b/miniprogram/pages/addDevicelog/addDeviceLog.wxss index ee0b75c..08d5fd7 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.wxss +++ b/miniprogram/pages/addDevicelog/addDeviceLog.wxss @@ -24,6 +24,17 @@ display: flex; align-items: center; } +.map-view{ + width: 750rpx; + height: 485rpx; + position: fixed; + top: 0px; + left: 0px; + z-index: 999; +} +.content{ + margin-top: 495rpx; +} .left { width: 210rpx; diff --git a/miniprogram/pages/addFunction/addFunction.js b/miniprogram/pages/addFunction/addFunction.js deleted file mode 100644 index 4966be3..0000000 --- a/miniprogram/pages/addFunction/addFunction.js +++ /dev/null @@ -1,60 +0,0 @@ -// pages/addFunction/addFunction.js - -const code = `// 云函数入口函数 -exports.main = (event, context) => { - console.log(event) - console.log(context) - return { - sum: event.a + event.b - } -}` - -Page({ - - data: { - result: '', - canIUseClipboard: wx.canIUse('setClipboardData'), - }, - - onLoad: function (options) { - - }, - - copyCode: function() { - wx.setClipboardData({ - data: code, - success: function () { - wx.showToast({ - title: '复制成功', - }) - } - }) - }, - - testFunction() { - wx.cloud.callFunction({ - name: 'sum', - data: { - a: 1, - b: 2 - }, - success: res => { - wx.showToast({ - title: '调用成功', - }) - this.setData({ - result: JSON.stringify(res.result) - }) - }, - fail: err => { - wx.showToast({ - icon: 'none', - title: '调用失败', - }) - console.error('[云函数] [sum] 调用失败:', err) - } - }) - }, - -}) - diff --git a/miniprogram/pages/addFunction/addFunction.json b/miniprogram/pages/addFunction/addFunction.json deleted file mode 100644 index a9a50c5..0000000 --- a/miniprogram/pages/addFunction/addFunction.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "navigationBarTitleText": "云函数指引", - "usingComponents": {} -} \ No newline at end of file diff --git a/miniprogram/pages/addFunction/addFunction.wxml b/miniprogram/pages/addFunction/addFunction.wxml deleted file mode 100644 index 3a10626..0000000 --- a/miniprogram/pages/addFunction/addFunction.wxml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - 测试云函数 - - - 期望输出:{"sum":3} - - - 调用结果:{{result}} - - - - - 新增云函数 - 1. 在云函数根目录 cloudfunctions 上右键选择新建云函数,命名为 sum - 2. 在创建的 cloudfunctions/sum/index.js 文件中添加如下代码 - - - 3. 在 cloudfunctions/sum 目录上右键上传并部署 - 4. 点击测试云函数测试 - 5. 打开云开发云函数管理页,选择 sum 云函数 - 6. 查看 sum 的调用日志 - 进阶:可在云函数中使用 wx-server-sdk 操作数据库,文件存储和调用其他云函数,详见文档 - - - diff --git a/miniprogram/pages/addFunction/addFunction.wxss b/miniprogram/pages/addFunction/addFunction.wxss deleted file mode 100644 index 7ac8619..0000000 --- a/miniprogram/pages/addFunction/addFunction.wxss +++ /dev/null @@ -1,3 +0,0 @@ -/* pages/addFunction/addFunction.wxss */ - -@import "../../style/guide.wxss"; \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.js b/miniprogram/pages/applog/applog.js index 0e8c185..189e61f 100644 --- a/miniprogram/pages/applog/applog.js +++ b/miniprogram/pages/applog/applog.js @@ -13,98 +13,25 @@ isSeach: "false", params: {}, total: 0, - show: false + show: false, + delBtnWidth: 100, //删除按钮宽度单位(rpx) + activeIndex: -1, + list_style: '' }, - - touchE: function (e) { - // console.log(e); - var that = this - if (e.changedTouches.length == 1) { - //手指移动结束后触摸点位置的X坐标 - var endX = e.changedTouches[0].clientX; - //触摸开始与结束,手指移动的距离 - var disX = that.data.startX - endX; - var delBtnWidth = that.data.delBtnWidth; - //如果距离小于删除按钮的1/2,不显示删除按钮 - var txtStyle = disX > delBtnWidth / 2 ? "left:-" + delBtnWidth + "rpx" : "left:0rpx"; - - //获取手指触摸的是哪一项 - var index = e.currentTarget.dataset.index; - var list = that.data.deviceloglist; - list[index].txtStyle = txtStyle; - //更新列表的状态 - that.setData({ - deviceloglist: list - }); - } - }, - //手指触摸动作开始 记录起点X坐标 - touchstart: function (e) { - //开始触摸时 重置所有删除 - this.data.deviceloglist.forEach(function (v, i) { - if (v.isTouchMove) //只操作为true的 - v.isTouchMove = false; - }) - this.setData({ - startX: e.changedTouches[0].clientX, - startY: e.changedTouches[0].clientY, - deviceloglist: this.data.deviceloglist - }) - }, - //滑动事件处理 - touchmove: function (e) { - var that = this, - index = e.currentTarget.dataset.index, //当前索引 - startX = that.data.startX, //开始X坐标 - startY = that.data.startY, //开始Y坐标 - touchMoveX = e.changedTouches[0].clientX, //滑动变化坐标 - touchMoveY = e.changedTouches[0].clientY, //滑动变化坐标 - //获取滑动角度 - angle = that.angle({ - X: startX, - Y: startY - }, { - X: touchMoveX, - Y: touchMoveY - }); - that.data.deviceloglist.forEach(function (v, i) { - v.isTouchMove = false - //滑动超过30度角 return - if (Math.abs(angle) > 30) return; - if (i == index) { - if (touchMoveX > startX) //右滑 - v.isTouchMove = false - else //左滑 - v.isTouchMove = true - } - }) - //更新数据 - that.setData({ - deviceloglist: that.data.deviceloglist - }) - }, - /** - * 计算滑动角度 - * @param {Object} start 起点坐标 - * @param {Object} end 终点坐标 - */ - angle: function (start, end) { - var _X = end.X - start.X, - _Y = end.Y - start.Y - //返回角度 /Math.atan()返回数字的反正切值 - return 360 * Math.atan(_Y / _X) / (2 * Math.PI); - }, - /** - * 生命周期函数--监听页面加载var_this=this; - */ onLoad: function (options) { - if (options.params) { this.setData({ params: JSON.parse(options.params), isSeach: "true" }) this.initPages() + }else{ + this.setData({ + show: false + }) + //清空参数,重新加载 + this.clearParams(); + this.initPages(); } }, @@ -116,20 +43,33 @@ }, + //点击tabBar事件 + onTabItemTap(item) { + //隐藏历史显示总记录条数 + this.setData({ + show: false + }) + //清空参数,重新加载 + this.clearParams(); + this.initPages(); + }, + + /** * 生命周期函数--监听页面显示 */ onShow: function (options) { - this.setData({ - show:false - }) - if (this.data.isSeach == "false") { - this.clearParams(); - this.initPages(); - } - this.setData({ - isSeach: "false" - }) + + // this.setData({ + // show: false + // }) + // if (this.data.isSeach == "false") { + // this.clearParams(); + // this.initPages(); + // } + // this.setData({ + // isSeach: "false" + // }) }, /** @@ -167,6 +107,119 @@ }, + + //手指触摸动作开始 记录起点X坐标 + touchstart: function (e) { + //开始触摸时 重置所有删除 + this.data.deviceloglist.forEach(function (v, i) { + if (v.isTouchMove) //只操作为true的 + v.isTouchMove = false; + }) + this.setData({ + startX: e.changedTouches[0].clientX, + startY: e.changedTouches[0].clientY, + deviceloglist: this.data.deviceloglist + }) + }, + + //滑动事件处理 + touchmove: function (e) { + var that = this, + index = e.currentTarget.dataset.index, //当前索引 + startX = that.data.startX, //开始X坐标 + startY = that.data.startY, //开始Y坐标 + touchMoveX = e.changedTouches[0].clientX, //滑动变化坐标 + touchMoveY = e.changedTouches[0].clientY, //滑动变化坐标 + //获取滑动角度 + angle = that.angle({ + X: startX, + Y: startY + }, { + X: touchMoveX, + Y: touchMoveY + }); + that.data.deviceloglist.forEach(function (v, i) { + // v.isTouchMove = false + //滑动超过30度角 return + if (Math.abs(angle) > 30) return; + if (i == index) { + if (touchMoveX > startX) //右滑 + v.isTouchMove = false + else //左滑 + v.isTouchMove = true + } + }) + //更新数据 + that.setData({ + deviceloglist: that.data.deviceloglist + }) + }, + + /** + * 计算滑动角度 + * @param {Object} start 起点坐标 + * @param {Object} end 终点坐标 + */ + angle: function (start, end) { + var _X = end.X - start.X, + _Y = end.Y - start.Y + //返回角度 /Math.atan()返回数字的反正切值 + return 360 * Math.atan(_Y / _X) / (2 * Math.PI); + }, + + //删除事件 + delItem: function (e) { + if(app.globalData.role!='repair'){ + wx.showToast({ + icon: 'none', + title: '无权限删除', + duration:2000 + }) + return false + } + var that = this + wx.showModal({ + content: '是否删除?', + success: function (res) { + if (res.confirm) { + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/delete", + data: { + appDeviceAddId: e.currentTarget.dataset.devid + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if(res.data.code=='200'){ + that.data.deviceloglist.splice(e.currentTarget.dataset.index, 1) + that.setData({ + deviceloglist: that.data.deviceloglist, + total: that.data.deviceloglist.length + }) + wx.showToast({ + title: '删除成功!', + icon: 'none', + duration: 1000 + }) + } + }, + fail(err) { + wx.showToast({ + title: '删除失败!', + icon: 'none', + duration: 2000 + }) + } + }) + } else { //这里是点击了取消以后 + console.log('用户点击取消') + } + } + }) + }, + showLoading: function (message) { if (wx.showLoading) { // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 @@ -199,95 +252,105 @@ deviceloglist: [] }) }, + //查询列表数据 initPages: function () { var that = this + that.setData({ + show: false + }) var offsetValue = that.data.deviceloglist.length % 15 > 0 ? parseInt(that.data.deviceloglist.length / 15) + 2 : parseInt(that.data.deviceloglist.length / 15) + 1 - wx.cloud.callFunction({ - name: 'devicelog', + + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/listPage", data: { devcode: that.data.params.devcode, devtype: that.data.params.devtype, installtimeFmt: that.data.params.installtimeFmt, project: that.data.params.project, installPerson: that.data.params.installPerson, - url: app.globalData.url + "appDeviceLog/listPage", limit: 15, offset: offsetValue }, - }).then(res => { - if (res.result.data.rows.length > 0) { - var resultJson = res.result - that.setData({ - deviceloglist: that.data.deviceloglist.concat(resultJson.data.rows) - }) - } else if (that.data.deviceloglist.length > 0) { - that.setData({ - show: true, - total: that.data.deviceloglist.length - }) - wx.showToast({ - title: '数据已全部加载完', - icon: 'none', - duration: 2000 - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.data.rows.length > 0) { + var resultJson = res.data + var listArr = resultJson.data.rows + listArr.forEach(function (v, i) { + listArr[i]['isTouchMove'] = false + }) + that.setData({ + deviceloglist: that.data.deviceloglist.concat(listArr) + }) + } else if (that.data.deviceloglist.length > 0) { + that.setData({ + show: true, + total: that.data.deviceloglist.length + }) + wx.showToast({ + title: '数据已全部加载完', + icon: 'none', + duration: 2000 + }) + } + if (offsetValue == 1 && res.data.data.rows.length < 15) { + that.setData({ + show: true, + total: that.data.deviceloglist.length + }) + } } - if(offsetValue==1&&res.result.data.rows.length<15){ - that.setData({ - show: true, - total: that.data.deviceloglist.length - }) - } - // console.log(res); - }).catch(err => { - console.error(err); }) + }, addDetail: function (event) { - this.showLoading("数据请求中..."); - wx.cloud.callFunction({ - name: 'deviceDetail', + var that = this + that.showLoading("数据请求中..."); + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deviceDetail", data: { devcode: event.target.dataset.devcode, - url: app.globalData.url + "appDeviceLog/deviceDetail", }, - }).then(res => { - this.hideLoading(); - var resultObject = JSON.parse(res.result); - var pageName = '../applog/applog' - if (resultObject.code == 200) { - wx.navigateTo({ - url: '../addDevicelog/addDeviceLog?detail=' + - JSON.stringify(resultObject.data) + "&pageName=" + pageName - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + that.hideLoading(); + // var resultObject = JSON.parse(res.data); + var resultObject = res.data; + var pageName = '../applog/applog' + if (resultObject.code == 200) { + wx.setStorageSync('resultObject', resultObject.data) + wx.navigateTo({ + url: '../addDevicelog/addDeviceLog?detail=' + "&pageName=" + pageName + }) + } + }, + fail(err) { + that.hideLoading(); } - }).catch(err => { - this.hideLoading() }) + }, add: function (event) { - wx.reLaunch({ - url: '../earth/earth?devcode=' + event.target.dataset.devcode - // url: '../earth/earth' + app.globalData.devcode = event.target.dataset.devcode; + wx.switchTab({ + url: '../earth/earth' }) + // wx.reLaunch({ + // url: '../earth/earth?devcode=' + event.target.dataset.devcode + // // url: '../earth/earth' + // }) }, onSearch: function () { + var _this = this wx.navigateTo({ - url: '../searchLog/searchLog' + url: '../searchLog/searchLog?params=' + JSON.stringify(_this.data.params) }) - }, - // initPages: function () { - // wx.cloud.callFunction({ - // name: 'devicelog' - // }).then(res => { - // var that = this; - // var jsonList = JSON.parse(res.result) - // that.setData({ - // deviceloglist: jsonList.data.rows - // }) - // console.log(res); - // }).catch(err => { - // console.error(err); - // }) - // } + } }) \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.wxml b/miniprogram/pages/applog/applog.wxml index e9a2352..2bfd041 100644 --- a/miniprogram/pages/applog/applog.wxml +++ b/miniprogram/pages/applog/applog.wxml @@ -1,54 +1,59 @@ - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {{item.devcode}} {{item.devicetype}} + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + {{item.devcode}} {{item.devicetype}} + + {{item.project}} {{item.installtime}}- {{item.installperson}} - - - - - + + + + + + 删除 - - - + + - 共计:{{total}}台 - + 共计:{{total}}台 + \ No newline at end of file diff --git a/miniprogram/pages/applog/applog.wxss b/miniprogram/pages/applog/applog.wxss index 6d3428b..e6e8983 100644 --- a/miniprogram/pages/applog/applog.wxss +++ b/miniprogram/pages/applog/applog.wxss @@ -22,16 +22,18 @@ position: fixed; width: 100%; top: 0rpx; + z-index: 9999; /* margin-bottom: 100rpx; */ } .log-list { /* height: 100rpx; */ - /* display: flex; */ - + display: flex; + width: 100%; padding: 2px; margin-top: 2px; border-bottom: 1px solid #e5e5e5; + overflow: hidden } @@ -53,23 +55,29 @@ left: 35%; margin: 20rpx } - .del { - width: 90px; + /* display: flex; */ + width: 100rpx; display: flex; flex-direction: column; align-items: center; justify-content: center; - color: #fff; - -webkit-transform: translateX(90px); - transform: translateX(90px); - -webkit-transition: all 0.4s; + /* -webkit-transform: translateX(100rpx); */ + transform: translateX(100rpx); + /* -webkit-transition: all 0.4s; */ transition: all 0.4s; - font-size: 35rpx; + color: #fff; + background-color: #fe3e2f; +} +.logrow{ + width: 100%; + transform: translateX(100rpx); + /* -webkit-transform: translateX(100px); */ + margin-left: -100rpx; } -.touch-move-active .content, +.touch-move-active .logrow, .touch-move-active .del { - -webkit-transform: translateX(0); - transform: translateX(0); +/* -webkit-transform: translateX(0); */ +transform: translateX(0); } \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.js b/miniprogram/pages/deployFunctions/deployFunctions.js deleted file mode 100644 index a76b144..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.js +++ /dev/null @@ -1,66 +0,0 @@ -// pages/deployFunctions/deployFunctions.js -Page({ - - /** - * 页面的初始数据 - */ - data: { - - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - - }, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { - - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - - }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { - - }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { - - } -}) \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.json b/miniprogram/pages/deployFunctions/deployFunctions.json deleted file mode 100644 index 7fbedab..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "navigationBarTitleText": "部署云函数", - "usingComponents": {} -} \ No newline at end of file diff --git a/miniprogram/pages/deployFunctions/deployFunctions.wxml b/miniprogram/pages/deployFunctions/deployFunctions.wxml deleted file mode 100644 index 462b6b6..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.wxml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - 调用失败 - - - 请检查 login 云函数是否已部署 - - - - - 部署 login 云函数 - 1. 确保已通过工具栏云开发入口开通云开发 - 2. 在 cloudfunctions/login 目录上右键上传并部署 - 3. 回到首页,重新点击获取 openid - - - - diff --git a/miniprogram/pages/deployFunctions/deployFunctions.wxss b/miniprogram/pages/deployFunctions/deployFunctions.wxss deleted file mode 100644 index c8803e6..0000000 --- a/miniprogram/pages/deployFunctions/deployFunctions.wxss +++ /dev/null @@ -1,7 +0,0 @@ -/* pages/deployFunctions/deployFunctions.wxss */ - -@import "../../style/guide.wxss"; - -.black { - color: black; -} \ No newline at end of file diff --git a/miniprogram/pages/earth/earth.js b/miniprogram/pages/earth/earth.js index ae0d3f3..376a6e2 100644 --- a/miniprogram/pages/earth/earth.js +++ b/miniprogram/pages/earth/earth.js @@ -21,19 +21,12 @@ show: false, enableSsatellite: false, windowWidth: 0, - longitude: 113.324520, - latitude: 23.099994, - longitude84: 113.324520, - latitude84: 23.099994, - markers: [{ - id: 0, - iconPath: "../../images/locat.png", - latitude: 23.099994, - longitude: 113.324520, - width: 50, - height: 50 - }], - controls: [], + longitude: "116.627340", + latitude: "39.874390", + longitude84: "", + latitude84: "", + markers: [], + controls: [] }, /** @@ -41,39 +34,13 @@ */ onLoad: function (options) { var that = this; - //获取当前坐标(gcj02) - wx.getLocation({ - type: "gcj02", - altitude: true, - success: function (res) { - that.setData({ - latitude: parseFloat(res.latitude).toFixed(6), - longitude: parseFloat(res.longitude).toFixed(6), - // markers: [{ - // latitude: res.latitude, - // longitude: res.longitude, - // }] - }) - //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 - wx.getLocation({ - type: "wgs84", - altitude: true, - success: function (res) { - that.setData({ - latitude84: parseFloat(res.latitude).toFixed(6), - longitude84: parseFloat(res.longitude).toFixed(6) - }) - } - }) - } - }), - - //设置地图组件 - wx.getSystemInfo({ + //设置地图组件 + wx.getSystemInfo({ success(res) { var windowWidth = res.windowWidth var windowHeight = res.windowHeight var query = wx.createSelectorQuery() + var platform =res.platform query.select('#map').boundingClientRect() query.exec(function (res) { that.setData({ @@ -139,10 +106,20 @@ clickable: true }, { id: 7, - iconPath: '../../images/locat.png', + iconPath: '../../images/applocat.png', position: { - left: res[0].width/2, - top: res[0].height/2, + left: res[0].width / 2 - 20, + top: platform=="ios"?res[0].height / 2 - 80:res[0].height / 2 - 40, + width: 40, + height: 40 + }, + clickable: true + }, { + id: 8, + iconPath: '../../images/back.png', + position: { + left: windowWidth - 40, + top: windowHeight - 140, width: 30, height: 30 }, @@ -150,71 +127,15 @@ }] }) }) - + } - }), + }) + // 实例化API核心类 qqmapsdk = new QQMapWX({ key: 'BGPBZ-C5O3P-ROUDR-LWC4J-63EKH-V5FRX' }) - - if (options.devcode) { - var that = this - var devcode = options.devcode - wx.cloud.callFunction({ - name: 'findListByCodes', - data: { - devcodes: devcode, - url: app.globalData.url + "appDeviceAdd/findListByCodes" - }, - }).then(res => { - if (res.result.code == 200) { - var listResultData = res.result.data; - that.setData({ - listData: listResultData - }) - var markersArr = that.data.markers; - for (var i = 0; i < listResultData.length; i++) { - markersArr = markersArr.concat({ - iconPath: "../../images/locat.png", - id: listResultData[i].id, - callout: { - content: listResultData[i].devcode, - fontSize: '14', - // padding: true, - color: '#00000', - borderColor: '#F4EA2A', - bgColor: '#F4EA2A', - borderWidth: 5, - display: 'ALWAYS', - textAlign: 'center', - // borderRadius: 15 - }, - latitude: listResultData[i].latitude, - longitude: listResultData[i].longitude, - width: 40, - height: 40 - }); - } - this.setData({ - markers: markersArr, - latitude: listResultData[0].latitude, - longitude: listResultData[0].longitude, - marker_latitude: listResultData[0].latitude, - marker_longitude: listResultData[0].longitude, - title: listResultData[0].devcode - }) - } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "无法获取设备地理信息!", - icon: 'none', - duration: 2000 - }) - }) - } }, /** @@ -228,6 +149,97 @@ * 生命周期函数--监听页面显示 */ onShow: function () { + //输入设备编号获取marker位置信息 + var that = this; + if ( app.globalData.devcode!="") { + var devcode = app.globalData.devcode + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/findListByCodes", + data: { + devcodes: devcode, + }, + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + app.globalData.devcode=""; + if (res.data.code == 200) { + var listResultData = res.data.data; + that.setData({ + listData: listResultData + }) + var markersArr = that.data.markers; + for (var i = 0; i < listResultData.length; i++) { + markersArr = markersArr.concat({ + iconPath: "../../images/locat.png", + id: Number(listResultData[i].id), + callout: { + content: "编号:"+listResultData[i].devcode+"\r\n位置:"+listResultData[i].position+"\r\n时间:"+listResultData[i].createtime, + fontSize: '14', + padding: true, + color: '#000000', + borderColor: '#F4EA2A', + bgColor: '#F4EA2A', + borderWidth: 5, + display: 'ALWAYS', + textAlign: 'left', + // borderRadius: 15 + }, + latitude: listResultData[i].latitude, + longitude: listResultData[i].longitude, + width: 40, + height: 40 + }); + } + that.setData({ + markers: markersArr, + latitude: listResultData[0].latitude, + longitude: listResultData[0].longitude, + marker_latitude: listResultData[0].latitude, + marker_longitude: listResultData[0].longitude, + title: listResultData[0].devcode + }) + } + }, + fail(err) { + app.globalData.devcode=""; + wx.showToast({ + title: "无法获取设备地理信息!", + icon: 'none', + duration: 2000 + }) + } + }) +} else { + //获取当前坐标(gcj02) + wx.getLocation({ + type: "gcj02", + altitude: true, + success: function (res) { + that.setData({ + latitude: parseFloat(res.latitude).toFixed(6), + longitude: parseFloat(res.longitude).toFixed(6), + // markers: [{ + // latitude: res.latitude, + // longitude: res.longitude, + // }] + }) + //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 + wx.getLocation({ + type: "wgs84", + altitude: true, + success: function (res) { + that.setData({ + latitude84: parseFloat(res.latitude).toFixed(6), + longitude84: parseFloat(res.longitude).toFixed(6) + }) + } + }) + } + }) +} + }, @@ -265,12 +277,46 @@ onShareAppMessage: function () { }, + + //定位出来 + + locationPosition: function () { + var that = this; + //获取当前坐标(gcj02) + wx.getLocation({ + type: "gcj02", + altitude: true, + success: function (res) { + that.setData({ + latitude: parseFloat(res.latitude).toFixed(6), + longitude: parseFloat(res.longitude).toFixed(6), + // markers: [{ + // latitude: res.latitude, + // longitude: res.longitude + // }] + }) + //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 + wx.getLocation({ + type: "wgs84", + altitude: true, + success: function (res) { + that.setData({ + latitude84: parseFloat(res.latitude).toFixed(6), + longitude84: parseFloat(res.longitude).toFixed(6) + }) + } + }) + } + }) + }, + + //加载地图组件 controltap: function (e) { // console.log(e.controlId); //进入添加设备页 if (1 == e.controlId) { wx.setClipboardData({ - data: this.data.latitude + "," + this.data.longitude+ "," + this.data.latitude84+ "," + this.data.longitude84, + data: this.data.latitude + "," + this.data.longitude + "," + this.data.latitude84 + "," + this.data.longitude84, success: function (res) { wx.getClipboardData({ success: function (res) { @@ -282,6 +328,17 @@ } }) } else if (3 == e.controlId) { + //先定位 + // this.locationPosition() + wx.setClipboardData({ + data: this.data.latitude + "," + this.data.longitude + "," + this.data.latitude84 + "," + this.data.longitude84, + success: function (res) { + wx.showToast({ + title: '坐标已获取', + duration: 1000 + }) + } + }) wx.navigateTo({ url: '../addDevice/addDevice' }) @@ -302,32 +359,15 @@ enableSsatellite: !flag }); } else if (6 == e.controlId) { - var that = this; - //获取当前坐标(gcj02) - wx.getLocation({ - type: "gcj02", - altitude: true, - success: function (res) { - that.setData({ - latitude: parseFloat(res.latitude).toFixed(6), - longitude:parseFloat(res.longitude).toFixed(6), - // markers: [{ - // latitude: res.latitude, - // longitude: res.longitude - // }] - }) - //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误 - wx.getLocation({ - type: "wgs84", - altitude: true, - success: function (res) { - that.setData({ - latitude84: parseFloat(res.latitude).toFixed(6), - longitude84: parseFloat(res.longitude).toFixed(6) - }) - } - }) - } + //先清marker + this.setData({ + markers: [] + }) + this.locationPosition() + }else if (8 == e.controlId) { + //跳转日志缓存页 + wx.switchTab({ + url: '../applog/applog', }) } }, @@ -343,63 +383,68 @@ }); }, + //获取设备maker leave() { var that = this; if (that.data.devcodes == "") { return false; } - wx.cloud.callFunction({ - name: 'findListByCodes', + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceAdd/findListByCodes", data: { - devcodes: that.data.devcodes, - url: app.globalData.url + "appDeviceAdd/findListByCodes" + devcodes: that.data.devcodes }, - }).then(res => { - if (res.result.code == 200) { - var listResultData = res.result.data; - that.setData({ - listData: listResultData - }) - var markersArr = that.data.markers; - for (var i = 0; i < listResultData.length; i++) { - markersArr = markersArr.concat({ - iconPath: "../../images/locat.png", - id: listResultData[i].id, - callout: { - content: listResultData[i].devcode, - fontSize: '14', - // padding: true, - color: '', - borderColor: '#F4EA2A', - bgColor: '#F4EA2A', - borderWidth: 5, - display: 'ALWAYS', - textAlign: 'center', - // borderRadius: 15 - }, - latitude: listResultData[i].latitude, - longitude: listResultData[i].longitude, - width: 40, - height: 40 - }); + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var listResultData = res.data.data; + that.setData({ + listData: listResultData + }) + var markersArr = that.data.markers; + for (var i = 0; i < listResultData.length; i++) { + markersArr = markersArr.concat({ + iconPath: "../../images/locat.png", + id: listResultData[i].id, + callout: { + content: "编号:"+listResultData[i].devcode+"\r\n位置:"+listResultData[i].position+"\r\n时间:"+listResultData[i].createtime, + fontSize: '14', + // padding: true, + color: '#212121', + borderColor: '#F4EA2A', + bgColor: '#F4EA2A', + borderWidth: 5, + display: 'ALWAYS', + textAlign: 'left', + // borderRadius: 15 + }, + latitude: listResultData[i].latitude, + longitude: listResultData[i].longitude, + width: 40, + height: 40 + }); + } + that.setData({ + markers: markersArr, + latitude: listResultData[0].latitude, + longitude: listResultData[0].longitude, + marker_latitude: listResultData[0].latitude, + marker_longitude: listResultData[0].longitude, + title: listResultData[0].devcode + }) } - this.setData({ - markers: markersArr, - latitude: listResultData[0].latitude, - longitude: listResultData[0].longitude, - marker_latitude: listResultData[0].latitude, - marker_longitude: listResultData[0].longitude, - title: listResultData[0].devcode + }, + fail(err) { + wx.showToast({ + title: "无法获取设备地理信息!", + icon: 'none', + duration: 2000 }) } - }).catch(err => { - console.error(err); - wx.showToast({ - title: "无法获取设备地理信息!", - icon: 'none', - duration: 2000 - }) }) }, @@ -422,6 +467,8 @@ } }, + + bindregionchange: function (e) { var that = this if (e.causedBy == "drag") { @@ -445,8 +492,8 @@ that.setData({ latitude: parseFloat(latitude).toFixed(6), longitude: parseFloat(longitude).toFixed(6), - latitude84:"", - longitude84:"", + latitude84: "", + longitude84: "", // markers: markersArr }) // mapCtx.moveToLocation(); @@ -465,16 +512,19 @@ qqmapsdk.search({ keyword: this.data.value, success: function (res) { + console.log(res) if (res && res.data) { _this.setData({ isShow: true, tips: res.data }); } + }, + complete: function (res){ + console.log(res); } }) }, - bindSearch: function (e) { var location = e.target.dataset.location; this.setData({ diff --git a/miniprogram/pages/earth/earth.wxml b/miniprogram/pages/earth/earth.wxml index a0db6ef..87474f8 100644 --- a/miniprogram/pages/earth/earth.wxml +++ b/miniprogram/pages/earth/earth.wxml @@ -1,9 +1,10 @@ + - + {{item.title}} {{item.address}} @@ -17,6 +18,6 @@ + placeholder="请输入定位设备编号用换行隔开" autosize border="{{ false }}" /> \ No newline at end of file diff --git a/miniprogram/pages/indexapp/indexapp.js b/miniprogram/pages/indexapp/indexapp.js index 5063372..849dbdb 100644 --- a/miniprogram/pages/indexapp/indexapp.js +++ b/miniprogram/pages/indexapp/indexapp.js @@ -7,9 +7,8 @@ */ data: { - count:1, - show: false, - onshow:true, + count: 1, + onshow: true, value: "", deviceloglist: [], devcode: "", @@ -21,6 +20,7 @@ // iconPath: "../../images/point.png", latitude: 23.099994, longitude: 113.324520, + label:'1', width: 50, height: 50 }], @@ -31,62 +31,26 @@ * 生命周期函数--监听页面加载 */ onLoad: function (options) { - + }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { - + }, /** * 生命周期函数--监听页面显示 */ onShow: function () { - // if( app.globalData.indexCount>1){ - // this.setData({ - // show:false - // }) - // }else{ - // this.showNotice() - // } - if(app.globalData.indexCount==1){ - this.setData({ - show:true - }) - this.showNotice() - } - app.globalData.indexCount+=1 - if(this.data.onshow){ + if (this.data.onshow) { this.initPages(); } }, - - showNotice: function() { - var that = this - var times = 0 - var i = setInterval(function() { - times++ - if (times >= 15) { - that.setData({ - show:false - }) - wx.showTabBar({ - animation: false, - }) - clearInterval(i) - } else { - wx.hideTabBar({ - animation: false, - }) - } - }, 1000) -}, - /** * 生命周期函数--监听页面隐藏 */ @@ -122,16 +86,27 @@ }, jump: function (event) { - var that = this; var latitude = event.target.dataset.pointLat; var longitude = event.target.dataset.pointLon; + let devcode = event.target.dataset.pointCode; that.setData({ latitude: latitude, longitude: longitude, markers: [{ latitude: latitude, - longitude: longitude + longitude: longitude, + callout: { + display:'ALWAYS',// 常显气泡 + content: devcode, //名称文本 + color: '#fff', //文本颜色 + borderRadius: 5, //边框圆角 + borderWidth: 1, //边框宽度 + borderColor: '#0060ff', //边框颜色 + bgColor: '#0060ff', //背景色 + padding: 5, //文本边缘留白 + textAlign: 'center' //文本对齐方式。有效值: left, right, center + } }] }) }, @@ -142,7 +117,7 @@ var devcode = res.result _this.setData({ devcode: devcode, - onshow:false + onshow: false }); _this.searchlogs(devcode) } @@ -151,40 +126,11 @@ onSearch: function (event) { this.setData({ - devcode:event.detail + devcode: event.detail }) this.searchlogs(event.detail) }, - - // bindregionchange: function (e) { - // var that = this - // if (e.causedBy == "drag") { - // var mapCtx = wx.createMapContext("map") - // mapCtx.getCenterLocation({ - // success: function (res) { - // var markersArr = that.data.markers - // for (var i = 0; i < markersArr.length; i++) { - // if (markersArr[i].iconPath == undefined) { - // markersArr.splice(i, 1) - // } - // } - // var latitude = res.latitude - // var longitude = res.longitude - // markersArr = markersArr.concat({ - // latitude: latitude, - // longitude: longitude - // }) - // that.setData({ - // latitude: latitude, - // longitude: longitude, - // markers: markersArr - // }) - // } - // }) - // } - // }, - showLoading: function (message) { if (wx.showLoading) { // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 @@ -211,81 +157,89 @@ } }, + //加载设备运维详细信息 toDetail: function (event) { - this.showLoading("数据加载中...") - wx.cloud.callFunction({ - name: 'deviceDetail', + var that = this + that.showLoading("数据加载中...") + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/deviceDetail", data: { devcode: event.target.dataset.devcode, - url: app.globalData.url + "appDeviceLog/deviceDetail", }, - }).then(res => { - this.hideLoading(); - var resultObject = JSON.parse(res.result); - var pageName='../indexapp/indexapp' - if (resultObject.code == 200) { - wx.navigateTo({ - url: '../addDevicelog/addDeviceLog?detail=' + - JSON.stringify(resultObject.data)+'&pageName='+pageName - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + that.hideLoading(); + var resultObject = res.data; + var pageName = '../indexapp/indexapp' + if (resultObject.code == 200) { + wx.setStorageSync('resultObject', resultObject.data) + wx.navigateTo({ + url: '../addDevicelog/addDeviceLog?detail=' +'&pageName=' + pageName + }) + } + }, + fail(err){ + that.hideLoading(); } - }).catch(err => { - this.hideLoading(); }) }, + //加载列表 getlogs: function (devcode) { var that = this - wx.cloud.callFunction({ - name: 'devicelog', + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/listPage", data: { devcode: devcode, - url: app.globalData.url + "appDeviceLog/listPage", limit: 100, offset: that.data.deviceloglist.length % 100 > 0 ? parseInt(that.data.deviceloglist.length / 100) + 2 : parseInt(that.data.deviceloglist.length / 100) + 1 }, - }).then(res => { - if (res.result) { - // var resultJson = JSON.parse(res.result) - var resultJson = res.result - that.setData({ - deviceloglist: that.data.deviceloglist.concat(resultJson.data.rows) - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + // var resultJson = JSON.parse(res.result) + var resultJson = res.data + that.setData({ + deviceloglist: that.data.deviceloglist.concat(resultJson.data.rows) + }) + } } - console.log(res); - }).catch(err => { - console.error(err); }) }, + //查询列表 searchlogs: function (devcode) { var that = this - wx.cloud.callFunction({ - name: 'devicelog', + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "appDeviceLog/listPage", data: { devcode: devcode, - url: app.globalData.url + "appDeviceLog/listPage", limit: 100, offset: 1 }, - }).then(res => { - if (res.result) { - var resultJson = res.result - that.setData({ - deviceloglist: resultJson.data.rows, - onshow:true - }) + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data) { + var resultJson = res.data + that.setData({ + deviceloglist: resultJson.data.rows, + onshow: true + }) + } } - console.log(res); - }).catch(err => { - console.error(err); }) }, initPages: function () { var that = this; - that.setData({ - devcode: "" - }); wx.getLocation({ type: "gcj02", success: function (res) { @@ -302,6 +256,6 @@ }) } }) - this.searchlogs() + this.data.devcode !== '' ? this.searchlogs(this.data.devcode) : this.searchlogs() }, }) \ No newline at end of file diff --git a/miniprogram/pages/indexapp/indexapp.wxml b/miniprogram/pages/indexapp/indexapp.wxml index 69322a0..f65b082 100644 --- a/miniprogram/pages/indexapp/indexapp.wxml +++ b/miniprogram/pages/indexapp/indexapp.wxml @@ -1,8 +1,12 @@ + + + + - @@ -32,9 +36,15 @@ - + + + + + + + @@ -46,14 +56,14 @@ - + - - + diff --git a/miniprogram/pages/indexapp/indexapp.wxss b/miniprogram/pages/indexapp/indexapp.wxss index b18706a..fc27fcb 100644 --- a/miniprogram/pages/indexapp/indexapp.wxss +++ b/miniprogram/pages/indexapp/indexapp.wxss @@ -128,6 +128,7 @@ .noticeClass{ height: 2300rpx; width: 750rpx; + overflow-y:hidden; } @@ -148,14 +149,14 @@ } +/* .vanstyle{ + button: not([size='mini']) { + user agent stylesheetmin-height: 40px; + width: 650rpx; + margin-left: 20rpx; + margin-right: auto; + + } + +} */ -/* .van-enter-active-class, -.van-leave-active-class { - transition-property: background-color, transform; -} - -.van-enter-class, -.van-leave-to-class { - background-color: red; - transform: rotate(-360deg) translate3d(-100%, -100%, 0); -} */ \ No newline at end of file diff --git a/miniprogram/pages/log/log.js b/miniprogram/pages/log/log.js deleted file mode 100644 index 83ba349..0000000 --- a/miniprogram/pages/log/log.js +++ /dev/null @@ -1,66 +0,0 @@ -// pages/log/log.js -Page({ - - /** - * 页面的初始数据 - */ - data: { - - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - - }, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { - - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - - }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { - - }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { - - } -}) \ No newline at end of file diff --git a/miniprogram/pages/log/log.json b/miniprogram/pages/log/log.json deleted file mode 100644 index 8835af0..0000000 --- a/miniprogram/pages/log/log.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "usingComponents": {} -} \ No newline at end of file diff --git a/miniprogram/pages/log/log.wxml b/miniprogram/pages/log/log.wxml deleted file mode 100644 index a510ad6..0000000 --- a/miniprogram/pages/log/log.wxml +++ /dev/null @@ -1,2 +0,0 @@ - -pages/log/log.wxml diff --git a/miniprogram/pages/log/log.wxss b/miniprogram/pages/log/log.wxss deleted file mode 100644 index 23db318..0000000 --- a/miniprogram/pages/log/log.wxss +++ /dev/null @@ -1 +0,0 @@ -/* pages/log/log.wxss */ \ No newline at end of file diff --git a/miniprogram/pages/login/login.js b/miniprogram/pages/login/login.js index a4074e7..cb0542a 100644 --- a/miniprogram/pages/login/login.js +++ b/miniprogram/pages/login/login.js @@ -1,11 +1,14 @@ // miniprogram/pages/login/login.js +var app = getApp() Page({ /** * 页面的初始数据 */ data: { - windowWidth:"" + windowWidth: "", + time: 15 * 1000, + showTime: false }, /** @@ -20,9 +23,9 @@ */ onReady: function () { this.setData({ - windowWidth:wx.getSystemInfoSync().windowWidth + windowWidth: wx.getSystemInfoSync().windowWidth }) - + }, /** @@ -66,14 +69,158 @@ onShareAppMessage: function () { }, + + + showLoading: function (message) { + if (wx.showLoading) { + // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 + wx.showLoading({ + title: message, + mask: true + }); + } else { + // 低版本采用Toast兼容处理并将时间设为20秒以免自动消失 + wx.showToast({ + title: message, + icon: 'loading', + mask: true, + duration: 20000 + }); + } + }, + hideLoading: function () { + if (wx.hideLoading) { + // 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理 + wx.hideLoading(); + } else { + wx.hideToast(); + } + }, + + //注册 loginClick: function () { + var that = this + that.showLoading("授权中...") + wx.login({ + success: function (res) { + if (res.code) { + wx.request({ + url: app.globalData.httpsUrl + "appUserOpenid/login", + data: { + code: res.code + }, + success: function (res) { + app.globalData.openid = res.data.data + wx.getUserInfo({ + success: (res) => { + var nickname = res.userInfo.nickName; + app.globalData.nickName = nickname; + //openid绑定昵称存入后台 + wx.request({ + url: app.globalData.httpsUrl + "appUserOpenid/add", + data: { + attr: nickname, + openid: app.globalData.openid + }, + success: function (res) { + that.hideLoading(); + wx.showToast({ + title: res.data.data+",\r\n请从正式版入口登录!", + icon: 'none', + duration: 2000 + }) - wx.navigateTo({ - - url: '../farmermain/farmermain', - + // //授权成功后跳转 + // wx.switchTab({ + // url: '../indexapp/indexapp' + // }) + } + }) + }, + fail: function (err) { + that.hideLoading(); + } + }) + }, + fail: function (res) { + that.hideLoading(); + wx.showToast({ + title: '服务器异常', + }) + } + }) + } + }, + fail: function (res) { + that.hideLoading(); + } }) + }, + //登录验证 + loginValidate: function () { + var that = this + that.showLoading("登录中...") + wx.login({ + success: function (res) { + if (res.code) { + console.info(res); + wx.request({ + url: app.globalData.httpsUrl + "appUserOpenid/login", + data: { + code: res.code + }, + success: function (res) { + app.globalData.openid = res.data.data + wx.request({ + url: app.globalData.httpsUrl + "appUserOpenid/validate", + data: { + openid: app.globalData.openid + }, + success: function (res) { + that.hideLoading(); + if (res.data.data) { + app.globalData.userName = res.data.data.attr1 == '' ? res.data.data.attr : res.data.data.attr1 + app.globalData.nickName = res.data.data.attr + app.globalData.role = res.data.data.role + wx.navigateTo({ + url: '../notice/notice' + }) + } else { + wx.showToast({ + icon: 'none', + title: '请联系管理员授权', + duration: 2000 + }) + } + }, + fail: function (err) { + that.hideLoading(); + wx.showToast({ + title: '验证失败', + }) + } + }) + }, + fail: function (res) { + that.hideLoading(); + wx.showToast({ + title: '服务器异常', + }) + } + }) + } + }, + fail: function (res) { + that.hideLoading(); + } + }) + }, + + finished() { + this.setData({ + showTime: true + }) }, onClickSubmit: function () { diff --git a/miniprogram/pages/login/login.json b/miniprogram/pages/login/login.json index 8835af0..f2043a3 100644 --- a/miniprogram/pages/login/login.json +++ b/miniprogram/pages/login/login.json @@ -1,3 +1,8 @@ { - "usingComponents": {} + "usingComponents": { + "van-count-down": "../../miniprogram_npm/@vant/weapp/count-down", + "van-button": "../../miniprogram_npm/@vant/weapp/button" + }, + "navigationBarBackgroundColor": "#E6D480", + "disableScroll":true } \ No newline at end of file diff --git a/miniprogram/pages/login/login.wxml b/miniprogram/pages/login/login.wxml index c69df42..cf2ec72 100644 --- a/miniprogram/pages/login/login.wxml +++ b/miniprogram/pages/login/login.wxml @@ -1,21 +1,46 @@ + - + + + - + + + +    本程序为施工日志管理小程序,为航天二院智慧市 +政技术研究室内部系统,不对外开放。出于对数据信 +息安全的考虑,在您首次使用小程序时,请先对小程 +序进行授权,授权后的用户可以正常对小程序进行编 +辑,谢谢您的配合! + + + + + + + + 授权/登录 + + + - + + + diff --git a/miniprogram/pages/login/login.wxss b/miniprogram/pages/login/login.wxss index ca77568..b9fa569 100644 --- a/miniprogram/pages/login/login.wxss +++ b/miniprogram/pages/login/login.wxss @@ -54,7 +54,8 @@ } .form .submit { - margin-top: 80rpx; + + /* margin-top: 80rpx; */ color: #fff; border: 2rpx solid #FFB90F; background-color: #FFB90F; @@ -63,10 +64,30 @@ } .login_image { - width: 200rpx; - height: 200rpx; - padding-top: 100rpx; - padding-left: 250rpx; + width: 750rpx; + height: 360rpx; + /* height: 2300rpx; */ + /* padding-top: 100rpx + padding-left: 250rpx; */ +} +.bottom_image { + width: 750rpx; + height: 32%; + position: fixed; + bottom: 0px; + /* padding-top: 100rpx + padding-left: 250rpx; */ +} +.cover{ + position: fixed; + top: 0rpx; + margin-left: 290rpx; + text-align:center; + font-size: 50rpx; + color: #FFCF00; + width: 750rpx; + z-index:9999; + } -} \ No newline at end of file + \ No newline at end of file diff --git a/miniprogram/pages/notice/notice.js b/miniprogram/pages/notice/notice.js new file mode 100644 index 0000000..7aeafb9 --- /dev/null +++ b/miniprogram/pages/notice/notice.js @@ -0,0 +1,80 @@ +// miniprogram/pages/notice.js +Page({ + + /** + * 页面的初始数据 + */ + data: { + time: 15 * 1000, + showTime: false + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { + this.setData({ + showTime: true + }) + wx.switchTab({ + url: '../indexapp/indexapp' + }) + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + }, + finished() { + this.setData({ + showTime: true + }) + wx.switchTab({ + url: '../indexapp/indexapp' + }) + } +}) \ No newline at end of file diff --git a/miniprogram/pages/notice/notice.json b/miniprogram/pages/notice/notice.json new file mode 100644 index 0000000..4c73264 --- /dev/null +++ b/miniprogram/pages/notice/notice.json @@ -0,0 +1,5 @@ +{ + "usingComponents": { + "van-count-down": "../../miniprogram_npm/@vant/weapp/count-down" + } +} \ No newline at end of file diff --git a/miniprogram/pages/notice/notice.wxml b/miniprogram/pages/notice/notice.wxml new file mode 100644 index 0000000..975304a --- /dev/null +++ b/miniprogram/pages/notice/notice.wxml @@ -0,0 +1,10 @@ + + + + + + + + diff --git a/miniprogram/pages/notice/notice.wxss b/miniprogram/pages/notice/notice.wxss new file mode 100644 index 0000000..36d7542 --- /dev/null +++ b/miniprogram/pages/notice/notice.wxss @@ -0,0 +1,18 @@ +/* miniprogram/pages/notice.wxss */ + +.login_image { + width: 750rpx; + height: 2300rpx; + /* padding-top: 100rpx + padding-left: 250rpx; */ +} +.cover{ + position: fixed; + top: 0rpx; + margin-left: 290rpx; + text-align:center; + font-size: 50rpx; + color: #FFCF00; + width: 750rpx; + z-index:9999; + } \ No newline at end of file diff --git a/miniprogram/pages/searchLog/searchLog.js b/miniprogram/pages/searchLog/searchLog.js index a4f8c33..1f7069b 100644 --- a/miniprogram/pages/searchLog/searchLog.js +++ b/miniprogram/pages/searchLog/searchLog.js @@ -6,29 +6,35 @@ * 页面的初始数据 */ data: { - defaultDay:[ + defaultDay: [ new Date().getTime(), - new Date().getTime()+24*60*60*1000, + new Date().getTime() + 24 * 60 * 60 * 1000, ], projectoption: [], - devtypeList:[], + devtypeList: [], personoption: [], installtimeFmt: '', show: false, - minDate: new Date(2010, 0, 1).getTime(), devcode: '', + timeShow:false, project: '', devtype: '', - installPerson:'', + installPerson: '', + projectvalue:'', minDate: new Date(2018, 0, 1).getTime(), // maxDate: new Date(2018, 0, 31).getTime(), }, onDisplay() { - this.setData({ show: true }); + this.setData({ + show: true + }); }, onClose() { - this.setData({ show: false }); + this.setData({ + show: false + }); }, + //格式化时间 formatDate(date) { date = new Date(date); // return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; @@ -50,6 +56,7 @@ return currentdate; }, + //查询时间区域设置 onConfirm(event) { // this.setData({ @@ -67,87 +74,102 @@ /** * 生命周期函数--监听页面加载 */ - onLoad: function (options) { - var _this=this + onLoad: async function (options) { + await this.setData({ + timeShow:true, + }) + const {devcode,devtype,installPerson,installtimeFmt,project} = JSON.parse(options.params) + this.setData({ + devcode:devcode || '', + devtype:devtype || '', + installPerson:installPerson || '', + installtimeFmt:installtimeFmt || '', + project:project || '', + projectvalue:project || '', + + }) + + var _this = this /** * 获取所属项目下拉列表 */ - wx.cloud.callFunction({ - name: 'getProject', - data: { - url: app.globalData.url + "project/getProject" + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "project/getProject", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - }).then(res => { - if (res.result.code == 200) { - var projectList = res.result.data - var projectArr = []; - for (var i = 0; i < projectList.length; i++) { - var project = { - text: projectList[i].projectName, - value: projectList[i].projectName - }; - projectArr.push(project); + success(res) { + if (res.data.code == 200) { + var projectList = res.data.data + var projectArr = []; + for (var i = 0; i < projectList.length; i++) { + var project = { + text: projectList[i].projectName, + value: projectList[i].projectName + }; + projectArr.push(project); + } + _this.setData({ + projectoption: projectArr + }) } - _this.setData({ - projectoption: projectArr - }) } - }).catch(err => { - console.error(err); }) - - - /** + /** * 获取设备类型下拉列表 */ - wx.cloud.callFunction({ - name: 'getTypeList', - data: { - url: app.globalData.url + "deviceType/deviceType" + wx.request({ + method: "POST", + url: app.globalData.httpsUrl + "deviceType/deviceType", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - }).then(res => { - if (res.result.code == 200) { - var TypeList = res.result.data - var typeArr = []; - for (var i = 0; i < TypeList.length; i++) { - var type = { - text: TypeList[i].productName, - value: TypeList[i].productName - }; - typeArr.push(type); + success(res) { + if (res.data.code == 200) { + var TypeList = res.data.data + var typeArr = []; + for (var i = 0; i < TypeList.length; i++) { + var type = { + text: TypeList[i].productName, + value: TypeList[i].productName + }; + typeArr.push(type); + } + _this.setData({ + devtypeList: typeArr + }) } - _this.setData({ - devtypeList: typeArr - }) } - }).catch(err => { - console.error(err); }) - //获取人员下拉列表 - wx.cloud.callFunction({ - name: 'getPerson', - data: { - url: app.globalData.url + "deviceType/getUser" + //获取人员下拉列表 + wx.request({ + method: "POST", + data:{ + tips:'repair' }, - }).then(res => { - if (res.result.code == 200) { - var users = res.result.data - var personArr = []; - for (var i = 0; i < users.length; i++) { - var person = { - text: users[i].name, - value: users[i].name - }; - personArr.push(person); + url: app.globalData.httpsUrl + "deviceType/getUser", + header: { + 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' + }, + success(res) { + if (res.data.code == 200) { + var users = res.data.data + var personArr = []; + for (var i = 0; i < users.length; i++) { + var person = { + text: users[i].name, + value: users[i].name + }; + personArr.push(person); + } + _this.setData({ + personoption: personArr + }) } - _this.setData({ - personoption: personArr - }) } - }).catch(err => { - console.error(err); }) }, @@ -202,13 +224,13 @@ }, scan() { - var _this=this; + var _this = this; wx.scanCode({ success(res) { - var devcode=res.result + var devcode = res.result _this.setData({ - devcode: devcode, - }); + devcode: devcode, + }); } }) }, @@ -221,6 +243,7 @@ [formName]: formValue }) }, + //设置项目 selectprojectValue(event) { var that = this; that.setData({ @@ -228,7 +251,7 @@ }) }, - + //设置设备类型 selectDevType(event) { var that = this; that.setData({ @@ -236,46 +259,24 @@ }) }, + //设置人员 selectpersonValue(event) { var that = this; that.setData({ installPerson: event.detail }) }, - + //查询 query: function (event) { - var data={ + var data = { devcode: this.data.devcode, installtimeFmt: this.data.installtimeFmt, project: this.data.project, devtype: this.data.devtype, - installPerson:this.data.installPerson + installPerson: this.data.installPerson } wx.reLaunch({ url: '../applog/applog?params=' + JSON.stringify(data) }) - // var that = this; - // wx.cloud.callFunction({ - // name: 'devicelog', - // data: { - // devcode: that.data.devcode, - // installtimeFmt: that.data.installtimeFmt, - // project: that.data.project, - // devtype: that.data.devtype, - // }, - // }).then(res => { - // // var resultObj=JSON.parse(res.result); - // var resultObj=res.result; - // if (resultObj.code == 200) { - // wx.reLaunch({ - // url: '../applog/applog?applogList=' + JSON.stringify(resultObj.data.rows) - // }) - // } - // }).catch(err => { - // console.error(err); - // wx.showToast({ - // title: "查询失败", - // }) - // }) }, }) \ No newline at end of file diff --git a/miniprogram/pages/searchLog/searchLog.wxml b/miniprogram/pages/searchLog/searchLog.wxml index dfbc788..daf06bc 100644 --- a/miniprogram/pages/searchLog/searchLog.wxml +++ b/miniprogram/pages/searchLog/searchLog.wxml @@ -21,14 +21,10 @@ - + - - @@ -39,7 +35,12 @@ - - 查询 + + + + + 查询 \ No newline at end of file diff --git a/miniprogram/project.config.json b/miniprogram/project.config.json new file mode 100644 index 0000000..4a797a9 --- /dev/null +++ b/miniprogram/project.config.json @@ -0,0 +1,43 @@ +{ + "appid": "wx79419f886f8c77ef", + "compileType": "miniprogram", + "libVersion": "2.27.3", + "packOptions": { + "ignore": [], + "include": [] + }, + "setting": { + "urlCheck": true, + "coverView": true, + "es6": true, + "postcss": true, + "lazyloadPlaceholderEnable": false, + "preloadBackgroundData": false, + "minified": true, + "autoAudits": false, + "uglifyFileName": false, + "uploadWithSourceMap": true, + "enhance": true, + "showShadowRootInWxmlPanel": true, + "packNpmManually": false, + "packNpmRelationList": [], + "minifyWXSS": true, + "useStaticServer": true, + "showES6CompileOption": false, + "checkInvalidKey": true, + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + }, + "disableUseStrict": false, + "useCompilerPlugins": false, + "minifyWXML": true + }, + "condition": {}, + "editorSetting": { + "tabIndent": "insertSpaces", + "tabSize": 4 + }, + "description": "项目配置文件,详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html" +} \ No newline at end of file diff --git a/miniprogram/project.private.config.json b/miniprogram/project.private.config.json new file mode 100644 index 0000000..7bbb91d --- /dev/null +++ b/miniprogram/project.private.config.json @@ -0,0 +1,56 @@ +{ + "projectname": "miniprogram", + "setting": { + "compileHotReLoad": true, + "urlCheck": true + }, + "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", + "condition": { + "miniprogram": { + "list": [ + { + "name": "", + "pathName": "pages/indexapp/indexapp", + "query": "", + "launchMode": "default", + "scene": null + }, + { + "name": "", + "pathName": "pages/addDevice/addDevice", + "query": "", + "launchMode": "default", + "scene": null + }, + { + "name": "", + "pathName": "pages/addDevicelog/addDeviceLog", + "query": "", + "launchMode": "default", + "scene": null + }, + { + "name": "", + "pathName": "pages/searchLog/searchLog", + "query": "", + "launchMode": "default", + "scene": null + }, + { + "name": "", + "pathName": "pages/applog/applog", + "query": "", + "launchMode": "default", + "scene": null + }, + { + "name": "", + "pathName": "pages/login/login", + "query": "", + "launchMode": "default", + "scene": null + } + ] + } + } +} \ No newline at end of file diff --git a/project.config.json b/project.config.json index c5f5337..c3a97f8 100644 --- a/project.config.json +++ b/project.config.json @@ -1,61 +1,55 @@ { - "miniprogramRoot": "miniprogram/", - "cloudfunctionRoot": "cloudfunctions/", - "setting": { - "urlCheck": false, - "es6": true, - "enhance": true, - "postcss": true, - "preloadBackgroundData": false, - "minified": true, - "newFeature": true, - "coverView": true, - "nodeModules": true, - "autoAudits": false, - "showShadowRootInWxmlPanel": true, - "scopeDataCheck": false, - "checkInvalidKey": true, - "checkSiteMap": true, - "uploadWithSourceMap": true, - "babelSetting": { - "ignore": [], - "disablePlugins": [], - "outputPath": "" - }, - "useCompilerModule": false, - "userConfirmedUseCompilerModuleSwitch": false - }, - "appid": "wx79419f886f8c77ef", - "projectname": "constructionApp", - "libVersion": "2.8.1", - "simulatorType": "wechat", - "simulatorPluginLibVersion": {}, - "cloudfunctionTemplateRoot": "cloudfunctionTemplate", - "condition": { - "search": { - "current": -1, - "list": [] - }, - "conversation": { - "current": -1, - "list": [] - }, - "plugin": { - "current": -1, - "list": [] - }, - "game": { - "list": [] - }, - "miniprogram": { - "current": 0, - "list": [ - { - "id": -1, - "name": "db guide", - "pathName": "pages/databaseGuide/databaseGuide" - } - ] - } - } + "miniprogramRoot": "miniprogram/", + "cloudfunctionRoot": "cloudfunctions/", + "setting": { + "urlCheck": false, + "es6": true, + "enhance": true, + "postcss": true, + "preloadBackgroundData": false, + "minified": true, + "newFeature": true, + "coverView": true, + "nodeModules": true, + "autoAudits": false, + "showShadowRootInWxmlPanel": true, + "scopeDataCheck": false, + "checkInvalidKey": true, + "checkSiteMap": true, + "uploadWithSourceMap": true, + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + }, + "useCompilerModule": false, + "userConfirmedUseCompilerModuleSwitch": false + }, + "appid": "wx2cef527a000f87c9", + "projectname": "constructionApp", + "libVersion": "2.8.1", + "simulatorType": "wechat", + "simulatorPluginLibVersion": {}, + "cloudfunctionTemplateRoot": "cloudfunctionTemplate/", + "compileType": "miniprogram", + "condition": { + "miniprogram": { + "list": [ + { + "name": "db guide", + "pathName": "pages/databaseGuide/databaseGuide", + "query": "" + } + ] + } + }, + "srcMiniprogramRoot": "miniprogram/", + "packOptions": { + "ignore": [], + "include": [] + }, + "editorSetting": { + "tabIndent": "insertSpaces", + "tabSize": 4 + } } \ No newline at end of file diff --git a/project.private.config.json b/project.private.config.json new file mode 100644 index 0000000..251bbf7 --- /dev/null +++ b/project.private.config.json @@ -0,0 +1,20 @@ +{ + "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", + "projectname": "%E6%99%BA%E6%85%A7%E6%96%BD%E5%B7%A5", + "setting": { + "compileHotReLoad": true + }, + "condition": { + "miniprogram": { + "list": [ + { + "name": "pages/indexapp/indexapp", + "pathName": "pages/databaseGuide/databaseGuide", + "query": "", + "launchMode": "default", + "scene": null + } + ] + } + } +} \ No newline at end of file