Browse Source

添加音频下载

zhuxiuping 3 years ago
parent
commit
8669bb8510

+ 10 - 10
manifest.json

@@ -63,16 +63,16 @@
             "disableHostCheck" : true,
             "proxy" : {
                 //使用代理
-                // "/video" : {
-                //     "target" : "https://chuanghai-tech.com/video", //目标地址
-                //     "changeOrigin" : true,
-                //     "secure" : false,
-                //     // 设置地址重定向,把程序中/api开头的路径替换成:http://t.yushu.im"
-                //     "pathRewrite" : {
-                //         "/video" : "" // 设置/api路径重定向
-                //     }
-                // },
-                ///testingServer/shareVideo
+                "/img" : {
+                    "target" : "http://139.199.2.142:8081//img", //目标地址
+                    "changeOrigin" : true,
+                    "secure" : false,
+                    // 设置地址重定向,把程序中/api开头的路径替换成:http://t.yushu.im"
+                    "pathRewrite" : {
+                        "/img" : "" // 设置/api路径重定向
+                    }
+                },
+                // /testingServer/shareVideo
                 "/shareVideo" : {
                     "target" : "http://139.199.2.142:8081/shareVideo", //目标地址https://chtech.ncjti.edu.cn/testingServer/shareVideo
                     "changeOrigin" : true,

+ 4 - 3
pages/IOSDownLoad/IOSDownLoad.vue

@@ -2,7 +2,7 @@
  
 <template>
 	<view>
-		<button v-if="!isWeiXin" class="download-btn" type="default" @click="downLoad()">点击下载pdf</button>
+		<button v-if="!isWeiXin" class="download-btn" type="default" @click="downLoad()">点击下载{{fileUrl}}</button>
 	</view>
 </template>
  
@@ -46,7 +46,8 @@
 					title: "正在请求数据"
 				});
 				uni.request({
-					url: '/video/txt.pdf', //获取文件流的请求路径
+					url: '/img'+this.fileUrl, //获取文件流的请求路径
+					// url: '/api//img/1.pdf',
 					responseType: "arraybuffer",
 					success: (response) => {
 						uni.hideLoading();
@@ -61,7 +62,7 @@
 						let downloadElement = document.createElement("a");
 						let href = window.URL.createObjectURL(blob); //创建下载的链接
 						downloadElement.href = href;
-						downloadElement.download = '文件.pdf'; //下载后文件名
+						downloadElement.download = this.fileUrl; //下载后文件名
 						document.body.appendChild(downloadElement);
 						downloadElement.click(); //点击下载
 						uni.showToast({

+ 8 - 5
pages/index/index.vue

@@ -21,8 +21,8 @@
 			<view class="list-icon"></view>
 			<view class="list-title2">学习资料</view>
 			<!-- 资料 -->
-			<view style="width: 690rpx;margin-left: 40px;margin-top: 10px;">
-				<view class="ziliao">{{item.courseName}}</view>
+			<view style="width: 690rpx;margin-left: 40px;margin-top: 10px;" v-for="(item,index) in item.videoElseList" :key="index">
+				<view class="ziliao">{{item.videoElesName}}</view>
 				<image src="../../static/xiazai.png" class="xiazai" @click="download(item)"></image>
 			</view>
 			<view style="height:20px"></view>
@@ -42,6 +42,7 @@
 				phone:'xxxxxxxxxxx',//手机号
 				fileUrl:'https://chuanghai-tech.com/video/txt.pdf',//下载链接
 				list:[],//当前页面数组数据
+				list2:[],//下载的东西2
 				token:'',//缓存token
 				resultDecodeN:'',//解密后数据
 			}
@@ -73,12 +74,13 @@
 						this.$fns.rsaDecode(shu[3])+this.$fns.rsaDecode(shu[4])+
 						this.$fns.rsaDecode(shu[5])+this.$fns.rsaDecode(shu[6])+
 						this.$fns.rsaDecode(shu[7])+this.$fns.rsaDecode(shu[8])+
-						this.$fns.rsaDecode(shu[9])
+						this.$fns.rsaDecode(shu[9])+this.$fns.rsaDecode(shu[10])
 						//解析
 						console.log(JSON.parse(this.resultDecodeN));
 						//获取数组
 						JSON.parse(this.resultDecodeN).forEach(data => {
 							this.list.push(data)
+							// this.list2.push(data.videoElseList)
 						})
 					} else {
 						uni.showToast({ title: res.data.message, icon: 'none' });
@@ -96,11 +98,11 @@
 			download(item) {
 				if(this.isIos()){
 						uni.navigateTo({
-						    url:'/pages/IOSDownLoad/IOSDownLoad?url='+item.courseUrl
+						    url:'/pages/IOSDownLoad/IOSDownLoad?url='+item.videoElesUrl
 					    })
 					}else{
 				        //直接在浏览器中打开
-						window.location.href = item.courseUrl;
+						window.location.href = 'http://139.199.2.142:8081//img'+item.videoElesUrl;
 					}
 			},
 			//判断是否ios
@@ -214,6 +216,7 @@
 	}
 	/* 资料 */
 	.ziliao{
+		width: 170px;
 		line-height: 40rpx;
 		font-size: 32rpx;
 		float: left;

BIN
unpackage/dist/build/h5.zip


File diff suppressed because it is too large
+ 1 - 1
unpackage/dist/build/h5/index.html


File diff suppressed because it is too large
+ 1 - 1
unpackage/dist/build/h5/static/js/index.292ab4b6.js


File diff suppressed because it is too large
+ 0 - 1
unpackage/dist/build/h5/static/js/pages-IOSDownLoad-IOSDownLoad.231b2773.js


File diff suppressed because it is too large
+ 1 - 0
unpackage/dist/build/h5/static/js/pages-IOSDownLoad-IOSDownLoad.e1195cfd.js


File diff suppressed because it is too large
+ 0 - 1
unpackage/dist/build/h5/static/js/pages-index-index.35c3278e.js


File diff suppressed because it is too large
+ 1 - 0
unpackage/dist/build/h5/static/js/pages-index-index.e05d1096.js


File diff suppressed because it is too large
+ 0 - 1
unpackage/dist/build/h5/static/js/pages-video-video.30e00a9a.js


File diff suppressed because it is too large
+ 1 - 0
unpackage/dist/build/h5/static/js/pages-video-video.ebb1ea21.js