import { queryWrUserReceiptInfo } from "../../../../services/api/common/index" import { setWrUserReceiptInfo, userid } from "../../../../services/utils" import { hideLoading, showLoading } from "../../../../utils/message/index" Page({ /** * 页面的初始数据 */ data: { /// 底部安全区域 safeBottom: getApp().globalData.safeBottom, /// 是否空数据 isEmpty: true, /// 数据信息 infos: >[], /// 是否从我的页面过来 isMine: 'true' }, /** * 返回上层视图 */ backToParent() { /// 返回上层视图 wx.navigateBack() }, /** * 按钮点击响应事件 */ onButtonPressed(e: any) { const id = e.currentTarget.id switch (id) { case "new": /// 新增 wx.navigateTo({ url: "/mMine/pages/invoice/operate/index" }) break; default: /// 修改 if (this.data.isMine === 'true') { wx.navigateTo({ url: "/mMine/pages/invoice/operate/index?id="+JSON.stringify(this.data.infos[e.currentTarget.id]) }) } else { setWrUserReceiptInfo(this.data.infos[Number(id)]) wx.navigateBack() } break; } }, /// 查询用户发票信息 queryWrUserReceiptInfo() { /// showLoading showLoading(()=>{ /// 发送查询请求 queryWrUserReceiptInfo({ data: { userid: userid() }, success: (res) => { /// 加载失败 if (res.code != 200) { hideLoading(()=>{}, '数据加载失败,原因:'+res.msg) return } /// 数据信息 hideLoading(()=>{ this.setData({ infos: res.data, isEmpty: res.data.length === 0 }) }) }, fail: (emsg) => { hideLoading(()=>{}, emsg) }, complete: () => { /// 结束下拉刷新 wx.stopPullDownRefresh() } }) }) }, /** * 生命周期函数--监听页面加载 */ onLoad(options: any) { this.setData({ isMine: options.isMine }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { /// 查询用户发票信息 this.queryWrUserReceiptInfo() }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { /// 查询用户发票信息 this.queryWrUserReceiptInfo() }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })