Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

commonReq.js 23KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165
  1. /*
  2. * @Author: gaorf30153 gaorf30153@hundsun.com
  3. * @Date: 2024-06-24 09:53:36
  4. * @LastEditors: gaorf30153 gaorf30153@hundsun.com
  5. * @LastEditTime: 2024-09-10 17:09:00
  6. * @FilePath: \wxminipro\plugin\utils\commonReq.js
  7. * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  8. */
  9. import Api from "../api/index.js"
  10. import {
  11. getStore,
  12. removeStore,
  13. setStore
  14. } from "./index.js"
  15. import {
  16. requestFnc
  17. } from "./request.js"
  18. import {
  19. configObj
  20. } from "../config.js"
  21. import {
  22. encrypt
  23. } from "./aesutils.js"
  24. // 微信车主签约
  25. export function wxSign(cb, status) {
  26. let params = {
  27. filename: Api.signBank.filename,
  28. data: {
  29. accountId: getStore("accountId"),
  30. productId: JSON.parse(getStore("productObj")).productId,
  31. preVehicleId: getStore("vehicleId"),
  32. etcProductId: getStore("etcProductId"),
  33. signArgs: JSON.stringify({
  34. openId: getStore("myWxOpenId")
  35. }),
  36. signChannelCode: "102",
  37. notifyAppId: "#",
  38. notifyPage: "#",
  39. },
  40. }
  41. requestFnc(
  42. Api.signBank.url,
  43. params,
  44. (res) => {
  45. setStore("signChannelId", res.signChannelId)
  46. // 已签约未支付
  47. if (status === 5) {
  48. getOrderRenewalPayInfo((handleFees) => {
  49. if (!getStore("wechatSignNo")) {
  50. wx.redirectTo({
  51. url: "plugin://issuer-plugin/delivery-method",
  52. })
  53. }
  54. if (getStore("wechatSignNo")) {
  55. wechatSignNoOrderRenewalPayInfo(handleFees, cb)
  56. }
  57. })
  58. return
  59. }
  60. // 已签约未绑定
  61. if (res.signStatus === 1) {
  62. getSignResult(cb)
  63. } else {
  64. let list = JSON.parse(res.signParameter)
  65. let params = {}
  66. for (let obj of list) {
  67. // 高速
  68. if (obj.tradeScene === "HIGHWAY") {
  69. params = obj.wxVehicleModel
  70. }
  71. }
  72. console.log("签约参数", params)
  73. wx.navigateToMiniProgram({
  74. appId: params.appId,
  75. path: params.path,
  76. extraData: params.extraData,
  77. success(res) {
  78. setStore("sign", "1")
  79. console.log("跳转车主小程序")
  80. },
  81. fail(res) {
  82. console.log("未跳转小程序", res)
  83. },
  84. })
  85. cb && cb()
  86. }
  87. },
  88. () => {
  89. cb && cb()
  90. }
  91. )
  92. }
  93. // 签约结果查询
  94. export function getSignResult(cb) {
  95. let params = {
  96. filename: Api.signResult.filename,
  97. data: {
  98. accountId: getStore("accountId"),
  99. vehicleId: getStore("vehicleId"),
  100. signArgs: JSON.stringify({
  101. openId: getStore("myWxOpenId"),
  102. }),
  103. signChannelId: getStore("signChannelId"),
  104. },
  105. }
  106. if (getStore("sign") == 2) { //恢复签约
  107. params.data = {
  108. ...params.data,
  109. source: "resumeSign"
  110. }
  111. }
  112. requestFnc(
  113. Api.signResult.url,
  114. params,
  115. (res) => {
  116. if (res.status === 1) {
  117. if (getStore("sign") == 2) { //恢复签约
  118. wx.showModal({
  119. title: "提示",
  120. content: "车辆恢复签约已完成",
  121. showCancel: false,
  122. success: (res) => {
  123. if (res.confirm) {
  124. wx.reLaunch({
  125. url: getStore("redirectUrl"),
  126. })
  127. }
  128. },
  129. })
  130. } else {
  131. bindSignChannel(cb)
  132. }
  133. } else {
  134. if (getStore("sign") === 2) { //恢复签约
  135. wx.showModal({
  136. title: "提示",
  137. content: "签约失败, 请重新签约",
  138. showCancel: false,
  139. success: (res) => {
  140. if (res.confirm) {
  141. wx.reLaunch({
  142. url: getStore("redirectUrl"),
  143. })
  144. }
  145. },
  146. })
  147. } else {
  148. wx.showToast({
  149. title: "签约失败, 请重新签约",
  150. icon: "none",
  151. })
  152. }
  153. cb && cb()
  154. }
  155. removeStore("sign")
  156. },
  157. () => {
  158. cb && cb()
  159. }
  160. )
  161. }
  162. // 校验车辆状态
  163. export function checkCarStatus(cb) {
  164. getCarStatus((status) => {
  165. // 不存在
  166. if (status === 0) {
  167. wx.showModal({
  168. title: "提示",
  169. content: "该车辆不存在",
  170. showCancel: false,
  171. success(res) {
  172. if (res.confirm) {
  173. wx.navigateBack(1)
  174. }
  175. },
  176. })
  177. cb && cb()
  178. return
  179. }
  180. // 已完成
  181. if (status === 1) {
  182. wx.showModal({
  183. title: "提示",
  184. content: "该车辆已完成办理",
  185. showCancel: false,
  186. success(res) {
  187. if (res.confirm) {
  188. wx.navigateBack(1)
  189. }
  190. },
  191. })
  192. cb && cb()
  193. return
  194. }
  195. // 上传车主证件
  196. if (status === 2) {
  197. // wx.showModal({
  198. // title: "提示",
  199. // content: text,
  200. // confirmText: "传身份证",
  201. // cancelText: "传企业证",
  202. // success(res) {
  203. // if (res.confirm) {
  204. // wx.redirectTo({
  205. // url: "plugin://issuer-plugin/uploadPersion?type=carOwners",
  206. // })
  207. // } else if (res.cancel) {
  208. // wx.redirectTo({
  209. // url: "plugin://issuer-plugin/uploadCorp?type=carOwners",
  210. // })
  211. // }
  212. // },
  213. // })
  214. cb && cb(status)
  215. return
  216. }
  217. // 未签约或已签约未绑定
  218. if (status === 4) {
  219. //app扫码签约
  220. if (getStore("wechatSignNo")) {
  221. wx.showModal({
  222. title: "提示",
  223. content: "即将前往微信车主认证",
  224. confirmColor: "#00B38B",
  225. confirmText: "前往认证",
  226. success(res) {
  227. if (res.confirm) {
  228. wxSign(cb)
  229. } else if (res.cancel) {
  230. wx.reLaunch({
  231. url: getStore("redirectUrl"),
  232. })
  233. }
  234. },
  235. })
  236. } else {
  237. wxSign(cb)
  238. }
  239. return
  240. }
  241. // 未下单未支付
  242. if (status === 5) {
  243. wxSign(cb, status)
  244. return
  245. }
  246. // 未二发
  247. if (status === 6) {
  248. if (getStore("wechatSignNo")) {
  249. wx.showModal({
  250. title: "提示",
  251. content: "车辆绑定签约支付已完成",
  252. showCancel: false,
  253. success: (res) => {
  254. if (res.confirm) {
  255. wx.reLaunch({
  256. url: getStore("redirectUrl"),
  257. })
  258. }
  259. },
  260. })
  261. } else {
  262. wx.redirectTo({
  263. url: "plugin://issuer-plugin/device-act-guidance?activeCode=6",
  264. })
  265. }
  266. return
  267. }
  268. // 已二发未激活
  269. if (status === 7) {
  270. wx.redirectTo({
  271. url: "plugin://issuer-plugin/device-act-guidance?activeCode=7",
  272. })
  273. return
  274. }
  275. }, cb)
  276. }
  277. // 获取车辆办理状态
  278. function getCarStatus(cb1, cb2) {
  279. let params = {
  280. filename: Api.carHandle.filename,
  281. data: {
  282. vehicleId: getStore("vehicleId"),
  283. accountId: getStore("accountId"),
  284. },
  285. }
  286. console.log("查询车辆办理状态", params.data)
  287. requestFnc(
  288. Api.carHandle.url,
  289. params,
  290. (res) => {
  291. let {
  292. etcProductId = ""
  293. } = res
  294. setStore("etcProductId", etcProductId)
  295. // 续办
  296. if (getStore("handleType") === "continuation") {
  297. cb1(res.status)
  298. return
  299. }
  300. // 重新激活
  301. if (getStore("handleType") === "reactivate") {
  302. if (res.status === 1) {
  303. wx.redirectTo({
  304. url: "plugin://issuer-plugin/device-act-guidance?activeCode=7",
  305. })
  306. } else {
  307. wx.showModal({
  308. title: "提示",
  309. content: "该车辆未完成办理",
  310. showCancel: false,
  311. success(res) {
  312. if (res.confirm) {
  313. wx.navigateBack(1)
  314. }
  315. },
  316. })
  317. }
  318. cb2 && cb2()
  319. return
  320. }
  321. //恢复签约
  322. if (getStore("handleType") === "resumeSigning") {
  323. if (res.status === 1) {
  324. _accountResumesign(cb2)
  325. } else {
  326. wx.showModal({
  327. title: "提示",
  328. content: "该车辆未完成办理",
  329. showCancel: false,
  330. success(res) {
  331. if (res.confirm) {
  332. wx.reLaunch({
  333. url: getStore("redirectUrl"),
  334. })
  335. }
  336. },
  337. })
  338. cb2 && cb2()
  339. }
  340. return
  341. }
  342. // 售后(包含新办的退货,换货,补货)
  343. if (getStore("handleType") === "aftersale") {
  344. let type = getStore("afterType")
  345. if (!type) {
  346. wx.showModal({
  347. title: "提示",
  348. content: "售后类型缺失",
  349. showCancel: false,
  350. success(res) {
  351. if (res.confirm) {
  352. wx.navigateBack(1)
  353. }
  354. },
  355. })
  356. cb2 && cb2()
  357. return
  358. }
  359. // 续期,挂失,解挂,注销需要校验车辆状态,不需要校验订单状态
  360. if (res.status === 1) {
  361. // 续期
  362. if (type === "4") {
  363. wx.redirectTo({
  364. url: "plugin://issuer-plugin/renewal-connecting",
  365. })
  366. return
  367. // 注销
  368. } else if (type === "6") {
  369. wx.redirectTo({
  370. url: "plugin://issuer-plugin/logOff",
  371. })
  372. return
  373. } else if (type === "1") {
  374. // 挂失/解挂
  375. wx.redirectTo({
  376. url: "plugin://issuer-plugin/devApplyReplace",
  377. })
  378. return
  379. }
  380. } else if (type !== "7" && type !== "8" && type !== "9") {
  381. wx.showModal({
  382. title: "提示",
  383. content: "该车辆未完成办理",
  384. showCancel: false,
  385. success(res) {
  386. if (res.confirm) {
  387. wx.navigateBack(1)
  388. }
  389. },
  390. })
  391. cb2 && cb2()
  392. return
  393. }
  394. // 新办
  395. if (getStore("orderType") === "1") {
  396. // 新办订单办理类型校验
  397. getPreSalesOrderDetail(() => {
  398. dealAfter(type)
  399. }, cb2)
  400. } else if (getStore("orderType") === "2") {
  401. // 售后订单办理
  402. getAfterSalesOrderDetail(() => {
  403. if (res.status === 1) {
  404. dealAfter(type)
  405. } else {
  406. wx.showModal({
  407. title: "提示",
  408. content: "该车辆未完成办理",
  409. showCancel: false,
  410. success(res) {
  411. if (res.confirm) {
  412. wx.navigateBack(1)
  413. }
  414. },
  415. })
  416. cb2 && cb2()
  417. }
  418. }, cb2)
  419. } else {
  420. wx.showModal({
  421. title: "提示",
  422. content: "未查询到订单类型",
  423. showCancel: false,
  424. success(res) {
  425. if (res.confirm) {
  426. wx.navigateBack(1)
  427. }
  428. },
  429. })
  430. cb2 && cb2()
  431. }
  432. }
  433. //APP拉起前签约
  434. if (getStore("wechatSignNo")) {
  435. cb1(res.status)
  436. return
  437. }
  438. },
  439. (msg) => {
  440. cb2 && cb2()
  441. }
  442. )
  443. }
  444. // 售后处理
  445. function dealAfter(type) {
  446. // 退货、换货、补货
  447. if (type === "7" || type === "8" || type === "9") {
  448. // 还要结合订单状态
  449. const orderStatus = getStore("orderStatus")
  450. console.log("工单状态 2333----", orderStatus)
  451. if (orderStatus == "4" || orderStatus == "5" || orderStatus == "6") {
  452. // 已发货,才能申请 退、换、补
  453. wx.redirectTo({
  454. url: "plugin://issuer-plugin/applyExchange",
  455. })
  456. } else {
  457. wx.redirectTo({
  458. url: "plugin://issuer-plugin/exchangeDetail",
  459. })
  460. }
  461. return
  462. }
  463. // 更换、补办
  464. if (type === "3" || type === "5") {
  465. // 14-卡补办 15-OBU补办 16-卡更换 17-OBU更换 18-卡和OBU更换
  466. let afterOrderType = getStore("afterOrderType")
  467. let orderStatus = getStore("orderStatus")
  468. // 3 审核不通过 5 已激活 6 取消订单
  469. if (orderStatus == "3" || orderStatus == "5" || orderStatus == "6") {
  470. wx.redirectTo({
  471. url: "plugin://issuer-plugin/devApplyReplace",
  472. })
  473. } else {
  474. if (afterOrderType == "14" || afterOrderType == "15") {
  475. wx.redirectTo({
  476. url: `plugin://issuer-plugin/divReissue?type=${
  477. afterOrderType == "14" ? 1 : 2
  478. }`,
  479. })
  480. }
  481. if (
  482. afterOrderType == "16" ||
  483. afterOrderType == "17" ||
  484. afterOrderType == "18"
  485. ) {
  486. wx.redirectTo({
  487. url: `plugin://issuer-plugin/deviceReplace?type=${
  488. afterOrderType == "16"
  489. ? 1
  490. : afterOrderType == "17"
  491. ? 2
  492. : 3
  493. }`,
  494. })
  495. }
  496. }
  497. }
  498. }
  499. // 获取账户列表
  500. export function getAccountList(cb1, cb2) {
  501. let params = {
  502. filename: Api.getAccountList.filename,
  503. data: {},
  504. }
  505. requestFnc(
  506. Api.getAccountList.url,
  507. params,
  508. (res) => {
  509. let list = JSON.parse(res.data)
  510. let hasPersion = false
  511. let integralFlag = 1
  512. for (let obj of list) {
  513. if (obj.accountType == "1" && obj.idType === "101") {
  514. setStore("persionAccountId", obj.accountId)
  515. if (getStore("accountType") == "1") {
  516. setStore("accountId", obj.accountId)
  517. }
  518. hasPersion = true
  519. integralFlag = obj.integralFlag
  520. }
  521. }
  522. cb1 && cb1(hasPersion, list, integralFlag)
  523. },
  524. (msg) => {
  525. cb2 && cb2()
  526. }
  527. )
  528. }
  529. // 获取车辆列表
  530. function getCarList(cb1, cb2) {
  531. let params = {
  532. filename: Api.getCarList.filename,
  533. data: {
  534. accountId: getStore("accountId"),
  535. pageNo: 1,
  536. pageSize: 99,
  537. },
  538. }
  539. requestFnc(
  540. Api.getCarList.url,
  541. params,
  542. (res) => {
  543. let carList = JSON.parse(res.encryptedData)
  544. let hasCar = false
  545. for (let obj of carList) {
  546. if (obj.vehicleId === getStore("vehicleId")) {
  547. hasCar = true
  548. setStore("plateNum", obj.plateNum)
  549. setStore("plateColor", `${obj.plateColor}`)
  550. getCarStatus(cb1, cb2)
  551. }
  552. }
  553. if (!hasCar) {
  554. wx.showModal({
  555. title: "提示",
  556. content: "当前账户下无该车辆",
  557. showCancel: false,
  558. success(res) {
  559. if (res.confirm) {
  560. wx.navigateBack(1)
  561. }
  562. },
  563. })
  564. cb2 && cb2()
  565. }
  566. },
  567. (msg) => {
  568. cb2 && cb2()
  569. }
  570. )
  571. }
  572. // 关联签约渠道
  573. function bindSignChannel(cb) {
  574. let productId = JSON.parse(getStore("productObj")).productId
  575. let params = {
  576. filename: Api.bindSignChannel.filename,
  577. data: {
  578. accountId: getStore("accountId"),
  579. vehicleId: getStore("vehicleId"),
  580. signChannelId: getStore("signChannelId"),
  581. code: encrypt(productId, configObj.aesKey),
  582. validType: "2",
  583. },
  584. }
  585. requestFnc(
  586. Api.bindSignChannel.url,
  587. params,
  588. (res) => {
  589. // APP端只签约绑定之后需要下单
  590. if (getStore("wechatSignNo")) {
  591. getOrderRenewalPayInfo((handleFees) => {
  592. wechatSignNoOrderRenewalPayInfo(handleFees, cb)
  593. })
  594. } else {
  595. wx.redirectTo({
  596. url: "plugin://issuer-plugin/delivery-method",
  597. })
  598. }
  599. },
  600. () => {
  601. cb && cb()
  602. }
  603. )
  604. }
  605. // 创建支付订单
  606. function preOrder({
  607. addressId,
  608. sendType,
  609. packageId,
  610. processingFeeType,
  611. cb
  612. }) {
  613. console.log("----preOrder1111-----", {
  614. addressId,
  615. sendType,
  616. packageId,
  617. processingFeeType,
  618. })
  619. let params = {
  620. filename: Api.preOrder.filename,
  621. data: {
  622. accountId: getStore("accountId"),
  623. packageId,
  624. vehicleId: getStore("vehicleId"),
  625. signChannelId: getStore("signChannelId"),
  626. wxOpenId: getStore("myWxOpenId"),
  627. bizType: "1",
  628. addressId,
  629. sendType,
  630. processingFeeType,
  631. payRouteCode: "04"
  632. },
  633. }
  634. console.log("----preOrder2222-----", params)
  635. requestFnc(
  636. Api.preOrder.url,
  637. params,
  638. (res) => {
  639. let paymentArgs = {
  640. timeStamp: res.timeStamp + "",
  641. nonceStr: res.nonceStr,
  642. signType: res.signType,
  643. paySign: res.paySign,
  644. package: res.wxPackage,
  645. fee: res.money,
  646. payTradeNo: res.payTradeNo,
  647. }
  648. cb && cb(paymentArgs)
  649. // if (paymentArgs.fee === 0) {
  650. // payResult(paymentArgs.payTradeNo, cb)
  651. // } else {
  652. // setStore("paymentArgs", paymentArgs)
  653. // wx.navigateTo({
  654. // url: "plugin://issuer-plugin/payment",
  655. // })
  656. // }
  657. },
  658. () => {
  659. cb && cb()
  660. }
  661. )
  662. }
  663. // 支付
  664. export function pay(paymentArgs, cb) {
  665. if (wx.requestPluginPayment) {
  666. wx.requestPluginPayment({
  667. version: configObj.env,
  668. fee: Number(paymentArgs.fee),
  669. paymentArgs: {
  670. timeStamp: paymentArgs.timeStamp,
  671. nonceStr: paymentArgs.nonceStr,
  672. signType: paymentArgs.signType,
  673. paySign: paymentArgs.paySign,
  674. package: paymentArgs.package,
  675. },
  676. currencyType: "CNY",
  677. success(res) {
  678. appPayResult(paymentArgs.payTradeNo, (result) => {
  679. cb && cb(result)
  680. })
  681. },
  682. fail(res) {
  683. wx.showToast({
  684. title: "支付失败",
  685. icon: "error",
  686. })
  687. cb && cb(false)
  688. },
  689. })
  690. } else {
  691. wx.showModal({
  692. title: "提示",
  693. content: "当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。",
  694. })
  695. }
  696. }
  697. // app支付结果查询
  698. export function appPayResult(payTradeNo, cb) {
  699. let params = {
  700. filename: Api.appPayResult.filename,
  701. data: {
  702. payTradeNo,
  703. },
  704. }
  705. requestFnc(
  706. Api.appPayResult.url,
  707. params,
  708. (res) => {
  709. if (res.tradeStatus == 2) {
  710. cb && cb(true)
  711. } else {
  712. wx.showToast({
  713. title: "支付失败: 状态" + res.tradeStatus,
  714. icon: "error",
  715. })
  716. cb && cb(false)
  717. }
  718. },
  719. () => {
  720. cb && cb(false)
  721. }
  722. )
  723. }
  724. // 支付结果查询
  725. export function payResult(payTradeNo, cb) {
  726. let params = {
  727. filename: Api.payResult.filename,
  728. data: {
  729. accountId: getStore("accountId"),
  730. payTradeNo,
  731. },
  732. }
  733. requestFnc(
  734. Api.payResult.url,
  735. params,
  736. (res) => {
  737. // APP端只签约绑定之后需要下单
  738. if (getStore("wechatSignNo")) {
  739. wx.showModal({
  740. title: "提示",
  741. content: "车辆绑定签约渠道成功",
  742. showCancel: false,
  743. success: (res) => {
  744. if (res.confirm) {
  745. wx.reLaunch({
  746. url: getStore("redirectUrl"),
  747. })
  748. }
  749. },
  750. })
  751. }
  752. cb && cb(res)
  753. },
  754. () => {
  755. cb && cb(false)
  756. }
  757. )
  758. }
  759. // 已签约渠道列表
  760. function signChannelList(cb1, cb2) {
  761. let params = {
  762. filename: Api.signChannelList.filename,
  763. data: {
  764. accountId: getStore("accountId"),
  765. },
  766. }
  767. requestFnc(
  768. Api.signChannelList.url,
  769. params,
  770. (res) => {
  771. let list = res.list || []
  772. if (list.length > 0) {
  773. setStore("signChannelId", list[0].signChannelId)
  774. wx.redirectTo({
  775. url: "plugin://issuer-plugin/delivery-method",
  776. })
  777. } else {
  778. cb1()
  779. }
  780. },
  781. () => {
  782. cb2 && cb2()
  783. }
  784. )
  785. }
  786. //校验获取授权码
  787. export function getApplyReqSender(businessType, cb) {
  788. let params = {
  789. filename: Api.getApplyReqSender.filename,
  790. data: {
  791. accountId: getStore("accountId"),
  792. vehicleId: getStore("vehicleId"),
  793. plateNum: getStore("plateNum"),
  794. plateColor: getStore("plateColor"),
  795. businessType,
  796. },
  797. }
  798. requestFnc(Api.getApplyReqSender.url, params, (res) => {
  799. cb(res.authCode)
  800. })
  801. }
  802. // 获取新办订单详情
  803. function getPreSalesOrderDetail(cb1, cb2) {
  804. let params = {
  805. filename: Api.preSalesOrderDetail.filename,
  806. data: {
  807. orderNo: getStore("orderNo"),
  808. },
  809. }
  810. requestFnc(
  811. Api.preSalesOrderDetail.url,
  812. params,
  813. (res) => {
  814. let data = JSON.parse(res.data)
  815. if (data.length > 0) {
  816. setStore("orderStatus", data[0].orderStatus)
  817. setStore(
  818. "orderDetail",
  819. JSON.stringify({
  820. sendType: `${data[0].orderSendType}`,
  821. ...data[0],
  822. })
  823. )
  824. }
  825. cb1()
  826. },
  827. () => {
  828. cb2 && cb2()
  829. }
  830. )
  831. }
  832. // 获取售后订单详情
  833. function getAfterSalesOrderDetail(cb1, cb2) {
  834. let params = {
  835. filename: Api.afterSalesOrderDetail.filename,
  836. data: {
  837. orderNo: getStore("orderNo"),
  838. },
  839. }
  840. requestFnc(
  841. Api.afterSalesOrderDetail.url,
  842. params,
  843. (res) => {
  844. let data = JSON.parse(res.data)
  845. if (data.length > 0) {
  846. setStore("afterOrderType", `${data[0].orderType}`)
  847. setStore("orderStatus", data[0].orderStatus)
  848. setStore(
  849. "orderDetail",
  850. JSON.stringify({
  851. sendType: `${data[0].orderSendType}`,
  852. ...data[0],
  853. })
  854. )
  855. cb1()
  856. } else {
  857. wx.showModal({
  858. title: "提示",
  859. content: "无售后订单",
  860. showCancel: false,
  861. success(res) {
  862. if (res.confirm) {
  863. wx.navigateBack(1)
  864. }
  865. },
  866. })
  867. }
  868. },
  869. () => {
  870. cb2 && cb2()
  871. }
  872. )
  873. }
  874. // 获取收货地址
  875. export function getAddress(cb, errorCb) {
  876. let params = {
  877. filename: Api.getAddress.filename,
  878. data: {
  879. accountId: getStore("accountId"),
  880. },
  881. }
  882. requestFnc(
  883. Api.getAddress.url,
  884. params,
  885. (res) => {
  886. let adressObj = res.dataModel[0]
  887. cb && cb(adressObj)
  888. },
  889. () => errorCb && errorCb()
  890. )
  891. }
  892. //获取车辆详情
  893. export function getVehicleInformation(cb, errorCb) {
  894. let params = {
  895. filename: Api.getUserQueryReq.filename,
  896. data: {
  897. vehicleId: getStore("vehicleId"),
  898. accountId: getStore("accountId"),
  899. },
  900. }
  901. requestFnc(
  902. Api.getUserQueryReq.url,
  903. params,
  904. (res) => {
  905. let {
  906. data = {}
  907. } = res
  908. cb(data)
  909. },
  910. () => errCb && errCb()
  911. )
  912. }
  913. //获取卡详情
  914. export function getCpuInfo(cb, errorCb) {
  915. let params = {
  916. filename: Api.getCpuInfo.filename,
  917. data: {
  918. accountId: getStore("accountId"),
  919. plateNum: getStore("plateNum"),
  920. plateColor: getStore("plateColor"),
  921. },
  922. }
  923. requestFnc(
  924. Api.getCpuInfo.url,
  925. params,
  926. (res) => {
  927. let {
  928. data = []
  929. } = res
  930. cb(data)
  931. },
  932. () => errorCb && errorCb()
  933. )
  934. }
  935. //获取obu详情
  936. export function getObuInfo(cb, errorCb) {
  937. let params = {
  938. filename: Api.getObuInfo.filename,
  939. data: {
  940. accountId: getStore("accountId"),
  941. plateNum: getStore("plateNum"),
  942. plateColor: getStore("plateColor"),
  943. },
  944. }
  945. requestFnc(
  946. Api.getObuInfo.url,
  947. params,
  948. (res) => {
  949. let {
  950. data = []
  951. } = res
  952. cb(data)
  953. },
  954. () => errorCb && errorCb()
  955. )
  956. }
  957. //获取支付产品列表
  958. function getOrderRenewalPayInfo(cb) {
  959. let params = {
  960. filename: Api.orderRenewalPayInfo.filename,
  961. data: {
  962. vehicleId: getStore("vehicleId"),
  963. accountId: getStore("accountId"),
  964. },
  965. }
  966. requestFnc(Api.orderRenewalPayInfo.url, params, (res) => {
  967. let {
  968. data = ""
  969. } = res
  970. let list = JSON.parse(data)
  971. let productObj = JSON.parse(getStore("productObj"))
  972. setStore("productObj", {
  973. ...productObj,
  974. handleFees: list,
  975. })
  976. cb && cb(list)
  977. })
  978. }
  979. //app拉起签约支付产品
  980. function wechatSignNoOrderRenewalPayInfo(handleFees, cb) {
  981. let fee = handleFees.filter((el) => el.processingAmount === 0)
  982. if (fee.length === handleFees.length) {
  983. //支付金额为0
  984. preOrder({
  985. addressId: "",
  986. sendType: "2",
  987. packageId: JSON.parse(getStore("productObj")).productId,
  988. processingFeeType: "EQUITY_FEE",
  989. cb: (paymentArgs) => {
  990. if (paymentArgs.fee === 0)
  991. payResult(paymentArgs.payTradeNo, cb)
  992. },
  993. })
  994. } else {
  995. let obj = {
  996. accountId: getStore("accountId"),
  997. packageId: JSON.parse(getStore("productObj")).productId,
  998. vehicleId: getStore("vehicleId"),
  999. signChannelId: getStore("signChannelId"),
  1000. wxOpenId: getStore("myWxOpenId"),
  1001. bizType: "1",
  1002. addressId: "",
  1003. sendType: "2",
  1004. }
  1005. wx.navigateTo({
  1006. url: `plugin://issuer-plugin/product-selection?deliveryMethod=${JSON.stringify(
  1007. obj
  1008. )}`,
  1009. })
  1010. }
  1011. }
  1012. function _accountResumesign(cb) {
  1013. let params = {
  1014. filename: Api.accountResumesign.filename,
  1015. data: {
  1016. accountId: getStore("accountId"),
  1017. // productId: JSON.parse(getStore("productObj")).productId,
  1018. preVehicleId: getStore("vehicleId"),
  1019. wxOpenId: getStore("myWxOpenId"),
  1020. notifyAppId: "#",
  1021. notifyPage: "#",
  1022. }
  1023. }
  1024. requestFnc(
  1025. Api.accountResumesign.url,
  1026. params,
  1027. (res) => {
  1028. let {
  1029. signChannelId = ""
  1030. } = res;
  1031. setStore("signChannelId", signChannelId)
  1032. if (res.signStatus === -1) {
  1033. wx.showModal({
  1034. title: "提示",
  1035. content: res.signParameter,
  1036. showCancel: false,
  1037. success: (res) => {
  1038. if (res.confirm) {
  1039. wx.reLaunch({
  1040. url: getStore("redirectUrl"),
  1041. })
  1042. }
  1043. },
  1044. })
  1045. }
  1046. // 已签约
  1047. if (res.signStatus === 1) {
  1048. wx.showModal({
  1049. title: "提示",
  1050. content: "车辆恢复签约已完成",
  1051. showCancel: false,
  1052. success: (res) => {
  1053. if (res.confirm) {
  1054. wx.reLaunch({
  1055. url: getStore("redirectUrl"),
  1056. })
  1057. }
  1058. },
  1059. })
  1060. }
  1061. //未签约
  1062. if (res.signStatus === 0) {
  1063. let signParameter = JSON.parse(res.signParameter)
  1064. let f = signParameter.find(el => el.tradeScene === "HIGHWAY") // 高速
  1065. if (f) {
  1066. let {
  1067. wxVehicleModel = {}
  1068. } = f
  1069. let {
  1070. appId = "", path = "", extraData = {}
  1071. } = wxVehicleModel
  1072. wx.navigateToMiniProgram({
  1073. appId,
  1074. path,
  1075. extraData,
  1076. success(res) {
  1077. setStore("sign", "2")
  1078. console.log("跳转车主小程序")
  1079. },
  1080. fail(res) {
  1081. console.log("未跳转小程序", res)
  1082. },
  1083. })
  1084. }
  1085. }
  1086. cb && cb()
  1087. },
  1088. () => {
  1089. cb && cb()
  1090. }
  1091. )
  1092. }
  1093. // 获取支付信息
  1094. export function getPayInfo(cb) {
  1095. let params = {
  1096. filename: Api.afterPrePay.filename,
  1097. data: {
  1098. accountId: getStore("accountId"),
  1099. vehicleId: getStore("vehicleId"),
  1100. businessType: getStore("afterOrderType"),
  1101. orderNo: getStore("orderNo"),
  1102. wxOpenId: getStore("myWxOpenId"),
  1103. },
  1104. }
  1105. requestFnc(
  1106. Api.createdOrder.url,
  1107. params,
  1108. (res) => {
  1109. let paymentArgs = {
  1110. timeStamp: res.timeStamp + "",
  1111. nonceStr: res.nonceStr,
  1112. signType: res.signType,
  1113. paySign: res.paySign,
  1114. package: res.wxPackage,
  1115. fee: res.money,
  1116. payTradeNo: res.payTradeNo,
  1117. }
  1118. cb(paymentArgs)
  1119. },
  1120. () => {
  1121. cb(false)
  1122. }
  1123. )
  1124. }