diy_top_nav.js
3.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
// components/diy_top_nav/diy_top_nav.js
const app = getApp();
var os = app.globalData.setting;
Component({
/**
* 组件的属性列表
*/
properties: {
nav_type:{
type:Number,
value:0,
},
istop:{
type:Number,
value:0,
},
nav_title:{
type:String,
value:'首页',
},
nav_frontColor:{
type:String,
value:'#000',
},
nav_backgroundColor:{
type:String,
value:'#ffffff',
},
is_share:{
type:Boolean,
value:true
}
},
/**
* 组件的初始数据
*/
data: {
imghots: os.imghost,
nav_h:0, //导航胶囊上面状态栏的高度
mentButt_h:0,//导航胶囊高度
navleft_pb:0, //导航左边的自定义内容的左右内边距
nav_left_w:281, // 导航左边自定义的内容宽度
navleft_w:0, //左边胶囊宽度
nav_pb:0, // 导航的下内边距
show_menu:false,//详情页导航下拉菜单显示
men_list:[
{
name:'首页',
img:'miniapp/js_img/goods_info/home.png?v=3',
url:'/pages/index/index/index'
},
{
name:'我的订单',
img:'miniapp/js_img/goods_info/order.png?v=3',
url:'/pages/user/order_list/order_list'
},
{
name:'我的收藏',
img:'miniapp/js_img/goods_info/collect.png?v=3',
url:'/packageB/pages/user/collect_list/collect_list'
},
// {
// name:'浏览足迹',
// img:'',
// url:''
// },
],
is_pc:0
},
lifetimes:{
attached:function(){
var is_pc=getApp().globalData.is_pc;
if(!is_pc) {
//满屏顶部导航参数获取-----------
try {
let systemInfo = wx.getSystemInfoSync()
let mentButt = wx.getMenuButtonBoundingClientRect()
let nav_pb = mentButt.top - systemInfo.statusBarHeight
let navleft_pb = systemInfo.windowWidth - mentButt.right
let user_no = '';
if (getApp().globalData.userInfo) {
user_no = getApp().globalData.userInfo.erpvipno
}
this.setData({
nav_h: mentButt.top,
mentButt_h: mentButt.height,
nav_left_w: mentButt.left,
navleft_pb,
nav_pb,
navleft_w: mentButt.width * 0.9,
user_no
})
} catch (e) {
console.error(e);
wx.showToast({
title: '系统参数获取失败',
icon: 'none',
duration: 2000
})
// this.setData({
// is_full_screen_navigation:false
// })
// Do something when catch error
}
}else{
this.setData({is_pc:1});
}
}
},
/**
* 组件的方法列表
*/
methods: {
nav_menu(e){
let url=e.currentTarget.dataset.url
getApp().goto(url)
},
show_menu_fn(){
this.setData({
show_menu:!this.data.show_menu
})
},
hide_menu_fn(){
this.setData({
show_menu:false
})
},
//分享
fenx_fn(){
this.triggerEvent('clickShare')
},
call_back(){
wx.navigateBack({
delta:1,
fail:()=>{
wx.reLaunch({
url: '/pages/index/index/index',
})
}
})
},
nav_search(){
getApp().goto('/packageG/pages/goods/search/search')
}
}
})