<template>
|
<view>
|
<wd-icon name="scan" color="#999" size="18px" @click="openScan" />
|
<Scan ref="scanRef" />
|
<!-- 弹窗 -->
|
<wd-toast />
|
</view>
|
</template>
|
|
<script setup lang="ts">
|
import Scan from "@/components/scan/index.vue";
|
import { useUserStore } from "@/store/modules/user";
|
import reportApi from "@/api/work/report";
|
import { useToast } from "wot-design-uni";
|
|
defineOptions({
|
name: "工时发送",
|
});
|
|
const scanRef = ref();
|
const userStore = useUserStore();
|
const userInfo: any = computed(() => userStore.userInfo);
|
const toast = useToast();
|
|
const openScan = () => {
|
scanRef.value.triggerScan();
|
};
|
|
const getScanCode = async () => {
|
const { code } = await reportApi.sendWorkTime({
|
userName: userInfo.value.userName,
|
});
|
if (code == 200) {
|
toast.success("扫码成功");
|
}
|
};
|
|
onLoad(() => {
|
// 开启广播监听事件
|
uni.$on("scan", getScanCode);
|
});
|
onUnload(() => {
|
// 开启广播监听事件
|
uni.$off("scan", getScanCode);
|
});
|
</script>
|
|
<style lang="scss" scoped></style>
|