public void Exchange(uint uid, Int64 amount, string remark, string password, string key, Action <BS_MoneyResult> result) { //string url = GameApp.GameData.BackStorgeUrl + "/ProxyHandler/User.ashx?action=recharge"; string url = GameApp.GameData.BackStorgeUrl + GlobalConst.URL.Exchange; var req = new BS_MoneyRequest(); req.Url = url; req.UserID = uid; req.Amount = (int)amount; req.Remark = remark; req.Result = result; req.OrderType = 201; req.passWord = password; req.Key = key; StartCoroutine("RechargeOrExchange", req); }
public IEnumerator RechargeOrExchange(BS_MoneyRequest req) { var data = new WWWForm(); data.AddField("UserID", req.UserID.ToString()); data.AddField("payAmount", req.Amount.ToString()); data.AddField("submitRemark", req.Remark); data.AddField("OrderType", req.OrderType.ToString()); data.AddField("password", req.passWord); data.AddField("token", req.Key); float elapsedTime = 0.0f; var www = new WWW(req.Url, data); yield return(www); while (!www.isDone) { elapsedTime += Time.deltaTime; if (elapsedTime >= TIMEOUT) { break; } yield return(new WaitForFixedUpdate()); } if (!string.IsNullOrEmpty(www.error) || string.IsNullOrEmpty(www.text)) { req.Result(null); yield break; } var jsonData = JsonMapper.ToObject <BS_MoneyResult>(www.text); req.Result(jsonData); yield break; }