Explorar o código

机柜信息接口处理

郭宇琦 hai 3 semanas
pai
achega
0afacc05b1

+ 25 - 0
common/config_gyq.js

@@ -0,0 +1,25 @@
+var params = require('./params.js');
+
+var api_web_url = params.api_web_url;
+var up_img_url = params.up_img_url;
+const gps_url = params.gps_url;
+var map_bms_url = params.map_url;
+var config = {
+	APP_VERSION: '4.1.2024121301',
+	APP_VERSION_DESC: '优化小程序',
+	QQ_MAP_KEY: 'Q7DBZ-BQH65-MEMIO-Q7LEF-S43Z3-G6B34',
+	// 腾讯地图api key
+	QINIU_SITE: 'https://qiniu.bms16.com/',
+	// 拉取图片地址
+	QINIU_UPLOAD_SITE: 'https://up-z2.qiniup.com/',
+	// 七牛上传地址
+	API_QINIU_UP_IMG_TOKEN: up_img_url + '?r=qiniu/token-v2',
+	// 获取上传token
+	API_GET_OPEN_ID: api_web_url + '?r=user/get-open-id',
+	API_OPENID_LOGIN: api_web_url + '?r=user/slogin', //opendid一键登录
+	API_CABINET_INFO: api_web_url + '?r=flk/cabinet/info', 
+	API_CAR_DEVICE_LIST: api_web_url + '?r=flk/car/device-list', 
+	// 机柜换电
+	API_FLK_CABINET_CHANGE_BATTERY: api_web_url +'?r=flk/cabinet/change-battery'
+};
+module.exports = config;

+ 25 - 27
common/request.js

@@ -53,25 +53,22 @@ async function getRequest(url, data) {
 	let res = await uni.request({
 		url: url,
 		method: 'GET',
-		uni.hideLoading();
-		if (_checkTokenValid(res)) {
-			return res
-		}
-		throw Error(res.data.msg);
 	});
-
-
+	uni.hideLoading();
+	 res = res[1]
+	if (_checkTokenValid(res)) {
+		return res
+	}
+	throw Error(res.data.msg);
 }
 
- async function postRequest(url, data,) {
+async function postRequest(url, data ) {
 	const datetime = Math.floor(Date.now() / 1000)
 	data.time = datetime.toString()
 	let jsonStr = JSON.stringify(selfSort(data))
 	var encrypted = crypto.SHA256(jsonStr)
 	var sign = encrypted.toString()
-	if (!failCallBack) failCallBack = function() {}
 	var token = storage.getUserToken()
-
 	// 申请拖车服务接口加密签名校验
 	// if (url === config.API_DAYHIRE_DRAG_CAR_SERVICE) {
 	data.sign = sign
@@ -86,25 +83,26 @@ async function getRequest(url, data) {
 		},
 		method: 'POST',
 	});
-	
-		wx.hideLoading();
-		if (res.data.code == 200) {
-			res.succeed = true
-			res.body = res.data
-		} else {
-			uni.showToast({
-				title: res.data.msg,
-				icon: 'none'
-			})
-		}
-		if (_checkTokenValid(res)) {
-			return res
-		}
-		
-		throw Error(res.data.msg);
+	res = res[1]
+	wx.hideLoading();
+	if (res.data.code == 200) {
+		res.succeed = true
+		res.body = res.data
+		return res
+	} else {
+		uni.showToast({
+			title: res.data.msg,
+			icon: 'none'
+		})
+	}
+	if (_checkTokenValid(res)) {
+		return res
+	}
+
+	throw Error(res.data.msg);
 }
 
- function selfSort(data) {
+function selfSort(data) {
 	// console.log(data,"签名数据")
 	let sortedKeys = Object.keys(data).sort((a, b) => {
 		//对key 进行翻转

+ 2 - 0
component/scanBtn/scanBtn.vue

@@ -13,6 +13,7 @@
 				<view @tap="sacnBtn" class="scan-btn"><text>扫码换电</text></view>
 			</view>
 		</view>
+		
 	<!-- 购买换电次数弹窗 -->
 		<view v-if="isShowToBuy" class="modal-group">
 			<view class="fee-rules-main">
@@ -128,6 +129,7 @@
 		 */
 		,
 		mounted: function(options) {
+			console.log(454444)
 			const car_list = uni.getStorageSync('user_car_list') || null
 			const storedLocation = uni.getStorageSync('user_current_location');
 			if (car_list){

+ 157 - 291
component/scanCabBtn/scanBtn.vue

@@ -1,148 +1,14 @@
 <template>
 	<view class="container-view">
-		<view v-if="is_battery&&battery_info===null"></view>
-		<view v-else>
-			<block v-if="JSON.stringify(packInfo) !== '{}' && (packInfo.packType === 1 || packInfo.packType === 0) ||is_battery">
-				<view class="no-height"></view>
-				<view class="cabinet-bottom">
-					<view @tap="navToGuild" class="guide-view flex-row">
-						<img class="battery-img" src="https://qiniu.bms16.com/FkJlBRAxbGzR85wOO8WB_bAUTp-i" alt="">
-						<view class="guide-text">{{is_battery?'电池归还操作指南':'电池换电指南'}}</view>
-						<img class="arrow-img" src="https://qiniu.bms16.com/FtC9Hb8y1QEOidsI2UySz85iUQHy" alt="">
-					</view>
-					
-					<block v-if="packInfo.packType === 0">
-						<view class="scan-btn-view flex-row">
-							<view @tap="sacnBtn" class="refund-btn"><text>扫码换电</text></view>
-							<view v-if="showScanBtn" @tap="tapReservation" class="scan-btn">预约换电</view>
-						</view>
-						<!-- <view class="scan-btn-view1">
-							<view @tap="sacnBtn" class="scan-btn1"><text>扫码换电</text></view>
-						</view>
-						<view class="appoint-btn-view1">
-							<view @click="tapReservation" class="phone-view">预约换电</view>
-						</view> -->
-					</block>
-					<block v-else>
-						<block v-if="!is_battery&&((isShowAppoint && reservation_info.length === 0) || reservation_info.length !== 0)">
-							<view :class="showScanBtn?'scan':'show_scan'">
-								<view class="scan-btn-view1">
-									<view @tap="sacnBtn" class="scan-btn1"><text>扫码换电</text></view>
-								</view>
-								<view class="appoint-btn-view1">
-									<view v-if="(isShowAppoint && reservation_info.length === 0) &&showScanBtn" @click="tapReservation"
-										class="phone-view">
-										{{reservation_info.length === 0?'预约换电':'取消预约'}}
-									</view>
-									<view v-if="reservation_info.length !== 0&&showScanBtn"
-										@click="cancelReservation(reservation_info[0].reservation_order_sn)" class="phone-view">
-										{{'取消预约'}}
-									</view>
-									<view
-										v-if="reservation_info.length !== 0 && (countdownTimer.hours != 0 || countdownTimer.minutes != 0 || countdownTimer.secs != 0)"
-										class="cancel_subscribe_mark">
-										<!-- {{countdownTimer}} -->
-										<text class="time_num" v-if="countdownTimer.hours != 0">{{countdownTimer.hours}}</text>
-										<text class="time_mark" v-if="countdownTimer.hours != 0">时</text>
-										<text class="time_num">{{countdownTimer.minutes}}</text>
-										<text class="time_mark">分</text>
-										<text class="time_num">{{countdownTimer.secs}}</text>
-										<text class="time_mark">秒</text>
-										<text class="time_mark">自动取消</text>
-									</view>
-								</view>
-							</view>
-						
-						</block>
-						<block v-else>
-							<view class="scan-btn-view">
-								<view @tap="sacnBtnReturn" class="refund-btn"><text>还电</text></view>
-								<view @tap="sacnBtn" class="scan-btn"><text>{{is_battery?'换电':'扫码换电'}}</text></view>
-							</view>
-						</block>
-					</block>
-				</view>
-				<!-- 购买换电次数弹窗 -->
-				<view v-if="isShowToBuy" class="modal-group">
-					<view class="fee-rules-main">
-						<view class="fee-rules-top flex-row">
-							<view @tap="claseShowToBuy" class="fee-rules-close">
-								<img class="close-icon" src="https://qiniu.bms16.com/FtoTEHOJiUf_gjPCJGGHMsAtHI5M" alt="">
-							</view>
-							<view class="pay-moneu-view">
-								<view class="pay-money-text">付款金额/¥</view>
-								<view class="pay-money">{{free_price}}</view>
-							</view>
-						</view>
-						<view class="fee-rules-view">
-							<view class="fee-rules flex-row flex-between">
-								<view class="fee-rules-title flex-row">
-									<img class="fee-rules-icon" src="https://qiniu.bms16.com/FjJ70vT8ydLEGfeABSFYWFe-zosV"
-										alt="">
-									<text style="margin-left:16rpx;">换电收费规则</text>
-								</view>
-								<view class="fee-rules-money-view">
-									<text class="fee-rules-money">¥{{free_price}}</text>
-									<text>/1次</text>
-								</view>
-							</view>
-							<view class="open-result-tip">您的免费换电次数已用完,后续换电需要支付</view>
-						</view>
-						<view class="pay-type-view">
-							<!-- #ifdef MP-WEIXIN  -->
-							<view @tap="changePayType" :data-type="0" class="pay-view flex-row">
-								<img class="pay-icon" src="https://qiniu.bms16.com/FkmtlfJrmGfAh9n1138KC1WloQkZ" alt="">
-								<view class="pay-view-text">微信支付</view>
-								<img class="wx-pay-icon"
-									:src="payType==0?'https://qiniu.bms16.com/FhWimtmWybKlYMB6mgIReVWArbfq':'https://qiniu.bms16.com/FkmDjxBNZhFGFU5inza2usdtDlX8'"
-									alt="">
-							</view>
-							<!-- #endif  -->
-							<!-- #ifdef MP-ALIPAY-->
-							<view @tap="changePayType" :data-type="2" class="pay-view flex-row">
-								<img class="pay-icon" src="https://qiniu.bms16.com/Fk4YmG_RbdH0LNo1s8qHKDtpCTXl" alt="">
-								<view class="pay-view-text">支付宝支付</view>
-								<img class="wx-pay-icon"
-									:src="payType==2?'https://qiniu.bms16.com/FhWimtmWybKlYMB6mgIReVWArbfq':'https://qiniu.bms16.com/FkmDjxBNZhFGFU5inza2usdtDlX8'"
-									alt="">
-							</view>
-							<!-- #endif  -->
-							<view @tap="changePayType" :data-type="9" class="pay-view flex-row">
-								<img class="pay-icon" src="https://qiniu.bms16.com/FiGNLQ5lqhEK5im_mUVgRrE8PJMB" alt="">
-								<view class="pay-view-text">钱包余额支付(¥{{wallet_money}})</view>
-								<img class="wx-pay-icon"
-									:src="payType==9?'https://qiniu.bms16.com/FhWimtmWybKlYMB6mgIReVWArbfq':'https://qiniu.bms16.com/FkmDjxBNZhFGFU5inza2usdtDlX8'"
-									alt="">
-							</view>
-						</view>
-						<view class="over-btn-view">
-							<view class="over-btn flex-row" @tap="toPayOrFreeExchange">立即支付</view>
-						</view>
-					</view>
-				</view>
-				<!-- 打开蓝牙连接弹窗 -->
-				<view v-if="isOpenBluetooth" class="modal-group">
-					<view class="def-alert-bluetooth">
-						<view class="close-view flex-row"><img @tap="close" class="close-icon"
-								src="https://qiniu.bms16.com/FtoTEHOJiUf_gjPCJGGHMsAtHI5M" alt=""></view>
-						<view class="bluetooth-view flex-row"><img class="bluetooth-icon"
-								src="https://qiniu.bms16.com/FjWK8ZBtxCmspiOtHJWrNEoPRA0M" alt=""></view>
-						<view class="need-bluetooth-text">本次{{is_retuen_battery?'还':'换'}}电需要连接蓝牙</view>
-						<view class="need-bluetooth-tip">请开启手机蓝牙,点击 (蓝牙{{is_retuen_battery?'还':'换'}}电) 按钮</view>
-						<view class="bluetooth-connect-view">
-							<view class="bluetooth-connect-btn" @tap="tapOpenBluetooth">蓝牙{{is_retuen_battery?'还':'换'}}电
-							</view>
-						</view>
-					</view>
-				</view>
-			</block>
-		</view>
+		<view @tap="sacnBtn" class="refund-btn"><text>扫码换电</text></view>
 	</view>
 </template>
 
 <script>
-	var http = require('../../common/http.js');
-	var config = require('../../common/config.js');
+	// var http = require('../../common/http.js');
+	var http = require('../../common/request.js');
+	// var config = require('../../common/config.js');
+	var config = require('../../common/config_gyq.js');
 	var common = require('../../common/common.js');
 	var storage = require('../../common/storage.js')
 	var user = require('../../common/user.js');
@@ -210,7 +76,7 @@
 							reservation_info: JSON.stringify(newVal) == '{}' ? [] : newVal
 								.reservation_info
 						});
-						this.updateCountdown();
+						// this.updateCountdown();
 					}
 				},
 				immediate: true
@@ -289,48 +155,38 @@
 				// )
 			},
 
-			navToGuild() {
-				const url = this.is_battery ? '/pages/my/leadReturnBattery/leadReturnBattery' :
-					'/pages/exchangeGuide/exchangeGuide'
-				console.log(url);
-				uni.navigateTo({
-					url: url
-				});
-			},
+			// navToGuild() {
+			// 	const url = this.is_battery ? '/pages/my/leadReturnBattery/leadReturnBattery' :
+			// 		'/pages/exchangeGuide/exchangeGuide'
+			// 	uni.navigateTo({
+			// 		url: url
+			// 	});
+			// },
 
-			sacnBtn() {
-				const me = this
-				this.is_retuen_battery = false
-				if (this.packInfo.packType === 0||this.packInfo.packType === 2) {
-					const notShow = 1
-					this.$emit(
-						'popPackageModel', this.packInfo,notShow
-					);
-				} else{
-				uni.scanCode({
+			async sacnBtn() {
+				let res = await uni.scanCode({
 					onlyFromCamera: true,
 					scanType: [],
-					success: function(res) {
-						var cabinet_dev_id = '';
-						me.loadGeneralQRData(res)
-						if ('path' in res && res.path) {
-							if (res.path.split('%26devid%3D').length > 1) {
-								cabinet_dev_id = res.path.split('%26devid%3D')[1].split('%26')[0];
-							} else if (res.path.split('&devid=').length > 1) {
-								cabinet_dev_id = res.path.split('&devid=')[1].split('&')[0];
-							}
-						}
-						if (cabinet_dev_id != '') {
-							me.scan_dev_id = cabinet_dev_id
-							me.loadNowCabinetDetail(cabinet_dev_id)
-						} else {
-							//common.simpleToast("未找到相应的机柜")
-						}
-					},
-					fail: function(res) {},
-					complete: function(res) {}
 				});
+				var cabinet_dev_id = '';
+				if(res[0]) return
+				res = res[1]
+				this.loadGeneralQRData(res)
+				
+				if ('path' in res && res.path) {
+					if (res.path.split('%26devid%3D').length > 1) {
+						cabinet_dev_id = res.path.split('%26devid%3D')[1].split('%26')[0];
+					} else if (res.path.split('&devid=').length > 1) {
+						cabinet_dev_id = res.path.split('&devid=')[1].split('&')[0];
+					}
+				}
+				if (cabinet_dev_id != '') {
+					this.scan_dev_id = cabinet_dev_id
+					this.loadNowCabinetDetail(cabinet_dev_id)
+				} else {
+					//common.simpleToast("未找到相应的机柜")
 				}
+				
 			},
 			sacnBtnReturn() {
 				const me = this
@@ -476,102 +332,111 @@
 				}
 			},
 
-			loadNowCabinetDetail(dev_id) {
-				const timeNow = Date.now()
-				this.scan_dev_id = dev_id
-				//扫码机柜信息
-				const me = this
-				const pData = {
-					longitude: this.myLocation.longitude,
-					latitude: this.myLocation.latitude,
-					dev_id: dev_id || '',
-					service: "reservation",
-					time: timeNow
-				}
-				http.postApi(config.API_DAYHIRE_CABINRT_CABINRT_INFO, pData, (resp) => {
-					if (resp.data.code === 200) {
-						this.online_status = resp.data.data.cabinetInfo.online_status
-						const device = {
-							device_type: "LSCabinet",
-							bt_type: "",
-							mac_id: resp.data.data.cabinetInfo.bt_mac,
-							btid: resp.data.data.cabinetInfo.bt_mac,
-							dev_id: resp.data.data.cabinetInfo.dev_id,
-							key: me.decodeKey(resp.data.data.cabinetInfo.bt_sec),
-							btkey: resp.data.data.cabinetInfo.bt_mac,
-							bt_sec: me.decodeKey(resp.data.data.cabinetInfo.bt_sec),
-							bt_mac: resp.data.data.cabinetInfo.bt_mac
-						}
-						me.setData({
-							blueInfo: device,
-							cabinetInfo: resp.data.data.cabinetInfo
-						})
-						me.updateCountdown()
-						me.bluetoothClose()
-						if (me.online_status == 1) {
-							if (me.is_retuen_battery) {
-								//机柜还电流程
-								me.noBluetoothBack()
-							} else {
-								if (me.packInfo.last_num == 0&&me.packInfo.num != 0) {
-									if (me.free_price != 0) {
-										me.setData({
-											isShowToBuy: true
-										})
-										me.walletInfo()
-									} else{
-										const pData = {
-											from: from,
-											battery_sn: this.is_battery ? this.battery_info.battery_sn : this.packInfo.current_battery_sn,
-											dev_id: this.scan_dev_id,
-											pay_type: 9
-										}
-										const me = this
-										//#ifdef MP-ALIPAY
-										const from = 'ali'
-										//#endif
-										//#ifdef MP-WEIXIN
-										const from = 'wx'
-										//#endif
-										http.postApi(config.API_CABINET_CHANGE_BATTERY2, pData, (resp) => {
-											if (resp.data.code === 200) {
-												// 钱包支付不需要支付直接换电 有换电次数可以直接换电
-												if (!resp.data.data.need_pay) {
-													me.orderInfo = {
-														order_sn: resp.data.data.order_sn,
-														empty_door_id: resp.data.data.empty_door_id,
-														full_door_id: resp.data.data.full_door_id,
-														cabbatterysn: resp.data.data.rtn_battery_sn || ''
-													};
-													me.navOpenCabinet(me.orderInfo)
-												} else {
-													me.setData({
-														isShowToBuy: false
-													})
-													me.wxPayPrice = resp.data.data.price
-													me.payResp = resp
-													me.doPayBattery({})
-												}
-											} else {
-												common.simpleToast(resp.data.msg)
-											}
-										})
-									}
-								} else {
-									me.toPayOrFreeExchange()
-								}
-							}
+			async loadNowCabinetDetail(dev_id) {
+				console.log(dev_id)
+				this.dev_id = dev_id
+				// await http.postApi(config.API_FLK_CABINET_CHANGE_BATTERY,{
+				// 	car_sn:'',
+				// 	dev_id:'',
+				// 	pay_type:'',
+				// 	from:'',
+				// 	battery_sn_list:'',
+				// })
+				// const timeNow = Date.now()
+				// this.scan_dev_id = dev_id
+				// //扫码机柜信息
+				// const me = this
+				// const pData = {
+				// 	longitude: this.myLocation.longitude,
+				// 	latitude: this.myLocation.latitude,
+				// 	dev_id: dev_id || '',
+				// 	service: "reservation",
+				// 	time: timeNow
+				// }
+				// http.postApi(config.API_DAYHIRE_CABINRT_CABINRT_INFO, pData, (resp) => {
+				// 	if (resp.data.code === 200) {
+				// 		this.online_status = resp.data.data.cabinetInfo.online_status
+				// 		const device = {
+				// 			device_type: "LSCabinet",
+				// 			bt_type: "",
+				// 			mac_id: resp.data.data.cabinetInfo.bt_mac,
+				// 			btid: resp.data.data.cabinetInfo.bt_mac,
+				// 			dev_id: resp.data.data.cabinetInfo.dev_id,
+				// 			key: me.decodeKey(resp.data.data.cabinetInfo.bt_sec),
+				// 			btkey: resp.data.data.cabinetInfo.bt_mac,
+				// 			bt_sec: me.decodeKey(resp.data.data.cabinetInfo.bt_sec),
+				// 			bt_mac: resp.data.data.cabinetInfo.bt_mac
+				// 		}
+				// 		me.setData({
+				// 			blueInfo: device,
+				// 			cabinetInfo: resp.data.data.cabinetInfo
+				// 		})
+				// 		// me.updateCountdown()
+				// 		me.bluetoothClose()
+				// 		if (me.online_status == 1) {
+				// 			if (me.is_retuen_battery) {
+				// 				//机柜还电流程
+				// 				me.noBluetoothBack()
+				// 			} else {
+				// 				if (me.packInfo.last_num == 0&&me.packInfo.num != 0) {
+				// 					if (me.free_price != 0) {
+				// 						me.setData({
+				// 							isShowToBuy: true
+				// 						})
+				// 						me.walletInfo()
+				// 					} else{
+				// 						const pData = {
+				// 							from: from,
+				// 							battery_sn: this.is_battery ? this.battery_info.battery_sn : this.packInfo.current_battery_sn,
+				// 							dev_id: this.scan_dev_id,
+				// 							pay_type: 9
+				// 						}
+				// 						const me = this
+				// 						//#ifdef MP-ALIPAY
+				// 						const from = 'ali'
+				// 						//#endif
+				// 						//#ifdef MP-WEIXIN
+				// 						const from = 'wx'
+				// 						//#endif
+				// 						http.postApi(config.API_CABINET_CHANGE_BATTERY2, pData, (resp) => {
+				// 							if (resp.data.code === 200) {
+				// 								// 钱包支付不需要支付直接换电 有换电次数可以直接换电
+				// 								if (!resp.data.data.need_pay) {
+				// 									me.orderInfo = {
+				// 										order_sn: resp.data.data.order_sn,
+				// 										empty_door_id: resp.data.data.empty_door_id,
+				// 										full_door_id: resp.data.data.full_door_id,
+				// 										cabbatterysn: resp.data.data.rtn_battery_sn || ''
+				// 									};
+				// 									me.navOpenCabinet(me.orderInfo)
+				// 								} else {
+				// 									me.setData({
+				// 										isShowToBuy: false
+				// 									})
+				// 									me.wxPayPrice = resp.data.data.price
+				// 									me.payResp = resp
+				// 									me.doPayBattery({})
+				// 								}
+				// 							} else {
+				// 								common.simpleToast(resp.data.msg)
+				// 							}
+				// 						})
+				// 					}
+				// 				} else {
+				// 					me.toPayOrFreeExchange()
+				// 				}
+				// 			}
 
-						} else {
-							me.setData({
-								isOpenBluetooth: true
-							})
-						}
+				// 		} else {
+				// 			me.setData({
+				// 				isOpenBluetooth: true
+				// 			})
+				// 		}
 
-					} else {
-						common.simpleToast(resp.data.msg)
-					}
-				})
+				// 	} else {
+				// 		common.simpleToast(resp.data.msg)
+				// 	}
+				// })
 			},
 			walletInfo() {
 				const me = this
@@ -625,31 +490,31 @@
 				})
 			},
 
-			loadBatteryInfo() {
+			async loadBatteryInfo() {
 				console.log("加载电池信息")
 				const me = this
 				console.log(2222);
-				http.postApi(config.API_HIREEXCHANGE_INDEX_BATTERY, {}, function(resp) {
-					if (resp.data.code === 200) {
-						if (resp.data.data !== null) {
-							me.setData({
-								battery_info: resp.data.data,
-								free_price: resp.data.data.exchange_money / 100,
-								is_battery: me.is_my
-							})
-							me.$emit(
-								'updateBatteryInfo', resp.data.data
-							);
-						} else {
-							me.setData({
-								battery_info: resp.data.data,
-								is_battery: me.is_my
-							})
-						}
+				
+				let resp = await http.postApi(config.API_CAR_DEVICE_LIST, {})
+				if (resp.data.code === 200) {
+					console.log(resp.data)
+					if (resp.data.data !== null) {
+						me.setData({
+							battery_info: resp.data.data.list,
+							is_battery: true
+						})
+						// me.$emit(
+						// 	'updateBatteryInfo', resp.data.data
+						// );
 					} else {
-						common.simpleToast(resp.data.msg)
+						me.setData({
+							// battery_info: resp.data.data,
+							is_battery: false
+						})
 					}
-				})
+				} else {
+					common.simpleToast(resp.data.msg)
+				}
 			},
 
 			doPayBattery: function(pData) {
@@ -852,6 +717,7 @@
 					});
 				}
 			},
+			
 			reportCabintInfo(dev_id, list) {
 				var pushList = []
 				for (var i = 0; list.length > i; i++) {

+ 2 - 0
manifest.json

@@ -6,7 +6,9 @@
     "versionCode" : 130,
     "transformPx" : false,
     "loadnativePlugins" : false,
+	"sassImplementationName":"node-sass",
     "app-plus" : {
+		
         "usingComponents" : true,
         "nvueStyleCompiler" : "uni-app",
         "compilerVersion" : 3,

+ 181 - 181
pages/cabinetDetail/cabinetDetail.vue

@@ -1,163 +1,164 @@
 <template>
 	<view v-if="cabinetInfo.dev_id" class="main-view">
-		<view class="content">
-			<swiper v-if="shop_image.length!=0" class="swiper" :indicator-dots="true" :autoplay="true" :interval="2000"
-				indicator-color="rgba(0, 0, 0, 0.3)" indicator-active-color="#000000" :duration="1000" circular>
-				<swiper-item class="swiper-item" v-for="(item,index) in shop_image" :key="index">
-					<img class="swiper-item-img" :src="item" />
-				</swiper-item>
-			</swiper>
-			<img v-else class="bg-img" src="https://qiniu.bms16.com/FhRnr7rADHHsOFfpWO4duD15SgIt" alt="">
-		</view>
-		<view class="cabinet-detail">
-			<view class="cabinet-name-view flex-row flex-between">
-				<view class="cabinet-name">{{cabinetInfo.cabinet_name}}</view>
-				<!-- <view class="distance">{{cabinetInfo.distance}}km</view> -->
-			</view>
-
-			<view v-if="tagList.length==0" class="no_battery">
-				无可用电池
+			<view class="content">
+				<swiper v-if="shop_image.length!=0" class="swiper" :indicator-dots="true" :autoplay="true" :interval="2000"
+					indicator-color="rgba(0, 0, 0, 0.3)" indicator-active-color="#000000" :duration="1000" circular>
+					<swiper-item class="swiper-item" v-for="(item,index) in shop_image" :key="index">
+						<img class="swiper-item-img" :src="item" />
+					</swiper-item>
+				</swiper>
+				<img v-else class="bg-img" src="https://qiniu.bms16.com/FhRnr7rADHHsOFfpWO4duD15SgIt" alt="">
 			</view>
-			<view class="flex-row" style="justify-content: center;">
-				<view class="icon-box flex-row">
-					<view v-for="(item, index) in tagList" class="item-tag flex-row">
-						<text class="tag_name">
-							{{item.main_tag_name ? (item.main_tag_name) : ''}}{{item.child_tag_name ? '/' + item.child_tag_name : ''}}·
-						</text>
-						<text class="tag_num">{{'x' + item.num}}</text>
-					</view>
+			<view class="cabinet-detail">
+				<view class="cabinet-name-view flex-row flex-between">
+					<view class="cabinet-name">{{cabinetInfo.cabinet_name}}</view>
+					<!-- <view class="distance">{{cabinetInfo.distance}}km</view> -->
 				</view>
-			</view>
-
-			<view class="flex-row flex-between">
-				<view :class="isWorkTimer ? 'left_grid_2' : 'left_grid_1'">
-					<view class="flex-row">
-						<img class="icon_grid"
-							:src="!isWorkTimer ? 'https://zxappfile.bms16.com/zx_admin/cab_timer.png' : 'https://zxappfile.bms16.com/zx_admin/cab_timer_work.png'">
-						<view :class="isWorkTimer ? 'grid_text_1' : 'grid_text_rest' ">{{isWorkTimer ? '营业中' : '已休息'}}
+	
+				<!-- <view v-if="tagList.length==0" class="no_battery">
+					无可用电池
+				</view>
+				<view class="flex-row" style="justify-content: center;">
+					<view class="icon-box flex-row">
+						<view v-for="(item, index) in tagList" class="item-tag flex-row">
+							<text class="tag_name">
+								{{item.main_tag_name ? (item.main_tag_name) : ''}}{{item.child_tag_name ? '/' + item.child_tag_name : ''}}·
+							</text>
+							<text class="tag_num">{{'x' + item.num}}</text>
 						</view>
 					</view>
-					<view class="grid_text_2">
-						{{cabinetInfo.work_begin_time!=null?cabinetInfo.work_begin_time:'00:00'}}-{{cabinetInfo.work_end_time!=null?cabinetInfo.work_end_time:'23:59'}}
-					</view>
-				</view>
-				<view  @tap="navToCabinet" class="right_grid flex-between">
-					<view>
-						<view class="cab_distance">
-							直线距您{{cabinetInfo.distance>1?(cabinetInfo.distance+'千米'):(cabinetInfo.distance*1000+'米')}}
+				</view> -->
+	
+				<view class="flex-row flex-between">
+					<view :class="isWorkTimer ? 'left_grid_2' : 'left_grid_1'">
+						<view class="flex-row">
+							<img class="icon_grid"
+								:src="!isWorkTimer ? 'https://zxappfile.bms16.com/zx_admin/cab_timer.png' : 'https://zxappfile.bms16.com/zx_admin/cab_timer_work.png'">
+							<view :class="isWorkTimer ? 'grid_text_1' : 'grid_text_rest' ">{{isWorkTimer ? '营业中' : '已休息'}}
+							</view>
+						</view>
+						<view class="grid_text_2">
+							{{cabinetInfo.work_begin_time!=null?cabinetInfo.work_begin_time:'00:00'}}-{{cabinetInfo.work_end_time!=null?cabinetInfo.work_end_time:'23:59'}}
 						</view>
-						<view class="cab_address">{{cabinetInfo.address}}</view>
 					</view>
-					<view>
-						<img class="icon_grid_1" src="https://zxappfile.bms16.com/zx_admin/cab_nav.png">
-						<view class="grid_nav">导航</view>
+					<view  @tap="navToCabinet" class="right_grid flex-between">
+						<view>
+							<view class="cab_distance">
+								直线距您{{cabinetInfo.distance>1?(cabinetInfo.distance+'千米'):(cabinetInfo.distance*1000+'米')}}
+							</view>
+							<view class="cab_address">{{cabinetInfo.address}}</view>
+						</view>
+						<view>
+							<img class="icon_grid_1" src="https://zxappfile.bms16.com/zx_admin/cab_nav.png">
+							<view class="grid_nav">导航</view>
+						</view>
 					</view>
 				</view>
 			</view>
-		</view>
-		<view class="battery-list-view">
-			<view class="battery-title flex-row flex-between">
-				<text class="blod-text">格口详情</text>
-				<text class="cabinet-ref">电柜编号:<text class="cabinet-ref-text"> {{cabinetInfo.dev_id}}</text></text>
-			</view>
-			<view class="battery-list-main flex-row flex-start">
-				<view class="battery-list" v-for="(item, index) in batteryList" :key="item.unique">
-					<block v-if="item.isReservation">
-						<view class="battery-list-g">
-							<view class="namber-view flex-row">
-								<view class="namber namber-g">
-									{{item.box_sn}}
-								</view>
-							</view>
-
-							<view class="status-img-view flex-row">
-								<img class="status-img" src="https://zxappfile.bms16.com/zx_admin/reservation.png"
-									alt="">
-							</view>
-							<view class="tip-text tip-text-g1">已预约</view>
-						</view>
-					</block>
-					<!-- 没有预约-->
-					<block v-else>
-						<!-- 空仓或者仓门不可用-->
-						<view v-if="!item.cabinet_battery_sn||(item.fault_reason&&item.fault_reason.length>0)"
-							:class="(item.fault_reason&&item.fault_reason.length>0)?'battery-list-s':'battery-list-g'">
-							<!-- <view class="namber-view flex-row">
-								<view
-									:class="(item.fault_reason&&item.fault_reason.length>0)?'namber namber-s':'namber namber-g'">
-									{{item.box_sn}}
-								</view>
-							</view> -->
-
-							<view class="namber-view flex-row flex-between">
-								<view
-									:class="(item.fault_reason&&item.fault_reason.length>0)?'namber namber-s':'namber namber-g'">
-									{{item.box_sn}}
+			<view class="battery-list-view">
+				<view class="battery-title flex-row flex-between">
+					<text class="blod-text">格口详情</text>
+					<text class="cabinet-ref">电柜编号:<text class="cabinet-ref-text"> {{cabinetInfo.dev_id}}</text></text>
+				</view>
+				<view class="battery-list-main flex-row flex-start">
+					<view class="battery-list" v-for="(item, index) in batteryList" :key="item.unique">
+						<!-- <block v-if="item.isReservation">
+							<view class="battery-list-g">
+								<view class="namber-view flex-row">
+									<view class="namber namber-g">
+										{{item.box_sn}}
+									</view>
 								</view>
-								<view v-if="item.tag_info.length !== 0" class="tag_type_n">
-									{{item.tag_info[0].main_tag_name ? (item.tag_info[0].main_tag_name) : ''}}{{item.tag_info[0].child_tag_name ? '/' + item.tag_info[0].child_tag_name : ''}}
+	
+								<view class="status-img-view flex-row">
+									<img class="status-img" src="https://zxappfile.bms16.com/zx_admin/reservation.png"
+										alt="">
 								</view>
+								<view class="tip-text tip-text-g1">已预约</view>
 							</view>
-
-							<view class="status-img-view flex-row">
-								<img v-if="!item.cabinet_battery_sn&&!(item.fault_reason&&item.fault_reason.length>0)"
-									class="status-img" src="https://qiniu.bms16.com/FtOgmvwtoUCVzEyxIau6-6i0hjLt"
-									alt="">
-								<img v-if="item.fault_reason&&item.fault_reason.length>0" class="status-img"
-									src="https://qiniu.bms16.com/FmMGYfe7eRSQvM8zeKEVeSmzbArd" alt="">
-							</view>
-							<!-- <view class="battery-ref">124513215</view> -->
-							<view v-if="!item.cabinet_battery_sn&&!(item.fault_reason&&item.fault_reason.length>0)"
-								class="tip-text tip-text-g">空仓</view>
-							<view v-if="item.fault_reason&&item.fault_reason.length>0" class="tip-text tip-text-u">
-								{{item.fault_reason[0]}}
-							</view>
-						</view>
-						<!-- 满电或者电量未满 -->
-						<view v-else :class="(item.is_full_soc==1)?'battery-list-b':'battery-list-o'">
-							<view class="namber-view flex-row flex-between">
-								<view :class="(item.is_full_soc==1)?'namber namber-b':'namber namber-o'">{{item.box_sn}}
+						</block> -->
+						<!-- 没有预约-->
+						<!-- <block v-else> -->
+							<!-- 空仓或者仓门不可用-->
+							<view v-if="!item.cabinet_battery_sn||(item.fault_reason&&item.fault_reason.length>0)"
+								:class="(item.fault_reason&&item.fault_reason.length>0)?'battery-list-s':'battery-list-g'">
+								<!-- <view class="namber-view flex-row">
+									<view
+										:class="(item.fault_reason&&item.fault_reason.length>0)?'namber namber-s':'namber namber-g'">
+										{{item.box_sn}}
+									</view>
+								</view> -->
+	
+								<view class="namber-view flex-row flex-between">
+									<view
+										:class="(item.fault_reason&&item.fault_reason.length>0)?'namber namber-s':'namber namber-g'">
+										{{item.box_sn}}
+									</view>
+									<view v-if="item.tag_info && item.tag_info.length !== 0" class="tag_type_n">
+										{{item.tag_info[0].main_tag_name ? (item.tag_info[0].main_tag_name) : ''}}{{item.tag_info[0].child_tag_name ? '/' + item.tag_info[0].child_tag_name : ''}}
+									</view>
 								</view>
-								<view v-if="item.tag_info.length !== 0" class="tag_type">
-									{{item.tag_info[0].main_tag_name ? (item.tag_info[0].main_tag_name) : ''}}{{item.tag_info[0].child_tag_name ? '/' + item.tag_info[0].child_tag_name : ''}}
+	
+								<view class="status-img-view flex-row">
+									<img v-if="!item.cabinet_battery_sn&&!(item.fault_reason&&item.fault_reason.length>0)"
+										class="status-img" src="https://qiniu.bms16.com/FtOgmvwtoUCVzEyxIau6-6i0hjLt"
+										alt="">
+									<img v-if="item.fault_reason&&item.fault_reason.length>0" class="status-img"
+										src="https://qiniu.bms16.com/FmMGYfe7eRSQvM8zeKEVeSmzbArd" alt="">
+								</view>
+								<!-- <view class="battery-ref">124513215</view> -->
+								<view v-if="!item.cabinet_battery_sn&&!(item.fault_reason&&item.fault_reason.length>0)"
+									class="tip-text tip-text-g">空仓</view>
+								<view v-if="item.fault_reason&&item.fault_reason.length>0" class="tip-text tip-text-u">
+									{{item.fault_reason[0]}}
 								</view>
 							</view>
-							<view class="status-img-view flex-row">
-								<view v-if="item.cabinet_battery_sn" class="progress-bar-view">
-									<progressView :soc="item.soc" :status="item.is_full_soc"></progressView>
+							<!-- 满电或者电量未满 -->
+							<view v-else :class="(item.is_full_soc==1)?'battery-list-b':'battery-list-o'">
+								<view class="namber-view flex-row flex-between">
+									<view :class="(item.is_full_soc==1)?'namber namber-b':'namber namber-o'">{{item.box_sn}}
+									</view>
+									<view v-if="item.tag_info && item.tag_info.length !== 0" class="tag_type">
+										{{item.tag_info[0].main_tag_name ? (item.tag_info[0].main_tag_name) : ''}}{{item.tag_info[0].child_tag_name ? '/' + item.tag_info[0].child_tag_name : ''}}
+									</view>
 								</view>
-								<view v-if="item.cabinet_battery_sn" class="battery-number">
-									{{item.battery_sn}}
-									<!-- 0168 8256 9608 -->
+								<view class="status-img-view flex-row">
+									<view v-if="item.cabinet_battery_sn" class="progress-bar-view">
+										<progressView :soc="item.soc" :status="item.is_full_soc"></progressView>
+									</view>
+									<view v-if="item.cabinet_battery_sn" class="battery-number">
+										{{item.battery_sn}}
+										<!-- 0168 8256 9608 -->
+									</view>
 								</view>
+								<view v-if="item.is_full_soc==1" class="tip-text tip-text-b">电池可用</view>
+								<view v-else class="tip-text tip-text-o">待充满</view>
 							</view>
-							<view v-if="item.is_full_soc==1" class="tip-text tip-text-b">电池可用</view>
-							<view v-else class="tip-text tip-text-o">待充满</view>
-						</view>
-					</block>
+						<!-- </block> -->
+					</view>
 				</view>
 			</view>
+			<scanBtn :dev_id="dev_id" :cab_info="cabinetInfo" @refreshCabinet="refreshCabinet"
+				@popPackageModel="clickPopPackageModel" ref="scanRef"></scanBtn>
+			
+			<view v-if="isModelCenter" class="model_center">
+				<image class="pack_model" src="https://zxappfile.bms16.com/zx_client/buy_pack_model.png" />
+				<view v-if="packType==0" class="pack_model_text">您还未购买换电套餐,需先完成购买后再扫码领取电池</view>
+				<view v-if="packType==2" class="pack_model_text">您还未完成押金授权,现在前往押金授权?</view>
+				<view v-if="packType==0" class="look_package" @tap="clickLookPackage">查看套餐</view>
+				<view v-if="packType==2" class="look_package" @tap="clickMyPackage">去押金认证</view>
+				<view class="line_view"></view>
+				<image @tap="clickClosePackage" class="close_package"
+					src="https://zxappfile.bms16.com/zx_client/close_package.png"></image>
+			</view>
 		</view>
-		<scanBtn :dev_id="dev_id" :cab_info="cabinetInfo" @refreshCabinet="refreshCabinet"
-			@popPackageModel="clickPopPackageModel" ref="scanRef"></scanBtn>
-
-		<view v-if="isModelCenter" class="model_center">
-			<image class="pack_model" src="https://zxappfile.bms16.com/zx_client/buy_pack_model.png" />
-			<view v-if="packType==0" class="pack_model_text">您还未购买换电套餐,需先完成购买后再扫码领取电池</view>
-			<view v-if="packType==2" class="pack_model_text">您还未完成押金授权,现在前往押金授权?</view>
-			<view v-if="packType==0" class="look_package" @tap="clickLookPackage">查看套餐</view>
-			<view v-if="packType==2" class="look_package" @tap="clickMyPackage">去押金认证</view>
-			<view class="line_view"></view>
-			<image @tap="clickClosePackage" class="close_package"
-				src="https://zxappfile.bms16.com/zx_client/close_package.png"></image>
-		</view>
-	</view>
 </template>
 
 <script>
-	import progressView from '@/component/progressView/progressView';
-	const http = require('../../common/http.js');
-	const config = require('../../common/config.js');
+	import { getLocation, msg,strJoin } from '../../utils/util.js';
+import progressView from '@/component/progressView/progressView';
+	const http = require('../../common/request.js');
+	const config = require('../../common/config_gyq.js');
 	const common = require('../../common/common.js');
 	var user = require('../../common/user.js');
 	var bluetooth = require('../../common/bluetooth.js');
@@ -172,6 +173,8 @@
 		},
 		data() {
 			return {
+				dev_id: '',
+				listData:{},
 				isWorkTimer: true,
 				tagList: [],
 				batteryList: [], //电池列表
@@ -182,7 +185,6 @@
 				myLocation: {},
 				reservation_info: [],
 				cabinetInfo: {}, //机柜详情
-				dev_id: '',
 				num: 0,
 				is_scan: 0,
 				fre_price: 0,
@@ -205,6 +207,7 @@
 		 */
 		onLoad: function(options) {
 			this.notShow = options.notShow?options.notShow:1
+			this.dev_id = options.dev_id
 			const storedLocation = uni.getStorageSync('user_current_location');
 			const car_list = uni.getStorageSync('user_car_list') || null
 			this.license_plate_number = car_list ? car_list.plate_number : ''
@@ -226,6 +229,7 @@
 				this.getLocationAndSave();
 			}
 			bluetooth.initBluetooth()
+			
 		},
 		/**
 		 * 生命周期函数--监听页面显示
@@ -234,7 +238,6 @@
 
 		},
 		methods: {
-
 			clickLookPackage() {
 				wx.switchTab({
 					url: '/pages/packageCenter/packageCenter'
@@ -296,57 +299,54 @@
 				})
 			},
 
-			loadCabinetDetail() {
+			async loadCabinetDetail() {
 				//获取机柜信息
 				const that = this
-				const pData = {
+				var _can_num = 0
+				let resp = await http.postApi(config.API_CABINET_INFO, {
+					dev_id:this.dev_id,
 					longitude: this.myLocation.longitude,
 					latitude: this.myLocation.latitude,
-					dev_id: this.dev_id,
-					service: "reservation"
-				}
-				var _can_num = 0
-				http.postApi(config.API_NEAR_SHOP_CABINET_INFO, pData, (resp) => {
-					if (resp.data.code === 200) {
-						const _batteryList = resp.data.data.boxList
-						// 计算可用电池数
-						for (let i = 0; i < _batteryList.length; i++) {
-							if (_batteryList[i].cabinet_battery_sn && (!(_batteryList[i].fault_reason &&
-									_batteryList[i].fault_reason.length > 0))) {
-								_can_num = _can_num + 1
-							}
+				})
+				if (resp.data.code === 200) {
+					const _batteryList = resp.data.data.boxList
+					// 计算可用电池数
+					for (let i = 0; i < _batteryList.length; i++) {
+						if (_batteryList[i].cabinet_battery_sn && (!(_batteryList[i].fault_reason &&
+								_batteryList[i].fault_reason.length > 0))) {
+							_can_num = _can_num + 1
 						}
-
-						var cabinetInfo = resp.data.data.cabinetInfo
-						cabinetInfo.work_begin_time = cabinetInfo.work_begin_time == null ? '00:00' : cabinetInfo
-							.work_begin_time
-						cabinetInfo.work_end_time = cabinetInfo.work_end_time == null ? '00:00' : cabinetInfo
-							.work_end_time
-						const isWorkTimer = cabinetDetailImpl.isWithinTimeRange(cabinetInfo.work_begin_time,
-							cabinetInfo.work_end_time)
-						var reservation_List = resp.data.data.cabinetInfo.reservation_info
-						var box_list = resp.data.data.boxList
-						box_list = cabinetDetailImpl.getBoxReservation(box_list, reservation_List)
-						console.log(box_list, "box_list")
-						that.setData({
-							reservation_info: reservation_List,
-							isWorkTimer: isWorkTimer,
-							tagList: resp.data.data.tagList,
-							cabinetInfo: cabinetInfo,
-							batteryList: box_list,
-							online_status: cabinetInfo.online_status,
-							can_battery_num: _can_num,
-							shop_image: JSON.parse(cabinetInfo.imgs.split(',')) || []
-						})
-					} else {
-						common.simpleToast(resp.data.msg)
-						setTimeout(() => {
-							uni.switchTab({
-								url: '/pages/index/index'
-							});
-						}, 1500)
 					}
-				})
+				
+					var cabinetInfo = resp.data.data.cabinetInfo
+					cabinetInfo.work_begin_time = cabinetInfo.work_begin_time == null ? '00:00' : cabinetInfo
+						.work_begin_time
+					cabinetInfo.work_end_time = cabinetInfo.work_end_time == null ? '00:00' : cabinetInfo
+						.work_end_time
+					const isWorkTimer = cabinetDetailImpl.isWithinTimeRange(cabinetInfo.work_begin_time,
+						cabinetInfo.work_end_time)
+					var reservation_List = resp.data.data.cabinetInfo.reservation_info
+					var box_list = resp.data.data.boxList
+					// box_list = cabinetDetailImpl.getBoxReservation(box_list, reservation_List)
+					console.log(box_list, "box_list")
+					that.setData({
+						reservation_info: reservation_List,
+						isWorkTimer: isWorkTimer,
+						tagList: resp.data.data.tagList,
+						cabinetInfo: cabinetInfo,
+						batteryList: box_list,
+						online_status: cabinetInfo.online_status,
+						can_battery_num: _can_num,
+						shop_image: JSON.parse(cabinetInfo.imgs.split(',')) || []
+					})
+				} else {
+					common.simpleToast(resp.data.msg)
+					setTimeout(() => {
+						uni.switchTab({
+							url: '/pages/index/index'
+						});
+					}, 1500)
+				}
 			},
 
 			refreshCabinet() {

+ 4 - 5
pages/service/components/cabinetList/cabinetList.vue

@@ -1,6 +1,6 @@
 <template>
 	<view class="">
-		<view class="cabinet-list-main" v-if="item.dev_id" @tap="navDeatil" :data-dev_id="item.dev_id" v-for="(item, index) in near_cabinet_list" :key="index">
+		<view class="cabinet-list-main" v-if="item.dev_id" @tap="navDeatil(item)"  v-for="(item, index) in near_cabinet_list" :key="index">
 			<view class="flex-row flex-between">
 				<view class="cabinet-name">{{item.cabinet_name}}</view>
 				<view class="cabinet-distance">{{item.distance}}m</view>
@@ -48,11 +48,10 @@
 					success: function(res) {}
 				})
 			},
-			navDeatil(e){
-				const dev_id=e.currentTarget.dataset.dev_id
-				console.log(dev_id,'dev_id');
+			navDeatil(item){
+				let dev_id = item.dev_id
 				uni.navigateTo({
-					url: '/pages/cabinetDetail/cabinetDetail?dev_id='+dev_id
+					url: `/pages/cabinetDetail/cabinetDetail?dev_id=${dev_id}`
 				});
 				
 			}

+ 23 - 2
utils/util.js

@@ -7,12 +7,33 @@ const formatTime = (date) => {
     const second = date.getSeconds();
     return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':');
 };
-
+const getLocation = async ()=>{
+	let res = await uni.getLocation({
+		type: 'wgs84',
+		// success: function (res) {
+		// 	console.log('当前位置的经度:' + res.longitude);
+		// 	console.log('当前位置的纬度:' + res.latitude);
+		// }
+	});
+	return res[1]
+}
+const msg = (str)=>{
+	uni.showToast({
+		title:str
+	})
+}
+const strJoin = (str)=>{
+	if(!str) return []
+	return JSON.parse(str)
+}
 const formatNumber = (n) => {
     n = n.toString();
     return n[1] ? n : '0' + n;
 };
 
 module.exports = {
-    formatTime: formatTime
+    formatTime: formatTime,
+	getLocation,
+	msg,
+	strJoin
 };