materials.js
3.95 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
const IMG_URL = 'https://img02.glsx.com.cn/weapp/resource/dj-car-boutique-work-wechat/'
import { materialListApi, leavePageTrack } from "../../api/api"
import commonApi from "~/api/api";
let currentTabType = 'video';
Component({
properties: {
navBarHeight: Number
},
data: {
IMG_URL,
userInfo: {},
menuList: [{
title: '视频',
name: 'video',
icon: 'default_video',
list: []
}, {
title: 'PDF',
name: 'PDF',
icon: 'default_pdf',
list: []
}, {
title: '图片',
name: 'image',
icon: 'default_img',
list: []
}],
searchKey: '',
showPage: false,
noResult: false,
isNeedFixed: false
},
methods: {
async onLoad() {
this.pdfPageTrack()
this.closeRemind()
setTimeout(async () => {
this.setData({
showPage: true,
userInfo: wx.$util.getUserInfo() || {}
})
// await this.getScroviewHeight()
this.getListData()
}, 300);
this.intaval = setInterval(() => {
this.selectComponent('#tabID').resize();
}, 500);
},
closeRemind() {
let userInfo = wx.$util.getUserInfo()
let params = {
merchantId: userInfo?.shopMerchantId,
staffUuid: userInfo?.uuid,
scene: 0,
taskId:6,
};
commonApi.shutDownTaskApi(params)
},
onChangeTab(e) {
currentTabType = e.detail.name
this.initData()
},
async getScroviewHeight() {
let query = wx.createSelectorQuery().in(this)
let heightArr = []
let s = 0, navBarHeight = this.data.navBarHeight
query
.selectAll('.scroll_height_d_part')
.boundingClientRect(react => {
react.forEach(item => {
s += item.height
heightArr.push(s)
})
const last = heightArr.pop()
let systemInfo = wx.getSystemInfoSync()
const scroll_height = systemInfo.safeArea.height - last - navBarHeight
this.setData({
scroll_height
})
})
.exec()
},
getListData() {
const userInfo = wx.$util.getUserInfo()
// 登录信息映射值: 0 会员权益升级 1 精品升级 3 售后众筹 ,2次新车转化
// 0-图片;1-视频;2-pdf;
const newType = currentTabType == 'video' ? 1 : currentTabType == 'PDF' ? 2 : 0
let { searchKey, noResult } = this.data
let params = {
merchantId: userInfo.default4SStoreInfo.merchantId,
scene: userInfo.sceneType,
showChannel: 1,
type: newType,
title: searchKey,
sortedBy: 1
}
let list = [], listNameMap = {
0: 'menuList[2].list',
1: 'menuList[0].list',
2: 'menuList[1].list',
}
const target = listNameMap[newType]
this.currentTarget = target
materialListApi(params).then(res => {
if (res && res.data) {
res.data.forEach(el => {
if (el.createdDate) {
let date = el.createdDate + ''
date = date.replace(/-/g, '/').split(' ')[0] // 日期格式处理
el.createdDate = date
}
})
}
list = res.data || []
noResult = list.length ? false : true
this.setData({
[target]: list,
noResult
})
})
},
onChangeSearch(e) {
},
onSearch(e) {
this.setData({
searchKey: e.detail
}, () => {
this.getListData()
})
},
onCancel(e) {
this.onSearch(e)
},
initData() {
this.setData({
[this.currentTarget]: [],
searchKey: ''
}, () => {
this.getListData()
})
},
pdfPageTrack() {
const id = wx.getStorageSync('pageQueryOfcontent_trackId')
if (id) {
leavePageTrack({ id }).then(res => {
wx.removeStorageSync('pageQueryOfcontent_trackId');
})
}
},
onHide() {
clearInterval(this.intaval)
}
}
})