浏览代码

1、报名作品上传新增进度条
2、商家小票页面样式修改

lyb 4 年之前
父节点
当前提交
1629d2deee
共有 3 个文件被更改,包括 130 次插入14 次删除
  1. 65 0
      components/alert/uploadAlert.vue
  2. 59 6
      pages/apply/apply.vue
  3. 6 8
      pages/payResult/payResult.vue

+ 65 - 0
components/alert/uploadAlert.vue

@@ -0,0 +1,65 @@
+<template>
+	<view v-if="updateProgress != ''">
+		<u-popup v-model="show" mode="center" width="80%" border-radius="15" :mask-close-able="false">
+			<view class="upload-alert-container">
+				<view class="title">视频上传</view>
+				<u-line-progress :striped="true" :percent="updateProgress.progress" :striped-active="true" :active-color="vuex_theme.bgColor"></u-line-progress>
+				<view class="upload-content">
+					<view class="">{{(updateProgress.totalBytesSent/1024/1024).toFixed(2)}}M/{{(updateProgress.totalBytesExpectedToSend/1024/1024).toFixed(2)}}M</view>
+				</view>
+				<view class="cancel-upload" @click="cancelUpload">取消上传</view>
+			</view>
+		</u-popup>
+		<toast ref="toast"></toast>
+	</view>
+</template>
+
+<script>
+	export default {
+		props: {
+			updateProgress: ''
+		},
+		data() {
+			return {
+				show: false,
+			};
+		},
+		created() {},
+		computed: {},
+		methods: {
+			cancelUpload(){
+				this.$emit('cancelUpload')
+			}
+		}
+	}
+</script>
+
+<style lang="scss" scoped>
+	.upload-alert-container {
+		padding: 30rpx 50rpx;
+		.title {
+			width: 100%;
+			text-align: center;
+			padding: 0rpx 10rpx 50rpx 10rpx;
+			font-weight: 500;
+			color: #353535;
+			letter-spacing: 2rpx;
+			font-size: 30rpx;
+		}
+		.upload-content{
+			display: flex;
+			justify-content: flex-end;
+			margin-top: 4rpx;
+		}
+		.cancel-upload{
+			width: 300rpx;
+			height: 60rpx;
+			text-align: center;
+			line-height: 60rpx;
+			border-radius: 40rpx;
+			background: var(--bgColor);
+			color: #FFFFFF;
+			margin: 30rpx auto 0;
+		}
+	}
+</style>

+ 59 - 6
pages/apply/apply.vue

@@ -48,17 +48,22 @@
 		</view>
 		<compress ref="compress"></compress>
 		<toast ref="toast"></toast>
+		<uploadAlert ref="uploadAlert" :updateProgress="updateProgress" @cancelUpload="cancelUpload"></uploadAlert>
 	</view>
 </template>
 
 <script>
 	import compress from "@/components/compress.vue"
 	import uploadImg from "@/components/uploadImg/uploadImg.vue"
+	import uploadAlert from "@/components/alert/uploadAlert.vue"
+	import config from "@/assets/http/config.js"
+	let uploadTask
 	export default {
 		name: '',
 		components: {
 			compress,
-			uploadImg
+			uploadImg,
+			uploadAlert
 		},
 		data() {
 			return {
@@ -82,6 +87,7 @@
 
 				applyInfo: {},
 				activeType: '', //活动类型: VIDEO_TEXT视频图文 IMAGE_TEXT图片文本
+				updateProgress: '', //上传进度
 			};
 		},
 		onLoad(options) {
@@ -161,19 +167,26 @@
 			 * 上传视频作品
 			 */
 			async uploadVideoWork() {
-				this.$dialog.showLoading('正在上传中..')
 				let resp = await this.chooseVideo()
+				// this.$dialog.showLoading('正在上传中..')
+				this.$refs.uploadAlert.show = true;
 				//上传视频链接
-				let videoRes = await this.$api.uploadFile(resp.tempFilePath)
-				this.applyInfo.videoUrl = videoRes.data.data.link
+				let videoRes = await this.uploadVideo(resp.tempFilePath)
+				this.applyInfo.videoUrl = videoRes.data.link;
 				//上传视频封面链接
-				let coverRes = await this.$api.uploadFile(resp.thumbTempFilePath)
+				// let coverRes = await this.$api.uploadFile(resp.thumbTempFilePath)
 				// this.applyInfo.imgUrl = coverRes.data.data.link
 				// this.$refs.uploadImg.imgList = [this.applyInfo.imgUrl]
 				//显示的是视频链接
 				this.showUrl = this.applyInfo.videoUrl
 				uni.hideLoading()
 			},
+			/**
+			 * 取消视频作品
+			 */
+			cancelUpload(){
+				uploadTask.abort();
+			},
 			/**
 			 * 选择视频
 			 */
@@ -184,7 +197,12 @@
 						count: 1,
 						sourceType: ['album'],
 						success: function(res) {
-							console.log("视频大小", res)
+							let fileSize = (res.size/1024/1024).toFixed(2)
+							console.log("视频大小", fileSize)
+							if(fileSize > 50){
+								that.$refs.toast.error('上传视频不能大于50M')
+								return
+							}
 							resolve(res)
 						},
 						fail() {
@@ -193,6 +211,41 @@
 					});
 				})
 			},
+			/**
+			 * 上传视频
+			 */
+			uploadVideo(tempFilePath) {
+				let that = this;
+				return new Promise((resolve, reject) => {
+					uploadTask = uni.uploadFile({
+						url: `${config.baseURL}/blade-resource/oss/endpoint/put-file`,
+						filePath: tempFilePath,
+						name: 'file',
+						formData: { user: 'test' },
+						header: { "Blade-Auth": uni.getStorageSync('token') },
+						success(res) {
+							resolve(JSON.parse(res.data))
+							that.$refs.uploadAlert.show = false;
+							that.updateProgress = '';
+						},
+						fail(err) {
+							//用户取消上传
+							if(err.errMsg === 'uploadFile:fail abort'){
+								that.$refs.uploadAlert.show = false;
+								that.updateProgress = '';
+								that.$refs.toast.warn('取消上传')
+							}
+						}
+					});
+
+					uploadTask.onProgressUpdate(function(res) {
+						that.updateProgress = res;
+						console.log('上传进度' + res.progress);
+						console.log('已经上传的数据长度' + res.totalBytesSent);
+						console.log('预期需要上传的数据总长度' + res.totalBytesExpectedToSend);
+					});
+				});
+			},
 			/**
 			 * 压缩视频
 			 */

+ 6 - 8
pages/payResult/payResult.vue

@@ -1,8 +1,8 @@
 <template>
 	<view class="payResult">
-		<u-icon name="checkmark-circle-fill" :color="bgColor" style="margin-top: 50rpx;" size="100"></u-icon>
+		<u-icon name="checkmark-circle-fill" color="#04BE02" style="margin-top: 50rpx;" size="180"></u-icon>
 		<view>支付成功</view>
-		<u-button  shape="circle" :custom-style="customStyle" style="margin-top: 50rpx;" @click="goback">{{orderType == 'VOTE_ORDER' ? '返回投票页' : '返回详情页'}}</u-button>
+		<u-button  shape="circle" :custom-style="customStyle" style="margin-top: 120rpx;" @click="goback">{{orderType == 'VOTE_ORDER' ? '返回投票' : '返回商城'}}</u-button>
 	</view>
 </template>
 
@@ -14,11 +14,11 @@
 			return {
 				customStyle: {
 					color: 'white',
-					background: "#E72226",
-					width: '200rpx',
+					background: "#04BE02",
+					width: '320rpx',
 					margin: '10rpx',
-					height:"60rpx",
-					fontSize:"26rpx"
+					height:"80rpx",
+					fontSize:"30rpx"
 				},
 				redirect_url: '',
 				bgColor: '',
@@ -28,7 +28,6 @@
 		async onLoad(options) {
 			// const vConsole = new VConsole();
 			console.log("商品小票",options)
-			this.customStyle.background = this.bgColor;
 			let params = {
 				orderId: options.out_trade_no
 			}
@@ -36,7 +35,6 @@
 			if(res.data.success){
 				this.redirect_url = res.data.data.url;
 				this.bgColor = res.data.data.color;
-				this.customStyle.background = this.bgColor;
 				this.orderType = res.data.data.type;
 			}