204 lines
4.0 KiB
JavaScript
204 lines
4.0 KiB
JavaScript
// packageH/blindBox/blindBoxIndex/blindBoxIndex.js
|
|
const app = getApp();
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
activeName:0,
|
|
page:1,
|
|
searchText:'',
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
this.getData();
|
|
},
|
|
// 我的订单
|
|
goOrder() {
|
|
wx.navigateTo({
|
|
url: '/packageA/member/myOrder_v2/myOrder_v2?status=0',
|
|
});
|
|
},
|
|
tapTabs(e){
|
|
// console.log(e.detail.index)
|
|
let ind = e.detail.index;
|
|
this.setData({
|
|
activeName:ind,
|
|
page:1
|
|
});
|
|
this.getData();
|
|
},
|
|
goDetail(e){
|
|
let id = e.currentTarget.dataset.id;
|
|
wx.navigateTo({
|
|
url: '/packageH/blindBox/blindBoxDetail/blindBoxDetail?id='+id,
|
|
});
|
|
},
|
|
tapSlide(e){
|
|
let isurl = e.currentTarget.dataset.mini_url;
|
|
wx.navigateTo({
|
|
url:isurl
|
|
});
|
|
},
|
|
textInp(e){
|
|
console.log(e);
|
|
let txt = e.detail.value;
|
|
this.setData({
|
|
searchText:txt,
|
|
});
|
|
},
|
|
goSearch(){
|
|
this.setData({
|
|
page:1
|
|
});
|
|
this.getData();
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function () {
|
|
if(this.data.current_page >= this.data.last_page){
|
|
console.log('没有更多了');
|
|
return;
|
|
}else{
|
|
let pages = this.data.page + 1;
|
|
this.setData({
|
|
page : pages
|
|
});
|
|
this.getMoreData();
|
|
}
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage: function () {},
|
|
getData() {
|
|
wx.showLoading({
|
|
title: '加载中',
|
|
});
|
|
let json;
|
|
if(this.data.activeName){
|
|
json = {
|
|
activity_type:this.data.activeName,
|
|
page:this.data.page
|
|
};
|
|
}else{
|
|
json = {
|
|
activity_type:'',
|
|
page:this.data.page
|
|
};
|
|
}
|
|
if(this.data.searchText != ''){
|
|
json.search = this.data.searchText;
|
|
}
|
|
let that = this;
|
|
let urlStr = app.getNetAddresss('plugin.blind-box.api.index.activity');
|
|
app._postNetWork({
|
|
url: urlStr,
|
|
data: json,
|
|
success: (resdata) => {
|
|
let res = resdata.data;
|
|
wx.hideLoading({
|
|
success: (res) => {},
|
|
});
|
|
if (res.result == 1) {
|
|
that.setData({
|
|
list:res.data.list.data,
|
|
slide:res.data.slide,
|
|
current_page:res.data.list.current_page,
|
|
last_page:res.data.list.last_page
|
|
});
|
|
} else {
|
|
console.log(res);
|
|
}
|
|
},
|
|
fail: function (res) {
|
|
console.log(res.msg);
|
|
}
|
|
});
|
|
},
|
|
getMoreData() {
|
|
wx.showLoading({
|
|
title: '加载中',
|
|
});
|
|
let json;
|
|
if(this.data.activeName){
|
|
json = {
|
|
activity_type:this.data.activeName,
|
|
page:this.data.page
|
|
};
|
|
}else{
|
|
json = {
|
|
activity_type:'',
|
|
page:this.data.page
|
|
};
|
|
}
|
|
if(this.data.searchText != ''){
|
|
json.search = this.data.searchText;
|
|
}
|
|
let that = this;
|
|
let urlStr = app.getNetAddresss('plugin.blind-box.api.index.activity');
|
|
app._postNetWork({
|
|
url: urlStr,
|
|
data: json,
|
|
success: (resdata) => {
|
|
let res = resdata.data;
|
|
wx.hideLoading({
|
|
success: (res) => {},
|
|
});
|
|
if (res.result == 1) {
|
|
that.setData({
|
|
list:res.data.list.data,
|
|
current_page:res.data.list.current_page,
|
|
last_page:res.data.list.last_page
|
|
});
|
|
} else {
|
|
console.log(res);
|
|
}
|
|
},
|
|
fail: function (res) {
|
|
console.log(res.msg);
|
|
}
|
|
});
|
|
},
|
|
}); |