代码更新
This commit is contained in:
@@ -10,9 +10,9 @@
|
||||
<view class="u-m-t-48">
|
||||
<up-form labelPosition="left" :model="data" :rules="rules" ref="refForm">
|
||||
<view>商品名称</view>
|
||||
<view class="u-m-t-16" v-if="isSku">{{data.name}}</view>
|
||||
<view class="u-m-t-16" v-if="data.type == 'sku'">{{data.name}}</view>
|
||||
<view class="u-m-t-38">
|
||||
<template v-if="!isSku">
|
||||
<template v-if="data.type != 'sku'">
|
||||
<view class="u-m-b-32">
|
||||
<view class="u-flex u-row-between">
|
||||
<view>{{data.name}}</view>
|
||||
@@ -84,41 +84,11 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
computed,
|
||||
reactive,
|
||||
ref,
|
||||
watch,
|
||||
nextTick,
|
||||
onMounted
|
||||
} from 'vue';
|
||||
import {
|
||||
returnSkuSnap,
|
||||
returnTypeEnum,
|
||||
returnCategory
|
||||
} from '@/pageProduct/util.js'
|
||||
import {
|
||||
formatPrice
|
||||
} from "@/commons/utils/format.js";
|
||||
|
||||
function priceFormat(item, key, val) {
|
||||
let min = 0;
|
||||
let max = 100000000;
|
||||
const returnNewVal = formatPrice(val, min, max, true)
|
||||
const newval = typeof returnNewVal !== 'number' ? returnNewVal.value : returnNewVal
|
||||
if (typeof returnNewVal !== 'number') {
|
||||
uni.showToast({
|
||||
title: `请输入${min}到${max}范围内的数字`,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
setTimeout(() => {
|
||||
item[key] = newval
|
||||
}, 100)
|
||||
}
|
||||
const refForm = ref(null)
|
||||
|
||||
|
||||
import { computed, reactive, ref, watch, onMounted } from 'vue';
|
||||
import { returnSkuSnap, returnTypeEnum, returnCategory } from '@/pageProduct/util.js'
|
||||
import { formatPrice } from "@/commons/utils/format.js";
|
||||
|
||||
const emits = defineEmits(['update:show', 'save'])
|
||||
const props = defineProps({
|
||||
show: {
|
||||
type: Boolean,
|
||||
@@ -135,10 +105,11 @@
|
||||
lowPrice: 0,
|
||||
skuList: []
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
})
|
||||
let popShow = ref(props.show)
|
||||
let data = ref({
|
||||
lowPrice: 0,
|
||||
skuList: []
|
||||
@@ -159,37 +130,57 @@
|
||||
}
|
||||
]
|
||||
}
|
||||
const emits = defineEmits(['update:show', 'save'])
|
||||
const refForm = ref(null)
|
||||
onMounted(()=>{
|
||||
// #ifndef H5
|
||||
refForm.value.setRules(rules)
|
||||
// #endif
|
||||
})
|
||||
watch(() => popShow.value, (newval) => {
|
||||
emits('update:show', newval)
|
||||
})
|
||||
|
||||
/**
|
||||
* 金额处理
|
||||
* @param {Object} item
|
||||
* @param {Object} key
|
||||
* @param {Object} val
|
||||
*/
|
||||
function priceFormat(item, key, val) {
|
||||
let min = 0;
|
||||
let max = 100000000;
|
||||
const returnNewVal = formatPrice(val, min, max, true)
|
||||
const newval = typeof returnNewVal !== 'number' ? returnNewVal.value : returnNewVal
|
||||
if (typeof returnNewVal !== 'number') {
|
||||
uni.showToast({
|
||||
title: `请输入${min}到${max}范围内的数字`,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
setTimeout(() => {
|
||||
item[key] = newval
|
||||
}, 100)
|
||||
}
|
||||
|
||||
|
||||
const form = reactive({
|
||||
note: ''
|
||||
})
|
||||
let popShow = ref(props.show)
|
||||
watch(() => props.show, (newval) => {
|
||||
popShow.value = newval
|
||||
if (newval) {
|
||||
data.value = {
|
||||
...props.goods
|
||||
}
|
||||
|
||||
}
|
||||
})
|
||||
const isSku = computed(() => {
|
||||
return data.value.typeEnum == '多规格'
|
||||
})
|
||||
watch(() => popShow.value, (newval) => {
|
||||
emits('update:show', newval)
|
||||
})
|
||||
|
||||
function close() {
|
||||
popShow.value = false
|
||||
}
|
||||
|
||||
function open() {
|
||||
|
||||
}
|
||||
|
||||
function save() {
|
||||
refForm.value.validate().then(valid => {
|
||||
if (valid) {
|
||||
console.log(data)
|
||||
emits('save', {
|
||||
...data.value,
|
||||
})
|
||||
@@ -200,37 +191,16 @@
|
||||
// 处理验证错误
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
function close() {
|
||||
popShow.value = false
|
||||
}
|
||||
|
||||
function open() {
|
||||
|
||||
}
|
||||
|
||||
// function save() {
|
||||
// const skuSnap = returnSkuSnap(data.value)
|
||||
// let typeEnum = returnTypeEnum(data.value.typeEnum)
|
||||
// let lowPrice = undefined
|
||||
// typeEnum = typeEnum ? typeEnum : 'normal'
|
||||
// const findCategory = returnCategory(data.value.categoryName, props.category)
|
||||
// console.log(typeEnum);
|
||||
// console.log(findCategory);
|
||||
// const categoryId = findCategory ? findCategory.id : ''
|
||||
// if (typeEnum == 'normal') {
|
||||
// // 单规格
|
||||
// lowPrice = data.value.skuList[0].salePrice
|
||||
// }
|
||||
// emits('save', {
|
||||
// ...data.value,
|
||||
// lowPrice,
|
||||
// typeEnum,
|
||||
// images: data.value.images ? data.value.images : [data.value.coverImg],
|
||||
// categoryId,
|
||||
// skuSnap: JSON.stringify(skuSnap)
|
||||
// })
|
||||
// }
|
||||
|
||||
onMounted(()=>{
|
||||
// #ifndef H5
|
||||
refForm.value.setRules(rules)
|
||||
// #endif
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
@@ -32,15 +32,11 @@
|
||||
<view class="info-p-l color-333 u-flex u-row-between">
|
||||
<view class="u-flex">
|
||||
<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="u-font-32">
|
||||
<text v-if="data.type=='single'">¥</text>
|
||||
<text>{{data.lowPrice}}</text>
|
||||
<!-- <text>¥</text>
|
||||
<text>{{data.lowPrice}}</text>
|
||||
<text v-if="data.typeEnum == '多规格'">~¥{{data.maxPrice }}</text> -->
|
||||
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-m-t-24">
|
||||
|
||||
Reference in New Issue
Block a user