102 lines
3.1 KiB
JavaScript
102 lines
3.1 KiB
JavaScript
// pages/mine/mineAccount/mineInvoice/mineInvoice.js
|
|
import InvoiceApi from '../../../../net/api/invoiceApi'
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
keywords: '',
|
|
pageData: {
|
|
page: 1,
|
|
rows: 10,
|
|
keywords: ''
|
|
},
|
|
msgShow: false,
|
|
msgHint: '',
|
|
msgType: 'error',
|
|
loadingState: 'loading',
|
|
listRefreshTrig: false,
|
|
isLoadMore: false,
|
|
hasMore: true,
|
|
recordList: [], //开票记录
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad(options) {
|
|
wx.setNavigationBarTitle({
|
|
title: '发票管理',
|
|
})
|
|
wx.setNavigationBarColor({
|
|
frontColor: '#000000', // 必写项,字体颜色仅支持#ffffff和#000000
|
|
backgroundColor: '#F0F0F0', // 传递的颜色值,仅支持十六进制颜色
|
|
animation: { // 可选项
|
|
duration: 500,
|
|
timingFunc: 'easeIn'
|
|
}
|
|
})
|
|
this.doRefreshList()
|
|
},
|
|
openInvoiceInfo() {
|
|
wx.navigateTo({
|
|
url: '/pages/mine/mineAccount/invoiceInfo/invoiceInfo',
|
|
})
|
|
},
|
|
doRefreshList() {
|
|
console.log('正在刷新...')
|
|
const _self = this
|
|
_self.setData({
|
|
listRefreshTrig: true,
|
|
loadingState: 'loading',
|
|
hasMore: true,
|
|
'pageData.page': 1,
|
|
'pageData.keywords': _self.data.keywords,
|
|
isLoadMore: false
|
|
})
|
|
_self.doGetInvoiceRecordList(true)
|
|
},
|
|
doLoadMore() {
|
|
//判断是否正在加载中 与是否存在更多数据
|
|
const _self = this
|
|
if (_self.data.isLoadMore || !_self.data.hasMore) {
|
|
return
|
|
}
|
|
_self.setData({
|
|
isLoadMore: true,
|
|
'pageData.page': ++_self.data.pageData.page,
|
|
'pageData.keywords': _self.data.keywords
|
|
})
|
|
_self.doGetInvoiceRecordList(false)
|
|
},
|
|
doGetInvoiceRecordList(isRefresh) {
|
|
const _self = this
|
|
_self.setData({
|
|
recordList: isRefresh ? [] : _self.data.recordList,
|
|
loadingState: isRefresh ? 'loading' : ''
|
|
})
|
|
InvoiceApi.doGetInvoiceRecordList(_self.data.pageData)
|
|
.then(res => {
|
|
console.log(res)
|
|
var status = 'success'
|
|
status = res.rows && res.rows.length > 0 ? 'success' : 'empty'
|
|
_self.setData({
|
|
loadingState: isRefresh ? status : '',
|
|
recordList: _self.data.recordList.concat(res.rows),
|
|
listRefreshTrig: false,
|
|
isLoadMore: false
|
|
})
|
|
_self.setData({
|
|
hasMore: _self.data.recordList.length < res.total
|
|
})
|
|
}, err => {
|
|
_self.setData({
|
|
loadingState: 'error',
|
|
listRefreshTrig: false,
|
|
isLoadMore: false,
|
|
hasMore: true
|
|
})
|
|
})
|
|
}
|
|
}) |