personBaseIndex.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <template>
  2. <view>
  3. <view>
  4. <web-view :webview-styles="webviewStyles" v-if="url" :src="url" @message="message" @onPostMessage="recivePostMessage" style="background-color: #0A8CD5;"></web-view>
  5. </view>
  6. </view>
  7. </template>
  8. <script>
  9. import config from "../../core/api.js"
  10. export default {
  11. data() {
  12. return {
  13. id: "",
  14. url: "",
  15. webviewStyles: {
  16. //进度条样式。仅加载网络 HTML 时生效,
  17. progress: {
  18. color: '#0A8CD5'
  19. }
  20. }
  21. }
  22. },
  23. onLoad(e) {
  24. this.id = e.id;
  25. var project = uni.getStorageSync("porject"+"_"+uni.getStorageSync("userInfo").id);
  26. var authorityList = uni.getStorageSync("authorityList");
  27. var isShangbao = 0;
  28. var isFaqirenwu = 0;
  29. for (let i = 0; i < authorityList.length; i++) {
  30. if(authorityList[i].url == '/ziiliaotianbaoshangbao'){
  31. isShangbao = 1;
  32. }
  33. if(authorityList[i].url == '/ziliaotianbaofaqirenwu'){
  34. isFaqirenwu = 1;
  35. }
  36. }
  37. let faction = 1;
  38. //施工质检资料 为1
  39. if(project.contract_type == 1 || project.contract_type == 2){
  40. faction = 2
  41. }
  42. let userInfo = uni.getStorageSync("userInfo")
  43. if (config.api == "/api") { //本地测试
  44. 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;
  45. } else {
  46. 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;
  47. }
  48. //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;
  49. // if (e.type) {
  50. // this.type = e.type
  51. // }
  52. var height = 0; //定义动态的高度变量,如高度为定值,可以直接写
  53. uni.getSystemInfo({
  54. //成功获取的回调函数,返回值为系统信息
  55. success: (sysinfo) => {
  56. height = sysinfo.windowHeight - 32; //自行修改,自己需要的高度
  57. }
  58. });
  59. var currentWebview = this.$scope.$getAppWebview(); //获取当前web-view
  60. setTimeout(function() {
  61. var wv = currentWebview.children()[0];
  62. wv.setStyle({ //设置web-view距离顶部的距离以及自己的高度,单位为px
  63. top: 35,
  64. height: height,
  65. softinputMode: "adjustResize"
  66. })
  67. }, 1000);
  68. plus.globalEvent.addEventListener('plusMessage', function(msg){
  69. if(msg.data.args.data.name == 'postMessage'){
  70. console.log('子页面返回的数据为:'+JSON.stringify(msg.data.args.data.arg));
  71. }
  72. });
  73. //console.log(plus.webview)
  74. //console.log(plus.webview.getLaunchWebview())
  75. },
  76. methods: {
  77. message(e) { //接收h5的下载url,进行url解析,然后下载到手机
  78. var url = e.detail.data[0];
  79. var id = url.split("=")[1];
  80. var that = this;
  81. that.http.request("/app/attByApp", {
  82. id: id
  83. }).then((reslut) => {
  84. uni.downloadFile({
  85. url: reslut.data.filePath,
  86. success: (res) => {
  87. if (res.statusCode === 200) {
  88. uni.saveFile({
  89. tempFilePath: res.tempFilePath,
  90. success: function(data) {
  91. that.$prompt.none('下载成功');
  92. /*手机保存的位置为:内部存储\Android\data\io.dcloud.HBuilder\apps\HBuilder\doc\uniapp_save*/
  93. }
  94. })
  95. }
  96. }
  97. });
  98. })
  99. },
  100. recivePostMessage(e){
  101. console.log(e)
  102. uni.showLoading({
  103. title: '加载中'
  104. });
  105. }
  106. }
  107. }
  108. </script>
  109. <style>
  110. .solid-bottom-type {
  111. border-bottom: 0.5px solid #eee;
  112. }
  113. .bg-add {
  114. background-color: #F7F7F7;
  115. }
  116. .cu-list_b {
  117. margin: 22rpx 22rpx 30rpx;
  118. padding-bottom: 30rpx;
  119. background-color: #fff;
  120. border-radius: 20rpx;
  121. box-shadow: 0px 0px 6px #D0D0D0;
  122. }
  123. .cu-item_b {
  124. display: flex;
  125. align-items: center;
  126. height: 118rpx;
  127. justify-content: space-between;
  128. padding: 0 22rpx;
  129. border-bottom: 2rpx solid #0A8CD5;
  130. }
  131. .cu-item_img {
  132. display: flex;
  133. }
  134. .cu-item_img image {
  135. width: 80rpx;
  136. height: 80rpx;
  137. margin-right: 16rpx;
  138. }
  139. .content_nav {
  140. font-size: 30rpx;
  141. color: #101010;
  142. font-weight: bold;
  143. padding: 22rpx 22rpx 26rpx;
  144. }
  145. .cu-button {
  146. padding: 58rpx 0 20rpx;
  147. display: flex;
  148. border-bottom: 2rpx solid #E3E1E1;
  149. }
  150. .cu-button button {
  151. background-color: #EF9D1E;
  152. border-radius: 0 100rpx 100rpx 0;
  153. width: 200rpx;
  154. height: 80rpx;
  155. font-size: 30rpx;
  156. color: #fff;
  157. }
  158. uni-button:after {
  159. border: none;
  160. }
  161. .cu-form-group {
  162. padding: 24rpx 22rpx;
  163. display: flex;
  164. align-items: center;
  165. border-bottom: 2rpx solid #E3E1E1;
  166. }
  167. .cu-form-group:last-child {
  168. border-bottom: none
  169. }
  170. .cu-form-group .title {
  171. font-size: 30rpx;
  172. color: #101010;
  173. padding-right: 16rpx;
  174. font-weight: bold;
  175. }
  176. .cu-form-group input {
  177. font-size: 30rpx;
  178. color: #8a8a8a;
  179. }
  180. </style>