179 lines
3.5 KiB
JavaScript
179 lines
3.5 KiB
JavaScript
/* eslint-disable no-param-reassign */
|
|
|
|
import Toast from 'tdesign-miniprogram/toast/index';
|
|
|
|
const initFilters = {
|
|
overall: 1,
|
|
sorts: '',
|
|
};
|
|
|
|
Page({
|
|
data: {
|
|
emoticonDataList: [{
|
|
emoticonDataId: 1,
|
|
emoticonDataImg: "http://mall.api.aerwen.net/Uploads/uploads/20231029/C59225894486D6A4.jpg",
|
|
emoticonDataName: "loopy表情包"
|
|
},],
|
|
tabList: [{
|
|
text: "全部",
|
|
key: 0,
|
|
},
|
|
{
|
|
text: "可爱loopy",
|
|
key: 1,
|
|
},
|
|
],
|
|
categoryGuid: 0,
|
|
overall: 1,
|
|
show: false,
|
|
hasLoaded: false,
|
|
keywords: '',
|
|
loadMoreStatus: 0,
|
|
loading: true,
|
|
},
|
|
|
|
privateData: {
|
|
tabIndex: 0,
|
|
},
|
|
|
|
total: 0,
|
|
pageNum: 1,
|
|
pageSize: 10,
|
|
|
|
onLoad(options) {
|
|
const {
|
|
searchValue = ''
|
|
} = options || {};
|
|
this.setData({
|
|
keywords: searchValue,
|
|
},
|
|
() => {
|
|
this.init(true);
|
|
},
|
|
);
|
|
},
|
|
|
|
generalQueryData(reset = false) {
|
|
const {
|
|
keywords,
|
|
} = this.data;
|
|
const {
|
|
pageNum,
|
|
pageSize
|
|
} = this;
|
|
|
|
const params = {
|
|
pageNum: 1,
|
|
pageSize: 6,
|
|
goodsName: keywords,
|
|
};
|
|
|
|
if (reset) return params;
|
|
return {
|
|
...params,
|
|
pageNum: pageNum + 1,
|
|
pageSize,
|
|
};
|
|
},
|
|
|
|
// 点击分类
|
|
tabChangeHandle(e) {
|
|
this.privateData.tabIndex = e.detail;
|
|
this.setData({
|
|
categoryGuid: e.detail.value,
|
|
});
|
|
// 刷新列表
|
|
this.init()
|
|
},
|
|
|
|
async init(reset = true) {
|
|
const {
|
|
loadMoreStatus,
|
|
emoticonDataList = []
|
|
} = this.data;
|
|
const params = this.generalQueryData(reset);
|
|
if (loadMoreStatus !== 0) return;
|
|
this.setData({
|
|
loadMoreStatus: 1,
|
|
loading: true,
|
|
});
|
|
// try {
|
|
// const result = await getemoticonList(params);
|
|
// const data = result.data;
|
|
// if (result.code == 200) {
|
|
// const {
|
|
// result,
|
|
// totalPage = 0
|
|
// } = data;
|
|
// if (totalPage === 0 && reset) {
|
|
// this.total = totalPage;
|
|
// this.setData({
|
|
// emptyInfo: {
|
|
// tip: '抱歉,未找到相关商品',
|
|
// },
|
|
// hasLoaded: true,
|
|
// loadMoreStatus: 0,
|
|
// loading: false,
|
|
// emoticonDataList: [],
|
|
// });
|
|
// return;
|
|
// }
|
|
|
|
// const _emoticonDataList = reset ? result : emoticonDataList.concat(result);
|
|
// const _loadMoreStatus = _emoticonDataList.length === totalPage ? 2 : 0;
|
|
// this.pageNum = params.pageNum || 1;
|
|
// this.total = totalPage;
|
|
// this.setData({
|
|
// emoticonDataList: _emoticonDataList,
|
|
// loadMoreStatus: _loadMoreStatus,
|
|
// });
|
|
// } else {
|
|
// this.setData({
|
|
// loading: false,
|
|
// });
|
|
// wx.showToast({
|
|
// title: '查询失败,请稍候重试',
|
|
// });
|
|
// }
|
|
// } catch (error) {
|
|
// this.setData({
|
|
// loading: false,
|
|
// });
|
|
// }
|
|
this.setData({
|
|
hasLoaded: true,
|
|
loading: false,
|
|
});
|
|
},
|
|
|
|
handleSubmit(e) {
|
|
this.setData({
|
|
emoticonDataList: [],
|
|
loadMoreStatus: 0,
|
|
keywords: e.detail.value
|
|
},
|
|
() => {
|
|
this.init(true);
|
|
},
|
|
);
|
|
},
|
|
|
|
onReachBottom() {
|
|
const {
|
|
emoticonDataList
|
|
} = this.data;
|
|
const {
|
|
total = 0
|
|
} = this;
|
|
if (emoticonDataList.length === total) {
|
|
this.setData({
|
|
loadMoreStatus: 2,
|
|
});
|
|
return;
|
|
}
|
|
this.init(false);
|
|
},
|
|
|
|
|
|
|
|
}); |