index.ts 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. import { accountid, clientType, getErrorMsg, isEncrypted, marketid, protoHeader, timetample, userid } from "../../../../services/utils"
  2. import { hideLoading, showLoading, showModel } from "../../../../utils/message/index"
  3. import { encryptBody } from "../../../../utils/websocket/crypto"
  4. import { FunCode } from "../../../../constants/enum/funcode"
  5. import { sendMsgToMQ } from "../../../../services/api/common/index"
  6. import { formatDateString } from "../../../../utils/util"
  7. import { queryPermancePlanTmp } from "../../../../services/api/orders/index"
  8. Page({
  9. /**
  10. * 页面的初始数据
  11. */
  12. data: {
  13. navTitle: '预售详情',
  14. /// 底部安全区域
  15. safeBottom: getApp().globalData.safeBottom,
  16. /// 数据信息
  17. item: {},
  18. /// 选中履约模板
  19. tmp: <GuangZuan.PermancePlanTmp>({}),
  20. /// 颜色
  21. colors: ['rebeccapurple', 'green', 'hotpink', 'orange', 'darkgoldenrod', 'firebrick'],
  22. /// banner图
  23. banners: ['']
  24. },
  25. /**
  26. * 返回上层视图
  27. */
  28. backToParent() {
  29. /// 返回上层视图
  30. wx.navigateBack()
  31. },
  32. /**
  33. * 立即购买
  34. */
  35. doSubmit(orderID: string, qty: string) {
  36. /// showModel
  37. showModel(() => {
  38. /// showLoading
  39. showLoading(() => {
  40. /// 请求参数
  41. const info = JSON.stringify({
  42. Header: protoHeader(FunCode.GZPresaleOrderReq),
  43. UserID: userid(),
  44. AccountID: accountid(),
  45. WRTradeOrderID: Number(orderID),
  46. OrderQty: Number(qty),
  47. MarketID: marketid(),
  48. ClientType: clientType(),
  49. ClientOrderTime: formatDateString(new Date().toString()),
  50. ClientSerialNo: timetample().toString()
  51. })
  52. /// 发送请求
  53. sendMsgToMQ({
  54. data: {
  55. data: encryptBody(info),
  56. funCodeReq: FunCode.GZPresaleOrderReq,
  57. funCodeRsp: FunCode.GZPresaleOrderRsp,
  58. isEncrypted: isEncrypted()
  59. },
  60. success: (res) => {
  61. /// 解析对象
  62. const data = JSON.parse(res.data.data)
  63. if (data.RetCode != 0) {
  64. hideLoading(() => {}, getErrorMsg(data.RetCode))
  65. return
  66. }
  67. /// 求购发布请求成功
  68. hideLoading(() => {
  69. wx.navigateBack()
  70. }, '立即购买申请成功', 'success')
  71. },
  72. fail: (emsg) => {
  73. hideLoading(()=>{}, emsg)
  74. }
  75. })
  76. }, '提交申请请求中....')
  77. }, '提示', '确认要立即购买申请吗?')
  78. },
  79. /// 获取履约模板信息
  80. queryPermancePlanTmp(performancetemplateid: number) {
  81. /// showLoading
  82. showLoading(() => {
  83. queryPermancePlanTmp({
  84. success: (res) => {
  85. /// 获取数据
  86. this.setData({
  87. tmp: res.data.filter(obj => { return obj.autoid === performancetemplateid })[0]
  88. })
  89. },
  90. complete: () => {
  91. /// hideLoading
  92. hideLoading()
  93. }
  94. })
  95. })
  96. },
  97. /**
  98. * 生命周期函数--监听页面加载
  99. */
  100. onLoad(options: any) {
  101. const obj = JSON.parse(options.item)
  102. /// 解析数据
  103. this.setData({ item: obj })
  104. /// 查询履约模板
  105. this.queryPermancePlanTmp(obj.performancetemplateid)
  106. },
  107. /**
  108. * 生命周期函数--监听页面初次渲染完成
  109. */
  110. onReady() {
  111. },
  112. /**
  113. * 生命周期函数--监听页面显示
  114. */
  115. onShow() {
  116. },
  117. /**
  118. * 生命周期函数--监听页面隐藏
  119. */
  120. onHide() {
  121. },
  122. /**
  123. * 生命周期函数--监听页面卸载
  124. */
  125. onUnload() {
  126. },
  127. /**
  128. * 页面相关事件处理函数--监听用户下拉动作
  129. */
  130. onPullDownRefresh() {
  131. },
  132. /**
  133. * 页面上拉触底事件的处理函数
  134. */
  135. onReachBottom() {
  136. },
  137. /**
  138. * 用户点击右上角分享
  139. */
  140. onShareAppMessage() {
  141. }
  142. })