You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
119 lines
2.7 KiB
119 lines
2.7 KiB
import { urlPrefix } from '../../config/index'
|
|
// pages/home/home.js
|
|
Page({
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
goodsList: [],
|
|
pageIndex: 1,
|
|
pageLoading: false,
|
|
goodsListLoadStatus: 1,
|
|
styleId: '3',
|
|
titleImage: ''
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载1
|
|
*/
|
|
onLoad(options) {
|
|
let _titleImage = 'http://hzkc.oss-cn-beijing.aliyuncs.com/Images/temp/single_title.png';
|
|
if (options.style_id == 4) {
|
|
_titleImage = 'http://hzkc.oss-cn-beijing.aliyuncs.com/Images/temp/double_title.png';
|
|
}
|
|
this.setData({ styleId: options.style_id, titleImage: _titleImage });
|
|
this.loadDataList(true);
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom() {
|
|
if (this.data.goodsListLoadStatus === 1) {
|
|
this.setData({ pageIndex: this.data.pageIndex + 1 });
|
|
this.loadDataList();
|
|
}
|
|
},
|
|
|
|
loadDataList(fresh = false, limit = 6) {
|
|
|
|
let page = this.data.pageIndex;
|
|
if (fresh) {
|
|
page = 1;
|
|
this.setData({ goodsListLoadStatus: 1, pageIndex: 1 });
|
|
wx.pageScrollTo({
|
|
scrollTop: 0,
|
|
});
|
|
}
|
|
let that = this;
|
|
wx.request({
|
|
url: urlPrefix + '/QingLong/HuiYa/wxGetModelList',
|
|
method: "POST",
|
|
header: {
|
|
'content-type': 'application/x-www-form-urlencoded'
|
|
},
|
|
data: {
|
|
page: page,
|
|
limit: limit,
|
|
token: wx.getStorageSync('token'),
|
|
style_ids: this.data.styleId,
|
|
keyword: ''
|
|
},
|
|
success(res) {
|
|
|
|
if (res.data.token) {
|
|
wx.setStorageSync('token', res.data.token);
|
|
}
|
|
that.setData({ goodsList: fresh ? res.data.data.list : that.data.goodsList.concat(res.data.data.list) });
|
|
if (page * 6 >= res.data.data.totalRow) {
|
|
that.setData({ goodsListLoadStatus: 2 });
|
|
} else {
|
|
that.setData({ goodsListLoadStatus: 1 });
|
|
}
|
|
}
|
|
});
|
|
},
|
|
|
|
goodListClickHandle(e) {
|
|
wx.navigateTo({
|
|
url: '/pages/make/index?model_id=' + e.detail.goods.model_id + '&input_img_count=' + e.detail.goods.input_img_count + '&generate_img_count=' + e.detail.goods.max_input_count + '&model_type_id=' + e.detail.goods.model_type_id,
|
|
});
|
|
},
|
|
}) |