user_spsy.js
3.4 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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
// pages/user/usersy/usersy.js
var e = getApp(),
os = e.globalData.setting;
var ut = require('../../../utils/util');
var regeneratorRuntime = require('../../../utils/runtime.js');
Page({
/**
* 页面的初始数据
*/
data: {
qr_code_object: {},
xp_list: null,
iurl: os.imghost,
page: 1,
isLoading: 0,
no_more: 0,
is_use: 0 //领取状态
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
var h_pic = options.img;
if (h_pic.indexOf("http") == -1) {
h_pic = os.imghost + h_pic;
}
var FormId = options.FormId;
var GradeId = options.gradeId;
var now = ut.gettimestamp();
this.setData({
h_pic,
GradeId,
FormId,
now,
});
this.requestData()
this.getQrCode(FormId,GradeId)
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
async getQrCode(FormId,GradeId) {
const res = await getApp().request.promiseGet("/api/weshop/users/grade/wares/code/get", {
data: {
privilegeId: FormId,
storeId: os.stoid,
GradeId:GradeId,
userId: getApp().globalData.user_id,
},
});
if (res.data.code == 0 && res.data.data) {
if (res.data.data.VerifyDate || res.data.data.VerifyNo) {
this.setData({
is_use: 1
})
} else {
this.setData({
qr_code_object: res.data.data,
})
}
}
},
async requestData() {
if (this.data.no_more) return false;
if (this.data.isLoading) return false;
this.data.isLoading = 1;
let {
GradeId,
FormId,
page,
xp_list
} = this.data;
let req_data = {
page,
GradeId,
FormId,
storeId: os.stoid,
userId: getApp().globalData.user_id,
}
const res = await getApp().request.promiseGet("/api/weshop/users/grade/wechat/wares/page", {
data: req_data
});
if (ut.ajax_ok(res)) {
if (res.data.data.page > 1) {
xp_list = xp_list.concat(res.data.data.pageData);
} else {
xp_list = res.data.data.pageData;
}
this.setData({
xp_list,
isLoading: 0,
no_more: 0,
})
} else {
this.setData({
xp_list: [],
isLoading: 0,
no_more: 0,
})
}
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
},
/*-- 打开服务项目 --*/
open_xp: function (e) {
var th = this;
var qc_com = this.selectComponent("#qc_com"); //组件的id
qc_com.open(th.data.qr_code_object)
},
//--领取商品--
async show_hxm(e) {
setTimeout(() => {
let qr_code_object = this.data.qr_code_object;
if (qr_code_object !== {}) {
let {
WriteOffCode: val,
BeginDate,
EndDate
} = qr_code_object;
let qr_code = this.selectComponent("#qc_com");
let obj = {
val,
content: "当前核销码仅限当面使用",
now: BeginDate,
validay: EndDate,
is_quan: 0,
is_fw:0,
};
qr_code.open(obj)
} else {
wx.showToast({
title: "获取失败",
icon: 'none',
duration: 1000
})
}
}, 500);
},
close: function () {
this.getQrCode(this.data.FormId)
}
})