oil-station/gasStation-uni/pagesMy/myorder/myorder.vue
2023-12-22 16:33:34 +08:00

463 lines
10 KiB
Vue

<template>
<view class="content">
<view class="container">
<view class="my-header">
<view class="my-icons" @click="goBack"> <uni-icons type="left" size="16"></uni-icons> </view>
<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>
<input type="text" placeholder="搜索我的订单" v-model="query" @confirm="queryOrder" />
</view>
<view class="" @click="queryOrder">搜索</view>
</view>
<!-- tap -->
<view class="tap-box">
<view class="box-fv" :class="{'actbox' : tapindex == index }" v-for="(item,index) in tapList"
:key="index" @click="getTapIndex(index)">
<view class="">{{item.text}}</view>
<view class="gang" :class="{'actg' : tapindex == index }"></view>
</view>
</view>
<view>
<scroll-view scroll-y="true" :scroll-top="scrollTop" id="scrollList" style="height: 78vh;"
@scrolltolower="scrolltolower">
<!-- 油品订单列表 -->
<view class="box-order" v-for="(item,index) in list" :key="index">
<view class="or-box-top">
<view class="">{{getStoreName(storeList,item.storeId)}}</view>
<view class="chengg">{{getPayName(payList,item.orderStatus)}}</view>
</view>
<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>
<view v-if="item.orderStatus=='paid'" class="end-box" @click="goComment()">
<view class="anniu">
<text>评价有礼</text>
</view>
</view>
<view v-else-if="item.orderStatus=='unpaid'" class="end-box" @click="goPayment()">
<view class="anniu">
<text>去支付</text>
</view>
</view>
<view v-else class="end-box">
<!-- <view class="anniu">
<text>去支付</text>
</view> -->
</view>
</view>
<!-- 储值卡订单列表 -->
<view class="box-order" v-for="(item,index) in balanceList" :key="index">
<view class="or-box-top">
<view class="">{{getStoreName(storeList,item.storeId)}}</view>
<view class="chengg">{{getPayName(payList,item.orderStatus)}}</view>
</view>
<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>
<view class="end-box" @click="goComment()">
<view class="anniu">
<text>评价有礼</text>
</view>
</view>
</view>
<!-- 状态:加载更多、没有更多了... -->
<u-load-more :status="status"></u-load-more>
</scroll-view>
</view>
</view>
</view>
</template>
<script>
import request from '../../utils/request'
export default {
data() {
return {
title: '',
tapindex: 0,
tapList: [{
text: '全部'
},
{
text: '待支付'
},
{
text: '已完成'
},
{
text: '待评价'
},
],
// 订单列表信息
orderList: [],
list: [],
// 储值卡订单列表信息
balanceList:[],
map: {
page: 1,
pageSize: 10,
storeId: "",
orderStatus: "",
remark: "",
},
// 总条数
total: 0,
// 店铺列表信息
storeList: [],
// 支付状态列表
payList: [],
query: "",
status: 'more', // 状态-正在加载中
scrollTop: 0,
}
},
onLoad(option) {
this.tapindex = option.id
this.getTapIndex(option.id)
// this.getMyOrder()
this.getStores()
this.getPayList()
},
components: {
},
methods: {
// 搜索我的订单
queryOrder() {
let _this = this;
_this.list = [];
if (_this.query == "") {
_this.list = _this.orderList
} else {
_this.storeList.forEach(item => {
_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)
}
}
})
})
}
},
parseTime(dateTime) {
let date = new Date(dateTime);
let y = date.getFullYear() + "-";
let mon = ((date.getMonth() + 1 < 10) ? ('0' + date.getMonth()) : date.getMonth()) + "-";
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());
return y + mon + d + h + m + s;
},
getStoreName(list, id) {
let name = "";
list.forEach(item => {
if (item.id == id) {
if (item.description != "" && item.description != null) {
name = item.name + "(" + item.description + ")"
} else {
name = item.name
}
}
})
return name;
},
getPayName(list, type) {
let name = "";
list.forEach(item => {
if (item.dictValue == type) {
name = item.dictLabel
}
})
return name;
},
// 查询支付状态列表信息
getPayList() {
let _this = this;
request({
url: "system/dict/data/type/pay_status",
method: 'get',
}).then((res) => {
_this.payList = res.data
})
},
// 查询店铺列表信息
getStores() {
let _this = this;
request({
url: "business/storeInformation/store/list",
method: 'get',
}).then((res) => {
_this.storeList = res.data
})
},
// 滚动区域
scrolltolower() {
if (this.orderList.length < this.total) {
this.map.page++;
this.getMyOrder()
} else {
this.status = "no-more"
}
},
// 查询我的订单信息
getMyOrder() {
let _this = this;
request({
url: "business/oilOrder/userOrders",
method: 'get',
params: _this.map,
}).then((res) => {
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();
console.log(res,_this.map,_this.map.page)
}
})
},
getTapIndex(index) {
this.tapindex = index
if (this.tapindex == 0) {
this.map = {
page: 1,
pageSize: 10,
storeId: "",
orderStatus: "",
remark: "",
}
this.getMyOrder()
} else if (this.tapindex == 1) {
this.map = {
page: 1,
pageSize: 10,
storeId: "",
orderStatus: "unpaid",
remark: "",
}
this.getMyOrder()
} else if (this.tapindex == 2) {
this.map = {
page: 1,
pageSize: 10,
storeId: "",
orderStatus: "paid",
remark: "",
}
this.getMyOrder()
} else {
this.map = {
page: 1,
pageSize: 10,
storeId: "",
orderStatus: "paid",
remark: "待评价",
}
this.getMyOrder()
}
},
goPayment(){
},
goComment() {
uni.navigateTo({
url: "/pagesMy/comment/comment"
})
},
goBack() {
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>