index.ts 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. import { EOrderSrc } from "../../../constants/enum/index"
  2. import { FunCode } from "../../../constants/enum/funcode"
  3. import { sendMsgToMQ } from "../../../services/api/common/index"
  4. import { queryPermancePlanTmp } from "../../../services/api/orders/index"
  5. import { accountid, clientType, getErrorMsg, isEncrypted, loginid, marketid, protoHeader, timetample, userid } from "../../../services/utils"
  6. import { hideLoading, showLoading, showModel } from "../../../utils/message/index"
  7. import { encryptBody } from "../../../utils/websocket/crypto"
  8. import { formatDateString } from "../../../utils/util"
  9. Page({
  10. /**
  11. * 页面的初始数据
  12. */
  13. data: {
  14. /// 单据信息
  15. order: <GuangZuan.BuyOrder>({}),
  16. /// 选中履约模板
  17. tmp: <GuangZuan.PermancePlanTmp>({}),
  18. /// 颜色
  19. colors: ['rebeccapurple', 'green', 'hotpink', 'orange', 'darkgoldenrod', 'firebrick'],
  20. /// 资金账户ID
  21. accountid: accountid()
  22. },
  23. /**
  24. * 返回上层视图
  25. */
  26. backToParent() {
  27. /// 返回上层视图
  28. wx.navigateBack()
  29. },
  30. /// 进行摘卖
  31. goToDelistingSell() {
  32. /// 摘卖
  33. wx.navigateTo({
  34. url: '/mTrade/pages/delistingsell/index?item='+JSON.stringify(this.data.order)
  35. })
  36. },
  37. /// 获取履约模板信息
  38. queryPermancePlanTmp() {
  39. /// showLoading
  40. showLoading(() => {
  41. queryPermancePlanTmp({
  42. success: (res) => {
  43. /// 获取数据
  44. this.setData({
  45. tmps: res.data,
  46. tmp: res.data[0],
  47. actions: res.data.map(obj => { return obj.templatename })
  48. })
  49. },
  50. complete: () => {
  51. /// hideLoading
  52. hideLoading()
  53. }
  54. })
  55. })
  56. },
  57. /// 出售挂牌-求购挂牌撤单请求(下架)
  58. doWRListingCancelOrder() {
  59. /// showModel
  60. showModel(() => {
  61. /// loading
  62. showLoading(()=>{
  63. /// 参数信息
  64. const info = JSON.stringify({
  65. ClientSerialNo: timetample().toString(),
  66. UserID: userid(),
  67. AccountID: accountid(),
  68. OldWRTradeOrderID: this.data.order.wrtradeorderid,
  69. OrderSrc: EOrderSrc.ORDERSRC_CLIENT,
  70. ClientType: clientType(),
  71. OperatorID: loginid(),
  72. ClientOrderTime: formatDateString(new Date().toString()),
  73. Header: protoHeader(FunCode.WRListingCancelOrderReq)
  74. })
  75. /// 发送请求
  76. sendMsgToMQ({
  77. data: {
  78. funCodeReq: FunCode.WRListingCancelOrderReq,
  79. funCodeRsp: FunCode.WRListingCancelOrderRsp,
  80. isEncrypted: isEncrypted(),
  81. data: encryptBody(info)
  82. },
  83. success: (res) => {
  84. /// 解析对象
  85. const data = JSON.parse(res.data.data)
  86. if (data.RetCode != 0) {
  87. hideLoading(() => {}, getErrorMsg(data.RetCode))
  88. return
  89. }
  90. /// 操作成功
  91. hideLoading(()=>{ wx.navigateBack() }, '操作成功', 'success')
  92. },
  93. fail: (emsg) => {
  94. /// 操作失败
  95. hideLoading(()=>{}, emsg)
  96. }
  97. })
  98. }, '请求中....')
  99. }, '提示', '确定要撤销吗?')
  100. },
  101. /**
  102. * 生命周期函数--监听页面加载
  103. */
  104. onLoad(options: any) {
  105. /// 数据显示
  106. try {
  107. const item = JSON.parse(options.item)
  108. if (item) {
  109. this.setData({ order: item })
  110. }
  111. } catch (error) {
  112. console.log(error)
  113. }
  114. /// 获取履约模板信息
  115. this.queryPermancePlanTmp()
  116. },
  117. /**
  118. * 生命周期函数--监听页面初次渲染完成
  119. */
  120. onReady() {
  121. },
  122. /**
  123. * 生命周期函数--监听页面显示
  124. */
  125. onShow() {
  126. },
  127. /**
  128. * 生命周期函数--监听页面隐藏
  129. */
  130. onHide() {
  131. },
  132. /**
  133. * 生命周期函数--监听页面卸载
  134. */
  135. onUnload() {
  136. },
  137. /**
  138. * 页面相关事件处理函数--监听用户下拉动作
  139. */
  140. onPullDownRefresh() {
  141. },
  142. /**
  143. * 页面上拉触底事件的处理函数
  144. */
  145. onReachBottom() {
  146. },
  147. /**
  148. * 用户点击右上角分享
  149. */
  150. onShareAppMessage() {
  151. }
  152. })