index.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  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 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 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: 1 }">
  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">Pay 14:40</button>
  80. <button
  81. class="ptc-button ptc-button--stroke"
  82. @click="cancelOrder(item)"
  83. >
  84. Cancel
  85. </button>
  86. </template>
  87. <button
  88. v-else
  89. class="ptc-button ptc-button--stroke"
  90. @click="deleteOrder(item)"
  91. >
  92. Delete
  93. </button>
  94. </div>
  95. </div>
  96. </div>
  97. </template>
  98. <script>
  99. import { defineComponent } from 'vue'
  100. import * as api from '@/service/order'
  101. export default defineComponent({
  102. name: 'OrderList',
  103. async beforeRouteEnter(to, from, next) {
  104. const { results } = await api.getOrderList()
  105. next(vm => (vm.list = results))
  106. },
  107. data() {
  108. return {
  109. /** @type {any[]} */
  110. list: [],
  111. }
  112. },
  113. methods: {
  114. async cancelOrder(item) {
  115. await api.cancelOrder(item.id)
  116. item.status = 2
  117. },
  118. async deleteOrder(item) {
  119. await api.deleteOrder(item.id)
  120. this.list.splice(this.list.indexOf(item), 1)
  121. },
  122. },
  123. })
  124. </script>
  125. <style lang="scss">
  126. .p-my-order {
  127. background: #f7f7f7;
  128. .pb24 {
  129. padding-bottom: 24px !important;
  130. }
  131. .cell {
  132. &-group {
  133. padding: 8px 0 48px;
  134. &--compact {
  135. padding: 48px 0 8px;
  136. .cell + .cell {
  137. margin-top: 24px;
  138. }
  139. }
  140. @include media-breakpoint-up(md) {
  141. margin: auto;
  142. width: 1258px;
  143. &:first-child {
  144. display: flex;
  145. flex-wrap: wrap;
  146. justify-content: space-between;
  147. .cell {
  148. width: 45%;
  149. justify-content: flex-start;
  150. + .cell {
  151. margin-top: 20px;
  152. }
  153. &:nth-child(2) {
  154. margin-top: 0;
  155. }
  156. &__label {
  157. margin-right: 14px;
  158. &::after {
  159. content: ':';
  160. }
  161. }
  162. }
  163. }
  164. .ptc-tag {
  165. margin-left: 0;
  166. }
  167. }
  168. }
  169. display: flex;
  170. justify-content: space-between;
  171. align-items: center;
  172. font-size: 32px;
  173. + .cell {
  174. margin-top: 48px;
  175. }
  176. &__label {
  177. color: #999;
  178. }
  179. &__value {
  180. color: #1a1a1a;
  181. }
  182. }
  183. .ptc-tag {
  184. &.not-paid {
  185. background: #dae1ef;
  186. color: $primary-color;
  187. }
  188. &.paid {
  189. background: #dae1ef;
  190. color: #a7b0c1;
  191. }
  192. &.canceled {
  193. background: #eaeaea;
  194. color: #999;
  195. }
  196. }
  197. .button-group {
  198. display: flex;
  199. flex-direction: row-reverse;
  200. justify-content: flex-start;
  201. margin-top: 24px;
  202. @include media-breakpoint-up(md) {
  203. margin-left: auto;
  204. margin-right: auto;
  205. margin-bottom: 24px;
  206. width: 1258px;
  207. }
  208. .ptc-button {
  209. width: 328px;
  210. height: 92px;
  211. + .ptc-button {
  212. margin-right: 26px;
  213. }
  214. }
  215. }
  216. @include media-breakpoint-up(xl) {
  217. .wrapper {
  218. display: flex;
  219. padding-left: 176px;
  220. }
  221. .button-group {
  222. display: block;
  223. width: auto;
  224. margin-left: 90px;
  225. margin-top: 122px;
  226. .ptc-button + .ptc-button {
  227. margin-right: 0;
  228. margin-top: 24px;
  229. }
  230. }
  231. }
  232. }
  233. </style>