unicom.js 70 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453
  1. import * as compnt from "./compnt.js";
  2. import * as env from "./env.js"
  3. export var aes = getPass()
  4. export var query = {};
  5. export var product = {};
  6. export var products = {}; // 聚合页面有多个产品要订购
  7. export var fesname = {};
  8. export var user = {};
  9. export var root = null;
  10. export var productID = {};
  11. export var name_a = null;
  12. export var passwordsr = '';
  13. export function init() {
  14. window.root = getRootPath();
  15. parseQueryParms();
  16. $("#useraccount_tt").attr("value", getUrlParam("freeflow_token"));
  17. var param = {
  18. "fes": query.fes,
  19. "sou": query.sou,
  20. "orderId": query.orderId
  21. }
  22. var def = $.Deferred();
  23. $.ajax({
  24. url: root + "/ini/getstyle",
  25. type: "POST",
  26. contentType: "application/json",
  27. data: JSON.stringify(param),
  28. timeout: 10000
  29. }).then(function (responseText) {
  30. var response = JSON.parse(responseText);
  31. if (response.resultCode != "0000") {
  32. window.location.href = window.root + "/404.html";
  33. def.reject();
  34. return def;
  35. }
  36. product = response.product[0];
  37. for (i = 0; i < response.product.length; i++) {
  38. products[response.product[i].productid] = response.product[i]
  39. }
  40. $("#fog_" + product.url).attr("value", product.fog);
  41. var smslist = product.icon.split(",");
  42. for (var i = 0; i < smslist.length; i++) {
  43. if (i == 0) {
  44. $("#sendsms_order_" + product.url).attr("value", smslist[i]);
  45. }
  46. if (i == 1) {
  47. $("#sendsms_cancel_" + product.url).attr("value", smslist[i]);
  48. }
  49. if (i == 2) {
  50. $("#sendsms_yuyue_" + product.url).attr("value", smslist[i]);
  51. }
  52. }
  53. def.resolve(response);
  54. }, function (jqXHR, textStatus, errorThrown) {
  55. if (textStatus === "timeout") {
  56. window.location.href = getRootPath() + "/hot.html?cb=" + encodeURIComponent(window.location.href);
  57. }
  58. })
  59. return def;
  60. }
  61. /**
  62. * 抖音产品订购
  63. */
  64. export function orderDouyin(token, usermob) {
  65. var param = {
  66. "fog": getMemoValbyId(product, "fog"),
  67. "usermob": usermob,
  68. "useraccount": getMemoValbyId(product, "useraccount"),
  69. "fes": getUrlParam("fes"),
  70. "sou": getUrlParam("sou"),
  71. "token": token
  72. }
  73. return $.ajax({
  74. url: root + '/com/buyc',
  75. type: "POST",
  76. contentType: "application/json",
  77. data: JSON.stringify(param)
  78. });
  79. }
  80. export function setProduct(_product) {
  81. product = _product;
  82. }
  83. export function setFesname(_fesname) {
  84. fesname = _fesname;
  85. }
  86. /**
  87. * 订购
  88. */
  89. export function order(userid, token, usermob, ringid) {
  90. var param = {
  91. "fes": query.fes,
  92. "sou": query.sou,
  93. "fog": product.fog,
  94. "token": token,
  95. "userid": userid || user.userid,
  96. "usermob": usermob || user.usermob,
  97. "useraccount": "",
  98. "f": query.F,
  99. "ringid": ringid || query.ringid
  100. }
  101. return $.ajax({
  102. url: root + '/comm/order',
  103. type: "POST",
  104. contentType: "application/json",
  105. data: JSON.stringify(param)
  106. });
  107. }
  108. /**
  109. * 手厅免登陆订购
  110. */
  111. export function usermob(userid, usermob, ringid) {
  112. var param = {
  113. "fes": query.fes,
  114. "sou": query.sou,
  115. "fog": product.fog,
  116. "userid": userid || user.userid,
  117. "usermob": usermob || user.usermob,
  118. "useraccount": "",
  119. "f": query.F,
  120. "ringid": ringid || query.ringid
  121. }
  122. return $.ajax({
  123. url: root + '/unicom/order',
  124. type: "POST",
  125. contentType: "application/json",
  126. data: JSON.stringify(param)
  127. })
  128. }
  129. /**
  130. * 阿里订购
  131. */
  132. export function alorder(userid, token, usermob, ringid, alichannel) {
  133. var param = {
  134. "fes": query.fes,
  135. "sou": query.sou,
  136. "fog": product.fog,
  137. "token": token,
  138. "userid": userid || user.userid,
  139. "usermob": usermob || user.usermob,
  140. "useraccount": "",
  141. "f": query.F,
  142. "ringid": ringid || query.ringid,
  143. "alichannel": alichannel
  144. }
  145. return $.ajax({
  146. url: root + '/comm/order',
  147. type: "POST",
  148. contentType: "application/json",
  149. data: JSON.stringify(param)
  150. });
  151. }
  152. /**
  153. * 阿里退订
  154. */
  155. export function alcancel(userid, usermob, canceltype, cancelmsg, alichannel) {
  156. passwordsr = getMess(user.usermob, aes);
  157. var param = {
  158. "fes": query.fes,
  159. "sou": query.sou,
  160. "fog": product.fog,
  161. "userid": userid || user.userid,
  162. "usermob": usermob || passwordsr,
  163. "canceltype": encodeURIComponent(canceltype),
  164. "cancelmsg": encodeURIComponent(cancelmsg),
  165. "useraccount": "",
  166. }
  167. if (alichannel != null && alichannel != "") {
  168. param.alichannel = alichannel;
  169. }
  170. return $.ajax({
  171. url: root + '/comm/cancel',
  172. type: "POST",
  173. contentType: "application/json",
  174. data: JSON.stringify(param)
  175. });
  176. }
  177. /**
  178. * 退订
  179. */
  180. export function cancel(userid, usermob, canceltype, cancelmsg) {
  181. passwordsr = getMess(user.usermob, aes);
  182. var param = {
  183. "fes": query.fes,
  184. "sou": query.sou,
  185. "fog": product.fog,
  186. "userid": userid || user.userid,
  187. "usermob": usermob || passwordsr,
  188. "canceltype": encodeURIComponent(canceltype),
  189. "cancelmsg": encodeURIComponent(cancelmsg),
  190. "useraccount": ""
  191. }
  192. return $.ajax({
  193. url: root + '/comm/cancel',
  194. type: "POST",
  195. contentType: "application/json",
  196. data: JSON.stringify(param)
  197. });
  198. }
  199. /**
  200. * 多选一产品订购
  201. */
  202. export function choiceOrder(userid, token, usermob) {
  203. var param = {
  204. "fes": query.fes,
  205. "sou": query.sou,
  206. "fog": product.fog,
  207. "token": token,
  208. "userid": userid || user.userid,
  209. "usermob": usermob || user.usermob,
  210. "useraccount": ""
  211. }
  212. return $.ajax({
  213. url: root + '/choiceorder/order',
  214. type: "POST",
  215. contentType: "application/json",
  216. data: JSON.stringify(param)
  217. });
  218. }
  219. /**
  220. * 多选一产品退订
  221. */
  222. export function choiceCancel(userid, usermob, canceltype, cancelmsg) {
  223. passwordsr = getMess(user.usermob, aes);
  224. var param = {
  225. "fes": query.fes,
  226. "sou": query.sou,
  227. "fog": product.fog,
  228. "userid": userid || user.userid,
  229. "usermob": usermob || passwordsr,
  230. "canceltype": encodeURIComponent(canceltype),
  231. "cancelmsg": encodeURIComponent(cancelmsg),
  232. "useraccount": ""
  233. }
  234. return $.ajax({
  235. url: root + '/choiceorder/cancel',
  236. type: "POST",
  237. contentType: "application/json",
  238. data: JSON.stringify(param)
  239. });
  240. }
  241. /**
  242. * 查询流量消耗
  243. */
  244. export function queryFlow(userid, usermob) {
  245. var param = {
  246. "fes": query.fes,
  247. "sou": query.sou,
  248. "fog": product.fog,
  249. "userid": userid || user.userid,
  250. "usermob": usermob || user.usermob,
  251. }
  252. return $.ajax({
  253. url: root + '/flow/query',
  254. type: "POST",
  255. contentType: "application/json",
  256. data: JSON.stringify(param)
  257. });
  258. }
  259. /**
  260. * 查询订购关系
  261. */
  262. export function queryOrder(userid, usermob) {
  263. var param = {
  264. "fes": query.fes,
  265. "sou": query.sou,
  266. "fog": product.fog,
  267. "userid": userid || user.userid,
  268. "usermob": usermob || user.usermob
  269. }
  270. return $.ajax({
  271. url: root + '/comm/queryorder',
  272. type: "POST",
  273. contentType: "application/json",
  274. data: JSON.stringify(param)
  275. });
  276. }
  277. /**
  278. * 手厅百度查询订购关系
  279. */
  280. export function queryOrders(userid, usermob) {
  281. var param = {
  282. "fes": query.fes,
  283. "sou": query.sou,
  284. "fog": product.fog,
  285. "userid": userid || user.userid,
  286. "usermob": usermob || user.usermob
  287. }
  288. return $.ajax({
  289. url: root + '/unicom/queryorder',
  290. type: "POST",
  291. contentType: "application/json",
  292. data: JSON.stringify(param)
  293. });
  294. }
  295. //手厅免登陆
  296. export function register(ticket) {
  297. var param = {
  298. "fes": query.fes,
  299. "sou": query.sou,
  300. "fog": product.fog,
  301. 'ticket': ticket
  302. }
  303. var def = $.Deferred();
  304. $.ajax({
  305. url: root + "/unicom/check",
  306. type: "POST",
  307. contentType: "application/json",
  308. data: JSON.stringify(param)
  309. }).then(function (response) {
  310. def.resolve(response);
  311. // switch (response.resultCode) {
  312. // case "0000":
  313. // def.resolve(response);
  314. // break;
  315. // case "1066":
  316. // def.resolve(response);
  317. // break;
  318. // default:
  319. // def.reject(response);
  320. // break;
  321. // }
  322. }).fail(function (error) {
  323. def.reject('服务调用异常')
  324. })
  325. return def;
  326. };
  327. export function queryStock(stockcode) {
  328. var param = {
  329. "fes": query.fes,
  330. "sou": query.sou,
  331. "fog": product.fog,
  332. "stockcode": stockcode
  333. }
  334. return $.ajax({
  335. url: root + '/backward/queryStock',
  336. type: "POST",
  337. contentType: "application/json",
  338. data: JSON.stringify(param)
  339. });
  340. }
  341. /**
  342. * 后向产品订购
  343. */
  344. export function orderBack(stockcode, cpid) {
  345. var param = {
  346. "fes": query.fes,
  347. "sou": query.sou,
  348. "fog": product.fog,
  349. "userid": user.userid,
  350. "productType": query.productType,
  351. "payMethod": query.payMethod,
  352. "ringid": query.ringid,
  353. "returnUrl": window.location.href + "&productType=" + query.productType + "&payMethod=" + query.payMethod
  354. }
  355. if (!!stockcode && stockcode != '') {
  356. param.stockcode = stockcode;
  357. }
  358. return $.ajax({
  359. url: root + '/backward/order',
  360. type: "POST",
  361. contentType: "application/json",
  362. data: JSON.stringify(param)
  363. });
  364. }
  365. /**
  366. * 后向退订
  367. */
  368. export function cancelBack(stockcode, cpid, canceltype, cancelmsg) {
  369. var param = {
  370. "fes": query.fes,
  371. "sou": query.sou,
  372. "fog": product.fog,
  373. "userid": user.userid,
  374. "canceltype": encodeURIComponent(canceltype),
  375. "cancelmsg": encodeURIComponent(cancelmsg),
  376. }
  377. return $.ajax({
  378. url: root + '/backward/cancel',
  379. type: "POST",
  380. contentType: "application/json",
  381. data: JSON.stringify(param)
  382. });
  383. }
  384. /**
  385. * 南研支付结果查询
  386. */
  387. export function queryPay(orderId) {
  388. var param = {
  389. "fes": query.fes,
  390. "sou": query.sou,
  391. "fog": product.fog,
  392. "userid": user.userid,
  393. "orderId": orderId
  394. }
  395. return $.ajax({
  396. url: root + '/backward/queryPay',
  397. type: "POST",
  398. contentType: "application/json",
  399. data: JSON.stringify(param)
  400. });
  401. }
  402. export function setting(ringid, userid) {
  403. var param = {
  404. "fes": query.fes,
  405. "sou": query.sou,
  406. "fog": product.fog,
  407. "userid": userid || user.userid,
  408. "ringid": ringid
  409. }
  410. return $.ajax({
  411. url: root + '/rbtmv/setting',
  412. type: "POST",
  413. contentType: "application/json",
  414. data: JSON.stringify(param)
  415. });
  416. }
  417. /**
  418. * 南研支付订购
  419. */
  420. export function nanyanPayOrder(signing) {
  421. var param = {
  422. "fes": query.fes,
  423. "sou": query.sou,
  424. "fog": product.fog,
  425. "userid": user.userid,
  426. "signing": signing
  427. }
  428. return $.ajax({
  429. url: root + '/backward/nanyansign',
  430. type: "POST",
  431. contentType: "application/json",
  432. data: JSON.stringify(param)
  433. });
  434. }
  435. /**
  436. * 南研支付解除签约
  437. */
  438. export function nanyanUnsign() {
  439. var param = {
  440. "fes": query.fes,
  441. "sou": query.sou,
  442. "fog": product.fog,
  443. "userid": user.userid
  444. }
  445. return $.ajax({
  446. url: root + '/backward/nanyanunsign',
  447. type: "POST",
  448. contentType: "application/json",
  449. data: JSON.stringify(param)
  450. });
  451. }
  452. /**
  453. * 后向产品退款
  454. */
  455. export function refund(stockcode, username, password) {
  456. var param = {
  457. "fes": query.fes,
  458. "sou": query.sou,
  459. "fog": product.fog,
  460. "stockcode": stockcode,
  461. "captchaCode": product.captchaCode,
  462. "username": username,
  463. "password": password
  464. }
  465. return $.ajax({
  466. url: root + '/backward/refund',
  467. type: "POST",
  468. contentType: "application/json",
  469. data: JSON.stringify(param)
  470. });
  471. }
  472. /**
  473. * 检查用户是否可以订购
  474. */
  475. export function can(uid) {
  476. if (!uid) {
  477. var def = $.Deferred();
  478. def.reject();
  479. return def;
  480. }
  481. var param = {
  482. "fes": query.fes,
  483. "sou": query.sou,
  484. "fog": product.fog,
  485. "uid": uid || ""
  486. }
  487. return $.ajax({
  488. url: root + '/member/can',
  489. type: "POST",
  490. contentType: "application/json",
  491. data: JSON.stringify(param)
  492. });
  493. }
  494. /*
  495. * 领取会员
  496. */
  497. export function drawMember(uid, screen_name, userid, usermob) {
  498. if (uid == null || uid.trim() == "") {
  499. compnt.showAlert('获取微博账号信息失败')
  500. var def = $.Deferred();
  501. def.reject();
  502. return def;
  503. }
  504. var param = {
  505. "fes": query.fes,
  506. "sou": query.sou,
  507. "fog": product.fog,
  508. "userid": userid || user.userid,
  509. "usermob": usermob || user.usermob,
  510. "uid": uid,
  511. "screen_name": encodeURIComponent(screen_name) || ""
  512. }
  513. return $.ajax({
  514. url: root + '/member/draw',
  515. type: "POST",
  516. contentType: "application/json",
  517. data: JSON.stringify(param)
  518. });
  519. }
  520. /**
  521. * 查询会员领取状态
  522. */
  523. export function queryMember(userid, usermob, uid) {
  524. var param = {
  525. "fes": query.fes,
  526. "sou": query.sou,
  527. "fog": product.fog,
  528. "userid": userid || user.userid,
  529. "usermob": usermob || user.usermob,
  530. "uid": uid || ''
  531. }
  532. if (isEmpty(param.userid) && isEmpty(param.uid)) {
  533. var def = $.Deferred();
  534. def.reject('参数错误')
  535. return def;
  536. }
  537. return $.ajax({
  538. url: root + '/member/query',
  539. type: "POST",
  540. contentType: "application/json",
  541. data: JSON.stringify(param)
  542. });
  543. }
  544. /*
  545. * 领取会员
  546. */
  547. export function drawCoin(uid, screen_name, userid, usermob) {
  548. if (uid == null || uid.trim() == "") {
  549. compnt.showAlert('获取账号信息失败')
  550. var def = $.Deferred();
  551. def.reject();
  552. return def;
  553. }
  554. var param = {
  555. "fes": query.fes,
  556. "sou": query.sou,
  557. "fog": product.fog,
  558. "userid": userid || user.userid,
  559. "usermob": usermob || user.usermob,
  560. "uid": uid,
  561. "screen_name": screen_name || ""
  562. }
  563. return $.ajax({
  564. url: root + '/coin/draw',
  565. type: "POST",
  566. contentType: "application/json",
  567. data: JSON.stringify(param)
  568. });
  569. }
  570. /**
  571. * 查询会员领取状态
  572. */
  573. export function queryCoin(userid, usermob, uid) {
  574. var param = {
  575. "fes": query.fes,
  576. "sou": query.sou,
  577. "fog": product.fog,
  578. "userid": userid || user.userid,
  579. "usermob": usermob || user.usermob,
  580. "uid": uid || ''
  581. }
  582. if (isEmpty(param.userid) && isEmpty(param.uid)) {
  583. var def = $.Deferred();
  584. def.reject('参数错误')
  585. return def;
  586. }
  587. return $.ajax({
  588. url: root + '/coin/query',
  589. type: "POST",
  590. contentType: "application/json",
  591. data: JSON.stringify(param)
  592. });
  593. }
  594. /**
  595. * 检查用户是否可以订购
  596. */
  597. export function canDrawCoin(uid) {
  598. if (!uid) {
  599. var def = $.Deferred();
  600. def.reject();
  601. return def;
  602. }
  603. var param = {
  604. "fes": query.fes,
  605. "sou": query.sou,
  606. "fog": product.fog,
  607. "uid": uid || ""
  608. }
  609. return $.ajax({
  610. url: root + '/coin/can',
  611. type: "POST",
  612. contentType: "application/json",
  613. data: JSON.stringify(param)
  614. });
  615. }
  616. /**
  617. * 大转盘抽奖
  618. */
  619. export function lottery(usermob, productid) {
  620. var param = {
  621. "userid": usermob,
  622. "productid": productid,
  623. 'fog': product.fog
  624. }
  625. return $.ajax({
  626. url: root + '/lottery/draw',
  627. type: "POST",
  628. contentType: "application/json",
  629. data: JSON.stringify(param)
  630. });
  631. }
  632. /**
  633. * 查询中奖记录
  634. */
  635. export function lotterys(usermob, productid, fog) {
  636. var param = {
  637. "userid": usermob,
  638. "productid": productid,
  639. 'fog': fog
  640. }
  641. return $.ajax({
  642. url: root + '/lottery/query',
  643. type: "POST",
  644. contentType: "application/json",
  645. data: JSON.stringify(param)
  646. });
  647. }
  648. /**
  649. * 视频彩铃播放地址,50个
  650. */
  651. export function findRbtMvs(productid) {
  652. var param = {
  653. "productid": productid,
  654. "fog": product.fog
  655. }
  656. return $.ajax({
  657. url: root + '/rbtmv/findRbtMvs',
  658. type: "POST",
  659. contentType: "application/json",
  660. data: JSON.stringify(param)
  661. });
  662. }
  663. function isEmpty(str) {
  664. if (str == null || str == '') {
  665. return true;
  666. }
  667. return false;
  668. }
  669. /**
  670. * 发送短信验证码
  671. * @param {}} $container
  672. */
  673. export function sendSms($container, smstype, currentProduct) {
  674. var def = $.Deferred();
  675. if ($container.attr('n') != null && $container.attr('n') > 0) {
  676. return;
  677. }
  678. var usermob = $container.find('.usermob').val();
  679. if (usermob == null || usermob.trim() == "") {
  680. compnt.showAlert('请输入联通手机号码');
  681. def.reject();
  682. return def;
  683. }
  684. if (!usermob.startsWith("1") || usermob.length != 11) {
  685. compnt.showAlert('手机号码格式不正确');
  686. def.reject();
  687. return def;
  688. }
  689. user.usermob = usermob
  690. passwordsr = getMess(usermob, aes);
  691. var param = {
  692. "fes": query.fes,
  693. "sou": query.sou,
  694. "fog": product.fog,
  695. "usermob": passwordsr,
  696. "smstype": smstype
  697. }
  698. var count = 60;
  699. $container.attr('n', count);
  700. $.ajax({
  701. url: root + '/sms/send',
  702. type: "POST",
  703. contentType: "application/json",
  704. data: JSON.stringify(param)
  705. }).then(function (response) {
  706. if (response.resultCode != "0000") {
  707. count = 0;
  708. $container.attr('n', count);
  709. compnt.showAlert(response.errorInfo);
  710. return;
  711. }
  712. var $sendcode = $container.find('.sendcode')
  713. var template = '{}s'
  714. if ($sendcode.is('input')) {
  715. $sendcode.val(template.replace('{}', count));
  716. } else {
  717. $sendcode.text(template.replace('{}', count));
  718. }
  719. $sendcode.addClass('sendcode-wait');
  720. var timer = setInterval(function () {
  721. count -= 1;
  722. $container.attr('n', count);
  723. if ($sendcode.is('input')) {
  724. $sendcode.val(template.replace('{}', count));
  725. } else {
  726. $sendcode.text(template.replace('{}', count));
  727. }
  728. if (count === 0) {
  729. clearInterval(timer);
  730. if ($sendcode.is('input')) {
  731. $sendcode.val('获取验证码');
  732. } else {
  733. $sendcode.text('获取验证码');
  734. }
  735. $container.attr('n', count);
  736. $sendcode.removeClass('sendcode-wait');
  737. }
  738. }, 1000);
  739. try {
  740. window.HtmlPageVisitor && window.HtmlPageVisitor.setMp(user.usermob);
  741. } catch (e) { }
  742. })
  743. }
  744. /**
  745. * 检验短信验证码,并且返回手机号伪代码,有效期10分钟
  746. * @param {*} usermob
  747. * @param {*} smscode
  748. */
  749. export function checkCode($container, keepUserInfo) {
  750. var def = $.Deferred();
  751. var usermob = $container.find('.usermob').val();
  752. var smscode = $container.find('.smscode').val();
  753. if (keepUserInfo == null) keepUserInfo = false;
  754. if (usermob == null || usermob.trim() == "") {
  755. compnt.showAlert('请输入联通手机号码');
  756. def.reject()
  757. return def;
  758. }
  759. if (smscode == null || smscode.trim() == "") {
  760. compnt.showAlert('请输入验证码');
  761. def.reject()
  762. return def;
  763. }
  764. if (smscode.length != 6) {
  765. compnt.showAlert('短信验证码不正确');
  766. def.reject()
  767. return def;
  768. }
  769. passwordsr = getMess(usermob, aes);
  770. var param = {
  771. "fes": query.fes,
  772. "sou": query.sou,
  773. "fog": product.fog,
  774. "code": smscode,
  775. "usermob": passwordsr,
  776. }
  777. $.ajax({
  778. url: root + '/checkvercode',
  779. type: "POST",
  780. contentType: "application/json",
  781. data: JSON.stringify(param)
  782. }).then(function (response) {
  783. $container.find('.smscode').val('')
  784. switch (response.resultCode) {
  785. case "0000":
  786. user.userid = response.userid;
  787. user.usermob = usermob;
  788. user.usertime = new Date().getTime();
  789. if (!keepUserInfo) {
  790. $container.find('.usermob').val('')
  791. $container.find('.usermob').val('')
  792. }
  793. def.resolve(response.userid);
  794. break;
  795. default:
  796. compnt.showAlert(response.errorInfo)
  797. def.reject(response);
  798. break;
  799. }
  800. }).fail(function (error) {
  801. def.reject('服务调用异常')
  802. })
  803. return def;
  804. }
  805. /**
  806. * 检验短信验证码,并且返回手机号伪代码,有效期10分钟
  807. * @param {*} usermob
  808. * @param {*} smscode
  809. */
  810. export function checkCodes($container, keepUserInfo) {
  811. var def = $.Deferred();
  812. var usermob = $container.find('.usermob').val();
  813. var smscode = $container.find('.smscode').val();
  814. if (keepUserInfo == null) keepUserInfo = false;
  815. if (usermob == null || usermob.trim() == "") {
  816. compnt.showAlert('请输入联通手机号码');
  817. def.reject()
  818. return def;
  819. }
  820. if (smscode == null || smscode.trim() == "") {
  821. compnt.showAlert('请输入验证码');
  822. def.reject()
  823. return def;
  824. }
  825. if (smscode.length != 6) {
  826. compnt.showAlert('短信验证码不正确');
  827. def.reject()
  828. return def;
  829. }
  830. passwordsr = getMess(usermob, aes);
  831. var param = {
  832. "fes": query.fes,
  833. "sou": query.sou,
  834. "fog": product.fog,
  835. "code": smscode,
  836. "usermob": passwordsr,
  837. }
  838. $.ajax({
  839. url: root + '/checkvercode',
  840. type: "POST",
  841. contentType: "application/json",
  842. data: JSON.stringify(param)
  843. }).then(function (response) {
  844. // $container.find('.smscode').val('')
  845. switch (response.resultCode) {
  846. case "0000":
  847. user.userid = response.userid;
  848. user.usermob = usermob;
  849. user.usertime = new Date().getTime();
  850. if (!keepUserInfo) {
  851. // $container.find('.usermob').val('')
  852. // $container.find('.usermob').val('')
  853. }
  854. def.resolve(response.userid);
  855. break;
  856. default:
  857. compnt.showAlert(response.errorInfo)
  858. def.reject(response);
  859. break;
  860. }
  861. }).fail(function (error) {
  862. def.reject('服务调用异常')
  863. })
  864. return def;
  865. }
  866. export function oneClickLogin(code) {
  867. if (code == null || code == "") {
  868. return;
  869. }
  870. var param = {
  871. "fes": query.fes,
  872. "sou": query.sou,
  873. "fog": product.fog,
  874. "code": code
  875. }
  876. var def = $.Deferred();
  877. $.ajax({
  878. url: root + '/onekeylogin',
  879. type: "POST",
  880. contentType: "application/json",
  881. data: JSON.stringify(param)
  882. }).then(function (response) {
  883. switch (response.resultCode) {
  884. case "0000":
  885. user.userid = response.userid;
  886. user.usermob = response.usermob;
  887. user.usertime = new Date().getTime();
  888. def.resolve(response.userid);
  889. break;
  890. default:
  891. compnt.showAlert(response.errorInfo)
  892. def.reject(response);
  893. break;
  894. }
  895. }).fail(function (error) {
  896. def.reject('服务调用异常')
  897. })
  898. return def;
  899. }
  900. /**
  901. * 发送短信验证码
  902. * @param {}} $container
  903. */
  904. export function sendSmsarr($container, smstype, currentProduct) {
  905. var def = $.Deferred();
  906. if ($container.attr('n') != null && $container.attr('n') > 0) {
  907. return;
  908. }
  909. var usermob = $container.find('.usermob').val();
  910. if (usermob == null || usermob.trim() == "") {
  911. compnt.showAlertarxe('请输入联通手机号码');
  912. def.reject();
  913. return def;
  914. }
  915. if (!usermob.startsWith("1") || usermob.length != 11) {
  916. compnt.showAlertarxe('手机号码格式不正确');
  917. def.reject();
  918. return def;
  919. }
  920. user.usermob = usermob
  921. passwordsr = getMess(usermob, aes);
  922. var param = {
  923. "fes": query.fes,
  924. "sou": query.sou,
  925. "fog": product.fog,
  926. "usermob": passwordsr,
  927. "smstype": smstype
  928. }
  929. var count = 60;
  930. $container.attr('n', count);
  931. $.ajax({
  932. url: root + '/sms/send',
  933. type: "POST",
  934. contentType: "application/json",
  935. data: JSON.stringify(param)
  936. }).then(function (response) {
  937. if (data.status == 302) {
  938. location.href = data.location;
  939. }
  940. if (response.resultCode != "0000") {
  941. count = 0;
  942. $container.attr('n', count);
  943. compnt.showAlertarxe(response.errorInfo);
  944. return;
  945. }
  946. var $sendcode = $container.find('.sendcode')
  947. var template = '{}s'
  948. if ($sendcode.is('input')) {
  949. $sendcode.val(template.replace('{}', count));
  950. } else {
  951. $sendcode.text(template.replace('{}', count));
  952. }
  953. $sendcode.addClass('sendcode-wait');
  954. var timer = setInterval(function () {
  955. count -= 1;
  956. $container.attr('n', count);
  957. if ($sendcode.is('input')) {
  958. $sendcode.val(template.replace('{}', count));
  959. } else {
  960. $sendcode.text(template.replace('{}', count));
  961. }
  962. if (count === 0) {
  963. clearInterval(timer);
  964. if ($sendcode.is('input')) {
  965. $sendcode.val('获取验证码');
  966. } else {
  967. $sendcode.text('获取验证码');
  968. }
  969. $container.attr('n', count);
  970. $sendcode.removeClass('sendcode-wait');
  971. }
  972. }, 1000);
  973. try {
  974. window.HtmlPageVisitor && window.HtmlPageVisitor.setMp(user.usermob);
  975. } catch (e) { }
  976. })
  977. }
  978. /**
  979. * 检验短信验证码,并且返回手机号伪代码,有效期10分钟
  980. * @param {*} usermob
  981. * @param {*} smscode
  982. */
  983. export function checkCodearr($container, keepUserInfo) {
  984. var def = $.Deferred();
  985. var usermob = $container.find('.usermob').val();
  986. var smscode = $container.find('.smscode').val();
  987. if (keepUserInfo == null) keepUserInfo = false;
  988. if (usermob == null || usermob.trim() == "") {
  989. compnt.showAlertarxe('请输入联通手机号码');
  990. def.reject()
  991. return def;
  992. }
  993. if (smscode == null || smscode.trim() == "") {
  994. compnt.showAlertarxe('请输入验证码');
  995. def.reject()
  996. return def;
  997. }
  998. if (smscode.length != 6) {
  999. compnt.showAlertarxe('短信验证码不正确');
  1000. def.reject()
  1001. return def;
  1002. }
  1003. passwordsr = getMess(usermob, aes);
  1004. var param = {
  1005. "fes": query.fes,
  1006. "sou": query.sou,
  1007. "fog": product.fog,
  1008. "code": smscode,
  1009. "usermob": passwordsr,
  1010. }
  1011. $.ajax({
  1012. url: root + '/checkvercode',
  1013. type: "POST",
  1014. contentType: "application/json",
  1015. data: JSON.stringify(param)
  1016. }).then(function (response) {
  1017. $container.find('.smscode').val('')
  1018. switch (response.resultCode) {
  1019. case "0000":
  1020. user.userid = response.userid;
  1021. user.usermob = usermob;
  1022. user.usertime = new Date().getTime();
  1023. if (!keepUserInfo) {
  1024. $container.find('.usermob').val('')
  1025. $container.find('.usermob').val('')
  1026. }
  1027. def.resolve(response.userid);
  1028. break;
  1029. default:
  1030. compnt.showAlertarxe(response.errorInfo)
  1031. def.reject(response);
  1032. break;
  1033. }
  1034. }).fail(function (error) {
  1035. def.reject('服务调用异常')
  1036. })
  1037. return def;
  1038. }
  1039. /**
  1040. * 通过code参数,调用微博开放平台的接口查询用户信息
  1041. */
  1042. export function queryWeiboUserInfo() {
  1043. var param = {
  1044. "code": query.code,
  1045. "redirect_uri": "http://100.0.3.69:3344/orderchannel/sina/wb/weibo1.html"
  1046. }
  1047. var def = $.Deferred();
  1048. $.ajax({
  1049. url: root + "/weibo/query",
  1050. type: "POST",
  1051. contentType: "application/json",
  1052. data: JSON.stringify(param)
  1053. }).then(function (response) {
  1054. switch (response.resultCode) {
  1055. case "0000":
  1056. def.resolve(response);
  1057. break;
  1058. default:
  1059. compnt.showAlert(response.errorInfo)
  1060. def.reject(response);
  1061. break;
  1062. }
  1063. }).fail(function (error) {
  1064. def.reject('服务调用异常')
  1065. })
  1066. return def;
  1067. };
  1068. /*
  1069. 领取权益接口
  1070. */
  1071. export function deaw(userid, token, usermob, spid, productname) {
  1072. var param = {
  1073. "userid": usermob,
  1074. "vipcode": token,
  1075. "vipuser": userid,
  1076. 'fog': product.fog,
  1077. 'spid': spid || '',
  1078. 'productname': productname || ''
  1079. }
  1080. if (spid != null && spid != "") {
  1081. param.spid = spid;
  1082. }
  1083. var def = $.Deferred();
  1084. $.ajax({
  1085. url: root + "/rights/draw",
  1086. type: "POST",
  1087. contentType: "application/json",
  1088. data: JSON.stringify(param)
  1089. }).then(function (response) {
  1090. switch (response.resultCode) {
  1091. case "0000":
  1092. def.resolve(response);
  1093. break;
  1094. case "1102":
  1095. def.resolve(response);
  1096. break;
  1097. case "1105":
  1098. def.resolve(response);
  1099. break;
  1100. case "1015":
  1101. def.resolve(response);
  1102. break;
  1103. default:
  1104. compnt.showAlert(response.errorInfo)
  1105. def.reject(response);
  1106. break;
  1107. }
  1108. }).fail(function (error) {
  1109. def.reject('服务调用异常')
  1110. })
  1111. return def;
  1112. };
  1113. /*
  1114. 领取百度权益接口
  1115. */
  1116. export function deaws(userid, token, usermob, spid, productname, productid) {
  1117. var param = {
  1118. "userid": usermob,
  1119. "vipcode": token,
  1120. "vipuser": userid,
  1121. 'fog': product.fog,
  1122. 'spid': spid || '',
  1123. 'productname': productname || ''
  1124. }
  1125. if (spid != null && spid != "") {
  1126. param.spid = spid;
  1127. }
  1128. if (productid != null && productid != "") {
  1129. param.productid = productid;
  1130. }
  1131. var def = $.Deferred();
  1132. $.ajax({
  1133. url: root + "/rights/draw",
  1134. type: "POST",
  1135. contentType: "application/json",
  1136. data: JSON.stringify(param)
  1137. }).then(function (response) {
  1138. switch (response.resultCode) {
  1139. case "0000":
  1140. def.resolve(response);
  1141. break;
  1142. case "1102":
  1143. def.resolve(response);
  1144. break;
  1145. case "1105":
  1146. def.resolve(response);
  1147. break;
  1148. case "1015":
  1149. def.resolve(response);
  1150. break;
  1151. default:
  1152. compnt.showAlertarxe(response.errorInfo)
  1153. def.reject(response);
  1154. break;
  1155. }
  1156. }).fail(function (error) {
  1157. def.reject('服务调用异常')
  1158. })
  1159. return def;
  1160. };
  1161. /*
  1162. 查询开通记录与状态
  1163. */
  1164. export function queryWeiboUserInfoaks(usermob, spid) {
  1165. // var productid = 2020010201
  1166. var param = {
  1167. "userid": usermob,
  1168. 'fog': product.fog,
  1169. }
  1170. if (spid != null && spid != "") {
  1171. param.spid = spid;
  1172. }
  1173. var def = $.Deferred();
  1174. $.ajax({
  1175. url: root + "/rights/query",
  1176. type: "POST",
  1177. contentType: "application/json",
  1178. data: JSON.stringify(param)
  1179. }).then(function (response) {
  1180. if (response.productid == '2020090401') {
  1181. name_a = '定向流量权益包(后向)';
  1182. } else if (response.productid == '2021091709') {
  1183. name_a = '定向流量权益包(联通次月生效)';
  1184. } else if (response.productid == '2020111201') {
  1185. name_a = '定向流量权益包(次月生效)';
  1186. } else if (response.productid == '2021091702') {
  1187. name_a = '定向流量权益包(联通)';
  1188. }
  1189. // switch (response.resultCode) {
  1190. // case "0000":
  1191. // def.resolve(response);
  1192. // break;
  1193. // case "1066":
  1194. // def.resolve(response);
  1195. // break;
  1196. // default:
  1197. // def.reject(response);
  1198. // break;
  1199. // }
  1200. }).fail(function (error) {
  1201. def.reject('服务调用异常')
  1202. })
  1203. return def;
  1204. };
  1205. //查询百度产品状态
  1206. export function queryWeiboUserInfoaksra(usermob) {
  1207. // var productid = 2020010201
  1208. var param = {
  1209. "userid": usermob,
  1210. 'fog': product.fog,
  1211. 'vipcode': '90001'
  1212. }
  1213. // if (spid != null && spid != "") {
  1214. // param.spid = spid;
  1215. // }
  1216. var def = $.Deferred();
  1217. $.ajax({
  1218. url: root + "/rights/querys",
  1219. type: "POST",
  1220. contentType: "application/json",
  1221. data: JSON.stringify(param)
  1222. }).then(function (response) {
  1223. switch (response.resultCode) {
  1224. case "0000":
  1225. def.resolve(response);
  1226. break;
  1227. case "1066":
  1228. def.resolve(response);
  1229. break;
  1230. default:
  1231. def.reject(response);
  1232. break;
  1233. }
  1234. }).fail(function (error) {
  1235. def.reject('服务调用异常')
  1236. })
  1237. return def;
  1238. };
  1239. /*
  1240. 查询开通记录与状态三个月接口
  1241. */
  1242. export function queryWeiboUserInfoak(usermob) {
  1243. // var productid = 2020010201
  1244. var param = {
  1245. "userid": usermob,
  1246. 'fog': product.fog,
  1247. 'vipcode': '10001'
  1248. }
  1249. // if (spid != null && spid != "") {
  1250. // param.spid = spid;
  1251. // }
  1252. var def = $.Deferred();
  1253. $.ajax({
  1254. url: root + "/rights/querys",
  1255. type: "POST",
  1256. contentType: "application/json",
  1257. data: JSON.stringify(param)
  1258. }).then(function (response) {
  1259. // console.log(response.data.length)
  1260. switch (response.resultCode) {
  1261. case "0000":
  1262. def.resolve(response);
  1263. break;
  1264. case "1066":
  1265. def.resolve(response);
  1266. break;
  1267. default:
  1268. def.reject(response);
  1269. break;
  1270. }
  1271. }).fail(function (error) {
  1272. def.reject('服务调用异常')
  1273. })
  1274. return def;
  1275. };
  1276. /*
  1277. 文明办领取接口*/
  1278. export function wmbdraw(usermob) {
  1279. var param = {
  1280. "usermob": usermob,
  1281. 'fog': product.fog,
  1282. "sou": query.sou,
  1283. 'fes': query.fes
  1284. }
  1285. var def = $.Deferred();
  1286. $.ajax({
  1287. url: root + "/civilize/order",
  1288. type: "POST",
  1289. contentType: "application/json",
  1290. data: JSON.stringify(param)
  1291. }).then(function (response) {
  1292. switch (response.resultCode) {
  1293. case "0000":
  1294. def.resolve(response);
  1295. break;
  1296. case "1023":
  1297. def.resolve(response);
  1298. break;
  1299. // case "1105":
  1300. // def.resolve(response);
  1301. // break;
  1302. // case "1061":
  1303. // def.resolve(response);
  1304. // break;
  1305. // case "8601":
  1306. // def.resolve(response);
  1307. // break;
  1308. default:
  1309. $('.overlayssr').css('display', 'none');
  1310. $('body').css('overflow', 'auto');
  1311. compnt.showAlerts(response.errorInfo)
  1312. def.reject(response);
  1313. break;
  1314. }
  1315. }).fail(function (error) {
  1316. def.reject('服务调用异常')
  1317. })
  1318. return def;
  1319. };
  1320. /*
  1321. 后向电商页面7元8g产品,白名单用户订购*/
  1322. export function allowdeaw(ticket, orderchannel, usermob) {
  1323. var param = {
  1324. "ticket": ticket,
  1325. "orderchannel": query.sou,
  1326. 'fog': product.fog,
  1327. }
  1328. // console.log(userid, product.fog, query.sou)
  1329. var def = $.Deferred();
  1330. $.ajax({
  1331. url: root + "/allowlistdarw/order",
  1332. type: "POST",
  1333. contentType: "application/json",
  1334. data: JSON.stringify(param)
  1335. }).then(function (response) {
  1336. switch (response.resultCode) {
  1337. case "0000":
  1338. def.resolve(response);
  1339. break;
  1340. case "1104":
  1341. def.resolve(response);
  1342. break;
  1343. case "1105":
  1344. def.resolve(response);
  1345. break;
  1346. case "1061":
  1347. def.resolve(response);
  1348. break;
  1349. case "8601":
  1350. def.resolve(response);
  1351. break;
  1352. default:
  1353. // response.errorInfo
  1354. compnt.showAlerts(response.errorInfo)
  1355. def.reject(response);
  1356. break;
  1357. }
  1358. }).fail(function (error) {
  1359. def.reject('服务调用异常')
  1360. })
  1361. return def;
  1362. };
  1363. /**
  1364. * 调用统一认证订购接口
  1365. */
  1366. export function showCapOrder(fog, productName, scrollable, hasNetNumber, decryptUsermob, capTemplet) {
  1367. historyBackExecuted = false;
  1368. var capUrl;
  1369. var baseUrl;
  1370. if (window.location.href.indexOf("https://800.wo.cn/orderchannel") >= 0) {
  1371. capUrl = "https://800.wo.cn/cap/order.html";
  1372. baseUrl = "https://800.wo.cn/";
  1373. } else if (window.location.href.indexOf("https://800.wo.cn/festivalchannel") >= 0) {
  1374. capUrl = "https://800.wo.cn/festivalcap/order.html";
  1375. baseUrl = "https://800.wo.cn/";
  1376. } else if (window.location.href.indexOf("localhost") >= 0) {
  1377. capUrl = "http://localhost:8088/cap/order.html";
  1378. baseUrl = "http://localhost:8088/";
  1379. } else if (window.location.href.indexOf("100.0.3.69:3344") >= 0) {
  1380. capUrl = "http://100.0.3.69:3344/cap/order.html";
  1381. baseUrl = "http://100.0.3.69:3344/";
  1382. } else if (window.location.href.indexOf("100.0.3.69:8282") >= 0) {
  1383. capUrl = "http://100.0.3.69:8282/cap/order.html";
  1384. baseUrl = "http://100.0.3.69:8282/";
  1385. } else if (window.location.href.indexOf("https://operation1.bol.wo.cn") >= 0) {
  1386. capUrl = "https://800.wo.cn/cap/order.html";
  1387. baseUrl = "https://800.wo.cn/";
  1388. } else {
  1389. // capUrl = "https://800.wo.cn/festivalcap/order.html";
  1390. // baseUrl = "https://800.wo.cn/";
  1391. capUrl = "https://800.wo.cn/cap/order.html";
  1392. baseUrl = "https://800.wo.cn/";
  1393. }
  1394. var $iframe;
  1395. if ($('#uniauthframe').length >= 1) {
  1396. $iframe = $('#uniauthframe').attr('src', capUrl);
  1397. } else {
  1398. $iframe = $('<iframe id="uniauthframe" src="' + capUrl + '"></iframe>');
  1399. }
  1400. $iframe.css({
  1401. width: "100%",
  1402. height: "100%",
  1403. position: "fixed",
  1404. top: 0,
  1405. left: 0,
  1406. margin: 0,
  1407. padding: 0,
  1408. "-webkit-overflow-scrolling": "touch",
  1409. border: "0px",
  1410. })
  1411. compnt.showLoading();
  1412. $iframe.on('load', function () {
  1413. $capoverlay.remove();
  1414. generClientSecret(fog).then(function (response) {
  1415. compnt.hideLoading();
  1416. response.festival = parseInt(query.fes, 32);
  1417. response.orderChannel = parseInt(query.sou, 32);
  1418. if (productName != null && productName != '') {
  1419. response.productName = productName;
  1420. }
  1421. if (capTemplet != null && capTemplet != '') {
  1422. response.capTemplet = capTemplet
  1423. }
  1424. $iframe[0].contentWindow.postMessage(JSON.stringify(response), baseUrl)
  1425. })
  1426. })
  1427. if (navigator.userAgent.indexOf("MicroMessenger") >= 0) {
  1428. //微信6.7.4及以后版本 ios12软键盘顶起页面后隐藏不回弹解决方案
  1429. //打开嵌入的统一认证取号页面前,让原来的页面上下滚动。
  1430. //统一认证的页面关闭以后,删除定时任务 clearInterval(window.capTimer)
  1431. var currentPosition;
  1432. var speed = 1; // 页面滚动距离
  1433. window.capTimer = setInterval(function () {
  1434. currentPosition = document.documentElement.scrollTop || document.body.scrollTop;
  1435. currentPosition -= speed;
  1436. window.top.scrollTo(0, currentPosition); //页面向上滚动
  1437. currentPosition += speed; //speed变量
  1438. window.top.scrollTo(0, currentPosition); //页面向下滚动
  1439. }, 200);
  1440. }
  1441. window.$capoverlay = $('<div class="overlay" style="z-index: 0"></div>');
  1442. $capoverlay.appendTo($(document.body));
  1443. if ($('#uniauthframe').length == 0) {
  1444. $('body').append($iframe);
  1445. } else {
  1446. $iframe.css('position', 'unset')
  1447. .css('min-height', '10rem')
  1448. }
  1449. // 是否允许横向,网易游戏的窗口只能横向,横向的情况,不能进制滚动
  1450. if (!scrollable) {
  1451. $("body").css("overflow", "hidden");
  1452. }
  1453. var def = $.Deferred();
  1454. function handleMessage(event) {
  1455. var data = JSON.parse(event.data);
  1456. switch (data.resultcode) {
  1457. case "0": //处理成功
  1458. $iframe.remove();
  1459. $capoverlay.remove();
  1460. $("body").css("overflow", "auto");
  1461. clearInterval(window.capTimer)
  1462. user.token = data.token;
  1463. user.userid = decodeURIComponent(data.userid);
  1464. user.userid1 = data.userid1;
  1465. user.usermob = data.usermob;
  1466. user.usertime = new Date().getTime();
  1467. if (!!decryptUsermob) {
  1468. decodeUsermob()
  1469. }
  1470. def.resolve(user);
  1471. break;
  1472. case "9001": //关闭H5认证页面
  1473. $iframe.remove();
  1474. $capoverlay.remove();
  1475. clearInterval(window.capTimer)
  1476. $("body").css("overflow", "auto");
  1477. def.reject(data);
  1478. if (hasNetNumber != null && !!hasNetNumber && !historyBackExecuted) {
  1479. if (query.test == '1') {
  1480. alert(navigator.userAgent);
  1481. }
  1482. // 目前火狐浏览在打开iframe后不会产生历史记录,Chrome内核的浏览器会产生历史记录
  1483. if (isChromeKernelBrowser()) {
  1484. historyBackExecuted = true;
  1485. history.back();
  1486. }
  1487. }
  1488. break;
  1489. case "0001": //auth_no无效
  1490. case "0003": //client_id不存在
  1491. case "0006": //验证码不正确
  1492. case "4444": //服务暂时不可用(系统忙/系统队列满)
  1493. break;
  1494. default:
  1495. $iframe.remove();
  1496. $capoverlay.remove();
  1497. $("body").css("overflow", "auto");
  1498. clearInterval(window.capTimer)
  1499. compnt.showAlert(data.errorinfo)
  1500. def.reject(data)
  1501. break;
  1502. }
  1503. }
  1504. window.removeEventListener('message', handleMessage);
  1505. window.addEventListener('message', handleMessage);
  1506. return def;
  1507. }
  1508. /**
  1509. * 打开统一认证的页面,
  1510. * hasNetNumber 统一认证页面是否支持net取号
  1511. * historyBackExecuted 是否已经调用了history.back方法
  1512. */
  1513. var historyBackExecuted = true;
  1514. export function showCapPage(fog, productName, scrollable, hasNetNumber, decryptUsermob, capTemplet) {
  1515. console.log(fog, productName, scrollable, hasNetNumber, decryptUsermob, capTemplet,"open1");
  1516. historyBackExecuted = false;
  1517. if (fog != null && product.fog == null) {
  1518. product.fog = fog;
  1519. }
  1520. // 是否允许横向,网易游戏的窗口只能横向,横向的情况,不能限制滚动
  1521. if (!scrollable) {
  1522. $("body").css("overflow", "hidden");
  1523. }
  1524. var capUrl;
  1525. var baseUrl;
  1526. if (window.location.href.indexOf("https://800.wo.cn/orderchannel") >= 0) {
  1527. capUrl = "https://800.wo.cn/cap/CAP-AUTH.html";
  1528. baseUrl = "https://800.wo.cn/";
  1529. } else if (window.location.href.indexOf("https://800.wo.cn/festivalchannel") >= 0) {
  1530. capUrl = "https://800.wo.cn/festivalcap/CAP-AUTH.html";
  1531. baseUrl = "https://800.wo.cn/";
  1532. } else if (window.location.href.indexOf("http://localhost") >= 0) {
  1533. capUrl = "http://localhost:8088/cap/CAP-AUTH.html";
  1534. baseUrl = "http://localhost:8088/";
  1535. } else if (window.location.href.indexOf("http://127.0.0.1") >= 0) {
  1536. capUrl = "http://127.0.0.1:8088/cap/CAP-AUTH.html";
  1537. baseUrl = "http://127.0.0.1:8088/";
  1538. } else if (window.location.href.indexOf("http://100.0.3.69:3344") >= 0) {
  1539. capUrl = "http://100.0.3.69:3344/cap/CAP-AUTH.html";
  1540. baseUrl = "http://100.0.3.69:3344/";
  1541. } else if (window.location.href.indexOf("http://100.0.3.69:8282") >= 0) {
  1542. capUrl = "http://100.0.3.69:8282/cap/CAP-AUTH.html";
  1543. baseUrl = "http://100.0.3.69:8282/";
  1544. } else if (window.location.href.indexOf("https://800.wo.cn/festivalcap") >= 0) {
  1545. capUrl = "https://800.wo.cn/festivalcap/CAP-AUTH.html";
  1546. baseUrl = "https://800.wo.cn/";
  1547. } else {
  1548. capUrl = "https://800.wo.cn/cap/CAP-AUTH.html";
  1549. baseUrl = "https://800.wo.cn/";
  1550. }
  1551. // ad 是广告英文单词的缩写,会被浏览器当作广告拦截
  1552. // if ($("#nanyanad").val() != null) {
  1553. // capUrl += '?ny=' + $("#nanyanad").val()
  1554. // }
  1555. var $iframe;
  1556. if ($('#uniauthframe').length >= 1) {
  1557. $iframe = $('#uniauthframe').attr('src', capUrl);
  1558. } else {
  1559. $iframe = $('<iframe id="uniauthframe" src="' + capUrl + '" style="width:100%;height:100%;position:fixed;top:0;left:0;margin:0;padding:0;border:0"></iframe>');
  1560. }
  1561. // $iframe.css({
  1562. // width: "100%",
  1563. // height: "100%",
  1564. // position: "fixed",
  1565. // top: 0,
  1566. // left: 0,
  1567. // margin: 0,
  1568. // padding: 0,
  1569. // "-webkit-overflow-scrolling": "touch",
  1570. // border: "0px",
  1571. // })
  1572. compnt.showLoading();
  1573. $iframe.on('load', function () {
  1574. $capoverlay.remove();
  1575. generClientSecret(fog).then(function (response) {
  1576. compnt.hideLoading();
  1577. response.orderChannel = query.fes + "_" + query.sou;
  1578. if (productName != null && productName != '') {
  1579. response.productName = productName;
  1580. }
  1581. if (capTemplet != null && capTemplet != '') {
  1582. response.capTemplet = capTemplet
  1583. }
  1584. if (query.phone && query.phone != "") {
  1585. response.phone = query.phone;
  1586. }
  1587. try {
  1588. // response.appid = htmlPageVisitorAppId;
  1589. } catch (e) {
  1590. }
  1591. // alert(baseUrl)
  1592. // alert(JSON.stringify(response))
  1593. // alert($iframe[0].contentWindow.postMessage)
  1594. try {
  1595. console.log(response,baseUrl,"this.response");
  1596. $iframe[0].contentWindow.postMessage(JSON.stringify(response), baseUrl)
  1597. console.log('进入收银页面:cap_open')
  1598. WoAnalytics && WoAnalytics.addPoint({ ad: $('#directflowactivity').val(), at: $('#namehd').val(), ett: 'open', ea: 'cashier_view', cpn: 'cashier', pm: parseInt(query.sou, 32) })
  1599. } catch (e) {
  1600. // alert(JSON.stringify(e))
  1601. }
  1602. })
  1603. })
  1604. if (navigator.userAgent.indexOf("MicroMessenger") >= 0) {
  1605. //微信6.7.4及以后版本 ios12软键盘顶起页面后隐藏不回弹解决方案
  1606. //打开嵌入的统一认证取号页面前,让原来的页面上下滚动。
  1607. //统一认证的页面关闭以后,删除定时任务 clearInterval(window.capTimer)
  1608. var currentPosition;
  1609. var speed = 1; // 页面滚动距离
  1610. window.capTimer = setInterval(function () {
  1611. currentPosition = document.documentElement.scrollTop || document.body.scrollTop;
  1612. currentPosition -= speed;
  1613. window.top.scrollTo(0, currentPosition); //页面向上滚动
  1614. currentPosition += speed; //speed变量
  1615. window.top.scrollTo(0, currentPosition); //页面向下滚动
  1616. }, 200);
  1617. }
  1618. window.$capoverlay = $('<div class="overlay" style="z-index: 0"></div>');
  1619. $capoverlay.appendTo($(document.body));
  1620. if ($('#uniauthframe').length == 0) {
  1621. $('body').append($iframe);
  1622. } else {
  1623. $iframe.css('position', 'unset')
  1624. .css('min-height', '10rem')
  1625. }
  1626. var def = $.Deferred();
  1627. function messageListener(event) {
  1628. var data = null;
  1629. try {
  1630. data = JSON.parse(event.data);
  1631. } catch (e) {
  1632. return;
  1633. }
  1634. console.log(data)
  1635. switch (data.resultcode) {
  1636. case "0": //处理成功
  1637. $iframe.remove();
  1638. $capoverlay.remove();
  1639. window.removeEventListener('message', messageListener);
  1640. $("body").css("overflow", "auto");
  1641. clearInterval(window.capTimer)
  1642. user.token = data.token;
  1643. user.userid = decodeURIComponent(data.userid);
  1644. user.userid1 = data.userid1;
  1645. user.usermob = data.usermob;
  1646. user.usertime = new Date().getTime();
  1647. if (!!decryptUsermob) {
  1648. decodeUsermob()
  1649. }
  1650. try {
  1651. window.HtmlPageVisitor && window.HtmlPageVisitor.setMp(data.usermob);
  1652. console.log('进入收银台页面,点击确认支付按钮')
  1653. 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 })
  1654. } catch (e) { }
  1655. def.resolve(user);
  1656. break;
  1657. case "9001": //关闭H5认证页面
  1658. $iframe.remove();
  1659. $capoverlay.remove();
  1660. window.removeEventListener('message', messageListener);
  1661. clearInterval(window.capTimer)
  1662. $("body").css("overflow", "auto");
  1663. def.reject(data);
  1664. if (hasNetNumber != null && !!hasNetNumber && !historyBackExecuted) {
  1665. if (query.test == '1') {
  1666. alert(navigator.userAgent);
  1667. }
  1668. // 目前火狐浏览在打开iframe后不会产生历史记录,Chrome内核的浏览器会产生历史记录
  1669. if (isChromeKernelBrowser()) {
  1670. historyBackExecuted = true;
  1671. history.back();
  1672. }
  1673. }
  1674. break;
  1675. case "0001": //auth_no无效
  1676. case "0003": //client_id不存在
  1677. case "0006": //验证码不正确
  1678. case "4444": //服务暂时不可用(系统忙/系统队列满)
  1679. break;
  1680. case "99999": // 埋点信号
  1681. if (data.operid) {
  1682. burypointLogId(data.operid);
  1683. }
  1684. if (data.ea) {
  1685. WoAnalytics.addPoint({ ad: $("#nanyanad").val(), ett: 'open', ea: data.ea + $("#nanyanlabel").val(), ct: 'web', pm: parseInt(getUrlParam("sou"), 32) })
  1686. }
  1687. try {
  1688. window.WoAnalytics && window.WoAnalytics.setMp(data.usermob);
  1689. } catch (e) { }
  1690. break;
  1691. default:
  1692. $iframe.remove();
  1693. $capoverlay.remove();
  1694. window.removeEventListener('message', messageListener);
  1695. $("body").css("overflow", "auto");
  1696. clearInterval(window.capTimer)
  1697. compnt.showAlert(data.errorinfo)
  1698. def.reject(data)
  1699. break;
  1700. }
  1701. }
  1702. window.addEventListener('message', messageListener);
  1703. return def;
  1704. }
  1705. export function showCancelReasonPage() {
  1706. var reasonUrl;
  1707. var baseUrl;
  1708. if (window.location.href.indexOf("https://800.wo.cn/orderchannel") >= 0) {
  1709. reasonUrl = "https://800.wo.cn/orderchannel/public/libs/cancelreason/index.html";
  1710. baseUrl = "https://800.wo.cn/";
  1711. } else if (window.location.href.indexOf("https://optest.bol.wo.cn") >= 0) {
  1712. reasonUrl = "https://optest.bol.wo.cn/orderchannel/orderchannel-s1h5/public/libs/cancelreason/indexs.html";
  1713. baseUrl = "https://optest.bol.wo.cn/";
  1714. } else if (window.location.href.indexOf("https://800.wo.cn/festivalchannel") >= 0) {
  1715. reasonUrl = "https://800.wo.cn/festivalchannel/public/libs/cancelreason/index.html";
  1716. baseUrl = "https://800.wo.cn/";
  1717. } else if (window.location.href.indexOf("http://localhost") >= 0) {
  1718. reasonUrl = "http://localhost:8088/orderchannel/public/libs/cancelreason/index.html";
  1719. baseUrl = "http://localhost:8088/";
  1720. } else if (window.location.href.indexOf("http://127.0.0.1") >= 0) {
  1721. reasonUrl = "http://127.0.0.1:8088/orderchannel/public/libs/cancelreason/index.html";
  1722. baseUrl = "http://127.0.0.1:8088/";
  1723. } else if (window.location.href.indexOf("http://100.0.3.69:3344") >= 0) {
  1724. reasonUrl = "http://100.0.3.69:3344/orderchannel/public/libs/cancelreason/index.html";
  1725. baseUrl = "http://100.0.3.69:3344/";
  1726. } else if (window.location.href.indexOf("http://100.0.3.69:8282") >= 0) {
  1727. reasonUrl = "http://100.0.3.69:8282/orderchannel/public/libs/cancelreason/index.html";
  1728. baseUrl = "http://100.0.3.69:8282/";
  1729. } else {
  1730. reasonUrl = "https://operation1.bol.wo.cn/orderchannel/public/libs/cancelreason/index.html";
  1731. baseUrl = "https://operation1.bol.wo.cn/";
  1732. }
  1733. window.$capoverlay = $('<div class="overlay" style="z-index: 0; background-color: rgba(0,0,0,0.4);"></div>');
  1734. $capoverlay.appendTo($(document.body));
  1735. $("body").css("overflow", "hidden");
  1736. var $iframe;
  1737. if ($('#reasonIframe').length >= 1) {
  1738. $iframe = $('#reasonIframe').attr('src', reasonUrl);
  1739. } else {
  1740. $iframe = $('<iframe id="reasonIframe" src="' + reasonUrl + '"></iframe>');
  1741. $('body').append($iframe);
  1742. }
  1743. $iframe.css({
  1744. width: "100%",
  1745. height: "100%",
  1746. position: "fixed",
  1747. top: 0,
  1748. left: 0,
  1749. margin: 0,
  1750. padding: 0,
  1751. "-webkit-overflow-scrolling": "touch",
  1752. border: "0px",
  1753. "z-index": 111,
  1754. });
  1755. var def = $.Deferred();
  1756. function messageListener(event) {
  1757. var data = JSON.parse(event.data);
  1758. $iframe.remove();
  1759. $capoverlay.remove();
  1760. $("body").css("overflow", "auto");
  1761. window.removeEventListener('message', messageListener);
  1762. if (data.eventtype != 'close') {
  1763. def.resolve(data)
  1764. } else {
  1765. def.reject(data)
  1766. }
  1767. }
  1768. window.addEventListener('message', messageListener);
  1769. return def;
  1770. }
  1771. //抖音以外产品调用退订采集原因页面
  1772. export function showCancelReasonPages() {
  1773. var reasonUrl;
  1774. var baseUrl;
  1775. if (window.location.href.indexOf("https://800.wo.cn/orderchannel") >= 0) {
  1776. reasonUrl = "https://800.wo.cn/orderchannel/public/libs/cancelreason/indexs.html";
  1777. baseUrl = "https://800.wo.cn/";
  1778. } else if (window.location.href.indexOf("https://optest.bol.wo.cn") >= 0) {
  1779. reasonUrl = "https://optest.bol.wo.cn/orderchannel/orderchannel-s1h5/public/libs/cancelreason/indexs.html";
  1780. baseUrl = "https://optest.bol.wo.cn/";
  1781. } else if (window.location.href.indexOf("https://800.wo.cn/festivalchannel") >= 0) {
  1782. reasonUrl = "https://800.wo.cn/festivalchannel/public/libs/cancelreason/indexs.html";
  1783. baseUrl = "https://800.wo.cn/";
  1784. } else if (window.location.href.indexOf("http://localhost") >= 0) {
  1785. reasonUrl = "http://localhost:8088/orderchannel/public/libs/cancelreason/indexs.html";
  1786. baseUrl = "http://localhost:8088/";
  1787. } else if (window.location.href.indexOf("http://127.0.0.1") >= 0) {
  1788. reasonUrl = "http://127.0.0.1:8088/orderchannel/public/libs/cancelreason/indexs.html";
  1789. baseUrl = "http://127.0.0.1:8088/";
  1790. } else if (window.location.href.indexOf("http://100.0.3.69:3344") >= 0) {
  1791. reasonUrl = "http://100.0.3.69:3344/orderchannel/public/libs/cancelreason/indexs.html";
  1792. baseUrl = "http://100.0.3.69:3344/";
  1793. } else if (window.location.href.indexOf("http://100.0.3.69:8282") >= 0) {
  1794. reasonUrl = "http://100.0.3.69:8282/orderchannel/public/libs/cancelreason/indexs.html";
  1795. baseUrl = "http://100.0.3.69:8282/";
  1796. } else {
  1797. reasonUrl = "https://operation1.bol.wo.cn/orderchannel/public/libs/cancelreason/index.html";
  1798. baseUrl = "https://operation1.bol.wo.cn/";
  1799. }
  1800. window.$capoverlay = $('<div class="overlay" style="z-index: 0; background-color: rgba(0,0,0,0.4);"></div>');
  1801. $capoverlay.appendTo($(document.body));
  1802. $("body").css("overflow", "hidden");
  1803. var $iframe;
  1804. if ($('#reasonIframe').length >= 1) {
  1805. $iframe = $('#reasonIframe').attr('src', reasonUrl);
  1806. } else {
  1807. $iframe = $('<iframe id="reasonIframe" src="' + reasonUrl + '"></iframe>');
  1808. $('body').append($iframe);
  1809. }
  1810. $iframe.css({
  1811. width: "100%",
  1812. height: "100%",
  1813. position: "fixed",
  1814. top: 0,
  1815. left: 0,
  1816. margin: 0,
  1817. padding: 0,
  1818. "-webkit-overflow-scrolling": "touch",
  1819. border: "0px",
  1820. "z-index": 111,
  1821. });
  1822. var def = $.Deferred();
  1823. function messageListener(event) {
  1824. var data = JSON.parse(event.data);
  1825. $iframe.remove();
  1826. $capoverlay.remove();
  1827. $("body").css("overflow", "auto");
  1828. window.removeEventListener('message', messageListener);
  1829. if (data.eventtype != 'close') {
  1830. def.resolve(data)
  1831. } else {
  1832. def.reject(data)
  1833. }
  1834. }
  1835. window.addEventListener('message', messageListener);
  1836. return def;
  1837. }
  1838. function decodeUsermob(userid) {
  1839. var param = {
  1840. "fog": product.fog || fog || "",
  1841. "userid": userid || user.userid
  1842. }
  1843. $.ajax({
  1844. url: root + '/decodeUserid',
  1845. type: "POST",
  1846. contentType: "application/json",
  1847. data: JSON.stringify(param)
  1848. }).then(function (data) {
  1849. if (data.resultCode == '0') {
  1850. user.usermob = data.usermob;
  1851. }
  1852. });
  1853. }
  1854. function parseQueryParms() {
  1855. var QUERY_SEPARATOR = '&',
  1856. VALUE_SEPARATOR = '=';
  1857. var queryStr = window.location.search.substring(1);
  1858. var startIndex = 0,
  1859. vIndex, qIndex;
  1860. while (queryStr.length > 0) {
  1861. vIndex = queryStr.indexOf(VALUE_SEPARATOR, startIndex);
  1862. if (vIndex == -1) {
  1863. break;
  1864. }
  1865. qIndex = queryStr.indexOf(QUERY_SEPARATOR, vIndex + 1);
  1866. if (qIndex == -1) {
  1867. qIndex = queryStr.length;
  1868. }
  1869. var key = queryStr.substring(startIndex, vIndex);
  1870. var value = queryStr.substring(vIndex + 1, qIndex);
  1871. query[key] = decodeURIComponent(value);
  1872. startIndex = qIndex + 1;
  1873. }
  1874. }
  1875. export function removeGetParam(name, url) {
  1876. var tempUrl = url || window.location.href;
  1877. var arr = tempUrl.split("?");
  1878. if (arr.length == 1) {
  1879. return tempUrl;
  1880. }
  1881. var paramArr = arr[1].split("&");
  1882. var i = paramArr.length - 1;
  1883. for (; i >= 0; i--) {
  1884. if (paramArr[i].startsWith(name + "=")) {
  1885. paramArr.splice(i, 1);
  1886. }
  1887. }
  1888. return arr[0] + "?" + paramArr.join("&");
  1889. }
  1890. function generClientSecret(fog) {
  1891. var param = {
  1892. "fog": product.fog || fog || "",
  1893. "channel": ""
  1894. }
  1895. return $.ajax({
  1896. url: root + '/ini/gensign',
  1897. type: "POST",
  1898. contentType: "application/json",
  1899. data: JSON.stringify(param)
  1900. })
  1901. }
  1902. export function saveUserInfo(duration) {
  1903. localStorage.setItem('user' + product.productid, JSON.stringify(user));
  1904. localStorage.setItem('time' + product.productid, duration || ((new Date().getTime()) + ""));
  1905. }
  1906. export function loadUserInfo(duration) {
  1907. if (query.userid) {
  1908. user.userid = query.userid;
  1909. user.usermob = query.usermob;
  1910. return;
  1911. }
  1912. try {
  1913. var time = localStorage.getItem('time' + product.productid);
  1914. if (time) {
  1915. var curr = new Date().getTime();
  1916. // 默认有效期是1小时
  1917. if (curr <= parseFloat(time) + (duration || (1000 * 60 * 60))) {
  1918. var userString = localStorage.getItem("user" + product.productid);
  1919. if (userString != null) {
  1920. user = JSON.parse(userString);
  1921. user.userid = user.userid;
  1922. user.usermob = user.usermob;
  1923. }
  1924. // if (user.usermob == "18674842761" || user.usermob == "17610768237") {
  1925. // setTimeout(function() {
  1926. // alert(time + (duration || (1000 * 60 * 60)))
  1927. // }, 100);
  1928. // }
  1929. } else {
  1930. // 超过1小时删除缓存数据
  1931. localStorage.removeItem("time" + product.productid)
  1932. localStorage.removeItem("user" + product.productid)
  1933. }
  1934. return user;
  1935. } else {
  1936. localStorage.removeItem("time" + product.productid)
  1937. localStorage.removeItem("user" + product.productid)
  1938. }
  1939. } catch (e) {
  1940. }
  1941. }
  1942. /**
  1943. * SliderCaptcha
  1944. */
  1945. export function verifyCaptcha(arr) {
  1946. $.ajax({
  1947. url: root + '/sliderCaptcha/verify',
  1948. type: "POST",
  1949. contentType: "application/json",
  1950. data: JSON.stringify(arr)
  1951. }).then(function (responseText) {
  1952. var response = JSON.parse(responseText);
  1953. if (response.resultCode == "0000") {
  1954. product.captchaCode = response.captchaCode;
  1955. return true;
  1956. } else {
  1957. compnt.showAlert(response.errorInfo);
  1958. return false;
  1959. }
  1960. })
  1961. };
  1962. /**
  1963. * 获取项目根目录
  1964. * @returns
  1965. */
  1966. export function getRootPath() {
  1967. //获取当前网址,如: http://localhost:8080/ems/Pages/Basic/Person.jsp
  1968. var curWwwPath = window.document.location.href;
  1969. //获取主机地址之后的目录,如: /ems/Pages/Basic/Person.jsp
  1970. var pathName = window.document.location.pathname;
  1971. var pos = curWwwPath.indexOf(pathName);
  1972. //获取主机地址,如: http://localhost:8080
  1973. var localhostPath = curWwwPath.substring(0, pos);
  1974. //获取带"/"的项目名,如:/ems
  1975. // var projectName = pathName.substring(0, pathName.substr(1).indexOf('/') + 1);
  1976. var projectName = "/orderchannel-s1api"
  1977. root = (localhostPath + projectName);
  1978. // return (localhostPath + projectName);
  1979. return env.APP_BASE.apiUrl
  1980. }
  1981. /**
  1982. * 获取当前url中参数信息
  1983. * @param urlprm url中参数名称
  1984. * @returns
  1985. */
  1986. export function getUrlParam(urlprm) {
  1987. if (window.location.href == "https://800.wo.cn/orderchannel/hd/Dy/order202005.html?fes=jh7") {
  1988. window.location.href = "https://800.wo.cn/orderchannel/hd/Dy/order202005.html?fes=jh7&sou=12";
  1989. return;
  1990. }
  1991. if (window.location.href.indexOf('jiangtao') >= 0) {
  1992. alert(window.location.href);
  1993. }
  1994. var reg = new RegExp("(^|&)" + urlprm + "=([^&]*)(&|$)");
  1995. var r = window.location.search.substr(1).match(reg);
  1996. if (r != null) {
  1997. return r[2];
  1998. } else {
  1999. switch (urlprm) {
  2000. case "con":
  2001. return "1";
  2002. case "freeflow_token":
  2003. return "";
  2004. default:
  2005. var url = getRootPath() + "/404.html";
  2006. $(location).attr('href', url);
  2007. }
  2008. }
  2009. }
  2010. export function burypointLogId(operid, remark, url, productid) {
  2011. var uuid = getCookie('uuid'); // uv
  2012. var vvid = getCookie('vvid'); // vv
  2013. if (uuid == null || uuid.trim() == '') {
  2014. uuid = guid();
  2015. setCookie('uuid', uuid, Date.remainMillis());
  2016. }
  2017. if (vvid == null || vvid.trim() == '') {
  2018. vvid = guid();
  2019. setCookie('vvid', vvid, -1);
  2020. }
  2021. if (operid == null || operid == '') {
  2022. // 页面的埋点不通过/burypoint/logid接口实现,通过文件日志入库方式
  2023. return;
  2024. }
  2025. var param = {
  2026. operid: operid,
  2027. uuid: uuid,
  2028. vvid: vvid,
  2029. fog: product.fog,
  2030. userid: user.userid,
  2031. fes: query.fes,
  2032. sou: query.sou,
  2033. url: encodeURIComponent(url || window.location.href),
  2034. remark: encodeURIComponent(remark || '')
  2035. }
  2036. $.ajax({
  2037. url: root + '/burypoint/logid',
  2038. type: "POST",
  2039. contentType: "application/json",
  2040. data: JSON.stringify(param)
  2041. }).then(function (responseText) {
  2042. })
  2043. }
  2044. export function getCookie(name) {
  2045. var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
  2046. if (arr = document.cookie.match(reg))
  2047. return unescape(arr[2]);
  2048. else
  2049. return null;
  2050. }
  2051. /**
  2052. * 如果没有设置时间
  2053. */
  2054. export function setCookie(name, value, millis) {
  2055. millis = (millis == undefined ? 0 : millis);
  2056. var exp = new Date();
  2057. if (millis < 0) {
  2058. document.cookie = name + "=" + escape(value);
  2059. } else {
  2060. exp.setTime(exp.getTime() + millis);
  2061. document.cookie = name + "=" + escape(value) + ";expires=" + exp.toGMTString();
  2062. }
  2063. }
  2064. export function guid() {
  2065. return 'xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
  2066. var r = Math.random() * 16 | 0,
  2067. v = c == 'x' ? r : (r & 0x3 | 0x8);
  2068. return v.toString(16);
  2069. });
  2070. }
  2071. /**
  2072. * 查询微信支付结果
  2073. */
  2074. export function queryWxPay(tradeno, tradedate, userid) {
  2075. var param = {
  2076. "fes": query.fes,
  2077. "sou": query.sou,
  2078. "fog": product.fog,
  2079. "tradeno": tradeno,
  2080. "userid": userid || user.userid,
  2081. "tradedate": tradedate, //例子:20190115
  2082. }
  2083. var def = $.Deferred();
  2084. if (isEmpty(param.userid)) {
  2085. def.reject('参数错误')
  2086. return def;
  2087. }
  2088. if (isEmpty(param.tradeno)) {
  2089. def.reject('参数错误')
  2090. return def;
  2091. }
  2092. return $.ajax({
  2093. url: root + '/backward/stackpkgquerypay',
  2094. type: "POST",
  2095. contentType: "application/json",
  2096. data: JSON.stringify(param)
  2097. })
  2098. }
  2099. export function getNowFormatDate(sperator) {
  2100. if (sperator == null) {
  2101. sperator = ''
  2102. }
  2103. var date = new Date();
  2104. var year = date.getFullYear();
  2105. var month = date.getMonth() + 1;
  2106. var strDate = date.getDate();
  2107. if (month >= 1 && month <= 9) {
  2108. month = "0" + month;
  2109. }
  2110. if (strDate >= 0 && strDate <= 9) {
  2111. strDate = "0" + strDate;
  2112. }
  2113. var currentdate = year + sperator + month + sperator + strDate;
  2114. return currentdate;
  2115. }
  2116. /**
  2117. * 目前已知的是Opera、火狐浏览器,使用iframe不会产生history记录
  2118. */
  2119. export function isChromeKernelBrowser() {
  2120. var isBaidu = navigator.userAgent.indexOf("Baidu") > -1;
  2121. if (isBaidu) return isBaidu;
  2122. var isOpera = navigator.userAgent.indexOf("OPR") > -1;
  2123. var isFirefox = navigator.userAgent.indexOf("Firefox") > -1; //判断是否 Firefox 浏览器
  2124. var isUCBrowser = navigator.userAgent.indexOf("UCBrowser")
  2125. if (!isOpera || !isFirefox || !isUCBrowser) {
  2126. return false;
  2127. }
  2128. // 微信、百度App、谷歌浏览器
  2129. var isMicroMessenger = navigator.userAgent.indexOf("MicroMessenger") > -1;
  2130. var isSafari = navigator.userAgent.indexOf("Safari") > -1;
  2131. var isChrome = navigator.userAgent.indexOf("Chrome") > -1;
  2132. return isMicroMessenger || isBaidu || isSafari || isChrome;
  2133. }
  2134. function getMess(message, data) {
  2135. const CryptoJS = require('./crypto-js');
  2136. var keyHex = CryptoJS.enc.Utf8.parse(data);
  2137. var encrypted = CryptoJS.DES.encrypt(message, keyHex, {
  2138. mode: CryptoJS.mode.ECB,
  2139. padding: CryptoJS.pad.Pkcs7
  2140. });
  2141. return encrypted.ciphertext.toString().toUpperCase();
  2142. };
  2143. function getPass() {
  2144. var d = new Date();
  2145. var year = d.getFullYear();
  2146. var month = change(d.getMonth() + 1);
  2147. var day = change(d.getDate());
  2148. function change(t) {
  2149. if (t < 10) {
  2150. return "0" + t;
  2151. } else {
  2152. return t;
  2153. }
  2154. }
  2155. var key = year + '' + month + '' + day;
  2156. return key;
  2157. }