order.vue 5.3 KB

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