144 行
3.9 KiB
Vue
144 行
3.9 KiB
Vue
<template>
|
||
<s-layout title="兑换商城">
|
||
<!-- 资产看板:当前积分与可用兑换券 -->
|
||
<view class="asset-banner ss-m-20 ss-p-20">
|
||
<view class="ss-flex ss-row-between ss-col-center">
|
||
<view class="asset-item">
|
||
<view class="asset-label">当前积分</view>
|
||
<view class="asset-val">{{ userInfo.score || 0 }}</view>
|
||
</view>
|
||
<view class="asset-line"></view>
|
||
<view class="asset-item">
|
||
<view class="asset-label">可用兑换券</view>
|
||
<view class="asset-val text-red">¥ {{ userVoucherAvailable }}</view>
|
||
</view>
|
||
<button class="ss-reset-button earn-btn" @tap="sheep.$router.go('/pages/commission/voucher')">
|
||
券明细
|
||
</button>
|
||
</view>
|
||
<view class="asset-tip ss-m-t-16">
|
||
💡 兑换商品时支持使用可用兑换券 1:1 全额抵扣现金
|
||
</view>
|
||
</view>
|
||
|
||
<view class="ss-p-x-20">
|
||
<view v-for="item in state.pagination.data" :key="item.id" class="ss-m-b-20">
|
||
<s-score-card
|
||
size="sl"
|
||
:data="item"
|
||
priceColor="#FF3000"
|
||
@tap="sheep.$router.go('/pages/goods/score', { id: item.id })"
|
||
></s-score-card>
|
||
</view>
|
||
</view>
|
||
<s-empty
|
||
v-if="state.pagination.total === 0"
|
||
icon="/static/goods-empty.png"
|
||
text="暂无兑换商品"
|
||
></s-empty>
|
||
<uni-load-more
|
||
v-if="state.pagination.total > 0"
|
||
:status="state.loadStatus"
|
||
:content-text="{
|
||
contentdown: '上拉加载更多',
|
||
}"
|
||
@tap="loadmore"
|
||
/>
|
||
</s-layout>
|
||
</template>
|
||
<script setup>
|
||
import sheep from '@/sheep';
|
||
import { onLoad, onReachBottom } from '@dcloudio/uni-app';
|
||
import { computed, reactive } from 'vue';
|
||
import _ from 'lodash';
|
||
|
||
const userInfo = computed(() => sheep.$store('user').userInfo || {});
|
||
const agentInfo = computed(() => sheep.$store('user').agentInfo || {});
|
||
const userVoucherAvailable = computed(() => {
|
||
return agentInfo.value?.voucher_available || userInfo.value?.voucher_available || '0.00';
|
||
});
|
||
|
||
const state = reactive({
|
||
pagination: {
|
||
data: [],
|
||
current_page: 1,
|
||
total: 1,
|
||
last_page: 1,
|
||
},
|
||
loadStatus: '',
|
||
});
|
||
async function getData(page = 1, list_rows = 5) {
|
||
state.loadStatus = 'loading';
|
||
let res = await sheep.$api.app.scoreShop.list({
|
||
list_rows,
|
||
page,
|
||
});
|
||
if (res.code === 1) {
|
||
let couponlist = _.concat(state.pagination.data, res.data.data);
|
||
state.pagination = {
|
||
...res.data,
|
||
data: couponlist,
|
||
};
|
||
if (state.pagination.current_page < state.pagination.last_page) {
|
||
state.loadStatus = 'more';
|
||
} else {
|
||
state.loadStatus = 'noMore';
|
||
}
|
||
}
|
||
}
|
||
// 加载更多
|
||
function loadmore() {
|
||
if (state.loadStatus !== 'noMore') {
|
||
getData(state.pagination.current_page + 1);
|
||
}
|
||
}
|
||
|
||
// 上拉加载更多
|
||
onReachBottom(() => {
|
||
loadmore();
|
||
});
|
||
onLoad(() => {
|
||
getData();
|
||
});
|
||
</script>
|
||
|
||
<style lang="scss" scoped>
|
||
.asset-banner {
|
||
background: linear-gradient(135deg, #2d3139 0%, #1f2228 100%);
|
||
border-radius: 16rpx;
|
||
color: #fff;
|
||
.asset-item {
|
||
.asset-label {
|
||
font-size: 24rpx;
|
||
color: #999;
|
||
margin-bottom: 8rpx;
|
||
}
|
||
.asset-val {
|
||
font-size: 34rpx;
|
||
font-weight: bold;
|
||
color: #f7d088;
|
||
&.text-red {
|
||
color: #ff5252;
|
||
}
|
||
}
|
||
}
|
||
.asset-line {
|
||
width: 1rpx;
|
||
height: 48rpx;
|
||
background: rgba(255, 255, 255, 0.15);
|
||
}
|
||
.earn-btn {
|
||
padding: 8rpx 20rpx;
|
||
font-size: 24rpx;
|
||
color: #fff;
|
||
background: rgba(255, 255, 255, 0.15);
|
||
border-radius: 24rpx;
|
||
border: 1rpx solid rgba(255, 255, 255, 0.2);
|
||
}
|
||
.asset-tip {
|
||
font-size: 22rpx;
|
||
color: #d1b172;
|
||
}
|
||
}
|
||
</style>
|