MyWallet.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. <template>
  2. <div class="MyWallet"
  3. :style="localOptions.style">
  4. <div class="header">
  5. جزییات کیف پول
  6. </div>
  7. <div class="body">
  8. <div class="card-column">
  9. <div class="card">
  10. <div class="photo">
  11. <q-img src="/assets/images/web/user-top-menu-logo.png"
  12. width="33px" />
  13. </div>
  14. <div class="title">
  15. کیف پول شما
  16. </div>
  17. <div class="inventory">
  18. {{ wallet.inventory.toLocaleString('fa') }}
  19. <span class="unit">
  20. ریال
  21. </span>
  22. </div>
  23. </div>
  24. </div>
  25. <div class="actions-column">
  26. <div class="deposit-section">
  27. <div class="row q-col-gutter-md">
  28. <div class="col-md-5 col-12">
  29. <div>افزایش موجودی</div>
  30. <q-input v-model="depositAmount"
  31. dense
  32. placeholder="لطفا مبلغ مورد نظر خود را مشخص کنید" />
  33. </div>
  34. <div class="col-md-7 col-12">
  35. <q-btn class="btn-deposit"
  36. color="primary"
  37. :loading="wallet.loading"
  38. @click="deposit">
  39. <q-icon name="add_circle_outline"
  40. class="q-mr-sm" />
  41. افزایش موجودی
  42. </q-btn>
  43. </div>
  44. </div>
  45. </div>
  46. <div class="withdraw-section q-mt-md">
  47. <div class="row q-col-gutter-sm">
  48. <div class="col-md-5 col-12">
  49. <div class="title-of-input">
  50. <div>
  51. برداشت از کیف پول
  52. </div>
  53. <q-btn flat
  54. color="primary"
  55. @click="setWithdrawAmountForAll">
  56. برداشت همه
  57. </q-btn>
  58. </div>
  59. <q-input v-model="withdrawAmount"
  60. dense
  61. placeholder="لطفا مبلغ مورد نظر خود را مشخص کنید" />
  62. </div>
  63. <div class="col-md-4 col-12">
  64. <div class="title-of-input">شماره شبا</div>
  65. <q-input v-model="shabaNumber"
  66. dense
  67. placeholder="شماره شبای خود را وارد نمایید" />
  68. </div>
  69. <div class="col-md-3 col-12">
  70. <q-btn class="btn-withdraw"
  71. color="red"
  72. outline
  73. :loading="wallet.loading"
  74. @click="withdraw">
  75. <q-icon name="remove_circle_outline"
  76. class="q-mr-sm" />
  77. برداشت از حساب
  78. </q-btn>
  79. </div>
  80. </div>
  81. </div>
  82. </div>
  83. </div>
  84. </div>
  85. </template>
  86. <script>
  87. import { User } from 'src/models/User.js'
  88. import { Wallet } from 'src/models/Wallet.js'
  89. import { mixinWidget } from 'src/mixin/Mixins.js'
  90. import { APIGateway } from 'src/api/APIGateway.js'
  91. export default {
  92. name: 'MyWallet',
  93. mixins: [mixinWidget],
  94. data: () => {
  95. return {
  96. user: new User(),
  97. wallet: new Wallet(),
  98. shabaNumber: null,
  99. withdrawAmount: null,
  100. depositAmount: null
  101. }
  102. },
  103. mounted() {
  104. this.loadAuthData()
  105. this.getMyWallet()
  106. },
  107. methods: {
  108. loadAuthData() { // prevent Hydration node mismatch
  109. this.user = this.$store.getters['Auth/user']
  110. },
  111. getMyWallet () {
  112. this.wallet.loading = true
  113. APIGateway.wallet.getMyWallet(this.user.id)
  114. .then((wallet) => {
  115. this.wallet = new Wallet(wallet)
  116. this.wallet.loading = false
  117. })
  118. .catch(() => {
  119. this.wallet.loading = false
  120. })
  121. },
  122. deposit () {
  123. this.wallet.loading = true
  124. APIGateway.wallet.deposit({ amount: this.depositAmount })
  125. .then((url) => {
  126. window.location.href = url
  127. })
  128. .catch(() => {
  129. this.wallet.loading = false
  130. })
  131. },
  132. withdraw () {
  133. this.wallet.loading = true
  134. APIGateway.payment.requestWithdraw({ IBAN: this.shabaNumber, amount: this.withdrawAmount })
  135. .then(() => {
  136. this.shabaNumber = null
  137. this.withdrawAmount = null
  138. this.getMyWallet()
  139. this.$bus.emit('ReloadUserPayments')
  140. })
  141. .catch(() => {
  142. this.wallet.loading = false
  143. })
  144. },
  145. setWithdrawAmountForAll () {
  146. this.withdrawAmount = this.wallet.inventory
  147. }
  148. }
  149. }
  150. </script>
  151. <style scoped lang="scss">
  152. .MyWallet {
  153. background: #FFFFFF;
  154. border: 1px solid #DFE1EC;
  155. border-radius: 8px;
  156. .header {
  157. padding-left: 21px;
  158. display: flex;
  159. flex-flow: row;
  160. justify-content: flex-start;
  161. align-items: center;
  162. font-size: 16px;
  163. letter-spacing: 0;
  164. color: #212121;
  165. height: 70px;
  166. border-bottom: 1px solid #DFE1EC;
  167. }
  168. .body {
  169. display: flex;
  170. flex-flow: row;
  171. flex-wrap: wrap;
  172. justify-content: flex-start;
  173. align-items: center;
  174. padding: 45px 16px;
  175. $cardColumn: 380px;
  176. .card-column {
  177. width: $cardColumn;
  178. @media screen and (max-width: 1024px) {
  179. width: 100%;
  180. }
  181. .card {
  182. max-width: 357px;
  183. width: 100%;
  184. height: 165px;
  185. background: transparent linear-gradient(-242deg, #8AB890 0%, #5B7A5F 100%) 0 0 no-repeat padding-box;
  186. border-radius: 20px;
  187. position: relative;
  188. .photo {
  189. position: absolute;
  190. top: 20px;
  191. left: 20px;
  192. width: 60px;
  193. height: 60px;
  194. background: white;
  195. border-radius: 10px;
  196. display: flex;
  197. flex-flow: row;
  198. justify-content: center;
  199. align-items: center;
  200. }
  201. .title {
  202. position: absolute;
  203. top: 41px;
  204. left: 90px;
  205. color: #FFFFFF;
  206. font-size: 16px;
  207. }
  208. .inventory {
  209. position: absolute;
  210. top: 108px;
  211. left: 105px;
  212. color: #FFFFFF;
  213. font-size: 24px;
  214. @media screen and (max-width: 500px) {
  215. left: 50px;
  216. }
  217. .unit {
  218. font-size: 18px;
  219. }
  220. }
  221. }
  222. }
  223. .actions-column {
  224. width: calc( 100% - #{$cardColumn} );
  225. @media screen and (max-width: 1024px) {
  226. width: 100%;
  227. margin-top: 32px;
  228. }
  229. .deposit-section {
  230. .btn-deposit {
  231. margin-top: 25px;
  232. }
  233. }
  234. .withdraw-section {
  235. .title-of-input {
  236. display: flex;
  237. justify-content: space-between;
  238. align-items: center;
  239. height: 32px;
  240. }
  241. .btn-withdraw {
  242. margin-top: 35px;
  243. }
  244. }
  245. }
  246. }
  247. }
  248. </style>