reportList.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  1. <template>
  2. <view class="container">
  3. <view class="header-box">
  4. <view class="search-box">
  5. <u-search v-model="searchForm.keyword" :clearabled="true" bg-color="#E5E5E5"
  6. :input-style="searchInputStyle" placeholder="搜索您想要的内容" @search="toSearch"></u-search>
  7. </view>
  8. <view class="tab-box">
  9. <u-tabs name="label" :list="searchType" :is-scroll="true" v-model="searchForm.type"
  10. @change="onSearchTypeChange" font-size="24" :bold="false" inactive-color="#000000"
  11. active-color="#000000" :bar-style="{'background-color': '#2979ff'}" :gutter="25"
  12. height="45"></u-tabs>
  13. </view>
  14. </view>
  15. <view class="list-box">
  16. <view class="list-item-box" v-for="item in list" :key="item.id" @click="onClickReport(item)">
  17. <view class="image-box">
  18. <image :src="item.imgUrl" mode="aspectFill"></image>
  19. </view>
  20. <view class="info-box">
  21. <view class="title">
  22. {{item.title}}
  23. </view>
  24. <view class="type">
  25. <span>{{item.type}}</span>
  26. </view>
  27. <view class="func">
  28. <!-- 如果是免费,直接显示免费 -->
  29. <view v-if="item.viewMode==='1'" class="func-box" style="justify-content: flex-end;">
  30. <view class="button free" >免费</view>
  31. </view>
  32. <view v-else-if="item.viewMode==='2' && isMember" class="func-box">
  33. <view class="price">¥{{ item.price }}元</view>
  34. <view class="button member-free">会员免费</view>
  35. </view>
  36. <view v-else-if="item.viewMode==='2' && !isMember" class="func-box">
  37. <view style="flex: 0 0 auto;display: flex;align-items: center;">
  38. <view class="member-free">
  39. 会员免费
  40. </view>
  41. <view class="not-member-price">
  42. 非会员:¥{{item.price}}元
  43. </view>
  44. </view>
  45. <view :class="['button', item.hasBuy ? 'free' : 'buy']">
  46. {{item.hasBuy ? '已购买' : '立即购买'}}
  47. </view>
  48. </view>
  49. <view v-else-if="item.viewMode==='3' && item.price===item.priceMember" class="func-box">
  50. <view class="price">¥{{ item.price }}元</view>
  51. <view :class="['button', item.hasBuy ? 'free' : 'buy']">
  52. {{item.hasBuy ? '已购买' : '立即购买'}}
  53. </view>
  54. </view>
  55. <view v-else-if="item.viewMode==='3' && item.price!==item.priceMember" class="func-box">
  56. <view style="flex: 0 0 auto;display: flex;align-items: center;">
  57. <view class="member-free">
  58. {{`会员:${item.priceMember}元`}}
  59. </view>
  60. <view class="not-member-price">
  61. 非会员:¥{{item.price}}元
  62. </view>
  63. </view>
  64. <view :class="['button', item.hasBuy ? 'free' : 'buy']">
  65. {{item.hasBuy ? '已购买' : '立即购买'}}
  66. </view>
  67. </view>
  68. </view>
  69. </view>
  70. </view>
  71. </view>
  72. <u-loadmore :status="status" margin-top="20" margin-bottom="20" @loadmore="loadmore" />
  73. </view>
  74. </template>
  75. <script setup>
  76. import {
  77. ref,
  78. computed
  79. } from 'vue'
  80. import {
  81. onLoad
  82. } from '@dcloudio/uni-app'
  83. import {
  84. loadReportList
  85. } from '@/api/report.js'
  86. import {
  87. useReportStore
  88. } from '@/store/reportStore.js'
  89. import {
  90. useAuthStore
  91. } from '@/store/authStore.js'
  92. const reportStore = useReportStore();
  93. const authStore = useAuthStore();
  94. const customButtonStyle = {
  95. height: '40rpx',
  96. lineHeight: '40rpx',
  97. padding: '0 30rpx'
  98. }
  99. const searchInputStyle = {
  100. backgroundColor: '#E5E5E5'
  101. }
  102. const isMember = ref(false);
  103. const categoryList = ref({});
  104. const pageNum = ref(1);
  105. const pageSize = ref(10);
  106. const count = ref(0);
  107. const model = ref(null);
  108. const status = ref('loadmore');
  109. const searchType = ref([{
  110. label: '全部',
  111. value: ' '
  112. }])
  113. // 对应tab的code
  114. const currentType = ref(null);
  115. function onSearchTypeChange(val) {
  116. currentType.value = searchType.value[val].value;
  117. pageNum.value = 1;
  118. search(searchForm.value.keyword, 1, model.value, currentType.value);
  119. }
  120. const searchForm = ref({
  121. keyword: '',
  122. type: 0
  123. })
  124. const modelName = ref()
  125. const list = ref([
  126. // {
  127. // id: 66,
  128. // imgUrl: "http://www.gzrea.org.cn/upload/news/2025/03/teicvnoekviwelkv214234kk.png",
  129. // model: "二手住宅市场",
  130. // price: 0,
  131. // priceMember: 0,
  132. // title: "2025年2月从化区二手住宅市场交易简报",
  133. // type: "月度成交简报",
  134. // viewMode: "1",
  135. // viewObject: "4",
  136. // },
  137. // {
  138. // id: 33,
  139. // imgUrl: "http://www.gzrea.org.cn/upload/news/2025/03/teicvnoekviwelkv214234kk.png",
  140. // model: "二手住宅市场2",
  141. // price: 20,
  142. // priceMember: 30,
  143. // title: "2025年2月从化区二手住宅市场交易简报2",
  144. // type: "月度成交简报",
  145. // viewMode: "2",
  146. // viewObject: "4",
  147. // },
  148. // {
  149. // id: 663,
  150. // imgUrl: "http://www.gzrea.org.cn/upload/news/2025/03/teicvnoekviwelkv214234kk.png",
  151. // model: "二手住宅市场3",
  152. // price: 10,
  153. // priceMember: 40,
  154. // title: "2025年2月从化区二手住宅市场交易简报3",
  155. // type: "月度成交简报",
  156. // viewMode: "3",
  157. // viewObject: "4",
  158. // },
  159. // {
  160. // id: 663,
  161. // imgUrl: "http://www.gzrea.org.cn/upload/news/2025/03/teicvnoekviwelkv214234kk.png",
  162. // model: "二手住宅市场3",
  163. // price: 10,
  164. // priceMember: 10,
  165. // title: "2025年2月从化区二手住宅市场交易简报3",
  166. // type: "月度成交简报",
  167. // viewMode: "3",
  168. // viewObject: "4",
  169. // },
  170. ])
  171. const listFilter = ref([])
  172. function onClickReport(report) {
  173. uni.navigateTo({
  174. url: `/pages/reportDetail/reportDetail?id=${report.id}&title=${report.title}`
  175. })
  176. }
  177. function init() {
  178. searchForm.value.keyword = '';
  179. pageNum.value = 1
  180. search('', 1, model.value, currentType.value)
  181. }
  182. function search(keyword, pageNumber, model, type, pageSize) {
  183. status.value = 'loading'
  184. const form = {
  185. keyword,
  186. model,
  187. type,
  188. pageNumber,
  189. pageSize: pageSize ? pageSize : 10
  190. }
  191. loadReportList(form).then(res => {
  192. // console.log(res)
  193. if (res.code === 0) {
  194. if (pageNumber === 1) {
  195. list.value = res.data
  196. } else {
  197. list.value = [...list.value, ...res.data];
  198. }
  199. pageNum.value = pageNumber + 1;
  200. count.value = res.count;
  201. if(list.value.length===count.value){
  202. status.value = 'nomore'
  203. }else{
  204. status.value ='loadmore'
  205. }
  206. }
  207. }).catch(() => {
  208. status.value = 'loadmore'
  209. })
  210. }
  211. function loadmore() {
  212. search(searchForm.value.keyword, pageNum.value, model.value, currentType.value);
  213. }
  214. function toSearch() {
  215. search(searchForm.value.keyword, 1, model.value, currentType.value);
  216. }
  217. onLoad((load) => {
  218. isMember.value = authStore.userInfo.isMember === '0' ? false : true;
  219. if (load.model) {
  220. // console.log(load, reportStore.reportCate , "传过来的值")
  221. searchType.value = reportStore.reportCate[load.model].child;
  222. modelName.value = load.model
  223. model.value = load.value
  224. currentType.value = searchType.value[0].value;
  225. uni.setNavigationBarTitle({
  226. title: modelName.value
  227. })
  228. init()
  229. }
  230. })
  231. </script>
  232. <style lang="scss">
  233. $image-width: 230rpx;
  234. .container {
  235. height: 100vh;
  236. width: 100vw;
  237. background-color: $uni-text-color-inverse;
  238. .header-box {
  239. padding: 0 20rpx;
  240. background-color: $uni-text-color-inverse;
  241. @include topMagnet();
  242. }
  243. .search-box {
  244. margin-bottom: 20rpx;
  245. ::v-deep(.u-search) {
  246. background-color: #e5e5e5;
  247. border-radius: 50rpx;
  248. .u-action {
  249. width: 18%;
  250. background-color: $uni-color-primary;
  251. border-radius: 50rpx;
  252. color: $uni-text-color-inverse;
  253. margin-right: 8rpx;
  254. font-size: 28rpx;
  255. line-height: 50rpx;
  256. letter-spacing: 3rpx;
  257. text-align: center;
  258. }
  259. }
  260. }
  261. .list-box {
  262. padding: 0 20rpx;
  263. .list-item-box {
  264. padding: 30rpx 20rpx;
  265. display: flex;
  266. gap: 20rpx;
  267. // height: 210rpx;
  268. border-bottom: 5rpx solid #E6E6E6;
  269. &:active {
  270. background-color: $uni-bg-color-hover;
  271. }
  272. .image-box {
  273. width: $image-width;
  274. image {
  275. width: $image-width;
  276. flex: 0 0 $image-width;
  277. height: 100%;
  278. border-radius: $uni-card-border-radius;
  279. }
  280. }
  281. .info-box {
  282. .title {
  283. font-size: $uni-title-font-size-2;
  284. font-weight: bold;
  285. line-height: 40rpx;
  286. margin-bottom: 15rpx;
  287. @include text-line-overflow(2);
  288. }
  289. .type {
  290. font-size: $uni-font-size-2;
  291. .iconfont {
  292. font-size: $uni-font-size-2;
  293. padding-right: 10rpx;
  294. }
  295. }
  296. .func {
  297. display: flex;
  298. justify-content: space-between;
  299. align-items: flex-end;
  300. font-size: $uni-font-size-2;
  301. font-weight: bold;
  302. margin-top: 10rpx;
  303. .func-box {
  304. display: flex;
  305. justify-content: space-between;
  306. width: 100%;
  307. align-items: center;
  308. }
  309. .button {
  310. text-align: center;
  311. width: 130rpx;
  312. }
  313. .price {
  314. color: $uni-color-error;
  315. font-size: $uni-title-font-size-3;
  316. }
  317. .not-member-price {
  318. font-size: $uni-font-size-4;
  319. color: $uni-text-color-grey;
  320. text-align: end;
  321. }
  322. .buy {
  323. padding: 6rpx 25rpx;
  324. background-color: $uni-color-error;
  325. border-radius: $uni-card-border-radius;
  326. color: $uni-text-color-inverse;
  327. }
  328. .free {
  329. padding: 6rpx 25rpx;
  330. background-color: $uni-color-primary;
  331. border-radius: $uni-card-border-radius;
  332. color: $uni-text-color-inverse;
  333. }
  334. .member-free {
  335. padding: 10rpx 20rpx;
  336. @include backgroundImg('http://www.gzrea.org.cn:8543/icon/wxmp/bg-label.png');
  337. color: $uni-text-color;
  338. }
  339. }
  340. }
  341. }
  342. }
  343. }
  344. </style>