Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
46a58a16
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
6001
Star
91
Fork
163
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
18
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello uni-app x
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
18
Issue
18
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
46a58a16
编写于
9月 15, 2023
作者:
张
张磊
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
补充crop属性
上级
d6a7a3f0
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
110 addition
and
10 deletion
+110
-10
pages/API/choose-image/choose-image.uvue
pages/API/choose-image/choose-image.uvue
+110
-10
未找到文件。
pages/API/choose-image/choose-image.uvue
浏览文件 @
46a58a16
<template>
<template>
<!-- #ifdef APP -->
<!-- #ifdef APP -->
<scroll-view style="flex:1">
<scroll-view style="flex:1">
<!-- #endif -->
<!-- #endif -->
<view>
<view>
<page-head :title="title"></page-head>
<page-head :title="title"></page-head>
<view class="uni-common-mt">
<view class="uni-common-mt">
...
@@ -29,7 +29,49 @@
...
@@ -29,7 +29,49 @@
数量限制
数量限制
</view>
</view>
<view class="uni-list-cell-right">
<view class="uni-list-cell-right">
<input class="click-t" :value="countIndex+1" type="number" :maxlength="1" @confirm="chooseImageCount" confirm-type="done"/>
<input class="click-t" :value="countIndex+1" type="number" :maxlength="1" @confirm="chooseImageCount" confirm-type="done" />
</view>
</view>
<view class="uni-list-cell cell-pd">
<view class="uni-list-cell-left uni-label">
图像裁剪
</view>
<view class="uni-list-cell-right">
<switch :checked="isCrop" @change="switchCrop"></switch>
</view>
</view>
<view ref="cropOptionNode" class="crop-option" :style="{'height':isCrop?'200px':'0px'}">
<view class="uni-list-cell cell-pd">
<view class="uni-list-cell-left item_width">
图片质量(%)
</view>
<view class="uni-list-cell-right">
<input :value="cropPercent" @confirm="cropPercentConfim" type="number" />
</view>
</view>
<view class="uni-list-cell cell-pd">
<view class="uni-list-cell-left item_width">
裁剪宽度(px)
</view>
<view class="uni-list-cell-right">
<input :value="cropWidth" @confirm="cropWidthConfim" type="number" />
</view>
</view>
<view class="uni-list-cell cell-pd">
<view class="uni-list-cell-left item_width">
裁剪高度(px)
</view>
<view class="uni-list-cell-right">
<input :value="cropHeight" @confirm="cropHeightConfim" type="number" />
</view>
</view>
<view class="uni-list-cell cell-pd">
<view class="uni-list-cell-left item_width">
保留原宽高
</view>
<view class="uni-list-cell-right">
<switch :checked="cropResize" @change="cropResizeChange"></switch>
</view>
</view>
</view>
</view>
</view>
</view>
</view>
...
@@ -51,7 +93,7 @@
...
@@ -51,7 +93,7 @@
</view>
</view>
</view>
</view>
</view>
</view>
<!-- #ifdef APP -->
<!-- #ifdef APP -->
</scroll-view>
</scroll-view>
<!-- #endif -->
<!-- #endif -->
</template>
</template>
...
@@ -77,7 +119,12 @@
...
@@ -77,7 +119,12 @@
sizeTypeIndex: 2,
sizeTypeIndex: 2,
sizeType: ['压缩', '原图', '压缩或原图'],
sizeType: ['压缩', '原图', '压缩或原图'],
countIndex: 8,
countIndex: 8,
count: [1, 2, 3, 4, 5, 6, 7, 8, 9]
count: [1, 2, 3, 4, 5, 6, 7, 8, 9],
isCrop: false,
cropPercent: 80,
cropWidth: 100,
cropHeight: 100,
cropResize: false
}
}
},
},
onUnload() {
onUnload() {
...
@@ -89,13 +136,52 @@
...
@@ -89,13 +136,52 @@
this.countIndex = 8
this.countIndex = 8
},
},
methods: {
methods: {
cropHeightConfim(e : InputConfirmEvent) {
let value = parseInt(e.detail.value)
if (value > 0) {
this.cropHeight = value
} else {
uni.showToast({
position: "bottom",
title: "裁剪高度需要大于0"
})
}
},
cropWidthConfim(e : InputConfirmEvent) {
let value = parseInt(e.detail.value)
if (value > 0) {
this.cropWidth = value
} else {
uni.showToast({
position: "bottom",
title: "裁剪宽度需要大于0"
})
}
},
cropPercentConfim(e : InputConfirmEvent) {
let value = parseInt(e.detail.value)
if (value > 0 && value <= 100) {
this.cropPercent = value
} else {
uni.showToast({
position: "bottom",
title: "请输入0~100之间的值"
})
}
},
cropResizeChange(e : SwitchChangeEvent) {
this.cropResize = e.detail.value
},
switchCrop(e : SwitchChangeEvent) {
this.isCrop = e.detail.value
},
removeImage(index : number) {
removeImage(index : number) {
this.imageList.splice(index, 1)
this.imageList.splice(index, 1)
},
},
chooseImageSource() {
chooseImageSource() {
uni.showActionSheet({
uni.showActionSheet({
itemList: ['拍照', '相册', '拍照或相册'],
itemList: ['拍照', '相册', '拍照或相册'],
success(e){
success(e)
{
this.sourceTypeIndex = e.tapIndex!
this.sourceTypeIndex = e.tapIndex!
}
}
})
})
...
@@ -103,23 +189,24 @@
...
@@ -103,23 +189,24 @@
chooseImageType() {
chooseImageType() {
uni.showActionSheet({
uni.showActionSheet({
itemList: ['压缩', '原图', '压缩或原图'],
itemList: ['压缩', '原图', '压缩或原图'],
success(e){
success(e)
{
this.sizeTypeIndex = e.tapIndex!
this.sizeTypeIndex = e.tapIndex!
}
}
})
})
},
},
chooseImageCount(event: InputConfirmEvent) {
chooseImageCount(event
: InputConfirmEvent) {
let count = parseInt(event.detail.value) - 1
let count = parseInt(event.detail.value) - 1
if
(count <=
0) {
if
(count <
0) {
uni.showToast({
uni.showToast({
position:"bottom",
position:
"bottom",
title:"图片数量应该大于0"
title:
"图片数量应该大于0"
})
})
return
return
}
}
this.countIndex = count
this.countIndex = count
},
},
chooseImage: function () {
chooseImage: function () {
// var cropOption:ChooseImageCropOptions|null = this.isCrop ? null : new ChooseImageCropOptions( )
if (this.imageList.length >= 9) {
if (this.imageList.length >= 9) {
uni.showToast({
uni.showToast({
position: "bottom",
position: "bottom",
...
@@ -130,6 +217,7 @@
...
@@ -130,6 +217,7 @@
uni.chooseImage({
uni.chooseImage({
sourceType: sourceTypeArray[this.sourceTypeIndex],
sourceType: sourceTypeArray[this.sourceTypeIndex],
sizeType: sizeTypeArray[this.sizeTypeIndex],
sizeType: sizeTypeArray[this.sizeTypeIndex],
crop: this.isCrop ? { "quality": this.cropPercent, "width": this.cropWidth, "height": this.cropHeight, "resize": this.cropResize } as ChooseImageCropOptions : null,
count: this.imageList.length + this.count[this.countIndex] > 9 ? 9 - this.imageList.length : this.count[this.countIndex],
count: this.imageList.length + this.count[this.countIndex] > 9 ? 9 - this.imageList.length : this.count[this.countIndex],
success: (res) => {
success: (res) => {
this.imageList = this.imageList.concat(res.tempFilePaths);
this.imageList = this.imageList.concat(res.tempFilePaths);
...
@@ -189,4 +277,16 @@
...
@@ -189,4 +277,16 @@
border-radius: 25rpx;
border-radius: 25rpx;
background-color: rgba(200, 200, 200, 0.8);
background-color: rgba(200, 200, 200, 0.8);
}
}
.item_width {
width: 260rpx;
}
.crop-option {
border-top-color: lightgray;
border-width: 1rpx;
padding: 20rpx;
transition: height;
transition-duration: 300;
}
</style>
</style>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录