Tang 4 лет назад
Родитель
Сommit
46f2635769
4 измененных файлов с 85 добавлено и 65 удалено
  1. 5 7
      common/request.js
  2. 66 47
      pages2/course/detail.vue
  3. 7 4
      pages2/wd/avatar.vue
  4. 7 7
      store/index.js

+ 5 - 7
common/request.js

@@ -53,19 +53,17 @@ export const myRequest = (options) => {
 		const res = await myRequest(datas)
 		if (res.data.code === 200) {
 			uni.setStorageSync('token', res.data.data.token)
-
-			var userInfo = {
+			
+			 var userInfo = {
 				url: '/getInfo',
 				method: 'get',
 			}
 			const resUser = await myRequest(userInfo)
 			if (resUser.data.code === 200) {
-				uni.setStorageSync('userInfo', res.data.data)
-				let onset = await myRequest(response)
-				return onset
-			}
+				store.state.userInfo = resUser.data.data
+			} 
 			let onset = await myRequest(response)
-			return onset
+			return onset 
 		} else {
 			uni.navigateTo({
 				url: '/pages/login/login'

+ 66 - 47
pages2/course/detail.vue

@@ -122,7 +122,7 @@
 				<view style="margin: 10rpx;">
 					<view class="tj_box" v-for="(item, index) in commendList" :key="index" @click="getNavTo(item)">
 						<image :src="$method.splitImgHost(item.coverUrl)" style="width: 320rpx;height: 160rpx;"></image>
-						<view style="font-size: 24rpx;color: #666666;d">{{ item.courseName }}</view>
+						<view style="font-size: 24rpx;color: #666666;text-align: left;">{{ item.courseName }}</view>
 						<view>
 							<u-row>
 								<u-col span="6">
@@ -162,7 +162,7 @@
 						<view
 							v-for="(item, index) in boxList"
 							:key="index"
-							style="height: 60rpx;line-height: 60rpx;border-bottom: 1rpx solid #eee;display: flex;align-items: center;justify-content: space-between;"
+							style="line-height: 60rpx;border-bottom: 1rpx solid #eee;display: flex;align-items: center;justify-content: space-between;padding: 15rpx 0;"
 							:style="infoData.sectionId === item.sectionId ? 'color:#1677ff;' : ''"
 							@click="getsec(item)"
 						>
@@ -246,50 +246,10 @@ export default {
 			this.favoritesStatus();
 		}
 		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) {
 		//防止触发两次跳动
@@ -310,6 +270,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) {
@@ -344,11 +352,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);
+
 				}
 			});
 		},
@@ -399,15 +409,24 @@ export default {
 				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(){

+ 7 - 7
store/index.js

@@ -14,14 +14,8 @@ const store = new Vuex.Store({
 		userInfo: state => {
 			if(state.userInfo==null){
 				if(uni.getStorageSync('union_id')){
-					api.getInfo().then(resdata => {
-						if(resdata.data.code == 200){
-							state.userInfo = resdata.data.data;
-						}
-						
-					});
+					getUserInfo(state)
 				}
-				
 			}
 			return state.userInfo
 		}
@@ -33,4 +27,10 @@ const store = new Vuex.Store({
         
     }  
 })  
+async function getUserInfo(state){
+	const resdata = await api.getInfo()
+	if(resdata.data.code == 200){
+		state.userInfo = resdata.data.data;
+	}
+}
 export default store