proDetail.js
4.05 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
// packagesList/pages/productDetail/components/proDetail/proDetail.js
import { senceData, productData1 } from '~/pages/tab/index/constant/senceData'
const norTabList = ['项目亮点', '合作案例', '合作方式', '适配产品']
import { componentsMixin } from "../../mixins/index";
Component({
externalClasses: ['custom-class'],
behaviors: [componentsMixin],
/**
* 组件的属性列表
*/
properties: {
// 场景值下标
actNum: {
type: Number,
value: -1,
observer(n) {
this.getInfo()
this.getImgHeight()
}
},
// 选中的产品
activeNavIdx: {
type: Number,
value: 0
},
cardInfo: {
type: Object,
value: {}
},
// 配置url
activeUrl: {
type: String,
value: ''
},
detailType: {
type: String,
value: 'pro'
}
},
/**
* 组件的初始数据
*/
data: {
IMG_URL: 'https://img02.glsx.com.cn/weapp/resource/saas/business-assistant/',
productData: productData1,
proInfo: {},
prodItemVideo: '', //选中的场景下的video的第一个
tabAct: 0,
scrollTop: 0,
showCard: false,
tabList: []
},
/**
* 组件的方法列表
*/
methods: {
getInfo() {
let { activeNavIdx, actNum } = this.data
const spcList = [99, 4] // 订阅模块需要特殊处理
const senceList = productData1[actNum].filter(item => item.name != '全部')
for (let i = 0; i < senceList.length; i++) {
let item = senceList[i]
let proIdList = item?.productList.map(k => k.id)
if (proIdList.includes(activeNavIdx)) {
let proInfo = item.productList.find(k => k.id == activeNavIdx)
this.setData({
proInfo,
productImgs: spcList.includes(actNum) ? proInfo.sceneImgs : item.productImgs,
tabList: spcList.includes(actNum) ? proInfo.tabList : norTabList,
prodItemVideo: item.videoList.length ? spcList.includes(actNum) ?item.videoList[proInfo.currentIndex] : item.videoList[activeNavIdx] : item.noVideoPicture[0]
})
break
}
}
},
getImgHeight() {
let query = wx.createSelectorQuery().in(this)
let heightArr = []
let imgTopArr = []
let s = 0
let top
let { scrollTop } = this.data
let _this = this
query
.selectAll('.img-item')
.boundingClientRect(react => {
react.forEach((item, index) => {
s = item.top - 44 + scrollTop
imgTopArr.push(s)
})
_this.setData({
imgTopArr
})
})
.exec()
},
// 1.3查看活动详情按钮
checkActive() {
let { activeUrl } = this.data
wx.$router.jumpH5(activeUrl);
},
onClickTab(event) {
let { index } = event.detail
this.setData({
tabAct: index
})
let { imgTopArr } = this.data
wx.pageScrollTo({
scrollTop: imgTopArr[index] + 5
})
},
pageSroll(e) {
let { imgTopArr } = this.data
wx.nextTick(() => {
let idx
if (imgTopArr[0] > e.scrollTop) {
idx = 0
} else if (imgTopArr[imgTopArr.length - 1] > e.scrollTop && imgTopArr[0] < e.scrollTop) {
idx = imgTopArr.findIndex(item => item > e.scrollTop) - 1
} else {
idx = imgTopArr.length - 1
}
this.setData({
tabAct: idx,
scrollTop: e.scrollTop
})
})
},
selectCard() {
this.setData({
showCard: !this.data.showCard
})
},
// 长按图片
handleLongPress(e) {
let { actnum, index } = e.target.dataset
// 膨胀金活动,合作方式
if (actnum == 4 && index == 4) {
wx.downloadFile({
url: 'https://scrm.glsx.com.cn/frontpdf/expand_agreement.pdf',
success: function (res) {
const filePath = res.tempFilePath
wx.openDocument({
filePath: filePath,
success: function (res) {
}
})
}
})
}
}
}
})