index.ts 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. import { queryGZMyTradingPreSell, queryGZPreSell } from "../../../../services/api/orders/index"
  2. import { getEnumdicValue, 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. /// subtabs
  21. subtabs: [{id: 1, name: '执行中'}, {id: 2, name: '未开始'}],
  22. /// 类别
  23. active: 0,
  24. /// 状态
  25. status: 1,
  26. /// 是否空数据
  27. isEmpty: false,
  28. /// 预售大厅/我的预售/集采大厅/我的集采 列表查询
  29. perSells: <GuangZuan.GZPreSell[]>[{}],
  30. /// 我参与的预售(预售中\执行中)\我参与的集采(集采中\执行中) 列表查询
  31. myTradingPreSells: <GuangZuan.GZMyTradingPreSell[]>[{}],
  32. /// 显示数据信息
  33. values: <{}>[]
  34. },
  35. /**
  36. * 预售大厅/我的预售/集采大厅/我的集采 列表查询
  37. * 预售状态 - 1:未开始 2:进行中 3:已结束 4:已关闭 5:处理中 6::处理失败 7:已完成
  38. */
  39. queryGZPreSell(presalestatus: number) {
  40. /// loding
  41. showLoading(()=>{
  42. /// 数据查询请求
  43. queryGZPreSell({
  44. data: {
  45. presalestatus: presalestatus,
  46. marketid: marketid()
  47. },
  48. success: (res) => {
  49. /// 请求失败
  50. if (res.code != 200) {
  51. /// 加载失败
  52. hideLoading(()=>{}, '请求失败,原因:'+res.msg)
  53. return
  54. }
  55. hideLoading(()=>{
  56. /// 设置数据
  57. this.setData({
  58. /// 设置列头
  59. perSells: res.data,
  60. /// 数据是否为空
  61. isEmpty: res.data.length === 0,
  62. values: res.data.map(obj => {
  63. return {
  64. presaleapplyid: obj.presaleapplyid,
  65. wrstandardname: isnullstr(obj.wrstandardname),
  66. customername: isnullstr(obj.customername),
  67. status: getEnumdicValue('WRPresaleStatus', obj.presalestatus),
  68. startdate: isnullstr(obj.startdate),
  69. enddate: isnullstr(obj.enddate),
  70. minsuccessqty: obj.minsuccessqty.toFixed(0),
  71. minbuyqty: obj.minbuyqty.toFixed(0),
  72. maxbuyqty: obj.maxbuyqty.toFixed(0),
  73. presaleqty: obj.presaleqty.toFixed(0)+'克拉',
  74. buymarginvalue: (obj.buymarginvalue*100).toFixed(2)+'%',
  75. surplusqty: (obj.presaleqty-obj.placeqty).toFixed(0)+'克拉',
  76. price: '¥'+obj.unitprice.toFixed(2)+'(元/克拉)',
  77. presalestatus: obj.presalestatus
  78. }
  79. })
  80. })
  81. })
  82. },
  83. fail: (emsg) => {
  84. hideLoading(()=>{}, emsg)
  85. },
  86. complete: () => {
  87. /// 停止下拉刷新
  88. wx.stopPullDownRefresh()
  89. }
  90. })
  91. }, '加载中....')
  92. },
  93. /**
  94. * 我参与的预售(预售中\执行中)\我参与的集采(集采中\执行中) 列表查询
  95. * 状态 1:预售中\集采中 2:执行中 3:已完成
  96. */
  97. queryGZMyTradingPreSell(status: number) {
  98. /// loding
  99. showLoading(()=>{
  100. /// 数据查询请求
  101. queryGZMyTradingPreSell({
  102. data: {
  103. userid: userid(),
  104. marketid: marketid(),
  105. status: status
  106. },
  107. success: (res) => {
  108. /// 请求失败
  109. if (res.code != 200) {
  110. /// 加载失败
  111. hideLoading(()=>{}, '请求失败,原因:'+res.msg)
  112. return
  113. }
  114. hideLoading(()=>{
  115. /// 设置数据
  116. this.setData({
  117. /// 设置列头
  118. myTradingPreSells: res.data,
  119. /// 数据是否为空
  120. isEmpty: res.data.length === 0,
  121. /// 显示数据
  122. values: res.data.map(obj => {
  123. return {
  124. presaleapplyid: obj.presaleapplyid,
  125. wrstandardname: isnullstr(obj.wrstandardname),
  126. customername: isnullstr(obj.customername),
  127. tradeamount: obj.tradeamount.toFixed(2),
  128. status: obj.status,
  129. ordertime: isnullstr(obj.ordertime),
  130. freezemargin: obj.freezemargin.toFixed(2),
  131. marginvalue: (obj.marginvalue*100).toFixed(2)+'%',
  132. tradeprice: '¥'+obj.tradeprice.toFixed(2)+'(元/克拉)',
  133. orderqty: obj.orderqty.toFixed(2),
  134. }
  135. })
  136. })
  137. })
  138. },
  139. fail: (emsg) => {
  140. hideLoading(()=>{}, emsg)
  141. },
  142. complete: () => {
  143. /// 停止下拉刷新
  144. wx.stopPullDownRefresh()
  145. }
  146. })
  147. }, '加载中....')
  148. },
  149. /**
  150. * 返回上层视图
  151. */
  152. backToParent() {
  153. /// 返回上层视图
  154. wx.navigateBack()
  155. },
  156. /// 点击
  157. onItemClick(e: any) {
  158. wx.navigateTo({
  159. url: '/mHome/pages/purchase/detail/index?item='+JSON.stringify(this.data.values[Number(e.currentTarget.id)])+'&index='+this.data.active
  160. })
  161. },
  162. /**
  163. * 集采申请
  164. */
  165. addPurchase() {
  166. wx.navigateTo({
  167. url: '/mHome/pages/purchase/new/index'
  168. })
  169. },
  170. /**
  171. * 预售申请
  172. */
  173. onTabChange(e: any) {
  174. if (e.target.id === "category") {
  175. /// 重置状态
  176. this.setData({ status: 1, active: e.detail.index })
  177. /// 数据重置
  178. switch (e.detail.index) {
  179. case 0: /// 预售大厅
  180. this.setData({ subtabs: [{id: 1, name: '执行中'}, {id: 2, name: '未开始'}] })
  181. break;
  182. case 1: /// 我的预售
  183. this.setData({ subtabs: [{id: 1, name: '执行中'}, {id: 2, name: '未开始'}, {id: 3, name: '已结束'}] })
  184. break;
  185. default: /// 我参与的预售
  186. this.setData({ subtabs: [{id: 1, name: '预售中'}, {id: 2, name: '执行中'}, {id: 3, name: '已完成'}] })
  187. break;
  188. }
  189. } else {
  190. this.setData({ status: e.detail.index+1 })
  191. }
  192. this.data.active != 2 ? this.queryGZPreSell(this.data.status) : this.queryGZMyTradingPreSell(this.data.status)
  193. },
  194. /**
  195. * 生命周期函数--监听页面加载
  196. */
  197. onLoad() {
  198. this.data.active != 2 ? this.queryGZPreSell(this.data.status) : this.queryGZMyTradingPreSell(this.data.status)
  199. },
  200. /**
  201. * 生命周期函数--监听页面初次渲染完成
  202. */
  203. onReady() {
  204. },
  205. /**
  206. * 生命周期函数--监听页面显示
  207. */
  208. onShow() {
  209. },
  210. /**
  211. * 生命周期函数--监听页面隐藏
  212. */
  213. onHide() {
  214. },
  215. /**
  216. * 生命周期函数--监听页面卸载
  217. */
  218. onUnload() {
  219. },
  220. /**
  221. * 页面相关事件处理函数--监听用户下拉动作
  222. */
  223. onPullDownRefresh() {
  224. this.data.active != 2 ? this.queryGZPreSell(this.data.status) : this.queryGZMyTradingPreSell(this.data.status)
  225. },
  226. /**
  227. * 页面上拉触底事件的处理函数
  228. */
  229. onReachBottom() {
  230. },
  231. /**
  232. * 用户点击右上角分享
  233. */
  234. onShareAppMessage() {
  235. }
  236. })