Temp fix for inventory and buy

This commit is contained in:
Zach Fox 2017-08-24 10:24:06 -07:00
parent a489267cec
commit 3d0fd76997
2 changed files with 19 additions and 80 deletions

View file

@ -17,6 +17,7 @@ import QtQuick.Controls 1.4
import "../../styles-uit" import "../../styles-uit"
import "../../controls-uit" as HifiControlsUit import "../../controls-uit" as HifiControlsUit
import "../../controls" as HifiControls import "../../controls" as HifiControls
import "./wallet" as HifiWallet
// references XXX from root context // references XXX from root context
@ -30,28 +31,29 @@ Rectangle {
property string itemHref: ""; property string itemHref: "";
property int balanceAfterPurchase: 0; property int balanceAfterPurchase: 0;
property bool alreadyOwned: false; property bool alreadyOwned: false;
property int itemPriceFull: 0;
// Style // Style
color: hifi.colors.baseGray; color: hifi.colors.baseGray;
Hifi.QmlCommerce { Hifi.QmlCommerce {
id: commerce; id: commerce;
onBuyResult: { onBuyResult: {
if (result.status !== 'success') { if (result.status !== 'success') {
buyButton.text = result.message; buyButton.text = result.message;
buyButton.enabled = false; buyButton.enabled = false;
} else { } else {
if (urlHandler.canHandleUrl(itemHref)) { if (urlHandler.canHandleUrl(itemHref)) {
urlHandler.handleUrl(itemHref); urlHandler.handleUrl(itemHref);
}
sendToScript({method: 'checkout_buySuccess', itemId: itemId});
} }
sendToScript({method: 'checkout_buySuccess', itemId: itemId});
}
} }
onBalanceResult: { onBalanceResult: {
if (result.status !== 'success') { if (result.status !== 'success') {
console.log("Failed to get balance", result.message); console.log("Failed to get balance", result.message);
} else { } else {
balanceReceived = true; balanceReceived = true;
hfcBalanceText.text = result.data.balance; hfcBalanceText.text = parseFloat(result.data.balance/100).toFixed(2);
balanceAfterPurchase = result.data.balance - parseInt(itemPriceText.text, 10); balanceAfterPurchase = parseFloat(result.data.balance/100) - parseFloat(checkoutRoot.itemPriceFull/100).toFixed(2);
} }
} }
onInventoryResult: { onInventoryResult: {
@ -67,14 +69,6 @@ Rectangle {
} }
} }
} }
onSecurityImageResult: {
securityImage.source = securityImageSelection.getImagePathFromImageID(imageID);
}
}
SecurityImageSelection {
id: securityImageSelection;
referrerURL: checkoutRoot.itemHref;
} }
// //
@ -89,20 +83,6 @@ Rectangle {
anchors.left: parent.left; anchors.left: parent.left;
anchors.top: parent.top; anchors.top: parent.top;
// Security Image
Image {
id: securityImage;
// Anchors
anchors.top: parent.top;
anchors.left: parent.left;
anchors.leftMargin: 16;
height: parent.height - 5;
width: height;
anchors.verticalCenter: parent.verticalCenter;
fillMode: Image.PreserveAspectFit;
mipmap: true;
}
// Title Bar text // Title Bar text
RalewaySemiBold { RalewaySemiBold {
id: titleBarText; id: titleBarText;
@ -111,7 +91,7 @@ Rectangle {
size: hifi.fontSizes.overlayTitle; size: hifi.fontSizes.overlayTitle;
// Anchors // Anchors
anchors.top: parent.top; anchors.top: parent.top;
anchors.left: securityImage.right; anchors.left: parent.left;
anchors.leftMargin: 16; anchors.leftMargin: 16;
anchors.bottom: parent.bottom; anchors.bottom: parent.bottom;
width: paintedWidth; width: paintedWidth;
@ -420,7 +400,7 @@ Rectangle {
text: (inventoryReceived && balanceReceived) ? (alreadyOwned ? "Already Owned: Get Item" : "Buy") : "--"; text: (inventoryReceived && balanceReceived) ? (alreadyOwned ? "Already Owned: Get Item" : "Buy") : "--";
onClicked: { onClicked: {
if (!alreadyOwned) { if (!alreadyOwned) {
commerce.buy(itemId, parseInt(itemPriceText.text)); commerce.buy(itemId, parseFloat(itemPriceText.text*100));
} else { } else {
if (urlHandler.canHandleUrl(itemHref)) { if (urlHandler.canHandleUrl(itemHref)) {
urlHandler.handleUrl(itemHref); urlHandler.handleUrl(itemHref);
@ -456,11 +436,11 @@ Rectangle {
itemId = message.params.itemId; itemId = message.params.itemId;
itemNameText.text = message.params.itemName; itemNameText.text = message.params.itemName;
itemAuthorText.text = message.params.itemAuthor; itemAuthorText.text = message.params.itemAuthor;
itemPriceText.text = message.params.itemPrice; checkoutRoot.itemPriceFull = message.params.itemPrice;
itemPriceText.text = parseFloat(checkoutRoot.itemPriceFull/100).toFixed(2);
itemHref = message.params.itemHref; itemHref = message.params.itemHref;
commerce.balance(); commerce.balance();
commerce.inventory(); commerce.inventory();
commerce.getSecurityImage();
break; break;
default: default:
console.log('Unrecognized message from marketplaces.js:', JSON.stringify(message)); console.log('Unrecognized message from marketplaces.js:', JSON.stringify(message));

View file

@ -17,6 +17,7 @@ import QtQuick.Controls 1.4
import "../../styles-uit" import "../../styles-uit"
import "../../controls-uit" as HifiControlsUit import "../../controls-uit" as HifiControlsUit
import "../../controls" as HifiControls import "../../controls" as HifiControls
import "./wallet" as HifiWallet
// references XXX from root context // references XXX from root context
@ -33,7 +34,7 @@ Rectangle {
if (result.status !== 'success') { if (result.status !== 'success') {
console.log("Failed to get balance", result.message); console.log("Failed to get balance", result.message);
} else { } else {
hfcBalanceText.text = result.data.balance; hfcBalanceText.text = parseFloat(result.data.balance/100).toFixed(2);
} }
} }
onInventoryResult: { onInventoryResult: {
@ -43,14 +44,6 @@ Rectangle {
inventoryContentsList.model = result.data.assets; inventoryContentsList.model = result.data.assets;
} }
} }
onSecurityImageResult: {
securityImage.source = securityImageSelection.getImagePathFromImageID(imageID);
}
}
SecurityImageSelection {
id: securityImageSelection;
referrerURL: inventoryRoot.referrerURL;
} }
// //
@ -65,20 +58,6 @@ Rectangle {
anchors.left: parent.left; anchors.left: parent.left;
anchors.top: parent.top; anchors.top: parent.top;
// Security Image
Image {
id: securityImage;
// Anchors
anchors.top: parent.top;
anchors.left: parent.left;
anchors.leftMargin: 16;
height: parent.height - 5;
width: height;
anchors.verticalCenter: parent.verticalCenter;
fillMode: Image.PreserveAspectFit;
mipmap: true;
}
// Title Bar text // Title Bar text
RalewaySemiBold { RalewaySemiBold {
id: titleBarText; id: titleBarText;
@ -87,7 +66,7 @@ Rectangle {
size: hifi.fontSizes.overlayTitle; size: hifi.fontSizes.overlayTitle;
// Anchors // Anchors
anchors.top: parent.top; anchors.top: parent.top;
anchors.left: securityImage.right; anchors.left: parent.left;
anchors.leftMargin: 16; anchors.leftMargin: 16;
anchors.bottom: parent.bottom; anchors.bottom: parent.bottom;
width: paintedWidth; width: paintedWidth;
@ -98,25 +77,6 @@ Rectangle {
verticalAlignment: Text.AlignVCenter; verticalAlignment: Text.AlignVCenter;
} }
// "Change Security Image" button
HifiControlsUit.Button {
id: changeSecurityImageButton;
color: hifi.buttons.black;
colorScheme: hifi.colorSchemes.dark;
anchors.top: parent.top;
anchors.topMargin: 3;
anchors.bottom: parent.bottom;
anchors.bottomMargin: 3;
anchors.right: parent.right;
anchors.rightMargin: 20;
width: 200;
text: "Change Security Image"
onClicked: {
securityImageSelection.isManuallyChangingSecurityImage = true;
securityImageSelection.visible = true;
}
}
// Separator // Separator
HifiControlsUit.Separator { HifiControlsUit.Separator {
anchors.left: parent.left; anchors.left: parent.left;
@ -307,7 +267,6 @@ Rectangle {
referrerURL = message.referrerURL; referrerURL = message.referrerURL;
commerce.balance(); commerce.balance();
commerce.inventory(); commerce.inventory();
commerce.getSecurityImage();
break; break;
default: default:
console.log('Unrecognized message from marketplaces.js:', JSON.stringify(message)); console.log('Unrecognized message from marketplaces.js:', JSON.stringify(message));