Commit 9345359e authored by wykolor's avatar wykolor

feat: 对接提现部分接口

parent bfbe5096
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
"amfe-flexible": "^2.2.1", "amfe-flexible": "^2.2.1",
"axios": "^0.21.1", "axios": "^0.21.1",
"core-js": "^3.6.5", "core-js": "^3.6.5",
"js-cookie": "^2.2.1",
"vant": "^3.0.9", "vant": "^3.0.9",
"vconsole": "^3.4.0", "vconsole": "^3.4.0",
"vue": "^3.0.0", "vue": "^3.0.0",
......
/* /*
* @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: mikey.zhaopeng
* @Last Modified time: 2021-03-26 15:38:13 * @Last Modified time: 2021-04-06 19:01:39
*/ */
export interface PageParams { export interface PageParams {
...@@ -69,14 +69,20 @@ export interface WithdrawListResponse { ...@@ -69,14 +69,20 @@ export interface WithdrawListResponse {
} }
export interface CheckCaptchaParams { export interface CheckCaptchaParams {
userId: string;
ticket: string; ticket: string;
randStr: string; randStr: string;
} }
export interface WithdrawParams { export interface WithdrawParams {
withdrawAmount: number; withdrawAmount: number;
userId: number;
studentId: number; studentId: number;
smsVerifyCode: string; smsVerifyCode: string;
} }
export interface WithdrawResponse {
serialNo: string;
withdrawAccount: string;
amount: number;
withdrawApplyTime: string;
expectedPayTime: string;
}
...@@ -6,34 +6,40 @@ import { ...@@ -6,34 +6,40 @@ import {
Paging, Paging,
WithdrawListParams, WithdrawListParams,
WithdrawListResponse, WithdrawListResponse,
WithdrawParams WithdrawParams,
WithdrawResponse
} from "@/model/bonus"; } from "@/model/bonus";
import { get, post } from "../../request"; import { get, post } from "../../request";
// 奖励金收支列表 // 奖励金收支列表
export const getBonusList = (params: BonusListParams) => { export const getBonusList = (params: BonusListParams) => {
return post<Paging<BonusListResponse>>( return get<Paging<BonusListResponse>>(
`/mock/api-jksxb-app/v1/marketingAccount/bonus/flow/list`, `/api-jksxb-app/v1/marketingAccount/bonus/flow/list`,
params params
); );
}; };
// 奖励金账户信息 // 奖励金账户信息
export const getBonusAccount = (studentId: string) => { export const getBonusAccount = (studentId: string) => {
return get<BonusAccountResponse>(`/mock/api-jksxb-app/v1/marketingAccount/bonus/count`, { studentId }); return get<BonusAccountResponse>(`/api-jksxb-app/v1/marketingAccount/bonus/count`, { studentId });
}; };
// 提现记录列表 // 提现记录列表
export const getWithdrawList = (params: WithdrawListParams) => { export const getWithdrawList = (params: WithdrawListParams) => {
return post<Paging<WithdrawListResponse>>(`/mock/api-jksxb-app/v1/withdraw/query`, params); return get<Paging<WithdrawListResponse>>(`/api-jksxb-app/v1/withdraw/query`, params);
}; };
// 检验图形验证码 // 检验图形验证码
export const checkCaptcha = (params: CheckCaptchaParams) => { export const checkCaptcha = (params: CheckCaptchaParams) => {
return get<string>(`/v1/withdraw/checkCaptcha`, params); return post<string>(`/api-jksxb-app/v1/withdraw/checkCaptcha`, params);
}; };
// 提现 // 提现
export const withdraw = (params: WithdrawParams) => { export const withdraw = (params: WithdrawParams) => {
return post<string>("/v1/withdraw", params); 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)
}
let baseURL = "";
if (process.env.NODE_ENV === "development") {
baseURL = "/api";
} else {
// baseURL = "";
}
export default baseURL;
import axios, { AxiosRequestConfig } from "axios"; import axios, { AxiosRequestConfig } from "axios";
import Cookies from 'js-cookie';
import { Toast } from "vant";
const instance = axios.create({ const instance = axios.create({
// headers: { headers: {
// 'content-type': 'application/json;charset=UTF-8', 'content-type': 'application/json;charset=UTF-8',
// 'token': 'one' 'Authorization': `Bearer ${Cookies.get('token')}`
// }, },
baseURL: "", baseURL: "",
timeout: 10000, timeout: 10000,
withCredentials: true withCredentials: true
...@@ -53,7 +55,10 @@ instance.interceptors.request.use( ...@@ -53,7 +55,10 @@ instance.interceptors.request.use(
// 响应拦截器 // 响应拦截器
instance.interceptors.response.use( instance.interceptors.response.use(
response => { response => {
// 隐藏加载样式 const { code, msg } = response.data;
if (code !== 0) {
return Promise.reject(msg);
}
return response.data; return response.data;
}, },
error => { error => {
......
import axios from "./http"; import axios from "./http";
import { BaseResponse } from "../model/bonus/index";
/** /**
* 封装的get请求 * 封装的get请求
* @param {*} url 请求路径 * @param {*} url 请求路径
...@@ -7,7 +6,7 @@ import { BaseResponse } from "../model/bonus/index"; ...@@ -7,7 +6,7 @@ import { BaseResponse } from "../model/bonus/index";
* @returns * @returns
*/ */
export function get<T>(url: string, params?: object) { export function get<T>(url: string, params?: object) {
return axios.get<T>(url, params); return axios.get<T>(url, { params });
} }
/** /**
...@@ -16,6 +15,6 @@ export function get<T>(url: string, params?: object) { ...@@ -16,6 +15,6 @@ export function get<T>(url: string, params?: object) {
* @param {*} params 请求参数 * @param {*} params 请求参数
* @returns * @returns
*/ */
export function post<T>(url: string, params?: object) { export function post<T>(url: string, data?: object) {
return axios.post<T>(url, params); return axios.post<T>(url, data);
} }
import Cookies from 'js-cookie'
const bonus = { const bonus = {
namespaced: true, namespaced: true,
state: () => ({ state: () => ({
...@@ -11,6 +12,7 @@ const bonus = { ...@@ -11,6 +12,7 @@ const bonus = {
state.studentId = payload; state.studentId = payload;
}, },
saveToken(state, payload) { saveToken(state, payload) {
Cookies.set('token', payload)
state.token = payload; state.token = payload;
}, },
saveUserId(state, payload) { saveUserId(state, payload) {
......
...@@ -24,6 +24,7 @@ window.$geek_excuteJS = function (args) { ...@@ -24,6 +24,7 @@ window.$geek_excuteJS = function (args) {
const params = JSON.parse(args); const params = JSON.parse(args);
eventBus.emit<NativeInvokeFuncParams>(GEEK_NATIVE_NAME, params); eventBus.emit<NativeInvokeFuncParams>(GEEK_NATIVE_NAME, params);
} catch (error) { } catch (error) {
eventBus.emit<NativeInvokeFuncParams>(GEEK_NATIVE_NAME, args); eventBus.emit<NativeInvokeFuncParams>(GEEK_NATIVE_NAME, args);
} }
}; };
......
...@@ -14,11 +14,11 @@ ...@@ -14,11 +14,11 @@
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">
<template v-if="reduceList.length"> <template>
<div v-for="item in reduceList" :key="item.id" class="bonus-detail-pay-item"> <div v-for="item in reduceList" :key="item.id" class="bonus-detail-pay-item">
<ul> <ul>
<li style="color: #000">{{ item.bizTypeName }}</li> <li style="color: #000">{{ item.bizTypeName }}</li>
...@@ -52,10 +52,10 @@ ...@@ -52,10 +52,10 @@
</ul> </ul>
</div> </div>
</template> </template>
<van-empty description="暂无数据~" v-else /> <!-- <van-empty description="暂无数据~" v-else /> -->
</van-tab> </van-tab>
<van-tab name="ADD" title="收入" class="bonus-detail-income-list"> <van-tab name="ADD" title="收入" class="bonus-detail-income-list">
<template v-if="addList.length"> <template>
<div class="bonus-detail-income-item" v-for="item in addList" :key="item.id"> <div class="bonus-detail-income-item" v-for="item in addList" :key="item.id">
<ul> <ul>
<li class="flex "> <li class="flex ">
...@@ -71,7 +71,7 @@ ...@@ -71,7 +71,7 @@
</ul> </ul>
</div> </div>
</template> </template>
<van-empty description="暂无数据~" v-else /> <!-- <van-empty description="暂无数据~" v-else /> -->
</van-tab> </van-tab>
</van-list> </van-list>
</van-pull-refresh> </van-pull-refresh>
...@@ -140,6 +140,10 @@ const BonusDetail = defineComponent({ ...@@ -140,6 +140,10 @@ const BonusDetail = defineComponent({
}; };
bonusModel.getBonusList(params).then(res => { bonusModel.getBonusList(params).then(res => {
const { list, total } = res.data; const { list, total } = res.data;
if (total === 0) {
state.finished = true;
return;
}
state.loading = false; state.loading = false;
if (state.active === FlowType.REDUCE) { if (state.active === FlowType.REDUCE) {
bonusList.reduceList = bonusList.reduceList.concat(list); bonusList.reduceList = bonusList.reduceList.concat(list);
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
<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 || 0 }}
<label <label
class="frozen" class="frozen"
v-if="bonusAccount?.status && bonusAccount?.status === BonusAccountStatus.FREEZE" v-if="bonusAccount?.status && bonusAccount?.status === BonusAccountStatus.FREEZE"
...@@ -35,21 +35,38 @@ ...@@ -35,21 +35,38 @@
<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 || 0 }}</span>
</van-col> </van-col>
<van-col span="8"> <van-col span="8">
<label>累计提现</label> <label>累计提现</label>
<span>¥{{ bonusAccount?.withdrawedTotal }}</span> <span>¥{{ bonusAccount?.withdrawedTotal || 0 }}</span>
</van-col> </van-col>
<van-col span="8"> <van-col span="8">
<label>提现中</label> <label>提现中</label>
<span>¥{{ bonusAccount?.withdrawing }}</span> <span>¥{{ bonusAccount?.withdrawing || 0 }}</span>
</van-col> </van-col>
</van-row> </van-row>
</div> </div>
<van-cell <van-cell
center center
:title="`可提现金额:¥${bonusAccount?.withdrawableTotal}`" :title="`微信(${bonusAccount?.withdrawAccount || '未绑定'})`"
size="large"
style="border-radius: 0.3rem; margin-bottom: 0.3rem"
:border="false"
>
<van-button
color="#39BF17"
:plain="bonusAccount?.withdrawAccount ? true : false"
round
size="small"
@click="bindWeiChatOrUnbind"
style="width: 70%"
>{{ bonusAccount?.withdrawAccount ? "换绑微信" : "绑定微信" }}</van-button
>
</van-cell>
<van-cell
center
:title="`可提现金额:¥${bonusAccount?.withdrawableTotal || 0}`"
size="large" size="large"
style="border-radius: 0.3rem;" style="border-radius: 0.3rem;"
:border="false" :border="false"
...@@ -62,14 +79,14 @@ ...@@ -62,14 +79,14 @@
<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 || 0 }}元&nbsp;</van-col
> >
</van-row> </van-row>
<van-list <van-list
v-model:loading="loading" v-model:loading="loading"
:finished="finished" :finished="finished"
finished-text="~我是有底线的~" finished-text="~暂无更多数据~"
@load="onLoad" @load="onLoad"
:immediate-check="false" :immediate-check="false"
> >
...@@ -135,11 +152,15 @@ ...@@ -135,11 +152,15 @@
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="
bonusAccount?.withdrawAccount
? '换绑后,将提现到新绑定的微信零钱中!'
: '绑定微信后,才可进行提现!'
"
> >
<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="bindWeiChat" :disabled="binding" ><van-button type="primary" round @click="bindWeiChatModal" :disabled="binding"
><van-loading v-if="binding" size="20px" color="#ccc">绑定中...</van-loading ><van-loading v-if="binding" size="20px" color="#ccc">绑定中...</van-loading
><span v-else>绑定微信</span></van-button ><span v-else>绑定微信</span></van-button
> >
...@@ -167,13 +188,14 @@ import { computed, defineComponent, onMounted, reactive, toRefs } from "vue"; ...@@ -167,13 +188,14 @@ import { computed, defineComponent, onMounted, reactive, toRefs } from "vue";
import { useRoute, useRouter } from "vue-router"; import { useRoute, useRouter } from "vue-router";
import { useStore } from "vuex"; import { useStore } from "vuex";
import { Dialog, Button, Col, Row, Cell, List, Loading } from "vant"; import { Dialog, Button, Col, Row, Cell, List, Loading, Toast } from "vant";
import { BonusAccountResponse, WithdrawListParams, WithdrawListResponse } from "@/model/bonus"; import { BonusAccountResponse, WithdrawListParams, WithdrawListResponse } from "@/model/bonus";
import { bonusModel } from "@/server/api"; import { bonusModel } from "@/server/api";
import { BonusAccountStatus, ErrCode } from "@/model/bonus/constant"; import { BonusAccountStatus, ErrCode } from "@/model/bonus/constant";
import { bindWeChat, useNativeBridge, makeCall } from "@/util/use-native-bridge"; import { bindWeChat, useNativeBridge, makeCall } from "@/util/use-native-bridge";
import { formatBonusTipTxt } from "@/util/formatBonusTipTxt"; import { formatBonusTipTxt } from "@/util/formatBonusTipTxt";
import { bindWeiChat } from "@/server/api/bonus";
interface BonusState { interface BonusState {
withdrawList: WithdrawListResponse[]; withdrawList: WithdrawListResponse[];
...@@ -223,7 +245,11 @@ const Bonus = defineComponent({ ...@@ -223,7 +245,11 @@ const Bonus = defineComponent({
const onLoad = () => { const onLoad = () => {
state.loading = true; state.loading = true;
bonusModel.getWithdrawList(withdrawListParams).then(res => { bonusModel.getWithdrawList(withdrawListParams).then(res => {
const { hasNextPage, list } = res.data; const { hasNextPage, list, total } = res.data;
if (!list || total === 0) {
state.finished = true;
return;
}
state.loading = false; state.loading = false;
state.finished = !hasNextPage; state.finished = !hasNextPage;
state.withdrawList = state.withdrawList.concat(list); state.withdrawList = state.withdrawList.concat(list);
...@@ -239,32 +265,57 @@ const Bonus = defineComponent({ ...@@ -239,32 +265,57 @@ const Bonus = defineComponent({
onLoad(); onLoad();
}); });
const withdraw = () => { const withdraw = () => {
if (!state.bonusAccount?.errCode) {
// 都正常的状态
router.push({
name: "withdraw",
params: {
withdrawableTotal: state.bonusAccount?.withdrawableTotal || 0,
withdrawAccount: state.bonusAccount?.withdrawAccount || ""
}
});
} else if (state.bonusAccount?.errCode === ErrCode.NOT_BIND) {
state.showBindWx = true; state.showBindWx = true;
// if (!state.bonusAccount?.errCode) { } else {
// // 都正常的状态 state.showDangerous = true;
// router.push("withdraw"); }
// } else if (state.bonusAccount?.errCode === ErrCode.NOT_BIND) {
// state.showBindWx = true;
// } else {
// state.showDangerous = true;
// }
}; };
const withdrawRule = () => { const withdrawRule = () => {
state.showWithdrawRules = true; state.showWithdrawRules = true;
}; };
const phoneCall = () => { const phoneCall = () => {
makeCall("400—8777389") makeCall("400—8777389");
// sendNativeMessage({
// type: "phoneCall",
// data: "400—8777389"
// });
}; };
const bindWeiChat = () => {
const bindWeiChatModal = async () => {
state.binding = true; state.binding = true;
bindWeChat().then(() => { const params = await bindWeChat();
bindWeiChat(params)
.then(() => {
Toast("绑定成功");
state.showBindWx = false; state.showBindWx = false;
state.binding = false; state.binding = false;
getBonusAccount(); getBonusAccount();
})
.catch(() => {
Toast("绑定失败");
});
};
// 绑定或者换邦
const bindWeiChatOrUnbind = async () => {
// 已经绑定微信
if (state.bonusAccount?.withdrawAccount) {
state.showBindWx = true;
return false;
}
const params = await bindWeChat();
bindWeiChat(params)
.then(() => {
getBonusAccount();
Toast("绑定成功");
})
.catch(() => {
Toast("绑定失败");
}); });
}; };
return { return {
...@@ -273,7 +324,8 @@ const Bonus = defineComponent({ ...@@ -273,7 +324,8 @@ const Bonus = defineComponent({
withdraw, withdraw,
withdrawRule, withdrawRule,
phoneCall, phoneCall,
bindWeiChat, bindWeiChatModal,
bindWeiChatOrUnbind,
bonusStoreState, bonusStoreState,
formatBonusTipTxt formatBonusTipTxt
}; };
......
...@@ -21,12 +21,12 @@ ...@@ -21,12 +21,12 @@
type="primary" type="primary"
round round
color="#F1551E" color="#F1551E"
@click="withdrawAmount = maxMoney" @click="withdrawAmount = withdrawableTotal"
>全部</van-button >全部</van-button
> >
</template> </template>
</van-field> </van-field>
<p class="bonus-withdraw-input-valid">今日可提现金额¥{{ maxMoney }}元</p> <p class="bonus-withdraw-input-valid">今日可提现金额¥{{ withdrawableTotal }}元</p>
<p class="bonus-withdraw-input-tip"> <p class="bonus-withdraw-input-tip">
<i class="iconfont icon-wenhao"></i> <i class="iconfont icon-wenhao"></i>
<span>单日累计提现不超过500元!</span> <span>单日累计提现不超过500元!</span>
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
<van-cell class="van-cell-tip" title="提现至" size="large" :border="false"> <van-cell class="van-cell-tip" title="提现至" size="large" :border="false">
<div class="slot-value"> <div class="slot-value">
<img class="wechat" src="../../../assets/images/bonus/wechat.png" alt="微信图片" /> <img class="wechat" src="../../../assets/images/bonus/wechat.png" alt="微信图片" />
<span class="van-ellipsis">微信名字k~k~kolor</span> <span class="van-ellipsis">微信名字:{{ withdrawAccount }}</span>
</div> </div>
</van-cell> </van-cell>
<div class="handle-btn"> <div class="handle-btn">
...@@ -52,7 +52,7 @@ ...@@ -52,7 +52,7 @@
class="withdraw-dialog" class="withdraw-dialog"
> >
<ul class="withdraw-dialog-header"> <ul class="withdraw-dialog-header">
<li>提现至微信账户:k~k~kolor</li> <li>提现至微信账户:{{ withdrawAccount }}</li>
<li class="withdraw-dialog-header-money">¥{{ withdrawAmount }}</li> <li class="withdraw-dialog-header-money">¥{{ withdrawAmount }}</li>
</ul> </ul>
<ul class="withdraw-dialog-field"> <ul class="withdraw-dialog-field">
...@@ -74,7 +74,9 @@ ...@@ -74,7 +74,9 @@
</template> </template>
</van-field> </van-field>
</li> </li>
<li class="withdraw-dialog-field-tip">今日可提现已将验证码发送至{{ mobileTip }}</li> <li class="withdraw-dialog-field-tip" v-if="mobileTip">
今日可提现已将验证码发送至{{ mobileTip }}
</li>
</ul> </ul>
<div class="handle-btns"> <div class="handle-btns">
<van-button round type="primary" size="large" block color="#027AFF;" @click="withdrawReal" <van-button round type="primary" size="large" block color="#027AFF;" @click="withdrawReal"
...@@ -104,11 +106,11 @@ ...@@ -104,11 +106,11 @@
<ul class="withdraw-success-dialog-text"> <ul class="withdraw-success-dialog-text">
<li>提现申请成功!</li> <li>提现申请成功!</li>
<li>提现金额:</li> <li>提现金额:</li>
<li>¥1345.00</li> <li>¥{{ withdrawResponse?.amount }}</li>
<li>提现至微信</li> <li>提现至微信</li>
<li>k~k~kololr</li> <li>{{ withdrawResponse?.withdrawAccount }}</li>
<li>预计到账时间</li> <li>预计到账时间</li>
<li>2021/3/7 12:12:12</li> <li>{{ withdrawResponse?.expectedPayTime }}</li>
</ul> </ul>
<div class="withdraw-success-dialog-btns"> <div class="withdraw-success-dialog-btns">
<van-button <van-button
...@@ -129,10 +131,14 @@ ...@@ -129,10 +131,14 @@
<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, onMounted, reactive, toRefs } from "vue"; import { computed, defineComponent, onMounted, reactive, ref, toRefs } from "vue";
import { Button, Cell, Dialog, Field, Toast } from "vant"; import { Button, Cell, Dialog, Field, Toast } from "vant";
import { useRoute } from "vue-router";
import { useStore } from "vuex";
import { useNativeBridge } from "@/util/use-native-bridge"; import { useNativeBridge } from "@/util/use-native-bridge";
import { countDown } from "../../../util/timer"; import { countDown } from "../../../util/timer";
import { checkCaptcha, withdraw } from "@/server/api/bonus";
import { WithdrawResponse } from "@/model/bonus";
interface TencentCaptchaResponse { interface TencentCaptchaResponse {
ret: number; ret: number;
ticket: string; ticket: string;
...@@ -140,6 +146,11 @@ interface TencentCaptchaResponse { ...@@ -140,6 +146,11 @@ interface TencentCaptchaResponse {
bizState: unknown; bizState: unknown;
randstr: string; randstr: string;
} }
interface State {
WithdrawResponse: WithdrawResponse | object;
[key: string]: unknown;
}
const Withdraw = defineComponent({ const Withdraw = defineComponent({
components: { components: {
[Button.name]: Button, [Button.name]: Button,
...@@ -148,21 +159,29 @@ const Withdraw = defineComponent({ ...@@ -148,21 +159,29 @@ const Withdraw = defineComponent({
[Dialog.Component.name]: Dialog.Component [Dialog.Component.name]: Dialog.Component
}, },
setup() { setup() {
const [sendNativeMessage, eventBus] = useNativeBridge("title", function(arg) { const [sendNativeMessage] = useNativeBridge("title", function(arg) {
console.log(this, arg); console.log(this, arg);
}); });
const route = useRoute();
const store = useStore();
const bonusStoreState = computed(() => store.state.bonus);
const state = reactive({ const state = reactive({
withdrawAmount: "", withdrawAmount: 0,
smsVerifyCode: "", smsVerifyCode: "",
maxMoney: 500.32, withdrawableTotal: 500.32,
showTime: "获取验证码", showTime: "获取验证码",
showWithdraw: false, showWithdraw: false,
showWithdrawSuccess: false, showWithdrawSuccess: false,
mobileTip: "191****1273" mobileTip: "",
withdrawAccount: "",
withdrawResponse: {}
}); });
const { withdrawableTotal, withdrawAccount } = route.params;
state.withdrawableTotal = Number(withdrawableTotal);
state.withdrawAccount = withdrawAccount as string;
const formatter = value => { const formatter = value => {
if (value > state.maxMoney) { if (value > state.withdrawAccount) {
return state.maxMoney; return state.withdrawAccount;
} }
return value && Number(value).toFixed(2); return value && Number(value).toFixed(2);
...@@ -183,8 +202,10 @@ const Withdraw = defineComponent({ ...@@ -183,8 +202,10 @@ const Withdraw = defineComponent({
const getSmsVerifyCode = () => { const getSmsVerifyCode = () => {
const captcha1 = new TencentCaptcha( const captcha1 = new TencentCaptcha(
"2087826974", "2087826974",
(res: TencentCaptchaResponse) => { async (res: TencentCaptchaResponse) => {
const { ret } = res; const { ret, randstr, ticket } = res;
const { data } = await checkCaptcha({ randStr: randstr, ticket });
state.mobileTip = data;
if (ret === 0) { if (ret === 0) {
countDown(60, 1000, (time: number) => { countDown(60, 1000, (time: number) => {
time === 0 ? (state.showTime = `获取验证码`) : (state.showTime = `${time} 后再获取`); time === 0 ? (state.showTime = `获取验证码`) : (state.showTime = `${time} 后再获取`);
...@@ -198,12 +219,25 @@ const Withdraw = defineComponent({ ...@@ -198,12 +219,25 @@ const Withdraw = defineComponent({
captcha1.show(); captcha1.show();
}; };
const withdrawReal = () => { const withdrawReal = async () => {
if (!state.smsVerifyCode) { if (!state.smsVerifyCode) {
Toast("请输入验证码"); Toast("请输入验证码");
return; return;
} }
try {
const params = {
studentId: bonusStoreState.value.studentId,
smsVerifyCode: state.smsVerifyCode,
withdrawAmount: state.withdrawAmount
};
const { data } = await withdraw(params);
state.withdrawResponse = data;
state.showWithdrawSuccess = true; state.showWithdrawSuccess = true;
} catch (err) {
Toast(err);
}
// state.showWithdrawSuccess = true;
}; };
onMounted(() => { onMounted(() => {
const message = { const message = {
...@@ -211,7 +245,7 @@ const Withdraw = defineComponent({ ...@@ -211,7 +245,7 @@ const Withdraw = defineComponent({
data: "提现" data: "提现"
}; };
sendNativeMessage(message); sendNativeMessage(message);
}) });
return { return {
...toRefs(state), ...toRefs(state),
formatter, formatter,
......
...@@ -12,13 +12,13 @@ module.exports = { ...@@ -12,13 +12,13 @@ module.exports = {
ws: true, ws: true,
changOrigin: true //允许跨域 changOrigin: true //允许跨域
}, },
"/api": { "/service": {
target: "http://192.168.44.114:4100", target: "http://172.10.62.92",
ws: true, ws: true,
changOrigin: true //允许跨域 changOrigin: true //允许跨域
}, },
"/service": { "/api": {
target: "http://192.168.44.114:4100", target: "http://172.10.62.92",
ws: true, ws: true,
changOrigin: true //允许跨域 changOrigin: true //允许跨域
} }
......
...@@ -5328,6 +5328,11 @@ js-base64@^2.1.9: ...@@ -5328,6 +5328,11 @@ js-base64@^2.1.9:
resolved "https://registry.npm.taobao.org/js-base64/download/js-base64-2.6.4.tgz?cache=0&sync_timestamp=1604450326544&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fjs-base64%2Fdownload%2Fjs-base64-2.6.4.tgz#f4e686c5de1ea1f867dbcad3d46d969428df98c4" resolved "https://registry.npm.taobao.org/js-base64/download/js-base64-2.6.4.tgz?cache=0&sync_timestamp=1604450326544&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fjs-base64%2Fdownload%2Fjs-base64-2.6.4.tgz#f4e686c5de1ea1f867dbcad3d46d969428df98c4"
integrity sha1-9OaGxd4eofhn28rT1G2WlCjfmMQ= integrity sha1-9OaGxd4eofhn28rT1G2WlCjfmMQ=
js-cookie@^2.2.1:
version "2.2.1"
resolved "https://registry.npm.taobao.org/js-cookie/download/js-cookie-2.2.1.tgz#69e106dc5d5806894562902aa5baec3744e9b2b8"
integrity sha1-aeEG3F1YBolFYpAqpbrsN0Tpsrg=
js-message@1.0.7: js-message@1.0.7:
version "1.0.7" version "1.0.7"
resolved "https://registry.npm.taobao.org/js-message/download/js-message-1.0.7.tgz#fbddd053c7a47021871bb8b2c95397cc17c20e47" resolved "https://registry.npm.taobao.org/js-message/download/js-message-1.0.7.tgz#fbddd053c7a47021871bb8b2c95397cc17c20e47"
......
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