纸通宝小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

81 lines
2.0 KiB

// pages/balance/fragment/index.js
const request = require('../../../utils/request'); //导入模块
Component({
options: {
addGlobalClass: true,
multipleSlots: true
},
properties: {
direction: {
type: Number,
value: 0
},
height: {
type: Number,
value: 0
}
},
/**
* 页面的初始数据
*/
data: {
firstShow: false,
finished: false,
requesting: false,
taskList: [],
form: {
pageSize: 10,
pageNum: 1,
direction: null
}
},
methods: {
onRestart: function () {
if (!this.data.firstShow) {
this.fetchList()
this.data.firstShow = true
}
},
fetchList: function () {
if (this.data.requesting || this.data.finished) {
return
}
this.data.form.direction = this.data.direction
this.data.requesting = true
wx.showLoading({ title: '加载中', mask: true })
// /product/cheapList特价产品列表
request.get('/saas-user/account/financeLog/list', this.data.form).then(result => {
//成功回调
this.setData({ requesting: false, loading: false })
if (result.data.records.length) {
var respList = result.data.records
let nowList = `taskList[${this.data.taskList.length}]`
var num = this.data.form.pageNum
var finished = this.data.form.pageNum >= result.data.pages
this.setData({
[nowList]: respList,
total: result.data.total,
['form.pageNum']: (num + 1),
finished
})
} else {
this.setData({
finished: true
})
}
wx.hideLoading()
}).catch(err => {
//异常回调
this.setData({ requesting: false, loading: false })
wx.hideLoading()
util.showToast(err)
})
},
lookItem: function(e){
wx.navigateTo({
url: '/pages/balance/detail/index?id=' + e.currentTarget.id + '&type=' + this.data.direction
})
}
}
})