Ejemplo n.º 1
0
 public async Task <AccountInfo> Withdraw(int expectMoney)
 {
     if (!list.tryGetId(expectMoney, out int id))
     {
         var accInfo = new AccountInfo();
         accInfo.isSuccess = false;
         accInfo.msg       = "请稍后...";
         log?.Log($"not found money config  money = {expectMoney}");
         return(accInfo);
     }
     return(await WithdrawById(expectMoney, id));
 }
Ejemplo n.º 2
0
        //bool isInited;
        public async Task Init()
        {
            //if (isInited) return;
            //isInited = true;
            var send = new JObject();

            send.Add("game", info.package);
            send.Add("openId", info.openid);
            var recv = JsonConvert.DeserializeObject <JObject>(await http.PostStr(api.getApi("moneylist"), JsonConvert.SerializeObject(send)));

            log?.Log(recv);
            if (recv.Value <int>("code") == 200)
            {
                JArray array = recv.Value <JArray>("data");
                for (int i = 0; i < array.Count; i++)
                {
                    var item = array[i];
                    int m    = item.Value <int>("amount");
                    if (money2id.ContainsKey(m))
                    {
                        continue;
                    }
                    moneys.Add(m);
                    money2id.Add(m, item.Value <int>("id"));
                }
            }
            else
            {
                toast?.Show(recv.Value <string>("message"));
            }
        }
Ejemplo n.º 3
0
 async void onRecv(Dictionary <string, string> dic)
 {
     WX.onRecvMsg -= onRecv;
     try
     {
         if (int.Parse(dic["type"]) == 0 && int.Parse(dic["errcode"]) == 0)
         {
             JObject json = new JObject();
             json.Add("code", dic["code"]);
             json.Add("version", info.version);
             json.Add("game", info.package);
             json.Add("device", UniqueId.GetUniteId());
             log?.Log(json);
             var jo = JsonConvert.DeserializeObject <JObject>(await http.PostStr(api.getApi("login"), json.ToString()));
             log?.Log(jo);
             int code = jo.Value <int>("code");
             if (code == 200)
             {
                 info.openid  = jo["data"]["token"].Value <string>("openid");
                 head.nick    = jo["data"]["token"].Value <string>("nickname");
                 head.headUrl = jo["data"]["token"].Value <string>("avatar");
                 GetGold();
                 list.Init();
                 //UpdateInfo();
             }
             tcs.SetResult(code == 200);
         }
     }
     catch (System.Exception e)
     {
         log?.Log(e);
         throw;
     }
 }
Ejemplo n.º 4
0
        public async Task <RemoteMoneyInfo> GetGold(int type, string configName)
        {
            this.type = type;
            JObject jo = new JObject();

            if (!string.IsNullOrEmpty(info.openid))
            {
                jo.Add("openId", info.openid);
            }
            jo.Add("game", info.package);
            jo.Add("device", info.deviceId);
            jo.Add("configName", configName);
            log?.Log(jo);
            JObject retJo = JsonConvert.DeserializeObject <JObject>(await http.PostStr(url.getApi("reward"), JsonConvert.SerializeObject(jo)));

            log?.Log(retJo);
            var ret  = new RemoteMoneyInfo();
            int code = retJo.Value <int>("code");

            errcode    = ret.errcode = code;
            ret.isShow = code == 200;
            if (ret.isShow)
            {
                var dataJo = retJo["data"];
                id        = dataJo.Value <int>("configId");
                ret.money = dataJo.Value <int>("normalPay");
                ret.other = dataJo.Value <int>("multiPay");
                switch (type)
                {
                case 2:
                    ret.other = dataJo.Value <int>("morePay");
                    break;
                }
            }
            return(ret);
        }
Ejemplo n.º 5
0
        public async Task <int> GetCount(int id, int defaultV = 0)
        {
            var send = new JObject();

            send.Add("moveId", id);
            if (!string.IsNullOrEmpty(info.openid))
            {
                send.Add("openId", info.openid);
            }
            send.Add("game", info.package);
            send.Add("deviceId", info.deviceId);
            //Debug.Log(Url.getApi("counter_get"));
            log?.Log("GetCount send::" + send);
            var recv = JsonConvert.DeserializeObject <JObject>(await http.PostStr(Url.getApi("counter_get"), send.ToString()));

            log?.Log("GetCount recv::" + recv);
            int code = recv.Value <int>("code");

            if (code == 200)
            {
                return(recv["data"].Value <int>("count"));
            }
            return(defaultV);
        }