index.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. // index.js
  2. // 获取应用实例
  3. import http from '../../base/httputil'
  4. const app = getApp()
  5. Page({
  6. data: {
  7. host: app.globalData.host,
  8. current: 0, //当前所在页面的 index
  9. dofun: null,
  10. xunjianImgCount: '000,000',
  11. NoticeTitle: "登录查看公告",
  12. noticeItem: '',
  13. },
  14. onReady() {
  15. },
  16. onLoad() {
  17. },
  18. onShow() {
  19. },
  20. // 通知公告更多跳转
  21. bindViewGengDuo() {
  22. if (app.globalToken == null) {
  23. wx.showToast({
  24. title: '尚未登录,登录后即可使用',
  25. icon: 'none'
  26. })
  27. return
  28. }
  29. wx.navigateTo({
  30. url: '../notice/notice'
  31. })
  32. },
  33. initIndexPage() {
  34. if (app.globalToken == null || app.globalToken == '') {
  35. return
  36. }
  37. http.send_post("/system/AppIndexController/getIndexPageData", null, this.initIndexPageSuccess)
  38. },
  39. initIndexPageSuccess(res) {
  40. if (res.code == 200) {
  41. this.setData({
  42. xunjianImgCount: res.data.xunjianImgCount,
  43. })
  44. if (res.data.noticeList.length > 0) {
  45. this.setData({
  46. NoticeTitle: res.data.noticeList[0].noticeTitle,
  47. noticeItem: res.data.noticeList[0]
  48. })
  49. } else {
  50. this.setData({
  51. NoticeTitle: "暂无公告"
  52. })
  53. }
  54. }
  55. },
  56. goNoticeDetails(e) {
  57. let details = e.currentTarget.dataset.item
  58. if (app.globalToken == null) {
  59. wx.showToast({
  60. title: '尚未登录,登录后即可使用',
  61. icon: 'none'
  62. })
  63. return
  64. }
  65. if (details == null || details == '') {
  66. wx.showToast({
  67. title: '暂无公告',
  68. icon: 'none'
  69. })
  70. return
  71. }
  72. let competition = {}//这是一个很长的很多数据的对象
  73. //转成String编码一下
  74. competition = encodeURIComponent(JSON.stringify(details))
  75. wx.navigateTo({
  76.  url:`../notice/notice_details?details=${competition}`
  77. })  
  78. },
  79. onTabItemTap(item) {
  80. }
  81. })