index.ts 6.9 KB

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