/// <summary> /// 注入 /// </summary> /// <param name="_appleData"></param> /// <param name="buyCallback"></param> public void refresh(Product _appleData, ServerGoodsInfo _snapData, IAPNode _manaegr) { if (_appleData != null && _appleData.definition != null && _appleData.definition.id != null) { GoodsServerData = _snapData; visible(true); GoodsID = _appleData.definition.id; GoodsMoney = _appleData.metadata.localizedPrice; GoodsName = _appleData.metadata.localizedTitle; GoodsInfo = _appleData.metadata.localizedDescription; Manager = _manaegr; GoodsMoneyTF.text = "" + GoodsMoney; GoodsLvTF.text = "" + GoodsServerData.GoodsLvInt; AsyncImageDownload.GetInstance().SetAsyncImage(GoodsServerData.GoodsIconUrl, GoodsIconTrue); GoodsIsBuyed.SetActive(GoodsServerData.GoodsIsBuyed); GoodsIconTrue.GetComponent <Button>().enabled = !GoodsServerData.GoodsIsBuyed; } else { visible(false); } }
/// <summary> /// 根据当前页刷新UI /// </summary> private void refreshUIForPage() { // 先全隐藏 foreach (GameObject item in GoodsIconList) { item.GetComponent <IAPGoodsItem> ().visible(false); } //拿到当前页的数据 ArrayList pageData = new ArrayList(); int pageStartIndex = (GoodsListCurrentPage - 1) * UIItemPageGoodsNum; int pageEndIndex = (pageStartIndex + UIItemPageGoodsNum); for (int startIndex = pageStartIndex; startIndex < pageEndIndex; startIndex++) { if (GoodsAppleInfo.Count >= startIndex + 1) { ArrayList itemPageData = new ArrayList(); string goodsID = GoodsAppleInfo[startIndex].definition.id; ServerGoodsInfo serverInfo = null; foreach (ServerGoodsInfo item in GoodsPublisServer) { if (goodsID == item.GoodsID) { serverInfo = item; break; } } itemPageData.Add(GoodsAppleInfo[startIndex]); itemPageData.Add(serverInfo); pageData.Add(itemPageData); } } // 刷新显示 for (int refreshI = 0; refreshI < pageData.Count; refreshI++) { ArrayList itemPageData = pageData[refreshI] as ArrayList; Product _appleData; ServerGoodsInfo _snapData; _appleData = itemPageData[0] as Product; _snapData = itemPageData[1] as ServerGoodsInfo; GoodsIconList[refreshI].GetComponent <IAPGoodsItem> ().refresh(_appleData, _snapData, this); } pageData = null; }
/// <summary> /// 请求商品信息 /// </summary> /// <param name="rpcResultObj"></param> private void RequestGoodsInfoCallback(SnapRpcDataVO rpcResultObj) { if (CurrentIsDispose) { return; } JsonData data = rpcResultObj.data; if (rpcResultObj.code == RpcDataCode.RequestFinish) { GoodsPublisServer = new List <ServerGoodsInfo> (); for (int i = 0; i < data.Count; i++) { ServerGoodsInfo item = new ServerGoodsInfo(); item.GoodsID = (string)data[i]["appleGoodsId"]; item.GoodsSnapID = (string)data[i]["id"]; item.GoodsIconUrl = (string)data[i]["icon"]; item.GoodsLvInt = (int)data[i]["courseNum"]; item.GoodsSnapType = (int)data[i]["itemType"]; item.GoodsIsBuyed = (Boolean)data[i]["isBuy"]; GoodsPublisServer.Add(item); } IAPProxy.Instance().InitializeIAP(GoodsPublisServer, InitializeUI); string logStr = "请求商品信息成功:" + JsonMapper.ToJson(data); log(logStr); } else { PromptManager.Instance.MessageBox(PromptManager.Type.FloatingTip, "支付通信失败,请稍后重试"); string logStr = "请求商品信息失败:" + JsonMapper.ToJson(data); log(logStr); } }