order.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. <template>
  2. <view id="order" class="order">
  3. <view class="header">
  4. <view class="title">
  5. 订单明细
  6. </view>
  7. <view class="tabs">
  8. <view class="tab-item" :class="{'active':orderStatus===undefined}"
  9. @tap="orderStatus=undefined,orders=[],page=1,getOrdersData()">全部</view>
  10. <view class="tab-item" :class="{'active':orderStatus==='wait_deliver'}"
  11. @tap="orderStatus='wait_deliver',orders=[],page=1,getOrdersData()">已付款</view>
  12. <view class="tab-item" :class="{'active':orderStatus==='complete'}"
  13. @tap="orderStatus='complete',orders=[],page=1,getOrdersData()">已完成</view>
  14. </view>
  15. </view>
  16. <view v-if="orders.length===0" style="margin: 20upx auto;text-align: center; font-size: 28upx;color: #999999;">
  17. 暂无任何订单
  18. </view>
  19. <view class="order-list">
  20. <view class="order-item" v-for="order in orders">
  21. <view class="order-head">
  22. <view class="factory-name">{{order.seller.nickname?order.seller.nickname:'省心直供(该厂家暂未设置昵称)'}}</view>
  23. <view v-if="order.status === 'wait_pay'" class="order-status">待付款</view>
  24. <view v-if="order.status === 'wait_deliver'" class="order-status">待发货</view>
  25. <view v-if="order.status === 'delivered'" class="order-status">已发货</view>
  26. <view v-if="order.status === 'wait_sign'" class="order-status">待取件</view>
  27. <view v-if="order.status === 'complete'" class="order-status">已完成</view>
  28. <view v-if="order.status === 'invalid'" class="order-status">已失效</view>
  29. </view>
  30. <view class="order-info" @tap="openDetails(order.id)">
  31. <view class="product-item" v-for="product in order.products_json">
  32. <view class="product-image">
  33. <image class="image" :src="product.spec_image|imagesFilter" mode="scaleToFill"></image>
  34. </view>
  35. <view class="product-info">
  36. <view class="row">
  37. <view class="name">{{product.name}}</view>
  38. <view class="price">¥{{product.spec_price|priceFilter}}</view>
  39. </view>
  40. <view class="row">
  41. <view class="spec">{{product.spec_name}}</view>
  42. <view class="num">×{{product.num}}</view>
  43. </view>
  44. </view>
  45. </view>
  46. </view>
  47. <view class="total-price">
  48. 总价 <text class="warning">¥{{order.total_amount}}</text>
  49. </view>
  50. <view v-if="$store.state.user.group_id===3" class="option">
  51. <button v-if="order.status === 'wait_pay'" class="pay-btn" type="default" @tap="goToCashier(order.order_no)">立即支付</button>
  52. <button v-if="order.status === 'wait_sign'" class="confirm-btn" type="default">确认收货</button>
  53. </view>
  54. </view>
  55. </view>
  56. </view>
  57. </template>
  58. <script>
  59. export default {
  60. data() {
  61. return {
  62. orderStatus: undefined,
  63. orders: [],
  64. page: 1,
  65. pageLoading: false
  66. }
  67. },
  68. onLoad() {
  69. this.getOrdersData();
  70. },
  71. onPageScroll(e) {
  72. const query = uni.createSelectorQuery();
  73. query.select("#order").boundingClientRect(data => {
  74. if (e.scrollTop > data.height - uni.getSystemInfoSync().windowHeight * 2 &&
  75. (this.page - 1) * 10 < this.orders.length) {
  76. this.getOrdersData();
  77. }
  78. }).exec();
  79. },
  80. methods: {
  81. openDetails(id) {
  82. uni.navigateTo({
  83. url: "order-details?id=" + id
  84. })
  85. },
  86. getOrdersData() {
  87. if (!this.pageLoading) {
  88. console.log("加载下一页");
  89. this.pageLoading = true;
  90. this.$http.get({
  91. url: "/order/lists",
  92. data: {
  93. status: this.orderStatus,
  94. limit: 10,
  95. page: this.page
  96. },
  97. success: (res) => {
  98. this.orders = [...this.orders, ...res.data.data.rows.map((item) => {
  99. item.products_json = JSON.parse(item.products_snapshot)
  100. return item;
  101. })]
  102. this.page++;
  103. this.pageLoading = false;
  104. }
  105. })
  106. }
  107. },
  108. goToCashier(order_no){
  109. uni.navigateTo({
  110. url:"/pages/order/cashier?order_no="+order_no
  111. })
  112. }
  113. }
  114. }
  115. </script>
  116. <style lang="scss">
  117. .message {
  118. overflow: hidden;
  119. }
  120. .header {
  121. margin: 20upx;
  122. background: white;
  123. text-align: center;
  124. border-radius: 20upx;
  125. .title {
  126. height: 100upx;
  127. font-size: 30upx;
  128. line-height: 100upx;
  129. // font-weight: bold;
  130. }
  131. .tabs {
  132. display: flex;
  133. justify-content: space-between;
  134. .tab-item {
  135. flex: 1;
  136. padding: 10upx 0;
  137. font-size: 28upx;
  138. color: #999999;
  139. &.active {
  140. background: $primary-color;
  141. color: white;
  142. border-radius: 20upx;
  143. }
  144. }
  145. }
  146. }
  147. .order-list {
  148. .order-item {
  149. background: white;
  150. margin: 20upx;
  151. padding: 20upx;
  152. border-radius: 20upx;
  153. .order-head {
  154. display: flex;
  155. justify-content: space-between;
  156. margin-bottom: 20upx;
  157. .order-status {
  158. color: $primary-color;
  159. font-size: 24upx;
  160. }
  161. }
  162. .factory-name {
  163. font-size: 28upx;
  164. font-weight: bold;
  165. }
  166. .product-item {
  167. display: flex;
  168. .product-image {
  169. width: 120upx;
  170. height: 120upx;
  171. margin-right: 20upx;
  172. margin-top: 10upx;
  173. .image {
  174. width: 120upx;
  175. height: 120upx;
  176. }
  177. }
  178. .product-info {
  179. flex-grow: 1;
  180. font-size: 28upx;
  181. .name {
  182. font-size: 28upx;
  183. white-space: normal;
  184. display: -webkit-box;
  185. -webkit-box-orient: vertical;
  186. -webkit-line-clamp: 2;
  187. overflow: hidden;
  188. }
  189. .num {
  190. color: #999999;
  191. }
  192. .spec {
  193. font-size: 26upx;
  194. background: #CCCCCC;
  195. color: white;
  196. padding: 0 10upx;
  197. border-radius: 10upx;
  198. }
  199. }
  200. .row {
  201. display: flex;
  202. justify-content: space-between;
  203. margin-bottom: 10upx;
  204. }
  205. }
  206. .total-price {
  207. text-align: right;
  208. font-size: 28upx;
  209. padding: 10upx 0;
  210. .warning {
  211. color: $primary-color;
  212. font-weight: bold;
  213. }
  214. }
  215. .option {
  216. text-align: right;
  217. .pay-btn,
  218. .confirm-btn {
  219. background: white;
  220. border: 2upx solid $primary-color;
  221. display: inline-block;
  222. line-height: normal;
  223. font-size: 28upx;
  224. color: $primary-color;
  225. border-radius: 40upx;
  226. padding: 5upx 10upx;
  227. }
  228. }
  229. }
  230. }
  231. </style>