ll
liukangdong
2024-08-06 d41f1f707dc643b726a42b9d2a63b186dd9e4f28
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
191
192
import { getZhongTaiVideoPage,  actionDo, getCataLogTagList ,refreshEnjoy} from '../../api/index'
Page({
 
  /**
   * 页面的初始数据
   */
  data: {
    activeIndex: -1,
    activeParam: [],
    tagCodes: [],
 
    category: [],
    tagCodes: [],
    acVid:'',
    viewIdList: [],
 
    dataList: [],
    total: 0,
    pageSize: 10,
    pageNum: 1,
 
  },
  changeShowParams(e) {
    const { category } = this.data
    const activeIndex = e.currentTarget.dataset.index
    if (activeIndex === this.data.activeIndex) {
      this.setData({ activeIndex: -1, activeParam: [] })
    } else {
      this.setData({
        activeIndex,
        activeParam: category[activeIndex].valueVos
      })
    }
  },
  cancelParam() {
    const { category } = this.data
    category.forEach(item => { 
      item.tempParamIndex = item.paramIndex
      item.tempParamName =   item.paramName
      item.tempParamCode =  item.paramCode 
    })
    this.setData({ activeParam: [],activeIndex: -1 ,category}) 
  },
  subParam() {
    const { category } = this.data
    var codes = []
    category.forEach(item => {
      item.paramIndex =  item.tempParamIndex 
      item.paramName = item.tempParamName  
      item.paramCode = item.tempParamCode
      if( item.paramIndex>-1 && item.tempParamCode){
        codes.push( item.tempParamCode) 
      } 
    })  
    this.setData({tagCodes:codes}) 
    this.setData({ pageNum: 1, activeParam: [] ,activeIndex: -1, dataList: [], total: 0 })
    this.getList()
  },
  tagClick(e) {
    const code = e.currentTarget.dataset.code
    const paramIndex = e.currentTarget.dataset.index
    const { category, tagCodes, activeParam, activeIndex } = this.data
    const index = tagCodes.indexOf(code)
    if ( category[activeIndex].tempParamIndex==null || category[activeIndex].tempParamIndex != paramIndex) {
      category[activeIndex].tempParamIndex = paramIndex
      category[activeIndex].tempParamCode = code
      category[activeIndex].tempParamName = activeParam[paramIndex].labelValueName
    } else {
      category[activeIndex].tempParamIndex = -1
      category[activeIndex].tempParamCode = ''
      category[activeIndex].tempParamName = ''
    }
    this.setData({ category })
  },
  onReachBottom() {
    console.log('触底事件');
    const { total, dataList, pageNum } = this.data
    if(total > dataList.length){
      this.setData({ pageNum: pageNum + 1 })
      this.getList()
    }else{
      wx.showToast({
        title: '暂无更多数据',
        icon: 'none'
      })
    }
  },
  getList() {
    const { pageSize, pageNum, tagCodes } = this.data
    getZhongTaiVideoPage({
      pageSize,pageNum, tagCodes
    }).then(res => {
      this.setData({
        dataList: [...this.data.dataList, ...res.data.records],
        total: res.data.total
      })
    })
  },
  getTagList() {
    getCataLogTagList({
      catalogCode: 'video_rec'
    }).then(res => {
      this.setData({ category: res.data })
    })
  },
  itemClick(e) {
    const { id } = e.currentTarget.dataset.item
    const { dataList, acVid, viewIdList } = this.data
    const index = viewIdList.findIndex(i => i === id)
    if(acVid){
      if(id != acVid){
        wx.createVideoContext(acVid).pause()
        wx.createVideoContext(id).play()
        this.setData({ acVid: id })
      }
    }else{
      this.setData({ acVid: id })
      wx.createVideoContext(id).play()
    }
    dataList.forEach(ite => {
      if(id === ite.id && index === -1){
        ite.viewCount += 1
        viewIdList.push(id)
        actionDo({
          actionType: 'view',
          id: id
        })
        this.setData({ viewIdList })
      }
    })
    this.setData({ dataList })
  },
  cateClick(e) {
    const { code, index } = e.target.dataset
    if(this.data.activeIndex === index){
      this.setData({ tagCodes: [], activeIndex: -1 })
    }else{
      this.setData({ tagCodes: [code], activeIndex: index })
    }
    this.setData({ total: 0, dataList: [], pageNum: 1 })
    this.getList()
  },
  seCateClick(e) {
    const { index } = e.target.dataset
    console.log(index);
  },
  onLoad(options) {
    this.getTagList()
    this.getList()
  },
 
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {
 
  },
 
  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    refreshEnjoy(this)
  },
 
  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {
 
  },
 
  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {
 
  },
 
  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {
 
  },
  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {
 
  }
})