郭宇琦 1 hete
szülő
commit
3cbcdb29c4

+ 5 - 1
component/carPlan/carPlan.vue

@@ -46,7 +46,7 @@
 						<view :class="(type == item.hire_duration_unit ? 'car-plan-price-i' : 'car-plan-price') ">$<text style="font-size: 48rpx;margin-left: 6rpx;">{{item.hire_price/100}}</text></view>
 					</view>
 					
-					<view v-if="params.sell_price != 0"  @click="tapSelectType({hire_duration_unit:100,hire_price:params.sell_price})" :class="['flex-row' , (type == 100 ? 'car-plan-list-i' : 'car-plan-list') ]" style="padding:  0rpx 20rpx; min-width: auto; "  >
+					<view v-if="params.sell_price != 0 && isBuy"  @click="tapSelectType({hire_duration_unit:100,hire_price:params.sell_price})" :class="['flex-row' , (type == 100 ? 'car-plan-list-i' : 'car-plan-list') ]" style="padding:  0rpx 20rpx; min-width: auto; "  >
 						<view :class="(type == 100 ? 'car-plan-unit-i' : 'car-plan-unit') ">购买</view>
 						<view :class="(type == 100 ? 'car-plan-price-i' : 'car-plan-price') ">$<text style="font-size: 48rpx;margin-left: 6rpx;">{{params.sell_price/100}}</text></view>
 					</view>
@@ -138,6 +138,10 @@
 		 * 组件的属性列表
 		 */
 		props: {
+			isBuy:{
+				type: Boolean,
+				default: true
+			},
 			params:{
 				type:Object,
 				default:{}

+ 20 - 6
component/scanCabBtn/scanBtn.vue

@@ -140,8 +140,8 @@
 		},
 		methods: {
 			clickLookPackage() {
-				wx.switchTab({
-					url: '/pages/packageCenter/packageCenter'
+				wx.navigateTo({
+					url: '/pages/batteryPackage/batteryPackage'
 				})
 			},
 			clickMyPackage() {
@@ -224,24 +224,38 @@
 				})
 			},
 			async sacnBtn() {
+				
 				const user_token = storage.getUserToken()
 				if (!user_token) {
 					this.loadIsLogin()
 					return
 				}
 				await this.loadBatteryInfo()
-				if((this.listData.user_battery_list.length - this.listData.can_exchange_num) >= 0 && this.listData.can_exchange_num != -1){
-					common.simpleToast('您的次数不足无法换电!')
-					return
-				}
+				
 				if(this.isTagCodeFn().length < 1){
 					common.simpleToast('未找到可更换的电池!')
 					return
 				}
+				if((this.listData.user_battery_list.length - this.listData.can_exchange_num) >= 0 && this.listData.can_exchange_num != -1){
+					
+					// if(showModal[1].confirm){
+					// 	uni.navigateTo({
+					// 		url:`/pages/batteryPackage/batteryPackage`
+					// 	})
+					// 	return
+					// }
+					this.packType = 0
+					this.isModelCenter = true
+					return
+				}
+				uni.showLoading({
+					title:' 加载中...'
+				})
 				let res = await uni.scanCode({
 					onlyFromCamera: true,
 					scanType: ['qrCode'],
 				});
+				uni.hideLoading()
 				var cabinet_dev_id = '';
 				if(res[0]) return
 				res = res[1]

+ 1 - 2
pages/batteryPackage/batteryPackage.vue

@@ -95,10 +95,9 @@ import { fenToYuan, msg } from '../../utils/util.js';
 					data
 				} = await http.postApi(config.API_FLK_EXCHANGE_PACKAGE_PAY, this.form)
 				uni.hideLoading()
-				console.log(data)
 				if(data.code == 200){
 					uni.navigateTo({
-						url:`/pages/order/order`
+						url:`/pages/order/order?selectOrderType=0`
 					})
 				}else{
 					msg(data.msg)

+ 159 - 115
pages/cabinetDetail/cabinetDetail.vue

@@ -1,22 +1,22 @@
 <template>
-	<view  class="main-view">
+	<view class="main-view">
 		<Navigation :scroll='scrollTop'></Navigation>
-			<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 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 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 v-if="tagList.length==0" class="no_battery">
 					无可用电池
 				</view>
 				<view class="flex-row" style="justify-content: center;">
@@ -28,42 +28,42 @@
 							<text class="tag_num">{{'x' + item.num}}</text>
 						</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>
-						</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="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  @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 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="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 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>
+		<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">
@@ -78,76 +78,79 @@
 								<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">
+					<!-- 没有预约-->
+					<!-- <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" class="tag_type_n">
-										{{item.tag_info.main_tag_name ? (item.tag_info.main_tag_name) : ''}}{{item.tag_info.child_tag_name ? '/' + item.tag_info.child_tag_name : ''}}
-									</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 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-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" class="tag_type">
-										{{item.tag_info.main_tag_name ? (item.tag_info.main_tag_name) : ''}}{{item.tag_info.child_tag_name ? '/' + item.tag_info.child_tag_name : ''}}
-									</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>
-									<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 v-if="item.tag_info" class="tag_type_n">
+								{{item.tag_info.main_tag_name ? (item.tag_info.main_tag_name) : ''}}{{item.tag_info.child_tag_name ? '/' + item.tag_info.child_tag_name : ''}}
+							</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}}
+							</view>
+							<view v-if="item.tag_info" class="tag_type">
+								{{item.tag_info.main_tag_name ? (item.tag_info.main_tag_name) : ''}}{{item.tag_info.child_tag_name ? '/' + item.tag_info.child_tag_name : ''}}
 							</view>
-						<!-- </block> -->
+						</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>
+							<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>
+					<!-- </block> -->
 				</view>
-				<scanBtn :dev_id="dev_id" :listData='listData' :cab_info="cabinetInfo" @refreshCabinet="refreshCabinet"
-					@popPackageModel="clickPopPackageModel" ref="scanRef"></scanBtn>
 			</view>
-		
+			<scanBtn :dev_id="dev_id" :listData='listData' :cab_info="cabinetInfo" @refreshCabinet="refreshCabinet"
+				@popPackageModel="clickPopPackageModel" ref="scanRef"></scanBtn>
 		</view>
+
+	</view>
 </template>
 
 <script>
-	import { getLocation, msg,strJoin } from '../../utils/util.js';
-import progressView from '@/component/progressView/progressView';
+	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');
@@ -168,7 +171,7 @@ import progressView from '@/component/progressView/progressView';
 		data() {
 			return {
 				dev_id: '',
-				listData:{},
+				listData: {},
 				isWorkTimer: true,
 				tagList: [],
 				batteryList: [], //电池列表
@@ -193,17 +196,17 @@ import progressView from '@/component/progressView/progressView';
 				isShowAppoint: false,
 				packType: 0,
 				notShow: 0,
-				car_info:{}
+				car_info: {}
 			};
 		},
 		/**
 		 * 生命周期函数--监听页面加载
 		 */
 		onLoad: function(options) {
-			this.notShow = options.notShow?options.notShow:1
+			this.notShow = options.notShow ? options.notShow : 1
 			this.dev_id = options.dev_id
 			const storedLocation = uni.getStorageSync('user_current_location');
-			this.car_info =  uni.getStorageSync('car_info') || {};
+			this.car_info = uni.getStorageSync('car_info') || {};
 			const car_list = uni.getStorageSync('user_car_list') || null
 			this.license_plate_number = car_list ? car_list.plate_number : ''
 			const me = this
@@ -224,7 +227,7 @@ import progressView from '@/component/progressView/progressView';
 				// this.getLocationAndSave();
 			}
 			// bluetooth.initBluetooth()
-			
+
 		},
 		/**
 		 * 生命周期函数--监听页面显示
@@ -238,9 +241,9 @@ import progressView from '@/component/progressView/progressView';
 					isModelCenter: false
 				})
 			},
-			clickPopPackageModel(e,notShow) {
+			clickPopPackageModel(e, notShow) {
 				// console.log(e.packType,notShow,'sadasd');
-				
+
 				// this.notShow = notShow?notShow:this.notShow
 				// if ((e.packType === 0&&this.notShow==1) || e.packType === 2) {
 				// 	this.setData({
@@ -282,13 +285,46 @@ import progressView from '@/component/progressView/progressView';
 				})
 			},
 
+			//计算电池数量
+			deduplicateAndCountByMainAndChild(data) {
+				// 1. 统计次数:根据 main_tag_code 和 child_tag_code(如果存在)
+				const countMap = {};
+
+				data.forEach(item => {
+					// 如果 child_tag_code 为空,则只根据 main_tag_code 统计
+					const key = item.child_tag_code ?
+						`${item.main_tag_code}_${item.child_tag_code}` :
+						item.main_tag_code;
+
+					countMap[key] = (countMap[key] || 0) + 1;
+				});
+
+				// 2. 去重并添加 num 字段
+				const seen = new Set();
+				return data.filter(item => {
+					// 生成去重键(与统计时逻辑一致)
+					const key = item.child_tag_code ?
+						`${item.main_tag_code}_${item.child_tag_code}` :
+						item.main_tag_code;
+
+					// 如果是第一次出现,添加 num 并保留
+					if (!seen.has(key)) {
+						seen.add(key);
+						item.num = countMap[key]; // 直接修改原对象(如需要深拷贝可改用 { ...item, num })
+						return true;
+					}
+					// 否则过滤掉
+					return false;
+				});
+			},
+
 			async loadCabinetDetail() {
 				//获取机柜信息
 				const that = this
 				var _can_num = 0
 				let resp = await http.postApi(config.API_CABINET_INFO, {
-					car_sn:this.car_info.car_sn,
-					dev_id:this.dev_id,
+					car_sn: this.car_info.car_sn,
+					dev_id: this.dev_id,
 					longitude: this.myLocation.longitude,
 					latitude: this.myLocation.latitude,
 				})
@@ -301,7 +337,7 @@ import progressView from '@/component/progressView/progressView';
 					// 		_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
@@ -313,13 +349,21 @@ import progressView from '@/component/progressView/progressView';
 					var box_list = resp.data.data.boxList
 					// box_list = cabinetDetailImpl.getBoxReservation(box_list, reservation_List)
 					console.log(box_list, "box_list")
+					let tagList = []
+					box_list.map(item => {
+						if (item.tag_info) {
+							tagList.push(item.tag_info)
+						}
+
+					})
+					tagList = this.deduplicateAndCountByMainAndChild(tagList)
 					that.setData({
 						reservation_info: reservation_List,
 						isWorkTimer: isWorkTimer,
-						tagList: resp.data.data.tagList,
+						tagList,
 						cabinetInfo: cabinetInfo,
 						batteryList: box_list,
-						listData:resp.data.data,
+						listData: resp.data.data,
 						online_status: cabinetInfo.online_status,
 						can_battery_num: resp.data.data.can_exchange_num,
 						shop_image: JSON.parse(cabinetInfo.imgs.split(',')) || []
@@ -419,6 +463,6 @@ import progressView from '@/component/progressView/progressView';
 	};
 </script>
 
-<style  >
+<style>
 	@import './cabinetDetail.css';
 </style>

+ 8 - 5
pages/order/order.vue

@@ -205,6 +205,7 @@
 		 * 生命周期函数--监听页面加载
 		 */
 		onLoad: function(options) {
+			this.selectOrderType = options.selectOrderType == 0 ? 0 : 1
 			const locationStr = uni.getStorageSync('user_current_location');
 			if (locationStr) {
 				this.myLocation = locationStr;
@@ -219,11 +220,13 @@
 			this.car_info = uni.getStorageSync('car_info') || {};
 			this.page = 1
 			this.hireOrderList = []
-			if(this.selectOrderType == 1){
-				this.bindHireOrderList()
-			}else{
-				this.bindExchangeOrderFn()
-			}
+			setTimeout(()=> {
+				if(this.selectOrderType == 1){
+					this.bindHireOrderList()
+				}else{
+					this.bindExchangeOrderFn()
+				}
+			}, 300);
 		},
 
 		// 分享给好友

+ 1 - 1
pages/orderStatus/orderStatus.vue

@@ -287,7 +287,7 @@
 		<returnCar :isShowReturnCar="isShowReturnCar" @closeShowReturnCarBtn="()=>isShowReturnCar=false"
 			@navStoreBtn="navStoreBtn" @immediatelyReturnBtn="immediatelyReturnBtn" />
 
-		<carPlan @payToOrder='payReturn' v-if="showCarPlan" @changeSelectType="changeSelectType"
+		<carPlan :isBuy='false' @payToOrder='payReturn' v-if="showCarPlan" @changeSelectType="changeSelectType"
 			@closeShowMore="showCarPlan = false" :params="params" :selectType="selectType" />
 
 		<PayTypeModel @closeShow="()=>isShowToBuy=false" @payToOrder="payToOrder" :free_price="totalPrice"