1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440 |
- import * as compnt from "./compnt.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) {
- 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 {
- $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://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://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);
- }
- /**
- * 获取当前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;
- }
|