Commit d5254d3c authored by hewenhao's avatar hewenhao

Merge branch 'feature/2021_03_12_bonus' of…

Merge branch 'feature/2021_03_12_bonus' of https://dev.jiuaoedu.com/wykolor/GeekBonusH5 into feature/2021_03_12_bonus
parents 2c95129f 00d4ebd8
......@@ -57,7 +57,9 @@
"parserOptions": {
"ecmaVersion": 2020
},
"rules": {}
"rules": {
"@typescript-eslint/camelcase": "off"
}
},
"browserslist": [
"> 1%",
......
......@@ -4,6 +4,7 @@
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.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><%= htmlWebpackPlugin.options.title %></title>
......
import { createApp } from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";
import "./assets/style/normalize.css";
import "amfe-flexible";
createApp(App)
.use(store)
.use(router)
.mount("#app");
import { createApp } from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";
import "./assets/style/normalize.css";
import "amfe-flexible";
import nativeBridge from './util/nativeBridge'
createApp(App)
.use(store)
.use(router)
.use(nativeBridge)
.mount("#app");
......@@ -2,7 +2,7 @@
* @Author: wykolor
* @Date: 2021-03-23 11:44:35
* @Last Modified by: wykolor
* @Last Modified time: 2021-03-24 16:20:07
* @Last Modified time: 2021-03-26 15:38:13
*/
export interface PageParams {
......@@ -44,10 +44,13 @@ export interface BonusListParams extends PageParams {
export interface BonusAccountResponse {
status: string;
balance: number;
sumAdd: number;
sumWithdraw: number;
withdrawing: number;
balanceTotal: number;
addTotal: number;
withdrawedTotal: number;
withdrawAccount: string;
withdrawableTotal: number;
errCode: string;
}
export interface WithdrawListParams extends PageParams {
......
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")
}
];
const router = createRouter({
history: createWebHashHistory(),
routes
});
export default router;
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")
}
];
const router = createRouter({
history: createWebHashHistory(),
routes
});
export default router;
......@@ -20,12 +20,12 @@ export const getBonusList = (params: BonusListParams) => {
// 奖励金账户信息
export const getBonusAccount = (studentId: string) => {
return get<BonusAccountResponse>(`v1/marketingAccount/bonus/count`, { studentId });
return get<BonusAccountResponse>(`/mock/api-jksxb-app/v1/marketingAccount/bonus/count`, { studentId });
};
// 提现记录列表
export const getWithdrawList = (params: WithdrawListParams) => {
return post<Paging<WithdrawListResponse>>(`/v1/withdraw/query`, params);
return post<Paging<WithdrawListResponse>>(`/mock/api-jksxb-app/v1/withdraw/query`, params);
};
// 检验图形验证码
......
const bonus = {
namespaced: true,
state: () => ({
studentId: 12,
userId: "color"
studentId: 0,
token: "",
userId: 0
}),
getters: {
studentId: state => state.studentId + 1,
userName: state => state.userId + "wangyan",
studentFullName: state => state.studentId + state.userId
getters: {},
mutations: {
saveStudentId(state, payload) {
state.studentId = payload;
},
saveToken(state, payload) {
state.token = payload;
},
saveUserId(state, payload) {
state.userId = payload;
}
},
mutations: {},
actions: {}
};
......
/* 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;
/* 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;
......@@ -17,7 +17,7 @@ const isAndroid = () => {
return android;
};
window.$geek_excuteJS = function(args) {
window.$geek_excuteJS = function (args) {
try {
const params = JSON.parse(args);
eventBus.emit<NativeInvokeFuncParams>(GEEK_NATVIE_NAME, params);
......@@ -52,7 +52,7 @@ function useNativeBridge(
eventTypeOrEventMap: string | { [key: string]: ListenerType },
listener?: ListenerType
): [typeof sendNativeMessage, typeof eventBus] {
const _listener = function(this: ComponentInternalInstance | null, arg?: NativeInvokeFuncParams) {
const _listener = function (this: ComponentInternalInstance | null, arg?: NativeInvokeFuncParams) {
if (!arg) return;
const { method, data } = arg;
if (typeof eventTypeOrEventMap === "string") {
......
......@@ -14,7 +14,7 @@
v-model:loading="loading"
v-model:error="error"
:finished="finished"
finished-text="没有更多了"
finished-text="~我是有底线的~"
@load="onLoad"
>
<van-tab name="REDUCE" title="支出" class="bonus-detail-pay-list">
......
......@@ -10,9 +10,16 @@
></van-col>
</van-row>
<van-row class="bonus-account-money" align="center">
<van-col span="12" class="money-desc"
><span>¥{{ bonusAccount.balance }}</span></van-col
>
<van-col span="12" class="money-desc">
<span style="position: relative"
>¥{{ bonusAccount.balanceTotal }}
<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
style="border-color: #fff; width: 45%"
......@@ -28,11 +35,11 @@
<van-row class="bonus-account-status">
<van-col span="8">
<label>累计收入</label>
<span>¥{{ bonusAccount.sumAdd }}</span>
<span>¥{{ bonusAccount.addTotal }}</span>
</van-col>
<van-col span="8">
<label>累计提现</label>
<span>¥{{ bonusAccount.sumWithdraw }}</span>
<span>¥{{ bonusAccount.withdrawedTotal }}</span>
</van-col>
<van-col span="8">
<label>提现中</label>
......@@ -42,7 +49,7 @@
</div>
<van-cell
center
:title="`可提现金额:¥${bonusAccount.balance}`"
:title="`可提现金额:¥${bonusAccount.withdrawableTotal}`"
size="large"
style="border-radius: 0.3rem;"
:border="false"
......@@ -51,19 +58,18 @@
>提现</van-button
>
</van-cell>
<!-- -->
<div class="bouns-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.sumWithdraw }}元&nbsp;</van-col
>总计:{{ bonusAccount.withdrawedTotal }}元&nbsp;</van-col
>
</van-row>
<van-list
v-model:loading="state.loading"
:finished="state.finished"
finished-text="我是有底线的"
v-model:loading="loading"
:finished="finished"
finished-text="~我是有底线的~"
@load="onLoad"
>
<div class="bonus-record-item" v-for="item in withdrawList" :key="item.id">
......@@ -103,7 +109,6 @@
</div>
</van-list>
</div>
<!-- 规则弹窗 -->
<van-dialog
v-model:show="showDialog"
......@@ -154,81 +159,58 @@
<script lang="ts">
// eslint-disable-next-line @typescript-eslint/no-explicit-any
import { computed, defineComponent, reactive } from "vue";
import { Dialog, Button, Col, Row, Cell, List } from "vant";
import { BonusAccountResponse, WithdrawListResponse } from "@/model/bonus";
import { computed, defineComponent, reactive, toRefs } from "vue";
import { useRoute } from "vue-router";
import { useStore } from "vuex";
import { Dialog, Button, Col, Row, Cell, List } from "vant";
import { WithdrawListParams, WithdrawListResponse } from "@/model/bonus";
import { bonusModel } from "@/server/api";
import { BonusAccountStatus } from "@/model/bonus/constant";
interface BonusState {
withdrawList: WithdrawListResponse[];
[key: string]: unknown;
}
const Bonus = defineComponent({
setup() {
const route = useRoute();
const store = useStore();
const { studentId, token, userId } = route.query;
const bonusStoreState = computed(() => store.state.bonus);
const getters = computed(() => store.getters);
console.log(getters);
const state = reactive({
store.commit("bonus/saveStudentId", studentId);
store.commit("bonus/saveToken", token);
store.commit("bonus/saveUserId", userId);
const state = reactive<BonusState>({
loading: false,
finished: false
finished: false,
bonusAccount: {},
BonusAccountStatus,
withdrawList: []
});
const bonusAccount = reactive<BonusAccountResponse>({
status: "",
balance: 1.97,
sumAdd: 2.09,
sumWithdraw: 376.79,
withdrawing: 4.09
// 获取奖励金信息
bonusModel.getBonusAccount(bonusStoreState.value.studentId).then(res => {
const { data } = res;
state.bonusAccount = data;
});
const withdrawListParams = reactive<WithdrawListParams>({
pageSize: 10,
pageNum: 1,
studentId: bonusStoreState.value.studentId
});
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++) {
// withdrawList.push();
}
// 加载状态结束
bonusModel.getWithdrawList(withdrawListParams).then(res => {
const { hasNextPage, list } = res.data;
state.loading = false;
// 数据全部加载完成
if (withdrawList.length >= 40) {
state.finished = true;
}
}, 1000);
state.finished = !hasNextPage;
state.withdrawList = state.withdrawList.concat(list);
withdrawListParams.pageNum++;
});
};
return {
state,
bonusAccount,
withdrawList,
...toRefs(state),
onLoad,
bonusStoreState
};
......@@ -257,7 +239,9 @@ const Bonus = defineComponent({
withdraw() {
// this.showDangerous = true;
this.$router.push("withdraw");
// this.$router.push("withdraw");
// console.log(this.withdrawRule);
window.open('tel:10086', '_blank')
}
}
});
......@@ -278,6 +262,19 @@ export default Bonus;
.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;
}
}
}
.bonus-account-status {
......
/* eslint-disable @typescript-eslint/no-var-requires */
const tsImportPluginFactory = require("ts-import-plugin");
module.exports = {
devServer: {
hot: true,
open: true,
https: false,
proxy: {
//配置跨域
"/mock": {
target: "http://192.168.44.114:4100",
ws: true,
changOrigin: true //允许跨域
},
"/api": {
target: "http://192.168.44.114:4100",
ws: true,
changOrigin: true //允许跨域
},
"/service": {
target: "http://192.168.44.114:4100",
ws: true,
changOrigin: true //允许跨域
}
}
},
chainWebpack: config => {
config.module
.rule("ts")
.use("ts-loader")
.tap(options => {
return Object.assign(options || {}, {
transpileOnly: false,
getCustomTransformers: () => ({
before: [
tsImportPluginFactory({
libraryDirectory: "es",
libraryName: "vant",
style: true
})
]
})
});
});
},
css: {
loaderOptions: {
postcss: {
plugins: [
require("postcss-plugin-px2rem")({
rootValue: 75,
propList: ["*"],
replace: true,
mediaQuery: false,
minPixelValue: 2,
exclude: /(node_module)/i
})
]
}
}
}
};
/* eslint-disable @typescript-eslint/no-var-requires */
const tsImportPluginFactory = require("ts-import-plugin");
module.exports = {
devServer: {
hot: true,
open: true,
https: false,
proxy: {
//配置跨域
"/mock": {
target: "http://192.168.44.114:4100",
ws: true,
changOrigin: true //允许跨域
},
"/api": {
target: "http://192.168.44.114:4100",
ws: true,
changOrigin: true //允许跨域
},
"/service": {
target: "http://192.168.44.114:4100",
ws: true,
changOrigin: true //允许跨域
}
}
},
chainWebpack: config => {
config.module
.rule("ts")
.use("ts-loader")
.tap(options => {
return Object.assign(options || {}, {
transpileOnly: false,
getCustomTransformers: () => ({
before: [
tsImportPluginFactory({
libraryDirectory: "es",
libraryName: "vant",
style: true
})
]
})
});
});
},
css: {
loaderOptions: {
postcss: {
plugins: [
require("postcss-plugin-px2rem")({
rootValue: 75,
propList: ["*"],
replace: true,
mediaQuery: false,
minPixelValue: 2,
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