pageMixin.js
1.99 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
import { marketingApi } from '@/api'
export default {
data () {
return {
list: [],
total: 0,
flag: false,
businessText: '全部',
materialName: '',
sort: 0,
businessType: '',
groupId: '',
}
},
mounted () {
let { groupId } = this.getQuery()
if (groupId) {
this.groupId = groupId
return
}
if (this.$route.name != 'psd') {
this.init()
}
},
methods: {
init () {
this.showLoading()
this.getList()
},
search (e) {
this.materialName = e
this.clearData()
},
change (index) {
let { psdGroupList } = this
if (psdGroupList.length > 1) this.groupId = psdGroupList[index + 1].value
this.clearData()
},
menuSelect (e) {
this.groupId = e && e.length && e[0].value || ''
this.clearData()
},
clearData () {
this.flag = false
this.list = []
this.init()
},
changeSort (e) {
this.sort = e
this.clearData()
},
businessConfirm (chooseList) {
console.log(chooseList)
if (chooseList.length) {
let text = []
let businessType = []
chooseList.map(e => {
text.push(e.text)
businessType.push(e.value)
})
this.businessText = `${text.join(',').substring(0, 5)}...`
this.businessType = businessType.join(',')
} else {
this.businessType = ''
this.businessText = '全部'
}
this.clearData()
},
onReachBottom () {
this.$refs.scrollView.finished = true
},
sortList (data, attr) {
return data.sort((a, b) => b[attr] - a[attr])
},
getList () {
let { materialName, businessType, groupId, sort } = this
setTimeout(()=>{
marketingApi.getPsdList({ materialName, businessType, groupId }).then(data => {
console.log('素材列表', data)
if (sort != 0 && data && data.materialToCRpcResponses && data.materialToCRpcResponses.length) data.materialToCRpcResponses = this.sortList(data.materialToCRpcResponses, sort == 1 ? 'sendNum' : 'readNum')
this.list = data.materialToCRpcResponses || []
this.flag = true
this.hideLoading()
})
},500)
}
}
}