quickNavigation.js
5.21 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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
// components/Dialog/dialog.js
import {
logEvent,
YB_TO_OPEN_APP_C,
YB_OPEN_APP_RESULT_L
} from '../../libs/analytics.js'
import { API_HOST, SERVICE_HOST } from '../../libs/config';
import { GET, POST } from '../../libs/request';
import { postFormId } from '../../libs/formIdCollectRequest';
let app = getApp();
Component({
options: {
multipleSlots: true // 在组件定义时的选项中启用多slot支持
},
/**
* 组件的属性列表
* 用于组件自定义设置
*/
properties: {
isShowIndicator: { //是否展示返回顶部按钮
type: Boolean,
value: false,
observer: "_indicatorChange"
},
isShowShopCart: { //是否展示购物车
type: Boolean,
value: true
},
marginBottom: { //底部边距
type: Number,
value: 100
},
isShowMenu: {
type: Boolean,
value: true
},
isShare: { // 是否显示分享
type: Boolean,
value: false
},
isGuangShare: {
type: Boolean,
value: false
},
isUnionShare: {// 是否显示创建联盟分享按钮
type: Boolean,
value: false
},
isGoApp: { // 是否显示取app按钮
type: Boolean,
value: false
},
appParameter: {
type: String,
value: ''
},
isHome: {
type: Boolean,
value: false
}
},
attached: function () {
app.showYOHOIconCount ++ ;
if (app.showYOHOIconCount == 1 && (app.globalData.currentScene == 1007 || app.globalData.currentScene == 1012) && !this.properties.isHome){
this.showYOHOIcon();
}
},
/**
* 私有数据,组件的初始数据
* 可用于模版渲染
*/
data: {
// 弹窗显示控制
isShow: true,
isExpand: false,
needYOHOIcon: false,
menuOpacity: 0,
funcItemAnimation: {},
indicatorAnimation: {},
isAnimation: false,
},
/**
* 组件的方法列表
* 更新属性和数据的方法与更新页面数据的方法类似
*/
methods: {
//上报formid
formSubmit: function (e) {
// console.log('####formID:', e.detail.formId)
let formId = e.detail.formId;
postFormId(formId)
},
/*
* 公有方法
*/
//隐藏
hide() {
this.setData({
isShow: !this.data.isShow
})
},
//展示
show() {
this.setData({
isShow: !this.data.isShow
})
},
switchMenu() {
if(this.data.isAnimation){
return;
}
var time = 150;
if(this.data.isExpand){
this.takeback(time);
}else {
this.popout(time);
}
this.setData({
isAnimation: true
});
var delayTime = time;
setTimeout(function () {
this.setData({
isAnimation: false
})
}.bind(this), delayTime);
this.setData({
isExpand: !this.data.isExpand,
})
},
_indicatorChange: function(newVal, oldVal) {
var animtionIndicator = wx.createAnimation({
duration: 300,
timingFunction: 'linear',
});
if(newVal){
animtionIndicator.opacity(1).height(44).width(44).step();
}else {
animtionIndicator.opacity(0).height(0).width(0).step();
}
this.setData({
indicatorAnimation: animtionIndicator.export(),
})
},
// 动画
popout(time) {
var funcItemAnimation = wx.createAnimation({
duration: time,
timingFunction: 'ease-in-out'
});
funcItemAnimation.opacity(1).width(44).height(44).step({ duration: time });
this.setData({
funcItemAnimation: funcItemAnimation.export(),
});
},
takeback(time) {
var funcItemAnimation = wx.createAnimation({
duration: time,
timingFunction: 'ease-in-out'
});
funcItemAnimation.opacity(0).width(0).height(0).step({ duration: time });
this.setData({
funcItemAnimation: funcItemAnimation.export(),
});
},
showYOHOIcon() {
this.setData({
needYOHOIcon: 1,
});
},
//事件
jumpToHome() {
wx.switchTab({
url: '/pages/index/index',
})
},
jumpToSearch() {
wx.navigateTo({
url: '/pages/search/search',
})
},
jumpToShopCart() {
wx.switchTab({
url: '/pages/shopCart/shopCart',
})
},
backToTop() {
this.triggerEvent("backToTop");
},
unionShare() {
this.triggerEvent("unionShare");
},
share: function(event){
this.triggerEvent("share");
},
goApp: function (e) {
var pages = getCurrentPages()
var currentPage = pages[pages.length - 1]
var url = currentPage.route
// let params = {
// PAGE_PATH: url,
// };
// logEvent(YB_TO_OPEN_APP_C, params);
},
launchAppError: function (e) {
var pages = getCurrentPages()
var currentPage = pages[pages.length - 1]
var url = currentPage.route
// let params = {
// PAGE_PATH: url,
// OPEN_RESULT: 2
// };
// logEvent(YB_OPEN_APP_RESULT_L, params);
wx.showToast({
title: '打开失败!您可能未安装Yoho!Buy官方APP,请下载后再尝试。',
icon: 'none',
duration: 3000
})
}
}
})