123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- <template>
- <view class="container">
- <view class="tabs">
- <view :class="['tab', tabActive == 1 ? 'active' : '']" @click="tabClick(1)">可使用</view>
- <view :class="['tab', tabActive == 2 ? 'active' : '']" style="margin-left: 10px" @click="tabClick(2)">
- 已使用
- </view>
- <view :class="['tab', tabActive == 3 ? 'active' : '']" style="margin-left: 10px" @click="tabClick(3)">
- 已过期
- </view>
- </view>
- <view :class="['card', item.status != 0 ? 'grey' : '']" v-for="(item, index) in list">
- <view class="leftIcon"></view>
- <view class="left">
- ¥
- <span style="font-size: 18px">{{ item.discount }}</span>
- </view>
- <view class="right">
- <view class="row title">
- {{ item.name }}
- </view>
- <view class="row endTime">{{ item.endTime }}到期</view>
- <view class="row desc">
- {{ item.desc }}
- </view>
- </view>
- </view>
- <noData v-if="list.length == 0" />
- </view>
- </template>
- <script>
- import noData from '@/component/noData.vue'
- import { couponListApi } from '@/api/coupon.js'
- export default {
- components: {
- noData,
- },
- onLoad() {
- this.$nextTick(() => {
- this.getList()
- })
- },
- data() {
- return {
- tabActive: 1,
- list: [],
- params: {
- limit: 999,
- page: 1,
- status: 0,
- },
- }
- },
- methods: {
- tabClick(index) {
- this.tabActive = index
- if (index == 1) {
- this.params.status = 0
- } else if (index == 2) {
- this.params.status = 1
- } else {
- this.params.status = 2
- }
- this.getList()
- },
- getList() {
- // wx.showLoading()
- couponListApi(this.params).then(res => {
- console.log(res, '我的优惠券')
- this.list = res.data.list
- // wx.hideLoading()
- })
- },
- },
- }
- </script>
- <style scoped lang="scss">
- .tabs {
- display: flex;
- margin-bottom: 10px;
- .tab {
- width: 68px;
- height: 24px;
- font-size: 14px;
- background: #fff;
- border-radius: 4px;
- line-height: 24px;
- text-align: center;
- }
- .active {
- background: #fea200;
- color: #fff;
- }
- }
- .container {
- background: #eaeaea;
- padding: 10px;
- .card {
- background: #fff;
- border-radius: 8px;
- overflow: hidden;
- display: flex;
- margin-bottom: 10px;
- .leftIcon {
- height: auto;
- width: 8px;
- background: #ff2c43;
- }
- .left {
- width: 80px;
- display: inline-flex;
- justify-content: center;
- align-items: center;
- color: #ff2c43;
- font-weight: 600;
- }
- .right {
- padding: 10px;
- .row {
- margin-bottom: 4px;
- font-size: 12px;
- }
- .title {
- font-size: 14px;
- font-weight: 600;
- }
- .endTime {
- color: #ff2c43;
- }
- .desc {
- margin-top: 5px;
- color: #8c8c8c;
- }
- }
- }
- }
- </style>
|