vipActivity.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. // pages/vipActivity/vipActivity.js
  2. import httpRequestApi from '../../utils/APIClient';
  3. const app = getApp()
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. peopleNumData: [],
  10. isIOS: app.globalData.isIOS,
  11. date: ''
  12. },
  13. /**
  14. * 生命周期函数--监听页面加载
  15. */
  16. onLoad: function(options) {
  17. this.getVipData();
  18. this.getHelp();
  19. },
  20. /**
  21. * 生命周期函数--监听页面初次渲染完成
  22. */
  23. onReady: function() {
  24. },
  25. /**
  26. * 生命周期函数--监听页面显示
  27. */
  28. onShow: function() {
  29. },
  30. /**
  31. * 生命周期函数--监听页面隐藏
  32. */
  33. onHide: function() {
  34. },
  35. /**
  36. * 生命周期函数--监听页面卸载
  37. */
  38. onUnload: function() {
  39. },
  40. /**
  41. * 页面相关事件处理函数--监听用户下拉动作
  42. */
  43. onPullDownRefresh: function() {
  44. this.getVipData();
  45. this.getHelp();
  46. wx.showNavigationBarLoading() //在标题栏中显示加载
  47. //模拟加载
  48. setTimeout(function() {
  49. wx.hideNavigationBarLoading() //完成停止加载
  50. wx.stopPullDownRefresh() //停止下拉刷新
  51. }, 1000);
  52. },
  53. /**
  54. * 点击分享e
  55. */
  56. shareRead(e) {
  57. this.triggerEvent('openShare', e)
  58. this.shareDialog = this.selectComponent("#share-dialog");
  59. const user = wx.getStorageSync('user');
  60. const type = this.data.isIOS ? 'ios' : 'iphone';
  61. const data = {
  62. avatar: user.avatar,
  63. name: user.nickName,
  64. uid: user.uid,
  65. type,
  66. path: `pages/index/index`
  67. }
  68. this.setData({
  69. noScroll: 'noScroll'
  70. })
  71. this.shareDialog.share(data);
  72. },
  73. onShareAppMessage: function(res) {
  74. if (res.from === 'button') {
  75. const type = this.data.isIOS ? 'ios' : 'iphone';
  76. const user = wx.getStorageSync('user');
  77. return {
  78. title: `${user.nickName}邀请你一起来朗读课文`,
  79. path: `/pages/index/index?type=${type}&uid=${user.uid}`,
  80. imageUrl: 'http://reader-wx.ai160.com/images/reader/pay/share_read_bg.png'
  81. }
  82. }
  83. },
  84. // 获取会员信息
  85. getVipData() {
  86. httpRequestApi.getAuthActivity().success(res => {
  87. if (!res.data.data) {
  88. wx.setStorageSync('vip', false)
  89. wx.setStorageSync('date', '')
  90. } else {
  91. wx.setStorageSync('vip', true)
  92. wx.setStorageSync('date', res.data.data)
  93. this.setData({
  94. date: res.data.data
  95. })
  96. }
  97. }).fail(error => {
  98. console.log(error)
  99. })
  100. },
  101. // 获取帮助的人
  102. getHelp() {
  103. if (this.data.isIOS) {
  104. httpRequestApi.getHelpNum().success(res => {
  105. this.setData({
  106. peopleNumData: res.data.data.list
  107. })
  108. }).fail(error => {
  109. console.log(error)
  110. })
  111. } else {
  112. httpRequestApi.getOrderNum().success(res => {
  113. this.setData({
  114. peopleNumData: res.data.data.list
  115. })
  116. }).fail(error => {
  117. console.log(error)
  118. })
  119. }
  120. }
  121. })