This commit is contained in:
zjf committed 2025-10-09 09:54:19 +08:00
commit 091cb9d76c
11 files changed
+590 -40

No files matched your search

+5
View File
@@ -4,6 +4,7 @@
<meta charset="UTF-8" />
<script src="https://dapp.tmuyun.com/oss-static/app/jcommind.js"></script>
<script src="https://g.alicdn.com/gdt/jsapi/1.9.43/index.js"></script>
<!-- <script src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js"></script> -->
<script>
var coverSupport =
"CSS" in window && typeof CSS.supports === "function" && (CSS.supports("top: env(a)") || CSS.supports("top: constant(a)"))
@@ -20,5 +21,9 @@
<body>
<div id="app"><!--app-html--></div>
<script type="module" src="/src/main.ts"></script>
<!-- <script>
var vConsole = new VConsole()
console.log("console:", vConsole)
</script> -->
</body>
</html>
@@ -113,7 +113,7 @@
</view>
<view class="flex-col justify-center items-center">
<image src="@/static/page/order-select.png" class="w-50rpx h-50rpx" />
<view class="text-center text-24 c-#1977FD">邀约记录</view>
<view class="text-center text-24 c-#1977FD">访客记录</view>
</view>
</view>
</template>
@@ -163,8 +163,8 @@ const query = (page: number, pagesize: number) => {
pageHook.startPage(page, pagesize, false, state.params)
}
const onTabChange = (e: number) => {
state.params.type = e
const onTabChange = (index: number, value: number) => {
state.params.type = value
pageRef.value.reload(true)
}
+2 -2
View File
@@ -69,7 +69,7 @@
<tm-form-item name="isDrive" label="是否可驾驶车辆" direction="horizontal" labelWidth="500">
<tm-switch v-model="form.isDrive" />
</tm-form-item>
<tm-button class="mt-4" form-type="submit" block>提交</tm-button>
<tm-button class="mt-4" form-type="submit" block>提 交</tm-button>
</tm-form>
</tm-sheet>
@@ -112,7 +112,7 @@
</view>
<view class="flex-col justify-center items-center" @click="goInvitationRecord">
<image src="@/static/page/order.png" class="w-50rpx h-50rpx" />
<view class="text-center text-24 c-#999999">邀约记录</view>
<view class="text-center text-24 c-#999999">访客记录</view>
</view>
</view>
</template>
@@ -46,12 +46,12 @@
{ label: '下架', value: '1' },
]"
:key="index"
></tm-radio>
/>
</tm-radio-group>
</tm-form-item>
<view class="prefix_title mb-2">父级分类</view>
<view class="my-2">
<node-tree v-model="selectedNode" :node-data="categoryTree" />
<node-tree v-model="selectedNodeId" :node-data="categoryTree" />
</view>
<view class="prefix_title mb-2">分类图</view>
<tm-upload-photo
@@ -89,7 +89,7 @@ const form = reactive<any>({
picUrl: [],
})
const categoryTree = ref([])
const selectedNode = ref<any>({})
const selectedNodeId = ref<string>("")
const { categoryList, getGoodsCategory, delCategary } = useCategaryManage()
@@ -113,28 +113,28 @@ const addCategary = () => {
parentId: "",
picUrl: [],
})
selectedNode.value = {}
selectedNodeId.value = ""
categaryFormDrawer.value = true
}
// 编辑分类
const editCategary = (item) => {
getCategaryTree()
const picUrl = [{ path: filePath(item.picUrl), response: JSON.stringify({ data: { url: item.picUrl } }) }]
const picUrl = item.picUrl ? [{ path: filePath(item.picUrl), response: JSON.stringify({ data: { url: item.picUrl } }) }] : []
Object.assign(form, { ...item, picUrl })
selectedNode.value = { id: item.parentId }
selectedNodeId.value = item.parentId
categaryFormDrawer.value = true
}
// 提交保存
const saveCategary = async () => {
if (!form.name) return uni.showToast({ title: "请填写分类名称", icon: "none" })
if (selectedNode.value.id === form.id) return uni.showToast({ title: "父级分类不能是自己", icon: "none" })
if (selectedNodeId.value === form.id) return uni.showToast({ title: "父级分类不能是自己", icon: "none" })
try {
const params = {
...form,
parentId: selectedNode.value.id,
picUrl: JSON.parse(form.picUrl[0].response).data.url,
parentId: selectedNodeId.value,
picUrl: form.picUrl?.length ? JSON.parse(form.picUrl[0].response).data.url : "",
}
uni.showLoading({ title: "保存中..." })
const { code, msg } = await (form.id ? prosperityShopApi.editCategary(params) : prosperityShopApi.addCategary(params))
+1 -1
View File
@@ -80,7 +80,7 @@
</view>
</view>
<view class="fixed bottom-80rpx right-40rpx">
<view class="fixed bottom-120rpx right-40rpx">
<tm-button size="m" class="px-1 ml-1" @click="doWaterTotal">每月流水合计</tm-button>
</view>
</z-paging>
+4
View File
@@ -86,6 +86,10 @@ const jumpByParam = async () => {
uni.setStorageSync("launchParam", launchParam)
uni.switchTab({ url: "/pages/tabbar/integrated" })
break
case "prosperityShop": // 共富商城
uni.setStorageSync("launchParam", launchParam)
uni.switchTab({ url: "/pages/tabbar/prosperityShop" })
break
default:
uni.hideTabBar()
break
+99
View File
@@ -0,0 +1,99 @@
<script setup lang="ts">
import { ref, reactive } from "vue"
import { onLoad, onShow } from "@dcloudio/uni-app"
import { hooks, router } from "@@/index"
import { merchantApi } from "@@/api"
import { filePath } from "@@/utils/file"
const state = reactive<any>({
pa: {
pagesize: 10,
type: "1",
},
})
onLoad(() => {
const app = getApp()
app._initTabbar()
})
onShow(() => {
if (pageRef.value) {
pageRef.value.reload(false)
}
})
const pageRef = ref<any>(null)
const pageHook = hooks.usePage(pageRef, merchantApi.page, null, "data.records")
const query = (page: number, pagesize: number) => {
pageHook.startPage(page, pagesize, false, state.pa)
}
const toDetail = async (v: any) => {
const isLogin = await hooks.useCheckLogin()
if (isLogin) {
router.jump("/pages/canteen/detail", { id: v.id })
}
}
</script>
<template>
<crud-layout bg="/static/page/blue-bg.png">
<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"
>
<view class="h-20rpx" />
<tm-input placeholder="请输入关键字" leftIcon="search-2-line" />
<view class="h-20rpx" />
<view class="flex-row items-center justify-between mb-20rpx">
<view class="flex-row-center sub-text-28">附近店铺</view>
<view class="sub-text-22 color-#00a624!">
查看全部
</view>
</view>
<view class="flex-col card p-20rpx m-b-20rpx" v-for="(v, i) in pageHook.list" :key="i" @tap="toDetail(v)">
<image class="w-100% h-300rpx rounded-12rpx" :src="filePath(v.logoPic)" mode="aspectFill" />
<view class="flex-1 flex-col m-l-20rpx">
<view class="flex-row items-center justify-between mt-20rpx">
<view class="flex-row-center sub-text-34">{{ v.name }}</view>
<view>
<tm-tag size="s">{{ v.deptName }}</tm-tag>
</view>
</view>
<view class="flex-row-center m-t-5rpx justify-left mb-5rpx">
<tm-icon name="map-pin-2-line" color="#999"></tm-icon>
<view class="second-text-22 m-l-10rpx">
地址详情信息示意
</view>
</view>
<view class="second-text-24">
<view class="second-text-28">营业时间:</view>
<view>{{ v.jobTime?.split(",")[0] ? "早:" + v.jobTime?.split(",")[0] : "" }}</view>
<view>{{ v.jobTime?.split(",")[1] ? "中:" + v.jobTime?.split(",")[1] : "" }}</view>
<view>{{ v.jobTime?.split(",")[2] ? "晚:" + v.jobTime?.split(",")[2] : "" }}</view>
</view>
<view class="">
<tm-tag bgColor="#fff6e0" borderColor="#fff6e0"
fontColor="#FFBE4C" size="xs" class="mr-10rpx">折扣</tm-tag>
<tm-tag bgColor="#effefa" borderColor="#effefa" fontColor="#00a624" size="xs">送货</tm-tag>
</view>
<view v-if="v.addressDes" class="m-t-10rpx second-text-28">
<text>食堂地址</text>
<text class="m-l-10rpx">{{ v.addressDes }}</text>
</view>
</view>
</view>
</z-paging>
</crud-layout>
</template>
+435
View File
@@ -0,0 +1,435 @@
<template>
<crud-layout bg="/static/page/blue-bg.png">
<z-paging
ref="pageRef"
: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 v-if="false">
<view class="h-30rpx" />
<view class="flex justify-between items-center bg-white rounded-16rpx px-20rpx">
<z-tabs :list="tabs" @change="tabChange" />
<tm-between-time
start="2020-1-1"
end="2050-1-1"
v-model="state.date"
v-model:model-str="state.formatVal"
@confirm="datePickerConfirm"
format="YYYY-MM-DD"
:quickDate="[]"
drawerSize="900"
>
<view class="w-100rpx text-center second-text-28 text-30 mb-4rpx">筛选</view>
</tm-between-time>
</view>
</template>
<template #top>
<view>
<view class="h-20rpx" />
<tm-input placeholder="请输入关键字" leftIcon="search-2-line" />
<view class="h-20rpx" />
<tabSearch />
</view>
</template>
<view class="h-20rpx" />
<view class="flex-col justify-center card p-3 m-b-20rpx border-2rpx border-solid border-color-#eeeeee" v-for="(v, i) in pageHook.list" :key="i">
<view class="flex-row">
<image class="w-160rpx h-212rpx rounded-8rpx" :src="filePath(v.logoPic)" mode="aspectFill" />
<view class="flex-1 m-l-20rpx">
<view class="flex-row items-center justify-between">
<view class="flex-row items-center">
<view class="main-text-28">{{ v.merchantName }}</view>
<view v-if="false" class="m-l-15rpx color-#999 font-size-26rpx! iconfont icon-youjiantou" />
</view>
<template v-if="false">
<tm-tag v-if="v.orderStatus == 1" color="info" size="xs">未支付</tm-tag>
<tm-tag v-if="v.orderStatus == 5" color="success" size="xs">已支付</tm-tag>
<tm-tag v-if="v.orderStatus == 10" color="error" size="xs">售后</tm-tag>
<tm-tag v-if="v.orderStatus == 20" size="xs">已核销</tm-tag>
<tm-tag v-if="v.orderStatus == 30" color="info" size="xs">已取消(智能柜)</tm-tag>
</template>
</view>
<view class="flex-row-center m-t-10rpx justify-left">
<tm-icon name="map-pin-2-line" color="#999"></tm-icon>
<view class="second-text-22 m-l-10rpx">
地址详情信息示意
</view>
</view>
<view class="m-t-15rpx m-b-15rpx h-1rpx bg-#eeeeee "></view>
<view class="flex justify-between items-center m-b-10rpx" v-if="false">
<view class="second-text-22">
<text>{{ v.username }}</text>
<text class="m-l-10rpx">{{ v.userMobile }}</text>
</view>
<view class="second-text-22 h-30rpx">{{ hooks.useEnum("hardwareRefundStatusEnum", v.refundStatus) }}</view>
</view>
<view class="flex justify-between items-center m-b-10rpx">
<view class="second-text-22">
<text>商品</text>
</view>
<view class="second-text-22 color-#000! h-30rpx">3物品</view>
</view>
<view class="flex justify-between items-center m-b-10rpx">
<view class="second-text-22">
<text>日期</text>
</view>
<view class="second-text-22 color-#000! h-30rpx">{{ hooks.useTime(v.createTime, "{y}-{m}-{d} {h}:{i}:{s}") }}</view>
</view>
<view class="flex justify-between items-center" v-if="false">
<view class="second-text-22">
<text>下单时间</text>
<text class="m-l-10rpx">{{ hooks.useTime(v.createTime, "{y}-{m}-{d} {h}:{i}:{s}") }}</text>
</view>
<view class="main-text-30 color-red! min-w-140rpx text-right">¥ {{ hooks.useMoney(v.totalPrice) }}</view>
<!-- <view class="second-text-24">共 {{ v.carList.length }} 件</view> -->
</view>
<view v-if="v.payType == '9'" class="sub-text-24">{{ v.productDesc }}</view>
</view>
</view>
<view class="m-t-15rpx m-b-15rpx h-1rpx bg-#eeeeee "></view>
<view class="flex justify-between items-center m-b-10rpx">
<view class="second-text-22">
<tm-tag v-if="v.orderStatus == 1" color="info" size="xs">未支付</tm-tag>
<tm-tag v-if="v.orderStatus == 5" color="success" size="xs">已支付</tm-tag>
<tm-tag v-if="v.orderStatus == 10" color="error" size="xs">售后</tm-tag>
<tm-tag v-if="v.orderStatus == 20" size="xs">已核销</tm-tag>
<tm-tag v-if="v.orderStatus == 30" color="info" size="xs">已取消(智能柜)</tm-tag>
</view>
<view class="main-text-30 color-red! min-w-140rpx text-right">¥ {{ hooks.useMoney(v.totalPrice) }}</view>
</view>
<view class="flex justify-end items-center mt-1">
<view v-if="v.orderType == '1' && v.refundStatus" class="ml-1 botder_btn" @tap.stop="refundDetail(v)">售后详情</view>
<view
v-if="v.orderStatus == '5' && v.orderType == '1' && v.payType != '9'"
class="ml-1 botder_btn"
@tap.stop="doIndividualRefund(v)"
>
申请退款
</view>
</view>
</view>
</z-paging>
<tm-drawer title="退款" :showClose="true" size="90%" placement="bottom" bgColor="#EBF6FF" v-model:show="state.showDrawer" zIndex="999">
<view class="bg-white rounded-16rpx px-10rpx m-b-10rpx animate-both">
<z-tabs
:list="['同意退款', '拒绝退款']"
bar-width="300"
bar-height="0"
:active-style="{
width: '300rpx',
height: '70rpx',
backgroundColor: '#0779FDdd',
color: '#000000',
textAlign: 'center',
lineHeight: '70rpx',
fontWeight: 'bold',
fontSize: '30rpx',
borderRadius: '10rpx',
marginTop: '10rpx',
}"
:inactive-style="{
width: '300rpx',
height: '70rpx',
color: '#000000',
textAlign: 'center',
lineHeight: '70rpx',
fontWeight: 'bold',
fontSize: '30rpx',
borderRadius: '10rpx',
marginTop: '10rpx',
}"
@change="refundTabChange"
/>
</view>
<view class="flex-col justify-center card p-x-15rpx p-y-25rpx m-b-10rpx">
<view class="flex-row items-center">
<image class="w-100rpx h-100rpx rounded-8rpx" :src="filePath(state.curOrder.logoPic)" mode="aspectFill" />
<view class="flex-1 flex-col m-l-20rpx">
<view class="flex-row items-center justify-between">
<view class="flex-row items-center">
<view class="main-text-28">{{ state.curOrder.merchantName }}</view>
<view v-if="false" class="m-l-15rpx color-#999 font-size-26rpx! iconfont icon-youjiantou" />
</view>
<tm-tag v-if="state.curOrder.orderStatus == 1" color="info" size="xs">未支付</tm-tag>
<tm-tag v-if="state.curOrder.orderStatus == 5" color="success" size="xs">已支付</tm-tag>
<tm-tag v-if="state.curOrder.orderStatus == 10" color="error" size="xs">售后</tm-tag>
<tm-tag v-if="state.curOrder.orderStatus == 20" size="xs">已核销</tm-tag>
</view>
<view class="flex justify-between items-center">
<view class="flex flex-col">
<view class="second-text-20">
<text>{{ state.curOrder.username }}</text>
<text class="m-l-10rpx">{{ state.curOrder.userMobile }}</text>
</view>
<view class="second-text-20">
<text>下单时间</text>
<text class="m-l-10rpx">
{{ hooks.useTime(state.curOrder.createTime, "{y}-{m}-{d} {h}:{i}:{s}") }}
</text>
</view>
</view>
<view class="flex flex-col items-end justify-center m-t-5rpx">
<view class="second-text-22">{{ hooks.useEnum("hardwareRefundStatusEnum", state.curOrder.refundStatus) }}</view>
<view class="flex">
<view v-if="state.curOrder.carList?.length" class="m-t-4rpx m-r-10rpx second-text-26">
共 {{ state.curOrder.carList.length }} 件
</view>
<view class="main-text-30 color-red!">¥ {{ hooks.useMoney(state.curOrder.totalPrice) }}</view>
</view>
</view>
</view>
</view>
</view>
</view>
<view class="flex-col justify-center card p-x-20rpx p-y-30rpx m-b-10rpx">
<view class="flex-row items-center justify-between">
<view class="sub-text-28">实付款</view>
<view class="flex-row items-end">
<view class="sub-text-28">¥</view>
<view class="m-l-5rpx sub-text-28">{{ hooks.useMoney(state.curOrder.payPrice) }}</view>
</view>
</view>
</view>
<view class="flex-row items-center justify-between card p-x-20rpx p-y-30rpx m-b-10rpx">
<view class="sub-text-28">退款金额</view>
<view class="sub-text-28 color-red!">¥{{ hooks.useMoney(state.curOrder.payPrice) }}</view>
</view>
<view class="card p-x-20rpx p-y-30rpx space-y-10rpx m-b-10rpx second-text-24">
<view class="flex-row items-center">
<view>服务单号:</view>
<view>{{ state.refundDetail.no }}</view>
</view>
<view class="flex-row items-center">
<view>申请时间:</view>
<view>{{ hooks.useTime(state.refundDetail.createTime, "") }}</view>
</view>
<view class="flex-row items-center">
<view>售后类型:</view>
<view>{{ state.refundDetail.applyReason }}</view>
</view>
<view class="flex-row items-center">
<view>相关描述:</view>
<view>{{ state.refundDetail.applyDescription }}</view>
</view>
</view>
<view v-if="state.refundDetail.status == 62" class="card p-x-20rpx p-y-30rpx space-y-10rpx m-b-10rpx second-text-24">
<view class="flex-row items-center">
<view>审核人:</view>
<view>{{ state.refundDetail.auditUsername }}</view>
</view>
<view class="flex-row items-center">
<view>审核时间:</view>
<view>{{ hooks.useTime(state.refundDetail.auditTime, "") }}</view>
</view>
<view class="flex-row items-center">
<view>拒绝原因:</view>
<view>{{ state.refundDetail.auditReason }}</view>
</view>
</view>
<view v-if="state.refundScene === 1" class="flex-col justify-center card p-x-20rpx p-y-30rpx m-b-10rpx">
<view class="sub-text-28">拒绝原因</view>
<view class="m-t-20rpx">
<tm-input v-model="state.remark" type="textarea" :showClear="false" placeholder="请描述拒绝原因" />
</view>
</view>
<view v-else class="h-270rpx" />
<view class="flex">
<tm-modal
v-if="state.refundScene === 0"
style="flex: 1"
height="250"
title="确定同意退款吗?"
:show-footer="true"
@confirm="doAgreeRefund()"
>
<template v-slot:trigger><tm-button block>同意退款</tm-button></template>
</tm-modal>
<tm-modal
v-if="state.refundScene === 1"
style="flex: 1"
height="250"
title="确定拒绝退款吗?"
:show-footer="true"
@confirm="doRefuseRefund()"
>
<template v-slot:trigger><tm-button block color="danger">拒绝退款</tm-button></template>
</tm-modal>
</view>
</tm-drawer>
</crud-layout>
</template>
<script setup lang="ts">
import { ref, reactive, computed } from "vue"
import { onLoad, onShow } from "@dcloudio/uni-app"
import { hooks, router } from "@@/index"
import { filePath } from "@@/utils/file"
import zTabs from "@@/components/other/z-tabs/z-tabs.vue"
import { individualOrderApi, refundApi } from "@@/api";
import tabSearch from "./tabSearch.vue"
const pageRef = ref<any>(null)
// 选项卡
const tabs = [
{ id: null, name: "全部", disabled: false },
{ id: 5, name: "已支付", disabled: false },
{ id: 10, name: "售后", disabled: false },
]
const state = reactive<any>({
pa: {
orderStatus: tabs[0].id,
createTimeList: [],
},
showDrawer: false,
refundScene: 0,
curOrder: {},
refundDetail: {},
remark: "",
date: [],
formatVal: "",
})
const formatVal = computed(() => (state.date.length === 2 ? state.formatVal : ""))
const pageHook = hooks.usePage(pageRef, individualOrderApi.page, null, "data.records")
onLoad(() => {
const app = getApp()
app._initTabbar()
})
onShow(() => {
const isLogin = hooks.useCheckLogin()
if (!isLogin) return
if (pageRef.value) {
pageRef.value.reload(false)
}
})
// 切换选项卡
const tabChange = (e: number) => {
state.pa.orderStatus = tabs[e].id
pageRef.value.reload(true)
}
const query = (page: number, pagesize: number) => {
// const isLogin = hooks.useStaticCheckLogin()
// if (!isLogin) return
pageHook.startPage(page, pagesize, false, state.pa)
}
// 时间范围选择器确认
const datePickerConfirm = (date: any) => {
state.pa.createTimeList = formatVal.value.split("~")
pageRef.value.reload(false)
}
// 重置状态
const resetState = () => {
state.refundScene = 0
state.curOrder = {}
state.refundDetail = {}
state.remark = ""
}
// 点击售后详情
const refundDetail = (v: any) => {
router.jump("/pages/order/detail", { id: v.id })
}
// 点击退款
const doIndividualRefund = async (v: any) => {
return router.jump("/pages/refund/apply", { id: v.id })
if (!v.id) return uni.showToast({ title: "订单id不存在", icon: "none" })
resetState()
state.curOrder = v
state.showDrawer = true
uni.showLoading({ title: "加载中...", mask: true })
try {
const res: any = await refundApi.get({ id: v.id })
if (res.code == 0) {
state.refundDetail = res.data
} else {
uni.showToast({ title: res.msg || "加载退款详情失败", icon: "none" })
}
} catch (error) {
uni.showToast({ title: "错误", icon: "none" })
} finally {
uni.hideLoading()
}
}
// 退款切换选项卡
const refundTabChange = (e: number) => {
state.refundScene = e
}
// 同意退款
const doAgreeRefund = async () => {
if (!state.refundDetail.id) {
return uni.showToast({ title: "订单不存在", icon: "none" })
}
uni.showLoading({ title: "操作中...", mask: true })
try {
const res: any = await individualOrderApi.agreeRefund({ id: state.refundDetail.id })
if (res.code == 0) {
uni.showToast({ title: "操作成功", icon: "success" })
state.showDrawer = false
pageRef.value.reload(true)
} else {
uni.showToast({ title: res.msg || "退款失败", icon: "none" })
}
} catch (error) {
uni.showToast({ title: "错误", icon: "none" })
} finally {
uni.hideLoading()
}
}
// 拒绝退款
const doRefuseRefund = async () => {
if (!state.refundDetail.id) {
return uni.showToast({ title: "订单不存在", icon: "none" })
}
uni.showLoading({ title: "操作中...", mask: true })
try {
const res: any = await individualOrderApi.refuseRefund({ id: state.refundDetail.id, auditReason: state.remark })
if (res.code == 0) {
uni.showToast({ title: "操作成功", icon: "success" })
state.showDrawer = false
pageRef.value.reload(true)
} else {
uni.showToast({ title: res.msg || "拒绝退款失败", icon: "none" })
}
} catch (error) {
uni.showToast({ title: "错误", icon: "none" })
} finally {
uni.hideLoading()
}
}
</script>
+18 -8
View File
@@ -3,7 +3,7 @@
<view v-for="item in nodeData" :key="item.id">
<view
class="tree-item"
:style="item.id == selectedNode.id ? { borderColor: '#1879ff' } : { color: '#000' }"
:style="item.id == selectedNodeId ? { borderColor: '#1879ff' } : { color: '#000' }"
@click.stop="toCurrentNode(item)"
>
<image class="tree-item-icon" :src="filePath(item.picUrl)" />
@@ -11,10 +11,10 @@
</view>
<node-tree
v-model="selectedNode"
v-model="selectedNodeId"
v-if="item.children && item.children.length"
:node-data="item.children"
:style="{ marginLeft: `${getLevel(item.level) * 60}rpx` }"
:style="{ marginLeft: `${getLevel() * 60}rpx` }"
@currentNode="(v) => emit('currentNode', v)"
/>
</view>
@@ -22,19 +22,29 @@
</template>
<script setup lang="ts">
import { getCurrentInstance } from "vue"
import { filePath } from "../utils/file"
import NodeTree from "./node-tree.vue"
withDefaults(defineProps<{ nodeData: any[] }>(), { nodeData: () => [] })
const emit = defineEmits(["currentNode"])
const selectedNode = defineModel<any>("modelValue")
const selectedNodeId = defineModel<any>("modelValue")
defineOptions({ name: "node-tree-item" })
const compInstance = getCurrentInstance()
const toCurrentNode = (item) => {
emit("currentNode", item)
selectedNode.value = item
emit("currentNode", { ...item, level: getLevel() })
selectedNodeId.value = item.id
}
const getLevel = (level) => {
const getLevel = () => {
let level = 1
let $parent = compInstance?.parent
while ($parent && $parent.proxy?.$options.name === "node-tree-item") {
level++
$parent = $parent.parent
}
return level
}
</script>
@@ -44,7 +54,7 @@ const getLevel = (level) => {
overflow: hidden;
}
.tree-item {
border: 4rpx solid #e4e7ed77;
border: 4rpx solid #e4e7ed;
margin-bottom: 16rpx;
display: flex;
align-items: center;
@@ -1,6 +1,6 @@
<template>
<view class="mb-20rpx">
<node-tree v-model="selectedNode" :node-data="categoryTree" />
<node-tree :node-data="categoryTree" @currentNode="currentNode" />
<view v-if="categoryTree.length === 0" class="text-center text-#888 py-40rpx">暂无数据</view>
</view>
<view class="px-20rpx py-2 flex justify-between sticky bottom-0 bg-white">
@@ -24,10 +24,14 @@ const emit = defineEmits(["confirm", "cancel"])
const selectedNode = ref<any>({})
const currentNode = (currentNode) => {
selectedNode.value = currentNode
}
function onConfirm() {
if (!selectedNode.value) {
return uni.showToast({ title: "请选择分类", icon: "none" })
}
emit("confirm", { ...selectedNode, categoryId: selectedNode.value.id, categoryName: selectedNode.value.name })
emit("confirm", { categoryId: selectedNode.value.id, categoryName: selectedNode.value.name })
}
</script>
+8 -15
View File
@@ -12,14 +12,16 @@
</view>
</view>
<view class="day-time-point-list">
<button
:class="selectedTimePointIndex == index ? 'active' : ''"
<tm-button
class="day-time-button"
size="m"
:color="selectedTimePointIndex == index ? '' : 'info'"
v-for="(item, index) in dayTimePointList"
:key="index"
@click="selectTimePoint(item, index)"
>
{{ item.slice(0, 5) }}
</button>
</tm-button>
</view>
<view class="px-20rpx py-2 flex justify-between">
<tm-button skin="thin" block @click="emit('cancel')">取消</tm-button>
@@ -101,6 +103,7 @@ function onConfirm() {
border-radius: 12rpx;
text-align: center;
white-space: nowrap;
transition: all 0.1s linear;
}
.date-time-range .active {
background: #0779fd;
@@ -113,17 +116,7 @@ function onConfirm() {
gap: 10rpx;
margin-bottom: 20rpx;
}
.day-time-point-list button {
flex: 1 0 calc(100vw / 9);
padding: 6rpx;
border: none;
background: #eeeeee;
border-radius: 12rpx;
font-size: 26rpx;
cursor: pointer;
}
.day-time-point-list .active {
background-color: #0779fd;
color: white;
.day-time-button {
flex: 1 0 calc(100vw / 4);
}
</style>