index.ts 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  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: 0,
  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 === 0 ? {
  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.placeqty).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. }
  104. })
  105. })
  106. })
  107. },
  108. fail: (emsg) => {
  109. hideLoading(()=>{}, emsg)
  110. },
  111. complete: () => {
  112. /// 停止下拉刷新
  113. wx.stopPullDownRefresh()
  114. }
  115. })
  116. }, '加载中....')
  117. },
  118. /**
  119. * 我参与的预售(预售中\执行中)\我参与的集采(集采中\执行中) 列表查询
  120. * 状态 1:预售中\集采中 2:执行中 3:已完成
  121. */
  122. queryGZMyTradingPreSell(status: number) {
  123. /// loding
  124. showLoading(()=>{
  125. /// 数据查询请求
  126. queryGZMyTradingPreSell({
  127. data: {
  128. userid: userid(),
  129. marketid: marketID(63),
  130. status: status
  131. },
  132. success: (res) => {
  133. /// 请求失败
  134. if (res.code != 200) {
  135. /// 加载失败
  136. hideLoading(()=>{}, '请求失败,原因:'+res.msg)
  137. return
  138. }
  139. hideLoading(()=>{
  140. /// 设置数据
  141. this.setData({
  142. /// 设置列头
  143. myTradingPreSells: res.data,
  144. /// 数据是否为空
  145. isEmpty: res.data.length === 0,
  146. /// 显示数据
  147. values: res.data.map(obj => {
  148. return {
  149. pictureurls: obj.pictureurls,
  150. bannerpicurl: obj.bannerpicurl,
  151. performancetemplateid: obj.performancetemplateid,
  152. presaleapplyid: obj.presaleapplyid,
  153. wrstandardname: isnullstr(obj.wrstandardname),
  154. customername: isnullstr(obj.customername),
  155. tradeamount: obj.tradeamount.toFixed(2),
  156. status: this.data.subtabs.filter(itm => { return itm.id === status })[0].name,
  157. ordertime: isnullstr(obj.ordertime),
  158. freezemargin: obj.freezemargin.toFixed(2),
  159. marginvalue: (obj.marginvalue*100).toFixed(2)+'%',
  160. tradeprice: obj.tradeprice.toFixed(2)+'(元/克拉)',
  161. orderqty: obj.orderqty.toFixed(2),
  162. ysproductionmode: obj.ysproductionmode,
  163. yszscategory: obj.yszscategory,
  164. yieldrate: isnullstr(obj.yieldrate),
  165. zsclaritytypestr: isnullstr(obj.zsclaritytypestr),
  166. zscolortypestr: isnullstr(obj.zscolortypestr),
  167. zscuttypestr: isnullstr(obj.zscuttypestr),
  168. zsfluorescencetypestr: isnullstr(obj.zsfluorescencetypestr),
  169. zspolishtypestr: isnullstr(obj.zspolishtypestr),
  170. zsshapetypestr: isnullstr(obj.zsshapetypestr),
  171. zssymmetrytypestr: isnullstr(obj.zssymmetrytypestr),
  172. sizestr: isnullstr(obj.sizestr),
  173. remark: isnullstr(obj.remark),
  174. placeqty: obj.placeqty,
  175. qtydesc: isnullstr(obj.qtydesc),
  176. weightdesc: isnullstr(obj.weightdesc)
  177. }
  178. })
  179. })
  180. })
  181. },
  182. fail: (emsg) => {
  183. hideLoading(()=>{}, emsg)
  184. },
  185. complete: () => {
  186. /// 停止下拉刷新
  187. wx.stopPullDownRefresh()
  188. }
  189. })
  190. }, '加载中....')
  191. },
  192. /**
  193. * 返回上层视图
  194. */
  195. backToParent() {
  196. /// 返回上层视图
  197. wx.navigateBack()
  198. },
  199. /// 点击
  200. onItemClick(e: any) {
  201. wx.navigateTo({
  202. url: '/mHome/pages/presell/detail/index?item='+JSON.stringify(this.data.values[Number(e.currentTarget.id)])+'&index='+this.data.active
  203. })
  204. },
  205. /**
  206. * 预售申请
  207. */
  208. addPreSell() {
  209. wx.navigateTo({
  210. url: '/mHome/pages/presell/new/index'
  211. })
  212. },
  213. /**
  214. * 预售申请
  215. */
  216. onTabChange(e: any) {
  217. if (e.target.id === "category") {
  218. /// 重置状态
  219. this.setData({ active: e.detail.name })
  220. /// 数据重置
  221. switch (e.detail.name) {
  222. case 1: /// 预售大厅
  223. this.setData({ subtabs: [{id: 2, name: '执行中'}, {id: 1, name: '未开始'}], status: 2 })
  224. break;
  225. case 2: /// 我的预售
  226. this.setData({ subtabs: [{id: 2, name: '执行中'}, {id: 1, name: '未开始'}, {id: 3, name: '已结束'}], status: 2 })
  227. break;
  228. default: /// 我参与的预售
  229. this.setData({ subtabs: [{id: 1, name: '预售中'}, {id: 2, name: '执行中'}, {id: 3, name: '已完成'}], status: 1 })
  230. break;
  231. }
  232. } else {
  233. this.setData({ status: e.detail.name })
  234. }
  235. this.data.active != 3 ? this.queryGZPreSell(this.data.status) : this.queryGZMyTradingPreSell(this.data.status)
  236. },
  237. /**
  238. * 生命周期函数--监听页面加载
  239. */
  240. onLoad() {
  241. this.data.active != 3 ? this.queryGZPreSell(this.data.status) : this.queryGZMyTradingPreSell(this.data.status)
  242. },
  243. /**
  244. * 生命周期函数--监听页面初次渲染完成
  245. */
  246. onReady() {
  247. },
  248. /**
  249. * 生命周期函数--监听页面显示
  250. */
  251. onShow() {
  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. })