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