scholarship.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. var util = require("../../utils/util.js")
  2. const app = getApp()
  3. Page({
  4. data: {
  5. userInfo: {
  6. avatarUrl: 'https://yuesuo.yueguanjia.com/MiniProgram/images/head.png',
  7. name: ''
  8. },
  9. listData: [],
  10. listTab: [{
  11. n: '全部',
  12. i: 'all'
  13. }, {
  14. n: 'LV1',
  15. i: 1
  16. }, {
  17. n: 'LV2',
  18. i: 2
  19. },
  20. {
  21. n: 'LV3',
  22. i: 3
  23. }, {
  24. n: 'LV4',
  25. i: 4
  26. }, {
  27. n: 'LV5',
  28. i: 5
  29. }
  30. ],
  31. activeTab: 'all',
  32. loaddisplay: true,
  33. hasLogin: false,
  34. },
  35. onLoad: function(options) {
  36. this.setData({
  37. navH: app.globalData.navHeight
  38. });
  39. this.getPostDataNologin();
  40. },
  41. onShow: function() {
  42. const _this = this;
  43. wx.checkSession({
  44. success(res) {
  45. app.setUserInfo().then(() => {
  46. _this.getPostData()
  47. });
  48. }
  49. })
  50. },
  51. // 获取页面数据
  52. getPostData() {
  53. util.postData('/college/queryRedeemIndex', {
  54. openid: app.globalData.openid
  55. })
  56. .then(res => {
  57. console.log(res)
  58. if (res.code == '1000000') {
  59. app.checkSession();
  60. } else {
  61. this.setData({
  62. userInfo: res.userInfo,
  63. listData: res.presentInfo
  64. })
  65. }
  66. })
  67. },
  68. // 没登陆获取页面数据
  69. getPostDataNologin() {
  70. const _this = this;
  71. util.postData('/college/queryRedeemIndexNoLogin')
  72. .then(res => {
  73. console.log(res)
  74. _this.setData({
  75. listData: res.presentInfo
  76. })
  77. })
  78. },
  79. tologin() {
  80. app.checkSession()
  81. },
  82. // 选择不同的级别
  83. selectTab(event) {
  84. // console.log(event)
  85. this.setData({
  86. activeTab: event.currentTarget.dataset.id
  87. })
  88. },
  89. // 兑换记录
  90. gotoRecord() {
  91. app.checkSession().then(res => {
  92. wx.navigateTo({
  93. url: '/pages/scholarship/record/record'
  94. })
  95. })
  96. },
  97. // 去兑换
  98. exchange(event) {
  99. console.log(event)
  100. let dataSet = event.currentTarget.dataset
  101. wx.navigateTo({
  102. url: '/pages/scholarship/info/info?id=' + dataSet.id
  103. })
  104. },
  105. onShareAppMessage: function() {}
  106. })