achao 3 years ago
parent
commit
ebb4fffb16
2 changed files with 51 additions and 23 deletions
  1. 43 22
      hybrid/html/video.html
  2. 8 1
      pages/mine/cargoowner/editpersonalinformation.vue

+ 43 - 22
hybrid/html/video.html

@@ -3,7 +3,7 @@
 	<head>
 		<meta charset="utf-8">
 		<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
-		<title></title>
+		<title>视频认证</title>
 		<style>
 			body {
 				margin: 0;
@@ -131,7 +131,7 @@
 				</div>
 
 
-				<!-- <video ref="videob" controls="" name="media" v-show="!showVideo" width="100%" height="400"></video> -->
+				<video ref="videob" controls="" name="media" v-show="!showVideo" width="100%" height="400"></video>
 			</div>
 
 
@@ -175,7 +175,7 @@
 					const policyText = {
 						"expiration": srcT, //设置该Policy的失效时间,超过这个失效时间之后,就没有办法通过这个policy上传文件了 
 						"conditions": [
-							["content-length-range", 0, 5 * 1024 * 1024] // 设置上传文件的大小限制,5mb
+							["content-length-range", 0, 100 * 1024 * 1024] // 设置上传文件的大小限制,5mb
 						]
 					};
 
@@ -194,22 +194,19 @@
 					// console.log(signature);
 					return signature;
 				},
-				uploadFile() {
+				uploadFile(file) {
 					var formdata = new FormData()
 					const policyBase64 = this.getPolicyBase64();
-					console.log("policyBase64-----------------------")
-					console.log(policyBase64)
 					const signature = this.getSignature(policyBase64); //获取签名
-					console.log("signatur--------------------------------------e")
-					console.log(signature)
-					formdata.append("key", 'appData/' + new Date().getTime() + Math.floor(Math.random() * 150) +
-						'.png')
+					formdata.append("key", 'appData/video' + new Date().getTime() + Math.floor(Math.random() * 150) +
+						'.mp4')
 					formdata.append("policy", policyBase64)
 					formdata.append("OSSAccessKeyId", 'LTAI4G9c14PgKvM23WZ9zrpc')
 					// E9996KCDUh5wSzsJjHzqaq/FmHk=
 					// formdata.append("signature", 'E9996KCDUh5wSzsJjHzqaq/FmHk=')
 					formdata.append("signature", signature)
 					formdata.append("success_action_status", '200')
+					formdata.append("file",file)
 					$.ajax({
 						type: "POST",
 						data: formdata,
@@ -322,8 +319,35 @@
 						}, 1000)
 					}
 				},
+				dataURLtoBlob(dataurl) {
+				
+				      var arr = dataurl.split(","),
+				
+				        mime = arr[0].match(/:(.*?);/)[1],
+				
+				        bstr = atob(arr[1]),
+				
+				        n = bstr.length,
+				
+				        u8arr = new Uint8Array(n);
+				
+				      while (n--) {
+				
+				        u8arr[n] = bstr.charCodeAt(n);
+				
+				      }
+				
+				      return this.blobToFile(new Blob([u8arr], { type: mime }), { type: mime });
+				
+				    },
+					blobToFile(theBlob, type) {
+					      theBlob.lastModifiedDate = new Date();
+					      return new File([theBlob], `${new Date().getTime()}.mp4`, type);
+					
+					    },
 				// 保存录制视频
 				saveVideo() {
+					let that = this
 					if (this.isAlreadyRecord) {
 						this.countTimer && clearTimeout(this.countTimer)
 						this.showVideo = false
@@ -335,24 +359,21 @@
 						}
 						this.mediaRecorder.stop()
 						setTimeout(() => {
+							console.log("this.recordedBlobs-------------------------")
 							var blob = new Blob(this.recordedBlobs, {
 								type: 'video/mp4'
 							})
-
-							// console.log(blob)
 							this.isAlreadyRecord = false
 							this.MediaStreamTrack && this.MediaStreamTrack.stop()
 							var reader = new FileReader();
-							reader.readAsDataURL(blob, 'utf-8')
-							reader.onload = () => {
-
-								console.log('11111111111111111')
-								console.log(reader.result); // base64格式
-								// this.$refs.videob.src = reader.result
-								this.uploadFile(blob)
-
-								console.log(reader)
-
+							reader.readAsDataURL(blob)
+							reader.onload = (e) => {
+								this.$refs.videob.src = reader.result
+								
+								
+								let a = this.dataURLtoBlob(reader.result)
+								console.log(a)
+								this.uploadFile(a)
 							}
 						}, 1000)
 					} else {

+ 8 - 1
pages/mine/cargoowner/editpersonalinformation.vue

@@ -19,7 +19,7 @@
 			<view class="flex row" style='padding:10px 0 5px;border-bottom:1px solid #eee;'>
 				<view style='width:100px;font-size:14px;'>性别</view>
 				<u-radio-group v-model="dataDetails.driverSex" placement="row">
-					<u-radio :customStyle="{marginBottom: '8px'}" v-for="(item, index) in radiolist1" :key="index"
+					<u-radio :customStyle="radioCustomStyle" v-for="(item, index) in radiolist1" :key="index"
 						:label="item.name" :name="item.name" @change="radioChange">
 					</u-radio>
 				</u-radio-group>
@@ -83,6 +83,7 @@
 					</view>
 				</view>
 			</view>
+			<view class="bz">注:个人信息审核通过后自动认证成为个人货主。</view>
 			<u-picker :show="isShowcardValidity" ref="uPicker" :columns="validityPeriod"
 				@confirm="confirmValidityPeriod" @change="changeHandler" @cancel="isShowcardValidity=false">
 			</u-picker>
@@ -125,6 +126,9 @@
 		components: {},
 		data() {
 			return {
+				radioCustomStyle: {
+					margin: '0 0 0 20rpx'
+				},
 				radiolist1: [{
 						name: '男',
 						disabled: false
@@ -523,4 +527,7 @@
 		height: 80rpx;
 		z-index: 9;
 	}
+	.bz{
+		font-size: 28rpx;
+	}
 </style>