// pages/component/TitleHeader.js var app = getApp() Component({ options: { styleIsolation: 'apply-shared', addGlobalClass: true }, /** * 组件的属性列表 */ properties: { title:{ type:String, value:"" }, transparent:{ type:String, value:"0" }, clickid:{ type:String, value:"" } }, /** * 组件的初始数据 */ data: { height: 90, padHeight:0, right:0 }, lifetimes:{ attached:function(){ let systemInfo = wx.getSystemInfoSync(),rect = wx.getMenuButtonBoundingClientRect(); let height = (rect.top - systemInfo.statusBarHeight) * 2 + rect.height; this.setData({ height:height, padHeight:systemInfo.statusBarHeight, right:(systemInfo.screenWidth - rect.right) + rect.width }) } }, /** * 组件的方法列表 */ methods: { back:function(){ // if(this.properties.clickid){ // wx.uma.trackEvent(this.properties.clickid) // } const pages = getCurrentPages(); if(pages[pages.length-1].route.indexOf('linkman/add')==-1){ app.globalData.index = app.globalData.index -1 console.log(app.globalData.index, 'appGlobalIndex') } if(pages[pages.length-1].route.indexOf('login')!=-1 || pages[pages.length-1].route.indexOf('bindTel')!=-1){ // 如果是登录页面的返回需要返回两层 if(pages.length>2){ wx.navigateBack({ delta: 2 }) } else { wx.switchTab({ url: "/pages/index/index" }) } } // else if (pages[pages.length-1].route.indexOf('cartlist') != -1){ // wx.switchTab({ // url: '/pages/user/user' // }) // } else if (pages[pages.length-1].route.indexOf('pages/order/pay/index') != -1){ wx.redirectTo({ url:'/pages/user/order/list' }) } else if (pages[pages.length-1].route.indexOf('pages/user/order/list') != -1){ wx.switchTab({ url: '/pages/user/user' }) } else if (pages[pages.length-1].route.indexOf('pages/user/cartlist/list') != -1){ wx.switchTab({ url: '/pages/user/user' }) } else if (pages[pages.length-1].route.indexOf('orderList') != -1){ // 清空购物车 try { console.log("清除购物车") app.globalData.list = null;app.globalData.createDate = null; app.globalData.index = 0;app.globalData.productPrice = 0;app.globalData.ticketPrice = 0; } catch(e) { console.log("清空购物车失败", e) } wx.navigateTo({ url: '/pages/user/cartlist/list' }) } // else if (pages[pages.length-1].route.indexOf('scene') != -1){ // console.log(22222); // wx.reLaunch({ // url: "/pages/user/cartlist/list" // }) // } else if (pages.length>1){ wx.navigateBack({ delta: 1 }) } else { wx.switchTab({ url: "/pages/index/index" }) } } } })