336 lines
7.3 KiB
Vue
336 lines
7.3 KiB
Vue
<template>
|
||
<view>
|
||
<u-sticky bgColor="#fff">
|
||
<view class="tab-wrap">
|
||
<view class="item" v-for="(item, index) in tabs" :key="index" @click="orderswitch(item,index)">
|
||
<text>{{ item.name }}</text>
|
||
</view>
|
||
<view class="line-wrap"
|
||
:style="{ left: `${(100 / tabs.length) * active}%`, width: `${100 / tabs.length}%` }">
|
||
<view class="line"></view>
|
||
</view>
|
||
</view>
|
||
</u-sticky>
|
||
<view class="list-wrap">
|
||
<view class="item" v-for="(item,index) in list" :key="index" @click="orderinfo(item)">
|
||
<view class="header-wrap">
|
||
<text v-if="item.sendType == 'post'">快递</text>
|
||
<text v-if="item.sendType == 'takeaway'">外卖</text>
|
||
<text v-if="item.sendType == 'takeself'">自提</text>
|
||
<text v-if="item.sendType == 'table'">堂食</text>
|
||
<text class="status" v-if="item.status == 'unpaid' || item.status == 'paying'">
|
||
<text>待支付</text>
|
||
</text>
|
||
<text class="status" v-if="item.status == 'unsend'">
|
||
<text>待发货</text>
|
||
</text>
|
||
<text class="status" v-if="item.status == 'closed'">
|
||
<text>订单完成</text>
|
||
</text>
|
||
<text class="status" v-if="item.status == 'send'">
|
||
<text> 已发</text>
|
||
</text>
|
||
<text class="status" v-if="item.status == 'refunding'">
|
||
<text>申请退单</text>
|
||
</text>
|
||
<text class="status" v-if="item.status == 'refund'">
|
||
<text>退单</text>
|
||
</text>
|
||
<text class="status" v-if="item.status == 'cancelled'">
|
||
<text>取消订单</text>
|
||
</text>
|
||
<text class="status" v-if="item.status == 'merge'">
|
||
<text>合台</text>
|
||
</text>
|
||
</view>
|
||
<view class="content">
|
||
<view class="shop-info">
|
||
<view class="shop-item">
|
||
<view class="cover flex-start" v-for="(item1,index1) in item.detailList" :key="index1">
|
||
<!-- <image :src="item1.productImg" style="width: 200rpx;height: 200rpx; border-radius: 20rpx;" mode="widthFix"></image> -->
|
||
<c-image width="200" height="200" radius="20" :src="item1.productImg"></c-image>
|
||
</view>
|
||
<!-- <view class="info">
|
||
<text class="name">美味大宅蟹</text>
|
||
<text class="num">数量:1</text>
|
||
</view> -->
|
||
</view>
|
||
</view>
|
||
<view class="total">
|
||
<text class="t">需付款</text>
|
||
<text class="i">¥</text>
|
||
<text class="num">{{item.orderAmount}}</text>
|
||
</view>
|
||
<view class="intro-wrap">
|
||
<text class="time">下单日期:{{$u.timeFormat(item.createdAt, 'yyyy-mm-dd hh:MM')}}</text>
|
||
<text class="intro num">共{{item.totalNumber}}件商品 合计:¥{{item.orderAmount}}</text>
|
||
</view>
|
||
</view>
|
||
<view class="footer-wrap">
|
||
<view class="btn">
|
||
<text>查看详情</text>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
<u-loadmore :status="form.status" fontSize="28" color="#999" iconSize="28" />
|
||
</view>
|
||
</template>
|
||
|
||
<script>
|
||
import list from '../../uni_modules/uview-ui/libs/config/props/list';
|
||
export default {
|
||
data() {
|
||
return {
|
||
active: 0,
|
||
tabs: [{
|
||
name: '全部',
|
||
type: 1,
|
||
status: ''
|
||
},
|
||
{
|
||
name: '待支付',
|
||
type: 2,
|
||
status: 'unpaid'
|
||
},
|
||
{
|
||
name: '待发货',
|
||
type: 3,
|
||
status: 'unsend'
|
||
},
|
||
{
|
||
name: '已完成',
|
||
type: 4,
|
||
status: 'closed'
|
||
},
|
||
{
|
||
name: '退款',
|
||
type: 5,
|
||
status: 'refund'
|
||
}
|
||
],
|
||
list: [],
|
||
is_end: false,
|
||
swiperCurrent: '',
|
||
form: {
|
||
page: 1,
|
||
size: 10,
|
||
status: 'loadmore',
|
||
},
|
||
};
|
||
},
|
||
onShow() {
|
||
if (uni.cache.get('token')) {
|
||
this.loginwxuserInfo()
|
||
}
|
||
if (this.tabs.findIndex((item) => item.type == this.useStorage.get('orderType')) == -1) {
|
||
this.active = 0
|
||
} else {
|
||
this.active = (this.tabs.findIndex((item) => item.type == this.useStorage.get('orderType')));
|
||
}
|
||
this.init_fn()
|
||
},
|
||
onReachBottom() {
|
||
this.orderorderList()
|
||
},
|
||
methods: {
|
||
async loginwxuserInfo() {
|
||
let res = await this.api.loginwxuserInfo({
|
||
userId: uni.cache.get('userInfo').id
|
||
})
|
||
if (res.code == 0) {
|
||
uni.cache.set('userInfo', res.data);
|
||
this.userInfo = uni.cache.get('userInfo')
|
||
}
|
||
},
|
||
orderinfo(e) {
|
||
uni.pro.navigateTo('order/order_detail', {
|
||
orderId: e.id
|
||
})
|
||
},
|
||
init_fn() {
|
||
this.list = []
|
||
this.is_end = false
|
||
this.form.page = 1
|
||
this.form.status = 'loadmore'
|
||
this.orderorderList()
|
||
},
|
||
orderswitch(e, a) {
|
||
this.active = a
|
||
if (e.type == 1) {
|
||
this.swiperCurrent = ''
|
||
} else {
|
||
this.swiperCurrent = e.status
|
||
}
|
||
this.init_fn()
|
||
},
|
||
async orderorderList() {
|
||
let res = await this.api.orderorderList({
|
||
page: this.form.page,
|
||
size: this.form.size,
|
||
userId: uni.cache.get('userInfo').id, //userId
|
||
status: this.swiperCurrent
|
||
})
|
||
if (res.data.length == 0) {
|
||
this.is_end = true
|
||
this.form.status = 'nomore'
|
||
return false;
|
||
} else {
|
||
this.form.status = 'loading';
|
||
this.form.page = ++this.form.page;
|
||
setTimeout(() => {
|
||
this.list = [...this.list, ...res.data];
|
||
if (res.data.length == 10) {
|
||
this.form.status = 'loading';
|
||
} else {
|
||
this.is_end = true;
|
||
this.form.status = 'nomore';
|
||
}
|
||
}, 500)
|
||
}
|
||
},
|
||
}
|
||
};
|
||
</script>
|
||
|
||
<style scoped lang="scss">
|
||
$tabH: 80upx;
|
||
$color: #ff411d;
|
||
|
||
.tab-wrap {
|
||
display: flex;
|
||
height: $tabH;
|
||
position: relative;
|
||
|
||
.item {
|
||
flex: 1;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
position: relative;
|
||
z-index: 2;
|
||
}
|
||
|
||
.line-wrap {
|
||
position: absolute;
|
||
bottom: 0;
|
||
display: flex;
|
||
justify-content: center;
|
||
padding-bottom: 8upx;
|
||
transition: all 0.3s ease-in-out;
|
||
|
||
.line {
|
||
$h: 6upx;
|
||
width: 30%;
|
||
height: $h;
|
||
border-radius: $h;
|
||
background-color: $color;
|
||
}
|
||
}
|
||
}
|
||
|
||
.list-wrap {
|
||
padding: $paddingSize;
|
||
|
||
.item {
|
||
border-radius: 20upx;
|
||
background-color: #fff;
|
||
|
||
&:not(:first-child) {
|
||
margin-top: $paddingSize;
|
||
}
|
||
|
||
.header-wrap {
|
||
padding: $paddingSize;
|
||
border-bottom: 1upx solid #ececec;
|
||
display: flex;
|
||
justify-content: space-between;
|
||
|
||
.status {
|
||
color: $color;
|
||
}
|
||
}
|
||
|
||
.content {
|
||
padding: $paddingSize;
|
||
|
||
.shop-info {
|
||
.shop-item {
|
||
display: flex;
|
||
overflow: hidden;
|
||
overflow-x: scroll;
|
||
|
||
.cover:nth-child(1) {
|
||
margin-left: 0rpx;
|
||
}
|
||
|
||
.cover {
|
||
|
||
// white-space: nowrap;
|
||
margin-left: 10rpx;
|
||
}
|
||
|
||
.info {
|
||
flex: 1;
|
||
display: flex;
|
||
flex-direction: column;
|
||
justify-content: space-around;
|
||
padding-left: 20upx;
|
||
}
|
||
}
|
||
}
|
||
|
||
.total {
|
||
display: flex;
|
||
align-items: flex-end;
|
||
justify-content: flex-end;
|
||
|
||
.t {
|
||
font-weight: bold;
|
||
font-size: 32upx;
|
||
}
|
||
|
||
.i {
|
||
font-size: 24upx;
|
||
}
|
||
|
||
.num {
|
||
font-size: 38upx;
|
||
position: relative;
|
||
top: 8upx;
|
||
}
|
||
}
|
||
|
||
.intro-wrap {
|
||
display: flex;
|
||
justify-content: space-between;
|
||
padding-top: $paddingSize;
|
||
|
||
.time {
|
||
color: #999;
|
||
font-size: 24upx;
|
||
}
|
||
|
||
.intro {
|
||
font-size: 24upx;
|
||
}
|
||
}
|
||
}
|
||
|
||
.footer-wrap {
|
||
display: flex;
|
||
justify-content: flex-end;
|
||
border-top: 1upx solid #ececec;
|
||
padding: $paddingSize;
|
||
|
||
.btn {
|
||
padding: 8upx 24upx;
|
||
border-radius: 100upx;
|
||
border: 1px solid #333;
|
||
display: flex;
|
||
align-items: center;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
</style> |