// miniprogram/pages/invoiceStock/invoiceStock.js const utils = require('../../utils/util.js') Page({ /** * 页面的初始数据 */ data: { list: [], invoiceType: ['增值税普通纸质发票', '增值税专用纸质发票', '增值税普通电子发票', '增值税专用电子发票'], invoiceTypeIndex: 0, invoiceStatus: '3', finish: false, isNoData: false, userInfo: '', company: '', invoiceData: {} }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { this.getUser() }, //获取企业信息(当前登录用户的默认企业信息) getUser() { this.setData({ userInfo: utils.getInfo(), company:utils.getCurrEntInfo() }) this.getInvoiceInfo() // utils.getCompany().then(res => { // let result = res.data // this.setData({ // company: result // }) // this.getInvoiceInfo() // }) }, //发票类型 setInvoiceType(e) { let value = Number(e.detail.value) let status = '' if (value === 0) { status = 3 } if (value === 1) { status = 4 } if (value === 2) { status = 1 } if (value === 3) { status = 2 } this.setData({ invoiceTypeIndex: value, invoiceStatus: status }) this.toFresh() }, //发票库存查询 getInvoiceInfo(type) { let params = { entTaxId: this.data.company.entTaxId, deviceType: this.data.company.defaultDeviceInfo.deviceType, taxDiscId: this.data.company.defaultDeviceInfo.taxDiscId, invoiceCategory: this.data.invoiceStatus, } utils.axios({ method: 'get', url: '/sys/invoiceExt/purchaseQuery', data: params, sendBefore() { wx.showLoading({ title: '加载中...' }) }, complete() { wx.hideLoading() wx.stopPullDownRefresh() }, success: res => { this.setData({ invoiceData: res.data }) if (res.data.purchaseDetailVOs.length > 0) { this.setData({ isNoData: false }) } else { this.setData({ isNoData: true }) } } }) }, toFresh() { this.setData({ pageNum: 1, pages: '', finish: false }) wx.pageScrollTo({ scrollTop: 0, duration: 300 }) this.getInvoiceInfo('toFresh') }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { this.toFresh() }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { return { title: '诺信云', path: '/pages/index/index' } } })