back-order.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  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"
  38. @tap="openCashier(order.order_no)">立即支付</button>
  39. <button v-if="order.status === 'wait_sign'" class="confirm-btn" type="default">确认收货</button>
  40. </view>
  41. </view>
  42. </view>
  43. </view>
  44. </template>
  45. <script>
  46. export default {
  47. data() {
  48. return {
  49. orderStatus: '',
  50. orders: [],
  51. page: 1,
  52. pageLoading: false
  53. }
  54. },
  55. onLoad() {
  56. if (this.$store.state.user.group_id === 2) {
  57. this.orderStatus = 'wait_deliver'
  58. uni.setNavigationBarTitle({
  59. title: "我的待发货"
  60. })
  61. }
  62. if (this.$store.state.user.group_id === 3) {
  63. this.orderStatus = 'wait_pay'
  64. uni.setNavigationBarTitle({
  65. title: "我的待付款"
  66. })
  67. }
  68. this.getOrdersData();
  69. },
  70. onPageScroll(e) {
  71. const query = uni.createSelectorQuery();
  72. query.select("#order").boundingClientRect(data => {
  73. if (e.scrollTop > data.height - uni.getSystemInfoSync().windowHeight * 2) {
  74. this.getOrdersData();
  75. }
  76. }).exec();
  77. },
  78. methods: {
  79. openDetails(id) {
  80. uni.navigateTo({
  81. url: "order-details?id=" + id
  82. })
  83. },
  84. openCashier(order_no) {
  85. uni.navigateTo({
  86. url: "cashier?order_no=" + order_no
  87. })
  88. },
  89. getOrdersData() {
  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. }
  109. </script>
  110. <style lang="scss">
  111. .order {
  112. overflow: hidden;
  113. }
  114. .order-list {
  115. .order-item {
  116. background: white;
  117. margin: 20upx;
  118. padding: 20upx;
  119. border-radius: 20upx;
  120. .order-head {
  121. display: flex;
  122. justify-content: space-between;
  123. margin-bottom: 20upx;
  124. .order-status {
  125. color: $primary-color;
  126. font-size: 24upx;
  127. }
  128. }
  129. .factory-name {
  130. font-size: 28upx;
  131. font-weight: bold;
  132. }
  133. .product-item {
  134. display: flex;
  135. .product-image {
  136. width: 120upx;
  137. height: 120upx;
  138. margin-right: 20upx;
  139. margin-top: 10upx;
  140. .image {
  141. width: 120upx;
  142. height: 120upx;
  143. }
  144. }
  145. .product-info {
  146. flex-grow: 1;
  147. font-size: 28upx;
  148. .name {
  149. font-size: 28upx;
  150. white-space: normal;
  151. display: -webkit-box;
  152. -webkit-box-orient: vertical;
  153. -webkit-line-clamp: 2;
  154. overflow: hidden;
  155. }
  156. .num {
  157. color: #999999;
  158. }
  159. .spec {
  160. font-size: 26upx;
  161. background: #CCCCCC;
  162. color: white;
  163. padding: 0 10upx;
  164. border-radius: 10upx;
  165. }
  166. }
  167. .row {
  168. display: flex;
  169. justify-content: space-between;
  170. margin-bottom: 10upx;
  171. }
  172. }
  173. .total-price {
  174. text-align: right;
  175. font-size: 28upx;
  176. padding: 10upx 0;
  177. .warning {
  178. color: $primary-color;
  179. font-weight: bold;
  180. }
  181. }
  182. .option {
  183. text-align: right;
  184. .pay-btn,
  185. .confirm-btn {
  186. background: white;
  187. border: 2upx solid $primary-color;
  188. display: inline-block;
  189. line-height: normal;
  190. font-size: 28upx;
  191. color: $primary-color;
  192. border-radius: 40upx;
  193. padding: 5upx 10upx;
  194. }
  195. }
  196. }
  197. }
  198. </style>