Descarga de archivos Uniapp, archivo de descarga del paquete apk y abierto

Descarga de archivos sin aplicación, vue

<template>
	<view class="uni-common-mt">
		<view class="uni-padding-wrap">
			<view class="cu-form-group">
				<view class="title">未绑定:</view>
				<input class="input" type="text" name="codeTest1" @confirm="unBinderConfirm($event)"></input>
			</view>
			<view class="uni-textarea" style="background-color: white;">
				<textarea v-model="tetsCode.unbinderText" style="color: black;" />
			</view>
			<view class="tag-view panel-full margin-top">
				<uni-tag text="清空" type="success" @click="tetsCode.unbinderText = '未绑定文本:'" />
			</view>
			<view class="cu-form-group">
				<view class="title" style="color: red;">双向绑定:</view>
				<input v-model="tetsCode.binderCode" @confirm="BinderConfirm()" class="input" type="text"
					name="codeTest2" style="color: red;"></input>
			</view>
			<view class="uni-textarea" style="background-color: white;">
				<textarea v-model="tetsCode.binderText" style="color: red;" />
			</view>
			<view class="tag-view panel-full margin-top">
				<uni-tag text="清空" type="success" @click="tetsCode.binderText = '双向绑定文本:'" />
			</view>
			<view class="cu-form-group">
				<view class="title" style="color: green;">主机名:</view>
				<input v-model="tetsCode.host" @confirm="BinderConfirm()" class="input" type="text" name="codeTest2"
					style="color: green;"></input>
			</view>
			<view class="tag-view panel-full margin-top">
				<uni-tag text="获取" type="error" @click="download3()" />
			</view>
		</view>
	</view>
	</view>
</template>

<script>
	import permision from "@/common/js/permission.js"
	import uniTag from '@/components/uni-ui/uni-tag/uni-tag.vue';
	import UniIcons from '@/components/uni-ui/uni-icon/uni-icon.vue'
	import UniNumberBox from '@/components/uni-ui/uni-number-box/uni-number-box.vue'

	import uniIcon from '@/components/uni-icon/uni-icon.vue'
	import tTable from '@/components/t-table/t-table.vue';
	import tTh from '@/components/t-table/t-th.vue';
	import tTr from '@/components/t-table/t-tr.vue';
	import tTd from '@/components/t-table/t-td.vue';

	export default {
    
    
		components: {
    
    
			uniTag,
			UniIcons,
			UniNumberBox,
			uniIcon,
			tTable,
			tTh,
			tTr,
			tTd
		},
		onLoad(e) {
    
    

		},
		data() {
    
    

			return {
    
    
				tetsCode: {
    
    
					binderCode: "123",
					binderText: "双向绑定文本:",
					unbinderText: "未绑定文本:",
					host: "127.0.0.1"
				}
			}
		},
		onLoad() {
    
    
			//this.circleRodObjList = []
		},
		methods: {
    
    
			unBinderConfirm(e) {
    
    
				//获取文本框条码
				let text = e.target.value
				console.log(text)
				this.tetsCode.unbinderText = this.tetsCode.unbinderText + "\n" + text
			},
			BinderConfirm(e) {
    
    
				let binderCode = this.tetsCode.binderCode
				console.log(binderCode)
				this.tetsCode.binderText = this.tetsCode.binderText + "\n" + binderCode
			},
			download() {
    
    
				let downUrl = "http://" + this.tetsCode.host + ":8088/webapp/service/apk/downloadLastFile2"
				uni.downloadFile({
    
    
					url: downUrl, //仅为示例,并非真实的资源
					success: (res) => {
    
    
						if (res.statusCode === 200) {
    
    
							console.log('下载成功');
							console.log(res.tempFilePath);
						}
					}
				});

			},
			download2() {
    
    
				let downUrl = "http://" + this.tetsCode.host + ":8088/webapp/service/apk/downloadLastFile2"
				uni.downloadFile({
    
    
					url: downUrl, //仅为示例,并非真实的资源
					success: (res) => {
    
    
						if (res.statusCode === 200) {
    
    
							console.log('下载成功');
						}
						let that = this;
						uni.openDocument({
    
    
							filePath: res.tempFilePath,
							showMenu: true,
							success: function(res) {
    
    
								console.log('打开文档成功');
							}
						});
					}
				});

			},
			download3() {
    
    
				let downUrl = "http://" + this.tetsCode.host + ":8088/webapp/service/apk/downloadLastFile2"
				plus.runtime.openURL(downUrl)
			}
		}
	}
</script>
<style>
	.uni-padding-wrap {
    
    
		width: 100%;
		padding: 0 20upx;
	}

	.uni-common-mt {
    
    
		width: 100%;
	}

	.cu-form-group {
    
    
		width: 100%;
		margin: 20upx 0;
	}

	.scroll-view_H {
    
    
		width: 200;
		display: flex;
		flex-wrap: nowrap;
	}

	.scrollx_items {
    
    
		text-align: center;
		display: inline-block;
		width: 210rpx;
		box-sizing: border-box;
		margin-left: 30rpx;
		margin-top: 3px;
	}

	.t-td {
    
    

		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;

	}

	.t-th {
    
    
		width: 180px;
	}

	.tap-button-text {
    
    
		color: darkcyan
	}

	.radio_mat {
    
    

		margin-left: 40upx;
	}
</style>

Supongo que te gusta

Origin blog.csdn.net/oXiaoWeiWuDi/article/details/126161670
Recomendado
Clasificación