阿里云OSS上传图片实现流程
前置,在阿里云开通OSS对象储存。然后在下图文件管理配置文件储存目录和图中传输管理配置访问域名。
1.复制 uploadFileUtil 文件夹和 uploadFile.js 文件在 util 文件夹
2.在使用的页面 引入 uploadFile
效果图:
实现代码
<template><view class="quiz"><view class="title">请选择你要提问的领域</view><picker @change="bindPickerChange" :range="arr"><view class="xuanzhe"><img @click="" class="rrr" src="@/static/image/rrr.png" />{{faq_val||arr[0]}}</view></picker><view class="title title2">请输入您想要提问的问题</view><textarea class="textarea1" v-model="title" placeholder-style="color:#d0d0d0" placeholder="请输入问题的标题" /><textarea class="textarea2" v-model="introduce" placeholder-style="color:#d0d0d0" placeholder="请输入问题的具体描述" /><view class="title title3">请拍照或上传图片帮我们更好的解答问题</view><!-- 添加图片 --><view class="mainAddpic"><p class="addPic"><span>添加图片</span><span>(可添加1-5张图片)</span></p><view class="ThreePic"><block v-for="item in uploadimageArr" :key=""><view class="picMore"><image v-if="item" :src="delet" mode="widthFix" class="delete" @click="detete(0)" /><image v-if="item" :src="item" class="add1" /><image class="addPic1" v-else :src="add" @click="addPic" /></view></block><img class="picMore" v-if="uploadimageArr.length<5" @click="addPic()" :src="quiz_upImg" /></view></view><view class="btn" @click="btn()">我要提问</view></view>
</template><script>import uploadImage from "@/util/uploadFile";// 请求话题接口 拿到提问领域,然后请求用户发帖 userSendForum 上传图片用上海的ossimport Search from '@/components/search.vue';var that;export default {components: {Search},data() {return {delet: this.$config.nhsImagesUrl + "apply/applyClosed.png",add: this.$config.ibugooImageUrl + "addImg.png",quiz_upImg: this.$config.dadaImagesUrl + 'quiz_upImg.png',type: 'FeedBack',lists: [],arr: [],faq_val: '',title: '1',introduce: '2',files: [],uploadimageArr: [],cdnImages: [],};},onLoad() {that = this;this.$common.Init.call(this);this.topicLists();},methods: {// 添加图片addPic(e) {const length = this.uploadimageArr.length;if (length >= 5) return;uni.chooseImage({count: 5 - length,sizeType: ["original", "compressed"],sourceType: ["album", "camera"],success: function(res) {var tempFilePaths = res.tempFilePaths;that.uploadimageArr = [...that.uploadimageArr, ...res.tempFilePaths];},});},// 删除选中图片detete(e) {this.uploadimageArr = this.uploadimageArr.filter((item, index) => {return index != e;});},btn() {let cdnImages = new Array(that.uploadimageArr.length);cdnImages = cdnImages.fill("").map((value, index) => {return new Promise((resolve, reject) => {uploadImage.uploadFile(that.uploadimageArr[index],`dadaDepot/${new Date().getTime() + Math.floor(Math.random() * 150)}`,function(resl) {console.log("======上传成功图片地址为:", resl,'网络路径')resolve(resl);uni.hideLoading()},function() {uni.hideLoading()})})})Promise.all(cdnImages).then((res) => {console.log('上传成功',res)}).catch((err) => {that.showSignFlag = false;});},topicLists() {var data = {type: this.type}this.$request(this.$api.community.topicLists, data).then((res) => {this.lists = res.data.lists || [];this.arr = this.lists.map(item => item.title)});},bindPickerChange(e) {this.faq_val = this.arr[e.detail.value];console.log(this.faq_val)},quxiao(item, index, type) {this.setCollection(item, index, type);setTimeout(() => {this.userCollectList();}, 1000)}}};
</script><style lang="scss" scoped>.quiz {margin: 36rpx;position: relative;color: #102841;.mainAddpic {width: 100%;padding: 40rpx 28rpx 50rpx;border-radius: 20rpx;margin-bottom: 20rpx;box-sizing: border-box;.ThreePic {display: flex;// justify-introduce: space-around;flex-wrap:wrap}.addPic {width: 100%;padding-left: 10rpx;padding-bottom: 10rpx;border-bottom: 1px solid #E5F1FF;span:nth-child(1) {font-family: PingFangSC-Medium, PingFang SC;font-size: 28rpx;color: grey;font-weight: bold;}span:nth-child(2) {font-size: 24rpx;color: #999;}}.picMore {width: 190rpx;height: 190rpx;border-radius: 8rpx;display: flex;margin: 30rpx auto 10rpx;position: relative;// border: 1px dashed #ccc;image {width: 88rpx;height: 88rpx;margin: 0 auto;}.add1 {width: 186rpx;height: 186rpx;border-radius: 8rpx;}.delete {position: absolute;right: 0;top: 0;z-index: 2;width: 40rpx;}.addPic1 {width: 60rpx;height: 60rpx;}}}.quiz_upImg {width: 212rpx;height: 212rpx;position: relative;left: 50%;margin-left: -106rpx;margin-top: 40rpx;}.title {// height: 100rpx;position: relative;font-size: 34rpx;font-family: Source Han Sans CN;font-weight: 500;}.title2 {margin-top: 80rpx;}.title3 {margin-top: 60rpx;}.xuanzhe {position: relative;top: 22rpx;padding: 24rpx;background: #fcfcfc;border-radius: 14rpx;box-shadow: 0rpx 2rpx 6rpx 0rpx rgba(16, 40, 65, 0.26);.rrr {width: 12rpx;height: 22rpx;position: absolute;right: 30rpx;margin-top: 10rpx;z-index: 3;}}textarea {position: relative;top: 22rpx;padding: 24rpx;background: #fcfcfc;border-radius: 14rpx;box-shadow: 0rpx 2rpx 6rpx 0rpx rgba(16, 40, 65, 0.26);}.textarea1 {height: 70rpx;}.textarea2 {margin-top: 26rpx;height: 200rpx;}.btn {position: absolute;margin: auto;margin-top: 34rpx;border-radius: 24rpx;height: 80rpx;line-height: 80rpx;width: 240rpx;left: 50%;margin-left: -120rpx;background-color: #102841;color: #fff;font-size: 32rpx;text-align: center;}.list {margin-top: 40rpx;.item {width: 90%;padding-bottom: 0rpx;min-height: 80rpx;background: #FFFFFF;box-shadow: 0rpx 2rpx 6rpx 0rpx rgba(16, 40, 65, 0.26);border-radius: 12rpx;margin: auto;position: relative;margin-bottom: 28rpx;.red_point {margin-top: -6rpx;margin-right: 14rpx;width: 16rpx;height: 16rpx;border-radius: 50%;background-color: red;position: absolute;right: 4rpx;}.txt {line-height: 96rpx;// height: 36rpx;font-size: 28rpx;font-family: Source Han Sans CN;font-weight: 500;color: #102841;margin-left: 30rpx;width: 470rpx;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;}}}}
</style>
相关文章:

修改远程桌面连接3389端口号
修改注册表: HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Terminal Server\Wds\Repwd\Tds\Tcp 键:PortNumber,以十进制显示:3389,修改成55555,保存刷新注册表。 HKEY_LOCAL_MACHINE\SYSTEM\Curre…

理解 : UDID、UUID、IDFA、IDFV
iOS获取设备唯一标识的各种方法?IDFA、IDFV、UDID分别是什么含义?iOS获取设备ID总结IDFA解释 关于UUID的理解 : 英文名称是:Universally Unique Identifier,翻译过来就是通用唯一标识符。 UUID是指在一台机器上生成的数字,它保证对…

推箱子2-向右推!_保持冷静,砍箱子-me脚
推箱子2-向右推!Hack The Box (HTB) is an online platform allowing you to test your penetration testing skills. It contains several challenges that are constantly updated. Some of them simulating real world scenarios and some of them leaning more towards a C…

H5面试题---介绍js的基本数据类型
js的基本数据类型 Undefined、Null、Boolean、Number、String 转载于:https://www.cnblogs.com/songchunmin/p/7789582.html

Node.js express 之mongoose 从异步回调函数返回值,类似于同步
http://my.oschina.net/antianlu/blog/187023转载于:https://www.cnblogs.com/cylblogs/p/5192314.html

小程序登录、用户信息相关接口调整说明
为优化用户的使用体验,平台将进行以下调整: 2021年2月23日起,若小程序已在微信开放平台进行绑定,则通过wx.login接口获取的登录凭证可直接换取unionID2021年4月13日后发布的小程序新版本,无法通过wx.getU…

小程序 reduce_使用Reduce制作的10个JavaScript实用程序功能
小程序 reduceThe multi-tool strikes again. 多功能工具再次触击。 In my last article I offered you a challenge to recreate well-known functions using reduce. This article will show you how some of them can be implemented, along with some extras! 在上一篇文章…

流媒体,hls
所谓流媒体是指采用流式传输的方式在Internet播放的媒体格式。流媒体又叫流式媒体,它是指商家用一个视频传送服务器把节目当成数据包发出,传送到网络上。用户通过解压设备对这些数据进行解压后,节目就会像发送前那样显示出来。流媒体…

uniapp实现页面左右滑动,上下滑动事件
实现代码: <view class"" touchstart"touchstart" touchend"touchend"> </view> data() {return {touchData: {}, //滑动事件数据} } methods: {touchstart(e) {this.touchData.clientX e.changedTouches[0].clientX;…

android逆向分析概述_Android存储概述
android逆向分析概述Storage is this thing we are all aware of, but always take for granted. Not long ago, every leap in storage capacity was incremental and appeared to be impossible. Nowadays, we don’t give a second thought when contemplating how much of …

小程序地图的使用笔记
这两天在看小程序的地图,写写笔记记录一下 小程序官方文档提供的方法 https://mp.weixin.qq.com/debug/wxadoc/dev/api/location.html 腾讯地图提供的jssdk http://lbs.qq.com/qqmap_wx_jssdk/qqmapwx.html 根据提示使用腾讯地图jssdk需要申请,在实例化的…

JS 实现可停顿的垂直滚动
1 var ScrollMiddle {2 Odiv:document.getElementById(comment), // 目标DOM 3 Oli: document.getElementById(comment).getElementsByTagName(li), 4 times:30, // 配置滚动时间 …

uniapp 上拉加载更多完整实现源码
直接上代码 <template><view class"searchList"><!-- 搜索框 --><Search></Search><img class"top_img" src"/static/image/dataDelivery.png" /><view class"menus p_r"><view class&…

todoist 无法登陆_通过构建Todoist克隆将您的React技能提升到一个新的水平
todoist 无法登陆In this intermediate React course from Karl Hadwen, you will learn how to create the popular Todoist application from scratch using React, Custom Hooks, Firebase & the React Testing Library. You will lean how to use SCSS to style the ap…

w3cscholl的在线代码编辑工具
https://www.w3cschool.cn/tryrun/runcode?langc转载于:https://www.cnblogs.com/jhj117/p/7804133.html

点击事件加锁封装
看代码 // 提交答案 btnReply() {if (!this.$clickLock) returnthis.changeClickLock() } 封装代码 // 点击事件加锁 使用方式,在点击时加入以下代码// if (!this.$clickLock) return// this.changeClickLock()that.changeClickLock () > {that.$clickLock f…

WinCE 7 Mouse HOOK
WinCE 5.0&6.0 的鼠标 HOOK,偶在本博客中已经写过文章。WinCE7.0 的下的鼠标 HOOK 实现,完全和 WinCE 6 是一样的。 效果:在 WinCE 系统界面可以 HOOK 住鼠标的操作。 但是在 Silverlight 应用的界面,HOOK 功能失效。转载于:h…

devops和docker_通过免费的2小时Docker课程学习DevOps基础知识
devops和dockerDocker is a powerful DevOps tool for putting your apps into "containers." Docker是功能强大的DevOps工具,可将您的应用程序放入“容器”中。 You can run these same containers anywhere - on your laptop, on a server - even on a…

生成24位字符串ID__IdGenerator.java
此工具类用于生成24位字符串ID,唯一不重复。 直接通过 IdGenerator.get() 获取。 源码如下:(点击下载源码 - IdGenerator.java ) 1 import java.net.NetworkInterface;2 import java.nio.ByteBuffer;3 import java.nio.ByteOrder;4 import java.util.Enu…

IDEA构建一个mybatis项目
目录结构如下: 在pom.xml中配置需要的jar包 <dependencies><dependency><groupId>org.mybatis</groupId><artifactId>mybatis</artifactId><version>3.3.0</version></dependency><dependency><gro…

小程序在canvas上层做图片滚动
实现该功能踩过的坑 1.swiper的swiper-item中image图片无法在canvas的上层显示,会被canvas 覆盖 2.swiper的swiper-item 里面放 cover-image 会样式错乱 3.scroll-view里面放 cover-image 会样式错乱 解决方案:使用CSS样式实现,超出部分隐…

React是如何在后台运行的
React is a very popular JavaScript library. With over 5.5 million weekly downloads, React is enjoying great popularity. But not a lot of React developers know how React works under the hood. React是一个非常流行JavaScript库。 每周的下载量超过550万࿰…

H5播放视频流
代码 <html> <head> <title>视频直播</title> <meta charset"utf-8"> <link href"http://vjs.zencdn.net/5.5.3/video-js.css" rel"stylesheet"> <!-- If youd like to support IE8 --> <!-…

获取Java系统相关信息
1 package com.test;2 3 import java.util.Properties;4 import java.util.Map.Entry;5 6 import org.junit.Test;7 8 public class SystemTest {9 10 /** 11 * 获取Java系统相关信息 12 * throws Exception 13 */ 14 Test 15 public void testSys…

如何使用FaunaDB + GraphQL
I have one or two projects I maintain on Netlify, in addition to hosting my blog there. It’s an easy platform to deploy to, and has features for content management (CMS) and lambda functions (by way of AWS).除了在其中托管我的博客外,我在Netlify上…

POJ 1414 Life Line(搜索)
题意: 给定一块正三角形棋盘,然后给定一些棋子和空位,棋子序号为a(1<a<9),group的定义是相邻序号一样的棋子。 然后到C(1<N<9)棋手在空位放上自己序号C的棋子, 放完后&a…

MySQL_数据库操作语句
ZC:数据库名/表名/字段名 都使用小写字母 1、 创建 数据库 和 表 的时候,都要指定 编码方式为 utf-8 ! ! ! 因为 执行命令“show variables like char%;”后可以看到 character_set_database 的值为 latin1,即 默认创建数据库是使用的 字符编…

H5打开预览PDF,PPT等文件
实现代码: pdfUrl 写你的文件路径 <iframe :src"//www.xdocin.com/xdoc?_functo&_formathtml&_cache1&_xdocpdfUrl"width"100%"height"100%"frameborder"0"> </iframe> 可以直接打开看

广播代码_代码广播:专为编码而设计的24/7音乐
广播代码阅读本文时,您可以继续阅读Code Radio。 (You can go ahead and start listening to Code Radio while you read this) Most developers I know listen to music while they code. When the meetings are over, the headphones come out.我认识的大多数开发…

从 Android 静音看正确的查bug的姿势?
0、写在前面 没抢到小马哥的红包,无心回家了,回公司写篇文章安慰下自己TT。。话说年关难过,bug多多,时间久了难免头昏脑热,不辨朝暮,难识乾坤。。。艾玛,扯远了,话说谁没踩过坑&…