You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

117 lines
2.5 KiB

import productApi from "../../utils/https/product.js"
const app = getApp()
Component({
options: {
styleIsolation: 'apply-shared',
addGlobalClass: true
},
/**
* 组件的属性列表
*/
properties: {
isIndex:{
type:String,
value:"0"
},
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:""
}
},
/**
* 组件的初始数据
*/
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: {
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;
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(this.properties.isIndex==1){
// 首页只需要隐藏 不需要返回
this.triggerEvent("indexback")
}
else if (pages.length<=1){
wx.switchTab({
url: app.globalData.menuRoute
})
}
else {
wx.navigateBack({
delta: 1
})
}
}
}
})