Esempio n. 1
0
    void DoBuyByItemID(uint currentItem)
    {
#if UNITY_EDITOR || WINDOWS_GUEST
        GameMain.hall_.GetPlayer().RequestBuyItem((uint)currentItem);
#else
#if VVPAY_H5
        OpenPayPlatfromSelectUI((uint)parma);
#else
#if UKGAME_SDK
        ShopItemdata itemdata = CCsvDataManager.Instance.ShopItemDataMgr.GetShopItemData((uint)currentItem);
        if (itemdata == null)
        {
            return;
        }
        string playeritemId = string.Format("{0}|{1}", GameMain.hall_.GetPlayerData().GetPlayerID(), itemdata.ItemID);
        CUKGameSDK.UKPlatform_Pay(itemdata.ItemPrice.ToString(), itemdata.ItemName, playeritemId, itemdata.ItemID.ToString());
#else
        //如果只允许行apple支付
        if (GameMain.hall_.GetPlayer().IsOnlyApplePay())
        {
            GameMain.hall_.GetPlayer().RequestBuyItem((uint)currentItem, PayPlatform.Apple);
        }
        else
        {
            GameMain.hall_.shop.OpenPayPlatfromSelectUI((uint)currentItem);
        }
#endif
#endif
#endif
    }
Esempio n. 2
0
    /// <summary>
    /// 订单确认界面按钮事件
    /// </summary>
    void OnClickConfirmEvent(EventTriggerType eventtype, object button, PointerEventData eventData)
    {
        if (eventtype != EventTriggerType.PointerClick)
        {
            return;
        }
        CustomAudio.GetInstance().PlayCustomAudio(1002);

        if ((bool)button && CurItemData != null)
        {
            ShopItemdata itemdata = CCsvDataManager.Instance.ShopItemDataMgr.GetShopItemData(CurItemData.itemScriptid);
            if (itemdata == null)
            {
                CRollTextUI.Instance.AddVerticalRollText("购买物品已经下架!");
                return;
            }

            bool bCheckState = true;
            if (BagDataManager.GetBagDataInstance().currentItems_.ContainsKey((ushort)CurItemData.itemid))
            {
                if (BagDataManager.GetBagDataInstance().currentItems_[(ushort)CurItemData.itemid].itemNumber < itemdata.ItemPrice)
                {
                    bCheckState = false;
                }
            }

            if (itemdata.SpecilSign != CurItemData.itemid || !bCheckState)
            {
                CRollTextUI.Instance.AddVerticalRollText("兑换商品校验出错!");
                return;
            }

            //姓名
            InputField name = ExchangeItemPanelGameObject.transform.Find("pop_up/Exchange_Gouwuka/InputName").GetComponent <InputField>();
            //手机号码
            InputField mobilenum = ExchangeItemPanelGameObject.transform.Find("pop_up/Exchange_Gouwuka/InputPhoneNum").GetComponent <InputField>();
            //收件地址
            InputField address = ExchangeItemPanelGameObject.transform.Find("pop_up/Exchange_Gouwuka/InputAdd").GetComponent <InputField>();
            name.text      = string.Empty;
            address.text   = string.Empty;
            mobilenum.text = string.Empty;

            GameMain.hall_.GetPlayer().RequestBuyItem(CurItemData.itemScriptid, CurPhoneNum, CurRecvName, CurRecvAddress);
        }
        CloseExchangeEvent();
    }
Esempio n. 3
0
    //显示兑换确认单
    void ShowExchangeItemOrderConfirmPanel()
    {
        if (CurItemData == null)
        {
            return;
        }

        if (ExchangeItemPanelGameObject == null)
        {
            LoadExchangeItemPanelResource();
        }
        UnityEngine.Transform ItemPopTransform     = ExchangeItemPanelGameObject.transform.Find("pop_up");
        UnityEngine.Transform ItemConfirmTransform = ItemPopTransform.Find("Tips_Confirm");


        ShopItemdata itemdata = CCsvDataManager.Instance.ShopItemDataMgr.GetShopItemData(CurItemData.itemScriptid);

        if (itemdata == null)
        {
            CRollTextUI.Instance.AddVerticalRollText("购买物品已经下架!");
            return;
        }

        ItemConfirmTransform.Find("ImageBG/Imageline/Image_goods/Textgoods").gameObject.GetComponent <Text>().text = itemdata.ItemName;

        string orderstring = "";

        if (string.IsNullOrEmpty(CurRecvName))
        {
            orderstring = "充值手机号码:<color=#FF8C00>" + CurPhoneNum + "</color>";
        }
        else
        {
            orderstring = "收件人:<color=#FF8C00>" + CurRecvName + "</color>\r\n手机号码:<color=#FF8C00>"
                          + CurPhoneNum + "</color>\r\n收件地址:<color=#FF8C00>" + CurRecvAddress + "</color>";
        }
        ItemConfirmTransform.Find("ImageBG/Textaddress").gameObject.GetComponent <Text>().text = orderstring;

        ItemConfirmTransform.gameObject.SetActive(true);
        ItemPopTransform.gameObject.SetActive(true);
        ExchangeItemPanelGameObject.SetActive(true);
    }
Esempio n. 4
0
    //请求购买物品(奖券兑换京东卡,手机充值卡)
    public bool RequestBuyItem(uint itemId, string consigneePhone, string consigneeName = null, string consigneeAddr = null)
    {
        ShopItemdata itemdata = CCsvDataManager.Instance.ShopItemDataMgr.GetShopItemData(itemId);

        if (itemdata == null)
        {
            return(false);
        }
        if (bBuyingProcess)
        {
            Debug.LogWarning("当前正处于购买过程中。。。。");
            return(false);
        }
        iBuyingItemId  = itemId;
        bBuyingProcess = true;

        CCustomDialog.OpenCustomWaitUI(1107);
        switch (itemdata.ItemType)
        {
        case Shop.ITEMTYPE.ITEMTYPE_JINGDONG:
        case Shop.ITEMTYPE.ITEMTYPE_MOBILE:
        {
            //判断奖券是否足够
            if (playerData.GetLottery() < itemdata.ItemPrice)
            {
                BuyEnd();
                CCustomDialog.OpenCustomConfirmUI(1103);
            }
            else
            {
                SendBuyReq(itemdata.ItemID, consigneePhone, consigneeName, consigneeAddr);
            }
        }
        break;

        case Shop.ITEMTYPE.ITEMTYPE_GOODS:
            SendBuyReq(itemdata.ItemID, consigneePhone, consigneeName, consigneeAddr);
            break;
        }
        return(true);
    }
Esempio n. 5
0
    void ChangeGoodsInfo(uint index)
    {
        ShopItemdata sid = CCsvDataManager.Instance.ShopItemDataMgr.GetShopItemData(index);

        if (sid == null)
        {
            return;
        }
        string goods       = sid.ItemNum.ToString();
        string externgoods = sid.PresentItemNum.ToString();

        Text goodsTx = discountobj.transform.Find("ImageBG").Find("goodsinfo").
                       Find("ImageBG").Find("coin_buy").Find("Text_Coin").gameObject.GetComponent <Text>();

        goodsTx.text = goods;

        Text externgoodsTx = discountobj.transform.Find("ImageBG").Find("goodsinfo").
                             Find("ImageBG").Find("coin_give").Find("Text_Coin").gameObject.GetComponent <Text>();

        externgoodsTx.text = externgoods;
    }
Esempio n. 6
0
    /// <summary>
    /// 读取商品表
    /// </summary>
    public void LoadShopItemDataFile()
    {
        List <string[]> strList;

        CReadCsvBase.ReaderCsvDataFromAB(GameDefine.CsvAssetbundleName, GameDefine.ShopCsvFileName, out strList);

        int columnCount = strList.Count;

        for (int i = 2; i < columnCount; i++)
        {
            ShopItemdata itemData = new ShopItemdata();
            uint.TryParse(strList[i][0], out itemData.ItemID);

            byte type;
            byte.TryParse(strList[i][1], out type);
            itemData.BelongShopType = (Shop.SHOPTYPE)type;

            byte.TryParse(strList[i][2], out type);
            itemData.ItemType = (Shop.ITEMTYPE)type;

            itemData.ItemIcon = strList[i][3];
            itemData.ItemName = strList[i][4];
            uint.TryParse(strList[i][5], out itemData.ItemNum);
            uint.TryParse(strList[i][6], out itemData.PresentItemNum);
            uint.TryParse(strList[i][7], out itemData.ItemPrice);

            byte.TryParse(strList[i][8], out type);
            itemData.CurrencyType = (Shop.CURRENCYTYPE)type;

            uint.TryParse(strList[i][9], out itemData.SpecilSign);

            int shoptype = (int)(itemData.BelongShopType);
            if (!ShopKindsItemList.ContainsKey(shoptype))
            {
                ShopKindsItemList.Add(shoptype, new List <uint>());
            }
            ShopKindsItemList[shoptype].Add(itemData.ItemID);
            ShopItemDataDictionary.Add(itemData.ItemID, itemData);
        }
    }
Esempio n. 7
0
    /// <summary>
    ///  更新兑换记录
    /// </summary>
    public void UpdateExchangeRecordData()
    {
        if (ExchangeItemPanelGameObject == null)
        {
            return;
        }
        AssetBundle bundle = AssetBundleManager.GetAssetBundle(GameDefine.HallAssetbundleName);

        if (bundle == null)
        {
            return;
        }

        ShopItemdata itemData        = null;
        Transform    recordTransform = null;
        Transform    prtf            = ExchangeItemPanelGameObject.transform.Find("pop_up/Exchange_Record/Viewport_Exchange_Record/Content_Exchange_Record");

        for (int index = 0; index < ExchangeRecordDataList.Count; ++index)
        {
            if (index >= prtf.childCount)
            {
                recordTransform = (GameMain.instantiate(bundle.LoadAsset <Object>("Shop_pop_up_Record")) as GameObject).transform;
                recordTransform.SetParent(prtf, false);
            }
            else
            {
                recordTransform = prtf.GetChild(index);
            }

            recordTransform.Find("TextRiqi").gameObject.GetComponent <Text>().text = ExchangeRecordDataList[index].orderId;
            itemData = CCsvDataManager.Instance.ShopItemDataMgr.GetShopItemData(ExchangeRecordDataList[index].itemId);
            recordTransform.Find("TextJiangpin").gameObject.GetComponent <Text>().text = itemData != null ? itemData.ItemName : "未知物品";
            string statetxt = "<color=#FF8C00>等待处理</color>";
            if (ExchangeRecordDataList[index].orderState == 1)
            {
                statetxt = "<color=#FF8C00>已处理</color>";
            }
            recordTransform.Find("TextZhuangtai").gameObject.GetComponent <Text>().text = statetxt;
        }
    }
Esempio n. 8
0
    /// <summary>
    /// 玩家购买结果消息处理
    /// </summary>
    /// <param name="msgType"></param>
    /// <param name="umsg"></param>
    /// <returns></returns>
    private bool PlayerBuyResultHandle(uint msgType, UMessage umsg)
    {
        uint playerid = umsg.ReadUInt();

        if (playerid == GetPlayerId())
        {
            bBuyingProcess = false;
            uint itemid   = umsg.ReadUInt();
            byte buystate = umsg.ReadByte();

            ShopItemdata itemdata = CCsvDataManager.Instance.ShopItemDataMgr.GetShopItemData(itemid);
            if (itemdata == null)
            {
                return(false);
            }

            //购买钻石时由支付平台返回值处理关闭等待框
            //if(itemdata.ItemType != Shop.ITEMTYPE.ITEMTYPE_DIAMOND)
            CCustomDialog.CloseCustomWaitUI();
#if UKGAME_SDK
            CCustomDialog.CloseCustomWaitUI();
#endif

#if UNITY_EDITOR || WINDOWS_GUEST
            //编辑器模式下购买钻石没有支付平台返回结果
            if (itemdata.ItemType == Shop.ITEMTYPE.ITEMTYPE_DIAMOND)
            {
                CCustomDialog.CloseCustomWaitUI();
            }
#endif
            if (buystate == 0)
            {
                //京东卡和手机充值
                if (itemdata.ItemType == Shop.ITEMTYPE.ITEMTYPE_JINGDONG ||
                    itemdata.ItemType == Shop.ITEMTYPE.ITEMTYPE_MOBILE ||
                    itemdata.ItemType == Shop.ITEMTYPE.ITEMTYPE_GOODS)
                {
                    string tradeNoId = umsg.ReadString();
                    Bag.GetBagInstance().AddExchangeRecordData(tradeNoId, itemid, 0);
                    Bag.GetBagInstance().SetItemInfoPanelActive(false);
                    CCustomDialog.OpenCustomConfirmUIWithFormatParam(1113, itemdata.ItemName);
                }
                else
                {
                    //GameMain.hall_.shop.OpenBuyResultDialogUI(itemdata.ItemIcon, itemdata.ItemType, itemdata.ItemNum + itemdata.PresentItemNum, 1101);
                    //GameMain.hall_.gift.ShowBuyItemIcon((int)itemdata.ItemID);
                }
            }
            else
            {
                uint tipsID = 0;
                //0表示成功 ,1验证不通过,2购买所需的货币不足,3商品库存不足
                switch (buystate)
                {
                case 1:
                    tipsID = 1104;
                    break;

                case 2:
                {
                    if (itemdata.CurrencyType == Shop.CURRENCYTYPE.CURRENCYTYPE_DIAMOND)
                    {
                        tipsID = 1102;
                    }
                    else if (itemdata.CurrencyType == Shop.CURRENCYTYPE.CURRENCYTYPE_LOTTERY)
                    {
                        tipsID = 1103;
                    }
                    else if (itemdata.CurrencyType == Shop.CURRENCYTYPE.CURRENCYTYPE_GOODS)
                    {
                        tipsID = 1114;
                    }
                }
                break;

                case 3:
                    tipsID = 1105;
                    break;
                }
                CCustomDialog.OpenCustomConfirmUI(tipsID);
            }
        }
        return(true);
    }
Esempio n. 9
0
    //请求购买物品
    public bool RequestBuyItem(uint itemId, PayPlatform tradeplatform = PayPlatform.none)
    {
        ShopItemdata itemdata = CCsvDataManager.Instance.ShopItemDataMgr.GetShopItemData(itemId);

        if (itemdata == null)
        {
            return(false);
        }
        if (bBuyingProcess)
        {
            Debug.LogWarning("当前正处于购买过程中。。。。");
            return(false);
        }
        iBuyingItemId  = itemId;
        bBuyingProcess = true;

        CCustomDialog.OpenCustomWaitUI(1107);
        switch (itemdata.ItemType)
        {
        case Shop.ITEMTYPE.ITEMTYPE_DIAMOND:
        {
            //苹果平台
            if (tradeplatform == PayPlatform.Apple)
            {
#if UNITY_IOS
                ApplePay.Instance.BuyItem(itemId.ToString());
#endif
            }
            else if (tradeplatform == PayPlatform.none)
            {
                //SendBuyReq(itemdata.ItemID, PayPlatform.Wechat);
                //发个假的票据
                Player.SendBuyReceiptToServer(tradeplatform, "this is fake receipt!");
            }
            else
            {
                SendBuyReq(itemdata.ItemID, tradeplatform);
            }
        }
        break;

        case Shop.ITEMTYPE.ITEMTYPE_COIN:
        {
            //判断钻石是否足够
            if (itemdata.CurrencyType == Shop.CURRENCYTYPE.CURRENCYTYPE_DIAMOND)
            {
                if (playerData.GetDiamond() < itemdata.ItemPrice)
                {
                    BuyEnd();
                    CCustomDialog.OpenCustomConfirmUI(1102);
                }
                else
                {
                    SendBuyReq(itemdata.ItemID);
                }
            }
            else if (itemdata.CurrencyType == Shop.CURRENCYTYPE.CURRENCYTYPE_LOTTERY)
            {
                //判断奖券是否足够
                if (playerData.GetLottery() < itemdata.ItemPrice)
                {
                    BuyEnd();
                    CCustomDialog.OpenCustomConfirmUI(1103);
                }
                else
                {
                    SendBuyReq(itemdata.ItemID);
                }
            }
        }
        break;

        default:
            //发个假的票据
            Player.SendBuyReceiptToServer(tradeplatform, "this is fake receipt!");
            break;
        }

        return(true);
    }