Files

160 lines
3.6 KiB
Vue
Raw Permalink Normal View History

2023-10-11 11:27:47 +08:00
<template>
<uv-sticky
bgColor="#fff"
customNavHeight="0"
>
<uv-navbar
:fixed="false"
:title="title"
@leftClick="goUser"
/>
<uv-tabs
:list="navList"
@click="click"
lineColor="#f56c6c"
:current="actionType"
2023-11-17 20:55:32 +08:00
>
</uv-tabs>
</uv-sticky>
<view class="orderList">
<template v-if="!listEmpty">
<order
:data="item"
v-for="(item, index) in dataList"
:key="actionType + '_' + index"
@refresh="handleRefresh"
@pay="openPay"
@check-off-code="showCheckOffCode"
2023-11-17 20:55:32 +08:00
/>
</template>
<Empty
:iconSrc="emptyOrderIcon"
v-else
>
您还没有相关订单~
</Empty>
<!-- 加载中 -->
<ListLoadLoading v-if="loading" />
<!-- 加载完毕-->
<ListLoadOver v-if="loadend" />
2023-11-15 19:59:37 +08:00
<!-- 支付弹窗 -->
<PayPopup
ref="payPopupRef"
@confirm="paySuccess"
/>
<!-- 核销 -->
<CheckOffCode ref="checkOffCodeRef" />
<!-- 返回顶部 -->
<ReturnTop :scroll-top="scrollTop" />
</view>
2023-10-11 11:27:47 +08:00
</template>
<script setup>
import { computed, ref } from 'vue'
import { onLoad, onPageScroll, onShow } from '@dcloudio/uni-app'
2023-10-11 11:27:47 +08:00
import { orderList } from '@/api/order'
2023-11-14 17:21:03 +08:00
import { useRouter } from "@/hooks/useRouter";
2023-11-15 19:59:37 +08:00
import ListLoadOver from "@/components/ListLoadOver/index.vue"
import ListLoadLoading from "@/components/ListLoadLoading/index.vue"
2023-11-14 17:21:03 +08:00
import Empty from '@/components/Empty/index.vue'
2023-11-17 20:55:32 +08:00
import { emptyOrderIcon } from "@/utils/images";
2023-11-14 17:21:03 +08:00
import PayPopup from '@/components/PayPopup/index.vue'
import { usePage } from "@/hooks";
2023-11-17 20:55:32 +08:00
import ReturnTop from "@/components/ReturnTop/index.vue";
import { useScroll } from "@/hooks/useScroll";
import { usePay } from "@/hooks/usePay";
import CheckOffCode from "@/components/order/CheckOffCode.vue";
2023-11-14 17:21:03 +08:00
const {payPopupRef, openPay, paySuccess} = usePay()
2023-11-17 20:55:32 +08:00
const {scrollTop} = useScroll()
2023-11-14 17:21:03 +08:00
const {type, refresh, dataList, loadend, loading, listEmpty} = usePage(orderList)
const {getUrlParams, pushToTab, push} = useRouter()
2023-10-11 11:27:47 +08:00
const actionType = ref(0)
const navList = ref([
2023-11-14 17:21:03 +08:00
{name: "全部", value: -1,},
{name: "未支付", value: 0,},
{name: "待成团", value: 5,},
2023-11-14 17:21:03 +08:00
{name: "待发货", value: 1,},
{name: "待收货", value: 2,},
{name: "待评价", value: 3,},
{name: "已完成", value: 4,},
2023-10-11 11:27:47 +08:00
// { name: "退款中", value: 5, },
// { name: "已退款", value: 6, },
// { name: "退款", value: 7, },
])
2023-11-17 20:55:32 +08:00
const title = computed(() => {
const find = navList.value.find(item => item.value === type.value);
return find ? `${ find.name }订单` : '订单'
2023-11-15 19:59:37 +08:00
})
2023-10-11 11:27:47 +08:00
const handleRefresh = () => {
2023-11-14 17:21:03 +08:00
// 确认收货
if (actionType.value === 2) {
actionType.value++
type.value++
}
refresh()
2023-10-11 11:27:47 +08:00
}
const click = (data) => {
2023-11-14 17:21:03 +08:00
type.value = data.value
refresh()
}
function goUser() {
pushToTab({url: '/root/user/user'}, {})
2023-10-11 11:27:47 +08:00
}
// ============================= 核销相关 ==============================
const checkOffCodeRef = ref()
2023-11-14 17:21:03 +08:00
/**
* 打开核销码
* @param writeOffCode 核销码
*/
function showCheckOffCode(writeOffCode) {
checkOffCodeRef.value.open(writeOffCode)
2023-11-22 18:55:55 +08:00
}
2023-11-14 17:21:03 +08:00
onLoad(() => {
const params = getUrlParams()
2023-11-14 17:21:03 +08:00
type.value = params.type
if (Number(type.value < 0)) {
2023-10-11 11:27:47 +08:00
actionType.value = 0
2023-11-14 17:21:03 +08:00
return
2023-10-11 11:27:47 +08:00
}
actionType.value = navList.value.findIndex(item => item.value === params.type)
2023-10-11 11:27:47 +08:00
})
onShow(() => {
refresh()
2023-10-11 11:27:47 +08:00
})
// 返回该页面的获取数据
// uni.$on('update', function (data) {
// console.log('update')
// //触发更新后
// refresh()
// })
onPageScroll((e) => {
2023-11-17 20:55:32 +08:00
})
2023-10-11 11:27:47 +08:00
</script>
2023-11-14 17:21:03 +08:00
<style lang="scss">
2023-10-11 11:27:47 +08:00
.orderList {
padding: 20rpx 0;
}
</style>