You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
shengxian/pages/index/list.vue

439 lines
10 KiB

2 years ago
<template>
<view class="page_box">
<view class="head_box">
<!-- tab -->
<view class="order-nav u-flex">
<view class="nav-item u-flex-col u-flex-1 u-col-center" v-for="nav in orderState" :key="nav.id"
@tap="onNav(nav.type)">
<view class="item-title">{{ nav.title }}</view>
<text class="nav-line" :class="{ 'line-active': orderType === nav.type }"></text>
</view>
</view>
</view>
<view class="content_box">
<scroll-view scroll-y="true" enable-back-to-top @scrolltolower="loadMore" class="scroll-box">
<!-- 订单列表 -->
<view class="order-list" v-for="(order, orderIndex) in orderList" :key="order.id"
@tap.stop="jump('/pages/order/detail', { id: order.id })">
<view class="order-head u-flex u-row-between">
<text class="no">订单编号{{ order.order_sn }}</text>
<text class="state">{{ order.status_name }}</text>
</view>
<view class="goods-order" v-for="goods in order.item" :key="goods.id">
<view class="order-content">
<shopro-mini-card :title="goods.goods_title" :image="goods.goods_image">
2 years ago
<!-- <template #describe>
2 years ago
<view class="order-sku u-ellipsis-1">
<text class="order-num">数量:{{ goods.goods_num || 0 }};</text>
{{ goods.goods_sku_text ? goods.goods_sku_text : '' }}
</view>
2 years ago
</template> -->
2 years ago
<template #cardBottom>
2 years ago
<view class="order-price-box u-flex " style="justify-content: space-between;">
2 years ago
<text class="order-price font-OPPOSANS">{{ goods.goods_price || 0 }}</text>
2 years ago
<text>x{{goods.goods_num}}</text>
2 years ago
<!-- <button class="u-reset-button status-btn"
v-if="goods.status_name">{{ goods.status_name }}</button> -->
2 years ago
</view>
</template>
</shopro-mini-card>
</view>
</view>
<view class="order-bottom">
<view class="all-msg u-flex font-OPPOSANS">
优惠
<text class="all-unit"></text>
2 years ago
{{ order.discount_fee }} 配送费
2 years ago
<text class="all-unit"></text>
2 years ago
{{ order.dispatch_amount }} {{ order.status <= 0 ? '合计金额' : '实付款' }}
2 years ago
<view class="all-money font-OPPOSANS">{{ order.total_fee }}</view>
</view>
<!-- 按钮 -->
<view class="btn-box u-flex" v-if="order.btns.length">
<block v-for="orderBtn in order.btns" :key="orderBtn">
<button v-if="orderBtn === 'cancel'" @tap.stop="onCancel(order.id, orderIndex)"
class="u-reset-button obtn1">取消订单</button>
<button v-if="orderBtn === 'pay'" @tap.stop="onPay(order.id)"
2 years ago
class="u-reset-button obtn2">去支付</button>
2 years ago
<button v-if="orderBtn === 'groupon'"
@tap.stop="jump('/pages/activity/groupon/detail', { id: order.ext_arr.groupon_id })"
class="u-reset-button obtn2">
拼团详情
</button>
<button v-if="orderBtn === 'delete'" @tap.stop="onDelete(order.id, orderIndex)"
class="u-reset-button obtn3">删除</button>
<button v-if="orderBtn === 'express'" @tap.stop="onExpress(order.id, orderIndex)"
class="u-reset-button obtn1">查看物流</button>
</block>
</view>
</view>
</view>
1 year ago
2 years ago
<!-- 空白页 -->
<shopro-empty v-if="isEmpty" :image="$IMG_URL + '/imgs/empty/empty_groupon.png'"
tipText="暂无商品,还有更多好货等着你噢~"></shopro-empty>
<!-- 更多 -->
<u-loadmore v-show="orderList.length" height="80rpx" :status="loadStatus" icon-type="flower"
color="#ccc" />
</scroll-view>
1 year ago
<recommend></recommend>
2 years ago
</view>
1 year ago
2 years ago
</view>
</template>
<script>
1 year ago
import recommend from '@/components/recommend.vue'
2 years ago
import { mapMutations, mapActions, mapState, mapGetters } from 'vuex';
2 years ago
export default {
1 year ago
components: {recommend},
2 years ago
computed: {
...mapGetters(['isLogin']),
},
2 years ago
data() {
return {
isEmpty: false,
loadStatus: 'loadmore', //loadmore-加载前的状态,loading-加载中的状态,nomore-没有更多的状态
currentPage: 1,
lastPage: 1,
orderType: 'all',
orderList: [],
orderState: [{
id: 0,
2 years ago
title: '全部订单',
2 years ago
type: 'all'
},
{
id: 1,
2 years ago
title: '待支付',
2 years ago
type: 'nopay'
},
2 years ago
// {
// id: 2,
// title: '待发货',
// type: 'nosend'
// },
2 years ago
{
id: 3,
title: '待收货',
type: 'noget'
},
{
id: 4,
2 years ago
title: '已完成',
2 years ago
type: 'nocomment'
}
]
};
},
onShow() {
if (this.$Route.query.type) {
this.orderType = this.$Route.query.type;
}
this.orderList = [];
this.currentPage = 1;
this.lastPage = 1;
2 years ago
if(this.isLogin){
this.getOrderList();
}else{
this.isEmpty = true
}
2 years ago
},
methods: {
jump(path, parmas) {
this.$Router.push({
path: path,
query: parmas
});
},
// tab切换
onNav(id) {
if (this.orderType !== id) {
this.orderType = id;
this.orderList = [];
this.currentPage = 1;
this.lastPage = 1;
this.getOrderList();
}
},
// 订单列表
getOrderList() {
let that = this;
that.loadStatus = 'loading';
that.$http('order.index', {
type: that.orderType,
page: that.currentPage
}, '加载中...').then(res => {
if (res.code === 1) {
that.orderList = [...that.orderList, ...res.data.data];
that.isEmpty = !that.orderList.length;
that.lastPage = res.data.last_page;
that.loadStatus = that.currentPage < res.data.last_page ? 'loadmore' : 'nomore';
}
2 years ago
}).catch((res)=>{
2 years ago
});
},
// 加载更多
loadMore() {
if (this.currentPage < this.lastPage) {
this.currentPage += 1;
this.getOrderList();
}
},
// 删除订单
onDelete(orderId, orderIndex) {
let that = this;
uni.showModal({
title: '删除订单',
content: '确定要删除这个订单么?',
cancelText: '取消',
confirmText: '删除',
success: res => {
if (res.confirm) {
that.$http('order.deleteOrder', {
id: orderId
},
'删除中...'
).then(res => {
if (res.code === 1) {
2 years ago
// that.$u.toast(res.msg);
setTimeout(() => {
uni.showToast({
title: res.msg,
icon: "none",
duration: 2000,
success: (res) => {
setTimeout(() => {
uni.hideToast();
}, 2000)
}
});
}, 200);
2 years ago
that.orderList.splice(orderIndex, 1);
}
});
}
}
});
},
// 取消订单
onCancel(id, orderIndex) {
let that = this;
that.$http('order.cancel', {
id: id
},
'取消中...'
).then(res => {
if (res.code === 1) {
2 years ago
// that.$u.toast(res.msg);
2 years ago
this.orderList.splice(orderIndex, 1);
}
});
},
// 立即购买
onPay(id) {
uni.navigateTo({
url: `/pages/order/payment/method?orderId=${id}&orderType=goods`
});
},
// 查看物流
onExpress(orderId) {
let that = this;
that.$http('order.expressList', {
order_id: orderId
}).then(res => {
if (res.code === 1) {
if (res.data.length == 1) {
this.jump('/pages/order/express/express-detail', { orderId: orderId, expressId: res
.data[0].id });
} else if (res.data.length > 1) {
this.jump('/pages/order/express/express-list', { orderId: orderId });
} else {
that.$u.toast('暂无包裹~');
}
}
});
}
}
};
</script>
<style lang="scss">
.order-nav {
background: #fff;
height: 80rpx;
.nav-item {
flex: 1;
.item-title {
font-size: 30rpx;
font-weight: 400;
color: rgba(51, 51, 51, 1);
line-height: 76rpx;
}
.nav-line {
width: 100rpx;
height: 4rpx;
background: #fff;
}
.line-active {
2 years ago
// background: rgba(230, 184, 115, 1);
background-color: #17C161;
2 years ago
}
}
}
.order-list {
background: #fff;
2 years ago
margin: 20rpx 24rpx;
border-radius: 20rpx;
2 years ago
.order-bottom {
padding-bottom: 20rpx;
.btn-box {
justify-content: flex-end;
2 years ago
margin-top: 29rpx;
2 years ago
}
.all-msg {
font-size: 24rpx;
color: #999;
justify-content: flex-end;
margin-bottom: 10rpx;
padding: 0 30rpx;
.all-unit {
font-size: 20rpx;
}
.all-money {
font-size: 26rpx;
color: #333;
font-weight: 500;
2 years ago
color:#FE1B26;
2 years ago
&::before {
content: '¥';
2 years ago
font-size: 18rpx;
2 years ago
}
}
}
.obtn1 {
width: 160rpx;
line-height: 60rpx;
background: rgba(238, 238, 238, 1);
border-radius: 30rpx;
font-size: 26rpx;
font-weight: 400;
color: rgba(51, 51, 51, 1);
margin-right: 20rpx;
padding: 0;
}
.obtn2 {
width: 160rpx;
line-height: 60rpx;
2 years ago
background: #17C161;
// background: linear-gradient(90deg, rgba(233, 180, 97, 1), rgba(238, 204, 137, 1));
2 years ago
box-shadow: 0px 7rpx 6rpx 0px rgba(229, 138, 0, 0.22);
border-radius: 30rpx;
margin-right: 20rpx;
font-size: 26rpx;
font-weight: 400;
color: #fff;
padding: 0;
}
.obtn3 {
background: #ffeeee;
color: #e50808;
width: 160rpx;
line-height: 60rpx;
border-radius: 30rpx;
margin-right: 20rpx;
font-size: 26rpx;
font-weight: 400;
padding: 0;
}
}
.order-head {
padding: 0 25rpx;
height: 77rpx;
2 years ago
// border-bottom: 1rpx solid #dfdfdf;
2 years ago
.no {
font-size: 26rpx;
color: #999;
}
.state {
font-size: 26rpx;
2 years ago
color: #17C161;
2 years ago
}
}
.goods-order {
2 years ago
// border-bottom: 1px solid rgba(223, 223, 223, 0.5);
2 years ago
padding: 20rpx 20rpx 0;
margin-bottom: 20rpx;
.order-content {
padding-bottom: 20rpx;
.order-sku {
font-size: 24rpx;
font-weight: 400;
color: rgba(153, 153, 153, 1);
width: 450rpx;
margin-bottom: 20rpx;
.order-num {
margin-right: 10rpx;
}
}
.order-price-box {
.status-btn {
height: 32rpx;
2 years ago
border: 1rpx solid #17C161;
2 years ago
border-radius: 15rpx;
font-size: 20rpx;
font-weight: 400;
2 years ago
color: #17C161;
2 years ago
padding: 0 10rpx;
margin-left: 20rpx;
background: rgba(233, 183, 102, 0.16);
}
.order-price {
font-size: 26rpx;
font-weight: 600;
2 years ago
color:#FE1B26;
2 years ago
}
}
}
}
}
</style>