couponCollectionDetails.vue
8.85 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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
<template>
<div class="good-details-box">
<!-- H5唤起App组件 -->
<call-app-box class="call-app-box"
:style="'padding-top: ' + $parent.top.value + 'px'"
ref="callApp"
v-if="!isCNLive.value"
:callApps="$parent.callApps">
</call-app-box>
<back-box v-if="isCNLive.value"
:class="{'hide': $route.query.hideBack == true}"
class="back-box"
:style="'padding-top: ' + $parent.top.value + 'px'"
@back="back"
:backs="backs">
</back-box>
<!-- pl -->
<div class="pl"
:style="'padding-top: ' + $parent.top.value + 'px'"
:class="{'is-cnlive': isCNLive.value, 'is-open-app': $parent.isOpenApp.value, 'hide': $route.query.hideBack == true}"></div>
<div class="banner_box"
v-if="goodsInfo">
<div class="banner_desc">
满{{parseInt(goodsInfo.filled)}}可用
</div>
<div class="discount">
{{parseInt(goodsInfo.discount) > 10000 ? this.formatDecimal((parseInt(goodsInfo.discount) / 10000), 1) + "万" : parseInt(goodsInfo.discount)}}
<span>¥</span>
</div>
</div>
<!-- 内容 -->
<div class="main-box">
<!-- 标题 -->
<div v-if="goodsInfo"
class="title">
满{{parseInt(goodsInfo.filled)}}减{{parseInt(goodsInfo.discount)}} 满{{parseInt(goodsInfo.filled)}}可用
(<span v-if="goodsInfo.sort==1">店铺全场</span>
<span v-else-if="goodsInfo.sort==3">单品优惠</span>)
</div>
<!-- 商品信息 -->
<div class="goods-info">
<!-- 商品规格 -->
<div class="good-title">
<span class="left"></span>领取规则
<span class="right"></span>
</div>
<div class="good-desc">
<!-- 优惠券 -->
<div class="desc_title">兑换流程</div>
<div class="text-left">
1、 领取后需在优惠券有效期内使用<br> 2、请到【购物车】或购好物挑选商品下单使用。
</div>
<div class="desc_title mar_top10">注意事项</div>
<div class="text-left">
1、 使用说明:此优惠券每个手机号
<span v-if="goodsInfo && goodsInfo.receive_number == 1">不限次数领;</span>
<span v-else-if="goodsInfo && goodsInfo.receive_number == 2">只能领取一次;</span>
<br> 2、优惠券有效期:优惠券使用有效期截止到
<span v-if="goodsInfo && goodsInfo.endtime">{{goodsInfo.endtime*1000 | datetime('yyyy-MM-dd')}}</span>;
<!-- <a href="tel:010-65832485">010-65832485</a> -->
</div>
</div>
</div>
</div>
<!-- 有积分页脚显示 -->
<div v-if="goodsInfo && goodsInfo.stock != 0">
<!-- 积分充足 -->
<div class="footer">
<div class="btn"
@click="coupon">
立即领取
</div>
</div>
</div>
</div>
</template>
<script>
import { Swipe, SwipeItem } from 'vant';
import callAppBox from "@/components/callAppBox/callAppBox";
import swiper from "@/components/swiper/swiper";
import backBox from "@/components/backBox/backBox";
import { Toast, Indicator } from "mint-ui";
export default {
data () {
return {
title: "", // 标题
banner: null,
goodsInfo: null,
backs: null, // 后退按钮组
}
},
//部件
components: { callAppBox, swiper, backBox },
//静态
props: [
],
//对象内部的属性监听,也叫深度监听
watch: {
},
//属性的结果会被缓存,除非依赖的响应式属性变化才会重新计算。主要当作属性来使用;
computed: {
},
//方法表示一个具体的操作,主要书写业务逻辑;
methods: {
/**
* 分享
*/
toShare () {
// 判断分享
if (typeof this.$parent.toShare === 'function') {
this.$parent.toShare(77, (this.$route.query.couponId || 1));
}
},
// type=2跳转原生优惠券列表3跳转原生购买内容列表
jumpType (type) {
// 跳转到优惠券列表
window.obj.jumpCoupon();
},
// 领取优惠券
coupon () {
if (this.isCNLive.value) {
// 校验登录
if (this.$parent.checkLogin()) {
// 实物商品不提示用积分
this.getShopCoupon();
}
} else {
this.$parent.callApp();
}
},
/**
* 领取优惠券接口
*/
getShopCoupon () {
// 加载中提示
Indicator.open("加载中...");
// 获取证书请求接口
this.http("/Api/" + this.getApiVersion().index + "/getShopCoupon", {
uid: this.getStore("uid"),
coupon_id: this.$route.query.couponId, // 优惠券ID
}, this.getShopCouponCallback, {
method: "POST"
});
},
/**
* 积分兑换接口回调
* @param {Object} res [服务器返回数据]
* @param {Object} ext [扩展参数]
*/
getShopCouponCallback (res, ext) {
// 加载完成
Indicator.close();
// 返回处理
if (res.code == 200) {
// 解构数据
let { data: datas } = res;
// 方式连续点击兑换
this.isExchange = true;
// 两秒后可继续兑换
let _this = this
setTimeout(function () {
_this.isExchange = false;
}, 1500);
// 提示语判断
let tipMessage = "优惠券已存入您的账户,前往“我的”—“我的卡券查看”"
// 显示查看地址弹框
let options = {
message: tipMessage,
messageAlign: "center",
confirmButtonText: "确定",
showCancelButton: true,
cancelButtonText: "取消",
confirmButtonCallback: this.jumpType,
};
this.$set(this.$parent, "showOptions", options);
// 显示通用浮层
this.$parent.$refs.showModal.showLayer();
} else {
Toast(res.message);
}
},
/**
* 优惠券商品详情页页面接口
*/
couponInfo (couponId) {
// 加载中提示
Indicator.open("加载中...");
// 获取证书请求接口
this.http("/Api/" + this.getApiVersion().index + "/couponInfo", {
coupon_id: couponId, // 商品ID
uid: this.getStore("uid") // 用户ID
}, this.couponInfoCallback, {
method: "POST"
});
},
/**
* 优惠券商品详情页页面接口回调
* @param {Object} res [服务器返回数据]
* @param {Object} ext [扩展参数]
*/
couponInfoCallback (res, ext) {
// 加载完成
Indicator.close();
// 返回处理
if (res.code == 200) {
// 解构数据
let { data: datas } = res;
/* 获取详细信息 */
this.goodsInfo = datas
/* 设置商品详情页 */
/* 相似商品 */
} else if (res.code == 400) {
// 获取优惠券商品详情页失败
Toast(res.message);
} else {
// 获取优惠券商品详情页失败
Toast("获取优惠券商品详情页失败");
}
},
/**
* 后退
*/
back () {
// 返回先隐藏弹框
// 判断是否有处理函数
if (typeof this.$parent.back === 'function') {
// 隐藏通用浮层
this.$parent.$refs.showModal.hideLayer();
// 后退
this.$parent.back();
} else {
// 后退
window.history.go(-1);
}
},
},
//请求数据
created () {
// 设置标题
this.$set(this, "title", "优惠券");
// 获取商品ID
let couponId = this.$route.query.couponId;
if (couponId) {
// 获取商品信息
this.couponInfo(couponId);
}
// 判断是否在App内
if (this.isCNLive.value) {
// 添加后退按钮组“后退”和“分享”按钮
this.$set(this, 'backs', {
funcs: {
back: {
icon: "static/img/icon_back.png"
},
funcArray: [
{
icon: "static/img/icon_share.png",
func: this.toShare
}
]
}
});
// 设置标题
this.$set(this.backs, 'title', '优惠券');
}
},
mounted () {
// 如果是App外,设置唤起App和微信内分享参数
if (!this.isCNLive.value) {
// 设置积分首页唤起app参数
if (typeof this.$parent.getOpenApp === "function") {
this.$parent.getOpenApp({
type: 77,
id: this.$route.query.couponId || 1,
url: ""
});
}
if (typeof this.$parent.getShareData === "function") {
this.$parent.getShareData({
type: 77,
id: this.$route.query.couponId || 1,
url: ""
});
}
}
}
}
</script>
<style scoped lang="less" rel="stylesheet/less">
@import './couponCollectionDetails.less';
</style>