index.ts 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. import { FunCode } from "../../../constants/enum/funcode"
  2. import { EOrderSrc } from "../../../constants/enum/index"
  3. import { sendMsgToMQ } from "../../../services/api/common/index"
  4. import { getGoods } from "../../../services/api/orders/index"
  5. import { accountid, clientType, getErrorMsg, isEncrypted, loginid, marketid, protoHeader, timetample, userid } from "../../../services/utils"
  6. import { hideLoading, showLoading, showModel, showToast } from "../../../utils/message/index"
  7. import { encryptBody } from "../../../utils/websocket/crypto"
  8. Page({
  9. /**
  10. * 页面的初始数据
  11. */
  12. data: {
  13. /// 底部安全区域
  14. safeBottom: getApp().globalData.safeBottom,
  15. /// 商品信息
  16. goods: <GuangZuan.GetGoods>({}),
  17. /// 商品编号
  18. goodsno: '',
  19. /// 卖单信息
  20. order: <GuangZuan.SellOrder>({})
  21. },
  22. /**
  23. * 返回上层视图
  24. */
  25. backToParent() {
  26. /// 返回上层视图
  27. wx.navigateBack()
  28. },
  29. /**
  30. * 获取商品数据信息
  31. */
  32. getGoods() {
  33. showLoading(() => {
  34. /// 发送请求
  35. getGoods({
  36. data: {
  37. goodsno: this.data.goodsno
  38. },
  39. success: (res) => {
  40. hideLoading( ()=> {
  41. this.setData({ goods: res.data })
  42. })
  43. },
  44. fail: (emsg) => {
  45. hideLoading( ()=> {}, emsg, 'error')
  46. }
  47. })
  48. })
  49. },
  50. /// 钻石买摘牌接口
  51. doZSBuyOrderDesting() {
  52. /// showModel
  53. showModel(() => {
  54. /// showLoding....
  55. showLoading(() => {
  56. /// 构建参数信息
  57. const info = JSON.stringify({
  58. Header: protoHeader(FunCode.ZSBuyOrderDestingReq),
  59. UserID: userid(),
  60. AccountID: accountid(),
  61. RelatedWRTradeOrderID: this.data.order.wrtradeorderid,
  62. OrderQty: this.data.order.remainqty,
  63. OrderSrc: EOrderSrc.ORDERSRC_CLIENT,
  64. ClientSerialNo: timetample().toString(),
  65. ClientType: clientType(),
  66. OperatorID: loginid(),
  67. MarketID: marketid()
  68. })
  69. /// 发送请求
  70. sendMsgToMQ({
  71. data: {
  72. data: encryptBody(info),
  73. funCodeReq: FunCode.ZSBuyOrderDestingReq,
  74. funCodeRsp: FunCode.ZSBuyOrderDestingRsp,
  75. isEncrypted: isEncrypted(),
  76. },
  77. success: (res) => {
  78. /// 请求失败
  79. if (res.code ! = 0) {
  80. hideLoading(() => {}, res.msg, 'error')
  81. return
  82. }
  83. /// 解析对象
  84. const data = JSON.parse(res.data.data)
  85. if (data.RetCode != 0) {
  86. hideLoading(() => {}, getErrorMsg(data.RetCode), 'error')
  87. return
  88. }
  89. /// 请求成功
  90. hideLoading(() => {
  91. wx.navigateBack()
  92. }, '购买请求成功')
  93. },
  94. fail: (emsg) => {
  95. hideLoading(() => {
  96. showToast('购买操作请求失败,原因:'+emsg)
  97. })
  98. }
  99. })
  100. }, '请求中......')
  101. }, '提示', '确定要购买吗?', true)
  102. },
  103. /**
  104. * 生命周期函数--监听页面加载
  105. */
  106. onLoad(options: any) {
  107. /// 单据信息
  108. const item = JSON.parse(options.item)
  109. if (item) {
  110. this.setData({ order: item })
  111. }
  112. /// 商品编号
  113. this.setData({ goodsno: options.goodsno })
  114. /// 获取商品数据
  115. this.getGoods()
  116. },
  117. /**
  118. * 生命周期函数--监听页面初次渲染完成
  119. */
  120. onReady() {},
  121. /**
  122. * 生命周期函数--监听页面显示
  123. */
  124. onShow() {},
  125. /**
  126. * 生命周期函数--监听页面隐藏
  127. */
  128. onHide() {},
  129. /**
  130. * 生命周期函数--监听页面卸载
  131. */
  132. onUnload() {},
  133. /**
  134. * 页面相关事件处理函数--监听用户下拉动作
  135. */
  136. onPullDownRefresh() {
  137. },
  138. /**
  139. * 页面上拉触底事件的处理函数
  140. */
  141. onReachBottom() {
  142. },
  143. /**
  144. * 用户点击右上角分享
  145. */
  146. onShareAppMessage() {
  147. }
  148. })