| | |
| | | <!-- #ifdef APP --> |
| | | <scroll-view class="page-scroll-view"> |
| | | <!-- #endif --> |
| | | <view> |
| | | <view class="uni-common-mt"> |
| | | <view class="uni-list list-pd" style="padding: 15px;"> |
| | | <view class="uni-flex" style="margin-bottom: 10px;"> |
| | | <view class="uni-list-cell-left">点击可预览选好的图片</view> |
| | | <view style="margin-left: auto;"> |
| | | <text class="click-t">{{ qsImage.length }}/{{ countIndex + 1 }}</text> |
| | | <view class="page-container"> |
| | | <view class="header-info"> |
| | | <view class="header-text">点击可预览选好的图片</view> |
| | | <view class="header-count">{{ qsImage.length }}/{{ countIndex + 1 }}</view> |
| | | </view> |
| | | |
| | | <view class="image-grid"> |
| | | <view v-for="(image, index) in qsImage" :key="index" class="image-card"> |
| | | <view class="image-wrapper"> |
| | | <image :src="image.img" :data-src="image.img" @tap="previewImage(index)" class="preview-image"></image> |
| | | <view class="remove-button" @click="removeImage(index, image.id)"> |
| | | <image src="/static/plus.png" class="remove-icon"></image> |
| | | </view> |
| | | </view> |
| | | <view class="uni-flex" style="flex-wrap: wrap;"> |
| | | <view v-for="(image,index) in qsImage" :key="index" class="uni-uploader__input-box" |
| | | style="position: relative; border: 0;"> |
| | | <image :src="image.img" :data-src="image.img" |
| | | @tap="previewImage(index)"></image> |
| | | <image src="/static/plus.png" class="image-remove" @click="removeImage(index,image.id)"></image> |
| | | </view> |
| | | <image class="uni-uploader__input-box" @tap="chooseImage" src="/static/plus.png"></image> |
| | | </view> |
| | | </view> |
| | | |
| | | <view class="add-image-card" @tap="chooseImage"> |
| | | <image src="/static/plus.png" class="add-icon"></image> |
| | | <text class="add-text">添加图片</text> |
| | | </view> |
| | | </view> |
| | | <view class="plus-button"> |
| | | <button type="warn" @click="save">上传图片</button> |
| | | |
| | | <view class="upload-button-container"> |
| | | <button type="primary" @click="save" class="upload-button"> |
| | | <text class="button-text">上传图片</text> |
| | | </button> |
| | | </view> |
| | | </view> |
| | | <!-- #ifdef APP --> |
| | |
| | | </template> |
| | | |
| | | <script> |
| | | |
| | | import {pathToBase64, base64ToPath} from '../../../js_sdk/mmmm-image-tools/index' |
| | | import { pathToBase64, base64ToPath } from '../../../js_sdk/mmmm-image-tools/index' |
| | | |
| | | var sourceTypeArray = [ |
| | | ['camera'], |
| | |
| | | ['original'], |
| | | ['compressed', 'original'] |
| | | ] |
| | | |
| | | export default { |
| | | data() { |
| | | return { |
| | |
| | | } |
| | | }, |
| | | onLoad(options) { |
| | | //options中包含了url附带的参数 |
| | | |
| | | let params = options; |
| | | |
| | | if (params["id"]) { |
| | | this.fid = params["id"]; |
| | | //getQaItemXj02 |
| | | this.init(); |
| | | } |
| | | }, |
| | |
| | | let url = res.tempFilePaths[0]; |
| | | pathToBase64(url) |
| | | .then(base64 => { |
| | | // 找到最后一个斜杠的位置 |
| | | let lastSlashIndex = url.lastIndexOf("/"); |
| | | // 提取文件名 |
| | | let fileName = url.substring(lastSlashIndex + 1); |
| | | let entity = {}; |
| | | entity.img = base64; |
| | |
| | | }, |
| | | previewImage(index) { |
| | | // uni.previewImage({ |
| | | // current: index, // 设置当前显示图片的链接 |
| | | // urls: this.qsImage.map(s=>s.img), // 需要预览的图片链接列表 |
| | | // loop: false, // 是否开启图片轮播,默认为 false |
| | | // indicator: 'default',// 图片指示器类型,可选值为 "default"、"number"、"pointer",默认为 "default" |
| | | // current: index, |
| | | // urls: this.qsImage.map(s=>s.img), |
| | | // loop: false, |
| | | // indicator: 'default', |
| | | // }); |
| | | }, |
| | | init() { |
| | |
| | | </script> |
| | | |
| | | <style> |
| | | .click-t { |
| | | color: darkgray; |
| | | /* 基础配色方案 */ |
| | | :root { |
| | | --primary-color: #165DFF; /* 主色调 - 蓝色 */ |
| | | --success-color: #00B42A; /* 成功色 - 绿色 */ |
| | | --danger-color: #F53F3F; /* 危险色 - 红色 */ |
| | | --text-color: #1D2129; /* 主文本色 */ |
| | | --text-secondary: #4E5969; /* 次要文本色 */ |
| | | --text-light: #86909C; /* 浅色文本 */ |
| | | --bg-color: #F2F3F5; /* 背景色 */ |
| | | --card-bg: #FFFFFF; /* 卡片背景色 */ |
| | | --border-color: #E5E6EB; /* 边框色 */ |
| | | } |
| | | |
| | | .list-pd { |
| | | margin-top: 25px; |
| | | /* 页面整体样式 */ |
| | | .page-container { |
| | | padding: 20px; |
| | | background-color: var(--bg-color); |
| | | min-height: 100vh; |
| | | } |
| | | |
| | | .uni-uploader__input-box { |
| | | margin: 5px; |
| | | border: 1px solid #D9D9D9; |
| | | /* 头部信息样式 */ |
| | | .header-info { |
| | | display: flex; |
| | | justify-content: space-between; |
| | | align-items: center; |
| | | margin-bottom: 20px; |
| | | padding: 12px 16px; |
| | | background-color: var(--card-bg); |
| | | border-radius: 12px; |
| | | box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06); |
| | | } |
| | | |
| | | .image-remove { |
| | | transform: rotate(45deg); |
| | | width: 25px; |
| | | height: 25px; |
| | | position: absolute; |
| | | top: 0; |
| | | right: 0; |
| | | border-radius: 13px; |
| | | background-color: #FF0000; |
| | | .header-text { |
| | | font-size: 14px; |
| | | color: var(--text-color); |
| | | font-weight: 500; |
| | | } |
| | | |
| | | .uni-common-mt { |
| | | background-color: #ffffff; |
| | | /* 红色背景 */ |
| | | .header-count { |
| | | font-size: 14px; |
| | | color: var(--text-secondary); |
| | | } |
| | | |
| | | .plus-button { |
| | | position: fixed; |
| | | left: 0; |
| | | bottom: 0; |
| | | /* 图片网格样式 */ |
| | | .image-grid { |
| | | display: grid; |
| | | grid-template-columns: repeat(3, 1fr); |
| | | gap: 12px; |
| | | } |
| | | |
| | | /* 图片卡片样式 */ |
| | | .image-card { |
| | | position: relative; |
| | | border-radius: 12px; |
| | | overflow: hidden; |
| | | aspect-ratio: 1/1; |
| | | box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06); |
| | | transition: transform 0.2s, box-shadow 0.2s; |
| | | } |
| | | |
| | | .image-card:hover { |
| | | transform: translateY(-2px); |
| | | box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1); |
| | | } |
| | | |
| | | .image-wrapper { |
| | | position: relative; |
| | | width: 100%; |
| | | background-color: #ffffff; /* 背景颜色 */ |
| | | padding: 10px; |
| | | box-shadow: 0 -2px 4px rgba(0, 0, 0, 0.1); /* 添加底部阴影效果 */ |
| | | z-index: 999; /* 确保按钮位于顶层 */ |
| | | height: 100%; |
| | | } |
| | | |
| | | .uni-flex { |
| | | max-height: calc(100vh - 240px); /* 屏幕高度减去上传按钮高度 */ |
| | | overflow-y: auto; /* 当内容超出高度时出现垂直滚动条 */ |
| | | .preview-image { |
| | | width: 100%; |
| | | height: 100%; |
| | | object-fit: cover; |
| | | } |
| | | |
| | | /* 删除按钮样式 */ |
| | | .remove-button { |
| | | position: absolute; |
| | | top: 8px; |
| | | right: 8px; |
| | | width: 24px; |
| | | height: 24px; |
| | | background-color: rgba(245, 63, 63, 0.8); |
| | | border-radius: 50%; |
| | | display: flex; |
| | | justify-content: center; |
| | | align-items: center; |
| | | cursor: pointer; |
| | | transition: background-color 0.2s; |
| | | } |
| | | |
| | | .remove-button:hover { |
| | | background-color: rgba(245, 63, 63, 1); |
| | | } |
| | | |
| | | .remove-icon { |
| | | width: 14px; |
| | | height: 14px; |
| | | filter: brightness(0) invert(1); |
| | | transform: rotate(45deg); |
| | | } |
| | | |
| | | /* 添加图片卡片样式 */ |
| | | .add-image-card { |
| | | border: 2px dashed var(--border-color); |
| | | border-radius: 12px; |
| | | display: flex; |
| | | flex-direction: column; |
| | | justify-content: center; |
| | | align-items: center; |
| | | background-color: rgba(22, 93, 255, 0.05); |
| | | cursor: pointer; |
| | | transition: all 0.2s; |
| | | } |
| | | |
| | | .add-image-card:hover { |
| | | border-color: var(--primary-color); |
| | | background-color: rgba(22, 93, 255, 0.1); |
| | | } |
| | | |
| | | .add-icon { |
| | | width: 36px; |
| | | height: 36px; |
| | | margin-bottom: 8px; |
| | | opacity: 0.6; |
| | | transition: opacity 0.2s; |
| | | } |
| | | |
| | | .add-image-card:hover .add-icon { |
| | | opacity: 0.8; |
| | | } |
| | | |
| | | .add-text { |
| | | font-size: 12px; |
| | | color: var(--text-secondary); |
| | | } |
| | | |
| | | /* 上传按钮样式 */ |
| | | .upload-button-container { |
| | | margin-top: 24px; |
| | | padding: 0 16px 20px; |
| | | } |
| | | |
| | | .upload-button { |
| | | width: 100%; |
| | | height: 50px; |
| | | background-color: var(--primary-color); |
| | | border: none; |
| | | border-radius: 25px; |
| | | color: white; |
| | | font-size: 16px; |
| | | font-weight: 500; |
| | | box-shadow: 0 4px 12px rgba(22, 93, 255, 0.2); |
| | | transition: all 0.2s; |
| | | display: flex; |
| | | justify-content: center; |
| | | align-items: center; |
| | | } |
| | | |
| | | .upload-button:hover { |
| | | background-color: #0D47A1; |
| | | box-shadow: 0 6px 16px rgba(22, 93, 255, 0.3); |
| | | transform: translateY(-1px); |
| | | } |
| | | |
| | | .upload-button:active { |
| | | transform: translateY(1px); |
| | | box-shadow: 0 2px 8px rgba(22, 93, 255, 0.2); |
| | | } |
| | | |
| | | .button-text { |
| | | display: flex; |
| | | align-items: center; |
| | | } |
| | | |
| | | /* 滚动视图样式 */ |
| | | .page-scroll-view { |
| | | height: 100vh; |
| | | } |
| | | </style> |