index.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. <template>
  2. <div class="p-my-order">
  3. <h3 class="ptc-title">My Order</h3>
  4. <div
  5. v-for="item of list"
  6. :key="item.id"
  7. class="ptc-block wrapper"
  8. :class="{ pb24: item.status !== 1 }"
  9. >
  10. <div
  11. class="pointer"
  12. @click="item.status === 1 && $router.push(`/order/${item.id}`)"
  13. >
  14. <div class="cell-group border-bottom">
  15. <div class="cell">
  16. <span class="cell__label">Order Status</span>
  17. <span class="cell__value">
  18. <span
  19. class="ptc-tag"
  20. :class="{
  21. 'not-paid': item.status === 0,
  22. paid: item.status === 1,
  23. canceled: item.stauts > 1,
  24. }"
  25. >{{
  26. item.status === 0
  27. ? 'Not Paid'
  28. : item.status === 1
  29. ? 'Paid'
  30. : 'Canceled'
  31. }}</span
  32. >
  33. </span>
  34. </div>
  35. <div class="cell">
  36. <span class="cell__label">Order Number</span>
  37. <span class="cell__value">{{ item.contract_no }}</span>
  38. </div>
  39. <div class="cell">
  40. <span class="cell__label">Order Time</span>
  41. <span class="cell__value">{{ item.created_at }}</span>
  42. </div>
  43. <div class="cell">
  44. <span class="cell__label">Phone brand</span>
  45. <span class="cell__value">{{ item.phone_info }}</span>
  46. </div>
  47. <div class="cell">
  48. <span class="cell__label">Version</span>
  49. <span class="cell__value"
  50. >{{ item.product_name }}({{ item.end_time }} Expires)</span
  51. >
  52. </div>
  53. </div>
  54. <div class="cell-group cell-group--compact">
  55. <template v-if="item.status < 2">
  56. <div v-if="item.payment_open" class="cell">
  57. <span class="cell__label">Activation fee</span>
  58. <span class="cell__value">${{ item.payment_open }}</span>
  59. </div>
  60. <div class="cell">
  61. <span class="cell__label">Membership fee</span>
  62. <span class="cell__value">${{ item.payment_product }}</span>
  63. </div>
  64. <div v-if="item.discount_amount" class="cell">
  65. <span class="cell__label">Discount</span>
  66. <span class="cell__value highlight"
  67. >-${{ item.discount_amount }}</span
  68. >
  69. </div>
  70. </template>
  71. <div class="cell" :class="{ mt48: item.stauts < 2 }">
  72. <span class="cell__label">Cost</span>
  73. <span class="cell__value bold">${{ item.payment_amount }}</span>
  74. </div>
  75. </div>
  76. </div>
  77. <div v-if="item.status !== 1" class="button-group">
  78. <template v-if="item.status === 0">
  79. <button class="ptc-button" @click="handlePay(item.stripe_pay_link)">
  80. Pay 14:40
  81. </button>
  82. <button
  83. class="ptc-button ptc-button--stroke"
  84. @click="cancelOrder(item)"
  85. >
  86. Cancel
  87. </button>
  88. </template>
  89. <button
  90. v-else
  91. class="ptc-button ptc-button--stroke"
  92. @click="deleteOrder(item)"
  93. >
  94. Delete
  95. </button>
  96. </div>
  97. </div>
  98. </div>
  99. </template>
  100. <script>
  101. import { defineComponent } from 'vue'
  102. import * as api from '@/service/order'
  103. export default defineComponent({
  104. name: 'OrderList',
  105. async beforeRouteEnter(to, from, next) {
  106. const { results } = await api.getOrderList()
  107. next(vm => (vm.list = results))
  108. },
  109. data() {
  110. return {
  111. /** @type {any[]} */
  112. list: [],
  113. }
  114. },
  115. methods: {
  116. async cancelOrder(item) {
  117. await api.cancelOrder(item.id)
  118. item.status = 2
  119. },
  120. async deleteOrder(item) {
  121. await api.deleteOrder(item.id)
  122. this.list.splice(this.list.indexOf(item), 1)
  123. },
  124. handlePay(link) {
  125. location.href = link
  126. },
  127. },
  128. })
  129. </script>
  130. <style lang="scss">
  131. .p-my-order {
  132. background: #f7f7f7;
  133. .pb24 {
  134. padding-bottom: 24px !important;
  135. }
  136. .cell {
  137. &-group {
  138. padding: 8px 0 48px;
  139. &--compact {
  140. padding: 48px 0 8px;
  141. .cell + .cell {
  142. margin-top: 24px;
  143. }
  144. }
  145. @include media-breakpoint-up(md) {
  146. margin: auto;
  147. width: 1258px;
  148. &:first-child {
  149. display: flex;
  150. flex-wrap: wrap;
  151. justify-content: space-between;
  152. .cell {
  153. width: 45%;
  154. justify-content: flex-start;
  155. + .cell {
  156. margin-top: 20px;
  157. }
  158. &:nth-child(2) {
  159. margin-top: 0;
  160. }
  161. &__label {
  162. margin-right: 14px;
  163. &::after {
  164. content: ':';
  165. }
  166. }
  167. }
  168. }
  169. .ptc-tag {
  170. margin-left: 0;
  171. }
  172. }
  173. }
  174. display: flex;
  175. justify-content: space-between;
  176. align-items: center;
  177. font-size: 32px;
  178. + .cell {
  179. margin-top: 48px;
  180. }
  181. &__label {
  182. color: #999;
  183. }
  184. &__value {
  185. color: #1a1a1a;
  186. }
  187. }
  188. .ptc-tag {
  189. &.not-paid {
  190. background: #dae1ef;
  191. color: $primary-color;
  192. }
  193. &.paid {
  194. background: #dae1ef;
  195. color: #a7b0c1;
  196. }
  197. &.canceled {
  198. background: #eaeaea;
  199. color: #999;
  200. }
  201. }
  202. .button-group {
  203. display: flex;
  204. flex-direction: row-reverse;
  205. justify-content: flex-start;
  206. margin-top: 24px;
  207. @include media-breakpoint-up(md) {
  208. margin-left: auto;
  209. margin-right: auto;
  210. margin-bottom: 24px;
  211. width: 1258px;
  212. }
  213. .ptc-button {
  214. width: 328px;
  215. height: 92px;
  216. + .ptc-button {
  217. margin-right: 26px;
  218. }
  219. }
  220. }
  221. @include media-breakpoint-up(xl) {
  222. .wrapper {
  223. display: flex;
  224. padding-left: 176px;
  225. }
  226. .button-group {
  227. display: block;
  228. width: auto;
  229. margin-left: 90px;
  230. margin-top: 122px;
  231. .ptc-button + .ptc-button {
  232. margin-right: 0;
  233. margin-top: 24px;
  234. }
  235. }
  236. }
  237. }
  238. </style>