Commit 92013d43 authored by wykolor's avatar wykolor

feat: 绑定微信

parent 00d4ebd8
......@@ -12,6 +12,7 @@
"axios": "^0.21.1",
"core-js": "^3.6.5",
"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",
......
......@@ -5,6 +5,8 @@ import store from "./store";
import "./assets/style/normalize.css";
import "amfe-flexible";
import nativeBridge from './util/nativeBridge'
import VConsole from "vconsole";
new VConsole();
createApp(App)
.use(store)
.use(router)
......
/*
* @Author: wykolor
* @Date: 2021-03-23 10:36:45
* @Last Modified by: wykolor
* @Last Modified time: 2021-03-24 16:16:30
* @Last Modified by: mikey.zhaopeng
* @Last Modified time: 2021-03-29 13:48:46
*/
// 流水类型
......@@ -25,3 +25,14 @@ 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", // 余额不足
}
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 = '当前账号存在风险,无法进行提现操作!';
break;
case ErrCode.USER_UP_LIMIT:
case ErrCode.SYSTEM_UP_LIMIT:
tip = '今日已达到提现次数/提现金额上限,无法进行提现操作,请明日进行提现操作!';
break;
case ErrCode.STUDENT_WITHDRAWING:
tip = '您当前有一笔资金处于提现中,待该笔资金完成提现后,再进行提现操作!';
break;
case ErrCode.BALANCE_NOT_ENOUGH:
tip = '提现金额至少为:1.00元。当前奖励金账户余额不足,多多转介绍吧!';
break;
default:
tip = '绑定微信后,才可进行提现!'
}
return tip;
}
\ No newline at end of file
/* eslint-disable @typescript-eslint/camelcase */
/* eslint-disable @typescript-eslint/no-explicit-any */
import { Toast } from "vant";
import { onBeforeUnmount, onMounted, getCurrentInstance, ComponentInternalInstance } from "vue";
import mitt from "./mitt";
......@@ -18,6 +19,7 @@ const isAndroid = () => {
};
window.$geek_excuteJS = function (args) {
console.log(args);
try {
const params = JSON.parse(args);
eventBus.emit<NativeInvokeFuncParams>(GEEK_NATVIE_NAME, params);
......@@ -42,6 +44,8 @@ function useNativeBridge(
listener: (this: ComponentInternalInstance | null, ...arg: any[]) => any
): [typeof sendNativeMessage, typeof eventBus] {
const _listener = function (this: ComponentInternalInstance | null, arg?: NativeInvokeFuncParams) {
console.log(arg, 1111111);
if (!arg) return;
if (eventType === arg.method) {
listener.apply(this, [arg.data]);
......
......@@ -12,10 +12,10 @@
<van-row class="bonus-account-money" align="center">
<van-col span="12" class="money-desc">
<span style="position: relative"
>¥{{ bonusAccount.balanceTotal }}
>¥{{ bonusAccount?.balanceTotal }}
<label
class="frozen"
v-if="bonusAccount.status && bonusAccount.status === BonusAccountStatus.FREEZE"
v-if="bonusAccount?.status && bonusAccount?.status === BonusAccountStatus.FREEZE"
>冻结
</label></span
>
......@@ -35,21 +35,21 @@
<van-row class="bonus-account-status">
<van-col span="8">
<label>累计收入</label>
<span>¥{{ bonusAccount.addTotal }}</span>
<span>¥{{ bonusAccount?.addTotal }}</span>
</van-col>
<van-col span="8">
<label>累计提现</label>
<span>¥{{ bonusAccount.withdrawedTotal }}</span>
<span>¥{{ bonusAccount?.withdrawedTotal }}</span>
</van-col>
<van-col span="8">
<label>提现中</label>
<span>¥{{ bonusAccount.withdrawing }}</span>
<span>¥{{ bonusAccount?.withdrawing }}</span>
</van-col>
</van-row>
</div>
<van-cell
center
:title="`可提现金额:¥${bonusAccount.withdrawableTotal}`"
:title="`可提现金额:¥${bonusAccount?.withdrawableTotal}`"
size="large"
style="border-radius: 0.3rem;"
:border="false"
......@@ -62,7 +62,7 @@
<van-row>
<van-col span="12" class="tip">&emsp;奖励金提现金额</van-col>
<van-col span="12" class="tip-money" style="text-align: right; font-weight: 550"
>总计:{{ bonusAccount.withdrawedTotal }}元&nbsp;</van-col
>总计:{{ bonusAccount?.withdrawedTotal }}元&nbsp;</van-col
>
</van-row>
......@@ -71,6 +71,7 @@
:finished="finished"
finished-text="~我是有底线的~"
@load="onLoad"
:immediate-check="false"
>
<div class="bonus-record-item" v-for="item in withdrawList" :key="item.id">
<div class="bonus-record-item-header">
......@@ -111,7 +112,7 @@
</div>
<!-- 规则弹窗 -->
<van-dialog
v-model:show="showDialog"
v-model:show="showWithdrawRules"
title="提现规则说明"
:show-cancel-button="false"
:show-confirm-button="false"
......@@ -126,19 +127,19 @@
<li>6.如需帮助请联系:400—8777389!</li>
</ul>
<div class="dialog-handle-btns">
<van-button type="default" round @click="showDialog = false">电话咨询</van-button
><van-button type="primary" round @click="showDialog = false">我知道了</van-button>
<van-button type="default" round @click="phoneCall">电话咨询</van-button
><van-button type="primary" round @click="showWithdrawRules = false">我知道了</van-button>
</div>
</van-dialog>
<van-dialog
v-model:show="showBindWx"
:show-cancel-button="false"
:show-confirm-button="false"
title="绑定微信后,才可以进行提现!"
title="绑定微信后,才可进行提现!"
>
<div class="dialog-handle-btns">
<van-button type="default" round @click="showBindWx = false">取消</van-button
><van-button type="primary" round @click="showBindWx = false">绑定微信</van-button>
><van-button type="primary" round @click="bindWeChat">绑定微信</van-button>
</div>
</van-dialog>
<van-dialog
......@@ -147,11 +148,11 @@
:show-confirm-button="false"
>
<p class="dangerous-dialog-tip" style="text-align: center">
当前账号存在风险,无法进行提现操作! 如需帮助请联系:400-8777389
{{ formatBonusTipTxt(bonusAccount?.errCode) }}
</p>
<div class="dialog-handle-btns">
<van-button type="default" round @click="showDangerous = false">确定</van-button
><van-button type="primary" round @click="showDangerous = false">电话咨询</van-button>
><van-button type="primary" round @click="phoneCall">电话咨询</van-button>
</div>
</van-dialog>
</div>
......@@ -159,34 +160,44 @@
<script lang="ts">
// eslint-disable-next-line @typescript-eslint/no-explicit-any
import { computed, defineComponent, reactive, toRefs } from "vue";
import { useRoute } from "vue-router";
import { computed, defineComponent, onMounted, reactive, toRefs } from "vue";
import { useRoute, useRouter } from "vue-router";
import { useStore } from "vuex";
import { Dialog, Button, Col, Row, Cell, List } from "vant";
import { Dialog, Button, Col, Row, Cell, List, Toast } from "vant";
import { WithdrawListParams, WithdrawListResponse } from "@/model/bonus";
import { BonusAccountResponse, WithdrawListParams, WithdrawListResponse } from "@/model/bonus";
import { bonusModel } from "@/server/api";
import { BonusAccountStatus } from "@/model/bonus/constant";
import { BonusAccountStatus, ErrCode } from "@/model/bonus/constant";
import { useNativeBridge } from "@/util/use-native-bridge";
import { formatBonusTipTxt } from "@/util/formatBonusTipTxt";
interface BonusState {
withdrawList: WithdrawListResponse[];
bonusAccount: BonusAccountResponse | null;
[key: string]: unknown;
}
const Bonus = defineComponent({
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("bindWeChatChange", function(arg) {
Toast('成功啦')
});
const state = reactive<BonusState>({
loading: false,
finished: false,
bonusAccount: {},
showWithdrawRules: false,
showBindWx: false,
showDangerous: false,
bonusAccount: null,
BonusAccountStatus,
withdrawList: []
});
......@@ -201,6 +212,7 @@ const Bonus = defineComponent({
studentId: bonusStoreState.value.studentId
});
const onLoad = () => {
state.loading = true;
bonusModel.getWithdrawList(withdrawListParams).then(res => {
const { hasNextPage, list } = res.data;
state.loading = false;
......@@ -209,10 +221,49 @@ const Bonus = defineComponent({
withdrawListParams.pageNum++;
});
};
onMounted(() => {
const message = {
type: "title",
data: "我的奖励金"
};
sendNativeMessage(message);
onLoad();
});
const withdraw = () => {
if (!state.bonusAccount?.errCode) {
// 都正常的状态
// router.push("withdraw");
state.showBindWx = true;
} else if (state.bonusAccount?.errCode === ErrCode.NOT_BIND) {
state.showBindWx = true;
} else {
state.showDangerous = true;
}
};
const withdrawRule = () => {
state.showWithdrawRules = true;
};
const phoneCall = () => {
sendNativeMessage({
type: "phoneCall",
data: "400—8777389"
});
};
const bindWeChat = () => {
sendNativeMessage({
type: "bindWeChat",
data: "bindWeChat"
});
};
return {
...toRefs(state),
onLoad,
bonusStoreState
withdraw,
withdrawRule,
phoneCall,
bindWeChat,
bonusStoreState,
formatBonusTipTxt
};
},
components: {
......@@ -222,27 +273,6 @@ const Bonus = defineComponent({
[Cell.name]: Cell,
[List.name]: List,
[Dialog.Component.name]: Dialog.Component
},
data() {
return {
showTime: "获取验证码",
showDialog: false,
showBindWx: false,
showDangerous: false
};
},
methods: {
withdrawRule() {
this.showDialog = true;
// console.log(this.$store.state.studentId);
},
withdraw() {
// this.showDangerous = true;
// this.$router.push("withdraw");
// console.log(this.withdrawRule);
window.open('tel:10086', '_blank')
}
}
});
export default Bonus;
......
......@@ -129,8 +129,9 @@
<script lang="ts">
// eslint-disable-next-line @typescript-eslint/no-explicit-any
declare const TencentCaptcha: any;
import { defineComponent, reactive, toRefs } from "vue";
import { defineComponent, onMounted, reactive, toRefs } from "vue";
import { Button, Cell, Dialog, Field, Toast } from "vant";
import { useNativeBridge } from "@/util/use-native-bridge";
import { countDown } from "../../../util/timer";
interface TencentCaptchaResponse {
ret: number;
......@@ -147,6 +148,9 @@ const Withdraw = defineComponent({
[Dialog.Component.name]: Dialog.Component
},
setup() {
const [sendNativeMessage, eventBus] = useNativeBridge("title", function(arg) {
console.log(this, arg);
});
const state = reactive({
withdrawAmount: "",
smsVerifyCode: "",
......@@ -201,6 +205,13 @@ const Withdraw = defineComponent({
}
state.showWithdrawSuccess = true;
};
onMounted(() => {
const message = {
type: "title",
data: "提现"
};
sendNativeMessage(message);
})
return {
...toRefs(state),
formatter,
......
<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("bindWechatChange", function(arg) {
console.log(this, arg);
const [sendNativeMessage, eventBus] = useNativeBridge("title", function(arg) {
Toast('hahahahah')
});
const count = ref(1000);
const emitTest = () => {
......@@ -20,6 +22,14 @@ const emitTest = () => {
});
count.value = count.value + 1;
};
const emitTest2 = () => {
eventBus.emit("GEEK_NATVIE_NAME", {
method: "title",
data: "我的体现计划"
});
};
</script>
<style></style>
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