index.ts 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. import { FunCode } from "../../../../constants/enum/funcode"
  2. import { sendMsgToMQ } from "../../../../services/api/common/index"
  3. import { queryFworderoperate } from "../../../../services/api/trade/index"
  4. import { userid, loginid, clientType, timetample, loginCode, protoHeader, isEncrypted, taAccount, accountid, getErrorMsg } from "../../../../services/utils"
  5. import { showModel, showLoading, hideLoading } from "../../../../utils/message/index"
  6. import { encryptBody } from "../../../../utils/websocket/crypto"
  7. Page({
  8. /**
  9. * 页面的初始数据
  10. */
  11. data: {
  12. /// 单据信息
  13. orderid: '',
  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,
  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: 4,
  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. /// 计算余额
  120. const {balance, orifreezecharge ,oriotherfreezemargin} = taAccount(accountid())
  121. this.setData({
  122. orderid: options.orderid,
  123. statusdisplay: options.statusdisplay,
  124. status: options.status,
  125. orderno: options.orderno,
  126. /// 设置账户信息
  127. ta: taAccount(accountid()),
  128. /// 当前余额
  129. blance: (balance-orifreezecharge-oriotherfreezemargin).toFixed(2)
  130. })
  131. }
  132. },
  133. /**
  134. * 生命周期函数--监听页面初次渲染完成
  135. */
  136. onReady() {
  137. },
  138. /**
  139. * 生命周期函数--监听页面显示
  140. */
  141. onShow() {
  142. /// 查询保税服务单据操作
  143. this.queryFworderoperate()
  144. },
  145. /**
  146. * 生命周期函数--监听页面隐藏
  147. */
  148. onHide() {
  149. },
  150. /**
  151. * 生命周期函数--监听页面卸载
  152. */
  153. onUnload() {
  154. },
  155. /**
  156. * 页面相关事件处理函数--监听用户下拉动作
  157. */
  158. onPullDownRefresh() {
  159. },
  160. /**
  161. * 页面上拉触底事件的处理函数
  162. */
  163. onReachBottom() {
  164. },
  165. /**
  166. * 用户点击右上角分享
  167. */
  168. onShareAppMessage() {
  169. }
  170. })