index.js 3.1 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. var that=this;
  41. wx.getSetting({
  42. success(res) {
  43. if (!res.authSetting['scope.userInfo']) {
  44. that.setData({ window: true });
  45. }
  46. }
  47. });
  48. },
  49. catchTouchMove: function (res) {
  50. return false
  51. },
  52. onColse:function(){
  53. this.setData({ window: false});
  54. },
  55. /**
  56. * 生命周期函数--监听页面初次渲染完成
  57. */
  58. onReady: function () {
  59. },
  60. /**
  61. * 生命周期函数--监听页面显示
  62. */
  63. onShow: function () {
  64. this.getIndexConfig();
  65. if(app.globalData.isLog && app.globalData.token) this.get_issue_coupon_list();
  66. },
  67. get_issue_coupon_list:function(){
  68. var that = this;
  69. app.baseGet(app.U({ c: 'coupons_api', a:'get_issue_coupon_list',q:{limit:3}}),function(res){
  70. that.setData({couponList:res.data});
  71. if (!res.data.length) that.setData({ window: false });
  72. });
  73. },
  74. getIndexConfig:function(){
  75. var that = this;
  76. var url = app.U({ c: 'public_api', a: 'index' }, app.globalData.url);
  77. app.baseGet(url,function(res){
  78. that.setData({
  79. imgUrls: res.data.banner,
  80. menus: res.data.menus,
  81. itemNew: res.data.roll,
  82. activityList: res.data.activity,
  83. bastBanner: res.data.info.bastBanner,
  84. bastInfo: res.data.info.bastInfo,
  85. bastList: res.data.info.bastList,
  86. fastInfo: res.data.info.fastInfo,
  87. fastList: res.data.info.fastList,
  88. firstInfo: res.data.info.firstInfo,
  89. firstList: res.data.info.firstList,
  90. salesInfo: res.data.info.salesInfo,
  91. likeInfo: res.data.likeInfo,
  92. lovelyBanner:res.data.info,
  93. benefit: res.data.benefit,
  94. logoUrl: res.data.logoUrl,
  95. couponList: res.data.couponList,
  96. });
  97. });
  98. },
  99. /**
  100. * 生命周期函数--监听页面隐藏
  101. */
  102. onHide: function () {
  103. this.setData({ window:false});
  104. },
  105. /**
  106. * 生命周期函数--监听页面卸载
  107. */
  108. onUnload: function () {
  109. },
  110. /**
  111. * 页面相关事件处理函数--监听用户下拉动作
  112. */
  113. onPullDownRefresh: function () {
  114. this.getIndexConfig();
  115. if (app.globalData.isLog && app.globalData.token) this.get_issue_coupon_list();
  116. wx.stopPullDownRefresh();
  117. },
  118. /**
  119. * 页面上拉触底事件的处理函数
  120. */
  121. onReachBottom: function () {
  122. },
  123. /**
  124. * 用户点击右上角分享
  125. */
  126. onShareAppMessage: function () {
  127. }
  128. })