back-order.vue 4.8 KB

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