商品编辑增加套餐商品,称重商品,定时上下架,是否允许临时改价,限购等
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,34 +1,30 @@
|
|||||||
<template>
|
<template>
|
||||||
<view class="mask u-fixed position-all u-flex u-col-bottom" v-if="show" @tap="close">
|
<view class="mask u-fixed position-all u-flex u-col-bottom u-font-28" v-if="show" @tap="close">
|
||||||
<view class="bg-fff w-full" @tap.stop="nullFunction">
|
<view class="bg-fff w-full " @tap.stop="nullFunction">
|
||||||
<view class="u-p-30">
|
<view class="u-p-30">
|
||||||
<view class="font-bold u-text-center">选择商品</view>
|
<view class="font-bold u-text-center">选择商品</view>
|
||||||
<view class="u-m-t-32 u-flex">
|
<view class="u-m-t-32 u-flex">
|
||||||
<view class="u-flex-1 u-p-r-16">
|
<view class=" ">
|
||||||
<view class="u-m-b-12">商品名称</view>
|
|
||||||
<uni-easyinput v-model="goods.query.name" placeholder="请输入商品名称" />
|
|
||||||
</view>
|
|
||||||
<view class="u-flex-1 u-p-l-16">
|
|
||||||
<view class="u-m-b-12">商品分类</view>
|
|
||||||
<uni-data-picker :clear-icon="false" :map="{text:'name',value:'id'}" placeholder="请选择分类"
|
<uni-data-picker :clear-icon="false" :map="{text:'name',value:'id'}" placeholder="请选择分类"
|
||||||
popup-title="请选择分类" :localdata="category" v-model="goods.query.categoryId">
|
popup-title="请选择分类" :localdata="category" v-model="goods.query.categoryId">
|
||||||
|
<view class="u-flex u-font-28" >
|
||||||
|
<text class=" u-line-1"
|
||||||
|
style="max-width: 100rpx;">{{goods.query.categoryId||'分类' }}</text>
|
||||||
|
<up-icon name="arrow-down" size="16"></up-icon>
|
||||||
|
</view>
|
||||||
</uni-data-picker>
|
</uni-data-picker>
|
||||||
</view>
|
</view>
|
||||||
|
<view class="u-flex-1 u-p-l-16">
|
||||||
|
<up-search @custom="getGoods" v-model="goods.query.name" placeholder="请输入商品名称" @search="getGoods" @clear="getGoods"></up-search>
|
||||||
|
</view>
|
||||||
|
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="u-m-t-32 u-flex u-row-right">
|
|
||||||
<view class="u-flex-1 u-p-r-16">
|
|
||||||
<my-button type="cancel" plain @tap="resetQuery">重置</my-button>
|
|
||||||
</view>
|
|
||||||
<view class="u-flex-1 u-p-l-16">
|
|
||||||
<my-button @tap="getGoods">查询</my-button>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<scroll-view :scroll-x="false" scroll-y="true" :style="computedStyle()">
|
<scroll-view :scroll-x="false" scroll-y="true" :style="computedStyle()">
|
||||||
<view class="u-p-l-30 u-p-r-30">
|
<view class="u-p-l-30 u-p-r-30 table">
|
||||||
<view class="u-flex u-row-between no-wrap">
|
<view class="u-flex u-row-between no-wrap title">
|
||||||
<view>
|
<view>
|
||||||
<my-radio @change="radioAllChange" v-model="goods.allChecked" shape="square"
|
<my-radio @change="radioAllChange" v-model="goods.allChecked" shape="square"
|
||||||
:size="20"></my-radio>
|
:size="20"></my-radio>
|
||||||
@@ -41,22 +37,26 @@
|
|||||||
<view>销量/库存</view>
|
<view>销量/库存</view>
|
||||||
<view>分类名称</view>
|
<view>分类名称</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="u-m-t-12 u-flex u-row-between" v-for="(item,index) in goods.list" :key="index">
|
<view @click="changeChecked(item)" class="u-m-t-12 u-flex u-p-24 u-row-between row" v-for="(item,index) in goods.list" :key="index">
|
||||||
<my-radio @change="radioChange" v-model="item.checked" shape="square" :size="20"></my-radio>
|
<view class="">
|
||||||
<view class="u-flex u-flex-col u-row-center u-col-center">
|
<my-radio @change="radioChange($event,item)" v-model="item.checked" shape="square" :size="20"></my-radio>
|
||||||
<image lazy-load class="coverImg" :src="item.coverImg" mode=""></image>
|
|
||||||
<view class="u-m-t-10">{{item.name}}</view>
|
|
||||||
</view>
|
</view>
|
||||||
<view>
|
<view class="u-text-left u-flex-1 u-p-l-20">
|
||||||
|
<!-- <view class="u-flex">
|
||||||
|
<image lazy-load class="coverImg" :src="item.coverImg" mode=""></image>
|
||||||
|
</view> -->
|
||||||
|
<view class="">{{item.name}}</view>
|
||||||
|
</view>
|
||||||
|
<view class="u-flex-1">
|
||||||
{{item.typeEnum}}
|
{{item.typeEnum}}
|
||||||
</view>
|
</view>
|
||||||
<view>
|
<view class="u-flex-1">
|
||||||
¥{{ item.lowPrice }}
|
¥{{ item.lowPrice }}
|
||||||
</view>
|
</view>
|
||||||
<view>
|
<view class="u-flex-1">
|
||||||
{{ item.realSalesNumber }}/{{ item.stockNumber }}
|
{{ item.realSalesNumber }}/{{ item.stockNumber }}
|
||||||
</view>
|
</view>
|
||||||
<view>
|
<view class="u-flex-1">
|
||||||
{{item.categoryName}}
|
{{item.categoryName}}
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -83,7 +83,7 @@
|
|||||||
import myRadio from '@/components/my-components/my-radio';
|
import myRadio from '@/components/my-components/my-radio';
|
||||||
import myPagination from '@/components/my-components/my-pagination'
|
import myPagination from '@/components/my-components/my-pagination'
|
||||||
import {
|
import {
|
||||||
$tbProductV2
|
$tbProductList
|
||||||
} from '@/http/yskApi/goods.js';
|
} from '@/http/yskApi/goods.js';
|
||||||
import {
|
import {
|
||||||
reactive,
|
reactive,
|
||||||
@@ -98,7 +98,7 @@
|
|||||||
},
|
},
|
||||||
height: {
|
height: {
|
||||||
type: [Number, String],
|
type: [Number, String],
|
||||||
default: '40vh'
|
default: '50vh'
|
||||||
},
|
},
|
||||||
category: {
|
category: {
|
||||||
type: Array,
|
type: Array,
|
||||||
@@ -107,26 +107,39 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
function changeChecked(item){
|
||||||
|
item.checked=!item.checked
|
||||||
|
if(!item.checked&&$selGoodsMap[item.id]){
|
||||||
|
delete $selGoodsMap[item.id]
|
||||||
|
}else{
|
||||||
|
$selGoodsMap[item.id]=item
|
||||||
|
}
|
||||||
|
goods.allChecked = goods.list.filter(v => v.checked).length != 0
|
||||||
|
}
|
||||||
function nullFunction() {
|
function nullFunction() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const show = ref(props.modelValue)
|
const show = ref(props.modelValue)
|
||||||
|
|
||||||
function open(arr) {
|
let selArr=[]
|
||||||
|
|
||||||
|
let $selGoodsMap={}
|
||||||
|
async function open(arr) {
|
||||||
show.value = true
|
show.value = true
|
||||||
if (arr) {
|
selArr=arr
|
||||||
for (let i in goods.list) {
|
console.log(arr);
|
||||||
console.log(arr.includes(goods.list[i].id));
|
for(let i in arr){
|
||||||
goods.list[i].checked = arr.includes(goods.list[i].id)
|
$selGoodsMap[arr[i].proId
|
||||||
}
|
]=arr[i]
|
||||||
}
|
}
|
||||||
|
getGoods()
|
||||||
}
|
}
|
||||||
|
|
||||||
function close() {
|
function close() {
|
||||||
show.value = false
|
show.value = false
|
||||||
|
resetQuery()
|
||||||
|
$selGoodsMap={}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -162,38 +175,58 @@
|
|||||||
...$quey
|
...$quey
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
getGoods()
|
||||||
function getGoods() {
|
function getGoods() {
|
||||||
$tbProductV2(goods.query).then(res => {
|
const arr=selArr
|
||||||
|
$tbProductList(goods.query).then(res => {
|
||||||
|
let selLen=0;
|
||||||
goods.list = res.content.map(v => {
|
goods.list = res.content.map(v => {
|
||||||
|
const checked=$selGoodsMap[v.id]?true:false
|
||||||
|
selLen+=(checked?1:0)
|
||||||
return {
|
return {
|
||||||
...v,
|
...v,
|
||||||
checked: false
|
checked
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
goods.allChecked = false
|
goods.allChecked = selLen==res.content.length?true:false
|
||||||
goods.totalElements = res.totalElements
|
goods.totalElements = res.totalElements
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
getGoods()
|
|
||||||
|
|
||||||
function pageChange(page) {
|
function pageChange(page) {
|
||||||
goods.query.page = page - 1
|
goods.query.page = page - 1
|
||||||
getGoods()
|
getGoods()
|
||||||
}
|
}
|
||||||
|
|
||||||
function radioChange(newval) {
|
function radioChange(newval,item) {
|
||||||
|
if(!newval&&$selGoodsMap[item.id]){
|
||||||
|
delete $selGoodsMap[item.id]
|
||||||
|
}else{
|
||||||
|
$selGoodsMap[item.id]=item
|
||||||
|
}
|
||||||
goods.allChecked = goods.list.filter(v => v.checked).length != 0
|
goods.allChecked = goods.list.filter(v => v.checked).length != 0
|
||||||
}
|
}
|
||||||
|
|
||||||
function radioAllChange(newval) {
|
function radioAllChange(newval) {
|
||||||
goods.list.forEach(i => {
|
goods.list.forEach(i => {
|
||||||
i.checked = newval
|
i.checked = newval
|
||||||
|
if($selGoodsMap[i.id]&&!newval){
|
||||||
|
delete $selGoodsMap[i.id]
|
||||||
|
}else{
|
||||||
|
$selGoodsMap[i.id]=i
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function confrim() {
|
function confrim() {
|
||||||
const arr = goods.list.filter(v => v.checked)
|
for(let i in goods.list){
|
||||||
|
const item=goods.list[i]
|
||||||
|
if($selGoodsMap[item.id]&&!item.checked){
|
||||||
|
delete $selGoodsMap[item.id]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.log($selGoodsMap);
|
||||||
|
const arr = Object.values($selGoodsMap)
|
||||||
emits('confirm', arr)
|
emits('confirm', arr)
|
||||||
}
|
}
|
||||||
defineExpose({
|
defineExpose({
|
||||||
@@ -203,6 +236,9 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
.bg-fff{
|
||||||
|
border-radius: 24rpx 24rpx 0 0 ;
|
||||||
|
}
|
||||||
.mask {
|
.mask {
|
||||||
background: rgba(51, 51, 51, 0.5);
|
background: rgba(51, 51, 51, 0.5);
|
||||||
z-index: 900;
|
z-index: 900;
|
||||||
@@ -213,4 +249,20 @@
|
|||||||
height: 60rpx;
|
height: 60rpx;
|
||||||
border-radius: 10rpx;
|
border-radius: 10rpx;
|
||||||
}
|
}
|
||||||
|
.table {
|
||||||
|
background: #F9F9F9;
|
||||||
|
border-radius: 8rpx;
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
|
.title {
|
||||||
|
padding: 12rpx 24rpx 12rpx 24rpx;
|
||||||
|
background: #AEBAD2;
|
||||||
|
border-radius: 8rpx 8rpx 0rpx 0rpx;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.row:nth-of-type(2n+1) {
|
||||||
|
background: #F0F0F0;
|
||||||
|
}
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
164
pageProduct/add-Product/components/choose-guige.vue
Normal file
164
pageProduct/add-Product/components/choose-guige.vue
Normal file
@@ -0,0 +1,164 @@
|
|||||||
|
<template>
|
||||||
|
<view class="mask u-fixed position-all u-flex u-col-bottom u-font-28" v-if="show" @tap="close">
|
||||||
|
<view class="bg-fff w-full " @tap.stop="nullFunction">
|
||||||
|
<view class="u-p-30">
|
||||||
|
<view class="font-bold u-text-center">选择规格</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<scroll-view :scroll-x="false" scroll-y="true" :style="computedStyle()">
|
||||||
|
<view class="u-p-l-30 u-p-r-30 ">
|
||||||
|
<view class="u-flex u-flex-wrap w-full gap-10 u-col-top">
|
||||||
|
<view class="skd" v-for="(item,index) in skuList" :key="index"
|
||||||
|
:class="{active:sel.id==item.id}"
|
||||||
|
@click="guigeClick(item,index)">
|
||||||
|
<text>{{item.specSnap||item.name}}</text>
|
||||||
|
<view class="tag-primary tag" v-if="item.isGrounding">上架中</view>
|
||||||
|
<view class="tag-gray tag" v-if="item.isPauseSale">已售罄</view>
|
||||||
|
<view class="tag-gray tag" v-if="!item.isGrounding">已下架</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
</view>
|
||||||
|
</scroll-view>
|
||||||
|
<view class="u-p-30">
|
||||||
|
<view class="u-m-t-20 u-flex">
|
||||||
|
<view class="u-flex-1 u-p-r-16">
|
||||||
|
<my-button type="cancel" plain @tap="close">取消</my-button>
|
||||||
|
</view>
|
||||||
|
<view class="u-flex-1 u-p-l-16">
|
||||||
|
<my-button @tap="confrim">确定</my-button>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import {
|
||||||
|
$tbProduct
|
||||||
|
} from '@/http/yskApi/goods.js';
|
||||||
|
import {
|
||||||
|
reactive,
|
||||||
|
onMounted,
|
||||||
|
ref,
|
||||||
|
watch
|
||||||
|
} from 'vue';
|
||||||
|
import infoBox from '@/commons/utils/infoBox.js'
|
||||||
|
const props = defineProps({
|
||||||
|
modelValue: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
let skuList=ref([])
|
||||||
|
function nullFunction() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
const show = ref(props.modelValue)
|
||||||
|
|
||||||
|
|
||||||
|
async function open(arr,sel) {
|
||||||
|
show.value = true
|
||||||
|
skuList.value=arr
|
||||||
|
}
|
||||||
|
|
||||||
|
function close() {
|
||||||
|
show.value = false
|
||||||
|
sel.value={}
|
||||||
|
}
|
||||||
|
|
||||||
|
let sel=ref({
|
||||||
|
|
||||||
|
})
|
||||||
|
function guigeClick(item,index){
|
||||||
|
if(sel.value.id==item.id){
|
||||||
|
return sel.value={}
|
||||||
|
}
|
||||||
|
sel.value=item
|
||||||
|
}
|
||||||
|
|
||||||
|
function computedStyle() {
|
||||||
|
return `height:${typeof props.height==='string'?props.height:props.height+'rpx'};`
|
||||||
|
}
|
||||||
|
|
||||||
|
const emits = defineEmits(['update:modelValue', 'confirm'])
|
||||||
|
|
||||||
|
function confrim() {
|
||||||
|
if(!sel.value.id){
|
||||||
|
return infoBox.showToast('请选择选择一个规格')
|
||||||
|
}
|
||||||
|
emits('confirm', sel.value)
|
||||||
|
close()
|
||||||
|
}
|
||||||
|
defineExpose({
|
||||||
|
open,
|
||||||
|
close
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.bg-fff{
|
||||||
|
border-radius: 24rpx 24rpx 0 0 ;
|
||||||
|
}
|
||||||
|
.mask {
|
||||||
|
background: rgba(51, 51, 51, 0.5);
|
||||||
|
z-index: 900;
|
||||||
|
}
|
||||||
|
.skd {
|
||||||
|
padding: 10rpx 38rpx 8rpx 40rpx;
|
||||||
|
background: #F0F2F5;
|
||||||
|
border-radius: 4rpx;
|
||||||
|
position: relative;
|
||||||
|
color: #666;
|
||||||
|
overflow: hidden;
|
||||||
|
margin-bottom: 10rpx;
|
||||||
|
font-size: 24rpx;
|
||||||
|
border: 1px solid transparent;
|
||||||
|
&.active{
|
||||||
|
border-color: $my-main-color;
|
||||||
|
}
|
||||||
|
.tag {
|
||||||
|
position: absolute;
|
||||||
|
right: 0;
|
||||||
|
top: 0;
|
||||||
|
font-size: 12rpx;
|
||||||
|
height: 18rpx;
|
||||||
|
line-height: 18rpx;
|
||||||
|
right: 0;
|
||||||
|
border-radius: 0rpx 2rpx 2rpx 8rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tag-primary {
|
||||||
|
background-color: $my-main-color;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tag-gray {
|
||||||
|
background-color: rgb(144, 147, 153);
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.coverImg {
|
||||||
|
width: 60rpx;
|
||||||
|
height: 60rpx;
|
||||||
|
border-radius: 10rpx;
|
||||||
|
}
|
||||||
|
.table {
|
||||||
|
background: #F9F9F9;
|
||||||
|
border-radius: 8rpx;
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
|
.title {
|
||||||
|
padding: 12rpx 24rpx 12rpx 24rpx;
|
||||||
|
background: #AEBAD2;
|
||||||
|
border-radius: 8rpx 8rpx 0rpx 0rpx;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.row:nth-of-type(2n+1) {
|
||||||
|
background: #F0F0F0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
105
pageProduct/add-Product/components/price-number-box.vue
Normal file
105
pageProduct/add-Product/components/price-number-box.vue
Normal file
@@ -0,0 +1,105 @@
|
|||||||
|
<template>
|
||||||
|
<view class="u-flex number-box">
|
||||||
|
<view class="u-flex u-flex-1">
|
||||||
|
<up-input @blur="priceFormat" border="none" v-model="number" type="number" :placeholder="placeholder"></up-input>
|
||||||
|
</view>
|
||||||
|
<view class="u-flex u-flex-col right">
|
||||||
|
<view class="u-flex-1 u-p-l-8 u-p-r-8" @click="changeNumber('add')">
|
||||||
|
<up-icon name="arrow-up" color="#E5E5E5"></up-icon>
|
||||||
|
</view>
|
||||||
|
<view class="line"></view>
|
||||||
|
<view class="u-flex-1 u-p-l-8 u-p-r-8" @click="changeNumber('reduce')">
|
||||||
|
<up-icon name="arrow-down" color="#E5E5E5"></up-icon>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import {
|
||||||
|
formatPrice
|
||||||
|
} from "@/commons/utils/format.js";
|
||||||
|
import {
|
||||||
|
ref,
|
||||||
|
watch,nextTick
|
||||||
|
} from 'vue';
|
||||||
|
const props = defineProps({
|
||||||
|
modelValue: {
|
||||||
|
type: [String, Number]
|
||||||
|
},
|
||||||
|
min: {
|
||||||
|
type: Number,
|
||||||
|
default: 0
|
||||||
|
},
|
||||||
|
max: {
|
||||||
|
type: Number,
|
||||||
|
default: 999999999
|
||||||
|
},
|
||||||
|
step: {
|
||||||
|
type: Number,
|
||||||
|
default: 1
|
||||||
|
},
|
||||||
|
placeholder: {
|
||||||
|
type: String,
|
||||||
|
default: '请输入'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
let number = ref(props.modelValue)
|
||||||
|
|
||||||
|
function changeNumber(type) {
|
||||||
|
const newval = number.value + props.step * (type == 'add' ? 1 : -1)
|
||||||
|
if (newval < props.min) {
|
||||||
|
number.value = props.min
|
||||||
|
}
|
||||||
|
if (newval > props.max) {
|
||||||
|
number.value = props.max
|
||||||
|
}
|
||||||
|
priceFormat(newval)
|
||||||
|
}
|
||||||
|
|
||||||
|
function priceFormat(e) {
|
||||||
|
nextTick(() => {
|
||||||
|
const min = props
|
||||||
|
.min;
|
||||||
|
const max = props.max;
|
||||||
|
if (e === '') {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const newval = formatPrice(e, min, max, true)
|
||||||
|
if (typeof newval !== 'number') {
|
||||||
|
number.value = newval.value
|
||||||
|
uni.showToast({
|
||||||
|
title: `请输入${min}到${max}范围内的数字`,
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
number.value = newval
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
watch(() => props.modelValue, (newval) => {
|
||||||
|
number.value = newval
|
||||||
|
})
|
||||||
|
const emits = defineEmits(['update:modelValue'])
|
||||||
|
watch(() => number.value, (newval) => {
|
||||||
|
emits('update:modelValue', newval)
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.line {
|
||||||
|
width: 100%;
|
||||||
|
height: 1px;
|
||||||
|
background-color: #E5E5E5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.number-box {
|
||||||
|
border: 1px solid #E5E5E5;
|
||||||
|
border-radius: 8rpx 8rpx 8rpx 8rpx;
|
||||||
|
padding-left: 24rpx;
|
||||||
|
|
||||||
|
.right {
|
||||||
|
border-left: 1px solid #E5E5E5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
224
pageProduct/add-Product/timer - 副本.vue
Normal file
224
pageProduct/add-Product/timer - 副本.vue
Normal file
@@ -0,0 +1,224 @@
|
|||||||
|
<template>
|
||||||
|
<view class="u-p-30 min-page u-font-28">
|
||||||
|
<!-- <view class="u-flex">
|
||||||
|
<view style="width: 210rpx;">
|
||||||
|
<my-button shape="circle" @click="addTimer">添加定时器</my-button>
|
||||||
|
</view>
|
||||||
|
</view> -->
|
||||||
|
<view class="list u-m-t-20" v-if="list.length">
|
||||||
|
<view class="block" v-for="(item,index) in list" :key="index">
|
||||||
|
<!-- <view class="u-flex u-row-between">
|
||||||
|
<view>定时器{{index+1}}</view>
|
||||||
|
<uni-icons @click="delTimer(index)" type="trash"></uni-icons>
|
||||||
|
</view> -->
|
||||||
|
<view class="u-flex u-row-between">
|
||||||
|
<view>周期</view>
|
||||||
|
<view class="color-main" @click="selectAllClick(index)">
|
||||||
|
{{isAllChecked?'取消全选':'全选'}}
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="u-m-t-24">
|
||||||
|
<uni-data-checkbox :selectedColor="color.ColorMain" multiple v-model="item.cycleChecked" :localdata="cycle"></uni-data-checkbox>
|
||||||
|
</view>
|
||||||
|
<view class="u-m-t-24">
|
||||||
|
<view class="u-flex">
|
||||||
|
<view>上架时间:</view>
|
||||||
|
<view class="u-flex-1 u-m-l-10">
|
||||||
|
<picker mode="multiSelector" @change="listingTimeChange($event,index)"
|
||||||
|
:value="item.listingTime.index" :range="times">
|
||||||
|
<view class="bg-gray u-p-l-20 u-p-t-6 u-p-b-6 u-p-r-20 ">
|
||||||
|
{{item.listingTime.value}}
|
||||||
|
</view>
|
||||||
|
</picker>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="u-flex u-m-t-16">
|
||||||
|
<view>下架时间:</view>
|
||||||
|
<view class="u-flex-1 u-m-l-10">
|
||||||
|
<picker mode="multiSelector" @change="offShelfChange($event,index)"
|
||||||
|
:value="item.offShelf.index" :range="times">
|
||||||
|
<view class="bg-gray u-p-l-20 u-p-t-6 u-p-b-6 u-p-r-20 ">
|
||||||
|
{{item.offShelf.value}}
|
||||||
|
</view>
|
||||||
|
</picker>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view class="u-flex u-row-center u-m-t-60">
|
||||||
|
<my-button width="580" shape="circle" @click="save">保存</my-button>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import {
|
||||||
|
onLoad,
|
||||||
|
onReady
|
||||||
|
} from '@dcloudio/uni-app';
|
||||||
|
import {
|
||||||
|
computed,
|
||||||
|
ref
|
||||||
|
} from 'vue';
|
||||||
|
import go from '@/commons/utils/go.js';
|
||||||
|
import color from '@/commons/color.js'
|
||||||
|
import {
|
||||||
|
$getProductDetail,
|
||||||
|
} from '@/http/yskApi/goods.js'
|
||||||
|
//返回一天的时间 时分格式
|
||||||
|
function returnDayTime() {
|
||||||
|
return new Array(2).fill(1).map((v, index) => {
|
||||||
|
if (index === 0) {
|
||||||
|
return new Array(24).fill(1).map((hour, index) => {
|
||||||
|
return `0${index}`.slice(-2)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if (index === 1) {
|
||||||
|
return new Array(60).fill(1).map((hour, index) => {
|
||||||
|
return `0${index}`.slice(-2)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
const times = ref(returnDayTime())
|
||||||
|
let defaultTimeIndex = ref(0)
|
||||||
|
|
||||||
|
function getTime(indexArr) {
|
||||||
|
const hour = times.value[0][indexArr[0]]
|
||||||
|
const month = times.value[1][indexArr[1]]
|
||||||
|
return `${hour}:${month}`
|
||||||
|
}
|
||||||
|
//获取$event.detail.value
|
||||||
|
function getEnentDetailValue(e) {
|
||||||
|
return e.detail.value
|
||||||
|
}
|
||||||
|
|
||||||
|
function setListTimeValue(index, key, time) {
|
||||||
|
list.value[index][key].value = time
|
||||||
|
}
|
||||||
|
|
||||||
|
function listingTimeChange(e, index) {
|
||||||
|
const indexArr = getEnentDetailValue(e)
|
||||||
|
const time = getTime(indexArr)
|
||||||
|
setListTimeValue(index, 'listingTime', time)
|
||||||
|
}
|
||||||
|
|
||||||
|
function offShelfChange(e, index) {
|
||||||
|
const indexArr = getEnentDetailValue(e)
|
||||||
|
const time = getTime(indexArr)
|
||||||
|
setListTimeValue(index, 'offShelf', time)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const cycle = [{
|
||||||
|
value: 0,
|
||||||
|
text: '星期一'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 1,
|
||||||
|
text: '星期二'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 2,
|
||||||
|
text: '星期三'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 3,
|
||||||
|
text: '星期四'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 4,
|
||||||
|
text: '星期五'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 5,
|
||||||
|
text: '星期六'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 6,
|
||||||
|
text: '星期日'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
const ListDataconstructor = {
|
||||||
|
cycleChecked: [0, 1, 2, 3, 4, 5, 6],
|
||||||
|
}
|
||||||
|
|
||||||
|
function returnBasicTimeConstructor() {
|
||||||
|
return {
|
||||||
|
listingTime: {
|
||||||
|
value: '00:00',
|
||||||
|
index: [0, 0]
|
||||||
|
},
|
||||||
|
offShelf: {
|
||||||
|
value: '00:00',
|
||||||
|
index: [0, 0]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const list = ref([returnBasicDataConstructor()])
|
||||||
|
function returnBasicDataConstructor() {
|
||||||
|
return {
|
||||||
|
...ListDataconstructor,
|
||||||
|
...returnBasicTimeConstructor()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function addTimer() {
|
||||||
|
list.value.push(returnBasicDataConstructor())
|
||||||
|
}
|
||||||
|
function delTimer(index) {
|
||||||
|
list.value.splice(index,1)
|
||||||
|
}
|
||||||
|
const isAllChecked=computed(()=>{
|
||||||
|
return list.value[0].cycleChecked.length==cycle.length?true:false
|
||||||
|
})
|
||||||
|
function selectAllClick(index){
|
||||||
|
if(isAllChecked.value){
|
||||||
|
list.value[index].cycleChecked=[]
|
||||||
|
}else{
|
||||||
|
list.value[index].cycleChecked=ListDataconstructor.cycleChecked
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 触发定时器保存事件将数据给到添加商品页面
|
||||||
|
function emitTimerSave(){
|
||||||
|
uni.$emit('timerSave',list.value)
|
||||||
|
go.back()
|
||||||
|
}
|
||||||
|
function save(){
|
||||||
|
console.log(list.value);
|
||||||
|
emitTimerSave()
|
||||||
|
}
|
||||||
|
let goodsDetail=ref({})
|
||||||
|
|
||||||
|
function returnTimer(res){
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
onLoad(async(opt)=>{
|
||||||
|
let res=null
|
||||||
|
if(opt.productId){
|
||||||
|
res=await $getProductDetail(opt.productId)
|
||||||
|
goodsDetail.value=res
|
||||||
|
}
|
||||||
|
const arr=res?returnTimer(res):[]
|
||||||
|
if(arr.length){
|
||||||
|
list.value=arr
|
||||||
|
}
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
.min-page {
|
||||||
|
background-color: #F9F9F9;
|
||||||
|
}
|
||||||
|
|
||||||
|
.block {
|
||||||
|
background: #FFFFFF;
|
||||||
|
border-radius: 18rpx 18rpx 18rpx 18rpx;
|
||||||
|
padding: 32rpx 28rpx;
|
||||||
|
margin-bottom: 32rpx;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -1,42 +1,45 @@
|
|||||||
<template>
|
<template>
|
||||||
<view class="u-p-30 min-page">
|
<view class="u-p-30 min-page u-font-28">
|
||||||
<view class="u-flex">
|
<!-- <view class="u-flex">
|
||||||
<view style="width: 210rpx;">
|
<view style="width: 210rpx;">
|
||||||
<my-button shape="circle" @click="addTimer">添加定时器</my-button>
|
<my-button shape="circle" @click="addTimer">添加定时器</my-button>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view> -->
|
||||||
<view class="list u-m-t-20" v-if="list.length">
|
<view class="list u-m-t-20" v-if="list.length">
|
||||||
<view class="block" v-for="(item,index) in list" :key="index">
|
<view class="block" v-for="(item,index) in list" :key="index">
|
||||||
<view class="u-flex u-row-between">
|
<!-- <view class="u-flex u-row-between">
|
||||||
<view>定时器{{index+1}}</view>
|
<view>定时器{{index+1}}</view>
|
||||||
<uni-icons @click="delTimer(index)" type="trash"></uni-icons>
|
<uni-icons @click="delTimer(index)" type="trash"></uni-icons>
|
||||||
</view>
|
</view> -->
|
||||||
<view class="u-flex u-m-t-20 u-row-between">
|
<view class="u-flex u-row-between">
|
||||||
<view>周期</view>
|
<view>周期</view>
|
||||||
<view @click="selectAllClick(index)">全选</view>
|
<view class="color-main" @click="selectAllClick(index)">
|
||||||
|
{{isAllChecked?'取消全选':'全选'}}
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="u-m-t-20">
|
<view class="u-m-t-24">
|
||||||
<uni-data-checkbox multiple v-model="item.cycleChecked" :localdata="cycle"></uni-data-checkbox>
|
<uni-data-checkbox :selectedColor="color.ColorMain" multiple v-model="item.cycleChecked"
|
||||||
|
:localdata="cycle"></uni-data-checkbox>
|
||||||
</view>
|
</view>
|
||||||
<view class="u-m-t-20">
|
<view class="u-m-t-24">
|
||||||
<view class="u-flex">
|
<view class="u-flex">
|
||||||
<view>上架时间:</view>
|
<view>上架时间:</view>
|
||||||
<view class="u-flex-1 u-m-l-10">
|
<view class="u-flex-1 u-m-l-10">
|
||||||
<picker mode="multiSelector" @change="listingTimeChange($event,index)"
|
<picker mode="multiSelector" @change="startTimeChange($event,index)"
|
||||||
:value="item.listingTime.index" :range="times">
|
:value="item.startTime.index" :range="times">
|
||||||
<view class="bg-gray u-p-l-20 u-p-t-6 u-p-b-6 u-p-r-20 ">
|
<view class="bg-gray u-p-l-20 u-p-t-6 u-p-b-6 u-p-r-20 ">
|
||||||
{{item.listingTime.value}}
|
{{item.startTime.value}}
|
||||||
</view>
|
</view>
|
||||||
</picker>
|
</picker>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="u-flex u-m-t-20">
|
<view class="u-flex u-m-t-16">
|
||||||
<view>下架时间:</view>
|
<view>下架时间:</view>
|
||||||
<view class="u-flex-1 u-m-l-10">
|
<view class="u-flex-1 u-m-l-10">
|
||||||
<picker mode="multiSelector" @change="offShelfChange($event,index)"
|
<picker mode="multiSelector" @change="endTimeChange($event,index)"
|
||||||
:value="item.offShelf.index" :range="times">
|
:value="item.endTime.index" :range="times">
|
||||||
<view class="bg-gray u-p-l-20 u-p-t-6 u-p-b-6 u-p-r-20 ">
|
<view class="bg-gray u-p-l-20 u-p-t-6 u-p-b-6 u-p-r-20 ">
|
||||||
{{item.offShelf.value}}
|
{{item.endTime.value}}
|
||||||
</view>
|
</view>
|
||||||
</picker>
|
</picker>
|
||||||
</view>
|
</view>
|
||||||
@@ -58,19 +61,23 @@
|
|||||||
onReady
|
onReady
|
||||||
} from '@dcloudio/uni-app';
|
} from '@dcloudio/uni-app';
|
||||||
import {
|
import {
|
||||||
|
computed,
|
||||||
ref
|
ref
|
||||||
} from 'vue';
|
} from 'vue';
|
||||||
import go from '@/commons/utils/go.js';
|
import go from '@/commons/utils/go.js';
|
||||||
import myButton from '@/components/my-components/my-button.vue'
|
import color from '@/commons/color.js'
|
||||||
|
import {
|
||||||
|
$getProductDetail,
|
||||||
|
} from '@/http/yskApi/goods.js'
|
||||||
//返回一天的时间 时分格式
|
//返回一天的时间 时分格式
|
||||||
function returnDayTime() {
|
function returnDayTime() {
|
||||||
return new Array(2).fill(1).map((v, index) => {
|
return new Array(3).fill(1).map((v, index) => {
|
||||||
if (index === 0) {
|
if (index === 0) {
|
||||||
return new Array(24).fill(1).map((hour, index) => {
|
return new Array(24).fill(1).map((hour, index) => {
|
||||||
return `0${index}`.slice(-2)
|
return `0${index}`.slice(-2)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if (index === 1) {
|
if (index === 1 || index === 2) {
|
||||||
return new Array(60).fill(1).map((hour, index) => {
|
return new Array(60).fill(1).map((hour, index) => {
|
||||||
return `0${index}`.slice(-2)
|
return `0${index}`.slice(-2)
|
||||||
})
|
})
|
||||||
@@ -83,7 +90,8 @@
|
|||||||
function getTime(indexArr) {
|
function getTime(indexArr) {
|
||||||
const hour = times.value[0][indexArr[0]]
|
const hour = times.value[0][indexArr[0]]
|
||||||
const month = times.value[1][indexArr[1]]
|
const month = times.value[1][indexArr[1]]
|
||||||
return `${hour}:${month}`
|
const s = times.value[2][indexArr[2]]
|
||||||
|
return `${hour}:${month}:${s}`
|
||||||
}
|
}
|
||||||
//获取$event.detail.value
|
//获取$event.detail.value
|
||||||
function getEnentDetailValue(e) {
|
function getEnentDetailValue(e) {
|
||||||
@@ -94,66 +102,67 @@
|
|||||||
list.value[index][key].value = time
|
list.value[index][key].value = time
|
||||||
}
|
}
|
||||||
|
|
||||||
function listingTimeChange(e, index) {
|
function startTimeChange(e, index) {
|
||||||
const indexArr = getEnentDetailValue(e)
|
const indexArr = getEnentDetailValue(e)
|
||||||
const time = getTime(indexArr)
|
const time = getTime(indexArr)
|
||||||
setListTimeValue(index, 'listingTime', time)
|
setListTimeValue(index, 'startTime', time)
|
||||||
}
|
}
|
||||||
|
|
||||||
function offShelfChange(e, index) {
|
function endTimeChange(e, index) {
|
||||||
const indexArr = getEnentDetailValue(e)
|
const indexArr = getEnentDetailValue(e)
|
||||||
const time = getTime(indexArr)
|
const time = getTime(indexArr)
|
||||||
setListTimeValue(index, 'offShelf', time)
|
setListTimeValue(index, 'endTime', time)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const cycle = [{
|
const cycle = [{
|
||||||
value: 0,
|
value: 'Monday',
|
||||||
text: '星期一'
|
text: '星期一'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: 1,
|
value: 'Tuesday',
|
||||||
text: '星期二'
|
text: '星期二'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: 2,
|
value: 'Wednesday',
|
||||||
text: '星期三'
|
text: '星期三'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: 3,
|
value: 'Thursday',
|
||||||
text: '星期四'
|
text: '星期四'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: 4,
|
value: 'Friday',
|
||||||
text: '星期五'
|
text: '星期五'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: 5,
|
value: 'Saturday',
|
||||||
text: '星期六'
|
text: '星期六'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: 6,
|
value: 'Sunday',
|
||||||
text: '星期日'
|
text: '星期日'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
const ListDataconstructor = {
|
const ListDataconstructor = {
|
||||||
cycleChecked: [0, 1, 2, 3, 4, 5, 6],
|
cycleChecked: ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'],
|
||||||
}
|
}
|
||||||
|
|
||||||
function returnBasicTimeConstructor() {
|
function returnBasicTimeConstructor() {
|
||||||
return {
|
return {
|
||||||
listingTime: {
|
startTime: {
|
||||||
value: '09:00',
|
value: '00:00:00',
|
||||||
index: [9, 0]
|
index: [0, 0, 0]
|
||||||
},
|
},
|
||||||
offShelf: {
|
endTime: {
|
||||||
value: '18:00',
|
value: '00:00:00',
|
||||||
index: [18, 0]
|
index: [0, 0, 0]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const list = ref([returnBasicDataConstructor()])
|
const list = ref([returnBasicDataConstructor()])
|
||||||
|
|
||||||
function returnBasicDataConstructor() {
|
function returnBasicDataConstructor() {
|
||||||
return {
|
return {
|
||||||
...ListDataconstructor,
|
...ListDataconstructor,
|
||||||
@@ -164,25 +173,68 @@
|
|||||||
function addTimer() {
|
function addTimer() {
|
||||||
list.value.push(returnBasicDataConstructor())
|
list.value.push(returnBasicDataConstructor())
|
||||||
}
|
}
|
||||||
|
|
||||||
function delTimer(index) {
|
function delTimer(index) {
|
||||||
list.value.splice(index,1)
|
list.value.splice(index, 1)
|
||||||
}
|
}
|
||||||
function selectAllClick(index){
|
const isAllChecked = computed(() => {
|
||||||
list.value[index].cycleChecked=ListDataconstructor.cycleChecked
|
return list.value[0].cycleChecked.length == cycle.length ? true : false
|
||||||
|
})
|
||||||
|
|
||||||
|
function selectAllClick(index) {
|
||||||
|
if (isAllChecked.value) {
|
||||||
|
list.value[index].cycleChecked = []
|
||||||
|
} else {
|
||||||
|
list.value[index].cycleChecked = ListDataconstructor.cycleChecked
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// 触发定时器保存事件将数据给到添加商品页面
|
// 触发定时器保存事件将数据给到添加商品页面
|
||||||
function emitTimerSave(){
|
function emitTimerSave() {
|
||||||
uni.$emit('timerSave',list.value)
|
const par={
|
||||||
|
days:list.value[0].cycleChecked.join(','),
|
||||||
|
startTime:list.value[0].startTime.value,
|
||||||
|
endTime:list.value[0].endTime.value
|
||||||
|
}
|
||||||
|
console.log(par);
|
||||||
|
uni.$emit('timerSave',par)
|
||||||
go.back()
|
go.back()
|
||||||
}
|
}
|
||||||
function save(){
|
|
||||||
console.log(list.value);
|
function save() {
|
||||||
emitTimerSave()
|
emitTimerSave()
|
||||||
}
|
}
|
||||||
onLoad(()=>{
|
let goodsDetail = ref({})
|
||||||
const arr=uni.getStorageSync('timer')
|
|
||||||
if(arr.length){
|
function returnTimeIndex(time) {
|
||||||
list.value=arr
|
console.log(time);
|
||||||
|
return time.split(':').map(v=>{
|
||||||
|
return v*1
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function returnTimer(res) {
|
||||||
|
return [{
|
||||||
|
cycleChecked: res.days ? res.days.split(',').filter(v=>v) : [],
|
||||||
|
startTime: res.startTime ? {
|
||||||
|
value: res.startTime,
|
||||||
|
index: returnTimeIndex(res.startTime)
|
||||||
|
} : returnBasicTimeConstructor.startTime,
|
||||||
|
endTime: res.endTime ? {
|
||||||
|
value: res.endTime,
|
||||||
|
index: returnTimeIndex(res.endTime)
|
||||||
|
} : returnBasicTimeConstructor.endTime
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
onLoad(async (opt) => {
|
||||||
|
let res = null
|
||||||
|
if (opt.productId) {
|
||||||
|
res = await $getProductDetail(opt.productId)
|
||||||
|
goodsDetail.value = res
|
||||||
|
}
|
||||||
|
const arr = res ? returnTimer(res) : [];
|
||||||
|
console.log(arr);
|
||||||
|
if (arr.length) {
|
||||||
|
list.value = arr
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
@@ -195,7 +247,7 @@
|
|||||||
.block {
|
.block {
|
||||||
background: #FFFFFF;
|
background: #FFFFFF;
|
||||||
border-radius: 18rpx 18rpx 18rpx 18rpx;
|
border-radius: 18rpx 18rpx 18rpx 18rpx;
|
||||||
padding: 30rpx;
|
padding: 32rpx 28rpx;
|
||||||
margin-bottom: 20rpx;
|
margin-bottom: 32rpx;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
Reference in New Issue
Block a user