Browse Source

修复扫码

Ming 4 years ago
parent
commit
6862469a2e
4 changed files with 107 additions and 136 deletions
  1. 7 8
      pages/deviceManage/component/exportModal.vue
  2. 67 107
      pages/deviceManage/deviceManage.vue
  3. 30 18
      pages/index/index.vue
  4. 3 3
      util/jssdk.js

+ 7 - 8
pages/deviceManage/component/exportModal.vue

@@ -12,9 +12,9 @@
 				<view style="margin:20rpx 0">已导出文件,是否打开?</view>
 			</view>
 			<view class="cu-bar operate bg-white" style="min-height: 100rpx;">
-				<view class="action margin-0   " @tap="saveAs">
+				<view class="action margin-0   " @tap="cSaveAsData">
 					另存为</view>
-				<view class="action margin-0  solid-left text-blue" @tap="cancel">取消</view>
+				<view class="action margin-0  solid-left text-blue" @tap="cCancel">取消</view>
 			</view>
 		</view>
 	</view>
@@ -29,14 +29,13 @@
 			}
 		},
 		methods: {
-			saveAs() {
-				// alert(1)
-			        // this.$emit('fatherHideModal');
-					this.$emit('fSaveAsData')
+			cSaveAsData() {
+
+					this.$emit('f-SaveAsData')
 			 },
-			 cancel(){
+			 cCancel(){
 				 alert(1)
-				  this.$emit('fatherHideModal');
+				  this.$emit('f-HideModel');
 				 
 			 }
 		}

+ 67 - 107
pages/deviceManage/deviceManage.vue

@@ -3,7 +3,6 @@
 
 		<!-- 筛选框start -->
 		<view>
-
 			<view style="height:206rpx"></view>
 			<view class="ding">
 				<view class="cu-bar search bg-gray filter-section" style="with:50%;">
@@ -47,7 +46,7 @@
 					<view class="cu-list menu-avatar ">
 						<view class=" site-item text-center margin-top" v-if="!this.deviceManage.length&&this.deviceManageRes==1">暂无数据</view>
 						<view class="cu-item" :class="modalName=='move-box-'+ index?'move-cur':''"
-							v-for="(item,index) in deviceManage" :key="index" :data-target="'move-box-' + index">
+							v-for="(item,index) in newDeviceManage" :key="index" :data-target="'move-box-' + index">
 							<view class="cu-form-group margin-top">
 								<checkbox :value="String(item.id)" :checked="checkedArr.includes(String(item.id))"
 									:class="{'checked':checkedArr.includes(String(item.id))}"></checkbox>
@@ -71,8 +70,6 @@
 										:data-index='index'>删除设备</view> -->
 								</view>
 
-
-
 							</view>
 							<view class="nav-right num">
 								<view class="text-grey">
@@ -104,17 +101,8 @@
 				<view @tap="showModal" data-target="DialogModal">
 						导出
 				</view>
-				<!-- <view @tap="showModal" data-target="DialogModal" v-else>
-					<download-excel class="export-excel-wrapper" :data="exportData" :fields="json_fields" header='导出数据'
-						name="设备管理数据表.xls">
-						导出
-					</download-excel>
-					
-				</view> -->
-
 			</view>
 			<view class="checkAll" style="display:inline-block">
-
 				<checkbox-group @change="allChoose" v-if="deviceManage.length">
 					<label>
 						<checkbox value="all" :class="{'checked':allChecked}" :checked="allChecked?true:false">
@@ -126,7 +114,7 @@
 		<!-- 分享区域  end-->
 
 		<!-- 导出弹框 -->
-		<export-modal :modalName='modalName' @fSaveAsData="saveAsData()" @fatherHideModal="hideModal()"></export-modal>
+		<export-modal :modalName='modalName' @f-SaveAsData="saveAsData()" @f-HideModel="hideModal()"></export-modal>
 		<!-- 导出弹框 end -->
 
 		<!-- 删除弹框 -->
@@ -185,59 +173,43 @@
 	export default {
 		components: {
 			validCode,
-			// searchArea,
 			exportModal
 		},
 		data() {
 			return {
-				deviceManage: 0,
-				json_fields: {
-					"单位编号": "company", //常规字段
-					"状态": "device_state",
-					"设备编号": "owner_code", 
-					"设备名称": "owner_name",
-					"单元地址": "unitinfo",
-					"创建时间": "install_time",
-				},
-
+				dwtype: 0,
+				transmission_mode: 0,
+				
 				deviceManage: [],
-				validCode: '',
-
+				deviceManageRes: 0,
+				type: '0',
+				modalName: null,
+				
 				checkbox: [{
 					value: 'A',
 					checked: false
 				}],
-
-				deviceManageRes: 0,
-
-				type: '0',
-				siteListData: [],
-				modalName: null,
-				listTouchStart: 0,
-				listTouchDirection: null,
-				CustomBar: this.CustomBar,
-
+				isChecked: false,
+				checkedArr: [], //复选框选中的值
+				allChecked: false ,//是否全选
+				
 				deleteIndex: '',
 				deleteId: '',
-				dwtype: 0,
-				transmission_mode: 0,
-
-				// checkAllFlag:false,
+				validCode: '',
 
 				exportData:[],
-				isChecked: false,
-				checkedArr: [], //复选框选中的值
-				allChecked: false //是否全选
+				json_fields: {
+					"单位编号": "company", //常规字段
+					"状态": "device_state",
+					"设备编号": "owner_code", 
+					"设备名称": "owner_name",
+					"单元地址": "unitinfo",
+					"创建时间": "install_time",
+				},
+
 			};
 		},
 
-
-		onPullDownRefresh() {
-			console.log('refresh');
-			setTimeout(function() {
-				uni.stopPullDownRefresh();
-			}, 1000);
-		},
 		computed: {
 			newDeviceManage() {
 				return this.deviceManage.map(item => {
@@ -245,10 +217,9 @@
 					return item
 				})
 			}
-
 		},
-
 		mounted() {
+			//点击弹框外隐藏弹框
 			document.addEventListener('click', (event) => {
 				if (event.target.className != 'showDetailEdit') {
 					this.deviceManage.forEach(item => {
@@ -264,7 +235,7 @@
 		},
 		methods: {
 
-			//筛选
+			//筛选请求
 			searchList() {
 				this.getDataList({
 					"transmission_mode": this.transmission_mode,
@@ -295,24 +266,48 @@
 					url: '/pages/deviceManage/deviceEdit/deviceEdit?type=' + item.id + '',
 				});
 			},
+
+			// 长摁隐藏显示查看详情弹框
+			showDetail(e) {
+				// console.log(e)
+				// 存储点击那一项的状态
+				const nowStatu = e.isShow;
+				//判断如果长摁弹框出来时,
+				if (!nowStatu) {
+					this.checkedArr = [];
+					this.allChecked = false;
+				}
+				// 将每一项列表的isShow设置为false,让所有的列表都隐藏
+				this.deviceManage.forEach(item => {
+					item.isShow = false
+				})
+				// 用于再次点击该项的取反
+				e.isShow = !nowStatu
+			},
+			
+			
 			//导出弹框
 			showModal(e) {
-				console.log('e')
-				console.log(e)
-				
 				var ua = window.navigator.userAgent.toLowerCase();
 				if(ua.match(/MicroMessenger/i) == 'micromessenger'){
-					alert('点击右上角 ┇,选择默认浏览器进行导出操作')
+					uni.showModal({
+						showCancel: false,
+						content: '点击右上角 ┇,选择默认浏览器进行导出操作'
+					});
 				}else{
 					if (this.checkedArr.length == 0) {
-						alert('请选择至少一条需要导出的数据')
+						uni.showModal({
+							showCancel: false,
+							content: '请选择至少一条需要导出的数据'
+						});
 					} else {
 						this.modalName = e.currentTarget.dataset.target;
-					
 					}
 				}
 				
 			},
+			
+			//导出事件
 			getDataExport() {
 				const base64 = s => window.btoa(unescape(encodeURIComponent(s)));
 				// let exportData = [];
@@ -328,8 +323,6 @@
 						install_time: item.install_time,
 					})
 				});
-				console.log('newData')
-				console.log(newData);
 				let str =
 					'<tr style="text-align:center"><th>单位编号</th><th>状态</th><th>设备编号</th><th>设备名称</th><th>单位地址</th><th>创建时间</th></tr>';
 				// 循环遍历,每行加入tr标签,每个单元格加td标签
@@ -363,8 +356,6 @@
 				link.download = "设备注册管理数据表.xls";
 				link.click();
 			},
-			
-			
 			//导出按钮另存为
 			saveAsData(e){
 				this.modalName = null
@@ -372,23 +363,21 @@
 			},
 
 			//关闭弹框
-			
 			hideModal(e) {
 				this.modalName = null
 			},
 
 			//删除弹出框操作
 			deleteItem(e) {
-
-				// uni.showModal({
-				// 	showCancel: false,
-				// 	content: '暂不支持删除功能'
-				// });
-				if (this.checkedArr.length == 0) {
-					alert('请选择至少一条需要删除的数据')
-				} else {
-					this.modalName = e.currentTarget.dataset.target;
-				}
+				uni.showModal({
+					showCancel: false,
+					content: '暂不支持删除功能'
+				});
+				// if (this.checkedArr.length == 0) {
+				// 	alert('请选择至少一条需要删除的数据')
+				// } else {
+				// 	this.modalName = e.currentTarget.dataset.target;
+				// }
 			},
 			deleteItem2(e) {
 				this.checkedArr.push(e.target.dataset.id);
@@ -403,42 +392,12 @@
 				console.log(this.deviceManage)
 				this.modalName = null
 			},
-			//再次确认弹框
+			//再次确认删除弹框
 			openConfirmModal(e) {
 				this.modalName = e.currentTarget.dataset.target;
 			},
 
 
-			// 隐藏显示
-			showDetail(e) {
-
-				console.log(this.deviceManage)
-				// console.log('e')
-				// console.log(e)
-				// 存储点击那一项的状态
-				const nowStatu = e.isShow;
-
-				//判断如果长摁弹框出来时,情况选中状态 ???
-				if (!nowStatu) {
-					this.checkedArr = [];
-					this.allChecked = false;
-				}
-				// 将每一项列表的isShow设置为false,让所有的列表都隐藏
-				this.deviceManage.forEach(item => {
-					item.isShow = false
-				})
-				// 用于再次点击该项的取反
-				e.isShow = !nowStatu
-			},
-
-
-			InputFocus(e) {
-				this.InputBottom = e.detail.height
-			},
-			InputBlur(e) {
-				this.InputBottom = 0
-			},
-
 			// 多选复选框改变事件
 			changeCheckbox(e) {
 				this.checkedArr = e.detail.value;
@@ -466,7 +425,8 @@
 					this.allChecked = false;
 					this.checkedArr = [];
 				}
-			}
+			},
+
 		},
 
 	}

+ 30 - 18
pages/index/index.vue

@@ -59,7 +59,7 @@
 			</view>
 		</view>
 		<!-- 图表 end-->
-		
+
 
 		<!-- 宫格列表 -->
 		<view class="section2 section  bg-white margin-top-sm margin-bottom-sm">
@@ -75,7 +75,7 @@
 			</view>
 		</view>
 		<!-- 宫格列表 end -->
-		
+
 	</view>
 </template>
 
@@ -121,10 +121,14 @@
 		// 自定义导航事件
 		onNavigationBarButtonTap(e) {
 			if (e.float == 'right') {
-				console.log("你点击了扫一扫");
+				alert("你点击了扫一扫");
 				this.scanQRCode();
 			} else {
-				this.showTag()
+				alert("你点击了获取位置");
+				this.getLocation()
+
+
+				// this.showTag()
 			}
 		},
 
@@ -154,35 +158,43 @@
 		},
 		methods: {
 
-			//新增
+			//扫码
 			scanQRCode() {
 				alert(1)
 				// 将this赋值给that
 				let that = this;
 				// 微信公众号获取位置
 				jwx.configWeiXin(jweixin => {
-					alert(2)
-
+					alert(11)
 					wx.scanQRCode({
 						needResult: 1, // 默认为0,扫描结果由微信处理,1则直接返回扫描结果,
 						scanType: ["qrCode", "barCode"], // 可以指定扫二维码还是一维码,默认二者都有
 						success: function(res) {
 							var result = res.resultStr; // 当needResult 为 1 时,扫码返回的结果
-							console.log(result);
+							alert(result);
 						}
 					});
 
-					// jwx.configWeiXin(jweixin => {
-					// 	wx.getLocation({
-					// 	  type: 'gcj02', // 默认为wgs84的gps坐标,如果要返回直接给openLocation用的火星坐标,可传入'gcj02'
-					// 	  success: function (res) {
-					// 		  alert(3)
-					// 		that.longitude=res.longitude
-					// 		that.latitude=res.latitude
-					// 	  }
-					// 	});
-					// });
 				});
+			},
+
+			//获取地理位置
+			getLocation() {
+				alert(2)
+				// 将this赋值给that
+				let that = this;
+				// 微信公众号获取位置
+
+				jwx.configWeiXin(jweixin => {
+					alert(22)
+					wx.getLocation({
+						type: 'gcj02', // 默认为wgs84的gps坐标,如果要返回直接给openLocation用的火星坐标,可传入'gcj02'
+						success: function(res) {
+							alert(res.longitude)
+						}
+					});
+				});
+
 
 
 			},

+ 3 - 3
util/jssdk.js

@@ -19,8 +19,8 @@ export function configWeiXin(callback) {
 		},
 		method: 'GET',
 		success: (res) => {
-			console.log('请求的签名的参数')
-			console.log(res)
+			// console.log('请求的签名的参数')
+			// console.log(res)
 
 			let apiList = [ // 可能需要用到的能力 需要啥就写啥。多写也没有坏处
 				'openLocation',
@@ -43,7 +43,7 @@ export function configWeiXin(callback) {
 			});
 
 			jweixin.ready(res => {
-				// if (callback) callback(jweixin);
+				if (callback) callback(jweixin);
 			});
 		}
 	});