公告接口完成接入
This commit is contained in:
parent
6da8993024
commit
e3aac30262
@ -11,6 +11,7 @@ GameObject:
|
|||||||
- component: {fileID: 768269564691424297}
|
- component: {fileID: 768269564691424297}
|
||||||
- component: {fileID: 768269564691424303}
|
- component: {fileID: 768269564691424303}
|
||||||
- component: {fileID: 768269564691424296}
|
- component: {fileID: 768269564691424296}
|
||||||
|
- component: {fileID: 1396186562}
|
||||||
m_Layer: 5
|
m_Layer: 5
|
||||||
m_Name: Announcement
|
m_Name: Announcement
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
@ -78,6 +79,21 @@ MonoBehaviour:
|
|||||||
m_FillOrigin: 0
|
m_FillOrigin: 0
|
||||||
m_UseSpriteMesh: 0
|
m_UseSpriteMesh: 0
|
||||||
m_PixelsPerUnitMultiplier: 1
|
m_PixelsPerUnitMultiplier: 1
|
||||||
|
--- !u!114 &1396186562
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 768269564691424298}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: b10c5aab2252acd4cb5fe9914dfc6d44, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
retbutton: {fileID: 0}
|
||||||
|
ClosureObj: {fileID: 0}
|
||||||
|
Content: {fileID: 6702361763452661266}
|
||||||
--- !u!1 &768269564704585520
|
--- !u!1 &768269564704585520
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -1216,6 +1232,14 @@ PrefabInstance:
|
|||||||
propertyPath: m_LocalEulerAnglesHint.z
|
propertyPath: m_LocalEulerAnglesHint.z
|
||||||
value: 0
|
value: 0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 5044707777241721125, guid: dac544bca4358514d949413f04b4421c, type: 3}
|
||||||
|
propertyPath: retbutton
|
||||||
|
value:
|
||||||
|
objectReference: {fileID: 1982229824339661807}
|
||||||
|
- target: {fileID: 5044707777241721125, guid: dac544bca4358514d949413f04b4421c, type: 3}
|
||||||
|
propertyPath: ClosureObj
|
||||||
|
value:
|
||||||
|
objectReference: {fileID: 768269564691424298}
|
||||||
m_RemovedComponents: []
|
m_RemovedComponents: []
|
||||||
m_SourcePrefab: {fileID: 100100000, guid: dac544bca4358514d949413f04b4421c, type: 3}
|
m_SourcePrefab: {fileID: 100100000, guid: dac544bca4358514d949413f04b4421c, type: 3}
|
||||||
--- !u!224 &1982229824339661804 stripped
|
--- !u!224 &1982229824339661804 stripped
|
||||||
@ -1223,3 +1247,14 @@ RectTransform:
|
|||||||
m_CorrespondingSourceObject: {fileID: 4894555910357792269, guid: dac544bca4358514d949413f04b4421c, type: 3}
|
m_CorrespondingSourceObject: {fileID: 4894555910357792269, guid: dac544bca4358514d949413f04b4421c, type: 3}
|
||||||
m_PrefabInstance: {fileID: 6372240730770466273}
|
m_PrefabInstance: {fileID: 6372240730770466273}
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
--- !u!114 &1982229824339661807 stripped
|
||||||
|
MonoBehaviour:
|
||||||
|
m_CorrespondingSourceObject: {fileID: 4894555910357792270, guid: dac544bca4358514d949413f04b4421c, type: 3}
|
||||||
|
m_PrefabInstance: {fileID: 6372240730770466273}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 0}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
@ -170,6 +170,7 @@ GameObject:
|
|||||||
- component: {fileID: 3658515979474970494}
|
- component: {fileID: 3658515979474970494}
|
||||||
- component: {fileID: 3658515979474970464}
|
- component: {fileID: 3658515979474970464}
|
||||||
- component: {fileID: 3658515979474970465}
|
- component: {fileID: 3658515979474970465}
|
||||||
|
- component: {fileID: 3824674125751036598}
|
||||||
m_Layer: 5
|
m_Layer: 5
|
||||||
m_Name: Announcement_newitem
|
m_Name: Announcement_newitem
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
@ -237,6 +238,20 @@ MonoBehaviour:
|
|||||||
m_FillOrigin: 0
|
m_FillOrigin: 0
|
||||||
m_UseSpriteMesh: 0
|
m_UseSpriteMesh: 0
|
||||||
m_PixelsPerUnitMultiplier: 1
|
m_PixelsPerUnitMultiplier: 1
|
||||||
|
--- !u!114 &3824674125751036598
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 3658515979474970495}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 2495763b61e83bd43be031a5fdeb8569, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
neirong: {fileID: 3658515979145581876}
|
||||||
|
creatTime: {fileID: 3658515979674595317}
|
||||||
--- !u!1 &3658515979494861314
|
--- !u!1 &3658515979494861314
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -3616,7 +3616,7 @@ RectTransform:
|
|||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
m_AnchorMin: {x: 0, y: 1}
|
m_AnchorMin: {x: 0, y: 1}
|
||||||
m_AnchorMax: {x: 0, y: 1}
|
m_AnchorMax: {x: 0, y: 1}
|
||||||
m_AnchoredPosition: {x: 686, y: -1387.5}
|
m_AnchoredPosition: {x: 712.31714, y: -1387.5}
|
||||||
m_SizeDelta: {x: 1018, y: 0}
|
m_SizeDelta: {x: 1018, y: 0}
|
||||||
m_Pivot: {x: 0.5, y: 0.5}
|
m_Pivot: {x: 0.5, y: 0.5}
|
||||||
--- !u!114 &1071890038
|
--- !u!114 &1071890038
|
||||||
|
8
TheStrongestSnail/Assets/Scripts/Announcement.meta
Normal file
8
TheStrongestSnail/Assets/Scripts/Announcement.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: a14248879380ce64dbfd470757767729
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
31
TheStrongestSnail/Assets/Scripts/Announcement/annDetail32.cs
Normal file
31
TheStrongestSnail/Assets/Scripts/Announcement/annDetail32.cs
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
//查询公告详情
|
||||||
|
public class annDetail32 : MonoBehaviour
|
||||||
|
{
|
||||||
|
|
||||||
|
public async Task<annDetail> annDetail(int noticeId)
|
||||||
|
{
|
||||||
|
// 准备请求的头部信息,包含授权令牌
|
||||||
|
Dictionary<string, string> head32 = new Dictionary<string, string>
|
||||||
|
{
|
||||||
|
{ "Authorization", Global.global.serverResponse.data.token }
|
||||||
|
};
|
||||||
|
|
||||||
|
// 异步发送请求
|
||||||
|
string response32 = await web.SendRequest(web.URL + "/snail/notice/info?noticeId=" + noticeId, "GET", "{}", head32);
|
||||||
|
|
||||||
|
// 调试输出接收到的响应
|
||||||
|
Debug.Log("3.2查询公告详情:=============== " + response32);
|
||||||
|
|
||||||
|
// 解析响应的 JSON 数据
|
||||||
|
annDetail annDetailResponse = JsonConvert.DeserializeObject<annDetail>(response32);
|
||||||
|
|
||||||
|
// 返回解析后的数据
|
||||||
|
return annDetailResponse;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 3ae2cee5656837748a28acdd4834a8cc
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -0,0 +1,54 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using UnityEngine;
|
||||||
|
//查询公告分页
|
||||||
|
public class announcementPage31 : MonoBehaviour
|
||||||
|
{
|
||||||
|
public async Task<announcementPage> announcementPage(int pageNo,int pageSize)
|
||||||
|
{
|
||||||
|
// 准备请求的头部信息,包含授权令牌
|
||||||
|
Dictionary<string, string> head31 = new Dictionary<string, string>
|
||||||
|
{
|
||||||
|
{ "Authorization", Global.global.serverResponse.data.token }
|
||||||
|
};
|
||||||
|
RealPlayerInfo realPlayerInfo = new RealPlayerInfo();
|
||||||
|
queryPlayerInfo queryPlayerInfo = new queryPlayerInfo();
|
||||||
|
realPlayerInfo = await queryPlayerInfo.QueryPlayerInfoPro();
|
||||||
|
|
||||||
|
|
||||||
|
// 请求体
|
||||||
|
announcementPageBody announcementPageBody = new announcementPageBody()
|
||||||
|
{
|
||||||
|
userId = realPlayerInfo.data.userId,
|
||||||
|
pageNo = pageNo,
|
||||||
|
pageSize = pageSize
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
Debug.Log("====入参====" + JsonConvert.SerializeObject(announcementPageBody));
|
||||||
|
// 异步发送请求
|
||||||
|
string response31 = await web.SendRequest(web.URL + "/snail/notice/page", "POST", JsonConvert.SerializeObject(announcementPageBody), head31);
|
||||||
|
|
||||||
|
// 调试输出接收到的响应
|
||||||
|
Debug.Log("3.1查询公告分页:=============== " + response31);
|
||||||
|
|
||||||
|
// 解析响应的 JSON 数据
|
||||||
|
announcementPage announcementPage = JsonConvert.DeserializeObject<announcementPage>(response31);
|
||||||
|
// 遍历公告列表
|
||||||
|
foreach (var announcement in announcementPage.data.dataList)
|
||||||
|
{
|
||||||
|
int id = announcement.id; // 公告ID
|
||||||
|
string title = announcement.title; // 公告标题
|
||||||
|
string icon = announcement.icon; // 公告图标URL
|
||||||
|
string content = announcement.content; // 公告内容
|
||||||
|
int onShelves = announcement.onShelves; // 是否上架
|
||||||
|
string createTime = announcement.createTime; // 创建时间
|
||||||
|
|
||||||
|
// 你可以在这里使用这些字段进行其他操作,例如展示公告内容
|
||||||
|
Debug.Log($"公告ID: {id}, 标题: {title}, 图标: {icon}, 内容: {content}, 上架状态: {onShelves}, 创建时间: {createTime}");
|
||||||
|
}
|
||||||
|
return announcementPage;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b3d4da22507db97468bb3de37d46e09a
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -913,3 +913,54 @@ public class BuyProductResponse : Response
|
|||||||
{
|
{
|
||||||
public string data;
|
public string data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//====3.1===============================================
|
||||||
|
public class announcementPageBody
|
||||||
|
{
|
||||||
|
public int userId;
|
||||||
|
public int pageNo;
|
||||||
|
public int pageSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 表示公告页
|
||||||
|
public class announcementPage : Response
|
||||||
|
{
|
||||||
|
public AnnouncementData data { get; set; } // 包含公告数据的对象
|
||||||
|
}
|
||||||
|
|
||||||
|
// 包含公告数据
|
||||||
|
public class AnnouncementData
|
||||||
|
{
|
||||||
|
public int pageNo { get; set; } // 当前页码
|
||||||
|
public int pageSize { get; set; } // 每页数据量
|
||||||
|
public int totalCount { get; set; } // 总记录数
|
||||||
|
public List<Announcement> dataList { get; set; } // 公告列表
|
||||||
|
}
|
||||||
|
|
||||||
|
// 单条公告
|
||||||
|
public class Announcement
|
||||||
|
{
|
||||||
|
public int id { get; set; } // 公告ID
|
||||||
|
public string title { get; set; } // 公告标题
|
||||||
|
public string icon { get; set; } // 公告图标URL
|
||||||
|
public string content { get; set; } // 公告内容
|
||||||
|
public int onShelves { get; set; } // 是否上架 (1为上架,0为下架)
|
||||||
|
public string createTime { get; set; } // 创建时间
|
||||||
|
}
|
||||||
|
//========3.2=======================================================
|
||||||
|
// 响应结果的根类
|
||||||
|
public class annDetail : Response
|
||||||
|
{
|
||||||
|
public AnnDetailData data { get; set; } // 包含具体公告数据的对象
|
||||||
|
}
|
||||||
|
|
||||||
|
// 公告数据的对象
|
||||||
|
public class AnnDetailData
|
||||||
|
{
|
||||||
|
public int id { get; set; } // 公告ID
|
||||||
|
public string title { get; set; } // 公告标题
|
||||||
|
public string icon { get; set; } // 公告图标URL
|
||||||
|
public string content { get; set; } // 公告内容
|
||||||
|
public int onShelves { get; set; } // 是否上架 (1为上架,0为下架)
|
||||||
|
public string createTime { get; set; } // 创建时间
|
||||||
|
}
|
@ -1,19 +1,30 @@
|
|||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
public class AnniyncementPanel : MonoBehaviour
|
public class AnniyncementPanel : Base
|
||||||
{
|
{
|
||||||
|
public GameObject Content;
|
||||||
|
announcementPage31 page31 = new announcementPage31();
|
||||||
|
announcementPage announcementPage = new announcementPage();
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
|
testLogo();
|
||||||
Init();
|
Init();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async void Init()
|
async void Init()
|
||||||
{
|
{
|
||||||
|
announcementPage = await page31.announcementPage(1,20);
|
||||||
|
Debug.Log(announcementPage.data.totalCount);
|
||||||
|
for (int i = 0; i < announcementPage.data.totalCount; i++)
|
||||||
|
{
|
||||||
|
GameObject Page = (GameObject)Instantiate(Resources.Load("LLPrefabs/Announcement_newitem"), Content.transform);
|
||||||
|
Page.GetComponent<Announcementitem>().neirong.text = announcementPage.data.dataList[i].title;
|
||||||
|
Page.GetComponent<Announcementitem>().creatTime.text = announcementPage.data.dataList[i].createTime;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -0,0 +1,20 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
public class Announcementitem : MonoBehaviour
|
||||||
|
{
|
||||||
|
public Text neirong;
|
||||||
|
public Text creatTime;
|
||||||
|
// Start is called before the first frame update
|
||||||
|
void Start()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update is called once per frame
|
||||||
|
void Update()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 2495763b61e83bd43be031a5fdeb8569
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
Loading…
Reference in New Issue
Block a user