Bläddra i källkod

广告完成,图片压缩优化

程志平 3 år sedan
förälder
incheckning
e3b2f55785

+ 13 - 5
pagesElectric/jiaofei/ad_dianfei.vue

@@ -43,13 +43,21 @@
 				}
 
 				if (res.data.code == 200) {
-					if (res.data.data.length > 0) {
-						this.url = res.data.data[res.data.data.length - 1].url
-					} else {
+					let tf = false;
+					let tmpData = res.data.data;
+					for (var i = 0; i < tmpData.length; i++) {
+						if (tmpData[i].state == 1 && tmpData[i].remark.indexOf('二维码') != -1) {
+							this.url = tmpData[i].url;
+							tf = true;
+						}
+					}
+
+					if (tf == false) {
 						uni.showToast({
-							title: '未找到图片',
+							icon: 'none',
+							title: '没有启用的二维码图',
 							duration: 2000
-						})
+						});
 					}
 				} else {
 					uni.showToast({

+ 52 - 6
pagesElectric/jiaofei/jiaofei.vue

@@ -71,8 +71,8 @@
 		<view class="change-show" @tap="navigateToShow">
 			台账管理
 		</view>
-		<view class="ad">
-			<image src="../static/images/ad_dianfei.jpg" mode="aspectFill" class="ad_img" @tap="ad_redirect"></image>
+		<view v-if="img_url !== ''" class="ad">
+			<image :src="img_url" mode="aspectFill" class="ad_img" @tap="ad_redirect"></image>
 		</view>
 	</view>
 </template>
@@ -91,7 +91,8 @@
 				stu_number: '',
 				compus: '', //校区
 				ceshi: 'code',
-				test: this.$store.state.test
+				test: this.$store.state.test,
+				img_url: ''
 			}
 		},
 		onLoad(options) {
@@ -103,13 +104,58 @@
 			// 	return
 			// }
 			// 获取基本信息
-			this.get_base_info(options, 'onLoad')
+			this.get_base_info(options, 'onLoad');
+			this.get_img();
 		},
 		onShow() {
 			// 获取基本信息
 			this.get_base_info('options', 'onShow')
 		},
 		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) {
+					let tf = false;
+					let tmpData = res.data.data;
+					for (var i = 0; i < tmpData.length; i++) {
+						if (tmpData[i].state == 1 && tmpData[i].remark.indexOf('缩略图') != -1) {
+							this.img_url = tmpData[i].url;
+							tf = true;
+						}
+					}
+					
+					if (tf == false) {
+						uni.showToast({
+							icon: 'none',
+							title: '没有启用的缩略图',
+							duration: 2000
+						});
+					}
+				} else {
+					uni.showToast({
+						title: '加载数据异常',
+						duration: 1500
+					})
+
+					return
+				}
+			},
 			/**
 			 * 电费详情页面
 			 */
@@ -117,7 +163,7 @@
 				if (this.haveSelectRoom()) {
 					return
 				}
-				
+
 				uni.navigateTo({
 					url: '../dfxq/dfxq'
 				})
@@ -129,7 +175,7 @@
 				if (this.haveSelectRoom()) {
 					return
 				}
-				
+
 				uni.navigateTo({
 					url: '../sfxq/sfxq'
 				})

BIN
pagesElectric/static/images/ad_dianfei.jpg


BIN
static/images/ad_reshui.jpg


BIN
static/images/banner2x.png


BIN
static/images/qr-code.png