You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
231 lines
6.1 KiB
231 lines
6.1 KiB
<template>
|
|
<view id="coupon-over">
|
|
|
|
<view class="no-list" v-if="(!list.length || !list[0].length) && init">
|
|
<i class="iconfont icon-youhuiquan"></i>
|
|
<view>报告主人,您暂无优惠券~</view>
|
|
</view>
|
|
|
|
<view v-for="(items, idx) in list" :key="idx">
|
|
<view class="coupon" v-for="(item, index) in list[idx]" :key="index">
|
|
<view class="coupon-left">
|
|
<view class="text-wrap">
|
|
<view class="text-box">
|
|
<view class="text">
|
|
<text class="money" v-if="item.discount.action_type.type == 'cash'">¥</text>
|
|
<sapn>{{ item.discount.action_type.value }}</sapn>
|
|
|
|
<text class="money" v-if="item.discount.action_type.type == 'discount'">折</text>
|
|
</view>
|
|
<text class="label text">{{ item.discount.label }}</text>
|
|
</view>
|
|
|
|
</view>
|
|
<view class="dot-wrap">
|
|
<view class="dot-item">
|
|
|
|
</view>
|
|
<view class="dot-item">
|
|
|
|
</view>
|
|
<view class="dot-item">
|
|
|
|
</view>
|
|
<view class="dot-item">
|
|
|
|
</view>
|
|
<view class="dot-item">
|
|
|
|
</view>
|
|
<view class="dot-item">
|
|
|
|
</view>
|
|
</view>
|
|
</view>
|
|
<view class="coupon-right">
|
|
<view class="top">
|
|
<span class="type">
|
|
<span v-if="item.discount.channel == 'ec'">商城</span>
|
|
<span v-else>门店</span>
|
|
</span>
|
|
<text class="info">{{item.discount.title}}</text>
|
|
</view>
|
|
<view class="bottom">
|
|
<view class="bottom-use">
|
|
<view class="tiem-box">
|
|
<text>{{item.discount.use_start_time}}至{{item.discount.use_end_time}}</text>
|
|
</view>
|
|
<view v-if="is_coupon == 1">
|
|
<!-- <view class="btn use" data-code="{{item.discount.code}}" data-index="{{idx}}" data-findex="{{index}}" wx:if="{{!item.discount.has_get}}" @tap.stop="getCoupon">
|
|
点击领取
|
|
</view>
|
|
<view class="btn already" data-id="{{item.id}}" @tap.stop="jumpList">
|
|
去使用
|
|
</view> -->
|
|
</view>
|
|
|
|
|
|
</view>
|
|
</view>
|
|
</view>
|
|
<view class="cover">
|
|
<view class="big-circle">
|
|
<view class="small-circle">
|
|
<view :animation="animationData" v-if="item.used_at">已使用</view>
|
|
<view :animation="animationData" v-else>已过期</view>
|
|
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
|
|
|
|
</template>
|
|
<script>
|
|
import {pageLogin, getUrl,config} from '@/common/js/utils.js';
|
|
|
|
export default {
|
|
data() {
|
|
return {
|
|
page: 1,
|
|
list: [],
|
|
meta: '',
|
|
show: false,
|
|
init: false,
|
|
animationDate: {}
|
|
};
|
|
},
|
|
|
|
onReachBottom() {
|
|
var hasMore = this.meta.pagination.total_pages > this.meta.pagination.current_page;
|
|
|
|
if (hasMore) {
|
|
var page = this.meta.pagination.current_page + 1;
|
|
this.setData({
|
|
show: true
|
|
});
|
|
this.queryCouponList(0, page);
|
|
} else {
|
|
wx.showToast({
|
|
image: '../../../static/error.png',
|
|
title: '再拉也没有啦'
|
|
});
|
|
}
|
|
},
|
|
|
|
onShow() {
|
|
var animation = wx.createAnimation({
|
|
duration: 1000,
|
|
timingFunction: 'ease'
|
|
});
|
|
this.animation = animation;
|
|
animation.rotate(-30).step();
|
|
|
|
// this.setData({
|
|
// animationData: animation.export()
|
|
// });
|
|
|
|
this.animationDate=animation.export();
|
|
|
|
},
|
|
|
|
onLoad() {
|
|
this.queryCouponList(0);
|
|
},
|
|
|
|
components: {},
|
|
props: {},
|
|
methods: {
|
|
jumpOff() {
|
|
wx.navigateTo({
|
|
url: '/pages/coupon/over/over'
|
|
});
|
|
},
|
|
|
|
// 查询优惠券列表
|
|
queryCouponList(status, page = 1) {
|
|
var token = this.$cookieStorage.get('user_token');
|
|
wx.showLoading({
|
|
title: "加载中",
|
|
mask: true
|
|
});
|
|
this.$http.get({
|
|
api: 'api/coupon',
|
|
header: {
|
|
Authorization: token
|
|
},
|
|
data: {
|
|
is_active: status,
|
|
page
|
|
}
|
|
}).then(res => {
|
|
if (res.statusCode == 200) {
|
|
res = res.data;
|
|
|
|
if (res.status) {
|
|
// this.setData({
|
|
// [`list[${page - 1}]`]: res.data,
|
|
// meta: res.meta
|
|
// });
|
|
|
|
this.$set(this.list, page -1, res.data);
|
|
this.meta=res.meta;
|
|
|
|
} else {
|
|
wx.showModal({
|
|
content: res.message,
|
|
showCancel: false
|
|
});
|
|
}
|
|
} else {
|
|
wx.showModal({
|
|
content: "请求失败",
|
|
showCancel: false
|
|
});
|
|
}
|
|
|
|
this.setData({
|
|
show: false,
|
|
init: true
|
|
});
|
|
wx.hideLoading();
|
|
}).catch(rej => {
|
|
wx.hideLoading();
|
|
this.setData({
|
|
show: false,
|
|
init: true
|
|
});
|
|
});
|
|
},
|
|
|
|
setData: function (obj) {
|
|
let that = this;
|
|
let keys = [];
|
|
let val, data;
|
|
Object.keys(obj).forEach(function (key) {
|
|
keys = key.split('.');
|
|
val = obj[key];
|
|
data = that.$data;
|
|
keys.forEach(function (key2, index) {
|
|
if (index + 1 == keys.length) {
|
|
that.$set(data, key2, val);
|
|
} else {
|
|
if (!data[key2]) {
|
|
that.$set(data, key2, {});
|
|
}
|
|
}
|
|
|
|
data = data[key2];
|
|
});
|
|
});
|
|
}
|
|
},
|
|
computed: {},
|
|
watch: {}
|
|
};
|
|
</script>
|
|
<style rel="stylesheet/less" lang="less">
|
|
@import "over";
|
|
</style>
|