yuminge-app/yun-min-program-plugin-master/packageE/community_buying/group_buying/group_buying.js

194 lines
4.3 KiB
JavaScript

// packageE/community_buying/group_buying/group_buying.js
var app = getApp();
Page({
/**
* 页面的初始数据
*/
data: {
currentTime: new Date().getTime(),
active: "0",
listData: [],
shareShow: false,
shareOptions: [
{ name: "生成海报", icon: "poster" },
{ name: "分享给好友", icon: "wechat", openType: "share" },
],
openShareId: 0,
openShareImg: "",
deliver_id: 0,
isLoadMore: true,
total_page: 0,
page: 1,
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.getListData();
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {},
changeTags(e) {
this.data.active = e.detail.index;
this.getListData();
},
onSelectShare(evt) {
this.onCloseShare();
if (evt.detail.index == 0) {
this.setData({
posterShow: true,
});
}
console.log(evt.detail.index);
},
onCloseShare() {
this.setData({ shareShow: false });
},
openShareShow(e) {
let item = e.currentTarget.dataset.item;
this.setData({
openShareId: item.id,
openShareImg: item.share_img,
shareShow: true,
});
},
gotoIndex() {
wx.navigateTo({
url: "/packageE/community_buying/index/index",
});
},
gotoBuyingOrder() {
wx.navigateTo({
url: "/packageE/community_buying/buying_order/buying_order",
});
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
if (this.data.isLoadMore) {
this.getMoreListData();
} else {
console.log("没有更多数据");
}
},
gotoBuyingOrderId(evt) {
let id = evt.currentTarget.dataset.id;
wx.navigateTo({
url:
"/packageE/community_buying/buying_order/buying_order?buyingid=" + id,
});
},
gotoBuyingDetails(evt) {
let id = evt.currentTarget.dataset.id;
wx.navigateTo({
url:
"/packageE/community_buying/buying_details/buying_details?buyingid=" +
id,
});
},
getListData() {
let urlStr = app.getNetAddresss(
"plugin.package-deliver.frontend.communityGroups.groupList"
);
app._postNetWork({
url: urlStr,
data: {
status: this.data.active,
},
success: (resdata) => {
var res = resdata.data;
console.log(res);
if (res.result == 1) {
this.data.total_page = res.data.list.last_page;
if (res.data.list.current_page >= res.data.list.last_page) {
this.data.isLoadMore = false;
}
this.setData({
deliver_id: res.data.deliver_id,
listData: res.data.list.data,
});
}
},
});
},
getMoreListData() {
let urlStr = app.getNetAddresss(
"plugin.package-deliver.frontend.communityGroups.groupList"
);
this.data.page++;
app._postNetWork({
url: urlStr,
data: {
status: this.data.active,
page: this.data.page,
},
success: (resdata) => {
var res = resdata.data;
console.log(res);
if (res.result == 1) {
this.data.total_page = res.data.list.last_page;
if (res.data.list.current_page >= res.data.list.last_page) {
this.data.isLoadMore = false;
}
let listData = this.data.listata;
listData.push(...res.data.list.data);
this.setData({ listData });
}
},
});
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
let path =
"/packageE/community_buying/buying_personal/buying_personal?buyingid=" +
this.data.openShareId +
"&deliver_id=" +
this.data.deliver_id;
var mid = wx.getStorageSync('yz_uid');
if (mid) {
path = path + '&mid=' + mid
}
let obj = { path };
if (this.data.openShareImg) {
obj.imageUrl = this.data.openShareImg;
}
return obj;
},
});