Add loyalty points
parent
09ab4c6230
commit
12de8be446
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
|
||||
function displayLoyaltyPoints() {
|
||||
$("#loyalty-balance-box").addClass("display-none");
|
||||
$("#loyalty-error").html("");
|
||||
if (inStorage("phonenumber")) {
|
||||
var phone = getStorage("phonenumber");
|
||||
} else {
|
||||
$("#loyalty-error").text("Error: No phone number saved.");
|
||||
}
|
||||
app.dialog.preloader("Checking points balance...");
|
||||
apirequest(SETTINGS.apis.loyalty, {phone: phone}, function (success) {
|
||||
app.dialog.close();
|
||||
if (success.status == "OK") {
|
||||
$("#loyalty-credit-balance").text(success.credits + " points");
|
||||
$("#loyalty-balance-box").removeClass("display-none");
|
||||
|
||||
var canvas = document.createElement('canvas');
|
||||
|
||||
bwipjs.toCanvas(canvas, {
|
||||
bcid: 'code128', // Barcode type
|
||||
text: success.phone, // Text to encode
|
||||
scaleX: 5,
|
||||
scaleY: 1,
|
||||
includetext: false, // Show human-readable text
|
||||
textxalign: 'center', // Always good to set this
|
||||
eclevel: 'M'
|
||||
});
|
||||
document.getElementById("loyalty-barcode").src = canvas.toDataURL('image/png');
|
||||
} else {
|
||||
$("#loyalty-balance-box").addClass("display-none");
|
||||
$("#loyalty-error").text("Error: " + success.message);
|
||||
}
|
||||
}, function (error) {
|
||||
$("#loyalty-error").text("Error: Couldn't check your points balance. Try again later.");
|
||||
}, "GET");
|
||||
}
|
||||
|
||||
function savePhoneNumber() {
|
||||
var phone = $("#phonenumber").val().replace(/\D/g, '');
|
||||
if (phone.length < 10) {
|
||||
app.dialog.alert("Please enter a full 10-digit phone number.", "Oops!");
|
||||
return;
|
||||
}
|
||||
setStorage("phonenumber", phone);
|
||||
router.refreshPage();
|
||||
}
|
@ -0,0 +1,135 @@
|
||||
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
||||
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||
|
||||
<div class="page" data-name="loyalty">
|
||||
|
||||
<div class="navbar">
|
||||
<div class="navbar-bg"></div>
|
||||
<div class="navbar-inner">
|
||||
<div class="left">
|
||||
<a class="link back" href="#">
|
||||
<i class="icon icon-back"></i>
|
||||
<span class="if-not-md">Back</span>
|
||||
</a>
|
||||
</div>
|
||||
<div class="title">Loyalty Points</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="page-content">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-100 medium-90 xlarge-75 margin-horizontal">
|
||||
<div class="card margin">
|
||||
<div class="card-content text-align-center padding-vertical">
|
||||
{{#if hasphone}}
|
||||
<div id="loyalty-balance-box" class="card-content-padding">
|
||||
<div>You have earned a total of</div>
|
||||
<h1 id="loyalty-credit-balance">...</h1>
|
||||
<img id="loyalty-barcode" style="max-width: 90%; padding: 1.2em; background: white;" />
|
||||
<!-- Timeline -->
|
||||
<div class="timeline">
|
||||
<!-- Timeline item -->
|
||||
<div class="timeline-item">
|
||||
<div class="timeline-item-date">36 Points</div>
|
||||
<div class="timeline-item-divider"></div>
|
||||
<div class="timeline-item-content">
|
||||
<div class="timeline-item-inner">
|
||||
Postcard stamp
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Timeline item with inner -->
|
||||
<div class="timeline-item">
|
||||
<div class="timeline-item-date">50 Points</div>
|
||||
<div class="timeline-item-divider"></div>
|
||||
<div class="timeline-item-content">
|
||||
<div class="timeline-item-inner">
|
||||
Forever stamp
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="timeline-item">
|
||||
<div class="timeline-item-date">100 Points</div>
|
||||
<div class="timeline-item-divider"></div>
|
||||
<div class="timeline-item-content">
|
||||
<div class="timeline-item-inner">
|
||||
$1 pickup discount
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="timeline-item">
|
||||
<div class="timeline-item-date">500 Points</div>
|
||||
<div class="timeline-item-divider"></div>
|
||||
<div class="timeline-item-content">
|
||||
<div class="timeline-item-inner">
|
||||
<div class="timeline-item-text">$5 pickup discount</div>
|
||||
</div>
|
||||
<div class="timeline-item-inner">
|
||||
<div class="timeline-item-text">Sheet of Forever stamps</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="timeline-item">
|
||||
<div class="timeline-item-date">800 Points</div>
|
||||
<div class="timeline-item-divider"></div>
|
||||
<div class="timeline-item-content">
|
||||
<div class="timeline-item-inner">
|
||||
Postage for a Priority Mail envelope or small flat rate box
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="timeline-item">
|
||||
<div class="timeline-item-date">2500 Points</div>
|
||||
<div class="timeline-item-divider"></div>
|
||||
<div class="timeline-item-content">
|
||||
<div class="timeline-item-inner">
|
||||
Postage for a Priority Mail Express envelope
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="loyalty-error"></div>
|
||||
{{else}}
|
||||
<div class="block">
|
||||
Save your phone number to start earning points!
|
||||
</div>
|
||||
<div class="list">
|
||||
<ul id="savephoneform">
|
||||
<li class="item-content item-input item-input-outline">
|
||||
<div class="item-inner">
|
||||
<div class="item-title item-floating-label">Phone Number</div>
|
||||
<div class="item-input-wrap">
|
||||
<input type="tel" id="phonenumber" />
|
||||
<span class="input-clear-button"></span>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="card-content-padding">
|
||||
<div class="button" onclick="savePhoneNumber()"><i class="far fa-phone-plus"></i> Save Number</div>
|
||||
</div>
|
||||
{{/if}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="block">
|
||||
Loyalty points have no cash value. All points and associated discounts
|
||||
are offered as a courtesy by and at the discretion of Helena Express
|
||||
and may be revoked, canceled, or modified at any time for any reason.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="popup text-color-black" id="addresscode-popup">
|
||||
<div class="block text-align-center">
|
||||
<img id="addresscode-barcode" style="max-width: 90%;" />
|
||||
<p>Present this code to the Helena Express agent.</p>
|
||||
<p><a class="button popup-close" href="#">Close</a></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
Loading…
Reference in New Issue