import { queryGetDivisions } from "./api/common/index"; import { getTaAccounts } from './api/account/index'; import { v4 } from "../utils/uuid/index"; import { IMessageHead } from './../services/socket/trade/protobuf/proto'; import Toast from "../miniprogram_npm/@vant/weapp/toast/toast"; /// 获取履约步骤类型ID export function getSteptype(typeid: number): string { switch (typeid) { case 1: return '买方支付' break; case 2: return '卖方收款' break; case 3: return '买方自提' break; case 4: return '卖方发货' break; case 5: return '买方确认货' break; case 6: return '卖方发票' break; case 7: return '买方确认票' break; case 8: return '卖仓单转移' break; case 9: return '释放卖方冻结' break; case 10: return '货款溢短' break; case 11: return '生成合同[中江]' break; case 12: return '运费' break; case 90: return '确认支付' break; case 91: return '确认放行' break; default: return '买方支付(直接扣款)' break; } } /// 获取履约步骤类型ID export function getStepStatus(stepstatus: number): string { switch (stepstatus) { case 1: return '待开始' break; case 2: return '进行中' break; case 3: return '已完成' break; case 4: return '延期(进行中)' break; case 5: return '失败' break; case 6: return '自动完成' break; default: return '超时关闭' break; } } /// 获取履约状态 export function getPerformancestatus(status: number): string { switch (status) { case 1: return '待激活' break; case 2: return '正常' break; case 3: return '处理错误' break; case 4: return '违约待处理' break; case 5: return '违约处理中' break; case 6: return '完成' break; case 7: return '违约已完成' break; case 8: return '释放冻结失败 ' break; case 9: return '超时待处理' break; default: return '超时关闭' break; } } /// 获取出境检测执行状态 export function getExecutestatus(status: number) { switch (status) { case 1: return '未生效' break; case 2: return '进行中' break; default: return '已结束' break; } } /// 获取地区区域信息 export function getDivisions() { /// 发送请求 queryGetDivisions({ enableAuthorization: false, success: (res) => { /// 数据缓存 setDivisions(res.data) }, fail: () => { Toast('地区信息获取失败') } }) } /// 获取资金账户信息 export function taAccounts() { /// 发送请求 getTaAccounts({ data: { loginID: loginid() }, success: (res) => { /// 数据缓存 wx.setStorageSync('GetTaAccounts', res.data) wx.setStorageSync('AccountID', res.data[0].accountid) }, fail: () => { Toast('资金账户信息获取失败') } }) } /// 获取当前对应的资金账户 export function taAccount(accountid: number): GuangZuan.TaAccount { const tas = wx.getStorageSync('GetTaAccounts') return tas.filter(obj => { return obj.accountid === accountid })[0] } /// 获取登录Loginid export function loginid() { return wx.getStorageSync('LoginID') } /// 获取用户userid export function userid() { return wx.getStorageSync('UserId') } /// 获取资金用户ID export function accountid() { return wx.getStorageSync('AccountID') } /// 获取用户Token export function xtoken() { return wx.getStorageSync('Authorization') } /// 获取市场id export function marketid() { return wx.getStorageSync('MarketID') } /// 是否加密 export function isEncrypted() { return false } /// 存储地区信息 export function setDivisions(datas: GuangZuan.GetDivisions[]) { wx.setStorageSync('GetDivisions', datas) } /// 获取地区信息 export function divisions() { return wx.getStorageSync('GetDivisions') } /// 终端类型 export function clientType() { return 5 } /// 返回proto交易头 export function protoHeader(funcode: number, marketID: number = marketid()) { /// 组合请求头 const header: IMessageHead = { FunCode: funcode, AccountID: accountid(), UserID: userid(), MarketID: marketID, UUID: v4() } return header } /// 获取时间戳 export function timetample() { return Date.parse(new Date().toString()) } /// 获取登录查询数据信息 export function loginQuery(): GuangZuan.LoginQuery { const data = wx.getStorageSync('LoginQuery') return data } /// 获取登录账号 export function loginCode(): string { const code = (wx.getStorageSync('LoginQuery')).loginAccount.logincode return code === '' ? loginid() : code } /// 存储所有的枚举信息 export function setAllEnums(enums: GuangZuan.AllEnums[]) { wx.setStorageSync('AllEnums', enums) } export function getAllEnums(): GuangZuan.AllEnums[] { const objs = <[GuangZuan.AllEnums]>wx.getStorageSync('AllEnums') return objs } export function getEnumList(enumdiccode: string): GuangZuan.AllEnums[] { const objs = getAllEnums().filter(obj => { return obj.enumdiccode === enumdiccode }) return objs } /// 获取对应枚举的值 export function getEnumdicValue(enumdiccode: string, enumdicname: string): number { const objs = getEnumList(enumdiccode) if (objs.length != 0) { const enums = objs.filter(obj => { return obj.enumdicname === enumdicname }) return enums.filter(obj => { return obj.enumdicname === enumdicname })[0].enumitemname } return 0 }