const util = require("../../utils/util.js"); const app = getApp(); Page({ data: { array: ['全部','一级购活动','二级购活动','自购活动','奖金','退款返还','提现','拒绝提现','购买使用','其它'], index:0, finishedText:'', finished: false, pageSize:10, pageIndex:1, list: [], walletInfo:{}, showPriceTip:false }, onShow:function(){ this.getList(true) this.getWallet(); }, onReachBottom: function () { var self = this; if(self.data.finished) return false; setTimeout(function () { self.setData({ pageIndex: self.data.pageIndex + 1 }); self.getList(false); }, 1000); }, getList(load) { let that = this; let ctypeArr = [-1,6,7,10,12,13,2,14,1,0]; util.ajax({ func: "v2/user/coin/list", data: { pageSize: that.data.pageSize, pageIndex: that.data.pageIndex, ctype: ctypeArr[that.data.index], }, load: true }, function (res) { if (res.code == 0) { res.data.list = res.data.list.map((item) => { let avatar = item.avatar ? item.avatar : '/images/default_logo.jpg'; if(item.price.toString().indexOf('-') != -1) { return {...item, signStatus: false, price: util.toMoney(item.price, ','), avatar} } else { return {...item, signStatus: true, price: util.toMoney(item.price, ','), avatar} } }) let list = load ? res.data.list : [...that.data.list, ...res.data.list]; that.setData({list}); if (that.data.list.length >= res.data.total || that.data.list.length < that.data.pageSize) { that.setData({ finishedText: that.data.list.length < that.data.pageSize ? '' : "~~已经到底了~~", finished:true}) } else { } } else { util.showTips(res.reason); } }); }, getWallet(){ let that = this; util.ajax({ func: "v2/user/coin/stat", data: {type:1}, }, function (res) { if (res.code == 0) { let walletInfo = {}; walletInfo.coinUnpaidAccount = util.toMoney(res.data.coinUnpaidAccount, ','); walletInfo.coinTatal = util.toMoney(res.data.coinTatal, ','); walletInfo.coinBalance = util.toMoney(res.data.coinBalance, ','); walletInfo.coinOneLevelIncome = util.toMoney(res.data.coinOneLevelIncome, ','); walletInfo.coinTwoLevelIncome = util.toMoney(res.data.coinTwoLevelIncome, ','); that.setData({walletInfo}) } else { util.showTips(res.reason); } }); }, bindChildChange(e) { this.setData({index:e.detail.value,pageIndex: 1}) this.getList(true) }, binderror(e) { var list = this.data.list, index = e.currentTarget.dataset.index; list[index].avatar = '/images/default_logo.jpg' this.setData({ list }); }, navigatorURl(e){ console.log(e) let bol = e.currentTarget.dataset.bol || 0; //仅用于小程序不支持提现提示 if (bol) { util.navigator(e.currentTarget.dataset.url); } else { this.setData({showPriceTip:true}) } }, })