he2802 4 anos atrás
pai
commit
14a095221c
3 arquivos alterados com 75 adições e 58 exclusões
  1. 64 51
      pages2/course/detail.vue
  2. 7 4
      pages2/wd/avatar.vue
  3. 4 3
      store/index.js

+ 64 - 51
pages2/course/detail.vue

@@ -241,50 +241,10 @@ export default {
 	},
 	onShow() {
 		let that = this;
-		const query = uni.createSelectorQuery().in(this);
-		query
-			.select('#modules1')
-			.boundingClientRect(data => {
-				that.h1 = data.height;
-				that.countHeight(that);
-			})
-			.exec();
-		query
-			.select('#modules2')
-			.boundingClientRect(data => {
-				that.h2 = data.height;
-				that.countHeight(that);
-			})
-			.exec();
-		query
-			.select('#modules3')
-			.boundingClientRect(data => {
-				that.h3 = data.height;
-				that.countHeight(that);
-			})
-			.exec();
-		query
-			.select('#modules4')
-			.boundingClientRect(data => {
-				that.h4 = data.height;
-				that.countHeight(that);
-			})
-			.exec();
-		query
-			.select('#foot')
-			.boundingClientRect(data => {
-				that.foot_h = data.height;
-				that.countModelusPadding();
-			})
-			.exec();
-		query
-			.select('#top')
-			.boundingClientRect(data => {
-				that.top_h = data.height;
-				that.countModelusPadding();
-			})
-			.exec();
 		this.windowHeight = uni.getSystemInfoSync().windowHeight;
+		setTimeout(function(){
+			that.getHeight()
+		},1800)
 	},
 	onPageScroll: function(e) {
 		//防止触发两次跳动
@@ -305,6 +265,54 @@ export default {
 		}
 	},
 	methods: {
+		getHeight(){
+			let that = this
+			const query = uni.createSelectorQuery().in(this);
+			query
+				.select('#modules1')
+				.boundingClientRect(data => {
+					that.h1 = data.height;
+					that.countHeight(that);
+				})
+				.exec();
+			query
+				.select('#modules2')
+				.boundingClientRect(data => {
+					that.h2 = data.height;
+					console.log(data.height,66)
+					that.countHeight(that);
+				})
+				.exec();
+			query
+				.select('#modules3')
+				.boundingClientRect(data => {
+					that.h3 = data.height;
+					that.countHeight(that);
+				})
+				.exec();
+			query
+				.select('#modules4')
+				.boundingClientRect(data => {
+					that.h4 = data.height;
+					console.log(data.height,4444)
+					that.countHeight(that);
+				})
+				.exec();
+			query
+				.select('#foot')
+				.boundingClientRect(data => {
+					that.foot_h = data.height;
+					that.countModelusPadding();
+				})
+				.exec();
+			query
+				.select('#top')
+				.boundingClientRect(data => {
+					that.top_h = data.height;
+					that.countModelusPadding();
+				})
+				.exec();
+		},
 		favoritesStatus() {
 			this.$api.coursecollectPD(this.queryData.courseId).then(result => {
 				if (result.data.data === undefined) {
@@ -339,11 +347,12 @@ export default {
 			}
 		},
 		getcommendList(v) {
+			let self = this
 			var data = {
 				courseId: v
 			};
 			this.$api.courseInforecommendList(data).then(res => {
-				this.commendList = res.data.data;
+				self.commendList = res.data.data;
 			});
 		},
 		activeList(item, index) {
@@ -375,6 +384,7 @@ export default {
 				if (res.data.code === 200) {
 					self.pageData = res.data.data;
 					self.getTeacher(res.data.data.teacherIds);
+
 				}
 			});
 		},
@@ -385,21 +395,24 @@ export default {
 			};
 			this.$api.coursechapterlist(data).then(res => {
 				var chaList = res.data.rows;
-				var dataset = {
-					chapterId: res.data.rows[0].chapterId
-				};
-				self.$api.coursesectionlist(dataset).then(result => {
-					self.getsec(result.data.rows[0]);
-				});
+				if(chaList.length>0){
+					var dataset = {
+						chapterId: res.data.rows[0].chapterId
+					};
+					self.$api.coursesectionlist(dataset).then(result => {
+						self.getsec(result.data.rows[0]);
+					});
+				}
 				this.chapterList = chaList;
 			});
 		},
 		getTeacher(v) {
+			let self = this
 			var data = {
 				teacherIds: v
 			};
 			this.$api.teacherList(data).then(res => {
-				this.teacherInfo = res.data.rows[0];
+				self.teacherInfo = res.data.rows[0];
 			});
 		},
 		startVideo() {

+ 7 - 4
pages2/wd/avatar.vue

@@ -4,11 +4,11 @@
 				<u-cell-item  title="头像" @click="editAvatar">
 					<image :src="userInfo!=null?$method.splitImgHost(avatarUrl):''" class="avatar"></image>
 				</u-cell-item>
-				<u-cell-item  title="昵称" :value="userInfo.nickname" @click="editNickName"></u-cell-item>
+				<u-cell-item  title="昵称" :value="nickname" @click="editNickName"></u-cell-item>
 			</u-cell-group>
 			<u-modal v-model="show" :show-cancel-button="true" title="修改昵称">
 				<view class="slot-content">
-					<u-input v-model="userInfo.nickname"  />
+					<u-input v-model="nickname"  />
 				</view>
 			</u-modal>
 			<view style="position: fixed;bottom: 50rpx;width: 100%;padding: 20rpx;">
@@ -25,7 +25,8 @@
 		data() {
 			return {
 				show: false,
-				avatarUrl:''
+				avatarUrl:'',
+				nickname:''
 			}
 		},
 		onLoad(option) {
@@ -33,6 +34,7 @@
 		},
 		onShow(){
 			this.avatarUrl = this.userInfo.avatar
+			this.nickname = this.userInfo.nickname
 		},
 		methods: {
 			imageInfos(){
@@ -123,7 +125,7 @@
 				});
 			},
 			submitForm(){
-				if(this.userInfo.nickname==''){
+				if(this.nickname==''){
 					uni.showModal({
 						title: "提示",
 						content: '昵称不能为空',
@@ -131,6 +133,7 @@
 					})
 					return
 				}
+				this.userInfo.nickname=this.nickname
 				this.submit()
 			},
 			async submit(){

+ 4 - 3
store/index.js

@@ -8,17 +8,18 @@ const store = new Vuex.Store({
         token: '',  
         avatarUrl: '',  
         userName: '',
-		userInfo:null
+		userInfo:{
+			avatar:''
+		}
     },  
 	 getters: {
 		userInfo: state => {
-			if(state.userInfo==null){
+			if(state.userInfo.avatar==''){
 				if(uni.getStorageSync('union_id')){
 					api.getInfo().then(resdata => {
 						if(resdata.data.code == 200){
 							state.userInfo = resdata.data.data;
 						}
-						
 					});
 				}