12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- const util = require('../../../utils/util.js');
- Page({
- data: {
- activeTab:1,
- viewDate:{
- year:util.getNowFormatDate('yyyy'),
- month:util.getNowFormatDate('MM')
- },
- dateList:[],
- pageIndex:1,
- noMore:false
- },
- onLoad: function (options) {
- let nowDate=util.getNowFormatDate('yyyy-MM')
- this.getList()
- },
- onShow: function () {
- },
- // 页面上拉触底事件的处理函数
- onReachBottom: function () {
- this.getList(true)
- },
- getList(type){
- let that=this,data={};
- data.addType=that.data.activeTab;
- data.pageIndex=that.data.pageIndex;
- data.pageSize=15;
- data.crtYear=this.data.viewDate.year;
- data.crtMonth=this.data.viewDate.month;
- util.ajax({
- func: "v2/user/userCoin/list",
- method:'post',
- data: data,
- load:false
- }, function (res) {
- if (res.code==0) {
- res.data.list.forEach(el => {
- el.date_time=util.formatDate(el.crtTime,'',false);
- });
- that.setData({dateList:type?[...that.data.dateList,...res.data.list]:res.data.list,noMore:res.data.list.length<data.pageSize?true:false,pageIndex:that.data.pageIndex+1})
- }else{
- util.showTips(res.reason)
- }
- })
- },
- bindDateChange(e){
- console.log(e)
- let date ={
- year:e.detail.value.split('-')[0],
- month:e.detail.value.split('-')[1]
- }
- this.setData({viewDate:date,pageIndex:1})
- this.getList()
- },
- selectTab(e){
- console.log(e)
- let i=e.currentTarget.dataset.index;
- if (this.data.activeTab!=i) {
- this.setData({activeTab:i,pageIndex:1})
- this.getList()
- }
- }
- })
|