event.js 666 B

123456789101112131415161718192021222324
  1. const app = getApp()
  2. import {
  3. userEvent
  4. } from '~/api/global'
  5. module.exports = Behavior({
  6. data: {
  7. isIos: app.globalData.isIOS,
  8. },
  9. pageLifetimes: {
  10. show() {
  11. // 页面被展示
  12. console.log('页面被展示', this.data.isIos);
  13. /*获取当前页url*/
  14. var pages = getCurrentPages() //获取加载的页面
  15. var currentPage = pages[pages.length - 1] //获取当前页面的对象
  16. var url = currentPage.route
  17. userEvent({
  18. action: this.data.isIos ? 'PV_IOS' : 'PV_ANDROID',
  19. targetContent: url
  20. })
  21. },
  22. }
  23. })