2024-11-12 20:46:23 +08:00
using System ;
using System.Collections ;
using System.Collections.Generic ;
using UnityEngine ;
using System.Threading.Tasks ;
using Newtonsoft.Json ;
2024-11-13 21:52:56 +08:00
using UnityEngine.UI ;
/ * public class loadMall : MonoBehaviour
2024-11-12 20:46:23 +08:00
{
public string token = null ; // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> µ<EFBFBD> token<65> <6E> <EFBFBD> <EFBFBD> ʼ Ϊ null
public int escapeId = - 1 ; // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> µ<EFBFBD> escapeId<49> <64> <EFBFBD> <EFBFBD> ʼ Ϊ -1 <20> <> ʾ δ<CABE> <CEB4> <EFBFBD> <EFBFBD>
void Start ( )
{
// ע<> <D7A2> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ¼<EFBFBD> <C2BC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> յ<EFBFBD> token ʱ<> <CAB1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> HandleTokenReceived
LoginAndGetToken . OnTokenReceived + = HandleTokenReceived ;
// ע<> <D7A2> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> escapeId <20> <> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1> <EFBFBD> <EFBFBD> HandleGameEscapeIdUpdated<65> <64> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ִ<EFBFBD> <D6B4> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
selectGameEscape512 . OnGameEscapeIdUpdated + = HandleGameEscapeIdUpdated ;
}
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> յ<EFBFBD> token ʱ<> <CAB1> <EFBFBD> <EFBFBD> <EFBFBD> ˷<EFBFBD> <CBB7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> token
public void HandleTokenReceived ( string receivedToken )
{
token = receivedToken ; // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> µ<EFBFBD> token
// <20> ״ε<D7B4> <CEB5> ü<EFBFBD> <C3BC> س<EFBFBD> ʼ <EFBFBD> <CABC> <EFBFBD> <EFBFBD>
LoadInitialData ( ) ;
//LoadGameEscapeData();
//Debug.Log("<22> <> <EFBFBD> յ<EFBFBD> <D5B5> µ<EFBFBD> token: " + token);
}
// <20> <> <EFBFBD> <EFBFBD> Ϸ<EFBFBD> <CFB7> <EFBFBD> <EFBFBD> ID <20> <> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1> <EFBFBD> <EFBFBD> <EFBFBD> ˷<EFBFBD> <CBB7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> µ<EFBFBD> escapeId
public async void HandleGameEscapeIdUpdated ( int newGameEscapeId )
{
escapeId = newGameEscapeId ; // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> µ<EFBFBD> escapeId
await LoadMallData ( ) ; //=====================================================================<3D> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϊ<EFBFBD> <CEAA> <EFBFBD> <EFBFBD> д<EFBFBD> <D0B4> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Է<EFBFBD> <D4B7> <EFBFBD> <EFBFBD> κεط<CEB5> <D8B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> input.GetKeyDown.....<2E> <> <EFBFBD> <EFBFBD> <EFBFBD> ĵ<EFBFBD> <C4B5> <EFBFBD> <EFBFBD> Է<EFBFBD> <D4B7> <EFBFBD> <EFBFBD> <EFBFBD>
//Debug.Log("<22> <> <EFBFBD> յ<EFBFBD> <D5B5> µ<EFBFBD> GameEscapeId: " + escapeId);
}
// <20> <> <EFBFBD> س<EFBFBD> ʼ <EFBFBD> <CABC> <EFBFBD> ݣ<EFBFBD> ʹ <EFBFBD> <CAB9> <EFBFBD> <EFBFBD> <EFBFBD> µ<EFBFBD> token
public async void LoadInitialData ( )
{
if ( string . IsNullOrEmpty ( token ) )
{
Debug . LogWarning ( "<22> <EFBFBD> <DEB7> <EFBFBD> <EFBFBD> س<EFBFBD> ʼ <EFBFBD> <CABC> <EFBFBD> ݣ<EFBFBD> token δ<> <CEB4> <EFBFBD> á<EFBFBD> " ) ;
return ;
}
await LoadMallData ( ) ; //=====================================================================<3D> <> <EFBFBD> ڴ˴ <DAB4> ֻΪ<D6BB> <CEAA> <EFBFBD> <EFBFBD> һ <EFBFBD> <D2BB> <EFBFBD> <EFBFBD> ɫ<EFBFBD> <C9AB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ġ<EFBFBD> <C4A1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Բ<EFBFBD> Ҫ
}
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϸ<EFBFBD> <CFB7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݣ<EFBFBD> ʹ <EFBFBD> <CAB9> <EFBFBD> <EFBFBD> <EFBFBD> µ<EFBFBD> escapeId <20> <> token
public async void selectQueryKill1 ( )
{
if ( string . IsNullOrEmpty ( token ) )
{
Debug . LogWarning ( "<22> <EFBFBD> <DEB7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϸ<EFBFBD> <CFB7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݣ<EFBFBD> token δ<> <CEB4> <EFBFBD> á<EFBFBD> " ) ;
return ;
}
if ( escapeId = = - 1 )
{
Debug . LogWarning ( "<22> <EFBFBD> <DEB7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϸ<EFBFBD> <CFB7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݣ<EFBFBD> escapeId δ<> <CEB4> <EFBFBD> á<EFBFBD> " ) ;
return ;
}
await LoadMallData ( ) ; //==========================================================================================================================================================================
}
//===============================================================================================================================================================================================================================
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> ̳<EFBFBD> <CCB3> <EFBFBD> <EFBFBD> <EFBFBD>
public async Task LoadMallData ( )
{
// <20> <> ѯ<EFBFBD> ̳<EFBFBD> <CCB3> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ʒ <EFBFBD> б <EFBFBD>
await QueryMallList ( 0 ) ;
// <20> <> ѯ<EFBFBD> ̳<EFBFBD> ʵ<EFBFBD> <CAB5> <EFBFBD> <EFBFBD> Ʒ <EFBFBD> б <EFBFBD>
await QueryMallList ( 1 ) ;
// <20> <> ȡ<EFBFBD> <C8A1> Ʒ <EFBFBD> <C6B7> <EFBFBD> <EFBFBD>
await GetMallProductDetails ( 1 ) ;
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ʒ
await BuyMallProduct ( 106 , 1 ) ;
}
// <20> <> ѯ<EFBFBD> ̳<EFBFBD> <CCB3> б <EFBFBD>
public async Task QueryMallList ( int productType )
{
var headers = CreateHeaders ( ) ;
Mall_List mallList = new Mall_List
{
productType = productType
} ;
string response = await web . SendRequest ( "http://121.40.42.41:8080/snail/product/page" , "POST" , JsonUtility . ToJson ( mallList ) , headers ) ;
Debug . Log ( $"<22> ̳<EFBFBD> <CCB3> б <EFBFBD> (productType: {productType}) <20> <> Ӧ: " + response ) ;
}
// <20> <> ȡ<EFBFBD> ̳<EFBFBD> <CCB3> <EFBFBD> Ʒ <EFBFBD> <C6B7> <EFBFBD> <EFBFBD>
public async Task GetMallProductDetails ( int productId )
{
var headers = CreateHeaders ( ) ;
Product_Details productDetails = new Product_Details
{
productId = productId
} ;
string response = await web . SendRequest ( "http://121.40.42.41:8080/snail/product/info" , "POST" , JsonUtility . ToJson ( productDetails ) , headers ) ;
Debug . Log ( "<22> <> ȡ<EFBFBD> <C8A1> Ʒ <EFBFBD> <C6B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ӧ: " + response ) ;
}
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ʒ
public async Task BuyMallProduct ( int userId , int productId )
{
var headers = CreateHeaders ( ) ;
Mall_buy mallBuy = new Mall_buy
{
userId = userId ,
productId = productId
} ;
string response = await web . SendRequest ( "http://121.40.42.41:8080/snail/product/buy" , "POST" , JsonUtility . ToJson ( mallBuy ) , headers ) ;
Debug . Log ( "<22> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ʒ <EFBFBD> <C6B7> Ӧ: " + response ) ;
}
//===============================================================================================================================================================================================================================
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ͷ<EFBFBD> <CDB7> ʹ <EFBFBD> <CAB9> <EFBFBD> <EFBFBD> <EFBFBD> µ<EFBFBD> token
public Dictionary < string , string > CreateHeaders ( )
{
if ( string . IsNullOrEmpty ( token ) )
{
Debug . LogWarning ( "<22> <> <EFBFBD> Դ<EFBFBD> <D4B4> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ͷʱ<CDB7> <CAB1> token δ<> <CEB4> <EFBFBD> á<EFBFBD> " ) ;
return new Dictionary < string , string > ( ) ;
}
return new Dictionary < string , string >
{
{ "Authorization" , token }
} ;
}
void OnDestroy ( )
{
// ע<> <D7A2> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ¼<EFBFBD> <C2BC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ڴ<EFBFBD> й©
LoginAndGetToken . OnTokenReceived - = HandleTokenReceived ;
selectGameEscape512 . OnGameEscapeIdUpdated - = HandleGameEscapeIdUpdated ;
}
2024-11-13 21:52:56 +08:00
} * /
public class LoadMall : MonoBehaviour
{
public string token = null ; // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> µ<EFBFBD> token<65> <6E> <EFBFBD> <EFBFBD> ʼ Ϊ null
public int escapeId = - 1 ; // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> µ<EFBFBD> escapeId<49> <64> <EFBFBD> <EFBFBD> ʼ Ϊ -1 <20> <> ʾ δ<CABE> <CEB4> <EFBFBD> <EFBFBD>
private string lastMallResponse = null ; // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> µ<EFBFBD> <C2B5> ̳Dz<CCB3> <C7B2> <EFBFBD> <EFBFBD> <EFBFBD> Ӧ
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> һ <EFBFBD> <D2BB> <EFBFBD> ֶ<EFBFBD> <D6B6> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ̳<EFBFBD> <CCB3> <EFBFBD> <EFBFBD> ݵİ<DDB5> ť========================================================================================
public Button loadMallButton ;
void Start ( )
{
// ע<> <D7A2> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ¼<EFBFBD> <C2BC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> յ<EFBFBD> token ʱ<> <CAB1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> HandleTokenReceived
LoginAndGetToken . OnTokenReceived + = HandleTokenReceived ;
// ע<> <D7A2> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> escapeId <20> <> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1> <EFBFBD> <EFBFBD> HandleGameEscapeIdUpdated
selectGameEscape512 . OnGameEscapeIdUpdated + = HandleGameEscapeIdUpdated ;
// <20> <> <EFBFBD> 谴ť<E8B0B4> <C5A5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1> <EFBFBD> <EFBFBD> OnLoadMallButtonClicked========================================================================
if ( loadMallButton ! = null )
{
loadMallButton . onClick . AddListener ( OnLoadMallButtonClicked ) ;
}
}
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> յ<EFBFBD> token ʱ<> <CAB1> <EFBFBD> <EFBFBD> <EFBFBD> ˷<EFBFBD> <CBB7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> token
public void HandleTokenReceived ( string receivedToken )
{
token = receivedToken ; // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> µ<EFBFBD> token
Debug . Log ( "<22> <> <EFBFBD> յ<EFBFBD> <D5B5> µ<EFBFBD> token: " + token ) ;
// <20> ״ε<D7B4> <CEB5> ü<EFBFBD> <C3BC> س<EFBFBD> ʼ <EFBFBD> <CABC> <EFBFBD> <EFBFBD>
LoadInitialData ( ) ;
}
// <20> <> <EFBFBD> <EFBFBD> Ϸ<EFBFBD> <CFB7> <EFBFBD> <EFBFBD> ID <20> <> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1> <EFBFBD> <EFBFBD> <EFBFBD> ˷<EFBFBD> <CBB7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> µ<EFBFBD> escapeId
public async void HandleGameEscapeIdUpdated ( int newGameEscapeId )
{
escapeId = newGameEscapeId ; // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> µ<EFBFBD> escapeId
Debug . Log ( "<22> <> <EFBFBD> յ<EFBFBD> <D5B5> µ<EFBFBD> GameEscapeId: " + escapeId ) ;
// <20> ڽ<EFBFBD> <DABD> յ<EFBFBD> escapeId <20> <> <EFBFBD> <EFBFBD> ʱ<EFBFBD> Զ<EFBFBD> <D4B6> <EFBFBD> <EFBFBD> ü<EFBFBD> <C3BC> <EFBFBD> <EFBFBD> ̳<EFBFBD> <CCB3> <EFBFBD> <EFBFBD> <EFBFBD>
lastMallResponse = await LoadMallData ( ) ;
Debug . Log ( "HandleGameEscapeIdUpdated <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ̳<EFBFBD> <CCB3> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ӧ: " + lastMallResponse ) ;
}
// <20> <> <EFBFBD> س<EFBFBD> ʼ <EFBFBD> <CABC> <EFBFBD> ݣ<EFBFBD> ʹ <EFBFBD> <CAB9> <EFBFBD> <EFBFBD> <EFBFBD> µ<EFBFBD> token
public async void LoadInitialData ( )
{
if ( string . IsNullOrEmpty ( token ) )
{
Debug . LogWarning ( "<22> <EFBFBD> <DEB7> <EFBFBD> <EFBFBD> س<EFBFBD> ʼ <EFBFBD> <CABC> <EFBFBD> ݣ<EFBFBD> token δ<> <CEB4> <EFBFBD> á<EFBFBD> " ) ;
return ;
}
// <20> <> <EFBFBD> ü<EFBFBD> <C3BC> <EFBFBD> <EFBFBD> ̳<EFBFBD> <CCB3> <EFBFBD> <EFBFBD> ݷ<EFBFBD> <DDB7> <EFBFBD>
lastMallResponse = await LoadMallData ( ) ;
Debug . Log ( "<22> <> ʼ <EFBFBD> <CABC> <EFBFBD> ص<EFBFBD> <D8B5> ̳<EFBFBD> <CCB3> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ӧ: " + lastMallResponse ) ;
}
// <20> <> ť<EFBFBD> <C5A5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <F3B4A5B7> ̳<EFBFBD> <CCB3> <EFBFBD> <EFBFBD> ݼ<EFBFBD> <DDBC> ز<EFBFBD> <D8B2> <EFBFBD>
public async void OnLoadMallButtonClicked ( )
{
// <20> <> <EFBFBD> <EFBFBD> token <20> Ƿ<EFBFBD> <C7B7> <EFBFBD> <EFBFBD> <EFBFBD> ȷ<EFBFBD> <C8B7> <EFBFBD> <EFBFBD>
if ( string . IsNullOrEmpty ( token ) )
{
Debug . LogWarning ( "<22> <EFBFBD> <DEB7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ̳<EFBFBD> <CCB3> <EFBFBD> <EFBFBD> ݣ<EFBFBD> token δ<> <CEB4> <EFBFBD> á<EFBFBD> " ) ;
return ;
}
// <20> <> <EFBFBD> ü<EFBFBD> <C3BC> <EFBFBD> <EFBFBD> ̳<EFBFBD> <CCB3> <EFBFBD> <EFBFBD> ݷ<EFBFBD> <DDB7> <EFBFBD>
lastMallResponse = await LoadMallData ( ) ;
Debug . Log ( "<22> û<EFBFBD> <C3BB> <EFBFBD> ť<EFBFBD> <C5A5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ̳<EFBFBD> <CCB3> <EFBFBD> <EFBFBD> ݼ<EFBFBD> <DDBC> <EFBFBD> <EFBFBD> <EFBFBD> Ӧ: " + lastMallResponse ) ;
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ӧ<EFBFBD> <D3A6> <EFBFBD> <EFBFBD> һ <EFBFBD> <D2BB> <EFBFBD> Ĵ<EFBFBD> <C4B4> <EFBFBD>
HandleMallResponse ( lastMallResponse ) ;
}
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> ̳<EFBFBD> <CCB3> <EFBFBD> <EFBFBD> <EFBFBD>
public async Task < string > LoadMallData ( )
{
if ( string . IsNullOrEmpty ( token ) )
{
Debug . LogWarning ( "<22> <EFBFBD> <DEB7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ̳<EFBFBD> <CCB3> <EFBFBD> <EFBFBD> ݣ<EFBFBD> token δ<> <CEB4> <EFBFBD> á<EFBFBD> " ) ;
return null ;
}
var headers = CreateHeaders ( ) ;
// <20> <> ѯ<EFBFBD> ̳<EFBFBD> <CCB3> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ʒ <EFBFBD> б <EFBFBD>
await QueryMallList ( 0 ) ;
// <20> <> ѯ<EFBFBD> ̳<EFBFBD> ʵ<EFBFBD> <CAB5> <EFBFBD> <EFBFBD> Ʒ <EFBFBD> б <EFBFBD>
await QueryMallList ( 1 ) ;
// <20> <> ȡ<EFBFBD> <C8A1> Ʒ <EFBFBD> <C6B7> <EFBFBD> <EFBFBD>
await GetMallProductDetails ( 1 ) ;
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ʒ
await BuyMallProduct ( 106 , 1 ) ;
Debug . Log ( "<22> ̳<EFBFBD> <CCB3> <EFBFBD> <EFBFBD> ݼ<EFBFBD> <DDBC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> " ) ;
return "<22> ̳<EFBFBD> <CCB3> <EFBFBD> <EFBFBD> ݼ<EFBFBD> <DDBC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> " ;
}
// <20> <> ѯ<EFBFBD> ̳<EFBFBD> <CCB3> б <EFBFBD>
public async Task QueryMallList ( int productType )
{
var headers = CreateHeaders ( ) ;
Mall_List mallList = new Mall_List
{
productType = productType
} ;
string response = await web . SendRequest ( "http://121.40.42.41:8080/snail/product/page" , "POST" , JsonUtility . ToJson ( mallList ) , headers ) ;
Debug . Log ( $"<22> ̳<EFBFBD> <CCB3> б <EFBFBD> (productType: {productType}) <20> <> Ӧ: " + response ) ;
}
// <20> <> ȡ<EFBFBD> ̳<EFBFBD> <CCB3> <EFBFBD> Ʒ <EFBFBD> <C6B7> <EFBFBD> <EFBFBD>
public async Task GetMallProductDetails ( int productId )
{
var headers = CreateHeaders ( ) ;
Product_Details productDetails = new Product_Details
{
productId = productId
} ;
string response = await web . SendRequest ( "http://121.40.42.41:8080/snail/product/info" , "POST" , JsonUtility . ToJson ( productDetails ) , headers ) ;
Debug . Log ( "<22> <> ȡ<EFBFBD> <C8A1> Ʒ <EFBFBD> <C6B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ӧ: " + response ) ;
}
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ʒ
public async Task BuyMallProduct ( int userId , int productId )
{
var headers = CreateHeaders ( ) ;
Mall_buy mallBuy = new Mall_buy
{
userId = userId ,
productId = productId
} ;
string response = await web . SendRequest ( "http://121.40.42.41:8080/snail/product/buy" , "POST" , JsonUtility . ToJson ( mallBuy ) , headers ) ;
Debug . Log ( "<22> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ʒ <EFBFBD> <C6B7> Ӧ: " + response ) ;
}
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ͷ<EFBFBD> <CDB7> ʹ <EFBFBD> <CAB9> <EFBFBD> <EFBFBD> <EFBFBD> µ<EFBFBD> token
public Dictionary < string , string > CreateHeaders ( )
{
if ( string . IsNullOrEmpty ( token ) )
{
Debug . LogWarning ( "<22> <> <EFBFBD> Դ<EFBFBD> <D4B4> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ͷʱ<CDB7> <CAB1> token δ<> <CEB4> <EFBFBD> á<EFBFBD> " ) ;
return new Dictionary < string , string > ( ) ;
}
return new Dictionary < string , string >
{
{ "Authorization" , token }
} ;
}
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> ̳<EFBFBD> <CCB3> <EFBFBD> <EFBFBD> ݵ<EFBFBD> <DDB5> <EFBFBD> Ӧ
private void HandleMallResponse ( string response )
{
if ( response . Contains ( "<22> <> <EFBFBD> <EFBFBD> " ) )
{
Debug . Log ( "<22> ̳<EFBFBD> <CCB3> <EFBFBD> <EFBFBD> ݼ<EFBFBD> <DDBC> سɹ<D8B3> <C9B9> <EFBFBD> " ) ;
}
else
{
Debug . LogWarning ( "<22> ̳<EFBFBD> <CCB3> <EFBFBD> <EFBFBD> ݼ<EFBFBD> <DDBC> <EFBFBD> ʧ<EFBFBD> ܣ<EFBFBD> <DCA3> <EFBFBD> Ӧ: " + response ) ;
}
}
void OnDestroy ( )
{
// ע<> <D7A2> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ¼<EFBFBD> <C2BC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ڴ<EFBFBD> й©
LoginAndGetToken . OnTokenReceived - = HandleTokenReceived ;
selectGameEscape512 . OnGameEscapeIdUpdated - = HandleGameEscapeIdUpdated ;
// ȡ<> <C8A1> <EFBFBD> <EFBFBD> ť<EFBFBD> ĵ<EFBFBD> <C4B5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ==============================================================================================
if ( loadMallButton ! = null )
{
loadMallButton . onClick . RemoveListener ( OnLoadMallButtonClicked ) ;
}
}
}