reportHome.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461
  1. <template>
  2. <view class="container">
  3. <view v-show="menuCurrent === 0">
  4. <view class="menus-box">
  5. <view class="menus-item-box"
  6. @click="toReportList(key, data.value)"
  7. v-for="(data,key) in categoryList"
  8. :key="key">
  9. <view class="icon-box">
  10. <view class="iconfont icon-hetong"></view>
  11. </view>
  12. <view class="text-box">
  13. {{ key }}
  14. </view>
  15. </view>
  16. <!-- <view class="menus-item-box" @click="toReportList('二手住宅市场')">
  17. <view class="icon-box">
  18. <view class="iconfont icon-hetong"></view>
  19. </view>
  20. <view class="text-box">
  21. 二手住宅市场
  22. </view>
  23. </view>
  24. <view class="menus-item-box" @click="toReportList('住宅租赁市场')">
  25. <view class="icon-box">
  26. <view class="iconfont icon-chengshi"></view>
  27. </view>
  28. <view class="text-box">
  29. 住宅租赁市场
  30. </view>
  31. </view>
  32. <view class="menus-item-box" @click="toReportList('房地产中介行业')">
  33. <view class="icon-box">
  34. <view class="iconfont icon-zhongjie"></view>
  35. </view>
  36. <view class="text-box">
  37. 房地产中介行业
  38. </view>
  39. </view> -->
  40. </view>
  41. </view>
  42. <view v-show="menuCurrent === 1">
  43. <view class="header-box">
  44. <view class="search-box">
  45. <u-search
  46. v-model="searchForm.keyword"
  47. :clearabled="true"
  48. bg-color="#E5E5E5"
  49. :input-style="searchInputStyle"
  50. placeholder="搜索您想要的内容"
  51. @search="searchHistory(searchForm.keyword, 1)"
  52. @custom="searchHistory(searchForm.keyword, 1)"
  53. ></u-search>
  54. </view>
  55. </view>
  56. <view class="list-box">
  57. <view class="list-item-box" v-for="item in list" :key="item.id" @click="onClickReport(item)">
  58. <view class="image-box">
  59. <image :src="item.imgUrl" mode="aspectFill"></image>
  60. </view>
  61. <view class="info-box">
  62. <view class="title">
  63. {{item.title}}
  64. </view>
  65. <view class="time">
  66. <span class="iconfont icon-time"></span>
  67. <span>{{item.time}}</span>
  68. </view>
  69. <view class="func">
  70. <view v-if="item.free > 0" class="button free">免费</view>
  71. <view v-else-if="item.memberFree > 0" class="button member-free">会员免费</view>
  72. <view v-else :class="['button', item.status > 0 ? 'free' : 'buy']">{{item.status > 0 ? '已购买' : '立即购买'}}</view>
  73. </view>
  74. </view>
  75. </view>
  76. </view>
  77. <!-- <u-loadmore :status="status" margin-top="20" margin-bottom="20"/> -->
  78. </view>
  79. <view v-show="menuCurrent === 2">
  80. <view class="header-box">
  81. <view class="search-box">
  82. <u-search
  83. v-model="searchForm.keyword"
  84. :clearabled="true"
  85. bg-color="#E5E5E5"
  86. :input-style="searchInputStyle"
  87. placeholder="搜索您想要的内容"
  88. @search="searchMy(searchForm.keyword, 1)"
  89. @custom="searchMy(searchForm.keyword, 1)"
  90. ></u-search>
  91. </view>
  92. </view>
  93. <view class="list-box">
  94. <view class="list-item-box" v-for="item in list2" :key="item.id" @click="onClickReport(item)">
  95. <view class="image-box">
  96. <image :src="item.imgUrl" mode="aspectFill"></image>
  97. </view>
  98. <view class="info-box">
  99. <view class="title">
  100. {{item.title}}
  101. </view>
  102. <view class="time">
  103. <span>购买时间:&nbsp;{{item.time}}</span>
  104. </view>
  105. <view class="func">
  106. <view class="price">实付款:{{item.price}}元</view>
  107. </view>
  108. </view>
  109. </view>
  110. </view>
  111. </view>
  112. <u-loadmore v-if="menuCurrent !== 0" :status="status" margin-top="20" margin-bottom="20" @loadmore="loadMore"/>
  113. <view class="bottom-block"></view>
  114. <view class="bottom-box">
  115. <view class="menu-box">
  116. <view class="menu-item-box" :class="{'is-active': menuCurrent === 0}" @click="onMenuClick(0)">
  117. <view class="iconfont icon-home"></view>
  118. <view class="text">首页</view>
  119. </view>
  120. <view class="menu-item-box" :class="{'is-active': menuCurrent === 1}" @click="onMenuClick(1)">
  121. <view class="iconfont icon-time"></view>
  122. <view class="text">我的浏览</view>
  123. </view>
  124. <view class="menu-item-box" :class="{'is-active': menuCurrent === 2}" @click="onMenuClick(2)">
  125. <view class="iconfont icon-baogao"></view>
  126. <view class="text">我的报告</view>
  127. </view>
  128. </view>
  129. </view>
  130. </view>
  131. </template>
  132. <script setup>
  133. import { ref, computed } from 'vue'
  134. import { onLoad } from '@dcloudio/uni-app'
  135. import {
  136. getReportCate,
  137. loadReportHistory,
  138. loadMyReport
  139. } from '@/api/report.js'
  140. import { useReportStore } from '@/store/reportStore.js'
  141. const reportStore = useReportStore();
  142. const categoryList = ref({});
  143. const pageNum = ref(1);
  144. const status = ref('nomore');
  145. const list = ref([]);
  146. const list2 = ref([]);
  147. const listCount = ref(0);
  148. const listCount2 = ref(0);
  149. const customButtonStyle = {
  150. height: '40rpx',
  151. lineHeight: '40rpx',
  152. padding: '0 30rpx'
  153. }
  154. const searchInputStyle = {
  155. backgroundColor: '#E5E5E5'
  156. }
  157. const searchForm = ref({
  158. keyword: '',
  159. type: 0
  160. })
  161. const menuCurrent = ref(0)
  162. function onMenuClick(index) {
  163. menuCurrent.value = index;
  164. searchForm.value.keyword = ""
  165. status.value = 'loadmore'
  166. if(index===1){
  167. // 浏览记录
  168. searchHistory("", 1)
  169. }else if(index===2){
  170. // 我的报告
  171. searchMy("", 1)
  172. }
  173. }
  174. function searchHistory(keyword, pageNumber, pageSize){
  175. status.value = 'loading'
  176. loadReportHistory({
  177. keyword,
  178. pageNumber: pageNumber,
  179. pageSize: pageSize?pageSize:10
  180. }).then(res=>{
  181. if(res.code===0){
  182. if(pageNumber===1){
  183. list.value = res.data
  184. }else{
  185. list.value = [...list.value, ...res.data]
  186. }
  187. listCount.value = res.count
  188. if(list.value.length === res.count){
  189. status.value = 'nomore'
  190. }else{
  191. status.value = 'loadmore'
  192. }
  193. pageNum.value = pageNumber + 1;
  194. }
  195. })
  196. }
  197. function searchMy(keyword, pageNumber, pageSize){
  198. status.value = 'loading'
  199. loadMyReport({
  200. keyword,
  201. pageNumber: pageNumber,
  202. pageSize: pageSize?pageSize:10
  203. }).then(res=>{
  204. if(res.code===0){
  205. if(pageNumber===1){
  206. list2.value = res.data
  207. }else{
  208. list2.value = [...list2.value, ...res.data]
  209. }
  210. listCount2.value = res.count
  211. if(list2.value.length === res.count){
  212. status.value = 'nomore'
  213. }else{
  214. status.value = 'loadmore'
  215. }
  216. pageNum.value = pageNumber + 1;
  217. }
  218. })
  219. }
  220. function toReportList(model, val) {
  221. uni.setStorageSync("reportCate", categoryList.value[model].child);
  222. uni.navigateTo({
  223. url: `/pages/researchReport/reportList/reportList?model=${model}&value=${val}`
  224. })
  225. }
  226. async function init(){
  227. const cateRes = await getReportCate();
  228. if (cateRes.code === 0) {
  229. const result = cateRes.data.reduce((acc, curr) => {
  230. const modifiedChild = [{
  231. value: " ",
  232. label: "全部"
  233. }, // 新增的默认项(value 为空格)
  234. ...curr.child.map(child => ({
  235. value: child.code, // 将子对象的 code 改为 value
  236. label: child.name
  237. }))
  238. ];
  239. acc[curr.name] = {
  240. value: curr.code,
  241. child: modifiedChild
  242. };
  243. return acc;
  244. }, {});
  245. categoryList.value = result;
  246. reportStore.setReportCate(result);
  247. }
  248. }
  249. function onClickReport(report) {
  250. uni.navigateTo({
  251. url: `/pages/reportDetail/reportDetail?id=${report.id}&title=${report.title}`
  252. })
  253. }
  254. function loadMore(){
  255. if(menuCurrent.value === 1){
  256. searchHistory(searchForm.value.keyword, pageNum.value)
  257. }else{
  258. searchMy(searchForm.value.keyword, pageNum.value)
  259. }
  260. }
  261. onLoad((load) => {
  262. // console.log(load,"reporthome")
  263. if (load.menuCurrent) {
  264. menuCurrent.value = Number(load.menuCurrent)
  265. }
  266. init()
  267. })
  268. </script>
  269. <style lang="scss" scoped>
  270. $image-width: 230rpx;
  271. .container {
  272. height: 100vh;
  273. width: 100vw;
  274. background-color: $uni-text-color-inverse;
  275. .header-box {
  276. padding: 0 20rpx;
  277. background-color: $uni-text-color-inverse;
  278. @include topMagnet();
  279. }
  280. .search-box {
  281. margin-bottom: 20rpx;
  282. ::v-deep(.u-search) {
  283. background-color: #e5e5e5;
  284. border-radius: 50rpx;
  285. .u-action {
  286. width: 18%;
  287. background-color: $uni-color-primary;
  288. border-radius: 50rpx;
  289. color: $uni-text-color-inverse;
  290. margin-right: 8rpx;
  291. font-size: 28rpx;
  292. line-height: 50rpx;
  293. letter-spacing: 3rpx;
  294. text-align: center;
  295. }
  296. }
  297. }
  298. .list-box {
  299. padding: 0 20rpx;
  300. .list-item-box {
  301. padding: 30rpx 20rpx;
  302. display: flex;
  303. gap: 20rpx;
  304. height: 210rpx;
  305. border-bottom: 5rpx solid #E6E6E6;
  306. &:active {
  307. background-color: $uni-bg-color-hover;
  308. }
  309. .image-box {
  310. width: $image-width;
  311. image {
  312. width: $image-width;
  313. flex: 0 0 $image-width;
  314. height: 100%;
  315. border-radius: $uni-card-border-radius;
  316. }
  317. }
  318. .info-box {
  319. .title {
  320. font-size: $uni-title-font-size-2;
  321. font-weight: bold;
  322. line-height: 40rpx;
  323. margin-bottom: 15rpx;
  324. @include text-line-overflow(2);
  325. }
  326. .time {
  327. font-size: $uni-font-size-2;
  328. color: $uni-text-color-grey;
  329. .iconfont {
  330. font-size: $uni-font-size-2;
  331. padding-right: 10rpx;
  332. }
  333. }
  334. .func {
  335. display: flex;
  336. justify-content: flex-end;
  337. font-size: $uni-font-size-2;
  338. font-weight: bold;
  339. .button {
  340. text-align: center;
  341. width: 130rpx;
  342. }
  343. .price {
  344. color: $uni-color-error;
  345. font-size: $uni-title-font-size-2;
  346. }
  347. .buy {
  348. padding: 6rpx 25rpx;
  349. background-color: $uni-color-error;
  350. border-radius: $uni-card-border-radius;
  351. color: $uni-text-color-inverse;
  352. }
  353. .free {
  354. padding: 6rpx 25rpx;
  355. background-color: $uni-color-primary;
  356. border-radius: $uni-card-border-radius;
  357. color: $uni-text-color-inverse;
  358. }
  359. .member-free {
  360. padding: 10rpx 20rpx;
  361. @include backgroundImg('http://www.gzrea.org.cn:8543/icon/wxmp/bg-label.png');
  362. color: $uni-text-color;
  363. }
  364. }
  365. }
  366. }
  367. }
  368. .menus-box {
  369. padding: 0 20rpx;
  370. .menus-item-box {
  371. width: 100%;
  372. padding: 35rpx 50rpx;
  373. margin-bottom: 35rpx;
  374. display: flex;
  375. gap: 30rpx;
  376. align-items: center;
  377. background-color: #006AF4;
  378. border-radius: $uni-card-border-radius;
  379. &:active {
  380. background-color: #005AF4;
  381. }
  382. .icon-box {
  383. width: 40%;
  384. text-align: center;
  385. width: 100rpx;
  386. height: 100rpx;
  387. line-height: 100rpx;
  388. text-align: center;
  389. border-radius: 50%;
  390. border: 3rpx solid $uni-text-color-inverse;
  391. background-color: #004DC9;
  392. .iconfont {
  393. font-size: 60rpx;
  394. color: $uni-text-color-inverse;
  395. }
  396. }
  397. .text-box {
  398. font-size: 50rpx;
  399. font-weight: bold;
  400. color: $uni-text-color-inverse;
  401. }
  402. }
  403. }
  404. .bottom-block {
  405. // height: 112rpx;
  406. height: calc(112rpx + env(safe-area-inset-bottom, 0));
  407. }
  408. .bottom-box {
  409. padding: 5rpx 20rpx;
  410. background-color: $uni-bg-color-grey;
  411. border: 1rpx solid #E9E9E9;
  412. padding-bottom: calc(5rpx + env(safe-area-inset-bottom, 0));
  413. @include bottomMagnet();
  414. .menu-box {
  415. height: 100rpx;
  416. display: flex;
  417. align-items: center;
  418. .menu-item-box {
  419. width: calc(100% / 3);
  420. text-align: center;
  421. .iconfont {
  422. font-size: 55rpx;
  423. }
  424. .text {
  425. font-size: $uni-font-size-2;
  426. }
  427. }
  428. .is-active {
  429. color: $uni-color-primary;
  430. }
  431. }
  432. }
  433. }
  434. </style>