123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198 |
- <template>
- <view>
- <view>
- <web-view :webview-styles="webviewStyles" v-if="url" :src="url" @message="message" @onPostMessage="recivePostMessage" style="background-color: #0A8CD5;"></web-view>
- </view>
- </view>
- </template>
- <script>
- import config from "../../core/api.js"
- export default {
- data() {
- return {
- id: "",
- url: "",
- webviewStyles: {
- //进度条样式。仅加载网络 HTML 时生效,
- progress: {
- color: '#0A8CD5'
- }
- }
- }
- },
- onLoad(e) {
- this.id = e.id;
- var project = uni.getStorageSync("porject"+"_"+uni.getStorageSync("userInfo").id);
- var authorityList = uni.getStorageSync("authorityList");
- var isShangbao = 0;
- var isFaqirenwu = 0;
- for (let i = 0; i < authorityList.length; i++) {
- if(authorityList[i].url == '/ziiliaotianbaoshangbao'){
- isShangbao = 1;
- }
- if(authorityList[i].url == '/ziliaotianbaofaqirenwu'){
- isFaqirenwu = 1;
- }
- }
-
- let faction = 1;
- //施工质检资料 为1
- if(project.contract_type == 1 || project.contract_type == 2){
- faction = 2
- }
- let userInfo = uni.getStorageSync("userInfo")
- if (config.api == "/api") { //本地测试
- this.url = "http://www.hcxxy.com/app/findForm?id=" + this.id + "&userId=" + userInfo.id+"&projectId="+project.id+"&contractId="+project.contractId+"&roleId="+project.roleId+"&faction="+faction +"&isShangbao="+isShangbao+"&isFaqirenwu="+isFaqirenwu+"&storeName="+uni.getStorageSync("storeName")+"&Authorization="+uni.getStorageSync("token")+'&account=' + userInfo.account;
- } else {
- this.url = config.api + "/app/findForm?id=" + this.id + "&userId=" + userInfo.id+"&projectId="+project.id+"&contractId="+project.contractId+"&roleId="+project.roleId+"&faction="+faction +"&isShangbao="+isShangbao+"&isFaqirenwu="+isFaqirenwu+"&storeName="+uni.getStorageSync("storeName")+"&Authorization="+uni.getStorageSync("token")+'&account=' + userInfo.account;
- }
- //this.url = "http://192.168.1.195/app/findForm?id=" + this.id + "&userId=" + userInfo.id+"&projectId="+project.id+"&contractId="+project.contractId+"&roleId="+project.roleId+"&faction="+faction +"&isShangbao="+isShangbao+"&isFaqirenwu="+isFaqirenwu;
- // if (e.type) {
- // this.type = e.type
- // }
- var height = 0; //定义动态的高度变量,如高度为定值,可以直接写
- uni.getSystemInfo({
- //成功获取的回调函数,返回值为系统信息
- success: (sysinfo) => {
- height = sysinfo.windowHeight - 32; //自行修改,自己需要的高度
- }
- });
- var currentWebview = this.$scope.$getAppWebview(); //获取当前web-view
- setTimeout(function() {
- var wv = currentWebview.children()[0];
- wv.setStyle({ //设置web-view距离顶部的距离以及自己的高度,单位为px
- top: 35,
- height: height,
- softinputMode: "adjustResize"
- })
- }, 1000);
- plus.globalEvent.addEventListener('plusMessage', function(msg){
- if(msg.data.args.data.name == 'postMessage'){
- console.log('子页面返回的数据为:'+JSON.stringify(msg.data.args.data.arg));
- }
- });
- //console.log(plus.webview)
- //console.log(plus.webview.getLaunchWebview())
- },
- methods: {
- message(e) { //接收h5的下载url,进行url解析,然后下载到手机
- var url = e.detail.data[0];
- var id = url.split("=")[1];
- var that = this;
- that.http.request("/app/attByApp", {
- id: id
- }).then((reslut) => {
- uni.downloadFile({
- url: reslut.data.filePath,
- success: (res) => {
- if (res.statusCode === 200) {
- uni.saveFile({
- tempFilePath: res.tempFilePath,
- success: function(data) {
- that.$prompt.none('下载成功');
- /*手机保存的位置为:内部存储\Android\data\io.dcloud.HBuilder\apps\HBuilder\doc\uniapp_save*/
- }
- })
- }
- }
- });
- })
- },
- recivePostMessage(e){
- console.log(e)
- uni.showLoading({
- title: '加载中'
- });
- }
- }
- }
- </script>
- <style>
- .solid-bottom-type {
- border-bottom: 0.5px solid #eee;
- }
- .bg-add {
- background-color: #F7F7F7;
- }
- .cu-list_b {
- margin: 22rpx 22rpx 30rpx;
- padding-bottom: 30rpx;
- background-color: #fff;
- border-radius: 20rpx;
- box-shadow: 0px 0px 6px #D0D0D0;
- }
- .cu-item_b {
- display: flex;
- align-items: center;
- height: 118rpx;
- justify-content: space-between;
- padding: 0 22rpx;
- border-bottom: 2rpx solid #0A8CD5;
- }
- .cu-item_img {
- display: flex;
- }
- .cu-item_img image {
- width: 80rpx;
- height: 80rpx;
- margin-right: 16rpx;
- }
- .content_nav {
- font-size: 30rpx;
- color: #101010;
- font-weight: bold;
- padding: 22rpx 22rpx 26rpx;
- }
- .cu-button {
- padding: 58rpx 0 20rpx;
- display: flex;
- border-bottom: 2rpx solid #E3E1E1;
- }
- .cu-button button {
- background-color: #EF9D1E;
- border-radius: 0 100rpx 100rpx 0;
- width: 200rpx;
- height: 80rpx;
- font-size: 30rpx;
- color: #fff;
- }
- uni-button:after {
- border: none;
- }
- .cu-form-group {
- padding: 24rpx 22rpx;
- display: flex;
- align-items: center;
- border-bottom: 2rpx solid #E3E1E1;
- }
- .cu-form-group:last-child {
- border-bottom: none
- }
- .cu-form-group .title {
- font-size: 30rpx;
- color: #101010;
- padding-right: 16rpx;
- font-weight: bold;
- }
- .cu-form-group input {
- font-size: 30rpx;
- color: #8a8a8a;
- }
- </style>
|