Commit 92013d43 authored by wykolor's avatar wykolor

feat: 绑定微信

parent 00d4ebd8
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
"axios": "^0.21.1", "axios": "^0.21.1",
"core-js": "^3.6.5", "core-js": "^3.6.5",
"vant": "^3.0.9", "vant": "^3.0.9",
"vconsole": "^3.4.0",
"vue": "^3.0.0", "vue": "^3.0.0",
"vue-class-component": "^8.0.0-0", "vue-class-component": "^8.0.0-0",
"vue-router": "^4.0.0-0", "vue-router": "^4.0.0-0",
......
...@@ -5,6 +5,8 @@ import store from "./store"; ...@@ -5,6 +5,8 @@ import store from "./store";
import "./assets/style/normalize.css"; import "./assets/style/normalize.css";
import "amfe-flexible"; import "amfe-flexible";
import nativeBridge from './util/nativeBridge' import nativeBridge from './util/nativeBridge'
import VConsole from "vconsole";
new VConsole();
createApp(App) createApp(App)
.use(store) .use(store)
.use(router) .use(router)
......
/* /*
* @Author: wykolor * @Author: wykolor
* @Date: 2021-03-23 10:36:45 * @Date: 2021-03-23 10:36:45
* @Last Modified by: wykolor * @Last Modified by: mikey.zhaopeng
* @Last Modified time: 2021-03-24 16:16:30 * @Last Modified time: 2021-03-29 13:48:46
*/ */
// 流水类型 // 流水类型
...@@ -25,3 +25,14 @@ export enum BonusAccountStatus { ...@@ -25,3 +25,14 @@ export enum BonusAccountStatus {
ACTIVE = "ACTIVE", // 正常 ACTIVE = "ACTIVE", // 正常
FREEZE = "FREEZE" // 冻结 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/camelcase */
/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-explicit-any */
import { Toast } from "vant";
import { onBeforeUnmount, onMounted, getCurrentInstance, ComponentInternalInstance } from "vue"; import { onBeforeUnmount, onMounted, getCurrentInstance, ComponentInternalInstance } from "vue";
import mitt from "./mitt"; import mitt from "./mitt";
...@@ -18,6 +19,7 @@ const isAndroid = () => { ...@@ -18,6 +19,7 @@ const isAndroid = () => {
}; };
window.$geek_excuteJS = function (args) { window.$geek_excuteJS = function (args) {
console.log(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);
...@@ -42,6 +44,8 @@ function useNativeBridge( ...@@ -42,6 +44,8 @@ function useNativeBridge(
listener: (this: ComponentInternalInstance | null, ...arg: any[]) => any listener: (this: ComponentInternalInstance | null, ...arg: any[]) => any
): [typeof sendNativeMessage, typeof eventBus] { ): [typeof sendNativeMessage, typeof eventBus] {
const _listener = function (this: ComponentInternalInstance | null, arg?: NativeInvokeFuncParams) { const _listener = function (this: ComponentInternalInstance | null, arg?: NativeInvokeFuncParams) {
console.log(arg, 1111111);
if (!arg) return; if (!arg) return;
if (eventType === arg.method) { if (eventType === arg.method) {
listener.apply(this, [arg.data]); listener.apply(this, [arg.data]);
......
...@@ -12,10 +12,10 @@ ...@@ -12,10 +12,10 @@
<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 style="position: relative" <span style="position: relative"
>¥{{ bonusAccount.balanceTotal }} >¥{{ bonusAccount?.balanceTotal }}
<label <label
class="frozen" class="frozen"
v-if="bonusAccount.status && bonusAccount.status === BonusAccountStatus.FREEZE" v-if="bonusAccount?.status && bonusAccount?.status === BonusAccountStatus.FREEZE"
>冻结 >冻结
</label></span </label></span
> >
...@@ -35,21 +35,21 @@ ...@@ -35,21 +35,21 @@
<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.addTotal }}</span> <span>¥{{ bonusAccount?.addTotal }}</span>
</van-col> </van-col>
<van-col span="8"> <van-col span="8">
<label>累计提现</label> <label>累计提现</label>
<span>¥{{ bonusAccount.withdrawedTotal }}</span> <span>¥{{ bonusAccount?.withdrawedTotal }}</span>
</van-col> </van-col>
<van-col span="8"> <van-col span="8">
<label>提现中</label> <label>提现中</label>
<span>¥{{ bonusAccount.withdrawing }}</span> <span>¥{{ bonusAccount?.withdrawing }}</span>
</van-col> </van-col>
</van-row> </van-row>
</div> </div>
<van-cell <van-cell
center center
:title="`可提现金额:¥${bonusAccount.withdrawableTotal}`" :title="`可提现金额:¥${bonusAccount?.withdrawableTotal}`"
size="large" size="large"
style="border-radius: 0.3rem;" style="border-radius: 0.3rem;"
:border="false" :border="false"
...@@ -62,7 +62,7 @@ ...@@ -62,7 +62,7 @@
<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.withdrawedTotal }}元&nbsp;</van-col >总计:{{ bonusAccount?.withdrawedTotal }}元&nbsp;</van-col
> >
</van-row> </van-row>
...@@ -71,6 +71,7 @@ ...@@ -71,6 +71,7 @@
:finished="finished" :finished="finished"
finished-text="~我是有底线的~" finished-text="~我是有底线的~"
@load="onLoad" @load="onLoad"
:immediate-check="false"
> >
<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">
<div class="bonus-record-item-header"> <div class="bonus-record-item-header">
...@@ -111,7 +112,7 @@ ...@@ -111,7 +112,7 @@
</div> </div>
<!-- 规则弹窗 --> <!-- 规则弹窗 -->
<van-dialog <van-dialog
v-model:show="showDialog" v-model:show="showWithdrawRules"
title="提现规则说明" title="提现规则说明"
:show-cancel-button="false" :show-cancel-button="false"
:show-confirm-button="false" :show-confirm-button="false"
...@@ -126,19 +127,19 @@ ...@@ -126,19 +127,19 @@
<li>6.如需帮助请联系:400—8777389!</li> <li>6.如需帮助请联系:400—8777389!</li>
</ul> </ul>
<div class="dialog-handle-btns"> <div class="dialog-handle-btns">
<van-button type="default" round @click="showDialog = false">电话咨询</van-button <van-button type="default" round @click="phoneCall">电话咨询</van-button
><van-button type="primary" round @click="showDialog = false">我知道了</van-button> ><van-button type="primary" round @click="showWithdrawRules = false">我知道了</van-button>
</div> </div>
</van-dialog> </van-dialog>
<van-dialog <van-dialog
v-model:show="showBindWx" v-model:show="showBindWx"
:show-cancel-button="false" :show-cancel-button="false"
:show-confirm-button="false" :show-confirm-button="false"
title="绑定微信后,才可以进行提现!" title="绑定微信后,才可进行提现!"
> >
<div class="dialog-handle-btns"> <div class="dialog-handle-btns">
<van-button type="default" round @click="showBindWx = false">取消</van-button <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> </div>
</van-dialog> </van-dialog>
<van-dialog <van-dialog
...@@ -147,11 +148,11 @@ ...@@ -147,11 +148,11 @@
:show-confirm-button="false" :show-confirm-button="false"
> >
<p class="dangerous-dialog-tip" style="text-align: center"> <p class="dangerous-dialog-tip" style="text-align: center">
当前账号存在风险,无法进行提现操作! 如需帮助请联系:400-8777389 {{ formatBonusTipTxt(bonusAccount?.errCode) }}
</p> </p>
<div class="dialog-handle-btns"> <div class="dialog-handle-btns">
<van-button type="default" round @click="showDangerous = false">确定</van-button <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> </div>
</van-dialog> </van-dialog>
</div> </div>
...@@ -159,34 +160,44 @@ ...@@ -159,34 +160,44 @@
<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, toRefs } from "vue"; import { computed, defineComponent, onMounted, reactive, toRefs } from "vue";
import { useRoute } from "vue-router"; import { useRoute, useRouter } from "vue-router";
import { useStore } from "vuex"; 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 { 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 { interface BonusState {
withdrawList: WithdrawListResponse[]; withdrawList: WithdrawListResponse[];
bonusAccount: BonusAccountResponse | null;
[key: string]: unknown; [key: string]: unknown;
} }
const Bonus = defineComponent({ const Bonus = defineComponent({
setup() { setup() {
const route = useRoute(); const route = useRoute();
const router = useRouter();
const store = useStore(); const store = useStore();
const { studentId, token, userId } = route.query; const { studentId, token, userId } = route.query;
const bonusStoreState = computed(() => store.state.bonus); const bonusStoreState = computed(() => store.state.bonus);
store.commit("bonus/saveStudentId", studentId); store.commit("bonus/saveStudentId", studentId);
store.commit("bonus/saveToken", token); store.commit("bonus/saveToken", token);
store.commit("bonus/saveUserId", userId); store.commit("bonus/saveUserId", userId);
const [sendNativeMessage] = useNativeBridge("bindWeChatChange", function(arg) {
Toast('成功啦')
});
const state = reactive<BonusState>({ const state = reactive<BonusState>({
loading: false, loading: false,
finished: false, finished: false,
bonusAccount: {}, showWithdrawRules: false,
showBindWx: false,
showDangerous: false,
bonusAccount: null,
BonusAccountStatus, BonusAccountStatus,
withdrawList: [] withdrawList: []
}); });
...@@ -201,6 +212,7 @@ const Bonus = defineComponent({ ...@@ -201,6 +212,7 @@ const Bonus = defineComponent({
studentId: bonusStoreState.value.studentId studentId: bonusStoreState.value.studentId
}); });
const onLoad = () => { const onLoad = () => {
state.loading = true;
bonusModel.getWithdrawList(withdrawListParams).then(res => { bonusModel.getWithdrawList(withdrawListParams).then(res => {
const { hasNextPage, list } = res.data; const { hasNextPage, list } = res.data;
state.loading = false; state.loading = false;
...@@ -209,10 +221,49 @@ const Bonus = defineComponent({ ...@@ -209,10 +221,49 @@ const Bonus = defineComponent({
withdrawListParams.pageNum++; 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 { return {
...toRefs(state), ...toRefs(state),
onLoad, onLoad,
bonusStoreState withdraw,
withdrawRule,
phoneCall,
bindWeChat,
bonusStoreState,
formatBonusTipTxt
}; };
}, },
components: { components: {
...@@ -222,27 +273,6 @@ const Bonus = defineComponent({ ...@@ -222,27 +273,6 @@ const Bonus = defineComponent({
[Cell.name]: Cell, [Cell.name]: Cell,
[List.name]: List, [List.name]: List,
[Dialog.Component.name]: Dialog.Component [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; export default Bonus;
......
...@@ -129,8 +129,9 @@ ...@@ -129,8 +129,9 @@
<script lang="ts"> <script lang="ts">
// eslint-disable-next-line @typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-explicit-any
declare const TencentCaptcha: 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 { Button, Cell, Dialog, Field, Toast } from "vant";
import { useNativeBridge } from "@/util/use-native-bridge";
import { countDown } from "../../../util/timer"; import { countDown } from "../../../util/timer";
interface TencentCaptchaResponse { interface TencentCaptchaResponse {
ret: number; ret: number;
...@@ -147,6 +148,9 @@ const Withdraw = defineComponent({ ...@@ -147,6 +148,9 @@ const Withdraw = defineComponent({
[Dialog.Component.name]: Dialog.Component [Dialog.Component.name]: Dialog.Component
}, },
setup() { setup() {
const [sendNativeMessage, eventBus] = useNativeBridge("title", function(arg) {
console.log(this, arg);
});
const state = reactive({ const state = reactive({
withdrawAmount: "", withdrawAmount: "",
smsVerifyCode: "", smsVerifyCode: "",
...@@ -201,6 +205,13 @@ const Withdraw = defineComponent({ ...@@ -201,6 +205,13 @@ const Withdraw = defineComponent({
} }
state.showWithdrawSuccess = true; state.showWithdrawSuccess = true;
}; };
onMounted(() => {
const message = {
type: "title",
data: "提现"
};
sendNativeMessage(message);
})
return { return {
...toRefs(state), ...toRefs(state),
formatter, formatter,
......
<template> <template>
<div>{{ count }}</div> <div>{{ count }}</div>
<button @click="emitTest">emit</button> <button @click="emitTest">emit</button>
<button @click="emitTest2">测试</button>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { ref } from "vue"; import { ref } from "vue";
import { useNativeBridge } from "@/util/use-native-bridge"; import { useNativeBridge } from "@/util/use-native-bridge";
import { Toast } from "vant";
const [sendNativeMessage, eventBus] = useNativeBridge("bindWechatChange", function(arg) { const [sendNativeMessage, eventBus] = useNativeBridge("title", function(arg) {
console.log(this, arg); Toast('hahahahah')
}); });
const count = ref(1000); const count = ref(1000);
const emitTest = () => { const emitTest = () => {
...@@ -20,6 +22,14 @@ const emitTest = () => { ...@@ -20,6 +22,14 @@ const emitTest = () => {
}); });
count.value = count.value + 1; count.value = count.value + 1;
}; };
const emitTest2 = () => {
eventBus.emit("GEEK_NATVIE_NAME", {
method: "title",
data: "我的体现计划"
});
};
</script> </script>
<style></style> <style></style>
...@@ -5995,6 +5995,11 @@ multicast-dns@^6.0.1: ...@@ -5995,6 +5995,11 @@ multicast-dns@^6.0.1:
dns-packet "^1.3.1" dns-packet "^1.3.1"
thunky "^1.0.2" thunky "^1.0.2"
mutation-observer@^1.0.3:
version "1.0.3"
resolved "https://registry.npm.taobao.org/mutation-observer/download/mutation-observer-1.0.3.tgz#42e9222b101bca82e5ba9d5a7acf4a14c0f263d0"
integrity sha1-QukiKxAbyoLlup1aes9KFMDyY9A=
mute-stream@0.0.8: mute-stream@0.0.8:
version "0.0.8" version "0.0.8"
resolved "https://registry.npm.taobao.org/mute-stream/download/mute-stream-0.0.8.tgz#1630c42b2251ff81e2a283de96a5497ea92e5e0d" resolved "https://registry.npm.taobao.org/mute-stream/download/mute-stream-0.0.8.tgz#1630c42b2251ff81e2a283de96a5497ea92e5e0d"
...@@ -8449,6 +8454,11 @@ tough-cookie@~2.5.0: ...@@ -8449,6 +8454,11 @@ tough-cookie@~2.5.0:
psl "^1.1.28" psl "^1.1.28"
punycode "^2.1.1" punycode "^2.1.1"
transitionEnd@^1.0.2:
version "1.0.2"
resolved "https://registry.npm.taobao.org/transitionEnd/download/transitionEnd-1.0.2.tgz#1914db5b45a7efdc34a01af69285a3a693871633"
integrity sha1-GRTbW0Wn79w0oBr2koWjppOHFjM=
tryer@^1.0.1: tryer@^1.0.1:
version "1.0.1" version "1.0.1"
resolved "https://registry.npm.taobao.org/tryer/download/tryer-1.0.1.tgz#f2c85406800b9b0f74c9f7465b81eaad241252f8" resolved "https://registry.npm.taobao.org/tryer/download/tryer-1.0.1.tgz#f2c85406800b9b0f74c9f7465b81eaad241252f8"
...@@ -8813,6 +8823,14 @@ vary@~1.1.2: ...@@ -8813,6 +8823,14 @@ vary@~1.1.2:
resolved "https://registry.npm.taobao.org/vary/download/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc" resolved "https://registry.npm.taobao.org/vary/download/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc"
integrity sha1-IpnwLG3tMNSllhsLn3RSShj2NPw= integrity sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=
vconsole@^3.4.0:
version "3.4.0"
resolved "https://registry.npm.taobao.org/vconsole/download/vconsole-3.4.0.tgz?cache=0&sync_timestamp=1610614380057&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fvconsole%2Fdownload%2Fvconsole-3.4.0.tgz#2cf2ffaa86cd7ab736997a22b63d05627c6ab567"
integrity sha1-LPL/qobNerc2mXoitj0FYnxqtWc=
dependencies:
mutation-observer "^1.0.3"
transitionEnd "^1.0.2"
vendors@^1.0.0: vendors@^1.0.0:
version "1.0.4" version "1.0.4"
resolved "https://registry.npm.taobao.org/vendors/download/vendors-1.0.4.tgz?cache=0&sync_timestamp=1615203397897&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fvendors%2Fdownload%2Fvendors-1.0.4.tgz#e2b800a53e7a29b93506c3cf41100d16c4c4ad8e" resolved "https://registry.npm.taobao.org/vendors/download/vendors-1.0.4.tgz?cache=0&sync_timestamp=1615203397897&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fvendors%2Fdownload%2Fvendors-1.0.4.tgz#e2b800a53e7a29b93506c3cf41100d16c4c4ad8e"
......
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