diff --git a/miniprogram/app.js b/miniprogram/app.js
index c10326f..4f1ad89 100644
--- a/miniprogram/app.js
+++ b/miniprogram/app.js
@@ -20,7 +20,7 @@
globalData: {
httpsUrl: "https://logapi.smartlog.work/", // 正式域名
// httpsUrl: "http://111.198.10.15:11638/", // 15
- // httpsUrl: "http://192.168.126.39:5905/", // 周甜
+ // httpsUrl: "http://192.168.95.39:5905/", // 周甜
// httpsUrl: "https://grey.logapi.smartlog.work/", // 测试域名
openid: null,
indexCount:1,
diff --git a/miniprogram/app.js b/miniprogram/app.js
index c10326f..4f1ad89 100644
--- a/miniprogram/app.js
+++ b/miniprogram/app.js
@@ -20,7 +20,7 @@
globalData: {
httpsUrl: "https://logapi.smartlog.work/", // 正式域名
// httpsUrl: "http://111.198.10.15:11638/", // 15
- // httpsUrl: "http://192.168.126.39:5905/", // 周甜
+ // httpsUrl: "http://192.168.95.39:5905/", // 周甜
// httpsUrl: "https://grey.logapi.smartlog.work/", // 测试域名
openid: null,
indexCount:1,
diff --git a/miniprogram/app.json b/miniprogram/app.json
index 3c1d780..975101c 100644
--- a/miniprogram/app.json
+++ b/miniprogram/app.json
@@ -50,6 +50,9 @@
"permission": {
"scope.userLocation": {
"desc": "你的位置信息将用于小程序位置接口的效果展示"
+ },
+ "scope.camera": {
+ "desc": "你的小程序需要使用相机来完成相关操作,如扫描设备、上传照片等"
}
},
"requiredPrivateInfos": [
diff --git a/miniprogram/app.js b/miniprogram/app.js
index c10326f..4f1ad89 100644
--- a/miniprogram/app.js
+++ b/miniprogram/app.js
@@ -20,7 +20,7 @@
globalData: {
httpsUrl: "https://logapi.smartlog.work/", // 正式域名
// httpsUrl: "http://111.198.10.15:11638/", // 15
- // httpsUrl: "http://192.168.126.39:5905/", // 周甜
+ // httpsUrl: "http://192.168.95.39:5905/", // 周甜
// httpsUrl: "https://grey.logapi.smartlog.work/", // 测试域名
openid: null,
indexCount:1,
diff --git a/miniprogram/app.json b/miniprogram/app.json
index 3c1d780..975101c 100644
--- a/miniprogram/app.json
+++ b/miniprogram/app.json
@@ -50,6 +50,9 @@
"permission": {
"scope.userLocation": {
"desc": "你的位置信息将用于小程序位置接口的效果展示"
+ },
+ "scope.camera": {
+ "desc": "你的小程序需要使用相机来完成相关操作,如扫描设备、上传照片等"
}
},
"requiredPrivateInfos": [
diff --git a/miniprogram/images/red-marker.png b/miniprogram/images/red-marker.png
new file mode 100644
index 0000000..ed00cf5
--- /dev/null
+++ b/miniprogram/images/red-marker.png
Binary files differ
diff --git a/miniprogram/app.js b/miniprogram/app.js
index c10326f..4f1ad89 100644
--- a/miniprogram/app.js
+++ b/miniprogram/app.js
@@ -20,7 +20,7 @@
globalData: {
httpsUrl: "https://logapi.smartlog.work/", // 正式域名
// httpsUrl: "http://111.198.10.15:11638/", // 15
- // httpsUrl: "http://192.168.126.39:5905/", // 周甜
+ // httpsUrl: "http://192.168.95.39:5905/", // 周甜
// httpsUrl: "https://grey.logapi.smartlog.work/", // 测试域名
openid: null,
indexCount:1,
diff --git a/miniprogram/app.json b/miniprogram/app.json
index 3c1d780..975101c 100644
--- a/miniprogram/app.json
+++ b/miniprogram/app.json
@@ -50,6 +50,9 @@
"permission": {
"scope.userLocation": {
"desc": "你的位置信息将用于小程序位置接口的效果展示"
+ },
+ "scope.camera": {
+ "desc": "你的小程序需要使用相机来完成相关操作,如扫描设备、上传照片等"
}
},
"requiredPrivateInfos": [
diff --git a/miniprogram/images/red-marker.png b/miniprogram/images/red-marker.png
new file mode 100644
index 0000000..ed00cf5
--- /dev/null
+++ b/miniprogram/images/red-marker.png
Binary files differ
diff --git a/miniprogram/pages/addDevice/addDevice copy.js b/miniprogram/pages/addDevice/addDevice copy.js
new file mode 100644
index 0000000..fcf664d
--- /dev/null
+++ b/miniprogram/pages/addDevice/addDevice copy.js
@@ -0,0 +1,947 @@
+// miniprogram/pages/addDevice/addDevice.js
+// import WxValidate from '../../utils/WxValidate.js'
+var QQMapWX = require('../../libs/qqmap-wx-jssdk.js');
+var qqmapsdk;
+var app = getApp()
+const installTypeMap = {
+ '1': '初次安装',
+ '2': '初次拆走',
+ '3': '二次安装',
+ '4': '二次拆走',
+ '5': '正在维护',
+ '6': '其他',
+}
+Page({
+
+ /**
+ * 页面的初始数据
+ */
+ data: {
+ wellActions: [], // 选择井编号
+ wellShow: false, // 是否显示选择井编号
+ projectName: '', // 项目名称
+ canvasHeight: '',
+ canvasWidth: '',
+ longitude: '',
+ latitude: '',
+ option1: [],
+ personoption1: [],
+ projectoption: [],
+ devtypeList:[],
+ installTypeList:[
+ {
+ text: '初次安装',
+ value: '1',
+ },
+ {
+ text: '初次拆走',
+ value: '2',
+ },
+ {
+ text: '二次安装',
+ value: '3',
+ },
+ {
+ text: '二次拆走',
+ value: '4',
+ },
+ {
+ text: '正在维护',
+ value: '5',
+ },
+ {
+ text: '其他',
+ value: '6',
+ },
+ ],
+ show: false,
+ form: {
+ devcode: "",
+ wellcode: "",
+ welltype: "",
+ welldepth: "",
+ installheigt: "",
+ installperson: "",
+ installtimeFmt: "",
+ photopath: "",
+ factory: "",
+ workmsg: "",
+ position: "",
+ longitude: "",
+ latitude: "",
+ longitude84: "",
+ latitude84: "",
+ devicetype: "",
+ project: '',
+ area: "",
+ street: "",
+ wellname: "",
+ photopath1: '',
+ photopath2: '',
+ photopath3: '',
+ installType: '1', // 设备安装情况
+ description: "初次安装", // 备注
+ },
+ fileList: [],
+ listQuery: {
+ wellCode: '', // wellCode
+ wellType: '', // 井类型
+ position: '', // 位置
+ projectId: '', // 所在项目
+ },
+ showSelectProject: false,
+ },
+
+ onDisplay() {
+ this.setData({
+ show: true
+ });
+ },
+ onClose() {
+ this.setData({
+ show: false
+ });
+ },
+ // cleaable 清除经度
+ clearLongitude() {
+ var _this = this;
+ _this.setData({
+ 'form.longitude': '',
+ });
+ },
+// 清除纬度
+ clearclearLatitude() {
+ var _this = this;
+ _this.setData({
+ 'form.latitude': '',
+ });
+ },
+ 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),
+ });
+ },
+
+ /**
+ * 生命周期函数--监听页面加载
+ */
+ onLoad: function (options) {
+ var that = this;
+ if(app.globalData.role === 'repair' && app.globalData.isConfigProject === '0') {
+ that.setData({
+ 'showSelectProject': true,
+ })
+ } else {
+ that.setData({
+ 'showSelectProject': false,
+ })
+ }
+
+ console.log(app.globalData.selectProjectId, '===');
+ that.setData({
+ 'form.project': app.globalData.selectProjectName,
+ 'projectName': app.globalData.selectProjectName,
+ })
+ console.log('-----------------------3333', options);
+ //=========初始化表单内容为上次填写值==========
+ // 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
+ //默认安装经纬度为当前位置(gcj02)
+ if(options.fromPage !== 'defineMap') {
+ wx.getLocation({
+ type: "gcj02",
+ altitude: true,
+ success: function (res) {
+ var longitude = 'form.longitude';
+ var latitude = 'form.latitude';
+ that.setData({
+ [longitude]: parseFloat(res.longitude).toFixed(6),
+ [latitude]: parseFloat(res.latitude).toFixed(6),
+ longitude: parseFloat(res.longitude).toFixed(6),
+ latitude: parseFloat(res.latitude).toFixed(6),
+ });
+ //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误
+ wx.getLocation({
+ type: "wgs84",
+ altitude: true,
+ success: function (res) {
+ var longitude84 = 'form.longitude84';
+ var latitude84 = 'form.latitude84';
+ that.setData({
+ [latitude84]: parseFloat(res.latitude).toFixed(6),
+ [longitude84]: parseFloat(res.longitude).toFixed(6)
+ })
+ }
+ })
+ }
+ })
+ }
+
+
+ //获取井类型下拉列表
+ 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);
+ }
+ console.log('------', welltypeArr)
+ that.setData({
+ option1: welltypeArr
+ })
+ }
+ }
+ })
+
+ //获取人员下拉列表
+ 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);
+ }
+ personArr.push({
+ text: app.globalData.currentUserName,
+ value: app.globalData.currentUserName
+ });
+
+ that.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);
+ }
+ that.setData({
+ projectoption: projectArr
+ })
+ }
+ }
+ })
+
+ var installtime = 'form.installtimeFmt';
+ var dateNow = this.formatDate();
+ this.setData({
+ show: false,
+ 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
+ })
+ }
+ }
+ })
+
+ // 粘贴经纬度
+ if(options.fromPage !== 'defineMap') {
+ this.paste()
+ }
+ // 处理备注的默认
+ var description = 'form.description';
+ that.setData({
+ [description]: installTypeMap[that.data.form.installType]
+ })
+ console.log('options', options);
+ if(options.fromPage === 'defineMap') { // 从自定义地图页面跳转过来
+ console.log('-09999999999', app.globalData.currentUserName);
+ that.setData({
+ 'form.wellType': options.wellType, // 井类型
+ 'form.wellcode': options.wellCode, // 井编号
+ 'form.position': options.position, // 位置
+ 'form.devicetype': '井盖状态监测仪', // 设备类型
+ 'form.installperson': app.globalData.currentUserName, // 安装人员
+ 'form.project': '2025-NBJ', // 所属项目
+ 'form.latitude': parseFloat(options.latitude).toFixed(6),
+ 'form.longitude': parseFloat(options.longitude).toFixed(6),
+ latitude: parseFloat(options.latitude).toFixed(6),
+ longitude: parseFloat(options.longitude).toFixed(6),
+ })
+ }
+ that.setData({
+ 'form.installperson': app.globalData.currentUserName, // 安装人员
+ 'form.project': '2025-NBJ', // 所属项目
+ })
+ },
+
+
+
+
+ /**
+ * 生命周期函数--监听页面初次渲染完成
+ */
+ onReady: function () {
+
+ },
+
+ /**
+ * 生命周期函数--监听页面显示
+ */
+ onShow: function () {
+
+ },
+
+ /**
+ * 生命周期函数--监听页面隐藏
+ */
+ onHide: function () {
+
+ },
+
+ /**
+ * 生命周期函数--监听页面卸载
+ */
+ onUnload: function () {
+
+ },
+
+ /**
+ * 页面相关事件处理函数--监听用户下拉动作
+ */
+ onPullDownRefresh: function () {
+
+ },
+
+ // 监听页面滚动
+ onPageScroll(e) {
+ console.log('监听页面滚动');
+ var that = this
+ console.log(that.selectComponent('#selectPersonDropdown'));
+ // that.selectComponent('#selectPersonDropdown').triggerEvent(false)
+},
+
+toggle() {
+
+},
+ // 点击检索
+ searchWellCode() {
+ if(!this.data.form.wellcode) {
+ wx.showToast({
+ icon: 'error',
+ title: '请先输入井编号',
+ })
+ return false
+ }
+ this.setData({
+ 'listQuery.wellCode': this.data.form.wellcode
+ })
+ this.fetchWellPre()
+ },
+ //获取井列表
+ fetchWellPre() {
+ return new Promise((resolve, reject) => {
+ var that = this
+ wx.showLoading({
+ mask: true
+ })
+ wx.request({
+ method: "POST",
+ url: app.globalData.httpsUrl + "well/pre/listPage" + `?offset=${1}&limit=${9999}`,
+ // header: {
+ // 'content-type': 'application/x-www-form-urlencoded;charset=utf-8'
+ // },
+ data: {
+ ...that.data.listQuery,
+ offset: 1,
+ limit: 9999
+ },
+ success(res) {
+ wx.hideLoading()
+ if (res.data) {
+ if(!res.data.data.rows.length) {
+ wx.showToast({
+ icon: 'error',
+ title: '查无结果'
+ })
+ } else {
+ const tempList = res.data.data.rows.map(item => {
+ return {
+ ...item,
+ name: item.wellName,
+ }
+ })
+ that.setData({
+ wellActions: tempList,
+ wellShow: true
+ })
+ }
+ }
+ },
+ fail(res) {
+ wx.hideLoading()
+ wx.showToast({
+ icon: 'none',
+ title: '查询失败,请手动输入'
+ })
+ }
+ })
+ })
+ },
+ // 点击选择器的取消
+ cancleWellShow() {
+ this.setData({
+ wellShow: false,
+ })
+ },
+ // 选择好井
+ selectWells(e) {
+ var that = this
+ const val = e.detail
+ console.log(val);
+ that.setData({
+ 'form.wellcode': val.wellCode, // 井编号
+ 'form.wellname': val.wellName, // 井名称
+ 'form.welltype': val.wellType, // 井类型
+ 'form.position': val.position, //位置描述
+ })
+ that.cancleWellShow()
+ },
+
+ /**
+ * 页面上拉触底事件的处理函数
+ */
+ onReachBottom: function () {
+
+ },
+
+ /**
+ * 用户点击右上角分享
+ */
+ onShareAppMessage: function () {
+
+ },
+
+
+
+ /**
+ * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true
+ **/
+
+ isNumber: function (val) {
+
+ var regPos = /^[0-9]*$/; //非负浮点数
+ var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数
+ if (regPos.test(val) || regNeg.test(val)) {
+ return false;
+ } else {
+ return true;
+ }
+
+ },
+
+ //验证表单
+ formValidate() {
+
+ if (this.data.form.devcode == "") {
+ 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',
+ title: '井编号不能为空!',
+ })
+ return false
+ }
+
+ if (this.data.form.devicetype == "") {
+ wx.showToast({
+ icon: 'none',
+ title: '设备类型不能为空!',
+ })
+ return false
+ }
+
+
+
+ if (this.data.form.installperson == "") {
+ 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
+ }
+ }
+
+ if (this.data.form.project == "") {
+ wx.showToast({
+ icon: 'none',
+ title: '所属项目不能为空!',
+ })
+ return false
+ }
+
+ if (this.data.form.installtimeFmt == null) {
+ wx.showToast({
+ icon: 'none',
+ title: '安装时间不能为空!',
+ })
+ return false
+ }
+ return true;
+ },
+ //提交表单
+ formSubmit: function (event) {
+ console.log(this.data.form)
+ //表单参数验证
+ if (!this.formValidate()) {
+ return false;
+ }
+ var that = this;
+ //验证设备编号长度
+ wx.request({
+ method: 'POST',
+ url: app.globalData.httpsUrl + "appDeviceAdd/getDevTypeLength",
+ data: {
+ code: encodeURI(this.data.form.devicetype)
+ },
+ 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
+ }
+ }
+ })
+ },
+
+ //保存设备基本信息
+ 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]
+ })
+ }
+ that.setData({
+ 'form.project': that.data.form.project,
+ 'projectName': that.data.form.project,
+ })
+ //表单提交
+ 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: '提交成功,是否返回?',
+ showCancel: false, // 不显示取消按钮
+ success: function (res) {
+ console.log('用户点击了返回')
+ //用于回显
+ console.log('lll', that.data.form);
+ wx.setStorageSync('cacheList', that.data.form)
+ //提交成功后提示用户操作
+ if (res.confirm) {
+ // wx.switchTab({
+ // url: '../earth/earth'
+ // })
+ console.log('lleeel', that.data.form);
+ app.globalData.addsuccessWellCode = that.data.form.wellcode
+ wx.navigateBack({ // 返回上一页
+ delta: 1
+ });
+ } else { //这里是点击了取消以后
+ console.log('用户点击取消')
+ }
+ }
+ })
+ }
+ },
+ fail(err) {
+ wx.showToast({
+ title: '提交失败!',
+ })
+ }
+ })
+ },
+ // 井编号输入框点击清除按钮
+// clickClearable() {
+// this.setData({
+// 'form.wellcode': ''
+// })
+// },
+ // 井编号改变
+ changeWellCode(e) {
+ console.log(e);
+ this.setData({
+ 'form.wellcode': e.detail
+ })
+ },
+
+ //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,
+ })
+ //若输入是设备编号,自动获取设备类型
+ 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({
+ success(res) {
+ var devcode = res.result
+ var formdevcode = 'form.devcode'
+ _this.setData({
+ [formdevcode]: devcode
+ });
+ wx.request({
+ method: 'POST',
+ url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode",
+ data: {
+ devcode: devcode,
+ },
+ 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({
+ 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),
+ });
+ _this.showAddress(_this.data.form.longitude,_this.data.form.latitude,_this)
+ }
+ })
+ },
+ //设置经类型
+ selectValue(value) {
+
+ var that = this;
+ var wellType = 'form.welltype';
+ that.setData({
+ [wellType]: value.detail
+ })
+ },
+ // 设置设备安装情况
+ selectInstallType(value) {
+ var that = this;
+ var installType = 'form.installType';
+ var description = 'form.description';
+ that.setData({
+ [installType]: value.detail,
+ [description]: installTypeMap[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';
+ that.setData({
+ [installPerson]: event.detail
+ })
+ },
+ //设置项目
+ selectprojectValue(event) {
+ var that = this;
+ var project = 'form.project';
+ that.setData({
+ [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;
+ 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
+ });
+ }
+ }
+ })
+ }
+ })
+ },
+ //删除照片
+ deletePhoto(event) {
+ var image_index = event.detail.index
+ var fileList_new = this.data.fileList;
+ fileList_new.splice(image_index, 1);
+ this.setData({
+ fileList: fileList_new
+ })
+ },
+})
\ No newline at end of file
diff --git a/miniprogram/app.js b/miniprogram/app.js
index c10326f..4f1ad89 100644
--- a/miniprogram/app.js
+++ b/miniprogram/app.js
@@ -20,7 +20,7 @@
globalData: {
httpsUrl: "https://logapi.smartlog.work/", // 正式域名
// httpsUrl: "http://111.198.10.15:11638/", // 15
- // httpsUrl: "http://192.168.126.39:5905/", // 周甜
+ // httpsUrl: "http://192.168.95.39:5905/", // 周甜
// httpsUrl: "https://grey.logapi.smartlog.work/", // 测试域名
openid: null,
indexCount:1,
diff --git a/miniprogram/app.json b/miniprogram/app.json
index 3c1d780..975101c 100644
--- a/miniprogram/app.json
+++ b/miniprogram/app.json
@@ -50,6 +50,9 @@
"permission": {
"scope.userLocation": {
"desc": "你的位置信息将用于小程序位置接口的效果展示"
+ },
+ "scope.camera": {
+ "desc": "你的小程序需要使用相机来完成相关操作,如扫描设备、上传照片等"
}
},
"requiredPrivateInfos": [
diff --git a/miniprogram/images/red-marker.png b/miniprogram/images/red-marker.png
new file mode 100644
index 0000000..ed00cf5
--- /dev/null
+++ b/miniprogram/images/red-marker.png
Binary files differ
diff --git a/miniprogram/pages/addDevice/addDevice copy.js b/miniprogram/pages/addDevice/addDevice copy.js
new file mode 100644
index 0000000..fcf664d
--- /dev/null
+++ b/miniprogram/pages/addDevice/addDevice copy.js
@@ -0,0 +1,947 @@
+// miniprogram/pages/addDevice/addDevice.js
+// import WxValidate from '../../utils/WxValidate.js'
+var QQMapWX = require('../../libs/qqmap-wx-jssdk.js');
+var qqmapsdk;
+var app = getApp()
+const installTypeMap = {
+ '1': '初次安装',
+ '2': '初次拆走',
+ '3': '二次安装',
+ '4': '二次拆走',
+ '5': '正在维护',
+ '6': '其他',
+}
+Page({
+
+ /**
+ * 页面的初始数据
+ */
+ data: {
+ wellActions: [], // 选择井编号
+ wellShow: false, // 是否显示选择井编号
+ projectName: '', // 项目名称
+ canvasHeight: '',
+ canvasWidth: '',
+ longitude: '',
+ latitude: '',
+ option1: [],
+ personoption1: [],
+ projectoption: [],
+ devtypeList:[],
+ installTypeList:[
+ {
+ text: '初次安装',
+ value: '1',
+ },
+ {
+ text: '初次拆走',
+ value: '2',
+ },
+ {
+ text: '二次安装',
+ value: '3',
+ },
+ {
+ text: '二次拆走',
+ value: '4',
+ },
+ {
+ text: '正在维护',
+ value: '5',
+ },
+ {
+ text: '其他',
+ value: '6',
+ },
+ ],
+ show: false,
+ form: {
+ devcode: "",
+ wellcode: "",
+ welltype: "",
+ welldepth: "",
+ installheigt: "",
+ installperson: "",
+ installtimeFmt: "",
+ photopath: "",
+ factory: "",
+ workmsg: "",
+ position: "",
+ longitude: "",
+ latitude: "",
+ longitude84: "",
+ latitude84: "",
+ devicetype: "",
+ project: '',
+ area: "",
+ street: "",
+ wellname: "",
+ photopath1: '',
+ photopath2: '',
+ photopath3: '',
+ installType: '1', // 设备安装情况
+ description: "初次安装", // 备注
+ },
+ fileList: [],
+ listQuery: {
+ wellCode: '', // wellCode
+ wellType: '', // 井类型
+ position: '', // 位置
+ projectId: '', // 所在项目
+ },
+ showSelectProject: false,
+ },
+
+ onDisplay() {
+ this.setData({
+ show: true
+ });
+ },
+ onClose() {
+ this.setData({
+ show: false
+ });
+ },
+ // cleaable 清除经度
+ clearLongitude() {
+ var _this = this;
+ _this.setData({
+ 'form.longitude': '',
+ });
+ },
+// 清除纬度
+ clearclearLatitude() {
+ var _this = this;
+ _this.setData({
+ 'form.latitude': '',
+ });
+ },
+ 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),
+ });
+ },
+
+ /**
+ * 生命周期函数--监听页面加载
+ */
+ onLoad: function (options) {
+ var that = this;
+ if(app.globalData.role === 'repair' && app.globalData.isConfigProject === '0') {
+ that.setData({
+ 'showSelectProject': true,
+ })
+ } else {
+ that.setData({
+ 'showSelectProject': false,
+ })
+ }
+
+ console.log(app.globalData.selectProjectId, '===');
+ that.setData({
+ 'form.project': app.globalData.selectProjectName,
+ 'projectName': app.globalData.selectProjectName,
+ })
+ console.log('-----------------------3333', options);
+ //=========初始化表单内容为上次填写值==========
+ // 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
+ //默认安装经纬度为当前位置(gcj02)
+ if(options.fromPage !== 'defineMap') {
+ wx.getLocation({
+ type: "gcj02",
+ altitude: true,
+ success: function (res) {
+ var longitude = 'form.longitude';
+ var latitude = 'form.latitude';
+ that.setData({
+ [longitude]: parseFloat(res.longitude).toFixed(6),
+ [latitude]: parseFloat(res.latitude).toFixed(6),
+ longitude: parseFloat(res.longitude).toFixed(6),
+ latitude: parseFloat(res.latitude).toFixed(6),
+ });
+ //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误
+ wx.getLocation({
+ type: "wgs84",
+ altitude: true,
+ success: function (res) {
+ var longitude84 = 'form.longitude84';
+ var latitude84 = 'form.latitude84';
+ that.setData({
+ [latitude84]: parseFloat(res.latitude).toFixed(6),
+ [longitude84]: parseFloat(res.longitude).toFixed(6)
+ })
+ }
+ })
+ }
+ })
+ }
+
+
+ //获取井类型下拉列表
+ 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);
+ }
+ console.log('------', welltypeArr)
+ that.setData({
+ option1: welltypeArr
+ })
+ }
+ }
+ })
+
+ //获取人员下拉列表
+ 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);
+ }
+ personArr.push({
+ text: app.globalData.currentUserName,
+ value: app.globalData.currentUserName
+ });
+
+ that.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);
+ }
+ that.setData({
+ projectoption: projectArr
+ })
+ }
+ }
+ })
+
+ var installtime = 'form.installtimeFmt';
+ var dateNow = this.formatDate();
+ this.setData({
+ show: false,
+ 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
+ })
+ }
+ }
+ })
+
+ // 粘贴经纬度
+ if(options.fromPage !== 'defineMap') {
+ this.paste()
+ }
+ // 处理备注的默认
+ var description = 'form.description';
+ that.setData({
+ [description]: installTypeMap[that.data.form.installType]
+ })
+ console.log('options', options);
+ if(options.fromPage === 'defineMap') { // 从自定义地图页面跳转过来
+ console.log('-09999999999', app.globalData.currentUserName);
+ that.setData({
+ 'form.wellType': options.wellType, // 井类型
+ 'form.wellcode': options.wellCode, // 井编号
+ 'form.position': options.position, // 位置
+ 'form.devicetype': '井盖状态监测仪', // 设备类型
+ 'form.installperson': app.globalData.currentUserName, // 安装人员
+ 'form.project': '2025-NBJ', // 所属项目
+ 'form.latitude': parseFloat(options.latitude).toFixed(6),
+ 'form.longitude': parseFloat(options.longitude).toFixed(6),
+ latitude: parseFloat(options.latitude).toFixed(6),
+ longitude: parseFloat(options.longitude).toFixed(6),
+ })
+ }
+ that.setData({
+ 'form.installperson': app.globalData.currentUserName, // 安装人员
+ 'form.project': '2025-NBJ', // 所属项目
+ })
+ },
+
+
+
+
+ /**
+ * 生命周期函数--监听页面初次渲染完成
+ */
+ onReady: function () {
+
+ },
+
+ /**
+ * 生命周期函数--监听页面显示
+ */
+ onShow: function () {
+
+ },
+
+ /**
+ * 生命周期函数--监听页面隐藏
+ */
+ onHide: function () {
+
+ },
+
+ /**
+ * 生命周期函数--监听页面卸载
+ */
+ onUnload: function () {
+
+ },
+
+ /**
+ * 页面相关事件处理函数--监听用户下拉动作
+ */
+ onPullDownRefresh: function () {
+
+ },
+
+ // 监听页面滚动
+ onPageScroll(e) {
+ console.log('监听页面滚动');
+ var that = this
+ console.log(that.selectComponent('#selectPersonDropdown'));
+ // that.selectComponent('#selectPersonDropdown').triggerEvent(false)
+},
+
+toggle() {
+
+},
+ // 点击检索
+ searchWellCode() {
+ if(!this.data.form.wellcode) {
+ wx.showToast({
+ icon: 'error',
+ title: '请先输入井编号',
+ })
+ return false
+ }
+ this.setData({
+ 'listQuery.wellCode': this.data.form.wellcode
+ })
+ this.fetchWellPre()
+ },
+ //获取井列表
+ fetchWellPre() {
+ return new Promise((resolve, reject) => {
+ var that = this
+ wx.showLoading({
+ mask: true
+ })
+ wx.request({
+ method: "POST",
+ url: app.globalData.httpsUrl + "well/pre/listPage" + `?offset=${1}&limit=${9999}`,
+ // header: {
+ // 'content-type': 'application/x-www-form-urlencoded;charset=utf-8'
+ // },
+ data: {
+ ...that.data.listQuery,
+ offset: 1,
+ limit: 9999
+ },
+ success(res) {
+ wx.hideLoading()
+ if (res.data) {
+ if(!res.data.data.rows.length) {
+ wx.showToast({
+ icon: 'error',
+ title: '查无结果'
+ })
+ } else {
+ const tempList = res.data.data.rows.map(item => {
+ return {
+ ...item,
+ name: item.wellName,
+ }
+ })
+ that.setData({
+ wellActions: tempList,
+ wellShow: true
+ })
+ }
+ }
+ },
+ fail(res) {
+ wx.hideLoading()
+ wx.showToast({
+ icon: 'none',
+ title: '查询失败,请手动输入'
+ })
+ }
+ })
+ })
+ },
+ // 点击选择器的取消
+ cancleWellShow() {
+ this.setData({
+ wellShow: false,
+ })
+ },
+ // 选择好井
+ selectWells(e) {
+ var that = this
+ const val = e.detail
+ console.log(val);
+ that.setData({
+ 'form.wellcode': val.wellCode, // 井编号
+ 'form.wellname': val.wellName, // 井名称
+ 'form.welltype': val.wellType, // 井类型
+ 'form.position': val.position, //位置描述
+ })
+ that.cancleWellShow()
+ },
+
+ /**
+ * 页面上拉触底事件的处理函数
+ */
+ onReachBottom: function () {
+
+ },
+
+ /**
+ * 用户点击右上角分享
+ */
+ onShareAppMessage: function () {
+
+ },
+
+
+
+ /**
+ * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true
+ **/
+
+ isNumber: function (val) {
+
+ var regPos = /^[0-9]*$/; //非负浮点数
+ var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数
+ if (regPos.test(val) || regNeg.test(val)) {
+ return false;
+ } else {
+ return true;
+ }
+
+ },
+
+ //验证表单
+ formValidate() {
+
+ if (this.data.form.devcode == "") {
+ 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',
+ title: '井编号不能为空!',
+ })
+ return false
+ }
+
+ if (this.data.form.devicetype == "") {
+ wx.showToast({
+ icon: 'none',
+ title: '设备类型不能为空!',
+ })
+ return false
+ }
+
+
+
+ if (this.data.form.installperson == "") {
+ 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
+ }
+ }
+
+ if (this.data.form.project == "") {
+ wx.showToast({
+ icon: 'none',
+ title: '所属项目不能为空!',
+ })
+ return false
+ }
+
+ if (this.data.form.installtimeFmt == null) {
+ wx.showToast({
+ icon: 'none',
+ title: '安装时间不能为空!',
+ })
+ return false
+ }
+ return true;
+ },
+ //提交表单
+ formSubmit: function (event) {
+ console.log(this.data.form)
+ //表单参数验证
+ if (!this.formValidate()) {
+ return false;
+ }
+ var that = this;
+ //验证设备编号长度
+ wx.request({
+ method: 'POST',
+ url: app.globalData.httpsUrl + "appDeviceAdd/getDevTypeLength",
+ data: {
+ code: encodeURI(this.data.form.devicetype)
+ },
+ 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
+ }
+ }
+ })
+ },
+
+ //保存设备基本信息
+ 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]
+ })
+ }
+ that.setData({
+ 'form.project': that.data.form.project,
+ 'projectName': that.data.form.project,
+ })
+ //表单提交
+ 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: '提交成功,是否返回?',
+ showCancel: false, // 不显示取消按钮
+ success: function (res) {
+ console.log('用户点击了返回')
+ //用于回显
+ console.log('lll', that.data.form);
+ wx.setStorageSync('cacheList', that.data.form)
+ //提交成功后提示用户操作
+ if (res.confirm) {
+ // wx.switchTab({
+ // url: '../earth/earth'
+ // })
+ console.log('lleeel', that.data.form);
+ app.globalData.addsuccessWellCode = that.data.form.wellcode
+ wx.navigateBack({ // 返回上一页
+ delta: 1
+ });
+ } else { //这里是点击了取消以后
+ console.log('用户点击取消')
+ }
+ }
+ })
+ }
+ },
+ fail(err) {
+ wx.showToast({
+ title: '提交失败!',
+ })
+ }
+ })
+ },
+ // 井编号输入框点击清除按钮
+// clickClearable() {
+// this.setData({
+// 'form.wellcode': ''
+// })
+// },
+ // 井编号改变
+ changeWellCode(e) {
+ console.log(e);
+ this.setData({
+ 'form.wellcode': e.detail
+ })
+ },
+
+ //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,
+ })
+ //若输入是设备编号,自动获取设备类型
+ 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({
+ success(res) {
+ var devcode = res.result
+ var formdevcode = 'form.devcode'
+ _this.setData({
+ [formdevcode]: devcode
+ });
+ wx.request({
+ method: 'POST',
+ url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode",
+ data: {
+ devcode: devcode,
+ },
+ 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({
+ 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),
+ });
+ _this.showAddress(_this.data.form.longitude,_this.data.form.latitude,_this)
+ }
+ })
+ },
+ //设置经类型
+ selectValue(value) {
+
+ var that = this;
+ var wellType = 'form.welltype';
+ that.setData({
+ [wellType]: value.detail
+ })
+ },
+ // 设置设备安装情况
+ selectInstallType(value) {
+ var that = this;
+ var installType = 'form.installType';
+ var description = 'form.description';
+ that.setData({
+ [installType]: value.detail,
+ [description]: installTypeMap[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';
+ that.setData({
+ [installPerson]: event.detail
+ })
+ },
+ //设置项目
+ selectprojectValue(event) {
+ var that = this;
+ var project = 'form.project';
+ that.setData({
+ [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;
+ 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
+ });
+ }
+ }
+ })
+ }
+ })
+ },
+ //删除照片
+ deletePhoto(event) {
+ var image_index = event.detail.index
+ var fileList_new = this.data.fileList;
+ fileList_new.splice(image_index, 1);
+ this.setData({
+ fileList: fileList_new
+ })
+ },
+})
\ No newline at end of file
diff --git a/miniprogram/pages/addDevice/addDevice copy.wxml b/miniprogram/pages/addDevice/addDevice copy.wxml
new file mode 100644
index 0000000..d3a77a0
--- /dev/null
+++ b/miniprogram/pages/addDevice/addDevice copy.wxml
@@ -0,0 +1,129 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 保存
+
+
+
+
+
\ No newline at end of file
diff --git a/miniprogram/app.js b/miniprogram/app.js
index c10326f..4f1ad89 100644
--- a/miniprogram/app.js
+++ b/miniprogram/app.js
@@ -20,7 +20,7 @@
globalData: {
httpsUrl: "https://logapi.smartlog.work/", // 正式域名
// httpsUrl: "http://111.198.10.15:11638/", // 15
- // httpsUrl: "http://192.168.126.39:5905/", // 周甜
+ // httpsUrl: "http://192.168.95.39:5905/", // 周甜
// httpsUrl: "https://grey.logapi.smartlog.work/", // 测试域名
openid: null,
indexCount:1,
diff --git a/miniprogram/app.json b/miniprogram/app.json
index 3c1d780..975101c 100644
--- a/miniprogram/app.json
+++ b/miniprogram/app.json
@@ -50,6 +50,9 @@
"permission": {
"scope.userLocation": {
"desc": "你的位置信息将用于小程序位置接口的效果展示"
+ },
+ "scope.camera": {
+ "desc": "你的小程序需要使用相机来完成相关操作,如扫描设备、上传照片等"
}
},
"requiredPrivateInfos": [
diff --git a/miniprogram/images/red-marker.png b/miniprogram/images/red-marker.png
new file mode 100644
index 0000000..ed00cf5
--- /dev/null
+++ b/miniprogram/images/red-marker.png
Binary files differ
diff --git a/miniprogram/pages/addDevice/addDevice copy.js b/miniprogram/pages/addDevice/addDevice copy.js
new file mode 100644
index 0000000..fcf664d
--- /dev/null
+++ b/miniprogram/pages/addDevice/addDevice copy.js
@@ -0,0 +1,947 @@
+// miniprogram/pages/addDevice/addDevice.js
+// import WxValidate from '../../utils/WxValidate.js'
+var QQMapWX = require('../../libs/qqmap-wx-jssdk.js');
+var qqmapsdk;
+var app = getApp()
+const installTypeMap = {
+ '1': '初次安装',
+ '2': '初次拆走',
+ '3': '二次安装',
+ '4': '二次拆走',
+ '5': '正在维护',
+ '6': '其他',
+}
+Page({
+
+ /**
+ * 页面的初始数据
+ */
+ data: {
+ wellActions: [], // 选择井编号
+ wellShow: false, // 是否显示选择井编号
+ projectName: '', // 项目名称
+ canvasHeight: '',
+ canvasWidth: '',
+ longitude: '',
+ latitude: '',
+ option1: [],
+ personoption1: [],
+ projectoption: [],
+ devtypeList:[],
+ installTypeList:[
+ {
+ text: '初次安装',
+ value: '1',
+ },
+ {
+ text: '初次拆走',
+ value: '2',
+ },
+ {
+ text: '二次安装',
+ value: '3',
+ },
+ {
+ text: '二次拆走',
+ value: '4',
+ },
+ {
+ text: '正在维护',
+ value: '5',
+ },
+ {
+ text: '其他',
+ value: '6',
+ },
+ ],
+ show: false,
+ form: {
+ devcode: "",
+ wellcode: "",
+ welltype: "",
+ welldepth: "",
+ installheigt: "",
+ installperson: "",
+ installtimeFmt: "",
+ photopath: "",
+ factory: "",
+ workmsg: "",
+ position: "",
+ longitude: "",
+ latitude: "",
+ longitude84: "",
+ latitude84: "",
+ devicetype: "",
+ project: '',
+ area: "",
+ street: "",
+ wellname: "",
+ photopath1: '',
+ photopath2: '',
+ photopath3: '',
+ installType: '1', // 设备安装情况
+ description: "初次安装", // 备注
+ },
+ fileList: [],
+ listQuery: {
+ wellCode: '', // wellCode
+ wellType: '', // 井类型
+ position: '', // 位置
+ projectId: '', // 所在项目
+ },
+ showSelectProject: false,
+ },
+
+ onDisplay() {
+ this.setData({
+ show: true
+ });
+ },
+ onClose() {
+ this.setData({
+ show: false
+ });
+ },
+ // cleaable 清除经度
+ clearLongitude() {
+ var _this = this;
+ _this.setData({
+ 'form.longitude': '',
+ });
+ },
+// 清除纬度
+ clearclearLatitude() {
+ var _this = this;
+ _this.setData({
+ 'form.latitude': '',
+ });
+ },
+ 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),
+ });
+ },
+
+ /**
+ * 生命周期函数--监听页面加载
+ */
+ onLoad: function (options) {
+ var that = this;
+ if(app.globalData.role === 'repair' && app.globalData.isConfigProject === '0') {
+ that.setData({
+ 'showSelectProject': true,
+ })
+ } else {
+ that.setData({
+ 'showSelectProject': false,
+ })
+ }
+
+ console.log(app.globalData.selectProjectId, '===');
+ that.setData({
+ 'form.project': app.globalData.selectProjectName,
+ 'projectName': app.globalData.selectProjectName,
+ })
+ console.log('-----------------------3333', options);
+ //=========初始化表单内容为上次填写值==========
+ // 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
+ //默认安装经纬度为当前位置(gcj02)
+ if(options.fromPage !== 'defineMap') {
+ wx.getLocation({
+ type: "gcj02",
+ altitude: true,
+ success: function (res) {
+ var longitude = 'form.longitude';
+ var latitude = 'form.latitude';
+ that.setData({
+ [longitude]: parseFloat(res.longitude).toFixed(6),
+ [latitude]: parseFloat(res.latitude).toFixed(6),
+ longitude: parseFloat(res.longitude).toFixed(6),
+ latitude: parseFloat(res.latitude).toFixed(6),
+ });
+ //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误
+ wx.getLocation({
+ type: "wgs84",
+ altitude: true,
+ success: function (res) {
+ var longitude84 = 'form.longitude84';
+ var latitude84 = 'form.latitude84';
+ that.setData({
+ [latitude84]: parseFloat(res.latitude).toFixed(6),
+ [longitude84]: parseFloat(res.longitude).toFixed(6)
+ })
+ }
+ })
+ }
+ })
+ }
+
+
+ //获取井类型下拉列表
+ 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);
+ }
+ console.log('------', welltypeArr)
+ that.setData({
+ option1: welltypeArr
+ })
+ }
+ }
+ })
+
+ //获取人员下拉列表
+ 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);
+ }
+ personArr.push({
+ text: app.globalData.currentUserName,
+ value: app.globalData.currentUserName
+ });
+
+ that.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);
+ }
+ that.setData({
+ projectoption: projectArr
+ })
+ }
+ }
+ })
+
+ var installtime = 'form.installtimeFmt';
+ var dateNow = this.formatDate();
+ this.setData({
+ show: false,
+ 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
+ })
+ }
+ }
+ })
+
+ // 粘贴经纬度
+ if(options.fromPage !== 'defineMap') {
+ this.paste()
+ }
+ // 处理备注的默认
+ var description = 'form.description';
+ that.setData({
+ [description]: installTypeMap[that.data.form.installType]
+ })
+ console.log('options', options);
+ if(options.fromPage === 'defineMap') { // 从自定义地图页面跳转过来
+ console.log('-09999999999', app.globalData.currentUserName);
+ that.setData({
+ 'form.wellType': options.wellType, // 井类型
+ 'form.wellcode': options.wellCode, // 井编号
+ 'form.position': options.position, // 位置
+ 'form.devicetype': '井盖状态监测仪', // 设备类型
+ 'form.installperson': app.globalData.currentUserName, // 安装人员
+ 'form.project': '2025-NBJ', // 所属项目
+ 'form.latitude': parseFloat(options.latitude).toFixed(6),
+ 'form.longitude': parseFloat(options.longitude).toFixed(6),
+ latitude: parseFloat(options.latitude).toFixed(6),
+ longitude: parseFloat(options.longitude).toFixed(6),
+ })
+ }
+ that.setData({
+ 'form.installperson': app.globalData.currentUserName, // 安装人员
+ 'form.project': '2025-NBJ', // 所属项目
+ })
+ },
+
+
+
+
+ /**
+ * 生命周期函数--监听页面初次渲染完成
+ */
+ onReady: function () {
+
+ },
+
+ /**
+ * 生命周期函数--监听页面显示
+ */
+ onShow: function () {
+
+ },
+
+ /**
+ * 生命周期函数--监听页面隐藏
+ */
+ onHide: function () {
+
+ },
+
+ /**
+ * 生命周期函数--监听页面卸载
+ */
+ onUnload: function () {
+
+ },
+
+ /**
+ * 页面相关事件处理函数--监听用户下拉动作
+ */
+ onPullDownRefresh: function () {
+
+ },
+
+ // 监听页面滚动
+ onPageScroll(e) {
+ console.log('监听页面滚动');
+ var that = this
+ console.log(that.selectComponent('#selectPersonDropdown'));
+ // that.selectComponent('#selectPersonDropdown').triggerEvent(false)
+},
+
+toggle() {
+
+},
+ // 点击检索
+ searchWellCode() {
+ if(!this.data.form.wellcode) {
+ wx.showToast({
+ icon: 'error',
+ title: '请先输入井编号',
+ })
+ return false
+ }
+ this.setData({
+ 'listQuery.wellCode': this.data.form.wellcode
+ })
+ this.fetchWellPre()
+ },
+ //获取井列表
+ fetchWellPre() {
+ return new Promise((resolve, reject) => {
+ var that = this
+ wx.showLoading({
+ mask: true
+ })
+ wx.request({
+ method: "POST",
+ url: app.globalData.httpsUrl + "well/pre/listPage" + `?offset=${1}&limit=${9999}`,
+ // header: {
+ // 'content-type': 'application/x-www-form-urlencoded;charset=utf-8'
+ // },
+ data: {
+ ...that.data.listQuery,
+ offset: 1,
+ limit: 9999
+ },
+ success(res) {
+ wx.hideLoading()
+ if (res.data) {
+ if(!res.data.data.rows.length) {
+ wx.showToast({
+ icon: 'error',
+ title: '查无结果'
+ })
+ } else {
+ const tempList = res.data.data.rows.map(item => {
+ return {
+ ...item,
+ name: item.wellName,
+ }
+ })
+ that.setData({
+ wellActions: tempList,
+ wellShow: true
+ })
+ }
+ }
+ },
+ fail(res) {
+ wx.hideLoading()
+ wx.showToast({
+ icon: 'none',
+ title: '查询失败,请手动输入'
+ })
+ }
+ })
+ })
+ },
+ // 点击选择器的取消
+ cancleWellShow() {
+ this.setData({
+ wellShow: false,
+ })
+ },
+ // 选择好井
+ selectWells(e) {
+ var that = this
+ const val = e.detail
+ console.log(val);
+ that.setData({
+ 'form.wellcode': val.wellCode, // 井编号
+ 'form.wellname': val.wellName, // 井名称
+ 'form.welltype': val.wellType, // 井类型
+ 'form.position': val.position, //位置描述
+ })
+ that.cancleWellShow()
+ },
+
+ /**
+ * 页面上拉触底事件的处理函数
+ */
+ onReachBottom: function () {
+
+ },
+
+ /**
+ * 用户点击右上角分享
+ */
+ onShareAppMessage: function () {
+
+ },
+
+
+
+ /**
+ * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true
+ **/
+
+ isNumber: function (val) {
+
+ var regPos = /^[0-9]*$/; //非负浮点数
+ var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数
+ if (regPos.test(val) || regNeg.test(val)) {
+ return false;
+ } else {
+ return true;
+ }
+
+ },
+
+ //验证表单
+ formValidate() {
+
+ if (this.data.form.devcode == "") {
+ 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',
+ title: '井编号不能为空!',
+ })
+ return false
+ }
+
+ if (this.data.form.devicetype == "") {
+ wx.showToast({
+ icon: 'none',
+ title: '设备类型不能为空!',
+ })
+ return false
+ }
+
+
+
+ if (this.data.form.installperson == "") {
+ 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
+ }
+ }
+
+ if (this.data.form.project == "") {
+ wx.showToast({
+ icon: 'none',
+ title: '所属项目不能为空!',
+ })
+ return false
+ }
+
+ if (this.data.form.installtimeFmt == null) {
+ wx.showToast({
+ icon: 'none',
+ title: '安装时间不能为空!',
+ })
+ return false
+ }
+ return true;
+ },
+ //提交表单
+ formSubmit: function (event) {
+ console.log(this.data.form)
+ //表单参数验证
+ if (!this.formValidate()) {
+ return false;
+ }
+ var that = this;
+ //验证设备编号长度
+ wx.request({
+ method: 'POST',
+ url: app.globalData.httpsUrl + "appDeviceAdd/getDevTypeLength",
+ data: {
+ code: encodeURI(this.data.form.devicetype)
+ },
+ 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
+ }
+ }
+ })
+ },
+
+ //保存设备基本信息
+ 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]
+ })
+ }
+ that.setData({
+ 'form.project': that.data.form.project,
+ 'projectName': that.data.form.project,
+ })
+ //表单提交
+ 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: '提交成功,是否返回?',
+ showCancel: false, // 不显示取消按钮
+ success: function (res) {
+ console.log('用户点击了返回')
+ //用于回显
+ console.log('lll', that.data.form);
+ wx.setStorageSync('cacheList', that.data.form)
+ //提交成功后提示用户操作
+ if (res.confirm) {
+ // wx.switchTab({
+ // url: '../earth/earth'
+ // })
+ console.log('lleeel', that.data.form);
+ app.globalData.addsuccessWellCode = that.data.form.wellcode
+ wx.navigateBack({ // 返回上一页
+ delta: 1
+ });
+ } else { //这里是点击了取消以后
+ console.log('用户点击取消')
+ }
+ }
+ })
+ }
+ },
+ fail(err) {
+ wx.showToast({
+ title: '提交失败!',
+ })
+ }
+ })
+ },
+ // 井编号输入框点击清除按钮
+// clickClearable() {
+// this.setData({
+// 'form.wellcode': ''
+// })
+// },
+ // 井编号改变
+ changeWellCode(e) {
+ console.log(e);
+ this.setData({
+ 'form.wellcode': e.detail
+ })
+ },
+
+ //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,
+ })
+ //若输入是设备编号,自动获取设备类型
+ 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({
+ success(res) {
+ var devcode = res.result
+ var formdevcode = 'form.devcode'
+ _this.setData({
+ [formdevcode]: devcode
+ });
+ wx.request({
+ method: 'POST',
+ url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode",
+ data: {
+ devcode: devcode,
+ },
+ 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({
+ 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),
+ });
+ _this.showAddress(_this.data.form.longitude,_this.data.form.latitude,_this)
+ }
+ })
+ },
+ //设置经类型
+ selectValue(value) {
+
+ var that = this;
+ var wellType = 'form.welltype';
+ that.setData({
+ [wellType]: value.detail
+ })
+ },
+ // 设置设备安装情况
+ selectInstallType(value) {
+ var that = this;
+ var installType = 'form.installType';
+ var description = 'form.description';
+ that.setData({
+ [installType]: value.detail,
+ [description]: installTypeMap[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';
+ that.setData({
+ [installPerson]: event.detail
+ })
+ },
+ //设置项目
+ selectprojectValue(event) {
+ var that = this;
+ var project = 'form.project';
+ that.setData({
+ [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;
+ 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
+ });
+ }
+ }
+ })
+ }
+ })
+ },
+ //删除照片
+ deletePhoto(event) {
+ var image_index = event.detail.index
+ var fileList_new = this.data.fileList;
+ fileList_new.splice(image_index, 1);
+ this.setData({
+ fileList: fileList_new
+ })
+ },
+})
\ No newline at end of file
diff --git a/miniprogram/pages/addDevice/addDevice copy.wxml b/miniprogram/pages/addDevice/addDevice copy.wxml
new file mode 100644
index 0000000..d3a77a0
--- /dev/null
+++ b/miniprogram/pages/addDevice/addDevice copy.wxml
@@ -0,0 +1,129 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 保存
+
+
+
+
+
\ No newline at end of file
diff --git a/miniprogram/pages/addDevice/addDevice.js b/miniprogram/pages/addDevice/addDevice.js
index fcf664d..b397d10 100644
--- a/miniprogram/pages/addDevice/addDevice.js
+++ b/miniprogram/pages/addDevice/addDevice.js
@@ -90,6 +90,9 @@
projectId: '', // 所在项目
},
showSelectProject: false,
+ showCamera: false,
+ flashMode: 'torch', // 闪光灯模式: off | on | auto
+ maxCount: 6, // 最多能上传几张图片
},
onDisplay() {
@@ -885,7 +888,61 @@
});
},
//上传照片
- afterRead(event) {
+ afterReadCamera(event) {
+ var _this = this;
+ if (_this.data.form.devcode == "") {
+ wx.showToast({
+ icon: 'none',
+ title: '请先填写设备编号!\r\n否则水印中无编号',
+ duration: 2000
+ })
+ return false
+ }
+ // const {
+ // file
+ // } = event.detail;
+ const file = event
+ const {
+ fileList = []
+ } = this.data;
+ var convertpath = "";
+ // 压缩图片
+ wx.compressImage({
+ src: event.tempImagePath,
+ // 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
+ });
+ console.log('fileList', _this.data.fileList);
+ }
+ }
+ })
+ }
+ })
+ },
+ //上传照片
+ afterRead(event) {
var _this = this;
if (_this.data.form.devcode == "") {
wx.showToast({
@@ -898,6 +955,7 @@
const {
file
} = event.detail;
+ // const file = event
const {
fileList = []
} = this.data;
@@ -929,6 +987,7 @@
_this.setData({
fileList
});
+ console.log('fileList', _this.data.fileList);
}
}
})
@@ -944,4 +1003,107 @@
fileList: fileList_new
})
},
-})
\ No newline at end of file
+
+ // 切换闪光灯模式
+ toggleFlash() {
+ var that = this
+ const flashMode = that.data.flashMode === 'off' ? 'torch' : 'off';
+ that.setData({ 'flashMode': flashMode });
+ },
+
+ // 拍摄照片
+ takePhoto() {
+ console.log('闪光灯', this.data.flashMode);
+ const ctx = wx.createCameraContext();
+ ctx.takePhoto({
+ quality: 'high',
+ success: (res) => {
+ this.setData({
+ tempImagePath: res.tempImagePath,
+ showCamera: false
+ });
+
+ this.afterReadCamera(res)
+ console.log('拍摄的图片', res);
+ },
+ fail: (err) => {
+ console.error('拍摄失败:', err);
+ wx.showToast({
+ title: '拍摄失败,请重试',
+ icon: 'none'
+ });
+ }
+ });
+ },
+
+ // 取消拍摄
+ cancelCamera() {
+ this.setData({ showCamera: false });
+ },
+ // 打开相机
+ openCamera() {
+ var that= this
+ if (that.data.form.devcode == "") {
+ wx.showToast({
+ icon: 'none',
+ title: '请先填写设备编号!\r\n否则水印中无编号',
+ duration: 2000
+ })
+ return false
+ }
+ if(Array.isArray(that.data.fileList) && that.data.fileList.length >= 6) {
+ wx.showToast({
+ icon: 'none',
+ title: '最多只允许上传6张图片',
+ duration: 2000
+ })
+ return false
+ }
+ that.setData({
+ 'showCamera': true
+ })
+ },
+// ---------------------------------新的-----------------------------------------------
+
+ /**
+ * 从相册选择(保持不变)
+ */
+ chooseFromAlbum() {
+ if (this.data.fileList.length >= this.data.maxCount) {
+ wx.showToast({ title: `最多选择${this.data.maxCount}张`, icon: 'none' });
+ return;
+ }
+
+ wx.chooseMedia({
+ count: this.data.maxCount - this.data.fileList.length,
+ mediaType: ['image'],
+ sourceType: ['album']
+ })
+ .then(res => {
+ const newImages = res.tempFiles.map(file => ({
+ tempFilePath: file.tempFilePath,
+ }));
+ this.afterRead()
+ const updatedList = [...this.data.fileList, ...newImages];
+ this.setData({
+ fileList: updatedList,
+ });
+
+ // newImages.forEach((img, idx) => {
+ // const globalIndex = this.data.fileList.length + idx;
+ // this.uploadSingleImage(globalIndex);
+ // });
+ })
+ .catch(err => {
+ console.error('选择相册失败:', err);
+ if (err.errMsg.includes('deny')) {
+ wx.showModal({
+ title: '权限不足',
+ content: '请在设置中开启相册权限',
+ confirmText: '去设置',
+ success: res => res.confirm && wx.openSetting()
+ });
+ }
+ });
+ },
+});
\ No newline at end of file
diff --git a/miniprogram/app.js b/miniprogram/app.js
index c10326f..4f1ad89 100644
--- a/miniprogram/app.js
+++ b/miniprogram/app.js
@@ -20,7 +20,7 @@
globalData: {
httpsUrl: "https://logapi.smartlog.work/", // 正式域名
// httpsUrl: "http://111.198.10.15:11638/", // 15
- // httpsUrl: "http://192.168.126.39:5905/", // 周甜
+ // httpsUrl: "http://192.168.95.39:5905/", // 周甜
// httpsUrl: "https://grey.logapi.smartlog.work/", // 测试域名
openid: null,
indexCount:1,
diff --git a/miniprogram/app.json b/miniprogram/app.json
index 3c1d780..975101c 100644
--- a/miniprogram/app.json
+++ b/miniprogram/app.json
@@ -50,6 +50,9 @@
"permission": {
"scope.userLocation": {
"desc": "你的位置信息将用于小程序位置接口的效果展示"
+ },
+ "scope.camera": {
+ "desc": "你的小程序需要使用相机来完成相关操作,如扫描设备、上传照片等"
}
},
"requiredPrivateInfos": [
diff --git a/miniprogram/images/red-marker.png b/miniprogram/images/red-marker.png
new file mode 100644
index 0000000..ed00cf5
--- /dev/null
+++ b/miniprogram/images/red-marker.png
Binary files differ
diff --git a/miniprogram/pages/addDevice/addDevice copy.js b/miniprogram/pages/addDevice/addDevice copy.js
new file mode 100644
index 0000000..fcf664d
--- /dev/null
+++ b/miniprogram/pages/addDevice/addDevice copy.js
@@ -0,0 +1,947 @@
+// miniprogram/pages/addDevice/addDevice.js
+// import WxValidate from '../../utils/WxValidate.js'
+var QQMapWX = require('../../libs/qqmap-wx-jssdk.js');
+var qqmapsdk;
+var app = getApp()
+const installTypeMap = {
+ '1': '初次安装',
+ '2': '初次拆走',
+ '3': '二次安装',
+ '4': '二次拆走',
+ '5': '正在维护',
+ '6': '其他',
+}
+Page({
+
+ /**
+ * 页面的初始数据
+ */
+ data: {
+ wellActions: [], // 选择井编号
+ wellShow: false, // 是否显示选择井编号
+ projectName: '', // 项目名称
+ canvasHeight: '',
+ canvasWidth: '',
+ longitude: '',
+ latitude: '',
+ option1: [],
+ personoption1: [],
+ projectoption: [],
+ devtypeList:[],
+ installTypeList:[
+ {
+ text: '初次安装',
+ value: '1',
+ },
+ {
+ text: '初次拆走',
+ value: '2',
+ },
+ {
+ text: '二次安装',
+ value: '3',
+ },
+ {
+ text: '二次拆走',
+ value: '4',
+ },
+ {
+ text: '正在维护',
+ value: '5',
+ },
+ {
+ text: '其他',
+ value: '6',
+ },
+ ],
+ show: false,
+ form: {
+ devcode: "",
+ wellcode: "",
+ welltype: "",
+ welldepth: "",
+ installheigt: "",
+ installperson: "",
+ installtimeFmt: "",
+ photopath: "",
+ factory: "",
+ workmsg: "",
+ position: "",
+ longitude: "",
+ latitude: "",
+ longitude84: "",
+ latitude84: "",
+ devicetype: "",
+ project: '',
+ area: "",
+ street: "",
+ wellname: "",
+ photopath1: '',
+ photopath2: '',
+ photopath3: '',
+ installType: '1', // 设备安装情况
+ description: "初次安装", // 备注
+ },
+ fileList: [],
+ listQuery: {
+ wellCode: '', // wellCode
+ wellType: '', // 井类型
+ position: '', // 位置
+ projectId: '', // 所在项目
+ },
+ showSelectProject: false,
+ },
+
+ onDisplay() {
+ this.setData({
+ show: true
+ });
+ },
+ onClose() {
+ this.setData({
+ show: false
+ });
+ },
+ // cleaable 清除经度
+ clearLongitude() {
+ var _this = this;
+ _this.setData({
+ 'form.longitude': '',
+ });
+ },
+// 清除纬度
+ clearclearLatitude() {
+ var _this = this;
+ _this.setData({
+ 'form.latitude': '',
+ });
+ },
+ 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),
+ });
+ },
+
+ /**
+ * 生命周期函数--监听页面加载
+ */
+ onLoad: function (options) {
+ var that = this;
+ if(app.globalData.role === 'repair' && app.globalData.isConfigProject === '0') {
+ that.setData({
+ 'showSelectProject': true,
+ })
+ } else {
+ that.setData({
+ 'showSelectProject': false,
+ })
+ }
+
+ console.log(app.globalData.selectProjectId, '===');
+ that.setData({
+ 'form.project': app.globalData.selectProjectName,
+ 'projectName': app.globalData.selectProjectName,
+ })
+ console.log('-----------------------3333', options);
+ //=========初始化表单内容为上次填写值==========
+ // 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
+ //默认安装经纬度为当前位置(gcj02)
+ if(options.fromPage !== 'defineMap') {
+ wx.getLocation({
+ type: "gcj02",
+ altitude: true,
+ success: function (res) {
+ var longitude = 'form.longitude';
+ var latitude = 'form.latitude';
+ that.setData({
+ [longitude]: parseFloat(res.longitude).toFixed(6),
+ [latitude]: parseFloat(res.latitude).toFixed(6),
+ longitude: parseFloat(res.longitude).toFixed(6),
+ latitude: parseFloat(res.latitude).toFixed(6),
+ });
+ //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误
+ wx.getLocation({
+ type: "wgs84",
+ altitude: true,
+ success: function (res) {
+ var longitude84 = 'form.longitude84';
+ var latitude84 = 'form.latitude84';
+ that.setData({
+ [latitude84]: parseFloat(res.latitude).toFixed(6),
+ [longitude84]: parseFloat(res.longitude).toFixed(6)
+ })
+ }
+ })
+ }
+ })
+ }
+
+
+ //获取井类型下拉列表
+ 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);
+ }
+ console.log('------', welltypeArr)
+ that.setData({
+ option1: welltypeArr
+ })
+ }
+ }
+ })
+
+ //获取人员下拉列表
+ 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);
+ }
+ personArr.push({
+ text: app.globalData.currentUserName,
+ value: app.globalData.currentUserName
+ });
+
+ that.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);
+ }
+ that.setData({
+ projectoption: projectArr
+ })
+ }
+ }
+ })
+
+ var installtime = 'form.installtimeFmt';
+ var dateNow = this.formatDate();
+ this.setData({
+ show: false,
+ 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
+ })
+ }
+ }
+ })
+
+ // 粘贴经纬度
+ if(options.fromPage !== 'defineMap') {
+ this.paste()
+ }
+ // 处理备注的默认
+ var description = 'form.description';
+ that.setData({
+ [description]: installTypeMap[that.data.form.installType]
+ })
+ console.log('options', options);
+ if(options.fromPage === 'defineMap') { // 从自定义地图页面跳转过来
+ console.log('-09999999999', app.globalData.currentUserName);
+ that.setData({
+ 'form.wellType': options.wellType, // 井类型
+ 'form.wellcode': options.wellCode, // 井编号
+ 'form.position': options.position, // 位置
+ 'form.devicetype': '井盖状态监测仪', // 设备类型
+ 'form.installperson': app.globalData.currentUserName, // 安装人员
+ 'form.project': '2025-NBJ', // 所属项目
+ 'form.latitude': parseFloat(options.latitude).toFixed(6),
+ 'form.longitude': parseFloat(options.longitude).toFixed(6),
+ latitude: parseFloat(options.latitude).toFixed(6),
+ longitude: parseFloat(options.longitude).toFixed(6),
+ })
+ }
+ that.setData({
+ 'form.installperson': app.globalData.currentUserName, // 安装人员
+ 'form.project': '2025-NBJ', // 所属项目
+ })
+ },
+
+
+
+
+ /**
+ * 生命周期函数--监听页面初次渲染完成
+ */
+ onReady: function () {
+
+ },
+
+ /**
+ * 生命周期函数--监听页面显示
+ */
+ onShow: function () {
+
+ },
+
+ /**
+ * 生命周期函数--监听页面隐藏
+ */
+ onHide: function () {
+
+ },
+
+ /**
+ * 生命周期函数--监听页面卸载
+ */
+ onUnload: function () {
+
+ },
+
+ /**
+ * 页面相关事件处理函数--监听用户下拉动作
+ */
+ onPullDownRefresh: function () {
+
+ },
+
+ // 监听页面滚动
+ onPageScroll(e) {
+ console.log('监听页面滚动');
+ var that = this
+ console.log(that.selectComponent('#selectPersonDropdown'));
+ // that.selectComponent('#selectPersonDropdown').triggerEvent(false)
+},
+
+toggle() {
+
+},
+ // 点击检索
+ searchWellCode() {
+ if(!this.data.form.wellcode) {
+ wx.showToast({
+ icon: 'error',
+ title: '请先输入井编号',
+ })
+ return false
+ }
+ this.setData({
+ 'listQuery.wellCode': this.data.form.wellcode
+ })
+ this.fetchWellPre()
+ },
+ //获取井列表
+ fetchWellPre() {
+ return new Promise((resolve, reject) => {
+ var that = this
+ wx.showLoading({
+ mask: true
+ })
+ wx.request({
+ method: "POST",
+ url: app.globalData.httpsUrl + "well/pre/listPage" + `?offset=${1}&limit=${9999}`,
+ // header: {
+ // 'content-type': 'application/x-www-form-urlencoded;charset=utf-8'
+ // },
+ data: {
+ ...that.data.listQuery,
+ offset: 1,
+ limit: 9999
+ },
+ success(res) {
+ wx.hideLoading()
+ if (res.data) {
+ if(!res.data.data.rows.length) {
+ wx.showToast({
+ icon: 'error',
+ title: '查无结果'
+ })
+ } else {
+ const tempList = res.data.data.rows.map(item => {
+ return {
+ ...item,
+ name: item.wellName,
+ }
+ })
+ that.setData({
+ wellActions: tempList,
+ wellShow: true
+ })
+ }
+ }
+ },
+ fail(res) {
+ wx.hideLoading()
+ wx.showToast({
+ icon: 'none',
+ title: '查询失败,请手动输入'
+ })
+ }
+ })
+ })
+ },
+ // 点击选择器的取消
+ cancleWellShow() {
+ this.setData({
+ wellShow: false,
+ })
+ },
+ // 选择好井
+ selectWells(e) {
+ var that = this
+ const val = e.detail
+ console.log(val);
+ that.setData({
+ 'form.wellcode': val.wellCode, // 井编号
+ 'form.wellname': val.wellName, // 井名称
+ 'form.welltype': val.wellType, // 井类型
+ 'form.position': val.position, //位置描述
+ })
+ that.cancleWellShow()
+ },
+
+ /**
+ * 页面上拉触底事件的处理函数
+ */
+ onReachBottom: function () {
+
+ },
+
+ /**
+ * 用户点击右上角分享
+ */
+ onShareAppMessage: function () {
+
+ },
+
+
+
+ /**
+ * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true
+ **/
+
+ isNumber: function (val) {
+
+ var regPos = /^[0-9]*$/; //非负浮点数
+ var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数
+ if (regPos.test(val) || regNeg.test(val)) {
+ return false;
+ } else {
+ return true;
+ }
+
+ },
+
+ //验证表单
+ formValidate() {
+
+ if (this.data.form.devcode == "") {
+ 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',
+ title: '井编号不能为空!',
+ })
+ return false
+ }
+
+ if (this.data.form.devicetype == "") {
+ wx.showToast({
+ icon: 'none',
+ title: '设备类型不能为空!',
+ })
+ return false
+ }
+
+
+
+ if (this.data.form.installperson == "") {
+ 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
+ }
+ }
+
+ if (this.data.form.project == "") {
+ wx.showToast({
+ icon: 'none',
+ title: '所属项目不能为空!',
+ })
+ return false
+ }
+
+ if (this.data.form.installtimeFmt == null) {
+ wx.showToast({
+ icon: 'none',
+ title: '安装时间不能为空!',
+ })
+ return false
+ }
+ return true;
+ },
+ //提交表单
+ formSubmit: function (event) {
+ console.log(this.data.form)
+ //表单参数验证
+ if (!this.formValidate()) {
+ return false;
+ }
+ var that = this;
+ //验证设备编号长度
+ wx.request({
+ method: 'POST',
+ url: app.globalData.httpsUrl + "appDeviceAdd/getDevTypeLength",
+ data: {
+ code: encodeURI(this.data.form.devicetype)
+ },
+ 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
+ }
+ }
+ })
+ },
+
+ //保存设备基本信息
+ 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]
+ })
+ }
+ that.setData({
+ 'form.project': that.data.form.project,
+ 'projectName': that.data.form.project,
+ })
+ //表单提交
+ 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: '提交成功,是否返回?',
+ showCancel: false, // 不显示取消按钮
+ success: function (res) {
+ console.log('用户点击了返回')
+ //用于回显
+ console.log('lll', that.data.form);
+ wx.setStorageSync('cacheList', that.data.form)
+ //提交成功后提示用户操作
+ if (res.confirm) {
+ // wx.switchTab({
+ // url: '../earth/earth'
+ // })
+ console.log('lleeel', that.data.form);
+ app.globalData.addsuccessWellCode = that.data.form.wellcode
+ wx.navigateBack({ // 返回上一页
+ delta: 1
+ });
+ } else { //这里是点击了取消以后
+ console.log('用户点击取消')
+ }
+ }
+ })
+ }
+ },
+ fail(err) {
+ wx.showToast({
+ title: '提交失败!',
+ })
+ }
+ })
+ },
+ // 井编号输入框点击清除按钮
+// clickClearable() {
+// this.setData({
+// 'form.wellcode': ''
+// })
+// },
+ // 井编号改变
+ changeWellCode(e) {
+ console.log(e);
+ this.setData({
+ 'form.wellcode': e.detail
+ })
+ },
+
+ //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,
+ })
+ //若输入是设备编号,自动获取设备类型
+ 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({
+ success(res) {
+ var devcode = res.result
+ var formdevcode = 'form.devcode'
+ _this.setData({
+ [formdevcode]: devcode
+ });
+ wx.request({
+ method: 'POST',
+ url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode",
+ data: {
+ devcode: devcode,
+ },
+ 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({
+ 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),
+ });
+ _this.showAddress(_this.data.form.longitude,_this.data.form.latitude,_this)
+ }
+ })
+ },
+ //设置经类型
+ selectValue(value) {
+
+ var that = this;
+ var wellType = 'form.welltype';
+ that.setData({
+ [wellType]: value.detail
+ })
+ },
+ // 设置设备安装情况
+ selectInstallType(value) {
+ var that = this;
+ var installType = 'form.installType';
+ var description = 'form.description';
+ that.setData({
+ [installType]: value.detail,
+ [description]: installTypeMap[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';
+ that.setData({
+ [installPerson]: event.detail
+ })
+ },
+ //设置项目
+ selectprojectValue(event) {
+ var that = this;
+ var project = 'form.project';
+ that.setData({
+ [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;
+ 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
+ });
+ }
+ }
+ })
+ }
+ })
+ },
+ //删除照片
+ deletePhoto(event) {
+ var image_index = event.detail.index
+ var fileList_new = this.data.fileList;
+ fileList_new.splice(image_index, 1);
+ this.setData({
+ fileList: fileList_new
+ })
+ },
+})
\ No newline at end of file
diff --git a/miniprogram/pages/addDevice/addDevice copy.wxml b/miniprogram/pages/addDevice/addDevice copy.wxml
new file mode 100644
index 0000000..d3a77a0
--- /dev/null
+++ b/miniprogram/pages/addDevice/addDevice copy.wxml
@@ -0,0 +1,129 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 保存
+
+
+
+
+
\ No newline at end of file
diff --git a/miniprogram/pages/addDevice/addDevice.js b/miniprogram/pages/addDevice/addDevice.js
index fcf664d..b397d10 100644
--- a/miniprogram/pages/addDevice/addDevice.js
+++ b/miniprogram/pages/addDevice/addDevice.js
@@ -90,6 +90,9 @@
projectId: '', // 所在项目
},
showSelectProject: false,
+ showCamera: false,
+ flashMode: 'torch', // 闪光灯模式: off | on | auto
+ maxCount: 6, // 最多能上传几张图片
},
onDisplay() {
@@ -885,7 +888,61 @@
});
},
//上传照片
- afterRead(event) {
+ afterReadCamera(event) {
+ var _this = this;
+ if (_this.data.form.devcode == "") {
+ wx.showToast({
+ icon: 'none',
+ title: '请先填写设备编号!\r\n否则水印中无编号',
+ duration: 2000
+ })
+ return false
+ }
+ // const {
+ // file
+ // } = event.detail;
+ const file = event
+ const {
+ fileList = []
+ } = this.data;
+ var convertpath = "";
+ // 压缩图片
+ wx.compressImage({
+ src: event.tempImagePath,
+ // 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
+ });
+ console.log('fileList', _this.data.fileList);
+ }
+ }
+ })
+ }
+ })
+ },
+ //上传照片
+ afterRead(event) {
var _this = this;
if (_this.data.form.devcode == "") {
wx.showToast({
@@ -898,6 +955,7 @@
const {
file
} = event.detail;
+ // const file = event
const {
fileList = []
} = this.data;
@@ -929,6 +987,7 @@
_this.setData({
fileList
});
+ console.log('fileList', _this.data.fileList);
}
}
})
@@ -944,4 +1003,107 @@
fileList: fileList_new
})
},
-})
\ No newline at end of file
+
+ // 切换闪光灯模式
+ toggleFlash() {
+ var that = this
+ const flashMode = that.data.flashMode === 'off' ? 'torch' : 'off';
+ that.setData({ 'flashMode': flashMode });
+ },
+
+ // 拍摄照片
+ takePhoto() {
+ console.log('闪光灯', this.data.flashMode);
+ const ctx = wx.createCameraContext();
+ ctx.takePhoto({
+ quality: 'high',
+ success: (res) => {
+ this.setData({
+ tempImagePath: res.tempImagePath,
+ showCamera: false
+ });
+
+ this.afterReadCamera(res)
+ console.log('拍摄的图片', res);
+ },
+ fail: (err) => {
+ console.error('拍摄失败:', err);
+ wx.showToast({
+ title: '拍摄失败,请重试',
+ icon: 'none'
+ });
+ }
+ });
+ },
+
+ // 取消拍摄
+ cancelCamera() {
+ this.setData({ showCamera: false });
+ },
+ // 打开相机
+ openCamera() {
+ var that= this
+ if (that.data.form.devcode == "") {
+ wx.showToast({
+ icon: 'none',
+ title: '请先填写设备编号!\r\n否则水印中无编号',
+ duration: 2000
+ })
+ return false
+ }
+ if(Array.isArray(that.data.fileList) && that.data.fileList.length >= 6) {
+ wx.showToast({
+ icon: 'none',
+ title: '最多只允许上传6张图片',
+ duration: 2000
+ })
+ return false
+ }
+ that.setData({
+ 'showCamera': true
+ })
+ },
+// ---------------------------------新的-----------------------------------------------
+
+ /**
+ * 从相册选择(保持不变)
+ */
+ chooseFromAlbum() {
+ if (this.data.fileList.length >= this.data.maxCount) {
+ wx.showToast({ title: `最多选择${this.data.maxCount}张`, icon: 'none' });
+ return;
+ }
+
+ wx.chooseMedia({
+ count: this.data.maxCount - this.data.fileList.length,
+ mediaType: ['image'],
+ sourceType: ['album']
+ })
+ .then(res => {
+ const newImages = res.tempFiles.map(file => ({
+ tempFilePath: file.tempFilePath,
+ }));
+ this.afterRead()
+ const updatedList = [...this.data.fileList, ...newImages];
+ this.setData({
+ fileList: updatedList,
+ });
+
+ // newImages.forEach((img, idx) => {
+ // const globalIndex = this.data.fileList.length + idx;
+ // this.uploadSingleImage(globalIndex);
+ // });
+ })
+ .catch(err => {
+ console.error('选择相册失败:', err);
+ if (err.errMsg.includes('deny')) {
+ wx.showModal({
+ title: '权限不足',
+ content: '请在设置中开启相册权限',
+ confirmText: '去设置',
+ success: res => res.confirm && wx.openSetting()
+ });
+ }
+ });
+ },
+});
\ No newline at end of file
diff --git a/miniprogram/pages/addDevice/addDevice.wxml b/miniprogram/pages/addDevice/addDevice.wxml
index d3a77a0..6e4022b 100644
--- a/miniprogram/pages/addDevice/addDevice.wxml
+++ b/miniprogram/pages/addDevice/addDevice.wxml
@@ -96,8 +96,55 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{flashMode === 'torch' ? '关闭闪光灯' : '开启闪光灯'}}
+
+ 拍摄
+ 取消
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 保存
+
+
+
+
+
\ No newline at end of file
diff --git a/miniprogram/pages/addDevice/addDevice.js b/miniprogram/pages/addDevice/addDevice.js
index fcf664d..b397d10 100644
--- a/miniprogram/pages/addDevice/addDevice.js
+++ b/miniprogram/pages/addDevice/addDevice.js
@@ -90,6 +90,9 @@
projectId: '', // 所在项目
},
showSelectProject: false,
+ showCamera: false,
+ flashMode: 'torch', // 闪光灯模式: off | on | auto
+ maxCount: 6, // 最多能上传几张图片
},
onDisplay() {
@@ -885,7 +888,61 @@
});
},
//上传照片
- afterRead(event) {
+ afterReadCamera(event) {
+ var _this = this;
+ if (_this.data.form.devcode == "") {
+ wx.showToast({
+ icon: 'none',
+ title: '请先填写设备编号!\r\n否则水印中无编号',
+ duration: 2000
+ })
+ return false
+ }
+ // const {
+ // file
+ // } = event.detail;
+ const file = event
+ const {
+ fileList = []
+ } = this.data;
+ var convertpath = "";
+ // 压缩图片
+ wx.compressImage({
+ src: event.tempImagePath,
+ // 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
+ });
+ console.log('fileList', _this.data.fileList);
+ }
+ }
+ })
+ }
+ })
+ },
+ //上传照片
+ afterRead(event) {
var _this = this;
if (_this.data.form.devcode == "") {
wx.showToast({
@@ -898,6 +955,7 @@
const {
file
} = event.detail;
+ // const file = event
const {
fileList = []
} = this.data;
@@ -929,6 +987,7 @@
_this.setData({
fileList
});
+ console.log('fileList', _this.data.fileList);
}
}
})
@@ -944,4 +1003,107 @@
fileList: fileList_new
})
},
-})
\ No newline at end of file
+
+ // 切换闪光灯模式
+ toggleFlash() {
+ var that = this
+ const flashMode = that.data.flashMode === 'off' ? 'torch' : 'off';
+ that.setData({ 'flashMode': flashMode });
+ },
+
+ // 拍摄照片
+ takePhoto() {
+ console.log('闪光灯', this.data.flashMode);
+ const ctx = wx.createCameraContext();
+ ctx.takePhoto({
+ quality: 'high',
+ success: (res) => {
+ this.setData({
+ tempImagePath: res.tempImagePath,
+ showCamera: false
+ });
+
+ this.afterReadCamera(res)
+ console.log('拍摄的图片', res);
+ },
+ fail: (err) => {
+ console.error('拍摄失败:', err);
+ wx.showToast({
+ title: '拍摄失败,请重试',
+ icon: 'none'
+ });
+ }
+ });
+ },
+
+ // 取消拍摄
+ cancelCamera() {
+ this.setData({ showCamera: false });
+ },
+ // 打开相机
+ openCamera() {
+ var that= this
+ if (that.data.form.devcode == "") {
+ wx.showToast({
+ icon: 'none',
+ title: '请先填写设备编号!\r\n否则水印中无编号',
+ duration: 2000
+ })
+ return false
+ }
+ if(Array.isArray(that.data.fileList) && that.data.fileList.length >= 6) {
+ wx.showToast({
+ icon: 'none',
+ title: '最多只允许上传6张图片',
+ duration: 2000
+ })
+ return false
+ }
+ that.setData({
+ 'showCamera': true
+ })
+ },
+// ---------------------------------新的-----------------------------------------------
+
+ /**
+ * 从相册选择(保持不变)
+ */
+ chooseFromAlbum() {
+ if (this.data.fileList.length >= this.data.maxCount) {
+ wx.showToast({ title: `最多选择${this.data.maxCount}张`, icon: 'none' });
+ return;
+ }
+
+ wx.chooseMedia({
+ count: this.data.maxCount - this.data.fileList.length,
+ mediaType: ['image'],
+ sourceType: ['album']
+ })
+ .then(res => {
+ const newImages = res.tempFiles.map(file => ({
+ tempFilePath: file.tempFilePath,
+ }));
+ this.afterRead()
+ const updatedList = [...this.data.fileList, ...newImages];
+ this.setData({
+ fileList: updatedList,
+ });
+
+ // newImages.forEach((img, idx) => {
+ // const globalIndex = this.data.fileList.length + idx;
+ // this.uploadSingleImage(globalIndex);
+ // });
+ })
+ .catch(err => {
+ console.error('选择相册失败:', err);
+ if (err.errMsg.includes('deny')) {
+ wx.showModal({
+ title: '权限不足',
+ content: '请在设置中开启相册权限',
+ confirmText: '去设置',
+ success: res => res.confirm && wx.openSetting()
+ });
+ }
+ });
+ },
+});
\ No newline at end of file
diff --git a/miniprogram/pages/addDevice/addDevice.wxml b/miniprogram/pages/addDevice/addDevice.wxml
index d3a77a0..6e4022b 100644
--- a/miniprogram/pages/addDevice/addDevice.wxml
+++ b/miniprogram/pages/addDevice/addDevice.wxml
@@ -96,8 +96,55 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{flashMode === 'torch' ? '关闭闪光灯' : '开启闪光灯'}}
+
+ 拍摄
+ 取消
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 保存
+
+
+
+
+
\ No newline at end of file
diff --git a/miniprogram/pages/addDevice/addDevice.js b/miniprogram/pages/addDevice/addDevice.js
index fcf664d..b397d10 100644
--- a/miniprogram/pages/addDevice/addDevice.js
+++ b/miniprogram/pages/addDevice/addDevice.js
@@ -90,6 +90,9 @@
projectId: '', // 所在项目
},
showSelectProject: false,
+ showCamera: false,
+ flashMode: 'torch', // 闪光灯模式: off | on | auto
+ maxCount: 6, // 最多能上传几张图片
},
onDisplay() {
@@ -885,7 +888,61 @@
});
},
//上传照片
- afterRead(event) {
+ afterReadCamera(event) {
+ var _this = this;
+ if (_this.data.form.devcode == "") {
+ wx.showToast({
+ icon: 'none',
+ title: '请先填写设备编号!\r\n否则水印中无编号',
+ duration: 2000
+ })
+ return false
+ }
+ // const {
+ // file
+ // } = event.detail;
+ const file = event
+ const {
+ fileList = []
+ } = this.data;
+ var convertpath = "";
+ // 压缩图片
+ wx.compressImage({
+ src: event.tempImagePath,
+ // 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
+ });
+ console.log('fileList', _this.data.fileList);
+ }
+ }
+ })
+ }
+ })
+ },
+ //上传照片
+ afterRead(event) {
var _this = this;
if (_this.data.form.devcode == "") {
wx.showToast({
@@ -898,6 +955,7 @@
const {
file
} = event.detail;
+ // const file = event
const {
fileList = []
} = this.data;
@@ -929,6 +987,7 @@
_this.setData({
fileList
});
+ console.log('fileList', _this.data.fileList);
}
}
})
@@ -944,4 +1003,107 @@
fileList: fileList_new
})
},
-})
\ No newline at end of file
+
+ // 切换闪光灯模式
+ toggleFlash() {
+ var that = this
+ const flashMode = that.data.flashMode === 'off' ? 'torch' : 'off';
+ that.setData({ 'flashMode': flashMode });
+ },
+
+ // 拍摄照片
+ takePhoto() {
+ console.log('闪光灯', this.data.flashMode);
+ const ctx = wx.createCameraContext();
+ ctx.takePhoto({
+ quality: 'high',
+ success: (res) => {
+ this.setData({
+ tempImagePath: res.tempImagePath,
+ showCamera: false
+ });
+
+ this.afterReadCamera(res)
+ console.log('拍摄的图片', res);
+ },
+ fail: (err) => {
+ console.error('拍摄失败:', err);
+ wx.showToast({
+ title: '拍摄失败,请重试',
+ icon: 'none'
+ });
+ }
+ });
+ },
+
+ // 取消拍摄
+ cancelCamera() {
+ this.setData({ showCamera: false });
+ },
+ // 打开相机
+ openCamera() {
+ var that= this
+ if (that.data.form.devcode == "") {
+ wx.showToast({
+ icon: 'none',
+ title: '请先填写设备编号!\r\n否则水印中无编号',
+ duration: 2000
+ })
+ return false
+ }
+ if(Array.isArray(that.data.fileList) && that.data.fileList.length >= 6) {
+ wx.showToast({
+ icon: 'none',
+ title: '最多只允许上传6张图片',
+ duration: 2000
+ })
+ return false
+ }
+ that.setData({
+ 'showCamera': true
+ })
+ },
+// ---------------------------------新的-----------------------------------------------
+
+ /**
+ * 从相册选择(保持不变)
+ */
+ chooseFromAlbum() {
+ if (this.data.fileList.length >= this.data.maxCount) {
+ wx.showToast({ title: `最多选择${this.data.maxCount}张`, icon: 'none' });
+ return;
+ }
+
+ wx.chooseMedia({
+ count: this.data.maxCount - this.data.fileList.length,
+ mediaType: ['image'],
+ sourceType: ['album']
+ })
+ .then(res => {
+ const newImages = res.tempFiles.map(file => ({
+ tempFilePath: file.tempFilePath,
+ }));
+ this.afterRead()
+ const updatedList = [...this.data.fileList, ...newImages];
+ this.setData({
+ fileList: updatedList,
+ });
+
+ // newImages.forEach((img, idx) => {
+ // const globalIndex = this.data.fileList.length + idx;
+ // this.uploadSingleImage(globalIndex);
+ // });
+ })
+ .catch(err => {
+ console.error('选择相册失败:', err);
+ if (err.errMsg.includes('deny')) {
+ wx.showModal({
+ title: '权限不足',
+ content: '请在设置中开启相册权限',
+ confirmText: '去设置',
+ success: res => res.confirm && wx.openSetting()
+ });
+ }
+ });
+ },
+});
\ No newline at end of file
diff --git a/miniprogram/pages/addDevice/addDevice.wxml b/miniprogram/pages/addDevice/addDevice.wxml
index d3a77a0..6e4022b 100644
--- a/miniprogram/pages/addDevice/addDevice.wxml
+++ b/miniprogram/pages/addDevice/addDevice.wxml
@@ -96,8 +96,55 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{flashMode === 'torch' ? '关闭闪光灯' : '开启闪光灯'}}
+
+ 拍摄
+ 取消
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 保存
+
+
+
+
+
\ No newline at end of file
diff --git a/miniprogram/pages/addDevice/addDevice.js b/miniprogram/pages/addDevice/addDevice.js
index fcf664d..b397d10 100644
--- a/miniprogram/pages/addDevice/addDevice.js
+++ b/miniprogram/pages/addDevice/addDevice.js
@@ -90,6 +90,9 @@
projectId: '', // 所在项目
},
showSelectProject: false,
+ showCamera: false,
+ flashMode: 'torch', // 闪光灯模式: off | on | auto
+ maxCount: 6, // 最多能上传几张图片
},
onDisplay() {
@@ -885,7 +888,61 @@
});
},
//上传照片
- afterRead(event) {
+ afterReadCamera(event) {
+ var _this = this;
+ if (_this.data.form.devcode == "") {
+ wx.showToast({
+ icon: 'none',
+ title: '请先填写设备编号!\r\n否则水印中无编号',
+ duration: 2000
+ })
+ return false
+ }
+ // const {
+ // file
+ // } = event.detail;
+ const file = event
+ const {
+ fileList = []
+ } = this.data;
+ var convertpath = "";
+ // 压缩图片
+ wx.compressImage({
+ src: event.tempImagePath,
+ // 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
+ });
+ console.log('fileList', _this.data.fileList);
+ }
+ }
+ })
+ }
+ })
+ },
+ //上传照片
+ afterRead(event) {
var _this = this;
if (_this.data.form.devcode == "") {
wx.showToast({
@@ -898,6 +955,7 @@
const {
file
} = event.detail;
+ // const file = event
const {
fileList = []
} = this.data;
@@ -929,6 +987,7 @@
_this.setData({
fileList
});
+ console.log('fileList', _this.data.fileList);
}
}
})
@@ -944,4 +1003,107 @@
fileList: fileList_new
})
},
-})
\ No newline at end of file
+
+ // 切换闪光灯模式
+ toggleFlash() {
+ var that = this
+ const flashMode = that.data.flashMode === 'off' ? 'torch' : 'off';
+ that.setData({ 'flashMode': flashMode });
+ },
+
+ // 拍摄照片
+ takePhoto() {
+ console.log('闪光灯', this.data.flashMode);
+ const ctx = wx.createCameraContext();
+ ctx.takePhoto({
+ quality: 'high',
+ success: (res) => {
+ this.setData({
+ tempImagePath: res.tempImagePath,
+ showCamera: false
+ });
+
+ this.afterReadCamera(res)
+ console.log('拍摄的图片', res);
+ },
+ fail: (err) => {
+ console.error('拍摄失败:', err);
+ wx.showToast({
+ title: '拍摄失败,请重试',
+ icon: 'none'
+ });
+ }
+ });
+ },
+
+ // 取消拍摄
+ cancelCamera() {
+ this.setData({ showCamera: false });
+ },
+ // 打开相机
+ openCamera() {
+ var that= this
+ if (that.data.form.devcode == "") {
+ wx.showToast({
+ icon: 'none',
+ title: '请先填写设备编号!\r\n否则水印中无编号',
+ duration: 2000
+ })
+ return false
+ }
+ if(Array.isArray(that.data.fileList) && that.data.fileList.length >= 6) {
+ wx.showToast({
+ icon: 'none',
+ title: '最多只允许上传6张图片',
+ duration: 2000
+ })
+ return false
+ }
+ that.setData({
+ 'showCamera': true
+ })
+ },
+// ---------------------------------新的-----------------------------------------------
+
+ /**
+ * 从相册选择(保持不变)
+ */
+ chooseFromAlbum() {
+ if (this.data.fileList.length >= this.data.maxCount) {
+ wx.showToast({ title: `最多选择${this.data.maxCount}张`, icon: 'none' });
+ return;
+ }
+
+ wx.chooseMedia({
+ count: this.data.maxCount - this.data.fileList.length,
+ mediaType: ['image'],
+ sourceType: ['album']
+ })
+ .then(res => {
+ const newImages = res.tempFiles.map(file => ({
+ tempFilePath: file.tempFilePath,
+ }));
+ this.afterRead()
+ const updatedList = [...this.data.fileList, ...newImages];
+ this.setData({
+ fileList: updatedList,
+ });
+
+ // newImages.forEach((img, idx) => {
+ // const globalIndex = this.data.fileList.length + idx;
+ // this.uploadSingleImage(globalIndex);
+ // });
+ })
+ .catch(err => {
+ console.error('选择相册失败:', err);
+ if (err.errMsg.includes('deny')) {
+ wx.showModal({
+ title: '权限不足',
+ content: '请在设置中开启相册权限',
+ confirmText: '去设置',
+ success: res => res.confirm && wx.openSetting()
+ });
+ }
+ });
+ },
+});
\ No newline at end of file
diff --git a/miniprogram/pages/addDevice/addDevice.wxml b/miniprogram/pages/addDevice/addDevice.wxml
index d3a77a0..6e4022b 100644
--- a/miniprogram/pages/addDevice/addDevice.wxml
+++ b/miniprogram/pages/addDevice/addDevice.wxml
@@ -96,8 +96,55 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{flashMode === 'torch' ? '关闭闪光灯' : '开启闪光灯'}}
+
+ 拍摄
+ 取消
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{flashMode === 'torch' ? '关闭闪光灯' : '开启闪光灯'}}
+
+ 拍摄
+ 取消
+
+
保存
diff --git a/miniprogram/app.js b/miniprogram/app.js
index c10326f..4f1ad89 100644
--- a/miniprogram/app.js
+++ b/miniprogram/app.js
@@ -20,7 +20,7 @@
globalData: {
httpsUrl: "https://logapi.smartlog.work/", // 正式域名
// httpsUrl: "http://111.198.10.15:11638/", // 15
- // httpsUrl: "http://192.168.126.39:5905/", // 周甜
+ // httpsUrl: "http://192.168.95.39:5905/", // 周甜
// httpsUrl: "https://grey.logapi.smartlog.work/", // 测试域名
openid: null,
indexCount:1,
diff --git a/miniprogram/app.json b/miniprogram/app.json
index 3c1d780..975101c 100644
--- a/miniprogram/app.json
+++ b/miniprogram/app.json
@@ -50,6 +50,9 @@
"permission": {
"scope.userLocation": {
"desc": "你的位置信息将用于小程序位置接口的效果展示"
+ },
+ "scope.camera": {
+ "desc": "你的小程序需要使用相机来完成相关操作,如扫描设备、上传照片等"
}
},
"requiredPrivateInfos": [
diff --git a/miniprogram/images/red-marker.png b/miniprogram/images/red-marker.png
new file mode 100644
index 0000000..ed00cf5
--- /dev/null
+++ b/miniprogram/images/red-marker.png
Binary files differ
diff --git a/miniprogram/pages/addDevice/addDevice copy.js b/miniprogram/pages/addDevice/addDevice copy.js
new file mode 100644
index 0000000..fcf664d
--- /dev/null
+++ b/miniprogram/pages/addDevice/addDevice copy.js
@@ -0,0 +1,947 @@
+// miniprogram/pages/addDevice/addDevice.js
+// import WxValidate from '../../utils/WxValidate.js'
+var QQMapWX = require('../../libs/qqmap-wx-jssdk.js');
+var qqmapsdk;
+var app = getApp()
+const installTypeMap = {
+ '1': '初次安装',
+ '2': '初次拆走',
+ '3': '二次安装',
+ '4': '二次拆走',
+ '5': '正在维护',
+ '6': '其他',
+}
+Page({
+
+ /**
+ * 页面的初始数据
+ */
+ data: {
+ wellActions: [], // 选择井编号
+ wellShow: false, // 是否显示选择井编号
+ projectName: '', // 项目名称
+ canvasHeight: '',
+ canvasWidth: '',
+ longitude: '',
+ latitude: '',
+ option1: [],
+ personoption1: [],
+ projectoption: [],
+ devtypeList:[],
+ installTypeList:[
+ {
+ text: '初次安装',
+ value: '1',
+ },
+ {
+ text: '初次拆走',
+ value: '2',
+ },
+ {
+ text: '二次安装',
+ value: '3',
+ },
+ {
+ text: '二次拆走',
+ value: '4',
+ },
+ {
+ text: '正在维护',
+ value: '5',
+ },
+ {
+ text: '其他',
+ value: '6',
+ },
+ ],
+ show: false,
+ form: {
+ devcode: "",
+ wellcode: "",
+ welltype: "",
+ welldepth: "",
+ installheigt: "",
+ installperson: "",
+ installtimeFmt: "",
+ photopath: "",
+ factory: "",
+ workmsg: "",
+ position: "",
+ longitude: "",
+ latitude: "",
+ longitude84: "",
+ latitude84: "",
+ devicetype: "",
+ project: '',
+ area: "",
+ street: "",
+ wellname: "",
+ photopath1: '',
+ photopath2: '',
+ photopath3: '',
+ installType: '1', // 设备安装情况
+ description: "初次安装", // 备注
+ },
+ fileList: [],
+ listQuery: {
+ wellCode: '', // wellCode
+ wellType: '', // 井类型
+ position: '', // 位置
+ projectId: '', // 所在项目
+ },
+ showSelectProject: false,
+ },
+
+ onDisplay() {
+ this.setData({
+ show: true
+ });
+ },
+ onClose() {
+ this.setData({
+ show: false
+ });
+ },
+ // cleaable 清除经度
+ clearLongitude() {
+ var _this = this;
+ _this.setData({
+ 'form.longitude': '',
+ });
+ },
+// 清除纬度
+ clearclearLatitude() {
+ var _this = this;
+ _this.setData({
+ 'form.latitude': '',
+ });
+ },
+ 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),
+ });
+ },
+
+ /**
+ * 生命周期函数--监听页面加载
+ */
+ onLoad: function (options) {
+ var that = this;
+ if(app.globalData.role === 'repair' && app.globalData.isConfigProject === '0') {
+ that.setData({
+ 'showSelectProject': true,
+ })
+ } else {
+ that.setData({
+ 'showSelectProject': false,
+ })
+ }
+
+ console.log(app.globalData.selectProjectId, '===');
+ that.setData({
+ 'form.project': app.globalData.selectProjectName,
+ 'projectName': app.globalData.selectProjectName,
+ })
+ console.log('-----------------------3333', options);
+ //=========初始化表单内容为上次填写值==========
+ // 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
+ //默认安装经纬度为当前位置(gcj02)
+ if(options.fromPage !== 'defineMap') {
+ wx.getLocation({
+ type: "gcj02",
+ altitude: true,
+ success: function (res) {
+ var longitude = 'form.longitude';
+ var latitude = 'form.latitude';
+ that.setData({
+ [longitude]: parseFloat(res.longitude).toFixed(6),
+ [latitude]: parseFloat(res.latitude).toFixed(6),
+ longitude: parseFloat(res.longitude).toFixed(6),
+ latitude: parseFloat(res.latitude).toFixed(6),
+ });
+ //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误
+ wx.getLocation({
+ type: "wgs84",
+ altitude: true,
+ success: function (res) {
+ var longitude84 = 'form.longitude84';
+ var latitude84 = 'form.latitude84';
+ that.setData({
+ [latitude84]: parseFloat(res.latitude).toFixed(6),
+ [longitude84]: parseFloat(res.longitude).toFixed(6)
+ })
+ }
+ })
+ }
+ })
+ }
+
+
+ //获取井类型下拉列表
+ 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);
+ }
+ console.log('------', welltypeArr)
+ that.setData({
+ option1: welltypeArr
+ })
+ }
+ }
+ })
+
+ //获取人员下拉列表
+ 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);
+ }
+ personArr.push({
+ text: app.globalData.currentUserName,
+ value: app.globalData.currentUserName
+ });
+
+ that.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);
+ }
+ that.setData({
+ projectoption: projectArr
+ })
+ }
+ }
+ })
+
+ var installtime = 'form.installtimeFmt';
+ var dateNow = this.formatDate();
+ this.setData({
+ show: false,
+ 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
+ })
+ }
+ }
+ })
+
+ // 粘贴经纬度
+ if(options.fromPage !== 'defineMap') {
+ this.paste()
+ }
+ // 处理备注的默认
+ var description = 'form.description';
+ that.setData({
+ [description]: installTypeMap[that.data.form.installType]
+ })
+ console.log('options', options);
+ if(options.fromPage === 'defineMap') { // 从自定义地图页面跳转过来
+ console.log('-09999999999', app.globalData.currentUserName);
+ that.setData({
+ 'form.wellType': options.wellType, // 井类型
+ 'form.wellcode': options.wellCode, // 井编号
+ 'form.position': options.position, // 位置
+ 'form.devicetype': '井盖状态监测仪', // 设备类型
+ 'form.installperson': app.globalData.currentUserName, // 安装人员
+ 'form.project': '2025-NBJ', // 所属项目
+ 'form.latitude': parseFloat(options.latitude).toFixed(6),
+ 'form.longitude': parseFloat(options.longitude).toFixed(6),
+ latitude: parseFloat(options.latitude).toFixed(6),
+ longitude: parseFloat(options.longitude).toFixed(6),
+ })
+ }
+ that.setData({
+ 'form.installperson': app.globalData.currentUserName, // 安装人员
+ 'form.project': '2025-NBJ', // 所属项目
+ })
+ },
+
+
+
+
+ /**
+ * 生命周期函数--监听页面初次渲染完成
+ */
+ onReady: function () {
+
+ },
+
+ /**
+ * 生命周期函数--监听页面显示
+ */
+ onShow: function () {
+
+ },
+
+ /**
+ * 生命周期函数--监听页面隐藏
+ */
+ onHide: function () {
+
+ },
+
+ /**
+ * 生命周期函数--监听页面卸载
+ */
+ onUnload: function () {
+
+ },
+
+ /**
+ * 页面相关事件处理函数--监听用户下拉动作
+ */
+ onPullDownRefresh: function () {
+
+ },
+
+ // 监听页面滚动
+ onPageScroll(e) {
+ console.log('监听页面滚动');
+ var that = this
+ console.log(that.selectComponent('#selectPersonDropdown'));
+ // that.selectComponent('#selectPersonDropdown').triggerEvent(false)
+},
+
+toggle() {
+
+},
+ // 点击检索
+ searchWellCode() {
+ if(!this.data.form.wellcode) {
+ wx.showToast({
+ icon: 'error',
+ title: '请先输入井编号',
+ })
+ return false
+ }
+ this.setData({
+ 'listQuery.wellCode': this.data.form.wellcode
+ })
+ this.fetchWellPre()
+ },
+ //获取井列表
+ fetchWellPre() {
+ return new Promise((resolve, reject) => {
+ var that = this
+ wx.showLoading({
+ mask: true
+ })
+ wx.request({
+ method: "POST",
+ url: app.globalData.httpsUrl + "well/pre/listPage" + `?offset=${1}&limit=${9999}`,
+ // header: {
+ // 'content-type': 'application/x-www-form-urlencoded;charset=utf-8'
+ // },
+ data: {
+ ...that.data.listQuery,
+ offset: 1,
+ limit: 9999
+ },
+ success(res) {
+ wx.hideLoading()
+ if (res.data) {
+ if(!res.data.data.rows.length) {
+ wx.showToast({
+ icon: 'error',
+ title: '查无结果'
+ })
+ } else {
+ const tempList = res.data.data.rows.map(item => {
+ return {
+ ...item,
+ name: item.wellName,
+ }
+ })
+ that.setData({
+ wellActions: tempList,
+ wellShow: true
+ })
+ }
+ }
+ },
+ fail(res) {
+ wx.hideLoading()
+ wx.showToast({
+ icon: 'none',
+ title: '查询失败,请手动输入'
+ })
+ }
+ })
+ })
+ },
+ // 点击选择器的取消
+ cancleWellShow() {
+ this.setData({
+ wellShow: false,
+ })
+ },
+ // 选择好井
+ selectWells(e) {
+ var that = this
+ const val = e.detail
+ console.log(val);
+ that.setData({
+ 'form.wellcode': val.wellCode, // 井编号
+ 'form.wellname': val.wellName, // 井名称
+ 'form.welltype': val.wellType, // 井类型
+ 'form.position': val.position, //位置描述
+ })
+ that.cancleWellShow()
+ },
+
+ /**
+ * 页面上拉触底事件的处理函数
+ */
+ onReachBottom: function () {
+
+ },
+
+ /**
+ * 用户点击右上角分享
+ */
+ onShareAppMessage: function () {
+
+ },
+
+
+
+ /**
+ * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true
+ **/
+
+ isNumber: function (val) {
+
+ var regPos = /^[0-9]*$/; //非负浮点数
+ var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数
+ if (regPos.test(val) || regNeg.test(val)) {
+ return false;
+ } else {
+ return true;
+ }
+
+ },
+
+ //验证表单
+ formValidate() {
+
+ if (this.data.form.devcode == "") {
+ 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',
+ title: '井编号不能为空!',
+ })
+ return false
+ }
+
+ if (this.data.form.devicetype == "") {
+ wx.showToast({
+ icon: 'none',
+ title: '设备类型不能为空!',
+ })
+ return false
+ }
+
+
+
+ if (this.data.form.installperson == "") {
+ 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
+ }
+ }
+
+ if (this.data.form.project == "") {
+ wx.showToast({
+ icon: 'none',
+ title: '所属项目不能为空!',
+ })
+ return false
+ }
+
+ if (this.data.form.installtimeFmt == null) {
+ wx.showToast({
+ icon: 'none',
+ title: '安装时间不能为空!',
+ })
+ return false
+ }
+ return true;
+ },
+ //提交表单
+ formSubmit: function (event) {
+ console.log(this.data.form)
+ //表单参数验证
+ if (!this.formValidate()) {
+ return false;
+ }
+ var that = this;
+ //验证设备编号长度
+ wx.request({
+ method: 'POST',
+ url: app.globalData.httpsUrl + "appDeviceAdd/getDevTypeLength",
+ data: {
+ code: encodeURI(this.data.form.devicetype)
+ },
+ 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
+ }
+ }
+ })
+ },
+
+ //保存设备基本信息
+ 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]
+ })
+ }
+ that.setData({
+ 'form.project': that.data.form.project,
+ 'projectName': that.data.form.project,
+ })
+ //表单提交
+ 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: '提交成功,是否返回?',
+ showCancel: false, // 不显示取消按钮
+ success: function (res) {
+ console.log('用户点击了返回')
+ //用于回显
+ console.log('lll', that.data.form);
+ wx.setStorageSync('cacheList', that.data.form)
+ //提交成功后提示用户操作
+ if (res.confirm) {
+ // wx.switchTab({
+ // url: '../earth/earth'
+ // })
+ console.log('lleeel', that.data.form);
+ app.globalData.addsuccessWellCode = that.data.form.wellcode
+ wx.navigateBack({ // 返回上一页
+ delta: 1
+ });
+ } else { //这里是点击了取消以后
+ console.log('用户点击取消')
+ }
+ }
+ })
+ }
+ },
+ fail(err) {
+ wx.showToast({
+ title: '提交失败!',
+ })
+ }
+ })
+ },
+ // 井编号输入框点击清除按钮
+// clickClearable() {
+// this.setData({
+// 'form.wellcode': ''
+// })
+// },
+ // 井编号改变
+ changeWellCode(e) {
+ console.log(e);
+ this.setData({
+ 'form.wellcode': e.detail
+ })
+ },
+
+ //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,
+ })
+ //若输入是设备编号,自动获取设备类型
+ 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({
+ success(res) {
+ var devcode = res.result
+ var formdevcode = 'form.devcode'
+ _this.setData({
+ [formdevcode]: devcode
+ });
+ wx.request({
+ method: 'POST',
+ url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode",
+ data: {
+ devcode: devcode,
+ },
+ 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({
+ 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),
+ });
+ _this.showAddress(_this.data.form.longitude,_this.data.form.latitude,_this)
+ }
+ })
+ },
+ //设置经类型
+ selectValue(value) {
+
+ var that = this;
+ var wellType = 'form.welltype';
+ that.setData({
+ [wellType]: value.detail
+ })
+ },
+ // 设置设备安装情况
+ selectInstallType(value) {
+ var that = this;
+ var installType = 'form.installType';
+ var description = 'form.description';
+ that.setData({
+ [installType]: value.detail,
+ [description]: installTypeMap[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';
+ that.setData({
+ [installPerson]: event.detail
+ })
+ },
+ //设置项目
+ selectprojectValue(event) {
+ var that = this;
+ var project = 'form.project';
+ that.setData({
+ [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;
+ 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
+ });
+ }
+ }
+ })
+ }
+ })
+ },
+ //删除照片
+ deletePhoto(event) {
+ var image_index = event.detail.index
+ var fileList_new = this.data.fileList;
+ fileList_new.splice(image_index, 1);
+ this.setData({
+ fileList: fileList_new
+ })
+ },
+})
\ No newline at end of file
diff --git a/miniprogram/pages/addDevice/addDevice copy.wxml b/miniprogram/pages/addDevice/addDevice copy.wxml
new file mode 100644
index 0000000..d3a77a0
--- /dev/null
+++ b/miniprogram/pages/addDevice/addDevice copy.wxml
@@ -0,0 +1,129 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 保存
+
+
+
+
+
\ No newline at end of file
diff --git a/miniprogram/pages/addDevice/addDevice.js b/miniprogram/pages/addDevice/addDevice.js
index fcf664d..b397d10 100644
--- a/miniprogram/pages/addDevice/addDevice.js
+++ b/miniprogram/pages/addDevice/addDevice.js
@@ -90,6 +90,9 @@
projectId: '', // 所在项目
},
showSelectProject: false,
+ showCamera: false,
+ flashMode: 'torch', // 闪光灯模式: off | on | auto
+ maxCount: 6, // 最多能上传几张图片
},
onDisplay() {
@@ -885,7 +888,61 @@
});
},
//上传照片
- afterRead(event) {
+ afterReadCamera(event) {
+ var _this = this;
+ if (_this.data.form.devcode == "") {
+ wx.showToast({
+ icon: 'none',
+ title: '请先填写设备编号!\r\n否则水印中无编号',
+ duration: 2000
+ })
+ return false
+ }
+ // const {
+ // file
+ // } = event.detail;
+ const file = event
+ const {
+ fileList = []
+ } = this.data;
+ var convertpath = "";
+ // 压缩图片
+ wx.compressImage({
+ src: event.tempImagePath,
+ // 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
+ });
+ console.log('fileList', _this.data.fileList);
+ }
+ }
+ })
+ }
+ })
+ },
+ //上传照片
+ afterRead(event) {
var _this = this;
if (_this.data.form.devcode == "") {
wx.showToast({
@@ -898,6 +955,7 @@
const {
file
} = event.detail;
+ // const file = event
const {
fileList = []
} = this.data;
@@ -929,6 +987,7 @@
_this.setData({
fileList
});
+ console.log('fileList', _this.data.fileList);
}
}
})
@@ -944,4 +1003,107 @@
fileList: fileList_new
})
},
-})
\ No newline at end of file
+
+ // 切换闪光灯模式
+ toggleFlash() {
+ var that = this
+ const flashMode = that.data.flashMode === 'off' ? 'torch' : 'off';
+ that.setData({ 'flashMode': flashMode });
+ },
+
+ // 拍摄照片
+ takePhoto() {
+ console.log('闪光灯', this.data.flashMode);
+ const ctx = wx.createCameraContext();
+ ctx.takePhoto({
+ quality: 'high',
+ success: (res) => {
+ this.setData({
+ tempImagePath: res.tempImagePath,
+ showCamera: false
+ });
+
+ this.afterReadCamera(res)
+ console.log('拍摄的图片', res);
+ },
+ fail: (err) => {
+ console.error('拍摄失败:', err);
+ wx.showToast({
+ title: '拍摄失败,请重试',
+ icon: 'none'
+ });
+ }
+ });
+ },
+
+ // 取消拍摄
+ cancelCamera() {
+ this.setData({ showCamera: false });
+ },
+ // 打开相机
+ openCamera() {
+ var that= this
+ if (that.data.form.devcode == "") {
+ wx.showToast({
+ icon: 'none',
+ title: '请先填写设备编号!\r\n否则水印中无编号',
+ duration: 2000
+ })
+ return false
+ }
+ if(Array.isArray(that.data.fileList) && that.data.fileList.length >= 6) {
+ wx.showToast({
+ icon: 'none',
+ title: '最多只允许上传6张图片',
+ duration: 2000
+ })
+ return false
+ }
+ that.setData({
+ 'showCamera': true
+ })
+ },
+// ---------------------------------新的-----------------------------------------------
+
+ /**
+ * 从相册选择(保持不变)
+ */
+ chooseFromAlbum() {
+ if (this.data.fileList.length >= this.data.maxCount) {
+ wx.showToast({ title: `最多选择${this.data.maxCount}张`, icon: 'none' });
+ return;
+ }
+
+ wx.chooseMedia({
+ count: this.data.maxCount - this.data.fileList.length,
+ mediaType: ['image'],
+ sourceType: ['album']
+ })
+ .then(res => {
+ const newImages = res.tempFiles.map(file => ({
+ tempFilePath: file.tempFilePath,
+ }));
+ this.afterRead()
+ const updatedList = [...this.data.fileList, ...newImages];
+ this.setData({
+ fileList: updatedList,
+ });
+
+ // newImages.forEach((img, idx) => {
+ // const globalIndex = this.data.fileList.length + idx;
+ // this.uploadSingleImage(globalIndex);
+ // });
+ })
+ .catch(err => {
+ console.error('选择相册失败:', err);
+ if (err.errMsg.includes('deny')) {
+ wx.showModal({
+ title: '权限不足',
+ content: '请在设置中开启相册权限',
+ confirmText: '去设置',
+ success: res => res.confirm && wx.openSetting()
+ });
+ }
+ });
+ },
+});
\ No newline at end of file
diff --git a/miniprogram/pages/addDevice/addDevice.wxml b/miniprogram/pages/addDevice/addDevice.wxml
index d3a77a0..6e4022b 100644
--- a/miniprogram/pages/addDevice/addDevice.wxml
+++ b/miniprogram/pages/addDevice/addDevice.wxml
@@ -96,8 +96,55 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{flashMode === 'torch' ? '关闭闪光灯' : '开启闪光灯'}}
+
+ 拍摄
+ 取消
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{flashMode === 'torch' ? '关闭闪光灯' : '开启闪光灯'}}
+
+ 拍摄
+ 取消
+
+
保存
diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.wxss b/miniprogram/pages/addDevicelog/addDeviceLog.wxss
index 08d5fd7..013e4fb 100644
--- a/miniprogram/pages/addDevicelog/addDeviceLog.wxss
+++ b/miniprogram/pages/addDevicelog/addDeviceLog.wxss
@@ -101,4 +101,219 @@
/* .van-cell{
height: 100rpx;
-} */
\ No newline at end of file
+} */
+
+/* -------------------------------------新的--------------------------------------- */
+
+/* index.wxss */
+.camera-container {
+ position: fixed;
+ top: 0;
+ left: 0;
+ width: 100%;
+ height: 100%;
+ background-color: #000;
+ z-index: 999;
+ }
+
+ .camera {
+ width: 100%;
+ height: calc(100% - 160rpx);
+ }
+
+ .camera-controls {
+ position: absolute;
+ bottom: 0;
+ left: 0;
+ width: 100%;
+ height: 160rpx;
+ background-color: rgba(0, 0, 0, 0.7);
+ display: flex;
+ align-items: center;
+ justify-content: space-around;
+ }
+
+ .flash-btn, .capture-btn, .cancel-btn {
+ color: white;
+ font-size: 28rpx;
+ padding: 20rpx 40rpx;
+ border-radius: 8rpx;
+ }
+
+ .capture-btn {
+ background-color: #f00;
+ width: 120rpx;
+ height: 120rpx;
+ border-radius: 50%;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ }
+
+ .flash-btn, .cancel-btn {
+ background-color: rgba(255, 255, 255, 0.2);
+ }
+
+
+/* 新增样式 */
+.upload-status {
+ position: absolute;
+ top: 0;
+ left: 0;
+ width: 100%;
+ height: 100%;
+ background-color: rgba(0,0,0,0.5);
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ }
+
+ .upload-tips {
+ color: #666;
+ font-size: 28rpx;
+ text-align: center;
+ margin: 20rpx 0;
+ }
+
+
+/* 新增闪光灯控制样式 */
+.camera-section {
+ flex: 1;
+ display: flex;
+ flex-direction: column;
+ gap: 15rpx;
+ }
+
+ .flash-control {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ gap: 10rpx;
+ font-size: 26rpx;
+ color: #666;
+ padding: 5rpx 0;
+ }
+
+ .flash-status {
+ color: #07c160;
+ font-weight: 500;
+ }
+
+ /* 原有样式保持不变 */
+ .btn-group {
+ display: flex;
+ gap: 20rpx;
+ padding: 20rpx;
+ align-items: center;
+ margin-bottom: 20rpx;
+ }
+
+ .action-btn {
+ flex: 1;
+ padding: 0 25rpx;
+ border-radius: 12rpx;
+ color: #fff;
+ font-size: 32rpx;
+ }
+
+ .camera-btn {
+ background-color: #07c160;
+ }
+
+ .album-btn {
+ background-color: #1677ff;
+ flex: 1;
+ }
+
+ /* 图片预览相关样式 */
+ .image-grid {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 15rpx;
+ padding: 0 20rpx;
+ }
+
+ .image-item {
+ position: relative;
+ width: calc(33.333% - 10rpx);
+ aspect-ratio: 1/1;
+ border-radius: 8rpx;
+ overflow: hidden;
+ }
+
+ .image-item image {
+ width: 100%;
+ height: 100%;
+ }
+
+ /* 上传状态样式 */
+ .status-mask {
+ position: absolute;
+ bottom: 0;
+ left: 0;
+ width: 100%;
+ height: 15rpx;
+ }
+
+ .progress-bar {
+ height: 100%;
+ background-color: #07c160;
+ }
+
+ .progress-text {
+ position: absolute;
+ top: -30rpx;
+ right: 10rpx;
+ font-size: 24rpx;
+ color: #07c160;
+ background-color: rgba(255,255,255,0.8);
+ padding: 2rpx 10rpx;
+ border-radius: 4rpx;
+ }
+
+ .status-icon {
+ position: absolute;
+ top: 10rpx;
+ right: 10rpx;
+ width: 40rpx;
+ height: 40rpx;
+ border-radius: 50%;
+ color: white;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ font-size: 24rpx;
+ }
+
+ .success {
+ background-color: #07c160;
+ }
+
+ .fail {
+ background-color: #ff4d4f;
+ }
+
+ .delete-icon {
+ position: absolute;
+ top: 10rpx;
+ right: 10rpx;
+ width: 40rpx;
+ height: 40rpx;
+ background-color: rgba(0,0,0,0.5);
+ color: white;
+ border-radius: 50%;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ font-size: 30rpx;
+ }
+
+ .retry-btn {
+ width: calc(100% - 40rpx);
+ margin: 20rpx;
+ padding: 20rpx 0;
+ background-color: #1677ff;
+ color: white;
+ border-radius: 8rpx;
+ font-size: 28rpx;
+ }
diff --git a/miniprogram/app.js b/miniprogram/app.js
index c10326f..4f1ad89 100644
--- a/miniprogram/app.js
+++ b/miniprogram/app.js
@@ -20,7 +20,7 @@
globalData: {
httpsUrl: "https://logapi.smartlog.work/", // 正式域名
// httpsUrl: "http://111.198.10.15:11638/", // 15
- // httpsUrl: "http://192.168.126.39:5905/", // 周甜
+ // httpsUrl: "http://192.168.95.39:5905/", // 周甜
// httpsUrl: "https://grey.logapi.smartlog.work/", // 测试域名
openid: null,
indexCount:1,
diff --git a/miniprogram/app.json b/miniprogram/app.json
index 3c1d780..975101c 100644
--- a/miniprogram/app.json
+++ b/miniprogram/app.json
@@ -50,6 +50,9 @@
"permission": {
"scope.userLocation": {
"desc": "你的位置信息将用于小程序位置接口的效果展示"
+ },
+ "scope.camera": {
+ "desc": "你的小程序需要使用相机来完成相关操作,如扫描设备、上传照片等"
}
},
"requiredPrivateInfos": [
diff --git a/miniprogram/images/red-marker.png b/miniprogram/images/red-marker.png
new file mode 100644
index 0000000..ed00cf5
--- /dev/null
+++ b/miniprogram/images/red-marker.png
Binary files differ
diff --git a/miniprogram/pages/addDevice/addDevice copy.js b/miniprogram/pages/addDevice/addDevice copy.js
new file mode 100644
index 0000000..fcf664d
--- /dev/null
+++ b/miniprogram/pages/addDevice/addDevice copy.js
@@ -0,0 +1,947 @@
+// miniprogram/pages/addDevice/addDevice.js
+// import WxValidate from '../../utils/WxValidate.js'
+var QQMapWX = require('../../libs/qqmap-wx-jssdk.js');
+var qqmapsdk;
+var app = getApp()
+const installTypeMap = {
+ '1': '初次安装',
+ '2': '初次拆走',
+ '3': '二次安装',
+ '4': '二次拆走',
+ '5': '正在维护',
+ '6': '其他',
+}
+Page({
+
+ /**
+ * 页面的初始数据
+ */
+ data: {
+ wellActions: [], // 选择井编号
+ wellShow: false, // 是否显示选择井编号
+ projectName: '', // 项目名称
+ canvasHeight: '',
+ canvasWidth: '',
+ longitude: '',
+ latitude: '',
+ option1: [],
+ personoption1: [],
+ projectoption: [],
+ devtypeList:[],
+ installTypeList:[
+ {
+ text: '初次安装',
+ value: '1',
+ },
+ {
+ text: '初次拆走',
+ value: '2',
+ },
+ {
+ text: '二次安装',
+ value: '3',
+ },
+ {
+ text: '二次拆走',
+ value: '4',
+ },
+ {
+ text: '正在维护',
+ value: '5',
+ },
+ {
+ text: '其他',
+ value: '6',
+ },
+ ],
+ show: false,
+ form: {
+ devcode: "",
+ wellcode: "",
+ welltype: "",
+ welldepth: "",
+ installheigt: "",
+ installperson: "",
+ installtimeFmt: "",
+ photopath: "",
+ factory: "",
+ workmsg: "",
+ position: "",
+ longitude: "",
+ latitude: "",
+ longitude84: "",
+ latitude84: "",
+ devicetype: "",
+ project: '',
+ area: "",
+ street: "",
+ wellname: "",
+ photopath1: '',
+ photopath2: '',
+ photopath3: '',
+ installType: '1', // 设备安装情况
+ description: "初次安装", // 备注
+ },
+ fileList: [],
+ listQuery: {
+ wellCode: '', // wellCode
+ wellType: '', // 井类型
+ position: '', // 位置
+ projectId: '', // 所在项目
+ },
+ showSelectProject: false,
+ },
+
+ onDisplay() {
+ this.setData({
+ show: true
+ });
+ },
+ onClose() {
+ this.setData({
+ show: false
+ });
+ },
+ // cleaable 清除经度
+ clearLongitude() {
+ var _this = this;
+ _this.setData({
+ 'form.longitude': '',
+ });
+ },
+// 清除纬度
+ clearclearLatitude() {
+ var _this = this;
+ _this.setData({
+ 'form.latitude': '',
+ });
+ },
+ 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),
+ });
+ },
+
+ /**
+ * 生命周期函数--监听页面加载
+ */
+ onLoad: function (options) {
+ var that = this;
+ if(app.globalData.role === 'repair' && app.globalData.isConfigProject === '0') {
+ that.setData({
+ 'showSelectProject': true,
+ })
+ } else {
+ that.setData({
+ 'showSelectProject': false,
+ })
+ }
+
+ console.log(app.globalData.selectProjectId, '===');
+ that.setData({
+ 'form.project': app.globalData.selectProjectName,
+ 'projectName': app.globalData.selectProjectName,
+ })
+ console.log('-----------------------3333', options);
+ //=========初始化表单内容为上次填写值==========
+ // 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
+ //默认安装经纬度为当前位置(gcj02)
+ if(options.fromPage !== 'defineMap') {
+ wx.getLocation({
+ type: "gcj02",
+ altitude: true,
+ success: function (res) {
+ var longitude = 'form.longitude';
+ var latitude = 'form.latitude';
+ that.setData({
+ [longitude]: parseFloat(res.longitude).toFixed(6),
+ [latitude]: parseFloat(res.latitude).toFixed(6),
+ longitude: parseFloat(res.longitude).toFixed(6),
+ latitude: parseFloat(res.latitude).toFixed(6),
+ });
+ //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误
+ wx.getLocation({
+ type: "wgs84",
+ altitude: true,
+ success: function (res) {
+ var longitude84 = 'form.longitude84';
+ var latitude84 = 'form.latitude84';
+ that.setData({
+ [latitude84]: parseFloat(res.latitude).toFixed(6),
+ [longitude84]: parseFloat(res.longitude).toFixed(6)
+ })
+ }
+ })
+ }
+ })
+ }
+
+
+ //获取井类型下拉列表
+ 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);
+ }
+ console.log('------', welltypeArr)
+ that.setData({
+ option1: welltypeArr
+ })
+ }
+ }
+ })
+
+ //获取人员下拉列表
+ 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);
+ }
+ personArr.push({
+ text: app.globalData.currentUserName,
+ value: app.globalData.currentUserName
+ });
+
+ that.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);
+ }
+ that.setData({
+ projectoption: projectArr
+ })
+ }
+ }
+ })
+
+ var installtime = 'form.installtimeFmt';
+ var dateNow = this.formatDate();
+ this.setData({
+ show: false,
+ 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
+ })
+ }
+ }
+ })
+
+ // 粘贴经纬度
+ if(options.fromPage !== 'defineMap') {
+ this.paste()
+ }
+ // 处理备注的默认
+ var description = 'form.description';
+ that.setData({
+ [description]: installTypeMap[that.data.form.installType]
+ })
+ console.log('options', options);
+ if(options.fromPage === 'defineMap') { // 从自定义地图页面跳转过来
+ console.log('-09999999999', app.globalData.currentUserName);
+ that.setData({
+ 'form.wellType': options.wellType, // 井类型
+ 'form.wellcode': options.wellCode, // 井编号
+ 'form.position': options.position, // 位置
+ 'form.devicetype': '井盖状态监测仪', // 设备类型
+ 'form.installperson': app.globalData.currentUserName, // 安装人员
+ 'form.project': '2025-NBJ', // 所属项目
+ 'form.latitude': parseFloat(options.latitude).toFixed(6),
+ 'form.longitude': parseFloat(options.longitude).toFixed(6),
+ latitude: parseFloat(options.latitude).toFixed(6),
+ longitude: parseFloat(options.longitude).toFixed(6),
+ })
+ }
+ that.setData({
+ 'form.installperson': app.globalData.currentUserName, // 安装人员
+ 'form.project': '2025-NBJ', // 所属项目
+ })
+ },
+
+
+
+
+ /**
+ * 生命周期函数--监听页面初次渲染完成
+ */
+ onReady: function () {
+
+ },
+
+ /**
+ * 生命周期函数--监听页面显示
+ */
+ onShow: function () {
+
+ },
+
+ /**
+ * 生命周期函数--监听页面隐藏
+ */
+ onHide: function () {
+
+ },
+
+ /**
+ * 生命周期函数--监听页面卸载
+ */
+ onUnload: function () {
+
+ },
+
+ /**
+ * 页面相关事件处理函数--监听用户下拉动作
+ */
+ onPullDownRefresh: function () {
+
+ },
+
+ // 监听页面滚动
+ onPageScroll(e) {
+ console.log('监听页面滚动');
+ var that = this
+ console.log(that.selectComponent('#selectPersonDropdown'));
+ // that.selectComponent('#selectPersonDropdown').triggerEvent(false)
+},
+
+toggle() {
+
+},
+ // 点击检索
+ searchWellCode() {
+ if(!this.data.form.wellcode) {
+ wx.showToast({
+ icon: 'error',
+ title: '请先输入井编号',
+ })
+ return false
+ }
+ this.setData({
+ 'listQuery.wellCode': this.data.form.wellcode
+ })
+ this.fetchWellPre()
+ },
+ //获取井列表
+ fetchWellPre() {
+ return new Promise((resolve, reject) => {
+ var that = this
+ wx.showLoading({
+ mask: true
+ })
+ wx.request({
+ method: "POST",
+ url: app.globalData.httpsUrl + "well/pre/listPage" + `?offset=${1}&limit=${9999}`,
+ // header: {
+ // 'content-type': 'application/x-www-form-urlencoded;charset=utf-8'
+ // },
+ data: {
+ ...that.data.listQuery,
+ offset: 1,
+ limit: 9999
+ },
+ success(res) {
+ wx.hideLoading()
+ if (res.data) {
+ if(!res.data.data.rows.length) {
+ wx.showToast({
+ icon: 'error',
+ title: '查无结果'
+ })
+ } else {
+ const tempList = res.data.data.rows.map(item => {
+ return {
+ ...item,
+ name: item.wellName,
+ }
+ })
+ that.setData({
+ wellActions: tempList,
+ wellShow: true
+ })
+ }
+ }
+ },
+ fail(res) {
+ wx.hideLoading()
+ wx.showToast({
+ icon: 'none',
+ title: '查询失败,请手动输入'
+ })
+ }
+ })
+ })
+ },
+ // 点击选择器的取消
+ cancleWellShow() {
+ this.setData({
+ wellShow: false,
+ })
+ },
+ // 选择好井
+ selectWells(e) {
+ var that = this
+ const val = e.detail
+ console.log(val);
+ that.setData({
+ 'form.wellcode': val.wellCode, // 井编号
+ 'form.wellname': val.wellName, // 井名称
+ 'form.welltype': val.wellType, // 井类型
+ 'form.position': val.position, //位置描述
+ })
+ that.cancleWellShow()
+ },
+
+ /**
+ * 页面上拉触底事件的处理函数
+ */
+ onReachBottom: function () {
+
+ },
+
+ /**
+ * 用户点击右上角分享
+ */
+ onShareAppMessage: function () {
+
+ },
+
+
+
+ /**
+ * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true
+ **/
+
+ isNumber: function (val) {
+
+ var regPos = /^[0-9]*$/; //非负浮点数
+ var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数
+ if (regPos.test(val) || regNeg.test(val)) {
+ return false;
+ } else {
+ return true;
+ }
+
+ },
+
+ //验证表单
+ formValidate() {
+
+ if (this.data.form.devcode == "") {
+ 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',
+ title: '井编号不能为空!',
+ })
+ return false
+ }
+
+ if (this.data.form.devicetype == "") {
+ wx.showToast({
+ icon: 'none',
+ title: '设备类型不能为空!',
+ })
+ return false
+ }
+
+
+
+ if (this.data.form.installperson == "") {
+ 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
+ }
+ }
+
+ if (this.data.form.project == "") {
+ wx.showToast({
+ icon: 'none',
+ title: '所属项目不能为空!',
+ })
+ return false
+ }
+
+ if (this.data.form.installtimeFmt == null) {
+ wx.showToast({
+ icon: 'none',
+ title: '安装时间不能为空!',
+ })
+ return false
+ }
+ return true;
+ },
+ //提交表单
+ formSubmit: function (event) {
+ console.log(this.data.form)
+ //表单参数验证
+ if (!this.formValidate()) {
+ return false;
+ }
+ var that = this;
+ //验证设备编号长度
+ wx.request({
+ method: 'POST',
+ url: app.globalData.httpsUrl + "appDeviceAdd/getDevTypeLength",
+ data: {
+ code: encodeURI(this.data.form.devicetype)
+ },
+ 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
+ }
+ }
+ })
+ },
+
+ //保存设备基本信息
+ 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]
+ })
+ }
+ that.setData({
+ 'form.project': that.data.form.project,
+ 'projectName': that.data.form.project,
+ })
+ //表单提交
+ 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: '提交成功,是否返回?',
+ showCancel: false, // 不显示取消按钮
+ success: function (res) {
+ console.log('用户点击了返回')
+ //用于回显
+ console.log('lll', that.data.form);
+ wx.setStorageSync('cacheList', that.data.form)
+ //提交成功后提示用户操作
+ if (res.confirm) {
+ // wx.switchTab({
+ // url: '../earth/earth'
+ // })
+ console.log('lleeel', that.data.form);
+ app.globalData.addsuccessWellCode = that.data.form.wellcode
+ wx.navigateBack({ // 返回上一页
+ delta: 1
+ });
+ } else { //这里是点击了取消以后
+ console.log('用户点击取消')
+ }
+ }
+ })
+ }
+ },
+ fail(err) {
+ wx.showToast({
+ title: '提交失败!',
+ })
+ }
+ })
+ },
+ // 井编号输入框点击清除按钮
+// clickClearable() {
+// this.setData({
+// 'form.wellcode': ''
+// })
+// },
+ // 井编号改变
+ changeWellCode(e) {
+ console.log(e);
+ this.setData({
+ 'form.wellcode': e.detail
+ })
+ },
+
+ //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,
+ })
+ //若输入是设备编号,自动获取设备类型
+ 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({
+ success(res) {
+ var devcode = res.result
+ var formdevcode = 'form.devcode'
+ _this.setData({
+ [formdevcode]: devcode
+ });
+ wx.request({
+ method: 'POST',
+ url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode",
+ data: {
+ devcode: devcode,
+ },
+ 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({
+ 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),
+ });
+ _this.showAddress(_this.data.form.longitude,_this.data.form.latitude,_this)
+ }
+ })
+ },
+ //设置经类型
+ selectValue(value) {
+
+ var that = this;
+ var wellType = 'form.welltype';
+ that.setData({
+ [wellType]: value.detail
+ })
+ },
+ // 设置设备安装情况
+ selectInstallType(value) {
+ var that = this;
+ var installType = 'form.installType';
+ var description = 'form.description';
+ that.setData({
+ [installType]: value.detail,
+ [description]: installTypeMap[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';
+ that.setData({
+ [installPerson]: event.detail
+ })
+ },
+ //设置项目
+ selectprojectValue(event) {
+ var that = this;
+ var project = 'form.project';
+ that.setData({
+ [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;
+ 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
+ });
+ }
+ }
+ })
+ }
+ })
+ },
+ //删除照片
+ deletePhoto(event) {
+ var image_index = event.detail.index
+ var fileList_new = this.data.fileList;
+ fileList_new.splice(image_index, 1);
+ this.setData({
+ fileList: fileList_new
+ })
+ },
+})
\ No newline at end of file
diff --git a/miniprogram/pages/addDevice/addDevice copy.wxml b/miniprogram/pages/addDevice/addDevice copy.wxml
new file mode 100644
index 0000000..d3a77a0
--- /dev/null
+++ b/miniprogram/pages/addDevice/addDevice copy.wxml
@@ -0,0 +1,129 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 保存
+
+
+
+
+
\ No newline at end of file
diff --git a/miniprogram/pages/addDevice/addDevice.js b/miniprogram/pages/addDevice/addDevice.js
index fcf664d..b397d10 100644
--- a/miniprogram/pages/addDevice/addDevice.js
+++ b/miniprogram/pages/addDevice/addDevice.js
@@ -90,6 +90,9 @@
projectId: '', // 所在项目
},
showSelectProject: false,
+ showCamera: false,
+ flashMode: 'torch', // 闪光灯模式: off | on | auto
+ maxCount: 6, // 最多能上传几张图片
},
onDisplay() {
@@ -885,7 +888,61 @@
});
},
//上传照片
- afterRead(event) {
+ afterReadCamera(event) {
+ var _this = this;
+ if (_this.data.form.devcode == "") {
+ wx.showToast({
+ icon: 'none',
+ title: '请先填写设备编号!\r\n否则水印中无编号',
+ duration: 2000
+ })
+ return false
+ }
+ // const {
+ // file
+ // } = event.detail;
+ const file = event
+ const {
+ fileList = []
+ } = this.data;
+ var convertpath = "";
+ // 压缩图片
+ wx.compressImage({
+ src: event.tempImagePath,
+ // 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
+ });
+ console.log('fileList', _this.data.fileList);
+ }
+ }
+ })
+ }
+ })
+ },
+ //上传照片
+ afterRead(event) {
var _this = this;
if (_this.data.form.devcode == "") {
wx.showToast({
@@ -898,6 +955,7 @@
const {
file
} = event.detail;
+ // const file = event
const {
fileList = []
} = this.data;
@@ -929,6 +987,7 @@
_this.setData({
fileList
});
+ console.log('fileList', _this.data.fileList);
}
}
})
@@ -944,4 +1003,107 @@
fileList: fileList_new
})
},
-})
\ No newline at end of file
+
+ // 切换闪光灯模式
+ toggleFlash() {
+ var that = this
+ const flashMode = that.data.flashMode === 'off' ? 'torch' : 'off';
+ that.setData({ 'flashMode': flashMode });
+ },
+
+ // 拍摄照片
+ takePhoto() {
+ console.log('闪光灯', this.data.flashMode);
+ const ctx = wx.createCameraContext();
+ ctx.takePhoto({
+ quality: 'high',
+ success: (res) => {
+ this.setData({
+ tempImagePath: res.tempImagePath,
+ showCamera: false
+ });
+
+ this.afterReadCamera(res)
+ console.log('拍摄的图片', res);
+ },
+ fail: (err) => {
+ console.error('拍摄失败:', err);
+ wx.showToast({
+ title: '拍摄失败,请重试',
+ icon: 'none'
+ });
+ }
+ });
+ },
+
+ // 取消拍摄
+ cancelCamera() {
+ this.setData({ showCamera: false });
+ },
+ // 打开相机
+ openCamera() {
+ var that= this
+ if (that.data.form.devcode == "") {
+ wx.showToast({
+ icon: 'none',
+ title: '请先填写设备编号!\r\n否则水印中无编号',
+ duration: 2000
+ })
+ return false
+ }
+ if(Array.isArray(that.data.fileList) && that.data.fileList.length >= 6) {
+ wx.showToast({
+ icon: 'none',
+ title: '最多只允许上传6张图片',
+ duration: 2000
+ })
+ return false
+ }
+ that.setData({
+ 'showCamera': true
+ })
+ },
+// ---------------------------------新的-----------------------------------------------
+
+ /**
+ * 从相册选择(保持不变)
+ */
+ chooseFromAlbum() {
+ if (this.data.fileList.length >= this.data.maxCount) {
+ wx.showToast({ title: `最多选择${this.data.maxCount}张`, icon: 'none' });
+ return;
+ }
+
+ wx.chooseMedia({
+ count: this.data.maxCount - this.data.fileList.length,
+ mediaType: ['image'],
+ sourceType: ['album']
+ })
+ .then(res => {
+ const newImages = res.tempFiles.map(file => ({
+ tempFilePath: file.tempFilePath,
+ }));
+ this.afterRead()
+ const updatedList = [...this.data.fileList, ...newImages];
+ this.setData({
+ fileList: updatedList,
+ });
+
+ // newImages.forEach((img, idx) => {
+ // const globalIndex = this.data.fileList.length + idx;
+ // this.uploadSingleImage(globalIndex);
+ // });
+ })
+ .catch(err => {
+ console.error('选择相册失败:', err);
+ if (err.errMsg.includes('deny')) {
+ wx.showModal({
+ title: '权限不足',
+ content: '请在设置中开启相册权限',
+ confirmText: '去设置',
+ success: res => res.confirm && wx.openSetting()
+ });
+ }
+ });
+ },
+});
\ No newline at end of file
diff --git a/miniprogram/pages/addDevice/addDevice.wxml b/miniprogram/pages/addDevice/addDevice.wxml
index d3a77a0..6e4022b 100644
--- a/miniprogram/pages/addDevice/addDevice.wxml
+++ b/miniprogram/pages/addDevice/addDevice.wxml
@@ -96,8 +96,55 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{flashMode === 'torch' ? '关闭闪光灯' : '开启闪光灯'}}
+
+ 拍摄
+ 取消
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{flashMode === 'torch' ? '关闭闪光灯' : '开启闪光灯'}}
+
+ 拍摄
+ 取消
+
+
保存
diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.wxss b/miniprogram/pages/addDevicelog/addDeviceLog.wxss
index 08d5fd7..013e4fb 100644
--- a/miniprogram/pages/addDevicelog/addDeviceLog.wxss
+++ b/miniprogram/pages/addDevicelog/addDeviceLog.wxss
@@ -101,4 +101,219 @@
/* .van-cell{
height: 100rpx;
-} */
\ No newline at end of file
+} */
+
+/* -------------------------------------新的--------------------------------------- */
+
+/* index.wxss */
+.camera-container {
+ position: fixed;
+ top: 0;
+ left: 0;
+ width: 100%;
+ height: 100%;
+ background-color: #000;
+ z-index: 999;
+ }
+
+ .camera {
+ width: 100%;
+ height: calc(100% - 160rpx);
+ }
+
+ .camera-controls {
+ position: absolute;
+ bottom: 0;
+ left: 0;
+ width: 100%;
+ height: 160rpx;
+ background-color: rgba(0, 0, 0, 0.7);
+ display: flex;
+ align-items: center;
+ justify-content: space-around;
+ }
+
+ .flash-btn, .capture-btn, .cancel-btn {
+ color: white;
+ font-size: 28rpx;
+ padding: 20rpx 40rpx;
+ border-radius: 8rpx;
+ }
+
+ .capture-btn {
+ background-color: #f00;
+ width: 120rpx;
+ height: 120rpx;
+ border-radius: 50%;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ }
+
+ .flash-btn, .cancel-btn {
+ background-color: rgba(255, 255, 255, 0.2);
+ }
+
+
+/* 新增样式 */
+.upload-status {
+ position: absolute;
+ top: 0;
+ left: 0;
+ width: 100%;
+ height: 100%;
+ background-color: rgba(0,0,0,0.5);
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ }
+
+ .upload-tips {
+ color: #666;
+ font-size: 28rpx;
+ text-align: center;
+ margin: 20rpx 0;
+ }
+
+
+/* 新增闪光灯控制样式 */
+.camera-section {
+ flex: 1;
+ display: flex;
+ flex-direction: column;
+ gap: 15rpx;
+ }
+
+ .flash-control {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ gap: 10rpx;
+ font-size: 26rpx;
+ color: #666;
+ padding: 5rpx 0;
+ }
+
+ .flash-status {
+ color: #07c160;
+ font-weight: 500;
+ }
+
+ /* 原有样式保持不变 */
+ .btn-group {
+ display: flex;
+ gap: 20rpx;
+ padding: 20rpx;
+ align-items: center;
+ margin-bottom: 20rpx;
+ }
+
+ .action-btn {
+ flex: 1;
+ padding: 0 25rpx;
+ border-radius: 12rpx;
+ color: #fff;
+ font-size: 32rpx;
+ }
+
+ .camera-btn {
+ background-color: #07c160;
+ }
+
+ .album-btn {
+ background-color: #1677ff;
+ flex: 1;
+ }
+
+ /* 图片预览相关样式 */
+ .image-grid {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 15rpx;
+ padding: 0 20rpx;
+ }
+
+ .image-item {
+ position: relative;
+ width: calc(33.333% - 10rpx);
+ aspect-ratio: 1/1;
+ border-radius: 8rpx;
+ overflow: hidden;
+ }
+
+ .image-item image {
+ width: 100%;
+ height: 100%;
+ }
+
+ /* 上传状态样式 */
+ .status-mask {
+ position: absolute;
+ bottom: 0;
+ left: 0;
+ width: 100%;
+ height: 15rpx;
+ }
+
+ .progress-bar {
+ height: 100%;
+ background-color: #07c160;
+ }
+
+ .progress-text {
+ position: absolute;
+ top: -30rpx;
+ right: 10rpx;
+ font-size: 24rpx;
+ color: #07c160;
+ background-color: rgba(255,255,255,0.8);
+ padding: 2rpx 10rpx;
+ border-radius: 4rpx;
+ }
+
+ .status-icon {
+ position: absolute;
+ top: 10rpx;
+ right: 10rpx;
+ width: 40rpx;
+ height: 40rpx;
+ border-radius: 50%;
+ color: white;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ font-size: 24rpx;
+ }
+
+ .success {
+ background-color: #07c160;
+ }
+
+ .fail {
+ background-color: #ff4d4f;
+ }
+
+ .delete-icon {
+ position: absolute;
+ top: 10rpx;
+ right: 10rpx;
+ width: 40rpx;
+ height: 40rpx;
+ background-color: rgba(0,0,0,0.5);
+ color: white;
+ border-radius: 50%;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ font-size: 30rpx;
+ }
+
+ .retry-btn {
+ width: calc(100% - 40rpx);
+ margin: 20rpx;
+ padding: 20rpx 0;
+ background-color: #1677ff;
+ color: white;
+ border-radius: 8rpx;
+ font-size: 28rpx;
+ }
diff --git a/miniprogram/pages/defineMap/defineMap.js b/miniprogram/pages/defineMap/defineMap.js
index 651c287..278aca3 100644
--- a/miniprogram/pages/defineMap/defineMap.js
+++ b/miniprogram/pages/defineMap/defineMap.js
@@ -249,10 +249,12 @@
getMarkerIcon(status, wellType) {
// 地图上 橙红色:井打不开2,黄色 :已安装,蓝色1:未安装0
- if((wellType === '燃气井' || wellType === '雨水井' || wellType === '污水井') && status !== '3' && status !== '4' && status !== '5') {
+ if((wellType === '燃气井' || wellType === '雨水井' || wellType === '污水井') && status !== '3' && status !== '4' && status !== '5' && status !== '6') {
return '/images/gray-marker.png'
} else if((wellType === '燃气井' || wellType === '雨水井' || wellType === '污水井') && (status === '3' || status === '4' || status === '5')) {
return '/images/purple-marker.png'
+ } else if(status === '6') {
+ return '/images/red-marker.png'
}
else{
switch(status) {
@@ -281,6 +283,7 @@
case '0': return '未 ';
case '1': return '已 ';
case '2': return '井打不开 ';
+ case '6': return '井找不到 ';
default: return '未知 ';
}
},
@@ -289,7 +292,7 @@
console.log('气泡里面的按钮被点击');
// 在这里可以添加按钮点击后的具体逻辑
},
- // 点击井打不开
+ // 点击井打不开2
notopen() {
var that = this
wx.showModal({
@@ -330,14 +333,54 @@
}
})
},
+ // 井找不到6
+ notexit() {
+ var that = this
+ wx.showModal({
+ content: '确定井打不到吗?',
+ success: function (res) {
+ if (res.confirm) {
+ if(wellList.length) {
+ const index = wellList.findIndex(item => item.wellCode === that.data.activeMarkerWellCode)
+ if(index !== -1) {
+ wellList[index].isInStall = '6'
+ that.initManholeData(wellList)
+ }
+ }
+ wx.request({
+ method: "post",
+ url: app.globalData.httpsUrl + "/appDeviceAdd/markerWell",
+ data: {
+ wellCode: that.data.activeMarker.manholeInfo.wellCode,
+ isInStall: '6'
+ },
+ header: {
+ 'content-type': 'application/x-www-form-urlencoded;charset=utf-8'
+ },
+ success(res) {
+ },
+ fail(err) {
+ wx.showToast({
+ title: "修改井找不到状态失败",
+ icon: 'none',
+ duration: 2000
+ })
+ }
+ })
+ } else { //这里是点击了取消以后
+ console.log('用户点击取消')
+ }
+ }
+ })
+ },
// 编辑雨-污-燃井
updateWellType() {
var that = this
wx.showActionSheet({
- itemList: ['雨水井', '污水井', '燃气井'],
+ itemList: ['雨水井', '污水井', '燃气井', '井找不到'],
success: (res) => {
if (!res.cancel) {
- const types = [{label: '雨水井', value: '3'}, {label: '污水井', value: '4'}, {label: '燃气井', value: '5'}];
+ const types = [{label: '雨水井', value: '3'}, {label: '污水井', value: '4'}, {label: '燃气井', value: '5'}, {label: '井找不到', value: '6'}];
const paramstypes = types[res.tapIndex].value
const paramstitle = types[res.tapIndex].label
wx.showModal({
diff --git a/miniprogram/app.js b/miniprogram/app.js
index c10326f..4f1ad89 100644
--- a/miniprogram/app.js
+++ b/miniprogram/app.js
@@ -20,7 +20,7 @@
globalData: {
httpsUrl: "https://logapi.smartlog.work/", // 正式域名
// httpsUrl: "http://111.198.10.15:11638/", // 15
- // httpsUrl: "http://192.168.126.39:5905/", // 周甜
+ // httpsUrl: "http://192.168.95.39:5905/", // 周甜
// httpsUrl: "https://grey.logapi.smartlog.work/", // 测试域名
openid: null,
indexCount:1,
diff --git a/miniprogram/app.json b/miniprogram/app.json
index 3c1d780..975101c 100644
--- a/miniprogram/app.json
+++ b/miniprogram/app.json
@@ -50,6 +50,9 @@
"permission": {
"scope.userLocation": {
"desc": "你的位置信息将用于小程序位置接口的效果展示"
+ },
+ "scope.camera": {
+ "desc": "你的小程序需要使用相机来完成相关操作,如扫描设备、上传照片等"
}
},
"requiredPrivateInfos": [
diff --git a/miniprogram/images/red-marker.png b/miniprogram/images/red-marker.png
new file mode 100644
index 0000000..ed00cf5
--- /dev/null
+++ b/miniprogram/images/red-marker.png
Binary files differ
diff --git a/miniprogram/pages/addDevice/addDevice copy.js b/miniprogram/pages/addDevice/addDevice copy.js
new file mode 100644
index 0000000..fcf664d
--- /dev/null
+++ b/miniprogram/pages/addDevice/addDevice copy.js
@@ -0,0 +1,947 @@
+// miniprogram/pages/addDevice/addDevice.js
+// import WxValidate from '../../utils/WxValidate.js'
+var QQMapWX = require('../../libs/qqmap-wx-jssdk.js');
+var qqmapsdk;
+var app = getApp()
+const installTypeMap = {
+ '1': '初次安装',
+ '2': '初次拆走',
+ '3': '二次安装',
+ '4': '二次拆走',
+ '5': '正在维护',
+ '6': '其他',
+}
+Page({
+
+ /**
+ * 页面的初始数据
+ */
+ data: {
+ wellActions: [], // 选择井编号
+ wellShow: false, // 是否显示选择井编号
+ projectName: '', // 项目名称
+ canvasHeight: '',
+ canvasWidth: '',
+ longitude: '',
+ latitude: '',
+ option1: [],
+ personoption1: [],
+ projectoption: [],
+ devtypeList:[],
+ installTypeList:[
+ {
+ text: '初次安装',
+ value: '1',
+ },
+ {
+ text: '初次拆走',
+ value: '2',
+ },
+ {
+ text: '二次安装',
+ value: '3',
+ },
+ {
+ text: '二次拆走',
+ value: '4',
+ },
+ {
+ text: '正在维护',
+ value: '5',
+ },
+ {
+ text: '其他',
+ value: '6',
+ },
+ ],
+ show: false,
+ form: {
+ devcode: "",
+ wellcode: "",
+ welltype: "",
+ welldepth: "",
+ installheigt: "",
+ installperson: "",
+ installtimeFmt: "",
+ photopath: "",
+ factory: "",
+ workmsg: "",
+ position: "",
+ longitude: "",
+ latitude: "",
+ longitude84: "",
+ latitude84: "",
+ devicetype: "",
+ project: '',
+ area: "",
+ street: "",
+ wellname: "",
+ photopath1: '',
+ photopath2: '',
+ photopath3: '',
+ installType: '1', // 设备安装情况
+ description: "初次安装", // 备注
+ },
+ fileList: [],
+ listQuery: {
+ wellCode: '', // wellCode
+ wellType: '', // 井类型
+ position: '', // 位置
+ projectId: '', // 所在项目
+ },
+ showSelectProject: false,
+ },
+
+ onDisplay() {
+ this.setData({
+ show: true
+ });
+ },
+ onClose() {
+ this.setData({
+ show: false
+ });
+ },
+ // cleaable 清除经度
+ clearLongitude() {
+ var _this = this;
+ _this.setData({
+ 'form.longitude': '',
+ });
+ },
+// 清除纬度
+ clearclearLatitude() {
+ var _this = this;
+ _this.setData({
+ 'form.latitude': '',
+ });
+ },
+ 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),
+ });
+ },
+
+ /**
+ * 生命周期函数--监听页面加载
+ */
+ onLoad: function (options) {
+ var that = this;
+ if(app.globalData.role === 'repair' && app.globalData.isConfigProject === '0') {
+ that.setData({
+ 'showSelectProject': true,
+ })
+ } else {
+ that.setData({
+ 'showSelectProject': false,
+ })
+ }
+
+ console.log(app.globalData.selectProjectId, '===');
+ that.setData({
+ 'form.project': app.globalData.selectProjectName,
+ 'projectName': app.globalData.selectProjectName,
+ })
+ console.log('-----------------------3333', options);
+ //=========初始化表单内容为上次填写值==========
+ // 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
+ //默认安装经纬度为当前位置(gcj02)
+ if(options.fromPage !== 'defineMap') {
+ wx.getLocation({
+ type: "gcj02",
+ altitude: true,
+ success: function (res) {
+ var longitude = 'form.longitude';
+ var latitude = 'form.latitude';
+ that.setData({
+ [longitude]: parseFloat(res.longitude).toFixed(6),
+ [latitude]: parseFloat(res.latitude).toFixed(6),
+ longitude: parseFloat(res.longitude).toFixed(6),
+ latitude: parseFloat(res.latitude).toFixed(6),
+ });
+ //获取当前坐标(wgs84),特别注意需要放在加载里面,否则获取有误
+ wx.getLocation({
+ type: "wgs84",
+ altitude: true,
+ success: function (res) {
+ var longitude84 = 'form.longitude84';
+ var latitude84 = 'form.latitude84';
+ that.setData({
+ [latitude84]: parseFloat(res.latitude).toFixed(6),
+ [longitude84]: parseFloat(res.longitude).toFixed(6)
+ })
+ }
+ })
+ }
+ })
+ }
+
+
+ //获取井类型下拉列表
+ 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);
+ }
+ console.log('------', welltypeArr)
+ that.setData({
+ option1: welltypeArr
+ })
+ }
+ }
+ })
+
+ //获取人员下拉列表
+ 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);
+ }
+ personArr.push({
+ text: app.globalData.currentUserName,
+ value: app.globalData.currentUserName
+ });
+
+ that.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);
+ }
+ that.setData({
+ projectoption: projectArr
+ })
+ }
+ }
+ })
+
+ var installtime = 'form.installtimeFmt';
+ var dateNow = this.formatDate();
+ this.setData({
+ show: false,
+ 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
+ })
+ }
+ }
+ })
+
+ // 粘贴经纬度
+ if(options.fromPage !== 'defineMap') {
+ this.paste()
+ }
+ // 处理备注的默认
+ var description = 'form.description';
+ that.setData({
+ [description]: installTypeMap[that.data.form.installType]
+ })
+ console.log('options', options);
+ if(options.fromPage === 'defineMap') { // 从自定义地图页面跳转过来
+ console.log('-09999999999', app.globalData.currentUserName);
+ that.setData({
+ 'form.wellType': options.wellType, // 井类型
+ 'form.wellcode': options.wellCode, // 井编号
+ 'form.position': options.position, // 位置
+ 'form.devicetype': '井盖状态监测仪', // 设备类型
+ 'form.installperson': app.globalData.currentUserName, // 安装人员
+ 'form.project': '2025-NBJ', // 所属项目
+ 'form.latitude': parseFloat(options.latitude).toFixed(6),
+ 'form.longitude': parseFloat(options.longitude).toFixed(6),
+ latitude: parseFloat(options.latitude).toFixed(6),
+ longitude: parseFloat(options.longitude).toFixed(6),
+ })
+ }
+ that.setData({
+ 'form.installperson': app.globalData.currentUserName, // 安装人员
+ 'form.project': '2025-NBJ', // 所属项目
+ })
+ },
+
+
+
+
+ /**
+ * 生命周期函数--监听页面初次渲染完成
+ */
+ onReady: function () {
+
+ },
+
+ /**
+ * 生命周期函数--监听页面显示
+ */
+ onShow: function () {
+
+ },
+
+ /**
+ * 生命周期函数--监听页面隐藏
+ */
+ onHide: function () {
+
+ },
+
+ /**
+ * 生命周期函数--监听页面卸载
+ */
+ onUnload: function () {
+
+ },
+
+ /**
+ * 页面相关事件处理函数--监听用户下拉动作
+ */
+ onPullDownRefresh: function () {
+
+ },
+
+ // 监听页面滚动
+ onPageScroll(e) {
+ console.log('监听页面滚动');
+ var that = this
+ console.log(that.selectComponent('#selectPersonDropdown'));
+ // that.selectComponent('#selectPersonDropdown').triggerEvent(false)
+},
+
+toggle() {
+
+},
+ // 点击检索
+ searchWellCode() {
+ if(!this.data.form.wellcode) {
+ wx.showToast({
+ icon: 'error',
+ title: '请先输入井编号',
+ })
+ return false
+ }
+ this.setData({
+ 'listQuery.wellCode': this.data.form.wellcode
+ })
+ this.fetchWellPre()
+ },
+ //获取井列表
+ fetchWellPre() {
+ return new Promise((resolve, reject) => {
+ var that = this
+ wx.showLoading({
+ mask: true
+ })
+ wx.request({
+ method: "POST",
+ url: app.globalData.httpsUrl + "well/pre/listPage" + `?offset=${1}&limit=${9999}`,
+ // header: {
+ // 'content-type': 'application/x-www-form-urlencoded;charset=utf-8'
+ // },
+ data: {
+ ...that.data.listQuery,
+ offset: 1,
+ limit: 9999
+ },
+ success(res) {
+ wx.hideLoading()
+ if (res.data) {
+ if(!res.data.data.rows.length) {
+ wx.showToast({
+ icon: 'error',
+ title: '查无结果'
+ })
+ } else {
+ const tempList = res.data.data.rows.map(item => {
+ return {
+ ...item,
+ name: item.wellName,
+ }
+ })
+ that.setData({
+ wellActions: tempList,
+ wellShow: true
+ })
+ }
+ }
+ },
+ fail(res) {
+ wx.hideLoading()
+ wx.showToast({
+ icon: 'none',
+ title: '查询失败,请手动输入'
+ })
+ }
+ })
+ })
+ },
+ // 点击选择器的取消
+ cancleWellShow() {
+ this.setData({
+ wellShow: false,
+ })
+ },
+ // 选择好井
+ selectWells(e) {
+ var that = this
+ const val = e.detail
+ console.log(val);
+ that.setData({
+ 'form.wellcode': val.wellCode, // 井编号
+ 'form.wellname': val.wellName, // 井名称
+ 'form.welltype': val.wellType, // 井类型
+ 'form.position': val.position, //位置描述
+ })
+ that.cancleWellShow()
+ },
+
+ /**
+ * 页面上拉触底事件的处理函数
+ */
+ onReachBottom: function () {
+
+ },
+
+ /**
+ * 用户点击右上角分享
+ */
+ onShareAppMessage: function () {
+
+ },
+
+
+
+ /**
+ * 校验只要是数字(包含正负整数,0以及正负浮点数)就返回true
+ **/
+
+ isNumber: function (val) {
+
+ var regPos = /^[0-9]*$/; //非负浮点数
+ var regNeg = /^(-?\d+)(\.\d+)?$/; //负浮点数
+ if (regPos.test(val) || regNeg.test(val)) {
+ return false;
+ } else {
+ return true;
+ }
+
+ },
+
+ //验证表单
+ formValidate() {
+
+ if (this.data.form.devcode == "") {
+ 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',
+ title: '井编号不能为空!',
+ })
+ return false
+ }
+
+ if (this.data.form.devicetype == "") {
+ wx.showToast({
+ icon: 'none',
+ title: '设备类型不能为空!',
+ })
+ return false
+ }
+
+
+
+ if (this.data.form.installperson == "") {
+ 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
+ }
+ }
+
+ if (this.data.form.project == "") {
+ wx.showToast({
+ icon: 'none',
+ title: '所属项目不能为空!',
+ })
+ return false
+ }
+
+ if (this.data.form.installtimeFmt == null) {
+ wx.showToast({
+ icon: 'none',
+ title: '安装时间不能为空!',
+ })
+ return false
+ }
+ return true;
+ },
+ //提交表单
+ formSubmit: function (event) {
+ console.log(this.data.form)
+ //表单参数验证
+ if (!this.formValidate()) {
+ return false;
+ }
+ var that = this;
+ //验证设备编号长度
+ wx.request({
+ method: 'POST',
+ url: app.globalData.httpsUrl + "appDeviceAdd/getDevTypeLength",
+ data: {
+ code: encodeURI(this.data.form.devicetype)
+ },
+ 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
+ }
+ }
+ })
+ },
+
+ //保存设备基本信息
+ 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]
+ })
+ }
+ that.setData({
+ 'form.project': that.data.form.project,
+ 'projectName': that.data.form.project,
+ })
+ //表单提交
+ 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: '提交成功,是否返回?',
+ showCancel: false, // 不显示取消按钮
+ success: function (res) {
+ console.log('用户点击了返回')
+ //用于回显
+ console.log('lll', that.data.form);
+ wx.setStorageSync('cacheList', that.data.form)
+ //提交成功后提示用户操作
+ if (res.confirm) {
+ // wx.switchTab({
+ // url: '../earth/earth'
+ // })
+ console.log('lleeel', that.data.form);
+ app.globalData.addsuccessWellCode = that.data.form.wellcode
+ wx.navigateBack({ // 返回上一页
+ delta: 1
+ });
+ } else { //这里是点击了取消以后
+ console.log('用户点击取消')
+ }
+ }
+ })
+ }
+ },
+ fail(err) {
+ wx.showToast({
+ title: '提交失败!',
+ })
+ }
+ })
+ },
+ // 井编号输入框点击清除按钮
+// clickClearable() {
+// this.setData({
+// 'form.wellcode': ''
+// })
+// },
+ // 井编号改变
+ changeWellCode(e) {
+ console.log(e);
+ this.setData({
+ 'form.wellcode': e.detail
+ })
+ },
+
+ //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,
+ })
+ //若输入是设备编号,自动获取设备类型
+ 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({
+ success(res) {
+ var devcode = res.result
+ var formdevcode = 'form.devcode'
+ _this.setData({
+ [formdevcode]: devcode
+ });
+ wx.request({
+ method: 'POST',
+ url: app.globalData.httpsUrl + "appDeviceAdd/findModeCodeByCode",
+ data: {
+ devcode: devcode,
+ },
+ 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({
+ 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),
+ });
+ _this.showAddress(_this.data.form.longitude,_this.data.form.latitude,_this)
+ }
+ })
+ },
+ //设置经类型
+ selectValue(value) {
+
+ var that = this;
+ var wellType = 'form.welltype';
+ that.setData({
+ [wellType]: value.detail
+ })
+ },
+ // 设置设备安装情况
+ selectInstallType(value) {
+ var that = this;
+ var installType = 'form.installType';
+ var description = 'form.description';
+ that.setData({
+ [installType]: value.detail,
+ [description]: installTypeMap[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';
+ that.setData({
+ [installPerson]: event.detail
+ })
+ },
+ //设置项目
+ selectprojectValue(event) {
+ var that = this;
+ var project = 'form.project';
+ that.setData({
+ [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;
+ 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
+ });
+ }
+ }
+ })
+ }
+ })
+ },
+ //删除照片
+ deletePhoto(event) {
+ var image_index = event.detail.index
+ var fileList_new = this.data.fileList;
+ fileList_new.splice(image_index, 1);
+ this.setData({
+ fileList: fileList_new
+ })
+ },
+})
\ No newline at end of file
diff --git a/miniprogram/pages/addDevice/addDevice copy.wxml b/miniprogram/pages/addDevice/addDevice copy.wxml
new file mode 100644
index 0000000..d3a77a0
--- /dev/null
+++ b/miniprogram/pages/addDevice/addDevice copy.wxml
@@ -0,0 +1,129 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 保存
+
+
+
+
+
\ No newline at end of file
diff --git a/miniprogram/pages/addDevice/addDevice.js b/miniprogram/pages/addDevice/addDevice.js
index fcf664d..b397d10 100644
--- a/miniprogram/pages/addDevice/addDevice.js
+++ b/miniprogram/pages/addDevice/addDevice.js
@@ -90,6 +90,9 @@
projectId: '', // 所在项目
},
showSelectProject: false,
+ showCamera: false,
+ flashMode: 'torch', // 闪光灯模式: off | on | auto
+ maxCount: 6, // 最多能上传几张图片
},
onDisplay() {
@@ -885,7 +888,61 @@
});
},
//上传照片
- afterRead(event) {
+ afterReadCamera(event) {
+ var _this = this;
+ if (_this.data.form.devcode == "") {
+ wx.showToast({
+ icon: 'none',
+ title: '请先填写设备编号!\r\n否则水印中无编号',
+ duration: 2000
+ })
+ return false
+ }
+ // const {
+ // file
+ // } = event.detail;
+ const file = event
+ const {
+ fileList = []
+ } = this.data;
+ var convertpath = "";
+ // 压缩图片
+ wx.compressImage({
+ src: event.tempImagePath,
+ // 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
+ });
+ console.log('fileList', _this.data.fileList);
+ }
+ }
+ })
+ }
+ })
+ },
+ //上传照片
+ afterRead(event) {
var _this = this;
if (_this.data.form.devcode == "") {
wx.showToast({
@@ -898,6 +955,7 @@
const {
file
} = event.detail;
+ // const file = event
const {
fileList = []
} = this.data;
@@ -929,6 +987,7 @@
_this.setData({
fileList
});
+ console.log('fileList', _this.data.fileList);
}
}
})
@@ -944,4 +1003,107 @@
fileList: fileList_new
})
},
-})
\ No newline at end of file
+
+ // 切换闪光灯模式
+ toggleFlash() {
+ var that = this
+ const flashMode = that.data.flashMode === 'off' ? 'torch' : 'off';
+ that.setData({ 'flashMode': flashMode });
+ },
+
+ // 拍摄照片
+ takePhoto() {
+ console.log('闪光灯', this.data.flashMode);
+ const ctx = wx.createCameraContext();
+ ctx.takePhoto({
+ quality: 'high',
+ success: (res) => {
+ this.setData({
+ tempImagePath: res.tempImagePath,
+ showCamera: false
+ });
+
+ this.afterReadCamera(res)
+ console.log('拍摄的图片', res);
+ },
+ fail: (err) => {
+ console.error('拍摄失败:', err);
+ wx.showToast({
+ title: '拍摄失败,请重试',
+ icon: 'none'
+ });
+ }
+ });
+ },
+
+ // 取消拍摄
+ cancelCamera() {
+ this.setData({ showCamera: false });
+ },
+ // 打开相机
+ openCamera() {
+ var that= this
+ if (that.data.form.devcode == "") {
+ wx.showToast({
+ icon: 'none',
+ title: '请先填写设备编号!\r\n否则水印中无编号',
+ duration: 2000
+ })
+ return false
+ }
+ if(Array.isArray(that.data.fileList) && that.data.fileList.length >= 6) {
+ wx.showToast({
+ icon: 'none',
+ title: '最多只允许上传6张图片',
+ duration: 2000
+ })
+ return false
+ }
+ that.setData({
+ 'showCamera': true
+ })
+ },
+// ---------------------------------新的-----------------------------------------------
+
+ /**
+ * 从相册选择(保持不变)
+ */
+ chooseFromAlbum() {
+ if (this.data.fileList.length >= this.data.maxCount) {
+ wx.showToast({ title: `最多选择${this.data.maxCount}张`, icon: 'none' });
+ return;
+ }
+
+ wx.chooseMedia({
+ count: this.data.maxCount - this.data.fileList.length,
+ mediaType: ['image'],
+ sourceType: ['album']
+ })
+ .then(res => {
+ const newImages = res.tempFiles.map(file => ({
+ tempFilePath: file.tempFilePath,
+ }));
+ this.afterRead()
+ const updatedList = [...this.data.fileList, ...newImages];
+ this.setData({
+ fileList: updatedList,
+ });
+
+ // newImages.forEach((img, idx) => {
+ // const globalIndex = this.data.fileList.length + idx;
+ // this.uploadSingleImage(globalIndex);
+ // });
+ })
+ .catch(err => {
+ console.error('选择相册失败:', err);
+ if (err.errMsg.includes('deny')) {
+ wx.showModal({
+ title: '权限不足',
+ content: '请在设置中开启相册权限',
+ confirmText: '去设置',
+ success: res => res.confirm && wx.openSetting()
+ });
+ }
+ });
+ },
+});
\ No newline at end of file
diff --git a/miniprogram/pages/addDevice/addDevice.wxml b/miniprogram/pages/addDevice/addDevice.wxml
index d3a77a0..6e4022b 100644
--- a/miniprogram/pages/addDevice/addDevice.wxml
+++ b/miniprogram/pages/addDevice/addDevice.wxml
@@ -96,8 +96,55 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{flashMode === 'torch' ? '关闭闪光灯' : '开启闪光灯'}}
+
+ 拍摄
+ 取消
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{flashMode === 'torch' ? '关闭闪光灯' : '开启闪光灯'}}
+
+ 拍摄
+ 取消
+
+
保存
diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.wxss b/miniprogram/pages/addDevicelog/addDeviceLog.wxss
index 08d5fd7..013e4fb 100644
--- a/miniprogram/pages/addDevicelog/addDeviceLog.wxss
+++ b/miniprogram/pages/addDevicelog/addDeviceLog.wxss
@@ -101,4 +101,219 @@
/* .van-cell{
height: 100rpx;
-} */
\ No newline at end of file
+} */
+
+/* -------------------------------------新的--------------------------------------- */
+
+/* index.wxss */
+.camera-container {
+ position: fixed;
+ top: 0;
+ left: 0;
+ width: 100%;
+ height: 100%;
+ background-color: #000;
+ z-index: 999;
+ }
+
+ .camera {
+ width: 100%;
+ height: calc(100% - 160rpx);
+ }
+
+ .camera-controls {
+ position: absolute;
+ bottom: 0;
+ left: 0;
+ width: 100%;
+ height: 160rpx;
+ background-color: rgba(0, 0, 0, 0.7);
+ display: flex;
+ align-items: center;
+ justify-content: space-around;
+ }
+
+ .flash-btn, .capture-btn, .cancel-btn {
+ color: white;
+ font-size: 28rpx;
+ padding: 20rpx 40rpx;
+ border-radius: 8rpx;
+ }
+
+ .capture-btn {
+ background-color: #f00;
+ width: 120rpx;
+ height: 120rpx;
+ border-radius: 50%;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ }
+
+ .flash-btn, .cancel-btn {
+ background-color: rgba(255, 255, 255, 0.2);
+ }
+
+
+/* 新增样式 */
+.upload-status {
+ position: absolute;
+ top: 0;
+ left: 0;
+ width: 100%;
+ height: 100%;
+ background-color: rgba(0,0,0,0.5);
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ }
+
+ .upload-tips {
+ color: #666;
+ font-size: 28rpx;
+ text-align: center;
+ margin: 20rpx 0;
+ }
+
+
+/* 新增闪光灯控制样式 */
+.camera-section {
+ flex: 1;
+ display: flex;
+ flex-direction: column;
+ gap: 15rpx;
+ }
+
+ .flash-control {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ gap: 10rpx;
+ font-size: 26rpx;
+ color: #666;
+ padding: 5rpx 0;
+ }
+
+ .flash-status {
+ color: #07c160;
+ font-weight: 500;
+ }
+
+ /* 原有样式保持不变 */
+ .btn-group {
+ display: flex;
+ gap: 20rpx;
+ padding: 20rpx;
+ align-items: center;
+ margin-bottom: 20rpx;
+ }
+
+ .action-btn {
+ flex: 1;
+ padding: 0 25rpx;
+ border-radius: 12rpx;
+ color: #fff;
+ font-size: 32rpx;
+ }
+
+ .camera-btn {
+ background-color: #07c160;
+ }
+
+ .album-btn {
+ background-color: #1677ff;
+ flex: 1;
+ }
+
+ /* 图片预览相关样式 */
+ .image-grid {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 15rpx;
+ padding: 0 20rpx;
+ }
+
+ .image-item {
+ position: relative;
+ width: calc(33.333% - 10rpx);
+ aspect-ratio: 1/1;
+ border-radius: 8rpx;
+ overflow: hidden;
+ }
+
+ .image-item image {
+ width: 100%;
+ height: 100%;
+ }
+
+ /* 上传状态样式 */
+ .status-mask {
+ position: absolute;
+ bottom: 0;
+ left: 0;
+ width: 100%;
+ height: 15rpx;
+ }
+
+ .progress-bar {
+ height: 100%;
+ background-color: #07c160;
+ }
+
+ .progress-text {
+ position: absolute;
+ top: -30rpx;
+ right: 10rpx;
+ font-size: 24rpx;
+ color: #07c160;
+ background-color: rgba(255,255,255,0.8);
+ padding: 2rpx 10rpx;
+ border-radius: 4rpx;
+ }
+
+ .status-icon {
+ position: absolute;
+ top: 10rpx;
+ right: 10rpx;
+ width: 40rpx;
+ height: 40rpx;
+ border-radius: 50%;
+ color: white;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ font-size: 24rpx;
+ }
+
+ .success {
+ background-color: #07c160;
+ }
+
+ .fail {
+ background-color: #ff4d4f;
+ }
+
+ .delete-icon {
+ position: absolute;
+ top: 10rpx;
+ right: 10rpx;
+ width: 40rpx;
+ height: 40rpx;
+ background-color: rgba(0,0,0,0.5);
+ color: white;
+ border-radius: 50%;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ font-size: 30rpx;
+ }
+
+ .retry-btn {
+ width: calc(100% - 40rpx);
+ margin: 20rpx;
+ padding: 20rpx 0;
+ background-color: #1677ff;
+ color: white;
+ border-radius: 8rpx;
+ font-size: 28rpx;
+ }
diff --git a/miniprogram/pages/defineMap/defineMap.js b/miniprogram/pages/defineMap/defineMap.js
index 651c287..278aca3 100644
--- a/miniprogram/pages/defineMap/defineMap.js
+++ b/miniprogram/pages/defineMap/defineMap.js
@@ -249,10 +249,12 @@
getMarkerIcon(status, wellType) {
// 地图上 橙红色:井打不开2,黄色 :已安装,蓝色1:未安装0
- if((wellType === '燃气井' || wellType === '雨水井' || wellType === '污水井') && status !== '3' && status !== '4' && status !== '5') {
+ if((wellType === '燃气井' || wellType === '雨水井' || wellType === '污水井') && status !== '3' && status !== '4' && status !== '5' && status !== '6') {
return '/images/gray-marker.png'
} else if((wellType === '燃气井' || wellType === '雨水井' || wellType === '污水井') && (status === '3' || status === '4' || status === '5')) {
return '/images/purple-marker.png'
+ } else if(status === '6') {
+ return '/images/red-marker.png'
}
else{
switch(status) {
@@ -281,6 +283,7 @@
case '0': return '未 ';
case '1': return '已 ';
case '2': return '井打不开 ';
+ case '6': return '井找不到 ';
default: return '未知 ';
}
},
@@ -289,7 +292,7 @@
console.log('气泡里面的按钮被点击');
// 在这里可以添加按钮点击后的具体逻辑
},
- // 点击井打不开
+ // 点击井打不开2
notopen() {
var that = this
wx.showModal({
@@ -330,14 +333,54 @@
}
})
},
+ // 井找不到6
+ notexit() {
+ var that = this
+ wx.showModal({
+ content: '确定井打不到吗?',
+ success: function (res) {
+ if (res.confirm) {
+ if(wellList.length) {
+ const index = wellList.findIndex(item => item.wellCode === that.data.activeMarkerWellCode)
+ if(index !== -1) {
+ wellList[index].isInStall = '6'
+ that.initManholeData(wellList)
+ }
+ }
+ wx.request({
+ method: "post",
+ url: app.globalData.httpsUrl + "/appDeviceAdd/markerWell",
+ data: {
+ wellCode: that.data.activeMarker.manholeInfo.wellCode,
+ isInStall: '6'
+ },
+ header: {
+ 'content-type': 'application/x-www-form-urlencoded;charset=utf-8'
+ },
+ success(res) {
+ },
+ fail(err) {
+ wx.showToast({
+ title: "修改井找不到状态失败",
+ icon: 'none',
+ duration: 2000
+ })
+ }
+ })
+ } else { //这里是点击了取消以后
+ console.log('用户点击取消')
+ }
+ }
+ })
+ },
// 编辑雨-污-燃井
updateWellType() {
var that = this
wx.showActionSheet({
- itemList: ['雨水井', '污水井', '燃气井'],
+ itemList: ['雨水井', '污水井', '燃气井', '井找不到'],
success: (res) => {
if (!res.cancel) {
- const types = [{label: '雨水井', value: '3'}, {label: '污水井', value: '4'}, {label: '燃气井', value: '5'}];
+ const types = [{label: '雨水井', value: '3'}, {label: '污水井', value: '4'}, {label: '燃气井', value: '5'}, {label: '井找不到', value: '6'}];
const paramstypes = types[res.tapIndex].value
const paramstitle = types[res.tapIndex].label
wx.showModal({
diff --git a/miniprogram/pages/defineMap/defineMap.wxml b/miniprogram/pages/defineMap/defineMap.wxml
index b7d1db5..0059ebd 100644
--- a/miniprogram/pages/defineMap/defineMap.wxml
+++ b/miniprogram/pages/defineMap/defineMap.wxml
@@ -52,7 +52,12 @@
井打不开
-