i
This commit is contained in:
@@ -10,29 +10,43 @@
|
||||
|
||||
<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 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));
|
||||
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",
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
};
|
||||
@@ -41,7 +55,7 @@ const scanCode = () => {
|
||||
<style lang="scss">
|
||||
page {
|
||||
background-color: #f5f5f5;
|
||||
background-image: url("../../../static/admin/cancellation-header.png");
|
||||
background-image: url("~@/static/admin/cancellation-header.png");
|
||||
background-repeat: no-repeat;
|
||||
background-size: 100% 30%;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user