Пример #1
0
    /**
     * 检查凭证是否有效
     */
    public static void checkReceiptIsValid(string productID, string receipt, string uuid, GameObject gameObject)
    {
        Dictionary <string, object> receiptDict = new Dictionary <string, object>();

        receiptDict.Add("apple_data", receipt);
        receiptDict.Add("user_id", UserManager.Instance().authModel.user_id);
        receiptDict.Add("charge_goods_id", productID);
        receiptDict.Add("price", MainData.Instance().getGoodsPrice(productID));
        receiptDict.Add("uuid", uuid);

        // 发送之前先des加密
        string RSAString = DESBase64.DesEncryptWithKey(JsonMapper.ToJson(receiptDict), DESBase64.purchaseKey);
        Dictionary <string, object> RSADic = new Dictionary <string, object>();

        RSADic.Add("data", RSAString);

        HttpUtil.Http.Post(URLManager.appStoreCheckPurchaseCertUrl).Form(RSADic).OnSuccess(result =>
        {
            Debug.Log("OnSuccess: result------------------" + result);
            Dictionary <string, object> resultDict = JsonMapper.ToObject <Dictionary <string, object> >(result);
            string code = resultDict["code"].ToString();
            int codeInt = int.Parse(code);
            if (codeInt == 1)   // 凭证验证成功
            {
                removeReceipt(uuid);
                // 刷新主界面的信息
                UserInfoRefreshManager.refreshUserInfo(null);
                PopUtil.ShowMessageBoxWithConfirm("提示", "购买成功!");
            }
            else if (codeInt == -1)    //  服务器凭证验证成功但是数据操作异常,需要重新发送一次
            {
                PopUtil.ShowMessageBoxWithConfirmAndCancle("提示", "购买失败!点击确定重试!", () =>
                {          // 点击重新发送服务器验证
                    checkReceiptIsValid(productID, receipt, uuid, gameObject);
                }, () => { // 取消存储在本地,下次启动时候发送
                    saveReceipt(receiptDict, uuid);
                });
            }
            else if (codeInt == 0)    // 凭证无效
            {
                removeReceipt(uuid);
                PopUtil.ShowMessageBoxWithConfirm("提示", "购买失败!");
            }
        }).OnFail(result =>
        {
            Debug.Log("OnFail: result------------------" + result);
            // 网络问题
            PopUtil.ShowMessageBoxWithConfirmAndCancle("提示", "购买失败!点击确定重试!", () =>
            {             // 点击重新发送服务器验证
                checkReceiptIsValid(productID, receipt, uuid, gameObject);
            }, () =>
            {              // 取消存储在本地,下次启动时候发送
                saveReceipt(receiptDict, uuid);
            });
        }).GoSync();
    }
Пример #2
0
    void Start()
    {
        // 进入主界面, 刷新右上角用户信息
        UserInfoRefreshManager.refreshUserInfo(null);
        initUserInfoView();
        initUIPosition();

        // 检查当前是否有签到,没有签到择弹出签到窗口
        checkIsSignIn();
    }
Пример #3
0
    void loadGoldView()
    {
        GameObject commonUIPrefab = Resources.Load("Prefabs/GoldsItem") as GameObject;

        goldsObjectList = new List <GameObject>();
        for (int i = 0; i < MainData.Instance().chargeGoods.Length; i++)
        {
            ChargeGoodsInfo chargeGoods = MainData.Instance().chargeGoods[i];
            GameObject      golds       = Instantiate(commonUIPrefab) as GameObject;
            float           width       = golds.GetComponent <RectTransform>().sizeDelta.x;
            golds.transform.parent        = GameObject.Find("GoldContent/Viewport/Content").transform;
            golds.name                    = "GoldsItem" + i;
            golds.transform.localPosition = new Vector3(300 + i % 3 * (width + 150), -300 - (i / 3 * 400), 0);
            golds.transform.localScale    = new Vector3(1, 1, 0);

            //Image GoldTypeImage = golds.Find<Image>("GoldContent/Viewport/Content/"+golds.name +"/TopImage/GoldTypeImage");
            Text MondyText      = golds.Find <Text>("GoldContent/Viewport/Content/" + golds.name + "/TopImage/MondyText");
            Text ConversionText = golds.Find <Text>("GoldContent/Viewport/Content/" + golds.name + "/TopImage/ConversionText");
            Text DiamondText    = golds.Find <Text>("GoldContent/Viewport/Content/" + golds.name + "/DiamondImage/DiamondText");

            //GoldTypeImage.SetWebImage(chargeGoods.image, "");
            MondyText.text      = chargeGoods.price + "万";
            ConversionText.text = chargeGoods.goods_describe;
            DiamondText.text    = chargeGoods.price.ToString();

            golds.GetComponent <Button>().onClick.AddListener(() => {
                if (UserManager.Instance().userInfo.diamond_balance < chargeGoods.price)
                {
                    PopUtil.ShowMessageBoxWithConfirm("提示", "钻石不够啦,赶紧去买!");
                    return;
                }
                ShoppingHandle.exchargeDiamond(chargeGoods.id.ToString(), (error) =>
                {
                    if (error == null)
                    {
                        PopUtil.ShowMessageBoxWithConfirm("提示", "兑换成功!");
                        UserInfoRefreshManager.refreshUserInfo(null);
                    }
                    else
                    {
                        PopUtil.ShowMessageBoxWithConfirm("提示", "兑换失败");
                    }
                });
            });

            goldsObjectList.Add(golds);
        }
    }
    // 编辑昵称
    public void editBtnClick()
    {
        Image      editImg       = userCenter.Find <Image>(userCenter.name + "/UserInfo/Name/Edit");
        Text       nameText      = userCenter.Find <Text>(userCenter.name + "/UserInfo/Name/UserName");
        InputField nameFieldText = userCenter.Find <InputField>(userCenter.name + "/UserInfo/Name/NameField");

        if (isEdit)
        {
            if (nameFieldText.text == null || nameFieldText.text == "")
            {
                PopUtil.ShowTotoast("昵称不能为空");
                return;
            }
            else
            {
                isEdit = false;
                editImg.SetLocalImage("Textures/main/main_edit");
                mainHandle.nickname(nameFieldText.text, (error, result) =>
                {
                    if (error == null)
                    {
                        //UserManager.Instance().userInfo.nick_name = result;
                        //UserManager.saveUserInfoToUserDefault(UserManager.Instance().userInfo);
                        Text nicknameText = userCenter.Find <Text>(userCenter.name + "/UserInfo/Name/UserName");
                        nicknameText.text = result;
                        UserInfoRefreshManager.refreshUserInfo(null);
                    }
                    else
                    {
                        PopUtil.ShowTotoast("昵称修改失败");
                        return;
                    }
                });
                GameObject.Find(userCenter.name + "/UserInfo/Name/UserName").SetActive(true);
                GameObject.Find(userCenter.name + "/UserInfo/Name/NameField").SetActive(false);
            }
        }
        else
        {
            isEdit = true;
            editImg.SetLocalImage("Textures/main/main_checkin");
            nameFieldText.Select();
            GameObject.Find(userCenter.name + "/UserInfo/Name/NameField").SetActive(true);
            nameFieldText.text = nameText.text;
            GameObject.Find(userCenter.name + "/UserInfo/Name/UserName").SetActive(false);
        }
    }
Пример #5
0
 /**
  * 任务领取奖励
  */
 public void taskReceiveClick(UserTaskModel userTaskModel)
 {
     TaskHandle.taskReceive(userTaskModel.task_id.ToString(), (error, receiveResult) => {
         if (error == null)
         {
             if (receiveResult.ret == 1)
             {
                 // 成功之后刷新界面
                 refreshNewTask(userTaskModel, receiveResult.data);
                 // 更新用户信息
                 UserInfoRefreshManager.refreshUserInfo(null);
                 PopUtil.ShowSignInSuccessView(userTaskModel.image_describe);
             }
             else
             {
                 PopUtil.ShowMessageBoxWithConfirm("提示", "领取失败!");
             }
         }
         else
         {
             PopUtil.ShowMessageBoxWithConfirm("提示", "领取失败!");
         }
     });
 }