index.js
3.39 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
import { env } from '~/api/env/index'
import {
classifyTitleList,
classifyGoodsList1,
classifyGoodsList2,
classifyGoodsList3,
} from "../constant/lifeConstant";
Page({
/**
* 页面的初始数据
*/
data: {
recreationMenu: [],
foodMenu: [],
strategyList: [],
classifyTitleList,
titleActive: 0,
goodsList: [],
classifyGoodsList1,
classifyGoodsList2,
classifyGoodsList3,
},
/**
* 生命周期函数--监听页面加载
*/
onLoad() {
this.getStrategyList();
this.getAllMerchantList()
},
// 获取省钱攻略
getStrategyList() {
wx.p.api.strategyApi
.getStrategyList({
pageNum: 1,
pageSize: 100,
})
.then((res) => {
this.setData({
strategyList: res.list,
});
});
},
switchTitle(e) {
const { index } = e.currentTarget.dataset;
const _list = ['classifyGoodsList1', 'classifyGoodsList2', 'classifyGoodsList3']
this.setData({
titleActive: index,
goodsList: this.data[_list[index]]
});
},
selectStrategy(e) {
const { id } = e.detail;
wx.p.router.go("/packageStrategy/pages/strategyDetail/index", {
id,
notIntercept: true
});
},
getAllMerchantList() {
const {
merchantId
} = wx.p.storage.get('merchant_info')
let para = {
merchantId
}
wx.p.api.equityApi.getAllEquity(para).then(res => {
const carList = res.carServiceList
const equityList = res.goodsServiceList
let foodMenu = [], recreationMenu = []
const needShowEquity = ['星巴克', '瑞幸咖啡', '奈雪の茶', '麦当劳', '肯德基']
const needShowEquity2 = ['猫眼电影', '爱奇艺', '优酷', '网易云音乐', '喜马拉雅']
if (env == 'production') {
let all = []
equityList.forEach(el => {
if (el.equityGoodsGroupDescDtos) {
el.equityGoodsGroupDescDtos.forEach(item => {
all.push(item)
})
}
})
all.forEach(item => {
if (needShowEquity.includes(item.equityName)) {
if (item.equityName == '瑞幸咖啡') {
item.sign = '9.9元起'
} else if (item.equityName == '麦当劳') {
item.sign = '新品'
}
foodMenu.push({
name: item.equityName,
icon: item.equityIcon,
...item
})
}
if (needShowEquity2.includes(item.equityName)) {
if (item.equityName == '猫眼电影') {
item.sign = '19元起'
}
recreationMenu.push({
name: item.equityName,
icon: item.equityIcon,
...item
})
}
})
} else if (env == 'test' || env == 'beta') {
let all = []
equityList.forEach(el => {
if (el.equityGoodsGroupDescDtos) {
el.equityGoodsGroupDescDtos.forEach(item => {
all.push(item)
})
}
})
all.forEach(item => {
foodMenu.push({
name: item.equityName,
icon: item.equityIcon,
...item
})
recreationMenu.push({
name: item.equityName,
icon: item.equityIcon,
...item
})
})
}
this.setData({
foodMenu,
recreationMenu
})
})
},
});