first commit
This commit is contained in:
168
src/views/Can/CanCharge.vue
Normal file
168
src/views/Can/CanCharge.vue
Normal file
@@ -0,0 +1,168 @@
|
||||
<template>
|
||||
<div>
|
||||
<v-toolbar dark>
|
||||
<v-spacer />
|
||||
<v-toolbar-title>코인 충전</v-toolbar-title>
|
||||
<v-spacer />
|
||||
</v-toolbar>
|
||||
|
||||
<br>
|
||||
<v-container>
|
||||
<v-text-field
|
||||
v-model="account_id"
|
||||
label="회원번호"
|
||||
outlined
|
||||
required
|
||||
/>
|
||||
|
||||
<v-text-field
|
||||
v-model="method"
|
||||
label="기록 내용"
|
||||
outlined
|
||||
required
|
||||
/>
|
||||
|
||||
<v-text-field
|
||||
v-model="coin"
|
||||
label="지급할 코인 수"
|
||||
outlined
|
||||
required
|
||||
/>
|
||||
|
||||
<v-row>
|
||||
<v-col cols="10" />
|
||||
<v-col>
|
||||
<v-btn
|
||||
block
|
||||
color="#9970ff"
|
||||
dark
|
||||
depressed
|
||||
@click="confirm"
|
||||
>
|
||||
코인 지급
|
||||
</v-btn>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-row>
|
||||
<v-dialog
|
||||
v-model="show_confirm"
|
||||
max-width="400px"
|
||||
persistent
|
||||
>
|
||||
<v-card>
|
||||
<v-card-title>코인 지급 확인</v-card-title>
|
||||
<v-card-text>
|
||||
회원번호: {{ account_id }}
|
||||
</v-card-text>
|
||||
<v-card-text>
|
||||
기록내용: {{ method }}
|
||||
</v-card-text>
|
||||
<v-card-text>
|
||||
지급할 코인 수: {{ coin }}코인
|
||||
</v-card-text>
|
||||
<v-card-actions v-show="!isLoading">
|
||||
<v-spacer />
|
||||
<v-btn
|
||||
color="blue darken-1"
|
||||
text
|
||||
@click="submit"
|
||||
>
|
||||
코인 지급
|
||||
</v-btn>
|
||||
<v-spacer />
|
||||
<v-btn
|
||||
color="blue darken-1"
|
||||
text
|
||||
@click="cancel"
|
||||
>
|
||||
취소
|
||||
</v-btn>
|
||||
<v-spacer />
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
</v-row>
|
||||
</v-container>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import * as api from '@/api/coin'
|
||||
|
||||
export default {
|
||||
name: "CoinCharge",
|
||||
|
||||
data() {
|
||||
return {
|
||||
show_confirm: false,
|
||||
isLoading: false,
|
||||
account_id: '',
|
||||
method: '',
|
||||
coin: ''
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
notifyError(message) {
|
||||
this.$dialog.notify.error(message)
|
||||
},
|
||||
|
||||
notifySuccess(message) {
|
||||
this.$dialog.notify.success(message)
|
||||
},
|
||||
|
||||
confirm() {
|
||||
if (this.account_id.trim() === '' || isNaN(this.account_id)) {
|
||||
return this.notifyError('코인을 지급할 회원의 회원번호를 입력하세요.')
|
||||
}
|
||||
|
||||
if (this.method.trim() === '') {
|
||||
return this.notifyError('기록할 내용을 입력하세요')
|
||||
}
|
||||
|
||||
if (isNaN(this.coin)) {
|
||||
return this.notifyError('코인은 숫자만 넣을 수 있습니다.')
|
||||
}
|
||||
|
||||
if (!this.isLoading) {
|
||||
this.show_confirm = true
|
||||
}
|
||||
},
|
||||
|
||||
cancel() {
|
||||
this.show_confirm = false
|
||||
},
|
||||
|
||||
async submit() {
|
||||
if (!this.isLoading) {
|
||||
this.isLoading = true
|
||||
|
||||
try {
|
||||
this.show_confirm = false
|
||||
|
||||
const res = await api.paymentCoin(Number(this.coin), this.method, this.account_id)
|
||||
if (res.status === 200 && res.data.success === true) {
|
||||
this.notifySuccess('코인이 지급되었습니다.')
|
||||
this.account_id = ''
|
||||
this.method = ''
|
||||
this.coin = ''
|
||||
this.is_loading = false
|
||||
} else {
|
||||
this.notifyError(res.data.message || '알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.')
|
||||
this.is_loading = false
|
||||
}
|
||||
} catch (e) {
|
||||
this.notifyError('알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.')
|
||||
this.is_loading = false
|
||||
} finally {
|
||||
this.is_loading = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
Reference in New Issue
Block a user