Explorar o código

locationId从接口获取

xuqiaoying %!s(int64=3) %!d(string=hai) anos
pai
achega
e21268e411
Modificáronse 2 ficheiros con 28 adicións e 6 borrados
  1. 8 0
      common/httpList/base.js
  2. 20 6
      pages/index/index.vue

+ 8 - 0
common/httpList/base.js

@@ -32,6 +32,14 @@ export default {
 			noToken: true
 		})
 	},
+	advertisingLocation(data) {
+		return myRequest({
+			url: '/app/common/base/advertising/adLocation',
+			method: 'get',
+			data: data,
+			noToken: true
+		})
+	},
 	advertisingList(data) {
 		return myRequest({
 			url: '/app/common/base/advertising/list',

+ 20 - 6
pages/index/index.vue

@@ -506,7 +506,8 @@ export default {
 		},
 		async getAdvertising() {
 			await this.advertisingHomeLocation();
-			await this.advertisingList();
+			await this.getLocation()
+			// await this.advertisingList();
 		},
 		
 		getUserSubscribeRecentExam() {
@@ -542,13 +543,26 @@ export default {
 				})
 			})
 		},
-		advertisingList() {
-			return new Promise(resolve => {
-				this.$api.advertisingList({locationId:1}).then(res => {
+		getLocation() {
+			this.$api.advertisingLocation({
+				platform: 1,
+				status: 1,
+				locationKey: 'home-banner'
+			}).then((res) => {
+				if (res.data.code == 200) {
+					let locationId = res.data.data && res.data.data[0].locationId || 1
+					console.log('locationId:', locationId);
+					this.advertisingList(locationId)
+				}
+			})
+		},
+		advertisingList(locationId) {
+			// return new Promise(resolve => {
+				this.$api.advertisingList({locationId: locationId}).then(res => {
 					this.list = res.data.rows;
-					resolve()
+					// resolve()
 				})
-			})
+			// })
 		},
 		jumpPage(){
 			this.$navTo.togo('/pages4/msg/index')