index.ts 9.5 KB

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