accounts.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. var _request = require('../../../../utils/request.js')
  2. var id
  3. Page({
  4. data: {
  5. page: 1,
  6. per_page: 10,
  7. list: [],
  8. already_settle:'',
  9. not_settle:'',
  10. total_sale:'',
  11. // settle_price:[],
  12. more: true,
  13. num: ''
  14. },
  15. onLoad: function (options) {
  16. id = options.id
  17. // var app = getApp()
  18. // new app.ToastPannel()
  19. this.getSettleList()
  20. this.getSettleStat()
  21. this.getTime()
  22. },
  23. getSettleList () {
  24. var that = this
  25. var url = 'v1/merchant/settle/list'
  26. var params = {
  27. merchant_id: id,
  28. page: this.data.page,
  29. per_page: this.data.per_page
  30. }
  31. var success = function (res) {
  32. // var arr = []
  33. // for(var i = 0; i<data.length; i++){
  34. // // console.log(data[i].settle_price)
  35. // arr.push(that.formatNumber(data[i].settle_price))
  36. // console.log(arr.length)
  37. // }
  38. var result = that.data.list.concat(res.data.list || [])
  39. console.log(result)
  40. that.setData({
  41. list: result,
  42. // settle_price: arr
  43. })
  44. var listMore = res.data.list_count > that.data.list.length
  45. that.setData({
  46. more: listMore
  47. })
  48. }
  49. _request.$get(url, params, success, that)
  50. },
  51. getSettleStat () {
  52. var that = this
  53. var url = 'v1/merchant/settle/stat'
  54. var params = {
  55. merchant_id: id,
  56. }
  57. var success = function (res) {
  58. var data1 = res.data
  59. console.log(data1)
  60. that.setData({
  61. already_settle: that.formatNumber(data1.already_settle),
  62. not_settle: that.formatNumber(data1.not_settle),
  63. total_sale: that.formatNumber(data1.total_sale)
  64. })
  65. }
  66. _request.$get(url, params, success, that)
  67. },
  68. //千分位格式化
  69. formatNumber (num) {
  70. var num1 = num.toFixed(2)
  71. if (isNaN(num)) {
  72. throw new TypeError("num is not a number");
  73. }
  74. return ("" + num1).replace(/(\d{1,3})(?=(\d{3})+(?:$|\.))/g, "$1,");
  75. },
  76. toOther () {
  77. wx.navigateTo({
  78. url: '/pages/parse/parse?id=10'
  79. })
  80. },
  81. onReachBottom: function () {
  82. if (this.data.more) {
  83. var page = this.data.page + 1
  84. this.setData({
  85. page: page
  86. })
  87. this.getSettleList()
  88. }
  89. },
  90. getTime () {
  91. var that = this
  92. var date=new Date;
  93. var year=date.getFullYear();
  94. var month=date.getMonth()+1;
  95. month =(month<10 ? "0"+month:month);
  96. var mydate = (year.toString()+'/'+month.toString());
  97. that.setData({
  98. num: mydate
  99. })
  100. }
  101. })