12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453 |
- import * as compnt from "./compnt.js";
- import * as env from "./env.js"
- export var aes = getPass()
- export var query = {};
- export var product = {};
- export var products = {}; // 聚合页面有多个产品要订购
- export var fesname = {};
- export var user = {};
- export var root = null;
- export var productID = {};
- export var name_a = null;
- export var passwordsr = '';
- export function init() {
- window.root = getRootPath();
- parseQueryParms();
- $("#useraccount_tt").attr("value", getUrlParam("freeflow_token"));
- var param = {
- "fes": query.fes,
- "sou": query.sou,
- "orderId": query.orderId
- }
- var def = $.Deferred();
- $.ajax({
- url: root + "/ini/getstyle",
- type: "POST",
- contentType: "application/json",
- data: JSON.stringify(param),
- timeout: 10000
- }).then(function (responseText) {
- var response = JSON.parse(responseText);
- if (response.resultCode != "0000") {
- window.location.href = window.root + "/404.html";
- def.reject();
- return def;
- }
- product = response.product[0];
- for (i = 0; i < response.product.length; i++) {
- products[response.product[i].productid] = response.product[i]
- }
- $("#fog_" + product.url).attr("value", product.fog);
- var smslist = product.icon.split(",");
- for (var i = 0; i < smslist.length; i++) {
- if (i == 0) {
- $("#sendsms_order_" + product.url).attr("value", smslist[i]);
- }
- if (i == 1) {
- $("#sendsms_cancel_" + product.url).attr("value", smslist[i]);
- }
- if (i == 2) {
- $("#sendsms_yuyue_" + product.url).attr("value", smslist[i]);
- }
- }
- def.resolve(response);
- }, function (jqXHR, textStatus, errorThrown) {
- if (textStatus === "timeout") {
- window.location.href = getRootPath() + "/hot.html?cb=" + encodeURIComponent(window.location.href);
- }
- })
- return def;
- }
- /**
- * 抖音产品订购
- */
- export function orderDouyin(token, usermob) {
- var param = {
- "fog": getMemoValbyId(product, "fog"),
- "usermob": usermob,
- "useraccount": getMemoValbyId(product, "useraccount"),
- "fes": getUrlParam("fes"),
- "sou": getUrlParam("sou"),
- "token": token
- }
- return $.ajax({
- url: root + '/com/buyc',
- type: "POST",
- contentType: "application/json",
- data: JSON.stringify(param)
- });
- }
- export function setProduct(_product) {
- product = _product;
- }
- export function setFesname(_fesname) {
- fesname = _fesname;
- }
- /**
- * 订购
- */
- export function order(userid, token, usermob, ringid) {
- var param = {
- "fes": query.fes,
- "sou": query.sou,
- "fog": product.fog,
- "token": token,
- "userid": userid || user.userid,
- "usermob": usermob || user.usermob,
- "useraccount": "",
- "f": query.F,
- "ringid": ringid || query.ringid
- }
- return $.ajax({
- url: root + '/comm/order',
- type: "POST",
- contentType: "application/json",
- data: JSON.stringify(param)
- });
- }
- /**
- * 手厅免登陆订购
- */
- export function usermob(userid, usermob, ringid) {
- var param = {
- "fes": query.fes,
- "sou": query.sou,
- "fog": product.fog,
- "userid": userid || user.userid,
- "usermob": usermob || user.usermob,
- "useraccount": "",
- "f": query.F,
- "ringid": ringid || query.ringid
- }
- return $.ajax({
- url: root + '/unicom/order',
- type: "POST",
- contentType: "application/json",
- data: JSON.stringify(param)
- })
- }
- /**
- * 阿里订购
- */
- export function alorder(userid, token, usermob, ringid, alichannel) {
- var param = {
- "fes": query.fes,
- "sou": query.sou,
- "fog": product.fog,
- "token": token,
- "userid": userid || user.userid,
- "usermob": usermob || user.usermob,
- "useraccount": "",
- "f": query.F,
- "ringid": ringid || query.ringid,
- "alichannel": alichannel
- }
- return $.ajax({
- url: root + '/comm/order',
- type: "POST",
- contentType: "application/json",
- data: JSON.stringify(param)
- });
- }
- /**
- * 阿里退订
- */
- export function alcancel(userid, usermob, canceltype, cancelmsg, alichannel) {
- passwordsr = getMess(user.usermob, aes);
- var param = {
- "fes": query.fes,
- "sou": query.sou,
- "fog": product.fog,
- "userid": userid || user.userid,
- "usermob": usermob || passwordsr,
- "canceltype": encodeURIComponent(canceltype),
- "cancelmsg": encodeURIComponent(cancelmsg),
- "useraccount": "",
- }
- if (alichannel != null && alichannel != "") {
- param.alichannel = alichannel;
- }
- return $.ajax({
- url: root + '/comm/cancel',
- type: "POST",
- contentType: "application/json",
- data: JSON.stringify(param)
- });
- }
- /**
- * 退订
- */
- export function cancel(userid, usermob, canceltype, cancelmsg) {
- passwordsr = getMess(user.usermob, aes);
- var param = {
- "fes": query.fes,
- "sou": query.sou,
- "fog": product.fog,
- "userid": userid || user.userid,
- "usermob": usermob || passwordsr,
- "canceltype": encodeURIComponent(canceltype),
- "cancelmsg": encodeURIComponent(cancelmsg),
- "useraccount": ""
- }
- return $.ajax({
- url: root + '/comm/cancel',
- type: "POST",
- contentType: "application/json",
- data: JSON.stringify(param)
- });
- }
- /**
- * 多选一产品订购
- */
- export function choiceOrder(userid, token, usermob) {
- var param = {
- "fes": query.fes,
- "sou": query.sou,
- "fog": product.fog,
- "token": token,
- "userid": userid || user.userid,
- "usermob": usermob || user.usermob,
- "useraccount": ""
- }
- return $.ajax({
- url: root + '/choiceorder/order',
- type: "POST",
- contentType: "application/json",
- data: JSON.stringify(param)
- });
- }
- /**
- * 多选一产品退订
- */
- export function choiceCancel(userid, usermob, canceltype, cancelmsg) {
- passwordsr = getMess(user.usermob, aes);
- var param = {
- "fes": query.fes,
- "sou": query.sou,
- "fog": product.fog,
- "userid": userid || user.userid,
- "usermob": usermob || passwordsr,
- "canceltype": encodeURIComponent(canceltype),
- "cancelmsg": encodeURIComponent(cancelmsg),
- "useraccount": ""
- }
- return $.ajax({
- url: root + '/choiceorder/cancel',
- type: "POST",
- contentType: "application/json",
- data: JSON.stringify(param)
- });
- }
- /**
- * 查询流量消耗
- */
- export function queryFlow(userid, usermob) {
- var param = {
- "fes": query.fes,
- "sou": query.sou,
- "fog": product.fog,
- "userid": userid || user.userid,
- "usermob": usermob || user.usermob,
- }
- return $.ajax({
- url: root + '/flow/query',
- type: "POST",
- contentType: "application/json",
- data: JSON.stringify(param)
- });
- }
- /**
- * 查询订购关系
- */
- export function queryOrder(userid, usermob) {
- var param = {
- "fes": query.fes,
- "sou": query.sou,
- "fog": product.fog,
- "userid": userid || user.userid,
- "usermob": usermob || user.usermob
- }
- return $.ajax({
- url: root + '/comm/queryorder',
- type: "POST",
- contentType: "application/json",
- data: JSON.stringify(param)
- });
- }
- /**
- * 手厅百度查询订购关系
- */
- export function queryOrders(userid, usermob) {
- var param = {
- "fes": query.fes,
- "sou": query.sou,
- "fog": product.fog,
- "userid": userid || user.userid,
- "usermob": usermob || user.usermob
- }
- return $.ajax({
- url: root + '/unicom/queryorder',
- type: "POST",
- contentType: "application/json",
- data: JSON.stringify(param)
- });
- }
- //手厅免登陆
- export function register(ticket) {
- var param = {
- "fes": query.fes,
- "sou": query.sou,
- "fog": product.fog,
- 'ticket': ticket
- }
- var def = $.Deferred();
- $.ajax({
- url: root + "/unicom/check",
- type: "POST",
- contentType: "application/json",
- data: JSON.stringify(param)
- }).then(function (response) {
- def.resolve(response);
- // switch (response.resultCode) {
- // case "0000":
- // def.resolve(response);
- // break;
- // case "1066":
- // def.resolve(response);
- // break;
- // default:
- // def.reject(response);
- // break;
- // }
- }).fail(function (error) {
- def.reject('服务调用异常')
- })
- return def;
- };
- export function queryStock(stockcode) {
- var param = {
- "fes": query.fes,
- "sou": query.sou,
- "fog": product.fog,
- "stockcode": stockcode
- }
- return $.ajax({
- url: root + '/backward/queryStock',
- type: "POST",
- contentType: "application/json",
- data: JSON.stringify(param)
- });
- }
- /**
- * 后向产品订购
- */
- export function orderBack(stockcode, cpid) {
- var param = {
- "fes": query.fes,
- "sou": query.sou,
- "fog": product.fog,
- "userid": user.userid,
- "productType": query.productType,
- "payMethod": query.payMethod,
- "ringid": query.ringid,
- "returnUrl": window.location.href + "&productType=" + query.productType + "&payMethod=" + query.payMethod
- }
- if (!!stockcode && stockcode != '') {
- param.stockcode = stockcode;
- }
- return $.ajax({
- url: root + '/backward/order',
- type: "POST",
- contentType: "application/json",
- data: JSON.stringify(param)
- });
- }
- /**
- * 后向退订
- */
- export function cancelBack(stockcode, cpid, canceltype, cancelmsg) {
- var param = {
- "fes": query.fes,
- "sou": query.sou,
- "fog": product.fog,
- "userid": user.userid,
- "canceltype": encodeURIComponent(canceltype),
- "cancelmsg": encodeURIComponent(cancelmsg),
- }
- return $.ajax({
- url: root + '/backward/cancel',
- type: "POST",
- contentType: "application/json",
- data: JSON.stringify(param)
- });
- }
- /**
- * 南研支付结果查询
- */
- export function queryPay(orderId) {
- var param = {
- "fes": query.fes,
- "sou": query.sou,
- "fog": product.fog,
- "userid": user.userid,
- "orderId": orderId
- }
- return $.ajax({
- url: root + '/backward/queryPay',
- type: "POST",
- contentType: "application/json",
- data: JSON.stringify(param)
- });
- }
- export function setting(ringid, userid) {
- var param = {
- "fes": query.fes,
- "sou": query.sou,
- "fog": product.fog,
- "userid": userid || user.userid,
- "ringid": ringid
- }
- return $.ajax({
- url: root + '/rbtmv/setting',
- type: "POST",
- contentType: "application/json",
- data: JSON.stringify(param)
- });
- }
- /**
- * 南研支付订购
- */
- export function nanyanPayOrder(signing) {
- var param = {
- "fes": query.fes,
- "sou": query.sou,
- "fog": product.fog,
- "userid": user.userid,
- "signing": signing
- }
- return $.ajax({
- url: root + '/backward/nanyansign',
- type: "POST",
- contentType: "application/json",
- data: JSON.stringify(param)
- });
- }
- /**
- * 南研支付解除签约
- */
- export function nanyanUnsign() {
- var param = {
- "fes": query.fes,
- "sou": query.sou,
- "fog": product.fog,
- "userid": user.userid
- }
- return $.ajax({
- url: root + '/backward/nanyanunsign',
- type: "POST",
- contentType: "application/json",
- data: JSON.stringify(param)
- });
- }
- /**
- * 后向产品退款
- */
- export function refund(stockcode, username, password) {
- var param = {
- "fes": query.fes,
- "sou": query.sou,
- "fog": product.fog,
- "stockcode": stockcode,
- "captchaCode": product.captchaCode,
- "username": username,
- "password": password
- }
- return $.ajax({
- url: root + '/backward/refund',
- type: "POST",
- contentType: "application/json",
- data: JSON.stringify(param)
- });
- }
- /**
- * 检查用户是否可以订购
- */
- export function can(uid) {
- if (!uid) {
- var def = $.Deferred();
- def.reject();
- return def;
- }
- var param = {
- "fes": query.fes,
- "sou": query.sou,
- "fog": product.fog,
- "uid": uid || ""
- }
- return $.ajax({
- url: root + '/member/can',
- type: "POST",
- contentType: "application/json",
- data: JSON.stringify(param)
- });
- }
- /*
- * 领取会员
- */
- export function drawMember(uid, screen_name, userid, usermob) {
- if (uid == null || uid.trim() == "") {
- compnt.showAlert('获取微博账号信息失败')
- var def = $.Deferred();
- def.reject();
- return def;
- }
- var param = {
- "fes": query.fes,
- "sou": query.sou,
- "fog": product.fog,
- "userid": userid || user.userid,
- "usermob": usermob || user.usermob,
- "uid": uid,
- "screen_name": encodeURIComponent(screen_name) || ""
- }
- return $.ajax({
- url: root + '/member/draw',
- type: "POST",
- contentType: "application/json",
- data: JSON.stringify(param)
- });
- }
- /**
- * 查询会员领取状态
- */
- export function queryMember(userid, usermob, uid) {
- var param = {
- "fes": query.fes,
- "sou": query.sou,
- "fog": product.fog,
- "userid": userid || user.userid,
- "usermob": usermob || user.usermob,
- "uid": uid || ''
- }
- if (isEmpty(param.userid) && isEmpty(param.uid)) {
- var def = $.Deferred();
- def.reject('参数错误')
- return def;
- }
- return $.ajax({
- url: root + '/member/query',
- type: "POST",
- contentType: "application/json",
- data: JSON.stringify(param)
- });
- }
- /*
- * 领取会员
- */
- export function drawCoin(uid, screen_name, userid, usermob) {
- if (uid == null || uid.trim() == "") {
- compnt.showAlert('获取账号信息失败')
- var def = $.Deferred();
- def.reject();
- return def;
- }
- var param = {
- "fes": query.fes,
- "sou": query.sou,
- "fog": product.fog,
- "userid": userid || user.userid,
- "usermob": usermob || user.usermob,
- "uid": uid,
- "screen_name": screen_name || ""
- }
- return $.ajax({
- url: root + '/coin/draw',
- type: "POST",
- contentType: "application/json",
- data: JSON.stringify(param)
- });
- }
- /**
- * 查询会员领取状态
- */
- export function queryCoin(userid, usermob, uid) {
- var param = {
- "fes": query.fes,
- "sou": query.sou,
- "fog": product.fog,
- "userid": userid || user.userid,
- "usermob": usermob || user.usermob,
- "uid": uid || ''
- }
- if (isEmpty(param.userid) && isEmpty(param.uid)) {
- var def = $.Deferred();
- def.reject('参数错误')
- return def;
- }
- return $.ajax({
- url: root + '/coin/query',
- type: "POST",
- contentType: "application/json",
- data: JSON.stringify(param)
- });
- }
- /**
- * 检查用户是否可以订购
- */
- export function canDrawCoin(uid) {
- if (!uid) {
- var def = $.Deferred();
- def.reject();
- return def;
- }
- var param = {
- "fes": query.fes,
- "sou": query.sou,
- "fog": product.fog,
- "uid": uid || ""
- }
- return $.ajax({
- url: root + '/coin/can',
- type: "POST",
- contentType: "application/json",
- data: JSON.stringify(param)
- });
- }
- /**
- * 大转盘抽奖
- */
- export function lottery(usermob, productid) {
- var param = {
- "userid": usermob,
- "productid": productid,
- 'fog': product.fog
- }
- return $.ajax({
- url: root + '/lottery/draw',
- type: "POST",
- contentType: "application/json",
- data: JSON.stringify(param)
- });
- }
- /**
- * 查询中奖记录
- */
- export function lotterys(usermob, productid, fog) {
- var param = {
- "userid": usermob,
- "productid": productid,
- 'fog': fog
- }
- return $.ajax({
- url: root + '/lottery/query',
- type: "POST",
- contentType: "application/json",
- data: JSON.stringify(param)
- });
- }
- /**
- * 视频彩铃播放地址,50个
- */
- export function findRbtMvs(productid) {
- var param = {
- "productid": productid,
- "fog": product.fog
- }
- return $.ajax({
- url: root + '/rbtmv/findRbtMvs',
- type: "POST",
- contentType: "application/json",
- data: JSON.stringify(param)
- });
- }
- function isEmpty(str) {
- if (str == null || str == '') {
- return true;
- }
- return false;
- }
- /**
- * 发送短信验证码
- * @param {}} $container
- */
- export function sendSms($container, smstype, currentProduct) {
- var def = $.Deferred();
- if ($container.attr('n') != null && $container.attr('n') > 0) {
- return;
- }
- var usermob = $container.find('.usermob').val();
- if (usermob == null || usermob.trim() == "") {
- compnt.showAlert('请输入联通手机号码');
- def.reject();
- return def;
- }
- if (!usermob.startsWith("1") || usermob.length != 11) {
- compnt.showAlert('手机号码格式不正确');
- def.reject();
- return def;
- }
- user.usermob = usermob
- passwordsr = getMess(usermob, aes);
- var param = {
- "fes": query.fes,
- "sou": query.sou,
- "fog": product.fog,
- "usermob": passwordsr,
- "smstype": smstype
- }
- var count = 60;
- $container.attr('n', count);
- $.ajax({
- url: root + '/sms/send',
- type: "POST",
- contentType: "application/json",
- data: JSON.stringify(param)
- }).then(function (response) {
- if (response.resultCode != "0000") {
- count = 0;
- $container.attr('n', count);
- compnt.showAlert(response.errorInfo);
- return;
- }
- var $sendcode = $container.find('.sendcode')
- var template = '{}s'
- if ($sendcode.is('input')) {
- $sendcode.val(template.replace('{}', count));
- } else {
- $sendcode.text(template.replace('{}', count));
- }
- $sendcode.addClass('sendcode-wait');
- var timer = setInterval(function () {
- count -= 1;
- $container.attr('n', count);
- if ($sendcode.is('input')) {
- $sendcode.val(template.replace('{}', count));
- } else {
- $sendcode.text(template.replace('{}', count));
- }
- if (count === 0) {
- clearInterval(timer);
- if ($sendcode.is('input')) {
- $sendcode.val('获取验证码');
- } else {
- $sendcode.text('获取验证码');
- }
- $container.attr('n', count);
- $sendcode.removeClass('sendcode-wait');
- }
- }, 1000);
- try {
- window.HtmlPageVisitor && window.HtmlPageVisitor.setMp(user.usermob);
- } catch (e) { }
- })
- }
- /**
- * 检验短信验证码,并且返回手机号伪代码,有效期10分钟
- * @param {*} usermob
- * @param {*} smscode
- */
- export function checkCode($container, keepUserInfo) {
- var def = $.Deferred();
- var usermob = $container.find('.usermob').val();
- var smscode = $container.find('.smscode').val();
- if (keepUserInfo == null) keepUserInfo = false;
- if (usermob == null || usermob.trim() == "") {
- compnt.showAlert('请输入联通手机号码');
- def.reject()
- return def;
- }
- if (smscode == null || smscode.trim() == "") {
- compnt.showAlert('请输入验证码');
- def.reject()
- return def;
- }
- if (smscode.length != 6) {
- compnt.showAlert('短信验证码不正确');
- def.reject()
- return def;
- }
- passwordsr = getMess(usermob, aes);
- var param = {
- "fes": query.fes,
- "sou": query.sou,
- "fog": product.fog,
- "code": smscode,
- "usermob": passwordsr,
- }
- $.ajax({
- url: root + '/checkvercode',
- type: "POST",
- contentType: "application/json",
- data: JSON.stringify(param)
- }).then(function (response) {
- $container.find('.smscode').val('')
- switch (response.resultCode) {
- case "0000":
- user.userid = response.userid;
- user.usermob = usermob;
- user.usertime = new Date().getTime();
- if (!keepUserInfo) {
- $container.find('.usermob').val('')
- $container.find('.usermob').val('')
- }
- def.resolve(response.userid);
- break;
- default:
- compnt.showAlert(response.errorInfo)
- def.reject(response);
- break;
- }
- }).fail(function (error) {
- def.reject('服务调用异常')
- })
- return def;
- }
- /**
- * 检验短信验证码,并且返回手机号伪代码,有效期10分钟
- * @param {*} usermob
- * @param {*} smscode
- */
- export function checkCodes($container, keepUserInfo) {
- var def = $.Deferred();
- var usermob = $container.find('.usermob').val();
- var smscode = $container.find('.smscode').val();
- if (keepUserInfo == null) keepUserInfo = false;
- if (usermob == null || usermob.trim() == "") {
- compnt.showAlert('请输入联通手机号码');
- def.reject()
- return def;
- }
- if (smscode == null || smscode.trim() == "") {
- compnt.showAlert('请输入验证码');
- def.reject()
- return def;
- }
- if (smscode.length != 6) {
- compnt.showAlert('短信验证码不正确');
- def.reject()
- return def;
- }
- passwordsr = getMess(usermob, aes);
- var param = {
- "fes": query.fes,
- "sou": query.sou,
- "fog": product.fog,
- "code": smscode,
- "usermob": passwordsr,
- }
- $.ajax({
- url: root + '/checkvercode',
- type: "POST",
- contentType: "application/json",
- data: JSON.stringify(param)
- }).then(function (response) {
- // $container.find('.smscode').val('')
- switch (response.resultCode) {
- case "0000":
- user.userid = response.userid;
- user.usermob = usermob;
- user.usertime = new Date().getTime();
- if (!keepUserInfo) {
- // $container.find('.usermob').val('')
- // $container.find('.usermob').val('')
- }
- def.resolve(response.userid);
- break;
- default:
- compnt.showAlert(response.errorInfo)
- def.reject(response);
- break;
- }
- }).fail(function (error) {
- def.reject('服务调用异常')
- })
- return def;
- }
- export function oneClickLogin(code) {
- if (code == null || code == "") {
- return;
- }
- var param = {
- "fes": query.fes,
- "sou": query.sou,
- "fog": product.fog,
- "code": code
- }
- var def = $.Deferred();
- $.ajax({
- url: root + '/onekeylogin',
- type: "POST",
- contentType: "application/json",
- data: JSON.stringify(param)
- }).then(function (response) {
- switch (response.resultCode) {
- case "0000":
- user.userid = response.userid;
- user.usermob = response.usermob;
- user.usertime = new Date().getTime();
- def.resolve(response.userid);
- break;
- default:
- compnt.showAlert(response.errorInfo)
- def.reject(response);
- break;
- }
- }).fail(function (error) {
- def.reject('服务调用异常')
- })
- return def;
- }
- /**
- * 发送短信验证码
- * @param {}} $container
- */
- export function sendSmsarr($container, smstype, currentProduct) {
- var def = $.Deferred();
- if ($container.attr('n') != null && $container.attr('n') > 0) {
- return;
- }
- var usermob = $container.find('.usermob').val();
- if (usermob == null || usermob.trim() == "") {
- compnt.showAlertarxe('请输入联通手机号码');
- def.reject();
- return def;
- }
- if (!usermob.startsWith("1") || usermob.length != 11) {
- compnt.showAlertarxe('手机号码格式不正确');
- def.reject();
- return def;
- }
- user.usermob = usermob
- passwordsr = getMess(usermob, aes);
- var param = {
- "fes": query.fes,
- "sou": query.sou,
- "fog": product.fog,
- "usermob": passwordsr,
- "smstype": smstype
- }
- var count = 60;
- $container.attr('n', count);
- $.ajax({
- url: root + '/sms/send',
- type: "POST",
- contentType: "application/json",
- data: JSON.stringify(param)
- }).then(function (response) {
- if (data.status == 302) {
- location.href = data.location;
- }
- if (response.resultCode != "0000") {
- count = 0;
- $container.attr('n', count);
- compnt.showAlertarxe(response.errorInfo);
- return;
- }
- var $sendcode = $container.find('.sendcode')
- var template = '{}s'
- if ($sendcode.is('input')) {
- $sendcode.val(template.replace('{}', count));
- } else {
- $sendcode.text(template.replace('{}', count));
- }
- $sendcode.addClass('sendcode-wait');
- var timer = setInterval(function () {
- count -= 1;
- $container.attr('n', count);
- if ($sendcode.is('input')) {
- $sendcode.val(template.replace('{}', count));
- } else {
- $sendcode.text(template.replace('{}', count));
- }
- if (count === 0) {
- clearInterval(timer);
- if ($sendcode.is('input')) {
- $sendcode.val('获取验证码');
- } else {
- $sendcode.text('获取验证码');
- }
- $container.attr('n', count);
- $sendcode.removeClass('sendcode-wait');
- }
- }, 1000);
- try {
- window.HtmlPageVisitor && window.HtmlPageVisitor.setMp(user.usermob);
- } catch (e) { }
- })
- }
- /**
- * 检验短信验证码,并且返回手机号伪代码,有效期10分钟
- * @param {*} usermob
- * @param {*} smscode
- */
- export function checkCodearr($container, keepUserInfo) {
- var def = $.Deferred();
- var usermob = $container.find('.usermob').val();
- var smscode = $container.find('.smscode').val();
- if (keepUserInfo == null) keepUserInfo = false;
- if (usermob == null || usermob.trim() == "") {
- compnt.showAlertarxe('请输入联通手机号码');
- def.reject()
- return def;
- }
- if (smscode == null || smscode.trim() == "") {
- compnt.showAlertarxe('请输入验证码');
- def.reject()
- return def;
- }
- if (smscode.length != 6) {
- compnt.showAlertarxe('短信验证码不正确');
- def.reject()
- return def;
- }
- passwordsr = getMess(usermob, aes);
- var param = {
- "fes": query.fes,
- "sou": query.sou,
- "fog": product.fog,
- "code": smscode,
- "usermob": passwordsr,
- }
- $.ajax({
- url: root + '/checkvercode',
- type: "POST",
- contentType: "application/json",
- data: JSON.stringify(param)
- }).then(function (response) {
- $container.find('.smscode').val('')
- switch (response.resultCode) {
- case "0000":
- user.userid = response.userid;
- user.usermob = usermob;
- user.usertime = new Date().getTime();
- if (!keepUserInfo) {
- $container.find('.usermob').val('')
- $container.find('.usermob').val('')
- }
- def.resolve(response.userid);
- break;
- default:
- compnt.showAlertarxe(response.errorInfo)
- def.reject(response);
- break;
- }
- }).fail(function (error) {
- def.reject('服务调用异常')
- })
- return def;
- }
- /**
- * 通过code参数,调用微博开放平台的接口查询用户信息
- */
- export function queryWeiboUserInfo() {
- var param = {
- "code": query.code,
- "redirect_uri": "http://100.0.3.69:3344/orderchannel/sina/wb/weibo1.html"
- }
- var def = $.Deferred();
- $.ajax({
- url: root + "/weibo/query",
- type: "POST",
- contentType: "application/json",
- data: JSON.stringify(param)
- }).then(function (response) {
- switch (response.resultCode) {
- case "0000":
- def.resolve(response);
- break;
- default:
- compnt.showAlert(response.errorInfo)
- def.reject(response);
- break;
- }
- }).fail(function (error) {
- def.reject('服务调用异常')
- })
- return def;
- };
- /*
- 领取权益接口
- */
- export function deaw(userid, token, usermob, spid, productname) {
- var param = {
- "userid": usermob,
- "vipcode": token,
- "vipuser": userid,
- 'fog': product.fog,
- 'spid': spid || '',
- 'productname': productname || ''
- }
- if (spid != null && spid != "") {
- param.spid = spid;
- }
- var def = $.Deferred();
- $.ajax({
- url: root + "/rights/draw",
- type: "POST",
- contentType: "application/json",
- data: JSON.stringify(param)
- }).then(function (response) {
- switch (response.resultCode) {
- case "0000":
- def.resolve(response);
- break;
- case "1102":
- def.resolve(response);
- break;
- case "1105":
- def.resolve(response);
- break;
- case "1015":
- def.resolve(response);
- break;
- default:
- compnt.showAlert(response.errorInfo)
- def.reject(response);
- break;
- }
- }).fail(function (error) {
- def.reject('服务调用异常')
- })
- return def;
- };
- /*
- 领取百度权益接口
- */
- export function deaws(userid, token, usermob, spid, productname, productid) {
- var param = {
- "userid": usermob,
- "vipcode": token,
- "vipuser": userid,
- 'fog': product.fog,
- 'spid': spid || '',
- 'productname': productname || ''
- }
- if (spid != null && spid != "") {
- param.spid = spid;
- }
- if (productid != null && productid != "") {
- param.productid = productid;
- }
- var def = $.Deferred();
- $.ajax({
- url: root + "/rights/draw",
- type: "POST",
- contentType: "application/json",
- data: JSON.stringify(param)
- }).then(function (response) {
- switch (response.resultCode) {
- case "0000":
- def.resolve(response);
- break;
- case "1102":
- def.resolve(response);
- break;
- case "1105":
- def.resolve(response);
- break;
- case "1015":
- def.resolve(response);
- break;
- default:
- compnt.showAlertarxe(response.errorInfo)
- def.reject(response);
- break;
- }
- }).fail(function (error) {
- def.reject('服务调用异常')
- })
- return def;
- };
- /*
- 查询开通记录与状态
- */
- export function queryWeiboUserInfoaks(usermob, spid) {
- // var productid = 2020010201
- var param = {
- "userid": usermob,
- 'fog': product.fog,
- }
- if (spid != null && spid != "") {
- param.spid = spid;
- }
- var def = $.Deferred();
- $.ajax({
- url: root + "/rights/query",
- type: "POST",
- contentType: "application/json",
- data: JSON.stringify(param)
- }).then(function (response) {
- if (response.productid == '2020090401') {
- name_a = '定向流量权益包(后向)';
- } else if (response.productid == '2021091709') {
- name_a = '定向流量权益包(联通次月生效)';
- } else if (response.productid == '2020111201') {
- name_a = '定向流量权益包(次月生效)';
- } else if (response.productid == '2021091702') {
- name_a = '定向流量权益包(联通)';
- }
- // switch (response.resultCode) {
- // case "0000":
- // def.resolve(response);
- // break;
- // case "1066":
- // def.resolve(response);
- // break;
- // default:
- // def.reject(response);
- // break;
- // }
- }).fail(function (error) {
- def.reject('服务调用异常')
- })
- return def;
- };
- //查询百度产品状态
- export function queryWeiboUserInfoaksra(usermob) {
- // var productid = 2020010201
- var param = {
- "userid": usermob,
- 'fog': product.fog,
- 'vipcode': '90001'
- }
- // if (spid != null && spid != "") {
- // param.spid = spid;
- // }
- var def = $.Deferred();
- $.ajax({
- url: root + "/rights/querys",
- type: "POST",
- contentType: "application/json",
- data: JSON.stringify(param)
- }).then(function (response) {
- switch (response.resultCode) {
- case "0000":
- def.resolve(response);
- break;
- case "1066":
- def.resolve(response);
- break;
- default:
- def.reject(response);
- break;
- }
- }).fail(function (error) {
- def.reject('服务调用异常')
- })
- return def;
- };
- /*
- 查询开通记录与状态三个月接口
- */
- export function queryWeiboUserInfoak(usermob) {
- // var productid = 2020010201
- var param = {
- "userid": usermob,
- 'fog': product.fog,
- 'vipcode': '10001'
- }
- // if (spid != null && spid != "") {
- // param.spid = spid;
- // }
- var def = $.Deferred();
- $.ajax({
- url: root + "/rights/querys",
- type: "POST",
- contentType: "application/json",
- data: JSON.stringify(param)
- }).then(function (response) {
- // console.log(response.data.length)
- switch (response.resultCode) {
- case "0000":
- def.resolve(response);
- break;
- case "1066":
- def.resolve(response);
- break;
- default:
- def.reject(response);
- break;
- }
- }).fail(function (error) {
- def.reject('服务调用异常')
- })
- return def;
- };
- /*
- 文明办领取接口*/
- export function wmbdraw(usermob) {
- var param = {
- "usermob": usermob,
- 'fog': product.fog,
- "sou": query.sou,
- 'fes': query.fes
- }
- var def = $.Deferred();
- $.ajax({
- url: root + "/civilize/order",
- type: "POST",
- contentType: "application/json",
- data: JSON.stringify(param)
- }).then(function (response) {
- switch (response.resultCode) {
- case "0000":
- def.resolve(response);
- break;
- case "1023":
- def.resolve(response);
- break;
- // case "1105":
- // def.resolve(response);
- // break;
- // case "1061":
- // def.resolve(response);
- // break;
- // case "8601":
- // def.resolve(response);
- // break;
- default:
- $('.overlayssr').css('display', 'none');
- $('body').css('overflow', 'auto');
- compnt.showAlerts(response.errorInfo)
- def.reject(response);
- break;
- }
- }).fail(function (error) {
- def.reject('服务调用异常')
- })
- return def;
- };
- /*
- 后向电商页面7元8g产品,白名单用户订购*/
- export function allowdeaw(ticket, orderchannel, usermob) {
- var param = {
- "ticket": ticket,
- "orderchannel": query.sou,
- 'fog': product.fog,
- }
- // console.log(userid, product.fog, query.sou)
- var def = $.Deferred();
- $.ajax({
- url: root + "/allowlistdarw/order",
- type: "POST",
- contentType: "application/json",
- data: JSON.stringify(param)
- }).then(function (response) {
- switch (response.resultCode) {
- case "0000":
- def.resolve(response);
- break;
- case "1104":
- def.resolve(response);
- break;
- case "1105":
- def.resolve(response);
- break;
- case "1061":
- def.resolve(response);
- break;
- case "8601":
- def.resolve(response);
- break;
- default:
- // response.errorInfo
- compnt.showAlerts(response.errorInfo)
- def.reject(response);
- break;
- }
- }).fail(function (error) {
- def.reject('服务调用异常')
- })
- return def;
- };
- /**
- * 调用统一认证订购接口
- */
- export function showCapOrder(fog, productName, scrollable, hasNetNumber, decryptUsermob, capTemplet) {
- historyBackExecuted = false;
- var capUrl;
- var baseUrl;
- if (window.location.href.indexOf("https://800.wo.cn/orderchannel") >= 0) {
- capUrl = "https://800.wo.cn/cap/order.html";
- baseUrl = "https://800.wo.cn/";
- } else if (window.location.href.indexOf("https://800.wo.cn/festivalchannel") >= 0) {
- capUrl = "https://800.wo.cn/festivalcap/order.html";
- baseUrl = "https://800.wo.cn/";
- } else if (window.location.href.indexOf("localhost") >= 0) {
- capUrl = "http://localhost:8088/cap/order.html";
- baseUrl = "http://localhost:8088/";
- } else if (window.location.href.indexOf("100.0.3.69:3344") >= 0) {
- capUrl = "http://100.0.3.69:3344/cap/order.html";
- baseUrl = "http://100.0.3.69:3344/";
- } else if (window.location.href.indexOf("100.0.3.69:8282") >= 0) {
- capUrl = "http://100.0.3.69:8282/cap/order.html";
- baseUrl = "http://100.0.3.69:8282/";
- } else if (window.location.href.indexOf("https://operation1.bol.wo.cn") >= 0) {
- capUrl = "https://800.wo.cn/cap/order.html";
- baseUrl = "https://800.wo.cn/";
- } else {
- // capUrl = "https://800.wo.cn/festivalcap/order.html";
- // baseUrl = "https://800.wo.cn/";
- capUrl = "https://800.wo.cn/cap/order.html";
- baseUrl = "https://800.wo.cn/";
- }
- var $iframe;
- if ($('#uniauthframe').length >= 1) {
- $iframe = $('#uniauthframe').attr('src', capUrl);
- } else {
- $iframe = $('<iframe id="uniauthframe" src="' + capUrl + '"></iframe>');
- }
- $iframe.css({
- width: "100%",
- height: "100%",
- position: "fixed",
- top: 0,
- left: 0,
- margin: 0,
- padding: 0,
- "-webkit-overflow-scrolling": "touch",
- border: "0px",
- })
- compnt.showLoading();
- $iframe.on('load', function () {
- $capoverlay.remove();
- generClientSecret(fog).then(function (response) {
- compnt.hideLoading();
- response.festival = parseInt(query.fes, 32);
- response.orderChannel = parseInt(query.sou, 32);
- if (productName != null && productName != '') {
- response.productName = productName;
- }
- if (capTemplet != null && capTemplet != '') {
- response.capTemplet = capTemplet
- }
- $iframe[0].contentWindow.postMessage(JSON.stringify(response), baseUrl)
- })
- })
- if (navigator.userAgent.indexOf("MicroMessenger") >= 0) {
- //微信6.7.4及以后版本 ios12软键盘顶起页面后隐藏不回弹解决方案
- //打开嵌入的统一认证取号页面前,让原来的页面上下滚动。
- //统一认证的页面关闭以后,删除定时任务 clearInterval(window.capTimer)
- var currentPosition;
- var speed = 1; // 页面滚动距离
- window.capTimer = setInterval(function () {
- currentPosition = document.documentElement.scrollTop || document.body.scrollTop;
- currentPosition -= speed;
- window.top.scrollTo(0, currentPosition); //页面向上滚动
- currentPosition += speed; //speed变量
- window.top.scrollTo(0, currentPosition); //页面向下滚动
- }, 200);
- }
- window.$capoverlay = $('<div class="overlay" style="z-index: 0"></div>');
- $capoverlay.appendTo($(document.body));
- if ($('#uniauthframe').length == 0) {
- $('body').append($iframe);
- } else {
- $iframe.css('position', 'unset')
- .css('min-height', '10rem')
- }
- // 是否允许横向,网易游戏的窗口只能横向,横向的情况,不能进制滚动
- if (!scrollable) {
- $("body").css("overflow", "hidden");
- }
- var def = $.Deferred();
- function handleMessage(event) {
- var data = JSON.parse(event.data);
- switch (data.resultcode) {
- case "0": //处理成功
- $iframe.remove();
- $capoverlay.remove();
- $("body").css("overflow", "auto");
- clearInterval(window.capTimer)
- user.token = data.token;
- user.userid = decodeURIComponent(data.userid);
- user.userid1 = data.userid1;
- user.usermob = data.usermob;
- user.usertime = new Date().getTime();
- if (!!decryptUsermob) {
- decodeUsermob()
- }
- def.resolve(user);
- break;
- case "9001": //关闭H5认证页面
- $iframe.remove();
- $capoverlay.remove();
- clearInterval(window.capTimer)
- $("body").css("overflow", "auto");
- def.reject(data);
- if (hasNetNumber != null && !!hasNetNumber && !historyBackExecuted) {
- if (query.test == '1') {
- alert(navigator.userAgent);
- }
- // 目前火狐浏览在打开iframe后不会产生历史记录,Chrome内核的浏览器会产生历史记录
- if (isChromeKernelBrowser()) {
- historyBackExecuted = true;
- history.back();
- }
- }
- break;
- case "0001": //auth_no无效
- case "0003": //client_id不存在
- case "0006": //验证码不正确
- case "4444": //服务暂时不可用(系统忙/系统队列满)
- break;
- default:
- $iframe.remove();
- $capoverlay.remove();
- $("body").css("overflow", "auto");
- clearInterval(window.capTimer)
- compnt.showAlert(data.errorinfo)
- def.reject(data)
- break;
- }
- }
- window.removeEventListener('message', handleMessage);
- window.addEventListener('message', handleMessage);
- return def;
- }
- /**
- * 打开统一认证的页面,
- * hasNetNumber 统一认证页面是否支持net取号
- * historyBackExecuted 是否已经调用了history.back方法
- */
- var historyBackExecuted = true;
- export function showCapPage(fog, productName, scrollable, hasNetNumber, decryptUsermob, capTemplet) {
- console.log(fog, productName, scrollable, hasNetNumber, decryptUsermob, capTemplet,"open1");
- historyBackExecuted = false;
- if (fog != null && product.fog == null) {
- product.fog = fog;
- }
- // 是否允许横向,网易游戏的窗口只能横向,横向的情况,不能限制滚动
- if (!scrollable) {
- $("body").css("overflow", "hidden");
- }
- var capUrl;
- var baseUrl;
- if (window.location.href.indexOf("https://800.wo.cn/orderchannel") >= 0) {
- capUrl = "https://800.wo.cn/cap/CAP-AUTH.html";
- baseUrl = "https://800.wo.cn/";
- } else if (window.location.href.indexOf("https://800.wo.cn/festivalchannel") >= 0) {
- capUrl = "https://800.wo.cn/festivalcap/CAP-AUTH.html";
- baseUrl = "https://800.wo.cn/";
- } else if (window.location.href.indexOf("http://localhost") >= 0) {
- capUrl = "http://localhost:8088/cap/CAP-AUTH.html";
- baseUrl = "http://localhost:8088/";
- } else if (window.location.href.indexOf("http://127.0.0.1") >= 0) {
- capUrl = "http://127.0.0.1:8088/cap/CAP-AUTH.html";
- baseUrl = "http://127.0.0.1:8088/";
- } else if (window.location.href.indexOf("http://100.0.3.69:3344") >= 0) {
- capUrl = "http://100.0.3.69:3344/cap/CAP-AUTH.html";
- baseUrl = "http://100.0.3.69:3344/";
- } else if (window.location.href.indexOf("http://100.0.3.69:8282") >= 0) {
- capUrl = "http://100.0.3.69:8282/cap/CAP-AUTH.html";
- baseUrl = "http://100.0.3.69:8282/";
- } else if (window.location.href.indexOf("https://800.wo.cn/festivalcap") >= 0) {
- capUrl = "https://800.wo.cn/festivalcap/CAP-AUTH.html";
- baseUrl = "https://800.wo.cn/";
- } else {
- capUrl = "https://800.wo.cn/cap/CAP-AUTH.html";
- baseUrl = "https://800.wo.cn/";
- }
- // ad 是广告英文单词的缩写,会被浏览器当作广告拦截
- // if ($("#nanyanad").val() != null) {
- // capUrl += '?ny=' + $("#nanyanad").val()
- // }
- var $iframe;
- if ($('#uniauthframe').length >= 1) {
- $iframe = $('#uniauthframe').attr('src', capUrl);
- } else {
- $iframe = $('<iframe id="uniauthframe" src="' + capUrl + '" style="width:100%;height:100%;position:fixed;top:0;left:0;margin:0;padding:0;border:0"></iframe>');
- }
- // $iframe.css({
- // width: "100%",
- // height: "100%",
- // position: "fixed",
- // top: 0,
- // left: 0,
- // margin: 0,
- // padding: 0,
- // "-webkit-overflow-scrolling": "touch",
- // border: "0px",
- // })
- compnt.showLoading();
- $iframe.on('load', function () {
- $capoverlay.remove();
- generClientSecret(fog).then(function (response) {
- compnt.hideLoading();
- response.orderChannel = query.fes + "_" + query.sou;
- if (productName != null && productName != '') {
- response.productName = productName;
- }
- if (capTemplet != null && capTemplet != '') {
- response.capTemplet = capTemplet
- }
- if (query.phone && query.phone != "") {
- response.phone = query.phone;
- }
- try {
- // response.appid = htmlPageVisitorAppId;
- } catch (e) {
- }
- // alert(baseUrl)
- // alert(JSON.stringify(response))
- // alert($iframe[0].contentWindow.postMessage)
- try {
- console.log(response,baseUrl,"this.response");
- $iframe[0].contentWindow.postMessage(JSON.stringify(response), baseUrl)
- console.log('进入收银页面:cap_open')
- WoAnalytics && WoAnalytics.addPoint({ ad: $('#directflowactivity').val(), at: $('#namehd').val(), ett: 'open', ea: 'cashier_view', cpn: 'cashier', pm: parseInt(query.sou, 32) })
- } catch (e) {
- // alert(JSON.stringify(e))
- }
- })
- })
- if (navigator.userAgent.indexOf("MicroMessenger") >= 0) {
- //微信6.7.4及以后版本 ios12软键盘顶起页面后隐藏不回弹解决方案
- //打开嵌入的统一认证取号页面前,让原来的页面上下滚动。
- //统一认证的页面关闭以后,删除定时任务 clearInterval(window.capTimer)
- var currentPosition;
- var speed = 1; // 页面滚动距离
- window.capTimer = setInterval(function () {
- currentPosition = document.documentElement.scrollTop || document.body.scrollTop;
- currentPosition -= speed;
- window.top.scrollTo(0, currentPosition); //页面向上滚动
- currentPosition += speed; //speed变量
- window.top.scrollTo(0, currentPosition); //页面向下滚动
- }, 200);
- }
- window.$capoverlay = $('<div class="overlay" style="z-index: 0"></div>');
- $capoverlay.appendTo($(document.body));
- if ($('#uniauthframe').length == 0) {
- $('body').append($iframe);
- } else {
- $iframe.css('position', 'unset')
- .css('min-height', '10rem')
- }
- var def = $.Deferred();
- function messageListener(event) {
- var data = null;
- try {
- data = JSON.parse(event.data);
- } catch (e) {
- return;
- }
- console.log(data)
- switch (data.resultcode) {
- case "0": //处理成功
- $iframe.remove();
- $capoverlay.remove();
- window.removeEventListener('message', messageListener);
- $("body").css("overflow", "auto");
- clearInterval(window.capTimer)
- user.token = data.token;
- user.userid = decodeURIComponent(data.userid);
- user.userid1 = data.userid1;
- user.usermob = data.usermob;
- user.usertime = new Date().getTime();
- if (!!decryptUsermob) {
- decodeUsermob()
- }
- try {
- window.HtmlPageVisitor && window.HtmlPageVisitor.setMp(data.usermob);
- console.log('进入收银台页面,点击确认支付按钮')
- WoAnalytics && WoAnalytics.addPoint({ ad: $('#directflowactivity').val(), at: $('#namehd').val(), ett: 'click', ea: 'pay_continue_click', cpn: 'cashier', pm: parseInt(query.sou, 32), mp: user.usermob })
- } catch (e) { }
- def.resolve(user);
- break;
- case "9001": //关闭H5认证页面
- $iframe.remove();
- $capoverlay.remove();
- window.removeEventListener('message', messageListener);
- clearInterval(window.capTimer)
- $("body").css("overflow", "auto");
- def.reject(data);
- if (hasNetNumber != null && !!hasNetNumber && !historyBackExecuted) {
- if (query.test == '1') {
- alert(navigator.userAgent);
- }
- // 目前火狐浏览在打开iframe后不会产生历史记录,Chrome内核的浏览器会产生历史记录
- if (isChromeKernelBrowser()) {
- historyBackExecuted = true;
- history.back();
- }
- }
- break;
- case "0001": //auth_no无效
- case "0003": //client_id不存在
- case "0006": //验证码不正确
- case "4444": //服务暂时不可用(系统忙/系统队列满)
- break;
- case "99999": // 埋点信号
- if (data.operid) {
- burypointLogId(data.operid);
- }
- if (data.ea) {
- WoAnalytics.addPoint({ ad: $("#nanyanad").val(), ett: 'open', ea: data.ea + $("#nanyanlabel").val(), ct: 'web', pm: parseInt(getUrlParam("sou"), 32) })
- }
- try {
- window.WoAnalytics && window.WoAnalytics.setMp(data.usermob);
- } catch (e) { }
- break;
- default:
- $iframe.remove();
- $capoverlay.remove();
- window.removeEventListener('message', messageListener);
- $("body").css("overflow", "auto");
- clearInterval(window.capTimer)
- compnt.showAlert(data.errorinfo)
- def.reject(data)
- break;
- }
- }
- window.addEventListener('message', messageListener);
- return def;
- }
- export function showCancelReasonPage() {
- var reasonUrl;
- var baseUrl;
- if (window.location.href.indexOf("https://800.wo.cn/orderchannel") >= 0) {
- reasonUrl = "https://800.wo.cn/orderchannel/public/libs/cancelreason/index.html";
- baseUrl = "https://800.wo.cn/";
- } else if (window.location.href.indexOf("https://optest.bol.wo.cn") >= 0) {
- reasonUrl = "https://optest.bol.wo.cn/orderchannel/orderchannel-s1h5/public/libs/cancelreason/indexs.html";
- baseUrl = "https://optest.bol.wo.cn/";
- } else if (window.location.href.indexOf("https://800.wo.cn/festivalchannel") >= 0) {
- reasonUrl = "https://800.wo.cn/festivalchannel/public/libs/cancelreason/index.html";
- baseUrl = "https://800.wo.cn/";
- } else if (window.location.href.indexOf("http://localhost") >= 0) {
- reasonUrl = "http://localhost:8088/orderchannel/public/libs/cancelreason/index.html";
- baseUrl = "http://localhost:8088/";
- } else if (window.location.href.indexOf("http://127.0.0.1") >= 0) {
- reasonUrl = "http://127.0.0.1:8088/orderchannel/public/libs/cancelreason/index.html";
- baseUrl = "http://127.0.0.1:8088/";
- } else if (window.location.href.indexOf("http://100.0.3.69:3344") >= 0) {
- reasonUrl = "http://100.0.3.69:3344/orderchannel/public/libs/cancelreason/index.html";
- baseUrl = "http://100.0.3.69:3344/";
- } else if (window.location.href.indexOf("http://100.0.3.69:8282") >= 0) {
- reasonUrl = "http://100.0.3.69:8282/orderchannel/public/libs/cancelreason/index.html";
- baseUrl = "http://100.0.3.69:8282/";
- } else {
- reasonUrl = "https://operation1.bol.wo.cn/orderchannel/public/libs/cancelreason/index.html";
- baseUrl = "https://operation1.bol.wo.cn/";
- }
- window.$capoverlay = $('<div class="overlay" style="z-index: 0; background-color: rgba(0,0,0,0.4);"></div>');
- $capoverlay.appendTo($(document.body));
- $("body").css("overflow", "hidden");
- var $iframe;
- if ($('#reasonIframe').length >= 1) {
- $iframe = $('#reasonIframe').attr('src', reasonUrl);
- } else {
- $iframe = $('<iframe id="reasonIframe" src="' + reasonUrl + '"></iframe>');
- $('body').append($iframe);
- }
- $iframe.css({
- width: "100%",
- height: "100%",
- position: "fixed",
- top: 0,
- left: 0,
- margin: 0,
- padding: 0,
- "-webkit-overflow-scrolling": "touch",
- border: "0px",
- "z-index": 111,
- });
- var def = $.Deferred();
- function messageListener(event) {
- var data = JSON.parse(event.data);
- $iframe.remove();
- $capoverlay.remove();
- $("body").css("overflow", "auto");
- window.removeEventListener('message', messageListener);
- if (data.eventtype != 'close') {
- def.resolve(data)
- } else {
- def.reject(data)
- }
- }
- window.addEventListener('message', messageListener);
- return def;
- }
- //抖音以外产品调用退订采集原因页面
- export function showCancelReasonPages() {
- var reasonUrl;
- var baseUrl;
- if (window.location.href.indexOf("https://800.wo.cn/orderchannel") >= 0) {
- reasonUrl = "https://800.wo.cn/orderchannel/public/libs/cancelreason/indexs.html";
- baseUrl = "https://800.wo.cn/";
- } else if (window.location.href.indexOf("https://optest.bol.wo.cn") >= 0) {
- reasonUrl = "https://optest.bol.wo.cn/orderchannel/orderchannel-s1h5/public/libs/cancelreason/indexs.html";
- baseUrl = "https://optest.bol.wo.cn/";
- } else if (window.location.href.indexOf("https://800.wo.cn/festivalchannel") >= 0) {
- reasonUrl = "https://800.wo.cn/festivalchannel/public/libs/cancelreason/indexs.html";
- baseUrl = "https://800.wo.cn/";
- } else if (window.location.href.indexOf("http://localhost") >= 0) {
- reasonUrl = "http://localhost:8088/orderchannel/public/libs/cancelreason/indexs.html";
- baseUrl = "http://localhost:8088/";
- } else if (window.location.href.indexOf("http://127.0.0.1") >= 0) {
- reasonUrl = "http://127.0.0.1:8088/orderchannel/public/libs/cancelreason/indexs.html";
- baseUrl = "http://127.0.0.1:8088/";
- } else if (window.location.href.indexOf("http://100.0.3.69:3344") >= 0) {
- reasonUrl = "http://100.0.3.69:3344/orderchannel/public/libs/cancelreason/indexs.html";
- baseUrl = "http://100.0.3.69:3344/";
- } else if (window.location.href.indexOf("http://100.0.3.69:8282") >= 0) {
- reasonUrl = "http://100.0.3.69:8282/orderchannel/public/libs/cancelreason/indexs.html";
- baseUrl = "http://100.0.3.69:8282/";
- } else {
- reasonUrl = "https://operation1.bol.wo.cn/orderchannel/public/libs/cancelreason/index.html";
- baseUrl = "https://operation1.bol.wo.cn/";
- }
- window.$capoverlay = $('<div class="overlay" style="z-index: 0; background-color: rgba(0,0,0,0.4);"></div>');
- $capoverlay.appendTo($(document.body));
- $("body").css("overflow", "hidden");
- var $iframe;
- if ($('#reasonIframe').length >= 1) {
- $iframe = $('#reasonIframe').attr('src', reasonUrl);
- } else {
- $iframe = $('<iframe id="reasonIframe" src="' + reasonUrl + '"></iframe>');
- $('body').append($iframe);
- }
- $iframe.css({
- width: "100%",
- height: "100%",
- position: "fixed",
- top: 0,
- left: 0,
- margin: 0,
- padding: 0,
- "-webkit-overflow-scrolling": "touch",
- border: "0px",
- "z-index": 111,
- });
- var def = $.Deferred();
- function messageListener(event) {
- var data = JSON.parse(event.data);
- $iframe.remove();
- $capoverlay.remove();
- $("body").css("overflow", "auto");
- window.removeEventListener('message', messageListener);
- if (data.eventtype != 'close') {
- def.resolve(data)
- } else {
- def.reject(data)
- }
- }
- window.addEventListener('message', messageListener);
- return def;
- }
- function decodeUsermob(userid) {
- var param = {
- "fog": product.fog || fog || "",
- "userid": userid || user.userid
- }
- $.ajax({
- url: root + '/decodeUserid',
- type: "POST",
- contentType: "application/json",
- data: JSON.stringify(param)
- }).then(function (data) {
- if (data.resultCode == '0') {
- user.usermob = data.usermob;
- }
- });
- }
- function parseQueryParms() {
- var QUERY_SEPARATOR = '&',
- VALUE_SEPARATOR = '=';
- var queryStr = window.location.search.substring(1);
- var startIndex = 0,
- vIndex, qIndex;
- while (queryStr.length > 0) {
- vIndex = queryStr.indexOf(VALUE_SEPARATOR, startIndex);
- if (vIndex == -1) {
- break;
- }
- qIndex = queryStr.indexOf(QUERY_SEPARATOR, vIndex + 1);
- if (qIndex == -1) {
- qIndex = queryStr.length;
- }
- var key = queryStr.substring(startIndex, vIndex);
- var value = queryStr.substring(vIndex + 1, qIndex);
- query[key] = decodeURIComponent(value);
- startIndex = qIndex + 1;
- }
- }
- export function removeGetParam(name, url) {
- var tempUrl = url || window.location.href;
- var arr = tempUrl.split("?");
- if (arr.length == 1) {
- return tempUrl;
- }
- var paramArr = arr[1].split("&");
- var i = paramArr.length - 1;
- for (; i >= 0; i--) {
- if (paramArr[i].startsWith(name + "=")) {
- paramArr.splice(i, 1);
- }
- }
- return arr[0] + "?" + paramArr.join("&");
- }
- function generClientSecret(fog) {
- var param = {
- "fog": product.fog || fog || "",
- "channel": ""
- }
- return $.ajax({
- url: root + '/ini/gensign',
- type: "POST",
- contentType: "application/json",
- data: JSON.stringify(param)
- })
- }
- export function saveUserInfo(duration) {
- localStorage.setItem('user' + product.productid, JSON.stringify(user));
- localStorage.setItem('time' + product.productid, duration || ((new Date().getTime()) + ""));
- }
- export function loadUserInfo(duration) {
- if (query.userid) {
- user.userid = query.userid;
- user.usermob = query.usermob;
- return;
- }
- try {
- var time = localStorage.getItem('time' + product.productid);
- if (time) {
- var curr = new Date().getTime();
- // 默认有效期是1小时
- if (curr <= parseFloat(time) + (duration || (1000 * 60 * 60))) {
- var userString = localStorage.getItem("user" + product.productid);
- if (userString != null) {
- user = JSON.parse(userString);
- user.userid = user.userid;
- user.usermob = user.usermob;
- }
- // if (user.usermob == "18674842761" || user.usermob == "17610768237") {
- // setTimeout(function() {
- // alert(time + (duration || (1000 * 60 * 60)))
- // }, 100);
- // }
- } else {
- // 超过1小时删除缓存数据
- localStorage.removeItem("time" + product.productid)
- localStorage.removeItem("user" + product.productid)
- }
- return user;
- } else {
- localStorage.removeItem("time" + product.productid)
- localStorage.removeItem("user" + product.productid)
- }
- } catch (e) {
- }
- }
- /**
- * SliderCaptcha
- */
- export function verifyCaptcha(arr) {
- $.ajax({
- url: root + '/sliderCaptcha/verify',
- type: "POST",
- contentType: "application/json",
- data: JSON.stringify(arr)
- }).then(function (responseText) {
- var response = JSON.parse(responseText);
- if (response.resultCode == "0000") {
- product.captchaCode = response.captchaCode;
- return true;
- } else {
- compnt.showAlert(response.errorInfo);
- return false;
- }
- })
- };
- /**
- * 获取项目根目录
- * @returns
- */
- export function getRootPath() {
- //获取当前网址,如: http://localhost:8080/ems/Pages/Basic/Person.jsp
- var curWwwPath = window.document.location.href;
- //获取主机地址之后的目录,如: /ems/Pages/Basic/Person.jsp
- var pathName = window.document.location.pathname;
- var pos = curWwwPath.indexOf(pathName);
- //获取主机地址,如: http://localhost:8080
- var localhostPath = curWwwPath.substring(0, pos);
- //获取带"/"的项目名,如:/ems
- // var projectName = pathName.substring(0, pathName.substr(1).indexOf('/') + 1);
- var projectName = "/orderchannel-s1api"
- root = (localhostPath + projectName);
- // return (localhostPath + projectName);
- return env.APP_BASE.apiUrl
- }
- /**
- * 获取当前url中参数信息
- * @param urlprm url中参数名称
- * @returns
- */
- export function getUrlParam(urlprm) {
- if (window.location.href == "https://800.wo.cn/orderchannel/hd/Dy/order202005.html?fes=jh7") {
- window.location.href = "https://800.wo.cn/orderchannel/hd/Dy/order202005.html?fes=jh7&sou=12";
- return;
- }
- if (window.location.href.indexOf('jiangtao') >= 0) {
- alert(window.location.href);
- }
- var reg = new RegExp("(^|&)" + urlprm + "=([^&]*)(&|$)");
- var r = window.location.search.substr(1).match(reg);
- if (r != null) {
- return r[2];
- } else {
- switch (urlprm) {
- case "con":
- return "1";
- case "freeflow_token":
- return "";
- default:
- var url = getRootPath() + "/404.html";
- $(location).attr('href', url);
- }
- }
- }
- export function burypointLogId(operid, remark, url, productid) {
- var uuid = getCookie('uuid'); // uv
- var vvid = getCookie('vvid'); // vv
- if (uuid == null || uuid.trim() == '') {
- uuid = guid();
- setCookie('uuid', uuid, Date.remainMillis());
- }
- if (vvid == null || vvid.trim() == '') {
- vvid = guid();
- setCookie('vvid', vvid, -1);
- }
- if (operid == null || operid == '') {
- // 页面的埋点不通过/burypoint/logid接口实现,通过文件日志入库方式
- return;
- }
- var param = {
- operid: operid,
- uuid: uuid,
- vvid: vvid,
- fog: product.fog,
- userid: user.userid,
- fes: query.fes,
- sou: query.sou,
- url: encodeURIComponent(url || window.location.href),
- remark: encodeURIComponent(remark || '')
- }
- $.ajax({
- url: root + '/burypoint/logid',
- type: "POST",
- contentType: "application/json",
- data: JSON.stringify(param)
- }).then(function (responseText) {
- })
- }
- export function getCookie(name) {
- var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
- if (arr = document.cookie.match(reg))
- return unescape(arr[2]);
- else
- return null;
- }
- /**
- * 如果没有设置时间
- */
- export function setCookie(name, value, millis) {
- millis = (millis == undefined ? 0 : millis);
- var exp = new Date();
- if (millis < 0) {
- document.cookie = name + "=" + escape(value);
- } else {
- exp.setTime(exp.getTime() + millis);
- document.cookie = name + "=" + escape(value) + ";expires=" + exp.toGMTString();
- }
- }
- export function guid() {
- return 'xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
- var r = Math.random() * 16 | 0,
- v = c == 'x' ? r : (r & 0x3 | 0x8);
- return v.toString(16);
- });
- }
- /**
- * 查询微信支付结果
- */
- export function queryWxPay(tradeno, tradedate, userid) {
- var param = {
- "fes": query.fes,
- "sou": query.sou,
- "fog": product.fog,
- "tradeno": tradeno,
- "userid": userid || user.userid,
- "tradedate": tradedate, //例子:20190115
- }
- var def = $.Deferred();
- if (isEmpty(param.userid)) {
- def.reject('参数错误')
- return def;
- }
- if (isEmpty(param.tradeno)) {
- def.reject('参数错误')
- return def;
- }
- return $.ajax({
- url: root + '/backward/stackpkgquerypay',
- type: "POST",
- contentType: "application/json",
- data: JSON.stringify(param)
- })
- }
- export function getNowFormatDate(sperator) {
- if (sperator == null) {
- sperator = ''
- }
- var date = new Date();
- var year = date.getFullYear();
- var month = date.getMonth() + 1;
- var strDate = date.getDate();
- if (month >= 1 && month <= 9) {
- month = "0" + month;
- }
- if (strDate >= 0 && strDate <= 9) {
- strDate = "0" + strDate;
- }
- var currentdate = year + sperator + month + sperator + strDate;
- return currentdate;
- }
- /**
- * 目前已知的是Opera、火狐浏览器,使用iframe不会产生history记录
- */
- export function isChromeKernelBrowser() {
- var isBaidu = navigator.userAgent.indexOf("Baidu") > -1;
- if (isBaidu) return isBaidu;
- var isOpera = navigator.userAgent.indexOf("OPR") > -1;
- var isFirefox = navigator.userAgent.indexOf("Firefox") > -1; //判断是否 Firefox 浏览器
- var isUCBrowser = navigator.userAgent.indexOf("UCBrowser")
- if (!isOpera || !isFirefox || !isUCBrowser) {
- return false;
- }
- // 微信、百度App、谷歌浏览器
- var isMicroMessenger = navigator.userAgent.indexOf("MicroMessenger") > -1;
- var isSafari = navigator.userAgent.indexOf("Safari") > -1;
- var isChrome = navigator.userAgent.indexOf("Chrome") > -1;
- return isMicroMessenger || isBaidu || isSafari || isChrome;
- }
- function getMess(message, data) {
- const CryptoJS = require('./crypto-js');
- var keyHex = CryptoJS.enc.Utf8.parse(data);
- var encrypted = CryptoJS.DES.encrypt(message, keyHex, {
- mode: CryptoJS.mode.ECB,
- padding: CryptoJS.pad.Pkcs7
- });
- return encrypted.ciphertext.toString().toUpperCase();
- };
- function getPass() {
- var d = new Date();
- var year = d.getFullYear();
- var month = change(d.getMonth() + 1);
- var day = change(d.getDate());
- function change(t) {
- if (t < 10) {
- return "0" + t;
- } else {
- return t;
- }
- }
- var key = year + '' + month + '' + day;
- return key;
- }
|