back-order.vue 6.3 KB

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