index.ts 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. import { FunCode } from "../../../../constants/enum/funcode"
  2. import { sendMsgToMQ } from "../../../../services/api/common/index"
  3. import { accountid, clientType, getErrorMsg, isEncrypted, loginCode, loginid, protoHeader, taAccount, timetample, userid } from "../../../../services/utils"
  4. import { hideLoading, showLoading, showModel } from "../../../../utils/message/index"
  5. import { queryFworderoperate } from "../../../../services/api/trade/index"
  6. import { encryptBody } from "../../../../utils/websocket/crypto"
  7. Page({
  8. /**
  9. * 页面的初始数据
  10. */
  11. data: {
  12. /// 单据信息
  13. orderid: 0,
  14. /// 单据编号
  15. orderno: '',
  16. /// 单据状态
  17. status: 0,
  18. /// 状态描述
  19. statusdisplay: '',
  20. /// 操作信息
  21. operator: <GuangZuan.FworderoperateRsp>({}),
  22. /// 资金账户信息
  23. ta: <GuangZuan.TaAccount>({}),
  24. /// 当前余额
  25. blance: '0.0'
  26. },
  27. /**
  28. * 返回上层视图
  29. */
  30. backToParent() {
  31. /// 返回上层视图
  32. wx.navigateBack()
  33. },
  34. /// 查询保税服务单据操作
  35. queryFworderoperate() {
  36. /// loding...
  37. showLoading(() => {
  38. /// 发送查询请求
  39. queryFworderoperate({
  40. data: {
  41. orderid: this.data.orderid.toString(),
  42. status: this.data.status
  43. },
  44. success: (res) => {
  45. /// hideLoading
  46. hideLoading(() => {
  47. if (res.data.length != 0) {
  48. this.setData({ operator: res.data[0] })
  49. }
  50. })
  51. },
  52. fail: (emsg) => {
  53. hideLoading(() => {}, emsg)
  54. }
  55. })
  56. })
  57. },
  58. /**
  59. * 保税服务操作
  60. */
  61. doBSFWOperator() {
  62. /// showModel
  63. showModel(()=> {
  64. /// showLoading
  65. showLoading(() => {
  66. /// 参数信息
  67. const info = JSON.stringify({
  68. UserID: userid(),
  69. OperateID: loginid(),
  70. ClientType: clientType,
  71. ClientSerialNo: timetample().toString(),
  72. OperateAccount: loginCode().toString(),
  73. OrderID: this.data.orderid,
  74. OperateType: 3,
  75. Header: protoHeader(FunCode.BSFWMemberOperateReq, 66201)
  76. })
  77. /// 发送请求
  78. sendMsgToMQ({
  79. data: {
  80. data: encryptBody(info),
  81. funCodeReq: FunCode.BSFWMemberOperateReq,
  82. funCodeRsp: FunCode.BSFWMemberOperateRsp,
  83. isEncrypted: isEncrypted()
  84. },
  85. success: (res) => {
  86. /// 请求失败
  87. if (res.code ! = 0) {
  88. hideLoading(() => {}, res.msg)
  89. return
  90. }
  91. /// 解析对象
  92. const data = JSON.parse(res.data.data)
  93. if (data.RetCode != 0) {
  94. hideLoading(() => {}, getErrorMsg(data.RetCode))
  95. return
  96. }
  97. hideLoading(() => {
  98. /// 返回上层视图
  99. wx.navigateBack()
  100. }, '操作成功', 'success')
  101. },
  102. fail: (emsg) => {
  103. /// 操作失败
  104. hideLoading(() => {
  105. /// 返回上层视图
  106. wx.navigateBack()
  107. }, emsg)
  108. }
  109. })
  110. }, '请求中.....')
  111. }, '提示', '确认要预付款吗?', true)
  112. },
  113. /**
  114. * 生命周期函数--监听页面加载
  115. */
  116. onLoad(options: any) {
  117. /// 数据解析
  118. if (options.orderid) {
  119. const {balance, orifreezecharge ,oriotherfreezemargin} = taAccount(accountid())
  120. this.setData({
  121. orderid: options.orderid,
  122. statusdisplay: options.statusdisplay,
  123. status: options.status,
  124. orderno: options.orderno,
  125. /// 设置账户信息
  126. ta: taAccount(accountid()),
  127. /// 当前余额
  128. blance: (balance-orifreezecharge-oriotherfreezemargin).toFixed(2)
  129. })
  130. }
  131. /// 查询保税服务单据操作
  132. this.queryFworderoperate()
  133. },
  134. /**
  135. * 生命周期函数--监听页面初次渲染完成
  136. */
  137. onReady() {
  138. },
  139. /**
  140. * 生命周期函数--监听页面显示
  141. */
  142. onShow() {
  143. },
  144. /**
  145. * 生命周期函数--监听页面隐藏
  146. */
  147. onHide() {
  148. },
  149. /**
  150. * 生命周期函数--监听页面卸载
  151. */
  152. onUnload() {
  153. },
  154. /**
  155. * 页面相关事件处理函数--监听用户下拉动作
  156. */
  157. onPullDownRefresh() {
  158. },
  159. /**
  160. * 页面上拉触底事件的处理函数
  161. */
  162. onReachBottom() {
  163. },
  164. /**
  165. * 用户点击右上角分享
  166. */
  167. onShareAppMessage() {
  168. }
  169. })