allEquity.js
2.81 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
Page({
/**
* 页面的初始数据
*/
data: {
cHeight: 600,
curIndex: 0,
equityList: [],
to: 'to-0'
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
let system = wx.getSystemInfoSync()
this.getAllMerchantList()
this.setData({
cHeight: system.windowHeight
})
if (options.showToast) {
setTimeout(()=>{
wx.p.wxApi.showToast('原商品及品牌均已下架,您可查看其他权益商品')
},500)
}
},
computerHeight() {
let query = wx.createSelectorQuery().in(this)
let heightArr = []
let s = 0
query
.selectAll('.scroll_item_wrap')
.boundingClientRect(react => {
react.forEach(item => {
s += item.height
heightArr.push(s)
})
this.data.heightArr = heightArr
})
.exec()
query
.select('.right_wrap')
.boundingClientRect(res => {
this.data.rightHeight = res.height
})
.exec()
},
scrollViewFn(e) {
let scrollTop = e.detail.scrollTop
let scrollArr = this.data.heightArr
if (this.data.isClickLeft) {
this.data.isClickLeft = false
return
}
if (scrollTop >= scrollArr[scrollArr.length - 1] - this.data.rightHeight) {
return
} else {
for (let i = 0; i < scrollArr.length; i++) {
if (scrollTop >= 0 && scrollTop < scrollArr[0]) {
this.setData({
curIndex: 0
})
} else if (scrollTop >= scrollArr[i - 1] - 110 && scrollTop < scrollArr[i] - 110) {
this.setData({
curIndex: i
})
}
}
}
},
slectLeftItem(e) {
const { index } = e.currentTarget.dataset
this.setData({
curIndex: index,
to: `to-${index}`,
isClickLeft: true
})
},
getAllMerchantList() {
let {merchantId} = wx.p.storage.get('merchant_info')
let para = {
merchantId
}
wx.p.api.equityApi.getAllEquity(para).then(res => {
let tempArr = res.goodsServiceList
this.setData(
{
equityList: tempArr
},
() => {
this.computerHeight()
}
)
})
},
toNewPage(e) {
const { item } = e.currentTarget.dataset
let url = ''
if (item.appearance == 1) {
let param = {
supplier: item.supplier,
brandName: item.brandName,
location: true
}
wx.p.router.go('/packageEquity/pages/commodity/detail/detail',{
param,
notIntercept: true
})
} else if (item.appearance == 2) {
let param = {
supplier: item.supplier,
brandName: item.brandName,
icon: item.equityIcon
}
wx.p.router.go('/packageEquity/pages/commodity/chargeDetail/chargeDetail',{
param,
notIntercept: true
})
}
}
})