| 313 | } |
| 314 | |
| 315 | function convert(url, isOriginJXURL) { |
| 316 | return new Promise((resolve) => { |
| 317 | if (!cookie) { |
| 318 | $tool.setCache("false", "jfUseConvert"); |
| 319 | resolve(""); |
| 320 | } else { |
| 321 | let id; |
| 322 | if ( |
| 323 | url.includes("item.m.jd") || |
| 324 | url.includes("item.jd") || |
| 325 | (!autoChoose && chooseScheme == "openApp.jdHealth") |
| 326 | ) { |
| 327 | id = url.match(/(\d+)\.html/)[1]; |
| 328 | url = `https:\/\/item.m.jd.com\/product\/${id}.html`; |
| 329 | } else if (url.includes("m.jingxi") || url.includes("wq.jd.com")) { |
| 330 | id = url.match(/sku=(\d+)/)[1]; |
| 331 | url = `https:\/\/wq.jd.com\/item\/view?sku=${id}`; |
| 332 | if (isOriginJXURL || (!autoChoose && chooseScheme == "openjdlite")) |
| 333 | url = `https:\/\/m.jingxi.com\/item\/jxview?sku=${id}`; |
| 334 | autoScheme = "openapp.jdpingou"; |
| 335 | } else if (url.includes("kpl.m.jd")) { |
| 336 | id = url.match(/wareId=(\d+)/)[1]; |
| 337 | url = `https:\/\/kpl.m.jd.com\/product?wareId=${id}`; |
| 338 | autoScheme = jsapp ? "openjdlite" : "browser"; |
| 339 | } else { |
| 340 | url = url; |
| 341 | //url = url.replace(/\//g, "\\/"); |
| 342 | } |
| 343 | let body = { |
| 344 | funName: "getSuperClickUrl", |
| 345 | param: { |
| 346 | materialInfo: url, |
| 347 | ext1: "200|100_3|", |
| 348 | }, |
| 349 | }; |
| 350 | let t = +new Date(); |
| 351 | let options = { |
| 352 | url: `https://api.m.jd.com/api?functionId=ConvertSuperLink&appid=u&_=${t}&body=${encodeURI( |
| 353 | JSON.stringify(body) |
| 354 | )}&loginType=2`, |
| 355 | headers: { |
| 356 | "Accept-Encoding": "gzip,compress,br,deflate", |
| 357 | Connection: "keep-alive", |
| 358 | Cookie: cookie, |
| 359 | Host: "api.m.jd.com", |
| 360 | Referer: "https://servicewechat.com/wxf463e50cd384beda/114/page-frame.html", |
| 361 | "User-Agent": |
| 362 | "Mozilla/5.0 (iPhone; CPU iPhone OS 13_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/8.0.4(0x18000429) NetType/WIFI Language/zh_CN", |
| 363 | "content-type": "application/json", |
| 364 | }, |
| 365 | }; |
| 366 | $tool.get(options, function (err, resp, data) { |
| 367 | if (!err) { |
| 368 | data = JSON.parse(data); |
| 369 | console.log("JD Convert Data:\n" + data); |
| 370 | if (data.code === 200) { |
| 371 | let r = {}; |
| 372 | let scheme = autoChoose ? autoScheme : chooseScheme; |