修复bug,添加我的积分页面
This commit is contained in:
293
property-uniapp-project/pageSubPack/my/myPointsIndex.vue
Normal file
293
property-uniapp-project/pageSubPack/my/myPointsIndex.vue
Normal file
@@ -0,0 +1,293 @@
|
||||
<template>
|
||||
<view class="page">
|
||||
<view class="header-area">
|
||||
<view class="status-bar"></view>
|
||||
<uni-nav-bar title="我的积分" left-icon="left" @clickLeft="goBack" backgroundColor="transparent" :border="false"
|
||||
color="#ffffff" :iconStyle="{ color: '#ffffff' }">
|
||||
</uni-nav-bar>
|
||||
<view class="points-display">
|
||||
<text class="points-num">{{ totalPoints }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 三个功能入口 -->
|
||||
<view class="entry-card">
|
||||
<view class="entry-item" v-for="(item, index) in entryList" :key="index" @click="goPage(item)">
|
||||
<image :src="item.icon" class="entry-icon" mode="aspectFit" />
|
||||
<text class="entry-text">{{ item.title }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 虚拟兑换 -->
|
||||
<view class="virtual-exchange">
|
||||
<text class="virtual-title">虚拟兑换</text>
|
||||
</view>
|
||||
<view class="section-header">
|
||||
<view class="section-line"></view>
|
||||
<text class="section-title">热门虚拟权益服务</text>
|
||||
<view class="section-line"></view>
|
||||
</view>
|
||||
|
||||
<!-- 人气兑换商品区域 -->
|
||||
<view class="goods-card">
|
||||
<uni-section title="人气兑换" type="line"></uni-section>
|
||||
<view class="goods-grid">
|
||||
<view class="goods-item" v-for="(item, index) in goodsList" :key="index">
|
||||
<image :src="item.image" class="goods-img" mode="aspectFill" />
|
||||
<text class="goods-name">{{ item.name }}</text>
|
||||
<text class="goods-desc">{{ item.desc }}</text>
|
||||
<text class="goods-points">{{ item.points }}分</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="goods-more" @click="goMore">
|
||||
<text class="more-text">更多积分兑换</text>
|
||||
<text class="more-arrow">></text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { getPointsBalance } from '/pageSubPack/api/apiSub.js'
|
||||
|
||||
const totalPoints = ref(780)
|
||||
|
||||
const entryList = ref([{
|
||||
title: '积分商城',
|
||||
icon: 'https://wuye.ckdzkj.com/images/propertyImgs/pointsMall.png',
|
||||
url: '/pageSubPack/my/myPointsMall'
|
||||
}, {
|
||||
title: '积分明细',
|
||||
icon: 'https://wuye.ckdzkj.com/images/propertyImgs/pointsRecord.png',
|
||||
url: '/pageSubPack/my/myPointsRecord'
|
||||
}, {
|
||||
title: '积分订单',
|
||||
icon: 'https://wuye.ckdzkj.com/images/propertyImgs/pointsOrder.png',
|
||||
url: '/pageSubPack/my/myPointsOrder'
|
||||
}])
|
||||
|
||||
const goodsList = ref([
|
||||
{ id: 1, name: '植物精油', desc: '温和无刺激 下单即赠试用装', points: 6000, image: 'https://via.placeholder.com/200x200/4CAF50/FFF?text=植物' },
|
||||
{ id: 2, name: '肯德基香辣劲脆鸡腿堡电子', desc: '下单即赠试用装', points: 6000, image: 'https://via.placeholder.com/200x200/FF5722/FFF?text=KFC' },
|
||||
{ id: 3, name: '植物精油', desc: '温和无刺激 下单即赠试用装', points: 6000, image: 'https://via.placeholder.com/200x200/4CAF50/FFF?text=植物' },
|
||||
{ id: 4, name: '肯德基香辣劲脆鸡腿堡电子', desc: '下单即赠试用装', points: 4000, image: 'https://via.placeholder.com/200x200/FF5722/FFF?text=KFC' },
|
||||
{ id: 5, name: '植物精油', desc: '温和无刺激 下单即赠试用装', points: 6000, image: 'https://via.placeholder.com/200x200/4CAF50/FFF?text=植物' },
|
||||
{ id: 6, name: '肯德基香辣劲脆鸡腿堡电子', desc: '下单即赠试用装', points: 4000, image: 'https://via.placeholder.com/200x200/FF5722/FFF?text=KFC' }
|
||||
])
|
||||
|
||||
const getBalance = async () => {
|
||||
try {
|
||||
const res = await getPointsBalance()
|
||||
if (res.code === 200 && res.data) {
|
||||
totalPoints.value = res.data.balance || res.data.points || 0
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('获取积分余额失败:', err)
|
||||
}
|
||||
}
|
||||
|
||||
const goPage = (item) => {
|
||||
uni.navigateTo({
|
||||
url: item.url
|
||||
})
|
||||
}
|
||||
|
||||
const goBack = () => {
|
||||
uni.navigateBack({ delta: 1 })
|
||||
}
|
||||
|
||||
const goMore = () => {
|
||||
uni.navigateTo({
|
||||
url: '/pageSubPack/my/myPointsMall'
|
||||
})
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getBalance()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.page {
|
||||
background-color: #f5f5f5;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
/* ===== 顶部蓝色区域 ===== */
|
||||
.header-area {
|
||||
background: #2E59FD;
|
||||
padding-bottom: 40rpx;
|
||||
}
|
||||
|
||||
.status-bar {
|
||||
width: 100vw;
|
||||
height: 46px;
|
||||
}
|
||||
|
||||
.points-display {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
padding: 30rpx 0 20rpx;
|
||||
}
|
||||
|
||||
.points-num {
|
||||
font-size: 64rpx;
|
||||
font-weight: 700;
|
||||
color: #ffffff;
|
||||
line-height: 1.1;
|
||||
letter-spacing: 4rpx;
|
||||
}
|
||||
|
||||
/* ===== 三个功能入口 ===== */
|
||||
.entry-card {
|
||||
display: flex;
|
||||
justify-content: space-around;
|
||||
align-items: center;
|
||||
background: #ffffff;
|
||||
border-radius: 20rpx;
|
||||
margin: -30rpx 30rpx 0;
|
||||
padding: 36rpx 0;
|
||||
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.08);
|
||||
position: relative;
|
||||
z-index: 2;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.entry-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex: 1;
|
||||
|
||||
&:active {
|
||||
opacity: 0.7;
|
||||
}
|
||||
}
|
||||
|
||||
.entry-icon {
|
||||
width: 72rpx;
|
||||
height: 72rpx;
|
||||
margin-bottom: 16rpx;
|
||||
}
|
||||
|
||||
.entry-text {
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
/* ===== 虚拟兑换 ===== */
|
||||
.virtual-exchange {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
padding: 40rpx 0 30rpx;
|
||||
}
|
||||
|
||||
.virtual-title {
|
||||
font-size: 32rpx;
|
||||
color: #000000;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
/* ===== 热门虚拟权益服务(横线 + 文字 + 横线) ===== */
|
||||
.section-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 0 110rpx;
|
||||
margin-bottom: 30rpx;
|
||||
}
|
||||
|
||||
.section-line {
|
||||
flex: 1;
|
||||
height: 1rpx;
|
||||
background: #cccccc;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 28rpx;
|
||||
color: #999999;
|
||||
margin: 0 24rpx;
|
||||
white-space: nowrap;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
/* ===== 人气兑换商品卡片 ===== */
|
||||
.goods-card {
|
||||
background: #ffffff;
|
||||
border-radius: 32rpx;
|
||||
margin: 0 30rpx;
|
||||
padding: 20rpx 20rpx 30rpx;
|
||||
}
|
||||
|
||||
.goods-grid {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
margin: 0 -10rpx;
|
||||
}
|
||||
|
||||
.goods-item {
|
||||
width: calc(33.33% - 20rpx);
|
||||
margin: 0 10rpx 20rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.goods-img {
|
||||
width: 210rpx;
|
||||
height: 210rpx;
|
||||
border-radius: 16rpx;
|
||||
background: #f0f0f0;
|
||||
margin-bottom: 12rpx;
|
||||
}
|
||||
|
||||
.goods-name {
|
||||
font-size: 26rpx;
|
||||
color: #333;
|
||||
font-weight: 500;
|
||||
text-align: left;
|
||||
line-height: 1.3;
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.goods-desc {
|
||||
font-size: 22rpx;
|
||||
color: #999;
|
||||
text-align: left;
|
||||
line-height: 1.3;
|
||||
margin-top: 6rpx;
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.goods-points {
|
||||
font-size: 32rpx;
|
||||
font-weight: 600;
|
||||
color: #FF8F40;
|
||||
margin-top: 8rpx;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
/* ===== 更多积分兑换 ===== */
|
||||
.goods-more {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 30rpx 0 10rpx;
|
||||
border-top: 1rpx solid #eee;
|
||||
}
|
||||
|
||||
.more-text {
|
||||
font-size: 28rpx;
|
||||
color: #333333;
|
||||
}
|
||||
</style>
|
||||
232
property-uniapp-project/pageSubPack/my/myPointsMall.vue
Normal file
232
property-uniapp-project/pageSubPack/my/myPointsMall.vue
Normal file
@@ -0,0 +1,232 @@
|
||||
<template>
|
||||
<view class="contentStyle">
|
||||
<!-- <view class="status-bar"></view>
|
||||
<uni-nav-bar title="积分商城" left-icon="left" @clickLeft="goBack" backgroundColor="transparent" :border="false">
|
||||
</uni-nav-bar> -->
|
||||
|
||||
<pull-refresh-scroll
|
||||
custom-class="page"
|
||||
:refreshing="isRefreshing"
|
||||
:loading-more="loading"
|
||||
:no-more-data="noMoreData"
|
||||
:empty="list.length === 0"
|
||||
empty-text="暂无商品"
|
||||
@refresh="onRefresh"
|
||||
@loadMore="loadMore"
|
||||
>
|
||||
<view class="mall-list">
|
||||
<view class="mall-card" v-for="(item, index) in list" :key="index" @click="onProductClick(item)">
|
||||
<image :src="item.image || defaultImg" class="product-img" mode="aspectFill" />
|
||||
<view class="product-info">
|
||||
<text class="product-name">{{ item.name }}</text>
|
||||
<text class="product-desc">{{ item.description || '' }}</text>
|
||||
<view class="product-bottom">
|
||||
<view class="product-points">
|
||||
<text class="points-value">{{ item.points }}</text>
|
||||
<text class="points-unit">积分</text>
|
||||
</view>
|
||||
<view class="exchange-btn">立即兑换</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</pull-refresh-scroll>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { getPointsMallList, postPointsExchange } from '/pageSubPack/api/apiSub.js'
|
||||
import PullRefreshScroll from '/components/pull-refresh-scroll/pull-refresh-scroll.vue'
|
||||
|
||||
const defaultImg = 'https://wuyeadmin.bugtc.com/images/propertyImgs/points.png'
|
||||
|
||||
const list = ref([])
|
||||
const pageNum = ref(1)
|
||||
const pageSize = ref(10)
|
||||
const noMoreData = ref(false)
|
||||
const loading = ref(false)
|
||||
const isRefreshing = ref(false)
|
||||
|
||||
const getList = async () => {
|
||||
if (loading.value) return
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await getPointsMallList({
|
||||
pageNum: pageNum.value,
|
||||
pageSize: pageSize.value
|
||||
})
|
||||
const newList = res.rows || res.data || []
|
||||
if (pageNum.value === 1) {
|
||||
list.value = newList
|
||||
} else {
|
||||
list.value = [...list.value, ...newList]
|
||||
}
|
||||
if (newList.length < pageSize.value) {
|
||||
noMoreData.value = true
|
||||
}
|
||||
} catch (err) {
|
||||
uni.showToast({ title: '加载失败', icon: 'none' })
|
||||
console.error('积分商城接口报错:', err)
|
||||
} finally {
|
||||
loading.value = false
|
||||
if (isRefreshing.value) isRefreshing.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const onRefresh = () => {
|
||||
isRefreshing.value = true
|
||||
pageNum.value = 1
|
||||
noMoreData.value = false
|
||||
loading.value = false
|
||||
getList()
|
||||
}
|
||||
|
||||
const loadMore = () => {
|
||||
if (loading.value || noMoreData.value) return
|
||||
pageNum.value++
|
||||
getList()
|
||||
}
|
||||
|
||||
const onProductClick = (item) => {
|
||||
uni.showModal({
|
||||
title: '确认兑换',
|
||||
content: `确定使用 ${item.points} 积分兑换「${item.name}」吗?`,
|
||||
success: async (modalRes) => {
|
||||
if (!modalRes.confirm) return
|
||||
try {
|
||||
uni.showLoading({ title: '兑换中...', mask: true })
|
||||
const res = await postPointsExchange({ productId: item.id || item.productId })
|
||||
uni.hideLoading()
|
||||
if (res.code === 200) {
|
||||
uni.showToast({ title: '兑换成功', icon: 'success' })
|
||||
} else {
|
||||
uni.showToast({ title: res.msg || '兑换失败', icon: 'none' })
|
||||
}
|
||||
} catch (err) {
|
||||
uni.hideLoading()
|
||||
uni.showToast({ title: err.msg || '兑换失败', icon: 'none' })
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const goBack = () => {
|
||||
uni.navigateBack({ delta: 1 })
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getList()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
page {
|
||||
background: linear-gradient(to left bottom, #e2efff 0%, #f9f9f9 50%);
|
||||
}
|
||||
</style>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.contentStyle {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100vh;
|
||||
background-color: #f5f7fa;
|
||||
}
|
||||
|
||||
.status-bar {
|
||||
width: 100vw;
|
||||
height: 46px;
|
||||
}
|
||||
|
||||
.page {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding: 0 40rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.mall-list {
|
||||
padding: 20rpx 0;
|
||||
}
|
||||
|
||||
.mall-card {
|
||||
display: flex;
|
||||
background: #fff;
|
||||
border-radius: 12rpx;
|
||||
padding: 20rpx;
|
||||
margin-bottom: 20rpx;
|
||||
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.04);
|
||||
}
|
||||
|
||||
.product-img {
|
||||
width: 180rpx;
|
||||
height: 180rpx;
|
||||
border-radius: 12rpx;
|
||||
flex-shrink: 0;
|
||||
background: #f5f5f5;
|
||||
}
|
||||
|
||||
.product-info {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-between;
|
||||
margin-left: 20rpx;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.product-name {
|
||||
font-size: 30rpx;
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.product-desc {
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
margin-top: 4rpx;
|
||||
}
|
||||
|
||||
.product-bottom {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.product-points {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
}
|
||||
|
||||
.points-value {
|
||||
font-size: 36rpx;
|
||||
font-weight: 700;
|
||||
color: #ff6b35;
|
||||
}
|
||||
|
||||
.points-unit {
|
||||
font-size: 24rpx;
|
||||
color: #ff6b35;
|
||||
margin-left: 4rpx;
|
||||
}
|
||||
|
||||
.exchange-btn {
|
||||
padding: 10rpx 28rpx;
|
||||
background: linear-gradient(135deg, #1677ff 0%, #4096ff 100%);
|
||||
color: #fff;
|
||||
font-size: 24rpx;
|
||||
border-radius: 30rpx;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.exchange-btn:active {
|
||||
opacity: 0.8;
|
||||
}
|
||||
</style>
|
||||
229
property-uniapp-project/pageSubPack/my/myPointsOrder.vue
Normal file
229
property-uniapp-project/pageSubPack/my/myPointsOrder.vue
Normal file
@@ -0,0 +1,229 @@
|
||||
<template>
|
||||
<view class="contentStyle">
|
||||
<!-- <view class="status-bar"></view>
|
||||
<uni-nav-bar title="积分订单" left-icon="left" @clickLeft="goBack" backgroundColor="transparent" :border="false">
|
||||
</uni-nav-bar> -->
|
||||
|
||||
<pull-refresh-scroll
|
||||
custom-class="page"
|
||||
:refreshing="isRefreshing"
|
||||
:loading-more="loading"
|
||||
:no-more-data="noMoreData"
|
||||
:empty="list.length === 0"
|
||||
empty-text="暂无兑换订单"
|
||||
@refresh="onRefresh"
|
||||
@loadMore="loadMore"
|
||||
>
|
||||
<view class="order-list">
|
||||
<view class="order-card" v-for="(item, index) in list" :key="index" @click="onOrderClick(item)">
|
||||
<view class="order-header">
|
||||
<text class="order-product">{{ item.productName }}</text>
|
||||
<text class="order-status" :class="getStatusClass(item.status)">
|
||||
{{ getStatusText(item.status) }}
|
||||
</text>
|
||||
</view>
|
||||
<view class="order-body">
|
||||
<view class="order-row">
|
||||
<text class="order-label">兑换积分</text>
|
||||
<text class="order-points">{{ item.points }}积分</text>
|
||||
</view>
|
||||
<view class="order-row">
|
||||
<text class="order-label">兑换时间</text>
|
||||
<text class="order-time">{{ item.createTime }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</pull-refresh-scroll>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { getPointsOrderList } from '/pageSubPack/api/apiSub.js'
|
||||
import PullRefreshScroll from '/components/pull-refresh-scroll/pull-refresh-scroll.vue'
|
||||
|
||||
const list = ref([])
|
||||
const pageNum = ref(1)
|
||||
const pageSize = ref(10)
|
||||
const noMoreData = ref(false)
|
||||
const loading = ref(false)
|
||||
const isRefreshing = ref(false)
|
||||
|
||||
const getList = async () => {
|
||||
if (loading.value) return
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await getPointsOrderList({
|
||||
pageNum: pageNum.value,
|
||||
pageSize: pageSize.value
|
||||
})
|
||||
const newList = res.rows || res.data || []
|
||||
if (pageNum.value === 1) {
|
||||
list.value = newList
|
||||
} else {
|
||||
list.value = [...list.value, ...newList]
|
||||
}
|
||||
if (newList.length < pageSize.value) {
|
||||
noMoreData.value = true
|
||||
}
|
||||
} catch (err) {
|
||||
uni.showToast({ title: '加载失败', icon: 'none' })
|
||||
console.error('积分订单接口报错:', err)
|
||||
} finally {
|
||||
loading.value = false
|
||||
if (isRefreshing.value) isRefreshing.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const onRefresh = () => {
|
||||
isRefreshing.value = true
|
||||
pageNum.value = 1
|
||||
noMoreData.value = false
|
||||
loading.value = false
|
||||
getList()
|
||||
}
|
||||
|
||||
const loadMore = () => {
|
||||
if (loading.value || noMoreData.value) return
|
||||
pageNum.value++
|
||||
getList()
|
||||
}
|
||||
|
||||
const onOrderClick = (item) => {
|
||||
uni.showToast({ title: `订单号:${item.orderNo || item.id}`, icon: 'none' })
|
||||
}
|
||||
|
||||
const getStatusText = (status) => {
|
||||
const map = { '0': '待处理', '1': '已发货', '2': '已完成', '3': '已取消' }
|
||||
return map[status] || '未知'
|
||||
}
|
||||
|
||||
const getStatusClass = (status) => {
|
||||
const map = { '0': 'status-pending', '1': 'status-shipped', '2': 'status-done', '3': 'status-cancel' }
|
||||
return map[status] || ''
|
||||
}
|
||||
|
||||
const goBack = () => {
|
||||
uni.navigateBack({ delta: 1 })
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getList()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
page {
|
||||
background: linear-gradient(to left bottom, #e2efff 0%, #f9f9f9 50%);
|
||||
}
|
||||
</style>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.contentStyle {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100vh;
|
||||
background-color: #f5f7fa;
|
||||
}
|
||||
|
||||
.status-bar {
|
||||
width: 100vw;
|
||||
height: 46px;
|
||||
}
|
||||
|
||||
.page {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding: 0 40rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.order-list {
|
||||
padding: 20rpx 0;
|
||||
}
|
||||
|
||||
.order-card {
|
||||
background: #fff;
|
||||
border-radius: 12rpx;
|
||||
padding: 28rpx;
|
||||
margin-bottom: 20rpx;
|
||||
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.04);
|
||||
}
|
||||
|
||||
.order-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding-bottom: 20rpx;
|
||||
border-bottom: 1rpx solid #f0f0f0;
|
||||
}
|
||||
|
||||
.order-product {
|
||||
font-size: 30rpx;
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.order-status {
|
||||
font-size: 26rpx;
|
||||
padding: 4rpx 16rpx;
|
||||
border-radius: 20rpx;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.status-pending {
|
||||
color: #fa8c16;
|
||||
background: #fff7e6;
|
||||
}
|
||||
|
||||
.status-shipped {
|
||||
color: #1677ff;
|
||||
background: #e6f4ff;
|
||||
}
|
||||
|
||||
.status-done {
|
||||
color: #07c160;
|
||||
background: #e6f9f0;
|
||||
}
|
||||
|
||||
.status-cancel {
|
||||
color: #999;
|
||||
background: #f5f5f5;
|
||||
}
|
||||
|
||||
.order-body {
|
||||
padding-top: 20rpx;
|
||||
}
|
||||
|
||||
.order-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 12rpx;
|
||||
}
|
||||
|
||||
.order-row:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.order-label {
|
||||
font-size: 26rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.order-points {
|
||||
font-size: 28rpx;
|
||||
color: #ff6b35;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.order-time {
|
||||
font-size: 26rpx;
|
||||
color: #666;
|
||||
}
|
||||
</style>
|
||||
190
property-uniapp-project/pageSubPack/my/myPointsRecord.vue
Normal file
190
property-uniapp-project/pageSubPack/my/myPointsRecord.vue
Normal file
@@ -0,0 +1,190 @@
|
||||
<template>
|
||||
<view class="contentStyle">
|
||||
<!-- <view class="status-bar"></view>
|
||||
<uni-nav-bar title="积分明细" left-icon="left" @clickLeft="goBack" backgroundColor="transparent" :border="false">
|
||||
</uni-nav-bar> -->
|
||||
|
||||
<pull-refresh-scroll
|
||||
custom-class="page"
|
||||
:refreshing="isRefreshing"
|
||||
:loading-more="loading"
|
||||
:no-more-data="noMoreData"
|
||||
:empty="list.length === 0"
|
||||
empty-text="暂无积分记录"
|
||||
@refresh="onRefresh"
|
||||
@loadMore="loadMore"
|
||||
>
|
||||
<view class="record-list">
|
||||
<view class="record-card" v-for="(item, index) in list" :key="index">
|
||||
<view class="record-left">
|
||||
<text class="record-title">{{ item.title }}</text>
|
||||
<text class="record-time">{{ item.createTime }}</text>
|
||||
</view>
|
||||
<view class="record-right">
|
||||
<text class="record-points" :class="item.type === 'income' ? 'income' : 'expense'">
|
||||
{{ item.type === 'income' ? '+' : '-' }}{{ item.points }}
|
||||
</text>
|
||||
<text class="record-balance">余额:{{ item.balance }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</pull-refresh-scroll>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { getPointsRecordList } from '/pageSubPack/api/apiSub.js'
|
||||
import PullRefreshScroll from '/components/pull-refresh-scroll/pull-refresh-scroll.vue'
|
||||
|
||||
const list = ref([])
|
||||
const pageNum = ref(1)
|
||||
const pageSize = ref(10)
|
||||
const noMoreData = ref(false)
|
||||
const loading = ref(false)
|
||||
const isRefreshing = ref(false)
|
||||
|
||||
const getList = async () => {
|
||||
if (loading.value) return
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await getPointsRecordList({
|
||||
pageNum: pageNum.value,
|
||||
pageSize: pageSize.value
|
||||
})
|
||||
const newList = res.rows || res.data || []
|
||||
if (pageNum.value === 1) {
|
||||
list.value = newList
|
||||
} else {
|
||||
list.value = [...list.value, ...newList]
|
||||
}
|
||||
if (newList.length < pageSize.value) {
|
||||
noMoreData.value = true
|
||||
}
|
||||
} catch (err) {
|
||||
uni.showToast({ title: '加载失败', icon: 'none' })
|
||||
console.error('积分明细接口报错:', err)
|
||||
} finally {
|
||||
loading.value = false
|
||||
if (isRefreshing.value) isRefreshing.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const onRefresh = () => {
|
||||
isRefreshing.value = true
|
||||
pageNum.value = 1
|
||||
noMoreData.value = false
|
||||
loading.value = false
|
||||
getList()
|
||||
}
|
||||
|
||||
const loadMore = () => {
|
||||
if (loading.value || noMoreData.value) return
|
||||
pageNum.value++
|
||||
getList()
|
||||
}
|
||||
|
||||
const goBack = () => {
|
||||
uni.navigateBack({ delta: 1 })
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getList()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
page {
|
||||
background: linear-gradient(to left bottom, #e2efff 0%, #f9f9f9 50%);
|
||||
}
|
||||
</style>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.contentStyle {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100vh;
|
||||
background-color: #f5f7fa;
|
||||
}
|
||||
|
||||
.status-bar {
|
||||
width: 100vw;
|
||||
height: 46px;
|
||||
}
|
||||
|
||||
.page {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding: 0 40rpx;
|
||||
box-sizing: border-box;
|
||||
background: #fff;
|
||||
margin: 0 40rpx;
|
||||
border-radius: 12rpx 12rpx 0 0;
|
||||
}
|
||||
|
||||
.record-list {
|
||||
padding: 20rpx 0;
|
||||
}
|
||||
|
||||
.record-card {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 28rpx 20rpx;
|
||||
border-bottom: 1rpx solid #f0f0f0;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.record-card:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.record-left {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.record-title {
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
font-weight: 500;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.record-time {
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
margin-top: 8rpx;
|
||||
}
|
||||
|
||||
.record-right {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-end;
|
||||
flex-shrink: 0;
|
||||
margin-left: 20rpx;
|
||||
}
|
||||
|
||||
.record-points {
|
||||
font-size: 32rpx;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.record-points.income {
|
||||
color: #07c160;
|
||||
}
|
||||
|
||||
.record-points.expense {
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.record-balance {
|
||||
font-size: 22rpx;
|
||||
color: #999;
|
||||
margin-top: 4rpx;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user