index.ts 4.7 KB

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