activity.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. // components/activity/activity.js
  2. const {
  3. urlParse
  4. } = require('../../utils/util.js');
  5. const app = getApp();
  6. Component({
  7. /**
  8. * 组件的属性列表
  9. */
  10. properties: {
  11. className: String,
  12. adList: Array
  13. },
  14. /**
  15. * 组件的初始数据
  16. */
  17. data: {
  18. _adList: null,
  19. autoplay: true,
  20. interval: 5000,
  21. selectIndex: 0
  22. },
  23. lifetimes: {
  24. attached: function () {
  25. this.setData({
  26. _adList: this.properties.adList.map(item => {
  27. const {
  28. query,
  29. url
  30. } = urlParse(item.appUrl || item.url)
  31. item.url = url || ''
  32. item.query = query || {}
  33. return item
  34. })
  35. })
  36. }
  37. },
  38. methods: {
  39. onSlideChangeEnd: function (e) {
  40. if (this.properties.adList.length > 1) {
  41. this.setData({
  42. selectIndex: e.detail.current
  43. })
  44. } else {
  45. return false
  46. }
  47. },
  48. handleTapAction:function(e) {
  49. const {item} = e.currentTarget.dataset;
  50. const userInfo = wx.getStorageSync("userInfo");
  51. if (userInfo && userInfo.token) {
  52. wx.navigateTo({
  53. url: "/pages/login/login"
  54. });
  55. } else {
  56. const {model,miniId,path,data,url} = item.query
  57. if (parseInt(model) == 30) {
  58. wx.navigateToMiniProgram({
  59. appId: miniId || '',
  60. path: path || '',
  61. extraData:data || {}
  62. });
  63. } else {
  64. wx.navigateTo({
  65. url: url
  66. });
  67. }
  68. }
  69. }
  70. }
  71. })