修改部分自写公共组件代码

This commit is contained in:
2024-09-28 15:05:54 +08:00
parent c3d4f1d78c
commit 1aa502103b
4 changed files with 100 additions and 58 deletions

View File

@@ -105,7 +105,7 @@ import { computed } from 'vue';
margin: auto; margin: auto;
} }
.shadow{ .shadow{
box-shadow: 0 0 10px #999; box-shadow: 0 0 10px #aaa;
} }
.btn { .btn {
font-size: 28rpx; font-size: 28rpx;

View File

@@ -1,10 +1,11 @@
<template> <template>
<view class="my-radio u-font-28 u-flex color-333" @tap.stop="changeVal"> <view class="my-radio u-font-28 u-flex color-333" @tap.stop="changeVal">
<view class="circle u-flex u-row-center" :style="computedStyle()" :class="{active:modelValue,square:shape==='square'}"> <view class="circle u-flex u-row-center" :style="computedStyle()"
:class="{active:modelValue,square:shape==='square'}">
<uni-icons type="checkmarkempty" v-if="modelValue" :size="size-4" color="#fff"></uni-icons> <uni-icons type="checkmarkempty" v-if="modelValue" :size="size-4" color="#fff"></uni-icons>
</view> </view>
<view class="u-m-l-12"> <view class="u-m-l-12">
{{text}} <slot>{{text}}</slot>
</view> </view>
</view> </view>
</template> </template>
@@ -52,6 +53,7 @@
` `
} }
const emits = defineEmits(['update:modelValue', 'change']) const emits = defineEmits(['update:modelValue', 'change'])
function changeVal() { function changeVal() {
if (props.disabled) { if (props.disabled) {
return return
@@ -84,6 +86,7 @@
border: 1px solid #707070; border: 1px solid #707070;
border-radius: 50%; border-radius: 50%;
overflow: hidden; overflow: hidden;
&.square { &.square {
border-radius: 8rpx; border-radius: 8rpx;
} }

View File

@@ -6,7 +6,7 @@
<view class="left-line" :class="{hide:index==list.length-1}"></view> <view class="left-line" :class="{hide:index==list.length-1}"></view>
</view> </view>
<view class="u-p-l-12 "> <view class="u-p-l-12 ">
<view class="u-font-20">{{item[titleKey]||''}}</view> <view class="u-font-20">{{formatTitle(item[titleKey]||'') }}</view>
<view class="u-font-24 u-m-t-2">{{item[contentKey]||''}}</view> <view class="u-font-24 u-m-t-2">{{item[contentKey]||''}}</view>
</view> </view>
</view> </view>
@@ -14,6 +14,7 @@
</template> </template>
<script setup> <script setup>
import dayjs from 'dayjs';
const props = defineProps({ const props = defineProps({
active: { active: {
type: [String, Number], type: [String, Number],
@@ -32,6 +33,10 @@
default: 'content' default: 'content'
} }
}) })
function formatTitle(time){
return dayjs(time).format('YYYY-M-D HH:MM:ss')
}
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@@ -1,13 +1,15 @@
<template> <template>
<up-upload :fileList="images" @afterRead="afterRead" @delete="deletePic" :multiple="multiple" <up-upload :fileList="images" @afterRead="afterRead" @delete="deletePic" :multiple="multiple" :width="width"
:width="width" :height="height" :height="height" :maxCount="maxCount"></up-upload>
:maxCount="10"></up-upload>
</template> </template>
<script setup> <script setup>
import {$uploadFile} from '@/http/yskApi/file.js'
import { import {
ref, watch $uploadFile
} from '@/http/yskApi/file.js'
import {
ref,
watch
} from 'vue'; } from 'vue';
const props = defineProps({ const props = defineProps({
@@ -23,6 +25,10 @@
type: [String, Number], type: [String, Number],
default: 60 default: 60
}, },
maxCount: {
type: [Number],
default: 10
},
multiple: { multiple: {
type: Boolean, type: Boolean,
default: true default: true
@@ -32,7 +38,10 @@
const emits = defineEmits(['update:modelValue']) const emits = defineEmits(['update:modelValue'])
const images = ref(props.modelValue) const images = ref(props.modelValue)
function afterRead(e) { function afterRead(e) {
console.log(e);
if (Array.isArray(e)) {
for (let i in e.file) { for (let i in e.file) {
const file = e.file[i].file const file = e.file[i].file
$uploadFile(file).then(res => { $uploadFile(file).then(res => {
@@ -53,9 +62,34 @@
}) })
} }
}else{
const i=0
const file = e.file.file
$uploadFile(file).then(res => {
console.log(res);
images.value.push({
url: e.file.url,
serveUrl: res.data[0]
})
}).catch(res => {
console.log(res);
if (res.errMsg) {
images.value.splice(i, 1)
uni.showToast({
title: '图片大小超出限制',
icon: 'error'
})
} }
})
}
}
function deletePic(e) { function deletePic(e) {
const {index}=e const {
index
} = e
images.value.splice(index, 1) images.value.splice(index, 1)
} }