Explorar o código

修复bug:1.研究报告重新进入后还需要购买;2.课程购买后点击观看返回详情页刷新

littleblue55 hai 1 día
pai
achega
616dc9a763

+ 1 - 1
api/home.js

@@ -31,7 +31,7 @@ export function homeReportList() {
 	return request({
 		'url': '/home/report',
 		headers: {
-			isToken: false
+			isToken: true
 		},
 		'method': 'get'
 	})

+ 29 - 7
pages/goOnEdu/course/courseDetail/courseDetail.vue

@@ -56,7 +56,8 @@
 		ref, computed
 	} from 'vue'
 	import {
-		onLoad
+		onLoad,
+		onShow
 	} from '@dcloudio/uni-app'
 
 	const courseDetail = ref({});
@@ -147,7 +148,8 @@
 		loadCourseDetail(id).then(res => {
 			if (res?.data) {
 				courseDetail.value = res.data;
-				console.log(courseDetail, "课程详情")
+				showBuy.value = showBuyAction()
+				// console.log(courseDetail, "课程详情")
 			}
 		})
 	}
@@ -191,8 +193,7 @@
 
 		return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
 	}
-
-	const showBuy = computed(()=>{
+	function showBuyAction(){
 		if (courseDetail.value.viewMode === '2' &&
 			!isMember.value &&
 			!courseDetail.value.hasBuy &&
@@ -209,7 +210,26 @@
 		}
 		console.log(3)
 		return false
-	})
+	}
+	// const showBuy = computed(()=>{
+	// 	if (courseDetail.value.viewMode === '2' &&
+	// 		!isMember.value &&
+	// 		!courseDetail.value.hasBuy &&
+	// 		currentTab.value === 0) {
+	// 		console.log(1)
+	// 		return true
+	// 	}
+	// 	// 付费,不管是不是会员,并且没买的
+	// 	if (courseDetail.value.viewMode === '3' &&
+	// 		!courseDetail.value.hasBuy &&
+	// 		currentTab.value === 0) {
+	// 		console.log(2)
+	// 		return true
+	// 	}
+	// 	console.log(3)
+	// 	return false
+	// })
+	const showBuy = ref(false)
 	const isMember = computed(()=>{
 		return authStore.userInfo.isMember == '0' ? false : true
 	})
@@ -222,12 +242,14 @@
 		// isMember.value = authStore.userInfo.isMember == '0' ? false : true;
 		// console.log("是否是会员", isMember.value)
 		courseId.value = id
-		init(id)
-		getComment(id)
 		uni.setNavigationBarTitle({
 			title: name
 		});
 	})
+	onShow(()=>{
+		init(courseId.value)
+		getComment(courseId.value)
+	})
 </script>
 
 <style lang="scss" scoped>

+ 7 - 4
pages/goOnEdu/course/courseDetail/courseOrder.vue

@@ -175,6 +175,9 @@
 				})
 			}
 		})
+		// uni.navigateTo({
+		// 	url:"/pages/goOnEdu/course/courseDetail/coursePay?id="+ courseId.value
+		// })
 		// uni.redirectTo({
 		// 	url: "/pages/goOnEdu/course/courseDetail/coursePay?id=" + courseId.value
 		// })
@@ -202,7 +205,7 @@
 			url: '/pages/joinClub/joinClub'
 		})
 	}
-	
+
 	// 初始化
 	function init(id) {
 		loadCourseDetail(id).then(res => {
@@ -362,7 +365,7 @@
 		width: 100%;
 		display: flex;
 		justify-content: space-between;
-		padding: 40rpx 20rpx env(safe-area-inset-bottom, 0);
+		padding: 30rpx 20rpx calc(10rpx + env(safe-area-inset-bottom, 0));
 		background-color: #fff;
 		align-items: center;
 
@@ -373,7 +376,7 @@
 		}
 
 		.pay-btn {
-			width: 200rpx;
+			// width: 200rpx;
 			height: 70rpx;
 			line-height: 70rpx;
 			background-color: red;
@@ -385,4 +388,4 @@
 	.text-red {
 		color: red;
 	}
-</style>
+</style>

+ 7 - 8
pages/goOnEdu/course/courseDetail/coursePay.vue

@@ -12,7 +12,7 @@
 </template>
 
 <script setup>
-	import { ref } from 'vue'
+	import { ref, computed } from 'vue'
 	import { onLoad } from '@dcloudio/uni-app'
 	import configService from '@/utils/baseurl.js'
 	const FILE_URL = configService.FILE_URL;
@@ -20,10 +20,7 @@
 		useAuthStore
 	} from '@/store/authStore'
 	const authStore = useAuthStore();
-	const isMember = computed(() => {
-		authStore.loadUserInfo()
-		return authStore.userInfo.isMember == '0' ? false : true
-	})
+	const isMember = ref(null)
 	const toJoin = () =>{
 		uni.navigateTo({
 			url: '/pages/joinClub/joinClub'
@@ -35,13 +32,15 @@
 		// 	url:"/pages/goOnEdu/course/courseDetail/courseDetail?id=" + courseId.value
 		// })
 		uni.navigateBack({
-			delta: 1
+			delta: 2
 		});
 	}
 	onLoad((option) => {
 		const { id } = option
 		courseId.value = id
-		console.log('onLoad')
+		authStore.loadUserInfo()
+		isMember.value = authStore.userInfo.isMember == '0' ? false : true
+		// console.log('onLoad')
 	})
 </script>
 
@@ -67,7 +66,7 @@
 		}
 		.play-btn{
 			margin-top: 100rpx;
-			width: 200rpx;
+			// width: 200rpx;
 			height: 70rpx;
 			line-height: 70rpx;
 			background-color: #0069f6;

+ 2 - 5
pages/goOnEdu/index.vue

@@ -17,7 +17,7 @@
 		data() {
 			return {
 				FILE_URL: configService.FILE_URL,
-				netAppid: "",
+				netAppid: "wx65323471c83da344",
 				courseUrl: "/pages/goOnEdu/course/index"
 			};
 		},
@@ -32,10 +32,7 @@
 				}
 				uni.navigateToMiniProgram({
 					appId: this.netAppid, // 替换为你要跳转的小程序的AppID
-					path: '', // 目标小程序的页面路径,留空则默认为首页
-					extraData: {
-						foo: 'bar' // 传递给目标小程序的数据(可选)
-					},
+					path: 'pages/index/index', // 目标小程序的页面路径,留空则默认为首页
 					envVersion: 'release', // 指定要打开的小程序版本: release 或 trial
 					success(res) {
 						console.log('成功跳转到小程序', res);

+ 38 - 23
pages/index/index.vue

@@ -40,7 +40,7 @@
 						@click="toPage('/pages/researchReport/reportHome/reportHome')"></u-section>
 				</template>
 				<template v-slot:body>
-					<view v-if="reportList.length!=0">
+					<view v-if="reportList.length!=0" >
 						<view v-for="(data,index) in reportList" :key="index" class="u-body-item u-flex u-p-t-0 "
 							style="align-items: inherit;" @click="toReport(data.id, data.title)">
 							<image :src="data.cover" mode="aspectFill"></image>
@@ -180,18 +180,19 @@
 	const isMember = ref(false)
 
 	// 首页-轮播图
-	const swiperList = ref([{
-			imgUrl: 'https://tse3-mm.cn.bing.net/th/id/OIP-C.YKoZzgmubNBxQ8j-mmoTKAHaEK?rs=1&pid=ImgDetMain',
-			id: 1
-		},
-		{
-			imgUrl: 'https://pic3.zhimg.com/v2-e52354ffdbd94a8e0a7649eacd34a788_r.jpg?source=1940ef5c',
-			id: 2
-		},
-		{
-			imgUrl: 'https://desk-fd.zol-img.com.cn/t_s960x600c5/g4/M03/00/0C/Cg-4zFS8bC-Ie9zBADCvovJAqiEAATJ8wDX__cAMK-6184.jpg',
-			id: 3
-		},
+	const swiperList = ref([
+		// {
+		// 	imgUrl: 'https://tse3-mm.cn.bing.net/th/id/OIP-C.YKoZzgmubNBxQ8j-mmoTKAHaEK?rs=1&pid=ImgDetMain',
+		// 	id: 1
+		// },
+		// {
+		// 	imgUrl: 'https://pic3.zhimg.com/v2-e52354ffdbd94a8e0a7649eacd34a788_r.jpg?source=1940ef5c',
+		// 	id: 2
+		// },
+		// {
+		// 	imgUrl: 'https://desk-fd.zol-img.com.cn/t_s960x600c5/g4/M03/00/0C/Cg-4zFS8bC-Ie9zBADCvovJAqiEAATJ8wDX__cAMK-6184.jpg',
+		// 	id: 3
+		// },
 	])
 
 	const courseList = ref([{
@@ -252,9 +253,9 @@
 			isLogin: true,
 			title: '水平认证',
 			icon: 'icon-zhengshu-copy',
-			url: '跳转页面的路径',
+			url: 'pages/index/index',
 			toOtherApp: true,
-			otherAppId: '其他小程序的appid'
+			otherAppId: 'wx050c17d8b239da86'
 		},
 		{
 			id: 'report',
@@ -279,8 +280,8 @@
 			isLogin: true,
 			title: '会费缴交',
 			icon: 'icon-jinqian-jiage',
-			url: '跳转页面的路径',
-			toOtherApp: true,
+			url: '/pages/huiFeiJiaoJiao/huiFeiJiaoJiao',
+			toOtherApp: false,
 			otherAppId: '其他小程序的appid'
 		}
 	])
@@ -291,7 +292,17 @@
 	const jumpToPage = (data) => {
 		if (data.toOtherApp) {
 			// 跳转其他小程序
-			console.log("跳转至其他小程序", data.otherAppId)
+			wx.navigateToMiniProgram({
+				appId: data.otherAppId, // 例如:wx1234567890abcdef
+				path: data.url, // 跳转路径
+				envVersion: 'release', // 版本(develop/trial/release)
+				success(res) {
+					console.log('跳转成功');
+				},
+				fail(err) {
+					console.error('跳转失败', err);
+				}
+			});
 			return
 		}
 		if (data.isLogin) {
@@ -363,16 +374,18 @@
 				courseList.value = res.data
 			}
 		})
+		initReport()
+		// homeSetting().then(res=>{
+		// 	console.log(res)
+		// })
+	}
+	function initReport (){
 		homeReportList().then(res => {
 			if (res?.data) {
 				reportList.value = res.data
 			}
 		})
-		// homeSetting().then(res=>{
-		// 	console.log(res)
-		// })
 	}
-
 	function getCharCount() {
 		count().then(res => {
 			if (res && res.message === 'success') {
@@ -417,12 +430,14 @@
 		if (isLogin) {
 			// 登录后才请求消息数量
 			getCharCount()
+			initReport()
 			// 没有用户信息就加载一边
 			if (!isUserInfo) {
 				initUser();
 			} else {
 				isMember.value = authStore.userInfo.isMember === '0' ? false : true;
 			}
+
 		}
 
 	})
@@ -659,4 +674,4 @@
 			color: $uni-text-color;
 		}
 	}
-</style>
+</style>

+ 12 - 5
pages/initial/initial.vue

@@ -49,6 +49,9 @@
 	import {
 		useAuthStore
 	} from '@/store/authStore'
+	import {
+		me
+	} from '@/api/user.js'
 	const authStore = useAuthStore()
 	const userBook = ref(false)
 	const userBookModal = ref(false)
@@ -117,11 +120,15 @@
 					}else{
 						// 老用户,跳转至:首页
 						msgSuccess("授权成功!")
-						setTimeout(()=>{
-							uni.switchTab({
-								url: "/pages/index/index"
-							})
-						}, 1000)
+						let userRes = await me();
+						if(userRes && userRes?.code===0){
+							authStore.setUserInfo(userRes.data)
+							setTimeout(()=>{
+								uni.switchTab({
+									url: "/pages/index/index"
+								})
+							}, 1000)
+						}
 					}
 				}
 			}catch(err){

+ 1 - 1
pages/login/login.vue

@@ -33,7 +33,7 @@
 						立即登录
 					</view>
 				</view>
-				<view class="phone-form" v-if="loginType=='username'">
+				<view class="phone-form" v-if="loginType=='username'">
 					<view class="form-item">
 						<u-input height="80" placeholder="请输入账号" border-color="#d0d0d0" v-model="userNameForm.username"
 							:border="true" class="form-item-input" @confirm="userNameLoginHandle" />

+ 30 - 33
pages/register/register.vue

@@ -70,7 +70,8 @@
 					checkPwd: '', // 确认密码
 					phone: '', // 手机号码
 					userCode: '', // 身份证
-					sex: '' // 性别
+					sex: '', // 性别
+					openid: ''
 				},
 				radioList1: [{
 						name: '1',
@@ -140,52 +141,48 @@
 			},
 			submit() {
 				const that = this;
-				that.$refs.registerForm.validate((valid) => {
+				that.$refs.registerForm.validate(async (valid) => {
 					const form = {
 						...this.registerForm
 					};
 					form.password = encryptAESCBC(form.password);
 					form.checkPwd = encryptAESCBC(form.checkPwd);
-					register(form).then(res => {
-						if (res?.data) {
-							this.useAuthStore.setAuthToken(res.data.token);
-							// this.useAuthStore.setUserInfo({
-							// 	userId,
-							// 	zhangHao
-							// })
-							msgSuccess("注册成功");
-							this.initUser()
-							// setTimeout(() => {
-							// 	if(this.redirect){
-							// 		uni.removeStorageSync("redirect")
-							// 		uni.reLaunch({
-							// 			url: this.redirect.url+'?id='+this.redirect.id+'&title='+this.redirect.title
-							// 		})
-							// 	}else{
-							// 		uni.switchTab({
-							// 			url: "/pages/index/index"
-							// 		})
-							// 	}
-								
-							// }, 1000)
-						}
-					})
+					
+					const loginRes = await wx.login();
+					const code = loginRes.code;
+					let wxRes = await wxLoginOpenid({code})
+					if(wxRes && wxRes?.data){
+						const { openid, sessionKey } = wxRes.data
+						// this.useAuthStore.setOpenid(openid)
+						this.registerForm.openid = openid
+						form.openid = openid
+						register(form).then(res => {
+							if (res?.data) {
+								this.useAuthStore.setAuthToken(res.data.token);
+								msgSuccess("注册成功");
+								this.initUser()
+							}
+						})
+					}
+					
+					
 				})
 			},
 			async initUser(){
-				const loginRes = await wx.login();
-				const code = loginRes.code;
+				// const loginRes = await wx.login();
+				// const code = loginRes.code;
 				let userRes = await me();
-				let wxRes = await wxLoginOpenid({code})
+				// let wxRes = await wxLoginOpenid({code})
 				// 加载用户信息
 				if(userRes && userRes?.code===0){
 					this.useAuthStore.setUserInfo(userRes.data)
 				}
+				this.useAuthStore.setOpenid(this.registerForm.openid)
 				// 加载openid
-				if(wxRes && wxRes?.data){
-					const { openid, sessionKey } = wxRes.data
-					this.useAuthStore.setOpenid(openid)
-				}
+				// if(wxRes && wxRes?.data){
+				// 	const { openid, sessionKey } = wxRes.data
+				// 	this.useAuthStore.setOpenid(openid)
+				// }
 				setTimeout(() => {
 					if(this.redirect){
 						uni.removeStorageSync("redirect")

+ 4 - 1
pages/reportDetail/reportDetail.vue

@@ -257,9 +257,12 @@
 				payForm.value.desc = res.data.title
 				payForm.value.amount = isMember.value ? report.value.priceMember : report.value.price
 				report.value.content = ""
-				if(!report.value.hasBuy){
+				if(!report.value.hasBuy && res.data.viewMode === '3'){
+					buyShow.value = true
+				}else if(!report.value.hasBuy && !isMember.value && res.data.viewMode === '2' ){
 					buyShow.value = true
 				}
+				// console.log(report.value.hasBuy, res.data.viewMode, buyShow.value, 100)
 				if(res.data.imgData){
 					const path = res.data.imgData.path
 					const type = res.data.imgData.type

+ 2 - 2
utils/request.js

@@ -39,7 +39,7 @@ const request = config => {
 					showConfirm('登录状态已过期,您可以继续留在该页面,或者重新登录?').then(res => {
 						if (res.confirm) {
 							uni.reLaunch({
-								url: '/pages/login/login'
+								url: '/pages/initial/initial'
 							});
 						}
 					});
@@ -73,4 +73,4 @@ const request = config => {
 	});
 };
 
-export default request;
+export default request;