back-order.vue 6.0 KB

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