上传
This commit is contained in:
parent
9cdd391a04
commit
1a2edfb356
|
|
@ -21,7 +21,7 @@ const ENV = {
|
|||
}
|
||||
|
||||
// 当前环境 - 开发时使用 development,打包时改为 production
|
||||
const CURRENT_ENV = 'production'
|
||||
const CURRENT_ENV = 'development'
|
||||
|
||||
// 导出配置
|
||||
export const config = {
|
||||
|
|
|
|||
|
|
@ -257,8 +257,8 @@
|
|||
</view>
|
||||
|
||||
<!-- 城市选择弹窗 -->
|
||||
<view class="picker-popup" v-if="showCityPopup" @click="closeCityPopup">
|
||||
<view class="picker-content city-picker-content" @click.stop>
|
||||
<view class="picker-popup" v-if="showCityPopup" @click="closeCityPopup" @touchmove.prevent.stop="onMaskTouchMove">
|
||||
<view class="picker-content city-picker-content" @click.stop @touchmove.stop>
|
||||
<view class="picker-header">
|
||||
<text class="picker-cancel" @click="showCityPopup = false">取消</text>
|
||||
<text class="picker-title">选择地区</text>
|
||||
|
|
@ -284,7 +284,11 @@
|
|||
<!-- 省份列表 -->
|
||||
<view class="province-section">
|
||||
<view class="section-title">按省份选择</view>
|
||||
<scroll-view scroll-y class="province-scroll">
|
||||
<scroll-view
|
||||
scroll-y
|
||||
class="province-scroll"
|
||||
@touchmove.stop
|
||||
>
|
||||
<view
|
||||
v-for="province in provinceData"
|
||||
:key="province.name"
|
||||
|
|
@ -627,6 +631,11 @@ const closeCityPopup = (e) => {
|
|||
}
|
||||
}
|
||||
|
||||
// 阻止遮罩层的touchmove事件
|
||||
const onMaskTouchMove = () => {
|
||||
// 空函数,仅用于阻止事件
|
||||
}
|
||||
|
||||
// 切换省份展开
|
||||
const toggleProvince = (provinceName) => {
|
||||
if (expandedProvince.value === provinceName) {
|
||||
|
|
@ -1110,12 +1119,20 @@ onMounted(() => {
|
|||
|
||||
.province-scroll {
|
||||
flex: 1;
|
||||
height: 500rpx;
|
||||
height: 400rpx;
|
||||
min-height: 400rpx;
|
||||
max-height: 50vh;
|
||||
padding-bottom: 120rpx;
|
||||
}
|
||||
|
||||
.province-item {
|
||||
border-bottom: 1rpx solid #f5f5f5;
|
||||
|
||||
&:last-child {
|
||||
border-bottom: none;
|
||||
margin-bottom: 80rpx;
|
||||
}
|
||||
|
||||
.province-name {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
|
|
|||
|
|
@ -62,9 +62,28 @@ public class ProfileController : ControllerBase
|
|||
/// <param name="files">照片文件</param>
|
||||
/// <returns>上传结果</returns>
|
||||
[HttpPost("photos")]
|
||||
public async Task<ApiResponse<UploadPhotoResponse>> UploadPhotos([FromForm] List<IFormFile> files)
|
||||
public async Task<ApiResponse<UploadPhotoResponse>> UploadPhotos([FromForm] IFormFile? files)
|
||||
{
|
||||
if (files == null || files.Count == 0)
|
||||
// 支持单文件上传(小程序 uni.uploadFile 每次只能上传一个文件)
|
||||
var fileList = new List<IFormFile>();
|
||||
if (files != null)
|
||||
{
|
||||
fileList.Add(files);
|
||||
}
|
||||
|
||||
// 也支持多文件上传
|
||||
if (Request.Form.Files.Count > 0)
|
||||
{
|
||||
foreach (var file in Request.Form.Files)
|
||||
{
|
||||
if (!fileList.Contains(file))
|
||||
{
|
||||
fileList.Add(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (fileList.Count == 0)
|
||||
{
|
||||
return ApiResponse<UploadPhotoResponse>.Error(ErrorCodes.MissingParameter, "请选择要上传的照片");
|
||||
}
|
||||
|
|
@ -72,7 +91,7 @@ public class ProfileController : ControllerBase
|
|||
var userId = GetCurrentUserId();
|
||||
|
||||
// 检查是否可以上传
|
||||
var canUpload = await _profileService.CanUploadPhotosAsync(userId, files.Count);
|
||||
var canUpload = await _profileService.CanUploadPhotosAsync(userId, fileList.Count);
|
||||
if (!canUpload)
|
||||
{
|
||||
return ApiResponse<UploadPhotoResponse>.Error(ErrorCodes.PhotoLimitExceeded, "照片数量超过限制,最多5张");
|
||||
|
|
@ -80,7 +99,7 @@ public class ProfileController : ControllerBase
|
|||
|
||||
// 转换为Stream列表
|
||||
var streams = new List<Stream>();
|
||||
foreach (var file in files)
|
||||
foreach (var file in fileList)
|
||||
{
|
||||
var stream = file.OpenReadStream();
|
||||
streams.Add(stream);
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@
|
|||
"SecretKey": "89GWr7JPWYTL8ueHlAYowGZnvzKZjqs9",
|
||||
"Region": "ap-shanghai",
|
||||
"BucketName": "miaoyu",
|
||||
"CdnDomain": "miaoyu-1308826010.cos.ap-shanghai.myqcloud.com"
|
||||
"CdnDomain": "https://miaoyu-1308826010.cos.ap-shanghai.myqcloud.com"
|
||||
}
|
||||
},
|
||||
"AliyunSms": {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user