oil-station/gasStation-uni/pagesMy/myorder/myorder.vue
2024-08-16 18:26:19 +08:00

587 lines
14 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" @click="goOrderInfo(item.orderNo)">
<view class="">{{getStoreName(storeList,item.storeId)}}</view>
<!-- <view class="chengg">{{getPayName(payList,item.orderStatus)}}</view> -->
<view class="chengg" v-if="item.orderStatus=='paid'">已支付</view>
<view class="chengg" v-else-if="item.orderStatus=='payFail'">支付失败</view>
<view class="chengg" v-else-if="item.orderStatus=='refund'">已退款</view>
<view class="chengg" v-else-if="item.orderStatus=='refunding'">退款中</view>
<view class="chengg" v-else>未支付</view>
</view>
<!-- <view class="but-box">
<view class="huis">订单类型</view>
<view class="">油品订单</view>
</view> -->
<view class="but-box" @click="goOrderInfo(item.orderNo)">
<view class="huis">订单金额</view>
<view class="">¥{{item.orderAmount}}</view>
</view>
<view class="but-box" @click="goOrderInfo(item.orderNo)">
<view class="huis">优惠合计</view>
<view class="reds">¥{{item.discountAmount}}</view>
</view>
<view class="but-box" @click="goOrderInfo(item.orderNo)">
<view class="huis">订单时间</view>
<view class="" v-if="item.orderStatus=='paid'">{{item.payTime}}</view>
<view class="" v-else>{{item.createTime}}</view>
</view>
<view v-if="item.orderStatus=='paid' && item.remark==null" class="end-box" @click="goComment(item.id)">
<view class="anniu">
<text>去评价</text>
</view>
</view>
<view v-if="item.orderStatus=='paid' && item.remark==''" class="end-box" @click="goComment(item.id)">
<view class="anniu">
<text>去评价</text>
</view>
</view>
<view v-if="item.orderStatus=='paid' && item.remark!='' && item.remark!=null" class="end-box">
<view>
<text>已评价</text>
</view>
</view>
<view v-else-if="item.orderStatus=='unpaid'" class="end-box" @click="goPayment(item.orderNo)">
<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.status)}}</view>
</view>
<view class="but-box">
<view class="huis">订单类型</view>
<view class="">储值卡订单</view>
</view>
<view class="but-box">
<view class="huis">订单金额</view>
<view class="">¥{{item.amount}}</view>
</view>
<view class="but-box">
<view class="huis">优惠合计</view>
<view class="reds">¥{{item.discount}}</view>
</view>
<view class="but-box">
<view class="huis">订单时间</view>
<view class="" v-if="item.status=='paid'">{{parseTime(item.payTime)}}</view>
<view class="" v-else>{{parseTime(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> -->
<u-empty v-if="list.length == 0" mode="coupon" text="内容为空"
icon="http://cdn.uviewui.com/uview/empty/coupon.png">
</u-empty>
</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:[],
list1: [],
map: {
page: 1,
pageSize: 10,
storeId: uni.getStorageSync("storeId"),
orderStatus: "",
remark: "",
payType:uni.getStorageSync("appltType")
},
map1: {
page: 1,
pageSize: 10,
status: "",
},
// 总条数
total: 0,
total1: 0,
// 店铺列表信息
storeList: [],
// 支付状态列表
payList: [],
query: "",
status: 'more', // 状态-正在加载中
scrollTop: 0,
}
},
onLoad(option) {
this.tapindex = option.id
this.getTapIndex(option.id)
// this.getMyOrder()
this.getStores()
// this.getPayList()
},
onShow() {
this.getTapIndex(0)
},
components: {
},
methods: {
// 搜索我的订单
queryOrder() {
let _this = this;
_this.list = [];
_this.list1 = [];
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)
}
}
})
})
_this.storeList.forEach(item => {
_this.balanceList.forEach(item1 => {
if (item.name.includes(_this.query)) {
if (item1.storeId == item.id) {
_this.list1.push(item1)
}
return
}
if (item.name.includes(_this.query)) {
if (item1.storeId == item.id) {
_this.list1.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) => {
console.log(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"
}
// if (this.balanceList.length < this.total1) {
// this.map1.page++;
// this.getBalanceOrder()
// } else {
// this.status = "no-more"
// }
},
// 查询我的油品订单信息
getMyOrder() {
let _this = this;
_this.map.storeId = uni.getStorageSync("storeId")
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();
}
})
},
// 查询我的储值卡订单信息
getBalanceOrder() {
let _this = this;
request({
url: "business/marketingActivity/activeExchange/cardValueOrders/list",
method: 'get',
params: _this.map1,
}).then((res) => {
console.log(res,uni.getStorageSync("userId"))
uni.showLoading({
title: '加载中'
});
if (res.code == 200) {
if (_this.map1.page == 1) {
_this.balanceList = res.data.records
_this.list1 = res.data.records
} else {
_this.balanceList = _this.balanceList.concat(res.data.records)
_this.list1 = _this.list.concat(res.data.records)
}
_this.total1 = res.data.total
uni.hideLoading();
}
})
},
getTapIndex(index) {
this.orderList = []
this.list = []
this.total = 0
this.tapindex = index
if (this.tapindex == 0) {
this.map = {
page: 1,
pageSize: 10,
storeId: "",
orderStatus: "",
remark: "",
payType:uni.getStorageSync("appltType")
}
this.getMyOrder()
// this.map1 = {
// page: 1,
// pageSize: 10,
// status: "",
// }
// this.getBalanceOrder()
} else if (this.tapindex == 1) {
this.map = {
page: 1,
pageSize: 10,
storeId: "",
orderStatus: "unpaid",
remark: "",
payType:uni.getStorageSync("appltType")
}
this.getMyOrder()
// this.map1 = {
// page: 1,
// pageSize: 10,
// status: "unpaid",
// }
// this.getBalanceOrder()
} else if (this.tapindex == 2) {
this.map = {
page: 1,
pageSize: 10,
storeId: "",
orderStatus: "paid",
remark: "",
payType:uni.getStorageSync("appltType")
}
this.getMyOrder()
// this.map1 = {
// page: 1,
// pageSize: 10,
// status: "paid",
// }
// this.getBalanceOrder()
} else {
this.map = {
page: 1,
pageSize: 10,
storeId: "",
orderStatus: "paid",
remark: "1",
payType:uni.getStorageSync("appltType")
}
this.getMyOrder()
// this.map1 = {
// page: 1,
// pageSize: 10,
// status: "paid",
// }
// this.getBalanceOrder()
}
},
goPayment(orderNo){
uni.navigateTo({
url: '/pagesRefuel/orderDetail/index?orderNo=' + orderNo,
})
},
goOrderInfo(orderNo){
uni.navigateTo({
url: '/pagesMy/details/details?orderNo=' + orderNo,
})
},
goComment(orderId) {
uni.navigateTo({
url: "/pagesMy/comment/comment?orderId=" + orderId,
})
},
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>