在添加账号中应用添加图片组件

This commit is contained in:
WindowBird 2025-08-25 16:53:48 +08:00
parent df1709deab
commit ba997299f7
3 changed files with 19 additions and 21 deletions

View File

@ -10,10 +10,10 @@
<image v-else :src="imageUrl" class="preview-image" mode="aspectFit"></image> <image v-else :src="imageUrl" class="preview-image" mode="aspectFit"></image>
</view> </view>
<!-- 错误提示 --> <!-- &lt;!&ndash; 错误提示 &ndash;&gt;-->
<view v-if="errorMessage" class="error-message"> <!-- <view v-if="errorMessage" class="error-message">-->
<text class="error-text">{{ errorMessage }}</text> <!-- <text class="error-text">{{ errorMessage }}</text>-->
</view> <!-- </view>-->
</view> </view>
</template> </template>

View File

@ -19,7 +19,6 @@ export default {
// //
handleUploadSuccess(result) { handleUploadSuccess(result) {
console.log('图片上传成功:', result.url) console.log('图片上传成功:', result.url)
uni.showToast({ uni.showToast({
title: '上传成功', title: '上传成功',
icon: 'success', icon: 'success',

View File

@ -17,13 +17,12 @@
<view class="form-item"> <view class="form-item">
<text class="form-label">{{ typeOptions[typeIndex].noLabel }}</text> <text class="form-label">{{ typeOptions[typeIndex].noLabel }}</text>
<view class="input-group"> <view class="input-group">
<textarea <image-uploader
v-if="typeOptions[typeIndex].value === 'QR'" v-if="typeOptions[typeIndex].value === 'QR'"
v-model="bankForm.no" ref="uploader"
:maxlength="500" :height="'150rpx'"
:placeholder="typeOptions[typeIndex].noPlaceholder" :width="'150rpx'"
auto-height @success="handleUploadSuccess"
class="form-input qr-input"
/> />
<input <input
v-else v-else
@ -32,14 +31,6 @@
class="form-input" class="form-input"
maxlength="30" maxlength="30"
/> />
<!-- 收款二维码类型时显示上传按钮 -->
<view
v-if="typeOptions[typeIndex].value === 'QR'"
class="upload-btn"
@click="goToImageUpload"
>
<text class="upload-text">上传</text>
</view>
</view> </view>
</view> </view>
@ -114,7 +105,7 @@ export default {
{ {
label: '收款二维码', label: '收款二维码',
value: 'QR', value: 'QR',
noLabel: '收款码图片url', noLabel: '点击添加二维码',
noPlaceholder: '请点击上传-上传收款二维码图片自动获得收款码图片URL', noPlaceholder: '请点击上传-上传收款二维码图片自动获得收款码图片URL',
}, },
], ],
@ -154,6 +145,14 @@ export default {
uni.$off('image-upload-success', this.onImageUploadSuccess) uni.$off('image-upload-success', this.onImageUploadSuccess)
}, },
methods: { methods: {
handleUploadSuccess(result) {
console.log('图片上传成功:', result.url)
this.bankForm.no = result.url
uni.showToast({
title: '上传成功',
icon: 'success',
})
},
// //
resetForm() { resetForm() {
this.bankForm = { this.bankForm = {