|
|
|
@ -6,9 +6,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function checkAccountStatus(callback) {
|
|
|
|
|
if (inStorage("phonenumber")) {
|
|
|
|
|
if (inStorage("accountnumber")) {
|
|
|
|
|
apirequest(SETTINGS.apis.authorstartverify, {
|
|
|
|
|
phone: getStorage("phonenumber"),
|
|
|
|
|
accountnumber: getStorage("accountnumber"),
|
|
|
|
|
accountkey: (inStorage("accountkey") ? getStorage("accountkey") : "")
|
|
|
|
|
}, function (resp) {
|
|
|
|
|
if (resp.status == "OK") {
|
|
|
|
@ -27,7 +27,7 @@ function checkAccountStatus(callback) {
|
|
|
|
|
router.back();
|
|
|
|
|
// Server is saying something's wrong, let's clear the account number in case
|
|
|
|
|
// the user wants to try a different one.
|
|
|
|
|
removeFromStorage("phonenumber");
|
|
|
|
|
removeFromStorage("accountnumber");
|
|
|
|
|
app.dialog.alert(resp.msg, "Error");
|
|
|
|
|
}
|
|
|
|
|
}, function (err) {
|
|
|
|
@ -40,12 +40,12 @@ function checkAccountStatus(callback) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function checkIfAccountGoodWithPaymentMethod(successcb, errorcb) {
|
|
|
|
|
if (!inStorage("phonenumber") || !inStorage("accountkey")) {
|
|
|
|
|
if (!inStorage("accountnumber") || !inStorage("accountkey")) {
|
|
|
|
|
successcb(false);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
apirequest(SETTINGS.apis.getaccountinfo, {
|
|
|
|
|
phone: getStorage("phonenumber"),
|
|
|
|
|
accountnumber: getStorage("accountnumber"),
|
|
|
|
|
accountkey: getStorage("accountkey")
|
|
|
|
|
}, function (success) {
|
|
|
|
|
if (success.status == "OK") {
|
|
|
|
@ -79,7 +79,7 @@ function verifyCode(code) {
|
|
|
|
|
app.dialog.preloader("Verifying...");
|
|
|
|
|
apirequest(SETTINGS.apis.verifyauthcode, {
|
|
|
|
|
code: code,
|
|
|
|
|
phone: getStorage("phonenumber")
|
|
|
|
|
accountnumber: getStorage("accountnumber")
|
|
|
|
|
}, function (resp) {
|
|
|
|
|
app.dialog.close();
|
|
|
|
|
if (resp.status == "OK") {
|
|
|
|
@ -98,13 +98,13 @@ function verifyCode(code) {
|
|
|
|
|
function displayAccountInfo() {
|
|
|
|
|
$("#loyaltyBalanceBox").addClass("display-none");
|
|
|
|
|
$("#loyaltyErrorMessage").html("");
|
|
|
|
|
if (inStorage("accountkey") && inStorage("phonenumber")) {
|
|
|
|
|
if (inStorage("accountkey") && inStorage("accountnumber")) {
|
|
|
|
|
} else {
|
|
|
|
|
$("#loyaltyErrorMessage").text("Error: No account connected.");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
apirequest(SETTINGS.apis.getaccountinfo, {
|
|
|
|
|
phone: getStorage("phonenumber"),
|
|
|
|
|
accountnumber: getStorage("accountnumber"),
|
|
|
|
|
accountkey: getStorage("accountkey")
|
|
|
|
|
}, function (success) {
|
|
|
|
|
$("#hasaccountbox").css("display", "");
|
|
|
|
@ -112,7 +112,7 @@ function displayAccountInfo() {
|
|
|
|
|
if (success.status == "OK") {
|
|
|
|
|
$("#loyaltyCreditBalanceHeading").text(success.credits + " points");
|
|
|
|
|
$("#loyaltyBalanceBox").removeClass("display-none")
|
|
|
|
|
$("#accountnumberspan").text(success.phone);
|
|
|
|
|
$("#accountnumberspan").text(success.accountnumber);
|
|
|
|
|
|
|
|
|
|
if (success.payments_setup === false) {
|
|
|
|
|
$("#addPaymentMethodBox").css("display", "");
|
|
|
|
@ -121,6 +121,7 @@ function displayAccountInfo() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$("#accountupdateform input#name").val(success.name);
|
|
|
|
|
$("#accountupdateform input#phone").val(success.phone);
|
|
|
|
|
$("#accountupdateform input#email").val(success.email);
|
|
|
|
|
$("#accountupdateform input#streetaddress").val(success.streetaddress);
|
|
|
|
|
$("#accountupdateform input#zipcode").val(success.zipcode);
|
|
|
|
@ -168,7 +169,7 @@ $("body").on("click", "#setupAccountBtn", function () {
|
|
|
|
|
app.dialog.alert(resp.msg, "Error");
|
|
|
|
|
return;
|
|
|
|
|
} else {
|
|
|
|
|
setStorage("phonenumber", resp.phone);
|
|
|
|
|
setStorage("accountnumber", resp.accountnumber);
|
|
|
|
|
router.refreshPage();
|
|
|
|
|
}
|
|
|
|
|
}, function (error) {
|
|
|
|
@ -196,9 +197,10 @@ $("body").on("click", "#updateAccountBtn", function () {
|
|
|
|
|
}
|
|
|
|
|
app.dialog.preloader("Updating Account...");
|
|
|
|
|
apirequest(SETTINGS.apis.accountregister, {
|
|
|
|
|
phone: getStorage("phonenumber"),
|
|
|
|
|
accountnumber: getStorage("accountnumber"),
|
|
|
|
|
accountkey: getStorage("accountkey"),
|
|
|
|
|
name: $("#accountupdateform input#name").val(),
|
|
|
|
|
phone: $("#accountupdateform input#phone").val(),
|
|
|
|
|
email: $("#accountupdateform input#email").val(),
|
|
|
|
|
address: $("#accountupdateform input#streetaddress").val(),
|
|
|
|
|
zipcode: $("#accountupdateform input#zipcode").val()
|
|
|
|
@ -210,7 +212,7 @@ $("body").on("click", "#updateAccountBtn", function () {
|
|
|
|
|
return;
|
|
|
|
|
} else {
|
|
|
|
|
app.popup.close("#accountUpdatePopup", true);
|
|
|
|
|
setStorage("phonenumber", resp.phone);
|
|
|
|
|
setStorage("accountnumber", resp.accountnumber);
|
|
|
|
|
router.refreshPage();
|
|
|
|
|
app.dialog.alert("Account details updated.", "Account Updated");
|
|
|
|
|
}
|
|
|
|
@ -227,7 +229,7 @@ $("body").on("click", "#connectExistingAccountBtn", function () {
|
|
|
|
|
app.dialog.alert("Please enter a full 10-digit phone number.", "Oops!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
setStorage("phonenumber", phone);
|
|
|
|
|
setStorage("accountnumber", accountnumber);
|
|
|
|
|
router.refreshPage();
|
|
|
|
|
}, function (cancel) {
|
|
|
|
|
// shrug
|
|
|
|
@ -236,6 +238,7 @@ $("body").on("click", "#connectExistingAccountBtn", function () {
|
|
|
|
|
|
|
|
|
|
$("body").on("popup:open", "#accountUpdatePopup", function () {
|
|
|
|
|
app.input.checkEmptyState("#accountupdateform input#name");
|
|
|
|
|
app.input.checkEmptyState("#accountupdateform input#phone");
|
|
|
|
|
app.input.checkEmptyState("#accountupdateform input#email");
|
|
|
|
|
app.input.checkEmptyState("#accountupdateform input#streetaddress");
|
|
|
|
|
app.input.checkEmptyState("#accountupdateform input#zipcode");
|
|
|
|
@ -269,7 +272,7 @@ function openCheckoutWindowToSaveCard(onaccountpage) {
|
|
|
|
|
onaccountpage = true;
|
|
|
|
|
}
|
|
|
|
|
openBrowser(SETTINGS.apis.redirecttopaymentsetup
|
|
|
|
|
+ "?phone=" + getStorage("phonenumber")
|
|
|
|
|
+ "?accountnumber=" + getStorage("accountnumber")
|
|
|
|
|
+ "&accountkey=" + getStorage("accountkey"),
|
|
|
|
|
"location=yes,hidenavigationbuttons=yes,hideurlbar=yes,zoom=no,hardwareback=no,fullscreen=no,presentationstyle=pagesheet,toolbarposition=top,lefttoright=yes,toolbarcolor=#D0F2FC",
|
|
|
|
|
function () {
|
|
|
|
|