index.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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. },
  17. /**
  18. * 生命周期函数--监听页面加载
  19. */
  20. onLoad: function (options) {
  21. this.getIndexList()
  22. },
  23. /**
  24. * 生命周期函数--监听页面初次渲染完成
  25. */
  26. onReady: function () {
  27. },
  28. /**
  29. * 生命周期函数--监听页面显示
  30. */
  31. onShow: function () {
  32. },
  33. /**
  34. * 生命周期函数--监听页面隐藏
  35. */
  36. onHide: function () {
  37. },
  38. /**
  39. * 生命周期函数--监听页面卸载
  40. */
  41. onUnload: function () {
  42. },
  43. /**
  44. * 页面相关事件处理函数--监听用户下拉动作
  45. */
  46. onPullDownRefresh: function () {
  47. },
  48. /**
  49. * 页面上拉触底事件的处理函数
  50. */
  51. onReachBottom: function () {
  52. },
  53. /**
  54. * 用户点击右上角分享
  55. */
  56. onShareAppMessage: function () {
  57. },
  58. //跳转超值券包
  59. goToCoupon:function(e){
  60. var appId = e.currentTarget.dataset.appId;
  61. var path = e.currentTarget.dataset.path;
  62. if(appId && path){
  63. wx.navigateToMiniProgram({
  64. appId: appId,
  65. path: path,
  66. success(res) {
  67. // 打开成功
  68. }
  69. })
  70. }
  71. if(!appId && path){
  72. wx.navigateTo({
  73. url: path,
  74. })
  75. }
  76. },
  77. goCouponDetail:function(e){
  78. let activityId = e.currentTarget.dataset.id
  79. wx.navigateTo({
  80. url: '/pages/welfareMall/activityInfo/activityInfo?activityId='+ activityId,
  81. })
  82. },
  83. async getIndexList(){
  84. let res = await WelfareMall.getIndexList();
  85. this.setData({
  86. activityList:res.data.activityList,
  87. bannerList:res.data.bannerList,
  88. navigationList:res.data.navigationList
  89. })
  90. },
  91. goToBanner(e){
  92. var appId = e.currentTarget.dataset.appid;
  93. var path = e.currentTarget.dataset.path;
  94. console.log(appId);
  95. console.log(path);
  96. if(appId && path){
  97. wx.navigateToMiniProgram({
  98. appId: 'wxd92a2d29f8022f40',
  99. path: 'pages/index/index',
  100. extraData: {
  101. foo: 'bar'
  102. },
  103. envVersion: 'develop',
  104. success(res) {
  105. // 打开成功
  106. }
  107. })
  108. }
  109. if(!appId && path){
  110. wx.navigateTo({
  111. url: path,
  112. })
  113. }
  114. }
  115. })