Commit 03d5f505 Harvey

上传图片

1 个父辈 1dd248d5
...@@ -68,6 +68,7 @@ ...@@ -68,6 +68,7 @@
"@vue/shared": "^3.0.0", "@vue/shared": "^3.0.0",
"core-js": "^3.6.5", "core-js": "^3.6.5",
"flyio": "^0.6.2", "flyio": "^0.6.2",
"image-tools": "^1.4.0",
"regenerator-runtime": "^0.12.1", "regenerator-runtime": "^0.12.1",
"uni-read-pages": "1.0.5", "uni-read-pages": "1.0.5",
"uni-simple-router": "2.0.7", "uni-simple-router": "2.0.7",
......
...@@ -39,25 +39,14 @@ ...@@ -39,25 +39,14 @@
methods: { methods: {
//上传图片 //上传图片
chooseImageHandle() { chooseImageHandle() {
console.log("[上传图片]")
let that = this; let that = this;
let limit = parseInt(this.limit); let limit = parseInt(this.limit);
uni.chooseImage({ uni.chooseImage({
count: limit, //默认9 count: limit, //默认9
sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有 sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
sourceType: ['album'], //从相册选择 sourceType: ['album'], //从相册选择
success: function(res) { success: function(res) {
console.log(res) that.tempFileList.push(res.tempFiles[0])
let tempFiles = res.tempFiles;
tempFiles.forEach(function(item, index) {
let filePath = item.path;
let filename = filePath.substr(filePath.lastIndexOf('/') + 1);
that.tempFileList.push({
name: filename,
path: filePath
})
})
} }
}) })
}, },
......
<template> <template>
<view class="panel"> <view class="panel">
<view class="panel-item panel-item-bottom"> <view class="panel-item panel-item-bottom">
<text class="panel-text">彩店类型</text> <text class="panel-text">彩店类型</text>
</view> <uni-combox :border="false" :candidates="candidates" labelWidth="50px"></uni-combox>
<view class="panel-item">
<view class="panel-text">海报显示名称水印</view>
<switch class="switch" :checked="true" color="#1A9BFC" />
</view>
<view class="panel-txt">
<input type="text" class="panel-txt-txt" placeholder="彩店名称" />
</view>
<view class="panel-item-bottom panel-top"></view>
<view class="panel-item">
<text class="panel-text">海报显示店主二维码</text>
<!-- <liSwitch :checked="true" width="90" bg="#1A9BFC" /> -->
<switch class="switch" :checked="true" color="#1A9BFC" />
</view>
<view class="panel-img">
<imgUpload />
</view>
<button type="default" class="btn" @click="subimit">提交</button>
</view> </view>
<view class="panel-item">
<view class="panel-text">海报显示名称水印</view>
<switch class="switch" :checked="true" color="#1A9BFC" />
</view>
<view class="panel-txt">
<input type="text" class="panel-txt-txt" placeholder="彩店名称" />
</view>
<view class="panel-item-bottom panel-top"></view>
<view class="panel-item">
<text class="panel-text">海报显示店主二维码</text>
<!-- <liSwitch :checked="true" width="90" bg="#1A9BFC" /> -->
<switch class="switch" :checked="true" color="#1A9BFC" />
</view>
<view class="panel-img">
<imgUpload limit="10" :FileList="imgList" />
</view>
<button type="default" class="btn" @click="subimit">提交</button>
</view>
</template> </template>
<script> <script>
import imgUpload from '@/components/chooseImage/chooseImage.vue' import imgUpload from '@/components/chooseImage/chooseImage.vue'
import {
export default { pathToBase64
components:{ } from "image-tools"
imgUpload
}, export default {
components: {
imgUpload
},
data() { data() {
return { return {
candidates: ['双彩店', '福彩', '体彩'],
imgList: []
} }
}, },
methods: { methods: {
subimit(){ async subimit() {
uni.showToast({ if (this.imgList.length < 1) {
title:'接口暂未实现' return
}) }
const base64 = await this.imgToBase64(this.imgList[0].path)
console.log(base64)
uni.showToast({
title: '接口暂未实现'
})
},
imgToBase64(data) {
return new Promise((resolve, reject) => {
pathToBase64(data)
.then((base64) => {
resolve(base64.split(',')[1]);
})
.catch((error) => {
console.error(error);
reject(error);
});
});
} }
} }
} }
...@@ -73,9 +97,9 @@ ...@@ -73,9 +97,9 @@
.panel-text { .panel-text {
color: #000; color: #000;
word-wrap: break-word; word-wrap: break-word;
line-height: 30px; line-height: 30px;
height: 30px; height: 30px;
text-align: center; text-align: center;
} }
...@@ -90,21 +114,21 @@ ...@@ -90,21 +114,21 @@
color: #8c8c8c8c; color: #8c8c8c8c;
background-color: #F5F5F5; background-color: #F5F5F5;
height: 38px; height: 38px;
} }
.switch{ .switch {
transform: scale(0.7,0.7); transform: scale(0.7, 0.7);
} }
.panel-img{ .panel-img {
height: 90px; height: 90px;
padding: 0px 20px; padding: 0px 20px;
} }
.btn { .btn {
height: 44px; height: 44px;
margin-top: 15px; margin-top: 15px;
background-color: #D23338; background-color: #D23338;
color: #FFFFFF; color: #FFFFFF;
} }
</style> </style>
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!