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.
yanzong_qianduan/pages/news/coupon/list.vue

246 lines
5.7 KiB

11 months ago
<template>
<view class="coupon">
<view class="coupon-tab">
11 months ago
<u-tabs :list="list" height="106" font-size="32" active-color="#F34A40" inactive-color="#686868"
:is-scroll="false" v-model="tabIndex" @change="change"></u-tabs>
</view>
<view class="coupon-bd">
9 months ago
<view class="item" :class="tabIndex == 2?'item-on':''" v-for="(item,index) in couponList" :key="index"
@click="choseItem(item)" :style="{'border':item.user_coupon_id==choseId?'2rpx solid red':none}">
11 months ago
<view class="a" v-if="item.coupon_type==10"><text>{{item.reduce_price}}</text></view>
<view class="a" v-if="item.coupon_type==20"><text>{{item.discount}}</text></view>
<view class="b">有效期{{item.end_time}}</view>
<view class="c">
<text v-if="item.apply_range==10">适用于全场商品</text>
<text v-if="item.apply_range==20">适用于部分商品</text>
</view>
<view class="d" v-if="tabIndex == 0" @click="goUse(item)">去使用</view>
9 months ago
<view class="e">{{item.min_price?Number(item.min_price):''}}元使用</view>
<view class="f" v-if="item.coupon_type==10">{{item.min_price?Number(item.min_price):''}}元减{{item.reduce_price?Number(item.reduce_price):''}}</view>
<view class="f" v-if="item.coupon_type==20">{{item.min_price?Number(item.min_price):''}}{{item.discount}}</view>
10 months ago
<image class="bg" v-if="tabIndex <= 1" :src="$picUrl+'/static/news/icon-coupon-01.png'"></image>
<image class="bg" v-else :src="$picUrl+'/static/news/icon-coupon-02.png'"></image>
<image class="icon" v-if="tabIndex == 1" :src="$picUrl+'/static/news/icon-coupon-use.png'"></image>
<image class="icon" v-if="tabIndex == 2" :src="$picUrl+'/static/news/icon-coupon-used.png'"></image>
<view class="line">
<u-line v-if="tabIndex <= 1" direction="col" border-style="dashed" color="#FFC7B9" />
<u-line v-if="tabIndex == 2" direction="col" border-style="dashed" color="#D9D9D9" />
</view>
</view>
</view>
11 months ago
<view class="nolist" v-if="couponList.length==0">
10 months ago
<image :src="$picUrl+'/static/news/icon-coupon-03.png'"></image>
<view class="txt">暂无已使用优惠券</view>
</view>
11 months ago
</view>
</template>
<script>
import * as CouponApi from '@/api/coupon'
export default {
data() {
return {
9 months ago
choseId: '',
11 months ago
list: [{
name: '未使用',
9 months ago
val: 'isUsable'
11 months ago
}, {
name: '已使用',
9 months ago
val: 'isUse'
11 months ago
}, {
name: '已过期',
9 months ago
val: 'isExpire'
}],
11 months ago
tabIndex: 0,
9 months ago
couponList: [],
isChose: false
11 months ago
}
},
9 months ago
onLoad(o) {
10 months ago
this.isChose = o.chose
},
11 months ago
onShow() {
this.getCoupon(this.tabIndex)
},
methods: {
9 months ago
choseItem(item) {
if (this.isChose) {
uni.setStorageSync('couponId', item.coupon_id)
10 months ago
uni.navigateBack()
}
},
11 months ago
getCoupon(e) {
const that = this
9 months ago
let param = {
dataType: that.list[e].val
11 months ago
}
CouponApi.myCouponList(param)
.then(res => {
that.couponList = res.data.list.data
})
.finally(() => that.isLoading = false)
},
change(e) {
9 months ago
this.couponList = []
11 months ago
this.getCoupon(e)
},
tabItem(index) {
this.tabIndex = index
11 months ago
},
9 months ago
goUse(item) {
11 months ago
// 使用优惠券
9 months ago
if (item.coupon_case == 10) {
11 months ago
// 调到商品列表
10 months ago
uni.switchTab({
url: "/pages/index/index"
11 months ago
})
}
},
}
}
11 months ago
</script>
<style lang="scss" scoped>
.coupon {
overflow: hidden;
11 months ago
.nolist {
width: 100%;
display: block;
margin: 0 auto;
text-align: center;
padding: 150rpx 50rpx;
image {
width: 388rpx;
height: 378rpx;
}
11 months ago
.txt {
font-size: 32rpx;
margin-top: 20rpx;
font-weight: 500;
11 months ago
color: #959595;
}
11 months ago
}
&-bd {
padding: 0 40rpx 40rpx;
overflow: hidden;
.item {
width: 662rpx;
9 months ago
height: 310rpx;
11 months ago
position: relative;
margin-top: 20rpx;
overflow: hidden;
.bg {
width: 100%;
height: 100%;
}
.icon {
width: 220rpx;
height: 195rpx;
position: absolute;
right: 0;
bottom: 0;
z-index: 1;
}
.a {
width: 235rpx;
position: absolute;
right: 0;
top: 40rpx;
z-index: 2;
font-size: 36rpx;
font-weight: 500;
text-align: center;
color: #FE6900;
text {
font-size: 68rpx;
}
}
.b {
position: absolute;
left: 40rpx;
top: 110rpx;
z-index: 2;
font-size: 28rpx;
font-weight: 500;
color: #AFAFAF;
}
.e {
position: absolute;
left: 40rpx;
top: 46rpx;
z-index: 2;
font-size: 36rpx;
font-weight: 500;
color: #454545;
}
.f {
position: absolute;
left: 40rpx;
top: 160rpx;
z-index: 2;
font-size: 28rpx;
font-family: PingFang SC, PingFang SC;
font-weight: 400;
color: #6C6C6C;
}
.c {
position: absolute;
left: 40rpx;
bottom: 20rpx;
z-index: 2;
font-size: 28rpx;
font-weight: 500;
color: #A7572C;
}
.d {
width: 188rpx;
line-height: 68rpx;
background: linear-gradient(180deg, #FF7366 0%, #FF5242 100%);
border-radius: 68rpx;
position: absolute;
right: 28rpx;
top: 140rpx;
z-index: 2;
font-size: 28rpx;
font-weight: 500;
color: #FFFFFF;
text-align: center;
}
.line {
position: absolute;
right: 230rpx;
height: 200rpx;
width: 2px;
z-index: 3;
top: 36rpx;
}
11 months ago
&-on {
.a {
color: #BBBBBB;
}
.c {
color: #BBBBBB;
}
}
}
}
}
9 months ago
</style>