import { getStore, setStore } from "./index.js" import { requestEtcFnc, } from './requestEtc' import Api from '../api/etc-api' export async function etcWxSign() { const { orderId = '', openId = '', } = arguments[0] || {} const accessToken = getStore("etc-accessToken") || "token" let myWxOpenId = getStore("myWxOpenId") const params = { subOpenId: myWxOpenId, orderId, openId, accessToken: accessToken, loginSource: "69af303ba2eb4608a099163f0d2a5dbd" } const res = await requestEtcFnc(Api.userSignQuery, { data: params, }) return res } export async function apiIssueApply() { const { orderId, cardId, obuId, } = arguments[0] const params = { orderId, agentId: "52010106004", loginSource: "69af303ba2eb4608a099163f0d2a5dbd", channelId: "5201010200601130001", channelType: 1, issueType: 1, cardId, obuId, } const res = await requestEtcFnc(Api.issueApply, { data: params, isNeedAuth: false, }) return res } export async function apiIssueCallback() { const { transOrderId, cmd, cmdResult, stepNo, } = arguments[0] const params = { transOrderId, // openId, agentId: "52010106004", loginSource: "69af303ba2eb4608a099163f0d2a5dbd", channelId: "5201010200601130001", channelType: 1, cmd, cmdResult, stepNo, staffId: "54623263cb4d4a289dccbc983b22a4af", } const res = await requestEtcFnc(Api.issueCallback, { data: params, isNeedAuth: false, }) return res } export async function repaetGetOpenId(jsCode) { const res = await requestEtcFnc(Api.getOpenId, { data: { jsCode: jsCode }, isNeedAuth: false, }) if (res.code == 0) { const data = res.data.data if (data) { const info = JSON.parse(data) console.log(info); const openId = info.openId; setStore("myWxOpenId", openId) } } else { wx.hideLoading() wx.showToast({ title: res.message || "登录失败,请稍后重试", icon: false, }); } return res.code; } export async function repeatLogin() { const openId = getStore('etc-openId') const accessToken = getStore("etc-accessToken") || "token" const params = { openId, accessToken, } const res = await requestEtcFnc(Api.phoneLogin, { data: params, isNeedAuth: false, }) if (res.code == 0) { const { accessToken, openId, } = res.data setStore('etc-accessToken', accessToken) setStore('etc-openId', openId) } return res } export async function contractQuery() { const { orderId, } = arguments[0] const res = await requestEtcFnc(Api.contractQuery, { data: { orderId, }, isNeedAuth: false, }) return res } export async function accountSign() { const { orderId, } = arguments[0] const res = await requestEtcFnc(Api.accountSign, { data: { orderId, orderSource: "CHANNEL" }, isNeedAuth: false, }) return res }