InvoicePaymentCard.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. <template>
  2. <div class="InvoicePaymentCard">
  3. <div class="InvoicePaymentCard-head">
  4. <div class="InvoicePaymentCard-head-title">
  5. پرداخت از طریق کیف پول
  6. </div>
  7. <div class="InvoicePaymentCard-head-caption">
  8. خرید شما قطعی نشده است و در صورت عدم پرداخت تا پایان زمان، صورتحساب شما لغو خواهد شد
  9. </div>
  10. <div class="InvoicePaymentCard-head-remaining-time">
  11. <q-icon name="isax:clock" />
  12. زمان باقی مانده :
  13. {{ timerString }}
  14. </div>
  15. </div>
  16. <div class="InvoicePaymentCard-body">
  17. <div class="final-price">
  18. <div class="final-price-label">
  19. <q-img src="/assets/images/web/user-top-menu-logo.png"
  20. width="32px" />
  21. خرید محصول از فروشگاه
  22. </div>
  23. <div class="final-price-value">
  24. {{ invoice.amount ? invoice.amount.toLocaleString('fa') : 0 }}
  25. <span class="unit">
  26. ریال
  27. </span>
  28. </div>
  29. </div>
  30. <div class="other-items">
  31. <div class="other-item">
  32. <div class="other-item-label">
  33. <q-icon name="isax:wallet" />
  34. موجودی کیف پول
  35. </div>
  36. <div class="other-item-value">
  37. <q-skeleton v-if="wallet.loading"
  38. type="text"
  39. width="200px" />
  40. <template v-else>
  41. {{ wallet.inventory ? wallet.inventory.toLocaleString('fa') : 0 }}
  42. </template>
  43. <span class="unit">
  44. ریال
  45. </span>
  46. </div>
  47. </div>
  48. <div v-if="needToDeposit"
  49. class="other-item">
  50. <div class="other-item-label">
  51. <q-icon name="isax:card" />
  52. نیازمند افزایش موجودی
  53. </div>
  54. <div class="other-item-value">
  55. {{ (invoice.amount - wallet.inventory) ? (invoice.amount - wallet.inventory).toLocaleString('fa') : 0 }}
  56. <span class="unit">
  57. ریال
  58. </span>
  59. </div>
  60. </div>
  61. </div>
  62. <div class="action-area">
  63. <q-btn color="red"
  64. class="btn-cancel"
  65. outline
  66. :loading="invoice.loading || wallet.loading"
  67. @click="onCancel">
  68. انصراف
  69. </q-btn>
  70. <q-btn color="primary"
  71. class="btn-pay"
  72. :loading="invoice.loading || wallet.loading"
  73. @click="onAccept">
  74. <template v-if="amountOfDepositWalletNeeded > 0">
  75. افزایش موجودی و پرداخت
  76. </template>
  77. <template v-else>
  78. برداشت از کیف پول و برداشت
  79. </template>
  80. </q-btn>
  81. </div>
  82. <div v-if="showInvoiceLinkBtn"
  83. class="show-invoice-row">
  84. <q-btn class="btn-show-invoice"
  85. color="primary"
  86. flat
  87. :to="{name: 'UserPanel.Invoice.Show', params: {id: invoice.id}}">
  88. مشاهده صورتحساب
  89. </q-btn>
  90. </div>
  91. </div>
  92. </div>
  93. </template>
  94. <script>
  95. import { Wallet } from 'src/models/Wallet.js'
  96. import { Invoice } from 'src/models/Invoice.js'
  97. export default {
  98. name: 'InvoicePaymentCard',
  99. props: {
  100. invoice: {
  101. type: Invoice,
  102. default: new Invoice()
  103. },
  104. wallet: {
  105. type: Wallet,
  106. default: new Wallet()
  107. }
  108. },
  109. data: () => {
  110. return {
  111. walletLoaded: false,
  112. needToDeposit: false,
  113. timer: 10 * 60,
  114. timerString: '10:00',
  115. min: 0,
  116. sec: 0,
  117. interval: null
  118. }
  119. },
  120. computed: {
  121. showInvoiceLinkBtn () {
  122. return this.$route.name !== 'UserPanel.Invoice.Show'
  123. },
  124. amountOfDepositWalletNeeded () {
  125. return this.invoice.amount - this.wallet.inventory
  126. }
  127. },
  128. mounted() {
  129. this.runTimer()
  130. },
  131. methods: {
  132. onCancel () {
  133. this.$emit('onCancel')
  134. },
  135. onAccept () {
  136. this.$emit('onAccept')
  137. },
  138. checkForNeedToDeposit () {
  139. this.needToDeposit = this.invoice.amount > this.wallet.inventory
  140. },
  141. runTimer () {
  142. this.interval = setInterval(() => {
  143. this.updateTimer()
  144. }, 1000)
  145. },
  146. updateTimer () {
  147. this.timer--
  148. if (this.timer < 0) {
  149. this.stopTimer()
  150. return
  151. }
  152. const min = String(Math.floor(this.timer / 60)).padStart(2, '0')
  153. const sec = String(this.timer % 60).padStart(2, '0')
  154. this.timerString = min + ':' + sec
  155. },
  156. stopTimer () {
  157. clearInterval(this.interval)
  158. }
  159. }
  160. }
  161. </script>
  162. <style scoped lang="scss">
  163. .InvoicePaymentCard{
  164. background: #F5F5F5;
  165. border: 1px solid #DFE1EC;
  166. border-radius: 8px;
  167. .InvoicePaymentCard-head {
  168. background: #FFFFFF;
  169. border-bottom: 1px solid #DFE1EC;
  170. border-radius: 8px 8px 0 0;
  171. position: relative;
  172. display: flex;
  173. flex-flow: column;
  174. justify-content: flex-start;
  175. align-items: center;
  176. .InvoicePaymentCard-head-title {
  177. margin-top: 24px;
  178. width: 100%;
  179. text-align: left;
  180. font-size: 18px;
  181. letter-spacing: 0;
  182. color: #212121;
  183. padding-left: 12px;
  184. margin-bottom: 21px;
  185. @media screen and (max-width: 600px) {
  186. margin-bottom: 35px;
  187. }
  188. }
  189. .InvoicePaymentCard-head-caption {
  190. margin-bottom: 17px;
  191. width: 100%;
  192. text-align: left;
  193. font-size: 14px;
  194. letter-spacing: 0;
  195. color: #212121;
  196. padding-left: 53px;
  197. padding-right: 20px;
  198. @media screen and (max-width: 600px) {
  199. padding-left: 20px;
  200. }
  201. }
  202. .InvoicePaymentCard-head-remaining-time {
  203. position: absolute;
  204. right: 23px;
  205. top: 26px;
  206. .q-icon {
  207. color: #AAA095;
  208. }
  209. @media screen and (max-width: 600px) {
  210. top: 55px;
  211. }
  212. }
  213. }
  214. .InvoicePaymentCard-body {
  215. padding: 20px 22px 26px;
  216. color: #212121;
  217. .final-price {
  218. display: flex;
  219. flex-wrap: wrap !important;
  220. flex-flow: row;
  221. justify-content: space-between;
  222. padding: 13px 22px 13px 27px;
  223. margin-bottom: 33px;
  224. background: #FFFFFF;
  225. border-radius: 8px;
  226. .final-price-label {
  227. display: flex;
  228. flex-flow: row;
  229. justify-content: flex-start;
  230. align-items: center;
  231. font-size: 17px;
  232. @media screen and (max-width: 599px) {
  233. width: 100%;
  234. }
  235. .q-img {
  236. width: 32px;
  237. margin-right: 15px;
  238. }
  239. }
  240. .final-price-value {
  241. font-size: 20px;
  242. font-weight: bold;
  243. @media screen and (max-width: 599px) {
  244. width: 100%;
  245. text-align: right;
  246. }
  247. .unit {
  248. font-size: 17px;
  249. font-weight: normal;
  250. }
  251. }
  252. }
  253. .other-items {
  254. margin-bottom: 60px;
  255. .other-item {
  256. display: flex;
  257. flex-flow: row;
  258. flex-wrap: wrap !important;
  259. justify-content: space-between;
  260. padding: 19px 22px 18px 27px;
  261. border-bottom: 1px solid #E1E3ED;
  262. .other-item-label {
  263. display: flex;
  264. flex-flow: row;
  265. justify-content: flex-start;
  266. align-items: center;
  267. font-size: 16px;
  268. @media screen and (max-width: 599px) {
  269. width: 100%;
  270. }
  271. .q-icon {
  272. color: #475F4A;
  273. margin-right: 10px;
  274. }
  275. }
  276. .other-item-value {
  277. display: flex;
  278. flex-flow: row;
  279. justify-content: flex-end;
  280. align-items: center;
  281. font-size: 18px;
  282. font-weight: bold;
  283. @media screen and (max-width: 599px) {
  284. width: 100%;
  285. text-align: right;
  286. }
  287. .unit {
  288. font-size: 16px;
  289. font-weight: normal;
  290. }
  291. }
  292. }
  293. }
  294. .action-area {
  295. display: flex;
  296. flex-flow: row;
  297. flex-wrap: wrap !important;
  298. justify-content: flex-start;
  299. align-items: center;
  300. margin-bottom: 28px;
  301. .btn-pay {
  302. width: 60%;
  303. margin-left: 19px;
  304. @media screen and (max-width: 599px) {
  305. width: 100%;
  306. margin-bottom: 16px;
  307. margin-left: 0;
  308. order: 1;
  309. }
  310. }
  311. .btn-cancel {
  312. width: calc( 40% - 19px );
  313. @media screen and (max-width: 599px) {
  314. margin-bottom: 16px;
  315. width: 100%;
  316. order: 2;
  317. }
  318. }
  319. }
  320. .show-invoice-row {
  321. display: flex;
  322. flex-flow: row;
  323. justify-content: center;
  324. align-items: center;
  325. }
  326. }
  327. }
  328. </style>