index.ts 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  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(62)
  46. } : {
  47. presalestatus: presalestatus,
  48. marketid: marketID(62),
  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. sellwrtradeorderid: isnullstr(obj.sellwrtradeorderid)
  101. }
  102. })
  103. })
  104. })
  105. },
  106. fail: (emsg) => {
  107. hideLoading(()=>{}, emsg)
  108. },
  109. complete: () => {
  110. /// 停止下拉刷新
  111. wx.stopPullDownRefresh()
  112. }
  113. })
  114. }, '加载中....')
  115. },
  116. /**
  117. * 我参与的预售(预售中\执行中)\我参与的集采(集采中\执行中) 列表查询
  118. * 状态 1:预售中\集采中 2:执行中 3:已完成
  119. */
  120. queryGZMyTradingPreSell(status: number) {
  121. /// loding
  122. showLoading(()=>{
  123. /// 数据查询请求
  124. queryGZMyTradingPreSell({
  125. data: {
  126. userid: userid(),
  127. marketid: marketID(62),
  128. status: status
  129. },
  130. success: (res) => {
  131. /// 请求失败
  132. if (res.code != 200) {
  133. /// 加载失败
  134. hideLoading(()=>{}, '请求失败,原因:'+res.msg)
  135. return
  136. }
  137. hideLoading(()=>{
  138. /// 设置数据
  139. this.setData({
  140. /// 设置列头
  141. myTradingPreSells: res.data,
  142. /// 数据是否为空
  143. isEmpty: res.data.length === 0,
  144. /// 显示数据
  145. values: res.data.map(obj => {
  146. return {
  147. pictureurls: obj.pictureurls,
  148. bannerpicurl: obj.bannerpicurl,
  149. performancetemplateid: obj.performancetemplateid,
  150. presaleapplyid: obj.presaleapplyid,
  151. wrstandardname: isnullstr(obj.wrstandardname),
  152. customername: isnullstr(obj.customername),
  153. tradeamount: obj.tradeamount.toFixed(2),
  154. status: this.data.subtabs.filter(itm => { return itm.id === status })[0].name,
  155. ordertime: isnullstr(obj.ordertime),
  156. freezemargin: obj.freezemargin.toFixed(2),
  157. marginvalue: (obj.marginvalue*100).toFixed(2)+'%',
  158. tradeprice: obj.tradeprice.toFixed(2)+'(元/克拉)',
  159. orderqty: obj.orderqty.toFixed(2),
  160. ysproductionmode: obj.ysproductionmode,
  161. yszscategory: obj.yszscategory,
  162. yieldrate: isnullstr(obj.yieldrate),
  163. zsclaritytypestr: isnullstr(obj.zsclaritytypestr),
  164. zscolortypestr: isnullstr(obj.zscolortypestr),
  165. zscuttypestr: isnullstr(obj.zscuttypestr),
  166. zsfluorescencetypestr: isnullstr(obj.zsfluorescencetypestr),
  167. zspolishtypestr: isnullstr(obj.zspolishtypestr),
  168. zsshapetypestr: isnullstr(obj.zsshapetypestr),
  169. zssymmetrytypestr: isnullstr(obj.zssymmetrytypestr),
  170. sizestr: isnullstr(obj.sizestr),
  171. remark: isnullstr(obj.remark),
  172. placeqty: obj.placeqty
  173. }
  174. })
  175. })
  176. })
  177. },
  178. fail: (emsg) => {
  179. hideLoading(()=>{}, emsg)
  180. },
  181. complete: () => {
  182. /// 停止下拉刷新
  183. wx.stopPullDownRefresh()
  184. }
  185. })
  186. }, '加载中....')
  187. },
  188. /**
  189. * 返回上层视图
  190. */
  191. backToParent() {
  192. /// 返回上层视图
  193. wx.navigateBack()
  194. },
  195. /// 点击
  196. onItemClick(e: any) {
  197. console.log(e)
  198. wx.navigateTo({
  199. url: '/mHome/pages/purchase/detail/index?item='+JSON.stringify(this.data.values[e.currentTarget.id])+'&index='+this.data.active
  200. })
  201. },
  202. /**
  203. * 集采申请
  204. */
  205. addPurchase() {
  206. wx.navigateTo({
  207. url: '/mHome/pages/purchase/new/index'
  208. })
  209. },
  210. /**
  211. * 预售申请
  212. */
  213. onTabChange(e: any) {
  214. if (e.target.id === "category") {
  215. /// 数据重置
  216. switch (e.detail.name) {
  217. case 1: /// 预售大厅
  218. this.setData({ subtabs: [{id: 2, name: '执行中'}, {id: 1, name: '未开始'}] })
  219. /// 重置状态
  220. this.setData({ status: 2, active: e.detail.name })
  221. break;
  222. case 2: /// 我的预售
  223. this.setData({ subtabs: [ {id: 2, name: '执行中'}, {id: 1, name: '未开始'}, {id: 3, name: '已结束'}] })
  224. /// 重置状态
  225. this.setData({ status: 2, active: e.detail.name })
  226. break;
  227. default: /// 我参与的预售
  228. this.setData({ subtabs: [{id: 1, name: '预售中'}, {id: 2, name: '执行中'}, {id: 3, name: '已完成'}] })
  229. /// 重置状态
  230. this.setData({ status: 1, active: e.detail.name })
  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. this.data.active != 3 ? this.queryGZPreSell(this.data.status) : this.queryGZMyTradingPreSell(this.data.status)
  243. },
  244. /**
  245. * 生命周期函数--监听页面初次渲染完成
  246. */
  247. onReady() {
  248. },
  249. /**
  250. * 生命周期函数--监听页面显示
  251. */
  252. onShow() {
  253. },
  254. /**
  255. * 生命周期函数--监听页面隐藏
  256. */
  257. onHide() {
  258. },
  259. /**
  260. * 生命周期函数--监听页面卸载
  261. */
  262. onUnload() {
  263. },
  264. /**
  265. * 页面相关事件处理函数--监听用户下拉动作
  266. */
  267. onPullDownRefresh() {
  268. this.data.active != 3 ? this.queryGZPreSell(this.data.status) : this.queryGZMyTradingPreSell(this.data.status)
  269. },
  270. /**
  271. * 页面上拉触底事件的处理函数
  272. */
  273. onReachBottom() {
  274. },
  275. /**
  276. * 用户点击右上角分享
  277. */
  278. onShareAppMessage() {
  279. }
  280. })