Orders.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. <template>
  2. <div class="order">
  3. <el-tabs v-model="activeName" class="demo-tabs" @tab-click="handleClick">
  4. <el-tab-pane v-for="tab in tabs" :key="tab.name" :label="$t(tab.label)" :name="tab.name">
  5. <ul class="order-list">
  6. <li v-for="(item, index) in list" :key="index">
  7. <div class="order-list-top flex-center-between">
  8. <div class="order-list-top-l flex-align-center">
  9. <el-tag :type="index == 0 ? 'primary' : index == 1 ? 'success' : 'danger'">{{ index == 0 ?
  10. $t('personalCenter.daifukuan') : index == 1 ? $t('personalCenter.yiwancheng') :
  11. $t('personalCenter.yiquxiao') }}</el-tag>
  12. <div class="">{{ $t('personalCenter.dingdanhao') }}: {{ item.orderNo }}</div>
  13. </div>
  14. <div class="order-list-top-r">{{ $t('common.orderTime') }}: {{ item.createTime }}</div>
  15. </div>
  16. <div class="order-list-main flex">
  17. <img class="image"
  18. src="https://shadow.elemecdn.com/app/element/hamburger.9cf7b091-55e9-11e9-a976-7f4d0b07eef6.png" alt="">
  19. <div class="order-list-con flex-center-between flex_1">
  20. <div class="">
  21. <div class="title">UI界面设计教程</div>
  22. <div class="">
  23. <el-button type="primary" size="small" plain>技能标签</el-button>
  24. <el-button type="primary" size="small" plain>技能标签</el-button>
  25. </div>
  26. </div>
  27. <div class="mi_price">
  28. <div class="">29900</div>
  29. <div class="">{{ $t('common.mibi') }}</div>
  30. </div>
  31. <div class="mi_price price">
  32. <div class="">¥239.20</div>
  33. <div class="">{{ $t('common.actualAmount') }}</div>
  34. </div>
  35. <div class="">
  36. <template v-if="index == 0">
  37. <div class="gradient btn">
  38. <img src="/src/assets/imgs/my/order1@2x.png" alt="">
  39. <div class="">{{ $t('common.goPay') }}</div>
  40. </div>
  41. <div class="blue btn mt8">
  42. <img src="/src/assets/imgs/my/order2@2x.png" alt="">
  43. <div class="">{{ $t('common.cancelOrder') }}</div>
  44. </div>
  45. </template>
  46. <template v-else-if="index == 1">
  47. <div class="blue btn">
  48. <img src="/src/assets/imgs/my/order3@2x.png" alt="">
  49. <div class="">{{ $t('common.applyInvoice') }}</div>
  50. </div>
  51. <div class="red btn mt8">
  52. <img src="/src/assets/imgs/my/order4@2x.png" alt="">
  53. <div class="">{{ $t('common.applyRefund') }}</div>
  54. </div>
  55. </template>
  56. <template v-else-if="index == 2">
  57. <div class="btn gradient">
  58. <img src="/src/assets/imgs/my/order5@2x.png" alt="">
  59. <div class="">{{ $t('common.reorder') }}</div>
  60. </div>
  61. </template>
  62. </div>
  63. </div>
  64. </div>
  65. </li>
  66. </ul>
  67. </el-tab-pane>
  68. </el-tabs>
  69. <template v-if="list.length">
  70. <Pagination :total="form.total" :page-size="form.pageSize" :current-page="form.pageNum"
  71. @page-change="handlePageChange" />
  72. </template>
  73. <el-empty v-else :description="$t('common.empty')" />
  74. </div>
  75. </template>
  76. <script lang="ts" setup>
  77. import { ref, onMounted } from 'vue'
  78. import type { TabsPaneContext } from 'element-plus'
  79. import Pagination from '@/components/Pagination.vue'
  80. import { orderList } from '@/api/my.js'
  81. const tabs = ref([
  82. { label: 'personalCenter.allOrders', name: 'first' },
  83. { label: 'personalCenter.daifukuan', name: 'second' },
  84. { label: 'personalCenter.yiwancheng', name: 'third' },
  85. { label: 'personalCenter.yiquxiao', name: 'fourth' },
  86. ])
  87. const activeName = ref('first')
  88. const list = ref([]);
  89. const form = ref({
  90. pageNum: 1,
  91. pageSize: 10,
  92. total: 0,
  93. activeName: 0
  94. })
  95. const handleClick = (tab: TabsPaneContext) => {
  96. list.value = []
  97. form.value.pageNum = 1;
  98. form.value.activeName = tab.props.name;
  99. getList()
  100. }
  101. // 获取我的订单
  102. const getList = async () => {
  103. let res = await orderList(form.value);
  104. console.log(res.rows)
  105. list.value = res.rows || [];
  106. form.value.total = res.total;
  107. }
  108. const handlePageChange = (page) => {
  109. list.value = []
  110. form.value.pageNum = page;
  111. getList()
  112. }
  113. onMounted(() => {
  114. getList()
  115. })
  116. </script>
  117. <style scoped lang="scss">
  118. .order {
  119. padding-bottom: 16px;
  120. .order-list {
  121. li {
  122. background: #FFFFFF;
  123. border-radius: 16rpx;
  124. margin-bottom: 16px;
  125. &:last-child {
  126. margin-bottom: 0;
  127. }
  128. .order-list-top {
  129. height: 42px;
  130. padding: 0 16px;
  131. background: #F5F7FA;
  132. border-radius: 16px 16px 0px 0px;
  133. .order-list-top-l {
  134. div {
  135. margin-left: 8px;
  136. font-size: 16px;
  137. font-weight: bold;
  138. }
  139. }
  140. .order-list-top-r {
  141. font-size: 14px;
  142. }
  143. }
  144. .order-list-main {
  145. padding: 16px;
  146. border-radius: 0 0 16px 16px;
  147. border: 1px solid #EBEEF5;
  148. .image {
  149. width: 160px;
  150. height: 90px;
  151. object-fit: cover;
  152. margin-right: 16px;
  153. border-radius: 8px;
  154. }
  155. .title {
  156. font-size: 16px;
  157. font-weight: bold;
  158. margin-bottom: 8px;
  159. line-height: 1;
  160. }
  161. .mi_price {
  162. div {
  163. font-size: 18px;
  164. text-align: center;
  165. &:last-child {
  166. font-size: 12px;
  167. color: #666666;
  168. }
  169. }
  170. }
  171. .price {
  172. div {
  173. &:first-child {
  174. color: #FD5F3C;
  175. }
  176. }
  177. }
  178. .mt8 {
  179. margin-top: 8px;
  180. }
  181. .btn {
  182. display: flex;
  183. align-items: center;
  184. justify-content: center;
  185. width: 106px;
  186. height: 32px;
  187. cursor: pointer;
  188. border-radius: 4px;
  189. img {
  190. width: 14px;
  191. height: 14px;
  192. margin-right: 4px;
  193. }
  194. div {
  195. font-size: 14px;
  196. color: #FFFFFF;
  197. }
  198. }
  199. .red {
  200. background: #FCEBEB;
  201. div {
  202. color: #E43434;
  203. }
  204. }
  205. .blue {
  206. background: #EAF0FF;
  207. div {
  208. color: #2D71FF;
  209. }
  210. }
  211. }
  212. }
  213. }
  214. }
  215. </style>