开关支付
This commit is contained in:
		
							parent
							
								
									dd66d10bdb
								
							
						
					
					
						commit
						a746f55b27
					
				|  | @ -19,7 +19,7 @@ const install = (Vue, vm) => { | |||
| 	// 	},
 | ||||
| 	// }); 
 | ||||
| 	Vue.prototype.$u.http.setConfig({  | ||||
| 			// baseUrl: 'http://192.168.2.223:10002',
 | ||||
| 			// baseUrl: 'http://192.168.2.81:10002',
 | ||||
| 			baseUrl: 'https://kg.chuangtewl.com/prod-api', | ||||
| 			// loadingText: '努力加载中~',
 | ||||
| 			// loadingTime: 1000,
 | ||||
|  |  | |||
|  | @ -361,7 +361,11 @@ | |||
| 				// } | ||||
| 			}, | ||||
| 			btnljzf(){ | ||||
|                   this.$u.get(`/app/pay/wx/${this.orderno}`).then((res) => { | ||||
| 				let data = { | ||||
| 					billNo:this.orderno, | ||||
| 					channelId:5 | ||||
| 				} | ||||
|                   this.$u.put(`/app/bill/pay`,data).then((res) => { | ||||
|                   	if (res.code == 200) { | ||||
|                   		let that = this | ||||
|                   		uni.requestPayment({ | ||||
|  | @ -372,9 +376,7 @@ | |||
|                   			signType: res.data.payParams.signType, | ||||
|                   			paySign: res.data.payParams.paySign, | ||||
|                   			success: (res) => { | ||||
|                   				that.$u.put( | ||||
|                   					`/app/bill/${that.orderno}/refreshPayResult` | ||||
|                   					).then(res => {}) | ||||
|                   				that.$u.put(`/app/bill/${that.orderno}/refreshPayResult`).then(res => {}) | ||||
|                   				// 支付成功逻辑 | ||||
|                   				uni.showToast({ | ||||
|                   					title: res.msg, | ||||
|  | @ -386,7 +388,7 @@ | |||
|                   					uni.reLaunch({ | ||||
|                   						url: '/pages/shouye/index' | ||||
|                   					}) | ||||
|                   				}, 1500) | ||||
|                   				}, 2000) | ||||
|                   			}, | ||||
|                   			fail(err) { | ||||
|                   				that.jieshuflag = false | ||||
|  | @ -465,7 +467,11 @@ | |||
| 				   		}) | ||||
| 				   	} else { | ||||
| 				   		if (this.detaobj.status == 1) { | ||||
| 				   			this.$u.get(`/app/pay/wx/${this.orderno}`).then((res) => { | ||||
| 				   			let data = { | ||||
| 				   				billNo:this.orderno, | ||||
| 				   				channelId:5 | ||||
| 				   			} | ||||
| 				   			  this.$u.put(`/app/bill/pay`,data).then.then((res) => { | ||||
| 				   				if (res.code == 200) { | ||||
| 				   					let that = this | ||||
| 				   					uni.requestPayment({ | ||||
|  | @ -510,7 +516,11 @@ | |||
| 				   			} | ||||
| 				   			this.$u.put(`/app/bill/endUse`, data).then(res => { | ||||
| 				   				if (res.code == 200) { | ||||
| 				   					this.$u.get(`/app/pay/wx/${this.orderno}`).then((res) => { | ||||
| 				   					let data = { | ||||
| 				   						billNo:this.orderno, | ||||
| 				   						channelId:5 | ||||
| 				   					} | ||||
| 				   					  this.$u.put(`/app/bill/pay`,data).then.then((res) => { | ||||
| 				   						if (res.code == 200) { | ||||
| 				   							let that = this | ||||
| 				   							uni.requestPayment({ | ||||
|  | @ -521,9 +531,7 @@ | |||
| 				   								signType: res.data.payParams.signType, | ||||
| 				   								paySign: res.data.payParams.paySign, | ||||
| 				   								success: (res) => { | ||||
| 				   									that.$u.put( | ||||
| 				   										`/app/bill/${that.orderno}/refreshPayResult` | ||||
| 				   										).then(res => {}) | ||||
| 				   									that.$u.put(`/app/bill/${that.orderno}/refreshPayResult`).then(res => {}) | ||||
| 				   									// 支付成功逻辑 | ||||
| 				   									uni.showToast({ | ||||
| 				   										title: res.msg, | ||||
|  | @ -652,12 +660,15 @@ | |||
| 				   									success(res) {  | ||||
| 				   										setTimeout(()=> { | ||||
| 				   											xBlufi.notifySendCustomData({ | ||||
| 				   													customData: 'close' | ||||
| 				   													customData: 'close'  | ||||
| 				   												}) | ||||
| 				   												setTimeout(() => { | ||||
| 				   													that.$u.get(`/app/pay/wx/${that.orderno}`).then((res) => { | ||||
| 				   													let data = { | ||||
| 				   														billNo:that.orderno, | ||||
| 				   														channelId:5 | ||||
| 				   													} | ||||
| 				   													  that.$u.put(`/app/bill/pay`,data).then.then((res) => { | ||||
| 				   														if (res.code == 200) { | ||||
| 				   														 | ||||
| 				   															uni.requestPayment({ | ||||
| 				   																provider: 'wxpay', | ||||
| 				   																timeStamp: res.data.payParams.timeStamp, | ||||
|  |  | |||
|  | @ -21,10 +21,10 @@ | |||
| 		<!-- 检测蓝牙未开启 --> | ||||
| 		<view class="shibai" v-if="lanyaflag"> | ||||
| 			<view class="top"> | ||||
| 				设备未联网 | ||||
| 				设备离线 | ||||
| 			</view> | ||||
| 			<view class="tishi"> | ||||
| 				检测到该设备未联网,请打开蓝牙进行蓝牙模式 | ||||
| 				检测到该设备离线,请打开蓝牙进行蓝牙模式 | ||||
| 			</view> | ||||
| 			<view class="li"> | ||||
| 				<view class="wz"> | ||||
|  | @ -110,17 +110,6 @@ | |||
| 				</view> | ||||
| 			</view> | ||||
| 
 | ||||
| <!-- 			<view class="shuom" v-for="(item,index) in deviceobj.suitList" :key="index" | ||||
| 				v-if="indexactive == item.suitId"> | ||||
| 				<view class="tits" style="margin-top: 10rpx;"> | ||||
| 					套餐说明 | ||||
| 				</view> | ||||
| 				<view class="" style="margin-top: 30rpx;"> | ||||
| 					<textarea :readonly="isReadOnly" v-model="item.description == null ? '无' : item.description" | ||||
| 						id="myTextarea" cols="30" rows="10" style="pointer-events: none;"></textarea> | ||||
| 				</view> | ||||
| 			</view> --> | ||||
| 
 | ||||
| 			<view class="tongyi" v-if="deviceobj.suitList != null"> | ||||
| 				<u-checkbox-group> | ||||
| 					<u-checkbox v-model="checked" @change="checkboxChange" active-color="#8883F0 ">我已同意 | ||||
|  | @ -277,26 +266,6 @@ | |||
| 									if (res.code == 200) { | ||||
| 										that.mac = 'CTKG-' + res.data.mac | ||||
| 										that.onlineStatus = res.data.onlineStatus | ||||
| 										// if (that.onlineStatus == 0) { | ||||
| 										// 	// 一开始搜索设备 | ||||
| 										// 	xBlufi.initXBlufi(1) | ||||
| 										// 	xBlufi.listenDeviceMsgEvent(true, that.funListenDeviceMsgEvent); | ||||
| 										// 	xBlufi.notifyStartDiscoverBle({ | ||||
| 										// 		'isStart': true | ||||
| 										// 	}) | ||||
| 										// 	setTimeout(() => { | ||||
| 										// 		xBlufi.notifyStartDiscoverBle({ | ||||
| 										// 			'isStart': false | ||||
| 										// 		}) | ||||
| 										// 		if (that.devicesList.length > 0) { | ||||
| 										// 			xBlufi.notifyConnectBle({ | ||||
| 										// 				isStart: true, | ||||
| 										// 				deviceId: that.deviceId, | ||||
| 										// 				name: that.name | ||||
| 										// 			}) | ||||
| 										// 		} | ||||
| 										// 	}, 2000) | ||||
| 										// } | ||||
| 									} | ||||
| 								}) | ||||
| 							}  | ||||
|  | @ -305,45 +274,10 @@ | |||
| 						uni.navigateTo({ | ||||
| 							url:'/pages/shouye/index?id=' + this.id | ||||
| 						}) | ||||
| 						// console.log(111); | ||||
| 						// uni.showModal({  | ||||
| 						// 	title: '提示', | ||||
| 						// 	content: '该设备未绑定,你需进行绑定吗?', | ||||
| 						// 	success: function(res) { | ||||
| 						// 		if (res.confirm) { | ||||
| 						// 			that.$u.put("/app/device/bind", data).then(res => { | ||||
| 						// 				if(res.code == 200){ | ||||
| 						// 					that.$u.get(`/app/device/${that.id}/bySn`).then((res) => { | ||||
| 						// 						if (res.code == 200) { | ||||
| 						// 							uni.navigateTo({ | ||||
| 						// 								url: '/page_components/bindsz?id=' + res.data.deviceId | ||||
| 						// 							}) | ||||
| 						// 						}  | ||||
| 						// 					}) | ||||
| 						// 				} | ||||
| 						// 			}) | ||||
| 						// 		} else if (res.cancel) { | ||||
| 									   | ||||
| 						// 		} | ||||
| 						// 	} | ||||
| 						// }) | ||||
| 					} else if (res.data == 0) { | ||||
| 						uni.navigateTo({ | ||||
| 							url:'/pages/shouye/index?id=' + this.id | ||||
| 						}) | ||||
| 						// uni.showModal({ | ||||
| 						// 	title: '提示', | ||||
| 						// 	content: '该设备未录入,你需进行录入吗?', | ||||
| 						// 	success: function(res) { | ||||
| 						// 		if (res.confirm) { | ||||
| 						// 			uni.navigateTo({ | ||||
| 						// 				url: '/page_fenbao/zhuce?sn=' + that.id | ||||
| 						// 			}) | ||||
| 						// 		} else if (res.cancel) { | ||||
| 									   | ||||
| 						// 		} | ||||
| 						// 	} | ||||
| 						// }) | ||||
| 					} | ||||
| 				}) | ||||
| 				this.gettaoc() | ||||
|  | @ -510,7 +444,7 @@ | |||
| 							if(this.suitFeeType == 3 || this.suitFeeType == 4){ | ||||
| 								let data = { | ||||
| 									billNo:that.orderno, | ||||
| 									channelId:1 | ||||
| 									channelId:5 | ||||
| 								} | ||||
| 								that.$u.put(`/app/bill/payDeposit`,data).then(res => { | ||||
| 									if(res.code == 200){ | ||||
|  | @ -552,7 +486,11 @@ | |||
| 									} | ||||
| 								}) | ||||
| 							}else{ | ||||
| 								that.$u.get(`/app/pay/wx/${that.orderno}`).then((res) => { | ||||
| 								let data = { | ||||
| 									billNo:that.orderno, | ||||
| 									channelId:5 | ||||
| 								} | ||||
| 								that.$u.put(`/app/bill/pay/`,data).then((res) => { | ||||
| 									if (res.code == 200) { | ||||
| 											uni.requestPayment({ | ||||
| 												provider: 'wxpay', | ||||
|  | @ -665,7 +603,7 @@ | |||
| 								if(this.suitFeeType == 3 || this.suitFeeType == 4){ | ||||
| 									let data = { | ||||
| 										billNo:that.orderno, | ||||
| 										channelId:1 | ||||
| 										channelId:5 | ||||
| 									} | ||||
| 									that.$u.put(`/app/bill/payDeposit`,data).then((res) => { | ||||
| 										if (res.code == 200) { | ||||
|  | @ -792,7 +730,11 @@ | |||
| 									// 支付成功逻辑 | ||||
| 									// uni.setStorageSync('time', that.expireTimeStr) | ||||
| 								}else{ | ||||
| 									that.$u.get(`/app/pay/wx/${that.orderno}`).then((res) => { | ||||
| 								let data = { | ||||
| 									billNo:that.orderno, | ||||
| 									channelId:5 | ||||
| 								} | ||||
| 								that.$u.put(`/app/bill/pay/`,data).then((res) => { | ||||
| 										if (res.code == 200) { | ||||
| 												uni.requestPayment({ | ||||
| 													provider: 'wxpay', | ||||
|  | @ -977,11 +919,11 @@ | |||
| 						setTimeout(()=>{ | ||||
| 							this.czflag = false | ||||
| 							uni.hideLoading() | ||||
| 							uni.showToast({ | ||||
| 								title: '切换成功,请点击支付', | ||||
| 								icon: 'none', | ||||
| 								duration: 2000 | ||||
| 							}) | ||||
| 							// uni.showToast({ | ||||
| 							// 	title: '切换成功,请点击支付', | ||||
| 							// 	icon: 'none', | ||||
| 							// 	duration: 2000 | ||||
| 							// }) | ||||
| 						},1000) | ||||
| 						break; | ||||
| 					case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS_STOP: | ||||
|  |  | |||
|  | @ -68,11 +68,23 @@ | |||
| 					<text class="shen">套餐金额</text><text class="qian">{{detailobj.money == undefined ? '--' : detailobj.money}}</text> | ||||
| 				</view> | ||||
| 				<view class="nav"> | ||||
| 					<text class="shen">计时模式</text><text class="qian">{{detailobj.suitFeeMode == 1 ? '单次计时' : '智能计时'}}</text> | ||||
| 				</view> | ||||
| 				<view class="nav"> | ||||
| 					<text class="shen">收费模式</text><text class="qian"> | ||||
| 					<text v-if="detailobj.suitFeeType == 1">计时收费</text> | ||||
| 					<text v-if="detailobj.suitFeeType == 2">按量收费</text> | ||||
| 					<text v-if="detailobj.suitFeeType == 3">分时段按量收费</text> | ||||
| 					<text v-if="detailobj.suitFeeType == 4">分时段计时收费</text></text> | ||||
| 				</view> | ||||
| 				<view class="nav" v-if="detailobj.suitFeeType == 2 || detailobj.suitFeeType == 3"> | ||||
| 					<text class="shen">使用度数</text><text class="qian">{{Number(detailobj.suitEndEle) - Number(detailobj.suitStartEle)}}度</text> | ||||
| 				</view> | ||||
| 				<view class="nav" v-else> | ||||
| 					<text class="shen">套餐时长</text><text class="qian">{{detailobj.suitTime == undefined ? '--' : detailobj.suitTime}}  | ||||
| 					<text v-if="detailobj.suitTimeUnit == 1">天</text>  <text v-if="detailobj.suitTimeUnit == 2">时</text> <text v-if="detailobj.suitTimeUnit == 3">分钟</text> <text v-if="detailobj.suitTimeUnit == 4">秒</text> | ||||
| 					</text> | ||||
| 				</view> | ||||
| 				 | ||||
| 				<view class="xian"></view> | ||||
| 				<view class="nav"> | ||||
| 					<text class="shen">共计</text><text class="qian">¥{{detailobj.money == undefined ? '--' : detailobj.money}}</text> | ||||
|  | @ -379,7 +391,7 @@ | |||
| 			} | ||||
| 			.listxq{ | ||||
| 				width: 680rpx; | ||||
| 				height: 1068rpx;  | ||||
| 				height: 1200rpx;  | ||||
| 				background: #FFFFFF; | ||||
| 				border-radius: 20rpx 20rpx 20rpx 20rpx; | ||||
| 				margin: auto; | ||||
|  |  | |||
|  | @ -8,10 +8,13 @@ | |||
| 					单次收费为一次性收取费用,不退款! | ||||
| 				</view> | ||||
| 				<view class=""> | ||||
| 					智能收费为按用时和用量智能动态计费,用户提前 结束、异常结束、商家关闭订单等操作都将动态智 能计算费用 | ||||
| 					智能收费为按用时和用量智能动态计费,用户提前结束、异常结束、商家关闭订单等操作都将动态智能计算费用 | ||||
| 				</view> | ||||
| 				<view class=""> | ||||
| 					例如:1小时2元的收费模式,用户用半小时提前 结束订单,实际消费为1元,多收费用将退回原支 付账户! | ||||
| 					例如:1小时2元的收费模式,用户用半小时提前结束订单,实际消费为1元,多收费用将退回原支付账户! | ||||
| 				</view> | ||||
| 				<view class=""> | ||||
| 					提示:当套餐的金额低于5元手续费都按0.05元收取! | ||||
| 				</view> | ||||
| 			</view> | ||||
| 			<view class="tcname"> | ||||
|  | @ -299,8 +302,7 @@ | |||
| 			</view> | ||||
| 		</view> | ||||
| 
 | ||||
| 		<view v-if="btnmsk" | ||||
| 			style="width: 100%;height: 100vh;position: fixed;top: 0;left: 0;background-color: #000;opacity: .1;z-index: 999;"> | ||||
| 		<view v-if="btnmsk" style="width: 100%;height: 100vh;position: fixed;top: 0;left: 0;background-color: #000;opacity: .1;z-index: 999;"> | ||||
| 		</view> | ||||
| 
 | ||||
| 	</view> | ||||
|  | @ -414,7 +416,7 @@ | |||
| 		}, | ||||
| 		onLoad(option) { | ||||
| 			if (option.suitId) { | ||||
| 				this.deviceId = option.id | ||||
| 				this.deviceId = option.id	 | ||||
| 				this.title = '修改' | ||||
| 				this.suitId = option.suitId | ||||
| 			} else { | ||||
|  | @ -549,10 +551,6 @@ | |||
| 			}, | ||||
| 			// 收费时间  收费时间  收费时间  收费时间 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 			// 点击删除套餐里面的设备 | ||||
| 			sbdel(id) { | ||||
| 				if (this.title == '确定') { | ||||
|  | @ -1209,7 +1207,7 @@ | |||
| 
 | ||||
| 			.titwz { | ||||
| 				width: 654rpx; | ||||
| 				height: 344rpx; | ||||
| 				height: 450rpx; | ||||
| 				background: #F0EFFF; | ||||
| 				box-shadow: 0rpx 0rpx 8rpx 0rpx rgba(0, 0, 0, 0.15); | ||||
| 				padding: 16rpx 28rpx; | ||||
|  |  | |||
|  | @ -251,15 +251,14 @@ | |||
| 
 | ||||
| 			btnedit(item) { | ||||
| 				uni.navigateTo({ | ||||
| 					url: '/page_fenbao/statulist/taocanlist/addtaocan/index?id=' + this.deviceId + '&suitId=' + | ||||
| 						item.suitId | ||||
| 					url: '/page_fenbao/statulist/taocanlist/addtaocan/index?id=' + this.deviceId + '&suitId=' + item.suitId | ||||
| 				}) | ||||
| 			}, | ||||
| 
 | ||||
| 			click(item) { | ||||
| 				this.$u.delete(`/app/suit/${item.suitId}`).then((res) => { | ||||
| 					if (res.code == 200) { | ||||
| 						this.$u.toast(`删除成功`); | ||||
| 						this.$u.toast(`删除成功`) | ||||
| 						this.getlist() | ||||
| 					} else { | ||||
| 						uni.showToast({ | ||||
|  | @ -268,8 +267,7 @@ | |||
| 							duration: 1000, | ||||
| 						}) | ||||
| 					} | ||||
| 				}); | ||||
| 
 | ||||
| 				}) | ||||
| 			}, | ||||
| 			open(index) { | ||||
| 				this.list[index].show = true | ||||
|  |  | |||
|  | @ -4,18 +4,17 @@ | |||
| 			back-icon-color="#fff" height='50'></u-navbar> | ||||
| 		<view class="title"> | ||||
| 			<text>设备录入列表</text> | ||||
| 			<!-- 			<image src="https://api.ccttiot.com/smartmeter/img/static/uCfe9273aC89tGOT7n1G" mode="widthFix"></image> | ||||
| 			<text class="sm"> {{texts}} </text --> | ||||
| 		</view> | ||||
| 
 | ||||
|          <view class="dblist" v-for="(item, index) in devicesLists" :key="index"> | ||||
| 		<!-- <view class="dblist"> --> | ||||
| 			<view class="lt"> | ||||
| 				<image src="https://api.ccttiot.com/smartmeter/img/static/uGVs6cbSjcuQNXuHhoWi" mode="aspectFit"></image> | ||||
| 			</view> | ||||
| 		<view class="dblist" v-for="(item, index) in devicesLists" :key="index"> | ||||
| 			<view class="cen"> | ||||
| 				<view class="name"> | ||||
| 					智能开关录入 | ||||
| 				    <view class=""> | ||||
| 				    	状态:<text v-if="item.flags == true" style="color: red;">已录入</text> <text v-else style="color:seagreen;">未录入</text> | ||||
| 				    </view> | ||||
| 					<view class="" style="display: flex;"> | ||||
| 						SN码: <input style="width: 200rpx;background-color: #ccc;padding: 5rpx;box-sizing: border-box;text-align: center;" v-model="item.sn" placeholder="输入SN"/> | ||||
| 					</view> | ||||
| 				</view> | ||||
| 				<view class="mac"> | ||||
| 					MAC:{{item.name.substring(5)}} | ||||
|  | @ -23,12 +22,14 @@ | |||
| 				<view class="" style="color: #8883F0;margin-top: 10rpx;margin-bottom: 10rpx;text-align: left;"> | ||||
| 					蓝牙强度:{{item.RSSI}} | ||||
| 				</view> | ||||
| 				<view @click="btnshows(item,index)" style="color: #8883F0;margin-top: 10rpx;margin-bottom: 10rpx;text-align: left;"> | ||||
| 				<view @click="btnshows(item,index)" | ||||
| 					style="color: #8883F0;margin-top: 10rpx;margin-bottom: 10rpx;text-align: left;"> | ||||
| 					型号选择:{{item.xuanz == undefined ? '--' : item.xuanz}} | ||||
| 				</view> | ||||
| 			</view> | ||||
| 			<view class="rt"> | ||||
| 				<!-- <text style="margin-bottom: 10rpx;" :id="item.deviceId" @tap="createBLEConnections(item)">响铃</text> --> | ||||
| 				<!-- <text style="margin-bottom: 10rpx;" :id="item.deviceId" @tap="createBLEConnections(item)">扫码</text> --> | ||||
| 				<text  @click="scanQRCode(item)" style="margin-bottom: 10rpx;">扫码</text> | ||||
| 				<text :id="item.deviceId" @click="createBLEConnection(item)">录入</text> | ||||
| 			</view> | ||||
| 		</view> | ||||
|  | @ -47,16 +48,12 @@ | |||
| 			<text>3.确保设备未被添加过。</text> | ||||
| 			<button @click="btnyc">好的</button> | ||||
| 		</view> | ||||
|          | ||||
| 		<view v-if="mengcflag" class="mengc" style="width: 100%;height: 100vh;background-color: #000;opacity: .5;position: fixed;top: 0;left: 0;"></view> | ||||
| 		 | ||||
| 
 | ||||
| 		<view v-if="mengcflag" class="mengc" | ||||
| 			style="width: 100%;height: 100vh;background-color: #000;opacity: .5;position: fixed;top: 0;left: 0;"></view> | ||||
| 
 | ||||
| 		<!-- 选择蓝牙型号 --> | ||||
| 		<u-select v-model="shows" :list="arr" @confirm="confirm"></u-select> | ||||
| 		<!-- 	<view class="containers" v-show="statusflag"> | ||||
| 			<uni-section> | ||||
| 				<uni-load-more :status="status" /> | ||||
| 			</uni-section> | ||||
| 		</view> --> | ||||
| 	</view> | ||||
| </template> | ||||
| 
 | ||||
|  | @ -67,7 +64,7 @@ | |||
| 	export default { | ||||
| 		data() { | ||||
| 			return { | ||||
| 				mengcflag:false, | ||||
| 				mengcflag: false, | ||||
| 				titleflag: false, //提示隐藏 | ||||
| 				bgc: { | ||||
| 					backgroundColor: "#F7FAFE", | ||||
|  | @ -94,10 +91,14 @@ | |||
| 					backgroundColor: "#8883f0", | ||||
| 				}, | ||||
| 				lurulist: [], | ||||
|                 arr:[], | ||||
| 				shows:false, | ||||
| 				arrname:'', | ||||
| 				valuexh:'' | ||||
| 				arr: [], | ||||
| 				shows: false, | ||||
| 				arrname: '', | ||||
| 				valuexh: '', | ||||
| 				deviceId: '', | ||||
| 				arrs: [], | ||||
| 				sn:'输入SN', | ||||
| 				snname:'' | ||||
| 			} | ||||
| 		}, | ||||
| 		onLoad(option) { | ||||
|  | @ -106,58 +107,96 @@ | |||
| 			this.getxingh() | ||||
| 			this.storeId = option.sn | ||||
| 		}, | ||||
| 
 | ||||
| 		onUnload: function() { | ||||
| 			console.log("unload "); | ||||
| 			xBlufi.listenDeviceMsgEvent(false, this.funListenDeviceMsgEvent); | ||||
| 			wx.closeBLEConnection({ | ||||
| 				deviceId: this.deviceId, | ||||
| 			}) | ||||
| 		}, | ||||
| 		// 分享到好友(会话) | ||||
| 		  onShareAppMessage: function () {   | ||||
| 		    return {   | ||||
| 		      title: '创想物联',   | ||||
| 		      path: '/pages/shouye/index'   | ||||
| 		    }   | ||||
| 		  },   | ||||
| 		   | ||||
| 		  // 分享到朋友圈   | ||||
| 		  onShareTimeline: function () {   | ||||
| 		    return {   | ||||
| 		      title: '创想物联',   | ||||
| 		      query: '',   | ||||
| 		      path: '/pages/shouye/index'   | ||||
| 		    }   | ||||
| 		  }, | ||||
| 		onShareAppMessage: function() { | ||||
| 			return { | ||||
| 				title: '创想物联', | ||||
| 				path: '/pages/shouye/index' | ||||
| 			} | ||||
| 		}, | ||||
| 
 | ||||
| 		// 分享到朋友圈   | ||||
| 		onShareTimeline: function() { | ||||
| 			return { | ||||
| 				title: '创想物联', | ||||
| 				query: '', | ||||
| 				path: '/pages/shouye/index' | ||||
| 			} | ||||
| 		}, | ||||
| 		mounted() { | ||||
| 			// this.videoContext = uni.createVideoContext('myVideo', this) | ||||
| 		}, | ||||
| 		methods: { | ||||
| 			getxingh(){ | ||||
| 			// 扫码sn | ||||
| 			scanQRCode(item){ | ||||
| 				this.snname = item.name | ||||
| 				uni.scanCode({ | ||||
| 					onlyFromCamera: true, | ||||
| 					scanType: ['qrCode'], | ||||
| 					success: res => { | ||||
| 						function getQueryParam(url, paramName) { | ||||
| 							let regex = new RegExp(`[?&]${paramName}=([^&]*)`) | ||||
| 							let results = regex.exec(url); | ||||
| 							return results ? decodeURIComponent(results[1].replace(/\+/g, ' ')) : null | ||||
| 						} | ||||
| 						let sceneValue = res.result | ||||
| 						let decodedValue = decodeURIComponent(sceneValue) | ||||
| 						let id = getQueryParam(decodedValue, 's') | ||||
|                         this.storeId = id | ||||
| 						this.devicesLists.forEach(item => { | ||||
| 							if (item.name == this.snname) { | ||||
| 								item.sn = id | ||||
| 							} | ||||
| 						}) | ||||
| 					}, | ||||
| 					fail: err => { | ||||
| 						console.error('扫描失败:', err) | ||||
| 						uni.showToast({ | ||||
| 							title: '扫描失败', | ||||
| 							icon: 'none' | ||||
| 						}) | ||||
| 					} | ||||
| 				}) | ||||
| 			},  | ||||
| 			 | ||||
| 			getxingh() { | ||||
| 				this.$u.get(`/app/model/all`).then(res => { | ||||
| 					if(res.code == 200){ | ||||
| 					if (res.code == 200) { | ||||
| 						this.arr = res.data | ||||
| 					this.arr.forEach(item => {   | ||||
| 					    if (item.hasOwnProperty('modelId')) {   | ||||
| 					        item.value = item.modelId;   | ||||
| 					    }   | ||||
| 					    if (item.hasOwnProperty('modelName')) {   | ||||
| 					        item.label = item.modelName;   | ||||
| 					    }   | ||||
| 					}) | ||||
| 					console.log(this.arr,'2121212') | ||||
| 						this.arr.forEach(item => { | ||||
| 							if (item.hasOwnProperty('modelId')) { | ||||
| 								item.value = item.modelId; | ||||
| 							} | ||||
| 							if (item.hasOwnProperty('modelName')) { | ||||
| 								item.label = item.modelName; | ||||
| 							} | ||||
| 						}) | ||||
| 						console.log(this.arr, '2121212') | ||||
| 					} | ||||
| 				}) | ||||
| 			}, | ||||
| 			btnshows(item,index){ | ||||
| 			btnshows(item, index) { | ||||
| 				this.arrname = item.name | ||||
| 				this.shows = true | ||||
| 			}, | ||||
| 			// 选择型号 | ||||
| 			confirm(e){ | ||||
| 			confirm(e) { | ||||
| 				this.devicesLists.forEach(item => { | ||||
| 					if(item.name == this.arrname){ | ||||
| 					if (item.name == this.arrname) { | ||||
| 						item.xuanz = e[0].label | ||||
| 						this.valuexh = e[0].value | ||||
| 					} | ||||
| 				}) | ||||
| 			}, | ||||
| 			 | ||||
| 			 | ||||
| 
 | ||||
| 
 | ||||
| 			btnyc() { | ||||
| 				this.titleflag = false | ||||
| 			}, | ||||
|  | @ -166,8 +205,6 @@ | |||
| 					case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS: | ||||
| 						if (options.result) { | ||||
| 							this.devicesList = options.data | ||||
| 							// let devicesarr = options.data | ||||
| 							console.log(options.data,100100); | ||||
| 						} | ||||
| 						break; | ||||
| 
 | ||||
|  | @ -184,6 +221,8 @@ | |||
| 
 | ||||
| 					case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS_START: | ||||
| 						if (!options.result) { | ||||
| 							this.mengcflag = false | ||||
| 							uni.hideLoading() | ||||
| 							console.log("蓝牙未开启", options); | ||||
| 							uni.showToast({ | ||||
| 								title: '蓝牙未开启,请打开手机蓝牙', | ||||
|  | @ -192,7 +231,7 @@ | |||
| 							}); | ||||
| 						} else { | ||||
| 							this.searching = true | ||||
| 							 | ||||
| 
 | ||||
| 						} | ||||
| 
 | ||||
| 						break; | ||||
|  | @ -200,32 +239,59 @@ | |||
| 					case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS_STOP: | ||||
| 						if (options.result) { | ||||
| 							let uniqueDevicesList = Array.from(new Set(this.devicesList)); | ||||
| 							this.devicesLists = uniqueDevicesList.map(device => {   | ||||
| 							    const deviceId = device.name.substring(5);   | ||||
| 							    const newDevice = { ...device, xuanz: "请选择" }; // 直接在复制时添加 xuanz 字段   | ||||
| 							    return newDevice;   | ||||
| 							this.devicesLists = uniqueDevicesList.map(device => { | ||||
| 								const deviceId = device.name.substring(5); | ||||
| 								const newDevice = { | ||||
| 									...device, | ||||
| 									xuanz: "请选择", | ||||
| 								}; // 直接在复制时添加 xuanz 字段   | ||||
| 								return newDevice; | ||||
| 							}) | ||||
| 							let devicesarr = options.data | ||||
| 							 | ||||
| 
 | ||||
| 							this.devicesList.forEach(device => { | ||||
| 								if (device.name.substring(0, 4) == "CTKG" || device.name.substring(0, 4) == "CTPO") { | ||||
| 								if (device.name.substring(0, 4) == "CTKG" || device.name.substring(0, 4) == | ||||
| 									"CTPO") { | ||||
| 									this.devicesList.push(device); | ||||
| 									let uniqueDevicesList = Array.from(new Set(this.devicesList)); | ||||
| 									this.devicesLists = uniqueDevicesList.filter(device => { | ||||
| 										const deviceId = device.name.substring(5); | ||||
| 										return !this.lurulist.includes(deviceId); | ||||
| 										// return !this.lurulist.includes(deviceId); | ||||
| 										return deviceId | ||||
| 									}) | ||||
| 									// console.log(this.devicesLists); | ||||
| 								} | ||||
| 							}) | ||||
| 							// console.log(devicesarr,100100); | ||||
| 
 | ||||
| 							console.log('蓝牙停止搜索ok') | ||||
| 							// console.log('蓝牙停止搜索ok') | ||||
| 							console.log(this.devicesLists, '蓝牙停止'); | ||||
| 							this.mengcflag = false | ||||
| 							uni.hideLoading() | ||||
| 							if (this.devicesLists.length == 0) { | ||||
| 								this.titleflag = true | ||||
| 							} else { | ||||
| 								this.devicesLists.forEach(item => { | ||||
| 									this.arrs.push(item.name.slice(5)) | ||||
| 								}) | ||||
| 								this.arrs = this.arrs.join(',') | ||||
| 								this.$u.get(`/app/device/getExistMac/${this.arrs}`).then(res => { | ||||
| 									if (res.code == 200) { | ||||
| 										const existingDevices = new Set(res.data); // 将 res.data 转换为 Set,以提高查找效率   | ||||
| 										this.devicesLists = this.devicesLists.map(device => { | ||||
| 											const trimmedName = device.name.slice(5); // 假设前缀总是5个字符长   | ||||
| 											const flags = existingDevices.has(trimmedName); // true 如果存在,否则 false   | ||||
| 											return { | ||||
| 												...device, | ||||
| 												flags, // 直接使用 flags 变量   | ||||
| 												sn:'', | ||||
| 											} | ||||
| 										}) | ||||
| 									} | ||||
| 								}) | ||||
| 							} | ||||
| 						} else { | ||||
| 							//蓝牙停止搜索失败 | ||||
| 							this.mengcflag = false | ||||
| 							uni.hideLoading() | ||||
| 							console.log('蓝牙停止搜索失败'); | ||||
| 						} | ||||
| 						this.searching = false | ||||
|  | @ -256,29 +322,29 @@ | |||
| 			//         }, | ||||
| 			// 请求已经录入设备的mac | ||||
| 			getluru() { | ||||
| 				this.$u.get(`/app/device/listAllMac`).then(res => { | ||||
| 					if (res.code == 200) { | ||||
| 						this.lurulist = res.data | ||||
| 						if(this.lurulist){ | ||||
| 							xBlufi.initXBlufi(1); | ||||
| 							xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent); | ||||
| 							xBlufi.notifyStartDiscoverBle({ | ||||
| 								'isStart': true | ||||
| 							})  | ||||
| 							// 两秒后停止蓝牙搜索   | ||||
| 							setTimeout(() => { | ||||
| 								xBlufi.notifyStartDiscoverBle({ | ||||
| 									'isStart': false | ||||
| 								}); | ||||
| 								this.status = true | ||||
| 							}, 1000) | ||||
| 						} | ||||
| 					} | ||||
| 				// this.$u.get(`/app/device/listAllMac`).then(res => { | ||||
| 				// 	if (res.code == 200) { | ||||
| 				// this.lurulist = res.data | ||||
| 				// if(this.lurulist){ | ||||
| 				xBlufi.initXBlufi(1); | ||||
| 				xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent); | ||||
| 				xBlufi.notifyStartDiscoverBle({ | ||||
| 					'isStart': true | ||||
| 				}) | ||||
| 				// 两秒后停止蓝牙搜索   | ||||
| 				setTimeout(() => { | ||||
| 					xBlufi.notifyStartDiscoverBle({ | ||||
| 						'isStart': false | ||||
| 					}); | ||||
| 					this.status = true | ||||
| 				}, 1000) | ||||
| 				// } | ||||
| 				// } | ||||
| 				// }) | ||||
| 			}, | ||||
| 			//4、建立连接 | ||||
| 			createBLEConnection(e) { | ||||
| 				console.log(11); | ||||
| 				this.deviceId = e.name | ||||
| 				this.mengcflag = true | ||||
| 				uni.showLoading({ | ||||
| 					title: '录入中...' | ||||
|  | @ -288,23 +354,24 @@ | |||
| 				let data = { | ||||
| 					sn: this.storeId, | ||||
| 					mac: this.mac, | ||||
| 					modelId:this.valuexh | ||||
| 					modelId: this.valuexh | ||||
| 				} | ||||
| 				this.$u.post('/app/device', data).then((res) => { | ||||
| 					if (res.code == 200) { | ||||
| 						uni.showToast({ | ||||
| 							title: '设备:'+ this.mac +'已录入成功', | ||||
| 							title: '设备:' + this.mac + '已录入成功', | ||||
| 							icon: 'success', | ||||
| 							duration: 2000	 | ||||
| 						})  | ||||
| 							duration: 2000 | ||||
| 						}) | ||||
| 						this.mengcflag = false | ||||
| 						uni.hideLoading() | ||||
| 						setTimeout(()=>{ | ||||
| 							uni.navigateBack() | ||||
| 						},1000) | ||||
| 						this.Search() | ||||
| 						// setTimeout(() => { | ||||
| 						// 	uni.navigateBack() | ||||
| 						// }, 1000) | ||||
| 						uni.removeStorageSync('mac'); | ||||
| 					} else { | ||||
| 						this.mengcflag = false | ||||
| 						this.mengcflag = false  | ||||
| 						uni.hideLoading() | ||||
| 						uni.showToast({ | ||||
| 							title: res.msg, | ||||
|  | @ -318,6 +385,10 @@ | |||
| 			Search() { | ||||
| 				// console.log(1); | ||||
| 				// if (this.status) { | ||||
| 				this.mengcflag = true | ||||
| 				uni.showLoading({ | ||||
| 					title: '请稍后...' | ||||
| 				}) | ||||
| 				xBlufi.notifyStartDiscoverBle({ | ||||
| 					'isStart': true | ||||
| 				}); | ||||
|  | @ -325,6 +396,7 @@ | |||
| 				this.bluthlist = [] | ||||
| 				this.devicesList = [] | ||||
| 				this.devicesLists = [] | ||||
| 				this.arrs = [] | ||||
| 				// 重新搜索 | ||||
| 				// this.startBluetoothDevicesDiscovery() | ||||
| 				this.statusflag = true | ||||
|  | @ -423,11 +495,12 @@ | |||
| 
 | ||||
| 	.dblist { | ||||
| 		display: flex; | ||||
| 		justify-content: space-between; | ||||
| 		width: 100%; | ||||
| 		margin-top: 34rpx; | ||||
| 		background: #FFFFFF; | ||||
| 		box-shadow: 0rpx 10rpx 64rpx 0rpx rgba(0, 0, 0, 0.08); | ||||
| 		padding: 20rpx 0 24rpx 18rpx; | ||||
| 		padding: 20rpx 20rpx 24rpx 18rpx; | ||||
| 		box-sizing: border-box; | ||||
| 		text-align: center; | ||||
| 		border-radius: 10rpx; | ||||
|  | @ -475,10 +548,11 @@ | |||
| 
 | ||||
| 		.rt { | ||||
| 			margin-top: 32rpx; | ||||
|             padding-top: 50rpx; | ||||
| 			padding-top: 50rpx; | ||||
| 			box-sizing: border-box; | ||||
| 
 | ||||
| 			text { | ||||
| 				display: inline-block; | ||||
| 				display: block; | ||||
| 				width: 108rpx; | ||||
| 				height: 60rpx; | ||||
| 				background: rgba(255, 255, 255, 0); | ||||
|  |  | |||
|  | @ -1100,7 +1100,7 @@ | |||
| 					case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS: | ||||
| 						if (options.result) { | ||||
| 							let devicesarr = options.data | ||||
| 							// console.log(devicesarr,'devicesarrdevicesarr')  | ||||
| 							console.log(devicesarr,'devicesarrdevicesarr')  | ||||
| 							devicesarr.forEach(device => { | ||||
| 								const mac = device.name.substring(5) | ||||
| 								if (device.name.slice(5, 17) == this.qrResult) { | ||||
|  | @ -1171,18 +1171,18 @@ | |||
| 							// 将去重后的数组重新赋值给 this.devicesList | ||||
| 							this.devicesList = uniqueDevicesList | ||||
| 							let list = [] | ||||
| 							filteredDevices.forEach(device => { | ||||
| 								// 从设备名称中提取 MAC 地址(假设 MAC 地址是设备名称的后6个字符) | ||||
| 								let macFromName = device.name.substring(device.name.length - 12) | ||||
| 								this.$u.get(`/app/device/${macFromName}/isBind`).then((res) => { | ||||
| 									if (res.data == false) { | ||||
| 										list.push(device) | ||||
| 									} else { | ||||
| 							// filteredDevices.forEach(device => { | ||||
| 							// 	// 从设备名称中提取 MAC 地址(假设 MAC 地址是设备名称的后6个字符) | ||||
| 							// 	let macFromName = device.name.substring(device.name.length - 12) | ||||
| 							// 	this.$u.get(`/app/device/${macFromName}/isBind`).then((res) => { | ||||
| 							// 		if (res.data == false) { | ||||
| 							// 			list.push(device) | ||||
| 							// 		} else { | ||||
| 
 | ||||
| 									} | ||||
| 								}) | ||||
| 							// 		} | ||||
| 							// 	}) | ||||
| 
 | ||||
| 							}); | ||||
| 							// }); | ||||
| 							setTimeout(() => { | ||||
| 								this.devicesList = list | ||||
| 							}, 200) | ||||
|  |  | |||
|  | @ -433,18 +433,18 @@ | |||
| 							// 将去重后的数组重新赋值给 this.devicesList | ||||
| 							this.devicesList = uniqueDevicesList | ||||
| 							let list = [] | ||||
| 							filteredDevices.forEach(device => { | ||||
| 								// 从设备名称中提取 MAC 地址(假设 MAC 地址是设备名称的后6个字符) | ||||
| 								let macFromName = device.name.substring(device.name.length - 12) | ||||
| 								this.$u.get(`/app/device/${macFromName}/isBind`).then((res) => { | ||||
| 									if (res.data == false) { | ||||
| 										list.push(device) | ||||
| 									} else { | ||||
| 			// 				filteredDevices.forEach(device => { | ||||
| 			// 					// 从设备名称中提取 MAC 地址(假设 MAC 地址是设备名称的后6个字符) | ||||
| 			// 					let macFromName = device.name.substring(device.name.length - 12) | ||||
| 			// 					this.$u.get(`/app/device/${macFromName}/isBind`).then((res) => { | ||||
| 			// 						if (res.data == false) { | ||||
| 			// 							list.push(device) | ||||
| 			// 						} else { | ||||
| 			 | ||||
| 									} | ||||
| 								}) | ||||
| 			// 						} | ||||
| 			// 					}) | ||||
| 			 | ||||
| 							}); | ||||
| 			// 				}); | ||||
| 							setTimeout(() => { | ||||
| 								this.devicesList = list | ||||
| 							}, 200) | ||||
|  |  | |||
|  | @ -15,11 +15,11 @@ | |||
| 							共{{userinfo.storeCount == null ? 0 : userinfo.storeCount}}间店铺 | ||||
| 						</view> | ||||
| 					</view> | ||||
| 					<view class=""> | ||||
| 						<!-- <view class="botcard" @click="btnsblr"> --> | ||||
| 					<view class="" v-if="userinfo.deviceAdmin == true"> | ||||
| 						<view class="botcard" @click="btnsblr"> | ||||
| 							<!-- <image src="https://api.ccttiot.com/smartmeter/img/static/uYWpW30vIQ6M4svb7Vnb"></image> --> | ||||
| 							<!-- <view class="txt">设备录入</view> --> | ||||
| 						<!-- </view> --> | ||||
| 							<view class="txt">设备录入</view> | ||||
| 						</view> | ||||
| 					</view> | ||||
| 				</view> | ||||
| 				<!-- <view class="tit"> | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user