import productApi from "../../utils/https/product.js" const app = getApp() Component({ options: { styleIsolation: 'apply-shared', addGlobalClass: true }, /** * 组件的属性列表 */ properties: { isIndex:{ type:String, value:"1" }, tab: { type: String, value: "0" }, transparent:{ type:String, value:"0" }, isScene:{ type:String, value:0 }, clickid:{ type:String, value:"" }, cityclickid:{ type:String, value:"" }, focusclickid:{ type:String, value:"" }, name:{ type:String, value:"" } }, /** * 组件的初始数据 */ data: { height: 90, keywords:'', 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 }) console.log(systemInfo,rect) } }, /** * 组件的方法列表 */ methods: { getVal(e) { console.log(e.detail.value); let keywords = e.detail.value == ''?'': e.detail.value this.triggerEvent("onload",{keywords:keywords}) }, inputFocus:function(){ // if(this.properties.focusclickid){ // wx.uma.trackEvent(this.properties.focusclickid); // } }, searchInput:function(e){ this.setData({ keywords:e.detail.value }) }, search:function(){ let keywords = this.data.keywords; console.log(keywords) this.triggerEvent("onload",{keywords:keywords}) // productApi._get("productfront/search", { pageNo: 1, pageNum: 10, keywords:keywords}).then(res=>{ // console.log(res) // }) // console.log(this.data.keywords) }, // 如果是首页的那么跳转搜索页 indexFocus:function(){ // if(this.properties.isIndex==1){ // wx.navigateTo({ // url: '/pages/search/index', // }) // } }, back: function () { if(this.properties.clickid){ wx.uma.trackEvent(this.properties.clickid); } const pages = getCurrentPages(); // wx.showTabBar({}) console.log(this.properties.isIndex) if (pages.length<=1){ wx.switchTab({ url: app.globalData.menuRoute }) } else { wx.navigateBack({ delta: 1 }) } } } })