index.js
4.51 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
import {
kfMixin,
} from '~/mixins/index'
Page({
behaviors: [kfMixin],
/**
* 页面的初始数据
*/
data: {
pageNum: 1,
goodsIndex: 0,
customerlist: [],
navStyle : "background-color: transparent;",
animationData: {},
specialSaleArr: [{
id: 1,
url: 'https://img02.glsx.com.cn/weapp/resource/miniprogram/points-mall/index/index-bg.png',
saleName: '九阳专场'
}, {
id: 2,
url: 'https://img02.glsx.com.cn/weapp/resource/miniprogram/points-mall/login/login-bg.png',
saleName: '维达专场'
}],
tab: [{
id: '1',
label: '我能兑换'
}, {
id: '',
label: '全部'
}, {
id: '2',
label: '100积分以下'
}, {
id: '3',
label: '100-200积分'
}, {
id: '4',
label: '200-300积分'
}],
subTab: [{
id: '',
label: '全部品类'
}, {
id: '1',
label: '汽车保养'
}, {
id: '2',
label: '车载设备'
}, {
id: '3',
label: '个护清洁'
}, {
id: '4',
label: '休闲零食'
}],
goodsList: [{
goodsId: '1',
goodsUrl: 'https://img02.glsx.com.cn/weapp/resource/miniprogram/points-mall/login/login-img.png',
goodsName: 'Tempo得宝手帕纸',
salePoints: '10',
marketPrice: '15.9'
}, {
goodsId: '2',
goodsUrl: 'https://img02.glsx.com.cn/weapp/resource/miniprogram/points-mall/login/login-img.png',
goodsName: '维达抽纸超韧整箱M码家用实惠装面巾纸',
salePoints: '69.9',
marketPrice: '79.9'
}, {
goodsId: '3',
goodsUrl: 'https://img02.glsx.com.cn/weapp/resource/miniprogram/points-mall/index/index-bg.png',
goodsName: '5100西藏冰川矿泉水整箱',
salePoints: '10',
marketPrice: '15.9'
}, {
goodsId: '4',
goodsUrl: 'https://img02.glsx.com.cn/weapp/resource/miniprogram/points-mall/login/login-img.png',
goodsName: '洁柔Face纸巾抽纸3层',
salePoints: '10',
marketPrice: '15.9'
}]
},
onReady() {
this.startAnimation();
},
// 顶部公告动画
startAnimation: function() {
const query = wx.createSelectorQuery()
query.select('.text-container').boundingClientRect()
query.select('.text').boundingClientRect()
query.exec((res) => {
const containerWidth = res[0]?.width
const textWidth = res[1]?.width
// 只有文字宽度超过容器宽度时才滚动
if (textWidth > containerWidth) {
const animation = wx.createAnimation({
duration: (textWidth / 30) * 1000, // 根据文字长度调整滚动时间
timingFunction: 'linear',
delay: 0
})
animation.translateX(-textWidth).step()
this.setData({
animationData: animation.export()
})
// 设置循环
setTimeout(() => {
this.resetAnimation();
}, (textWidth / 30) * 1000)
}
})
},
resetAnimation: function() {
const animation = wx.createAnimation({
duration: 0,
timingFunction: 'linear',
delay: 0
})
animation.translateX(0).step()
this.setData({
animationData: animation.export()
})
setTimeout(() => {
this.startAnimation()
}, 50)
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
// 跳转积分中心
handleToPointCenter() {
wx.p.router.go('/packageIndex/pages/integral/index/index')
},
// 查看公告政策详情
policyDetail() {
wx.p.router.jumpH5(`https://fgk.chinatax.gov.cn/zcfgk/c100012/c5241472/content.html`)
},
// 跳转专场
handleSpecialSale(e) {
console.log(e, 2222)
let { target } = e.currentTarget.dataset
wx.p.router.go('/packageIndex/pages/SpecialSale/SpecialSale', target)
},
changeTab(e) {
this.setData({
goodsIndex: e.detail
})
},
toIntegral(){
wx.p.router.go('/packageIndex/pages/integral/index/index')
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onReachBottom() {
let {
pageNum,
total
} = this.data
wx.p.util.onReachBottom({
pageNum,
total,
}, () => {
this.getActivityList()
})
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {}
})