index.ts 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. import { FunCode } from "../../../../constants/enum/funcode"
  2. import { sendMsgToMQ } from "../../../../services/api/common/index"
  3. import { queryGzbscReckonOrder } from "../../../../services/api/orders/index"
  4. import { getEnumdicValue, getErrorMsg, isEncrypted, protoHeader, timetample, userid } from "../../../../services/utils"
  5. import { hideLoading, showLoading, showModel } from "../../../../utils/message/index"
  6. import { encryptBody } from "../../../../utils/websocket/crypto"
  7. Page({
  8. /**
  9. * 页面的初始数据
  10. */
  11. data: {
  12. /// 底部安全区域
  13. safeBottom: getApp().globalData.safeBottom,
  14. /// tabs
  15. tabs: [{id: 2, name: '待支付'}, {id: 3, name: '已支付'}],
  16. /// 类别
  17. active: 0,
  18. /// 是否空数据
  19. isEmpty: false,
  20. /// 显示数据信息
  21. values: <{}>[]
  22. },
  23. /**
  24. * 返回上层视图
  25. */
  26. backToParent() {
  27. /// 返回上层视图
  28. wx.navigateBack()
  29. },
  30. onTabChange(e: any) {
  31. // 重置状态
  32. this.setData({ active: e.detail.index })
  33. /// 查询数据
  34. this.queryGzbscReckonOrder()
  35. },
  36. /// 申请支付提交
  37. doPayment(orderID: string) {
  38. /// showModel
  39. showModel(() => {
  40. /// showLoading
  41. showLoading(() => {
  42. /// 请求参数
  43. const info = JSON.stringify({
  44. Header: protoHeader(FunCode.BSWMSReckonPayReq),
  45. UserID: userid(),
  46. OrderID: orderID,
  47. ClientSerialNo: timetample().toString()
  48. })
  49. /// 发送请求
  50. sendMsgToMQ({
  51. data: {
  52. data: encryptBody(info),
  53. funCodeReq: FunCode.BSWMSReckonPayReq,
  54. funCodeRsp: FunCode.BSWMSReckonPayRsp,
  55. isEncrypted: isEncrypted()
  56. },
  57. success: (res) => {
  58. /// 解析对象
  59. const data = JSON.parse(res.data.data)
  60. if (data.RetCode != 0) {
  61. hideLoading(() => {}, getErrorMsg(data.RetCode))
  62. return
  63. }
  64. /// 求购发布请求成功
  65. hideLoading(() => {
  66. wx.navigateBack()
  67. }, '提交支付申请成功', 'success')
  68. },
  69. fail: (emsg) => {
  70. hideLoading(()=>{}, emsg)
  71. }
  72. })
  73. }, '提交申请请求中....')
  74. }, '提示', '确认要提交支付申请吗?')
  75. },
  76. /// 保税仓结算单表查询
  77. queryGzbscReckonOrder() {
  78. /// showLoading
  79. showLoading(() => {
  80. queryGzbscReckonOrder({
  81. data: {
  82. userid: userid(),
  83. paystatus: this.data.active+2
  84. },
  85. success: (res) => {
  86. /// 获取数据
  87. this.setData({
  88. isEmpty: res.data.length === 0,
  89. values: res.data.map(obj => {
  90. return {
  91. servicefee: obj.servicefee,
  92. paystatusdesc: getEnumdicValue('GZBSCPayStatus', obj.paystatus),
  93. paytradedate: obj.paytradedate,
  94. totalfee: obj.totalfee,
  95. storagefee: obj.storagefee,
  96. powerfee: obj.powerfee,
  97. premium: obj.premium,
  98. customsfee: obj.customsfee,
  99. paystatus: obj.paystatus,
  100. paytime: obj.paytime,
  101. orderid: obj.orderid
  102. }
  103. })
  104. })
  105. },
  106. complete: () => {
  107. /// hideLoading
  108. hideLoading()
  109. }
  110. })
  111. })
  112. },
  113. /**
  114. * 生命周期函数--监听页面加载
  115. */
  116. onLoad() {
  117. /// 保税仓结算单表查询
  118. this.queryGzbscReckonOrder()
  119. },
  120. /**
  121. * 生命周期函数--监听页面初次渲染完成
  122. */
  123. onReady() {
  124. },
  125. /**
  126. * 生命周期函数--监听页面显示
  127. */
  128. onShow() {
  129. },
  130. /**
  131. * 生命周期函数--监听页面隐藏
  132. */
  133. onHide() {
  134. },
  135. /**
  136. * 生命周期函数--监听页面卸载
  137. */
  138. onUnload() {
  139. },
  140. /**
  141. * 页面相关事件处理函数--监听用户下拉动作
  142. */
  143. onPullDownRefresh() {
  144. /// 保税仓结算单表查询
  145. this.queryGzbscReckonOrder()
  146. },
  147. /**
  148. * 页面上拉触底事件的处理函数
  149. */
  150. onReachBottom() {
  151. },
  152. /**
  153. * 用户点击右上角分享
  154. */
  155. onShareAppMessage() {
  156. }
  157. })