utils.ts 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. import { queryGetDivisions } from "./api/common/index";
  2. import { getTaAccounts } from './api/account/index';
  3. import { v4 } from "../store/utils/uuid/index";
  4. import { IMessageHead } from './../services/socket/trade/protobuf/proto';
  5. import Toast from "../miniprogram_npm/@vant/weapp/toast/toast";
  6. /// 获取履约步骤类型ID
  7. export function getSteptype(typeid: number): string {
  8. switch (typeid) {
  9. case 1:
  10. return '买方支付'
  11. break;
  12. case 2:
  13. return '卖方收款'
  14. break;
  15. case 3:
  16. return '买方自提'
  17. break;
  18. case 4:
  19. return '卖方发货'
  20. break;
  21. case 5:
  22. return '买方确认货'
  23. break;
  24. case 6:
  25. return '卖方发票'
  26. break;
  27. case 7:
  28. return '买方确认票'
  29. break;
  30. case 8:
  31. return '卖仓单转移'
  32. break;
  33. case 9:
  34. return '释放卖方冻结'
  35. break;
  36. case 10:
  37. return '货款溢短'
  38. break;
  39. case 11:
  40. return '生成合同[中江]'
  41. break;
  42. case 12:
  43. return '运费'
  44. break;
  45. case 90:
  46. return '确认支付'
  47. break;
  48. case 91:
  49. return '确认放行'
  50. break;
  51. default:
  52. return '买方支付(直接扣款)'
  53. break;
  54. }
  55. }
  56. /// 获取履约状态
  57. export function getPerformancestatus(status: number): string {
  58. switch (status) {
  59. case 1:
  60. return '待激活'
  61. break;
  62. case 2:
  63. return '正常'
  64. break;
  65. case 3:
  66. return '处理错误'
  67. break;
  68. case 4:
  69. return '违约待处理'
  70. break;
  71. case 5:
  72. return '违约处理中'
  73. break;
  74. case 6:
  75. return '完成'
  76. break;
  77. case 7:
  78. return '违约已完成'
  79. break;
  80. case 8:
  81. return '释放冻结失败 '
  82. break;
  83. case 9:
  84. return '超时待处理'
  85. break;
  86. default:
  87. return '超时关闭'
  88. break;
  89. }
  90. }
  91. /// 获取出境检测执行状态
  92. export function getExecutestatus(status: number) {
  93. switch (status) {
  94. case 1:
  95. return '未生效'
  96. break;
  97. case 2:
  98. return '进行中'
  99. break;
  100. default:
  101. return '已结束'
  102. break;
  103. }
  104. }
  105. /// 获取地区区域信息
  106. export function getDivisions() {
  107. /// 发送请求
  108. queryGetDivisions({
  109. enableAuthorization: false,
  110. success: (res) => {
  111. /// 数据缓存
  112. wx.setStorageSync('GetDivisions', res.data)
  113. },
  114. fail: () => {
  115. Toast('地区信息获取失败')
  116. }
  117. })
  118. }
  119. /// 获取资金账户信息
  120. export function taAccounts() {
  121. /// 发送请求
  122. getTaAccounts({
  123. data: {
  124. loginID: loginid()
  125. },
  126. success: (res) => {
  127. /// 数据缓存
  128. wx.setStorageSync('GetTaAccounts', res.data)
  129. wx.setStorageSync('AccountID', res.data[0].accountid)
  130. },
  131. fail: () => {
  132. Toast('资金账户信息获取失败')
  133. }
  134. })
  135. }
  136. /// 获取登录Loginid
  137. export function loginid() {
  138. return wx.getStorageSync('LoginID')
  139. }
  140. /// 获取用户userid
  141. export function userid() {
  142. return wx.getStorageSync('UserId')
  143. }
  144. /// 获取资金用户ID
  145. export function accountid() {
  146. return wx.getStorageSync('AccountID')
  147. }
  148. /// 获取用户Token
  149. export function xtoken() {
  150. return wx.getStorageSync('Authorization')
  151. }
  152. /// 获取市场id
  153. export function marketid() {
  154. return wx.getStorageSync('MarketID')
  155. }
  156. /// 是否加密
  157. export function isEncrypted() {
  158. return false
  159. }
  160. /// 获取地区信息
  161. export function divisions() {
  162. return wx.getStorageSync('GetDivisions')
  163. }
  164. /// 终端类型
  165. export function clientType() {
  166. return 5
  167. }
  168. /// 返回proto交易头
  169. export function protoHeader(funcode: number) {
  170. /// 组合请求头
  171. const header: IMessageHead = {
  172. FunCode: funcode,
  173. AccountID: accountid(),
  174. UserID: userid(),
  175. MarketID: marketid(),
  176. UUID: v4()
  177. }
  178. return header
  179. }
  180. /// 获取时间戳
  181. export function timetample() {
  182. return Date.parse(new Date().toString())
  183. }