1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165 |
- /*
- * @Author: gaorf30153 gaorf30153@hundsun.com
- * @Date: 2024-06-24 09:53:36
- * @LastEditors: gaorf30153 gaorf30153@hundsun.com
- * @LastEditTime: 2024-09-10 17:09:00
- * @FilePath: \wxminipro\plugin\utils\commonReq.js
- * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
- */
- import Api from "../api/index.js"
- import {
- getStore,
- removeStore,
- setStore
- } from "./index.js"
- import {
- requestFnc
- } from "./request.js"
- import {
- configObj
- } from "../config.js"
- import {
- encrypt
- } from "./aesutils.js"
-
- // 微信车主签约
- export function wxSign(cb, status) {
- let params = {
- filename: Api.signBank.filename,
- data: {
- accountId: getStore("accountId"),
- productId: JSON.parse(getStore("productObj")).productId,
- preVehicleId: getStore("vehicleId"),
- etcProductId: getStore("etcProductId"),
- signArgs: JSON.stringify({
- openId: getStore("myWxOpenId")
- }),
- signChannelCode: "102",
- notifyAppId: "#",
- notifyPage: "#",
- },
- }
- requestFnc(
- Api.signBank.url,
- params,
- (res) => {
- setStore("signChannelId", res.signChannelId)
- // 已签约未支付
- if (status === 5) {
- getOrderRenewalPayInfo((handleFees) => {
- if (!getStore("wechatSignNo")) {
- wx.redirectTo({
- url: "plugin://issuer-plugin/delivery-method",
- })
- }
- if (getStore("wechatSignNo")) {
- wechatSignNoOrderRenewalPayInfo(handleFees, cb)
- }
- })
- return
- }
-
- // 已签约未绑定
- if (res.signStatus === 1) {
- getSignResult(cb)
- } else {
- let list = JSON.parse(res.signParameter)
- let params = {}
- for (let obj of list) {
- // 高速
- if (obj.tradeScene === "HIGHWAY") {
- params = obj.wxVehicleModel
- }
- }
- console.log("签约参数", params)
- wx.navigateToMiniProgram({
- appId: params.appId,
- path: params.path,
- extraData: params.extraData,
- success(res) {
- setStore("sign", "1")
- console.log("跳转车主小程序")
- },
- fail(res) {
- console.log("未跳转小程序", res)
- },
- })
- cb && cb()
- }
- },
- () => {
- cb && cb()
- }
- )
- }
-
- // 签约结果查询
- export function getSignResult(cb) {
- let params = {
- filename: Api.signResult.filename,
- data: {
- accountId: getStore("accountId"),
- vehicleId: getStore("vehicleId"),
- signArgs: JSON.stringify({
- openId: getStore("myWxOpenId"),
- }),
- signChannelId: getStore("signChannelId"),
- },
- }
- if (getStore("sign") == 2) { //恢复签约
- params.data = {
- ...params.data,
- source: "resumeSign"
- }
- }
-
- requestFnc(
- Api.signResult.url,
- params,
- (res) => {
- if (res.status === 1) {
-
- if (getStore("sign") == 2) { //恢复签约
- wx.showModal({
- title: "提示",
- content: "车辆恢复签约已完成",
- showCancel: false,
- success: (res) => {
- if (res.confirm) {
- wx.reLaunch({
- url: getStore("redirectUrl"),
- })
- }
- },
- })
- } else {
- bindSignChannel(cb)
- }
- } else {
- if (getStore("sign") === 2) { //恢复签约
- wx.showModal({
- title: "提示",
- content: "签约失败, 请重新签约",
- showCancel: false,
- success: (res) => {
- if (res.confirm) {
- wx.reLaunch({
- url: getStore("redirectUrl"),
- })
- }
- },
- })
- } else {
- wx.showToast({
- title: "签约失败, 请重新签约",
- icon: "none",
- })
- }
-
- cb && cb()
- }
- removeStore("sign")
- },
- () => {
- cb && cb()
- }
- )
- }
-
- // 校验车辆状态
- export function checkCarStatus(cb) {
- getCarStatus((status) => {
- // 不存在
- if (status === 0) {
- wx.showModal({
- title: "提示",
- content: "该车辆不存在",
- showCancel: false,
- success(res) {
- if (res.confirm) {
- wx.navigateBack(1)
- }
- },
- })
- cb && cb()
- return
- }
- // 已完成
- if (status === 1) {
- wx.showModal({
- title: "提示",
- content: "该车辆已完成办理",
- showCancel: false,
- success(res) {
- if (res.confirm) {
- wx.navigateBack(1)
- }
- },
- })
- cb && cb()
- return
- }
- // 上传车主证件
- if (status === 2) {
- // wx.showModal({
- // title: "提示",
- // content: text,
- // confirmText: "传身份证",
- // cancelText: "传企业证",
- // success(res) {
- // if (res.confirm) {
- // wx.redirectTo({
- // url: "plugin://issuer-plugin/uploadPersion?type=carOwners",
- // })
- // } else if (res.cancel) {
- // wx.redirectTo({
- // url: "plugin://issuer-plugin/uploadCorp?type=carOwners",
- // })
- // }
- // },
- // })
- cb && cb(status)
- return
- }
- // 未签约或已签约未绑定
- if (status === 4) {
- //app扫码签约
- if (getStore("wechatSignNo")) {
- wx.showModal({
- title: "提示",
- content: "即将前往微信车主认证",
- confirmColor: "#00B38B",
- confirmText: "前往认证",
- success(res) {
- if (res.confirm) {
- wxSign(cb)
- } else if (res.cancel) {
- wx.reLaunch({
- url: getStore("redirectUrl"),
- })
- }
- },
- })
- } else {
- wxSign(cb)
- }
-
- return
- }
- // 未下单未支付
- if (status === 5) {
- wxSign(cb, status)
- return
- }
-
- // 未二发
- if (status === 6) {
- if (getStore("wechatSignNo")) {
- wx.showModal({
- title: "提示",
- content: "车辆绑定签约支付已完成",
- showCancel: false,
- success: (res) => {
- if (res.confirm) {
- wx.reLaunch({
- url: getStore("redirectUrl"),
- })
- }
- },
- })
- } else {
- wx.redirectTo({
- url: "plugin://issuer-plugin/device-act-guidance?activeCode=6",
- })
- }
-
- return
- }
- // 已二发未激活
- if (status === 7) {
- wx.redirectTo({
- url: "plugin://issuer-plugin/device-act-guidance?activeCode=7",
- })
- return
- }
- }, cb)
- }
-
- // 获取车辆办理状态
- function getCarStatus(cb1, cb2) {
- let params = {
- filename: Api.carHandle.filename,
- data: {
- vehicleId: getStore("vehicleId"),
- accountId: getStore("accountId"),
- },
- }
- console.log("查询车辆办理状态", params.data)
- requestFnc(
- Api.carHandle.url,
- params,
- (res) => {
- let {
- etcProductId = ""
- } = res
- setStore("etcProductId", etcProductId)
- // 续办
- if (getStore("handleType") === "continuation") {
- cb1(res.status)
- return
- }
- // 重新激活
- if (getStore("handleType") === "reactivate") {
- if (res.status === 1) {
- wx.redirectTo({
- url: "plugin://issuer-plugin/device-act-guidance?activeCode=7",
- })
- } else {
- wx.showModal({
- title: "提示",
- content: "该车辆未完成办理",
- showCancel: false,
- success(res) {
- if (res.confirm) {
- wx.navigateBack(1)
- }
- },
- })
- }
- cb2 && cb2()
- return
- }
- //恢复签约
- if (getStore("handleType") === "resumeSigning") {
- if (res.status === 1) {
- _accountResumesign(cb2)
- } else {
- wx.showModal({
- title: "提示",
- content: "该车辆未完成办理",
- showCancel: false,
- success(res) {
- if (res.confirm) {
- wx.reLaunch({
- url: getStore("redirectUrl"),
- })
- }
- },
- })
- cb2 && cb2()
- }
- return
- }
- // 售后(包含新办的退货,换货,补货)
- if (getStore("handleType") === "aftersale") {
- let type = getStore("afterType")
- if (!type) {
- wx.showModal({
- title: "提示",
- content: "售后类型缺失",
- showCancel: false,
- success(res) {
- if (res.confirm) {
- wx.navigateBack(1)
- }
- },
- })
- cb2 && cb2()
- return
- }
- // 续期,挂失,解挂,注销需要校验车辆状态,不需要校验订单状态
- if (res.status === 1) {
- // 续期
- if (type === "4") {
- wx.redirectTo({
- url: "plugin://issuer-plugin/renewal-connecting",
- })
- return
- // 注销
- } else if (type === "6") {
- wx.redirectTo({
- url: "plugin://issuer-plugin/logOff",
- })
- return
- } else if (type === "1") {
- // 挂失/解挂
- wx.redirectTo({
- url: "plugin://issuer-plugin/devApplyReplace",
- })
- return
- }
- } else if (type !== "7" && type !== "8" && type !== "9") {
- wx.showModal({
- title: "提示",
- content: "该车辆未完成办理",
- showCancel: false,
- success(res) {
- if (res.confirm) {
- wx.navigateBack(1)
- }
- },
- })
- cb2 && cb2()
- return
- }
- // 新办
- if (getStore("orderType") === "1") {
- // 新办订单办理类型校验
- getPreSalesOrderDetail(() => {
- dealAfter(type)
- }, cb2)
- } else if (getStore("orderType") === "2") {
- // 售后订单办理
- getAfterSalesOrderDetail(() => {
- if (res.status === 1) {
- dealAfter(type)
- } else {
- wx.showModal({
- title: "提示",
- content: "该车辆未完成办理",
- showCancel: false,
- success(res) {
- if (res.confirm) {
- wx.navigateBack(1)
- }
- },
- })
- cb2 && cb2()
- }
- }, cb2)
- } else {
- wx.showModal({
- title: "提示",
- content: "未查询到订单类型",
- showCancel: false,
- success(res) {
- if (res.confirm) {
- wx.navigateBack(1)
- }
- },
- })
- cb2 && cb2()
- }
- }
- //APP拉起前签约
- if (getStore("wechatSignNo")) {
- cb1(res.status)
- return
- }
- },
- (msg) => {
- cb2 && cb2()
- }
- )
- }
-
- // 售后处理
- function dealAfter(type) {
- // 退货、换货、补货
- if (type === "7" || type === "8" || type === "9") {
- // 还要结合订单状态
- const orderStatus = getStore("orderStatus")
- console.log("工单状态 2333----", orderStatus)
- if (orderStatus == "4" || orderStatus == "5" || orderStatus == "6") {
- // 已发货,才能申请 退、换、补
- wx.redirectTo({
- url: "plugin://issuer-plugin/applyExchange",
- })
- } else {
- wx.redirectTo({
- url: "plugin://issuer-plugin/exchangeDetail",
- })
- }
- return
- }
- // 更换、补办
- if (type === "3" || type === "5") {
- // 14-卡补办 15-OBU补办 16-卡更换 17-OBU更换 18-卡和OBU更换
- let afterOrderType = getStore("afterOrderType")
- let orderStatus = getStore("orderStatus")
- // 3 审核不通过 5 已激活 6 取消订单
- if (orderStatus == "3" || orderStatus == "5" || orderStatus == "6") {
- wx.redirectTo({
- url: "plugin://issuer-plugin/devApplyReplace",
- })
- } else {
- if (afterOrderType == "14" || afterOrderType == "15") {
- wx.redirectTo({
- url: `plugin://issuer-plugin/divReissue?type=${
- afterOrderType == "14" ? 1 : 2
- }`,
- })
- }
- if (
- afterOrderType == "16" ||
- afterOrderType == "17" ||
- afterOrderType == "18"
- ) {
- wx.redirectTo({
- url: `plugin://issuer-plugin/deviceReplace?type=${
- afterOrderType == "16"
- ? 1
- : afterOrderType == "17"
- ? 2
- : 3
- }`,
- })
- }
- }
- }
- }
-
- // 获取账户列表
- export function getAccountList(cb1, cb2) {
- let params = {
- filename: Api.getAccountList.filename,
- data: {},
- }
- requestFnc(
- Api.getAccountList.url,
- params,
- (res) => {
- let list = JSON.parse(res.data)
- let hasPersion = false
- let integralFlag = 1
-
- for (let obj of list) {
- if (obj.accountType == "1" && obj.idType === "101") {
- setStore("persionAccountId", obj.accountId)
- if (getStore("accountType") == "1") {
- setStore("accountId", obj.accountId)
- }
- hasPersion = true
- integralFlag = obj.integralFlag
- }
- }
- cb1 && cb1(hasPersion, list, integralFlag)
- },
- (msg) => {
- cb2 && cb2()
- }
- )
- }
-
- // 获取车辆列表
- function getCarList(cb1, cb2) {
- let params = {
- filename: Api.getCarList.filename,
- data: {
- accountId: getStore("accountId"),
- pageNo: 1,
- pageSize: 99,
- },
- }
- requestFnc(
- Api.getCarList.url,
- params,
- (res) => {
- let carList = JSON.parse(res.encryptedData)
- let hasCar = false
- for (let obj of carList) {
- if (obj.vehicleId === getStore("vehicleId")) {
- hasCar = true
- setStore("plateNum", obj.plateNum)
- setStore("plateColor", `${obj.plateColor}`)
- getCarStatus(cb1, cb2)
- }
- }
- if (!hasCar) {
- wx.showModal({
- title: "提示",
- content: "当前账户下无该车辆",
- showCancel: false,
- success(res) {
- if (res.confirm) {
- wx.navigateBack(1)
- }
- },
- })
- cb2 && cb2()
- }
- },
- (msg) => {
- cb2 && cb2()
- }
- )
- }
-
- // 关联签约渠道
- function bindSignChannel(cb) {
- let productId = JSON.parse(getStore("productObj")).productId
- let params = {
- filename: Api.bindSignChannel.filename,
- data: {
- accountId: getStore("accountId"),
- vehicleId: getStore("vehicleId"),
- signChannelId: getStore("signChannelId"),
- code: encrypt(productId, configObj.aesKey),
- validType: "2",
- },
- }
- requestFnc(
- Api.bindSignChannel.url,
- params,
- (res) => {
- // APP端只签约绑定之后需要下单
- if (getStore("wechatSignNo")) {
- getOrderRenewalPayInfo((handleFees) => {
- wechatSignNoOrderRenewalPayInfo(handleFees, cb)
- })
- } else {
- wx.redirectTo({
- url: "plugin://issuer-plugin/delivery-method",
- })
- }
- },
- () => {
- cb && cb()
- }
- )
- }
-
- // 创建支付订单
- function preOrder({
- addressId,
- sendType,
- packageId,
- processingFeeType,
- cb
- }) {
- console.log("----preOrder1111-----", {
- addressId,
- sendType,
- packageId,
- processingFeeType,
- })
- let params = {
- filename: Api.preOrder.filename,
- data: {
- accountId: getStore("accountId"),
- packageId,
- vehicleId: getStore("vehicleId"),
- signChannelId: getStore("signChannelId"),
- wxOpenId: getStore("myWxOpenId"),
- bizType: "1",
- addressId,
- sendType,
- processingFeeType,
- payRouteCode: "04"
- },
- }
- console.log("----preOrder2222-----", params)
- requestFnc(
- Api.preOrder.url,
- params,
- (res) => {
- let paymentArgs = {
- timeStamp: res.timeStamp + "",
- nonceStr: res.nonceStr,
- signType: res.signType,
- paySign: res.paySign,
- package: res.wxPackage,
- fee: res.money,
- payTradeNo: res.payTradeNo,
- }
- cb && cb(paymentArgs)
-
- // if (paymentArgs.fee === 0) {
- // payResult(paymentArgs.payTradeNo, cb)
- // } else {
- // setStore("paymentArgs", paymentArgs)
- // wx.navigateTo({
- // url: "plugin://issuer-plugin/payment",
- // })
- // }
- },
- () => {
- cb && cb()
- }
- )
- }
-
- // 支付
- export function pay(paymentArgs, cb) {
-
- if (wx.requestPluginPayment) {
- wx.requestPluginPayment({
- version: configObj.env,
- fee: Number(paymentArgs.fee),
- paymentArgs: {
- timeStamp: paymentArgs.timeStamp,
- nonceStr: paymentArgs.nonceStr,
- signType: paymentArgs.signType,
- paySign: paymentArgs.paySign,
- package: paymentArgs.package,
- },
- currencyType: "CNY",
- success(res) {
- appPayResult(paymentArgs.payTradeNo, (result) => {
- cb && cb(result)
- })
- },
- fail(res) {
- wx.showToast({
- title: "支付失败",
- icon: "error",
- })
- cb && cb(false)
- },
- })
- } else {
- wx.showModal({
- title: "提示",
- content: "当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。",
- })
- }
- }
-
- // app支付结果查询
- export function appPayResult(payTradeNo, cb) {
- let params = {
- filename: Api.appPayResult.filename,
- data: {
- payTradeNo,
- },
- }
- requestFnc(
- Api.appPayResult.url,
- params,
- (res) => {
- if (res.tradeStatus == 2) {
- cb && cb(true)
- } else {
- wx.showToast({
- title: "支付失败: 状态" + res.tradeStatus,
- icon: "error",
- })
- cb && cb(false)
- }
- },
- () => {
- cb && cb(false)
- }
- )
- }
-
- // 支付结果查询
- export function payResult(payTradeNo, cb) {
- let params = {
- filename: Api.payResult.filename,
- data: {
- accountId: getStore("accountId"),
- payTradeNo,
- },
- }
- requestFnc(
- Api.payResult.url,
- params,
- (res) => {
- // APP端只签约绑定之后需要下单
- if (getStore("wechatSignNo")) {
- wx.showModal({
- title: "提示",
- content: "车辆绑定签约渠道成功",
- showCancel: false,
- success: (res) => {
- if (res.confirm) {
- wx.reLaunch({
- url: getStore("redirectUrl"),
- })
- }
- },
- })
- }
- cb && cb(res)
- },
- () => {
- cb && cb(false)
- }
- )
- }
-
- // 已签约渠道列表
- function signChannelList(cb1, cb2) {
- let params = {
- filename: Api.signChannelList.filename,
- data: {
- accountId: getStore("accountId"),
- },
- }
- requestFnc(
- Api.signChannelList.url,
- params,
- (res) => {
- let list = res.list || []
- if (list.length > 0) {
- setStore("signChannelId", list[0].signChannelId)
- wx.redirectTo({
- url: "plugin://issuer-plugin/delivery-method",
- })
- } else {
- cb1()
- }
- },
- () => {
- cb2 && cb2()
- }
- )
- }
-
- //校验获取授权码
- export function getApplyReqSender(businessType, cb) {
- let params = {
- filename: Api.getApplyReqSender.filename,
- data: {
- accountId: getStore("accountId"),
- vehicleId: getStore("vehicleId"),
- plateNum: getStore("plateNum"),
- plateColor: getStore("plateColor"),
- businessType,
- },
- }
-
- requestFnc(Api.getApplyReqSender.url, params, (res) => {
- cb(res.authCode)
- })
- }
-
- // 获取新办订单详情
- function getPreSalesOrderDetail(cb1, cb2) {
- let params = {
- filename: Api.preSalesOrderDetail.filename,
- data: {
- orderNo: getStore("orderNo"),
- },
- }
- requestFnc(
- Api.preSalesOrderDetail.url,
- params,
- (res) => {
- let data = JSON.parse(res.data)
- if (data.length > 0) {
- setStore("orderStatus", data[0].orderStatus)
- setStore(
- "orderDetail",
- JSON.stringify({
- sendType: `${data[0].orderSendType}`,
- ...data[0],
- })
- )
- }
- cb1()
- },
- () => {
- cb2 && cb2()
- }
- )
- }
-
- // 获取售后订单详情
- function getAfterSalesOrderDetail(cb1, cb2) {
- let params = {
- filename: Api.afterSalesOrderDetail.filename,
- data: {
- orderNo: getStore("orderNo"),
- },
- }
- requestFnc(
- Api.afterSalesOrderDetail.url,
- params,
- (res) => {
- let data = JSON.parse(res.data)
- if (data.length > 0) {
- setStore("afterOrderType", `${data[0].orderType}`)
- setStore("orderStatus", data[0].orderStatus)
- setStore(
- "orderDetail",
- JSON.stringify({
- sendType: `${data[0].orderSendType}`,
- ...data[0],
- })
- )
- cb1()
- } else {
- wx.showModal({
- title: "提示",
- content: "无售后订单",
- showCancel: false,
- success(res) {
- if (res.confirm) {
- wx.navigateBack(1)
- }
- },
- })
- }
- },
- () => {
- cb2 && cb2()
- }
- )
- }
-
- // 获取收货地址
- export function getAddress(cb, errorCb) {
- let params = {
- filename: Api.getAddress.filename,
- data: {
- accountId: getStore("accountId"),
- },
- }
- requestFnc(
- Api.getAddress.url,
- params,
- (res) => {
- let adressObj = res.dataModel[0]
- cb && cb(adressObj)
- },
- () => errorCb && errorCb()
- )
- }
-
- //获取车辆详情
- export function getVehicleInformation(cb, errorCb) {
- let params = {
- filename: Api.getUserQueryReq.filename,
- data: {
- vehicleId: getStore("vehicleId"),
- accountId: getStore("accountId"),
- },
- }
-
- requestFnc(
- Api.getUserQueryReq.url,
- params,
- (res) => {
- let {
- data = {}
- } = res
- cb(data)
- },
- () => errCb && errCb()
- )
- }
-
- //获取卡详情
- export function getCpuInfo(cb, errorCb) {
- let params = {
- filename: Api.getCpuInfo.filename,
- data: {
- accountId: getStore("accountId"),
- plateNum: getStore("plateNum"),
- plateColor: getStore("plateColor"),
- },
- }
- requestFnc(
- Api.getCpuInfo.url,
- params,
- (res) => {
- let {
- data = []
- } = res
- cb(data)
- },
- () => errorCb && errorCb()
- )
- }
-
- //获取obu详情
- export function getObuInfo(cb, errorCb) {
- let params = {
- filename: Api.getObuInfo.filename,
- data: {
- accountId: getStore("accountId"),
- plateNum: getStore("plateNum"),
- plateColor: getStore("plateColor"),
- },
- }
- requestFnc(
- Api.getObuInfo.url,
- params,
- (res) => {
- let {
- data = []
- } = res
- cb(data)
- },
- () => errorCb && errorCb()
- )
- }
-
- //获取支付产品列表
- function getOrderRenewalPayInfo(cb) {
- let params = {
- filename: Api.orderRenewalPayInfo.filename,
- data: {
- vehicleId: getStore("vehicleId"),
- accountId: getStore("accountId"),
- },
- }
- requestFnc(Api.orderRenewalPayInfo.url, params, (res) => {
- let {
- data = ""
- } = res
-
- let list = JSON.parse(data)
- let productObj = JSON.parse(getStore("productObj"))
- setStore("productObj", {
- ...productObj,
- handleFees: list,
- })
- cb && cb(list)
- })
- }
- //app拉起签约支付产品
- function wechatSignNoOrderRenewalPayInfo(handleFees, cb) {
- let fee = handleFees.filter((el) => el.processingAmount === 0)
- if (fee.length === handleFees.length) {
- //支付金额为0
- preOrder({
- addressId: "",
- sendType: "2",
- packageId: JSON.parse(getStore("productObj")).productId,
- processingFeeType: "EQUITY_FEE",
- cb: (paymentArgs) => {
- if (paymentArgs.fee === 0)
- payResult(paymentArgs.payTradeNo, cb)
- },
- })
- } else {
- let obj = {
- accountId: getStore("accountId"),
- packageId: JSON.parse(getStore("productObj")).productId,
- vehicleId: getStore("vehicleId"),
- signChannelId: getStore("signChannelId"),
- wxOpenId: getStore("myWxOpenId"),
- bizType: "1",
- addressId: "",
- sendType: "2",
- }
- wx.navigateTo({
- url: `plugin://issuer-plugin/product-selection?deliveryMethod=${JSON.stringify(
- obj
- )}`,
- })
- }
- }
-
- function _accountResumesign(cb) {
-
- let params = {
- filename: Api.accountResumesign.filename,
- data: {
- accountId: getStore("accountId"),
- // productId: JSON.parse(getStore("productObj")).productId,
- preVehicleId: getStore("vehicleId"),
- wxOpenId: getStore("myWxOpenId"),
- notifyAppId: "#",
- notifyPage: "#",
- }
- }
- requestFnc(
- Api.accountResumesign.url,
- params,
- (res) => {
-
- let {
- signChannelId = ""
- } = res;
- setStore("signChannelId", signChannelId)
-
- if (res.signStatus === -1) {
- wx.showModal({
- title: "提示",
- content: res.signParameter,
- showCancel: false,
- success: (res) => {
- if (res.confirm) {
- wx.reLaunch({
- url: getStore("redirectUrl"),
- })
- }
- },
- })
- }
-
- // 已签约
- if (res.signStatus === 1) {
- wx.showModal({
- title: "提示",
- content: "车辆恢复签约已完成",
- showCancel: false,
- success: (res) => {
- if (res.confirm) {
- wx.reLaunch({
- url: getStore("redirectUrl"),
- })
- }
- },
- })
- }
- //未签约
- if (res.signStatus === 0) {
-
- let signParameter = JSON.parse(res.signParameter)
- let f = signParameter.find(el => el.tradeScene === "HIGHWAY") // 高速
- if (f) {
- let {
- wxVehicleModel = {}
- } = f
- let {
- appId = "", path = "", extraData = {}
- } = wxVehicleModel
- wx.navigateToMiniProgram({
- appId,
- path,
- extraData,
- success(res) {
- setStore("sign", "2")
- console.log("跳转车主小程序")
- },
- fail(res) {
- console.log("未跳转小程序", res)
- },
- })
- }
-
- }
- cb && cb()
- },
- () => {
- cb && cb()
- }
- )
- }
- // 获取支付信息
- export function getPayInfo(cb) {
- let params = {
- filename: Api.afterPrePay.filename,
- data: {
- accountId: getStore("accountId"),
- vehicleId: getStore("vehicleId"),
- businessType: getStore("afterOrderType"),
- orderNo: getStore("orderNo"),
- wxOpenId: getStore("myWxOpenId"),
- },
- }
- requestFnc(
- Api.createdOrder.url,
- params,
- (res) => {
- let paymentArgs = {
- timeStamp: res.timeStamp + "",
- nonceStr: res.nonceStr,
- signType: res.signType,
- paySign: res.paySign,
- package: res.wxPackage,
- fee: res.money,
- payTradeNo: res.payTradeNo,
- }
- cb(paymentArgs)
- },
- () => {
- cb(false)
- }
- )
- }
|