index.js
3.48 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
import { imgUrlMixin } from '~/mixins/index'
const navStyle = 'background-color: transparent;'
import ActivityApi from '~/api/activityApi/index'
Component({
behaviors: [imgUrlMixin],
properties: {},
data: {
loading: true,
navStyle,
tab: [],
roadTodayNum: 0,
roadCountNum: 0,
tabIndex: 0,
to: '',
showMenu: false,
totals_zc: 0,
ids: [],
currentServiceType: 0,
usedCarFlag: 0,
},
methods: {
// 获取众筹总数
getTotal(e) {
const { type, total } = e.detail
if (e && e.detail && type == 0) {
this.setData({
totals_zc: total
})
}
},
hideEmpSelect() {
wx.$eventbus.emit("hideEmpSelect")
},
// 点击菜单按钮切换到对应的tab
getCurrentMenu(e) {
let { tab } = this.data
const index = tab.findIndex(item => item.serviceType == e.detail)
this.setData({
tabIndex: index,
to: `to-${index}`,
currentServiceType: e.detail || 0,
})
},
// 展示菜单列表
showMenuList() {
this.setData({
showMenu: true
})
},
navbarReady(e) {
let { height } = e.detail
this.setData({
navHeight: height
})
},
// 切换tab
async click(e) {
let { index } = e.currentTarget.dataset
let { tab } = this.data
const TEMP = tab[index]
this.setData({
tabIndex: index,
to: `to-${index}`,
currentServiceType: TEMP.serviceType || 0,
})
},
onLoad(options) {
const { merchantId, merchantName, usedCarFlag } = options;
this.setData({ merchantId, merchantName, usedCarFlag })
this.getSubscribeConfig(options)
this.addEvent()
},
// 获取活动订阅配置
getSubscribeConfig(obj) {
let tab = [
{ serviceTypeName: '精品升级', serviceType: 1 },
{ serviceTypeName: '售后众筹', serviceType: 0 },
{ serviceTypeName: '会员权益/升级', serviceType: 2 },
{ serviceTypeName: '二手车', serviceType: 7 }]
const index = tab.findIndex(item => item.serviceType == obj.type) || 0
this.setData({
tab,
fresh: obj && obj.fresh,
currentServiceType: obj.type || 0,
tabIndex: index,
to: `to-${index}`,
})
console.log(Date.now())
setTimeout(() => {
this.configHttpCount = false
this.setData({
fresh: false,
})
}, 300)
},
// 添加evevtbus通知刷新订阅
addEvent() {
wx.$eventbus.on("RESFRESH_SUBCRIBE", (obj) => {
this.getSubscribeConfig(obj)
});
},
// 跳转发现页面
toDoscoverPage() {
wx.$router.getPageInstance().changeTabBar({
detail: 1,
myTabIdx: 1
})
},
// 检查是否开通福利官
checkOpenPrivate(e) {
this.setData({
openPravite: e.detail
})
}
}
})