This commit is contained in:
bb_pan 2025-07-19 17:13:47 +08:00
parent dc44e00aec
commit ce65d63713
2 changed files with 75 additions and 0 deletions

View File

@ -0,0 +1,67 @@
<template>
<div>
<!-- <button @click="openQrCode">打开扫码页面</button> -->
<div v-if="receivedData">
<h3>接收到的数据:</h3>
<pre>{{ receivedData }}</pre>
</div>
</div>
</template>
<script>
export default {
name: 'ScanPageCommunication',
data() {
return {
bWindow: null,
receivedData: null,
checkCloseInterval: null
};
},
methods: {
openQrCode() {
//
if (this.bWindow && !this.bWindow.closed) {
this.bWindow.close();
}
//
this.bWindow = window.open('https://27.106.98.29:8443/testqrCode.html', '_blank');
//
this.checkCloseInterval = setInterval(() => {
if (this.bWindow.closed) {
clearInterval(this.checkCloseInterval);
console.log('B页面已关闭');
}
}, 500);
},
handleMessage(event) {
//
if (this.bWindow && event.source === this.bWindow) {
this.receivedData = event.data;
console.log('收到来自B页面的数据:', event.data);
}
uni.showModal({
title: '收到来自B页面的数据',
content: event.data,
duration: 2000,
});
}
},
mounted() {
window.addEventListener('message', this.handleMessage);
},
beforeDestroy() {
window.removeEventListener('message', this.handleMessage);
if (this.checkCloseInterval) {
clearInterval(this.checkCloseInterval);
}
}
};
</script>
<style scoped>
/* 样式按需自定义 */
</style>

View File

@ -166,6 +166,7 @@
</scroll-view> </scroll-view>
<view class="outbound-btn" @tap="onHandleOutbound"> 添加 </view> <view class="outbound-btn" @tap="onHandleOutbound"> 添加 </view>
</view> </view>
</template> </template>
<script setup> <script setup>
@ -178,6 +179,10 @@ import {
getMachine, getMachine,
} from '@/services/materialsStation' } from '@/services/materialsStation'
import ScanQrCode from '@/pages/devicesSearch/ScanQrCode.vue' import ScanQrCode from '@/pages/devicesSearch/ScanQrCode.vue'
const isOpenQrCode = ref(false)
const openQrCodeRef = ref(null)
const scanQrCodeRef = ref(null) const scanQrCodeRef = ref(null)
const queryParams = ref({}) const queryParams = ref({})
const queryParamsTemp = ref({ const queryParamsTemp = ref({
@ -415,6 +420,9 @@ const scanStart = () => {
if (scanQrCodeRef.value) { if (scanQrCodeRef.value) {
scanQrCodeRef.value.scanQrCode() scanQrCodeRef.value.scanQrCode()
} }
// isOpenQrCode.value = true
// openQrCodeRef.value.openQrCode()
// console.log('🚀 ~ scanStart ~ openQrCodeRef.value:', openQrCodeRef.value)
} }
// RFID // RFID