pull/3/head
张宇 2 years ago
parent 931e2e043f
commit 7eff39995c

@ -0,0 +1,68 @@
import {
request
} from "@/utils/request";
export default {
list(data) {
return request({
url: "/shop/shopGoods/goodsList",
method: "POST",
data,
});
},
goodsEditAttribute(data) {
return request({
url: "/shop/shopGoods/goodsEditAttribute",
method: "POST",
data,
});
},
classify: {
list(data) {
return request({
url: "/shop/shopClassify/list",
method: "POST",
data,
});
},
createItem(data) {
return request({
url: "/shop/shopClassify/createItem",
method: "POST",
data,
});
},
},
freightRules(data) {
return request({
url: "/shop/freightRules/list",
method: "POST",
data,
});
},
goodsItem(data) {
return request({
url: "/shop/shopGoods/goodsItem",
method: "POST",
data,
});
},
goodsEdit(data) {
return request({
url: "/shop/shopGoods/goodsEdit",
method: "POST",
data,
});
},
};

@ -0,0 +1,50 @@
import {
request
} from "@/utils/request";
export default {
dataCount: {
oneLine(data) {
return request({
url: "/shop/dataCount/oneLine",
method: "POST",
data,
});
},
orderProfit(data) {
return request({
url: "/shop/dataCount/orderProfit",
method: "POST",
data,
});
},
orderGood(data) {
return request({
url: "/shop/dataCount/orderGood",
method: "POST",
data,
});
},
},
getStoreSetting(data) {
return request({
url: "/shop/store/getStoreSetting",
method: "POST",
data,
})
},
setStoreSetting(data) {
return request({
url: "/shop/store/setStoreSetting",
method: "POST",
data,
})
}
};

@ -0,0 +1,106 @@
import {
request
} from "@/utils/request";
export default {
orderList(data) {
return request({
url: "/shop/order/orderList",
method: "POST",
data,
});
},
orderSend(data) {
return request({
url: "/shop/order/orderSend",
method: "POST",
data,
});
},
GetExpressList(data) {
return request({
url: "/admin/order/GetExpressList",
method: "POST",
data,
});
},
printOrder(data) {
return request({
url: "/shop/order/printOrder",
method: "POST",
data,
});
},
updateNotes(data) {
return request({
url: "/shop/order/updateNotes",
method: "POST",
data,
});
},
// 核销记录
checkLog(data) {
return request({
url: "/shop/shop/checkLog",
method: "POST",
data,
});
},
confirmCancel(data) {
return request({
url: "/shop/order/confirmCancel",
method: "POST",
data,
});
},
after_sale: {
index(data) {
return request({
url: "/shop/after_sale/index",
method: "POST",
data,
});
},
update(data) {
return request({
url: "/shop/after_sale/update",
method: "POST",
data,
});
},
show(data) {
return request({
url: "/shop/after_sale/show",
method: "POST",
data,
});
},
express(data) {
return request({
url: "/client/common/express",
method: "POST",
data,
});
},
enums(data) {
return request({
url: "/client/after_sale/enums",
method: "POST",
data,
});
},
},
};

@ -0,0 +1,41 @@
import {
request
} from "@/utils/request";
export default {
list(data) {
return request({
url: "/shop/shop/List",
method: "POST",
data,
})
},
edit(data) {
return request({
url: "/shop/shop/edit",
method: "POST",
data,
})
},
editStatus(data) {
return request({
url: "/shop/shop/editStatus",
method: "POST",
data,
})
},
synchronousGoods(data) {
return request({
url: "/shop/shop/synchronousGoods",
method: "POST",
data,
})
},
};

@ -0,0 +1,51 @@
import {
request
} from "@/utils/request";
export default {
userList(data) {
return request({
url: "/shop/user/userList",
method: "GET",
data,
})
},
userItem(data) {
return request({
url: "/shop/user/userItem",
method: "GET",
data,
})
},
getLog(data) {
return request({
url: "/shop/user/getLog",
method: "GET",
data,
})
},
changeInformation(data) {
return request({
url: "/shop/user/changeInformation",
method: "GET",
data,
})
},
UpdateLevel(data) {
return request({
url: "/shop/user/UpdateLevel",
method: "GET",
data,
})
},
};

@ -0,0 +1,56 @@
import {
request
} from "@/utils/request";
export default {
LevelShow(data) {
return request({
url: "/shop/UserMembers/LevelShow",
method: "GET",
data,
})
},
LevelSave(data) {
return request({
url: "/shop/UserMembers/LevelSave",
method: "GET",
data,
})
},
SetList(data) {
return request({
url: "/shop/UserMembers/SetList",
method: "GET",
data,
})
},
SetSave(data) {
return request({
url: "/shop/UserMembers/SetSave",
method: "GET",
data,
})
},
DiscountList(data) {
return request({
url: "/shop/UserMembers/DiscountList",
method: "GET",
data,
})
},
CreateDiscount(data) {
return request({
url: "/shop/UserMembers/CreateDiscount",
method: "POST",
data,
})
},
};

@ -101,6 +101,26 @@ export default {
});
},
},
OrderInpersonPayment: {
orderList(data) {
return request({
url: "/admin/OrderInpersonPayment/orderList",
method: "POST",
data,
});
},
GetQrItem(data) {
return request({
url: "/admin/OrderInpersonPayment/GetQrItem",
method: "POST",
data,
});
},
}
};

@ -0,0 +1,88 @@
<template>
<view class="charts-box bg-white content p-2">
<view v-if="parent.id" class="p-4 mb-2 bg-slate-50">
上级分类 ({{ parent.name }})
</view>
<wd-form ref="form" :model="baseForm">
<wd-cell-group class="flex py-2 w-full" title="分类图片">
<view class="ml-3">
<yUpload v-model="baseForm.pic_url" :size="1"></yUpload>
</view>
</wd-cell-group>
<wd-form-item label-width="76px" label="分类名称" prop="address">
<wd-input v-model="baseForm.name" placeholder="请输入分类名称" clearable />
</wd-form-item>
<wd-form-item label-width="80px" label="分类排序" prop="address">
<view class="ml-3 flex">
<wd-input-number v-model="baseForm.sort" />
</view>
</wd-form-item>
<wd-form-item label-width="80px" label="状态" prop="address">
<view class="ml-3 flex">
<wd-switch v-model="baseForm.status" :active-value="1" :inactive-value="0" />
</view>
</wd-form-item>
<view class="footer m-4">
<wd-button @click="saveCat" type="primary" size="large" block>保存</wd-button>
</view>
</wd-form>
</view>
</template>
<script setup>
import { ref } from 'vue'
import goods from '@/api/mall/goods.js'
import yUpload from "@/components/yUpload/index.vue"
import {
onLoad,
} from "@dcloudio/uni-app";
const parent = ref({})
const model = ref({})
const baseForm = ref({})
onLoad(async (e) => {
if (e.parent) {
parent.value = JSON.parse(e.parent)
}
if (e.edit) {
baseForm.value = JSON.parse(e.edit)
}
})
const saveCat = () => {
goods.classify.createItem({
parent_id: parent.value.id || baseForm.value.id || 0,
...baseForm.value
}).then(res => {
if (res.code == 0) {
uni.showToast({
title: '操作成功!',
icon: 'success'
})
uni.navigateBack()
}
})
}
</script>
<style scoped>
/* 请根据实际需求修改父元素尺寸,组件自动识别宽高 */
.charts-box {
width: 100%;
height: 300px;
}
</style>

@ -0,0 +1,130 @@
<template>
<view class="charts-box bg-white content">
<view v-show="classifyList.length" class="flex overflow-auto flex-wrap">
<div class="grid grid-cols-3 gap-4 p-4 w-full">
<wd-button @click="utils.toUrl('/mall/cat/edit?edit=' + JSON.stringify({}))" style="width: 100%;"
class="bg-[#f0f0f0] w-full flex-1" :round="false">
新增
</wd-button>
<wd-button @click="showActions(cat)" style="width: 100%;" v-for="cat of classifyList"
class="bg-[#f0f0f0] w-full flex-1" type="info" :round="false">
{{ cat.name }}
</wd-button>
</div>
</view>
<wd-action-sheet v-model="show" :actions="actions" @close="close" @select="select" />
<kevyloading v-if="loading" type="bsm-loader" color="#618af8" transparent></kevyloading>
</view>
</template>
<script setup>
import { ref } from 'vue'
import utils from '@/utils/utils.js'
import goods from '@/api/mall/goods.js'
import kevyloading from "@/components/kevy-loading/kevy-loading";
/** @type {Ref<boolean>} */
const loading = ref(false);
import {
onShow,
} from "@dcloudio/uni-app";
const model = ref({})
const baseForm = ref({})
const show = ref(false)
const actions = ref([
{
name: '编辑分类'
},
{
name: '新增子项'
}
])
const opt = ref("编辑分类")
function showActions(row) {
show.value = true
model.value = row
console.log(row);
}
function close() {
show.value = false
}
function select({ item, index }) {
opt.value = item.name
if (opt.value == '编辑分类') {
// message.alert({
// title: ""
// })
baseForm.value = model.value
utils.toUrl('/mall/cat/edit?edit=' + JSON.stringify(baseForm.value))
}
if (opt.value == '新增子项') {
console.log(model.value);
if (model.value.parentIds.length == 3) {
return uni.showToast({
title: '三级分类不可新增子级',
icon: 'none'
})
} else {
baseForm.value = model.value
utils.toUrl('/mall/cat/edit?edit=' + JSON.stringify({}) + "&parent=" + JSON.stringify(baseForm.value))
}
// baseForm.value = model.value
// utils.toUrl('/mall/cat/edit?edit=' + JSON.stringify(baseForm.value))
}
}
const classifyList = ref([])
const getClassify = () => {
loading.value = true
function flattenCategories(categories, parentIds = []) {
let flatCategories = [];
for (const category of categories) {
const categoryWithParents = {
...category,
parentIds: [...parentIds, category.id],
};
flatCategories.push(categoryWithParents);
if (category.children && category.children.length > 0) {
flatCategories = flatCategories.concat(flattenCategories(category.children, [...parentIds, category.id]));
}
}
return flatCategories;
}
goods.classify.list().then(res => {
classifyList.value = flattenCategories(res.data)
loading.value = false
})
}
onShow(() => {
getClassify()
})
</script>
<style scoped>
/* 请根据实际需求修改父元素尺寸,组件自动识别宽高 */
.charts-box {
width: 100%;
height: 300px;
}
</style>

@ -0,0 +1,174 @@
<template>
<view class="content">
<kevyloading v-if="loading" type="bsm-loader" color="#618af8" transparent></kevyloading>
<view class=" bg-white sticky top-0 z-50">
<wd-search @search="search({ value: params.keywords })" @clear="() => { search({ value: '' }) }"
v-model="params.keywords" hide-cancel>
<template #prefix>
<view class="search-type">
<text>门店名称</text>
</view>
</template>
</wd-search>
</view>
<div class="grid p-2">
<yList height="90vh" ref="yListRef" :apiObj="orderApi.checkLog" :params="{ ...params }">
<template #default="{ list: orderList }">
<div v-for="order of orderList" class="rounded-md overflow-hidden">
<wd-card class="rounded-md overflow-hidden" type="rectangle">
<template #title>
<view class="title">
<view>{{ order.shop?.name || '--' }}</view>
<view class="text-end">
<view @click="utils.copy(order.order_no, '核销编号复制成功')" class="title-tip" v-if="order.order_no">
核销编号: {{ order.order_no }}
<wd-icon name="file-copy" size="14px"></wd-icon>
</view>
<view @click="utils.copy(order.check_code, '核销编码复制成功')" class="title-tip" v-if="order.check_code">
核销编码: {{ order.check_code }}
<wd-icon name="file-copy" size="14px"></wd-icon>
</view>
</view>
</view>
</template>
<view v-show="!order.new_certificates.length">
--
</view>
<view v-for="i in order.new_certificates" style="" class="orderBox my-2">
<image mode="aspectFill" :src="i.goods.pic_url" :alt="order.name"
style="min-width: 60px;width: 60px;;height: 60px;border-radius: 4px; margin-right: 12px;" />
<view>
<view class="line2" style="color: rgba(0,0,0,0.85); font-size: 24rpx;">{{ i.goods.name }}</view>
<div class="num flex">
<div class="mr-4">数量{{ i.num }}</div>
<div>金额{{ i.original_amount }}</div>
</div>
</view>
</view>
<template #footer>
<view class="bg-gray-50 p-2 mb-2.5 flex justify-between" style="font-size: 22rpx;">
<view class="flex text-wrap">核销码<view @click="utils.copy(order.qr_code, '核销码复制成功')">点我复制</view>
</view>
<view>核销时间{{ order.create_time }} </view>
</view>
<view class="flex justify-between items-center">
<view>
核销平台{{ ["自提核销", "抖音商品券", "抖音金额券",
"支付宝团购"][order.type] }}
</view>
<view>
核销方式
<wd-tag class="py-2" :type="['success', 'primary'][order.check_origin]">{{ ["pos机核销",
"手机端核销"][order.check_origin]
}}</wd-tag>
</view>
</view>
</template>
</wd-card>
</div>
</template>
</yList>
</div>
<wd-toast />
<wd-message-box></wd-message-box>
</view>
</template>
<script setup>
import { ref } from 'vue';
import utils from '@/utils/utils.js';
import orderApi from '@/api/mall/order.js';
import kevyloading from "@/components/kevy-loading/kevy-loading";
import yList from "/components/yList/index.vue";
const yListRef = ref(null);
const search = ({ value } = {}) => {
yListRef.value.upData({
keywords: value,
});
};
const params = ref({
nickname: "",
mobile: "",
origin: '',
value: ''
});
/**
* @type {Ref<boolean>}
* 控制页面加载状态的 Ref
*/
const loading = ref(false);
</script>
<style lang="scss" scoped>
.search-type {
position: relative;
height: 30px;
line-height: 30px;
padding: 0 8px 0 16px;
font-size: 24rpx;
color: rgba(0, 0, 0, .45);
}
.search-type::after {
position: absolute;
content: '';
width: 1px;
right: 0;
top: 5px;
bottom: 5px;
background: rgba(0, 0, 0, 0.25);
}
.search-type {
:deep(.icon-arrow) {
display: inline-block;
font-size: 20px;
vertical-align: middle;
}
}
.orderBox,
.title {
display: flex;
flex-direction: row;
justify-content: flex-start;
align-items: center;
}
.orderBox {
justify-content: flex-start;
}
.title {
justify-content: space-between;
}
.title-tip {
color: rgba(0, 0, 0, 0.25);
font-size: 12px;
}
</style>

@ -0,0 +1,78 @@
<template>
<view class="charts-box">
<qiun-data-charts type="bar" :opts="opts" :chartData="barData" />
</view>
</template>
<script>
export default {
props: {
barData: {
type: Object,
default: () => ({})
}
},
data() {
return {
chartData: {},
// config-ucharts.js ['bar'] opts opts
opts: {
color: ["#8eabfb", "#8eabfb", "#FAC858", "#EE6666", "#73C0DE", "#3CA272", "#FC8452", "#9A60B4", "#ea7ccc"],
padding: [15, 30, 0, 5],
enableScroll: false,
legend: {},
xAxis: {
boundaryGap: "justify",
disableGrid: false,
min: 0,
axisLine: false,
max: 70
},
yAxis: {},
extra: {
bar: {
linearType: "custom",
barBorderCircle: true,
type: "group",
width: 30,
meterBorde: 1,
meterFillColor: "#FFFFFF",
activeBgColor: "#000000",
activeBgOpacity: 0.08,
categoryGap: 2
}
}
}
};
},
created() {
// this.getServerData();
},
methods: {
getServerData() {
//
setTimeout(() => {
//
let res = {
categories: ["2018", "2019", "2020", "2021", "2022", "2023"],
series: [
{
name: "目标值",
data: [35, 36, 31, 33, 13, 34]
},
]
};
this.chartData = JSON.parse(JSON.stringify(res));
}, 100);
},
}
};
</script>
<style scoped>
/* 请根据实际需求修改父元素尺寸,组件自动识别宽高 */
.charts-box {
width: 100%;
height: 300px;
}
</style>

@ -0,0 +1,26 @@
<template>
<view class="myTabbar">
<wd-tabbar custom-class="mb-3" fixed safeAreaInsetBottom placeholder v-model="tab" shape="round">
<wd-tabbar-item @click="utils.toUrl('/store/index/index')" name="home" title="首页" icon="home"></wd-tabbar-item>
<!-- <wd-tabbar-item name="cart" title="分类" icon="cart"></wd-tabbar-item> -->
<wd-tabbar-item name="user" @click="utils.toUrl('/store/user/list')" title="用户管理" icon="user"></wd-tabbar-item>
<wd-tabbar-item @click="utils.toUrl('/store/shop/list')" name="shop" title="门店管理" icon="detection"></wd-tabbar-item>
<!-- <wd-tabbar-item name="user" title="我的" icon="user"></wd-tabbar-item> -->
</wd-tabbar>
</view>
</template>
<script setup>
import utils from '@/utils/utils.js';
const props = defineProps({
tab: {
type: String,
default: "home"
}
})
const tab = props.tab
</script>
<style lang="scss"></style>

@ -0,0 +1,374 @@
<template>
<view class="skuEdit">
<wd-table rowHeight="100" :data="Pdata.use_sku == 0
? skuDefault
: skuLibrary
" :stripe="false">
<wd-table-col prop="name" label="SKU">
<template #value="scope">
<view class="custom-class">
<span style="margin-right: 4px" v-for="(item, index) of scope.row
.attr_list" :key="index">
{{ item.name }}
</span>
</view>
</template>
</wd-table-col>
<wd-table-col prop="school" label="售价">
<template #value="scope">
<view class="px-2 pb-1 bg-white">
<wd-input placeholder="售价" v-model="scope.row.price" type="number" />
</view>
</template>
</wd-table-col>
<wd-table-col prop="major" label="原价">
<template #value="scope">
<view class="px-2 pb-1 bg-white">
<wd-input placeholder="原价" v-model="scope.row.original_price" type="number">
</wd-input>
</view>
</template>
</wd-table-col>
<wd-table-col prop="major" label="库存">
<template #value="scope">
<view class="px-2 pb-1 bg-white">
<wd-input placeholder="库存" v-model="scope.row.stock" type="number">
</wd-input>
</view>
</template>
</wd-table-col>
<wd-table-col prop="major" label="产品号">
<template #value="scope">
<view class="px-2 pb-1 bg-white">
<wd-input placeholder="产品号" v-model="scope.row.no">
</wd-input>
</view>
</template>
</wd-table-col>
<wd-table-col prop="major" label="产品图">
<template #value="scope">
<view class="overflow-hidden w-full h-full flex items-center justify-center">
<view class="px-2 pb-1 bg-white flex items-center justify-center mt-4 overflow-hidden">
<yUpload v-model="scope.row.pic_url"></yUpload>
</view>
</view>
</template>
</wd-table-col>
</wd-table>
<view v-show="Pdata.use_sku == 1" class="bg-gray-100 rounded mb-2">
<div class="p-2 bg-white w-full">
<div class="name mb-2 text-xs">规格设置</div>
<view class="flex bg-white px-3 py-1 rounded w-full">
<div class="flex-1 mr-4">
<wd-input type="text" v-model="addGroupData.name" />
</div>
<wd-button @click="addSkuGroup"></wd-button>
</view>
</div>
<div class="p-2 bg-white">
<div style="display: flex; flex-flow: column; align-items: flex-start;">
<div class="name mb-2 text-xs">规格组</div>
<div class="w-full bg-gray-100 p-2" v-for="(item, index) in skuGroup" :key="index">
<div class="flex items-center justify-between w-full bg-white p-2">
<div class="mr-3">
<wd-tag type="primary" custom-class="space" closable @close="moveGroup(index)">{{
item.name }}</wd-tag>
</div>
<div class="mr-3">
<wd-input type="text" v-model="addGouppItemData[index]" />
</div>
<wd-button type="warning" @click="addGroupItem(index)"></wd-button>
</div>
<div type="flex" style="margin: 12px 0;">
<div class="name mb-2 text-xs">规格:</div>
<view class="flex gap-2 flex-wrap">
<wd-tag custom-class="space1" closable round type="warning" class="mx-1"
v-for="(value, key) in item.groupItem" :key="key" style="margin-left: 10px"
@close="removeGroupItem(index, key)">{{ value.name
}}</wd-tag>
</view>
</div>
</div>
</div>
</div>
</view>
</view>
</template>
<script>
import yUpload from "@/components/yUpload/index.vue"
import { useToast } from '@/uni_modules/wot-design-uni'
const toast = useToast()
export default {
name: "skuEdit",
props: {
Pdata: {
type: Object,
default: () => ({})
},
},
components: {
yUpload
},
data() {
return {
// sku
skuDefault: [
{
attr_list: [{ group_name: "默认", name: "默认" }],
price: "", //
original_price: "", //
stock: "", //
pic_url: "", //
no: "", //
},
],
skuGroup: [],
addGroupData: {
name: "",
groupItem: [],
}, //
addGouppItemData: [],
skuLibrary: [], //
//
all_price: "",
all_original_price: "",
all_stock: "",
all_no: "",
// sku
}
},
created() {
this.skuDefault = this.Pdata.skuDefault.length ? this.Pdata.skuDefault : this.skuDefault
this.skuLibrary = this.Pdata.skuLibrary
this.skuGroup = this.Pdata.skuGroup
},
methods: {
successImage($event, index) {
console.log($event, index);
},
/**
* 处理规格数据
*/
setGoodsAttrItem(attrGroup, attrList, index) {
var attrList1 = [];
if (index < attrGroup.length) {
if (index === 0 || attrList.length === 0) {
if (attrGroup[index].groupItem.length > 0) {
attrGroup[index].groupItem.forEach((element) => {
element.group_name = attrGroup[index].name;
attrList1.push([element]);
});
}
} else {
if (attrGroup[index].groupItem.length > 0) {
attrList.forEach((element) => {
attrGroup[index].groupItem.forEach((element1) => {
element1.group_name = attrGroup[index].name;
attrList1.push(element.concat([element1]));
});
});
} else {
attrList1 = attrList;
}
}
++index;
return this.setGoodsAttrItem(attrGroup, attrList1, index);
} else {
return attrList;
}
},
/**
* 获取其他详细数据
*/
getAttrDataInfo(attr) {
var attrList = [];
attr.forEach((element) => {
var setAttr = {};
if (this.skuLibrary) {
this.skuLibrary.forEach((element2) => {
if (element2.attr_list.length === element.length) {
var loading = true;
if (
loading &&
this.compareAttr(element2.attr_list, element)
) {
setAttr = element2;
loading = false;
}
}
});
}
var data = {
id: setAttr && setAttr.id ? setAttr.id : 0,
attr_list: element,
price: setAttr && setAttr.price ? setAttr.price : element.reduce((price, i) => price + i.price, 0).toFixed(2),
original_price:
setAttr && setAttr.original_price
? setAttr.original_price
: element.reduce((price, i) => price + i.price, 0).toFixed(2),
stock: setAttr && setAttr.stock ? setAttr.stock : 0,
pic_url: setAttr && setAttr.pic_url ? setAttr.pic_url : "",
no: setAttr && setAttr.no ? setAttr.no : "",
};
for (const key in setAttr) {
if (key.indexOf("member") !== -1) {
data[key] = setAttr[key];
}
}
attrList.push(data);
});
return attrList;
},
compareAttr(val1, val2) {
var compareLen = 0;
val1.forEach((element1) => {
val2.forEach((element2) => {
if (element1.name === element2.name) {
compareLen++;
}
});
});
return compareLen === val1.length;
},
//
addSkuGroup() {
if (!this.addGroupData.name) {
uni.showToast({
title: '请填写规格组名称',
icon: 'none'
})
return
}
//
console.log("添加了一个规格组");
this.skuGroup.push(this.addGroupData);
console.log("skuGroup发生了变换");
//
this.addGroupData = {
name: "",
groupItem: [],
};
},
//
moveGroup(index) {
if (this.skuGroup[index].groupItem.length === 0) {
console.log("删除的组合没有规格!!!");
this.skuGroup.splice(index, 1);
return
}
this.skuGroup.splice(index, 1);
var attrList = this.setGoodsAttrItem(this.skuGroup, [], 0);
this.skuLibrary = this.getAttrDataInfo(attrList);
this.calculateCombinationPrice(this.skuLibrary);
},
//
calculateCombinationPrice(skuLibrary) {
console.log(skuLibrary);
skuLibrary.forEach((sku) => {
// SKU
let combinationPrice = 0;
// SKU
sku.attr_list.forEach((attr) => {
//
combinationPrice += attr.price;
});
// SKU
sku.price = combinationPrice.toFixed(2);
sku.original_price = combinationPrice.toFixed(2);
});
this.skuLibrary = skuLibrary
},
//
addGroupItem(index) {
const _skuGroup = this.skuGroup
if (this.skuGroup[index].groupItem.length === 0) {
console.log("新的组合出现了!!!");
//
setTimeout(() => {
// console.log(this.skuGroup);
this.calculateCombinationPrice(this.skuLibrary);
});
} else {
console.log(_skuGroup);
}
if (!this.addGouppItemData[index]) {
if (!this.addGroupData.name) {
uni.showToast({
title: '请填写规格名称',
icon: 'none'
})
return
}
return
}
this.skuGroup[index].groupItem.push({
group_name: this.skuGroup[index].name,
name: this.addGouppItemData[index],
price: 0
});
console.log(this.skuGroup);
// todo
var attrList = this.setGoodsAttrItem(this.skuGroup, [], 0);
console.log(attrList);
this.skuLibrary = this.getAttrDataInfo(attrList);
this.addGouppItemData = [];
// //
// this.calculateCombinationPrice(this.skuLibrary);
},
//
removeGroupItem(index, key) {
this.skuGroup[index].groupItem.splice(key, 1);
var attrList = this.setGoodsAttrItem(this.skuGroup, [], 0);
this.skuLibrary = this.getAttrDataInfo(attrList);
},
}
}
</script>
<style lang="scss" scoped>
:deep(.space) {
padding: 6px 10px;
}
:deep(.space1) {
padding: 6px 10px;
background: #f0883a !important;
color: white !important;
.wd-tag__close {
color: white;
}
}
</style>

@ -0,0 +1,56 @@
## 1.0.32022-02-25
- 修复 nvue 不支持的 v-show 的 bug
## 1.0.22022-02-25
- 修复 条件编译 nvue 不支持的 css 样式
## 1.0.12021-11-23
- 修复 由上个版本引发的map、v-model等属性不生效的bug
## 1.0.02021-11-19
- 优化 组件 UI并提供设计资源详见:[https://uniapp.dcloud.io/component/uniui/resource](https://uniapp.dcloud.io/component/uniui/resource)
- 文档迁移,详见:[https://uniapp.dcloud.io/component/uniui/uni-data-picker](https://uniapp.dcloud.io/component/uniui/uni-data-picker)
## 0.4.92021-10-28
- 修复 VUE2 v-model 概率无效的 bug
## 0.4.82021-10-27
- 修复 v-model 概率无效的 bug
## 0.4.72021-10-25
- 新增 属性 spaceInfo 服务空间配置 HBuilderX 3.2.11+
- 修复 树型 uniCloud 数据类型为 int 时报错的 bug
## 0.4.62021-10-19
- 修复 非 VUE3 v-model 为 0 时无法选中的 bug
## 0.4.52021-09-26
- 新增 清除已选项的功能(通过 clearIcon 属性配置是否显示按钮),同时提供 clear 方法以供调用,二者等效
- 修复 readonly 为 true 时报错的 bug
## 0.4.42021-09-26
- 修复 上一版本造成的 map 属性失效的 bug
- 新增 ellipsis 属性,支持配置 tab 选项长度过长时是否自动省略
## 0.4.32021-09-24
- 修复 某些情况下级联未触发的 bug
## 0.4.22021-09-23
- 新增 提供 show 和 hide 方法,开发者可以通过 ref 调用
- 新增 选项内容过长自动添加省略号
## 0.4.12021-09-15
- 新增 map 属性 字段映射,将 text/value 映射到数据中的其他字段
## 0.4.02021-07-13
- 组件兼容 vue3如何创建 vue3 项目,详见 [uni-app 项目支持 vue3 介绍](https://ask.dcloud.net.cn/article/37834)
## 0.3.52021-06-04
- 修复 无法加载云端数据的问题
## 0.3.42021-05-28
- 修复 v-model 无效问题
- 修复 loaddata 为空数据组时加载时间过长问题
- 修复 上个版本引出的本地数据无法选择带有 children 的 2 级节点
## 0.3.32021-05-12
- 新增 组件示例地址
## 0.3.22021-04-22
- 修复 非树形数据有 where 属性查询报错的问题
## 0.3.12021-04-15
- 修复 本地数据概率无法回显时问题
## 0.3.02021-04-07
- 新增 支持云端非树形表结构数据
- 修复 根节点 parent_field 字段等于 null 时选择界面错乱问题
## 0.2.02021-03-15
- 修复 nodeclick、popupopened、popupclosed 事件无法触发的问题
## 0.1.92021-03-09
- 修复 微信小程序某些情况下无法选择的问题
## 0.1.82021-02-05
- 优化 部分样式在 nvue 上的兼容表现
## 0.1.72021-02-05
- 调整为 uni_modules 目录规范

@ -0,0 +1,45 @@
// #ifdef H5
export default {
name: 'Keypress',
props: {
disable: {
type: Boolean,
default: false
}
},
mounted () {
const keyNames = {
esc: ['Esc', 'Escape'],
tab: 'Tab',
enter: 'Enter',
space: [' ', 'Spacebar'],
up: ['Up', 'ArrowUp'],
left: ['Left', 'ArrowLeft'],
right: ['Right', 'ArrowRight'],
down: ['Down', 'ArrowDown'],
delete: ['Backspace', 'Delete', 'Del']
}
const listener = ($event) => {
if (this.disable) {
return
}
const keyName = Object.keys(keyNames).find(key => {
const keyName = $event.key
const value = keyNames[key]
return value === keyName || (Array.isArray(value) && value.includes(keyName))
})
if (keyName) {
// 避免和其他按键事件冲突
setTimeout(() => {
this.$emit(keyName, {})
}, 0)
}
}
document.addEventListener('keyup', listener)
this.$once('hook:beforeDestroy', () => {
document.removeEventListener('keyup', listener)
})
},
render: () => {}
}
// #endif

@ -0,0 +1,598 @@
<template>
<view class="uni-data-tree">
<view class="uni-data-tree-input" @click="handleInput">
<slot :options="options" :data="inputSelected" :error="errorMessage">
<view class="input-value" :class="{ 'input-value-border': border }">
<text v-if="errorMessage" class="selected-area error-text">{{
errorMessage
}}</text>
<view v-else-if="loading && !isOpened" class="selected-area">
<uni-load-more
class="load-more"
:contentText="loadMore"
status="loading"
></uni-load-more>
</view>
<scroll-view
v-else-if="inputSelected.length"
class="selected-area"
scroll-x="true"
>
<view class="selected-list">
<view
class="selected-item"
v-for="(item, index) in inputSelected"
:key="index"
>
<text>{{ item.text }}</text
><text
v-if="index < inputSelected.length - 1"
class="input-split-line"
>{{ split }}</text
>
</view>
</view>
</scroll-view>
<text v-else class="selected-area placeholder">{{
placeholder
}}</text>
<view
v-if="clearIcon && !readonly && inputSelected.length"
class="icon-clear"
@click.stop="clear"
>
<!-- <uni-icons type="clear" color="#e1e1e1" size="14"></uni-icons> -->
<!-- <i class="iconfont icon-reeor-fill"></i> -->
</view>
<view
class="arrow-area"
v-if="(!clearIcon || !inputSelected.length) && !readonly"
>
<view class="input-arrow"></view>
</view>
</view>
</slot>
</view>
<view
class="uni-data-tree-cover"
v-if="isOpened"
@click="handleClose"
></view>
<view class="uni-data-tree-dialog" v-if="isOpened">
<view class="uni-popper__arrow"></view>
<view class="dialog-caption">
<view class="title-area">
<text class="dialog-title">{{ popupTitle }}</text>
</view>
<view class="dialog-close" @click="handleClose">
<view class="dialog-close-plus" data-id="close"></view>
<view
class="dialog-close-plus dialog-close-rotate"
data-id="close"
></view>
</view>
</view>
<data-picker-view
class="picker-view"
ref="pickerView"
v-model="dataValue"
:localdata="localdata"
:preload="preload"
:collection="collection"
:field="field"
:orderby="orderby"
:where="where"
:step-searh="stepSearh"
:self-field="selfField"
:parent-field="parentField"
:managed-mode="true"
:map="map"
:ellipsis="ellipsis"
@change="onchange"
@datachange="ondatachange"
@nodeclick="onnodeclick"
>
</data-picker-view>
</view>
</view>
</template>
<script>
import dataPicker from "../uni-data-pickerview/uni-data-picker.js";
import DataPickerView from "../uni-data-pickerview/uni-data-pickerview.vue";
/**
* DataPicker 级联选择
* @description 支持单列和多列级联选择列数没有限制如果屏幕显示不全顶部tab区域会左右滚动
* @tutorial https://ext.dcloud.net.cn/plugin?id=3796
* @property {String} popup-title 弹出窗口标题
* @property {Array} localdata 本地数据参考
* @property {Boolean} border = [true|false] 是否有边框
* @property {Boolean} readonly = [true|false] 是否仅读
* @property {Boolean} preload = [true|false] 是否预加载数据
* @value true 开启预加载数据点击弹出窗口后显示已加载数据
* @value false 关闭预加载数据点击弹出窗口后开始加载数据
* @property {Boolean} step-searh = [true|false] 是否分布查询
* @value true 启用分布查询仅查询当前选中节点
* @value false 关闭分布查询一次查询出所有数据
* @property {String|DBFieldString} self-field 分布查询当前字段名称
* @property {String|DBFieldString} parent-field 分布查询父字段名称
* @property {String|DBCollectionString} collection 表名
* @property {String|DBFieldString} field 查询字段多个字段用 `,` 分割
* @property {String} orderby 排序字段及正序倒叙设置
* @property {String|JQLString} where 查询条件
* @event {Function} popupshow 弹出的选择窗口打开时触发此事件
* @event {Function} popuphide 弹出的选择窗口关闭时触发此事件
*/
export default {
name: "UniDataPicker",
emits: [
"popupopened",
"popupclosed",
"nodeclick",
"input",
"change",
"update:modelValue",
],
mixins: [dataPicker],
components: {
DataPickerView,
},
props: {
options: {
type: [Object, Array],
default() {
return {};
},
},
popupTitle: {
type: String,
default: "请选择",
},
placeholder: {
type: String,
default: "请选择",
},
heightMobile: {
type: String,
default: "",
},
readonly: {
type: Boolean,
default: false,
},
clearIcon: {
type: Boolean,
default: true,
},
border: {
type: Boolean,
default: true,
},
split: {
type: String,
default: "/",
},
ellipsis: {
type: Boolean,
default: true,
},
},
data() {
return {
isOpened: false,
inputSelected: [],
};
},
created() {
this.form = this.getForm("uniForms");
this.formItem = this.getForm("uniFormsItem");
if (this.formItem) {
if (this.formItem.name) {
this.rename = this.formItem.name;
this.form.inputChildrens.push(this);
}
}
this.$nextTick(() => {
this.load();
});
},
methods: {
clear() {
this.inputSelected.splice(0);
this._dispatchEvent([]);
},
onPropsChange() {
this._treeData = [];
this.selectedIndex = 0;
this.load();
},
load() {
if (this.readonly) {
this._processReadonly(this.localdata, this.dataValue);
return;
}
if (this.isLocaldata) {
this.loadData();
this.inputSelected = this.selected.slice(0);
} else if (!this.parentField && !this.selfField && this.hasValue) {
this.getNodeData(() => {
this.inputSelected = this.selected.slice(0);
});
} else if (this.hasValue) {
this.getTreePath(() => {
this.inputSelected = this.selected.slice(0);
});
}
},
getForm(name = "uniForms") {
let parent = this.$parent;
let parentName = parent.$options.name;
while (parentName !== name) {
parent = parent.$parent;
if (!parent) return false;
parentName = parent.$options.name;
}
return parent;
},
show() {
this.isOpened = true;
this.$nextTick(() => {
this.$refs.pickerView.updateData({
treeData: this._treeData,
selected: this.selected,
selectedIndex: this.selectedIndex,
});
});
this.$emit("popupopened");
},
hide() {
this.isOpened = false;
this.$emit("popupclosed");
},
handleInput() {
if (this.readonly) {
return;
}
this.show();
},
handleClose(e) {
this.hide();
},
onnodeclick(e) {
this.$emit("nodeclick", e);
},
ondatachange(e) {
this._treeData = this.$refs.pickerView._treeData;
},
onchange(e) {
this.hide();
this.inputSelected = e;
this._dispatchEvent(e);
},
_processReadonly(dataList, value) {
var isTree = dataList.findIndex((item) => {
return item.children;
});
if (isTree > -1) {
let inputValue;
if (Array.isArray(value)) {
inputValue = value[value.length - 1];
if (typeof inputValue === "object" && inputValue.value) {
inputValue = inputValue.value;
}
} else {
inputValue = value;
}
this.inputSelected = this._findNodePath(inputValue, this.localdata);
return;
}
if (!this.hasValue) {
this.inputSelected = [];
return;
}
let result = [];
for (let i = 0; i < value.length; i++) {
var val = value[i];
var item = dataList.find((v) => {
return v.value == val;
});
if (item) {
result.push(item);
}
}
if (result.length) {
this.inputSelected = result;
}
},
_filterForArray(data, valueArray) {
var result = [];
for (let i = 0; i < valueArray.length; i++) {
var value = valueArray[i];
var found = data.find((item) => {
return item.value == value;
});
if (found) {
result.push(found);
}
}
return result;
},
_dispatchEvent(selected) {
let item = {};
if (selected.length) {
var value = new Array(selected.length);
for (var i = 0; i < selected.length; i++) {
value[i] = selected[i].value;
}
item = selected[selected.length - 1];
} else {
item.value = "";
}
if (this.formItem) {
this.formItem.setValue(item.value);
}
this.$emit("input", item.value);
this.$emit("update:modelValue", item.value);
this.$emit("change", {
detail: {
value: selected,
},
});
},
},
};
</script>
<style>
.uni-data-tree {
position: relative;
font-size: 14px;
}
.error-text {
color: #dd524d;
}
.input-value {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
align-items: center;
flex-wrap: nowrap;
font-size: 14px;
line-height: 38px;
padding: 0 5px;
overflow: hidden;
/* #ifdef APP-NVUE */
height: 40px;
/* #endif */
}
.input-value-border {
border: 1px solid #e5e5e5;
border-radius: 5px;
}
.selected-area {
/* #ifndef MP-ALIPAY */
flex: 1;
/* #endif */
overflow: hidden;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
}
.load-more {
/* #ifndef APP-NVUE */
margin-right: auto;
/* #endif */
/* #ifdef APP-NVUE */
width: 40px;
/* #endif */
}
.selected-list {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
flex-wrap: nowrap;
padding: 0 5px;
}
.selected-item {
flex-direction: row;
padding: 0 1px;
/* #ifndef APP-NVUE */
white-space: nowrap;
/* #endif */
}
.placeholder {
color: grey;
}
.input-split-line {
opacity: 0.5;
}
.arrow-area {
position: relative;
width: 20px;
/* #ifndef APP-NVUE */
margin-bottom: 5px;
margin-left: auto;
display: flex;
/* #endif */
justify-content: center;
transform: rotate(-45deg);
transform-origin: center;
}
.input-arrow {
width: 7px;
height: 7px;
border-left: 1px solid #999;
border-bottom: 1px solid #999;
}
.uni-data-tree-cover {
position: fixed;
left: 0;
top: 0;
right: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0.4);
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: column;
z-index: 100;
}
.uni-data-tree-dialog {
position: fixed;
left: 0;
top: 20%;
right: 0;
bottom: 0;
background-color: #ffffff;
border-top-left-radius: 10px;
border-top-right-radius: 10px;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: column;
z-index: 102;
overflow: hidden;
/* #ifdef APP-NVUE */
width: 750rpx;
/* #endif */
}
.dialog-caption {
position: relative;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
/* border-bottom: 1px solid #f0f0f0; */
}
.title-area {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
align-items: center;
/* #ifndef APP-NVUE */
margin: auto;
/* #endif */
padding: 0 10px;
}
.dialog-title {
/* font-weight: bold; */
line-height: 44px;
}
.dialog-close {
position: absolute;
top: 0;
right: 0;
bottom: 0;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
align-items: center;
padding: 0 15px;
}
.dialog-close-plus {
width: 16px;
height: 2px;
background-color: #666;
border-radius: 2px;
transform: rotate(45deg);
}
.dialog-close-rotate {
position: absolute;
transform: rotate(-45deg);
}
.picker-view {
flex: 1;
overflow: hidden;
}
/* #ifdef H5 */
@media all and (min-width: 768px) {
.uni-data-tree-cover {
background-color: transparent;
}
.uni-data-tree-dialog {
position: absolute;
top: 55px;
height: auto;
min-height: 400px;
max-height: 50vh;
background-color: #fff;
border: 1px solid #ebeef5;
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
border-radius: 4px;
overflow: unset;
}
.dialog-caption {
display: none;
}
.icon-clear {
margin-right: 5px;
}
}
/* #endif */
/* picker 弹出层通用的指示小三角, todo扩展至上下左右方向定位 */
/* #ifndef APP-NVUE */
.uni-popper__arrow,
.uni-popper__arrow::after {
position: absolute;
display: block;
width: 0;
height: 0;
border-color: transparent;
border-style: solid;
border-width: 6px;
}
.uni-popper__arrow {
filter: drop-shadow(0 2px 12px rgba(0, 0, 0, 0.03));
top: -6px;
left: 10%;
margin-right: 3px;
border-top-width: 0;
border-bottom-color: #ebeef5;
}
.uni-popper__arrow::after {
content: " ";
top: 1px;
margin-left: -6px;
border-top-width: 0;
border-bottom-color: #fff;
}
/* #endif */
</style>

@ -0,0 +1,563 @@
export default {
props: {
localdata: {
type: [Array, Object],
default () {
return []
}
},
spaceInfo: {
type: Object,
default () {
return {}
}
},
collection: {
type: String,
default: ''
},
action: {
type: String,
default: ''
},
field: {
type: String,
default: ''
},
orderby: {
type: String,
default: ''
},
where: {
type: [String, Object],
default: ''
},
pageData: {
type: String,
default: 'add'
},
pageCurrent: {
type: Number,
default: 1
},
pageSize: {
type: Number,
default: 20
},
getcount: {
type: [Boolean, String],
default: false
},
getone: {
type: [Boolean, String],
default: false
},
gettree: {
type: [Boolean, String],
default: false
},
manual: {
type: Boolean,
default: false
},
value: {
type: [Array, String, Number],
default () {
return []
}
},
modelValue: {
type: [Array, String, Number],
default () {
return []
}
},
preload: {
type: Boolean,
default: false
},
stepSearh: {
type: Boolean,
default: true
},
selfField: {
type: String,
default: ''
},
parentField: {
type: String,
default: ''
},
multiple: {
type: Boolean,
default: false
},
map: {
type: Object,
default() {
return {
text: "text",
value: "value"
}
}
}
},
data() {
return {
loading: false,
errorMessage: '',
loadMore: {
contentdown: '',
contentrefresh: '',
contentnomore: ''
},
dataList: [],
selected: [],
selectedIndex: 0,
page: {
current: this.pageCurrent,
size: this.pageSize,
count: 0
}
}
},
computed: {
isLocaldata() {
return !this.collection.length
},
postField() {
let fields = [this.field];
if (this.parentField) {
fields.push(`${this.parentField} as parent_value`);
}
return fields.join(',');
},
dataValue() {
let isModelValue = Array.isArray(this.modelValue) ? (this.modelValue.length > 0) : (this.modelValue !== null || this.modelValue !== undefined)
return isModelValue ? this.modelValue : this.value
},
hasValue() {
if (typeof this.dataValue === 'number') {
return true
}
return (this.dataValue != null) && (this.dataValue.length > 0)
}
},
created() {
this.$watch(() => {
var al = [];
['pageCurrent',
'pageSize',
'spaceInfo',
'value',
'modelValue',
'localdata',
'collection',
'action',
'field',
'orderby',
'where',
'getont',
'getcount',
'gettree'
].forEach(key => {
al.push(this[key])
});
return al
}, (newValue, oldValue) => {
let needReset = false
for (let i = 2; i < newValue.length; i++) {
if (newValue[i] != oldValue[i]) {
needReset = true
break
}
}
if (newValue[0] != oldValue[0]) {
this.page.current = this.pageCurrent
}
this.page.size = this.pageSize
this.onPropsChange()
})
this._treeData = []
},
methods: {
onPropsChange() {
this._treeData = []
},
getCommand(options = {}) {
/* eslint-disable no-undef */
let db = uniCloud.database(this.spaceInfo)
const action = options.action || this.action
if (action) {
db = db.action(action)
}
const collection = options.collection || this.collection
db = db.collection(collection)
const where = options.where || this.where
if (!(!where || !Object.keys(where).length)) {
db = db.where(where)
}
const field = options.field || this.field
if (field) {
db = db.field(field)
}
const orderby = options.orderby || this.orderby
if (orderby) {
db = db.orderBy(orderby)
}
const current = options.pageCurrent !== undefined ? options.pageCurrent : this.page.current
const size = options.pageSize !== undefined ? options.pageSize : this.page.size
const getCount = options.getcount !== undefined ? options.getcount : this.getcount
const getTree = options.gettree !== undefined ? options.gettree : this.gettree
const getOptions = {
getCount,
getTree
}
if (options.getTreePath) {
getOptions.getTreePath = options.getTreePath
}
db = db.skip(size * (current - 1)).limit(size).get(getOptions)
return db
},
getNodeData(callback) {
if (this.loading) {
return
}
this.loading = true
this.getCommand({
field: this.postField,
where: this._pathWhere()
}).then((res) => {
this.loading = false
this.selected = res.result.data
callback && callback()
}).catch((err) => {
this.loading = false
this.errorMessage = err
})
},
getTreePath(callback) {
if (this.loading) {
return
}
this.loading = true
this.getCommand({
field: this.postField,
getTreePath: {
startWith: `${this.selfField}=='${this.dataValue}'`
}
}).then((res) => {
this.loading = false
let treePath = []
this._extractTreePath(res.result.data, treePath)
this.selected = treePath
callback && callback()
}).catch((err) => {
this.loading = false
this.errorMessage = err
})
},
loadData() {
if (this.isLocaldata) {
this._processLocalData()
return
}
if (this.dataValue != null) {
this._loadNodeData((data) => {
this._treeData = data
this._updateBindData()
this._updateSelected()
})
return
}
if (this.stepSearh) {
this._loadNodeData((data) => {
this._treeData = data
this._updateBindData()
})
} else {
this._loadAllData((data) => {
this._treeData = []
this._extractTree(data, this._treeData, null)
this._updateBindData()
})
}
},
_loadAllData(callback) {
if (this.loading) {
return
}
this.loading = true
this.getCommand({
field: this.postField,
gettree: true,
startwith: `${this.selfField}=='${this.dataValue}'`
}).then((res) => {
this.loading = false
callback(res.result.data)
this.onDataChange()
}).catch((err) => {
this.loading = false
this.errorMessage = err
})
},
_loadNodeData(callback, pw) {
if (this.loading) {
return
}
this.loading = true
this.getCommand({
field: this.postField,
where: pw || this._postWhere(),
pageSize: 500
}).then((res) => {
this.loading = false
callback(res.result.data)
this.onDataChange()
}).catch((err) => {
this.loading = false
this.errorMessage = err
})
},
_pathWhere() {
let result = []
let where_field = this._getParentNameByField();
if (where_field) {
result.push(`${where_field} == '${this.dataValue}'`)
}
if (this.where) {
return `(${this.where}) && (${result.join(' || ')})`
}
return result.join(' || ')
},
_postWhere() {
let result = []
let selected = this.selected
let parentField = this.parentField
if (parentField) {
result.push(`${parentField} == null || ${parentField} == ""`)
}
if (selected.length) {
for (var i = 0; i < selected.length - 1; i++) {
result.push(`${parentField} == '${selected[i].value}'`)
}
}
let where = []
if (this.where) {
where.push(`(${this.where})`)
}
if (result.length) {
where.push(`(${result.join(' || ')})`)
}
return where.join(' && ')
},
_nodeWhere() {
let result = []
let selected = this.selected
if (selected.length) {
result.push(`${this.parentField} == '${selected[selected.length - 1].value}'`)
}
if (this.where) {
return `(${this.where}) && (${result.join(' || ')})`
}
return result.join(' || ')
},
_getParentNameByField() {
const fields = this.field.split(',');
let where_field = null;
for (let i = 0; i < fields.length; i++) {
const items = fields[i].split('as');
if (items.length < 2) {
continue;
}
if (items[1].trim() === 'value') {
where_field = items[0].trim();
break;
}
}
return where_field
},
_isTreeView() {
return (this.parentField && this.selfField)
},
_updateSelected() {
var dl = this.dataList
var sl = this.selected
let textField = this.map.text
let valueField = this.map.value
for (var i = 0; i < sl.length; i++) {
var value = sl[i].value
var dl2 = dl[i]
for (var j = 0; j < dl2.length; j++) {
var item2 = dl2[j]
if (item2[valueField] === value) {
sl[i].text = item2[textField]
break
}
}
}
},
_updateBindData(node) {
const {
dataList,
hasNodes
} = this._filterData(this._treeData, this.selected)
let isleaf = this._stepSearh === false && !hasNodes
if (node) {
node.isleaf = isleaf
}
this.dataList = dataList
this.selectedIndex = dataList.length - 1
if (!isleaf && this.selected.length < dataList.length) {
this.selected.push({
value: null,
text: "请选择"
})
}
return {
isleaf,
hasNodes
}
},
_filterData(data, paths) {
let dataList = []
let hasNodes = true
dataList.push(data.filter((item) => {
return (item.parent_value === null || item.parent_value === undefined || item.parent_value === '')
}))
for (let i = 0; i < paths.length; i++) {
var value = paths[i].value
var nodes = data.filter((item) => {
return item.parent_value === value
})
if (nodes.length) {
dataList.push(nodes)
} else {
hasNodes = false
}
}
return {
dataList,
hasNodes
}
},
_extractTree(nodes, result, parent_value) {
let list = result || []
let valueField = this.map.value
for (let i = 0; i < nodes.length; i++) {
let node = nodes[i]
let child = {}
for (let key in node) {
if (key !== 'children') {
child[key] = node[key]
}
}
if (parent_value !== null && parent_value !== undefined && parent_value !== '') {
child.parent_value = parent_value
}
result.push(child)
let children = node.children
if (children) {
this._extractTree(children, result, node[valueField])
}
}
},
_extractTreePath(nodes, result) {
let list = result || []
for (let i = 0; i < nodes.length; i++) {
let node = nodes[i]
let child = {}
for (let key in node) {
if (key !== 'children') {
child[key] = node[key]
}
}
result.push(child)
let children = node.children
if (children) {
this._extractTreePath(children, result)
}
}
},
_findNodePath(key, nodes, path = []) {
let textField = this.map.text
let valueField = this.map.value
for (let i = 0; i < nodes.length; i++) {
let node = nodes[i]
let children = node.children
let text = node[textField]
let value = node[valueField]
path.push({
value,
text
})
if (value === key) {
return path
}
if (children) {
const p = this._findNodePath(key, children, path)
if (p.length) {
return p
}
}
path.pop()
}
return []
},
_processLocalData() {
this._treeData = []
this._extractTree(this.localdata, this._treeData)
var inputValue = this.dataValue
if (inputValue === undefined) {
return
}
if (Array.isArray(inputValue)) {
inputValue = inputValue[inputValue.length - 1]
if (typeof inputValue === 'object' && inputValue[this.map.value]) {
inputValue = inputValue[this.map.value]
}
}
this.selected = this._findNodePath(inputValue, this.localdata)
}
}
}

@ -0,0 +1,364 @@
<template>
<view class="uni-data-pickerview">
<scroll-view
class="selected-area"
scroll-x="true"
scroll-y="false"
:show-scrollbar="false"
>
<view class="selected-list">
<template v-for="(item, index) in selected">
<view
class="selected-item"
:class="{
'selected-item-active': index == selectedIndex,
'selected-item-text-overflow': ellipsis,
}"
:key="index"
v-if="item.text"
@click="handleSelect(index)"
>
<text class="">{{ item.text }}</text>
</view>
</template>
</view>
</scroll-view>
<view class="tab-c">
<template v-for="(child, i) in dataList">
<scroll-view
class="list"
:key="i"
v-if="i == selectedIndex"
:scroll-y="true"
>
<view
class="item"
:class="{ 'is-disabled': !!item.disable }"
v-for="(item, j) in child"
:key="j"
@click="handleNodeClick(item, i, j)"
>
<text class="item-text item-text-overflow">{{
item[map.text]
}}</text>
<view
class="check"
v-if="selected.length > i && item[map.value] == selected[i].value"
></view>
</view>
</scroll-view>
</template>
<view class="loading-cover" v-if="loading">
<uni-load-more
class="load-more"
:contentText="loadMore"
status="loading"
></uni-load-more>
</view>
<view class="error-message" v-if="errorMessage">
<text class="error-text">{{ errorMessage }}</text>
</view>
</view>
</view>
</template>
<script>
import dataPicker from "./uni-data-picker.js";
/**
* DataPickerview
* @description uni-data-pickerview
* @tutorial https://ext.dcloud.net.cn/plugin?id=3796
* @property {Array} localdata 本地数据参考
* @property {Boolean} step-searh = [true|false] 是否分布查询
* @value true 启用分布查询仅查询当前选中节点
* @value false 关闭分布查询一次查询出所有数据
* @property {String|DBFieldString} self-field 分布查询当前字段名称
* @property {String|DBFieldString} parent-field 分布查询父字段名称
* @property {String|DBCollectionString} collection 表名
* @property {String|DBFieldString} field 查询字段多个字段用 `,` 分割
* @property {String} orderby 排序字段及正序倒叙设置
* @property {String|JQLString} where 查询条件
*/
export default {
name: "UniDataPickerView",
emits: ["nodeclick", "change", "datachange", "update:modelValue"],
mixins: [dataPicker],
props: {
managedMode: {
type: Boolean,
default: false,
},
ellipsis: {
type: Boolean,
default: true,
},
},
data() {
return {};
},
created() {
if (this.managedMode) {
return;
}
this.$nextTick(() => {
this.load();
});
},
methods: {
onPropsChange() {
this._treeData = [];
this.selectedIndex = 0;
this.load();
},
load() {
if (this.isLocaldata) {
this.loadData();
} else if (this.dataValue.length) {
this.getTreePath((res) => {
this.loadData();
});
}
},
handleSelect(index) {
this.selectedIndex = index;
},
handleNodeClick(item, i, j) {
if (item.disable) {
return;
}
const node = this.dataList[i][j];
const text = node[this.map.text];
const value = node[this.map.value];
if (i < this.selected.length - 1) {
this.selected.splice(i, this.selected.length - i);
this.selected.push({
text,
value,
});
} else if (i === this.selected.length - 1) {
this.selected.splice(i, 1, {
text,
value,
});
}
if (node.isleaf) {
this.onSelectedChange(node, node.isleaf);
return;
}
const { isleaf, hasNodes } = this._updateBindData();
if (!this._isTreeView() && !hasNodes) {
this.onSelectedChange(node, true);
return;
}
if (this.isLocaldata && (!hasNodes || isleaf)) {
this.onSelectedChange(node, true);
return;
}
if (!isleaf && !hasNodes) {
this._loadNodeData((data) => {
if (!data.length) {
node.isleaf = true;
} else {
this._treeData.push(...data);
this._updateBindData(node);
}
this.onSelectedChange(node, node.isleaf);
}, this._nodeWhere());
return;
}
this.onSelectedChange(node, false);
},
updateData(data) {
this._treeData = data.treeData;
this.selected = data.selected;
if (!this._treeData.length) {
this.loadData();
} else {
//this.selected = data.selected
this._updateBindData();
}
},
onDataChange() {
this.$emit("datachange");
},
onSelectedChange(node, isleaf) {
if (isleaf) {
this._dispatchEvent();
}
if (node) {
this.$emit("nodeclick", node);
}
},
_dispatchEvent() {
this.$emit("change", this.selected.slice(0));
},
},
};
</script>
<style>
.uni-data-pickerview {
flex: 1;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: column;
overflow: hidden;
height: 100%;
}
.error-text {
color: #dd524d;
}
.loading-cover {
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
background-color: rgba(255, 255, 255, 0.5);
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: column;
align-items: center;
z-index: 1001;
}
.load-more {
/* #ifndef APP-NVUE */
margin: auto;
/* #endif */
}
.error-message {
background-color: #fff;
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
padding: 15px;
opacity: 0.9;
z-index: 102;
}
/* #ifdef APP-NVUE */
.selected-area {
width: 750rpx;
}
/* #endif */
.selected-list {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
flex-wrap: nowrap;
padding: 0 5px;
border-bottom: 1px solid #f8f8f8;
}
.selected-item {
margin-left: 10rpx;
margin-right: 10rpx;
padding: 12rpx 0;
text-align: center;
/* #ifndef APP-NVUE */
white-space: nowrap;
/* #endif */
}
.selected-item-text-overflow {
width: 168px;
line-height: 50rpx;
/* fix nvue */
overflow: hidden;
/* #ifndef APP-NVUE */
width: 6em;
white-space: nowrap;
text-overflow: ellipsis;
-o-text-overflow: ellipsis;
/* #endif */
}
.selected-item-active {
border-bottom: 2px solid #007aff;
}
.selected-item-text {
color: #007aff;
}
.tab-c {
position: relative;
flex: 1;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
overflow: hidden;
}
.list {
flex: 1;
}
.item {
padding: 12px 15px;
line-height: 50rpx;
/* border-bottom: 1px solid #f0f0f0; */
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
justify-content: space-between;
text-align: left;
}
.is-disabled {
opacity: 0.5;
}
.item-text {
/* flex: 1; */
color: #333333;
}
.item-text-overflow {
width: 280px;
/* fix nvue */
overflow: hidden;
/* #ifndef APP-NVUE */
width: 20em;
white-space: nowrap;
text-overflow: ellipsis;
-o-text-overflow: ellipsis;
/* #endif */
}
.check {
margin-right: 5px;
border: 2px solid #007aff;
border-left: 0;
border-top: 0;
height: 12px;
width: 6px;
transform-origin: center;
/* #ifndef APP-NVUE */
transition: all 0.3s;
/* #endif */
transform: rotate(45deg);
}
</style>

@ -0,0 +1,92 @@
{
"id": "uni-data-picker",
"displayName": "uni-data-picker 数据驱动的picker选择器",
"version": "1.0.3",
"description": "单列、多列级联选择器,常用于省市区城市选择、公司部门选择、多级分类等场景",
"keywords": [
"uni-ui",
"uniui",
"picker",
"级联",
"省市区",
""
],
"repository": "https://github.com/dcloudio/uni-ui",
"engines": {
"HBuilderX": ""
},
"directories": {
"example": "../../temps/example_temps"
},
"dcloudext": {
"category": [
"前端组件",
"通用组件"
],
"sale": {
"regular": {
"price": "0.00"
},
"sourcecode": {
"price": "0.00"
}
},
"contact": {
"qq": ""
},
"declaration": {
"ads": "无",
"data": "无",
"permissions": "无"
},
"npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui"
},
"uni_modules": {
"dependencies": [
"uni-load-more",
"uni-icons",
"uni-scss"
],
"encrypt": [],
"platforms": {
"cloud": {
"tcb": "y",
"aliyun": "y"
},
"client": {
"App": {
"app-vue": "y",
"app-nvue": "y"
},
"H5-mobile": {
"Safari": "y",
"Android Browser": "y",
"微信浏览器(Android)": "y",
"QQ浏览器(Android)": "y"
},
"H5-pc": {
"Chrome": "y",
"IE": "y",
"Edge": "y",
"Firefox": "y",
"Safari": "y"
},
"小程序": {
"微信": "y",
"阿里": "y",
"百度": "y",
"字节跳动": "y",
"QQ": "y"
},
"快应用": {
"华为": "u",
"联盟": "u"
},
"Vue": {
"vue2": "y",
"vue3": "y"
}
}
}
}
}

@ -0,0 +1,22 @@
## DataPicker 级联选择
> **组件名uni-data-picker**
> 代码块: `uDataPicker`
> 关联组件:`uni-data-pickerview`、`uni-load-more`。
`<uni-data-picker>` 是一个选择类[datacom组件](https://uniapp.dcloud.net.cn/component/datacom)。
支持单列、和多列级联选择。列数没有限制如果屏幕显示不全顶部tab区域会左右滚动。
候选数据支持一次性加载完毕,也支持懒加载,比如示例图中,选择了“北京”后,动态加载北京的区县数据。
`<uni-data-picker>` 组件尤其适用于地址选择、分类选择等选择类。
`<uni-data-picker>` 支持本地数据、云端静态数据(json)uniCloud云数据库数据。
`<uni-data-picker>` 可以通过JQL直连uniCloud云数据库配套[DB Schema](https://uniapp.dcloud.net.cn/uniCloud/schema)可在schema2code中自动生成前端页面还支持服务器端校验。
在uniCloud数据表中新建表“uni-id-address”和“opendb-city-china”这2个表的schema自带foreignKey关联。在“uni-id-address”表的表结构页面使用schema2code生成前端页面会自动生成地址管理的维护页面自动从“opendb-city-china”表包含的中国所有省市区信息里选择地址。
### [查看文档](https://uniapp.dcloud.io/component/uniui/uni-data-picker)
#### 如使用过程中有任何问题或者您对uni-ui有一些好的建议欢迎加入 uni-ui 交流群871950839

@ -0,0 +1,429 @@
<template>
<view v-if="load" class="content p-2 bg-gray-100">
<wd-toast />
<wd-form ref="form" :model="model">
<wd-cell-group border>
<div class="rounded-md overflow-hidden">
<div class="bg-gray-100 ">
<div class="bg-gray-100 rounded mb-2">
<div class="bg-white flex flex-col pt-3 pl-3">
<div class="name mb-2 text-xs">缩略图</div>
<yUpload v-model="model.pic_url"></yUpload>
</div>
</div>
</div>
<div class="bg-gray-100">
<div class="bg-gray-100 rounded mb-2">
<div class="bg-white flex flex-col pt-3 pl-3">
<div class="name mb-2 text-xs">商品主图</div>
<yUpload v-model="model.pic_list" :size="4"></yUpload>
</div>
</div>
</div>
</div>
<view class="h-2 bg-gray-100"></view>
<view class=" p-3 rounded mb-2">
<div class="name mb-2 text-xs">商品名称</div>
<view class="bg-white px-3 py-1 rounded">
<wd-textarea v-model="model.name" auto-height />
</view>
</view>
<view class="h-2 bg-gray-100"></view>
<view class=" p-3 rounded mb-2">
<div class="name mb-2 text-xs">商品分类</div>
<view class="bg-white px-3 py-1 rounded">
<wd-checkbox-group v-model="model.shop_classify_list">
<view class="flex overflow-auto flex-wrap">
<div class="grid grid-cols-3">
<wd-checkbox style="width: 100%;" shape="button" v-for="cat of classifyList"
:modelValue="JSON.stringify(cat.parentIds)">
{{ cat.name }}
</wd-checkbox>
</div>
</view>
</wd-checkbox-group>
</view>
</view>
<view class="h-2 bg-gray-100"></view>
<view class="bg-gray-100 rounded mb-2">
<div class="p-2 bg-white">
<div class="name mb-2 text-xs">服务内容</div>
<view class="bg-white px-3 py-1 rounded">
<wd-input type="text" v-model="model.server_project" placeholder="例子: 正品保障,极速发货,7天退换货。多个请使用英文逗号“,”分隔" />
</view>
</div>
</view>
<view class="h-2 bg-gray-100"></view>
<view class=" p-3 rounded mb-2">
<div class="name mb-2 text-xs">商品重量</div>
<view class="bg-white px-3 py-2 rounded flex items-center mb-4">
<wd-input-number v-model="model.weight" />
<view class="text-xs from-neutral-300 ml-4">千克</view>
</view>
<wd-picker v-if="freightRules.length" class="w-full" :columns="freightRules" label="运费模板"
v-model="model.freight_id" />
</view>
<view class="h-2 bg-gray-100"></view>
<view class="p-3 rounded mb-2">
<div class="name mb-2 text-xs">商品状态</div>
<view class="bg-white px-3 py-2 rounded flex items-center">
<wd-switch v-model="model.status" :active-value="1" :inactive-value="0" />
</view>
</view>
<view class="h-2 bg-gray-100"></view>
<view class="p-3 rounded mb-2">
<div class="name mb-2 text-xs">规格</div>
<view class="bg-white px-3 py-2 rounded flex items-center">
<wd-radio-group shape="button" v-model="model.use_sku">
<wd-radio :value="0">单规格</wd-radio>
<wd-radio :value="1">多规格</wd-radio>
</wd-radio-group>
</view>
</view>
<view class="h-2 bg-gray-100"></view>
<skuEdit ref="skuEditRef" :skuGroup="skuGroup"
:Pdata="{ skuDefault, skuLibrary, skuGroup, use_sku: model.use_sku }">
</skuEdit>
</wd-cell-group>
<view class="footer mt-4">
<wd-button @click="saveGoods" type="primary" size="large" block>保存</wd-button>
</view>
</wd-form>
</view>
</template>
<script setup>
import { ref } from 'vue';
import { useToast, useMessage } from '@/uni_modules/wot-design-uni';
import goods from '@/api/mall/goods.js';
import system from '@/api/modules/system.js';
import skuEdit from "./components/skuEdit.vue";
import yUpload from "@/components/yUpload/index.vue";
import { onLoad, onShow } from "@dcloudio/uni-app";
/**
* @typedef {import('@/api/mall/goods').GoodsItem} GoodsItem
*/
/**
* @typedef {import('@/api/mall/goods').FreightRule} FreightRule
*/
/**
* @typedef {Object} Sku
* @property {string} price - 商品价格
* @property {string} stock - 商品库存
* @property {string} original_price - 商品原价
*/
/**
* @typedef {Object} Model
* @property {number} id - 商品ID
* @property {Array<string>} shop_classify_list - 商品分类组
* @property {string} name - 商品名称
* @property {string} keywords - 商品关键词
* @property {number} sort - 商品排序
* @property {number} status - 商品状态
* @property {number} freight_id - 运费规则ID
* @property {number} weight - 商品重量
* @property {string} pic_url - 商品缩略图
* @property {Array<string>} pic_list - 商品图组
* @property {string} video - 商品视频
* @property {string} detail - 图文详情
* @property {number} use_sku - 是否使用规格
* @property {Array<Sku>} sku_list - 规格信息
* @property {number} is_discount - 是否有折扣
* @property {number} discount - 折扣比例小数
* @property {number} dist_price - 分销价格
* @property {number} limit - 限购
* @property {number} is_check - 自定义核销佣金
* @property {number} check_type - 佣金类型
* @property {number} check_price - 佣金
*/
/**
* @typedef {Object} FileItem
* @property {string} pic_url - 图片URL
*/
/**
* @typedef {Object} SkuGroup
* @property {Array<Sku>} skuDefault - 默认规格
* @property {Array<Sku>} skuLibrary - 规格库
* @property {Array<Sku>} skuGroup - 规格组
*/
/**
* @typedef {Object} SkuEditRef
* @property {SkuGroup} skuGroup - 规格组
* @property {number} skuDefault - 默认规格
* @property {number} skuLibrary - 规格库
*/
/** @type {Ref<Array<FileItem>>} */
const fileList = ref([]);
/**
* @param {Object} param0
* @param {FileItem} param0.file - 要删除的文件
* @param {Function} param0.resolve - 删除文件的回调函数
* @param {number} param0.index - 文件索引
* @returns {void}
*/
const beforeRemove = ({ file, resolve, index }) => {
fileList.value.splice(index, 1);
resolve(true);
};
/** @type {Ref<Model>} */
const model = ref({
shop_classify_list: [], //
name: "", //
keywords: "", //
sort: 1000,
status: 0, //
freight_id: 99999999, //
weight: 0, //
pic_url: "", //
pic_list: [], //
video: "", //
detail: "默认", //
use_sku: 0, // 使
sku_list: [], //
is_discount: 0, //
discount: 50, //
dist_price: 0, //
limit: 0, //
is_check: 0, //
check_type: 0, //
check_price: 0, //
});
/** @type {Ref<boolean>} */
const load = ref(false);
/** @type {Ref<SkuGroup>} */
const skuGroup = ref([]);
/** @type {Ref<Array<GoodsItem>>} */
const skuDefault = ref([]);
/** @type {Ref<Array<GoodsItem>>} */
const skuLibrary = ref([]);
/** @type {Ref<SkuEditRef>} */
const skuEditRef = ref(null);
/** @type {Ref<Array<FreightRule>>} */
const freightRules = ref([{
label: "默认",
value: "99999999"
}]);
onLoad(async (e) => {
model.value.id = e.id;
/**
* 获取运费规则
* @returns {void}
*/
const GetfreightRules = () => {
goods.freightRules().then(res => {
freightRules.value = [
...freightRules.value,
...res.data.rows.map(item => {
return {
label: item.name,
value: item.id
};
})
];
});
};
GetfreightRules();
if (e.id > 0) {
const res = await goods.goodsItem({
id: e.id
});
model.value = res.data;
model.value.pic_list = res.data.pic_list.map(({ pic_url }) => pic_url);
if (!model.value.freight_id) {
model.value.freight_id = 99999999;
}
model.value.shop_classify_list = model.value.shop_classify_list?.map(item => JSON.stringify(item));
if (res.data.use_sku == 0) {
skuDefault.value = res.data.goods_sku;
} else {
skuLibrary.value = res.data.goods_sku;
}
skuGroup.value = res.data.sku_group ? res.data.sku_group : [];
load.value = true;
} else {
load.value = true;
}
});
/**
* 保存商品信息
* @returns {Promise<void>}
*/
const saveGoods = async () => {
//
if (model.value.shop_classify_list.length === 0) {
return uni.showToast({
title: '请选择商品分类!',
icon: 'none'
});
}
//
if (model.value.name.trim() === "") {
return uni.showToast({
title: '请输入商品名称!',
icon: 'none'
});
}
//
if (model.value.weight < 0) {
return uni.showToast({
title: '请输入合法的商品重量!',
icon: 'none'
});
}
//
if (String(model.value.pic_url).trim() === "") {
return uni.showToast({
title: '请上传商品缩略图!',
icon: 'none'
});
}
//
if (model.value.pic_list.length === 0) {
return uni.showToast({
title: '请上传商品图片组!',
icon: 'none'
});
}
model.value.sku_group = [];
model.value.sku_list = [];
model.value.dist_price = Number.parseInt(model.value.dist_price);
if (model.value.use_sku == 1) {
model.value.sku_group = skuEditRef.value.skuGroup;
model.value.sku_list = skuEditRef.value.skuLibrary;
} else {
model.value.sku_list = skuEditRef.value.skuDefault;
}
if (!model.value.sku_list.length) {
uni.showToast({
title: '规格不完整,请调整!',
icon: 'none'
});
}
if (!model.value.sku_list.every(item => Boolean(item.price !== "" && item.stock !== "" && item.original_price !== ""))) {
uni.showToast({
title: '规格不完整,请调整!',
icon: 'none'
});
return;
}
let freight_id = model.value.freight_id;
if (freight_id = 99999999) {
freight_id = 0;
}
const pic_list = model.value.pic_list.map(item => ({
pic_url: item
}));
const shop_classify_list = model.value.shop_classify_list.map(item => JSON.parse(item));
const res = await goods.goodsEdit({ ...model.value, pic_list, freight_id, shop_classify_list });
if (res.code == 0) {
uni.showToast({
title: '商品信息保存成功!',
icon: 'success'
});
uni.navigateBack();
}
};
/** @type {Ref<Array<Object>>} */
const classifyList = ref([]);
/**
* 获取商品分类
* @returns {void}
*/
const getClassify = () => {
/**
* 递归展平商品分类
* @param {Array<GoodsItem>} categories - 商品分类数组
* @param {Array<number>} [parentIds=[]] - 父级分类ID数组
* @returns {Array<Object>} - 展平后的商品分类数组
*/
function flattenCategories(categories, parentIds = []) {
let flatCategories = [];
for (const category of categories) {
const categoryWithParents = {
...category,
parentIds: [...parentIds, category.id],
};
flatCategories.push(categoryWithParents);
if (category.children && category.children.length > 0) {
flatCategories = flatCategories.concat(flattenCategories(category.children, [...parentIds, category.id]));
}
}
return flatCategories;
}
goods.classify.list().then(res => {
classifyList.value = flattenCategories(res.data);
});
};
getClassify();
</script>
<style lang="scss"></style>

@ -0,0 +1,220 @@
<template>
<view class="content">
<view class=" bg-white sticky top-0 z-50">
<wd-search @search="search" @clear="search({ value: '' })" v-model="params.keywords" hide-cancel>
<template #prefix>
<wd-popover v-model="popover" mode="menu" :content="menu" @menuclick="changeSearchType">
<view class="search-type">
<text>{{ searchType }}</text>
<wd-icon custom-class="icon-arrow" name="fill-arrow-down"></wd-icon>
</view>
</wd-popover>
</template>
</wd-search>
<wd-drop-menu custom-class="flex w-full bg-white" v-show="classifyList.length">
<wd-drop-menu-item @change="search({ value: params.keywords })" custom-class="flex-1" v-model="classify_id"
:options="classifyList" label-key="name" value-key="id" />
</wd-drop-menu>
</view>
<div class="goodsBox p-2">
<yList height="78vh" ref="yListRef" :apiObj="goods.list" :params="{ ...params, classify_id }">
<template #default="{ list }">
<div>
<div v-for="item of list" class="goods">
<wd-card type="rectangle">
<template #title>
<view class="title">
<view>库存<span class="font-bold">{{ item.stock_num || 0 }}</span></view>
<view v-if="!(item.stock_num > 0)" class="title-tip">
<wd-icon name="warning" size="14px" custom-style="vertical-align: bottom" />
商品库存不足
</view>
</view>
</template>
<view style="height: 60px;" class="content">
<image :src="item.pic_url" width="40" height="40" alt="joy"
style="border-radius: 4px; margin-right: 12px;width: 60px;height: 60px;min-width: 60px;" />
<view>
<view class="line2" style="color: rgba(0,0,0,0.85); font-size: 16px;">{{ item.name }}</view>
<view class="font-bold" style="color: rgb(255, 0, 0); font-size: 16px;">{{ item.price_min }}</view>
</view>
</view>
<template #footer>
<view>
<wd-button @click="changeS(item)" v-if="item.status == 1" size="small" plain
style="margin-right: 8px;">下架</wd-button>
<wd-button @click="changeS(item)" v-if="item.status !== 1" size="small"
style="margin-right: 8px;">上架</wd-button>
<wd-button @click="utils.toUrl('/mall/goods/edit?id=' + item.id)" size="small">编辑</wd-button>
</view>
</template>
</wd-card>
</div>
</div>
</template>
</yList>
<view class="flex mt-2 fixed left-2 right-2 bottom-3 px-10">
<wd-button @click="utils.toUrl('/mall/cat/index')" class="flex-3">分类</wd-button>
<wd-button @click="utils.toUrl('/mall/goods/edit?id=' + 0)" class="flex-1 ml-4">发布商品</wd-button>
</view>
</div>
<wd-toast />
</view>
</template>
<script setup>
import { ref } from 'vue'
import { useToast } from '@/uni_modules/wot-design-uni'
import yList from "/components/yList/index.vue"
import goods from '@/api/mall/goods.js'
import utils from '@/utils/utils.js'
import {
onLoad,
onShow
} from "@dcloudio/uni-app";
const toast = useToast()
const classify_id = ref(0)
const params = ref({
keywords: "",
status: "",
})
const yListRef = ref(null)
const search = ({ value }) => {
yListRef.value.upData({
keywords: value,
classify_id: classify_id.value,
status: params.value.status
})
}
const searchType = ref('全部')
const popover = ref(false)
const menu = ref([
{
content: '全部'
},
{
content: '已上架'
},
{
content: '已下架'
}
])
function changeSearchType({ item, index }) {
searchType.value = item.content
if (item.content == '全部') {
params.value.status = ""
}
if (item.content == '已上架') {
params.value.status = 1
}
if (item.content == '已下架') {
params.value.status = 0
}
console.log(params.value.status);
search({
value: ""
})
}
const changeS = (row) => {
goods.goodsEditAttribute({
id: row.id,
value: [1, 0][row.status],
type: "status"
}).then(res => {
if (res.code == 0) {
toast.success('操作成功')
row.status = [1, 0][row.status]
} else {
showNotify({ type: 'error', message: '出错了' })
}
})
}
const classifyList = ref([])
const getClassify = () => {
goods.classify.list().then(res => {
classifyList.value = res.data
classifyList.value.unshift({
id: 0,
name: "店铺分类"
})
})
}
getClassify()
onShow(() => {
search({ value: '' })
})
</script>
<style lang="scss" scoped>
.search-type {
position: relative;
height: 30px;
line-height: 30px;
padding: 0 8px 0 16px;
font-size: 24rpx;
color: rgba(0, 0, 0, .45);
}
.search-type::after {
position: absolute;
content: '';
width: 1px;
right: 0;
top: 5px;
bottom: 5px;
background: rgba(0, 0, 0, 0.25);
}
.search-type {
:deep(.icon-arrow) {
display: inline-block;
font-size: 20px;
vertical-align: middle;
}
}
.goodsBox {
.content,
.title {
display: flex;
flex-direction: row;
justify-content: flex-start;
align-items: center;
}
.content {
justify-content: flex-start;
}
.title {
justify-content: space-between;
}
.title-tip {
color: rgba(0, 0, 0, 0.25);
font-size: 12px;
}
}
</style>

@ -0,0 +1,298 @@
<template>
<view class="content pt-[44px]">
<kevyloading v-if="loading" type="bsm-loader" color="#618af8" transparent></kevyloading>
<view class="w-full">
<wd-navbar fixed safeAreaInsetTop :leftText="user_info?.info?.name || '商城首页'">
<template #right>
<wd-icon @click="utils.toUrl('/mall/setup/index')" name="setting" size="22px"></wd-icon>
</template>
</wd-navbar>
</view>
<view bg-color="#f7f8fa" class="w-full grid grid-cols-3 gap-3 px-3 my-4">
<view @click="utils.toUrl('/mall/cat/index')" class="text-white rounded-3xl p-4 pb-0 shadow-lg overflow-hidden"
style="background-image: linear-gradient(to top, #7ea0ff 0%, #a9bdf5 100%);">
<view class="font-bold">分类管理</view>
<view class="h-0.5 w-5 mt-0.5 bg-white"></view>
<view class="flex justify-end">
<div class="rotate-[-28deg] translate-y-3 translate-x-5">
<wd-icon name="chat opacity-80" class="opacity-80" size="42px"></wd-icon>
</div>
</view>
</view>
<view @click="utils.toUrl('/mall/goods/index')" class="text-white rounded-3xl p-4 pb-0 shadow-lg overflow-hidden"
style="background-image: linear-gradient(to top, #7ea0ff 0%, #a9bdf5 100%);">
<view class="font-bold">商品管理</view>
<view class="h-0.5 w-5 mt-0.5 bg-white"></view>
<view class="flex justify-end">
<div class="rotate-[-28deg] translate-y-3 translate-x-5">
<wd-icon name="goods opacity-80" class="opacity-80" size="42px"></wd-icon>
</div>
</view>
</view>
<view @click="utils.toUrl('/mall/order/index')" class="text-white rounded-3xl p-4 pb-0 shadow-lg overflow-hidden"
style="background-image: linear-gradient(to top, #7ea0ff 0%, #a9bdf5 100%);">
<view class="font-bold">订单管理</view>
<view class="h-0.5 w-5 mt-0.5 bg-white"></view>
<view class="flex justify-end">
<div class="rotate-[-28deg] translate-y-3 translate-x-5">
<wd-icon name="gift opacity-80" class="opacity-80" size="42px"></wd-icon>
</div>
</view>
</view>
<!-- <view @click="utils.toUrl('/mall/check/list')" class="text-white rounded-3xl p-4 pb-0 shadow-lg overflow-hidden"
style="background-image: linear-gradient(to top, #7ea0ff 0%, #a9bdf5 100%);">
<view class="font-bold">核销记录</view>
<view class="h-0.5 w-5 mt-0.5 bg-white"></view>
<view class="flex justify-end">
<div class="rotate-[-28deg] translate-y-3 translate-x-5">
<wd-icon name="phone" class="opacity-80" size="42px"></wd-icon>
</div>
</view>
</view> -->
<!-- <view @click="utils.toUrl('/mall/order/index')" class="text-white rounded-3xl p-4 pb-0 shadow-lg overflow-hidden"
style="background-image: linear-gradient(to top, #7ea0ff 0%, #a9bdf5 100%);">
<view class="font-bold">订单管理</view>
<view class="h-0.5 w-5 mt-0.5 bg-white"></view>
<view class="flex justify-end">
<div class="rotate-[-28deg] translate-y-3 translate-x-5">
<wd-icon name="gift opacity-80" size="42px"></wd-icon>
</div>
</view>
</view> -->
</view>
<view style="transition: 1s;" class="w-full h-full bg-white pt-4 rounded-tr-3xl rounded-tl-3xl shadow-lg oh">
<view class="order mb-2">
<wd-grid v-show="oneLine.ok">
<wd-grid-item @click="utils.toUrl('/mall/user/list')" icon="round" :text="`用户 (${oneLine.user_count})`" />
<wd-grid-item @click="utils.toUrl('/mall/goods/index')" icon="round" :text="`商品 (${oneLine.goods_count})`" />
<wd-grid-item @click="utils.toUrl('/mall/goods/index')" icon="round"
:text="`售罄 (${oneLine.empty_stock_count})`" />
<wd-grid-item @click="utils.toUrl('/mall/order/index')" icon="round" :text="`订单 (${oneLine.order_count})`" />
</wd-grid>
</view>
</view>
<view class="flex-1 bg-white p-2 pb-4">
<!-- <div class="name mb-2">订单数据</div> -->
<view class=" p-2 rounded-md">
<div class="rounded-md overflow-hidden">
<wd-tabs @change="getOrderProfit">
<wd-tab :title="`今天`" :name="1"></wd-tab>
<wd-tab :title="`本周`" :name="2"></wd-tab>
<wd-tab :title="`本月`" :name="3"></wd-tab>
<wd-tab :title="`本年`" :name="4"></wd-tab>
</wd-tabs>
</div>
<div class="grid grid-cols-2 gap-2 my-4">
<div @click="utils.toUrl('/mall/order/index?s=' + (index + 1))"
class="item rounded-1xl bg-slate-50 p-2 flex justify-between" style="font-size: 24rpx;"
v-for="(item, index) of orderProfit.categories">
{{ item }}
<text>{{ orderProfit.series[0].data[index] }}</text>
</div>
<div @click="utils.toUrl('/mall/afterSale/index')"
class="item rounded-1xl bg-slate-50 p-2 flex justify-between" style="font-size: 24rpx;">
售后订单
<text></text>
</div>
</div>
<bar :barData="orderProfit"></bar>
</view>
</view>
<view class="flex-1 bg-white p-2 pb-4 ">
<view class=" p-2 rounded-md">
<div class="rounded-md overflow-hidden">
<wd-tabs @change="getOrderGood">
<wd-tab :title="`今天`" :name="1"></wd-tab>
<wd-tab :title="`本周`" :name="2"></wd-tab>
<wd-tab :title="`本月`" :name="3"></wd-tab>
<wd-tab :title="`本年`" :name="4"></wd-tab>
</wd-tabs>
</div>
<div class="grid grid-cols-2 gap-2 my-4">
<div class="item rounded-1xl bg-slate-50 p-2 flex justify-between" style="font-size: 24rpx;"
v-for="(item, index) of orderGood.categories">
{{ item }}
<text>{{ orderGood.series[0].data[index] }}</text>
</div>
</div>
<bar :barData="orderGood"></bar>
</view>
</view>
<view class="bg-white h-[80px]"></view>
<view class="fixed left-2 right-2 bottom-4 z-50">
<myTabbar></myTabbar>
</view>
</view>
</template>
<script setup>
import { ref } from 'vue';
import utils from '@/utils/utils.js';
import index from '@/api/mall/index.js';
import myTabbar from "../components/myTabbar/index.vue";
import bar from "../components/bar/bar.vue";
import kevyloading from "@/components/kevy-loading/kevy-loading";
/**
* @type {Ref<boolean>}
* 控制页面加载状态的 Ref
*/
const loading = ref(false);
/**
* 从本地存储中获取用户信息
*/
const user_info = uni.getStorageSync("user_info");
/**
* @type {Ref<Object>}
* 存储一行数据的 Ref
*/
const oneLine = ref({});
/**
* 获取一行数据的函数
*/
const getOneLine = () => {
index.dataCount.oneLine().then(res => {
oneLine.value = res.data;
oneLine.value.ok = true;
});
};
//
getOneLine();
/**
* @type {Ref<Object>}
* 存储订单利润数据的 Ref
*/
const orderProfit = ref({});
/**
* 获取订单利润数据的函数
* @param {Object} e - 包含索引的对象
*/
const getOrderProfit = (e) => {
loading.value = true;
index.dataCount.orderProfit({
date: e.index + 1
}).then(res => {
if (res.code === 0) {
const statusData = res.data.reduce((obj, cur) => {
obj[cur.status] = cur;
return obj;
}, {});
const arr = [
{ name: "未付款订单", data: statusData[0]?.count || 0 },
{ name: "待发货订单", data: statusData[1]?.count || 0 },
{ name: "已发货订单", data: statusData[2]?.count || 0 },
{ name: "已完成订单", data: statusData[3]?.count || 0 },
{ name: "已取消订单", data: statusData[4]?.count || 0 }
];
orderProfit.value.categories = arr.map(item => item.name);
orderProfit.value.series = [
{ name: "订单数据", data: arr.map(item => item.data) }
];
loading.value = false;
console.log(orderProfit.value);
}
});
};
//
getOrderProfit({ index: 0 });
/**
* @type {Ref<Object>}
* 存储订单商品数据的 Ref
*/
const orderGood = ref({});
/**
* 获取订单商品数据的函数
* @param {Object} e - 包含索引的对象
*/
const getOrderGood = (e) => {
loading.value = true;
index.dataCount.orderGood({
date: e.index + 1
}).then(res => {
if (res.code === 0) {
const payTypeData = res.data.reduce((obj, cur) => {
obj[cur.pay_type] = cur;
return obj;
}, {});
const totalPrice = (
(Number(payTypeData[1]?.pay_price) || 0) +
(Number(payTypeData[2]?.pay_price) || 0) +
(Number(payTypeData[3]?.pay_price) || 0)
);
const arr = [
{ name: "总成交金额", data: totalPrice || 0 },
{ name: "支付宝支付", data: payTypeData[1]?.pay_price || 0 },
{ name: "微信支付", data: payTypeData[2]?.pay_price || 0 },
{ name: "余额支付", data: payTypeData[3]?.pay_price || 0 },
];
orderGood.value.categories = arr.map(item => item.name);
orderGood.value.series = [
{ name: "交易数据", data: arr.map(item => item.data) }
];
loading.value = false;
console.log(orderGood.value);
}
});
};
//
getOrderGood({ index: 0 });
</script>
<style lang="scss" scoped>
.content {
padding-top: 44px;
}
</style>

@ -0,0 +1,511 @@
<template>
<view class="content">
<wd-message-box></wd-message-box>
<wd-message-box selector="wd-message-box-slot" use-slot>
<view>
<wd-form :model="shipmentsModel">
<wd-cell-group border>
<view class="mb-4">
<wd-radio-group v-model="shipmentsModel.send_type" shape="button" @change="change">
<wd-radio :value="1">快递发货</wd-radio>
<wd-radio :value="2">无需物流</wd-radio>
</wd-radio-group>
</view>
<view class="mb-4 overflow-hidden bg-white border-gray-100 border-solid border-[8px] p-3 rounded"
v-if="shipmentsModel.send_type == 1">
<view class="mb-2">
<wd-radio-group shape="button" v-model="shipmentsModel.delivery_company">
<view class="flex overflow-auto">
<wd-radio v-for="item of expressList" :value="item.value">{{ item.label }}</wd-radio>
</view>
</wd-radio-group>
</view>
<wd-input label-width="100px" clearable v-model="shipmentsModel.delivery_no" placeholder="快递单号">
</wd-input>
</view>
</wd-cell-group>
</wd-form>
</view>
</wd-message-box>
<view class=" bg-white sticky top-0 z-50">
<div class="flex items-center">
<view class="flex-1">
<wd-search @search="search" @clear="search({ value: '' })" v-model="params.keywords" hide-cancel>
<template #prefix>
<wd-popover v-model="popover" mode="menu" :content="menu" @menuclick="changeSearchType">
<view class="search-type">
<text>{{ searchType }}</text>
<wd-icon custom-class="icon-arrow" name="fill-arrow-down"></wd-icon>
</view>
</wd-popover>
</template>
</wd-search>
</view>
<!-- <div class="mr-2">
<wd-button @click="utils.toUrl('/store/afterSale/index')" size="small">售后订单</wd-button>
</div> -->
</div>
<wd-tabs @change="(e) => {
params.status = e.index;
search({ value: params.keywords })
}" v-model="params.status">
<wd-tab v-for="item in status" :key="item" :title="`${item.content}`"></wd-tab>
</wd-tabs>
</view>
<view class="goodsBox p-2">
<yList ref="yListRef" :apiObj="order.orderList" :params="{ ...params, status: params.status - 1 }">
<template #default="{ list }">
<view>
<view v-for="item of list" class="goods">
<wd-card type="rectangle">
<template #title>
<view class="title">
<view>
<span class="mr-2" v-if="item.shop">{{ item.shop.name }}</span>
<span class="mr-2" v-else></span>
<span class="font-bold">({{ status[item.status + 1].content }})</span>
</view>
<view @click="utils.copy(item.order_no, '已复制单号')" class="title-tip">
<span style="font-size: 24rpx;margin-left: 8px;">单号{{ item.order_no }}</span>
</view>
</view>
</template>
<view v-for="subItem of item.details" style="height: 60px;" class="content mb-4">
<image :src="subItem.goods_pic" width="40" height="40" alt="joy"
style="border-radius: 4px; margin-right: 12px;width: 60px;height: 60px;min-width: 60px;" />
<view>
<view class="line2" style="color: rgba(0,0,0,0.85); font-size: 16px;">{{ subItem.goods_name }}</view>
<!-- <view class="font-bold" style="color: rgb(255, 0, 0); font-size: 16px;">{{ subItem.price }}
</view> -->
<view class="font-bold" style="font-size: 22rpx;">小计: {{ subItem.price }} <text
style="color: rgb(255, 0, 0); font-size: 24rpx;">({{
subItem.num }}) </text></view>
<div class="goods_sky" style="font-size: 22rpx;">
<span v-for="(sku, _index) of subItem.goods_sku_json" :key="_index">
{{ sku.group_name }}{{ sku.name }}</span>
</div>
</view>
</view>
<view class="bg-gray-50 p-2">
<view class="text-[12px]" v-if="item.user">
<view class="mb-1">
下单用户{{ item.user.nickname }}
<text class="font-bold">
( 会员ID{{ item.user.id }} )
</text>
<view class="bg-gray-100 my-2 p-2 relative">
<view>收货人{{ item.receiver_name }} &nbsp; 电话{{ item.receiver_phone }}</view>
<view v-if="item.delivery_address">{{ item.delivery_address }} {{
item.delivery_address_detail }}</view>
<view
@click="utils.copy(`收货人:${item.receiver_name} 电话:${item.receiver_phone} 收货地址:${item.delivery_address}`, '已复制快递信息')"
class="absolute right-2 top-2">
<wd-icon name="file-copy" size="14px"></wd-icon>
</view>
</view>
</view>
<view class="flex items-center" v-if='[0, 1, 2][item.delivery_type]'>配送方式:
<wd-tag class="ml-2" :type="['', 'success', 'primary'][item.delivery_type]">
{{ ["", "快递配送", "到店自提"][item.delivery_type] }}
</wd-tag>
<view class="ml-2" v-if="item.delivery_type == 1">
<wd-tag type="warning">
运费: {{ item.delivery_money }}
</wd-tag>
</view>
</view>
</view>
</view>
<template #footer>
<view class="bg-gray-50 p-2 flex justify-between" style="font-size: 22rpx;">
<view>应付: {{ (Number(item.total_price) + Number(item.delivery_money)).toFixed(2) }} </view>
<view>余额支付: {{ item.pay_balance }} </view>
<view v-if="((Number(item.total_price) + Number(item.delivery_money)) -
item.pay_price) > 0">优惠: {{ ((Number(item.total_price) + Number(item.delivery_money)) -
item.pay_price).toFixed(2) }} </view>
</view>
<view class="h-2 opacity-0 text-white">占位</view>
<view class="flex justify-between items-center">
<view class="font-bold">实付: {{ item.pay_price }} </view>
<view class="flex-1 flex justify-end">
<view v-if="item.apply_cancel === 1" class="mr-2">
<wd-button type="error" @click="orderApproval(item)" size="small">退款</wd-button>
</view>
<view class="mr-2">
<wd-button @click="printing(item)" size="small">小票打印</wd-button>
</view>
<view class="mr-2">
<wd-button @click="orderNotes(item)" size="small">备注</wd-button>
</view>
<view v-if="item.status == 1" class="">
<wd-button @click="shipments(item)" size="small">发货</wd-button>
</view>
</view>
</view>
</template>
</wd-card>
</view>
</view>
</template>
</yList>
</view>
<wd-toast />
</view>
</template>
<script setup>
import utils from '@/utils/utils.js';
import order from '@/api/mall/order.js';
import yList from "/components/yList/index.vue";
import { useMessage } from '@/uni_modules/wot-design-uni';
import { useToast } from '@/uni_modules/wot-design-uni';
import { ref, nextTick } from 'vue';
import { onLoad } from "@dcloudio/uni-app";
const message = useMessage('wd-message-box-slot');
const message1 = useMessage();
const toast = useToast();
const classify_id = ref(0);
const params = ref({
keywords: "",
status: 0,
type: 'order_no'
});
const yListRef = ref(null);
const search = ({ value }) => {
yListRef.value.upData({
keywords: value,
classify_id: classify_id.value,
status: params.value.status - 1
});
};
onLoad(({ s } = {}) => {
if (s) {
params.value.status = Number(s)
}
})
const searchType = ref('订单编号');
const popover = ref(false);
const status = ref([
{ content: '全部' },
{ content: '未付款' },
{ content: '待发货' },
{ content: '已发货' },
{ content: '已完成' },
{ content: '已取消' },
{ content: '待处理' },
{ content: '回收站' }
]);
const menu = ref([
{ content: '订单编号' },
{ content: '商品名称' },
{ content: '手机号' },
{ content: '会员昵称' },
{ content: '收货人' },
]);
/**
* 切换搜索类型
* @param {Object} item - 切换的项
*/
function changeSearchType({ item, index }) {
searchType.value = item.content;
if (item.content == '订单编号') {
params.value.type = "order_no";
}
if (item.content == '商品名称') {
params.value.type = "goods_name";
}
if (item.content == '手机号') {
params.value.type = "receiver_phone";
}
if (item.content == '会员昵称') {
params.value.type = "nickname";
}
if (item.content == '收货人') {
params.value.type = "receiver_name";
}
}
/**
* 更改状态
* @param {Object} row - 行数据
*/
const changeS = (row) => {
//
// goods.goodsEditAttribute({
// id: item.id,
// value: [1, 0][item.status],
// type: "status"
// }).then(res => {
// if (res.code == 0) {
// toast.success('')
// item.status = [1, 0][item.status]
// } else {
// showNotify({ type: 'error', message: '' })
// }
// })
};
const expressList = ref([]);
/**
* 获取物流公司列表
*/
const getExpressList = () => {
order.GetExpressList().then(res => {
expressList.value = Object.entries(res.data).reduce((express, item) => {
express.push({ label: item[1], value: item[0] });
return express;
}, []);
});
};
//
getExpressList();
const shipmentsModel = ref({
send_type: 2,
delivery_company: ""
});
/**
* 处理发货操作
* @param {Object} row - 行数据
*/
const shipments = (row) => {
message
.confirm({
title: '订单发货',
})
.then((resp) => {
if (shipmentsModel.value.send_type == 2) {
order.orderSend({
id: row.id,
send_type: "2"
});
row.status = 2;
toast.success('操作成功');
setTimeout(() => {
shipmentsModel.value = {
send_type: 2,
delivery_company: ""
};
}, 300);
}
if (shipmentsModel.value.send_type == 1) {
if (shipmentsModel.value.delivery_company && shipmentsModel.value.delivery_no) {
order.orderSend({
id: row.id,
send_type: "1",
delivery_company: shipmentsModel.value.delivery_company,
delivery_no: shipmentsModel.value.delivery_no,
});
row.status = 2;
row.success('操作成功');
setTimeout(() => {
shipmentsModel.value = {
send_type: 2,
delivery_company: ""
};
}, 300);
} else {
toast.error('发货失败,请完善选择填写');
shipments(row);
}
}
})
.catch((error) => {
console.log(error);
setTimeout(() => {
shipmentsModel.value = {
send_type: 2,
delivery_company: ""
};
}, 300);
});
};
/**
* 处理打印小票操作
* @param {Object} row - 行数据
*/
const printing = (row) => {
message1
.confirm({
title: '打印小票',
})
.then((resp) => {
order.printOrder({
id: row.id,
send_type: "2"
}).then(res => {
if (res.code == 0) {
toast.success('调用成功');
} else {
toast.error('调用失败');
}
});
})
.catch((error) => {
console.log(error);
});
};
/**
* 处理订单备注操作
* @param {Object} row - 行数据
*/
const orderNotes = (row) => {
message1
.prompt({
title: '订单备注',
})
.then((resp) => {
order.updateNotes({
id: row.id,
notes: resp.value
}).then(res => {
if (res.code == 0) {
toast.success('操作成功');
} else {
toast.error('操作失败');
}
});
})
.catch((error) => {
console.log(error);
});
};
/**
* 处理退款审批操作
* @param {Object} row - 行数据
*/
const orderApproval = (row) => {
message1
.confirm({
title: '退款审批',
confirmButtonText: "同意",
cancelButtonText: "拒绝",
})
.then((resp) => {
order.confirmCancel({
id: row.id,
apply_cancel_notes: "同意",
handle_status: 1
}).then(res => {
if (res.code == 0) {
toast.success('操作成功');
row.apply_cancel = 0;
} else {
toast.error('操作失败');
}
});
})
.catch((error) => {
if (error.action == 'cancel') {
order.confirmCancel({
id: row.id,
apply_cancel_notes: "拒绝",
handle_status: 0
}).then(res => {
if (res.code == 0) {
toast.success('操作成功');
row.apply_cancel = 0;
} else {
toast.error('操作失败');
}
});
}
});
};
</script>
<style lang="scss" scoped>
.search-type {
position: relative;
height: 30px;
line-height: 30px;
padding: 0 8px 0 16px;
font-size: 24rpx;
color: rgba(0, 0, 0, .45);
}
.search-type::after {
position: absolute;
content: '';
width: 1px;
right: 0;
top: 5px;
bottom: 5px;
background: rgba(0, 0, 0, 0.25);
}
.search-type {
:deep(.icon-arrow) {
display: inline-block;
font-size: 20px;
vertical-align: middle;
}
}
.goodsBox {
.content,
.title {
display: flex;
flex-direction: row;
justify-content: flex-start;
align-items: center;
}
.content {
justify-content: flex-start;
}
.title {
justify-content: space-between;
}
.title-tip {
color: rgba(0, 0, 0, 0.25);
font-size: 12px;
}
}
</style>

@ -65,6 +65,18 @@
}
}
},
{
"path": "inpersonPay/index",
"style": {
"navigationBarTitleText": "当面付订单",
"enablePullDownRefresh": false,
"mp-alipay": {
"transparentTitle": "always",
"titlePenetrate": "YES",
"gestureBack": "YES"
}
}
},
{
"path": "afterSale/index",
"style": {
@ -234,6 +246,95 @@
}
}
]
},
{
"root": "mall",
"pages": [
{
"path": "index/index",
"style": {
"navigationBarTitleText": "门店首页",
"enablePullDownRefresh": false,
"mp-alipay": {
"transparentTitle": "always",
"titlePenetrate": "YES",
"gestureBack": "YES"
}
}
},
{
"path": "goods/index",
"style": {
"navigationBarTitleText": "商品管理",
"enablePullDownRefresh": false,
"mp-alipay": {
"transparentTitle": "always",
"titlePenetrate": "YES",
"gestureBack": "YES"
}
}
},
{
"path": "goods/edit",
"style": {
"navigationBarTitleText": "修改商品",
"enablePullDownRefresh": false,
"mp-alipay": {
"transparentTitle": "always",
"titlePenetrate": "YES",
"gestureBack": "YES"
}
}
},
{
"path": "cat/index",
"style": {
"navigationBarTitleText": "分类管理",
"enablePullDownRefresh": false,
"mp-alipay": {
"transparentTitle": "always",
"titlePenetrate": "YES",
"gestureBack": "YES"
}
}
},
{
"path": "cat/edit",
"style": {
"navigationBarTitleText": "分类编辑",
"enablePullDownRefresh": false,
"mp-alipay": {
"transparentTitle": "always",
"titlePenetrate": "YES",
"gestureBack": "YES"
}
}
},
{
"path": "check/list",
"style": {
"navigationBarTitleText": "核销记录",
"enablePullDownRefresh": false,
"mp-alipay": {
"transparentTitle": "always",
"titlePenetrate": "YES",
"gestureBack": "YES"
}
}
},
{
"path": "order/index",
"style": {
"navigationBarTitleText": "订单管理",
"enablePullDownRefresh": false,
"mp-alipay": {
"transparentTitle": "always",
"titlePenetrate": "YES",
"gestureBack": "YES"
}
}
}
]
}
],
"globalStyle": {

@ -11,6 +11,10 @@ if (token) {
const user_info = uni.getStorageSync("user_info");
if (user_info.type == 1) {
utils.toUrl("/store/index/index", "redirectTo")
} else if (user_info.type == 3) {
utils.toUrl("/mall/index/index", "redirectTo")
} else {
}
} else {
utils.toUrl("/pages/login/index", "redirectTo")

@ -59,6 +59,8 @@ function handleSubmit() {
if (res.data.user_info.type == 1) {
utils.toUrl("/store/index/index", "redirectTo")
} else if (res.data.user_info.type == 3) {
utils.toUrl("/mall/index/index", "redirectTo")
} else {
uni.showToast({
title: '登录平台开发中 ···',

@ -24,7 +24,7 @@
</view>
</view>
<view @click="utils.toUrl('/store/user/memberList')"
<!-- <view @click="utils.toUrl('/store/user/memberList')"
class="text-white rounded-3xl p-4 pb-0 shadow-lg overflow-hidden"
style="background-image: linear-gradient(to top, #7ea0ff 0%, #a9bdf5 100%);">
<view class="font-bold">等级管理</view>
@ -35,7 +35,7 @@
<wd-icon name="layers opacity-80" class="opacity-80" size="42px"></wd-icon>
</div>
</view>
</view>
</view> -->
<view @click="utils.toUrl('/store/cat/index')" class="text-white rounded-3xl p-4 pb-0 shadow-lg overflow-hidden"
style="background-image: linear-gradient(to top, #7ea0ff 0%, #a9bdf5 100%);">
@ -85,6 +85,20 @@
</view>
</view>
<view @click="utils.toUrl('/store/inpersonPay/index')"
class="text-white rounded-3xl p-4 pb-0 shadow-lg overflow-hidden"
style="background-image: linear-gradient(to top, #7ea0ff 0%, #a9bdf5 100%);">
<view class="font-bold">当面付订单</view>
<view class="h-0.5 w-5 mt-0.5 bg-white"></view>
<view class="flex justify-end">
<div class="rotate-[-28deg] translate-y-3 translate-x-5">
<wd-icon name="phone" class="opacity-80" size="42px"></wd-icon>
</div>
</view>
</view>

@ -0,0 +1,289 @@
<template>
<view class="content">
<view class=" bg-white sticky top-0 z-50">
<div class="flex items-center">
<view class="flex-1">
<wd-search @search="search" @clear="search({ value: '' })" v-model="params.keywords" hide-cancel>
<template #prefix>
<wd-popover v-model="popover" mode="menu" :content="menu" @menuclick="changeSearchType">
<view class="search-type">
<text>{{ searchType }}</text>
<wd-icon custom-class="icon-arrow" name="fill-arrow-down"></wd-icon>
</view>
</wd-popover>
</template>
</wd-search>
</view>
<div v-if="getQrItem.img_url" class="mr-2">
<wd-button @click="showImg = true" size="small">付款码</wd-button>
</div>
</div>
<wd-tabs @change="(e) => {
params.status = (e.index == 3 ? 5 : e.index);
search({ value: params.keywords })
}" v-model="params.status">
<wd-tab v-for="item in status" :key="item" :title="`${item.content}`"></wd-tab>
</wd-tabs>
</view>
<view class="goodsBox p-2">
<yList ref="yListRef" :apiObj="order.OrderInpersonPayment.orderList"
:params="{ ...params, status: params.status - 1 }">
<template #default="{ list }">
<view>
<view v-for="item of list" class="goods">
<wd-card type="rectangle">
<template #title>
<view class="title">
<view>
<span class="mr-2">用户{{ item?.user?.nickname }}</span>
</view>
<view @click="utils.copy(item.order_no, '已复制单号')" class="title-tip">
<span style="font-size: 24rpx;margin-left: 8px;">单号{{ item.order_no }}</span>
</view>
</view>
</template>
<view class="bg-gray-50 p-2 mb-2 flex justify-between" style="font-size: 22rpx;">
<view>原价<text class="text-red-600"> {{ item.total_price || 0 }}</text></view>
<view>支付金额<text class="text-red-600"> {{ item.pay_price || 0 }}</text></view>
<view>
支付方式
<text class="text-black">
{{ [
"", "支付宝", "微信", "余额", "货到付款", "先就餐后支付"
][item.pay_type] }}
</text>
</view>
</view>
<template #footer>
<!-- <view class="bg-gray-50 p-2 mb-2.5 flex justify-between" style="font-size: 22rpx;">
<view>
售后状态:
</view>
</view> -->
<view class="flex justify-between items-center">
<!-- <view class="font-bold">实付: {{ item.pay_price }} </view> -->
<view>
支付状态<wd-button :round="false" size="small"
:type="['warning', 'success', 'warning', 'success', 'info'][item.status]">
<div>{{ ["未支付", "已支付", "已取消"][item.status] || "已取消" }}</div>
</wd-button>
</view>
<view class="flex-1 flex justify-end">
<!-- <view v-if="item.apply_cancel === 1" class="mr-2">
<wd-button type="error" @click="orderApproval(item)" size="small">退款</wd-button>
</view>
<view class="mr-2">
<wd-button @click="printing(item)" size="small">小票打印</wd-button>
</view>
<view class="mr-2">
<wd-button @click="orderNotes(item)" size="small">备注</wd-button>
</view>
<view v-if="item.status == 1" class="">
<wd-button @click="shipments(item)" size="small">发货</wd-button>
</view> -->
</view>
</view>
</template>
</wd-card>
</view>
</view>
</template>
</yList>
</view>
<wd-toast />
<wd-curtain v-if="getQrItem.img_url" :value="showImg" :src="getQrItem.img_url" :to="'/store/inpersonPay/index'"
@close="showImg = false" close-position="top" width="280"></wd-curtain>
</view>
</template>
<script setup>
import utils from '@/utils/utils.js';
import order from '@/api/store/order.js';
import yList from "/components/yList/index.vue";
import { useMessage } from '@/uni_modules/wot-design-uni';
import { useToast } from '@/uni_modules/wot-design-uni';
import { ref } from 'vue';
const message = useMessage('wd-message-box-slot');
const message1 = useMessage();
const toast = useToast();
const showImg = ref(false)
let afterType = 1
/**
* 处理订单备注操作
* @param {Object} row - 行数据
*/
const orderNotes = (row, text) => {
message1
.prompt({
title: text,
inputValue: row.refund_amount
})
.then((resp) => {
order.after_sale.update({
id: row.id,
status: 5,
refund_amount: resp.value,
refund_type: afterType,
shop_description: 1,
}).then(res => {
if (res.code == 0) {
toast.success('操作成功');
row.status = 5;
} else {
toast.error('操作失败');
}
});
})
.catch((error) => {
console.log(error);
});
};
const classify_id = ref(0);
const params = ref({
keywords: "",
status: "",
type: 'order_no'
});
const yListRef = ref(null);
const search = ({ value }) => {
yListRef.value.upData({
keywords: value,
classify_id: classify_id.value,
status: params.value.status - 1
});
};
const searchType = ref('订单编号');
const popover = ref(false);
const status = ref([
{ content: '全部' },
{ content: '未支付' },
{ content: '已支付' },
{ content: '已取消' },
]);
const menu = ref([
{ content: '订单编号' },
{ content: '商品名称' },
{ content: '手机号' },
{ content: '会员昵称' },
{ content: '收货人' },
]);
/**
* 切换搜索类型
* @param {Object} item - 切换的项
*/
function changeSearchType({ item, index }) {
searchType.value = item.content;
if (item.content == '订单编号') {
params.value.type = "order_no";
}
if (item.content == '商品名称') {
params.value.type = "goods_name";
}
if (item.content == '手机号') {
params.value.type = "receiver_phone";
}
if (item.content == '会员昵称') {
params.value.type = "nickname";
}
if (item.content == '收货人') {
params.value.type = "receiver_name";
}
}
const getQrItem = ref({});
/**
* 获取物流公司列表
*/
const getGetQrItem = () => {
order.OrderInpersonPayment.GetQrItem().then(res => {
getQrItem.value = res.data
});
};
//
getGetQrItem();
</script>
<style lang="scss" scoped>
.search-type {
position: relative;
height: 30px;
line-height: 30px;
padding: 0 8px 0 10px;
font-size: 22rpx;
color: rgba(0, 0, 0, .45);
}
.search-type::after {
position: absolute;
content: '';
width: 1px;
right: 0;
top: 5px;
bottom: 5px;
background: rgba(0, 0, 0, 0.25);
}
.search-type {
:deep(.icon-arrow) {
display: inline-block;
font-size: 20px;
vertical-align: middle;
}
}
.goodsBox {
.content,
.title {
display: flex;
flex-direction: row;
justify-content: flex-start;
align-items: center;
}
.content {
justify-content: flex-start;
}
.title {
justify-content: space-between;
}
.title-tip {
color: rgba(0, 0, 0, 0.25);
font-size: 12px;
}
}
</style>

@ -24,7 +24,6 @@
</div>
<div class="z-20 relative">
<div class="flex items-center">
<view>
<wd-badge custom-class="badge" type="primary" :modelValue="`v${member.level}`">
@ -34,11 +33,9 @@
style="width: 60px;height: 60px;min-width: 60px;border-radius: 100px; " />
</view>
</wd-badge>
</view>
<view>
<view class="ml-4 px-4 py-2 rounded-3xl mb-1 inline-flex text-white" :class="gradients[index]"
style="font-size: 24rpx; ">
<view class="ml-4 px-4 py-2 rounded-3xl mb-1 inline-flex text-white" style="font-size: 24rpx; ">
{{ member.name }} {{ member.price }}
</view>
<view class="ml-4 rounded" style="font-size: 22rpx; ">
@ -88,7 +85,7 @@
</view>
</template>
<view class="bg-gray-50 p-2 mb-2.5 flex justify-between" style="font-size: 22rpx;">
<view class="bg-gray-50 p-2 mb-2 flex justify-between" style="font-size: 22rpx;">
<view>状态
<el-tag type="primary" v-if="user.status == 1"></el-tag>
<el-tag v-else></el-tag>
@ -96,14 +93,16 @@
<view>折扣商品{{ user?.goods_list?.length || 0 }} </view>
</view>
<view class="bg-gray-50 p-2 flex justify-between" style="font-size: 22rpx;">
<view>优惠时间
<wd-tag type="primary">{{ utils.dateFormat(user.start_time * 1000) }}</wd-tag> - <wd-tag>{{
utils.dateFormat(user.end_time * 1000) }}</wd-tag>
</view>
</view>
<template #footer>
<view class="bg-gray-50 p-2 mb-2.5 flex justify-between" style="font-size: 22rpx;">
<view>优惠时间
<wd-tag type="primary">{{ utils.dateFormat(user.start_time * 1000) }}</wd-tag> - <wd-tag>{{
utils.dateFormat(user.end_time * 1000) }}</wd-tag>
</view>
</view>
<view class="flex justify-between items-center">
<view></view>

Loading…
Cancel
Save