myperformance.ts 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. import { queryMyPerformanc } from "../../../services/api/orders/index"
  2. import { getPerformancestatus, getSteptype, userid } from "../../../services/utils"
  3. // mMine/pages/myperformance/myperformance.ts
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. /// tab激活索引
  10. active: 0,
  11. /// tabs
  12. tabs: [{id: 0, name: '买履约'}, {id: 1, name: '卖履约'}],
  13. /// 列头
  14. titles: ['付款方式', '总金额', '已付金额', '履约冻结金额', '约剩余冻结', '买卖方', '履约状态', '当前步骤', '剩余天数'],
  15. /// 列表总宽度
  16. totalWidth: 0,
  17. /// 是否空数据
  18. isEmpty: false,
  19. /// 列表宽度
  20. widths: [80, 80, 80, 80, 80, 80, 80, 80, 80],
  21. /// 内容
  22. values: <any>[[]],
  23. /// 选中行数
  24. selectRow: -1,
  25. },
  26. /// 查询我的履约
  27. queryMyPerformanc(buyOrSell: number) {
  28. /// loding.....
  29. wx.showLoading({ title: '数据请求中....' })
  30. /// 发送请求
  31. queryMyPerformanc({
  32. data: {
  33. userid: userid(),
  34. buyorsell: buyOrSell
  35. },
  36. success: (res) => {
  37. this.setData({
  38. values: res.data.map(obj => {
  39. return [obj.paymenttype == 1 ? '冻结' : '扣款',
  40. obj.amount,
  41. obj.buyorsell == 0 ? obj.buypaidamount : obj.sellreceivedamount,
  42. obj.buyorsell == 0 ? obj.buyerfreezeamount : obj.sellerfreezeamount,
  43. obj.buyorsell == 0 ? obj.buyerfreezeamountremain : obj.sellerfreezeamountremain,
  44. obj.buyorsell == 0 ? obj.sellerinfo : obj.buyerinfo,
  45. getPerformancestatus(obj.performancestatus),
  46. getSteptype(obj.steptypeid),
  47. obj.remaindays]
  48. })
  49. })
  50. },
  51. fail: (emsg) => {
  52. /// showToast
  53. wx.showToast({
  54. title: '数据请求失败, 原因:'+emsg,
  55. icon: 'error'
  56. })
  57. },
  58. complete: () => {
  59. /// hideLoading
  60. wx.hideLoading()
  61. /// 判断数据是否为空
  62. this.setData({
  63. isEmpty: this.data.values.length == 0
  64. })
  65. }
  66. })
  67. },
  68. /**
  69. * tabbar点击事件
  70. */
  71. onTabChange(e: any) {
  72. console.log(e)
  73. },
  74. /**
  75. * 返回上层视图
  76. */
  77. backToParent() {
  78. /// 返回上层视图
  79. wx.navigateBack()
  80. },
  81. /**
  82. * 点击每行触发事件
  83. */
  84. onListItemClick(e: any) {
  85. this.setData({
  86. selectRow: this.data.selectRow == e.currentTarget.id ? -1 : e.currentTarget.id
  87. })
  88. console.log(this.data.selectRow)
  89. },
  90. /**
  91. * 生命周期函数--监听页面加载
  92. */
  93. onLoad() {
  94. /// 计算总高度
  95. let num = 0.0
  96. this.data.widths.forEach(function(v) {
  97. num += v
  98. })
  99. this.setData({
  100. /// 设置总高度
  101. totalWidth: num
  102. })
  103. },
  104. /**
  105. * 生命周期函数--监听页面初次渲染完成
  106. */
  107. onReady() {
  108. },
  109. /**
  110. * 生命周期函数--监听页面显示
  111. */
  112. onShow() {
  113. /// 查询我的买履约
  114. this.queryMyPerformanc(0)
  115. },
  116. /**
  117. * 生命周期函数--监听页面隐藏
  118. */
  119. onHide() {
  120. },
  121. /**
  122. * 生命周期函数--监听页面卸载
  123. */
  124. onUnload() {
  125. },
  126. /**
  127. * 页面相关事件处理函数--监听用户下拉动作
  128. */
  129. onPullDownRefresh() {
  130. /// 查询我的买卖履约
  131. this.queryMyPerformanc(this.data.active)
  132. },
  133. /**
  134. * 页面上拉触底事件的处理函数
  135. */
  136. onReachBottom() {
  137. },
  138. /**
  139. * 用户点击右上角分享
  140. */
  141. onShareAppMessage() {
  142. }
  143. })