first
This commit is contained in:
93
pageProduct/index/components/category - 副本.vue
Normal file
93
pageProduct/index/components/category - 副本.vue
Normal file
@@ -0,0 +1,93 @@
|
||||
<template>
|
||||
<view>
|
||||
<view class="category " :style="getCompouteStyle()">
|
||||
<scroll-view scroll-y="true" :style="{height:props.height+'rpx'}">
|
||||
<view class="list">
|
||||
<view class="item" @tap="cateClick(item)" v-for="(item,index) in 20" :key="index">
|
||||
分类
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
ref, warn, watch, watchEffect,
|
||||
onMounted
|
||||
} from 'vue';
|
||||
import {$tbShopCategory} from '@/http/yskApi/goods.js'
|
||||
const emite=defineEmits(['cateClick'])
|
||||
const props = defineProps({
|
||||
width: {
|
||||
type: [Number, String],
|
||||
default: 264
|
||||
},
|
||||
height: {
|
||||
type: [Number, String],
|
||||
default: 420
|
||||
},
|
||||
right: {
|
||||
type: [Number, String],
|
||||
default: 30
|
||||
},
|
||||
bottom: {
|
||||
type: [Number, String],
|
||||
default: 0
|
||||
}
|
||||
})
|
||||
let show = ref(false)
|
||||
|
||||
function open() {
|
||||
show.value = true
|
||||
}
|
||||
|
||||
function close() {
|
||||
show.value = false
|
||||
}
|
||||
|
||||
function toggle() {
|
||||
show.value = !show.value
|
||||
}
|
||||
|
||||
function cateClick(item){
|
||||
emite('cateClick',item)
|
||||
}
|
||||
|
||||
function getCompouteStyle() {
|
||||
return {
|
||||
width: props.width + 'rpx',
|
||||
height: props.height + 'rpx',
|
||||
right: props.right + 'rpx',
|
||||
bottom: props.bottom + 'rpx',
|
||||
transform:`scaleY(${show.value?1:0})`
|
||||
}
|
||||
}
|
||||
onMounted(()=>{
|
||||
$tbShopCategory({
|
||||
page:0,size:200
|
||||
})
|
||||
})
|
||||
defineExpose({
|
||||
open,
|
||||
close,toggle
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.category {
|
||||
background: #FFFFFF;
|
||||
box-shadow: 0rpx 6rpx 12rpx 2rpx rgba(0, 0, 0, 0.16);
|
||||
border-radius: 14rpx 14rpx 14rpx 14rpx;
|
||||
position: fixed;
|
||||
font-size: 24rpx;
|
||||
color: #333;
|
||||
.list{
|
||||
box-sizing: border-box;
|
||||
.item{
|
||||
padding: 24rpx 24rpx 24rpx 48rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
120
pageProduct/index/components/category.vue
Normal file
120
pageProduct/index/components/category.vue
Normal file
@@ -0,0 +1,120 @@
|
||||
<template>
|
||||
<view>
|
||||
<view class="category " :style="getCompouteStyle()">
|
||||
<scroll-view scroll-y="true" :style="{height:props.height+'rpx'}">
|
||||
<view class="list">
|
||||
<view v-if="showAllText" class="font-bold item border-bottom u-font-28" @tap="cateClick({id:'',name:'全部分类'})">全部分类</view>
|
||||
<view v-for="(item,index) in category.list" :key="index">
|
||||
<view class="item font-bold border-bottom" @tap="cateClick(item)">
|
||||
{{item.name}}
|
||||
</view>
|
||||
<view class="item border-bottom" @tap="cateClick(child)"
|
||||
v-for="(child,childIndex) in item.childrenList"
|
||||
:key="childIndex" >
|
||||
<text> </text>
|
||||
{{child.name}}
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
ref, warn, watch, watchEffect,
|
||||
onMounted,reactive
|
||||
} from 'vue';
|
||||
import {$tbShopCategory} from '@/http/yskApi/goods.js'
|
||||
const emite=defineEmits(['cateClick','change'])
|
||||
const props = defineProps({
|
||||
showAllText:{
|
||||
type:Boolean,
|
||||
default:true
|
||||
},
|
||||
width: {
|
||||
type: [Number, String],
|
||||
default: 264
|
||||
},
|
||||
height: {
|
||||
type: [Number, String],
|
||||
default: 420
|
||||
},
|
||||
right: {
|
||||
type: [Number, String],
|
||||
default: 30
|
||||
},
|
||||
bottom: {
|
||||
type: [Number, String],
|
||||
default: 0
|
||||
}
|
||||
})
|
||||
let show = ref(false)
|
||||
|
||||
watch(()=>show.value,(newval)=>{
|
||||
emite('change',newval)
|
||||
})
|
||||
|
||||
function open() {
|
||||
show.value = true
|
||||
}
|
||||
|
||||
function close() {
|
||||
show.value = false
|
||||
}
|
||||
|
||||
function toggle() {
|
||||
show.value = !show.value
|
||||
}
|
||||
|
||||
function cateClick(item){
|
||||
emite('cateClick',item)
|
||||
close()
|
||||
}
|
||||
|
||||
function getCompouteStyle() {
|
||||
return {
|
||||
width: props.width + 'rpx',
|
||||
height: props.height + 'rpx',
|
||||
right: props.right + 'rpx',
|
||||
bottom: props.bottom + 'rpx',
|
||||
transform:`scaleY(${show.value?1:0})`
|
||||
}
|
||||
}
|
||||
const category=reactive({
|
||||
list:[],
|
||||
categoryId:'',
|
||||
categoryName:'',
|
||||
|
||||
})
|
||||
onMounted(()=>{
|
||||
$tbShopCategory({
|
||||
page:0,size:200
|
||||
}).then(res=>{
|
||||
category.list=res.content
|
||||
})
|
||||
})
|
||||
defineExpose({
|
||||
open,
|
||||
close,toggle
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.category {
|
||||
background: #FFFFFF;
|
||||
box-shadow: 0rpx 6rpx 12rpx 2rpx rgba(0, 0, 0, 0.16);
|
||||
border-radius: 14rpx 14rpx 14rpx 14rpx;
|
||||
position: fixed;
|
||||
font-size: 24rpx;
|
||||
color: #333;
|
||||
.list{
|
||||
box-sizing: border-box;
|
||||
.item{
|
||||
padding: 24rpx 24rpx 24rpx 48rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
161
pageProduct/index/components/control.vue
Normal file
161
pageProduct/index/components/control.vue
Normal file
@@ -0,0 +1,161 @@
|
||||
<template>
|
||||
<view class="control" :style="getComputedStyle()">
|
||||
<view class="u-flex control1" v-if="showControl1">
|
||||
<view class="btn" @click="changeShowControl1">批量管理</view>
|
||||
<view class="btn" @tap="go.to('PAGES_PRODUCT_ADD')">商品添加</view>
|
||||
<view class="color-999 btn u-flex u-row-center" @click="emitToggleCategory">
|
||||
<text class="u-m-r-10">{{categoryName||'选择分类'}}</text>
|
||||
<view class="arrow-down" :class="{'up':categoryShow}">
|
||||
<uni-icons type="right" size="16" color="#999"></uni-icons>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-flex control2 u-row-between" v-else>
|
||||
<view class="u-flex btn">
|
||||
<view class="u-m-r-58">
|
||||
<label class="radio" @click="changeIsSelectAll">
|
||||
<radio class="scale7" @tap.stop="changeIsSelectAll" :color="ColorMain" value="" :checked="isSelectAll" />
|
||||
<text>全选</text>
|
||||
</label>
|
||||
</view>
|
||||
<view class="u-p-l-30 u-p-r-30 my-bg-main" @click="changeShowControl1">取消</view>
|
||||
<view class="u-p-l-60 u-p-r-60 borde-r" @click="offShelf">下架</view>
|
||||
</view>
|
||||
<view class=" u-flex u-row-center btn" @click="emitToggleCategory">
|
||||
<text class="u-m-r-10">分类至</text>
|
||||
<uni-icons type="right" size="16" color="#fff"></uni-icons>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {$tbShopCategory} from '@/http/yskApi/goods.js'
|
||||
import go from '@/commons/utils/go.js';
|
||||
import {ColorMain} from '@/commons/color.js'
|
||||
import {
|
||||
onMounted,
|
||||
reactive,
|
||||
ref
|
||||
} from 'vue';
|
||||
const props = defineProps({
|
||||
bottom: {
|
||||
type: [Number, String],
|
||||
default: 30
|
||||
},
|
||||
categoryName:{
|
||||
type:String,
|
||||
default:''
|
||||
},
|
||||
categoryShow:{
|
||||
type:Boolean,
|
||||
default:false
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
let showControl1 = ref(true)
|
||||
const emits = defineEmits(['toggleCategory','controlChange','allCheckedChange','offShelf','categoryChange'])
|
||||
|
||||
function emitToggleCategory() {
|
||||
emits('toggleCategory')
|
||||
}
|
||||
|
||||
function changeShowControl1() {
|
||||
showControl1.value = !showControl1.value
|
||||
emits('controlChange',!showControl1.value)
|
||||
}
|
||||
|
||||
let isSelectAll = ref(false)
|
||||
|
||||
function changeIsSelectAll() {
|
||||
isSelectAll.value = !isSelectAll.value
|
||||
emits('allCheckedChange',isSelectAll.value)
|
||||
}
|
||||
|
||||
function getComputedStyle() {
|
||||
return {
|
||||
bottom: props.bottom + 'rpx'
|
||||
}
|
||||
}
|
||||
//设置是否全选
|
||||
function setisSelectAll(checked){
|
||||
isSelectAll.value =checked
|
||||
}
|
||||
defineExpose({
|
||||
setisSelectAll
|
||||
})
|
||||
|
||||
//下架
|
||||
function offShelf(){
|
||||
emits('offShelf')
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.scale7 {
|
||||
transform: scale(0.7);
|
||||
}
|
||||
|
||||
.borde-r {
|
||||
position: relative;
|
||||
|
||||
&::after {
|
||||
display: block;
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 20rpx;
|
||||
bottom: 20rpx;
|
||||
width: 2px;
|
||||
background-color: #fff;
|
||||
right: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.control {
|
||||
position: fixed;
|
||||
left: 30rpx;
|
||||
right: 30rpx;
|
||||
z-index: 100;
|
||||
background: #3E3A3A;
|
||||
border-radius: 100rpx;
|
||||
.btn{
|
||||
color: #fff;
|
||||
}
|
||||
.control1 {
|
||||
.arrow-down {
|
||||
transform: rotate(90deg);
|
||||
transition: all .2s ease-in-out;
|
||||
&.up{
|
||||
transform: rotate(-90deg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.control1 .btn:not(:last-child)::after {
|
||||
display: block;
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 20rpx;
|
||||
bottom: 20rpx;
|
||||
width: 2px;
|
||||
background-color: #fff;
|
||||
right: 0;
|
||||
}
|
||||
|
||||
.control1 .btn {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.control1 .btn,
|
||||
.control2 .btn{
|
||||
position: relative;
|
||||
line-height: 76rpx;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.control2 {
|
||||
padding: 0 28rpx;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
265
pageProduct/index/components/goods.vue
Normal file
265
pageProduct/index/components/goods.vue
Normal file
@@ -0,0 +1,265 @@
|
||||
<template>
|
||||
<view class=" goods">
|
||||
<view class="u-flex u-row-between">
|
||||
<view class="u-flex">
|
||||
<view class="color-333">
|
||||
<text class="">排序</text>
|
||||
<text class="u-m-l-20">{{data.sort}}</text>
|
||||
</view>
|
||||
<view class="color-333 u-m-l-42 u-flex">
|
||||
<text class="stock">库存</text>
|
||||
<text class="font-bold u-m-l-10">{{data.stockNumber}}</text>
|
||||
<uni-icons type="right" size="16" color="#000"></uni-icons>
|
||||
</view>
|
||||
</view>
|
||||
<text class="u-font-28 color-666" @click="changeClick">修改</text>
|
||||
</view>
|
||||
|
||||
|
||||
<view class="u-m-t-48 u-flex">
|
||||
<view v-if="props.showChecked">
|
||||
<label class="radio">
|
||||
<radio :color="ColorMain" style="transform: scale(0.7);" @click="radioClick"
|
||||
:checked="props.data.checked" /><text></text>
|
||||
</label>
|
||||
</view>
|
||||
<image :src="data.coverImg" lazy-load class="img"></image>
|
||||
<view class="h-100 u-p-l-16 u-flex u-flex-col u-row-between">
|
||||
<view class="color-333"> <text class="u-m-r-24">{{data.name}}</text><uni-tag size="small" type="primary"
|
||||
custom-style="background-color: #318AFE;" :text="data.typeEnum"></uni-tag></view>
|
||||
|
||||
<view class="price">¥{{data.lowPrice}}</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="u-m-t-16 skus u-text-center" v-if="showDetail&&data.skuList.length>=2">
|
||||
<view class="u-flex u-row-between font-bold">
|
||||
<view class="u-flex-1">商品信息</view>
|
||||
<view class="u-flex-1">售价</view>
|
||||
<view class="u-flex-1">库存</view>
|
||||
</view>
|
||||
<view v-for="(item,index) in data.skuList" :key="index">
|
||||
<view class="u-flex u-m-t-10">
|
||||
<view class="color-333 u-flex-1"> <text class="u-m-r-24">{{item.specSnap||''}}</text></view>
|
||||
<view class="price u-flex-1">¥{{data.lowPrice||0}}</view>
|
||||
<view class=" u-flex-1">{{item.stockNumber||0}} {{data.unitName||''}}</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- <view class="u-flex">
|
||||
<view class="sku">做法</view>
|
||||
<view class="u-flex u-flex-wrap u-flex-1 skds">
|
||||
<view class="skd">汤
|
||||
<view class="tag-primary tag">上架中</view>
|
||||
</view>
|
||||
<view class="skd">干
|
||||
<view class="tag-primary tag">上架中</view>
|
||||
</view>
|
||||
</view>
|
||||
</view> -->
|
||||
|
||||
</view>
|
||||
<view class="u-m-t-24 u-flex u-row-between">
|
||||
<view class="u-flex">
|
||||
<view class="u-m-r-18 color-999">设置热门</view>
|
||||
<my-switch v-model="data.isHot" @change="isHotChange"></my-switch>
|
||||
<!-- <view class="u-m-r-18 color-999">售罄</view>
|
||||
<my-switch v-model="isSellNone" @change="isSellNoneChange"></my-switch> -->
|
||||
</view>
|
||||
<view class="u-flex">
|
||||
<!-- <view class="btn-default btn" @tap="xiajia">下架商品</view> -->
|
||||
<view class="btn-default btn" @tap="del">删除</view>
|
||||
<view class="btn-primary btn u-m-l-38" @click="toEdit">编辑</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
|
||||
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
ref,
|
||||
watchEffect
|
||||
} from 'vue';
|
||||
import {$goodsIsHot} from '@/http/yskApi/goods.js'
|
||||
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', 'xiajia','del'])
|
||||
const props = defineProps({
|
||||
index: {
|
||||
type: Number
|
||||
},
|
||||
data: {
|
||||
type: Object,
|
||||
default: () => {
|
||||
return {}
|
||||
}
|
||||
},
|
||||
showChecked: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
showDetail: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
function isHotChange(e){
|
||||
$goodsIsHot({
|
||||
id:props.data.id,
|
||||
isHot:props.data.isHot
|
||||
}).then(res=>{
|
||||
uni.showToast({
|
||||
title:'修改成功',
|
||||
icon:'none'
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
let isSellNone = ref(false)
|
||||
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 xiajia() {
|
||||
emits('xiajia', props.index)
|
||||
}
|
||||
function del(){
|
||||
emits('del', props.index)
|
||||
}
|
||||
|
||||
//携带参数type edit跳转到商品添加页面,编辑与添加同一页面,根据type值来判断
|
||||
function toEdit() {
|
||||
go.to('PAGES_PRODUCT_ADD', {
|
||||
type: 'edit',
|
||||
productId: props.data.id
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
$imgSize: 126rpx;
|
||||
$price-color: #F02C45;
|
||||
|
||||
.btn {
|
||||
padding: 6rpx 28rpx;
|
||||
border-radius: 100rpx;
|
||||
border: 2rpx solid transparent;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
border-color: $my-main-color;
|
||||
;
|
||||
color: $my-main-color;
|
||||
}
|
||||
|
||||
.btn-default {
|
||||
border-color: #F4F4F4;
|
||||
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>
|
||||
505
pageProduct/index/index.vue
Normal file
505
pageProduct/index/index.vue
Normal file
@@ -0,0 +1,505 @@
|
||||
<template>
|
||||
<view class="safe-page">
|
||||
<view class="bg-fff u-p-l-30 u-p-t-16 u-p-r-30 u-p-b-30">
|
||||
<view class="myTabs ">
|
||||
<myTabs :list="tabsList" @change="tabsChange"></myTabs>
|
||||
</view>
|
||||
<view class="input-wrapper">
|
||||
<view class="input-main">
|
||||
<uni-easyinput
|
||||
clearable
|
||||
class='jeepay-search' :inputBorder="false" :placeholder="pageData.search.placeholder"
|
||||
v-model="pageData.query.name" @confirm="searchFunc">
|
||||
<template #prefixIcon>
|
||||
<image src="@/static/iconImg/icon-search.svg" class="input-icon" />
|
||||
</template>
|
||||
</uni-easyinput>
|
||||
<button type="text" @click="searchFunc()">搜索</button>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-flex u-m-t-20 u-p-l-30 u-p-r-30 u-font-28 u-p-b-20 border-bottom">
|
||||
<view class="u-flex-1 tranistion u-text-center color-333"
|
||||
:class="{'color-main':pageData.stateCurrent==index}" @tap="statesTableClick(index)"
|
||||
v-for="(item,index) in statesTabsList" :key="index">
|
||||
{{item}}
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="u-flex states1 u-row-between u-font-28">
|
||||
<view class="u-flex">
|
||||
<view class="u-p-l-16 item u-p-r-16 u-p-t-6 u-p-b-6 tranistion u-text-center color-333"
|
||||
:class="{'active':pageData.stateCurrent1==index}" @tap="states1TableClick(index)"
|
||||
v-for="(item,index) in states1TabsList" :key="index">
|
||||
{{item}}
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-flex u-col-center" @click="go.to('PAGES_PRODUCT_SPECIF_TEMPLATE')">
|
||||
<image src="/pageProduct/static/images/icon-guige.svg" class="icon-guige" />
|
||||
<text class="color-666 u-m-l-12 u-font-24">规格模版</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
|
||||
<view class="goods-list u-p-30" >
|
||||
<template v-if="pageData.goodsList.length">
|
||||
<view class="u-m-b-32" v-for="(item,index) in pageData.goodsList" :key="index">
|
||||
<my-goods @changeClick="goodsChangeClick" @radioClick="goodsRadioClick" :index="index" :data="item"
|
||||
@del="goodsDel"
|
||||
:showChecked="showChecked" :showDetail="pageData.showGoodsDetail"></my-goods>
|
||||
</view>
|
||||
</template>
|
||||
<template v-if="pageData.hasAjax&&!pageData.goodsList.length">
|
||||
<my-img-empty tips="未找到相关商品"></my-img-empty>
|
||||
</template>
|
||||
<my-pagination :totalElements="pageData.totalElements" :size="pageData.query.size" @change="pageChange"></my-pagination>
|
||||
<view style="height: 100rpx;"></view>
|
||||
</view>
|
||||
|
||||
<my-control ref="control"
|
||||
:categoryShow="pageData.categoryShow"
|
||||
:categoryName="pageData.categoryName"
|
||||
@categoryChange="categoryIdChange"
|
||||
@offShelf="offShelf" @allCheckedChange="allCheckedChange"
|
||||
@controlChange="controlChange" @toggleCategory="toggleCategory"
|
||||
:bottom="pageData.componentBottom"></my-control>
|
||||
<my-category ref="category"
|
||||
@change="onCategoryShowChange" @cateClick="cateClick" :bottom="pageData.componentBottom+100"></my-category>
|
||||
<!-- 下架弹窗 -->
|
||||
<my-model :desc="pageData.modelDesc" ref="model" @confirm="modelConfirm"></my-model>
|
||||
<!-- 商品库存修改弹窗 -->
|
||||
<my-model ref="goodsStockModel" title="商品修改" @close="goodsStockModelClose">
|
||||
<template #desc>
|
||||
<view class="u-p-40 u-text-left">
|
||||
<view>
|
||||
<view class="">排序:</view>
|
||||
<view class="u-m-t-24">
|
||||
<uni-easyinput v-model="goodsStockData.sort" placeholder="请输入排序"></uni-easyinput>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-flex u-m-t-32">
|
||||
<view class="">库存开关:</view>
|
||||
<view class="u-m-l-46 ">
|
||||
<my-switch v-model="goodsStockData.isStock"></my-switch>
|
||||
</view>
|
||||
</view>
|
||||
<!-- <view class="u-flex u-m-t-32">
|
||||
<view class="">共享库存:</view>
|
||||
<view class="u-m-l-46 ">
|
||||
<my-switch v-model="goodsStockData.isDistribute"></my-switch>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-flex u-m-t-32">
|
||||
<view class="">售罄:</view>
|
||||
<view class="u-m-l-46 ">
|
||||
<my-switch v-model="goodsStockData.isPauseSale"></my-switch>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-flex u-m-t-32">
|
||||
<view class="">上架:</view>
|
||||
<view class="u-m-l-46 ">
|
||||
<my-switch v-model="goodsStockData.isGrounding"></my-switch>
|
||||
</view>
|
||||
</view> -->
|
||||
|
||||
<!-- <view class="u-m-t-24 u-m-t-32" v-if="goodsStockData.isStock">
|
||||
<view class="">数量:</view>
|
||||
<view class="u-m-t-24">
|
||||
<uni-easyinput v-model="goodsStockData.stockNumber" placeholder="请输入库存数量"></uni-easyinput>
|
||||
</view>
|
||||
</view> -->
|
||||
</view>
|
||||
|
||||
</template>
|
||||
<template #btn>
|
||||
<view class="stock-btns u-p-b-40">
|
||||
<my-button shape="circle" @tap="goodsStockModelSave">保存</my-button>
|
||||
<my-button shape="circle" type="default" @tap="goodsStockModelCancel">取消</my-button>
|
||||
</view>
|
||||
</template>
|
||||
</my-model>
|
||||
</view>
|
||||
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
onLoad,
|
||||
onReady,
|
||||
onShow,
|
||||
onPageScroll,
|
||||
onPullDownRefresh
|
||||
} from '@dcloudio/uni-app';
|
||||
import {
|
||||
reactive,
|
||||
ref,
|
||||
watch
|
||||
} from 'vue';
|
||||
import go from '@/commons/utils/go.js';
|
||||
import myTabs from '@/pageProduct/components/my-tabs.vue'
|
||||
import myGoods from './components/goods.vue'
|
||||
import myControl from './components/control.vue'
|
||||
import myCategory from './components/category.vue'
|
||||
import infoBox from "@/commons/utils/infoBox.js"
|
||||
import myPagination from '@/components/my-components/my-pagination'
|
||||
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 {
|
||||
$tbProduct,
|
||||
$upProSort,
|
||||
$updateProduct,$getProductDetail,$delProduct,$updateProductStatus
|
||||
} from "@/http/yskApi/goods.js"
|
||||
const pageData = reactive({
|
||||
modelDesc: '是否下架',
|
||||
stateCurrent: 0,
|
||||
stateCurrent1: 0,
|
||||
componentBottom: 45,
|
||||
search: {
|
||||
value: '',
|
||||
placeholder: '输入搜索的商品'
|
||||
},
|
||||
showGoodsDetail: false,
|
||||
selGoodsIndex: '',
|
||||
totalElements: 0,
|
||||
totalPage: 0,
|
||||
goodsList: [],
|
||||
query: {
|
||||
page: 0,
|
||||
size: 10,
|
||||
categoryId:'',
|
||||
name:''
|
||||
},
|
||||
category:'',
|
||||
categoryShow:false,
|
||||
categoryName:'',
|
||||
hasAjax:false
|
||||
})
|
||||
function onCategoryShowChange(show){
|
||||
console.log(show);
|
||||
pageData.categoryShow=show
|
||||
}
|
||||
function categoryIdChange(categoryId){
|
||||
pageData.query.categoryId=categoryId
|
||||
getGoodsList()
|
||||
}
|
||||
function getGoodsList() {
|
||||
$tbProduct(pageData.query).then(res => {
|
||||
pageData.hasAjax=true
|
||||
console.log(res);
|
||||
pageData.goodsList = res.content.map(v => {
|
||||
return {
|
||||
...v,
|
||||
isSellNone: false,
|
||||
checked: false,
|
||||
showDetail: false
|
||||
}
|
||||
})
|
||||
pageData.totalElements = res.totalElements
|
||||
})
|
||||
}
|
||||
onShow(() => {
|
||||
getGoodsList()
|
||||
})
|
||||
|
||||
const tabsList = ['简洁', '详情']
|
||||
const statesTabsList = ['在售中', '已下架']
|
||||
const states1TabsList = ['全部', '已售罄']
|
||||
const control = ref(null)
|
||||
const model = ref(null)
|
||||
const goodsStockModel = ref(null)
|
||||
|
||||
function returnGoodsStockData() {
|
||||
return reactive({
|
||||
sort: 0,
|
||||
isStock: false,
|
||||
isDistribute:false,
|
||||
isPauseSale:false,
|
||||
isGrounding:false,
|
||||
stockNumber: 0,
|
||||
})
|
||||
}
|
||||
let goodsStockData = returnGoodsStockData()
|
||||
|
||||
function goodsStockModelClose() {
|
||||
console.log('goodsStockModelClose');
|
||||
goodsStockData = returnGoodsStockData()
|
||||
}
|
||||
|
||||
function goodsStockModelCancel() {
|
||||
console.log('goodsStockModelCancel');
|
||||
goodsStockModel.value.close()
|
||||
goodsStockData = returnGoodsStockData()
|
||||
}
|
||||
|
||||
async function goodsStockModelSave() {
|
||||
const item = pageData.goodsList[pageData.selGoodsIndex]
|
||||
const goods =await $getProductDetail(item.id,false)
|
||||
$updateProduct({
|
||||
...goods,
|
||||
sort:goodsStockData.sort,
|
||||
isStock:goodsStockData.isStock
|
||||
}).then(res=>{
|
||||
item.sort=goodsStockData.sort
|
||||
item.isStock=goodsStockData.isStock
|
||||
item.stockNumber=goodsStockData.stockNumber
|
||||
goodsStockModelCancel()
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
//点击修改按钮弹出修改商品弹窗
|
||||
function goodsChangeClick(index) {
|
||||
pageData.selGoodsIndex = index
|
||||
const goods = pageData.goodsList[index]
|
||||
Object.assign(goodsStockData,goods)
|
||||
goodsStockModel.value.open()
|
||||
}
|
||||
//删除商品
|
||||
function goodsDel(index){
|
||||
const goods = pageData.goodsList[index]
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确认删除该商品',
|
||||
success: function (res) {
|
||||
if (res.confirm) {
|
||||
$delProduct([goods.id]).then(res=>{
|
||||
uni.showToast({
|
||||
title:'删除成功',
|
||||
icon:'none'
|
||||
})
|
||||
pageData.goodsList.splice(index,1)
|
||||
})
|
||||
} else if (res.cancel) {
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
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.goodsList[index].checked = checked
|
||||
} else {
|
||||
pageData.goodsList.map(v => {
|
||||
v.checked = checked
|
||||
})
|
||||
}
|
||||
control.value.setisSelectAll(isAllChecked() ? true : false)
|
||||
}
|
||||
|
||||
|
||||
// 获取已经选中的商品
|
||||
function getChechkedGoodsList() {
|
||||
return pageData.goodsList.filter(v => v.checked)
|
||||
}
|
||||
//是否全部选中
|
||||
function isAllChecked() {
|
||||
return getChechkedGoodsList().length === pageData.goodsList.length
|
||||
}
|
||||
// 是否有商品选中
|
||||
function isHasChekdGoods() {
|
||||
return getChechkedGoodsList().length ? true : false
|
||||
}
|
||||
|
||||
function searchFunc() {
|
||||
console.log('searchFunc');
|
||||
getGoodsList()
|
||||
}
|
||||
|
||||
let showChecked = ref(false)
|
||||
|
||||
//商品start
|
||||
|
||||
function goodsRadioClick(index) {
|
||||
var checked = !pageData.goodsList[index].checked
|
||||
changeGoodsChecked(checked, index)
|
||||
}
|
||||
|
||||
|
||||
//下架
|
||||
function offShelf() {
|
||||
const hasCheckedArr = getChechkedGoodsList()
|
||||
const hasChecked = isHasChekdGoods()
|
||||
if (!hasChecked) {
|
||||
return infoBox.showToast('您还没有选中商品!')
|
||||
}
|
||||
model.value.open()
|
||||
}
|
||||
//下架确认
|
||||
function modelConfirm() {
|
||||
console.log('confirm');
|
||||
model.value.close()
|
||||
}
|
||||
|
||||
//商品end
|
||||
|
||||
//控制条
|
||||
function controlChange(bol) {
|
||||
showChecked.value = bol
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 全选
|
||||
function allCheckedChange(checked) {
|
||||
changeGoodsChecked(checked)
|
||||
}
|
||||
|
||||
// 页数改变事件
|
||||
function pageChange(page) {
|
||||
console.log(page);
|
||||
pageData.query.page = page - 1
|
||||
getGoodsList()
|
||||
}
|
||||
|
||||
//分类
|
||||
const category = ref(null)
|
||||
|
||||
function toggleCategory() {
|
||||
category.value.toggle()
|
||||
}
|
||||
|
||||
function cateClick(cate) {
|
||||
console.log(cate);
|
||||
pageData.query.categoryId=cate.id
|
||||
pageData.categoryName=cate.name
|
||||
pageData.category=cate
|
||||
getGoodsList()
|
||||
}
|
||||
</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: 40rpx;
|
||||
|
||||
.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;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user