unicom.js 67 KB

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