This commit is contained in:
zjf committed 2025-04-14 14:13:34 +08:00
commit b6fff4cb1c
14 files changed
+566 -576

No files matched your search

-4
View File
@@ -60,10 +60,6 @@
}
],
"subPackages": [
{
"root": "pages/order",
"pages": []
},
{
"root": "pages/shop",
"pages": [
@@ -1,78 +0,0 @@
<script setup lang="ts">
import { ref, reactive, withDefaults, defineProps, defineEmits } from "vue";
import { onLoad, onShow } from "@dcloudio/uni-app";
import { hooks, router } from "@@/index"
import { merchantApi } from "@@/api"
import ProductRow from './product-row.vue'
import ProductTotal from './product-total.vue'
import { filePath } from "@@/utils/file";
const emit = defineEmits(["update:modelValue", "submit", "doContainer", "add", "remove"])
export type Props = {
modelValue: any,
carList: any,
totPrice: number,
totCount: number,
}
const props = withDefaults(defineProps<Props>(), {
modelValue: false,
carList: [],
totPrice: 0,
totCount: 0,
});
const state = reactive<any>({
})
onLoad(() => {
});
onShow(() => {
})
const doClose = () => {
emit("update:modelValue")
}
const doPay = () => {
emit("submit")
}
const doContainer = () => {
emit("doContainer")
}
const getHeight = () => {
const { bottom } = uni.getSystemInfoSync().safeAreaInsets!;
return `-${bottom + 16}px`
}
</script>
<template>
<tm-drawer z-index="100" v-model:show="props.modelValue" showFooter title="购物车" position="bottom" size="60%"
@close="doClose">
<product-row v-for="(v, i) in props.carList" mode="car" :key="v.id" v-model="v.productCount" :pic="filePath(v.productPic)"
:count="v.productCount" :name="v.name" :price="v.productPrice" :marketPrice="v.marketPrice"
:salesCount="v.salesCount" :stock="v.stock" @add="() => emit('add', v)" @remove="emit('remove', v)" />
<template #footer>
<view class="car z-200 p-x-30rpx p-y-30rpx bg-white" :style="{ marginBottom: getHeight() }">
<product-total :totPrice="props.totPrice" :totCount="props.totCount" @submit="doPay"
@doContainer="doContainer" />
</view>
</template>
</tm-drawer>
</template>
<style lang="scss" scoped>
.car {
box-shadow: 0 8rpx 40rpx rgba(0, 0, 0, 0.1);
}
</style>
@@ -0,0 +1,62 @@
<script setup lang="ts">
import ProductRow from "./product-row.vue"
import ProductTotal from "./product-total.vue"
import { filePath } from "@@/utils/file"
const emit = defineEmits(["update:modelValue", "submit", "add", "remove"])
export type Props = {
modelValue: boolean
cartList: any
totPrice: number
totCount: number
}
const props = withDefaults(defineProps<Props>(), {
modelValue: false,
cartList: [],
totPrice: 0,
totCount: 0,
})
const doClose = () => {
emit("update:modelValue", false)
}
const doPay = () => {
emit("submit")
}
const getHeight = () => {
const { bottom } = uni.getSystemInfoSync().safeAreaInsets!
return `-${bottom + 16}px`
}
const add = (v) => emit("add", v)
const remove = (v) => emit("remove", v)
</script>
<template>
<tm-drawer z-index="100" v-model:show="props.modelValue" showFooter title="购物车" position="bottom" size="60%" @close="doClose">
<view v-for="(v, i) in props.cartList" :key="v.id">
<product-row
v-model="v.productCount"
mode="cart"
:pic="filePath(v.productPic)"
:count="v.productCount"
:name="v.productName"
:price="v.productPrice"
:marketPrice="v.marketPrice"
:salesCount="v.salesCount"
:stock="v.stock"
@add="add(v)"
@remove="remove(v)"
/>
</view>
<template #footer>
<view class="z-200 p-x-30rpx p-y-30rpx bg-white" :style="{ marginBottom: getHeight() }">
<product-total :totPrice="props.totPrice" :totCount="props.totCount" @submit="doPay" @doContainer="" />
</view>
</template>
</tm-drawer>
</template>
+17 -41
View File
@@ -1,28 +1,24 @@
<script setup lang="ts">
import { ref, reactive, withDefaults, defineProps, defineEmits } from "vue"
import { onLoad, onShow } from "@dcloudio/uni-app"
import { hooks, router } from "@@/index"
import { merchantApi } from "@@/api"
const emit = defineEmits(["update:modelValue", "add", "remove"])
export type Props = {
mode: "default" | "car"
productId: number | null
mode?: "default" | "cart"
modelValue: number
productId?: number | string | null
pic: string
name: string
price: any
price: string | number
marketPrice: number
salesCount: number
stock: number
count: number
count?: number
}
const props = withDefaults(defineProps<Props>(), {
mode: "default",
productId: null,
modelValue: 0,
productId: null,
pic: "",
name: "",
price: 0,
@@ -31,57 +27,43 @@ const props = withDefaults(defineProps<Props>(), {
stock: 0,
count: 0,
})
const state = reactive<any>({})
onLoad(() => {})
onShow(() => {})
// 点击加
const add = () => {
if (props.modelValue >= 99) {
emit("update:modelValue", 99)
return
}
// emit("update:modelValue", props.modelValue + 1)
// if (props.modelValue + 1 >= props.stock) return uni.showToast({ title: "库存不足", icon: "none" })
emit("update:modelValue", props.modelValue + 1)
emit("add")
}
// 点击减
const remove = () => {
if (props.modelValue < 0) {
emit("update:modelValue", 0)
return
}
// emit("update:modelValue", props.modelValue - 1)
if (props.modelValue - 1 < 0) return
emit("update:modelValue", props.modelValue - 1)
emit("remove")
}
</script>
<template>
<view
:class="[props.mode == 'car' ? 'car_border' : '']"
class="flex-row items-start card p-x-15rpx p-y-25rpx m-b-20rpx"
@tap="props.productId && router.jump('/pages/merchant/product-detail', { id: props.productId })"
>
<image v-if="props.mode == 'default'" class="size-180rpx rounded-12rpx" :src="props.pic" mode="aspectFill" />
<image v-if="props.mode == 'car'" class="size-120rpx rounded-12rpx" :src="props.pic" mode="aspectFill" />
<image v-if="props.mode == 'cart'" class="size-120rpx rounded-12rpx" :src="props.pic" mode="aspectFill" />
<view class="flex-1 m-l-20rpx">
<view class="sub-text-28 show-line">{{ props.name }}</view>
<view class="m-t-10rpx flex-row items-center">
<view class="second-text-32 color-red!"> ¥{{ hooks.useMoney(props.price) }} </view>
<view v-if="props.mode == 'default'" class="m-l-20rpx second-text-24 line-through">
¥{{ hooks.useMoney(props.marketPrice) }}
</view>
<view class="w-100rpx second-text-32 color-red!"> ¥{{ hooks.useMoney(props.price) }} </view>
<view v-if="props.mode == 'default'" class="m-l-20rpx second-text-24 line-through">¥{{ hooks.useMoney(props.marketPrice) }}</view>
<view v-if="props.mode == 'cart'" class="m-l-40rpx second-text-24">x{{ props.count }}</view>
</view>
<view v-if="props.mode == 'car'" class="m-t-10rpx second-text-28"> x{{ props.count }} </view>
<view v-if="props.mode == 'default'" class="flex-row items-center MT 10rpx">
<view class="second-text-24">{{ hooks.useFormatNum("库存", "", props.stock) }}</view>
<view class="w-1px h-20rpx m-x-5rpx bg-#999" />
<view class="w-1px h-20rpx m-x-5rpx bg-#999 mx-2" />
<view class="second-text-24">{{ hooks.useFormatNum("销量", "", props.salesCount) }}</view>
</view>
<view class="flex-row items-center justify-end m-t-20rpx">
<view
class="flex-row-center size-40rpx rounded-full border-1px border-solid border-color-#0094ff"
@tap.stop="remove"
>
<view class="flex-row-center size-40rpx rounded-full border-1px border-solid border-color-#0094ff" @tap.stop="remove">
<view class="iconfont icon-a--" />
</view>
<view class="sub-text-28 m-x-20rpx">{{ props.modelValue }}</view>
@@ -92,9 +74,3 @@ const remove = () => {
</view>
</view>
</template>
<style lang="scss" scoped>
.car_border {
border: 1px solid #f2f2f2;
}
</style>
+19 -41
View File
@@ -1,59 +1,37 @@
<script setup lang="ts">
import { ref, reactive, withDefaults, defineProps, defineEmits } from "vue";
import { onLoad, onShow } from "@dcloudio/uni-app";
import { hooks, router } from "@@/index"
import { merchantApi } from "@@/api"
import { hooks } from "@@/index"
const emit = defineEmits(["submit", "doContainer"])
export type Props = {
totPrice: number,
totCount: number,
totPrice: number
totCount: number
}
const props = withDefaults(defineProps<Props>(), {
totPrice: 0,
totCount: 0,
});
const state = reactive<any>({
})
onLoad(() => {
});
onShow(() => {
totPrice: 0,
totCount: 0,
})
const doPay = () => {
emit("submit")
emit("submit")
}
const doContainer = () => {
emit("doContainer")
emit("doContainer")
}
</script>
<template>
<view class="flex-row items-center justify-between" @tap="doContainer">
<view class="flex-row-center">
<view class="flex-row-center size-80rpx rounded-full bg-#0094ff">
<view class="color-white! iconfont icon-biaoqianlanicon_gouwuche-xuanzhong" />
</view>
<view class="flex-col m-l-30rpx">
<view class="second-text-36 color-#f63a36!">¥ {{ hooks.useMoney(props.totPrice) }}</view>
<view class="sub-text-28">共{{ props.totCount }}件</view>
</view>
</view>
<view class="bg-#0094ff p-x-30rpx p-y-20rpx text-center rounded-40rpx sub-text-30 color-white!"
@tap.stop="doPay">
购买
</view>
</view>
<view class="flex-row items-center justify-between" @tap="doContainer">
<view class="flex-row-center">
<view class="flex-row-center size-80rpx rounded-full bg-#0094ff">
<view class="color-white! iconfont icon-biaoqianlanicon_gouwuche-xuanzhong" />
</view>
<view class="flex-col m-l-30rpx">
<view class="second-text-36 color-#f63a36!">¥ {{ hooks.useMoney(props.totPrice) }}</view>
<view class="sub-text-28">共{{ props.totCount }}件</view>
</view>
</view>
<view class="bg-#0094ff p-x-30rpx p-y-20rpx text-center rounded-40rpx sub-text-30 color-white!" @tap.stop="doPay">购买</view>
</view>
</template>
<style lang="scss" scoped></style>
+110 -117
View File
@@ -7,21 +7,23 @@ import { merchantApi, foodApi, payApi } from "@@/api"
import { filePath } from "@@/utils/file"
import ProductRow from "./components/product-row.vue"
import ProductCar from "./components/product-car.vue"
import ProductCart from "./components/product-cart.vue"
import ProductTotal from "./components/product-total.vue"
const state = reactive<any>({
detailId: null,
canteenDetail: {},
foodList: [],
cartList: [],
totPrice: 0,
totCount: 0,
currentClassifyIndex: 0,
showCarDialog: false,
carList: [],
classifyList: [],
shopList: [],
currentClassifyIndex: 0,
showCartDialog: false,
})
onLoad((options: any) => {
@@ -31,10 +33,15 @@ onLoad((options: any) => {
})
onShow(() => {
getDetail()
getShopCar()
getFoodCart()
getClassify()
})
const getHeight = () => {
const rpx = 480
return `calc(100vh - ${uni.upx2px(rpx)}px)`
}
// 获取食堂详情信息
const getDetail = async () => {
uni.showLoading({ title: "加载中...", mask: true })
@@ -43,46 +50,46 @@ const getDetail = async () => {
uni.hideLoading()
}
const getShopCar = async () => {
// 获取购物车信息
const getFoodCart = async () => {
const { data } = await foodApi.getShopCar({ merchantId: state.detailId, hardType: "CANTEEN" })
state.carList = data ?? []
if (isEmpty(state.carList)) {
state.shopList.forEach((v: any) => {
state.cartList = data ?? []
if (isEmpty(state.cartList)) {
state.foodList.forEach((v: any) => {
v.productCount = 0
})
} else {
asyncCarCount(state.shopList)
syncCartCount(state.foodList)
}
state.totPrice = state.carList.map((v) => Number(v.totalPrice)).reduce((pre, next) => pre + next, 0)
state.totCount = state.carList.map((v) => v.productCount).reduce((pre, next) => pre + next, 0)
state.totPrice = state.cartList.map((v) => Number(v.totalPrice)).reduce((pre, next) => pre + next, 0)
state.totCount = state.cartList.map((v) => v.productCount).reduce((pre, next) => pre + next, 0)
}
const getClassify = async () => {
const _pa = { merchantId: state.detailId }
const { data } = await foodApi.classify(_pa)
state.classifyList = data
if (!isEmpty(state.classifyList)) {
getPorduct()
}
}
const updateShopCar = async () => {
if (isEmpty(state.carList)) return
const list = state.carList
.filter((v) => v.productCount !== undefined && v.productCount >= 0)
.map((v) => {
return {
productCount: v.productCount,
productId: v.productId,
// 同步购物车购买数量
const syncCartCount = (foodList: any) => {
if (state.cartList && state.cartList.length) {
for (const i of foodList) {
for (const v of state.cartList) {
if (i.id == v.productId) {
i.productCount = v.productCount
}
}
})
if (isEmpty(list)) return
const _pa = { merchantId: state.detailId, list: list, hardType: "CANTEEN" }
const { data, code }: any = await foodApi.updateShopCar(_pa)
if (code == 0) await getShopCar()
}
}
state.foodList = foodList
}
const getPorduct = async () => {
// 获取菜品分类
const getClassify = async () => {
const { data } = await foodApi.classify({ merchantId: state.detailId })
state.classifyList = data ?? []
if (!isEmpty(state.classifyList)) {
getFoodList()
}
}
// 获取食物列表
const getFoodList = async () => {
const target = state.classifyList[state.currentClassifyIndex]
if (isEmpty(target)) return
const _pa = {
@@ -94,51 +101,31 @@ const getPorduct = async () => {
i.productCount = 0
i.productId = i.id
})
asyncCarCount(data)
syncCartCount(data)
}
// 同步购买数量
const asyncCarCount = (shopList) => {
if (state.carList && state.carList.length) {
for (const i of shopList) {
for (const v of state.carList) {
if (i.id == v.productId) {
i.productCount = v.productCount
}
}
}
}
state.shopList = shopList
// 切换选中的分类
const doClassify = (i: any) => {
state.currentClassifyIndex = i
getClassify()
}
const doAdd = async (item: any) => {
chentProductCount(item, "add")
}
const remove = async (item: any) => {
chentProductCount(item, "remove")
}
const chentProductCount = async (item: any, type: "add" | "remove") => {
// 设置购物车商品的数量
const chentProductCartCount = async (item: any) => {
try {
uni.showLoading({ title: "加载中", mask: true })
let count = item.productCount
if (type === "add") {
count += 1
const { code }: any = await foodApi.checkSpuStock({ spuId: item.productId, incrCount: count })
if (code != 0) throw new Error()
} else if (type === "remove") {
count -= 1
}
const target = state.carList.find((v) => v.productId == item.productId)
const targetIndex = state.carList.findIndex((v) => v.productId == item.productId)
if (target) {
state.carList[targetIndex].productCount = count
// 检查商品库存
const { code }: any = await foodApi.checkSpuStock({ spuId: item.productId, incrCount: item.productCount })
if (code != 0) throw new Error()
const targetIndex = state.cartList.findIndex((v) => v.productId == item.productId)
if (targetIndex !== -1) {
state.cartList[targetIndex].productCount = item.productCount
} else {
state.carList.push({ ...item, productId: item.id, productCount: count })
state.cartList.push({ ...item, productId: item.id, productCount: item.productCount })
}
nextTick(async () => {
await updateShopCar()
await updateFoodCart()
})
} catch (e) {
console.error(e)
@@ -147,52 +134,57 @@ const chentProductCount = async (item: any, type: "add" | "remove") => {
}
}
const doClassify = (i: any) => {
state.currentClassifyIndex = i
getClassify()
// 保存购物车商品
const updateFoodCart = async () => {
if (isEmpty(state.cartList)) return
const list = state.cartList
.filter((v) => v.productCount !== undefined && v.productCount >= 0)
.map((v) => {
return {
productCount: v.productCount,
productId: v.productId,
}
})
if (isEmpty(list)) return
const _pa = { merchantId: state.detailId, list: list, hardType: "CANTEEN" }
const { data, code }: any = await foodApi.updateShopCar(_pa)
if (code == 0) await getFoodCart()
}
const doVisibleCar = async () => {
state.showCarDialog = true
}
// 打开购物车
const doVisibleCart = async () => (state.showCartDialog = true)
const submitPay = async () => {
try {
if (isEmpty(state.carList)) {
uni.showToast({ title: "请至少购买一件商品", icon: "none" })
return
}
uni.showLoading({ title: "支付中...", mask: false })
const _createtPa = {
carParentId: state.carList[0].parentCarId,
hardType: "CANTEEN",
}
const { data: createData, code: createCode }: any = await payApi.createHardwareOrder(_createtPa)
if (createCode != 0) throw new Error()
uni.hideLoading()
uni.showToast({ title: "支付成功", icon: "none" })
router.jump("/pages/tabbar/order")
} catch (error) {
console.error(error)
uni.hideLoading()
}
}
const doPay = async () => {
// 购买
const doBuy = async () => {
uni.showModal({
title: "提示",
content: "是否确定购买",
confirmColor: "#0094ff",
success: async (res) => {
if (!res.confirm) return
submitPay()
submitBuy()
},
})
}
const getHeight = () => {
const rpx = 480
return `calc(100vh - ${uni.upx2px(rpx)}px)`
// 确认购买
const submitBuy = async () => {
try {
if (isEmpty(state.cartList)) return uni.showToast({ title: "请至少购买一件商品", icon: "none" })
uni.showLoading({ title: "支付中...", mask: true })
const _createtPa = {
carParentId: state.cartList[0].parentCarId,
hardType: "CANTEEN",
}
const { data: createData, code: createCode }: any = await payApi.createHardwareOrder(_createtPa)
if (createCode != 0) throw new Error()
uni.showToast({ title: "支付成功", icon: "none" })
router.jump("/pages/tabbar/order")
} catch (error) {
console.error(error)
} finally {
uni.hideLoading()
}
}
const doPhone = () => {
@@ -202,6 +194,7 @@ const doPhone = () => {
}
hooks.useMakePhoneCall(state.canteenDetail.phone)
}
const doFood = () => {
router.jump("/pages/merchant/food", { merchantId: state.detailId })
}
@@ -307,11 +300,10 @@ const doFood = () => {
</view>
</view>
</scroll-view>
<scroll-view v-if="state.shopList.length > 0" scroll-y :style="{ height: getHeight() }" class="flex-1 p-b-20rpx">
<view v-for="(pV, pI) in state.shopList" :key="pI">
<scroll-view v-if="state.foodList.length > 0" scroll-y :style="{ height: getHeight() }" class="flex-1 p-b-20rpx">
<view v-for="(pV, pI) in state.foodList" :key="pI">
<view class="m-x-15rpx">
<product-row
:key="pV.id"
v-model="pV.productCount"
:productId="pV.id"
:pic="filePath(pV.picUrl)"
@@ -320,8 +312,8 @@ const doFood = () => {
:marketPrice="pV.marketPrice"
:salesCount="pV.salesCount"
:stock="pV.stock"
@add="doAdd(pV)"
@remove="remove(pV)"
@add="chentProductCartCount(pV)"
@remove="chentProductCartCount(pV)"
/>
</view>
</view>
@@ -332,18 +324,19 @@ const doFood = () => {
<!-- end 商品 end -->
<template #main-bottom>
<view v-if="state.classifyList.length > 0" class="car z-200 p-x-30rpx p-y-30rpx bg-white">
<product-total :totPrice="state.totPrice" :totCount="state.totCount" @doContainer="doVisibleCar" @submit="doPay" />
<product-total :totPrice="state.totPrice" :totCount="state.totCount" @doContainer="doVisibleCart" @submit="doBuy" />
</view>
</template>
</crud-layout>
<product-car
v-model="state.showCarDialog"
:carList="state.carList"
<product-cart
v-model="state.showCartDialog"
:cartList="state.cartList"
:totPrice="state.totPrice"
:totCount="state.totCount"
@add="doAdd"
@remove="remove"
@submit="doPay"
@add="(v) => chentProductCartCount(v)"
@remove="(v) => chentProductCartCount(v)"
@submit="doBuy"
/>
</template>
+3 -3
View File
@@ -61,7 +61,7 @@ const doCancelRefund = async () => {
const data = refundApi.cancel(_pa)
uni.hideLoading()
uni.showToast({ title: "取消成功", icon: "none" })
router.jump("/pages/tabbar/order", {}, 2)
router.jump("/pages/tabbar/individualOrder", {}, 2)
},
})
}
@@ -198,14 +198,14 @@ const doCancelRefund = async () => {
<view class="h-30rpx" />
<template #main-bottom>
<view
v-if="state.detail.orderStatus == 10 && state.refundDetail.status == 62"
v-if="state.detail.orderStatus == 10 && state.refundDetail.status == 10"
class="bg-#999 p-y-20rpx text-center rounded-40rpx m-x-30rpx m-y-30rpx sub-text-30 color-white!"
@tap="doCancelRefund"
>
取消申请
</view>
<view
v-else-if="state.refundDetail.status == 62"
v-else-if="state.refundDetail.status == 62 || state.refundDetail.status == 61"
class="bg-#999 p-y-20rpx text-center rounded-40rpx m-x-30rpx m-y-30rpx sub-text-30 color-white!"
@tap="router.jump('/pages/refund/apply', { id: state.detailId }, 2)"
>
+2 -1
View File
@@ -20,6 +20,7 @@ const state = reactive<any>({
shopCarList: [],
setting: {},
selectList: [],
header: "",
})
const uploadApplyPicUrls = ref<Array<Record<string, any> | string>>([]) // 补充凭证图片
const applyPicUrls = computed(() => uploadApplyPicUrls.value.map((item: any) => JSON.parse(item.response).data.url).join(","))
@@ -35,12 +36,12 @@ onLoad((options: any) => {
if (!isEmpty(options.id)) {
state.detailId = options.id
}
state.header = hooks.useDefaultHeader()
})
onShow(() => {
getDetail()
getSetting()
getShopCarList()
state.header = hooks.useDefaultHeader()
})
const getSetting = async () => {
+5 -17
View File
@@ -26,22 +26,10 @@
v-model:model-str="state.formatVal"
@confirm="datePickerConfirm"
format="YYYY-MM-DD"
:quickDate="[]"
:drawerSize="900"
>
<svg
t="1742280333491"
class="icon"
viewBox="0 0 1024 1024"
version="1.1"
xmlns="http://www.w3.org/2000/svg"
p-id="4288"
width="16"
height="14"
>
<path
d="M568.552727 954.181818a86.341818 86.341818 0 0 1-41.425454-10.472727l-114.269091-62.836364a86.574545 86.574545 0 0 1-44.916364-76.101818V442.181818a16.989091 16.989091 0 0 0-6.981818-13.730909L97.047273 218.298182 93.090909 214.807273A85.876364 85.876364 0 0 1 155.927273 69.818182h711.214545A86.574545 86.574545 0 0 1 930.909091 214.807273l-3.490909 3.490909-266.24 213.410909a17.454545 17.454545 0 0 0-6.050909 13.730909v422.4A86.341818 86.341818 0 0 1 568.552727 954.181818zM141.963636 166.632727l262.283637 209.454546A85.178182 85.178182 0 0 1 437.061818 442.181818v362.589091a17.92 17.92 0 0 0 8.610909 15.592727l114.269091 62.138182a17.687273 17.687273 0 0 0 17.687273 0 17.221818 17.221818 0 0 0 8.378182-15.36V445.44a85.876364 85.876364 0 0 1 31.883636-67.258182l263.214546-211.549091a17.687273 17.687273 0 0 0 1.62909-18.152727 17.454545 17.454545 0 0 0-15.592727-8.843636H155.927273a17.221818 17.221818 0 0 0-13.963637 27.694545zM920.669091 512h-188.974546a34.443636 34.443636 0 0 1 0-69.818182h188.974546a34.443636 34.443636 0 0 1 0 69.818182z m0 128.930909h-188.974546a34.443636 34.443636 0 0 1 0-69.818182h188.974546a34.443636 34.443636 0 0 1 0 69.818182z m0 128h-188.974546a34.443636 34.443636 0 0 1 0-69.818182h188.974546a34.443636 34.443636 0 0 1 0 69.818182z"
p-id="4289"
/>
</svg>
<image class="w-[30rpx] h-[30rpx]" src="@/static/page/filter.svg" />
<text class="ml-1 text-30">筛选</text>
</tm-between-time>
</view>
@@ -66,7 +54,7 @@
</view>
<view class="flex-1 flex items-center p-2 bg-white rounded-8rpx ml-2">
<text class="flex-1 text-sm text-center text-gray-600">流水次数</text>
<text class="flex-1 text-sm text-center text-gray-800">{{ v.totalPayCount }}</text>
<text class="flex-1 text-sm text-center text-gray-800">{{ v.totalPayCount || 0 }}</text>
</view>
</view>
<view class="flex justify-between mb-2">
@@ -76,7 +64,7 @@
</view>
<view class="flex-1 flex items-center p-2 bg-white rounded-8rpx ml-2">
<text class="flex-1 text-sm text-center text-gray-600">盈利次数</text>
<text class="flex-1 text-sm text-center text-green-500">{{ v.totalProfitCount }}</text>
<text class="flex-1 text-sm text-center text-green-500">{{ v.totalProfitCount || 0 }}</text>
</view>
</view>
<view class="flex justify-between mb-0">
+35 -5
View File
@@ -15,8 +15,20 @@
>
<template #top>
<view class="h-30rpx" />
<view class="bg-white rounded-16rpx px-20rpx">
<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>
@@ -59,9 +71,12 @@
</view>
</view>
</view>
<view v-if="v.orderStatus == '5' && v.orderType == '1'" class="h-50rpx mt-1 flex justify-end items-center">
<view class="botder_btn" @tap.stop="doIndividualRefund(v)">申请退款</view>
</view>
<div 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'" class="ml-1 botder_btn" @tap.stop="doIndividualRefund(v)">
申请退款
</view>
</div>
</view>
</z-paging>
@@ -218,7 +233,7 @@
</template>
<script setup lang="ts">
import { ref, reactive } from "vue"
import { ref, reactive, computed } from "vue"
import { onLoad, onShow } from "@dcloudio/uni-app"
import { hooks, router } from "@@/index"
import { filePath } from "@@/utils/file"
@@ -235,13 +250,17 @@ const tabs = [
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")
@@ -269,6 +288,12 @@ const query = (page: number, pagesize: number) => {
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
@@ -277,6 +302,11 @@ const resetState = () => {
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 })
+2 -2
View File
@@ -39,7 +39,7 @@
</template>
<script setup lang="ts">
import user from "@/sheep/api/user"
import { userApi } from "@/sheep/api"
import { ref } from "vue"
const userRole = ref("user")
@@ -55,7 +55,7 @@ const confirmRole = async () => {
}
if (userRole.value === "merchant") {
uni.showLoading({ title: "正在验证身份", mask: true })
const res = await user.isMerchant().finally(() => uni.hideLoading())
const res = await userApi.isMerchant().finally(() => uni.hideLoading())
if (res.code == 0) {
if (res.data) {
uni.setStorageSync("userRole", userRole.value)
+5 -2
View File
@@ -5,8 +5,11 @@ import isDevEnv from "../utils/isDevEnv"
export const useToken = () => {
const tokenKey = storageConstant.TOKEN
const tokenStorage = uni.getStorageSync(tokenKey)
if (!tokenStorage.access_token) return ""
return `Bearer ${tokenStorage.access_token}`
if (isDevEnv()) {
return tokenStorage?.access_token ? `Bearer ${tokenStorage.access_token}` : ""
}
return tokenStorage?.accessToken?.tokenValue ? `Bearer ${tokenStorage.accessToken.tokenValue}` : ""
}
export const useDefaultHeader = () => {
+15
View File
@@ -0,0 +1,15 @@
<svg
t="1742280333491"
class="icon"
viewBox="0 0 1024 1024"
version="1.1"
xmlns="http://www.w3.org/2000/svg"
p-id="4288"
width="16"
height="16"
>
<path
d="M568.552727 954.181818a86.341818 86.341818 0 0 1-41.425454-10.472727l-114.269091-62.836364a86.574545 86.574545 0 0 1-44.916364-76.101818V442.181818a16.989091 16.989091 0 0 0-6.981818-13.730909L97.047273 218.298182 93.090909 214.807273A85.876364 85.876364 0 0 1 155.927273 69.818182h711.214545A86.574545 86.574545 0 0 1 930.909091 214.807273l-3.490909 3.490909-266.24 213.410909a17.454545 17.454545 0 0 0-6.050909 13.730909v422.4A86.341818 86.341818 0 0 1 568.552727 954.181818zM141.963636 166.632727l262.283637 209.454546A85.178182 85.178182 0 0 1 437.061818 442.181818v362.589091a17.92 17.92 0 0 0 8.610909 15.592727l114.269091 62.138182a17.687273 17.687273 0 0 0 17.687273 0 17.221818 17.221818 0 0 0 8.378182-15.36V445.44a85.876364 85.876364 0 0 1 31.883636-67.258182l263.214546-211.549091a17.687273 17.687273 0 0 0 1.62909-18.152727 17.454545 17.454545 0 0 0-15.592727-8.843636H155.927273a17.221818 17.221818 0 0 0-13.963637 27.694545zM920.669091 512h-188.974546a34.443636 34.443636 0 0 1 0-69.818182h188.974546a34.443636 34.443636 0 0 1 0 69.818182z m0 128.930909h-188.974546a34.443636 34.443636 0 0 1 0-69.818182h188.974546a34.443636 34.443636 0 0 1 0 69.818182z m0 128h-188.974546a34.443636 34.443636 0 0 1 0-69.818182h188.974546a34.443636 34.443636 0 0 1 0 69.818182z"
p-id="4289"
/>
</svg>

After

Width:  |  Height:  |  Size: 1.5 KiB

@@ -1,6 +1,6 @@
<script lang="ts" setup>
import { ref, computed, onMounted, watch, type PropType, nextTick } from 'vue';
import tmPickerView from '../tm-picker-view/tm-picker-view.vue';
import { ref, computed, onMounted, watch, type PropType, nextTick } from "vue"
import tmPickerView from "../tm-picker-view/tm-picker-view.vue"
type TM_PICKER_X_ITEM = Record<string, any>
type TM_PICKER_ITEM_INFO = Record<string, any>
const pickerView = ref<InstanceType<typeof tmPickerView> | null>(null)
@@ -14,326 +14,352 @@ const pickerView = ref<InstanceType<typeof tmPickerView> | null>(null)
| --- | --- | --- | --- |
| ☑️| ☑️ | ☑️ | ☑️ | ☑️ | 1.0.0 |
*/
defineOptions({ name: 'TmPicker' });
defineOptions({ name: "TmPicker" })
const props = defineProps({
/**
* 数据
*/
list: {
type: Array as PropType<TM_PICKER_ITEM_INFO[]>,
default: (): TM_PICKER_ITEM_INFO[] => [] as TM_PICKER_ITEM_INFO[]
},
/**
* 当前选中项的id值
*/
modelValue: {
type: [Array<string | number>],
default: (): string[] => [] as string[]
},
/**
* 当前选中项的回显文本等同v-model:model-str
* 请不要更改此值,此值只对外输出显示。
* 如果空值,将内部首次递归渲染回显文本。如果你后台返回,就不会计算。
* 因此如果对性能有要求的请务必让后台在首次显示时先回显文本,
* 这样内部在第一次时不会递归计算回显文本,提高性能。
*/
modelStr: {
type: String,
default: ""
},
/**
* 当前打开的状态。
* 等同v-model:model-show
*/
modelShow: {
type: Boolean,
default: false
},
/**
* 顶部标题
*/
title: {
type: String,
default: "请选择"
},
/**
* 是否懒加载内部内容。
* 当前你的列表内容非常多,且影响打开的动画性能时,请务必
* 设置此项为true,以获得流畅视觉效果。如果选择数据较少没有必要打开
*/
lazyContent: {
type: Boolean,
default: false
},
/**
* 显示在顶部的单位名称
*/
cellUnits: {
type: Array as PropType<string[]>,
default: (): string[] => [] as string[]
},
/**
* 自定义标识id
*/
rangKey: {
type: String,
default: "id"
},
/**
* 自定义标识文本字段名
*/
rangText: {
type: String,
default: "title"
}
});
/**
* 数据
*/
list: {
type: Array as PropType<TM_PICKER_ITEM_INFO[]>,
default: (): TM_PICKER_ITEM_INFO[] => [] as TM_PICKER_ITEM_INFO[],
},
/**
* 当前选中项的id值
*/
modelValue: {
type: [Array<string | number>],
default: (): string[] => [] as string[],
},
/**
* 当前选中项的回显文本等同v-model:model-str
* 请不要更改此值,此值只对外输出显示。
* 如果空值,将内部首次递归渲染回显文本。如果你后台返回,就不会计算。
* 因此如果对性能有要求的请务必让后台在首次显示时先回显文本,
* 这样内部在第一次时不会递归计算回显文本,提高性能。
*/
modelStr: {
type: String,
default: "",
},
/**
* 当前打开的状态。
* 等同v-model:model-show
*/
modelShow: {
type: Boolean,
default: false,
},
/**
* 顶部标题
*/
title: {
type: String,
default: "请选择",
},
/**
* 是否懒加载内部内容。
* 当前你的列表内容非常多,且影响打开的动画性能时,请务必
* 设置此项为true,以获得流畅视觉效果。如果选择数据较少没有必要打开
*/
lazyContent: {
type: Boolean,
default: false,
},
/**
* 显示在顶部的单位名称
*/
cellUnits: {
type: Array as PropType<string[]>,
default: (): string[] => [] as string[],
},
/**
* 自定义标识id
*/
rangKey: {
type: String,
default: "id",
},
/**
* 自定义标识文本字段名
*/
rangText: {
type: String,
default: "title",
},
})
const emit = defineEmits([
/**
* 取消时触发
*/
'cancel',
/**
* 确认触发
* @param {string[]} ids 当前选中项的id值
*/
'confirm',
/**
* 滑动变换时触发
* @param {string[]} ids 当前选中项的id值
*/
'change',
/**
* 变量控制打开状态
* 等同v-model:model-show
*/
'update:modelShow',
/**
* 等同v-model:model-str
* 只对外输出当前回选区的选中项的文本,不要外部改变此值。
*/
'update:modelStr',
'update:modelValue'
]);
/**
* 取消时触发
*/
"cancel",
/**
* 确认触发
* @param {string[]} ids 当前选中项的id值
*/
"confirm",
/**
* 滑动变换时触发
* @param {string[]} ids 当前选中项的id值
*/
"change",
/**
* 变量控制打开状态
* 等同v-model:model-show
*/
"update:modelShow",
/**
* 等同v-model:model-str
* 只对外输出当前回选区的选中项的文本,不要外部改变此值。
*/
"update:modelStr",
"update:modelValue",
])
const show = ref(false);
const nowValue = ref<Array<string | number>>([]);
const modelStrValue = ref("");
const yanchiDuration = ref(false);
const show = ref(false)
const nowValue = ref<Array<string | number>>([])
const modelStrValue = ref("")
const yanchiDuration = ref(false)
const _list = computed(() => props.list.slice(0));
const _lazyContent = computed(() => props.lazyContent);
const _cellUnits = computed(() => props.cellUnits);
watch(() => props.modelValue, (newvalue: Array<string | number>) => {
if (newvalue.join('') == nowValue.value.join('')) return;
nowValue.value = newvalue.slice(0);
const _list = computed(() => props.list.slice(0))
const _lazyContent = computed(() => props.lazyContent)
const _cellUnits = computed(() => props.cellUnits)
watch(
() => props.modelValue,
(newvalue: Array<string | number>) => {
if (newvalue.join("") == nowValue.value.join("")) return
nowValue.value = newvalue.slice(0)
if (newvalue.length > 0 && _list.value.length > 0) {
const { strs } = getIndexsByids(props.modelValue);
emit('update:modelStr', strs.join(','));
modelStrValue.value = strs.join(',');
if (newvalue.length > 0 && _list.value.length > 0) {
const { strs } = getIndexsByids(props.modelValue)
emit("update:modelStr", strs.join(","))
modelStrValue.value = strs.join(",")
}
},
)
}
});
watch(() => props.modelShow, (newValue: boolean) => {
if (newValue == show.value) return;
show.value = newValue;
});
watch(
() => props.modelShow,
(newValue: boolean) => {
if (newValue == show.value) return
show.value = newValue
},
)
watch(_list, () => {
if (show.value) {
return;
}
if (_list.value.length == 0) {
emit('update:modelStr', '');
modelStrValue.value = '';
return;
}
if (_list.value.length > 0) {
onSetDefaultStr();
}
});
if (show.value) {
return
}
if (_list.value.length == 0) {
emit("update:modelStr", "")
modelStrValue.value = ""
return
}
if (_list.value.length > 0) {
onSetDefaultStr()
}
})
onMounted(() => {
nowValue.value = props.modelValue.slice(0);
yanchiDuration.value = _lazyContent.value ? false : true;
onSetDefaultStr();
});
nowValue.value = props.modelValue.slice(0)
yanchiDuration.value = _lazyContent.value ? false : true
onSetDefaultStr()
})
function onSetDefaultStr() {
if (props.modelStr == "" && _list.value.length > 0) {
const { strs } = getIndexsByids(props.modelValue)
if (props.modelStr == "" && _list.value.length > 0) {
const { strs } = getIndexsByids(props.modelValue);
emit('update:modelStr', strs.join(','));
modelStrValue.value = strs.join(',');
}
emit("update:modelStr", strs.join(","))
modelStrValue.value = strs.join(",")
}
}
function openShow() {
show.value = true;
emit('update:modelShow', true);
show.value = true
emit("update:modelShow", true)
}
function onClose() {
emit('update:modelShow', false);
nowValue.value = props.modelValue.slice(0);
if (_lazyContent.value) {
yanchiDuration.value = false;
}
emit("update:modelShow", false)
nowValue.value = props.modelValue.slice(0)
if (_lazyContent.value) {
yanchiDuration.value = false
}
}
function strChange(str: string) {
modelStrValue.value = str;
modelStrValue.value = str
}
function onOpen() {
yanchiDuration.value = true;
yanchiDuration.value = true
}
function mchange(ids: string[]) {
emit('change', ids.slice(0));
emit("change", ids.slice(0))
}
function onCancel() {
emit('cancel');
nowValue.value = props.modelValue.slice(0);
emit("cancel")
show.value = false
nowValue.value = props.modelValue.slice(0)
}
function onConfirm() {
let ids = nowValue.value.slice(0);
let str = [] as string[]
if (ids.length == 0) {
const temp = getNowCurrent();
ids = temp.ids
str = temp.strs
} else {
const temp = getIndexsByids(ids)
str = temp.strs
let ids = nowValue.value.slice(0)
let str = [] as string[]
if (ids.length == 0) {
const temp = getNowCurrent()
ids = temp.ids
str = temp.strs
} else {
const temp = getIndexsByids(ids)
str = temp.strs
}
}
nowValue.value = ids
modelStrValue.value = str.join(",")
emit("update:modelValue", ids)
emit("update:modelStr", modelStrValue.value)
emit("confirm", ids)
nowValue.value = ids;
modelStrValue.value = str.join(',');
emit('update:modelValue', ids);
emit('update:modelStr', modelStrValue.value);
emit('confirm', ids);
show.value = false
}
const getIndexsByids = (ids: Array<string | number>): { indexs: Array<number>, data: TM_PICKER_X_ITEM[][], strs: string[] } => {
let index = 0;
let val = ids.slice(0)
let indexs = [] as number[]
let data = [] as TM_PICKER_X_ITEM[][]
let strs = [] as string[]
const getIndexsByids = (ids: Array<string | number>): { indexs: Array<number>; data: TM_PICKER_X_ITEM[][]; strs: string[] } => {
let index = 0
let val = ids.slice(0)
let indexs = [] as number[]
let data = [] as TM_PICKER_X_ITEM[][]
let strs = [] as string[]
if (_list.value.length == 0 || ids.length == 0) return { indexs: [], data: [], strs: [] }
if (_list.value.length == 0 || ids.length == 0) return { indexs: [], data: [], strs: [] }
function getIndex(nodes: TM_PICKER_X_ITEM[]) {
if (val.length <= index || val.length == 0) return;
let id = val[index]
let sindex = 0
for (let i = 0; i < nodes.length; i++) {
let item = nodes[i]
if (item[props.rangKey] == id) {
sindex = i;
indexs.push(sindex)
data.push(nodes)
strs.push(item[props.rangText])
if (item?.children?.length > 0) {
index += 1
getIndex(item.children)
}
}
}
}
getIndex(_list.value)
return { indexs, data, strs }
function getIndex(nodes: TM_PICKER_X_ITEM[]) {
if (val.length <= index || val.length == 0) return
let id = val[index]
let sindex = 0
for (let i = 0; i < nodes.length; i++) {
let item = nodes[i]
if (item[props.rangKey] == id) {
sindex = i
indexs.push(sindex)
data.push(nodes)
strs.push(item[props.rangText])
if (item?.children?.length > 0) {
index += 1
getIndex(item.children)
}
}
}
}
getIndex(_list.value)
return { indexs, data, strs }
}
//根据索引返回ids
const getIdsByindexs = (indexs: number[]): { ids: Array<string | number>, data: TM_PICKER_X_ITEM[][], strs: string[] } => {
let ids = [] as string[]
let data = [] as TM_PICKER_X_ITEM[][]
let index = 0;
let val = indexs.slice(0)
let strs = [] as string[]
const getIdsByindexs = (indexs: number[]): { ids: Array<string | number>; data: TM_PICKER_X_ITEM[][]; strs: string[] } => {
let ids = [] as string[]
let data = [] as TM_PICKER_X_ITEM[][]
let index = 0
let val = indexs.slice(0)
let strs = [] as string[]
if (_list.value.length == 0 || indexs.length == 0) return { ids: [], data: [], strs: [] }
function getIds(nodes: TM_PICKER_X_ITEM[]) {
if (val.length <= index || val.length == 0) return;
let currentsIndex = val[index]
let id = ''
let str = ''
let children = [];
if (nodes.length - 1 >= currentsIndex) {
id = nodes[currentsIndex][props.rangKey]
str = nodes[currentsIndex][props.rangText]
children = nodes[currentsIndex]?.children ?? []
} else {
id = nodes[0][props.rangKey]
str = nodes[0][props.rangText]
children = nodes[0]?.children ?? []
}
ids.push(id)
data.push(nodes)
strs.push(str)
if (_list.value.length == 0 || indexs.length == 0) return { ids: [], data: [], strs: [] }
function getIds(nodes: TM_PICKER_X_ITEM[]) {
if (val.length <= index || val.length == 0) return
let currentsIndex = val[index]
let id = ""
let str = ""
let children = []
if (nodes.length - 1 >= currentsIndex) {
id = nodes[currentsIndex][props.rangKey]
str = nodes[currentsIndex][props.rangText]
children = nodes[currentsIndex]?.children ?? []
} else {
id = nodes[0][props.rangKey]
str = nodes[0][props.rangText]
children = nodes[0]?.children ?? []
}
ids.push(id)
data.push(nodes)
strs.push(str)
if (children.length > 0) {
index += 1
getIds(children)
}
}
getIds(_list.value)
return { ids, data, strs };
if (children.length > 0) {
index += 1
getIds(children)
}
}
getIds(_list.value)
return { ids, data, strs }
}
const _maxDeep = computed(() => {
if (_list.value.length == 0) return 0;
function getdiepWidth(list: TM_PICKER_X_ITEM[]): number {
let deepIndex = 1;
const node = list[0];
if (node?.children?.length > 0) {
deepIndex += getdiepWidth(node.children);
}
return deepIndex;
}
return getdiepWidth(_list.value.slice(0));
if (_list.value.length == 0) return 0
function getdiepWidth(list: TM_PICKER_X_ITEM[]): number {
let deepIndex = 1
const node = list[0]
if (node?.children?.length > 0) {
deepIndex += getdiepWidth(node.children)
}
return deepIndex
}
return getdiepWidth(_list.value.slice(0))
})
const getNowCurrent = () => {
nowValue.value = props.modelValue.slice(0)
let currneinexs = getIndexsByids(nowValue.value).indexs;
let dinexs = nowValue.value.length == 0 || currneinexs.length == 0 ? new Array(_maxDeep.value).fill(0) : currneinexs;
return getIdsByindexs(dinexs)
nowValue.value = props.modelValue.slice(0)
let currneinexs = getIndexsByids(nowValue.value).indexs
let dinexs = nowValue.value.length == 0 || currneinexs.length == 0 ? new Array(_maxDeep.value).fill(0) : currneinexs
return getIdsByindexs(dinexs)
}
</script>
<script lang="ts">
export default {
options: {
styleIsolation: "apply-shared",
virtualHost: true,
addGlobalClass: true,
multipleSlots: true,
},
};
options: {
styleIsolation: "apply-shared",
virtualHost: true,
addGlobalClass: true,
multipleSlots: true,
},
}
</script>
<template>
<view @click="openShow">
<!--
<view @click="openShow">
<!--
@slot 插槽,默认触发打开选择器。你的默认布局可以放置在这里。
@binding {boolean} show - 控制打开关闭状态
-->
<slot></slot>
</view>
<tm-drawer @open="onOpen" :widthCoverCenter="true" :disabledScroll="true" max-height="80%" size="850" :title="title"
@close="onClose" @confirm="onConfirm" @cancel="onCancel" :showFooter="true" v-model:show="show"
:show-close="true">
<tm-picker-view v-if="show" ref="pickerView" :rangKey="rangKey" :rangText="rangText" :cell-units="_cellUnits"
@update:modelStr="strChange" @change="mchange" v-model="nowValue" :list="_list"></tm-picker-view>
</tm-drawer>
<slot></slot>
</view>
<tm-drawer
@open="onOpen"
:widthCoverCenter="true"
:disabledScroll="true"
max-height="80%"
size="850"
:title="title"
@close="onClose"
:showFooter="true"
v-model:show="show"
:show-close="true"
>
<tm-picker-view
v-if="show"
ref="pickerView"
:rangKey="rangKey"
:rangText="rangText"
:cell-units="_cellUnits"
@update:modelStr="strChange"
@change="mchange"
v-model="nowValue"
:list="_list"
/>
<template #footer>
<view class="flex px-4">
<tm-button @click="onCancel" :block="true" skin="thin">取消</tm-button>
&nbsp;&nbsp;
<tm-button @click="onConfirm" :block="true">确定</tm-button>
</view>
</template>
</tm-drawer>
</template>
<style scoped></style>