This commit is contained in:
2023-08-15 13:30:58 +08:00
parent c081f0fc29
commit b444858bda
30 changed files with 984 additions and 3 deletions

View File

@@ -0,0 +1,61 @@
<template>
<view>
<view class="card">
<nut-button block type="primary" @click="scanCode"
>扫码核销</nut-button
>
</view>
</view>
</template>
<script setup lang="ts">
import Taro from "@tarojs/taro";
// url参数转对象
const urlParse = (url: string) => {
const obj: any = {};
const reg = /[?&][^?&]+=[^?&]+/g;
const arr = url.match(reg);
if (arr) {
arr.forEach((item) => {
const tempArr = item.substring(1).split("=");
const key = decodeURIComponent(tempArr[0]);
const val = decodeURIComponent(tempArr[1]);
obj[key] = val;
});
}
return obj;
};
const scanCode = () => {
Taro.scanCode({
onlyFromCamera: true,
scanType: ["qrCode"],
success: (res) => {
console.log(urlParse(res.result));
},
});
};
</script>
<style lang="scss">
page {
background-color: #f5f5f5;
background-image: url("../../../static/admin/cancellation-header.png");
background-repeat: no-repeat;
background-size: 100% 30%;
}
.card {
width: 80%;
height: 300px;
box-sizing: border-box;
background-color: #fff;
margin: 300px auto;
border-radius: 10px;
display: flex;
align-items: center;
justify-content: center;
padding: 0 100px;
}
</style>