myperformance.ts 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. import { queryMyPerformanc } from "../../../services/api/orders/index"
  2. import { getPerformancestatus, getSteptype } 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: wx.getStorageSync('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. onListItemClick(e: any) {
  78. this.setData({
  79. selectRow: this.data.selectRow == e.currentTarget.id ? -1 : e.currentTarget.id
  80. })
  81. console.log(this.data.selectRow)
  82. },
  83. /**
  84. * 生命周期函数--监听页面加载
  85. */
  86. onLoad() {
  87. /// 计算总高度
  88. let num = 0.0
  89. this.data.widths.forEach(function(v) {
  90. num += v
  91. })
  92. this.setData({
  93. /// 设置总高度
  94. totalWidth: num
  95. })
  96. },
  97. /**
  98. * 生命周期函数--监听页面初次渲染完成
  99. */
  100. onReady() {
  101. },
  102. /**
  103. * 生命周期函数--监听页面显示
  104. */
  105. onShow() {
  106. /// 查询我的买履约
  107. this.queryMyPerformanc(0)
  108. },
  109. /**
  110. * 生命周期函数--监听页面隐藏
  111. */
  112. onHide() {
  113. },
  114. /**
  115. * 生命周期函数--监听页面卸载
  116. */
  117. onUnload() {
  118. },
  119. /**
  120. * 页面相关事件处理函数--监听用户下拉动作
  121. */
  122. onPullDownRefresh() {
  123. /// 查询我的买卖履约
  124. this.queryMyPerformanc(this.data.active)
  125. },
  126. /**
  127. * 页面上拉触底事件的处理函数
  128. */
  129. onReachBottom() {
  130. },
  131. /**
  132. * 用户点击右上角分享
  133. */
  134. onShareAppMessage() {
  135. }
  136. })