mygiftpack.js
3.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
var i = require("../../../utils/util.js")
var e = getApp(),
a = e.globalData.setting,
os = a,
t = e.request,
d = e.globalData;
Page({
data: {
iurl: a.imghost, //图片前缀网址
getDate: "",
getStorageID: '',
getUserID: '',
wareCard: [],
// pages: 0,
// pageSize: 10,
isEmpty: false,
loadingType: 0, //定义加载方式 0---contentdown 1---contentrefresh 2---contentnomore
contentText: {
contentdown: '加载更多',
contentrefresh: '加载中...',
contentnomore: '已加载全部'
},
ismore: 0, //数据是否全部加载完成
is_read: 0, //是否查询过我的礼包接口
curpage: 1, //当前分页数
pageSize: 10, //页大小
total: 0, //总数量
},
onLoad: function(options) {
//--先判断会员状态--
var user_info = getApp().globalData.userInfo;
if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) {
wx.navigateTo({
url: '/pages/getphone/getphone',
})
return false;
}
var th = this;
th.setData({
getStorageID: a.stoid,
getUserID: d.user_id,
loadingType: 0,
getDate: i.formatTime(new Date().getTime())
})
th.getList();
},
onShow: function() {
//--先判断会员状态--
var user_info = getApp().globalData.userInfo;
if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) {
wx.navigateTo({
url: '/pages/getphone/getphone',
})
return false;
}
},
getList: function() {
var th = this;
getApp().request.get('/api/weshop/marketing/my/giftbag/page', {
isShowLoading: true,
data: {
storeId: th.data.getStorageID, //商家ID
userId: th.data.getUserID, //用户ID
page: th.data.curpage,
pageSize: th.data.pageSize
},
success: function(res) {
if (res.data.code == 0) {
th.data.curpage++;
var arr1 = th.data.wareCard;
var arr2 = res.data.data.pageData;
var arr3 = [...arr1, ...arr2];
var ismore = 0;
if (arr3.length == res.data.data.total) ismore = 1
th.setData({
wareCard: arr3,
total: res.data.data.total,
ismore: ismore,
is_read: 1
}), wx.stopPullDownRefresh(); //停止下拉刷新
} else {
th.setData({
is_read: 1,
ismore:1
})
}
}
});
},
//销毁界面跳转
redirectTo: function(e) {
var th = this;
var url = e.currentTarget.dataset.url;
//销毁跳转
wx.redirectTo({
url: url
});
},
//不销毁界面跳转
navigateTo: function(e) {
var th = this;
var url = e.currentTarget.dataset.url;
getApp().goto(url);
},
//下拉事件
onReachBottom: function() {
var th = this;
if (th.data.total <= th.data.pageSize) return;
if (th.data.ismore) return;
th.getList();
},
//图片失败,默认图片
bind_bnerr2: function(e) {
var _errImg = e.target.dataset.errorimg;
var _errObj = {};
_errObj[_errImg] = "/public/images/empty.jpg";
this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ;
},
});