oil-station/gasStation-uni/pagesMy/myorder/myorder.vue

419 lines
8.6 KiB
Vue
Raw Normal View History

2023-11-27 09:24:16 +08:00
<template>
<view class="content">
<view class="container">
<view class="my-header">
2023-12-05 17:18:27 +08:00
<view class="my-icons" @click="goBack"> <uni-icons type="left" size="16"></uni-icons> </view>
2023-11-27 09:24:16 +08:00
<view class="my-text">我的订单</view>
<view class="my-icons"></view>
</view>
<!-- 顶部区域 -->
<view class="top-box">
<view class="top-input">
<u-icon name="search" size="28"></u-icon>
2023-12-18 18:44:02 +08:00
<input type="text" placeholder="搜索我的订单" v-model="query" @confirm="queryOrder" />
2023-11-27 09:24:16 +08:00
</view>
2023-12-05 17:18:27 +08:00
<view class="" @click="queryOrder">搜索</view>
2023-11-27 09:24:16 +08:00
</view>
<!-- tap -->
<view class="tap-box">
<view class="box-fv" :class="{'actbox' : tapindex == index }" v-for="(item,index) in tapList"
2023-12-05 17:18:27 +08:00
:key="index" @click="getTapIndex(index)">
2023-11-27 09:24:16 +08:00
<view class="">{{item.text}}</view>
<view class="gang" :class="{'actg' : tapindex == index }"></view>
</view>
</view>
2023-12-06 09:20:25 +08:00
2023-12-05 17:18:27 +08:00
<view>
2023-12-06 18:36:10 +08:00
<scroll-view scroll-y="true" :scroll-top="scrollTop" id="scrollList" style="height: 78vh;"
2023-12-06 09:20:25 +08:00
@scrolltolower="scrolltolower">
2023-12-05 17:18:27 +08:00
<!-- 列表 -->
2023-12-06 09:20:25 +08:00
<view class="box-order" v-for="(item,index) in list" :key="index">
2023-12-05 17:18:27 +08:00
<view class="or-box-top">
<view class="">{{getStoreName(storeList,item.storeId)}}</view>
<view class="chengg">{{getPayName(payList,item.orderStatus)}}</view>
</view>
2023-12-06 09:20:25 +08:00
2023-12-05 17:18:27 +08:00
<view class="but-box">
<view class="huis">订单金额</view>
<view class="">{{item.orderAmount}}</view>
</view>
<view class="but-box">
<view class="huis">优惠合计</view>
<view class="reds">{{item.discountAmount}}</view>
</view>
<view class="but-box">
<view class="huis">订单时间</view>
<view class="" v-if="item.orderStatus=='paid'">{{parseTime(item.payTime)}}</view>
<view class="" v-else>{{item.createTime}}</view>
</view>
2023-12-06 09:41:19 +08:00
<view class="end-box" @click="goComment()">
2023-12-05 17:18:27 +08:00
<view class="anniu">
<text>评价有礼</text>
</view>
</view>
</view>
<!-- 状态加载更多没有更多了... -->
<u-load-more :status="status"></u-load-more>
</scroll-view>
</view>
2023-11-27 09:24:16 +08:00
</view>
</view>
</template>
<script>
2023-12-05 17:18:27 +08:00
import request from '../../utils/request'
2023-11-27 09:24:16 +08:00
export default {
data() {
return {
title: '',
tapindex: 0,
2023-12-06 09:20:25 +08:00
tapList: [{
text: '全部'
},
{
text: '待支付'
},
{
text: '已完成'
},
{
text: '待评价'
},
2023-12-05 17:18:27 +08:00
],
// 订单列表信息
2023-12-06 09:20:25 +08:00
orderList: [],
list: [],
map: {
page: 1,
pageSize: 5,
storeId: "",
orderStatus: "",
remark: "",
2023-12-05 17:18:27 +08:00
},
// 总条数
2023-12-06 09:20:25 +08:00
total: 0,
2023-12-05 17:18:27 +08:00
// 店铺列表信息
2023-12-06 09:20:25 +08:00
storeList: [],
2023-12-05 17:18:27 +08:00
// 支付状态列表
2023-12-06 09:20:25 +08:00
payList: [],
query: "",
2023-12-05 17:18:27 +08:00
status: 'more', // 状态-正在加载中
scrollTop: 0,
2023-11-27 09:24:16 +08:00
}
},
2023-12-06 09:41:19 +08:00
onLoad(option) {
this.tapindex = option.id
this.getTapIndex(option.id)
2023-12-08 15:48:54 +08:00
this.getMyOrder()
2023-12-05 17:18:27 +08:00
this.getStores()
this.getPayList()
},
2023-11-27 09:24:16 +08:00
components: {
},
methods: {
2023-12-05 17:18:27 +08:00
// 搜索我的订单
2023-12-06 09:20:25 +08:00
queryOrder() {
2023-12-05 17:18:27 +08:00
let _this = this;
_this.list = [];
2023-12-06 09:20:25 +08:00
if (_this.query == "") {
2023-12-05 17:18:27 +08:00
_this.list = _this.orderList
2023-12-06 09:20:25 +08:00
} else {
2023-12-05 17:18:27 +08:00
_this.storeList.forEach(item => {
2023-12-06 09:20:25 +08:00
_this.orderList.forEach(item1 => {
if (item.name.includes(_this.query)) {
if (item1.storeId == item.id) {
_this.list.push(item1)
}
return
}
if (item.name.includes(_this.query)) {
if (item1.storeId == item.id) {
_this.list.push(item1)
}
}
})
2023-12-05 17:18:27 +08:00
})
}
},
2023-12-06 09:20:25 +08:00
parseTime(dateTime) {
2023-12-05 17:18:27 +08:00
let date = new Date(dateTime);
let y = date.getFullYear() + "-";
2023-12-06 09:20:25 +08:00
let mon = ((date.getMonth() + 1 < 10) ? ('0' + date.getMonth()) : date.getMonth()) + "-";
2023-12-05 17:18:27 +08:00
let d = ((date.getDate() < 10) ? ('0' + date.getDate()) : date.getDate()) + " ";
let h = ((date.getHours() < 10) ? ('0' + date.getHours()) : date.getHours()) + ":";
let m = ((date.getMinutes() < 10) ? ('0' + date.getMinutes()) : date.getMinutes()) + ":";
let s = ((date.getSeconds() < 10) ? ('0' + date.getSeconds()) : date.getSeconds());
2023-12-06 09:20:25 +08:00
return y + mon + d + h + m + s;
2023-12-05 17:18:27 +08:00
},
2023-12-06 09:20:25 +08:00
getStoreName(list, id) {
2023-12-05 17:18:27 +08:00
let name = "";
list.forEach(item => {
if (item.id == id) {
2023-12-06 09:20:25 +08:00
if (item.description != "" && item.description != null) {
name = item.name + "(" + item.description + ")"
} else {
2023-12-05 17:18:27 +08:00
name = item.name
}
}
})
return name;
},
2023-12-06 09:20:25 +08:00
getPayName(list, type) {
2023-12-05 17:18:27 +08:00
let name = "";
list.forEach(item => {
if (item.dictValue == type) {
name = item.dictLabel
}
})
return name;
},
// 查询支付状态列表信息
2023-12-06 09:20:25 +08:00
getPayList() {
2023-12-05 17:18:27 +08:00
let _this = this;
request({
url: "system/dict/data/type/pay_status",
method: 'get',
2023-12-06 09:20:25 +08:00
}).then((res) => {
2023-12-05 17:18:27 +08:00
_this.payList = res.data
})
},
// 查询店铺列表信息
2023-12-06 09:20:25 +08:00
getStores() {
2023-12-05 17:18:27 +08:00
let _this = this;
request({
url: "business/storeInformation/store/stores",
method: 'get',
2023-12-06 09:20:25 +08:00
}).then((res) => {
2023-12-05 17:18:27 +08:00
_this.storeList = res.data
})
},
// 滚动区域
2023-12-06 09:20:25 +08:00
scrolltolower() {
if (this.orderList.length < this.total) {
2023-12-05 17:18:27 +08:00
this.map.page++;
this.getMyOrder()
2023-12-06 09:20:25 +08:00
} else {
2023-12-05 17:18:27 +08:00
this.status = "no-more"
}
},
// 查询我的订单信息
2023-12-06 09:20:25 +08:00
getMyOrder() {
2023-12-05 17:18:27 +08:00
let _this = this;
request({
url: "business/oilOrder/userOrders",
method: 'get',
params: _this.map,
2023-12-06 09:20:25 +08:00
}).then((res) => {
2023-12-06 09:41:19 +08:00
uni.showLoading({
title: '加载中'
});
if (res.code == 200) {
if (_this.map.page == 1) {
_this.orderList = res.data.records
_this.list = res.data.records
} else {
_this.orderList = _this.orderList.concat(res.data.records)
_this.list = _this.list.concat(res.data.records)
}
_this.total = res.data.total
uni.hideLoading();
2023-12-05 17:18:27 +08:00
}
2023-12-06 09:41:19 +08:00
2023-12-05 17:18:27 +08:00
})
},
getTapIndex(index) {
2023-11-27 09:24:16 +08:00
this.tapindex = index
2023-12-06 09:20:25 +08:00
if (this.tapindex == 0) {
2023-12-05 17:18:27 +08:00
this.map = {
2023-12-06 09:20:25 +08:00
storeId: "",
orderStatus: "",
remark: "",
2023-12-05 17:18:27 +08:00
}
this.getMyOrder()
2023-12-06 09:20:25 +08:00
} else if (this.tapindex == 1) {
2023-12-05 17:18:27 +08:00
this.map = {
2023-12-06 09:20:25 +08:00
page: 1,
pageSize: 5,
storeId: "",
orderStatus: "unpaid",
remark: "",
2023-12-05 17:18:27 +08:00
}
this.getMyOrder()
2023-12-06 09:20:25 +08:00
} else if (this.tapindex == 2) {
2023-12-05 17:18:27 +08:00
this.map = {
2023-12-06 09:20:25 +08:00
page: 1,
pageSize: 5,
storeId: "",
orderStatus: "paid",
remark: "",
2023-12-05 17:18:27 +08:00
}
this.getMyOrder()
2023-12-06 09:20:25 +08:00
} else {
2023-12-05 17:18:27 +08:00
this.map = {
2023-12-06 09:20:25 +08:00
page: 1,
pageSize: 5,
storeId: "",
2023-12-06 10:28:49 +08:00
orderStatus: "paid",
2023-12-06 09:20:25 +08:00
remark: "待评价",
2023-12-05 17:18:27 +08:00
}
this.getMyOrder()
}
2023-11-27 09:24:16 +08:00
},
2023-12-06 09:41:19 +08:00
goComment() {
uni.navigateTo({
url: "/pagesMy/comment/comment"
})
},
2023-12-05 17:18:27 +08:00
goBack() {
2023-11-27 09:24:16 +08:00
uni.navigateBack()
}
}
}
</script>
<style scoped lang="scss">
.content {
background: #f4f5f6;
}
.container {
width: 100%;
height: 100vh;
box-sizing: border-box;
padding-top: 88px;
}
.my-header {
width: 100%;
height: 88px;
background: #ffffff;
display: flex;
align-items: center;
justify-content: space-between;
color: #000;
box-sizing: border-box;
padding: 0px 15px;
padding-top: 40px;
.my-icons {
width: 20px;
}
position: fixed;
top: 0px;
}
.top-box {
background-color: #ffffff;
padding: 10px;
width: 100%;
display: flex;
align-items: center;
.top-input {
width: 80%;
height: 35px;
background: #F3F3F3;
border-radius: 33px;
margin-right: 15px;
display: flex;
align-items: center;
box-sizing: border-box;
padding: 0px 15px;
}
}
.tap-box {
width: 100%;
display: flex;
align-items: center;
background: #ffffff;
}
.box-fv {
color: #666666;
width: 25%;
text-align: center;
}
.gang {
width: 30px;
height: 5px;
margin: 5px auto;
// background: #339DFF;
border-radius: 5px;
}
.actg {
background: #339DFF;
}
.actbox {
font-weight: bold !important;
color: #000 !important;
}
.box-order {
width: 95%;
border-radius: 8px;
background: #ffffff;
box-sizing: border-box;
padding: 10px;
margin: 10px auto;
}
.or-box-top {
width: 100%;
display: flex;
align-items: center;
justify-content: space-between;
box-sizing: border-box;
padding: 5px 0px;
border-bottom: 1px solid #e5e5e5;
}
.chengg {
color: #1678ff;
}
.but-box {
width: 100%;
display: flex;
align-items: center;
justify-content: space-between;
font-size: 14px;
margin: 5px 0px;
}
.reds {
color: red;
}
.huis {
color: #666666;
}
.end-box {
width: 100%;
display: flex;
align-items: center;
justify-content: flex-end;
}
.anniu {
width: 70px;
height: 25px;
background-color: #1678ff;
color: #ffffff;
display: flex;
align-items: center;
justify-content: center;
font-size: 14px;
border-radius: 15px;
}
</style>