index.ts 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. import { accountid, clientType, getErrorMsg, isEncrypted, marketID, protoHeader, timetample, userid } from "../../../../services/utils"
  2. import { hideLoading, showLoading } 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, getDecimalNum } 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. orderQty: '',
  21. /// 选中履约模板
  22. tmp: <GuangZuan.PermancePlanTmp>({}),
  23. /// 颜色
  24. colors: ['rebeccapurple', 'green', 'hotpink', 'orange', 'darkgoldenrod', 'firebrick', 'forestgreen', 'darksalmon', 'goldenrod', 'khaki', 'rosybrown', 'sandybrown'],
  25. /// banner图
  26. banners: [''],
  27. /// 预售认购列表查询
  28. sells: <GuangZuan.GZMyPreSell[]>[],
  29. /// 是否显示弹出层
  30. show: false
  31. },
  32. /**
  33. * 返回上层视图
  34. */
  35. backToParent() {
  36. /// 返回上层视图
  37. wx.navigateBack()
  38. },
  39. /// 我的预售认购列表查询
  40. queryGZMyPresell(presaleapplyid: number) {
  41. /// showLoading
  42. showLoading(() => {
  43. queryGZMyPresell({
  44. data: {
  45. presaleapplyid: presaleapplyid
  46. },
  47. success: (res) => {
  48. /// 获取数据
  49. this.setData({ sells: res.data })
  50. },
  51. complete: () => {
  52. /// hideLoading
  53. hideLoading()
  54. }
  55. })
  56. })
  57. },
  58. onClose() {
  59. if (!this.data.show) {
  60. return
  61. }
  62. /// 关闭弹出层
  63. this.setData({ show: false })
  64. },
  65. /// 显示弹出层
  66. showPopup() {
  67. if (this.data.show) {
  68. return
  69. }
  70. /// 关闭弹出层
  71. this.setData({ show: true })
  72. },
  73. // input输入中
  74. getInputNum (e: any) {
  75. /// 截取2位小数位
  76. let num = getDecimalNum(e.detail)
  77. this.setData({ orderQty: num})
  78. },
  79. /**
  80. * 立即购买
  81. */
  82. doSubmit() {
  83. /// 关闭弹出窗
  84. this.onClose()
  85. /// showLoading
  86. showLoading(() => {
  87. /// 请求参数
  88. const info = JSON.stringify({
  89. Header: protoHeader(FunCode.GZCenterPurchaseOrderReq),
  90. UserID: userid(),
  91. AccountID: accountid(),
  92. WRTradeOrderID: Number(this.data.item.sellwrtradeorderid),
  93. OrderQty: Number(this.data.orderQty),
  94. MarketID: marketID(62),
  95. ClientType: clientType(),
  96. ClientOrderTime: formatDateString(new Date().toString()),
  97. ClientSerialNo: timetample().toString()
  98. })
  99. /// 发送请求
  100. sendMsgToMQ({
  101. data: {
  102. data: encryptBody(info),
  103. funCodeReq: FunCode.GZCenterPurchaseOrderReq,
  104. funCodeRsp: FunCode.GZCenterPurchaseOrderRsp,
  105. isEncrypted: isEncrypted()
  106. },
  107. success: (res) => {
  108. /// 解析对象
  109. const data = JSON.parse(res.data.data)
  110. if (data.RetCode != 0) {
  111. hideLoading(() => {}, getErrorMsg(data.RetCode))
  112. return
  113. }
  114. /// 求购发布请求成功
  115. hideLoading(() => {
  116. wx.navigateBack()
  117. }, '立即购买申请成功', 'success')
  118. },
  119. fail: (emsg) => {
  120. hideLoading(()=>{}, emsg)
  121. }
  122. })
  123. }, '提交申请请求中....')
  124. },
  125. /// 获取履约模板信息
  126. queryPermancePlanTmp(performancetemplateid: number) {
  127. /// showLoading
  128. showLoading(() => {
  129. queryPermancePlanTmp({
  130. success: (res) => {
  131. /// 获取数据
  132. this.setData({
  133. tmp: res.data.filter(obj => { return obj.autoid === performancetemplateid })[0]
  134. })
  135. },
  136. complete: () => {
  137. /// hideLoading
  138. hideLoading()
  139. }
  140. })
  141. })
  142. },
  143. /**
  144. * 生命周期函数--监听页面加载
  145. */
  146. onLoad(options: any) {
  147. const obj = JSON.parse(options.item)
  148. /// 解析数据
  149. this.setData({
  150. item: obj,
  151. banners: String(obj.pictureurls).split(',').map(itm => {
  152. return (services.config.openApiUrl+itm).replace('./uploadFile', '/uploadFile')
  153. }) })
  154. // 查询履约模板
  155. this.queryPermancePlanTmp(obj.performancetemplateid)
  156. /// 我的预售认购列表查询
  157. this.queryGZMyPresell(obj.presaleapplyid)
  158. },
  159. /**
  160. * 生命周期函数--监听页面初次渲染完成
  161. */
  162. onReady() {
  163. },
  164. /**
  165. * 生命周期函数--监听页面显示
  166. */
  167. onShow() {
  168. },
  169. /**
  170. * 生命周期函数--监听页面隐藏
  171. */
  172. onHide() {
  173. },
  174. /**
  175. * 生命周期函数--监听页面卸载
  176. */
  177. onUnload() {
  178. },
  179. /**
  180. * 页面相关事件处理函数--监听用户下拉动作
  181. */
  182. onPullDownRefresh() {
  183. },
  184. /**
  185. * 页面上拉触底事件的处理函数
  186. */
  187. onReachBottom() {
  188. },
  189. /**
  190. * 用户点击右上角分享
  191. */
  192. onShareAppMessage() {
  193. }
  194. })