积分:接入 100%

pull/34/head
YunaiV 2023-12-27 20:38:58 +08:00
parent 90751ac3c3
commit b8affe54c1
4 changed files with 249 additions and 235 deletions

View File

@ -1,274 +1,277 @@
<!-- 页面 --> <!-- 我的积分 -->
<template> <template>
<s-layout class="wallet-wrap" title="我的积分" navbar="inner"> <s-layout class="wallet-wrap" title="我的积分" navbar="inner">
<view class="header-box ss-flex ss-flex-col ss-row-center ss-col-center" :style="[ <view
class="header-box ss-flex ss-flex-col ss-row-center ss-col-center"
:style="[
{ {
marginTop: '-' + Number(statusBarHeight + 88) + 'rpx', marginTop: '-' + Number(statusBarHeight + 88) + 'rpx',
paddingTop: Number(statusBarHeight + 88) + 'rpx', paddingTop: Number(statusBarHeight + 88) + 'rpx',
}, },
]"> ]"
<view class="header-bg"> >
<view class="bg" /> <view class="header-bg">
</view> <view class="bg" />
<view class="score-box ss-flex-col ss-row-center ss-col-center"> </view>
<view class="ss-m-b-30"> <view class="score-box ss-flex-col ss-row-center ss-col-center">
<text class="all-title ss-m-r-8">当前积分</text> <view class="ss-m-b-30">
</view> <text class="all-title ss-m-r-8">当前积分</text>
<text class="all-num">{{ userInfo.point || 0 }}</text> </view>
</view> <text class="all-num">{{ userInfo.point || 0 }}</text>
</view> </view>
<!-- tab --> </view>
<su-sticky :customNavHeight="sys_navBar"> <!-- tab -->
<!-- 统计 --> <su-sticky :customNavHeight="sys_navBar">
<!-- <view class="filter-box ss-p-x-30 ss-flex ss-col-center ss-row-between"> <!-- 统计 -->
<uni-datetime-picker v-model="state.data" type="daterange" @change="onChangeTime" :end="state.today"> <view class="filter-box ss-p-x-30 ss-flex ss-col-center ss-row-between">
<uni-datetime-picker v-model="state.date" type="daterange" @change="onChangeTime" :end="state.today">
<button class="ss-reset-button date-btn"> <button class="ss-reset-button date-btn">
<text>{{ dateFilterText }}</text> <text>{{ dateFilterText }}</text>
<text class="cicon-drop-down ss-seldate-icon"></text> <text class="cicon-drop-down ss-seldate-icon"></text>
</button> </button>
</uni-datetime-picker> </uni-datetime-picker>
<view class="total-box"> <!-- TODO 芋艿优化 -->
<view class="ss-m-b-10">总收入{{ state.pagination.income }}</view> <!-- <view class="total-box">-->
<view>总支出{{ -state.pagination.expense }}</view> <!-- <view class="ss-m-b-10">总收入{{ state.pagination.income }}</view>-->
</view> <!-- <view>总支出{{ -state.pagination.expense }}</view>-->
</view> --> <!-- </view>-->
<su-tabs :list="tabMaps" @change="onChange" :scrollable="false" :current="state.currentTab"></su-tabs>
</su-sticky>
<!-- list -->
<view class="list-box">
<view v-if="state.pagination.total > 0">
<view class="list-item ss-flex ss-col-center ss-row-between" v-for="item in state.pagination.data"
:key="item.id">
<view class="ss-flex-col">
<view class="name">{{ item.title }}{{ item.description ? '-' + item.description : '' }}</view>
<view class="time">{{ sheep.$helper.timeFormat(item.createTime, 'yyyy-mm-dd hh:MM:ss')}}</view>
</view>
<view class="add" v-if="item.point > 0">+{{ parseInt(item.point) }}</view>
<view class="minus" v-else>{{ parseInt(item.point) }}</view>
</view>
</view> </view>
<s-empty v-else text="暂无数据" icon="/static/data-empty.png" /> <su-tabs
</view> :list="tabMaps"
@change="onChange"
:scrollable="false"
:current="state.currentTab"
></su-tabs>
</su-sticky>
<uni-load-more v-if="state.pagination.total > 0" :status="state.loadStatus" :content-text="{ <!-- list -->
<view class="list-box">
<view v-if="state.pagination.total > 0">
<view
class="list-item ss-flex ss-col-center ss-row-between"
v-for="item in state.pagination.list"
:key="item.id"
>
<view class="ss-flex-col">
<view class="name"
>{{ item.title }}{{ item.description ? ' - ' + item.description : '' }}</view
>
<view class="time">{{
sheep.$helper.timeFormat(item.createTime, 'yyyy-mm-dd hh:MM:ss')
}}</view>
</view>
<view class="add" v-if="item.point > 0">+{{ item.point }}</view>
<view class="minus" v-else>{{ item.point }}</view>
</view>
</view>
<s-empty v-else text="暂无数据" icon="/static/data-empty.png" />
</view>
<uni-load-more
v-if="state.pagination.total > 0"
:status="state.loadStatus"
:content-text="{
contentdown: '上拉加载更多', contentdown: '上拉加载更多',
}" @tap="onLoadMore" /> }"
</s-layout> @tap="onLoadMore"
/>
</s-layout>
</template> </template>
<script setup> <script setup>
import sheep from '@/sheep'; import sheep from '@/sheep';
import { import { onLoad, onReachBottom } from '@dcloudio/uni-app';
onLoad, import { computed, reactive } from 'vue';
onReachBottom import _ from 'lodash';
} from '@dcloudio/uni-app'; import dayjs from 'dayjs';
import { import PointApi from '@/sheep/api/member/point';
computed, import { resetPagination } from '@/sheep/util';
reactive
} from 'vue';
import _ from 'lodash';
import dayjs from 'dayjs';
import {
onPageScroll
} from '@dcloudio/uni-app';
onPageScroll(() => {});
const statusBarHeight = sheep.$platform.device.statusBarHeight * 2; const statusBarHeight = sheep.$platform.device.statusBarHeight * 2;
const userInfo = computed(() => sheep.$store('user').userInfo); const userInfo = computed(() => sheep.$store('user').userInfo);
const sys_navBar = sheep.$platform.navbar; const sys_navBar = sheep.$platform.navbar;
const pagination = { const state = reactive({
data: [], currentTab: 0,
current_page: 1, pagination: {
total: 1, list: 0,
last_page: 1, total: 0,
expense: 0, pageSize: 6,
income: 0, pageNo: 1,
}; },
loadStatus: '',
date: [],
today: '',
});
const state = reactive({ const tabMaps = [
currentTab: 0, {
pagination, name: '全部',
loadStatus: '', value: 'all',
date: [], },
today: '', {
}); name: '收入',
value: 'true',
},
{
name: '支出',
value: 'false',
},
];
const tabMaps = [{ const dateFilterText = computed(() => {
name: '全部', if (state.date[0] === state.date[1]) {
value: 'all', return state.date[0];
}, } else {
// { return state.date.join('~');
// name: '', }
// value: 'income', });
// },
// {
// name: '',
// value: 'expense',
// },
];
const dateFilterText = computed(() => { async function getLogList() {
if (state.date[0] === state.date[1]) { state.loadStatus = 'loading';
return state.date[0]; let { code, data } = await PointApi.getPointRecordPage({
} else { pageNo: state.pagination.pageNo,
return state.date.join('~'); pageSize: state.pagination.pageSize,
} addStatus: state.currentTab > 0 ? tabMaps[state.currentTab].value : undefined,
}); 'createTime[0]': state.date[0] + ' 00:00:00',
'createTime[1]': state.date[1] + ' 23:59:59',
});
if (code !== 0) {
return;
}
state.pagination.list = _.concat(state.pagination.list, data.list);
state.pagination.total = data.total;
state.loadStatus = state.pagination.list.length < state.pagination.total ? 'more' : 'noMore';
}
async function getLogList(page = 1, list_rows = 8) { onLoad(() => {
pagination.current_page = page; state.today = dayjs().format('YYYY-MM-DD');
state.loadStatus = 'loading'; state.date = [state.today, state.today];
let res = await sheep.$api.user.wallet.log2({ getLogList();
// type: 'score', });
pageSize: list_rows,
pageNo: page,
// tab: tabMaps[state.currentTab].value,
// date: appendTimeHMS(state.date),
});
console.log(res, '优惠券列表')
if (res.code === 0) {
let list = _.concat(state.pagination.data, res.data.list);
console.log(list, '处理后数据')
state.pagination = {
total: res.data.total,
...res.data.list,
data: list,
// income: res.data.income,
// expense: res.data.expense,
};
// if (state.pagination.current_page < state.pagination.last_page) {
state.loadStatus = 'more';
// } else {
// state.loadStatus = 'noMore';
// }
}
}
onLoad(async (options) => { function onChange(e) {
state.today = dayjs().format('YYYY-MM-DD'); state.currentTab = e.index;
state.date = [state.today, state.today]; resetPagination(state.pagination);
getLogList(); getLogList();
}); }
function onChange(e) { function onChangeTime(e) {
state.pagination = pagination; state.date[0] = e[0];
state.currentTab = e.index; state.date[1] = e[e.length - 1];
getLogList(); resetPagination(state.pagination);
} getLogList();
}
function onChangeTime(e) { function onLoadMore() {
state.date[0] = e[0]; if (state.loadStatus === 'noMore') {
state.date[1] = e[e.length - 1]; return;
state.pagination = pagination; }
getLogList(); state.pagination.pageNo++;
} getLogList();
}
function onLoadMore() { onReachBottom(() => {
// if (state.loadStatus !== 'noMore') { onLoadMore();
getLogList(pagination.current_page + 1); });
// }
}
onReachBottom(() => {
onLoadMore();
});
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.header-box { .header-box {
width: 100%; width: 100%;
background: linear-gradient(180deg, var(--ui-BG-Main) 0%, var(--ui-BG-Main-gradient) 100%) no-repeat; background: linear-gradient(180deg, var(--ui-BG-Main) 0%, var(--ui-BG-Main-gradient) 100%)
background-size: 750rpx 100%; no-repeat;
padding: 0 0 120rpx 0; background-size: 750rpx 100%;
box-sizing: border-box; padding: 0 0 120rpx 0;
box-sizing: border-box;
.score-box { .score-box {
height: 100%; height: 100%;
.all-num { .all-num {
font-size: 50rpx; font-size: 50rpx;
font-weight: bold; font-weight: bold;
color: #fff; color: #fff;
font-family: OPPOSANS; font-family: OPPOSANS;
} }
.all-title { .all-title {
font-size: 26rpx; font-size: 26rpx;
font-weight: 500; font-weight: 500;
color: #fff; color: #fff;
} }
.cicon-help-o { .cicon-help-o {
color: #fff; color: #fff;
font-size: 28rpx; font-size: 28rpx;
} }
} }
} }
// //
.filter-box { .filter-box {
height: 114rpx; height: 114rpx;
background-color: $bg-page; background-color: $bg-page;
.total-box { .total-box {
font-size: 24rpx; font-size: 24rpx;
font-weight: 500; font-weight: 500;
color: $dark-9; color: $dark-9;
} }
.date-btn { .date-btn {
background-color: $white; background-color: $white;
line-height: 54rpx; line-height: 54rpx;
border-radius: 27rpx; border-radius: 27rpx;
padding: 0 20rpx; padding: 0 20rpx;
font-size: 24rpx; font-size: 24rpx;
font-weight: 500; font-weight: 500;
color: $dark-6; color: $dark-6;
.ss-seldate-icon { .ss-seldate-icon {
font-size: 50rpx; font-size: 50rpx;
color: $dark-9; color: $dark-9;
} }
} }
} }
.list-box { .list-box {
.list-item { .list-item {
background: #fff; background: #fff;
border-bottom: 1rpx solid #dfdfdf; border-bottom: 1rpx solid #dfdfdf;
padding: 30rpx; padding: 30rpx;
.name { .name {
font-size: 28rpx; font-size: 28rpx;
font-weight: 500; font-weight: 500;
color: rgba(102, 102, 102, 1); color: rgba(102, 102, 102, 1);
line-height: 28rpx; line-height: 28rpx;
margin-bottom: 20rpx; margin-bottom: 20rpx;
} }
.time { .time {
font-size: 24rpx; font-size: 24rpx;
font-weight: 500; font-weight: 500;
color: rgba(196, 196, 196, 1); color: rgba(196, 196, 196, 1);
line-height: 24px; line-height: 24px;
} }
.add { .add {
font-size: 30rpx; font-size: 30rpx;
font-weight: 500; font-weight: 500;
color: #e6b873; color: #e6b873;
} }
.minus { .minus {
font-size: 30rpx; font-size: 30rpx;
font-weight: 500; font-weight: 500;
color: $dark-3; color: $dark-3;
} }
} }
} }
</style> </style>

19
sheep/api/member/point.js Normal file
View File

@ -0,0 +1,19 @@
import request from '@/sheep/request';
const PointApi = {
// 获得用户积分记录分页
getPointRecordPage: (params) => {
if (params.addStatus === undefined) {
delete params.addStatus
}
const queryString = Object.keys(params)
.map((key) => encodeURIComponent(key) + '=' + params[key])
.join('&');
return request({
url: `/app-api/member/point/record/page?${queryString}`,
method: 'GET',
});
}
};
export default PointApi;

View File

@ -256,14 +256,6 @@ export default {
params, params,
custom: {}, custom: {},
}), }),
log2: (params) =>
request2({
url: 'member/point/record/page',
// url: 'pay/wallet-transaction/page',
method: 'GET',
params,
custom: {},
}),
}, },
account: { account: {
info: (params) => info: (params) =>

View File

@ -23,7 +23,7 @@ const defaultUserInfo = {
gender: 0, // 性别 gender: 0, // 性别
mobile: '', // 手机号 mobile: '', // 手机号
money: '--', // 余额 money: '--', // 余额
score: '--', // 积分 score: '--', // 积分 TODO 芋艿:改成 point
verification: {}, // 认证字段 verification: {}, // 认证字段
}; };