391 lines
11 KiB
Vue
391 lines
11 KiB
Vue
<template>
|
|
<div class="memberExchange">
|
|
<Header title="会员兑换" />
|
|
<div class="main overflow-y-auto" v-if="!state.loading">
|
|
<div class="currentIntegralBox flex-center-center">
|
|
<div class="title">当前积分</div>
|
|
<div class="number">{{ state.userWallet.integral || 0 }}</div>
|
|
</div>
|
|
<div class="integralCardArea overflow-x-auto" @touchstart.stop @touchmove.stop @touchend.stop>
|
|
<div class="integralCardBox" v-for="item in state.integralListVip" :key="item.id">
|
|
<div class="integralCard">
|
|
<div class="vipIcon"></div>
|
|
<div class="integralDesc">{{ item.price }}积分</div>
|
|
<div class="integralTitle">{{ item.name }}</div>
|
|
</div>
|
|
<div class="exchangeBtn flex-center-center" @click="exchange(item)">兑换</div>
|
|
</div>
|
|
</div>
|
|
<div class="integralList">
|
|
<div class="itemlist" v-for="item in state.integralList" :key="item.id">
|
|
<div class="top">
|
|
<!-- <p>{{ item.name }}</p>
|
|
<span>{{ item.desc }}</span> -->
|
|
<LazyImg :src="item.img" class="itemlistimg" :key="item.img" />
|
|
</div>
|
|
<div class="bot flex-center-between">
|
|
花费{{ item.price }}积分
|
|
<div class="btn flex-center-center" @click="exchange(item)">立即兑换</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<Empty v-if="state.integralList.length == 0" />
|
|
<!-- <div class="exchangeRecordMain">
|
|
<div class="titleBox">兑换记录</div>
|
|
<div class="exchangeRecordBox overflow-y-auto">
|
|
<div class="exchangeRecord flex-center-between" v-for="item in state.integralRecordList" :key="item.id">
|
|
<div class="exchangeInfo">
|
|
{{ item.desc }}
|
|
</div>
|
|
<div class="exchangeTime">{{ dateFormat(item.createdAt) }}</div>
|
|
</div>
|
|
<div class="nodata" v-if="!state.integralRecordList.length">您还没有兑换过会员喔~</div>
|
|
</div>
|
|
</div> -->
|
|
<div class="recordTitle">兑换记录</div>
|
|
<div class="record">
|
|
<div class="th">
|
|
<div class="left">兑换方式</div>
|
|
<div class="center">兑换类型</div>
|
|
<div class="right">兑换时间</div>
|
|
</div>
|
|
<div v-if="state.integralRecordList.length">
|
|
<div class="td" v-for="(item, index) in state.integralRecordList" :key="index">
|
|
<div class="left">{{ item.name }}</div>
|
|
<div class="center">{{ item.desc }}</div>
|
|
<div class="right">{{ moment(item.createdAt).format('YYYY.MM.DD') }}</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="main" v-else>
|
|
<Loading />
|
|
</div>
|
|
</div>
|
|
</template>
|
|
<script lang="ts" setup>
|
|
import { reactive } from 'vue';
|
|
import { useUserStore } from '@/stores/user';
|
|
import { showToast } from 'vant';
|
|
import MineApi from '@/service/mine';
|
|
import UserApi from '@/service/user';
|
|
import HomeApi from '@/service/home';
|
|
import moment from 'moment';
|
|
|
|
const userStore = useUserStore();
|
|
const state = reactive({
|
|
integralListVip: <Array<Types.Recharge.IntegralList>>[], // 积分列表
|
|
integralList: <Array<Types.Recharge.IntegralList>>[], // 积分列表
|
|
loading: true,
|
|
userWallet: <Types.User.WalletInfo>{},
|
|
integralRecordList: <any>[],
|
|
});
|
|
// 查询会员卡列表
|
|
const getVipList = async () => {
|
|
const res: any = await MineApi.queryVipProduct();
|
|
const list = res.integralList || [];
|
|
state.loading = false;
|
|
state.integralListVip = list.filter((i: any) => i.type === 1) || [];
|
|
state.integralList = list;
|
|
};
|
|
// 查询积分兑换记录
|
|
const getIntegralRecordList = async () => {
|
|
try {
|
|
let req: any = await HomeApi.getIntegralRecord();
|
|
state.integralRecordList = req || [];
|
|
} catch (e) {
|
|
console.log(e);
|
|
}
|
|
};
|
|
const exchange = async (item: Types.Recharge.IntegralList) => {
|
|
if (item.price > state.userWallet.integral) return showToast('您当前积分不足');
|
|
try {
|
|
let req = {
|
|
id: item.id,
|
|
};
|
|
await UserApi.exchangeIntegral(req);
|
|
state.userWallet.integral -= item.price;
|
|
getIntegralRecordList();
|
|
showToast('兑换成功');
|
|
} catch (e) {
|
|
console.log(e);
|
|
}
|
|
};
|
|
const init = () => {
|
|
state.userWallet = userStore.walletInfo;
|
|
getVipList();
|
|
getIntegralRecordList();
|
|
};
|
|
init();
|
|
</script>
|
|
<style lang="scss" scoped>
|
|
.memberExchange {
|
|
height: 100%;
|
|
:deep(.header) {
|
|
background: transparent;
|
|
}
|
|
.main {
|
|
height: calc(100% - 44px);
|
|
padding: 24px 16px 60px;
|
|
.currentIntegralBox {
|
|
height: 101px;
|
|
width: 343px;
|
|
background: #ffffff0d;
|
|
border: 1px solid #f68804;
|
|
border-radius: 8px;
|
|
flex-direction: column;
|
|
// &::before {
|
|
// content: '';
|
|
// position: absolute;
|
|
// top: 10px;
|
|
// left: 0;
|
|
// width: 9px;
|
|
// height: 25px;
|
|
// background: rgba(219, 54, 31, 1);
|
|
// border-radius: 0 6px 6px 0;
|
|
// }
|
|
.title {
|
|
color: #fff;
|
|
font-size: 16px;
|
|
// text-align: left;
|
|
// position: absolute;
|
|
// left: 16px;
|
|
// top: 10px;
|
|
font-weight: 500;
|
|
margin-bottom: 15px;
|
|
}
|
|
.number {
|
|
color: #f68804;
|
|
font-size: 32px;
|
|
font-weight: 600;
|
|
// margin-top: 9px;
|
|
}
|
|
}
|
|
.integralCardArea {
|
|
margin: 20px 0;
|
|
display: flex;
|
|
.integralCardBox {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
flex-direction: column;
|
|
margin-left: 15px;
|
|
&:last-child {
|
|
// margin-right: 0;
|
|
}
|
|
.integralCard {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
flex-direction: column;
|
|
height: 120px;
|
|
width: 95px;
|
|
background: rgba(255, 255, 255, 0.1);
|
|
border-radius: 4px;
|
|
color: #421a11;
|
|
text-align: center;
|
|
.vipIcon {
|
|
height: 28px;
|
|
width: 28px;
|
|
background: url('@/assets/images/png/mine/vip1.png') no-repeat;
|
|
background-size: 100% 100%;
|
|
margin-top: 5px;
|
|
}
|
|
.integralTitle {
|
|
// color: rgba(153, 153, 153, 1);
|
|
background: rgba(255, 213, 168, 1);
|
|
border-radius: 2px;
|
|
font-size: 12px;
|
|
font-weight: 400;
|
|
margin-bottom: 10px;
|
|
height: 20px;
|
|
line-height: 20px;
|
|
min-width: 61px;
|
|
padding: 0 4px;
|
|
box-sizing: border-box;
|
|
color: rgba(105, 42, 31, 1);
|
|
}
|
|
.integralDesc {
|
|
// color: rgba(249, 193, 66, 1);
|
|
color: rgba(255, 255, 255, 0.9);
|
|
font-size: 16px;
|
|
font-weight: 400;
|
|
margin: 15px 0;
|
|
// padding: 3px 6px;
|
|
// border-radius: 2px;
|
|
// background-color: #f3e2d6;
|
|
}
|
|
}
|
|
.exchangeBtn {
|
|
height: 20px;
|
|
line-height: 20px;
|
|
width: 60px;
|
|
color: white;
|
|
background: #f68804;
|
|
border-radius: 2px;
|
|
margin-top: 8px;
|
|
font-size: 12px;
|
|
}
|
|
}
|
|
}
|
|
.integralList {
|
|
box-sizing: border-box;
|
|
display: grid;
|
|
grid-template-columns: 1fr 1fr;
|
|
grid-row-gap: 7px;
|
|
grid-column-gap: 9px;
|
|
.itemlist {
|
|
height: 134px;
|
|
background: #303030;
|
|
border-radius: 12px;
|
|
overflow: hidden;
|
|
padding: 10px;
|
|
box-sizing: border-box;
|
|
.top {
|
|
height: 76px;
|
|
padding: 15px 12px;
|
|
box-sizing: border-box;
|
|
position: relative;
|
|
p {
|
|
font-size: 16px;
|
|
margin-bottom: 5px;
|
|
position: relative;
|
|
z-index: 10;
|
|
color: #fff;
|
|
}
|
|
span {
|
|
font-size: 10px;
|
|
color: #cccccc;
|
|
position: relative;
|
|
z-index: 10;
|
|
}
|
|
.itemlistimg {
|
|
position: absolute;
|
|
width: 100%;
|
|
height: 100%;
|
|
top: 0;
|
|
left: 0;
|
|
:deep(.animationImg) {
|
|
height: auto;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
.bot {
|
|
height: 36px;
|
|
box-sizing: border-box;
|
|
font-size: 12px;
|
|
margin-top: 4px;
|
|
color: #989898;
|
|
.btn {
|
|
font-size: 10px;
|
|
width: 56px;
|
|
height: 24px;
|
|
line-height: 24px;
|
|
background: #f68804;
|
|
color: #000;
|
|
border-radius: 20px;
|
|
}
|
|
}
|
|
}
|
|
.exchangeRecordMain {
|
|
height: 253px;
|
|
// width: 311px;
|
|
// background: rgba(255, 200.76, 170.24, 0.28);
|
|
// border-radius: 6px;
|
|
// border: 1px #ffc9aa solid;
|
|
margin-top: 32px;
|
|
padding: 0 22px 0 16px;
|
|
.titleBox {
|
|
// 兑换记录
|
|
color: rgba(255, 255, 255, 1);
|
|
font-size: 18px;
|
|
border-radius: 2px;
|
|
}
|
|
.exchangeRecordBox {
|
|
height: 220px;
|
|
.exchangeRecord {
|
|
border-bottom: 0.5px rgba(139, 50, 0, 0.3) solid;
|
|
padding: 10px 0;
|
|
.exchangeInfo {
|
|
color: $themeColor;
|
|
font-size: 13px;
|
|
}
|
|
.exchangeTime {
|
|
font-size: 12px;
|
|
color: #999999;
|
|
}
|
|
}
|
|
.nodata {
|
|
color: #8b3200;
|
|
font-size: 13px;
|
|
margin-top: 100px;
|
|
text-align: center;
|
|
}
|
|
}
|
|
}
|
|
.recordTitle {
|
|
font-size: 18px;
|
|
color: #fff;
|
|
margin: 10px 0;
|
|
font-weight: 600;
|
|
margin-top: 30px;
|
|
}
|
|
.record {
|
|
// margin-top: 40px;
|
|
// padding: 0 10px;
|
|
.th {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
// background: #f5f5f5;
|
|
font-size: 14px;
|
|
width: 100%;
|
|
height: 42px;
|
|
gap: 4px;
|
|
& > div {
|
|
height: 100%;
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
background: rgba(255, 255, 255, 0.05);
|
|
flex: 1;
|
|
color: #fff;
|
|
font-weight: 400;
|
|
}
|
|
// .left {
|
|
// width: 28%;
|
|
// }
|
|
// .center {
|
|
// width: 34%;
|
|
// }
|
|
// .right {
|
|
// width: 38%;
|
|
// }
|
|
}
|
|
.td {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
font-size: 12px;
|
|
width: 100%;
|
|
height: 42px;
|
|
color: rgba(153, 153, 153, 1);
|
|
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
|
|
& > div {
|
|
width: 33.33%;
|
|
height: 100%;
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
border-bottom: solid 1px rgba(0, 0, 0, 0.05);
|
|
&:first-child {
|
|
color: #fff;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</style>
|