hmp 4 лет назад
Родитель
Сommit
90a2836f2f
2 измененных файлов с 78 добавлено и 40 удалено
  1. 44 21
      common/utils/mpi.js
  2. 34 19
      pages/activityList/activity/signUp.vue

+ 44 - 21
common/utils/mpi.js

@@ -1,27 +1,50 @@
 import Global from './global.js'
 let mpi = {}
 
-//选择图片 res.tempFilePaths[0]
-mpi.uploadFile = (count=1) => {
-  return new Promise((resolve, reject)=>{
-	uni.chooseFile({
-	  count, //默认100
-	  type:'all',
-	    success: function (res) {
-			uni.uploadFile({
-				url:`${Global.baseUrl}/putObject`, //仅为示例,非真实的接口地址
-				filePath: res.tempFilePaths[0],
-				name: 'file',
-				success: (uploadFileRes) => {
-					resolve(uploadFileRes.data)
-				},
-				fail:()=>{
-					reject(err)
-				}
-			});
-	    }
-	});
-  })
+//上传图片
+mpi.uploadFile = (count = 1) => {
+	return new Promise((resolve, reject) => {
+		uni.chooseImage({
+			count, //默认100
+			sizeType: ['original', 'compressed'],
+			sourceType: ['album', 'camera'],
+			success: function(res) {
+				uni.uploadFile({
+					url: `${Global.baseUrl}/putObject`, //仅为示例,非真实的接口地址
+					filePath: res.tempFilePaths[0],
+					name: 'file',
+					success: (uploadFileRes) => {
+						resolve(uploadFileRes.data)
+					},
+					fail: () => {
+						reject(err)
+					}
+				});
+			}
+		});
+	})
+}
+
+mpi.uploadVideo = () => {
+	return new Promise((resolve, reject) => {
+		uni.chooseVideo({
+			count:1, //默认100
+			sourceType: ['album', 'camera'],
+			success: function(res) {
+				uni.uploadFile({
+					url: `${Global.baseUrl}/putObject`, //仅为示例,非真实的接口地址
+					filePath: res.tempFilePath,
+					name: 'file',
+					success: (uploadFileRes) => {
+						resolve(uploadFileRes.data)
+					},
+					fail: () => {
+						reject(err)
+					}
+				});
+			}
+		});
+	})
 }
 
 export default mpi

+ 34 - 19
pages/activityList/activity/signUp.vue

@@ -4,6 +4,11 @@
 			<view class="cuIcon-roundaddfill theme-color" style="font-size: 80upx;padding: 100upx 0 30upx 0;"></view>
 			<view class="text-black text-bold text-sm">添加图片或视频</view>
 		</view>
+		<view class="image-container" v-if="data.urlsType==1">
+			<view class="cuIcon-roundaddfill theme-color" style="font-size: 80upx;padding: 100upx 0 30upx 0;"></view>
+			<view class="text-black text-bold text-sm">请上传作品封面</view>
+		</view>
+		
 		<u-action-sheet :list="list" @click="upload" v-model="selectShow"></u-action-sheet>
 		<view class="basic-container">
 			<view class="padding-sm">
@@ -12,29 +17,29 @@
 			</view>
 			<view class="padding-sm flex justify-around align-center">
 				<block v-for="(item, index) in classification" :key="index">
-					<view class="tags" :class="current == index ? 'theme-bg-color text-white' : ''" @click="current = index">{{item}}</view>
+					<view class="tags" :class="current == index ? 'theme-bg-color text-white' : ''" @click="current = index;data.personType=item">{{item}}</view>
 				</block>
 			</view>
 			<view class="padding-sm">
 				<text class="text-black text-bold text-lg padding-left-sm">{{detail.personTitle}}</text>
 				<view style="padding: 30upx 20upx;">
-					<u-input v-model="name" placeholder="请输入歌手名字" />
+					<u-input v-model="data.personName" :placeholder="'请输入'+detail.personTitle" />
 				</view>
 				<view style="padding: 0 20upx 40upx 20upx;">
 					<u-line color="#e3e3e3" />
 				</view>
 				<text class="text-black text-bold text-lg padding-left-sm">{{detail.productionTitle}}</text>
 				<view style="padding: 30upx 20upx;">
-					<u-input v-model="music" placeholder="请输入歌曲名称" />
+					<u-input v-model="data.title" :placeholder="'请输入'+detail.productionTitle" />
 				</view>
 				<view style="padding: 0 20upx 40upx 20upx;">
 					<u-line color="#e3e3e3" />
 				</view>
 				<text class="text-black text-bold text-lg padding-left-sm">{{detail.introductionTitle}}</text>
 				<view style="padding: 30upx 20upx 0 20upx;">
-					<u-input v-model="introduction" type="textarea" :clearable="false" height="140" :autoHeight="false" maxlength="60" placeholder="请输入个人简介" />
+					<u-input v-model="data.introduce" type="textarea" :clearable="false" height="140" :autoHeight="false" maxlength="60" :placeholder="'请输入'+detail.productionTitle" />
 				</view>
-				<view class="flex justify-end padding-right-sm padding-bottom-sm text-gray">{{introduction.length}} / 60</view>
+				<view class="flex justify-end padding-right-sm padding-bottom-sm text-gray">{{data.introduce.length}} / 60</view>
 				<view style="padding: 0 20upx 40upx 20upx;">
 					<u-line color="#e3e3e3" />
 				</view>
@@ -58,28 +63,37 @@
 					text: '上传视频'
 				}],
 				current: 0,
+				type:0,
 				classification: [],
 				name: '',
 				introduction: '',
-				music: '',
+				
+				data:{
+					userId:'',
+					urlsType:0,
+					urls:'',
+					person_name:'',
+					introduce:''
+				}
 			}
 		},
 		onLoad(options) {
 			this.getActivityDetail(options.activityId);
 		},
 		methods: {
-			upload(index) {
+			async upload(index) {
 				console.log(index);
-				if (index == 0) {
-					
-				}
-				if (index == 1) {
-					
+				let res;
+				this.data.urlsType=index
+				if (index==0) {
+					//上传图片
+					res=await this.$mpi.uploadFile()
+				}else{
+					//上传视频
+					res=await this.$mpi.uploadVideo()
 				}
-				// this.$mpi.uploadFile().then(res => {
-				// 	let obj = JSON.parse(res);
-				// 	console.log(res.data);
-				// })
+				let obj = JSON.parse(res);
+				this.data.urls=obj.data
 			},
 			getActivityDetail(id) {
 				this.$u.api.activity.detail({id: id}).then(res => {
@@ -88,9 +102,10 @@
 				})
 			},
 			navWithParam() {
-				uni.navigateTo({
-					url: '/pages/activityList/mine/introduction'
-				})
+				console.log(this.data);
+				// uni.navigateTo({
+				// 	url: '/pages/activityList/mine/introduction'
+				// })
 			}
 		}
 	}