72 行
2.5 KiB
JavaScript
可执行文件
72 行
2.5 KiB
JavaScript
可执行文件
var showIndex = localStorage.exchangeShowIndex||0;
|
|
$('.memb_inner').eq(showIndex).addClass('cheakm');
|
|
$('.list_con').eq(showIndex).show();
|
|
$(".memb_inner").on('touchstart',function() {
|
|
$(".memb_inner").removeClass("cheakm");
|
|
$(this).addClass("cheakm");
|
|
var index = $(this).index();
|
|
localStorage.exchangeShowIndex = index;
|
|
$('.list_con').hide();
|
|
$('.list_con').eq(index).show();
|
|
})
|
|
var need = 0;
|
|
//兑换优惠券
|
|
$('#coupon').on('touchstart',function (e) {
|
|
var e = e ||window.event;
|
|
exchange(e.target,1);
|
|
})
|
|
//兑换商品
|
|
$('#goods').on('touchstart',function (e) {
|
|
var e = e ||window.event;
|
|
exchange(e.target,2);
|
|
})
|
|
|
|
function exchange(target,type) {
|
|
var integral = parseInt($('.memb_a>p>span').html());
|
|
need = parseInt($(target).attr('need'));
|
|
if(need>integral){
|
|
alertMsg('您的积分不足'+need,1000);
|
|
return;
|
|
}
|
|
if(target.className=='memb_c03'||target.className=='memb_b04'){
|
|
var t = type==1?'优惠券':'商品';
|
|
alertSureAndCancel({
|
|
title:'温馨提示',
|
|
detail:'您确认兑换该'+t+'?',
|
|
sureText:'兑换',
|
|
sure:function () {
|
|
alertShowLoading({
|
|
title:t+'兑换中'
|
|
},function () {
|
|
var integral = parseInt($('.memb_a>p>span').html());
|
|
var exchangeid = $(target).attr('id');
|
|
exchangeid = exchangeid.split('-')[1];
|
|
$.post("/index.php/Vip/Exchange/toExchange",{
|
|
exchangeid:exchangeid,
|
|
type:type,
|
|
storeid:storeid
|
|
},function (data) {
|
|
alertHideLoading();
|
|
if(data.success){
|
|
localStorage.exchange = 1;//积分变动
|
|
if(type==1){
|
|
//优惠券
|
|
alertMsg(data.msg,1000,function () {
|
|
window.location.replace("/index.php/Vip/Coupon/index");
|
|
})
|
|
}else {
|
|
//商品
|
|
alertBtn(data.msg,function () {
|
|
window.history.go(-1);//返回首页
|
|
});
|
|
}
|
|
}else {
|
|
alertMsg(data.msg,1000);
|
|
}
|
|
})
|
|
})
|
|
|
|
}
|
|
})
|
|
}
|
|
} |