积分:接入 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,12 +1,15 @@
<!-- 页面 --> <!-- 我的积分 -->
<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="header-bg">
<view class="bg" /> <view class="bg" />
</view> </view>
@ -20,93 +23,101 @@
<!-- tab --> <!-- tab -->
<su-sticky :customNavHeight="sys_navBar"> <su-sticky :customNavHeight="sys_navBar">
<!-- 统计 --> <!-- 统计 -->
<!-- <view class="filter-box ss-p-x-30 ss-flex ss-col-center ss-row-between"> <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"> <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>总支出{{ -state.pagination.expense }}</view>-->
<!-- </view>-->
</view> </view>
</view> --> <su-tabs
<su-tabs :list="tabMaps" @change="onChange" :scrollable="false" :current="state.currentTab"></su-tabs> :list="tabMaps"
@change="onChange"
:scrollable="false"
:current="state.currentTab"
></su-tabs>
</su-sticky> </su-sticky>
<!-- list --> <!-- list -->
<view class="list-box"> <view class="list-box">
<view v-if="state.pagination.total > 0"> <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" <view
:key="item.id"> 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="ss-flex-col">
<view class="name">{{ item.title }}{{ item.description ? '-' + item.description : '' }}</view> <view class="name"
<view class="time">{{ sheep.$helper.timeFormat(item.createTime, 'yyyy-mm-dd hh:MM:ss')}}</view> >{{ item.title }}{{ item.description ? ' - ' + item.description : '' }}</view
>
<view class="time">{{
sheep.$helper.timeFormat(item.createTime, 'yyyy-mm-dd hh:MM:ss')
}}</view>
</view> </view>
<view class="add" v-if="item.point > 0">+{{ parseInt(item.point) }}</view> <view class="add" v-if="item.point > 0">+{{ item.point }}</view>
<view class="minus" v-else>{{ parseInt(item.point) }}</view> <view class="minus" v-else>{{ item.point }}</view>
</view> </view>
</view> </view>
<s-empty v-else text="暂无数据" icon="/static/data-empty.png" /> <s-empty v-else text="暂无数据" icon="/static/data-empty.png" />
</view> </view>
<uni-load-more v-if="state.pagination.total > 0" :status="state.loadStatus" :content-text="{ <uni-load-more
v-if="state.pagination.total > 0"
:status="state.loadStatus"
:content-text="{
contentdown: '上拉加载更多', contentdown: '上拉加载更多',
}" @tap="onLoadMore" /> }"
@tap="onLoadMore"
/>
</s-layout> </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
} from '@dcloudio/uni-app';
import {
computed,
reactive
} from 'vue';
import _ from 'lodash'; import _ from 'lodash';
import dayjs from 'dayjs'; import dayjs from 'dayjs';
import { import PointApi from '@/sheep/api/member/point';
onPageScroll import { resetPagination } from '@/sheep/util';
} 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 = {
data: [],
current_page: 1,
total: 1,
last_page: 1,
expense: 0,
income: 0,
};
const state = reactive({ const state = reactive({
currentTab: 0, currentTab: 0,
pagination, pagination: {
list: 0,
total: 0,
pageSize: 6,
pageNo: 1,
},
loadStatus: '', loadStatus: '',
date: [], date: [],
today: '', today: '',
}); });
const tabMaps = [{ const tabMaps = [
{
name: '全部', name: '全部',
value: 'all', value: 'all',
}, },
// { {
// name: '', name: '收入',
// value: 'income', value: 'true',
// }, },
// { {
// name: '', name: '支出',
// value: 'expense', value: 'false',
// }, },
]; ];
const dateFilterText = computed(() => { const dateFilterText = computed(() => {
@ -117,59 +128,50 @@
} }
}); });
async function getLogList(page = 1, list_rows = 8) { async function getLogList() {
pagination.current_page = page;
state.loadStatus = 'loading'; state.loadStatus = 'loading';
let res = await sheep.$api.user.wallet.log2({ let { code, data } = await PointApi.getPointRecordPage({
// type: 'score', pageNo: state.pagination.pageNo,
pageSize: list_rows, pageSize: state.pagination.pageSize,
pageNo: page, addStatus: state.currentTab > 0 ? tabMaps[state.currentTab].value : undefined,
// tab: tabMaps[state.currentTab].value, 'createTime[0]': state.date[0] + ' 00:00:00',
// date: appendTimeHMS(state.date), 'createTime[1]': state.date[1] + ' 23:59:59',
}); });
console.log(res, '优惠券列表') if (code !== 0) {
if (res.code === 0) { return;
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';
// }
} }
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';
} }
onLoad(async (options) => { onLoad(() => {
state.today = dayjs().format('YYYY-MM-DD'); state.today = dayjs().format('YYYY-MM-DD');
state.date = [state.today, state.today]; state.date = [state.today, state.today];
getLogList(); getLogList();
}); });
function onChange(e) { function onChange(e) {
state.pagination = pagination;
state.currentTab = e.index; state.currentTab = e.index;
resetPagination(state.pagination);
getLogList(); getLogList();
} }
function onChangeTime(e) { function onChangeTime(e) {
state.date[0] = e[0]; state.date[0] = e[0];
state.date[1] = e[e.length - 1]; state.date[1] = e[e.length - 1];
state.pagination = pagination; resetPagination(state.pagination);
getLogList(); getLogList();
} }
function onLoadMore() { function onLoadMore() {
// if (state.loadStatus !== 'noMore') { if (state.loadStatus === 'noMore') {
getLogList(pagination.current_page + 1); return;
// }
} }
state.pagination.pageNo++;
getLogList();
}
onReachBottom(() => { onReachBottom(() => {
onLoadMore(); onLoadMore();
}); });
@ -178,7 +180,8 @@
<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%)
no-repeat;
background-size: 750rpx 100%; background-size: 750rpx 100%;
padding: 0 0 120rpx 0; padding: 0 0 120rpx 0;
box-sizing: border-box; box-sizing: border-box;

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: {}, // 认证字段
}; };