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.
174 lines
3.8 KiB
174 lines
3.8 KiB
import { urlPrefix } from '../../config/index'
|
|
// pages/home/home.js
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
|
|
pageLoading: true,
|
|
goodsList: [],
|
|
pageIndex: 1,
|
|
pageLoading: false,
|
|
goodsListLoadStatus: 1,
|
|
wxCode: "",
|
|
visible: false,
|
|
showIndex: false,
|
|
closeBtn: false,
|
|
deleteBtn: false,
|
|
images: [],
|
|
delImageId: 0,
|
|
showWarnConfirm: false
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载1
|
|
*/
|
|
onLoad(options) {
|
|
// wx.setStorageSync('worksMd5', '1');
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow(options) {
|
|
this.getTabBar().init();
|
|
|
|
if (wx.getStorageSync('refreshFlag') == 1) {
|
|
this.loadDataList(true);
|
|
}
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide() {
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh() {
|
|
this.loadDataList(true);
|
|
wx.stopPullDownRefresh();
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
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/wxGetTaskImage',
|
|
method: "POST",
|
|
header: {
|
|
'content-type': 'application/x-www-form-urlencoded'
|
|
},
|
|
data: {
|
|
page: page,
|
|
limit: limit,
|
|
token: wx.getStorageSync('token'),
|
|
},
|
|
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.setStorageSync('refreshFlag', 0);
|
|
wx.request({
|
|
url: urlPrefix + '/QingLong/HuiYa/wxShowNextNine',
|
|
method: "POST",
|
|
header: {
|
|
'content-type': 'application/x-www-form-urlencoded'
|
|
},
|
|
data: {
|
|
id: e.detail.goods.id,
|
|
token: wx.getStorageSync('token'),
|
|
limit: 20
|
|
},
|
|
success(res) {
|
|
if (res.data.token) {
|
|
wx.setStorageSync('token', res.data.token);
|
|
}
|
|
if (res.data.success) {
|
|
wx.previewImage({
|
|
urls: res.data.data // 需要预览的图片http链接列表
|
|
})
|
|
}
|
|
}
|
|
});
|
|
|
|
},
|
|
|
|
delHandle(e) {
|
|
this.setData({ showWarnConfirm: true, delImageId: e.detail.goods.id });
|
|
},
|
|
confirmDialog(e) {
|
|
let that = this;
|
|
wx.request({
|
|
url: urlPrefix + '/QingLong/HuiYa/wxDeleteImage',
|
|
method: "POST",
|
|
header: {
|
|
'content-type': 'application/x-www-form-urlencoded'
|
|
},
|
|
data: {
|
|
id: this.data.delImageId,
|
|
token: wx.getStorageSync('token'),
|
|
},
|
|
success(res) {
|
|
if (res.data.token) {
|
|
wx.setStorageSync('token', res.data.token);
|
|
}
|
|
if (res.data.success) {
|
|
that.loadDataList(true);
|
|
that.setData({ showWarnConfirm: false });
|
|
}
|
|
}
|
|
});
|
|
},
|
|
|
|
cancelDialog(e) {
|
|
this.setData({ showWarnConfirm: false });
|
|
},
|
|
}) |