-
-
Save zjnxyz/e2efcdbef64c674eb2b543c312ff7db7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.addEventListener("DOMContentLoaded", function() { | |
FastClick.attach(document.body); | |
parent.registerBridge && parent.registerBridge(); | |
var g = "//" + window.OFO_ENV.API_HOST + "/ofo/Api/"; | |
var Q = function() { | |
if (window.location.host == "common.ofo.so") { | |
return "//" + "product.api.ofo.com" + "/ofo/Api/" | |
} else { | |
return g | |
} | |
}(); | |
var D = window.getOfoToken(), | |
o = "", | |
l = ""; | |
if (localStorage) { | |
o = localStorage.getItem("ofo-phone") | |
} | |
if (o == "null" || o == "undefined") { | |
o = "" | |
} | |
$(".loading-box").show(); | |
var a = window.OFO_ENV.query(); | |
var v = a.type || 1, | |
L = a.subType || "", | |
q = a.duringType || 1, | |
e = a.fromcity || "", | |
P = a.channel || "", | |
G = a.channelPage || "", | |
af, | |
r = a.shareInfo, | |
W = a.fromShare && a.shareInfo ? true : false; | |
if (P == "954_1504685113297") { | |
$(".default").hide(); | |
$(".moment").show() | |
} else { | |
if (P == "26193_1506597726554") { | |
$(".default").hide(); | |
$(".zq").show() | |
} | |
} | |
var J, | |
V, | |
y, | |
m; | |
var ah, | |
ag, | |
n = false; | |
var p; | |
console.log(" ENVQUERY.fromShare", a.fromShare, W); | |
function S(aj, ai, ak) { | |
console.log("埋点val", ak + "_" + P + "_" + e); | |
if (aj == "view") { | |
window.saTrackCompat.view(ai, ak + "_" + P + "_" + e) | |
} else { | |
if (aj == "click") { | |
window.saTrackCompat.click(ai, ak + "_" + P + "_" + e) | |
} | |
} | |
} | |
S("view", "cardbrand_view_00298", "cbpageview"); | |
window.saTrackCompat.ofoTrack("activitycard", "month_card_view", v, P, e, "", L); | |
if (D && o) { | |
$(".user-info").show(); | |
$(".current-phone").html(o); | |
$(".btn-wrap").attr("class", "btn-wrap addUser") | |
} | |
var x = window.OFO_ENV.sourceForApi; | |
var C = x == 1 || x == 2 ? true : false; | |
if (x == -1 || C) { | |
$(".wechat").show(); | |
$("#wechat-pay").attr("checked", true); | |
$("#zfb-pay").attr("checked", false) | |
} | |
if (x != -1) { | |
$(".zfb").show() | |
} | |
var j, | |
T; | |
var B; | |
$.ajax({ | |
type: "post", | |
url: Q + "v1/card/detail", | |
data: { | |
type: v, | |
subtype: L, | |
duringType: q | |
}, | |
success: function(aj) { | |
if (aj.errorCode == 200) { | |
$(".loading-box").hide(); | |
$(".banner").show(); | |
t(); | |
var al = aj.values; | |
j = al.productToken; | |
T = al.money; | |
var ak = al.subImage, | |
am = al.subContent; | |
window.ofoResponseProxy("setTitle", [al.title]); | |
$(".money").html(T); | |
if (T <= 0) { | |
af = true; | |
$(".freeDes").hide(); | |
$(".buy-btn").html("免费领取"); | |
$(".money").html(1); | |
$(".phone").attr("placeholder", "请输入手机号免费领取"); | |
$(".login-buy").html("免费领取"); | |
$(".again-btn").html("重新领取"); | |
if (o) { | |
$(".user-info").show(); | |
$(".current-phone").html(o); | |
$(".btn-wrap").attr("class", "btn-wrap addUser") | |
} | |
} | |
var ai = window.location.search.substr(1); | |
J = al.title; | |
V = "1元ofo月卡限量抢购中,抢到即可尽情畅骑30天!"; | |
if (af) { | |
V = "1元月卡免费抢,轻松畅骑30天。" | |
} | |
y = "https://" + window.location.host + "/campaign/monthCard/ofo_logo.png"; | |
m = "https://" + window.location.host + "/newdist/?" + ai; | |
console.log("刚开始进来页面分享链接", ai, m); | |
if (P != "8993_1502790362490" && P != "33548_1502539718547" && P != "33840_1503646042206" && P != "33840_1503647397472" && P != "33840_1503647518498" && P != "33840_1504172165218" && P != "33840_1504172296731" && P != "33840_1504172229589") { | |
window.ofoResponseProxy("shareConfig", [J, V, y, m]) | |
} | |
if (G == "page1") { | |
$(".page1").show() | |
} else { | |
if (G == "page2") { | |
$(".page2").show() | |
} else { | |
$(".page0").show(); | |
$(".name").html(al.name); | |
$(".image").attr("src", al.image); | |
if (ak) { | |
$(".subImage").attr("src", ak).show(); | |
$(".wrap").addClass("type1") | |
} | |
if (am) { | |
$(".subTitle").html(am).show() | |
} | |
if (P == "954_1504685113297") { | |
$(".content").html("【免费领取限量月卡】ofo上线两周年纪念月卡") | |
} else { | |
if (P == "26193_1506597726554") { | |
$(".content").html("【免费领取限量月卡】ofo中秋定制版月卡") | |
} else { | |
$(".content").html(al.content) | |
} | |
} | |
$(".origMoney").html(al.origMoney) | |
} | |
} | |
ah = al.content; | |
if (W) { | |
$(".content").html("拼手气,抢月卡<br/>限量免费月卡等你拿!") | |
} else { | |
if (P == "954_1504685113297") { | |
$(".content").html("【免费领取限量月卡】ofo上线两周年纪念月卡") | |
} else { | |
if (P == "26193_1506597726554") { | |
$(".content").html("【免费领取限量月卡】ofo中秋定制版月卡") | |
} else { | |
$(".content").html(al.content) | |
} | |
} | |
} | |
$(".origMoney").html(al.origMoney) | |
} else { | |
$(".loading-box").hide(); | |
window.tip(aj.msg) | |
} | |
} | |
}); | |
function t(ai) { | |
$.ajax({ | |
type: "post", | |
url: g + "v4/info/wallet", | |
data: { | |
token: D, | |
source: x | |
}, | |
success: function(aj) { | |
if (aj.errorCode == 200) { | |
$(".balance").html(aj.values.info.realBalance); | |
if (aj.values.info.realBalance < T) { | |
$(".type.ba").addClass("hide"); | |
$(".type.ba .radio").attr("disabled", true) | |
} else { | |
$(".type.ba").removeClass("hide"); | |
$(".type.ba .radio").removeAttr("disabled") | |
} | |
$(".btn-wrap").show(); | |
ai && ai() | |
} else { | |
if (aj.errorCode == 10003) { | |
$(".btn-wrap").show(); | |
console.log(aj.msg) | |
} else { | |
console.log(aj.msg) | |
} | |
} | |
} | |
}) | |
} | |
$(".buy-btn").on("click", function() { | |
if (P == "33096_1504872734746" || P == "21323_1505126148852" || P == "21323_1505115288607" || P == "21323_1505115388795" || P == "21323_1505115472788") { | |
window.tip("很遗憾,免费月卡已领光。"); | |
return | |
} | |
console.log("ofotoken", D, "ofoPhone", o); | |
S("click", "cardbrand_click_00299", "cbbuycard"); | |
window.saTrackCompat.ofoTrack("activitycard", "month_card_click_in", v, P, e, "", L); | |
if (af) { | |
if (W) { | |
$(".loading-box").show(); | |
U() | |
} else { | |
if (o || D) { | |
ac() | |
} else { | |
$(".login-dialog").addClass("free"); | |
$(".login-box").addClass("show") | |
} | |
} | |
} else { | |
if (!D || !o) { | |
$(".login-box").addClass("show") | |
} else { | |
$(".pay-box").addClass("show") | |
} | |
} | |
}); | |
$(".rush-btn").on("click", function() { | |
if (!D || !o) { | |
$(".login-box").addClass("show"); | |
$(".phone").attr("placeholder", "请输入手机号立即抢卡"); | |
$(".login-buy").html("立即抢卡") | |
} else { | |
k() | |
} | |
}); | |
console.log(".ISRUSHCARD", W); | |
if (W) { | |
$(".buy-btn").hide(); | |
$(".rush-btn").show(); | |
$(".cardBot").addClass("hide") | |
} | |
var aa; | |
function k() { | |
console.log("开始调用抢卡接口"); | |
$(".loading-box").show(); | |
$(".tip-text").html("努力抢卡中..."); | |
S("click", "cardbrand_click_00299", "cbrob"); | |
$.ajax({ | |
type: "post", | |
url: Q + "v1/card/rushCard", | |
data: { | |
token: D, | |
source: x, | |
shareToken: r, | |
city: e | |
}, | |
success: function(ai) { | |
$(".loading-box").hide(); | |
$(".tip-text").html("加载中..."); | |
n = true; | |
if (ai.errorCode == 200) { | |
$(".rush-btn").hide(); | |
$(".buy-btn").show(); | |
$(".content").html(ah); | |
$(".cardBot").removeClass("hide"); | |
if (ai.values.money > 0) { | |
aa = "恭喜获得<span class='red'>1元购卡</span>资格,点击下面‘立即购买’尽享30天轻松畅骑"; | |
af = false | |
} else { | |
aa = "恭喜获得<span class='red'>免费领取</span>资格,点击下面‘免费领取’尽享30天轻松畅骑"; | |
af = true | |
} | |
z(); | |
$(".success-h1").html("抢卡成功"); | |
$(".success-text").html(aa); | |
$(".success-box").addClass("show") | |
} else { | |
$(".fail-h1").html("抢卡失败"); | |
$(".fail-text").html(ai.msg); | |
$(".fail-box").addClass("show"); | |
$(".fail-box .again-btn").hide(); | |
$(".fail-box .ok-btn").show() | |
} | |
}, | |
error: function() { | |
$(".loading-box").hide(); | |
window.tip("网络错误,请重试") | |
} | |
}) | |
} | |
function z() { | |
if (af) { | |
$(".buy-btn").html("免费领取"); | |
$(".phone").attr("placeholder", "请输入手机号免费领取"); | |
$(".login-buy").html("免费领取"); | |
$(".again-btn").html("重新领取") | |
} else { | |
$(".buy-btn").html("立即购买"); | |
$(".phone").attr("placeholder", "请输入手机号立即购买"); | |
$(".login-buy").html("立即购卡"); | |
$(".again-btn").html("重新购买") | |
} | |
} | |
z(); | |
var ad = '成功领取 <span class="red">1</span> 张月卡,可免费骑行 <span class="red">30</span> 天'; | |
function U() { | |
var ai = { | |
token: D, | |
source: x, | |
productToken: j, | |
city: e, | |
shareToken: r | |
}; | |
if (!r) { | |
delete ai.shareToken | |
} | |
$.ajax({ | |
type: "post", | |
url: Q + "v1/card/receiveFreeCard", | |
data: ai, | |
success: function(aj) { | |
$(".loading-box").hide(); | |
if (aj.errorCode == 200) { | |
$(".success-h1").html("领取成功"); | |
$(".success-text").html(ad); | |
$(".success-box").addClass("show"); | |
if (W) { | |
console.log("抢卡页面 免费领取之后需要调一下shareToken============"); | |
w() | |
} | |
u() | |
} else { | |
if (aj.errorCode == 10003) { | |
$(".btn-wrap").show(); | |
console.log(aj.msg) | |
} else { | |
$(".fail-h1").html("领取失败"); | |
$(".fail-text").html(aj.msg); | |
$(".fail-box").addClass("show"); | |
$(".fail-box .again-btn").hide(); | |
$(".fail-box .ok-btn").show() | |
} | |
} | |
}, | |
error: function() { | |
$(".loading-box").hide(); | |
window.tip("网络错误,请重试") | |
} | |
}) | |
} | |
function ac(aj) { | |
$(".loading-box").show(); | |
var al; | |
if (aj && aj != "null" && aj != "undefined") { | |
al = aj | |
} else { | |
if (o && o != "null" && o != "undefined") { | |
al = o | |
} | |
} | |
console.log("ofoPhone", o, al); | |
console.log("mad", ofoMd5); | |
var ai = { | |
token: D, | |
tel: al, | |
source: x, | |
productToken: j, | |
city: e | |
}; | |
if (!e) { | |
delete ai.city | |
} | |
if (!D) { | |
delete ai.token | |
} | |
if (!al) { | |
delete ai.tel | |
} | |
console.log("sendData", ai); | |
ai.sign = ak(ai, "v6MLztbWgQEKQengk4ptS0ghjqu0BSxO"); | |
ai.access_key = "3I19PAyI5Y"; | |
function ak(ap, aq) { | |
var am = ""; | |
function an() { | |
var ar = []; | |
for (var at in ai) { | |
ar.push(at) | |
} | |
return ar.sort() | |
} | |
console.log("transform", an(ai), Object.keys(ap).sort()); | |
for (var ao in an(ai)) { | |
am += ap[an(ai)[ao]].toString() | |
} | |
am += aq; | |
console.log("requestStr", am); | |
return ofoMd5.hex(am) | |
} | |
console.log("sendData", ai); | |
$.ajax({ | |
type: "post", | |
url: g + "activity/monthCard/receive", | |
data: ai, | |
success: function(am) { | |
$(".loading-box").hide(); | |
$(".login-box").removeClass("show"); | |
if (am.errorCode == 200) { | |
$(".success-h1").html("领取成功"); | |
$(".success-text").html(ad); | |
$(".success-box").addClass("show"); | |
localStorage.setItem("ofo-phone", al); | |
o = al; | |
$(".user-info").show(); | |
$(".current-phone").html(al); | |
$(".btn-wrap").attr("class", "btn-wrap addUser"); | |
u() | |
} else { | |
$(".fail-h1").html("领取失败"); | |
$(".fail-text").html(am.msg); | |
$(".fail-box").addClass("show"); | |
$(".fail-box .again-btn").hide(); | |
$(".fail-box .ok-btn").show() | |
} | |
}, | |
error: function() { | |
$(".loading-box").hide(); | |
window.tip("网络错误,请重试") | |
} | |
}) | |
} | |
$(".again-btn").on("click", function() { | |
S("click", "cardbrand_click_00299", "cbagain"); | |
if (!D || !o) { | |
$(".login-box").addClass("show") | |
} else { | |
$(".fail-box").removeClass("show"); | |
$(".pay-box").addClass("show") | |
} | |
}); | |
$(".close-btn").each(function(ai, aj) { | |
$(aj).on("click", function() { | |
var ak = $(aj).parents(".box"); | |
if (ak.attr("class").indexOf("login") >= 0) { | |
S("click", "cardbrand_click_00299", "cblogincancel") | |
} else { | |
if (ak.attr("class").indexOf("pay") >= 0) { | |
S("click", "cardbrand_click_00299", "cbpaycancel") | |
} | |
} | |
if (n) { | |
S("click", "cardbrand_click_00299", "cbrobcancel"); | |
n = false | |
} | |
ak.removeClass("show") | |
}) | |
}); | |
$(".ok-btn").on("click", function() { | |
$(this).parents(".box").removeClass("show"); | |
if (n) { | |
S("click", "cardbrand_click_00299", "cbrobknow"); | |
n = false | |
} else { | |
S("click", "cardbrand_click_00299", "cbknow") | |
} | |
}); | |
var X = '成功购买 <span class="red">1</span> 张月卡,可免费骑行 <span class=" red">30</span> 天'; | |
$(".pay-btn").on("click", function() { | |
if (!D) { | |
window.tip("无法获取充值用户!"); | |
return | |
} | |
S("click", "cardbrand_click_00299", "cbpay"); | |
if (P == "33548_1502781370160") { | |
_taq.push({ | |
convert_id: "66476111934", | |
event_type: "shopping" | |
}); | |
_taq.push({ | |
convert_id: "66476296608", | |
event_type: "shopping" | |
}); | |
_taq.push({ | |
convert_id: "66476335428", | |
event_type: "shopping" | |
}); | |
_taq.push({ | |
convert_id: "66476506531", | |
event_type: "shopping" | |
}); | |
_taq.push({ | |
convert_id: "66476531017", | |
event_type: "shopping" | |
}); | |
_taq.push({ | |
convert_id: "66476578090", | |
event_type: "shopping" | |
}); | |
_taq.push({ | |
convert_id: "67675251607", | |
event_type: "other" | |
}); | |
_taq.push({ | |
convert_id: "67675250304", | |
event_type: "other" | |
}); | |
_taq.push({ | |
convert_id: "67675370828", | |
event_type: "other" | |
}); | |
_taq.push({ | |
convert_id: "67675379620", | |
event_type: "other" | |
}); | |
_taq.push({ | |
convert_id: "67675414441", | |
event_type: "other" | |
}); | |
_taq.push({ | |
convert_id: "67675495600", | |
event_type: "other" | |
}) | |
} else { | |
if (P == "33548_1502780801967") { | |
_taq.push({ | |
convert_id: "66535609282", | |
event_type: "form" | |
}); | |
_taq.push({ | |
convert_id: "66533473653", | |
event_type: "form" | |
}); | |
_taq.push({ | |
convert_id: "66535286293", | |
event_type: "form" | |
}); | |
_taq.push({ | |
convert_id: "66536035493", | |
event_type: "form" | |
}); | |
_taq.push({ | |
convert_id: "66535866043", | |
event_type: "form" | |
}) | |
} else { | |
if (P == "33548_1502780381297") { | |
_taq.push({ | |
convert_id: "66607781732", | |
event_type: "shopping" | |
}); | |
_taq.push({ | |
convert_id: "66608520572", | |
event_type: "shopping" | |
}); | |
_taq.push({ | |
convert_id: "66608109624", | |
event_type: "shopping" | |
}); | |
_taq.push({ | |
convert_id: "66608134356", | |
event_type: "shopping" | |
}) | |
} else { | |
if (P == "33982_1504171535065" || P == "33982_1504171655613") { | |
_taq.push({ | |
convert_id: "67843561881", | |
event_type: "shopping" | |
}); | |
_taq.push({ | |
convert_id: "67843594785", | |
event_type: "shopping" | |
}); | |
_taq.push({ | |
convert_id: "67844101407", | |
event_type: "shopping" | |
}); | |
_taq.push({ | |
convert_id: "67844617122", | |
event_type: "shopping" | |
}) | |
} else { | |
if (P == "33982_1504171709636" || P == "33982_1504171760189") { | |
_taq.push({ | |
convert_id: "67880424388", | |
event_type: "form" | |
}); | |
_taq.push({ | |
convert_id: "67879213176", | |
event_type: "form" | |
}); | |
_taq.push({ | |
convert_id: "67880616253", | |
event_type: "form" | |
}); | |
_taq.push({ | |
convert_id: "67880531156", | |
event_type: "form" | |
}); | |
_taq.push({ | |
convert_id: "67880248957", | |
event_type: "form" | |
}); | |
_taq.push({ | |
convert_id: "67880616759", | |
event_type: "form" | |
}) | |
} else { | |
if (P == "33982_1504171809072" || P == "33982_1504171914813") { | |
_taq.push({ | |
convert_id: "66476111934", | |
event_type: "shopping" | |
}); | |
_taq.push({ | |
convert_id: "66476296608", | |
event_type: "shopping" | |
}); | |
_taq.push({ | |
convert_id: "66476335428", | |
event_type: "shopping" | |
}); | |
_taq.push({ | |
convert_id: "66476506531", | |
event_type: "shopping" | |
}); | |
_taq.push({ | |
convert_id: "66476531017", | |
event_type: "shopping" | |
}); | |
_taq.push({ | |
convert_id: "66476578090", | |
event_type: "shopping" | |
}); | |
_taq.push({ | |
convert_id: "67675251607", | |
event_type: "other" | |
}); | |
_taq.push({ | |
convert_id: "67675250304", | |
event_type: "other" | |
}); | |
_taq.push({ | |
convert_id: "67675370828", | |
event_type: "other" | |
}); | |
_taq.push({ | |
convert_id: "67675379620", | |
event_type: "other" | |
}); | |
_taq.push({ | |
convert_id: "67675414441", | |
event_type: "other" | |
}); | |
_taq.push({ | |
convert_id: "67675495600", | |
event_type: "other" | |
}) | |
} | |
} | |
} | |
} | |
} | |
} | |
if (P == "33548_1503295296025" || P == "33548_1503295701679") { | |
gdt("track", "COMPLETE_ORDER", { | |
"channel": P, | |
"price": "1" | |
}) | |
} | |
var ai = $(".radio:checked").val(); | |
if (ai == "balancePay") { | |
S("click", "cardbrand_click_00299", "cbpay_yue"); | |
s() | |
} else { | |
if (ai == "aliPay") { | |
S("click", "cardbrand_click_00299", "cbpay_alipay"); | |
h("aliPay") | |
} else { | |
if (ai == "wechatPay") { | |
S("click", "cardbrand_click_00299", "cbpay_wechat"); | |
h("wxPay") | |
} | |
} | |
} | |
}); | |
function u() { | |
$(".buy-btn").hide(); | |
$(".btn-wrap").attr("class", "btn-wrap hideShare") | |
} | |
function R() { | |
if (P == "34055_1503027804089") { | |
$(".success-box .ok-btn").html("马上抽奖"); | |
$(".success-box .ok-btn").click(function() { | |
window.top.location.assign("http://x.jumei.com/turntable/OfoLinkage/get?from=ofo") | |
}) | |
} | |
if (P == "34055_1503027572279") { | |
$(".success-box .ok-btn").html("随便逛逛"); | |
$(".success-box .ok-btn").click(function() { | |
window.top.location.assign("http://h5.jumei.com") | |
}) | |
} | |
if (P == "34055_1505444588510" || P == "34055_1505444545907" || P == "34055_1505444668774") { | |
$(".success-box .ok-btn").html("点击变美"); | |
$(".success-box .ok-btn").click(function() { | |
window.top.location.assign("http://www.lilynails.com.cn/lilynailsandofo?from=singlemessage&isappinstalled=0") | |
}) | |
} | |
} | |
R(); | |
var A = (x <= 0) && (!window.OFO_ENV.isInWeChat); | |
var ae = "//" + (window.OFO_ENV.API_HOST) + "/ofo/Api/wechat/app/deposit"; | |
var f = "//" + (window.OFO_ENV.API_HOST) + "/ofo/Api/alipayDeposit"; | |
var i = "//" + (window.OFO_ENV.API_HOST) + "/ofo/Api/alipayWebDeposit"; | |
var b = function(ak, ai, aj) { | |
ak.onload = function() { | |
$(".loading-box").hide(); | |
var al; | |
try { | |
al = JSON.parse(ak.responseText) | |
} catch (am) { | |
aj("无法解析服务器响应:" + ak.responseText); | |
return | |
} | |
if (al) { | |
if (al.errorCode === 200) { | |
console.log("json", al); | |
ai(al) | |
} else { | |
if (al.errorCode === 40051) { | |
window.parent.location.assign("https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc663035786d80a97&redirect_uri=" + encodeURIComponent(window.location.protocol + "//" + (window.OFO_ENV.API_HOST) + "/ofo/wechat/auth?token=" + encodeURIComponent(D) + "&callback=" + encodeURIComponent(window.parent.location.href)) + "&response_type=code&scope=snsapi_userinfo&state=" + D + "#wechat_redirect") | |
} else { | |
aj(al.msg) | |
} | |
} | |
} else { | |
aj("服务器未返回有效数据") | |
} | |
}; | |
ak.onerror = function() { | |
$(".loading-box").hide(); | |
if (ak.status) { | |
aj("HTTP " + ak.status) | |
} else { | |
aj("连接失败") | |
} | |
} | |
}; | |
var h = function(ak, aj) { | |
$(".loading-box").show(); | |
window.Cookies.set("alipay-href", window.top.location.href, { | |
domain: "ofo.so", | |
path: "/" | |
}); | |
var al = new XMLHttpRequest(); | |
al.open("POST", A ? i : (ak == "aliPay" ? f : ae)); | |
al.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); | |
var ai = A ? Math.round(Date.now() / 100).toString(36) + Math.random().toString(36).substr(2, 4) : null; | |
b(al, function(am) { | |
if (A) { | |
window.ofoResponseProxy("alipayWeb", [am.values.info, T, ai]) | |
} else { | |
if (ak == "aliPay") { | |
window.ofoResponseProxy("alipay", [am.values.info, T]) | |
} else { | |
if (ak == "wxPay") { | |
window.ofoResponseProxy("wxpay", [JSON.stringify(am.values.info), T]) | |
} | |
} | |
} | |
}, function(am) { | |
$(".fail-box .again-btn").hide(); | |
$(".fail-box .ok-btn").show(); | |
$(".pay-box").removeClass("show"); | |
$(".success-box").removeClass("show"); | |
$(".fail-h1").html("购买失败"); | |
$(".fail-text").html(am); | |
$(".fail-box").addClass("show") | |
}); | |
al.send("source=" + x + "&payment=101&productToken=" + j + "&token=" + encodeURIComponent(D) + "&city=" + e + (A ? "&return_url=" + encodeURIComponent(window.location.protocol + "//" + window.location.host + "/about/alipay_return/?iden=" + encodeURIComponent(ai)) : "")) | |
}; | |
window.wechatPaySucc = function() { | |
if (P == "33548_1503295296025" || P == "33548_1503295701679") { | |
gdt("track", "COMPLETE_ORDER", { | |
"channel": P, | |
"price": "2" | |
}) | |
} | |
if (P == "33548_1502780381297" || P == "33982_1504171535065" || P == "33982_1504171655613") { | |
_taq.push({ | |
convert_id: "69677738649", | |
event_type: "form" | |
}); | |
_taq.push({ | |
convert_id: "69678315895", | |
event_type: "form" | |
}); | |
_taq.push({ | |
convert_id: "69678311048", | |
event_type: "form" | |
}); | |
_taq.push({ | |
convert_id: "69677738648", | |
event_type: "form" | |
}) | |
} else { | |
if (P == "33982_1504171709636" || P == "33982_1504171760189" || P == "33548_1502780801967") { | |
_taq.push({ | |
convert_id: "69678075821", | |
event_type: "form" | |
}); | |
_taq.push({ | |
convert_id: "69677604484", | |
event_type: "form" | |
}); | |
_taq.push({ | |
convert_id: "69678699931", | |
event_type: "form" | |
}); | |
_taq.push({ | |
convert_id: "69678196183", | |
event_type: "form" | |
}); | |
_taq.push({ | |
convert_id: "69677906616", | |
event_type: "form" | |
}); | |
_taq.push({ | |
convert_id: "69678785725", | |
event_type: "form" | |
}) | |
} | |
} | |
$(".loading-box").hide(); | |
$(".pay-box").removeClass("show"); | |
$(".fail-box").removeClass("show"); | |
$(".success-h1").html("购买成功"); | |
$(".success-text").html(X); | |
$(".success-box").addClass("show"); | |
w(true); | |
u() | |
}; | |
if (!window.ofoRequest) { | |
window.ofoRequest = {} | |
} | |
window.ofoRequest.paySucc = window.wechatPaySucc; | |
function s() { | |
$.ajax({ | |
type: "post", | |
url: g + "v3/payment", | |
data: { | |
token: D, | |
dPayTag: 10, | |
payment: 101, | |
source: x, | |
productToken: j, | |
city: e | |
}, | |
success: function(ai) { | |
if (ai.errorCode == 200) { | |
$(".pay-box").removeClass("show"); | |
$(".success-h1").html("购买成功"); | |
$(".success-text").html(X); | |
$(".success-box").addClass("show"); | |
$(".fail-box").removeClass("show"); | |
w(true); | |
t(); | |
u() | |
} else { | |
if (ai.errorCode == 220000 || ai.errorCode == 220001) { | |
$(".fail-box .again-btn").hide(); | |
$(".fail-box .ok-btn").show() | |
} | |
$(".pay-box").removeClass("show"); | |
$(".success-box").removeClass("show"); | |
$(".fail-h1").html("购买失败"); | |
$(".fail-text").html(ai.msg); | |
$(".fail-box").addClass("show") | |
} | |
}, | |
error: function() { | |
$(".pay-box").removeClass("show"); | |
$(".success-box").removeClass("show"); | |
$(".fail-h1").html("购买失败"); | |
$(".fail-text").html(""); | |
$(".fail-box").addClass("show") | |
} | |
}) | |
} | |
$(".share-btn").on("click", K); | |
function K() { | |
S("click", "cardbrand_click_00299", "cbshare"); | |
if (C) { | |
O(); | |
window.ofoResponseProxy("share", [J, V, y, ag]) | |
} else { | |
if (window.OFO_ENV.isInWeChat) { | |
$("#modal").show() | |
} | |
} | |
} | |
function w(ai) { | |
console.log("获取shareToken"); | |
$.ajax({ | |
type: "post", | |
url: Q + "v1/card/shareCard", | |
data: { | |
token: D, | |
source: x, | |
productToken: j, | |
city: e | |
}, | |
success: function(aj) { | |
if (aj.errorCode == 200) { | |
if (aj.values.shareToken) { | |
r = aj.values.shareToken; | |
if (m.indexOf("fromShare") <= -1) { | |
ag = m + "&fromShare=1&shareInfo=" + r | |
} else { | |
ag = m.substr(0, m.indexOf("shareInfo")) + "shareInfo=" + r | |
} | |
console.log("调用之后分享的链接", ag); | |
if (P != "8993_1502790362490" && P != "33548_1502539718547" && P != "33840_1503646042206" && P != "33840_1503647397472" && P != "33840_1503647518498" && P != "33840_1504172165218" && P != "33840_1504172296731" && P != "33840_1504172229589") { | |
console.log("在这里调用了shareSuccess"); | |
window.ofoResponseProxy("shareConfig", [J, V, y, ag]); | |
if (ai) { | |
window.ofoResponseProxy("newShareConfig", [{ | |
title: J, | |
desc: V, | |
imgUrl: y, | |
link: ag, | |
success: function() { | |
$.ajax({ | |
type: "post", | |
url: Q + "v1/card/shareSuccess", | |
data: { | |
token: D, | |
source: x, | |
city: e, | |
shareToken: r | |
}, | |
success: function(ak) {} | |
}) | |
} | |
}]) | |
} | |
} | |
} | |
} | |
} | |
}) | |
} | |
function O() { | |
$.ajax({ | |
type: "post", | |
url: Q + "v1/card/shareSuccess", | |
data: { | |
token: D, | |
source: x, | |
city: e, | |
shareToken: r | |
}, | |
success: function(ai) {} | |
}) | |
} | |
$("#modal").on("click", function() { | |
$("#modal").hide() | |
}); | |
var N = /^1[34578][0-9]{9}$/; | |
var ab, | |
Y = 59, | |
I; | |
$getCode = $(".get-code"); | |
var d = true; | |
$(".phone").on("input", function() { | |
ab = $(this).val(); | |
if (d) { | |
S("click", "cardbrand_click_00299", "cbphone"); | |
d = false | |
} | |
if (ab.length == 11) { | |
if (!N.test(ab)) { | |
window.tip("手机号码格式错误!"); | |
return | |
} else { | |
ab = $(this).val(); | |
if (af) { | |
$(".login-buy").removeAttr("disabled") | |
} else { | |
$getCode.removeAttr("disabled") | |
} | |
console.log("手机号格式正确 获取短信验证码" + ab) | |
} | |
} else { | |
$getCode.attr("disabled", true) | |
} | |
}); | |
$getCode.on("click", function() { | |
H() | |
}); | |
function H() { | |
S("click", "cardbrand_click_00299", "cbgetcode"); | |
window.saTrackCompat.ofoTrack("activitycard", "click_sms_send", v, P, e, "", L); | |
$.ajax({ | |
type: "post", | |
url: g + "activity/monthCard/verifyCode", | |
data: { | |
tel: ab | |
}, | |
success: function(ai) { | |
if (ai.errorCode == 200) { | |
I = setInterval(function() { | |
if (Y == 1) { | |
clearInterval(I); | |
Y = 59; | |
$getCode.html("发送验证码").removeAttr("disabled") | |
} else { | |
Y--; | |
$getCode.html("还剩" + Y + "秒") | |
} | |
}, 1000); | |
$getCode.html("还剩" + Y + "秒"); | |
$getCode.attr("disabled", true) | |
} else { | |
window.tip(ai.msg) | |
} | |
} | |
}) | |
} | |
var Z, | |
F = $(".login-buy"); | |
var M = true; | |
$(".code").on("input", function() { | |
if (M) { | |
S("click", "cardbrand_click_00299", "cbcode"); | |
M = false | |
} | |
Z = $(this).val(); | |
if (Z.length == 4) { | |
F.removeAttr("disabled") | |
} else { | |
F.attr("disabled", true) | |
} | |
}); | |
F.on("click", function() { | |
if (!N.test(ab)) { | |
window.tip("手机号码格式错误!"); | |
return | |
} | |
console.log("点击免费领取似的手机号", ab); | |
if (af) { | |
ac(ab); | |
return | |
} | |
S("click", "cardbrand_click_00299", "cbcardin"); | |
if ($.trim(Z).length !== 4) { | |
window.tip("短信验证码错误!"); | |
return | |
} | |
$.ajax({ | |
type: "post", | |
url: g + "login", | |
data: { | |
source: window.OFO_ENV.sourceForApi, | |
tel: ab, | |
code: Z, | |
idfa: "" | |
}, | |
success: function(ai) { | |
if (ai.errorCode == 200) { | |
try { | |
localStorage.setItem("ofo-tokened", ai.values.token); | |
localStorage.setItem("ofo-phone", ab); | |
D = window.getOfoToken(); | |
o = ab | |
} catch (aj) { | |
D = ai.values.token; | |
o = ab | |
} | |
$(".login-box").removeClass("show"); | |
$(".user-info").show(); | |
$(".current-phone").html(ab); | |
$(".btn-wrap").attr("class", "btn-wrap addUser"); | |
console.log("登陆完成之后获取到的", D, o); | |
if (W) { | |
t(); | |
k() | |
} else { | |
if (af) { | |
U() | |
} else { | |
t(function() { | |
$(".pay-box").addClass("show") | |
}) | |
} | |
} | |
c(); | |
E() | |
} else { | |
window.tip(ai.msg) | |
} | |
} | |
}) | |
}); | |
function c() { | |
$.ajax({ | |
type: "post", | |
url: g + "v4/info/user", | |
data: { | |
token: D, | |
source: x | |
}, | |
success: function(ai) { | |
if (ai.errorCode == 200) { | |
l = ai.values.info.cid; | |
window.saTrackCompat.addCid(l); | |
window.saTrackCompat.ofoTrack("activitycard", "month_card_click_login", v, P, e, l, L) | |
} | |
} | |
}) | |
} | |
function E() { | |
$(".phone").val("").attr("autofocus", true); | |
$(".code").val(""); | |
d = true; | |
M = true; | |
Z = ""; | |
clearInterval(I); | |
Y = 59; | |
$getCode.html("发送验证码").attr("disabled", true); | |
F.attr("disabled", true) | |
} | |
$(".change").on("click", function() { | |
if (af && !W) { | |
$(".login-dialog").addClass("free"); | |
$(".login-box").addClass("show"); | |
return | |
} | |
$(".login-box").addClass("show") | |
}) | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment