Files
jdt-user/src/pages/admin/verify/index.vue
2023-08-18 17:22:11 +08:00

76 lines
1.8 KiB
Vue

<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";
import { orderVerify } from "@/api/admin";
// 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: async (res) => {
try {
const data = await orderVerify({
oid: res.result,
});
Taro.showToast({
title: data.msg,
icon: "none",
});
} catch (error) {
Taro.showToast({
title: error.msg,
icon: "none",
});
}
},
});
};
</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>