選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

moreHighMsg.vue 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <template>
  2. <div class="content">
  3. <div class="item" v-for="(item,index) in state.highMsgData" :key='index' @click="link(item)">
  4. <div class="left-content">
  5. <div class="description">{{item.title}}</div>
  6. <div class="mark">{{item.copywriting}}</div>
  7. </div>
  8. <image :src="fileURL + item.speedUrl"></image>
  9. </div>
  10. <view style="text-align: center;margin: 20rpx;" v-if="state.flags">我是有底线的</view>
  11. </div>
  12. </template>
  13. <script setup lang="ts">
  14. import {fileURL} from "@/datas/fileURL.js";
  15. import {onPageScroll,onLoad,onPullDownRefresh,onReachBottom} from "@dcloudio/uni-app";
  16. import {queryHighMsg} from "@/utils/network/api.js";
  17. import {reactive} from "vue";
  18. import {stringToJson} from "@/utils/network/encryption.js";
  19. import {request} from "@/utils/network/request.js";
  20. import {navTo} from "@/utils/utils";
  21. import {getCodeName} from "@/datas/queryKey.js";
  22. const state = reactive({
  23. highMsgData:[],
  24. flags:false,
  25. page:1,
  26. })
  27. onLoad(() => {
  28. highMsg(); //高速快讯
  29. })
  30. // 下拉刷新
  31. onPullDownRefresh(()=>{
  32. state.page=1
  33. state.highMsgData=[]
  34. state.flags=false
  35. console.log('refresh');
  36. setTimeout(()=>{
  37. highMsg()
  38. uni.stopPullDownRefresh()
  39. }, 500);
  40. })
  41. // 触底加载
  42. onReachBottom(()=>{
  43. if(state.highMsgData.length<state.page*8) return state.flags = true
  44. console.log("触底了")
  45. state.page++
  46. highMsg()
  47. })
  48. // 高速快讯查询接口
  49. const highMsg =()=>{
  50. let options = {
  51. type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
  52. data: {
  53. pageNo:state.page,
  54. pageSize:8
  55. }, //请求参数
  56. method: "POST", //提交方式(默认POST)
  57. showLoading: true, //是否显示加载中(默认显示)
  58. };
  59. //调用方式
  60. request(queryHighMsg, options).then((res) => {
  61. console.log("高速快讯查询接口",stringToJson(res.bizContent).data);
  62. state.highMsgData=[...stringToJson(res.bizContent).data,...state.highMsgData]
  63. console.log("state.highMsgData",state.highMsgData)
  64. // state.highMsgData=stringToJson(res.bizContent).data
  65. })
  66. .catch((err) => {
  67. });
  68. }
  69. const link=(item)=>{
  70. console.log("item",item)
  71. navTo(`item.hyperLink`)
  72. }
  73. </script>
  74. <style scoped>
  75. .content{
  76. background-color: #eef7f7;
  77. overflow: hidden;
  78. min-height: 100vh;
  79. }
  80. .item{
  81. width: 95%;
  82. margin:0 auto;
  83. margin-top: 30rpx;
  84. background-color: white;
  85. display: flex;
  86. padding: 20rpx 30rpx;
  87. box-sizing: border-box;
  88. justify-content: space-between;
  89. border-radius: 14rpx;
  90. font-size: 30rpx;
  91. }
  92. .item>image{
  93. width: 100rpx;
  94. height: 100rpx;
  95. border-radius: 10rpx;
  96. }
  97. .mark{
  98. font-size: 22rpx;
  99. display: inline-block;
  100. text-align: center;
  101. background: #bae0f1;
  102. border-radius: 6rpx;
  103. color: #0a8f8a;
  104. padding: 4rpx 8rpx;
  105. margin-top: 16rpx;
  106. }
  107. .left-content{
  108. width: 70%;
  109. }
  110. .description{
  111. overflow: hidden;
  112. -webkit-line-clamp: 2;
  113. text-overflow: ellipsis;
  114. display: -webkit-box;
  115. -webkit-box-orient: vertical;
  116. }
  117. </style>