index.ts 4.4 KB

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