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.
yanzong_qianduan/pages/order/index.vue

824 lines
19 KiB

11 months ago
<template>
<view class="order" :style="appThemeStyle">
<mescroll-body ref="mescrollRef" :sticky="true" @init="mescrollInit" :down="{ native: true }"
@down="downCallback" :up="upOption" @up="upCallback">
<view class="search">
<view class="box">
<image src="/static/news/icon-search.png"></image>
<input type="search" @confirm="confirm" v-model='keyWords' placeholder="搜索订单" />
</view>
</view>
<!-- tab栏 -->
<u-tabs :list="tabs" bg-color="#fafafa" :is-scroll="false" height="120" font-size="32" :current="curTab"
bar-width="0" active-color="#111111" :duration="0.2" @change="onChangeTab" />
<!-- 订单列表 -->
<view class="order-list">
<view class="item" v-for="(item,index) in list">
<view class="hd">
<view class="a">
<image class="icon" :src="item.storeInfo.image_url"></image>
{{item.storeInfo.store_name}}
</view>
<view class="b">{{item.state_text}}</view>
</view>
<view class="bd" @click="goOrderDetail(item.order_id)" v-for="(goods, idx) in item.goods"
:key="idx">
<view class="pic">
<image :src="goods.goods_image"></image>
</view>
<view class="info">
<view class="a">{{ goods.goods_name }}</view>
<view class="b">
<text>{{ goods.is_user_grade ? goods.grade_goods_price : goods.goods_price }}</text>
</view>
</view>
<view class="num">
x{{ goods.total_num }}
</view>
</view>
<view class="fd">
{{ item.total_num }}件商品实付款<text>{{ item.pay_price }}</text>
</view>
<view v-if="item.menushow" class="menuarea">
<view class="mask" @click="changeMenu(index)">
</view>
<view class="menulist">
<view class="" v-if="item.order_status == OrderStatusEnum.COMPLETED.value"
@click="onInvoicing(item.order_id,item)">
申请开票
</view>
<!-- <view class=""
v-if="item.pay_status == PayStatusEnum.SUCCESS.value && item.delivery_status == ReceiptStatusEnum.NOT_RECEIVED.value"
@click="onRefund(item.order_id)">
申请退款
</view>
<view class=""
v-if="item.pay_status == PayStatusEnum.SUCCESS.value && item.delivery_status == ReceiptStatusEnum.RECEIVED.value"
@click="onSales(item.order_id)">
申请售后
</view> -->
<view class="" @click="onDelete(item.order_id)"
v-if="item.order_status == OrderStatusEnum.COMPLETED.value">
删除订单
</view>
<view class="" v-if="item.pay_status == PayStatusEnum.PENDING.value"
@click="onCancel(item.order_id)">
取消订单
</view>
</view>
<view class="trangle"></view>
</view>
<view class="btn">
<view class="a" @click="changeMenu(index)"
v-if="item.order_status == OrderStatusEnum.COMPLETED.value || item.pay_status == PayStatusEnum.PENDING.value">
更多</view>
<view class="b">
<view class="n" v-if="item.pay_status == PayStatusEnum.SUCCESS.value && item.delivery_type == DeliveryTypeEnum.EXTRACT.value
&& item.delivery_status == DeliveryStatusEnum.NOT_DELIVERED.value"
@click="onExtractQRCode(item.order_id)">核销码
</view>
<view class="n" v-if="item.pay_status == PayStatusEnum.PENDING.value"
@click="onPay(item.order_id)">去支付</view>
<view class="n" v-if="item.delivery_status == DeliveryStatusEnum.DELIVERED.value"
@click="onLogistics(item.order_id)">查看物流
</view>
<view class="n n-1"
v-if="item.delivery_status == DeliveryStatusEnum.DELIVERED.value && item.receipt_status == ReceiptStatusEnum.NOT_RECEIVED.value"
@click="onReceipt(item.order_id)">确认收货</view>
<view class="n"
v-if="item.pay_status == PayStatusEnum.SUCCESS.value && item.delivery_status == DeliveryStatusEnum.NOT_DELIVERED.value"
@click="onCdDia(item.goods_id)">催发货</view>
10 months ago
<view class="n" v-if="item.order_status == OrderStatusEnum.NORMAL.value && item.pay_status == PayStatusEnum.SUCCESS.value && item.delivery_status == DeliveryStatusEnum.NOT_DELIVERED.value"
@click="onCancel(item.order_id)">
取消订单
</view>
<!-- <view class="n"
v-if="item.pay_status == PayStatusEnum.SUCCESS.value && item.delivery_status == DeliveryStatusEnum.NOT_DELIVERED.value"
@click="onAdress(order.goods_id)">修改地址</view> -->
<!-- <view class="n n-1"
v-if="item.order_status == OrderStatusEnum.COMPLETED.value && item.is_comment == 0"
@click="handleTargetComment(item.order_id)">评价</view> -->
</view>
</view>
</view>
</view>
</mescroll-body>
<u-modal v-model="deleteShow" :show-cancel-button="true" :closable='false' @on-cancel="handleCancel"
@on-ok="handleOk" title="确认删除订单?" confirm-color="#F55349">
<view class="slot-content order-modal">
<view class="content">删除之后订单无法恢复无法处理您的售后问题 请慎重考虑</view>
<view class="desc" @click="toggleImage()">
<image v-if="isToggle" src="/static/invoice/select.png"></image>
<image v-else src="/static/invoice/select-on.png"></image>删除后将拼单信息设置为匿名
</view>
</view>
</u-modal>
<!-- 核销二维码弹窗 -->
<u-popup v-model="showQRCodePopup" mode="center" border-radius="26" :closeable="true">
<view class="qrcode-popup">
<view class="title">自提核销二维码</view>
<view class="pop-content">
<image v-if="qrcodeImage" class="image" :src="qrcodeImage"></image>
</view>
</view>
</u-popup>
<!-- 催单弹框 -->
<view class="dia" v-if="cdDia">
<view class="diaMain">
<image src="/static/order/ld.png" mode="" class="ld"></image>
<view class="cdTitle">
催单成功
</view>
<view class="cdInfo">
商家已收到您的催单提醒您精心挑选的商品正在配送中属于正常配送时效内请您耐心等待谢谢
</view>
<view class="iKnow" @click="meKone()">
我知道了
</view>
</view>
</view>
</view>
11 months ago
</template>
<script>
import {
DeliveryStatusEnum,
DeliveryTypeEnum,
OrderStatusEnum,
PayStatusEnum,
ReceiptStatusEnum
} from '@/common/enum/order'
import MescrollMixin from '@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins'
import {
getEmptyPaginateObj,
getMoreListData
} from '@/core/app'
import * as OrderApi from '@/api/order'
// 每页记录数量
const pageSize = 15
// tab栏数据
const tabs = [{
name: `待付款`,
value: 'payment'
}, {
name: `待发货`,
value: 'delivery'
}, {
name: `待收货`,
value: 'received'
}, {
name: `已完成`,
value: 'received'
}, ]
export default {
mixins: [MescrollMixin],
data() {
return {
cdDia: false,
isToggle: false,
deleteShow: false,
orderId: '',
// 枚举类
DeliveryStatusEnum,
DeliveryTypeEnum,
OrderStatusEnum,
PayStatusEnum,
ReceiptStatusEnum,
// 当前页面参数
options: {
dataType: 'all'
},
// tab栏数据
tabs,
// 当前标签索引
curTab: 0,
// 订单列表数据
list: [],
keyWords: '',
// 上拉加载配置
upOption: {
// 首次自动执行
auto: true,
// 每页数据的数量; 默认10
page: {
size: pageSize
},
// 数量要大于4条才显示无更多数据
noMoreSize: 4,
// 空布局
empty: {
tip: '亲,暂无订单记录'
}
},
// 控制onShow事件是否刷新订单列表
canReset: false,
// 核销二维码弹窗
showQRCodePopup: false,
// 核销二维码图片url (通过后端获取)
qrcodeImage: '',
}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
// 初始化当前选中的标签
this.initCurTab(options)
// 注册全局事件订阅: 是否刷新订单列表
uni.$on('syncRefresh', canReset => {
this.canReset = canReset
10 months ago
})
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
this.canReset && this.onRefreshList()
this.canReset = false
},
/**
* 生命周期函数--监听页面的卸载
*/
onUnload() {
// 卸载全局事件订阅
uni.$off('syncRefresh')
},
methods: {
confirm() {
// 刷新订单列表
app.onRefreshList()
},
changeMenu(index) {
this.list[index].menushow = !this.list[index].menushow
},
toggleImage() {
this.isToggle = !this.isToggle
},
// 初始化当前选中的标签
initCurTab(options) {
const app = this
if (options.dataType) {
const index = app.tabs.findIndex(item => item.value == options.dataType)
app.curTab = index > -1 ? index : 0
}
},
/**
* 上拉加载的回调 (页面初始化时也会执行一次)
* 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10
* @param {Object} page
*/
upCallback(page) {
const app = this
// 设置列表数据
app.getOrderList(page.num)
.then(list => {
const curPageLen = list.data.length
const totalSize = list.data.total
app.mescroll.endBySize(curPageLen, totalSize)
})
.catch(() => app.mescroll.endErr())
},
// 获取订单列表
getOrderList(pageNo = 1) {
const app = this
return new Promise((resolve, reject) => {
OrderApi.list({
dataType: app.getTabValue(),
page: pageNo,
keyword: app.keyWords
}, {
load: false
})
.then(result => {
// 合并新数据
const newList = app.initList(result.data.list)
app.list = getMoreListData(newList, app.list, pageNo)
resolve(newList)
})
})
},
// 初始化订单列表数据
initList(newList) {
newList.data.forEach(item => {
item.menushow = false;
item.total_num = 0
item.goods.forEach(goods => {
item.total_num += goods.total_num
})
})
return newList
},
// 获取当前标签项的值
getTabValue() {
return this.tabs[this.curTab].value
},
// 切换标签项
onChangeTab(index) {
const app = this
// 设置当前选中的标签
app.curTab = index
// 刷新订单列表
app.getOrderList()
},
// 刷新订单列表
onRefreshList() {
this.list = getEmptyPaginateObj()
setTimeout(() => {
this.mescroll.resetUpScroll()
}, 120)
},
// 取消订单
onCancel(orderId) {
const app = this
uni.showModal({
title: '友情提示',
content: '确认要取消该订单吗?',
success(o) {
if (o.confirm) {
OrderApi.cancel(orderId)
.then(result => {
// 显示成功信息
app.$toast(result.message)
// 刷新订单列表
app.onRefreshList()
})
}
}
});
},
handleCancel() {
app.deleteShow = false
},
onDelete(orderId) {
const app = this
uni.showModal({
title: '友情提示',
content: '删除之后订单无法恢复,无法处理您的售后问题 ,请慎重考虑,确认要删除该订单吗?',
success(o) {
if (o.confirm) {
OrderApi.del(orderId)
.then(result => {
// 显示成功信息
app.$toast(result.message)
// 刷新订单列表
app.onRefreshList()
})
}
}
});
},
// 删除订单
onDelete(orderId) {
const app = this
app.deleteShow = true
app.orderId = orderId
},
// 确认收货
onReceipt(orderId) {
const app = this
uni.showModal({
title: '友情提示',
content: '确认收到商品了吗?',
success(o) {
if (o.confirm) {
OrderApi.receipt(orderId)
.then(result => {
// 显示成功信息
app.$success(result.message)
// 刷新订单列表
app.onRefreshList()
})
}
}
});
},
// 获取核销二维码
onExtractQRCode(orderId) {
const app = this
OrderApi.extractQrcode(orderId, {
channel: app.platform
})
.then(result => {
app.qrcodeImage = result.data.qrcode
app.showQRCodePopup = true
})
},
// 跳转到订单评价页
handleTargetComment(orderId) {
this.$navTo('pages/order/comment/index', {
orderId
})
},
// 点击去开票
onInvoicing(orderId,order) {
uni.navigateTo({
url: '/pages/invoice/edit?orderId=' + orderId + '&source=' + 0 + "&order=" + JSON.stringify(order)
})
},
// 点击去退款
onRefund(orderId) {
this.$navTo('pages/order/refund/refund', {
orderId
})
},
// 申请售后
onSales(orderId) {
this.$navTo('pages/order/refund/index', {
orderId
})
},
// 点击去物流
onLogistics(orderId) {
this.$navTo('pages/order/express/index', {
orderId
})
},
// 点击去支付
onPay(orderId) {
this.$navTo('pages/checkout/cashier/index', {
orderId
})
},
// 跳转到订单详情页
goOrderDetail(orderId) {
this.$navTo('pages/order/detail', {
orderId
})
},
onCdDia(orderId) {
const app = this
OrderApi.orderfast(orderId)
.then(result => {
if (result.status == 200) {
this.cdDia = true
}
})
},
// 跳转到订单评价页
handleTargetComment(orderId) {
this.$navTo('pages/order/comment/index', {
orderId
})
}
},
}
11 months ago
</script>
<style lang="scss" scoped>
.order {
.search {
width: 750rpx;
height: 98rpx;
background: #FFFFFF;
padding: 20rpx 26rpx 20rpx 48rpx;
box-sizing: border-box;
.box {
padding: 15rpx 25rpx;
box-sizing: border-box;
display: flex;
align-items: center;
background: #F3F3F3;
border-radius: 60rpx;
image {
width: 28rpx;
height: 28rpx;
margin-right: 22rpx;
}
input {
flex: 1;
font-size: 28rpx;
line-height: 30rpx;
}
}
}
&-list {
padding: 0 30rpx 30rpx;
overflow: hidden;
.item {
background: #FFFFFF;
padding: 0 25rpx;
border-radius: 10rpx;
margin-top: 30rpx;
position: relative;
&:first-child {
margin-top: 0;
}
.menuarea {
width: 100%;
height: 100%;
}
.menulist {
background-color: #FFF;
border: 1rpx solid #F4F4F4;
width: 150rpx;
min-height: 50rpx;
position: absolute;
left: 0rpx;
bottom: 80rpx;
border-radius: 14rpx;
text-align: center;
padding: 10rpx 0;
}
.menulist view {
width: 100%;
height: 50rpx;
color: #333;
font-size: 24rpx;
font-family: PingFangSC-Medium, PingFang SC;
line-height: 50rpx;
}
.trangle {
width: 0px;
height: 0px;
position: absolute;
border: 10rpx solid #FFF;
border-top-color: #FFF;
border-bottom-color: transparent;
border-left-color: transparent;
border-right-color: transparent;
left: 16rpx;
bottom: 60rpx;
}
.hd {
padding: 24rpx 0;
display: flex;
align-items: center;
justify-content: space-between;
overflow: hidden;
.a {
display: flex;
align-items: center;
font-size: 32rpx;
font-weight: 500;
color: #333333;
padding-right: 30rpx;
position: relative;
word-break: break-all;
image {
width: 40rpx;
height: 40rpx;
margin-right: 24rpx;
}
&::after {
content: "";
width: 16rpx;
height: 16rpx;
border-top: 1px solid #818181;
border-left: 1px solid #818181;
position: absolute;
right: 0;
top: 14rpx;
z-index: 1;
transform: rotate(135deg);
}
}
.b {
font-size: 24rpx;
font-weight: 400;
color: #F21A1C;
}
}
.bd {
display: flex;
align-items: flex-start;
overflow: hidden;
margin-bottom: 30rpx;
.pic {
width: 145rpx;
height: 135rpx;
margin-right: 20rpx;
image {
width: 100%;
height: 100%;
border-radius: 10rpx;
}
}
.info {
flex: 1;
overflow: hidden;
.a {
text-align: left;
font-size: 28rpx;
font-weight: 400;
color: #1E1E1E;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
}
.b {
text {
font-size: 36rpx;
font-weight: 600;
}
font-size: 24rpx;
color: #F21A1C;
}
}
.num {
margin-left: 20rpx;
font-size: 28rpx;
font-weight: 500;
color: #1E1E1E;
}
}
.fd {
display: flex;
align-items: baseline;
justify-content: flex-end;
font-size: 24rpx;
font-weight: 500;
color: #1E1E1E;
text {
font-size: 36rpx;
}
}
.btn {
display: flex;
align-items: center;
justify-content: space-between;
padding: 30rpx 0;
overflow: hidden;
.a {
font-size: 28rpx;
font-weight: 400;
color: #A59E9E;
}
.b {
flex: 1;
display: flex;
align-items: center;
justify-content: flex-end;
overflow: hidden;
.n {
width: 148rpx;
line-height: 56rpx;
background: #FFFFFF;
border-radius: 56rpx;
opacity: 1;
border: 1px solid #DFDFDF;
margin-left: 6rpx;
text-align: center;
font-size: 24rpx;
font-weight: 400;
color: #1E1E1E;
&-1 {
border-color: #F21A1C;
color: #F21A1C;
}
}
}
}
}
}
&-modal {
padding: 50rpx;
position: relative;
.content {
font-size: 28rpx;
font-weight: 400;
line-height: 50rpx;
color: #4C4C4C;
}
.desc {
display: flex;
align-items: center;
font-size: 24rpx;
font-weight: 400;
color: #9F9F9F;
justify-content: center;
margin-top: 20rpx;
image {
width: 28rpx;
height: 28rpx;
margin-right: 20rpx;
}
}
}
}
.dia {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.7);
z-index: 99;
display: flex;
align-items: center;
justify-content: center;
.diaMain {
width: 560rpx;
height: 432rpx;
background: linear-gradient(180deg, #FFE4E4 0%, #FFFFFF 100%);
border-radius: 12rpx 12rpx 12rpx 12rpx;
opacity: 1;
position: relative;
.ld {
width: 100rpx;
height: 100rpx;
position: absolute;
top: -50rpx;
left: 230rpx;
}
.cdTitle {
width: 128rpx;
height: 44rpx;
font-size: 32rpx;
font-family: PingFang SC, PingFang SC;
font-weight: 500;
color: #000000;
line-height: 44rpx;
margin: 80rpx 0 0 216rpx;
}
.cdInfo {
width: 498rpx;
height: 120rpx;
font-size: 28rpx;
font-family: PingFang SC, PingFang SC;
font-weight: 400;
color: #727272;
line-height: 33rpx;
margin-left: 48rpx;
margin-top: 28rpx;
}
.iKnow {
width: 412rpx;
height: 72rpx;
background: #F55349;
border-radius: 8rpx 8rpx 8rpx 8rpx;
opacity: 1;
font-size: 28rpx;
font-family: PingFang SC, PingFang SC;
font-weight: 400;
color: #FFFFFF;
line-height: 72rpx;
margin: 36rpx 0 0 74rpx;
text-align: center;
}
}
}
11 months ago
</style>