back-order.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  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_sign'
  64. uni.setNavigationBarTitle({
  65. title: "待收货"
  66. })
  67. }
  68. this.refresh();
  69. },
  70. onTabItemTap(e) {
  71. uni.$emit("refresh_userinfo");
  72. },
  73. onPageScroll(e) {
  74. const query = uni.createSelectorQuery();
  75. query.select("#order").boundingClientRect(data => {
  76. if (e.scrollTop > data.height - uni.getSystemInfoSync().windowHeight * 2) {
  77. this.getOrdersData();
  78. }
  79. }).exec();
  80. },
  81. onPullDownRefresh() {
  82. this.refresh();
  83. },
  84. methods: {
  85. openDetails(id) {
  86. uni.navigateTo({
  87. url: "order-details?id=" + id
  88. })
  89. },
  90. openCashier(order_no) {
  91. uni.navigateTo({
  92. url: "cashier?order_no=" + order_no
  93. })
  94. },
  95. getOrdersData() {
  96. return new Promise((resolve, reject) => {
  97. this.$http.get({
  98. url: "/order/lists",
  99. data: {
  100. status: this.orderStatus,
  101. limit: 10,
  102. page: this.page
  103. },
  104. success: (res) => {
  105. this.orders = [...this.orders, ...res.data.data.rows.map((item) => {
  106. item.products_json = JSON.parse(item.products_snapshot)
  107. return item;
  108. })]
  109. this.page++;
  110. this.pageLoading = false;
  111. }
  112. })
  113. })
  114. },
  115. refresh() {
  116. this.page = 1;
  117. this.products = [];
  118. this.getOrdersData()
  119. .then(uni.stopPullDownRefresh())
  120. .catch(uni.stopPullDownRefresh());
  121. }
  122. }
  123. }
  124. </script>
  125. <style lang="scss">
  126. .order {
  127. overflow: hidden;
  128. }
  129. .order-list {
  130. .order-item {
  131. background: white;
  132. margin: 20upx;
  133. padding: 20upx;
  134. border-radius: 20upx;
  135. .order-head {
  136. display: flex;
  137. justify-content: space-between;
  138. margin-bottom: 20upx;
  139. .order-status {
  140. color: $primary-color;
  141. font-size: 24upx;
  142. }
  143. }
  144. .factory-name {
  145. font-size: 28upx;
  146. font-weight: bold;
  147. }
  148. .product-item {
  149. display: flex;
  150. .product-image {
  151. width: 120upx;
  152. height: 120upx;
  153. margin-right: 20upx;
  154. margin-top: 10upx;
  155. .image {
  156. width: 120upx;
  157. height: 120upx;
  158. }
  159. }
  160. .product-info {
  161. flex-grow: 1;
  162. font-size: 28upx;
  163. .name {
  164. font-size: 28upx;
  165. white-space: normal;
  166. display: -webkit-box;
  167. -webkit-box-orient: vertical;
  168. -webkit-line-clamp: 2;
  169. overflow: hidden;
  170. }
  171. .num {
  172. color: #999999;
  173. }
  174. .spec {
  175. font-size: 26upx;
  176. background: #CCCCCC;
  177. color: white;
  178. padding: 0 10upx;
  179. border-radius: 10upx;
  180. }
  181. }
  182. .row {
  183. display: flex;
  184. justify-content: space-between;
  185. margin-bottom: 10upx;
  186. }
  187. }
  188. .total-price {
  189. text-align: right;
  190. font-size: 28upx;
  191. padding: 10upx 0;
  192. .warning {
  193. color: $primary-color;
  194. font-weight: bold;
  195. }
  196. }
  197. .option {
  198. text-align: right;
  199. .pay-btn,
  200. .confirm-btn {
  201. background: white;
  202. border: 2upx solid $primary-color;
  203. display: inline-block;
  204. line-height: normal;
  205. font-size: 28upx;
  206. color: $primary-color;
  207. border-radius: 40upx;
  208. padding: 5upx 10upx;
  209. }
  210. }
  211. }
  212. }
  213. </style>