index.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. define([
  2. 'api/auth',
  3. 'text!./index.html',
  4. 'css!./index.css'
  5. ], function(authApi, html) {
  6. return {
  7. props: {
  8. activeName: {
  9. type: String,
  10. default: 'balance'
  11. },
  12. isLogin: {
  13. type: Boolean,
  14. default: false
  15. }
  16. },
  17. data: function () {
  18. return {
  19. balance: '',
  20. consumption: '',
  21. recharge: '',
  22. active: 'first',
  23. page1: 1,
  24. page2: 1,
  25. page3: 1,
  26. limit: 20,
  27. balanceList1: [],
  28. balanceList2: [],
  29. balanceList3: [],
  30. total1: 0,
  31. total2: 0,
  32. total3: 0
  33. };
  34. },
  35. watch: {
  36. isLogin: function (value) {
  37. if (value) {
  38. this.get_user_balance();
  39. this.get_user_balance_list1();
  40. this.get_user_balance_list2();
  41. this.get_user_balance_list3();
  42. }
  43. }
  44. },
  45. methods: {
  46. get_user_balance: function () {
  47. var vm = this;
  48. authApi.get_user_balance({}).then(function (res) {
  49. var data = res.data;
  50. vm.balance = data.balance;
  51. vm.consumption = data.consumption;
  52. vm.recharge = data.recharge;
  53. }).catch(function (err) {
  54. vm.$message.error(err.msg);
  55. });
  56. },
  57. get_user_balance_list1: function () {
  58. var vm = this;
  59. authApi.get_user_balance_list({
  60. page: this.page1,
  61. limit: this.limit,
  62. index: ''
  63. }).then(function (res) {
  64. vm.balanceList1 = res.data.list;
  65. vm.total1 = res.data.count;
  66. }).catch(function (err) {
  67. vm.$message.error(err.msg);
  68. });
  69. },
  70. get_user_balance_list2: function () {
  71. var vm = this;
  72. authApi.get_user_balance_list({
  73. page: this.page2,
  74. limit: this.limit,
  75. index: 2
  76. }).then(function (res) {
  77. vm.balanceList2 = res.data.list;
  78. vm.total2 = res.data.count;
  79. }).catch(function (err) {
  80. vm.$message.error(err.msg);
  81. });
  82. },
  83. get_user_balance_list3: function () {
  84. var vm = this;
  85. authApi.get_user_balance_list({
  86. page: this.page3,
  87. limit: this.limit,
  88. index: 1
  89. }).then(function (res) {
  90. vm.balanceList3 = res.data.list;
  91. vm.total3 = res.data.count;
  92. }).catch(function (err) {
  93. vm.$message.error(err.msg);
  94. });
  95. },
  96. handleClick: function (tab, event) {
  97. }
  98. },
  99. template: html
  100. };
  101. });