程志平 3 years ago
parent
commit
36b455a972
2 changed files with 90 additions and 7 deletions
  1. 86 3
      pagesElectric/jiaofei/ad_dianfei.vue
  2. 4 4
      pagesElectric/jiaofei/jiaofei.vue

+ 86 - 3
pagesElectric/jiaofei/ad_dianfei.vue

@@ -1,19 +1,102 @@
 <template>
-	<web-view :src="url" :progress="false"></web-view>
+	<!-- <web-view :src="url" :progress="false"></web-view> -->
+	<view class="container" :style="{height: screenHeight}">
+		<image :src="url" :show-menu-by-longpress="true" mode="aspectFit" class="ad_img" @tap="longClickImg"></image>
+	</view>
 </template>
 
 <script>
 	export default {
 		data() {
 			return {
-				url: 'https://chtech.ncjti.edu.cn/yidong.html'
+				ceshi: 'code',
+				screenHeight: '',
+				url: ''
 			}
 		},
+		onLoad() {
+			this.get_img()
+		},
+		onShow() {
+			// 从新计算高度
+			setTimeout(() => {
+				this.calc_screen_height()
+			}, 1500)
+		},
 		methods: {
+			async get_img() {
+				let res = await this.$myRequest({
+					host: this.ceshi,
+					url: '/HotWaters/advertquery_h.action',
+					method: 'POST',
+					header: {
+						'content-type': 'application/x-www-form-urlencoded'
+					},
+					data: {
+						'url_name': '水电广告'
+					}
+				})
+
+				// console.log(res.data)
+				if (res.data.data.length == 0) {
+					return
+				}
 
+				if (res.data.code == 200) {
+					if (res.data.data.length > 0) {
+						this.url = res.data.data[res.data.data.length - 1].url
+					} else {
+						uni.showToast({
+							title: '未找到图片',
+							duration: 2000
+						})
+					}
+				} else {
+					uni.showToast({
+						title: '加载数据异常',
+						duration: 1500
+					})
+
+					return
+				}
+			},
+			longClickImg() {
+				wx.previewImage({
+					current: this.url,
+					urls: [this.url]
+				})
+			},
+			/**
+			 * 计算屏幕的高度
+			 */
+			calc_screen_height() {
+				uni.getSystemInfo({
+					success: res => {
+						let h = ((res.screenHeight * (750 / res.windowWidth)) - 160) //将px 转换rpx
+						this.screenHeight = Math.floor(h) + 'rpx'
+					}
+				});
+			}
 		}
 	}
 </script>
 
-<style>
+<style scoped>
+	page {
+		background-color: #f5f5f5;
+	}
+
+	.container {
+		display: flex;
+		flex-direction: column;
+		font-size: 29upx;
+		font-family: "MicrosoftYaHei";
+		padding: 10rpx;
+		width: 730rpx;
+	}
+
+	.ad_img {
+		width: 730rpx;
+		height: 100%;
+	}
 </style>

+ 4 - 4
pagesElectric/jiaofei/jiaofei.vue

@@ -1,5 +1,5 @@
 <template>
-	<view class="content">
+	<view class="container">
 		<view class="select-item" @tap="navigateToSelect">
 			<view class="picker-item-logol">
 				<image class="picker-item-logo-left" src="../static/images/room.png"></image>
@@ -138,9 +138,9 @@
 			 * 跳转到ad页面
 			 */
 			ad_redirect() {
-				// uni.navigateTo({
-				// 	url: 'ad_dianfei'
-				// })
+				uni.navigateTo({
+					url: 'ad_dianfei'
+				})
 			},
 			/**
 			 * 获取基本信息