index.ts 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. import { queryGZMyTradingPreSell, queryGZPreSell } from "../../../../services/api/orders/index"
  2. import { marketid, userid } from "../../../../services/utils"
  3. import { hideLoading, showLoading } from "../../../../utils/message/index"
  4. import { isnullstr } from "../../../../utils/util"
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. /// 状态栏高度
  11. statusBarHeight: getApp().globalData.statusBarHeight,
  12. /// 导航栏高度
  13. navHeight: getApp().globalData.navHeight,
  14. /// 底部安全区域
  15. safeBottom: getApp().globalData.safeBottom,
  16. /// 窗口高度
  17. windowHeight: getApp().globalData.windowHeight,
  18. /// tabs
  19. tabs: [{id: 1, name: '集采大厅'}, {id: 2, name: '我的集采'}, {id: 3, name: '我参与的集采'}],
  20. /// 是否空数据
  21. isEmpty: false,
  22. /// 预售大厅/我的预售/集采大厅/我的集采 列表查询
  23. perSells: <GuangZuan.GZPreSell[]>[{}],
  24. /// 我参与的预售(预售中\执行中)\我参与的集采(集采中\执行中) 列表查询
  25. myTradingPreSells: <GuangZuan.GZMyTradingPreSell[]>[{}],
  26. /// 显示数据信息
  27. values: [{}]
  28. },
  29. /**
  30. * 预售大厅/我的预售/集采大厅/我的集采 列表查询
  31. * 预售状态 - 1:未开始 2:进行中 3:已结束 4:已关闭 5:处理中 6::处理失败 7:已完成
  32. */
  33. queryGZPreSell(presalestatus: number) {
  34. /// loding
  35. showLoading(()=>{
  36. /// 数据查询请求
  37. queryGZPreSell({
  38. data: {
  39. presalestatus: presalestatus,
  40. marketid: marketid()
  41. },
  42. success: (res) => {
  43. /// 请求失败
  44. if (res.code != 200) {
  45. /// 加载失败
  46. hideLoading(()=>{}, '请求失败,原因:'+res.msg)
  47. return
  48. }
  49. hideLoading(()=>{
  50. /// 设置数据
  51. this.setData({
  52. /// 设置列头
  53. perSells: res.data,
  54. /// 数据是否为空
  55. isEmpty: res.data.length === 0,
  56. values: res.data.map(obj => {
  57. return {
  58. wrstandardname: isnullstr(obj.wrstandardname),
  59. customername: isnullstr(obj.customername),
  60. status: getEnumdicValue('WRPresaleStatus', obj.presalestatus),
  61. startdate: isnullstr(obj.startdate),
  62. enddate: isnullstr(obj.enddate),
  63. minsuccessqty: obj.minsuccessqty.toFixed(0),
  64. minbuyqty: obj.minbuyqty.toFixed(0),
  65. maxbuyqty: obj.maxbuyqty.toFixed(0),
  66. presaleqty: obj.presaleqty.toFixed(0)+'克拉',
  67. buymarginvalue: (obj.buymarginvalue*100).toFixed(2)+'%',
  68. surplusqty: (obj.presaleqty-obj.placeqty).toFixed(0),
  69. price: '¥'+obj.lastprice.toFixed(2)+'(元/克拉)'
  70. }
  71. })
  72. })
  73. })
  74. },
  75. fail: (emsg) => {
  76. hideLoading(()=>{}, emsg)
  77. },
  78. complete: () => {
  79. /// 停止下拉刷新
  80. wx.stopPullDownRefresh()
  81. }
  82. })
  83. }, '加载中....')
  84. },
  85. /**
  86. * 我参与的预售(预售中\执行中)\我参与的集采(集采中\执行中) 列表查询
  87. * 状态 1:预售中\集采中 2:执行中 3:已完成
  88. */
  89. queryGZMyTradingPreSell(status: number) {
  90. /// loding
  91. showLoading(()=>{
  92. /// 数据查询请求
  93. queryGZMyTradingPreSell({
  94. data: {
  95. userid: userid(),
  96. marketid: marketid(),
  97. status: status
  98. },
  99. success: (res) => {
  100. /// 请求失败
  101. if (res.code != 200) {
  102. /// 加载失败
  103. hideLoading(()=>{}, '请求失败,原因:'+res.msg)
  104. return
  105. }
  106. hideLoading(()=>{
  107. /// 设置数据
  108. this.setData({
  109. /// 设置列头
  110. myTradingPreSells: res.data,
  111. /// 数据是否为空
  112. isEmpty: res.data.length === 0,
  113. /// 显示数据
  114. values: res.data.map(obj => {
  115. return {
  116. wrstandardname: isnullstr(obj.wrstandardname),
  117. customername: isnullstr(obj.customername),
  118. tradeamount: obj.tradeamount.toFixed(2),
  119. status: obj.status,
  120. ordertime: isnullstr(obj.ordertime),
  121. freezemargin: obj.freezemargin.toFixed(2),
  122. marginvalue: (obj.marginvalue*100).toFixed(2)+'%',
  123. tradeprice: '¥'+obj.tradeprice.toFixed(2)+'(元/克拉)'
  124. }
  125. })
  126. })
  127. })
  128. },
  129. fail: (emsg) => {
  130. hideLoading(()=>{}, emsg)
  131. },
  132. complete: () => {
  133. /// 停止下拉刷新
  134. wx.stopPullDownRefresh()
  135. }
  136. })
  137. }, '加载中....')
  138. },
  139. /**
  140. * 返回上层视图
  141. */
  142. backToParent() {
  143. /// 返回上层视图
  144. wx.navigateBack()
  145. },
  146. /**
  147. * 生命周期函数--监听页面加载
  148. */
  149. onLoad() {
  150. },
  151. /**
  152. * 生命周期函数--监听页面初次渲染完成
  153. */
  154. onReady() {
  155. },
  156. /**
  157. * 生命周期函数--监听页面显示
  158. */
  159. onShow() {
  160. },
  161. /**
  162. * 生命周期函数--监听页面隐藏
  163. */
  164. onHide() {
  165. },
  166. /**
  167. * 生命周期函数--监听页面卸载
  168. */
  169. onUnload() {
  170. },
  171. /**
  172. * 页面相关事件处理函数--监听用户下拉动作
  173. */
  174. onPullDownRefresh() {
  175. },
  176. /**
  177. * 页面上拉触底事件的处理函数
  178. */
  179. onReachBottom() {
  180. },
  181. /**
  182. * 用户点击右上角分享
  183. */
  184. onShareAppMessage() {
  185. }
  186. })