evaluateList.js
3.96 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
158
159
160
//evaluateList.js
import { API_HOST } from '../../../libs/config';
import { GET } from '../../../libs/request';
import { getChannelCode, getGenderCode } from '../../../utils/home';
import { parseEvaluateListData } from '../../../utils/evaluateList';
import {
logEvent,
YB_PAGE_OPEN_L,
} from '../../../libs/analytics.js'
//获取应用实例
var app = getApp();
const windowWidth = app.globalData.systemInfo.windowWidth;
const screenHeight = app.globalData.systemInfo.screenHeight;
let imageWidth = windowWidth;
let PV_ID = new Date().getTime() + '';
Page({
/**
* 页面的初始数据
*/
data: {
isFetching: false,
gender: '',
yh_channel: 1,
productId: '',
page: 1,
totalPage: 1,
fileterList: null,
evaluateList: null,
currentFilterId: '7',
current_page_name: 'evaluateList',
screenHeight,
scrollTop: 0
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
let gender = getGenderCode(getApp().globalData.selectedChannel);
let yh_channel = getChannelCode(getApp().globalData.selectedChannel);
var res = tt.getSystemInfoSync()
let screenHeight = res.windowHeight;
this.setData({
screenHeight,
gender: gender,
yh_channel: yh_channel,
productId : options.productId
});
this.fetchEvaluateList();
let from_page_name = options.page_name ? options.page_name : '';
let from_page_param = options.page_param ? options.page_param : '';
let current_page_param = options.productId ? options.productId:'';
let params = {
PAGE_NAME: this.data.current_page_name,
PAGE_PARAM: current_page_param,
FROM_PAGE_NAME: from_page_name,
FROM_PAGE_PARAM: from_page_param,
PV_ID: PV_ID,
};
logEvent(YB_PAGE_OPEN_L, params);
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
//下拉加载更多
loadMore: function () {
if (this.data.page >= this.data.totalPage) {
return;
}
this.setData({
page: this.data.page + 1,
});
this.fetchEvaluateList();
},
//获取晒单数据
fetchEvaluateList: function () {
let param = {
method: 'show.productShareOrderList',
gender: this.data.gender,
yh_channel: this.data.yh_channel,
productId: this.data.productId,
filterId: this.data.currentFilterId,
limit: '10',
page: this.data.page,
fromPage: this.data.current_page_name,
}
this.setData({
isFetching: true,
});
GET(API_HOST, param)
.then(result => {
if (!result || !result.code || result.code != 200) {
this.setData({
isFetching: false,
});
return;
}
let pageResponse = result.data.pageResponse;
let evaluateList = parseEvaluateListData(pageResponse.list, 200, 200, 80, 80, imageWidth);
if (this.data.page == 1) {
this.data.evaluateList = evaluateList;
} else { // 当page>1 时,数据累加,分页数据
evaluateList.map((item) => {
this.data.evaluateList.push(item);
});
}
this.setData({
isFetching: false,
page: pageResponse.pageNo,
totalPage: pageResponse.totalPage,
fileterList: result.data.fileter,
evaluateList: this.data.evaluateList
});
})
.catch(error => {
this.setData({
isFetching: false,
});
});
},
//选中顶部分类
onFilterIdSelected: function (e) {
let id = e.currentTarget.dataset.id;
if (id == this.data.currentFilterId) { //点的同一个不做处理
return;
}
this.setData({
scrollTop: 0
})
this.setData({
currentFilterId: id,
page:1
});
this.fetchEvaluateList();
},
//预览图片
previewImage: function (event) {
var src = event.currentTarget.dataset.src;
tt.previewImage({
urls: [src] // 需要预览的图片http链接列表
})
},
})