Riku
2024-08-13 cf693a5227f17bbf2201512128d267281a8c5695
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
import { fetchSelfPatrolDetails } from '../../../services/patrol/fetchSelfPatrol';
import { useLoading } from '../../../behaviors/loading';
Page({
  behaviors: [useLoading],
  data: {
    recordList: [],
 
    previewImageUrls: [],
    previewCurrent: 0,
    showPreview: false,
  },
 
  onLoad(options) {
    this.setData({ taskId: options.taskId });
    this._startLoad();
  },
 
  onReachBottom() {
    this._loadMore();
  },
 
  _fetchData(page) {
    const { taskId } = this.data;
    return fetchSelfPatrolDetails({ taskId }).then(res => {
      this.setData({
        recordList:
          page == 1 ? res.data : this.data.recordList.concat(res.data),
      });
      return res.head;
    });
  },
 
  previewImage(e) {
    const { index } = e.currentTarget.dataset;
    const ledger = this.data.recordList[index];
    if (ledger.ledgerFinished) {
      const previewTitle = ledger.ledgerName;
      const previewRemark = ledger.remark1;
      const previewImageUrls = ledger.path1;
      this.setData({
        previewImageUrls,
        previewRemark,
        previewTitle,
        previewCurrent: 0,
        showPreview: true,
      });
    }
  },
});