InvoicePaymentCard.vue 8.2 KB

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