You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
219 lines
6.1 KiB
JavaScript
219 lines
6.1 KiB
JavaScript
const app = getApp();
|
|
const util = require("../../utils/util.js")
|
|
const card = require('../../utils/card.js');
|
|
Page({
|
|
|
|
data: {
|
|
|
|
},
|
|
|
|
onLoad: function(options) {
|
|
//获取积分优惠券
|
|
//获取vip商品
|
|
//获取周边商品
|
|
if (!options.type) {
|
|
util.showWaring("缺少type参数,即将分返");
|
|
setTimeout(function() {
|
|
wx.navigateBack({})
|
|
}, 3000)
|
|
return;
|
|
}
|
|
if (options.type == 1) {
|
|
this.get_pointCoupon();
|
|
} else if (options.type == 2) {
|
|
this.get_roduct();
|
|
}
|
|
this.setData({
|
|
type: options.type
|
|
})
|
|
},
|
|
get_pointCoupon: function() {
|
|
var that = this;
|
|
//2 代表免费领取
|
|
card.couponCenter("", 1, function(json) {
|
|
console.log(json)
|
|
var data = json.data;
|
|
if (data.status == 1) {
|
|
var list = [];
|
|
if (data.list.length > 0) {
|
|
var memberReceiveCoupons = data.memberReceiveCoupons;
|
|
var memberDayReceiveCoupons = data.memberDayReceiveCoupons;
|
|
var list = [];
|
|
for (var item of data.list) {
|
|
if (memberReceiveCoupons[item.id]) {
|
|
var num = memberReceiveCoupons[item.id] ? memberReceiveCoupons[item.id] : 0;
|
|
if (item.personLimitNum != 0) {
|
|
if (parseFloat(num) >= parseFloat(item.personLimitNum)) {
|
|
continue;
|
|
}
|
|
}
|
|
// else {
|
|
// continue;
|
|
// }
|
|
}
|
|
var dayPersonLimitNum = item.dayPersonLimitNum;
|
|
if (memberDayReceiveCoupons[item.id]) {
|
|
var num = memberDayReceiveCoupons[item.id] ? memberDayReceiveCoupons[item.id] : 0;
|
|
if (parseFloat(num) >= parseFloat(dayPersonLimitNum)) {
|
|
continue;
|
|
}
|
|
}
|
|
|
|
if (item.cardType == "DISCOUNT") {
|
|
item.unitName = "折";
|
|
item.amount = item.discount;
|
|
item.size = "60rpx";
|
|
item.height = "90rpx;";
|
|
} else if (item.cardType == "CASH") {
|
|
item.unitName = "¥";
|
|
item.size = "60rpx";
|
|
item.height = "90rpx;";
|
|
item.amount = item.reduceCost;
|
|
} else if (item.cardType == "GIFT") {
|
|
item.unitName = "兑";
|
|
item.amount = "换券";
|
|
item.size = "34rpx";
|
|
item.height = "60rpx;";
|
|
}
|
|
if (item.status == 0) {
|
|
item.bgImage = "../../images/icon-coupon-unimage.png";
|
|
item.useStatus = "条件\不足";
|
|
} else if (item.status == 1) {
|
|
item.bgImage = "http://pos.juweiyun.cn/373001/file/wechatAppnewCoupon.png";
|
|
item.useStatus = "立即\n领取";
|
|
}
|
|
if (item.coverLogo) {
|
|
item.logoUrl = item.coverLogo
|
|
} else {
|
|
item.logoUrl = "http://pos.juweiyun.cn/373001/file/wechatApp%E5%88%B8%E5%8C%85%402x.png"
|
|
}
|
|
item.color = "#FFC639";
|
|
item.condition = "满" + item.leastCost + "可用";
|
|
item.effective = item.startDate + " 至 " + item.endDate;
|
|
item.shopType = 0;
|
|
list.push(item);
|
|
}
|
|
that.setData({
|
|
listPackage: list
|
|
})
|
|
} else {
|
|
that.setData({
|
|
listPackage: data.list,
|
|
})
|
|
wx.showToast({
|
|
title: "暂无优惠券",
|
|
icon: "none"
|
|
})
|
|
}
|
|
} else {
|
|
wx.showToast({
|
|
title: data.errMessage,
|
|
icon: "none"
|
|
})
|
|
}
|
|
}, function fail(err) {
|
|
console.log(err);
|
|
wx.showToast({
|
|
title: "网络连接不稳定, 请重试",
|
|
icon: "none"
|
|
})
|
|
})
|
|
},
|
|
get_roduct: function() {
|
|
var that = this;
|
|
card.pointAllTypeProduct( function(success) {
|
|
var result = success.data;
|
|
if (result.status == 1) {
|
|
// var list = result.list;
|
|
// for(var item of list){
|
|
// item.shopType = parseInt(type)+1;
|
|
// }
|
|
// if (type == 0) {
|
|
// that.setData({
|
|
// vipProduct: list
|
|
// });
|
|
// } else if (type == 1) {
|
|
// that.setData({
|
|
// memberProduct: list
|
|
// });
|
|
// }
|
|
var list = result.list;
|
|
var pointProduct = [];
|
|
for (var item of list) {
|
|
item.shopType = (parseInt(1) + 1);
|
|
pointProduct.push(item);
|
|
}
|
|
that.setData({
|
|
vipProduct: pointProduct
|
|
});
|
|
} else {
|
|
var str;
|
|
if (type == 0) {
|
|
str = "vip专区";
|
|
} else {
|
|
str = "会员周边";
|
|
}
|
|
var msg = "暂无" + str + "商品";
|
|
wx.showToast({
|
|
title: msg,
|
|
icon: "none"
|
|
})
|
|
}
|
|
}, function(error) {
|
|
console.log(err);
|
|
wx.showToast({
|
|
title: "网络连接不稳定, 请重试",
|
|
icon: "none"
|
|
})
|
|
})
|
|
},
|
|
goto_detail: function(e) {
|
|
console.log(e)
|
|
var shopType = e.currentTarget.dataset.shoptype;
|
|
var data = {};
|
|
data.shopType = shopType;
|
|
if (shopType == 0) {
|
|
var id = e.currentTarget.dataset.id;
|
|
var list = this.data.listPackage;
|
|
data.id = id;
|
|
for (var item of list) {
|
|
if (item.id) {
|
|
if (item.id == id) {
|
|
data.couponDetail = item;
|
|
}
|
|
}
|
|
}
|
|
} else if (shopType == 1 || shopType == 2) {
|
|
var productid = e.currentTarget.dataset.productid;
|
|
var schemeid = e.currentTarget.dataset.schemeid;
|
|
data.productid = productid;
|
|
data.schemeid = schemeid;
|
|
if (data.shopType == 2) {
|
|
data.shopType = 1;
|
|
}
|
|
}
|
|
if(data.couponDetail){
|
|
app.globalData.productDetailLogUrl = data.couponDetail.logoUrl;
|
|
//怕图片地址太长页面传递参数长度超过限制解析报错
|
|
data.couponDetail.logoUrl="";
|
|
}
|
|
wx.navigateTo({
|
|
url: "productDetail?data=" + JSON.stringify(data),
|
|
})
|
|
},
|
|
|
|
onShow: function() {
|
|
|
|
},
|
|
|
|
onPullDownRefresh: function() {
|
|
|
|
},
|
|
|
|
onReachBottom: function() {
|
|
|
|
},
|
|
onShareAppMessage: function() {
|
|
|
|
}
|
|
}) |