Commit 90d9ee87 authored by hewenhao's avatar hewenhao

Merge branch 'release/2021_03_12_bonus' into 'master'

Release/2021 03 12 bonus See merge request wykolor/mall-webview!2
parents 71186e7f d9f9875e
[*.{js,jsx,ts,tsx,vue}]
indent_style = space
indent_size = 2
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true
max_line_length = 100
.DS_Store
node_modules
/dist
/mall-webview
# local env files
.env.local
.env.*.local
# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
# GeekBonusH5
# GEEKBONUSH5
奖励金功能_H5版
\ No newline at end of file
## 奖励金H5版本
## Project setup
```
npm install
```
### Compiles and hot-reloads for development
```
npm run serve
```
### Compiles and minifies for production
```
npm run build
```
### Lints and fixes files
```
npm run lint
```
### Customize configuration
See [Configuration Reference](https://cli.vuejs.org/config/).
module.exports = {
presets: ["@vue/cli-plugin-babel/preset"]
};
This source diff could not be displayed because it is too large. You can view the blob instead.
{
"name": "bonus",
"version": "0.1.0",
"private": true,
"scripts": {
"build": "node scripts/build.js",
"serve": "node scripts/build.js --watch",
"lint": "node scripts/build.js --lint"
},
"dependencies": {
"amfe-flexible": "^2.2.1",
"axios": "^0.21.1",
"core-js": "^3.6.5",
"js-cookie": "^2.2.1",
"vant": "^3.0.9",
"vconsole": "^3.4.0",
"vue": "^3.0.0",
"vue-class-component": "^8.0.0-0",
"vue-router": "^4.0.0-0",
"vuex": "^4.0.0-0",
"webpack-merge": "^5.7.3"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^2.33.0",
"@typescript-eslint/parser": "^2.33.0",
"@vue/cli-plugin-babel": "~4.5.0",
"@vue/cli-plugin-eslint": "~4.5.0",
"@vue/cli-plugin-router": "~4.5.0",
"@vue/cli-plugin-typescript": "~4.5.0",
"@vue/cli-plugin-vuex": "~4.5.0",
"@vue/cli-service": "~4.5.0",
"@vue/compiler-sfc": "^3.0.0",
"@vue/eslint-config-prettier": "^6.0.0",
"@vue/eslint-config-typescript": "^5.0.2",
"eslint": "^6.7.2",
"eslint-plugin-prettier": "^3.1.3",
"eslint-plugin-vue": "^7.0.0-0",
"execa": "^5.0.0",
"less": "^4.1.1",
"less-loader": "^8.0.0",
"postcss-plugin-px2rem": "^0.8.1",
"prettier": "^1.19.1",
"sass": "^1.26.5",
"sass-loader": "^8.0.2",
"ts-import-plugin": "^1.6.7",
"typescript": "~3.9.3"
},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/vue3-essential",
"eslint:recommended",
"@vue/typescript/recommended",
"@vue/prettier",
"@vue/prettier/@typescript-eslint"
],
"parserOptions": {
"ecmaVersion": 2020
},
"rules": {
"@typescript-eslint/camelcase": "off",
"@typescript-eslint/no-explicit-any": 0
}
},
"browserslist": [
"> 1%",
"last 2 versions",
"not dead"
]
}
<!DOCTYPE html>
<html lang="">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<meta name="format-detection" content="telephone=yes">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<link rel="stylesheet" href="//at.alicdn.com/t/font_2425189_lvk0clvlo2.css">
<title>我的奖励金</title>
<script src="https://ssl.captcha.qq.com/TCaptcha.js"></script>
<!-- <% if (String(VUE_APP_DEPLOY_MODE) === 'test') { %>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vConsole/3.4.1/vconsole.min.js"></script>
<script>new window.VConsole({});</script>
<% } %> -->
<script>
(function flexible (window, document) {
var docEl = document.documentElement
var dpr = window.devicePixelRatio || 1
// adjust body font size
function setBodyFontSize () {
if (document.body) {
document.body.style.fontSize = (12 * dpr) + 'px'
}
else {
document.addEventListener('DOMContentLoaded', setBodyFontSize)
}
}
setBodyFontSize();
// set 1rem = viewWidth / 10
function setRemUnit () {
var rem = docEl.clientWidth / 10
rem = rem > 75 ? 75 : rem;
docEl.style.fontSize = rem + 'px';
}
setRemUnit()
// reset rem unit on page resize
window.addEventListener('resize', setRemUnit)
window.addEventListener('pageshow', function (e) {
if (e.persisted) {
setRemUnit()
}
})
// detect 0.5px supports
if (dpr >= 2) {
var fakeBody = document.createElement('body')
var testElement = document.createElement('div')
testElement.style.border = '.5px solid transparent'
fakeBody.appendChild(testElement)
docEl.appendChild(fakeBody)
if (testElement.offsetHeight === 1) {
docEl.classList.add('hairlines')
}
docEl.removeChild(fakeBody)
}
}(window, document))
</script>
</head>
<body>
<noscript>
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>
/* eslint-disable @typescript-eslint/no-var-requires */
const path = require("path");
const rawArgv = process.argv.slice(2);
const args = require("minimist")(rawArgv);
const execa = require("execa");
const resolve = d => path.resolve(__dirname, d);
const bin = cmd => resolve("../node_modules/.bin/" + cmd);
const { watch, lint } = args;
let cmd = "build";
if (lint) {
cmd = "lint";
} else if (watch) {
cmd = "serve";
}
let deployMode = args._[0] || "production";
if (cmd === "serve") {
deployMode = "test";
}
process.env.VUE_APP_DEPLOY_MODE = deployMode;
execa(bin("vue-cli-service"), [cmd], {
cwd: resolve(".."),
stdio: "inherit",
env: process.env
});
<template>
<div :class="styles.app">
<router-view />
</div>
</template>
<style lang="scss" module="styles">
.app {
:global(.van-button--small) {
height: 72px;
line-height: 72px;
font-size: 28px;
}
:global(.van-button) {
height: 72px;
line-height: 72px;
font-size: 28px;
}
}
</style>
<style lang="scss">
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
color: #2c3e50;
background: #f6f6f6;
min-height: 100vh;
box-sizing: border-box;
font-size: 28px;
}
* {
box-sizing: inherit;
}
i.iconfont {
font-family: "iconfont" !important;
font-size: 28px;
font-style: normal;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
</style>
/*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */
/* Document
========================================================================== */
/**
* 1. Correct the line height in all browsers.
* 2. Prevent adjustments of font size after orientation changes in iOS.
*/
html {
line-height: 1.15;
/* 1 */
-webkit-text-size-adjust: 100%;
/* 2 */
}
/* Sections
========================================================================== */
/**
* Remove the margin in all browsers.
*/
body {
margin: 0;
}
/**
* Render the `main` element consistently in IE.
*/
main {
display: block;
}
/**
* Correct the font size and margin on `h1` elements within `section` and
* `article` contexts in Chrome, Firefox, and Safari.
*/
h1 {
font-size: 2em;
margin: 0.67em 0;
}
/* Grouping content
========================================================================== */
/**
* 1. Add the correct box sizing in Firefox.
* 2. Show the overflow in Edge and IE.
*/
hr {
box-sizing: content-box;
/* 1 */
height: 0;
/* 1 */
overflow: visible;
/* 2 */
}
/**
* 1. Correct the inheritance and scaling of font size in all browsers.
* 2. Correct the odd `em` font sizing in all browsers.
*/
pre {
font-family: monospace, monospace;
/* 1 */
font-size: 1em;
/* 2 */
}
/* Text-level semantics
========================================================================== */
/**
* Remove the gray background on active links in IE 10.
*/
a {
background-color: transparent;
}
/**
* 1. Remove the bottom border in Chrome 57-
* 2. Add the correct text decoration in Chrome, Edge, IE, Opera, and Safari.
*/
abbr[title] {
border-bottom: none;
/* 1 */
text-decoration: underline;
/* 2 */
text-decoration: underline dotted;
/* 2 */
}
/**
* Add the correct font weight in Chrome, Edge, and Safari.
*/
b,
strong {
font-weight: bolder;
}
/**
* 1. Correct the inheritance and scaling of font size in all browsers.
* 2. Correct the odd `em` font sizing in all browsers.
*/
code,
kbd,
samp {
font-family: monospace, monospace;
/* 1 */
font-size: 1em;
/* 2 */
}
/**
* Add the correct font size in all browsers.
*/
small {
font-size: 80%;
}
/**
* Prevent `sub` and `sup` elements from affecting the line height in
* all browsers.
*/
sub,
sup {
font-size: 75%;
line-height: 0;
position: relative;
vertical-align: baseline;
}
sub {
bottom: -0.25em;
}
sup {
top: -0.5em;
}
/* Embedded content
========================================================================== */
/**
* Remove the border on images inside links in IE 10.
*/
img {
border-style: none;
}
/* Forms
========================================================================== */
/**
* 1. Change the font styles in all browsers.
* 2. Remove the margin in Firefox and Safari.
*/
button,
input,
optgroup,
select,
textarea {
font-family: inherit;
/* 1 */
font-size: 100%;
/* 1 */
line-height: 1.15;
/* 1 */
margin: 0;
/* 2 */
}
/**
* Show the overflow in IE.
* 1. Show the overflow in Edge.
*/
button,
input {
/* 1 */
overflow: visible;
}
/**
* Remove the inheritance of text transform in Edge, Firefox, and IE.
* 1. Remove the inheritance of text transform in Firefox.
*/
button,
select {
/* 1 */
text-transform: none;
}
/**
* Correct the inability to style clickable types in iOS and Safari.
*/
button,
[type="button"],
[type="reset"],
[type="submit"] {
-webkit-appearance: button;
}
/**
* Remove the inner border and padding in Firefox.
*/
button::-moz-focus-inner,
[type="button"]::-moz-focus-inner,
[type="reset"]::-moz-focus-inner,
[type="submit"]::-moz-focus-inner {
border-style: none;
padding: 0;
}
/**
* Restore the focus styles unset by the previous rule.
*/
button:-moz-focusring,
[type="button"]:-moz-focusring,
[type="reset"]:-moz-focusring,
[type="submit"]:-moz-focusring {
outline: 1px / 2 dotted ButtonText;
}
/**
* Correct the padding in Firefox.
*/
fieldset {
padding: 0.35em 0.75em 0.625em;
}
/**
* 1. Correct the text wrapping in Edge and IE.
* 2. Correct the color inheritance from `fieldset` elements in IE.
* 3. Remove the padding so developers are not caught out when they zero out
* `fieldset` elements in all browsers.
*/
legend {
box-sizing: border-box;
/* 1 */
color: inherit;
/* 2 */
display: table;
/* 1 */
max-width: 100%;
/* 1 */
padding: 0;
/* 3 */
white-space: normal;
/* 1 */
}
/**
* Add the correct vertical alignment in Chrome, Firefox, and Opera.
*/
progress {
vertical-align: baseline;
}
/**
* Remove the default vertical scrollbar in IE 10+.
*/
textarea {
overflow: auto;
}
/**
* 1. Add the correct box sizing in IE 10.
* 2. Remove the padding in IE 10.
*/
[type="checkbox"],
[type="radio"] {
box-sizing: border-box;
/* 1 */
padding: 0;
/* 2 */
}
/**
* Correct the cursor style of increment and decrement buttons in Chrome.
*/
[type="number"]::-webkit-inner-spin-button,
[type="number"]::-webkit-outer-spin-button {
height: auto;
}
/**
* 1. Correct the odd appearance in Chrome and Safari.
* 2. Correct the outline style in Safari.
*/
[type="search"] {
-webkit-appearance: textfield;
/* 1 */
outline-offset: -2px / 2;
/* 2 */
}
/**
* Remove the inner padding in Chrome and Safari on macOS.
*/
[type="search"]::-webkit-search-decoration {
-webkit-appearance: none;
}
/**
* 1. Correct the inability to style clickable types in iOS and Safari.
* 2. Change font properties to `inherit` in Safari.
*/
::-webkit-file-upload-button {
-webkit-appearance: button;
/* 1 */
font: inherit;
/* 2 */
}
/* Interactive
========================================================================== */
/*
* Add the correct display in Edge, IE 10+, and Firefox.
*/
details {
display: block;
}
/*
* Add the correct display in all browsers.
*/
summary {
display: list-item;
}
/* Misc
========================================================================== */
/**
* Add the correct display in IE 10+.
*/
template {
display: none;
}
/**
* Add the correct display in IE 10.
*/
[hidden] {
display: none;
}
\ No newline at end of file
/* eslint-disable @typescript-eslint/no-var-requires */
import { createApp } from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";
import "./assets/style/normalize.css";
if (process.env.VUE_APP_DEPLOY_MODE === "test") {
const VConsole = require("vconsole");
new VConsole();
}
createApp(App)
.use(store)
.use(router)
.mount("#app");
/*
* @Author: wykolor
* @Date: 2021-03-23 10:36:45
* @Last Modified by: mikey.zhaopeng
* @Last Modified time: 2021-04-07 11:51:44
*/
// 流水类型
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" // 冻结
}
// 奖励金预提现错误状态
export enum ErrCode {
NOT_BIND = "NOT_BIND", // 未绑定微信
USER_FREEZE = "USER_FREEZE", // 用户冻结
ACCOUNT_FREEZE = "ACCOUNT_FREEZE", // 学生账户冻结
USER_UP_LIMIT = "USER_UP_LIMIT", // 用户上限
SYSTEM_UP_LIMIT = "SYSTEM_UP_LIMIT", // 系统上限
STUDENT_WITHDRAWING = "STUDENT_WITHDRAWING", // 学生提现中
BALANCE_NOT_ENOUGH = "BALANCE_NOT_ENOUGH" // 余额不足
}
// 提现记录状态
export enum WithdrawStatus {
WITHDRAWING = "WITHDRAWING",
RECEIVED = "RECEIVED",
FAILED = "FAILED"
}
/*
* @Author: wykolor
* @Date: 2021-03-23 11:44:35
* @Last Modified by: mikey.zhaopeng
* @Last Modified time: 2021-04-25 17:46:04
*/
export interface PageParams {
pageSize: number;
pageNum: number;
}
export interface BaseResponse<T = object> {
code?: number;
msg?: string;
data: T;
}
export interface Paging<T = object> {
list: T[];
isLoad: boolean;
loading: boolean;
refreshing: boolean;
hasNextPage: boolean;
error: null | string;
total: number;
}
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;
withdrawing: number;
balanceTotal: number;
addTotal: number;
withdrawedTotal: number;
withdrawAccount: string;
withdrawAccountId: string;
withdrawableTotal: number;
errCode: string;
}
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 {
ticket: string;
randStr: string;
}
export interface WithdrawParams {
withdrawAmount: any;
studentId: any;
smsVerifyCode: any;
withdrawAccountId: any;
}
export interface WithdrawResponse {
serialNo: string;
withdrawAccount: string;
amount: number;
withdrawApplyTime: string;
expectedPayTime: string;
}
export interface WithdrawRiskResponse {
withdrawable: boolean;
systemDailyWithdrawLimit: number;
studentDailyWithdrawLimit: number;
studentWithdrawLimit: number;
userDailyWithdrawLimit: number;
userWithdrawLimit: number;
}
import { createRouter, createWebHashHistory, RouteRecordRaw } from "vue-router";
import Bonus from "../views/bonus/index.vue";
const routes: Array<RouteRecordRaw> = [
{
path: "/",
name: "Bonus",
component: Bonus
},
{
path: "/bonusDetail",
name: "bonusDetail",
component: () => import("../views/bonus/bonus-detail/index.vue")
},
{
path: "/withdraw",
name: "withdraw",
component: () => import("../views/bonus/withdraw/index.vue")
},
{
path: "/test",
name: "test",
component: () => import("../views/test/index.vue")
},
{
path: "/test/paging",
name: "test-paging",
component: () => import("../views/test/paging.vue")
}
];
const router = createRouter({
history: createWebHashHistory(),
routes
});
export default router;
import {
BonusAccountResponse,
BonusListParams,
BonusListResponse,
CheckCaptchaParams,
Paging,
WithdrawListParams,
WithdrawListResponse,
WithdrawParams,
WithdrawResponse,
WithdrawRiskResponse
} from "@/model/bonus";
import { get, post } from "../request";
// 奖励金收支列表
export const getBonusList = async (params: Partial<BonusListParams>) => {
return await get<Paging<BonusListResponse>>(
`/api-jksxb-app/v1/marketingAccount/bonus/flow/list`,
params
);
};
// 奖励金账户信息
export const getBonusAccount = (studentId: string) => {
return get<BonusAccountResponse>(`/api-jksxb-app/v1/marketingAccount/bonus/count`, { studentId });
};
// 提现记录列表
export const getWithdrawList = async (params: Partial<WithdrawListParams>) => {
return await get<Paging<WithdrawListResponse>>(`/api-jksxb-app/v1/withdraw/query`, params);
};
// 检验图形验证码
export const checkCaptcha = (params: CheckCaptchaParams) => {
return post<string>(`/api-jksxb-app/v1/withdraw/checkCaptcha`, params);
};
// 提现
export const withdraw = (params: object) => {
return post<WithdrawResponse>("/api-jksxb-app/v1/withdraw", params);
};
// 绑定微信
export const bindWeiChat = (params: { code: string }) => {
return post("/api-jksxb-app/v1/withdraw/bind/wx/parent", params);
};
// 获取用户风控值
export const getWithdrawRisk = (studentId: string) => {
return get<WithdrawRiskResponse>("/api-jksxb-app/v1/risk/getWithdrawRisk", { studentId });
};
import axios, { AxiosRequestConfig } from "axios";
import Cookies from "js-cookie";
import { unref } from "vue";
import router from "../router";
const instance = axios.create({
headers: {
"content-type": "application/json;charset=UTF-8",
Authorization: `Bearer ${Cookies.get("token")}`
},
baseURL: "",
timeout: 10000,
withCredentials: true
});
let globalToken: string | null = null;
// 拦截器 在请求之前拦截
instance.interceptors.request.use(
(config: AxiosRequestConfig) => {
const route = unref(router.currentRoute);
let token = route.query.token;
token = Array.isArray(token) ? token[0] : token;
// refresh token
if (token && token !== globalToken) {
globalToken = token;
}
if (globalToken) {
const pre = config.headers || {};
return {
...config,
headers: {
...pre,
Authorization: `Bearer ${globalToken}`
}
};
}
return config;
},
error => {
// 请求错误
return Promise.reject(error);
}
);
// 响应拦截器
instance.interceptors.response.use(
response => {
const { code, msg } = response.data;
if (code !== 0) {
return Promise.reject(msg);
}
return response.data;
},
error => {
return Promise.reject(error.message);
}
);
export default instance;
import axios from "./http";
/**
* 封装的get请求
* @param {*} url 请求路径
* @param {*} params 请求参数
* @returns
*/
export function get<T>(url: string, params?: object) {
return axios
.get<T>(url, { params })
.then(res => res.data);
}
/**
* 封装的post请求
* @param {*} url 请求路径
* @param {*} params 请求参数
* @returns
*/
export function post<T>(url: string, data?: object) {
return axios.post<T>(url, data).then(res => res.data);
}
/* eslint-disable */
declare module '*.vue' {
import type { DefineComponent } from 'vue'
const component: DefineComponent<{}, {}, any>
export default component
}
declare interface Window {
ReactNativeWebView: any;
$geek_excuteJS: any;
}
\ No newline at end of file
import { createStore } from "vuex";
import bonus from "./module/bonus";
export default createStore({
state: {
studentName: "wangyan"
},
getters: {
studentFullName: state => state.studentName + "WANG"
},
mutations: {},
actions: {},
modules: {
bonus: bonus
}
});
import Cookies from 'js-cookie'
const bonus = {
namespaced: true,
state: () => ({
studentId: 0,
token: "",
userId: 0
}),
getters: {},
mutations: {
saveStudentId(state, payload) {
state.studentId = payload;
},
saveToken(state, payload) {
Cookies.set('token', payload)
state.token = payload;
},
saveUserId(state, payload) {
state.userId = payload;
}
},
actions: {}
};
export default bonus;
import { ErrCode } from "@/model/bonus/constant";
export function formatBonusTipTxt(errCode: string): string {
let tip = "";
switch (errCode) {
case ErrCode.NOT_BIND:
tip = "绑定微信后,才可进行提现!";
break;
case ErrCode.USER_FREEZE:
case ErrCode.ACCOUNT_FREEZE:
tip = "当前账号存在风险,无法进行提现操作!如需帮助请联系:400-8777389";
break;
case ErrCode.USER_UP_LIMIT:
case ErrCode.SYSTEM_UP_LIMIT:
tip =
"今日已达到提现次数/提现金额上限,无法进行提现操作,请明日进行提现操作!如需帮助请联系:400-8777389";
break;
case ErrCode.STUDENT_WITHDRAWING:
tip =
"您当前有一笔资金处于提现中,待该笔资金完成提现后,再进行提现操作!如需帮助请联系:400-8777389";
break;
case ErrCode.BALANCE_NOT_ENOUGH:
tip = "提现金额至少为:1.00元。当前可提现金额不足!如需帮助请联系:400-8777389!";
break;
default:
tip = "";
}
return tip;
}
let appId = "2095826303"; // 腾讯验证码appid
if (process.env.VUE_APP_DEPLOY_MODE === "test") {
appId = "2087826974";
}
export default appId
\ No newline at end of file
export type EventType = string | symbol;
// An event handler can take an optional event argument
// and should not return a value
export type Handler<T = any> = (event?: T) => void;
export type WildcardHandler = (type: EventType, event?: any) => void;
// An array of all currently registered event handlers for a type
export type EventHandlerList = Array<Handler>;
export type WildCardEventHandlerList = Array<WildcardHandler>;
// A map of event types and their corresponding event handlers.
export type EventHandlerMap = Map<EventType, EventHandlerList | WildCardEventHandlerList>;
export interface Emitter {
all: EventHandlerMap;
on<T = any>(type: EventType, handler: Handler<T>): void;
on(type: "*", handler: WildcardHandler): void;
off<T = any>(type: EventType, handler: Handler<T>): void;
off(type: "*", handler: WildcardHandler): void;
emit<T = any>(type: EventType, event?: T): void;
emit(type: "*", event?: any): void;
}
/**
* Mitt: Tiny (~200b) functional event emitter / pubsub.
* @name mitt
* @returns {Mitt}
*/
export default function mitt(_all?: EventHandlerMap): Emitter {
const all = _all || new Map();
return {
/**
* A Map of event names to registered handler functions.
*/
all,
/**
* Register an event handler for the given type.
* @param {string|symbol} type Type of event to listen for, or `"*"` for all events
* @param {Function} handler Function to call in response to given event
* @memberOf mitt
*/
on<T = any>(type: EventType, handler: Handler<T>) {
const handlers = all.get(type);
const added = handlers && handlers.push(handler);
if (!added) {
all.set(type, [handler]);
}
},
/**
* Remove an event handler for the given type.
* @param {string|symbol} type Type of event to unregister `handler` from, or `"*"`
* @param {Function} handler Handler function to remove
* @memberOf mitt
*/
off<T = any>(type: EventType, handler: Handler<T>) {
const handlers = all.get(type);
if (handlers) {
handlers.splice(handlers.indexOf(handler) >>> 0, 1);
}
},
/**
* Invoke all handlers for the given type.
* If present, `"*"` handlers are invoked after type-matched handlers.
*
* Note: Manually firing "*" handlers is not supported.
*
* @param {string|symbol} type The event type to invoke
* @param {Any} [evt] Any value (object is recommended and powerful), passed to each handler
* @memberOf mitt
*/
emit<T = any>(type: EventType, evt: T) {
((all.get(type) || []) as EventHandlerList).slice().map(handler => {
handler(evt);
});
((all.get("*") || []) as WildCardEventHandlerList).slice().map(handler => {
handler(type, evt);
});
}
};
}
/* eslint-disable @typescript-eslint/camelcase */
import { App } from "vue";
import mitt from "./mitt";
const isiOS = () => {
const u = navigator.userAgent;
const iOs = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
return iOs;
};
const isAndroid = () => {
const u = navigator.userAgent;
const android = u.indexOf("Android") > -1 || u.indexOf("Adr") > -1;
return android;
};
const postMessage = data => {
if (isAndroid()) {
window.ReactNativeWebView &&
window.ReactNativeWebView.onMessage &&
window.ReactNativeWebView.onMessage(JSON.stringify(data));
}
window.ReactNativeWebView &&
window.ReactNativeWebView.postMessage &&
window.ReactNativeWebView.postMessage(JSON.stringify(data));
};
if (isiOS() || isAndroid()) {
// const debugLog = console.log
// eslint-disable-next-line func-names
// console.log = function (...args) {
// postMessage({
// type: 'log',
// data: args
// })
// debugLog(...args)
// }
}
function install(Vue: App) {
const GEEK_NATVIE_NAME = "GEEK_NATVIE_NAME";
// eslint-disable-next-line camelcase
const event_bus = mitt();
// eslint-disable-next-line func-names
window.$geek_excuteJS = function(args) {
try {
const params = JSON.parse(args);
event_bus.emit(GEEK_NATVIE_NAME, params);
} catch (error) {
event_bus.emit(GEEK_NATVIE_NAME, args);
}
};
Vue.mixin({
methods: {
listenNativeMessage(arg) {
const { method, data } = arg;
if (method) {
this[method] && this[method](data);
}
},
$nativeTitle(title) {
const message = {
type: "title",
data: title
};
postMessage(message);
},
$shareImg(base64Img, timeline = false) {
const message = {
type: timeline ? "shareTimeline" : "share",
data: {
type: "img",
img: base64Img
}
};
postMessage(message);
},
$shareText(txt, timeline = false) {
const message = {
type: timeline ? "shareTimeline" : "share",
data: {
type: "text",
description: txt
}
};
postMessage(message);
},
$shareNews({ title, url, description }, timeline = false) {
const message = {
type: timeline ? "shareTimeline" : "share",
data: {
type: "news",
description,
webpageUrl: url,
title
}
};
postMessage(message);
},
$playVieo(url) {
const message = {
type: "video",
data: {
url
}
};
postMessage(message);
},
$postMessage(message) {
postMessage(message);
},
$exitWebView(data) {
this.$postMessage({
type: "exitWebview",
data
});
},
$shareReport(params) {
this.$postMessage({
type: "reportShare",
params
});
}
},
created() {
event_bus.on(GEEK_NATVIE_NAME, this.listenNativeMessage);
},
beforeUnmount() {
event_bus.off(GEEK_NATVIE_NAME, this.listenNativeMessage);
}
});
}
export default install;
export function countDown(times: number, interval = 1000, callback?: Function) {
let count = 0;
const timeoutParams: {timeCounter: number | undefined} = { timeCounter: undefined }
function _countDownStart() {
if (!timeoutParams.timeCounter) {
return;
}
count++;
callback && callback(times - count + 1);
if (count > times) {
clearTimeout(timeoutParams.timeCounter);
} else {
timeoutParams.timeCounter = setTimeout(_countDownStart, interval);
}
}
timeoutParams.timeCounter = setTimeout(_countDownStart, interval);
return timeoutParams;
}
/* eslint-disable @typescript-eslint/no-use-before-define */
/* eslint-disable @typescript-eslint/camelcase */
/* eslint-disable @typescript-eslint/no-explicit-any */
import { onBeforeUnmount, onMounted, getCurrentInstance, ComponentInternalInstance } from "vue";
import mitt from "./mitt";
const eventBus = mitt();
const GEEK_NATIVE_NAME = "GEEK_NATIVE_NAME";
interface NativeInvokeFuncParams {
method: string;
data: any;
error?: string | null;
}
const isAndroid = () => {
const u = navigator.userAgent;
const android = u.indexOf("Android") > -1 || u.indexOf("Adr") > -1;
return android;
};
window.$geek_excuteJS = function (args) {
try {
const params = JSON.parse(args);
eventBus.emit<NativeInvokeFuncParams>(GEEK_NATIVE_NAME, params);
} catch (error) {
eventBus.emit<NativeInvokeFuncParams>(GEEK_NATIVE_NAME, args);
}
};
export const sendNativeMessage = (data: { type: string; data?: any; __callback__?: string }) => {
if (isAndroid()) {
window.ReactNativeWebView &&
window.ReactNativeWebView.onMessage &&
window.ReactNativeWebView.onMessage(JSON.stringify(data));
}
window.ReactNativeWebView &&
window.ReactNativeWebView.postMessage &&
window.ReactNativeWebView.postMessage(JSON.stringify(data));
};
type ListenerType = (this: ComponentInternalInstance | null, ...arg: any[]) => any;
function useNativeBridge(
eventType: string,
listener: ListenerType
): [typeof sendNativeMessage, typeof eventBus];
function useNativeBridge(eventMap: {
[key: string]: ListenerType;
}): [typeof sendNativeMessage, typeof eventBus];
function useNativeBridge(
eventTypeOrEventMap: string | { [key: string]: ListenerType },
listener?: ListenerType
): [typeof sendNativeMessage, typeof eventBus] {
const _listener = function (this: ComponentInternalInstance | null, arg?: NativeInvokeFuncParams) {
if (!arg) return;
const { method, data } = arg;
if (typeof eventTypeOrEventMap === "string") {
if (eventTypeOrEventMap === method && listener) {
listener.apply(this, [data]);
}
} else if (typeof eventTypeOrEventMap[method] === "function") {
eventTypeOrEventMap[method].apply(this, [data]);
}
};
let fn:
| ((this: ComponentInternalInstance | null, arg?: NativeInvokeFuncParams) => void)
| null = null;
onMounted(() => {
fn = _listener.bind(getCurrentInstance());
eventBus.on<NativeInvokeFuncParams>(GEEK_NATIVE_NAME, fn);
});
onBeforeUnmount(() => {
if (fn) {
eventBus.off<NativeInvokeFuncParams>(GEEK_NATIVE_NAME, fn);
}
});
return [sendNativeMessage, eventBus];
}
export { useNativeBridge };
const INVOKE_NATIVE_METHOD_TIMEOUT = 10000;
function invokeNativeMethod<T = any, P = any>(arg: { type: string; data?: P }): Promise<T> {
return new Promise((resolve, reject) => {
const callbackName = `${arg.type}_callback_${Math.random()}`.replace(/\./, "");
const timer = setTimeout(() => {
reject(new Error(`invoke ${arg.type} timeout`));
eventBus.off(GEEK_NATIVE_NAME, onCallback);
}, INVOKE_NATIVE_METHOD_TIMEOUT);
eventBus.on(GEEK_NATIVE_NAME, onCallback);
function onCallback(params?: NativeInvokeFuncParams) {
if (params?.method === callbackName) {
clearTimeout(timer);
if (params.error) {
reject(new Error(params.error));
} else {
resolve(params.data);
}
eventBus.off(GEEK_NATIVE_NAME, onCallback);
}
}
sendNativeMessage({ ...arg, __callback__: callbackName });
});
}
/**
* 微信登录
*/
export function bindWeChat() {
return invokeNativeMethod<{ code: string; userId: string }>({ type: "bindWechat" });
}
/**
* 打电话
*/
export function makeCall(phone: string) {
return invokeNativeMethod<null, string>({ type: "makecall", data: phone });
}
/* eslint-disable @typescript-eslint/no-explicit-any */
import { reactive, UnwrapRef, computed, ComputedRef } from "vue";
type PagingFuncRet<T = object> = {
list: T[] | null;
hasNextPage: boolean;
total: number;
};
type BasePagingParams = {
pageNum: number;
pageSize: number;
};
interface Paging<T = object> extends BasePagingParams {
list: T[];
isLoad: boolean;
loading: boolean;
refreshing: boolean;
hasNextPage: boolean;
error: null | string;
total: number;
}
export type PagingFunc<T = object, P = any> = (
arg: Partial<P> & BasePagingParams
) => Promise<PagingFuncRet<T>>;
export type UsePagingRet<T, P> = [
UnwrapRef<Paging<T>>,
(arg?: Partial<P>) => void,
(arg?: Partial<P>) => void,
{
isFinished: ComputedRef<boolean>;
finishText: ComputedRef<string>;
}
]
function usePaging<T = object, P = any>(
fn: PagingFunc<T, P>,
paramsFn?: () => Partial<P>
): UsePagingRet<T, P> {
const paging = reactive<Paging<T>>({
list: [],
isLoad: false,
pageNum: 1,
pageSize: 15,
loading: false,
refreshing: false,
hasNextPage: false,
error: null,
total: 0
});
const request = (isRefresh: boolean) => {
return async (arg: Partial<P> = {}) => {
if (paging.loading || paging.refreshing) return;
if (!isRefresh && !paging.hasNextPage) return;
if (isRefresh) {
paging.refreshing = true;
} else {
paging.loading = true;
}
const currentPage = isRefresh ? 1 : paging.pageNum + 1;
try {
const params = paramsFn ? paramsFn() : {};
const ret = await fn({
...arg,
...params,
pageNum: currentPage,
pageSize: paging.pageSize
});
if (Array.isArray(ret.list)) {
if (isRefresh) {
paging.list = ret.list as UnwrapRef<T[]>;
} else {
paging.list = paging.list.concat(ret.list as UnwrapRef<T[]>);
}
}
paging.total = ret.total;
paging.hasNextPage = ret.hasNextPage;
paging.pageNum = currentPage;
} catch (error) {
paging.error = error.message;
} finally {
if (isRefresh) {
paging.refreshing = false;
} else {
paging.loading = false;
}
paging.isLoad = true;
}
};
};
const loadMore = request(false);
const refresh = request(true);
const finishText = computed(() => {
const { total, isLoad, error } = paging;
if (!isLoad || error) return "";
if (total < 1) return "暂无相关数据";
if (total > 1) {
return "没有更多了";
}
return "";
});
const isFinished = computed(() => {
const { hasNextPage, error } = paging;
return !!error || !hasNextPage;
});
return [paging, loadMore, refresh, { finishText, isFinished }];
}
export { usePaging };
<template>
<van-dialog
v-model:show="showDialog"
:show-cancel-button="false"
:show-confirm-button="false"
:title="withdrawAccount ? '确认换绑微信' : '绑定微信'"
class="bind-wechat-dialog"
>
<i class="close" @click="$emit('update:show', false)"></i>
<p class="dangerous-dialog-tip">
{{ withdrawAccount ? "换绑后,将提现到新绑定的微信零钱中!" : "绑定微信后,才可进行提现!" }}
</p>
<div class="dialog-handle-btns">
<van-button type="default" round @click="$emit('update:show', false)">取消</van-button
><van-button
type="primary"
round
@click="bindWeiChatModal"
:disabled="binding"
:loading="binding"
loading-text="绑定中..."
>绑定微信</van-button
>
</div>
</van-dialog>
</template>
<script lang="ts">
import { defineComponent, ref, watchEffect } from "vue";
import { Dialog, Button, Toast } from "vant";
import { bindWeChat } from "@/util/use-native-bridge";
import { bindWeiChat } from "@/server/api/bonus";
export default defineComponent({
components: {
[Dialog.Component.name]: Dialog.Component,
[Button.name]: Button
},
props: {
show: Boolean,
withdrawAccount: String
},
emits: ["updateBonusAccount", "update:show"],
setup(props, context) {
const binding = ref(false);
const showDialog = ref(false);
watchEffect(() => {
showDialog.value = props.show;
});
const bindWeiChatModal = async () => {
binding.value = true;
try {
const params = await bindWeChat();
await bindWeiChat(params);
Toast("绑定成功");
context.emit("update:show", false);
context.emit("updateBonusAccount");
} catch (err) {
Toast("绑定失败");
} finally {
binding.value = false;
}
};
return { showDialog, bindWeiChatModal, binding };
}
});
</script>
<style lang="scss" scoped>
.dialog-handle-btns {
display: flex;
margin-top: 48px;
padding: 30px;
margin-bottom: 30px;
justify-content: space-between;
.van-button {
flex: 0.47;
font-size: 28px;
}
}
.dangerous-dialog-tip {
padding: 0 48px;
text-align: center;
line-height: 44px;
}
</style>
<template>
<div class="tab-add">
<pull-refresh-list v-slot="{ list }" :request="getBonusList" :params-fn="paramsFn">
<div v-for="item in list" :key="item.id" class="add-item">
<div class="flex">
<span>{{ item.bizTypeName }}</span>
</div>
<div class="flex">
<span class="gray">{{ item.creationTime }}</span>
<label class="desc-money">+¥{{ item.amountChange }}</label>
</div>
</div>
</pull-refresh-list>
</div>
</template>
<script lang="ts">
import { defineComponent, computed } from "vue";
import { useStore } from "vuex";
import { useRoute } from "vue-router";
import { getBonusList } from "@/server/api/bonus";
import PullRefreshList from "../components/pull-pefresh-list.vue";
export default defineComponent({
components: {
PullRefreshList
},
setup() {
const route = useRoute();
const store = useStore();
const bonusStoreState = computed(() => store.state.bonus);
const paramsFn = () => ({
studentId: route.query.studentId || bonusStoreState.value.studentId,
flowType: "ADD"
});
return { getBonusList, paramsFn };
}
});
</script>
<style lang="scss" scoped>
.tab-add {
:deep(.van-pull-refresh) {
min-height: calc(100vh - 80px);
}
}
.flex {
line-height: 47px;
display: flex;
justify-content: space-between;
}
.gray {
color: #bdc4d1;
font-size: 24px;
}
.add-item {
background: #fff;
margin: 26px 20px;
padding: 20px;
border-radius: 10px;
box-shadow: 0px 10px 20px 0px rgba(221, 221, 221, 0.3);
}
.desc-money {
color: #f1551e;
font-size: 28px;
font-weight: 600;
}
</style>
<template>
<van-tabs
color="#027AFF"
title-active-color="#027AFF"
title-inactive-color="#4C4E4F"
line-width="150"
:sticky="true"
v-model:active="currentTab"
>
<van-tab name="REDUCE" title="支出">
<BonusReduceList />
</van-tab>
<van-tab name="ADD" title="收入">
<BonusAddList />
</van-tab>
</van-tabs>
</template>
<script lang="ts">
import { defineComponent, ref } from "vue";
import { useRoute } from "vue-router";
import { Tab, Tabs, List, PullRefresh } from "vant";
import BonusReduceList from "./reduce.vue";
import BonusAddList from "./add.vue";
export default defineComponent({
components: {
[Tab.name]: Tab,
[Tabs.name]: Tabs,
[List.name]: List,
[PullRefresh.name]: PullRefresh,
BonusAddList,
BonusReduceList
},
setup() {
const route = useRoute();
const currentTab = ref(route.query.active || "REDUCE");
return { currentTab };
}
});
</script>
<template>
<div class="tab-reduce">
<pull-refresh-list v-slot="{ list }" :request="getBonusList" :params-fn="paramsFn">
<div v-for="item in list" :key="item.id" class="reduce-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="desc">
<li v-if="item.bizType === BizType.WITHDRAW" class="flex">
<span>申请时间:{{ item.withdrawApplyTime }}</span>
<label v-if="!item.withdrawPayTime" class="desc-money"
>-¥{{ item.amountChange }}</label
>
</li>
<li v-if="item.bizType === BizType.WITHDRAW && item.withdrawPayTime" class="flex">
<span>到账时间:{{ item.withdrawPayTime }}</span>
<label class="desc-money">-¥{{ item.amountChange }}</label>
</li>
<li v-if="item.bizType === BizType.ORDER">
<div v-for="(className, index) in item.className" :key="className + index">
{{ className }}
</div>
</li>
<li v-if="item.bizType === BizType.ORDER" class="flex">
<span>{{ item.schoolAreaName }}</span
><label v-if="item.bizType === BizType.ORDER" class="desc-money"
>-¥{{ item.amountChange }}</label
>
</li>
</ul>
</div>
</pull-refresh-list>
</div>
</template>
<script lang="ts">
import { defineComponent, computed } from "vue";
import { useStore } from "vuex";
import { useRoute } from "vue-router";
import { getBonusList } from "@/server/api/bonus";
import { FlowType, BizType } from "@/model/bonus/constant";
import PullRefreshList from "../components/pull-pefresh-list.vue";
export default defineComponent({
components: {
PullRefreshList
},
setup() {
const route = useRoute();
const store = useStore();
const bonusStoreState = computed(() => store.state.bonus);
const paramsFn = () => ({
studentId: route.query.studentId || bonusStoreState.value.studentId,
flowType: "REDUCE"
});
return { FlowType, BizType, getBonusList, paramsFn };
}
});
</script>
<style lang="scss" scoped>
.tab-reduce {
:deep(.van-pull-refresh) {
min-height: calc(100vh - 80px);
}
}
.flex {
line-height: 47px;
display: flex;
justify-content: space-between;
}
.gray {
color: #bdc4d1;
font-size: 24px;
}
.reduce-item {
background: #fff;
margin: 26px 20px;
padding: 20px;
border-radius: 10px;
box-shadow: 0px 10px 20px 0px rgba(221, 221, 221, 0.3);
li {
line-height: 47px;
}
}
.desc {
background: #f5faff;
padding: 20px;
color: #606263;
}
.desc-money {
color: #f1551e;
font-size: 28px;
font-weight: 600;
}
</style>
<template>
<van-pull-refresh :modelValue="paging.refreshing" @refresh="refresh">
<van-list :finished="isFinished" :finished-text="finishText" @load="loadMore">
<slot :list="paging.list"></slot>
<van-empty key="2" image="search" v-if="paging.error" :description="paging.error" />
<van-empty v-else-if="paging.isLoad && paging.total < 1" />
<div class="list-footer">
<van-loading v-if="paging.loading" color="#1989fa" />
</div>
</van-list>
</van-pull-refresh>
</template>
<script lang="ts">
import { defineComponent, onMounted, PropType } from "vue";
import { PullRefresh, List, Empty, Loading } from "vant";
import { PagingFunc, usePaging } from "@/util/use-paging";
export default defineComponent({
components: {
[List.name]: List,
[PullRefresh.name]: PullRefresh,
[Empty.name]: Empty,
[Loading.name]: Loading
},
props: {
request: {
type: Function as PropType<PagingFunc<object, any>>,
required: true
},
paramsFn: {
type: Function as PropType<() => Partial<any>>
}
},
setup(props) {
const [paging, loadMore, refresh, helpers] = usePaging(props.request, props.paramsFn);
onMounted(refresh);
return { ...helpers, paging, loadMore, refresh };
}
});
</script>
<style lang="scss" scoped>
.list-footer {
display: flex;
justify-content: center;
}
</style>
.bonus {
padding: 30px;
:deep(.van-button) {
&.withdraw-detail-btn {
height: 48px;
line-height: 48px;
background-color: inherit;
padding: 0 24px;
color: rgba(255, 255, 255, 0.8);
border: 2px solid rgba(255, 255, 255, 0.5);
}
}
&-account {
padding: 30px;
color: #fff;
background: url("~@/assets/images/bonus/account-bg.png") no-repeat;
background-size: 100% 100%;
margin-bottom: 16px;
&-money {
margin: 28px 0 70px;
.money-desc {
font-size: 72px;
font-weight: 600;
.frozen {
background: url("~@/assets/images/bonus/frozen.png") no-repeat;
background-size: 100% 100%;
font-size: 26px;
display: inline-block;
width: 117px;
height: 88px;
line-height: 76px;
text-align: center;
position: absolute;
top: -40px;
right: -100px;
}
}
}
&-status {
text-align: center;
.van-col {
display: flex;
flex-direction: column;
justify-content: center;
label {
opacity: 0.5;
}
span {
font-size: 32px;
}
}
}
}
.bind-wechat {
margin-bottom: 16px;
border-radius: 9px;
justify-content: space-between;
:deep(.van-cell__title),
:deep(.van-cell__value) {
flex: initial;
}
.van-button {
height: 56px;
width: 160px;
}
}
.withdrawable-money {
border-radius: 9px;
justify-content: space-between;
:deep(.van-cell__title),
:deep(.van-cell__value) {
flex: initial;
}
.van-button {
height: 56px;
width: 120px;
}
}
.bonus-record {
margin-top: 40px;
color: #484c4f;
.van-row {
padding: 0 20px;
margin-bottom: 24px;
.tip {
position: relative;
font-weight: 550;
font-size: 30px;
&::after {
content: "";
display: block;
height: 32px;
width: 7px;
background: #027aff;
position: absolute;
border-radius: 2px;
left: 6px;
top: 3px;
}
}
.tip-money {
font-size: 28px;
}
}
}
:deep(.bonus-rule-dialog),
:deep(.bind-wechat-dialog) {
overflow: initial;
.close {
width: 44px;
height: 44px;
display: inline-block;
background: url("~@/assets/images/bonus/close.png") no-repeat;
background-size: 100% 100%;
position: absolute;
right: 2px;
top: -78px;
}
.van-dialog__header {
background: linear-gradient(213deg, #05b2ff 0%, #027aff 100%);
padding: 23px 0;
color: #fff;
font-weight: bold;
font-size: 36px;
border-top-left-radius: 16px;
border-top-right-radius: 16px;
}
}
:deep(.bonus-rule-dialog) {
&.van-dialog {
top: 50%;
width: 622px;
}
.bonus-rule-list {
padding: 42px 51px 0 51px;
color: #565858;
li {
line-height: 48px;
margin: 10px 0;
font-size: 26px;
}
}
}
.dialog-handle-btns {
display: flex;
margin-top: 48px;
padding: 30px;
margin-bottom: 30px;
justify-content: space-between;
.van-button {
flex: 0.47;
font-size: 28px;
}
}
.dangerous-dialog-tip {
padding: 0 48px;
text-align: center;
line-height: 44px;
}
}
\ No newline at end of file
<template>
<div class="bonus">
<div class="bonus-account">
<van-row align="center" class="bonus-account-title">
<van-col span="12" style="opacity: 0.5;"
><i class="iconfont icon-qiandai">&nbsp;</i><span>账户余额(元)</span></van-col
>
<van-col span="12" style="text-align: right" @click="showWithdrawRules = true"
><span>提现规则</span>&nbsp;<i class="iconfont icon-tishi"></i
></van-col>
</van-row>
<van-row class="bonus-account-money" align="center">
<van-col span="12" class="money-desc">
<span style="position: relative"
>¥{{ bonusAccount?.balanceTotal.toFixed(2) || 0.0 }}
<label
class="frozen"
v-if="bonusAccount?.status && bonusAccount?.status === BonusAccountStatus.FREEZE"
>冻结
</label></span
>
</van-col>
<van-col span="12" style="text-align: right"
><van-button
round
class="withdraw-detail-btn"
size="small"
type="primary"
to="bonusDetail"
>明细</van-button
></van-col
>
</van-row>
<van-row class="bonus-account-status">
<van-col span="8">
<label>累计收入</label>
<span>¥{{ bonusAccount?.addTotal.toFixed(2) || 0.0 }}</span>
</van-col>
<van-col span="8">
<label>累计提现</label>
<span>¥{{ bonusAccount?.withdrawedTotal.toFixed(2) || 0.0 }}</span>
</van-col>
<van-col span="8">
<label>提现中</label>
<span>¥{{ bonusAccount?.withdrawing.toFixed(2) || 0.0 }}</span>
</van-col>
</van-row>
</div>
<van-cell
center
:title="`微信(${bonusAccount?.withdrawAccount || '未绑定'})`"
size="large"
class="bind-wechat"
:border="false"
>
<van-button
color="#39BF17"
:plain="bonusAccount?.withdrawAccount ? true : false"
round
size="small"
@click="bindWeiChatOrUnbind"
>{{ bonusAccount?.withdrawAccount ? "换绑微信" : "绑定微信" }}</van-button
>
</van-cell>
<van-cell
center
:title="`今日可提现金额:¥${bonusAccount?.withdrawableTotal.toFixed(2) || 0.0}`"
size="large"
class="withdrawable-money"
:border="false"
>
<van-button color="#F1551E" round size="small" @click="withdraw">提现</van-button>
</van-cell>
<div class="bonus-record">
<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"
>总计:{{ bonusAccount?.withdrawedTotal.toFixed(2) || 0.0 }}元&nbsp;</van-col
>
</van-row>
<WithdrawList />
</div>
<!-- 规则弹窗 -->
<WithdrawRulesDialog v-model:show="showWithdrawRules" />
<!-- 绑定微信弹窗 -->
<BindWXDialog
v-model:show="showBindWx"
:withdraw-account="bonusAccount?.withdrawAccount"
@update-bonus-account="getBonusAccountReq"
/>
<!-- 奖励金账户状态弹窗 -->
<WithdrawableDialog v-model:show="showDangerous" :err-code="bonusAccount?.errCode" />
</div>
</template>
<script lang="ts">
import { computed, defineComponent, onMounted, reactive, toRefs } from "vue";
import { useRoute, useRouter } from "vue-router";
import { useStore } from "vuex";
import { Button, Col, Row, Cell, Loading, Toast } from "vant";
import { BonusAccountResponse } from "@/model/bonus";
import { BonusAccountStatus, ErrCode } from "@/model/bonus/constant";
import { bindWeChat, useNativeBridge } from "@/util/use-native-bridge";
import { bindWeiChat, getBonusAccount } from "@/server/api/bonus";
import WithdrawList from "./withdraw-list.vue";
import WithdrawRulesDialog from "./withdraw-rules-dialog.vue";
import WithdrawableDialog from "./withdrawable-dialog.vue";
import BindWXDialog from "./bind-w-x-dialog.vue";
interface BonusState {
bonusAccount: BonusAccountResponse | null;
[key: string]: unknown;
}
const Bonus = defineComponent({
components: {
[Button.name]: Button,
[Col.name]: Col,
[Row.name]: Row,
[Cell.name]: Cell,
[Loading.name]: Loading,
WithdrawList,
WithdrawRulesDialog,
WithdrawableDialog,
BindWXDialog
},
setup() {
const route = useRoute();
const router = useRouter();
const store = useStore();
const { studentId, token, userId } = route.query;
const bonusStoreState = computed(() => store.state.bonus);
store.commit("bonus/saveStudentId", studentId);
store.commit("bonus/saveToken", token);
store.commit("bonus/saveUserId", userId);
const [sendNativeMessage] = useNativeBridge("test", () => {
//
});
const state = reactive<BonusState>({
showWithdrawRules: false,
showBindWx: false,
showDangerous: false,
bonusAccount: null,
BonusAccountStatus
});
// 获取奖励金信息
const getBonusAccountReq = async () => {
Toast.loading({
duration: 0,
message: "加载中..."
});
try {
state.bonusAccount = await getBonusAccount(bonusStoreState.value.studentId);
} finally {
Toast.clear();
}
};
onMounted(() => {
const message = {
type: "title",
data: "我的奖励金"
};
sendNativeMessage(message);
getBonusAccountReq();
});
const withdraw = () => {
if (!state.bonusAccount?.errCode) {
// 都正常的状态
router.push({
name: "withdraw",
params: {
withdrawableTotal: state.bonusAccount?.withdrawableTotal || 0,
withdrawAccount: state.bonusAccount?.withdrawAccount || "",
withdrawAccountId: state.bonusAccount?.withdrawAccountId || ""
}
});
} else if (state.bonusAccount?.errCode === ErrCode.NOT_BIND) {
state.showBindWx = true;
} else {
state.showDangerous = true;
}
};
// 绑定或者换邦
const bindWeiChatOrUnbind = async () => {
// 已经绑定微信
if (state.bonusAccount?.withdrawAccount) {
state.showBindWx = true;
return false;
}
try {
const params = await bindWeChat();
await bindWeiChat(params);
getBonusAccountReq();
Toast("绑定成功");
} catch {
Toast("绑定失败");
}
};
return {
...toRefs(state),
withdraw,
bindWeiChatOrUnbind,
bonusStoreState,
getBonusAccountReq
};
}
});
export default Bonus;
</script>
<style lang="scss" scoped>
@import "./index.scss";
</style>
<template>
<pull-refresh-list v-slot="{ list }" :request="getWithdrawList" :params-fn="paramsFn">
<div class="withdraw-list" v-for="item in list" :key="item.id">
<div class="header">
<div class="header-status">
<i
class="iconfont"
:class="
item.status === WithdrawStatus.WITHDRAWING
? 'icon-shijian'
: item.status === WithdrawStatus.RECEIVED
? 'icon-jindutiaoqiandai'
: 'icon-xiazaishibai'
"
:style="{
color:
item.status === WithdrawStatus.WITHDRAWING
? '#46BB36'
: item.status === WithdrawStatus.RECEIVED
? '#027AFF'
: '#F1551E'
}"
></i>
<span>{{
item.status === WithdrawStatus.WITHDRAWING
? "提现中"
: item.status === WithdrawStatus.RECEIVED
? "提现成功"
: "提现失败"
}}</span>
<label v-if="item.status === WithdrawStatus.WITHDRAWING">请耐心等候~</label>
</div>
<p class="apply-money">
{{ item.status === WithdrawStatus.RECEIVED ? "-" : "" }}¥{{
item.withdrawAmount.toFixed(2)
}}
</p>
</div>
<ul class="withdraw-list-detail">
<li>微信提现:{{ item.accountName }}</li>
<li>申请时间:{{ item.withdrawApplyTime }}</li>
<li v-if="item.status === WithdrawStatus.WITHDRAWING">
预计时间:{{ item.expectedPayTime }}
</li>
<li v-if="item.status === WithdrawStatus.RECEIVED">到账时间:{{ item.withdrawPayTime }}</li>
<li v-if="item.status === WithdrawStatus.FAILED">失败时间:{{ item.failTime }}</li>
<li v-if="item.status === WithdrawStatus.FAILED">失败原因:{{ item.reason }}</li>
</ul>
</div>
</pull-refresh-list>
</template>
<script lang="ts">
import { defineComponent, computed } from "vue";
import { useStore } from "vuex";
import { getWithdrawList } from "@/server/api/bonus";
import { WithdrawStatus } from "@/model/bonus/constant";
import PullRefreshList from "./components/pull-pefresh-list.vue";
export default defineComponent({
components: {
PullRefreshList
},
setup() {
const store = useStore();
const bonusStoreState = computed(() => store.state.bonus);
const paramsFn = () => ({
studentId: bonusStoreState.value.studentId
});
return { WithdrawStatus, getWithdrawList, paramsFn };
}
});
</script>
<style lang="scss" scoped>
.withdraw-list {
background: #fff;
margin-bottom: 16px;
padding: 20px 19px;
border-radius: 10px;
box-shadow: 0px 10px 20px 0px rgba(221, 221, 221, 0.3);
.header {
display: flex;
justify-content: space-between;
align-items: center;
.apply-money {
color: #f1551e;
font-weight: 550;
}
}
.header-status {
display: flex;
align-items: center;
i {
font-size: 54px;
margin-right: 20px;
}
span {
margin-right: 30px;
font-weight: 600;
}
label {
color: #a6a8aa;
font-size: 28px;
}
}
&-detail {
background: #f5faff;
opacity: 0.9;
padding: 20px;
border-radius: 10px;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #484c4f;
li {
line-height: 1.6em;
}
}
}
</style>
<template>
<van-dialog
v-model:show="showDialog"
title="提现规则说明"
:show-cancel-button="false"
:show-confirm-button="false"
class="bonus-rule-dialog"
>
<i class="close" @click="$emit('update:show', false)"></i>
<ul class="bonus-rule-list">
<li>1.当前只有转介绍收入可以在线提现;</li>
<li>2.提现前,确保已经绑定了微信,且微信已经实名认证;</li>
<li>3.每个学生,单日累计提现金额不超过{{ studentDailyWithdrawLimit }}元;</li>
<li>4.每个家长,单日累计提现金额不超过{{ userDailyWithdrawLimit }}元;</li>
<li>5.系统一般都是“秒到账”,具体到账时间, 请以系统提示为准;</li>
<li>6.如需帮助请联系:400—8777389!</li>
</ul>
<div class="dialog-handle-btns">
<van-button type="default" round @click="phoneCall">电话咨询</van-button
><van-button type="primary" round @click="$emit('update:show', false)">我知道了</van-button>
</div>
</van-dialog>
</template>
<script lang="ts">
import { defineComponent, ref, watchEffect, reactive, toRefs, computed, onMounted } from "vue";
import { useStore } from "vuex";
import { Dialog, Button } from "vant";
import { makeCall } from "@/util/use-native-bridge";
import { getWithdrawRisk } from "@/server/api/bonus";
export default defineComponent({
components: {
[Dialog.Component.name]: Dialog.Component,
[Button.name]: Button
},
props: {
show: Boolean
},
emits: ["update:show"],
setup(props) {
const store = useStore();
const bonusStoreState = computed(() => store.state.bonus);
const state = reactive({
studentDailyWithdrawLimit: 0,
userDailyWithdrawLimit: 0
});
const showDialog = ref(false);
watchEffect(() => {
showDialog.value = props.show;
});
const phoneCall = () => {
makeCall("400—8777389");
};
const getWithdrawRiskReq = async () => {
const { studentDailyWithdrawLimit, userDailyWithdrawLimit } = await getWithdrawRisk(
bonusStoreState.value.studentId
);
state.studentDailyWithdrawLimit = studentDailyWithdrawLimit;
state.userDailyWithdrawLimit = userDailyWithdrawLimit;
};
onMounted(getWithdrawRiskReq);
return { showDialog, phoneCall, ...toRefs(state) };
}
});
</script>
<style lang="scss" scoped>
.bonus-rule-dialog {
&.van-dialog {
top: 50%;
width: 622px;
}
.bonus-rule-list {
padding: 42px 51px 0 51px;
color: #565858;
li {
line-height: 48px;
margin: 10px 0;
font-size: 26px;
}
}
}
.dialog-handle-btns {
display: flex;
margin-top: 48px;
padding: 30px;
margin-bottom: 30px;
justify-content: space-between;
.van-button {
flex: 0.47;
font-size: 28px;
}
}
.dangerous-dialog-tip {
padding: 0 48px;
text-align: center;
line-height: 44px;
}
</style>
.bonus-withdraw {
padding: 146px 32px 0;
background: #fff;
min-height: 100vh;
.info {
text-align: center;
}
.input {
display: flex;
align-items: center;
justify-content: center;
height: 84px;
line-height: 84px;
position: relative;
&::after {
width: 430px;
height: 2px;
background: #f1f4f9;
content: "";
display: block;
position: absolute;
bottom: 0;
}
.money-symbol {
width: 62px;
font-size: 60px;
font-weight: 600;
display: inline-block;
margin-right: 30px;
color: #191919;
}
&-field {
width: 328px;
display: flex;
justify-content: center;
display: inline-block;
padding: 0;
position: relative;
right: 40px;
:deep(.van-field__body) {
font-size: 60px;
font-weight: 600;
color: #191919;
}
::-webkit-input-placeholder {
/* Chrome/Opera/Safari */
font-size: 30px;
color: #9fa1a3;
// opacity: 0.5;
}
::-moz-placeholder {
/* Firefox 19+ */
font-size: 30px;
color: #9fa1a3;
}
:-ms-input-placeholder {
/* IE 10+ */
font-size: 30px;
color: #9fa1a3;
}
:-moz-placeholder {
/* Firefox 18- */
font-size: 30px;
color: #9fa1a3;
}
}
&-valid {
font-size: 24px;
height: 33px;
line-height: 33px;
color: #484c4f;
margin-top: 19px;
margin-bottom: 56px;
}
&-tip {
display: inline-block;
align-items: center;
background: #f7f7f7;
font-size: 22px;
border-radius: 18px;
vertical-align: middle;
height: 36px;
margin-bottom: 80px;
vertical-align: middle;
color: #9fa1a3;
vertical-align: middle;
line-height: 36px;
text-align: left;
padding: 0 8px;
align-items: center;
i {
margin-right: 8px;
}
}
.all {
width: 107px;
height: 56px;
line-height: 56px;
position: absolute;
right: 0;
}
}
.van-cell.van-cell-tip {
padding-left: 2px;
padding-right: 2px;
border-top: 1px solid #ececec;
border-bottom: 1px solid #ececec;
justify-content: space-between;
:deep(.van-cell__title),
:deep(.van-cell__value) {
flex: initial;
}
.slot-value {
display: flex;
align-items: center;
.wechat {
width: 52px;
height: 52px;
margin-right: 3px;
}
}
}
.handle-btn {
padding: 0 72px;
margin-top: 107px;
.title {
font-size: 36px;
line-height: 50px;
}
.tips {
opacity: 0.5;
line-height: 32px;
}
.van-button {
height: 100px;
border-radius: 51px;
}
}
:deep .dialog {
overflow: initial;
.close {
width: 44px;
height: 44px;
display: inline-block;
background: url("~@/assets/images/bonus/close.png") no-repeat;
background-size: 100% 100%;
position: absolute;
right: 2px;
top: -78px;
}
}
}
\ No newline at end of file
<template>
<div class="bonus-withdraw">
<ul class="info">
<li class="input">
<span class="money-symbol">¥</span>
<van-field
v-model="withdrawAmount"
type="number"
format-trigger="onBlur"
:formatter="formatter"
placeholder="请输入金额"
clearable
:border="false"
input-align="center"
class="input-field"
></van-field>
<van-button
class="all"
size="small"
type="primary"
round
color="#F1551E"
@click="withdrawAmount = withdrawableTotal"
>全部</van-button
>
</li>
<li class="input-valid">今日可提现金额¥{{ withdrawableTotal }}元</li>
<li class="input-tip">
<i class="iconfont icon-wenhao"></i>
<span>单日累计提现不超过{{ studentDailyWithdrawLimit }}元!</span>
</li>
</ul>
<van-cell class="van-cell-tip" title="提现至" size="large" :border="false">
<div class="slot-value">
<img class="wechat" src="~@/assets/images/bonus/wechat.png" alt="微信图片" />
<span class="van-ellipsis">微信名字:{{ withdrawAccount }}</span>
</div>
</van-cell>
<div class="handle-btn">
<van-button round type="primary" size="large" color="#F1551E" block @click="withdrawSubmit">
<div class="title">确认提现</div>
<div class="tips">预计24小时内到账</div>
</van-button>
</div>
<!-- 提现弹窗 -->
<WithdrawDialog
v-model:show="showWithdraw"
:withdraw-amount="Number(withdrawAmount)"
:withdraw-account="withdrawAccount"
@withdraw-success="withdrawSuccess"
/>
<!-- 提现成功弹窗 -->
<WithdrawSuccessDialog
v-model:show="showWithdrawSuccess"
:withdraw-response="withdrawResponse"
/>
</div>
</template>
<script lang="ts">
import { computed, defineComponent, onMounted, reactive, toRefs } from "vue";
import { useRoute } from "vue-router";
import { useStore } from "vuex";
import { Button, Cell, Dialog, Field, Toast } from "vant";
import { sendNativeMessage } from "@/util/use-native-bridge";
import { getWithdrawRisk } from "@/server/api/bonus";
import { WithdrawResponse } from "@/model/bonus";
import WithdrawSuccessDialog from "./withdraw-success-dialog.vue";
import WithdrawDialog from "./withdraw-dialog.vue";
interface State {
WithdrawResponse?: WithdrawResponse | object;
withdrawAccountId: string;
[key: string]: number | string | boolean | any;
}
const Withdraw = defineComponent({
components: {
[Button.name]: Button,
[Cell.name]: Cell,
[Field.name]: Field,
[Dialog.Component.name]: Dialog.Component,
WithdrawSuccessDialog,
WithdrawDialog
},
setup() {
const route = useRoute();
const store = useStore();
const bonusStoreState = computed(() => store.state.bonus);
const state = reactive<State>({
withdrawAmount: 0,
withdrawableTotal: 0,
showWithdraw: false,
showWithdrawSuccess: false,
withdrawAccount: "",
withdrawAccountId: "",
withdrawResponse: {},
studentDailyWithdrawLimit: 0 // 学生单日提现上限
});
const { withdrawableTotal, withdrawAccount, withdrawAccountId } = route.params;
state.withdrawableTotal = Number(withdrawableTotal);
state.withdrawAccount = withdrawAccount as string;
state.withdrawAccountId = withdrawAccountId as string;
const formatter = value => {
if (value <= 0) return "";
if (value > state.withdrawableTotal) {
Toast(`今日可提现金额为:${state.withdrawableTotal}元`);
return state.withdrawableTotal.toFixed(2);
}
return value && Number(value).toFixed(2);
};
// 确认提现
const withdrawSubmit = () => {
if (!state.withdrawAmount) {
Toast("请输入提现金额");
return false;
}
if (Number(state.withdrawAmount) < 1) {
Toast("金额必须大于等于1元");
return false;
}
state.showWithdraw = true;
};
// 提现成功
const withdrawSuccess = data => {
state.withdrawResponse = data;
state.showWithdrawSuccess = true;
};
// 获取风控值
const getWithdrawRiskReq = async () => {
const { studentDailyWithdrawLimit } = await getWithdrawRisk(bonusStoreState.value.studentId);
state.studentDailyWithdrawLimit = studentDailyWithdrawLimit;
};
onMounted(() => {
const message = {
type: "title",
data: "提现"
};
sendNativeMessage(message);
getWithdrawRiskReq();
});
return {
...toRefs(state),
formatter,
withdrawSubmit,
withdrawSuccess
};
}
});
export default Withdraw;
</script>
<style lang="scss" scoped>
@import "./index.scss";
</style>
<template>
<div class="withdraw-validate">
<van-dialog
v-model:show="showDialog"
:show-cancel-button="false"
:show-confirm-button="false"
class="dialog"
>
<i class="close" @click="closeWithdraw"></i>
<ul class="dialog-header">
<li>提现至微信账户:{{ withdrawAccount }}</li>
<li class="dialog-money van-ellipsis">¥{{ withdrawAmount }}</li>
</ul>
<ul class="dialog-field">
<li class="dialog-field-input">
<van-field
v-model="smsVerifyCode"
type="digit"
label-width="0"
placeholder="请输入验证码"
>
</van-field>
<van-button
type="primary"
color="#027AFF"
:disabled="smsVerifyPass"
@click="getSmsVerifyCode"
>{{ showTime }}</van-button
>
</li>
<li class="dialog-field-tip" v-if="mobileTip">今日可提现已将验证码发送至{{ mobileTip }}</li>
</ul>
<div class="handle-btns">
<van-button
:loading="withdrawing"
:disabled="withdrawing || !tencentCaptchPass || !smsVerifyCode"
loading-text="提现中..."
round
type="primary"
size="large"
block
color="#027AFF;"
@click="withdrawReal"
>确定</van-button
>
<van-button
plain
round
type="primary"
size="large"
block
color="#027AFF;"
style="border: none"
@click="closeWithdraw"
>关闭</van-button
>
</div>
</van-dialog>
</div>
</template>
<script lang="ts">
declare const TencentCaptcha: any;
import { defineComponent, ref, watchEffect, reactive, computed, toRefs } from "vue";
import { useRoute } from "vue-router";
import { useStore } from "vuex";
import { Dialog, Button, Field, Toast, Cell } from "vant";
import { checkCaptcha, withdraw } from "@/server/api/bonus";
import { countDown } from "@/util/timer";
import appId from "@/util/index";
interface TencentCaptchaResponse {
ret: number;
ticket: string;
appid: string;
bizState: unknown;
randstr: string;
}
interface State {
timeoutParams?: { timeCounter: number | undefined };
[key: string]: number | string | boolean | any;
}
export default defineComponent({
components: {
[Dialog.Component.name]: Dialog.Component,
[Button.name]: Button,
[Field.name]: Field,
[Cell.name]: Cell
},
props: {
show: Boolean,
withdrawAmount: {
type: Number,
default: 0
}, // 提现金额
withdrawAccount: String // 微信账户
},
setup(props, context) {
const route = useRoute();
const store = useStore();
const bonusStoreState = computed(() => store.state.bonus);
const state = reactive<State>({
withdrawing: false,
tencentCaptchPass: false, // 图形验证码是否通过
smsVerifyPass: false,
mobileTip: "",
showTime: "获取验证码",
smsVerifyCode: "" // 验证码
});
const showDialog = ref(false);
watchEffect(() => {
showDialog.value = props.show;
});
// 获取验证码
const getSmsVerifyCode = () => {
const captcha = new TencentCaptcha(
appId,
async (res: TencentCaptchaResponse) => {
const { ret, randstr, ticket } = res;
if (ret === 0) {
state.tencentCaptchPass = true;
state.smsVerifyPass = true;
try {
const data = await checkCaptcha({ randStr: randstr, ticket });
Toast("发送验证码成功");
state.mobileTip = data;
state.timeoutParams = countDown(60, 1000, (time: number) => {
time === 0
? (state.showTime = `获取验证码`)
: (state.showTime = `${time} 后再获取`);
if (time === 0) {
state.smsVerifyPass = false;
}
});
} catch {
Toast("发送验证码失败,请重试");
state.smsVerifyPass = false;
}
}
},
{
needFeedBack: false
}
);
captcha.show();
};
// 提现
const withdrawReal = async () => {
if (!state.smsVerifyCode) {
Toast("请输入验证码");
return;
}
state.withdrawing = true;
try {
const params = {
studentId: bonusStoreState.value.studentId,
smsVerifyCode: state.smsVerifyCode,
withdrawAmount: props.withdrawAmount,
withdrawAccountId: route.params.withdrawAccountId as string
};
const data = await withdraw(params);
context.emit("update:show", false);
context.emit("withdrawSuccess", data);
} catch (err) {
Toast(err);
} finally {
state.withdrawing = false;
}
};
// 重置参数
const resetParams = () => {
if (state.timeoutParams && state.timeoutParams.timeCounter) {
clearTimeout(state.timeoutParams.timeCounter);
}
state.tencentCaptchPass = false;
state.smsVerifyPass = false;
state.smsVerifyCode = "";
state.mobileTip = "";
state.showTime = "获取验证码";
};
const closeWithdraw = () => {
context.emit("update:show", false);
resetParams();
};
return { showDialog, ...toRefs(state), getSmsVerifyCode, withdrawReal, closeWithdraw };
}
});
</script>
<style lang="scss" scoped>
.withdraw-validate {
:deep .dialog {
padding: 48px;
color: #fff;
width: 622px;
&-header {
background: url("~@/assets/images/bonus/withdraw-bg.png") no-repeat;
background-size: 100%;
padding: 32px 30px;
}
.dialog-money {
font-size: 60px;
font-weight: 600;
margin: 40px 0 47px;
}
&-field {
margin-top: 80px;
&-input {
display: flex;
align-items: center;
.van-cell {
flex: 1;
padding: 0;
.van-field__control {
padding: 22px 0 22px 45px;
border: 2px solid #dcdee0;
border-right: none;
border-radius: 8px 0px 0px 8px;
height: 80px;
width: 306px;
}
}
.van-button {
width: 220px;
height: 80px;
background: #027aff;
border-radius: 0px 8px 8px 0px;
font-size: 26px;
box-sizing: border-box;
}
}
&-tip {
text-align: center;
color: #484c4f;
font-size: 24px;
margin-top: 24px;
}
}
.handle-btns {
margin-top: 64px;
.van-button {
height: 100px;
}
}
}
}
</style>
<template>
<div class="withdraw-success">
<van-dialog
v-model:show="showDialog"
:show-cancel-button="false"
:show-confirm-button="false"
class="dialog"
>
<i class="close" @click="goBack"></i>
<ul class="dialog-text">
<li>提现申请成功!</li>
<li>提现金额:</li>
<li>¥{{ withdrawResponse?.amount || 0 }}</li>
<li>提现至微信</li>
<li>{{ withdrawResponse?.withdrawAccount }}</li>
<li>预计到账时间</li>
<li>{{ withdrawResponse?.expectedPayTime }}</li>
</ul>
<div class="dialog-btns">
<van-button round type="primary" size="large" @click="goBack">确定</van-button>
</div>
</van-dialog>
</div>
</template>
<script lang="ts">
import { defineComponent, ref, watchEffect } from "vue";
import { useRouter } from "vue-router";
import { Dialog, Button } from "vant";
export default defineComponent({
components: {
[Dialog.Component.name]: Dialog.Component,
[Button.name]: Button
},
props: {
show: Boolean,
withdrawResponse: Object
},
setup(props) {
const router = useRouter();
const showDialog = ref(false);
watchEffect(() => {
showDialog.value = props.show;
});
const goBack = () => {
router.back();
};
return { showDialog, goBack };
}
});
</script>
<style lang="scss" scoped>
.withdraw-success {
:deep .dialog {
padding: 60px 51px 35px;
background: url("~@/assets/images/bonus/withdraw-success.png") no-repeat;
background-size: 100% 100%;
height: 785px;
box-sizing: border-box;
font-size: 26px;
&-text {
line-height: 50px;
text-align: center;
li {
&:nth-of-type(1) {
font-size: 55px;
background: linear-gradient(360deg, #ef1237 0%, #fd7940 100%);
-webkit-background-clip: text;
color: transparent;
font-style: italic;
position: relative;
font-weight: bold;
margin-bottom: 24px;
line-height: 63px;
height: 63px;
&::after,
&::before {
content: "";
display: inline-block;
width: 63px;
height: 5px;
background: linear-gradient(270deg, #fdbd99 0%, rgba(255, 255, 255, 0) 100%);
position: absolute;
top: 50%;
}
&::before {
left: 0;
}
&::after {
background: linear-gradient(270deg, rgba(255, 255, 255, 0) 0%, #fdbd99 100%);
right: 0;
}
}
&:nth-of-type(2) {
font-size: 32px;
font-weight: 500;
margin-bottom: 16px;
}
&:nth-of-type(3) {
font-size: 64px;
font-family: DINAlternate-Bold, DINAlternate;
font-weight: bold;
color: #1a1a1a;
line-height: 63px;
background: linear-gradient(360deg, #ef1237 0%, #fd7940 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
margin-bottom: 39px;
}
&:nth-of-type(4),
&:nth-of-type(5) {
margin-bottom: 11px;
}
&:nth-of-type(4),
&:nth-of-type(6) {
font-size: 28px;
}
&:nth-of-type(6) {
margin-bottom: 7px;
}
&:nth-of-type(5),
&:nth-of-type(7) {
opacity: 0.8;
}
}
}
&-btns {
text-align: center;
.van-button {
margin-top: 100px;
padding: 0 100px;
height: 100px;
line-height: 100px;
width: 380px;
color: #f03d04;
border: none;
background: linear-gradient(to bottom, #ffeb8c, #fe9f56);
}
}
}
}
</style>
<template>
<van-dialog v-model:show="showDialog" :show-cancel-button="false" :show-confirm-button="false">
<p class="dangerous-dialog-tip">
{{ formatBonusTipTxt(errCode) }}
</p>
<div class="dialog-handle-btns">
<van-button type="default" round @click="$emit('update:show', false)">确定</van-button
><van-button type="primary" round @click="phoneCall">电话咨询</van-button>
</div>
</van-dialog>
</template>
<script lang="ts">
import { defineComponent, ref, watchEffect } from "vue";
import { Dialog, Button } from "vant";
import { makeCall } from "@/util/use-native-bridge";
import { formatBonusTipTxt } from "@/util/formatBonusTipTxt";
export default defineComponent({
components: {
[Dialog.Component.name]: Dialog.Component,
[Button.name]: Button
},
props: {
show: Boolean,
errCode: String
},
emits: ["update:show"],
setup(props) {
const showDialog = ref(false);
watchEffect(() => {
showDialog.value = props.show;
});
const phoneCall = () => {
makeCall("400—8777389");
};
return { showDialog, phoneCall, formatBonusTipTxt };
}
});
</script>
<style lang="scss" scoped>
.dialog-handle-btns {
display: flex;
margin-top: 48px;
padding: 30px;
margin-bottom: 30px;
justify-content: space-between;
.van-button {
flex: 0.47;
font-size: 28px;
}
}
.dangerous-dialog-tip {
padding: 0 48px;
text-align: center;
line-height: 44px;
}
</style>
<template>
<div>{{ count }}</div>
<button @click="emitTest">emit</button>
<button @click="emitTest2">测试</button>
</template>
<script lang="ts" setup>
import { ref } from "vue";
import { useNativeBridge } from "@/util/use-native-bridge";
import { Toast } from "vant";
const [sendNativeMessage, eventBus] = useNativeBridge({
onBindWechatChange(arg) {
console.log(this, arg);
}
});
useNativeBridge("onBindWechatChange", function(arg) {
console.log(this, arg, "bb");
});
const count = ref(1000);
const emitTest = () => {
eventBus.emit("GEEK_NATVIE_NAME", {
method: "onBindWechatChange",
data: {
hhh: 13213
}
});
count.value = count.value + 1;
};
const emitTest2 = () => {
eventBus.emit("GEEK_NATVIE_NAME", {
method: "title",
data: "我的体现计划"
});
};
</script>
<style></style>
<template>
<div>
<div v-if="paging.refreshing">refreshing</div>
<PullRefresh :modelValue="paging.refreshing" @refresh="onRefresh">
<List @load="loadMore" :modelValue="paging.loading" :finished="!paging.hasNextPage">
<div v-for="item in paging.list" class="item" :key="item.index">
{{ item.a }}
</div>
</List>
</PullRefresh>
<div v-if="paging.loading">loading</div>
<div v-if="paging.isLoad && !paging.hasNextPage">没有更多了</div>
</div>
</template>
<script lang="ts" setup>
import type { PagingFunc } from '@/util/use-paging';
import { usePaging } from "@/util/use-paging";
import { onMounted } from "vue";
import { PullRefresh, List } from 'vant';
type ListType = {
a: number;
index: number;
};
const fn: PagingFunc<ListType, { test: number }> = async (arg) => {
await new Promise(resolve => setTimeout(resolve, 1000));
console.log(arg)
return {
hasNextPage: arg.pageNum < 4,
total: 54,
list: new Array(20).fill(0).map((_, index) => ({
a: Math.random(),
index
}))
};
};
const [paging, loadMore, onRefresh] = usePaging(fn, () => ({ test: 1 }));
onMounted(() => {
onRefresh();
});
</script>
<style lang="scss">
.item {
height: 80px;
}
</style>
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"strict": true,
"jsx": "preserve",
"importHelpers": true,
"moduleResolution": "node",
"experimentalDecorators": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"sourceMap": true,
"baseUrl": ".",
"useDefineForClassFields": true,
"noImplicitAny": false,
"types": [
"webpack-env"
],
"paths": {
"@/*": [
"src/*"
]
},
"lib": [
"esnext",
"dom",
"dom.iterable",
"scripthost"
]
},
"include": [
"src/**/*.ts",
"src/**/*.tsx",
"src/**/*.vue",
"tests/**/*.ts",
"tests/**/*.tsx"
],
"exclude": [
"node_modules"
]
}
/* eslint-disable @typescript-eslint/no-var-requires */
const tsImportPluginFactory = require("ts-import-plugin");
const { merge } = require("webpack-merge");
module.exports = {
publicPath: "./",
parallel: process.env.NODE_ENV !== "production",
outputDir: "mall-webview",
productionSourceMap: false,
devServer: {
hot: true,
open: true,
https: false,
proxy: {
//配置跨域
"/mock": {
target: "http://192.168.44.114:4100",
ws: true,
changOrigin: true //允许跨域
},
"/service": {
target: "http://192.168.32.31",
ws: true,
changOrigin: true //允许跨域
},
"/api": {
target: "http://192.168.32.31",
ws: true,
changOrigin: true //允许跨域
}
}
},
chainWebpack: config => {
config.plugin(`html`).tap(args => {
const minify = args[0].minify;
args[0].minify = minify ? { ...minify, minifyJS: true } : minify;
return args;
});
config.module
.rule("ts")
.use("ts-loader")
.tap(options => {
options = merge(options, {
transpileOnly: true,
getCustomTransformers: () => ({
before: [
tsImportPluginFactory({
libraryName: "vant",
libraryDirectory: "es",
style: true
})
]
}),
compilerOptions: {
module: "es2015"
}
});
return options;
});
},
css: {
loaderOptions: {
postcss: {
plugins: [
require("postcss-plugin-px2rem")({
rootValue: 75,
propList: ["*"],
replace: true,
mediaQuery: false,
minPixelValue: 2,
exclude: /(node_module)/i
})
]
}
}
}
};
This source diff could not be displayed because it is too large. You can view the blob instead.
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