同步代码
This commit is contained in:
@@ -0,0 +1,128 @@
|
||||
<template>
|
||||
<view class="item">
|
||||
<view class="u-flex u-row-between">
|
||||
<view>#{{index+1}} {{data.name}}</view>
|
||||
<view class="color-666 u-font-24 id">ID:{{data.id}}</view>
|
||||
</view>
|
||||
<view class="u-m-t-16 color-666 u-font-24 u-p-b-24 border-bottom">
|
||||
添加时间:
|
||||
<uni-dateformat :date="data.createdAt"></uni-dateformat>
|
||||
</view>
|
||||
<view class="u-m-t-24">
|
||||
<view v-for="(spec,specIndex) in data.specList" :key="specIndex">
|
||||
<view class="font-bold " :class="{'u-m-t-32':specIndex>0}"> {{spec.name}}</view>
|
||||
<view class="u-m-t-24 bg-gray u-flex u-flex-wrap options u-p-24">
|
||||
<view class="u-flex option" v-for="(option,optionIndex) in spec.value" :key="optionIndex" @tap="statusClick(optionIndex)">
|
||||
{{option}}
|
||||
<!-- <view class="sellout" v-if="option.sellOut">已售罄</view>
|
||||
<view class="tag-primary tag" v-if="option.status">上架中</view>
|
||||
<view class="tag-gray tag" v-else>上架中</view> -->
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
<view class="u-m-t-20 u-flex u-row-right btns">
|
||||
<my-button @tap="del" :plain="btnProps.plain" :fontSize="btnProps.fontSize" :width="btnProps.width" :height="btnProps.height" type="cancel" :shape="btnProps.shape" >删除</my-button>
|
||||
<my-button @tap="edit" :plain="btnProps.plain" :fontSize="btnProps.fontSize" :width="btnProps.width" :height="btnProps.height" :shape="btnProps.shape">编辑</my-button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { reactive, ref } from 'vue';
|
||||
import myButton from "@/components/my-components/my-button.vue"
|
||||
import go from '@/commons/utils/go.js'
|
||||
const props=defineProps({
|
||||
index:{
|
||||
type:Number,
|
||||
},
|
||||
data:{
|
||||
type:Object,
|
||||
default:()=>{
|
||||
return {}
|
||||
}
|
||||
}
|
||||
})
|
||||
const emits=defineEmits(['del','edit','statusClick'])
|
||||
function del(){
|
||||
emits('del',props.index)
|
||||
}
|
||||
function edit(){
|
||||
uni.$emit('edit:spec',props.data)
|
||||
uni.setStorageSync('spec',props.data)
|
||||
go.to('PAGES_PRODUCT_GUIGE_ADD', {
|
||||
type: 'edit'
|
||||
})
|
||||
// emits('edit',props.index)
|
||||
}
|
||||
function statusClick(optionIndex){
|
||||
emits('statusClick',[props.index,optionIndex])
|
||||
}
|
||||
const btnProps=reactive({
|
||||
shape:'circle',
|
||||
width:120,
|
||||
height:48,
|
||||
fontSize:24,
|
||||
plain:true
|
||||
})
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.btns{
|
||||
gap: 0 20rpx;
|
||||
}
|
||||
.item{
|
||||
background: #FFFFFF;
|
||||
padding: 32rpx 24rpx;
|
||||
border-radius: 18rpx 18rpx 18rpx 18rpx;
|
||||
margin-bottom: 30rpx;
|
||||
.id{
|
||||
background: #F4F4F4;
|
||||
padding: 6rpx 10rpx;
|
||||
border-radius: 8rpx 8rpx 8rpx 8rpx;
|
||||
}
|
||||
.options{
|
||||
gap: 10rpx 50rpx;
|
||||
.option{
|
||||
padding: 12rpx 40rpx;
|
||||
background: #F0F2F5;
|
||||
border-radius: 4rpx;
|
||||
font-size: 24rpx;
|
||||
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;
|
||||
}
|
||||
.sellout{
|
||||
position: absolute;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background-color: rgb(147, 147, 153);
|
||||
color: #fff;
|
||||
text-align: center;
|
||||
font-size: 20rpx;
|
||||
}
|
||||
.tag-primary{
|
||||
background-color: $my-main-color;
|
||||
color: #fff;
|
||||
}
|
||||
.tag-gray{
|
||||
background-color: rgb(147, 147, 153);
|
||||
color: #fff;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
</style>
|
||||
183
pageProduct/specification-template/specification-template.vue
Normal file
183
pageProduct/specification-template/specification-template.vue
Normal file
@@ -0,0 +1,183 @@
|
||||
<template>
|
||||
<view class="u-p-30 min-page bg-gray">
|
||||
<view v-for="(item,index) in pageData.list" :key="index">
|
||||
<specifications-item @statusClick="specificationsStatusClick" @del="delSpecifications" @edit="editSpecifications" :data="item" :index="index"></specifications-item>
|
||||
</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>
|
||||
|
||||
<my-model :showBtn="modelData.showBtn" ref="model" @confirm="modelConfirm" :title="modelData.title" :desc="modelData.desc">
|
||||
<template #desc>
|
||||
<view class="u-p-30 u-m-t-40 u-p-b-60" v-if="specificationsData">
|
||||
<view class="u-flex u-row-between">
|
||||
<view>当前状态</view>
|
||||
<view class="u-flex-1 u-p-l-60">
|
||||
<uni-data-checkbox v-model="specificationsData.status"
|
||||
@change="specificationsStatusChange"
|
||||
:localdata="statusData"></uni-data-checkbox>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
<view class="u-m-t-30 u-p-t-30" style="border-top: 1px solid rgb(245, 245, 245);">
|
||||
<view class="u-flex u-row-between">
|
||||
<view>售罄</view>
|
||||
<my-switch @change="specificationsSellOutChange" v-model="specificationsData.sellOut"></my-switch>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</template>
|
||||
|
||||
</my-model>
|
||||
|
||||
<view class="fixed-b">
|
||||
<my-button @tap="toAdd" shape="circle">添加规格组</my-button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
reactive,
|
||||
ref
|
||||
} from 'vue';
|
||||
import {onLoad,onShow} from '@dcloudio/uni-app'
|
||||
import go from '@/commons/utils/go.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 specificationsItem from './components/specifications-item.vue'
|
||||
import {$productSpec} from '@/http/yskApi/goods.js'
|
||||
|
||||
|
||||
const statusData=[
|
||||
{
|
||||
text: '上架中',
|
||||
value: 1
|
||||
},
|
||||
{
|
||||
text: '已下架',
|
||||
value: 0
|
||||
}
|
||||
]
|
||||
|
||||
const model = ref(null)
|
||||
const specificationsData=reactive({
|
||||
index:null,
|
||||
optionIndex:null,
|
||||
status:1,
|
||||
sellOut:false
|
||||
})
|
||||
function specificationsSellOutChange(isSellOut){
|
||||
const {index,optionIndex}=specificationsData
|
||||
if(index!==null&&optionIndex!==null){
|
||||
pageData.list[index].options[optionIndex].sellOut=isSellOut
|
||||
}
|
||||
}
|
||||
function specificationsStatusChange(e){
|
||||
const {index,optionIndex}=specificationsData
|
||||
if(index!==null&&optionIndex!==null){
|
||||
pageData.list[index].options[optionIndex].status=e.detail.value
|
||||
}
|
||||
}
|
||||
function modelOpen(){
|
||||
model.value.open()
|
||||
}
|
||||
function modelClose(){
|
||||
model.value.close()
|
||||
}
|
||||
function modelConfirm(){
|
||||
console.log('modelConfirm');
|
||||
modelClose()
|
||||
}
|
||||
const modelData = reactive({
|
||||
title: '',
|
||||
desc: '',
|
||||
showBtn:true
|
||||
})
|
||||
const pageData = reactive({
|
||||
query:{
|
||||
page: 0,
|
||||
size:10
|
||||
},
|
||||
totalElements:0,
|
||||
list: []
|
||||
})
|
||||
|
||||
function delSpecifications(index){
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '删除后使用此模板的商品将取消此规格,是否继续?',
|
||||
success: function (res) {
|
||||
if (res.confirm) {
|
||||
console.log('用户点击确定');
|
||||
$productSpec.del([pageData.list[index].id]).then(res=>{
|
||||
uni.showToast({
|
||||
title:'删除成功',
|
||||
icon:'none'
|
||||
})
|
||||
init()
|
||||
})
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
function specificationsStatusClick(arr){
|
||||
console.log(arr);
|
||||
modelData.title=pageData.list[arr[0]].name
|
||||
modelData.desc=''
|
||||
modelData.showBtn=false
|
||||
|
||||
specificationsData.status=1
|
||||
specificationsData.sellOut=false
|
||||
specificationsData.index=arr[0]
|
||||
specificationsData.optionIndex=arr[1]
|
||||
// modelOpen()
|
||||
}
|
||||
function pageChange(page) {
|
||||
pageData.query.page=page-1
|
||||
init()
|
||||
}
|
||||
|
||||
let emitName = 'guigeEdit'
|
||||
|
||||
uni.$on(emitName, function(data) {
|
||||
console.log(data);
|
||||
})
|
||||
|
||||
function editSpecifications(index){
|
||||
uni.setStorageSync('guige', pageData.list[index])
|
||||
emitName='guigeEdit'
|
||||
go.to('PAGES_PRODUCT_GUIGE_ADD', {
|
||||
emitName: emitName
|
||||
})
|
||||
}
|
||||
|
||||
function toAdd() {
|
||||
// uni.setStorageSync('guige', FormData.specificationsGroup)
|
||||
go.to('PAGES_PRODUCT_GUIGE_ADD')
|
||||
}
|
||||
|
||||
function init(){
|
||||
$productSpec.get(pageData.query).then(res=>{
|
||||
console.log(res);
|
||||
pageData.list=res.content
|
||||
pageData.totalElements=res.totalElements
|
||||
})
|
||||
}
|
||||
onShow(()=>{
|
||||
init()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.fixed-b {
|
||||
position: fixed;
|
||||
left: 110rpx;
|
||||
right: 110rpx;
|
||||
bottom: 80rpx;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user