Browse Source

扫码样式调整

lwx_v5
liwenxuan 11 months ago
parent
commit
efa23e241c
  1. 23
      src/views/home/index.vue
  2. 85
      src/views/home/scanQrCode.vue

23
src/views/home/index.vue

@ -254,26 +254,27 @@ const openNews = (val:any,name:string) => {
</script> </script>
<template> <template>
<div> <div >
<div class="mt-4"> <div class="mt-4">
<div class="mt-4">
<div style="display: flex; justify-content: center;"> <div style="display: flex; justify-content: center;margin-top: 5px;">
<el-input <el-input
style="width: 92%;" style="width: 98%;"
placeholder="请输入搜索内容" placeholder="请输入搜索内容"
class="input-with-select" class="input-with-select"
> >
<template #prepend> <template #prepend>
<el-button class="footSvg " ><SvgIcon icon-class="search" size="18" /></el-button> <el-button class="footSvg " ><SvgIcon icon-class="search" size="18" /></el-button>
</template> </template>
<template #append>
<div style="display: flex; justify-content: center; max-width: 15px;"><el-icon :size="20" style="margin-top: 15%;" @click="router.push('/scanQrCode')"><SetUp /></el-icon></div>
</template>
</el-input> </el-input>
<el-dropdown placement="top-end"> <!-- <el-dropdown placement="top-end">
<!-- <el-button> topEnd </el-button> -->
<!-- <span split-button style="margin-top: 1.8%; width: 8%; border: 0px;background-color: #F5F5F5;" ><Plus /></span> -->
<span class="el-dropdown-link" > <span class="el-dropdown-link" >
<!-- <el-icon class="el-icon--right"><arrow-down /></el-icon> -->
<el-icon :size="22" style="margin-top: 26%; margin-left: 7%; background-color: #F5F5F5; "> <el-icon :size="22" style="margin-top: 26%; margin-left: 7%; background-color: #F5F5F5; ">
<CirclePlus /> <CirclePlus />
</el-icon> </el-icon>
@ -284,11 +285,11 @@ const openNews = (val:any,name:string) => {
</el-dropdown-menu> </el-dropdown-menu>
</template> </template>
</el-dropdown> </el-dropdown> -->
</div> </div>
</div>
<!-- --> <!-- -->
</div> </div>
<el-scrollbar ref="scrollBox" class="indexBody" @scroll="onHandleScroll"> <el-scrollbar ref="scrollBox" class="indexBody" @scroll="onHandleScroll">
@ -382,7 +383,7 @@ const openNews = (val:any,name:string) => {
<style lang='scss' scoped> <style lang='scss' scoped>
.indexBody{ .indexBody{
width:100%; width:100%;
height: calc(100vh - 97px); height: calc(100vh - 99px);
padding: 0 5px 0px 5px; padding: 0 5px 0px 5px;
.cardContBox{ .cardContBox{
display: flex; display: flex;

85
src/views/home/scanQrCode.vue

@ -2,33 +2,60 @@
<div class="scanCode"> <div class="scanCode">
<div class="container"> <div class="container">
<div class="qrcode"> <div class="qrcode">
<div class="btn">
<div class="left-back" style="float: left;">
<el-icon @click="clickBack" style="border: white solid 0px;">
<Back />
</el-icon>
</div>
<!-- <div class="right-file">
<van-uploader
v-model="fileList"
:preview-image="false"
:after-read="dealSelectFiles"
>
<el-icon><Picture /></el-icon>
</van-uploader>
</div> -->
</div>
<div id="reader"></div> <div id="reader"></div>
</div> </div>
</div> </div>
<div class="btn"> <!--<div class="btn">
<div class="left-back"> <div class="left-back">
<van-icon name="arrow-left" @click="clickBack" />
<el-icon @click="clickBack">
<Back />
</el-icon>
</div> </div>
<div class="right-file"> <div class="right-file">
<van-uploader <van-uploader
v-model="fileList" v-model="fileList"
:preview-image="false" :preview-image="false"
:after-read="dealSelectFiles" :after-read="dealSelectFiles"
> >
<van-icon name="photo-o" <el-icon><Picture /></el-icon>
/></van-uploader> </van-uploader>
</div> </div>
</div> </div> -->
</div> </div>
</template> </template>
<script> <script setup>
import { reactive } from "vue"; import { reactive } from "vue";
import { defineComponent, toRefs, onMounted, onUnmounted } from "vue"; import { defineComponent, toRefs, onMounted, onUnmounted } from "vue";
import { Html5Qrcode } from "html5-qrcode"; import { Html5Qrcode } from "html5-qrcode";
import { useRouter } from 'vue-router'
const router = useRouter()
export default defineComponent({
setup() {
const state = reactive({ const state = reactive({
html5QrCode: null, html5QrCode: null,
fileList: [], fileList: [],
@ -42,6 +69,7 @@
qrbox: { width: 250, height: 250 }, qrbox: { width: 250, height: 250 },
}, },
(decodedText, decodedResult) => { (decodedText, decodedResult) => {
window.location.href = decodedText;
console.log("decodedText", decodedText); console.log("decodedText", decodedText);
console.log("decodedResult", decodedResult); console.log("decodedResult", decodedResult);
} }
@ -51,6 +79,7 @@
let message = ""; // let message = ""; //
if (typeof err == "string") { if (typeof err == "string") {
message = "二维码识别失败!"; message = "二维码识别失败!";
alert(message)
} else { } else {
if (err.name == "NotAllowedError") { if (err.name == "NotAllowedError") {
message = "您需要授予相机访问权限!"; message = "您需要授予相机访问权限!";
@ -71,9 +100,14 @@
if (err.name == "StreamApiNotSupportedError") { if (err.name == "StreamApiNotSupportedError") {
message = "此浏览器不支持流API!"; message = "此浏览器不支持流API!";
} }
alert(message)
} }
}); });
}; };
const clickBack = () => {
//console.log(1)
router.back();
}
const getCameras = () => { const getCameras = () => {
Html5Qrcode.getCameras() Html5Qrcode.getCameras()
.then((devices) => { .then((devices) => {
@ -119,17 +153,13 @@
}); });
onUnmounted(() => { onUnmounted(() => {
// //
if (state.html5QrCode.isScanning) { if (state.html5QrCode&&state.html5QrCode.isScanning) {
stop(); stop();
} }
}); });
return {
...toRefs(state),
getCameras,
dealSelectFiles,
};
},
});
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@ -140,26 +170,35 @@
background: rgba(0, 0, 0); background: rgba(0, 0, 0);
} }
.container { .container {
height: 90vh; height: 100vh;
position: relative; position: relative;
width: 100%; width: 100%;
/* border: red solid 7px; */
} }
.qrcode { .qrcode {
height: 100%; height: 100%;
/* width: 100%;
border: yellow solid 7px; */
} }
#reader { #reader {
top: 50%; display: block;
height: 95.4vh;
/* top: 50%;
left: 0; left: 0;
transform: translateY(-50%); transform: translateY(-50%); */
/* border: yellow solid 1px; */
} }
.btn { .btn {
flex: 1; flex: 1;
padding: 3vw; padding-top: 2vw;
display: flex; display: flex;
justify-content: space-around; padding-left: 3vw;
color: #fff; color: #fff;
font-size: 8vw; font-size: 6vw;
align-items: flex-start; align-items: flex-start;
/* border: green solid 7px; */
} }
</style> </style>
Loading…
Cancel
Save