Commit 81db3e94 authored by wykolor's avatar wykolor

feat: bonus store module

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