msglist.ts 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. import { queryNotice } from "../../../../services/api/common/index"
  2. // pages/msg/msglist/msglist.ts
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. /// 公告消息
  9. msgs: [{}],
  10. /// tabs
  11. tabs: [{id: 1, title: '公告'}, {id: 2, title: '消息'}],
  12. /// 是否空数据
  13. isEmpty: false,
  14. },
  15. /// 进入公告消息详情页
  16. goToMsgDetail(r: any) {
  17. let jsonStr = JSON.stringify(this.data.msgs[r.currentTarget.id])
  18. wx.navigateTo({
  19. url: '/mHome/pages/msg/msgdetail/msgdetail?id='+jsonStr
  20. })
  21. },
  22. /// onChange
  23. onChange(e: any) {
  24. this.queryNotice(e.detail.index+1)
  25. },
  26. /// 查询公告消息信息
  27. queryNotice(msgtype: number){
  28. /// loding.....
  29. wx.showLoading({ title: '加载中....'})
  30. /// 发送查询请求
  31. queryNotice({
  32. data: {
  33. msgType: msgtype,
  34. loginID: wx.getStorageSync('LoginID')
  35. },
  36. success:(res) => {
  37. /// 加载成功
  38. this.setData({ msgs: res.data })
  39. },
  40. fail: (emsg) => {
  41. /// 加载失败
  42. wx.showToast({
  43. title: '公告消息请求失败, 原因::'+emsg,
  44. icon: 'error',
  45. })
  46. },
  47. complete: () => {
  48. /// hide loding.....
  49. wx.hideLoading()
  50. /// 判断数据是否为空
  51. this.setData({ isEmpty: this.data.msgs.length == 0 })
  52. }
  53. })
  54. },
  55. /**
  56. * 生命周期函数--监听页面加载
  57. */
  58. onLoad() {
  59. /// 查询公告消息
  60. this.queryNotice(1)
  61. },
  62. /**
  63. * 生命周期函数--监听页面初次渲染完成
  64. */
  65. onReady() {
  66. },
  67. /**
  68. * 生命周期函数--监听页面显示
  69. */
  70. onShow() {
  71. },
  72. /**
  73. * 生命周期函数--监听页面隐藏
  74. */
  75. onHide() {
  76. },
  77. /**
  78. * 生命周期函数--监听页面卸载
  79. */
  80. onUnload() {
  81. },
  82. /**
  83. * 页面相关事件处理函数--监听用户下拉动作
  84. */
  85. onPullDownRefresh() {
  86. },
  87. /**
  88. * 页面上拉触底事件的处理函数
  89. */
  90. onReachBottom() {
  91. },
  92. /**
  93. * 用户点击右上角分享
  94. */
  95. onShareAppMessage() {
  96. }
  97. })