171 lines
3.9 KiB
JavaScript
171 lines
3.9 KiB
JavaScript
// packageH/starMusic/starMusicOpenGroup/starMusicOpenGroup.js
|
|
var app = getApp();
|
|
Page({
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
sid: null,
|
|
sitem: null,
|
|
listData: [],
|
|
|
|
page: 1, //分页数,当前页数
|
|
isLoadMore: true, //判断是否要加载更多的标志
|
|
total_page: 0, //总页数
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
this.getData();
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady: function () {},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: function () {},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide: function () {},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload: function () {},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh: function () {},
|
|
|
|
openGroup() {
|
|
let { sid, sitem } = this.data;
|
|
if (sid == null) return app.tips("请选择要开的团");
|
|
let urlStr = app.getNetAddresss("plugin.star-spell.frontend.team.openTeam");
|
|
app._postNetWork({
|
|
url: urlStr,
|
|
data: {
|
|
at_id: sid,
|
|
goods_data: { goods_id: sitem.goods_id, total: 1, option_id: 0 },
|
|
},
|
|
success: (resdata) => {
|
|
var res = resdata.data;
|
|
if (res.result != 1) return app.tips(res.msg);
|
|
app.tips(res.msg);
|
|
setTimeout(() => {
|
|
this.gotoStarMusicGroupDetails(res.data.leader_id);
|
|
}, 800);
|
|
},
|
|
});
|
|
},
|
|
gotoStarMusicGroupDetails(id) {
|
|
wx.navigateTo({
|
|
url:
|
|
"/packageH/starMusic/starMusicGroupDetails/starMusicGroupDetails?id=" +
|
|
id,
|
|
});
|
|
//this.$router.push(this.fun.getUrl("starMusicGroupDetails",{id}));
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function () {
|
|
if (this.data.isLoadMore) {
|
|
this._getMoreData();
|
|
} else {
|
|
console.log("没有更多数据");
|
|
}
|
|
},
|
|
|
|
getData() {
|
|
let urlStr = app.getNetAddresss(
|
|
"plugin.star-spell.frontend.index.openTeam"
|
|
);
|
|
app._postNetWork({
|
|
url: urlStr,
|
|
data: {},
|
|
success: (resdata) => {
|
|
var res = resdata.data;
|
|
if (res.result != 1) return app.tips(res.msg);
|
|
|
|
this.data.isLoadMore = true;
|
|
this.data.total_page = res.data.last_page;
|
|
if (!this.data.total_page) {
|
|
this.data.total_page = 0;
|
|
}
|
|
this.setData({
|
|
listData: res.data.data,
|
|
});
|
|
},
|
|
});
|
|
},
|
|
|
|
//加载更多数据
|
|
_getMoreData() {
|
|
this.data.isLoadMore = false; // 防止多次请求分页数据
|
|
if (this.data.page >= this.data.total_page) {
|
|
// that.loading = true;
|
|
return;
|
|
} else {
|
|
this.data.page += 1;
|
|
let urlStr = app.getNetAddresss(
|
|
"plugin.star-spell.frontend.index.openTeam"
|
|
);
|
|
app._postNetWork({
|
|
url: urlStr,
|
|
data: {
|
|
page: this.data.page,
|
|
},
|
|
success: (resdata) => {
|
|
let res = resdata.data;
|
|
this.data.isLoadMore = true;
|
|
if (res.result === 1) {
|
|
var nextPageData = res.data.data;
|
|
let listData = this.data.listData.concat(nextPageData);
|
|
this.setData({ listData });
|
|
} else {
|
|
this.data.page = this.data.page - 1;
|
|
this.data.isLoadMore = false;
|
|
}
|
|
},
|
|
});
|
|
}
|
|
},
|
|
|
|
setSid(evt) {
|
|
let item = evt.currentTarget.dataset.item;
|
|
this.data.sitem = item;
|
|
this.setData({
|
|
sid: item.activity_id,
|
|
});
|
|
},
|
|
gotoStarMusicIndex() {
|
|
if (getCurrentPages().length == 2) {
|
|
wx.navigateBack();
|
|
} else {
|
|
wx.reLaunch({
|
|
url: "/packageH/starMusic/starMusicIndex/starMusicIndex",
|
|
});
|
|
}
|
|
},
|
|
gotoStarMusicMy() {
|
|
wx.navigateTo({
|
|
url: "/packageH/starMusic/starMusicMy/starMusicMy",
|
|
});
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage: function () {},
|
|
});
|