index.ts 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  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: 2, name: '进行中'}, {id: 1, name: '未开始'}],
  22. /// 类别
  23. active: 1,
  24. /// 状态
  25. status: 2,
  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. const params = this.data.active === 1 ? {
  44. presalestatus: presalestatus,
  45. marketid: marketID(63)
  46. } : {
  47. presalestatus: presalestatus,
  48. marketid: marketID(63),
  49. selluserid: userid()
  50. }
  51. /// 数据查询请求
  52. queryGZPreSell({
  53. data: params,
  54. success: (res) => {
  55. /// 请求失败
  56. if (res.code != 200) {
  57. /// 加载失败
  58. hideLoading(()=>{}, '请求失败,原因:'+res.msg)
  59. return
  60. }
  61. hideLoading(()=>{
  62. /// 设置数据
  63. this.setData({
  64. /// 设置列头
  65. perSells: res.data,
  66. /// 数据是否为空
  67. isEmpty: res.data.length === 0,
  68. values: res.data.map(obj => {
  69. return {
  70. pictureurls: obj.pictureurls,
  71. bannerpicurl: obj.bannerpicurl,
  72. performancetemplateid: obj.performancetemplateid,
  73. presaleapplyid: obj.presaleapplyid,
  74. wrstandardname: isnullstr(obj.wrstandardname),
  75. customername: isnullstr(obj.customername),
  76. status: getEnumdicValue('WRPresaleStatus', obj.presalestatus),
  77. startdate: isnullstr(obj.startdate),
  78. enddate: isnullstr(obj.enddate),
  79. minsuccessqty: obj.minsuccessqty.toFixed(2),
  80. minbuyqty: obj.minbuyqty.toFixed(2),
  81. maxbuyqty: obj.maxbuyqty.toFixed(2),
  82. presaleqty: obj.presaleqty.toFixed(2)+'克拉',
  83. buymarginvalue: (obj.buymarginvalue*100).toFixed(2)+'%',
  84. surplusqty: (obj.presaleqty-obj.tradeqty).toFixed(2)+'克拉',
  85. price: obj.unitprice.toFixed(2)+'(元/克拉)',
  86. presalestatus: obj.presalestatus,
  87. ysproductionmode: obj.ysproductionmode,
  88. yszscategory: obj.yszscategory,
  89. yieldrate: isnullstr(obj.yieldrate),
  90. zsclaritytypestr: isnullstr(obj.zsclaritytypestr),
  91. zscolortypestr: isnullstr(obj.zscolortypestr),
  92. zscuttypestr: isnullstr(obj.zscuttypestr),
  93. zsfluorescencetypestr: isnullstr(obj.zsfluorescencetypestr),
  94. zspolishtypestr: isnullstr(obj.zspolishtypestr),
  95. zsshapetypestr: isnullstr(obj.zsshapetypestr),
  96. zssymmetrytypestr: isnullstr(obj.zssymmetrytypestr),
  97. sizestr: isnullstr(obj.sizestr),
  98. remark: isnullstr(obj.remark),
  99. placeqty: obj.placeqty,
  100. qtydesc: isnullstr(obj.qtydesc),
  101. weightdesc: isnullstr(obj.weightdesc),
  102. sellwrtradeorderid: obj.sellwrtradeorderid,
  103. tradeqty: obj.tradeqty.toFixed(2)
  104. }
  105. })
  106. })
  107. })
  108. },
  109. fail: (emsg) => {
  110. hideLoading(()=>{}, emsg)
  111. },
  112. complete: () => {
  113. /// 停止下拉刷新
  114. wx.stopPullDownRefresh()
  115. }
  116. })
  117. }, '加载中....')
  118. },
  119. /**
  120. * 我参与的预售(预售中\执行中)\我参与的集采(集采中\执行中) 列表查询
  121. * 状态 1:预售中\集采中 2:执行中 3:已完成
  122. */
  123. queryGZMyTradingPreSell(status: number) {
  124. /// loding
  125. showLoading(()=>{
  126. /// 数据查询请求
  127. queryGZMyTradingPreSell({
  128. data: {
  129. userid: userid(),
  130. marketid: marketID(63),
  131. status: status
  132. },
  133. success: (res) => {
  134. /// 请求失败
  135. if (res.code != 200) {
  136. /// 加载失败
  137. hideLoading(()=>{}, '请求失败,原因:'+res.msg)
  138. return
  139. }
  140. hideLoading(()=>{
  141. /// 设置数据
  142. this.setData({
  143. /// 设置列头
  144. myTradingPreSells: res.data,
  145. /// 数据是否为空
  146. isEmpty: res.data.length === 0,
  147. /// 显示数据
  148. values: res.data.map(obj => {
  149. return {
  150. pictureurls: obj.pictureurls,
  151. bannerpicurl: obj.bannerpicurl,
  152. performancetemplateid: obj.performancetemplateid,
  153. presaleapplyid: obj.presaleapplyid,
  154. wrstandardname: isnullstr(obj.wrstandardname),
  155. customername: isnullstr(obj.customername),
  156. tradeamount: obj.tradeamount.toFixed(2),
  157. status: this.data.subtabs.filter(itm => { return itm.id === status })[0].name,
  158. ordertime: isnullstr(obj.ordertime),
  159. freezemargin: obj.freezemargin.toFixed(2),
  160. marginvalue: (obj.marginvalue*100).toFixed(2)+'%',
  161. tradeprice: obj.tradeprice.toFixed(2)+'(元/克拉)',
  162. orderqty: obj.orderqty.toFixed(2),
  163. ysproductionmode: obj.ysproductionmode,
  164. yszscategory: obj.yszscategory,
  165. yieldrate: isnullstr(obj.yieldrate),
  166. zsclaritytypestr: isnullstr(obj.zsclaritytypestr),
  167. zscolortypestr: isnullstr(obj.zscolortypestr),
  168. zscuttypestr: isnullstr(obj.zscuttypestr),
  169. zsfluorescencetypestr: isnullstr(obj.zsfluorescencetypestr),
  170. zspolishtypestr: isnullstr(obj.zspolishtypestr),
  171. zsshapetypestr: isnullstr(obj.zsshapetypestr),
  172. zssymmetrytypestr: isnullstr(obj.zssymmetrytypestr),
  173. sizestr: isnullstr(obj.sizestr),
  174. remark: isnullstr(obj.remark),
  175. placeqty: obj.placeqty,
  176. qtydesc: isnullstr(obj.qtydesc),
  177. weightdesc: isnullstr(obj.weightdesc)
  178. }
  179. })
  180. })
  181. })
  182. },
  183. fail: (emsg) => {
  184. hideLoading(()=>{}, emsg)
  185. },
  186. complete: () => {
  187. /// 停止下拉刷新
  188. wx.stopPullDownRefresh()
  189. }
  190. })
  191. }, '加载中....')
  192. },
  193. /**
  194. * 返回上层视图
  195. */
  196. backToParent() {
  197. /// 返回上层视图
  198. wx.navigateBack()
  199. },
  200. /// 点击
  201. onItemClick(e: any) {
  202. wx.navigateTo({
  203. url: '/mHome/pages/presell/detail/index?item='+JSON.stringify(this.data.values[Number(e.currentTarget.id)])+'&index='+this.data.active
  204. })
  205. },
  206. /**
  207. * 预售申请
  208. */
  209. addPreSell() {
  210. wx.navigateTo({
  211. url: '/mHome/pages/presell/new/index'
  212. })
  213. },
  214. /**
  215. * 预售申请
  216. */
  217. onTabChange(e: any) {
  218. if (e.target.id === "category") {
  219. /// 重置状态
  220. this.setData({ active: e.detail.name })
  221. /// 数据重置
  222. switch (e.detail.name) {
  223. case 1: /// 预售大厅
  224. this.setData({ subtabs: [{id: 2, name: '进行中'}, {id: 1, name: '未开始'}], status: 2 })
  225. break;
  226. case 2: /// 我的预售
  227. this.setData({ subtabs: [{id: 2, name: '进行中'}, {id: 1, name: '未开始'}, {id: 3, name: '已结束'}], status: 2 })
  228. break;
  229. default: /// 我参与的预售
  230. this.setData({ subtabs: [{id: 1, name: '预售中'}, {id: 2, name: '执行中'}, {id: 3, name: '已完成'}], status: 1 })
  231. break;
  232. }
  233. } else {
  234. this.setData({ status: e.detail.name })
  235. }
  236. this.data.active != 3 ? this.queryGZPreSell(this.data.status) : this.queryGZMyTradingPreSell(this.data.status)
  237. },
  238. /**
  239. * 生命周期函数--监听页面加载
  240. */
  241. onLoad() {},
  242. /**
  243. * 生命周期函数--监听页面初次渲染完成
  244. */
  245. onReady() {
  246. },
  247. /**
  248. * 生命周期函数--监听页面显示
  249. */
  250. onShow() {
  251. this.data.active != 3 ? this.queryGZPreSell(this.data.status) : this.queryGZMyTradingPreSell(this.data.status)
  252. },
  253. /**
  254. * 生命周期函数--监听页面隐藏
  255. */
  256. onHide() {
  257. },
  258. /**
  259. * 生命周期函数--监听页面卸载
  260. */
  261. onUnload() {
  262. },
  263. /**
  264. * 页面相关事件处理函数--监听用户下拉动作
  265. */
  266. onPullDownRefresh() {
  267. this.data.active != 3 ? this.queryGZPreSell(this.data.status) : this.queryGZMyTradingPreSell(this.data.status)
  268. },
  269. /**
  270. * 页面上拉触底事件的处理函数
  271. */
  272. onReachBottom() {
  273. },
  274. /**
  275. * 用户点击右上角分享
  276. */
  277. onShareAppMessage() {
  278. }
  279. })