index.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. <template>
  2. <!-- 订单页面 -->
  3. <view>
  4. <u-navbar title="我的运单" autoBack placeholder></u-navbar>
  5. <view class="tab_order">
  6. <u-tabs :list="tableList" lineColor="#333333" lineWidth="60" :scrollable="false" :current="current"
  7. @change="tabClick"></u-tabs>
  8. </view>
  9. <view class="card_order_mangement" v-if="orderList.length > 0">
  10. <x-orderManagement :orderList="orderList" :userInfo="userInfo"></x-orderManagement>
  11. <view v-if="loadingMore" style="width: 50%;"><u-divider :text="loading"></u-divider></view>
  12. </view>
  13. <u-empty mode="order" marginTop="50" v-else></u-empty>
  14. </view>
  15. </template>
  16. <script>
  17. export default {
  18. data() {
  19. return {
  20. tableList: [],
  21. list: [{
  22. name: '全部',
  23. }, {
  24. id: 3,
  25. name: '未入库',
  26. }, {
  27. id: 5,
  28. name: '已入库'
  29. }, {
  30. id: 7,
  31. name: '已出库'
  32. }],
  33. list1: [{
  34. name: '全部',
  35. }, {
  36. id: 2,
  37. name: '未装车',
  38. }, {
  39. id: 4,
  40. name: '已装车'
  41. },
  42. /* {
  43. id: 6,
  44. name: '已下车'
  45. }, */
  46. {
  47. id: 8,
  48. name: '已签收'
  49. }
  50. ],
  51. list2: [{
  52. name: '全部',
  53. }, {
  54. id: 1,
  55. name: '未发货',
  56. }, {
  57. id: 2,
  58. name: '已发货'
  59. }, {
  60. id: 3,
  61. name: '已签收'
  62. }],
  63. current: 0,
  64. userInfo: {},
  65. orderList: [],
  66. pageSize: 10,
  67. currentPage: 1,
  68. loadingMore: true,
  69. loading: '加载中',
  70. status: null,
  71. }
  72. },
  73. onReachBottom() {
  74. if (!this.loadingMore) {
  75. if (this.userInfo.userType == 'sys') {
  76. this.getList()
  77. } else {
  78. this.getUserList()
  79. }
  80. }
  81. },
  82. onLoad(value) {
  83. if (value.current) {
  84. this.current = Number(value.current)
  85. }
  86. var userInfo = this.$cache.getCache('userInfo')
  87. // console.log(userInfo, 25)
  88. this.userInfo = userInfo
  89. if (userInfo.userType == 'sys') {
  90. if (userInfo.type == 2) {
  91. // 仓管
  92. this.tableList = this.list
  93. let statusType = ''
  94. if (this.current != 0 || this.current) {
  95. statusType = this.tableList[this.current].id
  96. }
  97. this.status = statusType
  98. this.getList()
  99. } else if (userInfo.type == 3) {
  100. // 司机
  101. this.tableList = this.list1
  102. let statusType = ''
  103. if (this.current != 0 || this.current) {
  104. statusType = this.tableList[this.current].id
  105. }
  106. this.status = statusType
  107. this.getList()
  108. }
  109. } else {
  110. this.tableList = this.list2
  111. this.status = this.tableList[this.current].id
  112. this.getUserList()
  113. }
  114. },
  115. methods: {
  116. // 获取司机和仓管订单列表
  117. getList() {
  118. this.loadingMore = true;
  119. this.$api.get('/api/waybill/applet', {
  120. page: this.currentPage,
  121. pageSize: this.pageSize,
  122. status: this.status,
  123. }).then(res => {
  124. if (res.code == 200) {
  125. const data = res.data.list
  126. if (this.loadingMore == true && data) {
  127. this.orderList = this.orderList.concat(data);
  128. }
  129. if (this.orderList.length < this.pageSize) {
  130. this.loadingMore = true
  131. this.loading = '没有更多了'
  132. } else {
  133. this.loading = '加载中'
  134. this.loadingMore = false
  135. this.currentPage++
  136. }
  137. }
  138. })
  139. },
  140. // 获取用户订单列表
  141. getUserList() {
  142. this.loadingMore = true;
  143. this.$api.get('/api/waybill/customer', {
  144. page: this.currentPage,
  145. pageSize: this.pageSize,
  146. status: this.status,
  147. }).then(res => {
  148. if (res.code == 200) {
  149. const data = res.data.list
  150. if (this.loadingMore == true && data) {
  151. this.orderList = this.orderList.concat(data);
  152. }
  153. if (this.orderList.length < this.pageSize) {
  154. this.loadingMore = true
  155. this.loading = '没有更多了'
  156. } else {
  157. this.loading = '加载中'
  158. this.loadingMore = false
  159. this.currentPage++
  160. }
  161. }
  162. })
  163. },
  164. // tab订单
  165. tabClick(row) {
  166. this.currentPage = 1
  167. this.orderList = []
  168. if (this.userInfo.userType == 'sys') {
  169. this.status = row.id
  170. this.getList()
  171. } else {
  172. this.status = row.id
  173. this.getUserList()
  174. }
  175. }
  176. }
  177. }
  178. </script>
  179. <style lang="scss">
  180. .tab_order {
  181. background-color: #fff;
  182. }
  183. .card_order_mangement {
  184. display: flex;
  185. flex-direction: column;
  186. align-items: center;
  187. }
  188. </style>