list.ts 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. import Toast from "../../../../miniprogram_npm/@vant/weapp/toast/toast"
  2. import { queryWrUserReceiptInfo } from "../../../../services/api/common/index"
  3. import { userid } from "../../../../services/utils"
  4. // mMine/pages/invoice/list/list.ts
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. /// 底部安全区域
  11. safeBottom: getApp().globalData.safeBottom,
  12. /// 是否空数据
  13. isEmpty: true,
  14. /// 数据信息
  15. infos: <Array<GuangZuan.WrUserReceiptInfo>>[]
  16. },
  17. /**
  18. * 返回上层视图
  19. */
  20. backToParent() {
  21. /// 返回上层视图
  22. wx.navigateBack()
  23. },
  24. /**
  25. * 按钮点击响应事件
  26. */
  27. onButtonPressed(e: any) {
  28. switch (e.target.id) {
  29. case "new": /// 新增
  30. wx.navigateTo({
  31. url: "/mMine/pages/invoice/operate/operate"
  32. })
  33. break;
  34. default: /// 修改
  35. wx.navigateTo({
  36. url: "/mMine/pages/invoice/operate/operate?id="+JSON.stringify(this.data.infos[e.currentTarget.id])
  37. })
  38. break;
  39. }
  40. },
  41. /// 查询用户发票信息
  42. queryWrUserReceiptInfo() {
  43. /// showLoading
  44. Toast.loading({ message: '数据查询中.....'})
  45. /// 发送查询请求
  46. queryWrUserReceiptInfo({
  47. data: {
  48. userid: userid()
  49. },
  50. success: (res) => {
  51. /// 加载失败
  52. if (res.code != 200) {
  53. Toast('数据加载失败,原因:'+res.msg)
  54. return
  55. }
  56. /// 数据信息
  57. this.setData({ infos: res.data })
  58. },
  59. fail: (emsg) => {
  60. Toast('数据加载失败,原因:'+emsg)
  61. },
  62. complete: () => {
  63. /// 清楚Toast
  64. Toast.clear()
  65. /// 结束下拉刷新
  66. wx.stopPullDownRefresh()
  67. /// 判断数据是否为空
  68. this.setData({ isEmpty: this.data.infos.length == 0 })
  69. }
  70. })
  71. },
  72. /**
  73. * 生命周期函数--监听页面加载
  74. */
  75. onLoad() {
  76. },
  77. /**
  78. * 生命周期函数--监听页面初次渲染完成
  79. */
  80. onReady() {
  81. },
  82. /**
  83. * 生命周期函数--监听页面显示
  84. */
  85. onShow() {
  86. /// 查询用户发票信息
  87. this.queryWrUserReceiptInfo()
  88. },
  89. /**
  90. * 生命周期函数--监听页面隐藏
  91. */
  92. onHide() {
  93. },
  94. /**
  95. * 生命周期函数--监听页面卸载
  96. */
  97. onUnload() {
  98. },
  99. /**
  100. * 页面相关事件处理函数--监听用户下拉动作
  101. */
  102. onPullDownRefresh() {
  103. /// 查询用户发票信息
  104. this.queryWrUserReceiptInfo()
  105. },
  106. /**
  107. * 页面上拉触底事件的处理函数
  108. */
  109. onReachBottom() {
  110. },
  111. /**
  112. * 用户点击右上角分享
  113. */
  114. onShareAppMessage() {
  115. }
  116. })