|
@@ -239,6 +239,16 @@
|
|
|
<p class="totalT">Total</p>
|
|
|
<p class="totalVal">${$cartMoney}</p>
|
|
|
</div>
|
|
|
+ <div class="mbItem">
|
|
|
+ <div class="windInfoBox freeshipping">
|
|
|
+ {if $payByPoints}
|
|
|
+ <p class="key">You can redeem this order for free through points!</p>
|
|
|
+ {/if}
|
|
|
+ </div>
|
|
|
+ <div class="windInfoBox">
|
|
|
+ <p class="key">Your Points:{$points}</p>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
<div class="payPalButton">
|
|
|
<span>PayPal</span>
|
|
|
</div>
|
|
@@ -359,8 +369,9 @@
|
|
|
<script src="/assets/index/js/jquery.lazyload.js"></script>
|
|
|
<script>
|
|
|
$(document).ready(function () {
|
|
|
-
|
|
|
var addressId = {$addressId};
|
|
|
+ var payByPoints = "{$payByPoints}";
|
|
|
+ //console.log(payByPoints, payByPoints)
|
|
|
|
|
|
//默认地址
|
|
|
const defaultAddressInfo = {
|
|
@@ -368,14 +379,14 @@
|
|
|
lastName: "{$lastName}",
|
|
|
phoneNumber: "{$phone}",
|
|
|
areaSelect: "{$regionId}",
|
|
|
- address: "{$full}",
|
|
|
+ address: "{$detail}",
|
|
|
mailbox: "{$email}",
|
|
|
postalCode: "{$zipCode}"
|
|
|
}
|
|
|
// 是否已填写过地址
|
|
|
- if (addressId){
|
|
|
+ if (addressId) {
|
|
|
var isAddress = true
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
var isAddress = false
|
|
|
}
|
|
|
|
|
@@ -393,7 +404,7 @@
|
|
|
|
|
|
//初始化表单
|
|
|
function initAddressForm() {
|
|
|
- const {userName, lastName,phoneNumber, areaSelect, address, mailbox, postalCode} = defaultAddressInfo || {}
|
|
|
+ const {userName, lastName, phoneNumber, areaSelect, address, mailbox, postalCode} = defaultAddressInfo || {}
|
|
|
userName && $("#userName").val(userName)
|
|
|
lastName && $("#lastName").val(lastName)
|
|
|
phoneNumber && $("#phoneNumber").val(phoneNumber)
|
|
@@ -518,7 +529,6 @@
|
|
|
|
|
|
//支付方法
|
|
|
const orderPayment = (params) => {
|
|
|
- console.log(params)
|
|
|
return new Promise(function (resolve, reject) {
|
|
|
$.ajax({
|
|
|
url: "/index/checkout/submit?payType=30&mode=cart&address_id=" + addressId,
|
|
@@ -542,7 +552,6 @@
|
|
|
}
|
|
|
|
|
|
const orderPaymentPoints = (params) => {
|
|
|
- console.log(params)
|
|
|
return new Promise(function (resolve, reject) {
|
|
|
$.ajax({
|
|
|
url: "/index/checkout/submit?payType=50&mode=cart&address_id=" + addressId,
|
|
@@ -565,7 +574,6 @@
|
|
|
});
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 商品操作方法
|
|
|
* @param _this $(this)
|
|
@@ -578,7 +586,7 @@
|
|
|
const goodsId = _this.closest(".productItem").attr("goods-id");
|
|
|
const goodsSkuId = _this.closest(".productItem").attr("goods-sku-id");
|
|
|
let goodsNum = parseInt(_this.closest(".productItem").attr("data-goods-num"));
|
|
|
- console.log(productId, goodsId, goodsSkuId)
|
|
|
+ //console.log(productId, goodsId, goodsSkuId)
|
|
|
//商品增加
|
|
|
if (type === "add" || type === "reduce") {
|
|
|
if (type === "add") {
|
|
@@ -586,7 +594,6 @@
|
|
|
} else {
|
|
|
goodsNum -= 1
|
|
|
}
|
|
|
- console.log("商品增加")
|
|
|
$.ajax({
|
|
|
url: "/index/cart/update?goodsId=" + goodsId + "&goodsSkuId=" + goodsSkuId + "&goodsNum=" + goodsNum,
|
|
|
method: "POST",
|
|
@@ -676,9 +683,9 @@
|
|
|
const {status, message, data} = res || {}
|
|
|
if (status === 200 || status === "200") {
|
|
|
window.open(data.payment.approval_link, "_blank");
|
|
|
- var interId = setInterval(function (){
|
|
|
+ var interId = setInterval(function () {
|
|
|
fetchOrder(data.orderId, interId);
|
|
|
- },2000)
|
|
|
+ }, 2000)
|
|
|
} else if (status === 401 || status === "401") {
|
|
|
window.location.replace('../passport/logIn.html')
|
|
|
} else {
|
|
@@ -686,10 +693,10 @@
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- function fetchOrder(orderId, interId){
|
|
|
- $.get('/index/order/detail?orderId='+ orderId,function (res){
|
|
|
+ function fetchOrder(orderId, interId) {
|
|
|
+ $.get('/index/order/detail?orderId=' + orderId, function (res) {
|
|
|
console.log(res.data.order.pay_status);
|
|
|
- if (res.status == 200 && res.data.order.pay_status == 20){
|
|
|
+ if (res.status == 200 && res.data.order.pay_status == 20) {
|
|
|
clearInterval(interId);
|
|
|
$("#loadingModel").hide(0);
|
|
|
window.location.replace('/index/user/orderDetails.html?orderId=' + orderId)
|
|
@@ -700,6 +707,11 @@
|
|
|
|
|
|
//支付
|
|
|
$(".checkoutButton").on(tap, async function () {
|
|
|
+ if (payByPoints !== '1'){
|
|
|
+ showToast('Insufficient points!')
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
console.log("points")
|
|
|
const params = {
|
|
|
"delivery": 10,
|