Commit 81db3e94 authored by wykolor's avatar wykolor

feat: bonus store module

parent 6977ae15
import { createStore } from "vuex";
import bonus from './module/bonus'
export default createStore({
state: {},
state: {
studentName: 'wangyan'
},
getters: {
studentFullName: state => state.studentName + 'WANG'
},
mutations: {},
actions: {},
modules: {}
modules: {
bonus: bonus
}
});
const bonus = {
namespaced: true,
state: () => ({
studentId: 12,
userId: 'color'
}),
getters: {
studentId: state => state.studentId + 1,
userName: state => state.userId + 'wangyan',
studentFullName: state => state.studentId + state.userId
},
mutations: {
},
actions: {
}
}
export default bonus
\ No newline at end of file
......@@ -154,12 +154,17 @@
<script lang="ts">
// eslint-disable-next-line @typescript-eslint/no-explicit-any
import { defineComponent, reactive } from "vue";
import { computed, defineComponent, reactive } from "vue";
import { Dialog, Button, Col, Row, Cell, List } from "vant";
import { BonusAccountResponse, WithdrawListResponse } from "@/model/bonus";
import { useStore } from "vuex";
const Bonus = defineComponent({
setup(props) {
setup() {
const store = useStore();
const bonusStoreState = computed(() => store.state.bonus);
const getters = computed(() => store.getters);
console.log(getters);
const state = reactive({
loading: false,
finished: false
......@@ -224,7 +229,8 @@ const Bonus = defineComponent({
state,
bonusAccount,
withdrawList,
onLoad
onLoad,
bonusStoreState
};
},
components: {
......@@ -244,12 +250,9 @@ const Bonus = defineComponent({
};
},
methods: {
onClickLeft() {
console.log("返回");
},
withdrawRule() {
this.showDialog = true;
// console.log(this.$store.state.studentId);
},
withdraw() {
......
......@@ -3,7 +3,7 @@
<div class="bonus-withdraw-input">
<van-field
class="bonus-withdraw-input-field"
v-model="money"
v-model="withdrawAmount"
center
clearable
label="¥"
......@@ -21,7 +21,7 @@
type="primary"
round
color="#F1551E"
@click="money = maxMoney"
@click="withdrawAmount = maxMoney"
>全部</van-button
>
</template>
......@@ -53,23 +53,28 @@
>
<ul class="withdraw-dialog-header">
<li>提现至微信账户:k~k~kolor</li>
<li class="withdraw-dialog-header-money">¥{{ money }}</li>
<li class="withdraw-dialog-header-money">¥{{ withdrawAmount }}</li>
</ul>
<ul class="withdraw-dialog-field">
<li>
<van-field v-model="sms" type="digit" label-width="0" placeholder="请输入验证码">
<van-field
v-model="smsVerifyCode"
type="digit"
label-width="0"
placeholder="请输入验证码"
>
<template #button>
<van-button
type="primary"
color="#027AFF"
@click="getSms"
@click="getSmsVerifyCode"
:disabled="showTime != '获取验证码'"
>{{ showTime }}</van-button
>
</template>
</van-field>
</li>
<li class="withdraw-dialog-field-tip">今日可提现已将验证码发送至191****1273</li>
<li class="withdraw-dialog-field-tip">今日可提现已将验证码发送至{{ mobileTip }}</li>
</ul>
<div class="handle-btns">
<van-button round type="primary" size="large" block color="#027AFF;" @click="withdrawReal"
......@@ -143,12 +148,13 @@ const Withdraw = defineComponent({
},
setup() {
const state = reactive({
money: "",
sms: "",
withdrawAmount: "",
smsVerifyCode: "",
maxMoney: 500.32,
showTime: "获取验证码",
showWithdraw: false,
showWithdrawSuccess: false
showWithdrawSuccess: false,
mobileTip: "191****1273"
});
const formatter = value => {
if (value > state.maxMoney) {
......@@ -159,18 +165,18 @@ const Withdraw = defineComponent({
};
// 确认提现
const withdrawSubmit = () => {
if (!state.money) {
if (!state.withdrawAmount) {
Toast("请输入提现金额");
return false;
}
if (Number(state.money) < 1) {
if (Number(state.withdrawAmount) < 1) {
Toast("金额必须大于等于1元");
return false;
}
state.showWithdraw = true;
};
const getSms = () => {
const getSmsVerifyCode = () => {
const captcha1 = new TencentCaptcha(
"2087826974",
(res: TencentCaptchaResponse) => {
......@@ -189,7 +195,7 @@ const Withdraw = defineComponent({
};
const withdrawReal = () => {
if (!state.sms) {
if (!state.smsVerifyCode) {
Toast("请输入验证码");
return;
}
......@@ -198,7 +204,7 @@ const Withdraw = defineComponent({
return {
...toRefs(state),
formatter,
getSms,
getSmsVerifyCode,
withdrawSubmit,
withdrawReal
};
......
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