12121
This commit is contained in:
@@ -120,6 +120,9 @@ const BindData = async (map: string): Promise<void> => {
|
||||
console.log(result.data);
|
||||
|
||||
}
|
||||
else if (result.code == 103) {
|
||||
PageExtend.Redirect("/map/runing");
|
||||
}
|
||||
else {
|
||||
MessageExtend.ShowDialog("异常错误", result.msg);
|
||||
}
|
||||
|
||||
@@ -1 +1,75 @@
|
||||
<template></template>
|
||||
<template>
|
||||
<div class="content">
|
||||
请选择航线:<br>
|
||||
<div class="item" v-for="(item, index) in city" :key="index">
|
||||
{{ index + 1 }}.<Abutton @click="UserRunMap(item.cityId)">{{ item.cityName }}({{ item.distance }}海里)</Abutton>
|
||||
</div>
|
||||
<span v-if="city.length == 0">
|
||||
暂无海图.
|
||||
</span>
|
||||
</div>
|
||||
<div class="content">
|
||||
【
|
||||
<span v-for="item in area">
|
||||
<Acheak @click="ChangeCity(item.cityId)" :on-value="cityId.toString()" :on-cheak="item.cityId.toString()">
|
||||
{{ item.cityName }}</Acheak>
|
||||
</span>
|
||||
】
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
|
||||
definePageMeta({
|
||||
layout: layout.default,
|
||||
middleware: 'page-loading'
|
||||
})
|
||||
const area = ref<Array<any>>([]);
|
||||
const city = ref<Array<any>>([]);;
|
||||
const cityId = ref(0);
|
||||
onMounted(async () => {
|
||||
try {
|
||||
await BindData();
|
||||
}
|
||||
finally {
|
||||
PageLoading.Close();
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
|
||||
const BindData = async (): Promise<void> => {
|
||||
let npc = LocalStorageHelper.GetOnNpc();
|
||||
let result = await MapService.GetCityData(Number(npc), cityId.value);
|
||||
if (result.code == 0) {
|
||||
area.value = result.data.area;
|
||||
city.value = result.data.city;
|
||||
if (cityId.value == 0) {
|
||||
cityId.value = result.data.cityId;
|
||||
}
|
||||
}
|
||||
else {
|
||||
MessageExtend.ShowDialogEvent("提示", result.msg, () => {
|
||||
PageExtend.Redirect("/map");
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const ChangeCity = async (_cityId: number) => {
|
||||
cityId.value = _cityId;
|
||||
await BindData();
|
||||
}
|
||||
|
||||
const UserRunMap = async (_cityId: number) => {
|
||||
MessageExtend.LoadingToast("航行准备中...");
|
||||
let npc = LocalStorageHelper.GetOnNpc();
|
||||
let result = await MapService.UserRunMap(Number(npc), _cityId);
|
||||
MessageExtend.LoadingClose();
|
||||
if (result.code == 0) {
|
||||
PageExtend.RedirectTo("/map/runing");
|
||||
}
|
||||
else {
|
||||
MessageExtend.ShowToast(result.msg);
|
||||
}
|
||||
|
||||
}
|
||||
</script>
|
||||
104
Web/src/pages/map/runing.vue
Normal file
104
Web/src/pages/map/runing.vue
Normal file
@@ -0,0 +1,104 @@
|
||||
<template>
|
||||
<div class="content">
|
||||
<Abutton @click="Runing">航行</Abutton>.<Abutton @click="AutoRuning">{{ runState == 0 ? "自动航行" : "取消自动" }}
|
||||
</Abutton>.
|
||||
<Abutton @click="StopRun">取消</Abutton><br>
|
||||
航线:{{ data.onCity }} ⇒ {{ data.toCity }}<br>
|
||||
航距:{{ position }}/{{ distance - position }}/{{ distance }}海里<br>
|
||||
你可以:
|
||||
<span v-if="isShip == 1">
|
||||
<Abutton>钓鱼</Abutton>
|
||||
</span>
|
||||
<br>
|
||||
安全:{{ GameTool.GetSeaMapSafetyName(safety) }}<br>
|
||||
</div>
|
||||
<div class="content">
|
||||
您看到:<br>
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
|
||||
definePageMeta({
|
||||
layout: layout.default,
|
||||
middleware: 'page-loading'
|
||||
})
|
||||
const data = ref<any>({});
|
||||
const distance = ref(0);
|
||||
const position = ref(0);
|
||||
const isShip = ref(0);
|
||||
const safety = ref(0);
|
||||
const runState = ref(0);
|
||||
onMounted(async () => {
|
||||
try {
|
||||
await BindData();
|
||||
}
|
||||
finally {
|
||||
PageLoading.Close();
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
|
||||
const BindData = async (): Promise<void> => {
|
||||
let result = await MapService.GetUserRun();
|
||||
if (result.code == 0) {
|
||||
data.value = result.data;
|
||||
distance.value = result.data.distance;
|
||||
position.value = result.data.position;
|
||||
isShip.value = result.data.isShip;
|
||||
safety.value = result.data.safety;
|
||||
if (runState.value == 1) {
|
||||
setTimeout(async () => {
|
||||
await Runing();
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
}
|
||||
else if (result.code == 100) {
|
||||
PageExtend.RedirectTo("/map");
|
||||
}
|
||||
else {
|
||||
MessageExtend.ShowDialogEvent("提示", result.msg, () => {
|
||||
PageExtend.Redirect("/map");
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
const Runing = async () => {
|
||||
MessageExtend.LoadingToast("航行中...");
|
||||
let result = await MapService.UserMapRuning();
|
||||
MessageExtend.LoadingClose();
|
||||
if (result.code == 0) {
|
||||
await BindData();
|
||||
}
|
||||
else if (result.code == 100) {
|
||||
PageExtend.RedirectTo("/map");
|
||||
}
|
||||
else {
|
||||
MessageExtend.ShowDialog("提示", result.msg);
|
||||
}
|
||||
}
|
||||
|
||||
const StopRun = async () => {
|
||||
MessageExtend.ShowConfirmDialogAsyc("航海操作", `您确定要取消航行吗?`, async () => {
|
||||
let result = await MapService.StopUserRun();
|
||||
if (result.code == 0) {
|
||||
PageExtend.RedirectTo("/map");
|
||||
}
|
||||
else {
|
||||
MessageExtend.Notify(result.msg, "danger");
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
const AutoRuning = async () => {
|
||||
if (runState.value == 0) {
|
||||
runState.value = 1;
|
||||
await Runing()
|
||||
}
|
||||
else {
|
||||
runState.value = 0;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -26,7 +26,6 @@ definePageMeta({
|
||||
})
|
||||
const area = ref<Array<any>>([]);
|
||||
const city = ref<Array<any>>([]);;
|
||||
const copper = ref('');
|
||||
const tips = ref('');
|
||||
const cityId = ref(0);
|
||||
onMounted(async () => {
|
||||
|
||||
@@ -47,6 +47,38 @@ export class MapService {
|
||||
return await ApiService.Request("get", "/Map/Map/UserToMap", { npcId, cityId });
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户航海接口
|
||||
* GET /Map/Map/UserRunMap
|
||||
*/
|
||||
static async UserRunMap(npcId: number, cityId: number) {
|
||||
return await ApiService.Request("get", "/Map/Map/UserRunMap", { npcId, cityId });
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户航行状态
|
||||
* GET /Map/Map/GetUserRun
|
||||
*/
|
||||
static async GetUserRun() {
|
||||
return await ApiService.Request("get", "/Map/Map/GetUserRun");
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消航行
|
||||
* GET /Map/Map/StopUserRun
|
||||
*/
|
||||
static async StopUserRun() {
|
||||
return await ApiService.Request("get", "/Map/Map/StopUserRun");
|
||||
}
|
||||
|
||||
/**
|
||||
* UserMapRuning
|
||||
* GET /Map/Map/UserMapRuning
|
||||
*/
|
||||
static async UserMapRuning() {
|
||||
return await ApiService.Request("get", "/Map/Map/UserMapRuning");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取NPC相关信息
|
||||
* GET /Map/Map/GetNpcInfo
|
||||
|
||||
@@ -110,5 +110,21 @@ export class GameTool {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static GetSeaMapSafetyName(safety: number) {
|
||||
let result = "安全海域";
|
||||
switch (safety) {
|
||||
case 0:
|
||||
result = "安全海域";
|
||||
break;
|
||||
case 1:
|
||||
result = "普通海域";
|
||||
break;
|
||||
case 2:
|
||||
result = "危险海域";
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user