123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282 |
- <template>
- <view id="order" class="order">
- <view class="header" v-if="$store.state.user.group_id === 2">
- <view class="title">
- 我的待发货
- </view>
- <view style="position: relative;">
- <view class="sub-title">待发货订单</view>
- </view>
- </view>
- <view class="header" v-if="$store.state.user.group_id === 3">
- <view class="title">
- 我的待收货
- </view>
- <view style="position: relative;">
- <view class="sub-title">待收货订单</view>
- </view>
- </view>
- <view v-if="orders.length===0" style="margin: 20upx auto;text-align: center; font-size: 28upx;color: #999999;">
- 暂无任何订单
- </view>
- <view class="order-list">
- <view class="order-item" v-for="order in orders">
- <view class="order-head">
- <view class="factory-name">{{order.seller.nickname?order.seller.nickname:'省心直供(该厂家暂未设置昵称)'}}</view>
- <view v-if="order.status === 'wait_pay'" class="order-status">待付款</view>
- <view v-if="order.status === 'wait_deliver'" class="order-status">待发货</view>
- <view v-if="order.status === 'wait_sign'" class="order-status">待签收</view>
- <view v-if="order.status === 'complete'" class="order-status">已完成</view>
- <view v-if="order.status === 'invalid'" class="order-status">已失效</view>
- </view>
- <view class="order-info" @tap="openDetails(order.id)">
- <view class="product-item" v-for="product in order.products_json">
- <view class="product-image">
- <image class="image" :src="product.spec_image|imagesFilter" mode="scaleToFill"></image>
- </view>
- <view class="product-info">
- <view class="row">
- <view class="name">{{product.name}}</view>
- <view class="price">¥{{product.spec_price|priceFilter}}</view>
- </view>
- <view class="row">
- <view class="spec">{{product.spec_name}}</view>
- <view class="num">×{{product.num}}</view>
- </view>
- </view>
- </view>
- </view>
- <view class="total-price">
- 总价 <text class="warning">¥{{order.total_amount}}</text>
- </view>
- <view class="option">
- <button v-if="order.status === 'wait_pay'" class="pay-btn" type="default"
- @tap="openCashier(order.order_no)">立即支付</button>
- <button v-if="order.status === 'wait_sign'" class="confirm-btn" type="default">确认收货</button>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- orderStatus: '',
- orders: [],
- page: 1,
- pageLoading: false
- }
- },
- onShow() {
- if (this.$store.state.user.group_id === 2) {
- this.orderStatus = 'wait_deliver'
- uni.setNavigationBarTitle({
- title: "待发货",
- pagePath: "pages/order/back-order",
- iconPath: "static/images/qiang.png",
- selectedIconPath: "static/images/qiang_selected.png",
- })
- }
- if (this.$store.state.user.group_id === 3) {
- this.orderStatus = 'wait_sign'
- uni.setNavigationBarTitle({
- title: "待收货",
- pagePath: "pages/order/back-order",
- iconPath: "static/images/qiang.png",
- selectedIconPath: "static/images/qiang_selected.png",
- })
- }
- this.refresh();
- },
- onTabItemTap(e) {
- uni.$emit("refresh_userinfo");
- },
- onPageScroll(e) {
- const query = uni.createSelectorQuery();
- query.select("#order").boundingClientRect(data => {
- if (e.scrollTop > data.height - uni.getSystemInfoSync().windowHeight * 2) {
- this.getOrdersData();
- }
- }).exec();
- },
- onPullDownRefresh() {
- this.refresh();
- },
- methods: {
- openDetails(id) {
- uni.navigateTo({
- url: "order-details?id=" + id
- })
- },
- openCashier(order_no) {
- uni.navigateTo({
- url: "cashier?order_no=" + order_no
- })
- },
- getOrdersData() {
- return new Promise((resolve, reject) => {
- this.$http.get({
- url: "/order/lists",
- data: {
- status: this.orderStatus,
- limit: 10,
- page: this.page
- },
- success: (res) => {
- this.orders = [...this.orders, ...res.data.data.rows.map((item) => {
- item.products_json = JSON.parse(item.products_snapshot)
- return item;
- })]
- this.page++;
- this.pageLoading = false;
- }
- })
- })
- },
- refresh() {
- this.page = 1;
- this.orders = [];
- this.getOrdersData()
- .then(uni.stopPullDownRefresh())
- .catch(uni.stopPullDownRefresh());
- }
- }
- }
- </script>
- <style lang="scss">
- .header {
- margin: 20upx;
- background: white;
- text-align: center;
- border-radius: 20upx;
- padding-bottom: 10upx;
- .title {
- height: 100upx;
- font-size: 32upx;
- line-height: 100upx;
- // font-weight: bold;
- }
- .sub-title {
- font-size: 28upx;
- color: #999999;
- }
- }
- .order {
- overflow: hidden;
- }
- .order-list {
- .order-item {
- background: white;
- margin: 20upx;
- padding: 20upx;
- border-radius: 20upx;
- .order-head {
- display: flex;
- justify-content: space-between;
- margin-bottom: 20upx;
- .order-status {
- color: $primary-color;
- font-size: 24upx;
- }
- }
- .factory-name {
- font-size: 28upx;
- font-weight: bold;
- }
- .product-item {
- display: flex;
- .product-image {
- width: 120upx;
- height: 120upx;
- margin-right: 20upx;
- margin-top: 10upx;
- .image {
- width: 120upx;
- height: 120upx;
- }
- }
- .product-info {
- flex-grow: 1;
- font-size: 28upx;
- .name {
- font-size: 28upx;
- white-space: normal;
- display: -webkit-box;
- -webkit-box-orient: vertical;
- -webkit-line-clamp: 2;
- overflow: hidden;
- }
- .num {
- color: #999999;
- }
- .spec {
- font-size: 26upx;
- background: #CCCCCC;
- color: white;
- padding: 0 10upx;
- border-radius: 10upx;
- }
- }
- .row {
- display: flex;
- justify-content: space-between;
- margin-bottom: 10upx;
- }
- }
- .total-price {
- text-align: right;
- font-size: 28upx;
- padding: 10upx 0;
- .warning {
- color: $primary-color;
- font-weight: bold;
- }
- }
- .option {
- text-align: right;
- .pay-btn,
- .confirm-btn {
- background: white;
- border: 2upx solid $primary-color;
- display: inline-block;
- line-height: normal;
- font-size: 28upx;
- color: $primary-color;
- border-radius: 40upx;
- padding: 5upx 10upx;
- }
- }
- }
- }
- </style>
|