index.ts 4.3 KB

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