Files
frontend-app/pages/rwa_package/shop/points-shop.vue
T
2026-07-27 14:45:25 +08:00

300 lines
7.4 KiB
Vue

<template>
<view class="content-two">
<view class="top-header-container">
<TopSafe></TopSafe>
<Header :isBack="false" height="88rpx">
<template v-slot:left>
<view class="header-left-content">
<u-icon size="36rpx" name="arrow-left" color="#000" @click="goback"></u-icon>
<up-image src="https://static.tbmall.xin/static/mine-purse/vcoin.png" width="36rpx"
height="36rpx" bgColor="#f1f6ff00" class="purse_amount"></up-image>
<text class="header-text">数字积分兑换专区: {{ balanceData.curAmount || 0 }}</text>
</view>
</template>
</Header>
<scroll-view scroll-x class="swiper-view">
<view :class="['swiper-item', { 'active': currentItem === item.key }]"
v-for="(item, index) in swiperList" :key="index" @click="onClickItem(item)">
<view class="swiper-item-content">{{ item.label }}</view>
</view>
</scroll-view>
</view>
<mescroll-uni ref="mescrollRef" :top="mescrollTop" @down="downCallback" @up="upCallback" :up="upOption"
:down="downOption" @init="mescrollInit">
<view class="setting-view">
<view class="name-box">
<view class="mescrollUniView">
<view class="fall-col">
<ParityProductItem v-for="(item, i) in leftList" :key="item.id" :obj="item" @ok="onJumpShop"
style="margin-top: 24rpx" />
</view>
<view class="fall-col">
<ParityProductItem v-for="(item, i) in rightList" :key="item.id" :obj="item"
@ok="onJumpShop" style="margin-top: 24rpx" />
</view>
</view>
</view>
</view>
</mescroll-uni>
<up-toast ref="uToastRef"></up-toast>
</view>
</template>
<script>
import Header from '@/components/common/header.vue';
import TopSafe from '@/components/common/top-safe.nvue';
import MyBtn from '@/components/common/my-btn.vue';
import { searchList } from '@/api/product.js';
import { getAcctBalance } from "@/api/finance.js";
import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
import MescrollUni from "@/components/mescroll-uni/mescroll-uni.vue";
import ParityProductItem from "@/components/shop/parity-product-item.vue";
export default {
mixins: [MescrollMixin],
components: { Header, TopSafe, MyBtn, ParityProductItem, MescrollUni, },
computed: {
mescrollTop() {
// #ifdef MP-WEIXIN
const statusBarHeight = uni.getSystemInfoSync().statusBarHeight || 0;
return (statusBarHeight * 2 + 168) + 'rpx';
// #endif
// #ifdef H5
return '168rpx';
// #endif
// #ifdef APP-PLUS
const statusBarHeight = uni.getSystemInfoSync().statusBarHeight || 0;
return (statusBarHeight * 2 + 168) + 'rpx';
// #endif
},
},
data() {
return {
dataList: [],
swiperList: [
{ key: 0, label: '全部', minDeduction: 0, maxDeduction: 999999 },
{ key: 1, label: '<300积分', minDeduction: 0, maxDeduction: 299.99 },
{ key: 2, label: '300-500积分', minDeduction: 300, maxDeduction: 499.99 },
{ key: 3, label: '500-1000积分', minDeduction: 500, maxDeduction: 999.99 },
{ key: 4, label: '>1000积分', minDeduction: 1000, maxDeduction: 999999 },
],
currentItem: 0,
downOption: {
auto: false,
textColor: "#333",
bgColor: "rgba(0,0,0,0)",
},
upOption: {
auto: true,
page: {
num: 0,
size: 10,
},
noMoreSize: 10,
empty: {
tip: `空空如也`,
},
textColor: "#333",
bgColor: "rgba(0,0,0,0)",
},
leftList: [],
rightList: [],
mescroll: null,
balanceData: {},
};
},
onLoad() {
this.init();
},
methods: {
init() {
this.getAcctBalance();
},
async getAcctBalance() {
const resp = await getAcctBalance();
let data = [];
if (resp && resp.bizcode === 100) {
data = resp.data || [];
}
this.balanceData = data.filter(item => item.categoty === 'vcoin')[0] || {};
},
onClickItem(item) {
if (this.currentItem === item.key) return;
this.currentItem = item.key;
this.dataList = [];
this.leftList = [];
this.rightList = [];
this.mescroll && this.mescroll.scrollTo(0, 0);
this.downCallback();
},
mescrollInit(mescroll) {
this.mescroll = mescroll;
},
upCallback(page) {
let currentSwiperItem = this.swiperList.find(item => item.key === this.currentItem) || {};
let params = {
type: -1,
page: page.num,
pageSize: page.size,
minDeduction: currentSwiperItem.minDeduction || 0,
maxDeduction: currentSwiperItem.maxDeduction || 999999,
};
searchList(params).then((res) => {
let curPageLen = res.data ? res.data.length : 0;
let totalCount = (res.data && res.data.total !== undefined)
? res.data.total
: ((res.data && res.data.totalCount !== undefined)
? res.data.totalCount
: (res.total !== undefined ? res.total : (res.totalCount !== undefined ? res.totalCount : 0)));
if (page.num === 1) this.dataList = [];
if (res.data) {
this.dataList = this.dataList.concat(res.data);
}
this.waterfall();
this.mescroll.endBySize(curPageLen, totalCount);
}).catch(() => {
this.mescroll && this.mescroll.endErr();
});
},
downCallback() {
this.mescroll && this.mescroll.resetUpScroll();
},
waterfall() {
this.leftList = this.dataList
.map((item, index) => {
if (index % 2 == 0) return item;
return null;
})
.filter(Boolean);
this.rightList = this.dataList
.map((item, index) => {
if (index % 2 != 0) return item;
return null;
})
.filter(Boolean);
},
onJumpShop(id) {
uni.navigateTo({
url: '/pages/other_package/productInfo/productInfo?id=' + id + '&isPar=true&curAmount=' + (this.balanceData.curAmount || 0),
})
},
onShare() {
uni.navigateTo({
url: '/pages/other_package/invite_friends/invite_friends',
})
},
goback() {
uni.navigateBack()
}
}
}
</script>
<style lang="scss" scoped>
.content-two {
min-height: 100vh;
background-color: #fff;
}
.top-header-container {
position: fixed;
top: 0;
left: 0;
width: 100%;
z-index: 99;
background-color: #fff;
}
.header-left-content {
display: flex;
flex-direction: row;
align-items: center;
}
.header-text {
font-size: 28rpx;
color: #333;
margin-left: 18rpx;
}
.purse_amount {
width: 38rpx;
height: 38rpx;
display: flex;
align-items: center;
justify-content: center;
vertical-align: middle;
margin-left: 20rpx;
}
.swiper-view {
width: 100%;
height: 80rpx;
background: #FFFFFF;
white-space: nowrap;
padding: 0 16rpx;
box-sizing: border-box;
.swiper-item {
padding: 0 16rpx;
height: 100%;
color: #666;
display: inline-flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
box-sizing: border-box;
font-size: 28rpx;
border-bottom: 4rpx solid transparent;
.swiper-item-content {
font-size: 28rpx;
line-height: 40rpx;
}
&.active {
color: #7A35F6;
font-weight: bold;
border-bottom-color: #7A35F6;
}
}
}
.setting-view {
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
padding: 0 32rpx 40rpx;
box-sizing: border-box;
.name-box {
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
.mescrollUniView {
width: calc(100vw - 48rpx);
display: flex;
flex-wrap: wrap;
justify-content: space-between;
.fall-col {
width: 332rpx;
height: 100%;
}
}
}
}
</style>