index.ts 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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', 'firebrick'],
  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. success: (res) => {
  106. /// 获取数据
  107. this.setData({
  108. tmp: res.data.filter(obj => { return obj.autoid === performancetemplateid })[0]
  109. })
  110. },
  111. complete: () => {
  112. /// hideLoading
  113. hideLoading()
  114. }
  115. })
  116. })
  117. },
  118. /**
  119. * 生命周期函数--监听页面加载
  120. */
  121. onLoad(options: any) {
  122. const obj = JSON.parse(options.item)
  123. /// 解析数据
  124. this.setData({ item: obj })
  125. // 查询履约模板
  126. this.queryPermancePlanTmp(obj.performancetemplateid)
  127. /// 我的预售认购列表查询
  128. this.queryGZMyPresell(obj.presaleapplyid)
  129. },
  130. /**
  131. * 生命周期函数--监听页面初次渲染完成
  132. */
  133. onReady() {
  134. },
  135. /**
  136. * 生命周期函数--监听页面显示
  137. */
  138. onShow() {
  139. },
  140. /**
  141. * 生命周期函数--监听页面隐藏
  142. */
  143. onHide() {
  144. },
  145. /**
  146. * 生命周期函数--监听页面卸载
  147. */
  148. onUnload() {
  149. },
  150. /**
  151. * 页面相关事件处理函数--监听用户下拉动作
  152. */
  153. onPullDownRefresh() {
  154. },
  155. /**
  156. * 页面上拉触底事件的处理函数
  157. */
  158. onReachBottom() {
  159. },
  160. /**
  161. * 用户点击右上角分享
  162. */
  163. onShareAppMessage() {
  164. }
  165. })