index.ts 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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 { queryGZMyPresell, 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'],
  22. /// banner图
  23. banners: [''],
  24. /// 预售认购列表查询
  25. sells: <GuangZuan.GZMyPreSell[]>[]
  26. },
  27. /**
  28. * 返回上层视图
  29. */
  30. backToParent() {
  31. /// 返回上层视图
  32. wx.navigateBack()
  33. },
  34. /// 我的预售认购列表查询
  35. queryGZMyPresell(presaleapplyid: number) {
  36. /// showLoading
  37. showLoading(() => {
  38. queryGZMyPresell({
  39. data: {
  40. presaleapplyid: presaleapplyid
  41. },
  42. success: (res) => {
  43. /// 获取数据
  44. this.setData({ sells: res.data })
  45. },
  46. complete: () => {
  47. /// hideLoading
  48. hideLoading()
  49. }
  50. })
  51. })
  52. },
  53. /**
  54. * 立即购买
  55. */
  56. doSubmit(orderID: string, qty: string) {
  57. /// showModel
  58. showModel(() => {
  59. /// showLoading
  60. showLoading(() => {
  61. /// 请求参数
  62. const info = JSON.stringify({
  63. Header: protoHeader(FunCode.GZCenterPurchaseOrderReq),
  64. UserID: userid(),
  65. AccountID: accountid(),
  66. WRTradeOrderID: Number(orderID),
  67. OrderQty: Number(qty),
  68. MarketID: marketid(),
  69. ClientType: clientType(),
  70. ClientOrderTime: formatDateString(new Date().toString()),
  71. ClientSerialNo: timetample().toString()
  72. })
  73. /// 发送请求
  74. sendMsgToMQ({
  75. data: {
  76. data: encryptBody(info),
  77. funCodeReq: FunCode.GZCenterPurchaseOrderReq,
  78. funCodeRsp: FunCode.GZCenterPurchaseOrderRsp,
  79. isEncrypted: isEncrypted()
  80. },
  81. success: (res) => {
  82. /// 解析对象
  83. const data = JSON.parse(res.data.data)
  84. if (data.RetCode != 0) {
  85. hideLoading(() => {}, getErrorMsg(data.RetCode))
  86. return
  87. }
  88. /// 求购发布请求成功
  89. hideLoading(() => {
  90. wx.navigateBack()
  91. }, '立即购买申请成功', 'success')
  92. },
  93. fail: (emsg) => {
  94. hideLoading(()=>{}, emsg)
  95. }
  96. })
  97. }, '提交申请请求中....')
  98. }, '提示', '确认要立即购买申请吗?')
  99. },
  100. /// 获取履约模板信息
  101. queryPermancePlanTmp(performancetemplateid: number) {
  102. /// showLoading
  103. showLoading(() => {
  104. queryPermancePlanTmp({
  105. data: {
  106. marketid: marketid()
  107. },
  108. success: (res) => {
  109. /// 获取数据
  110. this.setData({
  111. tmp: res.data.filter(obj => { return obj.autoid === performancetemplateid })[0]
  112. })
  113. },
  114. complete: () => {
  115. /// hideLoading
  116. hideLoading()
  117. }
  118. })
  119. })
  120. },
  121. /**
  122. * 生命周期函数--监听页面加载
  123. */
  124. onLoad(options: any) {
  125. const obj = JSON.parse(options.item)
  126. /// 解析数据
  127. this.setData({ item: obj })
  128. // 查询履约模板
  129. this.queryPermancePlanTmp(obj.performancetemplateid)
  130. /// 我的预售认购列表查询
  131. this.queryGZMyPresell(obj.presaleapplyid)
  132. },
  133. /**
  134. * 生命周期函数--监听页面初次渲染完成
  135. */
  136. onReady() {
  137. },
  138. /**
  139. * 生命周期函数--监听页面显示
  140. */
  141. onShow() {
  142. },
  143. /**
  144. * 生命周期函数--监听页面隐藏
  145. */
  146. onHide() {
  147. },
  148. /**
  149. * 生命周期函数--监听页面卸载
  150. */
  151. onUnload() {
  152. },
  153. /**
  154. * 页面相关事件处理函数--监听用户下拉动作
  155. */
  156. onPullDownRefresh() {
  157. },
  158. /**
  159. * 页面上拉触底事件的处理函数
  160. */
  161. onReachBottom() {
  162. },
  163. /**
  164. * 用户点击右上角分享
  165. */
  166. onShareAppMessage() {
  167. }
  168. })