Commit 6977ae15 authored by wykolor's avatar wykolor

feat: mock数据对接

parent 48e03072
......@@ -5,7 +5,7 @@ import store from "./store";
import './assets/style/normalize.css';
import 'vant/lib/index.css';
import 'amfe-flexible';
createApp(App)
createApp(App)
.use(store)
.use(router)
.mount("#app");
.mount("#app");
\ No newline at end of file
/*
* @Author: wykolor
* @Date: 2021-03-23 10:36:45
* @Last Modified by: wykolor
* @Last Modified time: 2021-03-23 10:36:45
*/
// 流水类型
export enum FlowType {
ADD = 'ADD', // 收入
REDUCE = 'REDUCE' // 支出
}
// 业务类型
export enum BizType {
WITHDRAW = 'WITHDRAW', // 提现
ORDER = 'ORDER', // 订单支付
ORDER_RETURN = 'ORDER_RETURN', // 订单返还
INTRODUCE = 'INTRODUCE', // 转介绍
WITHDRAW_RETURN = 'WITHDRAW_RETURN', // 提现返还
}
// 奖励金账户状态
export enum BonusAccountStatus {
ACTIVE = 'ACTIVE', // 正常
FREEZE = 'FREEZE', // 冻结
}
\ No newline at end of file
/*
* @Author: wykolor
* @Date: 2021-03-23 11:44:35
* @Last Modified by: wykolor
* @Last Modified time: 2021-03-23 17:00:17
*/
export interface PageParams {
pageSize?: number
pageNum?: number
}
export interface baseResponse<T = object> {
code: number;
msg: string;
data: T
}
export interface Paging<T = object> {
total: number;
pageNum: number;
pageSize: number;
hasNextPage: boolean;
list: Array<T>
}
export interface BonusListResponse {
creationTime: string;
flowType: string;
amountChange: number;
bizType: string;
bizTypeName: string;
relationNo: string;
withdrawApplyTime: string;
withdrawPayTime: string;
className: string;
schoolAreaName: string;
}
export interface BonusListParams extends PageParams{
studentId: number;
flowType: string;
}
export interface BonusAccountResponse {
status: string;
balance: number;
sumAdd: number;
sumWithdraw: number;
withdrawing: number;
}
export interface WithdrawListParams extends PageParams {
studentId: number;
}
export interface WithdrawListResponse {
accountName: string ;
withdrawApplyTime: string;
withdrawAmount: number;
withdrawPayTime: string ;
status: string;
expectedPayTime: string ;
failTime: string;
reason: string;
}
export interface CheckCaptchaParams {
userId: string;
ticket: string;
randStr: string;
}
export interface WithdrawParams {
withdrawAmount: number;
userId: number;
studentId: number;
smsVerifyCode: string;
}
\ No newline at end of file
import { BonusAccountResponse, BonusListParams, BonusListResponse, CheckCaptchaParams, Paging, WithdrawListParams, WithdrawListResponse, WithdrawParams } from '@/model/bonus';
import { get, post } from '../../request';
const bonusUrl = '/v1/marketingAccount/';
const withdrawUrl = '/v1/withdraw/'
// 奖励金收支列表
export const getBonusList = (params: BonusListParams) => {
return post<Paging<BonusListResponse>>(`${bonusUrl}bonus/flow/list`, params )
}
// 奖励金账户信息
export const getBonusAccount = (studentId: string) => {
return get<BonusAccountResponse>(`${bonusUrl}bonus/count`, { studentId })
}
// 提现记录列表
export const getWithdrawList = (params: WithdrawListParams) => {
return post<Paging<WithdrawListResponse>>(`${withdrawUrl}query`, params)
}
// 检验图形验证码
export const checkCaptcha = (params: CheckCaptchaParams) => {
return get<string>(`${withdrawUrl}checkCaptcha`, params);
}
// 提现
export const withdraw = (params: WithdrawParams) => {
return post<string>('', params);
}
\ No newline at end of file
import * as bonusModel from "./bonus/index";
export {
bonusModel
}
\ No newline at end of file
import axios from "./http"
import { baseResponse } from '../model/bonus/index'
/**
* 封装的get请求
* @param {*} url 请求路径
* @param {*} params 请求参数
* @returns
*/
export function get(url: string, params?: object) {
return axios({
method: "get",
url: url,
params: params
});
export function get<T=any>(url: string, params?: object) {
return axios.get<baseResponse<T>>(url, params)
}
/**
......@@ -20,11 +16,6 @@ import axios from "./http"
* @param {*} params 请求参数
* @returns
*/
export function post(url: string, params?: object, headers?: object) {
return axios({
method: "post",
url: url,
data: params,
headers
});
export function post<T=any>(url: string, params?: object) {
return axios.post<baseResponse<T>>(url, params)
}
\ No newline at end of file
......@@ -7,163 +7,270 @@
line-width="150"
:sticky="true"
v-model:active="active"
@change="changeTabs"
>
<van-tab title="支出" class="bonus-detail-pay-list">
<template v-if="payList.length">
<div v-for="item in payList" :key="item.id" class="bonus-detail-pay-item">
<ul>
<li style="color: #000">{{ item.title }}</li>
<li class="flex gray">
<span>{{ item.handleTime }}</span>
<label
>{{ item.status === 0 ? "流水号:" : "订单号:" }}{{ item.handleNumber }}</label
>
</li>
</ul>
<ul class="bonus-detail-pay-item-desc">
<li v-if="item.status === 0">申请时间:{{ item.applyTime }}</li>
<li v-if="item.status === 0" class="bonus-detail-pay-item-desc-money flex">
<span>到账时间: {{ item.arrivalTime }}</span>
<label>¥{{ item.money }}</label>
</li>
<li v-if="item.status === 1">{{ item.className }}</li>
<li v-if="item.status === 1" class="bonus-detail-pay-item-desc-money flex">
<span>{{ item.schoolName }}</span
><label>¥{{ item.money }}</label>
</li>
</ul>
</div>
</template>
<van-empty description="暂无数据~" v-else />
</van-tab>
<van-tab title="收入" class="bonus-detail-income-list">
<template v-if="incomeList.length">
<div class="bonus-detail-income-item" v-for="item in incomeList" :key="item.id">
<ul>
<li>{{ item.title }}</li>
<li class="flex bonus-detail-pay-item-desc-money">
<span class="gray">{{ item.handleTime }}</span>
<label>¥{{ item.money }}</label>
</li>
</ul>
</div>
</template>
<van-empty description="暂无数据~" v-else />
</van-tab>
<van-pull-refresh v-model="refreshing" @refresh="onRefresh">
<van-list
v-model:loading="loading"
v-model:error="error"
:finished="finished"
finished-text="没有更多了"
@load="onLoad"
>
<van-tab name="REDUCE" title="支出" class="bonus-detail-pay-list">
<template v-if="reduceList.length">
<div v-for="item in reduceList" :key="item.bizTypeName" class="bonus-detail-pay-item">
<ul>
<li style="color: #000">{{ item.bizTypeName }}</li>
<li class="flex gray">
<span>{{ item.creationTime }}</span>
<label
>{{ item.bizType === BizType.WITHDRAW ? "流水号:" : "订单号:"
}}{{ item.relationNo }}</label
>
</li>
</ul>
<ul class="bonus-detail-pay-item-desc">
<li v-if="item.bizType === BizType.WITHDRAW">
申请时间:{{ item.withdrawApplyTime }}
</li>
<li
v-if="item.bizType === BizType.WITHDRAW"
class="bonus-detail-pay-item-desc-money flex"
>
<span>到账时间: {{ item.withdrawPayTime }}</span>
<label>-¥{{ item.amountChange }}</label>
</li>
<li v-if="item.bizType === BizType.ORDER">{{ item.className }}</li>
<li
v-if="item.bizType === BizType.ORDER"
class="bonus-detail-pay-item-desc-money flex"
>
<span>{{ item.schoolAreaName }}</span
><label v-if="item.bizType === BizType.ORDER">-¥{{ item.amountChange }}</label>
</li>
</ul>
</div>
</template>
<!-- <van-empty description="暂无数据~" v-else /> -->
</van-tab>
<van-tab name="ADD" title="收入" class="bonus-detail-income-list">
<template v-if="addList.length">
<div class="bonus-detail-income-item" v-for="item in addList" :key="item.bizTypeName">
<ul>
<li class="flex ">
<span>{{ item.bizTypeName }}</span>
<label class="gray" v-if="item.bizType === BizType.ORDER_RETURN"
>订单号:{{ item.relationNo }}</label
>
</li>
<li class="flex bonus-detail-pay-item-desc-money">
<span class="gray">{{ item.withdrawPayTime }}</span>
<label>+¥{{ item.amountChange }}</label>
</li>
</ul>
</div>
</template>
<!-- <van-empty description="暂无数据~" v-else /> -->
</van-tab>
</van-list>
</van-pull-refresh>
</van-tabs>
</div>
</template>
<script lang="ts">
import { NavBar, Tab, Tabs, Cell, Empty } from "vant";
import { defineComponent } from "vue";
import { BonusListResponse, PageParams } from "@/model/bonus";
import { FlowType, BizType } from "@/model/bonus/constant";
import { NavBar, Tab, Tabs, Cell, Empty, List, PullRefresh } from "vant";
import { defineComponent, reactive, toRefs } from "vue";
// import { bonusModel } from "@/server/api";
const BonusDetail = defineComponent({
data() {
return {
active: 0,
incomeList: [
// {
// title: "转介绍转入",
// money: 3000.06,
// handleTime: "2020.10.12 12:10",
// status: 0
// },
// {
// title: "被介绍转入",
// money: 3000.05,
// handleTime: "2020.10.12 12:10",
// status: 1
// },
// {
// title: "订单返回",
// money: 3000.05,
// handleTime: "2020.10.12 12:10",
// status: 2
// }
],
payList: [
{
title: "微信提现至 - 渣画化",
applyTime: "2020.10.12 12:10",
arrivalTime: "2020.10.12 12:10",
money: 3000.05,
handleTime: "2020.10.12 12:10",
handleNumber: "AAAA8888",
status: 0
},
{
title: "支付",
applyTime: "2020.10.12 12:10",
arrivalTime: "2020.10.12 12:10",
money: 3000,
handleTime: "2020.10.12 12:10",
handleNumber: "AAAA8888",
status: 1,
className: "清水河18寒春5年级数学极智1班",
schoolName: "清华坊校区"
},
{
title: "微信提现至 - 渣画化",
applyTime: "2020.10.12 12:10",
arrivalTime: "2020.10.12 12:10",
money: 3000.05,
handleTime: "2020.10.12 12:10",
handleNumber: "AAAA8888",
status: 0
},
{
title: "支付",
applyTime: "2020.10.12 12:10",
arrivalTime: "2020.10.12 12:10",
money: 3000.05,
handleTime: "2020.10.12 12:10",
handleNumber: "AAAA8888",
status: 1,
className: "清水河18寒春5年级数学极智1班",
schoolName: "清华坊校区"
},
{
title: "微信提现至 - 渣画化",
applyTime: "2020.10.12 12:10",
arrivalTime: "2020.10.12 12:10",
money: 3000.05,
handleTime: "2020.10.12 12:10",
handleNumber: "AAAA8888",
status: 0
},
{
title: "支付",
applyTime: "2020.10.12 12:10",
arrivalTime: "2020.10.12 12:10",
money: 3000,
handleTime: "2020.10.12 12:10",
handleNumber: "AAAA8888",
status: 1,
className: "清水河18寒春5年级数学极智1班",
schoolName: "清华坊校区"
},
{
title: "微信提现至 - 渣画化",
applyTime: "2020.10.12 12:10",
arrivalTime: "2020.10.12 12:10",
money: 3000.05,
handleTime: "2020.10.12 12:10",
handleNumber: "AAAA8888",
status: 0
},
{
title: "支付",
applyTime: "2020.10.12 12:10",
arrivalTime: "2020.10.12 12:10",
money: 3000.05,
handleTime: "2020.10.12 12:10",
handleNumber: "AAAA8888",
status: 1,
className: "清水河18寒春5年级数学极智1班",
schoolName: "清华坊校区"
setup() {
const pageAdd = reactive<PageParams>({
pageSize: 10,
pageNum: 1
});
const pageReduce = reactive<PageParams>({
pageSize: 10,
pageNum: 1
});
const state = reactive({
active: "REDUCE",
loading: false,
finished: false,
error: false,
refreshing: false,
BizType
});
const addList = reactive<BonusListResponse[]>([]);
const reduceList = reactive<BonusListResponse[]>([]);
const onLoad = () => {
if (state.refreshing) {
state.refreshing = false;
}
// const params = {
// studentId: 123,
// flowType: state.active === FlowType.ADD ? "ADD" : "REDUCE",
// pageSize: state.active === FlowType.ADD ? pageAdd.pageSize : pageReduce.pageSize,
// pageNum: state.active === FlowType.ADD ? pageAdd.pageNum : pageReduce.pageNum
// };
// console.log(params);
setTimeout(() => {
if (state.active === FlowType.REDUCE) {
reduceList.push(
...[
{
withdrawApplyTime: "2020.10.12 12:10",
withdrawPayTime: "2020.10.12 12:10",
amountChange: 200.89,
creationTime: "2020.10.12 12:10",
relationNo: "AAAA8888",
bizType: "INTRODUCE",
flowType: "ADD",
className: "清水河18寒春5年级数学极智1班",
schoolAreaName: "清华坊校区",
bizTypeName: "转介绍"
},
{
withdrawApplyTime: "2020.10.12 12:10",
withdrawPayTime: "2020.10.12 12:10",
amountChange: 200.89,
creationTime: "2020.10.12 12:10",
relationNo: "AAAA8888",
bizType: "WITHDRAW_RETURN",
flowType: "ADD",
className: "清水河18寒春5年级数学极智1班",
schoolAreaName: "清华坊校区",
bizTypeName: "提现返回"
},
{
withdrawApplyTime: "2020.10.12 12:10",
withdrawPayTime: "2020.10.12 12:10",
amountChange: 3000,
creationTime: "2020.10.12 12:10",
relationNo: "AAAA8888",
bizType: "WITHDRAW",
flowType: "REDUCE",
className: "清水河18寒春5年级数学极智1班",
schoolAreaName: "清华坊校区",
bizTypeName: "提现至微信"
},
{
withdrawApplyTime: "2020.10.12 12:10",
withdrawPayTime: "2020.10.12 12:10",
amountChange: 400,
creationTime: "2020.10.12 12:10",
relationNo: "AAAA8888",
bizType: "ORDER",
flowType: "REDUCE",
className: "清水河18寒春5年级数学极智1班",
schoolAreaName: "清华坊校区",
bizTypeName: "支付"
}
]
);
} else {
addList.push(
...[
{
withdrawApplyTime: "2020.10.12 12:10",
withdrawPayTime: "2020.10.12 12:10",
amountChange: 200.89,
creationTime: "2020.10.12 12:10",
relationNo: "AAAA8888",
bizType: "ORDER_RETURN",
flowType: "ADD",
className: "清水河18寒春5年级数学极智1班",
schoolAreaName: "清华坊校区",
bizTypeName: "订单返回"
},
{
withdrawApplyTime: "2020.10.12 12:10",
withdrawPayTime: "2020.10.12 12:10",
amountChange: 200.89,
creationTime: "2020.10.12 12:10",
relationNo: "AAAA8888",
bizType: "INTRODUCE",
flowType: "ADD",
className: "清水河18寒春5年级数学极智1班",
schoolAreaName: "清华坊校区",
bizTypeName: "转介绍"
},
{
withdrawApplyTime: "2020.10.12 12:10",
withdrawPayTime: "2020.10.12 12:10",
amountChange: 200.89,
creationTime: "2020.10.12 12:10",
relationNo: "AAAA8888",
bizType: "WITHDRAW_RETURN",
flowType: "ADD",
className: "清水河18寒春5年级数学极智1班",
schoolAreaName: "清华坊校区",
bizTypeName: "提现返回"
},
{
withdrawApplyTime: "2020.10.12 12:10",
withdrawPayTime: "2020.10.12 12:10",
amountChange: 3000,
creationTime: "2020.10.12 12:10",
relationNo: "AAAA8888",
bizType: "WITHDRAW",
flowType: "REDUCE",
className: "清水河18寒春5年级数学极智1班",
schoolAreaName: "清华坊校区",
bizTypeName: "提现至微信"
},
{
withdrawApplyTime: "2020.10.12 12:10",
withdrawPayTime: "2020.10.12 12:10",
amountChange: 400,
creationTime: "2020.10.12 12:10",
relationNo: "AAAA8888",
bizType: "ORDER",
flowType: "REDUCE",
className: "清水河18寒春5年级数学极智1班",
schoolAreaName: "清华坊校区",
bizTypeName: "支付"
}
]
);
}
state.loading = false;
if (reduceList.length > 40) {
state.finished = true;
}
if (addList.length > 40) {
state.finished = true;
}
]
}, 1000);
// bonusModel.getBonusList(params).then(response => {
// });
};
const onRefresh = () => {
// 清空列表数据
state.finished = false;
// 重新加载数据
// 将 loading 设置为 true,表示处于加载状态
state.loading = true;
onLoad();
};
const changeTabs = name => {
console.log(name);
state.loading = true;
state.finished = false;
onLoad();
};
return {
addList,
reduceList,
...toRefs(state),
onLoad,
onRefresh,
changeTabs
};
},
components: {
......@@ -171,7 +278,9 @@ const BonusDetail = defineComponent({
[Tab.name]: Tab,
[Tabs.name]: Tabs,
[Cell.name]: Cell,
[Empty.name]: Empty
[Empty.name]: Empty,
[List.name]: List,
[PullRefresh.name]: PullRefresh
},
methods: {
onClickLeft() {
......
......@@ -10,7 +10,9 @@
></van-col>
</van-row>
<van-row class="bonus-account-money" align="center">
<van-col span="12" class="money-desc"><span>¥1200.00</span></van-col>
<van-col span="12" class="money-desc"
><span>¥{{ bonusAccount.balance }}</span></van-col
>
<van-col span="12" style="text-align: right"
><van-button
style="border-color: #fff; width: 45%"
......@@ -26,21 +28,21 @@
<van-row class="bonus-account-status">
<van-col span="8">
<label>累计收入</label>
<span>¥11334.00</span>
<span>¥{{ bonusAccount.sumAdd }}</span>
</van-col>
<van-col span="8">
<label>累计提现</label>
<span>¥00.00</span>
<span>¥{{ bonusAccount.sumWithdraw }}</span>
</van-col>
<van-col span="8">
<label>提现中</label>
<span>¥334.00</span>
<span>¥{{ bonusAccount.withdrawing }}</span>
</van-col>
</van-row>
</div>
<van-cell
center
title="可提现金额:¥12.00"
:title="`可提现金额:¥${bonusAccount.balance}`"
size="large"
style="border-radius: 0.3rem;"
:border="false"
......@@ -54,7 +56,7 @@
<van-row>
<van-col span="12" class="tip">&emsp;奖励金提现金额</van-col>
<van-col span="12" class="tip-money" style="text-align: right; font-weight: 550"
>总计:570.00元&nbsp;</van-col
>总计:{{ bonusAccount.sumWithdraw }}元&nbsp;</van-col
>
</van-row>
......@@ -64,36 +66,39 @@
finished-text="我是有底线的"
@load="onLoad"
>
<div class="bonus-record-item" v-for="item in state.bonusRecordList" :key="item.id">
<div class="bonus-record-item" v-for="item in withdrawList" :key="item.id">
<div class="bonus-record-item-header">
<div class="bonus-record-item-header-status">
<i
class="iconfont"
:class="
item.status === 0
item.status === '0'
? 'icon-shijian'
: item.status === 1
: item.status === '1'
? 'icon-jindutiaoqiandai'
: 'icon-xiazaishibai'
"
:style="{
color: item.status === 0 ? '#46BB36' : item.status === 1 ? '#027AFF' : '#F1551E'
color:
item.status === '0' ? '#46BB36' : item.status === '1' ? '#027AFF' : '#F1551E'
}"
></i>
<span>{{
item.status === 0 ? "提现中" : item.status === 1 ? "提现成功" : "提现失败"
item.status === "0" ? "提现中" : item.status === "1" ? "提现成功" : "提现失败"
}}</span>
<label v-if="item.status === 0">请耐心等候~</label>
<label v-if="item.status === '0'">请耐心等候~</label>
</div>
<p class="bonus-record-item-apply-money">
{{ item.status === 1 ? "-" : "" }}¥{{ item.applyMoney }}
{{ item.status === "1" ? "-" : "" }}¥{{ item.withdrawAmount }}
</p>
</div>
<ul class="bonus-record-item-detail">
<li>微信提现:{{ item.userName }}</li>
<li>申请时间:{{ item.applyTime }}</li>
<li>预计时间:{{ item.arrivalTime }}</li>
<li v-if="item.status === 2">失败原因:{{ item.errorReason }}</li>
<li>微信提现:{{ item.accountName }}</li>
<li>申请时间:{{ item.withdrawApplyTime }}</li>
<li v-if="item.status === '0'">预计时间:{{ item.expectedPayTime }}</li>
<li v-if="item.status === '1'">到账时间:{{ item.withdrawPayTime }}</li>
<li v-if="item.status === '2'">失败时间:{{ item.failTime }}</li>
<li v-if="item.status === '2'">失败原因:{{ item.reason }}</li>
</ul>
</div>
</van-list>
......@@ -151,58 +156,74 @@
// eslint-disable-next-line @typescript-eslint/no-explicit-any
import { defineComponent, reactive } from "vue";
import { Dialog, Button, Col, Row, Cell, List } from "vant";
import { BonusAccountResponse, WithdrawListResponse } from "@/model/bonus";
const Bonus = defineComponent({
setup() {
setup(props) {
const state = reactive({
loading: false,
finished: false,
bonusRecordList: [
{
status: 0, // 提现中
userName: "王嘉尔",
applyTime: "2021-10-12 12:12:12",
arrivalTime: "2021-10-12 12:12:12",
applyMoney: 12.04
},
{
status: 1, // 提现成功
userName: "王嘉尔",
applyTime: "2021-10-12 12:12:12",
arrivalTime: "2021-10-12 12:12:12",
applyMoney: 12.02
},
{
status: 2, // 提现失败
userName: "王嘉尔",
applyTime: "2021-10-12 12:12:12",
arrivalTime: "2021-10-12 12:12:12",
applyMoney: 12.5,
errorReason: "账户异常"
}
]
finished: false
});
const bonusAccount = reactive<BonusAccountResponse>({
status: "",
balance: 1.97,
sumAdd: 2.09,
sumWithdraw: 376.79,
withdrawing: 4.09
});
const withdrawList = reactive<WithdrawListResponse[]>([
{
status: "0", // 提现中
accountName: "王嘉尔",
withdrawApplyTime: "2021-10-12 12:12:12",
withdrawPayTime: "2021-10-12 12:12:12",
expectedPayTime: "2021-10-12 12:12:12",
failTime: "2021-10-12 12:12:12",
withdrawAmount: 12.04,
reason: "账户异常"
},
{
status: "1", // 提现成功
accountName: "王嘉尔",
withdrawApplyTime: "2021-10-12 12:12:12",
withdrawPayTime: "2021-10-12 12:12:12",
expectedPayTime: "2021-10-12 12:12:12",
failTime: "2021-10-12 12:12:12",
withdrawAmount: 12.02,
reason: "账户异常"
},
{
status: "2", // 提现失败
accountName: "王嘉尔",
withdrawApplyTime: "2021-10-12 12:12:12",
withdrawPayTime: "2021-10-12 12:12:12",
expectedPayTime: "2021-10-12 12:12:12",
failTime: "2021-10-12 12:12:12",
withdrawAmount: 12.5,
reason: "账户异常"
}
]);
const onLoad = () => {
// 异步更新数据
// setTimeout 仅做示例,真实场景中一般为 ajax 请求
setTimeout(() => {
for (let i = 0; i < 10; i++) {
// state.bonusRecordList.push();
// withdrawList.push();
}
// 加载状态结束
state.loading = false;
// 数据全部加载完成
if (state.bonusRecordList.length >= 40) {
if (withdrawList.length >= 40) {
state.finished = true;
}
}, 1000);
};
return {
state,
bonusAccount,
withdrawList,
onLoad
};
},
......
......@@ -30,8 +30,7 @@ module.exports = {
replace: true,
mediaQuery: false,
minPixelValue: 2,
exclude: /(node_module)/i,
selectorBlackList: ["tc-", "t"]
exclude: /(node_module)/i
})
]
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment