This commit is contained in:
Putoo
2026-05-30 17:32:27 +08:00
parent bd1535aee9
commit f8d4a28d53
79 changed files with 1369 additions and 134 deletions

View File

@@ -0,0 +1,153 @@
<template>
<div class="content">
<Acheak @click="ChangeBag('0')" :on-value="type" on-cheak="0">好友</Acheak>|<Acheak @click="ChangeBag('1')"
:on-value="type" on-cheak="1">密友</Acheak>|<Acheak @click="ChangeBag('2')" :on-value="type" on-cheak="2">
师徒</Acheak>|<Acheak @click="ChangeBag('3')" :on-value="type" on-cheak="3">仇人</Acheak>
</div>
<div class="content">
在线/所有({{ online }}/{{ total }})<Abutton @click="Refresh">刷新</Abutton>
</div>
<div class="content" v-if="type == '0' || type == '1'">
<div class="item" v-for="(item, index) in data" :key="index">
{{ PageExtend.GetPageIndex(currentPage, 10, index + 1) }}.
{{ item.isOnline == 1 ? "[在线]" : "[离线]" }}
<GameUser :data="item.user" :show-icon="1"></GameUser>
<span v-if="type == '0'">
({{ item.user.lev }},{{ item.cityName }}{{ item.mapName }})
<Abutton @click="FriendHandle(item.user.userNo)">[×]</Abutton>
</span>
<span v-else>
(亲密度:{{ item.near }})
</span>
</div>
<span v-if="data.length == 0">
{{ type == '0' ? "暂无好友." : "暂无密友." }}
</span>
</div>
<div class="content" v-if="type == '2'">
<span v-if="data.length == 0">暂无师徒.</span>
</div>
<div class="content" v-if="type == '3'">
<div class="item" v-for="(item, index) in data" :key="index">
{{ PageExtend.GetPageIndex(currentPage, 10, index + 1) }}.
{{ item.isOnline == 1 ? "[在线]" : "[离线]" }}
<GameUser :data="item.user" :show-icon="1"></GameUser>
<span>
({{ item.user.lev }},{{ item.cityName }}{{ item.mapName }})
<Abutton @click="DeleteEnemy(item.user.userNo)">[×]</Abutton>
</span>
</div>
<span v-if="data.length == 0">暂无仇人.</span>
</div>
<div class="content">
<Pagination :currentPage="currentPage" :limit="10" :total="total" @pageChange="handlePageChange" />
</div>
<div class="clear"></div>
<div class="content">
<Abar href="/user/friend/search">添加好友</Abar>
</div>
</template>
<script setup lang="ts">
interface friendStorage {
type: string
page: number
}
definePageMeta({
layout: layout.default,
middleware: 'page-loading'
})
const currentPage = ref<number>(1);
const total = ref<number>(0);
const data = ref<Array<any>>([]);
const type = ref('0');
const online = ref(0);
onMounted(async () => {
try {
let localData = LocalStorageExtend.Get<friendStorage>("FriendCache");
if (localData != null) {
type.value = localData.type;
currentPage.value = localData.page;
}
await BindData();
}
finally {
PageLoading.Close();
}
})
const BindData = async (): Promise<void> => {
let result = await RelationService.GetRelation(Number(type.value), currentPage.value);
if (result.code == 0) {
data.value = result.data.data;
total.value = result.data.total;
online.value = result.data.online;
console.log(result);
//存储请求参数
let addLocalData: friendStorage = { type: type.value, page: currentPage.value };
LocalStorageExtend.Set("FriendCache", addLocalData);
}
else {
MessageExtend.ShowDialog("提示", result.msg);
}
};
/**切换背包 */
const ChangeBag = async (_type: string): Promise<void> => {
type.value = _type;
await BindData();
}
/**刷新 */
const Refresh = async (): Promise<void> => {
MessageExtend.LoadingToast("刷新中...");
currentPage.value = 1;
await BindData();
MessageExtend.LoadingClose();
PageExtend.ScrollToTop();
}
/**翻页 */
const handlePageChange = async (page: number): Promise<void> => {
currentPage.value = page;
await BindData();
};
const FriendHandle = async (no: string): Promise<void> => {
MessageExtend.ShowConfirmDialogAsyc("好友操作", `您确定要删除好友吗?`, async () => {
let result = await RelationService.FriendHandle(no);
if (result.code == 0) {
await BindData();
MessageExtend.Notify(result.msg, "success");
}
else {
MessageExtend.Notify(result.msg, "danger");
}
return true;
});
}
const DeleteEnemy = async (no: string): Promise<void> => {
MessageExtend.ShowConfirmDialogAsyc("关系操作", `您确定要删除仇人吗?`, async () => {
let result = await RelationService.DeleteEnemy(no);
if (result.code == 0) {
await BindData();
MessageExtend.Notify(result.msg, "success");
}
else {
MessageExtend.Notify(result.msg, "danger");
}
return true;
});
}
</script>

View File

@@ -0,0 +1,50 @@
<template>
<div class="content">
查找好友
</div>
<div class="content">
<div class="common">
<div class="input">
玩家ID:<input name="no" type="number" placeholder="输入玩家ID" maxlength="12" class="ipt" v-model="no" />
</div>
<div class="input">
<input type="button"" class=" btn btn-danger" value="查找玩家" @click="search" />
</div>
</div>
</div>
<div class="clear"></div>
</template>
<script setup lang="ts">
definePageMeta({
layout: layout.default,
middleware: middleware.loading
})
const no = ref('');
const search = async (): Promise<void> => {
if (no.value == null || no.value == '') {
MessageExtend.ShowToast("玩家ID不能为空!", "default");
return;
}
MessageExtend.LoadingToast("查找中...");
let result = await UserService.GetUserBaseInfo(no.value);
MessageExtend.LoadingClose();
if (result.code == 0) {
PageExtend.Redirect("/user/user?no=" + result.data.userNo);
}
else {
MessageExtend.ShowDialog("查找玩家", result.msg);
}
}
onMounted(async () => {
try {
}
finally {
PageLoading.Close();
}
})
</script>