wallet.js 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. const util = require("../../utils/util.js");
  2. const app = getApp();
  3. Page({
  4. data: {
  5. array: ['全部','一级购活动','二级购活动','自购活动','奖金','退款返还','提现','拒绝提现','购买使用','其它'],
  6. index:0,
  7. finishedText:'',
  8. finished: false,
  9. pageSize:10,
  10. pageIndex:1,
  11. list: [],
  12. walletInfo:{},
  13. showPriceTip:false
  14. },
  15. onShow:function(){
  16. this.getList(true)
  17. this.getWallet();
  18. },
  19. onReachBottom: function () {
  20. var self = this;
  21. if(self.data.finished) return false;
  22. setTimeout(function () {
  23. self.setData({ pageIndex: self.data.pageIndex + 1 });
  24. self.getList(false);
  25. }, 1000);
  26. },
  27. getList(load) {
  28. let that = this;
  29. let ctypeArr = [-1,6,7,10,12,13,2,14,1,0];
  30. util.ajax({
  31. func: "v2/user/coin/list",
  32. data: {
  33. pageSize: that.data.pageSize,
  34. pageIndex: that.data.pageIndex,
  35. ctype: ctypeArr[that.data.index],
  36. },
  37. load: true
  38. }, function (res) {
  39. if (res.code == 0) {
  40. res.data.list = res.data.list.map((item) => {
  41. let avatar = item.avatar ? item.avatar : '/images/default_logo.jpg';
  42. if(item.price.toString().indexOf('-') != -1) {
  43. return {...item, signStatus: false, price: util.toMoney(item.price, ','), avatar}
  44. } else {
  45. return {...item, signStatus: true, price: util.toMoney(item.price, ','), avatar}
  46. }
  47. })
  48. let list = load ? res.data.list : [...that.data.list, ...res.data.list];
  49. that.setData({list});
  50. if (that.data.list.length >= res.data.total || that.data.list.length < that.data.pageSize) {
  51. that.setData({ finishedText: that.data.list.length < that.data.pageSize ? '' : "~~已经到底了~~", finished:true})
  52. } else {
  53. }
  54. } else {
  55. util.showTips(res.reason);
  56. }
  57. });
  58. },
  59. getWallet(){
  60. let that = this;
  61. util.ajax({
  62. func: "v2/user/coin/stat",
  63. data: {type:1},
  64. }, function (res) {
  65. if (res.code == 0) {
  66. let walletInfo = {};
  67. walletInfo.coinUnpaidAccount = util.toMoney(res.data.coinUnpaidAccount, ',');
  68. walletInfo.coinTatal = util.toMoney(res.data.coinTatal, ',');
  69. walletInfo.coinBalance = util.toMoney(res.data.coinBalance, ',');
  70. walletInfo.coinOneLevelIncome = util.toMoney(res.data.coinOneLevelIncome, ',');
  71. walletInfo.coinTwoLevelIncome = util.toMoney(res.data.coinTwoLevelIncome, ',');
  72. that.setData({walletInfo})
  73. } else {
  74. util.showTips(res.reason);
  75. }
  76. });
  77. },
  78. bindChildChange(e) {
  79. this.setData({index:e.detail.value,pageIndex: 1})
  80. this.getList(true)
  81. },
  82. binderror(e) {
  83. var list = this.data.list, index = e.currentTarget.dataset.index;
  84. list[index].avatar = '/images/default_logo.jpg'
  85. this.setData({ list });
  86. },
  87. navigatorURl(e){
  88. console.log(e)
  89. let bol = e.currentTarget.dataset.bol || 0; //仅用于小程序不支持提现提示
  90. if (bol) {
  91. util.navigator(e.currentTarget.dataset.url);
  92. } else {
  93. this.setData({showPriceTip:true})
  94. }
  95. },
  96. })