// pages/ticketWait/ticketWait.js const utils = require('../../utils/util.js') Page({ /** * 页面的初始数据 */ data: { list: [], pageNum: 1, pageSize: 10, pages: '', finish: false, customerName: '', }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { this.getList() }, //获取待开抬头 getList(type) { let params = { mobile: utils.getInfo().mobile, // reqChannel: 5, belongEntTaxId: wx.getStorageSync('entTaxId'), pageNum: this.data.pageNum, pageSize: this.data.pageSize } let customerName = utils.trimAll(this.data.customerName) if (customerName !== '') { params.customerName = customerName } utils.axios({ method: 'get', url: '/sys/taitou/todo/findPage', data: params, sendBefore() { wx.showLoading({ title: '加载中...' }) }, complete() { wx.hideLoading() wx.stopPullDownRefresh() }, success: res => { let result = res.data if (type === 'toFresh') { this.setData({ list: result.records, pages: result.pages }) } else { let list = this.data.list list = list.concat(result.records) this.setData({ list, pages: result.pages }) } if (result.total <= this.data.pageSize) { this.setData({ finish: true }) } } }) }, toFresh() { this.setData({ pageNum: 1, pages: '', finish: false }) wx.pageScrollTo({ scrollTop: 0, duration: 300 }) this.getList('toFresh') }, //搜素 search(e) { let customerName = e.detail.value this.setData({ customerName }) this.toFresh() }, //确认框 showDel(e) { let params = { mobile: utils.getInfo().mobile, reqChannel: 5, delList: [{ recordId: e.currentTarget.dataset.recordid, belongEntTaxId: e.currentTarget.dataset.belong }] } let index = Number(e.currentTarget.dataset.index) wx.showModal({ content: '确定删除该条数据吗?', confirmColor: '#007dff', success: res => { if (res.confirm) { this.del(params, index) } } }) }, //删除 del(params, index) { utils.axios({ method: 'post', url: '/sys/taitou/todo/delete', data: params, sendBefore() { wx.showLoading({ title: '删除中...', mask: true }) }, complete() { wx.hideLoading() }, success: res => { let list = this.data.list list.splice(index, 1) this.setData({ list }) utils.toast('删除成功') } }) }, //点击开票 toTicket(e) { let index = e.currentTarget.dataset.index let item = this.data.list[index] wx.setStorageSync('ticketMakeData', item) wx.navigateTo({ url: '/pages/ticketMake/ticketMake' }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { this.toFresh() }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { let pageNum = this.data.pageNum let pages = this.data.pages pageNum++ if (pageNum <= pages) { this.setData({ pageNum }) this.getList() } else { this.setData({ finish: true }) return } }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { return { title: '诺信云', path: '/pages/index/index' } } })