Browse Source

完善研究报告首页和列表页

littleblue55 5 ngày trước cách đây
mục cha
commit
c2ca77f49b

+ 24 - 0
api/report.js

@@ -0,0 +1,24 @@
+import request from '@/utils/request'
+
+// 获取报告分类
+export function getReportCate(){
+	return request({
+		'url': '/report/category',
+		headers: {
+			isToken: true
+		},
+		'method': 'get'
+	})
+}
+
+// 获取研究报告列表
+export function loadReportList(data){
+	return request({
+		'url': '/report/list',
+		headers: {
+			isToken: true
+		},
+		data: data,
+		'method': 'post'
+	})
+}

+ 2 - 6
pages/goOnEdu/course/courseHome/courseHome.vue

@@ -198,11 +198,6 @@
 		}catch(err){
 		}catch(err){
 			courses.value[index].hasFavi = courses.value[index].hasFavi
 			courses.value[index].hasFavi = courses.value[index].hasFavi
 		}
 		}
-		
-		
-		// 联调后端,
-		// 返回成功后
-		
 	}
 	}
 	// 初始化
 	// 初始化
 	function init() {
 	function init() {
@@ -223,7 +218,8 @@
 		});
 		});
 	}
 	}
 	onMounted(() => {
 	onMounted(() => {
-		isMember.value = authStore.userInfo.isMember
+		isMember.value = authStore.userInfo.isMember === 1 ? true : false
+		// console.log(authStore.userInfo.isMember)
 	    init();
 	    init();
 	    watch(currentTab, (newValue) => {
 	    watch(currentTab, (newValue) => {
 	        courseStore.setCurrentTab(newValue); // 如果需要在切换时更新 Pinia 状态
 	        courseStore.setCurrentTab(newValue); // 如果需要在切换时更新 Pinia 状态

+ 57 - 6
pages/researchReport/reportHome/reportHome.vue

@@ -2,7 +2,18 @@
 	<view class="container">
 	<view class="container">
 		<view v-show="menuCurrent === 0">
 		<view v-show="menuCurrent === 0">
 			<view class="menus-box">
 			<view class="menus-box">
-				<view class="menus-item-box" @click="toReportList('二手住宅市场')">
+				<view class="menus-item-box" 
+				@click="toReportList(key, data.value)" 
+				v-for="(data,key) in categoryList" 
+				:key="key">
+					<view class="icon-box">
+						<view class="iconfont icon-hetong"></view>
+					</view>
+					<view class="text-box">
+						{{ key }}
+					</view>
+				</view>
+				<!-- <view class="menus-item-box" @click="toReportList('二手住宅市场')">
 					<view class="icon-box">
 					<view class="icon-box">
 						<view class="iconfont icon-hetong"></view>
 						<view class="iconfont icon-hetong"></view>
 					</view>
 					</view>
@@ -25,7 +36,7 @@
 					<view class="text-box">
 					<view class="text-box">
 						房地产中介行业
 						房地产中介行业
 					</view>
 					</view>
-				</view>
+				</view> -->
 			</view>
 			</view>
 		</view>
 		</view>
 		<view v-show="menuCurrent === 1">
 		<view v-show="menuCurrent === 1">
@@ -116,6 +127,16 @@
 <script setup>
 <script setup>
 	import { ref, computed } from 'vue'
 	import { ref, computed } from 'vue'
 	import { onLoad } from '@dcloudio/uni-app'
 	import { onLoad } from '@dcloudio/uni-app'
+	import {
+		getReportCate
+	} from '@/api/report.js'
+	
+	import { useReportStore } from '@/store/reportStore.js'
+	
+	const reportStore = useReportStore();
+	
+	const categoryList = ref({});
+	
 	
 	
 	const customButtonStyle = {
 	const customButtonStyle = {
 		height: '40rpx',
 		height: '40rpx',
@@ -135,12 +156,39 @@
 		menuCurrent.value = index
 		menuCurrent.value = index
 	}
 	}
 	
 	
-	function toReportList(model) {
+	function toReportList(model, val) {
+		// console.log(model,val)
+		uni.setStorageSync("reportCate", categoryList.value[model].child);
 		uni.navigateTo({
 		uni.navigateTo({
-			url: `/pages/researchReport/reportList/reportList?model=${model}`
+			url: `/pages/researchReport/reportList/reportList?model=${model}&value=${val}`
 		})
 		})
 	}
 	}
 	
 	
+	async function init(){
+		const cateRes = await getReportCate();
+		if (cateRes.code === 0) {
+			const result = cateRes.data.reduce((acc, curr) => {
+				const modifiedChild = [{
+						value: " ",
+						label: "全部"
+					}, // 新增的默认项(value 为空格)
+					...curr.child.map(child => ({
+						value: child.code, // 将子对象的 code 改为 value
+						label: child.name
+					}))
+				];
+				acc[curr.name] = {
+					value: curr.code,
+					child: modifiedChild
+				};
+				return acc;
+			}, {});
+			categoryList.value = result;
+			reportStore.setReportCate(result);
+		}
+	}
+	
+	
 	const list = [
 	const list = [
 		{
 		{
 			id: '01',
 			id: '01',
@@ -282,9 +330,11 @@
 	}
 	}
 	
 	
 	onLoad((load) => {
 	onLoad((load) => {
+		// console.log(load,"reporthome")
 		if (load.menuCurrent) {
 		if (load.menuCurrent) {
 			menuCurrent.value = Number(load.menuCurrent)
 			menuCurrent.value = Number(load.menuCurrent)
 		}
 		}
+		init()
 	})
 	})
 
 
 </script>
 </script>
@@ -432,13 +482,14 @@
 		}
 		}
 		
 		
 		.bottom-block {
 		.bottom-block {
-			height: 112rpx;
+			// height: 112rpx;
+			height: calc(112rpx + env(safe-area-inset-bottom, 0));
 		}
 		}
 		.bottom-box {
 		.bottom-box {
 			padding: 5rpx 20rpx;
 			padding: 5rpx 20rpx;
 			background-color: $uni-bg-color-grey;
 			background-color: $uni-bg-color-grey;
 			border: 1rpx solid #E9E9E9;
 			border: 1rpx solid #E9E9E9;
-			
+			padding-bottom: calc(5rpx + env(safe-area-inset-bottom, 0));
 			@include bottomMagnet();
 			@include bottomMagnet();
 			
 			
 			.menu-box {
 			.menu-box {

+ 119 - 163
pages/researchReport/reportList/reportList.vue

@@ -2,35 +2,20 @@
 	<view class="container">
 	<view class="container">
 		<view class="header-box">
 		<view class="header-box">
 			<view class="search-box">
 			<view class="search-box">
-				<u-search
-					v-model="searchForm.keyword"
-					:clearabled="true"
-					bg-color="#E5E5E5"
-					:input-style="searchInputStyle"
-					placeholder="搜索您想要的内容"
-				></u-search>
+				<u-search v-model="searchForm.keyword" :clearabled="true" bg-color="#E5E5E5"
+					:input-style="searchInputStyle" placeholder="搜索您想要的内容" @search="toSearch"></u-search>
 			</view>
 			</view>
 			<view class="tab-box">
 			<view class="tab-box">
-				<u-tabs 
-					name="label"
-					:list="searchType"
-					:is-scroll="true"
-					v-model="searchForm.type"
-					@change="onSearchTypeChange"
-					font-size="24"
-					:bold="false"
-					inactive-color="#000000"
-					active-color="#000000"
-					:bar-style="{'background-color': '#2979ff'}"
-					:gutter="25"
-					height="45"
-				></u-tabs>
+				<u-tabs name="label" :list="searchType" :is-scroll="true" v-model="searchForm.type"
+					@change="onSearchTypeChange" font-size="24" :bold="false" inactive-color="#000000"
+					active-color="#000000" :bar-style="{'background-color': '#2979ff'}" :gutter="25"
+					height="45"></u-tabs>
 			</view>
 			</view>
 		</view>
 		</view>
 		<view class="list-box">
 		<view class="list-box">
 			<view class="list-item-box" v-for="item in list" :key="item.id" @click="onClickReport(item)">
 			<view class="list-item-box" v-for="item in list" :key="item.id" @click="onClickReport(item)">
 				<view class="image-box">
 				<view class="image-box">
-					<image :src="item.image" mode="aspectFill"></image>
+					<image :src="item.imgUrl" mode="aspectFill"></image>
 				</view>
 				</view>
 				<view class="info-box">
 				<view class="info-box">
 					<view class="title">
 					<view class="title">
@@ -52,201 +37,158 @@
 						</view>
 						</view>
 						<view v-if="item.free > 0" class="button free">免费</view>
 						<view v-if="item.free > 0" class="button free">免费</view>
 						<view v-else-if="item.memberFree > 0" class="button member-free">会员免费</view>
 						<view v-else-if="item.memberFree > 0" class="button member-free">会员免费</view>
-						<view v-else :class="['button', item.status > 0 ? 'free' : 'buy']">{{item.status > 0 ? '已购买' : '立即购买'}}</view>
+						<view v-else :class="['button', item.status > 0 ? 'free' : 'buy']">
+							{{item.status > 0 ? '已购买' : '立即购买'}}
+						</view>
 					</view>
 					</view>
 				</view>
 				</view>
 			</view>
 			</view>
 		</view>
 		</view>
+		<u-loadmore :status="status" margin-top="20" margin-bottom="20" @loadmore="loadmore"/>
 	</view>
 	</view>
 </template>
 </template>
 
 
 <script setup>
 <script setup>
-	import { ref, computed } from 'vue'
-	import { onLoad } from '@dcloudio/uni-app'
+	import {
+		ref,
+		computed
+	} from 'vue'
+	import {
+		onLoad
+	} from '@dcloudio/uni-app'
+	import {
+		loadReportList
+	} from '@/api/report.js'
+	import { useReportStore } from '@/store/reportStore.js'
+	const reportStore = useReportStore();
 	
 	
 	const customButtonStyle = {
 	const customButtonStyle = {
 		height: '40rpx',
 		height: '40rpx',
 		lineHeight: '40rpx',
 		lineHeight: '40rpx',
 		padding: '0 30rpx'
 		padding: '0 30rpx'
 	}
 	}
+
 	const searchInputStyle = {
 	const searchInputStyle = {
 		backgroundColor: '#E5E5E5'
 		backgroundColor: '#E5E5E5'
 	}
 	}
-	const searchType = [
-		{
+
+	const categoryList = ref({});
+	const pageNum = ref(1);
+	const pageSize = ref(10);
+	const count = ref(0);
+	const model = ref(null);
+	const status = ref('loadmore');
+	
+	const searchType = ref([{
 			label: '全部',
 			label: '全部',
-			value: 0
-		},
-		{
-			label: '每周成交简报',
-			value: 1
-		},
-		{
-			label: '月度成交简报',
-			value: 2
-		},
-		{
-			label: '经理人指数报告',
-			value: 3
-		},
-		{
-			label: '一周楼市资讯',
-			value: 4
-		},
-	]
+			value: ' '
+		}
+	])
+	// 对应tab的code
+	const currentType = ref(null); 
 	function onSearchTypeChange(val) {
 	function onSearchTypeChange(val) {
-		console.log('搜索表单', searchForm.value)
+		currentType.value = searchType.value[val].value;
+		pageNum.value = 1;
+		search(searchForm.value.keyword, 1, model.value, currentType.value);
 	}
 	}
 	const searchForm = ref({
 	const searchForm = ref({
 		keyword: '',
 		keyword: '',
 		type: 0
 		type: 0
 	})
 	})
-	
+
 	const modelName = ref()
 	const modelName = ref()
-	
-	const list = [
-		{
-			id: '01',
-			title: '2024年11月广州市中介促成二手住宅市场交易简报',
-			time: '2023年8月8日',
-			image: 'https://img.shetu66.com/2023/10/21/1697901453723364.png',
-			type: '月度成交简报',
-			price: '9.9',
-			memberPrice: '9.9',
-			notMemberPrice: null,
-			free: 0, // 是否免费
-			memberFree: 0, // 是否会员免费
-			status: 0, // 是否购买
-		},
-		{
-			id: '02',
-			title: '2024年11月广州市中介促成二手住宅市场交易简报',
-			time: '2023年8月8日',
-			image: 'https://img.shetu66.com/2023/12/13/1702403646894275.png',
-			type: '月度成交简报',
-			price: '9.9',
-			memberPrice: '9.9',
-			notMemberPrice: null,
-			free: 0, // 是否免费
-			memberFree: 0, // 是否会员免费
-			status: 1, // 是否购买
-		},
-		{
-			id: '03',
-			title: '2024年11月广州市中介促成二手住宅市场交易简报',
-			time: '2023年8月8日',
-			image: 'https://img.shetu66.com/2023/10/16/1697397333933789.png',
-			type: '月度成交简报',
-			price: null,
-			memberPrice: null,
-			notMemberPrice: null,
-			free: 1, // 是否免费
-			memberFree: 0, // 是否会员免费
-			status: 0, // 是否购买
-		},
-		{
-			id: '04',
-			title: '2024年11月广州市中介促成二手住宅市场交易简报',
-			time: '2023年8月8日',
-			image: 'https://img.shetu66.com/2023/10/24/1698106006242859.png',
-			type: '月度成交简报',
-			price: '9.9',
-			memberPrice: null,
-			notMemberPrice: null,
-			free: 0, // 是否免费
-			memberFree: 1, // 是否会员免费
-			status: 0, // 是否购买
-		},
-		{
-			id: '05',
-			title: '2024年11月广州市中介促成二手住宅市场交易简报',
-			time: '2023年8月8日',
-			image: 'https://static.fxbaogao.com/subject/cover/prod/361.jpg',
-			type: '月度成交简报',
-			price: '9.9',
-			memberPrice: null,
-			notMemberPrice: null,
-			free: 0, // 是否免费
-			memberFree: 1, // 是否会员免费
-			status: 0, // 是否购买
-		},
-		{
-			id: '06',
-			title: '2024年11月广州市中介促成二手住宅市场交易简报',
-			time: '2023年8月8日',
-			image: 'https://img.shetu66.com/2023/10/16/1697387221220874.png',
-			type: '月度成交简报',
-			price: null,
-			memberPrice: null,
-			notMemberPrice: '9.9',
-			free: 0, // 是否免费
-			memberFree: 1, // 是否会员免费
-			status: 1, // 是否购买
-		},
-		{
-			id: '07',
-			title: '2024年11月广州市中介促成二手住宅市场交易简报',
-			time: '2023年8月8日',
-			image: 'https://img.shetu66.com/2023/10/21/1697901453723364.png',
-			type: '月度成交简报',
-			price: null,
-			memberPrice: '9.9',
-			notMemberPrice: '19.9',
-			free: 0, // 是否免费
-			memberFree: 0, // 是否会员免费
-			status: 0, // 是否购买
-		},
-		{
-			id: '08',
-			title: '2024年11月广州市中介促成二手住宅市场交易简报',
-			time: '2023年8月8日',
-			image: 'https://img.shetu66.com/2023/12/13/1702403646894275.png',
-			type: '月度成交简报',
-			price: null,
-			memberPrice: '9.9',
-			notMemberPrice: '19.9',
-			free: 0, // 是否免费
-			memberFree: 0, // 是否会员免费
-			status: 1, // 是否购买
-		},
-	]
-	
+
+	const list = ref([])
+	const listFilter = ref([])
+
 	function onClickReport(report) {
 	function onClickReport(report) {
 		uni.navigateTo({
 		uni.navigateTo({
 			url: `/pages/reportDetail/reportDetail?id=${report.id}&title=${report.title}`
 			url: `/pages/reportDetail/reportDetail?id=${report.id}&title=${report.title}`
 		})
 		})
 	}
 	}
+
+	function init(){
+		searchForm.value.keyword = '';
+		pageNum.value = 1
+		search('', 1, model.value, currentType.value)
+	}
+	
+	function search(keyword, pageNumber, model, type, pageSize) {
+		status.value = 'loading'
+		const form = {
+			keyword,
+			model,
+			type,
+			pageNumber,
+			pageSize: pageSize ? pageSize : 10
+		}
+
+		loadReportList(form).then(res => {
+			if (res.code === 0) {
+				if (pageNumber === 1) {
+					list.value = res.data
+				} else {
+					list.value = [...list.value, ...res.data];
+				}
+				pageNum.value = pageNumber + 1;
+				count.value = res.count;
+				if(list.value.length===count.value){
+					status.value = 'nomore' 
+				}else{
+					status.value ='loadmore'
+				}
+			}
+		}).catch(()=>{
+			status.value ='loadmore'
+		})
+	}
+
+	function loadmore(){
+		search(searchForm.value.keyword, pageNum.value, model.value, currentType.value);
+	}
+	function toSearch(){
+		search(searchForm.value.keyword, 1, model.value, currentType.value);
+	}
 	
 	
 	onLoad((load) => {
 	onLoad((load) => {
 		if (load.model) {
 		if (load.model) {
+			// console.log(load, reportStore.reportCate , "传过来的值")
+			searchType.value = reportStore.reportCate[load.model].child;
+			
 			modelName.value = load.model
 			modelName.value = load.model
+			model.value = load.value
+			
+			currentType.value = searchType.value[0].value;
+			
 			uni.setNavigationBarTitle({
 			uni.setNavigationBarTitle({
 				title: modelName.value
 				title: modelName.value
 			})
 			})
+			init()
 		}
 		}
 	})
 	})
 </script>
 </script>
 
 
 <style lang="scss">
 <style lang="scss">
-$image-width: 230rpx;
-	
+	$image-width: 230rpx;
+
 	.container {
 	.container {
 		height: 100vh;
 		height: 100vh;
 		width: 100vw;
 		width: 100vw;
 		background-color: $uni-text-color-inverse;
 		background-color: $uni-text-color-inverse;
-		
+
 		.header-box {
 		.header-box {
 			padding: 0 20rpx;
 			padding: 0 20rpx;
 			background-color: $uni-text-color-inverse;
 			background-color: $uni-text-color-inverse;
 			@include topMagnet();
 			@include topMagnet();
 		}
 		}
-		
+
 		.search-box {
 		.search-box {
 			margin-bottom: 20rpx;
 			margin-bottom: 20rpx;
+
 			::v-deep(.u-search) {
 			::v-deep(.u-search) {
 				background-color: #e5e5e5;
 				background-color: #e5e5e5;
 				border-radius: 50rpx;
 				border-radius: 50rpx;
-				
+
 				.u-action {
 				.u-action {
 					width: 18%;
 					width: 18%;
 					background-color: $uni-color-primary;
 					background-color: $uni-color-primary;
@@ -260,20 +202,24 @@ $image-width: 230rpx;
 				}
 				}
 			}
 			}
 		}
 		}
-		
+
 		.list-box {
 		.list-box {
 			padding: 0 20rpx;
 			padding: 0 20rpx;
+
 			.list-item-box {
 			.list-item-box {
 				padding: 30rpx 20rpx;
 				padding: 30rpx 20rpx;
 				display: flex;
 				display: flex;
 				gap: 20rpx;
 				gap: 20rpx;
 				height: 210rpx;
 				height: 210rpx;
 				border-bottom: 5rpx solid #E6E6E6;
 				border-bottom: 5rpx solid #E6E6E6;
+
 				&:active {
 				&:active {
 					background-color: $uni-bg-color-hover;
 					background-color: $uni-bg-color-hover;
 				}
 				}
+
 				.image-box {
 				.image-box {
 					width: $image-width;
 					width: $image-width;
+
 					image {
 					image {
 						width: $image-width;
 						width: $image-width;
 						flex: 0 0 $image-width;
 						flex: 0 0 $image-width;
@@ -281,6 +227,7 @@ $image-width: 230rpx;
 						border-radius: $uni-card-border-radius;
 						border-radius: $uni-card-border-radius;
 					}
 					}
 				}
 				}
+
 				.info-box {
 				.info-box {
 					.title {
 					.title {
 						font-size: $uni-title-font-size-2;
 						font-size: $uni-title-font-size-2;
@@ -289,44 +236,53 @@ $image-width: 230rpx;
 						margin-bottom: 15rpx;
 						margin-bottom: 15rpx;
 						@include text-line-overflow(2);
 						@include text-line-overflow(2);
 					}
 					}
+
 					.type {
 					.type {
 						font-size: $uni-font-size-2;
 						font-size: $uni-font-size-2;
+
 						.iconfont {
 						.iconfont {
 							font-size: $uni-font-size-2;
 							font-size: $uni-font-size-2;
 							padding-right: 10rpx;
 							padding-right: 10rpx;
 						}
 						}
 					}
 					}
+
 					.func {
 					.func {
 						display: flex;
 						display: flex;
 						justify-content: space-between;
 						justify-content: space-between;
 						align-items: flex-end;
 						align-items: flex-end;
 						font-size: $uni-font-size-2;
 						font-size: $uni-font-size-2;
 						font-weight: bold;
 						font-weight: bold;
+
 						.button {
 						.button {
 							text-align: center;
 							text-align: center;
 							width: 130rpx;
 							width: 130rpx;
 						}
 						}
+
 						.price {
 						.price {
 							color: $uni-color-error;
 							color: $uni-color-error;
 							font-size: $uni-title-font-size-3;
 							font-size: $uni-title-font-size-3;
 						}
 						}
+
 						.not-member-price {
 						.not-member-price {
 							font-size: $uni-font-size-4;
 							font-size: $uni-font-size-4;
 							color: $uni-text-color-grey;
 							color: $uni-text-color-grey;
 							text-align: end;
 							text-align: end;
 						}
 						}
+
 						.buy {
 						.buy {
 							padding: 6rpx 25rpx;
 							padding: 6rpx 25rpx;
 							background-color: $uni-color-error;
 							background-color: $uni-color-error;
 							border-radius: $uni-card-border-radius;
 							border-radius: $uni-card-border-radius;
 							color: $uni-text-color-inverse;
 							color: $uni-text-color-inverse;
 						}
 						}
+
 						.free {
 						.free {
 							padding: 6rpx 25rpx;
 							padding: 6rpx 25rpx;
 							background-color: $uni-color-primary;
 							background-color: $uni-color-primary;
 							border-radius: $uni-card-border-radius;
 							border-radius: $uni-card-border-radius;
 							color: $uni-text-color-inverse;
 							color: $uni-text-color-inverse;
 						}
 						}
+
 						.member-free {
 						.member-free {
 							padding: 10rpx 20rpx;
 							padding: 10rpx 20rpx;
 							@include backgroundImg('https://sylwt.top/api/visitor/resources/image?name=/ydl/menber-center/bg-label.png');
 							@include backgroundImg('https://sylwt.top/api/visitor/resources/image?name=/ydl/menber-center/bg-label.png');
@@ -337,4 +293,4 @@ $image-width: 230rpx;
 			}
 			}
 		}
 		}
 	}
 	}
-</style>
+</style>

+ 24 - 0
store/reportStore.js

@@ -0,0 +1,24 @@
+import { defineStore } from 'pinia'
+
+export const useReportStore = defineStore('report', {
+	state: () => ({
+		reportCate: null
+	}),
+	actions: {
+		setReportCate(data) {
+		  this.reportCate = data
+		},
+		// 初始化时从Storage加载
+		loadReportCate() {
+		  this.reportCate = null
+		},
+		cleanReportCate() {
+			this.reportCate = null
+		}
+	},
+	getters: {
+		isReportCate(state){
+			return !!state.reportCate;
+		}
+	}
+})