Add loyalty points
This commit is contained in:
parent
09ab4c6230
commit
12de8be446
52
www/assets/js/loyalty.js
Normal file
52
www/assets/js/loyalty.js
Normal file
@ -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();
|
||||
}
|
@ -53,6 +53,7 @@
|
||||
<script src="assets/js/addresscode.js"></script>
|
||||
<script src="assets/js/rates.js"></script>
|
||||
<script src="assets/js/noticeslip.js"></script>
|
||||
<script src="assets/js/loyalty.js"></script>
|
||||
|
||||
<script src="routes.js"></script>
|
||||
<script src="assets/js/main.js"></script>
|
135
www/pages/loyalty.html
Normal file
135
www/pages/loyalty.html
Normal file
@ -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>
|
@ -26,24 +26,30 @@ var routes = [
|
||||
icon: "fad fa-search",
|
||||
text: "Find the latest location and updates about any shipment."
|
||||
},
|
||||
{
|
||||
title: "Get Rates",
|
||||
href: "/rates",
|
||||
icon: "fad fa-calculator",
|
||||
text: "Calculate postage and prices for your item."
|
||||
},
|
||||
{
|
||||
title: "Pick Up and Redeliver",
|
||||
href: "/noticeslip",
|
||||
icon: "fad fa-sticky-note",
|
||||
text: "Take a picture of your pink postal notice slip and we'll go get your missed delivery."
|
||||
},
|
||||
{
|
||||
title: "Loyalty Points",
|
||||
href: "/loyalty",
|
||||
icon: "fad fa-badge-dollar",
|
||||
text: "Earn free stamps and discounts."
|
||||
},
|
||||
{
|
||||
title: "Express Pickup",
|
||||
href: "/addresscode",
|
||||
icon: "fal fa-qrcode",
|
||||
text: "Get a faster pickup and a discount by pre-typing the destination address here."
|
||||
},
|
||||
{
|
||||
title: "Get Rates",
|
||||
href: "/rates",
|
||||
icon: "fad fa-calculator",
|
||||
text: "Calculate postage and prices for your item."
|
||||
},
|
||||
]
|
||||
}
|
||||
});
|
||||
@ -130,6 +136,25 @@ var routes = [
|
||||
});
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/loyalty',
|
||||
name: 'loyalty',
|
||||
async: function (routeTo, routeFrom, resolve, reject) {
|
||||
var hasPhone = inStorage("phonenumber");
|
||||
var phone = getStorage("phonenumber");
|
||||
resolve({
|
||||
templateUrl: './pages/loyalty.html'
|
||||
}, {
|
||||
context: {
|
||||
hasphone: hasPhone,
|
||||
phone: phone
|
||||
},
|
||||
on: {
|
||||
pageAfterIn: displayLoyaltyPoints
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/track/:code',
|
||||
name: 'trackresult',
|
||||
|
@ -8,7 +8,8 @@ var SETTINGS = {
|
||||
apis: {
|
||||
track: "https://helena.express/tracker/api.php",
|
||||
rates: "https://helena.express/rateapi.php",
|
||||
pickuprequest: "https://helena.express/pspickup.php"
|
||||
pickuprequest: "https://helena.express/pspickup.php",
|
||||
loyalty: "https://helena.express/loyalty.php"
|
||||
},
|
||||
stripe_pubkey: "pk_live_RgpadCo1LIIkfyUsY47VhUq6",
|
||||
appointmenturl: "https://appointments.netsyms.com/index.php?service=19&hlnexp=1&embed=1&only=1",
|
||||
|
Loading…
x
Reference in New Issue
Block a user