123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using simplejson;
- using UnityEngine;
- public class PottingMobileServicesEditor : PottingMobileServicesBase
- {
- static PottingMobileServicesEditor()
- {
- InitManager();
- }
- /**
- * 获取服务器配置
- * appver:如果不需要根据版本判断可以串0
- * lastver:每次全新获取传0
- *
- * @param appVer
- * @param lastVer
- */
- public static void _configSync(string appVer, int lastVer)
- {
- YouLoftServices.ServerConfig((i, s) =>
- {
- PottingMobileServicesManger.Instance.ConfigSync(GETJsonString(i,s));
- });
- }
-
-
- /**
- * 渠道下单接口,根据不同渠道需要的数据不同
- * 返回的数据结构不同,前端需要根据情况解析
- *
- * @param channel 渠道
- * @param goodsid 商品ID
- */
- public static void _channelPayOrder(int channel, string goodsid)
- {
- YouLoftServices._channelPayOrder(channel,goodsid, (i, s) =>
- {
- PottingMobileServicesManger.Instance.ChannelpayOrder(GETJsonString(i,s));
-
- });
- }
- /**
- * 获取当前游戏,渠道的最新版本
- * 返回结果无加密
- *
- * @param channel 渠道
- */
- public static void _channelPayGetAppVersion(int channel)
- {
- YouLoftServices.GameServerVersion(channel, (i, s) =>
- {
- PottingMobileServicesManger.Instance.ChannelpayGetAppVersion(GETJsonString(i,s));
- });
- }
-
- /**
- * 兑换码兑换接口
- *
- * @param redeemcode 兑换码
- */
- public static void _dedeemConsume(string redeemcode)
- {
- YouLoftServices.RedemptionCode(redeemcode, (i, s) =>
- {
- PottingMobileServicesManger.Instance.DedeemConsume(GETJsonString(i,s));
-
- });
- }
- /**
- * 登录接口
- *
- * @param id 设备ID 或者第三方登录平台的ID
- * @param type 登录类型
- * @param name 用户昵称
- * @param icon 用户头像链接
- */
- public static void _userLogin(string id, int type, string name, string icon)
- {
- YouLoftServices.Login(id,type,name,icon, (i, s) =>
- {
- PottingMobileServicesManger.Instance.UserLogin(GETJsonString(i,s));
- });
-
- }
- /**
- * 获取(提交)存档到服务器
- * 1.每次启动游戏优先获取存档
- * 2.当有需要更新的存档时提交服务器
- * 提交存档时服务器会默认覆盖以前的存档不会做其他判断
- * 请求需要签名,返回数据有加密
- *
- * @param archive
- * @param archiveVersion
- */
- public static void _userSync(string archive, int archiveVersion)
- {
- YouLoftServices.CommitArchive(archive,archiveVersion, (i, s) =>
- {
- PottingMobileServicesManger.Instance.UserSync(GETJsonString(i,s));
- });
- }
- /**
- * 心跳检测,判断当前客户端登陆是否有效
- * 请求需要签名,返回数据无加密
- */
- public static void _userHeartbeat()
- {
- YouLoftServices._userHeartbeat((i, s) =>
- {
- PottingMobileServicesManger.Instance.UserHeartbeat(GETJsonString(i,s));
- });
- }
- /**
- * 用户下订接口,下单成功之后返回支付链接
- * -跳转支付页面
- *
- * @param goodsid 商品ID
- */
- public static void _userOrder(string goodsid, string activityid)
- {
- YouLoftServices.RequestOrder(goodsid,activityid, (code, starUrl,endUrl,orderid) =>
- {
- if (code==1)
- {
- code = 200;
- }
- if (code==2)
- {
- code = 4000;
- }
- var jsonData = new JSONObject
- {
- ["code"] = code,
- ["data"] =starUrl,
- ["returnAppLink"] =endUrl,
- ["orderid"] =orderid
- };
-
- PottingMobileServicesManger.Instance.UserOrder(jsonData.ToString());
- });
- }
- /**
- * 恢复购买,查看已完成的所有订单,以及消耗状态
- * 请求需要签名,返回结果有加密
- */
- public static void _userResumepurchase()
- {
- YouLoftServices.ResumeOrder((i, s) =>
- {
- PottingMobileServicesManger.Instance.UserResumepurchase(GETJsonString(i,s));
-
- });
-
- }
- /**
- * 订单消耗
- * 请求需要签名,返回结果有加密
- *
- * @param goodsid 商品ID
- * @param orderId 订单ID
- */
- public static void _userConsume(string goodsid, string orderId)
- {
- YouLoftServices.ConsumeOrder(goodsid,orderId, (i, s) =>
- {
- PottingMobileServicesManger.Instance.UserConsume(GETJsonString(i,s));
- });
- }
- /**
- * 查询单个订单的状态
- * 用来处理非消耗性商品,判断订单是否支付完成
- * 返回结果有加密
- *
- * @param goodsid 商品ID
- * @param orderId 订单ID
- */
- public static void _userQueryOrder(string goodsid, string orderId)
- {
- YouLoftServices._userQueryOrder(goodsid,orderId, (i, s) =>
- {
- PottingMobileServicesManger.Instance.UserQueryOrder(GETJsonString(i,s));
-
- });
-
- }
- /**
- * 提交用户分数
- * 返回用户排行榜信息,返回结果无加密
- *
- * @param score 名次
- * @param info 排名信息
- * @param rankingid 排名ID
- */
- public static void _userUploadScore(int score, string info, string rankingid)
- {
- YouLoftServices.UploadScore(rankingid,score,info,(b)=>
- {
- int code = b? 200 : 4000;
- var jsonData = new JSONObject
- {
- ["code"] = code,
- ["data"] =b
- };
- PottingMobileServicesManger.Instance.UserUploadScore(jsonData.ToString());
- });
- }
- /**
- * 获取用户自己的排名
- *
- * @param rankingid 排行榜ID
- */
- public static void _userGetUserRank(string rankingid)
- {
-
- YouLoftServices._userGetUserRank(rankingid, (i, s) =>
- {
- PottingMobileServicesManger.Instance.GetActivitiesWithChannel(GETJsonString(i,s));
- });
- }
- /// <summary>
- /// 获取活动
- /// </summary>
- /// <param name="channel">渠道</param>
- /// <param name="language">语言</param>
- public static void _getActivitiesWithChannel(string channel, string language)
- {
- YouLoftServices.ActivityBy(channel, language, (i, s) =>
- {
- PottingMobileServicesManger.Instance.GetActivitiesWithChannel(GETJsonString(i,s));
- });
- }
- /// <summary>
- /// 获取公告
- /// </summary>
- /// <param name="channel">渠道</param>
- /// <param name="version">版本</param>
- /// <param name="language">语言</param>
- public static void _getGameAnoncementsWithChannel(string channel, string version, string language)
- {
- YouLoftServices.AnnouncementBy(channel, version,language, (i, s) =>
- {
- PottingMobileServicesManger.Instance.GameAnoncementsWithChannel(GETJsonString(i,s));
- });
- }
- /// <summary>
- /// 根据渠道兑换码兑换接口
- /// </summary>
- /// <param name="redeemCode">兑换码</param>
- /// <param name="channel">渠道</param>
- public static void _redeemConsume(string redeemCode, string channel)
- {
- YouLoftServices._redeemConsume(redeemCode,channel, (i, s) =>
- {
- PottingMobileServicesManger.Instance.RedeemConsume(GETJsonString(i,s));
-
- });
- }
- /// <summary>
- /// 根据渠道兑换码兑换接口,需要用户登录
- /// </summary>
- /// <param name="redeemCode"></param>
- /// <param name="channel"></param>
- public static void _redeemUserConsume(string redeemCode, string channel,string clientId)
- {
- YouLoftServices._redeemUserConsume(redeemCode,channel, (i, s) =>
- {
- PottingMobileServicesManger.Instance.RedeemUserConsume(GETJsonString(i,s));
-
- });
- }
-
- public static void _FeedBackSubmit(string msg, string connect, string docInfo)
- {
- YouLoftServices.Feedback(msg,connect,"","","", "",(i,s) =>
- {
- PottingMobileServicesManger.Instance.feedBackSubmitComplected(GETJsonString(i,s));
- });
- }
- /// <summary>
- /// 上报关键数据
- /// </summary>
- /// <param name="lable"></param>
- public static void _GameInfoUpload (Dictionary<string, string> lable) {
- }
- /// <summary>
- /// 上报付费
- /// </summary>
- public static void _PayrecordSubmit()
- {
-
- }
- public static string GETJsonString(int code,string data )
- {
- if (code==1)
- {
- code = 200;
- }
- if (code==2)
- {
- code = 4000;
- }
- var jsonData = new JSONObject
- {
- ["code"] = code,
- ["data"] =data
- };
- Debug.Log(jsonData.ToString());
- return jsonData.ToString();
- }
- /// <summary>
- /// 获取服务器信息
- /// </summary>
- public static void _Serverinfo()
- {
- }
- }
|