myPrize.js
2.9 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
// pages/myPrize/myPrize.js
import {
request
} from "../../request/index.js";
const a = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
userMsg:'',
s4:"",
tablist:['待领取','已领取'],
drawid: 0,
active: 1,
prizeList: [],
s4_name: '',
showGetMydetail: false,
banner: '',
myDetail: []
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
console.log(options,111);
this.setData({
drawid: options.drawid,
s4_name: wx.getStorageSync('s4_name'),
active:options.type,
userMsg:JSON.parse(options.userMsg),
s4:wx.getStorageSync('s4_name')
})
},
onShow(){
this.getBanner()
this.getMyjiang()
},
getBanner(){
request({
url: 'api/chou_banner/get_banner',
data: {}
}).then((res) => {
console.log(res)
this.setData({
banner: res.data.data[0]['image']
})
})
},
toscore(){
wx.switchTab({
url: '/pages/stores/index',
})
},
onClick(event) {
console.log(event)
wx.showToast({
title: '加载中',
icon: 'none',
});
this.setData({
drawid: this.data.drawid,
active: event.currentTarget.dataset.idx
})
console.log(this.data.active)
this.getMyjiang()
},
// 获取奖品列表
getMyjiang(id) {
request({
url: 'api/h5/myJiang',
data: {
id: wx.getStorageSync('drawId'),
way: this.data.active
}
}).then((res) => {
console.log(res)
this.setData({
prizeList: res.data.data
})
console.log(this.data.prizeList)
})
},
// 立即领取
getPrize(e) {
console.log(e)
console.log(e.currentTarget.dataset.thisdraw)
let thisDraw = e.currentTarget.dataset.thisdraw
console.log(thisDraw)
//判断是否填写过获奖信息
request({
url: 'api/h5/haveInfo',
data: {
id: wx.getStorageSync('drawId')
}
}).then((res) => {
console.log(res)
if (res.data.have_id == 0) {
a.popText('请先填写获奖信息')
return
} else {
request({
url: 'api/h5/lingJiang',
data: {
log_id: thisDraw
}
}).then((res) => {
if(res.code == 1) {
a.popTest('领取成功')
} else {
a.popTest(res.msg)
}
}).catch((err) => {
a.popTest(err.msg)
})
}
})
},
// 查看个人信息
getMydetail() {
this.setData({
showGetMydetail: true
})
request({
url: 'api/h5/userInfo',
data: {
id: wx.getStorageSync('drawId')
}
}).then((res) => {
console.log(res.data.data)
this.setData({
myDetail: res.data.data
})
})
},
closeMydetail() {
console.log('123')
this.setData({
showGetMydetail: false
})
}
})