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 @@ ...@@ -57,7 +57,9 @@
"parserOptions": { "parserOptions": {
"ecmaVersion": 2020 "ecmaVersion": 2020
}, },
"rules": {} "rules": {
"@typescript-eslint/camelcase": "off"
}
}, },
"browserslist": [ "browserslist": [
"> 1%", "> 1%",
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
<meta charset="utf-8"> <meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0"> <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="icon" href="<%= BASE_URL %>favicon.ico">
<link rel="stylesheet" href="//at.alicdn.com/t/font_2425189_lvk0clvlo2.css"> <link rel="stylesheet" href="//at.alicdn.com/t/font_2425189_lvk0clvlo2.css">
<title><%= htmlWebpackPlugin.options.title %></title> <title><%= htmlWebpackPlugin.options.title %></title>
......
import { createApp } from "vue"; import { createApp } from "vue";
import App from "./App.vue"; import App from "./App.vue";
import router from "./router"; import router from "./router";
import store from "./store"; import store from "./store";
import "./assets/style/normalize.css"; import "./assets/style/normalize.css";
import "amfe-flexible"; import "amfe-flexible";
createApp(App) import nativeBridge from './util/nativeBridge'
.use(store) createApp(App)
.use(router) .use(store)
.mount("#app"); .use(router)
.use(nativeBridge)
.mount("#app");
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: wykolor * @Author: wykolor
* @Date: 2021-03-23 11:44:35 * @Date: 2021-03-23 11:44:35
* @Last Modified by: wykolor * @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 { export interface PageParams {
...@@ -44,10 +44,13 @@ export interface BonusListParams extends PageParams { ...@@ -44,10 +44,13 @@ export interface BonusListParams extends PageParams {
export interface BonusAccountResponse { export interface BonusAccountResponse {
status: string; status: string;
balance: number;
sumAdd: number;
sumWithdraw: number;
withdrawing: number; withdrawing: number;
balanceTotal: number;
addTotal: number;
withdrawedTotal: number;
withdrawAccount: string;
withdrawableTotal: number;
errCode: string;
} }
export interface WithdrawListParams extends PageParams { export interface WithdrawListParams extends PageParams {
......
import { createRouter, createWebHashHistory, RouteRecordRaw } from "vue-router"; import { createRouter, createWebHashHistory, RouteRecordRaw } from "vue-router";
import Bonus from "../views/bonus/index.vue"; import Bonus from "../views/bonus/index.vue";
const routes: Array<RouteRecordRaw> = [ const routes: Array<RouteRecordRaw> = [
{ {
path: "/", path: "/",
name: "Bonus", name: "Bonus",
component: Bonus component: Bonus
}, },
{ {
path: "/bonusDetail", path: "/bonusDetail",
name: "bonusDetail", name: "bonusDetail",
component: () => import("../views/bonus/bonus-detail/index.vue") component: () => import("../views/bonus/bonus-detail/index.vue")
}, },
{ {
path: "/withdraw", path: "/withdraw",
name: "withdraw", name: "withdraw",
component: () => import("../views/bonus/withdraw/index.vue") component: () => import("../views/bonus/withdraw/index.vue")
}, },
{ {
path: "/test", path: "/test",
name: "test", name: "test",
component: () => import("../views/test/index.vue") component: () => import("../views/test/index.vue")
} }
]; ];
const router = createRouter({ const router = createRouter({
history: createWebHashHistory(), history: createWebHashHistory(),
routes routes
}); });
export default router; export default router;
...@@ -20,12 +20,12 @@ export const getBonusList = (params: BonusListParams) => { ...@@ -20,12 +20,12 @@ export const getBonusList = (params: BonusListParams) => {
// 奖励金账户信息 // 奖励金账户信息
export const getBonusAccount = (studentId: string) => { 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) => { 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 = { const bonus = {
namespaced: true, namespaced: true,
state: () => ({ state: () => ({
studentId: 12, studentId: 0,
userId: "color" token: "",
userId: 0
}), }),
getters: { getters: {},
studentId: state => state.studentId + 1, mutations: {
userName: state => state.userId + "wangyan", saveStudentId(state, payload) {
studentFullName: state => state.studentId + state.userId state.studentId = payload;
},
saveToken(state, payload) {
state.token = payload;
},
saveUserId(state, payload) {
state.userId = payload;
}
}, },
mutations: {},
actions: {} actions: {}
}; };
......
/* eslint-disable @typescript-eslint/camelcase */ /* eslint-disable @typescript-eslint/camelcase */
import { App } from "vue"; import { App } from "vue";
import mitt from "./mitt"; import mitt from "./mitt";
const isiOS = () => { const isiOS = () => {
const u = navigator.userAgent; const u = navigator.userAgent;
const iOs = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); const iOs = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
return iOs; return iOs;
}; };
const isAndroid = () => { const isAndroid = () => {
const u = navigator.userAgent; const u = navigator.userAgent;
const android = u.indexOf("Android") > -1 || u.indexOf("Adr") > -1; const android = u.indexOf("Android") > -1 || u.indexOf("Adr") > -1;
return android; return android;
}; };
const postMessage = data => { const postMessage = data => {
if (isAndroid()) { if (isAndroid()) {
window.ReactNativeWebView && window.ReactNativeWebView &&
window.ReactNativeWebView.onMessage && window.ReactNativeWebView.onMessage &&
window.ReactNativeWebView.onMessage(JSON.stringify(data)); window.ReactNativeWebView.onMessage(JSON.stringify(data));
} }
window.ReactNativeWebView && window.ReactNativeWebView &&
window.ReactNativeWebView.postMessage && window.ReactNativeWebView.postMessage &&
window.ReactNativeWebView.postMessage(JSON.stringify(data)); window.ReactNativeWebView.postMessage(JSON.stringify(data));
}; };
if (isiOS() || isAndroid()) { if (isiOS() || isAndroid()) {
// const debugLog = console.log // const debugLog = console.log
// eslint-disable-next-line func-names // eslint-disable-next-line func-names
// console.log = function (...args) { // console.log = function (...args) {
// postMessage({ // postMessage({
// type: 'log', // type: 'log',
// data: args // data: args
// }) // })
// debugLog(...args) // debugLog(...args)
// } // }
} }
function install(Vue: App) { function install(Vue: App) {
const GEEK_NATVIE_NAME = "GEEK_NATVIE_NAME"; const GEEK_NATVIE_NAME = "GEEK_NATVIE_NAME";
// eslint-disable-next-line camelcase // eslint-disable-next-line camelcase
const event_bus = mitt(); const event_bus = mitt();
// eslint-disable-next-line func-names // eslint-disable-next-line func-names
window.$geek_excuteJS = function(args) { window.$geek_excuteJS = function (args) {
try { try {
const params = JSON.parse(args); const params = JSON.parse(args);
event_bus.emit(GEEK_NATVIE_NAME, params); event_bus.emit(GEEK_NATVIE_NAME, params);
} catch (error) { } catch (error) {
event_bus.emit(GEEK_NATVIE_NAME, args); event_bus.emit(GEEK_NATVIE_NAME, args);
} }
}; };
Vue.mixin({ Vue.mixin({
methods: { methods: {
listenNativeMessage(arg) { listenNativeMessage(arg) {
const { method, data } = arg; const { method, data } = arg;
if (method) { if (method) {
this[method] && this[method](data); this[method] && this[method](data);
} }
}, },
$nativeTitle(title) { $nativeTitle(title) {
const message = { const message = {
type: "title", type: "title",
data: title data: title
}; };
postMessage(message); postMessage(message);
}, },
$shareImg(base64Img, timeline = false) { $shareImg(base64Img, timeline = false) {
const message = { const message = {
type: timeline ? "shareTimeline" : "share", type: timeline ? "shareTimeline" : "share",
data: { data: {
type: "img", type: "img",
img: base64Img img: base64Img
} }
}; };
postMessage(message); postMessage(message);
}, },
$shareText(txt, timeline = false) { $shareText(txt, timeline = false) {
const message = { const message = {
type: timeline ? "shareTimeline" : "share", type: timeline ? "shareTimeline" : "share",
data: { data: {
type: "text", type: "text",
description: txt description: txt
} }
}; };
postMessage(message); postMessage(message);
}, },
$shareNews({ title, url, description }, timeline = false) { $shareNews({ title, url, description }, timeline = false) {
const message = { const message = {
type: timeline ? "shareTimeline" : "share", type: timeline ? "shareTimeline" : "share",
data: { data: {
type: "news", type: "news",
description, description,
webpageUrl: url, webpageUrl: url,
title title
} }
}; };
postMessage(message); postMessage(message);
}, },
$playVieo(url) { $playVieo(url) {
const message = { const message = {
type: "video", type: "video",
data: { data: {
url url
} }
}; };
postMessage(message); postMessage(message);
}, },
$postMessage(message) { $postMessage(message) {
postMessage(message); postMessage(message);
}, },
$exitWebView(data) { $exitWebView(data) {
this.$postMessage({ this.$postMessage({
type: "exitWebview", type: "exitWebview",
data data
}); });
}, },
$shareReport(params) { $shareReport(params) {
this.$postMessage({ this.$postMessage({
type: "reportShare", type: "reportShare",
params params
}); });
} }
}, },
created() { created() {
event_bus.on(GEEK_NATVIE_NAME, this.listenNativeMessage); event_bus.on(GEEK_NATVIE_NAME, this.listenNativeMessage);
}, },
beforeUnmount() { beforeUnmount() {
event_bus.off(GEEK_NATVIE_NAME, this.listenNativeMessage); event_bus.off(GEEK_NATVIE_NAME, this.listenNativeMessage);
} }
}); });
} }
export default install; export default install;
...@@ -17,7 +17,7 @@ const isAndroid = () => { ...@@ -17,7 +17,7 @@ const isAndroid = () => {
return android; return android;
}; };
window.$geek_excuteJS = function(args) { window.$geek_excuteJS = function (args) {
try { try {
const params = JSON.parse(args); const params = JSON.parse(args);
eventBus.emit<NativeInvokeFuncParams>(GEEK_NATVIE_NAME, params); eventBus.emit<NativeInvokeFuncParams>(GEEK_NATVIE_NAME, params);
...@@ -52,7 +52,7 @@ function useNativeBridge( ...@@ -52,7 +52,7 @@ function useNativeBridge(
eventTypeOrEventMap: string | { [key: string]: ListenerType }, eventTypeOrEventMap: string | { [key: string]: ListenerType },
listener?: ListenerType listener?: ListenerType
): [typeof sendNativeMessage, typeof eventBus] { ): [typeof sendNativeMessage, typeof eventBus] {
const _listener = function(this: ComponentInternalInstance | null, arg?: NativeInvokeFuncParams) { const _listener = function (this: ComponentInternalInstance | null, arg?: NativeInvokeFuncParams) {
if (!arg) return; if (!arg) return;
const { method, data } = arg; const { method, data } = arg;
if (typeof eventTypeOrEventMap === "string") { if (typeof eventTypeOrEventMap === "string") {
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
v-model:loading="loading" v-model:loading="loading"
v-model:error="error" v-model:error="error"
:finished="finished" :finished="finished"
finished-text="没有更多了" finished-text="~我是有底线的~"
@load="onLoad" @load="onLoad"
> >
<van-tab name="REDUCE" title="支出" class="bonus-detail-pay-list"> <van-tab name="REDUCE" title="支出" class="bonus-detail-pay-list">
......
...@@ -10,9 +10,16 @@ ...@@ -10,9 +10,16 @@
></van-col> ></van-col>
</van-row> </van-row>
<van-row class="bonus-account-money" align="center"> <van-row class="bonus-account-money" align="center">
<van-col span="12" class="money-desc" <van-col span="12" class="money-desc">
><span>¥{{ bonusAccount.balance }}</span></van-col <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-col span="12" style="text-align: right"
><van-button ><van-button
style="border-color: #fff; width: 45%" style="border-color: #fff; width: 45%"
...@@ -28,11 +35,11 @@ ...@@ -28,11 +35,11 @@
<van-row class="bonus-account-status"> <van-row class="bonus-account-status">
<van-col span="8"> <van-col span="8">
<label>累计收入</label> <label>累计收入</label>
<span>¥{{ bonusAccount.sumAdd }}</span> <span>¥{{ bonusAccount.addTotal }}</span>
</van-col> </van-col>
<van-col span="8"> <van-col span="8">
<label>累计提现</label> <label>累计提现</label>
<span>¥{{ bonusAccount.sumWithdraw }}</span> <span>¥{{ bonusAccount.withdrawedTotal }}</span>
</van-col> </van-col>
<van-col span="8"> <van-col span="8">
<label>提现中</label> <label>提现中</label>
...@@ -42,7 +49,7 @@ ...@@ -42,7 +49,7 @@
</div> </div>
<van-cell <van-cell
center center
:title="`可提现金额:¥${bonusAccount.balance}`" :title="`可提现金额:¥${bonusAccount.withdrawableTotal}`"
size="large" size="large"
style="border-radius: 0.3rem;" style="border-radius: 0.3rem;"
:border="false" :border="false"
...@@ -51,19 +58,18 @@ ...@@ -51,19 +58,18 @@
>提现</van-button >提现</van-button
> >
</van-cell> </van-cell>
<!-- -->
<div class="bouns-record"> <div class="bouns-record">
<van-row> <van-row>
<van-col span="12" class="tip">&emsp;奖励金提现金额</van-col> <van-col span="12" class="tip">&emsp;奖励金提现金额</van-col>
<van-col span="12" class="tip-money" style="text-align: right; font-weight: 550" <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-row>
<van-list <van-list
v-model:loading="state.loading" v-model:loading="loading"
:finished="state.finished" :finished="finished"
finished-text="我是有底线的" finished-text="~我是有底线的~"
@load="onLoad" @load="onLoad"
> >
<div class="bonus-record-item" v-for="item in withdrawList" :key="item.id"> <div class="bonus-record-item" v-for="item in withdrawList" :key="item.id">
...@@ -103,7 +109,6 @@ ...@@ -103,7 +109,6 @@
</div> </div>
</van-list> </van-list>
</div> </div>
<!-- 规则弹窗 --> <!-- 规则弹窗 -->
<van-dialog <van-dialog
v-model:show="showDialog" v-model:show="showDialog"
...@@ -154,81 +159,58 @@ ...@@ -154,81 +159,58 @@
<script lang="ts"> <script lang="ts">
// eslint-disable-next-line @typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-explicit-any
import { computed, defineComponent, reactive } from "vue"; import { computed, defineComponent, reactive, toRefs } from "vue";
import { Dialog, Button, Col, Row, Cell, List } from "vant"; import { useRoute } from "vue-router";
import { BonusAccountResponse, WithdrawListResponse } from "@/model/bonus";
import { useStore } from "vuex"; 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({ const Bonus = defineComponent({
setup() { setup() {
const route = useRoute();
const store = useStore(); const store = useStore();
const { studentId, token, userId } = route.query;
const bonusStoreState = computed(() => store.state.bonus); const bonusStoreState = computed(() => store.state.bonus);
const getters = computed(() => store.getters); store.commit("bonus/saveStudentId", studentId);
console.log(getters); store.commit("bonus/saveToken", token);
const state = reactive({ store.commit("bonus/saveUserId", userId);
const state = reactive<BonusState>({
loading: false, loading: false,
finished: false finished: false,
bonusAccount: {},
BonusAccountStatus,
withdrawList: []
}); });
const bonusAccount = reactive<BonusAccountResponse>({ // 获取奖励金信息
status: "", bonusModel.getBonusAccount(bonusStoreState.value.studentId).then(res => {
balance: 1.97, const { data } = res;
sumAdd: 2.09, state.bonusAccount = data;
sumWithdraw: 376.79, });
withdrawing: 4.09 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 = () => { const onLoad = () => {
// 异步更新数据 bonusModel.getWithdrawList(withdrawListParams).then(res => {
// setTimeout 仅做示例,真实场景中一般为 ajax 请求 const { hasNextPage, list } = res.data;
setTimeout(() => {
for (let i = 0; i < 10; i++) {
// withdrawList.push();
}
// 加载状态结束
state.loading = false; state.loading = false;
state.finished = !hasNextPage;
// 数据全部加载完成 state.withdrawList = state.withdrawList.concat(list);
if (withdrawList.length >= 40) { withdrawListParams.pageNum++;
state.finished = true; });
}
}, 1000);
}; };
return { return {
state, ...toRefs(state),
bonusAccount,
withdrawList,
onLoad, onLoad,
bonusStoreState bonusStoreState
}; };
...@@ -257,7 +239,9 @@ const Bonus = defineComponent({ ...@@ -257,7 +239,9 @@ const Bonus = defineComponent({
withdraw() { withdraw() {
// this.showDangerous = true; // 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; ...@@ -278,6 +262,19 @@ export default Bonus;
.money-desc { .money-desc {
font-size: 72px; font-size: 72px;
font-weight: 600; 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 { .bonus-account-status {
......
/* eslint-disable @typescript-eslint/no-var-requires */ /* eslint-disable @typescript-eslint/no-var-requires */
const tsImportPluginFactory = require("ts-import-plugin"); const tsImportPluginFactory = require("ts-import-plugin");
module.exports = { module.exports = {
devServer: { devServer: {
hot: true, hot: true,
open: true, open: true,
https: false, https: false,
proxy: { proxy: {
//配置跨域 //配置跨域
"/mock": { "/mock": {
target: "http://192.168.44.114:4100", target: "http://192.168.44.114:4100",
ws: true, ws: true,
changOrigin: true //允许跨域 changOrigin: true //允许跨域
}, },
"/api": { "/api": {
target: "http://192.168.44.114:4100", target: "http://192.168.44.114:4100",
ws: true, ws: true,
changOrigin: true //允许跨域 changOrigin: true //允许跨域
}, },
"/service": { "/service": {
target: "http://192.168.44.114:4100", target: "http://192.168.44.114:4100",
ws: true, ws: true,
changOrigin: true //允许跨域 changOrigin: true //允许跨域
} }
} }
}, },
chainWebpack: config => { chainWebpack: config => {
config.module config.module
.rule("ts") .rule("ts")
.use("ts-loader") .use("ts-loader")
.tap(options => { .tap(options => {
return Object.assign(options || {}, { return Object.assign(options || {}, {
transpileOnly: false, transpileOnly: false,
getCustomTransformers: () => ({ getCustomTransformers: () => ({
before: [ before: [
tsImportPluginFactory({ tsImportPluginFactory({
libraryDirectory: "es", libraryDirectory: "es",
libraryName: "vant", libraryName: "vant",
style: true style: true
}) })
] ]
}) })
}); });
}); });
}, },
css: { css: {
loaderOptions: { loaderOptions: {
postcss: { postcss: {
plugins: [ plugins: [
require("postcss-plugin-px2rem")({ require("postcss-plugin-px2rem")({
rootValue: 75, rootValue: 75,
propList: ["*"], propList: ["*"],
replace: true, replace: true,
mediaQuery: false, mediaQuery: false,
minPixelValue: 2, minPixelValue: 2,
exclude: /(node_module)/i 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