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.

198 lines
5.8 KiB

2 years ago
<template>
<HeaderNav title="优惠在这" :is-back="true"></HeaderNav>
<view class="app-wallpaper" :style="{
backgroundImage:'url('+staticImage.wallpaperBgImage+')'
}">
<view class="capsule-container row" v-if="type === 'lists'">
<view class="capsule col-6" :class="{active:item.value === couponType}" @click="couponTypeToggle(item)" v-for="item in types">
{{ item.title }}
2 years ago
</view>
</view>
<view class="coupons-list">
<view v-for="item in couponsList" class="coupons-item-container" :style="{
1 year ago
backgroundImage:'url('+(item.status > 0?staticImage.couponsGrayBackground:staticImage.couponsBackground)+')'
2 years ago
}">
<view class="coupons-item row">
<view class="coupons-left ">
<view class="coupons-big-title-group row">
<view class="coupons-big-title">{{item.price}}</view>
<view class="coupons-big-desc"></view>
</view>
<view class="coupons-cause">
{{item.cause}}
</view>
</view>
<view class="coupons-right col row">
<view class=" ">
<view class="coupons-title col-12">{{item.title}}</view>
<view class="coupons-desc col-12">{{item.time}}</view>
</view>
1 year ago
<view class="coupons-gq " v-show="item.status === 2">
2 years ago
<image class="img" :src="staticImage.couponsGQ" mode="aspectFill" />
</view>
1 year ago
<view class="coupons-gq " v-show="item.status === 1">
<image class="img" :src="staticImage.couponsUse" mode="aspectFill" />
</view>
2 years ago
<view class="coupons-bottom col-12 row">
<view class="coupons-rule row col">查看使用规则 <u-icon class="arrow-right" size="24rpx" color="#999999" name="arrow-right"></u-icon></view>
<view class="coupons-button">
<MzButton
title="立即使用"
@click="clickCoupons(item)"
button-width="145rpx"
1 year ago
:button-color="item.status > 0 ?'#CACACA':'#4DC3B8'"
font-color="#fff"
font-size="26rpx"
:is-background="false"
padding-tb="2rpx"
:btn-style="{
1 year ago
boxShadow:(item.status > 0?'2rpx -5rpx 0rpx 0rpx rgba(199,199,199,0.35)':'2rpx -5rpx 0rpx 0rpx rgba(77,195,184,0.35)')
}"></MzButton>
2 years ago
</view>
</view>
</view>
</view>
</view>
</view>
<u-loadmore :status="status" fontSize="28"
color="#ACB4B6"
line
line-color="#ACB4B6"
marginBottom="30" marginTop="30" @loadmore="getCouponsList(++this.page)"/>
2 years ago
</view>
<!-- <RightNav></RightNav> -->
</template>
<script>
import {
imghost
} from '@/config/host.js'
import HeaderNav from '@/components/HeaderNav/Index.vue';
import FooterNav from '@/components/FooterNav/Index.vue';
import RightNav from '@/components/RightNav/Index.vue';
import MzButton from '@/components/MzButton/Index.vue';
import {userCoupons} from "../../api/user";
2 years ago
export default {
components: {
HeaderNav,
FooterNav,
RightNav,
MzButton
},
data() {
return {
title: 'Hello',
loading: true,
staticImage: {
screenActiveImg: imghost + '/static/image/order-screen-active.png',
orderCardBackground: imghost + '/static/image/order-card-background.png',
wallpaperBgImage: imghost + '/static/image/background.png',
couponsBackground: imghost + '/static/image/coupons-bg.png',
couponsGrayBackground: imghost + '/static/image/coupons-gray-bg.png',
couponsGQ: imghost + '/static/image/coupons-gq.png',
couponsUse: imghost + '/static/image/coupons-use.png',
2 years ago
},
indexBanner: [{
image: imghost + '/static/image/banner.png',
url: '',
}],
user: {
avatar: imghost + '/static/image/banner.png',
nickname: '清晨的风',
coupons: 221,
id: 88685
},
isTop: false,
pagePadding: 100,
petImage: imghost + '/static/image/pet_avatar1.jpeg',
couponsList: [ ],
type:'lists',
couponType:2,
types:[
{title:'省点银子', value: 2},
{title:'豪门大户卡', value: 1},
],
page:1,
status:'loadmore',
2 years ago
}
},
onLoad(option) {
this.type = option.type||'lists'
console.log(this.type)
2 years ago
},
methods: {
clickCoupons(item){
1 year ago
if(item.status === 0){
console.log('coupons', item)
uni.setStorageSync('userCoupons',item);
uni.navigateBack();
}
},
navTo(url){
uni.navigateTo({
url:url
})
},
getCouponsList(page = 1){
if (this.status === 'nomore'){
return;
}else{
this.status = 'loading';
}
userCoupons({
page:page,
limit:10,
is_buy:this.couponType
}).then((res) => {
let couponsList = res.data.map((row) => {
return {
id:row.id,
price:parseFloat(row.deduction),
title:row.title,
time: '有效期至 '+row.end_time,
cause:'满'+parseFloat(row.min_price)+'使用',
1 year ago
status: row.status,
}
});
this.status = couponsList.length < 10 ? 'nomore' : 'loadmore';
if (page === 1) {
this.couponsList = couponsList;
return;
}
this.couponsList.push(...couponsList);
})
},
couponTypeToggle(item){
this.couponType = item.value;
this.page = 1;
this.status = 'loadmore';
this.getCouponsList();
}
2 years ago
},
onPageScroll(res) {
if (res.scrollTop <= 20) {
uni.$emit('isTop', true);
} else {
uni.$emit('isTop', false);
}
},
onReachBottom() {
this.getCouponsList(++this.page);
},
2 years ago
created() {
// this.pagePadding = (api.navHeight().navPaddingTop +
// api.navHeight().navHeight + (api.navHeight().headerPadding * 2))
},
mounted() {
this.getCouponsList();
}
}
2 years ago
</script>
<style lang="scss">
@import './components/index.scss';
2 years ago
</style>