beiliyouHome.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. <template>
  2. <view class="column " style="height: 100vh;" >
  3. <view class="top-content" >
  4. <!-- 搜索框 -->
  5. <view class="search-cont">
  6. <view class="inner">
  7. <image class="icon-search" src="/static/images/search.png" mode=""></image>
  8. <input type="text" v-model="keyword" placeholder="输入关键字搜索" confirm-type="search"
  9. @confirm="doSearch" placeholder-style="font-size:28rpx;color:#BBBBBB;font-family: PingFang SC;" />
  10. </view>
  11. </view>
  12. </view>
  13. <view class="bgf topguide" >
  14. <view class=" bold ml30 color3">以往会刊</view>
  15. <scroll-view
  16. scroll-x
  17. :refresher-enabled="true"
  18. class="scroll-container"
  19. @scrolltolower="loadMore"
  20. :scroll-left="scrollLeft"
  21. >
  22. <!-- 横向内容列表 -->
  23. <view class="item-list">
  24. <view v-for="(item, index) in guidelisttype" :key="index" class="item"
  25. @click="selguide(item.categoryId)" :class="{ 'active': selectedIndex === item.categoryId }">
  26. <view class="image-box ">
  27. <image :src="item.imageUrl" mode="aspectFill" ></image>
  28. <view class="fs28 mt10">{{item.categoryName}}</view>
  29. <view class="fs24 " style="color: #848484;font-weight: normal;"></view>
  30. </view>
  31. </view>
  32. <!-- 加载状态提示 -->
  33. <view @click="loadMore" class=" color9 fs24">{{statusA?"点击加载更多":"没有更多"}}</view>
  34. </view>
  35. </scroll-view>
  36. </view>
  37. <view class="ml30 mt30 bold color3 ">精选文章</view>
  38. <view style="flex: 1; overflow: hidden;" class="plr30 ptb20" >
  39. <scroll-view scroll-y="true" :refresher-enabled="isEnabled" style="height: 100%"
  40. :refresher-triggered="triggered" refresher-background="rgba(0,0,0,0)"
  41. @refresherrefresh="pullDownRefresh" @refresherrestore="triggered = false"
  42. :upper-threshold="100" :lower-threshold="40" @refresherabort="triggered = false"
  43. @scrolltolower="reachBottom">
  44. <view class="bgf guideitem mt60 " v-for='(item,index) in guidelist' :key="index" @click="toguide(item)">
  45. <image :src="item.imageUrl"
  46. mode="aspectFill"></image>
  47. <view class="column justify-between ptb30 mr30"
  48. style="height: calc(100% - 60rpx);width: calc(55% - 30rpx);float: right;">
  49. <view>
  50. <view>{{item.title}}</view>
  51. <view class="color6 fs28 text-ellipsis mt10">{{item.description?item.description:''}}</view>
  52. </view>
  53. <view class="justify-between align-center">
  54. <view class="justify-start align-center">
  55. <u-icon name="eye" color="#888" size="18"></u-icon>
  56. <view class="fs24 ">{{item.views}}</view>
  57. </view>
  58. <view class="u-border fs24 color3 ptb6 plr30 radius8">
  59. 点击阅读
  60. </view>
  61. </view>
  62. </view>
  63. </view>
  64. <u-loadmore :status="status" />
  65. </scroll-view>
  66. </view>
  67. </view>
  68. </template>
  69. <script>
  70. import {getbeilihometype,getbeilihomelist} from '@/api/doc.js'
  71. export default {
  72. data() {
  73. return {
  74. id:0,
  75. keyword:'',//搜索关键词
  76. guidelisttype:[],
  77. guidelist:[],
  78. selectedIndex:'',
  79. pageNum:1,
  80. pageSize: 5,
  81. triggered: false,
  82. isEnabled:true,
  83. status: 'nomore',
  84. // 分类分页
  85. pageNums:1,
  86. pageSizes:5,
  87. statusA:false,
  88. }
  89. },
  90. onLoad(option) {
  91. console.log(option)
  92. if (option.title) {
  93. uni.setNavigationBarTitle({
  94. title: option.title
  95. });
  96. }
  97. this.getclassification()
  98. },
  99. methods: {
  100. loadMore() {
  101. if (this.statusA) {
  102. this.pageNums++
  103. uni.showNavigationBarLoading()
  104. setTimeout(() => {
  105. this.getclassification() //触底 不穿执行else
  106. uni.hideNavigationBarLoading()
  107. }, 200);
  108. }
  109. },
  110. pullDownRefresh() {
  111. // 下拉
  112. this.triggered = true; //下拉了状态为true
  113. console.log(123)
  114. setTimeout(() => {
  115. this.triggered = false;
  116. uni.stopPullDownRefresh()
  117. this.pageNum = 1;
  118. this.getguideList('refresh') //触底 不穿执行else
  119. }, 1000)
  120. },
  121. reachBottom() {
  122. // status这个是加载状态
  123. console.log(123)
  124. if (this.status === 'loadmore') {
  125. this.status = 'loading'
  126. uni.showNavigationBarLoading()
  127. setTimeout(() => {
  128. this.pageNum++
  129. this.getguideList() //触底 不穿执行else
  130. uni.hideNavigationBarLoading()
  131. }, 1000);
  132. }
  133. },
  134. toguide(item){
  135. uni.navigateTo({
  136. url:'/pages_shopping/store/guideDetail?title='+item.title+'&id='+item.articleId
  137. })
  138. },
  139. doSearch(e){
  140. console.log(e)
  141. this.keyword=e.detail.value
  142. },
  143. selguide(id){
  144. this.selectedIndex=id
  145. this.guidelist=[]
  146. this.getguideList()
  147. },
  148. getclassification(){
  149. uni.showLoading({
  150. title: "加载中..."
  151. })
  152. const data={
  153. pageNum:this.pageNums,
  154. pageSize:this.pageSizes,
  155. }
  156. getbeilihometype(data).then(res=>{
  157. if(res.code==200){
  158. uni.hideLoading()
  159. if (res.data.isLastPage) {
  160. this.guidelisttype = [...this.guidelisttype, ...res.data.list]
  161. } else {
  162. this.guidelisttype = res.data.list
  163. this.selectedIndex=this.guidelisttype[0].categoryId
  164. }
  165. if ( res.data.isLastPage) {
  166. this.statusA = false
  167. } else {
  168. this.statusA = true
  169. }
  170. this.getguideList()
  171. }
  172. })
  173. },
  174. getguideList(type){
  175. // uni.showLoading({
  176. // title: "加载中..."
  177. // })
  178. const data={
  179. categoryId:this.selectedIndex,
  180. pageNum:this.pageNum,
  181. pageSize:this.pageSize
  182. }
  183. getbeilihomelist(data).then(res=>{
  184. if(res.code==200){
  185. // uni.hideLoading()
  186. if (type == 'refresh') {
  187. this.guidelist = res.data.list
  188. } else {
  189. // 加载更多 当前页和下一页合并
  190. this.guidelist = [...this.guidelist, ...res.data.list]
  191. }
  192. if ( res.data.isLastPage) {
  193. this.status = 'nomore'
  194. } else {
  195. this.status = 'loadmore'
  196. }
  197. }
  198. })
  199. }
  200. }
  201. }
  202. </script>
  203. <style lang="scss" scoped>
  204. .topguide{
  205. // position: fixed;
  206. z-index: 9;
  207. width: 100%;
  208. }
  209. .scroll-container{
  210. width: calc(100% - 40rpx);
  211. white-space: nowrap;
  212. background: #fff;
  213. padding: 10rpx 20rpx;
  214. z-index: 101;
  215. }
  216. .item-list {
  217. padding: 20rpx 0rpx;
  218. overflow-x: auto;
  219. box-sizing: border-box;
  220. display: flex;
  221. align-items: center;
  222. justify-content: flex-start;
  223. }
  224. /* 选中时的放大效果 */
  225. .item.active {
  226. transform: scale(1.15); /* 放大1.1倍 */
  227. margin-left: 20rpx;
  228. margin-right: 20rpx;
  229. font-weight: bold;
  230. border-radius: 20rpx;
  231. }
  232. .item {
  233. width: 300rpx;
  234. display: flex;
  235. flex-direction: column;
  236. align-items: flex-start;
  237. justify-content: flex-start;
  238. padding-bottom: 10rpx;
  239. transition: all 0.35s ease; /* 添加过渡动画 */
  240. .image-box{
  241. width: 210rpx;
  242. height: 340rpx;
  243. display: flex;
  244. flex-direction: column;
  245. image{
  246. width: 190rpx;
  247. height:340rpx;
  248. margin: 0 auto;
  249. }
  250. }
  251. }
  252. .loading-status {
  253. width: 200rpx;
  254. height: 200rpx;
  255. display: inline-flex;
  256. align-items: center;
  257. justify-content: center;
  258. color: #999;
  259. flex-shrink: 0;
  260. }
  261. .top-content{
  262. width: 100%;
  263. // position: fixed;
  264. top:0;
  265. left: 0;
  266. z-index: 10;
  267. }
  268. .search-cont{
  269. padding: 16upx 30upx;
  270. background-color: #FFFFFF;
  271. .inner{
  272. box-sizing: border-box;
  273. width: 100%;
  274. height: 72upx;
  275. background: #F7F7F7;
  276. border-radius: 36upx;
  277. display: flex;
  278. align-items: center;
  279. padding: 0 30upx;
  280. .icon-search{
  281. width: 28upx;
  282. height: 28upx;
  283. margin-right: 20upx;
  284. }
  285. input{
  286. height: 60upx;
  287. line-height: 60upx;
  288. flex: 1;
  289. }
  290. }
  291. }
  292. .guideitem{
  293. border-radius: 10rpx;
  294. box-shadow: 0px 0px 5px 2px rgba(0,0,0,0.05);
  295. padding: 20rpx;
  296. height: 300rpx;
  297. width: calc(100% -40rpx);
  298. position: relative;
  299. image{
  300. width: 250rpx;
  301. height:350rpx;
  302. border-radius: 8rpx;
  303. flex-shrink: 0; /* 禁止缩放 */
  304. position: absolute;
  305. top: -40rpx;
  306. box-shadow: 0px 0px 5px 2px rgba(0,0,0,0.05);
  307. }
  308. }
  309. </style>