index.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. var app = getApp();
  2. var Util = require('../../utils/util.js')
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. imgUrls: [],
  9. itemNew: [],
  10. activityList: [],
  11. menus: [],
  12. bastBanner: [],
  13. bastInfo: '',
  14. bastList: [],
  15. fastInfo: '',
  16. fastList: [],
  17. firstInfo: '',
  18. firstList: [],
  19. salesInfo: '',
  20. likeInfo: [],
  21. lovelyBanner: [],
  22. benefit: [],
  23. indicatorDots: false,
  24. circular: true,
  25. autoplay: true,
  26. interval: 3000,
  27. duration: 500,
  28. parameter: {
  29. 'navbar': '0',
  30. 'return': '0'
  31. },
  32. window: false,
  33. },
  34. /**
  35. * 生命周期函数--监听页面加载
  36. */
  37. onLoad: function (options) {
  38. if (options.spid) app.globalData.spid = options.spid;
  39. if (options.scene) app.globalData.code = decodeURIComponent(options.scene);
  40. },
  41. catchTouchMove: function (res) {
  42. return false
  43. },
  44. onColse: function () {
  45. this.setData({ window: false });
  46. },
  47. /**
  48. * 生命周期函数--监听页面初次渲染完成
  49. */
  50. onReady: function () {
  51. },
  52. /**
  53. * 生命周期函数--监听页面显示
  54. */
  55. onShow: function () {
  56. this.getIndexConfig();
  57. if (app.globalData.isLog && app.globalData.token) this.get_issue_coupon_list();
  58. },
  59. get_issue_coupon_list: function () {
  60. var that = this;
  61. app.baseGet(app.U({ c: 'coupons_api', a: 'get_issue_coupon_list', q: { limit: 3 } }), function (res) {
  62. that.setData({ couponList: res.data });
  63. if (!res.data.length) that.setData({ window: false });
  64. });
  65. },
  66. getIndexConfig: function () {
  67. var that = this;
  68. var url = app.U({ c: 'public_api', a: 'index' }, app.globalData.url);
  69. app.baseGet(url, function (res) {
  70. that.setData({
  71. imgUrls: res.data.banner,
  72. menus: res.data.menus,
  73. itemNew: res.data.roll,
  74. activityList: res.data.activity,
  75. bastBanner: res.data.info.bastBanner,
  76. bastInfo: res.data.info.bastInfo,
  77. bastList: res.data.info.bastList,
  78. fastInfo: res.data.info.fastInfo,
  79. fastList: res.data.info.fastList,
  80. firstInfo: res.data.info.firstInfo,
  81. firstList: res.data.info.firstList,
  82. salesInfo: res.data.info.salesInfo,
  83. likeInfo: res.data.likeInfo,
  84. lovelyBanner: res.data.info,
  85. benefit: res.data.benefit,
  86. logoUrl: res.data.logoUrl,
  87. couponList: res.data.couponList,
  88. });
  89. wx.getSetting({
  90. success(res) {
  91. if (!res.authSetting['scope.userInfo']) {
  92. that.setData({ window: that.data.couponList.length ? true : false });
  93. } else {
  94. that.setData({ window: false });
  95. }
  96. }
  97. });
  98. });
  99. },
  100. /**
  101. * 生命周期函数--监听页面隐藏
  102. */
  103. onHide: function () {
  104. this.setData({ window: false });
  105. },
  106. /**
  107. * 生命周期函数--监听页面卸载
  108. */
  109. onUnload: function () {
  110. },
  111. /**
  112. * 页面相关事件处理函数--监听用户下拉动作
  113. */
  114. onPullDownRefresh: function () {
  115. this.getIndexConfig();
  116. if (app.globalData.isLog && app.globalData.token) this.get_issue_coupon_list();
  117. wx.stopPullDownRefresh();
  118. },
  119. /**
  120. * 页面上拉触底事件的处理函数
  121. */
  122. onReachBottom: function () {
  123. },
  124. /**
  125. * 用户点击右上角分享
  126. */
  127. onShareAppMessage: function () {
  128. }
  129. })