/** */ $(function(){ //判断页面是否有底部悬浮的功能 if($("#foot").length>0 && $("#bottom").length>0){ $("body").css("padding-bottom","120px"); $("#foot").css("bottom",$("#bottom").height()); }else if($("#foot").length>0 || $("#bottom").length>0){ $("body").css("padding-bottom","60px"); } }); //选项卡 function tab(obj){ var index = $(obj).index(); $(obj).addClass("current").siblings().removeClass("current"); $(".tabContent>.tabItems").eq(index).show().siblings().hide(); } //弹窗 /* * tit:标题 * con:提示语 * btn1:取消按钮名字 * btn2:确认按钮名字 * name:执行函数名 * author:zhaobin * since:2017/12/26 */ function tips(tit,con,btn1,btn2,id,name){ var html = "
\
\
\
"+tit+"
\
"+con+"
\
\
\

"+btn1+"

\

"+btn2+"

\
\
\
" $("body").append(html); if ($(".nullBtn1").text() == "" || $(".nullBtn1").text() == "undefined") { $(".nullBtn1").remove(); } if ($(".nullBtn2").text() == "" || $(".nullBtn2").text() == "undefined") { $(".nullBtn2").remove(); } } // 弹窗按钮 function tipsHide(obj){ $(obj).parents(".tipbox").remove(); } //会员卡获取弹窗 /* usertx 用户头像 userid 用户名称 brandname 商家名称 link 用户领取路径 */ function giftCard(data){ data.logo = data.logo?data.logo:"/exusers/images/profilePic_default.png"; data.background = data.backgroundImage?data.backgroundColor+" url("+data.backgroundImage+") no-repeat":data.backgroundColor; var top = $('body').width()<767 ? 40 : 100 ; var html = "
\
\ \
\
Hi,"+data.userid+"
\
恭喜获得会员卡
\
\
\
\
"+data.brandname+"
\
\ VIP\

会员专享 专属优惠

\
\
\
\
享受折扣、积分抵扣等特权
\ 立即领取\
\ \ \
" $("body").append(html); } function giftClose(){ $(".giftCardWin").remove(); } function openCard(){ $.post(DIY_SCHEME+"//"+DIY_JS_SERVER+"/exusers/ajax/ajax_load_api.php",{'mod':'usercard','act':'openCard'}, function (res) { if(res != null) { if (res.code == 401) { window.location.href = './usercard/u8_login.php'; return; } else if (res.code == 200) { window.location.href = './usercard/usercardwx.php'; return; } else if (res.code == 201) { loadWxJsSdkInfo(function(){ var cardExt = '{"timestamp": ' + res.data.timestamp + ',"signature":"' + res.data.signature + '","nonce_str": "' + res.data.nonceStr + '"}' wx.ready(function () { wx.addCard({ cardList: [{ cardId: res.data.cardId, cardExt: cardExt }], success: function (res2) { var param = {}; param['cardId'] = res2['cardList'][0]['cardId']; param['code'] = res2['cardList'][0]['code']; param['vipcard_id'] = res.data.vipcard_id; $.post(DIY_SCHEME+"//"+DIY_JS_SERVER+"/exusers/ajax/ajax_load_api.php", { 'mod': 'usercard', 'act': 'addCardUser', 'data': param }, function (res3) { if(res3 != null) { if (res3.code == 200) { window.location.href = './usercard/usercardwx.php'; return; } else if (res3.code == 203) { openwxCard(res3.cardId, res3.userCardCode); } } }, "jsonp"); }, fail: function (res2) { console.log("aaa2:", res2); }, complete: function (res2) { console.log("aaa3:", res2); } }); }); }); } else if (res.code == 202) { loadWxJsSdkInfo(function(){ wx.ready(function () { openwxCard(res.data.cardId, res.data.userCardCode); }); }); } } },"jsonp"); } function openwxCard(cardId, userCardCode, callback){ wx.openCard({ cardList: [{ cardId: cardId, code: userCardCode }], success: function (res4) { if (typeof callback == 'function') { callback(res4); } }, fail: function (res4) { console.log("aaa44:", res4) if (typeof callback == 'function') { callback(res4); } } }); } function gotoUrl(obj){ var id = obj.data("id"); var rcid = obj.data("rcid"); $.post(DIY_SCHEME+"//"+DIY_JS_SERVER+"/exusers/ajax/ajax_load_api.php",{'mod':'coupon','act':'openwxCard','data': {'id':id,'rcid':rcid}}, function (res) { if (res.code == 401) { window.location.href = './usercard/u8_login.php'; return; } else if (res.code == 200) { window.location.href=DIY_SCHEME+"//"+DIY_JS_SERVER+"/exusers/coupons/coupons.php?id="+id+"&usercouponid="+rcid; } else if (res.code == 201) { loadWxJsSdkInfo(function() { wx.ready(function () { openwxCard(res.data.cardId, res.data.userCardCode); }); }); } },"jsonp"); } function getCoupons(){ // var that = this; // var formId = e.detail.formId; // var couponid = that.data.couponid; // var param = {}; // param['formId'] = formId; // param['id'] = couponid; // // param['type'] = 'getCoupons'; // console.log("param:", param); // app.nicebox.api.RequestAPI('coupon', 'submit', param, function (res) { // console.log("hi:", res); // if (res.code == 200) { // var lastid = res.lastid; // app.nicebox.fun.showModal({ // content: res.msg, // confirm: function () { // var gourl = "/pages/common/coupons/coupons?couponid=" + couponid + "&usercouponid=" + lastid; // app.nicebox.fun.turnToPage(gourl, true); // }, // confirmText: '确认' // }); // // } else if (res.code == 308) { // //需要支付去支付 // var order_id = res.order_id; // var gourl = "/pages/common/orders/pay?orderId="+order_id; // app.nicebox.fun.turnToPage(gourl); // return ; // } else if (res.code == 401) { // app.nicebox.fun.showModal({ // content: res.msg, // confirm: function () { // app.nicebox.user.checkLogin(); // }, // confirmText: '进入登录', // showCancel: true // }); // return; // } else { // app.nicebox.fun.showModal({ content: res.msg }); // } // // }); } function addwxCard(id, callback, title='优惠券领取',lang=0,formType=''){ $.post(DIY_SCHEME+"//"+DIY_JS_SERVER+"/exusers/ajax/ajax_load_api.php",{'mod':'coupon','act':'addwxCard','data': {'id':id}}, function (res) { if(res != null) { if (res.code == 401) { window.location.href = './usercard/u8_login.php'; return; }else if(res.code == 201){ loadWxJsSdkInfo(function(){ var cardExt = '{"timestamp": ' + res.data.timestamp + ',"signature":"' + res.data.signature + '","nonce_str": "' + res.data.nonceStr + '"}' wx.ready(function () { wx.addCard({ cardList: [{ cardId: res.data.cardId, cardExt: cardExt }], success: function (res2) { console.log("aaa1:", res2) var param = {}; param['cardId'] = res2['cardList'][0]['cardId']; param['code'] = res2['cardList'][0]['code']; param['id'] = res.data.id; $.post(DIY_SCHEME+"//"+DIY_JS_SERVER+"/exusers/ajax/ajax_load_api.php", { 'mod': 'coupon', 'act': 'wxsubmit', 'data': param }, function (res3) { if(res3 != null) { console.log("aaa3:", res3); if (typeof callback == 'function') { res2.result = res3; callback(res2); }else{ if (res3.code == 200) { openwxCard(res3.cardId, res3.userCardCode); } else { if(res.msg != '') alert(res.msg); return; } } } }, "jsonp"); }, fail: function (res2) { if (typeof callback == 'function') { callback(res2); } console.log("aaa2:", res2) } }); }); }); }else{ if(isMobile2()){ window.location.href=DIY_SCHEME+"//"+DIY_JS_SERVER+"/coupons/coupons_get.php?idweb="+DIY_WEBSITE_ID+"&id="+id+"&from="+formType; }else{ $("#boxName").html(title); $("#boxClose").html("×"); $("#showiframe").attr("src", DIY_SCHEME+"//"+DIY_JS_SERVER+"/coupons/coupons_get.php?idweb="+DIY_WEBSITE_ID+"&id="+id+"&lang="+lang+"&from="+formType); box.Show({width:'500px',height:'385px'}); } } } },"jsonp"); } function loadWxJsSdkInfo(callback){ if (typeof callback == 'function') { callback(); }else{ return true; } /* $.post(DIY_SCHEME+"//"+DIY_JS_SERVER+"/exusers/ajax/ajax_load_api.php",{'mod':'usercard','act':'wxjssdkinfo','data':{'cururl':DIY_CUR_URL}}, function (res) { if (res.code == 200) { console.log("res:",res); var json = { debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。 appId: res.data.appId, timestamp: res.data.timestamp, nonceStr: res.data.nonceStr, signature: res.data.signature, jsApiList: ["addCard","openCard"] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2 } wx.config(json); if (typeof callback == 'function') { callback(); } } },"jsonp"); */ }