Files
pj_mini_app_cloud/src/pages/tabbar/order.vue
T
2026-04-17 14:54:47 +08:00

170 lines
7.7 KiB
Vue

<script setup lang="ts">
import { ref, reactive, onMounted, nextTick } from "vue"
import { onLoad, onShow } from "@dcloudio/uni-app"
import { hooks, router } from "@@/index"
import { orderApi } from "@@/api"
import { filePath } from "@@/utils/file"
import { SERVICE_IMAGE } from "@@/constant/index"
import { useTabbarStore } from "@@/stores/tabbar"
import zTabs from "@@/components/other/z-tabs/z-tabs.vue"
import { getLaunchParam } from "@/sheep/utils/app"
const crudLayoutRef = ref<any>(null)
const tabbarStore = useTabbarStore()
const data = {
tabs: [
{ id: null, name: "全部", disabled: false },
{ id: 1, name: "未支付", disabled: false },
{ id: 5, name: "已支付", disabled: false },
{ id: 10, name: "售后", disabled: false },
{ id: 20, name: "已核销", disabled: false },
],
}
const state = reactive<any>({
pa: {
orderStatus: data.tabs[0].id,
},
})
onLoad(() => {
})
onShow(async () => {
const isLogin = await hooks.useCheckLogin()
if (!isLogin) return
if (pageRef.value) {
pageRef.value.reload(false)
}
})
onMounted(() => {
nextTick(() => {
crudLayoutRef.value?.checkVerifyDevice?.()
})
})
const doTab = (e: any) => {
const target = data.tabs[e]
state.pa.orderStatus = target.id
pageRef.value.reload(true)
}
const pageRef = ref<any>(null)
let orderPageApi: any = async () => []
const launchParam = tabbarStore.launchParam
if (!launchParam) {
orderPageApi = async () => []
} else if (launchParam === "canteen") {
orderPageApi = orderApi.caneenPage
} else if (["selfMerchant", "coopMerchant", "onlineShop"].includes(launchParam)) {
orderPageApi = orderApi.supPage
} else if (launchParam === "prosperityShop") {
orderPageApi = orderApi.farmerSpuPage
}
const pageHook = hooks.usePage(pageRef, orderPageApi, null, "data.records")
const query = (page: number, pagesize: number) => {
const isLogin = hooks.useStaticCheckLogin()
if (!isLogin) return
pageHook.startPage(page, pagesize, false, state.pa)
}
// 查看订单和核销码
const doToDetail = (v: any) => {
router.jump("/pages/order/detail", { id: v.id })
}
const doAppraise = () => { }
const doRefund = (v: any) => {
router.jump("/pages/refund/apply", { id: v.id })
}
</script>
<template>
<crud-layout title="订单" :bg="filePath(SERVICE_IMAGE.blueBg)" ref="crudLayoutRef">
<z-paging ref="pageRef" height="100%" :fixed="false" v-model="pageHook.list" :default-page-size="10"
safe-area-inset-bottom :loading-more-enabled="true" :show-scrollbar="false" @query="query"
:auto-clean-list-when-reload="false" :auto-scroll-to-top-when-reload="false" @scroll="pageHook.scroll">
<template #top>
<view class="bg-white rounded-16rpx px-20rpx my-20rpx">
<z-tabs :list="data.tabs" @change="doTab" />
</view>
</template>
<view class="flex-col justify-center card p-24rpx m-b-20rpx" v-for="(v, i) in pageHook.list" :key="i">
<view class="flex-row">
<image class="size-130rpx rounded-8rpx" :src="filePath(v.logoPic)" mode="aspectFill" />
<view class="flex-1 ml-20rpx">
<view class="flex-row items-center justify-between">
<view class="sub-text-30">{{ v.merchantName }}</view>
<!-- <view class="m-l-15rpx color-#999 font-size-26rpx! iconfont icon-youjiantou" /> -->
<tm-tag v-if="v.orderStatus == 1" color="info" size="s">未支付</tm-tag>
<tm-tag v-if="v.orderStatus == 5" color="success" size="s">已支付</tm-tag>
<tm-tag v-if="v.orderStatus == 10" color="error" size="s">售后</tm-tag>
<tm-tag v-if="v.orderStatus == 20" size="s">已核销</tm-tag>
<tm-tag v-if="v.orderStatus == 30" color="info" size="s">已取消(智能柜)</tm-tag>
</view>
<view class="flex-row items-center justify-between mt-5rpx second-text-24">
<view>
<text>下单时间</text>
<text class="ml-10rpx">{{ hooks.useTime(v.createTime, "{y}-{m}-{d} {h}:{i}:{s}")
}}</text>
</view>
<view>{{ hooks.useEnum("hardwareRefundStatusEnum", v.refundStatus) }}</view>
</view>
<view class="flex-row items-center justify-end mt-8rpx">
<text
v-if="v.carList?.length && ['5', '20'].includes(v.orderStatus) && ['1', '2'].includes(v.orderType)"
class="second-text-30 mr-16rpx">
共 {{ v.carList.length }} 件
</text>
<text class="main-text-30 color-red!">¥ {{ hooks.useMoney(v.totalPrice) }}</text>
</view>
</view>
</view>
<view v-if="['5', '20'].includes(v.orderStatus) && ['1', '2'].includes(v.orderType)">
<view class="border-b-2rpx border-dashed border-#eeeeee mt-16rpx"></view>
<tm-collapse>
<tm-collapse-item :name="i" title="详细购买" titleFontSize="28" activeColor="#000" titleHeight="80"
:showBottomLine="false">
<view v-if="v.carList.length" class="flex justify-between items-center mb-16rpx px-24rpx"
v-for="(pV, pI) in v.carList" :key="pI">
<view class="flex items-center w-6/10">
<view class="size-100rpx">
<image v-if="v.payType == '9'" class="size-100rpx rounded-8rpx"
:src="pV.productPic" mode="aspectFill" />
<image v-else class="size-100rpx rounded-8rpx" :src="filePath(pV.productPic)"
mode="aspectFill" />
</view>
<view class="ml-16rpx overflow-hidden">
<view class="sub-text-26 truncate">{{ pV.productName }}</view>
<view class="sub-text-26">¥ {{ hooks.useMoney(pV.productPrice) }}</view>
<view class="sub-text-26">x {{ pV.productCount }}</view>
</view>
</view>
<view class="sub-text-30 w-3/10">¥ {{ hooks.useMoney(pV.totalPrice) }}</view>
</view>
<view v-else class="second-text-26 text-center">无数据</view>
<view class="border-b-2rpx border-dashed border-#eeeeee mt-16rpx"></view>
</tm-collapse-item>
</tm-collapse>
</view>
<view v-if="['5', '10'].includes(v.orderStatus)"
class="w-full flex-row items-center justify-end my-8rpx">
<!-- <view v-if="v.orderStatus == 5 && v.orderType == 2" class="botder_btn" @tap.stop="doRefund(v)">退款</view> -->
<view v-if="v.orderStatus === '5' && ['2', '7'].includes(v.orderType)" class="m-l-20rpx botder_btn"
@tap.stop="doToDetail(v)">
核销码
</view>
</view>
</view>
</z-paging>
</crud-layout>
</template>