charge.js
3.66 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
Page({
data: {
loadOver: false,
commodityList: [],
loadingMore: false,
pageParam: {
appearance: 2,
pageSize: 0,
pageCount: 10
}
},
onLoad: function (options) {
this.toGetCommodity()
},
// 获取直充数据
toGetCommodity() {
let { pageParam, loadingMore, commodityList, loadOver } = this.data
if (loadOver) {
return
}
wx.p.wxApi.showLoading()
wx.p.api.equityApi.lasteCommodity(pageParam).then(res => {
if (!res) {
this.setData({
loadOver: true
})
wx.hideLoading()
return
}
let tempArr = []
res.map(item => {
let newArr = []
if (item && item.chargeGoddsList) {
item.chargeGoddsList.forEach(ele => {
ele.denominationList.forEach(info => {
let tempObj = {
productName: ele.productName,
...info
}
newArr.push(tempObj)
})
})
}
item.couponsGoodsList = newArr
item.bgurl = this.matchImage(item.brandName)
if (item.couponsGoodsList) {
tempArr.push(item)
}
return item
})
if (loadingMore) {
commodityList = commodityList.concat(tempArr)
}
this.setData({
commodityList: loadingMore ? commodityList : tempArr,
loadingMore: false,
loadOver: false
})
wx.hideLoading()
})
},
onReachBottom: function () {
if (this.data.unauthorized) {
return
}
let { pageParam } = this.data
pageParam.pageSize++
this.setData(
{
pageParam,
loadingMore: true
},
() => {
this.toGetCommodity()
}
)
},
// 直充品牌对应的图标
matchImage(brandName){
const commonBaseURL = 'https://img02.glsx.com.cn/weapp/resource/miniprogram/hmd/'
const ImageConfig = [{
name: `qq音乐`,
url: `${commonBaseURL}equity/QQ_music.png`
}, {
name: `WPS`,
url: `${commonBaseURL}equity/WPS.png`
}, {
name: `qq阅读`,
url: `${commonBaseURL}equity/QQ_read.png`
}, {
name: `爱奇艺`,
url: `${commonBaseURL}equity/aiqiyi.png`
}, {
name: `百度网盘`,
url: `${commonBaseURL}equity/baiduwp.png`
}, {
name: `哔哩哔哩`,
url: `${commonBaseURL}equity/bili.png`
}, {
name: `凯叔讲故事`,
url: `${commonBaseURL}equity/kaishu.png`
}, {
name: `酷狗音乐`,
url: `${commonBaseURL}equity/kugou.png`
}, {
name: `芒果TV`,
url: `${commonBaseURL}equity/mgTv.png`
}, {
name: `美团`,
url: `${commonBaseURL}equity/mtdc.png`
}, {
name: `奈雪`,
url: `${commonBaseURL}equity/naixue.png`
}, {
name: `瑞幸`,
url: `${commonBaseURL}equity/ruixin.png`
}, {
name: `腾讯视频`,
url: `${commonBaseURL}equity/tenxun.png`
}, {
name: `网易云`,
url: `${commonBaseURL}equity/wangyiyun.png`
}, {
name: `优酷`,
url: `${commonBaseURL}equity/youku.png`
}, {
name: `知乎`,
url: `${commonBaseURL}equity/zhihu.png`
}, {
name: `作业帮`,
url: `${commonBaseURL}equity/workjob.png`
}, {
name: `喜马拉雅`,
url: `${commonBaseURL}equity/ximalaya.png`
}, {
name: `e袋洗`,
url: `${commonBaseURL}equity/edaixi.png`
}]
brandName = brandName.toLowerCase()
let url = 'https://img01.glsx.com.cn/weapp/resource/equity-h5-new/aiqiyi.png'
ImageConfig.forEach(item => {
if (brandName.indexOf(item.name.toLowerCase()) != -1) {
url = item.url
}
})
return url
},
})