MyWallet.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <template>
  2. <el-row>
  3. <el-col :md="12">
  4. <el-card class="box-card">
  5. <div slot="header" class="clearfix">
  6. <span>我的钱包</span>
  7. <el-button style="float: right; padding: 3px 0" type="text" @click="getBillRecord">账单</el-button>
  8. </div>
  9. <div class="text item">
  10. <el-row>
  11. <h1>余额: <span style="color: red">¥{{wallet.balance}}</span></h1>
  12. </el-row>
  13. <el-row>
  14. <el-button
  15. size="medium"
  16. type="success"
  17. @click="showChargeDialog"
  18. >充值</el-button>
  19. </el-row>
  20. </div>
  21. </el-card>
  22. </el-col>
  23. <el-dialog
  24. title="充值"
  25. append-to-body
  26. :visible.sync="chargeDialog"
  27. width="30%"
  28. center
  29. >
  30. <el-form ref="form" :model="chargeForm">
  31. <el-form-item label="充值金额">
  32. <el-input
  33. v-model="chargeForm.quantity"
  34. placeholder="0.00"
  35. style="width: 70%; padding-right: 2px"
  36. clearable
  37. />
  38. </el-form-item>
  39. <el-form-item>
  40. <el-button
  41. type="primary"
  42. @click="chargeWallet"
  43. >确定</el-button>
  44. </el-form-item>
  45. </el-form>
  46. </el-dialog>
  47. </el-row>
  48. </template>
  49. <script>
  50. import {chargeWallet, getWallet, getWalletBill} from "@/api/mall";
  51. export default {
  52. name: 'MyWallet',
  53. data() {
  54. return {
  55. chargeDialog: false,
  56. chargeForm: {
  57. quantity: null
  58. },
  59. wallet: {
  60. balance: '0.00'
  61. }
  62. }
  63. },
  64. created() {
  65. document.title = '我的钱包'
  66. getWallet().then(resp => {
  67. if (resp.code === 0) {
  68. this.wallet = resp.data
  69. }
  70. })
  71. },
  72. mounted() {
  73. },
  74. methods: {
  75. showChargeDialog() {
  76. this.chargeDialog = true
  77. },
  78. chargeWallet() {
  79. if (this.chargeForm.quantity === null) {
  80. this.$message('请填写充值金额')
  81. return
  82. }
  83. this.chargeDialog = false
  84. chargeWallet(this.chargeForm).then(resp => {
  85. if (resp.code === 0) {
  86. this.$message('充值请求已提交')
  87. }
  88. })
  89. },
  90. getBillRecord() {
  91. getWalletBill().then(resp => {
  92. if (resp.code === 0) {
  93. console.log(resp.data)
  94. }
  95. })
  96. }
  97. }
  98. }
  99. </script>
  100. <style scoped>
  101. .clearfix:before,
  102. .clearfix:after {
  103. display: table;
  104. content: "";
  105. }
  106. .clearfix:after {
  107. clear: both;
  108. }
  109. </style>