index.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. // pages/welfareMall/index/index.js
  2. import WelfareMall from '../../../api/welfareMall';
  3. const util = require('../../../utils/util.js');
  4. const app = getApp();
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. activityList:[],
  11. bannerList:[],
  12. navigationList:[],
  13. autoplay: true,
  14. interval: 2000,
  15. duration: 500,
  16. indicatorDots:true
  17. },
  18. /**
  19. * 生命周期函数--监听页面加载
  20. */
  21. onLoad: function (options) {
  22. this.getIndexList()
  23. },
  24. /**
  25. * 生命周期函数--监听页面初次渲染完成
  26. */
  27. onReady: function () {
  28. },
  29. /**
  30. * 生命周期函数--监听页面显示
  31. */
  32. onShow: function () {
  33. },
  34. /**
  35. * 生命周期函数--监听页面隐藏
  36. */
  37. onHide: function () {
  38. },
  39. /**
  40. * 生命周期函数--监听页面卸载
  41. */
  42. onUnload: function () {
  43. },
  44. /**
  45. * 页面相关事件处理函数--监听用户下拉动作
  46. */
  47. onPullDownRefresh: function () {
  48. },
  49. /**
  50. * 页面上拉触底事件的处理函数
  51. */
  52. onReachBottom: function () {
  53. },
  54. /**
  55. * 用户点击右上角分享
  56. */
  57. onShareAppMessage: function () {
  58. },
  59. //跳转超值券包
  60. goToCoupon:function(e){
  61. var appId = e.currentTarget.dataset.appId;
  62. var path = e.currentTarget.dataset.path;
  63. if(appId && path){
  64. wx.navigateToMiniProgram({
  65. appId: appId,
  66. path: path,
  67. success(res) {
  68. // 打开成功
  69. }
  70. })
  71. }
  72. if(!appId && path){
  73. wx.navigateTo({
  74. url: path,
  75. })
  76. }
  77. },
  78. goCouponDetail:function(e){
  79. let activityId = e.currentTarget.dataset.id
  80. wx.navigateTo({
  81. url: '/pages/welfareMall/activityInfo/activityInfo?activityId='+ activityId,
  82. })
  83. },
  84. async getIndexList(){
  85. let res = await WelfareMall.getIndexList();
  86. this.setData({
  87. activityList:res.data.activityList,
  88. bannerList:res.data.bannerList,
  89. navigationList:res.data.navigationList
  90. })
  91. },
  92. goToBanner(e){
  93. var appId = e.currentTarget.dataset.appid;
  94. var path = e.currentTarget.dataset.path;
  95. if(appId && path){
  96. wx.navigateToMiniProgram({
  97. appId: appId,
  98. path: path,
  99. success(res) {
  100. // 打开成功
  101. }
  102. })
  103. }
  104. if(!appId && path){
  105. wx.navigateTo({
  106. url: path,
  107. })
  108. }
  109. }
  110. })