index.ts 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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'],
  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))
  91. return
  92. }
  93. /// 操作成功
  94. hideLoading(()=>{ wx.navigateBack() }, '操作成功', 'success')
  95. },
  96. fail: (emsg) => {
  97. /// 操作失败
  98. hideLoading(()=>{}, emsg)
  99. }
  100. })
  101. }, '请求中....')
  102. }, '提示', '确定要撤销吗?')
  103. },
  104. /**
  105. * 生命周期函数--监听页面加载
  106. */
  107. onLoad(options: any) {
  108. /// 数据显示
  109. try {
  110. const item = JSON.parse(options.item)
  111. if (item) {
  112. this.setData({ order: item })
  113. }
  114. } catch (error) {
  115. console.log(error)
  116. }
  117. /// 获取履约模板信息
  118. this.queryPermancePlanTmp()
  119. },
  120. /**
  121. * 生命周期函数--监听页面初次渲染完成
  122. */
  123. onReady() {
  124. },
  125. /**
  126. * 生命周期函数--监听页面显示
  127. */
  128. onShow() {
  129. },
  130. /**
  131. * 生命周期函数--监听页面隐藏
  132. */
  133. onHide() {
  134. },
  135. /**
  136. * 生命周期函数--监听页面卸载
  137. */
  138. onUnload() {
  139. },
  140. /**
  141. * 页面相关事件处理函数--监听用户下拉动作
  142. */
  143. onPullDownRefresh() {
  144. },
  145. /**
  146. * 页面上拉触底事件的处理函数
  147. */
  148. onReachBottom() {
  149. },
  150. /**
  151. * 用户点击右上角分享
  152. */
  153. onShareAppMessage() {
  154. }
  155. })