同步代码
This commit is contained in:
253
pageCategory/index/components/category.vue
Normal file
253
pageCategory/index/components/category.vue
Normal file
@@ -0,0 +1,253 @@
|
||||
<template>
|
||||
<view class=" goods">
|
||||
|
||||
<view class=" u-flex">
|
||||
<view v-if="showChecked">
|
||||
<label class="radio">
|
||||
<radio :color="ColorMain" style="transform: scale(0.7);" @click="radioClick"
|
||||
:checked="data.checked" /><text></text>
|
||||
</label>
|
||||
</view>
|
||||
<up-image width="126rpx" height="126rpx" :src="data.pic" :radius="6"></up-image>
|
||||
<!-- <image mode="aspectFill" :src="data.pic" class="img"></image> -->
|
||||
<view class=" u-p-l-16 u-flex u-p-r-16 u-flex-1 u-col-top">
|
||||
<view class="u-flex-1">
|
||||
<view class="color-333 font-bold">{{data.name}}</view>
|
||||
<view class="color-999 u-m-t-20">
|
||||
<text class="">排序:</text>
|
||||
<text class="u-m-l-10">{{data.sort}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-flex">
|
||||
<text class="u-font-28 color-666" @click="changeClick">修改排序</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="u-m-t-24 u-flex u-row-between">
|
||||
<view>
|
||||
<!-- <template v-if="data.childrenList.length">
|
||||
<view class="u-flex color-999 u-flex u-col-center" @tap="useTypeClick">
|
||||
<text class="u-font-24">{{computedUserType}} </text>
|
||||
<view class="u-flex">
|
||||
<uni-icons type="right" color="#999"></uni-icons>
|
||||
</view>
|
||||
</view>
|
||||
</template> -->
|
||||
<view class="u-flex">
|
||||
<view class="u-m-r-18 color-999">是否启用</view>
|
||||
<my-switch v-model="isShow" @change="isShowChange"></my-switch>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-m-t-24 u-flex u-row-right">
|
||||
<view class="btn-default btn" @click="del">删除</view>
|
||||
<view class="btn-primary btn u-m-l-38" @click="toEdit">编辑</view>
|
||||
</view>
|
||||
<!-- <view class="u-flex no-wrap">
|
||||
<view class="btn-default btn" @click="del">删除</view>
|
||||
<view class="btn-primary btn u-m-l-38" @click="toEdit">编辑</view>
|
||||
</view> -->
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
computed,
|
||||
ref,
|
||||
watch,
|
||||
watchEffect
|
||||
} from 'vue';
|
||||
import mySwitch from '@/components/my-components/my-switch.vue'
|
||||
import go from '@/commons/utils/go.js';
|
||||
import {
|
||||
ColorMain
|
||||
} from '@/commons/color.js'
|
||||
|
||||
const emits = defineEmits(['radioClick', 'changeClick', 'useTypeClick', 'del', 'isShowChange'])
|
||||
|
||||
const props = defineProps({
|
||||
index: {
|
||||
type: Number
|
||||
},
|
||||
data: {
|
||||
type: Object,
|
||||
default: () => {
|
||||
return {
|
||||
isShow: true
|
||||
}
|
||||
}
|
||||
},
|
||||
showChecked: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
})
|
||||
let isShow = ref(props.data.isShow)
|
||||
watch(() => props.data.isShow, (newval) => {
|
||||
isShow.value = newval
|
||||
})
|
||||
|
||||
function isShowChange() {
|
||||
console.log(isShow.value);
|
||||
emits('isShowChange', {
|
||||
...props.data,
|
||||
isShow: isShow.value
|
||||
})
|
||||
}
|
||||
const computedUserType = computed(() => {
|
||||
const len = props.data.useTypes.length
|
||||
const openArr = props.data.useTypes.filter(v => v.isOpen)
|
||||
if (openArr.length <= 0) {
|
||||
return '全部隐藏'
|
||||
}
|
||||
if (openArr.length >= len) {
|
||||
return '全部显示'
|
||||
}
|
||||
let openStr = openArr.reduce((prve, cur) => {
|
||||
return prve + cur.name + '、'
|
||||
}, '')
|
||||
return '显示(' + openStr.slice(0, -1) + ')'
|
||||
})
|
||||
|
||||
let isSellNone = ref(true)
|
||||
isSellNone.value = props.isSellNone
|
||||
|
||||
function isSellNoneChange() {
|
||||
console.log(isSellNone.value);
|
||||
console.log('isSellNoneChange');
|
||||
}
|
||||
|
||||
let checked = ref(false)
|
||||
|
||||
function radioClick() {
|
||||
console.log(props.index);
|
||||
emits('radioClick', props.index)
|
||||
}
|
||||
|
||||
function changeClick() {
|
||||
emits('changeClick', props.index)
|
||||
}
|
||||
|
||||
function useTypeClick() {
|
||||
emits('useTypeClick', props.index)
|
||||
}
|
||||
|
||||
function del() {
|
||||
emits('del', props.index)
|
||||
}
|
||||
|
||||
//携带参数type edit跳转到商品添加页面,编辑与添加同一页面,根据type值来判断
|
||||
function toEdit() {
|
||||
uni.setStorageSync('cateItem', props.data)
|
||||
go.to('PAGES_CATEGORY_EDIT', {
|
||||
type: 'edit',
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
$imgSize: 126rpx;
|
||||
$price-color: #F02C45;
|
||||
|
||||
.btn {
|
||||
padding: 6rpx 28rpx;
|
||||
border-radius: 100rpx;
|
||||
font-size: 24rpx;
|
||||
border: 1px solid transparent;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
border-color: $my-main-color;
|
||||
color: $my-main-color;
|
||||
}
|
||||
|
||||
.btn-default {
|
||||
border-color: #999;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.price {
|
||||
color: $price-color;
|
||||
}
|
||||
|
||||
.h-100 {
|
||||
height: $imgSize;
|
||||
}
|
||||
|
||||
.img {
|
||||
width: $imgSize;
|
||||
height: $imgSize;
|
||||
}
|
||||
|
||||
.icon-arrow-right {
|
||||
width: 32rpx;
|
||||
height: 32rpx;
|
||||
}
|
||||
|
||||
.stock {
|
||||
padding-right: 46rpx;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.stock::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
right: 10rpx;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
display: block;
|
||||
width: 16rpx;
|
||||
border: 2rpx solid #333333;
|
||||
}
|
||||
|
||||
.goods {
|
||||
border-radius: 10rpx 10rpx 10rpx 10rpx;
|
||||
background-color: #fff;
|
||||
padding: 24rpx 28rpx 16rpx 28rpx;
|
||||
font-size: 28rpx;
|
||||
|
||||
.skus {
|
||||
background: #F9F9F9;
|
||||
border-radius: 14rpx 14rpx 14rpx 14rpx;
|
||||
padding: 28rpx 42rpx;
|
||||
|
||||
.sku {
|
||||
color: #000;
|
||||
font-weight: 700;
|
||||
padding: 6rpx 40rpx;
|
||||
}
|
||||
|
||||
.skds {
|
||||
gap: 10rpx 50rpx;
|
||||
}
|
||||
|
||||
.skd {
|
||||
padding: 14rpx 40rpx;
|
||||
background: #F0F2F5;
|
||||
border-radius: 4rpx;
|
||||
position: relative;
|
||||
color: #666;
|
||||
overflow: hidden;
|
||||
|
||||
.tag {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
top: 0;
|
||||
font-size: 12rpx;
|
||||
right: 0;
|
||||
padding: 2rpx 4rpx;
|
||||
border-radius: 0rpx 4rpx 4rpx 4rpx;
|
||||
}
|
||||
|
||||
.tag-primary {
|
||||
background-color: $my-main-color;
|
||||
color: #fff;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
</style>
|
||||
414
pageCategory/index/index - 副本.vue
Normal file
414
pageCategory/index/index - 副本.vue
Normal file
@@ -0,0 +1,414 @@
|
||||
<template>
|
||||
<view class="safe-page">
|
||||
<view class="goods-list u-p-30">
|
||||
<view class="u-m-b-32" v-for="(item,index) in pageData.list" :key="index">
|
||||
<my-category
|
||||
@del="categoryDel"
|
||||
@useTypeClick="categoryUseTypeClick"
|
||||
@changeClick="goodsChangeClick"
|
||||
@radioClick="goodsRadioClick"
|
||||
:index="index" :data="item"
|
||||
:showChecked="showChecked"
|
||||
:showDetail="pageData.showGoodsDetail"></my-category>
|
||||
</view>
|
||||
<view class="u-m-t-44">
|
||||
<my-pagination :size="pageData.query.size" :totalElements="pageData.totalElements" @change="pageChange"></my-pagination>
|
||||
<view style="height: 200rpx;"></view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 删除弹窗 -->
|
||||
<my-model desc="请确保此分类下没有任何商品确认删除?" ref="delModel" @confirm="delModelConfirm"></my-model>
|
||||
|
||||
<!-- 分类修改排序弹窗 -->
|
||||
<my-model ref="goodsSortModel" title="修改排序" @close="goodsSortModelClose">
|
||||
<template #desc>
|
||||
<view class="u-p-40 u-text-left">
|
||||
<view>
|
||||
<view class="">排序:</view>
|
||||
<view class="u-m-t-24">
|
||||
<uni-easyinput v-model="sort" placeholder="请输入排序"></uni-easyinput>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</template>
|
||||
<template #btn>
|
||||
<view class="stock-btns u-p-b-40">
|
||||
<my-button shape="circle" @tap="goodsSortModelSave">确认修改</my-button>
|
||||
<my-button shape="circle" type="default" @tap="goodsSortModelCancel">取消</my-button>
|
||||
</view>
|
||||
</template>
|
||||
</my-model>
|
||||
<!-- 分类修改排序弹窗 -->
|
||||
<my-model mode="bottom" ref="goodsTypeModel" :title="goodsTypeModelData.title" >
|
||||
<template #desc>
|
||||
<view class="u-p-30 u-m-t-30">
|
||||
<view class="u-flex u-m-b-20 u-row-between u-p-t-10 u-p-b-10" v-for="(item,index) in goodsTypeModelData.useTypes" :key="index">
|
||||
<view class="font-bold color-000">{{item.name}}</view>
|
||||
<my-switch v-model="item.isOpen"></my-switch>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</template>
|
||||
<template #btn>
|
||||
<view class="u-flex gap-20 u-p-30 u-p-b-40 ">
|
||||
<view class="u-flex-1">
|
||||
<my-button shape="circle" color="#000" type="default" @tap="hideAllUseTypes">一键隐藏</my-button>
|
||||
</view>
|
||||
<view class="u-flex-1">
|
||||
<my-button shape="circle" @tap="showAllUseTypes">一键显示</my-button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
</my-model>
|
||||
|
||||
<view class="fixed-b">
|
||||
<my-button :height="80" shape="circle" showShadow @tap="toAddCategory">新建分类</my-button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
reactive, ref, watch
|
||||
} from 'vue';
|
||||
import {onShow} from '@dcloudio/uni-app'
|
||||
import go from '@/commons/utils/go.js';
|
||||
import myCategory from './components/category.vue'
|
||||
import infoBox from "@/commons/utils/infoBox.js"
|
||||
import myPagination from '@/components/my-components/my-pagination.vue'
|
||||
import myModel from "@/components/my-components/my-model.vue"
|
||||
import myButton from "@/components/my-components/my-button.vue"
|
||||
import mySwitch from "@/components/my-components/my-switch.vue"
|
||||
import {$productCategory} from '@/http/yskApi/goods.js'
|
||||
|
||||
|
||||
const tabsList = ['简洁', '详情']
|
||||
const statesTabsList = ['在售中', '已下架']
|
||||
const states1TabsList = ['全部', '已售罄']
|
||||
const control=ref(null)
|
||||
const delModel=ref(null)
|
||||
const goodsSortModel=ref(null)
|
||||
const goodsTypeModel=ref(null)
|
||||
let sort=ref(0)
|
||||
const goodsTypeModelData=reactive({
|
||||
title:'',
|
||||
index:null,
|
||||
useTypes:[
|
||||
{name:'堂食',isOpen:true},
|
||||
{name:'自取',isOpen:true},
|
||||
{name:'外卖',isOpen:true},
|
||||
{name:'快递',isOpen:true}
|
||||
]
|
||||
})
|
||||
const pageData = reactive({
|
||||
stateCurrent:0,
|
||||
stateCurrent1:0,
|
||||
componentBottom:264,
|
||||
search: {
|
||||
value: '',
|
||||
placeholder: '输入搜索的商品'
|
||||
},
|
||||
showGoodsDetail:false,
|
||||
query:{
|
||||
page: 0,
|
||||
size:10
|
||||
},
|
||||
totalElements:0,
|
||||
list:[]
|
||||
|
||||
})
|
||||
|
||||
async function init() {
|
||||
const res=await $productCategory.get(pageData.query)
|
||||
pageData.list=res.content.map(v=>{
|
||||
return {
|
||||
...v,
|
||||
isSellNone:false,
|
||||
checked:false,
|
||||
showDetail:false,
|
||||
useTypes:[
|
||||
{name:'堂食',isOpen:true},
|
||||
{name:'自取',isOpen:true},
|
||||
{name:'外卖',isOpen:true},
|
||||
{name:'快递',isOpen:true}
|
||||
]
|
||||
}
|
||||
})
|
||||
pageData.totalElements=res.totalElements
|
||||
}
|
||||
onShow(()=>{
|
||||
init()
|
||||
})
|
||||
function toAddCategory(){
|
||||
go.to('PAGES_CATEGORY_EDIT',{type:'add'})
|
||||
}
|
||||
|
||||
function hideAllUseTypes(){
|
||||
goodsTypeModelData.useTypes.map(v=>{
|
||||
v.isOpen=false
|
||||
})
|
||||
pageData.list[goodsTypeModelData.index].useTypes.map(v=>{
|
||||
v.isOpen=false
|
||||
})
|
||||
}
|
||||
|
||||
function showAllUseTypes(){
|
||||
goodsTypeModelData.useTypes.map(v=>{
|
||||
v.isOpen=true
|
||||
})
|
||||
pageData.list[goodsTypeModelData.index].useTypes.map(v=>{
|
||||
v.isOpen=true
|
||||
})
|
||||
}
|
||||
|
||||
function goodsSortModelCancel(){
|
||||
console.log('goodsSortModelCancel');
|
||||
goodsSortModel.value.close()
|
||||
}
|
||||
function goodsSortModelSave(){
|
||||
console.log('goodsSortModelSave');
|
||||
// $productCategory.update()
|
||||
}
|
||||
|
||||
|
||||
function categoryUseTypeClick(index){
|
||||
goodsTypeModelData.index=index
|
||||
goodsTypeModelData.useTypes=pageData.list[index].useTypes
|
||||
goodsTypeModel.value.open()
|
||||
}
|
||||
|
||||
|
||||
//点击修改按钮弹出修改商品弹窗
|
||||
function goodsChangeClick(index){
|
||||
console.log(index);
|
||||
sort.value=pageData.list[index].sort
|
||||
goodsSortModel.value.open()
|
||||
}
|
||||
|
||||
function statesTableClick(index){
|
||||
pageData.stateCurrent=index
|
||||
}
|
||||
function states1TableClick(index){
|
||||
pageData.stateCurrent1=index
|
||||
}
|
||||
|
||||
let test=ref(false)
|
||||
|
||||
function tabsChange(i) {
|
||||
console.log(i);
|
||||
pageData.showGoodsDetail=i?true:false
|
||||
}
|
||||
|
||||
|
||||
//改变商品的选中状态
|
||||
function changeGoodsChecked(checked,index){
|
||||
if(index!==undefined){
|
||||
pageData.list[index].checked=checked
|
||||
}else{
|
||||
pageData.list.map(v=>{
|
||||
v.checked=checked
|
||||
})
|
||||
}
|
||||
control.value.setisSelectAll(isAllChecked()?true:false)
|
||||
}
|
||||
|
||||
|
||||
// 获取已经选中的商品
|
||||
function getChechkedlist(){
|
||||
return pageData.list.filter(v=>v.checked)
|
||||
}
|
||||
//是否全部选中
|
||||
function isAllChecked(){
|
||||
return getChechkedlist().length===pageData.list.length
|
||||
}
|
||||
// 是否有商品选中
|
||||
function isHasChekdGoods(){
|
||||
return getChechkedlist().length?true:false
|
||||
}
|
||||
|
||||
function searchFunc() {
|
||||
console.log('searchFunc');
|
||||
}
|
||||
|
||||
let showChecked=ref(false)
|
||||
|
||||
//商品start
|
||||
|
||||
function goodsRadioClick(index){
|
||||
var checked=!pageData.list[index].checked
|
||||
changeGoodsChecked(checked,index)
|
||||
}
|
||||
|
||||
|
||||
//下架
|
||||
function offShelf(){
|
||||
const hasCheckedArr=getChechkedlist()
|
||||
const hasChecked=isHasChekdGoods()
|
||||
if(!hasChecked){
|
||||
return infoBox.showToast('您还没有选中商品!')
|
||||
}
|
||||
model.value.open()
|
||||
}
|
||||
let nowCateIndex=null
|
||||
function categoryDel(index){
|
||||
nowCateIndex=index
|
||||
delModel.value.open()
|
||||
}
|
||||
//删除分类确认
|
||||
function delModelConfirm(){
|
||||
console.log('confirm');
|
||||
pageData.list.splice(nowCateIndex,1)
|
||||
delModel.value.close()
|
||||
}
|
||||
|
||||
//商品end
|
||||
|
||||
//控制条
|
||||
function controlChange(bol){
|
||||
console.log(bol);
|
||||
showChecked.value=bol
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 全选
|
||||
function allCheckedChange(checked){
|
||||
changeGoodsChecked(checked)
|
||||
}
|
||||
|
||||
// 页数改变事件
|
||||
function pageChange(page) {
|
||||
pageData.query.page=page-1
|
||||
init()
|
||||
}
|
||||
|
||||
|
||||
//分类
|
||||
const category=ref(null)
|
||||
function toggleCategory(){
|
||||
category.value.toggle()
|
||||
}
|
||||
function cateClick(cate){
|
||||
console.log(cate);
|
||||
}
|
||||
</script>
|
||||
<style scoped>
|
||||
page{
|
||||
background: #F9F9F9;
|
||||
}
|
||||
</style>
|
||||
<style lang="scss" scoped>
|
||||
.stock-btns{
|
||||
padding: 0 100rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 20rpx;
|
||||
}
|
||||
.safe-page{
|
||||
background: #F9F9F9;
|
||||
}
|
||||
.icon-guige{
|
||||
width: 42rpx;
|
||||
height: 42rpx;
|
||||
}
|
||||
.bg-fff{
|
||||
background-color:#fff;
|
||||
}
|
||||
.myTabs {
|
||||
margin: 0 auto;
|
||||
width: 434rpx;
|
||||
height: 64rpx;
|
||||
}
|
||||
|
||||
.input-wrapper {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding-top: 26rpx;
|
||||
background-color: $J-bg-ff;
|
||||
|
||||
.input-main {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
height: 64rpx;
|
||||
|
||||
image {
|
||||
padding: 22rpx;
|
||||
width: 26rpx;
|
||||
height: 26rpx;
|
||||
}
|
||||
|
||||
input {
|
||||
flex: 1;
|
||||
font-size: 27rpx;
|
||||
}
|
||||
|
||||
::v-deep uni-button {
|
||||
font-size: 28rpx;
|
||||
color: $my-main-color;
|
||||
background: rgba(255, 255, 255, 1);
|
||||
}
|
||||
|
||||
::v-deep.uni-easyinput {
|
||||
.uni-easyinput__content {
|
||||
background-color: $J-bg-f5 !important;
|
||||
border-radius: $J-b-r12;
|
||||
|
||||
.uni-easyinput__content-input {
|
||||
padding-left: 0 !important;
|
||||
|
||||
.uni-input-input {
|
||||
border-radius: $J-b-r12 !important;
|
||||
overflow: hidden !important;
|
||||
}
|
||||
}
|
||||
|
||||
.uni-input-placeholder {
|
||||
font-size: 27rpx;
|
||||
}
|
||||
|
||||
.uni-icons {
|
||||
color: rgba(230, 230, 230, 1) !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.input-icon {
|
||||
position: relative;
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
.search-button {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
background-color: transparent !important;
|
||||
color: transparent !important;
|
||||
}
|
||||
.states1{
|
||||
margin-top: 78rpx;
|
||||
.item{
|
||||
font-size: 24rpx;
|
||||
color: #666;
|
||||
margin-right: 70rpx;
|
||||
background: #F4F4F4;
|
||||
border-radius: 8rpx 8rpx 8rpx 8rpx;
|
||||
}
|
||||
.item.active{
|
||||
background: #E6F0FF;
|
||||
color: $my-main-color;
|
||||
border-radius: 8rpx 8rpx 8rpx 8rpx;
|
||||
}
|
||||
}
|
||||
.fixed-b{
|
||||
position: fixed;
|
||||
left: 110rpx;
|
||||
right: 110rpx;
|
||||
bottom: 110rpx;
|
||||
}
|
||||
</style>
|
||||
479
pageCategory/index/index.vue
Normal file
479
pageCategory/index/index.vue
Normal file
@@ -0,0 +1,479 @@
|
||||
<template>
|
||||
<view class="safe-page min-page">
|
||||
<view class="goods-list u-p-30">
|
||||
<view class="u-m-b-32" v-for="(item,index) in pageData.list" :key="index">
|
||||
<my-category
|
||||
@del="categoryDel"
|
||||
@useTypeClick="categoryUseTypeClick"
|
||||
@changeClick="goodsChangeClick"
|
||||
@radioClick="goodsRadioClick"
|
||||
@isShowChange="isSHowChange"
|
||||
:index="index" :data="item"
|
||||
:showChecked="showChecked"
|
||||
:showDetail="pageData.showGoodsDetail"></my-category>
|
||||
</view>
|
||||
<view class="u-m-t-44" v-if="pageData.list.length>0">
|
||||
<my-pagination :page="pageData.query.page+1" :size="pageData.query.size" :totalElements="pageData.totalElements" @change="pageChange"></my-pagination>
|
||||
<view style="height: 200rpx;"></view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 删除弹窗 -->
|
||||
<my-model desc="请确保此分类下没有任何商品确认删除?" ref="delModel" @confirm="delModelConfirm"></my-model>
|
||||
|
||||
<!-- 分类修改排序弹窗 -->
|
||||
<my-model ref="goodsSortModel" title="修改排序" @close="goodsSortModelClose">
|
||||
<template #desc>
|
||||
<view class="u-p-40 u-text-left">
|
||||
<view>
|
||||
<view class="">排序:</view>
|
||||
<view class="u-m-t-24">
|
||||
<uni-easyinput v-model="sort" placeholder="请输入排序"></uni-easyinput>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</template>
|
||||
<template #btn>
|
||||
<view class="stock-btns u-p-b-40">
|
||||
<my-button shape="circle" @tap="goodsSortModelSave">确认修改</my-button>
|
||||
<my-button shape="circle" bgColor="#fff" type="default" @tap="goodsSortModelCancel">取消</my-button>
|
||||
</view>
|
||||
</template>
|
||||
</my-model>
|
||||
<!-- 全部分类修改弹窗 -->
|
||||
<my-model mode="bottom" ref="goodsTypeModel" :title="goodsTypeModelData.title" >
|
||||
<template #desc>
|
||||
<view class="u-p-30 u-m-t-30">
|
||||
<view class="u-flex u-m-b-20 u-row-between u-p-t-10 u-p-b-10" v-for="(item,index) in goodsTypeModelData.selCategory.childrenList" :key="index">
|
||||
<view class="font-bold color-000">{{item.name}}</view>
|
||||
<my-switch v-model="item.isOpen"></my-switch>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</template>
|
||||
<template #btn>
|
||||
<view class="u-flex gap-20 u-p-30 u-p-b-40 ">
|
||||
<view class="u-flex-1">
|
||||
<my-button shape="circle" color="#000" type="default" @tap="hideAllUseTypes">一键隐藏</my-button>
|
||||
</view>
|
||||
<view class="u-flex-1">
|
||||
<my-button shape="circle" @tap="showAllUseTypes">一键显示</my-button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
</my-model>
|
||||
<!-- <my-model mode="bottom" ref="goodsTypeModel" :title="goodsTypeModelData.title" >
|
||||
<template #desc>
|
||||
<view class="u-p-30 u-m-t-30">
|
||||
<view class="u-flex u-m-b-20 u-row-between u-p-t-10 u-p-b-10" v-for="(item,index) in goodsTypeModelData.useTypes" :key="index">
|
||||
<view class="font-bold color-000">{{item.name}}</view>
|
||||
<my-switch v-model="item.isOpen"></my-switch>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</template>
|
||||
<template #btn>
|
||||
<view class="u-flex gap-20 u-p-30 u-p-b-40 ">
|
||||
<view class="u-flex-1">
|
||||
<my-button shape="circle" color="#000" type="default" @tap="hideAllUseTypes">一键隐藏</my-button>
|
||||
</view>
|
||||
<view class="u-flex-1">
|
||||
<my-button shape="circle" @tap="showAllUseTypes">一键显示</my-button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
</my-model> -->
|
||||
|
||||
<view class="fixed-b">
|
||||
<my-button :height="80" shape="circle" showShadow @tap="toAddCategory">新建分类</my-button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
reactive, ref, watch
|
||||
} from 'vue';
|
||||
import {onShow,onLoad} from '@dcloudio/uni-app'
|
||||
import go from '@/commons/utils/go.js';
|
||||
import myCategory from './components/category.vue'
|
||||
import infoBox from "@/commons/utils/infoBox.js"
|
||||
import {$productCategory} from '@/http/yskApi/goods.js'
|
||||
|
||||
|
||||
const tabsList = ['简洁', '详情']
|
||||
const statesTabsList = ['在售中', '已下架']
|
||||
const states1TabsList = ['全部', '已售罄']
|
||||
const control=ref(null)
|
||||
const delModel=ref(null)
|
||||
const goodsSortModel=ref(null)
|
||||
const goodsTypeModel=ref(null)
|
||||
let sort=ref(0)
|
||||
const goodsTypeModelData=reactive({
|
||||
selCategory:'',
|
||||
title:'',
|
||||
index:null,
|
||||
useTypes:[
|
||||
{name:'堂食',isOpen:true},
|
||||
{name:'自取',isOpen:true},
|
||||
{name:'外卖',isOpen:true},
|
||||
{name:'快递',isOpen:true}
|
||||
]
|
||||
})
|
||||
const pageData = reactive({
|
||||
stateCurrent:0,
|
||||
stateCurrent1:0,
|
||||
componentBottom:264,
|
||||
search: {
|
||||
value: '',
|
||||
placeholder: '输入搜索的商品'
|
||||
},
|
||||
showGoodsDetail:false,
|
||||
query:{
|
||||
page: 0,
|
||||
size:10
|
||||
},
|
||||
totalElements:0,
|
||||
list:[],
|
||||
selCategory:''
|
||||
})
|
||||
|
||||
async function init() {
|
||||
const res=await $productCategory.get(pageData.query)
|
||||
pageData.list=res.content.map(v=>{
|
||||
return {
|
||||
...v,
|
||||
isSellNone:false,
|
||||
checked:false,
|
||||
showDetail:false,
|
||||
useTypes:[
|
||||
{name:'堂食',isOpen:true},
|
||||
{name:'自取',isOpen:true},
|
||||
{name:'外卖',isOpen:true},
|
||||
{name:'快递',isOpen:true}
|
||||
]
|
||||
}
|
||||
})
|
||||
pageData.totalElements=res.totalElements
|
||||
}
|
||||
onLoad(()=>{
|
||||
init()
|
||||
})
|
||||
function watchEvent(){
|
||||
uni.$off('update:pageCategoryIndex')
|
||||
uni.$on('update:pageCategoryIndex',(data)=>{
|
||||
init()
|
||||
})
|
||||
}
|
||||
onShow(()=>{
|
||||
watchEvent()
|
||||
})
|
||||
function toAddCategory(){
|
||||
go.to('PAGES_CATEGORY_EDIT',{type:'add'})
|
||||
}
|
||||
|
||||
function hideAllUseTypes(){
|
||||
goodsTypeModelData.useTypes.map(v=>{
|
||||
v.isOpen=false
|
||||
})
|
||||
pageData.list[goodsTypeModelData.index].useTypes.map(v=>{
|
||||
v.isOpen=false
|
||||
})
|
||||
}
|
||||
|
||||
function showAllUseTypes(){
|
||||
goodsTypeModelData.useTypes.map(v=>{
|
||||
v.isOpen=true
|
||||
})
|
||||
pageData.list[goodsTypeModelData.index].useTypes.map(v=>{
|
||||
v.isOpen=true
|
||||
})
|
||||
}
|
||||
|
||||
function goodsSortModelCancel(){
|
||||
console.log('goodsSortModelCancel');
|
||||
goodsSortModel.value.close()
|
||||
}
|
||||
async function goodsSortModelSave(){
|
||||
console.log('goodsSortModelSave');
|
||||
|
||||
const res=await $productCategory.update({...pageData.selCategory,sort:sort.value})
|
||||
infoBox.showToast('修改成功')
|
||||
goodsSortModelCancel()
|
||||
init()
|
||||
}
|
||||
|
||||
async function isSHowChange(data){
|
||||
const res=await $productCategory.update({...data})
|
||||
infoBox.showToast('修改成功')
|
||||
// init()
|
||||
}
|
||||
function categoryUseTypeClick(index){
|
||||
goodsTypeModelData.index=index
|
||||
// goodsTypeModelData.useTypes=pageData.list[index].useTypes
|
||||
const cateItem=pageData.list[index]
|
||||
console.log(cateItem);
|
||||
goodsTypeModelData.selCategory=cateItem
|
||||
goodsTypeModelData.title=cateItem.name
|
||||
goodsTypeModel.value.open()
|
||||
}
|
||||
|
||||
|
||||
//点击修改按钮弹出修改商品弹窗
|
||||
function goodsChangeClick(index){
|
||||
console.log(index);
|
||||
const goods=pageData.list[index]
|
||||
sort.value=goods.sort
|
||||
pageData.selCategory=goods
|
||||
goodsSortModel.value.open()
|
||||
}
|
||||
|
||||
function statesTableClick(index){
|
||||
pageData.stateCurrent=index
|
||||
}
|
||||
function states1TableClick(index){
|
||||
pageData.stateCurrent1=index
|
||||
}
|
||||
|
||||
let test=ref(false)
|
||||
|
||||
function tabsChange(i) {
|
||||
console.log(i);
|
||||
pageData.showGoodsDetail=i?true:false
|
||||
}
|
||||
|
||||
|
||||
//改变商品的选中状态
|
||||
function changeGoodsChecked(checked,index){
|
||||
if(index!==undefined){
|
||||
pageData.list[index].checked=checked
|
||||
}else{
|
||||
pageData.list.map(v=>{
|
||||
v.checked=checked
|
||||
})
|
||||
}
|
||||
control.value.setisSelectAll(isAllChecked()?true:false)
|
||||
}
|
||||
|
||||
|
||||
// 获取已经选中的商品
|
||||
function getChechkedlist(){
|
||||
return pageData.list.filter(v=>v.checked)
|
||||
}
|
||||
//是否全部选中
|
||||
function isAllChecked(){
|
||||
return getChechkedlist().length===pageData.list.length
|
||||
}
|
||||
// 是否有商品选中
|
||||
function isHasChekdGoods(){
|
||||
return getChechkedlist().length?true:false
|
||||
}
|
||||
|
||||
function searchFunc() {
|
||||
console.log('searchFunc');
|
||||
}
|
||||
|
||||
let showChecked=ref(false)
|
||||
|
||||
//商品start
|
||||
|
||||
function goodsRadioClick(index){
|
||||
var checked=!pageData.list[index].checked
|
||||
changeGoodsChecked(checked,index)
|
||||
}
|
||||
|
||||
|
||||
//下架
|
||||
function offShelf(){
|
||||
const hasCheckedArr=getChechkedlist()
|
||||
const hasChecked=isHasChekdGoods()
|
||||
if(!hasChecked){
|
||||
return infoBox.showToast('您还没有选中商品!')
|
||||
}
|
||||
model.value.open()
|
||||
}
|
||||
let nowCateIndex=null
|
||||
function categoryDel(index){
|
||||
// nowCateIndex=index
|
||||
// delModel.value.open()
|
||||
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '请确保此分类下没有任何商品确认删除?',
|
||||
success: res => {
|
||||
if(res.confirm){
|
||||
const islast=pageData.list.length===1
|
||||
$productCategory.del([pageData.list[index].id]).then(res=>{
|
||||
infoBox.showToast('删除成功')
|
||||
if(islast&&pageData.query.page>=1){
|
||||
pageData.query.page-=1
|
||||
}
|
||||
// if(islast&&pageData.query.page>=1){
|
||||
// pageData.query.page--
|
||||
// }
|
||||
init()
|
||||
})
|
||||
}
|
||||
|
||||
},
|
||||
fail: () => {},
|
||||
complete: () => {}
|
||||
});
|
||||
}
|
||||
//删除分类确认
|
||||
function delModelConfirm(){
|
||||
console.log('confirm');
|
||||
pageData.list.splice(nowCateIndex,1)
|
||||
delModel.value.close()
|
||||
}
|
||||
|
||||
//商品end
|
||||
|
||||
//控制条
|
||||
function controlChange(bol){
|
||||
console.log(bol);
|
||||
showChecked.value=bol
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 全选
|
||||
function allCheckedChange(checked){
|
||||
changeGoodsChecked(checked)
|
||||
}
|
||||
|
||||
// 页数改变事件
|
||||
function pageChange(page) {
|
||||
pageData.query.page=page-1
|
||||
init()
|
||||
}
|
||||
|
||||
|
||||
//分类
|
||||
const category=ref(null)
|
||||
function toggleCategory(){
|
||||
category.value.toggle()
|
||||
}
|
||||
function cateClick(cate){
|
||||
console.log(cate);
|
||||
}
|
||||
</script>
|
||||
<style scoped>
|
||||
page{
|
||||
background: #F9F9F9;
|
||||
}
|
||||
</style>
|
||||
<style lang="scss" scoped>
|
||||
.stock-btns{
|
||||
padding: 0 100rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 20rpx;
|
||||
}
|
||||
.safe-page{
|
||||
background: #F9F9F9;
|
||||
}
|
||||
.icon-guige{
|
||||
width: 42rpx;
|
||||
height: 42rpx;
|
||||
}
|
||||
.bg-fff{
|
||||
background-color:#fff;
|
||||
}
|
||||
.myTabs {
|
||||
margin: 0 auto;
|
||||
width: 434rpx;
|
||||
height: 64rpx;
|
||||
}
|
||||
|
||||
.input-wrapper {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding-top: 26rpx;
|
||||
background-color: $J-bg-ff;
|
||||
|
||||
.input-main {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
height: 64rpx;
|
||||
|
||||
image {
|
||||
padding: 22rpx;
|
||||
width: 26rpx;
|
||||
height: 26rpx;
|
||||
}
|
||||
|
||||
input {
|
||||
flex: 1;
|
||||
font-size: 27rpx;
|
||||
}
|
||||
|
||||
::v-deep uni-button {
|
||||
font-size: 28rpx;
|
||||
color: $my-main-color;
|
||||
background: rgba(255, 255, 255, 1);
|
||||
}
|
||||
|
||||
::v-deep.uni-easyinput {
|
||||
.uni-easyinput__content {
|
||||
background-color: $J-bg-f5 !important;
|
||||
border-radius: $J-b-r12;
|
||||
|
||||
.uni-easyinput__content-input {
|
||||
padding-left: 0 !important;
|
||||
|
||||
.uni-input-input {
|
||||
border-radius: $J-b-r12 !important;
|
||||
overflow: hidden !important;
|
||||
}
|
||||
}
|
||||
|
||||
.uni-input-placeholder {
|
||||
font-size: 27rpx;
|
||||
}
|
||||
|
||||
.uni-icons {
|
||||
color: rgba(230, 230, 230, 1) !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.input-icon {
|
||||
position: relative;
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
.search-button {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
background-color: transparent !important;
|
||||
color: transparent !important;
|
||||
}
|
||||
.states1{
|
||||
margin-top: 78rpx;
|
||||
.item{
|
||||
font-size: 24rpx;
|
||||
color: #666;
|
||||
margin-right: 70rpx;
|
||||
background: #F4F4F4;
|
||||
border-radius: 8rpx 8rpx 8rpx 8rpx;
|
||||
}
|
||||
.item.active{
|
||||
background: #E6F0FF;
|
||||
color: $my-main-color;
|
||||
border-radius: 8rpx 8rpx 8rpx 8rpx;
|
||||
}
|
||||
}
|
||||
.fixed-b{
|
||||
position: fixed;
|
||||
left: 110rpx;
|
||||
right: 110rpx;
|
||||
bottom: 110rpx;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user