mygift.vue
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
<template>
<view class="content">
<view class="giftlist">
<view class="giftitem flextwo" v-for="(item,index) in giftarr" :key="index">
<view class="giftitemleft">
<view class="flexone" v-if="item.type==1">
<view class="flexoneleft">
<image :src="item.image" mode=""></image>
</view>
<view class="itemtop jiangname">{{item.name}}</view>
</view>
<view class="itemtop" v-else>{{item.name}}</view>
<view class="itemtime">{{item.givetime}}</view>
</view>
<view class="itemname" v-if='item.is_give==2' @click="item.type==1?givegift(item):give(item)">立即兑换{{item.type}}</view>
<view class="itemnamek" v-if="item.is_give==1" @click="givegift(item)">已兑换</view>
</view>
</view>
</view>
</template>
<script>
import app from "../../App.vue";
export default {
data() {
return {
showbanben: false,
giftarr: [],
page:1
}
},
onLoad() {
},
onShow() {
this.page=1;
this.giftarr=[];
this.getgift()
},
methods: {
getgift(item) {
let that = this;
var url = 'gift/my_gift';
console.log('获取的参数', that.seldata)
var params = {
page:that.page,
pageNum:10
}
console.log(params)
app.post(url, params, "post").then((res) => {
console.log(res);
if(that.page>1){
if(res.data.data.length==0){
uni.showToast({
title:'没有更多了~',
icon:'none'
})
}
}
that.giftarr =that.giftarr.concat(res.data.data);
}).catch((err) => {
console.log(err)
})
},
// 领取积分优惠券
give(item) {
let that = this;
console.log("领取优惠券")
var url = 'gift/give';
console.log('获取的参数', that.seldata)
var params = {
gift_log_id: item.id
}
console.log(params)
app.post(url, params, "post").then((res) => {
console.log(res);
uni.showToast({
title:"兑换成功",
icon:"none"
})
that.page=1;
that.giftarr=[]
setTimeout(function(){
that.getgift()
},1500)
}).catch((err) => {
console.log(err)
uni.showToast({
title:err.msg,
icon:'none'
})
})
},
// 领取实物奖品
givegift(item) {
console.log("领取实物",item.id)
let that = this;
var newitem=JSON.stringify(item)
uni.navigateTo({
url:'/pages/homepage/giftorder?gift_log_id='+item.id+'&item='+newitem
})
}
},
onReachBottom() {
let newpage=this.page;
newpage++;
this.page=newpage;
this.getgift()
}
}
</script>
<style>
.flexoneleft {
width: 50rpx;
height: 50rpx;
font-size: 0;
}
.jiangname {
margin-left: 10rpx;
}
.giftlist {
padding: 0 32rpx;
box-sizing: border-box;
}
.giftitem {
padding: 24rpx 0;
box-sizing: border-box;
border-bottom: 1rpx solid #f5f5f5
}
.itemtop {
color: #232323;
font-size: 32rpx;
font-weight: bold;
}
.itemtime {
color: #BBC2CB;
font-size: 24rpx;
margin-top: 10rpx;
}
.itemname {
width: 160rpx;
height: 64rpx;
border-radius: 8rpx;
border: 2rpx solid rgba(255, 146, 24, 1);
color: #FF9218;
font-size: 30rpx;
text-align: center;
line-height: 64rpx;
}
.itemnamek {
width: 160rpx;
height: 64rpx;
border-radius: 8rpx;
color: #3F4444;
border: 1rpx solid #3F4444;
font-size: 30rpx;
text-align: center;
line-height: 64rpx;
}
</style>