index.ts 4.2 KB

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