11
This commit is contained in:
@@ -16,20 +16,22 @@ export class StateHelper {
|
||||
static get userId() {
|
||||
return this.userStore.userId;
|
||||
}
|
||||
static SetToken(userId: string, token: string, refToken: string) {
|
||||
this.userStore.setToken(userId, token, refToken);
|
||||
}
|
||||
|
||||
static SetSid(sid: string) {
|
||||
this.userStore.setSid(sid);
|
||||
}
|
||||
|
||||
static OffOnline()
|
||||
{
|
||||
static OffOnline() {
|
||||
this.userStore.offOnline();
|
||||
}
|
||||
static get IsAccLogin(){
|
||||
static get IsAccLogin() {
|
||||
return this.userStore.isLoginAccount;
|
||||
}
|
||||
|
||||
static get IsLogin(){
|
||||
static get IsLogin() {
|
||||
return this.userStore.isLogin;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,11 @@
|
||||
export class MessageExtend {
|
||||
// 消息通知
|
||||
static Notify(message: any, type?: 'primary' | 'success' | 'danger' | 'warning') {
|
||||
showNotify({ type, message })
|
||||
showNotify({
|
||||
type: type,
|
||||
message: message,
|
||||
duration: 1500,
|
||||
});
|
||||
}
|
||||
|
||||
// 提示弹窗
|
||||
@@ -12,6 +16,16 @@ export class MessageExtend {
|
||||
showDialog({ title: title, message: message })
|
||||
}
|
||||
|
||||
static ShowDialogEvent(title: string, message: string, onConfirm?: () => void, confirmButtonText?: string) {
|
||||
showDialog({
|
||||
title: title,
|
||||
message: message,
|
||||
confirmButtonText: confirmButtonText || '确认'
|
||||
}).then(() => {
|
||||
onConfirm?.()
|
||||
});
|
||||
}
|
||||
|
||||
// 确认提示弹窗
|
||||
static ShowConfirmDialog(title: string, message: string, onConfirm?: () => void, onCancel?: () => void, confirmButtonText?: string) {
|
||||
showConfirmDialog({
|
||||
|
||||
@@ -14,10 +14,10 @@
|
||||
</div>
|
||||
<div style="margin-top:5px;">
|
||||
<div>
|
||||
➢<a :href='"http://m.twbar.cn/Regain/ToMain?openid=" + AccountInfo.openId'>返回探玩驿站</a>
|
||||
➢<a :href='"https://3g.fan/Regain/ToMain?openid=" + AccountInfo.openId'>返回探玩驿站</a>
|
||||
</div>
|
||||
<div>
|
||||
➸<a :href='"http://m.twbar.cn/Regain/ToBbs?openid=" + AccountInfo.openId + "&bbs=1146"'>游戏论坛</a>
|
||||
➸<a :href='"https://3g.fan/Regain/ToBbs?openid=" + AccountInfo.openId + "&bbs=1146"'>游戏论坛</a>
|
||||
➸<a @click.stop="offOnline">退出游戏</a>
|
||||
</div>
|
||||
</div>
|
||||
@@ -30,8 +30,8 @@
|
||||
=====☆<Abar href="/area/my">我的区服</Abar>☆=====
|
||||
</div>
|
||||
<div class="content">
|
||||
<div class="item">
|
||||
<Abar href="/">✧【1区】新手村✰村长(男)</Abar>
|
||||
<div class="item" v-for="(item, index) in userData" :key="index">
|
||||
<a @click="loginGame(item.userId)">【{{ item.areaId }}区】{{ item.nick }}({{ (item.sex == null||item.sex=='') ? "未知" : item.sex }})</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -41,7 +41,7 @@
|
||||
</div>
|
||||
<div class="content">
|
||||
<div class="item" v-for="(item, index) in areaData" :key="index">
|
||||
✧<Abar :href='"/login/register?id=" + item.areaId'>({{ item.areaId }}区){{ item.name }}</Abar>
|
||||
✧<a @click="registerGame(item.areaId)">({{ item.areaId }}区){{ item.name }}</a>
|
||||
{{ item.status == 1 ? "(推荐)" : "(繁忙)" }}
|
||||
</div>
|
||||
<span v-if="areaData.length == 0">暂无区服.</span>
|
||||
@@ -49,7 +49,7 @@
|
||||
</div>
|
||||
|
||||
<div class="title">
|
||||
=====☆<Abar href="/news/">官方公告</Abar>☆=====
|
||||
=====☆<Abar href="/news/">官方公告</Abar>☆=====
|
||||
</div>
|
||||
<div>
|
||||
<div class="item" v-for="(item, index) in noticeData" :key="index">
|
||||
@@ -64,7 +64,7 @@
|
||||
<div class="content">
|
||||
<Abar href="/customer">客服</Abar>.
|
||||
<Abar href="/customer/about">关于</Abar>.
|
||||
<Abar href="/customer/cooperation">合作</Abar>
|
||||
<Abar href="/customer/cooperation">合作</Abar>
|
||||
</div>
|
||||
<div class="foot">
|
||||
<div class="timeService">
|
||||
@@ -85,50 +85,7 @@ const noticeData = ref<Array<any>>([]);
|
||||
const isOnline = ref(false);
|
||||
const OnCount = ref(0);
|
||||
const AccountInfo = ref<any>();
|
||||
|
||||
const Initialize = async (): Promise<void> => {
|
||||
var result = await PubService.GetMain(StateHelper.Sid);
|
||||
if (result.code == 0) {
|
||||
isOnline.value = result.data.isOnline;
|
||||
if (isOnline.value == false) {
|
||||
StateHelper.OffOnline();
|
||||
}
|
||||
areaData.value = result.data?.area;
|
||||
noticeData.value = result.data.notice;
|
||||
OnCount.value = result.data.onCount;
|
||||
AccountInfo.value = result.data.account;
|
||||
}
|
||||
else {
|
||||
MessageExtend.ShowToast(result.msg, "fail");
|
||||
}
|
||||
};
|
||||
|
||||
//退出登录
|
||||
const offOnline = async () => {
|
||||
MessageExtend.ShowConfirmDialog("退出游戏", "您确定要退出游戏吗?", async () => {
|
||||
var result = await PubService.GetMain(StateHelper.Sid);
|
||||
if (result.code == 0) {
|
||||
StateHelper.OffOnline();
|
||||
isOnline.value = false;
|
||||
MessageExtend.ShowToast("退出成功!", "success");
|
||||
}
|
||||
else {
|
||||
MessageExtend.ShowToast(result.msg, "fail");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
const login = async (code: string): Promise<void> => {
|
||||
var result = await LoginService.TwLogin(code);
|
||||
console.log(result);
|
||||
if (result.code == 0) {
|
||||
StateHelper.SetSid(result.data.token);
|
||||
await Initialize();
|
||||
}
|
||||
else {
|
||||
MessageExtend.ShowToast(result.msg, "default");
|
||||
}
|
||||
}
|
||||
const userData = ref<Array<any>>([]);
|
||||
|
||||
onMounted(async () => {
|
||||
try {
|
||||
@@ -146,4 +103,72 @@ onMounted(async () => {
|
||||
PageLoading.Close();
|
||||
}
|
||||
})
|
||||
|
||||
/**初始化数据 */
|
||||
const Initialize = async (): Promise<void> => {
|
||||
let result = await PubService.GetMain(StateHelper.Sid);
|
||||
if (result.code == 0) {
|
||||
isOnline.value = result.data.isOnline;
|
||||
if (isOnline.value == false) {
|
||||
StateHelper.OffOnline();
|
||||
}
|
||||
areaData.value = result.data?.area;
|
||||
noticeData.value = result.data.notice;
|
||||
OnCount.value = result.data.onCount;
|
||||
AccountInfo.value = result.data.account;
|
||||
userData.value = result.data.userData;
|
||||
}
|
||||
else {
|
||||
MessageExtend.ShowToast(result.msg, "fail");
|
||||
}
|
||||
};
|
||||
|
||||
/**自动登录 */
|
||||
const login = async (code: string): Promise<void> => {
|
||||
let result = await LoginService.TwLogin(code);
|
||||
console.log(result);
|
||||
if (result.code == 0) {
|
||||
StateHelper.SetSid(result.data.token);
|
||||
await Initialize();
|
||||
}
|
||||
else {
|
||||
MessageExtend.ShowToast(result.msg, "default");
|
||||
}
|
||||
}
|
||||
|
||||
/**退出登录 */
|
||||
const offOnline = async () => {
|
||||
MessageExtend.ShowConfirmDialog("退出游戏", "您确定要退出游戏吗?", async () => {
|
||||
let result = await PubService.GetMain(StateHelper.Sid);
|
||||
if (result.code == 0) {
|
||||
StateHelper.OffOnline();
|
||||
isOnline.value = false;
|
||||
MessageExtend.ShowToast("退出成功!", "success");
|
||||
}
|
||||
else {
|
||||
MessageExtend.ShowToast(result.msg, "fail");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**登录到游戏 */
|
||||
const loginGame = async (gameId: string): Promise<void> => {
|
||||
alert(gameId)
|
||||
};
|
||||
|
||||
/**注册游戏 */
|
||||
const registerGame = async (area: number): Promise<void> => {
|
||||
let result = await LoginService.Register(StateHelper.Sid, area);
|
||||
if (result.code == 0) {
|
||||
StateHelper.SetToken(result.data.userId, result.data.token, result.data.refToken);
|
||||
PageExtend.Redirect("/login/register");
|
||||
}
|
||||
else {
|
||||
MessageExtend.ShowDialog("注册角色", result.msg);
|
||||
}
|
||||
}
|
||||
|
||||
/**辅助方法 */
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
@@ -27,12 +27,10 @@ const data = ref<Array<any>>([]);
|
||||
const handlePageChange = async (page: number): Promise<void> => {
|
||||
currentPage.value = page;
|
||||
await BindData();
|
||||
console.log('跳转到第', page, '页');
|
||||
};
|
||||
|
||||
const BindData = async (): Promise<void> => {
|
||||
var result = await PubService.GetNoticeData(currentPage.value, 10);
|
||||
console.log(result);
|
||||
const BindData = async (): Promise<void> => {
|
||||
var result = await PubService.GetNoticeData(currentPage.value, 10);
|
||||
if (result.code == 0) {
|
||||
data.value = result.data.data;
|
||||
totalPages.value = result.data.total;
|
||||
|
||||
@@ -1 +1,51 @@
|
||||
<template></template>
|
||||
<template>
|
||||
<div class="content">
|
||||
<Abar href="/news/">官方公告</Abar>>详情
|
||||
</div>
|
||||
<div class="content">
|
||||
<div class="common">
|
||||
[标题]:<strong>{{ noticeData.title }}</strong>
|
||||
</div>
|
||||
<div class="common">
|
||||
[时间]: {{noticeData.addTime}}
|
||||
</div>
|
||||
<div class="common" v-html="noticeData.sign"></div>
|
||||
</div>
|
||||
<div class="content">
|
||||
<Abar href="/news/">返回公告列表</Abar>
|
||||
</div>
|
||||
<Abar href="/">返回游戏首页</Abar>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
|
||||
definePageMeta({
|
||||
layout: layout.empty,
|
||||
middleware: 'page-loading'
|
||||
})
|
||||
let noticeData = ref<any>({});
|
||||
|
||||
const BindData = async (): Promise<void> => {
|
||||
var noticeId = PageExtend.QueryString("id");
|
||||
var result = await PubService.GetNoticeInfo(noticeId);
|
||||
if (result.code == 0) {
|
||||
noticeData.value = result.data;
|
||||
}
|
||||
else {
|
||||
MessageExtend.ShowDialogEvent("提示", "公告不存在!", () => {
|
||||
PageExtend.Redirect("/news/");
|
||||
}, "我知道了");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
onMounted(async () => {
|
||||
try {
|
||||
await BindData();
|
||||
}
|
||||
finally {
|
||||
PageLoading.Close();
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
</script>
|
||||
@@ -8,10 +8,18 @@ export class PubService {
|
||||
}
|
||||
|
||||
/**
|
||||
* GetNoticeData
|
||||
* 获取公告列表
|
||||
* GET /Pub/GetNoticeData
|
||||
*/
|
||||
static async GetNoticeData(page: number, limit: number) {
|
||||
return await ApiService.Request("get", "/Pub/GetNoticeData", { page, limit });
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取公告详情
|
||||
* GET /Pub/GetNoticeInfo
|
||||
*/
|
||||
static async GetNoticeInfo(id: string) {
|
||||
return await ApiService.Request("get", "/Pub/GetNoticeInfo", { id });
|
||||
}
|
||||
}
|
||||
@@ -26,4 +26,12 @@ export class LoginService {
|
||||
static async LoginOut(sid: string) {
|
||||
return await ApiService.Request("get", "/Login/LoginOut", { sid });
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册基础账号信息
|
||||
* GET /Login/Regist
|
||||
*/
|
||||
static async Register(sid: string, area: number) {
|
||||
return await ApiService.Request("get", "/Login/Register", { sid, area });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user