index.ts 4.1 KB

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