祖安之光
2025-08-07 41193d186d157937ba052e73dd04c12018e9ecab
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
const app = getApp();
const api = require('../../../utils/api');
const cloudApi = require('../../../utils/cloudApi')
Page({
  data: {
    page: 'pages/tabBar/count/productDetail',
    statusBarHeight: '',
    examParams: {
      pageNum: 1,
      pageSize: 10,
    },
    examList: [],
    totalPage: 0
  },
 
  onLoad() {
    console.log('跳转完成');
    this.setData({
      statusBarHeight: wx.getSystemInfoSync()['statusBarHeight']
    });
    this.getList();
  },
 
  goBack() {
    const url = wx.getStorageSync("prevPage");
    if(url) {
      wx.reLaunch({
        url: url
      });
    } else {
      wx.reLaunch({
        url: '/pages/tabBar/count/count'
      });
    }
  },
 
  getList() {
    // cloudApi
    // const userId = wx.getStorageSync('user').id
    // wx.cloud.callFunction({
    //   name: 'getProductFlowByPage',
    //   data: {...this.data.examParams,userId: userId}
    // }).then(res=>{
    //   if(res.result && Array.isArray(res.result.list) && res.result.list.length>0){
    //     let list = cloudApi.changeKey(res.result.list)
    //     if (this.data.examParams.pageNum != 1) {
    //       this.setData({
    //         examList: this.data.examList.concat(list),
    //         totalPage: Math.ceil(res.result.total / res.result.pageSize)
    //       });
    //     } else {
    //       this.setData({
    //         examList: list,
    //         totalPage: Math.ceil(res.result.total / res.result.pageSize)
    //       });
    //     }
    //   }else{
    //     this.setData({
    //       examList: [],
    //       totalPage: 0
    //     });
    //   }
    // })
 
    // api请求
    api.getProductFlowByUser(this.data.examParams).then(res => {
      if(res.code == 200) {
        let list = res.data.list ? res.data.list : [];
        if (this.data.examParams.pageNum != 1) {
          this.setData({
            examList: this.data.examList.concat(list)
          });
        } else {
          this.setData({
            examList: res.data.list,
            totalPage: res.data.totalPage
          });
        }
      } else {
        wx.showToast({
          title: res.message,
          icon: 'none'
        });
      }
    });
  },
 
  upper(e) {
    // console.log(e)
  },
 
  lower(e) {
    if (this.data.examParams.pageNum >= this.data.totalPage) {
      wx.showToast({
        title: '已加载全部数据',
        icon: 'none'
      });
      return;
    }
    this.setData({
      'examParams.pageNum': this.data.examParams.pageNum + 1
    });
    this.getList();
  },
 
  scrollView(e) {
    // console.log(e)
  }
});