Files
shoot-miniprograms/src/components/Header.vue

74 lines
1.4 KiB
Vue
Raw Normal View History

2025-05-01 21:38:35 +08:00
<script setup>
2025-06-15 22:01:06 +08:00
import { ref, onMounted } from "vue";
2025-06-08 13:55:09 +08:00
import useStore from "@/store";
import { simulShootAPI } from "@/apis";
import { storeToRefs } from "pinia";
const store = useStore();
const { device } = storeToRefs(store);
2025-06-15 22:01:06 +08:00
const isIos = ref(true);
2025-06-08 13:55:09 +08:00
2025-06-17 16:42:53 +08:00
const props = defineProps({
2025-05-01 21:38:35 +08:00
title: {
type: String,
default: "",
},
2025-06-17 16:42:53 +08:00
onBack: {
type: Function,
default: null,
},
2025-05-01 21:38:35 +08:00
});
2025-06-08 13:55:09 +08:00
const simulShoot = async () => {
if (device.value.deviceId) {
await simulShootAPI(device.value.deviceId);
}
};
2025-06-15 22:01:06 +08:00
2025-06-17 16:42:53 +08:00
const onClick = () => {
if (props.onBack) props.onBack();
else uni.navigateBack();
};
2025-06-15 22:01:06 +08:00
onMounted(() => {
const deviceInfo = uni.getDeviceInfo();
isIos.value = deviceInfo.osName === "ios";
});
2025-05-01 21:38:35 +08:00
</script>
<template>
2025-06-15 22:01:06 +08:00
<view class="container" :style="{ paddingTop: isIos ? '35px' : '25px' }">
2025-06-17 16:42:53 +08:00
<view class="back-btn" @click="onClick">
2025-05-01 21:38:35 +08:00
<image src="../static/back.png" mode="widthFix" />
2025-06-17 16:42:53 +08:00
</view>
2025-05-01 21:38:35 +08:00
<text>{{ title }}</text>
2025-06-15 15:53:57 +08:00
<view class="simul" @click="simulShoot">模拟射箭</view>
2025-05-01 21:38:35 +08:00
</view>
</template>
<style scoped>
.container {
display: flex;
justify-content: flex-start;
align-items: center;
width: 72vw;
height: 60px;
padding-left: 15px;
}
.back-btn {
display: flex;
align-items: center;
}
.back-btn > image {
width: 22px;
height: 22px;
margin-right: 10px;
}
.container > text {
color: #fff;
}
2025-06-08 13:55:09 +08:00
.simul {
color: #fff;
margin-left: 20px;
}
2025-05-01 21:38:35 +08:00
</style>